Vergleich inc/functions.php - 1.6.5 - 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 5639 2011-10-26 09:16:47Z Tomm $

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

Zeile 76Zeile 82
		if($mybb->debug_mode == true)
{
debug_page();

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

		}
}


		}
}


	$contents = str_replace("<debugstuff>", "", $contents);
$contents = $plugins->run_hooks("pre_output_page", $contents);


	$contents = str_replace("<debugstuff>", "", $contents);
$contents = $plugins->run_hooks("pre_output_page", $contents);


Zeile 88Zeile 94
	}

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

	}

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

	

	

	echo $contents;

	echo $contents;





	$plugins->run_hooks("post_output_page");

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

 *

 *

 * @param mixed The name of the function.
* @param mixed An array of arguments for the function
* @return boolean True if function exists, otherwise false.

 * @param mixed The name of the function.
* @param mixed An array of arguments for the function
* @return boolean True if function exists, otherwise false.

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

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

	}

	}


return false;
}


return false;
}

Zeile 137Zeile 137
function run_shutdown()
{
global $config, $db, $cache, $plugins, $error_handler, $shutdown_functions, $shutdown_queries, $done_shutdown, $mybb;

function run_shutdown()
{
global $config, $db, $cache, $plugins, $error_handler, $shutdown_functions, $shutdown_queries, $done_shutdown, $mybb;





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

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

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

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

		}

		}

		
if(isset($config))
{

		
if(isset($config))
{

Zeile 243Zeile 243
	{
// Lock the queue so no other messages can be sent whilst these are (for popular boards)
$cache->update_mailqueue(0, TIME_NOW);

	{
// Lock the queue so no other messages can be sent whilst these are (for popular boards)
$cache->update_mailqueue(0, TIME_NOW);





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


Zeile 255Zeile 255
			if($db->affected_rows() == 1)
{
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");
}

/**
* Parses the contents of a page before outputting it.

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

/**
* Parses the contents of a page before outputting it.

 *

 *

 * @param string The contents of the page.
* @return string The parsed page.
*/

 * @param string The contents of the page.
* @return string The parsed page.
*/

Zeile 278Zeile 278
	$contents = str_replace('<archive_url>', $archive_url, $contents);

if($htmldoctype)

	$contents = str_replace('<archive_url>', $archive_url, $contents);

if($htmldoctype)

	{

	{

		$contents = $htmldoctype.$contents;
}
else

		$contents = $htmldoctype.$contents;
}
else

Zeile 328Zeile 328

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


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

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

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

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

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

Zeile 339Zeile 339
			$dstcorrection = $mybbadmin['dst'];
}
else

			$dstcorrection = $mybbadmin['dst'];
}
else

		{

		{

			$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 351
			if(my_substr($offset, 0, 1) != "-")
{
$offset = "+".$offset;

			if(my_substr($offset, 0, 1) != "-")
{
$offset = "+".$offset;

			}
}

			}
}

	}

if($offset == "-")

	}

if($offset == "-")

Zeile 434Zeile 434
		{
require_once MYBB_ROOT."inc/mailhandlers/php.php";
$mail = new PhpMail();

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

		}
}


		}
}


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

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

Zeile 447Zeile 447
	}

// Using PHP based mail()

	}

// Using PHP based mail()

	else

	else

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

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

Zeile 637Zeile 637

/**
* Produce a friendly error message page


/**
* Produce a friendly error message page

 *

 *

 * @param string The error message to be shown
* @param string The title of the message shown in the title of the page and the error table
*/

 * @param string The error message to be shown
* @param string The title of the message shown in the title of the page and the error table
*/

Zeile 750Zeile 750
	else
{
// Redirect to where the user came from

	else
{
// Redirect to where the user came from

		if($_SERVER['HTTP_REFERER'])


		$redirect_url = $_SERVER['PHP_SELF'];
if($_SERVER['QUERY_STRING'])

		{

		{

			$redirect_url = htmlentities($_SERVER['HTTP_REFERER']);

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

		}

		}

		else





$redirect_url = htmlspecialchars_uni($redirect_url);

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

		{

		{

			$redirect_url = '';












			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")."\";");
}





	error($errorpage);

	error($errorpage);

}


}


