Bravo List
Register
Go Back   > Bravo List > Source Code > Archived Trackers > TBDev
Reply
Thread Tools
  #1  
Old 26th December 2012, 06:55
ndbj ndbj is offline
Senior Member
 
Join Date: Dec 2012
Portugal
Posts: 35
Default [need help] punbb forum integration in old TBDev source
Hello comunity.

I'm running an old source of TBDev, it's an heavy moded tracker started 6 years ago with XTBDev 0.10 Beta from laffin.
I never looked at the forum i once installed, bleach forum from alex2005, cause we had an smf one that filled our needs, but actually we decided to kill that forum and the correspondent database to have just one.
So i started to mod that bleach forum but my php it's a bit rusty.
Someone told me to integrate an old version of punbb forum, 1.2.23 i guess, cause it was easy to manage and simple to the eye.

I searched the web for some help with this an all pages that have found are those in old TBDev forum wich is already dead.

So, is there anyone here with the mod or anyone who could give me some instructions on how to integrate punbb forum in old tbdev version?

thanks in advance
Reply With Quote
  #2  
Old 27th December 2012, 15:33
Phogo's Avatar
Phogo Phogo is offline
VIP
 
Join Date: Jan 2008
United Kingdom
Posts: 902
Default
Hey,

I found this guide, but its in Russian, http://fluxbb.org.ru/forum/viewtopic.php?id=2370

Seems to be pretty easy to do.
Reply With Quote
  #3  
Old 27th December 2012, 18:34
ndbj ndbj is offline
Senior Member
 
Join Date: Dec 2012
Portugal
Posts: 35
Default
thanks
i traslated that web page to english and took a quick look at the instructions and i'm guessing that that's not all to complete and correct integration.
but it's a start.

thanks again.

So, i'm gonna put here some of php files that i think need to be modified.

signup.php
PHP Code:
<?php

require_once("include/bittorrent.php");

$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 (" number_format($maxusers) . ") has been reached. Inactive accounts are pruned all the time, please check back again later...");


stdhead("Signup");

?>
<!--
<table width=500 border=1 cellspacing=0 cellpadding=10><tr><td align=left>
<h2 align=center>Proxy check</h2>
<b><font color=red>Important - please read:</font></b> We do not accept users connecting through public proxies. When you
submit the form below we will check whether any commonly used proxy ports on your computer is open. If you have a firewall it may alert of you of port
scanning activity originating from <b>69.10.142.42</b> (torrentbits.org). This is only our proxy-detector in action.
<b>The check takes up to 30 seconds to complete, please be patient.</b> The IP address we will test is <b><?= $_SERVER["REMOTE_ADDR"]; ?></b>.
By proceeding with submitting the form below you grant us permission to scan certain ports on this computer.
</td></tr></table>
<p>
-->
Nota: Tens de permitir cookies para efectuares registo.
<p>
<form method="post" action="takesignup.php">
<table border="1" cellspacing=0 cellpadding="10">
<tr><td align="right" class="heading">Username:</td><td align=left><input type="text" size="40" name="wantusername" /></td></tr>
<tr><td align="right" class="heading">Password:</td><td align=left><input type="password" size="40" name="wantpassword" /></td></tr>
<tr><td align="right" class="heading">Confirmação de password:</td><td align=left><input type="password" size="40" name="passagain" /></td></tr>
<tr valign=top><td align="right" class="heading">E-mail:</td><td align=left><input type="text" size="40" name="email" />
<table width=250 border=0 cellspacing=0 cellpadding=0><tr><td class=embedded><font class=small>O endereço de e-mail deverá ser válido.
Não precisas de confirmar o registo para entrar no Tracker mas se te esqueceres da password, a única forma que tens de a recuperar é através do teu e-mail. Verifica a tua caixa de lixo electrónico, pois por vezes os emails vão lá parar.</td></tr>
</font></td></tr></table>
</td></tr>
<tr><td colspan="2" align="center"><input type=submit value="Registar! (Clicar apenas uma vez)" style='height: 25px'></td></tr>
</table>
</form>
<?
stdfoot
();
?>
takesignup.php
PHP Code:
<?php

require_once("include/bittorrent.php");



$res mysql_query("SELECT COUNT(*) FROM users") or sqlerr(__FILE____LINE__);
$arr mysql_fetch_row($res);
if (
$arr[0] >= $maxusers)
    
stderr("Error""Sorry, user limit reached. Please try again later.");

if (!
mkglobal("wantusername:wantpassword:passagain:email"))
    die();

function 
bark($msg) {
  
stdhead();
    
stdmsg("Signup failed!"$msg);
  
stdfoot();
  exit;
}

function 
validusername($username)
{
    if (
$username == "")
      return 
false;

    
// The following characters are allowed in user names
    
$allowedchars "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_";

    for (
$i 0$i strlen($username); ++$i)
      if (
strpos($allowedchars$username[$i]) === false)
        return 
false;

    return 
true;
}

function 
isportopen($port)
{
    
$sd = @fsockopen($_SERVER["REMOTE_ADDR"], $port$errno$errstr1);
    if (
$sd)
    {
        
fclose($sd);
        return 
true;
    }
    else
        return 
false;
}
/*
function isproxy()
{
    $ports = array(80, 88, 1075, 1080, 1180, 1182, 2282, 3128, 3332, 5490, 6588, 7033, 7441, 8000, 8080, 8085, 8090, 8095, 8100, 8105, 8110, 8888, 22788);
    for ($i = 0; $i < count($ports); ++$i)
        if (isportopen($ports[$i])) return true;
    return false;
}
*/
if (empty($wantusername) || empty($wantpassword) || empty($email))
    
bark("Don't leave any fields blank.");

if (
strlen($wantusername) > 12)
    
bark("Sorry, username is too long (max is 12 chars)");

if (
$wantpassword != $passagain)
    
bark("The passwords didn't match! Must've typoed. Try again.");

if (
strlen($wantpassword) < 6)
    
bark("Sorry, password is too short (min is 6 chars)");

if (
strlen($wantpassword) > 40)
    
bark("Sorry, password is too long (max is 40 chars)");

if (
$wantpassword == $wantusername)
    
bark("Sorry, password cannot be same as user name.");

if (!
validemail($email))
    
bark("That doesn't look like a valid email address.");

if (!
validusername($wantusername))
    
bark("Invalid username.");


