Vergleich inc/functions.php - 1.8.14 - 1.8.24

  Keine Änderungen   Hinzugefügt   Modifiziert   Entfernt
Zeile 18Zeile 18
	global $db, $lang, $theme, $templates, $plugins, $mybb;
global $debug, $templatecache, $templatelist, $maintimer, $globaltime, $parsetime;


	global $db, $lang, $theme, $templates, $plugins, $mybb;
global $debug, $templatecache, $templatelist, $maintimer, $globaltime, $parsetime;


 
	$contents = $plugins->run_hooks("pre_parse_page", $contents);

	$contents = parse_page($contents);
$totaltime = format_time_duration($maintimer->stop());
$contents = $plugins->run_hooks("pre_output_page", $contents);

	$contents = parse_page($contents);
$totaltime = format_time_duration($maintimer->stop());
$contents = $plugins->run_hooks("pre_output_page", $contents);

Zeile 223Zeile 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 609Zeile 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']);

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

	}

	}

	// Guests get a special string

 
	else
{

	else
{

		return md5($session->useragent.$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 775Zeile 792

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 868Zeile 885

foreach($errors as $error)
{


foreach($errors as $error)
{

		$errorlist .= "<li>".$error."</li>\n";

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

	}

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

return $errors;

	}

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

return $errors;

}


}


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

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

Zeile 1030Zeile 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 '';
}

 

$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 1141Zeile 1169
		eval("\$jumptopage = \"".$templates->get("multipage_jump_page")."\";");
}


		eval("\$jumptopage = \"".$templates->get("multipage_jump_page")."\";");
}


	$lang->multipage_pages = $lang->sprintf($lang->multipage_pages, $pages);

	$multipage_pages = $lang->sprintf($lang->multipage_pages, $pages);


if($breadcrumb == true)
{


if($breadcrumb == true)
{

Zeile 1201Zeile 1229
/**
* Fetch the permissions for a specific user
*

/**
* Fetch the permissions for a specific user
*

 * @param int $uid The user ID

 * @param int $uid The user ID, if no user ID is provided then current user's ID will be considered.

 * @return array Array of user permissions for the specified user
*/

 * @return array Array of user permissions for the specified user
*/

function user_permissions($uid=0)

function user_permissions($uid=null)

{
global $mybb, $cache, $groupscache, $user_cache;

// If no user id is specified, assume it is the current user

{
global $mybb, $cache, $groupscache, $user_cache;

// If no user id is specified, assume it is the current user

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

// Its a guest. Return the group permissions directly from cache

	if($uid == 0)

	if($uid == 0)

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


	{
return $groupscache[1];
}


	// User id does not match current user, fetch permissions
if($uid != $mybb->user['uid'])
{
// We've already cached permissions for this user, return them.
if(!empty($user_cache[$uid]['permissions']))

	// User id does not match current user, fetch permissions
if($uid != $mybb->user['uid'])
{
// We've already cached permissions for this user, return them.
if(!empty($user_cache[$uid]['permissions']))

		{

		{

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


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


Zeile 1239Zeile 1273
	}
// This user is the current user, return their permissions
else

	}
// This user is the current user, return their permissions
else

	{

	{

		return $mybb->usergroup;
}
}

		return $mybb->usergroup;
}
}

Zeile 1253Zeile 1287
function usergroup_permissions($gid=0)
{
global $cache, $groupscache, $grouppermignore, $groupzerogreater;

function usergroup_permissions($gid=0)
{
global $cache, $groupscache, $grouppermignore, $groupzerogreater;


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


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

	}

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

	}

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

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

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

				{

				{

					$permbit = $usergroup[$perm];
}
else

					$permbit = $usergroup[$perm];
}
else

				{

				{

					$permbit = "";

					$permbit = "";

				}

				}


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


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

				}


				}


				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 1370Zeile 1404
			}

$groupperms = $mybb->usergroup;

			}

$groupperms = $mybb->usergroup;

		}
}

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

if(!$forum_cache)
{
return false;
}
}

if(!is_array($fpermcache))

		}
}

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

if(!$forum_cache)
{
return false;
}
}

if(!is_array($fpermcache))

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

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

	}

	}


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


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

Zeile 1397Zeile 1431
		return $cached_forum_permissions_permissions[$gid][$fid];
}
else

		return $cached_forum_permissions_permissions[$gid][$fid];
}
else

	{

	{

		if(empty($cached_forum_permissions[$gid]))
{
foreach($forum_cache as $forum)

		if(empty($cached_forum_permissions[$gid]))
{
foreach($forum_cache as $forum)

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

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

 *

 *

 * @param int $fid The forum ID
* @param string $gid A comma separated list of usergroups
* @param array $groupperms Group permissions

 * @param int $fid The forum ID
* @param string $gid A comma separated list of usergroups
* @param array $groupperms Group permissions

Zeile 1441Zeile 1475

// If our permissions arn't inherited we need to figure them out
if(empty($fpermcache[$fid][$gid]))


// If our permissions arn't inherited we need to figure them out
if(empty($fpermcache[$fid][$gid]))

			{

			{

				$parents = explode(',', $forum_cache[$fid]['parentlist']);
rsort($parents);
if(!empty($parents))

				$parents = explode(',', $forum_cache[$fid]['parentlist']);
rsort($parents);
if(!empty($parents))

Zeile 1454Zeile 1488
							break;
}
}

							break;
}
}

				}
}


				}
}


			// If we STILL don't have forum permissions we use the usergroup itself
if(empty($level_permissions))
{

			// If we STILL don't have forum permissions we use the usergroup itself
if(empty($level_permissions))
{

Zeile 1469Zeile 1503
				{
$current_permissions[$permission] = $access;
}

				{
$current_permissions[$permission] = $access;
}

			}


			}


			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;

			}

			}


if($level_permissions["canpostreplys"] && empty($level_permissions["canonlyreplyownthreads"]))
{


if($level_permissions["canpostreplys"] && empty($level_permissions["canonlyreplyownthreads"]))
{

Zeile 1485Zeile 1519

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


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

	{

	{

		$current_permissions["canonlyviewownthreads"] = 0;

		$current_permissions["canonlyviewownthreads"] = 0;

	}

	}


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

	}


	}


	if(count($current_permissions) == 0)

	if(count($current_permissions) == 0)

	{

	{

		$current_permissions = $groupperms;

		$current_permissions = $groupperms;

	}

	}

	return $current_permissions;

	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 1540Zeile 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 1565Zeile 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 1636Zeile 1713

// Get user groups
$perms = array();


// Get user groups
$perms = array();

	$user = get_user($uid);

