$gzsize = WurflSupport::formatBytes(filesize($newfile)); // Try to use ZipArchive, included from 5.2.0 if (class_exists("ZipArchive")) { $zip = new ZipArchive(); if ($zip->open(str_replace('\\', '/', $newfile)) === TRUE) { $zip->extractTo(str_replace('\\', '/', dirname($wurflfile)), array('wurfl.xml')); $zip->close(); } else { throw new Exception("Error: Unable to extract wurfl.xml from downloaded archive: {$newfile}"); exit(1); } } else { system("gunzip {$newfile}"); } $size = WurflSupport::formatBytes(filesize($wurflfile)) . " [{$gzsize} compressed]"; $download_rate = WurflSupport::formatBitrate(filesize($newfile), $download_time); $ok = true; echo "done ({$wurflfile}: {$size})<br />Downloaded in {$download_time} sec @ {$download_rate} <br/><br/>"; usleep(50000); flush(); } $loader = new TeraWurflLoader($base); //$ok = $base->db->initializeDB(); $ok = $loader->load(); if ($ok) { echo "<strong>Database Update OK</strong><hr />"; echo "Total Time: " . $loader->totalLoadTime() . "<br/>"; echo "Parse Time: " . $loader->parseTime() . " (" . $loader->getParserName() . ")<br/>"; echo "Validate Time: " . $loader->validateTime() . "<br/>"; echo "Sort Time: " . $loader->sortTime() . "<br/>"; echo "Patch Time: " . $loader->patchTime() . "<br/>";
public function downloadUpdate() { if ($this->verbose === true) { echo "Downloading WURFL from {$this->download_url} ...\n\n"; } $download_start = microtime(true); if (!($gzdata = @file_get_contents($this->download_url))) { if (isset($http_response_header) && is_array($http_response_header)) { list($version, $status_code, $msg) = explode(' ', $http_response_header[0], 3); $status_code = (int) $status_code; } else { $status_code = 404; $msg = "File not found"; } throw new TeraWurflUpdateDownloaderException("Unable to download WURFL file: HTTP Error {$status_code}: {$msg}", $status_code); } $this->download_time = microtime(true) - $download_start; file_put_contents($this->wurfl_file_zipped, $gzdata); $gzdata = null; $this->compressed_size = filesize($this->wurfl_file_zipped); // Try to use ZipArchive, included from 5.2.0 if (class_exists("ZipArchive", false)) { $zip = new ZipArchive(); if ($zip->open(str_replace('\\', '/', $this->wurfl_file_zipped)) === true) { $zip->extractTo(str_replace('\\', '/', dirname($this->wurfl_file_xml)), array('wurfl.xml')); $zip->close(); } else { throw new TeraWurflException("Error: Unable to extract wurfl.xml from downloaded archive: {$this->wurfl_file_zipped}"); } } else { system("gunzip {$this->wurfl_file_zipped}"); } $this->uncompressed_size = filesize($this->wurfl_file_xml); $this->download_speed = WurflSupport::formatBitrate(filesize($this->wurfl_file_zipped), $this->download_time); if ($this->verbose === true) { $nice_size = WurflSupport::formatBytes($this->uncompressed_size) . " [" . WurflSupport::formatBytes($this->compressed_size) . " compressed]"; echo "done ({$this->wurfl_file_xml}: {$nice_size})\nDownloaded in {$this->download_time} sec @ {$this->download_speed} \n\n"; flush(); } usleep(50000); }