Vergleich inc/functions.php - 1.6.10 - 1.6.11

  Keine Änderungen   Hinzugefügt   Modifiziert   Entfernt
Zeile 73Zeile 73
			{
$memory_usage = '';
}

			{
$memory_usage = '';
}

 
			// MySQLi is still MySQL, so present it that way to the user
$database_server = $db->short_title;





 
			if($database_server == 'MySQLi')
{
$database_server = 'MySQL';
}

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

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

			$debugstuff = "Generated in $totaltime seconds ($percentphp% PHP / $percentsql% MySQL)<br />SQL Queries: $db->query_count /  Global Parsing Time: $globaltime$memory_usage<br />$other<br />[<a href=\"$debuglink\" target=\"_blank\">advanced details</a>]<br />";

			$debugstuff = "Generated in $totaltime seconds ($percentphp% PHP / $percentsql% ".$database_server.")<br />SQL Queries: $db->query_count /  Global Parsing Time: $globaltime$memory_usage<br />$other<br />[<a href=\"$debuglink\" target=\"_blank\">advanced details</a>]<br />";

			$contents = str_replace("<debugstuff>", $debugstuff, $contents);
}


			$contents = str_replace("<debugstuff>", $debugstuff, $contents);
}


Zeile 92Zeile 98
	{
$contents = gzip_encode($contents, $mybb->settings['gziplevel']);
}

	{
$contents = gzip_encode($contents, $mybb->settings['gziplevel']);
}

	



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

	@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");

Zeile 110Zeile 116
function add_shutdown($name, $arguments=array())
{
global $shutdown_functions;

function add_shutdown($name, $arguments=array())
{
global $shutdown_functions;

	







if(!is_array($shutdown_functions))
{
$shutdown_functions = array();
}


	if(!is_array($arguments))
{
$arguments = array($arguments);
}

if(is_array($name) && method_exists($name[0], $name[1]))

	if(!is_array($arguments))
{
$arguments = array($arguments);
}

if(is_array($name) && method_exists($name[0], $name[1]))

	{
$shutdown_functions["class_".get_class($name[0])."_".$name[1]] = array('function' => $name, 'arguments' => $arguments);
return true;

	{
$shutdown_functions[] = array('function' => $name, 'arguments' => $arguments);
return true;

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

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

		$shutdown_functions[$name] = array('function' => $name, 'arguments' => $arguments);

		$shutdown_functions[] = array('function' => $name, 'arguments' => $arguments);

		return true;
}


		return true;
}


Zeile 141Zeile 152
	if($done_shutdown == true || !$config || $error_handler->has_errors)
{
return;

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

	}

	}


// Missing the core? Build
if(!is_object($mybb))


// Missing the core? Build
if(!is_object($mybb))

Zeile 162Zeile 173
		{
require MYBB_ROOT."inc/config.php";
}

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

		



		if(isset($config))
{
require_once MYBB_ROOT."inc/db_".$config['database']['type'].".php";

		if(isset($config))
{
require_once MYBB_ROOT."inc/db_".$config['database']['type'].".php";

Zeile 180Zeile 191
				default:
$db = new DB_MySQL;
}

				default:
$db = new DB_MySQL;
}

			





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

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

Zeile 190Zeile 201

// Cache object deconstructed? reconstruct
if(!is_object($cache))


// Cache object deconstructed? reconstruct
if(!is_object($cache))

	{

	{

		require_once MYBB_ROOT."inc/class_datacache.php";
$cache = new datacache;
$cache->cache();

		require_once MYBB_ROOT."inc/class_datacache.php";
$cache = new datacache;
$cache->cache();

Zeile 216Zeile 227

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

	{

	{

		foreach($shutdown_functions as $function)
{
call_user_func_array($function['function'], $function['arguments']);

		foreach($shutdown_functions as $function)
{
call_user_func_array($function['function'], $function['arguments']);

Zeile 225Zeile 236

$done_shutdown = true;
}


$done_shutdown = true;
}





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

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

Zeile 251Zeile 262
		{
// Delete the message from the queue
$db->delete_query("mailqueue", "mid='{$email['mid']}'");

		{
// Delete the message from the queue
$db->delete_query("mailqueue", "mid='{$email['mid']}'");

			



			if($db->affected_rows() == 1)
{

			if($db->affected_rows() == 1)
{

				my_mail($email['mailto'], $email['subject'], $email['message'], $email['mailfrom'], "", $email['headers']);

				my_mail($email['mailto'], $email['subject'], $email['message'], $email['mailfrom'], "", $email['headers'], true);

			}
}
// Update the mailqueue cache and remove the lock

			}
}
// Update the mailqueue cache and remove the lock

Zeile 285Zeile 296
	{
$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);


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


if($lang->settings['rtl'] == 1)
{


if($lang->settings['rtl'] == 1)
{

Zeile 302Zeile 313
	{
$contents = str_replace("<body>", "<body>\n".$error_handler->show_warnings(), $contents);
}

	{
$contents = str_replace("<body>", "<body>\n".$error_handler->show_warnings(), $contents);
}

	



	return $contents;
}


	return $contents;
}


Zeile 342Zeile 353
		{
$offset = $mybb->settings['timezoneoffset'];
$dstcorrection = $mybb->settings['dstcorrection'];

		{
$offset = $mybb->settings['timezoneoffset'];
$dstcorrection = $mybb->settings['dstcorrection'];

		}

		}


// If DST correction is enabled, add an additional hour to the timezone.
if($dstcorrection == 1)


// If DST correction is enabled, add an additional hour to the timezone.
if($dstcorrection == 1)

Zeile 353Zeile 364
				$offset = "+".$offset;
}
}

				$offset = "+".$offset;
}
}

	}

	}


if($offset == "-")


if($offset == "-")

	{

	{

		$offset = 0;

		$offset = 0;

	}


	}


	if($adodb == true && function_exists('adodb_date'))
{
$date = adodb_date($format, $stamp + ($offset * 3600));
}
else

	if($adodb == true && function_exists('adodb_date'))
{
$date = adodb_date($format, $stamp + ($offset * 3600));
}
else

	{

	{

		$date = gmdate($format, $stamp + ($offset * 3600));
}

		$date = gmdate($format, $stamp + ($offset * 3600));
}

	



	if($mybb->settings['dateformat'] == $format && $ty)
{
$stamp = TIME_NOW;

	if($mybb->settings['dateformat'] == $format && $ty)
{
$stamp = TIME_NOW;

		



		if($adodb == true && function_exists('adodb_date'))
{
$todaysdate = adodb_date($format, $stamp + ($offset * 3600));
$yesterdaysdate = adodb_date($format, ($stamp - 86400) + ($offset * 3600));

		if($adodb == true && function_exists('adodb_date'))
{
$todaysdate = adodb_date($format, $stamp + ($offset * 3600));
$yesterdaysdate = adodb_date($format, ($stamp - 86400) + ($offset * 3600));

		}

		}

		else

		else

		{

		{

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

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

		}

		}


if($todaysdate == $date)
{
$date = $lang->today;
}
else if($yesterdaysdate == $date)


if($todaysdate == $date)
{
$date = $lang->today;
}
else if($yesterdaysdate == $date)

		{

		{

			$date = $lang->yesterday;
}

			$date = $lang->yesterday;
}

	}


	}


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

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





	return $date;

	return $date;

}


}


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

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

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

{
global $mybb;
static $mail;

	



	// Does our object not exist? Create it
if(!is_object($mail))
{
require_once MYBB_ROOT."inc/class_mailhandler.php";

	// Does our object not exist? Create it
if(!is_object($mail))
{
require_once MYBB_ROOT."inc/class_mailhandler.php";

		



		if($mybb->settings['mail_handler'] == 'smtp')
{
require_once MYBB_ROOT."inc/mailhandlers/smtp.php";

		if($mybb->settings['mail_handler'] == 'smtp')
{
require_once MYBB_ROOT."inc/mailhandlers/smtp.php";

Zeile 436Zeile 447
			$mail = new PhpMail();
}
}

			$mail = new PhpMail();
}
}

	



	// Using SMTP based mail
if($mybb->settings['mail_handler'] == 'smtp')
{

	// Using SMTP based mail
if($mybb->settings['mail_handler'] == 'smtp')
{

Zeile 445Zeile 456
			$mail->keep_alive = true;
}
}

			$mail->keep_alive = true;
}
}

	



	// Using PHP based mail()
else
{

	// Using PHP based mail()
else
{

Zeile 453Zeile 464
		{
$mail->additional_parameters = $mybb->settings['mail_parameters'];
}

		{
$mail->additional_parameters = $mybb->settings['mail_parameters'];
}

	}


	}


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

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

Zeile 467Zeile 478
 */
function generate_post_check()
{

 */
function generate_post_check()
{

	global $mybb;

	global $mybb, $session;

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

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

	{

	{

		return md5($mybb->user['loginkey'].$mybb->user['salt'].$mybb->user['regdate']);

		return md5($mybb->user['loginkey'].$mybb->user['salt'].$mybb->user['regdate']);

	}

	}

	// Guests get a special string

	// Guests get a special string

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


	else
{
return md5($session->useragent.$mybb->config['database']['username'].$mybb->settings['internal']['encryption_key']);
}
}


/**
* Verifies a POST check code is valid, if not shows an error (silently returns false on silent parameter)
*

/**
* Verifies a POST check code is valid, if not shows an error (silently returns false on silent parameter)
*

Zeile 577Zeile 588
function cache_forums($force=false)
{
global $forum_cache, $cache;

function cache_forums($force=false)
{
global $forum_cache, $cache;

	



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

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

Zeile 601Zeile 612
 *
* @param int The forum ID
* @param return Array of descendants

 *
* @param int The forum ID
* @param return Array of descendants

 */

 */

function get_child_list($fid)
{
static $forums_by_parent;

function get_child_list($fid)
{
static $forums_by_parent;

Zeile 622Zeile 633
	{
return;
}

	{
return;
}

	



	foreach($forums_by_parent[$fid] as $forum)
{
$forums[] = $forum['fid'];

	foreach($forums_by_parent[$fid] as $forum)
{
$forums[] = $forum['fid'];

Zeile 671Zeile 682

eval("\$errorpage = \"".$templates->get("error")."\";");
output_page($errorpage);


eval("\$errorpage = \"".$templates->get("error")."\";");
output_page($errorpage);





	exit;
}


	exit;
}


Zeile 683Zeile 694
 * @return string The inline error HTML
*/
function inline_error($errors, $title="")

 * @return string The inline error HTML
*/
function inline_error($errors, $title="")

{

{

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

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





	if(!$title)

	if(!$title)

	{

	{

		$title = $lang->please_correct_errors;

		$title = $lang->please_correct_errors;

	}

	}


if(!is_array($errors))
{
$errors = array($errors);


if(!is_array($errors))
{
$errors = array($errors);

	}


	}


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

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

Zeile 707Zeile 718
	}

foreach($errors as $error)

	}

foreach($errors as $error)

	{

	{

		$errorlist .= "<li>".$error."</li>\n";
}


		$errorlist .= "<li>".$error."</li>\n";
}


Zeile 732Zeile 743
		"location2" => 0
);


		"location2" => 0
);


	$db->update_query("sessions", $noperm_array, "sid='{$session->sid}'", 1);


	$db->update_query("sessions", $noperm_array, "sid='{$session->sid}'", 1);


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

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

Zeile 743Zeile 754
	}

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

	}

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

	{

	{

		$lang->error_nopermission_user_username = $lang->sprintf($lang->error_nopermission_user_username, $mybb->user['username']);
eval("\$errorpage = \"".$templates->get("error_nopermission_loggedin")."\";");
}

		$lang->error_nopermission_user_username = $lang->sprintf($lang->error_nopermission_user_username, $mybb->user['username']);
eval("\$errorpage = \"".$templates->get("error_nopermission_loggedin")."\";");
}

