Vergleich inc/functions.php - 1.8.6 - 1.8.15

  Keine Änderungen   Hinzugefügt   Modifiziert   Entfernt
Zeile 322Zeile 322
/**
* Turn a unix timestamp in to a "friendly" date/time format for the user.
*

/**
* Turn a unix timestamp in to a "friendly" date/time format for the user.
*

 * @param string $format A date format according to PHP's date structure.

 * @param string $format A date format (either relative, normal or PHP's date() structure).

 * @param int $stamp The unix timestamp the date should be generated for.
* @param int|string $offset The offset in hours that should be applied to times. (timezones) Or an empty string to determine that automatically
* @param int $ty Whether or not to use today/yesterday formatting.

 * @param int $stamp The unix timestamp the date should be generated for.
* @param int|string $offset The offset in hours that should be applied to times. (timezones) Or an empty string to determine that automatically
* @param int $ty Whether or not to use today/yesterday formatting.

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 380Zeile 380
	}

$todaysdate = $yesterdaysdate = '';

	}

$todaysdate = $yesterdaysdate = '';

	if($ty && ($format == $mybb->settings['dateformat'] || $format == 'relative'))

	if($ty && ($format == $mybb->settings['dateformat'] || $format == 'relative' || $format == 'normal'))

	{
$_stamp = TIME_NOW;
if($adodb == true)

	{
$_stamp = TIME_NOW;
if($adodb == true)

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

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

 
		$real_date = $real_time = '';
if($adodb == true)
{
$real_date = adodb_date($mybb->settings['dateformat'], $stamp + ($offset * 3600));
$real_time = $mybb->settings['datetimesep'];
$real_time .= adodb_date($mybb->settings['timeformat'], $stamp + ($offset * 3600));
}
else
{
$real_date = gmdate($mybb->settings['dateformat'], $stamp + ($offset * 3600));
$real_time = $mybb->settings['datetimesep'];
$real_time .= gmdate($mybb->settings['timeformat'], $stamp + ($offset * 3600));
}


		if($ty != 2 && abs(TIME_NOW - $stamp) < 3600)
{
$diff = TIME_NOW - $stamp;
$relative = array('prefix' => '', 'minute' => 0, 'plural' => $lang->rel_minutes_plural, 'suffix' => $lang->rel_ago);

		if($ty != 2 && abs(TIME_NOW - $stamp) < 3600)
{
$diff = TIME_NOW - $stamp;
$relative = array('prefix' => '', 'minute' => 0, 'plural' => $lang->rel_minutes_plural, 'suffix' => $lang->rel_ago);


if($diff < 0)
{
$diff = abs($diff);
$relative['suffix'] = '';


if($diff < 0)
{
$diff = abs($diff);
$relative['suffix'] = '';

				$relative['prefix'] = $lang->rel_in;
}


				$relative['prefix'] = $lang->rel_in;
}


Zeile 423Zeile 437
			if($diff <= 60)
{
// Less than a minute

			if($diff <= 60)
{
// Less than a minute

				$relative['prefix'] = $lang->rel_less_than;
}

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

				$relative['prefix'] = $lang->rel_less_than;
}

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

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

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

Zeile 448Zeile 462
				$relative['plural'] = $lang->rel_hours_single;
}


				$relative['plural'] = $lang->rel_hours_single;
}


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

			$date = $lang->sprintf($lang->rel_time, $relative['prefix'], $relative['hour'], $relative['plural'], $relative['suffix'], $real_date, $real_time);

		}
else
{
if($ty)

		}
else
{
if($ty)

			{

			{

				if($todaysdate == $date)
{

				if($todaysdate == $date)
{

					$date = $lang->today;

					$date = $lang->sprintf($lang->today_rel, $real_date);

				}
else if($yesterdaysdate == $date)
{

				}
else if($yesterdaysdate == $date)
{

					$date = $lang->yesterday;

					$date = $lang->sprintf($lang->yesterday_rel, $real_date);

				}
}


				}
}


Zeile 473Zeile 487
			{
$date .= gmdate($mybb->settings['timeformat'], $stamp + ($offset * 3600));
}

			{
$date .= gmdate($mybb->settings['timeformat'], $stamp + ($offset * 3600));
}

 
		}
}
elseif($format == 'normal')
{
// Normal format both date and time
if($ty != 2)
{
if($todaysdate == $date)
{
$date = $lang->today;
}
else if($yesterdaysdate == $date)
{
$date = $lang->yesterday;
}
}

$date .= $mybb->settings['datetimesep'];
if($adodb == true)
{
$date .= adodb_date($mybb->settings['timeformat'], $stamp + ($offset * 3600));
}
else
{
$date .= gmdate($mybb->settings['timeformat'], $stamp + ($offset * 3600));

		}
}
else

		}
}
else

Zeile 598Zeile 637
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 645Zeile 684
	{
cache_forums();
return $forum_cache[$fid]['parentlist'];

	{
cache_forums();
return $forum_cache[$fid]['parentlist'];

	}
}

	}
}


/**
* Build a parent list of a specific forum, suitable for querying


/**
* Build a parent list of a specific forum, suitable for querying

Zeile 672Zeile 711
	{
$builtlist .= "$sep$column='$val'";
$sep = " $joiner ";

	{
$builtlist .= "$sep$column='$val'";
$sep = " $joiner ";

	}

$builtlist .= ")";

	}

$builtlist .= ")";


return $builtlist;
}


return $builtlist;
}

Zeile 688Zeile 727
function cache_forums($force=false)
{
global $forum_cache, $cache;

function cache_forums($force=false)
{
global $forum_cache, $cache;





	if($force == true)
{
$forum_cache = $cache->read("forums", 1);

	if($force == true)
{
$forum_cache = $cache->read("forums", 1);

Zeile 702Zeile 741
		{
$cache->update_forums();
$forum_cache = $cache->read("forums", 1);

		{
$cache->update_forums();
$forum_cache = $cache->read("forums", 1);

		}

		}

	}
return $forum_cache;
}

	}
return $forum_cache;
}

Zeile 716Zeile 755
function get_child_list($fid)
{
static $forums_by_parent;

function get_child_list($fid)
{
static $forums_by_parent;





	$forums = array();
if(!is_array($forums_by_parent))
{

	$forums = array();
if(!is_array($forums_by_parent))
{

Zeile 745Zeile 784
	}
return $forums;
}

	}
return $forums;
}





/**
* Produce a friendly error message page
*

/**
* Produce a friendly error message page
*

Zeile 758Zeile 797

$error = $plugins->run_hooks("error", $error);
if(!$error)


$error = $plugins->run_hooks("error", $error);
if(!$error)

	{

	{

		$error = $lang->unknown_error;

		$error = $lang->unknown_error;

	}

// AJAX error message?
if($mybb->get_input('ajax', MyBB::INPUT_INT))
{
// Send our headers.
@header("Content-type: application/json; charset={$lang->settings['charset']}");

	}

// AJAX error message?
if($mybb->get_input('ajax', MyBB::INPUT_INT))
{
// Send our headers.
@header("Content-type: application/json; charset={$lang->settings['charset']}");

		echo json_encode(array("errors" => array($error)));
exit;
}

		echo json_encode(array("errors" => array($error)));
exit;
}

Zeile 865Zeile 904

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 1005

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

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

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

Zeile 1009Zeile 1048
		$prev = $page-1;
$page_url = fetch_page_url($url, $prev);
eval("\$prevpage = \"".$templates->get("multipage_prevpage")."\";");

		$prev = $page-1;
$page_url = fetch_page_url($url, $prev);
eval("\$prevpage = \"".$templates->get("multipage_prevpage")."\";");

	}


	}


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

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

Zeile 1179Zeile 1218
	if($uid != $mybb->user['uid'])
{
// We've already cached permissions for this user, return them.

	if($uid != $mybb->user['uid'])
{
// We've already cached permissions for this user, return them.

		if($user_cache[$uid]['permissions'])

		if(!empty($user_cache[$uid]['permissions']))

		{
return $user_cache[$uid]['permissions'];
}

// This user was not already cached, fetch their user information.

		{
return $user_cache[$uid]['permissions'];
}

// This user was not already cached, fetch their user information.

		if(!$user_cache[$uid])

		if(empty($user_cache[$uid]))

		{
$user_cache[$uid] = get_user($uid);
}

		{
$user_cache[$uid] = get_user($uid);
}

Zeile 1209Zeile 1248
 * 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 1263

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 1376Zeile 1417
 * @param string $gid A comma separated list of usergroups
* @param array $groupperms Group permissions
* @return array Permissions for this forum

 * @param string $gid A comma separated list of usergroups
* @param array $groupperms Group permissions
* @return array Permissions for this forum

*/

