Vergleich inc/functions.php - 1.6.9 - 1.6.10

  Keine Änderungen   Hinzugefügt   Modifiziert   Entfernt
Zeile 47Zeile 47

if(my_strpos(getenv("REQUEST_URI"), "?"))
{


if(my_strpos(getenv("REQUEST_URI"), "?"))
{

				$debuglink = htmlspecialchars(getenv("REQUEST_URI")) . "&debug=1";

				$debuglink = htmlspecialchars_uni(getenv("REQUEST_URI")) . "&debug=1";

			}
else
{

			}
else
{

				$debuglink = htmlspecialchars(getenv("REQUEST_URI")) . "?debug=1";

				$debuglink = htmlspecialchars_uni(getenv("REQUEST_URI")) . "?debug=1";

			}

if($mybb->settings['gzipoutput'] != 0)

			}

if($mybb->settings['gzipoutput'] != 0)

Zeile 63Zeile 63
				$gzipen = "Disabled";
}


				$gzipen = "Disabled";
}


			if(function_exists("memory_get_usage"))







			$memory_usage = get_memory_usage();

if($memory_usage)
{
$memory_usage = " / Memory Usage: ".get_friendly_size($memory_usage);
}
else

			{

			{

				$memory_usage = " / Memory Usage: ".get_friendly_size(memory_get_peak_usage(true));

				$memory_usage = '';

			}

$other = "PHP version: $phpversion / Server Load: $serverload / GZip Compression: $gzipen";

			}

$other = "PHP version: $phpversion / Server Load: $serverload / GZip Compression: $gzipen";

Zeile 92Zeile 98
	echo $contents;

$plugins->run_hooks("post_output_page");

	echo $contents;

$plugins->run_hooks("post_output_page");

}

