Vergleich inc/functions.php - 1.6.0 - 1.6.10

  Keine Änderungen   Hinzugefügt   Modifiziert   Entfernt
Zeile 6Zeile 6
 * Website: http://mybb.com
* License: http://mybb.com/about/license
*

 * Website: http://mybb.com
* License: http://mybb.com/about/license
*

 * $Id: functions.php 5172 2010-08-02 23:13:03Z RyanGordon $

 * $Id$

 */

/**

 */

/**

Zeile 47Zeile 47

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


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

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

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

			}
else
{

			}
else
{

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

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

			}

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

			}

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

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


				$gzipen = "Disabled";
}


			if(function_exists("memory_get_usage"))







			$memory_usage = get_memory_usage();

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

			{

			{

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

				$memory_usage = '';

			}

$other = "PHP version: $phpversion / Server Load: $serverload / GZip Compression: $gzipen";
$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 />";
$contents = str_replace("<debugstuff>", $debugstuff, $contents);

			}

$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 />";
$contents = str_replace("<debugstuff>", $debugstuff, $contents);

		}

		}


if($mybb->debug_mode == true)
{


if($mybb->debug_mode == true)
{

Zeile 92Zeile 98
	echo $contents;

$plugins->run_hooks("post_output_page");

	echo $contents;

$plugins->run_hooks("post_output_page");


// If the use shutdown functionality is turned off, run any shutdown related items now.
if($mybb->settings['useshutdownfunc'] == 0 && $mybb->use_shutdown != true)
{
run_shutdown();
}
}

}








/**
* Adds a function or class to the list of code to run on shutdown.


/**
* Adds a function or class to the list of code to run on shutdown.

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

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

		return true;
}

		return true;
}

	else if(!is_array($name) && function_exists($name))
{
$shutdown_functions[$name] = array('function' => $name, 'arguments' => $arguments);

	else if(!is_array($name) && function_exists($name))
{
$shutdown_functions[$name] = array('function' => $name, 'arguments' => $arguments);

Zeile 141Zeile 141
	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))
{
require_once MYBB_ROOT."inc/class_core.php";
$mybb = new MyBB;


// Missing the core? Build
if(!is_object($mybb))
{
require_once MYBB_ROOT."inc/class_core.php";
$mybb = new MyBB;





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

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

	}


	}



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


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

Zeile 197Zeile 197
	}

// And finally.. plugins

	}

// And finally.. plugins

	if(!is_object($plugins) && !defined("NO_PLUGINS"))

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

	{
require_once MYBB_ROOT."inc/class_plugins.php";
$plugins = new pluginSystem;

	{
require_once MYBB_ROOT."inc/class_plugins.php";
$plugins = new pluginSystem;

Zeile 246Zeile 246

// Fetch emails for this page view - and send them
$query = $db->simple_select("mailqueue", "*", "", array("order_by" => "mid", "order_dir" => "asc", "limit_start" => 0, "limit" => $count));


// Fetch emails for this page view - and send them
$query = $db->simple_select("mailqueue", "*", "", array("order_by" => "mid", "order_dir" => "asc", "limit_start" => 0, "limit" => $count));


$plugins->run_hooks_by_ref("send_mail_queue_mail", $query);

 

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



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


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




			if($db->affected_rows() == 1)
{
my_mail($email['mailto'], $email['subject'], $email['message'], $email['mailfrom'], "", $email['headers']);
}

		}
// Update the mailqueue cache and remove the lock
$cache->update_mailqueue(TIME_NOW, 0);

		}
// Update the mailqueue cache and remove the lock
$cache->update_mailqueue(TIME_NOW, 0);

	}


	}


	$plugins->run_hooks("send_mail_queue_end");
}


	$plugins->run_hooks("send_mail_queue_end");
}


Zeile 279Zeile 280
	if($htmldoctype)
{
$contents = $htmldoctype.$contents;

	if($htmldoctype)
{
$contents = $htmldoctype.$contents;

	}

	}

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

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

Zeile 300Zeile 301
	if($error_handler->warnings)
{
$contents = str_replace("<body>", "<body>\n".$error_handler->show_warnings(), $contents);

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

	}

	}

	
return $contents;
}

	
return $contents;
}

Zeile 327Zeile 328

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


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

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

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

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

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

		}

		}

		elseif(defined("IN_ADMINCP"))

		elseif(defined("IN_ADMINCP"))

		{

		{

			$offset =  $mybbadmin['timezone'];
$dstcorrection = $mybbadmin['dst'];
}

			$offset =  $mybbadmin['timezone'];
$dstcorrection = $mybbadmin['dst'];
}

Zeile 341Zeile 342
		{
$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 351Zeile 352
			{
$offset = "+".$offset;
}

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

		}
}


		}
}


	if($offset == "-")

	if($offset == "-")

	{

	{

		$offset = 0;
}


		$offset = 0;
}


Zeile 364Zeile 365
		$date = adodb_date($format, $stamp + ($offset * 3600));
}
else

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

	{

	{

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


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


Zeile 395Zeile 396

if(is_object($plugins))
{


if(is_object($plugins))
{

		$plugins->run_hooks_by_ref("my_date", $date);

		$date = $plugins->run_hooks("my_date", $date);

	}

	}





	return $date;
}


	return $date;
}


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

{
global $mybb;
static $mail;

	

	

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

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

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

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

		}

		}

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

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

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

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

	{

	{

		if($keep_alive == true)

		if($keep_alive == true)

		{

		{

			$mail->keep_alive = true;
}
}

			$mail->keep_alive = true;
}
}

Zeile 449Zeile 450
	else
{
if($mybb->settings['mail_parameters'] != '')

	else
{
if($mybb->settings['mail_parameters'] != '')

		{

		{

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

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

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

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

}

/**

}

/**

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

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

Zeile 470Zeile 471
	if($mybb->user['uid'])
{
return md5($mybb->user['loginkey'].$mybb->user['salt'].$mybb->user['regdate']);

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

	}

	}

	// Guests get a special string
else
{

	// Guests get a special string
else
{

Zeile 502Zeile 503
			else
{
error($lang->invalid_post_code);

			else
{
error($lang->invalid_post_code);

			}
}
}
else

			}
}
}
else

	{
return true;
}

	{
return true;
}

Zeile 644Zeile 645
{
global $header, $footer, $theme, $headerinclude, $db, $templates, $lang, $mybb, $plugins;


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


	$plugins->run_hooks_by_ref("error", $error);

	$error = $plugins->run_hooks("error", $error);

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

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

Zeile 680Zeile 681
 * @param array Array of errors to be shown
* @param string The title of the error message
* @return string The inline error HTML

 * @param array Array of errors to be shown
* @param string The title of the error message
* @return string The inline error HTML

 */

 */

function inline_error($errors, $title="")
{
global $theme, $mybb, $db, $lang, $templates;

function inline_error($errors, $title="")
{
global $theme, $mybb, $db, $lang, $templates;

Zeile 691Zeile 692
	}

if(!is_array($errors))

	}

if(!is_array($errors))

	{

	{

		$errors = array($errors);
}


		$errors = array($errors);
}


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

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

		exit;
}


		exit;
}


	foreach($errors as $error)
{
$errorlist .= "<li>".$error."</li>\n";
}

	foreach($errors as $error)
{
$errorlist .= "<li>".$error."</li>\n";
}





	eval("\$errors = \"".$templates->get("error_inline")."\";");

return $errors;

	eval("\$errors = \"".$templates->get("error_inline")."\";");

return $errors;

}

}


