Vergleich inc/functions.php - 1.8.6 - 1.8.10

  Keine Änderungen   Hinzugefügt   Modifiziert   Entfernt
Zeile 343Zeile 343
	{
if(isset($mybb->user['uid']) && $mybb->user['uid'] != 0 && array_key_exists("timezone", $mybb->user))
{

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

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

			$offset = (float)$mybb->user['timezone'];

			$dstcorrection = $mybb->user['dst'];
}
elseif(defined("IN_ADMINCP"))
{

			$dstcorrection = $mybb->user['dst'];
}
elseif(defined("IN_ADMINCP"))
{

			$offset =  $mybbadmin['timezone'];

			$offset = (float)$mybbadmin['timezone'];

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

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

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

			$offset = (float)$mybb->settings['timezoneoffset'];

			$dstcorrection = $mybb->settings['dstcorrection'];
}


			$dstcorrection = $mybb->settings['dstcorrection'];
}


Zeile 598Zeile 598
function verify_post_check($code, $silent=false)
{
global $lang;

function verify_post_check($code, $silent=false)
{
global $lang;

	if(generate_post_check() != $code)

	if(generate_post_check() !== $code)

	{
if($silent == true)
{

	{
if($silent == true)
{

Zeile 865Zeile 865

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


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

		$lang->error_nopermission_user_username = $lang->sprintf($lang->error_nopermission_user_username, $mybb->user['username']);

		$lang->error_nopermission_user_username = $lang->sprintf($lang->error_nopermission_user_username, htmlspecialchars_uni($mybb->user['username']));

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

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

Zeile 966Zeile 966

run_shutdown();



run_shutdown();


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

		if(!my_validate_url($url, true))

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

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

Zeile 1209Zeile 1209
 * Fetch the usergroup permissions for a specific group or series of groups combined
*
* @param int|string $gid A list of groups (Can be a single integer, or a list of groups separated by a comma)

 * Fetch the usergroup permissions for a specific group or series of groups combined
*
* @param int|string $gid 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

 * @return array Array of permissions generated for the groups, containing also a list of comma-separated checked groups under 'all_usergroups' index

 */
function usergroup_permissions($gid=0)
{

 */
function usergroup_permissions($gid=0)
{

Zeile 1224Zeile 1224

if(count($groups) == 1)
{


if(count($groups) == 1)
{

 
		$groupscache[$gid]['all_usergroups'] = $gid;

		return $groupscache[$gid];
}

		return $groupscache[$gid];
}

	
$usergroup = array();



$usergroup = array();
$usergroup['all_usergroups'] = $gid;


foreach($groups as $gid)
{


foreach($groups as $gid)
{

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

		if(trim($gid) == "" || empty($groupscache[$gid]))
{

			continue;
}

foreach($groupscache[$gid] as $perm => $access)
{
if(!in_array($perm, $grouppermignore))

			continue;
}

foreach($groupscache[$gid] as $perm => $access)
{
if(!in_array($perm, $grouppermignore))

			{

			{

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

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

Zeile 1265Zeile 1267
	}

return $usergroup;

	}

return $usergroup;

}

}


/**
* Fetch the display group properties for a specific display group


/**
* Fetch the display group properties for a specific display group

Zeile 1329Zeile 1331
			}

$groupperms = $mybb->usergroup;

			}

$groupperms = $mybb->usergroup;

		}
}

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

if(!$forum_cache)

		}
}

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

if(!$forum_cache)

		{
return false;
}

		{
return false;
}

Zeile 1660Zeile 1662
				}

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

				}

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

			}
}
}

			}
}
}


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



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


Zeile 1676Zeile 1678
 * @param string $action The action tyring to be performed. (blank assumes any action at all)
* @param int $uid The user ID (0 assumes current user)
* @return bool Returns true if the user has permission, false if they do not

 * @param string $action The action tyring to be performed. (blank assumes any action at all)
* @param int $uid The user ID (0 assumes current user)
* @return bool Returns true if the user has permission, false if they do not

 */

 */

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)
{
return false;

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

	}


	}


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

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

Zeile 1714Zeile 1716
			{
foreach($modcache as $modusers)
{

			{
foreach($modcache as $modusers)
{

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

					if(isset($modusers['users'][$uid]) && $modusers['users'][$uid]['mid'] && (!$action || !empty($modusers['users'][$uid][$action])))

					{
return true;
}

					{
return true;
}

					elseif(isset($user_perms['gid']) && isset($modusers['usergroups'][$user_perms['gid']]))





$groups = explode(',', $user_perms['all_usergroups']);

foreach($groups as $group)

					{

					{

						// Moderating usergroup
return true;



						if(trim($group) != '' && isset($modusers['usergroups'][$group]) && (!$action || !empty($modusers['usergroups'][$group][$action])))
{
return true;
}

					}
}
}

					}
}
}

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

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

			}

			}

			else
{
if(isset($modperms[$action]) && $modperms[$action] == 1)

			else
{
if(isset($modperms[$action]) && $modperms[$action] == 1)

				{

				{

					return true;
}
else

					return true;
}
else

Zeile 1747Zeile 1754
				}
}
}

				}
}
}

	}

	}

}

/**

}

/**

Zeile 1774Zeile 1781
		$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']);

Zeile 1794Zeile 1801
		eval("\$iconlist .= \"".$templates->get("posticons_icon")."\";");
}


		eval("\$iconlist .= \"".$templates->get("posticons_icon")."\";");
}


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








	if(!empty($iconlist))
{
eval("\$posticons = \"".$templates->get("posticons")."\";");
}
else
{
$posticons = '';
}


return $posticons;
}


return $posticons;
}

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

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

	}

	}


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


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

	}

	}


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


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

 
	}

if($mybb->settings['cookiesecureflag'])
{
$cookie .= "; Secure";

	}

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

	}

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





	header($cookie, false);
}


	header($cookie, false);
}


Zeile 1884Zeile 1903
 * @return array|boolean The cookie id's content array or false when non-existent.
*/
function my_get_array_cookie($name, $id)

 * @return array|boolean The cookie id's content array or false when non-existent.
*/
function my_get_array_cookie($name, $id)

{

{

	global $mybb;

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

	global $mybb;

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

Zeile 2101Zeile 2120
					$list = &$data;
$expected[] = $expectedLength;
$state = 2;

					$list = &$data;
$expected[] = $expectedLength;
$state = 2;

					break;

					break;

				}
if($type != '}')
{

				}
if($type != '}')
{

Zeile 2133Zeile 2152
function my_unserialize($str)
{
// Ensure we use the byte count for strings even when strlen() is overloaded by mb_strlen()

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

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

		mb_internal_encoding($mbIntEnc);
}

	



	return $out;
}


	return $out;
}


Zeile 2154Zeile 2173
 * Safe serialize() replacement
* - output a strict subset of PHP's native serialized representation
* - does not my_serialize objects

 * Safe serialize() replacement
* - output a strict subset of PHP's native serialized representation
* - does not my_serialize objects

 *
* @param mixed $value
* @return string

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

 * @throw Exception if $value is malformed or contains unsupported types (e.g., resources, objects)
*/
function _safe_serialize( $value )
{
if(is_null($value))

	{

	{

		return 'N;';

		return 'N;';

	}


	}


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

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

	



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

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

	



	if(is_float($value))

	if(is_float($value))

	{

	{

		return 'd:'.str_replace(',', '.', $value).';';

		return 'd:'.str_replace(',', '.', $value).';';

	}


	}


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

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

	



	if(is_array($value))
{
$out = '';

	if(is_array($value))
{
$out = '';

Zeile 2193Zeile 2212
		{
$out .= _safe_serialize($k) . _safe_serialize($v);
}

		{
$out .= _safe_serialize($k) . _safe_serialize($v);
}

		



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


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


Zeile 2216Zeile 2235
		$mbIntEnc = mb_internal_encoding();
mb_internal_encoding('ASCII');
}

		$mbIntEnc = mb_internal_encoding();
mb_internal_encoding('ASCII');
}

	



	$out = _safe_serialize($value);
if(isset($mbIntEnc))
{
mb_internal_encoding($mbIntEnc);
}

	$out = _safe_serialize($value);
if(isset($mbIntEnc))
{
mb_internal_encoding($mbIntEnc);
}

	



	return $out;
}

	return $out;
}





