<?php

/*
// +--------------------------------------------------------------------------+
// | Project:    NVTracker - NetVision BitTorrent Tracker                     |
// +--------------------------------------------------------------------------+
// | This file is part of NVTracker. NVTracker is based on BTSource,          |
// | originally by RedBeard of TorrentBits, extensively modified by           |
// | Gartenzwerg.                                                             |
// |                                                                          |
// | NVTracker is free software; you can redistribute it and/or modify        |
// | it under the terms of the GNU General Public License as published by     |
// | the Free Software Foundation; either version 2 of the License, or        |
// | (at your option) any later version.                                      |
// |                                                                          |
// | NVTracker is distributed in the hope that it will be useful,             |
// | but WITHOUT ANY WARRANTY; without even the implied warranty of           |
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the            |
// | GNU General Public License for more details.                             |
// |                                                                          |
// | You should have received a copy of the GNU General Public License        |
// | along with NVTracker; if not, write to the Free Software Foundation,     |
// | Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA            |
// +--------------------------------------------------------------------------+
// | Obige Zeilen dürfen nicht entfernt werden!    Do not remove above lines! |
// +--------------------------------------------------------------------------+
*/


function local_user()
{
    global $_SERVER;

    return $_SERVER["SERVER_ADDR"] == $_SERVER["REMOTE_ADDR"];
} 

if (!file_exists("include/secrets.php") || !file_exists("include/config.php"))
    die("<html><head><title>FEHLER</title></head><body><p>Der Tracker wurde noch nicht konfiguriert.</p>
        <p><a href=\"inst/install.php\">Zum Installationsscript</a></p></body></html>");

require_once("include/secrets.php");
require_once("include/config.php");
require_once("include/cleanup.php");
require_once("include/shoutcast.php");

/**
 * *** validip/getip courtesy of manolete <manolete@myway.com> ***
 */
