Vergleich inc/functions.php - 1.8.15 - 1.8.22

  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 623Zeile 624
	// Guests get a special string
else
{

	// Guests get a special string
else
{

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

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

	}
}


	}
}


Zeile 868Zeile 869

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

	}

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

Zeile 1036Zeile 1037
	{
return '';
}

	{
return '';
}

 

$page = (int)$page;


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


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

Zeile 1141Zeile 1144
		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 1204
/**
* 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

	}

// User id does not match current user, fetch permissions

Zeile 1520Zeile 1529
	{
$forum_cache = cache_forums();
if(!$forum_cache)

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

		{

		{

			return false;
}
}

			return false;
}
}

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

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

			{

			{

				continue;

				continue;

			}

			}


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


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

Zeile 1551Zeile 1560
	{
$password = $forum_cache[$fid]['password'];
if(isset($mybb->input['pwverify']) && $pid == 0)

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

		{

		{

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

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

			{

			{

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

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

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

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

			{

			{

				$showform = true;

				$showform = true;

			}

			}

			else
{
$showform = false;
}
}

			else
{
$showform = false;
}
}

	}

	}

	else
{
$showform = false;
}

if($return)

	else
{
$showform = false;
}

if($return)

	{

	{

		return $showform;
}


		return $showform;
}


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

if(!empty($user['additionalgroups']))

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

if(!empty($user['additionalgroups']))

	{

	{

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

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





		foreach($extra_groups as $extra_group)

		foreach($extra_groups as $extra_group)

		{

		{

			$groups[] = $extra_group;
}
}

			$groups[] = $extra_group;
}
}

Zeile 1655Zeile 1664
	foreach($mod_cache as $forumid => $forum)
{
if(!is_array($forum) || !in_array($forumid, $parentslist))

	foreach($mod_cache as $forumid => $forum)
{
if(!is_array($forum) || !in_array($forumid, $parentslist))

		{

		{

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

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





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

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

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


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


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

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

Zeile 1699Zeile 1708
				{
continue;
}

				{
continue;
}





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

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

Zeile 1728Zeile 1737
	}

if($uid == 0)

	}

if($uid == 0)

	{

	{

		return false;
}


		return false;
}


Zeile 1758Zeile 1767
					if(isset($modusers['users'][$uid]) && $modusers['users'][$uid]['mid'] && (!$action || !empty($modusers['users'][$uid][$action])))
{
return true;

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

					}

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


					}

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


					foreach($groups as $group)
{
if(trim($group) != '' && isset($modusers['usergroups'][$group]) && (!$action || !empty($modusers['usergroups'][$group][$action])))

					foreach($groups as $group)
{
if(trim($group) != '' && isset($modusers['usergroups'][$group]) && (!$action || !empty($modusers['usergroups'][$group][$action])))

Zeile 1813Zeile 1822
	$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 1859Zeile 1868
 * @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 1917
	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 1932Zeile 1952
	my_setcookie($name, "", $expires);

unset($mybb->cookies[$name]);

	my_setcookie($name, "", $expires);

unset($mybb->cookies[$name]);

}


}


/**
* Get the contents from a serialised cookie array.
*

/**
* Get the contents from a serialised cookie array.
*

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

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

{
global $mybb;


{
global $mybb;


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

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

	{

	{

		return false;

		return false;

	}

$cookie = my_unserialize($mybb->cookies['mybb'][$name]);

if(is_array($cookie) && isset($cookie[$id]))
{
return $cookie[$id];
}
else

	}

$cookie = my_unserialize($mybb->cookies['mybb'][$name]);

if(is_array($cookie) && isset($cookie[$id]))
{
return $cookie[$id];
}
else

	{
return 0;
}

	{
return 0;
}

Zeile 2004Zeile 2024
 * Safe unserialize() replacement
* - accepts a strict subset of PHP's native my_serialized representation
* - does not unserialize objects

 * Safe unserialize() replacement
* - accepts a strict subset of PHP's native my_serialized representation
* - does not unserialize objects

 *

 *

 * @param string $str
* @return mixed
* @throw Exception if $str is malformed or contains unsupported types (e.g., resources, objects)

 * @param string $str
* @return mixed
* @throw Exception if $str is malformed or contains unsupported types (e.g., resources, objects)

Zeile 2022Zeile 2042
		return false;
}


		return false;
}


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

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



/*
* states:


/*
* states:

Zeile 3154Zeile 3173

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 3255Zeile 3274
			"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 3425Zeile 3444
	}

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 4318Zeile 4384
				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 5466Zeile 5530
		$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 5517Zeile 5580
	// Do we have the full month in our output?
// If so there's no need for the short month
if(strpos($display, 'F') !== false)

	// Do we have the full month in our output?
// If so there's no need for the short month
if(strpos($display, 'F') !== false)

	{

	{

		array_pop($find);
array_pop($replace);
}

		array_pop($find);
array_pop($replace);
}

Zeile 5665Zeile 5728
	else
{
$string_length = strlen($string);

	else
{
$string_length = strlen($string);

	}

	}


return $string_length;
}


return $string_length;
}

Zeile 5681Zeile 5744
 */
