PHP Code:
<?php
# IMPORTANT: Do not edit below unless you know what you are doing!
if(!defined('IN_TRACKER'))
die('Hacking attempt!');
include_once($rootpath . 'include/config.php');
require_once($rootpath . 'include/cleanup.php');
include($rootpath . 'include/globalfunctions.php');
//---------------------------------
//---- Max. Sysops v0.2 by xam
//---------------------------------
function maxsysop () {
global $CURUSER;
// Check Staff Names
$lmaxclass = 7;
$lsysopnames = array("tunad", "admin"); // Case sensitive. Change this (YOUR SYSOP-ADMIN NAMES GOES HERE) (example: array("adminname1","adminname2","adminname3","adminname4","so far")
if ($CURUSER["class"] >= $lmaxclass)
if (!in_array($CURUSER["username"], $lsysopnames, true)) { // true for strict comparison
$msg = "Fake Account Detected: Username: ".$CURUSER["username"]." - UserID: ".$CURUSER["id"]." - UserIP : ".getip();
write_log($msg);
stderr("Access Denied!","We come to believe you are using a fake account, therefore we've logged this action!");
}
// Check Staff IDS
define ('UC_STAFF', 4); // Minumum Staff Level (4= UC_MODERATOR)
if ($CURUSER['class'] >= UC_STAFF) {
$allowed_ID = array(1,2); // Change this (YOUR SYSOP-ADMIN IDS GOES HERE) (example: array(1,2,3,4,5))
if (!in_array((int)$CURUSER['id'], $allowed_ID, true)) { // true for strict comparison
$msg = "Fake Account Detected: Username: ".$CURUSER["username"]." - UserID: ".$CURUSER["id"]." - UserIP : ".getip();
write_log($msg);
stderr("Access Denied!","We come to believe you are using a fake account, therefore we've logged this action!");
}
}
}
//---------------------------------
//---- Max. Sysops v0.2 by xam
//---------------------------------
function strip_magic_quotes($arr)
{
foreach ($arr as $k => $v)
{
if (is_array($v))
{ $arr[$k] = strip_magic_quotes($v); }
else
{ $arr[$k] = stripslashes($v); }
}
return $arr;
}
function htmlspecialchars_uni($text, $entities = true)
{
return str_replace(
// replace special html characters
array('<', '>', '"'),
array('<', '>', '"'),
preg_replace(
// translates all non-unicode entities
'/&(?!' . ($entities ? '#[0-9]+' : '(#[0-9]+|[a-z]+)') . ';)/si',
'&',
$text
)
);
}
function xss_clean(&$var)
{
static
$preg_find = array('#javascript#i', '#vbscript#i'),
$preg_replace = array('java script', 'vb script');
$var = preg_replace($preg_find, $preg_replace, htmlspecialchars_uni($var));
return $var;
}
function local_user()
{
return $_SERVER["SERVER_ADDR"] == $_SERVER["REMOTE_ADDR"];
}
function cur_user_check () {
global $CURUSER;
if ($CURUSER)
stderr ("Permission denied!", "You are already logged in!");
}
function sql_query($query)
{
$_SESSION['queries']++;
return mysql_query($query);
}
function KPS($type = "+", $point = "1.0", $id = "") {
global $bonus;
if ($bonus == "enable" OR $bonus == "disablesave")
sql_query("UPDATE users SET seedbonus = seedbonus$type$point WHERE id = " .sqlesc($id)) or sqlerr(__FILE__, __LINE__);
else
return;
}
//---------------------------------
//---- BANNED EMAILS v0.1 by xam
//---------------------------------
function EmailBanned($newEmail)
{
$newEmail = trim(strtolower($newEmail));
$sql = mysql_query("SELECT * FROM bannedemails") or sqlerr(__FILE__, __LINE__);
$list = mysql_fetch_array($sql);
$addresses = explode(' ', preg_replace("/[[:space:]]+/", " ", trim($list[value])) );
if(count($addresses) > 0)
{
foreach ( $addresses as $email )
{
$email = trim(strtolower(ereg_replace('\.', '\\.', $email)));
if(strstr($email, "@"))
{
if(ereg('^@', $email))
{ // Any user @host?
// Expand the match expression to catch hosts and
// sub-domains
$email = ereg_replace('^@', '[@\\.]', $email);
if(ereg("$email$", $newEmail))
return true;
}
}
elseif(ereg('@$', $email))
{ // User at any host?
if(ereg("^$email", $newEmail))
return true;
}
else
{ // User@host
if(strtolower($email) == $newEmail)
return true;
}
}
}
return false;
}
//---------------------------------
//---- BANNED EMAILS v0.1 by xam
//---------------------------------
//---------------------------------
//---- Redirect MOD v0.1 by xam
//---------------------------------
function redirect($url)
{
if(!headers_sent())
header("Location : $url");
else
echo "<script language=\"JavaScript\">window.location.href = '$url';</script>";
exit;
}
//---------------------------------
//---- Redirect MOD v0.1 by xam
//---------------------------------
//---------------------------------
//---- CACHE MOD v0.1 by xam
//---------------------------------
function cache_check ($file = 'cachefile') {
global $rootpath,$cache;
$cachefile = $rootpath.$cache . '/'.$file.'.html';
$cachetime = 60 * 60; // 60 minutes
// Serve from the cache if it is younger than $cachetime
if (file_exists($cachefile) && (time() - $cachetime < filemtime($cachefile)))
{
include($cachefile);
print("<p align=center><font class=small>This page last updated ".date('Y-m-d H:i:s', filemtime($cachefile))."</font></p>");
end_main_frame();
stdfoot();
exit;
}
ob_start();
}
function cache_save ($file = 'cachefile') {
global $rootpath,$cache;
$cachefile = $rootpath.$cache . '/'.$file.'.html';
$fp = fopen($cachefile, 'w');
// save the contents of output buffer to the file
fwrite($fp, ob_get_contents());
// close the file
fclose($fp);
// Send the output to the browser
ob_end_flush();
}
//---------------------------------
//---- CACHE MOD v0.1 by xam
//---------------------------------
//---------------------------------
//---- Browser detection v0.1 by xam
//---------------------------------
function checkbrowser(){
unset($browser);
if ( strpos($_SERVER['HTTP_USER_AGENT'], 'Gecko') )
{
if ( strpos($_SERVER['HTTP_USER_AGENT'], 'Netscape') )
{
$browser = true;
}
else if ( strpos($_SERVER['HTTP_USER_AGENT'], 'Firefox') )
{
$browser = true;
}
else
{
$browser = true;
}
}else $browser = false;
if (!$browser)
Print ("<p class=codemain align=justify>If you enable cookies and are still unable to log in, perhaps something happened to cause a problem with your login cookie. We suggest delete your cookies and trying again. To delete cookies in Internet Explorer, go to Tools > Internet Options... and click on the Delete Cookies button. Note that this will delete all cookies stored on your system for other sites as well.</b></p>");
}
//---------------------------------
//---- Browser detection v0.1 by xam
//---------------------------------
//------------------------------------
//---- Secure Mail System v0.4 by xam
//------------------------------------
function safe_email($email) {
$email = str_replace("<","",$email);
$email = str_replace(">","",$email);
$email = str_replace("\'","",$email);
$email = str_replace('\"',"",$email);
$email = str_replace("\\\\","",$email);
return $email;
}
function check_email ($email) {
# Check EMail Function v.02 by xam!
if(ereg("^([A-Za-z0-9]+_+)|([A-Za-z0-9]+\-+)|([A-Za-z0-9]+\.+)|([A-Za-z0-9]+\++))*[A-Za-z0-9]+@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$", $email))
return true;
else
return false;
}
function sent_mail($to,$fromname,$fromemail,$subject,$body,$type = "confirmation",$showmsg=true,$multiple=false,$multiplemail='') {
global $rootpath,$SITENAME,$SITEEMAIL,$smtptype,$smtp,$smtp_host,$smtp_port,$smtp_from,$smtpaddress,$smtpport,$accountname,$accountpassword;
# Sent Mail Function v.05 by xam (This function to help avoid spam-filters.)
if ($smtptype == 'default') {
@mail($to, $subject, $body, "From: $SITEEMAIL", "-f$SITEEMAIL") or stderr("Error", "Unable to send mail. Please contact an administrator about this error.");
}elseif ($smtptype == 'advanced') {
# Is the OS Windows or Mac or Linux?
if (strtoupper(substr(PHP_OS,0,3)=='WIN')) {
$eol="\r\n";
$windows = true;
}
elseif (strtoupper(substr(PHP_OS,0,3)=='MAC'))
$eol="\r";
else
$eol="\n";
$mid = md5(getip() . $fromname);
$name = $_SERVER["SERVER_NAME"];
$headers .= "From: $fromname <$fromemail>".$eol;
$headers .= "Reply-To: $fromname <$fromemail>".$eol;
$headers .= "Return-Path: $fromname <$fromemail>".$eol;
$headers .= "Message-ID: <$mid thesystem@$name>".$eol;
$headers .= "X-Mailer: PHP v".phpversion().$eol;
$headers .= "MIME-Version: 1.0".$eol;
$headers .= "X-Sender: PHP".$eol;
if ($multiple)
$headers .= "Bcc: $multiplemail.$eol";
if ($smtp == "yes") {
ini_set('SMTP', $smtp_host);
ini_set('smtp_port', $smtp_port);
if ($windows)
ini_set('sendmail_from', $smtp_from);
}
@mail($to,$subject,$body,$headers) or stderr("Error", "Unable to send mail. Please contact an administrator about this error.");
ini_restore(SMTP);
ini_restore(smtp_port);
if ($windows)
ini_restore(sendmail_from);
}elseif ($smtptype == 'external') {
require ($rootpath . 'include/smtp/smtp.lib.php');
$mail = new smtp;
$mail->debug(false);
$mail->open($smtpaddress, $smtpport);
$mail->auth($accountname, $accountpassword);
$mail->from($SITEEMAIL);
$mail->to($to);
$mail->subject($subject);
$mail->body($body);
$mail->send();
$mail->close();
}
if ($showmsg) {
if ($type == "confirmation")
stderr("Success", "A confirmation email has been mailed to <b>". htmlspecialchars($to) ."</b>.\n" .
"Please allow a few minutes for the mail to arrive.",false);
else if ($type == "details")
stderr("Success", "The new account details have been mailed to <b>". htmlspecialchars($to) ."</b>.\n" .
"Please allow a few minutes for the mail to arrive.",false);
}else
return true;
}
//------------------------------------
//---- Secure Mail System v0.4 by xam
//------------------------------------
//---------------------------------
//---- Login Attempts v0.1 by xam
//---------------------------------
function failedloginscheck ($type = 'Login') {
global $maxloginattempts;
$total = 0;
$ip = sqlesc(getip());
$Query = mysql_query("SELECT SUM(attempts) FROM loginattempts WHERE ip=$ip") or sqlerr(__FILE__, __LINE__);
list($total) = mysql_fetch_array($Query);
if ($total >= $maxloginattempts) {
mysql_query("UPDATE loginattempts SET banned = 'yes' WHERE ip=$ip") or sqlerr(__FILE__, __LINE__);
stderr("$type Locked! (the maximum number of failed $type attempts is reached during reauthentication)", "We come to believe you are trying to cheat our system, therefore we've banned your ip!");
}
}
function failedlogins ($type = 'login', $recover = false, $head = true) {
$ip = sqlesc(getip());
$added = sqlesc(get_date_time());
$a = (@mysql_fetch_row(@mysql_query("select count(*) from loginattempts where ip=$ip"))) or sqlerr(__FILE__, __LINE__);
if ($a[0] == 0)
mysql_query("INSERT INTO loginattempts (ip, added, attempts) VALUES ($ip, $added, 1)") or sqlerr(__FILE__, __LINE__);
else
mysql_query("UPDATE loginattempts SET attempts = attempts + 1 where ip=$ip") or sqlerr(__FILE__, __LINE__);
if ($recover)
mysql_query("UPDATE loginattempts SET type = 'recover' WHERE ip = $ip") or sqlerr(__FILE__, __LINE__);
if ($type == 'silent')
return;
elseif ($type == 'login')
stderr("Login failed!","<b>Error</b>: Username or password incorrect!<br><br>Don't remember your password? <b><a href=recover.php>Recover</a></b> your password!",false);
else
stderr("Recover Failed",$type,false, $head);
}
function remaining ($type = 'login') {
global $maxloginattempts;
$total = 0;
$ip = sqlesc(getip());
$Query = mysql_query("SELECT SUM(attempts) FROM loginattempts WHERE ip=$ip") or sqlerr(__FILE__, __LINE__);
list($total) = mysql_fetch_array($Query);
$remaining = $maxloginattempts - $total;
if ($remaining <= 2 )
$remaining = "<font color=#666666 size=2>".$remaining."</font>";
else
$remaining = "<font color=#666666 size=2>".$remaining."</font>";
return $remaining;
}
//---------------------------------
//---- Login Attempts v0.1 by xam
//---------------------------------
//---------------------------------
//---- Signup Check v0.1 by xam
//---------------------------------
function registration_check($type = "invitesystem", $maxuserscheck = true, $ipcheck = true) {
global $invitesystem, $registration, $maxusers, $SITENAME, $maxip;
if ($type == "invitesystem") {
if ($invitesystem == "off") {
stderr("Sorry", "Invite System is currently disabled.");
}
}
if ($type == "normal") {
if ($registration == "off") {
stderr("Sorry", "Registration is currently disabled.");
}
}
if ($maxuserscheck) {
$res = mysql_query("SELECT COUNT(*) FROM users") or sqlerr(__FILE__, __LINE__);
$arr = mysql_fetch_row($res);
if ($arr[0] >= $maxusers)
stderr("Sorry", "The current user account limit has been reached. Inactive accounts are pruned all the time, please check back again later...");
}
if ($ipcheck) {
$ip = getip () ;
$a = (@mysql_fetch_row(@mysql_query("select count(*) from users where ip='" . mysql_real_escape_string($ip) . "'"))) or sqlerr(__FILE__, __LINE__);
if ($a[0] > $maxip)
stderr("Sorry", "The IP <b>" . htmlspecialchars($ip) . "</b> is Already being used on an account.... No Dupe accounts allowed at <b>$SITENAME</b>.",false);
}
}
//---------------------------------
//---- Signup Check v0.1 by xam
//---------------------------------
//-----------------------------------
//---- Image Verification v0.1 by xam
//-----------------------------------
function random_str($length="6")
{
$set = array("A","B","C","D","E","F","G","H","P","R","M","N","1","2","3","4","5","6","7","8","9");
$str;
for($i=1;$i<=$length;$i++)
{
$ch = rand(0, count($set)-1);
$str .= $set[$ch];
}
return $str;
}
function image_code () {
$randomstr = random_str();
$imagehash = md5($randomstr);
$dateline = time();
$sql = 'INSERT INTO `regimages` (`imagehash`, `imagestring`, `dateline`) VALUES (\''.$imagehash.'\', \''.$randomstr.'\', \''.$dateline.'\');';
mysql_query($sql) or die(mysql_error());
return $imagehash;
}
function check_code ($imagehash, $imagestring, $where = 'signup.php',$maxattemptlog=false,$head=true) {
$query = sprintf("SELECT * FROM regimages WHERE imagehash='%s' AND imagestring='%s'",
mysql_real_escape_string($imagehash),
mysql_real_escape_string($imagestring));
$sql = mysql_query($query);
$imgcheck = mysql_fetch_array($sql);
if(!$imgcheck['dateline']) {
$delete = sprintf("DELETE FROM regimages WHERE imagehash='%s'",
mysql_real_escape_string($imagehash));
mysql_query($delete);
if (!$maxattemptlog)
bark("Invalid Image Code! <br><b>Do not go back, The image code has been cleared!</b> <br><br>Please click <a href=".htmlspecialchars($where)."><b>here</b></a> to request a new image code.");
else
failedlogins("Invalid Image Code! <br><b>Do not go back, The image code has been cleared!</b> <br><br>Please click <a href=".htmlspecialchars($where)."><b>here</b></a> to request a new image code.",true,$head);
}else{
$delete = sprintf("DELETE FROM regimages WHERE imagehash='%s'",
mysql_real_escape_string($imagehash));
mysql_query($delete);
return true;
}
}
function show_image_code () {
global $iv;
unset($imagehash);
$imagehash = image_code () ;
if ($iv == "yes") {
print ("<tr><td class=\"style1\">Security Image:</td>");
Print ("<td><img src=\"image.php?action=regimage&imagehash=$imagehash\" border=\"0\"></a></td></tr>");
Print ("<tr><td class=\"style1\">Security Code:</td><td>");
Print("<input type=\"text\" size=\"26\" name=\"imagestring\" value=\"\" />");
Print("<input type=\"hidden\" name=\"imagehash\" value=\"$imagehash\" />");
}
}
//-----------------------------------
//---- Image Verification v0.1 by xam
//-----------------------------------
// IP Validation
function validip($ip)
{
if (!empty($ip) && $ip == long2ip(ip2long($ip)))
{
// 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 maxslots () {
global $CURUSER, $maxdlsystem;
$gigs = $CURUSER["uploaded"] / (1024*1024*1024);
$ratio = (($CURUSER["downloaded"] > 0) ? ($CURUSER["uploaded"] / $CURUSER["downloaded"]) : 1);
if ($ratio < 0.5 || $gigs < 5) $max = 1;
elseif ($ratio < 0.65 || $gigs < 6.5) $max = 2;
elseif ($ratio < 0.8 || $gigs < 8) $max = 3;
elseif ($ratio < 0.95 || $gigs < 9.5) $max = 4;
else $max = 0;
if ($maxdlsystem == "yes") {
if ($CURUSER["class"] < UC_VIP) {
if ($max > 0)
print ("<font color=#ffffff>Slots: </font><font color=lightblue><span class=smallfont>$max</span></font>");
else
print ("<font color=#ffffff>Slots: </font><font color=lightblue><span class=smallfont>Unlimited</span></font>");
}else
print ("<font color=#ffffff>Slots: </font><font color=lightblue><span class=smallfont>Unlimited</span></font>");
}else
print ("<font color=#ffffff>Slots: </font><font color=lightblue><span class=smallfont>Unlimited</span></font>");
}
function getip() {
if (isset($_SERVER)) {
if (isset($_SERVER['HTTP_X_FORWARDED_FOR']) && validip($_SERVER['HTTP_X_FORWARDED_FOR'])) {
$ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
} elseif (isset($_SERVER['HTTP_CLIENT_IP']) && validip($_SERVER['HTTP_CLIENT_IP'])) {
$ip = $_SERVER['HTTP_CLIENT_IP'];
} else {
$ip = $_SERVER['REMOTE_ADDR'];
}
} else {
if (getenv('HTTP_X_FORWARDED_FOR') && validip(getenv('HTTP_X_FORWARDED_FOR'))) {
$ip = getenv('HTTP_X_FORWARDED_FOR');
} elseif (getenv('HTTP_CLIENT_IP') && validip(getenv('HTTP_CLIENT_IP'))) {
$ip = getenv('HTTP_CLIENT_IP');
} else {
$ip = getenv('REMOTE_ADDR');
}
}
return $ip;
}
function dbconn($autoclean = false)
{
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("<html><head><meta http-equiv=refresh content=\"5 $_SERVER[REQUEST_URI]\"></head><body><table border=0 width=100% height=100%><tr><td><h3 align=center>The server load is very high at the moment. Retrying, please wait...</h3></td></tr></table></body></html>");
else
die("Too many users. Please press the Refresh button in your browser to retry.");
default:
die("[" . mysql_errno() . "] dbconn: mysql_connect: " . mysql_error());
}
}
mysql_select_db($mysql_db)
or die('dbconn: mysql_select_db: ' + mysql_error());
userlogin();
if ($autoclean)
register_shutdown_function("autoclean");
}
function userlogin() {
global $SITE_ONLINE, $iplog1;
unset($GLOBALS["CURUSER"]);
$ip = getip();
$nip = ip2long($ip);
$res = mysql_query("SELECT * FROM bans WHERE $nip >= first AND $nip <= last") or sqlerr(__FILE__, __LINE__);
if (mysql_num_rows($res) > 0)
{
header("HTTP/1.0 403 Forbidden");
print("<html><body><h1>403 Forbidden</h1>Unauthorized IP address.</body></html>\n");
die;
}
if (empty($_COOKIE["c_secure_pass"]) || empty($_COOKIE["c_secure_uid"]) || empty($_COOKIE["c_secure_login"]))
return;
if ($_COOKIE["c_secure_login"] == base64("yeah"))
if (empty($_SESSION["s_secure_uid"]) || empty($_SESSION["s_secure_pass"]))
return;
$b_id = base64($_COOKIE["c_secure_uid"],false);
$id = 0 + $b_id;
if (!$id || !is_valid_id($id) || strlen($_COOKIE["c_secure_pass"]) != 32)
return;
if ($_COOKIE["c_secure_login"] == base64("yeah"))
if (strlen($_SESSION["s_secure_pass"]) != 32)
return;
$res = mysql_query("SELECT users.*, NOW() as ctime FROM users WHERE id = ".mysql_real_escape_string($id)." AND enabled='yes' AND status = 'confirmed' LIMIT 1");
$row = mysql_fetch_array($res);
if (!$row)
return;
$sec = hash_pad($row["secret"]);
if ($_COOKIE["c_secure_pass"] !== md5($row["passhash"].$_SERVER["REMOTE_ADDR"]))
return;
if ($_COOKIE["c_secure_login"] == base64("yeah"))
if ($_SESSION["s_secure_pass"] !== md5($row["passhash"].$_SERVER["REMOTE_ADDR"]))
return;
if (!$row["passkey"]){
$passkey = md5($row['username'].get_date_time().$row['passhash']);
mysql_query("UPDATE users SET passkey = ".sqlesc($passkey)." WHERE id=" . mysql_real_escape_string($row["id"]));// or die(mysql_error());
}
if ($iplog1 == "yes") {
if (($ip != $row["ip"]) && $row["ip"])
mysql_query("INSERT INTO iplog (ip, userid, access) VALUES (" . sqlesc($row["ip"]) . ", " . $row["id"] . ", '" . $row["last_access"] . "')");
}
mysql_query("UPDATE users SET last_access='" . get_date_time() . "', ip=".sqlesc($ip)." WHERE id=" . mysql_real_escape_string($row["id"]));// or die(mysql_error());
$row['ip'] = $ip;
$GLOBALS["CURUSER"] = $row;
}
function autoclean() {
global $autoclean_interval;
$now = time();
$docleanup = 0;
$res = mysql_query("SELECT value_u FROM avps WHERE arg = 'lastcleantime'");
$row = mysql_fetch_array($res);
if (!$row) {
mysql_query("INSERT INTO avps (arg, value_u) VALUES ('lastcleantime',$now)");
return;
}
$ts = $row[0];
if ($ts + $autoclean_interval > $now)
return;
mysql_query("UPDATE avps SET value_u=$now WHERE arg='lastcleantime' AND value_u = $ts");
if (!mysql_affected_rows())
return;
docleanup();
}
function unesc($x) {
if (get_magic_quotes_gpc())
return stripslashes($x);
return $x;
}
function mksize($bytes)
{
if ($bytes < 1000 * 1024)
return number_format($bytes / 1024, 2) . " KB";
elseif ($bytes < 1000 * 1048576)
return number_format($bytes / 1048576, 2) . " MB";
elseif ($bytes < 1000 * 1073741824)
return number_format($bytes / 1073741824, 2) . " GB";
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,$relation='') {
if ($noesc)
$a = $y;
else {
$a = htmlspecialchars($y);
$a = str_replace("\n", "<br />\n", $a);
}
print("<tr".( $relation ? " relation = \"$relation\"" : "")."><td class=\"heading\" valign=\"top\" align=\"right\">$x</td><td valign=\"top\" align=left>$a</td></tr>\n");
}
function validfilename($name) {
return preg_match('/^[^\0-\x1f:\\\\\/?*\xff#<>|]+$/si', $name);
}
function validemail($email) {
return preg_match('/^[\w.-]+@([\w.-]+\.)+[a-z]{2,6}$/is', $email);
}
function sqlesc($value) {
// Stripslashes
if (get_magic_quotes_gpc()) {
$value = stripslashes($value);
}
// Quote if not a number or a numeric string
if (!is_numeric($value)) {
$value = "'" . mysql_real_escape_string($value) . "'";
}
return $value;
}
function sqlwildcardesc($x) {
return str_replace(array("%","_"), array("\\%","\\_"), mysql_real_escape_string($x));
}
function urlparse($m) {
$t = $m[0];
if (preg_match(',^\w+://,', $t))
return "<a href=\"$t\">$t</a>";
return "<a href=\"http://$t\">$t</a>";
}
function parsedescr($d, $html) {
if (!$html)
{
$d = htmlspecialchars($d);
$d = str_replace("\n", "\n<br>", $d);
}
return $d;
}
//-----------------------------------
//---- Where's User v0.1 by xam
//-----------------------------------
function where ($scriptname = "index", $userid) {
global $where;
if ($where == "yes") {
if (!is_valid_id($userid))
die;
if (preg_match("/details/i", $scriptname))
$where = "Browsing Torrents Details...";
elseif (preg_match("/browse/i", $scriptname))
$where = "Browsing Torrent Lists...";
elseif (preg_match("/userdetails/i", $scriptname))
$where = "Browsing Userdetails...";
elseif (preg_match("/upload/i", $scriptname))
$where = "Uploading Torrent..";
elseif (preg_match("/usercp/i", $scriptname))
$where = "Browsing User Control Panel...";
elseif (preg_match("/search/i", $scriptname))
$where = "Searching...";
elseif (preg_match("/forum/i", $scriptname))
$where = "Browsing Forums...";
elseif (preg_match("/index/i", $scriptname))
$where = "Browsing Homepage...";
else
$where = "Unknown Location...";
$query = sprintf("UPDATE users SET page=".sqlesc($where)." WHERE id ='%s'",
mysql_real_escape_string($userid));
$result = mysql_query($query);
if (!$result)
sqlerr(__FILE__,__LINE__);
else
return $where;
}
return;
}
//-----------------------------------
//---- Where's User v0.1 by xam
//-----------------------------------
//-----------------------------------
//---- Menu System v0.1 by xam
//-----------------------------------
function menu () {
global $BASEURL;
$script_name = $_SERVER["SCRIPT_FILENAME"];
print ("<div class=\"shadetabs\"><ul>");
print ("<li" . ($selected == "home" ? " class=selected" : "") . "><a href=\"index.php\" >Home</a></li>");
print ("<li" . ($selected == "browse" ? " class=selected" : "") . "><a href=\"browse.php\">Browse</a></li>");
print ("<li" . ($selected == "requests" ? " class=selected" : "") . "><a href=\"viewrequests.php\">Requests</a></li>");
print ("<li" . ($selected == "upload" ? " class=selected" : "") . "><a href=\"upload.php\">Upload</a></li>");
print ("<li" . ($selected == "usercp" ? " class=selected" : "") . "><a href=\"usercp.php\">User CP</a></li>");
print ("<li" . ($selected == "forums" ? " class=selected" : "") . "><a href=\"forums.php\">Forums</a></li>");
print ("<li" . ($selected == "topten" ? " class=selected" : "") . "><a href=\"topten.php\">Top 10</a></li>");
print ("<li" . ($selected == "rules" ? " class=selected" : "") . "><a href=\"rules.php\">Rules</a></li>");
print ("<li" . ($selected == "faq" ? " class=selected" : "") . "><a href=\"faq.php\">FAQ</a></li>");
print ("<li" . ($selected == "links" ? " class=selected" : "") . "><a href=\"links.php\">Links</a></li>");
print ("<li" . ($selected == "staff" ? " class=selected" : "") . "><a href=\"staff.php\">Staff</a></li>");
}
//-----------------------------------
//---- Menu System v0.1 by xam
//-----------------------------------
function stdhead($title = "", $msgalert = true, $script = "") {
global $CURUSER, $SITE_ONLINE, $FUNDS, $SITENAME,$SITEEMAIL,$BASEURL,$offlinemsg,$disablerightclick,$showversion,$autorefreshtime,$autorefresh,$leftmenu;
if ($SITE_ONLINE == "no") {
if (get_user_class() < UC_ADMINISTRATOR) {
die("Site is down for maintenance, please check back again later... thanks<br>");
}else{
$offlinemsg = true;
}
}
header("Content-Type: text/html; charset=iso-8859-1");
//header("Pragma: No-cache");
if ($title == "")
$title = $SITENAME.$showversion;
else
$title = "$SITENAME :: " . htmlspecialchars($title) . "$showversion";
if ($CURUSER)
{
$ss_a = @mysql_fetch_array(@mysql_query("select uri from stylesheets where id=" . $CURUSER["stylesheet"]));
if ($ss_a) $ss_uri = $ss_a["uri"];
}
if (!$ss_uri)
{
($r = 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 = mysql_query("SELECT COUNT(*) FROM messages WHERE receiver=" . $CURUSER["id"] . " && unread='yes'") or die("OopppsY!");
$arr = mysql_fetch_row($res);
$unread = $arr[0];
}
?>
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<?
if ($leftmenu == "yes") {
?>
<style type="text/css">
A.ssmItems:link {color:black;text-decoration:none;}
A.ssmItems:hover {color:black;text-decoration:none;}
A.ssmItems:active {color:black;text-decoration:none;}
A.ssmItems:visited {color:black;text-decoration:none;}
</style>
<SCRIPT SRC="ssm.js" language="JavaScript1.2">
</SCRIPT>
<SCRIPT LANGUAGE="Javascript">
YOffset=54; // no quotes!!
XOffset=0;
staticYOffset=10; // no quotes!!
slideSpeed=20 // no quotes!!
waitTime=100; // no quotes!! this sets the time the menu stays out for after the mouse goes off it.
menuBGColor="black";
menuIsStatic="yes"; //this sets whether menu should stay static on the screen
menuWidth=150; // Must be a multiple of 10! no quotes!!
menuCols=2;
hdrFontFamily="verdana";
hdrFontSize="1";
hdrFontColor="white";
hdrBGColor="#170088";
hdrAlign="left";
hdrVAlign="center";
hdrHeight="15";
linkFontFamily="Verdana";
linkFontSize="1";
linkBGColor="white";
linkOverBGColor="#FFFF99";
linkTarget="_top";
linkAlign="Left";
barBGColor="#444444";
barFontFamily="Verdana";
barFontSize="1";
barFontColor="white";
barVAlign="center";
barWidth=20; // no quotes!!
barText="<?=strtoupper($SITENAME);?>"; // <IMG> tag supported. Put exact html for an image to show.
<?
if ($CURUSER) {
?>
// ssmItems[...]=[name, link, target, colspan, endrow?] - leave 'link' and 'target' blank to make a header
ssmItems[0]=["Side Menu"] //create header
ssmItems[1]=["Home Page", "<?=$BASEURL;?>", ""]
ssmItems[2]=["Browse Torrents", "<?=$BASEURL;?>/browse.php",""]
ssmItems[3]=["Search Torrents/Posts", "<?=$BASEURL;?>/search.php", ""]
ssmItems[4]=["Upload Torrent", "<?=$BASEURL;?>/upload.php", "_new"]
ssmItems[5]=["User Control Panel", "<?=$BASEURL;?>/usercp.php", ""]
ssmItems[6]=["Forums", "<?=$BASEURL;?>/forums.php", ""]
ssmItems[7]=["TOP 10", "<?=$BASEURL;?>/topten.php", ""]
ssmItems[8]=["Rules", "<?=$BASEURL;?>/rules.php", ""]
ssmItems[9]=["FAQ", "<?=$BASEURL;?>/faq.php", ""]
ssmItems[10]=["Links Page", "<?=$BASEURL;?>/links.php", ""]
ssmItems[11]=["Staff Page", "<?=$BASEURL;?>/staff.php", ""]
ssmItems[12]=["Contact Staff", "<?=$BASEURL;?>/contactstaff.php", ""]
ssmItems[13]=["Extra Menu", "", ""] //create header
ssmItems[14]=["Invite Someone (<?=$CURUSER[invites];?>)", "<?=$BASEURL;?>/invite.php?id=<?=$CURUSER[id];?>", "", 2, "yes"] //create two column row
ssmItems[15]=["Bonus Points (<?=number_format($CURUSER['seedbonus'], 1)?>)", "<?=$BASEURL;?>/mybonus.php", "",2]
ssmItems[16]=["Private Messages", "<?=$BASEURL;?>/messages.php", "",2]
ssmItems[17]=["Friend List", "<?=$BASEURL;?>/friends.php", "",2]
ssmItems[18]=["User List", "<?=$BASEURL;?>/users.php", "",2]
<?}else{
?>
ssmItems[0]=["Side Menu"] //create header
ssmItems[1]=["Home Page", "<?=$BASEURL;?>", ""]
ssmItems[2]=["Login", "<?=$BASEURL;?>/login.php",""]
ssmItems[3]=["Register", "<?=$BASEURL;?>/signup.php", ""]
ssmItems[4]=["Recover Password", "", ""] //create header
ssmItems[5]=["Via EMAIL", "<?=$BASEURL;?>/recover.php", "", 1, "no"] //create two column row
ssmItems[6]=["Via Question", "<?=$BASEURL;?>/recoverhint.php", "",1]
ssmItems[7]=["Need Help?", "", ""] //create header
ssmItems[8]=["FAQ", "<?=$BASEURL;?>/faq.php", "", 1, "no"] //create two column row
ssmItems[9]=["Rules", "<?=$BASEURL;?>/rules.php", "",1]
<?
}
?>
buildMenu();
</SCRIPT>
<?
}
if ($autorefresh == "yes") {
?>
<SCRIPT LANGUAGE="Javascript">
// Refresh page every x minutes
if(self.location != "<?=$BASEURL;?>/chat.php") setInterval("document.location.reload();", <?=$autorefreshtime;?>);
// Add message to statusbar before refresh the page.
setInterval("window.status = window.defaultStatus+' - Page reloading...';", <?=$autorefreshtime;?> - 10000);
</SCRIPT>
<?
}
if ($script == 'textarealimiter') {
?>
<style type="text/css">
.progress{
width: 1px;
height: 14px;
color: white;
font-size: 12px;
overflow: hidden;
background-color: black;
padding-left: 5px;
}
</style>
<script type="text/JavaScript">
function textCounter(field,counter,maxlimit,linecounter) {
// text width//
var fieldWidth = parseInt(field.offsetWidth);
var charcnt = field.value.length;
// trim the extra text
if (charcnt > maxlimit) {
field.value = field.value.substring(0, maxlimit);
}
else {
// progress bar percentage
var percentage = parseInt(100 - (( maxlimit - charcnt) * 100)/maxlimit) ;
document.getElementById(counter).style.width = parseInt((fieldWidth*percentage)/100)+"px";
document.getElementById(counter).innerHTML="Limit: "+percentage+"%"
// color correction on style from CCFFF -> CC0000
setcolor(document.getElementById(counter),percentage,"background-color");
}
}
function setcolor(obj,percentage,prop){
obj.style[prop] = "rgb(80%,"+(100-percentage)+"%,"+(100-percentage)+"%)";
}
</script>
<?
}
?>
<title><?= $title ?></title>
<link rel="stylesheet" href="<?=$ss_uri?>" type="text/css">
<link rel="alternate" type="application/rss+xml" title="Latest Torrents" href="<?=$DEFAULTBASEURL?>/rss.php">
<script type="text/javascript" src="java_klappe.js"></script>
<script type="text/javascript" src="ncode_imageresizer.js"></script>
<!--Image Resizer v0.1 by xam//-->
<script type="text/javascript">
<!--
NcodeImageResizer.MAXWIDTH = 680;
NcodeImageResizer.MAXHEIGHT = 0;
NcodeImageResizer.Msg1 = 'Click this bar to view the full image.';
NcodeImageResizer.Msg2 = 'This image has been resized. Click this bar to view the full image.';
NcodeImageResizer.Msg3 = 'This image has been resized. Click this bar to view the full image.';
NcodeImageResizer.Msg4 = 'Click this bar to view the small image.';
//-->
<!--Image Resizer v0.1 by xam//-->
</script>
<script LANGUAGE="JavaScript">
<!-- Begin
var checkflag = "false";
function check(field) {
if (checkflag == "false") {
for (i = 0; i < field.length; i++) {
field[i].checked = true;}
checkflag = "true";
return "Uncheck All"; }
else {
for (i = 0; i < field.length; i++) {
field[i].checked = false; }
checkflag = "false";
return "Check All"; }
}
// End -->
</script>
<script type="text/javascript">
<!--
function SetSize(obj, x_size) {
if (obj.offsetWidth > x_size) {
obj.style.width = x_size;
};
};
//-->
</script>
</head>
<body>
<?
if ($disablerightclick == "yes") {
?>
<script language=JavaScript>
<!-- Begin
<?
$mesaj="Click dreapta este dezactivat!!!"
?>
var message="<?=$mesaj;?>";
function clickIE4(){
if (event.button==2){
alert(message);
return false;
}
}
function clickNS4(e){
if (document.layers||document.getElementById&&!document.all){
if (e.which==2||e.which==3){
alert(message);
return false;
}
}
}
if (document.layers){
document.captureEvents(Event.MOUSEDOWN);
document.onmousedown=clickNS4;
}
else if (document.all&&!document.getElementById){
document.onmousedown=clickIE4;
}
document.oncontextmenu=new Function("alert(message);return false")
// End -->
</script>
<?
}
?>
<table width="910" cellspacing="0" cellpadding="0" style="background: transparent" align="center">
<tr>
<br><br>
<td class=clear align=left width=50>
</td>
<td class=clear align=left>
<div align=center>
<a href="<?=$BASEURL;?>" target="_self" border="0"><img src=pic/logo.gif align=left border=0></a>
</div>
</td>
</tr>
</table>
<table class="mainouter" width="910" cellspacing="0" cellpadding="5" align="center">
<!------------- MENU ------------------------------------------------------------------------>
<tr>
<td class="outer" align="center" width="910">
<table class="main1" width="910" cellspacing="0" cellpadding="5">
<tr>
<? if (!$CURUSER) { ?>
<td align="center" class="navigation">
<a href="login.php"><img src="pic/retry.gif" border=0></a>
</td>
<? } else {
print ("<table class=\"main\" width=\"740\" cellspacing=\"0\" cellpadding=\"0\" border=\"0\">");
menu ();
print ("</table>");
} ?>
<!-- /////// some vars for the statusbar;o) //////// -->
<? if ($CURUSER) {
$datum = getdate();
$datum["hours"] = sprintf("%02.0f", $datum["hours"]);
$datum["minutes"] = sprintf("%02.0f", $datum["minutes"]);
$uped = mksize($CURUSER['uploaded']);
$downed = mksize($CURUSER['downloaded']);
if ($CURUSER["downloaded"] > 0)
{
$ratio = $CURUSER['uploaded'] / $CURUSER['downloaded'];
$ratio = number_format($ratio, 3);
$color = get_ratio_color($ratio);
if ($color)
$ratio = "<font color=$color>$ratio</font>";
}else
if ($CURUSER["uploaded"] > 0)
$ratio = "Inf.";
else
$ratio = "---";
if ($CURUSER['donor'] == "yes")
$medaldon = "<img src=pic/star.gif alt=donor title=donor>";
if ($CURUSER['warned'] == "yes")
$warn = "<img src=pic/warned.gif alt=warned title=warned>";
//// check for messages //////////////////
$res1 = mysql_query("SELECT COUNT(*) FROM messages WHERE receiver=" . $CURUSER["id"] . " AND location<>0") or print(mysql_error());
$arr1 = mysql_fetch_row($res1);
$messages = $arr1[0];
$res1 = mysql_query("SELECT COUNT(*) FROM messages WHERE receiver=" . $CURUSER["id"] . " AND location=1 AND unread='yes'") or print(mysql_error());
$arr1 = mysql_fetch_row($res1);
$unread = $arr1[0];
$res1 = mysql_query("SELECT COUNT(*) FROM messages WHERE sender=" . $CURUSER["id"] . " AND saved='yes'") or print(mysql_error());
$arr1 = mysql_fetch_row($res1);
$outmessages = $arr1[0];
$res1 = mysql_query("SELECT COUNT(*) FROM messages WHERE receiver=" . $CURUSER["id"] . " && unread='yes'") or die("OopppsY!");
$arr1 = mysql_fetch_row($res1);
$unread = $arr1[0];
if ($unread)
$inboxpic = "<img height=14px style=border:none alt=inbox title='inbox (new messages)' src=pic/pn_inboxnew.gif>";
else
$inboxpic = "<img height=14px style=border:none alt=inbox title='inbox (no new messages)' src=pic/pn_inbox.gif>";
$res2 = mysql_query("SELECT COUNT(*) FROM peers WHERE userid=" . $CURUSER["id"] . " AND seeder='yes'") or print(mysql_error());
$row = mysql_fetch_row($res2);
$activeseed = $row[0];
$res2 = mysql_query("SELECT COUNT(*) FROM peers WHERE userid=" . $CURUSER["id"] . " AND seeder='no'") or print(mysql_error());
$row = mysql_fetch_row($res2);
$activeleech = $row[0];
$res3 = mysql_query("SELECT connectable FROM peers WHERE userid=" . sqlesc($CURUSER["id"]) . " LIMIT 1") or print(mysql_error());
if($row = mysql_fetch_row($res3)){
$connect = $row[0];
if($connect == "yes"){
$connectable = "<b><font color=green><a title='Connectable = Yes'>Yes</a></font></b>";
}else{
$connectable = "<b><font color=red><a title='Connectable = No'>No</a></font></b>";
}
}else{
$connectable = "waiting...";
}
?>
<!-- //////// start the statusbar ///////////// -->
<?$usrclass = " ".get_user_class_name($CURUSER['class'])." ";?>
<table cellpadding="0" cellspacing="0" class="status_bar">
<tr>
<td class="bottom">
<table cellpadding="0" cellspacing="0" class="status_bar1">
<tr>
<td align="center" class="bottom1" border="0">
<?
if(!$CURUSER[avatar])
print("<a href=userdetails.php?id=$CURUSER[id]><img src=pic/default_avatar.gif max width=90 border=0></a>");
else
print("<a href=userdetails.php?id=$CURUSER[id]><img src=$CURUSER[avatar] max width=90 border=0></a>");
?>
</td>
<td class="bottom3" align="left"><span class="smallfont"><font color="ffffff">Welcome back,</font> <a href="userdetails.php?id=<?=$CURUSER['id']?>"><?=$CURUSER['username']?></a><?=$medaldon?><?=$warn?><font color=white> Class:</font><font color=000000><?print "$usrclass";?></font> <? if (get_user_class() >= UC_MODERATOR) { ?> [<a href="staffpanel.php">Staff Panel</a>] <?}?> <? if (get_user_class() >= UC_SYSOP) { ?> [<a href="settings.php">Site Settings</a>]<?}?> <br/><br/>
<font color=#ffffff>Ratio:</font> <?=$ratio?> <font color=green>Uploaded:</font> <font color=black><?=$uped?></font> <font color=darkred>Downloaded:</font> <font color=black><?=$downed?></font> <br><br/>
<font color=#ffffff>Active Torrents: </font></span> <img alt="Torrents seeding" title="Torrents seeding" src="pic/arrowup.gif"> <font color=black><span class="smallfont"><?=$activeseed?></span></font> <img alt="Torrents leeching" title="Torrents leeching" src="pic/arrowdown.gif"> <font color=black><span class="smallfont"><?=$activeleech?></span></font> <font color=#ffffff>Connectable: </font><?=$connectable?></td><br/>
<td class="bottom2"><br><br> <font color="ffffff">[ </font><a href="logout.php"><font color="ffffff">logout</font></a><font color="ffffff"> ]</font><br><br><br><br>
<font color=#ffffff>Bonus:</font> <a href="mybonus.php"><?=number_format($CURUSER['seedbonus'], 1)?></a> <?=maxslots();?></td>
<td class="bottom" align="left"><span class="smallfont">The time is now: <?echo "$datum[hours]:$datum[minutes]";?><br/><br/>
<?
if ($messages){
print("<span class=smallfont><a href=messages.php>$inboxpic</a> $messages ($unread New)</span>");
if ($outmessages)
print("<span class=smallfont> <a href=messages.php?action=viewmailbox&box=-1><img height=14px style=border:none alt=sentbox title=sentbox src=pic/pn_sentbox.gif></a> $outmessages</span>");
else
print("<span class=smallfont> <a href=messages.php?action=viewmailbox&box=-1><img height=14px style=border:none alt=sentbox title=sentbox src=pic/pn_sentbox.gif></a> 0</span>");
}else{
print("<span class=smallfont><a href=messages.php><img height=14px style=border:none alt=inbox title=inbox src=pic/pn_inbox.gif></a> 0</span>");
if ($outmessages)
print("<span class=smallfont> <a href=messages.php?action=viewmailbox&box=-1><img height=14px style=border:none alt=sentbox title=sentbox src=pic/pn_sentbox.gif></a> $outmessages</span>");
else
print("<span class=smallfont> <a href=messages.php?action=viewmailbox&box=-1><img height=14px style=border:none alt=sentbox title=sentbox src=pic/pn_sentbox.gif></a> 0</span>");
}
print(" <a href=friends.php><img style=border:none alt=Buddylist title=Buddylist src=pic/buddylist.gif></a>");
print(" <a href=getrss.php><img style=border:none alt=Buddylist title='Get RSS' src=pic/rss.gif width=11 height=12></a>");
?>
</span></td>
</tr>
</table>
<? }?>
</tr>
</table>
</td>
</tr>
<tr><td align="center" class="outer" style="padding-top: 20px; padding-bottom: 20px">
<?
if($CURUSER['downloaded'] > 0) { // Make sure there is a download value
// Set the ratio threshold based on user class
switch (get_user_class())
{
case UC_USER:
case UC_POWER_USER: $ratio = 1.00;
break;
case UC_VIP: $ratio = 0.30;
break;
case UC_UPLOADER:
case UC_MODERATOR: $ratio = 0.70;
break;
case UC_ADMINISTRATOR:
case UC_SYSOP:
case UC_STAFFLEADER: $ratio = 0.00;
break;
}
// Override ratio if donor, but only if existing ratio is higher than 0.70
if($CURSUSER['donor']=='yes' && $ratio > 0.70) $ratio = 0.70;
// Do remember warned users they are warned and for how long... [by fedepeco]
if ($CURUSER['leechwarn'] == 'yes') {
$leechwarnuntil = $CURUSER['leechwarnuntil'];
print("<p><table border=1 width=737 cellspacing=0 cellpadding=10 bgcolor=#8daff5 align=center><tr><td style='padding: 10px;'bgcolor=red align=center>\n");
print("<b><font color=white align=center>You are now warned for having a low ratio. You need to get a 0.6 ratio for your warning be removed.<br>If you don't get it in " . mkprettytime(strtotime($leechwarnuntil) - gmtime()) . ", your account will be banned.</font></b>");
print("</td></tr></table></p>\n");
print("<br>\n");
}
// End MOD...
}
if ($unread)
{
print("<p><table border=0 cellspacing=0 cellpadding=10 bgcolor=red><tr><td style='padding: 10px; background: red'>\n");
print("<b><a href=$BASEURL/messages.php><font color=white>You have $unread new message" . ($unread > 1 ? "s" : "") . "! Click here to read.</font></a></b>");
print("</td></tr></table></p><br />\n");
}
if ($CURUSER) {
$rel = sql_query("SELECT COUNT(*) FROM users WHERE status = 'pending' AND invited_by = ".mysql_real_escape_string($CURUSER[id])) or sqlerr(__FILE__, __LINE__);
$arro = mysql_fetch_row($rel);
$number = $arro[0];
if ($number > 0)
{
print("<p><table border=0 cellspacing=0 cellpadding=10 bgcolor=red><tr><td style='padding: 10px; background: red'>\n");
print("<b><a href=$BASEURL/invite.php?id=$CURUSER[id]><font color=white>Your friend".($number > 1 ? "s" : "")." ($number) awaiting confirmation from you!</font></a></b>");
print("</td></tr></table></p><br />\n");
}
}
if ($offlinemsg)
{
$settings_script_name = substr($_SERVER[SCRIPT_FILENAME], -12 , 12);
if ($settings_script_name != "settings.php" AND $settings_script_name != "announce.php") {
print("<p><table width=737 border=1 cellspacing=0 cellpadding=10 bgcolor=red><tr><td style='padding: 10px; background: red' class=text>\n");
print("<font color=white><center><b>WARNING</b>: The website is currently offline! Click <a href=settings.php>here</a> to change settings.</font></center>");
print("</td></tr></table></p>\n");
print("<br>\n");
}
}
if (get_user_class() > UC_MODERATOR)
{
$resa = mysql_query("select count(id) as numreports from reports WHERE dealtwith=0");
$arra = mysql_fetch_assoc($resa);
$numreports = $arra[numreports];
if ($numreports){
print("<p><table border=0 cellspacing=0 cellpadding=10 bgcolor=red><tr><td style='padding: 10px; background: blue'>\n");
print("<b><a href=reports.php><font color=white>There is $numreports new report" . ($numreports > 1 ? "s" : "") . "!</font></a></b>");
print("</td></tr></table></p>\n");}
$rese = mysql_query("SELECT COUNT(id) as nummessages from staffmessages WHERE answered='no'");
$arre = mysql_fetch_assoc($rese);
$nummessages = $arre[nummessages];
if ($nummessages > 0) {
print("<p><table border=0 cellspacing=0 cellpadding=10 bgcolor=red><tr><td style='padding: 10px; background: blue'>\n");
print("<b><a href=staffbox.php><font color=white>There is $nummessages new staff message" . ($nummessages > 1 ? "s" : "") . "!</font></a></b>");
print("</td></tr></table></p>\n");}
}
} // stdhead
function stdfoot() {
global $SITENAME,$BASEURL;
print("</td></tr></table></td></tr></table><center><br>\n");
print("<table class=stdfoot border=0><tr><td class=outer>\n");
// Variables for Start Time
$mtime = microtime(); // Get Current Time
$mtime = explode (" ", $mtime); // Split Seconds and Microseconds
$mtime = $mtime[1] + $mtime[0]; // Create a single value for start time
$tstart = $mtime; // Start time
// Variables for Start Time
$mtime = microtime();
$mtime = explode (" ", $mtime);
$mtime = $mtime[1] + $mtime[0];
$tend = $mtime; // End time
$totaltime = ($tend - $tstart);
print(VERSION." (c) ".date("Y")." $SITENAME Based On TBDev.<br / >");
print("<a class=acord href=useragreement.php>Prin folosirea acestui website declarati ca sunteti de acord cu termenii si regulile de utilizare ale acestuia!</a>");
//printf ("[Executed in <b> %f </b>seconds", $totaltime);
// print (" with <b>".($_SESSION["queries"] ? $_SESSION["queries"] : "0")."</b> queries!]");
print("</td></tr></table>\n");
print ("</td></tr></table></center><br><br><br>\n");
print("</body></head></html>\n");
unset($_SESSION['queries']);
}
function genbark($x,$y) {
stdhead($y);
print("<h2>" . htmlspecialchars($y) . "</h2>\n");
print("<p>" . htmlspecialchars($x) . "</p>\n");
stdfoot();
exit();
}
function mksecret($len = 20) {
$ret = "";
for ($i = 0; $i < $len; $i++)
$ret .= chr(mt_rand(0, 255));
return $ret;
}
function httperr($code = 404) {
header("HTTP/1.0 404 Not found");
print("<h1>Not Found</h1>\n");
print("<p>Sorry pal :(</p>\n");
exit();
}
function gmtime()
{
return strtotime(get_date_time());
}
//-------------------------------------
//---- Secure Login System v0.3 by xam
//-------------------------------------
function sessioncookie ($id, $passhash, $expires=false) {
if ($expires)
$GLOBALS[$sessioncacheexpire] = true;
$_SESSION['s_secure_uid'] = base64($id);
$_SESSION['s_secure_pass'] = $passhash;
return $sessioncacheexpire;
}
function logincookie($id, $passhash, $updatedb = 1, $expires = 0x7fffffff, $securelogin=true)
{
setcookie("c_secure_uid", base64($id), $expires, "/");
setcookie("c_secure_pass", $passhash, $expires, "/");
if ($securelogin)
setcookie("c_secure_login", base64("yeah"), $expires, "/");
else
setcookie("c_secure_login", base64("nope"), $expires, "/");
if ($updatedb)
mysql_query("UPDATE users SET last_login = NOW() WHERE id = ".mysql_real_escape_string($id));
}
function logoutsession () {
session_unset();
session_destroy();
}
function logoutcookie() {
setcookie("c_secure_uid", "", 0x7fffffff, "/");
setcookie("c_secure_pass", "", 0x7fffffff, "/");
setcookie("c_secure_login", "", 0x7fffffff, "/");
}
function base64 ($string, $encode=true) {
if ($encode)
return base64_encode($string);
else
return base64_decode($string);
}
//-------------------------------------
//---- Secure Login System v0.3 by xam
//-------------------------------------
function loggedinorreturn($mainpage = false) {
global $CURUSER,$BASEURL;
if (!$CURUSER) {
if ($mainpage)
header("Location: $BASEURL/login.php");
else {
$to = $_SERVER["REQUEST_URI"];
$to = basename($to);
header("Location: $BASEURL/login.php?returnto=" . urlencode($to));
}
exit();
}
}
function deletetorrent($id) {
global $torrent_dir;
mysql_query("DELETE FROM torrents WHERE id = ".mysql_real_escape_string($id));
mysql_query("DELETE FROM snatched WHERE torrentid = ".mysql_real_escape_string($id));
foreach(explode(".","peers.files.comments.ratings") as $x)
mysql_query("DELETE FROM $x WHERE torrent = ".mysql_real_escape_string($id));
unlink("$torrent_dir/$id.torrent");
}
function pager($rpp, $count, $href, $opts = array()) {
$pages = ceil($count / $rpp);
if (!$opts["lastpagedefault"])
$pagedefault = 0;
else {
$pagedefault = floor(($count - 1) / $rpp);
if ($pagedefault < 0)
$pagedefault = 0;
}
if (isset($_GET["page"])) {
$page = 0 + $_GET["page"];
if ($page < 0)
$page = $pagedefault;
}
else
$page = $pagedefault;
$pager = "";
$mp = $pages - 1;
$as = "<b><img src=pic/prev.png border=0></b>";
if ($page >= 1) {
$pager .= "<a href=\"{$href}page=" . ($page - 1) . "\">";
$pager .= $as;
$pager .= "</a>";
}
else
$pager .= $as;
$pager .= " ";
$as = "<b><img src=pic/next.png border=0></b>";
if ($page < $mp && $mp >= 0) {
$pager .= "<a href=\"{$href}page=" . ($page + 1) . "\">";
$pager .= $as;
$pager .= "</a>";
}
else
$pager .= $as;
if ($count) {
$pagerarr = array();
$dotted = 0;
$dotspace = 3;
$dotend = $pages - $dotspace;
$curdotend = $page - $dotspace;
$curdotstart = $page + $dotspace;
for ($i = 0; $i < $pages; $i++) {
if (($i >= $dotspace && $i <= $curdotend) || ($i >= $curdotstart && $i < $dotend)) {
if (!$dotted)
$pagerarr[] = "...";
$dotted = 1;
continue;
}
$dotted = 0;
$start = $i * $rpp + 1;
$end = $start + $rpp - 1;
if ($end > $count)
$end = $count;
$text = "$start - $end";
if ($i != $page)
$pagerarr[] = "<a href=\"{$href}page=$i\"><b>$text</b></a>";
else
$pagerarr[] = "<b>$text</b>";
}
$pagerstr = join(" | ", $pagerarr);
$pagertop = "<p align=\"center\">$pager<br />$pagerstr</p>\n";
$pagerbottom = "<p align=\"center\">$pagerstr<br />$pager</p>\n";
}
else {
$pagertop = "<p align=\"center\">$pager</p>\n";
$pagerbottom = $pagertop;
}
$start = $page * $rpp;
return array($pagertop, $pagerbottom, "LIMIT $start,$rpp");
}
function downloaderdata($res) {
$rows = array();
$ids = array();
$peerdata = array();
while ($row = mysql_fetch_assoc($res)) {
$rows[] = $row;
$id = $row["id"];
$ids[] = $id;
$peerdata[$id] = array(downloaders => 0, seeders => 0, comments => 0);
}
if (count($ids)) {
$allids = implode(",", $ids);
$res = mysql_query("SELECT COUNT(*) AS c, torrent, seeder FROM peers WHERE torrent IN ($allids) GROUP BY torrent, seeder");
while ($row = mysql_fetch_assoc($res)) {
if ($row["seeder"] == "yes")
$key = "seeders";
else
$key = "downloaders";
$peerdata[$row["torrent"]][$key] = $row["c"];
}
$res = mysql_query("SELECT COUNT(*) AS c, torrent FROM comments WHERE torrent IN ($allids) GROUP BY torrent");
while ($row = mysql_fetch_assoc($res)) {
$peerdata[$row["torrent"]]["comments"] = $row["c"];
}
}
return array($rows, $peerdata);
}
function commenttable($rows)
{
global $CURUSER;
begin_main_frame();
begin_frame();
$count = 0;
foreach ($rows as $row)
{
print("<p class=sub>#" . $row["id"] . " by ");
if (isset($row["username"]))
{
$title = $row["title"];
if ($title == "")
$title = get_user_class_name($row["class"]);
else
$title = htmlspecialchars(trim($title));
print("<a name=comm". $row["id"] .
" href=userdetails.php?id=" . $row["user"] . "><b>" .
htmlspecialchars($row["username"]) . "</b></a>" . ($row["donor"] == "yes" ? "<img src=pic/star.gif alt='Donor'>" : "") . ($row["warned"] == "yes" ? "<img src=".
"pic/warned.gif alt=\"Warned\">" : "") . " ($title)\n");
}
else
print("<a name=\"comm" . $row["id"] . "\"><i>(orphaned)</i></a>\n");
print(" at " . $row["added"] . " GMT" .
($row["user"] == $CURUSER["id"] || get_user_class() >= UC_MODERATOR ? "- [<a href=comment.php?action=edit&cid=$row[id]>Edit</a>]" : "") .
(get_user_class() >= UC_MODERATOR ? "- [<a href=comment.php?action=delete&cid=$row[id]>Delete</a>]" : "") .
($row["editedby"] && get_user_class() >= UC_MODERATOR ? "- [<a href=comment.php?action=vieworiginal&cid=$row[id]>View original</a>]" : "") . "</p>\n");
$avatar = ($CURUSER["avatars"] == "yes" ? htmlspecialchars(trim($row["avatar"])) : "");
if (!$avatar)
$avatar = "pic/default_avatar.gif";
$text = format_comment($row["text"]);
if ($row["editedby"])
$text .= "<p><font size=1 class=small>Last edited by <a href=userdetails.php?id=$row[editedby]><b>$row[username]</b></a> at $row[editedat] GMT</font></p>\n";
begin_table(true);
$dt = gmtime() - 180;
$dt = sqlesc(get_date_time($dt));
print("<tr>\n");
print("<td align=center width=100 height=100 style='padding: 0px'><img width=100 height=100 src=$avatar></td>\n");
print("<td class=text valign=top>$text</td>\n");
print("</tr>\n");
print("<tr><td colspan=2> ".("'".$row['last_access']."'">$dt?"<img src=pic/user_online.gif border=0 alt=\"Online\">":"<img src=pic/user_offline.gif border=0 alt=\"Offline\">" )."<a href=\"sendmessage.php?receiver=".htmlspecialchars(trim($row["user"]))."\"><img src=\"pic/pm.gif\" border=\"0\" alt=\"Send message to ".htmlspecialchars($row["username"])."\"></a> <a href=\"report.php?commentid=".htmlspecialchars(trim($row["id"]))."\"><img src=\"pic/report.gif\" border=\"0\" alt=\"Report this comment\"></a></td>");
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() {
$ret = array();
$res = mysql_query("SELECT id, name FROM categories ORDER BY name");
while ($row = mysql_fetch_array($res))
$ret[] = $row;
return $ret;
}
function linkcolor($num) {
if (!$num)
return "red";
// if ($num == 1)
// return "yellow";
return "green";
}
function ratingpic($num) {
global $pic_base_url;
$r = round($num * 2) / 2;
if ($r < 1 || $r > 5)
return;
return "<img src=\"$pic_base_url$r.gif\" border=\"0\" alt=\"rating: $num / 5\" />";
}
function writecomment($userid, $comment) {
$res = mysql_query("SELECT modcomment FROM users WHERE id = '$userid'") or sqlerr(__FILE__, __LINE__);
$arr = mysql_fetch_assoc($res);
$modcomment = gmdate("d-m-Y") . " - " . $comment . "" . ($arr[modcomment] != "" ? "\n\n" : "") . "$arr[modcomment]";
$modcom = sqlesc($modcomment);
return mysql_query("UPDATE users SET modcomment = $modcom WHERE id = '$userid'") or sqlerr(__FILE__, __LINE__);
}
function torrenttable($res, $variant = "index") {
global $pic_base_url, $CURUSER,$waitsystem;
unset($wait);
$browse_res = mysql_query("SELECT last_browse FROM users WHERE id=".sqlesc($CURUSER[id]));
$browse_arr = mysql_fetch_row($browse_res);
$last_browse = $browse_arr[0];
$time_now = gmtime();
if ($last_browse > $time_now) {
$last_browse=$time_now;
}
if ($CURUSER["class"] < UC_VIP)
{
if ($waitsystem == "yes") {
$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;
}
}
?>
<table border="1" cellspacing="0" cellpadding="3" width="830">
<tr>
<?
// sorting by MarkoStamcar
$count_get = 0;
foreach ($_GET as $get_name => $get_value) {
$get_name = mysql_escape_string(strip_tags(str_replace(array("\"","'"),array("",""),$get_name)));
$get_value = mysql_escape_string(strip_tags(str_replace(array("\"","'"),array("",""),$get_value)));
if ($get_name != "sort" && $get_name != "type") {
if ($count_get > 0) {
$oldlink = $oldlink . "&" . $get_name . "=" . $get_value;
} else {
$oldlink = $oldlink . $get_name . "=" . $get_value;
}
$count_get++;
}
}
if ($count_get > 0) {
$oldlink = $oldlink . "&";
}
if ($_GET['sort'] == "1") {
if ($_GET['type'] == "desc") {
$link1 = "asc";
} else {
$link1 = "desc";
}
}
if ($_GET['sort'] == "2") {
if ($_GET['type'] == "desc") {
$link2 = "asc";
} else {
$link2 = "desc";
}
}
if ($_GET['sort'] == "3") {
if ($_GET['type'] == "desc") {
$link3 = "asc";
} else {
$link3 = "desc";
}
}
if ($_GET['sort'] == "4") {
if ($_GET['type'] == "desc") {
$link4 = "asc";
} else {
$link4 = "desc";
}
}
if ($_GET['sort'] == "5") {
if ($_GET['type'] == "desc") {
$link5 = "asc";
} else {
$link5 = "desc";
}
}
if ($_GET['sort'] == "6") {
if ($_GET['type'] == "desc") {
$link6 = "asc";
} else {
$link6 = "desc";
}
}
if ($_GET['sort'] == "7") {
if ($_GET['type'] == "desc") {
$link7 = "asc";
} else {
$link7 = "desc";
}
}
if ($_GET['sort'] == "8") {
if ($_GET['type'] == "desc") {
$link8 = "asc";
} else {
$link8 = "desc";
}
}
if ($_GET['sort'] == "9") {
if ($_GET['type'] == "desc") {
$link9 = "asc";
} else {
$link9 = "desc";
}
}
if ($link1 == "") { $link1 = "asc"; } // for torrent name
if ($link2 == "") { $link2 = "desc"; }
if ($link3 == "") { $link3 = "desc"; }
if ($link4 == "") { $link4 = "desc"; }
if ($link5 == "") { $link5 = "desc"; }
if ($link6 == "") { $link6 = "desc"; }
if ($link7 == "") { $link7 = "desc"; }
if ($link8 == "") { $link8 = "desc"; }
if ($link9 == "") { $link9 = "desc"; }
?>
<td class="colhead" align="center"><font color=black>Type</font></td>
<td class="colhead" align="left"><a href="browse.php?<? print $oldlink; ?>sort=1&type=<? print $link1; ?>">Name</a> <font color=black>/</font> <a href="browse.php?<? print $oldlink; ?>sort=4&type=<? print $link4; ?>">Genre</a></td>
<?
if ($CURUSER["downloadpos"] != "no")
print("<td class=\"colhead\" align=\"center\"><img src=pic/down.png border=0 alt=download></td>");
if ($wait)
{
print("<td class=\"colhead\" align=\"center\"><font color=black>Wait</font></td>\n");
}
if ($variant == "mytorrents")
{
print("<td class=\"colhead\" align=\"center\">Edit</td>\n");
print("<td class=\"colhead\" align=\"center\">Visible</td>\n");
}
?>
<td class="colhead" align="center"><a href="browse.php?<? print $oldlink; ?>sort=2&type=<? print $link2; ?>"><img src=pic/files.gif border=0 alt=files></a></td>
<td class="colhead" align="center"><a href="browse.php?<? print $oldlink; ?>sort=3&type=<? print $link3; ?>"><img src=pic/comments.gif border=0 alt=comments></a></td>
<td class="colhead" align="center"><a href="browse.php?<? print $oldlink; ?>sort=7&type=<? print $link7; ?>"><img src=pic/seeders.gif border=0 alt=seeders></a></td>
<td class="colhead" align="center"><a href="browse.php?<? print $oldlink; ?>sort=8&type=<? print $link8; ?>"><img src=pic/leechers.gif border=0 alt=seeders></a></td>
<!--<td class="colhead" align="center">Rating</td>-->
<!--<td class="colhead" align="center">TTL</td>-->
<td class="colhead" align="center"><font color=black>Av.Progress</font></td>
<!--<td class="colhead" align="center">T.Speed</td>-->
<td class="colhead" align="center"><a href="browse.php?<? print $oldlink; ?>sort=5&type=<? print $link5; ?>"><img src=pic/size.png border=0 alt=size></a> <font color=black> </font> <a href="browse.php?<? print $oldlink; ?>sort=6&type=<? print $link6; ?>"><img src=pic/snat.png border=0 alt=snatched></a></td>
<!--
<td class="colhead" align=right>Views</td>
<td class="colhead" align=right>Hits</td>
-->
<?
if ($variant == "index")
print("<td class=\"colhead\" align=center><a href=\"browse.php?{$oldlink}sort=9&type={$link9}\">Uploader</a></td>\n");
?>
<? if ($CURUSER['class']>=UC_MODERATOR) { ?>
<td class="colhead" align="center"><font color=black>Action</font></td>
<? } ?>
<?
print("</tr>\n");
while ($row = mysql_fetch_assoc($res)) {
$id = $row["id"];
print("<tr>\n");
print("<td align=center width=16 height=16 style='padding: 0px'>");
if (isset($row["cat_name"])) {
print("<a href=\"browse.php?cat=" . $row["category"] . "\">");
if (isset($row["cat_pic"]) && $row["cat_pic"] != "")
print("<img border=\"0\" src=\"$pic_base_url" . $row["cat_pic"] . "\" alt=\"" . $row["cat_name"] . "\" />");
else
print($row["cat_name"]);
print("</a>");
}
else
print("-");
print("</td>\n");
$dispname = htmlspecialchars(trim($row["name"]));
$count_dispname=strlen($dispname);
$max_lenght_of_torrent_name="70"; // maximum lenght
if($count_dispname > $max_lenght_of_torrent_name){
$short_torrent_name_alt="title=\"$dispname\"";
$dispname=substr($dispname, 0, $max_lenght_of_torrent_name) . "...";
}else
$short_torrent_name_alt="title=\"$dispname\"";
print("<td align=left><a $short_torrent_name_alt href=\"details.php?");
if ($variant == "mytorrents")
print("returnto=" . urlencode($_SERVER["REQUEST_URI"]) . "&");
print("id=$id");
if ($variant == "index")
print("&hit=1");
$thisisfree = ($row[free]=="yes" ? "<img align=right src='pic/freedownload.gif' />" : "");
$genretit = "Genre: ";
$genre = $row["description"];
if (sql_timestamp_to_unix_timestamp($row["added"]) >= $last_browse)
print("\">$dispname</a> $thisisfree <img src=pic/new.png border=0 align=right><div class=genre>" . " Genre: <br>" . str_replace(" ", " ", $genre) . "</div>");
else
print("\">$dispname</a> $thisisfree <br><div class=genre>" . " Genre: " . str_replace(" ", " ", $genre) . "</div></div>");
if ($variant == "index")
if ($CURUSER["downloadpos"] != "no")
print("<td align=\"right\"><a class=\"index\" href=\"download.php?id=$id&name=" . rawurlencode($row["filename"]) . "\"><img src=pic/dl.gif border=0 alt=Download></a></td>\n");
if ($wait)
{
$elapsed = floor((gmtime() - strtotime($row["added"])) / 3600);
if ($elapsed < $wait)
{
$color = dechex(floor(127*($wait - $elapsed)/48 + 128)*65536);
print("<td align=center><nobr><a href=\"faq.php#46\"><font color=\"$color\">" . number_format($wait - $elapsed) . " h</font></a></nobr></td>\n");
}
else
print("<td align=center><nobr>None</nobr></td>\n");
}
/*
if ($row["nfoav"] && get_user_class() >= UC_POWER_USER)
print("<a href=viewnfo.php?id=$row[id]><img src=pic/viewnfo.gif border=0 alt='View NFO'></a>\n");
if ($variant == "index")
print("<a href=\"download.php/$id/" . rawurlencode($row["filename"]) . "\"><img src=pic/download.gif border=0 alt=Download></a>\n");
else */ if ($variant == "mytorrents")
print("<td align=\"center\"><a href=\"edit.php?returnto=" . urlencode($_SERVER["REQUEST_URI"]) . "&id=" . $row["id"] . "\">edit</a>\n");
print("</td>\n");
if ($variant == "mytorrents") {
print("<td align=\"right\">");
if ($row["visible"] == "no")
print("<b>no</b>");
else
print("yes");
print("</td>\n");
}
if ($row["type"] == "single")
print("<td align=\"center\">" . $row["numfiles"] . "</td>\n");
else {
if ($variant == "index")
print("<td align=\"center\"><a href=\"details.php?id=$id&hit=1&filelist=1\">" . $row["numfiles"] . "</a></td>\n");
else
print("<td align=\"center\"><a href=\"details.php?id=$id&filelist=1#filelist\">" . $row["numfiles"] . "</a></td>\n");
}
if (!$row["comments"])
print("<td align=\"center\">" . $row["comments"] . "</td>\n");
else {
if ($variant == "index")
print("<td align=\"center\"><a href=\"details.php?id=$id&hit=1&tocomm=1\">" . $row["comments"] . "</a></td>\n");
else
print("<td align=\"center\"><a href=\"details.php?id=$id&page=0#startcomments\">" . $row["comments"] . "</a></td>\n");
}
if ($row["seeders"]) {
if ($variant == "index")
{
if ($row["leechers"]) $ratio = $row["seeders"] / $row["leechers"]; else $ratio = 1;
print("<td align=center><a href=details.php?id=$id&hit=1&toseeders=1><font color=" .
get_slr_color($ratio) . ">" . $row["seeders"] . "</font></a></td>\n");
}
else
print("<td align=\"center\"><a class=\"" . linkcolor($row["seeders"]) . "\" href=\"details.php?id=$id&dllist=1#seeders\">" .
$row["seeders"] . "</a></td>\n");
}
else
print("<td align=\"center\"><span class=\"" . linkcolor($row["seeders"]) . "\">" . $row["seeders"] . "</span></td>\n");
if ($row["leechers"]) {
if ($variant == "index")
print("<td align=center><a href=details.php?id=$id&hit=1&todlers=1>" .
number_format($row["leechers"]) . (isset($peerlink) ? "</a>" : "") .
"</td>\n");
else
print("<td align=\"center\"><a class=\"" . linkcolor($row["leechers"]) . "\" href=\"details.php?id=$id&dllist=1#leechers\">" .
$row["leechers"] . "</a></td>\n");
}
else
print("<td align=\"center\">0</td>\n");
/*
print("<td align=\"center\">");
if (!isset($row["rating"]))
print("---");
else {
$rating = round($row["rating"] * 2) / 2;
$rating = ratingpic($row["rating"]);
if (!isset($rating))
print("---");
else
print($rating);
}
print("</td>\n");
*/
/*
$ttl = (28*24) - floor((gmtime() - sql_timestamp_to_unix_timestamp($row["added"])) / 3600);
if ($ttl == 1) $ttl .= "<br>hour"; else $ttl .= "<br>hours";
print("<td align=center>$ttl</td>\n");
*/
// Progressbar Mod
$seedersProgressbar = array();
$leechersProgressbar = array();
$resProgressbar = 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))." <br>(".round($progressTotal)."%)";
print("<td align=center>$picProgress</td>\n");
// End Progress Bar mod
/*
// Totalspeed mod
$resSpeed = mysql_query("SELECT seeders,leechers FROM torrents WHERE $where visible='yes' and id = $id ORDER BY added DESC LIMIT 15") or sqlerr(__FILE__, __LINE__);
if ($rowTmp = mysql_fetch_row($resSpeed))
list($seedersTmp,$leechersTmp) = $rowTmp;
if ($seedersTmp >= 1 && $leechersTmp >= 1){
$speedQ = mysql_query("SELECT (t.size * t.times_completed + SUM(p.downloaded)) / (UNIX_TIMESTAMP(NOW()) - UNIX_TIMESTAMP(added)) AS totalspeed FROM torrents AS t LEFT JOIN peers AS p ON t.id = p.torrent WHERE p.seeder = 'no' AND p.torrent = '$id' GROUP BY t.id ORDER BY added ASC LIMIT 15") or sqlerr(__FILE__, __LINE__);
$a = mysql_fetch_assoc($speedQ);
$totalspeed = mksize($a["totalspeed"]) . "/s";
}
else
$totalspeed = "No Traffic";
print "<td align=center>$totalspeed</td>\n";
// End Totalspeed mod
*/
// print("<td align=\"right\">" . $row["views"] . "</td>\n");
// print("<td align=\"right\">" . $row["hits"] . "</td>\n");
$_s = "";
if ($row["times_completed"] != 1)
$_s = "s";
print("<td align=center>" . str_replace(" ", " ", mksize($row["size"])) . "<br><a href=viewsnatches.php?id=$row[id]>" . number_format($row["times_completed"]) . " x time$_s</a></td>\n");
if ($variant == "index") {
if ($row["anonymous"] == "yes") {
print("<td align=center><i>[Anonymous]</i></td>\n");
}
else {
print("<td align=center>" . (isset($row["username"]) ? ("<a href=userdetails.php?id=" . $row["owner"] . ">" . htmlspecialchars($row["username"]) . "</a>") : "<i>(unknown)</i>") . "</td>\n");
}
}
if ($CURUSER['class'] >= UC_MODERATOR) {
print("<td align=center><a href=\"fastdelete.php?id=$row[id]\">D</a>\n");
print(" / <a href=\"edit.php?returnto=" . urlencode($_SERVER["REQUEST_URI"]) . "&id=" . $row["id"] . " alt=edit\">E</a></td>\n");
print("</tr>\n");
}
}
print("</table><P> <P>\n");
return $rows;
}
// IPLogger
function iplogger() {
GLOBAL $HTTP_SERVER_VARS, $CURUSER, $iplog2;
if ($iplog2 == "yes") {
$ip = getip();
$res = mysql_query("SELECT * FROM ips WHERE ip = '".mysql_real_escape_string($ip)."' AND userid = ".mysql_real_escape_string($CURUSER[id])) or die(mysql_error());
if (mysql_num_rows($res) == 0 ) {
mysql_query("INSERT INTO ips(userid, ip) VALUES (".mysql_real_escape_string($CURUSER[id]).", '".mysql_real_escape_string($ip)."')") or die(mysql_error());
}
return;
}
return;
}
// END IPLogger
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";
$leechwarnpic = "warnedbig.gif";
$warnedpic = "warnedbig3.gif";
$disabledpic = "disabledbig.gif";
$style = "style='margin-left: 4pt'";
}
else
{
$donorpic = "star.gif";
$leechwarnpic = "warned.gif";
$warnedpic = "warned3.gif";
$disabledpic = "disabled.gif";
$style = "style=\"margin-left: 2pt\"";
}
$pics = $arr["donor"] == "yes" ? "<img src=pic/$donorpic alt='Donor' border=0 $style>" : "";
if ($arr["enabled"] == "yes")
$pics .= ($arr["leechwarn"] == "yes" ? "<img src=pic/$leechwarnpic alt=\"Leechwarned\" border=0 $style>" : "") . ($arr["warned"] == "yes" ? "<img src=pic/$warnedpic alt=\"Warned\" border=0 $style>" : "");
else
$pics .= "<img src=pic/$disabledpic alt=\"Disabled\" border=0 $style>\n";
return $pics;
}
//----------
// Progress Bar Image Generator
//-----------------------------
// Dynamic image created by Dumpy Dooby
// Original code by johim
// ------------------------------------------------
function get_percent_completed_image($p) {
$maxpx = "45"; // Maximum amount of pixels for the progress bar
if ($p == 0) $progress = "<img src=\"pic/progbar-rest.gif\" height=9 width=" . ($maxpx) . " />";
if ($p == 100) $progress = "<img src=\"pic/progbar-green.gif\" height=9 width=" . ($maxpx) . " />";
if ($p >= 1 && $p <= 30) $progress = "<img src=\"pic/progbar-red.gif\" height=9 width=" . ($p*($maxpx/100)) . " /><img src=\"pic/progbar-rest.gif\" height=9 width=" . ((100-$p)*($maxpx/100)) . " />";
if ($p >= 31 && $p <= 65) $progress = "<img src=\"pic/progbar-yellow.gif\" height=9 width=" . ($p*($maxpx/100)) . " /><img src=\"pic/progbar-rest.gif\" height=9 width=" . ((100-$p)*($maxpx/100)) . " />";
if ($p >= 66 && $p <= 99) $progress = "<img src=\"pic/progbar-green.gif\" height=9 width=" . ($p*($maxpx/100)) . " /><img src=\"pic/progbar-rest.gif\" height=9 width=" . ((100-$p)*($maxpx/100)) . " />";
return "<img src=\"pic/bar_left.gif\" />" . $progress ."<img src=\"pic/bar_right.gif\" />";
}
//----------
// END Progress Bar Image Generator
//---------------------------------
//---------------------------------
//---- Website Settings v0.2 by xam
//---------------------------------
function ReadConfig ($configname) {
if (strstr($configname, ',')) {
$configlist = explode(',', $configname);
foreach ($configlist as $key=>$configname) {
ReadConfig(trim($configname));
}
} else {
$configname = basename($configname);
$path = './config/'.$configname;
if (!file_exists($path)) {
stderr("ERROR", "<font color=red>File [<b>".htmlspecialchars($configname)."</b>] doesn't exist!.</font><br><font color=blue>Before the setup starts, please ensure that you have properly configured file and directory access permissions. Please see below.</font><br><br>chmod 777 CONFIG (config directory).<br>chmod 777 CONFIG/main (the file which save the main settings).",false);
}
$fp = fopen($path, 'r');
$content = '';
while (!feof($fp)) {
$content .= fread($fp, 102400);
}
fclose($fp);
if (empty($content)) {
if ($configname == 'XAM') {
Header("Location: index.php");
die;
}
return array();
}
$tmp = @unserialize($content);
if (empty($tmp)) {
if ($configname == 'XAM') {
Header("Location: index.php");
die;
}
stderr("ERROR", "<font color=red>Cannot read file [<b>".htmlspecialchars($configname)."</b>]!.</font><br><font color=blue>Before the setup starts, please ensure that you have properly configured file and directory access permissions. Please see below.</font><br><br>chmod 777 CONFIG (config directory).<br>chmod 777 CONFIG/main (the file which save the main settings).",false);
}
$GLOBALS[$configname] = $tmp;
return true;
}
}
function WriteConfig ($configname, $config) {
$configname = basename($configname);
$path = './config/'.$configname;
if (!file_exists($path) || !is_writable ($path)) {
stdmsg("ERROR", "<font color=red>Cannot read file [<b>".htmlspecialchars($configname)."</b>]!.</font><br><font color=blue>Before the setup starts, please ensure that you have properly configured file and directory access permissions. Please see below.</font><br><br>chmod 777 CONFIG (config directory).<br>chmod 777 CONFIG/main (the file which save the main settings).",false);
}
$data = @serialize($config);
if (empty($data)) {
stdmsg("ERROR", "<font color=red>Cannot serialize file [<b>".htmlspecialchars($configname)."</b>]</font><br><font color=blue>Before the setup starts, please ensure that you have properly configured file and directory access permissions. Please see below.</font><br><br>chmod 777 CONFIG (config directory).<br>chmod 777 CONFIG/main (the file which save the main settings).",false);
}
$fp = @fopen ($path, 'w');
if (!$fp) {
stdmsg("ERROR", "<font color=red>Cannot open file [<b>".htmlspecialchars($configname)."</b>] to save info!.</font><br><font color=blue>Before the setup starts, please ensure that you have properly configured file and directory access permissions. Please see below.</font><br><br>chmod 777 CONFIG (config directory).<br>chmod 777 CONFIG/main (the file which save the main settings).",false);
}
$Res = @fwrite($fp, $data);
if (empty($Res)) {
stdmsg("ERROR", "<font color=red>Cannot save info in file (error in serialisation) [<b>".htmlspecialchars($configname)."</b>] to save info!.</font><br><font color=blue>Before the setup starts, please ensure that you have properly configured file and directory access permissions. Please see below.</font><br><br>chmod 777 CONFIG (config directory).<br>chmod 777 CONFIG/main (the file which save the main settings).",false);
}
fclose($fp);
return true;
}
function GetVar ($name) {
if ( is_array($name) ) {
foreach ($name as $var) GetVar ($var);
} else {
if ( !isset($_REQUEST[$name]) )
return false;
if ( get_magic_quotes_gpc() ) {
$_REQUEST[$name] = ssr($_REQUEST[$name]);
}
$GLOBALS[$name] = $_REQUEST[$name];
return $GLOBALS[$name];
}
}
function ssr ($arg) {
if (is_array($arg)) {
foreach ($arg as $key=>$arg_bit) {
$arg[$key] = ssr($arg_bit);
}
} else {
$arg = stripslashes($arg);
}
return $arg;
}
//---------------------------------
//---- Website Settings v0.2 by xam
//---------------------------------
function parked()
{
global $CURUSER;
if ($CURUSER["parked"] == "yes")
stderr("Access Denied!", "Your account is parked.");
}
function quote_smart($value)
{
// Stripslashes
if (get_magic_quotes_gpc()) {
$value = stripslashes($value);
}
// Quote if not a number or a numeric string
if (!is_numeric($value)) {
$value = "'" . mysql_real_escape_string($value) . "'";
}
return $value;
}
?>