/**
* Redirect the user to a given URL with a given message
*

/**
* Redirect the user to a given URL with a given message
*

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

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

	{

	{

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

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

		$url = htmlspecialchars($url);

		$url = htmlspecialchars_uni($url);


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


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

Zeile 825Zeile 839

run_shutdown();



run_shutdown();


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

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

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

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

		}
}


		}
}


	exit;
}


	exit;
}


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


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


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



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

$prevpage = '';

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

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

Zeile 870Zeile 885

// Maximum number of "page bits" to show
if(!$mybb->settings['maxmultipagelinks'])


// Maximum number of "page bits" to show
if(!$mybb->settings['maxmultipagelinks'])

	{

	{

		$mybb->settings['maxmultipagelinks'] = 5;

		$mybb->settings['maxmultipagelinks'] = 5;

	}

	}


$from = $page-floor($mybb->settings['maxmultipagelinks']/2);
$to = $page+floor($mybb->settings['maxmultipagelinks']/2);


$from = $page-floor($mybb->settings['maxmultipagelinks']/2);
$to = $page+floor($mybb->settings['maxmultipagelinks']/2);





	if($from <= 0)
{
$from = 1;
$to = $from+$mybb->settings['maxmultipagelinks']-1;

	if($from <= 0)
{
$from = 1;
$to = $from+$mybb->settings['maxmultipagelinks']-1;

	}


	}


	if($to > $pages)
{
$to = $pages;

	if($to > $pages)
{
$to = $pages;

Zeile 894Zeile 909
	}

if($to == 0)

	}

if($to == 0)

	{

	{

		$to = $pages;
}


		$to = $pages;
}


 
	$start = '';

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

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

Zeile 909Zeile 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 929Zeile 946
		}
}


		}
}


 
	$end = '';

	if($to < $pages)

	if($to < $pages)

	{

	{

		if($to+1 == $pages)
{
$lang->multipage_link_end = '';

		if($to+1 == $pages)
{
$lang->multipage_link_end = '';

Zeile 940Zeile 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 1014Zeile 1034

// If no user id is specified, assume it is the current user
if($uid == 0)


// If no user id is specified, assume it is the current user
if($uid == 0)

	{

	{

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


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


Zeile 1025Zeile 1045
		if($user_cache[$uid]['permissions'])
{
return $user_cache[$uid]['permissions'];

		if($user_cache[$uid]['permissions'])
{
return $user_cache[$uid]['permissions'];

		}

		}


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


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

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

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

	}

	}


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



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


Zeile 1085Zeile 1105
				if(isset($usergroup[$perm]))
{
$permbit = $usergroup[$perm];

				if(isset($usergroup[$perm]))
{
$permbit = $usergroup[$perm];

				}

				}

				else

				else

				{

				{

					$permbit = "";
}


					$permbit = "";
}


Zeile 1097Zeile 1117
					$usergroup[$perm] = 0;
continue;
}

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





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

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

Zeile 1120Zeile 1140
	global $cache, $groupscache, $displaygroupfields;

if(!is_array($groupscache))

	global $cache, $groupscache, $displaygroupfields;

if(!is_array($groupscache))

	{

	{

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


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


Zeile 1229Zeile 1249

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



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


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

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

	{
return $groupperms;
}

	{
return $groupperms;
}

Zeile 1311Zeile 1331
	{
$forum_cache = cache_forums();
if(!$forum_cache)

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

		{

		{

			return false;
}
}

			return false;
}
}

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

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

			}
}

			}
}

	}

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

	}

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

Zeile 1343Zeile 1363
			if($password == $mybb->input['pwverify'])
{
my_setcookie("forumpass[$fid]", md5($mybb->user['uid'].$mybb->input['pwverify']), null, true);

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

				$showform = false;
}

				$showform = false;
}

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

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

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

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

			{

			{

				$showform = true;
}
else

				$showform = true;
}
else

Zeile 1398Zeile 1418
	static $modpermscache;

if($uid < 1)

	static $modpermscache;

if($uid < 1)

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

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


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

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


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

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

Zeile 1580Zeile 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 1596Zeile 1617
		$dbicon['name'] = htmlspecialchars_uni($dbicon['name']);

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

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

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 = "";
}

Zeile 1711Zeile 1732
		return false;
}


		return false;
}


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

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


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


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

Zeile 1735Zeile 1756
	global $mybb;

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

	global $mybb;

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

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

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

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








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


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

	



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

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

 

/**
* Verifies that data passed is an array
*
* @param array Data to unserialize
* @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 1817Zeile 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 1845Zeile 1896
				}
}
else

				}
}
else

			{

			{

				$new_stats[$counter] = $changes[$counter];
}
// Less than 0? That's bad

				$new_stats[$counter] = $changes[$counter];
}
// Less than 0? That's bad

Zeile 1887Zeile 1938
		"numposts" => $stats['numposts']
);
$db->replace_query("stats", $todays_stats, "dateline");

		"numposts" => $stats['numposts']
);
$db->replace_query("stats", $todays_stats, "dateline");





	$cache->update("stats", $stats, "dateline");
}


	$cache->update("stats", $stats, "dateline");
}


Zeile 2077Zeile 2128
	if(count($update_query) > 0)
{
$db->update_query("threads", $update_query, "tid='".intval($tid)."'");

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

	}


	}


	unset($update_query, $thread);

	unset($update_query, $thread);





	update_thread_data($tid);
}


	update_thread_data($tid);
}


Zeile 2090Zeile 2141
 * @param int The thread ID
*/
function update_thread_data($tid)

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