/**

}

/**

 * Adds a function or class to the list of code to run on shutdown.
*
* @param mixed The name of the function.

 * Adds a function or class to the list of code to run on shutdown.
*
* @param mixed The name of the function.

Zeile 113Zeile 119
	if(is_array($name) && method_exists($name[0], $name[1]))
{
$shutdown_functions["class_".get_class($name[0])."_".$name[1]] = array('function' => $name, 'arguments' => $arguments);

	if(is_array($name) && method_exists($name[0], $name[1]))
{
$shutdown_functions["class_".get_class($name[0])."_".$name[1]] = array('function' => $name, 'arguments' => $arguments);

		return true;

		return true;

	}
else if(!is_array($name) && function_exists($name))
{

	}
else if(!is_array($name) && function_exists($name))
{

Zeile 123Zeile 129

return false;
}


return false;
}





/**
* Runs the shutdown items after the page has been sent to the browser.
*

/**
* Runs the shutdown items after the page has been sent to the browser.
*

Zeile 133Zeile 139
	global $config, $db, $cache, $plugins, $error_handler, $shutdown_functions, $shutdown_queries, $done_shutdown, $mybb;

if($done_shutdown == true || !$config || $error_handler->has_errors)

	global $config, $db, $cache, $plugins, $error_handler, $shutdown_functions, $shutdown_queries, $done_shutdown, $mybb;

if($done_shutdown == true || !$config || $error_handler->has_errors)

	{

	{

		return;
}


		return;
}


Zeile 142Zeile 148
	{
require_once MYBB_ROOT."inc/class_core.php";
$mybb = new MyBB;

	{
require_once MYBB_ROOT."inc/class_core.php";
$mybb = new MyBB;





		// Load the settings
require MYBB_ROOT."inc/settings.php";
$mybb->settings = &$settings;
}


		// Load the settings
require MYBB_ROOT."inc/settings.php";
$mybb->settings = &$settings;
}






	// If our DB has been deconstructed already (bad PHP 5.2.0), reconstruct
if(!is_object($db))

	// If our DB has been deconstructed already (bad PHP 5.2.0), reconstruct
if(!is_object($db))

	{

	{

		if(!isset($config) || empty($config['database']['type']))
{
require MYBB_ROOT."inc/config.php";

		if(!isset($config) || empty($config['database']['type']))
{
require MYBB_ROOT."inc/config.php";

Zeile 179Zeile 185
			$db->connect($config['database']);
define("TABLE_PREFIX", $config['database']['table_prefix']);
$db->set_table_prefix(TABLE_PREFIX);

			$db->connect($config['database']);
define("TABLE_PREFIX", $config['database']['table_prefix']);
$db->set_table_prefix(TABLE_PREFIX);

		}
}


		}
}


	// Cache object deconstructed? reconstruct
if(!is_object($cache))
{
require_once MYBB_ROOT."inc/class_datacache.php";
$cache = new datacache;
$cache->cache();

	// Cache object deconstructed? reconstruct
if(!is_object($cache))
{
require_once MYBB_ROOT."inc/class_datacache.php";
$cache = new datacache;
$cache->cache();

	}


	}


	// And finally.. plugins
if(!is_object($plugins) && !defined("NO_PLUGINS") && !($mybb->settings['no_plugins'] == 1))
{

	// And finally.. plugins
if(!is_object($plugins) && !defined("NO_PLUGINS") && !($mybb->settings['no_plugins'] == 1))
{

Zeile 218Zeile 224
	}

$done_shutdown = true;

	}

$done_shutdown = true;

}

/**

}

/**

 * Sends a specified amount of messages from the mail queue
*
* @param int The number of messages to send (Defaults to 10)

 * Sends a specified amount of messages from the mail queue
*
* @param int The number of messages to send (Defaults to 10)

Zeile 322Zeile 328

if(!$offset && $offset != '0')
{


if(!$offset && $offset != '0')
{

		if($mybb->user['uid'] != 0 && array_key_exists("timezone", $mybb->user))

		if(isset($mybb->user['uid']) && $mybb->user['uid'] != 0 && array_key_exists("timezone", $mybb->user))

		{
$offset = $mybb->user['timezone'];
$dstcorrection = $mybb->user['dst'];

		{
$offset = $mybb->user['timezone'];
$dstcorrection = $mybb->user['dst'];

Zeile 376Zeile 382
		{
$todaysdate = gmdate($format, $stamp + ($offset * 3600));
$yesterdaysdate = gmdate($format, ($stamp - 86400) + ($offset * 3600));

		{
$todaysdate = gmdate($format, $stamp + ($offset * 3600));
$yesterdaysdate = gmdate($format, ($stamp - 86400) + ($offset * 3600));

		}

		}


if($todaysdate == $date)


if($todaysdate == $date)

		{

		{

			$date = $lang->today;

			$date = $lang->today;

		}

		}

		else if($yesterdaysdate == $date)
{
$date = $lang->yesterday;

		else if($yesterdaysdate == $date)
{
$date = $lang->yesterday;

		}
}


		}
}


	if(is_object($plugins))
{
$date = $plugins->run_hooks("my_date", $date);
}

return $date;

	if(is_object($plugins))
{
$date = $plugins->run_hooks("my_date", $date);
}

return $date;

}

}


/**
* Sends an email using PHP's mail function, formatting it appropriately.


/**
* Sends an email using PHP's mail function, formatting it appropriately.

Zeile 413Zeile 419
{
global $mybb;
static $mail;

{
global $mybb;
static $mail;

	

	

	// Does our object not exist? Create it
if(!is_object($mail))
{

	// Does our object not exist? Create it
if(!is_object($mail))
{

Zeile 423Zeile 429
		{
require_once MYBB_ROOT."inc/mailhandlers/smtp.php";
$mail = new SmtpMail();

		{
require_once MYBB_ROOT."inc/mailhandlers/smtp.php";
$mail = new SmtpMail();

		}

		}

		else
{
require_once MYBB_ROOT."inc/mailhandlers/php.php";

		else
{
require_once MYBB_ROOT."inc/mailhandlers/php.php";

Zeile 452Zeile 458
	// Build and send
$mail->build_message($to, $subject, $message, $from, $charset, $headers, $format, $message_text, $return_email);
return $mail->send();

	// Build and send
$mail->build_message($to, $subject, $message, $from, $charset, $headers, $format, $message_text, $return_email);
return $mail->send();

}

/**

}

/**

 * Generates a unique code for POST requests to prevent XSS/CSRF attacks
*
* @return string The generated code

 * Generates a unique code for POST requests to prevent XSS/CSRF attacks
*
* @return string The generated code

Zeile 483Zeile 489
{
global $lang;
if(generate_post_check() != $code)

{
global $lang;
if(generate_post_check() != $code)

	{

	{

		if($silent == true)

		if($silent == true)

		{

		{

			return false;
}
else

			return false;
}
else

Zeile 493Zeile 499
			if(defined("IN_ADMINCP"))
{
return false;

			if(defined("IN_ADMINCP"))
{
return false;

			}

			}

			else
{
error($lang->invalid_post_code);

			else
{
error($lang->invalid_post_code);

Zeile 503Zeile 509
	else
{
return true;

	else
{
return true;

	}

	}

}

/**

}

/**

Zeile 522Zeile 528
		return $forumarraycache[$fid]['parentlist'];
}
elseif($forum_cache[$fid])

		return $forumarraycache[$fid]['parentlist'];
}
elseif($forum_cache[$fid])

	{
return $forum_cache[$fid]['parentlist'];
}

	{
return $forum_cache[$fid]['parentlist'];
}

	else
{
cache_forums();
return $forum_cache[$fid]['parentlist'];

	else
{
cache_forums();
return $forum_cache[$fid]['parentlist'];

	}
}


	}
}


/**
* Build a parent list of a specific forum, suitable for querying
*

/**
* Build a parent list of a specific forum, suitable for querying
*

Zeile 683Zeile 689
	if(!$title)
{
$title = $lang->please_correct_errors;

	if(!$title)
{
$title = $lang->please_correct_errors;

	}

if(!is_array($errors))
{

	}

if(!is_array($errors))
{

		$errors = array($errors);
}


		$errors = array($errors);
}


Zeile 753Zeile 759
		$redirect_url = htmlspecialchars_uni($redirect_url);

switch($mybb->settings['username_method'])

		$redirect_url = htmlspecialchars_uni($redirect_url);

switch($mybb->settings['username_method'])

		{

		{

			case 0:
$lang_username = $lang->username;
break;

			case 0:
$lang_username = $lang->username;
break;

Zeile 762Zeile 768
				break;
case 2:
$lang_username = $lang->username2;

				break;
case 2:
$lang_username = $lang->username2;

				break;

				break;

			default:
$lang_username = $lang->username;
break;

			default:
$lang_username = $lang->username;
break;

Zeile 786Zeile 792
	$redirect_args = array('url' => &$url, 'message' => &$message, 'title' => &$title);

$plugins->run_hooks("redirect", $redirect_args);

	$redirect_args = array('url' => &$url, 'message' => &$message, 'title' => &$title);

$plugins->run_hooks("redirect", $redirect_args);





	if($mybb->input['ajax'])
{
// Send our headers.

	if($mybb->input['ajax'])
{
// Send our headers.

Zeile 802Zeile 808
		echo 'window.location = "'.addslashes($url).'";'."\n";
echo "</script>\n";
exit;

		echo 'window.location = "'.addslashes($url).'";'."\n";
echo "</script>\n";
exit;

	}


	}


	if(!$message)
{
$message = $lang->redirect;

	if(!$message)
{
$message = $lang->redirect;

	}

	}


$time = TIME_NOW;
$timenow = my_date($mybb->settings['dateformat'], $time) . " " . my_date($mybb->settings['timeformat'], $time);


$time = TIME_NOW;
$timenow = my_date($mybb->settings['dateformat'], $time) . " " . my_date($mybb->settings['timeformat'], $time);

Zeile 819Zeile 825
	
// Show redirects only if both ACP and UCP settings are enabled, or ACP is enabled, and user is a guest.
if($mybb->settings['redirects'] == 1 && ($mybb->user['showredirect'] != 0 || !$mybb->user['uid']))

	
// Show redirects only if both ACP and UCP settings are enabled, or ACP is enabled, and user is a guest.
if($mybb->settings['redirects'] == 1 && ($mybb->user['showredirect'] != 0 || !$mybb->user['uid']))

	{

	{

		$url = str_replace("&amp;", "&", $url);

		$url = str_replace("&amp;", "&", $url);

		$url = htmlspecialchars($url);

		$url = htmlspecialchars_uni($url);


eval("\$redirectpage = \"".$templates->get("redirect")."\";");
output_page($redirectpage);


eval("\$redirectpage = \"".$templates->get("redirect")."\";");
output_page($redirectpage);

Zeile 869Zeile 875

$pages = ceil($count / $perpage);



$pages = ceil($count / $perpage);


 
	$prevpage = '';

	if($page > 1)
{
$prev = $page-1;

	if($page > 1)
{
$prev = $page-1;

Zeile 906Zeile 913
		$to = $pages;
}


		$to = $pages;
}


 
	$start = '';

	if($from > 1)
{
if($from-1 == 1)

	if($from > 1)
{
if($from-1 == 1)

Zeile 917Zeile 925
		eval("\$start = \"".$templates->get("multipage_start")."\";");
}


		eval("\$start = \"".$templates->get("multipage_start")."\";");
}


 
	$mppage = '';

	for($i = $from; $i <= $to; ++$i)
{
$page_url = fetch_page_url($url, $i);

	for($i = $from; $i <= $to; ++$i)
{
$page_url = fetch_page_url($url, $i);

Zeile 937Zeile 946
		}
}


		}
}


 
	$end = '';

	if($to < $pages)
{
if($to+1 == $pages)

	if($to < $pages)
{
if($to+1 == $pages)

Zeile 948Zeile 958
		eval("\$end = \"".$templates->get("multipage_end")."\";");
}


		eval("\$end = \"".$templates->get("multipage_end")."\";");
}


 
	$nextpage = '';

	if($page < $pages)
{
$next = $page+1;
$page_url = fetch_page_url($url, $next);
eval("\$nextpage = \"".$templates->get("multipage_nextpage")."\";");
}

	if($page < $pages)
{
$next = $page+1;
$page_url = fetch_page_url($url, $next);
eval("\$nextpage = \"".$templates->get("multipage_nextpage")."\";");
}

 


	$lang->multipage_pages = $lang->sprintf($lang->multipage_pages, $pages);

if($breadcrumb == true)

	$lang->multipage_pages = $lang->sprintf($lang->multipage_pages, $pages);

if($breadcrumb == true)

Zeile 1237Zeile 1249

$groups = explode(",", $gid);



$groups = explode(",", $gid);


	if(!$fpermcache[$fid]) // This forum has no custom or inherited permissions so lets just return the group permissions

	if(empty($fpermcache[$fid])) // This forum has no custom or inherited permissions so lets just return the group permissions

	{
return $groupperms;
}

	{
return $groupperms;
}

Zeile 1588Zeile 1600
		$icon = $mybb->input['icon'];
}


		$icon = $mybb->input['icon'];
}


 
	$iconlist = '';

	$no_icons_checked = " checked=\"checked\"";
// read post icons from cache, and sort them accordingly
$posticons_cache = $cache->read("posticons");

	$no_icons_checked = " checked=\"checked\"";
// read post icons from cache, and sort them accordingly
$posticons_cache = $cache->read("posticons");

Zeile 1837Zeile 1850
	$returnload = trim($serverload[0]);

return $returnload;

	$returnload = trim($serverload[0]);

return $returnload;

 
}

/**
* Returns the amount of memory allocated to the script.
*
* @return int The amount of memory allocated to the script.
*/
function get_memory_usage()
{
if(function_exists('memory_get_peak_usage'))
{
return memory_get_peak_usage(true);
}
elseif(function_exists('memory_get_usage'))
{
return memory_get_usage(true);
}
return false;

}

