Vergleich inc/functions.php - 1.2.2 - 1.2.14

  Keine Änderungen   Hinzugefügt   Modifiziert   Entfernt
Zeile 3Zeile 3
 * MyBB 1.2
* Copyright � 2006 MyBB Group, All Rights Reserved
*

 * MyBB 1.2
* Copyright � 2006 MyBB Group, All Rights Reserved
*

 * Website: http://www.mybboard.com
* License: http://www.mybboard.com/eula.html

 * Website: http://www.mybboard.net
* License: http://www.mybboard.net/eula.html

 *

 *

 * $Id: functions.php 2459 2006-11-29 09:09:55Z chris $

 * $Id: functions.php 3845 2008-05-18 17:50:09Z Tikitiki $

 */

/**

 */

/**

Zeile 18Zeile 18
{
global $db, $lang, $theme, $plugins, $mybb;
global $querytime, $debug, $templatecache, $templatelist, $maintimer, $globaltime, $parsetime;

{
global $db, $lang, $theme, $plugins, $mybb;
global $querytime, $debug, $templatecache, $templatelist, $maintimer, $globaltime, $parsetime;



 
	$contents = parse_page($contents);
$totaltime = $maintimer->stop();
if($mybb->usergroup['cancp'] == "yes")

	$contents = parse_page($contents);
$totaltime = $maintimer->stop();
if($mybb->usergroup['cancp'] == "yes")

Zeile 74Zeile 73
			$contents = gzip_encode($contents);
}
}

			$contents = gzip_encode($contents);
}
}

 

@header("Content-type: text/html; charset={$lang->settings['charset']}");


	echo $contents;

$plugins->run_hooks("post_output_page");

	echo $contents;

$plugins->run_hooks("post_output_page");





	// If the use shutdown functionality is turned off, run any shutdown related items now.

	// If the use shutdown functionality is turned off, run any shutdown related items now.

	if(($mybb->settings['useshutdownfunc'] == "no" || phpversion() >= '5.0.5') && $mybb->use_shutdown != true) 

	if(($mybb->settings['useshutdownfunc'] == "no"|| phpversion() >= '5.0.5') && $mybb->use_shutdown != true) 

	{
run_shutdown();

	{
run_shutdown();

	}

	}

}

/**

}

/**

Zeile 105Zeile 107
 *
*/
function run_shutdown()

 *
*/
function run_shutdown()

{

{

	global $db, $cache, $plugins, $shutdown_functions, $done_shutdown;

if($done_shutdown == true)

	global $db, $cache, $plugins, $shutdown_functions, $done_shutdown;

if($done_shutdown == true)

Zeile 115Zeile 117
	
// 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))

	{

	{

		require MYBB_ROOT."inc/config.php";
if(isset($config))
{

		require MYBB_ROOT."inc/config.php";
if(isset($config))
{

Zeile 131Zeile 133
	{
require_once MYBB_ROOT."inc/class_datacache.php";
$cache = new datacache;

	{
require_once MYBB_ROOT."inc/class_datacache.php";
$cache = new datacache;

	}

	}

	
// And finaly.. we have the PHP developers to thank for this "hack" which fixes a problem THEY created
if(!is_object($plugins) && !defined("NO_PLUGINS"))

	
// And finaly.. we have the PHP developers to thank for this "hack" which fixes a problem THEY created
if(!is_object($plugins) && !defined("NO_PLUGINS"))

Zeile 148Zeile 150
		foreach($db->shutdown_queries as $query)
{
$db->query($query);

		foreach($db->shutdown_queries as $query)
{
$db->query($query);

		}
}

		}
}


// Run any shutdown functions if we have them
if(is_array($shutdown_functions))


// Run any shutdown functions if we have them
if(is_array($shutdown_functions))

Zeile 219Zeile 221
	{
$contents = "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n".$contents;
}

	{
$contents = "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n".$contents;
}

 
	
$contents = str_replace("<html", "<html xmlns=\"http://www.w3.org/1999/xhtml\"", $contents);


	if($lang->settings['rtl'] == 1)
{
$contents = str_replace("<html", "<html dir=\"rtl\"", $contents);
}
if($lang->settings['htmllang'])

	if($lang->settings['rtl'] == 1)
{
$contents = str_replace("<html", "<html dir=\"rtl\"", $contents);
}
if($lang->settings['htmllang'])

	{
$contents = str_replace("<html", "<html lang=\"".$lang->settings['htmllang']."\"", $contents);
}

	{
$contents = str_replace("<html", "<html xml:lang=\"".$lang->settings['htmllang']."\" lang=\"".$lang->settings['htmllang']."\"", $contents);
}


if($loadpmpopup)
{


if($loadpmpopup)
{

Zeile 236Zeile 241
		}
}
return $contents;

		}
}
return $contents;

}


}


/**
* Turn a unix timestamp in to a "friendly" date/time format for the user.
*

/**
* Turn a unix timestamp in to a "friendly" date/time format for the user.
*

Zeile 353Zeile 358
	$headers .= "X-Priority: 3\n";
$headers .= "X-MSMail-Priority: Normal\n";
$headers .= "X-Mailer: MyBB\n";

	$headers .= "X-Priority: 3\n";
$headers .= "X-MSMail-Priority: Normal\n";
$headers .= "X-Mailer: MyBB\n";

 
	if(defined("IN_ADMINCP"))
{
$_SERVER['PHP_SELF'] = str_replace($mybb->config['admin_dir']."/", "admin-", $_SERVER['PHP_SELF']);
}
$headers .= "X-MyBB-Script: {$http_host}{$_SERVER['PHP_SELF']}\n";


// For some reason sendmail/qmail doesn't like \r\n
$sendmail = @ini_get('sendmail_path');


// For some reason sendmail/qmail doesn't like \r\n
$sendmail = @ini_get('sendmail_path');

Zeile 360Zeile 370
	{
$headers = preg_replace("#(\r\n|\r|\n)#s", "\n", $headers);
$message = preg_replace("#(\r\n|\r|\n)#s", "\n", $message);

	{
$headers = preg_replace("#(\r\n|\r|\n)#s", "\n", $headers);
$message = preg_replace("#(\r\n|\r|\n)#s", "\n", $message);

	}
else
{

	}
else
{

		$headers = preg_replace("#(\r\n|\r|\n)#s", "\r\n", $headers);
$message = preg_replace("#(\r\n|\r|\n)#s", "\r\n", $message);

		$headers = preg_replace("#(\r\n|\r|\n)#s", "\r\n", $headers);
$message = preg_replace("#(\r\n|\r|\n)#s", "\r\n", $message);

	}


	}


	mail($to, $subject, $message, $headers);

	mail($to, $subject, $message, $headers);

 
}

/**
* Generates a unique code for POST requests to prevent XSS/CSRF attacks
*
* @return string The generated code
*/
function generate_post_check()
{
global $mybb;
if($mybb->user['uid'])
{
return md5($mybb->user['loginkey'].$mybb->user['salt'].$mybb->user['regdate']);
}
// Guests get a special string
else
{
return md5($mybb->config['hostname'].$mybb->config['username'].$mybb->config['password']);
}
}

/**
* Verifies a POST check code is valid, if not shows an error (silently returns false on silent parameter)
*
* @param string The incoming POST check code
* @param boolean Silent mode or not (silent mode will not show the error to the user but returns false)
*/
function verify_post_check($code, $silent=false)
{
global $lang;
if(generate_post_check() != $code)
{
if($silent == true)
{
return false;
}
else
{
error($lang->invalid_post_code);
}
}
else
{
return true;
}

}

/**

}

/**

Zeile 425Zeile 480

/**
* Load the forum cache in to memory


/**
* Load the forum cache in to memory

 
 *
* @param boolean True to force a reload of the cache

 */

 */

function cache_forums()

function cache_forums($force=false)