// check if email addy is already in use
$a = (@mysql_fetch_row(@mysql_query("select count(*) from users where email='$email'"))) or die(mysql_error());
if (
$a[0] != 0)
  
bark("The e-mail address $email is already in use.");

/*
// do simple proxy check
if (isproxy())
    bark("You appear to be connecting through a proxy server. Your organization or ISP may use a transparent caching HTTP proxy. Please try and access the site on <a href=http://torrentbits.org:81/signup.php>port 81</a> (this should bypass the proxy server). <p><b>Note:</b> if you run an Internet-accessible web server on the local machine you need to shut it down until the sign-up is complete.");
*/
$secret mksecret();
$wantpasshash md5($secret $wantpassword $secret);
$editsecret = (!$arr[0]?""ENA_EMAIL_CONFIRM?mksecret():"");

$ret mysql_query($q=("INSERT INTO users (username, passhash, secret, editsecret, email, added, status" .
        (!
$arr[0]?", class":"") . (!ENA_EMAIL_CONFIRM?", last_access, enabled":"") . ") VALUES (" .
        
implode(","array_map("sqlesc"
            array(
$wantusername$wantpasshash$secret$editsecret$emailget_date_time()))) .
            
",'" . (!$arr[0] || !ENA_EMAIL_CONFIRM?'confirmed':'pending') ."'" .
            (!
$arr[0]?', '.UC_SYSOP:''). 
            (!
ENA_EMAIL_CONFIRM?", '"get_date_time() ."', 'yes'":'') .')'));

if (!
$ret) {
    if (
mysql_errno() == 1062)
        
bark("Username already exists!");
    
bark("borked");
}

$id mysql_insert_id();

//write_log("User account $id ($wantusername) was created");

$psecret md5($editsecret);

$body = <<<EOD
O teu registo no Tracker da RevAnime foi efectuado com sucesso.

Entraste na zona da fansubber onde poderás fazer o download de todos os trabalhos lançados por nós.
Caso não encontres o que procuras, poderás sempre pedir um re-seed no nosso fórum que, posteriormente, será partilhado aqui no tracker. http://forum.revanime.com/index.php?topic=227.0

Pensa na comunidade e mantém um bom rácio de partilha. A RevAnime agradece :)


Após o registo, se não conseguires fazer Login, clica no link abaixo:

$DEFAULTBASEURL/confirm.php?id=$id&secret=$psecret
EOD;

if(
$arr[0] || ENA_EMAIL_CONFIRM)
  
mail($email"$SITENAME user registration confirmation"$body"From: $SITEEMAIL""-f$SITEEMAIL");
else 
  
logincookie($id$wantpasshash);

header("Refresh: 0; url=ok.php?type=". (!$arr[0]?"sysop"ENA_EMAIL_CONFIRM ? ("signup&email=" urlencode($email)):"confirm"));

?>
login.php
PHP Code:
<?php

require_once("include/bittorrent.php");



stdhead("Login");

unset(
$returnto);
if (!empty(
$_GET["returnto"])) {
    
$returnto $_GET["returnto"];
    if (!
$_GET["nowarn"]) {
        print(
"\n");
    }
}
$number_logos 2;
$first 1;
$random mt_rand($first$number_logos);
$logo "pic/logo/logo$random.png";
?>
<form method="post" action="takelogin.php">


<?
    
{print("<img src=$logo>\n");}
    
?>

<?//<p><h1>Bem-vindo ao Tracker da RevAnime.</h1></p>?>

<table border="0" cellpadding=5>
<tr><td class=rowhead>Username:</td><td align=left><input type="text" size=28 name="username" /></td></tr>
<tr><td class=rowhead>Password:</td><td align=left><input type="password" size=28 name="password" /></td></tr>
<!--<tr><td class=rowhead>Duration:</td><td align=left><input type=checkbox name=logout value='yes' checked>Log out automático após 15 minutos de inactividade</td></tr>-->

<tr><td colspan="2" align="center"><input type="submit" value="Entrar!" class=btn></td></tr>
</table>

<?

if (isset($returnto))
    print(
"<input type=\"hidden\" name=\"returnto\" value=\"" htmlspecialchars($returnto) . "\" />\n");

?>
</form>
<p>Esqueceste a tua password? Para receberes uma nova, clica <a href="recover.php"><b>aqui</b></a>.</br></br>Não te esqueças que 6 tentativas falhadas de Login apagam a tua conta de forma automática.</p>

<?
stdfoot
();
?>
takelogin.php
PHP Code:
<?php

require_once("include/bittorrent.php");

if (!
mkglobal("username:password"))
    die();



function 
bark($text "Username or password incorrect")
{
  
stderr("Login failed!"$text);
}

$res mysql_query("SELECT id, passhash, secret, enabled FROM users WHERE username = " sqlesc($username) . " AND status = 'confirmed'");
$row mysql_fetch_assoc($res);

if (!
$row)
    
bark();

if (
$row["passhash"] != md5($row["secret"] . $password $row["secret"]))
    
bark();

if (
$row["enabled"] == "no")
    
bark("This account has been disabled.");

logincookie($row["id"], $row["passhash"]);

if (!empty(
$_POST["returnto"]))
    
header("Location: $_POST[returnto]");
else
    
header("Location: index.php");

?>


logout.php

PHP Code:
<?php

require_once("include/bittorrent.php");



logoutcookie();

//header("Refresh: 0; url=./");
Header("Location: $BASEURL/");

?>


include/bittorrent.php

PHP Code:
<?php
$stime
=array_sum(explode(' ',microtime()));

// Rules for torrent limitation
// Format is Ratio:UpGigs:SeedsMax:LeechesMax:AllMax|...
// Ratio and UpGigs are "minimum" requirements.
$GLOBALS["TORRENT_RULES"] = "0:0:10:2:12|1.01:5:10:3:13|2.01:20:10:4:14";