function my_substr($string, $start, $length=null, $handle_entities = false)
{

 */
function my_substr($string, $start, $length=null, $handle_entities = false)
{

	if($handle_entities)
{

	if($handle_entities)
{

		$string = unhtmlentities($string);
}
if(function_exists("mb_substr"))

		$string = unhtmlentities($string);
}
if(function_exists("mb_substr"))

	{
if($length != null)
{

	{
if($length != null)
{

			$cut_string = mb_substr($string, $start, $length);
}
else
{
$cut_string = mb_substr($string, $start);

			$cut_string = mb_substr($string, $start, $length);
}
else
{
$cut_string = mb_substr($string, $start);

		}

		}

	}
else
{

	}
else
{

Zeile 5706Zeile 5769
		{
$cut_string = substr($string, $start);
}

		{
$cut_string = substr($string, $start);
}

	}


	}


	if($handle_entities)
{
$cut_string = htmlspecialchars_uni($cut_string);
}
return $cut_string;

	if($handle_entities)
{
$cut_string = htmlspecialchars_uni($cut_string);
}
return $cut_string;

}


}


/**
* Lowers the case of a string, mb strings accounted for
*

/**
* Lowers the case of a string, mb strings accounted for
*

Zeile 5726Zeile 5789
	if(function_exists("mb_strtolower"))
{
$string = mb_strtolower($string);

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

	}
else

	}
else

	{
$string = strtolower($string);
}

return $string;

	{
$string = strtolower($string);
}

return $string;

}

}


/**
* Finds a needle in a haystack and returns it position, mb strings accounted for


/**
* Finds a needle in a haystack and returns it position, mb strings accounted for

Zeile 5746Zeile 5809
function my_strpos($haystack, $needle, $offset=0)
{
if($needle == '')

function my_strpos($haystack, $needle, $offset=0)
{
if($needle == '')

	{

	{

		return false;
}


		return false;
}


Zeile 5758Zeile 5821
	{
$position = strpos($haystack, $needle, $offset);
}

	{
$position = strpos($haystack, $needle, $offset);
}





	return $position;
}

/**
* Ups the case of a string, mb strings accounted for

	return $position;
}

/**
* Ups the case of a string, mb strings accounted for

 *

 *

 * @param string $string The string to up.
* @return string The uped string.
*/

 * @param string $string The string to up.
* @return string The uped string.
*/

Zeile 5863Zeile 5926
 * @return string The link to the event poster.
*/
function get_event_poster($event)

 * @return string The link to the event poster.
*/
function get_event_poster($event)

