<?php

/*
// +--------------------------------------------------------------------------+
// | Project:    NVTracker - NetVision BitTorrent Tracker                     |
// +--------------------------------------------------------------------------+
// | 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! |
// +--------------------------------------------------------------------------+
//
// erstellt von BiGPoWeR - für RooT-Torrents -- 08.03.2008
*/

require_once("include/bittorrent.php");

dbconn();
loggedinorreturn();

$rescount = mysql_query("SELECT COUNT(*) FROM torrents WHERE owner = ". $CURUSER['id'] ." $limit") or sqlerr(__FILE__,__LINE__);
$rowcount = mysql_fetch_array($rescount);
$count = $rowcount[0];

$torrentsperpage = $CURUSER["torrentsperpage"];
if (!$torrentsperpage)
    $torrentsperpage = 20;

list($pagertop, $pagerbottom, $limit) = pager($torrentsperpage, $count, "mytorrents.php?");
$res = mysql_query("SELECT * FROM torrents WHERE owner = ". $CURUSER['id'] ." order by added desc $limit");

if (mysql_num_rows($res)) {

    stdhead("Torrents");

        begin_frame(" Uploaded Torrents by " . $CURUSER['username'] . " ");

    print("<table width=100% border=0 cellspacing=0 cellpadding=3 align=center>");
    print("<tr>");
    print("<td class=colhead align=center>Type</td>");
    print("<td class=colhead align=center>Name</td>");
    print("<td class=colhead align=center>Visible</td>");
    print("<td class=colhead align=center>OU</td>");
    print("<td class=colhead align=center>REQ</td>");
    print("<td class=colhead align=center>Edit</td>");
    print("<td class=colhead align=center><img src=pic/files.gif border=0 alt=files></td>");
    print("<td class=colhead align=center><img src=pic/comments.gif border=0 alt=comments></td>");
    print("<td class=colhead align=center><img src=pic/seeders.gif border=0 alt=seeders></td>");
    print("<td class=colhead align=center><img src=pic/leechers.gif border=0 alt=leechers></td>");
    print("<td class=colhead align=center>Views</td>");
    print("<td class=colhead align=center>Hits</td>");
    print("<td class=colhead align=center>Added</td>");
    print("<td class=colhead align=center>Last Action</td>");
    print("<td class=colhead align=center>Size</td>");
    print("<td class=colhead align=center>Snatched</td>");
    print("</tr>");

    While ($row = mysql_fetch_array($res)) {
        print("<tr>");
        $cat = mysql_query("SELECT image FROM categories WHERE id = ". $row["category"] ."");
        while ($catrow = mysql_fetch_array($cat)) {
            print("<td width=5%><img src=pic/" . $catrow["image"] . "></td>");
        }

        //// smallname mytorrents
        $smallname = substr(htmlspecialchars($row["name"]) , 0, 40);
        if ($smallname != htmlspecialchars($row["name"])) {
            $smallname .= '...';
        }
        #$smallname = htmlspecialchars($row["name"]);
        //// smallname mytorrents end

        print("<td><a href=details.php?id=". $row[id] ."><b>". $smallname ."</b></a></td>");



        //// colored yes/no for visible
        if ($row["visible"] == 'yes') {
            $visible = "<font color=green>Yes</font>";
        }
        else {
            $visible = "<font color=red>No</font>";
        }
        //// colored yes/no for visible end

        print("<td align=center>". $visible ."</td>");



        //// colored yes/no for golden torrents
        if ($row["free"] == 'yes')
            $free = "<font color=green>Yes</font>";
        else
            $free = "<font color=red>No</font>";
        //// colored yes/no for golden torrents end

        print("<td align=center>". $free ."</td>");



        //// colored yes/no for request torrents
        if ($row["req"] == 'yes')
            $req = "<font color=green>Yes</font>";
        else
            $req = "<font color=red>No</font>";
        //// colored yes/no for request torrents end

        print("<td align=center>". $req ."</td>");



        //// red color by 0 seeders end
        if ($row["seeders"] == '0')
            $seeders = "<font color=#ff0000>". $row["seeders"] ."</font>";
        elseif($row["seeders"] < '2')
            $seeders = "<font color=#ff4500>". $row["seeders"] ."</font>";
        elseif($row["seeders"] < '5')
            $seeders = "<font color=#a0ce00>". $row["seeders"] ."</font>";
        else
            $seeders = "<font color=#7fff00>". $row["seeders"] ."</font>";
        //// red color by 0 seeders end

        //// red color by 0 leechers end
        if ($row["leechers"] == '0')
            $leechers = "<font color=#ff0000>". $row["leechers"] ."</font>";
        elseif($row["leechers"] < '2')
            $leechers = "<font color=#ff4500>". $row["leechers"] ."</font>";
        elseif($row["leechers"] < '5')
            $leechers = "<font color=#a0ce00>". $row["leechers"] ."</font>";
        else
            $leechers = "<font color=#7fff00>". $row["leechers"] ."</font>";
        //// red color by 0 leechers end


        print("<td align=center><a href=edit.php?id=". $row[id] .">Edit</a></td>");
        print("<td align=center><a href=details.php?id=". $row[id] ."&amp;filelist=1#filelist>". $row["numfiles"] ."</a></td>");
        print("<td align=center><a href=details.php?id=".$row[id] ."&amp;page=0#startcomments>". $row["comments"] ."</a></td>");
        print("<td align=center><a href=details.php?id=". $row[id] ."&amp;dllist=1#seeders>". $seeders ."</a></td>");
        print("<td align=center><a href=details.php?id=". $row[id] ."&amp;dllist=1#leechers>". $leechers ."</a></td>");
        print("<td align=center>". $row["views"] ."</td>");
        print("<td align=center>". $row["hits"] ."</td>");
        print("<td align=center>". $row["added"] ."</td>");
        print("<td align=center>". $row["last_action"] ."</td>");
        print("<td align=center>". mksize($row["size"]) ."</td>");



        //// red color by 0 times complete
        if ($row["times_completed"] == '0')
            $times_completed = "<font color=#ff0000>". $row["times_completed"] ." x</font>";
        elseif($row["times_completed"] < '2')
            $times_completed = "<font color=#ff4500>". $row["times_completed"] ." x</font>";
        elseif($row["times_completed"] < '5')
            $times_completed = "<font color=#a0ce00>". $row["times_completed"] ." x</font>";
        else
            $times_completed = "<font color=#7fff00>". $row["times_completed"] ." x</font>";
        //// red color by 0 times complete

        print("<td align=center><a href=details.php?id=". $row[id] ."&amp;snatcher=1#snatcher>". $times_completed ."</a></td>");


        print("</tr>");
    }
    print("</table>");
    print("$pagertop");
        
        end_frame();

    stdfoot();

}else

    stderr("Du hast noch nichts Hochgeladen also kannst du hier auch noch nichts sehen.");
?> 