function 
get_torrent_limits($userinfo)
{
$limit = array("seeds" => -1"leeches" => -1"total" => -1);

if (
$userinfo["tlimitall"] == 0) {
// Auto limit
$ruleset explode("|"$GLOBALS["TORRENT_RULES"]);
$ratio = (($userinfo["downloaded"] > 0) ? ($userinfo["uploaded"] / $userinfo["downloaded"]) : (($userinfo["uploaded"] > 0) ? 0));
$gigs $userinfo["uploaded"] / 1073741824;

$limit = array("seeds" => 0"leeches" => 0"total" => 0);
foreach (
$ruleset as $rule) {
$rule_partsexplode(":"$rule);
if (
$ratio >= $rule_parts[0] && $gigs >= $rule_parts[1] && $limit["total"] <= $rule_parts[4]) {
$limit["seeds"] = $rule_parts[2];
$limit["leeches"] = $rule_parts[3];
$limit["total"] = $rule_parts[4];
}
}
} elseif (
$userinfo["tlimitall"] > 0) {
// Manual limit
$limit["seeds"] = $userinfo["tlimitseeds"];
$limit["leeches"] = $userinfo["tlimitleeches"];
$limit["total"] = $userinfo["tlimitall"];
}
return 
$limit;
}
//=== end function

function local_user()
{
  return 
$_SERVER["SERVER_ADDR"] == $_SERVER["REMOTE_ADDR"];
}

if(!
file_exists('include/config.php'))

        die(
"<img src=http://tracker.revanime.net/pic/at-work.gif><br><br>Site is down for maintenance, please check back again later... thanks<br>");
require_once(
'include/config.php');
if(empty(
$mysql_user) && empty($mysql_pass) && empty($mysql_email))
        die(
"Site is down for maintenance, please check back again later... thanks<br>");

require_once(
'include/cleanup.php');
require_once(
'include/global.php');

/**** validip/getip courtesy of manolete <manolete@myway.com> ****/

// 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;
}

// Patched function to detect REAL IP address if it's valid
/*
function getip()
{
        //global $HTTP_SERVER_VARS;
        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 getip() {
    if (isset(
$_SERVER)) {
      if (isset(
$_SERVER['HTTP_X_FORWARDED_FOR'])) {
        
$ip $_SERVER['HTTP_X_FORWARDED_FOR'];
      } elseif (isset(
$_SERVER['HTTP_CLIENT_IP'])) {
        
$ip $_SERVER['HTTP_CLIENT_IP'];
      } else {
        
$ip $_SERVER['REMOTE_ADDR'];
      }
    } else {
      if (
getenv('HTTP_X_FORWARDED_FOR')) {
        
$ip getenv('HTTP_X_FORWARDED_FOR');
      } elseif (
getenv('HTTP_CLIENT_IP')) {
        
$ip getenv('HTTP_CLIENT_IP');
      } else {
        
$ip getenv('REMOTE_ADDR');
      }
    }

    return 
$ip;
  }



function 
userlogin() {
    global 
$SITE_ONLINE;
    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 (!
$SITE_ONLINE || empty($_COOKIE["uid"]) || empty($_COOKIE["pass"]))
        return;
    
$id $_COOKIE["uid"];
    if (!
$id || strlen($_COOKIE["pass"]) != 32)
        return;
    
$res mysql_query("SELECT * 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;
    
mysql_query("UPDATE users SET last_access='" get_date_time() . "', ip='$ip' WHERE id=" $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,MYSQL_NUM);
    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 10242) . " kB";
    elseif (
$bytes 1000 1048576)
        return 
number_format($bytes 10485762) . " MB";
    elseif (
$bytes 1000 1073741824)
        return 
number_format($bytes 10737418242) . " GB";
    else
        return 
number_format($bytes 10995116277762) . " 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 (
$v[0] == "!")
        {
            
$v substr($v1);
            
$opt true;
        }
        else
            
$opt false;
        if (isset(
$_GET[$v]))
            
$GLOBALS[$v] = unesc($_GET[$v]);
        elseif (isset(
$_POST[$v]))
            
$GLOBALS[$v] = unesc($_POST[$v]);
        elseif (!
$opt)
            return 
0;
    }
    return 
1;
}

function 
tr($x,$y,$noesc=0) {
    if (
$noesc)
        
$a $y;
    else {
        
$a htmlspecialchars($y);
        
$a str_replace("\n""<br />\n"$a);
    }
    print(
"<tr><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($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 
"<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;
}
//dub subs mod
function subs() {
             
$ret = array();
             
$res mysql_query("SELECT id, name FROM subs ORDER BY name");
             while (
$row mysql_fetch_assoc($res))
                 
$ret[] = $row;
             return 
$ret;
         }
        
         function 
dub() {
             
$ret = array();
             
$res mysql_query("SELECT id, name FROM dub ORDER BY name");
             while (
$row mysql_fetch_assoc($res))
                 
$ret[] = $row;
             return 
$ret;
         }
         
//
function stdhead($title ""$msgalert true) {
    global 
$CURUSER$SITE_ONLINE$FUNDS$SITENAME$BASEURL$pic_base_url;
    


  if (!
$SITE_ONLINE)
    die(
"Site is down for maintenance, please check back again later... thanks<br>");

    
header("Content-Type: text/html; charset=iso-8859-1");
    
//header('Content-Type: text/html; charset=utf-8');
    //header('Content-Language content="en-us"');
    //header("Content-Type: text/html; charset=latin1");
    //header("Pragma: No-cache");
    
if ($title == "")
        
$title $SITENAME .(isset($_GET['tbv'])?" (".TBVERSION.")":'');
    else
        
$title $SITENAME .(isset($_GET['tbv'])?" (".TBVERSION.")":''). " :: " htmlspecialchars($title);
  if (
$CURUSER)
  {
    
$ss_a = @mysql_fetch_assoc(@mysql_query("select uri from stylesheets where id=" $CURUSER["stylesheet"]));
    if (
$ss_a$ss_uri $ss_a["uri"];
  }
  if (!isset(
$ss_uri))
  {
    (
$r mysql_query("SELECT uri FROM stylesheets WHERE id=1")) or die(mysql_error());
    (
$a mysql_fetch_assoc($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><head>
<title><?= $title ?></title>
<link rel="stylesheet" href="/<?=$ss_uri?>" type="text/css">
</head>
<body>
<table width=100% cellspacing=0 cellpadding=0 style='background: transparent'>
<tr>
<td class=clear width=49%>
</td>
<td class=clear>
<div align=center>
<img src="<?=$pic_base_url?>trackerlogonatal.gif" align=center>
</div>
</td>
<td class=clear width=49% align=right>
</td>
</tr></table>

<?php

$w 
"width=100%";
//if ($_SERVER["REMOTE_ADDR"] == $_SERVER["SERVER_ADDR"]) $w = "width=984";

?>
<table class=mainouter <?=$w?> border="1" cellspacing="0" cellpadding="10">

<!------------- MENU ------------------------------------------------------------------------>

<? $fn substr($_SERVER['PHP_SELF'], strrpos($_SERVER['PHP_SELF'], "/") + 1); ?>
<tr><td class=outer align=center>
<table class=main width=900 cellspacing="0" cellpadding="10" border="0">
<tr>
<input type=button onClick="location.href='index.php'" style="height:26;font: bold 12px Tahoma;" value='¤ Início ¤'>&nbsp;&nbsp;
<input type=button onClick="location.href='forum.php'" style="height:26;font: bold 12px Tahoma;" value='¤ Fórum ¤'>&nbsp;&nbsp;
<input type=button onClick="location.href='browse.php'" style="height:26;font: bold 12px Tahoma;" value='¤ Tracker ¤'>&nbsp;&nbsp;
<input class="button space" type="button" style="height:26;font: bold 12px Tahoma;" value="¤ RevAniDB ¤"
onclick="window.open('http://db.revanime.net','_blank');" />&nbsp;&nbsp;
<input type=button onClick="location.href='staff.php'" style="height:26;font: bold 12px Tahoma;" value='¤ Staff ¤'>&nbsp;&nbsp;

<? if (!$CURUSER) { ?>
<input type=button align=right onClick="location.href='signup.php'" style="height:26;font: bold 12px Tahoma;" value='¤ Registar ¤'>

<? } else { ?>
<input type=button onClick="location.href='logout.php'" style="height:26;font: bold 12px Tahoma;" value='¤ Sair ¤'>

<?/*
<input type=button onClick="location.href='login.php'" style="height:26;font: bold 12px Tahoma;" value='¤ Entrar ¤'>&nbsp;&nbsp;
<input type=button onClick="location.href='logout.php'" style="height:26;font: bold 12px Tahoma;" value='¤ Sair ¤'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<input class="button space" type="button" style="height:26;font: bold 12px Tahoma;" value="¤ Fórum ¤"
onclick="window.open('http://forum.revanime.net','_blank');" />&nbsp;&nbsp;
<input class="button space" type="button" style="height:26;font: bold 12px Tahoma;" value="¤ RevAniDB ¤"
onclick="window.open('http://db.revanime.net','_blank');" />
*/
?>