*/

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

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

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

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

			}

			}


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


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

Zeile 1450Zeile 1491

// Figure out if we can reply more than our own threads
if($only_reply_own_threads == 0)


// Figure out if we can reply more than our own threads
if($only_reply_own_threads == 0)

	{

	{

		$current_permissions["canonlyreplyownthreads"] = 0;
}


		$current_permissions["canonlyreplyownthreads"] = 0;
}


Zeile 1495Zeile 1536
		foreach($parents as $parent_id)
{
if($parent_id == $fid || $parent_id == $pid)

		foreach($parents as $parent_id)
{
if($parent_id == $fid || $parent_id == $pid)

			{
continue;
}

			{
continue;
}


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


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

Zeile 1512Zeile 1553
		if(isset($mybb->input['pwverify']) && $pid == 0)
{
if($password === $mybb->get_input('pwverify'))

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

			{

			{

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

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

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

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

			}

			}

			else
{
$showform = false;
}
}

			else
{
$showform = false;
}
}

	}

	}

	else

	else

	{

	{

		$showform = false;
}

if($return)
{
return $showform;

		$showform = false;
}

if($return)
{
return $showform;

	}

	}


if($showform)
{


if($showform)
{

Zeile 1557Zeile 1598
			output_page($pwform);
}
exit;

			output_page($pwform);
}
exit;

	}

	}

}