/**
* Presents the user with a "no permission" page


/**
* Presents the user with a "no permission" page

Zeile 732Zeile 733
	);

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

	);

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

	$url = htmlspecialchars_uni("http://".$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI']);

 

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


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

	{

	{

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

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

Zeile 746Zeile 746
	{
$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")."\";");

	}

	}

	else
{

	else
{

 
		// Redirect to where the user came from
$redirect_url = $_SERVER['PHP_SELF'];
if($_SERVER['QUERY_STRING'])
{
$redirect_url .= '?'.$_SERVER['QUERY_STRING'];
}

$redirect_url = htmlspecialchars_uni($redirect_url);

switch($mybb->settings['username_method'])
{
case 0:
$lang_username = $lang->username;
break;
case 1:
$lang_username = $lang->username1;
break;
case 2:
$lang_username = $lang->username2;
break;
default:
$lang_username = $lang->username;
break;
}

		eval("\$errorpage = \"".$templates->get("error_nopermission")."\";");
}


		eval("\$errorpage = \"".$templates->get("error_nopermission")."\";");
}


Zeile 766Zeile 790
	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_by_ref("redirect", $redirect_args);


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


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

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

Zeile 803Zeile 827
	if($mybb->settings['redirects'] == 1 && ($mybb->user['showredirect'] != 0 || !$mybb->user['uid']))
{
$url = str_replace("&amp;", "&", $url);

	if($mybb->settings['redirects'] == 1 && ($mybb->user['showredirect'] != 0 || !$mybb->user['uid']))
{
$url = str_replace("&amp;", "&", $url);

		$url = htmlspecialchars($url);

		$url = htmlspecialchars_uni($url);


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


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

Zeile 815Zeile 839

run_shutdown();



run_shutdown();


		if(my_substr($url, 0, 7) !== 'http://')

		if(my_substr($url, 0, 7) !== 'http://' && my_substr($url, 0, 8) !== 'https://' && my_substr($url, 0, 1) !== '/')

		{
header("Location: {$mybb->settings['bburl']}/{$url}");
}

		{
header("Location: {$mybb->settings['bburl']}/{$url}");
}

Zeile 851Zeile 875

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



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


 
	$prevpage = '';

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

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

Zeile 888Zeile 913
		$to = $pages;
}


		$to = $pages;
}


 
	$start = '';

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

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

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


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


 
	$mppage = '';

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

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

Zeile 919Zeile 946
		}
}


		}
}


 
	$end = '';

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

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

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


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


 
	$nextpage = '';

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

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

	}


	}


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

if($breadcrumb == true)

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

if($breadcrumb == true)

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

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

	}


	}


	return $multipage;
}


	return $multipage;
}


Zeile 958Zeile 988
 */
function fetch_page_url($url, $page)
{

 */
function fetch_page_url($url, $page)
{

	// If no page identifier is specified we tack it on to the end of the URL
if(strpos($url, "{page}") === false)












	if($page <= 1)
{
$find = array(
"-page-{page}",
"&amp;page={page}",
"{page}"
);

// Remove "Page 1" to the defacto URL
$url = str_replace($find, array("", "", $page), $url);
return $url;
}
else if(strpos($url, "{page}") === false)

	{

	{

 
		// If no page identifier is specified we tack it on to the end of the URL

		if(strpos($url, "?") === false)

		if(strpos($url, "?") === false)

		{

		{

			$url .= "?";
}
else
{
$url .= "&amp;";

			$url .= "?";
}
else
{
$url .= "&amp;";

		}


		}


		$url .= "page=$page";

		$url .= "page=$page";

	}

	}

	else
{
$url = str_replace("{page}", $page, $url);
}

	else
{
$url = str_replace("{page}", $page, $url);
}

 


	return $url;
}


	return $url;
}


Zeile 999Zeile 1043
	{
// We've already cached permissions for this user, return them.
if($user_cache[$uid]['permissions'])

	{
// We've already cached permissions for this user, return them.
if($user_cache[$uid]['permissions'])

		{

		{

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


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


Zeile 1018Zeile 1062
		return $groupperms;
}
// This user is the current user, return their permissions

		return $groupperms;
}
// This user is the current user, return their permissions

	else
{

	else
{

		return $mybb->usergroup;
}
}

		return $mybb->usergroup;
}
}

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

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

			}

			}

		}
return $cached_forum_permissions[$gid];
}

		}
return $cached_forum_permissions[$gid];
}

Zeile 1205Zeile 1249

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



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


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

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

	{
return $groupperms;

	{
return $groupperms;

	}


	}


	$current_permissions = array();

	$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 1248Zeile 1293
				{
$current_permissions[$permission] = $access;
}

				{
$current_permissions[$permission] = $access;
}

 
			}

if(!$level_permissions["canonlyviewownthreads"])
{
$only_view_own_threads = 0;

			}
}

			}
}

 
	}

// Figure out if we can view more than our own threads
if($only_view_own_threads == 0)
{
$current_permissions["canonlyviewownthreads"] = 0;

	}

if(count($current_permissions) == 0)

	}

if(count($current_permissions) == 0)

Zeile 1358Zeile 1414
 */
function get_moderator_permissions($fid, $uid="0", $parentslist="")
{

 */
function get_moderator_permissions($fid, $uid="0", $parentslist="")
{

	global $mybb, $db;

	global $mybb, $cache, $db;

	static $modpermscache;

if($uid < 1)

	static $modpermscache;

if($uid < 1)

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

if($uid == 0)
{

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

if($uid == 0)
{

		return false;
}

		return false;
}

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






























if(isset($modpermscache[$fid][$uid]))
{
return $modpermscache[$fid][$uid];
}

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

// Get user groups
$perms = array();
$user = get_user($uid);

$groups = array($user['usergroup']);

if(!empty($user['additionalgroups']))
{
$extra_groups = explode(",", $user['additionalgroups']);

foreach($extra_groups as $extra_group)
{
$groups[] = $extra_group;
}
}

$mod_cache = $cache->read("moderators");

foreach($mod_cache as $fid => $forum)

	{

	{

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


























		if(!is_array($forum) || !in_array($fid, $parentslist))
{
// No perms or we're not after this forum
continue;
}

// User settings override usergroup settings
if(is_array($forum['users'][$uid]))
{
$perm = $forum['users'][$uid];
foreach($perm as $action => $value)
{
if(strpos($action, "can") === false)
{
continue;
}

// Figure out the user permissions
if($value == 0)
{
// The user doesn't have permission to set this action
$perms[$action] = 0;
}
else
{
$perms[$action] = max($perm[$action], $perms[$action]);
}
}

		}

		}

		
// Get user groups
$query = $db->simple_select("users", "usergroup,additionalgroups", "uid='{$uid}'");
$usergroups = $db->fetch_array($query);
$groups = "'{$usergroups['usergroup']}'";
if(!empty($usergroups['additionalgroups']))


foreach($groups as $group)





		{

		{

			$groups .= ",'{$usergroups['additionalgroups']}'";
















			if(!is_array($forum['usergroups'][$group]))
{
// There are no permissions set for this group
continue;
}

$perm = $forum['usergroups'][$group];
foreach($perm as $action => $value)
{
if(strpos($action, "can") === false)
{
continue;
}

$perms[$action] = max($perm[$action], $perms[$action]);
}

		}

		}

		
$query = $db->simple_select("moderators", "*", "((id IN ({$groups}) AND isgroup='1') OR (id='{$uid}' AND isgroup='0')) AND fid='$fid'");
while($results = $db->fetch_array($query))
{
$perms['caneditposts'] = max($perms['caneditposts'], $results['caneditposts']);
$perms['candeleteposts'] = max($perms['candeleteposts'], $results['candeleteposts']);
$perms['canviewips'] = max($perms['canviewips'], $results['canviewips']);
$perms['canopenclosethreads'] = max($perms['canopenclosethreads'], $results['canopenclosethreads']);
$perms['canmanagethreads'] = max($perms['canmanagethreads'], $results['canmanagethreads']);
$perms['canmovetononmodforum'] = max($perms['canmovetononmodforum'], $results['canmovetononmodforum']);
}

$sql = build_parent_list($fid, "fid", "OR", $parentslist);
$query = $db->simple_select("moderators", "*", "((id IN ({$groups}) AND isgroup='1') OR (id='{$uid}' AND isgroup='0')) AND {$sql}");
$uperms = $db->fetch_array($query);

if(!$uperms && !$perms)
{
return false;
}

//Join the group permissions with the user permissions
$perms['caneditposts'] = max($perms['caneditposts'], $uperms['caneditposts']);
$perms['candeleteposts'] = max($perms['candeleteposts'], $uperms['candeleteposts']);
$perms['canviewips'] = max($perms['canviewips'], $uperms['canviewips']);
$perms['canopenclosethreads'] = max($perms['canopenclosethreads'], $uperms['canopenclosethreads']);
$perms['canmanagethreads'] = max($perms['canmanagethreads'], $uperms['canmanagethreads']);
$perms['canmovetononmodforum'] = max($perms['canmovetononmodforum'], $uperms['canmovetononmodforum']);

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

 
	}

	}

 

$modpermscache[$fid][$uid] = $perms;


return $perms;


return $perms;

}


}


