Vergleich inc/functions.php - 1.6.11 - 1.6.18

  Keine Änderungen   Hinzugefügt   Modifiziert   Entfernt
Zeile 21Zeile 21

$contents = parse_page($contents);
$totaltime = $maintimer->stop();


$contents = parse_page($contents);
$totaltime = $maintimer->stop();

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


if($mybb->usergroup['cancp'] == 1)
{


if($mybb->usergroup['cancp'] == 1)
{

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

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

			}

			}

			else
{
// if we've got a super fast script... all we can do is assume something

			else
{
// if we've got a super fast script... all we can do is assume something

Zeile 57Zeile 58
			if($mybb->settings['gzipoutput'] != 0)
{
$gzipen = "Enabled";

			if($mybb->settings['gzipoutput'] != 0)
{
$gzipen = "Enabled";

			}
else

			}
else

			{
$gzipen = "Disabled";

			{
$gzipen = "Disabled";

			}

			}


$memory_usage = get_memory_usage();



$memory_usage = get_memory_usage();


Zeile 70Zeile 71
				$memory_usage = " / Memory Usage: ".get_friendly_size($memory_usage);
}
else

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

			{

			{

				$memory_usage = '';
}
// MySQLi is still MySQL, so present it that way to the user

				$memory_usage = '';
}
// MySQLi is still MySQL, so present it that way to the user

Zeile 92Zeile 93
	}

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

	}

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

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

 

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


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

	{

	{

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


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


Zeile 120Zeile 120
	if(!is_array($shutdown_functions))
{
$shutdown_functions = array();

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

	}

	}


if(!is_array($arguments))
{


if(!is_array($arguments))
{

Zeile 220Zeile 220
	{
// Loop through and run them all
foreach($shutdown_queries as $query)

	{
// Loop through and run them all
foreach($shutdown_queries as $query)

		{

		{

			$db->query($query);
}
}

			$db->query($query);
}
}

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

			else
{
error($lang->invalid_post_code);

			}
}
}
else
{
return true;
}

			}
}
}
else
{
return true;
}

}

/**

}

/**

Zeile 718Zeile 718
	}

foreach($errors as $error)

	}

foreach($errors as $error)

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

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


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



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


Zeile 733Zeile 733
function error_no_permission()
{
global $mybb, $theme, $templates, $db, $lang, $plugins, $session;

function error_no_permission()
{
global $mybb, $theme, $templates, $db, $lang, $plugins, $session;





	$time = TIME_NOW;
$plugins->run_hooks("no_permission");

	$time = TIME_NOW;
$plugins->run_hooks("no_permission");





	$noperm_array = array (
"nopermission" => '1',
"location1" => 0,
"location2" => 0
);

	$noperm_array = array (
"nopermission" => '1',
"location1" => 0,
"location2" => 0
);


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

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


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

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 757Zeile 757
	{
$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 to where the user came from
$redirect_url = $_SERVER['PHP_SELF'];
if($_SERVER['QUERY_STRING'])

Zeile 822Zeile 822
	}

if(!$message)

	}

if(!$message)

	{

	{

		$message = $lang->redirect;
}


		$message = $lang->redirect;
}


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

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





		run_shutdown();

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

		run_shutdown();

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

Zeile 885Zeile 885
	$url = htmlspecialchars_uni($url);

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

	$url = htmlspecialchars_uni($url);

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





	$prevpage = '';
if($page > 1)
{

	$prevpage = '';
if($page > 1)
{

Zeile 910Zeile 910
	}

if($to > $pages)

	}

if($to > $pages)

	{

	{

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

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

Zeile 922Zeile 922
	if($to == 0)
{
$to = $pages;

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

	}

	}


$start = '';
if($from > 1)


$start = '';
if($from > 1)

Zeile 934Zeile 934

$page_url = fetch_page_url($url, 1);
eval("\$start = \"".$templates->get("multipage_start")."\";");


$page_url = fetch_page_url($url, 1);
eval("\$start = \"".$templates->get("multipage_start")."\";");

	}

	}


$mppage = '';
for($i = $from; $i <= $to; ++$i)


$mppage = '';
for($i = $from; $i <= $to; ++$i)

Zeile 959Zeile 959

$end = '';
if($to < $pages)


$end = '';
if($to < $pages)

	{

	{

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

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





		$page_url = fetch_page_url($url, $pages);
eval("\$end = \"".$templates->get("multipage_end")."\";");
}

$nextpage = '';
if($page < $pages)

		$page_url = fetch_page_url($url, $pages);
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")."\";");

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

Zeile 1021Zeile 1021
		else
{
$url .= "&amp;";

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

		}


		}


		$url .= "page=$page";
}
else

		$url .= "page=$page";
}
else

Zeile 1220Zeile 1220
	}

if(!is_array($fpermcache))

	}

if(!is_array($fpermcache))

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

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


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


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

Zeile 1235Zeile 1235
	else
{
if(!$cached_forum_permissions[$gid])

	else
{
if(!$cached_forum_permissions[$gid])

		{

		{

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

Zeile 1295Zeile 1295
					{
$level_permissions = $groupscache[$gid];
}

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

				}
}


				}
}


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

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

Zeile 1322Zeile 1322
	if(count($current_permissions) == 0)
{
$current_permissions = $groupperms;

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

	}

	}

	return $current_permissions;
}

/**
* Check the password given on a certain forum for validity
*

	return $current_permissions;
}

/**
* Check the password given on a certain forum for validity
*

 * @param int The forum ID
* @param boolean The Parent ID



 * @param int $fid The forum ID
* @param int $pid The Parent ID
* @param bool $return
* @return bool

 */

 */

