コード例 #1
0
ファイル: Serie.php プロジェクト: CamTosh/Mediastorrent
 function streaming($id)
 {
     $this->layout = "streaming";
     if (is_string(\config\Conf::$user["user"])) {
         //Traitement du ticket
         $torrentf = \model\mysql\Torrentserie::getTorrentSerieParIdForStreaming($id);
     } else {
         $torrentf = \model\mysql\Torrentserie::getTorrentSerieParIdForStreamingDeUtilisateur($id);
     }
     if ($torrentf) {
         /*\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] . "]";
         }
         $str = str_replace("'", "\\'", str_replace("&lt;", "<", $torrentf->titre . " " . $compfile . "." . pathinfo($mediainfo["filename"], PATHINFO_EXTENSION)));
         $str = htmlentities($str, ENT_NOQUOTES, "UTF-8");
         // remplacer les entités HTML pour avoir juste le premier caractères non accentués
         // Exemple : "&ecute;" => "e", "&Ecute;" => "E", "Ã " => "a" ...
         $str = preg_replace('#&([A-za-z])(?:acute|grave|cedil|circ|orn|ring|slash|th|tilde|uml);#', '\\1', $str);
         // Remplacer les ligatures tel que : Œ, Æ ...
         // Exemple "Å“" => "oe"
         $str = preg_replace('#&([A-za-z]{2})(?:lig);#', '\\1', $str);
         // Supprimer tout le reste
         $str = preg_replace('#&[^;]+;#', '', $str);
         if (is_string(\config\Conf::$user["user"])) {
             $idticket = \model\mysql\Ticket::savTicket("controller\\Film", "download", [$id], 60 * 60 * 6);
         }
         $this->set(array("titre" => $torrentf->titre . " " . $compfile, "src" => is_string(\config\Conf::$user["user"]) == true ? "http://" . $torrentf->hostname . "/ticket/traite/" . $idticket . "/" . $str : "http://" . $torrentf->hostname . "/serie/download/" . $id . "/" . \config\Conf::$user["user"]->keyconnexion . "/" . $str));
         //}
     }
 }