Vergleich inc/functions.php - 1.8.22 - 1.8.23

  Keine Änderungen   Hinzugefügt   Modifiziert   Entfernt
Zeile 224Zeile 224
		// Loop through and run them all
foreach($shutdown_queries as $query)
{

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

			$db->query($query);

			$db->write_query($query);

		}
}


		}
}


Zeile 610Zeile 610
}

/**

}

/**

 * Generates a unique code for POST requests to prevent XSS/CSRF attacks


 * Generates a code for POST requests to prevent XSS/CSRF attacks.
* Unique for each user or guest session and rotated every 6 hours.

 *

 *

 
 * @param int $rotation_shift Adjustment of the rotation number to generate a past/future code

 * @return string The generated code
*/

 * @return string The generated code
*/

function generate_post_check()

function generate_post_check($rotation_shift=0)

{
global $mybb, $session;

{
global $mybb, $session;

 

$rotation_interval = 6 * 3600;
$rotation = floor(TIME_NOW / $rotation_interval) + $rotation_shift;

$seed = $rotation;


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

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

	{
return md5($mybb->user['loginkey'].$mybb->user['salt'].$mybb->user['regdate']);
}
// Guests get a special string

	{
$seed .= $mybb->user['loginkey'].$mybb->user['salt'].$mybb->user['regdate'];
}


	else
{

	else
{

		return md5($session->sid.$mybb->config['database']['username'].$mybb->settings['internal']['encryption_key']);

		$seed .= $session->sid;

	}

	}

 

$seed .= $mybb->settings['internal']['encryption_key'];

return md5($seed);

}

/**

}

/**

 * Verifies a POST check code is valid, if not shows an error (silently returns false on silent parameter)

 * Verifies a POST check code is valid (i.e. generated using a rotation number from the past 24 hours)

 *
* @param string $code The incoming POST check code

 *
* @param string $code The incoming POST check code

 * @param boolean $silent Silent mode or not (silent mode will not show the error to the user but returns false)
* @return bool

 * @param boolean $silent Don't show an error to the user
* @return bool|void Result boolean if $silent is true, otherwise shows an error to the user

 */
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 &&
generate_post_check(-1) !== $code &&
generate_post_check(-2) !== $code &&
generate_post_check(-3) !== $code
)

	{
if($silent == true)
{

	{
if($silent == true)
{

Zeile 664Zeile 680

/**
* Return a parent list for the specified forum.


/**
* Return a parent list for the specified forum.

 *

 *

 * @param int $fid The forum id to get the parent list for.
* @return string The comma-separated parent list.
*/

 * @param int $fid The forum id to get the parent list for.
* @return string The comma-separated parent list.
*/

Zeile 678Zeile 694
		return $forumarraycache[$fid]['parentlist'];
}
elseif($forum_cache[$fid])

		return $forumarraycache[$fid]['parentlist'];
}
elseif($forum_cache[$fid])

	{

	{

		return $forum_cache[$fid]['parentlist'];
}
else

		return $forum_cache[$fid]['parentlist'];
}
else

Zeile 733Zeile 749
	{
$forum_cache = $cache->read("forums", 1);
return $forum_cache;

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

	}


	}


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

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

Zeile 745Zeile 761
		}
}
return $forum_cache;

		}
}
return $forum_cache;

}

/**

}

/**

 * Generate an array of all child and descendant forums for a specific forum.
*
* @param int $fid The forum ID

 * Generate an array of all child and descendant forums for a specific forum.
*
* @param int $fid The forum ID

Zeile 775Zeile 791
	}

foreach($forums_by_parent[$fid] as $forum)

	}

foreach($forums_by_parent[$fid] as $forum)

	{
$forums[] = $forum['fid'];

	{
$forums[] = (int)$forum['fid'];

		$children = get_child_list($forum['fid']);
if(is_array($children))
{

		$children = get_child_list($forum['fid']);
if(is_array($children))
{

Zeile 844Zeile 860
	}

if(!is_array($errors))

	}

if(!is_array($errors))

	{

	{

		$errors = array($errors);
}


		$errors = array($errors);
}


Zeile 870Zeile 886
	foreach($errors as $error)
{
eval("\$errorlist .= \"".$templates->get("error_inline_item")."\";");

	foreach($errors as $error)
{
eval("\$errorlist .= \"".$templates->get("error_inline_item")."\";");

	}

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

	}

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


return $errors;
}


return $errors;
}





/**
* Presents the user with a "no permission" page
*/

