View Single Post
  #1  
Old 15th July 2008, 05:58
Keiichi's Avatar
Keiichi Keiichi is offline
Senior Member
 
Join Date: Feb 2008
Brazil
Posts: 25
Default [FIX] TSSE Upload and Scrape
1. posible fix for upload ERROR:

Code:
What the hell did you upload? This is not a bencoded file!
benc.php

PHP Code:
<?
/***********************************************/
/*                                             */
/*    E-mail          : mrdecoder@hotmail.com  */
/*                                             */
/*              FearlesS-Releases              */
/*             One Name, One Legend            */
/*                                             */
/***********************************************/


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 
bdec_file($f$ms) {

    
$fp fopen($f"rb");
    
    if (!
$fp)
    {
    return;
    }
    
    
$e fread($fp$ms);
    
fclose($fp);
    return 
bdec($e);
}

function 
bdec($s) {
    if (
preg_match('/^(\d+):/'$s$m)) 
    {
    {
    
$l $m[1];
    
$pl strlen($l) + 1;
    
$v substr($s$pl$l);
    
$ss substr($s0$pl $l);
    }
    
    if (
strlen($v) != $l)
    {
        return;
    }    
    
    return array(
type => "string"value => $vstrlen => strlen($ss), string => $ss);
    }
    
    if (
preg_match('/^i(\d+)e/'$s$m))
    {
    {
    
$v $m[1];
    
$ss "i" $v "e";
    }
    
    if (
$v === "-0")
    {
        return;
    }
    
    if (
$v[0] == "0" && strlen($v) != 1)
    {
        return;
    }    
        
    return array(
type => "integer"value => $vstrlen => strlen($ss), string => $ss);
    }
    
    switch (
$s[0]) {
    case 
"l":
        return 
bdec_list($s);
    case 
"d":
        return 
bdec_dict($s);
    default:
        return;
    }
}

function 
bdec_list($s) {

    if (
$s[0] != "l")
    {
    return;
    }
    
    
$sl strlen($s);
    
$i 1;
    
$v = array();
    
$ss "l";
    
    for (;;) 
    {    
    if (
$i >= $sl)
    {
        return;
    }
        
    if (
$s[$i] == "e")
    {
        break;
    }
    
    
$ret bdec(substr($s$i));
    
    if (!isset(
$ret) || !is_array($ret))
    {
        return;
    }    
        
    
$v[] = $ret;
    
$i += $ret["strlen"];
    
$ss .= $ret["string"];
    
    }
    
$ss .= "e";
    return array(
type => "list"value => $vstrlen => strlen($ss), string => $ss);
}

function 
bdec_dict($s) {

    if (
$s[0] != "d")
    {
    return;
    }
    
    
$sl strlen($s);
    
$i 1;
    
$v = array();
    
$ss "d";
    
    for (;;) 
    {
        if (
$i >= $sl)
        {
            return;
        }    
        
        if (
$s[$i] == "e")
        {
            break;
        }    
    
    
$ret bdec(substr($s$i));
    
    if (!isset(
$ret) || !is_array($ret) || $ret["type"] != "string")
    {
        return;
    }
        
    
$k $ret["value"];
    
$i += $ret["strlen"];
    
$ss .= $ret["string"];
    
    if (
$i >= $sl)
    {
        return;
    }    
        
    
$ret bdec(substr($s$i));
    
    if (!isset(
$ret) || !is_array($ret))
    {
        return;
    }    
        
    
$v[$k] = $ret;
    
$i += $ret["strlen"];
    
$ss .= $ret["string"];
    }
    
$ss .= "e";
    return array(
type => "dictionary"value => $vstrlen => strlen($ss), string => $ss);
}

  if (!
defined ('IN_SCRIPT_TSSEv51'))
  {
    exit (
'<font face=\"verdana\" size=\"2\" color=\"darkred\">Error! Direct initialization of this file is not allowed.</font>');
  }

  @
error_reporting (E_ALL & ~E_NOTICE);
  @
ini_set ("error_reporting"E_ALL & ~E_NOTICE);
  @
ini_set ("display_errors""0");
  @
ini_set ("display_startup_errors""0");
  @
ini_set ("ignore_repeated_errors""1");
  @
ini_set ("log_errors""1");
?>
2. TS 5.1 IOError in Azureus - Error in function gzip

scrape.php original

