当前位置: 首页>>代码示例>>PHP>>正文


PHP bdec函数代码示例

本文整理汇总了PHP中bdec函数的典型用法代码示例。如果您正苦于以下问题:PHP bdec函数的具体用法?PHP bdec怎么用?PHP bdec使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了bdec函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: recv_bvalue

function recv_bvalue($s)
{
    $v = bdec(recv_string($s));
    if ($v['value']['failure reason']['value']) {
        die($v['value']['failure reason']['value']);
    }
    return $v;
}
开发者ID:latik,项目名称:xbt,代码行数:8,代码来源:common.php

示例2: setUser

 function setUser($username, $userid)
 {
     $this->dict->hashSetter('[\'value\'][\'created by\']', bdec(benc_str("{$username}")));
     $this->dict->hashSetter('[\'value\'][\'publisher\']', bdec(benc_str("{$username}")));
     $this->dict->hashSetter('[\'value\'][\'publisher.utf-8\']', bdec(benc_str("username")));
     $this->dict->hashSetter('[\'value\'][\'publisher-url\']', bdec(benc_str(DEFAULTBASEURL . "/users/view/{$userid}")));
     $this->dict->hashSetter('[\'value\'][\'publisher-url.utf-8\']', bdec(benc_str(DEFAULTBASEURL . "/users/view/{$userid}")));
 }
开发者ID:BGCX262,项目名称:ztrackerengine-svn-to-git,代码行数:8,代码来源:torrentfile.php

示例3: bdec

function bdec($str, &$_len = 0)
{
    $type = substr($str, 0, 1);
    if (is_numeric($type)) {
        $type = 's';
    }
    switch ($type) {
        case 'i':
            //integer
            $p = strpos($str, 'e');
            $_len = $p + 1;
            //lenght of bencoded data
            return intval(substr($str, 1, $p - 1));
            break;
        case 's':
            //string
            $p = strpos($str, ':');
            $len = substr($str, 0, $p);
            $_len = $len + $p + 1;
            //lenght of bencoded data
            return substr($str, $p + 1, $len);
            break;
        case 'l':
            //list
            $l = 1;
            $ret_array = array();
            while (substr($str, $l, 1) != 'e') {
                $ret_array[] = bdec(substr($str, $l), $len);
                $l += $len;
            }
            $_len = $l + 1;
            //lenght of bencoded data
            return $ret_array;
            break;
        case 'd':
            //dictionary
            $l = 1;
            $ret_array = array();
            while (substr($str, $l, 1) != 'e') {
                $var = bdec(substr($str, $l), $len);
                $l += $len;
                $ret_array[$var] = bdec(substr($str, $l), $len);
                $l += $len;
            }
            $_len = $l + 1;
            //lenght of bencoded data
            return $ret_array;
            break;
    }
}
开发者ID:dvgamer,项目名称:DvGamer-PC,代码行数:50,代码来源:torrent.dbcode.php

示例4: bdec_dict

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);
}
开发者ID:skygunner,项目名称:ekucms,代码行数:37,代码来源:benc.php

