Vergleich inc/functions.php - 1.8.1 - 1.8.5

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

if(isset($config))
{


if(isset($config))
{

 
			// Load DB interface
require_once MYBB_ROOT."inc/db_base.php";


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

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

Zeile 397Zeile 400
	if($format == 'relative')
{
// Relative formats both date and time

	if($format == 'relative')
{
// Relative formats both date and time

		if($ty != 2 && (TIME_NOW - $stamp) < 3600)

		if($ty != 2 && abs(TIME_NOW - $stamp) < 3600)

		{
$diff = TIME_NOW - $stamp;
$relative = array('prefix' => '', 'minute' => 0, 'plural' => $lang->rel_minutes_plural, 'suffix' => $lang->rel_ago);

		{
$diff = TIME_NOW - $stamp;
$relative = array('prefix' => '', 'minute' => 0, 'plural' => $lang->rel_minutes_plural, 'suffix' => $lang->rel_ago);

Zeile 425Zeile 428

$date = $lang->sprintf($lang->rel_time, $relative['prefix'], $relative['minute'], $relative['plural'], $relative['suffix']);
}


$date = $lang->sprintf($lang->rel_time, $relative['prefix'], $relative['minute'], $relative['plural'], $relative['suffix']);
}

		elseif($ty != 2 && (TIME_NOW - $stamp) >= 3600 && (TIME_NOW - $stamp) < 43200)

		elseif($ty != 2 && abs(TIME_NOW - $stamp) < 43200)

		{
$diff = TIME_NOW - $stamp;
$relative = array('prefix' => '', 'hour' => 0, 'plural' => $lang->rel_hours_plural, 'suffix' => $lang->rel_ago);

		{
$diff = TIME_NOW - $stamp;
$relative = array('prefix' => '', 'hour' => 0, 'plural' => $lang->rel_hours_plural, 'suffix' => $lang->rel_ago);

Zeile 756Zeile 759
	}

// AJAX error message?

	}

// AJAX error message?

	if($mybb->get_input('ajax', 1))

	if($mybb->get_input('ajax', MyBB::INPUT_INT))

	{
// Send our headers.
@header("Content-type: application/json; charset={$lang->settings['charset']}");

	{
// Send our headers.
@header("Content-type: application/json; charset={$lang->settings['charset']}");

Zeile 802Zeile 805
	}

// AJAX error message?

	}

// AJAX error message?

	if($mybb->get_input('ajax', 1))

	if($mybb->get_input('ajax', MyBB::INPUT_INT))

	{
// Send our headers.
@header("Content-type: application/json; charset={$lang->settings['charset']}");

	{
// Send our headers.
@header("Content-type: application/json; charset={$lang->settings['charset']}");

Zeile 848Zeile 851

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



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


	if($mybb->get_input('ajax', 1))

	if($mybb->get_input('ajax', MyBB::INPUT_INT))

	{
// Send our headers.
header("Content-type: application/json; charset={$lang->settings['charset']}");

	{
// Send our headers.
header("Content-type: application/json; charset={$lang->settings['charset']}");

Zeile 909Zeile 912

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



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


	if($mybb->get_input('ajax', 1))

	if($mybb->get_input('ajax', MyBB::INPUT_INT))

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

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

Zeile 1198Zeile 1201
}

/**

}

/**

 * Fetch the usergroup permissions for a specic group or series of groups combined

 * Fetch the usergroup permissions for a specific group or series of groups combined

 *
* @param mixed A list of groups (Can be a single integer, or a list of groups separated by a comma)
* @return array Array of permissions generated for the groups

 *
* @param mixed A list of groups (Can be a single integer, or a list of groups separated by a comma)
* @return array Array of permissions generated for the groups

Zeile 1213Zeile 1216
	}

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

	}

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



 

if(count($groups) == 1)
{
return $groupscache[$gid];
}


if(count($groups) == 1)
{
return $groupscache[$gid];
}

 
	
$usergroup = array();


foreach($groups as $gid)
{


foreach($groups as $gid)
{

Zeile 1251Zeile 1255
				{
$usergroup[$perm] = $access;
}

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

			}
}
}

			}
}
}


return $usergroup;
}


return $usergroup;
}

Zeile 1279Zeile 1283
	foreach($displaygroupfields as $field)
{
$displaygroup[$field] = $group[$field];

	foreach($displaygroupfields as $field)
{
$displaygroup[$field] = $group[$field];

	}


	}


	return $displaygroup;
}


	return $displaygroup;
}


Zeile 1306Zeile 1310
		if($uid != 0 && $uid != $mybb->user['uid'])
{
$user = get_user($uid);

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





			$gid = $user['usergroup'].",".$user['additionalgroups'];
$groupperms = usergroup_permissions($gid);
}
else
{
$gid = $mybb->user['usergroup'];

			$gid = $user['usergroup'].",".$user['additionalgroups'];
$groupperms = usergroup_permissions($gid);
}
else
{
$gid = $mybb->user['usergroup'];





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

$groupperms = $mybb->usergroup;

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

$groupperms = $mybb->usergroup;

		}
}


		}
}


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

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





		if(!$forum_cache)
{
return false;

		if(!$forum_cache)
{
return false;

		}
}


		}
}


	if(!is_array($fpermcache))

	if(!is_array($fpermcache))

	{

	{

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


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


Zeile 1345Zeile 1349
			$cached_forum_permissions_permissions[$gid][$fid] = fetch_forum_permissions($fid, $gid, $groupperms);
}
return $cached_forum_permissions_permissions[$gid][$fid];

			$cached_forum_permissions_permissions[$gid][$fid] = fetch_forum_permissions($fid, $gid, $groupperms);
}
return $cached_forum_permissions_permissions[$gid][$fid];

	}

	}

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

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

Zeile 1358Zeile 1362
		return $cached_forum_permissions[$gid];
}
}

		return $cached_forum_permissions[$gid];
}
}





/**
* Fetches the permissions for a specific forum/group applying the inheritance scheme.
* Called by forum_permissions()

/**
* Fetches the permissions for a specific forum/group applying the inheritance scheme.
* Called by forum_permissions()

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

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





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

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

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

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

Zeile 1381Zeile 1385

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


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

 
	$only_reply_own_threads = 1;


foreach($groups as $gid)
{


foreach($groups as $gid)
{

Zeile 1410Zeile 1415
			if(empty($level_permissions))
{
$level_permissions = $groupscache[$gid];

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

			}

			}


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


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

			{

			{

				if(empty($current_permissions[$permission]) || $access >= $current_permissions[$permission] || ($access == "yes" && $current_permissions[$permission] == "no"))
{
$current_permissions[$permission] = $access;
}

				if(empty($current_permissions[$permission]) || $access >= $current_permissions[$permission] || ($access == "yes" && $current_permissions[$permission] == "no"))
{
$current_permissions[$permission] = $access;
}

			}


			}


			if($level_permissions["canview"] && empty($level_permissions["canonlyviewownthreads"]))
{
$only_view_own_threads = 0;

			if($level_permissions["canview"] && empty($level_permissions["canonlyviewownthreads"]))
{
$only_view_own_threads = 0;

			}
}
}







			}

if($level_permissions["canpostreplys"] && empty($level_permissions["canonlyreplyownthreads"]))
{
$only_reply_own_threads = 0;
}
}
}


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

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

 
	}

// Figure out if we can reply more than our own threads
if($only_reply_own_threads == 0)
{
$current_permissions["canonlyreplyownthreads"] = 0;

	}

if(count($current_permissions) == 0)

	}

if(count($current_permissions) == 0)

Zeile 1438Zeile 1454
		$current_permissions = $groupperms;
}
return $current_permissions;

		$current_permissions = $groupperms;
}
return $current_permissions;

}

/**

}

/**

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

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

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

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





	$showform = true;

if(!is_array($forum_cache))

	$showform = true;

if(!is_array($forum_cache))

	{

	{

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

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

Zeile 1466Zeile 1482
	{
$parents = explode(',', $forum_cache[$fid]['parentlist']);
rsort($parents);

	{
$parents = explode(',', $forum_cache[$fid]['parentlist']);
rsort($parents);

	}

	}

	if(!empty($parents))
{
foreach($parents as $parent_id)

	if(!empty($parents))
{
foreach($parents as $parent_id)

Zeile 1479Zeile 1495
			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 1488Zeile 1504
		$password = $forum_cache[$fid]['password'];
if(isset($mybb->input['pwverify']) && $pid == 0)
{

		$password = $forum_cache[$fid]['password'];
if(isset($mybb->input['pwverify']) && $pid == 0)
{

			if($password == $mybb->get_input('pwverify'))
{

			if($password === $mybb->get_input('pwverify'))
{

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

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

				$showform = false;
}
else
{

				$showform = false;
}
else
{

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

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

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

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

			{
$showform = true;
}

			{
$showform = true;
}

Zeile 1521Zeile 1537
		if($pid)
{
header("Location: ".$mybb->settings['bburl']."/".get_forum_link($fid));

		if($pid)
{
header("Location: ".$mybb->settings['bburl']."/".get_forum_link($fid));

		}

		}

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

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

Zeile 1534Zeile 1550

/**
* Return the permissions for a moderator in a specific forum


/**
* Return the permissions for a moderator in a specific forum

 *

 *

 * @param fid The forum ID
* @param uid The user ID to fetch permissions for (0 assumes current logged in user)
* @param string The parent list for the forum (if blank, will be fetched)

 * @param fid The forum ID
* @param uid The user ID to fetch permissions for (0 assumes current logged in user)
* @param string The parent list for the forum (if blank, will be fetched)

Zeile 1586Zeile 1602
	foreach($mod_cache as $forumid => $forum)
{
if(!is_array($forum) || !in_array($forumid, $parentslist))

	foreach($mod_cache as $forumid => $forum)
{
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 1595Zeile 1611
		if(is_array($forum['users'][$uid]))
{
$perm = $forum['users'][$uid];

		if(is_array($forum['users'][$uid]))
{
$perm = $forum['users'][$uid];

			foreach($perm as $action => $value)
{
if(strpos($action, "can") === false)
{
continue;

			foreach($perm as $action => $value)
{
if(strpos($action, "can") === false)
{
continue;

				}

// Figure out the user permissions
if($value == 0)

				}

// Figure out the user permissions
if($value == 0)

				{

				{

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

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

				}
}

				}
}

		}

foreach($groups as $group)

		}

foreach($groups as $group)

Zeile 1639Zeile 1655
	$modpermscache[$fid][$uid] = $perms;

return $perms;

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

return $perms;

}


}


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

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

Zeile 1652Zeile 1668
function is_moderator($fid="0", $action="", $uid="0")
{
global $mybb, $cache;

function is_moderator($fid="0", $action="", $uid="0")
{
global $mybb, $cache;


if($uid == 0)
{


if($uid == 0)
{

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

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

	}

	}


if($uid == 0)


if($uid == 0)

	{

	{

		return false;
}


		return false;
}


Zeile 1667Zeile 1683
	if($user_perms['issupermod'] == 1)
{
if($fid)

	if($user_perms['issupermod'] == 1)
{
if($fid)

		{

		{

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

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

Zeile 1680Zeile 1696
	else
{
if(!$fid)

	else
{
if(!$fid)

		{

		{

			$modcache = $cache->read('moderators');
if(!empty($modcache))
{

			$modcache = $cache->read('moderators');
if(!empty($modcache))
{

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

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





	foreach($posticons as $dbicon)
{
$dbicon['path'] = str_replace("{theme}", $theme['imgdir'], $dbicon['path']);

	foreach($posticons as $dbicon)
{
$dbicon['path'] = str_replace("{theme}", $theme['imgdir'], $dbicon['path']);

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

		$dbicon['path'] = htmlspecialchars_uni($mybb->get_asset_url($dbicon['path']));

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

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

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

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

Zeile 1899Zeile 1915
	}

$newcookie[$id] = $value;

	}

$newcookie[$id] = $value;

	$newcookie = serialize($newcookie);

	$newcookie = my_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;

	my_setcookie("mybb[$name]", addslashes($newcookie), $expires);

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

 
}

/*
* Arbitrary limits for _safe_unserialize()
*/
define('MAX_SERIALIZED_INPUT_LENGTH', 10240);
define('MAX_SERIALIZED_ARRAY_LENGTH', 256);
define('MAX_SERIALIZED_ARRAY_DEPTH', 5);

/**
* Credits go to https://github.com/piwik
* Safe unserialize() replacement
* - accepts a strict subset of PHP's native my_serialized representation
* - does not unserialize objects
*
* @param string $str
* @return mixed
* @throw Exception if $str is malformed or contains unsupported types (e.g., resources, objects)
*/
function _safe_unserialize($str)
{
if(strlen($str) > MAX_SERIALIZED_INPUT_LENGTH)
{
// input exceeds MAX_SERIALIZED_INPUT_LENGTH
return false;
}

if(empty($str) || !is_string($str))
{
return false;
}

$stack = array();
$expected = array();

/*
* states:
* 0 - initial state, expecting a single value or array
* 1 - terminal state
* 2 - in array, expecting end of array or a key
* 3 - in array, expecting value or another array
*/
$state = 0;
while($state != 1)
{
$type = isset($str[0]) ? $str[0] : '';

if($type == '}')
{
$str = substr($str, 1);
}
else if($type == 'N' && $str[1] == ';')
{
$value = null;
$str = substr($str, 2);
}
else if($type == 'b' && preg_match('/^b:([01]);/', $str, $matches))
{
$value = $matches[1] == '1' ? true : false;
$str = substr($str, 4);
}
else if($type == 'i' && preg_match('/^i:(-?[0-9]+);(.*)/s', $str, $matches))
{
$value = (int)$matches[1];
$str = $matches[2];
}
else if($type == 'd' && preg_match('/^d:(-?[0-9]+\.?[0-9]*(E[+-][0-9]+)?);(.*)/s', $str, $matches))
{
$value = (float)$matches[1];
$str = $matches[3];
}
else if($type == 's' && preg_match('/^s:([0-9]+):"(.*)/s', $str, $matches) && substr($matches[2], (int)$matches[1], 2) == '";')
{
$value = substr($matches[2], 0, (int)$matches[1]);
$str = substr($matches[2], (int)$matches[1] + 2);
}
else if($type == 'a' && preg_match('/^a:([0-9]+):{(.*)/s', $str, $matches) && $matches[1] < MAX_SERIALIZED_ARRAY_LENGTH)
{
$expectedLength = (int)$matches[1];
$str = $matches[2];
}
else
{
// object or unknown/malformed type
return false;
}

switch($state)
{
case 3: // in array, expecting value or another array
if($type == 'a')
{
if(count($stack) >= MAX_SERIALIZED_ARRAY_DEPTH)
{
// array nesting exceeds MAX_SERIALIZED_ARRAY_DEPTH
return false;
}

$stack[] = &$list;
$list[$key] = array();
$list = &$list[$key];
$expected[] = $expectedLength;
$state = 2;
break;
}
if($type != '}')
{
$list[$key] = $value;
$state = 2;
break;
}

// missing array value
return false;

case 2: // in array, expecting end of array or a key
if($type == '}')
{
if(count($list) < end($expected))
{
// array size less than expected
return false;
}

unset($list);
$list = &$stack[count($stack)-1];
array_pop($stack);

// go to terminal state if we're at the end of the root array
array_pop($expected);
if(count($expected) == 0) {
$state = 1;
}
break;
}
if($type == 'i' || $type == 's')
{
if(count($list) >= MAX_SERIALIZED_ARRAY_LENGTH)
{
// array size exceeds MAX_SERIALIZED_ARRAY_LENGTH
return false;
}
if(count($list) >= end($expected))
{
// array size exceeds expected length
return false;
}

$key = $value;
$state = 3;
break;
}

// illegal array index type
return false;

case 0: // expecting array or value
if($type == 'a')
{
if(count($stack) >= MAX_SERIALIZED_ARRAY_DEPTH)
{
// array nesting exceeds MAX_SERIALIZED_ARRAY_DEPTH
return false;
}

$data = array();
$list = &$data;
$expected[] = $expectedLength;
$state = 2;
break;
}
if($type != '}')
{
$data = $value;
$state = 1;
break;
}

// not in array
return false;
}
}

if(!empty($str))
{
// trailing data in input
return false;
}
return $data;
}

/**
* Credits go to https://github.com/piwik
* Wrapper for _safe_unserialize() that handles exceptions and multibyte encoding issue
*
* @param string $str
* @return mixed
*/
function my_unserialize($str)
{
// Ensure we use the byte count for strings even when strlen() is overloaded by mb_strlen()
if(function_exists('mb_internal_encoding') && (((int)ini_get('mbstring.func_overload')) & 2))
{
$mbIntEnc = mb_internal_encoding();
mb_internal_encoding('ASCII');
}

$out = _safe_unserialize($str);

if(isset($mbIntEnc))
{
mb_internal_encoding($mbIntEnc);
}

return $out;
}

/**
* Credits go to https://github.com/piwik
* Safe serialize() replacement
* - output a strict subset of PHP's native serialized representation
* - does not my_serialize objects
*
* @param mixed $value
* @return string
* @throw Exception if $value is malformed or contains unsupported types (e.g., resources, objects)
*/
function _safe_serialize( $value )
{
if(is_null($value))
{
return 'N;';
}

if(is_bool($value))
{
return 'b:'.(int)$value.';';
}

if(is_int($value))
{
return 'i:'.$value.';';
}

if(is_float($value))
{
return 'd:'.str_replace(',', '.', $value).';';
}

if(is_string($value))
{
return 's:'.strlen($value).':"'.$value.'";';
}

if(is_array($value))
{
$out = '';
foreach($value as $k => $v)
{
$out .= _safe_serialize($k) . _safe_serialize($v);
}

return 'a:'.count($value).':{'.$out.'}';
}

// safe_serialize cannot my_serialize resources or objects
return false;

}

/**

}

/**

 * Verifies that data passed is an array


 * Credits go to https://github.com/piwik
* Wrapper for _safe_serialize() that handles exceptions and multibyte encoding issue

 *

 *

 * @param array Data to unserialize
* @return array Unserialized data array
*/
function my_unserialize($data)

 * @param mixed $value
* @return string
*/
function my_serialize($value)

{

{

	$array = unserialize($data);

if(!is_array($array))







	// ensure we use the byte count for strings even when strlen() is overloaded by mb_strlen()
if(function_exists('mb_internal_encoding') && (((int)ini_get('mbstring.func_overload')) & 2))
{
$mbIntEnc = mb_internal_encoding();
mb_internal_encoding('ASCII');
}

$out = _safe_serialize($value);
if(isset($mbIntEnc))

	{

	{

		$array = array();

		mb_internal_encoding($mbIntEnc);

	}

	}


return $array;

	
return $out;

}

/**

}

/**

Zeile 1934Zeile 2224
	global $mybb, $lang;

$serverload = array();

	global $mybb, $lang;

$serverload = array();





	// DIRECTORY_SEPARATOR checks if running windows
if(DIRECTORY_SEPARATOR != '\\')
{

	// DIRECTORY_SEPARATOR checks if running windows
if(DIRECTORY_SEPARATOR != '\\')
{

Zeile 1968Zeile 2258
			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 1979Zeile 2269
			if(!is_array($serverload))
{
return $lang->unknown;

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

			}
}
}
else

			}
}
}
else

	{
return $lang->unknown;
}

	{
return $lang->unknown;
}

Zeile 2074Zeile 2364
				{
$new_stats[$counter] = $stats[$counter] + $changes[$counter];
if(!$force && (substr($stats[$counter], 0, 1) == "+" || substr($stats[$counter], 0, 1) == "-"))

				{
$new_stats[$counter] = $stats[$counter] + $changes[$counter];
if(!$force && (substr($stats[$counter], 0, 1) == "+" || substr($stats[$counter], 0, 1) == "-"))

					{

					{

						// We had relative values? Then it is still relative
if($new_stats[$counter] >= 0)
{

						// We had relative values? Then it is still relative
if($new_stats[$counter] >= 0)
{

Zeile 2086Zeile 2376
					{
$new_stats[$counter] = 0;
}

					{
$new_stats[$counter] = 0;
}

				}
}

				}
}

			else
{
$new_stats[$counter] = $changes[$counter];

			else
{
$new_stats[$counter] = $changes[$counter];

Zeile 2095Zeile 2385
				if($new_stats[$counter] < 0)
{
$new_stats[$counter] = 0;

				if($new_stats[$counter] < 0)
{
$new_stats[$counter] = 0;

				}
}
}
}


				}
}
}
}


	if(!$force)
{
$stats_changes = array_merge($stats, $new_stats); // Overwrite changed values

	if(!$force)
{
$stats_changes = array_merge($stats, $new_stats); // Overwrite changed values

Zeile 2135Zeile 2425
		"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");
$stats_changes['inserted'] = true;
}

	$cache->update("stats", $stats, "dateline");
$stats_changes['inserted'] = true;
}

Zeile 2172Zeile 2462
				if((int)$changes[$counter] != 0)
{
$update_query[$counter] = $forum[$counter] + $changes[$counter];

				if((int)$changes[$counter] != 0)
{
$update_query[$counter] = $forum[$counter] + $changes[$counter];

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


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


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

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

Zeile 2491Zeile 2781

// 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("users", $update_query, "uid='{$uid}'");
}
}

		$db->update_query("users", $update_query, "uid='{$uid}'");
}
}





/**
* Deletes a thread from the database
*
* @param int The thread ID
*/
function delete_thread($tid)

/**
* Deletes a thread from the database
*
* @param int The thread ID
*/
function delete_thread($tid)

{
global $moderation;

if(!is_object($moderation))

{
global $moderation;

if(!is_object($moderation))

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

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





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


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


Zeile 2518Zeile 2808
 * Deletes a post from the database
*
* @param int The thread ID

 * Deletes a post from the database
*
* @param int The thread ID

 */

 */

function delete_post($pid)
{
global $moderation;

function delete_post($pid)
{
global $moderation;





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

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

Zeile 2531Zeile 2821

return $moderation->delete_post($pid);
}


return $moderation->delete_post($pid);
}





/**
* Builds a forum jump menu
*

/**
* Builds a forum jump menu
*

Zeile 2541Zeile 2831
 * @param int The current depth of forums we're at
* @param int Whether or not to show extra items such as User CP, Forum home
* @param boolean Ignore the showinjump setting and show all forums (for moderation pages)

 * @param int The current depth of forums we're at
* @param int Whether or not to show extra items such as User CP, Forum home
* @param boolean Ignore the showinjump setting and show all forums (for moderation pages)

 * @param array Array of permissions

 * @param unknown_type deprecated

 * @param string The name of the forum jump
* @return string Forum jump items
*/
function build_forum_jump($pid="0", $selitem="", $addselect="1", $depth="", $showextras="1", $showall=false, $permissions="", $name="fid")
{

 * @param string The name of the forum jump
* @return string Forum jump items
*/
function build_forum_jump($pid="0", $selitem="", $addselect="1", $depth="", $showextras="1", $showall=false, $permissions="", $name="fid")
{

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

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


$pid = (int)$pid;


$pid = (int)$pid;

	$jumpsel['default'] = '';

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

 

if(!is_array($jumpfcache))
{


if(!is_array($jumpfcache))
{

Zeile 2565Zeile 2849
		}

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

		}

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

		{

		{

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

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

Zeile 2591Zeile 2875
					$optionselected = "";

if($selitem == $forum['fid'])

					$optionselected = "";

if($selitem == $forum['fid'])

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

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

					{
$optionselected = 'selected="selected"';
}

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



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



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


Zeile 2604Zeile 2887
					{
$newdepth = $depth."--";
$forumjumpbits .= build_forum_jump($forum['fid'], $selitem, 0, $newdepth, $showextras, $showall);

					{
$newdepth = $depth."--";
$forumjumpbits .= build_forum_jump($forum['fid'], $selitem, 0, $newdepth, $showextras, $showall);

					}
}
}

					}
}
}

		}
}

if($addselect)
{

		}
}

if($addselect)
{

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

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

if($showextras == 0)

		if($showextras == 0)











		{
$template = "special";
}
else
{
$template = "advanced";

		{
$template = "special";
}
else
{
$template = "advanced";





			if(strpos(FORUM_URL, '.html') !== false)

			if(strpos(FORUM_URL, '.html') !== false)

			{
$forum_link = "'".str_replace('{fid}', "'+this.options[this.selectedIndex].value+'", FORUM_URL)."'";
}

			{
$forum_link = "'".str_replace('{fid}', "'+option+'", FORUM_URL)."'";
}

			else
{

			else
{

				$forum_link = "'".str_replace('{fid}', "'+this.options[this.selectedIndex].value", FORUM_URL);

				$forum_link = "'".str_replace('{fid}', "'+option", 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 2655Zeile 2928
function get_extension($file)
{
return my_strtolower(my_substr(strrchr($file, "."), 1));

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

}

/**

}

/**

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

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

Zeile 2709Zeile 2982
	}

$format = stripslashes($format);

	}

$format = stripslashes($format);





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


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


Zeile 2722Zeile 2995
 * @return array Information for the formatted avatar
*/
function format_avatar($avatar, $dimensions = '', $max_dimensions = '')

 * @return array Information for the formatted avatar
*/
function format_avatar($avatar, $dimensions = '', $max_dimensions = '')

{

{

	global $mybb;
static $avatars;

if(!isset($avatars))

	global $mybb;
static $avatars;

if(!isset($avatars))

	{

	{

		$avatars = array();

		$avatars = array();

	}


	}


	if(!$avatar)

	if(!$avatar)

	{

	{

		// Default avatar
$avatar = $mybb->settings['useravatar'];
$dimensions = $mybb->settings['useravatardims'];
}


		// Default avatar
$avatar = $mybb->settings['useravatar'];
$dimensions = $mybb->settings['useravatardims'];
}


	if(isset($avatars[$avatar]))


















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

// An empty key wouldn't work so we need to add a fall back
$key = $dimensions;
if(empty($key))
{
$key = 'default';
}
$key2 = $max_dimensions;
if(empty($key2))
{
$key2 = 'default';
}

if(isset($avatars[$avatar][$key][$key2]))

	{

	{

		return $avatars[$avatar];
}

if(!$max_dimensions)
{
$max_dimensions = $mybb->settings['maxavatardims'];

		return $avatars[$avatar][$key][$key2];






	}

$avatar_width_height = '';

	}

$avatar_width_height = '';

Zeile 2758Zeile 3043
		{
list($max_width, $max_height) = explode('x', $max_dimensions);


		{
list($max_width, $max_height) = explode('x', $max_dimensions);


			if($dimensions[0] > $max_width || $dimensions[1] > $max_height)

			if(!empty($max_dimensions) && ($dimensions[0] > $max_width || $dimensions[1] > $max_height))

			{
require_once MYBB_ROOT."inc/functions_image.php";
$scaled_dimensions = scale_image($dimensions[0], $dimensions[1], $max_width, $max_height);

			{
require_once MYBB_ROOT."inc/functions_image.php";
$scaled_dimensions = scale_image($dimensions[0], $dimensions[1], $max_width, $max_height);

Zeile 2771Zeile 3056
		}
}


		}
}


	$avatars[$avatar] = array(
'image' => $mybb->get_asset_url($avatar),

	$avatars[$avatar][$key][$key2] = array(
'image' => htmlspecialchars_uni($mybb->get_asset_url($avatar)),

		'width_height' => $avatar_width_height
);


		'width_height' => $avatar_width_height
);


	return $avatars[$avatar];

	return $avatars[$avatar][$key][$key2];

}

/**

}

/**

Zeile 2933Zeile 3218
						// Only show the first text to replace in the box
$smilie['find'] = $finds[0];


						// Only show the first text to replace in the box
$smilie['find'] = $finds[0];


						$find = htmlspecialchars_uni($smilie['find']);
$image = $mybb->get_asset_url($smilie['image']);
$image = htmlspecialchars_uni($image);


						$find = str_replace(array('\\', '"'), array('\\\\', '\"'), htmlspecialchars_uni($smilie['find']));
$image = htmlspecialchars_uni($mybb->get_asset_url($smilie['image']));
$image = str_replace(array('\\', '"'), array('\\\\', '\"'), $image);


						if($i < $mybb->settings['smilieinsertertot'])
{
$dropdownsmilies .= '"'.$find.'": "'.$image.'",';

						if($i < $mybb->settings['smilieinsertertot'])
{
$dropdownsmilies .= '"'.$find.'": "'.$image.'",';

Zeile 2947Zeile 3233

for($j = 1; $j < $finds_count; ++$j)
{


for($j = 1; $j < $finds_count; ++$j)
{

							$find = htmlspecialchars_uni($finds[$j]);

							$find = str_replace(array('\\', '"'), array('\\\\', '\"'), htmlspecialchars_uni($finds[$j]));

							$hiddensmilies .= '"'.$find.'": "'.$image.'",';
}
++$i;

							$hiddensmilies .= '"'.$find.'": "'.$image.'",';
}
++$i;

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

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







					
$smilie['image'] = str_replace("{theme}", $theme['imgdir'], $smilie['image']);
$smilie['image'] = htmlspecialchars_uni($mybb->get_asset_url($smilie['image']));
$smilie['name'] = htmlspecialchars_uni($smilie['name']);


					// Only show the first text to replace in the box
$temp = explode("\n", $smilie['find']); // assign to temporary variable for php 5.3 compatibility
$smilie['find'] = $temp[0];


					// Only show the first text to replace in the box
$temp = explode("\n", $smilie['find']); // assign to temporary variable for php 5.3 compatibility
$smilie['find'] = $temp[0];


					$find = htmlspecialchars_uni($smilie['find']);

					$find = str_replace(array('\\', "'"), array('\\\\', "\'"), htmlspecialchars_uni($smilie['find']));





					$onclick = ' onclick="MyBBEditor.insertText(\' '.$smilie['find'].' \');"';

					$onclick = " onclick=\"MyBBEditor.insertText(' $find ');\"";

					$extra_class = ' smilie_pointer';
eval('$smilie = "'.$templates->get('smilie', 1, 0).'";');
eval("\$smilies .= \"".$templates->get("smilieinsert_smilie")."\";");

					$extra_class = ' smilie_pointer';
eval('$smilie = "'.$templates->get('smilie', 1, 0).'";');
eval("\$smilies .= \"".$templates->get("smilieinsert_smilie")."\";");

Zeile 3116Zeile 3406
		else
{
$clickablesmilies = "";

		else
{
$clickablesmilies = "";

		}
}

		}
}

	else
{
$clickablesmilies = "";

	else
{
$clickablesmilies = "";

Zeile 3150Zeile 3440
	$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 3173Zeile 3463
	else if(!empty($prefixes_cache))
{
return $prefixes_cache;

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

	}


	}


	return false;
}


	return false;
}


Zeile 3353Zeile 3643
	else if($selected_pid == -2)
{
$default_selected['any'] = ' selected="selected"';

	else if($selected_pid == -2)
{
$default_selected['any'] = ' selected="selected"';

	}


	}


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

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

Zeile 3454Zeile 3744
		unset($data['pid']);
}


		unset($data['pid']);
}


	// Any remaining extra data - we serialize and insert in to its own column

	// Any remaining extra data - we my_serialize and insert in to its own column

	if(is_array($data))
{

	if(is_array($data))
{

		$data = serialize($data);

		$data = my_serialize($data);

	}

$sql_array = array(

	}

$sql_array = array(

Zeile 3497Zeile 3787
	{
$reputation_class = "reputation_neutral";
}

	{
$reputation_class = "reputation_neutral";
}

 
	
$reputation = my_number_format($reputation);


if($uid != 0)
{


if($uid != 0)
{

Zeile 3551Zeile 3843
{
global $mybb, $plugins;


{
global $mybb, $plugins;


	$ip = $_SERVER['REMOTE_ADDR'];

	$ip = strtolower($_SERVER['REMOTE_ADDR']);


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


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

Zeile 3559Zeile 3851

if(isset($_SERVER['HTTP_X_FORWARDED_FOR']))
{


if(isset($_SERVER['HTTP_X_FORWARDED_FOR']))
{

			$addresses = explode(',', $_SERVER['HTTP_X_FORWARDED_FOR']);

			$addresses = explode(',', strtolower($_SERVER['HTTP_X_FORWARDED_FOR']));

		}
elseif(isset($_SERVER['HTTP_X_REAL_IP']))
{

		}
elseif(isset($_SERVER['HTTP_X_REAL_IP']))
{

			$addresses = explode(',', $_SERVER['HTTP_X_REAL_IP']);

			$addresses = explode(',', strtolower($_SERVER['HTTP_X_REAL_IP']));

		}

if(is_array($addresses))

		}

if(is_array($addresses))

Zeile 3585Zeile 3877
	{
if(isset($_SERVER['HTTP_CLIENT_IP']))
{

	{
if(isset($_SERVER['HTTP_CLIENT_IP']))
{

			$ip = $_SERVER['HTTP_CLIENT_IP'];

			$ip = strtolower($_SERVER['HTTP_CLIENT_IP']);

		}
}


		}
}


Zeile 3704Zeile 3996
 */
function get_attachment_icon($ext)
{

 */
function get_attachment_icon($ext)
{

	global $cache, $attachtypes, $theme, $templates, $lang;

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


if(!$attachtypes)
{


if(!$attachtypes)
{

Zeile 3714Zeile 4006
	$ext = my_strtolower($ext);

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

	$ext = my_strtolower($ext);

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

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














	{
static $attach_icons_schemes = array();
if(!isset($attach_icons_schemes[$ext]))
{
$attach_icons_schemes[$ext] = parse_url($attachtypes[$ext]['icon']);
if(!empty($attach_icons_schemes[$ext]['scheme']))
{
$attach_icons_schemes[$ext] = $attachtypes[$ext]['icon'];
}
elseif(defined("IN_ADMINCP"))
{
$attach_icons_schemes[$ext] = str_replace("{theme}", "", $attachtypes[$ext]['icon']);
if(my_substr($attach_icons_schemes[$ext], 0, 1) != "/")
{
$attach_icons_schemes[$ext] = "../".$attach_icons_schemes[$ext];
}
}
elseif(defined("IN_PORTAL"))

			{

			{

				$icon = "../".$icon;








				global $change_dir;
$attach_icons_schemes[$ext] = $change_dir."/".str_replace("{theme}", $theme['imgdir'], $attachtypes[$ext]['icon']);
$attach_icons_schemes[$ext] = $mybb->get_asset_url($attach_icons_schemes[$ext]);
}
else
{
$attach_icons_schemes[$ext] = str_replace("{theme}", $theme['imgdir'], $attachtypes[$ext]['icon']);
$attach_icons_schemes[$ext] = $mybb->get_asset_url($attach_icons_schemes[$ext]);

			}
}

			}
}

		elseif(defined("IN_PORTAL"))
{
global $change_dir;
$icon = $change_dir."/".str_replace("{theme}", $theme['imgdir'], $attachtypes[$ext]['icon']);
}
else
{
$icon = str_replace("{theme}", $theme['imgdir'], $attachtypes[$ext]['icon']);
}


$icon = $attach_icons_schemes[$ext];









$name = htmlspecialchars_uni($attachtypes[$ext]['name']);
}


$name = htmlspecialchars_uni($attachtypes[$ext]['name']);
}

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

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

		}



		}

$icon = "{$theme['imgdir']}/attachtypes/unknown.png";





		$icon = "{$theme['imgdir']}/attachtypes/unknown.png";

 
		$name = $lang->unknown;
}


		$name = $lang->unknown;
}


 
	$icon = htmlspecialchars_uni($icon);

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

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

Zeile 3763Zeile 4070
 */
function get_unviewable_forums($only_readable_threads=false)
{

 */
function get_unviewable_forums($only_readable_threads=false)
{

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

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

	global $forum_cache, $permissioncache, $mybb;







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


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

	}


	}


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


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


	$unviewableforums = '';
$password_forums = array();

	$password_forums = $unviewable = array();


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

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

		}

		}

		else
{
$perms = $mybb->usergroup;

		else
{
$perms = $mybb->usergroup;

Zeile 3797Zeile 4098

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


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

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

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

			{
$pwverified = 0;
}

			{
$pwverified = 0;
}

Zeile 3810Zeile 4111
			$parents = explode(",", $forum['parentlist']);
foreach($parents as $parent)
{

			$parents = explode(",", $forum['parentlist']);
foreach($parents as $parent)
{

				if(isset($password_forums[$parent]) && $mybb->cookies['forumpass'][$parent] != md5($mybb->user['uid'].$password_forums[$parent]))

				if(isset($password_forums[$parent]) && $mybb->cookies['forumpass'][$parent] !== md5($mybb->user['uid'].$password_forums[$parent]))

				{
$pwverified = 0;
}

				{
$pwverified = 0;
}

Zeile 3819Zeile 4120

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

			if($unviewableforums)
{
$unviewableforums .= ",";
}

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

			$unviewable[] = $forum['fid'];






		}
}

		}
}


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

	
$unviewableforums = implode(',', $unviewable);

return $unviewableforums;


}

/**

}

/**

Zeile 4552Zeile 4847
 *
* @param boolean True to return as "hidden" fields
* @param array Array of fields to ignore if first argument is true

 *
* @param boolean True to return as "hidden" fields
* @param array Array of fields to ignore if first argument is true

 
 * @param boolean True to skip all inputs and return only the file path part of the URL

 * @return string The current URL being accessed
*/

 * @return string The current URL being accessed
*/

function get_current_location($fields=false, $ignore=array())

function get_current_location($fields=false, $ignore=array(), $quick=false)

{
if(defined("MYBB_LOCATION"))
{
return MYBB_LOCATION;
}


{
if(defined("MYBB_LOCATION"))
{
return MYBB_LOCATION;
}


	if(!empty($_SERVER['PATH_INFO']))

	if(!empty($_SERVER['SCRIPT_NAME']))

	{

	{

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

		$location = htmlspecialchars_uni($_SERVER['SCRIPT_NAME']);

	}

	}

	elseif(!empty($_ENV['PATH_INFO']))
{













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

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

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

	elseif(!empty($_ENV['PHP_SELF']))


	
if($quick)

	{

	{

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

		return $location;





	}

if($fields == true)

	}

if($fields == true)

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

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

		}

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

 
		}

return $location;

		}

return $location;

Zeile 4751Zeile 5051
		}

return $themeselect;

		}

return $themeselect;

	}
else
{

	}
else
{

		return false;

		return false;

	}
}

	}
}


/**
* Custom function for htmlspecialchars which takes in to account unicode


/**
* Custom function for htmlspecialchars which takes in to account unicode

Zeile 4786Zeile 5086
	if($number == "-")
{
return $number;

	if($number == "-")
{
return $number;

	}

	}


if(is_int($number))
{


if(is_int($number))
{

Zeile 4799Zeile 5099
		if(isset($parts[1]))
{
$decimals = my_strlen($parts[1]);

		if(isset($parts[1]))
{
$decimals = my_strlen($parts[1]);

		}
else
{

		}
else
{

			$decimals = 0;
}


			$decimals = 0;
}


Zeile 4882Zeile 5182
}

/**

}

/**

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

 * DEPRECATED! Please use other alternatives.




 */
function my_wordwrap($message)
{

 */
function my_wordwrap($message)
{

	global $mybb;

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

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

$new_message = convert_through_utf8($new_message, false);

return $new_message;
}


 
	return $message;
}


	return $message;
}


Zeile 4962Zeile 5243
		31,
30,
31,

		31,
30,
31,

		31,
30,

		31,
30,

		31,
30,
31

		31,
30,
31

Zeile 5039Zeile 5320

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


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





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

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

Zeile 5083Zeile 5364
	$age = $year-$bday[2];

if(($month == $bday[1] && $day < $bday[0]) || $month < $bday[1])

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

if(($month == $bday[1] && $day < $bday[0]) || $month < $bday[1])

	{

	{

		--$age;
}
return $age;
}

		--$age;
}
return $age;
}





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

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

