PageRenderTime 51ms CodeModel.GetById 25ms RepoModel.GetById 0ms app.codeStats 0ms

/search/stats.php

https://bitbucket.org/molusc/sma-website
PHP | 185 lines | 151 code | 21 blank | 13 comment | 11 complexity | ba11eaee38a909df21ec258555529307 MD5 | raw file
Possible License(s): BSD-3-Clause
  1. <?php
  2. /******************************************************************************
  3. * iSearch2 - website search engine *
  4. * *
  5. * Visit the iSearch homepage at http://www.iSearchTheNet.com/isearch *
  6. * *
  7. * Copyright (C) 2002-2007 Z-Host. All rights reserved. *
  8. * *
  9. ******************************************************************************/
  10. // PHPLOCKITOPT NOENCODE
  11. $isearch_path = dirname(__FILE__);
  12. define('IN_ISEARCH', true);
  13. require_once "$isearch_path/inc/core.inc.php";
  14. /* Open the search component (read only) */
  15. isearch_open(True);
  16. /* Check the action and set the page title accordingly */
  17. if (isset($isearch_lang['stats_title']))
  18. {
  19. $isearch_pageTitle = $isearch_lang['stats_title'];
  20. }
  21. else
  22. {
  23. $isearch_pageTitle = $isearch_lang['results_title'];
  24. }
  25. echo '
  26. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  27. <html dir="ltr" xmlns="http://www.w3.org/1999/xhtml" xml:lang="' . $isearch_languageCode . '">
  28. <head>
  29. <meta http-equiv="Content-Type" content="text/html; charset='.$isearch_config['char_set'].'" />
  30. <title>' . $isearch_pageTitle . '</title>
  31. <meta name="author" content="Ian Willis" />
  32. <meta name="copyright" content="Copyright Z-Host. All rights reserved." />
  33. <link rel="stylesheet" href="'.$isearch_config['base_url'].'/style/'.$isearch_config['style_name'].'.css" type="text/css" />
  34. </head>
  35. ';
  36. include "$isearch_path/inc/header.inc.php";
  37. echo <<<EOF
  38. <h1 class="isearch">$isearch_pageTitle</h1>\n
  39. EOF;
  40. if ($isearch_config['total_searches'])
  41. {
  42. $result = mysql_query("SELECT count(search_term) AS num FROM $isearch_table_search_log");
  43. if (!$result)
  44. {
  45. echo '<p>ERROR: MySQL error : ' . mysql_error() . '</p>';
  46. }
  47. else if ($item = mysql_fetch_object($result))
  48. {
  49. echo '
  50. <table summary="' . $isearch_lang['sum_stats_total'] . '" width="100%" border=0 cellpadding=0 class="isearch-stats">
  51. <caption>Total Searches</caption>
  52. <thead>
  53. <tr>
  54. <th scope="col">Total Searches</th>
  55. </tr>
  56. </thead>
  57. <tbody>
  58. <tr>
  59. <td style="text-align:center">' . $item->num . '</td>
  60. </tr>
  61. </tbody>
  62. </table>
  63. <br />
  64. ';
  65. }
  66. }
  67. if ($isearch_config['top_searches'] > 0)
  68. {
  69. $result = mysql_query("SELECT DISTINCT search_term, matches, count(search_term) AS num FROM $isearch_table_search_log WHERE matches>0 GROUP BY search_term ORDER BY num desc LIMIT " . $isearch_config['top_searches']);
  70. if (!$result)
  71. {
  72. echo '<p>ERROR: MySQL error : ' . mysql_error() . '</p>';
  73. }
  74. else
  75. {
  76. echo '
  77. <table summary="' . $isearch_lang['sum_stats_top'] . '" width="100%" border="0" cellpadding="0" class="isearch-stats">
  78. <caption>' . str_replace("%d", $isearch_config['top_searches'], $isearch_lang['topsearches']) . '</caption>
  79. <col width="15%" />
  80. <col width="70%" />
  81. <col width="15%" />
  82. <thead>
  83. <tr>
  84. <th scope="col">Searches</th>
  85. <th scope="col">' . $isearch_lang['searchterm'] . '</th>
  86. <th scope="col">' . $isearch_lang['matches'] . '</th>
  87. </tr>
  88. </thead>
  89. <tbody>
  90. ';
  91. while ($item = mysql_fetch_object($result))
  92. {
  93. echo '
  94. <tr>
  95. <td>' . $item->num . '</td>
  96. <td><a href="'.$_SERVER['PHP_SELF'] . '?s=' . $item->search_term . '">' . $item->search_term . '</a></td>
  97. <td>' . $item->matches . '</td>
  98. </tr>
  99. ';
  100. }
  101. echo '
  102. </tbody>
  103. </table>
  104. <br />
  105. ';
  106. }
  107. }
  108. if ($isearch_config['last_searches'] > 0)
  109. {
  110. $result = mysql_query("SELECT DISTINCT search_term, matches FROM $isearch_table_search_log ORDER BY time desc LIMIT " . $isearch_config['last_searches']);
  111. if (!$result)
  112. {
  113. echo '
  114. <p>ERROR: MySQL error : ' . mysql_error() . '</p>
  115. ';
  116. }
  117. else
  118. {
  119. echo '
  120. <table summary="' . $isearch_lang['sum_stats_last'] . '" width="100%" border="0" cellpadding="0" class="isearch-stats">
  121. <caption>' . str_replace("%d", $isearch_config['last_searches'], $isearch_lang['lastsearches']) . '</caption>
  122. <col width="85%" />
  123. <col width="15%" />
  124. <thead>
  125. <tr>
  126. <th scope="col">' . $isearch_lang['searchterm'] . '</th>
  127. <th scope="col">' . $isearch_lang['matches'] . '</th>
  128. </tr>
  129. </thead>
  130. <tbody>
  131. ';
  132. while ($item = mysql_fetch_object($result))
  133. {
  134. echo '
  135. <tr>
  136. <td><a href="' . $_SERVER['PHP_SELF'] . '?s=' . $item->search_term . '">' . $item->search_term . '</a></td>
  137. <td>' . $item->matches . '</td>
  138. </tr>
  139. ';
  140. }
  141. echo '
  142. </tbody>
  143. </table>
  144. <br />
  145. ';
  146. }
  147. }
  148. /* Display the search form */
  149. $s = '';
  150. $partial=False;
  151. $advanced=False;
  152. require_once "$isearch_path/inc/form_internal.inc.php";
  153. /* Close the search component */
  154. isearch_close();
  155. include "$isearch_path/inc/footer.inc.php";
  156. echo <<<EOF
  157. </body>
  158. </html>
  159. EOF;
  160. ?>