Zeile 755Zeile 766
		{
$redirect_url .= '?'.$_SERVER['QUERY_STRING'];
}

		{
$redirect_url .= '?'.$_SERVER['QUERY_STRING'];
}





		$redirect_url = htmlspecialchars_uni($redirect_url);

		$redirect_url = htmlspecialchars_uni($redirect_url);

		



		switch($mybb->settings['username_method'])
{
case 0:
$lang_username = $lang->username;

		switch($mybb->settings['username_method'])
{
case 0:
$lang_username = $lang->username;

				break;

				break;

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

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

				break;

				break;

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

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

Zeile 790Zeile 801
	global $header, $footer, $mybb, $theme, $headerinclude, $templates, $lang, $plugins;

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

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

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

	



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

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

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

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

Zeile 817Zeile 828

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


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





	if(!$title)
{
$title = $mybb->settings['bbname'];
}

	if(!$title)
{
$title = $mybb->settings['bbname'];
}

	



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

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

Zeile 838Zeile 849
		$url = str_replace(array("\n","\r",";"), "", $url);

run_shutdown();

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

run_shutdown();

		



		if(my_substr($url, 0, 7) !== 'http://' && my_substr($url, 0, 8) !== 'https://' && my_substr($url, 0, 1) !== '/')
{
header("Location: {$mybb->settings['bburl']}/{$url}");

		if(my_substr($url, 0, 7) !== 'http://' && my_substr($url, 0, 8) !== 'https://' && my_substr($url, 0, 1) !== '/')
{
header("Location: {$mybb->settings['bburl']}/{$url}");

Zeile 866Zeile 877
	global $theme, $templates, $lang, $mybb;

if($count <= $perpage)

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

if($count <= $perpage)

	{

	{

		return;
}

		return;
}

	



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


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


Zeile 967Zeile 978
	}

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

	}

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

	



	if($breadcrumb == true)

	if($breadcrumb == true)

	{

	{

		eval("\$multipage = \"".$templates->get("multipage_breadcrumb")."\";");

		eval("\$multipage = \"".$templates->get("multipage_breadcrumb")."\";");

	}

	}

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

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





	return $multipage;

	return $multipage;

}


}


/**
* Generate a page URL for use by the multipage function
*

/**
* Generate a page URL for use by the multipage function
*

Zeile 989Zeile 1000
function fetch_page_url($url, $page)
{
if($page <= 1)

function fetch_page_url($url, $page)
{
if($page <= 1)

 	{

	{

		$find = array(
"-page-{page}",
"&amp;page={page}",

		$find = array(
"-page-{page}",
"&amp;page={page}",

Zeile 1037Zeile 1048
	{
$uid = $mybb->user['uid'];
}

	{
$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 1059Zeile 1070

// Store group permissions in user cache.
$user_cache[$uid]['permissions'] = $groupperms;


// Store group permissions in user cache.
$user_cache[$uid]['permissions'] = $groupperms;

		return $groupperms;
}

		return $groupperms;
}

	// This user is the current user, return their permissions
else
{

	// This user is the current user, return their permissions
else
{

Zeile 1078Zeile 1089
{
global $cache, $groupscache, $grouppermignore, $groupzerogreater;


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


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

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


if(count($groups) == 1)

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

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


if(count($groups) == 1)

	{
return $groupscache[$gid];
}

	{
return $groupscache[$gid];
}

Zeile 1096Zeile 1107
		if(trim($gid) == "" || !$groupscache[$gid])
{
continue;

		if(trim($gid) == "" || !$groupscache[$gid])
{
continue;

		}

		}


foreach($groupscache[$gid] as $perm => $access)
{


foreach($groupscache[$gid] as $perm => $access)
{

Zeile 1116Zeile 1127
				{
$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 1157Zeile 1168

/**
* Build the forum permissions for a specific forum, user or group


/**
* Build the forum permissions for a specific forum, user or group

 *

 *

 * @param int The forum ID to build permissions for (0 builds for all forums)
* @param int The user to build the permissions for (0 will select the uid automatically)
* @param int The group of the user to build permissions for (0 will fetch it)

 * @param int The forum ID to build permissions for (0 builds for all forums)
* @param int The user to build the permissions for (0 will select the uid automatically)
* @param int The group of the user to build permissions for (0 will fetch it)

Zeile 1180Zeile 1191
			{
$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);

			}


			}


			$gid = $usercache[$uid]['usergroup'].",".$usercache[$uid]['additionalgroups'];
$groupperms = usergroup_permissions($gid);
}

			$gid = $usercache[$uid]['usergroup'].",".$usercache[$uid]['additionalgroups'];
$groupperms = usergroup_permissions($gid);
}

Zeile 1192Zeile 1203
			if(isset($mybb->user['additionalgroups']))
{
$gid .= ",".$mybb->user['additionalgroups'];

			if(isset($mybb->user['additionalgroups']))
{
$gid .= ",".$mybb->user['additionalgroups'];

			}


			}


			$groupperms = $mybb->usergroup;
}
}

			$groupperms = $mybb->usergroup;
}
}

Zeile 1205Zeile 1216
		if(!$forum_cache)
{
return false;

		if(!$forum_cache)
{
return false;

		}

		}

	}

if(!is_array($fpermcache))

	}

if(!is_array($fpermcache))

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

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

	}


	}


	$current_permissions = array();
$only_view_own_threads = 1;

	$current_permissions = array();
$only_view_own_threads = 1;

	



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

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

			



			// If our permissions arn't inherited we need to figure them out
if(empty($level_permissions))
{

			// If our permissions arn't inherited we need to figure them out
if(empty($level_permissions))
{

Zeile 1278Zeile 1289
							break;
}
}

							break;
}
}

					



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

					// 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)
{
if($access >= $current_permissions[$permission] || ($access == "yes" && $current_permissions[$permission] == "no") || !$current_permissions[$permission])
{
$current_permissions[$permission] = $access;
}

			foreach($level_permissions as $permission => $access)
{
if($access >= $current_permissions[$permission] || ($access == "yes" && $current_permissions[$permission] == "no") || !$current_permissions[$permission])
{
$current_permissions[$permission] = $access;
}

			}

			}





			if(!$level_permissions["canonlyviewownthreads"])

			if($level_permissions["canview"] && !$level_permissions["canonlyviewownthreads"])

			{
$only_view_own_threads = 0;
}

			{
$only_view_own_threads = 0;
}

Zeile 1324Zeile 1335
function check_forum_password($fid, $pid=0)
{
global $mybb, $header, $footer, $headerinclude, $theme, $templates, $lang, $forum_cache;

function check_forum_password($fid, $pid=0)
{
global $mybb, $header, $footer, $headerinclude, $theme, $templates, $lang, $forum_cache;

	



	$showform = true;

	$showform = true;

	



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

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

Zeile 1347Zeile 1358
			{
continue;
}

			{
continue;
}

			



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

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

	



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

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

Zeile 1421Zeile 1432
	{
$uid = $mybb->user['uid'];
}

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

	



	if($uid == 0)
{
return false;

	if($uid == 0)
{
return false;

Zeile 1529Zeile 1540
	{
$uid = $mybb->user['uid'];
}

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

	



	if($uid == 0)

	if($uid == 0)

	{

	{

		return false;
}


		return false;
}


Zeile 1550Zeile 1561
				foreach($modcache as $modusers)
{
if(isset($modusers['users'][$uid]) && $modusers['users'][$uid]['mid'])

				foreach($modcache as $modusers)
{
if(isset($modusers['users'][$uid]) && $modusers['users'][$uid]['mid'])

					{
return true;
}

					{
return true;
}

					elseif(isset($modusers['usergroups'][$user_perms['gid']]))
{
// Moderating usergroup

					elseif(isset($modusers['usergroups'][$user_perms['gid']]))
{
// Moderating usergroup

Zeile 1561Zeile 1572
				}
}
return false;

				}
}
return false;

		}
else
{

		}
else
{

			$modperms = get_moderator_permissions($fid, $uid);

			$modperms = get_moderator_permissions($fid, $uid);

			



			if(!$action && $modperms)
{
return true;

			if(!$action && $modperms)
{
return true;

Zeile 1610Zeile 1621
		$posticons[$posticon['name']] = $posticon;
}
krsort($posticons);

		$posticons[$posticon['name']] = $posticon;
}
krsort($posticons);

	



	foreach($posticons as $dbicon)
{
$dbicon['path'] = htmlspecialchars_uni($dbicon['path']);

	foreach($posticons as $dbicon)
{
$dbicon['path'] = htmlspecialchars_uni($dbicon['path']);

Zeile 1624Zeile 1635
		else
{
$iconlist .= "<label><input type=\"radio\" name=\"icon\" value=\"".$dbicon['iid']."\" /> <img src=\"".$dbicon['path']."\" alt=\"".$dbicon['name']."\" /></label>";

		else
{
$iconlist .= "<label><input type=\"radio\" name=\"icon\" value=\"".$dbicon['iid']."\" /> <img src=\"".$dbicon['path']."\" alt=\"".$dbicon['name']."\" /></label>";

		}


		}


		++$listed;
if($listed == 10)
{

		++$listed;
if($listed == 10)
{

Zeile 1648Zeile 1659
 * @param boolean True if setting a HttpOnly cookie (supported by IE, Opera 9, Konqueror)
*/
function my_setcookie($name, $value="", $expires="", $httponly=false)

 * @param boolean True if setting a HttpOnly cookie (supported by IE, Opera 9, Konqueror)
*/
function my_setcookie($name, $value="", $expires="", $httponly=false)