/**
* Presents the user with a "no permission" page
*/

Zeile 886Zeile 902

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


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





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

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

Zeile 955Zeile 971
	$redirect_args = array('url' => &$url, 'message' => &$message, 'title' => &$title);

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

	$redirect_args = array('url' => &$url, 'message' => &$message, 'title' => &$title);

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





	if($mybb->get_input('ajax', MyBB::INPUT_INT))
{
// Send our headers.

	if($mybb->get_input('ajax', MyBB::INPUT_INT))
{
// Send our headers.

Zeile 1031Zeile 1047
 */
function multipage($count, $perpage, $page, $url, $breadcrumb=false)
{

 */
function multipage($count, $perpage, $page, $url, $breadcrumb=false)
{

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

	global $theme, $templates, $lang, $mybb, $plugins;


if($count <= $perpage)
{
return '';


if($count <= $perpage)
{
return '';

	}

$page = (int)$page;











	}

$args = array(
'count' => &$count,
'perpage' => &$perpage,
'page' => &$page,
'url' => &$url,
'breadcrumb' => &$breadcrumb,
);
$plugins->run_hooks('multipage', $args);

$page = (int)$page;


	$url = str_replace("&amp;", "&", $url);
$url = htmlspecialchars_uni($url);


	$url = str_replace("&amp;", "&", $url);
$url = htmlspecialchars_uni($url);


Zeile 1066Zeile 1091
	{
$from = 1;
$to = $from+$mybb->settings['maxmultipagelinks']-1;

	{
$from = 1;
$to = $from+$mybb->settings['maxmultipagelinks']-1;

	}

	}


if($to > $pages)
{


if($to > $pages)
{

Zeile 1287Zeile 1312
		}

foreach($groupscache[$gid] as $perm => $access)

		}

foreach($groupscache[$gid] as $perm => $access)

		{

		{

			if(!in_array($perm, $grouppermignore))
{
if(isset($usergroup[$perm]))

			if(!in_array($perm, $grouppermignore))
{
if(isset($usergroup[$perm]))

				{

				{

					$permbit = $usergroup[$perm];

					$permbit = $usergroup[$perm];

				}

				}

				else
{
$permbit = "";

				else
{
$permbit = "";

Zeile 1301Zeile 1326

// 0 represents unlimited for numerical group permissions (i.e. private message limit) so take that into account.
if(in_array($perm, $groupzerogreater) && ($access == 0 || $permbit === 0))


// 0 represents unlimited for numerical group permissions (i.e. private message limit) so take that into account.
if(in_array($perm, $groupzerogreater) && ($access == 0 || $permbit === 0))

				{

				{

					$usergroup[$perm] = 0;
continue;

					$usergroup[$perm] = 0;
continue;

				}


				}


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

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

Zeile 1315Zeile 1340
	}

return $usergroup;

	}

return $usergroup;

}

}


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


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

Zeile 1383Zeile 1408
	}

if(!is_array($forum_cache))

	}

if(!is_array($forum_cache))

	{
$forum_cache = cache_forums();


	{
$forum_cache = cache_forums();


		if(!$forum_cache)
{
return false;
}

		if(!$forum_cache)
{
return false;
}

	}

	}


if(!is_array($fpermcache))
{


if(!is_array($fpermcache))
{

Zeile 1398Zeile 1423
	}

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

	}

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

	{

	{

		if(empty($cached_forum_permissions_permissions[$gid][$fid]))

		if(empty($cached_forum_permissions_permissions[$gid][$fid]))

		{

		{

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

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

Zeile 1412Zeile 1437
			foreach($forum_cache as $forum)
{
$cached_forum_permissions[$gid][$forum['fid']] = fetch_forum_permissions($forum['fid'], $gid, $groupperms);

			foreach($forum_cache as $forum)
{
$cached_forum_permissions[$gid][$forum['fid']] = fetch_forum_permissions($forum['fid'], $gid, $groupperms);

			}

			}

		}
return $cached_forum_permissions[$gid];
}

		}
return $cached_forum_permissions[$gid];
}

Zeile 1481Zeile 1506
			}

if($level_permissions["canview"] && empty($level_permissions["canonlyviewownthreads"]))

			}

if($level_permissions["canview"] && empty($level_permissions["canonlyviewownthreads"]))

			{

			{

				$only_view_own_threads = 0;
}


				$only_view_own_threads = 0;
}


Zeile 1509Zeile 1534
		$current_permissions = $groupperms;
}
return $current_permissions;

		$current_permissions = $groupperms;
}
return $current_permissions;

 
}