<? ?>
</tr>
<!-- /////// some vars for the statusbar;o) //////// -->
<? if ($CURUSER) { ?>

<?

$datum 
getdate();
$datum[hours] = sprintf("%02.0f"$datum[hours]);
$datum[minutes] = sprintf("%02.0f"$datum[minutes]);
//$datum = gmdate("H:i", time() + (($CURUSER["timezone"] + $CURUSER["dst"]) * 60));


$uped mksize($CURUSER['uploaded']);

$downed mksize($CURUSER['downloaded']);

if (
$CURUSER["downloaded"] > 0)

{

$ratio $CURUSER['uploaded'] / $CURUSER['downloaded'];

$ratio number_format($ratio3);

$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 IN ('in', 'both')") 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 IN ('in', 'both') 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 location IN ('out', 'both')") 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='Recebidas (mensagens novas)' src=pic/pn_inboxnew.gif>";

else

$inboxpic "<img height=14px style=border:none alt=inbox title='Recebidas (não há novas mensagens)' src=pic/pn_inbox.gif>";

//// check active torrents ///////////////////////

$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];

$tlimitseeds $CURUSER["tlimitseeds"];
$tlimitleeches $CURUSER["tlimitleeches"];

//// end







$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 "<a title='well done good connection'><b><font color=green>Sim</a></font></b>";
}else{
$connectable "<b><a title='need to fix this'><font color=red>Não</a></font></b>";
}
}else{
$connectable ="<b><a title='Unknown connection still'><font color=orange><i>Aguarda Announce</i></font></a></b>";
}
//torents novos
$datum[hours]=$datum[hours];
$res mysql_query("SELECT COUNT(id) AS new_torrents FROM torrents WHERE UNIX_TIMESTAMP(added) >= ".($CURUSER['last_browse'] > gmtime() ? gmtime() : $CURUSER['last_browse'])) or sqlerr(__FILE____LINE__);
$arr mysql_fetch_assoc($res);
$new_torrents = (int)$arr['new_torrents'];


//torrents novos
?>




<!-- //////// start the statusbar ///////////// -->



<center><table cellpadding="4" cellspacing="1" border="0" style="width:100%" background="transparent">


<br>
<tr>


<td ><table style="width:100%" cellspacing="0" cellpadding="0" border="0" background="transparent">

<tr>

<td class="bottom" align="left"><span class="smallfont"><b><a href="userdetails.php?id=<?=$CURUSER['id']?>"><?=$CURUSER['username']?></a></b><?=$medaldon?><?=$warn?>&nbsp;•&nbsp;[<a href="my.php">Editar Perfil</a>]&nbsp;•&nbsp;<font color=1900D1>Torrents Activos:</font></span> <img alt="Torrents seeding" title="Torrents seeding" src="pic/arrowup.gif">&nbsp;<font color=black><span class="smallfont"><?=$activeseed?>&nbsp;(<?=$tlimitseeds?>)</span></font>&nbsp;&nbsp;<img alt="Torrents leeching" title="Torrents leeching" src="pic/arrowdown.gif">&nbsp;<font color=black><span class="smallfont"><?=$activeleech?>&nbsp;(<?=$tlimitleeches?>)&nbsp;•&nbsp;<font color=1900D1>Rácio:</font><?=$ratio?>&nbsp;•&nbsp;<font color=green>Enviado:</font><font color=black><?=$uped?></font>&nbsp;•&nbsp;<font color=darkred>Recebido:</font><font color=black><?=$downed?></font>&nbsp;•&nbsp;<font color=1900D1>Conectável:</font> <?=$connectable?></span></font></td>


<td class="bottom" align="right"><span class="smallfont">


<?

if ($messages){

print(
"<span class=smallfont><a href=inbox.php>$inboxpic</a> $messages (Novas: $unread)</span>");

if (
$outmessages)

print(
"<span class=smallfont>&nbsp;&nbsp;<a href=inbox.php?out=1><img height=14px style=border:none alt=sentbox title=Enviadas src=pic/pn_sentbox.gif></a> $outmessages</span>");

else

print(
"<span class=smallfont>&nbsp;&nbsp;<a href=inbox.php?out=1><img height=14px style=border:none alt=sentbox title=Enviadas src=pic/pn_sentbox.gif></a> 0</span>");

}

