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 'magnet':
echo "<th>".T_("MAGNET2")."</th>";
break;
case 'imdb':
echo "<th>".T_("IMDB_INDEX_PAGE")."</th>";
break;
case 'tube':
echo "<th>".T_("YOUTUBE")."</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 = mysqli_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>";
$dispname .= " <img src='images/newtorrent.png' border='0'>";
if ($row["sticky"] == "yes")
$dispname .= " <img src='images/sticky.gif' border='0'>";
if ($row["freeleech"] == 1)
$dispname .= " <img src='images/free.gif' border='0' alt='' />";
if ($row["uplreq"] == 'yes')
$dispname .= "<b><font color='#0000FF'> - (".T_("REQUEST").")</font></b>";
//////////BALLOON TOOLTIP MOD UFFENO1 VERSION (8-4-2018). Edited to suit the use of CSS to control the color of background. See theme.css of each theme for ballooncolor and balloonheadercolor.
$preparing_descr=SQL_Query_exec("SELECT torrents.anon, torrents.views, torrents.hits, torrents.descr, torrents.seeders, torrents.banned, torrents.leechers, torrents.info_hash, torrents.filename, torrents.nfo, torrents.last_action, torrents.numratings, torrents.name, torrents.owner, torrents.save_as, torrents.descr, torrents.visible, torrents.size, torrents.added, torrents.views, torrents.hits, torrents.times_completed, torrents.id, torrents.type, torrents.external, torrents.image1, torrents.announce, torrents.numfiles, torrents.freeleech, IF(torrents.numratings < 2, NULL, ROUND(torrents.ratingsum / torrents.numratings, 1)) AS rating, torrents.numratings, categories.name AS cat_name, torrentlang.name AS lang_name, torrentlang.image AS lang_image, categories.parent_cat as cat_parent, users.username, users.privacy FROM torrents LEFT JOIN categories ON torrents.category = categories.id LEFT JOIN torrentlang ON torrents.torrentlang = torrentlang.id LEFT JOIN users ON torrents.owner = users.id WHERE torrents.id = $id");
$descr=mysqli_fetch_array($preparing_descr);
if (empty($descr["lang_name"]))
$descr["lang_name"] = "Unknown/NA";
$lang = "<b>" .T_("LANG"). " : </b>" . $descr["lang_name"] . "";
if (isset($descr["lang_image"]) && $descr["lang_image"] != "")
$flag = "<img src=$site_config[SITEURL]/images/languages/$descr[lang_image] border=0 alt=$descr[lang_name]>";
$bimg = @mysqli_fetch_array(@SQL_Query_exec("SELECT image1 FROM torrents WHERE id=$id"));
$balon =($bimg["image1"] ? "$site_config[SITEURL]/uploads/images/" . htmlspecialchars($bimg["image1"]) : "images/nocover.png");
$des = mysqli_real_escape_string($GLOBALS["DBconnector"],format_comment($descr['descr']));
$char5 = 500; //cut name length
if (($descr["anon"] == "yes" || $row["privacy"] == "strong") && $CURUSER["id"] != $descr["owner"] && $CURUSER["edit_torrents"] != "yes") {
$descr['username'] = "".T_("ANONYMOUS")."";
}else{
$descr['username'];
}
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>":"")." <a href=\"torrents-details.php?id=$id&hit=1\" onMouseover=\"return overlib('<table class=ballooncolor border=1 width=100% class=ttable_headinner cellspacing=0 cellpadding=5 align=center><tr><td class=balloonheadercolor colspan=2 align=center>$smallname</td></tr><tr valign=top><td class=table_col1 align=center><img border=0 width=120 src=$balon></td><td width=80% class=table_col1><div align=left><b>Uploaded on: </b>" . date("m-d-Y", utc_to_tz_time($row["added"])) . "<br /><b>Size: </b>". mksize($row["size"]) . "<br /><b>Completed: </b>" . $row["times_completed"] . "<br /></div><div align=left><b>Views: </b>" . $descr["views"] . "<br />".$lang." ".$flag."<br /><b>Hits: </b>" . $descr["hits"] . "<br /><b>Seeders: </b><font color=green>" . $row["seeders"] . "</font><br /><b>Leechers: </b><font color=red>" . $row["leechers"] . "</font><br /><b> Uploaded by: </b>" . $descr['username'] . "</div></td></tr><tr><td class=balloonheadercolor colspan=2 align=center>".T_("DESCRIPTION")."</td></tr><tr><td class=table_col1 colspan=2>" . CutName($des, $char5) . "</td></tr></table>', CENTER, HEIGHT, 150, WIDTH, 300)\"; onMouseout=\"return nd()\">".$dispname."</a></td>");
break;
////////END BALLOON MOD
/////This goes below to reverse the torrent encryption/////<a href=\"download.php?id=$id&name=" . rawurlencode($row["filename"]) . "\">
// case 'dl':
// print("<td class='ttable_col$x' align='center'><a href=\"download.php?id=$id&name=" . rawurlencode($row["filename"]) . "\"><img src='" . $site_config['SITEURL'] . "/images/icon_download.png' border='0' width='50' height='50'alt=\"Download .torrent\" /></a></td>");
// break;
case 'dl':
//require_once("backend/URLencrypt.php");
print("<td class='ttable_col$x' align='center'><a href=\"download.php?id=$id&name=" . rawurlencode($row["filename"]) . "\"><img src='" . $site_config['SITEURL'] . "/images/icon_download.png' border='0' width='50' height='50'title='Download .torrent' /></a></td>");
break;
case 'magnet':
$shit = mysqli_fetch_array(SQL_Query_exec("SELECT info_hash FROM torrents WHERE id=$id"));
if ($row["external"]!='yes') {
print ("<td class='ttable_col$x' align='center'><a href=\"magnet:?xt=urn:btih:" . $shit["info_hash"] . "&dn=" . rawurlencode($row['name']) . "&tr=" . $row['announce'] . "?passkey=". $CURUSER ['passkey']. "\"><img src='" . $site_config['SITEURL'] . "/images/magnetique.png' border='0' width='50' height='50'title='Download via Magnet' /></a></td>");
}else{
print ("<td class='ttable_col$x' align='center'><img src='" . $site_config['SITEURL'] . "/images/no_magnet.png' border='0' width='50' height='50'title='No magnet links on externally tracked torrents due to user passkey' /></td>");
}
break;
// case 'magnet':
// $shit = @mysqli_fetch_array(@SQL_Query_exec("SELECT info_hash FROM torrents WHERE id=$id"));
// print ("<td class='ttable_col$x' align='center'><a href=\"magnet:?xt=urn:btih:" . $shit["info_hash"] . "&dn=" . rawurlencode($row['name']) . "&tr=" . $row['announce'] . "?passkey=". $CURUSER ['passkey']. "\"><img src='" . $site_config['SITEURL'] . "/images/magnetique.png' border='0' width='50' height='50'title='Download via Magnet' /></a></td>");
// break;
case 'imdb':
if ($row["imdb"])
print("<td class='ttable_col$x' align='center'><a href=".$row['imdb']." target='_blank'><".htmlspecialchars($row['imdb'])."><img src='" . $site_config['SITEURL'] . "/images/imdb.png' border='0' width='50' height='50' alt=\"\" /></a></td>");
else
print("<td class='ttable_colx' align='center'>-</td>");
break;
case 'tube':
$video=$row["trailers"]; //Dont forget to make changes to torrents-details also around line 304
$video=substr($video,27); //adjustments to shorten the URL removes first 27 characters from URL
$video2=$video; //changing variables to further shorten the URL
$video2=substr($video2, 0, -21); //more adjustments to shorten the URL down the the IMDB video number only. removes last 21 characters
if ($row["tube"])
print("<td class='ttable_col$x' align='center'><a rel=\"prettyPhoto\" href=".$row['tube']." ><".htmlspecialchars($row['tube'])."><img src='" . $site_config['SITEURL'] . "/images/youtube1.png' border='0' width='50' height='50' title='Click to watch the YouTube Trailer' /></a></td>");
elseif ($row["trailers"])
print("<td class='ttable_col$x' align='center'><a rel=\"prettyPhoto[iframes]\" href=\"http://www.imdb.com/videoembed/". $video2."?ref_=embed&?iframe=true\"><img src='" . $site_config['SITEURL'] . "/images/movietrailers.png' border='0' width='50' height='50' title='Click to watch the IMDb Trailer' /></a></td>");
else
print("<td class='ttable_colx' align='center'>-</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]'>".class_user($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&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]'rel=\"prettyPhoto\"><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("n-d-Y g:i a", 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 = mysqli_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++;
}
?> 
Database Error in torrents-edit.php on line 152: Data truncated for column 'freeleech' at row 1. Query was: UPDATE torrents SET name = 'DJ Blyatman',descr = 'No description given.',category = 50,torrentlang = 1,banned = 'no',visible = 'yes',freeleech = '',anon = 'no' WHERE id = 8.$updateset[] = "freeleech = '".$_POST["freeleech"]."'"; SQL_Query_exec("UPDATE torrents SET " . join(",", $updateset) . " WHERE id = $id"); $s = preg_replace("/\[video\][^\s'\"<>]*youtube.com.*v=([^\s'\"<>]+)\[\/video\]/ims", "<object width=\"340\" height=\"220\"><param name=\"movie\" value=\"https://www.youtube.com/v/\\1\"></param><embed src=\"http://www.youtube.com/v/\\1\" type=\"application/x-shockwave-flash\" width=\"340\" height=\"220\"></embed></object>", $s); <?php
// Please Note: Languages should not be implemented here...
error_reporting(E_ALL ^ E_NOTICE);
require_once("backend/mysql.php");
require_once("backend/config.php");
require_once("backend/mysql.class.php");
$GLOBALS["DBconnector"] = @mysqli_connect($mysql_host, $mysql_user, $mysql_pass) or err('dbconn: mysqli_connect: ' . mysqli_connect_error());
@mysqli_select_db($GLOBALS["DBconnector"],$mysql_db) or err('dbconn: mysqli_select_db: ' . mysqli_error($GLOBALS["DBconnector"]));
$MEMBERSONLY = $site_config["MEMBERSONLY"];
$MEMBERSONLY_WAIT = $site_config["MEMBERSONLY_WAIT"];
$_GET = array_map_recursive("unesc", $_GET);
//START FUNCTIONS
function array_map_recursive ($callback, $array) {
$ret = array();
if (!is_array($array))
return $callback($array);
foreach ($array as $key => $val) {
$ret[$key] = array_map_recursive($callback, $val);
}
return $ret;
}
function unesc($x) {
if (get_magic_quotes_gpc())
return stripslashes($x);
return $x;
}
function is_valid_id($id) {
return is_numeric($id) && ($id > 0) && (floor($id) == $id);
}
function sqlesc($x) {
return "'".mysqli_real_escape_string($GLOBALS["DBconnector"],$x)."'";
}
function err($msg) {
mysqli_close($GLOBALS["DBconnector"]);
return benc_resp_raw("d".benc_str("failure reason").benc_str($msg)."e");
}
function benc_str($s) {
return strlen($s) . ":$s";
}
function benc_int($i) {
return "i" . $i . "e";
}
function benc_resp_raw($x) {
header("Content-Type: text/plain");
header("Pragma: no-cache");
if (extension_loaded('zlib') && !ini_get('zlib.output_compression') && $_SERVER["HTTP_ACCEPT_ENCODING"] == "gzip") {
header("Content-Encoding: gzip");
echo gzencode($x, 9, FORCE_GZIP);
} else
print($x);
exit();
}
function gmtime()
{
return strtotime(get_date_time());
}
function get_date_time($timestamp = 0)
{
if ($timestamp)
return date("Y-m-d H:i:s", $timestamp);
else
return gmdate("Y-m-d H:i:s");
}
function portblacklisted($port) {
// direct connect
if ($port >= 411 && $port <= 413) return true;
// kazaa
if ($port == 1214) return true;
// gnutella
if ($port >= 6346 && $port <= 6347) return true;
// emule
if ($port == 4662) return true;
// winmx
if ($port == 6699) return true;
return false;
}
//////////////////////// NOW WE DO THE ANNOUNCE CODE ////////////////////////
// BLOCK ACCESS WITH WEB BROWSERS
$agent = $_SERVER["HTTP_USER_AGENT"];
if (preg_match("/^Mozilla|^Opera|^Links|^Lynx/i", $agent))
die("No");
//GET DETAILS OF PEERS ANNOUNCE
foreach (array("passkey","info_hash","peer_id","ip","event") as $x) {
$GLOBALS[$x] = $_GET[$x];
}
foreach (array("port","downloaded","uploaded","left") as $x)
$GLOBALS[$x] = 0 + $_GET[$x];
if (strpos($passkey, "?")) {
$tmp = substr($passkey, strpos($passkey, "?"));
$passkey = substr($passkey, 0, strpos($passkey, "?"));
$tmpname = substr($tmp, 1, strpos($tmp, "=")-1);
$tmpvalue = substr($tmp, strpos($tmp, "=")+1);
$GLOBALS[$tmpname] = $tmpvalue;
}
foreach (array("passkey","info_hash","peer_id","port","downloaded","uploaded","left") as $x)
if (!isset($$x))
err("Missing key: $x");
if (strlen($peer_id) != 20)
err("Invalid peer_id");
$no_peer_id = (int) $_GET["no_peer_id"];
if (strlen($GLOBALS['info_hash']) == 20)
$GLOBALS['info_hash'] = bin2hex($GLOBALS['info_hash']);
else if (strlen($GLOBALS['info_hash']) != 40)
err("Invalid info hash value.");
$GLOBALS['info_hash'] = strtolower($GLOBALS['info_hash']);
if ($MEMBERSONLY){
if (strlen($passkey) != 32)
err("Invalid passkey (" . strlen($passkey) . " - $passkey)");
}
$ip = $_SERVER["REMOTE_ADDR"];
foreach(array("num want", "numwant", "num_want") as $k)
{
if (isset($_GET[$k]))
{
$rsize = (int) $_GET[$k];
break;
}
}
//PORT CHECK
if (!$port || $port > 0xffff)
err("invalid port");
//TRACKER EVENT CHECK
if (!isset($event))
$event = "";
$seeder = ($left == 0) ? "yes" : "no";
//Agent Ban
$agentarray = array_map("trim", explode(",", $site_config["BANNED_AGENTS"]));
$useragent = substr($peer_id, 0, 8);
foreach($agentarray as $bannedclient)
if (@strpos($useragent, $bannedclient) !== false)
err("Client is banned");
//End Agent Bans
if (portblacklisted($port))
err("Port $port is blacklisted.");
$userfields = "u.id, u.class, u.uploaded, u.downloaded, u.ip, u.passkey, g.can_download"; //user details to get
$peerfields = "seeder, UNIX_TIMESTAMP(last_action) AS ez, peer_id, ip, port, uploaded, downloaded, userid, passkey"; //peers details to get
$torrentfields = "id, info_hash, banned, freeleech, seeders + leechers AS numpeers, UNIX_TIMESTAMP(added) AS ts, seeders, leechers, times_completed"; //torrent details to get
$userid = 0;
if ($MEMBERSONLY){
//check passkey is valid, and get users details
$res = SQL_Query_exec("SELECT $userfields FROM users u INNER JOIN groups g ON u.class = g.group_id WHERE u.passkey=".sqlesc($passkey)." AND u.enabled = 'yes' AND u.status = 'confirmed' LIMIT 1") or err("Cannot Get User Details");
$user = mysqli_fetch_assoc($res);
if (!$user)
err("Cannot locate a user with that passkey!");
if ($user["can_download"] == "no")
err("You do not have permission to download.");
$userid = $user["id"]; //etc
}
//check torrent is valid and get torrent fields
$res = SQL_Query_exec("SELECT $torrentfields FROM torrents WHERE info_hash=".sqlesc($info_hash)) or err("Cannot Get Torrent Details");
$torrent = mysqli_fetch_assoc($res);
if (!$torrent)
err("Torrent not found on this tracker - hash = " . $info_hash);
if ($torrent["banned"]=='yes')
err("Torrent has been banned - hash = " . $info_hash);
$torrentid = $torrent["id"];
//Now get data from peers table
$peerlimit = 5550;
$numpeers = $torrent["numpeers"];
if ($numpeers > $peerlimit){
$limit = "ORDER BY RAND() LIMIT $peerlimit";
}else{
$limit = "";
}
$res = SQL_Query_exec("SELECT $peerfields FROM peers WHERE torrent = $torrentid $limit") or err("Error Selecting Peers");
//DO SOME BENC STUFF TO THE PEERS CONNECTION
$resp = "d8:completei$torrent[seeders]e10:downloadedi$torrent[times_completed]e10:incompletei$torrent[leechers]e";
$resp .= benc_str("interval") . "i" . $site_config['announce_interval'] . "e" . benc_str("min interval") . "i300e" . benc_str("peers");
unset($self);
while ($row = mysqli_fetch_assoc($res)) {
if ($row["peer_id"] === $peer_id) {
$self = $row;
continue;
}
$peers .= "d" . benc_str("ip") . benc_str($row["ip"]);
if (!$no_peer_id)
$peers .= benc_str("peer id") . benc_str($row["peer_id"]);
$peers .= benc_str("port") . "i" . $row["port"] . "ee";
}
$resp .= "l{$peers}e";
$resp .= "ee";
$selfwhere = "torrent = $torrentid AND peer_id = ".sqlesc($peer_id);
// FILL $SELF WITH DETAILS FROM PEERS TABLE (CONNECTING PEERS DETAILS)
if (!isset($self)){
//check passkey isnt leaked
if ($MEMBERSONLY) {
$valid = @mysqli_fetch_row(@SQL_Query_exec("SELECT COUNT(*) FROM peers WHERE torrent=$torrentid AND passkey=" . sqlesc($passkey)));
if ($valid[0] >= 3 && $seeder == 'no')
err("Connection limit exceeded...");
if ($valid[0] >= 5 && $seeder == 'yes')
err("Connection limit exceeded...");
}
$res = SQL_Query_exec("SELECT $peerfields FROM peers WHERE $selfwhere");
$row = mysqli_fetch_assoc($res);
if ($row){
$self = $row;
}
}
// END $SELF FILL
if (!isset($self)){ //IF PEER IS NOT IN PEERS TABLE DO THE WAIT TIME CHECK
if ($MEMBERSONLY_WAIT && $MEMBERSONLY){
//wait time check
if($left > 0 && in_array($user["class"], explode(",",$site_config["WAIT_CLASS"]))){ //check only leechers and lowest user class
$gigs = $user["uploaded"] / (1024*1024*1024);
$elapsed = floor((gmtime() - $torrent["ts"]) / 3600);
$ratio = (($user["downloaded"] > 0) ? ($user["uploaded"] / $user["downloaded"]) : 1);
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;
if ($elapsed < $wait)
err("Wait Time (" . ($wait - $elapsed) . " hours) - Visit ".$site_config["SITEURL"]." for more info");
}
}
$sockres = @fsockopen($ip, $port, $errno, $errstr, 5);
if (!$sockres)
$connectable = "no";
else
$connectable = "yes";
@fclose($sockres);
}else{
$upthis = max(0, $uploaded - $self["uploaded"]);
$downthis = max(0, $downloaded - $self["downloaded"]);
if (($upthis > 0 || $downthis > 0) && is_valid_id($userid)){ // LIVE STATS!)
if ($torrent["freeleech"] == 1){
SQL_Query_exec("UPDATE users SET uploaded = uploaded + $upthis WHERE id=$userid") or err("Tracker error: Unable to update stats");
}else{
SQL_Query_exec("UPDATE users SET uploaded = uploaded + $upthis, downloaded = downloaded + $downthis WHERE id=$userid") or err("Tracker error: Unable to update stats");
}
}
}//END WAIT AND STATS UPDATE
$updateset = array();
////////////////// NOW WE DO THE TRACKER EVENT UPDATES ///////////////////
if ($event == "stopped") { // UPDATE "STOPPED" EVENT
SQL_Query_exec("DELETE FROM peers WHERE $selfwhere");
if (mysqli_affected_rows($GLOBALS["DBconnector"])){
if ($self["seeder"] == "yes")
$updateset[] = "seeders = (CASE WHEN (seeders < 1) THEN 0 ELSE (seeders - 1) END)";
else
$updateset[] = "leechers = (CASE WHEN (leechers < 1) THEN 0 ELSE (leechers - 1) END)";
}
}
// UPDATE "COMPLETED" EVENT
if ($event == "completed")
{
$updateset[] = "times_completed = times_completed + 1";
if ( $MEMBERSONLY )
{
SQL_Query_exec("INSERT INTO completed (userid, torrentid, date) VALUES ($userid, $torrentid, '".get_date_time()."')");
SQL_Query_exec("UPDATE LOW_PRIORITY `snatched` SET `completed` = '1' WHERE `tid` = '$torrentid' AND `uid` = '$userid'");
}
}
if (isset($self))
{
SQL_Query_exec("UPDATE peers SET ip = " . sqlesc($ip) . ", passkey = " . sqlesc($passkey) . ", port = $port, uploaded = $uploaded, downloaded = $downloaded, to_go = $left, last_action = '".get_date_time()."', client = " . sqlesc($agent) . ", seeder = '$seeder' WHERE $selfwhere");
if (mysqli_affected_rows($GLOBALS["DBconnector"]) && $self["seeder"] != $seeder)
{
if ($seeder == "yes")
{
$updateset[] = "seeders = seeders + 1";
$updateset[] = "leechers = (CASE WHEN (leechers < 1) THEN 0 ELSE (leechers - 1) END)";
}
else
{
$updateset[] = "seeders = (CASE WHEN (seeders < 1) THEN 0 ELSE (seeders - 1) END)";
$updateset[] = "leechers = leechers + 1";
}
}
}
else
{
$ret = SQL_Query_exec("INSERT INTO peers (connectable, torrent, peer_id, ip, passkey, port, uploaded, downloaded, to_go, started, last_action, seeder, userid, client) VALUES ('$connectable', $torrentid, " . sqlesc($peer_id) . ", " . sqlesc($ip) . ", " . sqlesc($passkey) . ", $port, $uploaded, $downloaded, $left, '".get_date_time()."', '".get_date_time()."', '$seeder', '$userid', " . sqlesc($agent) . ")");
if ( $MEMBERSONLY && $seeder == 'no' )
{
SQL_Query_exec("INSERT INTO `snatched` (`uid`, `tid`, `stime`, `utime`) VALUES ('$userid', '$torrentid', '".gmtime()."', '".gmtime()."') ON DUPLICATE KEY UPDATE `utime` = '" . gmtime() . "'");
}
if ($ret)
{
if ($seeder == "yes")
$updateset[] = "seeders = seeders + 1";
else
$updateset[] = "leechers = leechers + 1";
}
}
////////////////// END TRACKER EVENT UPDATES ///////////////////
// SEEDED, LETS MAKE IT VISIBLE THEN
if ($seeder == "yes") {
if ($torrent["banned"] != "yes") // DONT MAKE BANNED ONES VISIBLE
$updateset[] = "visible = 'yes'";
$updateset[] = "last_action = '".get_date_time()."'";
}
// NOW WE UPDATE THE TORRENT AS PER ABOVE
if (count($updateset))
SQL_Query_exec("UPDATE torrents SET " . join(",", $updateset) . " WHERE id=$torrentid") or err("Tracker error: Unable to update torrent");
// NOW BENC THE DATA AND SEND TO CLIENT???
benc_resp_raw($resp);
mysqli_close($GLOBALS["DBconnector"]);
?>
ALTER TABLE users ADD `seedbonus` decimal(10,1) NOT NULL;<?php
if (!$CURUSER) {
begin_block(T_("LOGIN"));
?>
<form method="post" action="account-login.php">
<table border="0" width="100%" cellspacing="0" cellpadding="0">
<tr><td>
<table border="0" cellpadding="1" align="center">
<tr>
<td align="center"><font face="verdana" size="1"><b><?php echo T_("USERNAME"); ?>:</b></font></td>
</tr><tr>
<td align="center"><input type="text" size="12" name="username" /></td>
</tr><tr>
<td align="center"><font face="verdana" size="1"><b><?php echo T_("PASSWORD"); ?>:</b></font></td>
</tr><tr>
<td align="center"><input type="password" size="12" name="password" /></td>
</tr><tr>
<td align="center"><input type="submit" value="<?php echo T_("LOGIN"); ?>" /></td>
</tr>
</table>
</td>
</tr>
<tr>
<td align="center">[<a href="account-signup.php"><?php echo T_("SIGNUP");?></a>]<br />[<a href="account-recover.php"><?php echo T_("RECOVER_ACCOUNT");?></a>]</td> </tr>
</table>
</form>
<?php
end_block();
} else {
begin_block($CURUSER["username"]);
$avatar = htmlspecialchars($CURUSER["avatar"]);
if (!$avatar)
$avatar = $site_config["SITEURL"]."/images/default_avatar.png";
$userdownloaded = mksize($CURUSER["downloaded"]);
$useruploaded = mksize($CURUSER["uploaded"]);
$privacylevel = T_($CURUSER["privacy"]);
$bonus = $CURUSER['seedbonus'];
if ($CURUSER["uploaded"] > 0 && $CURUSER["downloaded"] == 0)
$userratio = "Inf.";
elseif ($CURUSER["downloaded"] > 0)
$userratio = number_format($CURUSER["uploaded"] / $CURUSER["downloaded"], 2);
else
$userratio = "---";
print ("<center><img width='80' height='80' src='$avatar' alt='' /></center><br />" . T_("DOWNLOADED") . ": $userdownloaded<br />" . T_("UPLOADED") . ": $useruploaded<br />".T_("CLASS").": ".T_($CURUSER["level"])."<br />" . T_("ACCOUNT_PRIVACY_LVL") . ": $privacylevel<br />". T_("RATIO") .": $userratio<br>Seedbonus : <b><a href=mybonus.php>".$bonus."</a></b>");
?>
<center><a href="account.php"><?php echo T_("ACCOUNT"); ?></a> <br />
<?php if ($CURUSER["control_panel"]=="yes") {print("<a href=\"admincp.php\">".T_("STAFFCP")."</a>");}?>
</center>
<?php
end_block();
}
?> echo "<div align='right' style='float: right'><a href=javascript:Reply_code('".$row['user'].":','shoutboxform','message') style=font-size: 8px>[R]</a><div>";echo "<div align='left' style='float: left'><a href=javascript:Reply_code('".$row['user'].":','shoutboxform','message') style=font-size: 8px><img src='images/reply.png'</a><div>";