(file) Return to functions.php CVS log (file) (dir) Up to [RizwankCVS] / geekymedia_web / phpBB2 / includes

  1 rizwank 1.1 <?php
  2             /***************************************************************************
  3              *                               functions.php
  4              *                            -------------------
  5              *   begin                : Saturday, Feb 13, 2001
  6              *   copyright            : (C) 2001 The phpBB Group
  7              *   email                : support@phpbb.com
  8              *
  9              *   $Id: functions.php,v 1.133.2.21 2003/01/13 18:54:16 psotfx Exp $
 10              *
 11              *
 12              ***************************************************************************/
 13             
 14             /***************************************************************************
 15              *
 16              *   This program is free software; you can redistribute it and/or modify
 17              *   it under the terms of the GNU General Public License as published by
 18              *   the Free Software Foundation; either version 2 of the License, or
 19              *   (at your option) any later version.
 20              *
 21              *
 22 rizwank 1.1  ***************************************************************************/
 23             
 24             function get_db_stat($mode)
 25             {
 26             	global $db;
 27             
 28             	switch( $mode )
 29             	{
 30             		case 'usercount':
 31             			$sql = "SELECT COUNT(user_id) AS total
 32             				FROM " . USERS_TABLE . "
 33             				WHERE user_id <> " . ANONYMOUS;
 34             			break;
 35             
 36             		case 'newestuser':
 37             			$sql = "SELECT user_id, username
 38             				FROM " . USERS_TABLE . "
 39             				WHERE user_id <> " . ANONYMOUS . "
 40             				ORDER BY user_id DESC
 41             				LIMIT 1";
 42             			break;
 43 rizwank 1.1 
 44             		case 'postcount':
 45             		case 'topiccount':
 46             			$sql = "SELECT SUM(forum_topics) AS topic_total, SUM(forum_posts) AS post_total
 47             				FROM " . FORUMS_TABLE;
 48             			break;
 49             	}
 50             
 51             	if ( !($result = $db->sql_query($sql)) )
 52             	{
 53             		return false;
 54             	}
 55             
 56             	$row = $db->sql_fetchrow($result);
 57             
 58             	switch ( $mode )
 59             	{
 60             		case 'usercount':
 61             			return $row['total'];
 62             			break;
 63             		case 'newestuser':
 64 rizwank 1.1 			return $row;
 65             			break;
 66             		case 'postcount':
 67             			return $row['post_total'];
 68             			break;
 69             		case 'topiccount':
 70             			return $row['topic_total'];
 71             			break;
 72             	}
 73             
 74             	return false;
 75             }
 76             
 77             function get_userdata($user)
 78             {
 79             	global $db;
 80             
 81             	$sql = "SELECT *
 82             		FROM " . USERS_TABLE . " 
 83             		WHERE ";
 84             	$sql .= ( ( is_integer($user) ) ? "user_id = $user" : "username = '" .  str_replace("\'", "''", $user) . "'" ) . " AND user_id <> " . ANONYMOUS;
 85 rizwank 1.1 	if ( !($result = $db->sql_query($sql)) )
 86             	{
 87             		message_die(GENERAL_ERROR, 'Tried obtaining data for a non-existent user', '', __LINE__, __FILE__, $sql);
 88             	}
 89             
 90             	return ( $row = $db->sql_fetchrow($result) ) ? $row : false;
 91             }
 92             
 93             function make_jumpbox($action, $match_forum_id = 0)
 94             {
 95             	global $template, $userdata, $lang, $db, $nav_links, $phpEx;
 96             
 97             //	$is_auth = auth(AUTH_VIEW, AUTH_LIST_ALL, $userdata);
 98             
 99             	$sql = "SELECT c.cat_id, c.cat_title, c.cat_order
100             		FROM " . CATEGORIES_TABLE . " c, " . FORUMS_TABLE . " f
101             		WHERE f.cat_id = c.cat_id
102             		GROUP BY c.cat_id, c.cat_title, c.cat_order
103             		ORDER BY c.cat_order";
104             	if ( !($result = $db->sql_query($sql)) )
105             	{
106 rizwank 1.1 		message_die(GENERAL_ERROR, "Couldn't obtain category list.", "", __LINE__, __FILE__, $sql);
107             	}
108             	
109             	$category_rows = array();
110             	while ( $row = $db->sql_fetchrow($result) )
111             	{
112             		$category_rows[] = $row;
113             	}
114             
115             	if ( $total_categories = count($category_rows) )
116             	{
117             		$sql = "SELECT *
118             			FROM " . FORUMS_TABLE . "
119             			ORDER BY cat_id, forum_order";
120             		if ( !($result = $db->sql_query($sql)) )
121             		{
122             			message_die(GENERAL_ERROR, 'Could not obtain forums information', '', __LINE__, __FILE__, $sql);
123             		}
124             
125             		$boxstring = '<select name="' . POST_FORUM_URL . '" onchange="if(this.options[this.selectedIndex].value != -1){ forms[\'jumpbox\'].submit() }"><option value="-1">' . $lang['Select_forum'] . '</option>';
126             
127 rizwank 1.1 		$forum_rows = array();
128             		while ( $row = $db->sql_fetchrow($result) )
129             		{
130             			$forum_rows[] = $row;
131             		}
132             
133             		if ( $total_forums = count($forum_rows) )
134             		{
135             			for($i = 0; $i < $total_categories; $i++)
136             			{
137             				$boxstring_forums = '';
138             				for($j = 0; $j < $total_forums; $j++)
139             				{
140             					if ( $forum_rows[$j]['cat_id'] == $category_rows[$i]['cat_id'] && $forum_rows[$j]['auth_view'] <= AUTH_REG )
141             					{
142             
143             //					if ( $forum_rows[$j]['cat_id'] == $category_rows[$i]['cat_id'] && $is_auth[$forum_rows[$j]['forum_id']]['auth_view'] )
144             //					{
145             						$selected = ( $forum_rows[$j]['forum_id'] == $match_forum_id ) ? 'selected="selected"' : '';
146             						$boxstring_forums .=  '<option value="' . $forum_rows[$j]['forum_id'] . '"' . $selected . '>' . $forum_rows[$j]['forum_name'] . '</option>';
147             
148 rizwank 1.1 						//
149             						// Add an array to $nav_links for the Mozilla navigation bar.
150             						// 'chapter' and 'forum' can create multiple items, therefore we are using a nested array.
151             						//
152             						$nav_links['chapter forum'][$forum_rows[$j]['forum_id']] = array (
153             							'url' => append_sid("viewforum.$phpEx?" . POST_FORUM_URL . "=" . $forum_rows[$j]['forum_id']),
154             							'title' => $forum_rows[$j]['forum_name']
155             						);
156             								
157             					}
158             				}
159             
160             				if ( $boxstring_forums != '' )
161             				{
162             					$boxstring .= '<option value="-1">&nbsp;</option>';
163             					$boxstring .= '<option value="-1">' . $category_rows[$i]['cat_title'] . '</option>';
164             					$boxstring .= '<option value="-1">----------------</option>';
165             					$boxstring .= $boxstring_forums;
166             				}
167             			}
168             		}
169 rizwank 1.1 
170             		$boxstring .= '</select>';
171             	}
172             	else
173             	{
174             		$boxstring .= '<select name="' . POST_FORUM_URL . '" onchange="if(this.options[this.selectedIndex].value != -1){ forms[\'jumpbox\'].submit() }"></select>';
175             	}
176             
177             	if ( !empty($SID) )
178             	{
179             		$boxstring .= '<input type="hidden" name="sid" value="' . $userdata['session_id'] . '" />';
180             	}
181             
182             	$template->set_filenames(array(
183             		'jumpbox' => 'jumpbox.tpl')
184             	);
185             	$template->assign_vars(array(
186             		'L_GO' => $lang['Go'],
187             		'L_JUMP_TO' => $lang['Jump_to'],
188             		'L_SELECT_FORUM' => $lang['Select_forum'],
189             
190 rizwank 1.1 		'S_JUMPBOX_SELECT' => $boxstring,
191             		'S_JUMPBOX_ACTION' => append_sid($action))
192             	);
193             	$template->assign_var_from_handle('JUMPBOX', 'jumpbox');
194             
195             	return;
196             }
197             
198             //
199             // Initialise user settings on page load
200             function init_userprefs($userdata)
201             {
202             	global $board_config, $theme, $images;
203             	global $template, $lang, $phpEx, $phpbb_root_path;
204             
205             	if ( $userdata['user_id'] != ANONYMOUS )
206             	{
207             		if ( !empty($userdata['user_lang']))
208             		{
209             			$board_config['default_lang'] = $userdata['user_lang'];
210             		}
211 rizwank 1.1 
212             		if ( !empty($userdata['user_dateformat']) )
213             		{
214             			$board_config['default_dateformat'] = $userdata['user_dateformat'];
215             		}
216             
217             		if ( isset($userdata['user_timezone']) )
218             		{
219             			$board_config['board_timezone'] = $userdata['user_timezone'];
220             		}
221             	}
222             
223             	if ( !file_exists(@phpbb_realpath($phpbb_root_path . 'language/lang_' . $board_config['default_lang'] . '/lang_main.'.$phpEx)) )
224             	{
225             		$board_config['default_lang'] = 'english';
226             	}
227             
228             	include($phpbb_root_path . 'language/lang_' . $board_config['default_lang'] . '/lang_main.' . $phpEx);
229             
230             	if ( defined('IN_ADMIN') )
231             	{
232 rizwank 1.1 		if( !file_exists(@phpbb_realpath($phpbb_root_path . 'language/lang_' . $board_config['default_lang'] . '/lang_admin.'.$phpEx)) )
233             		{
234             			$board_config['default_lang'] = 'english';
235             		}
236             
237             		include($phpbb_root_path . 'language/lang_' . $board_config['default_lang'] . '/lang_admin.' . $phpEx);
238             	}
239             
240             	//
241             	// Set up style
242             	//
243             	if ( !$board_config['override_user_style'] )
244             	{
245             		if ( $userdata['user_id'] != ANONYMOUS && $userdata['user_style'] > 0 )
246             		{
247             			if ( $theme = setup_style($userdata['user_style']) )
248             			{
249             				return;
250             			}
251             		}
252             	}
253 rizwank 1.1 
254             	$theme = setup_style($board_config['default_style']);
255             
256             	return;
257             }
258             
259             function setup_style($style)
260             {
261             	global $db, $board_config, $template, $images, $phpbb_root_path;
262             
263             	$sql = "SELECT *
264             		FROM " . THEMES_TABLE . "
265             		WHERE themes_id = $style";
266             	if ( !($result = $db->sql_query($sql)) )
267             	{
268             		message_die(CRITICAL_ERROR, 'Could not query database for theme info');
269             	}
270             
271             	if ( !($row = $db->sql_fetchrow($result)) )
272             	{
273             		message_die(CRITICAL_ERROR, "Could not get theme data for themes_id [$style]");
274 rizwank 1.1 	}
275             
276             	$template_path = 'templates/' ;
277             	$template_name = $row['template_name'] ;
278             
279             	$template = new Template($phpbb_root_path . $template_path . $template_name, $board_config, $db);
280             
281             	if ( $template )
282             	{
283             		$current_template_path = $template_path . $template_name;
284             		@include($phpbb_root_path . $template_path . $template_name . '/' . $template_name . '.cfg');
285             
286             		if ( !defined('TEMPLATE_CONFIG') )
287             		{
288             			message_die(CRITICAL_ERROR, "Could not open $template_name template config file", '', __LINE__, __FILE__);
289             		}
290             
291             		$img_lang = ( file_exists(@phpbb_realpath($phpbb_root_path . $current_template_path . '/images/lang_' . $board_config['default_lang'])) ) ? $board_config['default_lang'] : 'english';
292             
293             		while( list($key, $value) = @each($images) )
294             		{
295 rizwank 1.1 			if ( !is_array($value) )
296             			{
297             				$images[$key] = str_replace('{LANG}', 'lang_' . $img_lang, $value);
298             			}
299             		}
300             	}
301             
302             	return $row;
303             }
304             
305             function encode_ip($dotquad_ip)
306             {
307             	$ip_sep = explode('.', $dotquad_ip);
308             	return sprintf('%02x%02x%02x%02x', $ip_sep[0], $ip_sep[1], $ip_sep[2], $ip_sep[3]);
309             }
310             
311             function decode_ip($int_ip)
312             {
313             	$hexipbang = explode('.', chunk_split($int_ip, 2, '.'));
314             	return hexdec($hexipbang[0]). '.' . hexdec($hexipbang[1]) . '.' . hexdec($hexipbang[2]) . '.' . hexdec($hexipbang[3]);
315             }
316 rizwank 1.1 
317             //
318             // Create date/time from format and timezone
319             //
320             function create_date($format, $gmepoch, $tz)
321             {
322             	global $board_config, $lang;
323             	static $translate;
324             
325             	if ( empty($translate) && $board_config['default_lang'] != 'english' )
326             	{
327             		@reset($lang['datetime']);
328             		while ( list($match, $replace) = @each($lang['datetime']) )
329             		{
330             			$translate[$match] = $replace;
331             		}
332             	}
333             
334             	return ( !empty($translate) ) ? strtr(@gmdate($format, $gmepoch + (3600 * $tz)), $translate) : @gmdate($format, $gmepoch + (3600 * $tz));
335             }
336             
337 rizwank 1.1 //
338             // Pagination routine, generates
339             // page number sequence
340             //
341             function generate_pagination($base_url, $num_items, $per_page, $start_item, $add_prevnext_text = TRUE)
342             {
343             	global $lang;
344             
345             	$total_pages = ceil($num_items/$per_page);
346             
347             	if ( $total_pages == 1 )
348             	{
349             		return '';
350             	}
351             
352             	$on_page = floor($start_item / $per_page) + 1;
353             
354             	$page_string = '';
355             	if ( $total_pages > 10 )
356             	{
357             		$init_page_max = ( $total_pages > 3 ) ? 3 : $total_pages;
358 rizwank 1.1 
359             		for($i = 1; $i < $init_page_max + 1; $i++)
360             		{
361             			$page_string .= ( $i == $on_page ) ? '<b>' . $i . '</b>' : '<a href="' . append_sid($base_url . "&amp;start=" . ( ( $i - 1 ) * $per_page ) ) . '">' . $i . '</a>';
362             			if ( $i <  $init_page_max )
363             			{
364             				$page_string .= ", ";
365             			}
366             		}
367             
368             		if ( $total_pages > 3 )
369             		{
370             			if ( $on_page > 1  && $on_page < $total_pages )
371             			{
372             				$page_string .= ( $on_page > 5 ) ? ' ... ' : ', ';
373             
374             				$init_page_min = ( $on_page > 4 ) ? $on_page : 5;
375             				$init_page_max = ( $on_page < $total_pages - 4 ) ? $on_page : $total_pages - 4;
376             
377             				for($i = $init_page_min - 1; $i < $init_page_max + 2; $i++)
378             				{
379 rizwank 1.1 					$page_string .= ($i == $on_page) ? '<b>' . $i . '</b>' : '<a href="' . append_sid($base_url . "&amp;start=" . ( ( $i - 1 ) * $per_page ) ) . '">' . $i . '</a>';
380             					if ( $i <  $init_page_max + 1 )
381             					{
382             						$page_string .= ', ';
383             					}
384             				}
385             
386             				$page_string .= ( $on_page < $total_pages - 4 ) ? ' ... ' : ', ';
387             			}
388             			else
389             			{
390             				$page_string .= ' ... ';
391             			}
392             
393             			for($i = $total_pages - 2; $i < $total_pages + 1; $i++)
394             			{
395             				$page_string .= ( $i == $on_page ) ? '<b>' . $i . '</b>'  : '<a href="' . append_sid($base_url . "&amp;start=" . ( ( $i - 1 ) * $per_page ) ) . '">' . $i . '</a>';
396             				if( $i <  $total_pages )
397             				{
398             					$page_string .= ", ";
399             				}
400 rizwank 1.1 			}
401             		}
402             	}
403             	else
404             	{
405             		for($i = 1; $i < $total_pages + 1; $i++)
406             		{
407             			$page_string .= ( $i == $on_page ) ? '<b>' . $i . '</b>' : '<a href="' . append_sid($base_url . "&amp;start=" . ( ( $i - 1 ) * $per_page ) ) . '">' . $i . '</a>';
408             			if ( $i <  $total_pages )
409             			{
410             				$page_string .= ', ';
411             			}
412             		}
413             	}
414             
415             	if ( $add_prevnext_text )
416             	{
417             		if ( $on_page > 1 )
418             		{
419             			$page_string = ' <a href="' . append_sid($base_url . "&amp;start=" . ( ( $on_page - 2 ) * $per_page ) ) . '">' . $lang['Previous'] . '</a>&nbsp;&nbsp;' . $page_string;
420             		}
421 rizwank 1.1 
422             		if ( $on_page < $total_pages )
423             		{
424             			$page_string .= '&nbsp;&nbsp;<a href="' . append_sid($base_url . "&amp;start=" . ( $on_page * $per_page ) ) . '">' . $lang['Next'] . '</a>';
425             		}
426             
427             	}
428             
429             	$page_string = $lang['Goto_page'] . ' ' . $page_string;
430             
431             	return $page_string;
432             }
433             
434             //
435             // This does exactly what preg_quote() does in PHP 4-ish
436             // If you just need the 1-parameter preg_quote call, then don't bother using this.
437             //
438             function phpbb_preg_quote($str, $delimiter)
439             {
440             	$text = preg_quote($str);
441             	$text = str_replace($delimiter, '\\' . $delimiter, $text);
442 rizwank 1.1 	
443             	return $text;
444             }
445             
446             //
447             // Obtain list of naughty words and build preg style replacement arrays for use by the
448             // calling script, note that the vars are passed as references this just makes it easier
449             // to return both sets of arrays
450             //
451             function obtain_word_list(&$orig_word, &$replacement_word)
452             {
453             	global $db;
454             
455             	//
456             	// Define censored word matches
457             	//
458             	$sql = "SELECT word, replacement
459             		FROM  " . WORDS_TABLE;
460             	if( !($result = $db->sql_query($sql)) )
461             	{
462             		message_die(GENERAL_ERROR, 'Could not get censored words from database', '', __LINE__, __FILE__, $sql);
463 rizwank 1.1 	}
464             
465             	if ( $row = $db->sql_fetchrow($result) )
466             	{
467             		do 
468             		{
469             			$orig_word[] = '#\b(' . str_replace('\*', '\w*?', phpbb_preg_quote($row['word'], '#')) . ')\b#i';
470             			$replacement_word[] = $row['replacement'];
471             		}
472             		while ( $row = $db->sql_fetchrow($result) );
473             	}
474             
475             	return true;
476             }
477             
478             //
479             // This is general replacement for die(), allows templated
480             // output in users (or default) language, etc.
481             //
482             // $msg_code can be one of these constants:
483             //
484 rizwank 1.1 // GENERAL_MESSAGE : Use for any simple text message, eg. results 
485             // of an operation, authorisation failures, etc.
486             //
487             // GENERAL ERROR : Use for any error which occurs _AFTER_ the 
488             // common.php include and session code, ie. most errors in 
489             // pages/functions
490             //
491             // CRITICAL_MESSAGE : Used when basic config data is available but 
492             // a session may not exist, eg. banned users
493             //
494             // CRITICAL_ERROR : Used when config data cannot be obtained, eg
495             // no database connection. Should _not_ be used in 99.5% of cases
496             //
497             function message_die($msg_code, $msg_text = '', $msg_title = '', $err_line = '', $err_file = '', $sql = '')
498             {
499             	global $db, $template, $board_config, $theme, $lang, $phpEx, $phpbb_root_path, $nav_links, $gen_simple_header, $images;
500             	global $userdata, $user_ip, $session_length;
501             	global $starttime;
502             
503             	if(defined('HAS_DIED'))
504             	{
505 rizwank 1.1 		die("message_die() was called multiple times. This isn't supposed to happen. Was message_die() used in page_tail.php?");
506             	}
507             	
508             	define(HAS_DIED, 1);
509             	
510             
511             	$sql_store = $sql;
512             	
513             	//
514             	// Get SQL error if we are debugging. Do this as soon as possible to prevent 
515             	// subsequent queries from overwriting the status of sql_error()
516             	//
517             	if ( DEBUG && ( $msg_code == GENERAL_ERROR || $msg_code == CRITICAL_ERROR ) )
518             	{
519             		$sql_error = $db->sql_error();
520             
521             		$debug_text = '';
522             
523             		if ( $sql_error['message'] != '' )
524             		{
525             			$debug_text .= '<br /><br />SQL Error : ' . $sql_error['code'] . ' ' . $sql_error['message'];
526 rizwank 1.1 		}
527             
528             		if ( $sql_store != '' )
529             		{
530             			$debug_text .= "<br /><br />$sql_store";
531             		}
532             
533             		if ( $err_line != '' && $err_file != '' )
534             		{
535             			$debug_text .= '</br /><br />Line : ' . $err_line . '<br />File : ' . $err_file;
536             		}
537             	}
538             
539             	if( empty($userdata) && ( $msg_code == GENERAL_MESSAGE || $msg_code == GENERAL_ERROR ) )
540             	{
541             		$userdata = session_pagestart($user_ip, PAGE_INDEX);
542             		init_userprefs($userdata);
543             	}
544             
545             	//
546             	// If the header hasn't been output then do it
547 rizwank 1.1 	//
548             	if ( !defined('HEADER_INC') && $msg_code != CRITICAL_ERROR )
549             	{
550             		if ( empty($lang) )
551             		{
552             			if ( !empty($board_config['default_lang']) )
553             			{
554             				include($phpbb_root_path . 'language/lang_' . $board_config['default_lang'] . '/lang_main.'.$phpEx);
555             			}
556             			else
557             			{
558             				include($phpbb_root_path . 'language/lang_english/lang_main.'.$phpEx);
559             			}
560             		}
561             
562             		if ( empty($template) )
563             		{
564             			$template = new Template($phpbb_root_path . 'templates/' . $board_config['board_template']);
565             		}
566             		if ( empty($theme) )
567             		{
568 rizwank 1.1 			$theme = setup_style($board_config['default_style']);
569             		}
570             
571             		//
572             		// Load the Page Header
573             		//
574             		if ( !defined('IN_ADMIN') )
575             		{
576             			include($phpbb_root_path . 'includes/page_header.'.$phpEx);
577             		}
578             		else
579             		{
580             			include($phpbb_root_path . 'admin/page_header_admin.'.$phpEx);
581             		}
582             	}
583             
584             	switch($msg_code)
585             	{
586             		case GENERAL_MESSAGE:
587             			if ( $msg_title == '' )
588             			{
589 rizwank 1.1 				$msg_title = $lang['Information'];
590             			}
591             			break;
592             
593             		case CRITICAL_MESSAGE:
594             			if ( $msg_title == '' )
595             			{
596             				$msg_title = $lang['Critical_Information'];
597             			}
598             			break;
599             
600             		case GENERAL_ERROR:
601             			if ( $msg_text == '' )
602             			{
603             				$msg_text = $lang['An_error_occured'];
604             			}
605             
606             			if ( $msg_title == '' )
607             			{
608             				$msg_title = $lang['General_Error'];
609             			}
610 rizwank 1.1 			break;
611             
612             		case CRITICAL_ERROR:
613             			//
614             			// Critical errors mean we cannot rely on _ANY_ DB information being
615             			// available so we're going to dump out a simple echo'd statement
616             			//
617             			include($phpbb_root_path . 'language/lang_english/lang_main.'.$phpEx);
618             
619             			if ( $msg_text == '' )
620             			{
621             				$msg_text = $lang['A_critical_error'];
622             			}
623             
624             			if ( $msg_title == '' )
625             			{
626             				$msg_title = 'phpBB : <b>' . $lang['Critical_Error'] . '</b>';
627             			}
628             			break;
629             	}
630             
631 rizwank 1.1 	//
632             	// Add on DEBUG info if we've enabled debug mode and this is an error. This
633             	// prevents debug info being output for general messages should DEBUG be
634             	// set TRUE by accident (preventing confusion for the end user!)
635             	//
636             	if ( DEBUG && ( $msg_code == GENERAL_ERROR || $msg_code == CRITICAL_ERROR ) )
637             	{
638             		if ( $debug_text != '' )
639             		{
640             			$msg_text = $msg_text . '<br /><br /><b><u>DEBUG MODE</u></b>' . $debug_text;
641             		}
642             	}
643             
644             	if ( $msg_code != CRITICAL_ERROR )
645             	{
646             		if ( !empty($lang[$msg_text]) )
647             		{
648             			$msg_text = $lang[$msg_text];
649             		}
650             
651             		if ( !defined('IN_ADMIN') )
652 rizwank 1.1 		{
653             			$template->set_filenames(array(
654             				'message_body' => 'message_body.tpl')
655             			);
656             		}
657             		else
658             		{
659             			$template->set_filenames(array(
660             				'message_body' => 'admin/admin_message_body.tpl')
661             			);
662             		}
663             
664             		$template->assign_vars(array(
665             			'MESSAGE_TITLE' => $msg_title,
666             			'MESSAGE_TEXT' => $msg_text)
667             		);
668             		$template->pparse('message_body');
669             
670             		if ( !defined('IN_ADMIN') )
671             		{
672             			include($phpbb_root_path . 'includes/page_tail.'.$phpEx);
673 rizwank 1.1 		}
674             		else
675             		{
676             			include($phpbb_root_path . 'admin/page_footer_admin.'.$phpEx);
677             		}
678             	}
679             	else
680             	{
681             		echo "<html>\n<body>\n" . $msg_title . "\n<br /><br />\n" . $msg_text . "</body>\n</html>";
682             	}
683             
684             	exit;
685             }
686             
687             //
688             // This function is for compatibility with PHP 4.x's realpath()
689             // function.  In later versions of PHP, it needs to be called
690             // to do checks with some functions.  Older versions of PHP don't
691             // seem to need this, so we'll just return the original value.
692             // dougk_ff7 <October 5, 2002>
693             function phpbb_realpath($path)
694 rizwank 1.1 {
695             	return (!@function_exists('realpath') || !@realpath($phpbb_root_path . 'includes/functions.'.$phpEx)) ? $path : @realpath($path);
696             }
697             
698             function redirect($url)
699             {
700             	global $db, $board_config;
701             
702             	if (!empty($db))
703             	{
704             		$db->sql_close();
705             	}
706             
707             	$server_protocol = ($board_config['cookie_secure']) ? 'https://' : 'http://';
708             	$server_name = preg_replace('#^\/?(.*?)\/?$#', '\1', trim($board_config['server_name']));
709             	$server_port = ($board_config['server_port'] <> 80) ? ':' . trim($board_config['server_port']) : '';
710             	$script_name = preg_replace('#^\/?(.*?)\/?$#', '\1', trim($board_config['script_path']));
711             	$script_name = ($script_name == '') ? $script_name : '/' . $script_name;
712             	$url = preg_replace('#^\/?(.*?)\/?$#', '/\1', trim($url));
713             
714             	// Redirect via an HTML form for PITA webservers
715 rizwank 1.1 	if (@preg_match('/Microsoft|WebSTAR|Xitami/', getenv('SERVER_SOFTWARE')))
716             	{
717             		header('Refresh: 0; URL=' . $server_protocol . $server_name . $server_port . $script_name . $url);
718             		echo '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"><meta http-equiv="refresh" content="0; url=' . $server_protocol . $server_name . $server_port . $script_name . $url . '"><title>Redirect</title></head><body><div align="center">If your browser does not support meta redirection please click <a href="' . $server_protocol . $server_name . $server_port . $script_name . $url . '">HERE</a> to be redirected</div></body></html>';
719             		exit;
720             	}
721             
722             	// Behave as per HTTP/1.1 spec for others
723             	header('Location: ' . $server_protocol . $server_name . $server_port . $script_name . $url);
724             	exit;
725             }
726             
727             ?>

Rizwan Kassim
Powered by
ViewCVS 0.9.2