$groups = array($user['usergroup']);


	$user = get_user($uid);

$groups = array($user['usergroup']);


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

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

Zeile 1673Zeile 1750

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


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

				{

				{

					// The user doesn't have permission to set this action
$perms[$action] = 0;

					// The user doesn't have permission to set this action
$perms[$action] = 0;

				}

				}

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

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

				}
}
}


				}
}
}


		foreach($groups as $group)
{
if(!is_array($forum['usergroups'][$group]))
{
// There are no permissions set for this group
continue;

		foreach($groups as $group)
{
if(!is_array($forum['usergroups'][$group]))
{
// There are no permissions set for this group
continue;

			}

			}


$perm = $forum['usergroups'][$group];
foreach($perm as $action => $value)


$perm = $forum['usergroups'][$group];
foreach($perm as $action => $value)

Zeile 1701Zeile 1778
				}

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

				}

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

			}
}
}

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


			}
}
}

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


	return $perms;
}


	return $perms;
}


Zeile 1721Zeile 1798
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'];
}


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

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

			{

			{

				return true;
}
return false;

				return true;
}
return false;

Zeile 1756Zeile 1833
				foreach($modcache as $modusers)
{
if(isset($modusers['users'][$uid]) && $modusers['users'][$uid]['mid'] && (!$action || !empty($modusers['users'][$uid][$action])))

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

					{

					{

						return true;
}


						return true;
}


Zeile 1772Zeile 1849
				}
}
return false;

				}
}
return false;

		}

		}

		else
{
$modperms = get_moderator_permissions($fid, $uid);

if(!$action && $modperms)

		else
{
$modperms = get_moderator_permissions($fid, $uid);

if(!$action && $modperms)

			{

			{

				return true;

				return true;

			}

			}

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

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

				}

				}

				else

				else

				{

				{

					return false;
}
}
}
}

					return false;
}
}
}
}

 
}

/**
* 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 1813Zeile 1946
	$iconlist = '';
$no_icons_checked = " checked=\"checked\"";
// read post icons from cache, and sort them accordingly

	$iconlist = '';
$no_icons_checked = " checked=\"checked\"";
// read post icons from cache, and sort them accordingly

	$posticons_cache = $cache->read("posticons");

	$posticons_cache = (array)$cache->read("posticons");

	$posticons = array();
foreach($posticons_cache as $posticon)
{

	$posticons = array();
foreach($posticons_cache as $posticon)
{

Zeile 1838Zeile 1971
		}

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

		}

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

	}


	}


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

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

Zeile 1859Zeile 1992
 * @param string $value The cookie value.
* @param int|string $expires The timestamp of the expiry date.
* @param boolean $httponly True if setting a HttpOnly cookie (supported by the majority of web browsers)

 * @param string $value The cookie value.
* @param int|string $expires The timestamp of the expiry date.
* @param boolean $httponly True if setting a HttpOnly cookie (supported by the majority of web browsers)

 
 * @param string $samesite The samesite attribute to prevent CSRF.

 */

 */

function my_setcookie($name, $value="", $expires="", $httponly=false)

function my_setcookie($name, $value="", $expires="", $httponly=false, $samesite="")

{
global $mybb;


{
global $mybb;


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

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

 
	}

if($samesite != "" && $mybb->settings['cookiesamesiteflag'])
{
$samesite = strtolower($samesite);

if($samesite == "lax" || $samesite == "strict")
{
$cookie .= "; SameSite=".$samesite;
}

	}

if($mybb->settings['cookiesecureflag'])

	}

if($mybb->settings['cookiesecureflag'])

Zeile 2022Zeile 2166
		return false;
}


		return false;
}


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

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



/*
* states:


/*
* states:

Zeile 3050Zeile 3193
 */
function format_name($username, $usergroup, $displaygroup=0)
{

 */
function format_name($username, $usergroup, $displaygroup=0)
{

	global $groupscache, $cache;

	global $groupscache, $cache, $plugins;





	if(!is_array($groupscache))



	static $formattednames = array();

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

	{

	{

		$groupscache = $cache->read("usergroups");
}

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





















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

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

$format = "{username}";

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





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

		$format = $parameters['format'];







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

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



	}


	}


	$format = stripslashes($format);

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

	return $formattednames[$username];



}