/**
* Returns the serverload of the system.
*

/**
* Returns the serverload of the system.
*

Zeile 2234Zeile 2253
function get_server_load()
{
global $mybb, $lang;

function get_server_load()
{
global $mybb, $lang;


$serverload = array();


$serverload = array();


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


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

Zeile 2260Zeile 2279

// 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)
{
return $lang->unknown;
}

			{
if(strpos(",".$func_blacklist.",", 'exec') !== false)
{
return $lang->unknown;
}

			}
// PHP disabled functions?
if($func_blacklist = @ini_get('disable_functions'))

			}
// PHP disabled functions?
if($func_blacklist = @ini_get('disable_functions'))

Zeile 2273Zeile 2292
				{
return $lang->unknown;
}

				{
return $lang->unknown;
}

			}


			}


			$load = @exec("uptime");
$load = explode("load average: ", $load);
$serverload = explode(",", $load[1]);

			$load = @exec("uptime");
$load = explode("load average: ", $load);
$serverload = explode(",", $load[1]);

Zeile 2287Zeile 2306
	else
{
return $lang->unknown;

	else
{
return $lang->unknown;

	}

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

	}

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


return $returnload;
}


return $returnload;
}

Zeile 2300Zeile 2319
 * @return int The amount of memory allocated to the script.
*/
function get_memory_usage()

 * @return int The amount of memory allocated to the script.
*/
function get_memory_usage()

{

{

	if(function_exists('memory_get_peak_usage'))
{
return memory_get_peak_usage(true);

	if(function_exists('memory_get_peak_usage'))
{
return memory_get_peak_usage(true);

Zeile 2327Zeile 2346
	{
// Update stats after all changes are done
add_shutdown('update_stats', array(array(), true));

	{
// Update stats after all changes are done
add_shutdown('update_stats', array(array(), true));

	}


	}


	if(empty($stats_changes) || $stats_changes['inserted'])
{
$stats_changes = array(

	if(empty($stats_changes) || $stats_changes['inserted'])
{
$stats_changes = array(

Zeile 2341Zeile 2360
			'numdeletedthreads' => '+0',
'inserted' => false // Reset after changes are inserted into cache
);

			'numdeletedthreads' => '+0',
'inserted' => false // Reset after changes are inserted into cache
);

		$stats = $stats_changes;
}

		$stats = $stats_changes;
}


if($force) // Force writing to cache?
{


if($force) // Force writing to cache?
{

Zeile 2355Zeile 2374
		$changes = $stats_changes;
}
else

		$changes = $stats_changes;
}
else

	{

	{

		$stats = $stats_changes;
}


		$stats = $stats_changes;
}


Zeile 2382Zeile 2401
						{
$new_stats[$counter] = "+{$new_stats[$counter]}";
}

						{
$new_stats[$counter] = "+{$new_stats[$counter]}";
}

					}

					}

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

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

Zeile 2414Zeile 2433
		$query = $db->simple_select("users", "uid, username", "", array('order_by' => 'regdate', 'order_dir' => 'DESC', 'limit' => 1));
$lastmember = $db->fetch_array($query);
$new_stats['lastuid'] = $lastmember['uid'];

		$query = $db->simple_select("users", "uid, username", "", array('order_by' => 'regdate', 'order_dir' => 'DESC', 'limit' => 1));
$lastmember = $db->fetch_array($query);
$new_stats['lastuid'] = $lastmember['uid'];

		$new_stats['lastusername'] = $lastmember['username'];

		$new_stats['lastusername'] = $lastmember['username'] = htmlspecialchars_uni($lastmember['username']);

	}

if(!empty($new_stats))

	}

if(!empty($new_stats))

Zeile 2432Zeile 2451
	// Update stats row for today in the database
$todays_stats = array(
"dateline" => mktime(0, 0, 0, date("m"), date("j"), date("Y")),

	// Update stats row for today in the database
$todays_stats = array(
"dateline" => mktime(0, 0, 0, date("m"), date("j"), date("Y")),

		"numusers" => $stats['numusers'],
"numthreads" => $stats['numthreads'],
"numposts" => $stats['numposts']

		"numusers" => (int)$stats['numusers'],
"numthreads" => (int)$stats['numthreads'],
"numposts" => (int)$stats['numposts']

	);
$db->replace_query("stats", $todays_stats, "dateline");

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

	);
$db->replace_query("stats", $todays_stats, "dateline");

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

}

}


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


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

Zeile 2644Zeile 2663
				if((int)$changes[$counter] != 0)
{
$update_query[$counter] = $thread[$counter] + $changes[$counter];

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

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

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


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

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


	$db->free_result($query);

// Only update if we're actually doing something

	$db->free_result($query);

// Only update if we're actually doing something

Zeile 2874Zeile 2893
	if(!is_array($permissioncache))
{
$permissioncache = forum_permissions();

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

	}


	}


	if(isset($jumpfcache[$pid]) && is_array($jumpfcache[$pid]))
{
foreach($jumpfcache[$pid] as $main)

	if(isset($jumpfcache[$pid]) && is_array($jumpfcache[$pid]))
{
foreach($jumpfcache[$pid] as $main)

Zeile 2889Zeile 2908
					$optionselected = "";

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

					$optionselected = "";

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

					{

					{

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


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


Zeile 2916Zeile 2935
		else
{
$template = "advanced";

		else
{
$template = "advanced";





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

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

			{

			{

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

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

			}

			}

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

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





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

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

	}


	}


	return $forumjump;
}


	return $forumjump;
}


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

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

}


}


/**
* Generates a random string.
*

/**
* Generates a random string.
*

Zeile 2969Zeile 2988
		$str[] = $set[my_rand(36, 61)];

$length -= 3;

		$str[] = $set[my_rand(36, 61)];

$length -= 3;

	}


	}


	for($i = 0; $i < $length; ++$i)
{
$str[] = $set[my_rand(0, 61)];
}

	for($i = 0; $i < $length; ++$i)
{
$str[] = $set[my_rand(0, 61)];
}

	



	// Make sure they're in random order and convert them to a string
shuffle($str);

	// Make sure they're in random order and convert them to a string
shuffle($str);





	return implode($str);
}

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

	return implode($str);
}

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

 *

 *

 * @param string $username The username
* @param int $usergroup The usergroup for the user
* @param int $displaygroup The display group for the user

 * @param string $username The username
* @param int $usergroup The usergroup for the user
* @param int $displaygroup The display group for the user

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

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

	}

	}


if($displaygroup != 0)
{
$usergroup = $displaygroup;
}


if($displaygroup != 0)
{
$usergroup = $displaygroup;
}





	$ugroup = $groupscache[$usergroup];
$format = $ugroup['namestyle'];
$userin = substr_count($format, "{username}");

if($userin == 0)

	$ugroup = $groupscache[$usergroup];
$format = $ugroup['namestyle'];
$userin = substr_count($format, "{username}");

if($userin == 0)

	{

	{

		$format = "{username}";
}


		$format = "{username}";
}


Zeile 3028Zeile 3047
 */
