MyBB Hacks

Full Version: profile plugin
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
i'm trying to make a profile plugin but i start testing it with db updates with with the msn button but msn won't work can you check heres the whole plugin:

PHP Code:
<?php
if(!defined("IN_MYBB"))
{
    die("Direct initialization of this file is not allowed.<br /><br />Please make sure IN_MYBB is defined.");
} 
//All the information about the plugin. These will appear in the plugins list.
function pp_info()
{
    return array(
        "name"          => "Posting profile icon",
        "description"   => "The profile icon plugin let you see the contact details in their posting profile",
        "website"       => "http://www.phcompany.info/plugins",
        "author"        => "pachel	",
        "authorsite"    => "http://www.phcompany.info/plugins",
        "version"       => "0.5",
    );
}

//All the activation processes go here
function pp_activate()
{

require MYBB_ROOT.'/inc/adminfunctions_templates.php';
find_replace_templatesets("postbit_author_user", '#'.preg_quote('{$post[\'replink\']}<br />').'#' , '{$post[\'replink\']}<br />
<a href="private.php?action=send&amp;uid={$post[\'uid\']}">{$lang->send_pm[\'username\']}<img src="images/pm.png" border="0" /></a>
<a href="javascript:;" onclick="MyBB.popupWindow(\'misc.php?action=imcenter&amp;imtype=icq&amp;uid={$post[\'uid\']}\', \'imcenter\', 450, 300);"><img src="images/icq.gif"></a>
<a href="javascript:;" onclick="MyBB.popupWindow(\'misc.php?action=imcenter&amp;imtype=aim&amp;uid={$post[\'uid\']}\', \'imcenter\', 450, 300);"><img src="images/aim.gif"></a>
<a href="javascript:;" onclick="MyBB.popupWindow(\'misc.php?action=imcenter&amp;imtype=yahoo&amp;uid={$post[\'uid\']}\', \'imcenter\', 450, 300);"><img src="images/yahoo.gif"></a>
{$post[\'msndet\']}');

}

//All deactivation processes go here
function pp_deactivate()
{

require MYBB_ROOT.'/inc/adminfunctions_templates.php';
find_replace_templatesets("postbit_author_user", '#'.preg_quote('{$post[\'replink\']}<br />
<a href="private.php?action=send&amp;uid={$post[\'uid\']}">{$lang->send_pm[\'username\']}<img src="images/pm.png" border="0" /></a>
<a href="javascript:;" onclick="MyBB.popupWindow(\'misc.php?action=imcenter&amp;imtype=icq&amp;uid={$post[\'uid\']}\', \'imcenter\', 450, 300);"><img src="images/icq.gif"></a>
<a href="javascript:;" onclick="MyBB.popupWindow(\'misc.php?action=imcenter&amp;imtype=aim&amp;uid={$post[\'uid\']}\', \'imcenter\', 450, 300);"><img src="images/aim.gif"></a>
<a href="javascript:;" onclick="MyBB.popupWindow(\'misc.php?action=imcenter&amp;imtype=yahoo&amp;uid={$post[\'uid\']}\', \'imcenter\', 450, 300);"><img src="images/yahoo.gif"></a>
{$post[\'msndet\']}').'#s' , '{$post[\'replink\']}<br />',0);

} 

function parse_details()
{	
global $db, $mybb;

	if ($post['msn'])
	{
                $query = $db->query("select * FROM ".TABLE_PREFIX."userfields WHERE name='msn");
		$ffid = $db->fetch_array($query);
		$fid = $ffid['fid'];
		$source = "fid".$fid;
		if ($post[$source] != '') 
		{
			$post['msndet'] = "<a href=\"javascript:onclick='MyBB.popupWindow(\\'misc.php?action=imcenter&amp;imtype=msn&amp;uid={$post['uid']}\\', \\'imcenter\\', 450, 300);\">{$post['msn']}<img src=\"images/msn.gif\"></a><br />";
		}

	} 
	else 
	{
          $ffid = $db->fetch_array($query);
		$fid = $ffid['fid'];
		$source = "fid".$post['msn'];
		if ($post[$source] != '') 
		{
			$post['msndet'] = "<a href=\"javascript:onclick='MyBB.popupWindow(\\'misc.php?action=imcenter&amp;imtype=msn&amp;uid={$post['uid']}\\', \\'imcenter\\', 450, 300);\">{$post['msn']}<img src=\"images/msn.gif\"></a><br />";
		}
	}	
}

?>

Well, this part has a syntax error:

PHP Code:
                $query = $db->query("select * FROM ".TABLE_PREFIX."userfields WHERE name='msn");

Place a closing quote after msn.

Next, parse_details() isn't hooked anywhere, so it will never be run.  I'm guessing it should hook into postbit ?  Also note that the $post variable doesn't just appear - I believe it should be received in the function argument.

Also:

PHP Code:
	else 
	{
          $ffid = $db->fetch_array($query);

There is no query to fetch there, so there'll be an error at that point.

well its stil don't work as needed it needs the icon to apear when the msn fields are filled and to not apear when there empty.
You'll have to review your logic on this one.
Imagine explaining every line of code.
For example, explain to me what this query does:

PHP Code:
                $query = $db->query("select * FROM ".TABLE_PREFIX."userfields WHERE name='msn'");

Also tell me what results it returns.

I'm not going to write the whole plugin for you - it will teach you nothing, in the end.

it searches in the table userfields for msn
...and is that what you want?

Tell me what the query returns...
no i want it that if the details are there that the icon comes and if not then the icon wont come.

it possibly returns the userfield msn code.
I'm not sure if you're getting it.
I'll post a modified version.  I haven't bothered testing if I've got everything correct - I'll leave that to you.
Hopefully, you can understand the logic behind this:

PHP Code:
<?php
if(!defined("IN_MYBB"))
{
    die("Direct initialization of this file is not allowed.<br /><br />Please make sure IN_MYBB is defined.");
}

$plugins->add_hook("postbit", "pp_parse_details");

//All the information about the plugin. These will appear in the plugins list.
function pp_info()
{
    return array(
        "name"          => "Posting profile icon",
        "description"   => "The profile icon plugin let you see the contact details in their posting profile",
        "website"       => "http://www.phcompany.info/plugins",
        "author"        => "pachel",
        "authorsite"    => "http://www.phcompany.info/plugins",
        "version"       => "0.5",
    );
}

//All the activation processes go here
function pp_activate()
{
require MYBB_ROOT.'/inc/adminfunctions_templates.php';
find_replace_templatesets("postbit", '#'.preg_quote('{$post[\'user_details\']}').'#' , '{$post[\'user_details\']}<br />
<a href="private.php?action=send&amp;uid={$post[\'uid\']}">{$lang->send_pm[\'username\']}<img src="images/pm.png" border="0" /></a>
<a href="javascript:;" onclick="MyBB.popupWindow(\'misc.php?action=imcenter&amp;imtype=icq&amp;uid={$post[\'uid\']}\', \'imcenter\', 450, 300);"><img src="images/icq.gif"></a>
<a href="javascript:;" onclick="MyBB.popupWindow(\'misc.php?action=imcenter&amp;imtype=aim&amp;uid={$post[\'uid\']}\', \'imcenter\', 450, 300);"><img src="images/aim.gif"></a>
<a href="javascript:;" onclick="MyBB.popupWindow(\'misc.php?action=imcenter&amp;imtype=yahoo&amp;uid={$post[\'uid\']}\', \'imcenter\', 450, 300);"><img src="images/yahoo.gif"></a>
{$post[\'msndet\']}');
}

//All deactivation processes go here
function pp_deactivate()
{
require MYBB_ROOT.'/inc/adminfunctions_templates.php';
find_replace_templatesets("postbit", '#'.preg_quote('{$post[\'user_details\']}<br />
<a href="private.php?action=send&amp;uid={$post[\'uid\']}">{$lang->send_pm[\'username\']}<img src="images/pm.png" border="0" /></a>
<a href="javascript:;" onclick="MyBB.popupWindow(\'misc.php?action=imcenter&amp;imtype=icq&amp;uid={$post[\'uid\']}\', \'imcenter\', 450, 300);"><img src="images/icq.gif"></a>
<a href="javascript:;" onclick="MyBB.popupWindow(\'misc.php?action=imcenter&amp;imtype=aim&amp;uid={$post[\'uid\']}\', \'imcenter\', 450, 300);"><img src="images/aim.gif"></a>
<a href="javascript:;" onclick="MyBB.popupWindow(\'misc.php?action=imcenter&amp;imtype=yahoo&amp;uid={$post[\'uid\']}\', \'imcenter\', 450, 300);"><img src="images/yahoo.gif"></a>
{$post[\'msndet\']}').'#s' , '{$post[\'user_details\']}',0);
}

function pp_parse_details(&$post)
{
	if ($post['msn'])
	{
		$post['msndet'] = "<a href=\"javascript:onclick='MyBB.popupWindow(\\'misc.php?action=imcenter&amp;imtype=msn&amp;uid={$post['uid']}\\', \\'imcenter\\', 450, 300);\">{$post['msn']}<img src=\"images/msn.gif\"></a><br />";
	}
	else
	{
		$post['msndet'] = "";
	}
}

?>

Note that I'm using the postbit template.  I wouldn't fiddle with the postbit_author_user template unless you know what you're doing.

well white screen explains not much.
pachel Wrote:well white screen explains not much.
1) Enable displaying of errors by editing your php.ini file (or check the log files)
2) Look through your code and make sure you understand exactly what it does.  If you don't, play around with it until you do.
Pages: 1 2
Reference URL's