/**

}

/**

Zeile 3138Zeile 3297

if($dimensions)
{


if($dimensions)
{

		$dimensions = explode("|", $dimensions);

		$dimensions = preg_split('/[|x]/', $dimensions);


if($dimensions[0] && $dimensions[1])
{


if($dimensions[0] && $dimensions[1])
{

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

			list($max_width, $max_height) = preg_split('/[|x]/', $max_dimensions);


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


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

Zeile 3239Zeile 3398
			"editor_invalidyoutube" => "Invalid YouTube video",
"editor_dailymotion" => "Dailymotion",
"editor_metacafe" => "MetaCafe",

			"editor_invalidyoutube" => "Invalid YouTube video",
"editor_dailymotion" => "Dailymotion",
"editor_metacafe" => "MetaCafe",

			"editor_veoh" => "Veoh",

			"editor_mixer" => "Mixer",

			"editor_vimeo" => "Vimeo",
"editor_youtube" => "Youtube",
"editor_facebook" => "Facebook",

			"editor_vimeo" => "Vimeo",
"editor_youtube" => "Youtube",
"editor_facebook" => "Facebook",

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

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





						if(!$mybb->settings['smilieinserter'] || !$mybb->settings['smilieinsertercols'] || !$mybb->settings['smilieinsertertot'] || !$smilie['showclickable'])
{
$hiddensmilies .= '"'.$find.'": "'.$image.'",';
}
elseif($i < $mybb->settings['smilieinsertertot'])

						if(!$mybb->settings['smilieinserter'] || !$mybb->settings['smilieinsertercols'] || !$mybb->settings['smilieinsertertot'] || !$smilie['showclickable'])
{
$hiddensmilies .= '"'.$find.'": "'.$image.'",';
}
elseif($i < $mybb->settings['smilieinsertertot'])

						{

						{

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

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

						{

						{

							$moresmilies .= '"'.$find.'": "'.$image.'",';
}


							$moresmilies .= '"'.$find.'": "'.$image.'",';
}


Zeile 3344Zeile 3503
						}
}
}

						}
}
}

			}


			}


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

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

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

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

			{

			{

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

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

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

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

			{

			{

				$align = "left,center,right,justify|";
}


				$align = "left,center,right,justify|";
}


Zeile 3365Zeile 3524
			}

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

			}

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

			{

			{

				$size = "size,";
}


				$size = "size,";
}


Zeile 3382Zeile 3541
			if($mybb->settings['allowemailmycode'] == 1)
{
$email = "email,";

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

			}

			}


if($mybb->settings['allowlinkmycode'] == 1)
{
$link = "link,unlink";


if($mybb->settings['allowlinkmycode'] == 1)
{
$link = "link,unlink";

			}

			}


if($mybb->settings['allowlistmycode'] == 1)
{
$list = "bulletlist,orderedlist|";


if($mybb->settings['allowlistmycode'] == 1)
{
$list = "bulletlist,orderedlist|";

			}


			}


			if($mybb->settings['allowcodemycode'] == 1)
{
$code = "code,php,";

			if($mybb->settings['allowcodemycode'] == 1)
{
$code = "code,php,";

			}


			}


			if($mybb->user['sourceeditor'] == 1)
{
$sourcemode = "MyBBEditor.sourceMode(true);";
}

			if($mybb->user['sourceeditor'] == 1)
{
$sourcemode = "MyBBEditor.sourceMode(true);";
}





			eval("\$codeinsert = \"".$templates->get("codebuttons")."\";");
}
}


			eval("\$codeinsert = \"".$templates->get("codebuttons")."\";");
}
}


	return $codeinsert;
















































	return $codeinsert;
}

/**
* @param int $tid
* @param array $postoptions The options carried with form submit
*
* @return string Predefined / updated subscription method of the thread for the user
*/
function get_subscription_method($tid = 0, $postoptions = array())
{
global $mybb;

$subscription_methods = array('', 'none', 'email', 'pm'); // Define methods
$subscription_method = (int)$mybb->user['subscriptionmethod']; // Set user default

// If no user default method available then reset method
if(!$subscription_method)
{
$subscription_method = 0;
}

// Return user default if no thread id available, in case
if(!(int)$tid || (int)$tid <= 0)
{
return $subscription_methods[$subscription_method];
}

// If method not predefined set using data from database
if(isset($postoptions['subscriptionmethod']))
{
$method = trim($postoptions['subscriptionmethod']);
return (in_array($method, $subscription_methods)) ? $method : $subscription_methods[0];
}
else
{
global $db;

$query = $db->simple_select("threadsubscriptions", "tid, notification", "tid='".(int)$tid."' AND uid='".$mybb->user['uid']."'", array('limit' => 1));
$subscription = $db->fetch_array($query);

if($subscription['tid'])
{
$subscription_method = (int)$subscription['notification'] + 1;
}
}

return $subscription_methods[$subscription_method];

}

/**

}

/**

Zeile 4183Zeile 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 4197Zeile 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 4212Zeile 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 4224Zeile 4427
			$unviewable[] = $forum['fid'];
}
}

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





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

return $unviewableforums;

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

return $unviewableforums;

Zeile 4246Zeile 4449

return $format;
}


return $format;
}





/**
* Build the breadcrumb navigation trail from the specified items
*

/**
* Build the breadcrumb navigation trail from the specified items
*

Zeile 4262Zeile 4465
	$activesep = '';

if(is_array($navbits))

	$activesep = '';

if(is_array($navbits))

	{

	{

		reset($navbits);
foreach($navbits as $key => $navbit)
{

		reset($navbits);
foreach($navbits as $key => $navbit)
{

Zeile 4284Zeile 4487
					if(!$mybb->settings['threadsperpage'] || (int)$mybb->settings['threadsperpage'] < 1)
{
$mybb->settings['threadsperpage'] = 20;

					if(!$mybb->settings['threadsperpage'] || (int)$mybb->settings['threadsperpage'] < 1)
{
$mybb->settings['threadsperpage'] = 20;

					}


					}


					$multipage = multipage($navbit['multipage']['num_threads'], $mybb->settings['threadsperpage'], $navbit['multipage']['current_page'], $navbit['multipage']['url'], true);
if($multipage)
{

					$multipage = multipage($navbit['multipage']['num_threads'], $mybb->settings['threadsperpage'], $navbit['multipage']['current_page'], $navbit['multipage']['url'], true);
if($multipage)
{

Zeile 4302Zeile 4505
				eval("\$nav .= \"".$templates->get("nav_bit")."\";");
}
}

				eval("\$nav .= \"".$templates->get("nav_bit")."\";");
}
}

 
		$navsize = count($navbits);
$navbit = $navbits[$navsize-1];

	}

	}


$activesep = '';
$navsize = count($navbits);
$navbit = $navbits[$navsize-1];

 

if($nav)
{


if($nav)
{

Zeile 4326Zeile 4527
 * @param string $url The URL of the item to add
*/
function add_breadcrumb($name, $url="")

 * @param string $url The URL of the item to add
*/
function add_breadcrumb($name, $url="")

{

{

	global $navbits;

	global $navbits;





	$navsize = count($navbits);
$navbits[$navsize]['name'] = $name;
$navbits[$navsize]['url'] = $url;
}

	$navsize = count($navbits);
$navbits[$navsize]['name'] = $name;
$navbits[$navsize]['url'] = $url;
}





/**
* Build the forum breadcrumb nagiation (the navigation to a specific forum including all parent forums)
*

/**
* Build the forum breadcrumb nagiation (the navigation to a specific forum including all parent forums)
*

Zeile 4348Zeile 4549
	if(!$pforumcache)
{
if(!is_array($forum_cache))

	if(!$pforumcache)
{
if(!is_array($forum_cache))

		{

		{

			cache_forums();
}


			cache_forums();
}


Zeile 4386Zeile 4587
					}
}
elseif(!empty($multipage))

					}
}
elseif(!empty($multipage))

				{

				{

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

$navbits[$navsize]['multipage'] = $multipage;

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

$navbits[$navsize]['multipage'] = $multipage;

Zeile 4398Zeile 4599
				}
}
}

				}
}
}

	}


	}


	return 1;
}


	return 1;
}


Zeile 4413Zeile 4614
	$newnav[0]['name'] = $navbits[0]['name'];
$newnav[0]['url'] = $navbits[0]['url'];
if(!empty($navbits[0]['options']))

	$newnav[0]['name'] = $navbits[0]['name'];
$newnav[0]['url'] = $navbits[0]['url'];
if(!empty($navbits[0]['options']))

	{

	{

		$newnav[0]['options'] = $navbits[0]['options'];
}

unset($GLOBALS['navbits']);
$GLOBALS['navbits'] = $newnav;
}

		$newnav[0]['options'] = $navbits[0]['options'];
}

unset($GLOBALS['navbits']);
$GLOBALS['navbits'] = $newnav;
}





/**
* Builds a URL to an archive mode page
*

/**
* Builds a URL to an archive mode page
*

Zeile 4441Zeile 4642
	else
{
$base_url = $mybb->settings['bburl']."/archive/index.php?";

	else
{
$base_url = $mybb->settings['bburl']."/archive/index.php?";

	}

switch($type)
{
case "thread":

	}

switch($type)
{
case "thread":

			$url = "{$base_url}thread-{$id}.html";
break;
case "announcement":

			$url = "{$base_url}thread-{$id}.html";
break;
case "announcement":

Zeile 4460Zeile 4661

return $url;
}


return $url;
}





/**
* Prints a debug information page
*/