else

{

print(
"<span class=smallfont><a href=inbox.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>&nbsp;&nbsp;<a href=inbox.php?out=1><img height=14px style=border:none alt=sentbox title=Enviadas src=pic/pn_sentbox.gif></a> $outmessages</span>");

else

print(
"<span class=smallfont>&nbsp;&nbsp;<a href=inbox.php?out=1><img height=14px style=border:none alt=sentbox title=Enviadas src=pic/pn_sentbox.gif></a> 0</span>");

}

?>

</span></td>



</tr>

</table>

<p>

<? }?>
</table>
</td>
</tr>

<tr><td align=center class=outer style="padding-top: 20px; padding-bottom: 20px">
<?
//
if ($new_torrents)
{
    
?><table border='0' cellspacing='0' cellpadding='10' align="center"><tr><td style="background-color:green;">
    <a href='/browse.php' title="Clica para ver <?php echo ($new_torrents == '' ''); ?>"><font color='white'><b>Novos torrents no tracker : <?php echo ($new_torrents == '' '').' '.$new_torrents.' '.($new_torrents '' ''); ?></font></b></a>
    </td></tr></table><?php
}
//
if (isset($unread) && $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/inbox.php><font color=white>Tens $unread mensagem nova" . ($unread "s" "") . "!</font></a></b>");
  print(
"</td></tr></table></p>\n");
}
  
//nova poll
if ($CURUSER){
    
$res mysql_query("SELECT * FROM polls ORDER BY added DESC LIMIT 1") or sqlerr();
    
$arr mysql_fetch_assoc($res) or die();
    
$pollid $arr["id"];
    
$userid $CURUSER["id"];
    
$question $arr["question"];
    
$res mysql_query("SELECT * FROM pollanswers WHERE pollid=$pollid && userid=$userid") or sqlerr();
    
$arr2 mysql_fetch_assoc($res);
  
$voted $arr2;
  if (
$voted)
  {
  }
else
  {
print(
"<p><table border=0 cellspacing=0 cellpadding=10 bgcolor=green><tr><td style='padding: 10px; background: green'>\n");
print(
"<b><a href=$BASEURL/newpoll.php><font color=white>Existe uma nova poll no Tracker.   Por favor, deixa o teu voto.</font></a></b>");
print(
"</td></tr></table></p><p></p>\n");
  }
}
  
//nova poll

// stdhead 

function stdfoot() {
  global 
$pic_base_url;
  print(
"</td></tr></table>\n");
  print(
"<table class=bottom width=100% border=0 cellspacing=10 cellpadding=10><tr valign=top>\n");
  
/*print("<td class=bottom align=left width=49%><img src=\"{$pic_base_url}bottom_left.gif\"></td><td width=49% align=right class=bottom><img src=\"{$pic_base_url}bottom_right.gif\"></td>\n");
  */
  
print("<td class=bottom align=center width=49%><img src=\"{$pic_base_url}Apoio_Fansubs.gif\"></td>\n");
  print(
"</tr></table>\n");
  print(
"</body></html>\n");
}

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(0255));
    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());
}

/*
function logincookie($id, $password, $secret, $updatedb = 1, $expires = 0x7fffffff) {
    $md5 = md5($secret . $password . $secret);
    setcookie("uid", $id, $expires, "/");
    setcookie("pass", $md5, $expires, "/");

    if ($updatedb)
        mysql_query("UPDATE users SET last_login = NOW() WHERE id = $id");
}
*/

function logincookie($id$passhash$updatedb 1$expires 0x7fffffff)
{
    
setcookie("uid"$id$expires"/");
    
setcookie("pass"$passhash$expires"/");

  if (
$updatedb)
      
mysql_query("UPDATE users SET last_login = NOW() WHERE id = $id");
}


function 
logoutcookie() {
    
setcookie("uid"""0x7fffffff"/");
    
setcookie("pass"""0x7fffffff"/");
}

function 
loggedinorreturn() {
    global 
$CURUSER,$BASEURL;
    if (!
$CURUSER) {
        
header("Location: $BASEURL/login.php?returnto=" urlencode($_SERVER['PHP_SELF']));
        exit();
    }
}

function 
deletetorrent($id) {
  global 
$torrent_dir;
  
mysql_query("DELETE FROM torrents WHERE id = $id");
  
mysql_query("DELETE FROM torrentsd WHERE tid = $id");
  
mysql_query("DELETE FROM snatched WHERE torrentid = $id");
  foreach(
explode(".","peers.files.comments.ratings") as $x)
      
mysql_query("DELETE FROM $x WHERE torrent = $id");
  
unlink("$torrent_dir/$id.torrent");
}

function 
deletefansubber($id) {
  
mysql_query("DELETE FROM fansubbers WHERE id = $id");
}

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 $_GET["page"];
        if (
$page 0)
            
$page $pagedefault;
    }
    else
        
$page $pagedefault;

    
$pager "";

    
$mp $pages 1;
    
$as "<b>&lt;&lt;&nbsp;Anterior</b>";
    if (
$page >= 1) {
        
$pager .= "<a href=\"{$href}page=" . ($page 1) . "\">";
        
$pager .= $as;
        
$pager .= "</a>";
    }
    else
        
$pager .= $as;
    
$pager .= "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
    
$as "<b>Seguinte&nbsp;&gt;&gt;</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&nbsp;-&nbsp;$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 => 0seeders => 0comments => 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,$pic_base_url;
    
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($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_base_url}star.gif\" alt='Donor'>" "") . ($row["warned"] == "yes" "<img src=".
                
"\"{$pic_base_url}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&amp;cid=$row[id]>Edit</a>]" "") .
            (
get_user_class() >= UC_MODERATOR "- [<a href=comment.php?action=delete&amp;cid=$row[id]>Delete</a>]" "") .
        (
$row["editedby"] && get_user_class() >= UC_MODERATOR "- [<a href=comment.php?action=vieworiginal&amp;cid=$row[id]>View original</a>]" "") . "</p>\n");    
        
$avatar = ($CURUSER["avatars"] == "yes" htmlspecialchars($row["avatar"]) : "");
        if (!
$avatar)
            
$avatar "{$pic_base_url}default_avatar.gif";
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";