function format_avatar($avatar, $dimensions = '', $max_dimensions = '')
{

 */
function format_avatar($avatar, $dimensions = '', $max_dimensions = '')
{

	global $mybb;

	global $mybb, $theme;

	static $avatars;

if(!isset($avatars))

	static $avatars;

if(!isset($avatars))

Zeile 3036Zeile 3055
		$avatars = array();
}


		$avatars = array();
}


	if(!$avatar)







	if(my_strpos($avatar, '://') !== false && !$mybb->settings['allowremoteavatars'])
{
// Remote avatar, but remote avatars are disallowed.
$avatar = null;
}

if(!$avatar)

	{
// Default avatar

	{
// Default avatar

		$avatar = $mybb->settings['useravatar'];






		if(defined('IN_ADMINCP'))
{
$theme['imgdir'] = '../images';
}

$avatar = str_replace('{theme}', $theme['imgdir'], $mybb->settings['useravatar']);

		$dimensions = $mybb->settings['useravatardims'];
}

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

		$dimensions = $mybb->settings['useravatardims'];
}

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

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

Zeile 3058Zeile 3088
	if(empty($key2))
{
$key2 = 'default';

	if(empty($key2))
{
$key2 = 'default';

	}


	}


	if(isset($avatars[$avatar][$key][$key2]))
{
return $avatars[$avatar][$key][$key2];

	if(isset($avatars[$avatar][$key][$key2]))
{
return $avatars[$avatar][$key][$key2];

Zeile 3084Zeile 3114
			else
{
$avatar_width_height = "width=\"{$dimensions[0]}\" height=\"{$dimensions[1]}\"";

			else
{
$avatar_width_height = "width=\"{$dimensions[0]}\" height=\"{$dimensions[1]}\"";

			}
}
}


			}
}
}


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

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

Zeile 3182Zeile 3212
		$editor_language = "(function ($) {\n$.sceditor.locale[\"mybblang\"] = {\n";

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

		$editor_language = "(function ($) {\n$.sceditor.locale[\"mybblang\"] = {\n";

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





		$editor_languages_count = count($editor_lang_strings);
$i = 0;
foreach($editor_lang_strings as $lang_string => $key)

		$editor_languages_count = count($editor_lang_strings);
$i = 0;
foreach($editor_lang_strings as $lang_string => $key)

Zeile 3195Zeile 3225
			if($i < $editor_languages_count)
{
$editor_language .= ",";

			if($i < $editor_languages_count)
{
$editor_language .= ",";

			}

			}


$editor_language .= "\n";
}


$editor_language .= "\n";
}

Zeile 3214Zeile 3244
			$emoticons_enabled = "false";
if($smilies)
{

			$emoticons_enabled = "false";
if($smilies)
{

				if($mybb->settings['smilieinserter'] && $mybb->settings['smilieinsertercols'] && $mybb->settings['smilieinsertertot'])
{
$emoticon = ",emoticon";
}
$emoticons_enabled = "true";


 
				if(!$smiliecache)
{
if(!isset($smilie_cache) || !is_array($smilie_cache))

				if(!$smiliecache)
{
if(!isset($smilie_cache) || !is_array($smilie_cache))

Zeile 3232Zeile 3256
						$smiliecache[$smilie['sid']] = $smilie;
}
}

						$smiliecache[$smilie['sid']] = $smilie;
}
}

 

if($mybb->settings['smilieinserter'] && $mybb->settings['smilieinsertercols'] && $mybb->settings['smilieinsertertot'] && !empty($smiliecache))
{
$emoticon = ",emoticon";
}
$emoticons_enabled = "true";


unset($smilie);



unset($smilie);


Zeile 3256Zeile 3286

if(!$mybb->settings['smilieinserter'] || !$mybb->settings['smilieinsertercols'] || !$mybb->settings['smilieinsertertot'] || !$smilie['showclickable'])
{


if(!$mybb->settings['smilieinserter'] || !$mybb->settings['smilieinsertercols'] || !$mybb->settings['smilieinsertertot'] || !$smilie['showclickable'])
{

							$hiddensmilies .= '"'.$find.'": "'.$image.'",';							

							$hiddensmilies .= '"'.$find.'": "'.$image.'",';

						}
elseif($i < $mybb->settings['smilieinsertertot'])
{

						}
elseif($i < $mybb->settings['smilieinsertertot'])
{

Zeile 3275Zeile 3305
						}
}
}

						}
}
}

			}

$basic1 = $basic2 = $align = $font = $size = $color = $removeformat = $email = $link = $list = $code = $sourcemode = "";

			}

$basic1 = $basic2 = $align = $font = $size = $color = $removeformat = $email = $link = $list = $code = $sourcemode = "";


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


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

			{

			{

				$basic1 = "bold,italic,underline,strike|";
$basic2 = "horizontalrule,";
}

				$basic1 = "bold,italic,underline,strike|";
$basic2 = "horizontalrule,";
}

Zeile 3288Zeile 3318
			if($mybb->settings['allowalignmycode'] == 1)
{
$align = "left,center,right,justify|";

			if($mybb->settings['allowalignmycode'] == 1)
{
$align = "left,center,right,justify|";

			}


			}


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

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

			{

			{

				$font = "font,";

				$font = "font,";

			}


			}


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

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

			{

			{

				$size = "size,";

				$size = "size,";

			}

			}


if($mybb->settings['allowcolormycode'] == 1)
{
$color = "color,";


if($mybb->settings['allowcolormycode'] == 1)
{
$color = "color,";

			}

			}


