Пример #1
0
 function TDict($fname = '', $fsize = 0)
 {
     if ($fname == '' && $fsize == 0) {
         $this->_dict = null;
         return;
     }
     if ($fname == '' && $fsize != 0) {
         $this->setDict($fsize);
         return;
     }
     $this->_dict = bdec_file($fname, $fsize);
     if (!$this->_dict) {
         $this->ErrorMsg = 'Error decoding file';
     } else {
         $this->ErrorMsg = '';
     }
 }
Пример #2
0
if ($CURUSER['downloadpos'] == "no") {
    permissiondenied();
}
if (!$row || !is_file($fn) || !is_readable($fn)) {
    httperr();
}
if ($row['banned'] == 'yes' && get_user_class() < $seebanned_class) {
    permissiondenied();
}
sql_query("UPDATE torrents SET hits = hits + 1 WHERE id = " . sqlesc($id)) or sqlerr(__FILE__, __LINE__);
require_once "include/benc.php";
if (strlen($CURUSER['passkey']) != 32) {
    $CURUSER['passkey'] = md5($CURUSER['username'] . date("Y-m-d H:i:s") . $CURUSER['passhash']);
    sql_query("UPDATE users SET passkey=" . sqlesc($CURUSER[passkey]) . " WHERE id=" . sqlesc($CURUSER[id]));
}
$dict = bdec_file($fn, $max_torrent_size);
$dict['value']['announce']['value'] = $ssl_torrent . $base_announce_url . "?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']);
/*if ($announce_urls[1] != "") // add multi-tracker
{
	$dict['value']['announce-list']['type'] = "list";
	$dict['value']['announce-list']['value'][0]['type'] = "list";
	$dict['value']['announce-list']['value'][0]['value'][0]["type"] = "string";
	$dict['value']['announce-list']['value'][0]['value'][0]["value"] = $ssl_torrent . $announce_urls[0] . "?passkey=$CURUSER[passkey]";
	$dict['value']['announce-list']['value'][0]['value'][0]["string"] = strlen($dict['value']['announce-list']['value'][0]['value'][0]["value"]).":".$dict['value']['announce-list']['value'][0]['value'][0]["value"];
	$dict['value']['announce-list']['value'][0]['value'][0]["strlen"] = strlen($dict['value']['announce-list']['value'][0]['value'][0]["string"]);
	$dict['value']['announce-list']['value'][0]['string'] = "l".$dict['value']['announce-list']['value'][0]['value'][0]["string"]."e";
	$dict['value']['announce-list']['value'][0]['strlen'] = strlen($dict['value']['announce-list']['value'][0]['string']);
	$dict['value']['announce-list']['value'][1]['type'] = "list";
	$dict['value']['announce-list']['value'][1]['value'][0]["type"] = "string";
Пример #3
0
$tmpname[] = $f2["tmp_name"];
$tmpname[] = $f3["tmp_name"];
$tmpname[] = $f4["tmp_name"];
$tmpname[] = $f5["tmp_name"];
$i = 0;
// i miss my normal for loops
// this is why!
foreach ($tmpname as $value) {
    $shortfname[$i] = $torrent[$i] = $matches[$i];
    if (!is_uploaded_file($value)) {
        bark("Bad filename found on file no #{$i}");
    }
    if (!filesize($value)) {
        bark("Empty file! {$value}");
    }
    $dict[] = bdec_file($value, $max_torrent_size);
    if (!isset($dict[$i])) {
        bark("What the hell did you upload? This is not a bencoded file 1!");
    }
    // I think i can just use $ann[] $dbname[] $info[] and $plen[] without specifying the index $i -- but this should work too
    list($ann[$i], $info[$i]) = dict_check($dict[$i], "announce(string):info");
    list($dname[$i], $plen[$i], $pieces[$i]) = dict_check($info[$i], "name(string):piece length(integer):pieces(string)");
    if (!in_array($ann[$i], $announce_urls, 1)) {
        bark("invalid announce url! in file no #{$i} must be " . $announce_urls[0] . " - Make sure its exactly like that even the port number should be in there like '80'");
    }
    if (strlen($pieces[$i]) % 20 != 0) {
        bark("invalid pieces in file {$i}");
    }
    $totallen = dict_get($info[$i], "length", "integer");
    if (isset($totallen)) {
        $filelist[] = array($dname[$i], $totallen);
Пример #4
0
}
$shortfname = $torrent = $matches[1];
if (!empty($_POST["name"])) {
    $torrent = unesc($_POST["name"]);
}
if ($f['size'] > $max_torrent_size) {
    bark($lang_takeupload['std_torrent_file_too_big'] . number_format($max_torrent_size) . $lang_takeupload['std_remake_torrent_note']);
}
$tmpname = $f["tmp_name"];
if (!is_uploaded_file($tmpname)) {
    bark("eek");
}
if (!filesize($tmpname)) {
    bark($lang_takeupload['std_empty_file']);
}
$dict = bdec_file($tmpname, $max_torrent_size);
if (!isset($dict)) {
    bark($lang_takeupload['std_not_bencoded_file']);
}
function dict_check($d, $s)
{
    global $lang_takeupload;
    if ($d["type"] != "dictionary") {
        bark($lang_takeupload['std_not_a_dictionary']);
    }
    $a = explode(":", $s);
    $dd = $d["value"];
    $ret = array();
    foreach ($a as $k) {
        unset($t);
        if (preg_match('/^(.*)\\((.*)\\)$/', $k, $m)) {
Пример #5
0
    exit;
}
$filePath = "torrents/" . $id . ".torrent";
$sth = $db->prepare("SELECT filename FROM torrents WHERE id = ?");
$sth->bindParam(1, $id, PDO::PARAM_INT);
$sth->execute();
$torrent = $sth->fetch(PDO::FETCH_ASSOC);
if (!$torrent) {
    echo "Torrent not found";
    exit;
}
$sth = $db->prepare("SELECT https FROM users WHERE passkey = ? AND enabled = 'yes'");
$sth->bindParam(1, $passkey, PDO::PARAM_STR);
$sth->execute();
$user = $sth->fetch(PDO::FETCH_ASSOC);
if (!$user) {
    echo "User not found";
    exit;
}
$dict = bdec_file($filePath, filesize($filePath));
$dict['value']['announce']['value'] = "http" . ($user["https"] == 1 ? "s" : "") . "://127.0.0.1:133" . ($user["https"] == 1 ? "8" : "7") . "/tracker.php/{$passkey}/announce";
$dict['value']['announce']['string'] = strlen($dict['value']['announce']['value']) . ":" . $dict['value']['announce']['value'];
$dict['value']['announce']['strlen'] = strlen($dict['value']['announce']['string']);
$dict["value"]["comment"]["type"] = "string";
$dict["value"]["comment"]["value"] = "rartracker";
$dict["value"]["comment"]["strlen"] = strlen(strlen("127.0.0.1") . ":127.0.0.1");
$dict["value"]["comment"]["string"] = strlen("127.0.0.1") . ":127.0.0.1";
unset($dict['value']['announce-list']);
header('Content-Disposition: attachment;filename="' . $torrent['filename'] . '"');
header("Content-Type: application/x-bittorrent");
print benc($dict);
Пример #6
0
    // moddifed logginorreturn by retro//Remember to change the following line to match your server
    print "<html><h1>Not Found</h1><p>The requested URL /{$_SERVER['PHP_SELF']} was not found on this server.</p><hr /><address>Apache/1.1.11 " . $SITENAME . " Server at " . $_SERVER['SERVER_NAME'] . " Port 80</address></body></html>\n";
    die;
}
if (!preg_match(':^/(\\d{1,10})/(.+)\\.torrent$:', $_SERVER["PATH_INFO"], $matches)) {
    httperr();
}
$id = 0 + $matches[1];
if (!$id) {
    httperr();
}
$res = mysql_query("SELECT name FROM torrents WHERE id = {$id}") or sqlerr(__FILE__, __LINE__);
$row = mysql_fetch_assoc($res);
$fn = "{$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 (strlen($CURUSER['passkey']) != 32) {
    $CURUSER['passkey'] = md5($CURUSER['username'] . get_date_time() . $CURUSER['passhash']);
    mysql_query("UPDATE users SET passkey='{$CURUSER['passkey']}' WHERE id={$CURUSER['id']}");
}
$dict = bdec_file($fn, 1024 * 1024);
$dict['value']['announce']['value'] = "{$announce_urls['0']}";
$dict['value']['announce']['string'] = strlen($dict['value']['announce']['value']) . ":" . $dict['value']['announce']['value'];
$dict['value']['announce']['strlen'] = strlen($dict['value']['announce']['string']);
$dict['value']['created by'] = bdec(benc_str("" . $CURUSER['username'] . ""));
//header('Content-Disposition: attachment; filename="'.$torrent['filename'].'"');
header("Content-Type: application/x-bittorrent");
print benc($dict);
Пример #7
0
$ids = array();
$tmpname[] = $f1["tmp_name"];
$tmpname[] = $f2["tmp_name"];
$tmpname[] = $f3["tmp_name"];
$tmpname[] = $f4["tmp_name"];
$tmpname[] = $f5["tmp_name"];
$i = 0;
foreach ($tmpname as $value) {
    $shortfname[$i] = $torrent[$i] = $matches[$i];
    if (!is_uploaded_file($value)) {
        stderr("Opps", "Bad filename found on file no #{$i}");
    }
    if (!filesize($value)) {
        stderr("Oops", "Empty file! {$value}");
    }
    $dict[] = bdec_file($value, $INSTALLER09['max_torrent_size']);
    if (!isset($dict[$i])) {
        stderr("Oops", "What the hell did you upload? This is not a bencoded file 1!");
    }
    list($ann[$i], $info[$i]) = dict_check($dict[$i], "announce(string):info");
    list($dname[$i], $plen[$i], $pieces[$i]) = dict_check($info[$i], "name(string):piece length(integer):pieces(string)");
    if (!in_array($ann[$i], $INSTALLER09['announce_urls'], 1)) {
        stderr("Oops", "invalid announce url! in file no #{$i} must be {$INSTALLER09['announce_urls'][0]} - Make sure its exactly like that even the port number should be in there like '80'");
    }
    if (strlen($pieces[$i]) % 20 != 0) {
        stderr("Oops", "invalid pieces in file {$i}");
    }
    $totallen = dict_get($info[$i], "length", "integer");
    if (isset($totallen)) {
        $filelist[] = array($dname[$i], $totallen);
        $type = "single";
Пример #8
0
 public function download($id)
 {
     $torrent = $this->get($id);
     include 'benc.php';
     $filepath = $this->torrentDir . $torrent["id"] . ".torrent";
     if (!file_exists($filepath)) {
         throw new Exception('Torrentfilen saknas.');
     }
     if ($this->user->getHttps()) {
         $announce = Helper::$trackerUrlSsl . "/tracker.php/" . $this->user->getPasskey() . "/announce";
     } else {
         $announce = Helper::$trackerUrl . "/tracker.php/" . $this->user->getPasskey() . "/announce";
     }
     $dict = bdec_file($filepath, filesize($filepath));
     $dict['value']['announce']['value'] = $announce;
     $dict['value']['announce']['string'] = strlen($dict['value']['announce']['value']) . ":" . $dict['value']['announce']['value'];
     $dict['value']['announce']['strlen'] = strlen($dict['value']['announce']['string']);
     $dict["value"]["comment"]["type"] = "string";
     $dict["value"]["comment"]["value"] = Helper::$siteName;
     $dict["value"]["comment"]["strlen"] = strlen(strlen(Helper::$siteName) . ":" . Helper::$siteName);
     $dict["value"]["comment"]["string"] = strlen(Helper::$siteName) . ":" . Helper::$siteName;
     unset($dict['value']['announce-list']);
     header('Content-Disposition: attachment;filename="' . $torrent['filename'] . '"');
     header("Content-Type: application/x-bittorrent");
     print benc($dict);
     exit;
 }
Пример #9
0
 public function download($id, $passkey = null)
 {
     $useHttps = null;
     if ($passkey) {
         $sth = $this->db->prepare("SELECT https FROM users WHERE passkey = ? AND enabled = 'yes'");
         $sth->bindParam(1, $passkey, PDO::PARAM_STR);
         $sth->execute();
         $user = $sth->fetch(PDO::FETCH_ASSOC);
         if (!$user) {
             throw new Exception(L::get("USER_NOT_EXIST"), 404);
         }
         $useHttps = $user["https"] == 1;
     } else {
         $useHttps = $this->user->getHttps();
         $passkey = $this->user->getPasskey();
     }
     $torrent = $this->get($id);
     include 'benc.php';
     $filepath = $this->torrentDir . $torrent["id"] . ".torrent";
     if (!file_exists($filepath)) {
         throw new Exception(L::get("TORRENT_NOT_FOUND"), 404);
     }
     if ($useHttps) {
         $announce = Config::TRACKER_URL_SSL . "/tracker.php/" . $passkey . "/announce";
     } else {
         $announce = Config::TRACKER_URL . "/tracker.php/" . $passkey . "/announce";
     }
     $dict = bdec_file($filepath, filesize($filepath));
     $dict['value']['announce']['value'] = $announce;
     $dict['value']['announce']['string'] = strlen($dict['value']['announce']['value']) . ":" . $dict['value']['announce']['value'];
     $dict['value']['announce']['strlen'] = strlen($dict['value']['announce']['string']);
     $dict["value"]["comment"]["type"] = "string";
     $dict["value"]["comment"]["value"] = Config::SITE_NAME;
     $dict["value"]["comment"]["strlen"] = strlen(strlen(Config::SITE_NAME) . ":" . Config::SITE_NAME);
     $dict["value"]["comment"]["string"] = strlen(Config::SITE_NAME) . ":" . Config::SITE_NAME;
     unset($dict['value']['announce-list']);
     header('Content-Disposition: attachment;filename="' . $torrent['filename'] . '"');
     header("Content-Type: application/x-bittorrent");
     print benc($dict);
     exit;
 }
Пример #10
0
 if (isset($_FILES['nfo']) && !empty($_FILES['nfo']['name'])) {
     $nfofile = $_FILES['nfo'];
     if ($nfofile['size'] == 0) {
         throw new Exception("NFO file size to small.");
     }
     if ($nfofile['size'] > 65535) {
         throw new Exception("NFO file size to big.");
     }
     $nfofilename = $nfofile['tmp_name'];
     if (@(!is_uploaded_file($nfofilename))) {
         throw new Exception("NFO file upload failed.");
     }
     $nfo = str_replace("\r\r\n", "\r\n", @file_get_contents($nfofilename));
 }
 $nfo = nfostrip($nfo);
 $dict = bdec_file($tmpname, filesize($tmpname));
 if (!isset($dict)) {
     throw new Exception("torrent file not benc coded");
 }
 list($ann, $info) = dict_check($dict, "announce(string):info");
 $tmaker = isset($dict['value']['created by']) && !empty($dict['value']['created by']['value']) ? $dict['value']['created by']['value'] : "Unknown";
 list($dname, $plen, $pieces) = dict_check($info, "name(string):piece length(integer):pieces(string)");
 if (strlen($pieces) % 20 != 0) {
     throw new Exception("somthing bad happend. and we dont know what.");
 }
 $filelist = array();
 $totallen = dict_get($info, "length", "integer");
 if (isset($totallen)) {
     $filelist[] = array($dname, $totallen);
     $type = "single";
 } else {
Пример #11
0
if (!$id) {
    httperr();
}
$res = mysql_query("SELECT name, filename FROM torrents WHERE id = {$id}") or sqlerr(__FILE__, __LINE__);
$row = mysql_fetch_assoc($res);
$fn = "{$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($fn, filesize($fn));
$dict['value']['announce']['value'] = "{$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']);
//Added support for announce-list (if set by user's uploaded torrent)
//if(isset($dict['value']['announce-list']['value'][0]['value'][0]['value'])){
//$dict['value']['announce-list']['value'][0]['value'][0]['value'] = $dict['value']['announce']['value'];
//$dict['value']['announce-list']['value'][0]['value'][0]['string'] = strlen($dict['value']['announce-list']['value'][0]['value'][0]['value']).":".$dict['value']['announce-list']['value'][0]['value'][0]['value'];
//$dict['value']['announce-list']['value'][0]['value'][0]['strlen'] = strlen($dict['value']['announce-list']['value'][0]['value'][0]['string']);
//}
//Added support for using openbittorrent tracker
$announce_list = array(array('value' => $dict['value']['announce']['value'], 'type' => 'string'));
$announce_list2 = array(array('value' => $announce_urls[1], 'type' => 'string'));
#two trackers
#$dict['value']['announce-list']['value'] = array( array( 'value' => $announce_list, 'type' => 'list' ),array( 'value' => $announce_list2, 'type' => 'list' ));
#one tracker
Пример #12
0
}
if (!preg_match('/^(.+)\\.torrent$/si', $fname, $matches)) {
    stderr($lang['takeupload_failed'], $lang['takeupload_not_torrent']);
}
$shortfname = $torrent = $matches[1];
if (!empty($_POST["name"])) {
    $torrent = unesc($_POST["name"]);
}
$tmpname = $f["tmp_name"];
if (!is_uploaded_file($tmpname)) {
    stderr($lang['takeupload_failed'], $lang['takeupload_eek']);
}
if (!filesize($tmpname)) {
    stderr($lang['takeupload_failed'], $lang['takeupload_no_file']);
}
$dict = bdec_file($tmpname, $INSTALLER09['max_torrent_size']);
if (!isset($dict)) {
    stderr($lang['takeupload_failed'], $lang['takeupload_not_benc']);
}
function dict_check($d, $s)
{
    global $lang;
    if ($d["type"] != "dictionary") {
        stderr($lang['takeupload_failed'], $lang['takeupload_not_dict']);
    }
    $a = explode(":", $s);
    $dd = $d["value"];
    $ret = array();
    $t = '';
    foreach ($a as $k) {
        unset($t);
Пример #13
0
}
if (!preg_match('/^(.+)\\.torrent$/si', $fname, $matches)) {
    stderr($lang['takeupload_failed'], $lang['takeupload_not_torrent']);
}
$shortfname = $torrent = $matches[1];
if (!empty($_POST["name"])) {
    $torrent = unesc($_POST["name"]);
}
$tmpname = $f["tmp_name"];
if (!is_uploaded_file($tmpname)) {
    stderr($lang['takeupload_failed'], $lang['takeupload_eek']);
}
if (!filesize($tmpname)) {
    stderr($lang['takeupload_failed'], $lang['takeupload_no_file']);
}
$dict = bdec_file($tmpname, $TBDEV['max_torrent_size']);
if (!isset($dict)) {
    stderr($lang['takeupload_failed'], $lang['takeupload_not_benc']);
}
function dict_check($d, $s)
{
    if ($d["type"] != "dictionary") {
        stderr($lang['takeupload_failed'], $lang['takeupload_not_dict']);
    }
    $a = explode(":", $s);
    $dd = $d["value"];
    $ret = array();
    $t = '';
    foreach ($a as $k) {
        unset($t);
        if (preg_match('/^(.*)\\((.*)\\)$/', $k, $m)) {
Пример #14
0
function videoname($id)
{
    $i = 0;
    require_once "include/benc.php";
    require_once "include/bittorrent.php";
    function bark($msg)
    {
        global $lang_takeupload;
        genbark($msg, $lang_takeupload['std_upload_failed']);
        die;
    }
    function dict_get($d, $k, $t)
    {
        global $lang_takeupload;
        if ($d["type"] != "dictionary") {
            bark($lang_takeupload['std_not_a_dictionary']);
        }
        $dd = $d["value"];
        if (!isset($dd[$k])) {
            return;
        }
        $v = $dd[$k];
        if ($v["type"] != $t) {
            bark($lang_takeupload['std_invalid_dictionary_entry_type']);
        }
        return $v["value"];
    }
    function dict_check($d, $s)
    {
        global $lang_takeupload;
        if ($d["type"] != "dictionary") {
            bark($lang_takeupload['std_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($lang_takeupload['std_dictionary_is_missing_key']);
            }
            if (isset($t)) {
                if ($dd[$k]["type"] != $t) {
                    bark($lang_takeupload['std_invalid_entry_in_dictionary']);
                }
                $ret[] = $dd[$k]["value"];
            } else {
                $ret[] = $dd[$k];
            }
        }
        return $ret;
    }
    $filename = "/var/www/nexusphp/torrents/" . $id . ".torrent";
    echo $filename;
    if (file_exists($filename) == 0) {
        echo "没发现种子";
    } else {
        $dict = bdec_file($filename, $max_torrent_size);
        list($ann, $info) = dict_check($dict, "announce(string):info");
        list($dname, $plen, $pieces) = dict_check($info, "name(string):piece length(integer):pieces(string)");
        $filelist = array();
        $totallen = dict_get($info, "length", "integer");
        if (isset($totallen)) {
            $filelist[] = array($dname, $totallen);
            $type = "single";
            //echo $dname;
            $ffa4 = $dname;
            $ffa5[] = $dname;
            //echo '<br>';
        } else {
            $flist = dict_get($info, "files", "list");
            if (!isset($flist)) {
                bark($lang_takeupload['std_missing_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($lang_takeupload['std_filename_errors']);
                    }
                    $ffa[] = $ffe["value"];
                    //  echo $ffe["value"];
                    //echo '<br>';
                }
                if (!count($ffa)) {
                    bark($lang_takeupload['std_filename_errors']);
                }
                //echo $ffa[0];
                foreach ($ffa as $ffa1) {
                    $ffa2 = explode('.', $ffa1);
                    $numm = count($ffa2);
                    $ffa3 = $ffa2[$numm - 1];
                    $array1 = array('mp4', 'wma', 'avi', 'mkv', '3gp', 'mpg', 'vob', 'flv', 'swf', 'mov', 'rmvb');
                    if (in_array("{$ffa3}", $array1)) {
                        $ffa4 = $ffa1;
                        $ffa5[$i] = $ffa1;
                        $i++;
                        //echo '<br>';
                    }
                }
            }
            $type = "multi";
        }
        $str = implode("|", $ffa5);
        echo $str;
        echo "a";
    }
    $con = mysql_connect("localhost", "root", "buptnic");
    if (!$con) {
        die('Could not connect: ' . mysql_error());
    }
    mysql_query("set names utf8");
    mysql_select_db("nexusphp", $con);
    $sql = "update torrents set videoname='{$str}' where id='{$id}'";
    $result = mysql_query($sql);
    //mysql_close($con);
    ///////
    $i = 0;
    //$arr=array();
    //mysql_select_db("nexusphp", $con);
    $sql = "select * from torrents where id='{$id}'";
    $result = mysql_query($sql);
    while ($row = mysql_fetch_array($result)) {
        $array[$i] = $row['id'];
        $arr[$i] = $row['name'];
        $arra[$i] = $row['videoname'];
        echo $arra[$i];
        //$i++;
    }
    ///////////
    mysql_select_db("ekucms", $con);
    for ($j = 0; $j <= $i; $j++) {
        $a = date("Y-m-d H:i:s");
        $b = strtotime($a);
        $sql = "insert into eku122x_video (nexusphp,title,playurl,vodplay,videoname,addtime,cid) VALUES ('{$array[$j]}','{$arr[$j]}','第一集','v6','{$arra[$j]}','{$b}','9')";
        $result = mysql_query($sql);
    }
    mysql_close($con);
    //---------------------------------------------------
}
 function download($id)
 {
     $this->autoRender = false;
     $this->autoLayout = false;
     Configure::write('debug', '0');
     app::import('vendor', 'ztracker/dict');
     app::import('vendor', 'ztracker/global');
     $tfile = "../torrents/{$id}.torrent";
     $torrent = $this->Torrent->find(array('id' => $id));
     $user = $this->User->find(array('username' => $this->ZTAuth->user('username')));
     if (strlen($user['User']['passkey']) != 40) {
         $user['User']['passkey'] = sha1($user['User']['username'] . get_date_time() . $user['User']['username']);
         $this->User->save($user['User']);
     }
     $passkey = $user['User']['passkey'];
     $dict = bdec_file($tfile, 1024 * 1024);
     $dict['value']['announce']['value'] = $this->webroot . "announce.php?passkey={$passkey}";
     $dict['value']['announce']['string'] = strlen($dict['value']['announce']['value']) . ":" . $dict['value']['announce']['value'];
     $dict['value']['announce']['strlen'] = strlen($dict['value']['announce']['string']);
     header("Expires: Tue, 1 Jan 2000 00:00:00 GMT");
     header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
     header("Cache-Control: no-store, no-cache, must-revalidate");
     header("Cache-Control: post-check=0, pre-check=0", false);
     header("Pragma: no-cache");
     header("X-Powered-by: ZTracker (c) ZTSoft Research Lab - http://bymep.com");
     header("Accept-Ranges: bytes");
     header("Connection: close");
     header("Content-Transfer-Encoding: binary");
     header("Content-Type: application/x-bittorrent");
     header("Content-Disposition: attachment; filename=\"" . $torrent['Torrent']['filename'] . "\"");
     print benc($dict);
     exit;
 }