Exemplo n.º 1
0
 public static function fastResume($torrent, $base, $add_path = true)
 {
     $files = array();
     $info = $torrent->info;
     $psize = intval($info['piece length']);
     $base = trim($base);
     if ($base == '') {
         $req = new rXMLRPCRequest(new \model\xmlrpc\rXMLRPCCommand(\config\Conf::$userscgi, 'get_directory'));
         if ($req->success()) {
             $base = $req->val[0];
         }
     }
     if ($psize && \model\xmlrpc\rTorrentSettings::get(\config\Conf::$userscgi)->correctDirectory($base)) {
         $base = addslash($base);
         $tsize = 0.0;
         if (isset($info['files'])) {
             foreach ($info['files'] as $key => $file) {
                 $tsize += floatval($file['length']);
                 $files[] = $add_path ? $info['name'] . "/" . implode('/', $file['path']) : implode('/', $file['path']);
             }
         } else {
             $tsize = floatval($info['length']);
             $files[] = $info['name'];
         }
         $chunks = intval(($tsize + $psize - 1) / $psize);
         $torrent->{'libtorrent_resume'}['bitfield'] = intval($chunks);
         if (!isset($torrent->{'libtorrent_resume'}['files'])) {
             $torrent->{'libtorrent_resume'}['files'] = array();
         }
         foreach ($files as $key => $file) {
             $ss = LFS::stat($base . $file);
             if ($ss === false) {
                 return false;
             }
             if (count($torrent->{'libtorrent_resume'}['files']) < $key) {
                 $torrent->{'libtorrent_resume'}['files'][$key]['mtime'] = $ss["mtime"];
             } else {
                 $torrent->{'libtorrent_resume'}['files'][$key] = array("priority" => 2, "mtime" => $ss["mtime"]);
             }
         }
         return $torrent;
     }
     return false;
 }