$signature = ($CURUSER["signatures"] == "yes" htmlspecialchars($row["signature"]) : "");  
if (
$signature)
  
$info format_comment($signature);

        
begin_table(true);
        print(
"<tr valign=top>\n");
        print(
"<td align=center width=100 style='padding: 0px'><img width=100 src=\"$avatar\"></td>\n");
        print(
"<td class=text>" format_comment($row["text"]));
        print(
$editedby."<hr />\n");
        print(
format_comment($signature)."</td>\n");
        print(
"</tr>\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() {
$ret = array();
$res mysql_query("SELECT id, name, image FROM categories ORDER BY id");
while (
$row mysql_fetch_array($res))
$ret[] = $row;
return 
$ret;
}

function 
fansubberslist() {
$ret2 = array();
$res2 mysql_query("SELECT id, name, tag, logof FROM fansubbers ORDER BY name");
while (
$row2 mysql_fetch_array($res2))
$ret2[] = $row2;
return 
$ret2;
}

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 || $r 5)
        return;
    return 
"<img src=\"{$pic_base_url}{$r}.gif\" border=\"0\" alt=\"rating: $num / 5\" />";
}

function 
torrenttable($res$variant "index") {
    global 
$pic_base_url$CURUSER;
$browse_res mysql_query("SELECT last_browse FROM users WHERE id='".$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)
  {
      
$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=5>
<tr>

<td class="colhead" align="center"><img src=http://tracker.revanime.net/pic/download.gif></td>
<td class="colhead" align="center">[Fansubber] Torrent</td>
<!--<td class="heading" align=left>DL</td>-->
<?
    
if ($wait)
    {
        print(
"<td class=\"colhead\" align=\"center\">Wait</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>Tipo</td>
<td class="colhead" align=right>Ficheiros</td>
<td class="colhead" align=right><img src=http://tracker.revanime.net/pic/comments.gif></td>
<!--<td class="colhead" align="center">Rating</td>-->
<td class="colhead" align="center"><img src=http://tracker.revanime.net/pic/clock.png></td>
<td class="colhead" align="center">Tamanho</td>
<!--
<td class="colhead" align=right>Visto</td>
<td class="colhead" align=right>Hits</td>
-->
<td class="colhead" align="center"><img src=http://tracker.revanime.net/pic/icon_completed.gif></td>
<td class="colhead" align="center"><img src=http://tracker.revanime.net/pic/arrowup.gif></td>
<td class="colhead" align="center"><img src=http://tracker.revanime.net/pic/arrowdown.gif></td>
<td class="colhead" align="center">Transferido</td>
<?

    
if ($variant == "index")
        print(
"<td class=\"colhead\" align=center><img src=http://tracker.revanime.net/pic/folder_arrow.gif></td>\n");
 if (
get_user_class() >= UC_SYSOP) { ?>
  <td class="colhead" align="center">#</td>
<? }
    print(
"</tr>\n");

 
 
    while (
$row mysql_fetch_assoc($res)) {
        
$id $row["id"];
        print(
"<tr>\n");

        print(
"<td align=center style='padding: 0px'>");
        
 

if (isset(
$row["cat_name"])) {
//if ($row['banned'] != "no"){
            
print("<a href=\"download.php".
        (
ENA_ALTANNOUNCE?("/$id/" rawurlencode($row["filename"])):("?id=$id&name="rawurlencode($row["filename"]))) . "\">");
        if (isset(
$row['poster']) && $row['poster'] != "")
echo
'<img border="0" src='.$row['poster'].' height="44" alt="'.$row['cat_name'].'" />';
            else
                print(
$row["cat_name"]);
                
                
//if ($row['banned'] != "yes")
            
print("</a>");
        }
        else
            print(
"-");
            print(
"</td>\n");

///////////////////////////////////////////////fansubbers
$res2 mysql_query("SELECT fansubbers.name as f_name, fansubbers.tag AS f_tag, fansubbers.id AS f_id FROM fansubbers 
LEFT JOIN torrents ON torrents.fansubber = fansubbers.id WHERE torrents.id = 
$id")
or 
sqlerr();
$row2 mysql_fetch_assoc($res2);
///////////////////////////////////////////////fansubbers

        
$dispname htmlspecialchars($row["name"]);
        print(
"<td align=left>&nbsp;<a href=\"fansubbersdetails.php?id="$row2["f_id"] ."\" class=altlink><b>[" $row2["f_tag"] . "]</b></a>&nbsp;<a class=altlink href=\"details.php?");
        if (
$variant == "mytorrents")
            print(
"returnto=" urlencode($_SERVER["REQUEST_URI"]) . "&amp;");
        print(
"id=$id");
        if (
$variant == "index")
            print(
"&amp;hit=1");
$no_download = ($row[banned]=="yes" "<img title='Download bloqueado' src='pic/no_download.gif' />" "");
$thisisfree = ($row[free]=="yes" "<img title='Torrent grátis - Donwload não contabilizado' src='pic/freedownload.gif' />" "");
        if (
sql_timestamp_to_unix_timestamp($row["added"]) >= $last_browse)
        print(
"\"><font color=black><b>$dispname</b></font></a> $thisisfree &nbsp;$no_download&nbsp;<b>(<font color=red>Novo</font>)</b>\n");
        else
        print(
"\"><font color=black><b>$dispname</b></font></a> $thisisfree &nbsp;$no_download&nbsp; \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#dl8\"><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_base_url}viewnfo.gif border=0 alt='View NFO'></a>\n");
        if ($variant == "index")
            print("<a href=\"download.php?id=$id&name=" . rawurlencode($row["filename"]) . "\"><img src={$pic_base_url}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"]) . "&amp;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[dvd]=="yes")
if (isset($row["miniposter"]))
print(
"<td align=\"center\"><img title='Projecto "$row2["f_name"] ."' src='".$row["miniposter"]."'></td>\n");
else
                print(
$row["miniposter"]);
 
//           print("</a>");
//else
//print("<td align=\"center\"><img src='pic/reva2.png' /></td>\n");

        
if ($row["type"] == "single")
            print(
"<td align=\"right\">" $row["numfiles"] . "</td>\n");
        else {
            if (
$variant == "index")
                print(
"<td align=\"right\"><b><a href=\"details.php?id=$id&amp;hit=1&amp;filelist=1\">" $row["numfiles"] . "</a></b></td>\n");
            else
                print(
"<td align=\"right\"><b><a href=\"details.php?id=$id&amp;filelist=1#filelist\">" $row["numfiles"] . "</a></b></td>\n");
        }

        if (!
$row["comments"])
            print(
"<td align=\"right\">" $row["comments"] . "</td>\n");
        else {
            if (
$variant == "index")
                print(
"<td align=\"right\"><b><a href=\"details.php?id=$id&amp;hit=1&amp;tocomm=1\">" $row["comments"] . "</a></b></td>\n");
            else
                print(
"<td align=\"right\"><b><a href=\"details.php?id=$id&amp;page=0#startcomments\">" $row["comments"] . "</a></b></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");
*/
        
print("<td align=center><nobr>" str_replace(" ""<br />"$row["added"]) . "</nobr></td>\n");
        print(
"<td align=center>" str_replace(" ""<br>"mksize($row["size"])) . "</td>\n");
//        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><a href=viewsnatches.php?id=$row[id]>" .          number_format($row["times_completed"]) . "<br></a></td>\n");

        if (
$row["seeders"]) {
            if (
$variant == "index")
            {
               if (
$row["leechers"]) $ratio $row["seeders"] / $row["leechers"]; else $ratio 1;
                print(
"<td align=right><b><a href=details.php?id=$id&amp;hit=1&amp;toseeders=1><font color=" .
                  
get_slr_color($ratio) . ">" $row["seeders"] . "</font></a></b></td>\n");
            }
            else
                print(
"<td align=\"right\"><b><a class=\"" linkcolor($row["seeders"]) . "\" href=\"details.php?id=$id&amp;dllist=1#seeders\">" .
                  
$row["seeders"] . "</a></b></td>\n");
        }
        else
            print(
"<td align=\"right\"><span class=\"" linkcolor($row["seeders"]) . "\">" $row["seeders"] . "</span></td>\n");

        if (
$row["leechers"]) {
            if (
$variant == "index")
                print(
"<td align=right><b><a href=details.php?id=$id&amp;hit=1&amp;todlers=1>" .
                   
number_format($row["leechers"]) . ($peerlink "</a>" "") .
                   
"</b></td>\n");
            else
                print(
"<td align=\"right\"><b><a class=\"" linkcolor($row["leechers"]) . "\" href=\"details.php?id=$id&amp;dllist=1#leechers\">" .
                  
$row["leechers"] . "</a></b></td>\n");
        }
        else
            print(
"<td align=\"right\">0</td>\n");
$data mysql_query("SELECT size * times_completed AS data FROM torrents WHERE id = '$id' AND times_completed >= '1' GROUP BY id ORDER BY added ASC LIMIT 10") or sqlerr(__FILE____LINE__);  $a mysql_fetch_assoc($data);
  
$data mksize($a["data"]) . "";  
print(
"<td align=\"right\">" $data "</td>\n");

if (
$variant == "index")

            print(
"<td align=center>" . (isset($row["username"]) ? ("<a href=userdetails.php?id=" $row["owner"] . "><b>" htmlspecialchars($row["username"]) . "</b></a>") : "<i>(unknown)</i>") . "</td>\n");



if (
$CURUSER['class'] >= UC_SYSOP) {
       print(
"<td align=center><a href=\"edit.php?returnto=" urlencode($_SERVER["REQUEST_URI"]) . "&id=" $row["id"] . " alt=edit\"><font color=red>E</font></a></td>\n"); 
//print(" / <a href=\"fastdelete.php?id=$row[id]\"><b>D</b></a></td>\n");
       
         
print("</tr>\n");
    }
     
    }
    print(
"</table>\n");

    return 
$rows;
}
/*
function hit_start() {
    return;
    global $RUNTIME_START, $RUNTIME_TIMES;
    $RUNTIME_TIMES = posix_times();
    $RUNTIME_START = gettimeofday();
}

function hit_count() {
    return;
    global $RUNTIME_CLAUSE;
    if (preg_match(',([^/]+)$,', $_SERVER["SCRIPT_NAME"], $matches))
        $path = $matches[1];
    else
        $path= "(unknown)";
    $period = date("Y-m-d H") . ":00:00";
    $RUNTIME_CLAUSE = "page = " . sqlesc($path) . " AND period = '$period'";
    $update = "UPDATE hits SET count = count + 1 WHERE $RUNTIME_CLAUSE";
    mysql_query($update);
    if (mysql_affected_rows())
        return;
    $ret = mysql_query("INSERT INTO hits (page, period, count) VALUES (" . sqlesc($path) . ", '$period', 1)");
    if (!$ret)
        mysql_query($update);
}

function hit_end() {
    return;
    global $RUNTIME_START, $RUNTIME_CLAUSE, $RUNTIME_TIMES;
    if (empty($RUNTIME_CLAUSE))
        return;
    $now = gettimeofday();
    $runtime = ($now["sec"] - $RUNTIME_START["sec"]) + ($now["usec"] - $RUNTIME_START["usec"]) / 1000000;
    $ts = posix_times();
    $sys = ($ts["stime"] - $RUNTIME_TIMES["stime"]) / 100;
    $user = ($ts["utime"] - $RUNTIME_TIMES["utime"]) / 100;
    mysql_query("UPDATE hits SET runs = runs + 1, runtime = runtime + $runtime, user_cpu = user_cpu + $user, sys_cpu = sys_cpu + $sys WHERE $RUNTIME_CLAUSE");
}
*/
function hash_pad($hash) {
    return 
str_pad($hash20);
}

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)
{
    global 
$pic_base_url;
    
    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" "<img src=\"{$pic_base_url}{$donorpic}\" alt='Donor' border=0 $style>" "";
    if (
$arr["enabled"] == "yes")
        
$pics .= $arr["warned"] == "yes" "<img src=\"{$pic_base_url}{$warnedpic}\" alt=\"Warned\" border=0 $style>" "";
    else
        
$pics .= "<img src=\"{$pic_base_url}{$disabledpic}\" alt=\"Disabled\" border=0 $style>\n";
    return 
$pics;
}

function 
verify_passkey($passkey)
{
  global 
$CURUSER;
  if (
strlen($CURUSER['passkey']) != 32
  {
      do {
             
$CURUSER['passkey'] = md5($CURUSER['username'].get_date_time().$CURUSER['passhash']);
            
$notok=mysql_query("UPDATE users SET passkey='$CURUSER[passkey]' WHERE id=$CURUSER[id]") === FALSE;
        } while(
$notok);
    }
    
    return(
$CURUSER['passkey']==$passkey);
}

$number_logos 4;
$first 1;
$random mt_rand($first$number_logos);
$logo "pic/logo/logo$random.png";
// Old dbconn() function, now isn't called, but is done automatically when it's included
    
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><center><img src=$logo></center><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());
        
// new line here
    //$res=mysql_query('SET NAMES "latin1" COLLATE "latin1_swedish_ci"') or sqlerr(__FILE__,__LINE__);
// end new line

    
userlogin();

    if (
basename($_SERVER['SCRIPT_FILENAME']) == 'index.php')
        
register_shutdown_function("autoclean");

// Empty dbconn for compatibility
function dbconn()
{
}

?>
takeprofedit.php
PHP Code:
<?php

require_once("include/bittorrent.php");

function 
bark($msg) {
    
genbark($msg"Update failed!");
}



loggedinorreturn();

if (!
mkglobal("email:chpassword:passagain"))
    
bark("missing form data");

// $set = array();

$updateset = array();
$changedemail 0;

if (
$chpassword != "") {
    if (
strlen($chpassword) > 40)
        
bark("Sorry, password is too long (max is 40 chars)");
    if (
$chpassword != $passagain)
        
bark("The passwords didn't match. Try again.");

    
$sec mksecret();

  
$passhash md5($sec $chpassword $sec);

    
$updateset[] = "secret = " sqlesc($sec);
    
$updateset[] = "passhash = " sqlesc($passhash);
    
logincookie($CURUSER["id"], $passhash);
}

if (
$email != $CURUSER["email"]) {
    if (!
validemail($email))
        
bark("That doesn't look like a valid email address.");
  
$r mysql_query("SELECT id FROM users WHERE email=" sqlesc($email)) or sqlerr();
    if (
mysql_num_rows($r) > 0)
        
bark("The e-mail address $email is already in use.");
    
$changedemail 1;
}

$acceptpms $_POST["acceptpms"];
$deletepms = ($_POST["deletepms"] != "" "yes" "no");
$savepms = ($_POST["savepms"] != "" "yes" "no");
$pmnotif $_POST["pmnotif"];
$emailnotif $_POST["emailnotif"];
$notifs = ($pmnotif == 'yes' "[pm]" "");
$notifs .= ($emailnotif == 'yes' "[email]" "");
$r mysql_query("SELECT id FROM categories") or sqlerr();
$rows mysql_num_rows($r);
for (
$i 0$i $rows; ++$i)
{
    
$a mysql_fetch_assoc($r);
    if (
$_POST["cat$a[id]"] == 'yes')
      
$notifs .= "[cat$a[id]]";
}
$avatar $_POST["avatar"];
$avatars = ($_POST["avatars"] != "" "yes" "no");
$anon = ($_POST["anon"] != "" "yes" "no");
// $ircnick = $_POST["ircnick"];
// $ircpass = $_POST["ircpass"];
$info $_POST["info"];
$stylesheet $_POST["stylesheet"];
$country $_POST["country"];
if (
$_POST['resetpasskey']) 
    
$updateset[] = "passkey=''";
//$timezone = 0 + $_POST["timezone"];
//$dst = ($_POST["dst"] != "" ? "yes" : "no");
/*
if ($privacy != "normal" && $privacy != "low" && $privacy != "strong")
    bark("whoops");

$updateset[] = "privacy = '$privacy'";
*/

$updateset[] = "torrentsperpage = " min(100$_POST["torrentsperpage"]);
$updateset[] = "topicsperpage = " min(100$_POST["topicsperpage"]);
$updateset[] = "postsperpage = " min(100$_POST["postsperpage"]);

if (
is_valid_id($stylesheet))
  
$updateset[] = "stylesheet = '$stylesheet'";
if (
is_valid_id($country))
  
$updateset[] = "country = $country";

//$updateset[] = "timezone = $timezone";
//$updateset[] = "dst = '$dst'";

$updateset[] = "info = " sqlesc($info);
$updateset[] = "acceptpms = " sqlesc($acceptpms);
$updateset[] = "deletepms = '$deletepms'";
$updateset[] = "savepms = '$savepms'";
$updateset[] = "notifs = '$notifs'";
$updateset[] = "avatar = " sqlesc($avatar);
$updateset[] = "avatars = '$avatars'";
$updateset[] = "anon = '$anon'";
//if(($anon = isset($_POST["anon"]) ? ($_POST["anon"]=='yes'?'yes':'no'):'no')  != $CURUSER["anon"])
//$updateset[] = "anon = " . sqlesc($anon);

/* ****** */

$urladd "";

if (
$changedemail) {
    
$sec mksecret();
    
$hash md5($sec $email $sec);
    
$obemail urlencode($email);
    
$updateset[] = "editsecret = " sqlesc($sec);
    
$thishost $_SERVER["HTTP_HOST"];
    
$thisdomain preg_replace('/^www\./is'""$thishost);
    
$body = <<<EOD
You have requested that your user profile (username {$CURUSER["username"]})
on 
$thisdomain should be updated with this email address ($email) as
user contact.

If you did not do this, please ignore this email. The person who entered your
email address had the IP address 
{$_SERVER["REMOTE_ADDR"]}. Please do not reply.

To complete the update of your user profile, please follow this link:

http://
$thishost/confirmemail.php/{$CURUSER["id"]}/$hash/$obemail

Your new email address will appear in your profile after you do this. Otherwise
your profile will remain unchanged.
EOD;

    
mail($email"$thisdomain profile change confirmation"$body"From: $SITEEMAIL""-f$SITEEMAIL");

    
$urladd .= "&mailsent=1";
}

mysql_query("UPDATE users SET " implode(","$updateset) . " WHERE id = " $CURUSER["id"]) or sqlerr(__FILE__,__LINE__);

header("Location: $BASEURL/my.php?edited=1" $urladd);

?>

Last edited by ndbj; 27th December 2012 at 18:52.
Reply With Quote
Reply

Tags
forum , integration , punbb , source , tbdev


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump



All times are GMT +2. The time now is 19:24. vBulletin skin by ForumMonkeys. Powered by vBulletin® Version 3.8.11 Beta 3
Copyright ©2000 - 2024, vBulletin Solutions Inc.