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