{
global $forum_cache, $db, $cache;

{
global $forum_cache, $db, $cache;

 
	
if($force == true)
{
$forum_cache = $cache->read("forums", 1);
return $forum_cache;
}


if(!$forum_cache)
{


if(!$forum_cache)
{

Zeile 508Zeile 571
		"location1" => 0,
"location2" => 0
);

		"location1" => 0,
"location2" => 0
);

	$db->update_query(TABLE_PREFIX."sessions", $noperm_array, "sid='".$session->sid."'");
$url = $_SERVER['REQUEST_URI'];
$url = str_replace("&", "&amp;", $url);

	$db->update_query(TABLE_PREFIX."sessions", $noperm_array, "sid='".$session->sid."'", 1);
$url = htmlspecialchars_uni($_SERVER['REQUEST_URI']);


	if($mybb->user['uid'])
{
$lang->error_nopermission_user_5 = sprintf($lang->error_nopermission_user_5, $mybb->user['username']);

	if($mybb->user['uid'])
{
$lang->error_nopermission_user_5 = sprintf($lang->error_nopermission_user_5, $mybb->user['username']);

Zeile 625Zeile 687

/**
* Fetch the permissions for a specific user


/**
* Fetch the permissions for a specific user

 *

 *

 * @param int The user ID
* @return array Array of user permissions for the specified user
*/
function user_permissions($uid=0)
{
global $mybb, $cache, $groupscache, $user_cache;

 * @param int The user ID
* @return array Array of user permissions for the specified user
*/
function user_permissions($uid=0)
{
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 no user id is specified, assume it is the current user
if($uid == 0)
{
$uid = $mybb->user['uid'];

	}


	}


	// User id does not match current user, fetch permissions
if($uid != $mybb->user['uid'])
{
// We've already cached permissions for this user, return them.
if($user_cache[$uid]['permissions'])

	// User id does not match current user, fetch permissions
if($uid != $mybb->user['uid'])
{
// We've already cached permissions for this user, return them.
if($user_cache[$uid]['permissions'])

		{

		{

			return $user_cache[$uid]['permissions'];
}

// This user was not already cached, fetch their user information.
if(!$user_cache[$uid])

			return $user_cache[$uid]['permissions'];
}

// This user was not already cached, fetch their user information.
if(!$user_cache[$uid])

		{

		{

			$user_cache[$uid] = get_user($uid);

			$user_cache[$uid] = get_user($uid);

		}

		}


// Collect group permissions.


// Collect group permissions.

		$gid = $user_cache[$uid]['usergroup'].",".$user_cache[$uid]['additionalgroups'];





		$gid = $user_cache[$uid]['usergroup'];
if($user_cache[$uid]['additionalgroups'])
{
$gid .= ",".$user_cache[$uid]['additionalgroups'];
}

		$groupperms = usergroup_permissions($gid);

// Store group permissions in user cache.

		$groupperms = usergroup_permissions($gid);

// Store group permissions in user cache.

Zeile 676Zeile 742
 * @return array Array of permissions generated for the groups
*/
function usergroup_permissions($gid=0)

 * @return array Array of permissions generated for the groups
*/
function usergroup_permissions($gid=0)

{

{

	global $cache, $groupscache, $grouppermignore, $groupzerogreater;

if(!is_array($groupscache))
{
$groupscache = $cache->read("usergroups");
}

	global $cache, $groupscache, $grouppermignore, $groupzerogreater;

if(!is_array($groupscache))
{
$groupscache = $cache->read("usergroups");
}

 


	$groups = explode(",", $gid);
if(count($groups) == 1)

	$groups = explode(",", $gid);
if(count($groups) == 1)

	{

	{

		return $groupscache[$gid];
}
foreach($groups as $gid)

		return $groupscache[$gid];
}
foreach($groups as $gid)

Zeile 699Zeile 766
			if(!in_array($perm, $grouppermignore))
{
if(isset($usergroup[$perm]))

			if(!in_array($perm, $grouppermignore))
{
if(isset($usergroup[$perm]))

				{

				{

					$permbit = $usergroup[$perm];
}
else

					$permbit = $usergroup[$perm];
}
else

				{

				{

					$permbit = "";
}

					$permbit = "";
}

				$zerogreater = 0;



				if(in_array($perm, $groupzerogreater))
{
if($access == 0)
{
$usergroup[$perm] = 0;

				if(in_array($perm, $groupzerogreater))
{
if($access == 0)
{
$usergroup[$perm] = 0;

						$zerogreater = 1;

						continue;

					}
}

					}
}

				if(($access > $permbit || ($access == "yes" && $permbit == "no") || !$permbit) && $zerogreater != 1)



if($access > $permbit || ($access == "yes" && $permbit == "no") || !$permbit)

				{
$usergroup[$perm] = $access;
}

				{
$usergroup[$perm] = $access;
}

Zeile 759Zeile 827
function forum_permissions($fid=0, $uid=0, $gid=0)
{
global $db, $cache, $groupscache, $forum_cache, $fpermcache, $mybb, $usercache, $fpermissionscache;

function forum_permissions($fid=0, $uid=0, $gid=0)
{
global $db, $cache, $groupscache, $forum_cache, $fpermcache, $mybb, $usercache, $fpermissionscache;



	static $cached_forum_permissions;

	if($uid == 0)
{
$uid = $mybb->user['uid'];
}
if(!$gid || $gid == 0) // If no group, we need to fetch it
{

	if($uid == 0)
{
$uid = $mybb->user['uid'];
}
if(!$gid || $gid == 0) // If no group, we need to fetch it
{

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

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

		{
if($usercache[$uid])
{

		{
if($usercache[$uid])
{

Zeile 800Zeile 868
	}
if($fid) // Fetch the permissions for a single forum
{

	}
if($fid) // Fetch the permissions for a single forum
{

		$permissions = fetch_forum_permissions($fid, $gid, $groupperms);





		if(!$cached_forum_permissions[$gid][$fid])
{
$cached_forum_permissions_permissions[$gid][$fid] = fetch_forum_permissions($fid, $gid, $groupperms);
}
return $cached_forum_permissions_permissions[$gid][$fid];

	}
else
{

	}
else
{

		foreach($forum_cache as $forum)

		if(!$cached_forum_permissions[$gid])

		{

		{

			$permissions[$forum['fid']] = fetch_forum_permissions($forum['fid'], $gid, $groupperms);




			foreach($forum_cache as $forum)
{
$cached_forum_permissions[$gid][$forum['fid']] = fetch_forum_permissions($forum['fid'], $gid, $groupperms);
}

		}

		}

 
		return $cached_forum_permissions[$gid];

	}

	}

	return $permissions;

 
}

/**

}

/**

Zeile 824Zeile 899
function fetch_forum_permissions($fid, $gid, $groupperms)
{
global $groupscache, $forum_cache, $fpermcache, $mybb, $fpermfields;

function fetch_forum_permissions($fid, $gid, $groupperms)
{
global $groupscache, $forum_cache, $fpermcache, $mybb, $fpermfields;

 


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

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

 
	

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

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

 
		$groupperms['fid'] = $fid;
$groupperms['gid'] = $gid;

		return $groupperms;

		return $groupperms;

	}
// The fix here for better working inheritance was provided by tinywizard - http://windizupdate.com/
// Many thanks.
foreach($fpermfields as $perm)
{
$forumpermissions[$perm] = "no";
}


	}

$current_permissions = array();






	foreach($groups as $gid)

	foreach($groups as $gid)

	{
if($gid && $groupscache[$gid])
{
if(is_array($fpermcache[$fid][$gid]))
{
$p = $fpermcache[$fid][$gid];
}
else
{
$p = $groupperms;
}

if($p == NULL)
{
foreach($forumpermissions as $k => $v)
{
$forumpermissions[$k] = 'yes'; // no inherited group, assume one has access
}
}
else











	{
if($groupscache[$gid])
{
$level_permissions = $fpermcache[$fid][$gid];

// If our permissions arn't inherited we need to figure them out
if(empty($level_permissions))
{
$parents = explode(',', $forum_cache[$fid]['parentlist']);
rsort($parents);
if(!empty($parents))
{
foreach($parents as $parent_id)
{
if(!empty($fpermcache[$parent_id][$gid]))
{
$level_permissions = $fpermcache[$parent_id][$gid];
break;
}
}

// If we STILL don't have forum permissions we use the usergroup itself
if(empty($level_permissions))
{
$level_permissions = $groupscache[$gid];
}
}
}

foreach($level_permissions as $permission => $access)

			{

			{

				foreach($p as $perm => $access)

				if($access >= $current_permissions[$permission] || ($access == "yes" && $current_permissions[$permission] == "no") || !$current_permissions[$permission])

				{

				{

					if(isset($forumpermissions[$perm]) && $access == 'yes')
{
$forumpermissions[$perm] = $access;
}

					$current_permissions[$permission] = $access;




				}
}
}
}

				}
}
}
}

	return $forumpermissions;






	
if(count($current_permissions) == 0)
{
$current_permissions = $groupperms;
}
return $current_permissions;

}

/**
* Check the password given on a certain forum for validity
*
* @param int The forum ID

}

/**
* Check the password given on a certain forum for validity
*
* @param int The forum ID

 * @param string The plain text password for the forum

 * @param boolean The Parent ID

 */

 */

function check_forum_password($fid, $password="")

function check_forum_password($fid, $pid=0)

{

{

	global $mybb, $header, $footer, $headerinclude, $theme, $templates, $lang;
$showform = 1;











	global $mybb, $header, $footer, $headerinclude, $theme, $templates, $lang, $forum_cache;

$showform = true;

if(!is_array($forum_cache))
{
$forum_cache = cache_forums();
if(!$forum_cache)
{
return false;
}
}





 
	// Loop through each of parent forums to ensure we have a password for them too
$parents = explode(',', $forum_cache[$fid]['parentlist']);
rsort($parents);
if(!empty($parents))
{
foreach($parents as $parent_id)
{
if($parent_id == $fid || $parent_id == $pid)
{
continue;
}

if($forum_cache[$parent_id]['password'] != "")
{
check_forum_password($parent_id, $fid);
}
}
}

$password = $forum_cache[$fid]['password'];

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

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

			{

			{

				my_setcookie("forumpass[$fid]", md5($mybb->user['uid'].$mybb->input['pwverify']), null, true);

				my_setcookie("forumpass[$fid]", md5($mybb->user['uid'].$mybb->input['pwverify']), null, true);

				$showform = 0;

				$showform = false;

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

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

				$showform = 1;

				$showform = true;

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

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

			{
$showform = 1;
}

			{
$showform = true;
}

			else
{

			else
{

				$showform = 0;

				$showform = false;

			}

			}

		}
}
else
{
$showform = 0;
}
if($showform)


		}
}
else
{
$showform = false;
}

if($showform)

	{

	{

 
		$_SERVER['REQUEST_URI'] = htmlspecialchars_uni($_SERVER['REQUEST_URI']);

		eval("\$pwform = \"".$templates->get("forumdisplay_password")."\";");
output_page($pwform);

		eval("\$pwform = \"".$templates->get("forumdisplay_password")."\";");
output_page($pwform);

		exit;
}

		exit;
}

}

/**

}

/**

Zeile 935Zeile 1054
	static $modpermscache;

if($uid < 1)

	static $modpermscache;

if($uid < 1)

	{

	{

		$uid = $mybb->user['uid'];
}

		$uid = $mybb->user['uid'];
}

	if(!isset($modpermscache[$uid][$fid]))


	
if(!isset($modpermscache[$fid][$uid]))

	{
if(!$parentslist)
{
$parentslist = get_parent_list($fid);
}

	{
if(!$parentslist)
{
$parentslist = get_parent_list($fid);
}

 
		

		$sql = build_parent_list($fid, "fid", "OR", $parentslist);

		$sql = build_parent_list($fid, "fid", "OR", $parentslist);

		$query = $db->query("
SELECT *
FROM ".TABLE_PREFIX."moderators
WHERE uid='$uid'
AND $sql
");

		$query = $db->simple_select(TABLE_PREFIX."moderators", "*", "uid='{$uid}' AND {$sql}");






		$perms = $db->fetch_array($query);

		$perms = $db->fetch_array($query);

		$modpermscache[$uid][$fid] = $perms;
}
else
{
$perms = $modpermscache[$uid][$fid];
}


		$modpermscache[$fid][$uid] = $perms;
}
else
{
$perms = $modpermscache[$fid][$uid];
}


	return $perms;
}


	return $perms;
}


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

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

	}

	}





	if($mybb->usergroup['issupermod'] == "yes")


	$user_perms = user_permissions($uid);
if($user_perms['issupermod'] == "yes")

	{
return "yes";
}

	{
return "yes";
}

Zeile 986Zeile 1104
	{
if(!$fid)
{

	{
if(!$fid)
{

			$query = $db->simple_select(TABLE_PREFIX.'moderators', 'mid', "uid={$uid}", array('limit' => 1));

			$query = $db->simple_select(TABLE_PREFIX.'moderators', 'COUNT(*) as count', "uid={$uid}", array('limit' => 1));

			$modcheck = $db->fetch_array($query);

			$modcheck = $db->fetch_array($query);

			if($modcheck['mid'])
{
return "yes";
}

			if($modcheck['count'] > 0)
{
return "yes";
}

			else
{
return "no";

			else
{
return "no";

Zeile 1009Zeile 1127
				if($modperms[$action] == "yes")
{
return "yes";

				if($modperms[$action] == "yes")
{
return "yes";

				}

				}

				else
{
return "no";

				else
{
return "no";

Zeile 1154Zeile 1272
	else
{
return 0;

	else
{
return 0;

	}

	}

}

/**

}

/**

Zeile 1181Zeile 1299
function get_server_load()
{
global $lang;

function get_server_load()
{
global $lang;

	if(strtolower(substr(PHP_OS, 0, 3)) === 'win')





$serverload = array();

if(my_strtolower(substr(PHP_OS, 0, 3)) !== 'win')

	{

	{

		return $lang->unknown;
}
elseif(@file_exists("/proc/loadavg"))
{
$load = @file_get_contents("/proc/loadavg");
$serverload = explode(" ", $load);
$serverload[0] = round($serverload[0], 4);

		if(@file_exists("/proc/loadavg") && $load = @file_get_contents("/proc/loadavg"))
{
$serverload = explode(" ", $load);
$serverload[0] = round($serverload[0], 4);
}



		if(!$serverload)
{

		if(!$serverload)
{

 
			if(@ini_get('safe_mode') == 'On')
{
return $lang->unknown;
}

// Suhosin likes to throw a warning if exec is disabled then die - weird
if($func_blacklist = @ini_get('suhosin.executor.func.blacklist'))
{
if(strpos(",".$func_blacklist.",", 'exec') !== false)
{
return $lang->unknown;
}
}
// PHP disabled functions?
if($func_blacklist = @ini_get('disable_functions'))
{
if(strpos(",".$func_blacklist.",", 'exec') !== false)
{
return $lang->unknown;
}
}

			$load = @exec("uptime");
$load = split("load averages?: ", $load);
$serverload = explode(",", $load[1]);

			$load = @exec("uptime");
$load = split("load averages?: ", $load);
$serverload = explode(",", $load[1]);

 
			if(!is_array($serverload))
{
return $lang->unknown;
}

		}

		}

	}

	}

	else
{

	else
{

		$load = @exec("uptime");
$load = split("load averages?: ", $load);
$serverload = explode(",", $load[1]);

		return $lang->unknown;



	}

	}

 


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

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

	if(!$returnload)
{
$returnload = $lang->unknown;
}






	return $returnload;

	return $returnload;

}

/**
* Update the forum counters for a specific forum
*
* @param int The forum ID








































































































































}


/**
* Updates the forum statistics with specific values (or addition/subtraction of the previous value)
*
* @param array Array of items being updated (numthreads,numposts,numusers,lastuser)
*/
function update_stats($changes=array())
{
global $cache, $db;

$stats = $cache->read("stats");

$counters = array('numthreads', 'numposts', 'numusers');
$update = array();
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) == "-")
{
$new_stats[$counter] = $stats[$counter] + $changes[$counter];
}
else
{
$new_stats[$counter] = $changes[$counter];
}
// Less than 0? That's bad
if($new_stats[$counter] < 0)
{
$new_stats[$counter] = 0;
}
}
}

// Fetch latest user if the user count is changing
if(array_key_exists('numusers', $changes) || array_key_exists('lastuser', $changes))
{
$query = $db->simple_select(TABLE_PREFIX."users", "uid, username", "", array('order_by' => 'uid', 'order_dir' => 'DESC', 'limit' => 1));
$lastmember = $db->fetch_array($query);
$new_stats['lastuid'] = $lastmember['uid'];
$new_stats['lastusername'] = $lastmember['username'];
}
if(is_array($stats))
{
$stats = array_merge($stats, $new_stats);
}
else
{
$stats = $new_stats;
}
$cache->update("stats", $stats);
}

/**
* Updates the forum counters with a specific value (or addition/subtraction of the previous value)
*
* @param int The forum ID
* @param array Array of items being updated (threads, posts, unapprovedthreads, unapprovedposts) and their value (ex, 1, +1, -1)
*/
function update_forum_counters($fid, $changes=array())
{
global $db, $cache;

$update_query = array();

$counters = array('threads', 'unapprovedthreads', 'posts', 'unapprovedposts');

// Fetch above counters for this forum
$query = $db->simple_select(TABLE_PREFIX."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) == "-")
{
$update_query[$counter] = $forum[$counter] + $changes[$counter];
}
else
{
$update_query[$counter] = $changes[$counter];
}
// Less than 0? That's bad
if($update_query[$counter] < 0)
{
$update_query[$counter] = 0;
}
}
}

// Only update if we're actually doing something
if(count($update_query) > 0)
{
$db->update_query(TABLE_PREFIX."forums", $update_query, "fid='".intval($fid)."'");
}

// Guess we should update the statistics too?
if(isset($update_query['threads']) || isset($update_query['posts']))
{
$new_stats = array();
if(array_key_exists('threads', $update_query))
{
$threads_diff = $update_query['threads'] - $forum['threads'];
if($threads_diff > -1)
{
$new_stats['numthreads'] = "+{$threads_diff}";
}
else
{
$new_stats['numthreads'] = "{$threads_diff}";
}
}
if(array_key_exists('posts', $update_query))
{
$posts_diff = $update_query['posts'] - $forum['posts'];
if($posts_diff > -1)
{
$new_stats['numposts'] = "+{$posts_diff}";
}
else
{
$new_stats['numposts'] = "{$posts_diff}";
}
}

update_stats($new_stats);
}

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

/**
* Update the last post information for a specific forum
*
* @param int The forum ID

 */

 */

function update_forum_count($fid)

function update_forum_lastpost($fid)

{

{

	global $db, $cache;

	global $db;


// Fetch the last post for this forum
$query = $db->query("


// Fetch the last post for this forum
$query = $db->query("

Zeile 1230Zeile 1505
	");
$lastpost = $db->fetch_array($query);


	");
$lastpost = $db->fetch_array($query);


	// Fetch the number of threads and replies in this forum (Approved only)
$query = $db->query("
SELECT COUNT(*) AS threads, SUM(replies) AS replies
FROM ".TABLE_PREFIX."threads
WHERE fid='$fid' AND visible='1' AND closed NOT LIKE 'moved|%'
");
$count = $db->fetch_array($query);
$count['posts'] = $count['threads'] + $count['replies'];

// Fetch the number of threads and replies in this forum (Unapproved only)
$query = $db->query("
SELECT COUNT(*) AS threads
FROM ".TABLE_PREFIX."threads
WHERE fid='$fid' AND visible='0' AND closed NOT LIKE 'moved|%'
");
$unapproved_count['threads'] = $db->fetch_field($query, "threads");
$query = $db->query("
SELECT SUM(unapprovedposts) AS posts
FROM ".TABLE_PREFIX."threads
WHERE fid='$fid' AND closed NOT LIKE 'moved|%'
");
$unapproved_count['posts'] = $db->fetch_field($query, "posts");

$update_count = array(
"posts" => intval($count['posts']),
"threads" => intval($count['threads']),
"unapprovedposts" => intval($unapproved_count['posts']),
"unapprovedthreads" => intval($unapproved_count['threads']),

	$updated_forum = array(




























		"lastpost" => intval($lastpost['lastpost']),
"lastposter" => $db->escape_string($lastpost['lastposter']),
"lastposteruid" => intval($lastpost['lastposteruid']),

		"lastpost" => intval($lastpost['lastpost']),
"lastposter" => $db->escape_string($lastpost['lastposter']),
"lastposteruid" => intval($lastpost['lastposteruid']),

Zeile 1265Zeile 1513
		"lastpostsubject" => $db->escape_string($lastpost['subject'])
);


		"lastpostsubject" => $db->escape_string($lastpost['subject'])
);


	$db->update_query(TABLE_PREFIX."forums", $update_count, "fid='{$fid}'");

	$db->update_query(TABLE_PREFIX."forums", $updated_forum, "fid='{$fid}'");

}

/**

}

/**

 * Update the thread counters for a specific thread

















































 * Updates the thread counters with a specific value (or addition/subtraction of the previous value)
*
* @param int The thread ID
* @param array Array of items being updated (replies, unapprovedposts, attachmentcount) and their value (ex, 1, +1, -1)
*/
function update_thread_counters($tid, $changes=array())
{
global $db;

$update_query = array();

$counters = array('replies', 'unapprovedposts', 'attachmentcount');

// Fetch above counters for this thread
$query = $db->simple_select(TABLE_PREFIX."threads", implode(",", $counters), "tid='{$tid}'");
$thread = $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) == "-")
{
$update_query[$counter] = $thread[$counter] + $changes[$counter];
}
else
{
$update_query[$counter] = $changes[$counter];
}
// Less than 0? That's bad
if($update_query[$counter] < 0)
{
$update_query[$counter] = 0;
}
}
}

// Only update if we're actually doing something
if(count($update_query) > 0)
{
$db->update_query(TABLE_PREFIX."threads", $update_query, "tid='".intval($tid)."'");
}

update_thread_data($tid);
}

/**
* Update the first post and lastpost data for a specific thread

 *
* @param int The thread ID
*/

 *
* @param int The thread ID
*/

function update_thread_count($tid)

function update_thread_data($tid)

{

{

	global $db, $cache;
$query = $db->query("
SELECT COUNT(*) AS replies
FROM ".TABLE_PREFIX."posts
WHERE tid='$tid'
AND visible='1'
");
$replies = $db->fetch_array($query);
$treplies = $replies['replies'] - 1;
if($treplies < 0)
{
$treplies = 0;
}

	global $db;













	$query = $db->query("
SELECT u.uid, u.username, p.username AS postusername, p.dateline

	$query = $db->query("
SELECT u.uid, u.username, p.username AS postusername, p.dateline

		FROM ".TABLE_PREFIX."posts p LEFT JOIN ".TABLE_PREFIX."users u ON (u.uid=p.uid)


		FROM ".TABLE_PREFIX."posts p
LEFT JOIN ".TABLE_PREFIX."users u ON (u.uid=p.uid)

		WHERE p.tid='$tid' AND p.visible='1'
ORDER BY p.dateline DESC
LIMIT 1"

		WHERE p.tid='$tid' AND p.visible='1'
ORDER BY p.dateline DESC
LIMIT 1"

Zeile 1299Zeile 1584

$query = $db->query("
SELECT u.uid, u.username, p.username AS postusername, p.dateline


$query = $db->query("
SELECT u.uid, u.username, p.username AS postusername, p.dateline

		FROM ".TABLE_PREFIX."posts p LEFT JOIN ".TABLE_PREFIX."users u ON (u.uid=p.uid)


		FROM ".TABLE_PREFIX."posts p
LEFT JOIN ".TABLE_PREFIX."users u ON (u.uid=p.uid)

		WHERE p.tid='$tid'
ORDER BY p.dateline ASC

		WHERE p.tid='$tid'
ORDER BY p.dateline ASC

		LIMIT 0,1

		LIMIT 1

	");
$firstpost = $db->fetch_array($query);

	");
$firstpost = $db->fetch_array($query);

 


	if(!$firstpost['username'])
{
$firstpost['username'] = $firstpost['postusername'];

	if(!$firstpost['username'])
{
$firstpost['username'] = $firstpost['postusername'];

	}


	}


	if(!$lastpost['username'])
{
$lastpost['username'] = $lastpost['postusername'];
}

	if(!$lastpost['username'])
{
$lastpost['username'] = $lastpost['postusername'];
}

	



	if(!$lastpost['dateline'])
{
$lastpost['username'] = $firstpost['username'];
$lastpost['uid'] = $firstpost['uid'];
$lastpost['dateline'] = $firstpost['dateline'];

	if(!$lastpost['dateline'])
{
$lastpost['username'] = $firstpost['username'];
$lastpost['uid'] = $firstpost['uid'];
$lastpost['dateline'] = $firstpost['dateline'];

	}	


	}


	$lastpost['username'] = $db->escape_string($lastpost['username']);
$firstpost['username'] = $db->escape_string($firstpost['username']);

	$lastpost['username'] = $db->escape_string($lastpost['username']);
$firstpost['username'] = $db->escape_string($firstpost['username']);

	// Unapproved posts
$query = $db->query("
SELECT COUNT(*) AS totunposts
FROM ".TABLE_PREFIX."posts
WHERE tid='$tid' AND visible='0'
");
$nounposts = $db->fetch_field($query, "totunposts");

// Update the attachment count for this thread
update_thread_attachment_count($tid);
$db->query("
UPDATE ".TABLE_PREFIX."threads
SET username='".$firstpost['username']."', uid='".intval($firstpost['uid'])."', lastpost='".intval($lastpost['dateline'])."', lastposter='".$lastpost['username']."', lastposteruid='".intval($lastpost['uid'])."', replies='$treplies', unapprovedposts='$nounposts'
WHERE tid='$tid'
");





$update_array = array(
'username' => $firstpost['username'],
'uid' => intval($firstpost['uid']),
'lastpost' => intval($lastpost['dateline']),
'lastposter' => $lastpost['username'],
'lastposteruid' => intval($lastpost['uid']),
);
$db->update_query(TABLE_PREFIX."threads", $update_array, "tid='{$tid}'");
}

function update_forum_count($fid)
{
die("Depreciated function call: update_forum_count");
}
function update_thread_count($tid)
{
die("Depreciated function call: update_thread_count");

}

}


/**
* Updates the number of attachments for a specific thread
*
* @param int The thread ID
*/

 
function update_thread_attachment_count($tid)
{

function update_thread_attachment_count($tid)
{

	global $db;
$query = $db->query("
SELECT COUNT(*) AS attachment_count
FROM ".TABLE_PREFIX."attachments a LEFT JOIN ".TABLE_PREFIX."posts p ON (a.pid=p.pid)
WHERE p.tid='$tid'
");
$attachment_count = $db->fetch_field($query, "attachment_count");
$db->query("
UPDATE ".TABLE_PREFIX."threads
SET attachmentcount='{$attachment_count}'
WHERE tid='$tid'
");

	die("Depreciated function call: update_thread_attachment_count");












}

/**

}

/**

Zeile 1367Zeile 1641
 * @param int The thread ID
*/
function delete_thread($tid)

 * @param int The thread ID
*/
function delete_thread($tid)

{
global $moderation;
if(!is_object($moderation))
{
require_once MYBB_ROOT."inc/class_moderation.php";
$moderation = new Moderation;
}

{
global $moderation;
if(!is_object($moderation))
{
require_once MYBB_ROOT."inc/class_moderation.php";
$moderation = new Moderation;
}

	return $moderation->delete_thread($tid);
}


	return $moderation->delete_thread($tid);
}


Zeile 1386Zeile 1660
{
global $moderation;
if(!is_object($moderation))

{
global $moderation;
if(!is_object($moderation))

	{

	{

		require_once MYBB_ROOT."inc/class_moderation.php";
$moderation = new Moderation;
}
return $moderation->delete_post($pid);
}

		require_once MYBB_ROOT."inc/class_moderation.php";
$moderation = new Moderation;
}
return $moderation->delete_post($pid);
}





/**
* Builds a forum jump menu
*

/**
* Builds a forum jump menu
*

Zeile 1407Zeile 1681
 */
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", $permissions="", $name="fid")
{

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

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


$pid = intval($pid);
if($permissions)


$pid = intval($pid);
if($permissions)

	{

	{

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

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

		{

		{

			cache_forums();
}
foreach($forum_cache as $fid => $forum)
{
if($forum['active'] != "no")

			cache_forums();
}
foreach($forum_cache as $fid => $forum)
{
if($forum['active'] != "no")

			{

			{

				$jumpfcache[$forum['pid']][$forum['disporder']][$forum['fid']] = $forum;
}
}

				$jumpfcache[$forum['pid']][$forum['disporder']][$forum['fid']] = $forum;
}
}

Zeile 1446Zeile 1720
					{
$optionselected = "selected=\"selected\"";
$selecteddone = 1;

					{
$optionselected = "selected=\"selected\"";
$selecteddone = 1;

					}




					}

$forum['name'] = htmlspecialchars_uni($forum['name']);


					eval("\$forumjumpbits .= \"".$templates->get("forumjump_bit")."\";");
if($forum_cache[$forum['fid']])
{

					eval("\$forumjumpbits .= \"".$templates->get("forumjump_bit")."\";");
if($forum_cache[$forum['fid']])
{

Zeile 1470Zeile 1747
		if($showextras == 0)
{
$template = "special";

		if($showextras == 0)
{
$template = "special";

		}
else
{

		}
else
{

			$template = "advanced";
}
eval("\$forumjump = \"".$templates->get("forumjump_".$template)."\";");

			$template = "advanced";
}
eval("\$forumjump = \"".$templates->get("forumjump_".$template)."\";");

Zeile 1579Zeile 1856
			"editor_size_x_small",
"editor_size_small",
"editor_size_medium",

			"editor_size_x_small",
"editor_size_small",
"editor_size_medium",

 
			"editor_size_large",

			"editor_size_x_large",
"editor_size_xx_large",
"editor_color_white",

			"editor_size_x_large",
"editor_size_xx_large",
"editor_color_white",

Zeile 1617Zeile 1895
		eval("\$codeinsert = \"".$templates->get("codebuttons")."\";");
}
return $codeinsert;

		eval("\$codeinsert = \"".$templates->get("codebuttons")."\";");
}
return $codeinsert;

}

/**

}

/**

 * Build the javascript clickable smilie inserter
*
* @return string The clickable smilies list
*/
function build_clickable_smilies()
{

 * Build the javascript clickable smilie inserter
*
* @return string The clickable smilies list
*/
function build_clickable_smilies()
{

	global $db, $smiliecache, $theme, $templates, $lang, $mybb;

	global $db, $smiliecache, $theme, $templates, $lang, $mybb, $smiliecount;


if($mybb->settings['smilieinserter'] != "off" && $mybb->settings['smilieinsertercols'] && $mybb->settings['smilieinsertertot'])
{


if($mybb->settings['smilieinserter'] != "off" && $mybb->settings['smilieinsertercols'] && $mybb->settings['smilieinsertertot'])
{

		$smiliecount = 0;






		if(!$smiliecount)
{
$query = $db->simple_select(TABLE_PREFIX."smilies", "COUNT(*) as smilies");
$smiliecount = $db->fetch_field($query, "smilies");
}


		if(!$smiliecache)
{

		if(!$smiliecache)
{

			$query = $db->query("
SELECT *
FROM ".TABLE_PREFIX."smilies
WHERE showclickable != 'no'
ORDER BY disporder
");

			$query = $db->simple_select(TABLE_PREFIX."smilies", "*", "showclickable != 'no'", array('order_by' => 'disporder'));







while($smilie = $db->fetch_array($query))
{
$smiliecache[$smilie['find']] = $smilie['image'];


while($smilie = $db->fetch_array($query))
{
$smiliecache[$smilie['find']] = $smilie['image'];

				$smiliecount++;

 
			}
}
unset($smilie);

			}
}
unset($smilie);

Zeile 1670Zeile 1947
					{
$smilies .= "<tr>\n";
}

					{
$smilies .= "<tr>\n";
}

					$find = $db->escape_string(htmlspecialchars($find));

					$find = htmlspecialchars_uni($find);

					$smilies .= "<td><img src=\"{$image}\" border=\"0\" class=\"smilie\" alt=\"{$find}\" /></td>\n";
$i++;
$counter++;

					$smilies .= "<td><img src=\"{$image}\" border=\"0\" class=\"smilie\" alt=\"{$find}\" /></td>\n";
$i++;
$counter++;

Zeile 1725Zeile 2002
			$encoding = "gzip";
}
if(isset($encoding))

			$encoding = "gzip";
}
if(isset($encoding))

		{

		{

			header("Content-Encoding: $encoding");
if(function_exists("gzencode"))
{

			header("Content-Encoding: $encoding");
if(function_exists("gzencode"))
{

Zeile 1755Zeile 2032
function log_moderator_action($data, $action="")
{
global $mybb, $db, $session;

function log_moderator_action($data, $action="")
{
global $mybb, $db, $session;





	/* If the fid or tid is not set, set it at 0 so MySQL doesn't choke on it. */
if($data['fid'] == '')
{
$fid = 0;

	/* If the fid or tid is not set, set it at 0 so MySQL doesn't choke on it. */
if($data['fid'] == '')
{
$fid = 0;

	}
else

	}
else

	{
$fid = $data['fid'];
unset($data['fid']);
}
if($data['tid'] == '')

	{
$fid = $data['fid'];
unset($data['fid']);
}
if($data['tid'] == '')

	{

	{

		$tid = 0;

		$tid = 0;

	}

	}

	else
{
$tid = $data['tid'];
unset($data['tid']);

	else
{
$tid = $data['tid'];
unset($data['tid']);

	}


	}


	// Any remaining extra data - we serialize and insert in to its own column
if(is_array($data))
{

	// Any remaining extra data - we serialize and insert in to its own column
if(is_array($data))
{

Zeile 1791Zeile 2068
		"tid" => $tid,
"action" => $db->escape_string($action),
"data" => $db->escape_string($data),

		"tid" => $tid,
"action" => $db->escape_string($action),
"data" => $db->escape_string($data),

		"ipaddress" => $session->ipaddress

		"ipaddress" => $db->escape_string($session->ipaddress)

	);
$db->insert_query(TABLE_PREFIX."moderatorlog", $sql_array);
}

	);
$db->insert_query(TABLE_PREFIX."moderatorlog", $sql_array);
}

Zeile 1807Zeile 2084
{
global $theme;


{
global $theme;


	if($uid != 0)
{

	if($uid != 0)
{

		$display_reputation = "<a href=\"reputation.php?uid={$uid}\">";
}
$display_reputation .= "<strong class=\"";

		$display_reputation = "<a href=\"reputation.php?uid={$uid}\">";
}
$display_reputation .= "<strong class=\"";

Zeile 1826Zeile 2103
	}
$display_reputation .= "\">{$reputation}</strong>";
if($uid != 0)

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

	{

	{

		$display_reputation .= "</a>";
}
return $display_reputation;

		$display_reputation .= "</a>";
}
return $display_reputation;

Zeile 1851Zeile 2128
					break;
}
}

					break;
}
}

		}

		}

	}
if(!isset($ip))
{
if(isset($_SERVER['HTTP_CLIENT_IP']))
{
$ip = $_SERVER['HTTP_CLIENT_IP'];

	}
if(!isset($ip))
{
if(isset($_SERVER['HTTP_CLIENT_IP']))
{
$ip = $_SERVER['HTTP_CLIENT_IP'];

		}

		}

		else
{
$ip = $_SERVER['REMOTE_ADDR'];
}
}

		else
{
$ip = $_SERVER['REMOTE_ADDR'];
}
}

 

$ip = preg_replace("#([^.0-9 ]*)#", "", $ip);


	return $ip;
}


	return $ip;
}


Zeile 1876Zeile 2156
function get_friendly_size($size)
{
global $lang;

function get_friendly_size($size)
{
global $lang;





	if($size >= 1073741824)
{
$size = round(($size / 1073741824), 2) . " " . $lang->size_gb;

	if($size >= 1073741824)
{
$size = round(($size / 1073741824), 2) . " " . $lang->size_gb;

Zeile 1886Zeile 2166
		$size = round(($size / 1048576), 2) . " " . $lang->size_mb;
}
elseif($size >= 1024)

		$size = round(($size / 1048576), 2) . " " . $lang->size_mb;
}
elseif($size >= 1024)

	{

	{

		$size = round(($size / 1024), 2) . " " . $lang->size_kb;
}
elseif($size == 0)

		$size = round(($size / 1024), 2) . " " . $lang->size_kb;
}
elseif($size == 0)

	{

	{

		$size = "0 ".$lang->size_bytes;
}
else

		$size = "0 ".$lang->size_bytes;
}
else

Zeile 1914Zeile 2194
	{
$attachtypes = $cache->read("attachtypes");
}

	{
$attachtypes = $cache->read("attachtypes");
}

 
	
$directory = "";

if(defined("IN_PORTAL"))
{
global $change_dir;
$directory = $change_dir."/";
}


	$ext = strtolower($ext);
if($attachtypes[$ext]['icon'])
{

	$ext = strtolower($ext);
if($attachtypes[$ext]['icon'])
{

		return "<img src=\"".$attachtypes[$ext]['icon']."\" border=\"0\" alt=\".$ext File\" />";

		return "<img src=\"{$directory}".$attachtypes[$ext]['icon']."\" border=\"0\" alt=\".$ext File\" />";

	}
else
{

	}
else
{

		return "<img src=\"images/attachtypes/unknown.gif\" border=\"0\" alt=\".$ext File\" />";

		return "<img src=\"{$directory}images/attachtypes/unknown.gif\" border=\"0\" alt=\".$ext File\" />";

	}
}


	}
}


Zeile 2125Zeile 2414
	if((preg_match("#win#i", PHP_OS) && is_numeric(stripos($_SERVER['SERVER_SOFTWARE'], "apache")) == false) || is_numeric(stripos(SAPI_NAME, "cgi")) !== false || defined("ARCHIVE_QUERY_STRINGS"))
{
$base_url = $mybb->settings['bburl']."/archive/index.php?";

	if((preg_match("#win#i", PHP_OS) && is_numeric(stripos($_SERVER['SERVER_SOFTWARE'], "apache")) == false) || is_numeric(stripos(SAPI_NAME, "cgi")) !== false || defined("ARCHIVE_QUERY_STRINGS"))
{
$base_url = $mybb->settings['bburl']."/archive/index.php?";

	}
else
{

	}
else
{

		$base_url = $mybb->settings['bburl']."/archive/index.php/";
}
switch($type)
{
case "thread":
$url = "{$base_url}thread-{$id}.html";

		$base_url = $mybb->settings['bburl']."/archive/index.php/";
}
switch($type)
{
case "thread":
$url = "{$base_url}thread-{$id}.html";

			break;

			break;

		case "announcement":
$url = "{$base_url}announcement-{$id}.html";
break;

		case "announcement":
$url = "{$base_url}announcement-{$id}.html";
break;

Zeile 2146Zeile 2435
	}
return $url;
}

	}
return $url;
}





/**
* Prints a debug information page
*/

/**
* Prints a debug information page
*/

Zeile 2170Zeile 2459
		$gzipen = "Disabled";
}
echo "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n";

		$gzipen = "Disabled";
}
echo "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n";

	echo "<html lang=\"en\">";

	echo "<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\" lang=\"en\">";

	echo "<head>";
echo "<title>MyBB Debug Information</title>";
echo "</head>";

	echo "<head>";
echo "<title>MyBB Debug Information</title>";
echo "</head>";

Zeile 2178Zeile 2467
	echo "<h1>MyBB Debug Information</h1>\n";
echo "<h2>Page Generation</h2>\n";
echo "<table bgcolor=\"#666666\" width=\"95%\" cellpadding=\"4\" cellspacing=\"1\" align=\"center\">\n";

	echo "<h1>MyBB Debug Information</h1>\n";
echo "<h2>Page Generation</h2>\n";
echo "<table bgcolor=\"#666666\" width=\"95%\" cellpadding=\"4\" cellspacing=\"1\" align=\"center\">\n";

	echo "<tr>\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 "<td bgcolor=\"#CCCCCC\" colspan=\"4\"><b><span style=\"size:2;\">Page Generation Statistics</span></b></td>\n";
echo "</tr>\n";
echo "<tr>\n";

Zeile 2188Zeile 2477
	echo "<td bgcolor=\"#FEFEFE\" width=\"25%\"><font face=\"Tahoma\" size=\"2\">$db->query_count</font></td>\n";
echo "</tr>\n";
echo "<tr>\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 "<td bgcolor=\"#EFEFEF\" width=\"25%\"><b><font face=\"Tahoma\" size=\"2\">PHP Proccessing 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\">MySQL Processing Time:</font></b></td>\n";
echo "<td bgcolor=\"#FEFEFE\" width=\"25%\"><font face=\"Tahoma\" size=\"2\">$querytime seconds ($percentsql%)</font></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\">MySQL Processing Time:</font></b></td>\n";
echo "<td bgcolor=\"#FEFEFE\" width=\"25%\"><font face=\"Tahoma\" size=\"2\">$querytime seconds ($percentsql%)</font></td>\n";

Zeile 2228Zeile 2517
	echo "<h2>Template Statistics</h2>\n";

if(count($templates->cache) > 0)

	echo "<h2>Template Statistics</h2>\n";

if(count($templates->cache) > 0)

	{
echo "<table style=\"background-color: #666;\" width=\"95%\" cellpadding=\"4\" cellspacing=\"1\" align=\"center\">\n";

	{
echo "<table style=\"background-color: #666;\" width=\"95%\" cellpadding=\"4\" cellspacing=\"1\" align=\"center\">\n";

		echo "<tr>\n";

		echo "<tr>\n";

		echo "<td colspan=\"8\" style=\"background-color: #ccc;\"><strong>Templates Used (Loaded for this Page) - ".count($templates->cache)." Total</strong></td>\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 "<td style=\"background: #fff;\">".implode(", ", array_keys($templates->cache))."</td>\n";

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

Zeile 2244Zeile 2533
	{
echo "<table style=\"background-color: #666;\" width=\"95%\" cellpadding=\"4\" cellspacing=\"1\" align=\"center\">\n";
echo "<tr>\n";

	{
echo "<table style=\"background-color: #666;\" width=\"95%\" cellpadding=\"4\" cellspacing=\"1\" align=\"center\">\n";
echo "<tr>\n";

		echo "<td colspan=\"8\" style=\"background-color: #ccc;\"><strong>Templates Requiring Additional Calls (Not Cached at Startup) - ".count($templates->uncached_templates)." Total</strong></td>\n";

		echo "<td style=\"background-color: #ccc;\"><strong>Templates Requiring Additional Calls (Not Cached at Startup) - ".count($templates->uncached_templates)." Total</strong></td>\n";

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

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

Zeile 2381Zeile 2670
		$nicetime['days'] = "1 ".$lang->day;
}
elseif($days > 1)

		$nicetime['days'] = "1 ".$lang->day;
}
elseif($days > 1)

	{

	{

		$nicetime['days'] = $days." ".$lang->days;
}


		$nicetime['days'] = $days." ".$lang->days;
}


Zeile 2405Zeile 2694

if($seconds == 1)
{


if($seconds == 1)
{

		$nicetime['seconds'] = "1 ".$lang->seconds;

		$nicetime['seconds'] = "1 ".$lang->second;

	}
elseif($seconds > 1)
{

	}
elseif($seconds > 1)
{

Zeile 2532Zeile 2821
		UPDATE ".TABLE_PREFIX."users
SET additionalgroups='$groupslist' $dispupdate
WHERE uid='$uid'

		UPDATE ".TABLE_PREFIX."users
SET additionalgroups='$groupslist' $dispupdate
WHERE uid='$uid'

	");

	");

}

/**

}

/**

Zeile 2612Zeile 2901
 */
function build_theme_select($name, $selected="", $tid=0, $depth="", $usergroup_override=0)
{

 */
function build_theme_select($name, $selected="", $tid=0, $depth="", $usergroup_override=0)
{

	global $db, $themeselect, $tcache, $lang, $mybb;


	global $db, $themeselect, $tcache, $lang, $mybb, $limit;


	if($tid == 0)

	if($tid == 0)

	{

	{

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

		$themeselect = "<select name=\"$name\">";
$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))
{

		$query = $db->query("
SELECT name, pid, tid, allowedgroups
FROM ".TABLE_PREFIX."themes
WHERE pid != 0
ORDER BY pid, name
");

		$query = $db->simple_select(TABLE_PREFIX."themes", "name, pid, tid, allowedgroups", "pid != '0'", array('order_by' => 'pid, name'));






		while($theme = $db->fetch_array($query))
{

		while($theme = $db->fetch_array($query))
{

			$tcache[$theme['pid']][] = $theme;

			$tcache[$theme['pid']][$theme['tid']] = $theme;

		}
}

		}
}

	if(is_array($tcache))


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

	{
// Figure out what groups this user is in
if($mybb->user['additionalgroups'])

	{
// Figure out what groups this user is in
if($mybb->user['additionalgroups'])

Zeile 2641Zeile 2930
		}
$in_groups[] = $mybb->user['usergroup'];


		}
$in_groups[] = $mybb->user['usergroup'];


		foreach($tcache as $misc)

		foreach($tcache[$tid] as $theme)

		{

		{

			foreach($misc as $theme)




			$sel = "";
// Make theme allowed groups into array
$is_allowed = false;
if($theme['allowedgroups'] != "all" && $theme['allowedgroups'] != "")

			{

			{

				$sel = "";
// Make theme allowed groups into array
$is_allowed = false;
if($theme['allowedgroups'] != "all" && $theme['allowedgroups'] != "")

				$allowed_groups = explode(",", $theme['allowedgroups']);
// See if groups user is in is allowed
foreach($allowed_groups as $agid)


				{

				{

					$allowed_groups = explode(",", $theme['allowedgroups']);
// See if groups user is in is allowed
foreach($allowed_groups as $agid)

					if(in_array($agid, $in_groups))



					{

					{

						if(in_array($agid, $in_groups))
{
$is_allowed = true;
break;
}

						$is_allowed = true;
break;




					}
}

					}
}

				// Show theme if allowed, or if override is on
if($is_allowed || $theme['allowedgroups'] == "all" || $usergroup_override == 1)
















			}

// Show theme if allowed, or if override is on
if($is_allowed || $theme['allowedgroups'] == "all" || $theme['allowedgroups'] == "" || $usergroup_override == 1)
{
if($theme['tid'] == $selected)
{
$sel = " selected=\"selected\"";
}

if($theme['pid'] != 0)
{
$themeselect .= "<option value=\"".$theme['tid']."\"$sel>".$depth.$theme['name']."</option>";
$depthit = $depth."--";
}

if(array_key_exists($theme['tid'], $tcache))

				{

				{

					if($theme['tid'] == $selected)
{
$sel = " selected=\"selected\"";
}
if($theme['pid'] != 0)
{
$themeselect .= "<option value=\"".$theme['tid']."\"$sel>".$depth.$theme['name']."</option>";
$depthit = $depth."--";
}
if(array_key_exists($theme['tid'], $tcache))
{
build_theme_select($name, $selected, $theme['tid'], $depthit, $usergroup_override);
}

					build_theme_select($name, $selected, $theme['tid'], $depthit, $usergroup_override);













				}
}
}
}

				}
}
}
}

	if(!$tid)


	
if($tid == 0)

	{
$themeselect .= "</select>";
}

	{
$themeselect .= "</select>";
}

 
	

	return $themeselect;

	return $themeselect;

}

/**

}

/**

 * Custom function for htmlspecialchars which takes in to account unicode
*
* @param string The string to format

 * Custom function for htmlspecialchars which takes in to account unicode
*
* @param string The string to format

Zeile 2700Zeile 2991
	$message = str_replace("<","&lt;",$message);
$message = str_replace(">","&gt;",$message);
$message = str_replace("\"","&quot;",$message);

	$message = str_replace("<","&lt;",$message);
$message = str_replace(">","&gt;",$message);
$message = str_replace("\"","&quot;",$message);

	$message = str_replace("  ", "&nbsp;&nbsp;", $message);

 
	return $message;
}


	return $message;
}


Zeile 2711Zeile 3001
 * @return int The formatted number.
*/
function my_number_format($number)

 * @return int The formatted number.
*/
function my_number_format($number)

{

{

	global $mybb;
if($number == "-")
{
return $number;
}
if(is_int($number))

	global $mybb;
if($number == "-")
{
return $number;
}
if(is_int($number))

	{

	{

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

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

Zeile 2733Zeile 3023
			$decimals = 0;
}
return number_format($number, $decimals, $mybb->settings['decpoint'], $mybb->settings['thousandssep']);

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

	}
}

/**

	}
}

/**

 * Replacement function for PHP's wordwrap(). This version does not break up HTML tags, URLs or unicode references.
*
* @param string The string to be word wrapped

 * Replacement function for PHP's wordwrap(). This version does not break up HTML tags, URLs or unicode references.
*
* @param string The string to be word wrapped

Zeile 2748Zeile 3038

if($mybb->settings['wordwrap'] > 0)
{


if($mybb->settings['wordwrap'] > 0)
{

		$message = preg_replace("#(?>[^\s&/<>\"\\-\.\[\]]{{$mybb->settings['wordwrap']}})#", "$0 ", $message);








		if($mybb->config['db_encoding'] == "utf8" && !preg_match("#[\x80-\xFF]#", $message))
{
$message = preg_replace("#(?>[^\s&/<>\"\\-\.\[\]]{{$mybb->settings['wordwrap']}})#u", "$0 ", $message);
}
else
{
$message = preg_replace("#(?>[^\s&/<>\"\\-\.\[\]]{{$mybb->settings['wordwrap']}})#", "$0 ", $message);
}

	}
return $message;
}

	}
return $message;
}

Zeile 2762Zeile 3059
 * @return int The numeric day of the week for the birthday
*/
function get_weekday($month, $day, $year)

 * @return int The numeric day of the week for the birthday
*/
function get_weekday($month, $day, $year)

{

{

	$h = 4;
for($i = 1969; $i >= $year; $i--)
{

	$h = 4;
for($i = 1969; $i >= $year; $i--)
{

Zeile 2826Zeile 3123
 */
function get_age($birthday)
{

 */
function get_age($birthday)
{

        $bday = explode("-", $birthday);
if($bday[2] < 1970)
{
$years = 1970-$bday[2];
$year = $bday[2]+($years*2);
$stamp = mktime(0, 0, 0, $bday[1], $bday[0], $year)-($years*31556926*2);
}
else
{
$stamp = mktime(0, 0, 0, $bday[1], $bday[0], $bday[2]);
}
$age = floor((time()-$stamp)/31556926);
return $age;



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

list($day, $month, $year) = explode("-", my_date("j-n-Y", time(), 0, 0));

$age = $year-$bday[2];

if(($month == $bday[1] && $day < $bday[0]) || $month < $bday[1])
{
--$age;
}
return $age;

}

/**
* Updates the first posts in a thread.

}

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

 * @param int The thread id for which to update the first post id.
*/
function update_first_post($tid)

Zeile 2874Zeile 3173
 * @return int The length of the string.
*/
function my_strlen($string)

 * @return int The length of the string.
*/
function my_strlen($string)

{
$string = preg_replace("#&\#(0-9]+);#", "-", $string);
if(function_exists("mb_strlen"))
{
$string_length = mb_strlen($string);
}
else
{
$string_length = strlen($string);
}

return $string_length;
}















{
global $lang;

$string = preg_replace("#&\#(0-9]+);#", "-", $string);

if(strtolower($lang->settings['charset']) == "utf-8")
{
// 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 whitspaces
$string = str_replace(chr(0xCA), "", $string);
}
$string = trim($string);

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

return $string_length;
}


/**
* Cuts a string at a specified point, mb strings accounted for


/**
* Cuts a string at a specified point, mb strings accounted for

Zeile 2899Zeile 3212
function my_substr($string, $start, $length="")
{
if(function_exists("mb_substr"))

function my_substr($string, $start, $length="")
{
if(function_exists("mb_substr"))

	{
if($length != "")
{

	{
if($length != "")
{

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

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

Zeile 2922Zeile 3235
	}

return $cut_string;

	}

return $cut_string;

 
}

/**
* lowers the case of a string, mb strings accounted for
*
* @param string The string to lower.
* @return int The lowered string.
*/
function my_strtolower($string)
{
if(function_exists("mb_strtolower"))
{
$string = mb_strtolower($string);
}
else
{
$string = strtolower($string);
}

return $string;
}

/**
* 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
* @return int false on needle not found, integer position if found
*/
function my_strpos($haystack, $needle, $offset=0)
{
if($needle == '')
{
return false;
}

if(function_exists("mb_strpos"))
{
$position = mb_strpos($haystack, $needle, $offset);
}
else
{
$position = strpos($haystack, $needle, $offset);
}

return $position;
}

/**
* ups the case of a string, mb strings accounted for
*
* @param string The string to up.
* @return int The uped string.
*/
function my_strtoupper($string)
{
if(function_exists("mb_strtoupper"))
{
$string = mb_strtoupper($string);
}
else
{
$string = strtoupper($string);
}

return $string;

}

/**

}

/**

Zeile 2932Zeile 3312
 */
function unhtmlentities($string)
{

 */
function unhtmlentities($string)
{

   // replace numeric entities

   // Replace numeric entities

   $string = preg_replace('~&#x([0-9a-f]+);~ei', 'chr(hexdec("\\1"))', $string);
$string = preg_replace('~&#([0-9]+);~e', 'chr(\\1)', $string);

   $string = preg_replace('~&#x([0-9a-f]+);~ei', 'chr(hexdec("\\1"))', $string);
$string = preg_replace('~&#([0-9]+);~e', 'chr(\\1)', $string);

   // replace literal entities



// Replace literal entities

   $trans_tbl = get_html_translation_table(HTML_ENTITIES);
$trans_tbl = array_flip($trans_tbl);

   $trans_tbl = get_html_translation_table(HTML_ENTITIES);
$trans_tbl = array_flip($trans_tbl);

 


   return strtr($string, $trans_tbl);

   return strtr($string, $trans_tbl);

}

}


/**
* Get the event poster.


/**
* Get the event poster.

 *
* @param array The event data array.

 *
* @param array The event data array.

 * @return string The link to the event poster.
*/
function get_event_poster($event)
{
if($event['username'])

 * @return string The link to the event poster.
*/
function get_event_poster($event)
{
if($event['username'])

	{

	{

		$event_poster = "<a href=\"member.php?action=profile&amp;uid=".$event['author']."\">" . format_name($event['username'], $event['usergroup'], $event['displaygroup']) . "</a>";
}
else

		$event_poster = "<a href=\"member.php?action=profile&amp;uid=".$event['author']."\">" . format_name($event['username'], $event['usergroup'], $event['displaygroup']) . "</a>";
}
else

Zeile 2959Zeile 3341
	}

return $event_poster;

	}

return $event_poster;

}

/**

}

/**

 * Get the event date.
*
* @param array The event data array.
* @return string The event date.

 * Get the event date.
*
* @param array The event data array.
* @return string The event date.

 */

 */

function get_event_date($event)
{
$event_date = explode("-", $event['date']);
$event_date = mktime(0, 0, 0, $event_date[1], $event_date[0], $event_date[2]);
$event_date = my_date($mybb->settings['dateformat'], $event_date);

function get_event_date($event)
{
$event_date = explode("-", $event['date']);
$event_date = mktime(0, 0, 0, $event_date[1], $event_date[0], $event_date[2]);
$event_date = my_date($mybb->settings['dateformat'], $event_date);





	return $event_date;
}

/**
* Get the profile link.

	return $event_date;
}

/**
* Get the profile link.

 *
* @param int The user id of the profile.
* @return string The url to the profile.
*/

 *
* @param int The user id of the profile.
* @return string The url to the profile.
*/

function get_profile_link($uid=0)
{
$link = str_replace("{uid}", $uid, PROFILE_URL);

function get_profile_link($uid=0)
{
$link = str_replace("{uid}", $uid, PROFILE_URL);

Zeile 2994Zeile 3376
 * @param string The Username of the profile.
* @param int The user id of the profile.
* @param string The target frame

 * @param string The Username of the profile.
* @param int The user id of the profile.
* @param string The target frame

 
 * @param string Any onclick javascript.

 * @return string The url to the profile.
*/

 * @return string The url to the profile.
*/

function build_profile_link($username="", $uid=0, $target="")

function build_profile_link($username="", $uid=0, $target="", $onclick="")

{
global $lang;


{
global $lang;


Zeile 3017Zeile 3400
		{
$target = " target=\"{$target}\"";
}

		{
$target = " target=\"{$target}\"";
}

		return "<a href=\"".get_profile_link($uid)."\"{$target}>{$username}</a>";





		if(!empty($onclick))
{
$onclick = " onclick=\"{$onclick}\"";
}
return "<a href=\"".get_profile_link($uid)."\"{$target}{$onclick}>{$username}</a>";

	}
}


	}
}


Zeile 3062Zeile 3449
}

/**

}

/**

 * Get the username of a user id.

 * Get the user data of a user id.

 *
* @param int The user id of the user.

 *
* @param int The user id of the user.

 * @return string The username of the user.

 * @return array The user data.

 */
function get_user($uid)
{

 */
function get_user($uid)
{

Zeile 3235Zeile 3622
 * @return bool Number of logins when success, false if failed.
*/
function login_attempt_check($fatal = true)

 * @return bool Number of logins when success, false if failed.
*/
function login_attempt_check($fatal = true)

{

{

	global $mybb, $lang, $session, $db;

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

	global $mybb, $lang, $session, $db;

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

Zeile 3302Zeile 3689
*/
function validate_email_format($email)
{

*/
function validate_email_format($email)
{

	if(!preg_match("/^(.+)@[a-zA-Z0-9-]+\.[a-zA-Z0-9.-]+$/si", $email))

	if(strpos($email, ' ') !== false)

	{
return false;
}

	{
return false;
}

	else
{
return true;
}

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



}

/**

}

/**

Zeile 3336Zeile 3721

while($setting = $db->fetch_array($query))
{


while($setting = $db->fetch_array($query))
{

		$setting['value'] = str_replace("\"", "\\\"", $setting['value']);
$settings .= "\$settings['".$setting['name']."'] = \"".$setting['value']."\";\n";

 
		$mybb->settings[$setting['name']] = $setting['value'];

		$mybb->settings[$setting['name']] = $setting['value'];

 
		$setting['value'] = addcslashes($setting['value'], '\\"$');
$settings .= "\$settings['{$setting['name']}'] = \"{$setting['value']}\";\n";

	}
$settings = "<"."?php\n/*********************************\ \n DO NOT EDIT THIS FILE, PLEASE USE\n THE SETTINGS EDITOR\n\*********************************/\n\n$settings\n?".">";
$file = @fopen(MYBB_ROOT."inc/settings.php", $mode);

	}
$settings = "<"."?php\n/*********************************\ \n DO NOT EDIT THIS FILE, PLEASE USE\n THE SETTINGS EDITOR\n\*********************************/\n\n$settings\n?".">";
$file = @fopen(MYBB_ROOT."inc/settings.php", $mode);

Zeile 3388Zeile 3773
		return false;
}
return $dest;

		return false;
}
return $dest;

 
}

/**
* Return a list of banned usernames.
*
* @return array The array of banned usernames.
*/
function get_banned_usernames()
{
global $mybb;
$banned_usernames = explode(",", $mybb->settings['bannedusernames']);
$banned_usernames = array_map("trim", $banned_usernames);
$banned_usernames = array_map("strtolower", $banned_usernames);
return $banned_usernames;
}

/**
* Checks if a username has been disallowed for registration/use.
*
* @param string The username
* @return boolean True if banned, false if not banned
*/
function is_banned_username($username)
{
$banned_usernames = get_banned_usernames();
if(in_array(strtolower($username), $banned_usernames))
{
return true;
}
else
{
return false;
}
}

/**
* Return a list of banned email addresses.
*
* @return array The array of banned email addresses.
*/
function get_banned_emails()
{
global $mybb;
$banned_emails = explode(",", $mybb->settings['bannedemails']);
$banned_emails = array_map("trim", $banned_emails);
$banned_emails = array_map("strtolower", $banned_emails);
return $banned_emails;
}

/**
* Check if a specific email address has been banned.
*
* @param string The email address.
* @return boolean True if banned, false if not banned
*/
function is_banned_email($email)
{
$banned_emails = get_banned_emails();
$email = strtolower($email);
foreach($banned_emails as $banned_email)
{
if($banned_email != "" && strpos($email, $banned_email) !== false)
{
return true;
}
}
return false;
}

/**
* Return a list of banned IP addresses.
*
* @return array The array of banned IP addresses.
*/
function get_banned_ips()
{
global $mybb;
$banned_ips = explode(",", $mybb->settings['bannedips']);
$banned_ips = array_map("trim", $banned_ips);
return $banned_ips;
}

/**
* Checks if a specific IP address has been banned.
*
* @param string The IP address.
* @return boolean True if banned, false if not banned.
*/
function is_banned_ip($ip_address)
{
$banned_ips = get_banned_ips();
foreach($banned_ips as $banned_ip)
{
if($banned_ip != "" && strpos($ip_address, $banned_ip) !== false)
{
return true;
}
}
return false;
}

/**
* Fetch the contents of a remote fle.
*
* @param string The URL of the remote file
* @return string The remote file contents.
*/
function fetch_remote_file($url)
{
if(function_exists("curl_init"))
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$data = curl_exec($ch);
curl_close($ch);
return $data;
}
else if(function_exists("fsockopen"))
{
$url = parse_url($url);
if(!$url['host'])
{
return false;
}
if(!$url['port'])
{
$url['port'] = 80;
}
if(!$url['path'])
{
$url['path'] = "/";
}
if($url['query'])
{
$url['path'] .= "?{$url['path']}";
}
$fp = @fsockopen($url['host'], $url['port'], $error_no, $error, 10);
@stream_set_timeout($fp, 10);
if(!$fp)
{
return false;
}
$headers = "GET {$url['path']} HTTP/1.1\r\n";
$headers .= "Host: {$url['host']}\r\n";
$headers .= "Connection: Close\r\n\r\n";
if(!@fwrite($fp, $headers))
{
return false;
}
while(!feof($fp))
{
$data .= fgets($fp, 12800);
}
fclose($fp);
$data = explode("\r\n\r\n", $data, 2);
return $data[1];
}
else
{
return @implode("", @file($url));
}
}

/**
* Unicode function for php function chr()
*
* @param string The character
* @return mixed The unicoded chr()
*/
function unicode_chr($c)
{
if($c <= 0x7F)
{
return chr($c);
}
elseif($c <= 0x7FF)
{
return chr(0xC0 | $c >> 6) . chr(0x80 | $c & 0x3F);
}
elseif($c <= 0xFFFF)
{
return chr(0xE0 | $c >> 12) . chr(0x80 | $c >> 6 & 0x3F)
. chr(0x80 | $c & 0x3F);
}
elseif($c <= 0x10FFFF)
{
return chr(0xF0 | $c >> 18) . chr(0x80 | $c >> 12 & 0x3F)
. chr(0x80 | $c >> 6 & 0x3F)
. chr(0x80 | $c & 0x3F);
}
else
{
return false;
}

}

/**

}

/**