if($mybb->settings['allowfontmycode'] == 1 || $mybb->settings['allowsizemycode'] == 1 || $mybb->settings['allowcolormycode'] == 1)
{


if($mybb->settings['allowfontmycode'] == 1 || $mybb->settings['allowsizemycode'] == 1 || $mybb->settings['allowcolormycode'] == 1)
{

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

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





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

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

		{

		{

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

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

Zeile 3362Zeile 3392
		if(!$smiliecache)
{
if(!is_array($smilie_cache))

		if(!$smiliecache)
{
if(!is_array($smilie_cache))

			{

			{

				$smilie_cache = $cache->read("smilies");
}
foreach($smilie_cache as $smilie)
{

				$smilie_cache = $cache->read("smilies");
}
foreach($smilie_cache as $smilie)
{

				if($smilie['showclickable'] != 0)
{
$smilie['image'] = str_replace("{theme}", $theme['imgdir'], $smilie['image']);
$smiliecache[$smilie['sid']] = $smilie;
}

				$smilie['image'] = str_replace("{theme}", $theme['imgdir'], $smilie['image']);
$smiliecache[$smilie['sid']] = $smilie;




			}
}


			}
}


Zeile 3391Zeile 3418
				$smiliecount = $mybb->settings['smilieinsertertot'];
eval("\$getmore = \"".$templates->get("smilieinsert_getmore")."\";");
}

				$smiliecount = $mybb->settings['smilieinsertertot'];
eval("\$getmore = \"".$templates->get("smilieinsert_getmore")."\";");
}


$smilies = "";


$smilies = '';

			$counter = 0;
$i = 0;

$extra_class = '';
foreach($smiliecache as $smilie)
{

			$counter = 0;
$i = 0;

$extra_class = '';
foreach($smiliecache as $smilie)
{

				if($i < $mybb->settings['smilieinsertertot'])

				if($i < $mybb->settings['smilieinsertertot'] && $smilie['showclickable'] != 0)

				{

				{

					if($counter == 0)
{
$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']);

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

Zeile 3419Zeile 3441
					$onclick = " onclick=\"MyBBEditor.insertText(' $find ');\"";
$extra_class = ' smilie_pointer';
eval('$smilie = "'.$templates->get('smilie', 1, 0).'";');

					$onclick = " onclick=\"MyBBEditor.insertText(' $find ');\"";
$extra_class = ' smilie_pointer';
eval('$smilie = "'.$templates->get('smilie', 1, 0).'";');

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

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

					++$i;
++$counter;

if($counter == $mybb->settings['smilieinsertercols'])
{
$counter = 0;

					++$i;
++$counter;

if($counter == $mybb->settings['smilieinsertercols'])
{
$counter = 0;

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


						eval("\$smilies .= \"".$templates->get("smilieinsert_row")."\";");
$smilie_icons = '';

					}
}
}

					}
}
}

Zeile 3434Zeile 3457
			if($counter != 0)
{
$colspan = $mybb->settings['smilieinsertercols'] - $counter;

			if($counter != 0)
{
$colspan = $mybb->settings['smilieinsertercols'] - $counter;

				$smilies .= "<td colspan=\"{$colspan}\">&nbsp;</td>\n</tr>\n";

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

			}

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

			}

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

Zeile 3505Zeile 3528
}

/**

}

/**

 * Build the thread prefix selection menu

 * Build the thread prefix selection menu for the current user

 *
* @param int|string $fid The forum ID (integer ID or string all)
* @param int|string $selected_pid The selected prefix ID (integer ID or string any)
* @param int $multiple Allow multiple prefix selection

 *
* @param int|string $fid The forum ID (integer ID or string all)
* @param int|string $selected_pid The selected prefix ID (integer ID or string any)
* @param int $multiple Allow multiple prefix selection

 
 *  @param int $previous_pid The previously selected prefix ID

 *  @return string The thread prefix selection menu
*/

 *  @return string The thread prefix selection menu
*/

function build_prefix_select($fid, $selected_pid=0, $multiple=0)

function build_prefix_select($fid, $selected_pid=0, $multiple=0, $previous_pid=0)

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


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


Zeile 3524Zeile 3548
	$prefix_cache = build_prefixes(0);
if(empty($prefix_cache))
{

	$prefix_cache = build_prefixes(0);
if(empty($prefix_cache))
{

		return false; // We've got no prefixes to show
}

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

foreach($exp as $group)
{
$groups[] = $group;
}

		// We've got no prefixes to show
return '';











	}

// Go through each of our prefixes and decide which ones we can use

	}

// Go through each of our prefixes and decide which ones we can use

Zeile 3543Zeile 3557
	foreach($prefix_cache as $prefix)
{
if($fid != "all" && $prefix['forums'] != "-1")

	foreach($prefix_cache as $prefix)
{
if($fid != "all" && $prefix['forums'] != "-1")

		{
// Decide whether this prefix can be used in our forum
$forums = explode(",", $prefix['forums']);

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

		{
// Decide whether this prefix can be used in our forum
$forums = explode(",", $prefix['forums']);

if(!in_array($fid, $forums) && $prefix['pid'] != $previous_pid)
{

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

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

			}
}

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

foreach($groups as $group)
{
if(in_array($group, $prefix_groups) && !isset($prefixes[$prefix['pid']]))
{
// Our group can use this prefix!
$prefixes[$prefix['pid']] = $prefix;
}
}
}
else
{
// This prefix is for anybody to use...
$prefixes[$prefix['pid']] = $prefix;
}
}

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

			}
}

if(is_member($prefix['groups']) || $prefix['pid'] == $previous_pid)
{
// The current user can use this prefix
$prefixes[$prefix['pid']] = $prefix;
}
}

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















$prefixselect = $prefixselect_prefix = '';



$prefixselect = $prefixselect_prefix = '';


Zeile 3585Zeile 3586
	{
$any_selected = "";
if($selected_pid == 'any')

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

		{
$any_selected = " selected=\"selected\"";
}
}


		{
$any_selected = " selected=\"selected\"";
}
}


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

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

Zeile 3602Zeile 3603
		if($prefix['pid'] == $selected_pid)
{
$selected = " selected=\"selected\"";

		if($prefix['pid'] == $selected_pid)
{
$selected = " selected=\"selected\"";

		}


		}


		$prefix['prefix'] = htmlspecialchars_uni($prefix['prefix']);
eval("\$prefixselect_prefix .= \"".$templates->get("post_prefixselect_prefix")."\";");

		$prefix['prefix'] = htmlspecialchars_uni($prefix['prefix']);
eval("\$prefixselect_prefix .= \"".$templates->get("post_prefixselect_prefix")."\";");

	}

	}


if($multiple != 0)
{
eval("\$prefixselect = \"".$templates->get("post_prefixselect_multiple")."\";");


if($multiple != 0)
{
eval("\$prefixselect = \"".$templates->get("post_prefixselect_multiple")."\";");

	}

	}

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

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

	}


	}


	return $prefixselect;
}

/**

	return $prefixselect;
}

/**

 * Build the thread prefix selection menu for a forum

 * Build the thread prefix selection menu for a forum without group permission checks

 *
* @param int $fid The forum ID (integer ID)
* @param int $selected_pid The selected prefix ID (integer ID)

 *
* @param int $fid The forum ID (integer ID)
* @param int $selected_pid The selected prefix ID (integer ID)

 
 *  @return string The thread prefix selection menu

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

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

Zeile 3635Zeile 3637
	$prefix_cache = build_prefixes(0);
if(empty($prefix_cache))
{

	$prefix_cache = build_prefixes(0);
if(empty($prefix_cache))
{

		return false; // We've got no prefixes to show


		// We've got no prefixes to show
return '';

	}

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

	}

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

	{

	{

		if($prefix['forums'] != "-1")
{
// Decide whether this prefix can be used in our forum

		if($prefix['forums'] != "-1")
{
// Decide whether this prefix can be used in our forum

Zeile 3662Zeile 3665

if(empty($prefixes))
{


if(empty($prefixes))
{

		return false;

		return '';

	}

	}





	$default_selected = array();
$selected_pid = (int)$selected_pid;

	$default_selected = array();
$selected_pid = (int)$selected_pid;

	



	if($selected_pid == 0)
{
$default_selected['all'] = ' selected="selected"';

	if($selected_pid == 0)
{
$default_selected['all'] = ' selected="selected"';

Zeile 3778Zeile 3781
	{
$pid = (int)$data['pid'];
unset($data['pid']);

	{
$pid = (int)$data['pid'];
unset($data['pid']);

	}

	}


// Any remaining extra data - we my_serialize and insert in to its own column
if(is_array($data))


// Any remaining extra data - we my_serialize and insert in to its own column
if(is_array($data))

Zeile 3805Zeile 3808
 * @param int $reputation The reputation value
* @param int $uid The user ID (if not specified, the generated reputation will not be a link)
* @return string The formatted repuation

 * @param int $reputation The reputation value
* @param int $uid The user ID (if not specified, the generated reputation will not be a link)
* @return string The formatted repuation

 */

 */

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

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

Zeile 3814Zeile 3817
	if($reputation < 0)
{
$reputation_class = "reputation_negative";

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

	}

	}

	elseif($reputation > 0)
{
$reputation_class = "reputation_positive";

	elseif($reputation > 0)
{
$reputation_class = "reputation_positive";

	}
else

	}
else

	{
$reputation_class = "reputation_neutral";
}

	{
$reputation_class = "reputation_neutral";
}

	



	$reputation = my_number_format($reputation);

if($uid != 0)

	$reputation = my_number_format($reputation);

if($uid != 0)

Zeile 3845Zeile 3848
 * @return string Formatted warning level
*/
function get_colored_warning_level($level)

 * @return string Formatted warning level
*/
function get_colored_warning_level($level)

