PageRenderTime 40ms CodeModel.GetById 12ms RepoModel.GetById 0ms app.codeStats 0ms

/htdocs/yurivn/archive/global.php

https://gitlab.com/trang1104/portable_project
PHP | 363 lines | 259 code | 56 blank | 48 comment | 39 complexity | f0632d5fe7ce4537a482d380dfde5a71 MD5 | raw file
Possible License(s): GPL-2.0, BSD-2-Clause, AGPL-1.0, Apache-2.0, GPL-3.0, MPL-2.0, LGPL-3.0, LGPL-2.0, LGPL-2.1, MPL-2.0-no-copyleft-exception, BSD-3-Clause
  1. <?php
  2. /*======================================================================*\
  3. || #################################################################### ||
  4. || # vBulletin 4.2.2 Alpha 1 - Licence Number VBFSA2W3VC
  5. || # ---------------------------------------------------------------- # ||
  6. || # Copyright ©2000-2013 vBulletin Solutions Inc. All Rights Reserved. ||
  7. || # This file may not be redistributed in whole or significant part. # ||
  8. || # ---------------- VBULLETIN IS NOT FREE SOFTWARE ---------------- # ||
  9. || # http://www.vbulletin.com | http://www.vbulletin.com/license.html # ||
  10. || #################################################################### ||
  11. \*======================================================================*/
  12. // identify where we are
  13. define('VB_AREA', 'Archive');
  14. // ###################### Start initialisation #######################
  15. chdir('./../');
  16. define('CWD', (($getcwd = getcwd()) ? $getcwd : '.'));
  17. require_once(CWD . '/includes/init.php');
  18. // ###################### Start headers #######################
  19. exec_headers();
  20. // ############ Some stuff for the gmdate bug ####################
  21. $vbulletin->options['hourdiff'] = (date('Z', TIMENOW) / 3600 - $vbulletin->userinfo['timezoneoffset']) * 3600;
  22. // ###################### Get date / time info #######################
  23. fetch_options_overrides($vbulletin->userinfo);
  24. fetch_time_data();
  25. // ############################################ LANGUAGE STUFF ####################################
  26. // initialize $vbphrase and set language constants
  27. $vbphrase = init_language();
  28. // ###################### Start templates & styles #######################
  29. // allow archive to use a non-english language
  30. $styleid = intval($vbulletin->options['styleid']);
  31. ($hook = vBulletinHook::fetch_hook('style_fetch')) ? eval($hook) : false;
  32. $style = $db->query_first_slave("
  33. SELECT * FROM " . TABLE_PREFIX . "style
  34. WHERE styleid = $styleid
  35. ");
  36. fetch_stylevars($style, $vbulletin->userinfo);
  37. if ((strtoupper(substr(PHP_OS, 0, 3)) == 'WIN' AND stristr($_SERVER['SERVER_SOFTWARE'], 'apache') === false) OR (strpos(SAPI_NAME, 'cgi') !== false AND @!ini_get('cgi.fix_pathinfo')))
  38. {
  39. define('SLASH_METHOD', false);
  40. }
  41. else
  42. {
  43. define('SLASH_METHOD', true);
  44. }
  45. if (SLASH_METHOD)
  46. {
  47. $archive_info = $_SERVER['REQUEST_URI'] ? $_SERVER['REQUEST_URI'] : $_SERVER['PHP_SELF'];
  48. }
  49. else
  50. {
  51. $archive_info = $_SERVER['QUERY_STRING'];
  52. }
  53. if ($vbulletin->session->visible)
  54. {
  55. if (SLASH_METHOD)
  56. {
  57. define('ARCHIVE_SESSION_URL', '?s=' . $vbulletin->session->vars['sessionhash']);
  58. }
  59. else
  60. {
  61. define('ARCHIVE_SESSION_URL', '&amp;s=' . $vbulletin->session->vars['sessionhash']);
  62. }
  63. }
  64. else
  65. {
  66. define('ARCHIVE_SESSION_URL', '');
  67. }
  68. // check to see if server is too busy. this is checked at the end of session.php
  69. if ((server_overloaded() AND $vbulletin->userinfo['usergroupid'] != 6) OR $vbulletin->options['archiveenabled'] == 0)
  70. {
  71. exec_header_redirect(fetch_seo_url('forumhome|bburl', array()));
  72. }
  73. // #############################################################################
  74. // ### CACHE PERMISSIONS AND GRAB $permissions
  75. // get the combined permissions for the current user
  76. // this also creates the $fpermscache containing the user's forum permissions
  77. $permissions = cache_permissions($vbulletin->userinfo);
  78. $vbulletin->userinfo['permissions'] =& $permissions;
  79. // #############################################################################
  80. // check that board is active - if not admin, then display error
  81. if ((!$vbulletin->options['bbactive'] AND !($permissions['adminpermissions'] & $vbulletin->bf_ugp_adminpermissions['cancontrolpanel'])) OR !($permissions['forumpermissions'] & $vbulletin->bf_ugp_forumpermissions['canview']))
  82. {
  83. exec_header_redirect(fetch_seo_url('forumhome|bburl', array()));
  84. }
  85. // if password is expired, deny access
  86. if ($vbulletin->userinfo['userid'] AND $permissions['passwordexpires'])
  87. {
  88. $passworddaysold = floor((TIMENOW - $vbulletin->userinfo['passworddate']) / 86400);
  89. if ($passworddaysold >= $permissions['passwordexpires'])
  90. {
  91. exec_header_redirect(fetch_seo_url('forumhome|bburl', array()));
  92. }
  93. }
  94. verify_ip_ban();
  95. $cache_templates = array('ad_archive_above_content1', 'ad_archive_above_content2', 'ad_archive_below_content');
  96. ($hook = vBulletinHook::fetch_hook('archive_global')) ? eval($hook) : false;
  97. cache_templates($cache_templates, $style['templatelist']);
  98. unset($cache_templates);
  99. // #########################################################################################
  100. // ###################### ARCHIVE FUNCTIONS ################################################
  101. // function to list forums in their correct order and nesting
  102. function print_archive_forum_list($parentid = -1, $indent = '')
  103. {
  104. global $vbulletin;
  105. $output = '';
  106. if (empty($vbulletin->iforumcache))
  107. {
  108. $forums = $vbulletin->db->query_read_slave("
  109. SELECT forumid, title, link, parentid, displayorder, title_clean, description, description_clean,
  110. (options & " . $vbulletin->bf_misc_forumoptions['cancontainthreads'] . ") AS cancontainthreads
  111. FROM " . TABLE_PREFIX . "forum AS forum
  112. WHERE displayorder <> 0 AND
  113. password = '' AND
  114. (options & " . $vbulletin->bf_misc_forumoptions['active'] . ")
  115. ORDER BY displayorder
  116. ");
  117. $vbulletin->iforumcache = array();
  118. while ($forum = $vbulletin->db->fetch_array($forums))
  119. {
  120. $vbulletin->iforumcache["$forum[parentid]"]["$forum[displayorder]"]["$forum[forumid]"] = $forum;
  121. }
  122. unset($forum);
  123. $vbulletin->db->free_result($forums);
  124. }
  125. if (is_array($vbulletin->iforumcache["$parentid"]))
  126. {
  127. foreach($vbulletin->iforumcache["$parentid"] AS $x)
  128. {
  129. foreach($x AS $forumid => $forum)
  130. {
  131. ($hook = vBulletinHook::fetch_hook('archive_forum')) ? eval($hook) : false;
  132. if (!($vbulletin->userinfo['forumpermissions']["$forumid"] & $vbulletin->bf_ugp_forumpermissions['canview']) AND ($vbulletin->forumcache["$forumid"]['showprivate'] == 1 OR (!$vbulletin->forumcache["$forumid"]['showprivate'] AND !$vbulletin->options['showprivateforums'])))
  133. {
  134. continue;
  135. }
  136. else
  137. {
  138. if ($forum['cancontainthreads'] OR $forum['link'] !== '')
  139. {
  140. $link = ($forum['link'] !== '' ? $forum['link'] : $vbulletin->options['bburl'] . '/archive/index.php' .
  141. (SLASH_METHOD ? '/' : '?') . "f-$forumid.html" . ARCHIVE_SESSION_URL );
  142. $forum_link = '<a href="' . $link . '">';
  143. }
  144. else
  145. {
  146. $forum_link = "<a style=\"font-weight:bold\">";
  147. }
  148. $output .= "$indent\t<li>$forum_link$forum[title_clean]</a>" . print_archive_forum_list($forumid, "\t$indent") . "</li>\n";
  149. }
  150. }
  151. }
  152. // only add to $output if there were actual forums
  153. if (!empty($output))
  154. {
  155. $output = "\n$indent<ul>\n" . $output . "$indent</ul>\n$indent";
  156. }
  157. }
  158. return $output;
  159. }
  160. // function to draw the navbar for the archive pages
  161. function print_archive_navigation($foruminfo, $threadinfo='')
  162. {
  163. global $vbulletin, $vbphrase, $pda, $querystring;
  164. $navarray = array('<a href="' . $vbulletin->options['bburl'] . '/archive/index.php' .
  165. $vbulletin->session->vars['sessionurl_q'] . '">' . $vbulletin->options['bbtitle'] . '</a>');
  166. if (!empty($foruminfo))
  167. {
  168. foreach(array_reverse(explode(',', substr($foruminfo['parentlist'], 0, -3))) AS $forumid)
  169. {
  170. if ($threadinfo == '' AND $forumid == $foruminfo['forumid'])
  171. {
  172. $navarray[] = $vbulletin->forumcache["$forumid"]['title_clean'];
  173. }
  174. else
  175. {
  176. $navarray[] = "<a href=\"" . $vbulletin->options['bburl'] . '/archive/index.php' . (SLASH_METHOD ? '/' : '?')
  177. . "f-$forumid.html" . ARCHIVE_SESSION_URL . "\">" . $vbulletin->forumcache["$forumid"]['title_clean'] . "</a>";
  178. }
  179. }
  180. if (is_array($threadinfo))
  181. {
  182. $navarray[] = $threadinfo['prefix_plain_html'] . ' ' . $threadinfo['title'];
  183. }
  184. }
  185. if (SLASH_METHOD)
  186. {
  187. $loginlink = 'index.php' . (!empty($querystring) ? "/$querystring" : '') . '?' . $vbulletin->session->vars['sessionurl'] . 'login=1';
  188. $pdalink = 'index.php' . (!empty($querystring) ? "/$querystring" : '') . '?' . $vbulletin->session->vars['sessionurl'] . 'pda=1';
  189. }
  190. else
  191. {
  192. $loginlink = 'index.php?' . (!empty($querystring) ? "$querystring&amp;" : '') . $vbulletin->session->vars['sessionurl'] . 'login=1';
  193. $pdalink = 'index.php?' . (!empty($querystring) ? "$querystring&amp;" : '') . $vbulletin->session->vars['sessionurl'] . 'pda=1';
  194. }
  195. if ($pda)
  196. {
  197. if ($vbulletin->userinfo['userid'] == 0)
  198. {
  199. $extra = '<div class="pda"><a href="' . $vbulletin->options['bburl'] . "/archive/$loginlink" . '" rel="nofollow">' . $vbphrase['log_in'] . "</a></div>\n";
  200. }
  201. }
  202. else
  203. {
  204. $extra = '<div class="pda"><a href="' . $vbulletin->options['bburl'] . "/archive/$pdalink" . '" rel="nofollow">' . $vbphrase['pda'] . "</a></div>\n";
  205. }
  206. $return = '<div id="navbar">' . implode(' &gt; ', $navarray) . "</div>\n<hr />\n" . $extra;
  207. ($hook = vBulletinHook::fetch_hook('archive_navigation')) ? eval($hook) : false;
  208. return $return;
  209. }
  210. // this function seems to only be used in project.php, and is thus probably no longer needed.
  211. function print_archive_navbar($navbits = array())
  212. {
  213. global $vbulletin, $vbphrase, $pda, $querystring;
  214. $navarray = array('<a href="' . $vbulletin->options['bburl'] . '/index.php' .
  215. $vbulletin->session->vars['sessionurl_q'] . '">' . $vbulletin->options['bbtitle'] . '</a>');
  216. foreach ($navbits AS $url => $navbit)
  217. {
  218. if ($url)
  219. {
  220. $navarray[] = "<a href=\"" . htmlspecialchars_uni($url) .
  221. $vbulletin->session->vars['sessionurl_q'] . "\">$navbit</a>";
  222. }
  223. else
  224. {
  225. $navarray[] = $navbit;
  226. }
  227. }
  228. if (SLASH_METHOD)
  229. {
  230. $loginlink = 'index.php' . (!empty($querystring) ? "/$querystring" : '') . '?' . $vbulletin->session->vars['sessionurl'] . 'login=1';
  231. $pdalink = 'index.php' . (!empty($querystring) ? "/$querystring" : '') . '?' . $vbulletin->session->vars['sessionurl'] . 'pda=1';
  232. }
  233. else
  234. {
  235. $loginlink = 'index.php?' . (!empty($querystring) ? "$querystring&amp;" : '') . $vbulletin->session->vars['sessionurl'] . 'login=1';
  236. $pdalink = 'index.php?' . (!empty($querystring) ? "$querystring&amp;" : '') . $vbulletin->session->vars['sessionurl'] . 'pda=1';
  237. }
  238. if ($pda)
  239. {
  240. if ($vbulletin->userinfo['userid'] == 0)
  241. {
  242. $extra = '<div class="pda"><a href="' . $vbulletin->options['bburl'] . "/archive/$loginlink" . '" rel="nofollow">' . $vbphrase['log_in'] . "</a></div>\n";
  243. }
  244. }
  245. else
  246. {
  247. $extra = '<div class="pda"><a href="' . $vbulletin->options['bburl'] . "/archive/$pdalink" . '" rel="nofollow">' . $vbphrase['pda'] . "</a></div>\n";
  248. }
  249. $return = '<div id="navbar">' . implode(' &gt; ', $navarray) . "</div>\n<hr />\n" . $extra;
  250. ($hook = vBulletinHook::fetch_hook('archive_navigation')) ? eval($hook) : false;
  251. return $return;
  252. }
  253. // function to draw the page links for the archive pages
  254. function print_archive_page_navigation($total, $perpage, $link)
  255. {
  256. global $p, $vbphrase, $vbulletin;
  257. $output = '';
  258. $numpages = ceil($total / $perpage);
  259. if ($numpages > 1)
  260. {
  261. $output .= "<div id=\"pagenumbers\"><b>$vbphrase[pages] :</b>\n";
  262. for ($i=1; $i <= $numpages; $i++)
  263. {
  264. if ($i == $p)
  265. {
  266. $output .= "[<b>$i</b>]\n";
  267. }
  268. else if ($i == 1)
  269. {
  270. $output .= '<a href="' . $vbulletin->options['bburl'] . '/archive/index.php' .
  271. (SLASH_METHOD ? '/' : '?') . "$link.html" . ARCHIVE_SESSION_URL . "\">$i</a>\n";
  272. }
  273. else
  274. {
  275. $output .= '<a href="' . $vbulletin->options['bburl'] . '/archive/index.php' .
  276. (SLASH_METHOD ? '/' : '?') . "$link-p-$i.html" . ARCHIVE_SESSION_URL . "\">$i</a>\n";
  277. }
  278. }
  279. $output .= "</div>\n<hr />\n";
  280. }
  281. return $output;
  282. }
  283. // #############################################################################
  284. /**
  285. * Returns specified ad template output as an assoc array of title => parsed template
  286. *
  287. * @param array Name of templates to be fetched
  288. *
  289. * @return array Keyed by template name, value is HTML for template
  290. */
  291. function fetch_ad_templates(array $templatenames)
  292. {
  293. global $vbulletin;
  294. $ad_templates = array();
  295. foreach ($templatenames AS $template)
  296. {
  297. $ad_templates[$template] = vB_Template::create($template)->render();
  298. }
  299. return $ad_templates;
  300. }
  301. /*======================================================================*\
  302. || ####################################################################
  303. || # Downloaded: 03:13, Sat Sep 7th 2013
  304. || # CVS: $RCSfile$ - $Revision: 59007 $
  305. || ####################################################################
  306. \*======================================================================*/
  307. ?>