PageRenderTime 52ms CodeModel.GetById 26ms RepoModel.GetById 1ms app.codeStats 0ms

/public_html/forum/archive/global.php

https://github.com/openstate/Watstemtmijnraad
PHP | 200 lines | 156 code | 20 blank | 24 comment | 31 complexity | cddc62eb95463f8a0f38e0b3aedb5f70 MD5 | raw file
  1. <?php
  2. /**
  3. * MyBB 1.4
  4. * Copyright © 2008 MyBB Group, All Rights Reserved
  5. *
  6. * Website: http://www.mybboard.net
  7. * License: http://www.mybboard.net/about/license
  8. *
  9. * $Id: global.php 4324 2009-03-05 21:23:18Z Tikitiki $
  10. */
  11. // If archive mode does not work, uncomment the line below and try again
  12. // define("ARCHIVE_QUERY_STRINGS", 1);
  13. // Lets pretend we're a level higher
  14. chdir('./../');
  15. require_once dirname(dirname(__FILE__))."/inc/init.php";
  16. require_once MYBB_ROOT."inc/functions_archive.php";
  17. require_once MYBB_ROOT."inc/class_session.php";
  18. require_once MYBB_ROOT."inc/class_parser.php";
  19. $parser = new postParser;
  20. $groupscache = $cache->read("usergroups");
  21. if(!is_array($groupscache))
  22. {
  23. $cache->update_usergroups();
  24. $groupscache = $cache->read("usergroups");
  25. }
  26. $fpermissioncache = $cache->read("forumpermissions");
  27. // Send headers before anything else.
  28. send_page_headers();
  29. // If the installer has not been removed and no lock exists, die.
  30. if(is_dir(MYBB_ROOT."install") && !file_exists(MYBB_ROOT."install/lock"))
  31. {
  32. echo "Please remove the install directory from your server, or create a file called 'lock' in the install directory. Until you do so, your board will remain unaccessable";
  33. exit;
  34. }
  35. // If the server OS is not Windows and not Apache or the PHP is running as a CGI or we have defined ARCHIVE_QUERY_STRINGS, use query strings - DIRECTORY_SEPARATOR checks if running windows
  36. if((DIRECTORY_SEPARATOR == '\\' && stripos($_SERVER['SERVER_SOFTWARE'], 'apache') == false) || stripos(SAPI_NAME, 'cgi') !== false || defined("ARCHIVE_QUERY_STRINGS"))
  37. {
  38. $url = $_SERVER['QUERY_STRING'];
  39. $base_url = $mybb->settings['bburl']."/archive/index.php?";
  40. $endpart = $url;
  41. }
  42. // Otherwise, we're using 100% friendly URLs
  43. else
  44. {
  45. if($_SERVER['REQUEST_URI'])
  46. {
  47. $url = $_SERVER['REQUEST_URI'];
  48. }
  49. elseif($_SERVER['REDIRECT_URL'])
  50. {
  51. $url = $_SERVER['REDIRECT_URL'];
  52. }
  53. elseif($_SERVER['PATH_INFO'])
  54. {
  55. $url = $_SERVER['PATH_INFO'];
  56. }
  57. else
  58. {
  59. $url = $_SERVER['PHP_SELF'];
  60. }
  61. $base_url = $mybb->settings['bburl']."/archive/index.php/";
  62. $endpart = my_substr(strrchr($url, "/"), 1);
  63. }
  64. $action = "index";
  65. // This seems to work the same as the block below except without the css bugs O_o
  66. $archiveurl = $mybb->settings['bburl'].'/archive';
  67. if($endpart != "index.php")
  68. {
  69. $endpart = str_replace(".html", "", $endpart);
  70. $todo = explode("-", $endpart, 3);
  71. if($todo[0])
  72. {
  73. $action = $todo[0];
  74. }
  75. $page = intval($todo[2]);
  76. $id = intval($todo[1]);
  77. // Get the thread, announcement or forum information.
  78. if($action == "announcement")
  79. {
  80. $time = TIME_NOW;
  81. $query = $db->query("
  82. SELECT a.*, u.username
  83. FROM ".TABLE_PREFIX."announcements a
  84. LEFT JOIN ".TABLE_PREFIX."users u ON (u.uid=a.uid)
  85. WHERE a.aid='{$id}' AND startdate < '{$time}' AND (enddate > '{$time}' OR enddate = 0)
  86. ");
  87. $announcement = $db->fetch_array($query);
  88. if(!$announcement['aid'])
  89. {
  90. $action = "404";
  91. }
  92. }
  93. elseif($action == "thread")
  94. {
  95. $query = $db->simple_select("threads", "*", "tid='{$id}' AND visible='1' AND closed NOT LIKE 'moved|%'");
  96. $thread = $db->fetch_array($query);
  97. if(!$thread['tid'])
  98. {
  99. $action = "404";
  100. }
  101. }
  102. elseif($action == "forum")
  103. {
  104. $query = $db->simple_select("forums", "*", "fid='{$id}' AND active!=0 AND password=''");
  105. $forum = $db->fetch_array($query);
  106. if(!$forum['fid'])
  107. {
  108. $action = "404";
  109. }
  110. }
  111. else if($action != 'index')
  112. {
  113. $action = "404";
  114. }
  115. }
  116. // Define the full MyBB version location of this page.
  117. if($action == "thread")
  118. {
  119. define(MYBB_LOCATION, get_thread_link($id));
  120. }
  121. elseif($action == "forum")
  122. {
  123. define(MYBB_LOCATION, get_forum_link($id));
  124. }
  125. elseif($action == "announcement")
  126. {
  127. define(MYBB_LOCATION, get_announcement_link($id));
  128. }
  129. else
  130. {
  131. define(MYBB_LOCATION, INDEX_URL);
  132. }
  133. // Initialise session
  134. $session = new session;
  135. $session->init();
  136. if(!$mybb->settings['bblanguage'])
  137. {
  138. $mybb->settings['bblanguage'] = "english";
  139. }
  140. $lang->set_language($mybb->settings['bblanguage']);
  141. // Load global language phrases
  142. $lang->load("global");
  143. $lang->load("messages");
  144. $lang->load("archive");
  145. // Draw up the basic part of our naviagation
  146. $navbits[0]['name'] = $mybb->settings['bbname_orig'];
  147. $navbits[0]['url'] = $mybb->settings['bburl']."/archive/index.php";
  148. // Check banned ip addresses
  149. if(is_banned_ip($session->ipaddress))
  150. {
  151. archive_error($lang->error_banned);
  152. }
  153. // If our board is closed..
  154. if($mybb->settings['boardclosed'] == 1)
  155. {
  156. if($mybb->usergroup['cancp'] != 1)
  157. {
  158. $lang->error_boardclosed .= "<blockquote>".$mybb->settings['boardclosed_reason']."</blockquote>";
  159. archive_error($lang->error_boardclosed);
  160. }
  161. }
  162. // Load Limiting - DIRECTORY_SEPARATOR checks if running windows
  163. if(DIRECTORY_SEPARATOR != '\\')
  164. {
  165. if($uptime = @exec('uptime'))
  166. {
  167. preg_match("/averages?: ([0-9\.]+),[\s]+([0-9\.]+),[\s]+([0-9\.]+)/", $uptime, $regs);
  168. $load = $regs[1];
  169. if($mybb->usergroup['cancp'] != 1 && $load > $mybb->settings['load'] && $mybb->settings['load'] > 0)
  170. {
  171. archive_error($lang->error_loadlimit);
  172. }
  173. }
  174. }
  175. if($mybb->usergroup['canview'] == 0)
  176. {
  177. archive_error_no_permission();
  178. }
  179. ?>