/**
* Check whether password for given forum was validated for the current user
*
* @param array $forum The forum data
* @param bool $ignore_empty Whether to treat forum password configured as an empty string as validated
* @param bool $check_parents Whether to check parent forums using `parentlist`
* @return bool
*/
function forum_password_validated($forum, $ignore_empty=false, $check_parents=false)
{
global $mybb, $forum_cache;

if($check_parents && isset($forum['parentlist']))
{
if(!is_array($forum_cache))
{
$forum_cache = cache_forums();
if(!$forum_cache)
{
return false;
}
}

$parents = explode(',', $forum['parentlist']);
rsort($parents);

foreach($parents as $parent_id)
{
if($parent_id != $forum['fid'] && !forum_password_validated($forum_cache[$parent_id], true))
{
return false;
}
}
}

return ($ignore_empty && $forum['password'] === '') || (
isset($mybb->cookies['forumpass'][$forum['fid']]) &&
my_hash_equals(
md5($mybb->user['uid'].$forum['password']),
$mybb->cookies['forumpass'][$forum['fid']]
)
);

}

/**

}

/**

Zeile 1549Zeile 1618
				continue;
}


				continue;
}


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

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

			{
check_forum_password($parent_id, $fid);
}
}
}


			{
check_forum_password($parent_id, $fid);
}
}
}


	if(!empty($forum_cache[$fid]['password']))

	if($forum_cache[$fid]['password'] !== '')

	{

	{

		$password = $forum_cache[$fid]['password'];

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

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

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

			if(my_hash_equals($forum_cache[$fid]['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 1574Zeile 1642
		}
else
{

		}
else
{

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

			if(!forum_password_validated($forum_cache[$fid]))

			{
$showform = true;
}

			{
$showform = true;
}

Zeile 1803Zeile 1871
			}
}
}

			}
}
}

 
}

/**
* Get an array of fids that the forum moderator has access to.
* Do not use for administraotrs or global moderators as they moderate any forum and the function will return false.
*
* @param int $uid The user ID (0 assumes current user)
* @return array|bool an array of the fids the user has moderator access to or bool if called incorrectly.
*/
function get_moderated_fids($uid=0)
{
global $mybb, $cache;

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

if($uid == 0)
{
return array();
}

$user_perms = user_permissions($uid);

if($user_perms['issupermod'] == 1)
{
return false;
}

$fids = array();

$modcache = $cache->read('moderators');
if(!empty($modcache))
{
$groups = explode(',', $user_perms['all_usergroups']);

foreach($modcache as $fid => $forum)
{
if(isset($forum['users'][$uid]) && $forum['users'][$uid]['mid'])
{
$fids[] = $fid;
continue;
}

foreach($groups as $group)
{
if(trim($group) != '' && isset($forum['usergroups'][$group]))
{
$fids[] = $fid;
}
}
}
}

return $fids;

}

