Exemplo n.º 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);
 }