示例5: bark

             bark("filename error");
         }
         $ffe = implode("/", $ffa);
         $filelist[] = array($ffe, $ll);
     }
     $type = "multi";
 }
 /* Private Tracker mod code goes below */
 $info[$i]['value']['source']['type'] = "string";
 $info[$i]['value']['source']['value'] = $SITENAME;
 $info[$i]['value']['source']['strlen'] = strlen($info[$i]['value']['source']['value']);
 $info[$i]['value']['private']['type'] = "integer";
 $info[$i]['value']['private']['value'] = 1;
 $dict[$i]['value']['info'] = $info[$i];
 $dict[$i] = benc($dict[$i]);
 $dict[$i] = bdec($dict[$i]);
 list($ann[$i], $info[$i]) = dict_check($dict[$i], "announce(string):info");
 unset($dict['value']['created by']);
 $infohash[$i] = pack("H*", sha1($info[$i]["string"]));
 /* ...... end of Private Tracker mod */
 $torrent[$i] = str_replace("_", " ", $torrent[$i]);
 $torrent[$i] = str_replace("'", " ", $torrent[$i]);
 $torrent[$i] = str_replace("\"", " ", $torrent[$i]);
 $torrent[$i] = str_replace(",", " ", $torrent[$i]);
 $nfo[$i] = sqlesc(str_replace("\r\r\n", "\r\n", @file_get_contents($nfofilename[$i])));
 $first = $shortfname[$i][1];
 $second = $dname[$i];
 $third = $torrent[$i][1];
 $ret = mysql_query("INSERT INTO torrents (search_text, filename, owner, visible, info_hash, name, size, numfiles, type, descr, ori_descr, category, save_as, added, last_action, nfo) VALUES (" . implode(",", array_map("sqlesc", array(searchfield("{$first} {$second} {$third}"), $fname[$i], $CURUSER["id"], "no", $infohash[$i], $torrent[$i][1], $totallen, count($filelist[$i]), $type, $descr, $descr, $cat[$i], $dname[$i]))) . ", '" . get_date_time() . "', '" . get_date_time() . "', {$nfo[$i]})");
 // //////new torrent upload detail sent to shoutbox//////////
 if ($CURUSER["anonymous"] == 'yes') {
开发者ID:ZenoX2012,项目名称:CyBerFuN-CoDeX,代码行数:31,代码来源:takemultiupload.php

示例6: array

        $filelist[] = array($ffe, $ll);
    }
    $type = "multi";
}
$dict['value']['announce'] = bdec(benc_str(get_protocol_prefix() . $announce_urls[0]));
// change announce url to local
$dict['value']['info']['value']['private'] = bdec('i1e');
// add private tracker flag
//The following line requires uploader to re-download torrents after uploading
//even the torrent is set as private and with uploader's passkey in it.
$dict['value']['info']['value']['source'] = bdec(benc_str("[{$BASEURL}] {$SITENAME}"));
unset($dict['value']['announce-list']);
// remove multi-tracker capability
unset($dict['value']['nodes']);
// remove cached peers (Bitcomet & Azareus)
$dict = bdec(benc($dict));
// double up on the becoding solves the occassional misgenerated infohash
list($ann, $info) = dict_check($dict, "announce(string):info");
$infohash = pack("H*", sha1($info["string"]));
function hex_esc2($matches)
{
    return sprintf("%02x", ord($matches[0]));
}
//die(phpinfo());
//die("magic:" . get_magic_quotes_gpc());
//die("\\' pos:" . strpos($infohash,"\\") . ", after sqlesc:" . (strpos(sqlesc($infohash),"\\") == false ? "gone" : strpos(sqlesc($infohash),"\\")));
//die(preg_replace_callback('/./s', "hex_esc2", $infohash));
// ------------- start: check upload authority ------------------//
$allowtorrents = user_can_upload("torrents");
$allowspecial = user_can_upload("music");
$catmod = get_single_value("categories", "mode", "WHERE id=" . sqlesc($catid));
开发者ID:CptTZ,项目名称:NexusPHP-1,代码行数:31,代码来源:takeupload.php

示例7: bdec_list

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);
}
开发者ID:n4v,项目名称:openTracker,代码行数:27,代码来源:init.php

示例8: httperr

    // 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);
开发者ID:ZenoX2012,项目名称:CyBerFuN-CoDeX,代码行数:31,代码来源:downloaddump.php

示例9: unesc