{

{

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

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

Zeile 5879Zeile 5942
function get_event_date($event)
{
global $mybb;

function get_event_date($event)
{
global $mybb;





	$event_date = explode("-", $event['date']);
$event_date = gmmktime(0, 0, 0, $event_date[1], $event_date[0], $event_date[2]);
$event_date = my_date($mybb->settings['dateformat'], $event_date);

	$event_date = explode("-", $event['date']);
$event_date = gmmktime(0, 0, 0, $event_date[1], $event_date[0], $event_date[2]);
$event_date = my_date($mybb->settings['dateformat'], $event_date);





	return $event_date;
}


	return $event_date;
}


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

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

{

{

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

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

	return htmlspecialchars_uni($link);

	return htmlspecialchars_uni($link);

}

/**

}

/**

Zeile 5909Zeile 5972
{
$link = str_replace("{aid}", $aid, ANNOUNCEMENT_URL);
return htmlspecialchars_uni($link);

{
$link = str_replace("{aid}", $aid, ANNOUNCEMENT_URL);
return htmlspecialchars_uni($link);

}

}


/**
* Build the profile link.


/**
* Build the profile link.

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

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

	{

	{

		if($action)
{
$link = THREAD_URL_ACTION;

		if($action)
{
$link = THREAD_URL_ACTION;

Zeile 6347Zeile 6410
 * @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)

function login_attempt_check($uid = 0, $fatal = true)

{

{

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

	global $mybb, $lang, $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'];

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

	}

	}


if(!empty($mybb->cookies['failedlogin']))

	// This user has a cookie lockout, show waiting time
elseif($mybb->cookies['lockoutexpiry'] && $mybb->cookies['lockoutexpiry'] > $now)

	{

	{

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











		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;

	}

	}


// Work out if the user has had more than the allowed number of login attempts
if($loginattempts > $mybb->settings['failedlogincount'])


if($mybb->settings['failedlogincount'] > 0 && $attempts['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;











		// Set the expiry dateline if not set yet
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']);

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





		if(empty($mybb->cookies['failedlogin']))

		if(empty($mybb->cookies['lockoutexpiry']))

		{

		{

			$failedtime = $now;

			$failedtime = $attempts['loginlockoutexpiry'];

		}
else
{

		}
else
{

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

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

 
		// Unlock if enough time has passed
else {





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

			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 6448Zeile 6520

/**
* Checks to see if the email is already in use by another


/**
* Checks to see if the email is already in use by another

 *

 *

 * @param string $email The email to check.
* @param int $uid User ID of the user (updating only)
* @return boolean True when in use, false when not.

 * @param string $email The email to check.
* @param int $uid User ID of the user (updating only)
* @return boolean True when in use, false when not.

Zeile 6463Zeile 6535
		$uid_string = " AND uid != '".(int)$uid."'";
}
$query = $db->simple_select("users", "COUNT(email) as emails", "email = '".$db->escape_string($email)."'{$uid_string}");

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





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

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

Zeile 6489Zeile 6561
	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 6507Zeile 6581
 * @return array PREG compatible array of terms
*/
function build_highlight_array($terms)

 * @return array PREG compatible array of terms
*/
function build_highlight_array($terms)

{

{

	global $mybb;

if($mybb->settings['minsearchword'] < 1)

	global $mybb;

if($mybb->settings['minsearchword'] < 1)

Zeile 6868Zeile 6942

$selected = str_replace("+", "", $selected);
foreach($timezones as $timezone => $label)


$selected = str_replace("+", "", $selected);
foreach($timezones as $timezone => $label)

	{

	{

		$selected_add = "";
if($selected == $timezone)
{

		$selected_add = "";
if($selected == $timezone)
{

Zeile 7040Zeile 7114

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 7165Zeile 7239

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 7572Zeile 7646
 * @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 7853Zeile 7927
	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 8088Zeile 8161
		{
$unique_state = md5(microtime().$unique_state);
$output .= md5($unique_state);

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

		}


		}


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

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

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

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

Zeile 8561Zeile 8634
		$fromid = (int)$mybb->user['uid'];
}
elseif((int)$fromid < 0)

		$fromid = (int)$mybb->user['uid'];
}
elseif((int)$fromid < 0)

	{

	{

		$fromid = 0;
}

		$fromid = 0;
}





	// Build our final PM array
$pm = array(
"subject" => $subject,

	// Build our final PM array
$pm = array(
"subject" => $subject,

Zeile 8575Zeile 8648
		"bccid" => $recipients_bcc,
"do" => '',
"pmid" => ''

		"bccid" => $recipients_bcc,
"do" => '',
"pmid" => ''

	);


	);


	if(isset($session))
{
$pm['ipaddress'] = $session->packedip;
}

$pm['options'] = array(

	if(isset($session))
{
$pm['ipaddress'] = $session->packedip;
}

$pm['options'] = array(

		"signature" => 0,

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

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

Zeile 8607Zeile 8679

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


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

 *

 *

 * @param string $username The username that the user was using.
* @param string $email The email address the user was using.
* @param string $ip_address The IP addres of the user.

 * @param string $username The username that the user was using.
* @param string $email The email address the user was using.
* @param string $ip_address The IP addres of the user.

Zeile 8621Zeile 8693
	if(!is_array($data))
{
$data = array($data);

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

	}

	}


if(!$ip_address)
{


if(!$ip_address)
{

Zeile 8680Zeile 8752
			$cdn_upload_path = $cdn_path . DIRECTORY_SEPARATOR . $file_dir_path;

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

			$cdn_upload_path = $cdn_path . DIRECTORY_SEPARATOR . $file_dir_path;

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

			{

			{

				$dir_exists = @mkdir($cdn_upload_path, 0777, true);
}


				$dir_exists = @mkdir($cdn_upload_path, 0777, true);
}


Zeile 8695Zeile 8767
						$uploaded_path = $cdn_upload_path;
}
}

						$uploaded_path = $cdn_upload_path;
}
}

			}
}

			}
}


if(is_object($plugins))
{


if(is_object($plugins))
{

Zeile 8709Zeile 8781
			);

$plugins->run_hooks('copy_file_to_cdn_end', $hook_args);

			);

$plugins->run_hooks('copy_file_to_cdn_end', $hook_args);

		}
}

		}
}


