<?php


require "include/bittorrent.php";
dbconn();
loggedinorreturn();
if (get_user_class() < UC_MODERATOR)
        stderr("Dein Rang ist zu niedrig der Zugriff wurde dir verwehrt!!");

stdhead();

$res = mysql_query("SELECT * FROM torrents WHERE id NOT IN (SELECT torrentid FROM deluxebits)");
$number2 = mysql_num_rows($res);

$res2 = mysql_query("SELECT * FROM torrents WHERE id NOT IN (SELECT torrentid FROM saugstube)");
$number1 = mysql_num_rows($res2);

$res3 = mysql_query("SELECT * FROM torrents WHERE id NOT IN (SELECT torrentid FROM bitreactor)");
$number3 = mysql_num_rows($res3);

$res4 = mysql_query("SELECT * FROM torrents WHERE id NOT IN (SELECT torrentid FROM hightorrent)");
$number4 = mysql_num_rows($res4);

$res5 = mysql_query("SELECT * FROM torrents WHERE id NOT IN (SELECT torrentid FROM torrentsmore)");
$number5 = mysql_num_rows($res5);




begin_frame("Promoter Area", true);
?>  
<table align="center">
<tr class=tablea>
<td class=tablecat>
<br>
Anzahl der noch nicht Promoteten Torrents:</td></tr><br>
<tr class=tablea>
<td class=tablea>
<left><a href=notmystiktorrent.php>Mystik-Torrent</a></left><div align="right"><b> <font color = red> <? echo " $number2" ?></b></font><br><br></div></td></tr>

<tr class=tablea>
<td class=tablea>
<left><a href=notsaugstube.php>Saugstube</a></left><div align="right"><b> <font color = red> <? echo " $number1" ?></b></font><br><br></div></td></tr>

<tr class=tablea>
<td class=tablea>
<left><a href=notbitreactor.php>Bitreactor</a></left><div align="right"><b> <font color = red> <? echo " $number3" ?>    </b></font><br><br></div></td></tr>

<tr class=tablea>
<td class=tablea>
<left><a href=nothightorrent.php>Hightorrent</a></left><div align="right"><b> <font color = red> <? echo " $number4" ?>    </b></font><br><br></div></td></tr>

<tr class=tablea>
<td class=tablea>
<left><a href=notbitreactor.php>Torrents and More</a></left><div align="right"><b> <font color = red> <? echo " $number5" ?>    </b></font><br></div><br></td></tr>
</table>
<br>
<?

end_frame();
?>

<?
begin_frame("Top 5 Promoter", true);
?>
<br>

<table align="center">
<tr class=tablea>
  <td class=tablecat > <div align="center">Saugstube</div></td>
 <td class=tablecat> <div align="center">Mystik- Torrent</div></td>
 <td class=tablecat> <div align="center">Bitreactor</div></td>
 <td class=tablecat> <div align="center">Hightorrent</div></td>
 <td class=tablecat> <div align="center">Torrents and More</div></td>
</tr>


<tr>
 <td>
<table>
<?
print("<tr class=tablea><td class=tableb> <u><b><div align='center'>Platz</div></u></b></td>");

print("<td class=tablea> <u><b><div align='center'>Username</div></u></b></td>");

print("<td class=tableb><u><b><div align='center'>Anzahl</div></u></b></td></tr>");
$dd=1;

$top1 = mysql_query("select username, count(*) as summe from saugstube, users where saugstube.userid = users.id group by username order by summe desc LIMIT 5");
$saug = mysql_fetch_array($top1);

print("<tr class=tablea><td class=tableb> <div align='center'>" . $dd . "</div></td>");


print("<td class=tablea><div align='center'>" . $saug['username'] . "</div></td>");

print("<td class=tableb><div align='center'>" . $saug['summe'] . "</div></td></tr>");


while ($sau = mysql_fetch_array($top1)) {
$dd=$dd+1;
print("<tr class=tablea><td class=tableb> <div align='center'>" . $dd . "</div></td>");


print("<td class=tablea><div align='center'>" . $sau['username'] . "</div></td>");

print("<td class=tableb><div align='center'>" . $sau['summe'] . "</div></td></tr>");


}