$recommended = unesc($_POST['recommended']);
$tube = unesc($_POST['tube']);
$url = unesc($_POST['url']);
$dict['value']['announce'] = bdec(benc_str($announce_urls[0]));
// change announce url to local
$dict['value']['info']['value']['private'] = bdec('i1e');
// add private tracker flag
$dict['value']['info']['value']['source'] = bdec(benc_str("[{$DEFAULTBASEURL}] {$SITENAME}"));
// add link for bitcomet users
unset($dict['value']['announce-list']);
// remove multi-tracker capability
unset($dict['value']['nodes']);
// remove cached peers (Bitcomet & Azareus)
$dict = bdec(benc($dict));
// double up on the becoding solves the occassional misgenerated infohash
$dict['value']['comment'] = bdec(benc_str("In using this torrent you are bound by the '{$SITENAME}' Confidentiality Agreement By Law"));
// change torrent comment
list($ann, $info) = dict_check($dict, "announce(string):info");
unset($dict['value']['created by']);
//Null the created_by field///
$infohash = pack("H*", sha1($info["string"]));
$uclass = $CURUSER["class"];
// Replace punctuation characters with spaces
$torrent = str_replace("_", " ", $torrent);
// /////////pretime////////
/*
$pre = getpre($torrent,1);
$timestamp = strtotime($pre);
$tid = time();
if (empty($pre)) {
$predif = "N/A";
开发者ID:ZenoX2012,项目名称:CyBerFuN-CoDeX,代码行数:31,代码来源:takeupload.php

示例10: unset

// remove cached peers (Bitcomet & Azareus)
unset($dict['value']['info']['value']['crc32']);
// remove crc32
unset($dict['value']['info']['value']['ed2k']);
// remove ed2k
unset($dict['value']['info']['value']['md5sum']);
// remove md5sum
unset($dict['value']['info']['value']['sha1']);
// remove sha1
unset($dict['value']['info']['value']['tiger']);
// remove tiger
unset($dict['value']['azureus_properties']);
// remove azureus properties
$dict = bdec(benc($dict));
// double up on the becoding solves the occassional misgenerated infohash
$dict['value']['comment'] = bdec(benc_str("Torrent created for SceneBits"));
// change torrent comment
list($ann, $info) = dict_check($dict, "announce(string):info");
#End of Private Tracker Patch
$infohash = pack("H*", sha1($info["string"]));
// Replace punctuation characters with spaces
$pretime = 0 + @file_get_contents("http://xxxxx/abcd.php?name=" . trim($torrent));
$poster = isset($_POST['poster']) ? unesc($_POST['poster']) : "";
//$torrent = str_replace("_", " ", $torrent);
$anonymous = 'yes';
$ret = mysql_query("INSERT INTO torrents (search_text, filename, owner, visible, scene, freeleech, url, anonymous, vip, info_hash, poster, name, size, numfiles, type, descr, ori_descr, category, save_as, added, last_action, nfo, pretime) VALUES (" . implode(",", array_map("sqlesc", array(searchfield("{$shortfname} {$dname} {$torrent}"), $fname, $CURUSER["id"], "no", $scene, $freeleech, $url, $anonymous, $vip, $infohash, $poster, $torrent, $totallen, count($filelist), $type, $descr, $descr, 0 + $_POST["type"], $dname))) . ", '" . get_date_time() . "', '" . get_date_time() . "', {$nfo}, '" . $pretime . "')");
if (!$ret) {
    if (mysql_errno() == 1062) {
        bark("torrent already uploaded!");
    }
    bark("mysql puked: " . mysql_error());
开发者ID:scriptzteam,项目名称:SCENE-SCRiPTS,代码行数:31,代码来源:takeup-bot.php

示例11: upload

 public function upload($uploaded_file, $post)
 {
     if ($this->user->isUploadBanned()) {
         throw new Exception("Du är bannad ifrån att kunna ladda upp torrents.", 401);
     }
     $max_torrent_size = 10000000;
     ini_set("upload_max_filesize", $max_torrent_size);
     include 'benc.php';
     if ($post["category"] < 1 || $post["category"] > 12) {
         throw new Exception('Ogiltig kategori.');
     }
     if (!preg_match("/^\\d+\$/", $post["reqid"])) {
         throw new Exception('Ogiltig sektion.');
     }
     if (!preg_match("/\\.torrent\$/", $uploaded_file["name"], $match)) {
         throw new Exception('Ingen torrent-fil.');
     }
     if (!is_uploaded_file($uploaded_file["tmp_name"])) {
         throw new Exception('Filen kunde inte laddas upp.');
     }
     if (!filesize($uploaded_file["tmp_name"])) {
         throw new Exception('Filen verkar vara tom.');
     }
     if ($post["category"] == 8 && $post["reqid"] == 0 && ($post["channel"] == 0 || $post["program"] == 0)) {
         throw new Exception('Du måste välja kanal och program för ny Svensk TV.');
     }
     if ($post["reqid"] > 2) {
         $request = $this->requests->get($post["reqid"]);
         if ($this->user->getId() == $request["user"]["id"]) {
             throw new Exception("Du får inte fylla din egna request", 400);
         }
         if ($request["filled"] == 1) {
             throw new Exception("Requesten är redan fylld.", 400);
         }
     }
     $name = preg_replace("/\\.torrent\$/", '', $uploaded_file["name"]);
     $category = $post["category"];
     $reqid = $post["reqid"];
     $anonymousUpload = $post["anonymousUpload"];
     $nfo = $post["nfo"];
     $imdbId = $post["imdbId"];
     $p2p = $post["p2p"];
     $freeleech = 0;
     $stereoscopic = 0;
     $swesub = 0;
     if (in_array($category, array(1, 2, 3, 10, 11))) {
         $swesub = 1;
     }
     if ($post["swesub"] == 1 && in_array($category, array(4, 5, 6, 7))) {
         $swesub = 1;
     }
     /* SWE-TV */
     $tvProgramId = $post["program"] ?: 0;
     $tvChannel = $post["channel"] ?: 0;
     $tvProgram = '';
     $tvEpisode = '';
     $tvInfo = '';
     $tvTime = 0;
     if ($category == 8 && $tvProgramId > 0 && $tvChannel > 0) {
         /* Manual entered program */
         if ($tvProgramId == 1) {
             $tvProgram = $post["programTitle"];
             $tvTime = strtotime($post["programDate"]);
             if (strlen($tvProgram) < 2) {
                 throw new Exception('Programnamnet för kort.');
             }
             $tvProgramId = 2;
         } else {
             $sweTv = $this->sweTv->getProgram($tvProgramId);
             if (!$sweTv) {
                 throw new Exception('Ogiltigt TV-program valt.');
             }
             $tvProgram = $sweTv["program"];
             $tvEpisode = $sweTv["episod"];
             $tvInfo = $sweTv["info"];
             $tvTime = $sweTv["datum"];
         }
     }
     if ($this->user->getClass() < User::CLASS_UPLOADER && $reqid == 0) {
         throw new Exception('Bara uppladdare kan ladda upp på nytt.');
     }
     $sth = $this->db->prepare("SELECT COUNT(*) FROM torrents WHERE name = ?");
     $sth->execute(array($name));
     $arr = $sth->fetch();
     if ($arr[0] == 1) {
         throw new Exception('Dublett. Releasen finns redan på sidan.');
     }
     $sth = $this->db->prepare("SELECT COUNT(*) FROM packfiles WHERE filename = ?");
     $sth->execute(array($name));
     $arr = $sth->fetch();
     if ($arr[0] == 1) {
         throw new Exception('Dublett. Releasen finns redan inuti ett pack.');
     }
     $sth = $this->db->prepare("SELECT comment FROM banned WHERE namn = ?");
     $sth->execute(array($name));
     while ($arr = $sth->fetch(PDO::FETCH_ASSOC)) {
         throw new Exception('Releasen är bannad med anledning: ' . $arr["comment"]);
     }
     $dict = bdec_file($uploaded_file["tmp_name"], $max_torrent_size);
     if (!isset($dict)) {
//.........这里部分代码省略.........
开发者ID:lordgabber,项目名称:rartracker,代码行数:101,代码来源:Torrent.php

示例12: upload


//.........这里部分代码省略.........
             }
             $tvProgramId = 2;
         } else {
             $sweTv = $this->sweTv->getProgram($tvProgramId);
             if (!$sweTv) {
                 throw new Exception(L::get("TORRENT_TV_PROGRAM_INVALID"));
             }
             $tvProgram = $sweTv["program"];
             $tvEpisode = $sweTv["episod"];
             $tvInfo = $sweTv["info"];
             $tvTime = $sweTv["datum"];
         }
     }
     if ($this->user->getClass() < User::CLASS_UPLOADER && $section == 'new') {
         throw new Exception(L::get("TORRENT_UPLOADER_REQUIRED_NEW"));
     }
     $sth = $this->db->prepare("SELECT COUNT(*) FROM torrents WHERE name = ?");
     $sth->execute(array($name));
     $arr = $sth->fetch();
     if ($arr[0] == 1) {
         throw new Exception(L::get("TORRENT_CONFLICT"), 409);
     }
     $sth = $this->db->prepare("SELECT COUNT(*) FROM packfiles WHERE filename = ?");
     $sth->execute(array($name));
     $arr = $sth->fetch();
     if ($arr[0] == 1) {
         throw new Exception(L::get("TORRENT_CONFLICT_IN_PACK"), 409);
     }
     $sth = $this->db->prepare("SELECT comment FROM banned WHERE namn = ?");
     $sth->execute(array($name));
     while ($arr = $sth->fetch(PDO::FETCH_ASSOC)) {
         throw new Exception(L::get("TORRENT_BANNED", [$arr["comment"]]));
     }
     $dict = bdec_file($uploaded_file["tmp_name"], $max_torrent_size);
     if (!isset($dict)) {
         throw new Exception(L::get("TORRENT_FILE_ERROR"));
     }
     function dict_check($d, $s)
     {
         if ($d["type"] != "dictionary") {
             throw new Exception(L::get("TORRENT_INVLID_FILE"));
         }
         $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($t)) {
                 if ($dd[$k]["type"] != $t) {
                     throw new Exception(L::get("TORRENT_MISSING_ANNOUNCE_URL"));
                 }
                 $ret[] = $dd[$k]["value"];
             } else {
                 $ret[] = $dd[$k];
             }
         }
         return $ret;
     }
     function dict_get($d, $k, $t)
     {
         if ($d["type"] != "dictionary") {
             throw new Exception(L::get("TORRENT_FILE_ERROR"));
开发者ID:swetorrentking,项目名称:rartracker,代码行数:67,代码来源:Torrent.php

示例13: bdec_list

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);
}
开发者ID:latik,项目名称:xbt,代码行数:27,代码来源:benc.php