function check_forum_password($fid, $pid=0)

function check_forum_password($fid, $pid=0, $return=false)

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

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





	$showform = true;

	$showform = true;





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

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

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

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

			}

			}

		}
}


		}
}


Zeile 1374Zeile 1376
			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")."\";");

				$showform = true;

				$showform = true;

			}
}
else

			}
}
else

Zeile 1387Zeile 1389
			if(!$mybb->cookies['forumpass'][$fid] || ($mybb->cookies['forumpass'][$fid] && md5($mybb->user['uid'].$password) != $mybb->cookies['forumpass'][$fid]))
{
$showform = true;

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

			}

			}

			else
{
$showform = false;
}
}

			else
{
$showform = false;
}
}

	}

	}

	else

	else

	{

	{

		$showform = false;

		$showform = false;

 
	}

if($return)
{
return $showform;

	}

if($showform)

	}

if($showform)

Zeile 1424Zeile 1431
 * @return array Array of moderator permissions for the specific forum
*/
function get_moderator_permissions($fid, $uid="0", $parentslist="")

 * @return array Array of moderator permissions for the specific forum
*/
function get_moderator_permissions($fid, $uid="0", $parentslist="")

{

{

	global $mybb, $cache, $db;
static $modpermscache;

if($uid < 1)

	global $mybb, $cache, $db;
static $modpermscache;

if($uid < 1)

	{

	{

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

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

	}


	}


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

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

	}


	}


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

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

