コード例 #1
0
ファイル: torrents.class.php プロジェクト: Kufirc/Gazelle
 /**
  * Regenerate a torrent's file list from its meta data,
  * update the database record and clear relevant cache keys
  *
  * @param int $TorrentID
  */
 public static function regenerate_filelist($TorrentID)
 {
     $QueryID = G::$DB->get_query_id();
     G::$DB->query("\n\t\t\tSELECT tg.ID,\n\t\t\t\ttf.File\n\t\t\tFROM torrents_files AS tf\n\t\t\t\tJOIN torrents AS t ON t.ID = tf.TorrentID\n\t\t\t\tJOIN torrents_group AS tg ON tg.ID = t.GroupID\n\t\t\tWHERE tf.TorrentID = {$TorrentID}");
     if (G::$DB->has_results()) {
         list($GroupID, $Contents) = G::$DB->next_record(MYSQLI_NUM, false);
         if (Misc::is_new_torrent($Contents)) {
             $Tor = new BencodeTorrent($Contents);
             $FilePath = isset($Tor->Dec['info']['files']) ? Format::make_utf8($Tor->get_name()) : '';
         } else {
             $Tor = new TORRENT(unserialize(base64_decode($Contents)), true);
             $FilePath = isset($Tor->Val['info']->Val['files']) ? Format::make_utf8($Tor->get_name()) : '';
         }
         list($TotalSize, $FileList) = $Tor->file_list();
         foreach ($FileList as $File) {
             $TmpFileList[] = self::filelist_format_file($File);
         }
         $FileString = implode("\n", $TmpFileList);
         G::$DB->query("\n\t\t\t\tUPDATE torrents\n\t\t\t\tSET Size = {$TotalSize}, FilePath = '" . db_string($FilePath) . "', FileList = '" . db_string($FileString) . "'\n\t\t\t\tWHERE ID = {$TorrentID}");
         G::$Cache->delete_value("torrents_details_{$GroupID}");
     }
     G::$DB->set_query_id($QueryID);
 }