/**

}

/**

Zeile 1874Zeile 1905
				$new_stats[$counter] = 0;
}
}

				$new_stats[$counter] = 0;
}
}

	}

	}


// Fetch latest user if the user count is changing
if(array_key_exists('numusers', $changes))


// Fetch latest user if the user count is changing
if(array_key_exists('numusers', $changes))

Zeile 1928Zeile 1959
	// Fetch above counters for this forum
$query = $db->simple_select("forums", implode(",", $counters), "fid='{$fid}'");
$forum = $db->fetch_array($query);

	// Fetch above counters for this forum
$query = $db->simple_select("forums", implode(",", $counters), "fid='{$fid}'");
$forum = $db->fetch_array($query);


foreach($counters as $counter)
{


foreach($counters as $counter)
{

		if(array_key_exists($counter, $changes))
{
// Adding or subtracting from previous value?

		if(array_key_exists($counter, $changes))
{
// Adding or subtracting from previous value?

Zeile 2245Zeile 2276
	global $forum_cache, $jumpfcache, $permissioncache, $mybb, $selecteddone, $forumjump, $forumjumpbits, $gobutton, $theme, $templates, $lang;

$pid = intval($pid);

	global $forum_cache, $jumpfcache, $permissioncache, $mybb, $selecteddone, $forumjump, $forumjumpbits, $gobutton, $theme, $templates, $lang;

$pid = intval($pid);

 
	$jumpsel['default'] = '';


if($permissions)
{


if($permissions)
{

Zeile 2272Zeile 2304
		$permissioncache = forum_permissions();
}


		$permissioncache = forum_permissions();
}


	if(is_array($jumpfcache[$pid]))

	if(isset($jumpfcache[$pid]) && is_array($jumpfcache[$pid]))

	{
foreach($jumpfcache[$pid] as $main)
{

	{
foreach($jumpfcache[$pid] as $main)
{

Zeile 2470Zeile 2502
			$string = str_replace("\"", "\\\"", $lang->$lang_string);
$editor_language .= "\t{$js_lang_string}: \"{$string}\"";


			$string = str_replace("\"", "\\\"", $lang->$lang_string);
$editor_language .= "\t{$js_lang_string}: \"{$string}\"";


			if($editor_lang_strings[$key+1])

			if(isset($editor_lang_strings[$key+1]))

			{
$editor_language .= ",";
}

			{
$editor_language .= ",";
}

Zeile 2532Zeile 2564
		{
reset($smiliecache);


		{
reset($smiliecache);


 
			$getmore = '';

			if($mybb->settings['smilieinsertertot'] >= $smiliecount)
{
$mybb->settings['smilieinsertertot'] = $smiliecount;

			if($mybb->settings['smilieinsertertot'] >= $smiliecount)
{
$mybb->settings['smilieinsertertot'] = $smiliecount;

Zeile 2872Zeile 2905
function get_reputation($reputation, $uid=0)
{
global $theme;

function get_reputation($reputation, $uid=0)
{
global $theme;

 

$display_reputation = '';


if($uid != 0)
{
$display_reputation = "<a href=\"reputation.php?uid={$uid}\">";


if($uid != 0)
{
$display_reputation = "<a href=\"reputation.php?uid={$uid}\">";

	}


	}


	$display_reputation .= "<strong class=\"";

if($reputation < 0)

	$display_reputation .= "<strong class=\"";

if($reputation < 0)

	{

	{

		$display_reputation .= "reputation_negative";
}
elseif($reputation > 0)

		$display_reputation .= "reputation_negative";
}
elseif($reputation > 0)

Zeile 2891Zeile 2926
	else
{
$display_reputation .= "reputation_neutral";

	else
{
$display_reputation .= "reputation_neutral";

	}

$display_reputation .= "\">{$reputation}</strong>";


	}

$display_reputation .= "\">{$reputation}</strong>";


	if($uid != 0)
{
$display_reputation .= "</a>";
}

	if($uid != 0)
{
$display_reputation .= "</a>";
}





	return $display_reputation;
}


	return $display_reputation;
}


Zeile 2908Zeile 2943
 *
* @param int The warning level (percentage of 100)
* @return string Formatted warning level

 *
* @param int The warning level (percentage of 100)
* @return string Formatted warning level

 */

 */

