Vergleich inc/functions.php - 1.8.15 - 1.8.26

  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 840Zeile 857
	if(!$title)
{
$title = $lang->please_correct_errors;

	if(!$title)
{
$title = $lang->please_correct_errors;

	}


	}


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

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

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

	}

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

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 1171Zeile 1199
			"&amp;page={page}",
"{page}"
);

			"&amp;page={page}",
"{page}"
);





		// Remove "Page 1" to the defacto URL
$url = str_replace($find, array("", "", $page), $url);
return $url;

		// Remove "Page 1" to the defacto URL
$url = str_replace($find, array("", "", $page), $url);
return $url;

Zeile 1191Zeile 1219
		$url .= "page=$page";
}
else

		$url .= "page=$page";
}
else

	{

	{

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


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


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;

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





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

	// 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 1500Zeile 1534
		$current_permissions = $groupperms;
}
return $current_permissions;

		$current_permissions = $groupperms;
}
return $current_permissions;

 
}

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

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

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

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

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

}

/**

}

/**

Zeile 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 1794Zeile 1871
			}
}
}

			}
}
}

 
}

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

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

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

$user_perms = user_permissions($uid);

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

$fids = array();

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

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

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

return $fids;

}

/**

}

/**

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

	}

	}

	else
{
$posticons = '';

	else
{
$posticons = '';

Zeile 1851Zeile 1984

return $posticons;
}


return $posticons;
}





/**
* MyBB setcookie() wrapper.
*

/**
* MyBB setcookie() wrapper.
*

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 1892Zeile 2026
	if($expires > 0)
{
$cookie .= "; expires=".@gmdate('D, d-M-Y H:i:s \\G\\M\\T', $expires);

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

	}


	}


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

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

	{

	{

		$cookie .= "; path={$mybb->settings['cookiepath']}";

		$cookie .= "; path={$mybb->settings['cookiepath']}";

	}


	}


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

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

	{

	{

		$cookie .= "; domain={$mybb->settings['cookiedomain']}";

		$cookie .= "; domain={$mybb->settings['cookiedomain']}";

	}


	}


	if($httponly == true)

	if($httponly == true)

	{

	{

		$cookie .= "; HttpOnly";

		$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 3154Zeile 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 3255Zeile 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 3425Zeile 3568
	}

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 3435Zeile 3625
function build_clickable_smilies()
{
global $cache, $smiliecache, $theme, $templates, $lang, $mybb, $smiliecount;

function build_clickable_smilies()
{
global $cache, $smiliecache, $theme, $templates, $lang, $mybb, $smiliecount;





	if($mybb->settings['smilieinserter'] != 0 && $mybb->settings['smilieinsertercols'] && $mybb->settings['smilieinsertertot'])
{
if(!$smiliecount)

	if($mybb->settings['smilieinserter'] != 0 && $mybb->settings['smilieinsertercols'] && $mybb->settings['smilieinsertertot'])
{
if(!$smiliecount)

		{

		{

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

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

Zeile 3454Zeile 3644
			{
$smilie['image'] = str_replace("{theme}", $theme['imgdir'], $smilie['image']);
$smiliecache[$smilie['sid']] = $smilie;

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

			}
}

unset($smilie);

			}
}

unset($smilie);


if(is_array($smiliecache))
{


if(is_array($smiliecache))
{

Zeile 3465Zeile 3655

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


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

			{

			{

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

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

Zeile 3486Zeile 3676
					$smilie['image'] = str_replace("{theme}", $theme['imgdir'], $smilie['image']);
$smilie['image'] = htmlspecialchars_uni($mybb->get_asset_url($smilie['image']));
$smilie['name'] = htmlspecialchars_uni($smilie['name']);

					$smilie['image'] = str_replace("{theme}", $theme['imgdir'], $smilie['image']);
$smilie['image'] = htmlspecialchars_uni($mybb->get_asset_url($smilie['image']));
$smilie['name'] = htmlspecialchars_uni($smilie['name']);





					// Only show the first text to replace in the box
$temp = explode("\n", $smilie['find']); // assign to temporary variable for php 5.3 compatibility
$smilie['find'] = $temp[0];

					// Only show the first text to replace in the box
$temp = explode("\n", $smilie['find']); // assign to temporary variable for php 5.3 compatibility
$smilie['find'] = $temp[0];





					$find = str_replace(array('\\', "'"), array('\\\\', "\'"), htmlspecialchars_uni($smilie['find']));

$onclick = " onclick=\"MyBBEditor.insertText(' $find ');\"";

					$find = str_replace(array('\\', "'"), array('\\\\', "\'"), htmlspecialchars_uni($smilie['find']));

$onclick = " onclick=\"MyBBEditor.insertText(' $find ');\"";

Zeile 3516Zeile 3706
			}

eval("\$clickablesmilies = \"".$templates->get("smilieinsert")."\";");

			}

eval("\$clickablesmilies = \"".$templates->get("smilieinsert")."\";");

		}

		}

		else
{
$clickablesmilies = "";

		else
{
$clickablesmilies = "";

Zeile 3575Zeile 3765
		return $prefixes_cache[$pid];
}
else if(!empty($prefixes_cache))

		return $prefixes_cache[$pid];
}
else if(!empty($prefixes_cache))

	{

	{

		return $prefixes_cache;
}


		return $prefixes_cache;
}


Zeile 3594Zeile 3784
function build_prefix_select($fid, $selected_pid=0, $multiple=0, $previous_pid=0)
{
global $cache, $db, $lang, $mybb, $templates;

function build_prefix_select($fid, $selected_pid=0, $multiple=0, $previous_pid=0)
{
global $cache, $db, $lang, $mybb, $templates;





	if($fid != 'all')
{
$fid = (int)$fid;

	if($fid != 'all')
{
$fid = (int)$fid;

Zeile 3604Zeile 3794
	if(empty($prefix_cache))
{
// We've got no prefixes to show

	if(empty($prefix_cache))
{
// We've got no prefixes to show

		return '';

		return '';

	}

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

	}

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

Zeile 3621Zeile 3811
				// This prefix is not in our forum list
continue;
}

				// This prefix is not in our forum list
continue;
}

		}


		}


		if(is_member($prefix['groups']) || $prefix['pid'] == $previous_pid)
{
// The current user can use this prefix
$prefixes[$prefix['pid']] = $prefix;
}

		if(is_member($prefix['groups']) || $prefix['pid'] == $previous_pid)
{
// The current user can use this prefix
$prefixes[$prefix['pid']] = $prefix;
}

	}


	}


	if(empty($prefixes))
{
return '';

	if(empty($prefixes))
{
return '';

	}


	}


	$prefixselect = $prefixselect_prefix = '';

if($multiple == 1)

	$prefixselect = $prefixselect_prefix = '';

if($multiple == 1)

	{

	{

		$any_selected = "";
if($selected_pid == 'any')
{
$any_selected = " selected=\"selected\"";

		$any_selected = "";
if($selected_pid == 'any')
{
$any_selected = " selected=\"selected\"";

		}
}


		}
}


	$default_selected = "";
if(((int)$selected_pid == 0) && $selected_pid != 'any')
{

	$default_selected = "";
if(((int)$selected_pid == 0) && $selected_pid != 'any')
{

Zeile 3662Zeile 3852

$prefix['prefix'] = htmlspecialchars_uni($prefix['prefix']);
eval("\$prefixselect_prefix .= \"".$templates->get("post_prefixselect_prefix")."\";");


$prefix['prefix'] = htmlspecialchars_uni($prefix['prefix']);
eval("\$prefixselect_prefix .= \"".$templates->get("post_prefixselect_prefix")."\";");

	}


	}


	if($multiple != 0)
{
eval("\$prefixselect = \"".$templates->get("post_prefixselect_multiple")."\";");

	if($multiple != 0)
{
eval("\$prefixselect = \"".$templates->get("post_prefixselect_multiple")."\";");

Zeile 3693Zeile 3883
	if(empty($prefix_cache))
{
// We've got no prefixes to show

	if(empty($prefix_cache))
{
// We've got no prefixes to show

		return '';

		return '';

	}

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

	}

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

Zeile 3733Zeile 3923
	else if($selected_pid == -1)
{
$default_selected['none'] = ' selected="selected"';

	else if($selected_pid == -1)
{
$default_selected['none'] = ' selected="selected"';

	}

	}

	else if($selected_pid == -2)

	else if($selected_pid == -2)

	{

	{

		$default_selected['any'] = ' selected="selected"';
}


		$default_selected['any'] = ' selected="selected"';
}


Zeile 3743Zeile 3933
	{
$selected = '';
if($prefix['pid'] == $selected_pid)

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

		{

		{

			$selected = ' selected="selected"';
}


			$selected = ' selected="selected"';
}


Zeile 3903Zeile 4093
	else
{
$reputation_class = "reputation_neutral";

	else
{
$reputation_class = "reputation_neutral";

	}

$reputation = my_number_format($reputation);

	}

$reputation = my_number_format($reputation);


if($uid != 0)
{


if($uid != 0)
{

Zeile 3926Zeile 4116
 * @return string Formatted warning level
*/
function get_colored_warning_level($level)

 * @return string Formatted warning level
