Пример #1
0
 function getTime($keyconnexion, $idtorrentfilm)
 {
     \model\simple\Utilisateur::authentificationDistante($keyconnexion);
     if (!\config\Conf::$user["user"]) {
         throw new \Exception("Non User");
     }
     $tf = \model\mysql\Torrentserie::getTorrentSerieParId($idtorrentfilm);
     $tf->mediainfo = json_decode($tf->mediainfo);
     if (is_null($tf)) {
         throw new \Exception("Id incorrect");
     }
     if ($tf->fini === "0") {
         $cmds = array("d.name", "d.down.rate", "d.size_chunks", "d.completed_chunks", "d.chunk_size");
         $req = new \model\xmlrpc\rXMLRPCRequest($tf->scgi);
         foreach ($cmds as $v) {
             $req->addCommand(new \model\xmlrpc\rXMLRPCCommand($tf->scgi, $v, $tf->hash));
         }
         if ($req->success()) {
             $tf->nomtorrent = $req->val[0];
             $get_completed_chunks = $req->val[3];
             $get_size_chunks = $req->val[2];
             $get_chunk_size = $req->val[4];
             $tf->timerestant = $req->val[1] > 0 ? floor(($get_size_chunks - $get_completed_chunks) * $get_chunk_size / $req->val[1]) : -1;
             //Eta 9 (Temps restant en seconde)
         }
     }
     $this->set("file", $tf);
 }
Пример #2
0
 function download($id)
 {
     if ($torrentf = \model\mysql\Torrentfilm::getFilmDuServeur($id)) {
         \config\Conf::$userscgi = $torrentf->userscgi;
         $req = new \model\xmlrpc\rXMLRPCRequest(\config\Conf::$userscgi, new \model\xmlrpc\rXMLRPCCommand(\config\Conf::$userscgi, "f.frozen_path", array($torrentf->hash . ":f" . $torrentf->numfile)));
         if ($req->success()) {
             $filename = $req->val[0];
             if ($filename == '') {
                 $req = new \model\xmlrpc\rXMLRPCRequest(\config\Conf::$userscgi, array(new \model\xmlrpc\rXMLRPCCommand(\config\Conf::$userscgi, "d.open", $torrentf->hash), new \model\xmlrpc\rXMLRPCCommand(\config\Conf::$userscgi, "f.frozen_path", array($torrentf->hash . ":f" . $torrentf->numfile)), new \model\xmlrpc\rXMLRPCCommand(\config\Conf::$userscgi, "d.close", $torrentf->hash)));
                 if ($req->success()) {
                     $filename = $req->val[1];
                 }
             }
             $mediainfo = json_decode($torrentf->mediainfo, true);
             $compfile = "[";
             $compfile .= strlen($torrentf->complementfichier) > 0 ? $torrentf->complementfichier . "." : "";
             switch ($mediainfo["typequalite"]) {
                 case "SD":
                     $compfile .= $mediainfo["codec"];
                     break;
                 case "HD":
                     $compfile .= $mediainfo["qualite"] . "." . $mediainfo["codec"];
                     break;
             }
             $audios = array();
             foreach ($mediainfo["audios"] as $v) {
                 $res = "";
                 if ($v["type"] !== "MP3") {
                     $res .= $v["type"] . " " . $v["cannal"];
                     if (isset($v["lang"])) {
                         $res .= " " . $v["lang"];
                     }
                 }
                 $audios[] = $res;
             }
             if (count($audios) > 1) {
                 $au = implode(".", $audios);
                 $compfile .= "." . $au . "]";
             } else {
                 $compfile .= "." . $audios[0] . "]";
             }
             $tmp = \model\simple\Download::sendFileName($filename, $torrentf->titre . " " . $compfile);
         }
     } else {
         if ($torrentf = \model\mysql\Torrentfilm::getAdresseServeurFilmUser($id)) {
             //echo ('Location: http'.($_SERVER["SERVER_PORT"] == 80 ? "" : "s") . "://" . $torrentf->hostname."/film/download/".$id."/".\config\Conf::$user["user"]->login."/".\config\Conf::$user["user"]->keyconnexion);
             //die();
             header('Location: http' . ($_SERVER["SERVER_PORT"] == 80 ? "" : "s") . "://" . $torrentf->hostname . "/film/download/" . $id . "/" . \config\Conf::$user["user"]->login . "/" . \config\Conf::$user["user"]->keyconnexion);
             exit;
         } else {
             throw new \Exception("FILE NOT FOUND");
         }
     }
 }
    $filename = ROOT . DS . str_replace("\\", DS, $class_name) . ".php";
    if (file_exists($filename)) {
        require_once $filename;
    } else {
    }
}
use model\mysql\Torrentserie as Torrentfilm;
\config\Conf::$debuglocalfile = false;
//retour visuel
$torrentfilm = Torrentfilm::getAll();
foreach ($torrentfilm as $v) {
    //var_dump($v);
    \config\Conf::$userscgi = $v->login;
    $hashtorrentselectionne = $v->hashtorrent;
    $nofile = $v->numfile;
    $mediasinfo = json_decode($v->mediainfo, true);
    $req = new \model\xmlrpc\rXMLRPCRequest(\config\Conf::$userscgi, new \model\xmlrpc\rXMLRPCCommand(\config\Conf::$userscgi, "f.frozen_path", array($hashtorrentselectionne . ":f" . $nofile)));
    if ($req->success()) {
        $filename = $req->val[0];
        if ($filename == '') {
            $req = new \model\xmlrpc\rXMLRPCRequest(\config\Conf::$userscgi, array(new \model\xmlrpc\rXMLRPCCommand(\config\Conf::$userscgi, "d.open", $hashtorrentselectionne), new \model\xmlrpc\rXMLRPCCommand(\config\Conf::$userscgi, "f.frozen_path", array($hashtorrentselectionne . ":f" . $nofile)), new \model\xmlrpc\rXMLRPCCommand(\config\Conf::$userscgi, "d.close", $hashtorrentselectionne)));
            if ($req->success()) {
                $filename = $req->val[1];
            }
        }
        $mediasinfo["taille"] = filesize($filename);
        $mediasinfo["filename"] = $filename;
        \model\simple\Console::println($filename);
        \model\simple\Console::println($v->updateMediainfo($mediasinfo));
    }
}
Пример #4
0
 * Time: 00:37
 */