{

{

	global $templates;

$warning_class = '';

	global $templates;

$warning_class = '';

Zeile 3886Zeile 3889
		$addresses = array();

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

		$addresses = array();

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

		{

		{

			$addresses = explode(',', strtolower($_SERVER['HTTP_X_FORWARDED_FOR']));
}
elseif(isset($_SERVER['HTTP_X_REAL_IP']))

			$addresses = explode(',', strtolower($_SERVER['HTTP_X_FORWARDED_FOR']));
}
elseif(isset($_SERVER['HTTP_X_REAL_IP']))

Zeile 3955Zeile 3958
	elseif($size >= 1152921504606846976)
{
$size = my_number_format(round(($size / 1152921504606846976), 2))." ".$lang->size_eb;

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

	}

	}

	// Petabyte (1024 Terabytes)
elseif($size >= 1125899906842624)
{
$size = my_number_format(round(($size / 1125899906842624), 2))." ".$lang->size_pb;

	// Petabyte (1024 Terabytes)
elseif($size >= 1125899906842624)
{
$size = my_number_format(round(($size / 1125899906842624), 2))." ".$lang->size_pb;

	}

	}

	// Terabyte (1024 Gigabytes)
elseif($size >= 1099511627776)
{

	// Terabyte (1024 Gigabytes)
elseif($size >= 1099511627776)
{

Zeile 3968Zeile 3971
	}
// Gigabyte (1024 Megabytes)
elseif($size >= 1073741824)

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

	{

	{

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

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

	}

	}

	// Megabyte (1024 Kilobytes)
elseif($size >= 1048576)
{
$size = my_number_format(round(($size / 1048576), 2))." ".$lang->size_mb;

	// Megabyte (1024 Kilobytes)
elseif($size >= 1048576)
{
$size = my_number_format(round(($size / 1048576), 2))." ".$lang->size_mb;

	}

	}

	// Kilobyte (1024 bytes)
elseif($size >= 1024)
{
$size = my_number_format(round(($size / 1024), 2))." ".$lang->size_kb;
}
elseif($size == 0)

	// Kilobyte (1024 bytes)
elseif($size >= 1024)
{
$size = my_number_format(round(($size / 1024), 2))." ".$lang->size_kb;
}
elseif($size == 0)

	{

	{

		$size = "0 ".$lang->size_bytes;

		$size = "0 ".$lang->size_bytes;

	}

	}

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

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





	return $size;
}

/**
* Format a decimal number in to microseconds, milliseconds, or seconds.

	return $size;
}

/**
* Format a decimal number in to microseconds, milliseconds, or seconds.

 *

 *

 * @param int $time The time in microseconds
* @return string The friendly time duration
*/

 * @param int $time The time in microseconds
* @return string The friendly time duration
*/

Zeile 4159Zeile 4162
			$unviewable[] = $forum['fid'];
}
}

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

	



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

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

	



	return $unviewableforums;
}


	return $unviewableforums;
}


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

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





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

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

Zeile 4540Zeile 4543
	echo "</body>";
echo "</html>";
exit;

	echo "</body>";
echo "</html>";
exit;

}

}


/**
* Outputs the correct page headers.


/**
* Outputs the correct page headers.

Zeile 4757Zeile 4760
 * @return string trow1 or trow2 depending on the previous call
*/
function alt_trow($reset=0)

 * @return string trow1 or trow2 depending on the previous call
*/
function alt_trow($reset=0)

{

{

	global $alttrow;

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

	global $alttrow;

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

	{

	{

		$trow = "trow2";

		$trow = "trow2";

	}

	}

	else
{
$trow = "trow1";

	else
{
$trow = "trow1";

	}


	}


	$alttrow = $trow;

	$alttrow = $trow;





	return $trow;
}

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

	return $trow;
}

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

 *
* @param int $uid The user ID

 *
* @param int $uid The user ID

 * @param int $joingroup The user group ID to join
