コード例 #1
0
            }
        } else {
            $file = dirname($base_path) . DS . $info['name'];
            \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);
                        $mediainfo = $mediainfo->getFormatVideo();
                        \model\simple\Console::println($torrentf->fini($mediainfo) ? "Sav ok" : "Sav Non ok");
                    }
                    break;
                case "serie":
                    $torrents = \model\mysql\Torrentserie::rechercheParNumFileHashClefunique($numfile, $hash, $clefunique);
                    \model\simple\Console::println(is_bool($torrents) ? "Non Présent" : "Présent");
                    if (!is_bool($torrents)) {
                        $mediainfo = new \model\simple\Mediainfo($file);
                        $mediainfo = $mediainfo->getFormatVideo();
                        //$torrentf->mediainfo = json_encode($mediainfo);
                        \model\simple\Console::println($torrents->fini($mediainfo) ? "Sav ok" : "Sav Non ok");
                    }
                    break;
            }
        }
    } else {
        \model\simple\Console::println("Erreur fichier torrent");
    }
} else {
    \model\simple\Console::println("Impossible de récupérer le torrent");
コード例 #2
0
ファイル: Torrent.php プロジェクト: CamTosh/Mediastorrent
 function send($keyconnexion = null)
 {
     \model\simple\Utilisateur::authentificationPourRtorrent($keyconnexion);
     if (!\config\Conf::$user["user"]) {
         throw new \Exception("Non User");
     }
     $erreur = 1;
     $torrents = null;
     $clefunique = null;
     $typemedias = null;
     $status = "ok";
     /*
      * =================================================
      * Traitement Mediastorrent !!!!
      * =================================================
      */
     if (isset($_REQUEST["mediastorrent"])) {
         $tmpclefunique = null;
         for ($idtorrent = 0; $idtorrent < $_REQUEST["nbtorrents"]; $idtorrent++) {
             if (isset($_REQUEST["torrent" . $idtorrent . "addbibli"])) {
                 $typemedias[$_REQUEST["torrent" . $idtorrent . "hash"]] = $_REQUEST["torrent" . $idtorrent . "type"];
                 switch ($_REQUEST["torrent" . $idtorrent . "type"]) {
                     case 'film':
                         $clef = \model\mysql\Torrentfilm::getClefUnique();
                         $clefunique[$_REQUEST["torrent" . $idtorrent . "hash"]] = $clef;
                         for ($idfile = 0; $idfile < $_REQUEST["torrent" . $idtorrent . "nbfiles"]; $idfile++) {
                             if (isset($_REQUEST["torrent" . $idtorrent . "ajoutecheckfile" . $idfile]) && isset($_REQUEST["torrent" . $idtorrent . "file" . $idfile . "recherche"])) {
                                 if ($_REQUEST["torrent" . $idtorrent . "file" . $idfile . "recherche"] === "manuel") {
                                     //Manuel
                                     $titre = trim($_REQUEST["torrent" . $idtorrent . "file" . $idfile . "titre"]);
                                     $otitre = trim($_REQUEST["torrent" . $idtorrent . "file" . $idfile . "titreoriginal"]);
                                     $synopsis = trim($_REQUEST["torrent" . $idtorrent . "file" . $idfile . "synopsis"]);
                                     $genre = explode(",", $_REQUEST["torrent" . $idtorrent . "file" . $idfile . "genre"]);
                                     array_walk($genre, create_function('&$val', '$val = trim($val);'));
                                     array_walk($genre, create_function('&$val', '$val = strtolower($val);'));
                                     array_walk($genre, create_function('&$val', '$val = ucfirst($val);'));
                                     $acteurs = explode(",", $_REQUEST["torrent" . $idtorrent . "file" . $idfile . "acteur"]);
                                     array_walk($acteurs, create_function('&$val', '$val = trim($val);'));
                                     array_walk($acteurs, create_function('&$val', '$val = strtolower($val);'));
                                     array_walk($acteurs, create_function('&$val', '$val = ucwords($val);'));
                                     $acteurs = implode(", ", $acteurs);
                                     $realisateurs = explode(",", $_REQUEST["torrent" . $idtorrent . "file" . $idfile . "realisateur"]);
                                     array_walk($realisateurs, create_function('&$val', '$val = trim($val);'));
                                     array_walk($realisateurs, create_function('&$val', '$val = strtolower($val);'));
                                     array_walk($realisateurs, create_function('&$val', '$val = ucwords($val);'));
                                     $realisateurs = implode(", ", $realisateurs);
                                     $anneeprod = trim($_REQUEST["torrent" . $idtorrent . "file" . $idfile . "anneeprod"]);
                                     $urlposter = trim($_REQUEST["torrent" . $idtorrent . "file" . $idfile . "poster"]);
                                     $urlbackdrop = trim($_REQUEST["torrent" . $idtorrent . "file" . $idfile . "backdrop"]);
                                     $infos["Titre"] = $titre;
                                     $infos["Titre original"] = $otitre;
                                     $infos["Genre"] = implode(", ", $genre);
                                     $infos["Réalisateur(s)"] = $realisateurs;
                                     $infos["Acteur(s)"] = $acteurs;
                                     $infos["Année de production"] = $anneeprod;
                                     $infos["Synopsis"] = $synopsis;
                                     $film = \model\mysql\Film::ajouteFilm($titre, $otitre, json_encode($infos), $urlposter, $urlbackdrop, $anneeprod, $acteurs, $realisateurs);
                                     $idfilm = $film->id;
                                     $film->addGenre($genre);
                                 } else {
                                     //Auto
                                     if ($_REQUEST["torrent" . $idtorrent . "file" . $idfile . "typerecherche"] === "local") {
                                         //Local
                                         $idfilm = $_REQUEST["torrent" . $idtorrent . "file" . $idfile . "code"];
                                     } else {
                                         //Allo
                                         $o["typesearch"] = "movie";
                                         $allo = new \model\simple\Allocine($_REQUEST["torrent" . $idtorrent . "file" . $idfile . "code"], $o);
                                         $infos = $allo->retourneResMovieFormatForBD();
                                         $genre = $infos["Genre"];
                                         $infos["Genre"] = implode(", ", $genre);
                                         $titre = isset($infos["Titre"]) ? $infos["Titre"] : $infos["Titre original"];
                                         $otitre = $infos["Titre original"];
                                         $urlposter = trim($_REQUEST["torrent" . $idtorrent . "file" . $idfile . "poster"]);
                                         $urlbackdrop = trim($_REQUEST["torrent" . $idtorrent . "file" . $idfile . "backdrop"]);
                                         $realisateurs = $infos["Réalisateur(s)"];
                                         $acteurs = "";
                                         if (isset($infos["Acteur(s)"])) {
                                             $acteurs = $infos["Acteur(s)"];
                                         }
                                         $anneeprod = $infos["Année de production"];
                                         $film = \model\mysql\Film::ajouteFilm($titre, $otitre, json_encode($infos), $urlposter, $urlbackdrop, $anneeprod, $acteurs, $realisateurs, $_REQUEST["torrent" . $idtorrent . "file" . $idfile . "code"]);
                                         $idfilm = $film->id;
                                         $film->addGenre($genre);
                                     }
                                 }
                                 \model\mysql\Torrentfilm::addTorrentFilm($idfilm, $_REQUEST["torrent" . $idtorrent . "numfile" . $idfile], $_REQUEST["torrent" . $idtorrent . "filecomplement" . $idfile], \config\Conf::$user["user"]->login, \config\Conf::$nomrtorrent, $_REQUEST["torrent" . $idtorrent . "hash"], $clef, isset($_REQUEST["torrent" . $idtorrent . "partagecheckfile" . $idfile]));
                             }
                         }
                         break;
                     case 'serie':
                         $clef = \model\mysql\Torrentserie::getClefUnique();
                         $clefunique[$_REQUEST["torrent" . $idtorrent . "hash"]] = $clef;
                         for ($idfile = 0; $idfile < $_REQUEST["torrent" . $idtorrent . "nbfiles"]; $idfile++) {
                             if (isset($_REQUEST["torrent" . $idtorrent . "ajoutecheckfile" . $idfile]) && isset($_REQUEST["torrent" . $idtorrent . "filerecherche"])) {
                                 if ($_REQUEST["torrent" . $idtorrent . "filerecherche"] === "manuel") {
                                     //Manuel
                                     /**
                                      * Todo check $idfile, une série == un torrent, pareil pour les différents fichier le contenant différent du film
                                      */
                                     $titre = trim($_REQUEST["torrent" . $idtorrent . "file" . $idfile . "titre"]);
                                     $otitre = trim($_REQUEST["torrent" . $idtorrent . "file" . $idfile . "titreoriginal"]);
                                     $synopsis = trim($_REQUEST["torrent" . $idtorrent . "file" . $idfile . "synopsis"]);
                                     $genre = explode(",", $_REQUEST["torrent" . $idtorrent . "file" . $idfile . "genre"]);
                                     array_walk($genre, create_function('&$val', '$val = trim($val);'));
                                     array_walk($genre, create_function('&$val', '$val = strtolower($val);'));
                                     array_walk($genre, create_function('&$val', '$val = ucfirst($val);'));
                                     $acteurs = explode(",", $_REQUEST["torrent" . $idtorrent . "file" . $idfile . "acteur"]);
                                     array_walk($acteurs, create_function('&$val', '$val = trim($val);'));
                                     array_walk($acteurs, create_function('&$val', '$val = strtolower($val);'));
                                     array_walk($acteurs, create_function('&$val', '$val = ucwords($val);'));
                                     $acteurs = implode(", ", $acteurs);
                                     $realisateurs = explode(",", $_REQUEST["torrent" . $idtorrent . "file" . $idfile . "realisateur"]);
                                     array_walk($realisateurs, create_function('&$val', '$val = trim($val);'));
                                     array_walk($realisateurs, create_function('&$val', '$val = strtolower($val);'));
                                     array_walk($realisateurs, create_function('&$val', '$val = ucwords($val);'));
                                     $realisateurs = implode(", ", $realisateurs);
                                     $anneeprod = trim($_REQUEST["torrent" . $idtorrent . "file" . $idfile . "anneeprod"]);
                                     $urlposter = trim($_REQUEST["torrent" . $idtorrent . "file" . $idfile . "poster"]);
                                     $urlbackdrop = trim($_REQUEST["torrent" . $idtorrent . "file" . $idfile . "backdrop"]);
                                     $infos["Titre"] = $titre;
                                     $infos["Titre original"] = $otitre;
                                     $infos["Genre"] = implode(", ", $genre);
                                     $infos["Réalisateur(s)"] = $realisateurs;
                                     $infos["Acteur(s)"] = $acteurs;
                                     $infos["Année de production"] = $anneeprod;
                                     $infos["Synopsis"] = $synopsis;
                                     $serie = \model\mysql\Serie::ajouteSerie($titre, $otitre, json_encode($infos), $urlposter, $urlbackdrop, $anneeprod, $acteurs, $realisateurs);
                                     $idserie = $serie->id;
                                     $serie->addGenre($genre);
                                 } else {
                                     //Auto
                                     if ($_REQUEST["torrent" . $idtorrent . "filetyperecherche"] === "local") {
                                         //Local
                                         $idserie = $_REQUEST["torrent" . $idtorrent . "filecode"];
                                     } else {
                                         //Allo
                                         $o["typesearch"] = "tvseries";
                                         $allo = new \model\simple\Allocine($_REQUEST["torrent" . $idtorrent . "filecode"], $o);
                                         $infos = $allo->retourneResSerieFormatForBD();
                                         $genre = $infos["Genre"];
                                         $infos["Genre"] = implode(", ", $genre);
                                         $titre = isset($infos["Titre"]) ? $infos["Titre"] : $infos["Titre original"];
                                         $otitre = $infos["Titre original"];
                                         $urlposter = trim($_REQUEST["torrent" . $idtorrent . "fileposter"]);
                                         $urlbackdrop = trim($_REQUEST["torrent" . $idtorrent . "filebackdrop"]);
                                         $realisateurs = $infos["Réalisateur(s)"];
                                         $acteurs = "";
                                         if (isset($infos["Acteur(s)"])) {
                                             $acteurs = $infos["Acteur(s)"];
                                         }
                                         $anneeprod = $infos["Lancement"];
                                         $this->set("ICI", "Ok");
                                         $serie = \model\mysql\Serie::ajouteSerie($titre, $otitre, json_encode($infos), $urlposter, $urlbackdrop, $anneeprod, $acteurs, $realisateurs, $_REQUEST["torrent" . $idtorrent . "filecode"]);
                                         $idserie = $serie->id;
                                         $serie->addGenre($genre);
                                     }
                                 }
                                 \model\mysql\Torrentserie::addTorrentSerie($idserie, $_REQUEST["torrent" . $idtorrent . "numfile" . $idfile], $_REQUEST["torrent" . $idtorrent . "filecomplement" . $idfile], \config\Conf::$user["user"]->login, $_REQUEST["torrent" . $idtorrent . "filesaison" . $idfile], $_REQUEST["torrent" . $idtorrent . "fileepisode" . $idfile], \config\Conf::$nomrtorrent, $_REQUEST["torrent" . $idtorrent . "hash"], $clef, isset($_REQUEST["torrent" . $idtorrent . "partagecheckfile" . $idfile]));
                             }
                         }
                         break;
                 }
             }
         }
     }
     if (isset($_FILES['torrentfile']) && !(count($_FILES['torrentfile']) == 1 && $_FILES['torrentfile']['error'][0] != 4)) {
         if (is_array($_FILES['torrentfile']['name'])) {
             for ($i = 0; $i < count($_FILES['torrentfile']['name']); ++$i) {
                 $files[] = array('name' => $_FILES['torrentfile']['name'][$i], 'tmp_name' => $_FILES['torrentfile']['tmp_name'][$i], 'error' => $_FILES['torrentfile']['error'][$i]);
             }
         } else {
             $files[] = $_FILES['torrentfile'];
         }
         foreach ($files as $file) {
             $erreur = 0;
             $torrent = null;
             $torrent['erreur'] = 1;
             $torrent['nom'] = $file["name"];
             if (pathinfo($file["name"], PATHINFO_EXTENSION) != "torrent") {
                 $file["name"] .= ".torrent";
             }
             $des = DS . "tmp" . DS . $file["name"];
             $torrent['nom'] = $file["name"];
             $ok = move_uploaded_file($file['tmp_name'], $des);
             if ($ok) {
                 $to = new \model\simple\Torrent($des);
                 //$torrents[]= array($to->getFileName(),$to->info["name"]);
                 if ($to->errors()) {
                     $torrent['status'] = "Erreur du fichier torrent";
                 } else {
                     $torrent["status"] = \model\xmlrpc\rTorrent::sendTorrent($to, !isset($_REQUEST['autostart']), $_REQUEST['repertoire']);
                     $torrent["clefunique"] = \model\simple\String::random(10);
                     usleep(40000);
                     if ($torrent['status'][0] === '0') {
                         $req = new \model\xmlrpc\rXMLRPCRequest(\config\Conf::$userscgi, array(new \model\xmlrpc\rXMLRPCCommand(\config\Conf::$userscgi, "d.custom.set", array($to->hash_info(), "clefunique", $clefunique[$to->hash_info()])), new \model\xmlrpc\rXMLRPCCommand(\config\Conf::$userscgi, "d.custom.set", array($to->hash_info(), "typemedias", isset($typemedias[$to->hash_info()]) ? $typemedias[$to->hash_info()] : "aucun"))));
                         $torrent["clefuniqueres"] = $req->success() ? $req->val : $req->val;
                         if ($torrent["clefuniqueres"][0] === "0" && $torrent["clefuniqueres"][1] === "0") {
                             $torrent['erreur'] = 0;
                         }
                     }
                 }
                 unlink($des);
             } else {
                 $torrent['status'] = "Erreur lors de l'upload | Code d'erreur => " . $file["error"];
             }
             $torrents[] = $torrent;
         }
     } else {
         $status = "Pas de fichier envoyer";
     }
     $this->set(array("torrents" => $torrents, "erreur" => $erreur, "status" => $status, "seedbox" => \model\mysql\Rtorrent::getRtorrentsDeUtilisateur(\config\Conf::$user["user"]->login)));
 }
コード例 #3
0
ファイル: Serie.php プロジェクト: CamTosh/Mediastorrent
 function download($id, $keyconnexion = null)
 {
     \model\simple\Utilisateur::authentificationDistante($keyconnexion);
     if (!\config\Conf::$user["user"]) {
         throw new \Exception("Non User");
     }
     if ($torrentf = \model\mysql\Torrentserie::getSerieUserDuServeur($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] . "]";
         }
         $compfile .= "]";
         $tmp = \model\simple\Download::sendFileName($mediainfo["filename"], $torrentf->titre . " Saison " . $torrentf->saison . " Épisode " . $torrentf->episode . " " . $compfile);
         //}
     } else {
         if ($torrentf = \model\mysql\Torrentserie::getAdresseServeurSerieUser($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");
         }
     }
 }
コード例 #4
0
 */
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 {
    }
}
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];
            }
        }
コード例 #5
0
ファイル: Serie.php プロジェクト: CamTosh/Mediastorrent
 function getSaison($id)
 {
     $a = \model\mysql\Torrentserie::getSaisonTorrentSerieParIdSerie($id);
     $this->set("file", $a);
     $this->set('idserie', $id);
 }