Zeile 1461Zeile 1468
		foreach($extra_groups as $extra_group)
{
$groups[] = $extra_group;

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

		}
}

		}
}


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


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


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


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

	{

	{

		if(!is_array($forum) || !in_array($fid, $parentslist))

		if(!is_array($forum) || !in_array($forumid, $parentslist))

		{
// No perms or we're not after this forum
continue;

		{
// No perms or we're not after this forum
continue;

Zeile 1476Zeile 1483

// User settings override usergroup settings
if(is_array($forum['users'][$uid]))


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

			$perm = $forum['users'][$uid];
foreach($perm as $action => $value)
{
if(strpos($action, "can") === false)

				{

				{

					continue;
}


					continue;
}


Zeile 1489Zeile 1496
				if($value == 0)
{
// The user doesn't have permission to set this action

				if($value == 0)
{
// The user doesn't have permission to set this action

					$perms[$action] = 0;

					$perms[$action] = 0;

				}
else
{

				}
else
{

Zeile 1501Zeile 1508
		foreach($groups as $group)
{
if(!is_array($forum['usergroups'][$group]))

		foreach($groups as $group)
{
if(!is_array($forum['usergroups'][$group]))

			{

			{

				// There are no permissions set for this group
continue;
}

				// There are no permissions set for this group
continue;
}

Zeile 1526Zeile 1533

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

 *

 *

 * @param int The forum ID (0 assumes global)
* @param string The action tyring to be performed. (blank assumes any action at all)
* @param int The user ID (0 assumes current user)

 * @param int The forum ID (0 assumes global)
* @param string The action tyring to be performed. (blank assumes any action at all)
* @param int The user ID (0 assumes current user)

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

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

	}

	}


if($uid == 0)


if($uid == 0)

	{

	{

		return false;
}

$user_perms = user_permissions($uid);
if($user_perms['issupermod'] == 1)
{

		return false;
}

$user_perms = user_permissions($uid);
if($user_perms['issupermod'] == 1)
{

 
		if($fid)
{
$forumpermissions = forum_permissions($fid);
if($forumpermissions['canview'] && $forumpermissions['canviewthreads'] && !$forumpermissions['canonlyviewownthreads'])
{
return true;
}
return false;
}

		return true;
}
else

		return true;
}
else

Zeile 1576Zeile 1592
		else
{
$modperms = get_moderator_permissions($fid, $uid);

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





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

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

Zeile 1626Zeile 1642
	{
$dbicon['path'] = htmlspecialchars_uni($dbicon['path']);
$dbicon['name'] = htmlspecialchars_uni($dbicon['name']);

	{
$dbicon['path'] = htmlspecialchars_uni($dbicon['path']);
$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>";

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

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

return $posticons;

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

return $posticons;

}

/**

}

/**

 * MyBB setcookie() wrapper.
*
* @param string The cookie identifier.

 * MyBB setcookie() wrapper.
*
* @param string The cookie identifier.

Zeile 1663Zeile 1679
	global $mybb;

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

	global $mybb;

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

	{

	{

		$mybb->settings['cookiepath'] = "/";
}


		$mybb->settings['cookiepath'] = "/";
}


Zeile 1700Zeile 1716
	if(!empty($mybb->settings['cookiedomain']))
{
$cookie .= "; domain={$mybb->settings['cookiedomain']}";

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

	}

	}


if($httponly == true)
{


if($httponly == true)
{

Zeile 1725Zeile 1741
	my_setcookie($name, "", $expires);

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

	my_setcookie($name, "", $expires);

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

}


}


/**
* Get the contents from a serialised cookie array.
*

/**
* Get the contents from a serialised cookie array.
*

Zeile 1739Zeile 1755
	global $mybb;

if(!isset($mybb->cookies['mybb'][$name]))

	global $mybb;

if(!isset($mybb->cookies['mybb'][$name]))

	{

	{

		return false;
}


		return false;
}


Zeile 1775Zeile 1791

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

/**
* Verifies that data passed is an array
*

Zeile 1785Zeile 1801
 */
function my_unserialize($data)
{

 */
function my_unserialize($data)
{

 
	// Do no unserialize objects
if(substr($data, 0, 1) == 'O')
{
return array();
}


	$array = unserialize($data);

if(!is_array($array))

	$array = unserialize($data);

if(!is_array($array))

Zeile 1813Zeile 1835
		{
// sys_getloadavg() will return an array with [0] being load within the last minute.
$serverload = sys_getloadavg();

		{
// sys_getloadavg() will return an array with [0] being load within the last minute.
$serverload = sys_getloadavg();

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

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

		else if(@file_exists("/proc/loadavg") && $load = @file_get_contents("/proc/loadavg"))

		else if(@file_exists("/proc/loadavg") && $load = @file_get_contents("/proc/loadavg"))

		{

		{

			$serverload = explode(" ", $load);
$serverload[0] = round($serverload[0], 4);
}
if(!is_numeric($serverload[0]))
{
if(@ini_get('safe_mode') == 'On')

			$serverload = explode(" ", $load);
$serverload[0] = round($serverload[0], 4);
}
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 1839Zeile 1861
			if($func_blacklist = @ini_get('disable_functions'))
{
if(strpos(",".$func_blacklist.",", 'exec') !== false)

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

				{

				{

					return $lang->unknown;
}
}

					return $lang->unknown;
}
}

Zeile 1850Zeile 1872
			if(!is_array($serverload))
{
return $lang->unknown;

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

			}
}

			}
}

	}
else
{

	}
else
{

Zeile 1889Zeile 1911
function update_stats($changes=array())
{
global $cache, $db;

function update_stats($changes=array())
{
global $cache, $db;





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

$counters = array('numthreads','numunapprovedthreads','numposts','numunapprovedposts','numusers');

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

$counters = array('numthreads','numunapprovedthreads','numposts','numunapprovedposts','numusers');

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

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

	}


	}


	if(empty($new_stats))

	if(empty($new_stats))

	{

	{

		return;
}

if(is_array($stats))

		return;
}

if(is_array($stats))

	{

	{

		$stats = array_merge($stats, $new_stats);
}
else

		$stats = array_merge($stats, $new_stats);
}
else

Zeile 1986Zeile 2008
			}

// Less than 0? That's bad

			}

// Less than 0? That's bad

			if(!$update_query[$counter])
{

			if($update_query[$counter] < 0)
{

				$update_query[$counter] = 0;

				$update_query[$counter] = 0;

			}
}
}


			}
}
}


	// 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("forums", $update_query, "fid='".intval($fid)."'");

		$db->update_query("forums", $update_query, "fid='".intval($fid)."'");

	}

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

if(array_key_exists('unapprovedthreads', $update_query))
{
$unapprovedthreads_diff = $update_query['unapprovedthreads'] - $forum['unapprovedthreads'];
if($unapprovedthreads_diff > -1)
{
$new_stats['numunapprovedthreads'] = "+{$unapprovedthreads_diff}";
}
else
{
$new_stats['numunapprovedthreads'] = "{$unapprovedthreads_diff}";
}
}

if(array_key_exists('posts', $update_query))
{
$posts_diff = $update_query['posts'] - $forum['posts'];
if($posts_diff > -1)
{
$new_stats['numposts'] = "+{$posts_diff}";
}
else
{
$new_stats['numposts'] = "{$posts_diff}";
}
}

if(array_key_exists('unapprovedposts', $update_query))
{
$unapprovedposts_diff = $update_query['unapprovedposts'] - $forum['unapprovedposts'];
if($unapprovedposts_diff > -1)
{
$new_stats['numunapprovedposts'] = "+{$unapprovedposts_diff}";
}
else
{
$new_stats['numunapprovedposts'] = "{$unapprovedposts_diff}";
}

	}

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

if(array_key_exists('unapprovedthreads', $update_query))
{
$unapprovedthreads_diff = $update_query['unapprovedthreads'] - $forum['unapprovedthreads'];
if($unapprovedthreads_diff > -1)
{
$new_stats['numunapprovedthreads'] = "+{$unapprovedthreads_diff}";
}
else
{
$new_stats['numunapprovedthreads'] = "{$unapprovedthreads_diff}";
}
}

if(array_key_exists('posts', $update_query))
{
$posts_diff = $update_query['posts'] - $forum['posts'];
if($posts_diff > -1)
{
$new_stats['numposts'] = "+{$posts_diff}";
}
else
{
$new_stats['numposts'] = "{$posts_diff}";
}
}

if(array_key_exists('unapprovedposts', $update_query))
{
$unapprovedposts_diff = $update_query['unapprovedposts'] - $forum['unapprovedposts'];
if($unapprovedposts_diff > -1)
{
$new_stats['numunapprovedposts'] = "+{$unapprovedposts_diff}";
}
else
{
$new_stats['numunapprovedposts'] = "{$unapprovedposts_diff}";




		}

		}

 
	}

if(!empty($new_stats))
{

		update_stats($new_stats);
}

		update_stats($new_stats);
}





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

$cache->update_forums();

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

$cache->update_forums();

}


}