{

{

	global $db;

	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 2102Zeile 2162
	);
$lastpost = $db->fetch_array($query);


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


	$db->free_result($query);


	$db->free_result($query);


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

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

Zeile 2150Zeile 2210
}

function update_forum_count($fid)

}

function update_forum_count($fid)

{

{

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

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

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

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

{
global $moderation;

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

{
global $moderation;

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

		$moderation = new Moderation;
}


		$moderation = new Moderation;
}


Zeile 2216Zeile 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 2243Zeile 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 2294Zeile 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 2311Zeile 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.


/**
* Generates a random string.

Zeile 2320Zeile 2390
 * @return string The random string.
*/
function random_str($length="8")

 * @return string The random string.
*/
function random_str($length="8")

{

{

	$set = array("a","A","b","B","c","C","d","D","e","E","f","F","g","G","h","H","i","I","j","J","k","K","l","L","m","M","n","N","o","O","p","P","q","Q","r","R","s","S","t","T","u","U","v","V","w","W","x","X","y","Y","z","Z","1","2","3","4","5","6","7","8","9");
$str = '';

	$set = array("a","A","b","B","c","C","d","D","e","E","f","F","g","G","h","H","i","I","j","J","k","K","l","L","m","M","n","N","o","O","p","P","q","Q","r","R","s","S","t","T","u","U","v","V","w","W","x","X","y","Y","z","Z","1","2","3","4","5","6","7","8","9");
$str = '';





	for($i = 1; $i <= $length; ++$i)
{
$ch = my_rand(0, count($set)-1);
$str .= $set[$ch];

	for($i = 1; $i <= $length; ++$i)
{
$ch = my_rand(0, count($set)-1);
$str .= $set[$ch];

	}


	}


	return $str;
}


	return $str;
}


Zeile 2362Zeile 2432
	if($userin == 0)
{
$format = "{username}";

	if($userin == 0)
{
$format = "{username}";

	}

$format = stripslashes($format);

	}

$format = stripslashes($format);


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


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

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


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


			if($editor_lang_strings[$key+1])

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

			{
$editor_language .= ",";
}

			{
$editor_language .= ",";
}

Zeile 2494Zeile 2564
		{
reset($smiliecache);


		{
reset($smiliecache);


 
			$getmore = '';

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

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

Zeile 2549Zeile 2620
	}

return $clickablesmilies;

	}

return $clickablesmilies;

}

/**

}

/**

 * Builds thread prefixes and returns a selected prefix (or all)
*
* @param int The prefix ID (0 to return all)

 * Builds thread prefixes and returns a selected prefix (or all)
*
* @param int The prefix ID (0 to return all)

Zeile 2563Zeile 2634
	static $prefixes_cache;

if(is_array($prefixes_cache))

	static $prefixes_cache;

if(is_array($prefixes_cache))

	{

	{

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

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





		return $prefixes_cache;
}

		return $prefixes_cache;
}





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

if(!is_array($prefix_cache))

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

if(!is_array($prefix_cache))

	{

	{

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


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


Zeile 2586Zeile 2657
	}

$prefixes_cache = array();

	}

$prefixes_cache = array();

	foreach($prefix_cache as $prefix)
{

	foreach($prefix_cache as $prefix)
{

		$prefixes_cache[$prefix['pid']] = $prefix;

		$prefixes_cache[$prefix['pid']] = $prefix;

	}


	}


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

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

	}

	}

	else if(!empty($prefixes_cache))
{
return $prefixes_cache;

	else if(!empty($prefixes_cache))
{
return $prefixes_cache;

	}


	}


	return false;
}


	return false;
}


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

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

	}


	}


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

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

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

			$groups[] = $group;
}
}





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

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

Zeile 2646Zeile 2717
			$forums = explode(",", $prefix['forums']);

if(!in_array($fid, $forums))

			$forums = explode(",", $prefix['forums']);

if(!in_array($fid, $forums))

			{

			{

				// This prefix is not in our forum list
continue;
}

				// This prefix is not in our forum list
continue;
}

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

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

		}

		}

	}

if(empty($prefixes))

	}

if(empty($prefixes))

Zeile 2692Zeile 2763
		if($selected_pid == 'any')
{
$any_selected = " selected=\"selected\"";

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

		}


		}


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

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

	}


	}


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

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


	}

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


	foreach($prefixes as $prefix)
{
$selected = "";

	foreach($prefixes as $prefix)
{
$selected = "";

Zeile 2740Zeile 2811
		}

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

		}

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

		{

		{

			$encoding = "x-gzip";
}


			$encoding = "x-gzip";
}


Zeile 2775Zeile 2846

/**
* Log the actions of a moderator.


/**
* Log the actions of a moderator.

 *

 *

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

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

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

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






$display_reputation = '';


	if($uid != 0)

	if($uid != 0)

	{

	{

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

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

	}


	}


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

if($reputation < 0)
{
$display_reputation .= "reputation_negative";

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

if($reputation < 0)
{
$display_reputation .= "reputation_negative";

	}

	}

	elseif($reputation > 0)

	elseif($reputation > 0)

	{

	{

		$display_reputation .= "reputation_positive";

		$display_reputation .= "reputation_positive";

	}

	}

	else
{
$display_reputation .= "reputation_neutral";

	else
{
$display_reputation .= "reputation_neutral";

	}

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


	}

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


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

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

Zeile 2926Zeile 2999
				{
$ip = $val;
break;

				{
$ip = $val;
break;

				}
}
}
}


				}
}
}
}


    if(!$ip)

    if(!$ip)

    {

    {

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

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

    }


    }


    if($plugins)
{

    if($plugins)
{

        $plugins->run_hooks("get_ip", array("ip" => $ip));


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

    }

return $ip;

    }

return $ip;

} 

}


/**
* Fetch the friendly size (GB, MB, KB, B) for a specified file size.


/**
* Fetch the friendly size (GB, MB, KB, B) for a specified file size.

Zeile 3076Zeile 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))
{


if(!is_array($forum_cache))
{

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

		else
{
$perms = $mybb->usergroup;

		}

		}


$pwverified = 1;



$pwverified = 1;


Zeile 3127Zeile 3194
				if(isset($password_forums[$parent]) && $mybb->cookies['forumpass'][$parent] != md5($mybb->user['uid'].$password_forums[$parent]))
{
$pwverified = 0;

				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($perms['canview'] == 0 || $pwverified == 0 || ($only_readable_threads == true && $perms['canviewthreads'] == 0))
{

Zeile 3137Zeile 3204
			{
$unviewableforums .= ",";
}

			{
$unviewableforums .= ",";
}





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

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

	}

	}





	return $unviewableforums;




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

}

/**

}

/**

Zeile 3174Zeile 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 3271Zeile 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 3280Zeile 3351
				// Convert & to &amp;
$navbits[$navsize]['name'] = preg_replace("#&(?!\#[0-9]+;)#si", "&amp;", $forumnav['name']);


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


				if(IN_ARCHIVE == 1)

				if(defined("IN_ARCHIVE"))

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

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

Zeile 3337Zeile 3408
	global $mybb;

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

	global $mybb;

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

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


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

	{

	{

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

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

	}
else
{

	}
else
{

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

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

	}

switch($type)

	}

switch($type)

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

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

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


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


	if(count($templates->uncached_templates > 0))
{
echo "<table style=\"background-color: #666;\" width=\"95%\" cellpadding=\"4\" cellspacing=\"1\" align=\"center\">\n";

	if(count($templates->uncached_templates > 0))
{
echo "<table style=\"background-color: #666;\" width=\"95%\" cellpadding=\"4\" cellspacing=\"1\" align=\"center\">\n";

Zeile 3503Zeile 3580
		header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
header("Cache-Control: no-cache, must-revalidate");
header("Pragma: no-cache");

		header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
header("Cache-Control: no-cache, must-revalidate");
header("Pragma: no-cache");

	}

	}

}

/**

}

/**

Zeile 3571Zeile 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 3656Zeile 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 3668Zeile 3745
		}
}


		}
}


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

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

	{
if($minutes == 1)
{

	{
if($minutes == 1)
{

Zeile 3680Zeile 3757
		}
}


		}
}


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

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

	{
if($seconds == 1)
{

	{
if($seconds == 1)
{

Zeile 3778Zeile 3855
 *
* @param int The user ID
* @param int The user group ID

 *
* @param int The user ID
* @param int The user group ID

 */

 */

function leave_usergroup($uid, $leavegroup)
{
global $db, $mybb, $cache;

function leave_usergroup($uid, $leavegroup)
{
global $db, $mybb, $cache;

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

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

	{

	{

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

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

	}

	}

	elseif(!empty($_ENV['PHP_SELF']))
{
$location = htmlspecialchars_uni($_ENV['PHP_SELF']);

	elseif(!empty($_ENV['PHP_SELF']))
{
$location = htmlspecialchars_uni($_ENV['PHP_SELF']);

	}

	}

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

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





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

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

Zeile 3866Zeile 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 3879Zeile 3954
					continue;
}


					continue;
}


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

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

			}
}


			}
}