*/
function get_colored_warning_level($level)

{

{

	global $templates;

$warning_class = '';

	global $templates;

$warning_class = '';

Zeile 3946Zeile 4136
	{
$warning_class = "normal_warning";
}

	{
$warning_class = "normal_warning";
}





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

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

Zeile 3985Zeile 4175
				{
$ip = $val;
break;

				{
$ip = $val;
break;

				}
}

				}
}

		}
}


		}
}


Zeile 4199Zeile 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 4213Zeile 4403

$pwverified = 1;



$pwverified = 1;


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

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


if(!forum_password_validated($forum, true))
{
$pwverified = 0;
}
else





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

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

				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;

				}
}
}

if($perms['canview'] == 0 || $pwverified == 0 || ($only_readable_threads == true && $perms['canviewthreads'] == 0))

				}
}
}

if($perms['canview'] == 0 || $pwverified == 0 || ($only_readable_threads == true && $perms['canviewthreads'] == 0))

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

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

		}
}

		}
}





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

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





	return $unviewableforums;
}

/**
* Fixes mktime for dates earlier than 1970

	return $unviewableforums;
}

/**
* Fixes mktime for dates earlier than 1970

 *

 *

 * @param string $format The date format to use
* @param int $year The year of the date
* @return string The correct date format

 * @param string $format The date format to use
* @param int $year The year of the date
* @return string The correct date format

Zeile 4298Zeile 4485
				if(!empty($navbit['multipage']))
{
if(!$mybb->settings['threadsperpage'] || (int)$mybb->settings['threadsperpage'] < 1)

				if(!empty($navbit['multipage']))
{
if(!$mybb->settings['threadsperpage'] || (int)$mybb->settings['threadsperpage'] < 1)

					{

					{

						$mybb->settings['threadsperpage'] = 20;
}


						$mybb->settings['threadsperpage'] = 20;
}


Zeile 4318Zeile 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 4632Zeile 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 4921Zeile 5103
	}

// Build the new list of additional groups for this user and make sure they're in the right format

	}

// Build the new list of additional groups for this user and make sure they're in the right format

	$usergroups = "";
$usergroups = $user['additionalgroups'].",".$joingroup;
$groupslist = "";
$groups = explode(",", $usergroups);







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

if(!in_array((int)$joingroup, $groups))
{
$groups[] = (int)$joingroup;
$groups = array_diff($groups, array($user['usergroup']));
$groups = array_unique($groups);





	if(is_array($groups))
{
$comma = '';
foreach($groups as $gid)
{
if(trim($gid) != "" && $gid != $user['usergroup'] && !isset($donegroup[$gid]))
{
$groupslist .= $comma.$gid;
$comma = ",";
$donegroup[$gid] = 1;
}
}
}

		$groupslist = implode(',', $groups);

















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

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

	}

	}

}

}





/**
* Remove a user from a specific additional user group
*

/**
* Remove a user from a specific additional user group
*

Zeile 4961Zeile 5134
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);


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

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

if(is_array($groups))


if($user['usergroup'] == $leavegroup)







	{

	{

		foreach($groups as $gid)
{
if(trim($gid) != "" && $leavegroup != $gid && empty($donegroup[$gid]))
{
$groupslist .= $comma.$gid;
$comma = ",";
$donegroup[$gid] = 1;
}
}

		return false;









	}

	}

 

$groups = array_map(
'intval',
explode(',', $user['additionalgroups'])
);
$groups = array_diff($groups, array($leavegroup));
$groups = array_unique($groups);

$groupslist = implode(',', $groups);


$dispupdate = "";
if($leavegroup == $user['displaygroup'])


$dispupdate = "";
if($leavegroup == $user['displaygroup'])

	{

	{

		$dispupdate = ", displaygroup=usergroup";
}


		$dispupdate = ", displaygroup=usergroup";
}


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

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

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

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

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

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

 * @return string The current URL being accessed

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

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

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

 
	global $mybb;


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

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

Zeile 5020Zeile 5190
	elseif(!empty($_SERVER['PHP_SELF']))
{
$location = htmlspecialchars_uni($_SERVER['PHP_SELF']);

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

	}

	}

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

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

	{

	{

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

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

	}

	}

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

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

	}

	}

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

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

	}

	}


if($quick)


if($quick)

	{

	{

		return $location;
}

		return $location;
}









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


	if($fields == true)
{

	if($fields == true)
{

		global $mybb;

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

 

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


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

Zeile 5066Zeile 5235
	}
else
{

	}
else
{

 
		$parameters = array();


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

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

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

			$current_query_string = $_SERVER['QUERY_STRING'];





		}

		}


if((isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] == "POST") || (isset($_ENV['REQUEST_METHOD']) && $_ENV['REQUEST_METHOD'] == "POST"))
{
$post_array = array('action', 'fid', 'pid', 'tid', 'uid', 'eid');


















		else if(isset($_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($mybb->request_method === 'post')
{
$post_array = array('action', 'fid', 'pid', 'tid', 'uid', 'eid');


foreach($post_array as $var)
{


foreach($post_array as $var)
{

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

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

				{

				{

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

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

				}
}

				}
}

 
		}





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

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










		}

return $location;

		}

return $location;

Zeile 5466Zeile 5642
		$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 5727Zeile 5902
	{
$string = mb_strtolower($string);
}

	{
$string = mb_strtolower($string);
}

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

	else
{
$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 5744Zeile 5946
 * @return int|bool false on needle not found, integer position if found
*/
function my_strpos($haystack, $needle, $offset=0)

 * @return int|bool false on needle not found, integer position if found