PHP Code:
<?
/***********************************************/
/*                                             */
/*    E-mail          : mrdecoder@hotmail.com  */
/*                                             */
/*              FearlesS-Releases              */
/*             One Name, One Legend            */
/*                                             */
/***********************************************/


  
function fast_db_connect ()
  {
    
$dbfile './config/DATABASE';
    if (!
file_exists ($dbfile))
    {
      exit (
'DATABASE Configuration file does not exists');
      return 
null;
    }

    
$data unserialize (@file_get_contents ($dbfile));
    if (!(
$connect mysql_connect ($data['mysql_host'], $data['mysql_user'], $data['mysql_pass'])))
    {
      exit (
'Error: Mysql Connection!');
      ;
    }

    if (!(
mysql_select_db ($data['mysql_db'], $connect)))
    {
      exit (
'Error: Mysql DB Selection!');
      ;
    }

    unset (
$data);
  }

  function 
sqlesc ($value)
  {
    if (
get_magic_quotes_gpc ())
    {
      
$value stripslashes ($value);
    }

    if (!
is_numeric ($value))
    {
      
$value '\'' mysql_real_escape_string ($value) . '\'';
    }

    return 
$value;
  }

  function 
hash_where ($name$hash)
  {
    return 
'' '(' $name ' = ' sqlesc ($hash) . ('' ' OR ' $name ' = ') . sqlesc (preg_replace ('/ *$/s'''$hash)) . ')';
  }

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

  function 
hash_pad ($hash)
  {
    return 
str_pad ($hash20);
  }

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

  @
error_reporting (E_ALL & ~E_NOTICE);
  @
ini_set ('error_reporting'E_ALL & ~E_NOTICE);
  @
ini_set ('display_errors''0');
  
define ('S_VERSION''0.6 by xam');
  if (!isset (
$_GET['info_hash']))
  {
    exit (
'Permission denied!');
  }

  
fast_db_connect ();
  
$r 'd' benc_str ('files') . 'd';
  if (!(
$res mysql_query ('SELECT info_hash,seeders,times_completed,leechers FROM torrents WHERE ' hash_where ('info_hash'unesc ($_GET['info_hash'])) . ' LIMIT 1')))
  {
    exit (
'Mysql error!');
    ;
  }

  while (
$row mysql_fetch_assoc ($res))
  {
    
$r .= '20:' hash_pad ($row['info_hash']) . 'd' benc_str ('complete') . 'i' $row['seeders'] . 'e' benc_str ('downloaded') . 'i' $row['times_completed'] . 'e' benc_str ('incomplete') . 'i' $row['leechers'] . 'e' 'e';
  }

  
$r .= 'ee';
  
header ('Content-Type: text/plain');
  if ((isset (
$_SERVER['HTTP_ACCEPT_ENCODING']) AND $_SERVER['HTTP_ACCEPT_ENCODING'] == 'gzip'))
  {
    
header ('Content-Encoding: gzip');
    echo 
gzencode ($x9FORCE_GZIP);
  }
  else
  {
    echo 
$r;
  }

  unset (
$r);

Fix 1


PHP Code:
<?
/***********************************************/
/*                                             */
/*    E-mail          : mrdecoder@hotmail.com  */
/*                                             */
/*              FearlesS-Releases              */
/*             One Name, One Legend            */
/*                                             */
/***********************************************/


  
function fast_db_connect ()
  {
    
$dbfile './config/DATABASE';
    if (!
file_exists ($dbfile))
    {
      exit (
'DATABASE Configuration file does not exists');
      return 
null;
    }

    
$data unserialize (@file_get_contents ($dbfile));
    if (!(
$connect mysql_connect ($data['mysql_host'], $data['mysql_user'], $data['mysql_pass'])))
    {
      exit (
'Error: Mysql Connection!');
    }

    if (!(
mysql_select_db ($data['mysql_db'], $connect)))
    {
      exit (
'Error: Mysql DB Selection!');
    }

    unset (
$data);
  }

  function 
sqlesc ($value)
  {
    if (
get_magic_quotes_gpc ())
    {
      
$value stripslashes ($value);
    }

    if (!
is_numeric ($value))
    {
      
$value '\'' mysql_real_escape_string ($value) . '\'';
    }

    return 
$value;
  }

  function 
hash_where ($name$hash)
  {
    return 
'' '(' $name ' = ' sqlesc ($hash) . ('' ' OR ' $name ' = ') . sqlesc (preg_replace ('/ *$/s'''$hash)) . ')';
  }

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

  function 
hash_pad ($hash)
  {
    return 
str_pad ($hash20);
  }

  function 
benc_str ($s)
  {
    return 
strlen ($s) . ':' $s;
  }
  
  @
error_reporting (E_ALL & ~E_NOTICE);
  @
ini_set ('error_reporting'E_ALL & ~E_NOTICE);
  @
ini_set ('display_errors''0');
  
define ('S_VERSION''0.6 by xam');
  if (!isset (
$_GET['info_hash']))
  {
    exit (
'Permission denied!');
  }

  