/**
* Prints a debug information page
*/

Zeile 4475Zeile 4676

$percentphp = number_format((($phptime/$maintimer->totaltime)*100), 2);
$percentsql = number_format((($query_time/$maintimer->totaltime)*100), 2);


$percentphp = number_format((($phptime/$maintimer->totaltime)*100), 2);
$percentsql = number_format((($query_time/$maintimer->totaltime)*100), 2);





	$phptime = format_time_duration($maintimer->totaltime - $db->query_time);
$query_time = format_time_duration($db->query_time);


	$phptime = format_time_duration($maintimer->totaltime - $db->query_time);
$query_time = format_time_duration($db->query_time);


Zeile 4505Zeile 4706
	echo "<h1>MyBB Debug Information</h1>\n";
echo "<h2>Page Generation</h2>\n";
echo "<table bgcolor=\"#666666\" width=\"95%\" cellpadding=\"4\" cellspacing=\"1\" align=\"center\">\n";

	echo "<h1>MyBB Debug Information</h1>\n";
echo "<h2>Page Generation</h2>\n";
echo "<table bgcolor=\"#666666\" width=\"95%\" cellpadding=\"4\" cellspacing=\"1\" align=\"center\">\n";

	echo "<tr>\n";

	echo "<tr>\n";

	echo "<td bgcolor=\"#cccccc\" colspan=\"4\"><b><span style=\"size:2;\">Page Generation Statistics</span></b></td>\n";
echo "</tr>\n";
echo "<tr>\n";

	echo "<td bgcolor=\"#cccccc\" colspan=\"4\"><b><span style=\"size:2;\">Page Generation Statistics</span></b></td>\n";
echo "</tr>\n";
echo "<tr>\n";

Zeile 4519Zeile 4720
	echo "<td bgcolor=\"#fefefe\" width=\"25%\"><span style=\"font-family: tahoma; font-size: 12px;\">$phptime ($percentphp%)</span></td>\n";
echo "<td bgcolor=\"#efefef\" width=\"25%\"><b><span style=\"font-family: tahoma; font-size: 12px;\">DB Processing Time:</span></b></td>\n";
echo "<td bgcolor=\"#fefefe\" width=\"25%\"><span style=\"font-family: tahoma; font-size: 12px;\">$query_time ($percentsql%)</span></td>\n";

	echo "<td bgcolor=\"#fefefe\" width=\"25%\"><span style=\"font-family: tahoma; font-size: 12px;\">$phptime ($percentphp%)</span></td>\n";
echo "<td bgcolor=\"#efefef\" width=\"25%\"><b><span style=\"font-family: tahoma; font-size: 12px;\">DB Processing Time:</span></b></td>\n";
echo "<td bgcolor=\"#fefefe\" width=\"25%\"><span style=\"font-family: tahoma; font-size: 12px;\">$query_time ($percentsql%)</span></td>\n";

	echo "</tr>\n";

	echo "</tr>\n";

	echo "<tr>\n";
echo "<td bgcolor=\"#efefef\" width=\"25%\"><b><span style=\"font-family: tahoma; font-size: 12px;\">Extensions Used:</span></b></td>\n";
echo "<td bgcolor=\"#fefefe\" width=\"25%\"><span style=\"font-family: tahoma; font-size: 12px;\">{$mybb->config['database']['type']}, xml</span></td>\n";

	echo "<tr>\n";
echo "<td bgcolor=\"#efefef\" width=\"25%\"><b><span style=\"font-family: tahoma; font-size: 12px;\">Extensions Used:</span></b></td>\n";
echo "<td bgcolor=\"#fefefe\" width=\"25%\"><span style=\"font-family: tahoma; font-size: 12px;\">{$mybb->config['database']['type']}, xml</span></td>\n";

Zeile 4549Zeile 4750
		$memory_usage = get_friendly_size($memory_usage)." ({$memory_usage} bytes)";
}
$memory_limit = @ini_get("memory_limit");

		$memory_usage = get_friendly_size($memory_usage)." ({$memory_usage} bytes)";
}
$memory_limit = @ini_get("memory_limit");

	echo "<tr>\n";

	echo "<tr>\n";

	echo "<td bgcolor=\"#EFEFEF\" width=\"25%\"><b><span style=\"font-family: tahoma; font-size: 12px;\">Memory Usage:</span></b></td>\n";
echo "<td bgcolor=\"#FEFEFE\" width=\"25%\"><span style=\"font-family: tahoma; font-size: 12px;\">{$memory_usage}</span></td>\n";
echo "<td bgcolor=\"#EFEFEF\" width=\"25%\"><b><span style=\"font-family: tahoma; font-size: 12px;\">Memory Limit:</span></b></td>\n";
echo "<td bgcolor=\"#FEFEFE\" width=\"25%\"><span style=\"font-family: tahoma; font-size: 12px;\">{$memory_limit}</span></td>\n";

	echo "<td bgcolor=\"#EFEFEF\" width=\"25%\"><b><span style=\"font-family: tahoma; font-size: 12px;\">Memory Usage:</span></b></td>\n";
echo "<td bgcolor=\"#FEFEFE\" width=\"25%\"><span style=\"font-family: tahoma; font-size: 12px;\">{$memory_usage}</span></td>\n";
echo "<td bgcolor=\"#EFEFEF\" width=\"25%\"><b><span style=\"font-family: tahoma; font-size: 12px;\">Memory Limit:</span></b></td>\n";
echo "<td bgcolor=\"#FEFEFE\" width=\"25%\"><span style=\"font-family: tahoma; font-size: 12px;\">{$memory_limit}</span></td>\n";

	echo "</tr>\n";

echo "</table>\n";


	echo "</tr>\n";

echo "</table>\n";


	echo "<h2>Database Connections (".count($db->connections)." Total) </h2>\n";
echo "<table style=\"background-color: #666;\" width=\"95%\" cellpadding=\"4\" cellspacing=\"1\" align=\"center\">\n";
echo "<tr>\n";

	echo "<h2>Database Connections (".count($db->connections)." Total) </h2>\n";