/**
* Checks if a moderator has permissions to perform an action in a specific forum
*

/**
* Checks if a moderator has permissions to perform an action in a specific forum
*

Zeile 1443Zeile 1531
	}

if($uid == 0)

	}

if($uid == 0)

	{

	{

		return false;
}


		return false;
}


Zeile 1463Zeile 1551
				{
if(isset($modusers['users'][$uid]) && $modusers['users'][$uid]['mid'])
{

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

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

						return true;
}
}

						return true;
}
}

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


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


 
	$iconlist = '';

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

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

Zeile 1519Zeile 1613
	
foreach($posticons as $dbicon)
{

	
foreach($posticons as $dbicon)
{

 
		$dbicon['path'] = htmlspecialchars_uni($dbicon['path']);
$dbicon['name'] = htmlspecialchars_uni($dbicon['name']);


		if($icon == $dbicon['iid'])

		if($icon == $dbicon['iid'])

		{

		{

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

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

		}

		}

		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)
{
$iconlist .= "<br />";
$listed = 0;
}

		++$listed;
if($listed == 10)
{
$iconlist .= "<br />";
$listed = 0;
}

	}

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


	}

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


	return $posticons;
}


	return $posticons;
}


Zeile 1570Zeile 1667
	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['cookieprefix'] = str_replace(array("\n","\r", " "), "", $mybb->settings['cookieprefix']);

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

Zeile 1580Zeile 1677
	$cookie = "Set-Cookie: {$mybb->settings['cookieprefix']}{$name}=".urlencode($value);

if($expires > 0)

	$cookie = "Set-Cookie: {$mybb->settings['cookieprefix']}{$name}=".urlencode($value);

if($expires > 0)

	{

	{

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


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


Zeile 1602Zeile 1699
	$mybb->cookies[$name] = $value;

header($cookie, false);

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

header($cookie, false);

}


}


/**
* Unset a cookie set by MyBB.
*

/**
* Unset a cookie set by MyBB.
*

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

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

	}

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

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

	}

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

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

		return $cookie[$id];

		return $cookie[$id];

	}

	}

	else
{
return 0;

	else
{
return 0;

	}
}

/**

	}
}

/**

 * Set a serialised cookie array.
*
* @param string The cookie identifier.
* @param int The cookie content id.
* @param string The value to set the cookie to.
*/

 * Set a serialised cookie array.
*
* @param string The cookie identifier.
* @param int The cookie content id.
* @param string The value to set the cookie to.
*/

function my_set_array_cookie($name, $id, $value)

function my_set_array_cookie($name, $id, $value, $expires="")

