示例#1
0
 function getTimeSerie($keyconnexion, $idserie, $saison)
 {
     \model\simple\Utilisateur::authentificationDistante($keyconnexion);
     if (!\config\Conf::$user["user"]) {
         throw new \Exception("Non User");
     }
     $tfs = \model\mysql\Torrentserie::getTorrentSerieNonFiniParIdSerieEtParSaisonDuServeur($idserie, $saison);
     $req = array();
     $cmds = array("d.name", "d.down.rate", "d.size_chunks", "d.completed_chunks", "d.chunk_size");
     foreach ($tfs as $tf) {
         if (!isset($req[$tf->userscgi])) {
             $req[$tf->userscgi][0] = new \model\xmlrpc\rXMLRPCRequest($tf->userscgi);
             $req[$tf->userscgi][1] = 0;
         }
         $req[$tf->userscgi][1]++;
         foreach ($cmds as $vv) {
             $req[$tf->userscgi][0]->addCommand(new \model\xmlrpc\rXMLRPCCommand($tf->userscgi, $vv, $tf->hashtorrent));
         }
         $req[$tf->userscgi][0]->addCommand(new \model\xmlrpc\rXMLRPCCommand($tf->userscgi, "d.custom", array($tf->hashtorrent, "clefunique")));
     }
     $time = array();
     if (count($tfs) > 0) {
         foreach ($req as $v) {
             $vreq = $v[0];
             if ($vreq->success()) {
                 for ($i = 0; $i < $v[1]; $i++) {
                     $tf = new \stdClass();
                     $tf->nomtorrent = $vreq->val[0 + $i * 6];
                     $get_completed_chunks = $vreq->val[3 + $i * 6];
                     $get_size_chunks = $vreq->val[2 + $i * 6];
                     $get_chunk_size = $vreq->val[4 + $i * 6];
                     $tf->timerestant = $vreq->val[1 + $i * 6] > 0 ? floor(($get_size_chunks - $get_completed_chunks) * $get_chunk_size / $vreq->val[1 + $i * 6]) : -1;
                     //Eta 9 (Temps restant en seconde)
                     $time[$vreq->val[5 + $i * 6]] = $tf;
                 }
             }
         }
     }
     $this->set('time', $time);
 }