* @return bool
*/
function join_usergroup($uid, $joingroup)
{
global $db, $mybb;

 * @param int $joingroup The user group ID to join
* @return bool
*/
function join_usergroup($uid, $joingroup)
{
global $db, $mybb;


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


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

	}
else
{

	}
else
{

Zeile 4817Zeile 4820

// What's the point in updating if they're the same?
if($groupslist != $user['additionalgroups'])


// What's the point in updating if they're the same?
if($groupslist != $user['additionalgroups'])

	{

	{

		$db->update_query("users", array('additionalgroups' => $groupslist), "uid='".(int)$uid."'");
return true;
}

		$db->update_query("users", array('additionalgroups' => $groupslist), "uid='".(int)$uid."'");
return true;
}

Zeile 4837Zeile 4840
{
global $db, $mybb, $cache;


{
global $db, $mybb, $cache;


	if($uid == $mybb->user['uid'])
{
$user = $mybb->user;
}
else
{
$user = get_user($uid);
}

	$user = get_user($uid);









$groupslist = $comma = '';
$usergroups = $user['additionalgroups'].",";


$groupslist = $comma = '';
$usergroups = $user['additionalgroups'].",";

Zeile 4915Zeile 4911
	{
$location = htmlspecialchars_uni($_ENV['PATH_INFO']);
}

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

	



	if($quick)
{
return $location;

	if($quick)
{
return $location;

Zeile 5027Zeile 5023

if(is_array($tcache[$tid]))
{


if(is_array($tcache[$tid]))
{

		// Figure out what groups this user is in
if(isset($mybb->user['additionalgroups']))
{
$in_groups = explode(",", $mybb->user['additionalgroups']);
}
$in_groups[] = $mybb->user['usergroup'];


 
		foreach($tcache[$tid] as $theme)
{
$sel = "";

		foreach($tcache[$tid] as $theme)
{
$sel = "";

Zeile 5200Zeile 5189
	if(!isset($use_mb))
{
$use_mb = function_exists("mb_convert_encoding");

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

	}


	}


	if($use_iconv || $use_mb)
{
if($to)

	if($use_iconv || $use_mb)
{
if($to)

		{

		{

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

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

		}

		}

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

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

		{

		{

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

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

		{

		{

			return @mb_convert_encoding($str, $to_charset, $from_charset);

			return @mb_convert_encoding($str, $to_charset, $from_charset);

		}

		}

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

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

		}

		}

		else
{
return utf8_decode($str);
}

		else
{
return utf8_decode($str);
}

	}

	}

	else
{
return $str;

	else
{
return $str;

Zeile 5242Zeile 5231

/**
* DEPRECATED! Please use other alternatives.


/**
* DEPRECATED! Please use other alternatives.

 *

 *

 * @deprecated
* @param string $message

 * @deprecated
* @param string $message

 *

 *

 * @return string
*/
function my_wordwrap($message)
{
return $message;

 * @return string
*/
function my_wordwrap($message)
{
return $message;

}

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

}

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

 * @param int $month The month of the birthday
* @param int $day The day of the birthday
* @param int $year The year of the bithday

 * @param int $month The month of the birthday
* @param int $day The day of the birthday
* @param int $year The year of the bithday

Zeile 5310Zeile 5299
		31,
30,
31,

		31,
30,
31,

		30,

		30,

		31
);
}

		31
);
}

Zeile 5633Zeile 5622
 * @return int|bool false on needle not found, integer position if found
*/
function my_strpos($haystack, $needle, $offset=0)

 * @return int|bool false on needle not found, integer position if found
*/
function my_strpos($haystack, $needle, $offset=0)

{

{

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

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

Zeile 5731Zeile 5720
 */
function get_event_poster($event)
{

 */
function get_event_poster($event)
{

 
	$event['username'] = htmlspecialchars_uni($event['username']);

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

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

Zeile 5747Zeile 5737
	global $mybb;

$event_date = explode("-", $event['date']);

	global $mybb;

$event_date = explode("-", $event['date']);

	$event_date = mktime(0, 0, 0, $event_date[1], $event_date[0], $event_date[2]);

	$event_date = gmmktime(0, 0, 0, $event_date[1], $event_date[0], $event_date[2]);

	$event_date = my_date($mybb->settings['dateformat'], $event_date);

return $event_date;

	$event_date = my_date($mybb->settings['dateformat'], $event_date);

return $event_date;

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

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

	{
if($action)
{

	{
if($action)
{

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

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

Zeile 6177Zeile 6167
 * @return string The comma separated values of the inactivate forum.
*/
function get_inactive_forums()

 * @return string The comma separated values of the inactivate forum.
*/
function get_inactive_forums()

{
global $forum_cache, $cache;

{
global $forum_cache, $cache;


if(!$forum_cache)
{


if(!$forum_cache)
{

Zeile 6201Zeile 6191
			}
}
}

			}
}
}

	



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

return $inactiveforums;
}

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

return $inactiveforums;
}





/**
* Checks to make sure a user has not tried to login more times than permitted
*

/**
* Checks to make sure a user has not tried to login more times than permitted
*

Zeile 6220Zeile 6210
	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.

// Use cookie if possible, otherwise use session

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

// Use cookie if possible, otherwise use session

Zeile 6287Zeile 6277
		}
// Not waited long enough
else if($mybb->cookies['failedlogin'] > ($now - $mybb->settings['failedlogintime'] * 60))

		}
// Not waited long enough
else if($mybb->cookies['failedlogin'] > ($now - $mybb->settings['failedlogintime'] * 60))

		{

		{

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

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





			return false;
}
}

			return false;
}
}





	// User can attempt another login
return $loginattempts;

	// User can attempt another login
return $loginattempts;

}


}


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

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

Zeile 6327Zeile 6317
function email_already_in_use($email, $uid=0)
{
global $db;

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





	$uid_string = "";
if($uid)
{

	$uid_string = "";
if($uid)
{

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

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

	}

	}

	else
{
$mode = "w";

	else
{
$mode = "w";

Zeile 6381Zeile 6371

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


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





/**
* Build a PREG compatible array of search highlight terms to replace in posts.
*

/**
* Build a PREG compatible array of search highlight terms to replace in posts.
*

Zeile 6391Zeile 6381
function build_highlight_array($terms)
{
global $mybb;

function build_highlight_array($terms)
{
global $mybb;





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

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

	}


	}


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

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

Zeile 6462Zeile 6452
				}
$words[] = trim($word);
}

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

		}
}


		}
}


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

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

Zeile 6504Zeile 6494
 * @return string|bool
*/
function dec_to_utf8($src)

 * @return string|bool
*/
function dec_to_utf8($src)

{

{

	$dest = '';

if($src < 0)

	$dest = '';

if($src < 0)

Zeile 6606Zeile 6596
					$db->update_query("banfilters", array("lastuse" => TIME_NOW), "fid='{$banned_email['fid']}'");
}
return true;

					$db->update_query("banfilters", array("lastuse" => TIME_NOW), "fid='{$banned_email['fid']}'");
}
return true;

			}
}

			}
}

	}

// Still here - good email

	}

// Still here - good email

Zeile 6706Zeile 6696
		"6.5" => $lang->timezone_gmt_650,
"7" => $lang->timezone_gmt_700,
"8" => $lang->timezone_gmt_800,

		"6.5" => $lang->timezone_gmt_650,
"7" => $lang->timezone_gmt_700,
"8" => $lang->timezone_gmt_800,

 
		"8.5" => $lang->timezone_gmt_850,
"8.75" => $lang->timezone_gmt_875,

		"9" => $lang->timezone_gmt_900,
"9.5" => $lang->timezone_gmt_950,
"10" => $lang->timezone_gmt_1000,

		"9" => $lang->timezone_gmt_900,
"9.5" => $lang->timezone_gmt_950,
"10" => $lang->timezone_gmt_1000,

Zeile 6779Zeile 6771
 *
* @param string $url The URL of the remote file
* @param array $post_data The array of post data

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

 
 * @param int $max_redirects Number of maximum redirects

 * @return string|bool The remote file contents. False on failure
*/

 * @return string|bool The remote file contents. False on failure
*/

function fetch_remote_file($url, $post_data=array())

function fetch_remote_file($url, $post_data=array(), $max_redirects=20)

{

{

 
	global $mybb, $config;

$url_components = @parse_url($url);

if(
!$url_components ||
empty($url_components['host']) ||
(!empty($url_components['scheme']) && !in_array($url_components['scheme'], array('http', 'https'))) ||
(!empty($url_components['port']) && !in_array($url_components['port'], array(80, 8080, 443))) ||
(!empty($config['disallowed_remote_hosts']) && in_array($url_components['host'], $config['disallowed_remote_hosts']))
)
{
return false;
}

if(!empty($config['disallowed_remote_addresses']))
{
$addresses = gethostbynamel($url_components['host']);
if($addresses)
{
foreach($config['disallowed_remote_addresses'] as $disallowed_address)
{
$ip_range = fetch_ip_range($disallowed_address);
foreach($addresses as $address)
{
$packed_address = my_inet_pton($address);

if(is_array($ip_range))
{
if(strcmp($ip_range[0], $packed_address) <= 0 && strcmp($ip_range[1], $packed_address) >= 0)
{
return false;
}
}
elseif($address == $disallowed_address)
{
return false;
}
}
}
}
}


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

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

Zeile 6795Zeile 6831

if(function_exists("curl_init"))
{


if(function_exists("curl_init"))
{

 
		$can_followlocation = @ini_get('open_basedir') === '' && !$mybb->safemode;

$request_header = $max_redirects != 0 && !$can_followlocation;


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

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

		curl_setopt($ch, CURLOPT_HEADER, 0);

		curl_setopt($ch, CURLOPT_HEADER, $request_header);

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

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

		curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);








		curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);

if($max_redirects != 0 && $can_followlocation)
{
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_MAXREDIRS, $max_redirects);
}


		if(!empty($post_body))
{
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_body);
}

		if(!empty($post_body))
{
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_body);
}

		$data = curl_exec($ch);





























$response = curl_exec($ch);

if($request_header)
{
$header_size = curl_getinfo($ch, CURLINFO_HEADER_SIZE);
$header = substr($response, 0, $header_size);
$body = substr($response, $header_size);

if(in_array(curl_getinfo($ch, CURLINFO_HTTP_CODE), array(301, 302)))
{
preg_match('/Location:(.*?)(?:\n|$)/', $header, $matches);

if($matches)
{
$data = fetch_remote_file(trim(array_pop($matches)), $post_data, --$max_redirects);
}
}
else
{
$data = $body;
}
}
else
{
$data = $response;
}


		curl_close($ch);
return $data;
}
else if(function_exists("fsockopen"))

		curl_close($ch);
return $data;
}
else if(function_exists("fsockopen"))

	{
$url = @parse_url($url);
if(!$url['host'])
{
return false;
}
if(!$url['port'])
{
$url['port'] = 80;
}
if(!$url['path'])
{
$url['path'] = "/";
}
if($url['query'])
{
$url['path'] .= "?{$url['query']}";
}

$scheme = '';

	{
if(!isset($url_components['port']))
{
$url_components['port'] = 80;
}
if(!isset($url_components['path']))
{
$url_components['path'] = "/";
}
if(isset($url_components['query']))
{
$url_components['path'] .= "?{$url_components['query']}";
}

$scheme = '';










		if($url['scheme'] == 'https')

		if($url_components['scheme'] == 'https')

		{
$scheme = 'ssl://';

		{
$scheme = 'ssl://';

			if($url['port'] == 80)

			if($url_components['port'] == 80)

			{

			{

				$url['port'] = 443;

				$url_components['port'] = 443;

			}

			}

		}

		}





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

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

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

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

Zeile 6850Zeile 6919
		$headers = array();
if(!empty($post_body))
{

		$headers = array();
if(!empty($post_body))
{

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

			$headers[] = "POST {$url_components['path']} HTTP/1.0";

			$headers[] = "Content-Length: ".strlen($post_body);
$headers[] = "Content-Type: application/x-www-form-urlencoded";

			$headers[] = "Content-Length: ".strlen($post_body);
$headers[] = "Content-Type: application/x-www-form-urlencoded";

		}
else

		}
else

		{

		{

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

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

		}


		}


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

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

		$headers[] = "Connection: Close";

		$headers[] = "Connection: Close";

		$headers[] = '';


		$headers[] = '';


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

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

Zeile 6875Zeile 6944

$headers = implode("\r\n", $headers);
if(!@fwrite($fp, $headers))


$headers = implode("\r\n", $headers);
if(!@fwrite($fp, $headers))

		{

		{

			return false;
}

			return false;
}

 

$data = null;


		while(!feof($fp))
{
$data .= fgets($fp, 12800);

		while(!feof($fp))
{
$data .= fgets($fp, 12800);

		}

		}

		fclose($fp);

		fclose($fp);

 


		$data = explode("\r\n\r\n", $data, 2);

		$data = explode("\r\n\r\n", $data, 2);

		return $data[1];





















$header = $data[0];
$status_line = current(explode("\n\n", $header, 1));
$body = $data[1];

if($max_redirects != 0 && (strstr($status_line, ' 301 ') || strstr($status_line, ' 302 ')))
{
preg_match('/Location:(.*?)(?:\n|$)/', $header, $matches);

if($matches)
{
$data = fetch_remote_file(trim(array_pop($matches)), $post_data, --$max_redirects);
}
}
else
{
$data = $body;
}

return $data;

	}
else if(empty($post_data))
{
return @implode("", @file($url));

	}
else if(empty($post_data))
{
return @implode("", @file($url));

	}
else
{
return false;
}
}


	}
else
{
return false;
}
}


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

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

