require "include/bittorrent.php";
dbconn();
loggedinorreturn();
extract($_GET, EXTR_SKIP);
// DELETE FORUM ACTION
if ($_GET['action'] == "del") {
if (get_user_class() < UC_ADMINISTRATOR)
stderr( _("Error"), _("Permission denied."));
//if ( $id) { header("Location: $_SERVER['PHP_SELF']?act=forum"); die();}
$result = do_mysql_query ("SELECT * FROM topics where forumid = '".(int) $_GET['id']."'");
if ($row = mysql_fetch_array($result)) {
do {
do_mysql_query ("DELETE FROM posts where topicid = '".$row["id"]."'") or sqlerr(__FILE__, __LINE__);
} while($row = mysql_fetch_array($result));
}
do_mysql_query ("DELETE FROM topics where forumid = '".(int) $_GET['id']."'") or sqlerr(__FILE__, __LINE__);
do_mysql_query ("DELETE FROM forums where id = '".(int) $_GET['id']."'") or sqlerr(__FILE__, __LINE__);
header("Location: ".$_SERVER['PHP_SELF']."?act=forum");
die();
}
//EDIT FORUM ACTION
if ($_POST['action'] == "editforum") {
if (get_user_class() < UC_ADMINISTRATOR)
stderr( _("Error"), _("Permission denied."));
//if (!$name && !$desc && !$id) { header("Location: $_SERVER['PHP_SELF']?act=forum"); die();}
do_mysql_query("UPDATE forums SET sort = '" . $_POST['sort'] . "', name = " . sqlesc($_POST['name']). ", description = " . sqlesc($_POST['desc']). ", minclassread = '" . $_POST['readclass'] . "', minclasswrite = '" . $_POST['writeclass'] . "', minclasscreate = '" . $_POST['createclass'] . "' where id = '".$_POST['id']."'") or sqlerr(__FILE__, __LINE__);
header("Location: ".$_SERVER['PHP_SELF']."?act=forum");
die();
}
//ADD FORUM ACTION
if ($_POST['action'] == "addforum") {
if (get_user_class() < UC_ADMINISTRATOR)
stderr( _("Error"), _("Permission denied."));
if (!$name && !$desc) { header("Location: ".$_SERVER['PHP_SELF']."?act=forum"); die();}
do_mysql_query("INSERT INTO forums (sort, name, description, minclassread, minclasswrite, minclasscreate) VALUES(" . $_POST['sort'] . ", " . sqlesc($_POST['name']). ", " . sqlesc($_POST['desc']). ", " . $_POST['readclass'] . ", " . $_POST['writeclass'] . ", " . $_POST['createclass'] . ")") or sqlerr(__FILE__, __LINE__);
header("Location: ".$_SERVER['PHP_SELF']."?act=forum");
die();
}
//ADD IP TO BAN LIST ACTION
if ($_POST['action'] == "ban") {
if (get_user_class() < UC_ADMINISTRATOR)
stderr( _("Error"), _("Permission denied."));
if (!$first && !$last) { header("Location: ".$_SERVER['PHP_SELF']."?act=ban"); die();}
$first = ip2long($_POST['first']);
$last = ip2long($_POST['last']);
do_mysql_query("INSERT INTO bans (first, last, comment, added, addedby) VALUES(" . $first . ", " . $last. ", " . sqlesc($_POST['comment']). ", NOW(), " . $CURUSER["id"] . ")") or sqlerr(__FILE__, __LINE__);
header("Location: ".$_SERVER['PHP_SELF']."?act=ban");
die();
}
//DELETE IP FROM BAN LIST
if ($_GET['action'] == "ipdel") {
if (get_user_class() < UC_ADMINISTRATOR)
stderr( _("Error"), _("Permission denied."));
if (!$id) { header("Location: ".$_SERVER['PHP_SELF']."?act=ban"); die();}
do_mysql_query ("DELETE FROM bans where id = '".(int) $_GET['id']."'") or sqlerr(__FILE__, __LINE__);
header("Location: ".$_SERVER['PHP_SELF']."?act=ban");
die();
}
stdhead( _("Staff") );
begin_main_frame();
?>
if (!$act) {
if(!$GLOBALS['settings']['cache'] || !($staff = $cache_lite->get('staff')) )
{
ob_start();
// LIST ALL ADMINISTRATORS AND MODERATORS
$res = do_mysql_query("SELECT
IF( ISNULL(countries.flagpic) <> 0, ' ', CONCAT('') ) as country,
IF( UNIX_TIMESTAMP(NOW())-UNIX_TIMESTAMP(last_access) <= 180, 'online', 'offline' ) as online,
users.id,
username,
class
FROM users
LEFT JOIN countries
ON users.country = countries.id
WHERE class>=".UC_MODERATOR. " AND
status='confirmed'
ORDER BY username
" ) or die(mysql_error());
$vips = array();
$mods = array();
$admins = array();
$sysops = array();
while($arr2 = mysql_fetch_assoc($res)) {
if($arr2["class"] == UC_VIP)
$vips[] = $arr2;
if($arr2["class"] == UC_MODERATOR)
$mods[] = $arr2;
if($arr2["class"] == UC_ADMINISTRATOR)
$admins[] = $arr2;
if($arr2["class"] == UC_SYSOP)
$sysops[] = $arr2;
}
print("
Staff Page
");
?>
All software support questions and those already answered in the /faq.php>FAQ will be ignored.
//you can call other classes, just call them in the same way
isset($sysops) ? DoStaff($sysops, "Sysops") : DoStaff($sysops=false, "Sysops");
isset($admins) ? DoStaff($admins, "Administrators") : DoStaff($admins=false, "Administrators");
isset($mods) ? DoStaff($mods, "Moderators") : DoStaff($mods=false, "Moderators");
//isset($vips) ? DoStaff($vips, "VIP's") : DoStaff($vips=false, "VIP's");
$staff = ob_get_clean();
$cache_lite->setLifeTime($GLOBALS['config']['cache_staff']);
$cache_lite->save($staff, 'staff');
}
echo $staff;
}
if (!$act) {
if (!$settings['cache'] || !($firstline = $cache_lite->get('firstline') ) ) {
// LIST ALL FIRSTLINE SUPPORTERS
// Search User Database for Firstline Support and display in alphabetical order
$res = do_mysql_query("SELECT
IF( ISNULL(countries.flagpic) <> 0, ' ', CONCAT('') ) as country,
IF( UNIX_TIMESTAMP(NOW())-UNIX_TIMESTAMP(last_access) <= 180, 'online', 'offline' ) as online,
users.id, username, supportfor
FROM users
LEFT JOIN countries
ON users.country = countries.id
WHERE
support='yes' AND
status='confirmed'
ORDER BY username LIMIT 10") or sqlerr();
//Abuse an output buffer to skip filling the string, which is quite slow on large strings :P
ob_start();
while ($arr = mysql_fetch_assoc($res))
{
echo "".$arr['username']." |
| ".
""." | ".
"".$arr['country']." | ".
"".$arr['supportfor']." |
\n";
}
$firstline = ob_get_clean();
$cache_lite->setLifeTime($GLOBALS['config']['cache_staff']);
$cache_lite->save($firstline, 'firstline');
}
begin_frame("Firstline Support");
?>
= _('General support questions should preferably be directed to these users. Note that they are volunteers, giving away their time and effort to help you.
Treat them accordingly. (Languages listed are those besides English.)') ?>
|
= _('Username') ?> |
= _('Active') ?> |
= _('Contact') ?> |
= _('Language') ?> |
= _('Support for') ?>: |
|
=$firstline?>
end_frame();
}
/* Display Site Owner Tools if user is Administrator */
if (get_user_class() >= UC_ADMINISTRATOR)
{
begin_frame("Admin Tools - Viewable by Admin only."); ?>
end_frame();
}
?>
if (get_user_class() >= UC_MODERATOR) {
// LIST OF THE MOD TOOLS (ONLY VISIBLE WHEN YOU ARE MOD, ELSE YOU ONLY SEE LIST OF MODS
begin_frame("Staff tools - Viewable by Mods only."); ?>
end_frame();
?>
?>
if (get_user_class() >= UC_MODERATOR) {
?>
end_frame(); } ?>
if ($act == "upstats") {
//SHOWS THE STATISTICS OF THE UPLOADERS
$res = do_mysql_query("SELECT COUNT(*) FROM torrents") or sqlerr(__FILE__, __LINE__);
$n = mysql_fetch_row($res);
$n_tor = $n[0];
$res = do_mysql_query("SELECT COUNT(*) FROM peers") or sqlerr(__FILE__, __LINE__);
$n = mysql_fetch_row($res);
$n_peers = $n[0];
$uporder = $_GET['uporder'];
$catorder = $_GET["catorder"];
if ($uporder == "lastul")
$orderby = "last DESC, name";
elseif ($uporder == "torrents")
$orderby = "n_t DESC, name";
elseif ($uporder == "peers")
$orderby = "n_p DESC, name";
else
$orderby = "name";
$query = "SELECT
u.id,
u.username AS name,
MAX(t.added) AS last,
COUNT(DISTINCT t.id) AS n_t,
COUNT(p.id) as n_p
FROM users as u
LEFT JOIN torrents as t ON u.id = t.owner
LEFT JOIN peers as p ON t.id = p.torrent
WHERE u.class > 0
GROUP BY u.id ORDER BY $orderby";
$res = do_mysql_query($query) or sqlerr(__FILE__, __LINE__);
if (mysql_num_rows($res) == 0)
stdmsg("Sorry...", "No uploaders.");
else
{
begin_frame("Uploader Activity", True);
begin_table();
print("\n
Uploader | \n
Last Upload | \n
Torrents | \n
Perc. | \n
Peers | \n
Perc. | \n
\n");
while ($uper = mysql_fetch_array($res))
{
print("".$uper['name']." | \n");
print("".$uper['last']." (".get_elapsed_time(sql_timestamp_to_unix_timestamp($uper['last']))." ago)"):"align=center>---") . " | \n");
print("" . $uper['n_t'] . " | \n");
print("" . ($n_tor > 0?number_format(100 * $uper['n_t']/$n_tor,1)."%":"---") . " | \n");
print("" . $uper['n_p']." | \n");
print("" . ($n_peers > 0?number_format(100 * $uper['n_p']/$n_peers,1)."%":"---") . " |
\n");
}
end_table();
end_frame();
}
if ($n_tor == 0)
stdmsg("Sorry...", "No categories defined!");
else
{
if ($catorder == "lastul")
$orderby = "last DESC, c.name";
elseif ($catorder == "torrents")
$orderby = "n_t DESC, c.name";
elseif ($catorder == "peers")
$orderby = "n_p DESC, name";
else
$orderby = "c.name";
$res = do_mysql_query("SELECT c.name, MAX(t.added) AS last, COUNT(DISTINCT t.id) AS n_t, COUNT(p.id) AS n_p
FROM categories as c LEFT JOIN torrents as t ON t.category = c.id LEFT JOIN peers as p
ON t.id = p.torrent GROUP BY c.id ORDER BY $orderby") or sqlerr(__FILE__, __LINE__);
begin_frame("Category Activity", True);
begin_table();
print("Category |
Last Upload |
Torrents |
Perc. |
Peers |
Perc. |
\n");
while ($cat = mysql_fetch_array($res))
{
print("" . $cat['name'] . " | ");
print("".$cat['last']." (".get_elapsed_time(sql_timestamp_to_unix_timestamp($cat['last']))." ago)"):"align = center>---") ." | ");
print("" . $cat['n_t'] . " | ");
print("" . number_format(100 * $cat['n_t']/$n_tor,1) . "% | ");
print("" . $cat['n_p'] . " | ");
print("" . ($n_peers > 0?number_format(100 * $cat['n_p']/$n_peers,1)."%":"---") . " | \n");
}
end_table();
end_frame();
}
end_frame(); }?>
if ($act == "last") {
begin_frame("Latest users");
echo '';
echo "User | Ratio | IP | Date Joined | Last Access | Download | Upload |
";
$result = do_mysql_query ("SELECT * FROM users WHERE enabled = 'yes' AND status = 'confirmed' ORDER BY added DESC limit 100");
if ($row = mysql_fetch_array($result)) {
do {
if ($row["uploaded"] == "0") { $ratio = "inf"; }
elseif ($row["downloaded"] == "0") { $ratio = "inf"; }
else {
$ratio = number_format($row["uploaded"] / $row["downloaded"], 3);
$ratio = "$ratio";
}
echo "".$row["username"]." | ".$ratio." | ".$row["ip"]." | ".$row["added"]." | ".$row["last_access"]." | ".mksize($row["downloaded"])." | ".mksize($row["uploaded"])." |
";
} while($row = mysql_fetch_array($result));
} else {print "Sorry, no records were found! |
";}
echo "
";
end_frame(); }?>
if ($act == "forum") {
// SHOW FORUMS WITH FORUM MANAGMENT TOOLS
begin_frame("Forums");
?>
echo '';
echo "Name | Topics | Posts | Read | Write | Create topic | Modify |
";
$result = do_mysql_query ("SELECT * FROM forums ORDER BY sort ASC");
if ($row = mysql_fetch_array($result)) {
do {
//if ($row["uploaded"] == "0" || $row["downloaded"] == "0") { $ratio = "inf"; } else {
//$ratio = $row["uploaded"] / $row["downloaded"];
//$ratio = number_format($ratio, 2);
//}
echo "".$row["name"]." ".$row["description"]." | ";
echo "".$row["topiccount"]." | ".$row["postcount"]." | minimal " . get_user_class_name($row["minclassread"]) . " | minimal " . get_user_class_name($row["minclasswrite"]) . " | minimal " . get_user_class_name($row["minclasscreate"]) . " | EDIT | DELETE |
";
} while($row = mysql_fetch_array($result));
} else {print "Sorry, no records were found! |
";}
echo "
";
?>