home *** CD-ROM | disk | FTP | other *** search
/ ftp.ee.pdx.edu / 2014.02.ftp.ee.pdx.edu.tar / ftp.ee.pdx.edu / oss / cvs-2004 / bahasa / web / statistics.php,v < prev    next >
Text File  |  2003-10-20  |  15KB  |  701 lines

  1. head    1.8;
  2. access;
  3. symbols
  4.     Initial:1.1.1.1 bule:1.1.1;
  5. locks; strict;
  6. comment    @# @;
  7.  
  8.  
  9. 1.8
  10. date    2003.10.20.00.21.46;    author bule;    state Exp;
  11. branches;
  12. next    1.7;
  13.  
  14. 1.7
  15. date    2003.10.18.00.33.42;    author bule;    state Exp;
  16. branches;
  17. next    1.6;
  18.  
  19. 1.6
  20. date    2003.10.06.00.39.27;    author bule;    state Exp;
  21. branches;
  22. next    1.5;
  23.  
  24. 1.5
  25. date    2003.10.01.06.51.30;    author bule;    state Exp;
  26. branches;
  27. next    1.4;
  28.  
  29. 1.4
  30. date    2003.09.11.05.28.22;    author bule;    state Exp;
  31. branches;
  32. next    1.3;
  33.  
  34. 1.3
  35. date    2003.09.04.07.27.00;    author bule;    state Exp;
  36. branches;
  37. next    1.2;
  38.  
  39. 1.2
  40. date    2003.08.19.19.24.21;    author bule;    state Exp;
  41. branches;
  42. next    1.1;
  43.  
  44. 1.1
  45. date    2003.08.12.19.18.23;    author bule;    state Exp;
  46. branches
  47.     1.1.1.1;
  48. next    ;
  49.  
  50. 1.1.1.1
  51. date    2003.08.12.19.18.23;    author bule;    state Exp;
  52. branches;
  53. next    ;
  54.  
  55.  
  56. desc
  57. @@
  58.  
  59.  
  60. 1.8
  61. log
  62. @*** empty log message ***
  63. @
  64. text
  65. @<?
  66. session_start();
  67. require_once("../php/Statistics.php");
  68. require_once("../php/Web.php");
  69. //////////////////////////////////////////////////////////////////////////////
  70. //////////////////////////////////////////////////////////////////////////////
  71. // Project Name: Bahasa Indonesia Dictionary
  72. // Directory:    bahasa/web
  73. // File Name:    statistics.php
  74. // Author(s):    John L. Whiteman
  75. // Created:      June 23, 2003  
  76. // Modified:     October 19, 2003
  77. // Description:  The purpose of this restricted access PHP web 
  78. //               client page is allow an administrator to view 
  79. //               various statistics regarding the current state
  80. //               of a live project.
  81. // 
  82. // Copyright (c) 2003 John L. Whiteman
  83. //
  84. // Permission is herby granted, free of charge, to any person obtaining a 
  85. // copy of this software, data, and associated documentation files 
  86. // (the "Software"), to deal in the Software without restriction, 
  87. // including without limitation the rights to use, copy, modify, merge, 
  88. // publish, distribute, sublicense, and/or sell copies of Software, and to
  89. // permit persons to whom the Software is furnished to do so, subject to 
  90. // the following conditions:
  91. //
  92. // The above copyright notice and this permission notice shall be 
  93. // included in all copies or substantial portions of the Software.
  94. //
  95. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 
  96. // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 
  97. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
  98. // IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR 
  99. // ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHERE IN AN ACTION OF CONTRACT,
  100. // TORT OR OTHERWISE, ARISING IN THE SOFTWARE.  
  101. //////////////////////////////////////////////////////////////////////////////
  102. //////////////////////////////////////////////////////////////////////////////
  103. $web = new Web();
  104.  
  105. if (!$_SESSION['ADMIN']) {
  106.  
  107.     $web->redirect("login.php");
  108.  
  109.     exit;
  110. }
  111.  
  112. $statistics = new Statistics();
  113.  
  114. $status = $statistics->get_dictionary_status();
  115.  
  116. if ($status["status"] == 1 || $status["status"] == 2) {
  117.  
  118.     $web->redirect("admin.php");
  119.  
  120.     exit;
  121. }
  122.  
  123. $title = "Statistics";
  124.  
  125. if (isset($_POST['database'])) {
  126.  
  127.     $title .= " [Database]";
  128.  
  129. } else if (isset($_POST['dictionary'])) {
  130.  
  131.     $title .= " [Dictionary]";
  132.  
  133. } else if (isset($_POST['php'])) { 
  134.  
  135.     $title .= " [PHP]";
  136.  
  137. } else if (isset($_POST['searches'])) { 
  138.  
  139.     $title .= " [Searches]";
  140.  
  141. } else if (isset($_POST['visitors'])) { 
  142.  
  143.     $title .= " [Visitors]";
  144. }
  145. ?>
  146. <html>
  147. <head>
  148. <title>Bahasa Indonesia Dictionary: <? echo "$title";?></title>
  149.  
  150. <link href="bahasa.css" rel="stylesheet" type="text/css">
  151.  
  152. </head>
  153. <body>
  154. <?
  155. $web->show_logo("$title");
  156. ?>
  157. <a href="admin.php">Administration</a>
  158. <br>
  159.  
  160. <?
  161.  
  162. if (isset($_POST['database'])) {
  163.  
  164.     view_database($web, $statistics);
  165.  
  166. } else if (isset($_POST['dictionary'])) {
  167.  
  168.     view_dictionary($web, $statistics);
  169.  
  170. } else if (isset($_POST['php'])) { 
  171.  
  172.     view_php($statistics);
  173.  
  174. } else if (isset($_POST['searches'])) { 
  175.  
  176.     view_searches($web, $statistics);
  177.  
  178. } else if (isset($_POST['visitors'])) { 
  179.  
  180.     view_visitors($web, $statistics);
  181.  
  182. } else {
  183.  
  184. }
  185. ?>
  186. </body>
  187. </html>
  188.  
  189. <?
  190. ///////////////////////////////////////////////////////////////////////////////
  191. function view_database($web, $statistics) {
  192.  
  193.     $stats = array();
  194.  
  195.     $errstr = $statistics->get_database_statistics($stats);    
  196.  
  197.     if ($errstr != "") {
  198.  
  199.         print "<br><hr><b>${errstr}</b><hr><br>\n";
  200.  
  201.         return;
  202.     }
  203.  
  204.     $client_info = $web->tohtml($stats["client_info"]);
  205.     $host_info = $web->tohtml($stats["host_info"]);
  206.     $proto_info = $web->tohtml($stats["proto_info"]);
  207.     $server_info = $web->tohtml($stats["server_info"]);
  208.     $database_name = $web->tohtml($stats["database_name"]);
  209.     $remote_adx = $web->tohtml($stats["remote_adx"]);
  210.  
  211.     $tables = $stats["tables"];
  212.  
  213.     $required_tables = $stats["required_tables"];
  214.  
  215.     $tables_html =
  216.     "<table cellpadding=\"3\" cellspacing=\"3\" border=\"1\"><tr>\n" .
  217.     "<th>Table Name</th>\n" .
  218.     "<th>Total Entries</th>\n" .
  219.     "<th>SQL File</th>\n" .
  220.     "<th>Description</th></tr>\n";
  221.  
  222.     foreach($tables as $table_name) {
  223.  
  224.         $table_count = 0;
  225.  
  226.         $errstr = $statistics->get_count($table_name, $table_count);
  227.  
  228.         if ($errstr != "") {
  229.  
  230.             print "<br><hr><b>${errstr}</b><hr><br>\n";
  231.  
  232.             return;
  233.         }
  234.  
  235.         $table_name = $web->tohtml($table_name);
  236.  
  237.         $sql_file = 
  238.         $web->tohtml($required_tables[$table_name]['sql']);
  239.  
  240.         $description =
  241.         $web->tohtml($required_tables[$table_name]['description']);
  242.         
  243.         $tables_html .= 
  244.         "<tr>\n" .
  245.         "<td>${table_name}</td>\n" .
  246.         "<td>${table_count}</td>\n" .
  247.         "<td>${sql_file}</td>\n" .
  248.         "<td>${description}</td>\n" .
  249.         "</tr>\n";
  250.     }
  251.  
  252.     $tables_html .= "</table>\n";
  253.  
  254. print <<<EOFVDB
  255. <table cellpadding="3" cellspacing="3" border="0">
  256. <tr>
  257. <td colspan="2"><hr><b>Database Server</b><hr></td>
  258. </tr><tr>
  259. <td>mySQL Host:</td>
  260. <td>${host_info}</td>
  261. </tr><tr>
  262. <td>mySQL Server:</td>
  263. <td>${server_info}</td>
  264. </tr><tr>
  265. <td>mySQL Client:</td>
  266. <td>${client_info}</td>
  267. </tr><tr>
  268. <td>mySQL Proto:</td>
  269. <td>${proto_info}</td>
  270. </tr><tr>
  271. <td>Database Name:</td>
  272. <td>${database_name}</td>
  273. </tr><tr>
  274. <td>Remote Address:</td>
  275. <td>${remote_adx}</td>
  276. </tr><tr>
  277. <td colspan="2"><hr><b>Database Tables</b><hr></td>
  278. </tr>
  279. </table>
  280. $tables_html
  281. EOFVDB;
  282. }
  283. ///////////////////////////////////////////////////////////////////////////////
  284. function view_dictionary($web, $statistics) {
  285.  
  286.     $dictionary = array();
  287.  
  288.     $errstr = $statistics->get_dictionary_statistics($dictionary);
  289.  
  290.     if ($errstr != "") {
  291.  
  292.         print "<br><hr><b>${errstr}</b><hr><br>\n";
  293.  
  294.         return;
  295.     }
  296.  
  297.     $total = $web->tohtml($dictionary["total"]);
  298.     $total_pos = $web->tohtml($dictionary["total_pos"]);
  299.     $old_spelling = $web->tohtml($dictionary["old_spelling"]);
  300.     $new_spelling = $web->tohtml($dictionary["new_spelling"]);
  301.     $comments = $web->tohtml($dictionary["comments"]);
  302.     $parts_of_speech = $dictionary["parts_of_speech"];
  303.  
  304.     $pos_html = "";
  305.  
  306.     foreach($parts_of_speech as $pos => $count) {
  307.  
  308.         $pos = ucfirst($pos);
  309.  
  310.         $pos = $web->tohtml($pos);
  311.  
  312.         $pos_html .= 
  313.         "<tr><td>   -${pos}</td>" .
  314.         "<td>${count}</td></tr>\n";
  315.     }
  316.  
  317. print <<<EOFVD
  318. <table cellspacing="3" cellpadding="3" border="0">
  319. <tr>
  320. <td colspan="2"><hr><b>Entries</b><hr></td>
  321. </tr><tr>
  322. <td>Total:</td>
  323. <td>${total}</td>
  324. </tr><tr>
  325. <td>Old Spelling:</td>
  326. <td>${old_spelling}</td>
  327. </tr><tr>
  328. <td>New Spelling:</td>
  329. <td>${new_spelling}</td>
  330. </tr><tr>
  331. <td>Comments:</td>
  332. <td>${comments}</td>
  333. </tr><tr>
  334. <td colspan="2"><hr><b>Parts of Speech</b><hr></td>
  335. </tr><tr>
  336. <td>Categories:</td>
  337. <td>${total_pos}</td> 
  338. </tr>
  339. ${pos_html}
  340. </table>
  341. EOFVD;
  342.     return;
  343. }
  344. ///////////////////////////////////////////////////////////////////////////////
  345. function view_php($statistics) {
  346.  
  347.     print "<br><br>";
  348.  
  349.     phpinfo();
  350.  
  351.     return;
  352. }
  353. ///////////////////////////////////////////////////////////////////////////////
  354. function view_searches($web, $statistics) {
  355.  
  356.     $searches = array();
  357.  
  358.     $errstr = $statistics->get_searches_statistics($searches);
  359.  
  360.     if ($errstr != "") {
  361.  
  362.         print "<br><hr><b>${errstr}</b><hr><br>\n";
  363.  
  364.         return;
  365.     }
  366.  
  367.     $total = $web->tohtml($searches["total"]);
  368.     $unique = $web->tohtml($searches["unique"]);
  369.     $average = $web->tohtml($searches["average"]);
  370.     $english = $web->tohtml($searches["english"]);
  371.     $indonesian = $web->tohtml($searches["indonesian"]);
  372.     $exact = $web->tohtml($searches["exact"]);
  373.     $fuzzy = $web->tohtml($searches["fuzzy"]);
  374.     $linear = $web->tohtml($searches["linear"]);
  375.     $hits = $web->tohtml($searches["hits"]);
  376.     $maybes = $web->tohtml($searches["maybes"]);
  377.     $misses = $web->tohtml($searches["misses"]);
  378.     $oldest = $web->tohtml($searches["oldest"]);
  379.     $newest = $web->tohtml($searches["newest"]);
  380.     $hit_rate = $web->tohtml($searches["hit_rate"]);
  381.     $maybe_rate = $web->tohtml($searches["maybe_rate"]);
  382.     $miss_rate = $web->tohtml($searches["miss_rate"]);
  383.     $coverage = $web->tohtml($searches["coverage"]);
  384.     $coverage_rate = $web->tohtml($searches["coverage_rate"]);
  385.  
  386. print <<<EOFVS
  387. <table cellspacing="3" cellpadding="3" border="0">
  388. <tr>
  389. <td colspan="2"><hr><b>Visitors</b><hr></td>
  390. </tr><tr>
  391. <td>Total:</td>
  392. <td>${total}</td>
  393. </tr><tr>
  394. <td>Unique:</td>
  395. <td>${unique}</td>
  396. </tr><tr>
  397. <td>Average:</td>
  398. <td>${average}</td>
  399. </tr><tr>
  400. <td>Oldest:</td>
  401. <td>${oldest}</td>
  402. </tr><tr>
  403. <td>Newest:</td>
  404. <td>${newest}</td>
  405. </tr><tr>
  406. <td colspan="2"><hr><b>Results</b><hr></td>
  407. </tr><tr>
  408. <td>Hits:</td>
  409. <td>${hits}</td>
  410. </tr><tr>
  411. <td>Hit Rate:</td>
  412. <td>${hit_rate}</td>
  413. </tr><tr>
  414. <td>Maybes:</td>
  415. <td>${maybes}</td>
  416. </tr><tr>
  417. <td>Maybe Rate:</td>
  418. <td>${maybe_rate}</td>
  419. </tr><tr>
  420. <td>Misses:</td>
  421. <td>${misses}</td>
  422. </tr><tr>
  423. <td>Miss Rate:</td>
  424. <td>${miss_rate}</td>
  425. </tr><tr>
  426. <td>Coverage:</td>
  427. <td>${coverage}</td>
  428. </tr><tr>
  429. <td>Coverage Rate:</td>
  430. <td>${coverage_rate}</td>
  431. </tr><tr>
  432. <td colspan="2"><hr><b>Language</b><hr></td>
  433. </tr><tr>
  434. <td>English:</td>
  435. <td>${english}</td>
  436. </tr><tr>
  437. <td>Indonesian:</td>
  438. <td>${indonesian}</td>
  439. </tr><tr>
  440. <td colspan="2"><hr><b>Search Type</b><hr></td>
  441. </tr><tr>
  442. <td>Exact:</td>
  443. <td>${exact}</td>
  444. </tr><tr>
  445. <td>Fuzzy:</td>
  446. <td>${fuzzy}</td>
  447. </tr><tr>
  448. <td>Linear:</td>
  449. <td>${linear}</td>
  450. </tr>
  451. </table>
  452. EOFVS;
  453.     
  454.     return;
  455. }
  456. ///////////////////////////////////////////////////////////////////////////////
  457. function view_visitors($web, $statistics) {
  458.  
  459.     $visitors = array();
  460.  
  461.     $errstr = $statistics->get_searches_statistics($visitors);
  462.  
  463.     if ($errstr != "") {
  464.  
  465.         print "<br><hr><b>${errstr}</b><hr><br>\n";
  466.  
  467.         return;
  468.     }
  469.  
  470.     $total = $web->tohtml($visitors["total"]);
  471.     $unique = $web->tohtml($visitors["unique"]);
  472.     $average = $web->tohtml($visitors["average"]);
  473.     $english = $web->tohtml($visitors["english"]);
  474.     $indonesian = $web->tohtml($visitors["indonesian"]);
  475.     $exact = $web->tohtml($visitors["exact"]);
  476.     $fuzzy = $web->tohtml($visitors["fuzzy"]);
  477.     $linear = $web->tohtml($visitors["linear"]);
  478.     $hits = $web->tohtml($visitors["hits"]);
  479.     $maybes = $web->tohtml($visitors["maybes"]);
  480.     $misses = $web->tohtml($visitors["misses"]);
  481.     $oldest = $web->tohtml($visitors["oldest"]);
  482.     $newest = $web->tohtml($visitors["newest"]);
  483.     $hit_rate = $web->tohtml($visitors["hit_rate"]);
  484.     $maybe_rate = $web->tohtml($visitors["maybe_rate"]);
  485.     $miss_rate = $web->tohtml($visitors["miss_rate"]);
  486.     $visits = $visitors["visitors"]; 
  487.  
  488.     if ($total == 0) {
  489.  
  490.         print "<hr><b>No dictionary searches found!</b><hr>\n"; 
  491.  
  492.         return;
  493.     }
  494.  
  495.     print 
  496.     "<table cellpadding=\"3\" cellspacing=\"3\" border=\"0\">\n" .
  497.     "<tr>\n" .
  498.     "<td>Total:</td>\n" .
  499.     "<td><u>${total}</u> </td>\n" .
  500.     "<td>Unique:</td>\n" .
  501.     "<td><u>${unique}</u> </td>\n" .
  502.     "<td>Hit Rate:</td>\n" .
  503.     "<td><u>${hit_rate}</u> </td>\n" .
  504.     "<td>Maybe Rate:</td>\n" .
  505.     "<td><u>${maybe_rate}</u> </td>\n" .
  506.     "<td>Miss Rate:</td>\n" .
  507.     "<td><u>${miss_rate}</u> </td>\n" .
  508.     "<td>Average:</td>\n" .
  509.     "<td><u>${average}</u> </td>\n" .
  510.     "</tr></table><hr>\n";
  511.  
  512.     $vhtml = 
  513.     "<table cellpadding=\"2\" cellspacing=\"2\" border=\"0\">\n" .
  514.     "<tr>\n" .
  515.     "<th>PKEY</th>\n" .
  516.     "<th>Visitor</th>\n" .
  517.     "<th>Total</th>\n" .
  518.     "<th>Hit Rate</th>\n" .
  519.     "<th>Hits</th>\n" .
  520.     "<th>Maybes</th>\n" .
  521.     "<th>Misses</th>\n" .
  522.     "<th>English</th>\n" .
  523.     "<th>Indonesian</th>\n" .
  524.     "<th>Exact</th>\n" .
  525.     "<th>Fuzzy</th>\n" .
  526.     "<th>Linear</th>\n" .
  527.     "<th>Created</th>\n" .
  528.     "<th>Modified</th>\n" .
  529.     "</tr>\n";
  530.  
  531.     foreach($visits as $visit) {
  532.  
  533.         $vpkey = $web->tohtml($visit->pkey);
  534.         $vvisitor = $web->tohtml($visit->visitor);
  535.         $venglish = $web->tohtml($visit->english);
  536.         $vindonesian = $web->tohtml($visit->indonesian);
  537.         $vexact = $web->tohtml($visit->exact);
  538.         $vfuzzy = $web->tohtml($visit->fuzzy);
  539.         $vlinear = $web->tohtml($visit->linear);
  540.         $vhits = $web->tohtml($visit->hits);
  541.         $vmaybes = $web->tohtml($visit->maybes);
  542.         $vmisses = $web->tohtml($visit->misses);
  543.         $vtotal = $web->tohtml($visit->total);
  544.         $vcreated = $web->tohtml($visit->created);
  545.         $vmodified = $web->tohtml($visit->modified);
  546.         $vhit_rate = "0.00%";
  547.  
  548.         $vcreated = $statistics->get_date($vcreated);
  549.  
  550.         if ($vtotal > 0) {
  551.  
  552.             $vhit_rate = 
  553.             sprintf("%000.2f%%", 100 * ($vhits) / ($vtotal));
  554.         }
  555.  
  556.         if ($vmodified > 0) {
  557.  
  558.             $vmodified = $statistics->get_date($vmodified);
  559.  
  560.         } else {
  561.  
  562.             $vmodified = "N/A";
  563.         }
  564.  
  565.         $vhtml .=
  566.         "<tr>\n" .
  567.         "<td>${vpkey} </td>\n" .
  568.         "<td>${vvisitor} </td>\n" .
  569.         "<td>${vtotal} </td>\n" .
  570.         "<td>${vhit_rate} </td>\n" . 
  571.         "<td>${vhits} </td>\n" .
  572.         "<td>${vmaybes} </td>\n" .
  573.         "<td>${vmisses} </td>\n" .
  574.         "<td>${venglish} </td>\n" .
  575.         "<td>${vindonesian} </td>\n" .
  576.         "<td>${vexact} </td>\n" .
  577.         "<td>${vfuzzy} </td>\n" .
  578.         "<td>${vlinear} </td>\n" .
  579.         "<td>${vcreated} </td>\n" .
  580.         "<td>${vmodified} </td>\n " .
  581.         "</tr><tr>\n" .
  582.         "<td colspan=\"14\"><hr><td>\n" .
  583.         "</tr>\n";
  584.     }
  585.  
  586.     $vhtml .= "</table>\n";
  587.  
  588.     print "$vhtml"; 
  589.  
  590.     return;
  591. }
  592. ///////////////////////////////////////////////////////////////////////////////
  593. ///////////////////////////////////////////////////////////////////////////////
  594. ?>
  595. @
  596.  
  597.  
  598. 1.7
  599. log
  600. @*** empty log message ***
  601. @
  602. text
  603. @d12 1
  604. a12 1
  605. // Modified:     October 17, 2003
  606. d85 3
  607. @
  608.  
  609.  
  610. 1.6
  611. log
  612. @*** empty log message ***
  613. @
  614. text
  615. @d12 1
  616. a12 1
  617. // Modified:     October 05, 2003
  618. d84 1
  619. a84 3
  620. <title>
  621. Bahasa Indonesia Dictionary: <? echo "$title";?> 
  622. </title>
  623. @
  624.  
  625.  
  626. 1.5
  627. log
  628. @*** empty log message ***
  629. @
  630. text
  631. @d12 1
  632. a12 1
  633. // Modified:     September 30, 2003
  634. d89 3
  635. a91 2
  636. <h2>Bahasa Indonesia Dictionary: <? echo "$title";?> </h2>
  637.  
  638. @
  639.  
  640.  
  641. 1.4
  642. log
  643. @*** empty log message ***
  644. @
  645. text
  646. @d12 1
  647. a12 1
  648. // Modified:     September 05, 2003
  649. d41 1
  650. a41 1
  651. if (!session_is_registered("ADMIN")) {
  652. @
  653.  
  654.  
  655. 1.3
  656. log
  657. @*** empty log message ***
  658. @
  659. text
  660. @d12 1
  661. a12 1
  662. // Modified:     September 03, 2003
  663. d92 1
  664. a92 2
  665.  
  666. <br><br>
  667. d421 7
  668. @
  669.  
  670.  
  671. 1.2
  672. log
  673. @*** empty log message ***
  674. @
  675. text
  676. @d12 1
  677. a12 1
  678. // Modified:     August 19, 2003
  679. @
  680.  
  681.  
  682. 1.1
  683. log
  684. @Initial revision
  685. @
  686. text
  687. @d5 34
  688. a38 1
  689.  
  690. a522 1
  691.  
  692. @
  693.  
  694.  
  695. 1.1.1.1
  696. log
  697. @Bahasa Indonesia Dictionary
  698. @
  699. text
  700. @@
  701.