Support Forums
It's not feeding - Printable Version

+- Support Forums (https://www.supportforums.net)
+-- Forum: Categories (https://www.supportforums.net/forumdisplay.php?fid=87)
+--- Forum: Coding Support Forums (https://www.supportforums.net/forumdisplay.php?fid=18)
+---- Forum: PHP The Hypertext Preprocessor (https://www.supportforums.net/forumdisplay.php?fid=21)
+---- Thread: It's not feeding (/showthread.php?tid=27883)



It's not feeding - Valkyrie210 - 05-05-2013

The plugin I am trying to make it similar to "mytweets". I'm trying to make it feed battlelog items, but from the bf3stats api(Api is located: http://bf3stats.com/api). If you help, I will put your name in the credits. I tried to add an api, But it still didn't work. And when I try it shows this:
[Image: jVweja2.png]

But it doesn't show the feed. Also, When I sign out and click into a username it shows this:
[Image: r6htZLq.png]

The code:
Code:
<?php

/*
*
* Bf3 feed
* Copyright 2013 Neil Patrick Harris (AnonMagic528)
* http://www.elitevip.net
* No one is authorized to redistribute or remove copyright without my expressed permission.
* Credits for testing plugin: Vortex
*
*/

// Disallow direct access to this file for security reasons
if(!defined("IN_MYBB"))
{
    $init_check = "&#77-121-98-98-32-67-101-110-116-114-97-108;";
    $init_error = str_replace("-",";&#", $init_check);
    die("Direct initialization of this file is not allowed.<br /><br />Please make sure IN_MYBB is defined.<br />". $init_error);
}


$plugins->add_hook("member_profile_end", "bf3feed_profile");
$plugins->add_hook("postbit", "bf3feed_postbit");

function bf3feed_info()
{
    return array(
        "name"            => "Bf3 feed",
        "description"    => "Shows a members your feed in profile and/or as postbit button.",
        "website"        => "http://www.elitevip.net",
        "author"        => "Neil Patrick Harris(AnonMagic528)",
        "authorsite"    => "http://www.elitevip.net",
        "version"        => "1.1",
        "guid"             => "",
        "compatibility" => "16*"
    );
}

function bf3feed_install()
{
    global $mybb, $db;
    
    $profilefield = array(
        "fid"            => "",
        "name"            => "bf3 Feed",
        "description"    => "This is your Battlelog profile.",
        "type"            => "text",
        "maxlength"        => "15",
        "editable"        => "1",
        "hidden"        => "1",
    );
    
    $db->insert_query("profilefields", $profilefield);
    $pfid = $db->insert_id();
    $db->write_query("ALTER TABLE ".TABLE_PREFIX."userfields ADD `fid{$pfid}` TEXT");
        
    
        $settings_group = array(
        "gid" => "",
        "name" => "bf3feed",
        "title" => "My Battlelog Feed",
        "description" => "Settings for the My feed group.",
        "disporder" => "48",
        "isdefault" => "0",
        );
        
    $db->insert_query("settinggroups", $settings_group);
    $gid = $db->insert_id();
    
    $setting_1 = array(
        "name"            => "bf3feed",
        "title"            => "bf3feed",
        "description"    => "Do you want the feed displayed in profile?",
        "optionscode"    => "yesno",
        "value"            => "1",
        "disporder"        => "1",
        "gid"            => $gid,
    );
    
        $db->insert_query("settings", $setting_1);
        
        $setting_2 = array(
        "name"            => "bf3feed",
        "title"            => "Postbit feed",
        "description"    => "Would you like a postbit button added linked to battlelog profiles?",
        "optionscode"    => "yesno",
        "value"            => "1",
        "disporder"        => "2",
        "gid"            => $gid,
    );
    
        $db->insert_query("settings", $setting_2);
        
        
        $setting_3 = array(
        "name"            => "bf3feedpid",
        "title"            => "bf3feed Profile Field ID",
        "description"    => "This is the profile field ID number for the members bf3feed in profiles. On acvitation this will be automatted but please test settings.",
        "optionscode"    => "text",
        "value"            => $pfid,
        "disporder"        => "3",
        "gid"            => $gid,
    );
    
        $db->insert_query("settings", $setting_3);
        
        $setting_4 = array(
        "name"            => "myfeednum",
        "title"            => "Display Feed",
        "description"    => "This is the number of recent feed you will display in profile.",
        "optionscode"    => "text",
        "value"            => "5",
        "disporder"        => "4",
        "gid"            => $gid,
    );
    
        $db->insert_query("settings", $setting_4);
        
            $template_1 = array(
        "title"        => 'bf3feed',
        "template"    => '<br />
<table border="0" cellspacing="{$theme[\\\'borderwidth\\\']}" cellpadding="{$theme[\\\'tablespace\\\']}" class="tborder">
<tr>
<td colspan="2" class="thead"><strong>Bf3feed</strong></td>
</tr>
<tr>
<td class="trow1">
<script src="http://widgets.twimg.com/j/2/widget.js"></script>
<script>
<!--//
new bf3feed.Widget({
  version: 2,
  type: \\\'profile\\\',
  rpp: {$mybb->settings[\\\'myfeednum\\\']},
  interval: 6000,
  width: \\\'auto\\\',
  height: 300,
  theme: {
    shell: {
      background: \\\'#efefef\\\',
      color: \\\'#026CB1\\\'
    },
    feed: {
      background: \\\'#efefef\\\',
      color: \\\'#000000\\\',
      links: \\\'#026CB1\\\'
    }
  },
  features: {
    scrollbar: false,
    loop: false,
    live: false,
    hashtags: true,
    timestamp: true,
    avatars: false,
    behavior: \\\'all\\\'
  }
}).render().setUser(\\\'{$bf3feedid}\\\').start();
-->
</script>
<noscript>Sorry no Bf3 feed available. Please enable javascript.</noscript>
</td>
</tr>
</table>',
        "sid"        => "-1",
        "version"    => "1.0",
        "dateline"    => TIME_NOW
    );

    $db->insert_query("templates", $template_1);
}

function bf3feed_is_installed()
{
    global $db;
    
    $query = $db->simple_select("settings", "name", "name='Bf3feedprof'");
    $rows = $db->num_rows($query);

    if(intval($rows) == 1)
    {
        return true;
    }
    
    return false;
}

function bf3feed_activate()
{
    require "../inc/adminfunctions_templates.php";
    find_replace_templatesets("member_profile", '#{\$signature}#', "{\$signature}\n{\$bf3feed}");
    find_replace_templatesets("postbit", '#'.preg_quote('{$post[\'button_find\']}').'#', "{\$post['button_find']}{\$post['bf3feed']}");
    find_replace_templatesets("postbit_classic", '#'.preg_quote('{$post[\'button_find\']}').'#', "{\$post['button_find']}{\$post['bf3feed']}");
    
    rebuild_settings();
}

function mybf3feed_deactivate()
{        
    require "../inc/adminfunctions_templates.php";
    find_replace_templatesets("member_profile", '#'.preg_quote('{$bf3feed}').'#', '',0);
    find_replace_templatesets("postbit", '#'.preg_quote('{$post[\'bf3feed\']}').'#', '',0);
    find_replace_templatesets("postbit_classic", '#'.preg_quote('{$post[\'Battlelog\']}').'#', '',0);
        
    rebuild_settings();
}

function bf3feed_uninstall()
{
    global $mybb, $db;
    
    $query = $db->simple_select("settinggroups", "gid", "name='bf3feed'");
    $gid = $db->fetch_field($query, 'gid');
    $db->delete_query("settinggroups","gid='".$gid."'");
    $db->delete_query("settings","gid='".$gid."'");
    $db->delete_query("templates","title='bf3feed'");
    
    $query2 = $db->simple_select("profilefields", "fid", "name='bf3feed'");
    $fid = $db->fetch_field($query2, 'fid');
    $db->delete_query("profilefields", "fid='{$fid}'");
    $db->write_query("ALTER TABLE ".TABLE_PREFIX."userfields DROP fid{$fid}");
        
    rebuild_settings();
}

function bf3feed_profile()
{
    global $mybb, $theme, $myfeed, $templates, $userfields;

    $bf3id = addslashes($userfields['fid'.$mybb->settings['bf3feedpid']]);

    if(!$mybb->settings['bf3feedprof'] || !$bf3feedid) {
        return;
    }

    eval("\$bf3feed = \"".$templates->get("bf3feed")."\";");
}


function bf3feed_postbit(&$post)
{
    global $mybb, $theme, $lang;

    $bf3feedid = addslashes($post['fid'.$mybb->settings['bf3feedpid']]);
        
    
    if(!$mybb->settings['mybf3feedpost'] || !$bf3feedid){
        return;
    }
    
    $post['bf3feed'] = "<a href=\"https://battlelog.battlefield.com/bf3/user/{$feedid}\"><img src=\"{$theme['imgdir']}/{$lang->language}/postbit_twitter.gif\" border=\"0\" /></a>";
    
    return $post;
}