/**

}

/**

Zeile 1572Zeile 1613
{
global $mybb, $cache, $db;
static $modpermscache;

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





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

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

	}


	}


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

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

	}


	}


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

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

	}


	}


	if(!$parentslist)

	if(!$parentslist)

	{

	{

		$parentslist = explode(',', get_parent_list($fid));
}


		$parentslist = explode(',', get_parent_list($fid));
}


Zeile 1602Zeile 1643
	if(!empty($user['additionalgroups']))
{
$extra_groups = explode(",", $user['additionalgroups']);

	if(!empty($user['additionalgroups']))
{
$extra_groups = explode(",", $user['additionalgroups']);





		foreach($extra_groups as $extra_group)

		foreach($extra_groups as $extra_group)

		{

		{

			$groups[] = $extra_group;
}
}

			$groups[] = $extra_group;
}
}





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

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

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

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

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

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

		}

		}


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


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

Zeile 1655Zeile 1696
			foreach($perm as $action => $value)
{
if(strpos($action, "can") === false)

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

				{

				{

					continue;
}


					continue;
}


Zeile 1668Zeile 1709

return $perms;
}


return $perms;
}





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

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

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

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


if($uid == 0)


if($uid == 0)

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

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

	}

	}


if($uid == 0)
{


if($uid == 0)
{

Zeile 1693Zeile 1734

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


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

	{

	{

		if($fid)
{
$forumpermissions = forum_permissions($fid);

		if($fid)
{
$forumpermissions = forum_permissions($fid);

Zeile 1714Zeile 1755
			{
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 1840
		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 1870
	}

if($expires == -1)

	}

if($expires == -1)

	{

	{

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

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

Zeile 1839Zeile 1892
	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 1907
	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 2203
	{
mb_internal_encoding($mbIntEnc);
}

	{
mb_internal_encoding($mbIntEnc);
}

	



	return $out;
}


	return $out;
}


Zeile 2154Zeile 2212
 * 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
* @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)

Zeile 2165Zeile 2223
	{
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 2251
		{
$out .= _safe_serialize($k) . _safe_serialize($v);
}

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

		



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

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

	}

	}


// safe_serialize cannot my_serialize resources or objects
return false;


// safe_serialize cannot my_serialize resources or objects
return false;

Zeile 2212Zeile 2270
{
// 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))

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

		$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 2353Zeile 2411
		}
$stats = $cache->read("stats");
$changes = $stats_changes;

		}
$stats = $cache->read("stats");
$changes = $stats_changes;

	}

	}

	else

	else

	{

	{

		$stats = $stats_changes;
}

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

		$stats = $stats_changes;
}

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

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

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

			{
$changes[$counter] = substr($changes[$counter], 1);
}

			{
$changes[$counter] = substr($changes[$counter], 1);
}

Zeile 2391Zeile 2449
				}
}
else

				}
}
else

			{

			{

				$new_stats[$counter] = $changes[$counter];
// Less than 0? That's bad
if($new_stats[$counter] < 0)

				$new_stats[$counter] = $changes[$counter];
// Less than 0? That's bad
if($new_stats[$counter] < 0)

Zeile 2403Zeile 2461
	}

if(!$force)

	}

if(!$force)

	{

	{

		$stats_changes = array_merge($stats, $new_stats); // Overwrite changed values
return;
}

		$stats_changes = array_merge($stats, $new_stats); // Overwrite changed values
return;
}

Zeile 2414Zeile 2472
		$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 2490
	// 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 2517
	// 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);
}
// Adding or subtracting from previous value?


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) == "-")
{
if((int)$changes[$counter] != 0)

			if(substr($changes[$counter], 0, 1) == "+" || substr($changes[$counter], 0, 1) == "-")
{
if((int)$changes[$counter] != 0)

Zeile 2524Zeile 2582
	}

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

	}

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

	{

	{

		$posts_diff = $update_query['posts'] - $forum['posts'];
if($posts_diff > -1)
{

		$posts_diff = $update_query['posts'] - $forum['posts'];
if($posts_diff > -1)
{

Zeile 2566Zeile 2624
	{
$deletedthreads_diff = $update_query['deletedthreads'] - $forum['deletedthreads'];
if($deletedthreads_diff > -1)

	{
$deletedthreads_diff = $update_query['deletedthreads'] - $forum['deletedthreads'];
if($deletedthreads_diff > -1)

		{

		{

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

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

		}

		}

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

		else
{
$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 2800Zeile 2858

/**
* Deletes a thread from the database


/**
* Deletes a thread from the database

 *

 *

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

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

Zeile 2975Zeile 3033
	{
$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
*

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

Zeile 2991Zeile 3049
 * @return string The formatted username
*/
function format_name($username, $usergroup, $displaygroup=0)

 * @return string The formatted username
*/
function format_name($username, $usergroup, $displaygroup=0)