/**

}

/**

Zeile 2122Zeile 2246
				}

// missing array value

				}

// missing array value

				return false;


				return false;


			case 2: // in array, expecting end of array or a key
if($type == '}')
{

			case 2: // in array, expecting end of array or a key
if($type == '}')
{

Zeile 2331Zeile 2455
		if(!is_numeric($serverload[0]))
{
if($mybb->safemode)

		if(!is_numeric($serverload[0]))
{
if($mybb->safemode)

			{
return $lang->unknown;
}


			{
return $lang->unknown;
}


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

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

Zeile 2359Zeile 2483
			{
return $lang->unknown;
}

			{
return $lang->unknown;
}

		}
}
else

		}
}
else

	{
return $lang->unknown;
}

	{
return $lang->unknown;
}

Zeile 2401Zeile 2525
	static $stats_changes;

if(empty($stats_changes))

	static $stats_changes;

if(empty($stats_changes))

	{

	{

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

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

Zeile 2438Zeile 2562

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


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

	foreach($counters as $counter)
{
if(array_key_exists($counter, $changes))

	foreach($counters as $counter)
{
if(array_key_exists($counter, $changes))

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

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

Zeile 2649Zeile 2773
		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);

Zeile 4265Zeile 4389
		$permissioncache = forum_permissions();
}


		$permissioncache = forum_permissions();
}


	$password_forums = $unviewable = array();

	$unviewable = array();

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

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

Zeile 4279Zeile 4403

$pwverified = 1;



$pwverified = 1;


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



if(!forum_password_validated($forum, true))

		{

		{

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

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

			$pwverified = 0;






		}
else
{

		}
else
{

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

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

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

				if(!forum_password_validated($forum_cache[$parent], true))

				{
$pwverified = 0;

				{
$pwverified = 0;

 
					break;

				}
}
}

				}
}
}

Zeile 4696Zeile 4817

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


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

		header("Expires: Sat, 1 Jan 2000 01:00:00 GMT");
header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
header("Cache-Control: no-cache, must-revalidate");
header("Pragma: no-cache");

		header("Cache-Control: no-cache, private");




	}
}


	}
}


Zeile 5027Zeile 5145
	global $db, $mybb, $cache;

$user = get_user($uid);

	global $db, $mybb, $cache;

$user = get_user($uid);

 

if($user['usergroup'] == $leavegroup)
{
return false;
}


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


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

Zeile 5066Zeile 5189
 * Get the current location taking in to account different web serves and systems
*
* @param boolean $fields True to return as "hidden" fields

 * Get the current location taking in to account different web serves and systems
*
* @param boolean $fields True to return as "hidden" fields

 * @param array $ignore Array of fields to ignore if first argument is true

 * @param array $ignore Array of fields to ignore for returning "hidden" fields or URL being accessed

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

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

 * @return string The current URL being accessed

 * @return string|array The current URL being accessed or form data if $fields is true

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

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

 
	global $mybb;


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

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

Zeile 5099Zeile 5224
	}

if($quick)

	}

if($quick)

	{

	{

		return $location;

		return $location;

 
	}

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

	}

if($fields == true)
{

	}

if($fields == true)
{

		global $mybb;

if(!is_array($ignore))
{
$ignore = array($ignore);
}

 

$form_html = '';
if(!empty($mybb->input))


$form_html = '';
if(!empty($mybb->input))

Zeile 5130Zeile 5254
	}
else
{

	}
else
{

 
		$parameters = array();


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

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

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

		{
$current_query_string = $_SERVER['QUERY_STRING'];
}

		else if(isset($_ENV['QUERY_STRING']))

		else if(isset($_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');














		{
$current_query_string = $_ENV['QUERY_STRING'];
} else
{
$current_query_string = '';
}

parse_str($current_query_string, $current_parameters);

foreach($current_parameters as $name => $value)
{
if(!in_array($name, $ignore))
{
$parameters[$name] = $value;
}
}

if($mybb->request_method === 'post')
{
$post_array = array('action', 'fid', 'pid', 'tid', 'uid', 'eid');


foreach($post_array as $var)
{


foreach($post_array as $var)
{

				if(isset($_POST[$var]))

				if(isset($_POST[$var]) && !in_array($var, $ignore))

				{

				{

					$addloc[] = urlencode($var).'='.urlencode($_POST[$var]);

					$parameters[$var] = $_POST[$var];

				}
}

				}
}


if(isset($addloc) && is_array($addloc))
{
if(strpos($location, "?") === false)
{
$location .= "?";
}
else
{
$location .= "&amp;";
}
$location .= implode("&amp;", $addloc);
}

		}

if(!empty($parameters))
{
$location .= '?'.http_build_query($parameters, '', '&amp;');









		}

return $location;

		}

return $location;

Zeile 5200Zeile 5331
	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 5208Zeile 5339
	}

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

	}

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

	{

	{

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

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

Zeile 5218Zeile 5349
				if($theme['tid'] == $selected)
{
$sel = " selected=\"selected\"";

				if($theme['tid'] == $selected)
{
$sel = " selected=\"selected\"";

				}

				}


if($theme['pid'] != 0)
{


if($theme['pid'] != 0)
{

Zeile 5248Zeile 5379
		}

return $themeselect;

		}

return $themeselect;

	}

	}

	else
{
return false;

	else
{
return false;

Zeile 5290Zeile 5421
	}

return $s_theme;

	}

return $s_theme;

}


}


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

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

Zeile 5624Zeile 5755

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


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

		FROM ".TABLE_PREFIX."posts p

		FROM ".TABLE_PREFIX."posts p

		LEFT JOIN ".TABLE_PREFIX."users u ON (u.uid=p.uid)
WHERE p.tid='$tid'
ORDER BY p.dateline ASC

		LEFT JOIN ".TABLE_PREFIX."users u ON (u.uid=p.uid)
WHERE p.tid='$tid'
ORDER BY p.dateline ASC

Zeile 5643Zeile 5774
		'username' => $firstpost['username'],
'uid' => (int)$firstpost['uid'],
'dateline' => (int)$firstpost['dateline']

		'username' => $firstpost['username'],
'uid' => (int)$firstpost['uid'],
'dateline' => (int)$firstpost['dateline']

	);
$db->update_query("threads", $update_array, "tid='{$tid}'");

	);
$db->update_query("threads", $update_array, "tid='{$tid}'");

}

/**

}

/**

Zeile 5705Zeile 5836
 * @return int The length of the string.
*/
function my_strlen($string)

 * @return int The length of the string.
*/
function my_strlen($string)

{
global $lang;


{
global $lang;


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

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

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

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

Zeile 5753Zeile 5884
		if($length != null)
{
$cut_string = mb_substr($string, $start, $length);

		if($length != null)
{
$cut_string = mb_substr($string, $start, $length);

		}
else
{

		}
else
{

			$cut_string = mb_substr($string, $start);
}
}

			$cut_string = mb_substr($string, $start);
}
}

Zeile 5787Zeile 5918
function my_strtolower($string)
{
if(function_exists("mb_strtolower"))

function my_strtolower($string)
{
if(function_exists("mb_strtolower"))

	{

	{

		$string = mb_strtolower($string);

		$string = mb_strtolower($string);

	}




























	}
else
{
$string = strtolower($string);
}

return $string;
}

/**
* Finds a needle in a haystack and returns it position, mb strings accounted for, case insensitive
*
* @param string $haystack String to look in (haystack)
* @param string $needle What to look for (needle)
* @param int $offset (optional) How much to offset
* @return int|bool false on needle not found, integer position if found
*/
function my_stripos($haystack, $needle, $offset=0)
{
if($needle == '')
{
return false;
}

if(function_exists("mb_stripos"))
{
$position = mb_stripos($haystack, $needle, $offset);
}

	else
{

	else
{

		$string = strtolower($string);

		$position = stripos($haystack, $needle, $offset);

	}


	}


	return $string;

	return $position;

}

/**

}

/**

Zeile 5834Zeile 5992
function my_strtoupper($string)
{
if(function_exists("mb_strtoupper"))

function my_strtoupper($string)
{
if(function_exists("mb_strtoupper"))

	{

	{

		$string = mb_strtoupper($string);
}
else

		$string = mb_strtoupper($string);
}
else

Zeile 5862Zeile 6020
	$trans_tbl = array_flip($trans_tbl);

return strtr($string, $trans_tbl);

	$trans_tbl = array_flip($trans_tbl);

return strtr($string, $trans_tbl);

}

/**
* Returns any ascii to it's character (utf-8 safe).

}

/**
* Returns any ascii to it's character (utf-8 safe).

 *
* @param int $c The ascii to characterize.
* @return string|bool The characterized ascii. False on failure

 *
* @param int $c The ascii to characterize.
* @return string|bool The characterized ascii. False on failure

Zeile 5895Zeile 6053
	{
return false;
}

	{
return false;
}

}


}


/**
* Returns any ascii to it's character (utf-8 safe).
*

/**
* Returns any ascii to it's character (utf-8 safe).
*

Zeile 5959Zeile 6117
function get_profile_link($uid=0)
{
$link = str_replace("{uid}", $uid, PROFILE_URL);

function get_profile_link($uid=0)
{
$link = str_replace("{uid}", $uid, PROFILE_URL);

	return htmlspecialchars_uni($link);
}

	return htmlspecialchars_uni($link);
}


/**
* Get the announcement link.


/**
* Get the announcement link.

Zeile 6269Zeile 6427
	global $cache;
static $forum_cache;


	global $cache;
static $forum_cache;


	if(!isset($forum_cache) || is_array($forum_cache))

	if(!isset($forum_cache) || !is_array($forum_cache))

	{
$forum_cache = $cache->read("forums");
}

	{
$forum_cache = $cache->read("forums");
}

Zeile 6340Zeile 6498
 * @return array|bool The database row of the post. False on failure
*/
function get_post($pid)

 * @return array|bool The database row of the post. False on failure
*/
function get_post($pid)

{

{

	global $db;
static $post_cache;


	global $db;
static $post_cache;


Zeile 6356Zeile 6514
		$post = $db->fetch_array($query);

if($post)

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

if($post)

		{

		{

			$post_cache[$pid] = $post;
return $post;
}

			$post_cache[$pid] = $post;
return $post;
}

Zeile 6372Zeile 6530
 * Get inactivate forums.
*
* @return string The comma separated values of the inactivate forum.

 * Get inactivate forums.
*
* @return string The comma separated values of the inactivate forum.

 */

 */

function get_inactive_forums()
{
global $forum_cache, $cache;

function get_inactive_forums()
{
global $forum_cache, $cache;

Zeile 6403Zeile 6561

return $inactiveforums;
}


return $inactiveforums;
}





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

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

Zeile 6451Zeile 6609
		if($attempts['loginlockoutexpiry'] == 0)
{
$attempts['loginlockoutexpiry'] = $now + ((int)$mybb->settings['failedlogintime'] * 60);

		if($attempts['loginlockoutexpiry'] == 0)
{
$attempts['loginlockoutexpiry'] = $now + ((int)$mybb->settings['failedlogintime'] * 60);





			// Add a cookie lockout. This is used to prevent access to the login page immediately.
// A deep lockout is issued if he tries to login into a locked out account
my_setcookie('lockoutexpiry', $attempts['loginlockoutexpiry']);

			// Add a cookie lockout. This is used to prevent access to the login page immediately.
// A deep lockout is issued if he tries to login into a locked out account
my_setcookie('lockoutexpiry', $attempts['loginlockoutexpiry']);





			$db->update_query("users", array(
"loginlockoutexpiry" => $attempts['loginlockoutexpiry']
), "uid='{$uid}'");

			$db->update_query("users", array(
"loginlockoutexpiry" => $attempts['loginlockoutexpiry']
), "uid='{$uid}'");

		}

		}


if(empty($mybb->cookies['lockoutexpiry']))
{
$failedtime = $attempts['loginlockoutexpiry'];
}
else


if(empty($mybb->cookies['lockoutexpiry']))
{
$failedtime = $attempts['loginlockoutexpiry'];
}
else

		{

		{

			$failedtime = $mybb->cookies['lockoutexpiry'];
}

			$failedtime = $mybb->cookies['lockoutexpiry'];
}





		// Are we still locked out?
if($attempts['loginlockoutexpiry'] > $now)
{

		// Are we still locked out?
if($attempts['loginlockoutexpiry'] > $now)
{

Zeile 6479Zeile 6637
				$hoursleft = floor($secsleft / 3600);
$minsleft = floor(($secsleft / 60) % 60);
$secsleft = floor($secsleft % 60);

				$hoursleft = floor($secsleft / 3600);
$minsleft = floor(($secsleft / 60) % 60);
$secsleft = floor($secsleft % 60);





				error($lang->sprintf($lang->failed_login_wait, $hoursleft, $minsleft, $secsleft));

				error($lang->sprintf($lang->failed_login_wait, $hoursleft, $minsleft, $secsleft));

			}


			}


			return false;
}
// Unlock if enough time has passed

			return false;
}
// Unlock if enough time has passed

Zeile 6498Zeile 6656

// Wipe the cookie, no matter if a guest or a member
my_unsetcookie('lockoutexpiry');


// Wipe the cookie, no matter if a guest or a member
my_unsetcookie('lockoutexpiry');





			return 0;
}
}

			return 0;
}
}





	// User can attempt another login
return $attempts['loginattempts'];
}

	// User can attempt another login
return $attempts['loginattempts'];
}

Zeile 6514Zeile 6672
 * @return boolean True when valid, false when invalid.
*/
function validate_email_format($email)

 * @return boolean True when valid, false when invalid.
*/
function validate_email_format($email)

{

{

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


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


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

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





		$setting['name'] = addcslashes($setting['name'], "\\'");
$setting['value'] = addcslashes($setting['value'], '\\"$');
$settings .= "\$settings['{$setting['name']}'] = \"{$setting['value']}\";\n";

		$setting['name'] = addcslashes($setting['name'], "\\'");
$setting['value'] = addcslashes($setting['value'], '\\"$');
$settings .= "\$settings['{$setting['name']}'] = \"{$setting['value']}\";\n";

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

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

	}

	}


// Strip out any characters that shouldn't be included
$bad_characters = array(


// Strip out any characters that shouldn't be included
$bad_characters = array(

Zeile 6654Zeile 6812
				}
$words[] = trim($word);
}

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

		}
}

		}
}


if(!is_array($words))
{


if(!is_array($words))
{

Zeile 6686Zeile 6844
	}

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

/**
* Sort the word array by length. Largest terms go first and work their way down to the smallest term.
*

Zeile 6718Zeile 6876
	elseif($src <= 0x007f)
{
$dest .= chr($src);

	elseif($src <= 0x007f)
{
$dest .= chr($src);

	}

	}

	elseif($src <= 0x07ff)
{
$dest .= chr(0xc0 | ($src >> 6));

	elseif($src <= 0x07ff)
{
$dest .= chr(0xc0 | ($src >> 6));

Zeile 6971Zeile 7129
			}
$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);

		}

		}


eval("\$timezone_option .= \"".$templates->get("usercp_options_timezone_option")."\";");
}


eval("\$timezone_option .= \"".$templates->get("usercp_options_timezone_option")."\";");
}

Zeile 7175Zeile 7333
					'ssl' => array(
'verify_peer' => false,
'verify_peer_name' => false,

					'ssl' => array(
'verify_peer' => false,
'verify_peer_name' => false,

 
						'peer_name' => $url_components['host'],

					),
));
}

					),
));
}

Zeile 7184Zeile 7343
		else
{
$fp = @fsockopen($scheme.$url_components['host'], (int)$url_components['port'], $error_no, $error, 10);

		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)

		{
return false;
}

		{
return false;
}

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

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

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

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

		}


		}


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

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

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

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

			return false;
}

$data = null;

while(!feof($fp))
{

			return false;
}

$data = null;

while(!feof($fp))
{

			$data .= fgets($fp, 12800);
}
fclose($fp);


			$data .= fgets($fp, 12800);
}
fclose($fp);


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


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


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

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

Zeile 7240Zeile 7399
		if($max_redirects > 0 && (strstr($status_line, ' 301 ') || strstr($status_line, ' 302 ')))
{
preg_match('/^Location:(.*?)(?:\n|$)/im', $header, $matches);

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





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

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

		}

		}

		else
{
$data = $body;
}

return $data;

		else
{
$data = $body;
}

return $data;

	}
else
{
return false;
}

	}
else
{
return false;
}

}

}





/**
* Resolves a hostname into a set of IP addresses.
*

/**
* Resolves a hostname into a set of IP addresses.
*

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

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





		if($result_set)
{
$addresses = array_column($result_set, 'ip');

		if($result_set)
{
$addresses = array_column($result_set, 'ip');

Zeile 7303Zeile 7462
	}

return false;

	}

return false;

}

}


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


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

Zeile 7319Zeile 7478
	{
global $mybb;
$super_admins = str_replace(" ", "", $mybb->config['super_admins']);

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

	}

	}


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


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

Zeile 7350Zeile 7509
	}

if($user == false)

	}

if($user == false)

	{

	{

		$user = $mybb->user;
}
else if(!is_array($user))

		$user = $mybb->user;
}
else if(!is_array($user))

Zeile 7729Zeile 7888
		 * @license     LGPL - http://www.gnu.org/licenses/lgpl.html
* @copyright 2004-2007 Aidan Lister <aidan@php.net>, Arpad Ray <arpad@php.net>
* @link http://php.net/inet_pton

		 * @license     LGPL - http://www.gnu.org/licenses/lgpl.html
* @copyright 2004-2007 Aidan Lister <aidan@php.net>, Arpad Ray <arpad@php.net>
* @link http://php.net/inet_pton

		 * @author      Arpad Ray <arpad@php.net>

		 * @author      Arpad Ray <arpad@php.net>

		 * @version     $Revision: 269597 $
*/
$r = ip2long($ip);

		 * @version     $Revision: 269597 $
*/
$r = ip2long($ip);

Zeile 8103Zeile 8262
			}

$output = @mcrypt_create_iv($bytes, $source);

			}

$output = @mcrypt_create_iv($bytes, $source);

		}
}
else
{
return $output;
}

		}
}
else
{
return $output;
}


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


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

Zeile 8121Zeile 8280
				if ($crypto_strong == false)
{
$output = null;

				if ($crypto_strong == false)
{
$output = null;

				}
}
}
}

				}
}
}
}

	else
{
return $output;

	else
{
return $output;

Zeile 8154Zeile 8313
	{
// 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();


$rounds = ceil($bytes / 16);



$rounds = ceil($bytes / 16);


		for($i = 0; $i < $rounds; $i++)
{
$unique_state = md5(microtime().$unique_state);

		for($i = 0; $i < $rounds; $i++)
{
$unique_state = md5(microtime().$unique_state);

Zeile 8185Zeile 8344
	$bytes = PHP_INT_SIZE;

do

	$bytes = PHP_INT_SIZE;

do

	{

$output = secure_binary_seed_rng($bytes);

	{

$output = secure_binary_seed_rng($bytes);


// convert binary data to a decimal number
if ($bytes == 4)


// convert binary data to a decimal number
if ($bytes == 4)

Zeile 8232Zeile 8391
		if(isset($result))
{
return $result;

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

		}
}


		}
}


	$seed = secure_seed_rng();

$distance = $max - $min;

	$seed = secure_seed_rng();

$distance = $max - $min;

Zeile 8740Zeile 8899

if(file_exists($file_path))
{


if(file_exists($file_path))
{

 

if(is_object($plugins))
{
$hook_args = array(
'file_path' => &$file_path,
'real_file_path' => &$real_file_path,
'file_name' => &$file_name,
'file_dir_path' => &$file_dir_path
);
$plugins->run_hooks('copy_file_to_cdn_start', $hook_args);
}


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

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