Bravo List

Bravo List (http://www.bvlist.com/index.php)
-   Template Shares (http://www.bvlist.com/forumdisplay.php?f=26)
-   -   [FIX] TSSE Upload and Scrape (http://www.bvlist.com/showthread.php?t=2291)

Keiichi 15th July 2008 05:58

[FIX] TSSE Upload and Scrape
 
1 Attachment(s)
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

Attachment 1154

Ashur 27th June 2009 18:04

wow this is awesome now I got scrape working and CPU usage dropped down
awesome :D

PRODIGY 27th June 2009 21:12

it doesnt work for v5.6...can somebody help me?
i get the message
Code:

What the hell did you upload? This is not a bencoded file!

rSt0n3 28th June 2009 13:33

bencoded file
 
i have the same problem...

Code:

What the hell did you upload? This is not a bencoded file!
i suposed that bencoded file has to do with benc.php, so i edited benc.php to be like that on the first post...
unfortunately it doesn't work...can anybody help me ???

Terminator 28th June 2009 14:26

works like a charm for us :coffee:

many thnx for this awesome revolutionary work!

cheers :drink:

fireman 30th June 2009 06:24

Quote:

Originally Posted by Keiichi (Post 2617)
These fixed are for the 4.3 TS, 5.1, 5.4 maybe 5.6
my testing with errors

The scrape works great however if i change benc file to whats list I get a message something like direct utilization of this file is not allowed and i tried to upload an external torrent when using this now the original benc file worked fine for me does anyone else have input on this

Ashur 30th June 2009 06:41

well if you got the original benc working then don't mess with it
i had major issues with scrape so this resolved it so I'm happy about that

mmisu120000 2nd July 2009 00:39

Quote:

Originally Posted by fireman (Post 12851)
The scrape works great however if i change benc file to whats list I get a message something like direct utilization of this file is not allowed and i tried to upload an external torrent when using this now the original benc file worked fine for me does anyone else have input on this

in benc.php there is a line where says :
PHP Code:

if (!defined ('IN_SCRIPT_TSSEv51')) 

now, if you have TSSE 5.3, 5.4, 5.4.1, you should replace it with:
PHP Code:

if (!defined ('IN_SCRIPT_TSSEv53')) 

and, if you have the 5.6 version:
PHP Code:

if (!defined ('IN_SCRIPT_TSSEv56')) 


sieucan 17th September 2009 11:17

when i active seo setting, scrape didn't working???
can somebody help me?

informatic 17th September 2009 22:05

Quote:

Originally Posted by sieucan (Post 15715)
when i active seo setting, scrape didn't working???
can somebody help me?

That's funny. Scrape works perfectly for me with SEO on. If it gives you problem, then it might be better to have it off. Besides, the SEO isn't entirely perfect, still a lot of links and etc which aren't "masked".


All times are GMT +2. The time now is 06:02.

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