{
global $groupscache, $cache;

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

{
global $groupscache, $cache, $plugins;










	if($displaygroup != 0)



	static $formattednames = array();

if(!isset($formattednames[$username]))

	{

	{

		$usergroup = $displaygroup;
}

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

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







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

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





	$format = stripslashes($format);

		$format = "{username}";





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






















		if(isset($groupscache[$usergroup]))
{
$ugroup = $groupscache[$usergroup];

if(strpos($ugroup['namestyle'], "{username}") !== false)
{
$format = $ugroup['namestyle'];
}
}

$format = stripslashes($format);

$parameters = compact('username', 'usergroup', 'displaygroup', 'format');

$parameters = $plugins->run_hooks('format_name', $parameters);

$format = $parameters['format'];

$formattednames[$username] = str_replace("{username}", $username, $format);
}

return $formattednames[$username];

}

/**

}

/**

Zeile 3028Zeile 3102
 */
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))

	{

	{

		$avatars = array();
}

		$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 3214Zeile 3299
			$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))
{
$smilie_cache = $cache->read("smilies");

				if(!$smiliecache)
{
if(!isset($smilie_cache) || !is_array($smilie_cache))
{
$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 3341

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 3452
			}
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 3465

$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 3496
					$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 3512
			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 3583
}

/**

}

/**

 * 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 3603
	$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 3546Zeile 3615
		{
// Decide whether this prefix can be used in our forum
$forums = explode(",", $prefix['forums']);

		{
// Decide whether this prefix can be used in our forum
$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


if(is_member($prefix['groups']) || $prefix['pid'] == $previous_pid)














		{

		{

			// This prefix is for anybody to use...

			// The current user can use this prefix

			$prefixes[$prefix['pid']] = $prefix;
}
}

if(empty($prefixes))
{

			$prefixes[$prefix['pid']] = $prefix;
}
}

if(empty($prefixes))
{

		return false;

		return '';

	}

	}





	$prefixselect = $prefixselect_prefix = '';

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

	$prefixselect = $prefixselect_prefix = '';

if($multiple == 1)
{
$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')

	{

	{

		$default_selected = " selected=\"selected\"";
}

foreach($prefixes as $prefix)

		$default_selected = " selected=\"selected\"";
}

foreach($prefixes as $prefix)

	{

	{

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

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

Zeile 3609Zeile 3665
	}

if($multiple != 0)

	}

if($multiple != 0)

	{

	{

		eval("\$prefixselect = \"".$templates->get("post_prefixselect_multiple")."\";");
}
else

		eval("\$prefixselect = \"".$templates->get("post_prefixselect_multiple")."\";");
}
else

Zeile 3621Zeile 3677
}

/**

}

/**

 * 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 3692
	$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

	}

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

Zeile 3643Zeile 3701
	foreach($prefix_cache as $prefix)
{
if($prefix['forums'] != "-1")

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

		{

		{

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


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


Zeile 3662Zeile 3720

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 3836
	{
$pid = (int)$data['pid'];
unset($data['pid']);

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

 
	}

$tids = array();
if(isset($data['tids']))
{
$tids = (array)$data['tids'];
unset($data['tids']);

	}

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

	}

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

Zeile 3796Zeile 3861
		"data" => $db->escape_string($data),
"ipaddress" => $db->escape_binary($session->packedip)
);

		"data" => $db->escape_string($data),
"ipaddress" => $db->escape_binary($session->packedip)
);

	$db->insert_query("moderatorlog", $sql_array);


















if($tids)
{
$multiple_sql_array = array();

foreach($tids as $tid)
{
$sql_array['tid'] = (int)$tid;
$multiple_sql_array[] = $sql_array;
}

$db->insert_query_multiple("moderatorlog", $multiple_sql_array);
}
else
{
$db->insert_query("moderatorlog", $sql_array);
}

}

/**
* Get the formatted reputation for a user.

}

/**
* Get the formatted reputation for a user.

 *

 *

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

Zeile 3823Zeile 3904
	{
$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")."\";");
}
else
{
eval("\$display_reputation = \"".$templates->get("postbit_reputation_formatted")."\";");

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

	}

	}


return $display_reputation;
}


return $display_reputation;
}

Zeile 3864Zeile 3945
	else
{
$warning_class = "normal_warning";

	else
{
$warning_class = "normal_warning";

	}

	}


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


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 3879Zeile 3960
{
global $mybb, $plugins;


{
global $mybb, $plugins;


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


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


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

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

Zeile 3892Zeile 3973
		elseif(isset($_SERVER['HTTP_X_REAL_IP']))
{
$addresses = explode(',', strtolower($_SERVER['HTTP_X_REAL_IP']));

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

		}

		}


if(is_array($addresses))
{


if(is_array($addresses))
{

Zeile 3906Zeile 3987
					break;
}
}

					break;
}
}

		}
}

		}
}


if(!$ip)
{


if(!$ip)
{

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

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

	}

	}


return $ip;
}


return $ip;
}

Zeile 3950Zeile 4031
	elseif($size >= 1180591620717411303424)
{
$size = my_number_format(round(($size / 1180591620717411303424), 2))." ".$lang->size_zb;

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

	}

	}

	// Exabyte (1024 Petabytes)
elseif($size >= 1152921504606846976)
{

	// Exabyte (1024 Petabytes)
elseif($size >= 1152921504606846976)
{

Zeile 3958Zeile 4039
	}
// Petabyte (1024 Terabytes)
elseif($size >= 1125899906842624)

	}
// Petabyte (1024 Terabytes)
elseif($size >= 1125899906842624)

	{

	{

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

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

	}

	}

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

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

Zeile 3980Zeile 4061
	elseif($size >= 1024)
{
$size = my_number_format(round(($size / 1024), 2))." ".$lang->size_kb;

	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 4022Zeile 4103
	}

return $time;

	}

return $time;

}


}


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

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

Zeile 4037Zeile 4118
	if(!$attachtypes)
{
$attachtypes = $cache->read("attachtypes");

	if(!$attachtypes)
{
$attachtypes = $cache->read("attachtypes");

	}

	}


$ext = my_strtolower($ext);



$ext = my_strtolower($ext);


Zeile 4052Zeile 4133
				$attach_icons_schemes[$ext] = $attachtypes[$ext]['icon'];
}
elseif(defined("IN_ADMINCP"))

				$attach_icons_schemes[$ext] = $attachtypes[$ext]['icon'];
}
elseif(defined("IN_ADMINCP"))

			{

			{

				$attach_icons_schemes[$ext] = str_replace("{theme}", "", $attachtypes[$ext]['icon']);
if(my_substr($attach_icons_schemes[$ext], 0, 1) != "/")
{

				$attach_icons_schemes[$ext] = str_replace("{theme}", "", $attachtypes[$ext]['icon']);
if(my_substr($attach_icons_schemes[$ext], 0, 1) != "/")
{

Zeile 4081Zeile 4162
		if(defined("IN_ADMINCP"))
{
$theme['imgdir'] = "../images";

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

		}

		}

		else if(defined("IN_PORTAL"))
{
global $change_dir;
$theme['imgdir'] = "{$change_dir}/images";
}

		else if(defined("IN_PORTAL"))
{
global $change_dir;
$theme['imgdir'] = "{$change_dir}/images";
}





		$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")."\";");
return $attachment_icon;

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

}


}


/**
* Get a list of the unviewable forums for the current user
*

/**
* Get a list of the unviewable forums for the current user
*

Zeile 4111Zeile 4192
	if(!is_array($forum_cache))
{
cache_forums();

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

	}

	}


if(!is_array($permissioncache))
{


if(!is_array($permissioncache))
{

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

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

			{

			{

				$pwverified = 0;
}


				$pwverified = 0;
}


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

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

	



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

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

	



	return $unviewableforums;
}


	return $unviewableforums;
}


Zeile 4330Zeile 4411
				else
{
$navbits[$navsize]['url'] = get_forum_link($forumnav['fid']);

				else
{
$navbits[$navsize]['url'] = get_forum_link($forumnav['fid']);

				}
}
}

				}
}
}

	}

return 1;

	}

return 1;

Zeile 4571Zeile 4652
	switch($type)
{
case "posts":

	switch($type)
{
case "posts":

			if(is_array($id))
{
$rids = implode($id, "','");

			if(is_array($id))
{
$rids = implode($id, "','");

				$rids = "'0','$rids'";
$db->update_query("reportedcontent", array('reportstatus' => 1), "id IN($rids) AND reportstatus='0' AND (type = 'post' OR type = '')");

				$rids = "'0','$rids'";
$db->update_query("reportedcontent", array('reportstatus' => 1), "id IN($rids) AND reportstatus='0' AND (type = 'post' OR type = '')");

			}
break;

			}
break;

		case "post":
$db->update_query("reportedcontent", array('reportstatus' => 1), "id='$id' AND reportstatus='0' AND (type = 'post' OR type = '')");
break;

		case "post":
$db->update_query("reportedcontent", array('reportstatus' => 1), "id='$id' AND reportstatus='0' AND (type = 'post' OR type = '')");
break;

Zeile 4588Zeile 4669
				$rids = "'0','$rids'";
$db->update_query("reportedcontent", array('reportstatus' => 1), "id2 IN($rids) AND reportstatus='0' AND (type = 'post' OR type = '')");
}

				$rids = "'0','$rids'";
$db->update_query("reportedcontent", array('reportstatus' => 1), "id2 IN($rids) AND reportstatus='0' AND (type = 'post' OR type = '')");
}

			break;

			break;

		case "thread":
$db->update_query("reportedcontent", array('reportstatus' => 1), "id2='$id' AND reportstatus='0' AND (type = 'post' OR type = '')");
break;

		case "thread":
$db->update_query("reportedcontent", array('reportstatus' => 1), "id2='$id' AND reportstatus='0' AND (type = 'post' OR type = '')");
break;

Zeile 4672Zeile 4753
	$stamp %= $msecs;
$seconds = $stamp;


	$stamp %= $msecs;
$seconds = $stamp;


	if($years == 1)
{
$nicetime['years'] = "1".$lang_year;
}
else if($years > 1)
{
$nicetime['years'] = $years.$lang_years;
}

if($months == 1)

	// Prevent gross over accuracy ($options parameter will override these)
if($years > 0)









	{

	{

		$nicetime['months'] = "1".$lang_month;






		$options = array_merge(array(
'days' => false,
'hours' => false,
'minutes' => false,
'seconds' => false
), $options);

	}

	}

	else if($months > 1)

	elseif($months > 0)

	{

	{

		$nicetime['months'] = $months.$lang_months;





		$options = array_merge(array(
'hours' => false,
'minutes' => false,
'seconds' => false
), $options);

	}

	}


if($weeks == 1)
{
$nicetime['weeks'] = "1".$lang_week;
}
else if($weeks > 1)

	elseif($weeks > 0)






	{

	{

		$nicetime['weeks'] = $weeks.$lang_weeks;














































		$options = array_merge(array(
'minutes' => false,
'seconds' => false
), $options);
}
elseif($days > 0)
{
$options = array_merge(array(
'seconds' => false
), $options);
}

if(!isset($options['years']) || $options['years'] !== false)
{
if($years == 1)
{
$nicetime['years'] = "1".$lang_year;
}
else if($years > 1)
{
$nicetime['years'] = $years.$lang_years;
}
}

if(!isset($options['months']) || $options['months'] !== false)
{
if($months == 1)
{
$nicetime['months'] = "1".$lang_month;
}
else if($months > 1)
{
$nicetime['months'] = $months.$lang_months;
}
}

if(!isset($options['weeks']) || $options['weeks'] !== false)
{
if($weeks == 1)
{
$nicetime['weeks'] = "1".$lang_week;
}
else if($weeks > 1)
{
$nicetime['weeks'] = $weeks.$lang_weeks;
}

	}


	}


	if($days == 1)

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

	{

	{

		$nicetime['days'] = "1".$lang_day;
}
else if($days > 1)
{
$nicetime['days'] = $days.$lang_days;




		if($days == 1)
{
$nicetime['days'] = "1".$lang_day;
}
else if($days > 1)
{
$nicetime['days'] = $days.$lang_days;
}

	}

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

	}

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

Zeile 4837Zeile 4962
{
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'].",";
$donegroup = array();

	$groupslist = $comma = '';
$usergroups = $user['additionalgroups'].",";
$donegroup = array();





	$groups = explode(",", $user['additionalgroups']);

if(is_array($groups))

	$groups = explode(",", $user['additionalgroups']);

if(is_array($groups))

Zeile 4857Zeile 4975
		foreach($groups as $gid)
{
if(trim($gid) != "" && $leavegroup != $gid && empty($donegroup[$gid]))

		foreach($groups as $gid)
{
if(trim($gid) != "" && $leavegroup != $gid && empty($donegroup[$gid]))

			{

			{

				$groupslist .= $comma.$gid;
$comma = ",";
$donegroup[$gid] = 1;

				$groupslist .= $comma.$gid;
$comma = ",";
$donegroup[$gid] = 1;

Zeile 4898Zeile 5016
	if(!empty($_SERVER['SCRIPT_NAME']))
{
$location = htmlspecialchars_uni($_SERVER['SCRIPT_NAME']);

	if(!empty($_SERVER['SCRIPT_NAME']))
{
$location = htmlspecialchars_uni($_SERVER['SCRIPT_NAME']);

	}

	}

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

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

	{

	{

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

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

	}

	}

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

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

	}

	}

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

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

	{

	{

		$location = htmlspecialchars_uni($_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 4939Zeile 5057
				{
continue;
}

				{
continue;
}





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

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

Zeile 4949Zeile 5067
	else
{
if(isset($_SERVER['QUERY_STRING']))

	else
{
if(isset($_SERVER['QUERY_STRING']))

		{

		{

			$location .= "?".htmlspecialchars_uni($_SERVER['QUERY_STRING']);
}
else if(isset($_ENV['QUERY_STRING']))

			$location .= "?".htmlspecialchars_uni($_SERVER['QUERY_STRING']);
}
else if(isset($_ENV['QUERY_STRING']))

		{

		{

			$location .= "?".htmlspecialchars_uni($_ENV['QUERY_STRING']);
}

			$location .= "?".htmlspecialchars_uni($_ENV['QUERY_STRING']);
}





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

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

Zeile 4966Zeile 5084
				if(isset($_POST[$var]))
{
$addloc[] = urlencode($var).'='.urlencode($_POST[$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 .= "?";

					$location .= "?";

				}

				}

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

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

			}
}


			}
}


		return $location;
}
}

		return $location;
}
}

Zeile 5026Zeile 5144
	}

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 5062Zeile 5173
	}

if($tid == 1 && ($num_themes > 1 || $count_override == true))

	}

if($tid == 1 && ($num_themes > 1 || $count_override == true))

	{

	{

		if($footer == true)

		if($footer == true)

		{

		{

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

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

		}

		}

		else
{
eval("\$themeselect = \"".$templates->get("usercp_themeselector")."\";");
}

return $themeselect;

		else
{
eval("\$themeselect = \"".$templates->get("usercp_themeselector")."\";");
}

return $themeselect;

	}

	}

	else
{
return false;

	else
{
return false;

	}

	}

}

}





/**
* Get the theme data of a theme id.
*

/**
* Get the theme data of a theme id.
*

Zeile 5093Zeile 5204
	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;

Zeile 5183Zeile 5294
	static $use_iconv;

if(!isset($charset))

	static $use_iconv;

if(!isset($charset))

	{

	{

		$charset = my_strtolower($lang->settings['charset']);

		$charset = my_strtolower($lang->settings['charset']);

	}

	}


if($charset == "utf-8")
{
return $str;


if($charset == "utf-8")
{
return $str;

	}


	}


	if(!isset($use_iconv))
{
$use_iconv = function_exists("iconv");
}

if(!isset($use_mb))

	if(!isset($use_iconv))
{
$use_iconv = function_exists("iconv");
}

if(!isset($use_mb))

	{

	{

		$use_mb = function_exists("mb_convert_encoding");
}


		$use_mb = function_exists("mb_convert_encoding");
}


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

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

		}

		}

		if($use_iconv)

		if($use_iconv)

		{

		{

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

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

		}

		}

		else

		else

		{

		{

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

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

Zeile 5228Zeile 5339
		if($to)
{
return utf8_encode($str);

		if($to)
{
return utf8_encode($str);

		}

		}

		else
{
return utf8_decode($str);

		else
{
return utf8_decode($str);

Zeile 5305Zeile 5416
		31,
30,
31,

		31,
30,
31,

		30,
31,
31,
30,

		30,
31,
31,
30,

		31,
30,
31

		31,
30,
31

Zeile 5318Zeile 5429
/**
* DEPRECATED! Please use mktime()!
* Formats a birthday appropriately

/**
* DEPRECATED! Please use mktime()!
* Formats a birthday appropriately

 *

 *

 * @deprecated
* @param string $display The PHP date format string
* @param int $bm The month of the birthday

 * @deprecated
* @param string $display The PHP date format string
* @param int $bm The month of the birthday

Zeile 5370Zeile 5481
		'F',
'l',
'M',

		'F',
'l',
'M',

	);


	);


	$html = array(
'&#109;',
'&#110;',

	$html = array(
'&#109;',
'&#110;',

Zeile 5384Zeile 5495
		'&#70;',
'&#108;',
'&#77;',

		'&#70;',
'&#108;',
'&#77;',

	);


	);


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


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


Zeile 5426Zeile 5537
	if(!$bday[2])
{
return;

	if(!$bday[2])
{
return;

	}

list($day, $month, $year) = explode("-", my_date("j-n-Y", TIME_NOW, 0, 0));

	}

list($day, $month, $year) = explode("-", my_date("j-n-Y", TIME_NOW, 0, 0));


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



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


Zeile 5680Zeile 5791
function unhtmlentities($string)
{
// Replace numeric entities

function unhtmlentities($string)
{
// Replace numeric entities

	$string = preg_replace_callback('~&#x([0-9a-f]+);~i', create_function('$matches', 'return unichr(hexdec($matches[1]));'), $string);
$string = preg_replace_callback('~&#([0-9]+);~', create_function('$matches', 'return unichr($matches[1]);'), $string);

	$string = preg_replace_callback('~&#x([0-9a-f]+);~i', 'unichr_callback1', $string);
$string = preg_replace_callback('~&#([0-9]+);~', 'unichr_callback2', $string);


// Replace literal entities
$trans_tbl = get_html_translation_table(HTML_ENTITIES);


// Replace literal entities
$trans_tbl = get_html_translation_table(HTML_ENTITIES);

Zeile 5721Zeile 5832
	{
return false;
}

	{
return false;
}

 
}

/**
* Returns any ascii to it's character (utf-8 safe).
*
* @param array $matches Matches.
* @return string|bool The characterized ascii. False on failure
*/
function unichr_callback1($matches)
{
return unichr(hexdec($matches[1]));
}

/**
* Returns any ascii to it's character (utf-8 safe).
*
* @param array $matches Matches.
* @return string|bool The characterized ascii. False on failure
*/
function unichr_callback2($matches)
{
return unichr($matches[1]);

}

/**

}

/**

Zeile 5728Zeile 5861
 *
* @param array $event The event data array.
* @return string The link to the event poster.

 *
* @param array $event The event data array.
* @return string The link to the event poster.

 */

 */

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 5741Zeile 5875
 *
* @param array $event The event data array.
* @return string The event date.

 *
* @param array $event The event data array.
* @return string The event date.

 */

 */

function get_event_date($event)
{
global $mybb;

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

function get_event_date($event)
{
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 5760Zeile 5894
 * @return string The url to the profile.
*/
function get_profile_link($uid=0)

 * @return string The url to the profile.
*/
function get_profile_link($uid=0)

{

{

	$link = str_replace("{uid}", $uid, PROFILE_URL);
return htmlspecialchars_uni($link);
}

	$link = str_replace("{uid}", $uid, PROFILE_URL);
return htmlspecialchars_uni($link);
}

Zeile 5787Zeile 5921
 * @return string The complete profile link.
*/
function build_profile_link($username="", $uid=0, $target="", $onclick="")

 * @return string The complete profile link.
*/
function build_profile_link($username="", $uid=0, $target="", $onclick="")

{

{

	global $mybb, $lang;

if(!$username && $uid == 0)

	global $mybb, $lang;

if(!$username && $uid == 0)

	{

	{

		// Return Guest phrase for no UID, no guest nickname

		// Return Guest phrase for no UID, no guest nickname

		return $lang->guest;
}

		return htmlspecialchars_uni($lang->guest);
}

	elseif($uid == 0)

	elseif($uid == 0)

	{

	{

		// Return the guest's nickname if user is a guest but has a nickname
return $username;

		// Return the guest's nickname if user is a guest but has a nickname
return $username;

	}
else
{

	}
else
{

		// Build the profile link for the registered user
if(!empty($target))
{
$target = " target=\"{$target}\"";

		// Build the profile link for the registered user
if(!empty($target))
{
$target = " target=\"{$target}\"";

		}


		}


		if(!empty($onclick))
{
$onclick = " onclick=\"{$onclick}\"";
}

return "<a href=\"{$mybb->settings['bburl']}/".get_profile_link($uid)."\"{$target}{$onclick}>{$username}</a>";

		if(!empty($onclick))
{
$onclick = " onclick=\"{$onclick}\"";
}

return "<a href=\"{$mybb->settings['bburl']}/".get_profile_link($uid)."\"{$target}{$onclick}>{$username}</a>";

	}
}

	}
}


/**
* Build the forum link.


/**
* Build the forum link.

Zeile 5829Zeile 5963
	if($page > 0)
{
$link = str_replace("{fid}", $fid, FORUM_URL_PAGED);

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

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

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

		return htmlspecialchars_uni($link);
}
else

		return htmlspecialchars_uni($link);
}
else

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

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

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

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

		{
$link = THREAD_URL_PAGED;
}

		{
$link = THREAD_URL_PAGED;
}

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

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

		}
else

		}
else

		{
$link = THREAD_URL;
}

		{
$link = THREAD_URL;
}

Zeile 5924Zeile 6058
 * @return string The URL of the calendar
*/
function get_calendar_link($calendar, $year=0, $month=0, $day=0)

 * @return string The URL of the calendar
*/
function get_calendar_link($calendar, $year=0, $month=0, $day=0)

{

{

	if($day > 0)
{
$link = str_replace("{month}", $month, CALENDAR_URL_DAY);
$link = str_replace("{year}", $year, $link);
$link = str_replace("{day}", $day, $link);

	if($day > 0)
{
$link = str_replace("{month}", $month, CALENDAR_URL_DAY);
$link = str_replace("{year}", $year, $link);
$link = str_replace("{day}", $day, $link);

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

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

		return htmlspecialchars_uni($link);
}
else if($month > 0)

		return htmlspecialchars_uni($link);
}
else if($month > 0)

Zeile 5938Zeile 6072
		$link = str_replace("{month}", $month, CALENDAR_URL_MONTH);
$link = str_replace("{year}", $year, $link);
$link = str_replace("{calendar}", $calendar, $link);

		$link = str_replace("{month}", $month, CALENDAR_URL_MONTH);
$link = str_replace("{year}", $year, $link);
$link = str_replace("{calendar}", $calendar, $link);

		return htmlspecialchars_uni($link);
}

		return htmlspecialchars_uni($link);
}

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

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

	{

	{

	}*/
else
{
$link = str_replace("{calendar}", $calendar, CALENDAR_URL);
return htmlspecialchars_uni($link);

	}*/
else
{
$link = str_replace("{calendar}", $calendar, CALENDAR_URL);
return htmlspecialchars_uni($link);

	}
}

/**

	}
}

/**

 * Build the link to a specified week on the calendar
*
* @param int $calendar The ID of the calendar

 * Build the link to a specified week on the calendar
*
* @param int $calendar The ID of the calendar

Zeile 5979Zeile 6113
{
global $mybb, $db;
static $user_cache;

{
global $mybb, $db;
static $user_cache;


$uid = (int)$uid;



$uid = (int)$uid;


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

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

Zeile 6201Zeile 6335
			}
}
}

			}
}
}

	



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

return $inactiveforums;

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

return $inactiveforums;

Zeile 6309Zeile 6443
 */
function validate_email_format($email)
{

 */
function validate_email_format($email)
{

	if(strpos($email, ' ') !== false)
{
return false;
}
// Valid local characters for email addresses: http://www.remote.org/jochen/mail/info/chars.html
return preg_match("/^[a-zA-Z0-9&*+\-_.{}~^\?=\/]+@[a-zA-Z0-9-]+\.([a-zA-Z0-9-]+\.)*[a-zA-Z0-9-]{2,}$/si", $email);

	return filter_var($email, FILTER_VALIDATE_EMAIL) !== false;






}

/**

}

/**

Zeile 6330Zeile 6459

$uid_string = "";
if($uid)


$uid_string = "";
if($uid)

	{

	{

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

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

	}

	}

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

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

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

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

	}


	}


	return false;
}

/**
* Rebuilds settings.php

	return false;
}

/**
* Rebuilds settings.php

 *
*/

 *
*/

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


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


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

$options = array(
"order_by" => "title",
"order_dir" => "ASC"
);
$query = $db->simple_select("settings", "value, name", "", $options);

	$query = $db->simple_select("settings", "value, name", "", array(
'order_by' => 'title',
'order_dir' => 'ASC',
));















	$settings = null;

	$settings = '';

	while($setting = $db->fetch_array($query))
{
$mybb->settings[$setting['name']] = $setting['value'];

	while($setting = $db->fetch_array($query))
{
$mybb->settings[$setting['name']] = $setting['value'];

Zeile 6375Zeile 6494
	}

$settings = "<"."?php\n/*********************************\ \n DO NOT EDIT THIS FILE, PLEASE USE\n THE SETTINGS EDITOR\n\*********************************/\n\n$settings\n";

	}

$settings = "<"."?php\n/*********************************\ \n DO NOT EDIT THIS FILE, PLEASE USE\n THE SETTINGS EDITOR\n\*********************************/\n\n$settings\n";

	$file = @fopen(MYBB_ROOT."inc/settings.php", $mode);
@fwrite($file, $settings);
@fclose($file);


file_put_contents(MYBB_ROOT.'inc/settings.php', $settings, LOCK_EX);



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


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

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

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

	}

	}


if(is_array($terms))
{


if(is_array($terms))
{

Zeile 6466Zeile 6584
	}

if(!is_array($words))

	}

if(!is_array($words))

	{
return false;
}

	{
return false;
}


// Sort the word array by length. Largest terms go first and work their way down to the smallest term.
// This resolves problems like "test tes" where "tes" will be highlighted first, then "test" can't be highlighted because of the changed html


// Sort the word array by length. Largest terms go first and work their way down to the smallest term.
// This resolves problems like "test tes" where "tes" will be highlighted first, then "test" can't be highlighted because of the changed html

	usort($words, create_function('$a,$b', 'return strlen($b) - strlen($a);'));

	usort($words, 'build_highlight_array_sort');


// Loop through our words to build the PREG compatible strings
foreach($words as $word)


// Loop through our words to build the PREG compatible strings
foreach($words as $word)

Zeile 6494Zeile 6612
	}

return $highlight_cache;

	}

