Advertisement
Guest User

MyBB Fehler

a guest
Apr 9th, 2020
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 12.32 KB | None | 0 0
  1. <?php
  2. /**
  3. * MyBB 1.8
  4. * Copyright 2014 MyBB Group, All Rights Reserved
  5. *
  6. * Website: http://www.mybb.com
  7. * License: http://www.mybb.com/about/license
  8. *
  9. */
  10.  
  11. define('IN_MYBB', 1);
  12. define('THIS_SCRIPT', 'index.php');
  13.  
  14. $templatelist = "index,index_whosonline,index_whosonline_memberbit,forumbit_depth1_cat,forumbit_depth2_cat,forumbit_depth2_forum,forumbit_depth1_forum_lastpost,forumbit_depth2_forum_lastpost,forumbit_moderators";
  15. $templatelist .= ",index_birthdays_birthday,index_birthdays,index_logoutlink,index_statspage,index_stats,forumbit_depth3,forumbit_depth3_statusicon,index_boardstats,forumbit_depth2_forum_lastpost_never,forumbit_depth2_forum_viewers";
  16. $templatelist .= ",forumbit_moderators_group,forumbit_moderators_user,forumbit_depth2_forum_lastpost_hidden,forumbit_subforums,forumbit_depth2_forum_unapproved_posts,forumbit_depth2_forum_unapproved_threads";
  17.  
  18. require_once './global.php';
  19. require_once MYBB_ROOT.'inc/functions_forumlist.php';
  20. require_once MYBB_ROOT.'inc/class_parser.php';
  21. $parser = new postParser;
  22.  
  23. $plugins->run_hooks('index_start');
  24.  
  25. // Load global language phrases
  26. $lang->load('index');
  27.  
  28. $logoutlink = '';
  29. if($mybb->user['uid'] != 0)
  30. {
  31. eval('$logoutlink = "'.$templates->get('index_logoutlink').'";');
  32. }
  33.  
  34. $statspage = '';
  35. if($mybb->settings['statsenabled'] != 0)
  36. {
  37. if(!empty($logoutlink))
  38. {
  39. $stats_page_separator = $lang->board_stats_link_separator;
  40. }
  41. eval('$statspage = "'.$templates->get('index_statspage').'";');
  42. }
  43.  
  44. $whosonline = '';
  45. if($mybb->settings['showwol'] != 0 && $mybb->usergroup['canviewonline'] != 0)
  46. {
  47. // Get the online users.
  48. if($mybb->settings['wolorder'] == 'username')
  49. {
  50. $order_by = 'u.username ASC';
  51. $order_by2 = 's.time DESC';
  52. }
  53. else
  54. {
  55. $order_by = 's.time DESC';
  56. $order_by2 = 'u.username ASC';
  57. }
  58.  
  59. $timesearch = TIME_NOW - (int)$mybb->settings['wolcutoff'];
  60.  
  61. $membercount = $guestcount = $anoncount = $botcount = 0;
  62. $forum_viewers = $doneusers = $onlinemembers = $onlinebots = array();
  63.  
  64. if($mybb->settings['showforumviewing'] != 0)
  65. {
  66. $query = $db->query("
  67. SELECT
  68. location1, COUNT(DISTINCT ip) AS guestcount
  69. FROM
  70. ".TABLE_PREFIX."sessions
  71. WHERE uid = 0 AND time > $timesearch
  72. GROUP BY location1
  73. ");
  74.  
  75. while($location = $db->fetch_array($query))
  76. {
  77. $guestcount += $location['guestcount'];
  78.  
  79. if($location['location1'])
  80. {
  81. $forum_viewers[$location['location1']] += $location['guestcount'];
  82. }
  83. }
  84. }
  85. else
  86. {
  87. $query = $db->simple_select("sessions", "COUNT(DISTINCT ip) AS guestcount", "uid = 0 AND time > $timesearch");
  88. $guestcount = $db->fetch_field($query, "guestcount");
  89. }
  90.  
  91. $query = $db->query("
  92. SELECT
  93. s.sid, s.ip, s.uid, s.time, s.location, s.location1, u.username, u.invisible, u.usergroup, u.displaygroup
  94. FROM
  95. ".TABLE_PREFIX."sessions s
  96. LEFT JOIN ".TABLE_PREFIX."users u ON (s.uid=u.uid)
  97. WHERE (s.uid != 0 OR SUBSTR(s.sid,4,1) = '=') AND s.time > $timesearch
  98. ORDER BY {$order_by}, {$order_by2}
  99. ");
  100.  
  101. // Fetch spiders
  102. $spiders = $cache->read('spiders');
  103.  
  104. // Loop through all users.
  105. while($user = $db->fetch_array($query))
  106. {
  107. // Create a key to test if this user is a search bot.
  108. $botkey = my_strtolower(str_replace('bot=', '', $user['sid']));
  109.  
  110. // Decide what type of user we are dealing with.
  111. if($user['uid'] > 0)
  112. {
  113. // The user is registered.
  114. if(empty($doneusers[$user['uid']]) || $doneusers[$user['uid']] < $user['time'])
  115. {
  116. // If the user is logged in anonymously, update the count for that.
  117. if($user['invisible'] == 1)
  118. {
  119. ++$anoncount;
  120. }
  121. ++$membercount;
  122. if($user['invisible'] != 1 || $mybb->usergroup['canviewwolinvis'] == 1 || $user['uid'] == $mybb->user['uid'])
  123. {
  124. // If this usergroup can see anonymously logged-in users, mark them.
  125. if($user['invisible'] == 1)
  126. {
  127. $invisiblemark = '*';
  128. }
  129. else
  130. {
  131. $invisiblemark = '';
  132. }
  133.  
  134. // Properly format the username and assign the template.
  135. $user['username'] = format_name(htmlspecialchars_uni($user['username']), $user['usergroup'], $user['displaygroup']);
  136. $user['profilelink'] = build_profile_link($user['username'], $user['uid']);
  137. eval('$onlinemembers[] = "'.$templates->get('index_whosonline_memberbit', 1, 0).'";');
  138. }
  139. // This user has been handled.
  140. $doneusers[$user['uid']] = $user['time'];
  141. }
  142. }
  143. elseif(my_strpos($user['sid'], 'bot=') !== false && $spiders[$botkey])
  144. {
  145. if($mybb->settings['wolorder'] == 'username')
  146. {
  147. $key = $spiders[$botkey]['name'];
  148. }
  149. else
  150. {
  151. $key = $user['time'];
  152. }
  153.  
  154. // The user is a search bot.
  155. $onlinebots[$key] = format_name($spiders[$botkey]['name'], $spiders[$botkey]['usergroup']);
  156. ++$botcount;
  157. }
  158.  
  159. if($user['location1'])
  160. {
  161. ++$forum_viewers[$user['location1']];
  162. }
  163. }
  164.  
  165. if($mybb->settings['wolorder'] == 'activity')
  166. {
  167. // activity ordering is DESC, username is ASC
  168. krsort($onlinebots);
  169. }
  170. else
  171. {
  172. ksort($onlinebots);
  173. }
  174.  
  175. $onlinemembers = array_merge($onlinebots, $onlinemembers);
  176. if(!empty($onlinemembers))
  177. {
  178. $comma = $lang->comma." ";
  179. $onlinemembers = implode($comma, $onlinemembers);
  180. }
  181. else
  182. {
  183. $onlinemembers = "";
  184. }
  185.  
  186. // Build the who's online bit on the index page.
  187. $onlinecount = $membercount + $guestcount + $botcount;
  188.  
  189. if($onlinecount != 1)
  190. {
  191. $onlinebit = $lang->online_online_plural;
  192. }
  193. else
  194. {
  195. $onlinebit = $lang->online_online_singular;
  196. }
  197. if($membercount != 1)
  198. {
  199. $memberbit = $lang->online_member_plural;
  200. }
  201. else
  202. {
  203. $memberbit = $lang->online_member_singular;
  204. }
  205. if($anoncount != 1)
  206. {
  207. $anonbit = $lang->online_anon_plural;
  208. }
  209. else
  210. {
  211. $anonbit = $lang->online_anon_singular;
  212. }
  213. if($guestcount != 1)
  214. {
  215. $guestbit = $lang->online_guest_plural;
  216. }
  217. else
  218. {
  219. $guestbit = $lang->online_guest_singular;
  220. }
  221. $lang->online_note = $lang->sprintf($lang->online_note, my_number_format($onlinecount), $onlinebit, $mybb->settings['wolcutoffmins'], my_number_format($membercount), $memberbit, my_number_format($anoncount), $anonbit, my_number_format($guestcount), $guestbit);
  222. eval('$whosonline = "'.$templates->get('index_whosonline').'";');
  223. }
  224.  
  225. // Build the birthdays for to show on the index page.
  226. $bdays = $birthdays = '';
  227. if($mybb->settings['showbirthdays'] != 0)
  228. {
  229. // First, see what day this is.
  230. $bdaycount = $bdayhidden = 0;
  231. $bdaydate = my_date('j-n', TIME_NOW, '', 0);
  232. $year = my_date('Y', TIME_NOW, '', 0);
  233.  
  234. $bdaycache = $cache->read('birthdays');
  235.  
  236. if(!is_array($bdaycache))
  237. {
  238. $cache->update_birthdays();
  239. $bdaycache = $cache->read('birthdays');
  240. }
  241.  
  242. $hiddencount = $today_bdays = 0;
  243. if(isset($bdaycache[$bdaydate]))
  244. {
  245. $hiddencount = $bdaycache[$bdaydate]['hiddencount'];
  246. $today_bdays = $bdaycache[$bdaydate]['users'];
  247. }
  248.  
  249. $comma = '';
  250. if(!empty($today_bdays))
  251. {
  252. if((int)$mybb->settings['showbirthdayspostlimit'] > 0)
  253. {
  254. $bdayusers = array();
  255. foreach($today_bdays as $key => $bdayuser_pc)
  256. {
  257. $bdayusers[$bdayuser_pc['uid']] = $key;
  258. }
  259.  
  260. if(!empty($bdayusers))
  261. {
  262. // Find out if our users have enough posts to be seen on our birthday list
  263. $bday_sql = implode(',', array_keys($bdayusers));
  264. $query = $db->simple_select('users', 'uid, postnum', "uid IN ({$bday_sql})");
  265.  
  266. while($bdayuser = $db->fetch_array($query))
  267. {
  268. if($bdayuser['postnum'] < $mybb->settings['showbirthdayspostlimit'])
  269. {
  270. unset($today_bdays[$bdayusers[$bdayuser['uid']]]);
  271. }
  272. }
  273. }
  274. }
  275.  
  276. // We still have birthdays - display them in our list!
  277. if(!empty($today_bdays))
  278. {
  279. foreach($today_bdays as $bdayuser)
  280. {
  281. if($bdayuser['displaygroup'] == 0)
  282. {
  283. $bdayuser['displaygroup'] = $bdayuser['usergroup'];
  284. }
  285.  
  286. // If this user's display group can't be seen in the birthday list, skip it
  287. if($groupscache[$bdayuser['displaygroup']] && $groupscache[$bdayuser['displaygroup']]['showinbirthdaylist'] != 1)
  288. {
  289. continue;
  290. }
  291.  
  292. $age = '';
  293. $bday = explode('-', $bdayuser['birthday']);
  294. if($year > $bday['2'] && $bday['2'] != '')
  295. {
  296. $age = ' ('.($year - $bday['2']).')';
  297. }
  298.  
  299. $bdayuser['username'] = format_name(htmlspecialchars_uni($bdayuser['username']), $bdayuser['usergroup'], $bdayuser['displaygroup']);
  300. $bdayuser['profilelink'] = build_profile_link($bdayuser['username'], $bdayuser['uid']);
  301. eval('$bdays .= "'.$templates->get('index_birthdays_birthday', 1, 0).'";');
  302. ++$bdaycount;
  303. $comma = $lang->comma;
  304. }
  305. }
  306. }
  307.  
  308. if($hiddencount > 0)
  309. {
  310. if($bdaycount > 0)
  311. {
  312. $bdays .= ' - ';
  313. }
  314.  
  315. $bdays .= "{$hiddencount} {$lang->birthdayhidden}";
  316. }
  317.  
  318. // If there are one or more birthdays, show them.
  319. if($bdaycount > 0 || $hiddencount > 0)
  320. {
  321. eval('$birthdays = "'.$templates->get('index_birthdays').'";');
  322. }
  323. }
  324.  
  325. // Build the forum statistics to show on the index page.
  326. $forumstats = '';
  327. if($mybb->settings['showindexstats'] != 0)
  328. {
  329. // First, load the stats cache.
  330. $stats = $cache->read('stats');
  331.  
  332. // Check who's the newest member.
  333. if(!$stats['lastusername'])
  334. {
  335. $newestmember = $lang->nobody;;
  336. }
  337. else
  338. {
  339. $newestmember = build_profile_link($stats['lastusername'], $stats['lastuid']);
  340. }
  341.  
  342. // Format the stats language.
  343. $lang->stats_posts_threads = $lang->sprintf($lang->stats_posts_threads, my_number_format($stats['numposts']), my_number_format($stats['numthreads']));
  344. $lang->stats_numusers = $lang->sprintf($lang->stats_numusers, my_number_format($stats['numusers']));
  345. $lang->stats_newestuser = $lang->sprintf($lang->stats_newestuser, $newestmember);
  346.  
  347. // Find out what the highest users online count is.
  348. $mostonline = $cache->read('mostonline');
  349. if($onlinecount > $mostonline['numusers'])
  350. {
  351. $time = TIME_NOW;
  352. $mostonline['numusers'] = $onlinecount;
  353. $mostonline['time'] = $time;
  354. $cache->update('mostonline', $mostonline);
  355. }
  356. $recordcount = $mostonline['numusers'];
  357. $recorddate = my_date($mybb->settings['dateformat'], $mostonline['time']);
  358. $recordtime = my_date($mybb->settings['timeformat'], $mostonline['time']);
  359.  
  360. // Then format that language string.
  361. $lang->stats_mostonline = $lang->sprintf($lang->stats_mostonline, my_number_format($recordcount), $recorddate, $recordtime);
  362.  
  363. eval('$forumstats = "'.$templates->get('index_stats').'";');
  364. }
  365.  
  366. // Show the board statistics table only if one or more index statistics are enabled.
  367. $boardstats = '';
  368. if(($mybb->settings['showwol'] != 0 && $mybb->usergroup['canviewonline'] != 0) || $mybb->settings['showindexstats'] != 0 || ($mybb->settings['showbirthdays'] != 0 && $bdaycount > 0))
  369. {
  370. if(!isset($stats) || isset($stats) && !is_array($stats))
  371. {
  372. // Load the stats cache.
  373. $stats = $cache->read('stats');
  374. }
  375.  
  376. $expaltext = (in_array("boardstats", $collapse)) ? "[+]" : "[-]";
  377. eval('$boardstats = "'.$templates->get('index_boardstats').'";');
  378. }
  379.  
  380. if($mybb->user['uid'] == 0)
  381. {
  382. // Build a forum cache.
  383. $query = $db->simple_select('forums', '*', 'active!=0', array('order_by' => 'pid, disporder'));
  384.  
  385. $forumsread = array();
  386. if(isset($mybb->cookies['mybb']['forumread']))
  387. {
  388. $forumsread = my_unserialize($mybb->cookies['mybb']['forumread']);
  389. }
  390. }
  391. else
  392. {
  393. // Build a forum cache.
  394. $query = $db->query("
  395. SELECT f.*, fr.dateline AS lastread
  396. FROM ".TABLE_PREFIX."forums f
  397. LEFT JOIN ".TABLE_PREFIX."forumsread fr ON (fr.fid = f.fid AND fr.uid = '{$mybb->user['uid']}')
  398. WHERE f.active != 0
  399. ORDER BY pid, disporder
  400. ");
  401. }
  402.  
  403. while($forum = $db->fetch_array($query))
  404. {
  405. if($mybb->user['uid'] == 0)
  406. {
  407. if(!empty($forumsread[$forum['fid']]))
  408. {
  409. $forum['lastread'] = $forumsread[$forum['fid']];
  410. }
  411. }
  412. $fcache[$forum['pid']][$forum['disporder']][$forum['fid']] = $forum;
  413. }
  414. $forumpermissions = forum_permissions();
  415.  
  416. // Get the forum moderators if the setting is enabled.
  417. $moderatorcache = array();
  418. if($mybb->settings['modlist'] != 0 && $mybb->settings['modlist'] != 'off')
  419. {
  420. $moderatorcache = $cache->read('moderators');
  421. }
  422.  
  423. $excols = 'index';
  424. $permissioncache['-1'] = '1';
  425. $bgcolor = 'trow1';
  426.  
  427. // Decide if we're showing first-level subforums on the index page.
  428. $showdepth = 2;
  429. if($mybb->settings['subforumsindex'] != 0)
  430. {
  431. $showdepth = 3;
  432. }
  433.  
  434. $forum_list = build_forumbits();
  435. $forums = $forum_list['forum_list'];
  436.  
  437. $plugins->run_hooks('index_end');
  438.  
  439. eval('$index = "'.$templates->get('index').'";');
  440. output_page($index);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement