Vergleich inc/functions.php - 1.4.4 - 1.4.15

  Keine Änderungen   Hinzugefügt   Modifiziert   Entfernt
Zeile 1Zeile 1
<?php
/**
* MyBB 1.4

<?php
/**
* MyBB 1.4

 * Copyright � 2008 MyBB Group, All Rights Reserved

 * Copyright © 2008 MyBB Group, All Rights Reserved

 *
* Website: http://www.mybboard.net
* License: http://www.mybboard.net/about/license
*

 *
* Website: http://www.mybboard.net
* License: http://www.mybboard.net/about/license
*

 * $Id: functions.php 4279 2008-11-26 00:01:25Z Tikitiki $

 * $Id: functions.php 5379 2011-02-21 11:06:42Z Tomm $

 */

/**

 */

/**

Zeile 154Zeile 154
	// 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))

		if(!isset($config) || empty($config['database']['type']))

		{
require MYBB_ROOT."inc/config.php";
}

		{
require MYBB_ROOT."inc/config.php";
}

Zeile 228Zeile 228
/**
* Sends a specified amount of messages from the mail queue
*

/**
* Sends a specified amount of messages from the mail queue
*

 * @param int The number of messages to send (Defaults to 20)

 * @param int The number of messages to send (Defaults to 10)

 */
function send_mail_queue($count=10)
{

 */
function send_mail_queue($count=10)
{

Zeile 454Zeile 454
	}

// Build and send

	}

// Build and send

	$mail->build_message($to, $subject, $message, $from, $charset, $headers, $format, $message_text);

	$mail->build_message($to, $subject, $message, $from, $charset, $headers, $format, $message_text, $return_email);

	return $mail->send();
}


	return $mail->send();
}


Zeile 473Zeile 473
	// Guests get a special string
else
{

	// Guests get a special string
else
{

		return md5($mybb->config['database']['hostname'].$mybb->config['database']['username'].md5($mybb->config['database']['password']));

		return md5($mybb->settings['bburl'].$mybb->config['database']['username'].$mybb->settings['internal']['encryption_key']);

	}
}


	}
}


Zeile 494Zeile 494
		}
else
{

		}
else
{

			error($lang->invalid_post_code);








			if(defined("IN_ADMINCP"))
{
return false;
}
else
{
error($lang->invalid_post_code);
}

		}
}
else

		}
}
else

Zeile 640Zeile 647
	if(!$error)
{
$error = $lang->unknown_error;

	if(!$error)
{
$error = $lang->unknown_error;

	}

// AJAX error message?
if($mybb->input['ajax'])
{

	}

// AJAX error message?
if($mybb->input['ajax'])
{

		// Send our headers.
@header("Content-type: text/html; charset={$lang->settings['charset']}");
echo "<error>{$error}</error>\n";

		// Send our headers.
@header("Content-type: text/html; charset={$lang->settings['charset']}");
echo "<error>{$error}</error>\n";

Zeile 802Zeile 809
	}
else
{

	}
else
{

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

 
		$url = htmlspecialchars_decode($url);
$url = str_replace(array("\n","\r",";"), "", $url);


		$url = htmlspecialchars_decode($url);
$url = str_replace(array("\n","\r",";"), "", $url);


Zeile 949Zeile 955
	global $mybb, $cache, $groupscache, $user_cache;

// If no user id is specified, assume it is the current user

	global $mybb, $cache, $groupscache, $user_cache;

// If no user id is specified, assume it is the current user

	if($uid == 0)
{
$uid = $mybb->user['uid'];
}


	if($uid == 0)
{
$uid = $mybb->user['uid'];
}


	// User id does not match current user, fetch permissions
if($uid != $mybb->user['uid'])
{

	// User id does not match current user, fetch permissions
if($uid != $mybb->user['uid'])
{

Zeile 1000Zeile 1006
	}

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

	}

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



 

if(count($groups) == 1)


if(count($groups) == 1)

	{

	{

		return $groupscache[$gid];
}


		return $groupscache[$gid];
}


Zeile 1028Zeile 1033
				}

// 0 represents unlimited for numerical group permissions (i.e. private message limit) so take that into account.

				}

// 0 represents unlimited for numerical group permissions (i.e. private message limit) so take that into account.

				if(in_array($perm, $groupzerogreater) && ($access == 0 || $usergroup[$perm] == 0))

				if(in_array($perm, $groupzerogreater) && ($access == 0 || $permbit === 0))

				{
$usergroup[$perm] = 0;
continue;

				{
$usergroup[$perm] = 0;
continue;

				} 

				}


