<?php

require "include/bittorrent.php";

dbconn(false);
stdhead("Report");

if ($_GET[typ] == "klar"){ stdmsg("Fertig","Dein Report wurde an den Staff gesendet!"); exit; }

$typ = htmlspecialchars($_GET[typ]);
$id = $_GET[id];

$vid = is_numeric($id);

if (!$vid) { stdmsg("Erm..","Diese id scheint falsch zu sein ;)"); exit;}

switch ($typ) {
case torrent:
$res = mysql_query("SELECT name FROM torrents WHERE id = '$id'");
$row = mysql_fetch_array($res);

if (!$row[0]) { stdmsg("Erm","es existiert kein Torrent mit der Id $id"); exit;}

$s = "<table cellpadding=4 cellspacing=1 border=0 style=width:75% class=tableinborder><tr  class=tabletitle width=100%>
        <td colspan=10 width=100%><span class=normalfont><center><b>Melde ein Torrent</b></b></center></span></td></tr> ";

$s .= "<tr><td class=tableb>Name</td><td class=tablea align=left>$row[name]</td></tr></a>";
      

$h .= "<input type=hidden name=tid value=$id>";
$h .= "<input type=hidden name=tname value=$row[name]>";
break;


case user:
$res = mysql_query("SELECT username FROM users WHERE id = '$id'");
$row = mysql_fetch_array($res);

if (!$row[0]) { stdmsg("Erm..","es existiert kein User mit der Id $id"); exit;}

$s = "<table cellpadding=4 cellspacing=1 border=0 style=width:75% class=tableinborder><tr  class=tabletitle width=100%>
        <td colspan=10 width=100%><span class=normalfont><center><b>Melde einen User</b></b></center></span></td></tr> ";

$s .= "<tr><td class=tableb>User</td><td class=tablea align=left>$row[username]</td></tr></a>";
     
$h = "<input type=hidden name=uname value=$row[username]>";
$h .= "<input type=hidden name=uid value=$id>";
break;



case komm:
$res = mysql_query("SELECT user,text FROM comments WHERE id = '$id'");
$row = mysql_fetch_array($res);
$usr = mysql_query("SELECT username FROM users WHERE id = '$row[user]'");
$user = mysql_fetch_array($usr);

if (!$row[0]) { stdmsg("Erm..","es existiert kein Kommentar mit der Id $id"); exit;}
$s = "<table cellpadding=4 cellspacing=1 border=0 style=width:75% class=tableinborder><tr  class=tabletitle width=100%>
        <td colspan=10 width=100%><span class=normalfont><center><b>Melde einen Kommentar</b></b></center></span></td></tr> ";     
$s .= "<tr><td class=tableb>Geschrieben von </td><td class=tablea align=left>$user[username]</td></tr>";
$s .= "<tr><td valign=top class=tableb>Das Kommentar</td><td  class=tablea><br><table width=100% align=center cellpadding=5><tr><td>".format_comment($row[text])."</td></tr></table><br></td></tr>";
$h .= "<input type=hidden name=kid value=$id>";
$h .= "<input type=hidden name=ktext value=$row[text]>";
$h .= "<input type=hidden name=uid value=$row[user]>";
$h .= "<input type=hidden name=uname value=$user[username]>";
break;


case avatar:
$res = mysql_query("SELECT username,avatar FROM users WHERE id = '$id'");
$row = mysql_fetch_array($res);

if (!$row[1]) { stdmsg("Erm..","es existiert kein User mit der Id $id oder Er/Sie besitzt kein Avatar."); exit;}
    

      
$s = "<table cellpadding=4 cellspacing=1 border=0 style=width:75% class=tableinborder><tr  class=tabletitle width=100%>
        <td colspan=10 width=100%><span class=normalfont><center><b>Melde einen Avatar</b></b></center></span></td></tr> ";
$s .= "<tr><td class=tableb>User</td><td class=tablea align=left>$row[username]</td></tr>";
$s .= "<tr><td class=tableb valign=top>Avatar</td><td class=tableb><img src=$row[avatar]></td></tr>";

$h .= "<input type=hidden name=uid value=$id>";
$h .= "<input type=hidden name=uname value=$row[username]>";
$h .= "<input type=hidden name=uavatar value=$row[avatar]>";
break;

default:
stdmsg("Erm..","Bitte noch einmal.");
exit;
break;
}

echo "<form action=/takereport.php?typ=".$typ." method=post>";

echo '<table border="1" cellspacing="0" cellpadding="5" width=737>';

echo $s;

echo "<tr><td class=tablea>Grund<br><font size=1>Was ist denn falsch??</font></td><td class=tableb><input  type=text size=50 name=reason></td></tr>";
echo "<tr><td colspan=2 class=tablea align=center><input class=btn type=submit name=report value=Meldung></td></tr>";
echo "</table>";


echo "<input type=hidden name=reportid value=$id>";


echo "</form>";

stdfoot();
?>
