} if ($settingsHackStats[5] == 1) { $tmpl->setvar('settingsHackStats6', 1); $tmpl->setvar('settingsHackStats66', $loadavgString); } } // users if ($cfg["ui_displayusers"] != "0") { $stats_cell_width += 100; $tmpl->setvar('ui_displayusers', 1); $tmpl->setvar('hide_offline', $cfg["hide_offline"]); $userCount = count($cfg['users']); $arOnlineUsers = array(); $arOfflineUsers = array(); for ($inx = 0; $inx < $userCount; $inx++) { if (IsOnline($cfg['users'][$inx])) { array_push($arOnlineUsers, array('user' => $cfg['users'][$inx])); } else { array_push($arOfflineUsers, array('user' => $cfg['users'][$inx])); } } if (count($arOnlineUsers) > 0) { $tmpl->setloop('arOnlineUsers', $arOnlineUsers); } if (count($arOfflineUsers) > 0) { $tmpl->setloop('arOfflineUsers', $arOfflineUsers); } } // Width of top right stats cell: $tmpl->setvar('stats_cell_width', $stats_cell_width); // xfer
/** * init user stats */ function _initUserStats() { global $cfg; $this->_userList = array(); $this->_userCount = count($cfg['users']); for ($i = 0; $i < $this->_userCount; $i++) { $userAry = array(); // name array_push($userAry, $cfg['users'][$i]); // state if (IsOnline($cfg['users'][$i])) { array_push($userAry, "online"); } else { array_push($userAry, "offline"); } // add user to list array_push($this->_userList, $userAry); } }
function displayUserSection() { global $cfg, $db; echo "<table width=\"760\" border=1 bordercolor=\"" . $cfg["table_admin_border"] . "\" cellpadding=\"2\" cellspacing=\"0\" bgcolor=\"" . $cfg["table_data_bg"] . "\">"; echo "<tr><td colspan=6 bgcolor=\"" . $cfg["table_header_bg"] . "\" background=\"themes/" . $cfg["theme"] . "/images/bar.gif\"><img src=\"images/user_group.gif\" width=17 height=14 border=0> <font class=\"title\">" . _USERDETAILS . "</font></div></td></tr>"; echo "<tr>"; echo "<td bgcolor=\"" . $cfg["table_header_bg"] . "\" width=\"15%\"><div align=center class=\"title\">" . _USER . "</div></td>"; echo "<td bgcolor=\"" . $cfg["table_header_bg"] . "\" width=\"6%\"><div align=center class=\"title\">" . _HITS . "</div></td>"; echo "<td bgcolor=\"" . $cfg["table_header_bg"] . "\"><div align=center class=\"title\">" . _UPLOADACTIVITY . " (" . $cfg["days_to_keep"] . " " . _DAYS . ")</div></td>"; echo "<td bgcolor=\"" . $cfg["table_header_bg"] . "\" width=\"6%\"><div align=center class=\"title\">" . _JOINED . "</div></td>"; echo "<td bgcolor=\"" . $cfg["table_header_bg"] . "\" width=\"15%\"><div align=center class=\"title\">" . _LASTVISIT . "</div></td>"; echo "<td bgcolor=\"" . $cfg["table_header_bg"] . "\" width=\"8%\"><div align=center class=\"title\">" . _ADMIN . "</div></td>"; echo "</tr>"; $total_activity = GetActivityCount(); $sql = "SELECT user_id, hits, last_visit, time_created, user_level FROM tf_users ORDER BY user_id"; $result = $db->Execute($sql); while (list($user_id, $hits, $last_visit, $time_created, $user_level) = $result->FetchRow()) { $user_activity = GetActivityCount($user_id); if ($user_activity == 0) { $user_percent = 0; } else { $user_percent = number_format($user_activity / $total_activity * 100); } $user_icon = "images/user_offline.gif"; if (IsOnline($user_id)) { $user_icon = "images/user.gif"; } echo "<tr>"; if (IsUser($user_id)) { echo "<td><a href=\"message.php?to_user="******"\"><img src=\"" . $user_icon . "\" width=17 height=14 title=\"" . _SENDMESSAGETO . " " . $user_id . "\" border=0 align=\"bottom\">" . $user_id . "</a></td>"; } else { echo "<td><img src=\"" . $user_icon . "\" width=17 height=14 title=\"n/a\" border=0 align=\"bottom\">" . $user_id . "</td>"; } echo "<td><div class=\"tiny\" align=\"right\">" . $hits . "</div></td>"; echo "<td><div align=center>"; ?> <table width="310" border="0" cellpadding="0" cellspacing="0"> <tr> <td width="200"> <table width="200" border="0" cellpadding="0" cellspacing="0"> <tr> <td background="themes/<?php echo $cfg["theme"]; ?> /images/proglass.gif" width="<?php echo $user_percent * 2; ?> "><img src="images/blank.gif" width="1" height="12" border="0"></td> <td background="themes/<?php echo $cfg["theme"]; ?> /images/noglass.gif" width="<?php echo 200 - $user_percent * 2; ?> "><img src="images/blank.gif" width="1" height="12" border="0"></td> </tr> </table> </td> <td align="right" width="40"><div class="tiny" align="right"><?php echo $user_activity; ?> </div></td> <td align="right" width="40"><div class="tiny" align="right"><?php echo $user_percent; ?> %</div></td> <td align="right"><a href="admin.php?op=showUserActivity&user_id=<?php echo $user_id; ?> "><img src="images/properties.png" width="18" height="13" title="<?php echo $user_id . "'s " . _USERSACTIVITY; ?> " border="0"></a></td> </tr> </table> <?php echo "</td>"; echo "<td><div class=\"tiny\" align=\"center\">" . date(_DATEFORMAT, $time_created) . "</div></td>"; echo "<td><div class=\"tiny\" align=\"center\">" . date(_DATETIMEFORMAT, $last_visit) . "</div></td>"; echo "<td><div align=\"right\" class=\"tiny\">"; $user_image = "images/user.gif"; $type_user = _NORMALUSER; if ($user_level == 1) { $user_image = "images/admin_user.gif"; $type_user = _ADMINISTRATOR; } if ($user_level == 2) { $user_image = "images/superadmin.gif"; $type_user = _SUPERADMIN; } if ($user_level <= 1 || IsSuperAdmin()) { echo "<a href=\"admin.php?op=editUser&user_id=" . $user_id . "\"><img src=\"images/edit.png\" width=12 height=13 title=\"" . _EDIT . " " . $user_id . "\" border=0></a>"; } echo "<img src=\"" . $user_image . "\" title=\"" . $user_id . " - " . $type_user . "\">"; if ($user_level <= 1) { echo "<a href=\"admin.php?op=deleteUser&user_id=" . $user_id . "\"><img src=\"images/delete_on.gif\" border=0 width=16 height=16 title=\"" . _DELETE . " " . $user_id . "\" onclick=\"return ConfirmDeleteUser('" . $user_id . "')\"></a>"; } else { echo "<img src=\"images/delete_off.gif\" width=16 height=16 title=\"n/a\">"; } echo "</div></td>"; echo "</tr>"; } echo "</table>"; ?> <script language="JavaScript"> function ConfirmDeleteUser(user) { return confirm("<?php echo _WARNING . ": " . _ABOUTTODELETE; ?> : " + user) } </script> <?php }
echo _TORRENTLINKS; ?> :</b><br> <?php $arLinks = GetLinks(); if (is_array($arLinks)) { foreach ($arLinks as $link) { echo "<a href=\"" . $link['url'] . "\" target=\"_blank\"><img src=\"images/arrow.gif\" width=9 height=9 title=\"" . $link['url'] . "\" border=0 align=\"baseline\">" . $link['sitename'] . "</a><br>\n"; } } echo "</ul></td>"; $arUsers = GetUsers(); $arOnlineUsers = array(); $arOfflineUsers = array(); for ($inx = 0; $inx < count($arUsers); $inx++) { if (IsOnline($arUsers[$inx])) { array_push($arOnlineUsers, $arUsers[$inx]); } else { array_push($arOfflineUsers, $arUsers[$inx]); } } echo "<td bgcolor=\"" . $cfg["table_data_bg"] . "\" valign=\"top\">"; echo "<b>" . _ONLINE . ":</b><br>"; for ($inx = 0; $inx < count($arOnlineUsers); $inx++) { echo "<a href=\"message.php?to_user="******"\">"; echo "<img src=\"images/user.gif\" width=17 height=14 title=\"\" border=0 align=\"bottom\">" . $arOnlineUsers[$inx]; echo "</a><br>\n"; } // Does the user want to see offline users? if ($cfg["hide_offline"] == false) { echo "<b>" . _OFFLINE . ":</b></br>";
$offset = 50; $inx = 0; $min = 0; if (isset($_REQUEST['min'])) { $min = tfb_getRequestVar('min'); } $max = $min + $offset; if ($cfg['enable_restrictivetview'] == 0) { $sql = "SELECT user_id, file, time FROM tf_log WHERE action=" . $db->qstr($cfg["constants"]["url_upload"]) . " OR action=" . $db->qstr($cfg["constants"]["file_upload"]) . " ORDER BY time desc"; } else { $sql = $cfg['isAdmin'] ? "SELECT user_id, file, time FROM tf_log WHERE action=" . $db->qstr($cfg["constants"]["url_upload"]) . " OR action=" . $db->qstr($cfg["constants"]["file_upload"]) . " ORDER BY time desc" : "SELECT user_id, file, time FROM tf_log WHERE user_id=" . $db->qstr($cfg["user"]) . " AND ( action=" . $db->qstr($cfg["constants"]["url_upload"]) . " OR action=" . $db->qstr($cfg["constants"]["file_upload"]) . " ) ORDER BY time desc"; } $result = $db->SelectLimit($sql, $offset, $min); $file_result = array(); while (list($user_id, $file, $time) = $result->FetchRow()) { $user_icon = IsOnline($user_id) ? "themes/" . $cfg['theme'] . "/images/user.gif" : "themes/" . $cfg['theme'] . "/images/user_offline.gif"; array_push($file_result, array('user_id' => $user_id, 'user_icon' => $user_icon, 'file' => $file, 'date' => date($cfg['_DATETIMEFORMAT'], $time))); $inx++; } // define vars if ($inx == 0) { $tmpl->setvar('inx', 1); $tmpl->setvar('_NORECORDSFOUND', $cfg['_NORECORDSFOUND']); } $tmpl->setloop('file_result', $file_result); $prev = $min - $offset; if ($prev >= 0) { $tmpl->setvar('prevlink', 1); $prevlink = 1; } else { $tmpl->setvar('prevlink', 0);
/** * sets vars for the user section */ function tmplSetUserSection() { global $cfg, $db, $tmpl; // xfer-prepare $tmpl->setvar('enable_xfer', $cfg["enable_xfer"]); if ($cfg['enable_xfer'] == 1) { $tmpl->setvar('userSection_colspan', 8); // getTransferListArray to update xfer-stats // xfer-init if ($cfg['xfer_realtime'] == 0) { $cfg['xfer_realtime'] = 1; // set xfer-newday Xfer::setNewday(); } @getTransferListArray(); } else { $tmpl->setvar('userSection_colspan', 7); } // activity-prepare $total_activity = GetActivityCount(); $sql = "SELECT user_id, hits, last_visit, time_created, user_level, state FROM tf_users ORDER BY user_id"; $result = $db->Execute($sql); if ($db->ErrorNo() != 0) { dbError($sql); } // user-details $user_details_list = array(); while (list($user_id, $hits, $last_visit, $time_created, $user_level, $user_state) = $result->FetchRow()) { // disk-usage $disk_usage = "0"; $tDir = $cfg["path"] . $user_id . "/"; if (is_dir($tDir)) { switch ($cfg["_OS"]) { case 1: //Linux $dudir = shell_exec($cfg['bin_du'] . " -sk -h -D " . tfb_shellencode($tDir)); break; case 2: //BSD $dudir = shell_exec($cfg['bin_du'] . " -sk -h -L " . tfb_shellencode($tDir)); break; } $dusize = explode("\t", $dudir); $disk_usage = array_shift($dusize); } // xfer-usage $xfer_usage = $cfg['enable_xfer'] == 1 ? Xfer::getUsage($user_id) : 0; // activity $user_activity = GetActivityCount($user_id); $user_percent = $user_activity == 0 ? 0 : number_format($user_activity / $total_activity * 100); // online $user_icon = "themes/" . $cfg['theme'] . "/images/user_offline.gif"; if (IsOnline($user_id)) { $user_icon = "themes/" . $cfg['theme'] . "/images/user.gif"; } // level $user_image = "themes/" . $cfg['theme'] . "/images/user.gif"; $type_user = $cfg['_NORMALUSER']; if ($user_level == 1) { $user_image = "themes/" . $cfg['theme'] . "/images/admin_user.gif"; $type_user = $cfg['_ADMINISTRATOR']; } if ($user_level == 2) { $user_image = "themes/" . $cfg['theme'] . "/images/superadmin.gif"; $type_user = $cfg['_SUPERADMIN']; } $is_superadmin = $user_level <= 1 || IsSuperAdmin() ? 1 : 0; // add to list array_push($user_details_list, array('is_user' => IsUser($user_id), 'user_id' => $user_id, 'user_icon' => $user_icon, 'hits' => $hits, 'disk_usage' => $disk_usage, 'xfer_usage' => $xfer_usage, 'user_percent' => $user_percent, 'user_percent2' => $user_percent * 2, 'user_percent3' => 200 - $user_percent * 2, 'time_created' => date($cfg['_DATEFORMAT'], $time_created), 'last_visit' => date($cfg['_DATETIMEFORMAT'], $last_visit), 'user_image' => $user_image, 'type_user' => $type_user, 'user_level' => $user_level, 'user_state' => $user_state, 'is_superadmin' => $is_superadmin)); } // set vars $tmpl->setvar('_USERDETAILS', $cfg['_USERDETAILS']); $tmpl->setvar('_USER', $cfg['_USER']); $tmpl->setvar('_HITS', $cfg['_HITS']); $tmpl->setvar('_UPLOADACTIVITY', $cfg['_UPLOADACTIVITY']); $tmpl->setvar('_JOINED', $cfg['_JOINED']); $tmpl->setvar('_LASTVISIT', $cfg['_LASTVISIT']); $tmpl->setvar('_ADMIN', $cfg['_ADMIN']); $tmpl->setvar('_DAYS', $cfg['_DAYS']); $tmpl->setvar('_SENDMESSAGETO', $cfg['_SENDMESSAGETO']); $tmpl->setvar('_WARNING', $cfg['_WARNING']); $tmpl->setvar('_ABOUTTODELETE', $cfg['_ABOUTTODELETE']); $tmpl->setvar('_USERSACTIVITY', $cfg['_USERSACTIVITY']); $tmpl->setvar('_EDIT', $cfg['_EDIT']); $tmpl->setvar('_DELETE', $cfg['_DELETE']); $tmpl->setvar('table_admin_border', $cfg["table_admin_border"]); $tmpl->setvar('days_to_keep', $cfg["days_to_keep"]); $tmpl->setloop('user_details_list', $user_details_list); }
function displayActivity($min = 0) { global $cfg, $db; $offset = 50; $inx = 0; $max = $min + $offset; $output = ""; $morelink = ""; // b4rt-62 // "Only Admin can see other user torrents" $sql = ""; if ($cfg['enable_restrictivetview'] == 0) { $sql = "SELECT user_id, file, time FROM tf_log WHERE action=" . $db->qstr($cfg["constants"]["url_upload"]) . " OR action=" . $db->qstr($cfg["constants"]["file_upload"]) . " ORDER BY time desc"; } else { if (IsAdmin() == true) { $sql = "SELECT user_id, file, time FROM tf_log WHERE action=" . $db->qstr($cfg["constants"]["url_upload"]) . " OR action=" . $db->qstr($cfg["constants"]["file_upload"]) . " ORDER BY time desc"; } else { $sql = "SELECT user_id, file, time FROM tf_log WHERE user_id='" . $cfg['user'] . "' AND ( action=" . $db->qstr($cfg["constants"]["url_upload"]) . " OR action=" . $db->qstr($cfg["constants"]["file_upload"]) . " ) ORDER BY time desc"; } } // "Only Admin can see other user torrents" // b4rt-62 $result = $db->SelectLimit($sql, $offset, $min); while (list($user_id, $file, $time) = $result->FetchRow()) { $user_icon = "images/user_offline.gif"; if (IsOnline($user_id)) { $user_icon = "images/user.gif"; } $output .= "<tr>"; $output .= "<td><a href=\"message.php?to_user="******"\"><img src=\"" . $user_icon . "\" width=17 height=14 title=\"" . $user_id . "\" border=0 align=\"bottom\">" . $user_id . "</a> </td>"; $output .= "<td><div align=center><div class=\"tiny\" align=\"left\">"; $output .= $file; $output .= "</div></td>"; $output .= "<td><div class=\"tiny\" align=\"center\">" . date(_DATETIMEFORMAT, $time) . "</div></td>"; $output .= "</tr>"; $inx++; } if ($inx == 0) { $output = "<tr><td colspan=6><center><strong>-- " . _NORECORDSFOUND . " --</strong></center></td></tr>"; } $prev = $min - $offset; if ($prev >= 0) { $prevlink = "<a href=\"history.php?min=" . $prev . "\">"; $prevlink .= "<font class=\"TinyWhite\"><<" . $min . " " . _SHOWPREVIOUS . "]</font></a> "; } $next = $min + $offset; if ($inx >= $offset) { $morelink = "<a href=\"history.php?min=" . $max . "\">"; $morelink .= "<font class=\"TinyWhite\">[" . _SHOWMORE . ">></font></a>"; } echo "<table width=\"760\" border=1 bordercolor=\"" . $cfg["table_admin_border"] . "\" cellpadding=\"2\" cellspacing=\"0\" bgcolor=\"" . $cfg["table_data_bg"] . "\">"; echo "<tr><td colspan=6 bgcolor=\"" . $cfg["table_header_bg"] . "\" background=\"themes/" . $cfg["theme"] . "/images/bar.gif\">"; echo "<table width=\"100%\" cellpadding=0 cellspacing=0 border=0><tr><td>"; echo "<img src=\"images/properties.png\" width=18 height=13 border=0> <strong><font class=\"title\">" . _UPLOADACTIVITY . " (" . $cfg["days_to_keep"] . " " . _DAYS . ")</font></strong>"; if (!empty($prevlink) && !empty($morelink)) { echo "</td><td align=\"right\">" . $prevlink . $morelink . "</td></tr></table>"; } elseif (!empty($prevlink)) { echo "</td><td align=\"right\">" . $prevlink . "</td></tr></table>"; } elseif (!empty($morelink)) { echo "</td><td align=\"right\">" . $morelink . "</td></tr></table>"; } else { echo "</td><td align=\"right\"></td></tr></table>"; } echo "</td></tr>"; echo "<tr>"; echo "<td bgcolor=\"" . $cfg["table_header_bg"] . "\"><div align=center class=\"title\">" . _USER . "</div></td>"; echo "<td bgcolor=\"" . $cfg["table_header_bg"] . "\"><div align=center class=\"title\">" . _FILE . "</div></td>"; echo "<td bgcolor=\"" . $cfg["table_header_bg"] . "\" width=\"15%\"><div align=center class=\"title\">" . _TIMESTAMP . "</div></td>"; echo "</tr>"; echo $output; if (!empty($prevlink) || !empty($morelink)) { echo "<tr><td colspan=6 bgcolor=\"" . $cfg["table_header_bg"] . "\">"; echo "<table width=\"100%\" cellpadding=0 cellspacing=0 border=0><tr><td align=\"left\">"; if (isset($prevlink)) { echo $prevlink; } echo "</td><td align=\"right\">"; if (isset($morelink)) { echo $morelink; } echo "</td></tr></table>"; echo "</td></tr>"; } echo "</table>"; }