2007-05-12, 11:27 AM
2007-05-12, 11:31 AM
amywinehouseforum.co.uk Wrote:thats just moved the time online and warn level down but they are still on the same line...
Then add the <br /> after the TimeOnline ...
$post['user_details'] = "{$post['user_details']}<font class=\"smalltext\">Spent Online: {$post['timeonline']}</font><br />";
2007-05-12, 11:35 AM
nice one thanks. i did try that but just realised i had been putting the '/' before the 'br' and then my forum stopped working. but all is fine now.
cheers Lex-.
cheers Lex-.
2007-08-04, 05:28 PM
Works fine, thank you..
2009-02-07, 09:51 PM
Is this supposed to be compatible for the latest version of mybb ?
When I active it i get an error
----------------------------------------------------
MyBB SQL Error
MyBB has experienced an internal SQL error and cannot continue.
SQL Error:
1146 - Table 'chainzs.mybb_mybb_users' doesn't exist
Query:
SELECT timeonline FROM mybb_mybb_users WHERE uid='1'
------------------------------------------------------
When I active it i get an error
----------------------------------------------------
MyBB SQL Error
MyBB has experienced an internal SQL error and cannot continue.
SQL Error:
1146 - Table 'chainzs.mybb_mybb_users' doesn't exist
Query:
SELECT timeonline FROM mybb_mybb_users WHERE uid='1'
------------------------------------------------------
2021-01-17, 01:32 PM
Hi ,
just write this to me, it doesn't work well, can someone help me?
Hi,
i did everything as you wrote but this error table was received
Can you help me ?
just write this to me, it doesn't work well, can someone help me?
(2007-05-11, 02:26 PM)LeX- Wrote: [ -> ]amywinehouseforum.co.uk Wrote:where is the template for this plugin as the Time Spent Online and Warning Level are on the same line so I need to move one of them down?
There is no "template" for it, it just adds the "Time Online" to the $post['userdetails'].
There's a <br /> missing because you have that "warning level" thing ... normally there's a <br /> at the end of the $post['userdetails'].
See if this works ...
Open the plugin and find
$post['user_details'] = "{$post['user_details']}<font class=\"smalltext\">Spent Online: {$post['timeonline']}</font>";
Replace By
$post['user_details'] = "{$post['user_details']}<br /><font class=\"smalltext\">Spent Online: {$post['timeonline']}</font>";
Hi,
i did everything as you wrote but this error table was received
Can you help me ?
2021-02-22, 07:02 AM
Please hel me !!!
2021-02-22, 07:51 AM
Error in the plugin:
Original line
Corrected line
The
@MyBBEinstein : DO NOT DOUBLE POST.
Original line
$queryon = $db->simple_select(TABLE_PREFIX."users", "timeonline", "uid='$onuid'");
Corrected line
$queryon = $db->simple_select("users", "timeonline", "uid='$onuid'");
The
simple_select
method automaticaly add TABLE_PREFIX to the table.@MyBBEinstein : DO NOT DOUBLE POST.
2021-02-22, 07:55 AM
(2021-02-22, 07:51 AM)Crazycat Wrote: [ -> ]Error in the plugin:
Original line$queryon = $db->simple_select(TABLE_PREFIX."users", "timeonline", "uid='$onuid'");
Corrected line$queryon = $db->simple_select("users", "timeonline", "uid='$onuid'");
Thesimple_select
method automaticaly add TABLE_PREFIX to the table.
@MyBBEinstein : DO NOT DOUBLE POST.
Hi, but what do I need to do to
4059313
it shows me the whole thing, not the month / day / hour
why?
Plugin cod !
<?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("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
?>
2021-02-22, 09:07 AM
The $post must be passed by reference :
And this plugin will occure a lot of warning because it uses undefined constants (W, M, D, ...).
BTW, I think it could be higly improved.
Edit :
I did a modification of the
Now it takes 3 arguments:
@TODO: add settings to the plugin to set short and prec.
function timeonline_postbit(&$post)
And this plugin will occure a lot of warning because it uses undefined constants (W, M, D, ...).
BTW, I think it could be higly improved.
Edit :
I did a modification of the
fl_nice_time
function. It uses the global translation from MyBB.Now it takes 3 arguments:
- timeonline : as before, unchanged
- short : if setted to 1, then the function uses the short naming (d for days, m for months, ...) else it uses the full naming
- prec : the number of max items you want to display
function fl_nice_time($timeonline, $short=1, $prec=3)
{
global $lang;
$start = DateTime::createFromFormat('Y-m-d H:i:s', '1970-01-01 00:00:00');
$spent = new DateTime('@'.$timeonline);
$interval = $spent->diff($start);
$plural = function($nb,$str, $short=0) {
global $lang;
if ($short==1) { $suf = '_short'; } else { $suf = ''; }
return $nb>1?$lang->{$str.'s'.$suf}:$lang->{$str.$suf};
};
$format = array();
if($interval->y !== 0) {
$format[] = '%y '.$plural($interval->y, 'year', $short);
}
if($interval->m !== 0) {
$format[] = '%m '.$plural($interval->m, 'month', $short);
}
if($interval->d !== 0) {
$format[] = '%d '.$plural($interval->d, 'day', $short);
}
if($interval->h !== 0) {
$format[] = '%h '.$plural($interval->h, 'hour', $short);
}
if($interval->i !== 0) {
$format[] = '%i '.$plural($interval->i, 'minute', $short);
}
if($interval->s !== 0) {
if(!count($format)) {
return $lang->rel_less_than . ' 1 ' . $plural(1, 'minute', $short);
} else {
$format[] = '%s '.$plural($interval->s, 'second', $short);
}
}
if(count($format) > 1) {
$format = implode(', ', array_slice($format, 0, (int) $prec));
} else {
$format = array_pop($format);
}
return $interval->format($format);
}
@TODO: add settings to the plugin to set short and prec.