PageRenderTime 40ms CodeModel.GetById 13ms RepoModel.GetById 1ms app.codeStats 0ms

/online.php

https://github.com/CasperGemini/e107
PHP | 322 lines | 255 code | 27 blank | 40 comment | 36 complexity | cef1ff06e95422cdbd87c8acdac7d224 MD5 | raw file
Possible License(s): GPL-2.0
  1. <?php
  2. /*
  3. + ----------------------------------------------------------------------------+
  4. | e107 website system
  5. |
  6. | Copyright (C) 2008-2009 e107 Inc
  7. | http://e107.org
  8. |
  9. |
  10. | Released under the terms and conditions of the
  11. | GNU General Public License (http://gnu.org).
  12. |
  13. | $Source: /cvs_backup/e107_0.8/online.php,v $
  14. | $Revision$
  15. | $Date$
  16. | $Author$
  17. +----------------------------------------------------------------------------+
  18. */
  19. /**
  20. * @package e107
  21. * @subpackage user
  22. * @version $Id$;
  23. *
  24. * Display list of online users, and the pages they're viewing
  25. */
  26. require_once('class2.php');
  27. include_lan(e_LANGUAGEDIR.e_LANGUAGE.'/lan_'.e_PAGE);
  28. require_once(HEADERF);
  29. if (!$pref['track_online'])
  30. {
  31. $ns->tablerender(ONLINE_EL4, ONLINE_EL16);
  32. require_once(FOOTERF);
  33. exit;
  34. }
  35. if (file_exists(THEME."online_template.php"))
  36. {
  37. require_once(THEME."online_template.php");
  38. }
  39. else
  40. {
  41. require_once(e_CORE."templates/online_template.php");
  42. }
  43. global $listuserson;
  44. foreach($listuserson as $uinfo => $pinfo)
  45. {
  46. $class_check = TRUE;
  47. list($oid, $oname) = explode(".", $uinfo, 2);
  48. $online_location = $pinfo;
  49. $online_location_page = substr(strrchr($online_location, "/"), 1);
  50. if (!strstr($online_location, "forum_") || !strstr($online_location, "content.php") || !strstr($online_location, "comment.php"))
  51. {
  52. $online_location_page = str_replace(".php", "", substr(strrchr($online_location, "/"), 1));
  53. }
  54. switch ($online_location_page)
  55. {
  56. case 'log' :
  57. case 'error' :
  58. $online_location = "news.php";
  59. $online_location_page = NEWS;
  60. break;
  61. case 'request' :
  62. $online_location = "download.php";
  63. break;
  64. case 'chat' :
  65. $online_location_page = CHAT;
  66. break;
  67. case 'content' :
  68. $online_location_page = CONTENT;
  69. break;
  70. case 'download' :
  71. $online_location_page = DOWNLOAD;
  72. break;
  73. case 'email' :
  74. $online_location_page = EMAIL;
  75. break;
  76. case 'forum' :
  77. $online_location_page = FORUM;
  78. break;
  79. case 'links' :
  80. $online_location_page = LINKS;
  81. break;
  82. case 'news' :
  83. $online_location_page = NEWS;
  84. break;
  85. case 'login' :
  86. $online_location_page = LOGIN;
  87. break;
  88. case 'search' :
  89. $online_location_page = SEARCH;
  90. break;
  91. case 'submitnews' :
  92. $online_location_page = SUBMITNEWS;
  93. break;
  94. case 'upload' :
  95. $online_location_page = UPLOAD;
  96. break;
  97. case 'user' :
  98. $online_location_page = USERPAGE;
  99. break;
  100. case 'usersettings' :
  101. $online_location_page = USERSETTINGS;
  102. break;
  103. case 'new' :
  104. $online_location_page = LISTNEW;
  105. break;
  106. case 'online' :
  107. $online_location_page = ONLINE;
  108. break;
  109. case 'userposts' :
  110. $online_location_page = USERPOSTS;
  111. break;
  112. case 'subcontent' :
  113. $online_location_page = SUBCONTENT;
  114. break;
  115. case 'top' :
  116. $online_location_page = TOP;
  117. break;
  118. case 'oldpolls' :
  119. $online_location_page = OLDPOLLS;
  120. break;
  121. //commonly used plugin pages
  122. case 'bugtracker' :
  123. $online_location_page = BUGTRACKER;
  124. break;
  125. case 'event' :
  126. $online_location_page = EVENT;
  127. break;
  128. case 'calendar' :
  129. $online_location_page = CALENDAR;
  130. break;
  131. case 'pm' :
  132. $online_location_page = PM;
  133. break;
  134. case 'survey' :
  135. $online_location_page = SURVEY;
  136. break;
  137. case 'faq' :
  138. $online_location_page = FAQ;
  139. break;
  140. default :
  141. $online_location_page = OTHER.$online_location_page;
  142. }
  143. /*
  144. Think these are no longer used
  145. case 'article' :
  146. $online_location_page = ARTICLEPAGE;
  147. break;
  148. if ($online_location_page == "oldpolls") {
  149. $online_location_page = OLDPOLLS;
  150. }
  151. if ($online_location_page == "print") {
  152. $online_location_page = PRINTPAGE;
  153. }
  154. if ($online_location_page == "stats") {
  155. $online_location_page = STATS;
  156. }
  157. */
  158. if (strstr($online_location, "content.php"))
  159. {
  160. $tmp = explode(".", substr(strrchr($online_location, "php."), 2));
  161. if ($tmp[0] == "article") {
  162. $sql->db_Select("content", "content_heading, content_class", "content_id='".intval($tmp[1])."'");
  163. $content = $sql->db_Fetch();
  164. $online_location_page = ARTICLE.": ".$content['content_heading'];
  165. $online_location = str_replace("php.", "php?", $online_location);
  166. if (!check_class($content['content_class'])) {
  167. $class_check = FALSE;
  168. $online_location_page = ARTICLE.": \"".CLASSRESTRICTED."\"";
  169. }
  170. } elseif($tmp[0] == "review") {
  171. $sql->db_Select("content", "content_heading, content_class", "content_id='".intval($tmp[1])."'");
  172. $content = $sql->db_Fetch();
  173. $online_location_page = REVIEW.": ".$content['content_heading'];
  174. $online_location = str_replace("php.", "php?", $online_location);
  175. if (!check_class($content['content_class'])) {
  176. $class_check = FALSE;
  177. $online_location_page = REVIEW.": \"".CLASSRESTRICTED."\"";
  178. }
  179. } elseif($tmp[0] == "content") {
  180. $sql->db_Select("content", "content_heading, content_class", "content_id='".intval($tmp[1])."'");
  181. $content = $sql->db_Fetch();
  182. $online_location_page = CONTENT.": ".$content['content_heading'];
  183. $online_location = str_replace("php.", "php?", $online_location);
  184. if (!check_class($content['content_class'])) {
  185. $class_check = FALSE;
  186. $online_location_page = CONTENT.": \"".CLASSRESTRICTED."\"";
  187. }
  188. }
  189. }
  190. if (strstr($online_location, "comment.php"))
  191. {
  192. $tmp = explode(".php.", $online_location);
  193. $tmp = explode(".", $tmp[1]);
  194. if ($tmp[1] == "news") {
  195. $id = ($tmp[0] == "reply" ? $tmp[3] : $tmp[2]);
  196. $sql->db_Select("news", "news_title, news_class", "news_id=".intval($id));
  197. $news = $sql->db_Fetch();
  198. $online_location_page = ($tmp[0] == "reply" ? COMMENT.": ".ONLINE_EL12." > ".$news['news_title'] : COMMENT.": ".$news['news_title']);
  199. $online_location = "comment.php?comment.news.$id";
  200. if (!check_class($news['news_class'])) {
  201. $class_check = FALSE;
  202. $online_location_page = COMMENT.": \"".CLASSRESTRICTED."\"";
  203. }
  204. } elseif($tmp[1] == "poll") {
  205. $id = ($tmp[0] == "reply" ? $tmp[3] : $tmp[2]);
  206. $sql->db_Select("poll", "poll_title", "poll_id=".intval($id));
  207. $poll = $sql->db_Fetch();
  208. $online_location_page = POLLCOMMENT.": ".$poll['poll_title'];
  209. $online_location = "comment.php?comment.poll.$id";
  210. } else {
  211. $online_location_page = COMMENT;
  212. $class_check = FALSE;
  213. }
  214. }
  215. if (strstr($online_location, "forum"))
  216. {
  217. $tmp = explode(".", substr(strrchr($online_location, "php."), 2));
  218. if (strstr($online_location, "_viewtopic")) {
  219. if ($tmp[2]) {
  220. $pref['forum_postspage'] = ($pref['forum_postspage'] ? $pref['forum_postspage'] : 10);
  221. $t_page = $tmp[2]/$pref['forum_postspage'] +1;
  222. } else {
  223. $t_page = 1;
  224. }
  225. $qry = "
  226. SELECT t.thread_name, f.forum_name, f.forum_class from #forum_thread AS t
  227. LEFT JOIN #forum AS f ON f.forum_id = t.thread_forum_id
  228. WHERE t.thread_id = ".intval($tmp[0])
  229. ;
  230. $sql->db_Select_gen($qry);
  231. $forum = $sql->db_Fetch();
  232. $online_location_page = ONLINE_EL13." .:. ".$forum['forum_name']."->".ONLINE_EL14." .:. ".$forum['thread_name']."->".ONLINE_EL15.": ".$t_page;
  233. $online_location = str_replace("php.", "php?", $online_location);
  234. if (!check_class($forum['forum_class'])) {
  235. $class_check = FALSE;
  236. $online_location_page = ONLINE_EL13.": \"".CLASSRESTRICTED."\"";
  237. }
  238. } elseif(strstr($online_location, "_viewforum")) {
  239. $sql->db_Select("forum", "forum_name, forum_class", "forum_id=".intval($tmp[0]));
  240. $forum = $sql->db_Fetch();
  241. $online_location_page = ONLINE_EL13." .:. ".$forum['forum_name'];
  242. $online_location = str_replace("php.", "php?", $online_location);
  243. if (!check_class($forum['forum_class'])) {
  244. $class_check = FALSE;
  245. $online_location_page = ONLINE_EL13.": \"".CLASSRESTRICTED."\"";
  246. }
  247. } elseif(strstr($online_location, "_post")) {
  248. $sql->db_Select("forum_thread", "thread_name, thread_forum_id", "thread_forum_id=".intval($tmp[0])." AND thread_parent=0");
  249. $forum_thread = $sql->db_Fetch();
  250. $sql->db_Select("forum", "forum_name", "forum_id=".$forum_thread['thread_forum_id']);
  251. $forum = $sql->db_Fetch();
  252. $online_location_page = ONLINE_EL12.": ".ONLINE_EL13." .:. ".$forum['forum_name']."->".ONLINE_EL14." .:. ".$forum_thread['thread_name'];
  253. $online_location = e_PLUGIN."forum/forum_viewtopic.php?$tmp[0].$tmp[1]";
  254. }
  255. }
  256. if (strstr($online_location, "admin"))
  257. {
  258. $class_check = FALSE;
  259. $online_location_page = ADMINAREA;
  260. }
  261. $ONLINE_TABLE_ICON = (varsettrue($pref['plug_installed']['pm']) && $oid != USERID ? $tp->parseTemplate("{SENDPM={$oid}}", 'sendpm.sc') : "<img src='".e_PLUGIN."online_extended_menu/images/user.png' alt='' style='vertical-align:middle' />");
  262. $ONLINE_TABLE_USERNAME = "<a href='".e_BASE."user.php?id.$oid'>{$oname}</a>";
  263. $ONLINE_TABLE_LOCATION = ($class_check ? "<a href='{$online_location}'>{$online_location_page}</a>" : $online_location_page);
  264. $textstring .= preg_replace("/\{(.*?)\}/e", '$\1', $ONLINE_TABLE);
  265. }
  266. $ONLINE_TABLE_MEMBERS_ONLINE = ONLINE_EL1.GUESTS_ONLINE;
  267. $ONLINE_TABLE_GUESTS_ONLINE = ONLINE_EL2.MEMBERS_ONLINE;
  268. if (!isset($gen) || !is_object($gen))
  269. {
  270. $gen = new convert;
  271. }
  272. $siteHistory = e107::getConfig('history')->getPref('');
  273. $datestamp = $gen->convert_date($siteHistory['most_online_datestamp'], "short");
  274. $ONLINE_TABLE_MOST_EVER_ONLINE = ONLINE_EL8.($siteHistory['most_members_online'] + $siteHistory['most_guests_online']);
  275. $ONLINE_TABLE_MOST_MEMBERS_ONLINE = ONLINE_EL2.$siteHistory['most_members_online'];
  276. $ONLINE_TABLE_MOST_GUESTS_ONLINE = ONLINE_EL1.$siteHistory['most_guests_online'];
  277. $ONLINE_TABLE_DATESTAMP = $datestamp;
  278. $total_members = $sql->db_Count("user","(*)","where user_ban = 0");
  279. if ($total_members > 1)
  280. {
  281. $newest_member = $sql->db_Select("user", "user_id, user_name", "user_ban=0 ORDER BY user_join DESC LIMIT 0,1");
  282. $row = $sql->db_Fetch();
  283. $ONLINE_TABLE_MEMBERS_TOTAL = "<br />".ONLINE_EL5.": ".$total_members;
  284. $ONLINE_TABLE_MEMBERS_NEWEST = "<br />".ONLINE_EL6.": ".(USER ? "<a href='".e_BASE."user.php?id.".$row['user_id']."'>".$row['user_name']."</a>" : $row['user_name']);
  285. }
  286. $text = '';
  287. if (count($listuserson))
  288. {
  289. $textstart = preg_replace("/\{(.*?)\}/e", '$\1', $ONLINE_TABLE_START);
  290. $textend = preg_replace("/\{(.*?)\}/e", '$\1', $ONLINE_TABLE_END);
  291. $text = $textstart.$textstring.$textend;
  292. }
  293. $text .= preg_replace("/\{(.*?)\}/e", '$\1', $ONLINE_TABLE_MISC);
  294. $ns->tablerender(ONLINE_EL4, $text);
  295. require_once(FOOTERF);