Vergleich inc/functions.php - 1.8.6 - 1.8.11

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

		{
continue;
}

Zeile 1254Zeile 1256
				{
$usergroup[$perm] = 0;
continue;

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

				}


				}


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

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

Zeile 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 1284Zeile 1286

$displaygroup = array();
$group = $groupscache[$gid];


$displaygroup = array();
$group = $groupscache[$gid];





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

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

Zeile 1304Zeile 1306
function forum_permissions($fid=0, $uid=0, $gid=0)
{
global $db, $cache, $groupscache, $forum_cache, $fpermcache, $mybb, $cached_forum_permissions_permissions, $cached_forum_permissions;

function forum_permissions($fid=0, $uid=0, $gid=0)
{
global $db, $cache, $groupscache, $forum_cache, $fpermcache, $mybb, $cached_forum_permissions_permissions, $cached_forum_permissions;


if($uid == 0)


if($uid == 0)

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

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

Zeile 1459Zeile 1461
		$current_permissions = $groupperms;
}
return $current_permissions;

		$current_permissions = $groupperms;
}
return $current_permissions;

}

/**

}

/**

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

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

Zeile 1481Zeile 1483
		if(!$forum_cache)
{
return false;

		if(!$forum_cache)
{
return false;

		}

		}

	}

// Loop through each of parent forums to ensure we have a password for them too

	}

// Loop through each of parent forums to ensure we have a password for them too

Zeile 1500Zeile 1502
			}

if($forum_cache[$parent_id]['password'] != "")

			}

if($forum_cache[$parent_id]['password'] != "")

			{

			{

				check_forum_password($parent_id, $fid);
}
}

				check_forum_password($parent_id, $fid);
}
}

Zeile 1510Zeile 1512
	{
$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);
$showform = false;
}
else
{
eval("\$pwnote = \"".$templates->get("forumdisplay_password_wrongpass")."\";");

				my_setcookie("forumpass[$fid]", md5($mybb->user['uid'].$mybb->get_input('pwverify')), null, true);
$showform = false;
}
else
{
eval("\$pwnote = \"".$templates->get("forumdisplay_password_wrongpass")."\";");

				$showform = true;

				$showform = true;

			}
}
else

			}
}
else

Zeile 1537Zeile 1539
	else
{
$showform = false;

	else
{
$showform = false;

	}


	}


	if($return)
{
return $showform;

	if($return)
{
return $showform;

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 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 1817Zeile 1831
	}

if($expires == -1)

	}

if($expires == -1)

	{

	{

		$expires = 0;
}
elseif($expires == "" || $expires == null)

		$expires = 0;
}
elseif($expires == "" || $expires == null)

Zeile 1839Zeile 1853
	if($expires > 0)
{
$cookie .= "; expires=".@gmdate('D, d-M-Y H:i:s \\G\\M\\T', $expires);

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

	}

	}


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


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

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

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

 
	}

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

	}

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

	}

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

Zeile 2145Zeile 2164
	{
mb_internal_encoding($mbIntEnc);
}

	{
mb_internal_encoding($mbIntEnc);
}

	



	return $out;
}


	return $out;
}


Zeile 2158Zeile 2177
 * @param mixed $value
* @return string
* @throw Exception if $value is malformed or contains unsupported types (e.g., resources, 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))

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


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

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

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

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

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

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

		{

		{

			$serverload = explode(" ", $load);
$serverload[0] = round($serverload[0], 4);
}
if(!is_numeric($serverload[0]))
{
if($mybb->safemode)

			$serverload = explode(" ", $load);
$serverload[0] = round($serverload[0], 4);
}
if(!is_numeric($serverload[0]))
{
if($mybb->safemode)

			{
return $lang->unknown;
}

			{
return $lang->unknown;
}


// Suhosin likes to throw a warning if exec is disabled then die - weird
if($func_blacklist = @ini_get('suhosin.executor.func.blacklist'))


// Suhosin likes to throw a warning if exec is disabled then die - weird
if($func_blacklist = @ini_get('suhosin.executor.func.blacklist'))

Zeile 2282Zeile 2301
			{
return $lang->unknown;
}

			{
return $lang->unknown;
}

		}

		}

	}
else
{

	}
else
{

Zeile 2308Zeile 2327
	elseif(function_exists('memory_get_usage'))
{
return memory_get_usage(true);

	elseif(function_exists('memory_get_usage'))
{
return memory_get_usage(true);

	}

	}

	return false;
}


	return false;
}


Zeile 2357Zeile 2376
	else
{
$stats = $stats_changes;

	else
{
$stats = $stats_changes;

	}

$new_stats = array();

	}

$new_stats = array();

	$counters = array('numthreads', 'numunapprovedthreads', 'numposts', 'numunapprovedposts', 'numusers', 'numdeletedposts', 'numdeletedthreads');
foreach($counters as $counter)
{

	$counters = array('numthreads', 'numunapprovedthreads', 'numposts', 'numunapprovedposts', 'numusers', 'numdeletedposts', 'numdeletedthreads');
foreach($counters as $counter)
{

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


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


Zeile 2459Zeile 2478
	// Fetch above counters for this forum
$query = $db->simple_select("forums", implode(",", $counters), "fid='{$fid}'");
$forum = $db->fetch_array($query);

	// Fetch above counters for this forum
$query = $db->simple_select("forums", implode(",", $counters), "fid='{$fid}'");
$forum = $db->fetch_array($query);


foreach($counters as $counter)
{
if(array_key_exists($counter, $changes))
{
if(substr($changes[$counter], 0, 2) == "+-")
{
$changes[$counter] = substr($changes[$counter], 1);


foreach($counters as $counter)
{
if(array_key_exists($counter, $changes))
{
if(substr($changes[$counter], 0, 2) == "+-")
{
$changes[$counter] = substr($changes[$counter], 1);

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

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

			{

			{

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

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

Zeile 2479Zeile 2498
			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 2503Zeile 2522
		if($threads_diff > -1)
{
$new_stats['numthreads'] = "+{$threads_diff}";

		if($threads_diff > -1)
{
$new_stats['numthreads'] = "+{$threads_diff}";

		}
else
{

		}
else
{

			$new_stats['numthreads'] = "{$threads_diff}";
}
}

			$new_stats['numthreads'] = "{$threads_diff}";
}
}

Zeile 2516Zeile 2535
		if($unapprovedthreads_diff > -1)
{
$new_stats['numunapprovedthreads'] = "+{$unapprovedthreads_diff}";

		if($unapprovedthreads_diff > -1)
{
$new_stats['numunapprovedthreads'] = "+{$unapprovedthreads_diff}";

		}
else
{

		}
else
{

			$new_stats['numunapprovedthreads'] = "{$unapprovedthreads_diff}";
}
}

			$new_stats['numunapprovedthreads'] = "{$unapprovedthreads_diff}";
}
}

Zeile 2529Zeile 2548
		if($posts_diff > -1)
{
$new_stats['numposts'] = "+{$posts_diff}";

		if($posts_diff > -1)
{
$new_stats['numposts'] = "+{$posts_diff}";

		}
else
{

		}
else
{

			$new_stats['numposts'] = "{$posts_diff}";
}
}

			$new_stats['numposts'] = "{$posts_diff}";
}
}

Zeile 2543Zeile 2562
		{
$new_stats['numunapprovedposts'] = "+{$unapprovedposts_diff}";
}

		{
$new_stats['numunapprovedposts'] = "+{$unapprovedposts_diff}";
}

		else
{
$new_stats['numunapprovedposts'] = "{$unapprovedposts_diff}";
}

		else
{
$new_stats['numunapprovedposts'] = "{$unapprovedposts_diff}";
}

	}

if(array_key_exists('deletedposts', $update_query))

	}

if(array_key_exists('deletedposts', $update_query))

Zeile 2557Zeile 2576
			$new_stats['numdeletedposts'] = "+{$deletedposts_diff}";
}
else

			$new_stats['numdeletedposts'] = "+{$deletedposts_diff}";
}
else

		{

		{

			$new_stats['numdeletedposts'] = "{$deletedposts_diff}";

			$new_stats['numdeletedposts'] = "{$deletedposts_diff}";

		}

		}

	}

if(array_key_exists('deletedthreads', $update_query))

	}

if(array_key_exists('deletedthreads', $update_query))

Zeile 2568Zeile 2587
		if($deletedthreads_diff > -1)
{
$new_stats['numdeletedthreads'] = "+{$deletedthreads_diff}";

		if($deletedthreads_diff > -1)
{
$new_stats['numdeletedthreads'] = "+{$deletedthreads_diff}";

		}
else

		}
else

		{
$new_stats['numdeletedthreads'] = "{$deletedthreads_diff}";
}

		{
$new_stats['numdeletedthreads'] = "{$deletedthreads_diff}";
}

	}


	}


	if(!empty($new_stats))
{
update_stats($new_stats);

	if(!empty($new_stats))
{
update_stats($new_stats);

	}
}


	}
}


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

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

Zeile 2631Zeile 2650
	$thread = $db->fetch_array($query);

foreach($counters as $counter)

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

foreach($counters as $counter)

	{

	{

		if(array_key_exists($counter, $changes))
{
if(substr($changes[$counter], 0, 2) == "+-")

		if(array_key_exists($counter, $changes))
{
if(substr($changes[$counter], 0, 2) == "+-")

Zeile 2657Zeile 2676
				$update_query[$counter] = 0;
}
}

				$update_query[$counter] = 0;
}
}

	}

	}


$db->free_result($query);


$db->free_result($query);





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

Zeile 2670Zeile 2689

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


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

 *
* @param int $tid The thread ID
*/

 *