{
global $db;


{
global $db;


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

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

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

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





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

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

Zeile 5185Zeile 5466
	global $lang;

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

	global $lang;

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





	if(strtolower($lang->settings['charset']) == "utf-8")

	if(strtolower($lang->settings['charset']) == "utf-8")

	{

	{

		// Get rid of any excess RTL and LTR override for they are the workings of the devil
$string = str_replace(dec_to_utf8(8238), "", $string);
$string = str_replace(dec_to_utf8(8237), "", $string);

		// Get rid of any excess RTL and LTR override for they are the workings of the devil
$string = str_replace(dec_to_utf8(8238), "", $string);
$string = str_replace(dec_to_utf8(8237), "", $string);





		// Remove dodgy whitespaces
$string = str_replace(chr(0xCA), "", $string);

		// Remove dodgy whitespaces
$string = str_replace(chr(0xCA), "", $string);

	}

	}

	$string = trim($string);

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

	$string = trim($string);

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

	}

	}

	else
{
$string_length = strlen($string);

	else
{
$string_length = strlen($string);

Zeile 5435Zeile 5716
 * @param string The target frame
* @param string Any onclick javascript.
* @return string The complete profile link.

 * @param string The target frame
* @param string Any onclick javascript.
* @return string The complete profile link.

 */

 */

function build_profile_link($username="", $uid=0, $target="", $onclick="")
{
global $mybb, $lang;

function build_profile_link($username="", $uid=0, $target="", $onclick="")
{
global $mybb, $lang;

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

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

	}

	}

	elseif($uid == 0)
{
// Return the guest's nickname if user is a guest but has a nickname
return $username;

	elseif($uid == 0)
{
// Return the guest's nickname if user is a guest but has a nickname
return $username;

	}

	}

	else
{
// Build the profile link for the registered user

	else
{
// Build the profile link for the registered user

Zeile 5477Zeile 5758
function get_forum_link($fid, $page=0)
{
if($page > 0)

function get_forum_link($fid, $page=0)
{
if($page > 0)

	{

	{

		$link = str_replace("{fid}", $fid, FORUM_URL_PAGED);
$link = str_replace("{page}", $page, $link);

		$link = str_replace("{fid}", $fid, FORUM_URL_PAGED);
$link = str_replace("{page}", $page, $link);

		return htmlspecialchars_uni($link);
}

		return htmlspecialchars_uni($link);
}

	else
{
$link = str_replace("{fid}", $fid, FORUM_URL);

	else
{
$link = str_replace("{fid}", $fid, FORUM_URL);

Zeile 5491Zeile 5772

/**
* Build the thread link.


/**
* Build the thread link.

 *

 *

 * @param int The thread id of the thread.
* @param int (Optional) The page number of the thread.
* @param string (Optional) The action we're performing (ex, lastpost, newpost, etc)

 * @param int The thread id of the thread.
* @param int (Optional) The page number of the thread.
* @param string (Optional) The action we're performing (ex, lastpost, newpost, etc)

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

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

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

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

		{
$link = THREAD_URL_PAGED;
}

		{
$link = THREAD_URL_PAGED;
}

Zeile 5519Zeile 5800
		if($action)
{
$link = THREAD_URL_ACTION;

		if($action)
{
$link = THREAD_URL_ACTION;

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

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

		}
else
{

		}
else
{

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

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

		return htmlspecialchars_uni($link);
}
}

/**

		return htmlspecialchars_uni($link);
}
}

/**

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

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

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

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

	return htmlspecialchars_uni($link);
}

	return htmlspecialchars_uni($link);
}


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


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

Zeile 5592Zeile 5873
	}
/* Not implemented
else if($year > 0)

	}
/* Not implemented
else if($year > 0)

	{

	{

	}*/
else
{

	}*/
else
{

Zeile 5636Zeile 5917
	if(!empty($mybb->user) && $uid == $mybb->user['uid'])
{
return $mybb->user;

	if(!empty($mybb->user) && $uid == $mybb->user['uid'])
{
return $mybb->user;

	}

	}

	elseif(isset($user_cache[$uid]))
{
return $user_cache[$uid];

	elseif(isset($user_cache[$uid]))
{
return $user_cache[$uid];

Zeile 5666Zeile 5947
	if(!isset($options['username_method']))
{
$options['username_method'] = 0;

	if(!isset($options['username_method']))
{
$options['username_method'] = 0;

 
	}

switch($db->type)
{
case 'mysql':
case 'mysqli':
$field = 'username';
$efield = 'email';
break;
default:
$field = 'LOWER(username)';
$efield = 'LOWER(email)';
break;

	}

switch($options['username_method'])
{
case 1:

	}

switch($options['username_method'])
{
case 1:

			$sqlwhere = 'LOWER(email)=\''.$username.'\'';

			$sqlwhere = "{$efield}='{$username}'";

			break;
case 2:

			break;
case 2:

			$sqlwhere = 'LOWER(username)=\''.$username.'\' OR LOWER(email)=\''.$username.'\'';

			$sqlwhere = "{$field}='{$username}' OR {$efield}='{$username}'";

			break;
default:

			break;
default:

			$sqlwhere = 'LOWER(username)=\''.$username.'\'';

			$sqlwhere = "{$field}='{$username}'";

			break;
}


			break;
}


Zeile 5817Zeile 6111
 */
function get_inactive_forums()
{

 */
function get_inactive_forums()
{

	global $forum_cache, $cache, $inactiveforums;

	global $forum_cache, $cache;


if(!$forum_cache)


if(!$forum_cache)

	{

	{

		cache_forums();
}

		cache_forums();
}





	$inactive = array();

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

	$inactive = array();

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

	{

	{

		if($forum['active'] == 0)
{
$inactive[] = $fid;

		if($forum['active'] == 0)
{
$inactive[] = $fid;

Zeile 5837Zeile 6131
				{
$inactive[] = $fid1;
}

				{
$inactive[] = $fid1;
}

			}
}

			}
}

	}

	}

 
	

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

return $inactiveforums;

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

return $inactiveforums;

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

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

	}

	}

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

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





	// Use cookie if possible, otherwise use session
// Find better solution to prevent clearing cookies
$loginattempts = 0;

	// Use cookie if possible, otherwise use session
// Find better solution to prevent clearing cookies
$loginattempts = 0;

Zeile 5869Zeile 6164
	if(!empty($mybb->cookies['loginattempts']))
{
$loginattempts = $mybb->cookies['loginattempts'];

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

	}

	}


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


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

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

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

		}

		}


$secondsleft = $mybb->settings['failedlogintime'] * 60 + $failedtime - $now;
$hoursleft = floor($secondsleft / 3600);


$secondsleft = $mybb->settings['failedlogintime'] * 60 + $failedtime - $now;
$hoursleft = floor($secondsleft / 3600);

Zeile 5901Zeile 6196
		if(empty($failedlogin))
{
my_setcookie('failedlogin', $now);

		if(empty($failedlogin))
{
my_setcookie('failedlogin', $now);

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

return false;
}


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

return false;
}


		// Work out if the user has waited long enough before letting them login again
if($mybb->cookies['failedlogin'] < ($now - $mybb->settings['failedlogintime'] * 60))
{

		// Work out if the user has waited long enough before letting them login again
if($mybb->cookies['failedlogin'] < ($now - $mybb->settings['failedlogintime'] * 60))
{

Zeile 5937Zeile 6232

// User can attempt another login
return $loginattempts;


// User can attempt another login
return $loginattempts;

}

/**

}

/**

 * Validates the format of an email address.
*
* @param string The string to check.

 * Validates the format of an email address.
*
* @param string The string to check.

Zeile 5970Zeile 6265
	if($uid)
{
$uid_string = " AND uid != '".(int)$uid."'";

	if($uid)
{
$uid_string = " AND uid != '".(int)$uid."'";

	}

	}

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

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





	if($db->fetch_field($query, "emails") > 0)
{
return true;

	if($db->fetch_field($query, "emails") > 0)
{
return true;

Zeile 5980Zeile 6275

return false;
}


return false;
}





/**
* Rebuilds settings.php
*

/**
* Rebuilds settings.php
*

Zeile 5990Zeile 6285
	global $db, $mybb;

if(!file_exists(MYBB_ROOT."inc/settings.php"))

	global $db, $mybb;

if(!file_exists(MYBB_ROOT."inc/settings.php"))

	{

	{

		$mode = "x";

		$mode = "x";

	}

	}

	else
{
$mode = "w";

	else
{
$mode = "w";

Zeile 6001Zeile 6296
	$options = array(
"order_by" => "title",
"order_dir" => "ASC"

	$options = array(
"order_by" => "title",
"order_dir" => "ASC"

	);

	);

	$query = $db->simple_select("settings", "value, name", "", $options);

	$query = $db->simple_select("settings", "value, name", "", $options);





	$settings = null;
while($setting = $db->fetch_array($query))
{
$mybb->settings[$setting['name']] = $setting['value'];
$setting['value'] = addcslashes($setting['value'], '\\"$');
$settings .= "\$settings['{$setting['name']}'] = \"{$setting['value']}\";\n";

	$settings = null;
while($setting = $db->fetch_array($query))
{
$mybb->settings[$setting['name']] = $setting['value'];
$setting['value'] = addcslashes($setting['value'], '\\"$');
$settings .= "\$settings['{$setting['name']}'] = \"{$setting['value']}\";\n";

	}


	}


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

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

Zeile 6031Zeile 6326
	global $mybb;

if($mybb->settings['minsearchword'] < 1)

	global $mybb;

if($mybb->settings['minsearchword'] < 1)

	{

	{

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


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


Zeile 6071Zeile 6366
					if(!is_array($split_words))
{
continue;

					if(!is_array($split_words))
{
continue;

					}

					}

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

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

Zeile 6100Zeile 6395
				}
$words[] = trim($word);
}

				}
$words[] = trim($word);
}

		}
}


		}
}


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

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

Zeile 6133Zeile 6428

return $highlight_cache;
}


return $highlight_cache;
}





/**
* Converts a decimal reference of a character to its UTF-8 equivalent
* (Code by Anne van Kesteren, http://annevankesteren.nl/2005/05/character-references)

/**
* Converts a decimal reference of a character to its UTF-8 equivalent
* (Code by Anne van Kesteren, http://annevankesteren.nl/2005/05/character-references)

Zeile 6153Zeile 6448
		$dest .= chr($src);
}
elseif($src <= 0x07ff)

		$dest .= chr($src);
}
elseif($src <= 0x07ff)

	{

	{

		$dest .= chr(0xc0 | ($src >> 6));

		$dest .= chr(0xc0 | ($src >> 6));

		$dest .= chr(0x80 | ($src & 0x003f));
}

		$dest .= chr(0x80 | ($src & 0x003f));
}

	elseif($src <= 0xffff)
{
$dest .= chr(0xe0 | ($src >> 12));

	elseif($src <= 0xffff)
{
$dest .= chr(0xe0 | ($src >> 12));

Zeile 6164Zeile 6459
		$dest .= chr(0x80 | ($src & 0x003f));
}
elseif($src <= 0x10ffff)

		$dest .= chr(0x80 | ($src & 0x003f));
}
elseif($src <= 0x10ffff)

	{

	{

		$dest .= chr(0xf0 | ($src >> 18));
$dest .= chr(0x80 | (($src >> 12) & 0x3f));
$dest .= chr(0x80 | (($src >> 6) & 0x3f));

		$dest .= chr(0xf0 | ($src >> 18));
$dest .= chr(0x80 | (($src >> 12) & 0x3f));
$dest .= chr(0x80 | (($src >> 6) & 0x3f));

Zeile 6174Zeile 6469
	{
// Out of range
return false;

	{
// Out of range
return false;

	}


	}


	return $dest;
}


	return $dest;
}


Zeile 6183Zeile 6478
 * Checks if a username has been disallowed for registration/use.
*
* @param string The username

 * Checks if a username has been disallowed for registration/use.
*
* @param string The username

 * @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 boolean True if the 'last used' dateline should be updated if a match is found.
* @return boolean True if banned, false if not banned

 */
function is_banned_username($username, $update_lastuse=false)
{

 */
function is_banned_username($username, $update_lastuse=false)
{

Zeile 6234Zeile 6529
		{
// Make regular expression * match
$banned_email['filter'] = str_replace('\*', '(.*)', preg_quote($banned_email['filter'], '#'));

		{
// 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(preg_match("#{$banned_email['filter']}#i", $email))
{
// Updating last use

Zeile 6281Zeile 6576
		$ip_range = fetch_ip_range($banned_ip['filter']);
if(is_array($ip_range))
{

		$ip_range = fetch_ip_range($banned_ip['filter']);
if(is_array($ip_range))
{

			if(strcmp($ip_range[0], $ip_address) >= 0 && strcmp($ip_range[1], $ip_address) <= 0)

			if(strcmp($ip_range[0], $ip_address) <= 0 && strcmp($ip_range[1], $ip_address) >= 0)

			{
$banned = true;
}

			{
$banned = true;
}

Zeile 6396Zeile 6691

eval("\$select = \"".$templates->get("usercp_options_timezone")."\";");
return $select;


eval("\$select = \"".$templates->get("usercp_options_timezone")."\";");
return $select;

}

/**
* Fetch the contents of a remote fle.

}

/**
* Fetch the contents of a remote file.

 *
* @param string The URL of the remote file
* @param array The array of post data

 *
* @param string The URL of the remote file
* @param array The array of post data

Zeile 6424Zeile 6719
		curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

		curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

 
		curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);

		if(!empty($post_body))

		if(!empty($post_body))

		{

		{

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

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

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

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

		{

		{

			$url['path'] = "/";

			$url['path'] = "/";

		}

		}

		if($url['query'])

		if($url['query'])

		{

		{

			$url['path'] .= "?{$url['query']}";
}

			$url['path'] .= "?{$url['query']}";
}

		$fp = @fsockopen($url['host'], $url['port'], $error_no, $error, 10);














$scheme = '';

if($url['scheme'] == 'https')
{
$scheme = 'ssl://';
if($url['port'] == 80)
{
$url['port'] = 443;
}
}

$fp = @fsockopen($scheme.$url['host'], $url['port'], $error_no, $error, 10);

		@stream_set_timeout($fp, 10);
if(!$fp)
{

		@stream_set_timeout($fp, 10);
if(!$fp)
{

Zeile 6538Zeile 6846
 * Originates from frostschutz's PluginLibrary
* github.com/frostschutz
*

 * Originates from frostschutz's PluginLibrary
* github.com/frostschutz
*

 * @param mixed A selection of groups to check

 * @param mixed A selection of groups to check or -1 for any group

 * @param mixed User to check selection against

 * @param mixed User to check selection against

 * @return mixed Array of groups this user belongs to

 * @return array Array of groups specified in the first param to which the user belongs

 */
function is_member($groups, $user = false)
{
global $mybb;

 */
function is_member($groups, $user = false)
{
global $mybb;

 
	
if(empty($groups))
{
return array();
}


if($user == false)


if($user == false)

	{

	{

		$user = $mybb->user;

		$user = $mybb->user;

	}

	}

	else if(!is_array($user))
{
// Assume it's a UID

	else if(!is_array($user))
{
// Assume it's a UID

Zeile 6561Zeile 6874

if(!is_array($groups))
{


if(!is_array($groups))
{

		if(is_string($groups))

		if((int)$groups == -1)

		{

		{

			$groups = explode(',', $groups);

			return $memberships;

		}
else
{

		}
else
{

			$groups = (array)$groups;








			if(is_string($groups))
{
$groups = explode(',', $groups);
}
else
{
$groups = (array)$groups;
}

		}
}


		}
}


Zeile 7006Zeile 7326
		else
{
// IPv4

		else
{
// IPv4

 
			$ip_bits = count(explode('.', $ipaddress));
if($ip_bits < 4)
{
// Support for 127.0.*
$replacement = str_repeat('.*', 4-$ip_bits);
$ipaddress = substr_replace($ipaddress, $replacement, strrpos($ipaddress, '*')+1, 0);
}

			$upper = str_replace('*', '255', $ipaddress);
$lower = str_replace('*', '0', $ipaddress);

			$upper = str_replace('*', '255', $ipaddress);
$lower = str_replace('*', '0', $ipaddress);

		}

		}

		$upper = my_inet_pton($upper);
$lower = my_inet_pton($lower);
if($upper === false || $lower === false)

		$upper = my_inet_pton($upper);
$lower = my_inet_pton($lower);
if($upper === false || $lower === false)

Zeile 7016Zeile 7343
			return false;
}
return array($lower, $upper);

			return false;
}
return array($lower, $upper);

	}

	}

	// CIDR notation
elseif(strpos($ipaddress, '/') !== false)
{

	// CIDR notation
elseif(strpos($ipaddress, '/') !== false)
{

Zeile 7028Zeile 7355
		{
// Invalid input
return false;

		{
// Invalid input
return false;

		}

		}

		else
{
$ip_address = my_inet_pton($ip_address);

		else
{
$ip_address = my_inet_pton($ip_address);

Zeile 7102Zeile 7429
function get_execution_time()
{
static $time_start;

function get_execution_time()
{
static $time_start;


$time = microtime(true);




$time = microtime(true);



	// Just starting timer, init and return
if(!$time_start)
{

	// Just starting timer, init and return
if(!$time_start)
{

Zeile 7363Zeile 7690
}

/**

}

/**

 * 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 7373Zeile 7700
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 7428Zeile 7745
		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}

	);


	);


	// 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 7462Zeile 7779
	$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 7643Zeile 7960
				}
}
else

				}
}
else

			{

			{

				$string .= $input[$i];
}
}

				$string .= $input[$i];
}
}

Zeile 7652Zeile 7969
	if($return)
{
if($allow_mb4)

	if($return)
{
if($allow_mb4)

		{

		{

			return $input;

			return $input;

		}
else
{

		}
else
{

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

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

Zeile 7691Zeile 8008
	}

if(!is_array($pm))

	}

if(!is_array($pm))

	{
return false;
}

	{
return false;
}


if(isset($pm['language']))
{


if(isset($pm['language']))
{

Zeile 7704Zeile 8021
			$lang->load($pm['language_file']);

$revert = true;

			$lang->load($pm['language_file']);

$revert = true;

		}


		}


		foreach(array('subject', 'message') as $key)
{
$lang_string = $pm[$key];

		foreach(array('subject', 'message') as $key)
{
$lang_string = $pm[$key];

Zeile 7730Zeile 8047
			$lang->set_language($mybb->user['language']);
$lang->load($pm['language_file']);
}

			$lang->set_language($mybb->user['language']);
$lang->load($pm['language_file']);
}

	}

	}


if(!$pm['subject'] ||!$pm['message'] || !$pm['touid'] || (!$pm['receivepms'] && !$admin_override))
{
return false;
}



if(!$pm['subject'] ||!$pm['message'] || !$pm['touid'] || (!$pm['receivepms'] && !$admin_override))
{
return false;
}


	$lang->load('messages');


	$lang->load('messages');


	require_once MYBB_ROOT."inc/datahandlers/pm.php";

$pmhandler = new PMDataHandler();

	require_once MYBB_ROOT."inc/datahandlers/pm.php";

$pmhandler = new PMDataHandler();





	$subject = $pm['subject'];
$message = $pm['message'];
$toid = $pm['touid'];

// Our recipients
if(is_array($toid))

	$subject = $pm['subject'];
$message = $pm['message'];
$toid = $pm['touid'];

// Our recipients
if(is_array($toid))

	{

	{

		$recipients_to = $toid;
}
else
{
$recipients_to = array($toid);

		$recipients_to = $toid;
}
else
{
$recipients_to = array($toid);

	}

	}


$recipients_bcc = array();

// Determine user ID
if((int)$fromid == 0)


$recipients_bcc = array();

// Determine user ID
if((int)$fromid == 0)

	{

	{

		$fromid = (int)$mybb->user['uid'];
}
elseif((int)$fromid < 0)
{
$fromid = 0;

		$fromid = (int)$mybb->user['uid'];
}
elseif((int)$fromid < 0)
{
$fromid = 0;

	}


	}


	// Build our final PM array
$pm = array(
"subject" => $subject,

	// Build our final PM array
$pm = array(
"subject" => $subject,

Zeile 7779Zeile 8096
		"bccid" => $recipients_bcc,
"do" => '',
"pmid" => ''

		"bccid" => $recipients_bcc,
"do" => '',
"pmid" => ''

	);


	);


	if(isset($session))
{
$pm['ipaddress'] = $session->packedip;

	if(isset($session))
{
$pm['ipaddress'] = $session->packedip;

Zeile 7791Zeile 8108
		"disablesmilies" => 0,
"savecopy" => 0,
"readreceipt" => 0

		"disablesmilies" => 0,
"savecopy" => 0,
"readreceipt" => 0

	);

$pm['saveasdraft'] = 0;

	);

$pm['saveasdraft'] = 0;


// Admin override
$pmhandler->admin_override = (int)$admin_override;


// Admin override
$pmhandler->admin_override = (int)$admin_override;





	$pmhandler->set_data($pm);

if($pmhandler->validate_pm())
{
$pmhandler->insert_pm();
return true;

	$pmhandler->set_data($pm);

if($pmhandler->validate_pm())
{
$pmhandler->insert_pm();
return true;

	}

	}


return false;
}


return false;
}

Zeile 7817Zeile 8134
 * @param string $ip_address The IP addres of the user.
* @param array $data An array of extra data to go with the block (eg: confidence rating).
* @return bool Whether the action was logged successfully.

 * @param string $ip_address The IP addres of the user.
* @param array $data An array of extra data to go with the block (eg: confidence rating).
* @return bool Whether the action was logged successfully.

 */

 */

function log_spam_block($username = '', $email = '', $ip_address = '', $data = array())
{
global $db, $session;

function log_spam_block($username = '', $email = '', $ip_address = '', $data = array())
{
global $db, $session;

Zeile 7839Zeile 8156
		'email'     => $db->escape_string($email),
'ipaddress' => $db->escape_binary($ip_address),
'dateline' => (int)TIME_NOW,

		'email'     => $db->escape_string($email),
'ipaddress' => $db->escape_binary($ip_address),
'dateline' => (int)TIME_NOW,

		'data'      => $db->escape_string(@serialize($data)),

		'data'      => $db->escape_string(@my_serialize($data)),

	);

return (bool)$db->insert_query('spamlog', $insert_array);

	);

return (bool)$db->insert_query('spamlog', $insert_array);

 
}

/**
* Copy a file to the CDN.
*
* @param string $file_path The path to the file to upload to the CDN.
*
* @param string $uploaded_path The path the file was uploaded to, reference parameter for when this may be needed.
*
* @return bool Whether the file was copied successfully.
*/
function copy_file_to_cdn($file_path = '', &$uploaded_path = null)
{
global $mybb, $plugins;

$success = false;

$file_path = (string)$file_path;

$real_file_path = realpath($file_path);

$file_dir_path = dirname($real_file_path);
$file_dir_path = str_replace(MYBB_ROOT, '', $file_dir_path);
$file_dir_path = ltrim($file_dir_path, './\\');

$file_name = basename($real_file_path);

if(file_exists($file_path))
{
if($mybb->settings['usecdn'] && !empty($mybb->settings['cdnpath']))
{
$cdn_path = rtrim($mybb->settings['cdnpath'], '/\\');

if(substr($file_dir_path, 0, my_strlen(MYBB_ROOT)) == MYBB_ROOT)
{
$file_dir_path = str_replace(MYBB_ROOT, '', $file_dir_path);
}

$cdn_upload_path = $cdn_path . DIRECTORY_SEPARATOR . $file_dir_path;

if(!($dir_exists = is_dir($cdn_upload_path)))
{
$dir_exists = @mkdir($cdn_upload_path, 0777, true);
}

if($dir_exists)
{
if(($cdn_upload_path = realpath($cdn_upload_path)) !== false)
{
$success = @copy($file_path, $cdn_upload_path.DIRECTORY_SEPARATOR.$file_name);

if($success)
{
$uploaded_path = $cdn_upload_path;
}
}
}
}

if(is_object($plugins))
{
$hook_args = array(
'file_path' => &$file_path,
'real_file_path' => &$real_file_path,
'file_name' => &$file_name,
'uploaded_path' => &$uploaded_path,
'success' => &$success,
);

$plugins->run_hooks('copy_file_to_cdn_end', $hook_args);
}
}

return $success;

}

}