{
global $mybb;

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

{
global $mybb;

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

	$newcookie = unserialize($cookie[$name]);


	$newcookie = my_unserialize($cookie[$name]);


	$newcookie[$id] = $value;
$newcookie = serialize($newcookie);

	$newcookie[$id] = $value;
$newcookie = serialize($newcookie);

	my_setcookie("mybb[$name]", addslashes($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
* @return array Unserialized data array
*/
function my_unserialize($data)
{
$array = unserialize($data);

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

return $array;
}


/**
* Returns the serverload of the system.


/**
* Returns the serverload of the system.

Zeile 1692Zeile 1808
		{
$serverload = explode(" ", $load);
$serverload[0] = round($serverload[0], 4);

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

		}

		}

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

			{
if(strpos(",".$func_blacklist.",", 'exec') !== false)

			{
if(strpos(",".$func_blacklist.",", 'exec') !== false)

				{
return $lang->unknown;
}

				{
return $lang->unknown;
}

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

return $returnload;

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

return $returnload;

 
}

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

}

/**

}

/**

Zeile 1841Zeile 1975
			}

// Less than 0? That's bad

			}

// Less than 0? That's bad

			if($update_query[$counter] < 0)

			if(!$update_query[$counter])

			{
$update_query[$counter] = 0;
}

			{
$update_query[$counter] = 0;
}

Zeile 1943Zeile 2077
		"lastposteruid" => intval($lastpost['lastposteruid']),
"lastposttid" => intval($lastpost['tid']),
"lastpostsubject" => $db->escape_string($lastpost['subject'])

		"lastposteruid" => intval($lastpost['lastposteruid']),
"lastposttid" => intval($lastpost['tid']),
"lastpostsubject" => $db->escape_string($lastpost['subject'])

	);


	);


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


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


Zeile 1976Zeile 2110
				$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];
}


Zeile 1992Zeile 2126

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


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

	{

	{

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


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


Zeile 2000Zeile 2134

update_thread_data($tid);
}


update_thread_data($tid);
}





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

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

Zeile 2009Zeile 2143
function update_thread_data($tid)
{
global $db;

function update_thread_data($tid)
{
global $db;

 

$thread = get_thread($tid);

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


	$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 2133Zeile 2276
	global $forum_cache, $jumpfcache, $permissioncache, $mybb, $selecteddone, $forumjump, $forumjumpbits, $gobutton, $theme, $templates, $lang;

$pid = intval($pid);

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

$pid = intval($pid);

 
	$jumpsel['default'] = '';


if($permissions)
{


if($permissions)
{

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


		$permissioncache = forum_permissions();
}


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

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

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

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

Zeile 2197Zeile 2341
		if(!$selecteddone)
{
if(!$selitem)

		if(!$selecteddone)
{
if(!$selitem)

			{

			{

				$selitem = "default";
}


				$selitem = "default";
}


Zeile 2211Zeile 2355
		else
{
$template = "advanced";

		else
{
$template = "advanced";

		}











if(strpos(FORUM_URL, '.html') !== false)
{
$forum_link = "'".str_replace('{fid}', "'+this.options[this.selectedIndex].value+'", FORUM_URL)."'";
}
else
{
$forum_link = "'".str_replace('{fid}', "'+this.options[this.selectedIndex].value", FORUM_URL);
}
}


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

return $forumjump;


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

return $forumjump;

}

/**

}

/**

 * Returns the extension of a file.
*
* @param string The filename.

 * Returns the extension of a file.
*
* @param string The filename.

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

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

}

/**

}

/**

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

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

Zeile 2263Zeile 2416
	global $groupscache, $cache;

if(!is_array($groupscache))

	global $groupscache, $cache;

if(!is_array($groupscache))

	{

	{

		$groupscache = $cache->read("usergroups");
}


		$groupscache = $cache->read("usergroups");
}


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

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

	$format = stripslashes($format);

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

}

}


/**
* Build the javascript based MyCode inserter


/**
* Build the javascript based MyCode inserter

Zeile 2294Zeile 2447
function build_mycode_inserter($bind="message")
{
global $db, $mybb, $theme, $templates, $lang, $plugins;

function build_mycode_inserter($bind="message")
{
global $db, $mybb, $theme, $templates, $lang, $plugins;





	if($mybb->settings['bbcodeinserter'] != 0)
{
$editor_lang_strings = array(

	if($mybb->settings['bbcodeinserter'] != 0)
{
$editor_lang_strings = array(

Zeile 2322Zeile 2475
			"editor_enter_image",
"editor_enter_video_url",
"editor_video_dailymotion",

			"editor_enter_image",
"editor_enter_video_url",
"editor_video_dailymotion",

			"editor_video_googlevideo",

 
			"editor_video_metacafe",
"editor_video_myspacetv",
"editor_video_vimeo",

			"editor_video_metacafe",
"editor_video_myspacetv",
"editor_video_vimeo",

Zeile 2341Zeile 2493
		);
$editor_language = "var editor_language = {\n";


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


		$plugins->run_hooks_by_ref("mycode_add_codebuttons", $editor_lang_strings);

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


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


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

Zeile 2349Zeile 2501
			$js_lang_string = preg_replace("#^editor_#i", "", $lang_string);
$string = str_replace("\"", "\\\"", $lang->$lang_string);
$editor_language .= "\t{$js_lang_string}: \"{$string}\"";

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


if($editor_lang_strings[$key+1])


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

			{
$editor_language .= ",";
}

			{
$editor_language .= ",";
}





			$editor_language .= "\n";
}

$editor_language .= "};";

if(defined("IN_ADMINCP"))

			$editor_language .= "\n";
}

$editor_language .= "};";

if(defined("IN_ADMINCP"))

		{

		{

			global $page;
$codeinsert = $page->build_codebuttons_editor($bind, $editor_language);

			global $page;
$codeinsert = $page->build_codebuttons_editor($bind, $editor_language);

		}

		}

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

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





	return $codeinsert;

	return $codeinsert;

}

/**

}

/**

 * Build the javascript clickable smilie inserter
*
* @return string The clickable smilies list

 * Build the javascript clickable smilie inserter
*
* @return string The clickable smilies list

Zeile 2382Zeile 2534
function build_clickable_smilies()
{
global $cache, $smiliecache, $theme, $templates, $lang, $mybb, $smiliecount;

function build_clickable_smilies()
{
global $cache, $smiliecache, $theme, $templates, $lang, $mybb, $smiliecount;





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

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

		{

		{

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

if(!$smiliecache)

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

if(!$smiliecache)

		{

		{

			if(!is_array($smilie_cache))

			if(!is_array($smilie_cache))

			{

			{

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

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

			}

			}

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

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

				}
}

				}
}

		}

		}





		unset($smilie);

		unset($smilie);





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


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


 
			$getmore = '';

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

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

			{

			{

				$mybb->settings['smilieinsertertot'] = $smiliecount;
}
else if($mybb->settings['smilieinsertertot'] < $smiliecount)

				$mybb->settings['smilieinsertertot'] = $smiliecount;
}
else if($mybb->settings['smilieinsertertot'] < $smiliecount)

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

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

					}


					}


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

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

Zeile 2455Zeile 2608
			}

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

			}

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

		}
else
{
$clickablesmilies = "";
}
}
else
{

		}
else
{
$clickablesmilies = "";
}
}
else
{

		$clickablesmilies = "";
}


		$clickablesmilies = "";
}


	return $clickablesmilies;





















































	return $clickablesmilies;
}

/**
* 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)
*/
function build_prefixes($pid=0)
{
global $cache;
static $prefixes_cache;

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

if(!is_array($prefix_cache))
{
// No cache
$prefix_cache = $cache->read("threadprefixes", true);

if(!is_array($prefix_cache))
{
return array();
}
}

$prefixes_cache = array();
foreach($prefix_cache as $prefix)
{
$prefixes_cache[$prefix['pid']] = $prefix;
}

if($pid != 0 && is_array($prefixes_cache[$pid]))
{
return $prefixes_cache[$pid];
}
else if(!empty($prefixes_cache))
{
return $prefixes_cache;
}

return false;

}

/**

}

/**

Zeile 2478Zeile 2683
 */
function build_prefix_select($fid, $selected_pid=0, $multiple=0)
{

 */
function build_prefix_select($fid, $selected_pid=0, $multiple=0)
{

	global $db, $lang, $mybb;

	global $cache, $db, $lang, $mybb;

	
if($fid != 'all')
{
$fid = intval($fid);
}


	
if($fid != 'all')
{
$fid = intval($fid);
}


	// Does this user have additional groups?







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

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

	if($mybb->user['additionalgroups'])
{
$exp = explode(",", $mybb->user['additionalgroups']);


	if($mybb->user['additionalgroups'])
{
$exp = explode(",", $mybb->user['additionalgroups']);


		// Because we like apostrophes...
$imps = array();

 
		foreach($exp as $group)

		foreach($exp as $group)

		{
$imps[] = "'{$group}'";
}

$additional_groups = implode(",", $imps);
$extra_sql = "groups IN ({$additional_groups}) OR ";
}
else
{
$extra_sql = '';
}

switch($db->type)
{
case "pgsql":
case "sqlite":
$whereforum = "";
if($fid != 'all')









		{
$groups[] = $group;
}
}

// Go through each of our prefixes and decide which ones we can use
$prefixes = array();
foreach($prefix_cache as $prefix)
{
if($fid != "all" && $prefix['forums'] != "-1")
{
// Decide whether this prefix can be used in our forum
$forums = explode(",", $prefix['forums']);

if(!in_array($fid, $forums))
{
// This prefix is not in our forum list
continue;
}
}

if($prefix['groups'] != "-1")
{
$prefix_groups = explode(",", $prefix['groups']);

foreach($groups as $group)

			{

			{

				$whereforum = " AND (','||forums||',' LIKE '%,{$fid},%' OR ','||forums||',' LIKE '%,-1,%' OR forums='')";





				if(in_array($group, $prefix_groups) && !isset($prefixes[$prefix['pid']]))
{
// Our group can use this prefix!
$prefixes[$prefix['pid']] = $prefix;
}

			}

			}

			
$query = $db->query("
SELECT pid, prefix
FROM ".TABLE_PREFIX."threadprefixes
WHERE ({$extra_sql}','||groups||',' LIKE '%,{$mybb->user['usergroup']},%' OR ','||groups||',' LIKE '%,-1,%' OR groups='')
{$whereforum}
");
break;
default:
$whereforum = "";
if($fid != 'all')
{
$whereforum = " AND (CONCAT(',',forums,',') LIKE '%,{$fid},%' OR CONCAT(',',forums,',') LIKE '%,-1,%' OR forums='')";
}

$query = $db->query("
SELECT pid, prefix
FROM ".TABLE_PREFIX."threadprefixes
WHERE ({$extra_sql}CONCAT(',',groups,',') LIKE '%,{$mybb->user['usergroup']},%' OR CONCAT(',',groups,',') LIKE '%,-1,%' OR groups='')
{$whereforum}
");
}


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

if(empty($prefixes))
{
return false;
}












	$prefixselect = "";

	$prefixselect = "";

	
if($db->num_rows($query) > 0)
{
$multipleselect = "";
if($multiple != 0)








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

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

if($multiple == 1)
{
$any_selected = "";
if($selected_pid == 'any')

		{

		{

			$multipleselect = " multiple=\"multiple\" size=\"5\"";

			$any_selected = " selected=\"selected\"";

		}

		}

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

if($multiple == 1)














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

$default_selected = "";
if((intval($selected_pid) == 0) && $selected_pid != 'any')
{
$default_selected = " selected=\"selected\"";
}

$prefixselect .= "<option value=\"0\"".$default_selected.">".$lang->no_prefix."</option>\n";

foreach($prefixes as $prefix)
{
$selected = "";
if($prefix['pid'] == $selected_pid)

		{

		{

			$any_selected = "";
if($selected_pid == 'any')
{
$any_selected = " selected=\"selected\"";
}

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

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

			$selected = " selected=\"selected\"";













		}

		}

		
$prefixselect .= "<option value=\"0\"".$default_selected.">".$lang->no_prefix."</option>\n";

while($prefix = $db->fetch_array($query))
{
$selected = "";
if($prefix['pid'] == $selected_pid)
{
$selected = " selected=\"selected\"";
}

$prefixselect .= "<option value=\"".$prefix['pid']."\"".$selected.">".htmlspecialchars_uni($prefix['prefix'])."</option>\n";
}

$prefixselect .= "</select>\n&nbsp;";


$prefixselect .= "<option value=\"".$prefix['pid']."\"".$selected.">".htmlspecialchars_uni($prefix['prefix'])."</option>\n";














	}

	}

	




$prefixselect .= "</select>\n&nbsp;";


	return $prefixselect;
}


	return $prefixselect;
}


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

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

 

$display_reputation = '';


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


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





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

if($reputation < 0)

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

if($reputation < 0)

	{

	{

		$display_reputation .= "reputation_negative";

		$display_reputation .= "reputation_negative";

	}

	}

	elseif($reputation > 0)

	elseif($reputation > 0)

	{

	{

		$display_reputation .= "reputation_positive";

		$display_reputation .= "reputation_positive";

	}
else
{

	}
else
{

		$display_reputation .= "reputation_neutral";
}


		$display_reputation .= "reputation_neutral";
}


Zeile 2731Zeile 2940

/**
* Fetch a color coded version of a warning level (based on it's percentage)


/**
* Fetch a color coded version of a warning level (based on it's percentage)

 *

 *

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

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

Zeile 2740Zeile 2949
	if($level >= 80)
{
return "<span class=\"high_warning\">{$level}%</span>";

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

	}

	}

	else if($level >= 50)

	else if($level >= 50)

	{

	{

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

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

	}

	}

	else
{
return $level."%";

	else
{
return $level."%";

Zeile 2762Zeile 2971
 */
function get_ip()
{

 */
function get_ip()
{

	if(isset($_SERVER['REMOTE_ADDR']))
{
$ip = $_SERVER['REMOTE_ADDR'];
}
elseif(isset($_SERVER['HTTP_X_FORWARDED_FOR']))
{
if(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))















    global $mybb, $plugins;

$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(is_array($addresses[0]))

		{
foreach($addresses[0] as $key => $val)
{

		{
foreach($addresses[0] as $key => $val)
{

Zeile 2779Zeile 3002
				}
}
}

				}
}
}

	}









    }

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





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

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











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

    return $ip;


}

/**

}

/**

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

 */
function get_unviewable_forums($only_readable_threads=false)
{

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

$pid = intval($pid);

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

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









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


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

	}


	}


	if(!is_array($permissioncache))
{
$permissioncache = forum_permissions();
}

	if(!is_array($permissioncache))
{
$permissioncache = forum_permissions();
}





$password_forums = array();

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

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

Zeile 2954Zeile 3172
		else
{
$perms = $mybb->usergroup;

		else
{
$perms = $mybb->usergroup;

		}


		}


		$pwverified = 1;

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

		$pwverified = 1;

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

Zeile 2963Zeile 3181
			if($mybb->cookies['forumpass'][$forum['fid']] != md5($mybb->user['uid'].$forum['password']))
{
$pwverified = 0;

			if($mybb->cookies['forumpass'][$forum['fid']] != md5($mybb->user['uid'].$forum['password']))
{
$pwverified = 0;

			}
}
















			}

$password_forums[$forum['fid']] = $forum['password'];
}
else
{
// Check parents for passwords
$parents = explode(",", $forum['parentlist']);
foreach($parents as $parent)
{
if(isset($password_forums[$parent]) && $mybb->cookies['forumpass'][$parent] != md5($mybb->user['uid'].$password_forums[$parent]))
{
$pwverified = 0;
}
}
}


		if($perms['canview'] == 0 || $pwverified == 0 || ($only_readable_threads == true && $perms['canviewthreads'] == 0))
{
if($unviewableforums)

		if($perms['canview'] == 0 || $pwverified == 0 || ($only_readable_threads == true && $perms['canviewthreads'] == 0))
{
if($unviewableforums)

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

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


return $unviewableforums;





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

}

/**

}

/**

Zeile 2995Zeile 3230
	$format = str_replace("y", my_substr($year, -2), $format);

return $format;

	$format = str_replace("y", my_substr($year, -2), $format);

return $format;

}

}


/**
* Build the breadcrumb navigation trail from the specified items


/**
* Build the breadcrumb navigation trail from the specified items

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

$i = 0;

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

$i = 0;

 
	$activesep = '';

	
if(is_array($navbits))
{

	
if(is_array($navbits))
{

Zeile 3038Zeile 3274
						$sep = $multipage_dropdown.$sep;
}
}

						$sep = $multipage_dropdown.$sep;
}
}

				






// 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 3071Zeile 3311
	$navsize = count($navbits);
$navbits[$navsize]['name'] = $name;
$navbits[$navsize]['url'] = $url;

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

}


}


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

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

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

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





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

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

Zeile 3091Zeile 3331
		}

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

		}

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

		{

		{

			$pforumcache[$val['fid']][$val['pid']] = $val;
}
}

			$pforumcache[$val['fid']][$val['pid']] = $val;
}
}

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

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

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

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

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

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

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

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


if(IN_ARCHIVE == 1)
{


if(defined("IN_ARCHIVE"))
{

					// Set up link to forum in breadcrumb.
if($pforumcache[$fid][$forumnav['pid']]['type'] == 'f' || $pforumcache[$fid][$forumnav['pid']]['type'] == 'c')
{
$navbits[$navsize]['url'] = "{$base_url}forum-".$forumnav['fid'].".html";

					// Set up link to forum in breadcrumb.
if($pforumcache[$fid][$forumnav['pid']]['type'] == 'f' || $pforumcache[$fid][$forumnav['pid']]['type'] == 'c')
{
$navbits[$navsize]['url'] = "{$base_url}forum-".$forumnav['fid'].".html";

					}

					}

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

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

				}

				}

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

$navbits[$navsize]['multipage'] = $multipage;

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

$navbits[$navsize]['multipage'] = $multipage;

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

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

				}
else
{

				}
else
{

Zeile 3137Zeile 3377
			}
}
}

			}
}
}





	return 1;
}


	return 1;
}


Zeile 3151Zeile 3391
	$newnav[0]['name'] = $navbits[0]['name'];
$newnav[0]['url'] = $navbits[0]['url'];
$newnav[0]['options'] = $navbits[0]['options'];

	$newnav[0]['name'] = $navbits[0]['name'];
$newnav[0]['url'] = $navbits[0]['url'];
$newnav[0]['options'] = $navbits[0]['options'];





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

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





/**
* Builds a URL to an archive mode page
*

/**
* Builds a URL to an archive mode page
*

Zeile 3168Zeile 3408
	global $mybb;

// If the server OS is not Windows and not Apache or the PHP is running as a CGI or we have defined ARCHIVE_QUERY_STRINGS, use query strings - DIRECTORY_SEPARATOR checks if running windows

	global $mybb;

// If the server OS is not Windows and not Apache or the PHP is running as a CGI or we have defined ARCHIVE_QUERY_STRINGS, use query strings - DIRECTORY_SEPARATOR checks if running windows

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






	//if((DIRECTORY_SEPARATOR == '\\' && is_numeric(stripos($_SERVER['SERVER_SOFTWARE'], "apache")) == false) || is_numeric(stripos(SAPI_NAME, "cgi")) !== false || defined("ARCHIVE_QUERY_STRINGS"))
if($mybb->settings['seourls_archive'] == 1)
{
$base_url = $mybb->settings['bburl']."/archive/index.php/";
}
else

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

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

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

	}






switch($type)
{


switch($type)
{

Zeile 3190Zeile 3431
			break;
default:
$url = $mybb->settings['bburl']."/archive/index.php";

			break;
default:
$url = $mybb->settings['bburl']."/archive/index.php";

	}


	}


	return $url;
}


	return $url;
}


Zeile 3200Zeile 3441
 */
function debug_page()
{

 */
function debug_page()
{

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

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


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


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

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


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


	if(function_exists("memory_get_usage"))


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

	{

	{

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

		$memory_usage = $lang->unknown;








	}

	}

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


echo "</table>\n";



echo "</table>\n";


Zeile 3328Zeile 3574
{
global $mybb;


{
global $mybb;


	if($mybb->settings['nocacheheaders'] == 1 && $mybb->settings['standardheaders'] != 1)

	if($mybb->settings['nocacheheaders'] == 1)

	{
header("Expires: Sat, 1 Jan 2000 01:00:00 GMT");
header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");

	{
header("Expires: Sat, 1 Jan 2000 01:00:00 GMT");
header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");

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


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


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

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

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

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

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


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


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

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

	{
if($hours == 1)
{

	{
if($hours == 1)
{

Zeile 3499Zeile 3745
		}
}


		}
}


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

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

	{
if($minutes == 1)
{

	{
if($minutes == 1)
{

Zeile 3511Zeile 3757
		}
}


		}
}


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

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

	{
if($seconds == 1)
{

	{
if($seconds == 1)
{

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

		{
$ignore = array($ignore);
}

		



		$form_html = "";

		$form_html = "";

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


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

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

Zeile 3708Zeile 3952
				if(in_array($name, $ignore))
{
continue;

				if(in_array($name, $ignore))
{
continue;

				}

				}

				

				

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

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

			}
}


			}
}


Zeile 3719Zeile 3963
	else
{
if(isset($_SERVER['QUERY_STRING']))

	else
{
if(isset($_SERVER['QUERY_STRING']))

		{

		{

			$location .= "?".htmlspecialchars_uni($_SERVER['QUERY_STRING']);

			$location .= "?".htmlspecialchars_uni($_SERVER['QUERY_STRING']);

		}

		}

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

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

Zeile 3730Zeile 3974
		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 3752Zeile 3996
				$location .= implode("&amp;", $addloc);
}
}

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

	







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


		return $location;
}
}

		return $location;
}
}

Zeile 3772Zeile 4021
	global $db, $themeselect, $tcache, $lang, $mybb, $limit;

if($tid == 0)

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

if($tid == 0)

	{

	{

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

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

Zeile 3782Zeile 4031
	if(!is_array($tcache))
{
$query = $db->simple_select("themes", "name, pid, tid, allowedgroups", "pid != '0'", array('order_by' => 'pid, name'));

	if(!is_array($tcache))
{
$query = $db->simple_select("themes", "name, pid, tid, allowedgroups", "pid != '0'", array('order_by' => 'pid, name'));





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

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

Zeile 3827Zeile 4076

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


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

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

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

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


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


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

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

		{

		{

			return utf8_encode($str);
}
else

			return utf8_encode($str);
}
else

Zeile 3977Zeile 4226
	{
$message = convert_through_utf8($message);


	{
$message = convert_through_utf8($message);


		if(!($new_message = @preg_replace("#(?>[^\s&/<>\"\\-\.\[\]]{{$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&/<>\"\\-\.\[\]]{{$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);

Zeile 4101Zeile 4350
		'Y',
'j',
'S',

		'Y',
'j',
'S',

		'l',

 
		'F',

		'F',

 
		'l',

		'M',
);


		'M',
);


 
	$html = array(
'&#109;',
'&#99;',
'&#68;',
'&#121;',
'&#89;',
'&#106;',
'&#83;',
'&#70;',
'&#108;',
'&#77;',
);

$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 4114Zeile 4379
		$by,
($bd[0] == 0 ? my_substr($bd, 1) : $bd),
($bd == 1 || $bd == 21 || $bd == 31 ? 'st' : ($bd == 2 || $bd == 22 ? 'nd' : ($bd == 3 || $bd == 23 ? 'rd' : 'th'))),

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

		$wd,

 
		$bmonth[$bm-1],

		$bmonth[$bm-1],

 
		$wd,

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

		($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

	
// Do we have the full month in our output?
// If so there's no need for the short month

Zeile 4283Zeile 4548

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


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

 *

 *

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

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

Zeile 4294Zeile 4559
	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 4315Zeile 4580
 * @return int The uped string.
*/
function my_strtoupper($string)

 * @return int The uped string.
*/
function my_strtoupper($string)

{

{

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

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

Zeile 4356Zeile 4621
function unichr($c)
{
if($c <= 0x7F)

function unichr($c)
{
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);
}
else if($c <= 0xFFFF)
{
return chr(0xE0 | $c >> 12) . chr(0x80 | $c >> 6 & 0x3F)

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

                                    . chr(0x80 | $c & 0x3F);

                                    . chr(0x80 | $c & 0x3F);

    }
else if($c <= 0x10FFFF)
{

    }
else if($c <= 0x10FFFF)
{

Zeile 4387Zeile 4652
 * @return string The link to the event poster.
*/
function get_event_poster($event)

 * @return string The link to the event poster.
*/
function get_event_poster($event)

{

{

	$event['username'] = format_name($event['username'], $event['usergroup'], $event['displaygroup']);
$event_poster = build_profile_link($event['username'], $event['author']);
return $event_poster;

	$event['username'] = format_name($event['username'], $event['usergroup'], $event['displaygroup']);
$event_poster = build_profile_link($event['username'], $event['author']);
return $event_poster;

Zeile 4401Zeile 4666
 */
function get_event_date($event)
{

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

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

return $event_date;

}


}


/**
* Get the profile link.
*

/**
* Get the profile link.
*

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

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

	return htmlspecialchars_uni($link);
}

	return htmlspecialchars_uni($link);
}


/**
* Get the announcement link.


/**
* Get the announcement link.

Zeile 4449Zeile 4716
	{
// Return Guest phrase for no UID, no guest nickname
return $lang->guest;

	{
// Return Guest phrase for no UID, no guest nickname
return $lang->guest;

	}

	}

	elseif($uid == 0)

	elseif($uid == 0)

	{

	{

		// Return the guest's nickname if user is a guest but has a nickname
return $username;
}

		// Return the guest's nickname if user is a guest but has a nickname
return $username;
}

Zeile 4459Zeile 4726
	{
// Build the profile link for the registered user
if(!empty($target))

	{
// Build the profile link for the registered user
if(!empty($target))

		{

		{

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

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

		}

		}


if(!empty($onclick))
{


if(!empty($onclick))
{

Zeile 4469Zeile 4736
		}

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 4505Zeile 4772
function get_thread_link($tid, $page=0, $action='')
{
if($page > 1)

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

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

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

		else
{
$link = THREAD_URL_PAGED;

		else
{
$link = THREAD_URL_PAGED;

Zeile 4531Zeile 4798
			$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 4552Zeile 4819
	else
{
$link = str_replace("{pid}", $pid, POST_URL);

	else
{
$link = str_replace("{pid}", $pid, POST_URL);

		return htmlspecialchars_uni($link);
}
}

/**

		return htmlspecialchars_uni($link);
}
}

/**

 * Build the event link.
*
* @param int The event ID of the event

 * Build the event link.
*
* @param int The event ID of the event

Zeile 4566Zeile 4833
{
$link = str_replace("{eid}", $eid, EVENT_URL);
return htmlspecialchars_uni($link);

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

}


}


/**
* Build the link to a specified date on the calendar
*

/**
* Build the link to a specified date on the calendar
*

Zeile 4588Zeile 4855
		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);
return htmlspecialchars_uni($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);

	}
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
{
$link = str_replace("{calendar}", $calendar, CALENDAR_URL);

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

Zeile 4620Zeile 4887
	if($week < 0)
{
$week = str_replace('-', "n", $week);

	if($week < 0)
{
$week = str_replace('-', "n", $week);

	}

	}

	$link = str_replace("{week}", $week, CALENDAR_URL_WEEK);
$link = str_replace("{calendar}", $calendar, $link);
return htmlspecialchars_uni($link);

	$link = str_replace("{week}", $week, CALENDAR_URL_WEEK);
$link = str_replace("{calendar}", $calendar, $link);
return htmlspecialchars_uni($link);

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

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





		return $user_cache[$uid];
}
}

		return $user_cache[$uid];
}
}



 

/**
* Get the forum of a specific forum id.


/**
* Get the forum of a specific forum id.

Zeile 4672Zeile 4938
	if(!isset($forum_cache) || is_array($forum_cache))
{
$forum_cache = $cache->read("forums");

	if(!isset($forum_cache) || is_array($forum_cache))
{
$forum_cache = $cache->read("forums");

	}


	}


	if(!$forum_cache[$fid])
{
return false;

	if(!$forum_cache[$fid])
{
return false;

Zeile 4705Zeile 4971
 * @return string The database row of the thread.
*/
function get_thread($tid, $recache = false)

 * @return string The database row of the thread.
*/
function get_thread($tid, $recache = false)

{
global $db;

{
global $db;

	static $thread_cache;

if(isset($thread_cache[$tid]) && !$recache)

	static $thread_cache;

if(isset($thread_cache[$tid]) && !$recache)

Zeile 4726Zeile 4992
		else
{
$thread_cache[$tid] = false;

		else
{
$thread_cache[$tid] = false;

			return false;

			return false;

		}
}
}

		}
}
}

Zeile 4736Zeile 5002
 *
* @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.

 */

 */

function get_post($pid)
{
global $db;

function get_post($pid)
{
global $db;

Zeile 4747Zeile 5013
		return $post_cache[$pid];
}
else

		return $post_cache[$pid];
}
else

	{

	{

		$query = $db->simple_select("posts", "*", "pid='".intval($pid)."'");
$post = $db->fetch_array($query);


		$query = $db->simple_select("posts", "*", "pid='".intval($pid)."'");
$post = $db->fetch_array($query);


Zeile 4790Zeile 5056
				if(my_strpos(",".$forum1['parentlist'].",", ",".$fid.",") !== false && !in_array($fid1, $inactive))
{
$inactive[] = $fid1;

				if(my_strpos(",".$forum1['parentlist'].",", ",".$fid.",") !== false && !in_array($fid1, $inactive))
{
$inactive[] = $fid1;

				}
}

				}
}

		}
}
$inactiveforums = implode(",", $inactive);

		}
}
$inactiveforums = implode(",", $inactive);

Zeile 4813Zeile 5079
	if($mybb->settings['failedlogincount'] == 0)
{
return 1;

	if($mybb->settings['failedlogincount'] == 0)
{
return 1;

	}

	}

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

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





	// Use cookie if possible, otherwise use session

	// Use cookie if possible, otherwise use session

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

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






	if(empty($cookielogins) || $cookielogins < $session->logins)
{
$loginattempts = $session->logins;
}
else
{
$loginattempts = $cookielogins;
}

if(empty($cookietime) || $cookietime < $session->failedlogin)

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










	{

	{

		$failedlogin = $session->failedlogin;

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

	}

	}

	else



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

	{

	{

		$failedlogin = $cookietime;

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

	}

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

	}

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

Zeile 4850Zeile 5107
		if(empty($mybb->cookies['failedlogin']))
{
$failedtime = $now;

		if(empty($mybb->cookies['failedlogin']))
{
$failedtime = $now;

		}

		}

		else
{
$failedtime = $mybb->cookies['failedlogin'];

		else
{
$failedtime = $mybb->cookies['failedlogin'];

Zeile 4893Zeile 5150
			if($fatal)
{
error($lang->sprintf($lang->failed_login_wait, $hoursleft, $minsleft, $secsleft));

			if($fatal)
{
error($lang->sprintf($lang->failed_login_wait, $hoursleft, $minsleft, $secsleft));

			}

			}


return false;
}


return false;
}

Zeile 4935Zeile 5192
	{
$uid_string = " AND uid != '".intval($uid)."'";
}

	{
$uid_string = " AND uid != '".intval($uid)."'";
}

	$query = $db->simple_select("users", "COUNT(email) as emails", "email = '".$db->escape_string(my_strtolower($email))."'{$uid_string}");

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

Zeile 5005Zeile 5262
	{
$mybb->settings['minsearchword'] = 3;
}

	{
$mybb->settings['minsearchword'] = 3;
}

 

if(is_array($terms))
{
$terms = implode(' ', $terms);
}


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


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

Zeile 5027Zeile 5289
			if($phrase != "")
{
if($inquote)

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

				{

				{

					$words[] = trim($phrase);
}
else
{
$split_words = preg_split("#\s{1,}#", $phrase, -1);
if(!is_array($split_words))

					$words[] = trim($phrase);
}
else
{
$split_words = preg_split("#\s{1,}#", $phrase, -1);
if(!is_array($split_words))

					{

					{

						continue;
}
foreach($split_words as $word)

						continue;
}
foreach($split_words as $word)

Zeile 5055Zeile 5317
	{
$terms = htmlspecialchars_uni($terms);
$split_words = preg_split("#\s{1,}#", $terms, -1);

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

		if(!is_array($split_words))

		if(is_array($split_words))

		{

		{

			continue;
}
foreach($split_words as $word)
{
if(!$word || strlen($word) < $mybb->settings['minsearchword'])

			foreach($split_words as $word)





			{

			{

				continue;





				if(!$word || strlen($word) < $mybb->settings['minsearchword'])
{
continue;
}
$words[] = trim($word);

			}

			}

			$words[] = trim($word);

 
		}

		}



 
	}

if(!is_array($words))

	}

if(!is_array($words))

Zeile 5093Zeile 5353
		}

// Now make PREG compatible

		}

// Now make PREG compatible

		$find = "#(?!<.*?)(".preg_quote($word, "#").")(?![^<>]*?>)#i";

		$find = "#(?!<.*?)(".preg_quote($word, "#").")(?![^<>]*?>)#ui";

		$replacement = "<span class=\"highlight\" style=\"padding-left: 0px; padding-right: 0px;\">$1</span>";
$highlight_cache[$find] = $replacement;
}

		$replacement = "<span class=\"highlight\" style=\"padding-left: 0px; padding-right: 0px;\">$1</span>";
$highlight_cache[$find] = $replacement;
}

Zeile 5102Zeile 5362
}

/**

}

/**

 * Converts a decimal reference of a character to its UTF-8 equivilant

 * Converts a decimal reference of a character to its UTF-8 equivalent

 * (Code by Anne van Kesteren, http://annevankesteren.nl/2005/05/character-references)
*
* @param string Decimal value of a character reference

 * (Code by Anne van Kesteren, http://annevankesteren.nl/2005/05/character-references)
*
* @param string Decimal value of a character reference

Zeile 5184Zeile 5444
 */
function is_banned_email($email, $update_lastuse=false)
{

 */
function is_banned_email($email, $update_lastuse=false)
{

	global $db;
$query = $db->simple_select("banfilters", "*", "type='3'");
while($banned_email = $db->fetch_array($query))
{
// Make regular expression * match
$banned_email['filter'] = str_replace('\*', '(.*)', preg_quote($banned_email['filter'], '#'));
if(preg_match("#{$banned_email['filter']}#i", $email))
{
// Updating last use
if($update_lastuse == true)
{
$db->update_query("banfilters", array("lastuse" => TIME_NOW), "fid='{$banned_email['fid']}'");















	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(is_array($banned_cache) && !empty($banned_cache))
{
foreach($banned_cache as $banned_email)
{
// Make regular expression * match
$banned_email['filter'] = str_replace('\*', '(.*)', preg_quote($banned_email['filter'], '#'));

if(preg_match("#{$banned_email['filter']}#i", $email))
{
// Updating last use
if($update_lastuse == true)
{
$db->update_query("banfilters", array("lastuse" => TIME_NOW), "fid='{$banned_email['fid']}'");
}
return true;

			}

			}

			return true;

 
		}
}

		}
}

 


	// Still here - good email
return false;
}

	// Still here - good email
return false;
}

Zeile 5226Zeile 5500
		if(!$banned_ip['filter'])
{
continue;

		if(!$banned_ip['filter'])
{
continue;

		}

		}

		
// Make regular expression * match
$banned_ip['filter'] = str_replace('\*', '(.*)', preg_quote($banned_ip['filter'], '#'));

		
// Make regular expression * match
$banned_ip['filter'] = str_replace('\*', '(.*)', preg_quote($banned_ip['filter'], '#'));

		if(preg_match("#{$banned_ip['filter']}#i", $ip_address))

		if(preg_match("#^{$banned_ip['filter']}$#i", $ip_address))

		{
// Updating last use
if($update_lastuse == true)

		{
// Updating last use
if($update_lastuse == true)

Zeile 5240Zeile 5514
			return true;
}
}

			return true;
}
}

 


	// Still here - good ip
return false;
}

	// Still here - good ip
return false;
}

Zeile 5325Zeile 5600
	}
$select .= "</select>";
return $select;

	}
$select .= "</select>";
return $select;

}

/**

}

/**

 * Fetch the contents of a remote fle.
*
* @param string The URL of the remote file

 * Fetch the contents of a remote fle.
*
* @param string The URL of the remote file

Zeile 5337Zeile 5612
{
$post_body = '';
if(!empty($post_data))

{
$post_body = '';
if(!empty($post_data))

	{

	{

		foreach($post_data as $key => $val)
{
$post_body .= '&'.urlencode($key).'='.urlencode($val);

		foreach($post_data as $key => $val)
{
$post_body .= '&'.urlencode($key).'='.urlencode($val);

Zeile 5346Zeile 5621
	}

if(function_exists("curl_init"))

	}

if(function_exists("curl_init"))

	{

	{

		$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, 0);

		$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, 0);

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

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

		{

		{

			$url['path'] = "/";
}
if($url['query'])

			$url['path'] = "/";
}
if($url['query'])

Zeile 5399Zeile 5674
		}

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

		}

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

		$headers[] = "Connection: Close";
$headers[] = "\r\n";


		$headers[] = "Connection: Close";
$headers[] = '';


		if(!empty($post_body))

		if(!empty($post_body))

		{

		{

			$headers[] = $post_body;

			$headers[] = $post_body;

 
		}
else
{
// 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);

Zeile 5424Zeile 5704
	{
return @implode("", @file($url));
}

	{
return @implode("", @file($url));
}

	else
{
return false;
}

	else
{
return false;
}

}

/**

}

/**

Zeile 5470Zeile 5750
		if(is_array($escape))
{
function escaped_explode_escape($string)

		if(is_array($escape))
{
function escaped_explode_escape($string)

			{

			{

				return preg_quote($string, "#");
}
$escape_preg = "(".implode("|", array_map("escaped_explode_escape", $escape)).")";

				return preg_quote($string, "#");
}
$escape_preg = "(".implode("|", array_map("escaped_explode_escape", $escape)).")";

Zeile 5516Zeile 5796
 * Fetch an IPv4 long formatted range for searching IPv4 IP addresses.
*
* @param string The IP address to convert to a range based LONG

 * Fetch an IPv4 long formatted range for searching IPv4 IP addresses.
*
* @param string The IP address to convert to a range based LONG

 * @rturn mixed If a full IP address is provided, the ip2long equivilent, otherwise an array of the upper & lower extremities of the IP

 * @rturn mixed If a full IP address is provided, the ip2long equivalent, otherwise an array of the upper & lower extremities of the IP

 */
function fetch_longipv4_range($ip)
{

 */
function fetch_longipv4_range($ip)
{

Zeile 5525Zeile 5805

if($ip == "*")
{


if($ip == "*")
{

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

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

	}

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

	}

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

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

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

			return ip2long($ip);

			return my_ip2long($ip);

		}
else
{

		}
else
{

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

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

		}
}
// Wildcard based IP provided

		}
}
// Wildcard based IP provided

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

			}