* @param int $tid The thread ID
*/

function update_thread_data($tid)
{
global $db;

function update_thread_data($tid)
{
global $db;





	$thread = get_thread($tid);

// If this is a moved thread marker, don't update it - we need it to stay as it is
if(strpos($thread['closed'], 'moved|') !== false)
{
return;

	$thread = get_thread($tid);

// If this is a moved thread marker, don't update it - we need it to stay as it is
if(strpos($thread['closed'], 'moved|') !== false)
{
return;

	}

$query = $db->query("

	}

$query = $db->query("

		SELECT u.uid, u.username, p.username AS postusername, p.dateline
FROM ".TABLE_PREFIX."posts p
LEFT JOIN ".TABLE_PREFIX."users u ON (u.uid=p.uid)

		SELECT u.uid, u.username, p.username AS postusername, p.dateline
FROM ".TABLE_PREFIX."posts p
LEFT JOIN ".TABLE_PREFIX."users u ON (u.uid=p.uid)

Zeile 2750Zeile 2769
function update_user_counters($uid, $changes=array())
{
global $db;

function update_user_counters($uid, $changes=array())
{
global $db;





	$update_query = array();

$counters = array('postnum', 'threadnum');

	$update_query = array();

$counters = array('postnum', 'threadnum');

Zeile 2774Zeile 2793
				if((int)$changes[$counter] != 0)
{
$update_query[$counter] = $user[$counter] + $changes[$counter];

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

				}
}

				}
}

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

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

Zeile 2975Zeile 2994
	{
$str[] = $set[my_rand(0, 61)];
}

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

	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
* @return string The formatted username

 * 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
* @return string The formatted username

 */

 */

function format_name($username, $usergroup, $displaygroup=0)
{
global $groupscache, $cache;

function format_name($username, $usergroup, $displaygroup=0)
{
global $groupscache, $cache;

Zeile 3002Zeile 3021
	if($displaygroup != 0)
{
$usergroup = $displaygroup;

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

	}


	}


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

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

Zeile 3017Zeile 3036

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


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





/**
* Formats an avatar to a certain dimension
*

/**
* Formats an avatar to a certain dimension
*

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))
{
$avatars = array();

	static $avatars;

if(!isset($avatars))
{
$avatars = array();

 
	}

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

	}

if(!$avatar)
{
// Default avatar

	}

if(!$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'];
}


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


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

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





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

$editor_language .= "\n";

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

$editor_language .= "\n";

		}

		}


$editor_language .= "}})(jQuery);";



$editor_language .= "}})(jQuery);";


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

					{

					{

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

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

					}

					}

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

					foreach($smilie_cache as $smilie)
{
$smilie['image'] = str_replace("{theme}", $theme['imgdir'], $smilie['image']);
$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 3367Zeile 3397
			}
foreach($smilie_cache as $smilie)
{

			}
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 3383Zeile 3410

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


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

			{

			{

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

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

			{

			{

				$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

		{
// Decide whether this prefix can be used in our forum

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

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


if(!in_array($fid, $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 = "";

	}

$default_selected = "";

Zeile 3621Zeile 3622
}

/**

}

/**

 * 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 3823Zeile 3826
	{
$reputation_class = "reputation_neutral";
}

	{
$reputation_class = "reputation_neutral";
}

	



	$reputation = my_number_format($reputation);

if($uid != 0)

	$reputation = my_number_format($reputation);

if($uid != 0)

	{

	{

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

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

	}
else
{

	}
else
{

		eval("\$display_reputation = \"".$templates->get("postbit_reputation_formatted")."\";");
}


		eval("\$display_reputation = \"".$templates->get("postbit_reputation_formatted")."\";");
}


Zeile 3854Zeile 3857
		$warning_class = "high_warning";
}
else if($level >= 50)

		$warning_class = "high_warning";
}
else if($level >= 50)

	{

	{

		$warning_class = "moderate_warning";

		$warning_class = "moderate_warning";

	}

	}

	else if($level >= 25)
{
$warning_class = "low_warning";
}
else

	else if($level >= 25)
{
$warning_class = "low_warning";
}
else

	{

	{

		$warning_class = "normal_warning";
}

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

		$warning_class = "normal_warning";
}

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





/**
* Fetch the IP address of the current user.
*

/**
* Fetch the IP address of the current user.
*

Zeile 3884Zeile 3887
	if($mybb->settings['ip_forwarded_check'])
{
$addresses = array();

	if($mybb->settings['ip_forwarded_check'])
{
$addresses = array();





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

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

Zeile 3953Zeile 3956
	}
// Exabyte (1024 Petabytes)
elseif($size >= 1152921504606846976)

	}
// Exabyte (1024 Petabytes)
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 / 1152921504606846976), 2))." ".$lang->size_eb;
}
// Petabyte (1024 Terabytes)
elseif($size >= 1125899906842624)

	{

	{

		$size = my_number_format(round(($size / 1125899906842624), 2))." ".$lang->size_pb;
}
// Terabyte (1024 Gigabytes)

		$size = my_number_format(round(($size / 1125899906842624), 2))." ".$lang->size_pb;
}
// Terabyte (1024 Gigabytes)

Zeile 3975Zeile 3978
	elseif($size >= 1048576)
{
$size = my_number_format(round(($size / 1048576), 2))." ".$lang->size_mb;

	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;

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

	elseif($size == 0)
{
$size = "0 ".$lang->size_bytes;

Zeile 3988Zeile 3991
	else
{
$size = my_number_format($size)." ".$lang->size_bytes;

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

	}

	}


return $size;
}


return $size;
}

Zeile 4022Zeile 4025
	}

return $time;

	}

return $time;

}

}


/**
* Get the attachment icon for a specific file extension


/**
* Get the attachment icon for a specific file extension

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

$name = $lang->unknown;

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

$name = $lang->unknown;

	}

	}


$icon = htmlspecialchars_uni($icon);
eval("\$attachment_icon = \"".$templates->get("attachment_icon")."\";");


$icon = htmlspecialchars_uni($icon);
eval("\$attachment_icon = \"".$templates->get("attachment_icon")."\";");

Zeile 4107Zeile 4110
function get_unviewable_forums($only_readable_threads=false)
{
global $forum_cache, $permissioncache, $mybb;

function get_unviewable_forums($only_readable_threads=false)
{
global $forum_cache, $permissioncache, $mybb;





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

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

	}

	}


if(!is_array($permissioncache))
{


if(!is_array($permissioncache))
{

Zeile 4124Zeile 4127
		if($permissioncache[$forum['fid']])
{
$perms = $permissioncache[$forum['fid']];

		if($permissioncache[$forum['fid']])
{
$perms = $permissioncache[$forum['fid']];

		}
else

		}
else

		{
$perms = $mybb->usergroup;

		{
$perms = $mybb->usergroup;

		}

$pwverified = 1;

		}

$pwverified = 1;


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


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

			}


			}


			$password_forums[$forum['fid']] = $forum['password'];
}
else

			$password_forums[$forum['fid']] = $forum['password'];
}
else

		{

		{

			// Check parents for passwords
$parents = explode(",", $forum['parentlist']);
foreach($parents as $parent)

			// Check parents for passwords
$parents = explode(",", $forum['parentlist']);
foreach($parents as $parent)

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

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

	



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

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

	



	return $unviewableforums;
}


	return $unviewableforums;
}


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 4889Zeile 4885
 * @return string The current URL being accessed
*/
function get_current_location($fields=false, $ignore=array(), $quick=false)

 * @return string The current URL being accessed
*/
function get_current_location($fields=false, $ignore=array(), $quick=false)

{

{

	if(defined("MYBB_LOCATION"))

	if(defined("MYBB_LOCATION"))

	{

	{

		return MYBB_LOCATION;
}

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

		return MYBB_LOCATION;
}

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

	{

	{

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

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

	}

	}

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

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

	{

	{

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

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

	}
else
{

	}
else
{

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

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

	



	if($quick)
{
return $location;

	if($quick)
{
return $location;

Zeile 4958Zeile 4954
		}

if((isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] == "POST") || (isset($_ENV['REQUEST_METHOD']) && $_ENV['REQUEST_METHOD'] == "POST"))

		}

if((isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] == "POST") || (isset($_ENV['REQUEST_METHOD']) && $_ENV['REQUEST_METHOD'] == "POST"))

		{

		{

			$post_array = array('action', 'fid', 'pid', 'tid', 'uid', 'eid');

			$post_array = array('action', 'fid', 'pid', 'tid', 'uid', 'eid');





			foreach($post_array as $var)
{
if(isset($_POST[$var]))
{
$addloc[] = urlencode($var).'='.urlencode($_POST[$var]);

			foreach($post_array as $var)
{
if(isset($_POST[$var]))
{
$addloc[] = urlencode($var).'='.urlencode($_POST[$var]);

				}

				}

			}

if(isset($addloc) && is_array($addloc))
{
if(strpos($location, "?") === false)

			}

if(isset($addloc) && is_array($addloc))
{
if(strpos($location, "?") === false)

				{

				{

					$location .= "?";
}
else

					$location .= "?";
}
else

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

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

		}

		}


return $location;
}
}


return $location;
}
}





/**
* Build a theme selection menu
*

/**
* Build a theme selection menu
*

Zeile 5004Zeile 5000
	global $db, $themeselect, $tcache, $lang, $mybb, $limit, $templates, $num_themes, $themeselect_option;

if($tid == 0)

	global $db, $themeselect, $tcache, $lang, $mybb, $limit, $templates, $num_themes, $themeselect_option;

if($tid == 0)

	{

	{

		$tid = 1;
$num_themes = 0;
$themeselect_option = '';

if(!isset($lang->use_default))

		$tid = 1;
$num_themes = 0;
$themeselect_option = '';

if(!isset($lang->use_default))

		{

		{

			$lang->use_default = $lang->lang_select_default;

			$lang->use_default = $lang->lang_select_default;

		}
}

		}
}


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


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





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

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





	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 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 6201Zeile 6191
			}
}
}

			}
}
}

	



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

return $inactiveforums;

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

return $inactiveforums;

Zeile 6350Zeile 6340
function rebuild_settings()
{
global $db, $mybb;

function rebuild_settings()
{
global $db, $mybb;





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

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

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

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

		}

		}

	}

if(!is_array($words))

	}

if(!is_array($words))

Zeile 6486Zeile 6476
		{
continue;
}

		{
continue;
}





		// Now make PREG compatible
$find = "#(?!<.*?)(".preg_quote($word, "#").")(?![^<>]*?>)#ui";
$replacement = "<span class=\"highlight\" style=\"padding-left: 0px; padding-right: 0px;\">$1</span>";

		// Now make PREG compatible
$find = "#(?!<.*?)(".preg_quote($word, "#").")(?![^<>]*?>)#ui";
$replacement = "<span class=\"highlight\" style=\"padding-left: 0px; padding-right: 0px;\">$1</span>";

Zeile 6499Zeile 6489
/**
* 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)

 *

 *

 * @param int $src Decimal value of a character reference
* @return string|bool
*/

 * @param int $src Decimal value of a character reference
* @return string|bool
*/

Zeile 6508Zeile 6498
	$dest = '';

if($src < 0)

	$dest = '';

if($src < 0)

	{

	{

		return false;
}
elseif($src <= 0x007f)

		return false;
}
elseif($src <= 0x007f)

	{

	{

		$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));
$dest .= chr(0x80 | (($src >> 6) & 0x003f));
$dest .= chr(0x80 | ($src & 0x003f));

	}
elseif($src <= 0xffff)
{
$dest .= chr(0xe0 | ($src >> 12));
$dest .= chr(0x80 | (($src >> 6) & 0x003f));
$dest .= chr(0x80 | ($src & 0x003f));

	}

	}

	elseif($src <= 0x10ffff)
{
$dest .= chr(0xf0 | ($src >> 18));

	elseif($src <= 0x10ffff)
{
$dest .= chr(0xf0 | ($src >> 18));

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

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

		}

		}

	}
// Still here - good username
return false;

	}
