Thread: Help fast!
View Single Post
  #1  
Old 15th September 2009, 17:02
tomys tomys is offline
Senior Member
 
Join Date: Apr 2009
Germany
Posts: 20
Question Help fast!
Hi! I have a problem i can`t upload the torrent i use TBDEV 2010

Click the image to open in full size.

Click the image to open in full size.

Click the image to open in full size.

1. I find torrent!
2.I click download
3.Give me a blank page, pleas help me!

My download.php
PHP Code:
<?php
/*
+------------------------------------------------
|   TBDev.net BitTorrent Tracker PHP
|   =============================================
|   by CoLdFuSiOn
|   (c) 2003 - 2009 TBDev.Net
|   TBDEV.NET - Community forum
|   =============================================
|   svn: TBDEV.net | Get TBDEV.net at SourceForge.net
|   Licence Info: GPL
+------------------------------------------------
|   $Date: 2009-09-05 20:48:06 +0300 (Sat, 05 Sep 2009) $
|   $Revision: 199 $
|   $Author: tbdevnet $
|   $URL: https://tbdevnet.svn.sourceforge.net/svnroot/tbdevnet/trunk/TB/download.php $
+------------------------------------------------
*/
require_once "include/bittorrent.php";
require_once 
"include/user_functions.php";

dbconn();

loggedinorreturn();


  
$id = isset($_GET['torrent']) ? intval($_GET['torrent']) : 0;

  if ( !
is_valid_id($id) )
    
stderr('USER ERROR''No torrent with that ID exists');


  
$res mysql_query("SELECT name, filename FROM torrents WHERE id = $id") or sqlerr(__FILE____LINE__);
  
$row mysql_fetch_assoc($res);

  
$fn "{$TBDEV['torrent_dir']}/$id.torrent";

  if (!
$row || !is_file($fn) || !is_readable($fn))
    
httperr();


  @
mysql_query("UPDATE torrents SET hits = hits + 1 WHERE id = $id");

  require_once 
"include/benc.php";



  if (!isset(
$CURUSER['passkey']) || strlen($CURUSER['passkey']) != 32
  {

    
$CURUSER['passkey'] = md5($CURUSER['username'].time().$CURUSER['passhash']);

    @
mysql_query("UPDATE users SET passkey='{$CURUSER['passkey']}' WHERE id={$CURUSER['id']}");

  }



  
$dict bdec_file($fnfilesize($fn));

  
$dict['value']['announce']['value'] = "{$TBDEV['announce_urls'][0]}?passkey={$CURUSER['passkey']}";

  
$dict['value']['announce']['string'] = strlen($dict['value']['announce']['value']).":".$dict['value']['announce']['value'];

  
$dict['value']['announce']['strlen'] = strlen($dict['value']['announce']['string']);



  
header('Content-Disposition: attachment; filename="[TBDev]'.$row['filename'].'"');

  
header("Content-Type: application/x-bittorrent");



  print(
benc($dict));



?>
takeupload.php
PHP Code:
<?php
/*
+------------------------------------------------
|   TBDev.net BitTorrent Tracker PHP
|   =============================================
|   by CoLdFuSiOn
|   (c) 2003 - 2009 TBDev.Net
|   TBDEV.NET - Community forum
|   =============================================
|   svn: TBDEV.net | Get TBDEV.net at SourceForge.net
|   Licence Info: GPL
+------------------------------------------------
|   $Date: 2009-09-05 20:48:06 +0300 (Sat, 05 Sep 2009) $
|   $Revision: 199 $
|   $Author: tbdevnet $
|   $URL: https://tbdevnet.svn.sourceforge.net/svnroot/tbdevnet/trunk/TB/takeupload.php $
+------------------------------------------------
*/
require_once("include/benc.php");
require_once(
"include/bittorrent.php");
require_once 
"include/user_functions.php";

ini_set("upload_max_filesize",$TBDEV['max_torrent_size']);

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

dbconn(); 

loggedinorreturn();

if (
$CURUSER['class'] < UC_UPLOADER)
  die;

foreach(
explode(":","descr:type:name") as $v) {
    if (!isset(
$_POST[$v]))
        
bark("missing form data");
}

if (!isset(
$_FILES["file"]))
    
bark("missing form data");

$f $_FILES["file"];
$fname unesc($f["name"]);
if (empty(
$fname))
    
bark("Empty filename!");
    
$nfo sqlesc('');
/////////////////////// NFO FILE ////////////////////////    
if(isset($_FILES['nfo']) && !empty($_FILES['nfo']['name'])) {
$nfofile $_FILES['nfo'];
if (
$nfofile['name'] == '')
  
bark("No NFO!");

if (
$nfofile['size'] == 0)
  
bark("0-byte NFO");

if (
$nfofile['size'] > 65535)
  
bark("NFO is too big! Max 65,535 bytes.");

$nfofilename $nfofile['tmp_name'];

if (@!
is_uploaded_file($nfofilename))
  
bark("NFO upload failed");

$nfo sqlesc(str_replace("\x0d\x0d\x0a""\x0d\x0a", @file_get_contents($nfofilename)));
}
/////////////////////// NFO FILE END /////////////////////

$descr unesc($_POST["descr"]);
if (!
$descr)
  
bark("You must enter a description!");

$catid = ($_POST["type"]);
if (!
is_valid_id($catid))
    
bark("You must select a category to put the torrent in!");
    
if (!
validfilename($fname))
    
bark("Invalid filename!");
if (!
preg_match('/^(.+)\.torrent$/si'$fname$matches))
    
bark("Invalid filename (not a .torrent).");
$shortfname $torrent $matches[1];
if (!empty(
$_POST["name"]))
    
$torrent unesc($_POST["name"]);

$tmpname $f["tmp_name"];
if (!
is_uploaded_file($tmpname))
    
bark("eek");
if (!
filesize($tmpname))
    
bark("Empty file!");

$dict bdec_file($tmpname$TBDEV['max_torrent_size']);
if (!isset(
$dict))
    
bark("What the hell did you upload? This is not a bencoded file!");


function 
dict_check($d$s) {
    if (
$d["type"] != "dictionary")
        
bark("not a dictionary");
    
$a explode(":"$s);
    
$dd $d["value"];
    
$ret = array();
    
$t='';
    foreach (
$a as $k) {
        unset(
$t);
        if (
preg_match('/^(.*)\((.*)\)$/'$k$m)) {
            
$k $m[1];
            
$t $m[2];
        }
        if (!isset(
$dd[$k]))
            
bark("dictionary is missing key(s)");
        if (isset(
$t)) {
            if (
$dd[$k]["type"] != $t)
                
bark("invalid entry in dictionary");
            
$ret[] = $dd[$k]["value"];
        }
        else
            
$ret[] = $dd[$k];
    }
    return 
$ret;
}

function 
dict_get($d$k$t) {
    if (
$d["type"] != "dictionary")
        
bark("not a dictionary");
    
$dd $d["value"];
    if (!isset(
$dd[$k]))
        return;
    
$v $dd[$k];
    if (
$v["type"] != $t)
        
bark("invalid dictionary entry type");
    return 
$v["value"];
}

list(
$ann$info) = dict_check($dict"announce(string):info");

$tmaker = (isset($dict['value']['created by']) && !empty($dict['value']['created by']['value'])) ? sqlesc($dict['value']['created by']['value']) : sqlesc('Unknown');

unset(
$dict);

list(
$dname$plen$pieces) = dict_check($info"name(string):piece length(integer):pieces(string)");

if (!
in_array($ann$TBDEV['announce_urls'], 1))
    
bark("invalid announce url! must be <b>" $TBDEV['announce_urls'][0] . "</b>");

if (
strlen($pieces) % 20 != 0)
    
bark("invalid pieces");

$filelist = array();
$totallen dict_get($info"length""integer");
if (isset(
$totallen)) {
    
$filelist[] = array($dname$totallen);
    
$type "single";
}
else {
    
$flist dict_get($info"files""list");
    if (!isset(
$flist))
        
bark("missing both length and files");
    if (!
count($flist))
        
bark("no files");
    
$totallen 0;
    foreach (
$flist as $fn) {
        list(
$ll$ff) = dict_check($fn"length(integer):path(list)");
        
$totallen += $ll;
        
$ffa = array();
        foreach (
$ff as $ffe) {
            if (
$ffe["type"] != "string")
                
bark("filename error");
            
$ffa[] = $ffe["value"];
        }
        if (!
count($ffa))
            
bark("filename error");
        
$ffe implode("/"$ffa);
        
$filelist[] = array($ffe$ll);
    }
    
$type "multi";
}


$infohash pack("H*"sha1($info["string"]));

unset(
$info);
// Replace punctuation characters with spaces

$torrent str_replace("_"" "$torrent);


$ret mysql_query("INSERT INTO torrents (search_text, filename, owner, visible, info_hash, name, size, numfiles, type, descr, ori_descr, category, save_as, added, last_action, nfo, client_created_by) VALUES (" .
        
implode(","array_map("sqlesc", array(searchfield("$shortfname $dname $torrent"), $fname$CURUSER["id"], "no"$infohash$torrent$totallencount($filelist), $type$descr$descr$_POST["type"], $dname))) .
        
", " time() . ", " time() . ", $nfo$tmaker)");
if (!
$ret) {
    if (
mysql_errno() == 1062)
        
bark("torrent already uploaded!");
    
bark("mysql puked: ".mysql_error());
}
$id mysql_insert_id();

@
mysql_query("DELETE FROM files WHERE torrent = $id");

function 
file_list($arr,$id)
{
    foreach(
$arr as $v)
        
$new[] = "($id,".sqlesc($v[0]).",".$v[1].")";
    return 
join(",",$new);
}

mysql_query("INSERT INTO files (torrent, filename, size) VALUES ".file_list($filelist,$id));

move_uploaded_file($tmpname"{$TBDEV['torrent_dir']}/$id.torrent");

write_log("Torrent $id ($torrent) was uploaded by " $CURUSER["username"]);



/* RSS feeds */

if (($fd1 = @fopen("rss.xml""w")) && ($fd2 fopen("rssdd.xml""w")))
{
    
$cats "";
    
$res mysql_query("SELECT id, name FROM categories");
    while (
$arr mysql_fetch_assoc($res))
        
$cats[$arr["id"]] = $arr["name"];
    
$s "<?xml version=\"1.0\" encoding=\"iso-8859-1\" ?>\n<rss version=\"0.91\">\n<channel>\n" .
        
"<title>$SITENAME</title>\n<description>TBDev is the best!</description>\n<link>{$TBDEV['baseurl']}/</link>\n";
    @
fwrite($fd1$s);
    @
fwrite($fd2$s);
    
$r mysql_query("SELECT id,name,descr,filename,category FROM torrents ORDER BY added DESC LIMIT 15") or sqlerr(__FILE____LINE__);
    while (
$a mysql_fetch_assoc($r))
    {
        
$cat $cats[$a["category"]];
        
$s "<item>\n<title>" htmlspecialchars($a["name"] . " ($cat)") . "</title>\n" .
            
"<description>" htmlspecialchars($a["descr"]) . "</description>\n";
        @
fwrite($fd1$s);
        @
fwrite($fd2$s);
        @
fwrite($fd1"<link>{$TBDEV['baseurl']}/details.php?id=$a[id]&amp;hit=1</link>\n</item>\n");
        
$filename htmlspecialchars($a["filename"]);
        @
fwrite($fd2"<link>{$TBDEV['baseurl']}/download.php/$a[id]/$filename</link>\n</item>\n");
    }
    
$s "</channel>\n</rss>\n";
    @
fwrite($fd1$s);
    @
fwrite($fd2$s);
    @
fclose($fd1);
    @
fclose($fd2);
}

/* Email notifs */
/*******************

$res = mysql_query("SELECT name FROM categories WHERE id=$catid") or sqlerr();
$arr = mysql_fetch_assoc($res);
$cat = $arr["name"];
$res = mysql_query("SELECT email FROM users WHERE enabled='yes' AND notifs LIKE '%[cat$catid]%'") or sqlerr();
$uploader = $CURUSER['username'];

$size = mksize($totallen);
$description = ($html ? strip_tags($descr) : $descr);

$body = <<<EOD
A new torrent has been uploaded.

Name: $torrent
Size: $size
Category: $cat
Uploaded by: $uploader

Description
-------------------------------------------------------------------------------
$description
-------------------------------------------------------------------------------

You can use the URL below to download the torrent (you may have to login).

{$TBDEV['baseurl']}/details.php?id=$id&hit=1

-- 
$SITENAME
EOD;
$to = "";
$nmax = 100; // Max recipients per message
$nthis = 0;
$ntotal = 0;
$total = mysql_num_rows($res);
while ($arr = mysql_fetch_row($res))
{
  if ($nthis == 0)
    $to = $arr[0];
  else
    $to .= "," . $arr[0];
  ++$nthis;
  ++$ntotal;
  if ($nthis == $nmax || $ntotal == $total)
  {
    if (!mail("Multiple recipients <{$TBDEV['site_email']}>", "New torrent - $torrent", $body,
    "From: {$TBDEV['site_email']}\r\nBcc: $to"))
      stderr("Error", "Your torrent has been been uploaded. DO NOT RELOAD THE PAGE!\n" .
        "There was however a problem delivering the e-mail notifcations.\n" .
        "Please let an administrator know about this error!\n");
    $nthis = 0;
  }
}
*******************/

header("Location: {$TBDEV['baseurl']}/details.php?id=$id&uploaded=1");

?>
PHP Code:
<?php
/*
+------------------------------------------------
|   TBDev.net BitTorrent Tracker PHP
|   =============================================
|   by CoLdFuSiOn
|   (c) 2003 - 2009 TBDev.Net
|   TBDEV.NET - Community forum
|   =============================================
|   svn: TBDEV.net | Get TBDEV.net at SourceForge.net
|   Licence Info: GPL
+------------------------------------------------
|   $Date: 2009-09-05 20:48:06 +0300 (Sat, 05 Sep 2009) $
|   $Revision: 199 $
|   $Author: tbdevnet $
|   $URL: https://tbdevnet.svn.sourceforge.net/svnroot/tbdevnet/trunk/TB/announce.php $
+------------------------------------------------
*/
////////////////// GLOBAL VARIABLES ////////////////////////////    
$TBDEV['baseurl'] = 'http://localhost/TB/';
$TBDEV['announce_interval'] = 60 30;
define ('UC_VIP'2);
// DB setup
$TBDEV['mysql_host'] = "localhost";
$TBDEV['mysql_user'] = "root";
$TBDEV['mysql_pass'] = "blank";
$TBDEV['mysql_db']   = "mytbdev";
////////////////// GLOBAL VARIABLES ////////////////////////////

// DO NOT EDIT BELOW UNLESS YOU KNOW WHAT YOU'RE DOING!!

$agent $_SERVER["HTTP_USER_AGENT"];

// Deny access made with a browser...
if (
    
ereg("^Mozilla\\/"$agent) || 
    
ereg("^Opera\\/"$agent) || 
    
ereg("^Links "$agent) || 
    
ereg("^Lynx\\/"$agent) || 
    isset(
$_SERVER['HTTP_COOKIE']) || 
    isset(
$_SERVER['HTTP_ACCEPT_LANGUAGE']) || 
    isset(
$_SERVER['HTTP_ACCEPT_CHARSET'])
    )
    
err("torrent not registered with this tracker CODE 1");

/////////////////////// FUNCTION DEFS ///////////////////////////////////
function dbconn()
{
    global 
$TBDEV;

    if (!@
mysql_connect($TBDEV['mysql_host'], $TBDEV['mysql_user'], $TBDEV['mysql_pass']))
    {
      
err('Please call back later');
    }
    
mysql_select_db($TBDEV['mysql_db']) or err('Please call back later');
}

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

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$x9FORCE_GZIP );
    }
    else
        echo 
$x ;
}

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 
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 
portblacklisted($port)
{
    
// direct connect
    
if ($port >= 411 && $port <= 413) return true;

    
// bittorrent
    
if ($port >= 6881 && $port <= 6889) 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;
}
/////////////////////// FUNCTION DEFS END ///////////////////////////////

$parts = array();
$pattern '[0-9a-fA-F]{32}';
if( !isset(
$_GET['passkey']) OR !ereg($pattern$_GET['passkey'], $parts) ) 
        
err("Invalid Passkey");
    else
        
$GLOBALS['passkey'] = $parts[0];
        
foreach (array(
"info_hash","peer_id","event","ip","localip") as $x
{
if(isset(
$_GET["$x"]))
$GLOBALS[$x] = "" $_GET[$x];
}

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


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

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



foreach (array(
"info_hash","peer_id") as $x)

if (
strlen($GLOBALS[$x]) != 20err("Invalid $x (" strlen($GLOBALS[$x]) . " - " urlencode($GLOBALS[$x]) . ")");

unset(
$x);



$ip $_SERVER['REMOTE_ADDR'];

$port $port;
$downloaded $downloaded;
$uploaded $uploaded;
$left $left;

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


if (!
$port || $port 0xffff)
    
err("invalid port");

if (!isset(
$event))
    
$event "";

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

dbconn();


$user_query mysql_query("SELECT id, uploaded, downloaded, class, enabled FROM users WHERE passkey=".sqlesc($passkey)) or err("Tracker error 2");

if ( 
mysql_num_rows($user_query) != )

 
err("Unknown passkey. Please redownload the torrent from {$TBDEV['baseurl']}.");
 
    
$user mysql_fetch_assoc($user_query);
    if( 
$user['enabled'] == 'no' err('Permission denied, you\'re not enabled');
    
    
$res mysql_query("SELECT id, banned, seeders + leechers AS numpeers, added AS ts FROM torrents WHERE info_hash = " .sqlesc($info_hash));//" . hash_where("info_hash", $info_hash));

$torrent mysql_fetch_assoc($res);
if (!
$torrent)
    
err("torrent not registered with this tracker CODE 2");

$torrentid $torrent["id"];

$fields "seeder, peer_id, ip, port, uploaded, downloaded, userid";

$numpeers $torrent["numpeers"];
$limit "";
if (
$numpeers $rsize)
    
$limit "ORDER BY RAND() LIMIT $rsize";
$res mysql_query("SELECT $fields FROM peers WHERE torrent = $torrentid AND connectable = 'yes' $limit");

//////////////////// START NEW COMPACT MODE/////////////////////////////

if($_GET['compact'] != 1)

{

$resp "d" benc_str("interval") . "i" $TBDEV['announce_interval'] . "e" benc_str("peers") . "l";

}

else

{

$resp "d" benc_str("interval") . "i" $TBDEV['announce_interval'] ."e" benc_str("min interval") . "i" 300 ."e5:"."peers" ;

}

$peer = array();

$peer_num 0;
while (
$row mysql_fetch_assoc($res))

{

    if(
$_GET['compact'] != 1)

{



$row["peer_id"] = str_pad($row["peer_id"], 20);



if (
$row["peer_id"] === $peer_id)

{

 
$self $row;

 continue;

}



$resp .= "d" .

 
benc_str("ip") . benc_str($row["ip"]);

       if (!
$_GET['no_peer_id']) {

  
$resp .= benc_str("peer id") . benc_str($row["peer_id"]);

 }

 
$resp .= benc_str("port") . "i" $row["port"] . "e" .

 
"e";

      }

      else

      {

         
$peer_ip explode('.'$row["ip"]);

$peer_ip pack("C*"$peer_ip[0], $peer_ip[1], $peer_ip[2], $peer_ip[3]);

$peer_port pack("n*", (int)$row["port"]);

$time intval((time() % 7680) / 60);

if(
$_GET['left'] == 0)

{

$time += 128;

}

$time pack("C"$time);



   
$peer[] = $time $peer_ip $peer_port;

$peer_num++;


      }

}



if (
$_GET['compact']!=1)

$resp .= "ee";

else

{
$o "";
for(
$i=0;$i<$peer_num;$i++)

 {

  
$o .= substr($peer[$i], 16);

 }

$resp .= strlen($o) . ':' $o 'e';

}

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

///////////////////////////// END NEW COMPACT MODE////////////////////////////////



if (!isset($self))
{
    
$res mysql_query("SELECT $fields FROM peers WHERE $selfwhere");
    
$row mysql_fetch_assoc($res);
    if (
$row)
    {
        
$userid $row["userid"];
        
$self $row;
    }
}

//// Up/down stats ////////////////////////////////////////////////////////////



if (!isset($self))

{

$valid = @mysql_fetch_row(@mysql_query("SELECT COUNT(*) FROM peers WHERE torrent=$torrentid AND passkey=" sqlesc($passkey)));

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

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


    
//$user['id'] = $az["id"];

    
if ($left && $user['class'] < UC_VIP)
//    if ($az["class"] < UC_VIP)
    
{
        
$gigs $user["uploaded"] / (1024*1024*1024);
        
$elapsed floor((time() - $torrent["ts"]) / 3600);
        
$ratio = (($user["downloaded"] > 0) ? ($user["uploaded"] / $user["downloaded"]) : 1);
        if (
$ratio 0.5 || $gigs 5$wait 48;
        elseif (
$ratio 0.65 || $gigs 6.5$wait 24;
        elseif (
$ratio 0.8 || $gigs 8$wait 12;
        elseif (
$ratio 0.95 || $gigs 9.5$wait 6;
        else 
$wait 0;
        if (
$elapsed $wait)
                
err("Not authorized (" . ($wait $elapsed) . "h) - READ THE FAQ!");
    }
}
else
{
    
$upthis max(0$uploaded $self["uploaded"]);
    
$downthis max(0$downloaded $self["downloaded"]);

    if (
$upthis || $downthis 0)
        
mysql_query("UPDATE users SET uploaded = uploaded + $upthis, downloaded = downloaded + $downthis WHERE id=".$user['id']) or err("Tracker error 3");
}

///////////////////////////////////////////////////////////////////////////////


$updateset = array();

if (
$event == "stopped")
{
    if (isset(
$self))
    {
        
mysql_query("DELETE FROM peers WHERE $selfwhere");
        if (
mysql_affected_rows())
        {
            if (
$self["seeder"] == "yes")
                
$updateset[] = "seeders = seeders - 1";
            else
                
$updateset[] = "leechers = leechers - 1";
        }
    }
}
else
{
    if (
$event == "completed")
        
$updateset[] = "times_completed = times_completed + 1";

    if (isset(
$self))
    {
        
mysql_query("UPDATE peers SET uploaded = $uploaded, downloaded = $downloaded, to_go = $left, last_action = ".time().", seeder = '$seeder'"
            
. ($seeder == "yes" && $self["seeder"] != $seeder ", finishedat = " time() : "") . " 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
    {
        if (
$event != "started")
            
err("Peer not found. ".$passkey." Restart the torrent.");

        if (
portblacklisted($port))
            
err("Port $port is blacklisted.");
        else
        {
            
$sockres = @fsockopen($ip$port$errno$errstr5);
            if (!
$sockres)
                
$connectable "no";
            else
            {
                
$connectable "yes";
                @
fclose($sockres);
            }
        }

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

if (
$seeder == "yes")
{
    if (
$torrent["banned"] != "yes")
        
$updateset[] = "visible = 'yes'";
    
$updateset[] = "last_action = ".time();
}

if (
count($updateset))
    
mysql_query("UPDATE torrents SET " join(","$updateset) . " WHERE id = $torrentid");

benc_resp_raw($resp);



?>
Thats all help me pleas! :unknown:

Last edited by Krypto; 15th September 2009 at 19:36. Reason: Removed Quote Tags and replaced with PHP Tags
Reply With Quote