<?php
	include_once('ressources/class.templates.inc');
	include_once('ressources/class.ldap.inc');
	include_once('ressources/class.users.menus.inc');
	include_once("ressources/class.os.system.inc");
	include_once("ressources/class.lvm.org.inc");
	
	$user=new usersMenus();
	if(!$user->AsSystemAdministrator){echo "alert('no privileges');";die();}
	
	if(isset($_GET["status"])){status();exit;}
	if(isset($_GET["tabs"])){tabs();exit;}
	if(isset($_GET["health"])){health();exit;}
	if(isset($_GET["health-table"])){health_table();exit;}
	popup();
	
	
function popup(){
	$page=CurrentPageName();
	$time=time();
	
	$html="<div id='$time'></div>
	<script>
		LoadAjax('$time','$page?tabs=yes&dev={$_GET["dev"]}');
	</script>	
	";
	
	echo $html;
	
	
}
include_once "ressources/class.lvm.org.inc";
$user = new usersMenus();
if (!$user->AsSystemAdministrator) {
    echo "alert('no privileges');";
    die;
}
if (isset($_GET["status"])) {
    status();
    exit;
}
if (isset($_GET["tabs"])) {
    tabs();
    exit;
}
if (isset($_GET["health"])) {
    health();
    exit;
}
if (isset($_GET["health-table"])) {
    health_table();
    exit;
}
popup();
function popup()
{
    $page = CurrentPageName();
    $time = time();
    $html = "<div id='{$time}'></div>\n\t<script>\n\t\tLoadAjax('{$time}','{$page}?tabs=yes&dev={$_GET["dev"]}');\n\t</script>\t\n\t";
    echo $html;
}
function tabs()
예제 #3
0
    while ($top5torrent = mysqli_fetch_assoc($res)) {
        $top5torrents[] = $top5torrent;
    }
    $mc1->cache_value('top5_tor_', $top5torrents, $INSTALLER09['expires']['top5_torrents']);
}
if (count($top5torrents) > 0) {
    $HTMLOUT .= "<div class='module'><div class='tbadge tbadge-top'></div>\n     \t    <table class='table table-bordered'>\n            <thead><tr>\n            <th class=' col-md-1 text-left'><b>{$lang['top5torrents_type']}</b></th>\n            <th class=' col-md-5 text-left'><b>{$lang['top5torrents_name']}</b></th>\n            <th class=' col-md-2 text-center'>{$lang['top5torrents_seeders']}</th>\n            <th class=' col-md-2 text-center'>{$lang['top5torrents_leechers']}</th>\n\t    <th class=' col-md-3 text-center'>{$lang['top5torrents_health']}</th></tr></thead>";
    if ($top5torrents) {
        foreach ($top5torrents as $top5torrentarr) {
            $top5torrentarr['cat_name'] = htmlsafechars($change[$top5torrentarr['category']]['name']);
            $top5torrentarr['cat_pic'] = htmlsafechars($change[$top5torrentarr['category']]['image']);
            $torrname = htmlsafechars($top5torrentarr['name']);
            if (strlen($torrname) > 50) {
                $torrname = substr($torrname, 0, 50) . "...";
            }
            $thealth = health($top5torrentarr['leechers'], $top5torrentarr['seeders']);
            $poster = empty($top5torrentarr["poster"]) ? "<img src=\\'{$INSTALLER09['pic_base_url']}noposter.jpg\\' width=\\'150\\' height=\\'220\\' />" : "<img src=\\'" . htmlsafechars($top5torrentarr['poster']) . "\\' width=\\'150\\' height=\\'220\\' />";
            $HTMLOUT .= "\n            <tbody><tr>\n            <td class='text-center'><img src='pic/caticons/{$CURUSER['categorie_icon']}/" . htmlsafechars($top5torrentarr["cat_pic"]) . "' alt='" . htmlsafechars($top5torrentarr["cat_name"]) . "' title='" . htmlsafechars($top5torrentarr["cat_name"]) . "' /></td>\n            <td><a href=\"{$INSTALLER09['baseurl']}/details.php?id=" . (int) $top5torrentarr['id'] . "&amp;hit=1\" onmouseover=\"Tip('<b>{$lang['index_ltst_name']}" . htmlsafechars($top5torrentarr['name']) . "</b><br /><b>{$lang['index_ltst_seeder']}" . (int) $top5torrentarr['seeders'] . "</b><br /><b>{$lang['index_ltst_leecher']}" . (int) $top5torrentarr['leechers'] . "</b><br />{$poster}');\" onmouseout=\"UnTip();\">{$torrname}</a></td>\n          <td class='text-center'><span class='badge'>" . (int) $top5torrentarr['seeders'] . "</span></td>\n          <td class='text-center'><span class='badge'>" . (int) $top5torrentarr['leechers'] . "</span></td>\n          <td class='text-center'><span class='badge'>{$thealth}</span></td>       \n\t </tr></tbody>";
        }
        $HTMLOUT .= "</table>";
    } else {
        //== If there are no torrents
        if (empty($top5torrents)) {
            $HTMLOUT .= "<tbody><tr><td class='text-left' colspan='3'>{$lang['top5torrents_no_torrents']}</td></tr></tbody></table>";
        }
    }
}
//==Last 5 begin
//$mc1->delete_value('last5_tor_');
if (($last5torrents = $mc1->get_value('last5_tor_')) === false) {
    $sql = "SELECT id, seeders, poster, leechers, name, category FROM torrents WHERE visible='yes' ORDER BY added DESC LIMIT {$INSTALLER09['latest_torrents_limit']}";
예제 #4
0
function torrenttable($res)
{
    global $site_config, $CURUSER, $THEME, $LANGUAGE;
    //Define globals
    if ($site_config["MEMBERSONLY_WAIT"] && $site_config["MEMBERSONLY"] && in_array($CURUSER["class"], explode(",", $site_config["WAIT_CLASS"]))) {
        $gigs = $CURUSER["uploaded"] / (1024 * 1024 * 1024);
        $ratio = $CURUSER["downloaded"] > 0 ? $CURUSER["uploaded"] / $CURUSER["downloaded"] : 0;
        if ($ratio < 0 || $gigs < 0) {
            $wait = $site_config["WAITA"];
        } elseif ($ratio < $site_config["RATIOA"] || $gigs < $site_config["GIGSA"]) {
            $wait = $site_config["WAITA"];
        } elseif ($ratio < $site_config["RATIOB"] || $gigs < $site_config["GIGSB"]) {
            $wait = $site_config["WAITB"];
        } elseif ($ratio < $site_config["RATIOC"] || $gigs < $site_config["GIGSC"]) {
            $wait = $site_config["WAITC"];
        } elseif ($ratio < $site_config["RATIOD"] || $gigs < $site_config["GIGSD"]) {
            $wait = $site_config["WAITD"];
        } else {
            $wait = 0;
        }
    }
    // Columns
    $cols = explode(",", $site_config["torrenttable_columns"]);
    $cols = array_map("strtolower", $cols);
    $cols = array_map("trim", $cols);
    $colspan = count($cols);
    // End
    // Expanding Area
    $expandrows = array();
    if (!empty($site_config["torrenttable_expand"])) {
        $expandrows = explode(",", $site_config["torrenttable_expand"]);
        $expandrows = array_map("strtolower", $expandrows);
        $expandrows = array_map("trim", $expandrows);
    }
    // End
    echo '<table align="center" class="ttable_headinner" width="100%"><thead><tr class="ttable_head">';
    foreach ($cols as $col) {
        switch ($col) {
            case 'category':
                echo "<th>" . T_("TYPE") . "</th>";
                break;
            case 'name':
                echo "<th>" . T_("NAME") . "</th>";
                break;
            case 'dl':
                echo "<th>" . T_("DL") . "</th>";
                break;
            case 'uploader':
                echo "<th>" . T_("UPLOADER") . "</th>";
                break;
            case 'comments':
                echo "<th>" . T_("COMM") . "</th>";
                break;
            case 'nfo':
                echo "<th>" . T_("NFO") . "</th>";
                break;
            case 'size':
                echo "<th>" . T_("SIZE") . "</th>";
                break;
            case 'completed':
                echo "<th>" . T_("C") . "</th>";
                break;
            case 'seeders':
                echo "<th>" . T_("S") . "</th>";
                break;
            case 'leechers':
                echo "<th>" . T_("L") . "</th>";
                break;
            case 'health':
                echo "<th>" . T_("HEALTH") . "</th>";
                break;
            case 'external':
                if ($site_config["ALLOWEXTERNAL"]) {
                    echo "<th>" . T_("L/E") . "</th>";
                }
                break;
            case 'added':
                echo "<th>" . T_("ADDED") . "</th>";
                break;
            case 'speed':
                echo "<th>" . T_("SPEED") . "</th>";
                break;
            case 'wait':
                if ($wait) {
                    echo "<th>" . T_("WAIT") . "</th>";
                }
                break;
            case 'rating':
                echo "<th>" . T_("RATINGS") . "</th>";
                break;
        }
    }
    if ($wait && !in_array("wait", $cols)) {
        echo "<th>" . T_("WAIT") . "</th>";
    }
    echo "</tr></thead>";
    while ($row = mysql_fetch_assoc($res)) {
        $id = $row["id"];
        print "<tr class='t-row'>\n";
        $x = 1;
        foreach ($cols as $col) {
            switch ($col) {
                case 'category':
                    print "<td class='ttable_col{$x}' align='center' valign='middle'>";
                    if (!empty($row["cat_name"])) {
                        print "<a href=\"torrents.php?cat=" . $row["category"] . "\">";
                        if (!empty($row["cat_pic"]) && $row["cat_pic"] != "") {
                            print "<img border=\"0\"src=\"" . $site_config['SITEURL'] . "/images/categories/" . $row["cat_pic"] . "\" alt=\"" . $row["cat_name"] . "\" />";
                        } else {
                            print $row["cat_parent"] . ": " . $row["cat_name"];
                        }
                        print "</a>";
                    } else {
                        print "-";
                    }
                    print "</td>\n";
                    break;
                case 'name':
                    $char1 = 35;
                    //cut name length
                    $smallname = htmlspecialchars(CutName($row["name"], $char1));
                    $dispname = "<b>" . $smallname . "</b>";
                    $last_access = $CURUSER["last_browse"];
                    $time_now = gmtime();
                    if ($last_access > $time_now || !is_numeric($last_access)) {
                        $last_access = $time_now;
                    }
                    if (sql_timestamp_to_unix_timestamp($row["added"]) >= $last_access) {
                        $dispname .= "<b><font color='#ff0000'> - (" . T_("NEW") . "!)</font></b>";
                    }
                    if ($row["freeleech"] == 1) {
                        $dispname .= " <img src='images/free.gif' border='0' alt='' />";
                    }
                    print "<td class='ttable_col{$x}' nowrap='nowrap'>" . (count($expandrows) ? "<a href=\"javascript: klappe_torrent('t" . $row['id'] . "')\"><img border=\"0\" src=\"" . $site_config["SITEURL"] . "/images/plus.gif\" id=\"pict" . $row['id'] . "\" alt=\"Show/Hide\" class=\"showthecross\" /></a>" : "") . "&nbsp;<a title=\"" . $row["name"] . "\" href=\"torrents-details.php?id={$id}&amp;hit=1\">{$dispname}</a></td>";
                    break;
                case 'dl':
                    print "<td class='ttable_col{$x}' align='center'><a href=\"download.php?id={$id}&amp;name=" . rawurlencode($row["filename"]) . "\"><img src='" . $site_config['SITEURL'] . "/images/icon_download.gif' border='0' alt=\"Download .torrent\" /></a></td>";
                    break;
                case 'uploader':
                    echo "<td class='ttable_col{$x}' align='center'>";
                    if (($row["anon"] == "yes" || $row["privacy"] == "strong") && $CURUSER["id"] != $row["owner"] && $CURUSER["edit_torrents"] != "yes") {
                        echo "Anonymous";
                    } elseif ($row["username"]) {
                        echo "<a href='account-details.php?id={$row['owner']}'>{$row['username']}</a>";
                    } else {
                        echo "Unknown";
                    }
                    echo "</td>";
                    break;
                case 'comments':
                    print "<td class='ttable_col{$x}' align='center'><font size='1' face='verdana'><a href='comments.php?type=torrent&amp;id={$id}'>" . number_format($row["comments"]) . "</a></font></td>\n";
                    break;
                case 'nfo':
                    if ($row["nfo"] == "yes") {
                        print "<td class='ttable_col{$x}' align='center'><a href='nfo-view.php?id={$row['id']}'><img src='" . $site_config['SITEURL'] . "/images/icon_nfo.gif' border='0' alt='View NFO' /></a></td>";
                    } else {
                        print "<td class='ttable_col{$x}' align='center'>-</td>";
                    }
                    break;
                case 'size':
                    print "<td class='ttable_col{$x}' align='center'>" . mksize($row["size"]) . "</td>\n";
                    break;
                case 'completed':
                    print "<td class='ttable_col{$x}' align='center'><font color='orange'><b>" . number_format($row["times_completed"]) . "</b></font></td>";
                    break;
                case 'seeders':
                    print "<td class='ttable_col{$x}' align='center'><font color='green'><b>" . number_format($row["seeders"]) . "</b></font></td>\n";
                    break;
                case 'leechers':
                    print "<td class='ttable_col{$x}' align='center'><font color='#ff0000'><b>" . number_format($row["leechers"]) . "</b></font></td>\n";
                    break;
                case 'health':
                    print "<td class='ttable_col{$x}' align='center'><img src='" . $site_config["SITEURL"] . "/images/health/health_" . health($row["leechers"], $row["seeders"]) . ".gif' alt='' /></td>\n";
                    break;
                case 'external':
                    if ($site_config["ALLOWEXTERNAL"]) {
                        if ($row["external"] == 'yes') {
                            print "<td class='ttable_col{$x}' align='center'>" . T_("E") . "</td>\n";
                        } else {
                            print "<td class='ttable_col{$x}' align='center'>" . T_("L") . "</td>\n";
                        }
                    }
                    break;
                case 'added':
                    print "<td class='ttable_col{$x}' align='center'>" . date("d-m-Y H:i:s", utc_to_tz_time($row['added'])) . "</td>";
                    break;
                case 'speed':
                    if ($row["external"] != "yes" && $row["leechers"] >= 1) {
                        $speedQ = SQL_Query_exec("SELECT (SUM(downloaded)) / (UNIX_TIMESTAMP('" . get_date_time() . "') - UNIX_TIMESTAMP(started)) AS totalspeed FROM peers WHERE seeder = 'no' AND torrent = '{$id}' ORDER BY started ASC");
                        $a = mysql_fetch_assoc($speedQ);
                        $totalspeed = mksize($a["totalspeed"]) . "/s";
                    } else {
                        $totalspeed = "--";
                    }
                    print "<td class='ttable_col{$x}' align='center'>{$totalspeed}</td>";
                    break;
                case 'wait':
                    if ($wait) {
                        $elapsed = floor((gmtime() - strtotime($row["added"])) / 3600);
                        if ($elapsed < $wait && $row["external"] != "yes") {
                            $color = dechex(floor(127 * ($wait - $elapsed) / 48 + 128) * 65536);
                            print "<td class='ttable_col{$x}' align='center'><a href=\"faq.php#section46\"><font color=\"{$color}\">" . number_format($wait - $elapsed) . " h</font></a></td>\n";
                        } else {
                            print "<td class='ttable_col{$x}' align='center'>--</td>\n";
                        }
                    }
                    break;
                case 'rating':
                    if (!$row["rating"]) {
                        $rating = "--";
                    } else {
                        $rating = "<a title='{$row['rating']}/5'>" . ratingpic($row["rating"]) . "</a>";
                    }
                    //$rating = ratingpic($row["rating"]);
                    //$srating .= "$rpic (" . $row["rating"] . " out of 5) " . $row["numratings"] . " users have rated this torrent";
                    print "<td class='ttable_col{$x}' align='center'>{$rating}</td>";
                    break;
            }
            if ($x == 2) {
                $x--;
            } else {
                $x++;
            }
        }
        //Wait Time Check
        if ($wait && !in_array("wait", $cols)) {
            $elapsed = floor((gmtime() - strtotime($row["added"])) / 3600);
            if ($elapsed < $wait && $row["external"] != "yes") {
                $color = dechex(floor(127 * ($wait - $elapsed) / 48 + 128) * 65536);
                print "<td class='ttable_col{$x}' align='center'><a href=\"faq.php\"><font color=\"{$color}\">" . number_format($wait - $elapsed) . " h</font></a></td>\n";
            } else {
                print "<td class='ttable_col{$x}' align='center'>--</td>\n";
            }
            $colspan++;
            if ($x == 2) {
                $x--;
            } else {
                $x++;
            }
        }
        print "</tr>\n";
        //Expanding area
        if (count($expandrows)) {
            print "<tr class='t-row'><td class='ttable_col{$x}' colspan='{$colspan}'><div id=\"kt" . $row['id'] . "\" style=\"margin-left: 2px; display: none;\">";
            print "<table width='100%' border='0' cellspacing='0' cellpadding='0'>";
            foreach ($expandrows as $expandrow) {
                switch ($expandrow) {
                    case 'size':
                        print "<tr><td><b>" . T_("SIZE") . "</b>: " . mksize($row['size']) . "</td></tr>";
                        break;
                    case 'speed':
                        if ($row["external"] != "yes" && $row["leechers"] >= 1) {
                            $speedQ = SQL_Query_exec("SELECT (SUM(downloaded)) / (UNIX_TIMESTAMP('" . get_date_time() . "') - UNIX_TIMESTAMP(started)) AS totalspeed FROM peers WHERE seeder = 'no' AND torrent = '{$id}' ORDER BY started ASC");
                            $a = mysql_fetch_assoc($speedQ);
                            $totalspeed = mksize($a["totalspeed"]) . "/s";
                            print "<tr><td><b>" . T_("SPEED") . ":</b> {$totalspeed}</td></tr>";
                        }
                        break;
                    case 'added':
                        print "<tr><td><b>" . T_("ADDED") . ":</b> " . date("d-m-Y \\a\\t H:i:s", utc_to_tz_time($row['added'])) . "</td></tr>";
                        break;
                    case 'tracker':
                        if ($row["external"] == "yes") {
                            print "<tr><td><b>" . T_("TRACKER") . ":</b> " . htmlspecialchars($row["announce"]) . "</td></tr>";
                        }
                        break;
                    case 'completed':
                        print "<tr><td><b>" . T_("COMPLETED") . "</b>: " . number_format($row['times_completed']) . "</td></tr>";
                        break;
                }
            }
            print "</table></div></td></tr>\n";
        }
        //End Expanding Area
    }
    print "</table><br />\n";
}
예제 #5
0
function torrenttable($res, $variant = "index")
{
    global $INSTALLER09, $CURUSER, $lang, $free, $mc1;
    require_once INCL_DIR . 'bbcode_functions.php';
    require_once CLASS_DIR . 'class_user_options_2.php';
    $htmlout = $prevdate = $nuked = $free_slot = $freetorrent = $free_color = $slots_check = $double_slot = $private = $newgenre = $oldlink = $char = $description = $type = $sort = $row = $youtube = '';
    $count_get = $wait = 0;
    if ($CURUSER["class"] < UC_VIP && $INSTALLER09['wait_times'] == 1) {
        $gigs = $CURUSER["uploaded"] / (1024 * 1024 * 1024);
        $ratio = $CURUSER["downloaded"] > 0 ? $CURUSER["uploaded"] / $CURUSER["downloaded"] : 0;
        if ($ratio < 0.5 || $gigs < 5) {
            $wait = 48;
        } elseif ($ratio < 0.65 || $gigs < 6.5) {
            $wait = 24;
        } elseif ($ratio < 0.8 || $gigs < 8) {
            $wait = 12;
        } elseif ($ratio < 0.95 || $gigs < 9.5) {
            $wait = 6;
        } else {
            $wait = 0;
        }
    }
    /** ALL FREE/DOUBLE **/
    foreach ($free as $fl) {
        switch ($fl['modifier']) {
            case 1:
                $free_display = '[Free]';
                break;
            case 2:
                $free_display = '[Double]';
                break;
            case 3:
                $free_display = '[Free and Double]';
                break;
            case 4:
                $free_display = '[Silver]';
                break;
        }
        $slot = make_freeslots($CURUSER['id'], 'fllslot_');
        $book = make_bookmarks($CURUSER['id'], 'bookmm_');
        $all_free_tag = $fl['modifier'] != 0 && ($fl['expires'] > TIME_NOW || $fl['expires'] == 1) ? ' <a class="info" href="#">
            <b>' . $free_display . '</b> 
            <span>' . ($fl['expires'] != 1 ? '
            Expires: ' . get_date($fl['expires'], 'DATE') . '<br />
            (' . mkprettytime($fl['expires'] - TIME_NOW) . ' to go)</span></a><br />' : 'Unlimited</span></a><br />') : '';
    }
    $oldlink = array();
    foreach ($_GET as $key => $var) {
        if (in_array($key, array('sort', 'type'))) {
            continue;
        }
        if (is_array($var)) {
            foreach ($var as $s_var) {
                $oldlink[] = sprintf('%s=%s', urlencode($key) . '%5B%5D', urlencode($s_var));
            }
        } else {
            $oldlink[] = sprintf('%s=%s', urlencode($key), urlencode($var));
        }
    }
    $oldlink = !empty($oldlink) ? join('&amp;', array_map('htmlsafechars', $oldlink)) . '&amp;' : '';
    $links = array('link1', 'link2', 'link3', 'link4', 'link5', 'link6', 'link7', 'link8', 'link9', 'link10');
    $i = 1;
    foreach ($links as $link) {
        if (isset($_GET['sort']) && $_GET['sort'] == $i) {
            ${$link} = isset($_GET['type']) && $_GET['type'] == 'desc' ? 'asc' : 'desc';
        } else {
            ${$link} = 'desc';
        }
        $i++;
    }
    $htmlout .= "<div class'table-responsive'>\n   <table class='table table-bordered'>\n   <tr>\n   <td class='text-center'>{$lang["torrenttable_type"]}</td>\n   <td class='text-left'><a href='{$_SERVER["PHP_SELF"]}?{$oldlink}sort=1&amp;type={$link1}'>{$lang["torrenttable_name"]}</a></td>\n   <td class='text-left'><img src='{$INSTALLER09['pic_base_url']}zip.gif' border='0' alt='Download' title='Download' /></td>";
    $htmlout .= $variant == 'index' ? "<td class='colhead' align='center'><a href='{$INSTALLER09['baseurl']}/bookmarks.php'><img src='{$INSTALLER09['pic_base_url']}bookmarks.png'  border='0' alt='Bookmark' title='Go To My Bookmarks' /></a></td>" : '';
    if ($variant == "mytorrents") {
        $htmlout .= "<td class='text-center'>{$lang["torrenttable_edit"]}</td>\n";
        $htmlout .= "<td class='text-center'>{$lang["torrenttable_visible"]}</td>\n";
    }
    $htmlout .= "<td class='text-right'><a href='{$_SERVER["PHP_SELF"]}?{$oldlink}sort=2&amp;type={$link2}'>{$lang["torrenttable_files"]}</a></td>\n   <td class='text-center'><a href='{$_SERVER["PHP_SELF"]}?{$oldlink}sort=3&amp;type={$link3}'>{$lang["torrenttable_comments"]}</a></td>\n   <td class='text-center'><a href='{$_SERVER["PHP_SELF"]}?{$oldlink}sort=4&amp;type={$link4}'>{$lang["torrenttable_added"]}</a></td>\n   " . ($INSTALLER09['wait_times'] == 1 ? "<td class='text-center'>{$lang["torrenttable_ttl"]}</td>" : "") . "\n   <td class='text-center'><a href='{$_SERVER["PHP_SELF"]}?{$oldlink}sort=5&amp;type={$link5}'>{$lang["torrenttable_size"]}</a></td>\n   <td class='text-center'><a href='{$_SERVER["PHP_SELF"]}?{$oldlink}sort=6&amp;type={$link6}'>{$lang["torrenttable_snatched"]}</a></td>\n   <td class='text-center'><a href='{$_SERVER["PHP_SELF"]}?{$oldlink}sort=7&amp;type={$link7}'>{$lang["torrenttable_seeders"]}</a></td>\n   <td class='text-center'><a href='{$_SERVER["PHP_SELF"]}?{$oldlink}sort=8&amp;type={$link8}'>{$lang["torrenttable_leechers"]}</a></td>";
    if ($variant == 'index') {
        $htmlout .= "<td class='colhead' align='center'><a href='{$_SERVER["PHP_SELF"]}?{$oldlink}sort=9&amp;type={$link9}'>{$lang["torrenttable_uppedby"]}</a></td>\n";
    }
    if ($CURUSER['class'] >= UC_STAFF) {
        $htmlout .= "<td class='text-center'>Tools</td>\n";
    }
    $htmlout .= "\n<td class='text-center'><a href='{$_SERVER["PHP_SELF"]}?{$oldlink}sort=10&amp;type={$link10}'>Health</a></td></tr>\n";
    $categories = genrelist();
    foreach ($categories as $key => $value) {
        $change[$value['id']] = array('id' => $value['id'], 'name' => $value['name'], 'image' => $value['image'], 'min_class' => $value['min_class']);
    }
    while ($row = mysqli_fetch_assoc($res)) {
        //==
        if ($CURUSER['opt2'] & user_options_2::SPLIT) {
            if (get_date($row['added'], 'DATE') == $prevdate) {
                $cleandate = '';
            } else {
                $htmlout .= "<tr><td class='text-left'><b>{$lang['torrenttable_upped']} " . get_date($row['added'], 'DATE') . "</b></td></tr>";
            }
            $prevdate = get_date($row['added'], 'DATE');
        }
        $row['cat_name'] = htmlsafechars($change[$row['category']]['name']);
        $row['cat_pic'] = htmlsafechars($change[$row['category']]['image']);
        $row['min_class'] = htmlsafechars($change[$row['category']]['min_class']);
        /** Freeslot/doubleslot in Use **/
        $id = (int) $row["id"];
        foreach ($slot as $sl) {
            $slots_check = ($sl['torrentid'] == $id && $sl['free'] == 'yes' or $sl['doubleup'] == 'yes');
        }
        if ($row["sticky"] == "yes") {
            $htmlout .= "<tr class='highlight'>\n";
        } else {
            $htmlout .= '<tr class="' . ($free_color && $all_free_tag != '' || $row['free'] != 0 || $slots_check ? 'freeleech_color' : 'browse_color') . '">';
        }
        $htmlout .= "<td class='text-center'>";
        if (isset($row["cat_name"])) {
            $htmlout .= "<a href='browse.php?cat=" . (int) $row['category'] . "'>";
            if (isset($row["cat_pic"]) && $row["cat_pic"] != "") {
                $htmlout .= "<img border='0' src='{$INSTALLER09['pic_base_url']}caticons/{$CURUSER['categorie_icon']}/{$row['cat_pic']}' alt='{$row['cat_name']}' />";
            } else {
                $htmlout .= htmlsafechars($row["cat_name"]);
            }
            $htmlout .= "</a>";
        } else {
            $htmlout .= "-";
        }
        $htmlout .= "</td>\n";
        $dispname = htmlsafechars($row["name"]);
        $smalldescr = !empty($row['description']) ? "<i>[" . htmlsafechars($row['description']) . "]</i>" : "";
        $checked = !empty($row['checked_by']) && $CURUSER['class'] >= UC_USER ? "&nbsp;<img src='{$INSTALLER09['pic_base_url']}mod.gif' width='15' border='0' alt='Checked - by " . htmlsafechars($row['checked_by']) . "' title='Checked - by " . htmlsafechars($row['checked_by']) . "' />" : "";
        $poster = empty($row["poster"]) ? "<img src=\\'{$INSTALLER09['pic_base_url']}noposter.png\\' width=\\'150\\' height=\\'220\\' border=\\'0\\' alt=\\'Poster\\' title=\\'poster\\' />" : "<img src=\\'" . htmlsafechars($row['poster']) . "\\' width=\\'150\\' height=\\'220\\' border=\\'0\\' alt=\\'Poster\\' title=\\'poster\\' />";
        //$rating = empty($row["rating"]) ? "No votes yet":"".ratingpic($row["rating"])."";
        $youtube = !empty($row['youtube']) ? "<a href='" . htmlsafechars($row['youtube']) . "' target='_blank'><img src='{$INSTALLER09['pic_base_url']}youtube.png' width='14' height='14' border='0' alt='Youtube Trailer' title='Youtube Trailer' /></a>" : "";
        if (isset($row["descr"])) {
            $descr = str_replace("\"", "&quot;", readMore($row["descr"], 350, "details.php?id=" . (int) $row["id"] . "&amp;hit=1"));
        }
        $descr = str_replace('&', '&amp;', $descr);
        $htmlout .= "<td align='left'><a href='details.php?";
        if ($variant == "mytorrents") {
            $htmlout .= "returnto=" . urlencode($_SERVER["REQUEST_URI"]) . "&amp;";
        }
        $htmlout .= "id={$id}";
        if ($variant == "index") {
            $htmlout .= "&amp;hit=1";
        }
        $newgenre = '';
        if (!empty($row['newgenre'])) {
            $newgenre = array();
            $row['newgenre'] = explode(',', $row['newgenre']);
            foreach ($row['newgenre'] as $foo) {
                $newgenre[] = '<a href="browse.php?search=' . trim(strtolower($foo)) . '&amp;searchin=genre">' . $foo . '</a>';
            }
            $newgenre = '<i>' . join(', ', $newgenre) . '</i>';
        }
        $sticky = $row['sticky'] == "yes" ? "<img src='{$INSTALLER09['pic_base_url']}sticky.gif' style='border:none' alt='Sticky' title='Sticky !' />" : "";
        $nuked = $row["nuked"] == "yes" ? "<img src='{$INSTALLER09['pic_base_url']}nuked.gif' style='border:none' alt='Nuked'  align='right' title='Reason :" . htmlsafechars($row["nukereason"]) . "' />" : "";
        $release_group = $row['release_group'] == "scene" ? "&nbsp;<img src='{$INSTALLER09['pic_base_url']}scene.gif' title='Scene' alt='Scene' style='border:none' />" : ($row['release_group'] == "p2p" ? "&nbsp;<img src='{$INSTALLER09['pic_base_url']}p2p.gif' title='P2P' alt='P2P' />" : "");
        $viponly = $row["vip"] == 1 ? "<img src='{$INSTALLER09['pic_base_url']}star.png' border='0' alt='Vip Torrent' title='Vip Torrent' />" : "";
        $freetorrent = XBT_TRACKER == true && $row["freetorrent"] >= 1 ? "<img src='{$INSTALLER09['pic_base_url']}freedownload.gif' border='0' alt='Free Torrent' title='Free Torrent' />" : "";
        $bump = $row['bump'] == "yes" ? "<img src='{$INSTALLER09['pic_base_url']}up.gif' width='12px' alt='Re-Animated torrent' title='This torrent was ReAnimated!' />" : "";
        /** FREE Torrent **/
        $free_tag = $row['free'] != 0 ? ' <a class="info" href="#"><b>[FREE]</b> <span>' . ($row['free'] > 1 ? 'Expires: ' . get_date($row['free'], 'DATE') . '<br />(' . mkprettytime($row['free'] - TIME_NOW) . ' to go)<br />' : 'Unlimited<br />') . '</span></a>' : $all_free_tag;
        /** Silver Torrent **/
        $silver_tag = $row['silver'] != 0 ? ' <a class="info" href="#"><b>[SILVER]</b> <span>' . ($row['silver'] > 1 ? 'Expires: ' . get_date($row['silver'], 'DATE') . '<br />(' . mkprettytime($row['silver'] - TIME_NOW) . ' to go)<br />' : 'Unlimited<br />') . '</span></a>' : '';
        if (!empty($slot)) {
            foreach ($slot as $sl) {
                if ($sl['torrentid'] == $id && $sl['free'] == 'yes') {
                    $free_slot = 1;
                }
                if ($sl['torrentid'] == $id && $sl['doubleup'] == 'yes') {
                    $double_slot = 1;
                }
                if ($free_slot && $double_slot) {
                    break;
                }
            }
        }
        $free_slot = $free_slot == 1 ? '&nbsp;<img src="' . $INSTALLER09['pic_base_url'] . 'freedownload.gif" width="12px" alt="Free Slot" title="Free Slot in Use" />&nbsp;<small>Free Slot</small>' : '';
        $double_slot = $double_slot == 1 ? '&nbsp;<img src="' . $INSTALLER09['pic_base_url'] . 'doubleseed.gif" width="12px" alt="Double Upload Slot" title="Double Upload Slot in Use" />&nbsp;<small>Double Slot</small><br />' : '';
        $nuked = $row['nuked'] != 'no' && $row['nuked'] != '' ? '&nbsp;<span title="Nuked ' . htmlsafechars($row['nuked']) . '" class="browse-icons-nuked"></span>' : '';
        //==
        $Subs = '';
        if (in_array($row["category"], $INSTALLER09['movie_cats']) && !empty($row["subs"])) {
            $subs_array = explode(",", $row["subs"]);
            foreach ($subs_array as $k => $sid) {
                require_once CACHE_DIR . 'subs.php';
                foreach ($subs as $sub) {
                    if ($sub["id"] == $sid) {
                        $Subs = "<img border='0' width='16px' style='padding:3px;' src='" . htmlsafechars($sub["pic"]) . "' alt='" . htmlsafechars($sub["name"]) . "' title='" . htmlsafechars($sub["name"]) . "' />";
                    }
                }
            }
        } else {
            $Subs = "---";
        }
        $htmlout .= "' onmouseover=\"Tip('<b>" . CutName($dispname, 80) . "</b><br /><b>Added:&nbsp;" . get_date($row['added'], 'DATE', 0, 1) . "</b><br /><b>Size:&nbsp;" . mksize(htmlsafechars($row["size"])) . "</b><br /><b>Subtitle:&nbsp;{$Subs}</b><br /><b>Seeders:&nbsp;" . htmlsafechars($row["seeders"]) . "</b><br /><b>Leechers:&nbsp;" . htmlsafechars($row["leechers"]) . "</b><br />{$poster}');\" onmouseout=\"UnTip();\"><b>" . CutName($dispname, 45) . "</b></a>&nbsp;&nbsp;<a href=\"javascript:klappe_descr('descr" . (int) $row["id"] . "');\" ><img src=\"{$INSTALLER09['pic_base_url']}plus.png\" border=\"0\" alt=\"Show torrent info in this page\" title=\"Show torrent info in this page\" /></a>&nbsp;&nbsp;{$youtube}&nbsp;{$viponly}&nbsp;{$release_group}&nbsp;{$sticky}&nbsp;" . ($row['added'] >= $CURUSER['last_browse'] ? " <img src='{$INSTALLER09['pic_base_url']}newb.png' border='0' alt='New !' title='New !' />" : "") . "&nbsp;{$checked}&nbsp;{$freetorrent}&nbsp;{$free_tag}&nbsp;{$silver_tag}<br />{$free_slot}&nbsp;{$double_slot}&nbsp;{$nuked}&nbsp;{$newgenre}&nbsp;{$bump}&nbsp;{$smalldescr}</td>\n";
        if ($variant == "mytorrents") {
            $htmlout .= "<td class='text-center'><a href=\"download.php?torrent={$id}" . ($CURUSER['ssluse'] == 3 ? "&amp;ssl=1" : "") . "\"><img src='{$INSTALLER09['pic_base_url']}zip.gif' border='0' alt='Download This Torrent!' title='Download This Torrent!' /></a></td>\n";
        }
        if ($variant == "mytorrents") {
            $htmlout .= "<td class='text-center'><a href='edit.php?id=" . (int) $row['id'] . "amp;returnto=" . urlencode($_SERVER["REQUEST_URI"]) . "'>{$lang["torrenttable_edit"]}</a></td>\n";
        }
        $htmlout .= $variant == "index" ? "<td class='text-center'><a href=\"download.php?torrent={$id}" . ($CURUSER['ssluse'] == 3 ? "&amp;ssl=1" : "") . "\"><img src='{$INSTALLER09['pic_base_url']}zip.gif' border='0' alt='Download This Torrent!' title='Download This Torrent!' /></a></td>" : "";
        if ($variant == "mytorrents") {
            $htmlout .= "<td class='text-right'>";
            if ($row["visible"] == "no") {
                $htmlout .= "<b>{$lang["torrenttable_not_visible"]}</b>";
            } else {
                $htmlout .= "{$lang["torrenttable_visible"]}";
            }
            $htmlout .= "</td>\n";
        }
        /** pdq bookmarks **/
        $booked = '';
        if (!empty($book)) {
            foreach ($book as $bk) {
                if ($bk['torrentid'] == $id) {
                    $booked = 1;
                }
            }
        }
        $rm_status = !$booked ? ' style="display:none;"' : ' style="display:inline;"';
        $bm_status = $booked ? ' style="display:none;"' : ' style="display:inline;"';
        $bookmark = '<span id="bookmark' . $id . '"' . $bm_status . '>
                    <a href="bookmark.php?torrent=' . $id . '&amp;action=add" class="bookmark" name="' . $id . '">
                    <span title="Bookmark it!" class="add_bookmark_b">
                    <img src="' . $INSTALLER09['pic_base_url'] . 'aff_tick.gif" align="top" width="14px" alt="Bookmark it!" title="Bookmark it!" />
                    </span>
                    </a>
                    </span>
                    <span id="remove' . $id . '"' . $rm_status . '>
                    <a href="bookmark.php?torrent=' . $id . '&amp;action=delete" class="remove" name="' . $id . '">
                    <span class="remove_bookmark_b">
                    <img src="' . $INSTALLER09['pic_base_url'] . 'aff_cross.gif" align="top" width="14px" alt="Delete Bookmark!" title="Delete Bookmark!" />
                    </span>
                    </a>
                    </span>';
        if ($variant == "index") {
            $htmlout .= "<td align='right'>{$bookmark}</td>";
        }
        if ($row["type"] == "single") {
            $htmlout .= "<td class='text-right'>" . (int) $row["numfiles"] . "</td>\n";
        } else {
            if ($variant == "index") {
                $htmlout .= "<td class='text-right'><b><a href='filelist.php?id={$id}'>" . (int) $row["numfiles"] . "</a></b></td>\n";
            } else {
                $htmlout .= "<td class='text-right'><b><a href='filelist.php?id={$id}'>" . (int) $row["numfiles"] . "</a></b></td>\n";
            }
        }
        if (!$row["comments"]) {
            $htmlout .= "<td class='text-right'>" . (int) $row["comments"] . "</td>\n";
        } else {
            if ($variant == "index") {
                $htmlout .= "<td class='text-right'><b><a href='details.php?id={$id}&amp;hit=1&amp;tocomm=1'>" . (int) $row["comments"] . "</a></b></td>\n";
            } else {
                $htmlout .= "<td class='text-right'><b><a href='details.php?id={$id}&amp;page=0#startcomments'>" . (int) $row["comments"] . "</a></b></td>\n";
            }
        }
        $htmlout .= "<td class='text-center'><span style='white-space: nowrap;'>" . str_replace(",", "<br />", get_date($row['added'], '')) . "</span></td>\n";
        $ttl = 28 * 24 - floor((TIME_NOW - $row["added"]) / 3600);
        if ($ttl == 1) {
            $ttl .= "<br />" . $lang["torrenttable_hour_singular"];
        } else {
            $ttl .= "<br />" . $lang["torrenttable_hour_plural"];
        }
        $htmlout .= $INSTALLER09['wait_times'] == 1 ? "<td class='text-center'>{$ttl}</td>\n" : "";
        $htmlout .= "<td class='text-center'>" . str_replace(" ", "<br />", mksize($row["size"])) . "</td>\n";
        if ($row["times_completed"] != 1) {
            $_s = "" . $lang["torrenttable_time_plural"];
        } else {
            $_s = "" . $lang["torrenttable_time_singular"];
        }
        $What_Script_S = XBT_TRACKER == true ? 'snatches_xbt.php?id=' : 'snatches.php?id=';
        $htmlout .= "<td class='text-center'><a href='{$What_Script_S}" . "{$id}'>" . number_format($row["times_completed"]) . "<br />{$_s}</a></td>\n";
        if ($row["seeders"]) {
            if ($variant == "index") {
                if ($row["leechers"]) {
                    $ratio = $row["seeders"] / $row["leechers"];
                } else {
                    $ratio = 1;
                }
                $What_Script_P = XBT_TRACKER == true ? 'peerlist_xbt.php?id=' : 'peerlist.php?id=';
                $htmlout .= "<td class='text-right'><b><a href='{$What_Script_P}" . "{$id}#seeders'><font color='" . get_slr_color($ratio) . "'>" . (int) $row["seeders"] . "</font></a></b></td>\n";
            } else {
                $What_Script_P = XBT_TRACKER == true ? 'peerlist_xbt.php?id=' : 'peerlist.php?id=';
                $htmlout .= "<td class='text-right'><b><a class='" . linkcolor($row["seeders"]) . "' href='{$What_Script_P}" . "{$id}#seeders'>" . (int) $row["seeders"] . "</a></b></td>\n";
            }
        } else {
            $htmlout .= "<td class='text-right'><span class='" . linkcolor($row["seeders"]) . "'>" . (int) $row["seeders"] . "</span></td>\n";
        }
        if ($row["leechers"]) {
            $What_Script_P = XBT_TRACKER == true ? 'peerlist_xbt.php?id=' : 'peerlist.php?id=';
            if ($variant == "index") {
                $htmlout .= "<td class='text-right'><b><a href='{$What_Script_P}" . "{$id}#leechers'>" . number_format($row["leechers"]) . "</a></b></td>\n";
            } else {
                $htmlout .= "<td class='text-right'><b><a class='" . linkcolor($row["leechers"]) . "' href='{$What_Script_P}" . "{$id}#leechers'>" . (int) $row["leechers"] . "</a></b></td>\n";
            }
        } else {
            $htmlout .= "<td class='text-right'>0</td>\n";
        }
        if ($variant == "index") {
            $htmlout .= "<td class='text-center'>" . (isset($row["username"]) ? $row["anonymous"] == "yes" && $CURUSER['class'] < UC_STAFF && $row['owner'] != $CURUSER['id'] ? "<i>" . $lang['torrenttable_anon'] . "</i>" : "<a href='userdetails.php?id=" . (int) $row["owner"] . "'><b>" . htmlsafechars($row["username"]) . "</b></a>" : "<i>(" . $lang["torrenttable_unknown_uploader"] . ")</i>") . "</td>\n";
        }
        if ($CURUSER['class'] >= UC_STAFF) {
            $url = "edit.php?id=" . (int) $row["id"];
            if (isset($_GET["returnto"])) {
                $addthis = "&amp;returnto=" . urlencode($_GET["returnto"]);
                $url .= $addthis;
            }
            $editlink = "a href=\"{$url}\" class=\"sublink\"";
            $del_link = $CURUSER['class'] === UC_MAX ? "<a href='fastdelete.php?id=" . (int) $row['id'] . "'>&nbsp;<img src='{$INSTALLER09['pic_base_url']}button_delete2.gif' alt='Fast Delete' title='Fast Delete' /></a>" : "";
            $htmlout .= "<td class='text-center'><{$editlink}><img src='{$INSTALLER09['pic_base_url']}button_edit2.gif' alt='Fast Edit' title='Fast Edit' /></a>{$del_link}</td>\n";
        }
        if (!function_exists('health')) {
            function health($leechers, $seeders)
            {
                global $INSTALLER09;
                if ($leechers > 0 && $seeders > 0) {
                    $ratio = $seeders / $leechers * 100;
                }
                if ($leechers == 1 && $seeders == 1) {
                    $ratio = $seeders / $leechers * 1;
                }
                if ($leechers == 0 && $seeders == 0 || $leechers > 0 && $seeders == 0) {
                    return "<img src=' " . $INSTALLER09['baseurl'] . "/images/health/health_0.gif' alt='Torrent Dead' title='Torrent Dead' />";
                } elseif ($seeders > $leechers) {
                    return "<img src=' " . $INSTALLER09['baseurl'] . "/images/health/health_10.gif' alt='Torrent health' title='Torrent health' />";
                }
                switch ($ratio) {
                    case $ratio > 0 && $ratio < 15:
                        return "<img src=' " . $INSTALLER09['baseurl'] . "/images/health/health_1.gif' alt='Torrent health' title='Torrent health' />";
                        break;
                    case $ratio >= 15 && $ratio < 25:
                        return "<img src=' " . $INSTALLER09['baseurl'] . "/images/health/health_2.gif' alt='Torrent health' title='Torrent health' />";
                        break;
                    case $ratio >= 25 && $ratio < 35:
                        return "<img src=' " . $INSTALLER09['baseurl'] . "/images/health/health_3.gif' alt='Torrent health' title='Torrent health' />";
                        break;
                    case $ratio >= 35 && $ratio < 45:
                        return "<img src=' " . $INSTALLER09['baseurl'] . "/images/health/health_4.gif' alt='Torrent health' title='Torrent health' />";
                        break;
                    case $ratio >= 45 && $ratio < 55:
                        return "<img src=' " . $INSTALLER09['baseurl'] . "/images/health/health_5.gif' alt='Torrent health' title='Torrent health' />";
                        break;
                    case $ratio >= 55 && $ratio < 65:
                        return "<img src=' " . $INSTALLER09['baseurl'] . "/images/health/health_6.gif' alt='Torrent health' title='Torrent health' />";
                        break;
                    case $ratio >= 65 && $ratio < 75:
                        return "<img src=' " . $INSTALLER09['baseurl'] . "/images/health/health_7.gif' alt='Torrent health' title='Torrent health' />";
                        break;
                    case $ratio >= 75 && $ratio < 85:
                        return "<img src=' " . $INSTALLER09['baseurl'] . "/images/health/health_8.gif' alt='Torrent health' title='Torrent health' />";
                        break;
                    case $ratio >= 85 && $ratio < 95:
                        return "<img src=' " . $INSTALLER09['baseurl'] . "/images/health/health_9.gif' alt='Torrent health' title='Torrent health' />";
                        break;
                }
            }
        }
        $htmlout .= "<td class='text-center'><span>" . health($row["leechers"], $row["seeders"]) . "</td>";
        $htmlout .= "</tr>\n";
        $htmlout .= "<tr id=\"kdescr" . (int) $row["id"] . "\" style=\"display:none;\"><td width=\"100%\" colspan=\"14\">" . format_comment($descr, false) . "</td></tr>\n";
    }
    $htmlout .= "</table></div>\n";
    return $htmlout;
}