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"); } } }
exec("chmod a+w " . ROOT . DS . "log"); exec("chmod a+w " . ROOT . DS . "cache"); exec("chmod a+w " . ROOT . DS . "config" . DS . "Conf.php"); exec('echo "php ' . ROOT . DS . "script" . DS . 'cronroot.php &>> ' . ROOT . DS . "log" . DS . 'cronroot.log" >> ' . ROOT . DS . "script" . DS . "cronroot.sh"); exec("chmod a+x " . ROOT . DS . "script" . DS . "cronroot.sh"); exec("chmod a+x " . ROOT . DS . "script" . DS . "createtorrent.sh"); $c = \model\simple\Console::execute("awk -F= '\$1 ~ /^ID\$/ {print \$2}' /etc/os-release"); if ($c[0] === 1) { throw new Exception("Impossible de trouver la distribution"); } \config\Conf::$distribution = $c[1]; $c = \model\simple\Console::execute("ls -l /proc/1/exe | awk '{ print \$11 }'"); if ($c[0] === 1) { throw new Exception("Impossible de trouver l'init.."); } \config\Conf::$init = basename($c[1]); \model\simple\MakerRtorrentLancer::create(); //\model\simple\MakerRtorrent::create(); \model\simple\Console::println("Configuration de mysql"); $host = \model\simple\Console::saisieString("Entré host de mysql"); $login = \model\simple\Console::saisieString("Entré le login de mysql"); $mdp = \model\simple\Console::saisieString("Entré le mot de passe de mysql"); $querys = file_get_contents(ROOT . DS . "mysql" . DS . "mediastorrent.sql"); \core\Mysqli::initmultiquery($host, $login, $mdp, $querys); $lvm = \model\simple\Console::saisieBoolean("Est ce que vous utiliserez lvm2 ?"); $volumegroup = ""; if ($lvm) { $volumegroup = \model\simple\Console::saisieString("Entré le nom du volume group que vous utiliserez"); $sortie = \model\simple\Console::execute('vgdisplay -c ' . $volumegroup); if ($sortie[0] === 1) { $lvm = false;
* Date: 15/05/14 * Time: 16:32 */ 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 { } } //Retour visuel \config\Conf::$debuglocalfile = false; \model\simple\Console::println("Debut cron"); $_SERVER["HTTP_HOST"] = \model\mysql\Rtorrent::getHostRtorrent(); $crontache = \model\mysql\Cronroot::getAllNonFini(); foreach ($crontache as $tache) { if ($tache->setEncour()) { $data = json_decode($tache->donnee, true); $cname = $data["classe"]; $controller = new $cname(null, null); if (!in_array($data["fonction"], get_class_methods($controller))) { trigger_error("Le controller " . $cname . " n'a pas de méthode " . $data["fonction"]); $this->error("Le controller " . $cname . " n'a pas de méthode " . $data["fonction"]); } $cn = explode("\\", $cname); $cn = $cn[count($cn) - 1]; if ($res = call_user_func_array(array($controller, $data["fonction"]), $data["args"])) {
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 { } } 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);
function __autoload($class_name) { $filename = ROOT . DS . str_replace("\\", DS, $class_name) . ".php"; if (file_exists($filename)) { require_once $filename; } else { } } if (function_exists('ini_set')) { ini_set('display_errors', true); ini_set('log_errors', false); } $taskNo = $argv[1]; $utilisateur = $argv[2]; //$userscgi = $argv[3]; \config\Conf::$userscgi = $utilisateur; $req = \core\Memcached::value($utilisateur, "task" . $taskNo); if (!is_null($req)) { $request = unserialize($req); $announce_list = array(); $trackers = array(); $trackersCount = 0; if (isset($request['trackers'])) { $arr = explode("\r", $request['trackers']); foreach ($arr as $key => $value) { $value = trim($value); if (strlen($value)) { $trackers[] = $value; $trackersCount = $trackersCount + 1; } else { if (count($trackers) > 0) {
static function authentificationPourRtorrent($keyconnexion) { if (!is_null($keyconnexion)) { $u = \core\Memcached::value($keyconnexion, "user"); if (is_null($u)) { $u = \model\mysql\Utilisateur::authentifierUtilisateurParKeyConnexion($keyconnexion); if ($u) { \core\Memcached::value($u->keyconnexion, "user", $u, 60 * 2); } } else { $u = $u->keyconnexion === $keyconnexion ? $u : false; if (is_bool($u)) { $u = \model\mysql\Utilisateur::authentifierUtilisateurParKeyConnexion($keyconnexion); if ($u) { \core\Memcached::value($u->keyconnexion, "user", $u, 60 * 2); } } else { \core\Memcached::value($u->keyconnexion, "user", $u, 60 * 2); } } \config\Conf::$user["user"] = $u; if ($u && !is_null($u)) { setcookie("keyconnexion", $u->keyconnexion, strtotime('+1 days'), "/"); $userscgi = \model\mysql\Rtorrent::getUserscgiDeUtilisateur($u->login); if (!$userscgi) { throw new \Exception("Aucun ports scgi sur " . HOST); } \config\Conf::$userscgi = $userscgi[0]->userscgi; } } }
function rt($ports) { \config\Conf::$userscgi = $ports; var_dump(\model\xmlrpc\rTorrentSettings::get(\config\Conf::$userscgi, true)); }