function get_colored_warning_level($level)
{
if($level >= 80)

function get_colored_warning_level($level)
{
if($level >= 80)

Zeile 2982Zeile 3017
    	$ip_array = array("ip" => &$ip); // Used for backwards compatibility on this hook with the updated run_hooks() function.
$plugins->run_hooks("get_ip", $ip_array);
}

    	$ip_array = array("ip" => &$ip); // Used for backwards compatibility on this hook with the updated run_hooks() function.
$plugins->run_hooks("get_ip", $ip_array);
}





    return $ip;
}


    return $ip;
}


Zeile 3115Zeile 3150
 */
function get_unviewable_forums($only_readable_threads=false)
{

 */
function get_unviewable_forums($only_readable_threads=false)
{

	global $forum_cache, $permissioncache, $mybb, $unviewableforums, $unviewable, $templates, $forumpass;

	global $forum_cache, $permissioncache, $mybb, $unviewable, $templates, $forumpass;





	$pid = intval($pid);

if(!$permissions)
{
$permissions = $mybb->usergroup;
}

if(!is_array($forum_cache))

	if(!is_array($forum_cache))








	{
cache_forums();

	{
cache_forums();

	}

	}


if(!is_array($permissioncache))
{


if(!is_array($permissioncache))
{

Zeile 3138Zeile 3166
	foreach($forum_cache as $fid => $forum)
{
if($permissioncache[$forum['fid']])

	foreach($forum_cache as $fid => $forum)
{
if($permissioncache[$forum['fid']])

		{

		{

			$perms = $permissioncache[$forum['fid']];
}
else

			$perms = $permissioncache[$forum['fid']];
}
else

Zeile 3156Zeile 3184
			}

$password_forums[$forum['fid']] = $forum['password'];

			}

$password_forums[$forum['fid']] = $forum['password'];

		}

		}

		else
{
// Check parents for passwords

		else
{
// Check parents for passwords

Zeile 3175Zeile 3203
			if($unviewableforums)
{
$unviewableforums .= ",";

			if($unviewableforums)
{
$unviewableforums .= ",";

			}


			}


			$unviewableforums .= "'".$forum['fid']."'";
}

			$unviewableforums .= "'".$forum['fid']."'";
}

	}

	}





	return $unviewableforums;




	if(isset($unviewableforums))
{
return $unviewableforums;
}

}