echo "<table style=\"background-color: #666;\" width=\"95%\" cellpadding=\"4\" cellspacing=\"1\" align=\"center\">\n";
echo "<tr>\n";

Zeile 4565Zeile 4766
	echo "</tr>\n";
echo "</table>\n";
echo "<br />\n";

	echo "</tr>\n";
echo "</table>\n";
echo "<br />\n";





	echo "<h2>Database Queries (".$db->query_count." Total) </h2>\n";
echo $db->explain;


	echo "<h2>Database Queries (".$db->query_count." Total) </h2>\n";
echo $db->explain;


Zeile 4616Zeile 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 4689Zeile 4887
	$msecs = 60;

if(isset($options['short']))

	$msecs = 60;

if(isset($options['short']))

	{

	{

		$lang_year = $lang->year_short;
$lang_years = $lang->years_short;
$lang_month = $lang->month_short;

		$lang_year = $lang->year_short;
$lang_years = $lang->years_short;
$lang_month = $lang->month_short;

Zeile 4704Zeile 4902
		$lang_minutes = $lang->minutes_short;
$lang_second = $lang->second_short;
$lang_seconds = $lang->seconds_short;

		$lang_minutes = $lang->minutes_short;
$lang_second = $lang->second_short;
$lang_seconds = $lang->seconds_short;

	}

	}

	else
{
$lang_year = " ".$lang->year;

	else
{
$lang_year = " ".$lang->year;

Zeile 4751Zeile 4949
	{
$options = array_merge(array(
'hours' => false,

	{
$options = array_merge(array(
'hours' => false,

			'minutes' => false,
'seconds' => false
), $options);
}

			'minutes' => false,
'seconds' => false
), $options);
}

	elseif($weeks > 0)

	elseif($weeks > 0)

	{

	{

		$options = array_merge(array(
'minutes' => false,

		$options = array_merge(array(
'minutes' => false,

			'seconds' => false
), $options);

			'seconds' => false
), $options);

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

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

	}


	}


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

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

	{

	{

		if($years == 1)

		if($years == 1)

		{

		{

			$nicetime['years'] = "1".$lang_year;

			$nicetime['years'] = "1".$lang_year;

		}

		}

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

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

Zeile 4782Zeile 4980
	}

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

	}

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

	{

	{

		if($months == 1)
{
$nicetime['months'] = "1".$lang_month;

		if($months == 1)
{
$nicetime['months'] = "1".$lang_month;

Zeile 4798Zeile 4996
		if($weeks == 1)
{
$nicetime['weeks'] = "1".$lang_week;

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

		}

		}

		else if($weeks > 1)

		else if($weeks > 1)

		{

		{

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

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

		}

		}

	}

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

	}

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

		{

		{

			$nicetime['days'] = "1".$lang_day;

			$nicetime['days'] = "1".$lang_day;

		}

		}

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

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

		}
}

		}
}


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


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

Zeile 4876Zeile 5074
	else
{
$trow = "trow1";

	else
{
$trow = "trow1";

	}

$alttrow = $trow;

	}

$alttrow = $trow;


return $trow;
}


return $trow;
}

Zeile 4926Zeile 5124

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


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

	{

	{

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

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

Zeile 4941Zeile 5139
 *
* @param int $uid The user ID
* @param int $leavegroup The user group ID

 *
* @param int $uid The user ID
* @param int $leavegroup The user group ID

 */

 */

function leave_usergroup($uid, $leavegroup)
{
global $db, $mybb, $cache;


function leave_usergroup($uid, $leavegroup)
{
global $db, $mybb, $cache;


	$user = get_user($uid);







	$user = get_user($uid);

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


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

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





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

if(is_array($groups))
{
foreach($groups as $gid)

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

if(is_array($groups))
{
foreach($groups as $gid)

		{

		{

			if(trim($gid) != "" && $leavegroup != $gid && empty($donegroup[$gid]))
{
$groupslist .= $comma.$gid;

			if(trim($gid) != "" && $leavegroup != $gid && empty($donegroup[$gid]))
{
$groupslist .= $comma.$gid;

Zeile 4986Zeile 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"))

	if(defined("MYBB_LOCATION"))

	{

	{

		return MYBB_LOCATION;

		return MYBB_LOCATION;

	}

	}


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


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

Zeile 5006Zeile 5211
		$location = htmlspecialchars_uni($_SERVER['PHP_SELF']);
}
elseif(!empty($_ENV['PHP_SELF']))

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

	{

	{

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

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

Zeile 5016Zeile 5221
	else
{
$location = htmlspecialchars_uni($_ENV['PATH_INFO']);

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

	}


	}


	if($quick)
{
return $location;

	if($quick)
{
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 5050Zeile 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']);














			$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((isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] == "POST") || (isset($_ENV['REQUEST_METHOD']) && $_ENV['REQUEST_METHOD'] == "POST"))


if($mybb->request_method === 'post')

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

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





			foreach($post_array as $var)

			foreach($post_array as $var)

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

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

			{
if(isset($_POST[$var]) && !in_array($var, $ignore))
{
$parameters[$var] = $_POST[$var];
}














			}

			}

 
		}

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

		}

return $location;

		}

return $location;

Zeile 5205Zeile 5416
			{
$s_theme = $theme;
break 2;

			{
$s_theme = $theme;
break 2;

			}
}
}

			}
}
}


return $s_theme;
}


return $s_theme;
}

Zeile 5280Zeile 5491
	if(!isset($charset))
{
$charset = my_strtolower($lang->settings['charset']);

	if(!isset($charset))
{
$charset = my_strtolower($lang->settings['charset']);

	}


	}


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

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

Zeile 5327Zeile 5538
		else
{
return utf8_decode($str);

		else
{
return utf8_decode($str);

		}
}
else
{
return $str;
}
}

		}
}
else
{
return $str;
}
}


