PageRenderTime 26ms CodeModel.GetById 24ms RepoModel.GetById 0ms app.codeStats 0ms

/stats.php

https://github.com/phpbb/mpv
PHP | 155 lines | 124 code | 16 blank | 15 comment | 8 complexity | 112a8a0adfb01a2002f6792048f3a80a MD5 | raw file
  1. <?php
  2. /**
  3. * Stats file
  4. *
  5. * @package mpv_server
  6. * @version $Id$
  7. * @copyright (c) 2010 phpBB Group
  8. * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
  9. *
  10. */
  11. header("Expires: Mon, 26 Jul 1997 05:00:00 GMT\n");
  12. $phpEx = substr(strrchr(__FILE__, '.'), 1);
  13. $root_path = './';
  14. // Will define all needed things.
  15. include($root_path . 'mpv_config.' . $phpEx);
  16. include($root_path . 'includes/languages/' . MPV_LANG . '/lang.' . $phpEx);
  17. include($root_path . 'includes/functions_mpv.' . $phpEx);
  18. include($root_path . 'includes/mpv.' . $phpEx);
  19. ?>
  20. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  21. <html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="en-gb" xml:lang="en-gb">
  22. <head>
  23. <style type="text/css">
  24. table.data {
  25. border-width: 1px;
  26. border-spacing: 2px;
  27. border-style: outset;
  28. border-color: gray;
  29. border-collapse: separate;
  30. background-color: white;
  31. margin: 0 auto;
  32. }
  33. table.data th {
  34. border-width: 1px;
  35. padding: 1px;
  36. border-style: inset;
  37. border-color: gray;
  38. background-color: lightgray;
  39. }
  40. table.data td {
  41. border-width: 1px;
  42. padding: 5px;
  43. border-style: inset;
  44. border-color: gray;
  45. background-color: white;
  46. }
  47. </style>
  48. <title><?php print $lang['TITLE_STATS']; ?></title>
  49. </head>
  50. <body>
  51. <br /><br />
  52. <?php
  53. //Do we need to show some statistics?
  54. if (sizeof($statistics))
  55. {
  56. $mod_count = $property_count = $entries = $split_entry = $entries_values = array();
  57. foreach ($statistics as $tag => $properties)
  58. {
  59. $data_file = './store/data/' . $tag . '_data.txt';
  60. if (file_exists($data_file))
  61. {
  62. $contents = file_get_contents($data_file);
  63. $entries = explode("\r\n", $contents);
  64. foreach ($entries as $entry)
  65. {
  66. $mod_name = '';
  67. $split_entry = explode("||", $entry);
  68. foreach ($split_entry as $entry_value)
  69. {
  70. //Check for the MOD name and assign counts as needed
  71. if (empty($mod_name))
  72. {
  73. $mod_name = $entry_value;
  74. $mod_name_id = str_replace(' ', '_', $mod_name);
  75. if (isset($mod_count[$mod_name_id]))
  76. {
  77. $mod_count[$mod_name_id] += 1;
  78. }
  79. else
  80. {
  81. $mod_count = array_merge($mod_count, array($mod_name_id => 1));
  82. }
  83. $entries_values[] = $entry_value;
  84. continue;
  85. }
  86. $entries_values[] = $entry_value;
  87. $entry_value_id = str_replace(' ', '_', $entry_value);
  88. if (isset($property_count[$entry_value_id]))
  89. {
  90. $property_count[$entry_value_id] += 1;
  91. }
  92. else
  93. {
  94. $property_count = array_merge($property_count, array($entry_value_id => 1));
  95. }
  96. }
  97. }
  98. }
  99. }
  100. //Remove the duplicates
  101. $entries_values = array_unique($entries_values);
  102. sort($entries_values);
  103. $row = " <tr><td>%s</td><td style=\"text-align:right;\">%s</td></tr>\n";
  104. print '<table id="tag_data" class="data">
  105. <tr>
  106. <th>' . $lang['TAG_DATA'] . '</th><th>' . $lang['DATA_COUNT'] . "</th>
  107. </tr>\n";
  108. //Print out each row for the properties
  109. foreach ($entries_values as $entry)
  110. {
  111. $entry_id = str_replace(' ', '_', $entry);
  112. if (isset($property_count[$entry_id]))
  113. {
  114. print sprintf($row, $entry, $property_count[$entry_id]);
  115. }
  116. }
  117. print '</table>
  118. <br /><br />
  119. <table id="mod_names" class="data">
  120. <tr>
  121. <th>' . $lang['MOD_NAME'] . '</th><th>' . $lang['SUBMIT_COUNT'] . "</th>
  122. </tr>\n";
  123. //Print out each row for the MOD names
  124. foreach ($entries_values as $entry)
  125. {
  126. if (!empty($entry))
  127. {
  128. $entry_id = str_replace(' ', '_', $entry);
  129. if (isset($mod_count[$entry_id]))
  130. {
  131. print sprintf($row, $entry, $mod_count[$entry_id]);
  132. }
  133. }
  134. }
  135. print '</table>';
  136. }
  137. ?>
  138. </body>
  139. </html>