/**

}

/**

Zeile 3213Zeile 3244
	eval("\$navsep = \"".$templates->get("nav_sep")."\";");

$i = 0;

	eval("\$navsep = \"".$templates->get("nav_sep")."\";");

$i = 0;

 
	$activesep = '';

	
if(is_array($navbits))
{

	
if(is_array($navbits))
{

Zeile 3248Zeile 3280
				$navbit['url'] = preg_replace("/&amp;page=1$/", "", $navbit['url']);

eval("\$nav .= \"".$templates->get("nav_bit")."\";");

				$navbit['url'] = preg_replace("/&amp;page=1$/", "", $navbit['url']);

eval("\$nav .= \"".$templates->get("nav_bit")."\";");

			}
}
}


			}
}
}


	$navsize = count($navbits);
$navbit = $navbits[$navsize-1];


	$navsize = count($navbits);
$navbit = $navbits[$navsize-1];


Zeile 3271Zeile 3303
 *
* @param string The name of the item to add
* @param string The URL of the item to add

 *
* @param string The name of the item to add
* @param string The URL of the item to add

 */

 */

function add_breadcrumb($name, $url="")
{
global $navbits;

function add_breadcrumb($name, $url="")
{
global $navbits;





	$navsize = count($navbits);
$navbits[$navsize]['name'] = $name;
$navbits[$navsize]['url'] = $url;
}

	$navsize = count($navbits);
$navbits[$navsize]['name'] = $name;
$navbits[$navsize]['url'] = $url;
}





/**
* Build the forum breadcrumb nagiation (the navigation to a specific forum including all parent forums)
*

/**
* Build the forum breadcrumb nagiation (the navigation to a specific forum including all parent forums)
*

Zeile 3290Zeile 3322
function build_forum_breadcrumb($fid, $multipage=array())
{
global $pforumcache, $currentitem, $forum_cache, $navbits, $lang, $base_url, $archiveurl;

function build_forum_breadcrumb($fid, $multipage=array())
{
global $pforumcache, $currentitem, $forum_cache, $navbits, $lang, $base_url, $archiveurl;





	if(!$pforumcache)
{
if(!is_array($forum_cache))

	if(!$pforumcache)
{
if(!is_array($forum_cache))

Zeile 3310Zeile 3342
		{
if($fid == $forumnav['fid'])
{

		{
if($fid == $forumnav['fid'])
{

				if($pforumcache[$forumnav['pid']])

				if(!empty($pforumcache[$forumnav['pid']]))

				{
build_forum_breadcrumb($forumnav['pid']);
}

				{
build_forum_breadcrumb($forumnav['pid']);
}

Zeile 3319Zeile 3351
				// Convert & to &amp;
$navbits[$navsize]['name'] = preg_replace("#&(?!\#[0-9]+;)#si", "&amp;", $forumnav['name']);


				// Convert & to &amp;
$navbits[$navsize]['name'] = preg_replace("#&(?!\#[0-9]+;)#si", "&amp;", $forumnav['name']);


				if(IN_ARCHIVE == 1)

				if(defined("IN_ARCHIVE"))

				{
// Set up link to forum in breadcrumb.
if($pforumcache[$fid][$forumnav['pid']]['type'] == 'f' || $pforumcache[$fid][$forumnav['pid']]['type'] == 'c')

				{
// Set up link to forum in breadcrumb.
if($pforumcache[$fid][$forumnav['pid']]['type'] == 'f' || $pforumcache[$fid][$forumnav['pid']]['type'] == 'c')

Zeile 3330Zeile 3362
					{
$navbits[$navsize]['url'] = $archiveurl."/index.php";
}

					{
$navbits[$navsize]['url'] = $archiveurl."/index.php";
}

				}

				}

				elseif(!empty($multipage))
{
$navbits[$navsize]['url'] = get_forum_link($forumnav['fid'], $multipage['current_page']);

$navbits[$navsize]['multipage'] = $multipage;
$navbits[$navsize]['multipage']['url'] = str_replace('{fid}', $forumnav['fid'], FORUM_URL_PAGED);

				elseif(!empty($multipage))
{
$navbits[$navsize]['url'] = get_forum_link($forumnav['fid'], $multipage['current_page']);

$navbits[$navsize]['multipage'] = $multipage;
$navbits[$navsize]['multipage']['url'] = str_replace('{fid}', $forumnav['fid'], FORUM_URL_PAGED);

				}

				}

				else
{
$navbits[$navsize]['url'] = get_forum_link($forumnav['fid']);

				else
{
$navbits[$navsize]['url'] = get_forum_link($forumnav['fid']);

Zeile 3376Zeile 3408
	global $mybb;

// 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

	global $mybb;

// 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

	if((DIRECTORY_SEPARATOR == '\\' && is_numeric(stripos($_SERVER['SERVER_SOFTWARE'], "apache")) == false) || is_numeric(stripos(SAPI_NAME, "cgi")) !== false || defined("ARCHIVE_QUERY_STRINGS"))


	//if((DIRECTORY_SEPARATOR == '\\' && is_numeric(stripos($_SERVER['SERVER_SOFTWARE'], "apache")) == false) || is_numeric(stripos(SAPI_NAME, "cgi")) !== false || defined("ARCHIVE_QUERY_STRINGS"))
if($mybb->settings['seourls_archive'] == 1)

	{

	{

		$base_url = $mybb->settings['bburl']."/archive/index.php?";

		$base_url = $mybb->settings['bburl']."/archive/index.php/";

	}
else
{

	}
else
{

		$base_url = $mybb->settings['bburl']."/archive/index.php/";

		$base_url = $mybb->settings['bburl']."/archive/index.php?";

	}

switch($type)

	}

switch($type)

Zeile 3408Zeile 3441
 */
