<?

//BeobachtungsMOD by ColaMan


require "include/bittorrent.php";


dbconn(false);
stdhead();

if (get_user_class() >= UC_MODERATOR)
{
$action=$_REQUEST['page'];
if($action=='') $action=$_REQUEST['mode'];
if($action=='') $action=$_REQUEST['action'];
if($action=='') $action=$_REQUEST['a'];
if($action=='') $action=$_REQUEST['m'];

switch($action)
{
case 'start':
?>

<table cellpadding="0" cellspacing="0" border="0" style="width:750px" class="tableinborder">
 <tr class="tabletitle" width="100%">
  <td colspan="10" width="100%"><span class="normalfont"><center><b>Hier siehst du die User, die du momentan Beobachtest
<?php
if (get_user_class() >= UC_ADMINISTRATOR)
{
print("<br><br><a href=beobachtungen.php?a=alle><b>Alle Anzeigen</b></a>");
}
?>
 </b></center></span></td> 
 </tr><tr><td width="100%" class="tablea">
<?
print("<table border=0 cellspacing=0 width=750 cellpadding=5>\n");
print("<tr><td class=tableb align=left><center>Benutzer</td><td class=tableb><center>Ratio</td><td class=tableb><center>Löschen</td></tr>\n");
$von = $CURUSER['username'];
$abfrage = mysql_query("SELECT * FROM users WHERE beobachtung = 'yes' AND beobachtet_von = '$von'");
while($row = mysql_fetch_object($abfrage))
{
$id = $row->id;
$name = $row->username;
$uploaded = $row->uploaded;
$downloaded = $row->downloaded;


        if ($downloaded > 0) {
            $ratio = number_format($uploaded / $downloaded, 3);
            $ratio = "<font color=" . get_ratio_color($ratio) . ">$ratio</font>";
        } else
        if ($arr["uploaded"] > 0)
            $ratio = "Inf.";
        else
            $ratio = "---";
print("<tr><td><center><a href=userdetails.php?id=$id><b>$name</b></a></center></td><td><center>$ratio</center></td><td><center><a href=beobachtungen.php?id=$id&a=loeschen>Löschen</a></center></td></tr>");

}
print("</table>");
break;


case 'loeschen':
$id = $_GET['id'];
$user = $CURUSER['username'];
$abfrage = mysql_query("SELECT * FROM users WHERE id = '$id'");
while($row = mysql_fetch_object($abfrage))
{
$bvon = $row->beobachtet_von;
}
if($bvon != $user AND get_user_class() < UC_ADMINISTRATOR)
{
print("<p style=\"text-align:center;font-size:12pt;\"><b>Du kannst nur deine eigenen beobachteten User löschen!</b></p>");
}
else
{
print("<p style=\"text-align:center;font-size:12pt;\"><b>Beobachtung aufgehoben!</b></p>");
$loeschen = mysql_query("UPDATE users SET `beobachtung` = 'no', `beobachtet_von` = '' WHERE id = '$id'");
}
break;


case 'alle':
if (get_user_class() >= UC_ADMINISTRATOR)
{
?>

<table cellpadding="0" cellspacing="0" border="0" style="width:750px" class="tableinborder">
 <tr class="tabletitle" width="100%">
  <td colspan="10" width="100%"><span class="normalfont"><center><b>Hier siehst du die User, die momentan beobachtet werden

 </b></center></span></td> 
 </tr><tr><td width="100%" class="tablea">
<?
print("<table border=0 cellspacing=0 width=750 cellpadding=5>\n");
print("<tr><td class=tableb align=left><center>Benutzer</td><td class=tableb><center>Ratio</td><td class=tableb><center>Löschen</td></tr>\n");

$abfrage = mysql_query("SELECT * FROM users WHERE beobachtung = 'yes' AND beobachtet_von != ''");
while($row = mysql_fetch_object($abfrage))
{
$id = $row->id;
$name = $row->username;
$uploaded = $row->uploaded;
$downloaded = $row->downloaded;


        if ($downloaded > 0) {
            $ratio = number_format($uploaded / $downloaded, 3);
            $ratio = "<font color=" . get_ratio_color($ratio) . ">$ratio</font>";
        } else
        if ($arr["uploaded"] > 0)
            $ratio = "Inf.";
        else
            $ratio = "---";
print("<tr><td><center><a href=userdetails.php?id=$id><b>$name</b></a></center></td><td><center>$ratio</center></td><td><center><a href=beobachtungen.php?id=$id&a=loeschen>Löschen</a></center></td></tr>");

}
print("</table>");
break;


}
else
{
print("<p style=\"text-align:center;font-size:12pt;\"><b>Dir ist es nicht erlaubt, hier zuzugreifen</b></p>");
break;
}

}//case ende
}
else {
print("<p style=\"text-align:center;font-size:12pt;\"><b>Dir ist es nicht erlaubt, hier zuzugreifen</b></p>");
}
stdfoot();
die;
?>