// Still here - good username
return false;

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


// Still here - good email
return false;

Zeile 6622Zeile 6612
 * @return boolean True if banned, false if not banned.
*/
function is_banned_ip($ip_address, $update_lastuse=false)

 * @return boolean True if banned, false if not banned.
*/
function is_banned_ip($ip_address, $update_lastuse=false)

{

{

	global $db, $cache;

	global $db, $cache;





	$banned_ips = $cache->read("bannedips");
if(!is_array($banned_ips))

	$banned_ips = $cache->read("bannedips");
if(!is_array($banned_ips))

	{

	{

		return false;
}


		return false;
}


Zeile 6635Zeile 6625
	foreach($banned_ips as $banned_ip)
{
if(!$banned_ip['filter'])

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

		{

		{

			continue;
}


			continue;
}


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 6716Zeile 6708
		"12.75" => $lang->timezone_gmt_1275,
"13" => $lang->timezone_gmt_1300,
"14" => $lang->timezone_gmt_1400

		"12.75" => $lang->timezone_gmt_1275,
"13" => $lang->timezone_gmt_1300,
"14" => $lang->timezone_gmt_1400

	);

	);

	return $timezones;
}


	return $timezones;
}


Zeile 6757Zeile 6749
					$label = str_replace(".", ":", $label);
