Bravo List

Bravo List (https://www.bvlist.com/index.php)
-   Downloads (https://www.bvlist.com/forumdisplay.php?f=16)
-   -   H-Tracker v2 (https://www.bvlist.com/showthread.php?t=1753)

raefor 12th August 2009 18:18

1 Attachment(s)
Quote:

Originally Posted by cigano33 (Post 14354)
comments

look in account-details

Attachment 1600

cigano33 13th August 2009 14:21

re
 
yes how to make it all in one motion please

edit a car by its short -

raefor 13th August 2009 14:32

Quote:

Originally Posted by cigano33 (Post 14382)
yes how to make it all in one motion please

edit a car by its short -

in Database

cigano33 13th August 2009 14:43

I am my daccort for me please because the request has members who Peuv and others do not, I want to meter all at once

raefor 13th August 2009 15:35

Quote:

Originally Posted by cigano33 (Post 14384)
I am my daccort for me please because the request has members who Peuv and others do not, I want to meter all at once

in Database in users set all there

eclivic 21st August 2009 02:54

Never connectible
 
No matter what I do I am not connectible, I have fowarded the ports in my router and used DMZ. My torrents are even seeding from utorrent but site says not connectible. I have two computers and I log into the site with my other one and can download the torrent but no one else can.

bit4you 4th September 2009 14:48

webseed hack for H2 source
 
http://img24.imageshack.us/img24/250...eedscreen2.jpg

does someone have hack for webseed or seedbox hack or blogs mod for the H2 source ?

thx for answer
best regards

blkmaster 6th September 2009 22:54

don't work for me i will fix it thx guys

cigano33 9th September 2009 18:54

vip torrent
 
goodnight how you add an image as freeleech for torrents vip for missing image thank you

bit4you 11th September 2009 08:36

error
 
Poll
Code:

Warning: Cannot modify header information - headers already sent by (output started at /srv/www/htdocs/blocks/navigate_block.php:8) in /srv/www/htdocs/backend/functions.php on line 32
:sos:

best regards

Security 22nd September 2009 11:34

How to fix that ?
Code:

Warning: Cannot modify header information - headers already sent by (output started at /home/visualt/public_html/newtorrent/viewrequests.php:1) in /home/visualt/public_html/newtorrent/backend/functions.php on line 33

raefor 22nd September 2009 13:50

Quote:

Originally Posted by Security (Post 15875)
How to fix that ?
Code:

Warning: Cannot modify header information - headers already sent by (output started at /home/visualt/public_html/newtorrent/viewrequests.php:1) in /home/visualt/public_html/newtorrent/backend/functions.php on line 33


try and replace announce with this one



PHP Code:

<?
//
//  H-Tracker v0.2
//    http://h-tracker.org
//    Based on TorrentTrader (http://www.torrenttrader.org)
//
//
error_reporting(E_ALL ^ E_NOTICE);
require_once(
"backend/mysql.php");
require_once(
"backend/config.php");

@
mysql_connect($mysql_host, $mysql_user, $mysql_pass) or err('dbconn: mysql_connect: ' . mysql_error());
@
mysql_select_db($mysql_db) or die('dbconn: mysql_select_db: ' + mysql_error());

$MEMBERSONLY = $site_config["MEMBERSONLY"];
$MEMBERSONLY_WAIT = $site_config["MEMBERSONLY_WAIT"];

//START FUNCTIONS
function ip2compact ($ip, $port) {
    return 
pack("N", ip2long($ip)).pack("n", $port);
}

function 
unesc($x) {
    if (
get_magic_quotes_gpc())
        return 
stripslashes($x);
    return 
$x;
}

function 
hex2bin($hexdata) {
  
$bindata = "";
  for (
$i=0;$i<strlen($hexdata);$i+=2) {
    
$bindata.=chr(hexdec(substr($hexdata,$i,2)));
  }
  return 
$bindata;
}

function 
is_valid_id($id)
{
  return 
is_numeric($id) && ($id > 0) && (floor($id) == $id);
}

function 
validip($ip)
{
    if (!empty(
$ip) && ip2long($ip)!=-1)
    {
        
$reserved_ips = array (
                array(
'0.0.0.0','2.255.255.255'),
                array(
'10.0.0.0','10.255.255.255'),
                array(
'127.0.0.0','127.255.255.255'),
                array(
'169.254.0.0','169.254.255.255'),
                array(
'172.16.0.0','172.31.255.255'),
                array(
'192.0.2.0','192.0.2.255'),
                array(
'192.168.0.0','192.168.255.255'),
                array(
'255.255.255.0','255.255.255.255')
        );

        foreach (
$reserved_ips as $r)
        {
                
$min = ip2long($r[0]);
                
$max = ip2long($r[1]);
                if ((
ip2long($ip) >= $min) && (ip2long($ip) <= $max)) return false;
        }
        return 
true;
    }
    else return 
false;
}

function 
getip() {
   if (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 
checkconnect($ip,$port)
{
    
$sockres = @fsockopen($ip, $port, $errno, $errstr, 5);
    if (!
$sockres)
 
$connectable = "no";
    else
    {
 
$connectable = "yes";
 @
fclose($sockres);
    }
    return 
$connectable;
}

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 
sqlesc($x) {
    return 
"'".mysql_real_escape_string($x)."'";
}

function 
err($msg)
{
    
benc_resp(array("failure reason" => array(type => "string", value => $msg)));
    exit();
}

function 
benc($obj) {
    if (!
is_array($obj) || !isset($obj["type"]) || !isset($obj["value"]))
        return;
    
$c = $obj["value"];
    switch (
$obj["type"]) {
        case 
"string":
            return 
benc_str($c);
        case 
"integer":
            return 
benc_int($c);
        case 
"list":
            return 
benc_list($c);
        case 
"dictionary":
            return 
benc_dict($c);
        default:
            return;
    }
}

function 
benc_str($s) {
    return 
strlen($s) . ":$s";
}

function 
benc_int($i) {
    return 
"i" . $i . "e";
}

function 
benc_list($a) {
    
$s = "l";
    foreach (
$a as $e) {
        
$s .= benc($e);
    }
    
$s .= "e";
    return 
$s;
}

function 
benc_dict($d) {
    
$s = "d";
    
$keys = array_keys($d);
    
sort($keys);
    foreach (
$keys as $k) {
        
$v = $d[$k];
        
$s .= benc_str($k);
        
$s .= benc($v);
    }
    
$s .= "e";
    return 
$s;
}

function 
benc_resp($d)
{
    
benc_resp_raw(benc(array(type => "dictionary", value => $d)));
}

function 
benc_resp_raw($x) {

header("Content-Type: text/plain");

header("Pragma: no-cache");

if (
$_SERVER["HTTP_ACCEPT_ENCODING"] == "gzip") {

header("Content-Encoding: gzip");

echo 
gzencode($x, 9, FORCE_GZIP);

} else

print(
$x);

}

function 
gmtime()
{
    return 
strtotime(get_date_time());
}

function 
get_date_time($timestamp = 0)
{
  if (
$timestamp)
    return 
date("Y-m-d H:i:s", $timestamp);
  else
    return 
gmdate("Y-m-d H:i:s");
}

function 
portblacklisted($port)
{
    
// direct connect
    
if ($port >= 411 && $port <= 413) return true;

    
// kazaa
    
if ($port == 1214) return true;

    
// gnutella
    
if ($port >= 6346 && $port <= 6347) return true;

    
// emule
    
if ($port == 4662) return true;

    
// winmx
    
if ($port == 6699) return true;

    return 
false;
}

//////////////////////// NOW WE DO THE ANNOUNCE CODE ////////////////////////

// BLOCK ACCESS WITH WEB BROWSERS
$agent = $_SERVER["HTTP_USER_AGENT"];
//if (ereg("^Mozilla\\/", $agent) || ereg("^Opera\\/", $agent) || ereg("^Links ", $agent) || ereg("^Lynx\\/", //$agent))
//   err("torrent not registered with this tracker");



//GET DETAILS OF PEERS ANNOUNCE
foreach (array("passkey","info_hash","peer_id","ip","event") as $x) {
    if (
get_magic_quotes_gpc())
        
$GLOBALS[$x] = stripslashes($_GET[$x]);
    else
        
$GLOBALS[$x] = $_GET[$x];
}

foreach (array(
"port","downloaded","uploaded","left") as $x)
    
$GLOBALS[$x] = 0 + $_GET[$x];

if (
strpos($passkey, "?")) {
    
$tmp = substr($passkey, strpos($passkey, "?"));
    
$passkey = substr($passkey, 0, strpos($passkey, "?"));
    
$tmpname = substr($tmp, 1, strpos($tmp, "=")-1);
    
$tmpvalue = substr($tmp, strpos($tmp, "=")+1);
    
$GLOBALS[$tmpname] = $tmpvalue;
}

foreach (array(
"passkey","info_hash","peer_id","port","downloaded","uploaded","left") as $x)

if (!isset(
$x))
    
err("Missing key: $x");

$no_peer_id = (int) $_GET["no_peer_id"];
$compact = (int) $_GET["compact"];

    if (
strlen($GLOBALS['info_hash']) == 20)
        
$GLOBALS['info_hash'] = bin2hex($GLOBALS['info_hash']);
    else if (
strlen($GLOBALS['info_hash']) != 40)
        
err("Invalid info hash value.");
    
$GLOBALS['info_hash'] = strtolower($GLOBALS['info_hash']);
    if (
$MEMBERSONLY){
         if (
strlen($passkey) != 32)
             
err("Invalid passkey (" . strlen($passkey) . " - $passkey)");
     }

$ip = getip(); 

foreach(array(
"num want", "numwant", "num_want") as $k)
{
    if (isset(
$_GET[$k]))
    {
        
$rsize = 0 + $_GET[$k];
        break;
    }
}

//PORT CHECK
if (!$port || $port > 0xffff)
    
err("invalid port");

//TRACKER EVENT CHECK
if (!isset($event))
    
$event = "";

$seeder = ($left == 0) ? "yes" : "no";

//Agent Ban
$agentarray = array_map("trim", explode(",", $site_config["BANNED_AGENTS"]));
$useragent = substr($peer_id, 0, 8);
foreach(
$agentarray as $bannedclient)
if(
strpos($useragent, $bannedclient) !== false)
    
err("Client is banned");
//End Agent Bans

if (portblacklisted($port))
    
err("Port $port is blacklisted.");

$userfields = "id, class, uploaded, downloaded, ip, passkey, parked"; //user details to get

$peerfields = "seeder, UNIX_TIMESTAMP(last_action) AS ez, peer_id, ip, port, uploaded, downloaded, userid, passkey"; //peers details to get

$torrentfields = "id, name, info_hash, category, banned, freeleech, vip, seeders + leechers AS numpeers, UNIX_TIMESTAMP(added) AS ts, seeders, leechers, times_completed"; //torrent details to get

$userid = 0;
if (
$MEMBERSONLY){
     
//check passkey is valid, and get users details
     
$res = mysql_query("SELECT $userfields FROM users WHERE passkey=".sqlesc($passkey)." AND enabled = 'yes' ORDER BY last_access DESC LIMIT 1") or err("Cannot Get User Details");
if (
$user["parked"] == "yes")
err("Error, your account is parked! Please read the FAQ!");
     
$user = mysql_fetch_array($res);
     if (!
$user)
         
err("Cannot locate a user with that passkey!");
     
$userid = $user["id"]; //etc
}


//check torrent is valid and get torrent fields
$res = mysql_query("SELECT $torrentfields FROM torrents WHERE ".hash_where("info_hash", $info_hash)) or err("Cannot Get Torrent Details");
$torrent = mysql_fetch_array($res);

if (!
$torrent)
    
err("Torrent not found on this tracker - hash = " . $info_hash);
if (
$torrent["banned"]=='yes')
    
err("Torrent has been banned - hash = " . $info_hash);
$torrentid = $torrent["id"];
if (
$torrent["vip"] == "y" && $user["class"] < 3)
    
err("This torrent is for VIPs only. Please visit $site_config[SITEURL] to upgrade.");


//Now get data from peers table
$peerlimit = 50;
$numpeers = $torrent["numpeers"];
if (
$numpeers > $peerlimit){
    
$limit = "ORDER BY RAND() LIMIT $peerlimit";
}else{
    
$limit = "";
}
$res = mysql_query("SELECT $peerfields FROM peers WHERE torrent = $torrentid $limit") or err("Error Selecting Peers");

//DO SOME BENC STUFF TO THE PEERS CONNECTION
$resp = "d8:completei$torrent[seeders]e10:downloadedi$torrent[times_completed]e10:incompletei$torrent[leechers]e";
$resp .= benc_str("interval") . "i" . $site_config['announce_interval'] . "e" . benc_str("min interval") . "i300e" . benc_str("peers");
unset(
$self);
while (
$row = mysql_fetch_assoc($res))
{
    
$row["peer_id"] = hash_pad($row["peer_id"]);

    if (
$row["peer_id"] === $peer_id)
    {
        
$self = $row;
        continue;
    }

    if (!
$compact || $no_peer_id) {
        
$peers .= "d" .
        
benc_str("ip") . benc_str($row["ip"]);
        if (!
$no_peer_id)
            
$peers .= benc_str("peer id") . benc_str($row["peer_id"]);
        
$peers .= benc_str("port") . "i" . $row["port"] . "ee";
    }else
        
$peers .= benc_str(ip2compact($row["ip"], $row["port"]));
}
if (!
$compact || $no_peer_id)
    
$resp .= "l{$peers}e";
else
    
$resp .= benc_str($peers);
$resp .= "ee";

$selfwhere = "torrent = $torrentid AND " . hash_where("peer_id", $peer_id);



// FILL $SELF WITH DETAILS FROM PEERS TABLE (CONNECTING PEERS DETAILS)
if (!isset($self)){

     
//check passkey isnt leaked
     
if ($MEMBERSONLY) {
         
$valid = @mysql_fetch_row(@mysql_query("SELECT COUNT(*) FROM peers WHERE torrent=$torrentid AND passkey=" . sqlesc($passkey)));

         if (
$valid[0] >= 1 && $seeder == 'no')
             
err("Connection limit exceeded! You may only leech from one location at a time.");

         if (
$valid[0] >= 3 && $seeder == 'yes')
             
err("Connection limit exceeded!");
     }

     
$res = mysql_query("SELECT $peerfields FROM peers WHERE $selfwhere");
     
$row = mysql_fetch_assoc($res);
     if (
$row){
             
$self = $row;
      if((
$connectable=checkconnect($row['ip'],$row['port']))=='yes')
     
mysql_query("UPDATE peers SET connectable='yes' WHERE $selfwhere"); 
     }
}
// END $SELF FILL


if (!isset($self)){ //IF PEER IS NOT IN PEERS TABLE DO THE WAIT TIME CHECK
    
if ($MEMBERSONLY_WAIT && $MEMBERSONLY){
        
//wait time check
        
if($left > 0 && in_array($user["class"], explode(",",$site_config["WAIT_CLASS"]))){ //check only leechers and lowest user class
            
$gigs = $user["uploaded"] / (1024*1024*1024);
            
$elapsed = floor((gmtime() - $torrent["ts"]) / 3600); 
            
$ratio = (($user["downloaded"] > 0) ? ($user["uploaded"] / $user["downloaded"]) : 1); 
            if (
$ratio == 0 && $gigs == 0) $wait = $site_config["WAITA"];
            elseif (
$ratio < $site_config["RATIOA"] || $gigs < $site_config["GIGSA"]) $wait = $site_config["WAITA"];
            elseif (
$ratio < $site_config["RATIOB"] || $gigs < $site_config["GIGSB"]) $wait = $site_config["WAITB"];
            elseif (
$ratio < $site_config["RATIOC"] || $gigs < $site_config["GIGSC"]) $wait = $site_config["WAITC"];
            elseif (
$ratio < $site_config["RATIOD"] || $gigs < $site_config["GIGSD"]) $wait = $site_config["WAITD"];
            else 
$wait = 0;
        if (
$elapsed < $wait)
            
err("Wait Time (" . ($wait - $elapsed) . " hours) - Visit ".$site_config["SITEURL"]." for more info");
        }
    }
    
$connectable=checkconnect($ip,$port);

}else{

// Deny access made with a browser...
if (ereg("^Mozilla\\/", $agent) || ereg("^Opera\\/", $agent) || ereg("^Links ", $agent) || ereg("^Lynx\\/", $agent))
        die(
"Not for browser, use upload.php or browse.php");

// Cheat hunter
if (isset($_SERVER['HTTP_COOKIE']) || isset($_SERVER['HTTP_ACCEPT_LANGUAGE']) || isset($_SERVER['HTTP_ACCEPT_CHARSET'])) {
        
$body = <<<EOD
Hello

Found cheater on 
{$_SERVER["REMOTE_ADDR"]}

Header of request

REMOTE_ADDR: 
{$_SERVER["REMOTE_ADDR"]}
HTTP_USER_AGENT: 
{$_SERVER[""]}
HTTP_ACCEPT: 
{$_SERVER["HTTP_ACCEPT"]}
HTTP_ACCEPT_ENCODING: 
{$_SERVER["HTTP_ACCEPT_ENCODING"]}
HTTP_ACCEPT_LANGUAGE: 
{$_SERVER["HTTP_ACCEPT_LANGUAGE"]}
HTTP_ACCEPT_CHARSET: 
{$_SERVER["HTTP_ACCEPT_CHARSET"]}
HTTP_COOKIE: 
{$_SERVER["HTTP_COOKIE"]}
REQUEST_METHOD: 
{$_SERVER["REQUEST_METHOD"]}
QUERY_STRING: 
{$_SERVER["QUERY_STRING"]}
HTTP_CONNECTION: 
{$_SERVER["HTTP_CONNECTION"]}
HTTP_REFERER: 
{$_SERVER["HTTP_REFERER"]}
REMOTE_PORT: 
{$_SERVER["REMOTE_PORT"]}
REQUEST_URI: 
{$_SERVER["REQUEST_URI"]}


---
Do not reply - autogenerated
WBR, 
$SITENAME
EOD;
        
mail($site_config['SITEEMAIL'], "CheatHunter: Cheater on ".$site_config['SITENAME']." from ".$_SERVER['REMOTE_ADDR']."", $body, "From: ".$site_config['SITENAME']." <".$site_config['SITEEMAIL'].">");
        die(
"Rescue the Earth - kill itself");
}
    
$upthis = max(0, $uploaded - $self["uploaded"]);
    
$downthis = max(0, $downloaded - $self["downloaded"]);

    if ((
$upthis > 0 || $downthis > 0) && is_valid_id($userid)){ //  (LIVE STATS!)
        
if ($torrent["freeleech"] == 1){
            
mysql_query("UPDATE users SET uploaded = uploaded + $upthis WHERE id=$userid") or err("Tracker error: Unable to update stats");
        }else{
            
mysql_query("UPDATE users SET uploaded = uploaded + $upthis, downloaded = downloaded + $downthis WHERE id=$userid") or err("Tracker error: Unable to update stats");
        }
    }
}
//END WAIT AND STATS UPDATE

$updateset = array();

////////////////// NOW WE DO THE TRACKER EVENT UPDATES ///////////////////

if ($event == "stopped") { // UPDATE "STOPPED" EVENT
        
mysql_query("DELETE FROM peers WHERE $selfwhere");
        if (
mysql_affected_rows()){
            if (
$self["seeder"] == "yes")
                
$updateset[] = "seeders = seeders - 1";
            else
                
$updateset[] = "leechers = leechers - 1";
        }
}

if (
$event == "completed") { // UPDATE "COMPLETED" EVENT    
    
$updateset[] = "times_completed = times_completed + 1";

    if (
$MEMBERSONLY)
        
mysql_query("INSERT INTO completed (userid, torrentid, date) VALUES ($userid, $torrentid, '".get_date_time()."')");
}
//END COMPLETED

if (isset($self)){// NO EVENT? THEN WE MUST BE A NEW PEER OR ARE NOW SEEDING A COMPLETED TORRENT
    
    
mysql_query("UPDATE peers SET ip = " . sqlesc($ip) . ", passkey = " . sqlesc($passkey) . ", port = $port, uploaded = $uploaded, downloaded = $downloaded, to_go = $left, last_action = '".get_date_time()."', client = " . sqlesc($agent) . ", seeder = '$seeder' WHERE $selfwhere");

    if (
mysql_affected_rows() && $self["seeder"] != $seeder){
        if (
$seeder == "yes"){
            
$updateset[] = "seeders = seeders + 1";
            
$updateset[] = "leechers = leechers - 1";
        } else {
            
$updateset[] = "seeders = seeders - 1";
            
$updateset[] = "leechers = leechers + 1";
        }
    }

} else {

    
$ret = mysql_query("INSERT INTO peers (connectable, torrent, peer_id, ip, passkey, port, uploaded, downloaded, to_go, started, last_action, seeder, userid, client) VALUES ('$connectable', $torrentid, " . sqlesc($peer_id) . ", " . sqlesc($ip) . ", " . sqlesc($passkey) . ", $port, $uploaded, $downloaded, $left, '".get_date_time()."', '".get_date_time()."', '$seeder', '$userid', " . sqlesc($agent) . ")");
    
    if (
$ret){
        if (
$seeder == "yes")
            
$updateset[] = "seeders = seeders + 1";
        else
            
$updateset[] = "leechers = leechers + 1";
    }
}

//////////////////    END TRACKER EVENT UPDATES ///////////////////

// SEEDED, LETS MAKE IT VISIBLE THEN
if ($seeder == "yes") {
    if (
$torrent["banned"] != "yes") // DONT MAKE BANNED ONES VISIBLE
        
$updateset[] = "visible = 'yes'";
    
$updateset[] = "last_action = '".get_date_time()."'";
}

// NOW WE UPDATE THE TORRENT AS PER ABOVE
if (count($updateset))
    
mysql_query("UPDATE torrents SET " . join(",", $updateset) . " WHERE id=$torrentid") or err("Tracker error: Unable to update torrent");

// NOW BENC THE DATA AND SEND TO CLIENT???
benc_resp_raw($resp);

mysql_close();
?>


komyomy 23rd September 2009 15:49

Who knows why members can not download the torrents from my tracker?
I uploaded some torrents (I make "seed" all time) but members can not download

Why?

GeOrGiiQ 1st October 2009 13:34

Upload, download, ratio don't show
 
hello, i have a h-tracker v2 installed and all work perfect but my info don't show
Code:

downloaded : 0.0 Kb
uploaded : 0.0 kb
ratio : ---
conectable : pending
seed : 0
leech : 0

how i make to work, were is the problem, announce.php ?
please help me !

all my tracker members don't show how much uploaded , downloaded , ratio

evaldas40 10th October 2009 23:57

Quote:

Originally Posted by raefor (Post 15878)
try and replace announce with this one

Its dont work :sos::muscle::wild:

sacco 12th October 2009 19:26

forum phpbb2 integrate
 
Hello my probleme is the forum is not functionali

i've change the config to "true"

and the forum make this error:


The Forum is disabled
Open your config.php from backend folder
Find this line:
$activate_phpbb2_forum = false;

Replace with this:
$activate_phpbb2_forum = true;

why my config .php is ok :sos:

filth 16th October 2009 10:28

Anyone has torrents history in userdetails?

Security 18th October 2009 09:44

how to fix?

Code:

Warning: Cannot modify header information - headers already sent by (output started at /home/visualt/public_html/collectors/viewrequests.php:1) in /home/visualt/public_html/collectors/backend/functions.php on line 34

Georgiq 22nd October 2009 22:12

hello,
 
1 Attachment(s)
any update to announce.php ? still don't send data ! uploaded , downloaded still 0 ! i tried to fix it but don't work anyway !

Bump:
Code:

[25-Oct-2009 05:02:19] PHP Warning:  strpos() [function.strpos]: Empty delimiter. in /home/****/public_html/tracker/announce.php on line 287
[25-Oct-2009 05:02:19] PHP Warning:  Cannot modify header information - headers already sent by (output started at /home/****/public_html/tracker/announce.php:287) in /home/firek2/public_html/tracker/announce.php on line 166
[25-Oct-2009 05:02:19] PHP Warning:  Cannot modify header information - headers already sent by (output started at /home/****/public_html/tracker/announce.php:287) in /home/firek2/public_html/tracker/announce.php on line 168
[25-Oct-2009 05:02:19] PHP Warning:  Cannot modify header information - headers already sent by (output started at /home/*****/public_html/tracker/announce.php:287) in /home/****/public_html/tracker/announce.php on line 172

all work perfect but my announce send invalid data
my announce.php is this ! who can tell me what to do !
ratio , uploaded , downloaded bonus dont count is 0 .
thank you,

underx 28th October 2009 11:05

I cant run this source (it's the same with torrenttrader sources and even with tbdev) ;
I import the sql file into DB and change settings in mysql.php but here is what I get: page with a lot of php code ans sql queries !

http://i37.tinypic.com/acd9fq.png

raefor 28th October 2009 13:14

my old site that worked
 
1 Attachment(s)
just putting it out there for you all hope it my help someone

underx 28th October 2009 22:11

After adding a theme is says:
"'The following themes were added:
themename


Redirecting...'"
then you are not redirected!

raefor 29th October 2009 15:01

Quote:

Originally Posted by underx (Post 17019)
After adding a theme is says:
"'The following themes were added:
themename


Redirecting...'"
then you are not redirected!



just go back to themes it will load
:relax:

DooM 11th January 2010 14:42

How can I remove the ads from the banner ?

moondust5 19th January 2010 09:13

H-Tracker v2
 
I dled H-Tracker v2 couple days ago i got it installed an everything seems to be running fine except for torrent downloads.

Some of the torrent download links works an others i this msg
Code:

(Your Site has been attacked. Details about last attack: "random ip"  - Mozilla/5.0 ( Windows; U; Windows NT 5.1; en-US; rv:1.9.1.7) Gecko/20091221 Firefox/3.5.7 ).
Can anyone give pointers?
Thanks....

PerformerXTR 20th January 2010 20:21

how can i set another default theme? not the "fisubice" theme!
When a new user comes to the site to see a theme that i want.:unknown:

I tryied to delete the fisubice theme from theme management but then the index page was blank!:sad:


later edit:
!! i made it!

I modified in the database value of the fisubice! I put 1 to my theme and 6 to the fisubice theme! Newbie work! :P

oopss 21st January 2010 02:12

edit comment
 
Hi, sorry, im dont speak english :sorry:

Pleaz help..in torrents details and news ,dont work EDIT Comments..
This deleet all text, about edit..whay problem?


* Add Comment *
http://s004.radikal.ru/i207/1001/20/784b13daa1b7.png

* Edit Comment *
http://s006.radikal.ru/i214/1001/84/fb3589264049.png

moondust5 13th February 2010 15:26

H-Tracker 2
 
Has anyone been having problems with h-tracker 2 being able to track torrents,i think its a header error, whenever i upload a torrent then download it with a client i error msg in client saying "http error 406", i have downloaded other announce.php but i get same error, looked into the problem an cant seem to figure it out help plzzzz

");
}
}else{
if ($site_config["AGEON"] && $CURUSER["class"] <=3){
if ($CURUSER["age"] < $row["age_name"]){
$torrentage = "\"Age";
}else{
$torrentage = "\"Age";
}
}else{
$torrentage = "\"Age";
}
print("
raefor 23rd February 2010 20:26

Quote:

Originally Posted by moondust5 (Post 20938)
Has anyone been having problems with h-tracker 2 being able to track torrents,i think its a header error, whenever i upload a torrent then download it with a client i error msg in client saying "http error 406", i have downloaded other announce.php but i get same error, looked into the problem an cant seem to figure it out help plzzzz

This error occurs very infrequently in Web browsers, because most browsers will accept any data returned from the Web server.
If the client is not a Web browser, then anyone can only investigate the problem by looking at the Accept headers generated by the client system and the data stream returned by the Web server.

Quote:

Originally Posted by oopss (Post 19817)
Hi, sorry, im dont speak english :sorry:
Pleaz help..in torrents details and news ,dont work EDIT Comments..
This deleet all text, about edit..whay problem?

you can try this one

[php] //
// H-Tracker v0.2
// http://h-tracker.org
// Based on TorrentTrader (http://www.torrenttrader.org)
//
//
require_once("backend/functions.php");
require_once("backend/BDecode.php") ;
require_once("backend/parse.php") ;//replace with parse later
dbconn();
parked();

$torrent_dir = $site_config["torrent_dir"];
$nfo_dir = $site_config["nfo_dir"];

//check permissions
if ($site_config["MEMBERSONLY"]){
loggedinonly();

if($CURUSER["view_torrents"]=="no")
show_error_msg("Error","You do not have permission to view torrents",1);
}

//************ DO SOME "GET" STUFF BEFORE PAGE LAYOUT ***************

$id = (int) $_GET["id"];
$scrape = (int)$_GET["scrape"];
if (!is_valid_id($id))
show_error_msg("ERROR","Thats not a valid ID",1);

//GET ALL MYSQL VALUES FOR THIS TORRENT
$res = mysql_query("SELECT torrents.anon, torrents.seeders, torrents.vip, torrents.thanks, torrents.banned, torrents.nuked, torrents.tube, torrents.leechers, torrents.info_hash, torrents.filename, torrents.nfo, torrents.last_action, torrents.numratings, torrents.name, torrents.owner, torrents.save_as, torrents.descr, torrents.visible, torrents.size, torrents.added, torrents.views, torrents.hits, torrents.times_completed, torrents.id, torrents.type, torrents.external, torrents.image1, torrents.image2, torrents.announce, torrents.numfiles, torrents.freeleech, IF(torrents.numratings < 2, NULL, ROUND(torrents.ratingsum / torrents.numratings, 1)) AS rating, torrents.numratings, categories.name AS cat_name, torrentlang.name AS lang_name, torrentlang.image AS lang_image, torrentage.name AS age_name, torrentage.image AS age_image, categories.parent_cat as cat_parent, users.username, users.privacy FROM torrents LEFT JOIN categories ON torrents.category = categories.id LEFT JOIN torrentlang ON torrents.torrentlang = torrentlang.id LEFT JOIN torrentage ON torrents.torrentage = torrentage.id LEFT JOIN users ON torrents.owner = users.id WHERE torrents.id = $id") or die(mysql_error());



$row = mysql_fetch_array($res);

$vip = $row["vip"];
$vips = $row["vip"];

if ($vip == "y") {
$vip = "Yes";
} else {
$vip = "No";
}
//DECIDE IF TORRENT EXISTS
if (!$row || ($row["banned"] == "yes" && !$moderator))
show_error_msg("Error","" . TORRENT_NOT_FOUND . "",1);

//torrent is availiable so do some stuff

if ($_GET["hit"]) {
mysql_query("UPDATE torrents SET views = views + 1 WHERE id = $id");
header("Location: torrents-details.php?id=$id");
die;
}

stdhead("Details for torrent \"" . $row["name"] . "\"");

if ($CURUSER["id"] == $row["owner"])
$owned = 1;
else
$owned = 0;

if ($CURUSER["edit_torrents"]=="yes")
$owned = 1;

//take rating
if ($_GET["takerating"] == 'yes'){
$rating = (int)$_POST['rating'];

if ($rating <= 0 || $rating > 5)
show_error_msg("Rating Error", "Invalid rating",1);

$res = mysql_query("INSERT INTO ratings (torrent, user, rating, added) VALUES ($id, " . $CURUSER["id"] . ", $rating, '".get_date_time()."')");

if (!$res) {
if (mysql_errno() == 1062)
show_error_msg("Rating Error", "You have already rated this torrent.",1);
else
show_error_msg("Rating Error", "A Unknown Error, contact staff",1);
}

mysql_query("UPDATE torrents SET numratings = numratings + 1, ratingsum = ratingsum + $rating WHERE id = $id");
autolink("torrents-details.php?id=$id", "Thank you for rating this torrent...");
}

//take comment add
if ($_GET["takecomment"] == 'yes'){
loggedinonly();
if (!($CURUSER['comment_count'] < $CURUSER['comment_max']))
show_error_msg("Notice","You have reached your Comment limit. Please wait 10 minutes before retrying.");
$commentbody = $_POST['body'];

if (!$commentbody)
show_error_msg("Error","You did not enter anything!",1);

mysql_query("UPDATE torrents SET comments = comments + 1 WHERE id = $id") or die(mysql_error());
mysql_query("UPDATE users SET comment_count = comment_count + 1 WHERE id = $id") or die(mysql_error());

mysql_query("INSERT INTO comments (user, torrent, added, text) VALUES (".$CURUSER["id"].", ".$id.", '" .get_date_time(). "', " . sqlesc($body).")") or die(mysql_error());

if (mysql_affected_rows() == 1)
autolink("torrents-details.php?id=$id", "Your Comment was added successfully");
else
show_error_msg("Error","Unable to add comment",0);
}//end insert comment

//START OF PAGE LAYOUT HERE
$char1 = 55; //cut length
$shortname = CutName(htmlspecialchars($row["name"]), $char1);

begin_frame("" . TORRENT_DETAILS_FOR . " \"" . $shortname . "\"");
if ($owned)
$edittorrent = "\"Edit";

// Calculate local torrent speed test
if ($row["leechers"] >= 1 && $row["seeders"] >= 1 && $row["external"]!='yes'){
$speedQ = mysql_query("SELECT (SUM(p.downloaded)) / (UNIX_TIMESTAMP('".get_date_time()."') - 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 die(mysql_error());
$a = mysql_fetch_assoc($speedQ);
$totalspeed = mksize($a["totalspeed"]) . "/s";
}else{
$totalspeed = "---";
}
echo "
Status";
echo "
";
if ($row["banned"] == "yes"){
print ("
" . DOWNLOAD . ": BANNED!
");
if ($vip == 'Yes' && get_user_class($CURSER) < 3) {
print("
VIP torrent!
");
print("

");
if ($row["external"]!='yes'){
print("");
}
print("");
if ($row["external"]!='yes' && $row["seeders"] <= 1 && $row["times_completed"] > 0){ //if local and completed
print("");
}
if ($row["external"]!='yes' && $row["freeleech"]=='1'){
print("");
}
if ($row["external"]!='yes' && $vips == "y") {
print("");
}
print("");
if ($row["external"]=='yes'){
if ($scrape =='1'){
if ($seeders1 != -1){
print("");
}else{
print("");
}
print("");
}else{
print("");
}
}

print("");
print("");
print("");
if ($row["external"]!='yes'){
print("");
}
print("");
if ($row["external"]!='yes' && $row["seeders"] <= 1 && $row["times_completed"] > 0){ //if local and completed
print("");
}
if ($row["external"]!='yes' && $row["freeleech"]=='1'){
print("");
}
if ($row["external"]!='yes' && $vips == "y") {
print("");
}
print("");

if ($row["external"]=='yes'){
if ($scrape =='1'){
print("\n");
$tracker=str_replace("/announce","/scrape",$row['announce']);
$stats = torrent_scrape_url($tracker, $row["info_hash"]);
$seeders1 = strip_tags($stats['seeds']);
$leechers1 = strip_tags($stats['peers']);
$downloaded1 = strip_tags($stats['downloaded']);

if ($seeders1 != -1){ //only update stats if data is received
print("");

mysql_query("UPDATE torrents SET leechers='".$leechers1."', seeders='".$seeders1."',times_completed='".$downloaded1."',last_action= '".get_date_time()."',visible='yes' WHERE id='".$row['id']."'");
}else{
print("");
}
}else{
print("\n");
}
print ("";
}
}
}
print ("");
echo "
" . HEALTH . ": \"" \""Speed:\""Who's Completed?Free Leech:VIP torrent: Last Checked:Tracked:Live StaTus:Live StaTus:Tracked:
".health($row["leechers"], $row["seeders"])."
" . $row["seeders"] . "" . $row["leechers"] . "" . $totalspeed . "" . $row["times_completed"] . "View  Request A Re-SeedThis torrent is freeleech so only upload counts!This torrent is for VIP members only!" . date("d-m-Y H:i:s", utc_to_tz_time($row["last_action"])) . " EXTERNAL ");
print ("Seeders: ".$seeders1."
");
print ("Leechers: ".$leechers1."
");
print ("Completed: ".$downloaded1."
\n");
print ("
");
print ("Tracker Timeout
Please retry later

EXTERNAL 
Tracker:
".$row['announce']."");
//read torrent info
$TorrentInfo = array();
$TorrentInfo = ParseTorrent("$torrent_dir/$id.torrent");
$annlist = $TorrentInfo[6];
$filelist = $TorrentInfo[8];

if (count($annlist)){
echo "
Backup trackers:";
foreach ($annlist as $alist) {
echo "
";
echo "".$alist[0]."";
}
echo"

";
//end download box
$ads = ads();
if ($ads){
echo "
Advertising";
echo"
".$ads."
";
echo "
";
}
echo "
Details";
echo "";
print("
");
print("\n");
print("\n");
print("\n");
print("\n");
if (empty($row["lang_name"])) $row["lang_name"] = "Unknown/NA";
print("");

print("\n");
print("\n");
print("");
$UClass=@mysql_fetch_array(@mysql_query("SELECT * FROM users JOIN groups ON users.class=groups.group_id WHERE users.id='$row[owner]'"));
$user = "$row[username]";
if ($row["anon"] == "yes" && !$owned)
print("");
elseif ($user)
print("");
else
print("");

print("\n");
print("\n");
print("\n");
print("\n");
if ($site_config["AGEON"] && $CURUSER["class"] <=3){
if ($CURUSER["age"] < $row["age_name"]){
$torrentube = "Watch The trailer";
} else{
$torrentube = "Watch The trailer";
}
}else{
$torrentube = "Watch The trailer";
}
if (!empty($row["tube"]))
print ("");
$thanksl = explode(",", $row['thanks']);
if ($CURUSER['username'] == $row['username'] || !$CURUSER) $leftthanks = true;
foreach ($thanksl as $u) {
$thanks .= ($i>0)?", $u":$u;
if ($u == $CURUSER['username']) $leftthanks = true;
$i++;
}

if (!$thanks) $thanks = "No one yet.";

print("\n");


// $srating IS RATING VARIABLE
$srating = "";
$srating .= "";

print("
". $srating . "
");// rating

//END DEFINE RATING VARIABLE
echo "
" . NAME . ":" . $shortname . "
Actions:$torrentage  \"Report ".$edittorrent."
Description:
" . format_comment($row['descr']) . "
" . TTYPE . ":" . $row["cat_parent"] . " > " . $row["cat_name"] . "
Language:" . $row["lang_name"] . "\n");

if (isset($row["lang_image"]) && $row["lang_image"] != "")
print(" \""");

print("
" . TOTAL_SIZE . ":" . mksize($row["size"]) . "
" . INFO_HASH . ":" . $row["info_hash"] . "
" . ADDED_BY . ":Anonymous
" . ADDED_BY . ":" . $user . "  \"Respect\"  \"Anti-Respect\"
" . ADDED_BY . ":Unknown
" . DATE_ADDED . ":" . date("d-m-Y H:i:s", utc_to_tz_time($row["added"])) . "
" . VIEWS . ":" . $row["views"] . "
" . HITS . ":" . $row["hits"] . "
" . Nuked . ":" . $row["nuked"] . "
" . Youtube . ": $torrentube
Thanks By:$thanks\n");
if (!$leftthanks) print(" 
Rating:";
if (!isset($row["rating"])) {
$srating .= "Not Yet Rated";
}else{
$rpic = ratingpic($row["rating"]);
if (!isset($rpic))
$srating .= "invalid?";
else
$srating .= "$rpic (" . $row["rating"] . " out of 5) " . $row["numratings"] . " users have rated this torrent";
}
$srating .= "\n";
if (!isset($CURUSER))
$srating .= "(Log in to rate it)";
else {
$ratings = array(
5 => "Cool!",
4 => "Pretty good",
3 => "Decent",
2 => "Pretty bad",
1 => "Sucks!",
);
//if (!$owned || $moderator) {
$xres = mysql_query("SELECT rating, added FROM ratings WHERE torrent = $id AND user = " . $CURUSER["id"]);
$xrow = mysql_fetch_array($xres);
if ($xrow)
$srating .= "
(You rated this torrent as \"" . $xrow["rating"] . " - " . $ratings[$xrow["rating"]] . "\")";
else {
$srating .= "
\n";
$srating .= "\n";
$srating .= "";
$srating .= "
\n";
}
//}
}
$srating .= "
";
echo "
";

if ($row["image1"] != "" OR $row["image2"] != "") {
if ($row["image1"] != "")
$img1 = "\"Click";
if ($row["image2"] != "")
$img2 = "\"Click";
print("
". $img1 . "&nbsp&nbsp" . $img2."

");
}

echo "
File List: 
";

if ($row["external"]!='yes'){
echo "
Peers List: 
";
}
}


echo "

";

//DISPLAY NFO BLOCK
function my_nfo_translate($nfo){
$trans = array(
"\x80" => "
melcu66 24th February 2010 01:23

how can I delete the columns marked on the picture from the website?
 
1 Attachment(s)
How can I delete the columns marked on the picture from the website?
& to add pictures from direct link without resizing when i upload torrents, (screens from movies etc.)
Pls help if you know ;):coffee:

raefor 24th February 2010 15:08

Quote:

Originally Posted by melcu66 (Post 21324)
How can I delete the columns marked on the picture from the website?
& to add pictures from direct link without resizing when i upload torrents, (screens from movies etc.)
Pls help if you know ;):coffee:

you can try this or edit your functions.php

PHP Code:

<?php
//
//
//
//
error_reporting(E_ALL ^ E_NOTICE);
// register_globals on *fix*
if (!ini_get("register_globals")) {
    
import_request_variables('GPC');
}

//If running on a windows server you "may" have to use absolute paths here

require_once("mysql.php"); //Get MYSQL Connection Info
require_once("config.php");  //Get Site Settings and Vars ($site_config)  
require("tzs.php"); // Get Timezones
require("ctracker.php");


function 
dbconn($autoclean = false) {
    global 
$mysql_host, $mysql_user, $mysql_pass, $mysql_db, $THEME, $LANGUAGE, $site_config;

    if (!
ob_get_level()) {
        if (
extension_loaded('zlib') && !ini_get('zlib.output_compression'))
            
ob_start('ob_gzhandler');
        else
            
ob_start();
    } 

    
header("Content-Type: text/html;charset=$site_config[CHARSET]");

    if (!
function_exists("mysql_connect"))
        die(
"MySQL support not available.");

    if (!@
mysql_connect($mysql_host, $mysql_user, $mysql_pass))
    {
         die(
"<center><img src=\"http://bvlist.com/images/mysqlerror.png\" border=\"0\" alt=\"Powered by h-tracker.org\"><strong>There seems to be a problem with the MySQL server,<font color=red>" . mysql_error() ."</font>We should be back shortly.</strong></center>");                                                                                                                   
    }
     
mysql_select_db($mysql_db)
        or die(
"<center><img src=\"http://bvlist.com/images/mysqlerror.png\" border=\"0\" alt=\"Powered by h-tracker.org\"><strong>There seems to be a problem with the MySQL server,<font color=red>" . mysql_error() ."</font>Check your settings.</strong></center>");

    unset(
$mysql_pass); //security

    
userlogin(); //Get user info    

    //Get language and theme
    
$CURUSER = $GLOBALS["CURUSER"];
    if (
$CURUSER)  {
        
$ss_a = @mysql_fetch_array(@mysql_query("SELECT uri FROM stylesheets WHERE id=$CURUSER[stylesheet]"));
        if (
$ss_a)
            
$THEME = $ss_a["uri"];
        else {
            
$ss_a = @mysql_fetch_array(@mysql_query("select uri from stylesheets where id=$site_config[default_theme]"));
            
$THEME = $ss_a['uri'];
        }
        
$lng_a = @mysql_fetch_array(@mysql_query("select uri from languages where id=$CURUSER[language]"));
        if (
$lng_a)
            
$LANGUAGE = $lng_a["uri"];
        else {
            
$lng_a = @mysql_fetch_array(@mysql_query("select uri from languages where id=$site_config[default_language]"));
            
$LANGUAGE = $lng_a['uri'];
        }
    }else{
//not logged in so get default theme/language
        
$ss_a = mysql_fetch_array(mysql_query("select uri from stylesheets where id='" . $site_config['default_theme'] . "'")) or die(mysql_error());
        if (
$ss_a)
            
$THEME = $ss_a["uri"];
        
$lng_a = mysql_fetch_array(mysql_query("select uri from languages where id='" . $site_config['default_language'] . "'")) or die(mysql_error());
        if (
$lng_a)
            
$LANGUAGE = $lng_a["uri"];
    }
    require_once(
"languages/$LANGUAGE");



    if (
$autoclean)
        
autoclean();
}

// Main Cleanup
function autoclean() {
    global 
$site_config;
    require_once(
"cleanup.php");

    
$now = gmtime();

    
$res = mysql_query("SELECT last_time FROM tasks WHERE task='cleanup'");
    
$row = mysql_fetch_array($res);
    if (!
$row) {
        
mysql_query("INSERT INTO tasks (task, last_time) VALUES ('cleanup',$now)");
        return;
    }
    
$ts = $row[0];
    if (
$ts + $site_config["autoclean_interval"] > $now)
        return;
    
mysql_query("UPDATE tasks SET last_time=$now WHERE task='cleanup' AND last_time = $ts");
    if (!
mysql_affected_rows())
        return;

    
do_cleanup();
}

// IP Validation
function validip($ip)
{
    if (!empty(
$ip) && $ip == long2ip(ip2long($ip)))
    {
        
$reserved_ips = array (
                array(
'0.0.0.0','2.255.255.255'),
                array(
'10.0.0.0','10.255.255.255'),
                array(
'127.0.0.0','127.255.255.255'),
                array(
'169.254.0.0','169.254.255.255'),
                array(
'172.16.0.0','172.31.255.255'),
                array(
'192.0.2.0','192.0.2.255'),
                array(
'192.168.0.0','192.168.255.255'),
                array(
'255.255.255.0','255.255.255.255')
        );

        foreach (
$reserved_ips as $r)
        {
                
$min = ip2long($r[0]);
                
$max = ip2long($r[1]);
                if ((
ip2long($ip) >= $min) && (ip2long($ip) <= $max)) return false;
        }
        return 
true;
    }
    else return 
false;
}

function 
getip() {
   if (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 
userlogin() {
    global 
$CURUSER;
    unset(
$GLOBALS["CURUSER"]);

    
$ip = getip(); //GET USERS IP

    //Check IP bans    
    
$nip = ip2long($ip);
    
$res = mysql_query("SELECT * FROM bans WHERE $nip >= first AND $nip <= last")  or die(mysql_error());
    if (
mysql_num_rows($res) > 0) {
        
$row = mysql_fetch_array($res);
        
header("HTTP/1.0 403 Forbidden");
        echo 
"<html><head><title>Forbidden</title></head><body><h1>Forbidden</h1>Unauthorized IP address.".
        
"Reason for banning: $row[comment]</body></html>";
        die;
    }


    
//Check The Cookie and get CURUSER details
    
if (empty($_COOKIE["uid"]) || empty($_COOKIE["pass"]))
        return;

    
$id = 0 + $_COOKIE["uid"]; //Get User ID from cookie
    
if (!$id)
    return;

    
//Get User Details And Permissions
    
$res = mysql_query("SELECT * FROM users INNER JOIN groups ON users.class=groups.group_id WHERE users.id = $id AND users.enabled='yes' AND users.status = 'confirmed'") or die(mysql_error());
    
$row = mysql_fetch_array($res);

    if (!
$row)
        return;

    
//Check PW in cookie matches DB (after adding secret to the hash)
    
$sec = hash_pad($row["secret"]);
    if (
$_COOKIE["pass"] != md5($sec . $row["password"] . $sec))
        return;

    
mysql_query("UPDATE users SET last_access='" . get_date_time() . "', ip=".sqlesc($ip)." WHERE id=" . $row["id"]) or die(mysql_error());

    
$GLOBALS["CURUSER"] = $row;
    unset(
$row);
}

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 = '".get_date_time()."' WHERE id = $id");
}

function 
logoutcookie() {
    
setcookie("uid", "null", time(), "/");
    
setcookie("pass", "null", time(), "/");
}

function 
stdhead($title = "") {
    global 
$site_config, $CURUSER, $THEME, $LANGUAGE;  //Define globals
 
    //require_once("cleanup.php");  //temp cleanup linkage :D
    //docleanup();//TEMP CLEANUP CALL

    //site online check
    
if (!$site_config["SITE_ONLINE"]){
        if (
$CURUSER["level"]!=="Administrator") {
            echo 
'<BR><BR><BR><CENTER>'. stripslashes($site_config["OFFLINEMSG"]) .'</CENTER><BR><BR>';
            die;
        }else{
            echo 
'<BR><BR><BR><CENTER><B><FONT COLOR=RED>SITE OFFLINE, ADMIN ONLY VIEWING! DO NOT LOGOUT</FONT></B><BR>If you logout please edit backend/config.php and set SITE_ONLINE to true </CENTER><BR><BR>';
        }
    }
    
//end check

    
if (!$CURUSER)
        
guestadd();

    if (
$title == "")
        
$title = $site_config['SITENAME'];
    else
        
$title = $site_config['SITENAME']. " : ". htmlspecialchars($title);

    require_once(
"themes/" . $THEME . "/block.php");
    require_once(
"themes/" . $THEME . "/header.php");
} 

function 
stdfoot() {
    global 
$site_config, $CURUSER, $THEME, $LANGUAGE;
    require_once(
"themes/" . $THEME . "/footer.php");
    
mysql_close();
}


//POLL MULTICOLOR BY HACK346
function get_poolsleft($i)
{
 global 
$site_config, $THEME;
    if (
$i == 0 || $i == 5 || $i == 10 || $i == 15) return "<img src=".$site_config['SITEURL']."/themes/$THEME/images/polls/bar1-l.png border=\"0\">";                                                                            
    if (
$i == 1 || $i == 6 || $i == 11 || $i == 16) return "<img src=".$site_config['SITEURL']."/themes/$THEME/images/polls/bar2-l.png border=\"0\">";                                                                           
    if (
$i == 2 || $i == 7 || $i == 12 || $i == 17) return "<img src=".$site_config['SITEURL']."/themes/$THEME/images/polls/bar3-l.png border=\"0\">"; 
    if (
$i == 3 || $i == 8 || $i == 13 || $i == 18) return "<img src=".$site_config['SITEURL']."/themes/$THEME/images/polls/bar4-l.png border=\"0\">";
    if (
$i == 4 || $i == 9 || $i == 14 || $i == 19) return "<img src=".$site_config['SITEURL']."/themes/$THEME/images/polls/bar5-l.png border=\"0\">";  
  return 
"";
}


function 
get_poolsmiddle($i)
{
 global 
$site_config, $THEME;
    if (
$i == 0 || $i == 5 || $i == 10 || $i == 15) return "<img src=".$site_config['SITEURL']."/themes/$THEME/images/polls/bar1.png border=\"0\"";                                                                           
    if (
$i == 1 || $i == 6 || $i == 11 || $i == 16) return "<img src=".$site_config['SITEURL']."/themes/$THEME/images/polls/bar2.png border=\"0\"";                                                                             
    if (
$i == 2 || $i == 7 || $i == 12 || $i == 17) return "<img src=".$site_config['SITEURL']."/themes/$THEME/images/polls/bar3.png border=\"0\""; 
    if (
$i == 3 || $i == 8 || $i == 13 || $i == 18) return "<img src=".$site_config['SITEURL']."/themes/$THEME/images/polls/bar4.png border=\"0\"";   
    if (
$i == 4 || $i == 9 || $i == 14 || $i == 19) return "<img src=".$site_config['SITEURL']."/themes/$THEME/images/polls/bar5.png border=\"0\"";   
  return 
"";
}

function 
get_poolsright($i)
 {
 global 
$site_config, $THEME; 
    if (
$i == 0 || $i == 5 || $i == 10 || $i == 15) return "<img src=".$site_config['SITEURL']."/themes/$THEME/images/polls/bar1-r.png border=\"0\">";                                                                           
    if (
$i == 1 || $i == 6 || $i == 11 || $i == 16) return "<img src=".$site_config['SITEURL']."/themes/$THEME/images/polls/bar2-r.png border=\"0\">";                                                                            
    if (
$i == 2 || $i == 7 || $i == 12 || $i == 17) return "<img src=".$site_config['SITEURL']."/themes/$THEME/images/polls/bar3-r.png border=\"0\">"; 
    if (
$i == 3 || $i == 8 || $i == 13 || $i == 18) return "<img src=".$site_config['SITEURL']."/themes/$THEME/images/polls/bar4-r.png border=\"0\">"; 
    if (
$i == 4 || $i == 9 || $i == 14 || $i == 19) return "<img src=".$site_config['SITEURL']."/themes/$THEME/images/polls/bar5-r.png border=\"0\">";         
    return 
"";
}     

function 
leftblocks() {
    global 
$site_config, $CURUSER, $THEME, $LANGUAGE;  //Define globals
    
$res=mysql_query("SELECT * FROM blocks WHERE position='left' AND enabled=1 ORDER BY sort");
    
$i=0;
    
$blocks=array();
    while(
$result=mysql_fetch_array($res)){
        if(
$result["position"]) { 
            
$block=$result["name"];
            
$blocks[$i++]=$block;
        }
    }

    foreach (
$blocks as $blockfilename){
        echo
"<div id=\"ka".$result['id']."\" style=\"display: block;\">\n";                                                                                                         
        include(
"blocks/".$blockfilename."_block.php");
        echo
"</div>";
    }
}

function 
rightblocks() {
    global 
$site_config, $CURUSER, $THEME, $LANGUAGE;  //Define globals
    
$res=mysql_query("SELECT * FROM blocks WHERE position='right' AND enabled=1 ORDER BY sort");
    
$i=0;
    
$blocks=array();
    while(
$result=mysql_fetch_array($res)){
        if(
$result["position"]) {
            
$block=$result["name"];
            
$blocks[$i++]=$block;
        }
    }

    foreach (
$blocks as $blockfilename){
        include(
"blocks/".$blockfilename."_block.php");
    }
}

function 
middleblocks() {
    global 
$site_config, $CURUSER, $THEME, $LANGUAGE;  //Define globals
    
$res=mysql_query("SELECT * FROM blocks WHERE position='middle' AND enabled=1 ORDER BY sort");
    
$i=0;
    
$blocks=array();
    while(
$result=mysql_fetch_array($res)){
        if(
$result["position"]) {
            
$block=$result["name"];
            
$blocks[$i++]=$block;
        }
    }

    foreach (
$blocks as $blockfilename){
        include(
"blocks/".$blockfilename."_block.php");
    }
} 

function 
show_error_msg($title, $message, $wrapper = "1") {
    if (
$wrapper=="1") {
        
stdhead($title);
        
//echo "<b>DEBUG: stdhead Wrapper ON/Kill php gen further</b>";//remove later
    
}
        
begin_frame("<div class=error>". htmlspecialchars($title) ."</div>");
        print(
"<CENTER><B>" . stripslashes(sqlesc($message)) . "</B></CENTER>\n");
        
end_frame();

    if (
$wrapper=="1"){
        
stdfoot();
        die();
    }
}


function 
show_success_msg($title, $message, $wrapper = "1") {
    if (
$wrapper=="1") {
        
stdhead($title);
        
//echo "<b>DEBUG: stdhead Wrapper ON/Kill php gen further</b>";//remove later
    
}
        
begin_frame("<div class=success>". htmlspecialchars($title) ."</div>");
        print(
"<p><CENTER><B>" . stripslashes(sqlesc($message)) . "</B></CENTER></p>\n");
        
end_frame();

    if (
$wrapper=="1"){
        
stdfoot();
        die();
    }
}

//calculate health

// New (hack346 21/Jan/2009 @ 11:26)
function health($leechers, $seeders) {
    if ((
$leechers == 0 && $seeders == 0) || ($leechers > 0 && $seeders == 0))
        return 
$health0 = "<span><em style=\"left:3%\"></em></span>0%"; 
    elseif (
$seeders > $leechers)
        return 
$health10 = "<span><em style=\"left:100%\"></em></span>100%"; 
 
    
$ratio = $seeders / $leechers * 100;
    if (
$ratio > 0 && $ratio < 15)
        return 
$health1= "<stan><em style=\"left:10%\">10%</em></span>10%";
    elseif (
$ratio >= 15 && $ratio < 25)
        return 
$health2 = "<span><em style=\"left:20%\">20%</em></span>20%"; 
    elseif (
$ratio >= 25 && $ratio < 35)
        return 
$health3 = "<span><em style=\"left:30%\">30%</em></span>30%"; 
    elseif (
$ratio >= 35 && $ratio < 45)
        return 
$health4 = "<span><em style=\"left:40%\">40%</em></span>40%"; 
    elseif (
$ratio >= 45 && $ratio < 55)
        return 
$health5 = "<span><em style=\"left:50%\">50%</em></span>50%"; 
    elseif (
$ratio >= 55 && $ratio < 65)
        return 
$health6 = "<span><em style=\"left:60%\">60%</em></span>60%"; 
    elseif (
$ratio >= 65 && $ratio < 75)
        return 
$health7 = "<span><em style=\"left:70%\">70%</em></span>70%"; 
    elseif (
$ratio >= 75 && $ratio < 85)
        return 
$health8 = "<span><em style=\"left:80%\">80%</em></span>80%"; 
    elseif (
$ratio >= 85 && $ratio < 95)
        return 
$health9 = "<span><em style=\"left:90%\">90%</em></span>90%"; 
    else
        return 
$health10 = "<span><em style=\"left:100%\">100%</em></span>100%"; 
}


//secure vars
function sqlesc($x) {
   if (
get_magic_quotes_gpc()) {
       
$x = stripslashes($x);
   }
   if (!
is_numeric($x)) {
       
$x = "'".mysql_real_escape_string($x)."'";
   }
   return 
$x;
}


function 
unesc($x) {
    if (
get_magic_quotes_gpc())
        return 
stripslashes($x);
    return 
$x;
}

function 
mkglobal($vars) {
    if (!
is_array($vars))
        
$vars = explode(":", $vars);
    foreach (
$vars as $v) {
        if (isset(
$_GET[$v]))
            
$GLOBALS[$v] = stripslashes($_GET[$v]);
        elseif (isset(
$_POST[$v]))
            
$GLOBALS[$v] = stripslashes($_POST[$v]);
        else
            return 
0;
    }
    return 
1;
}

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 
file_ungzip($fromFile){
    
$zp = @gzopen($fromFile, "r");
    while(!@
gzeof($zp)) { $string .= @gzread($zp, 4096); }
    @
gzclose($zp);
    return 
$string;
}

function 
mksize($bytes) {
    if (
$bytes < 1000 * 1024)
        return 
number_format($bytes / 1024, 2) . " KB";
    if (
$bytes < 1000 * 1048576)
        return 
number_format($bytes / 1048576, 2) . " MB";
    if (
$bytes < 1000 * 1073741824)
        return 
number_format($bytes / 1073741824, 2) . " GB";
    return 
number_format($bytes / 1099511627776, 2) . " TB";
}

function 
escape_url($url) {
    
$ret = '';
    for(
$i = 0; $i < strlen($url); $i+=2)
    
$ret .= '%'.$url[$i].$url[$i + 1];
    return 
$ret;
}

function 
torrent_scrape_url($scrape, $hash) {
    
$ch = curl_init();
    
$timeout = 5;
    
curl_setopt ($ch, CURLOPT_URL, $scrape.'?info_hash='.escape_url($hash));
    
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
    
curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
    
$fp = curl_exec($ch);
    
curl_close($ch);

    
$ret = array();
    if(!
$fp) {
        
$ret['seeds'] = -1;
        
$ret['peers'] = -1;
    }else{
        
$stats = BDecode($fp);
        
$binhash = addslashes(pack("H*", $hash));
        
$seeds = $stats['files'][$binhash]['complete'];
        
$peers = $stats['files'][$binhash]['incomplete'];
        
$downloaded = $stats['files'][$binhash]['downloaded'];
        
$ret['seeds'] = $seeds;
        
$ret['peers'] = $peers;
        
$ret['downloaded'] = $downloaded;
    }
    return 
$ret;
}

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"]);
        return 
sprintf("%d:%02d", $t["min"], $t["sec"]);
}

function 
gmtime() {
    return 
strtotime(get_date_time());
}

function 
loggedinonly() {
        global 
$CURUSER;
        if (!
$CURUSER) {
            
header("Refresh: 0; url=account-login.php?returnto=" . urlencode($_SERVER["REQUEST_URI"]));
            exit();
        }
        
$wherethisuser = where ($_SERVER["SCRIPT_FILENAME"],$CURUSER["id"]);
}

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);
    
return preg_match('/^([a-z0-9._-](\+[a-z0-9])*)+@[a-z0-9.-]+\.[a-z]{2,6}$/i', $email);
}

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", $d);
    }
    return 
$d;
}

function 
mksecret($len = 20) {
    
$ret = "";
    for (
$i = 0; $i < $len; $i++)
        
$ret .= chr(mt_rand(0, 255));
    return 
$ret;
}

function 
deletetorrent($id) {
    global 
$site_config;

    
$row = @mysql_fetch_array(@mysql_query("SELECT image1,image2 FROM torrents WHERE id=$id"));
    
    foreach(
explode(".","peers.comments.ratings") as $x)
        
mysql_query("DELETE FROM $x WHERE torrent = $id");

    if (
file_exists("".$site_config["torrent_dir"]."/$id.torrent"))
        
unlink("".$site_config["torrent_dir"]."/$id.torrent");

    if (
$row["image1"]) {
        
$img1 = "".$site_config["torrent_dir"]."/images/".$row["image1"]."";
        
$del = unlink($img1);
    }

    if (
$row["image2"]) {
        
$img2 = "".$site_config["torrent_dir"]."/images/".$row["image2"]."";
        
$del = unlink($img2);
    }

    
mysql_query("DELETE FROM torrents WHERE id = $id");
}

function 
deleteaccount($userid) {
        
mysql_query("DELETE FROM users WHERE id = $userid");
        
mysql_query("DELETE FROM warnings WHERE userid = $userid");
        
mysql_query("DELETE FROM ratings WHERE user = $userid");
}

function 
genrelist() {
    
$ret = array();
    
$res = mysql_query("SELECT id, name, parent_cat FROM categories ORDER BY parent_cat ASC, sort_index ASC");
    while (
$row = mysql_fetch_array($res))
        
$ret[] = $row;
    return 
$ret;
}

function 
langlist() {
    
$ret = array();
    
$res = mysql_query("SELECT id, name, image FROM torrentlang ORDER BY sort_index, id");
    while (
$row = mysql_fetch_array($res))
        
$ret[] = $row;
    return 
$ret;
}


function 
agelist() {
    
$ret = array();
    
$res = mysql_query("SELECT id, name, image FROM torrentage ORDER BY sort_index, id");
    while (
$row = mysql_fetch_array($res))
        
$ret[] = $row;
    return 
$ret;
}

function 
is_valid_id($id){
    return 
is_numeric($id) && ($id > 0) && (floor($id) == $id);
}

function 
sql_timestamp_to_unix_timestamp($s){
    return 
mktime(substr($s, 11, 2), substr($s, 14, 2), substr($s, 17, 2), substr($s, 5, 2), substr($s, 8, 2), substr($s, 0, 4));
}

function 
write_log($text){
    
$text = sqlesc($text);
    
$added = sqlesc(get_date_time());
    
mysql_query("INSERT INTO log (added, txt) VALUES($added, $text)") or sqlerr();
}

function 
get_elapsed_time($ts){
  
$mins = floor((gmtime() - $ts) / 60);
  
$hours = floor($mins / 60);
  
$mins -= $hours * 60;
  
$days = floor($hours / 24);
  
$hours -= $days * 24;
  
$weeks = floor($days / 7);
  
$days -= $weeks * 7;
  
$t = "";
  if (
$weeks > 0)
    return 
"$weeks wk" . ($weeks > 1 ? "s" : "");
  if (
$days > 0)
    return 
"$days day" . ($days > 1 ? "s" : "");
  if (
$hours > 0)
    return 
"$hours hr" . ($hours > 1 ? "s" : "");
  if (
$mins > 0)
    return 
"$mins min" . ($mins > 1 ? "s" : "");
  return 
"< 1 min";
}

function 
hex2bin($hexdata) {
    
$bindata = "";
    for (
$i=0;$i<strlen($hexdata);$i+=2) {
        
$bindata.=chr(hexdec(substr($hexdata,$i,2)));
    }
    return 
$bindata;
}

function 
guestadd() {
    
$ip = $_SERVER["REMOTE_ADDR"];
    
$sql = mysql_query("SELECT time FROM guests WHERE ip='$ip'");
    
$ctime = gmtime();
    if (
mysql_fetch_row($sql))
    {
        @
mysql_query("UPDATE guests SET ip='$ip', time='$ctime' WHERE ip='$ip'");
    } else {
        @
mysql_query("INSERT INTO guests (ip, time) VALUES ('$ip', '$ctime')");
    }
}

function 
getguests() {
    
$ip = $_SERVER["REMOTE_ADDR"];
    
$past = gmtime()-2400;
    @
mysql_query("DELETE FROM guests WHERE time < $past");
    
$guests = number_format(get_row_count("guests"));
    return 
$guests;
}

function 
time_ago($addtime) {
   
$addtime = get_elapsed_time(sql_timestamp_to_unix_timestamp($addtime));
   return 
$addtime;
}

function 
CutName ($vTxt, $Car) {
    while(
strlen($vTxt) > $Car) {
        return 
substr($vTxt, 0, $Car) . "...";
    } return 
$vTxt;
}

function 
searchfield($s) {
    return 
preg_replace(array('/[^a-z0-9]/si', '/^\s*/s', '/\s*$/s', '/\s+/s'), array(" ", "", "", " "), $s);
}

function 
get_row_count($table, $suffix = "") {
  if (
$suffix)
    
$suffix = " $suffix";
  (
$r = mysql_query("SELECT COUNT(*) FROM $table$suffix")) or die(mysql_error());
  (
$a = mysql_fetch_row($r)) or die(mysql_error());
  return 
$a[0];
}

function 
sqlerr($query = "") {
    
stdhead();
    
begin_frame("MYSQL Error");
    print(
"<BR><b>MySQL error occured</b>.\nQuery: " . $query . "\nError: (" . mysql_errno() . ") " . mysql_error());
    
end_frame();
    
stdfoot();
    die;
}

function 
get_dt_num(){
    return 
gmdate("YmdHis");
}


function 
get_date_time($timestamp = 0){
    if (
$timestamp)
    return 
date("Y-m-d H:i:s", $timestamp);
    else
      return 
gmdate("Y-m-d H:i:s");
}

// Convert UTC to user's timezone
function utc_to_tz ($timestamp=0) {
    GLOBAL 
$CURUSER;
    if (!
is_numeric($timestamp))
        
$timestamp = sql_timestamp_to_unix_timestamp($timestamp);
    if (
$timestamp == 0)
        
$timestamp = gmtime();

    
$timestamp = $timestamp + ($CURUSER['tzoffset']*60);
    return 
date("Y-m-d H:i:s", $timestamp);
}

function 
utc_to_tz_time ($timestamp=0) {
    GLOBAL 
$CURUSER;

    if (!
is_numeric($timestamp))
        
$timestamp = sql_timestamp_to_unix_timestamp($timestamp);
    if (
$timestamp == 0)
        
$timestamp = gmtime();

    
$timestamp = $timestamp + ($CURUSER['tzoffset']*60);
    return 
$timestamp;
}

function 
encodehtml($s, $linebreaks = true) {
      
$s = str_replace("<", "<", str_replace("&", "&", $s));
      if (
$linebreaks)
        
$s = nl2br($s);
      return 
$s;
}


function 
format_urls($s){
    return 
preg_replace(
    
"/(\A|[^=\]'\"a-zA-Z0-9])((http|ftp|https|ftps|irc):\/\/[^<>\s]+)/i",
    
"\\1<a href=http://anonym.to/?\\2 target=_blank>\\2</a>", $s);
}

function 
format_comment($text)
{
    global 
$site_config, $smilies, $privatesmilies;

    
$s = $text;

    
$s = htmlspecialchars($s);
    
$s = stripslashes($s);
    
$s = format_urls($s);

    
// [*]
    
$s = preg_replace("/\[\*\]/", "<li>", $s);

    
// [b]Bold[/b]
    
$s = preg_replace("/\[b\]((\s|.)+?)\[\/b\]/", "<b>\\1</b>", $s);

    
// [i]Italic[/i]
    
$s = preg_replace("/\[i\]((\s|.)+?)\[\/i\]/", "<i>\\1</i>", $s);

    
// [u]Underline[/u]
    
$s = preg_replace("/\[u\]((\s|.)+?)\[\/u\]/", "<u>\\1</u>", $s);

    
// [u]Underline[/u]
    
$s = preg_replace("/\[u\]((\s|.)+?)\[\/u\]/i", "<u>\\1</u>", $s);

    
// [img]http://www/image.gif[/img]
    
$s = preg_replace("/\[img\](http:\/\/[^\s'\"<>]+(\.gif|\.jpg|\.png|\.bmp|\.jpeg))\[\/img\]/i", "<a href=\"\\1\" rel=\"ibox\"><IMG border=\"0\" src=\"\\1\" width=120 title=\"Click to enlarge\"></a>", $s); 

    
// [img=http://www/image.gif]
    
$s = preg_replace("/\[img=(http:\/\/[^\s'\"<>]+(\.gif|\.jpg|\.png|\.bmp|\.jpeg))\]/i", "<a href=\"\\1\" rel=\"ibox\"><IMG border=\"0\" src=\"\\1\" width=120 title=\"Click to enlarge\"></a>", $s); 

    
// [color=blue]Text[/color]
    
$s = preg_replace(
        
"/\[color=([a-zA-Z]+)\]((\s|.)+?)\[\/color\]/i",
        
"<font color=\\1>\\2</font>", $s);

    
// [color=#ffcc99]Text[/color]
    
$s = preg_replace(
        
"/\[color=(#[a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9])\]((\s|.)+?)\[\/color\]/i",
        
"<font color=\\1>\\2</font>", $s);

    
// [url=http://www.example.com]Text[/url]
    
$s = preg_replace(
        
"/\[url=((http|ftp|https|ftps|irc):\/\/[^<>\s]+?)\]((\s|.)+?)\[\/url\]/i",
        
"<a href=http://anonym.to/?\\1 target=_blank>\\3</a>", $s);

    
// [url]http://www.example.com[/url]
    
$s = preg_replace(
        
"/\[url\]((http|ftp|https|ftps|irc):\/\/[^<>\s]+?)\[\/url\]/i",
        
"<a href=http://anonym.to/?\\1 target=_blank>\\1</a>", $s);

    
// [size=4]Text[/size]
    
$s = preg_replace(
        
"/\[size=([1-7])\]((\s|.)+?)\[\/size\]/i",
        
"<font size=\\1>\\2</font>", $s);

    
// [font=Arial]Text[/font]
    
$s = preg_replace(
        
"/\[font=([a-zA-Z ,]+)\]((\s|.)+?)\[\/font\]/i",
        
"<font face=\"\\1\">\\2</font>", $s);

    
//<<<@!2!@>>>
    
$s = preg_replace(
        
"/\<<<@!3!@>>>
    
$s = preg_replace(
        "
/\[quote=(.+?)\]\s*((\s|.)+?)\s*\[\/quote\]\s*/i",
        "
<p class=sub><b>\\1 wrote:</b></p><table class=main border=1 cellspacing=0 cellpadding=10><tr><td style='border: 1px black dotted'>\\2</td></tr></table>", $s);
                
    //[code]Text[/code ]
    
$s = preg_replace(
        "
/\[code\]\s*((\s|.)+?)\s*\[\/code\]\s*/i",
        "
<p><b>Code:</b></p><table class=main border=1 cellspacing=0 cellpadding=10><tr><td style='border: 1px black dotted'>\\1</td></tr></table>", $s);
        

    //[marqueeleft]Text[/marqueeleft]
    
$s = preg_replace(
        "
/\[marqueeleft\]\s*((\s|.)+?)\s*\[\/marqueeleft\]\s*/i",
        "
<div class=marqueetop>Message</div><table class=marquee cellspacing=0 cellpadding=0><tr><td><marquee onmouseover=this.stop() onmouseout=this.start() behavior=scroll scrollamount=1 width=100% direction=left loop=true >\\1</marquee></td></tr></table>", $s);

    //[marqueeright]Text[/marqueeright]
    
$s = preg_replace(
        "
/\[marqueeright\]\s*((\s|.)+?)\s*\[\/marqueeright\]\s*/i",
        "
<div class=marqueetop>Message</div><table class=marquee cellspacing=0 cellpadding=0><tr><td><marquee onmouseover=this.stop() onmouseout=this.start() behavior=scroll scrollamount=1 width=100% direction=right loop=true >\\1</marquee></td></tr></table>", $s);

    //[marqueeup]Text[/marqueeup]
    
$s = preg_replace(
        "
/\[marqueeup\]\s*((\s|.)+?)\s*\[\/marqueeup\]\s*/i",
        "
<div class=marqueetop>Message</div><table class=marquee cellspacing=0 cellpadding=0><tr><td><marquee onmouseover=this.stop() onmouseout=this.start() behavior=scroll scrollamount=1 width=100% direction=up loop=true >\\1</marquee></td></tr></table>", $s);

    //[marqueedown]Text[/marqueedown]
    
$s = preg_replace(
        "
/\[marqueedown\]\s*((\s|.)+?)\s*\[\/marqueedown\]\s*/i",
        "
<div class=marqueetop>Message</div><table class=marquee cellspacing=0 cellpadding=0><tr><td><marquee onmouseover=this.stop() onmouseout=this.start() behavior=scroll scrollamount=1 width=100% direction=down loop=true >\\1</marquee></td></tr></table>", $s);



// [codebox]Some long text[/codebox ]
        
$s = preg_replace(
    '/\[codebox\]\s*((\s|.)+?)\s*\[\/codebox\]\s*/i',
    '<div class="
codetop">CODEBOX</div><div class="codemain" style="OVERFLOW: auto; WHITE-SPACE: pre; width: 99%; HEIGHT: 200px">\\1</div>', $s );


      //[blink]Text[/blink]
    
$s = preg_replace("/\[blink\]((\s|.)+?)\[\/blink\]/", "<blink>\\1</blink>", $s);
 
     //[center]Text[/center]
    
$s = preg_replace("/\[center\]((\s|.)+?)\[\/center\]/", "<center>\\1</center>", $s);
     
     //[left]Text[/left]
    
$s = preg_replace("/\[left\]((\s|.)+?)\[\/left\]/", "<div align=left>\\1</div>", $s);

     //[right]Text[/right]
    
$s = preg_replace("/\[right\]((\s|.)+?)\[\/right\]/", "<div align=right>\\1</div>", $s);

          //[video]http://somesite.com/test.divx[/video]
        
$s = preg_replace("/\[video\]((www.|http:\/\/|https:\/\/)[^\s]+(\.divx))\[\/video\]/i",
        "
<param name=filename value=\\1/><embed width=470 height=310 src=\\1></embed>", $s);

     //[video]http://somesite.com/test.avi[/video]
        
$s = preg_replace("/\[video\]((www.|http:\/\/|https:\/\/)[^\s]+(\.avi))\[\/video\]/i",
        "
<object classid=\"clsid:67DABFBF-D0AB-41fa-9C46-CC0F21721616\" width=\"470\" height=\"310\" codebase=\"http://go.divx.com/plugin/DivXBrowserPlugin.cab\"><param name=\"autoPlay\" value=\"false\" /><param name=\"custommode\" value=\"Stage6\" /><param name=\"mode\" value=\"null\" /><param name=\"autoPlay\" value=\"false\" /><param name=\"allowContextMenu\" value=\"false\" /><param name=\"src\" value=\"\\1\" /><embed type=\"video/divx\" src=\"\\1\" custommode=\"Stage6\" width=\"470\" height=\"310\" mode=\"null\"  autoPlay=\"false\"  allowContextMenu=\"false\"  pluginspage=\"http://go.divx.com/plugin/download\"></embed></object>", $s);


     
//[video]http://somesite.com/test.wmv[/video]
        
$s = preg_replace("/\[video\]((www.|http:\/\/|https:\/\/)[^\s]+(\.wmv))\[\/video\]/i",
        
"<param name=filename value=\\1/><embed width=470 height=310 src=\\1></embed>", $s);

     
//[video]http://somesite.com/test.mp4[/video]
        
$s = preg_replace("/\[video\]((www.|http:\/\/|https:\/\/)[^\s]+(\.mp4))\[\/video\]/i",
        
"<object id=\"MediaPlayer\"  width=\"310\" height=\"280\" classid=\"CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95\" standby=\"Loading Windows Media Player components...\" type=\"application/x-oleobject\" codebase=\"http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=6,4,7,1112\"><param name=\"filename\" value=\"\\1\"><param name=\"Showcontrols\" value=\"True\"><param name=\"autoStart\" value=\"True\"><embed type=\"application/x-mplayer2\" src=\"\\1\" name=\"MediaPlayer\"  width=\"310\"  height=\"280\"> </embed></object>", $s);


     
//[video]http://somesite.com/test.swf[/video]
        
$s = preg_replace("/\[video\]((www.|http:\/\/|https:\/\/)[^\s]+(\.swf))\[\/video\]/i",
        
"<param name=movie value=\\1/><embed width=470 height=310 src=\\1></embed>", $s);

     
//[video=http://somesite.com/test.swf]
        
$s = preg_replace("/\[video=((www.|http:\/\/|https:\/\/)[^\s]+(\.swf))\]/i",
        
"<param name=movie value=\\1/><embed width=470 height=310 src=\\1></embed>", $s);


     
//[audio]http://somesite.com/file.mp3[/audio]
        
$s = preg_replace("/\[audio\]((www.|http:\/\/|https:\/\/)[^\s]+(\.mp3))\[\/audio\]/i","<embed autostart=false loop=false controller=true width=220 height=42 src=\\1></embed>", $s);

     
//[video]YouTube Vids url[/video]
        
$s = preg_replace("/\[tube\][^\s'\"<>]*youtube.com.*v=([^\s'\"<>]+)\[\/tube\]/ims", "<object width=\"330\" height=\"210\"><param name=\"movie\" value=\"http://www.youtube.com/v/\\1\"></param><embed src=\"http://www.youtube.com/v/\\1\" type=\"application/x-shockwave-flash\" width=\"330\" height=\"210\"></embed></object>", $s);

     
//[video]Dailymotion Vids url[/video]
        
$s = preg_replace("/\[video\][^\s'\"<>]*dailymotion.com\/swf\/([^\s'\"<>]+)\[\/video\]/ims", "<object width=\"425\" height=\"356\"><param name=\"movie\" value=\"http://www.dailymotion.com/swf/\\1\"></param><embed src=\"http://www.dailymotion.com/swf/\\1\" type=\"application/x-shockwave-flash\" width=\"500\" height=\"410\"></embed></object>", $s);

     
// [video]Google Vids url[/video]
        
$s = preg_replace("/\[gvideo\][^\s'\"<>]*video.google.com.*docid=(-?[0-9]+).*\[\/gvideo\]/ims", "<embed style=\"width:400px; height:310px;\" id=\"VideoPlayback\" align=\"middle\" type=\"application/x-shockwave-flash\" src=\"http://video.google.com/googleplayer.swf?docId=\\1\" allowScriptAccess=\"sameDomain\" quality=\"best\" bgcolor=\"#ffffff\" scale=\"noScale\" wmode=\"window\" salign=\"TL\"  FlashVars=\"playerMode=embedded\"> </embed>", $s);
    
     
//[hr]
        
$s = preg_replace("/\[hr\]/i", "<hr>", $s);

     
//[hr=#ffffff] [hr=red]
        
$s = preg_replace("/\[hr=((#[a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9])|([a-zA-z]+))\]/i", "<hr color=\"\\1\"/>", $s);

        
//[swf]http://somesite.com/test.swf[/swf]
        
$s = preg_replace("/\[swf\]((www.|http:\/\/|https:\/\/)[^\s]+(\.swf))\[\/swf\]/i",
        
"<param name=movie value=\\1/><embed width=470 height=310 src=\\1></embed>", $s);

        
//[swf=http://somesite.com/test.swf]
        
$s = preg_replace("/\[swf=((www.|http:\/\/|https:\/\/)[^\s]+(\.swf))\]/i",
        
"<param name=movie value=\\1/><embed width=470 height=310 src=\\1></embed>", $s);

    
// Linebreaks
    
$s = nl2br($s);

    
// Maintain spacing
    
$s = str_replace("  ", " &nbsp;", $s);

    
// Smilies
    
require_once("smilies.php");
    
reset($smilies);
    while (list(
$code, $url) = each($smilies))
        
$s = str_replace($code, "<img border=0 src=" . $site_config['SITEURL'] . "/images/smilies/$url>", $s);

    
reset($privatesmilies);
    while (list(
$code, $url) = each($privatesmilies))
        
$s = str_replace($code, "<img border=0 src=" . $site_config['SITEURL'] . "/images/smilies/$url>", $s);

    
$r = mysql_query("SELECT * FROM censor");
    while(
$rr=mysql_fetch_row($r))
        
$s = preg_replace("/".preg_quote($rr[0])."/i", $rr[1], $s);

    return 
$s;
}



function 
torrenttable($res) {
    global 
$site_config, $CURUSER, $THEME, $LANGUAGE;  //Define globals

    
if ($site_config["MEMBERSONLY_WAIT"] && $site_config["MEMBERSONLY"] && in_array($CURUSER["class"], explode(",",$site_config["WAIT_CLASS"]))) {
        
$gigs = $CURUSER["uploaded"] / (1024*1024*1024);
        
$ratio = (($CURUSER["downloaded"] > 0) ? ($CURUSER["uploaded"] / $CURUSER["downloaded"]) : 0);
        if (
$ratio < 0 || $gigs < 0) $wait = $site_config["WAITA"];
        elseif (
$ratio < $site_config["RATIOA"] || $gigs < $site_config["GIGSA"]) $wait = $site_config["WAITA"];
        elseif (
$ratio < $site_config["RATIOB"] || $gigs < $site_config["GIGSB"]) $wait = $site_config["WAITB"];
        elseif (
$ratio < $site_config["RATIOC"] || $gigs < $site_config["GIGSC"]) $wait = $site_config["WAITC"];
        elseif (
$ratio < $site_config["RATIOD"] || $gigs < $site_config["GIGSD"]) $wait = $site_config["WAITD"];
        else 
$wait = 0;
    }

    
// Columns
    
$cols = explode(",", $site_config["torrenttable_columns"]);
    
$cols = array_map("strtolower", $cols);
    
$cols = array_map("trim", $cols);
    
$colspan = count($cols);
    
// End
    
    // Expanding Area
    
$expandrows = array();
    if (!empty(
$site_config["torrenttable_expand"])) {
        
$expandrows = explode(",", $site_config["torrenttable_expand"]);
        
$expandrows = array_map("strtolower", $expandrows);
        
$expandrows = array_map("trim", $expandrows);
    }
    
// End
    
    
echo '<table align=center cellpadding="0" cellspacing="0" class="ttable_headinner" width=100%><tr>';

    foreach (
$cols as $col) {
        switch (
$col) {
            case 
'category':
                echo 
"<td class=ttable_head>".TYPE."</td>";
            break;
            case 
'name':
                echo 
"<td class=ttable_head>".NAME."</td>";
            break;
            
            case 
'uploader':
                echo 
"<td class=ttable_head>".UPLOADER."</td>";
            break;
            case 
'comments':
                echo 
"<td class=ttable_head><img src=\"".$site_config["SITEURL"]."/images/torrent/comments.png\" border=\"0\" alt=\"Comments\"></td>";
            break;
            case 
'nfo':
                echo 
"<td class=ttable_head>NFO</td>";
            break;
            case 
'size':
                echo 
"<td class=ttable_head>".SIZE."</td>";
            break;
            case 
'youtube':
                echo 
"<td class=ttable_head><img src=\"".$site_config["SITEURL"]."/images/torrent/youtube.png\" border=\"0\" alt=\"Youtube trailer\"></td>";
            break;
            case 
'completed':
                echo 
"<td class=ttable_head><img src=\"".$site_config["SITEURL"]."/images/torrent/completed.png\" border=\"0\" alt=\"Snatched\"></td>";
            break;
            case 
'seeders':
                echo 
"<td class=ttable_head><img src=\"".$site_config["SITEURL"]."/images/torrent/seeders.png\" border=\"0\" alt=\"Seeders\"></td>";
            break;
            case 
'leechers':
                echo 
"<td class=ttable_head><img src=\"".$site_config["SITEURL"]."/images/torrent/leechers.png\" border=\"0\" alt=\"Leechers\"></td>";
            
            break;
            case 
'external':
                if (
$site_config["ALLOWEXTERNAL"])
                    echo 
"<td class=ttable_head><img src=\"".$site_config["SITEURL"]."/images/torrent/trackedby.png\" border=\"0\" alt=\"Local/External\"></td>";
            break;
            case 
'added':
                echo 
"<td class=ttable_head>".DATE_ADDED."</td>";
            break;
            case 
'speed':
                echo 
"<td class=ttable_head>".SPEED."</td>";
            break;
            case 
'wait':
                if (
$wait)
                    echo 
"<td class=ttable_head>".WAIT."</td>";
            break;
            case 
'rating':
                echo 
"<td class=ttable_head>".RATINGS."</td>";
            break;
        }
    }
    if (
$wait && !in_array("wait", $cols))
        echo 
"<td class=ttable_head>".WAIT."</td>";
    
    echo 
"</tr>";

    while (
$row = mysql_fetch_assoc($res)) { 
        
$id = $row["id"];

        print(
"<tr>\n");

    
$x = 1;

    foreach (
$cols as $col) {
        switch (
$col) {
            case 
'category':
                print(
"<td class=ttable_col$x align=center valign=middle>");
                if (!empty(
$row["cat_name"])) {
                    print(
"<a href=\"torrents.php?cat=" . $row["category"] . "\">");
                    if (!empty(
$row["cat_pic"]) && $row["cat_pic"] != "")
                        print(
"<img border=\"0\"src=\"" . $site_config['SITEURL'] . "/images/categories/" . $row["cat_pic"] . "\" alt=\"" . $row["cat_name"] . "\" />");
                    else
                        print(
$row["cat_parent"].": ".$row["cat_name"]);
                    print(
"</a>");
                } else
                    print(
"-");
                print(
"</td>\n");
            break;
            case 
'name':
                
$char1 = 35; //cut name length 
                
$smallname = CutName(htmlspecialchars($row["name"]), $char1);
                
$dispname = "<b>".$smallname."</b>";

                
$last_access = $CURUSER["last_browse"];
                
$time_now = gmtime();
                if (
$last_access > $time_now || !is_numeric($last_access))
                    
$last_access = $time_now;
                if (
sql_timestamp_to_unix_timestamp($row["added"]) >= $last_access)
                    
$dispname .= "</a><img src='images/new.gif' border='0'>";
                        if (
$row["sticky"] == "yes")
                    
$dispname .= " </a><img src='images/sticky.gif' border='0' alt=Sticky>";
                        
$nuked_res = mysql_query("SELECT nuked FROM torrents WHERE id=$id") or
                        
sqlerr(__FILE__, __LINE__);
                        
$nuked_row = mysql_fetch_assoc($nuked_res);
                if (
$nuked_row["nuked"] == "yes")
                    
$dispname .= " </a>&nbsp;<img src='images/nuked.gif' border='0' alt=Nuked>";
                if (
$row["freeleech"] == 1)
                    
$dispname .= " </a><img src='images/free.gif' border='0' alt=Free>";
                if (
$row["vip"] == y)
                    
$dispname .= " </a><img src='images/vip.gif' border='0' alt=Vip Torrent";
                 
$resdet = mysql_query("SELECT views, hits, tube, times_completed, torrentlang.name AS lang_name, torrentage.name AS age_name, torrentage.image AS age_image FROM torrents LEFT JOIN torrentlang ON torrentlang = torrentlang.id  LEFT JOIN torrentage ON torrents.torrentage = torrentage.id  WHERE torrents.id = $id") or die(mysql_error());
                
$rowdet = mysql_fetch_array($resdet);
                
$bimg = @mysql_fetch_array(@mysql_query("SELECT image1 FROM torrents WHERE id=$id"));
                
$balon =($bimg["image1"] ? "$site_config[SITEURL]/uploads/images/" . htmlspecialchars($bimg["image1"]) : "http://bvlist.com/images/nocover.jpg");
                
$descr = "<table width=100% class=ttable_col1 cellspacing=0 cellpadding=5 align=center><tr><td class=ttable_head colspan=2 align=center>$smallname</td></tr><tr valign=top><td align=center><img border=0 width=120 src=$balon></td><td><div align=left><b>Date Added: </b>" . date("d-m-Y", utc_to_tz_time($row["added"])) . "<b>Size: </b>". mksize($row["size"]) . "<b>Snatched: </b>" . $rowdet["times_completed"] . "</div><div align=left><b>Views: </b>" . $rowdet["views"] . "<b>Language: </b>" .$rowdet["lang_name"] ."<b>Hits: </b>" . $rowdet["hits"] . "<b>Seeders: </b><font color=green>" . $row["seeders"] . "</font><b>Leechers: </b><font color=red>" . $row["leechers"] . "</font></div></td></tr></table>"; 
                
/// END BALONN MOD ///
                
print("<td class=ttable_col$x nowrap>".(count($expandrows)?" <a href=\"javascript: klappe_torrent('t".$row['id']."')\"><img border=\"0\" src=\"".$site_config["SITEURL"]."/images/plus.gif\" id=\"pict".$row['id']."\" alt=\"Show/Hide\" class=\"showthecross\"></a>":"")."&nbsp;<a href=\"torrents-details.php?id=$id&hit=1\" onMouseover=\"return overlib('$descr')\"; onMouseout=\"return nd()\">$dispname</td>");

            break;
        
            case 
'uploader':
                echo 
"<td class=ttable_col$x align=center>"; 
                if ((
$row["anon"] == "yes" || $row["privacy"] == "strong") && $CURUSER["id"] != $row["owner"] && $CURUSER["edit_torrents"] != "yes")
                    echo 
"Anonymous";
                elseif (
$row["username"]) 
                    echo 
"<a href='account-details.php?id=$row[owner]'>$row[username]</a>";
                else
                    echo 
"Unknown";
                echo 
"</td>";
            break;
            case 
'comments':
                print(
"<td class=ttable_col$x align=center><font size=1 face=Verdana><a href=comments.php?type=torrent&id=$id>" . $row["comments"] . "</a></td>\n");
            break;
            case 
'nfo':
                if (
$row["nfo"] == "yes")
                    print(
"<td class=ttable_col$x align=center><a href=nfo-view.php?id=$row[id]><img  src=" . $site_config['SITEURL'] . "/images/icon_nfo.gif border=0 alt='View NFO'></a></td>");
                else
                    print(
"<td class=ttable_col$x align=center>-</td>");
            break;
            case 
'size':
                print(
"<td class=ttable_col$x align=center>".mksize($row["size"])."</td>\n");
            break;
            case 
'youtube':
            
             if (
$site_config["AGEON"] && $CURUSER["class"] <=3) {
                 if (
$CURUSER["age"] < $rowdet["age_name"]){
                    
$torrentube =  "<a href=\"" . $site_config['SITEURL'] . "/images/torrent/novideo.jpg\" rel=\"ibox\"><img  src=" . $site_config['SITEURL'] . "/images/torrent/play.png border=0 alt='View Trailer'></a>";                                                          
                 } else{
                 
$torrentube =  "<a href=". str_replace("watch?v=", "v/", htmlspecialchars($rowdet["tube"])) ." rel=\"ibox\"><img  src=" . $site_config['SITEURL'] . "/images/torrent/play.png border=0 alt='View Trailer'></a>";
                 } 
             }else{          
                 
$torrentube =  "<a href=". str_replace("watch?v=", "v/", htmlspecialchars($rowdet["tube"])) ." rel=\"ibox\"><img  src=" . $site_config['SITEURL'] . "/images/torrent/play.png border=0 alt='View Trailer'></a>";
             }
                if (!empty(
$rowdet["tube"]))
                    print(
"<td class=ttable_col$x align=center>$torrentube</td>");
                else
                    print(
"<td class=ttable_col$x align=center>-</td>");
            break;
            case 
'completed':
                print(
"<td class=ttable_col$x align=center><font color=blue><B>".number_format($row["times_completed"])."</B></font></td>");
            break;
            case 
'seeders':
                print(
"<td class=ttable_col$x align=center><b><font color=green><B>".number_format($row["seeders"])."</b></font></td>\n");
            break;
            case 
'leechers':
                print(
"<td class=ttable_col$x align=center><font color=red><B>" . $row["leechers"] . "</b></font></td>\n");
            break;
            
            case 
'external':
                if (
$site_config["ALLOWEXTERNAL"]){
                    if (
$row["external"]=='yes')
                        print(
"<td class=ttable_col$x align=center><img src=\"".$site_config["SITEURL"]."/images/torrent/extern.png\" border=\"0\" alt=\"Extern\"></td>\n");
                    else
                        print(
"<td class=ttable_col$x align=center><img src=\"".$site_config["SITEURL"]."/images/torrent/intern.png\" border=\"0\" alt=\"Local\"></td>\n");
                }
            break;
            case 
'added':
                print(
"<td class=ttable_col$x align=center>".date("d-m-Y<\\B\\R>H:i:s", utc_to_tz_time($row['added']))."</td>");
            break;
            case 
'speed':
                if (
$row["external"] != "yes" && $row["leechers"] >= 1){
                    
$speedQ = mysql_query("SELECT (SUM(downloaded)) / (UNIX_TIMESTAMP('".get_date_time()."') - UNIX_TIMESTAMP(started)) AS totalspeed FROM peers WHERE seeder = 'no' AND torrent = '$id'ORDER BY started ASC") or die(mysql_error());
                    
$a = mysql_fetch_assoc($speedQ);
                    
$totalspeed = mksize($a["totalspeed"]) . "/s";
                } else
                    
$totalspeed = "--";
            print(
"<td class=ttable_col$x align=center>$totalspeed</td>");
            break;
            case 
'wait':
                if (
$wait){
                    
$elapsed = floor((gmtime() - strtotime($row["added"])) / 3600);
                    if (
$elapsed < $wait && $row["external"] != "yes") {
                        
$color = dechex(floor(127*($wait - $elapsed)/48 + 128)*65536);
                        print(
"<td class=ttable_col$x align=center><a href=\"faq.php\"><font color=\"$color\">" . number_format($wait - $elapsed) . " h</font></a></td>\n");
                    } else
                        print(
"<td class=ttable_col$x align=center>--</td>\n");
                }
            break;
            case 
'rating':
                if (!
$row["rating"])
                    
$rating = "--";
                else
                    
$rating = "<a title='$row[rating]/5'>".ratingpic($row["rating"])."</a>";
                    
//$rating = ratingpic($row["rating"]);
                     //$srating .= "$rpic (" . $row["rating"] . " out of 5) " . $row["numratings"] . " users have rated this torrent";
                
print("<td class=ttable_col$x align=center>$rating</td>");
            break;
        }
        if (
$x == 2)
            
$x--;
        else
            
$x++;
    }

    
        
//Wait Time Check
        
if ($wait && !in_array("wait", $cols)) {
            
$elapsed = floor((gmtime() - strtotime($row["added"])) / 3600);
            if (
$elapsed < $wait && $row["external"] != "yes") {
                
$color = dechex(floor(127*($wait - $elapsed)/48 + 128)*65536);
                print(
"<td class=ttable_col$x align=center><a href=\"faq.php\"><font color=\"$color\">" . number_format($wait - $elapsed) . " h</font></a></td>\n");
            } else
                print(
"<td class=ttable_col$x align=center>--</td>\n");
            
$colspan++;
            if (
$x == 2)
                
$x--;
            else
                
$x++;
        }
        
        print(
"</tr>\n");

        
//Expanding area
        
if (count($expandrows)) {
            print(
"<tr><td class=ttable_col$x colspan=$colspan><div id=\"kt".$row['id']."\" style=\"margin-left: 70px; display: none;\">");
            print(
"<table width=97% border=0 cellspacing=0 cellpadding=0>");
            foreach (
$expandrows as $expandrow) {
                switch (
$expandrow) {
                    case 
'size':
                        print(
"<tr><td><B>".SIZE."</B>: ".mksize($row['size'])."</td></tr>");
                    break;
                    case 
'speed':
                        if (
$row["external"] != "yes" && $row["leechers"] >= 1){
                            
$speedQ = mysql_query("SELECT (SUM(downloaded)) / (UNIX_TIMESTAMP('".get_date_time()."') - UNIX_TIMESTAMP(started)) AS totalspeed FROM peers WHERE seeder = 'no' AND torrent = '$id'ORDER BY started ASC") or die(mysql_error());
                            
$a = mysql_fetch_assoc($speedQ);
                            
$totalspeed = mksize($a["totalspeed"]) . "/s";
                            print(
"<tr><td><B>Speed:</B> $totalspeed</td></tr>");
                        }
                    break;
                    case 
'added':
                        print(
"<tr><td><B>".DATE_ADDED.":</B> ".date("d-m-Y \\a\\t H:i:s", utc_to_tz_time($row['added']))."</td></tr>");
                    break;
                    case 
'tracker':
                    if (
$row["external"] == "yes")
                        print(
"<tr><td><B>".TRACKER.":</B> ".htmlspecialchars($row["announce"])."</td></tr>");
                    break;
                    case 
'completed':
                        print(
"<tr><td><B>".COMPLETED."</B>: ".$row['times_completed']."</td></tr>");
                    break;
                         case 
'uploader':
                       echo
"<tr><td><B>".UPLOADER."</B>:";
                       if ((
$row["anon"] == "yes" || $row["privacy"] == "strong") && $CURUSER["id"] != $row["owner"] && $CURUSER["edit_torrents"] != "yes")
                    echo 
"Anonymous";
                      elseif (
$row["username"])
                          echo 
"<a href='account-details.php?id=$row[owner]'>$row[username]</a>";
                       else
                    echo 
"Unknown";
                       echo 
"</td></tr>";
                        break;
                      case 
'health':
                    print(
"<tr><td><B>".HEALTH."</B>: <img src=".$site_config["SITEURL"]."/images/health_".health($row["leechers"], $row["seeders"]).".gif></td></tr>\n");
                      break;
                }
            }
                print(
"</table></div></td></tr>\n");
        }
        
//End Expanding Area


    
}

    print(
"</table><BR>\n");

}

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 = "&nbsp;<img src=\"http://bvlist.com/images/torrent/prev.png\" border=\"0\" alt=\"Preview page\">";
    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 = "<img src=\"http://bvlist.com/images/torrent/next.png\" border=\"0\" alt=\"Next page\">&nbsp;";
    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$pagerstr</p>\n";
        
$pagerbottom = "<p align=\"center\">$pagerstr$pager</p>\n";
    }
    else {
        
$pagertop = "<p align=\"center\">$pager</p>\n";
        
$pagerbottom = $pagertop;
    }

    
$start = $page * $rpp;

    return array(
$pagertop, $pagerbottom, "LIMIT $start,$rpp");
}

//Commenttable FIX by hack346
function commenttable($res) {
    global 
$site_config, $CURUSER, $THEME, $LANGUAGE;  //Define globals
    
while ($row = mysql_fetch_assoc($res)) {

        
$postername = htmlspecialchars($row["username"]);
        if (
$postername == "") {
            
$postername = "Deluser";
            
$title = "Deleted Account";
            
$avatar = "";
            
$usersignature = "";
            
$userdownloaded = "";
            
$useruploaded = "";
        }else {
            
$privacylevel = $row["privacy"];
            
$avatar = htmlspecialchars($row["avatar"]);
            
$class = get_user_class_name($row["class"]);
            
$title =  htmlspecialchars($row["title"]);
            
$usersignature = stripslashes(format_comment($row["signature"]));
            
$userdownloaded = mksize($row["downloaded"]);
            
$useruploaded = mksize($row["uploaded"]); 
            
$gender =  htmlspecialchars($row["gender"]);
        }

        if (
$row["downloaded"] > 0)
            
$userratio = number_format($row["uploaded"] / $row["downloaded"], 2);
        else
            
$userratio = "---";

        if (!
$avatar)
            
$avatar = "".$site_config["SITEURL"]."/images/default_avatar.gif";
        
$commenttext = format_comment($row["text"]);
        
$type = $_GET["type"]; 
        if(!
$type)
        
$type = "torrent"; 
        print(
"<table border=0 width=100% cellpadding=4>\n");

        print(
"<tr><td colspan=2 align=right class=table_col1>");

        if(
$CURUSER["edit_torrents"]=="yes" || $CURUSER["edit_forum"]=="yes" || $CURUSER['id'] == $row['user']){
            print(
"[<a href=comments.php?id=" . $row["id"] . "&type=$type&edit=1>edit</a>]&nbsp;");
        }
        if(
$CURUSER["delete_torrents"]=="yes" || $CURUSER["delete_forum"]=="yes"){
            print(
"[<a href=comments.php?id=" . $row["id"] . "&type=$type&delete=1>delete</a>]&nbsp;");
        }

        print(
"[<a href=report.php?comment=" . $row["id"] . ">Report</a>]&nbsp;");

        print(
"Posted: ".date("d-m-Y \\a\\t H:i:s", utc_to_tz_time($row['added'])));
        print(
"</td></tr>");
            if (
$row["donated"] > 0) { 
            
$donated = "<img src=images/users/money.png border=0 alt=Donor>";
            } else {
            
$donated = "";
            }

        if (
$privacylevel != "strong" || ($CURUSER["control_panel"] == "yes")) {
            print(
"<tr><td valign=top width=120 align=left class=table_col2><center><b>$postername $donated</b><img width=120 height=120 src=$avatar></center>Class: $class<center>$title Uploaded: $useruploadedDownloaded: $userdownloadedRatio: <font color=".get_ratio_color($userratio).">$userratio</font>Gender: <img src=".get_user_gender_image($gender)."></td>");
        }else{
            print(
"<tr><td valign=top width=120 align=left class=table_col2><center><b>$postername $donated</b><img width=120 height=120 src=$avatar></center><center><i>$title</i></center>Uploaded: ---Downloaded: ---Ratio: ---</td>");
        }
        print(
"<td valign=top width='75%' class=table_col2>$commenttext");
        if(
$usersignature){
        print(
"<div style=\"padding-top:40%;\"><FIELDSET><LEGEND>Signature</LEGEND>$usersignature</FIELDSET></div></td>");
        }else{
            print(
"</td>");
        }
        print(
"</tr></table><BR>\n");
    }
}


function 
checker(){ 
GLOBAL 
$site_config, $THEME; 
$file = file_get_contents("themes/$THEME/footer.php");
if(!
strpos($file, "license")) {
show_error_msg("Warning!", "Copyright removed or changed ");
}
} 

function 
where ($scriptname = "index", $userid){
    if (!
is_valid_id($userid))
        die;
    if (
preg_match("/torrents-details/i", $scriptname))
        
$where = "Browsing Torrents Details...";
    elseif (
preg_match("/torrents/i", $scriptname))
        
$where = "Browsing Torrent Lists...";
    elseif (
preg_match("/account-details/i", $scriptname))
        
$where = "Browsing Account Details...";
    elseif (
preg_match("/torrents-upload/i", $scriptname))
        
$where = "Uploading Torrent..";
    elseif (
preg_match("/account/i", $scriptname))
        
$where = "Browsing User Control Panel...";
    elseif (
preg_match("/torrents-search/i", $scriptname))
        
$where = "Searching...";
    elseif (
preg_match("/forums/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)
        die;
    else
        return 
$where;
}

function 
get_user_class_name($i){
    
$res=mysql_query("SELECT level FROM groups WHERE group_id=".$i."");
    
$row=mysql_fetch_row($res);
    return 
$row[0];
}

function 
get_user_class(){
  global 
$CURUSER;
  return 
$CURUSER["class"];
}
 
function 
get_user_gender_image($gender)
{
  switch (
$gender)
  {
    case 
Male: return "http://bvlist.com/images/users/male.png alt=\"Male\"";
  
    case 
Female: return "http://bvlist.com/images/users/female.png alt=\"Female\"";
    
    case 
'': return "http://bvlist.com/images/users/na.png alt=\"Gender Not Selected\""; 
  }
  return 
"";
}  

function 
get_user_class_image($class)
{
  switch (
$class)
  {
    case 
1: return "http://bvlist.com/images/class/user.png";

    case 
2: return "http://bvlist.com/images/class/power.png";

    case 
3: return "http://bvlist.com/images/class/vip.png";

    case 
4: return "http://bvlist.com/images/class/uploader.png";

    case 
5: return "http://bvlist.com/images/class/mod.png";

    case 
6: return "http://bvlist.com/images/class/supmod.png";

    case 
7: return "http://bvlist.com/images/class/admin.png";
  }
  return 
"";
} 


function 
get_level_value($level)
{
  switch (
$level)
  {
    case 
yes: return "<img src=images/admin/yes.png alt=\"Yes\">";
  
    case 
no: return "<img src=images/admin/no.png alt=\"No\">";
  }
  return 
"";
} 

function 
reqcommenttable($rows)
{
global 
$site_config, $CURUSER, $THEME, $LANGUAGE;
$count = 0;

foreach (
$rows as $row)
{
        
$postername = htmlspecialchars($row["username"]);
        if (
$postername == "") {
            
$postername = "Deluser";
            
$title = "Deleted Account";
            
$avatar = "";
            
$usersignature = "";
            
$userdownloaded = "";
            
$useruploaded = "";
        }else {
            
$privacylevel = $row["privacy"];
            
$avatar = htmlspecialchars($row["avatar"]);
            
$class = get_user_class_name($row["class"]);
            
$title =  htmlspecialchars($row["title"]);
            
$usersignature = stripslashes(format_comment($row["signature"]));
            
$userdownloaded = mksize($row["downloaded"]);
            
$useruploaded = mksize($row["uploaded"]); 
            
$gender =  htmlspecialchars($row["gender"]);
        }

        if (
$row["downloaded"] > 0)
            
$userratio = number_format($row["uploaded"] / $row["downloaded"], 2);
        else
            
$userratio = "---";

        if (!
$avatar)
            
$avatar = "".$site_config["SITEURL"]."/images/default_avatar.gif";
$text = format_comment($row["text"]);
if (
$row["editedby"])
$text .= "<p><font size=1 class=small>Edited by <a
href=userdetails.php?id=
$row[editedby]><b>$row[username]</b></a> $row[editedat] GMT</font></p>\n";
        print(
"<table border=0 width=100% cellpadding=4>\n");

        print(
"<tr><td colspan=2 align=right class=table_col1>");

        if(
$CURUSER["edit_torrents"]=="yes" || $CURUSER["class"] >=5 || $CURUSER['id'] == $row['user']){
            print(
"[<a href=reqcomment.php?action=edit&cid=" . $row["id"] . ">edit</a>]&nbsp;");
        }
        if(
$CURUSER["delete_torrents"]=="yes" || $CURUSER["class"] >=5){
            print(
"[<a href=reqcomment.php?action=delete&cid=" . $row["id"] . ">delete</a>]&nbsp;");
        }

        print(
"[<a href=reqcomment.php?action=vieworiginal&cid=" . $row["id"] . ">View original</a>]&nbsp;");

        print(
"Posted: ".date("d-m-Y \\a\\t H:i:s", utc_to_tz_time($row['added'])));
        print(
"</td></tr>");
            if (
$row["donated"] > 0) { 
            
$donated = "<img src=images/users/money.png border=0 alt=Donor>";
            } else {
            
$donated = "";
            }

        if (
$privacylevel != "strong" || ($CURUSER["control_panel"] == "yes")) {
            print(
"<tr><td valign=top width=120 align=left class=table_col2><center><b>$postername $donated</b><img width=120 height=120 src=$avatar></center>Class: $class<center>$title Uploaded: $useruploadedDownloaded: $userdownloadedRatio: <font color=".get_ratio_color($userratio).">$userratio</font>Gender: <img src=".get_user_gender_image($gender)."></td>");
        }else{
            print(
"<tr><td valign=top width=120 align=left class=table_col2><center><b>$postername $donated</b><img width=120 height=120 src=$avatar></center><center><i>$title</i></center>Uploaded: ---Downloaded: ---Ratio: ---</td>");
        }
        print(
"<td valign=top width='75%' class=table_col2>$text");
        if(
$usersignature){
        print(
"<div style=\"padding-top:40%;\"><FIELDSET><LEGEND>Signature</LEGEND>$usersignature</FIELDSET></div></td>");
        }else{
            print(
"</td>");
        }
        print(
"</tr></table><BR>\n");
}
}

function 
get_ratio_color($ratio) {
    if (
$ratio < 0.1) return "#ff0000";
    if (
$ratio < 0.2) return "#ee0000";
    if (
$ratio < 0.3) return "#dd0000";
    if (
$ratio < 0.4) return "#cc0000";
    if (
$ratio < 0.5) return "#bb0000";
    if (
$ratio < 0.6) return "#aa0000";
    if (
$ratio < 0.7) return "#990000";
    if (
$ratio < 0.8) return "#880000";
    if (
$ratio < 0.9) return "#770000";
    if (
$ratio < 1) return "#660000";
    return 
"green";
}

function 
ratingpic($num) {
    GLOBAL 
$site_config;
    
$r = round($num * 2) / 2;
    if (
$r != $num) {
        
$n = $num-$r;
        if (
$n < .25)
            
$n = 0;
        elseif (
$n >= .25 && $n < .75)
            
$n = .5;
        
$r += $n;
    }
    if (
$r < 1 || $r > 5)
        return;

    return 
"<img src=\"".$site_config["SITEURL"]."/images/rating/$r.gif\" border=\"0\" alt=\"rating: $num/5\" />";
}

function 
DateDiff ($start, $end) {
    if (!
is_numeric($start))
        
$start = sql_timestamp_to_unix_timestamp($start);
    if (!
is_numeric($end))
        
$end = sql_timestamp_to_unix_timestamp($end);
    return (
$end - $start);
}

function 
autolink($al_url, $al_msg)     // create autolink
{
        
stdhead("Redirecting");
        
begin_frame("Redirecting");
        echo 
"\n<meta http-equiv=\"refresh\" content=\"2; URL=$al_url\">\n";
        echo 
"<center><b>$al_msg</b>\n";
        echo 
"<p>\n<b><div class=success>Redirecting ...</div></b>\n";
        echo 
"<p>\n[ <a href='$al_url'>Click here if u are not redirected</a> ]</center>\n";
        
end_frame();
        
stdfoot();
        exit;
}

function 
classlist() {
    
$ret = array();
    
$res = mysql_query("SELECT * FROM groups ORDER BY group_id ASC");
    while (
$row = mysql_fetch_array($res))
        
$ret[] = $row;
    return 
$ret;
}

function 
sql_query($query)
  {
  ++
$_SESSION['totalqueries'];
  return 
mysql_query($query);
  }
  
function 
write_transferlog($text)
{
$text = sqlesc($text);
$added = sqlesc(get_date_time());
mysql_query("INSERT INTO transferlog (added, txt) VALUES($added, $text)")  or die(mysql_error());
}

function 
parked() {
       global 
$CURUSER;
       if (
$CURUSER["parked"] == "yes")
show_error_msg("Error", "your account is parked.", 1);
} 

function 
license(){
global 
$GLOBALS, $site_config;
return 
$license = "<center>Powered by ".$site_config["license"]." v.".$site_config['h-trackerversion']."</center>";
}  

function 
generated(){
global 
$GLOBALS, $site_config;
$totaltime = array_sum(explode(" ", microtime())) - $GLOBALS['tstart'];
return 
printf("Page generated in %f", $totaltime);
} 


function 
ads(){
$res = mysql_query("SELECT id, banners, site_url FROM ads WHERE approved = 'yes' ORDER BY RAND()") or die(mysql_error());
while (
$row = mysql_fetch_assoc($res)) {
  return 
"<center><a href='".htmlspecialchars($row["site_url"])."'><img src=".htmlspecialchars($row["banners"])." border=0></a></center>";

}



} 
 
 
?>


oopss 1st March 2010 00:41

Quote:

Originally Posted by raefor (Post 21304)

you can try this one

:sorry: not work.. comments not editing..help pleaz :shock:

comments.php
Line 128

PHP Code:

begin_frame("" . COMMENTS . "");
    
    
$subres = mysql_query("SELECT COUNT(*) FROM comments WHERE $type = $id") or die(mysql_error());
    
$subrow = mysql_fetch_array($subres);
    
$commcount = $subrow[0];

    if (
$commcount) {
        list(
$pagertop, $pagerbottom, $limit) = pager(10, $commcount, "comments.php?id=$id&type=$type&");
        
$commquery = "SELECT comments.id, text, user, comments.added, avatar, signature, username, title, class, uploaded, downloaded, privacy, donated FROM comments LEFT JOIN users ON comments.user = users.id WHERE $type = $id ORDER BY comments.id $limit";
        
$commres = mysql_query($commquery) or die(mysql_error());
    }else{
        unset(
$commres);
    }

    if (
$commcount) {
        print(
$pagertop);
        
commenttable($commres);
        print(
$pagerbottom);
    }else {
        print(
"<BR><b><CENTER>" . NOCOMMENTS . "</CENTER></b><BR>\n");
    }

    echo 
"<CENTER>";
    echo 
"<form name=\"comment\" method=\"post\" action=\"comments.php?type=$type&id=$id&takecomment=yes\">";
    echo 
"".textbbcode("comment","body")."";
    echo 
"<input type=\"submit\" class=btn value=\"Add Comment\" />";
    echo 
"</form></CENTER>";

    
end_frame();

stdfoot();
?> 


melcu66 3rd March 2010 23:12

Quote:

Originally Posted by raefor (Post 21340)
you can try this or edit your functions.php

PHP Code:

<?php
//
//
//
//
error_reporting(E_ALL ^ E_NOTICE);
// register_globals on *fix*
if (!ini_get("register_globals")) {
    
import_request_variables('GPC');
}
 
//If running on a windows server you "may" have to use absolute paths here
 
require_once("mysql.php"); //Get MYSQL Connection Info
require_once("config.php");  //Get Site Settings and Vars ($site_config)  
require("tzs.php"); // Get Timezones
require("ctracker.php");
 
 
function 
dbconn($autoclean = false) {
    global 
$mysql_host, $mysql_user, $mysql_pass, $mysql_db, $THEME, $LANGUAGE, $site_config;
 
    if (!
ob_get_level()) {
        if (
extension_loaded('zlib') && !ini_get('zlib.output_compression'))
            
ob_start('ob_gzhandler');
        else
            
ob_start();
    } 
 
    
header("Content-Type: text/html;charset=$site_config[CHARSET]");
 
    if (!
function_exists("mysql_connect"))
        die(
"MySQL support not available.");
 
    if (!@
mysql_connect($mysql_host, $mysql_user, $mysql_pass))
    {
         die(
"<center><img src=\"http://bvlist.com/images/mysqlerror.png\" border=\"0\" alt=\"Powered by h-tracker.org\"><strong>There seems to be a problem with the MySQL server,<font color=red>" . mysql_error() ."</font>We should be back shortly.</strong></center>");                                                                                                                   
    }
     
mysql_select_db($mysql_db)
        or die(
"<center><img src=\"http://bvlist.com/images/mysqlerror.png\" border=\"0\" alt=\"Powered by h-tracker.org\"><strong>There seems to be a problem with the MySQL server,<font color=red>" . mysql_error() ."</font>Check your settings.</strong></center>");
 
    unset(
$mysql_pass); //security
 
    
userlogin(); //Get user info    
 
    //Get language and theme
    
$CURUSER = $GLOBALS["CURUSER"];
    if (
$CURUSER)  {
        
$ss_a = @mysql_fetch_array(@mysql_query("SELECT uri FROM stylesheets WHERE id=$CURUSER[stylesheet]"));
        if (
$ss_a)
            
$THEME = $ss_a["uri"];
        else {
            
$ss_a = @mysql_fetch_array(@mysql_query("select uri from stylesheets where id=$site_config[default_theme]"));
            
$THEME = $ss_a['uri'];
        }
        
$lng_a = @mysql_fetch_array(@mysql_query("select uri from languages where id=$CURUSER[language]"));
        if (
$lng_a)
            
$LANGUAGE = $lng_a["uri"];
        else {
            
$lng_a = @mysql_fetch_array(@mysql_query("select uri from languages where id=$site_config[default_language]"));
            
$LANGUAGE = $lng_a['uri'];
        }
    }else{
//not logged in so get default theme/language
        
$ss_a = mysql_fetch_array(mysql_query("select uri from stylesheets where id='" . $site_config['default_theme'] . "'")) or die(mysql_error());
        if (
$ss_a)
            
$THEME = $ss_a["uri"];
        
$lng_a = mysql_fetch_array(mysql_query("select uri from languages where id='" . $site_config['default_language'] . "'")) or die(mysql_error());
        if (
$lng_a)
            
$LANGUAGE = $lng_a["uri"];
    }
    require_once(
"languages/$LANGUAGE");
 
 
 
    if (
$autoclean)
        
autoclean();
}
 
// Main Cleanup
function autoclean() {
    global 
$site_config;
    require_once(
"cleanup.php");
 
    
$now = gmtime();
 
    
$res = mysql_query("SELECT last_time FROM tasks WHERE task='cleanup'");
    
$row = mysql_fetch_array($res);
    if (!
$row) {
        
mysql_query("INSERT INTO tasks (task, last_time) VALUES ('cleanup',$now)");
        return;
    }
    
$ts = $row[0];
    if (
$ts + $site_config["autoclean_interval"] > $now)
        return;
    
mysql_query("UPDATE tasks SET last_time=$now WHERE task='cleanup' AND last_time = $ts");
    if (!
mysql_affected_rows())
        return;
 
    
do_cleanup();
}
 
// IP Validation
function validip($ip)
{
    if (!empty(
$ip) && $ip == long2ip(ip2long($ip)))
    {
        
$reserved_ips = array (
                array(
'0.0.0.0','2.255.255.255'),
                array(
'10.0.0.0','10.255.255.255'),
                array(
'127.0.0.0','127.255.255.255'),
                array(
'169.254.0.0','169.254.255.255'),
                array(
'172.16.0.0','172.31.255.255'),
                array(
'192.0.2.0','192.0.2.255'),
                array(
'192.168.0.0','192.168.255.255'),
                array(
'255.255.255.0','255.255.255.255')
        );
 
        foreach (
$reserved_ips as $r)
        {
                
$min = ip2long($r[0]);
                
$max = ip2long($r[1]);
                if ((
ip2long($ip) >= $min) && (ip2long($ip) <= $max)) return false;
        }
        return 
true;
    }
    else return 
false;
}
 
function 
getip() {
   if (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 
userlogin() {
    global 
$CURUSER;
    unset(
$GLOBALS["CURUSER"]);
 
    
$ip = getip(); //GET USERS IP
 
    //Check IP bans    
    
$nip = ip2long($ip);
    
$res = mysql_query("SELECT * FROM bans WHERE $nip >= first AND $nip <= last")  or die(mysql_error());
    if (
mysql_num_rows($res) > 0) {
        
$row = mysql_fetch_array($res);
        
header("HTTP/1.0 403 Forbidden");
        echo 
"<html><head><title>Forbidden</title></head><body><h1>Forbidden</h1>Unauthorized IP address.".
        
"Reason for banning: $row[comment]</body></html>";
        die;
    }
 
 
    
//Check The Cookie and get CURUSER details
    
if (empty($_COOKIE["uid"]) || empty($_COOKIE["pass"]))
        return;
 
    
$id = 0 + $_COOKIE["uid"]; //Get User ID from cookie
    
if (!$id)
    return;
 
    
//Get User Details And Permissions
    
$res = mysql_query("SELECT * FROM users INNER JOIN groups ON users.class=groups.group_id WHERE users.id = $id AND users.enabled='yes' AND users.status = 'confirmed'") or die(mysql_error());
    
$row = mysql_fetch_array($res);
 
    if (!
$row)
        return;
 
    
//Check PW in cookie matches DB (after adding secret to the hash)
    
$sec = hash_pad($row["secret"]);
    if (
$_COOKIE["pass"] != md5($sec . $row["password"] . $sec))
        return;
 
    
mysql_query("UPDATE users SET last_access='" . get_date_time() . "', ip=".sqlesc($ip)." WHERE id=" . $row["id"]) or die(mysql_error());
 
    
$GLOBALS["CURUSER"] = $row;
    unset(
$row);
}
 
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 = '".get_date_time()."' WHERE id = $id");
}
 
function 
logoutcookie() {
    
setcookie("uid", "null", time(), "/");
    
setcookie("pass", "null", time(), "/");
}
 
function 
stdhead($title = "") {
    global 
$site_config, $CURUSER, $THEME, $LANGUAGE;  //Define globals
 
    //require_once("cleanup.php");  //temp cleanup linkage :D
    //docleanup();//TEMP CLEANUP CALL
 
    //site online check
    
if (!$site_config["SITE_ONLINE"]){
        if (
$CURUSER["level"]!=="Administrator") {
            echo 
'<BR><BR><BR><CENTER>'. stripslashes($site_config["OFFLINEMSG"]) .'</CENTER><BR><BR>';
            die;
        }else{
            echo 
'<BR><BR><BR><CENTER><B><FONT COLOR=RED>SITE OFFLINE, ADMIN ONLY VIEWING! DO NOT LOGOUT</FONT></B><BR>If you logout please edit backend/config.php and set SITE_ONLINE to true </CENTER><BR><BR>';
        }
    }
    
//end check
 
    
if (!$CURUSER)
        
guestadd();
 
    if (
$title == "")
        
$title = $site_config['SITENAME'];
    else
        
$title = $site_config['SITENAME']. " : ". htmlspecialchars($title);
 
    require_once(
"themes/" . $THEME . "/block.php");
    require_once(
"themes/" . $THEME . "/header.php");
} 
 
function 
stdfoot() {
    global 
$site_config, $CURUSER, $THEME, $LANGUAGE;
    require_once(
"themes/" . $THEME . "/footer.php");
    
mysql_close();
}
 
 
//POLL MULTICOLOR BY HACK346
function get_poolsleft($i)
{
 global 
$site_config, $THEME;
    if (
$i == 0 || $i == 5 || $i == 10 || $i == 15) return "<img src=".$site_config['SITEURL']."/themes/$THEME/images/polls/bar1-l.png border=\"0\">";                                                                            
    if (
$i == 1 || $i == 6 || $i == 11 || $i == 16) return "<img src=".$site_config['SITEURL']."/themes/$THEME/images/polls/bar2-l.png border=\"0\">";                                                                           
    if (
$i == 2 || $i == 7 || $i == 12 || $i == 17) return "<img src=".$site_config['SITEURL']."/themes/$THEME/images/polls/bar3-l.png border=\"0\">"; 
    if (
$i == 3 || $i == 8 || $i == 13 || $i == 18) return "<img src=".$site_config['SITEURL']."/themes/$THEME/images/polls/bar4-l.png border=\"0\">";
    if (
$i == 4 || $i == 9 || $i == 14 || $i == 19) return "<img src=".$site_config['SITEURL']."/themes/$THEME/images/polls/bar5-l.png border=\"0\">";  
  return 
"";
}
 
 
function 
get_poolsmiddle($i)
{
 global 
$site_config, $THEME;
    if (
$i == 0 || $i == 5 || $i == 10 || $i == 15) return "<img src=".$site_config['SITEURL']."/themes/$THEME/images/polls/bar1.png border=\"0\"";                                                                           
    if (
$i == 1 || $i == 6 || $i == 11 || $i == 16) return "<img src=".$site_config['SITEURL']."/themes/$THEME/images/polls/bar2.png border=\"0\"";                                                                             
    if (
$i == 2 || $i == 7 || $i == 12 || $i == 17) return "<img src=".$site_config['SITEURL']."/themes/$THEME/images/polls/bar3.png border=\"0\""; 
    if (
$i == 3 || $i == 8 || $i == 13 || $i == 18) return "<img src=".$site_config['SITEURL']."/themes/$THEME/images/polls/bar4.png border=\"0\"";   
    if (
$i == 4 || $i == 9 || $i == 14 || $i == 19) return "<img src=".$site_config['SITEURL']."/themes/$THEME/images/polls/bar5.png border=\"0\"";   
  return 
"";
}
 
function 
get_poolsright($i)
 {
 global 
$site_config, $THEME; 
    if (
$i == 0 || $i == 5 || $i == 10 || $i == 15) return "<img src=".$site_config['SITEURL']."/themes/$THEME/images/polls/bar1-r.png border=\"0\">";                                                                           
    if (
$i == 1 || $i == 6 || $i == 11 || $i == 16) return "<img src=".$site_config['SITEURL']."/themes/$THEME/images/polls/bar2-r.png border=\"0\">";                                                                            
    if (
$i == 2 || $i == 7 || $i == 12 || $i == 17) return "<img src=".$site_config['SITEURL']."/themes/$THEME/images/polls/bar3-r.png border=\"0\">"; 
    if (
$i == 3 || $i == 8 || $i == 13 || $i == 18) return "<img src=".$site_config['SITEURL']."/themes/$THEME/images/polls/bar4-r.png border=\"0\">"; 
    if (
$i == 4 || $i == 9 || $i == 14 || $i == 19) return "<img src=".$site_config['SITEURL']."/themes/$THEME/images/polls/bar5-r.png border=\"0\">";         
    return 
"";
}     
 
function 
leftblocks() {
    global 
$site_config, $CURUSER, $THEME, $LANGUAGE;  //Define globals
    
$res=mysql_query("SELECT * FROM blocks WHERE position='left' AND enabled=1 ORDER BY sort");
    
$i=0;
    
$blocks=array();
    while(
$result=mysql_fetch_array($res)){
        if(
$result["position"]) { 
            
$block=$result["name"];
            
$blocks[$i++]=$block;
        }
    }
 
    foreach (
$blocks as $blockfilename){
        echo
"<div id=\"ka".$result['id']."\" style=\"display: block;\">\n";                                                                                                         
        include(
"blocks/".$blockfilename."_block.php");
        echo
"</div>";
    }
}
 
function 
rightblocks() {
    global 
$site_config, $CURUSER, $THEME, $LANGUAGE;  //Define globals
    
$res=mysql_query("SELECT * FROM blocks WHERE position='right' AND enabled=1 ORDER BY sort");
    
$i=0;
    
$blocks=array();
    while(
$result=mysql_fetch_array($res)){
        if(
$result["position"]) {
            
$block=$result["name"];
            
$blocks[$i++]=$block;
        }
    }
 
    foreach (
$blocks as $blockfilename){
        include(
"blocks/".$blockfilename."_block.php");
    }
}
 
function 
middleblocks() {
    global 
$site_config, $CURUSER, $THEME, $LANGUAGE;  //Define globals
    
$res=mysql_query("SELECT * FROM blocks WHERE position='middle' AND enabled=1 ORDER BY sort");
    
$i=0;
    
$blocks=array();
    while(
$result=mysql_fetch_array($res)){
        if(
$result["position"]) {
            
$block=$result["name"];
            
$blocks[$i++]=$block;
        }
    }
 
    foreach (
$blocks as $blockfilename){
        include(
"blocks/".$blockfilename."_block.php");
    }
} 
 
function 
show_error_msg($title, $message, $wrapper = "1") {
    if (
$wrapper=="1") {
        
stdhead($title);
        
//echo "<b>DEBUG: stdhead Wrapper ON/Kill php gen further</b>";//remove later
    
}
        
begin_frame("<div class=error>". htmlspecialchars($title) ."</div>");
        print(
"<CENTER><B>" . stripslashes(sqlesc($message)) . "</B></CENTER>\n");
        
end_frame();
 
    if (
$wrapper=="1"){
        
stdfoot();
        die();
    }
}
 
 
function 
show_success_msg($title, $message, $wrapper = "1") {
    if (
$wrapper=="1") {
        
stdhead($title);
        
//echo "<b>DEBUG: stdhead Wrapper ON/Kill php gen further</b>";//remove later
    
}
        
begin_frame("<div class=success>". htmlspecialchars($title) ."</div>");
        print(
"<p><CENTER><B>" . stripslashes(sqlesc($message)) . "</B></CENTER></p>\n");
        
end_frame();
 
    if (
$wrapper=="1"){
        
stdfoot();
        die();
    }
}
 
//calculate health
 
// New (hack346 21/Jan/2009 @ 11:26)
function health($leechers, $seeders) {
    if ((
$leechers == 0 && $seeders == 0) || ($leechers > 0 && $seeders == 0))
        return 
$health0 = "<span><em style=\"left:3%\"></em></span>0%"; 
    elseif (
$seeders > $leechers)
        return 
$health10 = "<span><em style=\"left:100%\"></em></span>100%"; 
 
    
$ratio = $seeders / $leechers * 100;
    if (
$ratio > 0 && $ratio < 15)
        return 
$health1= "<stan><em style=\"left:10%\">10%</em></span>10%";
    elseif (
$ratio >= 15 && $ratio < 25)
        return 
$health2 = "<span><em style=\"left:20%\">20%</em></span>20%"; 
    elseif (
$ratio >= 25 && $ratio < 35)
        return 
$health3 = "<span><em style=\"left:30%\">30%</em></span>30%"; 
    elseif (
$ratio >= 35 && $ratio < 45)
        return 
$health4 = "<span><em style=\"left:40%\">40%</em></span>40%"; 
    elseif (
$ratio >= 45 && $ratio < 55)
        return 
$health5 = "<span><em style=\"left:50%\">50%</em></span>50%"; 
    elseif (
$ratio >= 55 && $ratio < 65)
        return 
$health6 = "<span><em style=\"left:60%\">60%</em></span>60%"; 
    elseif (
$ratio >= 65 && $ratio < 75)
        return 
$health7 = "<span><em style=\"left:70%\">70%</em></span>70%"; 
    elseif (
$ratio >= 75 && $ratio < 85)
        return 
$health8 = "<span><em style=\"left:80%\">80%</em></span>80%"; 
    elseif (
$ratio >= 85 && $ratio < 95)
        return 
$health9 = "<span><em style=\"left:90%\">90%</em></span>90%"; 
    else
        return 
$health10 = "<span><em style=\"left:100%\">100%</em></span>100%"; 
}
 
 
//secure vars
function sqlesc($x) {
   if (
get_magic_quotes_gpc()) {
       
$x = stripslashes($x);
   }
   if (!
is_numeric($x)) {
       
$x = "'".mysql_real_escape_string($x)."'";
   }
   return 
$x;
}
 
 
function 
unesc($x) {
    if (
get_magic_quotes_gpc())
        return 
stripslashes($x);
    return 
$x;
}
 
function 
mkglobal($vars) {
    if (!
is_array($vars))
        
$vars = explode(":", $vars);
    foreach (
$vars as $v) {
        if (isset(
$_GET[$v]))
            
$GLOBALS[$v] = stripslashes($_GET[$v]);
        elseif (isset(
$_POST[$v]))
            
$GLOBALS[$v] = stripslashes($_POST[$v]);
        else
            return 
0;
    }
    return 
1;
}
 
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 
file_ungzip($fromFile){
    
$zp = @gzopen($fromFile, "r");
    while(!@
gzeof($zp)) { $string .= @gzread($zp, 4096); }
    @
gzclose($zp);
    return 
$string;
}
 
function 
mksize($bytes) {
    if (
$bytes < 1000 * 1024)
        return 
number_format($bytes / 1024, 2) . " KB";
    if (
$bytes < 1000 * 1048576)
        return 
number_format($bytes / 1048576, 2) . " MB";
    if (
$bytes < 1000 * 1073741824)
        return 
number_format($bytes / 1073741824, 2) . " GB";
    return 
number_format($bytes / 1099511627776, 2) . " TB";
}
 
function 
escape_url($url) {
    
$ret = '';
    for(
$i = 0; $i < strlen($url); $i+=2)
    
$ret .= '%'.$url[$i].$url[$i + 1];
    return 
$ret;
}
 
function 
torrent_scrape_url($scrape, $hash) {
    
$ch = curl_init();
    
$timeout = 5;
    
curl_setopt ($ch, CURLOPT_URL, $scrape.'?info_hash='.escape_url($hash));
    
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
    
curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
    
$fp = curl_exec($ch);
    
curl_close($ch);
 
    
$ret = array();
    if(!
$fp) {
        
$ret['seeds'] = -1;
        
$ret['peers'] = -1;
    }else{
        
$stats = BDecode($fp);
        
$binhash = addslashes(pack("H*", $hash));
        
$seeds = $stats['files'][$binhash]['complete'];
        
$peers = $stats['files'][$binhash]['incomplete'];
        
$downloaded = $stats['files'][$binhash]['downloaded'];
        
$ret['seeds'] = $seeds;
        
$ret['peers'] = $peers;
        
$ret['downloaded'] = $downloaded;
    }
    return 
$ret;
}
 
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"]);
        return 
sprintf("%d:%02d", $t["min"], $t["sec"]);
}
 
function 
gmtime() {
    return 
strtotime(get_date_time());
}
 
function 
loggedinonly() {
        global 
$CURUSER;
        if (!
$CURUSER) {
            
header("Refresh: 0; url=account-login.php?returnto=" . urlencode($_SERVER["REQUEST_URI"]));
            exit();
        }
        
$wherethisuser = where ($_SERVER["SCRIPT_FILENAME"],$CURUSER["id"]);
}
 
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);
    
return preg_match('/^([a-z0-9._-](\+[a-z0-9])*)+@[a-z0-9.-]+\.[a-z]{2,6}$/i', $email);
}
 
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", $d);
    }
    return 
$d;
}
 
function 
mksecret($len = 20) {
    
$ret = "";
    for (
$i = 0; $i < $len; $i++)
        
$ret .= chr(mt_rand(0, 255));
    return 
$ret;
}
 
function 
deletetorrent($id) {
    global 
$site_config;
 
    
$row = @mysql_fetch_array(@mysql_query("SELECT image1,image2 FROM torrents WHERE id=$id"));
 
    foreach(
explode(".","peers.comments.ratings") as $x)
        
mysql_query("DELETE FROM $x WHERE torrent = $id");
 
    if (
file_exists("".$site_config["torrent_dir"]."/$id.torrent"))
        
unlink("".$site_config["torrent_dir"]."/$id.torrent");
 
    if (
$row["image1"]) {
        
$img1 = "".$site_config["torrent_dir"]."/images/".$row["image1"]."";
        
$del = unlink($img1);
    }
 
    if (
$row["image2"]) {
        
$img2 = "".$site_config["torrent_dir"]."/images/".$row["image2"]."";
        
$del = unlink($img2);
    }
 
    
mysql_query("DELETE FROM torrents WHERE id = $id");
}
 
function 
deleteaccount($userid) {
        
mysql_query("DELETE FROM users WHERE id = $userid");
        
mysql_query("DELETE FROM warnings WHERE userid = $userid");
        
mysql_query("DELETE FROM ratings WHERE user = $userid");
}
 
function 
genrelist() {
    
$ret = array();
    
$res = mysql_query("SELECT id, name, parent_cat FROM categories ORDER BY parent_cat ASC, sort_index ASC");
    while (
$row = mysql_fetch_array($res))
        
$ret[] = $row;
    return 
$ret;
}
 
function 
langlist() {
    
$ret = array();
    
$res = mysql_query("SELECT id, name, image FROM torrentlang ORDER BY sort_index, id");
    while (
$row = mysql_fetch_array($res))
        
$ret[] = $row;
    return 
$ret;
}
 
 
function 
agelist() {
    
$ret = array();
    
$res = mysql_query("SELECT id, name, image FROM torrentage ORDER BY sort_index, id");
    while (
$row = mysql_fetch_array($res))
        
$ret[] = $row;
    return 
$ret;
}
 
function 
is_valid_id($id){
    return 
is_numeric($id) && ($id > 0) && (floor($id) == $id);
}
 
function 
sql_timestamp_to_unix_timestamp($s){
    return 
mktime(substr($s, 11, 2), substr($s, 14, 2), substr($s, 17, 2), substr($s, 5, 2), substr($s, 8, 2), substr($s, 0, 4));
}
 
function 
write_log($text){
    
$text = sqlesc($text);
    
$added = sqlesc(get_date_time());
    
mysql_query("INSERT INTO log (added, txt) VALUES($added, $text)") or sqlerr();
}
 
function 
get_elapsed_time($ts){
  
$mins = floor((gmtime() - $ts) / 60);
  
$hours = floor($mins / 60);
  
$mins -= $hours * 60;
  
$days = floor($hours / 24);
  
$hours -= $days * 24;
  
$weeks = floor($days / 7);
  
$days -= $weeks * 7;
  
$t = "";
  if (
$weeks > 0)
    return 
"$weeks wk" . ($weeks > 1 ? "s" : "");
  if (
$days > 0)
    return 
"$days day" . ($days > 1 ? "s" : "");
  if (
$hours > 0)
    return 
"$hours hr" . ($hours > 1 ? "s" : "");
  if (
$mins > 0)
    return 
"$mins min" . ($mins > 1 ? "s" : "");
  return 
"< 1 min";
}
 
function 
hex2bin($hexdata) {
    
$bindata = "";
    for (
$i=0;$i<strlen($hexdata);$i+=2) {
        
$bindata.=chr(hexdec(substr($hexdata,$i,2)));
    }
    return 
$bindata;
}
 
function 
guestadd() {
    
$ip = $_SERVER["REMOTE_ADDR"];
    
$sql = mysql_query("SELECT time FROM guests WHERE ip='$ip'");
    
$ctime = gmtime();
    if (
mysql_fetch_row($sql))
    {
        @
mysql_query("UPDATE guests SET ip='$ip', time='$ctime' WHERE ip='$ip'");
    } else {
        @
mysql_query("INSERT INTO guests (ip, time) VALUES ('$ip', '$ctime')");
    }
}
 
function 
getguests() {
    
$ip = $_SERVER["REMOTE_ADDR"];
    
$past = gmtime()-2400;
    @
mysql_query("DELETE FROM guests WHERE time < $past");
    
$guests = number_format(get_row_count("guests"));
    return 
$guests;
}
 
function 
time_ago($addtime) {
   
$addtime = get_elapsed_time(sql_timestamp_to_unix_timestamp($addtime));
   return 
$addtime;
}
 
function 
CutName ($vTxt, $Car) {
    while(
strlen($vTxt) > $Car) {
        return 
substr($vTxt, 0, $Car) . "...";
    } return 
$vTxt;
}
 
function 
searchfield($s) {
    return 
preg_replace(array('/[^a-z0-9]/si', '/^\s*/s', '/\s*$/s', '/\s+/s'), array(" ", "", "", " "), $s);
}
 
function 
get_row_count($table, $suffix = "") {
  if (
$suffix)
    
$suffix = " $suffix";
  (
$r = mysql_query("SELECT COUNT(*) FROM $table$suffix")) or die(mysql_error());
  (
$a = mysql_fetch_row($r)) or die(mysql_error());
  return 
$a[0];
}
 
function 
sqlerr($query = "") {
    
stdhead();
    
begin_frame("MYSQL Error");
    print(
"<BR><b>MySQL error occured</b>.\nQuery: " . $query . "\nError: (" . mysql_errno() . ") " . mysql_error());
    
end_frame();
    
stdfoot();
    die;
}
 
function 
get_dt_num(){
    return 
gmdate("YmdHis");
}
 
 
function 
get_date_time($timestamp = 0){
    if (
$timestamp)
    return 
date("Y-m-d H:i:s", $timestamp);
    else
      return 
gmdate("Y-m-d H:i:s");
}
 
// Convert UTC to user's timezone
function utc_to_tz ($timestamp=0) {
    GLOBAL 
$CURUSER;
    if (!
is_numeric($timestamp))
        
$timestamp = sql_timestamp_to_unix_timestamp($timestamp);
    if (
$timestamp == 0)
        
$timestamp = gmtime();
 
    
$timestamp = $timestamp + ($CURUSER['tzoffset']*60);
    return 
date("Y-m-d H:i:s", $timestamp);
}
 
function 
utc_to_tz_time ($timestamp=0) {
    GLOBAL 
$CURUSER;
 
    if (!
is_numeric($timestamp))
        
$timestamp = sql_timestamp_to_unix_timestamp($timestamp);
    if (
$timestamp == 0)
        
$timestamp = gmtime();
 
    
$timestamp = $timestamp + ($CURUSER['tzoffset']*60);
    return 
$timestamp;
}
 
function 
encodehtml($s, $linebreaks = true) {
      
$s = str_replace("<", "<", str_replace("&", "&", $s));
      if (
$linebreaks)
        
$s = nl2br($s);
      return 
$s;
}
 
 
function 
format_urls($s){
    return 
preg_replace(
    
"/(\A|[^=\]'\"a-zA-Z0-9])((http|ftp|https|ftps|irc):\/\/[^<>\s]+)/i",
    
"\\1<a href=http://anonym.to/?\\2 target=_blank>\\2</a>", $s);
}
 
function 
format_comment($text)
{
    global 
$site_config, $smilies, $privatesmilies;
 
    
$s = $text;
 
    
$s = htmlspecialchars($s);
    
$s = stripslashes($s);
    
$s = format_urls($s);
 
    
// [*]
    
$s = preg_replace("/\[\*\]/", "<li>", $s);
 
    
// [b]Bold[/b]
    
$s = preg_replace("/\[b\]((\s|.)+?)\[\/b\]/", "<b>\\1</b>", $s);
 
    
// [i]Italic[/i]
    
$s = preg_replace("/\[i\]((\s|.)+?)\[\/i\]/", "<i>\\1</i>", $s);
 
    
// [u]Underline[/u]
    
$s = preg_replace("/\[u\]((\s|.)+?)\[\/u\]/", "<u>\\1</u>", $s);
 
    
// [u]Underline[/u]
    
$s = preg_replace("/\[u\]((\s|.)+?)\[\/u\]/i", "<u>\\1</u>", $s);
 
    
// [img]http://www/image.gif[/img]
    
$s = preg_replace("/\[img\](http:\/\/[^\s'\"<>]+(\.gif|\.jpg|\.png|\.bmp|\.jpeg))\[\/img\]/i", "<a href=\"\\1\" rel=\"ibox\"><IMG border=\"0\" src=\"\\1\" width=120 title=\"Click to enlarge\"></a>", $s); 
 
    
// [img=http://www/image.gif]
    
$s = preg_replace("/\[img=(http:\/\/[^\s'\"<>]+(\.gif|\.jpg|\.png|\.bmp|\.jpeg))\]/i", "<a href=\"\\1\" rel=\"ibox\"><IMG border=\"0\" src=\"\\1\" width=120 title=\"Click to enlarge\"></a>", $s); 
 
    
// [color=blue]Text[/color]
    
$s = preg_replace(
        
"/\[color=([a-zA-Z]+)\]((\s|.)+?)\[\/color\]/i",[/color]
[
color=([a-zA-Z]        "<font color=\\1>\\2</font>", $s);[/color]
[
color=([a-zA-Z][/color]
[
color=([a-zA-Z]    // [color=#ffcc99]Text[/color]
    
$s = preg_replace(
        
"/\[color=(#[a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9])\]((\s|.)+?)\[\/color\]/i",
        
"<font color=\\1>\\2</font>", $s);
 
    
// [url=http://www.example.com]Text[/url]
    
$s = preg_replace(
        
"/\[url=((http|ftp|https|ftps|irc):\/\/[^<>\s]+?)\]((\s|.)+?)\[\/url\]/i",
        
"<a href=http://anonym.to/?\\1 target=_blank>\\3</a>", $s);
 
    
// [url]http://www.example.com[/url]
    
$s = preg_replace(
        
"/\[url\]((http|ftp|https|ftps|irc):\/\/[^<>\s]+?)\[\/url\]/i",
        
"<a href=http://anonym.to/?\\1 target=_blank>\\1</a>", $s);
 
    
// [size=4]Text[/size]
    
$s = preg_replace(
        
"/\[size=([1-7])\]((\s|.)+?)\[\/size\]/i",
        
"<font size=\\1>\\2</font>", $s);
 
    
// [font=Arial]Text[/font]
    
$s = preg_replace(
        
"/\[font=([a-zA-Z ,]+)\]((\s|.)+?)\[\/font\]/i",
        
"<font face=\"\\1\">\\2</font>", $s);
 
    
//<<<@!2!@>>>
    
$s = preg_replace(
        
"/\<<<@!3!@>>>
    
$s = preg_replace(
        "
/\<<<@!2!@>>>

The code is not working !
Please paste here the functions.php if you know to resolve it:drink:

daffy 4th March 2010 01:41

there are 2 parts in functions to remove a comlumn in table. you will also need to add code to functions and theme header to resize images weather its direct link image or not. as aboec post says. get original functions workin back on your site and post your functions.php

softgame 17th March 2010 20:39

problem with captcha , i don`t se the image from captcha:sleep:

Fernandolazarone 14th April 2010 18:07

I have a problem in the captcha image does not appear it's time that will make my account

raefor 14th April 2010 20:39

Quote:

Originally Posted by Fernandolazarone (Post 22400)
I have a problem in the captcha image does not appear it's time that will make my account

try setting captcha folder to 777

Quote:

Originally Posted by melcu66 (Post 21522)
The code is not working !
Please paste here the functions.php if you know to resolve it:drink:


use this

comments.php


PHP Code:

<?
//
//  TorrentTrader v2.x
//    This file was last updated: 05/December/2007
//    
//    http://www.torrenttrader.org
//
//
require_once("backend/functions.php");
require_once(
"backend/BDecode.php") ;
require_once(
"backend/bbcode.php");
dbconn();


$id = (int)$_GET["id"];
$type = $_GET["type"];
$edit = (int)$_GET["edit"];
$delete = (int)$_GET["delete"];

if (
$edit == 1 || $delete == 1 || $_GET["takecomment"] == 'yes') loggedinonly();


if (!isset(
$id) || !$id || ($type != "torrent" && $type != "news"))
    
show_error_msg("ERROR","Error",1);

if (
$edit=='1'){
    
$row = mysql_fetch_assoc(mysql_query("SELECT user FROM comments WHERE id=$id"));

    if((
$CURUSER["edit_torrents"]=="no" || $CURUSER["edit_forum"]=="no") && $CURUSER['id'] != $row['user'])
        
show_error_msg("ERROR","You cant do this!",1);

        
$save = (int)$_GET["save"];

        if(
$save){
            
$text = sqlesc($_POST['text']);

            
$query="UPDATE comments SET text=$text WHERE id=$id";
            
$result=mysql_query($query);
            
write_log($CURUSER['username']." has edited comment: ID:$id");
            
show_error_msg("Complete","Comment Edited OK",1);
        }

        
stdhead("Edit Comment");

        
$res = mysql_query("SELECT * FROM comments WHERE id=$id");
        
$arr = mysql_fetch_array($res);

        
begin_frame("Edit Comment");
        print(
"<center><b>Edit comment </b><p>\n");
        print(
"<form method=\"post\" name=\"comment\" action=\"comments.php?type=torrent&edit=1&save=1&id=$id\">\n");
        print (
"".textbbcode("comment","text","" . htmlspecialchars($arr["text"]) . "")."");
        print(
"<p><input type=\"submit\" class=btn value=\"Submit Changes\" /></p></form></center>\n");
        
end_frame();
        
stdfoot();
        die();
}

if (
$delete=='1'){
    if(
$CURUSER["delete_torrents"]=="no" || $CURUSER["delete_forum"]=="no")
        
show_error_msg("ERROR","You cant do this!",1);

    if (
$type == "torrent") {
        
$res = mysql_query("SELECT torrent FROM comments WHERE id=$id");
        
$row = mysql_fetch_assoc($res);
        if (
$row["torrent"] > 0) {
            
mysql_query("UPDATE torrents SET comments = comments - 1 WHERE id = $row[torrent]") or die(mysql_error());
        }
    }

    
mysql_query("DELETE FROM comments WHERE id = $id");
    
write_log($CURUSER['username']." has deleted comment: ID: $id");
    
show_error_msg("Complete","Comment deleted OK",1);
}


stdhead("" . COMMENTS . "");


//take comment add
if ($_GET["takecomment"] == 'yes'){
    
$commentbody = $_POST['body'];
    
    if (!
$commentbody)
        
show_error_msg("Error","You did not enter anything!",1);

    if (
$type =="torrent"){
        
mysql_query("UPDATE torrents SET comments = comments + 1 WHERE id = $id") or die(mysql_error());
    }

    
mysql_query("INSERT INTO comments (user, ".$type.", added, text) VALUES (".$CURUSER["id"].", ".$id.", '" .get_date_time(). "', " . sqlesc($body).")") or die(mysql_error());

    if (
mysql_affected_rows() == 1)
            
show_error_msg("Completed","Your Comment was added successfully.",0);
        else
            
show_error_msg("Error","Unable to add comment",0);
}
//end insert comment

//NEWS
if ($type =="news"){
    
$res = mysql_query("SELECT * FROM news WHERE id = $id");
    
$row = mysql_fetch_array($res);

    if (!
$row){
        
show_error_msg("Error","News id invalid",0);
        
stdfoot();
    }

    
begin_frame("News");
    echo 
"".$row['title']."<BR><BR>".format_comment($row['body'])."<BR>";
    
end_frame();
    
}

//TORRENT
if ($type =="torrent"){
    
$res = mysql_query("SELECT id, name FROM torrents WHERE id = $id");
    
$row = mysql_fetch_array($res);

    if (!
$row){
        
show_error_msg("Error","News id invalid",0);
        
stdfoot();
    }

    echo 
"<CENTER><b>Comments for:</b> <a href=torrents-details.php?id=".$row['id'].">".htmlspecialchars($row['name'])."</a></CENTER><BR>";
    
}

begin_frame("" . COMMENTS . "");
    
    
$subres = mysql_query("SELECT COUNT(*) FROM comments WHERE $type = $id") or die(mysql_error());
    
$subrow = mysql_fetch_array($subres);
    
$commcount = $subrow[0];

    if (
$commcount) {
        list(
$pagertop, $pagerbottom, $limit) = pager(10, $commcount, "comments.php?id=$id&type=$type&");
        
$commquery = "SELECT comments.id, text, user, comments.added, avatar, signature, username, title, class, uploaded, downloaded, privacy, donated FROM comments LEFT JOIN users ON comments.user = users.id WHERE $type = $id ORDER BY comments.id $limit";
        
$commres = mysql_query($commquery) or die(mysql_error());
    }else{
        unset(
$commres);
    }

    if (
$commcount) {
        print(
$pagertop);
        
commenttable($commres);
        print(
$pagerbottom);
    }else {
        print(
"<BR><b><CENTER>" . NOCOMMENTS . "</CENTER></b><BR>\n");
    }

    echo 
"<CENTER>";
    echo 
"<form name=\"comment\" method=\"post\" action=\"comments.php?type=$type&id=$id&takecomment=yes\">";
    echo 
"".textbbcode("comment","body")."";
    echo 
"<input type=\"submit\" class=btn value=\"Add Comment\" />";
    echo 
"</form></CENTER>";

    
end_frame();

stdfoot();
?>


oopss 1st May 2010 21:51

Medal system
 
Hi, how integrate Medal system or Mod in H-Tracker?
Members nickname + Medal?

yoppy http://img690.imageshack.us/img690/9392/silver.gif
diiger http://img62.imageshack.us/img62/720/adminbh.png

danscarlat 2nd May 2010 00:38

I do not know why I can not upload
pray that the best experts to help me

http://img202.imageshack.us/img202/6730/problemwg.jpg

pedro444 28th May 2010 11:27

please help me
 
Hello I installed the H-Tracker only for members who do they have to wait for Donald 24.horas poso to take this option thanks.. :unknown:


All times are GMT +2. The time now is 23:18.

Powered by vBulletin® Version 3.8.11 Beta 3
Copyright ©2000 - 2026, vBulletin Solutions Inc.