*/
function my_strpos($haystack, $needle, $offset=0)

{

{

	if($needle == '')

	if($needle == '')

	{

	{

		return false;

		return false;

	}

	}


if(function_exists("mb_strpos"))
{


if(function_exists("mb_strpos"))
{

Zeile 5760Zeile 5962
	}

return $position;

	}

return $position;

}

}


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


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

Zeile 5823Zeile 6025
									. chr(0x80 | $c & 0x3F);
}
else if($c <= 0x10FFFF)

									. chr(0x80 | $c & 0x3F);
}
else if($c <= 0x10FFFF)

	{

	{

		return chr(0xF0 | $c >> 18) . chr(0x80 | $c >> 12 & 0x3F)
. chr(0x80 | $c >> 6 & 0x3F)
. chr(0x80 | $c & 0x3F);

		return chr(0xF0 | $c >> 18) . chr(0x80 | $c >> 12 & 0x3F)
. chr(0x80 | $c >> 6 & 0x3F)
. chr(0x80 | $c & 0x3F);

	}

	}

	else
{
return false;
}

	else
{
return false;
}

}

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

}

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

function unichr_callback1($matches)

function unichr_callback1($matches)

{

{

	return unichr(hexdec($matches[1]));
}


	return unichr(hexdec($matches[1]));
}