?>
</table>
 </td>
<td>
<table>
<?

print("<tr class=tablea><td class=tableb> <u><b><div align='center'>Platz</div></u></b></td>");

print("<td class=tablea> <u><b><div align='center'>Username</div></u></b></td>");

print("<td class=tableb><u><b><div align='center'>Anzahl</div></u></b></td></tr>");
$d=1;
$top2 = mysql_query("select username, count(*) as summe from deluxebits, users where deluxebits.userid = users.id group by username order by summe desc LIMIT 5");
$delu = mysql_fetch_array($top2);

print("<tr class=tablea><td class=tableb> <div align='center'>" . $d . "</div></td>");

print("<td class=tablea> <div align='center'>" . $delu['username'] . "</div></td>");

print("<td class=tableb> <div align='center'>" . $delu['summe'] . "</div></td></tr>");

while ($del=mysql_fetch_array($top2)) {
$d=$d+1;
print("<tr class=tablea><td class=tableb> <div align='center'>" . $d . "</div></td>");

print("<td class=tablea> <div align='center'>" . $del['username'] . "</div></td>");

print("<td class=tableb> <div align='center'>" . $del['summe'] . "</div></td></tr>");
}

?>
</table>
 </td>
<td>
<table>
<?

print("<tr class=tablea><td class=tableb> <u><b><div align='center'>Platz</div></u></b></td>");

print("<td class=tablea> <u><b><div align='center'>Username</div></u></b></td>");

print("<td class=tableb><u><b><div align='center'>Anzahl</div></u></b></td></tr>");
$ddd=1;
$top3 = mysql_query("select username, count(*) as summe from bitreactor, users where bitreactor.userid = users.id group by username order by summe desc LIMIT 5");
$bitr = mysql_fetch_array($top3);

print("<tr class=tablea><td class=tableb> <div align='center'>" . $ddd . "</div></td>");

print("<td class=tablea> <div align='center'>" . $bitr['username'] . "</div></td>");

print("<td class=tableb> <div align='center'>" . $bitr['summe'] . "</div></td></tr>");

while ($del=mysql_fetch_array($top3)) {
$ddd=$ddd+1;
print("<tr class=tablea><td class=tableb> <div align='center'>" . $ddd . "</div></td>");

print("<td class=tablea> <div align='center'>" . $del['username'] . "</div></td>");

print("<td class=tableb> <div align='center'>" . $del['summe'] . "</div></td></tr>");
}

?>
</table>
 </td>
<td>
<table>
<?

print("<tr class=tablea><td class=tableb> <u><b><div align='center'>Platz</div></u></b></td>");

print("<td class=tablea> <u><b><div align='center'>Username</div></u></b></td>");

print("<td class=tableb><u><b><div align='center'>Anzahl</div></u></b></td></tr>");
$h=1;
$top4 = mysql_query("select username, count(*) as summe from hightorrent, users where hightorrent.userid = users.id group by username order by summe desc LIMIT 5");
$hight = mysql_fetch_array($top4);

print("<tr class=tablea><td class=tableb> <div align='center'>" . $h . "</div></td>");

print("<td class=tablea> <div align='center'>" . $hight['username'] . "</div></td>");

print("<td class=tableb> <div align='center'>" . $hight['summe'] . "</div></td></tr>");

while ($del=mysql_fetch_array($top4)) {
$h=$h+1;
print("<tr class=tablea><td class=tableb> <div align='center'>" . $h . "</div></td>");

print("<td class=tablea> <div align='center'>" . $del['username'] . "</div></td>");

print("<td class=tableb> <div align='center'>" . $del['summe'] . "</div></td></tr>");
}

?>
</table>
 </td>
<td>
<table>
<?

print("<tr class=tablea><td class=tableb> <u><b><div align='center'>Platz</div></u></b></td>");

print("<td class=tablea> <u><b><div align='center'>Username</div></u></b></td>");

