<?
require "include/bittorrent.php";

dbconn(false);

loggedinorreturn();
if (get_user_class() < UC_MODERATOR)
stderr("Error", "Access denied.");

if ($_GET['action'] == "list") {

$res2 = mysql_query("SELECT userid, seeder, torrent, agent FROM peers WHERE connectable='no' ORDER BY userid DESC") or sqlerr();

stdhead("Peers that are unconnectable");

begin_frame("Not Connectable");
print("<a  align=center><font color><h3><center>Das sind alle User, die im Augenblick aktiv sind.</center><p><center>Diese markierten User<font color=red> * </font> seeden noch.</center></p></h></font></a>");
print("<table border=0 cellspacing=1 cellpadding=4 align=center class=tableinborder width=100%>\n");
print("<td class=tableb align=center><a href=findnotconnectable.php><center><b>Die Logs anzeigen (Bitte überprüfen,bevor man PM schickt)</b></center></a></td>");
print("<table border=0 cellspacing=1 cellpadding=4 align=center class=tableinborder width=100%>\n");
print("<td class=tableb align=center><a href=findnotconnectable.php?action=sendpm><center><b>allen Not Connectable Usern ein PM senden</b></center></a></td>");
print("<table border=0 cellspacing=1 cellpadding=4 align=center class=tableinborder width=100%>\n");


$result = mysql_query("select distinct userid from peers where connectable = 'no'");
$count = mysql_num_rows($result);
print("<table border=0 cellspacing=1 cellpadding=4 align=center>\n");

print ("<a align=center><font color=red><h2>$count User sind Not Connectable</h></font></a>");

@mysql_free_result($result);

if (mysql_num_rows($res2) == 0)
print("<p align=center><b>Alle Peers sind Connectable! biggrin.gif</b></p>\n");
else
{
print("<table border=0 cellspacing=1 cellpadding=4 align=center class=tableinborder width=100%>\n");
print("<td class=tabletitle align=center>User</td>
<td class=tabletitle align=center>Torrent</td>
<td class=tabletitle align=center>Client");

while($arr2 = mysql_fetch_assoc($res2))
{
$r2 = mysql_query("SELECT username FROM users WHERE id=$arr2[userid]") or sqlerr();
$a2 = mysql_fetch_assoc($r2);
print("<tr><td class=tableb align=center><a href=userdetails.php?id=$arr2[userid]>$a2[username]" . get_user_icons($arr2, true) . "</b></a>
<td class=tableb align=center><a href=details.php?id=$arr2[torrent]&dllist=1#seeders>$arr2[torrent]");
if ($arr2[seeder] == 'yes')
print("<font color=red> * </font>");
print("</a></td><td class=tableb align=center>$arr2[agent]</td></tr>\n");
}
print("</table>\n");
end_frame();
}
}


if ($HTTP_SERVER_VARS["REQUEST_METHOD"] == "POST"){
$dt = sqlesc(get_date_time());
$msg = $_POST['msg'];
if (!$msg)
stderr("Error","Please Type In Some Text");

$query = mysql_query("SELECT distinct userid FROM peers WHERE connectable='no'");
while($dat=mysql_fetch_assoc($query)){
mysql_query("INSERT INTO messages (sender, receiver, added, msg, folder_in, subject) VALUES (0,$dat[userid] , '" . get_date_time() . "', " . sqlesc($msg) .", -3, 'Not Connectable')") or sqlerr(__FILE__,__LINE__);
}
mysql_query("INSERT INTO notconnectablepmlog ( user , date ) VALUES ( $CURUSER[id], $dt)") or sqlerr(__FILE__,__LINE__);
header("Refresh: 0; url=findnotconnectable.php");
hit_end();

}

if ($_GET['action'] == "sendpm") {
stdhead("Peers that are unconnectable");

begin_frame("<h3>Massen PM an alle User die Not Connectable sind</h>");
?>
<form method=post action=findnotconnectable.php>
<?

if ($_GET["returnto"] || $_SERVER["HTTP_REFERER"])
{
?>
<input type=hidden name=returnto value=<?=$_GET["returnto"] ? $_GET["returnto"] : $_SERVER["HTTP_REFERER"]?>>
<?
}
//default message
$body = "
Unsere Trackersoftware hat festgestellt das deine Verbindung für andere User nicht erreichbar ist (not connectable),das kann folgende Gründe haben.
1.deine Verbindung wird durch deine PC Firewall geblockt,weil du deinen Clienten nicht in deiner Firewall freigegeben hast.
2.du benutzt einen Router für deine Verbindung und hast die von dir benutzten Clientports nicht freigegeben.

Lies unsere F.A.Q, Tutorials oder informiere dich in unserem IRC wie du dies abstellen kannst.

mfg der Staff!!!";
?>
<table cellspacing=0 cellpadding=5>
<tr>
<td><br>
<table style="border: 0" width="100%" cellpadding="0" cellspacing="0">
<tr>
<td style="border: 0">&nbsp;</td>
<td style="border: 0">&nbsp;</td>
</tr>
</table>
</td>
</tr>
<tr><td><textarea name=msg cols=120 rows=15><?=$body?></textarea></td></tr>
<tr>
<tr><td colspan=2 align=center><input type=submit value="Send" class=btn></td></tr>
</table>
<input type=hidden name=receiver value=<?=$receiver?>>
</form>

</div></td></tr></table>
<br>
NOTE: No HTML Code Allowed. (NO HTML)
<?
}
if ($_GET['action'] == ""){
stdhead("Unconnectable Peers Mass PM Log");

$getlog = mysql_query("SELECT * FROM `notconnectablepmlog` LIMIT 10");

begin_frame("<font color=red><h3>Not Connectable Peers Massen-PM Logbuch</h></font>");
print("<p class=table align=center><font color><h3><center>zeigt an wann die letzte PM an die User gesendet wurde</center></h></font></p>");

print("<table border=0 cellspacing=1 cellpadding=4 align=center class=tableinborder width=100%>\n");
print("<td class=tableb align=center><a href=findnotconnectable.php?action=list><font color=red><h4><center>zeige alle Not Connectable User</center></h></font></td></p>");

print("<table border=0 cellspacing=1 cellpadding=5 align=center class=tableinborder width=60%>\n");
print("<tr><td class=tableb align=center colhead><center>Prüfer</center></td><td class=tableb align=center colhead><center>Datum/Uhrzeit</center></td><td class=tableb align=center colhead><center>geprüft und<br><center>PM verschickt</center></br></td></tr>");
while($arr2 = mysql_fetch_assoc($getlog)){
$r2 = mysql_query("SELECT username FROM users WHERE id=$arr2[user]") or sqlerr();
$a2 = mysql_fetch_assoc($r2);
$elapsed = get_elapsed_time(sql_timestamp_to_unix_timestamp($arr2[date]));
print("<tr><td class=tableb align=center colhead><center><a href=userdetails.php?id=$arr2[user]>$a2[username]</a></center></td><td class=tableb align=center colhead><center>$arr2[date]</center></td><td class=tableb align=center><center>vor $elapsed</center></td></tr>");
}
print("</table>");
end_frame();

}

stdfoot();

?>