$label = str_replace(":5", ":30", $label);
$label = str_replace(":75", ":45", $label);

					$label = str_replace(".", ":", $label);
$label = str_replace(":5", ":30", $label);
$label = str_replace(":75", ":45", $label);

				}

				}

				else
{
$label .= ":00";

				else
{
$label .= ":00";

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;

if(!my_validate_url($url, true))
{
return false;
}

$url_components = @parse_url($url);

if(!isset($url_components['scheme']))
{
$url_components['scheme'] = 'https';
}
if(!isset($url_components['port']))
{
$url_components['port'] = $url_components['scheme'] == 'https' ? 443 : 80;
}

if(
!$url_components ||
empty($url_components['host']) ||
(!empty($url_components['scheme']) && !in_array($url_components['scheme'], array('http', 'https'))) ||
(!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;
}

$addresses = get_ip_by_hostname($url_components['host']);
$destination_address = $addresses[0];

if(!empty($config['disallowed_remote_addresses']))
{
foreach($config['disallowed_remote_addresses'] as $disallowed_address)
{
$ip_range = fetch_ip_range($disallowed_address);

$packed_address = my_inet_pton($destination_address);

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


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

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

Zeile 6795Zeile 6842

if(function_exists("curl_init"))
{


if(function_exists("curl_init"))
{

 
		$fetch_header = $max_redirects > 0;


		$ch = curl_init();

		$ch = curl_init();

		curl_setopt($ch, CURLOPT_URL, $url);
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);


































$curlopt = array(
CURLOPT_URL => $url,
CURLOPT_HEADER => $fetch_header,
CURLOPT_TIMEOUT => 10,
CURLOPT_RETURNTRANSFER => 1,
CURLOPT_FOLLOWLOCATION => 0,
);

if($ca_bundle_path = get_ca_bundle_path())
{
$curlopt[CURLOPT_SSL_VERIFYPEER] = 1;
$curlopt[CURLOPT_CAINFO] = $ca_bundle_path;
}
else
{
$curlopt[CURLOPT_SSL_VERIFYPEER] = 0;
}

$curl_version_info = curl_version();
$curl_version = $curl_version_info['version'];

if(version_compare(PHP_VERSION, '7.0.7', '>=') && version_compare($curl_version, '7.49', '>='))
{
// CURLOPT_CONNECT_TO
$curlopt[10243] = array(
$url_components['host'].':'.$url_components['port'].':'.$destination_address
);
}
elseif(version_compare(PHP_VERSION, '5.5', '>=') && version_compare($curl_version, '7.21.3', '>='))
{
// CURLOPT_RESOLVE
$curlopt[10203] = array(
$url_components['host'].':'.$url_components['port'].':'.$destination_address
);
}


		if(!empty($post_body))
{

		if(!empty($post_body))
{

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






























			$curlopt[CURLOPT_POST] = 1;
$curlopt[CURLOPT_POSTFIELDS] = $post_body;
}

curl_setopt_array($ch, $curlopt);

$response = curl_exec($ch);

if($fetch_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;

		}

		}

		$data = curl_exec($ch);



		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['path']))
{
$url_components['path'] = "/";
}
if(isset($url_components['query']))
{
$url_components['path'] .= "?{$url_components['query']}";
}
















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



		$scheme = '';

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

if(function_exists('stream_context_create'))
{
if($url_components['scheme'] == 'https' && $ca_bundle_path = get_ca_bundle_path())
{
$context = stream_context_create(array(
'ssl' => array(
'verify_peer' => true,
'verify_peer_name' => true,
'peer_name' => $url_components['host'],
'cafile' => $ca_bundle_path,
),
));
}
else
{
$context = stream_context_create(array(
'ssl' => array(
'verify_peer' => false,
'verify_peer_name' => false,
),
));

			}

			}

 

$fp = @stream_socket_client($scheme.$destination_address.':'.(int)$url_components['port'], $error_no, $error, 10, STREAM_CLIENT_CONNECT, $context);
}
else
{
$fp = @fsockopen($scheme.$url_components['host'], (int)$url_components['port'], $error_no, $error, 10);

		}


		}


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

 
		@stream_set_timeout($fp, 10);

		@stream_set_timeout($fp, 10);

		if(!$fp)
{
return false;
}

		if(!$fp)
{
return false;
}

		$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";
}
else
{

			$headers[] = "Content-Length: ".strlen($post_body);
$headers[] = "Content-Type: application/x-www-form-urlencoded";
}
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[] = '';


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


Zeile 6878Zeile 7008
		{
return false;
}

		{
return false;
}

 

$data = null;


		while(!feof($fp))

		while(!feof($fp))

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

		{
$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];
}
else if(empty($post_data))
{
return @implode("", @file($url));
}
else
{
return false;
}































































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