{

{

	global $mybb;

if(!$mybb->settings['cookiepath'])

	global $mybb;

if(!$mybb->settings['cookiepath'])

Zeile 1667Zeile 1678
	else
{
$expires = TIME_NOW + intval($expires);

	else
{
$expires = TIME_NOW + intval($expires);

	}

	}


$mybb->settings['cookiepath'] = str_replace(array("\n","\r"), "", $mybb->settings['cookiepath']);
$mybb->settings['cookiedomain'] = str_replace(array("\n","\r"), "", $mybb->settings['cookiedomain']);


$mybb->settings['cookiepath'] = str_replace(array("\n","\r"), "", $mybb->settings['cookiepath']);
$mybb->settings['cookiedomain'] = str_replace(array("\n","\r"), "", $mybb->settings['cookiedomain']);

Zeile 1684Zeile 1695
	if(!empty($mybb->settings['cookiepath']))
{
$cookie .= "; path={$mybb->settings['cookiepath']}";

	if(!empty($mybb->settings['cookiepath']))
{
$cookie .= "; path={$mybb->settings['cookiepath']}";

	}


	}


	if(!empty($mybb->settings['cookiedomain']))

	if(!empty($mybb->settings['cookiedomain']))

	{

	{

		$cookie .= "; domain={$mybb->settings['cookiedomain']}";

		$cookie .= "; domain={$mybb->settings['cookiedomain']}";

	}


	}


	if($httponly == true)
{
$cookie .= "; HttpOnly";
}

	if($httponly == true)
{
$cookie .= "; HttpOnly";
}

	



	$mybb->cookies[$name] = $value;

header($cookie, false);

	$mybb->cookies[$name] = $value;

header($cookie, false);

Zeile 1703Zeile 1714

/**
* Unset a cookie set by MyBB.


/**
* Unset a cookie set by MyBB.

 *
* @param string The cookie identifier.
*/

 *
* @param string The cookie identifier.
*/

function my_unsetcookie($name)
{
global $mybb;

function my_unsetcookie($name)
{
global $mybb;

	



	$expires = -3600;
my_setcookie($name, "", $expires);

	$expires = -3600;
my_setcookie($name, "", $expires);

	



	unset($mybb->cookies[$name]);
}


	unset($mybb->cookies[$name]);
}


Zeile 1726Zeile 1737
function my_get_array_cookie($name, $id)
{
global $mybb;

function my_get_array_cookie($name, $id)
{
global $mybb;

	



	if(!isset($mybb->cookies['mybb'][$name]))
{
return false;

	if(!isset($mybb->cookies['mybb'][$name]))
{
return false;

Zeile 1754Zeile 1765
function my_set_array_cookie($name, $id, $value, $expires="")
{
global $mybb;

function my_set_array_cookie($name, $id, $value, $expires="")
{
global $mybb;

	



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

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





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

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





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

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

}

/**

}

/**

 * Verifies that data passed is an array
*
* @param array Data to unserialize

 * Verifies that data passed is an array
*
* @param array Data to unserialize

Zeile 1777Zeile 1788
	$array = unserialize($data);

if(!is_array($array))

	$array = unserialize($data);

if(!is_array($array))

	{

	{

		$array = array();
}

return $array;

		$array = array();
}

return $array;

} 

}


/**
* Returns the serverload of the system.


/**
* Returns the serverload of the system.

Zeile 1812Zeile 1823
		if(!is_numeric($serverload[0]))
{
if(@ini_get('safe_mode') == 'On')

		if(!is_numeric($serverload[0]))
{
if(@ini_get('safe_mode') == 'On')

			{

			{

				return $lang->unknown;
}

				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'))
{

			// Suhosin likes to throw a warning if exec is disabled then die - weird
if($func_blacklist = @ini_get('suhosin.executor.func.blacklist'))
{

Zeile 1845Zeile 1856
	else
{
return $lang->unknown;

	else
{
return $lang->unknown;

	}


	}


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

return $returnload;

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

return $returnload;

Zeile 1864Zeile 1875
		return memory_get_peak_usage(true);
}
elseif(function_exists('memory_get_usage'))

		return memory_get_peak_usage(true);
}
elseif(function_exists('memory_get_usage'))

	{

	{

		return memory_get_usage(true);
}
return false;

		return memory_get_usage(true);
}
return false;

Zeile 1891Zeile 1902
			if(substr($changes[$counter], 0, 1) == "+" || substr($changes[$counter], 0, 1) == "-")
{
if(intval($changes[$counter]) != 0)

			if(substr($changes[$counter], 0, 1) == "+" || substr($changes[$counter], 0, 1) == "-")
{
if(intval($changes[$counter]) != 0)

                {

				{

					$new_stats[$counter] = $stats[$counter] + $changes[$counter];
}
}

					$new_stats[$counter] = $stats[$counter] + $changes[$counter];
}
}

Zeile 1909Zeile 1920

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


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

	{
$query = $db->simple_select("users", "uid, username", "", array('order_by' => 'uid', 'order_dir' => 'DESC', 'limit' => 1));

	{
$query = $db->simple_select("users", "uid, username", "", array('order_by' => 'regdate', 'order_dir' => 'DESC', 'limit' => 1));

		$lastmember = $db->fetch_array($query);
$new_stats['lastuid'] = $lastmember['uid'];
$new_stats['lastusername'] = $lastmember['username'];

		$lastmember = $db->fetch_array($query);
$new_stats['lastuid'] = $lastmember['uid'];
$new_stats['lastusername'] = $lastmember['username'];

	}


	}


	if(empty($new_stats))
{
return;
}

	if(empty($new_stats))
{
return;
}

	



	if(is_array($stats))
{
$stats = array_merge($stats, $new_stats);

	if(is_array($stats))
{
$stats = array_merge($stats, $new_stats);

Zeile 1973Zeile 1984
			{
$update_query[$counter] = $changes[$counter];
}

			{
$update_query[$counter] = $changes[$counter];
}

			



			// Less than 0? That's bad
if(!$update_query[$counter])
{
$update_query[$counter] = 0;

			// Less than 0? That's bad
if(!$update_query[$counter])
{
$update_query[$counter] = 0;

			}
}
}

			}
}
}


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


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





	// Guess we should update the statistics too?
if(isset($update_query['threads']) || isset($update_query['posts']) || isset($update_query['unapprovedthreads']) || isset($update_query['unapprovedposts']))
{
$new_stats = array();
if(array_key_exists('threads', $update_query))

	// Guess we should update the statistics too?
if(isset($update_query['threads']) || isset($update_query['posts']) || isset($update_query['unapprovedthreads']) || isset($update_query['unapprovedposts']))
{
$new_stats = array();
if(array_key_exists('threads', $update_query))

		{

		{

			$threads_diff = $update_query['threads'] - $forum['threads'];
if($threads_diff > -1)
{

			$threads_diff = $update_query['threads'] - $forum['threads'];
if($threads_diff > -1)
{

				$new_stats['numthreads'] = "+{$threads_diff}";			

				$new_stats['numthreads'] = "+{$threads_diff}";

			}
else
{
$new_stats['numthreads'] = "{$threads_diff}";
}
}

			}
else
{
$new_stats['numthreads'] = "{$threads_diff}";
}
}

		



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

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

			{

			{

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

				$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(array_key_exists('posts', $update_query))
{
$posts_diff = $update_query['posts'] - $forum['posts'];

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

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

		



		if(array_key_exists('unapprovedposts', $update_query))
{
$unapprovedposts_diff = $update_query['unapprovedposts'] - $forum['unapprovedposts'];

		if(array_key_exists('unapprovedposts', $update_query))
{
$unapprovedposts_diff = $update_query['unapprovedposts'] - $forum['unapprovedposts'];

Zeile 2048Zeile 2059

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


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

	



	$cache->update_forums();
}

	$cache->update_forums();
}





/**
* Update the last post information for a specific forum
*
* @param int The forum ID
*/
function update_forum_lastpost($fid)

/**
* Update the last post information for a specific forum
*
* @param int The forum ID
*/
function update_forum_lastpost($fid)

{
global $db;


{
global $db;


	// Fetch the last post for this forum
$query = $db->query("
SELECT tid, lastpost, lastposter, lastposteruid, subject

	// Fetch the last post for this forum
$query = $db->query("
SELECT tid, lastpost, lastposter, lastposteruid, subject

Zeile 2084Zeile 2095

/**
* Updates the thread counters with a specific value (or addition/subtraction of the previous value)


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

 * @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();

	$update_query = array();

	



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

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

	



	// Fetch above counters for this thread
$query = $db->simple_select("threads", implode(",", $counters), "tid='{$tid}'");
$thread = $db->fetch_array($query);

	// Fetch above counters for this thread
$query = $db->simple_select("threads", implode(",", $counters), "tid='{$tid}'");
$thread = $db->fetch_array($query);

	



	foreach($counters as $counter)
{
if(array_key_exists($counter, $changes))

	foreach($counters as $counter)
{
if(array_key_exists($counter, $changes))

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

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

			{

			{

				$update_query[$counter] = $changes[$counter];

				$update_query[$counter] = $changes[$counter];

			}


			}


			// Less than 0? That's bad
if($update_query[$counter] < 0)
{

			// Less than 0? That's bad
if($update_query[$counter] < 0)
{

Zeile 2121Zeile 2132
			}
}
}

			}
}
}

	



	$db->free_result($query);

// Only update if we're actually doing something

	$db->free_result($query);

// Only update if we're actually doing something

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

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

	



	unset($update_query, $thread);

update_thread_data($tid);

	unset($update_query, $thread);

update_thread_data($tid);

Zeile 2148Zeile 2159

// If this is a moved thread marker, don't update it - we need it to stay as it is
if(strpos($thread['closed'], 'moved|') !== false)


// If this is a moved thread marker, don't update it - we need it to stay as it is
if(strpos($thread['closed'], 'moved|') !== false)

	{

	{

		return false;
}


		return false;
}


Zeile 2161Zeile 2172
		LIMIT 1"
);
$lastpost = $db->fetch_array($query);

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

	



	$db->free_result($query);

	$db->free_result($query);

	



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

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

Zeile 2173Zeile 2184
		LIMIT 1
");
$firstpost = $db->fetch_array($query);

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

	
$db->free_result($query);


$db->free_result($query);


if(!$firstpost['username'])


if(!$firstpost['username'])

	{

	{

		$firstpost['username'] = $firstpost['postusername'];

		$firstpost['username'] = $firstpost['postusername'];

	}


	}


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

if(!$lastpost['dateline'])

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

if(!$lastpost['dateline'])

	{

	{

		$lastpost['username'] = $firstpost['username'];
$lastpost['uid'] = $firstpost['uid'];
$lastpost['dateline'] = $firstpost['dateline'];

		$lastpost['username'] = $firstpost['username'];
$lastpost['uid'] = $firstpost['uid'];
$lastpost['dateline'] = $firstpost['dateline'];

Zeile 2205Zeile 2216
		'lastposteruid' => intval($lastpost['uid']),
);
$db->update_query("threads", $update_array, "tid='{$tid}'");

		'lastposteruid' => intval($lastpost['uid']),
);
$db->update_query("threads", $update_array, "tid='{$tid}'");

	



	unset($firstpost, $lastpost, $update_array);
}

function update_forum_count($fid)
{
die("Deprecated function call: update_forum_count");

	unset($firstpost, $lastpost, $update_array);
}

function update_forum_count($fid)
{
die("Deprecated function call: update_forum_count");

}

}

function update_thread_count($tid)

function update_thread_count($tid)

{

{

	die("Deprecated function call: update_thread_count");
}
function update_thread_attachment_count($tid)

	die("Deprecated function call: update_thread_count");
}
function update_thread_attachment_count($tid)

Zeile 2224Zeile 2235

/**
* Deletes a thread from the database


/**
* Deletes a thread from the database

 *

 *

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

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

Zeile 2236Zeile 2247
		require_once MYBB_ROOT."inc/class_moderation.php";
$moderation = new Moderation;
}

		require_once MYBB_ROOT."inc/class_moderation.php";
$moderation = new Moderation;
}





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


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


Zeile 2248Zeile 2259
function delete_post($pid, $tid="")
{
global $moderation;

function delete_post($pid, $tid="")
{
global $moderation;





	if(!is_object($moderation))
{
require_once MYBB_ROOT."inc/class_moderation.php";

	if(!is_object($moderation))
{
require_once MYBB_ROOT."inc/class_moderation.php";

Zeile 2284Zeile 2295
	}

if(!is_array($jumpfcache))

	}

if(!is_array($jumpfcache))

	{

	{

		if(!is_array($forum_cache))

		if(!is_array($forum_cache))

		{

		{

			cache_forums();

			cache_forums();

		}

		}


foreach($forum_cache as $fid => $forum)
{
if($forum['active'] != 0)
{
$jumpfcache[$forum['pid']][$forum['disporder']][$forum['fid']] = $forum;


foreach($forum_cache as $fid => $forum)
{
if($forum['active'] != 0)
{
$jumpfcache[$forum['pid']][$forum['disporder']][$forum['fid']] = $forum;

			}
}

			}
}

	}

if(!is_array($permissioncache))

	}

if(!is_array($permissioncache))

Zeile 2320Zeile 2331
					{
$optionselected = "selected=\"selected\"";
$selecteddone = 1;

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

					}


					}


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

eval("\$forumjumpbits .= \"".$templates->get("forumjump_bit")."\";");

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

eval("\$forumjumpbits .= \"".$templates->get("forumjump_bit")."\";");

Zeile 2343Zeile 2354
			if(!$selitem)
{
$selitem = "default";

			if(!$selitem)
{
$selitem = "default";

			}


			}


			$jumpsel[$selitem] = 'selected="selected"';
}


			$jumpsel[$selitem] = 'selected="selected"';
}


Zeile 2401Zeile 2412
	}

return $str;

	}

return $str;

}

}


/**
* Formats a username based on their display group


/**
* Formats a username based on their display group

Zeile 2437Zeile 2448
	$format = stripslashes($format);

return str_replace("{username}", $username, $format);

	$format = stripslashes($format);

return str_replace("{username}", $username, $format);

}

/**

}

/**

 * Build the javascript based MyCode inserter
*
* @return string The MyCode inserter

 * Build the javascript based MyCode inserter
*
* @return string The MyCode inserter

Zeile 2492Zeile 2503
			"editor_color"
);
$editor_language = "var editor_language = {\n";

			"editor_color"
);
$editor_language = "var editor_language = {\n";

		



		$editor_lang_strings = $plugins->run_hooks("mycode_add_codebuttons", $editor_lang_strings);

foreach($editor_lang_strings as $key => $lang_string)

		$editor_lang_strings = $plugins->run_hooks("mycode_add_codebuttons", $editor_lang_strings);

foreach($editor_lang_strings as $key => $lang_string)

Zeile 2536Zeile 2547
	global $cache, $smiliecache, $theme, $templates, $lang, $mybb, $smiliecount;

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

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

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

	{

	{

		if(!$smiliecount)

		if(!$smiliecount)

		{

		{

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

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

Zeile 2548Zeile 2559
			if(!is_array($smilie_cache))
{
$smilie_cache = $cache->read("smilies");

			if(!is_array($smilie_cache))
{
$smilie_cache = $cache->read("smilies");

			}

			}

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

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

Zeile 2584Zeile 2595
				if($i < $mybb->settings['smilieinsertertot'])
{
if($counter == 0)

				if($i < $mybb->settings['smilieinsertertot'])
{
if($counter == 0)

					{

					{

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


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


Zeile 2608Zeile 2619
			}

eval("\$clickablesmilies = \"".$templates->get("smilieinsert")."\";");

			}

eval("\$clickablesmilies = \"".$templates->get("smilieinsert")."\";");

		}

		}

		else
{
$clickablesmilies = "";

		else
{
$clickablesmilies = "";

Zeile 2624Zeile 2635

/**
* Builds thread prefixes and returns a selected prefix (or all)


/**
* Builds thread prefixes and returns a selected prefix (or all)

 * 

 *

 *  @param int The prefix ID (0 to return all)
* @return array The thread prefix's values (or all thread prefixes)
*/

 *  @param int The prefix ID (0 to return all)
* @return array The thread prefix's values (or all thread prefixes)
*/

Zeile 2632Zeile 2643
{
global $cache;
static $prefixes_cache;

{
global $cache;
static $prefixes_cache;





	if(is_array($prefixes_cache))
{
if($pid > 0 && is_array($prefixes_cache[$pid]))
{
return $prefixes_cache[$pid];

	if(is_array($prefixes_cache))
{
if($pid > 0 && is_array($prefixes_cache[$pid]))
{
return $prefixes_cache[$pid];

		}

return $prefixes_cache;
}

$prefix_cache = $cache->read("threadprefixes");


		}

return $prefixes_cache;
}

$prefix_cache = $cache->read("threadprefixes");


	if(!is_array($prefix_cache))
{
// No cache

	if(!is_array($prefix_cache))
{
// No cache

Zeile 2676Zeile 2687

/**
* Build the thread prefix selection menu


/**
* Build the thread prefix selection menu

 * 

 *

 *  @param mixed The forum ID (integer ID or string all)
* @param mixed The selected prefix ID (integer ID or string any)
* @return string The thread prefix selection menu

 *  @param mixed The forum ID (integer ID or string all)
* @param mixed The selected prefix ID (integer ID or string any)
* @return string The thread prefix selection menu

Zeile 2684Zeile 2695
function build_prefix_select($fid, $selected_pid=0, $multiple=0)
{
global $cache, $db, $lang, $mybb;

function build_prefix_select($fid, $selected_pid=0, $multiple=0)
{
global $cache, $db, $lang, $mybb;

	



	if($fid != 'all')

	if($fid != 'all')

	{

	{

		$fid = intval($fid);
}


		$fid = intval($fid);
}


Zeile 2694Zeile 2705
	if(!$prefix_cache)
{
return false; // We've got no prefixes to show

	if(!$prefix_cache)
{
return false; // We've got no prefixes to show

	}

	}


$groups = array($mybb->user['usergroup']);
if($mybb->user['additionalgroups'])


$groups = array($mybb->user['usergroup']);
if($mybb->user['additionalgroups'])

Zeile 2706Zeile 2717
			$groups[] = $group;
}
}

			$groups[] = $group;
}
}





	// Go through each of our prefixes and decide which ones we can use
$prefixes = array();
foreach($prefix_cache as $prefix)

	// Go through each of our prefixes and decide which ones we can use
$prefixes = array();
foreach($prefix_cache as $prefix)

Zeile 2730Zeile 2741
			foreach($groups as $group)
{
if(in_array($group, $prefix_groups) && !isset($prefixes[$prefix['pid']]))

			foreach($groups as $group)
{
if(in_array($group, $prefix_groups) && !isset($prefixes[$prefix['pid']]))

				{

				{

					// Our group can use this prefix!
$prefixes[$prefix['pid']] = $prefix;
}

					// Our group can use this prefix!
$prefixes[$prefix['pid']] = $prefix;
}

Zeile 2740Zeile 2751
		{
// This prefix is for anybody to use...
$prefixes[$prefix['pid']] = $prefix;

		{
// This prefix is for anybody to use...
$prefixes[$prefix['pid']] = $prefix;

		}
}


		}
}


	if(empty($prefixes))

	if(empty($prefixes))

	{

	{

		return false;
}


		return false;
}


Zeile 2753Zeile 2764
	if($multiple != 0)
{
$multipleselect = " multiple=\"multiple\" size=\"5\"";

	if($multiple != 0)
{
$multipleselect = " multiple=\"multiple\" size=\"5\"";

	}

$prefixselect = "<select name=\"threadprefix\"{$multipleselect}>\n";

	}

$prefixselect = "<select name=\"threadprefix\"{$multipleselect}>\n";


if($multiple == 1)
{


if($multiple == 1)
{

Zeile 2766Zeile 2777
		}

$prefixselect .= "<option value=\"any\"".$any_selected.">".$lang->any_prefix."</option>\n";

		}

$prefixselect .= "<option value=\"any\"".$any_selected.">".$lang->any_prefix."</option>\n";

	}

	}


$default_selected = "";
if((intval($selected_pid) == 0) && $selected_pid != 'any')


$default_selected = "";
if((intval($selected_pid) == 0) && $selected_pid != 'any')

Zeile 2813Zeile 2824
		if(my_strpos(" ".$httpaccept_encoding, "x-gzip"))
{
$encoding = "x-gzip";

		if(my_strpos(" ".$httpaccept_encoding, "x-gzip"))
{
$encoding = "x-gzip";

		}


		}


		if(my_strpos(" ".$httpaccept_encoding, "gzip"))

		if(my_strpos(" ".$httpaccept_encoding, "gzip"))

		{

		{

			$encoding = "gzip";
}

			$encoding = "gzip";
}





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

if(function_exists("gzencode"))

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

if(function_exists("gzencode"))

			{

			{

				$contents = gzencode($contents, $level);
}
else

				$contents = gzencode($contents, $level);
}
else

Zeile 2849Zeile 2860
 *
* @param array The data of the moderator's action.
* @param string The message to enter for the action the moderator performed.

 *
* @param array The data of the moderator's action.
* @param string The message to enter for the action the moderator performed.

 */

 */

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

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

Zeile 2873Zeile 2884
	{
$tid = $data['tid'];
unset($data['tid']);

	{
$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 2909Zeile 2920
	$display_reputation = '';

if($uid != 0)

	$display_reputation = '';

if($uid != 0)

	{

	{

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

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

	}


	}


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

if($reputation < 0)

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

if($reputation < 0)

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

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

	{

	{

		$display_reputation .= "reputation_positive";
}
else

		$display_reputation .= "reputation_positive";
}
else

Zeile 2968Zeile 2979
 * Fetch the IP address of the current user.
*
* @return string The IP address.

 * Fetch the IP address of the current user.
*
* @return string The IP address.

 */

 */

function get_ip()
{

function get_ip()
{

    global $mybb, $plugins;

$ip = 0;

	global $mybb, $plugins;







    if(!preg_match("#^(10|172\.16|192\.168)\.#", $_SERVER['REMOTE_ADDR']))
{
$ip = $_SERVER['REMOTE_ADDR'];
}



	$ip = 0;

if(!preg_match("#^(10|172\.16|192\.168)\.#", $_SERVER['REMOTE_ADDR']))
{
$ip = $_SERVER['REMOTE_ADDR'];
}





    if($mybb->settings['ip_forwarded_check'])
{
if(isset($_SERVER['HTTP_X_FORWARDED_FOR']))
{
preg_match_all("#[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}#s", $_SERVER['HTTP_X_FORWARDED_FOR'], $addresses);
}
elseif(isset($_SERVER['HTTP_X_REAL_IP']))
{
preg_match_all("#[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}#s", $_SERVER['HTTP_X_REAL_IP'], $addresses);
}

	if($mybb->settings['ip_forwarded_check'])
{
if(isset($_SERVER['HTTP_X_FORWARDED_FOR']))
{
preg_match_all("#[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}#s", $_SERVER['HTTP_X_FORWARDED_FOR'], $addresses);
}
elseif(isset($_SERVER['HTTP_X_REAL_IP']))
{
preg_match_all("#[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}#s", $_SERVER['HTTP_X_REAL_IP'], $addresses);
}


if(is_array($addresses[0]))
{


if(is_array($addresses[0]))
{

Zeile 3002Zeile 3013
				}
}
}

				}
}
}

    }

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

	}













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









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

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





    return $ip;

	return $ip;

}

/**

}

/**

Zeile 3030Zeile 3041
function get_friendly_size($size)
{
global $lang;

function get_friendly_size($size)
{
global $lang;

	



	if(!is_numeric($size))
{
return $lang->na;
}

	if(!is_numeric($size))
{
return $lang->na;
}

	



	// Yottabyte (1024 Zettabytes)
if($size >= 1208925819614629174706176)
{

	// Yottabyte (1024 Zettabytes)
if($size >= 1208925819614629174706176)
{

Zeile 3048Zeile 3059
	}
// Exabyte (1024 Petabytes)
elseif($size >= 1152921504606846976)

	}
// Exabyte (1024 Petabytes)
elseif($size >= 1152921504606846976)

	{

	{

		$size = my_number_format(round(($size / 1152921504606846976), 2))." ".$lang->size_eb;

		$size = my_number_format(round(($size / 1152921504606846976), 2))." ".$lang->size_eb;

	}

	}

	// Petabyte (1024 Terabytes)
elseif($size >= 1125899906842624)

	// Petabyte (1024 Terabytes)
elseif($size >= 1125899906842624)

	{

	{

		$size = my_number_format(round(($size / 1125899906842624), 2))." ".$lang->size_pb;
}
// Terabyte (1024 Gigabytes)
elseif($size >= 1099511627776)
{
$size = my_number_format(round(($size / 1099511627776), 2))." ".$lang->size_tb;

		$size = my_number_format(round(($size / 1125899906842624), 2))." ".$lang->size_pb;
}
// Terabyte (1024 Gigabytes)
elseif($size >= 1099511627776)
{
$size = my_number_format(round(($size / 1099511627776), 2))." ".$lang->size_tb;

	}

	}

	// Gigabyte (1024 Megabytes)
elseif($size >= 1073741824)
{

	// Gigabyte (1024 Megabytes)
elseif($size >= 1073741824)
{

Zeile 3083Zeile 3094
	else
{
$size = my_number_format($size)." ".$lang->size_bytes;

	else
{
$size = my_number_format($size)." ".$lang->size_bytes;

	}


	}


	return $size;
}


	return $size;
}


Zeile 3106Zeile 3117
	$ext = my_strtolower($ext);

if($attachtypes[$ext]['icon'])

	$ext = my_strtolower($ext);

if($attachtypes[$ext]['icon'])

	{
if(defined("IN_ADMINCP"))
{

	{
if(defined("IN_ADMINCP"))
{

			$icon = str_replace("{theme}", "", $attachtypes[$ext]['icon']);
if(my_substr($icon, 0, 1) != "/" && my_substr($icon, 0, 7) != "http://")
{

			$icon = str_replace("{theme}", "", $attachtypes[$ext]['icon']);
if(my_substr($icon, 0, 1) != "/" && my_substr($icon, 0, 7) != "http://")
{

Zeile 3137Zeile 3148
			global $change_dir;
$theme['imgdir'] = "{$change_dir}/images";
}

			global $change_dir;
$theme['imgdir'] = "{$change_dir}/images";
}

		



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

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

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

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

 *

 *

 * @param boolean Set to true to only fetch those forums for which users can actually read a thread in.
* @return string Comma separated values list of the forum IDs which the user cannot view
*/

 * @param boolean Set to true to only fetch those forums for which users can actually read a thread in.
* @return string Comma separated values list of the forum IDs which the user cannot view
*/

Zeile 3155Zeile 3166
	if(!is_array($forum_cache))
{
cache_forums();

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

	}


	}


	if(!is_array($permissioncache))

	if(!is_array($permissioncache))

	{

	{

		$permissioncache = forum_permissions();
}


		$permissioncache = forum_permissions();
}


Zeile 3168Zeile 3179
		if($permissioncache[$forum['fid']])
{
$perms = $permissioncache[$forum['fid']];

		if($permissioncache[$forum['fid']])
{
$perms = $permissioncache[$forum['fid']];

		}

		}

		else
{
$perms = $mybb->usergroup;

		else
{
$perms = $mybb->usergroup;

Zeile 3182Zeile 3193
			{
$pwverified = 0;
}

			{
$pwverified = 0;
}

			



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

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

Zeile 3217Zeile 3228

/**
* Fixes mktime for dates earlier than 1970


/**
* Fixes mktime for dates earlier than 1970

 *

 *

 * @param string The date format to use
* @param int The year of the date
* @return string The correct date format

 * @param string The date format to use
* @param int The year of the date
* @return string The correct date format

Zeile 3240Zeile 3251
function build_breadcrumb()
{
global $nav, $navbits, $templates, $theme, $lang, $mybb;

function build_breadcrumb()
{
global $nav, $navbits, $templates, $theme, $lang, $mybb;





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

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

	



	$i = 0;
$activesep = '';

	$i = 0;
$activesep = '';

	



	if(is_array($navbits))
{
reset($navbits);

	if(is_array($navbits))
{
reset($navbits);

Zeile 3254Zeile 3265
			if(isset($navbits[$key+1]))
{
if(isset($navbits[$key+2]))

			if(isset($navbits[$key+1]))
{
if(isset($navbits[$key+2]))

				{

				{

					$sep = $navsep;

					$sep = $navsep;

				}

				}

				else
{
$sep = "";
}

				else
{
$sep = "";
}

				



				$multipage = null;
$multipage_dropdown = null;
if(!empty($navbit['multipage']))

				$multipage = null;
$multipage_dropdown = null;
if(!empty($navbit['multipage']))

Zeile 3278Zeile 3289
				// Replace page 1 URLs
$navbit['url'] = str_replace("-page-1.html", ".html", $navbit['url']);
$navbit['url'] = preg_replace("/&amp;page=1$/", "", $navbit['url']);

				// Replace page 1 URLs
$navbit['url'] = str_replace("-page-1.html", ".html", $navbit['url']);
$navbit['url'] = preg_replace("/&amp;page=1$/", "", $navbit['url']);





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

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

Zeile 3300Zeile 3311

/**
* Add a breadcrumb menu item to the list.


/**
* Add a breadcrumb menu item to the list.

 *

 *

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

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

Zeile 3312Zeile 3323
	$navbits[$navsize]['name'] = $name;
$navbits[$navsize]['url'] = $url;
}

	$navbits[$navsize]['name'] = $name;
$navbits[$navsize]['url'] = $url;
}





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

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

Zeile 3333Zeile 3344
		foreach($forum_cache as $key => $val)
{
$pforumcache[$val['fid']][$val['pid']] = $val;

		foreach($forum_cache as $key => $val)
{
$pforumcache[$val['fid']][$val['pid']] = $val;

		}
}

		}
}


if(is_array($pforumcache[$fid]))
{


if(is_array($pforumcache[$fid]))
{

Zeile 3343Zeile 3354
			if($fid == $forumnav['fid'])
{
if(!empty($pforumcache[$forumnav['pid']]))

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

				{

				{

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

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





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

if(defined("IN_ARCHIVE"))

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

if(defined("IN_ARCHIVE"))

				{

				{

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

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

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

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

					



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

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

Zeile 3379Zeile 3390
	}

return 1;

	}

return 1;

}

}


/**
* Resets the breadcrumb navigation to the first item, and clears the rest


/**
* Resets the breadcrumb navigation to the first item, and clears the rest

Zeile 3406Zeile 3417
function build_archive_link($type, $id="")
{
global $mybb;

function build_archive_link($type, $id="")
{
global $mybb;

	



	// If the server OS is not Windows and not Apache or the PHP is running as a CGI or we have defined ARCHIVE_QUERY_STRINGS, use query strings - DIRECTORY_SEPARATOR checks if running windows
//if((DIRECTORY_SEPARATOR == '\\' && is_numeric(stripos($_SERVER['SERVER_SOFTWARE'], "apache")) == false) || is_numeric(stripos(SAPI_NAME, "cgi")) !== false || defined("ARCHIVE_QUERY_STRINGS"))
if($mybb->settings['seourls_archive'] == 1)

	// If the server OS is not Windows and not Apache or the PHP is running as a CGI or we have defined ARCHIVE_QUERY_STRINGS, use query strings - DIRECTORY_SEPARATOR checks if running windows
//if((DIRECTORY_SEPARATOR == '\\' && is_numeric(stripos($_SERVER['SERVER_SOFTWARE'], "apache")) == false) || is_numeric(stripos(SAPI_NAME, "cgi")) !== false || defined("ARCHIVE_QUERY_STRINGS"))
if($mybb->settings['seourls_archive'] == 1)

Zeile 3550Zeile 3561
		echo "<br />\n";
}


		echo "<br />\n";
}


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

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

	{
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";

Zeile 3792Zeile 3803
	else
{
$trow = "trow1";

	else
{
$trow = "trow1";

	}

	}


$alttrow = $trow;



$alttrow = $trow;


Zeile 3888Zeile 3899
			}
}
}

			}
}
}

	



	$dispupdate = "";
if($leavegroup == $user['displaygroup'])
{

	$dispupdate = "";
if($leavegroup == $user['displaygroup'])
{

Zeile 3900Zeile 3911
		SET additionalgroups='$groupslist' $dispupdate
WHERE uid='".intval($uid)."'
");

		SET additionalgroups='$groupslist' $dispupdate
WHERE uid='".intval($uid)."'
");

	



	$cache->update_moderators();
}


	$cache->update_moderators();
}


Zeile 3933Zeile 3944
	else
{
$location = htmlspecialchars_uni($_SERVER['PHP_SELF']);

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

	}


	}


	if($fields == true)
{
global $mybb;

	if($fields == true)
{
global $mybb;

		



		if(!is_array($ignore))
{
$ignore = array($ignore);

		if(!is_array($ignore))
{
$ignore = array($ignore);

Zeile 3953Zeile 3964
				{
continue;
}

				{
continue;
}

				



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

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

		



		return array('location' => $location, 'form_html' => $form_html, 'form_method' => $mybb->request_method);
}
else

		return array('location' => $location, 'form_html' => $form_html, 'form_method' => $mybb->request_method);
}
else

Zeile 3970Zeile 3981
		{
$location .= "?".htmlspecialchars_uni($_ENV['QUERY_STRING']);
}

		{
$location .= "?".htmlspecialchars_uni($_ENV['QUERY_STRING']);
}

		



		if((isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] == "POST") || (isset($_ENV['REQUEST_METHOD']) && $_ENV['REQUEST_METHOD'] == "POST"))
{
$post_array = array('action', 'fid', 'pid', 'tid', 'uid', 'eid');

		if((isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] == "POST") || (isset($_ENV['REQUEST_METHOD']) && $_ENV['REQUEST_METHOD'] == "POST"))
{
$post_array = array('action', 'fid', 'pid', 'tid', 'uid', 'eid');

	



			foreach($post_array as $var)
{
if(isset($_POST[$var]))

			foreach($post_array as $var)
{
if(isset($_POST[$var]))

Zeile 3982Zeile 3993
					$addloc[] = urlencode($var).'='.urlencode($_POST[$var]);
}
}

					$addloc[] = urlencode($var).'='.urlencode($_POST[$var]);
}
}

	



			if(isset($addloc) && is_array($addloc))
{
if(strpos($location, "?") === false)

			if(isset($addloc) && is_array($addloc))
{
if(strpos($location, "?") === false)

Zeile 4153Zeile 4164
	static $charset;
static $use_mb;
static $use_iconv;

	static $charset;
static $use_mb;
static $use_iconv;

	



	if(!isset($charset))

	if(!isset($charset))

	{

	{

		$charset = my_strtolower($lang->settings['charset']);

		$charset = my_strtolower($lang->settings['charset']);

	}


	}


	if($charset == "utf-8")
{
return $str;
}

	if($charset == "utf-8")
{
return $str;
}

	



	if(!isset($use_iconv))

	if(!isset($use_iconv))

	{

	{

		$use_iconv = function_exists("iconv");

		$use_iconv = function_exists("iconv");

	}


	}


	if(!isset($use_mb))
{
$use_mb = function_exists("mb_convert_encoding");
}

	if(!isset($use_mb))
{
$use_mb = function_exists("mb_convert_encoding");
}

	



	if($use_iconv || $use_mb)

	if($use_iconv || $use_mb)

	{
if($to)
{

	{
if($to)
{

			$from_charset = $lang->settings['charset'];
$to_charset = "UTF-8";

			$from_charset = $lang->settings['charset'];
$to_charset = "UTF-8";

		}

		}

		else
{
$from_charset = "UTF-8";
$to_charset = $lang->settings['charset'];
}
if($use_iconv)

		else
{
$from_charset = "UTF-8";
$to_charset = $lang->settings['charset'];
}
if($use_iconv)

		{

		{

			return iconv($from_charset, $to_charset."//IGNORE", $str);
}
else

			return iconv($from_charset, $to_charset."//IGNORE", $str);
}
else

Zeile 4207Zeile 4218
		}
}
else

		}
}
else

	{

	{

		return $str;
}
}

		return $str;
}
}

Zeile 4225Zeile 4236
	if($mybb->settings['wordwrap'] > 0)
{
$message = convert_through_utf8($message);

	if($mybb->settings['wordwrap'] > 0)
{
$message = convert_through_utf8($message);

		



		if(!($new_message = @preg_replace("#(((?>[^\s&/<>\"\\-\[\]])|(&\#[a-z0-9]{1,10};)){{$mybb->settings['wordwrap']}})#u", "$0&#8203;", $message)))
{

		if(!($new_message = @preg_replace("#(((?>[^\s&/<>\"\\-\[\]])|(&\#[a-z0-9]{1,10};)){{$mybb->settings['wordwrap']}})#u", "$0&#8203;", $message)))
{

			$new_message = preg_replace("#(((?>[^\s&/<>\"\\-\[\]])|(&\#[a-z0-9]{1,10};)){{$mybb->settings['wordwrap']}})#", "$0&#8203;", $message);	

			$new_message = preg_replace("#(((?>[^\s&/<>\"\\-\[\]])|(&\#[a-z0-9]{1,10};)){{$mybb->settings['wordwrap']}})#", "$0&#8203;", $message);

		}

		}

		



		$new_message = convert_through_utf8($new_message, false);

		$new_message = convert_through_utf8($new_message, false);

		



		return $new_message;
}

		return $new_message;
}





	return $message;

	return $message;

}

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

}

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

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

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

Zeile 4339Zeile 4350
		$lang->month_11,
$lang->month_12
);

		$lang->month_11,
$lang->month_12
);

	




// This needs to be in this specific order
$find = array(


// This needs to be in this specific order
$find = array(

Zeile 4370Zeile 4381

$bdays = str_replace($find, $html, $bdays);
$bmonth = str_replace($find, $html, $bmonth);


$bdays = str_replace($find, $html, $bdays);
$bmonth = str_replace($find, $html, $bmonth);

	



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

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

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

		$wd,
($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)

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

Zeile 4391Zeile 4402
		array_pop($find);
array_pop($replace);
}

		array_pop($find);
array_pop($replace);
}

	



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


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


Zeile 4454Zeile 4465
 */
function my_strlen($string)
{

 */
function my_strlen($string)
{

    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 whitespaces
$string = str_replace(chr(0xCA), "", $string);
}
$string = trim($string);

	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 whitespaces
$string = str_replace(chr(0xCA), "", $string);
}
$string = trim($string);





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

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





    return $string_length;

	return $string_length;

}

/**

}

/**

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

		$string = unhtmlentities($string);
}
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 4537Zeile 4548
	if(function_exists("mb_strtolower"))
{
$string = mb_strtolower($string);

	if(function_exists("mb_strtolower"))
{
$string = mb_strtolower($string);

	}
else
{

	}
else
{

		$string = strtolower($string);
}


		$string = strtolower($string);
}


Zeile 4559Zeile 4570
	if($needle == '')
{
return false;

	if($needle == '')
{
return false;

	}

	}


if(function_exists("mb_strpos"))


if(function_exists("mb_strpos"))

	{

	{

		$position = mb_strpos($haystack, $needle, $offset);

		$position = mb_strpos($haystack, $needle, $offset);

	}

	}

	else
{
$position = strpos($haystack, $needle, $offset);
}

	else
{
$position = strpos($haystack, $needle, $offset);
}





	return $position;
}


	return $position;
}


Zeile 4578Zeile 4589
 *
* @param string The string to up.
* @return int The uped string.

 *
* @param string The string to up.
* @return int The uped string.

 */

 */

function my_strtoupper($string)
{
if(function_exists("mb_strtoupper"))

function my_strtoupper($string)
{
if(function_exists("mb_strtoupper"))

Zeile 4600Zeile 4611
 * @return int The un-htmlentitied' string.
*/
function unhtmlentities($string)

 * @return int The un-htmlentitied' string.
*/
function unhtmlentities($string)

{	

{

	// Replace numeric entities

	// Replace numeric entities

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


	$string = preg_replace_callback('~&#x([0-9a-f]+);~i', create_function('$matches', 'return unichr(hexdec($matches[1]));'), $string);
$string = preg_replace_callback('~&#([0-9]+);~', create_function('$matches', 'return unichr($matches[1]);'), $string);


	// Replace literal entities
$trans_tbl = get_html_translation_table(HTML_ENTITIES);
$trans_tbl = array_flip($trans_tbl);

	// Replace literal entities
$trans_tbl = get_html_translation_table(HTML_ENTITIES);
$trans_tbl = array_flip($trans_tbl);

	



	return strtr($string, $trans_tbl);
}


	return strtr($string, $trans_tbl);
}


Zeile 4620Zeile 4631
 */
function unichr($c)
{

 */
function unichr($c)
{

    if($c <= 0x7F)

	if($c <= 0x7F)

	{

	{

        return chr($c);
}

		return chr($c);
}

	else if($c <= 0x7FF)

	else if($c <= 0x7FF)

	{
return chr(0xC0 | $c >> 6) . chr(0x80 | $c & 0x3F);
}

	{
return chr(0xC0 | $c >> 6) . chr(0x80 | $c & 0x3F);
}

	else if($c <= 0xFFFF)

	else if($c <= 0xFFFF)

	{
return chr(0xE0 | $c >> 12) . chr(0x80 | $c >> 6 & 0x3F)
. chr(0x80 | $c & 0x3F);
}

	{
return chr(0xE0 | $c >> 12) . chr(0x80 | $c >> 6 & 0x3F)
. chr(0x80 | $c & 0x3F);
}

	else if($c <= 0x10FFFF)
{

	else if($c <= 0x10FFFF)
{

        return chr(0xF0 | $c >> 18) . chr(0x80 | $c >> 12 & 0x3F)
. chr(0x80 | $c >> 6 & 0x3F)
. chr(0x80 | $c & 0x3F);
}

		return chr(0xF0 | $c >> 18) . chr(0x80 | $c >> 12 & 0x3F)
. chr(0x80 | $c >> 6 & 0x3F)
. chr(0x80 | $c & 0x3F);
}

	else
{

	else
{

        return false;
}

		return false;
}

}

/**

}

/**

Zeile 4667Zeile 4678
function get_event_date($event)
{
global $mybb;

function get_event_date($event)
{
global $mybb;

	



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

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

Zeile 4734Zeile 4745
		{
$onclick = " onclick=\"{$onclick}\"";
}

		{
$onclick = " onclick=\"{$onclick}\"";
}

		



		return "<a href=\"{$mybb->settings['bburl']}/".get_profile_link($uid)."\"{$target}{$onclick}>{$username}</a>";
}
}

		return "<a href=\"{$mybb->settings['bburl']}/".get_profile_link($uid)."\"{$target}{$onclick}>{$username}</a>";
}
}

Zeile 4782Zeile 4793
		{
$link = THREAD_URL_PAGED;
}

		{
$link = THREAD_URL_PAGED;
}

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

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

		$link = str_replace("{page}", $page, $link);
return htmlspecialchars_uni($link);
}

		$link = str_replace("{page}", $page, $link);
return htmlspecialchars_uni($link);
}

Zeile 4798Zeile 4809
			$link = THREAD_URL;
}
$link = str_replace("{tid}", $tid, $link);

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

		return htmlspecialchars_uni($link);
}
}

		return htmlspecialchars_uni($link);
}
}


/**
* Build the post link.


/**
* Build the post link.

Zeile 4832Zeile 4843
function get_event_link($eid)
{
$link = str_replace("{eid}", $eid, EVENT_URL);

function get_event_link($eid)
{
$link = str_replace("{eid}", $eid, EVENT_URL);

	return htmlspecialchars_uni($link);
}

/**

	return htmlspecialchars_uni($link);
}

/**

 * Build the link to a specified date on the calendar
*
* @param int The ID of the calendar

 * Build the link to a specified date on the calendar
*
* @param int The ID of the calendar

Zeile 4845Zeile 4856
 * @return string The URL of the calendar
*/
function get_calendar_link($calendar, $year=0, $month=0, $day=0)

 * @return string The URL of the calendar
*/
function get_calendar_link($calendar, $year=0, $month=0, $day=0)

{

{

	if($day > 0)
{
$link = str_replace("{month}", $month, CALENDAR_URL_DAY);

	if($day > 0)
{
$link = str_replace("{month}", $month, CALENDAR_URL_DAY);

Zeile 4855Zeile 4866
		return htmlspecialchars_uni($link);
}
else if($month > 0)

		return htmlspecialchars_uni($link);
}
else if($month > 0)

	{

	{

		$link = str_replace("{month}", $month, CALENDAR_URL_MONTH);
$link = str_replace("{year}", $year, $link);

		$link = str_replace("{month}", $month, CALENDAR_URL_MONTH);
$link = str_replace("{year}", $year, $link);

		$link = str_replace("{calendar}", $calendar, $link);

		$link = str_replace("{calendar}", $calendar, $link);

		return htmlspecialchars_uni($link);
}
else if($year > 0)
{
$link = str_replace("{year}", $year, CALENDAR_URL_YEAR);
$link = str_replace("{calendar}", $calendar, $link);

		return htmlspecialchars_uni($link);
}
else if($year > 0)
{
$link = str_replace("{year}", $year, CALENDAR_URL_YEAR);
$link = str_replace("{calendar}", $calendar, $link);

		return htmlspecialchars_uni($link);

		return htmlspecialchars_uni($link);

	}
else
{

	}
else
{

Zeile 4885Zeile 4896
function get_calendar_week_link($calendar, $week)
{
if($week < 0)

function get_calendar_week_link($calendar, $week)
{
if($week < 0)

	{

	{

		$week = str_replace('-', "n", $week);
}
$link = str_replace("{week}", $week, CALENDAR_URL_WEEK);

		$week = str_replace('-', "n", $week);
}
$link = str_replace("{week}", $week, CALENDAR_URL_WEEK);

Zeile 4914Zeile 4925
	{
return $user_cache[$uid];
}

	{
return $user_cache[$uid];
}

	else

	elseif(($uid > 0))

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

return $user_cache[$uid];
}

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

return $user_cache[$uid];
}

 
	return array();

}

/**

}

/**

Zeile 4999Zeile 5011

/**
* Get the post of a post id.


/**
* Get the post of a post id.

 *

 *

 * @param int The post id of the post.
* @return string The database row of the post.
*/

 * @param int The post id of the post.
* @return string The database row of the post.
*/

Zeile 5162Zeile 5174

/**
* Validates the format of an email address.


/**
* Validates the format of an email address.

 *

 *

 * @param string The string to check.
* @return boolean True when valid, false when invalid.
*/

 * @param string The string to check.
* @return boolean True when valid, false when invalid.
*/

Zeile 5186Zeile 5198
function email_already_in_use($email, $uid="")
{
global $db;

function email_already_in_use($email, $uid="")
{
global $db;

	



	$uid_string = "";
if($uid)
{
$uid_string = " AND uid != '".intval($uid)."'";
}
$query = $db->simple_select("users", "COUNT(email) as emails", "email = '".$db->escape_string($email)."'{$uid_string}");

	$uid_string = "";
if($uid)
{
$uid_string = " AND uid != '".intval($uid)."'";
}
$query = $db->simple_select("users", "COUNT(email) as emails", "email = '".$db->escape_string($email)."'{$uid_string}");

	



	if($db->fetch_field($query, "emails") > 0)

	if($db->fetch_field($query, "emails") > 0)

	{

	{

		return true;
}

		return true;
}

	



	return false;
}


	return false;
}


Zeile 5206Zeile 5218
 * DEPRECATED! ONLY INCLUDED FOR COMPATIBILITY PURPOSES.
*/
function rebuildsettings()

 * DEPRECATED! ONLY INCLUDED FOR COMPATIBILITY PURPOSES.
*/
function rebuildsettings()

{

{

	rebuild_settings();
}


	rebuild_settings();
}


Zeile 5217Zeile 5229
function rebuild_settings()
{
global $db, $mybb;

function rebuild_settings()
{
global $db, $mybb;





	if(!file_exists(MYBB_ROOT."inc/settings.php"))
{
$mode = "x";

	if(!file_exists(MYBB_ROOT."inc/settings.php"))
{
$mode = "x";

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

		$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);
@fwrite($file, $settings);
@fclose($file);

	$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);
@fwrite($file, $settings);
@fclose($file);





	$GLOBALS['settings'] = &$mybb->settings;

	$GLOBALS['settings'] = &$mybb->settings;

}

/**

}

/**

 * Build a PREG compatible array of search highlight terms to replace in posts.
*
* @param string Incoming terms to highlight

 * Build a PREG compatible array of search highlight terms to replace in posts.
*
* @param string Incoming terms to highlight

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

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

	} 

	}


if(is_array($terms))
{


if(is_array($terms))
{

Zeile 5334Zeile 5346
	{
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);'));

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

Zeile 5345Zeile 5357
		$word = trim($word);

$word = my_strtolower($word);

		$word = trim($word);

$word = my_strtolower($word);

	



		// Special boolean operators should be stripped
if($word == "" || $word == "or" || $word == "not" || $word == "and")
{

		// Special boolean operators should be stripped
if($word == "" || $word == "or" || $word == "not" || $word == "and")
{

Zeile 5373Zeile 5385

if($src < 0)
{


if($src < 0)
{

  		return false;
}

		return false;
}

	elseif($src <= 0x007f)
{
$dest .= chr($src);

	elseif($src <= 0x007f)
{
$dest .= chr($src);

Zeile 5447Zeile 5459
	global $cache, $db;

$banned_cache = $cache->read("bannedemails");

	global $cache, $db;

$banned_cache = $cache->read("bannedemails");

	



	if($banned_cache === false)
{
// Failed to read cache, see if we can rebuild it
$cache->update_bannedemails();
$banned_cache = $cache->read("bannedemails");

	if($banned_cache === false)
{
// Failed to read cache, see if we can rebuild it
$cache->update_bannedemails();
$banned_cache = $cache->read("bannedemails");

	}


	}


	if(is_array($banned_cache) && !empty($banned_cache))
{
foreach($banned_cache as $banned_email)

	if(is_array($banned_cache) && !empty($banned_cache))
{
foreach($banned_cache as $banned_email)

Zeile 5471Zeile 5483
				}
return true;
}

				}
return true;
}

		}
}


		}
}


	// Still here - good email
return false;
}

	// Still here - good email
return false;
}

Zeile 5488Zeile 5500
function is_banned_ip($ip_address, $update_lastuse=false)
{
global $db, $cache;

function is_banned_ip($ip_address, $update_lastuse=false)
{
global $db, $cache;

	



	$banned_ips = $cache->read("bannedips");
if(!is_array($banned_ips))
{
return false;
}

	$banned_ips = $cache->read("bannedips");
if(!is_array($banned_ips))
{
return false;
}

	



	foreach($banned_ips as $banned_ip)
{
if(!$banned_ip['filter'])
{
continue;
}

	foreach($banned_ips as $banned_ip)
{
if(!$banned_ip['filter'])
{
continue;
}

		



		// Make regular expression * match
$banned_ip['filter'] = str_replace('\*', '(.*)', preg_quote($banned_ip['filter'], '#'));
if(preg_match("#^{$banned_ip['filter']}$#i", $ip_address))

		// Make regular expression * match
$banned_ip['filter'] = str_replace('\*', '(.*)', preg_quote($banned_ip['filter'], '#'));
if(preg_match("#^{$banned_ip['filter']}$#i", $ip_address))

Zeile 5619Zeile 5631
		}
$post_body = ltrim($post_body, '&');
}

		}
$post_body = ltrim($post_body, '&');
}

	



	if(function_exists("curl_init"))
{
$ch = curl_init();

	if(function_exists("curl_init"))
{
$ch = curl_init();

Zeile 5631Zeile 5643
		{
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_body);

		{
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_body);

		}

		}

		$data = curl_exec($ch);
curl_close($ch);
return $data;
}

		$data = curl_exec($ch);
curl_close($ch);
return $data;
}

 	else if(function_exists("fsockopen"))

	else if(function_exists("fsockopen"))

	{
$url = @parse_url($url);
if(!$url['host'])

	{
$url = @parse_url($url);
if(!$url['host'])

Zeile 5644Zeile 5656
			return false;
}
if(!$url['port'])

			return false;
}
if(!$url['port'])

		{

		{

			$url['port'] = 80;
}
if(!$url['path'])

			$url['port'] = 80;
}
if(!$url['path'])

Zeile 5667Zeile 5679
			$headers[] = "POST {$url['path']} HTTP/1.0";
$headers[] = "Content-Length: ".strlen($post_body);
$headers[] = "Content-Type: application/x-www-form-urlencoded";

			$headers[] = "POST {$url['path']} HTTP/1.0";
$headers[] = "Content-Length: ".strlen($post_body);
$headers[] = "Content-Type: application/x-www-form-urlencoded";

		}

		}

		else
{
$headers[] = "GET {$url['path']} HTTP/1.0";
}

		else
{
$headers[] = "GET {$url['path']} HTTP/1.0";
}

		



		$headers[] = "Host: {$url['host']}";
$headers[] = "Connection: Close";
$headers[] = '';

		$headers[] = "Host: {$url['host']}";
$headers[] = "Connection: Close";
$headers[] = '';

		



		if(!empty($post_body))
{
$headers[] = $post_body;

		if(!empty($post_body))
{
$headers[] = $post_body;

Zeile 5686Zeile 5698
			// If we have no post body, we need to add an empty element to make sure we've got \r\n\r\n before the (non-existent) body starts
$headers[] = '';
}

			// If we have no post body, we need to add an empty element to make sure we've got \r\n\r\n before the (non-existent) body starts
$headers[] = '';
}

		
$headers = implode("\r\n", $headers);


$headers = implode("\r\n", $headers);

		if(!@fwrite($fp, $headers))
{
return false;

		if(!@fwrite($fp, $headers))
{
return false;

Zeile 5719Zeile 5731
function is_super_admin($uid)
{
global $mybb;

function is_super_admin($uid)
{
global $mybb;

	



	$mybb->config['super_admins'] = str_replace(" ", "", $mybb->config['super_admins']);
if(my_strpos(",{$mybb->config['super_admins']},", ",{$uid},") === false)
{

	$mybb->config['super_admins'] = str_replace(" ", "", $mybb->config['super_admins']);
if(my_strpos(",{$mybb->config['super_admins']},", ",{$uid},") === false)
{

Zeile 5767Zeile 5779
	}
foreach($quoted_strings as $string)
{

	}
foreach($quoted_strings as $string)
{

		if($string != "") 

		if($string != "")

		{
if($in_escape)
{

		{
if($in_escape)
{

Zeile 5814Zeile 5826
		if(count($ip_bits) == 4)
{
return my_ip2long($ip);

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

		}
else

		}
else

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

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

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

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

			{

			{

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

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

Zeile 5840Zeile 5852
		}
return array(my_ip2long($ip_string1), my_ip2long($ip_string2));
}

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

} 

}


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


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

Zeile 5873Zeile 5885
	);

$ban_times = $plugins->run_hooks("functions_fetch_ban_times", $ban_times);

	);

$ban_times = $plugins->run_hooks("functions_fetch_ban_times", $ban_times);





	$ban_times['---'] = $lang->permanent;
return $ban_times;
}

	$ban_times['---'] = $lang->permanent;
return $ban_times;
}

Zeile 5907Zeile 5919
function expire_warnings()
{
global $db;

function expire_warnings()
{
global $db;

	



	$users = array();

	$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 5922Zeile 5934
			"expired" => 1
);
$db->update_query("warnings", $updated_warning, "wid='{$warning['wid']}'");

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

		



		if(array_key_exists($warning['uid'], $users))

		if(array_key_exists($warning['uid'], $users))

		{

		{

			$users[$warning['uid']] -= $warning['points'];
}
else

			$users[$warning['uid']] -= $warning['points'];
}
else

Zeile 5932Zeile 5944
			$users[$warning['uid']] = $warning['warningpoints']-$warning['points'];
}
}

			$users[$warning['uid']] = $warning['warningpoints']-$warning['points'];
}
}

	



	foreach($users as $uid => $warningpoints)

	foreach($users as $uid => $warningpoints)

	{

	{

		if($warningpoints < 0)
{
$warningpoints = 0;
}

		if($warningpoints < 0)
{
$warningpoints = 0;
}

		



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

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

	}
}


	}
}


/**
* Custom chmod function to fix problems with hosts who's server configurations screw up umasks
*

/**
* Custom chmod function to fix problems with hosts who's server configurations screw up umasks
*

Zeile 5957Zeile 5969
{
// Passing $mode as an octal number causes strlen and substr to return incorrect values. Instead pass as a string
if(substr($mode, 0, 1) != '0' || strlen($mode) !== 4)

{
// Passing $mode as an octal number causes strlen and substr to return incorrect values. Instead pass as a string
if(substr($mode, 0, 1) != '0' || strlen($mode) !== 4)

	{

	{

		return false;
}
$old_umask = umask(0);

		return false;
}
$old_umask = umask(0);

	



	// We convert the octal string to a decimal number because passing a octal string doesn't work with chmod
// and type casting subsequently removes the prepended 0 which is needed for octal numbers
$result = chmod($file, octdec($mode));
umask($old_umask);
return $result;

	// We convert the octal string to a decimal number because passing a octal string doesn't work with chmod
// and type casting subsequently removes the prepended 0 which is needed for octal numbers
$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
*

/**
* Custom rmdir function to loop through an entire directory and delete all files/folders within
*

Zeile 5978Zeile 5990
function my_rmdir_recursive($path, $ignore=array())
{
global $orig_dir;

function my_rmdir_recursive($path, $ignore=array())
{
global $orig_dir;

	



	if(!isset($orig_dir))

	if(!isset($orig_dir))

	{

	{

		$orig_dir = $path;

		$orig_dir = $path;

	}

if(@is_dir($path) && !@is_link($path))
{
if($dh = @opendir($path))
{
while(($file = @readdir($dh)) !== false)
{
if($file == '.' || $file == '..' || $file == '.svn' || in_array($path.'/'.$file, $ignore) || !my_rmdir_recursive($path.'/'.$file))
{
continue;
}
}
@closedir($dh);
}


	}

if(@is_dir($path) && !@is_link($path))
{
if($dh = @opendir($path))
{
while(($file = @readdir($dh)) !== false)
{
if($file == '.' || $file == '..' || $file == '.svn' || in_array($path.'/'.$file, $ignore) || !my_rmdir_recursive($path.'/'.$file))
{
continue;
}
}
@closedir($dh);
}


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

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

		
return @rmdir($path);
}

return @unlink($path);


return @rmdir($path);
}

return @unlink($path);

}

/**

}

/**

Zeile 6023Zeile 6035
	{
$count += count($array2);
}

	{
$count += count($array2);
}

	



	return $count;
}


	return $count;
}


Zeile 6033Zeile 6045
 *
* @param string The IP to convert
* @return integer IP in 32-bit signed format

 *
* @param string The IP to convert
* @return integer IP in 32-bit signed format

 */

 */

function my_ip2long($ip)
{
$ip_long = ip2long($ip);

function my_ip2long($ip)
{
$ip_long = ip2long($ip);

Zeile 6041Zeile 6053
	if(!$ip_long)
{
$ip_long = sprintf("%u", ip2long($ip));

	if(!$ip_long)
{
$ip_long = sprintf("%u", ip2long($ip));

		



		if(!$ip_long)
{
return 0;

		if(!$ip_long)
{
return 0;

		}
}

		}
}


if($ip_long >= 2147483648) // Won't occur on 32-bit PHP
{
$ip_long -= 4294967296;
}


if($ip_long >= 2147483648) // Won't occur on 32-bit PHP
{
$ip_long -= 4294967296;
}





	return $ip_long;
}

/**
* As above, fix for PHP's long2ip on 64-bit versions

	return $ip_long;
}

/**
* As above, fix for PHP's long2ip on 64-bit versions

 *

 *

 * @param integer The IP to convert (will accept 64-bit IPs as well)
* @return string IP in IPv4 format
*/

 * @param integer The IP to convert (will accept 64-bit IPs as well)
* @return string IP in IPv4 format
*/

Zeile 6083Zeile 6095
function verify_files($path=MYBB_ROOT, $count=0)
{
global $mybb, $checksums, $bad_verify_files;

function verify_files($path=MYBB_ROOT, $count=0)
{
global $mybb, $checksums, $bad_verify_files;

	



	// We don't need to check these types of files
$ignore = array(".", "..", ".svn", "config.php", "settings.php", "Thumb.db", "config.default.php", "lock", "htaccess.txt", "logo.gif");
$ignore_ext = array("attach");

	// We don't need to check these types of files
$ignore = array(".", "..", ".svn", "config.php", "settings.php", "Thumb.db", "config.default.php", "lock", "htaccess.txt", "logo.gif");
$ignore_ext = array("attach");

	



	if(substr($path, -1, 1) == "/")

	if(substr($path, -1, 1) == "/")

	{

	{

		$path = substr($path, 0, -1);

		$path = substr($path, 0, -1);

	}


	}


	if(!is_array($bad_verify_files))
{
$bad_verify_files = array();
}

	if(!is_array($bad_verify_files))
{
$bad_verify_files = array();
}

	



	// Make sure that we're in a directory and it's not a symbolic link

	// Make sure that we're in a directory and it's not a symbolic link

    if(@is_dir($path) && !@is_link($path))
{
if($dh = @opendir($path))
{

	if(@is_dir($path) && !@is_link($path))
{
if($dh = @opendir($path))
{

			// Loop through all the files/directories in this directory

			// Loop through all the files/directories in this directory

            while(($file = @readdir($dh)) !== false)
{

			while(($file = @readdir($dh)) !== false)
{

				if(in_array($file, $ignore) || in_array(get_extension($file), $ignore_ext))

				if(in_array($file, $ignore) || in_array(get_extension($file), $ignore_ext))

				{
continue;
}


				{
continue;
}


				// Recurse through the directory tree
if(is_dir($path."/".$file))
{
verify_files($path."/".$file, ($count+1));
continue;
}

				// Recurse through the directory tree
if(is_dir($path."/".$file))
{
verify_files($path."/".$file, ($count+1));
continue;
}

				



				// We only need the last part of the path (from the MyBB directory to the file. i.e. inc/functions.php)
$file_path = ".".str_replace(substr(MYBB_ROOT, 0, -1), "", $path)."/".$file;

				// We only need the last part of the path (from the MyBB directory to the file. i.e. inc/functions.php)
$file_path = ".".str_replace(substr(MYBB_ROOT, 0, -1), "", $path)."/".$file;

				



				// Does this file even exist in our official list? Perhaps it's a plugin
if(array_key_exists($file_path, $checksums))
{

				// Does this file even exist in our official list? Perhaps it's a plugin
if(array_key_exists($file_path, $checksums))
{

Zeile 6132Zeile 6144
						$contents .= fread($handle, 8192);
}
fclose($handle);

						$contents .= fread($handle, 8192);
}
fclose($handle);

					



					$md5 = md5($contents);

					$md5 = md5($contents);

					



					// Does it match any of our hashes (unix/windows new lines taken into consideration with the hashes)
if(!in_array($md5, $checksums[$file_path]))

					// Does it match any of our hashes (unix/windows new lines taken into consideration with the hashes)
if(!in_array($md5, $checksums[$file_path]))

					{						

					{

						$bad_verify_files[] = array("status" => "changed", "path" => $file_path);
}
}
unset($checksums[$file_path]);

						$bad_verify_files[] = array("status" => "changed", "path" => $file_path);
}
}
unset($checksums[$file_path]);

            }
@closedir($dh);
}
}


			}
@closedir($dh);
}
}


	if($count == 0)
{
if(!empty($checksums))

	if($count == 0)
{
if(!empty($checksums))

		{

		{

			foreach($checksums as $file_path => $hashes)
{
if(in_array(basename($file_path), $ignore))

			foreach($checksums as $file_path => $hashes)
{
if(in_array(basename($file_path), $ignore))

Zeile 6161Zeile 6173
			}
}
}

			}
}
}

	



	// uh oh
if($count == 0)
{

	// uh oh
if($count == 0)
{

Zeile 6196Zeile 6208
function secure_seed_rng($count=8)
{
$output = '';

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

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

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

	{

	{

		$output = '';

		$output = '';

		



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

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

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

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

	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 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 equivalent of a secure hexadecimal seed
*/

 * @param boolean True forces it to reseed the RNG first
* @return int An integer equivalent of a secure hexadecimal seed
*/

Zeile 6244Zeile 6256
		$seeded = true;

$obfuscator = abs((int) 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())
{

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

Zeile 6306Zeile 6318
					  0xBE => array(0xA0 => 1), // \x{FFA0}
0xBF => array(0xB9 => 1, 0xBA => 1, 0xBB => 1)), // \x{FFF9} to \x{FFFB}
);

					  0xBE => array(0xA0 => 1), // \x{FFA0}
0xBF => array(0xB9 => 1, 0xBA => 1, 0xBB => 1)), // \x{FFF9} to \x{FFFB}
);

	



	$hex_chrs_rev = array(
0x20 => 1,
0x09 => 1,

	$hex_chrs_rev = array(
0x20 => 1,
0x09 => 1,

Zeile 6352Zeile 6364
		0xBA => array(0xBF => array(0xEF => 1)), // \x{FFFA}
0xBB => array(0xBF => array(0xEF => 1)), // \x{FFFB}
);

		0xBA => array(0xBF => array(0xEF => 1)), // \x{FFFA}
0xBB => array(0xBF => array(0xEF => 1)), // \x{FFFB}
);

	



	// Start from the beginning and work our way in
do
{
// Check to see if we have matched a first character in our utf-16 array
$offset = match_sequence($string, $hex_chrs);

	// Start from the beginning and work our way in
do
{
// Check to see if we have matched a first character in our utf-16 array
$offset = match_sequence($string, $hex_chrs);

		if(!$offset)
{
// If not, then we must have a "good" character and we don't need to do anymore processing
break;
}
$string = substr($string, $offset);
}

		if(!$offset)
{
// If not, then we must have a "good" character and we don't need to do anymore processing
break;
}
$string = substr($string, $offset);
}

	while(++$i);

	while(++$i);

	



	// Start from the end and work our way in
$string = strrev($string);
do

	// Start from the end and work our way in
$string = strrev($string);
do

Zeile 6377Zeile 6389
		{
// If not, then we must have a "good" character and we don't need to do anymore processing
break;

		{
// If not, then we must have a "good" character and we don't need to do anymore processing
break;

		}

		}

		$string = substr($string, $offset);
}
while(++$i);
$string = strrev($string);

		$string = substr($string, $offset);
}
while(++$i);
$string = strrev($string);

	



	if($charlist !== false)
{
$string = trim($string, $charlist);

	if($charlist !== false)
{
$string = trim($string, $charlist);

Zeile 6391Zeile 6403
	{
$string = trim($string);
}

	{
$string = trim($string);
}

	



	return $string;
}

	return $string;
}





function match_sequence($string, $array, $i=0, $n=0)
{
if($string === "")
{
return 0;
}

function match_sequence($string, $array, $i=0, $n=0)
{
if($string === "")
{
return 0;
}

	



	$ord = ord($string[$i]);
if(array_key_exists($ord, $array))
{

	$ord = ord($string[$i]);
if(array_key_exists($ord, $array))
{

Zeile 6414Zeile 6426
		}
return $n;
}

		}
return $n;
}

	



	return 0;

	return 0;

}

}


/**
* Obtain the version of GD installed.


/**
* Obtain the version of GD installed.

Zeile 6426Zeile 6438
function gd_version()
{
static $gd_version;

function gd_version()
{
static $gd_version;

	



	if($gd_version)

	if($gd_version)

	{

	{

		return $gd_version;

		return $gd_version;

	}

	}

	if(!extension_loaded('gd'))
{
return;

	if(!extension_loaded('gd'))
{
return;

	}


	}


	if(function_exists("gd_info"))
{
$gd_info = gd_info();

	if(function_exists("gd_info"))
{
$gd_info = gd_info();

   		preg_match('/\d/', $gd_info['GD Version'], $gd);
$gd_version = $gd[0];

		preg_match('/\d/', $gd_info['GD Version'], $gd);
$gd_version = $gd[0];

	}
else

	}
else

	{

	{

		ob_start();
phpinfo(8);
$info = ob_get_contents();

		ob_start();
phpinfo(8);
$info = ob_get_contents();

Zeile 6452Zeile 6464
		preg_match('/\d/', $info, $gd);
$gd_version = $gd[0];
}

		preg_match('/\d/', $info, $gd);
$gd_version = $gd[0];
}

	



	return $gd_version;

	return $gd_version;

}









































































}

/**
* Handles 4 byte UTF-8 characters.
*
* This can be used to either reject strings which contain 4 byte UTF-8
* characters, or replace them with question marks. This is limited to UTF-8
* collated databases using MySQL.
*
* Original: http://www.avidheap.org/2013/a-quick-way-to-normalize-a-utf8-string-when-your-mysql-database-is-not-utf8mb4
*
* @param string The string to be checked.
* @param bool If false don't return the string, only the boolean result.
* @return mixed Return a string if the second parameter is true, boolean otherwise.
*/
function utf8_handle_4byte_string($input, $return=true)
{
global $config;

if($config['database']['type'] != 'mysql' && $config['database']['type'] != 'mysqli')
{
if($return == true)
{
return $input;
}
return true;
}

$contains_4bytes = false;
if(!empty($input))
{
$utf8_2byte = 0xC0 /*1100 0000*/;
$utf8_2byte_bmask = 0xE0 /*1110 0000*/;

$utf8_3byte = 0xE0 /*1110 0000*/;
$utf8_3byte_bmask = 0XF0 /*1111 0000*/;

$utf8_4byte = 0xF0 /*1111 0000*/;
$utf8_4byte_bmask = 0xF8 /*1111 1000*/;

$sanitized = "";
$len = strlen($input);
for($i = 0; $i < $len; ++$i)
{
$mb_char = $input[$i]; // Potentially a multibyte sequence
$byte = ord($mb_char);
if(($byte & $utf8_2byte_bmask) == $utf8_2byte)
{
$mb_char .= $input[++$i];
}
elseif(($byte & $utf8_3byte_bmask) == $utf8_3byte)
{
$mb_char .= $input[++$i];
$mb_char .= $input[++$i];
}
elseif(($byte & $utf8_4byte_bmask) == $utf8_4byte)
{
$contains_4bytes = true;
// Replace with ? to avoid MySQL exception
$mb_char = '?';
$i += 3;
}

$sanitized .= $mb_char;

if($contains_4bytes == true && $return == false)
{
return false;
}
}

$input = $sanitized;
}





 
	if($contains_4bytes == false && $return == false)
{
return true;
}
return $input;
}

?>

?>