/**
* DEPRECATED! Please use other alternatives.


/**
* DEPRECATED! Please use other alternatives.

 *

 *

 * @deprecated
* @param string $message
*

 * @deprecated
* @param string $message
*

Zeile 5346Zeile 5557
function my_wordwrap($message)
{
return $message;

function my_wordwrap($message)
{
return $message;

}

/**

}

/**

 * Workaround for date limitation in PHP to establish the day of a birthday (Provided by meme)
*
* @param int $month The month of the birthday

 * Workaround for date limitation in PHP to establish the day of a birthday (Provided by meme)
*
* @param int $month The month of the birthday

Zeile 5363Zeile 5574
	for($i = 1969; $i >= $year; $i--)
{
$j = get_bdays($i);

	for($i = 1969; $i >= $year; $i--)
{
$j = get_bdays($i);





		for($k = 11; $k >= 0; $k--)
{
$l = ($k + 1);

		for($k = 11; $k >= 0; $k--)
{
$l = ($k + 1);

Zeile 5407Zeile 5618
		31,
30,
31

		31,
30,
31

	);

	);

}

/**

}

/**

Zeile 5450Zeile 5661
		$lang->month_11,
$lang->month_12
);

		$lang->month_11,
$lang->month_12
);



 

// This needs to be in this specific order
$find = array(


// This needs to be in this specific order
$find = array(

Zeile 5710Zeile 5920
	if(function_exists("mb_strtolower"))
{
$string = mb_strtolower($string);

	if(function_exists("mb_strtolower"))
{
$string = mb_strtolower($string);

	}
else
{

	}
else
{

		$string = strtolower($string);
}


		$string = strtolower($string);
}


	return $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
{
$position = stripos($haystack, $needle, $offset);
}

return $position;

}

/**

}

/**

Zeile 6089Zeile 6326

/**
* Get the user data of an user id.


/**
* Get the user data of an user id.

 *

 *

 * @param int $uid The user id of the user.
* @return array The users data
*/

 * @param int $uid The user id of the user.
* @return array The users data
*/

Zeile 6097Zeile 6334
{
global $mybb, $db;
static $user_cache;

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





	$uid = (int)$uid;

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

	$uid = (int)$uid;

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

Zeile 6105Zeile 6342
		return $mybb->user;
}
elseif(isset($user_cache[$uid]))

		return $mybb->user;
}
elseif(isset($user_cache[$uid]))

	{

	{

		return $user_cache[$uid];
}
elseif($uid > 0)

		return $user_cache[$uid];
}
elseif($uid > 0)

Zeile 6137Zeile 6374
	}

switch($db->type)

	}

switch($db->type)

	{

	{

		case 'mysql':
case 'mysqli':
$field = 'username';

		case 'mysql':
case 'mysqli':
$field = 'username';

Zeile 6166Zeile 6403
	if(isset($options['fields']))
{
$fields = array_merge((array)$options['fields'], $fields);

	if(isset($options['fields']))
{
$fields = array_merge((array)$options['fields'], $fields);

	}

$query = $db->simple_select('users', implode(',', array_unique($fields)), $sqlwhere, array('limit' => 1));

	}

$query = $db->simple_select('users', implode(',', array_unique($fields)), $sqlwhere, array('limit' => 1));


if(isset($options['exists']))
{


if(isset($options['exists']))
{

Zeile 6190Zeile 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 6216Zeile 6453
	}

return $forum_cache[$fid];

	}

return $forum_cache[$fid];

}

}


/**
* Get the thread of a thread id.


/**
* Get the thread of a thread id.

Zeile 6272Zeile 6509
		return $post_cache[$pid];
}
else

		return $post_cache[$pid];
}
else

	{

	{

		$query = $db->simple_select("posts", "*", "pid = '{$pid}'");
$post = $db->fetch_array($query);


		$query = $db->simple_select("posts", "*", "pid = '{$pid}'");
$post = $db->fetch_array($query);


Zeile 6280Zeile 6517
		{
$post_cache[$pid] = $post;
return $post;

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

		}

		}

		else
{
$post_cache[$pid] = false;
return false;

		else
{
$post_cache[$pid] = false;
return false;

		}
}
}

		}
}
}


/**
* Get inactivate forums.


/**
* Get inactivate forums.

Zeile 6301Zeile 6538
	if(!$forum_cache)
{
cache_forums();

	if(!$forum_cache)
{
cache_forums();

	}

	}


$inactive = array();



$inactive = array();


Zeile 6330Zeile 6567
 *
* @param bool $fatal (Optional) Stop execution if it finds an error with the login. Default is True
* @return bool|int Number of logins when success, false if failed.

 *
* @param bool $fatal (Optional) Stop execution if it finds an error with the login. Default is True
* @return bool|int Number of logins when success, false if failed.

 */