$sep = ".";
}

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

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

	}
}


	}
}


Zeile 5592Zeile 5872
		"0-0-2" => "2 {$lang->years}"
);


		"0-0-2" => "2 {$lang->years}"
);


	$plugins->run_hooks_by_ref("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 5665Zeile 5945
		);
$db->update_query("users", $updated_user, "uid='".intval($uid)."'");
}

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

}

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

 
}

/**

}

/**

Zeile 5789Zeile 6036
 */
function my_ip2long($ip)
{

 */
function my_ip2long($ip)
{

	$ip = ip2long($ip);
if($ip >= 2147483648) // Won't occur on 32-bit PHP












	$ip_long = ip2long($ip);

if(!$ip_long)
{
$ip_long = sprintf("%u", ip2long($ip));

if(!$ip_long)
{
return 0;
}
}

if($ip_long >= 2147483648) // Won't occur on 32-bit PHP

	{

	{

		$ip -= 4294967296;

		$ip_long -= 4294967296;

	}

	}

	return $ip;



return $ip_long;

}

/**

}

/**

Zeile 5914Zeile 6173
 * Returns a signed value equal to an integer
*
* @param int The integer

 * Returns a signed value equal to an integer
*
* @param int The integer

 * @return string The signed equivallent

 * @return string The signed equivalent

 */
function signed($int)
{

 */
function signed($int)
{

Zeile 5932Zeile 6191
 * Returns a securely generated seed for PHP's RNG (Random Number Generator)
*
* @param int Length of the seed bytes (8 is default. Provides good cryptographic variance)

 * Returns a securely generated seed for PHP's RNG (Random Number Generator)
*
* @param int Length of the seed bytes (8 is default. Provides good cryptographic variance)

 * @return int An integer equivilent of a secure hexadecimal seed

 * @return int An integer equivalent of a secure hexadecimal seed

 */
function secure_seed_rng($count=8)
{

 */
function secure_seed_rng($count=8)
{

Zeile 5972Zeile 6231
 * @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

 * @param int Optional lowest value to be returned (default: 0) 
* @param int Optional highest value to be returned (default: mt_getrandmax())
* @param boolean True forces it to reseed the RNG first

 * @return int An integer equivilent of a secure hexadecimal seed

 * @return int An integer equivalent of a secure hexadecimal seed

 */
function my_rand($min=null, $max=null, $force_seed=false)
{

 */
function my_rand($min=null, $max=null, $force_seed=false)
{

Zeile 6028Zeile 6287
		0x0A => 1,
0x0D => 1,
0x0B => 1,

		0x0A => 1,
0x0D => 1,
0x0B => 1,

 
		0xAD => 1,
0xA0 => 1,
0xAD => 1,
0xBF => 1,
0x81 => 1,
0x8D => 1,
0x90 => 1,
0x9D => 1,

		0xCC => array(0xB7 => 1, 0xB8 => 1), // \x{0337} or \x{0338}
0xE1 => array(0x85 => array(0x9F => 1, 0xA0 => 1)), // \x{115F} or \x{1160}
0xE2 => array(0x80 => array(0x80 => 1, 0x81 => 1, 0x82 => 1, 0x83 => 1, 0x84 => 1, 0x85 => 1, 0x86 => 1, 0x87 => 1, 0x88 => 1, 0x89 => 1, 0x8A => 1, 0x8B => 1, // \x{2000} to \x{200B}

		0xCC => array(0xB7 => 1, 0xB8 => 1), // \x{0337} or \x{0338}
0xE1 => array(0x85 => array(0x9F => 1, 0xA0 => 1)), // \x{115F} or \x{1160}
0xE2 => array(0x80 => array(0x80 => 1, 0x81 => 1, 0x82 => 1, 0x83 => 1, 0x84 => 1, 0x85 => 1, 0x86 => 1, 0x87 => 1, 0x88 => 1, 0x89 => 1, 0x8A => 1, 0x8B => 1, // \x{2000} to \x{200B}

Zeile 6046Zeile 6313
		0x0A => 1,
0x0D => 1,
0x0B => 1,

		0x0A => 1,
0x0D => 1,
0x0B => 1,

 
		0xA0 => array(0xC2 => 1),
0xAD => array(0xC2 => 1),
0xBF => array(0xC2 => 1),
0x81 => array(0xC2 => 1),
0x8D => array(0xC2 => 1),
0x90 => array(0xC2 => 1),
0x9D => array(0xC2 => 1),

		0xB8 => array(0xCC => 1), // \x{0338}
0xB7 => array(0xCC => 1), // \x{0337}
0xA0 => array(0x85 => array(0xE1 => 1)), // \x{1160}

		0xB8 => array(0xCC => 1), // \x{0338}
0xB7 => array(0xCC => 1), // \x{0337}
0xA0 => array(0x85 => array(0xE1 => 1)), // \x{1160}