MyBB Community Forums

Full Version: Plugin error cod , please help me !!!
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
I'm download for Time Online plugin , and error cod !

Plugin link: https://community.mybb.com/thread-17936.html


it shows up when I enter the forum, I want to go to one of my posts, can someone help me ?


[Image: ha50lyO.png]
Your table prefix seems to be repeated. Be sure about your exact table name...
(2020-12-11, 08:32 AM)effone Wrote: [ -> ]Your table prefix seems to be repeated. Be sure about your exact table name...

Hi,


but what can you do about it? to be good
Check your database table name, If its mybb_users and not mybb_mybb_users then you have to inspect the faulty part of the plugin code which is creating the prefix repetition.
(2020-12-11, 08:43 AM)effone Wrote: [ -> ]Check your database table name, If its mybb_users and not mybb_mybb_users then you have to inspect the faulty part of the plugin code which is creating the prefix repetition.


Plugin full code


<?php
/**
 * Show Time Spent Online on Postbit 1.0
 * Copyright © 2006 DragonFever
 */
 
$plugins->add_hook("postbit", "timeonline_postbit");
 
function timeonline_info()
{
	return array(
		"name"				=> "Shows Time Spent Online on Postbit",
		"description"		=> "Shows Time Spent Online on Postbit.",
		"website"			=> "http://www.dragonfever.info/",
		"author"			=> "DragonFever",
		"authorsite"		=> "http://www.dragonfever.info/",
		"version"			=> "1.0",
		);
}
 
function timeonline_activate()
{
}
 
function timeonline_deactivate()
{
}
 
function timeonline_postbit($post)
{
	global $mybb, $lang, $db;
	$onuid = $post['uid'];
    $queryon = $db->simple_select(TABLE_PREFIX."users", "timeonline", "uid='$onuid'");
    $memprofile = $db->fetch_array($queryon);
    
    if($memprofile['timeonline'] > 0)
    {
        $post['timeonline'] = fl_nice_time($memprofile['timeonline']);
    }
    else
    {
        $post['timeonline'] = $lang->na;
    }
	$post['user_details'] = "{$post['user_details']}<font class=\"smalltext\">Spent Online: {$post['timeonline']}</font>";
}
// First Lettered nice_time Funtion
function fl_nice_time($stamp)
{

	$ysecs = 365*24*60*60;
	$mosecs = 31*24*60*60;
	$wsecs = 7*24*60*60;
	$dsecs = 24*60*60;
	$hsecs = 60*60;
	$msecs = 60;

	$years = floor($stamp/$ysecs);
	$stamp %= $ysecs;
	$months = floor($stamp/$mosecs);
	$stamp %= $mosecs;
	$weeks = floor($stamp/$wsecs);
	$stamp %= $wsecs;
	$days = floor($stamp/$dsecs);
	$stamp %= $dsecs;
	$hours = floor($stamp/$hsecs);
	$stamp %= $hsecs;
	$minutes = floor($stamp/$msecs);
	$stamp %= $msecs;
	$seconds = $stamp;

	if($years == 1)
	{
		$flnicetime['years'] = "1 ".Y;
	}
	elseif($years > 1)
	{
		$flnicetime['years'] = $years." ".Y;
	}

	if($months == 1)
	{
		$flnicetime['months'] = "1 ".M;
	}
	elseif($months > 1)
	{
		$flnicetime['months'] = $months." ".M;
	}

	if($weeks == 1)
	{
		$flnicetime['weeks'] = "1 ".W;
	}
	elseif($weeks > 1)
	{
		$flnicetime['weeks'] = $weeks." ".W;
	}

	if($days == 1)
	{
		$flnicetime['days'] = "1 ".D;
	}
	elseif($days > 1)
	{
		$flnicetime['days'] = $days." ".D;
	}

	if($hours == 1)
	{
		$flnicetime['hours'] = "1 ".H;
	}
	elseif($hours > 1)
	{
		$flnicetime['hours'] = $hours." ".H;
	}

	if($minutes == 1)
	{
		$flnicetime['minutes'] = "1 ".M;
	}
	elseif($minutes > 1)
	{
		$flnicetime['minutes'] = $minutes." ".M;
	}

	if(is_array($flnicetime))
	{
		return implode(", ", $flnicetime);
	}
}
// Function Ends
?>
Plugin code looks ok.
Your table prefix is repeated, and thats the issue, you need to identify the cause and correct it.