Zeile 5854Zeile 6056
function unichr_callback2($matches)
{
return unichr($matches[1]);

function unichr_callback2($matches)
{
return unichr($matches[1]);

}


}


/**
* Get the event poster.
*

/**
* Get the event poster.
*

Zeile 5868Zeile 6070
	$event['username'] = format_name($event['username'], $event['usergroup'], $event['displaygroup']);
$event_poster = build_profile_link($event['username'], $event['author']);
return $event_poster;

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

}

/**

}

/**

 * Get the event date.
*
* @param array $event The event data array.

 * Get the event date.
*
* @param array $event The event data array.

Zeile 5885Zeile 6087
	$event_date = my_date($mybb->settings['dateformat'], $event_date);

return $event_date;

	$event_date = my_date($mybb->settings['dateformat'], $event_date);

return $event_date;

}


}


/**
* Get the profile link.
*

/**
* Get the profile link.
*

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

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

	}

	}

	else
{
// Build the profile link for the registered user
if(!empty($target))

	else
{
// Build the profile link for the registered user
if(!empty($target))

		{

		{

			$target = " target=\"{$target}\"";

			$target = " target=\"{$target}\"";

		}

		}


if(!empty($onclick))
{


if(!empty($onclick))
{

Zeile 5948Zeile 6150
		}

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

		}

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

	}
}

	}
}


/**
* Build the forum link.


/**
* Build the forum link.

Zeile 5964Zeile 6166
	{
$link = str_replace("{fid}", $fid, FORUM_URL_PAGED);
$link = str_replace("{page}", $page, $link);

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

		return htmlspecialchars_uni($link);
}

		return htmlspecialchars_uni($link);
}

	else
{
$link = str_replace("{fid}", $fid, FORUM_URL);

	else
{
$link = str_replace("{fid}", $fid, FORUM_URL);

Zeile 5980Zeile 6182
 * @param int $page (Optional) The page number of the thread.
* @param string $action (Optional) The action we're performing (ex, lastpost, newpost, etc)
* @return string The url to the thread.

 * @param int $page (Optional) The page number of the thread.
* @param string $action (Optional) The action we're performing (ex, lastpost, newpost, etc)
* @return string The url to the thread.

 */

 */

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

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

