foreach ($matchers as $matcher) { $class = $i % 2 == 0 ? "lightrow" : "darkrow"; ?> <tr><td class="<?php echo $class; ?> ">UserAgentMatcher: <span class="setting"><?php echo $matcher['name']; ?> </span><br /> Rows: <span class="setting"><?php echo $matcher['stats']['rows']; ?> </span><br /> Table Size: <span class="setting"><?php echo WurflSupport::formatBytes($matcher['stats']['bytesize']); ?> </span></td></tr> <?php $i++; } ?> </table></td> </tr> <?php } ?> </table> <p><br/> <br/> </p>
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); }
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/>"; echo "Database Time: " . $loader->databaseTime() . "<br/>"; echo "Cache Rebuild Time: " . $loader->cacheRebuildTime() . "<br/>"; echo "Number of Queries: " . $base->db->numQueries . "<br/>"; if (version_compare(PHP_VERSION, '5.2.0') === 1) { echo "PHP Memory Usage: " . WurflSupport::formatBytes(memory_get_usage()) . "<br/>"; } echo "--------------------------------<br/>"; echo "WURFL Version: " . $loader->version . " (" . $loader->last_updated . ")<br />"; echo "WURFL Devices: " . $loader->mainDevices . "<br/>"; echo "PATCH New Devices: " . $loader->patchAddedDevices . "<br/>"; echo "PATCH Merged Devices: " . $loader->patchMergedDevices . "<br/>"; } else { echo "ERROR LOADING DATA!<br/>"; echo "Errors: <br/>\n"; echo "<pre>" . htmlspecialchars(var_export($loader->errors, true)) . "</pre>"; } echo "<hr/><a href=\"index.php\">Return to administration tool.</a>";
protected function actionStats(TeraWurflCLIArgument $arg) { $twversion = $this->wurfl->release_branch . " " . $this->wurfl->release_version; $wurflversion = $this->wurfl->db->getSetting('wurfl_version'); $lastupdated = date('r', $this->wurfl->db->getSetting('loaded_date')); $config = $this->wurfl->rootdir . "TeraWurflConfig.php"; $dbtype = str_replace("TeraWurflDatabase_", "", get_class($this->wurfl->db)); $dbver = $this->wurfl->db->getServerVersion(); $mergestats = $this->wurfl->db->getTableStats(TeraWurflConfig::$TABLE_PREFIX . 'Merge'); $mergestats['bytesize'] = WurflSupport::formatBytes($mergestats['bytesize']); $merge = "\n > MERGE\n Rows: {$mergestats['rows']}\n Devices: {$mergestats['actual_devices']}\n Size: {$mergestats['bytesize']}\n"; $index = ""; $indexstats = $this->wurfl->db->getTableStats(TeraWurflConfig::$TABLE_PREFIX . 'Index'); if (!empty($indexstats)) { $indexstats['bytesize'] = WurflSupport::formatBytes($indexstats['bytesize']); $index = "\n > INDEX\n Rows: {$indexstats['rows']}\n Size: {$indexstats['bytesize']}\n"; } $cachestats = $this->wurfl->db->getTableStats(TeraWurflConfig::$TABLE_PREFIX . 'Cache'); $cachestats['bytesize'] = WurflSupport::formatBytes($cachestats['bytesize']); $cache = "\n > CACHE\n Rows: {$cachestats['rows']}\n Size: {$cachestats['bytesize']}\n"; $matcherList = $this->wurfl->db->getMatcherTableList(); $matchers = array(); foreach ($matcherList as $name) { $matchers[] = array('name' => $name, 'stats' => $this->wurfl->db->getTableStats($name)); } $out = <<<EOF Tera-WURFL {$twversion} Database Type: {$dbtype} (ver {$dbver}) Loaded WURFL: {$wurflversion} Last Updated: {$lastupdated} Config File: {$config} ---------- Table Stats ----------- {$merge}{$index}{$cache} EOF; echo $out; }