To make sure go to line 33 and find TABLE_PREFIX. "users" replace it with "mybb_users", save the plugin, re-upload and see if the error goes away...
(2020-12-11, 08:52 AM)effone Wrote: [ -> ]Plugin code looks ok.
Your table prefix is repeated, and thats the issue, you need to identify the cause and correct it.

To make sure go to line 33 and find TABLE_PREFIX. "users" replace it with "mybb_users", save the plugin, re-upload and see if the error goes away...


I understand, but where can I find this table?

but it's fine here, so I don't see the mistake here! a phpmyadmin

[Image: I2rWCQs.png]
Do the change I suggested in plugin code and it should be ok for your site.
(2020-12-11, 09:48 AM)effone Wrote: [ -> ]Do the change I suggested in plugin code and it should be ok for your site.


i did but the same error code

[Image: Y02Q5Zw.png]

<?php
/**
 * Show Time Spent Online on Postbit 1.0
 * Copyright © 2006 DragonFever
 */
 
$plugins->add_hook("postbit", "timeonline_postbit");
 
function timeonline_info()
{
	return array(
		"name"				=> "Shows Time Spent Online on Postbit",
		"description"		=> "Shows Time Spent Online on Postbit.",
		"website"			=> "http://www.dragonfever.info/",
		"author"			=> "DragonFever",
		"authorsite"		=> "http://www.dragonfever.info/",
		"version"			=> "1.0",
		);
}
 
function timeonline_activate()
{
}
 
function timeonline_deactivate()
{
}
 
function timeonline_postbit($post)
{
	global $mybb, $lang, $db;
	$onuid = $post['uid'];
    $queryon = $db->simple_select(TABLE_PREFIX."mybb_users", "timeonline", "uid='$onuid'");
    $memprofile = $db->fetch_array($queryon);
    
    if($memprofile['timeonline'] > 0)
    {
        $post['timeonline'] = fl_nice_time($memprofile['timeonline']);
    }
    else
    {
        $post['timeonline'] = $lang->na;
    }
	$post['user_details'] = "{$post['user_details']}<font class=\"smalltext\">Spent Online: {$post['timeonline']}</font>";
}
// First Lettered nice_time Funtion
function fl_nice_time($stamp)
{

	$ysecs = 365*24*60*60;
	$mosecs = 31*24*60*60;
	$wsecs = 7*24*60*60;
	$dsecs = 24*60*60;
	$hsecs = 60*60;
	$msecs = 60;

	$years = floor($stamp/$ysecs);
	$stamp %= $ysecs;
	$months = floor($stamp/$mosecs);
	$stamp %= $mosecs;
	$weeks = floor($stamp/$wsecs);
	$stamp %= $wsecs;
	$days = floor($stamp/$dsecs);
	$stamp %= $dsecs;
	$hours = floor($stamp/$hsecs);
	$stamp %= $hsecs;
	$minutes = floor($stamp/$msecs);
	$stamp %= $msecs;
	$seconds = $stamp;

	if($years == 1)
	{
		$flnicetime['years'] = "1 ".Y;
	}
	elseif($years > 1)
	{
		$flnicetime['years'] = $years." ".Y;
	}

	if($months == 1)
	{
		$flnicetime['months'] = "1 ".M;
	}
	elseif($months > 1)
	{
		$flnicetime['months'] = $months." ".M;
	}

	if($weeks == 1)
	{
		$flnicetime['weeks'] = "1 ".W;
	}
	elseif($weeks > 1)
	{
		$flnicetime['weeks'] = $weeks." ".W;
	}

	if($days == 1)
	{
		$flnicetime['days'] = "1 ".D;
	}
	elseif($days > 1)
	{
		$flnicetime['days'] = $days." ".D;
	}

	if($hours == 1)
	{
		$flnicetime['hours'] = "1 ".H;
	}
	elseif($hours > 1)
	{
		$flnicetime['hours'] = $hours." ".H;
	}

	if($minutes == 1)
	{
		$flnicetime['minutes'] = "1 ".M;
	}
	elseif($minutes > 1)
	{
		$flnicetime['minutes'] = $minutes." ".M;
	}

	if(is_array($flnicetime))
	{
		return implode(", ", $flnicetime);
	}
}
// Function Ends
?>
I don't see the change you made in the code.
And the prefix is now triple.... Wow.

Hard code the prefix, as I suggested.
Pages: 1 2