PageRenderTime 39ms CodeModel.GetById 18ms RepoModel.GetById 0ms app.codeStats 0ms

/index.php

https://bitbucket.org/GlitchMr/abxd
PHP | 196 lines | 132 code | 36 blank | 28 comment | 34 complexity | 098be905333a9c21ef8604299fc4fae0 MD5 | raw file
  1. <?php
  2. $ajaxPage = false;
  3. if(isset($_GET["ajax"]))
  4. $ajaxPage = true;
  5. require('lib/common.php');
  6. //TODO: Put this in a proper place.
  7. function getBirthdaysText()
  8. {
  9. $rBirthdays = Query("select birthday, id, name, displayname, powerlevel, sex from users where birthday > 0 order by name");
  10. $birthdays = array();
  11. while($user = Fetch($rBirthdays))
  12. {
  13. $bucket = "userMangler"; include("./lib/pluginloader.php");
  14. $b = $user['birthday'];
  15. if(gmdate("m-d", $b) == gmdate("m-d"))
  16. {
  17. $y = gmdate("Y") - gmdate("Y", $b);
  18. $birthdays[] = UserLink($user)." (".$y.")";
  19. }
  20. }
  21. if(count($birthdays))
  22. $birthdaysToday = implode(", ", $birthdays);
  23. if($birthdaysToday)
  24. return "<br>".__("Birthdays today:")." ".$birthdaysToday;
  25. else
  26. return "";
  27. }
  28. //=======================
  29. // Do the page
  30. $page = $_GET["page"];
  31. if(!isset($page))
  32. $page = "index";
  33. if(!ctype_alnum($page))
  34. $page = "index";
  35. if($page == "index")
  36. {
  37. if(isset($_GET['fid']) && (int)$_GET['fid'] > 0 && !isset($_GET['action']))
  38. die(header("Location: ".actionLink("forum", (int)$_GET['fid'])));
  39. if(isset($_GET['tid']) && (int)$_GET['tid'] > 0)
  40. die(header("Location: ".actionLink("thread", (int)$_GET['tid'])));
  41. if(isset($_GET['uid']) && (int)$_GET['uid'] > 0)
  42. die(header("Location: ".actionLink("profile", (int)$_GET['uid'])));
  43. if(isset($_GET['pid']) && (int)$_GET['pid'] > 0)
  44. die(header("Location: ".actionLink("thread", "", "pid=".(int)$_GET['pid']."#".(int)$_GET['pid'])));
  45. }
  46. ob_start();
  47. $layout_crumbs = "";
  48. try {
  49. try {
  50. if(array_key_exists($page, $pluginpages))
  51. {
  52. $self = $plugins[$pluginpages[$page]];
  53. $selfsettings = Settings::$pluginsettings[$pluginpages[$page]];
  54. $page = "./plugins/".$plugins[$pluginpages[$page]]['dir']."/page_".$page.".php";
  55. if(!file_exists($page))
  56. throw new Exception(404);
  57. include($page);
  58. unset($self);
  59. }
  60. else {
  61. $page = 'pages/'.$page.'.php';
  62. if(!file_exists($page))
  63. throw new Exception(404);
  64. include($page);
  65. }
  66. }
  67. catch(Exception $e) {
  68. if ($e->getMessage() != 404) {
  69. throw $e;
  70. }
  71. require('pages/404.php');
  72. }
  73. }
  74. catch(KillException $e) {
  75. // Nothing. Just ignore this exception.
  76. }
  77. if($ajaxPage)
  78. {
  79. ob_end_flush();
  80. die();
  81. }
  82. $layout_contents = ob_get_contents();
  83. ob_end_clean();
  84. //Do this only if it's not an ajax page.
  85. include("lib/views.php");
  86. //=======================
  87. // Panels and footer
  88. ob_start();
  89. require('navigation.php');
  90. $layout_navigation = ob_get_contents();
  91. ob_end_clean();
  92. ob_start();
  93. require('userpanel.php');
  94. $layout_userpanel = ob_get_contents();
  95. ob_end_clean();
  96. ob_start();
  97. require('footer.php');
  98. $layout_footer = ob_get_contents();
  99. ob_end_clean();
  100. //=======================
  101. // Notification bars
  102. ob_start();
  103. $bucket = "userBar"; include("./lib/pluginloader.php");
  104. /*
  105. if($rssBar)
  106. {
  107. write("
  108. <div style=\"float: left; width: {1}px;\">&nbsp;</div>
  109. <div id=\"rss\">
  110. {0}
  111. </div>
  112. ", $rssBar, $rssWidth + 4);
  113. }*/
  114. DoPrivateMessageBar();
  115. $bucket = "topBar"; include("./lib/pluginloader.php");
  116. $layout_bars = ob_get_contents();
  117. ob_end_clean();
  118. //=======================
  119. // Misc stuff
  120. $layout_time = formatdatenow();
  121. $layout_onlineusers = getOnlineUsersText();
  122. $layout_birthdays = getBirthdaysText();
  123. $layout_views = __("Views:")." ".'<span id="viewCount">'.number_format($misc['views']).'</span>';
  124. $layout_title = htmlspecialchars(Settings::get("boardname"));
  125. if($title != "")
  126. $layout_title .= " &raquo; ".$title;
  127. //=======================
  128. // Board logo and theme
  129. if(file_exists("themes/$theme/logo.png"))
  130. $layout_logopic = themeResourceLink("logo.png");
  131. else if(file_exists("themes/$theme/logo.jpg"))
  132. $layout_logopic = themeResourceLink("logo.jpg");
  133. else if(file_exists("themes/$theme/logo.gif"))
  134. $layout_logopic = themeResourceLink("logo.gif");
  135. else
  136. $layout_logopic = resourceLink("img/logo.png");
  137. $layout_themefile = "themes/$theme/style.css";
  138. if(!file_exists($layout_themefile))
  139. $layout_themefile = "themes/$theme/style.php";
  140. $layout_contents = "<div id=\"page_contents\">$layout_contents</div>";
  141. //=======================
  142. // PoRA box
  143. if(Settings::get("showPoRA"))
  144. {
  145. $layout_pora = '
  146. <div class="PoRT nom">
  147. <table class="message">
  148. <tr class="header0"><th>'.Settings::get("PoRATitle").'</th></tr>
  149. <tr class="cell0"><td>'.Settings::get("PoRAText").'</td></tr>
  150. </table>
  151. </div>';
  152. }
  153. else
  154. $layout_pora = "";
  155. //=======================
  156. // Print everything!
  157. $layout = Settings::get("defaultLayout");
  158. //$layout_contents.="<br>".nl2br(htmlspecialchars($querytext));
  159. require("layouts/$layout.php");
  160. ?>