// IP Validation
function validip($ip)
{
    if (!empty($ip) && ip2long($ip) != -1) {
        // reserved IANA IPv4 addresses
        // http://www.iana.org/assignments/ipv4-address-space
        $reserved_ips = array (
            array('0.0.0.0', '2.255.255.255'),
            array('10.0.0.0', '10.255.255.255'),
            array('127.0.0.0', '127.255.255.255'),
            array('169.254.0.0', '169.254.255.255'),
            array('172.16.0.0', '172.31.255.255'),
            array('192.0.2.0', '192.0.2.255'),
            array('192.168.0.0', '192.168.255.255'),
            array('255.255.255.0', '255.255.255.255')
            );

        foreach ($reserved_ips as $r) {
            $min = ip2long($r[0]);
            $max = ip2long($r[1]);
            if ((ip2long($ip) >= $min) && (ip2long($ip) <= $max)) return false;
        } 
        return true;
    } else return false;
} 
// Patched function to detect REAL IP address if it's valid
function getip()
{
    if (validip($_SERVER['HTTP_CLIENT_IP']))
        return $_SERVER['HTTP_CLIENT_IP'];
    elseif ($_SERVER['HTTP_X_FORWARDED_FOR'] != "") {
        $forwarded = str_replace(",", "", $_SERVER['HTTP_X_FORWARDED_FOR']);
        $forwarded_array = split(" ", $forwarded);
        foreach($forwarded_array as $value) if (validip($value)) return $value;
    } 
    return $_SERVER['REMOTE_ADDR'];
} 
//BEGIN: Account parken by volcem
function parked()
{
       global $CURUSER;
       if ($CURUSER["parked"] == "yes")
stderr("Fehler", "Dein Account steht auf Parken.");
}
//ENDE: Account parken by volcem
function dbconn($autoclean = false)
{
    global $mysql_host, $mysql_user, $mysql_pass, $mysql_db, $_SERVER;

    if (!@mysql_connect($mysql_host, $mysql_user, $mysql_pass)) {
        switch (mysql_errno()) {
            case 1040:
            case 2002:
                if ($_SERVER["REQUEST_METHOD"] == "GET")
                    die("<html><head><meta http-equiv=refresh content=\"5 " . $_SERVER["REQUEST_URI"] . "\"></head>
                         <body><table border=0 width=100% height=100%><tr><td><h3 align=center>Die Serverlast
                         ist momentan zu hoch. Versuche es erneut, bitte warten...
                         </h3></td></tr></table></body></html>");
                else
                    die("Zu viele Benutzer. Bitte benutze den Aktualisieren-Button Deines Browsers,
                         um es erneut zu versuchen.");
            default:
                die("[" . mysql_errno() . "] dbconn: mysql_connect: " . mysql_error());
        } 
    } 
    mysql_select_db($mysql_db)
    or die('dbconn: mysql_select_db: ' + mysql_error());

    userlogin();

    if ($autoclean)
        register_shutdown_function("autoclean");
} 

function userlogin()
{
    global $SITE_ONLINE;
    unset($GLOBALS["CURUSER"]);

    $ip = getip();
    $nip = ip2long($ip);
    $res = mysql_query("SELECT * FROM bans WHERE $nip >= first AND $nip <= last") or sqlerr(__FILE__, __LINE__);
    if (mysql_num_rows($res) > 0) {
        header("HTTP/1.0 403 Forbidden");
        print("<html><body><h1>403 Forbidden</h1>Unauthorized IP address.</body></html>\n");
        die;
    } 
    // Neues sessionbasiertes Login für bessere Performance und Anzeige neuer Torrents
    session_start();

    if (!$SITE_ONLINE || (!isset($_SESSION["userdata"]) && (empty($_COOKIE["uid"]) || empty($_COOKIE["pass"]))))
        return;

    if (isset($_SESSION["userdata"])) {
        // Aktivierungsstatus und IP prüfen (Session hijacking vermeiden)
        $enabled = mysql_fetch_assoc(mysql_query("SELECT COUNT(*) AS `cnt` FROM `users` WHERE `id` = " . $_SESSION["userdata"]["id"] . " AND `enabled`='yes' AND `status` = 'confirmed'"));
        if ($enabled["cnt"] != 1 || $_SESSION["userdata"]["ip"] != $ip) {
            session_unset();
            session_destroy();
            return;
        } 
        $GLOBALS["CURUSER"] = $_SESSION["userdata"];
    } else {
        // Keine Session aktiv, login via Cookie
        $id = 0 + $_COOKIE["uid"];
        if (!$id || strlen($_COOKIE["pass"]) != 32)
            return;
        $res = mysql_query("SELECT * FROM users WHERE id = $id AND enabled='yes' AND status = 'confirmed'"); // or die(mysql_error());
        $row = mysql_fetch_array($res);
        if (!$row)
            return;
        $sec = hash_pad($row["secret"]);
        if ($_COOKIE["pass"] !== $row["passhash"])
            return;

        /* mysql_query("UPDATE users SET last_access='" . get_date_time() . "', ip='$ip' WHERE id=" . $row["id"]);// or die(mysql_error()); */

        $row['ip'] = $ip;
        $GLOBALS["CURUSER"] = $row;
        $_SESSION["userdata"] = $row;

        if (isset($_COOKIE["passhash"])) {
            $res = mysql_query("SELECT * FROM `accounts` WHERE `userid`=" . $GLOBALS["CURUSER"]["id"] . " AND `chash`=" . sqlesc($_COOKIE["passhash"]));
            if (mysql_num_rows($res))
                mysql_query("UPDATE `accounts` SET `lastaccess`=NOW() WHERE `userid`=" . $GLOBALS["CURUSER"]["id"]);
            else {
                $res = mysql_query("SELECT * FROM `accounts` WHERE `chash`=" . sqlesc($_COOKIE["passhash"]));
                if (mysql_num_rows($res)) {
                    $data = mysql_fetch_assoc($res);
                    $baduser = $data["baduser"];
                } else {
                    $baduser = 0;
                } 
                mysql_query("INSERT INTO `accounts` (`userid`,`chash`,`lastaccess`,`username`,`email`,`baduser`) VALUES (" . $row["id"] . "," . sqlesc($_COOKIE["passhash"]) . ", NOW(), " . sqlesc($row["username"]) . ", " . sqlesc($row["email"]) . ", " . $baduser . ")");
            } 
        } else {
            $res = mysql_query("SELECT * FROM `accounts` WHERE `userid`=" . $GLOBALS["CURUSER"]["id"]);
            if (mysql_num_rows($res)) {
                mysql_query("UPDATE `accounts` SET `lastaccess`=NOW() WHERE `userid`=" . $GLOBALS["CURUSER"]["id"]);
                $data = mysql_fetch_assoc($res);
                $hash = $data["chash"];
            } else {
                $hash = md5($row["username"] . mksecret() . $row["username"]);
                mysql_query("INSERT INTO `accounts` (`userid`,`chash`,`lastaccess`,`username`,`email`,`baduser`) VALUES (" . $row["id"] . "," . sqlesc($hash) . ", NOW(), " . sqlesc($row["username"]) . ", " . sqlesc($row["email"]) . ", 0)");
            } 
            setcookie("passhash", $hash, 0x7fffffff, "/");
        } 
    } 

    if ($GLOBALS["CURUSER"]["id"] != 1010) 
        // Letzten Zugriff aktualisieren
        mysql_query("UPDATE users SET last_access='" . date("Y-m-d H:i:s") . "', ip='$ip' WHERE id=" . $GLOBALS["CURUSER"]["id"]); // or die(mysql_error());
    if ($GLOBALS["CURUSER"]["accept_rules"] == "no" && !preg_match("/(takeprofedit|rules|faq|logout|delacct)\\.php$/", $_SERVER["PHP_SELF"])) {
        header("Location: rules.php?accept_rules");
        die();
    } 
} 

function logincookie($id, $passhash, $updatedb = 1, $expires = 0x7fffffff)
{
    setcookie("uid", $id, $expires, "/");
    setcookie("pass", $passhash, $expires, "/");

    if ($updatedb)
        mysql_query("UPDATE users SET last_login = NOW() WHERE id = $id");
} 

function logoutcookie()
{
    setcookie("uid", "", 0x7fffffff, "/");
    setcookie("pass", "", 0x7fffffff, "/");
    session_unset();
    session_destroy();
} 

function loggedinorreturn()
{
    global $CURUSER, $DEFAULTBASEURL;
    if (!$CURUSER) {
        header("Location: $DEFAULTBASEURL/login.php?returnto=" . urlencode($_SERVER["REQUEST_URI"]));
        exit();
    } 
}

function signupreturn()
{
    global $CURUSER, $DEFAULTBASEURL;
    if (!$CURUSER) {
        header("Location: $DEFAULTBASEURL/signup.php?returnto=" . urlencode($_SERVER["REQUEST_URI"]));
        exit();
    } 
} 

function autoclean()
{
    $now = time();
    $docleanup = 0;

    $res = mysql_query("SELECT value_u FROM avps WHERE arg = 'lastcleantime'");
    $row = mysql_fetch_array($res);
    if (!$row) {
        mysql_query("INSERT INTO avps (arg, value_u) VALUES ('lastcleantime',$now)");
        return;
    } 
    $ts = $row[0];
    if ($ts + $GLOBALS["AUTOCLEAN_INTERVAL"] > $now)
        return;
    mysql_query("UPDATE avps SET value_u=$now WHERE arg='lastcleantime' AND value_u = $ts");
    if (!mysql_affected_rows())
        return;

    docleanup();
} 

function unesc($x)
{
    if (get_magic_quotes_gpc())
        return stripslashes($x);
    return $x;
} 

function mksize($bytes)
{
    if ($bytes < 1000 * 1024)
        return number_format($bytes / 1024, 2, ",", ".") . " KB";
    elseif ($bytes < 1000 * 1048576)
        return number_format($bytes / 1048576, 2, ",", ".") . " MB";
    elseif ($bytes < 1000 * 1073741824)
        return number_format($bytes / 1073741824, 2, ",", ".") . " GB";
    elseif ($bytes < 1000 * 1099511627776)
        return number_format($bytes / 1099511627776, 2, ",", ".") . " TB";
    else
        return number_format($bytes / 1125899906842624, 2, ",", ".") . " PB";
} 

function mksizeint($bytes)
{
    $bytes = max(0, $bytes);
    if ($bytes < 1000)
        return number_format(floor($bytes), 0, ",", ".") . " B";
    elseif ($bytes < 1000 * 1024)
        return number_format(floor($bytes / 1024), 0, ",", ".") . " KB";
    elseif ($bytes < 1000 * 1048576)
        return number_format(floor($bytes / 1048576), 0, ",", ".") . " MB";
    elseif ($bytes < 1000 * 1073741824)
        return number_format(floor($bytes / 1073741824), 0, ",", ".") . " GB";
    elseif ($bytes < 1000 * 1099511627776)
        return number_format(floor($bytes / 1099511627776), 0, ",", ".") . " TB";
    else
        return number_format(floor($bytes / 1125899906842624), 0, ",", ".") . " PB";
} 

function deadtime()
{
    return time() - floor($GLOBALS["ANNOUNCE_INTERVAL"] * 1.3);
} 

function mkprettytime($s)
{
    if ($s < 0)
        $s = 0;
    $t = array();
    foreach (array("60:sec", "60:min", "24:hour", "0:day") as $x) {
        $y = explode(":", $x);
        if ($y[0] > 1) {
            $v = $s % $y[0];
            $s = floor($s / $y[0]);
        } else
            $v = $s;
        $t[$y[1]] = $v;
    } 

    if ($t["day"])
        return $t["day"] . "d " . sprintf("%02d:%02d:%02d", $t["hour"], $t["min"], $t["sec"]);
    if ($t["hour"])
        return sprintf("%d:%02d:%02d", $t["hour"], $t["min"], $t["sec"]); 
    // if ($t["min"])
    return sprintf("%d:%02d", $t["min"], $t["sec"]); 
    // return $t["sec"] . " secs";
} 

function mkglobal($vars)
{
    if (!is_array($vars))
        $vars = explode(":", $vars);
    foreach ($vars as $v) {
        if (isset($_GET[$v]))
            $GLOBALS[$v] = unesc($_GET[$v]);
        elseif (isset($_POST[$v]))
            $GLOBALS[$v] = unesc($_POST[$v]);
        else
            return 0;
    } 
    return 1;
} 

function tr($x, $y, $noesc = 0)
{
    if ($noesc)
        $a = $y;
    else {
        $a = htmlspecialchars($y);
        $a = str_replace("\n", "<br />\n", $a);
    } 
    print("<tr><td class=\"tableb\" valign=\"top\" align=\"left\">$x</td><td class=\"tablea\" valign=\"top\" align=left>$a</td></tr>\n");
} 

function validfilename($name)
{
    return preg_match('/^[^\0-\x1f:\\\\\/?*\xff#<>|]+$/si', $name);
} 

function validemail($email)
{
    return preg_match('/^[\w.-]+@([\w.-]+\.)+[a-z]{2,6}$/is', $email);
} 

function sqlesc($x)
{
    return "'" . mysql_real_escape_string($x) . "'";
} 

function sqlwildcardesc($x)
{
    return str_replace(array("%", "_"), array("\\%", "\\_"), mysql_real_escape_string($x));
} 

function urlparse($m)
{
    $t = $m[0];
    if (preg_match(',^\w+://,', $t))
        return "<a href=\"$t\">$t</a>";
    return "<a href=\"http://$t\">$t</a>";
} 

function parsedescr($d, $html)
{
    if (!$html) {
        $d = htmlspecialchars($d);
        $d = str_replace("\n", "\n<br>", $d);
    } 
    return $d;
} 

function ratiostatbox()
{
    global $CURUSER;

    if ($CURUSER) {
        $ratio = ($CURUSER["downloaded"] > 0?number_format($CURUSER["uploaded"] / $CURUSER["downloaded"], 3, ",", "."):"Inf.");
        $seedsarr = @mysql_fetch_assoc(mysql_query("SELECT COUNT(*) AS `cnt` FROM `peers` WHERE `userid`=" . $CURUSER["id"] . " AND `seeder`='yes'"));
        $seeds = $seedsarr["cnt"];
        $leechesarr = @mysql_fetch_assoc(mysql_query("SELECT COUNT(*) AS `cnt` FROM `peers` WHERE `userid`=" . $CURUSER["id"] . " AND `seeder`='no'"));
        $leeches = $leechesarr["cnt"];
        $tlimits = get_torrent_limits($CURUSER);

        if ($ratio < 0.5) {
            $ratiowarn = " style=\"background-color:red;color:white;\"";
        } elseif ($ratio < 0.75) {
            $ratiowarn = " style=\"background-color:#FFFF00;color:black;\"";
        }

        if ($tlimits["seeds"] >= 0) {
            if ($tlimits["seeds"] - $seeds < 1)
                $seedwarn = " style=\"background-color:red;color:white;\"";
            $tlimits["seeds"] = " / " . $tlimits["seeds"];
        } else
            $tlimits["seeds"] = "";
        if ($tlimits["leeches"] >= 0) {
            if ($tlimits["leeches"] - $leeches < 1)
                $leechwarn = " style=\"background-color:red;color:white;\"";
            $tlimits["leeches"] = " / " . $tlimits["leeches"];
        } else
            $tlimits["leeches"] = "";
        if ($tlimits["total"] >= 0) {
            if ($tlimits["total"] - $leeches + $seeds < 1)
                $totalwarn = " style=\"background-color:red;color:white;\"";
            $tlimits["total"] = " / " . $tlimits["total"];
        } else
            $tlimits["total"] = "";

        ?>
              <tr><td class="tabletitle" style="padding: 4px;"><b><?=htmlspecialchars($CURUSER["username"])?> :.</b></td>
              </tr>
              <tr><td class="tablea" style="padding-left: 4px;">
	            <table cellspacing="0" cellpadding="2" border="0" style="width:140px;">
		          <tr><td><b>Download:</b></td><td style="text-align:right"><?=mksize($CURUSER["downloaded"])?></td>
		          </tr>
		          <tr><td><b>Upload:</b></td><td style="text-align:right"><?=mksize($CURUSER["uploaded"])?></td>
		          </tr>
		          <tr><td><b>Ratio:</b></td><td style="text-align:right" style="color:<?=get_ratio_color($ratio)?>"><?=$ratio?></td></tr>
		          <tr><td colspan="2">&nbsp;</td></tr>
		          <tr<?=$seedwarn?>><td><b>Seeds:</b></td><td style="text-align:right"><?=$seeds . $tlimits["seeds"]?></td>
		          </tr>
		          <tr<?=$leechwarn?>><td><b>Leeches:</b></td><td style="text-align:right"><?=$leeches . $tlimits["leeches"]?></td>
		          </tr>
		          <tr<?=$totalwarn?>><td><b>Gesamt:</b></td><td style="text-align:right"><?=($seeds + $leeches) . $tlimits["total"]?></td>
		          </tr>
				   </table>
              </td></tr>
<?php } 
} 

function stdhead($title = "", $msgalert = true)
{
    global $CURUSER, $_SERVER, $PHP_SELF;

    if (!$GLOBALS["SITE_ONLINE"])
        die("Die Seite ist momentan aufgrund von Wartungsarbeiten nicht verfügbar.<br>");

    header("Content-Type: text/html; charset=iso-8859-1");
    header("Pragma: No-cache");
    header("Expires: 300");
    header("Cache-Control: private");

    if ($title == "")
        $title = $GLOBALS["SITENAME"];
    else
        $title = $GLOBALS["SITENAME"] . " :: " . htmlspecialchars($title);

    if ($CURUSER) {
        $ss_a = @mysql_fetch_assoc(@mysql_query("SELECT `uri` FROM `stylesheets` WHERE `id`=" . $CURUSER["stylesheet"]));
        if ($ss_a) $GLOBALS["ss_uri"] = $ss_a["uri"];
    } 

    if (!$GLOBALS["ss_uri"]) {
        ($r = mysql_query("SELECT `uri` FROM `stylesheets` WHERE `default`='yes'")) or die(mysql_error());
        ($a = mysql_fetch_assoc($r)) or die(mysql_error());
        $GLOBALS["ss_uri"] = $a["uri"];
    } 

    if ($msgalert && $CURUSER) {
        $res = mysql_query("SELECT COUNT(*) FROM `messages` WHERE `folder_in`<>0 AND `receiver`=" . $CURUSER["id"] . " && `unread`='yes'") or die("OopppsY!");
        $arr = mysql_fetch_row($res);
        $unread = $arr[0];
        if ($CURUSER["class"] >= UC_MODERATOR) {
            $res = mysql_query("SELECT COUNT(*) FROM `messages` WHERE `sender`=0 AND `receiver`=0 && `mod_flag`='open'") or die("OopppsY!");
            $arr = mysql_fetch_row($res);
            $unread_mod = $arr[0];
        } 
    } 

    $fn = substr($PHP_SELF, strrpos($PHP_SELF, "/") + 1);
    $logo_pic = $GLOBALS["PIC_BASE_URL"] . $GLOBALS["ss_uri"] . "/";
    if (file_exists($logo_pic . "logo.gif")) $logo_pic .= "logo.gif";
    if (file_exists($logo_pic . "logo_top.gif")) $logo_pic .= "logo_top.gif";
    if (file_exists($logo_pic . "logo.jpg")) $logo_pic .= "logo.jpg";
    if (file_exists($logo_pic . "logo_top.jpg")) $logo_pic .= "logo_top.jpg";
    if (file_exists($logo_pic . "logo.png")) $logo_pic .= "logo.png";
    if (file_exists($logo_pic . "logo_top.png")) $logo_pic .= "logo_top.png";
    if (file_exists("header.jpg")) $logo_pic .= "header.jpg";
    if (file_exists($logo_pic . "header.gif")) $logo_pic .= "header.gif";

    ?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
        "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title><?=$title?></title>
<script type="text/javascript" src="java_klappe.js"></script>
<script language="JavaScript">
<!--
function popUp(URL) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', & #39;toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=50
0,height=300,left = 426,top = 332');");
}
//////////////////// Kommentera modd ////////////////////////
$res = mysql_query("SELECT torrent_id AS torrent FROM completed WHERE user_id=$CURUSER[id]");

while($row = mysql_fetch_array($res)){
$thx = mysql_fetch_array(mysql_query("SELECT count(*) FROM thanks WHERE userid='$CURUSER[id]' AND torrentid='$row[torrent]'"));
$kom = mysql_fetch_array(mysql_query("SELECT count(*) FROM comments WHERE user='$CURUSER[id]' AND torrent='$row[torrent]'"));
$vot = mysql_fetch_array(mysql_query("SELECT count(*) FROM ratings WHERE user='$CURUSER[id]' AND torrent='$row[torrent]'"));
$tor = mysql_fetch_array(mysql_query("SELECT name,owner FROM torrents WHERE id='$row[torrent]'"));
if ($tor[owner] != $CURUSER[id]){
if (!$kom[0] && !$thx[0] && $tor != "")
{
 $komment .= "Du hast <a href=details.php?id=".$row[torrent].">".$tor[name]."</a> fertig<br>";
}
elseif (!$vot[0] && $tor != "")
{
 $komment .= "Du hast <a href=details.php?id=".$row[torrent].">".$tor[name]."</a> fertig<br>";
}
}
}
/////////////////////////////////////////////////
/////Abfrage/Bereich//////__ANFANG__24 Mitglieder Statistik by bliZZarD for NV///////////Abfrage/Bereich//////////

$dt24 = gmtime() - 86400;
$arr = mysql_fetch_assoc(mysql_query("SELECT * FROM avps WHERE arg='last24'")) or $no24=true;
$res=mysql_query("SELECT * FROM users WHERE last_access >= '". get_date_time($dt24). "' ORDER BY username") or sqlerr(__FILE__, __LINE__);
$totalonline24 = mysql_num_rows($res);

$_ss24 = ($totalonline24 != 1) ? 'er':'';


$last24record = get_date_time($arr["value_u"]);
$last24 = $arr["value_i"];
if ($no24 || $totalonline24 > $last24 )
{
$last24 = $totalonline24;

$period = strtotime(gmdate("Y-m-d H:i:s"));
mysql_query(($no24 ? 'INSERT':'UPDATE'). " avps SET value_i = $last24 , value_u = $period ". ($no24 ? ", arg='last24'":"WHERE arg='last24'")) or sqlerr();
}

while ($arr = mysql_fetch_assoc($res))
{
if ($activeusers24) $activeusers24 .= ",\n";

if($arr['class'] != '1')
   $arr["username"] = "<font class=".get_class_color($arr["class"]).">" . $arr["username"] . "</font>";

if($donator = $arr["donor"] === "yes");
$activeusers24 .= "<nobr>";
if ($warned = $arr["warned"] === "yes")
$activeusers24 .= "<nobr>";
if ($CURUSER)
$activeusers24 .= "<a href=userdetails.php?id=" . $arr["id"] . "><b>" . $arr["username"] . "</b></a>";
else
$activeusers24 .= "<b>{$arr["username"]}</b>";
if ($donator)
$activeusers24 .= "<img src={$pic_base_url}/pic/star.gif alt='Donated {$$arr["donor"]}'></nobr>";
if ($warned)
$activeusers24 .= "<img src={$pic_base_url}/pic/warned.gif alt='Warned {$$arr["warned"]}'></nobr>";
}

if (!$activeusers24)
$activeusers24 = "Es waren die letzten 24H keine Mitglieder aktiv auf dem Tracker.";

while ($arr = mysql_fetch_assoc($res))
{
    if ($activeusers) $activeusers .= ",\n";
    $arr["username"] = "<font class=".get_class_color($arr["class"]).">" . $arr["username"] . "</font>";
    if ($CURUSER)
        $activeusers .= "<a href=userdetails.php?id=" . $arr["id"] . "><b>" . $arr["username"] . "</b></a>";
    else
        $activeusers .= "<b>$arr[username]</b>";

    $activeusers .= "&nbsp;".get_user_icons($arr);
}

if (!$activeusers)
    $activeusers = "Keine aktiven Mitglieder in den letzten 15 Minuten.";
   
////Abfrage/Bereich//////___ENDE___24 Mitglieder Statistik by bliZZarD for NV///////////Abfrage/Bereich//////////
//-->
</script>
<script LANGUAGE="JavaScript">

function winopen(seite, breit, hoch)
{
window.open(seite,"testwin",'width=' + breit + ', height=' + hoch +' ,toolbar=no, scrollbars=yes, resizable=no');
}

</script>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="Content-Script-Type" content="text/javascript">
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="expires" content="300">
<meta http-equiv="cache-control" content="private">
<meta name="robots" content="noindex, nofollow, noarchive">
<meta name="MSSmartTagsPreventParsing" content="true">
<script type="text/javascript" src="overlib.js"></script>
<script type="text/javascript" src="cookies.js"></script>
</SCRIPT>
<link rel="stylesheet" href="css/lightbox.css" type="text/css" media="screen" />
<script type="text/javascript" src="js/prototype.js"></script>
<script type="text/javascript" src="js/scriptaculous.js?load=effects"></script>
<script type="text/javascript" src="js/lightbox.js"></script>
<script type="text/javascript">
<!--
var popup_mode = 1;
function popup_change(){
var expdate = new Date();
expdate.setTime (expdate.getTime() + (5 * 365 * 24 * 60 * 60 * 1000));
setCookie("NO_INFO_POPUPS", popup_mode, expdate, "/", "torrents.netcomlan.com.com", 0);
var thelink = document.getElementById("popup_change_link");
if (popup_mode){
 thelink.innerHTML = "Show tooltip";
}
else{
 thelink.innerHTML = "Hide tooltip";
}
popup_mode = (popup_mode + 1) % 2;
nd();
}
-->
</script>
<script language=javascript>


function doTEXT(message,subject,topic,form,text,form2,id){
var helptextbox = document.getElementById('helptxt');
var help = document.getElementById('help');

var txt = "";

    document.forms[form].elements[text].value = "";
    document.forms[form].elements[text].value = document.forms[form].elements[text].value+""+message+"";
    document.forms[form].elements[subject].value = "";
    document.forms[form].elements[subject].value = document.forms[form].elements[subject].value+""+topic+"";
    document.forms[form].elements[text].focus();

if (id=='1') {
addtext("Jeder der Uploader Rechte erhalten möchte kann hier schon einmal seine Daten angeben. Ihr erhaltet dann");
}
}

 function addtext( txt ) {
var help = document.getElementById('helptxt2');
     document.help.value += txt;
  	helptxt.style.display = 'block';

	  }

function pruefen() {
var radiovalue = null;
for (var i=0; i<document.forms[support].what.length; i++) {
if (document.support.what[i].checked) {
radiovalue = document.support.what[i].value;
}
}
if (radiovalue == null) {
return alert("Du hast keine Option gewählt");
}
}
</script>

<script type="text/javascript" src="include/overlib/overlib.js"></script>
<script language="JavaScript">< src="overlib.js"><!-- overLIB (c) Erik Bosrup //--></script>
<link rel="stylesheet" href="<?=$GLOBALS["PIC_BASE_URL"] . $GLOBALS["ss_uri"] . "/" . $GLOBALS["ss_uri"]?>.css" type="text/css">
<?php if ($GLOBALS["DYNAMIC_RSS"]) {
        ?>
<link rel="alternate" title="Dein Tracker RSS" href="<?=$BASEURL?>/rss.php" type="application/rss+xml">
<link rel="alternate" title="Dein Tracker RSS (Direktdownload)" href="<?=$BASEURL?>/rss.php?type=directdl" type="application/rss+xml">
<link rel="alternate" title="Dein Tracker RSS (Benutzerkategorien)" href="<?=$BASEURL?>/rss.php?categories=profile" type="application/rss+xml">
<link rel="alternate" title="Dein Tracker RSS (Benutzerkategorien, Direktdownload)" href="<?=$BASEURL?>/rss.php?categories=profile&type=directdl" type="application/rss+xml">

<?php } 
    ?>

<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="interface.js"></script>
<!--[if lt IE 7]>
<style type="text/css">
.dock img { behavior: url(iepngfix.htc) }
</style>
<![endif]-->

</head>

<body onLoad="show_clock()">
<?
if ($CURUSER) {
session_unset();
$_SESSION["userdata"] = mysql_fetch_assoc(mysql_query("SELECT * FROM `users` WHERE `id` = " . $CURUSER["id"]));
}
?>

<table style="width:90%" cellpadding="0" cellspacing="1" align="center" border="0" class="tableoutborder">
  <tr>
    <td class="mainpage" align="center">
      <table style="width:100%" border="0" cellspacing="0" cellpadding="0">
        <tr> 
          <td class="logobackground" align="left"><center><a href="index.php?sid="><img src="<?=$logo_pic?>" border="0" width="100%" alt="Made by Djbrocken" title="Made by Djbrocken" /></a></td>
        </tr>
      </table>
<style type="text/css">.imcm ul,.imcm li,.imcm div,.imcm span,.imcm a{text-align:center;vertical-align:top;padding:0px;margin:0;list-style:none outside none;border-style:none;background-image:none;clear:none;float:none;display:block;position:static;overflow:visible;line-height:normal;}.imcm li a img{display:inline;border-width:0px;}.imcm span{display:inline;}.imcm .imclear,.imclear{clear:both;height:0px;visibility:hidden;line-height:0px;font-size:1px;}.imcm .imsc{position:relative;}.imcm .imsubc{position:absolute;visibility:hidden;}.imcm li{list-style:none;font-size:1px;float:left;}.imcm ul ul li{width:100%;float:none !important;}.imcm a{display:block;position:relative;}.imcm ul .imsc,.imcm ul .imsubc {z-index:10;}.imcm ul ul .imsc,.imcm ul ul .imsubc{z-index:20;}.imcm ul ul ul .imsc,.imcm ul ul ul .imsubc{z-index:30;}.imde ul li:hover .imsubc{visibility:visible;}.imde ul ul li:hover  .imsubc{visibility:visible;}.imde ul ul ul li:hover  .imsubc{visibility:visible;}.imde li:hover ul  .imsubc{visibility:hidden;}.imde li:hover ul ul .imsubc{visibility:hidden;}.imde li:hover ul ul ul  .imsubc{visibility:hidden;}.imcm .imea{display:block;position:relative;center:0px;font-size:1px;line-height:1px;height:0px;width:1px;float:right;}.imcm .imea span{display:block;position:relative;font-size:1px;line-height:0px;}.dvs,.dvm{border-width:0px}/*\*//*/.imcm .imea{visibility:hidden;}/**/</style><!--[if IE]><style type="text/css">.imcm .imea span{position:absolute;}.imcm .imclear,.imclear{display:none;}.imcm{zoom:1;} .imcm li{curosr:hand;} .imcm ul{zoom:1}.imcm a{zoom:1;}</style><![endif]--><!--[if gte IE 7]><style type="text/css">.imcm .imsubc{background-image:url(ie_css_fix);}</style><![endif]--><!--end-->
<style type="text/css">
div.center { text-align:center; }

	/* --[[ Main Expand Icons ]]-- */
	#imenus0 .imeam span,#imenus0 .imeamj span {background-image:url(sample3_main_arrow.gif); width:7px; height:30px; left:-7px; top:8px; background-repeat:no-repeat;background-position:top center;}
	#imenus0 li:hover .imeam span,#imenus0 li a.iactive .imeamj span {background-image:url(sample3_main_arrow.gif); background-repeat:no-repeat;background-position:top left;}


	/* --[[ Sub Expand Icons ]]-- */
	#imenus0 ul .imeas span,#imenus0 ul .imeasj span {background-image:url(sample13_sub_expand_default.gif); width:7px; height:9px; left:-7px; top:3px; background-repeat:no-repeat;background-position:top left;}
	#imenus0 ul li:hover .imeas span,#imenus0 ul li a.iactive .imeasj span {background-image:url(sample13_sub_expand_on.gif); background-repeat:no-repeat;background-position:top left;}


	/* --[[ Main Container ]]-- */
	#imouter0 {background-image:url(sample13_main_bg.gif); border-style:none; border-color:#000000; border-width:0px; padding:0px; margin:15px 0px 0px; }


	/* --[[ Sub Container ]]-- */
	#imenus0 li ul {background-color:#404040; align:center; border-style:outset; border-color:#000000; border-width:0px 0px 0px; padding:0px; align:center; margin:0px 0px 0px; }


	/* --[[ Main Items ]]-- */
	#imenus0 li a, #imenus0 .imctitle { text-align:center; font-family:Arial; font-size:14px; font-weight:bolder ; text-decoration:none; border-style:outset; border-color:black; border-width: 0.5px 0px 0px; padding:10px 0px 0px 0px; }

		/* [hover] - These settings must be duplicated for IE compatibility.*/
		#imenus0 li:hover>a {background-color:#000000; color:#dddddd; border-style:inset; border-color:#000000; }
		#imenus0 li a.ihover, .imde imenus0 a:hover {background-image:url(sample13_main_bg.gif); color:#57509E; border-style:inset; border-color:#000000; }

		/* [active] */
		#imenus0 li a.iactive {}


	/* --[[ Sub Items ]]-- */
	#imenus0 ul a, #imenus0 .imsubc li .imctitle  {color:#ffffff; text-align:left; font-size:11px; font-weight:normal; text-decoration:none; border-style:none; border-color:#000000; border-width:1px; padding:2px 5px; }

		/* [hover] - These settings must be duplicated for IE comptatibility.*/
		#imenus0 ul li:hover>a {background-color:#606060; color:#ffffcc; border-style:none; border-color:yellow; }
		#imenus0 ul li a.ihover {background-color:#606060; color:#ffffcc; border-style:none; border-color:yellow; }

		/* [active] */
		#imenus0 ul li a.iactive {text-decoration:underline; }


</style><!--end-->
<?php
 if ($CURUSER)
 {
$res = mysql_query("SELECT downloaded FROM users WHERE id=$CURUSER[id]") or sqlerr(__FILE__, __LINE__);
    $arr = mysql_fetch_row($res);
    $curuserdownloaded = $arr[0];
    $res = mysql_query("SELECT uploaded FROM users WHERE id=$CURUSER[id]") or sqlerr(__FILE__, __LINE__);
    $arr = mysql_fetch_row($res);
    $curuseruploaded = $arr[0];
$ratio = ($curuserdownloaded > 0?number_format(($curuseruploaded + $curuserseederbonusupload) / $curuserdownloaded, 3):"Inf.");
$res99 = mysql_query("SELECT seedbonus FROM users WHERE id=$CURUSER[id]") or sqlerr(__FILE__, __LINE__);
$arr99 = mysql_fetch_assoc($res99);
$bonus = number_format($arr99['seedbonus'], 1);
//Messages
$res = mysql_query("SELECT COUNT(*) FROM `messages` WHERE `folder_in` AND `receiver`=" . $CURUSER["id"]) or die("0");
$arr = mysql_fetch_row($res);
$inbox = $arr[0];
$res = mysql_query("SELECT COUNT(*) FROM `messages` WHERE `folder_out` AND `sender`=" . $CURUSER["id"]) or die("0");
$arr = mysql_fetch_row($res);
$sentbox = $arr[0];
//connectable anzeige start
$res5 = mysql_query("SELECT connectable FROM peers WHERE userid=" . $CURUSER["id"] . "")or sqlerr(__FILE__, __LINE__);
if($row = mysql_fetch_row($res5)){
$connect = $row[0];
if($connect == "yes"){
$connectable = "<a title='Alles O.K! Gute Verbindung!'><b><font color=green>Yes ;)</a></font></b>";
$connectable_color = "green";
}else{
$connectable = "<b><a title='Wenn du ständig nicht connectable bist hast du Locale Probleme!'><font color=red>Du bist nicht Connectable</a></font></b>";
$connectable_color = "red";
}
}else{
$connectable ="<b><a title='Unbekannt'><font color=blue>Keine Connections zur Zeit</font></a></b>";
$connectable_color = "blue";
}


         $seedsarr = @mysql_fetch_assoc(mysql_query("SELECT COUNT(*) AS `cnt` FROM `peers` WHERE `userid`=" . $CURUSER["id"] . " AND `seeder`='yes'"));
        $seeds = $seedsarr["cnt"];
        $leechesarr = @mysql_fetch_assoc(mysql_query("SELECT COUNT(*) AS `cnt` FROM `peers` WHERE `userid`=" . $CURUSER["id"] . " AND `seeder`='no'"));
        $leeches = $leechesarr["cnt"];
		        $tlimits = get_torrent_limits($CURUSER);

        if ($ratio < 0.5) {
            $ratiowarn = " style=\"background-color:red;color:white;\"";
        } elseif ($ratio < 0.75) {
            $ratiowarn = " style=\"background-color:#FFFF00;color:black;\"";
        }

        if ($tlimits["seeds"] >= 0) {
            if ($tlimits["seeds"] - $seeds < 1)
                $seedwarn = " style=\"background-color:red;color:white;\"";
            $tlimits["seeds"] = " / " . $tlimits["seeds"];
        } else
            $tlimits["seeds"] = "";
        if ($tlimits["leeches"] >= 0) {
            if ($tlimits["leeches"] - $leeches < 1)
                $leechwarn = " style=\"background-color:red;color:white;\"";
            $tlimits["leeches"] = " / " . $tlimits["leeches"];
        } else
            $tlimits["leeches"] = "";
        if ($tlimits["total"] >= 0) {
            if ($tlimits["total"] - $leeches + $seeds < 1)
                $totalwarn = " style=\"background-color:red;color:white;\"";
            $tlimits["total"] = " / " . $tlimits["total"];
        } else
            $tlimits["total"] = "";
			}

?>


      <?php
 if ($CURUSER)
 { ?>

<table cellpadding="0" cellspacing="0" border="0" style="width:100%" class="tablea" class="tableinborder">

<tr><td class="tablea"><table cellpadding="4" cellspacing="1" border="0" style="width:100%" class="tableinborder"></center>      
<tr><td class=tablecat><center><b>
<a href="userdetails.php?id=<?=$CURUSER["id"]?>">
<?php if(date("G") < 12) {$a="Guten Morgen $CURUSER[username]";} 
if(date("G") <= 18 && date("G") >= 12) {$a="Guten Tag $CURUSER[username]";} 
if(date("G") >= 19) {$a="Guten Abend $CURUSER[username]";} echo $a; ?></a>
</b></center></td>





<td class=tablecat><center><a href=userdetails.php?id=<?=$CURUSER["id"]?>>Mein Profil</a></center></td>
<td class=tablecat><center><a href=mytorrents.php>Meine Torrents</a></center></td>
<td class=tablecat><center><a href=messages.php>Nachrichten <?php
        if ($unread || $unread_mod)
            echo "&nbsp;&nbsp;";

        if ($unread) {
            echo "<img src=\"" . $GLOBALS["PIC_BASE_URL"] . "multipage.gif\" border=\"0\"> <b>$unread</b>";
            if ($unread_mod)
                echo "&nbsp;&nbsp;";
        } 

        if ($unread_mod) {
            echo "<img src=\"" . $GLOBALS["PIC_BASE_URL"] . "multipagemod.gif\" border=\"0\"> <b>$unread_mod</b>";
        } 

        ?></a></center></td>
<td class=tablecat><center><a href=logout.php>Ausloggen</a></center></td>
<td class=tablecat><center>Uhrzeit: <script language="javascript" src="liveclock.js"></script></center>
<center>Datum <?php
$datum=date("j.n.Y");
$zeit=date("H:i");

echo "$datum";
?></center></td></tr></table>
  <tr>
   <td class="tablea"><table cellpadding="0" cellspacing="1" border="0" style="width:100%" class="tableinborder"><center><script type="text/javascript" src="data-deluxe-menu.js"></script></center>      
</td></tr>
<?php
 }
?>

      <table style="width:100%"  align="left" border="0" cellspacing="0" cellpadding="0">
        <tr>
          <td valign="top" align="left" valign="top" style="padding: 2px;width:160px">

<? if (!$CURUSER) ?>


<table cellpadding=3 align=center width=80% class=tableoutborder cellspacing=1>
 <tr><td class="tabletitle" style="padding: 4px;"><b><?=htmlspecialchars($CURUSER["username"])?> :.</b></td></tr>
              <tr><td class="tablea" style="padding-left: 4px;">
                <table cellspacing="0" cellpadding="2" border="0" style="width:90px;">
              <tr><td style="text-align:left;padding:4px" class="Stil1"><b>Avatar:</b> <img width="137" src="<?=$CURUSER["avatar"]?>" /></td></tr>
<td class="bottom" align="left">


<br><?php print(" <b><font color=\"$connectable_color\">Connectable:</font></b>  $connectable"); ?><br/>

<br>Deine IP: <b><?=htmlspecialchars($CURUSER["ip"])?></b>

<br>
<br><a href="mybonus.php" title="Seeder Bonus">Seeder-Bonus:</font></a> <?echo " $bonus";?><span class="Stil1"></span></span>&nbsp;&nbsp;


<br><font color="#0000FF"><b>Ratio:&nbsp;</b></font><?echo "$ratio";?> </font> </font>&nbsp;&nbsp;

<br><font color="#00CC00"><b>Upload:</b></font> <?=mksize($CURUSER["uploaded"])?> </font>&nbsp;&nbsp;

<br><font color=red><b>Download:</b></font> <?=mksize($CURUSER["downloaded"])?>  </font>&nbsp;&nbsp;
<br>
<br><font color=1900D1><b>Aktiv:</b>&nbsp;</font> <?=($seeds + $leeches) . $tlimits["total"]?></span></font>&nbsp;&nbsp;
    <img alt="Torrents seeding" title="Torrents seeding" src="pic/arrowup.gif">&nbsp;<?=$seeds . $tlimits["seeds"]?>&nbsp;&nbsp;
    <img alt="Torrents leeching" title="Torrents leeching" src="pic/arrowdown.gif">&nbsp;<?=$leeches . $tlimits["leeches"]?>&nbsp;



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

$index  = "<table cellpadding=3 align=center width=100% class=tableoutborder cellspacing=1>
<tr><td class=tablea><a href=index.php>News</a></td></tr>
<tr><td class=tablea><a href=menu.php>User Extra Menü</a></td></tr>
<tr><td class=tablea><a href=partner.php>Partner</td></tr>
<tr><td class=tablea><a href=contactstaff.php title=Hier kannst du eine Nachricht an das Team schicken bei Problemen oder Unklarheiten>Team kontaktieren</a></td></tr>
</table>\n";





$torrents = "<table cellpadding=3 align=center width=100% class=tableoutborder cellspacing=1>
<tr><td class=tablea><a href=browse.php>Durchsuchen</a></td></tr>
<tr><td class=tablea><a href=upload.php>Hochladen</a></td></tr>
<tr><td class=tablea><a href=http://www.cover-paradies.to/ target=_blank>Cover</a></td></tr>
<tr><td class=tablea><a href=mytorrents.php>Meine Torrents</a></td></tr>
<tr><td class=tablea><a href=requests.php>Requests</a></td></tr>
</table>\n";

if ($unread || $unread_mod) {
            $nachrichten = "<img src=pic/unread.gif border=0> <b>$unread <font color=red>$unread_mod</font></b>";
        } 

$user = "<table cellpadding=3 align=center width=100% class=tableoutborder cellspacing=1>
<tr><td class=tablea><a href=userdetails.php?id=$CURUSER[id]>Dein Profil</a></td></tr>
<tr><td class=tablea><a href=my.php>Profil bearbeiten</a></td></tr>
<tr><td class=tablea><a href=friends.php>Buddyliste</a></td></tr>
<tr><td class=tablea><a href=messages.php>Posteingang $nachrichten</a></td></tr>        
<tr><td class=tablea><a href=logout.php>Ausloggen</a></td></tr> 
</table>\n";



{
$resa = mysql_query("select count(id) as numreports from reports WHERE dealtwith=0");
$arra = mysql_fetch_assoc($resa);
$numreports = $arra[numreports];

if ($numreports > 0)

$meldungen= "<tr><td class=tablea><a href=reports.php><font color=red>Meldungen ($numreports)</font></a></td></tr>";
else

$meldungen= "<tr><td class=tablea><a href=reports.php>Meldungen</a></td></tr>";
}

$sup = "<table cellpadding=3 align=center width=100% class=tableoutborder cellspacing=1>
<tr><td class=tablea><a href=staffbox.php>Teamnachrichten</a></td></tr>       
</table>\n";



$mod = "<table cellpadding=3 align=center width=100% class=tableoutborder cellspacing=1>
<tr><td class=tablea><a href=controlpanel.php>Controlpanel</a></td></tr>
<tr><td class=tablea><a href=log.php>Site Log</a></td></tr>
<tr><td class=tablea><a href=staffbox.php>Teamnachrichten</a></td></tr>
<tr><td class=tablea><a href=usersearch.php>Benutzersuche</a></td></tr>
$meldungen
</table>\n";


$login = "<table cellpadding=3 align=center width=100% class=tableoutborder cellspacing=1>
<tr><td class=tablea><a href=login.php>Einloggen</a></td></tr>
<tr><td class=tablea><a href=signup.php>Registrieren</a></td></tr>
<tr><td class=tablea><a href=recover.php>Passwort anfordern</a></td></tr>
</table>\n";



$radio = "<table cellpadding=3 align=center width=100% class=tableoutborder cellspacing=1>
<tr><td class=tablea>
<?include('radio.php');?>
</td></tr></table>\n";

$tspeak = "<table cellpadding=3 align=center width=100% class=tableoutborder cellspacing=1>
<tr><td class=tablea>
<?include('swatch.php');?>
</td></tr></table>\n"; 



print("<table align=left width=160px><tr><td align=center>");


if ($CURUSER) {
if ($CURUSER["showtspeaknav"] == "yes") 
  {
if ($CURUSER["tspeaknav"] == "open")
{
print("<table cellpadding=3 cellspacing=1 class=tableinborder width=100%><tr><td class=tabletitle align=left><a href=\"javascript: klappe_news('a13".$array['id']."')\"><img border=\"0\" src=\"pic/minus.gif\" id=\"pica13".$array['id']."\" alt=\"Show/Hide\"></a>   <b><u>Swatch :.</u></b></td></tr></table><div id=\"ka13".$array['id']."\" style=\"display: block;\">
<table cellpadding=3 align=center width=50% class=tableoutborder cellspacing=1><tr><td class=tablea>");
include('swatch.php');
print("</td></tr></table>\n</div>\n");
  }
else
{
print("<table cellpadding=3 cellspacing=1 class=tableinborder width=100%><tr><td class=tabletitle align=left><a href=\"javascript: klappe_news('a13".$array['id']."')\"><img border=\"0\" src=\"pic/plus.gif\" id=\"pica13".$array['id']."\" alt=\"Show/Hide\"></a>   <b><u>Swatch :.</u></b></td></tr></table><div id=\"ka13".$array['id']."\" style=\"display: none;\">
<table cellpadding=3 align=center width=50% class=tableoutborder cellspacing=1><tr><td class=tablea>");
include('swatch.php');
print("</td></tr></table>\n</div>\n");
} 
 }
if ($CURUSER["indexnav"] == "open")
{
print("<table cellpadding=3 cellspacing=1 class=tableinborder width=100%><tr><td class=tabletitle align=left><a href=\"javascript: klappe_news('a2".$array['id']."')\"><img border=\"0\" src=\"pic/minus.gif\" id=\"pica2".$array['id']."\" alt=\"Show/Hide\"></a>   <b><u>Dein Tracker</u></b></td></tr></table><div id=\"ka2".$array['id']."\" style=\"display: block;\">$index</div>\n");
}
else
{  
print("<table cellpadding=3 cellspacing=1 class=tableinborder width=100%><tr><td class=tabletitle align=left><a href=\"javascript: klappe_news('a2".$array['id']."')\"><img border=\"0\" src=\"pic/plus.gif\" id=\"pica2".$array['id']."\" alt=\"Show/Hide\"></a>   <b><u>Dein Tracker</u></b></td></tr></table><div id=\"ka2".$array['id']."\" style=\"display: none;\">$index</div>\n");
}



if ($CURUSER["tornav"] == "open")
{
print("<table cellpadding=3 cellspacing=1 class=tableinborder width=100%><tr><td class=tabletitle align=left><a href=\"javascript: klappe_news('a4".$array['id']."')\"><img border=\"0\" src=\"pic/minus.gif\" id=\"pica4".$array['id']."\" alt=\"Show/Hide\"></a>   <b><u>Torrents :.</u></b></td></tr></table><div id=\"ka4".$array['id']."\" style=\"display: block;\">$torrents</div>\n");
}
else
{
print("<table cellpadding=3 cellspacing=1 class=tableinborder width=100%><tr><td class=tabletitle align=left><a href=\"javascript: klappe_news('a4".$array['id']."')\"><img border=\"0\" src=\"pic/plus.gif\" id=\"pica4".$array['id']."\" alt=\"Show/Hide\"></a>   <b><u>Torrents :.</u></b></td></tr></table><div id=\"ka4".$array['id']."\" style=\"display: none;\">$torrents</div>\n");
}
if ($CURUSER["usernav"] == "open")
{
print("<table cellpadding=3 cellspacing=1 class=tableinborder width=100%><tr><td class=tabletitle align=left><a href=\"javascript: klappe_news('a5".$array['id']."')\"><img border=\"0\" src=\"pic/minus.gif\" id=\"pica5".$array['id']."\" alt=\"Show/Hide\"></a>   <b><u>User CP :.</td></tr></table><div id=\"ka5".$array['id']."\" style=\"display: block;\">$user</div>\n");
}
else
{
print("<table cellpadding=3 cellspacing=1 class=tableinborder width=100%><tr><td class=tabletitle align=left><a href=\"javascript: klappe_news('a5".$array['id']."')\"><img border=\"0\" src=\"pic/plus.gif\" id=\"pica5".$array['id']."\" alt=\"Show/Hide\"></a>   <b><u>User CP :.</td></tr></table><div id=\"ka5".$array['id']."\" style=\"display: none;\">$user</div>\n");
}



if (get_user_class() >= UC_MODERATOR) 
{
if ($CURUSER["adminnav"] == "open")
{
print("<table cellpadding=3 cellspacing=1 width=100% class=tableoutborder><tr><td class=tabletitle align=left><a href=\"javascript: klappe_news('a10".$array['id']."')\"><img border=\"0\" src=\"pic/minus.gif\" id=\"pica10".$array['id']."\" alt=\"Show/Hide\"></a>   <b><u>Moderation :.</td></tr></table><div id=\"ka10".$array['id']."\" style=\"display: block;\">$mod</div>\n");
}
else
{
print("<table cellpadding=3 cellspacing=1 width=100% class=tableoutborder><tr><td class=tabletitle align=left><a href=\"javascript: klappe_news('a10".$array['id']."')\"><img border=\"0\" src=\"pic/plus.gif\" id=\"pica10".$array['id']."\" alt=\"Show/Hide\"></a>   <b><u>Moderation :.</td></tr></table><div id=\"ka10".$array['id']."\" style=\"display: none;\">$mod</div>\n");
}
}
if (get_user_class() == UC_MODERATOR) 
{
if ($CURUSER["supnav"] == "open")
{
print("<table cellpadding=3 cellspacing=1 width=100% class=tableoutborder><tr><td class=tabletitle align=left><a href=\"javascript: klappe_news('a11".$array['id']."')\"><img border=\"0\" src=\"pic/minus.gif\" id=\"pica11".$array['id']."\" alt=\"Show/Hide\"></a>   <b><u>Support :.</td></tr></table><div id=\"ka11".$array['id']."\" style=\"display: block;\">$sup</div>\n");
}
else
{
print("<table cellpadding=3 cellspacing=1 width=100% class=tableoutborder><tr><td class=tabletitle align=left><a href=\"javascript: klappe_news('a11".$array['id']."')\"><img border=\"0\" src=\"pic/plus.gif\" id=\"pica11".$array['id']."\" alt=\"Show/Hide\"></a>   <b><u>Support :.</td></tr></table><div id=\"ka11".$array['id']."\" style=\"display: none;\">$sup</div>\n");
}
}
}

else {
print("<table cellpadding=3 cellspacing=1 width=100% class=tableoutborder><tr><td class=tabletitle align=left><a href=\"javascript: klappe_news('a12".$array['id']."')\"><img border=\"0\" src=\"pic/minus.gif\" id=\"pica12".$array['id']."\" alt=\"Show/Hide\"></a>   <b><u>Account :.</u></b></td></tr></table><div id=\"ka12".$array['id']."\" style=\"display: block;\">$login</div>\n");
}
?>  
      
</td></tr></table>
          </td>
          <td valign="top" align="center" style="padding: 5px;width:100%">

<!-- Reports / Helpdesk MOD -->
<?
  if (get_user_class() >=UC_MODERATOR)
  {
    $reportsres= mysql_query("SELECT * FROM reports WHERE dealtwith=0");
    if (mysql_num_rows($reportsres)>0)
       {
       	 print("<p><table border=0 cellspacing=0 cellpadding=10 bgcolor=red><tr><td style='padding: 10px; background: red'>\n");
       	 print("<b><a href='reports.php'><font color='white'><h2>Offene Reports zur Bearbeitung</font></b> 
                	 
".mysql_num_rows($reportsres)."</a></h2>");
print("</td></tr></table></p>\n");
       }
    
} 
?>
<!-- reports helpdesk mod END -->
<?php
if (get_user_class() >=UC_MODERATOR)
{
$reportsres= mysql_query("SELECT * FROM reports WHERE dealtwith=0");
if (mysql_num_rows($reportsres)>0)
{
print("<p><table border=1 cellspacing=0 cellpadding=10 bgcolor=red><tr><td style='padding: 10px; background: red'>\n");
print("<b><a href=$BASEURL/reports.php><font color=white>Offene Reports zur Bearbeitung</font></b>
".mysql_num_rows($reportsres)."</a></h2>");
print("</td></tr></table></p>\n");
}
}

schongewusst();

$announcement = $CURUSER['announce'];
if ($announcement == "yes")
{
  print("<p><table border=0 cellspacing=0 cellpadding=10 bgcolor=url(pic/newmessage.png)><tr><td style='padding: 10px; background: Blue'>\n");
  print("<b><a href=$BASEURL/announcement.php><font color=white>Neue Ankündigung!</font></a></b>");
  print("</td></tr></table></p>\n");
}
if ($CURUSER["werbung"] == "0") {
?>


<?
}
if ($unread_mod)
{
  print("<p><table border=0 cellspacing=0 cellpadding=10><tr><td style='padding: 10px; background: url(pic/logoblue.gif);'>\n");
  print("<b><a href=$BASEURL/messages.php?folder=-4><font color=black>Du hast $unread_mod neue MOD-Nachricht" . ($unread_mod > 1 ? "en" : "") . "!</font></a></b>");
  
print("</td></tr></table></p>\n");

}

if ($CURUSER["dsl_speed"] == "0")
{
  print("<p><table border=0 cellspacing=0 cellpadding=10 bgcolor=red><tr><td style='padding: 10px; background: red'>\n");
  print("<b><a href=$BASEURL/my.php><font color=white>Du hast deinen DSL Speed nicht angegeben  (Klick zum ändern im Profil)!</font></a></b>");
  print("</td></tr></table></p>\n");
} 
if ($CURUSER["gender"] == "0")
{
  print("<p><table border=0 cellspacing=0 cellpadding=10 bgcolor=red><tr><td style='padding: 10px; background: red'>\n");
  print("<b><a href=$BASEURL/my.php><font color=white>Du hast deinen Familienstand nicht angegeben (Klick zum ändern im Profil)!</font></a></b>");
  print("</td></tr></table></p>\n");
} 


  
// blub blub by S4NE ;)
$warneduntil = $CURUSER['warneduntil'];
if ($CURUSER['warned'] == 'yes' AND $CURUSER['permban'] == 'no') {
print("<p><table border=1 width=75% cellspacing=0 cellpadding=10 bgcolor=#8daff5 align=center><tr><td style='padding: 10px;'bgcolor=red align=center>\n");
print("<b><font color=white align=center>Du wurdest von einem Staffmember verwarnt, wegen deines Verhalten auf dem Tracker. Wir bitten dich darum das dies nicht noch einmal vorkommt.<br>In " . mkprettytime(strtotime($warneduntil) - gmtime()) . " ist die Verwarnung abgelaufen.</font></b>");
print("</td></tr></table></p>\n");
print("<br>\n");
}
// End MOD...


// by S4NE^^
$warneduntil = $CURUSER['warneduntil'];
if ($CURUSER['systemwarn'] == 'yes' AND $CURUSER['warnedby'] == 'System'){
print("<p><table border=1 width=75% cellspacing=0 cellpadding=10 bgcolor=#8daff5 align=center><tr><td style='padding: 10px;'bgcolor=red align=center>\n");
print("<b><font color=white align=center>Du wurdest vom System verwarnt, wegen einer schlechten Ratio. Wir bitten dich darum deine Ratio auf min. " . $GLOBALS["AUTO_REM_MIN_RATIO"] . " zu bekommen damit die Verwarnung entfernt wird.<br>Wenn du dies nicht in " . mkprettytime(strtotime($warneduntil) - gmtime()) . " schaffst wird dein Account gesperrt.</font></b>");
print("</td></tr></table></p>\n");
print("<br>\n");
}
// End MOD... 


if ($unread)
{
  print("<p><table border=0 cellspacing=0 cellpadding=10><tr><td style='padding: 10px; background: url(pic/newmessage.png); border='0' width='340' height='60''>\n");
  print("<b><center><a href=$BASEURL/messages.php><font color=white>Du hast $unread neue Nachricht" . ($unread > 1 ? "en" : "") . "!</font></a></center></b>");
  print("</td></tr></table></p><br>\n");
}




if ($unread)
{



}
if (get_user_class() >=UC_MODERATOR)
{
$staffmessres= mysql_query("SELECT * FROM staffmessages WHERE answered=0");
if (mysql_num_rows($staffmessres)>0)
{
print("<p><table border=0 cellspacing=0 cellpadding=10><tr><td style='padding: 10px; background: url(pic/newmessage.png); border='0' width='340' height='60''>\n");
print("<b><center><a href=$BASEURL/staffbox.php><font color=white>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Offene Team-Nachricht zur Bearbeitung:</font></b>
".mysql_num_rows($staffmessres)."</a></center></h2>");
print("</td></tr></table></p><br>\n");
}
}

} 


// stdhead

function schongewusst()
{
?>

<table cellpadding="4" cellspacing="1" border="0" style="width:100%" class="tableinborder">
 <tr class="tabletitle" width="100%">
  <td colspan="10" width="100%"><span class="normalfont"><center><b> Schon gewusst? </b></center></span></td>
 </tr>
<?
$query = "SELECT * FROM schongewusst ORDER BY RAND() LIMIT 1";
$sql = mysql_query($query);
while ($row = mysql_fetch_array($sql)) {
$text = $row['text'];

echo ("<tr>
        <td width=100% class=tablea>
          <center>".$text."</center>
        </td>
       </tr>");
}
?>
</td></tr></table><br/>
<link rel="stylesheet" type="text/css" href="ajaxtabs/ajaxtabs.css" />
<script type="text/javascript" src="ajaxtabs/ajaxtabs.js"></script>
<?php
} // stdhead
function stdfoot()
{

    ?>
          </td>
        </tr>
      </table>
    </td>
  </tr>  
</table>
</body>
</html>
<?php
} 

function genbark($x, $y)
{
    stdhead($y);

    ?>

<table cellpadding="4" cellspacing="1" border="0" style="width:100%" class="tableinborder">
 <tr>
  <td class="tabletitle" colspan="10" width="100%"><span class="normalfont"><center><b> <?=htmlspecialchars($y)?> </b></center></span></td> 
 </tr><tr><td width="100%" class="tablea"><?=htmlspecialchars($x)?></td></tr></table><br>
<?php
    stdfoot();
    exit();
} 

function mksecret($len = 20)
{
    $ret = "";
    for ($i = 0; $i < $len; $i++)
    $ret .= chr(mt_rand(0, 255));
    return $ret;
} 

function httperr($code = 404)
{
    header("HTTP/1.0 404 Not found");
    print("<h1>Not Found</h1>\n");
    print("<p>Sorry pal :(</p>\n");
    exit();
} 

function gmtime()
{
    return strtotime(get_date_time());
} 

function deletetorrent($id, $owner = 0, $comment = "")
{
    global $CURUSER;

    $torrent = mysql_fetch_assoc(mysql_query("SELECT name,numpics FROM torrents WHERE id = $id")); 
    // Delete pictures associated with torrent
    if ($torrent["numpics"] > 0) {
        for ($I = 1; $I <= $torrent["numpics"]; $I++) {
            @unlink($GLOBALS["BITBUCKET_DIR"] . "/t-$id-$I.jpg");
            @unlink($GLOBALS["BITBUCKET_DIR"] . "/f-$id-$I.jpg");
        } 
    } 
    // Delete NFO image
    @unlink($GLOBALS["BITBUCKET_DIR"] . "/nfo-$id.png");
    mysql_query("DELETE FROM torrents WHERE id = $id");
    mysql_query("DELETE FROM traffic WHERE torrentid = $id");
    foreach(explode(".", "peers.files.comments.ratings.nowait") as $x)
    mysql_query("DELETE FROM $x WHERE torrent = $id");
    @unlink($GLOBALS["TORRENT_DIR"] . "/$id.torrent"); 
    // Send notification to owner if someone else deleted the torrent
    if ($CURUSER && $owner > 0 && $CURUSER["id"] != $owner) {
        $msg = sqlesc("Dein Torrent '$torrent[name]' wurde von [url=$DEFAULTBASEURL/userdetails.php?id=" . $CURUSER["id"] . "]" . $CURUSER["username"] . "[/url] gelöscht.\n\n[b]Grund:[/b]\n" . $comment);
        sendPersonalMessage(0, $owner, "Einer Deiner Torrents wurde gelöscht", $msg, PM_FOLDERID_SYSTEM, 0);
    } 
} 

function pager($rpp, $count, $href, $opts = array())
{
    $pages = ceil($count / $rpp);

    if (!$opts["lastpagedefault"])
        $pagedefault = 0;
    else {
        $pagedefault = floor(($count - 1) / $rpp);
        if ($pagedefault < 0)
            $pagedefault = 0;
    } 

    if (isset($_GET["page"])) {
        $page = 0 + $_GET["page"];
        if ($page < 0)
            $page = $pagedefault;
    } else
        $page = $pagedefault;

    $pager = "";

    $mp = $pages - 1;
    $as = "<b>&lt;&lt;&nbsp;Zurück</b>";
    if ($page >= 1) {
        $pager .= "<a href=\"{$href}page=" . ($page - 1) . "\">";
        $pager .= $as;
        $pager .= "</a>";
    } else
        $pager .= $as;
    $pager .= "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
    $as = "<b>Weiter&nbsp;&gt;&gt;</b>";
    if ($page < $mp && $mp >= 0) {
        $pager .= "<a href=\"{$href}page=" . ($page + 1) . "\">";
        $pager .= $as;
        $pager .= "</a>";
    } else
        $pager .= $as;

    if ($count) {
        $pagerarr = array();
        $dotted = 0;
        $dotspace = 3;
        $dotend = $pages - $dotspace;
        $curdotend = $page - $dotspace;
        $curdotstart = $page + $dotspace;
        for ($i = 0; $i < $pages; $i++) {
            if (($i >= $dotspace && $i <= $curdotend) || ($i >= $curdotstart && $i < $dotend)) {
                if (!$dotted)
                    $pagerarr[] = "...";
                $dotted = 1;
                continue;
            } 
            $dotted = 0;
            $start = $i * $rpp + 1;
            $end = $start + $rpp - 1;
            if ($end > $count)
                $end = $count;
            $text = "$start&nbsp;-&nbsp;$end";
            if ($i != $page)
                $pagerarr[] = "<a href=\"{$href}page=$i\"><b>$text</b></a>";
            else
                $pagerarr[] = "<b>$text</b>";
        } 
        $pagerstr = join(" | ", $pagerarr);
        $pagertop = "<p align=\"center\">$pager<br />$pagerstr</p>\n";
        $pagerbottom = "<p align=\"center\">$pagerstr<br />$pager</p>\n";
    } else {
        $pagertop = "<p align=\"center\">$pager</p>\n";
        $pagerbottom = $pagertop;
    } 

    $start = $page * $rpp;

    return array($pagertop, $pagerbottom, "LIMIT $start,$rpp");
} 

function downloaderdata($res)
{
    $rows = array();
    $ids = array();
    $peerdata = array();
    while ($row = mysql_fetch_assoc($res)) {
        $rows[] = $row;
        $id = $row["id"];
        $ids[] = $id;
        $peerdata[$id] = array(downloaders => 0, seeders => 0, comments => 0);
    } 

    if (count($ids)) {
        $allids = implode(",", $ids);
        $res = mysql_query("SELECT COUNT(*) AS c, torrent, seeder FROM peers WHERE torrent IN ($allids) GROUP BY torrent, seeder");
        while ($row = mysql_fetch_assoc($res)) {
            if ($row["seeder"] == "yes")
                $key = "seeders";
            else
                $key = "downloaders";
            $peerdata[$row["torrent"]][$key] = $row["c"];
        } 
        $res = mysql_query("SELECT COUNT(*) AS c, torrent FROM comments WHERE torrent IN ($allids) GROUP BY torrent");
        while ($row = mysql_fetch_assoc($res)) {
            $peerdata[$row["torrent"]]["comments"] = $row["c"];
        } 
    } 

    return array($rows, $peerdata);
} 

function commenttable($rows)
{
    global $CURUSER, $HTTP_SERVER_VARS;

    $count = 0;
    foreach ($rows as $row) {
        begin_table(true);
        print("<colgroup><col width=\"150\"><col width=\"600\"></colgroup>\n");
        print("<tr><td colspan=\"2\" class=\"tablecat\">#" . $row["id"] . " by ");
        if (isset($row["username"])) {
            $title = $row["title"];
            if ($title == "")
                $title = get_user_class_name($row["class"]);
            else
                $title = htmlspecialchars($title);
            print("<a name=\"comm" . $row["id"] . "\" href=\"userdetails.php?id=" . $row["user"] . "\"><b>" .
                htmlspecialchars($row["username"]) . "</b></a>" . get_user_icons(array("donor" => $row["donor"], "enabled" => $row["enabled"], "warned" => $row["warned"])) . " ($title)\n");
        } else
            print("<a name=\"comm" . $row["id"] . "\"><i>(Gelöscht)</i></a>\n");

        print(" am " . $row["added"] .
            ($row["user"] == $CURUSER["id"] || get_user_class() >= UC_MODERATOR ? " - [<a href=\"comment.php?action=edit&amp;cid=$row[id]\">Bearbeiten</a>]" : "") .
            (get_user_class() >= UC_MODERATOR ? " - [<a href=\"comment.php?action=delete&amp;cid=$row[id]\">Löschen</a>]" : "") .
            ($row["editedby"] && get_user_class() >= UC_MODERATOR ? " - [<a href=\"comment.php?action=vieworiginal&amp;cid=$row[id]\">Original anzeigen</a>]" : "") . "</td></tr>\n");
        $avatar = ($CURUSER["avatars"] == "yes" ? htmlspecialchars($row["avatar"]) : "");
        if (!$avatar)
            $avatar = $GLOBALS["PIC_BASE_URL"] . "default_avatar.gif";
        $text = stripslashes(format_comment($row["text"]));
        if ($row["editedby"])
            $text .= "<p><font size=\"1\" class=\"small\">Zuletzt von <a href=\"userdetails.php?id=$row[editedby]\"><b>$row[username]</b></a> am $row[editedat] bearbeitet</font></p>\n";
        print("<tr valign=\"top\">\n");
        print("<td class=\"tableb\" align=\"center\" style=\"padding: 0px;width: 150px\"><img width=\"150\" src=\"$avatar\" alt=\"Avatar von $row[username]\"></td>\n");
        print("<td class=\"tablea\">$text</td>\n");
        print("</tr>\n");
        end_table();
    } 
} 

function searchfield($s)
{
    return preg_replace(array('/[^a-z0-9]/si', '/^\s*/s', '/\s*$/s', '/\s+/s'), array(" ", "", "", " "), $s);
} 

function genrelist() {
global $CURUSER;
if ($CURUSER["27"] != 'no'){
$ret = array();   
$res = mysql_query("SELECT id, name FROM categories ORDER BY name");
    while ($row = mysql_fetch_array($res))
        $ret[] = $row;
    return $ret;

}
else
{
$ret = array();   
$res = mysql_query("SELECT id, name FROM categories WHERE id != '27' ORDER BY name");
    while ($row = mysql_fetch_array($res))
        $ret[] = $row;
    return $ret;
}
}

function tagelist()
{
    $ret = array();
    $res = mysql_query("SELECT id, name FROM tage ORDER BY id");
    while ($row = mysql_fetch_array($res))
    $ret[] = $row;
    return $ret;
} 
function dayslist()
{
    $ret = array();
    $res = mysql_query("SELECT id, name FROM days ORDER BY id");
    while ($row = mysql_fetch_array($res))
    $ret[] = $row;
    return $ret;
} 
function monthslist()
{
    $ret = array();
    $res = mysql_query("SELECT id, name FROM months ORDER BY id");
    while ($row = mysql_fetch_array($res))
    $ret[] = $row;
    return $ret;
} 
function hourslist()
{
    $ret = array();
    $res = mysql_query("SELECT id, name FROM hours ORDER BY id");
    while ($row = mysql_fetch_array($res))
    $ret[] = $row;
    return $ret;
} 
function minuteslist()
{
    $ret = array();
    $res = mysql_query("SELECT id, name FROM minutes ORDER BY id");
    while ($row = mysql_fetch_array($res))
    $ret[] = $row;
    return $ret;
} 
function yearslist()
{
    $ret = array();
    $res = mysql_query("SELECT id, name FROM years ORDER BY id");
    while ($row = mysql_fetch_array($res))
    $ret[] = $row;
    return $ret;
} 

function linkcolor($num)
{
    if ($num == 0)
        return "red";
    return "black";
} 

function ratingpic($num)
{
    $r = round($num * 2) / 2;
    if ($r < 1 || $r > 5)
        return;
    return "<img src=\"" . $GLOBALS["PIC_BASE_URL"] . "$r.gif\" border=\"0\" alt=\"rating: $num / 5\" />";
} 

function browse_sortlink($field, $params)
{
    if ($field == $_GET["orderby"]) {
        return "browse.php?orderby=$field&amp;sort=" . ($_GET["sort"] == "asc" ? "desc" : "asc") . "&amp;$params";
    } else {
        return "browse.php?orderby=$field&amp;sort=" . ($_GET["sort"] == "desc" ? "desc" : "asc") . "&amp;$params";
    } 
} 

function torrenttable_row_oldschool($torrent_info)
{
    global $CURUSER;

    if (strlen($torrent_info["name"]) > 45)
        $displayname = substr($torrent_info["name"], 0, 45) . "...";
    else
        $displayname = $torrent_info["name"];

    $returnto = "&amp;returnto=" . urlencode($_SERVER["REQUEST_URI"]);
    $baselink = "details.php?id=" . $torrent_info["id"];
    if ($torrent_info["variant"] == "index") {
        $baselink .= "&amp;hit=1";
        $filelistlink = $baselink . "&amp;filelist=1";
        $commlink = $baselink . "&amp;tocomm=1";
        $seederlink = $baselink . "&amp;toseeders=1";
        $leecherlink = $baselink . "&amp;todlers=1";
        $snatcherlink = $baselink . "&amp;tosnatchers=1";
    } else {
        $baselink .= $returnto;
        $filelistlink = $baselink . "&amp;filelist=1#filelist";
        $commlink = $baselink . "&amp;page=0#startcomments";
        $seederlink = $baselink . "&amp;dllist=1#seeders";
        $leecherlink = $baselink . "&amp;dllist=1#leechers";
        $snatcherlink = $baselink . "&amp;snatcher=1#snatcher";
    } 

    if ($torrent_info["leechers"])
        $ratio = $torrent_info["seeders"] / $torrent_info["leechers"];
    elseif ($torrent_info["seeders"])
        $ratio = 1;
    else
        $ratio = 0;

    $seedercolor = get_slr_color($ratio);

    ?>
<tr>
  ´?>
<tr>
  <td class="tableb" valign="top" style="width:1px;padding:0px;"><?php
    if (!isset($torrent_info["cat_pic"]))
        if ($torrent_info["cat_name"] != "")
            echo "<a href=\"browse.php?cat=" . $torrent_info["category"] . "\">" . $torrent_info["cat_name"] . "</a>";
        else
            echo "-";
        else
            echo "<a href=\"browse.php?cat=" . $torrent_info["category"] . "\"><img src=\"" . $GLOBALS["PIC_BASE_URL"] . $torrent_info["cat_pic"] . "\" alt=\"" . $torrent_info["cat_name"] . "\" title=\"" . $torrent_info["cat_name"] . "\" border=\"0\"></a>";

        ?></td>
  <td class="tablea" style="text-align:left;vertical-align:middle;" nowrap="nowrap"><?php if (isset($torrent_info["uploaderclass"]) && $torrent_info["uploaderclass"] < UC_UPLOADER) {
            echo '<font color="darkorange"></font> ';
        } 

if ($torrent_info["highlight"] == "yes") { 
?>
<a href="<?=$baselink?>"><b><font color=#CC0000><?=$torrent_info["name"]?></font></b></a><?php if ($torrent_info["variant"] != "guestuploads" && $torrent_info["is_new"]) echo " <font style=\"color:red\">(NEU)</font>";
}else{       
?>
<a href="<?=$baselink?>"><b><?=$torrent_info["name"]?></b></a><?php if ($torrent_info["variant"] != "guestuploads" && $torrent_info["is_new"]) echo " <font style=\"color:red\">(NEU)</font>";
}  
        ?>"><b><?=htmlspecialchars($displayname)?></b></a><?php if ($torrent_info["variant"] != "guestuploads" && $torrent_info["is_new"]) echo " <font style=\"color:red\">(NEU)</font>";
        if ($torrent_info["vip"] == "yes") echo " <font style=\"color:darkorange\">[VIP]</font>";
        ?></td>

  <?php if ($torrent_info["variant"] == "mytorrents") {
            ?>
  <td class="tablea" style="text-align:center;vertical-align:middle;" nowrap="nowrap"><a href="edit.php?id=<?=$torrent_info["id"] . $returnto?>">Bearbeiten</a></td>
  <td class="tablea" style="text-align:center;vertical-align:middle;" nowrap="nowrap"><?=($torrent_info["visible"] == "yes"?"Ja":"Nein")?></td>
  <?php } elseif ($torrent_info["variant"] == "guestuploads") {
            ?>
if ($torrent_info["nuked"] == "yes") {
            echo '<img src=/pic/nuked.gif title=Dieses File ist Nuked (Grund findet Ihr in den Torrentdetails)> ';
            }
            if ($torrent_info["nuked"] == "unnuked") {
            echo '<img src=/pic/nukedr.gif title=Dieses File wurde Unnuked (Grund findet Ihr in den Torrentdetails)> ';
            }
  <td class="tablea" style="text-align:center;vertical-align:middle;" nowrap="nowrap"><?php if ($torrent_info["gu_agent"] > 0) echo "Ja";
            else echo "<font color=\"red\">Nein</font>";
            ?></td>  
  <?php } elseif ($torrent_info["has_wait"]) {

            ?>
  <td class="tablea" style="text-align:center;vertical-align:middle;" nowrap="nowrap"><?php echo "<font color=\"", $torrent_info["wait_color"], "\">", $torrent_info["wait_left"], "<br>Std.</font>";

            ?></td>
  <?php } 

        ?>

  <td class="tablea" style="text-align:right;vertical-align:middle;" nowrap="nowrap"><a href="<?=$filelistlink?>"><?=$torrent_info["numfiles"]?></a></td>
  <td class="tablea" style="text-align:right;vertical-align:middle;" nowrap="nowrap"><a href="<?=$commlink?>"><?=$torrent_info["comments"]?></a></td>
  <td class="tablea" style="text-align:center;vertical-align:middle;" nowrap="nowrap"><?=str_replace("&nbsp;", "<br>", $torrent_info["added"])?></td>
  <td class="tablea" style="text-align:center;vertical-align:middle;" nowrap="nowrap"><?=str_replace(" ", "<br>", $torrent_info["ttl"])?></td>
  <td class="tablea" style="text-align:center;vertical-align:middle;" nowrap="nowrap"><?=str_replace(" ", "<br>", mksize($torrent_info["size"]))?></td>
  <td class="tablea" style="text-align:center;vertical-align:middle;" nowrap="nowrap"><div style="border:1px solid black;padding:0px;width:60px;height:10px;"><div style="border:none;width:<?=60 * $torrent_info["dist"] / 100?>px;height:10px;background-image:url(<?=$GLOBALS["PIC_BASE_URL"]?>ryg-verlauf-small.png);background-repeat:no-repeat;"></div></div></td>
  <td class="tablea" style="text-align:center;vertical-align:middle;" nowrap="nowrap"><a href="<?=$snatcherlink?>"><?=$torrent_info["times_completed"]?></a></td>
  <td class="tablea" style="text-align:center;vertical-align:middle;" nowrap="nowrap"><a href="<?=$seederlink?>"><font color="<?=$seedercolor?>"><?=intval($torrent_info["seeders"])?></font></a></td>
  <td class="tablea" style="text-align:center;vertical-align:middle;" nowrap="nowrap"><a href="<?=$leecherlink?>"><font color="<?=linkcolor($torrent_info["seeders"])?>"><?=intval($torrent_info["leechers"])?></font></a></td>
  <td class="tablea" style="text-align:left;vertical-align:middle;" nowrap="nowrap">D:&nbsp;<?=$torrent_info["dlspeed"]?>&nbsp;KB/s<br>U:&nbsp;<?=$torrent_info["ulspeed"]?>&nbsp;KB/s</td>
  <?php if ($torrent_info["variant"] == "index") {

            ?>
  <td class="tablea" style="text-align:left;vertical-align:middle;" nowrap="nowrap"><?=$torrent_info["uploaderlink"]?></td>
  <?php } 

        ?>  
</tr>
<?php
    }

    function torrenttable_row($torrent_info)
    {
        global $CURUSER;

        $returnto = "&amp;returnto=" . urlencode($_SERVER["REQUEST_URI"]);
        $baselink = "details.php?id=" . $torrent_info["id"];
        if ($torrent_info["variant"] == "index") {
            $baselink .= "&amp;hit=1";
            $filelistlink = $baselink . "&amp;filelist=1";
            $commlink = $baselink . "&amp;tocomm=1";
            $seederlink = $baselink . "&amp;toseeders=1";
            $leecherlink = $baselink . "&amp;todlers=1";
            $snatcherlink = $baselink . "&amp;tosnatchers=1";
        } else {
            $baselink .= $returnto;
            $filelistlink = $baselink . "&amp;filelist=1#filelist";
            $commlink = $baselink . "&amp;page=0#startcomments";
            $seederlink = $baselink . "&amp;dllist=1#seeders";
            $leecherlink = $baselink . "&amp;dllist=1#leechers";
            $snatcherlink = $baselink . "&amp;snatcher=1#snatcher";

        } 

        if ($torrent_info["leechers"])
            $ratio = $torrent_info["seeders"] / $torrent_info["leechers"];
        elseif ($torrent_info["seeders"])
            $ratio = 1;
        else
            $ratio = 0;

        $seedercolor = get_slr_color($ratio);

          $res = mysql_query("SELECT DISTINCT(user_id) as id, username, anon, class, peers.id as peerid FROM completed,users LEFT JOIN peers ON peers.userid=users.id AND peers.torrent=" . $torrent_info["id"] . " AND peers.seeder='yes' WHERE completed.user_id=users.id AND completed.torrent_id=" . $torrent_info["id"] . " ORDER BY complete_time DESC LIMIT 10");


        $last10users = "";
        while ($arr = mysql_fetch_assoc($res)) {
            if ($last10users) $last10users .= ", ";
            $arr["username"] = "<font class=\"" . get_class_color($arr["class"]) . "\">" . $arr["username"] . "</font>";
            if ($arr["peerid"] > 0) {
                $arr["username"] = "<b>" . $arr["username"] . "</b>";
            } 
            $last10users .= "<a href=\"userdetails.php?id=" . $arr["id"] . "\">" . $arr["username"] . "</a>";
        } 

        if ($last10users == "")
            $last10users = "Diesen Torrent hat noch niemand fertiggestellt.";
        else
            $last10users .= "<br/><br/>(Fettgedruckte User seeden noch)";

        if ($GLOBALS["DOWNLOAD_METHOD"] == DOWNLOAD_REWRITE)
            $download_url = "download/" . $torrent_info["id"] . "/" . rawurlencode($torrent_info["filename"]);
        else
            $download_url = "download.php?torrent=" . $torrent_info["id"];

        ?>
<tr>
  <td class="tableb" valign="top" style="color:#FFFFFF;width:1px;"><?php
        if (!isset($torrent_info["cat_pic"]))
            if ($torrent_info["cat_name"] != "")
                echo "<a href=\"browse.php?cat=" . $torrent_info["category"] . "\">" . $torrent_info["cat_name"] . "</a>";
            else
                echo "-";
            else
                echo "<a href=\"browse.php?cat=" . $torrent_info["category"] . "\"><img src=\"" . $GLOBALS["PIC_BASE_URL"] . $torrent_info["cat_pic"] . "\" alt=\"" . $torrent_info["cat_name"] . "\" title=\"" . $torrent_info["cat_name"] . "\" border=\"0\"></a>";

            ?><?
?>
<div align="center"></div>
<?php if (isset($torrent_info["uploaderclass"]) && $torrent_info["uploaderclass"] < UC_UPLOADER) {
                echo '<font color="darkorange">(*GU*)</font> ';
}
// Only for bt-technik.com by Force | START //
$completed = "";
if (get_user_class() >= UC_MODERATOR || (isset($CURUSER) && $CURUSER["id"] == $user["id"])) {
    if (!$_GET["allcompleted"])
        $limit_comp = " LIMIT 3";
    else
        $limit_comp = "";
    $res = mysql_query("SELECT completed.user_id,torrent_id as torrent,torrent_name,complete_time,free,torrents.seeders as seeders,torrents.leechers as leechers,torrents.id as torrent_origid,categories.name as catname,categories.image AS image,traffic.uploaded,traffic.downloaded,traffic.seedtime,traffic.uploadtime,traffic.downloadtime FROM completed LEFT JOIN traffic ON completed.torrent_id = traffic.torrentid AND completed.user_id = traffic.userid LEFT JOIN torrents ON completed.torrent_id = torrents.id LEFT JOIN categories ON completed.torrent_category = categories.id WHERE user_id=$id ORDER BY complete_time DESC$limit_comp");
    if (mysql_num_rows($res) > 0)
        $completed = makecomptable($res);
} 
// Only for bt-technik.com by Force | END // 
if ($torrent_info["vip"] == "yes") echo " <font style=\"color:red\">(VIP)</font>";         

if (isset($torrent_info["is_new"]) && $torrent_info["is_new"] == yes) {
                echo '<font color="red"> (NEU)</font> ';
            }  
     
if (isset($torrent_info["multi2"]) && $torrent_info["multi2"] == yes) {
                echo '<font color="red">Multi=<img src=pic/multi2.gif></font>';
            }         
if (isset($torrent_info["free"]) && $torrent_info["free"] == yes) {
                echo '<font color="red"> (Only)</font> ';
            } 
if (isset($torrent_info["webseed"]) && $torrent_info["webseed"] == yes) {
                echo '<font color="red"> (webseed)</font> ';
            }

if (isset($torrent_info["freeleech"]) && $torrent_info["freeleech"] == yes) {
                echo '<font color="red"> [Freeleech]</font> ';
            }
            if ($torrent_info["vdsl"] != 0) {
                echo '<font color="red"><img src="pic/vdsl.gif" border="0"></font><b>&nbsp;</b>';
            }

            if ($torrent_info["adsl"] != 0) {
                echo '<font color="red"><img src="pic/adsl.gif" border="0"></font><b>&nbsp;</b>';
            }

//Multiplikatoranzeige in browse.php
            if (isset($torrent_info["multi"]) && $torrent_info["multi"] > 0 && $torrent_info["multi"] < 4)
            {
            echo '<font color="red">** <img src=pic/multi2.gif>Multi</font>';
            }
            if (isset($torrent_info["multi"]) && $torrent_info["multi"] > 4 && $torrent_info["multi"] < 9)
            {
            echo '<font color="red">** <img src=pic/multi5.gif> Multi</font>';
            }
            if (isset($torrent_info["multi"]) && $torrent_info["multi"] > 9 && $torrent_info["multi"] < 11)
            {
            echo '<font color="red">** <img src=pic/multi10.gif>Multi</font>';
            }
            if (isset($torrent_info["multi"]) && $torrent_info["multi"] > 11)
            {
            echo '<font color="red"><img src=pic/disabledbig.png></font>';
            }
            //Eof Multiplikatoranzeige
?>
<div align="center"></div>
<?    
if (isset($torrent_info["nuked"]) && $torrent_info["nuked"] == yes) {
                echo '<font color="darkorange"> <img src=pic/nuke.gif></font> ';
            }                        
?>
<div align="center"></div>
 
<?             
            if ($torrent_info["nuked"] != 0) {
                echo '<font color="red">(Torrent hat Fehler)</font>';
}                      


?> 
<?

?></td>
  <td class="tablea" valign="top" align="left">
    <table cellpadding="2" cellspacing="2" border="0" style="width:100%">
      <colgroup>
        <col width="20%">
        <col width="20%">
        <col width="20%">
        <col width="20%">
        <col width="20%">
      </colgroup>
      <tr>
        <td colspan="4" nowrap>
          <?php if ($torrent_info["variant"] != "index") {

                ?>[ <a href="edit.php?id=<?=$torrent_info["id"] . $returnto?>">Bearbeiten</a> ]<?php } 

            ?>
          <?php if (isset($torrent_info["uploaderclass"]) && $torrent_info["uploaderclass"] < UC_UPLOADER) {
                echo '<font color="red">[GU]</font> ';
            } 

            ?>
          <a href="<?=$baselink?>"><b><?=$torrent_info["name"]?></b></a><?php if ($torrent_info["variant"] != "guestuploads" && $torrent_info["is_new"]) echo " <font style=\"color:red\">(NEU)</font>";
            if ($torrent_info["variant"] == "guestuploads" && $torrent_info["gu_agent"] > 0) echo " <font style=\"color:red\">(Bereits in Bearbeitung)</font>";
	     if ($torrent_info["vip"] == "yes") echo " <font style=\"color:red\"></font>";
            ?>


        </td>

<div align="center"></div>
<table cellpadding="2" cellspacing="2" border="0" style="width:100%">
<center><td><tr><div style="border:1px solid black;padding:0px;width:300px;height:15px;"><div style="border:none;width:<?=300 * $torrent_info["dist"] / 100?>px;height:15px;background-image:url(<?=$GLOBALS["PIC_BASE_URL"]?>ryg-verlauf.png);background-repeat:no-repeat;"></center></div></div></td></tr></center>
            <tr>
<td valign="top" align="left">
        <td style="font-size:90%">

<center><a href="<?=$baselink?>"<?=$torrent_info["id"] > 0 ? "onMouseOver=\"overlib('<img src=".$torrent_info["poster"].">');\" onMouseOut=\"nd();\"" : ""?>">POSTER</a>
<a href="<?=$baselink?>"<?=$torrent_info["numpics"] > 0 ? "onMouseOver=\"overlib('<img src=" . $DEFAULTBASEURL . "/" . $GLOBALS["BITBUCKET_DIR"] . "/f-".$torrent_info["id"]."-1.jpg>');\" onMouseOut=\"nd();\"" : ""?>">Bild</a>
<a href="javascript:expandCollaps('<?=$torrent_info["id"]?>');"><img id="plusminus<?=$torrent_info["id"]?>" src="<?=$GLOBALS["PIC_BASE_URL"] . $GLOBALS["ss_uri"]?>/beschreibung.gif" alt="Beschreibung" border="0"></a>
<a href="javascript:expandColla('<?=$torrent_info["id"]?>');"><img id="plusminus<?=$torrent_info["id"]?>" src="<?=$GLOBALS["PIC_BASE_URL"] . $GLOBALS["ss_uri"]?>/beschreibung.gif" alt="Info´s" border="0"></a>
<td valign="top" align="center">
        <td style="font-size:90%">
<center><b><font color=#00CD00>Dspeed </font></b><?=intval($torrent_info["dlspeed"])?><b><font color=#00CD00> KB/s</font></b>
<br>
<center><b><font color=#00CD00><b>UpSpeed </font></b><?=intval($torrent_info["ulspeed"])?><font color=#00CD00> KB/s</font>
<td valign="top" align="bottom">
        <td style="font-size:90%">
         <center><b><font color=#00CD00"<?=$seedercolor?>"><?=intval($torrent_info["seeders"])?></font></b> <a href="<?=$seederlink?>">Seeder</a></br>
<br>

          <center><b><font color=red"<?=linkcolor($torrent_info["seeders"])?>"><?=intval($torrent_info["leechers"])?></font></b> <a href="<?=$leecherlink?>">Leecher</a></td></br>
            </table>
<div id="poster<?=$torrent_info["id"]?>" style="display:none;">
     <?php
?>
      <table cellspacing="2" cellpadding="2" border="0" class="inposttable" style="width:50%;">
        <colgroup>
          <col width="20%">
          <col width="80%">
        </colgroup>
        <?php
            if ($torrent_info["variant"] == "mytorrents") {
                echo "<tr><td nowrap valign=\"top\"><b>Sichtbar:</b></td><td>", ($torrent_info["visible"] == "yes"?"Ja":"Nein, dieser Torrent ist inaktiv und als \"Tot\" markiert"), "</td></tr>";
            } 
            if ($torrent_info["has_wait"]) {
                echo "<tr><td nowrap valign=\"top\"><b>Wartezeit:</b></td><td><font color=\"",
                $torrent_info["wait_color"], "\">", $torrent_info["wait_left"],
                " Stunde(n)</font></td></tr>";
            } 
?>
        <tr><td nowrap="nowrap" valign="top"><b></b></td><td><?=$torrent_info["descr"] , 1?></a></td></tr>
 </table>
    </div>
<?
?>
    <div id="info<?=$torrent_info["id"]?>" style="display:none;">
      <?php
            ?>
      <table cellspacing="2" cellpadding="2" border="0" class="inposttable" style="width:50%;">
        <colgroup>
          <col width="20%">
          <col width="80%">
        </colgroup>
        <?php
            ?>
 <td nowrap><?=($torrent_info["variant"] == "mytorrents"?"Hochgeladen am:":"<font color=red>Dieses File wurde Von: </font> " . $torrent_info["uploaderlink"])?><font color=red>  Hochgeladen</font>
        </td>
      </tr>
       <tr><td nowrap="nowrap" valign="top"><b><font color=#00CD00>Letzte 10 Downloader: </font></b></td><td><?=$last10users?></td></tr>
        <tr><td nowrap="nowrap" valign="top"><b><font color=#00CD00>Letzte Aktivit&auml;t: </font></b></td><td><?=$torrent_info["last_action"]?></td></tr>
        <tr><td nowrap="nowrap" valign="top"><b><font color=#00CD00>Verbleibende Zeit: </font></b></td><td><?=$torrent_info["ttl"]?><center><b><font color=red> (falls inaktiv, sonst l&auml;nger)</font></b></td></tr>
      </table>
    </div>
  <td class="tableb" valign="top" align="center" style="width:22px;padding:4px;padding-top:10px;">
    <?php if ($torrent_info["variant"] == "guestuploads") {
                if ($torrent_info["gu_agent"] == 0)
                    echo "<img src=\"" . $GLOBALS["PIC_BASE_URL"] . "download.png\" width=\"22\" height=\"22\" alt=\"Nicht in Bearbeitung\" title=\"Nicht in Bearbeitung\">";
                else
                    echo "<img src=\"" . $GLOBALS["PIC_BASE_URL"] . "taken.png\" width=\"22\" height=\"22\" alt=\"Bereits in Bearbeitung\" title=\"Bereits in Bearbeitung\">";
            } else {
                if($torrent_info["vip"] == "no"){                

if ($torrent_info["activated"] == "yes") {
                    if (!isset($torrent_info["wait_left"]) || $torrent_info["wait_left"] == 0) {

                        ?>
    <a href="<?=$download_url?>"><img src="<?=$GLOBALS["PIC_BASE_URL"]?>download.png" width="22" height="22" alt="Torrent 

herunterladen" title="Torrent herunterladen" border="0"></a>
    <?php } else {

                        ?>
    <img src="<?=$GLOBALS["PIC_BASE_URL"]?>download.png" width="22" height="22" alt="Wartezeit nicht abgelaufen" title="Wartezeit 

nicht abgelaufen" border="0"
    <?php }

 

                } else {

                    ?>
    <img src="<?=$GLOBALS["PIC_BASE_URL"]?>download.png" width="22" height="22" alt="Torrent nicht freigeschaltet" title="Torrent 

nicht freigeschaltet" border="0"
    <?php } 
            
}
else if (get_user_class () >= UC_VIP)
{
?>
    <a href="<?=$download_url?>"><img src="<?=$GLOBALS["PIC_BASE_URL"]?>download.png" width="22" height="22" alt="Torrent 

herunterladen" title="Torrent herunterladen" border="0"></a>
    <?php 
}
else
{
                        ?>
    <img src="<?=$GLOBALS["PIC_BASE_URL"]?>download.png" width="22" height="22" alt="Dies ist ein VIP Torrent" title="Dies ist ein VIP Torrent" border="0"
    <?php }


}
            ?>
  </td>
</tr>
<?php
        } 

        function torrenttable($res, $variant = "index", $addparam = "")
        {
            global $CURUSER; 
            // Sortierkriterien entfernen
            $addparam_nosort = preg_replace(array("/orderby=(.*?)&amp;/i", "/sort=(.*?)&amp;/i"), array("", ""), $addparam); 
            // Hat dieser Benutzer Wartezeit?
            $has_wait = get_wait_time($CURUSER["id"], 0, true);

            ?>

<script type="text/javascript">

function expandCollapse(torrentId)
{
    var plusMinusImg = document.getElementById("plusminus"+torrentId);
    var detailRow = document.getElementById("details"+torrentId);

    if (plusMinusImg.src.indexOf("<?=$GLOBALS["PIC_BASE_URL"] . $GLOBALS["ss_uri"]?>/plus.gif") >= 0) {
        plusMinusImg.src = "<?=$GLOBALS["PIC_BASE_URL"] . $GLOBALS["ss_uri"]?>/minus.gif";
        detailRow.style.display = "block";
    } else {
        plusMinusImg.src = "<?=$GLOBALS["PIC_BASE_URL"] . $GLOBALS["ss_uri"]?>/plus.gif";
        detailRow.style.display = "none";
    }
}

</script>

<script type="text/javascript">

function expandColla(torrentid)
{
    var plusMinusImg = document.getElementById("plusminus"+torrentid);
    var detailRow = document.getElementById("info"+torrentid);

    if (plusMinusImg.src.indexOf("<?=$GLOBALS["PIC_BASE_URL"] . $GLOBALS["ss_uri"]?>/beschreibung.gif") >= 0) {
        plusMinusImg.src = "<?=$GLOBALS["PIC_BASE_URL"] . $GLOBALS["ss_uri"]?>/minus.gif";
        detailRow.style.display = "block";
    } else {
        plusMinusImg.src = "<?=$GLOBALS["PIC_BASE_URL"] . $GLOBALS["ss_uri"]?>/beschreibung.gif";
        detailRow.style.display = "none";
    }
}

</script>
<table cellspacing="0" cellpadding="0" border="0" style="width:100%"><tr>
        <td align="left"><img src="<?=$GLOBALS["PIC_BASE_URL"] . $GLOBALS["ss_uri"]?>/obenlinks.gif" alt="" title="" /></td>
<td style="width:100%" class="obenmitte"></td>
        <td align="right"><img src="<?=$GLOBALS["PIC_BASE_URL"] . $GLOBALS["ss_uri"]?>/obenrechts.gif" alt="" title="" /></td>
</tr></table>


<?php

            if ($CURUSER["oldtorrentlist"] == "yes") {

                ?>
<table border="0" cellspacing="1" cellpadding="4" class="tableinborder" style="width:100%">
<tr>
  <td class="tablecat" align="center">Typ</td>
  <td class="tablecat" align="left">Name</td>
  <?php if ($variant == "mytorrents") {

                    ?>
  <td class="tablecat" align="center">Bearbeiten</td>
  <td class="tablecat" align="center">Sichtbar</td>  
  <?php } elseif ($variant == "guestuploads") {

                    ?>
  <td class="tablecat" align="center">In&nbsp;Bearbeitung</td>
  <?php } elseif ($has_wait) {

                    ?>
  <td class="tablecat" align="center">Wartez.</td>  
  <?php } 

                ?>
  <td class="tablecat" align="right">Dateien</td>
  <td class="tablecat" align="right">Komm.</td>
  <td class="tablecat" align="center">Hinzugef.</td>
  <td class="tablecat" align="center">TTL</td>
  <td class="tablecat" align="center">Gr&ouml;&szlig;e</td>
  <td class="tablecat" align="center">Verteilung</td>
  <td class="tablecat" align="center">Fertig</td>
  <td class="tablecat" align="right">Seeder</td>
  <td class="tablecat" align="right">Leecher</td>
  <td class="tablecat" align="left">&Oslash;&nbsp;Geschw.</td>
  <?php if ($variant == "index") {

                    ?>
  <td class="tablecat" align="center">Uploader</td>          
  <?php } 

                ?>
</tr>               
            <?php
            } else {

                ?>
<table border="0" cellspacing="1" cellpadding="0" class="tableinborder" style="width:100%">
  <colgroup>
    <col width="32">
    <col width="100%">
    <col width="22">
  </colgroup>
            <?php
            } while ($row = mysql_fetch_assoc($res)) {
                $id = $row["id"];

                $torrent_info = array();
$torrent_info["nuked"] = $row["nuked"];
                $torrent_info["id"] = $row["id"];
                $torrent_info["vip"] = $row["vip"];
                $torrent_info["name"] = htmlspecialchars($row["name"]);
                $torrent_info["activated"] = (isset($row["activated"])?$row["activated"]:"yes");
                $torrent_info["gu_agent"] = (isset($row["gu_agent"])?$row["gu_agent"]:0);
                $torrent_info["filename"] = $row["filename"];
$torrent_info["multi"] = $row["multi"];

                $torrent_info["numpics"] = $row["numpics"];
                $torrent_info["poster"] = $row["poster"];
                $torrent_info["free"] = $row["free"];
$torrent_info["freeleech"] = $row["freeleech"];
                $torrent_info["nuked"] = $row["nuked"];
                $torrent_info["variant"] = $variant;
                $torrent_info["category"] = $row["category"];
                $torrent_info["cat_name"] = $row["cat_name"];
                $torrent_info["type"] = $row["type"];
                $torrent_info["numfiles"] = ($row["type"] == "single"?1:$row["numfiles"]);
                $torrent_info["size"] = $row["size"];
                $torrent_info["times_completed"] = intval($row["times_completed"]);
                $torrent_info["seeders"] = $row["seeders"];
                $torrent_info["leechers"] = $row["leechers"];
                $torrent_info["descr"] = $row["descr"];
                // BEGIN: Anonymous Torrent Liste by truenoir
        $torrent_info["uploaderlink"] = (isset($row["username"]) ? ($row["anon"]=="yes"&&get_user_class()<UC_MODERATOR?"<b>Anonym*</b>":("<a href=\"userdetails.php?id=" . $row["owner"] . "\"><b>" . htmlspecialchars($row["username"]) . "</b></a>")) : "<i>(Gelöscht)</i>");
// ENDE: Anonymous Torrent Liste by truenoir
                $torrent_info["added"] = str_replace(" ", "&nbsp;", date("d.m.Y H:i:s", sql_timestamp_to_unix_timestamp($row["added"])));
                $torrent_info["comments"] = $row["comments"];
                $torrent_info["visible"] = $row["visible"];
$torrent_info["highlight"] = $row["highlight"];
                $torrent_info["webseed"] = $seeds1;
                $torrent_info["last_action"] = str_replace(" ", "&nbsp;", date("d.m.Y H:i:s", sql_timestamp_to_unix_timestamp($row["last_action"])));

                if (isset($row["cat_pic"]) && $row["cat_pic"] != "")
                    $torrent_info["cat_pic"] = $row["cat_pic"];

                if (isset($row["uploaderclass"]))
                    $torrent_info["uploaderclass"] = $row["uploaderclass"];

                $torrent_info["has_wait"] = $has_wait;
                if ($has_wait) {
                    $torrent_info["wait_left"] = get_wait_time($CURUSER["id"], $id);
                    $torrent_info["wait_color"] = dechex(floor(127 * ($wait_left) / 48 + 128) * 65536);
                } 

                $speedres = mysql_query("SELECT ROUND(AVG((downloaded - downloadoffset) / (UNIX_TIMESTAMP() - UNIX_TIMESTAMP(`started`)))/1024, 2) AS dlspeed, ROUND(AVG((uploaded - uploadoffset) / (UNIX_TIMESTAMP() - UNIX_TIMESTAMP(`started`)))/1024, 2) AS ulspeed FROM peers WHERE torrent=$id");
                $speed = mysql_fetch_assoc($speedres);
                if ($speed["dlspeed"] == 0) $speed["dlspeed"] = "0";
                if ($speed["ulspeed"] == 0) $speed["ulspeed"] = "0";
                $torrent_info["dlspeed"] = $speed["dlspeed"];
                $torrent_info["ulspeed"] = $speed["ulspeed"];

                $distres = mysql_query("SELECT ROUND(AVG((" . $row["size"] . " - `to_go`) / " . $row["size"] . " * 100),2) AS `dist` FROM `peers` WHERE torrent=$id");
                $dist = mysql_fetch_assoc($distres);
                $torrent_info["dist"] = $dist["dist"];

                $ttl = (28 * 24) - floor((time() - sql_timestamp_to_unix_timestamp($row["added"])) / 3600);
                if ($ttl == 1) $ttl .= " Stunde";
                else $ttl .= " Stunden";
                $torrent_info["ttl"] = $ttl;

                $newadd = "";

                $torrentunix = sql_timestamp_to_unix_timestamp($row["added"]);
                $accessunix = sql_timestamp_to_unix_timestamp($CURUSER["last_access"]);

                if ($torrentunix >= $accessunix)
                    $torrent_info["is_new"] = true;

                if ($CURUSER["oldtorrentlist"] == "yes") {
                    torrenttable_row_oldschool($torrent_info);
                } else {
                    torrenttable_row($torrent_info);
                } 
            } 

            ?>
</table>
<table cellspacing="0" cellpadding="0" border="0" style="width:100%"><tr>
        <td align="left"><img src="<?=$GLOBALS["PIC_BASE_URL"] . $GLOBALS["ss_uri"]?>/untenlinks.gif" alt="" title="" /></td>
<td style="width:100%" class="untenmitte" align="center"></td>
        <td align="right"><img src="<?=$GLOBALS["PIC_BASE_URL"] . $GLOBALS["ss_uri"]?>/untenrechts.gif" alt="" title="" /></td>
</tr></table>
<?php
            return $rows;
        } 

        function hit_start()
        {
            global $RUNTIME_START, $RUNTIME_TIMES; 
            // $RUNTIME_TIMES = posix_times();
            $RUNTIME_START = gettimeofday();
        } 

        function hit_count()
        {
            return;
            global $RUNTIME_CLAUSE;
            if (preg_match(',([^/]+)$,', $_SERVER["SCRIPT_NAME"], $matches))
                $path = $matches[1];
            else
                $path = "(unknown)";
            $period = date("Y-m-d H") . ":00:00";
            $RUNTIME_CLAUSE = "page = " . sqlesc($path) . " AND period = '$period'";
            $update = "UPDATE hits SET count = count + 1 WHERE $RUNTIME_CLAUSE";
            mysql_query($update);
            if (mysql_affected_rows())
                return;
            $ret = mysql_query("INSERT INTO hits (page, period, count) VALUES (" . sqlesc($path) . ", '$period', 1)");
            if (!$ret)
                mysql_query($update);
        } 

        function hit_end()
        {
            return;
            global $RUNTIME_START, $RUNTIME_CLAUSE, $RUNTIME_TIMES;
            if (empty($RUNTIME_CLAUSE))
                return;
            $now = gettimeofday();
            $runtime = ($now["sec"] - $RUNTIME_START["sec"]) + ($now["usec"] - $RUNTIME_START["usec"]) / 1000000;
            $ts = posix_times();
            $sys = ($ts["stime"] - $RUNTIME_TIMES["stime"]) / 100;
            $user = ($ts["utime"] - $RUNTIME_TIMES["utime"]) / 100;
            mysql_query("UPDATE hits SET runs = runs + 1, runtime = runtime + $runtime, user_cpu = user_cpu + $user, sys_cpu = sys_cpu + $sys WHERE $RUNTIME_CLAUSE");
        } 

        function hash_pad($hash)
        {
            return str_pad($hash, 20);
        } 

        function hash_where($name, $hash)
        {
            $shhash = preg_replace('/ *$/s', "", $hash);
            return "($name = " . sqlesc($hash) . " OR $name = " . sqlesc($shhash) . ")";
        } 

        function get_user_icons($arr, $big = false)
        {
            if ($big) {
                         $donorpic = "starbig.png";
                $warnedpic = "warnedbig.gif";
$wechpic = "wech.png";
				$wspic = "wsbig.gif";
$vdslpic = "vdslbig.gif";
				$adslpic = "adslbig.gif";
                $disabledpic = "disabledbig.png";
                $newbiepic = "pacifierbig.png";
$djpic = "dj.png";
$lovepic = "heart.png";
                $style = "style=\"margin-left:4pt;vertical-align:middle;\"";
            } else {
                $donorpic = "star.png";
                $warnedpic = "warned.gif";
$wechpic = "wech.png";
				$wspic = "ws.gif";
$vdslpic = "vdsl.gif";
				$adslpic = "adsl.gif";
                $disabledpic = "disabled.png";
                $newbiepic = "pacifier.png";
$djpic = "dj.png"; 
$lovepic = "heart.png";
                $style = "style=\"margin-left:2pt;vertical-align:middle;\"";
  } 

                  $pics = $arr["donor"] == "yes" ? "<img src=\"" . $GLOBALS["PIC_BASE_URL"] . $donorpic . "\" alt=\"Spender\" title=\"Dieser Benutzer hat mit einer Spende zum Erhalt des Trackers beigetragen\" border=0 $style>" : "";
            if (isset($arr["wech"]) && $arr["wech"] == "yes")
                $pics .= "<img src=\"" . $GLOBALS["PIC_BASE_URL"] . $wechpic . "\" alt=\"Abwesend\" title=\"Dieses Teammitglied ist abwesend\" border=0 $style>";
if (isset($arr["love"]) && $arr["love"] == "yes")
                $pics .= "<img src=\"" . $GLOBALS["PIC_BASE_URL"] . $lovepic . "\" alt=\"Liebling\" title=\"Dieser Benutzer hat die Regel Verstossen!\" border=0 $style>";
            if (isset($arr["warned"]) && $arr["warned"] == "yes")
                $pics .= "<img src=\"" . $GLOBALS["PIC_BASE_URL"] . $warnedpic . "\" alt=\"Verwarnt\" title=\"Dieser Benutzer wurde verwarnt\" border=0 $style>";
if (isset($arr["dj"]) && $arr["dj"] == "yes")
                $pics .= "<img src=\"" . $GLOBALS["PIC_BASE_URL"] . $djpic . "\" alt=\"Dj\" title=\"Dieser Benutzer ist Tracker Dj\" border=0 $style>"; 				
			if (isset($arr["webseed"]) && $arr["webseed"] == "yes")
                $pics .= "<img src=\"" . $GLOBALS["PIC_BASE_URL"] . $wspic . "\" alt=\"Webseeder\" title=\"Dieser Benutzer ist ein Webseeder\" border=0 $style>";
if (isset($arr["vdsl"]) && $arr["vdsl"] == "yes")
                $pics .= "<img src=\"" . $GLOBALS["PIC_BASE_URL"] . $vdslpic . "\" alt=\"VDSL\" title=\"Dies ist ein VDSL User\" border=0 $style>";
            if (isset($arr["adsl"]) && $arr["adsl"] == "yes")
                $pics .= "<img src=\"" . $GLOBALS["PIC_BASE_URL"] . $adslpic . "\" alt=\"ADSL2\" title=\"Dies ist ein ADSL2 User\" border=0 $style>";    
                
            if (isset($arr["enabled"]) && $arr["enabled"] == "no")
                $pics .= "<img src=\"" . $GLOBALS["PIC_BASE_URL"] . $disabledpic . "\" alt=\"Deaktiviert\" title=\"Dieser Benutzer ist deaktiviert\" border=0 $style>";

            $timeadded = intval(sql_timestamp_to_unix_timestamp($arr["added"]));
            if ($timeadded > 0 && time() - $timeadded < 604800)
                $pics .= "<img src=\"" . $GLOBALS["PIC_BASE_URL"] . $newbiepic . "\" alt=\"Newbie\" title=\"Ist noch neu hier\" border=0 $style>";
            return $pics;
}
       
        function failedloginscheck ($type = 'login') {
    global $maxloginattempts, $ip;    
    $total = 0;
    if (!$ip)
        $ip = sqlesc(getip());
    $Query = mysql_query("SELECT SUM(attempts) FROM loginattempts WHERE ip=$ip") or sqlerr(__FILE__, __LINE__);
    list($total) = mysql_fetch_array($Query);
    if ($total >= $maxloginattempts) {
            mysql_query("UPDATE loginattempts SET banned = 'yes' WHERE ip=$ip") or sqlerr(__FILE__, __LINE__);            
            stderr("Anmeldung Geschlossen!", "Du hast <b>maximale Anmeldungsversuche überschriten</b>, deshalb ist deine IP-Adresse <b>(".htmlspecialchars($ip).")</b> nun gebannt.",false);              
        }
}

function failedlogins ($type = 'login', $recover = false, $head = true, $msg=false, $uid = 0) {    
    global $ip, $username, $password, $md5pw, $iphost, $ipaddress;
    if (!$ip)
        $ip = sqlesc(getip());
    $added = sqlesc(get_date_time());
    $a = (@mysql_fetch_row(@mysql_query("select count(*) from loginattempts where ip=$ip"))) or sqlerr(__FILE__, __LINE__);
    if ($a[0] == 0)
        mysql_query("INSERT INTO loginattempts (ip, added, attempts) VALUES ($ip, $added, 1)") or sqlerr(__FILE__, __LINE__);
    else
        mysql_query("UPDATE loginattempts SET attempts = attempts + 1 where ip=$ip") or sqlerr(__FILE__, __LINE__);        
    if ($recover)
        mysql_query("UPDATE loginattempts SET type = 'recover' WHERE ip = $ip") or sqlerr(__FILE__, __LINE__);
    if ($msg && $uid) {
        $message = sqlesc("Login failed!", $username, $password, $md5pw, $ipaddress, $iphost);
        mysql_query("INSERT INTO messages (sender, receiver, added, msg, poster) VALUES(0, $uid, $added, $message, 0)");
    }
    if ($type == 'silent')
        return;                
    elseif ($type == 'login')    
        
        stderr("Anmeldung Gescheitert!", "<b>Fehler</b>: Username oder Passwort falsch<br>Hast Du dein Passwort vergessen? <b><a href=recover.php>Recover</a></b> dein Passwort!", false);    
    else
        stderr("Anmeldung Gescheitert!", $type, false, $head);
    
} 
        
        function remaining ($type = 'login') {
        global $maxloginattempts, $ip;    
        $total = 0;
        if (!$ip)
           $ip = sqlesc(getip());
        $Query = mysql_query("SELECT SUM(attempts) FROM loginattempts WHERE ip=$ip") or sqlerr(__FILE__, __LINE__);
        list($total) = mysql_fetch_array($Query);
        $remaining = $maxloginattempts - $total;
        if ($remaining <= 2 )
            $remaining = "<font color=red>[".$remaining."]</font>";
        else
            $remaining = "<font color=green>[".$remaining."]</font>";
        
        return $remaining;
        }

        require_once("include/global.php");
        require_once("include/pmfunctions.php");

        ?>