return $highlight_cache;

 
}

/**
* Sort the word array by length. Largest terms go first and work their way down to the smallest term.
*
* @param string $a First word.
* @param string $b Second word.
* @return integer Result of comparison function.
*/
function build_highlight_array_sort($a, $b)
{
return strlen($b) - strlen($a);

}

/**

}

/**

Zeile 6506Zeile 6636
function dec_to_utf8($src)
{
$dest = '';

function dec_to_utf8($src)
{
$dest = '';





	if($src < 0)
{
return false;

	if($src < 0)
{
return false;

Zeile 6540Zeile 6670
	}

return $dest;

	}

return $dest;

}

/**

}

/**

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

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

Zeile 6706Zeile 6836
		"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 6761Zeile 6893
				else
{
$label .= ":00";

				else
{
$label .= ":00";

				}

				}

			}
$time_in_zone = my_date($mybb->settings['timeformat'], TIME_NOW, $timezone);
$label = $lang->sprintf($lang->timezone_gmt_short, $label." ", $time_in_zone);

			}
$time_in_zone = my_date($mybb->settings['timeformat'], TIME_NOW, $timezone);
$label = $lang->sprintf($lang->timezone_gmt_short, $label." ", $time_in_zone);

Zeile 6779Zeile 6911
 *
* @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 6982

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

		if(!isset($url_components['path']))










		{

		{

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

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

		}

		}

		if($url['query'])

		if(isset($url_components['query']))

		{

		{

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

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

		}

$scheme = '';


		}

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






























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


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

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

Zeile 6850Zeile 7120
		$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
{
$headers[] = "GET {$url['path']} HTTP/1.0";
}

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





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

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

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

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

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

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

		}
else

		}
else

		{
// If we have no post body, we need to add an empty element to make sure we've got \r\n\r\n before the (non-existent) body starts
$headers[] = '';

		{
// If we have no post body, we need to add an empty element to make sure we've got \r\n\r\n before the (non-existent) body starts
$headers[] = '';

Zeile 6875Zeile 7145

$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);
}
fclose($fp);

		while(!feof($fp))
{
$data .= fgets($fp, 12800);
}
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));
}

















$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

	else

	{

	{

		return false;
}

		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 6915Zeile 7250
	if(my_strpos(",{$super_admins},", ",{$uid},") === false)
{
return false;

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

	}

	}

	else
{
return true;

	else
{
return true;

Zeile 6934Zeile 7269
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 7883
	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 7589Zeile 7924
				{
$filename = $path."/".$file;
$handle = fopen($filename, "rb");

				{
$filename = $path."/".$file;
$handle = fopen($filename, "rb");

					$contents = '';

					$hashingContext = hash_init('sha512');

					while(!feof($handle))
{

					while(!feof($handle))
{

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

						hash_update($hashingContext, fread($handle, 8192));

					}
fclose($handle);


					}
fclose($handle);


					$md5 = md5($contents);

					$checksum = hash_final($hashingContext);


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


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

					if(!in_array($md5, $checksums[$file_path]))

					if(!in_array($checksum, $checksums[$file_path]))

					{
$bad_verify_files[] = array("status" => "changed", "path" => $file_path);
}

					{
$bad_verify_files[] = array("status" => "changed", "path" => $file_path);
}

Zeile 7651Zeile 7986
}

/**

}

/**

 * 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 8179
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 8245
	{
// 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 8277
	else
{
$string = trim($string);

	else
{
$string = trim($string);

	}

	}


return $string;
}


return $string;
}

Zeile 7904Zeile 8296
	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 8324
	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 8478
 * @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 8497
		{
// 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 8534
	{
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 8559
	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 8588
		"savecopy" => 0,
"readreceipt" => 0
);

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





	$pm['saveasdraft'] = 0;

// Admin override

	$pm['saveasdraft'] = 0;

// Admin override

Zeile 8225Zeile 8617
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 8636
		'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 8656

$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 8713
	}

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.
* @param bool $allow_local Whether or not the url could be pointing to local networks.
*
* @return bool Whether this is a valid url.
*/
function my_validate_url($url, $relative_path=false, $allow_local=false)
{
if($allow_local)
{
$regex = '_^(?:(?:https?|ftp)://)(?:\S+(?::\S*)?@)?(?:(?:[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]))|(?:localhost|(?:(?:[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';
}
else
{
$regex = '_^(?:(?: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';
}

if($relative_path && my_substr($url, 0, 1) == '/' || preg_match($regex, $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);
}

/**
* Escapes a RFC 4180-compliant CSV string.
* Based on https://github.com/Automattic/camptix/blob/f80725094440bf09861383b8f11e96c177c45789/camptix.php#L2867
*
* @param string $string The string to be escaped
* @param boolean $escape_active_content Whether or not to escape active content trigger characters
* @return string The escaped string
*/
function my_escape_csv($string, $escape_active_content=true)
{
if($escape_active_content)
{
$active_content_triggers = array('=', '+', '-', '@');
$delimiters = array(',', ';', ':', '|', '^', "\n", "\t", " ");

$first_character = mb_substr($string, 0, 1);

if(
in_array($first_character, $active_content_triggers, true) ||
in_array($first_character, $delimiters, true)
)
{
$string = "'".$string;
}

foreach($delimiters as $delimiter)
{
foreach($active_content_triggers as $trigger)
{
$string = str_replace($delimiter.$trigger, $delimiter."'".$trigger, $string);
}
}
}

$string = str_replace('"', '""', $string);

return $string;

}

}