Exemplo n.º 2
0
    } else {
    }
}
$userscgi = $argv[1];
$hash = $argv[2];
$base_path = $argv[3];
$base_name = $argv[4];
$is_multi = $argv[5];
$clefunique = $argv[6];
$typemedias = $argv[7];
define('LOG', ROOT . DS . "log" . DS . $userscgi . "_addbibli.log");
\model\simple\Console::println("Début");
\model\simple\Console::println($hash);
\model\simple\Console::println($typemedias);
file_put_contents(ROOT . DS . "log" . DS . $userscgi . "start_addblibli.log", $userscgi . " " . $hash . ' "' . $base_path . '" "' . $base_name . '" ' . $is_multi . " " . $clefunique . " " . $typemedias . "\n", FILE_APPEND);
$filetorrent = \model\xmlrpc\rTorrentSettings::get($userscgi)->session . DS . $hash . ".torrent";
if (file_exists($filetorrent)) {
    $torrent = new \model\simple\Torrent($filetorrent);
    if (!$torrent->errors()) {
        $info = $torrent->info;
        $numfile = 0;
        if (isset($info['files'])) {
            foreach ($info['files'] as $key => $file) {
                $file = $base_path . DS . implode('/', $file['path']);
                \model\simple\Console::println($file);
                switch ($typemedias) {
                    case "film":
                        $torrentf = \model\mysql\Torrentfilm::rechercheParNumFileHashClefunique($numfile, $hash, $clefunique);
                        \model\simple\Console::println(is_bool($torrentf) ? "Non Présent" : "Présent");
                        if (!is_bool($torrentf)) {
                            $mediainfo = new \model\simple\Mediainfo($file);
Exemplo n.º 3
0
 function init($keyconnexion = null)
 {
     \model\simple\Utilisateur::authentificationPourRtorrent($keyconnexion);
     $theSettings = \model\xmlrpc\rTorrentSettings::get(\config\Conf::$userscgi, true);
     $req = new \model\xmlrpc\rXMLRPCRequest(\config\Conf::$userscgi, array($theSettings->getOnFinishedCommand(array("seedingtime", \model\xmlrpc\rTorrentSettings::getCmd(\config\Conf::$userscgi, 'd.set_custom') . '=seedingtime,"$' . \model\xmlrpc\rTorrentSettings::getCmd(\config\Conf::$userscgi, 'execute_capture') . '={date,+%s}"')), $theSettings->getOnInsertCommand(array("addtime", \model\xmlrpc\rTorrentSettings::getCmd(\config\Conf::$userscgi, 'd.set_custom') . '=addtime,"$' . \model\xmlrpc\rTorrentSettings::getCmd(\config\Conf::$userscgi, 'execute_capture') . '={date,+%s}"')), $theSettings->getOnHashdoneCommand(array("seedingtimecheck", \model\xmlrpc\rTorrentSettings::getCmd(\config\Conf::$userscgi, 'branch=') . '$' . \model\xmlrpc\rTorrentSettings::getCmd(\config\Conf::$userscgi, 'not=') . '$' . \model\xmlrpc\rTorrentSettings::getCmd(\config\Conf::$userscgi, 'd.get_complete=') . ',,' . \model\xmlrpc\rTorrentSettings::getCmd(\config\Conf::$userscgi, 'd.get_custom') . '=seedingtime,,"' . \model\xmlrpc\rTorrentSettings::getCmd(\config\Conf::$userscgi, 'd.set_custom') . '=seedingtime,$' . \model\xmlrpc\rTorrentSettings::getCmd(\config\Conf::$userscgi, 'd.get_custom') . '=addtime' . '"')), \model\xmlrpc\rTorrentSettings::get(\config\Conf::$userscgi)->getOnEraseCommand(array('erasedata', \model\xmlrpc\rTorrentSettings::getCmd(\config\Conf::$userscgi, 'branch=') . \model\xmlrpc\rTorrentSettings::getCmd(\config\Conf::$userscgi, 'd.get_custom1') . '=,"' . \model\xmlrpc\rTorrentSettings::getCmd(\config\Conf::$userscgi, 'execute') . '={rm,-r,$' . \model\xmlrpc\rTorrentSettings::getCmd(\config\Conf::$userscgi, 'd.get_base_path') . '=}"')), $theSettings->getOnFinishedCommand(array('addbibliotheque', \model\xmlrpc\rTorrentSettings::getCmd(\config\Conf::$userscgi, 'execute') . '={' . 'php,' . ROOT . DS . 'script/addbibliotheque.php,' . \config\Conf::$userscgi . ',$' . \model\xmlrpc\rTorrentSettings::getCmd(\config\Conf::$userscgi, 'd.get_hash') . '=,$' . \model\xmlrpc\rTorrentSettings::getCmd(\config\Conf::$userscgi, 'd.get_base_path') . '=,$' . \model\xmlrpc\rTorrentSettings::getCmd(\config\Conf::$userscgi, 'd.get_base_filename') . '=,$' . \model\xmlrpc\rTorrentSettings::getCmd(\config\Conf::$userscgi, 'd.is_multi_file') . '=,$' . \model\xmlrpc\rTorrentSettings::getCmd(\config\Conf::$userscgi, 'd.get_custom') . "=clefunique" . '}'))));
     if ($req->run()) {
         echo "ok";
     } else {
         echo $req->val;
     }
 }
Exemplo n.º 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);
}
Exemplo n.º 5
0
 public static function getCmd($user, $cmd)
 {
     return rTorrentSettings::get($user, true)->getCommand($cmd);
 }
Exemplo n.º 6
0
<?php

/**
 * Created by PhpStorm.
 * User: salorium
 * Date: 25/03/14
 * Time: 10:26
 */
define('WEBROOT', __DIR__);
define('ROOT', dirname(WEBROOT));
define('DS', DIRECTORY_SEPARATOR);
define('CORE', ROOT . DS . 'core');
define('BASE_URL', "http" . ($_SERVER["SERVER_PORT"] == 80 ? "" : "s") . "://" . $_SERVER["HTTP_HOST"] . dirname(dirname($_SERVER["SCRIPT_NAME"])));
function __autoload($class_name)
{
    $filename = ROOT . DS . str_replace("\\", DS, $class_name) . ".php";
    if (file_exists($filename)) {
        require_once $filename;
    }
}
$theSettings = \model\xmlrpc\rTorrentSettings::get(5001, true);
var_dump($theSettings);
$req = new \model\xmlrpc\rXMLRPCRequest(5001, array($theSettings->getOnFinishedCommand(array("seedingtime", \model\xmlrpc\rTorrentSettings::getCmd(5001, 'd.set_custom') . '=seedingtime,"$' . \model\xmlrpc\rTorrentSettings::getCmd(5001, 'execute_capture') . '={date,+%s}"')), $theSettings->getOnInsertCommand(array("addtime", \model\xmlrpc\rTorrentSettings::getCmd(5001, 'd.set_custom') . '=addtime,"$' . \model\xmlrpc\rTorrentSettings::getCmd(5001, 'execute_capture') . '={date,+%s}"')), $theSettings->getOnHashdoneCommand(array("seedingtimecheck", \model\xmlrpc\rTorrentSettings::getCmd(5001, 'branch=') . '$' . \model\xmlrpc\rTorrentSettings::getCmd(5001, 'not=') . '$' . \model\xmlrpc\rTorrentSettings::getCmd(5001, 'd.get_complete=') . ',,' . \model\xmlrpc\rTorrentSettings::getCmd(5001, 'd.get_custom') . '=seedingtime,,"' . \model\xmlrpc\rTorrentSettings::getCmd(5001, 'd.set_custom') . '=seedingtime,$' . \model\xmlrpc\rTorrentSettings::getCmd(5001, 'd.get_custom') . '=addtime' . '"'))));
if ($req->success()) {
    echo "ok";
} else {
    echo "error";
}
echo $req;
Exemplo n.º 7
0
 function portrtorrent($userscgi)
 {
     //\config\Conf::$portscgi = $portscgi;
     $this->set("rtorrent", rTorrentSettings::get($userscgi)->port);
 }