/**
* Resolves a hostname into a set of IP addresses.
*
* @param string $hostname The hostname to be resolved
* @return array|bool The resulting IP addresses. False on failure
*/
function get_ip_by_hostname($hostname)
{
$addresses = @gethostbynamel($hostname);

if(!$addresses)
{
$result_set = @dns_get_record($hostname, DNS_A | DNS_AAAA);

if($result_set)
{
$addresses = array_column($result_set, 'ip');
}
else
{
return false;
}
}

return $addresses;
}

/**
* Returns the location of the CA bundle defined in the PHP configuration.
*
* @return string|bool The location of the CA bundle, false if not set
*/
function get_ca_bundle_path()
{
if($path = ini_get('openssl.cafile'))
{
return $path;
}
if($path = ini_get('curl.cainfo'))
{
return $path;
}

return false;

}

/**

}

/**

Zeile 6903Zeile 7098
 * @return boolean True if a super admin, false if not
*/
function is_super_admin($uid)

 * @return boolean True if a super admin, false if not
*/
function is_super_admin($uid)

{

{

	static $super_admins;

	static $super_admins;





	if(!isset($super_admins))
{
global $mybb;

	if(!isset($super_admins))
{
global $mybb;

Zeile 6913Zeile 7108
	}

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

	}

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

	{

	{

		return false;
}
else

		return false;
}
else

Zeile 6934Zeile 7129
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 7069Zeile 7264
		}
}
// Wildcard based IP provided

		}
}
// Wildcard based IP provided

	else
{

	else
{

		$sep = "";
foreach($ip_bits as $piece)
{

		$sep = "";
foreach($ip_bits as $piece)
{

Zeile 7124Zeile 7319

$ban_times['---'] = $lang->permanent;
return $ban_times;


$ban_times['---'] = $lang->permanent;
return $ban_times;

}

}


/**
* Format a ban length in to a UNIX timestamp.


/**
* Format a ban length in to a UNIX timestamp.

Zeile 7138Zeile 7333
	if($stamp == 0)
{
$stamp = TIME_NOW;

	if($stamp == 0)
{
$stamp = TIME_NOW;

	}

	}

	$d = explode('-', $date);
$nowdate = date("H-j-n-Y", $stamp);
$n = explode('-', $nowdate);

	$d = explode('-', $date);
$nowdate = date("H-j-n-Y", $stamp);
$n = explode('-', $nowdate);

Zeile 7150Zeile 7345

/**
* Expire old warnings in the database.


/**
* Expire old warnings in the database.

 *
* @return bool

 *
* @return bool

 */
function expire_warnings()
{

 */
function expire_warnings()
{

Zeile 7177Zeile 7372
{
// Passing $mode as an octal number causes strlen and substr to return incorrect values. Instead pass as a string
if(substr($mode, 0, 1) != '0' || strlen($mode) !== 4)

{
// Passing $mode as an octal number causes strlen and substr to return incorrect values. Instead pass as a string
if(substr($mode, 0, 1) != '0' || strlen($mode) !== 4)

	{
return false;

	{
return false;

	}
$old_umask = umask(0);


	}
$old_umask = umask(0);


Zeile 7395Zeile 7590

/**
* Fetch an binary formatted range for searching IPv4 and IPv6 IP addresses.


/**
* Fetch an binary formatted range for searching IPv4 and IPv6 IP addresses.

 *

 *

 * @param string $ipaddress The IP address to convert to a range
* @return string|array|bool If a full IP address is provided, the in_addr representation, otherwise an array of the upper & lower extremities of the IP. False on failure
*/

 * @param string $ipaddress The IP address to convert to a range
* @return string|array|bool If a full IP address is provided, the in_addr representation, otherwise an array of the upper & lower extremities of the IP. False on failure
*/

Zeile 7548Zeile 7743
	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 7613Zeile 7808
	if($count == 0)
{
if(!empty($checksums))

	if($count == 0)
{
if(!empty($checksums))

		{

		{

			foreach($checksums as $file_path => $hashes)
{
if(in_array(basename($file_path), $ignore))

			foreach($checksums as $file_path => $hashes)
{
if(in_array(basename($file_path), $ignore))

Zeile 7627Zeile 7822

// uh oh
if($count == 0)


// uh oh
if($count == 0)

	{

	{

		return $bad_verify_files;
}
}

		return $bad_verify_files;
}
}

Zeile 7641Zeile 7836
function signed($int)
{
if($int < 0)

function signed($int)
{
if($int < 0)

	{

	{

		return "$int";

		return "$int";

	}

	}

	else
{
return "+$int";

	else
{
return "+$int";

	}
}

/**
* Returns a securely generated seed for PHP's RNG (Random Number Generator)
*
* @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'))

	}
}

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

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









		{

		{

			$output = mcrypt_create_iv($count, MCRYPT_DEV_URANDOM);
}
// Try /dev/urandom
elseif(@is_readable('/dev/urandom') && ($handle = @fopen('/dev/urandom', 'rb')))
{
$output = @fread($handle, $count);
@fclose($handle);

			$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 = @fread($handle, $bytes);
@fclose($handle);
}
}
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'))

		{

		{

			$output = openssl_random_pseudo_bytes($count);









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

		}

		}

		// Try mcrypt
elseif(function_exists('mcrypt_create_iv'))
{
$output = mcrypt_create_iv($count, MCRYPT_RAND);
}
// Try Windows CAPICOM before using our own generator
elseif(class_exists('COM'))



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

		}
}

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



		}
}
else
{
return $output;
}

if(strlen($output) < $bytes)
{

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

		}

		}

	}

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

 




	return $output;










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

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

return $output;
}
else
{
return $output;
}

}

}





/**

/**

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

 * Returns a securely generated seed integer

 *

 *

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

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

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

function secure_seed_rng()

{

{

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

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

	$bytes = PHP_INT_SIZE;

do


	{

	{

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

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

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

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


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

		}
else
{

			return mt_rand($min, $max);


			$elements = unpack('N2', $output);
$output = abs($elements[1] << 32 | $elements[2]);

		}

		}

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



































} while($output > PHP_INT_MAX);

return $output;
}

/**
* Generates a cryptographically secure random number.
*
* @param int $min Optional lowest value to be returned (default: 0)
* @param int $max Optional highest value to be returned (default: PHP_INT_MAX)
*/
function my_rand($min=0, $max=PHP_INT_MAX)
{
// backward compatibility
if($min === null || $max === null || $max < $min)
{
$min = 0;
$max = PHP_INT_MAX;
}

if(version_compare(PHP_VERSION, '7.0', '>='))
{
try
{
$result = random_int($min, $max);
} catch (Exception $e) {
}

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

$seed = secure_seed_rng();

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

}

/**

}

/**

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

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

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

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

		0x0A => 1, // \x{000A}
0x0B => 1, // \x{000B}
0x0D => 1, // \x{000D}

		0x0A => 1, // \x{000A}
0x0B => 1, // \x{000B}
0x0D => 1, // \x{000D}

Zeile 7853Zeile 8105
	{
// 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(!$offset)
{

			// If not, then we must have a "good" character and we don't need to do anymore processing
break;
}

			// If not, then we must have a "good" character and we don't need to do anymore processing
break;
}

Zeile 7881Zeile 8133
	if($charlist)
{
$string = trim($string, $charlist);

	if($charlist)
{
$string = trim($string, $charlist);

	}

	}

	else
{
$string = trim($string);

	else
{
$string = trim($string);

Zeile 7920Zeile 8172
	}

return 0;

	}

return 0;

}

}


/**
* Obtain the version of GD installed.


/**
* Obtain the version of GD installed.

Zeile 7986Zeile 8238
					{
$string .= '?';
continue;

					{
$string .= '?';
continue;

					}
else
{
return false;
}

					}
else
{
return false;
}

				}
elseif($c > 239)
{

				}
elseif($c > 239)
{

Zeile 8058Zeile 8310
		if($allow_mb4)
{
return $input;

		if($allow_mb4)
{
return $input;

		}

		}

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

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

Zeile 8095Zeile 8347
	}

if(!is_array($pm))

	}

if(!is_array($pm))

	{
return false;
}


	{
return false;
}


	if(isset($pm['language']))
{
if($pm['language'] != $mybb->user['language'] && $lang->language_exists($pm['language']))

	if(isset($pm['language']))
{
if($pm['language'] != $mybb->user['language'] && $lang->language_exists($pm['language']))

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

$revert = true;

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

$revert = true;

		}


		}


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

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

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

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

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

 
			}

			}


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






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

$pm[$key] = $lang_string;
}


		if(isset($revert))
{
// Revert language

		if(isset($revert))
{
// Revert language

Zeile 8137Zeile 8391
	}

if(!$pm['subject'] ||!$pm['message'] || !$pm['touid'] || (!$pm['receivepms'] && !$admin_override))

	}

if(!$pm['subject'] ||!$pm['message'] || !$pm['touid'] || (!$pm['receivepms'] && !$admin_override))

	{

	{

		return false;
}

		return false;
}


$lang->load('messages');

 

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



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


Zeile 8207Zeile 8459
	if($pmhandler->validate_pm())
{
$pmhandler->insert_pm();

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

		return true;
}

return false;
}


		return true;
}

return false;
}


/**
* Log a user spam block from StopForumSpam (or other spam service providers...)
*

/**
* Log a user spam block from StopForumSpam (or other spam service providers...)
*

Zeile 8253Zeile 8505
 * Copy a file to the CDN.
*
* @param string $file_path The path to the file to upload to the CDN.

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

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

Zeile 8321Zeile 8573
	}

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

}

}