Zeile 4001Zeile 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 5008Zeile 5083
	// Note: Number of logins is defaulted to 1, because using 0 seems to clear cookie data. Not really a problem as long as we account for 1 being default.

// Use cookie if possible, otherwise use session

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

// Use cookie if possible, otherwise use session

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

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






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

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

	{

	{

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

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





	}


	}


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

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





	{

	{

		$failedlogin = $cookietime;

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

	}

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

	}

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

Zeile 5180Zeile 5246
	@fclose($file);

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

	@fclose($file);

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

}

/**

}

/**

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

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

Zeile 5287Zeile 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 5338Zeile 5404
	}

return $dest;

	}

return $dest;

}


}


/**
* Checks if a username has been disallowed for registration/use.
*

/**
* Checks if a username has been disallowed for registration/use.
*

Zeile 5379Zeile 5445
function is_banned_email($email, $update_lastuse=false)
{
global $cache, $db;

function is_banned_email($email, $update_lastuse=false)
{
global $cache, $db;





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


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


	if(!$banned_cache)
{


	if($banned_cache === false)
{
// Failed to read cache, see if we can rebuild it

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

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

	}

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']}'");





	}

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

/**
* Checks if a specific IP address has been banned.

	// Still here - good email
return false;
}

/**
* Checks if a specific IP address has been banned.

 *

 *

 * @param string The IP address.
* @param boolean True if the 'last used' dateline should be updated if a match is found.
* @return boolean True if banned, false if not banned.

 * @param string The IP address.
* @param boolean True if the 'last used' dateline should be updated if a match is found.
* @return boolean True if banned, false if not banned.

Zeile 5422Zeile 5493
	if(!is_array($banned_ips))
{
return false;

	if(!is_array($banned_ips))
{
return false;

	}

	}

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

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

		}

		}

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

		
// 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 5443Zeile 5514
			return true;
}
}

			return true;
}
}

 


	// Still here - good ip
return false;
}

/**
* Build a time zone selection list.

	// Still here - good ip
return false;
}

/**
* Build a time zone selection list.

 *

 *

 * @param string The name of the select
* @param int The selected time zone (defaults to GMT)
* @param boolean True to generate a "short" list with just timezone and current time

 * @param string The name of the select
* @param int The selected time zone (defaults to GMT)
* @param boolean True to generate a "short" list with just timezone and current time

Zeile 5640Zeile 5712

/**
* Checks if a particular user is a super administrator.


/**
* Checks if a particular user is a super administrator.

 *

 *

 * @param int The user ID to check against the list of super admins
* @return boolean True if a super admin, false if not
*/

 * @param int The user ID to check against the list of super admins
