2013-07-03, 10:55 AM
i found this file not a plugin which shows top online users by time spent on site, the problem is theres no pagination it lists all users so the page size is so big... someone good on php coding so it will have paganation, here is the code..
<?php
define("IN_MYBB", 1);
require_once "./global.php";
require_once "./inc/class_parser.php";
add_breadcrumb("Top Online User");
$lang->error = "Top Online User";
$title = "Top Online User";
// Add pagination
$perpage = $mybb->settings['threadsperpage'];
if(intval($mybb->input['page']) > 10)
{
$page = intval($mybb->input['page']);
$start = ($page+1) * $perpage;
$pages = ceil($todaycount / $perpage);
if($page > $pages)
{
$start = 0;
$page = 1;
}
}
else
{
$start = 0;
$page = 1;
}
if($mybb->user['uid']=='' || $mybb->user['usergroup']=='1')
{
error_no_permission();
}
$message = '<table border="0" cellspacing="1" cellpadding="3" class="tborder">';
$message .= '<tr>
<td class="tcat"><span class="smalltext"><strong>Username</strong></span></td>
<td class="tcat"><span class="smalltext"><strong>Time Online</strong></span></td>
</tr>';
$list = $db->query("SELECT * FROM `".TABLE_PREFIX."users` ORDER BY `timeonline` DESC");
while($get = $db->fetch_array($list)){
$username = format_name($get['username'],$get['usergroup'],$get['displaygroup']);
$post = $get['postnum'];
$last = my_date($mybb->settings['timeformat'],$get['lastactive']);
$lastpost = my_date($mybb->settings['timeformat'],$get['lastpost']);
$time = $get['timeonline'];
$message .= '<tr>
<td class="trow1">'. $username. '</td>
<td class="trow1">'. $time .' seconds.</td>
</tr>';
}
$message .= "</table>";
error($message,$title);
?>