Stats.template.php 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306
  1. <?php
  2. /**
  3. * Simple Machines Forum (SMF)
  4. *
  5. * @package SMF
  6. * @author Simple Machines
  7. * @copyright 2011 Simple Machines
  8. * @license http://www.simplemachines.org/about/smf/license.php BSD
  9. *
  10. * @version 2.1 Alpha 1
  11. */
  12. function template_main()
  13. {
  14. global $context, $settings, $options, $txt, $scripturl, $modSettings;
  15. echo '
  16. <table border="0" width="100%" cellspacing="1" cellpadding="4" class="bordercolor">
  17. <tr class="titlebg">
  18. <td align="center" colspan="4">', $context['page_title'], '</td>
  19. </tr>
  20. <tr>
  21. <td class="catbg" colspan="4"><strong>', $txt['general_stats'], '</strong></td>
  22. </tr><tr>
  23. <td class="windowbg" width="20" valign="middle" align="center"><img src="', $settings['images_url'], '/stats_info.gif" width="20" height="20" alt="" /></td>
  24. <td class="windowbg2" valign="top">
  25. <table border="0" cellpadding="1" cellspacing="0" width="100%">
  26. <tr>
  27. <td nowrap="nowrap">', $txt['total_members'], ':</td>
  28. <td align="right">', $context['show_member_list'] ? '<a href="' . $scripturl . '?action=mlist">' . $context['num_members'] . '</a>' : $context['num_members'], '</td>
  29. </tr><tr>
  30. <td nowrap="nowrap">', $txt['total_posts'], ':</td>
  31. <td align="right">', $context['num_posts'], '</td>
  32. </tr><tr>
  33. <td nowrap="nowrap">', $txt['total_topics'], ':</td>
  34. <td align="right">', $context['num_topics'], '</td>
  35. </tr><tr>
  36. <td nowrap="nowrap">', $txt['total_cats'], ':</td>
  37. <td align="right">', $context['num_categories'], '</td>
  38. </tr><tr>
  39. <td nowrap="nowrap">', $txt['users_online'], ':</td>
  40. <td align="right">', $context['users_online'], '</td>
  41. </tr><tr>
  42. <td nowrap="nowrap" valign="top">', $txt['most_online'], ':</td>
  43. <td align="right">', $context['most_members_online']['number'], ' - ', $context['most_members_online']['date'], '</td>
  44. </tr><tr>
  45. <td nowrap="nowrap">', $txt['users_online_today'], ':</td>
  46. <td align="right">', $context['online_today'], '</td>';
  47. if (!empty($modSettings['hitStats']))
  48. echo '
  49. </tr><tr>
  50. <td nowrap="nowrap">', $txt['num_hits'], ':</td>
  51. <td align="right">', $context['num_hits'], '</td>';
  52. echo '
  53. </tr>
  54. </table>
  55. </td>
  56. <td class="windowbg" width="20" valign="middle" align="center"><img src="', $settings['images_url'], '/stats_info.gif" width="20" height="20" alt="" /></td>
  57. <td class="windowbg2" valign="top">
  58. <table border="0" cellpadding="1" cellspacing="0" width="100%">
  59. <tr>
  60. <td nowrap="nowrap">', $txt['average_members'], ':</td>
  61. <td align="right">', $context['average_members'], '</td>
  62. </tr><tr>
  63. <td nowrap="nowrap">', $txt['average_posts'], ':</td>
  64. <td align="right">', $context['average_posts'], '</td>
  65. </tr><tr>
  66. <td nowrap="nowrap">', $txt['average_topics'], ':</td>
  67. <td align="right">', $context['average_topics'], '</td>
  68. </tr><tr>
  69. <td nowrap="nowrap">', $txt['total_boards'], ':</td>
  70. <td align="right">', $context['num_boards'], '</td>
  71. </tr><tr>
  72. <td nowrap="nowrap">', $txt['latest_member'], ':</td>
  73. <td align="right">', $context['common_stats']['latest_member']['link'], '</td>
  74. </tr><tr>
  75. <td nowrap="nowrap">', $txt['average_online'], ':</td>
  76. <td align="right">', $context['average_online'], '</td>
  77. </tr><tr>
  78. <td nowrap="nowrap">', $txt['gender_ratio'], ':</td>
  79. <td align="right">', $context['gender']['ratio'], '</td>';
  80. if (!empty($modSettings['hitStats']))
  81. echo '
  82. </tr><tr>
  83. <td nowrap="nowrap">', $txt['average_hits'], ':</td>
  84. <td align="right">', $context['average_hits'], '</td>';
  85. echo '
  86. </tr>
  87. </table>
  88. </td>
  89. </tr><tr>
  90. <td class="catbg" colspan="2" width="50%"><strong>', $txt['top_posters'], '</strong></td>
  91. <td class="catbg" colspan="2" width="50%"><strong>', $txt['top_boards'], '</strong></td>
  92. </tr><tr>
  93. <td class="windowbg" width="20" valign="middle" align="center"><img src="', $settings['images_url'], '/stats_posters.gif" width="20" height="20" alt="" /></td>
  94. <td class="windowbg2" width="50%" valign="top">
  95. <table border="0" cellpadding="1" cellspacing="0" width="100%">';
  96. foreach ($context['top_posters'] as $poster)
  97. echo '
  98. <tr>
  99. <td width="60%" valign="top">', $poster['link'], '</td>
  100. <td width="20%" align="', $context['right_to_left'] ? 'right' : 'left', '" valign="top">', $poster['num_posts'] > 0 ? '<img src="' . $settings['images_url'] . '/bar.gif" width="' . $poster['post_percent'] . '" height="15" alt="" />' : '&nbsp;', '</td>
  101. <td width="20%" align="right" valign="top">', $poster['num_posts'], '</td>
  102. </tr>';
  103. echo '
  104. </table>
  105. </td>
  106. <td class="windowbg" width="20" valign="middle" align="center"><img src="', $settings['images_url'], '/stats_board.gif" width="20" height="20" alt="" /></td>
  107. <td class="windowbg2" width="50%" valign="top">
  108. <table border="0" cellpadding="1" cellspacing="0" width="100%">';
  109. foreach ($context['top_boards'] as $board)
  110. echo '
  111. <tr>
  112. <td width="60%" valign="top">', $board['link'], '</td>
  113. <td width="20%" align="', $context['right_to_left'] ? 'right' : 'left', '" valign="top">', $board['num_posts'] > 0 ? '<img src="' . $settings['images_url'] . '/bar.gif" width="' . $board['post_percent'] . '" height="15" alt="" />' : '&nbsp;', '</td>
  114. <td width="20%" align="right" valign="top">', $board['num_posts'], '</td>
  115. </tr>';
  116. echo '
  117. </table>
  118. </td>
  119. </tr><tr>
  120. <td class="catbg" colspan="2" width="50%"><strong>', $txt['top_topics_replies'], '</strong></td>
  121. <td class="catbg" colspan="2" width="50%"><strong>', $txt['top_topics_views'], '</strong></td>
  122. </tr><tr>
  123. <td class="windowbg" width="20" valign="middle" align="center"><img src="', $settings['images_url'], '/stats_replies.gif" width="20" height="20" alt="" /></td>
  124. <td class="windowbg2" width="50%" valign="top">
  125. <table border="0" cellpadding="1" cellspacing="0" width="100%">';
  126. foreach ($context['top_topics_replies'] as $topic)
  127. echo '
  128. <tr>
  129. <td width="60%" valign="top">', $topic['link'], '</td>
  130. <td width="20%" align="', $context['right_to_left'] ? 'right' : 'left', '" valign="top">', $topic['num_replies'] > 0 ? '<img src="' . $settings['images_url'] . '/bar.gif" width="' . $topic['post_percent'] . '" height="15" alt="" />' : '&nbsp;', '</td>
  131. <td width="20%" align="right" valign="top">', $topic['num_replies'], '</td>
  132. </tr>';
  133. echo '
  134. </table>
  135. </td>
  136. <td class="windowbg" width="20" valign="middle" align="center"><img src="', $settings['images_url'], '/stats_views.gif" width="20" height="20" alt="" /></td>
  137. <td class="windowbg2" width="50%" valign="top">
  138. <table border="0" cellpadding="1" cellspacing="0" width="100%">';
  139. foreach ($context['top_topics_views'] as $topic)
  140. echo '
  141. <tr>
  142. <td width="60%" valign="top">', $topic['link'], '</td>
  143. <td width="20%" align="', $context['right_to_left'] ? 'right' : 'left', '" valign="top">', $topic['num_views'] > 0 ? '<img src="' . $settings['images_url'] . '/bar.gif" width="' . $topic['post_percent'] . '" height="15" alt="" />' : '&nbsp;', '</td>
  144. <td width="20%" align="right" valign="top">', $topic['num_views'], '</td>
  145. </tr>';
  146. echo '
  147. </table>
  148. </td>
  149. </tr><tr>
  150. <td class="catbg" colspan="2" width="50%"><strong>', $txt['top_starters'], '</strong></td>
  151. <td class="catbg" colspan="2" width="50%"><strong>', $txt['most_time_online'], '</strong></td>
  152. </tr><tr>
  153. <td class="windowbg" width="20" valign="middle" align="center"><img src="', $settings['images_url'], '/stats_replies.gif" width="20" height="20" alt="" /></td>
  154. <td class="windowbg2" width="50%" valign="top">
  155. <table border="0" cellpadding="1" cellspacing="0" width="100%">';
  156. foreach ($context['top_starters'] as $poster)
  157. echo '
  158. <tr>
  159. <td width="60%" valign="top">', $poster['link'], '</td>
  160. <td width="20%" align="', $context['right_to_left'] ? 'right' : 'left', '" valign="top">', $poster['num_topics'] > 0 ? '<img src="' . $settings['images_url'] . '/bar.gif" width="' . $poster['post_percent'] . '" height="15" alt="" />' : '&nbsp;', '</td>
  161. <td width="20%" align="right" valign="top">', $poster['num_topics'], '</td>
  162. </tr>';
  163. echo '
  164. </table>
  165. </td>
  166. <td class="windowbg" width="20" valign="middle" align="center" nowrap="nowrap"><img src="', $settings['images_url'], '/stats_views.gif" width="20" height="20" alt="" /></td>
  167. <td class="windowbg2" width="50%" valign="top">
  168. <table border="0" cellpadding="1" cellspacing="0" width="100%">';
  169. foreach ($context['top_time_online'] as $poster)
  170. echo '
  171. <tr>
  172. <td width="60%" valign="top">', $poster['link'], '</td>
  173. <td width="20%" align="', $context['right_to_left'] ? 'right' : 'left', '" valign="top">', $poster['time_online'] > 0 ? '<img src="' . $settings['images_url'] . '/bar.gif" width="' . $poster['time_percent'] . '" height="15" alt="" />' : '&nbsp;', '</td>
  174. <td width="20%" align="right" valign="top" nowrap="nowrap">', $poster['time_online'], '</td>
  175. </tr>';
  176. echo '
  177. </table>
  178. </td>
  179. </tr><tr>
  180. <td class="catbg" colspan="4"><strong>', $txt['forum_history'], '</strong></td>
  181. </tr><tr>
  182. <td class="windowbg" width="20" valign="middle" align="center"><img src="', $settings['images_url'], '/stats_history.gif" width="20" height="20" alt="" /></td>
  183. <td class="windowbg2" colspan="4">';
  184. if (!empty($context['yearly']))
  185. {
  186. echo '
  187. <table border="0" width="100%" cellspacing="1" cellpadding="4" class="tborder" style="margin-bottom: 1ex;" id="stats">
  188. <tr class="titlebg" valign="middle" align="center">
  189. <td width="25%">', $txt['yearly_summary'], '</td>
  190. <td width="15%">', $txt['stats_new_topics'], '</td>
  191. <td width="15%">', $txt['stats_new_posts'], '</td>
  192. <td width="15%">', $txt['stats_new_members'], '</td>
  193. <td width="15%">', $txt['most_online'], '</td>';
  194. if (!empty($modSettings['hitStats']))
  195. echo '
  196. <td>', $txt['page_views'], '</td>';
  197. echo '
  198. </tr>';
  199. foreach ($context['yearly'] as $id => $year)
  200. {
  201. echo '
  202. <tr class="windowbg2" valign="middle" id="year_', $id, '">
  203. <th class="lefttext" width="25%">
  204. <img id="year_img_', $id, '" src="', $settings['images_url'], '/collapse.gif" alt="*" /> <a href="#year_', $id, '" id="year_link_', $id, '">', $year['year'], '</a>
  205. </th>
  206. <th align="center" width="15%">', $year['new_topics'], '</th>
  207. <th align="center" width="15%">', $year['new_posts'], '</th>
  208. <th align="center" width="15%">', $year['new_members'], '</th>
  209. <th align="center" width="15%">', $year['most_members_online'], '</th>';
  210. if (!empty($modSettings['hitStats']))
  211. echo '
  212. <th align="center">', $year['hits'], '</th>';
  213. echo '
  214. </tr>';
  215. foreach ($year['months'] as $month)
  216. {
  217. echo '
  218. <tr class="windowbg2" valign="middle" id="tr_month_', $month['id'], '">
  219. <th class="lefttext" width="25%" style="padding-', ($context['right_to_left'] ? 'right' : 'left'), ': 3ex;">
  220. <img src="', $settings['images_url'], '/', $month['expanded'] ? 'collapse.gif' : 'expand.gif', '" alt="" id="img_', $month['id'], '" /> <a id="m', $month['id'], '" href="', $month['href'], '" onclick="return doingExpandCollapse;">', $month['month'], ' ', $month['year'], '</a>
  221. </th>
  222. <th align="center" width="15%">', $month['new_topics'], '</th>
  223. <th align="center" width="15%">', $month['new_posts'], '</th>
  224. <th align="center" width="15%">', $month['new_members'], '</th>
  225. <th align="center" width="15%">', $month['most_members_online'], '</th>';
  226. if (!empty($modSettings['hitStats']))
  227. echo '
  228. <th align="center">', $month['hits'], '</th>';
  229. echo '
  230. </tr>';
  231. if ($month['expanded'])
  232. {
  233. foreach ($month['days'] as $day)
  234. {
  235. echo '
  236. <tr class="windowbg2" valign="middle" align="left" id="tr_day_', $day['year'], '-', $day['month'], '-', $day['day'], '">
  237. <td class="lefttext" style="padding-', ($context['right_to_left'] ? 'right' : 'left'), ': 6ex;">', $day['year'], '-', $day['month'], '-', $day['day'], '</td>
  238. <td align="center">', $day['new_topics'], '</td>
  239. <td align="center">', $day['new_posts'], '</td>
  240. <td align="center">', $day['new_members'], '</td>
  241. <td align="center">', $day['most_members_online'], '</td>';
  242. if (!empty($modSettings['hitStats']))
  243. echo '
  244. <td align="center">', $day['hits'], '</td>';
  245. echo '
  246. </tr>';
  247. }
  248. }
  249. }
  250. }
  251. echo '
  252. </table>
  253. </td></tr>
  254. </table>
  255. <script type="text/javascript" src="', $settings['default_theme_url'], '/scripts/stats.js"></script>
  256. <script type="text/javascript"><!-- // --><![CDATA[
  257. var oStatsCenter = new smf_StatsCenter({
  258. sTableId: \'stats\',
  259. reYearPattern: /year_(\d+)/,
  260. sYearImageCollapsed: \'expand.gif\',
  261. sYearImageExpanded: \'collapse.gif\',
  262. sYearImageIdPrefix: \'year_img_\',
  263. sYearLinkIdPrefix: \'year_link_\',
  264. reMonthPattern: /tr_month_(\d+)/,
  265. sMonthImageCollapsed: \'expand.gif\',
  266. sMonthImageExpanded: \'collapse.gif\',
  267. sMonthImageIdPrefix: \'img_\',
  268. sMonthLinkIdPrefix: \'m\',
  269. reDayPattern: /tr_day_(\d+-\d+-\d+)/,
  270. sDayRowClassname: \'windowbg2\',
  271. sDayRowIdPrefix: \'tr_day_\',
  272. aCollapsedYears: [';
  273. foreach ($context['collapsed_years'] as $id => $year)
  274. {
  275. echo '
  276. \'', $year, '\'', $id != count($context['collapsed_years']) - 1 ? ',' : '';
  277. }
  278. echo '
  279. ],
  280. aDataCells: [
  281. \'date\',
  282. \'new_topics\',
  283. \'new_posts\',
  284. \'new_members\',
  285. \'most_members_online\'', empty($modSettings['hitStats']) ? '' :',
  286. \'hits\'', '
  287. ]
  288. });
  289. // ]]></script>';
  290. }
  291. }