* @return boolean True if a super admin, false if not
*/

Zeile 5733Zeile 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 5741Zeile 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 5766Zeile 5838
			}
$sep = ".";
}

			}
$sep = ".";
}

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

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

	}
}


	}
}


Zeile 6024Zeile 6096
	if(!is_array($bad_verify_files))
{
$bad_verify_files = array();

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

	}

	}

	
// Make sure that we're in a directory and it's not a symbolic link
if(@is_dir($path) && !@is_link($path))

	
// Make sure that we're in a directory and it's not a symbolic link
if(@is_dir($path) && !@is_link($path))

Zeile 6035Zeile 6107
            while(($file = @readdir($dh)) !== false)
{
if(in_array($file, $ignore) || in_array(get_extension($file), $ignore_ext))

            while(($file = @readdir($dh)) !== false)
{
if(in_array($file, $ignore) || in_array(get_extension($file), $ignore_ext))

				{
continue;

				{
continue;

				}

// Recurse through the directory tree

				}

// Recurse through the directory tree

Zeile 6060Zeile 6132
						$contents .= fread($handle, 8192);
}
fclose($handle);

						$contents .= fread($handle, 8192);
}
fclose($handle);

					

					

					$md5 = md5($contents);

// Does it match any of our hashes (unix/windows new lines taken into consideration with the hashes)

					$md5 = md5($contents);