Zeile 6206Zeile 6408
	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 6232Zeile 6434
	}

return $forum_cache[$fid];

	}

return $forum_cache[$fid];

}


}


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

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

Zeile 6288Zeile 6490
		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 6296Zeile 6498
		{
$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 6317Zeile 6519
	if(!$forum_cache)
{
cache_forums();

	if(!$forum_cache)
{
cache_forums();

	}

	}


$inactive = array();



$inactive = array();


Zeile 6346Zeile 6548
 *
* @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;

if(empty($mybb->cookies['failedlogin']))
{
$failedtime = $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($mybb->settings['failedlogincount'] > 0 && $attempts['loginattempts'] >= $mybb->settings['failedlogincount'])
{
// 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['lockoutexpiry']))
{
$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;

		}

// 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 6444Zeile 6655
function validate_email_format($email)
{
return filter_var($email, FILTER_VALIDATE_EMAIL) !== false;

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

}

}


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


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

Zeile 6489Zeile 6700
	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 6777Zeile 6990
			if(strcmp($ip_range[0], $ip_address) <= 0 && strcmp($ip_range[1], $ip_address) >= 0)
{
$banned = true;

			if(strcmp($ip_range[0], $ip_address) <= 0 && strcmp($ip_range[1], $ip_address) >= 0)
{
$banned = true;

			}
}

			}
}

		elseif($ip_address == $ip_range)
{
$banned = true;

		elseif($ip_address == $ip_range)
{
$banned = true;

Zeile 6859Zeile 7072
 * @param int $selected The selected time zone (defaults to GMT)
* @param boolean $short True to generate a "short" list with just timezone and current time
* @return string

 * @param int $selected The selected time zone (defaults to GMT)
* @param boolean $short True to generate a "short" list with just timezone and current time
* @return string

 */

 */

function build_timezone_select($name, $selected=0, $short=false)
{
global $mybb, $lang, $templates;

function build_timezone_select($name, $selected=0, $short=false)
{
global $mybb, $lang, $templates;

Zeile 6978Zeile 7191
			$post_body .= '&'.urlencode($key).'='.urlencode($val);
}
$post_body = ltrim($post_body, '&');

			$post_body .= '&'.urlencode($key).'='.urlencode($val);
}
$post_body = ltrim($post_body, '&');

	}


	}


	if(function_exists("curl_init"))
{
$fetch_header = $max_redirects > 0;

	if(function_exists("curl_init"))
{
$fetch_header = $max_redirects > 0;

Zeile 7040Zeile 7253

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 7101Zeile 7314
					'ssl' => array(
'verify_peer' => false,
'verify_peer_name' => false,

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

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

					),
));
}

					),
));
}

Zeile 7165Zeile 7379

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 7786
 * @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 8067
	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 8301
		{
$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 8774
		$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 8788
		"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 8819

/**
* 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 8833
	if(!is_array($data))
{
$data = array($data);

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

	}

	}


if(!$ip_address)
{


if(!$ip_address)
{

Zeile 8668Zeile 8880

if(file_exists($file_path))
{


if(file_exists($file_path))
{

 

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


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

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





			if(substr($file_dir_path, 0, my_strlen(MYBB_ROOT)) == MYBB_ROOT)
{
$file_dir_path = str_replace(MYBB_ROOT, '', $file_dir_path);
}

			if(substr($file_dir_path, 0, my_strlen(MYBB_ROOT)) == MYBB_ROOT)
{
$file_dir_path = str_replace(MYBB_ROOT, '', $file_dir_path);
}





			$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 8919
						$uploaded_path = $cdn_upload_path;
}
}

						$uploaded_path = $cdn_upload_path;
}
}

			}
}

			}
}


if(is_object($plugins))
{


if(is_object($plugins))
{

Zeile 8709Zeile 8933
			);

$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 8949
 * @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 8969
/**
* 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 8994
 * @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 9024
	$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;

}

}