TeraWurflAdmin
[ class tree: TeraWurflAdmin ] [ index: TeraWurflAdmin ] [ all elements ]

Source for file stats.php

Documentation is available at stats.php

  1. <?php
  2. /**
  3.  * Tera_WURFL - PHP MySQL driven WURFL
  4.  * 
  5.  * Tera-WURFL was written by Steve Kamerman, and is based on the
  6.  * Java WURFL Evolution package by Luca Passani and WURFL PHP Tools by Andrea Trassati.
  7.  * This version uses a MySQL database to store the entire WURFL file, multiple patch
  8.  * files, and a persistent caching mechanism to provide extreme performance increases.
  9.  * 
  10.  * @package TeraWurflAdmin
  11.  * @author Steve Kamerman <stevekamerman AT gmail.com>
  12.  * @version Stable 2.1.3 $Date: 2010/09/18 15:43:21
  13.  * @license http://www.mozilla.org/MPL/ MPL Vesion 1.1
  14.  */
  15. require_once realpath(dirname(__FILE__).'/../TeraWurfl.php');
  16.  
  17. $tw new TeraWurfl();
  18.  
  19. $db $tw->db;
  20.  
  21. $missing_tables false;
  22. if($db->connected === true){
  23.     $required_tables array(TeraWurflConfig::$TABLE_PREFIX.'Cache',TeraWurflConfig::$TABLE_PREFIX.'Index',TeraWurflConfig::$TABLE_PREFIX.'Merge');
  24.     $tables $db->getTableList();
  25. // See what tables are in the DB
  26. //die(var_export($tables,true));
  27.     foreach($required_tables as $req_table){
  28.         if(!in_array($req_table,$tables)){
  29.             $missing_tables true;
  30.         }
  31.     }
  32. }
  33.  
  34.  
  35. $mergestats $db->getTableStats(TeraWurflConfig::$TABLE_PREFIX.'Merge');
  36. $indexstats $db->getTableStats(TeraWurflConfig::$TABLE_PREFIX.'Index');
  37. $cachestats $db->getTableStats(TeraWurflConfig::$TABLE_PREFIX.'Cache');
  38. $matcherList $db->getMatcherTableList();
  39. $matchers array();
  40. foreach($matcherList as $name){
  41.     $matchers[array('name'=>$name,'stats'=>$db->getTableStats($name));
  42. }
  43.  
  44. $logfile $tw->rootdir.TeraWurflConfig::$DATADIR.TeraWurflConfig::$LOG_FILE;
  45.  
  46. if(!is_readable($logfile|| filesize($logfile5){
  47.     $lastloglines "Empty";
  48. }else{
  49.     $logarr file($logfile);
  50.     $loglines 30;
  51.     if(count($logarr)<$loglines)$loglines=count($logarr);
  52.     $end count($logarr)-1;
  53.     $lastloglines '';
  54.     for($i=$end;$i>=($end-$loglines);$i--){
  55.         $lastloglines .= @htmlspecialchars($logarr[$i])."<br />";
  56.     }
  57. }
  58.  
  59. ?>
  60. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  61. <html xmlns="http://www.w3.org/1999/xhtml">
  62. <head>
  63. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  64. <title>Tera-WURFL Administration</title>
  65. <link href="style.css" rel="stylesheet" type="text/css" /></head>
  66.  
  67. <body>
  68. <table width="800">
  69.     <tr><td>
  70. <div align="center" class="titlediv">
  71.     <p>        Tera-WURFL <?php echo $tw->release_version?> Administration<br />
  72.         <span class="version">Loaded WURFL: <?php echo $tw->getSetting(TeraWurfl::$SETTING_WURFL_VERSION)?></span></p>
  73. </div>
  74. </td></tr><tr><td>
  75.         <h3><br />
  76.             <a href="index.php">&lt;&lt; Back    to main page </a></h3>
  77.         <table width="800" border="0" cellspacing="0" cellpadding="0">
  78.         <tr>
  79.             <th scope="col">Database Table </th>
  80.             <th scope="col">Statistics</th>
  81.         </tr>
  82.         <tr>
  83.             <td width="145" class="darkrow">MERGE<br />
  84.                     <span class="setting"><?php echo TeraWurflConfig::$TABLE_PREFIX.'Merge'?></span></td>
  85.             <td width="655" class="darkrow">Rows: <span class="setting"><?php echo $mergestats['rows']?></span><br />
  86.                 Actual Devices: <span class="setting"><?php echo $mergestats['actual_devices']?></span> <br />
  87.                 Table Size: <span class="setting"><?php echo WurflSupport::formatBytes($mergestats['bytesize'])?></span><br />
  88.                 Purpose:<br />
  89.                 <span class="setting">The MERGE table holds all the data from the WURFL file, whether it be local, remote or remote CVS,  whenever a new WURFL is loaded, it is loaded into this table first, then it is filtered through all the UserAgentMatchers and split into many different tables specific to each matching technique. This MERGE table is retained for a last chance lookup if the UserAgentMatchers and INDEX table are unable to provide a conclusive match.</span></td>
  90.         </tr>
  91. <?php if(!empty($indexstats))?>
  92.         <tr>
  93.             <td class="lightrow">INDEX        <br />
  94.                 <span class="setting"><?php echo TeraWurflConfig::$TABLE_PREFIX.'Index'?></span></td>
  95.           <td class="lightrow">Rows: <span class="setting"><?php echo $indexstats['rows']?></span><br />
  96.                 Table Size: <span class="setting"><?php echo WurflSupport::formatBytes($indexstats['bytesize'])?></span><br />
  97.                 Purpose:<br />
  98.                 <span class="setting">The INDEX table acts as a lookup table for WURFL IDs and their respective UserAgentMatchers. </span></td>
  99.         </tr>
  100. <?php ?>
  101.         <tr>
  102.             <td class="darkrow">CACHE        <br />
  103.                 <span class="setting"><?php echo TeraWurflConfig::$TABLE_PREFIX.'Cache'?></span></td>
  104. <td class="darkrow">Rows: <span class="setting"><?php echo $cachestats['rows']?></span><br />
  105.                 Table Size: <span class="setting"><?php echo WurflSupport::formatBytes($cachestats['bytesize'])?></span><br />
  106.                 Purpose:<br />
  107.                 <span class="setting">The CACHE table stores unique user agents and the complete capabilities and device root that were determined when the device was first identified. <strong>Unlike version 1.x</strong>, the CACHE table stores every device that is detected <strong>permanently</strong>. When the device database is updated, the cached devices are also redetected and recached. This behavior is configurable.</span></td>
  108.         </tr>
  109. <?php if(!empty($matchers))?>
  110.         <tr>
  111.             <td class="lightrow" style="vertical-align:top;">User Agent Matchers<br/>
  112.                 Purpose:<br />
  113.                 <span class="setting">The User Agent Matchers store similar user agents.  Tera-WURFL sorts all the devices into the most appropriate UserAgentMatcher table to make lookups faster and perform different matching hueristics on certain groups of devices.</span></td><td>
  114.                 <table>
  115. <?php
  116. $i=0;
  117. foreach($matchers as $matcher){
  118.     $class ($i == 0)"lightrow""darkrow";
  119. ?>
  120. <tr><td class="<?php echo $class;?>">UserAgentMatcher: <span class="setting"><?php echo $matcher['name']?></span><br />
  121. Rows: <span class="setting"><?php echo $matcher['stats']['rows']?></span><br />
  122. Table Size: <span class="setting"><?php echo WurflSupport::formatBytes($matcher['stats']['bytesize'])?></span></td></tr>
  123. <?php
  124.     $i++;
  125. }
  126. ?></table></td>
  127.         </tr>
  128. <?php ?>
  129.     </table>
  130. <p><br/>
  131.             <br/>
  132.     </p>
  133.     <table width="800" border="0" cellpadding="0" cellspacing="0">
  134.         <tr>
  135.             <th scope="col">Tera-WURFL Settings</th>
  136.         </tr>
  137.         <tr><td>Installation Directory: <span class="setting"><?php echo dirname(dirname(__FILE__))?></span></td></tr>
  138.         <tr>
  139.             <td class="lightrow"><p>-- Database options --<br/>
  140.                 DB_HOST <span class="setting">
  141.     <?php echo TeraWurflConfig::$DB_HOST?>
  142.     </span>,    database server hostname or IP<br />
  143.                 DB_USER <span class="setting">
  144.     <?php echo TeraWurflConfig::$DB_USER?>
  145.     </span>,    database username (needs SELECT,INSERT,DELETE,DROP,CREATE)<br />
  146.                 DB_PASS <span class="setting">********</span>, database password<br />
  147.                 DB_SCHEMA <span class="setting">
  148.     <?php echo TeraWurflConfig::$DB_SCHEMA?>
  149.     </span>, database schema (database name)<br />
  150.                 DB_CONNECTOR <span class="setting">
  151.     <?php echo TeraWurflConfig::$DB_CONNECTOR?>
  152.     </span>, database type (MySQL4, MySQL5, MSSQL2005, etc...);<br />
  153.                 TABLE_PREFIX <span class="setting">
  154.     <?php echo TeraWurflConfig::$TABLE_PREFIX?>
  155.     </span>, prefix to be used for all table names<br />
  156.                             <br />
  157.                     -- General options --<br />
  158.                     WURFL_DL_URL <span class="setting">
  159.                         <?php echo TeraWurflConfig::$WURFL_DL_URL?>
  160.                             </span>, full URL to the current WURFL<br />
  161.                     WURFL_CVS_URL <span class="setting">
  162.                         <?php echo TeraWurflConfig::$WURFL_CVS_URL?>
  163.                       </span>, full URL to development (CVS) WURFL<br />
  164.                     DATADIR <span class="setting">
  165.                         <?php echo TeraWurflConfig::$DATADIR?>
  166.               </span>,    where all data is stored (wurfl.xml, temp files, logs)<br />
  167.                       CACHE_ENABLE <span class="setting"><?php echo WurflSupport::showBool(TeraWurflConfig::$CACHE_ENABLE)?></span>, enables or disables the cache <br />
  168.                     PATCH_ENABLE <span class="setting">
  169.                         <?php echo WurflSupport::showBool(TeraWurflConfig::$PATCH_ENABLE)?>
  170.                   </span>, enables or disables the patch<br />
  171.                     PATCH_FILE <span class="setting">
  172.                         <?php echo TeraWurflConfig::$PATCH_FILE?>
  173. </span>, optional patch file for WURFL. To use more than one, separate them with semicolons<br />
  174.                     WURFL_FILE <span class="setting">
  175.                         <?php echo TeraWurflConfig::$WURFL_FILE?>
  176.                         </span>, path and filename of wurfl.xml<br />
  177.                     WURFL_LOG_FILE <span class="setting">
  178.                         <?php echo TeraWurflConfig::$LOG_FILE?>
  179.                         </span>, defines full path and filename for logging<br />
  180.                     LOG_LEVEL <span class="setting">
  181.                         <?php echo WurflSupport::showLogLevel(TeraWurflConfig::$LOG_LEVEL)?>
  182.                         </span>, desired logging level. Use the same constants as for PHP logging<br />
  183.                     OVERRIDE_MEMORY_LIMIT <span class="setting">
  184.                         <?php echo WurflSupport::showBool(TeraWurflConfig::$OVERRIDE_MEMORY_LIMIT)?>
  185.                         </span>, override PHP's default memory limit<br />
  186.                     MEMORY_LIMIT <span class="setting">
  187.                         <?php echo TeraWurflConfig::$MEMORY_LIMIT?>
  188.                         </span>, the amount of memory to allocate to PHP if OVERRIDE_MEMORY_LIMIT is enabled<br />
  189.                     SIMPLE_DESKTOP_ENGINE_ENABLE <span class="setting">
  190.                         <?php echo WurflSupport::showBool(TeraWurflConfig::$SIMPLE_DESKTOP_ENGINE_ENABLE)?>
  191.                         </span>, enable the SimpleDesktop Detection Engine to increase performance<br />
  192.                     CAPABILITY_FILTER:
  193.                         <?php echo "<pre class=\"setting\">".var_export(TeraWurflConfig::$CAPABILITY_FILTER,true)."</pre>";?>
  194.                         the capability filter that is used to determine which capabilities are available<br />
  195.             </p>
  196.                 </td>
  197.         </tr>
  198.     </table>
  199.     <p>&nbsp;</p>
  200.     <table width="800" border="0" cellpadding="0" cellspacing="0">
  201.         <tr>
  202.             <th scope="col">Log File (last 30 lines) </th>
  203.         </tr>
  204.         <tr>
  205.             <td class="lightrow"><div class="logfile"><?php echo $lastloglines?></div>
  206.                 <br/></td>
  207.         </tr>
  208.     </table>    <p>&nbsp; </p></td>
  209. </tr></table>
  210. </body>
  211. </html>

Documentation generated on Sun, 19 Sep 2010 00:15:55 +0000 by phpDocumentor 1.4.3