コード例 #1
0
ファイル: class.bencdec.php プロジェクト: Bigjoos/U-232-V5
 public static function decode($str, $options = 0)
 {
     if (!is_string($str)) {
         return self::decode_error('Input data must be string in order to decode, "' . gettype($str) . '" given');
     }
     if (strlen($str) == 0) {
         return self::decode_error('Input string empty');
     }
     self::$bdata_position = 0;
     self::$bdata_depth = 0;
     self::$ext_valid = false;
     self::$bdata_length = strlen($str);
     self::$bdata = $str;
     unset($str);
     if ($options & self::OPTION_EXTENDED_VALIDATION) {
         self::$ext_valid = true;
     }
     $data = self::bdecode();
     if (self::$ext_valid) {
         if (self::$bdata_position < self::$bdata_length) {
             return self::decode_error('Garbage data at end');
         }
     }
     self::$bdata_position = 0;
     self::$bdata_length = 0;
     self::$bdata = '';
     self::$bdata_depth = 0;
     self::$ext_valid = false;
     return $data;
 }
コード例 #2
0
function scrape($url, $infohash = "")
{
    global $db;
    if (isset($url)) {
        $u = urldecode($url);
        $extannunce = str_replace("announce", "scrape", $u);
        $purl = parse_url($extannunce);
        $port = isset($purl["port"]) ? $purl["port"] : "80";
        $path = isset($purl["path"]) ? $purl["path"] : "/scrape.php";
        $an = ($purl["scheme"] != "http" ? $purl["scheme"] . "://" : "") . $purl["host"];
        $fd = @fsockopen($an, $port, $errno, $errstr, 60);
        if ($fd) {
            if ($infohash != "") {
                $ihash = array();
                $ihash = explode("','", $infohash);
                $info_hash = "";
                foreach ($ihash as $myihash) {
                    $info_hash .= "&info_hash=" . escapeURL($myihash);
                }
                $info_hash = substr($info_hash, 1);
                fputs($fd, "GET " . $path . "?" . $info_hash . " HTTP/1.0\r\nHost: somehost.net\r\n\r\n");
            } else {
                fputs($fd, "GET " . $path . " HTTP/1.0\r\nHost: somehost.net\r\n\r\n");
            }
            $stream = "";
            while (!feof($fd)) {
                $stream .= fgets($fd, 4096);
                if (strlen($stream) > 100000) {
                    $ret = $db->query("UPDATE namemap SET lastupdate = NOW() WHERE announce_url = '" . $url . "'" . ($infohash == "" ? "" : " AND namemap.info_hash IN ('" . $infohash . "')"));
                    write_log("FAILED update external torrent " . ($infohash == "" ? "" : "(infohash: " . $infohash . ")") . " from " . $url . " tracker (response too big)", "");
                    @fclose($fd);
                    return;
                }
            }
        } else {
            $ret = $db->query("UPDATE namemap SET lastupdate = NOW() WHERE announce_url = '" . $url . "'" . ($infohash == "" ? "" : " AND namemap.info_hash IN ('" . $infohash . "')"));
            write_log("FAILED update external torrent " . ($infohash == "" ? "" : "(infohash: " . $infohash . ")") . " from " . $url . " tracker (not connectable)", "");
            return;
        }
        @fclose($fd);
        $stream = utf8::trim(stristr($stream, "d5:files"));
        if (strpos($stream, "d5:files") === false) {
            // if host answer but stream is not valid encoded file try old metod
            // will work only with standard http
            $ihash = array();
            $ihash = explode("','", $infohash);
            $info_hash = "";
            foreach ($ihash as $myihash) {
                $info_hash .= "&info_hash=" . escapeURL($myihash);
            }
            $info_hash = substr($info_hash, 1);
            $fd = fopen($extannunce . ($infohash != "" ? "?{$info_hash}" : ""), "rb");
            if ($fd) {
                while (!feof($fd)) {
                    $stream .= fread($fd, 4096);
                    if (strlen($stream) > 100000) {
                        $ret = $db->query("UPDATE namemap SET lastupdate = NOW() WHERE announce_url = '" . $url . "'" . ($infohash == "" ? "" : " AND namemap.info_hash IN ('" . $infohash . "')"));
                        write_log("FAILED update external torrent " . ($infohash == "" ? "" : "(infohash: " . $infohash . ")") . " from " . $url . " tracker (response too big)", "");
                        @fclose($fd);
                        return;
                    }
                }
            } else {
                $ret = $db->query("UPDATE namemap SET lastupdate = NOW() WHERE announce_url = '" . $url . "'" . ($infohash == "" ? "" : " AND namemap.info_hash IN ('" . $infohash . "')"));
                write_log("FAILED update external torrent " . ($infohash == "" ? "" : "(infohash: " . $infohash . ")") . " from " . $url . " tracker (not connectable)", "");
                return;
            }
        }
        $array = bencdec::decode($stream);
        if (!isset($array)) {
            $ret = $db->query("UPDATE namemap SET lastupdate = NOW() WHERE announce_url = '" . $url . "'" . ($infohash == "" ? "" : " AND namemap.info_hash IN ('" . $infohash . "')"));
            write_log("FAILED update external torrent " . ($infohash == "" ? "" : "(infohash: " . $infohash . ")") . " from " . $url . " tracker (not bencode data)", "");
            return;
        }
        if ($array == false) {
            $ret = $db->query("UPDATE namemap SET lastupdate = NOW() WHERE announce_url = '" . $url . "'" . ($infohash == "" ? "" : " AND namemap.info_hash IN ('" . $infohash . "')"));
            write_log("FAILED update external torrent " . ($infohash == "" ? "" : "(infohash: " . $infohash . ")") . " from " . $url . " tracker (not bencode data)", "");
            return;
        }
        if (!isset($array["files"])) {
            $ret = $db->query("UPDATE namemap SET lastupdate = NOW() WHERE announce_url = '" . $url . "'" . ($infohash == "" ? "" : " AND namemap.info_hash IN ('" . $infohash . "')"));
            write_log("FAILED update external " . ($infohash == "" ? "" : "(infohash: " . $infohash . ")") . " torrent from " . $url . " tracker (not bencode data)", "");
            return;
        }
        $files = $array["files"];
        if (!is_array($files)) {
            $ret = $db->query("UPDATE namemap SET lastupdate = NOW() WHERE announce_url = '" . $url . "'" . ($infohash == "" ? "" : " AND namemap.info_hash IN ('" . $infohash . "')"));
            write_log("FAILED update external torrent " . ($infohash == "" ? "" : "(infohash: " . $infohash . ")") . " from " . $url . " tracker (probably deleted torrent(s))", "");
            return;
        }
        foreach ($files as $hash => $data) {
            $seeders = (int) $data["complete"];
            $leechers = (int) $data["incomplete"];
            if (isset($data["downloaded"])) {
                $completed = (int) $data["downloaded"];
            } else {
                $completed = "0";
            }
            $torrenthash = bin2hex(stripslashes($hash));
            $ret = $db->query("UPDATE namemap SET lastupdate = NOW(), lastsuccess = NOW() WHERE announce_url = '" . $url . "'" . ($hash == "" ? "" : " AND namemap.info_hash = '" . $torrenthash . "'"));
            $ret = $db->query("UPDATE summary INNER JOIN namemap ON namemap.info_hash = summary.info_hash SET summary.seeds = " . $seeders . ", summary.leechers = " . $leechers . ", summary.finished = " . $completed . " WHERE summary.info_hash = '" . $torrenthash . "' AND namemap.announce_url = '" . $url . "'");
            if ($db->affected_rows == 1) {
                write_log("SUCCESS update external torrent from " . $url . " tracker (infohash: " . $torrenthash . ")", "");
            }
        }
    }
}
コード例 #3
0
ファイル: takeupload.php プロジェクト: Bigjoos/U-232-V5
$mc1->delete_value('MyPeers_' . $CURUSER['id']);
//$mc1->delete_value('lastest_tor_');  //
$mc1->delete_value('last5_tor_');
$mc1->delete_value('scroll_tor_');
sql_query("DELETE FROM files WHERE torrent = " . sqlesc($id));
function file_list($arr, $id)
{
    foreach ($arr as $v) {
        $new[] = "({$id}," . sqlesc($v[0]) . "," . $v[1] . ")";
    }
    return join(",", $new);
}
sql_query("INSERT INTO files (torrent, filename, size) VALUES " . file_list($filelist, $id));
//==
$dir = $INSTALLER09['torrent_dir'] . '/' . $id . '.torrent';
if (!bencdec::encode_file($dir, $dict)) {
    stderr('Error', 'Could not properly encode file');
}
@unlink($tmpname);
chmod($dir, 0664);
//==
//=== if it was an offer notify the folks who liked it :D
if ($offer > 0) {
    $res_offer = sql_query('SELECT user_id FROM offer_votes WHERE vote = \'yes\' AND user_id != ' . sqlesc($CURUSER['id']) . ' AND offer_id = ' . sqlesc($offer)) or sqlerr(__FILE__, __LINE__);
    $subject = sqlesc('An offer you voted for has been uploaded!');
    $message = sqlesc("Hi, \n An offer you were interested in has been uploaded!!! \n\n Click  [url=" . $INSTALLER09['baseurl'] . "/details.php?id=" . $id . "]" . htmlsafechars($torrent, ENT_QUOTES) . "[/url] to see the torrent page!");
    while ($arr_offer = mysqli_fetch_assoc($res_offer)) {
        sql_query('INSERT INTO messages (sender, receiver, added, msg, subject, saved, location) 
    VALUES(0, ' . sqlesc($arr_offer['user_id']) . ', ' . TIME_NOW . ', ' . $message . ', ' . $subject . ', \'yes\', 1)') or sqlerr(__FILE__, __LINE__);
        $mc1->delete_value('inbox_new_' . $arr_offer['user_id']);
        $mc1->delete_value('inbox_new_sb_' . $arr_offer['user_id']);
コード例 #4
0
    sql_query('UPDATE users SET torrent_pass='******'torrent_pass']) . 'WHERE id=' . sqlesc($CURUSER['id'])) or sqlerr(__FILE__, __LINE__);
    $mc1->begin_transaction('MyUser_' . $CURUSER['id']);
    $mc1->update_row(false, array('torrent_pass' => $CURUSER['torrent_pass']));
    $mc1->commit_transaction($INSTALLER09['expires']['curuser']);
    $mc1->begin_transaction('user' . $CURUSER['id']);
    $mc1->update_row(false, array('torrent_pass' => $CURUSER['torrent_pass']));
    $mc1->commit_transaction($INSTALLER09['expires']['user_cache']);
}
$dict = bencdec::decode_file($fn, $INSTALLER09['max_torrent_size']);
if (XBT_TRACKER == true) {
    $dict['announce'] = $INSTALLER09['xbt_prefix'] . $CURUSER['torrent_pass'] . $INSTALLER09['xbt_suffix'];
} else {
    $dict['announce'] = $INSTALLER09['announce_urls'][$ssluse] . '?torrent_pass='******'torrent_pass'];
}
$dict['uid'] = (int) $CURUSER['id'];
$tor = bencdec::encode($dict);
if ($zipuse) {
    require_once INCL_DIR . 'phpzip.php';
    $row['name'] = str_replace(array(' ', '.', '-'), '_', $row['name']);
    $file_name = $INSTALLER09['torrent_dir'] . '/' . $row['name'] . '.torrent';
    if (file_put_contents($file_name, $tor)) {
        $zip = new PHPZip();
        $files = array($file_name);
        $file_name = $INSTALLER09['torrent_dir'] . '/' . $row['name'] . '.zip';
        $zip->Zip($files, $file_name);
        $zip->forceDownload($file_name);
        unlink($INSTALLER09['torrent_dir'] . '/' . $row['name'] . '.torrent');
        unlink($INSTALLER09['torrent_dir'] . '/' . $row['name'] . '.zip');
    } else {
        stderr('Error', 'Can\'t create the new file, please contatct staff');
    }
コード例 #5
0
ファイル: details.php プロジェクト: HDVinnie/BtiTracker-1.5.0
     obj[id1].style.display = 'block';
    }
    else {
     obj[id].style.display = 'block';
     obj[id1].style.display = 'none';
    }
}
</script>
<?php 
require_once CLASS_PATH . 'class.Bencode.php';
if (file_exists($row["url"])) {
    print "\n    <tr>\n    <td align='right' class='header' valign='top'>\n    <a name='#expand' href='#expand' onclick=\"javascript:ShowHide('files', 'msgfile');\">Show/Hide Files: </td>\n    <td align='left' class='lista'>\n    <div name='files' style='display:none' id='files'>\n        <table class='lista'>\n        <tr>\n        <td align='center' class='header'>" . FILE_NAME . "</td>\n        <td align='center' class='header'>" . SIZE . "</td>\n        </tr>";
    $ffile = fopen($row["url"], "rb");
    $content = fread($ffile, filesize($row["url"]));
    fclose($ffile);
    $content = bencdec::decode($content);
    $numfiles = 0;
    if (isset($content["info"]) && $content["info"]) {
        $thefile = $content["info"];
        if (isset($thefile["length"])) {
            $numfiles++;
            print "\n<tr>\n<td align='left' class='lista'>" . security::html_safe($thefile["name"]) . "</td>\n<td align='right' class='lista'>" . misc::makesize((int) $thefile["length"]) . "</td></tr>\n";
        } elseif (isset($thefile["files"])) {
            foreach ($thefile["files"] as $singlefile) {
                print "\n<tr>\n<td align='left' class='lista'>" . security::html_safe(implode("/", $singlefile["path"])) . "</td>\n<td align='right' class='lista'>" . misc::makesize((int) $singlefile["length"]) . "</td></tr>\n";
                $numfiles++;
            }
        } else {
            print "\n<tr>\n<td colspan='2'>No Data...</td></tr>\n";
            // can't be but...
        }
コード例 #6
0
    $fd = fopen($filepath, "rb");
    $alltorrent = fread($fd, filesize($filepath));
    fclose($fd);
    header("Content-Type: application/x-bittorrent");
    header('Content-Disposition: attachment; filename="' . AddSlashes($f) . '"');
    print $alltorrent;
} else {
    $fd = fopen($filepath, "rb");
    $alltorrent = fread($fd, filesize($filepath));
    //uTorrent v3.x.x fix
    $alltorrent = preg_replace("/file-mediali(.*?)ee(.*?):/i", "file-mediali0ee\$2:", $alltorrent);
    $alltorrent = preg_replace("/file-durationli(.*?)ee(.*?):/i", "file-durationli0ee\$2:", $alltorrent);
    $array = bencdec::decode($alltorrent);
    fclose($fd);
    $array["announce"] = $BASEURL . "/announce.php?pid=" . $pid;
    if (isset($array["announce-list"]) && is_array($array["announce-list"])) {
        for ($i = 0; $i < count($array["announce-list"]); $i++) {
            if (in_array($array["announce-list"][$i][0], $TRACKER_ANNOUNCEURLS)) {
                if (strpos($array["announce-list"][$i][0], "announce.php") === false) {
                    $array["announce-list"][$i][0] = trim(str_replace("/announce", "/" . $pid . "/announce", $array["announce-list"][$i][0]));
                } else {
                    $array["announce-list"][$i][0] = trim(str_replace("/announce.php", "/announce.php?pid=" . $pid . "", $array["announce-list"][$i][0]));
                }
            }
        }
    }
    $alltorrent = bencdec::encode($array);
    header("Content-Type: application/x-bittorrent");
    header('Content-Disposition: attachment; filename="' . AddSlashes($f) . '"');
    print $alltorrent;
}
コード例 #7
0
ファイル: class.bencdec.php プロジェクト: CharlieHD/U-232-V3
 public static function decode($str, $options = 0)
 {
     if (empty($str)) {
         return false;
     }
     self::$bdata_position = 0;
     self::$bdata_depth = 0;
     self::$ext_valid = false;
     self::$bdata_length = strlen($str);
     self::$bdata = $str;
     unset($str);
     if ($options & self::OPTION_EXTENDED_VALIDATION) {
         self::$ext_valid = true;
     }
     $data = self::bdecode();
     if (self::$ext_valid) {
         if (self::$bdata_position < self::$bdata_length) {
             return self::decode_error('Garbage data at end');
         }
     }
     self::$bdata_position = 0;
     self::$bdata_length = 0;
     self::$bdata = '';
     self::$bdata_depth = 0;
     self::$ext_valid = false;
     return $data;
 }