<?
//////////////////////Doppelte IP´s Genehmigen und Verwalten by bliZZarD for bt-technik//////////////A////////
require "include/bittorrent.php";
dbconn(false);
loggedinorreturn();
if(get_user_class()<UC_SYSOP) stderr("Fehler", "Zugriff Verweigert.");
stdhead("Geduldete Doppel IP Nutzung");
begin_frame("<b><font size=2 align=center>Erlaubte Doppel IP Nutzer</b></font><tr></tr>", false, "100%");

begin_table(TRUE);
print"<div align=Center>
<p><b><u>Auflistung aller Mitglieder die mit Erlaubnis Doppelte IP´s Nutzen dürfen auf dem Tracker
</u></b></p><hr><font size=2><b><u>Erklärungen:<br></u></b></font><br><b><u>-Ehem.Accs</u> =
Erkennung der Mehrfach Genuzten Account´s durch die Unique ID<br><br><u>-D-IP.Accs</u> = Erkennung der Mehrfach Genuzten
Account´s durch die IP-Adresse</b><hr><br></div> ";
print"<br><tr style='font-weight:normal'><td class=tablecat>Mitglied</td><td class=tablecat>Login-IP</td><td 
class=tablecat>Peer-IP</td><td
class=tablecat>Letzte Aktivität</td><td class=tablecat>Begründung</td><td
class=tablecat>Ratio</td><td class=tablecat>Ehem.Accs</td><td class=tablecat>D-IP.Accs</td></tr>\n";


//////////////////////////ABFRAGE BEREICH per SQL QUERY ANFANG/////////////////////////////////////////////////////
$res=mysql_query("SELECT id,username,ip,uploaded,downloaded,last_access,warned,donor,enabled,dipcomment FROM users WHERE
dipok='yes' ORDER BY IP DESC") or sqlerr();
while($row=mysql_fetch_array($res)){

  $up=$row["uploaded"];
  $dn=$row["downloaded"];
  $ratio=number_format($up/$dn, 2);

  $lastseen = $row["last_access"];

if ($lastseen == "0000-00-00 00:00:00")
  $lastseen = "nochnie";
else
{
  $lastseen ="" . get_elapsed_time(sql_timestamp_to_unix_timestamp($lastseen)) . "";
}
//////////Ehemalige Accounts Abfrage
$uidres = mysql_query("SELECT DISTINCT(`chash`) FROM `accounts` WHERE `userid`=" . $row["id"]);
        $acccnt = 0;
        while ($chash = mysql_fetch_assoc($uidres)) {
        $ucntarr = mysql_fetch_assoc(mysql_query("SELECT COUNT(*) AS `cnt` FROM `accounts` WHERE `chash`="
        . sqlesc($chash["chash"]) . " AND `userid`<>" . $row["id"]));
        $acccnt += $ucntarr["cnt"];
}

//////Doppelte IP Nutzung
$ipto = mysql_query("SELECT COUNT(id) FROM `users` AS iplist WHERE `ip` = '" . $row["ip"] . "'") or sqlerr(__FILE__,
__LINE__);
$row12 = mysql_fetch_row($ipto);
$ipuse = $row12[0];
$ipcheck=$row["ip"];

$peer_res = mysql_query("SELECT count(*) FROM peers WHERE ip = " . sqlesc($row['ip']) . " AND userid = " . $row['id']);
$peer_row = mysql_fetch_row($peer_res);

//////////////////////////ABFRAGE BEREICH per SQL QUERY ENDE/////////////////////////////////////////////////////

print"<tr><td class=tableb><a href=userdetails.php?id=".$row["id"].">".$row["username"]. get_user_icons($row, true)
."</a></td>";
print"<td class=tablea align=right>$ipcheck</td><td class=tablea>" .
($peer_row[0] ? "ja" : "nein") . "</td></td><td class=tableb
align=right>$lastseen</td><td class=tablea>" . $row[dipcomment] . "</td>";
print"<td class=tablea><font color=". $ratio .">$ratio</font></td>";

if ($acccnt == 0){
print"<td class=tableb><center>-</center></td>";
}
else
{
print"<td class=tableb><center><a
href=\"startstoplog.php?op=acclist&amp;id=$row[id]\"><b><font color=red>".$acccnt."</font></b></a></center></td>";
}
if ($ipuse == 1)
{
print"<td class=tablea><center>-</center></td>";

} else
{

print"<td class=tablea><center><a href=usersearch.php?ip=$ipcheck><b><font
color=red>".$ipuse."</font></b></a></center></td>";
}
}
print"</tr>\n";
end_table();
print"<tr><td class=tabletitle><center><b>Modifziert von bliZZarD</b></center></td></tr>";
stdfoot();
//////////////////////Doppelte IP´s Genehmigen und Verwalten by bliZZarD for bt-technik//////////////E////////
?>