fast_db_connect ();
  
$r 'd' benc_str ('files') . 'd';
  if (!(
$res mysql_query ('SELECT info_hash,seeders,times_completed,leechers FROM torrents WHERE ' hash_where ('info_hash'unesc ($_GET['info_hash'])) . ' LIMIT 1')))
  {
    exit (
'Mysql error!');
  }

  while (
$row mysql_fetch_assoc ($res))
  {
    
$r .= '20:' hash_pad ($row['info_hash']) . 'd' benc_str ('complete') . 'i' $row['seeders'] . 'e' benc_str ('downloaded') . 'i' $row['times_completed'] . 'e' benc_str ('incomplete') . 'i' $row['leechers'] . 'e' 'e';
  }

  
$r .= 'ee';
  
  if ((isset (
$_SERVER['HTTP_ACCEPT_ENCODING']) AND $_SERVER['HTTP_ACCEPT_ENCODING'] == 'gzip')) {
   
header('Content-Type: text/plain');
   
header('Content-Encoding: gzip');
   echo 
gzencode($r9FORCE_GZIP);
  }
  else
   
header('Content-Type: text/plain'); {
  echo 
$r;
  }
  unset(
$r);

?>
Fix 2

PHP Code:
<?
/***********************************************/
/*                                             */
/*    E-mail          : mrdecoder@hotmail.com  */
/*                                             */
/*              FearlesS-Releases              */
/*             One Name, One Legend            */
/*                                             */
/***********************************************/


  
function fast_db_connect ()
  {
    
$dbfile './config/DATABASE';
    if (!
file_exists ($dbfile))
    {
      exit (
'DATABASE Configuration file does not exists');
      return 
null;
    }

    
$data unserialize (@file_get_contents ($dbfile));
    if (!(
$connect mysql_connect ($data['mysql_host'], $data['mysql_user'], $data['mysql_pass'])))
    {
      exit (
'Error: Mysql Connection!');
      ;
    }

    if (!(
mysql_select_db ($data['mysql_db'], $connect)))
    {
      exit (
'Error: Mysql DB Selection!');
      ;
    }

    unset (
$data);
  }

  function 
sqlesc ($value)
  {
    if (
get_magic_quotes_gpc ())
    {
      
$value stripslashes ($value);
    }

    if (!
is_numeric ($value))
    {
      
$value '\'' mysql_real_escape_string ($value) . '\'';
    }

    return 
$value;
  }

  function 
hash_where ($name$hash)
  {
    return 
'' '(' $name ' = ' sqlesc ($hash) . ('' ' OR ' $name ' = ') . sqlesc (preg_replace ('/ *$/s'''$hash)) . ')';
  }

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

  function 
hash_pad ($hash)
  {
    return 
str_pad ($hash20);
  }

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

  @
error_reporting (E_ALL & ~E_NOTICE);
  @
ini_set ('error_reporting'E_ALL & ~E_NOTICE);
  @
ini_set ('display_errors''0');
  
define ('S_VERSION''0.6 by xam');
  if (!isset (
$_GET['info_hash']))
  {
    exit (
'Permission denied!');
  }

  
fast_db_connect ();
  
$r 'd' benc_str ('files') . 'd';
  if (!(
$res mysql_query ('SELECT info_hash,seeders,times_completed,leechers FROM torrents WHERE ' hash_where ('info_hash'unesc ($_GET['info_hash'])) . ' LIMIT 1')))
  {
    exit (
'Mysql error!');
    ;
  }

  while (
$row mysql_fetch_assoc ($res))
  {
    
$r .= '20:' hash_pad ($row['info_hash']) . 'd' benc_str ('complete') . 'i' $row['seeders'] . 'e' benc_str ('downloaded') . 'i' $row['times_completed'] . 'e' benc_str ('incomplete') . 'i' $row['leechers'] . 'e' 'e';
  }

  
$r .= 'ee';
  
header ('Content-Type: text/plain');

echo 
$r;
unset (
$r);
?>
These fixed are for the 4.3 TS, 5.1, 5.4 maybe 5.6
my testing with errors

Click image for larger version

Name:	IOError_in_Azureus.JPG
Views:	1116
Size:	91.4 KB
ID:	1154

Last edited by Ashur; 27th June 2009 at 18:48. Reason: edited by a possible error my
Reply With Quote
The Following 9 Users Say Thank You to Keiichi For This Useful Post:
aMiGo1972 (1st July 2009), Ashur (27th June 2009), blinko (22nd September 2009), GameOne (5th April 2009), sieucan (17th September 2009), syndrome (27th March 2009), Terminator (28th June 2009), Virusache (4th April 2009), zero (29th July 2009)