/**
* Update the last post information for a specific forum
*

/**
* Update the last post information for a specific forum
*

Zeile 2112Zeile 2135
	$thread = $db->fetch_array($query);

foreach($counters as $counter)

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

foreach($counters as $counter)

	{

	{

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

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

			{

			{

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

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

			}


			}


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

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

Zeile 2148Zeile 2171

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


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

 *
* @param int The thread ID

 *
* @param int The thread ID

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

	$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 2172Zeile 2195
		LIMIT 1"
);
$lastpost = $db->fetch_array($query);

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


$db->free_result($query);



$db->free_result($query);


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

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

Zeile 2249Zeile 2272
	}

return $moderation->delete_thread($tid);

	}

return $moderation->delete_thread($tid);

}

}


/**
* Deletes a post from the database


/**
* Deletes a post from the database

Zeile 2448Zeile 2471
	$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 2527Zeile 2550
		{
global $page;
$codeinsert = $page->build_codebuttons_editor($bind, $editor_language);

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

		}
else

		}
else

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

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

		}

		}

	}

	}





	return $codeinsert;
}

	return $codeinsert;
}





/**
* Build the javascript clickable smilie inserter
*

/**
* Build the javascript clickable smilie inserter
*

Zeile 2545Zeile 2568
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)

Zeile 2565Zeile 2588
				if($smilie['showclickable'] != 0)
{
$smiliecache[$smilie['find']] = $smilie['image'];

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

				}
}
}

				}
}
}


unset($smilie);



unset($smilie);


Zeile 2760Zeile 2783
	}

$prefixselect = "";

	}

$prefixselect = "";

	$multipleselect = "";

 
	if($multiple != 0)
{

	if($multiple != 0)
{

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





		$prefixselect = "<select name=\"threadprefix[]\" multiple=\"multiple\" size=\"5\">\n";
}
else
{
$prefixselect = "<select name=\"threadprefix\">\n";

	}

	}


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

 

if($multiple == 1)
{


if($multiple == 1)
{

Zeile 2986Zeile 3010

$ip = 0;



$ip = 0;


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

	if(!preg_match("#^(10|172\.(1[6-9]|2[0-9]|3[0-1])|192\.168)\.#", $_SERVER['REMOTE_ADDR']))

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

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

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

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

				if(!preg_match("#^(10|172\.16|192\.168)\.#", $val))

				if(!preg_match("#^(10|172\.(1[6-9]|2[0-9]|3[0-1])|192\.168)\.#", $val))

				{
$ip = $val;
break;

				{
$ip = $val;
break;

Zeile 3135Zeile 3159
		{
$icon = str_replace("{theme}", $theme['imgdir'], $attachtypes[$ext]['icon']);
}

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

 
		$icon = htmlspecialchars_uni($icon);

		return "<img src=\"{$icon}\" border=\"0\" alt=\".{$ext}\" />";
}
else

		return "<img src=\"{$icon}\" border=\"0\" alt=\".{$ext}\" />";
}
else

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

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

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

			$theme['imgdir'] = htmlspecialchars_uni("{$change_dir}/images");

		}

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

		}

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

Zeile 3277Zeile 3302
				$multipage_dropdown = null;
if(!empty($navbit['multipage']))
{

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

 
					if(!$mybb->settings['threadsperpage'] || (int)$mybb->settings['threadsperpage'] < 1)
{
$mybb->settings['threadsperpage'] = 20;
}


					$multipage = multipage($navbit['multipage']['num_threads'], $mybb->settings['threadsperpage'], $navbit['multipage']['current_page'], $navbit['multipage']['url'], true);
if($multipage)
{

					$multipage = multipage($navbit['multipage']['num_threads'], $mybb->settings['threadsperpage'], $navbit['multipage']['current_page'], $navbit['multipage']['url'], true);
if($multipage)
{

Zeile 3762Zeile 3792
		{
$nicetime['minutes'] = "1".$lang_minute;
}

		{
$nicetime['minutes'] = "1".$lang_minute;
}

		else if($minutes > 1)
{
$nicetime['minutes'] = $minutes.$lang_minutes;
}

		else if($minutes > 1)
{
$nicetime['minutes'] = $minutes.$lang_minutes;
}

	}

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

	}

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

Zeile 3773Zeile 3803
		if($seconds == 1)
{
$nicetime['seconds'] = "1".$lang_second;

		if($seconds == 1)
{
$nicetime['seconds'] = "1".$lang_second;

		}

		}

		else if($seconds > 1)
{
$nicetime['seconds'] = $seconds.$lang_seconds;
}

		else if($seconds > 1)
{
$nicetime['seconds'] = $seconds.$lang_seconds;
}

	}


	}


	if(is_array($nicetime))
{
return implode(", ", $nicetime);

	if(is_array($nicetime))
{
return implode(", ", $nicetime);

	}
}


	}
}


/**
* Select an alternating row colour based on the previous call to this function
*

/**
* Select an alternating row colour based on the previous call to this function
*

Zeile 3797Zeile 3827
	global $alttrow;

if($alttrow == "trow1" && !$reset)

	global $alttrow;

if($alttrow == "trow1" && !$reset)

	{

	{

		$trow = "trow2";

		$trow = "trow2";

	}

	}

	else
{
$trow = "trow1";
}

$alttrow = $trow;

	else
{
$trow = "trow1";
}

$alttrow = $trow;





	return $trow;

	return $trow;

}


}


/**
* Add a user to a specific additional user group.
*

/**
* Add a user to a specific additional user group.
*

Zeile 3821Zeile 3851
	global $db, $mybb;

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

	global $db, $mybb;

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

	{

	{

		$user = $mybb->user;
}
else

		$user = $mybb->user;
}
else

Zeile 3858Zeile 3888
	else
{
return false;

	else
{
return false;

	}
}

/**

	}
}

/**

 * Remove a user from a specific additional user group
*
* @param int The user ID

 * Remove a user from a specific additional user group
*
* @param int The user ID

Zeile 4055Zeile 4085
		if($mybb->user['additionalgroups'])
{
$in_groups = explode(",", $mybb->user['additionalgroups']);

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

		}

		}

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

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

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

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

Zeile 5730Zeile 5760
 */