Zeile 6921Zeile 7013
		return true;
}
}

		return true;
}
}





/**
* Checks if a user is a member of a particular group
* Originates from frostschutz's PluginLibrary

/**
* Checks if a user is a member of a particular group
* Originates from frostschutz's PluginLibrary

Zeile 6934Zeile 7026
function is_member($groups, $user = false)
{
global $mybb;

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

	



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

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

Zeile 7548Zeile 7640
	global $mybb, $checksums, $bad_verify_files;

// We don't need to check these types of files

	global $mybb, $checksums, $bad_verify_files;

// We don't need to check these types of files

	$ignore = array(".", "..", ".svn", "config.php", "settings.php", "Thumb.db", "config.default.php", "lock", "htaccess.txt", "logo.gif", "logo.png");

	$ignore = array(".", "..", ".svn", "config.php", "settings.php", "Thumb.db", "config.default.php", "lock", "htaccess.txt", "htaccess-nginx.txt", "logo.gif", "logo.png");

	$ignore_ext = array("attach");

if(substr($path, -1, 1) == "/")

	$ignore_ext = array("attach");

if(substr($path, -1, 1) == "/")

Zeile 7651Zeile 7743
}

/**

}

/**

 * Returns a securely generated seed for PHP's RNG (Random Number Generator)

 * Returns a securely generated seed

 *

 *

 * @param int $count Length of the seed bytes (8 is default. Provides good cryptographic variance)
* @return int An integer equivalent of a secure hexadecimal seed
*/
function secure_seed_rng($count=8)
{
$output = '';
// 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')))

 * @return string A secure binary seed
*/
function secure_binary_seed_rng($bytes)
{
$output = null;

if(version_compare(PHP_VERSION, '7.0', '>='))
{
try














		{

		{

			$output = @fread($handle, $count);
@fclose($handle);
}

			$output = random_bytes($bytes);
} catch (Exception $e) {
}

	}

	}

	else



if(strlen($output) < $bytes)

	{

	{

		// 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', '>='))

		if(@is_readable('/dev/urandom') && ($handle = @fopen('/dev/urandom', 'rb')))




		{

		{

			$output = openssl_random_pseudo_bytes($count);
}
// Try mcrypt
elseif(function_exists('mcrypt_create_iv'))
{
$output = mcrypt_create_iv($count, MCRYPT_RAND);

			$output = @fread($handle, $bytes);
@fclose($handle);





		}

		}

		// Try Windows CAPICOM before using our own generator
elseif(class_exists('COM'))

















































	}
else
{
return $output;
}

if(strlen($output) < $bytes)
{
if(function_exists('mcrypt_create_iv'))
{
if (DIRECTORY_SEPARATOR == '/')
{
$source = MCRYPT_DEV_URANDOM;
}
else
{
$source = MCRYPT_RAND;
}

$output = @mcrypt_create_iv($bytes, $source);
}
}
else
{
return $output;
}

if(strlen($output) < $bytes)
{
if(function_exists('openssl_random_pseudo_bytes'))
{
// PHP <5.3.4 had a bug which makes that function unusable on Windows
if ((DIRECTORY_SEPARATOR == '/') || version_compare(PHP_VERSION, '5.3.4', '>='))
{
$output = openssl_random_pseudo_bytes($bytes, $crypto_strong);
if ($crypto_strong == false)
{
$output = null;
}
}
}
}
else
{
return $output;
}

if(strlen($output) < $bytes)
{
if(class_exists('COM'))

		{
try
{
$CAPI_Util = new COM('CAPICOM.Utilities.1');
if(is_callable(array($CAPI_Util, 'GetRandom')))
{

		{
try
{
$CAPI_Util = new COM('CAPICOM.Utilities.1');
if(is_callable(array($CAPI_Util, 'GetRandom')))
{

					$output = $CAPI_Util->GetRandom($count, 0);

					$output = $CAPI_Util->GetRandom($bytes, 0);

				}
} catch (Exception $e) {
}
}

				}
} catch (Exception $e) {
}
}

 
	}
else
{
return $output;

	}


	}


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

	if(strlen($output) < $bytes)


	{

	{

		$output = '';


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

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


for($i = 0; $i < $count; $i += 16)
{




$rounds = ceil($bytes / 16);

for($i = 0; $i < $rounds; $i++)
{

			$unique_state = md5(microtime().$unique_state);

			$unique_state = md5(microtime().$unique_state);

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











			$output .= md5($unique_state);
}

$output = substr($output, 0, ($bytes * 2));

$output = pack('H*', $output);

return $output;
}
else
{
return $output;

	}

	}

 
}

/**
* Returns a securely generated seed integer
*
* @return int An integer equivalent of a secure hexadecimal seed
*/
function secure_seed_rng()
{
$bytes = PHP_INT_SIZE;

do
{

$output = secure_binary_seed_rng($bytes);

// convert binary data to a decimal number
if ($bytes == 4)
{
$elements = unpack('i', $output);
$output = abs($elements[1]);
}
else
{
$elements = unpack('N2', $output);
$output = abs($elements[1] << 32 | $elements[2]);
}





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

	} while($output > PHP_INT_MAX);



return $output;
}

/**


return $output;
}

/**

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

 * Generates a cryptographically secure random number.

 *
* @param int $min Optional lowest value to be returned (default: 0)

 *
* @param int $min Optional lowest value to be returned (default: 0)

 * @param int $max Optional highest value to be returned (default: mt_getrandmax())
* @param boolean $force_seed True forces it to reseed the RNG first
* @return int An integer equivalent of a secure hexadecimal seed

 * @param int $max Optional highest value to be returned (default: PHP_INT_MAX)



 */

 */

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

function my_rand($min=0, $max=PHP_INT_MAX)

{

{

	static $seeded = false;
static $obfuscator = 0;





	// backward compatibility
if($min === null || $max === null || $max < $min)
{
$min = 0;
$max = PHP_INT_MAX;
}





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

	if(version_compare(PHP_VERSION, '7.0', '>='))

	{

	{

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

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


		try
{
$result = random_int($min, $max);
} catch (Exception $e) {
}





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

		if(isset($result))


		{

		{

			$obfuscator -= mt_getrandmax();

			return $result;

		}
}

		}
}


if($min !== null && $max !== null)
{
$distance = $max - $min;
if($distance > 0)
{
return $min + (int)((float)($distance + 1) * (float)(mt_rand() ^ $obfuscator) / (mt_getrandmax() + 1));
}
else
{
return mt_rand($min, $max);
}
}
else
{
$val = mt_rand() ^ $obfuscator;
return $val;
}


$seed = secure_seed_rng();

$distance = $max - $min;
return $min + floor($distance * ($seed / PHP_INT_MAX) );














}

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

}

/**
* 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 $string The string to trim from
* @param string $charlist Optional. The stripped characters can also be specified using the charlist parameter
* @return string The trimmed string

 * @param string $string The string to trim from
* @param string $charlist Optional. The stripped characters can also be specified using the charlist parameter
* @return string The trimmed string

Zeile 7787Zeile 7936
function trim_blank_chrs($string, $charlist="")
{
$hex_chrs = array(

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

		0x09 => 1, // \x{0009}
0x0A => 1, // \x{000A}

		0x09 => 1, // \x{0009}
0x0A => 1, // \x{000A}

		0x0B => 1, // \x{000B}
0x0D => 1, // \x{000D}
0x20 => 1, // \x{0020}

		0x0B => 1, // \x{000B}
0x0D => 1, // \x{000D}
0x20 => 1, // \x{0020}

Zeile 7853Zeile 8002
	{
// Check to see if we have matched a first character in our utf-8 array
$offset = match_sequence($string, $hex_chrs);

	{
// Check to see if we have matched a first character in our utf-8 array
$offset = match_sequence($string, $hex_chrs);

		if(!$offset)
{
// If not, then we must have a "good" character and we don't need to do anymore processing
break;

		if(!$offset)
{
// If not, then we must have a "good" character and we don't need to do anymore processing
break;

		}
$string = substr($string, $offset);
}

		}
$string = substr($string, $offset);
}

Zeile 7885Zeile 8034
	else
{
$string = trim($string);

	else
{
$string = trim($string);

	}

	}


return $string;
}


return $string;
}

Zeile 7904Zeile 8053
	if($string === "")
{
return 0;

	if($string === "")
{
return 0;

	}

	}


$ord = ord($string[$i]);
if(array_key_exists($ord, $array))


$ord = ord($string[$i]);
if(array_key_exists($ord, $array))

Zeile 7932Zeile 8081
	static $gd_version;

if($gd_version)

	static $gd_version;

if($gd_version)

	{

	{

		return $gd_version;
}
if(!extension_loaded('gd'))

		return $gd_version;
}
if(!extension_loaded('gd'))

Zeile 8086Zeile 8235
 * @return bool True if PM sent
*/
function send_pm($pm, $fromid = 0, $admin_override=false)

 * @return bool True if PM sent
*/
function send_pm($pm, $fromid = 0, $admin_override=false)

{

{

	global $lang, $mybb, $db, $session;

	global $lang, $mybb, $db, $session;





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

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

	{
return false;

	{
return false;

	}

if(!is_array($pm))

	}

if(!is_array($pm))

	{
return false;

	{
return false;

	}

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

	}

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

Zeile 8105Zeile 8254
		{
// Load user language
$lang->set_language($pm['language']);

		{
// Load user language
$lang->set_language($pm['language']);

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

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


$revert = true;
}

foreach(array('subject', 'message') as $key)
{


$revert = true;
}

foreach(array('subject', 'message') as $key)
{

			$lang_string = $pm[$key];

 
			if(is_array($pm[$key]))
{

			if(is_array($pm[$key]))
{

 
				$lang_string = $lang->{$pm[$key][0]};

				$num_args = count($pm[$key]);

				$num_args = count($pm[$key]);





				for($i = 1; $i < $num_args; $i++)
{

				for($i = 1; $i < $num_args; $i++)
{

					$lang->{$pm[$key][0]} = str_replace('{'.$i.'}', $pm[$key][$i], $lang->{$pm[$key][0]});

					$lang_string = str_replace('{'.$i.'}', $pm[$key][$i], $lang_string);

				}

				}


$lang_string = $pm[$key][0];



			}
else
{
$lang_string = $lang->{$pm[$key]};

			}


			}


			$pm[$key] = $lang->{$lang_string};

			$pm[$key] = $lang_string;

		}

if(isset($revert))

		}

if(isset($revert))

Zeile 8140Zeile 8291
	{
return false;
}

	{
return false;
}


$lang->load('messages');

 

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



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


Zeile 8167Zeile 8316
	if((int)$fromid == 0)
{
$fromid = (int)$mybb->user['uid'];

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

	}

	}

	elseif((int)$fromid < 0)
{
$fromid = 0;

	elseif((int)$fromid < 0)
{
$fromid = 0;

Zeile 8196Zeile 8345
		"savecopy" => 0,
"readreceipt" => 0
);

		"savecopy" => 0,
"readreceipt" => 0
);





	$pm['saveasdraft'] = 0;

// Admin override

	$pm['saveasdraft'] = 0;

// Admin override

Zeile 8225Zeile 8374
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;





	if(!is_array($data))

	if(!is_array($data))

	{

	{

		$data = array($data);

		$data = array($data);

	}

	}


if(!$ip_address)
{
$ip_address = get_ip();
}


if(!$ip_address)
{
$ip_address = get_ip();
}





	$ip_address = my_inet_pton($ip_address);

$insert_array = array(

	$ip_address = my_inet_pton($ip_address);

$insert_array = array(

Zeile 8244Zeile 8393
		'ipaddress' => $db->escape_binary($ip_address),
'dateline' => (int)TIME_NOW,
'data' => $db->escape_string(@my_serialize($data)),

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

	);

	);


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


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

Zeile 8264Zeile 8413

$success = false;



$success = false;


	$file_path = (string)$file_path;


	$file_path = (string)$file_path;


	$real_file_path = realpath($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);

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

	if(file_exists($file_path))
{
if($mybb->settings['usecdn'] && !empty($mybb->settings['cdnpath']))

Zeile 8321Zeile 8470
	}

return $success;

	}

return $success;

 
}