print("<td class=tableb><u><b><div align='center'>Anzahl</div></u></b></td></tr>");
$t=1;
$top5 = mysql_query("select username, count(*) as summe from torrentsmore, users where torrentsmore.userid = users.id group by username order by summe desc LIMIT 5");
$torr = mysql_fetch_array($top5);

print("<tr class=tablea><td class=tableb> <div align='center'>" . $t . "</div></td>");

print("<td class=tablea> <div align='center'>" . $torr['username'] . "</div></td>");

print("<td class=tableb> <div align='center'>" . $torr['summe'] . "</div></td></tr>");

while ($del=mysql_fetch_array($top5)) {
$t=$t+1;
print("<tr class=tablea><td class=tableb> <div align='center'>" . $t . "</div></td>");

print("<td class=tablea> <div align='center'>" . $del['username'] . "</div></td>");

print("<td class=tableb> <div align='center'>" . $del['summe'] . "</div></td></tr>");
}

?>
</table>
 </td>



</tr>
</table>
<?

end_frame();
?>
<?
begin_frame("Promote-Statistik", true);
?>
<?
$ll= 0;
$res4 = mysql_query("SELECT COUNT(*) FROM saugstube GROUP BY userid");
$number4 = mysql_num_rows($res4);

$res10 = mysql_query("SELECT COUNT(*) FROM torrentsmore GROUP BY userid");
$number10 = mysql_num_rows($res10);

$res11 = mysql_query("SELECT COUNT(*) FROM bitreactor GROUP BY userid");
$number11 = mysql_num_rows($res11);

$res7 = mysql_query("SELECT COUNT(*) FROM deluxebits GROUP BY userid");
$number7 = mysql_num_rows($res7);

$res8 = mysql_query("SELECT COUNT(*) FROM hightorrent GROUP BY userid");
$number8 = mysql_num_rows($res7);

$res5 = mysql_query("SELECT COUNT(*) FROM saugstube GROUP BY torrentid");
$number5 = mysql_num_rows($res5);

$res12 = mysql_query("SELECT COUNT(*) FROM torrentsmore GROUP BY torrentid");
$number12 = mysql_num_rows($res12);

$res13 = mysql_query("SELECT COUNT(*) FROM bitreactor GROUP BY torrentid");
$number13 = mysql_num_rows($res13);

$res6 = mysql_query("SELECT COUNT(*) FROM deluxebits GROUP BY torrentid");
$number6 = mysql_num_rows($res6);

$res9 = mysql_query("SELECT COUNT(*) FROM hightorrent GROUP BY torrentid");
$number9 = mysql_num_rows($res9);


$du2 = $number5 / $number4;

$du1 = $number6 / $number7;

$du3 = $number12 / $number10;

$du4 = $number13 / $number11;

$du5 = $number9 / $number8;


?>
<table align="center">
<tr>
 <td> </td>
 <td class=tablecat> Saugstube</td>
 <td class=tablecat> Mystik-Torrent</td>
 <td class=tablecat> Hightorrent</td>
 <td class=tablecat> Torrents and More</td>
 <td class=tablecat> Bit-Reactor</td>
</tr>
<tr>
 
<td class=tablecat> Anzahl der Promoter</td>
 <?
echo"<td> $number4 </td>";
echo"<td> $number7 </td>";
echo"<td> $number8 </td>";
echo"<td> $number10 </td>";
echo"<td> $number11 </td>";
?>
</tr>
<tr>
 <td class=tablecat> Anzahl der Prom. Torrents</td>
 <?
echo"<td> $number5 </td>";
echo"<td> $number6 </td>";
echo"<td> $number9 </td>";
echo"<td> $number12 </td>";
echo"<td> $number13 </td>";

?>
</tr>
<tr>
 <td class=tablecat> Durchschnitt Tor/Prom</td>
 <?
echo"<td> $du2 </td>";
echo"<td> $du1 </td>";
echo"<td> $du3 </td>";
echo"<td> $du4 </td>";
echo"<td> $du5 </td>";

?>
</tr>
</table>
<?

end_frame();
?>



<?
stdfoot();
?>