function is_super_admin($uid)
{

 */
function is_super_admin($uid)
{

	global $mybb;

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






	static $super_admins;

if(!isset($super_admins))
{
global $mybb;
$super_admins = str_replace(" ", "", $mybb->config['super_admins']);
}

if(my_strpos(",{$super_admins},", ",{$uid},") === false)
{

		return false;

		return false;

	}

	}

	else

	else

	{

	{

		return true;
}

		return true;
}

 
}

/**
* Prevents super administrators being selected in a SELECT.
*
* @param boolean Prefix with an AND?
* @param string The prefix to add to uid when used in a JOIN (e.g. SELECTing users u would mean using 'u' in this argument).
* @return string An addition to the WHERE statement
*/
function not_super_admins($use_and = false, $uid_prefix = '')
{
static $super_admins;

if(!isset($super_admins))
{
global $mybb, $db;
$super_admins = $db->escape_string(str_replace(" ", "", $mybb->config['super_admins']));
}

if($super_admins)
{
$sql_where = '';
if($use_and)
{
$sql_where .= ' AND ';
}

if($uid_prefix != '')
{
$sql_where .= $uid_prefix.'.';
}

$sql_where .= "uid NOT IN({$super_admins})";

return $sql_where;
}
return '';

}

/**

}

/**

Zeile 6003Zeile 6075
			while(($file = @readdir($dh)) !== false)
{
if($file == '.' || $file == '..' || $file == '.svn' || in_array($path.'/'.$file, $ignore) || !my_rmdir_recursive($path.'/'.$file))

			while(($file = @readdir($dh)) !== false)
{
if($file == '.' || $file == '..' || $file == '.svn' || in_array($path.'/'.$file, $ignore) || !my_rmdir_recursive($path.'/'.$file))

				{
continue;

				{
continue;

				}
}
@closedir($dh);

				}
}
@closedir($dh);

Zeile 6208Zeile 6280
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);











































	// DIRECTORY_SEPARATOR checks if running windows
if(DIRECTORY_SEPARATOR != '\\')
{
// Unix/Linux
// Use OpenSSL when available
if(function_exists('openssl_random_pseudo_bytes'))
{
$output = openssl_random_pseudo_bytes($count);
}
// Try mcrypt
elseif(function_exists('mcrypt_create_iv'))
{
$output = mcrypt_create_iv($count, MCRYPT_DEV_URANDOM);
}
// Try /dev/urandom
elseif(@is_readable('/dev/urandom') && ($handle = @fopen('/dev/urandom', 'rb')))
{
$output = @fread($handle, $count);
@fclose($handle);
}
}
else
{
// Windows
// Use OpenSSL when available
// PHP <5.3.4 had a bug which makes that function unusable on Windows
if(function_exists('openssl_random_pseudo_bytes') && version_compare(PHP_VERSION, '5.3.4', '>='))
{
$output = openssl_random_pseudo_bytes($count);
}
// Try mcrypt
elseif(function_exists('mcrypt_create_iv'))
{
$output = mcrypt_create_iv($count, MCRYPT_RAND);
}
// Try Windows CAPICOM before using our own generator
elseif(class_exists('COM'))
{
try
{
$CAPI_Util = new COM('CAPICOM.Utilities.1');
if(is_callable(array($CAPI_Util, 'GetRandom')))
{
$output = $CAPI_Util->GetRandom($count, 0);
}
} catch (Exception $e) {
}
}

	}

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

	}

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





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


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


Zeile 6228Zeile 6342
		{
$unique_state = md5(microtime().$unique_state);
$output .= pack('H*', md5($unique_state));

		{
$unique_state = md5(microtime().$unique_state);
$output .= pack('H*', md5($unique_state));

		}
}

		}
}


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


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

Zeile 6280Zeile 6394
	{
$val = mt_rand() ^ $obfuscator;
return $val;

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

	}

	}

}

/**

}

/**

 * More robust version of PHP's trim() function. It includes a list of UTF-16 blank characters

 * More robust version of PHP's trim() function. It includes a list of UTF-8 blank characters

 * from http://kb.mozillazine.org/Network.IDN.blacklist_chars
*
* @param string The string to trim from

 * from http://kb.mozillazine.org/Network.IDN.blacklist_chars
*
* @param string The string to trim from

Zeile 6294Zeile 6408
function trim_blank_chrs($string, $charlist=false)
{
$hex_chrs = array(

function trim_blank_chrs($string, $charlist=false)
{
$hex_chrs = array(

		0x20 => 1,
0x09 => 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}
0xA8 => 1, 0xA9 => 1, 0xAA => 1, 0xAB => 1, 0xAC => 1, 0xAD => 1, 0xAE => 1, 0xAF => 1), // \x{2028} to \x{202F}
0x81 => array(0x9F => 1)), // \x{205F}

		0x09 => 1, // \x{0009}
0x0A => 1, // \x{000A}
0x0B => 1, // \x{000B}
0x0D => 1, // \x{000D}
0x20 => 1, // \x{0020}
0xC2 => array(0x81 => 1, 0x8D => 1, 0x90 => 1, 0x9D => 1, 0xA0 => 1, 0xAD => 1), // \x{0081}, \x{008D}, \x{0090}, \x{009D}, \x{00A0}, \x{00AD}
0xCC => array(0xB7 => 1, 0xB8 => 1), // \x{0337}, \x{0338}
0xE1 => array(0x85 => array(0x9F => 1, 0xA0 => 1), 0x9A => array(0x80 => 1), 0xA0 => array(0x8E => 1)), // \x{115F}, \x{1160}, \x{1680}, \x{180E}
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, 0x8C => 1, 0x8D => 1, 0x8E => 1, 0x8F => 1, // \x{2000} - \x{200F}
0xA8 => 1, 0xA9 => 1, 0xAA => 1, 0xAB => 1, 0xAC => 1, 0xAD => 1, 0xAE => 1, 0xAF => 1), // \x{2028} - \x{202F}
0x81 => array(0x9F => 1)), // \x{205F}








		0xE3 => array(0x80 => array(0x80 => 1), // \x{3000}

		0xE3 => array(0x80 => array(0x80 => 1), // \x{3000}

					  0x85 => array(0xA4 => 1)), // \x{3164}

			0x85 => array(0xA4 => 1)), // \x{3164}

		0xEF => array(0xBB => array(0xBF => 1), // \x{FEFF}

		0xEF => array(0xBB => array(0xBF => 1), // \x{FEFF}

					  0xBE => array(0xA0 => 1), // \x{FFA0}
0xBF => array(0xB9 => 1, 0xBA => 1, 0xBB => 1)), // \x{FFF9} to \x{FFFB}

			0xBE => array(0xA0 => 1), // \x{FFA0}
0xBF => array(0xB9 => 1, 0xBA => 1, 0xBB => 1)), // \x{FFF9} - \x{FFFB}

	);

$hex_chrs_rev = array(

	);

$hex_chrs_rev = array(

		0x20 => 1,
0x09 => 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),

		0x09 => 1, // \x{0009}
0x0A => 1, // \x{000A}
0x0B => 1, // \x{000B}
0x0D => 1, // \x{000D}
0x20 => 1, // \x{0020}
0x81 => array(0xC2 => 1, 0x80 => array(0xE2 => 1)), // \x{0081}, \x{2001}
0x8D => array(0xC2 => 1, 0x80 => array(0xE2 => 1)), // \x{008D}, \x{200D}
0x90 => array(0xC2 => 1), // \x{0090}
0x9D => array(0xC2 => 1), // \x{009D}
0xA0 => array(0xC2 => 1, 0x85 => array(0xE1 => 1), 0x81 => array(0xE2 => 1), 0xBE => array(0xEF => 1)), // \x{00A0}, \x{1160}, \x{2060}, \x{FFA0}
0xAD => array(0xC2 => 1, 0x80 => array(0xE2 => 1)), // \x{00AD}, \x{202D}


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

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

		0xA0 => array(0x85 => array(0xE1 => 1)), // \x{1160}
0x9F => array(0x85 => array(0xE1 => 1), // \x{115F}
0x81 => array(0xE2 => 1)), // \x{205F}
0x80 => array(0x80 => array(0xE3 => 1, 0xE2 => 1)), // \x{3000}, \x{2000}
0x81 => array(0x80 => array(0xE2 => 1)), // \x{2001}

		0x9F => array(0x85 => array(0xE1 => 1), 0x81 => array(0xE2 => 1)), // \x{115F}, \x{205F}
0x80 => array(0x9A => array(0xE1 => 1), 0x80 => array(0xE2 => 1, 0xE3 => 1)), // \x{1680}, \x{2000}, \x{3000}
0x8E => array(0xA0 => array(0xE1 => 1), 0x80 => array(0xE2 => 1)), // \x{180E}, \x{200E}



		0x82 => array(0x80 => array(0xE2 => 1)), // \x{2002}
0x83 => array(0x80 => array(0xE2 => 1)), // \x{2003}
0x84 => array(0x80 => array(0xE2 => 1)), // \x{2004}

		0x82 => array(0x80 => array(0xE2 => 1)), // \x{2002}
0x83 => array(0x80 => array(0xE2 => 1)), // \x{2003}
0x84 => array(0x80 => array(0xE2 => 1)), // \x{2004}

Zeile 6349Zeile 6453
		0x89 => array(0x80 => array(0xE2 => 1)), // \x{2009}
0x8A => array(0x80 => array(0xE2 => 1)), // \x{200A}
0x8B => array(0x80 => array(0xE2 => 1)), // \x{200B}

		0x89 => array(0x80 => array(0xE2 => 1)), // \x{2009}
0x8A => array(0x80 => array(0xE2 => 1)), // \x{200A}
0x8B => array(0x80 => array(0xE2 => 1)), // \x{200B}

 
		0x8C => array(0x80 => array(0xE2 => 1)), // \x{200C}
0x8F => array(0x80 => array(0xE2 => 1)), // \x{200F}

		0xA8 => array(0x80 => array(0xE2 => 1)), // \x{2028}
0xA9 => array(0x80 => array(0xE2 => 1)), // \x{2029}
0xAA => array(0x80 => array(0xE2 => 1)), // \x{202A}
0xAB => array(0x80 => array(0xE2 => 1)), // \x{202B}
0xAC => array(0x80 => array(0xE2 => 1)), // \x{202C}

		0xA8 => array(0x80 => array(0xE2 => 1)), // \x{2028}
0xA9 => array(0x80 => array(0xE2 => 1)), // \x{2029}
0xAA => array(0x80 => array(0xE2 => 1)), // \x{202A}
0xAB => array(0x80 => array(0xE2 => 1)), // \x{202B}
0xAC => array(0x80 => array(0xE2 => 1)), // \x{202C}

		0xAD => array(0x80 => array(0xE2 => 1)), // \x{202D}

 
		0xAE => array(0x80 => array(0xE2 => 1)), // \x{202E}
0xAF => array(0x80 => array(0xE2 => 1)), // \x{202F}
0xA4 => array(0x85 => array(0xE3 => 1)), // \x{3164}
0xBF => array(0xBB => array(0xEF => 1)), // \x{FEFF}

		0xAE => array(0x80 => array(0xE2 => 1)), // \x{202E}
0xAF => array(0x80 => array(0xE2 => 1)), // \x{202F}
0xA4 => array(0x85 => array(0xE3 => 1)), // \x{3164}
0xBF => array(0xBB => array(0xEF => 1)), // \x{FEFF}

		0xA0 => array(0xBE => array(0xEF => 1)), // \x{FFA0}

 
		0xB9 => array(0xBF => array(0xEF => 1)), // \x{FFF9}
0xBA => array(0xBF => array(0xEF => 1)), // \x{FFFA}
0xBB => array(0xBF => array(0xEF => 1)), // \x{FFFB}

		0xB9 => array(0xBF => array(0xEF => 1)), // \x{FFF9}
0xBA => array(0xBF => array(0xEF => 1)), // \x{FFFA}
0xBB => array(0xBF => array(0xEF => 1)), // \x{FFFB}

Zeile 6368Zeile 6472
	// Start from the beginning and work our way in
do
{

	// Start from the beginning and work our way in
do
{

		// Check to see if we have matched a first character in our utf-16 array

		// Check to see if we have matched a first character in our utf-8 array

		$offset = match_sequence($string, $hex_chrs);
if(!$offset)
{

		$offset = match_sequence($string, $hex_chrs);
if(!$offset)
{

Zeile 6383Zeile 6487
	$string = strrev($string);
do
{

	$string = strrev($string);
do
{

		// Check to see if we have matched a first character in our utf-16 array

		// Check to see if we have matched a first character in our utf-8 array

		$offset = match_sequence($string, $hex_chrs_rev);
if(!$offset)
{

		$offset = match_sequence($string, $hex_chrs_rev);
if(!$offset)
{

Zeile 6469Zeile 6573
}

/**

}

/**

 * Handles 4 byte UTF-8 characters.

 * Validates an UTF-8 string.

 *

 *

 * This can be used to either reject strings which contain 4 byte UTF-8
* characters, or replace them with question marks. This is limited to UTF-8
* collated databases using MySQL.
*
* Original: http://www.avidheap.org/2013/a-quick-way-to-normalize-a-utf8-string-when-your-mysql-database-is-not-utf8mb4
*
* @param string The string to be checked.
* @param bool If false don't return the string, only the boolean result.
* @return mixed Return a string if the second parameter is true, boolean otherwise.

 * @param string The string to be checked
* @param boolean Allow 4 byte UTF-8 characters?
* @param boolean Return the cleaned string?
* @return string/boolean Cleaned string or boolean






 */

 */

