<?php
// mod_cheat for torrentbits based tracker
// Copy this file to the same dir as the rest of the tracker stuff...

$top = 100;  // Only look at the top xxx most likely...

require "include/bittorrent.php";

dbconn();

loggedinorreturn();

if (get_user_class() < UC_MODERATOR) stderr("Error", "Permission denied.");
mysql_query("UPDATE users SET modcount=modcount+1 WHERE id=".$CURUSER['id']);

#####Merklisten Spion by vpm - BEGIN#####
$myid= $CURUSER[id];
if (isset($Submit)){
 $myid= $selected;
 }
$modname= mysql_fetch_array(mysql_query("SELECT username FROM users WHERE id= $myid"));
#####Merklisten Spion by vpm - END#####

stdhead("...Merker... ::");
print("<h2><b>Merkliste</h2></b><br>");

#####Merklisten Spion by vpm - BEGIN#####
if (get_user_class() == UC_SYSOP){ //bei Bedarf anpassen ;)
 $sql= mysql_query("SELECT id, username FROM users WHERE class >= 25 AND NOT id= $CURUSER[id]"); //Userklasse evtl. anpassen -> hier Moderator

echo "<table><tr><td class=tablea><center>";
if (isset($Submit)){
 echo "<h2>Du befindest dich in der Merkliste von<br>
        <font color= #ff0000><i><b>$modname[0]</b></i></font></h2><br>";
 }

?>
<form name="merkspion" method="post" action="<? echo $PHP_SELF; ?>">

 Wähle ein Teammitglied um seine Merkliste zu sehen:<br><br>
  <select name="selected" id="selected">
    <option value="<? echo $CURUSER[id]; ?>" selected><? echo $CURUSER[username]; ?></option>
<? 
while ($row= mysql_fetch_array($sql)){ ?>
    <option value="<? echo $row[id]; ?>"><? echo $row[username]; ?></option>
<? } ?>
  </select>
  <input type="submit" name="Submit" id="Submit" value="Merkliste abfragen">
</form><br>
</center></td></tr>
</table>

<? }
#####Merklisten Spion by vpm - END#####


$res1 = mysql_query("select * from sluser WHERE modid=$myid") or die(mysql_error());
$count=mysql_num_rows($res1);
if (!$count)
{
print("<center><b>Kein user auf der S&L Merkilste</b></center>");
}
else
{

begin_frame();
print("<center>");
print("<b><h1>Hier sind alle die User, die du auf der SL Merkliste hast</h1></b>");

begin_table();
print("<table class=tablea border=1 cellspacing=0 cellpadding=5 align=center width=90%>\n");
print("<tr><td class=\"left\" width=\"20%\"><b>User name</td><td width=\"20%\"><b>Torrent</td><td width=\"20%\"><b>Zeit bis</td><td width=\"20%\"><b>Löschen</td></tr>\n");

    $res2 = mysql_query("select id, torrentid, sluserid, pntime from sluser WHERE modid=$myid ORDER BY pntime ASC") or die(mysql_error());
while($arr2 = mysql_fetch_assoc($res2))
{
$res4=mysql_query("SELECT name FROM torrents WHERE id=$arr2[torrentid]");
$arr4=mysql_fetch_array($res4);

$res5=mysql_query("SELECT username FROM users WHERE id=$arr2[sluserid]");
$arr5=mysql_fetch_array($res5);


/*if (get_date_time(time()) < $arr2["pntime"])
$color="green";
else
$color="red";*/

$res6=mysql_query("SELECT seeder FROM peers WHERE userid=$arr2[sluserid] && torrent=$arr2[torrentid] ");
$arr6=mysql_fetch_array($res6);

 if ($arr6["seeder"] == 'yes')
 $color="green";
 
 if($arr6["seeder"] == '' && get_date_time(time()) < $arr2["pntime"]) 
  $color="blue";
 
 if($arr6["seeder"] == '' && get_date_time(time()) > $arr2["pntime"])
 $color="red";

echo '<tr><td style="background-color: ' . $color. '"><a href="userdetails.php?id='.$arr2['sluserid'].'"><font color=black>'.$arr5['username'].'</font></a></td>';
echo '<td style="background-color: ' . $color. '"><a href="details.php?id='.$arr2['torrentid'].'"><font color=black>' .$arr4['name']. '</font></a></td>';
echo '<td style="background-color: ' . $color. '"><font color=black>' .$arr2['pntime']. '</font></a></td>';
echo '<td style="background-color: ' . $color. '"><a href="delslmerker.php?id='.$arr2['id'].'"><font color=black>Löschen</font></a></td>';
}


print("</center>");
end_table();
end_frame();
}



stdfoot();
?>