PHP Code:
<?
function getfilebycat($cat)
{
if ($cat == 1) { return "soft"; }
elseif($cat == 13) { return "kino"; }
elseif($cat == 5) { return "games"; }
elseif($cat == 18) { return "tv"; }
elseif($cat == 10) { return "music"; }
elseif($cat == 19) { return "multiki"; }
elseif($cat == 11) { return "serial"; }
elseif($cat == 16) { return "knigi"; }
elseif($cat == 12) { return "anime"; }
}
function bark($msg = "")
{
//echo("error - ".$msg."<br>");
}
function gzdecode($data){
$g=tempnam('/tmp','ff');
@file_put_contents($g,$data);
ob_start();
readgzfile($g);
$d=ob_get_clean();
return $d;
}
require_once("parsers/exclude.php");
/* this is not a text @text */ function HTML2BB($text){$s = $text;$s = str_replace("<br>","", $s);$s = str_replace("<br />","", $s);$s = str_replace("<li>", "[*]", $s);$s = str_replace("</ul>", "", $s);$s = str_replace("<ul>", "", $s);$s = str_replace("</li>", "", $s);$s = str_replace(" ", " ", $s);$s = str_replace("&", "&", $s);$s = str_replace(">", "<", $s);$s = str_replace("<", ">", $s);$s = str_replace('"', '"', $s);$s = str_replace(''', "'", $s);$s = str_replace('"', '"', $s);$s = preg_replace("/\<b\>((\s|.)+?)\<\/b\>/", "[b]\\1[/b]", $s);$s = preg_replace("/\<i\>((\s|.)+?)\<\/i\>/", "[i]\\1[/i]", $s);$s = preg_replace("/\<u\>((\s|.)+?)\<\/u\>/", "[u]\\1[/u]", $s);$s = preg_replace("/\<img src=\"((http|ftp|https|ftps|irc):\/\/[^\s'\"<>]+(\.(gif|jpeg|jpg|png)))\" >/i", "[img]\\1[/img]", $s);$s = preg_replace("/\<img border=\"0\" src=\"((http|ftp|https|ftps|irc):\/\/[^\s'\"<>]+(\.(gif|jpeg|jpg|png)))\" >/i", "[img]\\1[/img]", $s);$s = preg_replace("/\<img border=\"0\" alt=\"\" src=\"((http|ftp|https|ftps|irc):\/\/[^\s'\"<>]+(\.(gif|jpeg|jpg|png)))\" >/i", "[img]\\1[/img]", $s);$s = preg_replace("/\<img border=\"0\" title=\"\" src=\"((http|ftp|https|ftps|irc):\/\/[^\s'\"<>]+(\.(gif|jpeg|jpg|png)))\" >/i", "[img]\\1[/img]", $s);$s = preg_replace("/\<img border=0 src=\"((http|ftp|https|ftps|irc):\/\/[^\s'\"<>]+(\.(gif|jpeg|jpg|png)))\">/i", "[img]\\1[/img]", $s);$s = preg_replace("/\<img border=0 src=\"((http|ftp|https|ftps|irc):\/\/[^\s'\"<>]+(\.(gif|jpeg|jpg|png)))\" \/>/i", "[img]\\1[/img]", $s);$s = preg_replace("/\<img src=\"((http|ftp|https|ftps|irc):\/\/[^\s'\"<>]+(\.(gif|jpeg|jpg|png)))\" \/>/i", "[img]\\1[/img]", $s);$s = preg_replace("/\<img border=\"0\" src=\"((http|ftp|https|ftps|irc):\/\/[^\s'\"<>]+(\.(gif|jpeg|jpg|png)))\" \/>/i", "[img]\\1[/img]", $s);$s = preg_replace("/\<img border=\"0\" alt=\"\" src=\"((http|ftp|https|ftps|irc):\/\/[^\s'\"<>]+(\.(gif|jpeg|jpg|png)))\" \/>/i", "[img]\\1[/img]", $s);$s = preg_replace("/\<img border=\"0\" title=\"\" src=\"((http|ftp|https|ftps|irc):\/\/[^\s'\"<>]+(\.(gif|jpeg|jpg|png)))\" \/>/i", "[img]\\[/img]", $s);$s = preg_replace("/\<img src=\"((http|ftp|https|ftps|irc):\/\/[^\s'\"<>]+(\.(gif|jpeg|jpg|png)))\">/i", "[img]\\[/img]", $s);$s = preg_replace("/\<a href=\"([^()<> ,]+)\" target=\"_blank\">((\s|.)+?)\<\/a\>/i","[url=\\1]\\2[/url]", $s);$s = preg_replace("/\<a href=\"([^()<>\s]+?)\">((\s|.)+?)\<\/a\>/i","[url=\\1]\\2[/url]", $s);$s = preg_replace("/\<a href=\"([^()<>\s]+?)\" class=\"lbimg\" target=\"_blank\">((\s|.)+?)\<\/a\>/i","[url=\\1]\\2[/url]", $s);$s = preg_replace("/\<font color=(#[a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9])\>((\s|.)+?)\<\/font\>/i","[color=\\1]\\2[/color]", $s);$s = preg_replace("/\<span style=\"color:([^()<>\s]+?);\"\>((\s|.)+?)\<\/span\>/i","[color=\\1]\\2[/color]", $s);$s = str_replace("<div class=\"hidehead\" onclick=\"hideshow($(this))\">", "", $s);$s = str_replace("<div class=\"hidebody\"></div><textarea class=\"hidearea\">", "", $s);$s = str_replace("</textarea></div>", "[/spoiler]", $s);$s = preg_replace("/\<font color=([a-zA-Z]+)\>((\s|.)+?)\<\/font\>/i","[color=\\1]\\2[/color]", $s); $s = preg_replace("/\<div class=\"hidewrap\">((\s|.)+?)\<\/div>/i","[spoiler=\\1]", $s);$s = preg_replace("/\<font face=\"([a-zA-Z ,]+)\">((\s|.)+?)\<\/font\>/i","[font=\\1]\\2[/font]", $s);$s = preg_replace("/\<div align=\"([a-zA-Z ,]+)\">((\s|.)+?)\<\/div\>/i","[\\1]\\2[/\\1]", $s);$s = preg_replace("/\<div align='([a-zA-Z ,]+)'>((\s|.)+?)\<\/div\>/i","[\\1]\\2[/\\1]", $s);$s = preg_replace("/\<font style=\"line-height:normal;\" size=\"([1-7])\/\">((\s|.)+?)\<\/font\>/i","[size=\\1]\\2[/size]", $s);$s = preg_replace("/\<font style=\"line-height:normal;\" size=\"([1-7])\">((\s|.)+?)\<\/font\>/i","[size=\\1]\\2[/size]", $s);$s = preg_replace("/\<font size=\"([1-7])\">((\s|.)+?)\<\/font\>/i","[size=\\1]\\2[/size]", $s);$s = preg_replace("/\<font size=([1-7])\>((\s|.)+?)\<\/font\>/i","[size=\\1]\\2[/size]", $s);return $s;}function tral ($str){global $rus_lang, $rom_lang, $rus_lang2;$i = 0;while($i < 34){$i++;$str = str_ireplace($rus_lang[$i], $rom_lang[$i], $str);$str = str_ireplace($rus_lang2[$i], $rom_lang[$i], $str);}return $str;} function searchfields($s) { return preg_replace(array('/[^a-z0-9]/si', '/^\s*/s', '/\s*$/s', '/\s+/s'), array(" ", "", "", " "), $s); }
function uploadtorrent($torrentid, $category = "1", $owner = "1"){
global $excl;
$torrent = file_get_contents('http://opensharing.org/torrent/'.$torrentid.'/', false);
if(!preg_match("/head/", $torrent))
{
$torrent = gzdecode($torrent);
}
$x = preg_match_all("/.*<h1>(.*)<\/h1>.*/isU", $torrent, $matches);
$torrent = str_replace("<img border=0 src=\"http://i9.fastpic.ru/big/2010/0909/a3/70a14db1e803628401eba93ed7bb03a3.png\"> <img border=0 src=\"http://i9.fastpic.ru/big/2010/0904/f2/5802c98d74b5f803d13fa6b476f04ff2.jpg\"> <img border=0 src=\"http://i9.fastpic.ru/big/2010/0909/a0/c8a08916461a4af38839c8f410432fa0.png\"> <img border=0 src=\"http://i9.fastpic.ru/big/2010/0904/f2/5802c98d74b5f803d13fa6b476f04ff2.jpg\"> <img border=0 src=\"http://i9.fastpic.ru/big/2010/0909/40/a92c82ea13fecaa004139337ace95b40.png\">","",$torrent);
$torrent = str_replace("<img border=0 src=\"http://i14.fastpic.ru/big/2010/1229/85/90422dd76cfdad9d4a7ee3393e2acf85.gif\">", "", $torrent);
$torrent = str_replace("<img border=0 src=\"http://i4.fastpic.ru/big/2011/0117/85/5815199029b94eae5ee799024819c585.png\">", "", $torrent);
##@POSTER
$x = preg_match_all("/.*<table id=\"details\">(.*)<td class='header'>.*/isU", $torrent, $matches00);
$x = preg_match_all("/.*src=\"(.*)\".*/isU", $matches00[1][0], $matches2);
$x = preg_match_all("/.*<.*><td class='header'>Раздают<\/td><.*>(.*)<\/td><\/tr>.*/isU", $torrent, $matchesS);
$x = preg_match_all("/.*<.*><td class='header'>Качают<\/td><.*>(.*)<\/td><\/tr>.*/isU", $torrent, $matchesL);
$x = preg_match_all("/.*<.*>Жанр: <.*\>(.*)<\/a>.*/isU", $torrent, $matches5);
$x = preg_match_all("/.*<a href=\".*\"><img src=\".*\" alt=\"скачать торрент-файл\" height=\"30\" width=\"27\" \/> Скачать (.*)<\/a>.*/isU", $torrent, $matches6);
$x = preg_match_all("/.*<tr><td><\/td><td>(.*)<\/td><\/tr>.*/isU", $torrent, $matches3);
$name = $matches[1][0];
$name = iconv('UTF-8', 'windows-1251', $name);
//die("name - ".$torrent);
$image = $matches2[1][0];
$descr = HTML2BB($matches3[1][0]);
$descr = iconv('UTF-8', 'windows-1251', $descr);
$descr = str_replace("[img]".$image."[/img]", "", $descr);
$descr = str_replace("[img=".$image."]", "", $descr);
//die("descriere - $descr");
$seeders = $matchesS[1][0];
$leechers = $matchesL[1][0];
$fname = $matches6[1][0];
$fp = fopen('torrents/'.$torrentid.'.torrent', 'w');
fwrite($fp, file_get_contents("http://opensharing.org/download/".$torrentid.""));
fclose($fp);
$dict = bdec_file("torrents/".$torrentid.".torrent", 1024 * 1024);
/// if (!isset($dict)){echo("Dict failed for #id.....skiping!<br>");}
list($info) = dict_check($dict, "info");
list($dname, $plen, $pieces) = dict_check($info, "name(string):piece length(integer):pieces(string)");
// die("ska");
if (strlen($pieces) % 20 != 0){echo("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)){ // echo("missing both length and files");
}if (!count($flist)) { echo("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"){
//echo("filename error");
} $ffa[] = $ffe["value"]; } if (!count($ffa)) {echo("filename error");}$ffe = implode("/", $ffa); $filelist[] = array($ffe, $ll);if ($ffe == 'Thumbs.db') {
//echo("Ошибка! В торрентах запрещено держать файлы Thumbs.db!<br>");
} } $type = "multi";}
$infohash = sha1($info["string"]);
$annurl = "http://announce.opensharing.org:2710/announce";
$external = "yes";
$activetrack = "announce.opensharing.org:2710---$seeders,$leechers,".($seeders+$leechers)."";
//$exc = array("FS-Media", "от");
foreach($excl as $gh)
{
$gh = substr($gh, 0, -1);
$name = str_ireplace("".$gh."", "", $name);
$descr = str_ireplace("".$gh."", "", $descr);
}
/*
$exclude = file("exclude.txt");
foreach($exclude as $toexclude){
//$toexclude = substr($toexclude, 0, -1);
//$toexcludes = str_replace("/", "\/", $toexclude);
//echo($toexclude." , ".$name."<br>");
// die();
// echo($toexclude." , ".$name."<br>");
}
*/
//die($name);
$descr = str_replace("
", "", $descr);
if(!empty($fname)) {
$ret = @mysql_query("INSERT INTO torrents (search_text, filename,owner,
visible,sticky,info_hash,name,size, announce_url, active_trackers, external, seeders_net, leechers_net,
numfiles,type,descr,ori_descr,category,save_as,added,last_action)
VALUES (" . implode(",", array_map("sqlesc", array(searchfields("$name"), $fname, $owner,"yes",
"no",$infohash,$name, $totallen, $annurl, $activetrack, $external, $seeders, $leechers, count($filelist),$type,$descr,$descr, 0+$category, $fname))) . ", NOW(), NOW())"); if (!$ret){ $fail = "double"; }
$newid = @mysql_insert_id();
@rename ("torrents/".$torrentid.".torrent", "torrents/".$newid.".torrent");
$ext = substr($image, strrpos($image, '.') + 1);
//echo("uploaded......$newid<br>");
///if (copy("".$image."", "torrents/images/".$newid."0.".$ext.""))
///{
///
mysql_query("update torrents set image1='".$image."' where id='".$newid."'") or sqlerr();
if ($ret){ echo "Torrent Upload .... <font color=green>OK</font><br>"; } else { echo "Torrent Upload....<font color=red>Fail! ".(mysql_errno() == 1062 ? "epic fail" : "Already exists in database!")."</font><br>"; }
if(file_exists('result_'.getfilebycat($category).'.txt')){
$file = file('result_'.getfilebycat($category).'.txt');
$rand = rand(0,2000);
$a=0;
foreach ($file as $line => $text)
{
if ($line == $rand)
{
$v = 1900; $name = $name;
while ($v < 2012)
{
$v++;
$name = str_replace("(".$v.")", "", $name);
}
$ar = array("DVDRip", "HDTVRip", "CAMRip", "HDRip", "BDRip", "1080p", "780p", "от HQCLUB");
foreach($ar as $replace)
{
$name = str_replace("".$replace."", "", $name);
}
$text = str_replace("TITLE", "<b>$name</b>", $text);
mysql_query("UPDATE `torrents` set `text` = ".sqlesc($text)." where id = '".$newid."'") or sqlerr();
}
}
}
if(file_exists('result_'.getfilebycat($category).'_niz.txt')){
$file = file('result_'.getfilebycat($category).'_niz.txt');
$rand = rand(0,4000);
$a=0;
foreach ($file as $line => $text)
{
if ($line == $rand)
{
$v = 1900; $name = $name;
while ($v < 2012)
{
$v++;
$name = str_replace("(".$v.")", "", $name);
}
$ar = array("DVDRip", "HDTVRip", "CAMRip", "HDRip", "BDRip", "1080p", "780p", "от HQCLUB");
foreach($ar as $replace)
{
$name = str_replace("".$replace."", "", $name);
}
$text = str_replace("TITLE", "<b>$name</b>", $text);
mysql_query("UPDATE `torrents` set `text_vniz` = ".sqlesc($text)." where id = '".$newid."'") or sqlerr();
}
}
usleep(500000);
}
}
///}
/*
$files = file('comment_'.getfilebycat($category).'.txt');
$rands = rand(0,2000);
$as=0;
foreach ($files as $line => $text)
{
if ($line == $rands)
{
$v = 1900; $name = $name;
while ($v < 2012)
{
$v++;
$name = str_replace("(".$v.")", "", $name);
}
$ar = array("DVDRip", "HDTVRip", "CAMRip", "HDRip", "BDRip", "1080p", "780p", "от HQCLUB");
foreach($ar as $replace)
{
$name = str_replace("".$replace."", "", $name);
}
$text = str_replace("TITLE", "[b]$name[/b]", $text);
$userid = array(21,15,22,9,10,11,14,20,12,16,17,18,19,23,13,8);
$gg = rand(1,16);
$to_user = $userid[$gg];
mysql_query("INSERT INTO comments (user, torrent, added, text, ori_text, ip) VALUES (" .
$to_user . ",$newid, '" . get_date_time() . "', " . sqlesc($text) .
"," . sqlesc($text) . "," . sqlesc(rand(6,9).".".rand(1,254).".".rand(1,254).".".rand(1,254)) . ")");
/// $newid = mysql_insert_id();
sql_query("UPDATE torrents SET comments = comments + 1 WHERE id = $newid");
//mysql_query("UPDATE `torrents` set `text` = ".sqlesc($text)." where id = '".$newid."'") or sqlerr();
}
}
usleep(500000);
*/ ///}
}
/* */
##############################
### This is NOT a Text File ##
##############################
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($s, 0, $pl + $l);
if (strlen($v) != $l)
return;
return array('type' => "string", 'value' => $v, 'strlen' => 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' => $v, 'strlen' => 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' => $v, 'strlen' => 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' => $v, 'strlen' => strlen($ss), 'string' => $ss);
}
function dict_check($d, $s) {
if ($d["type"] != "dictionary")
bark("not a dictionary");
$a = explode(":", $s);
$dd = $d["value"];
$ret = array();
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"];
}
?>
p.s. in attach all files downloaded from TBDev Yuna Scatari Edition forum