function login_attempt_check($fatal = true)
{
global $mybb, $lang, $session, $db;

if($mybb->settings['failedlogincount'] == 0)
{
return 1;
}
// Note: Number of logins is defaulted to 1, because using 0 seems to clear cookie data. Not really a problem as long as we account for 1 being default.

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

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

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

// Work out if the user has had more than the allowed number of login attempts
if($loginattempts > $mybb->settings['failedlogincount'])
{
// If so, then we need to work out if they can try to login again
// Some maths to work out how long they have left and display it to them
$now = TIME_NOW;




 */
function login_attempt_check($uid = 0, $fatal = true)
{
global $mybb, $lang, $db;

$attempts = array();
$uid = (int)$uid;
$now = TIME_NOW;

// Get this user's login attempts and eventual lockout, if a uid is provided
if($uid > 0)
{
$query = $db->simple_select("users", "loginattempts, loginlockoutexpiry", "uid='{$uid}'", 1);
$attempts = $db->fetch_array($query);

if($attempts['loginattempts'] <= 0)
{
return 0;
}
}
// This user has a cookie lockout, show waiting time
elseif($mybb->cookies['lockoutexpiry'] && $mybb->cookies['lockoutexpiry'] > $now)
{
if($fatal)
{
$secsleft = (int)($mybb->cookies['lockoutexpiry'] - $now);
$hoursleft = floor($secsleft / 3600);
$minsleft = floor(($secsleft / 60) % 60);
$secsleft = floor($secsleft % 60);

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

return false;
}





		if(empty($mybb->cookies['failedlogin']))
{
$failedtime = $now;
}
else

	if($mybb->settings['failedlogincount'] > 0 && $attempts['loginattempts'] >= $mybb->settings['failedlogincount'])
{
// Set the expiry dateline if not set yet
if($attempts['loginlockoutexpiry'] == 0)


		{

		{

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


















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

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

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

		}


		}


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

// This value will be empty the first time the user doesn't login in, set it
if(empty($failedlogin))

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






		{

		{

			my_setcookie('failedlogin', $now);

 
			if($fatal)

			if($fatal)

			{






			{
$secsleft = (int)($attempts['loginlockoutexpiry'] - $now);
$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;

			return false;

		}

// Work out if the user has waited long enough before letting them login again
if($mybb->cookies['failedlogin'] < ($now - $mybb->settings['failedlogintime'] * 60))
{
my_setcookie('loginattempts', 1);
my_unsetcookie('failedlogin');
if($mybb->user['uid'] != 0)

		}
// Unlock if enough time has passed
else {

if($uid > 0)




			{

			{

				$update_array = array(
'loginattempts' => 1
);
$db->update_query("users", $update_array, "uid = '{$mybb->user['uid']}'");

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

			}

			}

			return 1;
}
// Not waited long enough
else if($mybb->cookies['failedlogin'] > ($now - $mybb->settings['failedlogintime'] * 60))
{
if($fatal)
{
error($lang->sprintf($lang->failed_login_wait, $hoursleft, $minsleft, $secsleft));
}

return false;


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

return 0;







		}
}

		}
}





	// User can attempt another login

	// User can attempt another login

	return $loginattempts;
}


	return $attempts['loginattempts'];
}


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

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

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

{
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 6443Zeile 6684
 * @return boolean True when in use, false when not.
*/
function email_already_in_use($email, $uid=0)

 * @return boolean True when in use, false when not.
*/
function email_already_in_use($email, $uid=0)

{

{

	global $db;

$uid_string = "";

	global $db;

$uid_string = "";

Zeile 6478Zeile 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['value'] = addcslashes($setting['value'], '\\"$');
$settings .= "\$settings['{$setting['name']}'] = \"{$setting['value']}\";\n";
}

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

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

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

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

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

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

Zeile 6701Zeile 6944
{
global $cache, $db;


{
global $cache, $db;


	$banned_cache = $cache->read("bannedemails");


	$banned_cache = $cache->read("bannedemails");


	if($banned_cache === false)
{
// Failed to read cache, see if we can rebuild it

	if($banned_cache === false)
{
// Failed to read cache, see if we can rebuild it

Zeile 6749Zeile 6992
	{
return false;
}

	{
return false;
}





	$ip_address = my_inet_pton($ip_address);
foreach($banned_ips as $banned_ip)
{

	$ip_address = my_inet_pton($ip_address);
foreach($banned_ips as $banned_ip)
{

Zeile 6757Zeile 7000
		{
continue;
}

		{
continue;
}





		$banned = false;

$ip_range = fetch_ip_range($banned_ip['filter']);
if(is_array($ip_range))
{
if(strcmp($ip_range[0], $ip_address) <= 0 && strcmp($ip_range[1], $ip_address) >= 0)

		$banned = false;

$ip_range = fetch_ip_range($banned_ip['filter']);
if(is_array($ip_range))
{
if(strcmp($ip_range[0], $ip_address) <= 0 && strcmp($ip_range[1], $ip_address) >= 0)

			{

			{

				$banned = true;
}
}

				$banned = true;
}
}

Zeile 6889Zeile 7132
		}

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

		}

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

	}


	}


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

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

Zeile 6906Zeile 7149
function fetch_remote_file($url, $post_data=array(), $max_redirects=20)
{
global $mybb, $config;

function fetch_remote_file($url, $post_data=array(), $max_redirects=20)
{
global $mybb, $config;





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

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

	}


	}


	$url_components = @parse_url($url);

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

	$url_components = @parse_url($url);

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

	{

	{

		$url_components['scheme'] = 'https';

		$url_components['scheme'] = 'https';

	}

	}

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

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

	}


	}


	if(
!$url_components ||
empty($url_components['host']) ||

	if(
!$url_components ||
empty($url_components['host']) ||

Zeile 6938Zeile 7181
	$destination_address = $addresses[0];

if(!empty($config['disallowed_remote_addresses']))

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

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

Zeile 7000Zeile 7243
		{
// CURLOPT_CONNECT_TO
$curlopt[10243] = array(

		{
// CURLOPT_CONNECT_TO
$curlopt[10243] = array(

				$url_components['host'].':'.$url_components['port'].':'.$destination_address
);

				$url_components['host'].':'.$url_components['port'].':'.$destination_address
);

		}
elseif(version_compare(PHP_VERSION, '5.5', '>=') && version_compare($curl_version, '7.21.3', '>='))
{

		}
elseif(version_compare(PHP_VERSION, '5.5', '>=') && version_compare($curl_version, '7.21.3', '>='))
{

Zeile 7015Zeile 7258
		{
$curlopt[CURLOPT_POST] = 1;
$curlopt[CURLOPT_POSTFIELDS] = $post_body;

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

		}


		}


		curl_setopt_array($ch, $curlopt);

$response = curl_exec($ch);

		curl_setopt_array($ch, $curlopt);

$response = curl_exec($ch);

Zeile 7029Zeile 7272

if(in_array(curl_getinfo($ch, CURLINFO_HTTP_CODE), array(301, 302)))
{


if(in_array(curl_getinfo($ch, CURLINFO_HTTP_CODE), array(301, 302)))
{

				preg_match('/Location:(.*?)(?:\n|$)/', $header, $matches);

				preg_match('/^Location:(.*?)(?:\n|$)/im', $header, $matches);


if($matches)
{


if($matches)
{

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

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

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

					),
));
}

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

					),
));
}

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

		}
else

		}
else

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

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

Zeile 7112Zeile 7356
			$headers[] = "POST {$url_components['path']} HTTP/1.0";
$headers[] = "Content-Length: ".strlen($post_body);
$headers[] = "Content-Type: application/x-www-form-urlencoded";

			$headers[] = "POST {$url_components['path']} HTTP/1.0";
$headers[] = "Content-Length: ".strlen($post_body);
$headers[] = "Content-Type: application/x-www-form-urlencoded";

		}

		}

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

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

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

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

		}

		}

		fclose($fp);

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

		fclose($fp);

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

Zeile 7154Zeile 7398

if($max_redirects > 0 && (strstr($status_line, ' 301 ') || strstr($status_line, ' 302 ')))
{


if($max_redirects > 0 && (strstr($status_line, ' 301 ') || strstr($status_line, ' 302 ')))
{

			preg_match('/Location:(.*?)(?:\n|$)/', $header, $matches);

			preg_match('/^Location:(.*?)(?:\n|$)/im', $header, $matches);


if($matches)
{


if($matches)
{

Zeile 7561Zeile 7805
 * @param array $array The array of forums
* @return integer The number of sub forums
*/

 * @param array $array The array of forums
* @return integer The number of sub forums
*/

function subforums_count($array)

function subforums_count($array=array())

{
$count = 0;
foreach($array as $array2)

{
$count = 0;
foreach($array as $array2)

Zeile 7649Zeile 7893
		 */
$r = ip2long($ip);
if($r !== false && $r != -1)

		 */
$r = ip2long($ip);
if($r !== false && $r != -1)

		{

		{

			return pack('N', $r);

			return pack('N', $r);

		}

		}


$delim_count = substr_count($ip, ':');
if($delim_count < 1 || $delim_count > 7)


$delim_count = substr_count($ip, ':');
if($delim_count < 1 || $delim_count > 7)

		{

		{

			return false;
}


			return false;
}


Zeile 7665Zeile 7909
		{
$length = (!$doub || $doub == $rcount - 1 ? 2 : 1);
array_splice($r, $doub, $length, array_fill(0, 8 + $length - $rcount, 0));

		{
$length = (!$doub || $doub == $rcount - 1 ? 2 : 1);
array_splice($r, $doub, $length, array_fill(0, 8 + $length - $rcount, 0));

		}

		}


$r = array_map('hexdec', $r);
array_unshift($r, 'n*');


$r = array_map('hexdec', $r);
array_unshift($r, 'n*');

Zeile 7712Zeile 7956
					array('::', '(int)"$1"?"$1":"0$1"'),
$r);
return $r;

					array('::', '(int)"$1"?"$1":"0$1"'),
$r);
return $r;

		}

		}

		return false;
}
}

		return false;
}
}