if($access > $permbit || ($access == "yes" && $permbit == "no") || !$permbit) // Keep yes/no for compatibility?
{


if($access > $permbit || ($access == "yes" && $permbit == "no") || !$permbit) // Keep yes/no for compatibility?
{

Zeile 1092Zeile 1097
	{
if($uid != 0 && $uid != $mybb->user['uid'])
{

	{
if($uid != 0 && $uid != $mybb->user['uid'])
{

			if($usercache[$uid])

			if(!$usercache[$uid])

			{
$query = $db->simple_select("users", "*", "uid='$uid'");
$usercache[$uid] = $db->fetch_array($query);

			{
$query = $db->simple_select("users", "*", "uid='$uid'");
$usercache[$uid] = $db->fetch_array($query);

Zeile 1111Zeile 1116
			}

$groupperms = $mybb->usergroup;

			}

$groupperms = $mybb->usergroup;

		}
}

if(!is_array($forum_cache))
{
$forum_cache = cache_forums();

if(!$forum_cache)

		}
}

if(!is_array($forum_cache))
{
$forum_cache = cache_forums();

if(!$forum_cache)

		{
return false;
}

		{
return false;
}

Zeile 1127Zeile 1132
	if(!is_array($fpermcache))
{
$fpermcache = $cache->read("forumpermissions");

	if(!is_array($fpermcache))
{
$fpermcache = $cache->read("forumpermissions");

	}


	}


	if($fid) // Fetch the permissions for a single forum
{
if(!$cached_forum_permissions_permissions[$gid][$fid])

	if($fid) // Fetch the permissions for a single forum
{
if(!$cached_forum_permissions_permissions[$gid][$fid])

Zeile 1138Zeile 1143
		return $cached_forum_permissions_permissions[$gid][$fid];
}
else

		return $cached_forum_permissions_permissions[$gid][$fid];
}
else

	{

	{

		if(!$cached_forum_permissions[$gid])
{
foreach($forum_cache as $forum)

		if(!$cached_forum_permissions[$gid])
{
foreach($forum_cache as $forum)

Zeile 1196Zeile 1201
					
// If we STILL don't have forum permissions we use the usergroup itself
if(empty($level_permissions))

					
// If we STILL don't have forum permissions we use the usergroup itself
if(empty($level_permissions))

					{

					{

						$level_permissions = $groupscache[$gid];
}
}

						$level_permissions = $groupscache[$gid];
}
}

Zeile 1262Zeile 1267
	$password = $forum_cache[$fid]['password'];
if($password)
{

	$password = $forum_cache[$fid]['password'];
if($password)
{

		if($mybb->input['pwverify'])

		if($mybb->input['pwverify'] && $pid == 0)

		{
if($password == $mybb->input['pwverify'])
{

		{
if($password == $mybb->input['pwverify'])
{

Zeile 1272Zeile 1277
			else
{
eval("\$pwnote = \"".$templates->get("forumdisplay_password_wrongpass")."\";");

			else
{
eval("\$pwnote = \"".$templates->get("forumdisplay_password_wrongpass")."\";");

				$showform = true;
}
}

				$showform = true;
}
}

		else
{
if(!$mybb->cookies['forumpass'][$fid] || ($mybb->cookies['forumpass'][$fid] && md5($mybb->user['uid'].$password) != $mybb->cookies['forumpass'][$fid]))

		else
{
if(!$mybb->cookies['forumpass'][$fid] || ($mybb->cookies['forumpass'][$fid] && md5($mybb->user['uid'].$password) != $mybb->cookies['forumpass'][$fid]))

Zeile 1285Zeile 1290
			{
$showform = false;
}

			{
$showform = false;
}

		}
}

		}
}

	else
{
$showform = false;

	else
{
$showform = false;

Zeile 1294Zeile 1299

if($showform)
{


if($showform)
{

		$_SERVER['REQUEST_URI'] = htmlspecialchars_uni($_SERVER['REQUEST_URI']);
eval("\$pwform = \"".$templates->get("forumdisplay_password")."\";");
output_page($pwform);








		if($pid)
{
header("Location: ".$mybb->settings['bburl']."/".get_forum_link($fid));
}
else
{
$_SERVER['REQUEST_URI'] = htmlspecialchars_uni($_SERVER['REQUEST_URI']);
eval("\$pwform = \"".$templates->get("forumdisplay_password")."\";");
output_page($pwform);
}

		exit;
}
}

		exit;
}
}

Zeile 1510Zeile 1522

// Versions of PHP prior to 5.2 do not support HttpOnly cookies and IE is buggy when specifying a blank domain so set the cookie manually
$cookie = "Set-Cookie: {$mybb->settings['cookieprefix']}{$name}=".urlencode($value);


// Versions of PHP prior to 5.2 do not support HttpOnly cookies and IE is buggy when specifying a blank domain so set the cookie manually
$cookie = "Set-Cookie: {$mybb->settings['cookieprefix']}{$name}=".urlencode($value);





	if($expires > 0)
{
$cookie .= "; expires=".@gmdate('D, d-M-Y H:i:s \\G\\M\\T', $expires);

	if($expires > 0)
{
$cookie .= "; expires=".@gmdate('D, d-M-Y H:i:s \\G\\M\\T', $expires);

Zeile 1569Zeile 1581

$cookie = unserialize($mybb->cookies['mybb'][$name]);



$cookie = unserialize($mybb->cookies['mybb'][$name]);


	if(isset($cookie[$id]))

	if(is_array($cookie) && isset($cookie[$id]))

	{
return $cookie[$id];
}

	{
return $cookie[$id];
}

Zeile 1592Zeile 1604
	
$cookie = $mybb->cookies['mybb'];
$newcookie = unserialize($cookie[$name]);

	
$cookie = $mybb->cookies['mybb'];
$newcookie = unserialize($cookie[$name]);

 

if(!is_array($newcookie))
{
// Burnt / malformed cookie - reset
$newcookie = array();
}


	$newcookie[$id] = $value;

	$newcookie[$id] = $value;

	$newcookie = addslashes(serialize($newcookie));
my_setcookie("mybb[$name]", $newcookie);




	$newcookie = serialize($newcookie);
my_setcookie("mybb[$name]", addslashes($newcookie));

// Make sure our current viarables are up-to-date as well
$mybb->cookies['mybb'][$name] = $newcookie;

}

/**

}

/**

Zeile 1616Zeile 1638
			$serverload = explode(" ", $load);
$serverload[0] = round($serverload[0], 4);
}

			$serverload = explode(" ", $load);
$serverload[0] = round($serverload[0], 4);
}

		if(!$serverload)

		if(!is_numeric($serverload[0]))

		{
if(@ini_get('safe_mode') == 'On')
{

		{
if(@ini_get('safe_mode') == 'On')
{

Zeile 1641Zeile 1663
			}

$load = @exec("uptime");

			}

$load = @exec("uptime");

			$load = split("load averages?: ", $load);

			$load = explode("load average: ", $load);

			$serverload = explode(",", $load[1]);
if(!is_array($serverload))
{

			$serverload = explode(",", $load[1]);
if(!is_array($serverload))
{

Zeile 1740Zeile 1762
	// 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)
{
if(array_key_exists($counter, $changes))
{
// Adding or subtracting from previous value?
if(substr($changes[$counter], 0, 1) == "+" || substr($changes[$counter], 0, 1) == "-")
{


foreach($counters as $counter)
{
if(array_key_exists($counter, $changes))
{
// Adding or subtracting from previous value?
if(substr($changes[$counter], 0, 1) == "+" || substr($changes[$counter], 0, 1) == "-")
{

				$update_query[$counter] = $forum[$counter] + $changes[$counter];
}
else

				$update_query[$counter] = $forum[$counter] + $changes[$counter];
}
else

Zeile 1786Zeile 1808
		}

if(array_key_exists('unapprovedthreads', $update_query))

		}

if(array_key_exists('unapprovedthreads', $update_query))

		{

		{

			$unapprovedthreads_diff = $update_query['unapprovedthreads'] - $forum['unapprovedthreads'];
if($unapprovedthreads_diff > -1)

			$unapprovedthreads_diff = $update_query['unapprovedthreads'] - $forum['unapprovedthreads'];
if($unapprovedthreads_diff > -1)

			{

			{

				$new_stats['numunapprovedthreads'] = "+{$unapprovedthreads_diff}";

				$new_stats['numunapprovedthreads'] = "+{$unapprovedthreads_diff}";

			}

			}

			else
{
$new_stats['numunapprovedthreads'] = "{$unapprovedthreads_diff}";

			else
{
$new_stats['numunapprovedthreads'] = "{$unapprovedthreads_diff}";

			}
}

			}
}

		
if(array_key_exists('posts', $update_query))
{
$posts_diff = $update_query['posts'] - $forum['posts'];
if($posts_diff > -1)

		
if(array_key_exists('posts', $update_query))
{
$posts_diff = $update_query['posts'] - $forum['posts'];
if($posts_diff > -1)

			{

			{

				$new_stats['numposts'] = "+{$posts_diff}";

				$new_stats['numposts'] = "+{$posts_diff}";

			}
else
{

			}
else
{

				$new_stats['numposts'] = "{$posts_diff}";
}
}

				$new_stats['numposts'] = "{$posts_diff}";
}
}

Zeile 1824Zeile 1846
			}
}
update_stats($new_stats);

			}
}
update_stats($new_stats);

	}


	}


	// Update last post info
update_forum_lastpost($fid);

	// Update last post info
update_forum_lastpost($fid);

 
	
$cache->update_forums();

}

/**

}

/**

Zeile 1884Zeile 1908
		{
// Adding or subtracting from previous value?
if(substr($changes[$counter], 0, 1) == "+" || substr($changes[$counter], 0, 1) == "-")

		{
// Adding or subtracting from previous value?
if(substr($changes[$counter], 0, 1) == "+" || substr($changes[$counter], 0, 1) == "-")

			{

			{

				$update_query[$counter] = $thread[$counter] + $changes[$counter];
}
else

				$update_query[$counter] = $thread[$counter] + $changes[$counter];
}
else

Zeile 1903Zeile 1927

// Only update if we're actually doing something
if(count($update_query) > 0)


// Only update if we're actually doing something
if(count($update_query) > 0)

	{

	{

		$db->update_query("threads", $update_query, "tid='".intval($tid)."'");
}


		$db->update_query("threads", $update_query, "tid='".intval($tid)."'");
}


Zeile 1967Zeile 1991
	$update_array = array(
'username' => $firstpost['username'],
'uid' => intval($firstpost['uid']),

	$update_array = array(
'username' => $firstpost['username'],
'uid' => intval($firstpost['uid']),

 
		'dateline' => intval($firstpost['dateline']),

		'lastpost' => intval($lastpost['dateline']),
'lastposter' => $lastpost['username'],
'lastposteruid' => intval($lastpost['uid']),

		'lastpost' => intval($lastpost['dateline']),
'lastposter' => $lastpost['username'],
'lastposteruid' => intval($lastpost['uid']),

Zeile 2033Zeile 2058
 * @param int If we need to add select boxes to this cal or not
* @param int The current depth of forums we're at
* @param int Whether or not to show extra items such as User CP, Forum home

 * @param int If we need to add select boxes to this cal or not
* @param int The current depth of forums we're at
* @param int Whether or not to show extra items such as User CP, Forum home

 
 * @param boolean Ignore the showinjump setting and show all forums (for moderation pages)

 * @param array Array of permissions
* @param string The name of the forum jump
* @return string Forum jump items
*/

 * @param array Array of permissions
* @param string The name of the forum jump
* @return string Forum jump items
*/

function build_forum_jump($pid="0", $selitem="", $addselect="1", $depth="", $showextras="1", $permissions="", $name="fid")

function build_forum_jump($pid="0", $selitem="", $addselect="1", $depth="", $showextras="1", $showall=false, $permissions="", $name="fid")

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


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


Zeile 2077Zeile 2103
			{
$perms = $permissioncache[$forum['fid']];


			{
$perms = $permissioncache[$forum['fid']];


				if($forum['fid'] != "0" && ($perms['canview'] != 0 || $mybb->settings['hideprivateforums'] == 0) && $forum['linkto'] == '' && $forum['showinjump'] != 0)

				if($forum['fid'] != "0" && ($perms['canview'] != 0 || $mybb->settings['hideprivateforums'] == 0) && $forum['linkto'] == '' && ($forum['showinjump'] != 0 || $showall == true))

				{
$optionselected = "";


				{
$optionselected = "";


Zeile 2094Zeile 2120
					if($forum_cache[$forum['fid']])
{
$newdepth = $depth."--";

					if($forum_cache[$forum['fid']])
{
$newdepth = $depth."--";

						$forumjumpbits .= build_forum_jump($forum['fid'], $selitem, 0, $newdepth, $showextras);

						$forumjumpbits .= build_forum_jump($forum['fid'], $selitem, 0, $newdepth, $showextras, $showall);

					}
}
}

					}
}
}

Zeile 2137Zeile 2163
function get_extension($file)
{
return my_strtolower(my_substr(strrchr($file, "."), 1));

function get_extension($file)
{
return my_strtolower(my_substr(strrchr($file, "."), 1));

}

/**

}

/**

 * Generates a random string.
*
* @param int The length of the string to generate.

 * Generates a random string.
*
* @param int The length of the string to generate.

Zeile 2152Zeile 2178

for($i = 1; $i <= $length; ++$i)
{


for($i = 1; $i <= $length; ++$i)
{

		$ch = mt_rand(0, count($set)-1);

		$ch = my_rand(0, count($set)-1);

		$str .= $set[$ch];
}


		$str .= $set[$ch];
}


Zeile 2295Zeile 2321
		if(!$smiliecache)
{
if(!is_array($smilie_cache))

		if(!$smiliecache)
{
if(!is_array($smilie_cache))

			{

			{

				$smilie_cache = $cache->read("smilies");

				$smilie_cache = $cache->read("smilies");

			}

			}

			foreach($smilie_cache as $smilie)
{
if($smilie['showclickable'] != 0)
{
$smiliecache[$smilie['find']] = $smilie['image'];

			foreach($smilie_cache as $smilie)
{
if($smilie['showclickable'] != 0)
{
$smiliecache[$smilie['find']] = $smilie['image'];

				}
}
}

				}
}
}


unset($smilie);



unset($smilie);


Zeile 2334Zeile 2360
					if($counter == 0)
{
$smilies .= "<tr>\n";

					if($counter == 0)
{
$smilies .= "<tr>\n";

					}

					}


$find = htmlspecialchars_uni($find);
$smilies .= "<td style=\"text-align: center\"><img src=\"{$image}\" border=\"0\" class=\"smilie\" alt=\"{$find}\" /></td>\n";


$find = htmlspecialchars_uni($find);
$smilies .= "<td style=\"text-align: center\"><img src=\"{$image}\" border=\"0\" class=\"smilie\" alt=\"{$find}\" /></td>\n";

Zeile 2372Zeile 2398

/**
* Gzip encodes text to a specified level


/**
* Gzip encodes text to a specified level

 *

 *

 * @param string The string to encode
* @param int The level (1-9) to encode at
* @return string The encoded string

 * @param string The string to encode
* @param int The level (1-9) to encode at
* @return string The encoded string

Zeile 2527Zeile 2553
		return "<span class=\"high_warning\">{$level}%</span>";
}
else if($level >= 50)

		return "<span class=\"high_warning\">{$level}%</span>";
}
else if($level >= 50)

	{

	{

		return "<span class=\"moderate_warning\">{$level}%</span>";
}
else if($level >= 25)

		return "<span class=\"moderate_warning\">{$level}%</span>";
}
else if($level >= 25)

Zeile 2680Zeile 2706
		{
global $change_dir;
$icon = $change_dir."/".str_replace("{theme}", $theme['imgdir'], $attachtypes[$ext]['icon']);

		{
global $change_dir;
$icon = $change_dir."/".str_replace("{theme}", $theme['imgdir'], $attachtypes[$ext]['icon']);

		}
else
{

		}
else
{

			$icon = str_replace("{theme}", $theme['imgdir'], $attachtypes[$ext]['icon']);
}
return "<img src=\"{$icon}\" border=\"0\" alt=\".{$ext}\" />";

			$icon = str_replace("{theme}", $theme['imgdir'], $attachtypes[$ext]['icon']);
}
return "<img src=\"{$icon}\" border=\"0\" alt=\".{$ext}\" />";

Zeile 2692Zeile 2718
		if(defined("IN_ADMINCP"))
{
$theme['imgdir'] = "../images";

		if(defined("IN_ADMINCP"))
{
$theme['imgdir'] = "../images";

		}

		}

		else if(defined("IN_PORTAL"))
{
global $change_dir;

		else if(defined("IN_PORTAL"))
{
global $change_dir;

Zeile 2702Zeile 2728
		return "<img src=\"{$theme['imgdir']}/attachtypes/unknown.gif\" border=\"0\" alt=\".{$ext}\" />";
}
}

		return "<img src=\"{$theme['imgdir']}/attachtypes/unknown.gif\" border=\"0\" alt=\".{$ext}\" />";
}
}





/**
* Get a list of the unviewable forums for the current user
*

/**
* Get a list of the unviewable forums for the current user
*

Zeile 2713Zeile 2739
{
global $forum_cache, $permissioncache, $mybb, $unviewableforums, $unviewable, $templates, $forumpass;


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


	$pid = intval($pid);


	$pid = intval($pid);


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

if(!is_array($forum_cache))

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

if(!is_array($forum_cache))

	{

	{

		cache_forums();
}


		cache_forums();
}


Zeile 2739Zeile 2765
		else
{
$perms = $mybb->usergroup;

		else
{
$perms = $mybb->usergroup;

		}

$pwverified = 1;

		}

$pwverified = 1;


if($forum['password'] != "")
{


if($forum['password'] != "")
{

Zeile 2759Zeile 2785
			}

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

			}

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

		}
}

		}
}


return $unviewableforums;
}


return $unviewableforums;
}

Zeile 2835Zeile 2861
 * @param string The URL of the item to add
*/
function add_breadcrumb($name, $url="")

 * @param string The URL of the item to add
*/
function add_breadcrumb($name, $url="")

{
global $navbits;


{
global $navbits;


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

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

Zeile 2847Zeile 2873
 * Build the forum breadcrumb nagiation (the navigation to a specific forum including all parent forums)
*
* @param int The forum ID to build the navigation for

 * Build the forum breadcrumb nagiation (the navigation to a specific forum including all parent forums)
*
* @param int The forum ID to build the navigation for

 */

 */

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

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

Zeile 2857Zeile 2883
		if(!is_array($forum_cache))
{
cache_forums();

		if(!is_array($forum_cache))
{
cache_forums();

		}

		}


foreach($forum_cache as $key => $val)
{


foreach($forum_cache as $key => $val)
{

Zeile 2874Zeile 2900
				if($pforumcache[$forumnav['pid']])
{
build_forum_breadcrumb($forumnav['pid'], $archive);

				if($pforumcache[$forumnav['pid']])
{
build_forum_breadcrumb($forumnav['pid'], $archive);

				}

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


				}

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


if(IN_ARCHIVE == 1)
{


if(IN_ARCHIVE == 1)
{

Zeile 2914Zeile 2941

unset($GLOBALS['navbits']);
$GLOBALS['navbits'] = $newnav;


unset($GLOBALS['navbits']);
$GLOBALS['navbits'] = $newnav;

}

/**

}

/**

 * Builds a URL to an archive mode page
*
* @param string The type of page (thread|announcement|forum)

 * Builds a URL to an archive mode page
*
* @param string The type of page (thread|announcement|forum)

Zeile 2935Zeile 2962
	else
{
$base_url = $mybb->settings['bburl']."/archive/index.php/";

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

	}


	}


	switch($type)
{
case "thread":

	switch($type)
{
case "thread":

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

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





	$percentphp = number_format((($phptime/$maintimer->totaltime)*100), 2);
$percentsql = number_format((($query_time/$maintimer->totaltime)*100), 2);

	$percentphp = number_format((($phptime/$maintimer->totaltime)*100), 2);
$percentsql = number_format((($query_time/$maintimer->totaltime)*100), 2);





	$phpversion = phpversion();

	$phpversion = phpversion();





	$serverload = get_server_load();

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

	$serverload = get_server_load();

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

	{

	{

		$gzipen = "Enabled";
}
else

		$gzipen = "Enabled";
}
else

Zeile 2993Zeile 3020
	echo "<table bgcolor=\"#666666\" width=\"95%\" cellpadding=\"4\" cellspacing=\"1\" align=\"center\">\n";
echo "<tr>\n";
echo "<td bgcolor=\"#CCCCCC\" colspan=\"4\"><b><span style=\"size:2;\">Page Generation Statistics</span></b></td>\n";

	echo "<table bgcolor=\"#666666\" width=\"95%\" cellpadding=\"4\" cellspacing=\"1\" align=\"center\">\n";
echo "<tr>\n";
echo "<td bgcolor=\"#CCCCCC\" colspan=\"4\"><b><span style=\"size:2;\">Page Generation Statistics</span></b></td>\n";

	echo "</tr>\n";
echo "<tr>\n";

	echo "</tr>\n";
echo "<tr>\n";

	echo "<td bgcolor=\"#EFEFEF\" width=\"25%\"><b><font face=\"Tahoma\" size=\"2\">Page Generation Time:</font></b></td>\n";
echo "<td bgcolor=\"#FEFEFE\" width=\"25%\"><font face=\"Tahoma\" size=\"2\">$totaltime seconds</font></td>\n";
echo "<td bgcolor=\"#EFEFEF\" width=\"25%\"><b><font face=\"Tahoma\" size=\"2\">No. DB Queries:</font></b></td>\n";
echo "<td bgcolor=\"#FEFEFE\" width=\"25%\"><font face=\"Tahoma\" size=\"2\">$db->query_count</font></td>\n";

	echo "<td bgcolor=\"#EFEFEF\" width=\"25%\"><b><font face=\"Tahoma\" size=\"2\">Page Generation Time:</font></b></td>\n";
echo "<td bgcolor=\"#FEFEFE\" width=\"25%\"><font face=\"Tahoma\" size=\"2\">$totaltime seconds</font></td>\n";
echo "<td bgcolor=\"#EFEFEF\" width=\"25%\"><b><font face=\"Tahoma\" size=\"2\">No. DB Queries:</font></b></td>\n";
echo "<td bgcolor=\"#FEFEFE\" width=\"25%\"><font face=\"Tahoma\" size=\"2\">$db->query_count</font></td>\n";

	echo "</tr>\n";
echo "<tr>\n";

	echo "</tr>\n";
echo "<tr>\n";

	echo "<td bgcolor=\"#EFEFEF\" width=\"25%\"><b><font face=\"Tahoma\" size=\"2\">PHP Processing Time:</font></b></td>\n";
echo "<td bgcolor=\"#FEFEFE\" width=\"25%\"><font face=\"Tahoma\" size=\"2\">$phptime seconds ($percentphp%)</font></td>\n";
echo "<td bgcolor=\"#EFEFEF\" width=\"25%\"><b><font face=\"Tahoma\" size=\"2\">DB Processing Time:</font></b></td>\n";

	echo "<td bgcolor=\"#EFEFEF\" width=\"25%\"><b><font face=\"Tahoma\" size=\"2\">PHP Processing Time:</font></b></td>\n";
echo "<td bgcolor=\"#FEFEFE\" width=\"25%\"><font face=\"Tahoma\" size=\"2\">$phptime seconds ($percentphp%)</font></td>\n";
echo "<td bgcolor=\"#EFEFEF\" width=\"25%\"><b><font face=\"Tahoma\" size=\"2\">DB Processing Time:</font></b></td>\n";

Zeile 3023Zeile 3050
	echo "<td bgcolor=\"#FEFEFE\" width=\"25%\"><font face=\"Tahoma\" size=\"2\">$gzipen</font></td>\n";
echo "<td bgcolor=\"#EFEFEF\" width=\"25%\"><b><font face=\"Tahoma\" size=\"2\">No. Templates Used:</font></b></td>\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 "<td bgcolor=\"#FEFEFE\" width=\"25%\"><font face=\"Tahoma\" size=\"2\">$gzipen</font></td>\n";
echo "<td bgcolor=\"#EFEFEF\" width=\"25%\"><b><font face=\"Tahoma\" size=\"2\">No. Templates Used:</font></b></td>\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";


	echo "</tr>\n";


	if(function_exists("memory_get_usage"))
{
$memory_usage = memory_get_peak_usage(true);

	if(function_exists("memory_get_usage"))
{
$memory_usage = memory_get_peak_usage(true);

Zeile 3056Zeile 3083
		echo "<table style=\"background-color: #666;\" width=\"95%\" cellpadding=\"4\" cellspacing=\"1\" align=\"center\">\n";
echo "<tr>\n";
echo "<td style=\"background-color: #ccc;\"><strong>Templates Used (Loaded for this Page) - ".count($templates->cache)." Total</strong></td>\n";

		echo "<table style=\"background-color: #666;\" width=\"95%\" cellpadding=\"4\" cellspacing=\"1\" align=\"center\">\n";
echo "<tr>\n";
echo "<td style=\"background-color: #ccc;\"><strong>Templates Used (Loaded for this Page) - ".count($templates->cache)." Total</strong></td>\n";

		echo "</tr>\n";
echo "<tr>\n";

		echo "</tr>\n";
echo "<tr>\n";

		echo "<td style=\"background: #fff;\">".implode(", ", array_keys($templates->cache))."</td>\n";
echo "</tr>\n";
echo "</table>\n";

		echo "<td style=\"background: #fff;\">".implode(", ", array_keys($templates->cache))."</td>\n";
echo "</tr>\n";
echo "</table>\n";

Zeile 3437Zeile 3464
		$location = htmlspecialchars_uni($_SERVER['PATH_INFO']);
}
elseif(!empty($_ENV['PATH_INFO']))

		$location = htmlspecialchars_uni($_SERVER['PATH_INFO']);
}
elseif(!empty($_ENV['PATH_INFO']))

	{

	{

		$location = htmlspecialchars_uni($_ENV['PATH_INFO']);

		$location = htmlspecialchars_uni($_ENV['PATH_INFO']);

	}

	}

	elseif(!empty($_ENV['PHP_SELF']))

	elseif(!empty($_ENV['PHP_SELF']))

	{

	{

		$location = htmlspecialchars_uni($_ENV['PHP_SELF']);

		$location = htmlspecialchars_uni($_ENV['PHP_SELF']);

	}
else
{

	}
else
{

		$location = htmlspecialchars_uni($_SERVER['PHP_SELF']);
}


		$location = htmlspecialchars_uni($_SERVER['PHP_SELF']);
}


Zeile 3501Zeile 3528
	
if(isset($addloc) && is_array($addloc))
{

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

				$location .= "?".implode("&", $addloc);









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

			}
}


			}
}


Zeile 3646Zeile 3681
			$decimals = 0;
}


			$decimals = 0;
}


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

		return number_format((double)$number, $decimals, $mybb->settings['decpoint'], $mybb->settings['thousandssep']);

	}
}


	}
}


Zeile 3848Zeile 3883
	$find = array(
'm',
'd',

	$find = array(
'm',
'd',

 
		'D',

		'y',
'Y',
'j',

		'y',
'Y',
'j',

Zeile 3860Zeile 3896
	$replace = array(
sprintf('%02s', $bm),
sprintf('%02s', $bd),

	$replace = array(
sprintf('%02s', $bm),
sprintf('%02s', $bd),

 
		($wd == 2 ? my_substr($bdays[$wd], 0, 4) : ($wd == 4 ? my_substr($bdays[$wd], 0, 5) : my_substr($bdays[$wd], 0, 3))),

		my_substr($by, 2),
$by,
($bd[0] == 0 ? my_substr($bd, 1) : $bd),
($bd == 1 || $bd == 21 || $bd == 31 ? 'st' : ($bd == 2 || $bd == 22 ? 'nd' : ($bd == 3 || $bd == 23 ? 'rd' : 'th'))),

		my_substr($by, 2),
$by,
($bd[0] == 0 ? my_substr($bd, 1) : $bd),
($bd == 1 || $bd == 21 || $bd == 31 ? 'st' : ($bd == 2 || $bd == 22 ? 'nd' : ($bd == 3 || $bd == 23 ? 'rd' : 'th'))),

		$bdays[$wd],

		$wd,

		$bmonth[$bm-1],
($bm == 9 ? my_substr($bmonth[$bm-1], 0, 4) : my_substr($bmonth[$bm-1], 0, 3)),
);

		$bmonth[$bm-1],
($bm == 9 ? my_substr($bmonth[$bm-1], 0, 4) : my_substr($bmonth[$bm-1], 0, 3)),
);

 
	
// Do we have the full month in our output?
// If so there's no need for the short month
if(strpos($display, 'F') !== false)
{
array_pop($find);
array_pop($replace);
}

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

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

Zeile 4667Zeile 4712
		return false;
}
// Valid local characters for email addresses: http://www.remote.org/jochen/mail/info/chars.html

		return false;
}
// Valid local characters for email addresses: http://www.remote.org/jochen/mail/info/chars.html

	return preg_match("/^[a-zA-Z0-9&*+\-_.{}~^\?=\/]+@[a-zA-Z0-9-]+\.[a-zA-Z0-9.-]+$/si", $email);

	return preg_match("/^[a-zA-Z0-9&*+\-_.{}~^\?=\/]+@[a-zA-Z0-9-]+\.([a-zA-Z0-9-]+\.)*[a-zA-Z0-9-]{2,}$/si", $email);

}

/**

}

/**

Zeile 4750Zeile 4795
 */
function build_highlight_array($terms)
{

 */
function build_highlight_array($terms)
{

 
	global $mybb;

if($mybb->settings['minsearchword'] < 1)
{
$mybb->settings['minsearchword'] = 3;
}


	// Strip out any characters that shouldn't be included
$bad_characters = array(
"(",

	// Strip out any characters that shouldn't be included
$bad_characters = array(
"(",

Zeile 4766Zeile 4818
		$inquote = false;
$terms = explode("\"", $terms);
foreach($terms as $phrase)

		$inquote = false;
$terms = explode("\"", $terms);
foreach($terms as $phrase)

		{

		{

			$phrase = htmlspecialchars_uni($phrase);
if($phrase != "")
{
if($inquote)
{

			$phrase = htmlspecialchars_uni($phrase);
if($phrase != "")
{
if($inquote)
{

					$words[] = "\"".trim($phrase)."\"";

					$words[] = trim($phrase);

				}
else
{

				}
else
{

Zeile 4783Zeile 4835
					}
foreach($split_words as $word)
{

					}
foreach($split_words as $word)
{

						if(!$word)

						if(!$word || strlen($word) < $mybb->settings['minsearchword'])

						{
continue;
}

						{
continue;
}

Zeile 4792Zeile 4844
				}
}
$inquote = !$inquote;

				}
}
$inquote = !$inquote;

		}

		}

	}
// Otherwise just a simple search query with no phrases
else

	}
// Otherwise just a simple search query with no phrases
else

Zeile 4800Zeile 4852
		$terms = htmlspecialchars_uni($terms);
$split_words = preg_split("#\s{1,}#", $terms, -1);
if(!is_array($split_words))

		$terms = htmlspecialchars_uni($terms);
$split_words = preg_split("#\s{1,}#", $terms, -1);
if(!is_array($split_words))

		{

		{

			continue;
}
foreach($split_words as $word)
{

			continue;
}
foreach($split_words as $word)
{

			if(!$word)

			if(!$word || strlen($word) < $mybb->settings['minsearchword'])

			{
continue;
}

			{
continue;
}

Zeile 4818Zeile 4870
	{
return false;
}

	{
return false;
}

 
	
// Sort the word array by length. Largest terms go first and work their way down to the smallest term.
// This resolves problems like "test tes" where "tes" will be highlighted first, then "test" can't be highlighted because of the changed html
usort($words, create_function('$a,$b','return strlen($b) - strlen($a);'));


// Loop through our words to build the PREG compatible strings
foreach($words as $word)


// Loop through our words to build the PREG compatible strings
foreach($words as $word)

Zeile 4833Zeile 4889
		}

// Now make PREG compatible

		}

// Now make PREG compatible

		$find = "#(^|>)([^<]*)(".preg_quote($word, "#").")#i";
$replacement = "$1$2<span class=\"highlight\">$3</span>";

		$find = "#(?!<.*?)(".preg_quote($word, "#").")(?![^<>]*?>)#i";
$replacement = "<span class=\"highlight\" style=\"padding-left: 0px; padding-right: 0px;\">$1</span>";

		$highlight_cache[$find] = $replacement;
}


		$highlight_cache[$find] = $replacement;
}


Zeile 5261Zeile 5317
function fetch_longipv4_range($ip)
{
$ip_bits = explode(".", $ip);

function fetch_longipv4_range($ip)
{
$ip_bits = explode(".", $ip);

 
	$ip_string1 = $ip_string2 = "";





	if($ip == "*") return array(ip2long(0), ip2long(255));




	if($ip == "*")
{
return array(ip2long('0.0.0.0'), ip2long('255.255.255.255'));
}


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


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

Zeile 5270Zeile 5330
		if(count($ip_bits) == 4)
{
return ip2long($ip);

		if(count($ip_bits) == 4)
{
return ip2long($ip);

		}

		}

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

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

Zeile 5279Zeile 5339
	// Wildcard based IP provided
else
{

	// Wildcard based IP provided
else
{

 
		$sep = "";

		foreach($ip_bits as $piece)
{
if($piece == "*")

		foreach($ip_bits as $piece)
{
if($piece == "*")

			{
return array(ip2long($ip_string."0"), ip2long($ip_string."255"));
}


			{
$ip_string1 .= $sep."0";
$ip_string2 .= $sep."255";
}

			else
{

			else
{

				$ip_string .= $piece.".";


				$ip_string1 .= $sep.$piece;
$ip_string2 .= $sep.$piece;

			}

			}

		}
}
}




			$sep = ".";
}
return array(ip2long($ip_string1), ip2long($ip_string2));
}
}


/**
* Fetch a list of ban times for a user account.
*

/**
* Fetch a list of ban times for a user account.
*

Zeile 5358Zeile 5423
function expire_warnings()
{
global $db;

function expire_warnings()
{
global $db;

 
	
$users = array();


	$query = $db->query("
SELECT w.wid, w.uid, w.points, u.warningpoints
FROM ".TABLE_PREFIX."warnings w

	$query = $db->query("
SELECT w.wid, w.uid, w.points, u.warningpoints
FROM ".TABLE_PREFIX."warnings w

Zeile 5365Zeile 5433
		WHERE expires<".TIME_NOW." AND expires!=0 AND expired!=1
");
while($warning = $db->fetch_array($query))

		WHERE expires<".TIME_NOW." AND expires!=0 AND expired!=1
");
while($warning = $db->fetch_array($query))

	{

	{

		$updated_warning = array(
"expired" => 1
);
$db->update_query("warnings", $updated_warning, "wid='{$warning['wid']}'");

		$updated_warning = array(
"expired" => 1
);
$db->update_query("warnings", $updated_warning, "wid='{$warning['wid']}'");

		$warning['warningpoints'] -= $warning['points'];
if($warning['warningpoints'] < 0)













		
if(array_key_exists($warning['uid'], $users))
{
$users[$warning['uid']] -= $warning['points'];
}
else
{
$users[$warning['uid']] = $warning['warningpoints']-$warning['points'];
}
}

foreach($users as $uid => $warningpoints)
{
if($warningpoints < 0)

		{

		{

			$warning['warningpoints'] = 0;

			$warningpoints = 0;

		}

		}

 
		

		$updated_user = array(

		$updated_user = array(

			"warningpoints" => intval($warning['warningpoints'])

			"warningpoints" => intval($warningpoints)

		);

		);

		$db->update_query("users", $updated_user, "uid='{$warning['uid']}'");
}
}


		$db->update_query("users", $updated_user, "uid='".intval($uid)."'");
}
}


/**
* Unicode function for php function chr()
*

/**
* Unicode function for php function chr()
*

Zeile 5435Zeile 5516
	$result = chmod($file, octdec($mode));
umask($old_umask);
return $result;

	$result = chmod($file, octdec($mode));
umask($old_umask);
return $result;

}

/**

}

/**

 * Custom rmdir function to loop through an entire directory and delete all files/folders within
*
* @param string The path to the directory

 * Custom rmdir function to loop through an entire directory and delete all files/folders within
*
* @param string The path to the directory

Zeile 5465Zeile 5546
            }
@closedir($dh);
}

            }
@closedir($dh);
}

		

		

		// Are we done? Don't delete the main folder too and return true
if($path == $orig_dir)
{

		// Are we done? Don't delete the main folder too and return true
if($path == $orig_dir)
{

Zeile 5476Zeile 5557
    }

return @unlink($path);

    }

return @unlink($path);

}

}


/**
* Counts the number of subforums in a array([pid][disporder][fid]) starting from the pid


/**
* Counts the number of subforums in a array([pid][disporder][fid]) starting from the pid

Zeile 5493Zeile 5574
	}

return $count;

	}

return $count;

 
}

/**
* Returns a securely generated seed for PHP's RNG (Random Number Generator)
*
* @param int Length of the seed bytes (8 is default. Provides good cryptographic variance)
* @return int An integer equivilent of a secure hexadecimal seed
*/
function secure_seed_rng($count=8)
{
$output = '';

// Try the unix/linux method
if(@is_readable('/dev/urandom') && ($handle = @fopen('/dev/urandom', 'rb')))
{
$output = @fread($handle, $count);
@fclose($handle);
}

// Didn't work? Do we still not have enough bytes? Use our own (less secure) rng generator
if(strlen($output) < $count)
{
$output = '';

// Close to what PHP basically uses internally to seed, but not quite.
$unique_state = microtime().@getmypid();

for($i = 0; $i < $count; $i += 16)
{
$unique_state = md5(microtime().$unique_state);
$output .= pack('H*', md5($unique_state));
}
}

// /dev/urandom and openssl will always be twice as long as $count. base64_encode will roughly take up 33% more space but crc32 will put it to 32 characters
$output = hexdec(substr(dechex(crc32(base64_encode($output))), 0, $count));

return $output;
}

/**
* Wrapper function for mt_rand. Automatically seeds using a secure seed once.
*
* @param int Optional lowest value to be returned (default: 0)
* @param int Optional highest value to be returned (default: mt_getrandmax())
* @param boolean True forces it to reseed the RNG first
* @return int An integer equivilent of a secure hexadecimal seed
*/
function my_rand($min=null, $max=null, $force_seed=false)
{
static $seeded = false;
static $obfuscator = 0;

if($seeded == false || $force_seed == true)
{
mt_srand(secure_seed_rng());
$seeded = true;

$obfuscator = abs((int) secure_seed_rng());

// Ensure that $obfuscator is <= mt_getrandmax() for 64 bit systems.
if($obfuscator > mt_getrandmax())
{
$obfuscator -= mt_getrandmax();
}
}

if($min !== null && $max !== null)
{
$distance = $max - $min;
if ($distance > 0)
{
return $min + (int)((float)($distance + 1) * (float)(mt_rand() ^ $obfuscator) / (mt_getrandmax() + 1));
}
else
{
return mt_rand($min, $max);
}
}
else
{
$val = mt_rand() ^ $obfuscator;
return $val;
}

}

?>

}

?>