Changeset 1006
- Timestamp:
- 06/28/08 21:26:25 (5 months ago)
- Files:
-
- trunk/swisscenter/base/server.php (modified) (1 diff)
- trunk/swisscenter/ext/parsers/tv/www.TheTVDB.com.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/swisscenter/base/server.php
r820 r1006 23 23 function is_unix() 24 24 { return get_os_type() == "UNIX"; } 25 26 function is_synology() 27 { 28 // Have we already done the Sybology test? 29 if (! isset($_SESSION["Synology"]) ) 30 { 31 if ( preg_match('/phpinfo/', ini_get('disable_functions')) == 0) 32 { 33 // Is phpinfo() available for us to use? 34 ob_start(); 35 phpinfo(8); 36 $info = ob_get_contents(); 37 ob_end_clean(); 38 $_SESSION["Synology"] = !(stristr($info, 'synology') === false); 39 } 40 else 41 { 42 $_SESSION["Synology"] = ($_SERVER["SERVER_NAME"] == "synology"); 43 } 44 } 45 return $_SESSION["Synology"]; 46 } 25 47 26 48 // ---------------------------------------------------------------------------------- trunk/swisscenter/ext/parsers/tv/www.TheTVDB.com.php
r1000 r1006 24 24 31-Mar-2008: v1.1: Fixed episode year and now informs user if episode details are not found. 25 25 23-Apr-2008: v1.2: Fixed downloading of series 0 (Special) banners. 26 25-Jun-2008: v1.3: Improved zip support on Linux installations. 26 27 27 28 *************************************************************************************************/ … … 75 76 global $tvdb_series, $tvdb_episodes, $tvdb_banners; 76 77 77 $series_url = $xmlmirror.'/api/FA3F6F720A61DE71/series/'.$series_id.'/all/'.$language.'.zip'; 78 $series_zip_url = $xmlmirror.'/api/FA3F6F720A61DE71/series/'.$series_id.'/all/'.$language.'.zip'; 79 $series_xml_url = $xmlmirror.'/api/FA3F6F720A61DE71/series/'.$series_id.'/all/'.$language.'.xml'; 80 $banner_xml_url = $xmlmirror.'/api/FA3F6F720A61DE71/series/'.$series_id.'/banners.xml'; 78 81 $series_zip_cache = $cache_dir.'/'.$series_id.'_'.$language.'.zip'; 79 82 $series_cache = $cache_dir.'/'.$series_id.'_'.$language.'.xml'; … … 81 84 82 85 // Ensure local copy of full series zip is uptodate (cache valid for 6 hours) 83 $series_cache_time = (file_exists($series_ zip_cache) ? filemtime($series_zip_cache) : 0);86 $series_cache_time = (file_exists($series_cache) ? filemtime($series_cache) : 0); 84 87 if ($series_cache_time < (time() - 21600)) 85 88 { 86 send_to_log(4,'Downloading remote file to the local filesystem',$series_url); 87 if (!@copy($series_url, $series_zip_cache)) 88 send_to_log(6,'Failed to copy remote file to',$series_zip_cache); 89 // Extract zip contents 90 $zip = @zip_open($series_zip_cache); 91 if (is_resource($zip)) 92 { 93 while ($zip_entry = zip_read($zip)) 89 if (is_synology()) 90 { 91 // Synology has no zip support so download non-zipped data 92 send_to_log(4,'Downloading remote file to the local filesystem',$series_xml_url); 93 if (!@copy($series_xml_url, $series_cache)) 94 send_to_log(6,'Failed to copy remote file to',$series_cache); 95 send_to_log(4,'Downloading remote file to the local filesystem',$banner_xml_url); 96 if (!@copy($banner_xml_url, $banner_cache)) 97 send_to_log(6,'Failed to copy remote file to',$banner_cache); 98 } 99 else 100 { 101 send_to_log(4,'Downloading remote file to the local filesystem',$series_url); 102 if (!@copy($series_url, $series_zip_cache)) 103 send_to_log(6,'Failed to copy remote file to',$series_zip_cache); 104 else 94 105 { 95 // Get file contents from zip 96 $entry = zip_entry_open($zip,$zip_entry); 97 $zfilename = zip_entry_name($zip_entry); 98 $zfilesize = zip_entry_filesize($zip_entry); 99 $zcontents = zip_entry_read($zip_entry, $zfilesize); 100 $fp=@fopen($cache_dir.'/'.$series_id.'_'.$zfilename,"w"); 101 @fwrite($fp,$zcontents); 102 @fclose($fp); 103 zip_entry_close($zip_entry); 106 // Extract zip contents 107 if ( extension_loaded('zip') && is_resource($zip = @zip_open($series_zip_cache)) ) 108 { 109 while ($zip_entry = zip_read($zip)) 110 { 111 // Get file contents from zip 112 $entry = zip_entry_open($zip,$zip_entry); 113 $zfilename = zip_entry_name($zip_entry); 114 $zfilesize = zip_entry_filesize($zip_entry); 115 $zcontents = zip_entry_read($zip_entry, $zfilesize); 116 $fp=@fopen($cache_dir.'/'.$series_id.'_'.$zfilename,"w"); 117 @fwrite($fp,$zcontents); 118 @fclose($fp); 119 zip_entry_close($zip_entry); 120 } 121 @zip_close($zip); 122 } 123 elseif (is_unix()) 124 { 125 // On LINUX machines, we can use the standard "unzip" command to 126 // perform the same functions as the zip extension 127 exec('unzip '.$series_zip_cache.' -d '.$cache_dir); 128 } 129 else 130 { 131 send_to_log(6,"Failed to open series zip from www.thetvdb.com. (zip_open errno=$zip)"); 132 } 104 133 } 105 134 } 106 else107 {108 send_to_log(6,"Failed to open series zip from www.thetvdb.com. (zip_open errno=$zip)");109 }110 @zip_close($zip);111 135 } 112 136