return $success;
}


return $success;
}

Zeile 8725Zeile 8797
 * @return bool Whether this is a valid url.
*/
function my_validate_url($url, $relative_path=false, $allow_local=false)

 * @return bool Whether this is a valid url.
*/
function my_validate_url($url, $relative_path=false, $allow_local=false)

{

{

	if($allow_local)
{
$regex = '_^(?:(?:https?|ftp)://)(?:\S+(?::\S*)?@)?(?:(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:localhost|(?:(?:[a-z\x{00a1}-\x{ffff}0-9]-*)*[a-z\x{00a1}-\x{ffff}0-9]+)(?:\.(?:[a-z\x{00a1}-\x{ffff}0-9]-*)*[a-z\x{00a1}-\x{ffff}0-9]+)*(?:\.(?:[a-z\x{00a1}-\x{ffff}]{2,}))\.?))(?::\d{2,5})?(?:[/?#]\S*)?$_iuS';

	if($allow_local)
{
$regex = '_^(?:(?:https?|ftp)://)(?:\S+(?::\S*)?@)?(?:(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:localhost|(?:(?:[a-z\x{00a1}-\x{ffff}0-9]-*)*[a-z\x{00a1}-\x{ffff}0-9]+)(?:\.(?:[a-z\x{00a1}-\x{ffff}0-9]-*)*[a-z\x{00a1}-\x{ffff}0-9]+)*(?:\.(?:[a-z\x{00a1}-\x{ffff}]{2,}))\.?))(?::\d{2,5})?(?:[/?#]\S*)?$_iuS';

Zeile 8745Zeile 8817
/**
* 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 8769Zeile 8842
 * @param string $string The string to be escaped
* @param boolean $escape_active_content Whether or not to escape active content trigger characters
* @return string The escaped string

 * @param string $string The string to be escaped
* @param boolean $escape_active_content Whether or not to escape active content trigger characters
* @return string The escaped string

 */

 */

function my_escape_csv($string, $escape_active_content=true)
{
if($escape_active_content)

function my_escape_csv($string, $escape_active_content=true)
{
if($escape_active_content)

Zeile 8799Zeile 8872
	$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;

}

}