/**
* Validate an url
*
* @param string $url The url to validate.
* @param bool $relative_path Whether or not the url could be a relative path.
*
* @return bool Whether this is a valid url.
*/
function my_validate_url($url, $relative_path=false)
{
if($relative_path && my_substr($url, 0, 1) == '/' || preg_match('_^(?:(?:https?|ftp)://)(?:\S+(?::\S*)?@)?(?:(?!(?:10|127)(?:\.\d{1,3}){3})(?!(?:169\.254|192\.168)(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z\x{00a1}-\x{ffff}0-9]-*)*[a-z\x{00a1}-\x{ffff}0-9]+)(?:\.(?:[a-z\x{00a1}-\x{ffff}0-9]-*)*[a-z\x{00a1}-\x{ffff}0-9]+)*(?:\.(?:[a-z\x{00a1}-\x{ffff}]{2,}))\.?)(?::\d{2,5})?(?:[/?#]\S*)?$_iuS', $url))
{
return true;
}

return false;
}

/**
* Strip html tags from string, also removes <script> and <style> contents.
*
* @param string $string String to stripe
* @param string $allowable_tags Allowed html tags
*
* @return string Striped string
*/
function my_strip_tags($string, $allowable_tags = '')
{
$pattern = array(
'@(&lt;)style[^(&gt;)]*?(&gt;).*?(&lt;)/style(&gt;)@siu',
'@(&lt;)script[^(&gt;)]*?.*?(&lt;)/script(&gt;)@siu',
'@<style[^>]*?>.*?</style>@siu',
'@<script[^>]*?.*?</script>@siu',
);
$string = preg_replace($pattern, '', $string);
return strip_tags($string, $allowable_tags);

}

}