/**
 * Todo: A supprimer dans la version final plus nécessaire
 *
 */
define('WEBROOT', __DIR__);
define('ROOT', dirname(WEBROOT));
define('DS', DIRECTORY_SEPARATOR);
function __autoload($class_name)
{
    $filename = ROOT . DS . str_replace("\\", DS, $class_name) . ".php";
    if (file_exists($filename)) {
        require_once $filename;
    } else {
    }
}
$portscgi = trim(file_get_contents("/home/" . $argv[1] . "/.scgi.txt"));
usleep(10000);
define('LOG', ROOT . DS . "log" . DS . $portscgi . "_init.log");
\model\simple\Console::println("Début");
$theSettings = \model\xmlrpc\rTorrentSettings::get($portscgi, true);
$req = new \model\xmlrpc\rXMLRPCRequest($portscgi, array($theSettings->getOnFinishedCommand(array("seedingtime", \model\xmlrpc\rTorrentSettings::getCmd($portscgi, 'd.set_custom') . '=seedingtime,"$' . \model\xmlrpc\rTorrentSettings::getCmd($portscgi, 'execute_capture') . '={date,+%s}"')), $theSettings->getOnInsertCommand(array("addtime", \model\xmlrpc\rTorrentSettings::getCmd($portscgi, 'd.set_custom') . '=addtime,"$' . \model\xmlrpc\rTorrentSettings::getCmd($portscgi, 'execute_capture') . '={date,+%s}"')), $theSettings->getOnHashdoneCommand(array("seedingtimecheck", \model\xmlrpc\rTorrentSettings::getCmd($portscgi, 'branch=') . '$' . \model\xmlrpc\rTorrentSettings::getCmd($portscgi, 'not=') . '$' . \model\xmlrpc\rTorrentSettings::getCmd($portscgi, 'd.get_complete=') . ',,' . \model\xmlrpc\rTorrentSettings::getCmd($portscgi, 'd.get_custom') . '=seedingtime,,"' . \model\xmlrpc\rTorrentSettings::getCmd($portscgi, 'd.set_custom') . '=seedingtime,$' . \model\xmlrpc\rTorrentSettings::getCmd($portscgi, 'd.get_custom') . '=addtime' . '"')), \model\xmlrpc\rTorrentSettings::get($portscgi)->getOnEraseCommand(array('erasedata', \model\xmlrpc\rTorrentSettings::getCmd($portscgi, 'branch=') . \model\xmlrpc\rTorrentSettings::getCmd($portscgi, 'd.get_custom1') . '=,"' . \model\xmlrpc\rTorrentSettings::getCmd($portscgi, 'execute') . '={rm,-r,$' . \model\xmlrpc\rTorrentSettings::getCmd($portscgi, 'd.get_base_path') . '=}"')), $theSettings->getOnFinishedCommand(array('addbibliotheque', \model\xmlrpc\rTorrentSettings::getCmd($portscgi, 'execute') . '={' . 'php,' . ROOT . DS . 'script/addbibliotheque.php,' . $portscgi . ',$' . \model\xmlrpc\rTorrentSettings::getCmd($portscgi, 'd.get_hash') . '=,$' . \model\xmlrpc\rTorrentSettings::getCmd($portscgi, 'd.get_base_path') . '=,$' . \model\xmlrpc\rTorrentSettings::getCmd($portscgi, 'd.get_base_filename') . '=,$' . \model\xmlrpc\rTorrentSettings::getCmd($portscgi, 'd.is_multi_file') . '=,$' . \model\xmlrpc\rTorrentSettings::getCmd($portscgi, 'd.get_custom') . '=clefunique,$' . \model\xmlrpc\rTorrentSettings::getCmd($portscgi, 'd.get_custom') . '=typemedias}'))));
if ($req->run()) {
    \model\simple\Console::println("ok");
    exit(0);
} else {
    \model\simple\Console::println("Non ok");
    \model\simple\Console::println($req->val);
    exit(1);
}
Пример #5
0
 function xmlrpcrxmlrpcrequestall()
 {
     $cmds = array("d.get_hash=", "d.is_open=", "d.is_hash_checking=", "d.is_hash_checked=", "d.get_state=", "d.get_name=", "d.get_size_bytes=", "d.get_completed_chunks=", "d.get_size_chunks=", "d.get_bytes_done=", "d.get_up_total=", "d.get_ratio=", "d.get_up_rate=", "d.get_down_rate=", "d.get_chunk_size=", "d.get_custom1=", "d.get_peers_accounted=", "d.get_peers_not_connected=", "d.get_peers_connected=", "d.get_peers_complete=", "d.get_left_bytes=", "d.get_priority=", "d.get_state_changed=", "d.get_skip_total=", "d.get_hashing=", "d.get_chunks_hashed=", "d.get_base_path=", "d.get_creation_date=", "d.get_tracker_focus=", "d.is_active=", "d.get_message=", "d.get_custom2=", "d.get_free_diskspace=", "d.is_private=", "d.is_multi_file=", "d.get_throttle_name=", "d.get_custom=chk-state", "d.get_custom=chk-time", "d.get_custom=sch_ignore", 'cat="$t.multicall=d.get_hash=,t.get_scrape_complete=,cat={#}"', 'cat="$t.multicall=d.get_hash=,t.get_scrape_incomplete=,cat={#}"', 'cat=$d.views=', "d.get_custom=seedingtime", "d.get_custom=addtime");
     $cmd = new \model\xmlrpc\rXMLRPCCommand("d.multicall", "main");
     $cmd->addParameters(array_map("\\model\\xmlrpc\\rTorrentSettings::getCmd", $cmds));
     $cnt = count($cmd->params) - 1;
     $req = new \model\xmlrpc\rXMLRPCRequest(5001, $cmd);
     $t = null;
     if ($req->success()) {
         $i = 0;
         $tmp = array();
         $status = array('started' => 1, 'paused' => 2, 'checking' => 4, 'hashing' => 8, 'error' => 16);
         while ($i < count($req->val)) {
             $torrent = null;
             $state = 0;
             $is_open = $req->val[$i + 1];
             $is_hash_checking = $req->val[$i + 2];
             $is_hash_checked = $req->val[$i + 3];
             $get_state = $req->val[$i + 4];
             $get_hashing = $req->val[$i + 24];
             $is_active = $req->val[$i + 29];
             $msg = $req->val[$i + 30];
             if ($is_open != 0) {
                 $state |= $status["started"];
                 if ($get_state == 0 || $is_active == 0) {
                     $state |= $status["paused"];
                 }
             }
             if ($get_hashing != 0) {
                 $state |= $status["hashing"];
             }
             if ($is_hash_checking != 0) {
                 $state |= $status["checking"];
             }
             if ($msg != "" && $msg != "Tracker: [Tried all trackers.]") {
                 $state |= $status["error"];
             }
             $torrent[] = $state;
             //state 0
             $torrent[] = $req->val[$i + 5];
             //nom 1
             $torrent[] = $req->val[$i + 6];
             //taille 2
             $get_completed_chunks = $req->val[$i + 7];
             $get_hashed_chunks = $req->val[$i + 25];
             $get_size_chunks = $req->val[$i + 8];
             $chunks_processing = $is_hash_checking == 0 ? $get_completed_chunks : $get_hashed_chunks;
             $done = floor($chunks_processing / $get_size_chunks * 1000);
             $torrent[] = $done;
             // 3
             $torrent[] = $req->val[$i + 9];
             //downloaded 4
             $torrent[] = $req->val[$i + 10];
             //Uploaded 5
             $torrent[] = $req->val[$i + 11];
             //ratio 6
             $torrent[] = $req->val[$i + 12];
             //UL 7
             $torrent[] = $req->val[$i + 13];
             //DL 8
             $get_chunk_size = $req->val[$i + 14];
             $torrent[] = $req->val[$i + 13] > 0 ? floor(($get_size_chunks - $get_completed_chunks) * $get_chunk_size / $req->val[$i + 13]) : -1;
             //Eta 9 (Temps restant en seconde)
             /*$get_peers_not_connected = $req->val[$i+17];
               $get_peers_connected = $req->val[$i+18];
               $get_peers_all = $get_peers_not_connected+$get_peers_connected;*/
             $torrent[] = $req->val[$i + 16];
             //Peer Actual 10
             $torrent[] = $req->val[$i + 19];
             //Seed Actual 11
             $seeds = 0;
             foreach (explode("#", $req->val[$i + 39]) as $k => $v) {
                 $seeds += $v;
             }
             $peers = 0;
             foreach (explode("#", $req->val[$i + 40]) as $k => $v) {
                 $peers += $v;
             }
             $torrent[] = $peers;
             //Peer total 12
             $torrent[] = $seeds;
             //Seed tota 13
             $torrent[] = $req->val[$i + 20];
             //Taille restant 14
             $torrent[] = $req->val[$i + 21];
             //Priority 15 (0 ne pas télécharger, 1 basse, 2 moyenne, 3 haute)
             $torrent[] = $req->val[$i + 22];
             //State change 16 (dernière date de change d'état)
             $torrent[] = $req->val[$i + 23];
             //Skip total 17
             $torrent[] = $req->val[$i + 26];
             //Base Path 18
             $torrent[] = $req->val[$i + 27];
             //Date create 19
             $torrent[] = $req->val[$i + 28];
             //Focus tracker 20
             /*try {
                   torrent.comment = this.getValue(values,31);
                   if(torrent.comment.search("VRS24mrker")==0)
                       torrent.comment = decodeURIComponent(torrent.comment.substr(10));
               } catch(e) { torrent.comment = ''; }*/
             $torrent[] = $req->val[$i + 32];
             //Torrent free diskspace 21
             $torrent[] = $req->val[$i + 33];
             //Torrent is private 22
             $torrent[] = $req->val[$i + 34];
             //Torrent is multifile 23
             $torrent[] = preg_replace("#\n#", "", $req->val[$i + 42]);
             //Torrent seed time 24
             $torrent[] = preg_replace("#\n#", "", $req->val[$i + 43]);
             //Torrent add time 25
             $torrent[] = $msg;
             //Message tracker 26
             $torrent[] = $req->val[$i];
             //Hash 27
             $tmp[$req->val[$i]] = $torrent;
             $i = $i + 44;
         }
         $data = $tmp;
         /*if (isset($_REQUEST["cid"])){
                         if ($anc = MyMemcache::value("listrt".$_REQUEST["cid"])){
                             foreach ($anc as $k=>$v){
                                 if (!isset($tmp[$k]))
                                     $tmp[$k]=false;
                                 foreach($v as $kk=>$vv){
                                     if (isset($tmp[$k][$kk]) && $tmp[$k][$kk] == $vv){
                                         unset($tmp[$k][$kk]);
                                     }
                                 }
                                 if (count($tmp[$k]) ==0)
                                     unset($tmp[$k]);
                             }
                         }
                     }
         
                     $cid = uniqid(sha1(time()).$_COOKIE["login"]);
                     if (!(MyMemcache::value("listrt".$cid,$data,60*5)))
                         trigger_error("Impossible de mettre des données dans le cache");*/
         $t[] = $tmp;
         //$t[]= $cid;
         //$t[]= $_SERVER["HTTP_HOST"];
         //$t[]= disk_total_space(Variable::$documentroot."../rtorrent/data/salorium");
         //$t[]= disk_total_space(Variable::$documentroot."../rtorrent/data/salorium")-disk_free_space(Variable::$documentroot."../rtorrent/data/salorium");
         $cmds = array("get_up_rate", "get_upload_rate", "get_up_total", "get_down_rate", "get_download_rate", "get_down_total");
         $req = new \model\xmlrpc\rXMLRPCRequest(5001);
         foreach ($cmds as $cmd) {
             $req->addCommand(new \model\xmlrpc\rXMLRPCCommand(5001, $cmd));
         }
         if ($req->success()) {
             $t[] = $req->val;
         }
     }
     if (is_null($t)) {
         trigger_error("Impossible de se connecter à rtorrent :(");
     }
     var_dump($t);
 }