function utf8_handle_4byte_string($input, $return=true)

function validate_utf8_string($input, $allow_mb4=true, $return=true)

{

{

	global $config;

if($config['database']['type'] != 'mysql' && $config['database']['type'] != 'mysqli')
{
if($return == true)
{
return $input;
}
return true;
}

$contains_4bytes = false;
if(!empty($input))
{
$utf8_2byte = 0xC0 /*1100 0000*/;
$utf8_2byte_bmask = 0xE0 /*1110 0000*/;

$utf8_3byte = 0xE0 /*1110 0000*/;
$utf8_3byte_bmask = 0XF0 /*1111 0000*/;

$utf8_4byte = 0xF0 /*1111 0000*/;
$utf8_4byte_bmask = 0xF8 /*1111 1000*/;

$sanitized = "";

	// Valid UTF-8 sequence?
if(!preg_match('##u', $input))
{
$string = '';





















		$len = strlen($input);

		$len = strlen($input);

		for($i = 0; $i < $len; ++$i)
{
$mb_char = $input[$i]; // Potentially a multibyte sequence
$byte = ord($mb_char);
if(($byte & $utf8_2byte_bmask) == $utf8_2byte)

		for($i = 0; $i < $len; $i++)
{
$c = ord($input[$i]);
if($c > 128)


			{

			{

				$mb_char .= $input[++$i];
}
elseif(($byte & $utf8_3byte_bmask) == $utf8_3byte)
{
$mb_char .= $input[++$i];
$mb_char .= $input[++$i];




























































				if($c > 247 || $c <= 191)
{
if($return)
{
$string .= '?';
continue;
}
else
{
return false;
}
}
elseif($c > 239)
{
$bytes = 4;
}
elseif($c > 223)
{
$bytes = 3;
}
elseif($c > 191)
{
$bytes = 2;
}
if(($i + $bytes) > $len)
{
if($return)
{
$string .= '?';
break;
}
else
{
return false;
}
}
$valid = true;
$multibytes = $input[$i];
while($bytes > 1)
{
$i++;
$b = ord($input[$i]);
if($b < 128 || $b > 191)
{
if($return)
{
$valid = false;
$string .= '?';
break;
}
else
{
return false;
}
}
else
{
$multibytes .= $input[$i];
}
$bytes--;
}
if($valid)
{
$string .= $multibytes;
}

			}

			}

			elseif(($byte & $utf8_4byte_bmask) == $utf8_4byte)
{
$contains_4bytes = true;
// Replace with ? to avoid MySQL exception
$mb_char = '?';
$i += 3;

			else
{
$string .= $input[$i];




			}

			}


$sanitized .= $mb_char;

if($contains_4bytes == true && $return == false)
{
return false;
}
}

$input = $sanitized;




		}
$input = $string;
}
if($return)
{
if($allow_mb4)
{
return $input;
}
else
{
return preg_replace("#[^\\x00-\\x7F][\\x80-\\xBF]{3,}#", '?', $input);
}

	}

	}


if($contains_4bytes == false && $return == false)

	else


	{

	{

		return true;








		if($allow_mb4)
{
return true;
}
else
{
return !preg_match("#[^\\x00-\\x7F][\\x80-\\xBF]{3,}#", $input);
}

	}

	}

	return $input;

 
}
?>

}
?>