'; $q = mysql_query('EXPLAIN '.$sql); $i=0; $debug_output .= $sql.'
'.drawtable($q); } $num_q++; return $r; } function drawtable($qr) { // $qr = results of a mysql_query $rows = mysql_num_rows($qr); $toreturn = "\n"; $toreturn .= "\n"; for ($i=0; $i\n"; } $toreturn .= "\n"; for ($i=0; $i<$rows; $i++) { $row = mysql_fetch_row($qr); $cols = sizeof($row); $toreturn .= "\n"; for ($x=0; $x < $cols; $x++) { if ($row[$x]==NULL){ $row[$x]=' '; } $toreturn .= "\t\n"; } $toreturn .= "\n"; } $toreturn .= '
$row[$x]


'; return $toreturn; } function local_user() { global $_SERVER; return $_SERVER["SERVER_ADDR"] == $_SERVER["REMOTE_ADDR"]; } /**** validip/getip courtesy of manolete ****/ // 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; } 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']; } function dbconn($autoclean = true) { global $mysql_host, $mysql_user, $mysql_pass, $mysql_db; if (!@mysql_connect($mysql_host, $mysql_user, $mysql_pass)) { switch (mysql_errno()) { case 1040: case 2002: if ($_SERVER[REQUEST_METHOD] == "GET") die("

The server load is very high at the moment. Retrying, please wait...

"); else die("Too many users. Please press the Refresh button in your browser to retry."); default: die("[" . mysql_errno() . "] dbconn: mysql_connect: " . mysql_error()); } } if( $GLOBALS['settings']['mysql_41'] ) mysql_query("SET time_zone = '+00:00'"); 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); //Just use .htaccess for banning...well that's what i prefer so that's why it can be disabled ;) if($GLOBALS['settings']['mod_bans']) { $res_sql = sprintf('SELECT * FROM bans WHERE %u >= first AND %u <= last ', $nip, $nip); $res = do_mysql_query($res_sql) or sqlerr(__FILE__, __LINE__); if (mysql_num_rows($res) > 0) { header("HTTP/1.0 403 Forbidden"); print("

403 Forbidden

Unauthorized.\n"); die; } } if (!$SITE_ONLINE || empty($_COOKIE["uid"]) || empty($_COOKIE["pass"])) return; $id = (int) $_COOKIE["uid"]; if (!$id || !preg_match('/[a-f0-9]{32}/', $_COOKIE["pass"]) ) return; $res = do_mysql_query("SELECT acceptpms, age, anonymous, avatar, avatars, class, country, deletepms, donated, donor, downloaded, email, gender, id, info, invites, language, last_browse, logintype, maxtorrents, menubar, notifs, override_class, parked, passhash, passkey, postsperpage, privacy, savepms, showemail, showsig, showwebsite, sidebar, signatureinfo, stylesheet, toolbar, topicsperpage, torrentsperpage, uploaded, username, warned, website, IF( users.downloaded > 0, ROUND(users.uploaded / users.downloaded, 3), '---') as ratio, IF( users.donor = 'yes', '\"donor\"', '' ) as donor_img, IF( users.warned = 'yes', '\"Warned\"', '' ) as warned_img, UNIX_TIMESTAMP() - UNIX_TIMESTAMP(users.last_access) as time_last_online, UNIX_TIMESTAMP() - last_browse as time_last_browse FROM users WHERE id = ".$id." AND enabled='yes' AND status = 'confirmed'") or die(mysql_error()); $row = mysql_fetch_assoc($res); if (!$row) return; $sec = hash_pad($row["secret"]); if ($_COOKIE["pass"] !== $row["passhash"]) return; if ((md5($ip.$_COOKIE['pass']) !== $row['loginhash'] && !$row['logintype'] == "secure") || $_COOKIE['pass'] !== $row['passhash']) return; if( $row['time_last_online'] > 60 ) { do_mysql_query("UPDATE users SET last_access=NOW(), ip='".$ip."' WHERE id=" . $row["id"]); } $row['ip'] = $ip; if ($row['override_class'] < $row['class']) $row['class'] = $row['override_class']; $GLOBALS["CURUSER"] = $row; // I18N support information here $language = isset($GLOBALS['CURUSER']['language']) ? $GLOBALS['CURUSER']['language'] :'en'; putenv("LANG=".$language); setlocale(LC_ALL, $language); // Set the text domain as 'messages' $domain = 'messages'; bindtextdomain($domain, $GLOBALS['LOCALE_PATH']); textdomain($domain); } function autoclean() { global $autoclean_interval; $now = time(); $docleanup = 0; $res = do_mysql_query("SELECT value_u FROM avps WHERE arg = 'lastcleantime'"); $row = mysql_fetch_array($res); if (!$row) { do_mysql_query("INSERT INTO avps (arg, value_u) VALUES ('lastcleantime',$now)"); return; } $ts = $row[0]; if ($ts + $autoclean_interval > $now) return; do_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"; else return number_format($bytes / 1099511627776, 2) . " TB"; } function mksizeint($bytes) { $bytes = max(0, $bytes); if ($bytes < 1000) return floor($bytes) . " B"; elseif ($bytes < 1000 * 1024) return floor($bytes / 1024) . " kB"; elseif ($bytes < 1000 * 1048576) return floor($bytes / 1048576) . " MB"; elseif ($bytes < 1000 * 1073741824) return floor($bytes / 1073741824) . " GB"; else return floor($bytes / 1099511627776) . " TB"; } function deadtime() { global $announce_interval; return time() - floor($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", "
\n", $a); } print("$x$a\n"); } function validfilename($name) { return preg_match('/^[^\0-\x1f:\\\\\/?*\xff#<>|]+$/si', $name); } function validemail($email) { $qtext = '[^\\x0d\\x22\\x5c\\x80-\\xff]'; $dtext = '[^\\x0d\\x5b-\\x5d\\x80-\\xff]'; $atom = '[^\\x00-\\x20\\x22\\x28\\x29\\x2c\\x2e\\x3a-\\x3c'. '\\x3e\\x40\\x5b-\\x5d\\x7f-\\xff]+'; $quoted_pair = '\\x5c\\x00-\\x7f'; $domain_literal = "\\x5b($dtext|$quoted_pair)*\\x5d"; $quoted_string = "\\x22($qtext|$quoted_pair)*\\x22"; $domain_ref = $atom; $sub_domain = "($domain_ref|$domain_literal)"; $word = "($atom|$quoted_string)"; $domain = "$sub_domain(\\x2e$sub_domain)*"; $local_part = "$word(\\x2e$word)*"; $addr_spec = "$local_part\\x40$domain"; return preg_match("!^$addr_spec$!", $email) ? true : false; } function is_valid_type($type) { $valid_types = array('cat_name', 'name', 'numfiles', 'comments', 'rating', 'added', 'size', 'times_completed', 'seeders', 'leechers', 'username'); return in_array($type, $valid_types); } function is_valid_sort($sort) { if($sort == 'ASC' || $sort == 'DESC') return true; return false; } 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 "$t"; return "$t"; } function parsedescr($d, $html) { if (!$html) { $d = htmlspecialchars($d); $d = str_replace("\n", "\n
", $d); } return $d; } function stdhead($title = "", $msgalert = true) { global $CURUSER, $SITE_ONLINE, $FUNDS, $SITENAME; if (!$SITE_ONLINE) die("Site is down for maintenance, please check back again later... thanks
"); header("Content-Type: text/html; charset=iso-8859-1"); //header("Pragma: No-cache"); if ($title == "") $title = $SITENAME; else $title = "$SITENAME :: " . htmlspecialchars($title); if ($CURUSER) { $ss_a = @mysql_fetch_array(@do_mysql_query("select uri from stylesheets where id=" . $CURUSER["stylesheet"])); if ($ss_a) $ss_uri = $ss_a["uri"]; } if (!$ss_uri) { ($r = do_mysql_query("SELECT uri FROM stylesheets WHERE id=1")) or die(mysql_error()); ($a = mysql_fetch_array($r)) or die(mysql_error()); $ss_uri = $a["uri"]; } if ($msgalert && $CURUSER) { $res = do_mysql_query("SELECT COUNT(*) FROM messages WHERE receiver=" . $CURUSER["id"] . " && unread='yes'") or die("OopppsY!"); $arr = mysql_fetch_row($res); $unread = (int) $arr[0]; } ///////////////////for spacer///////////////////////// if (!$CURUSER || $CURUSER['toolbar'] == "yes") $size = "900px"; elseif ($CURUSER['toolbar'] == "no") $size = "700px"; ?> <?= $title ?> \n"); print("\n"); print("\n"); print("\n"); end_table(); } end_frame(); end_main_frame(); } function searchfield($s) { return preg_replace(array('/[^a-z0-9]/si', '/^\s*/s', '/\s*$/s', '/\s+/s'), array(" ", "", "", " "), $s); } function genrelist() { global $cache_lite; $ret = array(); if(!$GLOBALS['settings']['cache'] || !($ret = unserialize( $cache_lite->get('category_list')) ) ) { $res = do_mysql_query("SELECT id, name FROM categories ORDER BY name"); while ($row = mysql_fetch_assoc($res)) $ret[] = $row; $cache_lite->setLifeTime($GLOBALS['config']['cache_categories']); $cache_lite->save( serialize($ret) , 'category_list'); } return $ret; } function linkcolor($num) { if (!$num) return "red"; // if ($num == 1) // return "yellow"; return "green"; } function ratingpic($num) { $r = round($num * 2) / 2; if ($r < 1 || $r > 5) return; return "\"rating:"; } function torrenttable($records, $href, $variant = "index") { global $CURUSER; /*if ($CURUSER["class"] < UC_VIP) { $gigs = $CURUSER["uploaded"] / (1024*1024*1024); $ratio = (($CURUSER["downloaded"] > 0) ? ($CURUSER["uploaded"] / $CURUSER["downloaded"]) : 0); if ($ratio < 0.5 || $gigs < 5) $wait = 0; elseif ($ratio < 0.65 || $gigs < 6.5) $wait = 0; elseif ($ratio < 0.8 || $gigs < 8) $wait = 0; elseif ($ratio < 0.95 || $gigs < 9.5) $wait = 0; else $wait = 0; }*/ $sort[1] = '&d=ASC'; $sort[2] = '&d=ASC'; $sort[3] = '&d=DESC'; $sort[4] = '&d=DESC'; $sort[5] = '&d=DESC'; $sort[6] = '&d=DESC'; $sort[7] = '&d=DESC'; $sort[8] = '&d=DESC'; $sort[9] = '&d=DESC'; $sort[10] = '&d=DESC'; $sort[11] = '&d=DESC'; $sort[12] = '&d=ASC'; if(isset($_GET["sort"])) { $h = $_GET['h']; $order = $_GET['d']; $type= $_GET['sort']; if($order == 'ASC') $sort[$h]='&d=DESC'; else $sort[$h]='&d=ASC'; } ?> Wait\n"); } if ($variant == "mytorrents") { print("\n"); print("\n"); } ?> "; $time_now = gmtime(); //if ($last_browse > $time_now) { //$last_browse=$time_now; //} //if ($variant == "index" && get_user_class() >= UC_POWER_USER) print("\n"); print("\n"); foreach ($records as $row) { $id = $row["id"]; print("\n"); print("\n"); $dispname = htmlspecialchars($row["name"]); if($GLOBALS['settings']['mod_cutnames']) { $dispname = (strlen($dispname) > $GLOBALS['settings']['mod_cutnames_maxlength']) ? substr($dispname, 0, $GLOBALS['settings']['mod_cutnames_maxlength']).'...' : $dispname; } print("\n"); } else print("\n"); } /* if ($row["nfoav"] && get_user_class() >= UC_POWER_USER) print("View NFO\n"); if ($variant == "index") print("Download\n"); else */ if ($variant == "mytorrents") print("\n"); if ($variant == "mytorrents") { print("\n"); } if ($row["type"] == "single") print("\n"); else { if ($variant == "index") print("\n"); else print("\n"); } if (!$row["comments"]) print("\n"); else { if ($variant == "index") print("\n"); else print("\n"); } /*print("\n");*/ $timezone = $row['added']; print("\n"); //$ttl = floor((gmtime() - $row["utadded"]) / 3600); $ttl = $row['time_alive']; if ($ttl == 1) $ttl .= "
hour"; else $ttl .= "
hours"; print("\n"); if( $GLOBALS['settings']['mod_progressbar'] ) { // Progressbar Mod $seedersProgressbar = array(); $leechersProgressbar = array(); $resProgressbar = do_mysql_query("SELECT p.seeder, p.to_go, t.size FROM torrents AS t LEFT JOIN peers AS p ON t.id = p.torrent WHERE p.torrent = '$id'") or sqlerr(); $progressPerTorrent = 0; $iProgressbar = 0; while ($rowProgressbar = mysql_fetch_array($resProgressbar)) { $progressPerTorrent += sprintf("%.2f", 100 * (1 - ($rowProgressbar["to_go"] / $rowProgressbar["size"]))); $iProgressbar++; } if ($iProgressbar == 0) $iProgressbar = 1; $progressTotal = sprintf("%.2f", $progressPerTorrent / $iProgressbar); $picProgress = get_percent_completed_image(floor($progressTotal))." (".round($progressTotal)."%)"; print("\n"); // End Progress Bar modrogress Bar mod } print("\n"); // print("\n"); // print("\n"); $_s = ""; if ($row["times_completed"] != 1) $_s = "s"; print("\n"); if ($row["seeders"]) { if ($variant == "index") { if (get_user_class() >= UC_POWER_USER) { if ($row["leechers"]) $ratio = $row["seeders"] / $row["leechers"]; else $ratio = 1; print("\n"); } else print("\n"); } else { if (get_user_class() >= UC_POWER_USER) print("\n"); else print("\n"); } } else print("\n"); if ($row["leechers"]) { if ($variant == "index") { if (get_user_class() >= UC_POWER_USER) { print("\n"); } else print("\n"); } else { if (get_user_class() >= UC_POWER_USER) { print("\n"); } else print("\n"); } } else print("\n"); //if ($variant == "index" && get_user_class() >= UC_POWER_USER) //print("\n"); if($row["anonymous"] == "yes" AND get_user_class() < UC_MODERATOR AND $CURUSER["id"] != $row["owner"]){ $row["owner"] = ""; $row["username"] = "Anonymous"; } else $row["owner"] = ""; print("\n"); print("\n"); } print("
Type Name EditVisibleFiles Comm. Added Time Alive Average Progress Size Snatched Seeders Leechers Upped by
"); if (isset($row["cat_name"])) { print(""); if (isset($row["cat_pic"]) && $row["cat_pic"] != "") print("\"""); else print($row["cat_name"]); print(""); } else print("-"); print("= $last_browse) { print("\">$dispname (NEW)$download"); echo '
'.$row['description'].''; } else { print("\">$dispname$download"); echo '
'.$row['description'].''; } if ($wait) { $elapsed = floor((gmtime() - $row["utadded"]) / 3600); if ($elapsed < $wait) { $color = dechex(floor(127*($wait - $elapsed)/48 + 128)*65536); print("
" . number_format($wait - $elapsed) . " hNoneedit\n"); print(""); if ($row["visible"] == "no") print("no"); else print("yes"); print("" . $row["numfiles"] . "" . $row["numfiles"] . "" . $row["numfiles"] . "" . $row["comments"] . "" . $row["comments"] . "" . $row["comments"] . ""); if (!isset($row["rating"])) print("---"); else { $rating = round($row["rating"] * 2) / 2; $rating = ratingpic($row["rating"]); if (!isset($rating)) print("---"); else print($rating); } print("" . str_replace(" ", "
", $timezone) . "
$ttl$picProgress" . str_replace(" ", "
", mksize($row["size"])) . "
" . $row["views"] . "" . $row["hits"] . "" . number_format($row["times_completed"]) . "
time$_s
" . $row["seeders"] . "" . $row["seeders"] . "" . $row["seeders"] . "" . $row["seeders"] . "" . $row["seeders"] . "" . number_format($row["leechers"]) . ($peerlink ? "" : "") . "" . number_format($row["leechers"]) . ($peerlink ? "" : "") . "" . $row["leechers"] . "" . $row["leechers"] . "0" . (isset($row["username"]) && ($row['anonymous'] == 'no') && (get_user_class() >= UC_MODERATOR) ? ("" . htmlspecialchars($row["username"]) . "") : "Anonymous") . "" . ( isset($row["username"]) ? ("" . $row["owner"] . "" . htmlspecialchars($row["username"]). "") : "unknown") . "
\n"); return $rows; } function hit_start() { return; } function hit_count() { return; } function hit_end() { return; } 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.gif"; $warnedpic = "warnedbig.gif"; $disabledpic = "disabledbig.gif"; $style = "style='margin-left: 4pt'"; } else { $donorpic = "star.gif"; $warnedpic = "warned.gif"; $disabledpic = "disabled.gif"; $style = "style=\"margin-left: 2pt\""; } $pics = $arr["donor"] == "yes" ? "Donor" : ""; if ($arr["enabled"] == "yes") $pics .= $arr["warned"] == "yes" ? "\"Warned\"" : ""; else $pics .= "\"Disabled\"\n"; return $pics; } function parked() { global $CURUSER; if ($CURUSER["parked"] == "yes") stderr( _("Error"), _("your account is parked.") ); } function get_percent_completed_image($p) { $img = "progress-"; if ($p == 100) $img .= "5"; elseif (($p >= 0) && ($p <= 10)) $img .= "0"; elseif (($p >= 11) && ($p <= 40)) $img .= "1"; elseif (($p >= 41) && ($p <= 60)) $img .= "2"; elseif (($p >= 61) && ($p <= 80)) $img .= "3"; elseif (($p >= 81) && ($p <= 99)) $img .= "4"; return ""; } function srt($a,$b) { if ($a[0] > $b[0]) return -1; if ($a[0] < $b[0]) return 1; return 0; } ////// DoStaff function start /////////////////////////////// function DoStaff($staff, $staffclass, $cols = 2) { if($staff===false) { echo '
'.$staffclass.'                          
None defined yet
'; return; } $counter = count($staff); $rows = ceil($counter/$cols); $cols = ($counter < $cols) ? $counter : $cols; $r = 0; echo '
'; for($ia = 0; $ia < $rows; $ia++){ echo ""; for($i = 0; $i < $cols; $i++){ if( isset($staff[$r]) ) { echo ''; $r++; } else { echo ''; } //End for $i } echo ''; //End for $ia } print("
'.$staffclass.'                          
'.$staff[$r]['username'].' '.$staff[$r]['country'].'   
"); } ////// DoStaff function end /////////////////////////////// function get_categories() { global $cache_lite; if(!$GLOBALS['settings']['cache'] || (!$categories = unserialize( $cache_lite->get('get_categories') ))) { $sql = 'SELECT id,name FROM categories ORDER BY name'; $sql_run = do_mysql_query($sql); $categories = array(); while($inf = mysql_fetch_assoc($sql_run)) { $categories[ $inf['id'] ] = $inf['name']; } $cache_lite->setLifeTime($GLOBALS['config']['cache_categories']); $cache_lite->save( serialize($categories) , 'get_categories'); } return $categories; } function implode_type_check($glue,$arr,$type) { $str = ''; foreach ($arr as $val) { settype($val, $type); if( $type == 'string' ) mysql_escape_string($val); $str .= $val.$glue; } return substr($str, 0, -1); } require "global.php"; ?>