function debug_page()
{

 */
function debug_page()
{

	global $db, $debug, $templates, $templatelist, $mybb, $maintimer, $globaltime, $ptimer, $parsetime;

	global $db, $debug, $templates, $templatelist, $mybb, $maintimer, $globaltime, $ptimer, $parsetime, $lang;


$totaltime = $maintimer->totaltime;
$phptime = $maintimer->format($maintimer->totaltime - $db->query_time);


$totaltime = $maintimer->totaltime;
$phptime = $maintimer->format($maintimer->totaltime - $db->query_time);

Zeile 3473Zeile 3506
	echo "<td bgcolor=\"#FEFEFE\" width=\"25%\"><font face=\"Tahoma\" size=\"2\">".count($templates->cache)." (".intval(count(explode(",", $templatelist)))." Cached / ".intval(count($templates->uncached_templates))." Manually Loaded)</font></td>\n";
echo "</tr>\n";


	echo "<td bgcolor=\"#FEFEFE\" width=\"25%\"><font face=\"Tahoma\" size=\"2\">".count($templates->cache)." (".intval(count(explode(",", $templatelist)))." Cached / ".intval(count($templates->uncached_templates))." Manually Loaded)</font></td>\n";
echo "</tr>\n";


	if(function_exists("memory_get_usage"))


	$memory_usage = get_memory_usage();
if(!$memory_usage)

	{

	{

		$memory_usage = memory_get_peak_usage(true);
$memory_limit = @ini_get("memory_limit");
echo "<tr>\n";
echo "<td bgcolor=\"#EFEFEF\" width=\"25%\"><b><font face=\"Tahoma\" size=\"2\">Memory Usage:</font></b></td>\n";
echo "<td bgcolor=\"#FEFEFE\" width=\"25%\"><font face=\"Tahoma\" size=\"2\">".get_friendly_size($memory_usage)." ({$memory_usage} bytes)</font></td>\n";
echo "<td bgcolor=\"#EFEFEF\" width=\"25%\"><b><font face=\"Tahoma\" size=\"2\">Memory Limit:</font></b></td>\n";
echo "<td bgcolor=\"#FEFEFE\" width=\"25%\"><font face=\"Tahoma\" size=\"2\">{$memory_limit}</font></td>\n";
echo "</tr>\n";

		$memory_usage = $lang->unknown;








	}

	}

 
	else
{
$memory_usage = get_friendly_size($memory_usage)." ({$memory_usage} bytes)";
}
$memory_limit = @ini_get("memory_limit");
echo "<tr>\n";
echo "<td bgcolor=\"#EFEFEF\" width=\"25%\"><b><font face=\"Tahoma\" size=\"2\">Memory Usage:</font></b></td>\n";
echo "<td bgcolor=\"#FEFEFE\" width=\"25%\"><font face=\"Tahoma\" size=\"2\">{$memory_usage}</font></td>\n";
echo "<td bgcolor=\"#EFEFEF\" width=\"25%\"><b><font face=\"Tahoma\" size=\"2\">Memory Limit:</font></b></td>\n";
echo "<td bgcolor=\"#FEFEFE\" width=\"25%\"><font face=\"Tahoma\" size=\"2\">{$memory_limit}</font></td>\n";
echo "</tr>\n";


echo "</table>\n";



echo "</table>\n";


Zeile 3610Zeile 3648
	$hsecs = 60*60;
$msecs = 60;


	$hsecs = 60*60;
$msecs = 60;


	if($options['short'] == true)

	if(isset($options['short']))

	{
$lang_year = $lang->year_short;
$lang_years = $lang->years_short;

	{
$lang_year = $lang->year_short;
$lang_years = $lang->years_short;

Zeile 3695Zeile 3733
		$nicetime['days'] = $days.$lang_days;
}


		$nicetime['days'] = $days.$lang_days;
}


	if($options['hours'] !== false)

	if(!isset($options['hours']) || $options['hours'] !== false)

	{
if($hours == 1)
{

	{
if($hours == 1)
{

Zeile 3707Zeile 3745
		}
}


		}
}


	if($options['minutes'] !== false)

	if(!isset($options['minutes']) || $options['minutes'] !== false)

	{
if($minutes == 1)
{

	{
if($minutes == 1)
{

Zeile 3719Zeile 3757
		}
}


		}
}


	if($options['seconds'] !== false)

	if(!isset($options['seconds']) || $options['seconds'] !== false)

	{
if($seconds == 1)
{

	{
if($seconds == 1)
{

Zeile 3805Zeile 3843
	{
$db->update_query("users", array('additionalgroups' => $groupslist), "uid='".intval($uid)."'");
return true;

	{
$db->update_query("users", array('additionalgroups' => $groupslist), "uid='".intval($uid)."'");
return true;

	}
else
{
return false;
}
}

/**

	}
else
{
return false;
}
}

/**

 * Remove a user from a specific additional user group
*
* @param int The user ID

 * Remove a user from a specific additional user group
*
* @param int The user ID

Zeile 3905Zeile 3943
		{
$ignore = array($ignore);
}

		{
$ignore = array($ignore);
}

		



		$form_html = "";

		$form_html = "";

		$field_parts = explode('&', $field_parts);


 
		if(!empty($mybb->input))
{
foreach($mybb->input as $name => $value)
{
if(in_array($name, $ignore))

		if(!empty($mybb->input))
{
foreach($mybb->input as $name => $value)
{
if(in_array($name, $ignore))

				{

				{

					continue;
}


					continue;
}


				$form_html .= "<input type=\"hidden\" name=\"".htmlspecialchars((string)$name)."\" value=\"".htmlspecialchars((string)$value)."\" />\n";

				$form_html .= "<input type=\"hidden\" name=\"".htmlspecialchars_uni((string)$name)."\" value=\"".htmlspecialchars_uni((string)$value)."\" />\n";

			}
}


			}
}


Zeile 3944Zeile 3980
				if(isset($_POST[$var]))
{
$addloc[] = urlencode($var).'='.urlencode($_POST[$var]);

				if(isset($_POST[$var]))
{
$addloc[] = urlencode($var).'='.urlencode($_POST[$var]);

				}

				}

			}

if(isset($addloc) && is_array($addloc))

			}

if(isset($addloc) && is_array($addloc))

Zeile 3952Zeile 3988
				if(strpos($location, "?") === false)
{
$location .= "?";

				if(strpos($location, "?") === false)
{
$location .= "?";

				}

				}

				else
{
$location .= "&amp;";
}
$location .= implode("&amp;", $addloc);
}

				else
{
$location .= "&amp;";
}
$location .= implode("&amp;", $addloc);
}

		}


		}


		if(strlen($location) > 150)
{
$location = substr($location, 0, 150);
}

		if(strlen($location) > 150)
{
$location = substr($location, 0, 150);
}





		return $location;

		return $location;

	}
}

/**

	}
}

/**

 * Build a theme selection menu
*
* @param string The name of the menu

 * Build a theme selection menu
*
* @param string The name of the menu

Zeile 3990Zeile 4026
		$themeselect .= "<option value=\"0\">".$lang->use_default."</option>\n";
$themeselect .= "<option value=\"0\">-----------</option>\n";
$tid = 1;

		$themeselect .= "<option value=\"0\">".$lang->use_default."</option>\n";
$themeselect .= "<option value=\"0\">-----------</option>\n";
$tid = 1;

	}

	}


if(!is_array($tcache))
{


if(!is_array($tcache))
{

Zeile 3999Zeile 4035
		while($theme = $db->fetch_array($query))
{
$tcache[$theme['pid']][$theme['tid']] = $theme;

		while($theme = $db->fetch_array($query))
{
$tcache[$theme['pid']][$theme['tid']] = $theme;

		}

		}

	}

if(is_array($tcache[$tid]))

	}

if(is_array($tcache[$tid]))

Zeile 4040Zeile 4076

if($theme['pid'] != 0)
{


if($theme['pid'] != 0)
{

					$themeselect .= "<option value=\"".$theme['tid']."\"$sel>".$depth.$theme['name']."</option>";

					$themeselect .= "<option value=\"".$theme['tid']."\"$sel>".$depth.htmlspecialchars_uni($theme['name'])."</option>";

					$depthit = $depth."--";
}

if(array_key_exists($theme['tid'], $tcache))
{
build_theme_select($name, $selected, $theme['tid'], $depthit, $usergroup_override);

					$depthit = $depth."--";
}

if(array_key_exists($theme['tid'], $tcache))
{
build_theme_select($name, $selected, $theme['tid'], $depthit, $usergroup_override);

				}
}

				}
}

		}

		}

	}


	}


	if($tid == 1)
{
$themeselect .= "</select>";

	if($tid == 1)
{
$themeselect .= "</select>";

	}


	}


	return $themeselect;
}


	return $themeselect;
}


Zeile 4095Zeile 4131
		return number_format($number, 0, $mybb->settings['decpoint'], $mybb->settings['thousandssep']);
}
else

		return number_format($number, 0, $mybb->settings['decpoint'], $mybb->settings['thousandssep']);
}
else

	{

	{

		$parts = explode('.', $number);

if(isset($parts[1]))

		$parts = explode('.', $number);

if(isset($parts[1]))

Zeile 4124Zeile 4160
	}

if($charset == "utf-8")

	}

if($charset == "utf-8")

	{
return $str;
}

	{
return $str;
}

	
if(!isset($use_iconv))
{

	
if(!isset($use_iconv))
{

Zeile 4162Zeile 4198
	elseif($charset == "iso-8859-1" && function_exists("utf8_encode"))
{
if($to)

	elseif($charset == "iso-8859-1" && function_exists("utf8_encode"))
{
if($to)

		{

		{

			return utf8_encode($str);
}
else

			return utf8_encode($str);
}
else

Zeile 4201Zeile 4237
	}

return $message;

	}

return $message;

}

/**
* Workaround for date limitation in PHP to establish the day of a birthday (Provided by meme)

}

/**
* Workaround for date limitation in PHP to establish the day of a birthday (Provided by meme)

 *
* @param int The month of the birthday
* @param int The day of the birthday

 *
* @param int The month of the birthday
* @param int The day of the birthday

Zeile 4357Zeile 4393
	}

return str_replace($find, $replace, $display);

	}

return str_replace($find, $replace, $display);

}

/**

}

/**

 * Returns the age of a user with specified birthday.
*
* @param string The birthday of a user.

 * Returns the age of a user with specified birthday.
*
* @param string The birthday of a user.

Zeile 4369Zeile 4405
{
$bday = explode("-", $birthday);
if(!$bday[2])

{
$bday = explode("-", $birthday);
if(!$bday[2])

	{

	{

		return;
}


		return;
}


Zeile 4388Zeile 4424
 * Updates the first posts in a thread.
*
* @param int The thread id for which to update the first post id.

 * Updates the first posts in a thread.
*
* @param int The thread id for which to update the first post id.

 */

 */

function update_first_post($tid)
{
global $db;

function update_first_post($tid)
{
global $db;

Zeile 4427Zeile 4463
        // Get rid of any excess RTL and LTR override for they are the workings of the devil
$string = str_replace(dec_to_utf8(8238), "", $string);
$string = str_replace(dec_to_utf8(8237), "", $string);

        // Get rid of any excess RTL and LTR override for they are the workings of the devil
$string = str_replace(dec_to_utf8(8238), "", $string);
$string = str_replace(dec_to_utf8(8237), "", $string);





        // Remove dodgy whitespaces
$string = str_replace(chr(0xCA), "", $string);
}

        // Remove dodgy whitespaces
$string = str_replace(chr(0xCA), "", $string);
}

Zeile 4436Zeile 4472
    if(function_exists("mb_strlen"))
{
$string_length = mb_strlen($string);

    if(function_exists("mb_strlen"))
{
$string_length = mb_strlen($string);

    }

    }

    else
{
$string_length = strlen($string);

    else
{
$string_length = strlen($string);

Zeile 4455Zeile 4491
 * @return int The cut part of the string.
*/
function my_substr($string, $start, $length="", $handle_entities = false)

 * @return int The cut part of the string.
*/
function my_substr($string, $start, $length="", $handle_entities = false)

{

{

	if($handle_entities)

	if($handle_entities)

	{

	{

		$string = unhtmlentities($string);
}
if(function_exists("mb_substr"))

		$string = unhtmlentities($string);
}
if(function_exists("mb_substr"))

Zeile 4465Zeile 4501
		if($length != "")
{
$cut_string = mb_substr($string, $start, $length);

		if($length != "")
{
$cut_string = mb_substr($string, $start, $length);

		}

		}

		else
{
$cut_string = mb_substr($string, $start);

		else
{
$cut_string = mb_substr($string, $start);

Zeile 4474Zeile 4510
	else
{
if($length != "")

	else
{
if($length != "")

		{

		{

			$cut_string = substr($string, $start, $length);
}
else

			$cut_string = substr($string, $start, $length);
}
else

Zeile 4512Zeile 4548

/**
* Finds a needle in a haystack and returns it position, mb strings accounted for


/**
* Finds a needle in a haystack and returns it position, mb strings accounted for

 *

 *

 * @param string String to look in (haystack)
* @param string What to look for (needle)
* @param int (optional) How much to offset

 * @param string String to look in (haystack)
* @param string What to look for (needle)
* @param int (optional) How much to offset

Zeile 4521Zeile 4557
function my_strpos($haystack, $needle, $offset=0)
{
if($needle == '')

function my_strpos($haystack, $needle, $offset=0)
{
if($needle == '')

	{

	{

		return false;
}


		return false;
}


Zeile 4550Zeile 4586
		$string = mb_strtoupper($string);
}
else

		$string = mb_strtoupper($string);
}
else

	{

	{

		$string = strtoupper($string);
}


		$string = strtoupper($string);
}


Zeile 4589Zeile 4625
        return chr($c);
}
else if($c <= 0x7FF)

        return chr($c);
}
else if($c <= 0x7FF)

	{

	{

        return chr(0xC0 | $c >> 6) . chr(0x80 | $c & 0x3F);
}
else if($c <= 0xFFFF)

        return chr(0xC0 | $c >> 6) . chr(0x80 | $c & 0x3F);
}
else if($c <= 0xFFFF)

Zeile 4736Zeile 4772
function get_thread_link($tid, $page=0, $action='')
{
if($page > 1)

function get_thread_link($tid, $page=0, $action='')
{
if($page > 1)

	{
if($action)
{
$link = THREAD_URL_ACTION;
$link = str_replace("{action}", $action, $link);
}
else
{

	{
if($action)
{
$link = THREAD_URL_ACTION;
$link = str_replace("{action}", $action, $link);
}
else
{

			$link = THREAD_URL_PAGED;
}
$link = str_replace("{tid}", $tid, $link);

			$link = THREAD_URL_PAGED;
}
$link = str_replace("{tid}", $tid, $link);

Zeile 5047Zeile 5083
	// Note: Number of logins is defaulted to 1, because using 0 seems to clear cookie data. Not really a problem as long as we account for 1 being default.

// Use cookie if possible, otherwise use session

	// Note: Number of logins is defaulted to 1, because using 0 seems to clear cookie data. Not really a problem as long as we account for 1 being default.

// Use cookie if possible, otherwise use session

	// Session stops user clearing cookies to bypass the login
// Also use the greater of the two numbers present, stops people using scripts with altered cookie data to stay the same
$cookielogins = intval($mybb->cookies['loginattempts']);
$cookietime = $mybb->cookies['failedlogin'];

	// Find better solution to prevent clearing cookies
$loginattempts = 0;
$failedlogin = 0;






	if(empty($cookielogins) || $cookielogins < $session->logins)

	if(!empty($mybb->cookies['loginattempts']))

	{

	{

		$loginattempts = $session->logins;
}
else
{
$loginattempts = $cookielogins;

		$loginattempts = $mybb->cookies['loginattempts'];





	}


	}


	if(empty($cookietime) || $cookietime < $session->failedlogin)
{
$failedlogin = $session->failedlogin;
}
else

	if(!empty($mybb->cookies['failedlogin']))





	{

	{

		$failedlogin = $cookietime;

		$failedlogin = $mybb->cookies['failedlogin'];

	}

// Work out if the user has had more than the allowed number of login attempts

	}

// Work out if the user has had more than the allowed number of login attempts

Zeile 5778Zeile 5805

if($ip == "*")
{


if($ip == "*")
{

		return array(ip2long('0.0.0.0'), ip2long('255.255.255.255'));

		return array(my_ip2long('128.0.0.0'), my_ip2long('127.255.255.255'));

	}

if(strpos($ip, ".*") === false)

	}

if(strpos($ip, ".*") === false)

Zeile 5786Zeile 5813
		$ip = str_replace("*", "", $ip);
if(count($ip_bits) == 4)
{

		$ip = str_replace("*", "", $ip);
if(count($ip_bits) == 4)
{

			return ip2long($ip);

			return my_ip2long($ip);

		}
else
{

		}
else
{

			return array(ip2long($ip.".0"), ip2long($ip.".255"));

			return array(my_ip2long($ip.".0"), my_ip2long($ip.".255"));

		}
}
// Wildcard based IP provided

		}
}
// Wildcard based IP provided

Zeile 5811Zeile 5838
			}
$sep = ".";
}

			}
$sep = ".";
}

		return array(ip2long($ip_string1), ip2long($ip_string2));

		return array(my_ip2long($ip_string1), my_ip2long($ip_string2));

	}
}


	}
}