示例14: doubleUp

 function doubleUp()
 {
     $this->_dict = bdec(benc($this->_dict));
 }
开发者ID:BGCX262,项目名称:ztrackerengine-svn-to-git,代码行数:4,代码来源:dict.php

示例15: bark

$v = $dd[$k];
if ($v["type"] != $t)
bark("ógild tegund orðabókarfærslu");
return $v["value"];
}

// This section creates the additonal dictionary entries
$dict["value"]["info"]["value"]["private"]["type"] = "integer";
$dict["value"]["info"]["value"]["private"]["value"] = 1;
$dict["value"]["info"]["value"]["source"]["type"] = "string";
$dict["value"]["info"]["value"]["source"]["value"] = "Istorrent";
$dict["value"]["info"]["value"]["source"]["strlen"] = strlen($dict["value"]["info"]["value"]["source"]["value"]);

// This bencodes and bdecodes again - necessary...
$fn = benc($dict);
$dict = bdec($fn);

list($ann, $info) = dict_check($dict, "announce(string):info");
list($dname, $plen, $pieces) = dict_check($info, "name(string):piece length(integer):pieces(string)");

if (!in_array($ann, $announce_urls, 1))
bark("Lokað er á torrent frá öðrum síðum, búið til ný torrent með tilkynningarslóðinni " . $announce_urls[0] . ". Tilkynningarslóðin sem 
stendur í torrent skránni sem þú sendir er " . $ann . ".");

if (strlen($pieces) % 20 != 0)
bark("invalid pieces");

$filelist = array();
$totallen = dict_get($info, "length", "integer");
if (isset($totallen)) {
$filelist[] = array($dname, $totallen);
开发者ID:herrag33k,项目名称:TomTorrent,代码行数:31,代码来源:takeupload.php


注:本文中的bdec函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。