// Does it match any of our hashes (unix/windows new lines taken into consideration with the hashes)

Zeile 6094Zeile 6166
	if($count == 0)
{
return $bad_verify_files;

	if($count == 0)
{
return $bad_verify_files;

	}
}


	}
}


/**
* Returns a signed value equal to an integer
*

/**
* Returns a signed value equal to an integer
*

Zeile 6108Zeile 6180
	if($int < 0)
{
return "$int";

	if($int < 0)
{
return "$int";

	}

	}

	else
{
return "+$int";

	else
{
return "+$int";

Zeile 6119Zeile 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 equivalent of a secure hexadecimal seed

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

 */
function secure_seed_rng($count=8)
{
$output = '';

 */
function secure_seed_rng($count=8)
{
$output = '';

	

	

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

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

	}


	}


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

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

Zeile 6155Zeile 6227

/**
* Wrapper function for mt_rand. Automatically seeds using a secure seed once.


/**
* Wrapper function for mt_rand. Automatically seeds using a secure seed once.

 *

 *

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

 * @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

Zeile 6167Zeile 6239
	static $obfuscator = 0;

if($seeded == false || $force_seed == true)

	static $obfuscator = 0;

if($seeded == false || $force_seed == true)

	{

	{

		mt_srand(secure_seed_rng());
$seeded = true;

		mt_srand(secure_seed_rng());
$seeded = true;





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

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

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

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

		}
}


		}
}


	if($min !== null && $max !== null)
{
$distance = $max - $min;
if ($distance > 0)

	if($min !== null && $max !== null)
{
$distance = $max - $min;
if ($distance > 0)

		{

		{

			return $min + (int)((float)($distance + 1) * (float)(mt_rand() ^ $obfuscator) / (mt_getrandmax() + 1));
}
else
{
return mt_rand($min, $max);
}

			return $min + (int)((float)($distance + 1) * (float)(mt_rand() ^ $obfuscator) / (mt_getrandmax() + 1));
}
else
{
return mt_rand($min, $max);
}

	}

	}

	else
{
$val = mt_rand() ^ $obfuscator;

	else
{
$val = mt_rand() ^ $obfuscator;

Zeile 6216Zeile 6288
		0x0D => 1,
0x0B => 1,
0xAD => 1,

		0x0D => 1,
0x0B => 1,
0xAD => 1,

		0xC2 => array(0xA0 => 1,
0xAD => 1,
0xBF => 1,
0x81 => 1,
0x8D => 1,
0x90 => 1,
0x9D => 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}