Zeile 7775Zeile 8019
			{
// Invalid IP address
return false;

			{
// Invalid IP address
return false;

			}

			}

		}

/**

		}

/**

Zeile 7792Zeile 8036
		// IP bits (lots of 0's and 1's)
$ip_bits = '';
for($i = 0; $i < $ip_pack_size; $i = $i+1)

		// IP bits (lots of 0's and 1's)
$ip_bits = '';
for($i = 0; $i < $ip_pack_size; $i = $i+1)

		{

		{

			$bit = decbin(ord($ip_pack[$i]));
$bit = str_pad($bit, 8, '0', STR_PAD_LEFT);
$ip_bits .= $bit;

			$bit = decbin(ord($ip_pack[$i]));
$bit = str_pad($bit, 8, '0', STR_PAD_LEFT);
$ip_bits .= $bit;

Zeile 7842Zeile 8086
	static $time_start;

$time = microtime(true);

	static $time_start;

$time = microtime(true);



 

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


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

Zeile 7913Zeile 8156
				{
$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 8155Zeile 8398

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


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

Zeile 8234Zeile 8477
	{
// 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

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

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

Zeile 8283Zeile 8526
function match_sequence($string, $array, $i=0, $n=0)
{
if($string === "")

function match_sequence($string, $array, $i=0, $n=0)
{
if($string === "")

	{

	{

		return 0;
}


		return 0;
}


Zeile 8572Zeile 8815
	}

$pm['options'] = array(

	}

$pm['options'] = array(

		"signature" => 0,

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

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

Zeile 8657Zeile 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(substr($file_dir_path, 0, my_strlen(MYBB_ROOT)) == MYBB_ROOT)

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

if(substr($file_dir_path, 0, my_strlen(MYBB_ROOT)) == MYBB_ROOT)

			{

			{

				$file_dir_path = str_replace(MYBB_ROOT, '', $file_dir_path);

				$file_dir_path = str_replace(MYBB_ROOT, '', $file_dir_path);

			}

$cdn_upload_path = $cdn_path . DIRECTORY_SEPARATOR . $file_dir_path;

			}

$cdn_upload_path = $cdn_path . DIRECTORY_SEPARATOR . $file_dir_path;


if(!($dir_exists = is_dir($cdn_upload_path)))
{


if(!($dir_exists = is_dir($cdn_upload_path)))
{

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

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





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

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

Zeile 8725Zeile 8979
	}

if($relative_path && my_substr($url, 0, 1) == '/' || preg_match($regex, $url))

	}

if($relative_path && my_substr($url, 0, 1) == '/' || preg_match($regex, $url))

	{

	{

		return true;
}
return false;

		return true;
}
return false;

Zeile 8734Zeile 8988
/**
* Strip html tags from string, also removes <script> and <style> contents.
*

/**
* Strip html tags from string, also removes <script> and <style> contents.
*

 
 * @deprecated

 * @param  string $string         String to stripe
* @param string $allowable_tags Allowed html tags
*

 * @param  string $string         String to stripe
* @param string $allowable_tags Allowed html tags
*

Zeile 8772Zeile 9027
			in_array($first_character, $active_content_triggers, true) ||
in_array($first_character, $delimiters, true)
)

			in_array($first_character, $active_content_triggers, true) ||
in_array($first_character, $delimiters, true)
)

		{

		{

			$string = "'".$string;

			$string = "'".$string;

		}

		}


foreach($delimiters as $delimiter)
{


foreach($delimiters as $delimiter)
{

Zeile 8785Zeile 9040
		}
}


		}
}


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

return $string;











































































































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

return $string;
}

// Fallback function for 'array_column', PHP < 5.5.0 compatibility
if(!function_exists('array_column'))
{
function array_column($input, $column_key)
{
$values = array();
if(!is_array($input))
{
$input = array($input);
}
foreach($input as $val)
{
if(is_array($val) && isset($val[$column_key]))
{
$values[] = $val[$column_key];
}
elseif(is_object($val) && isset($val->$column_key))
{
$values[] = $val->$column_key;
}
}
return $values;
}
}

/**
* Performs a timing attack safe string comparison.
*
* @param string $known_string The first string to be compared.
* @param string $user_string The second, user-supplied string to be compared.
* @return bool Result of the comparison.
*/
function my_hash_equals($known_string, $user_string)
{
if(version_compare(PHP_VERSION, '5.6.0', '>='))
{
return hash_equals($known_string, $user_string);
}
else
{
$known_string_length = my_strlen($known_string);
$user_string_length = my_strlen($user_string);

if($user_string_length != $known_string_length)
{
return false;
}

$result = 0;

for($i = 0; $i < $known_string_length; $i++)
{
$result |= ord($known_string[$i]) ^ ord($user_string[$i]);
}

return $result === 0;
}
}

/**
* Retrieves all referrals for a specified user
*
* @param int uid
* @param int start position
* @param int total entries
* @param bool false (default) only return display info, true for all info
* @return array
*/
function get_user_referrals($uid, $start=0, $limit=0, $full=false)
{
global $db;

$referrals = $query_options = array();
$uid = (int) $uid;

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

if($start && $limit)
{
$query_options['limit_start'] = $start;
}

if($limit)
{
$query_options['limit'] = $limit;
}

$fields = 'uid, username, usergroup, displaygroup, regdate';
if($full === true)
{
$fields = '*';
}

$query = $db->simple_select('users', $fields, "referrer='{$uid}'", $query_options);

while($referral = $db->fetch_array($query))
{
$referrals[] = $referral;
}

return $referrals;

}

}