Vergleich inc/functions.php - 1.8.12 - 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 322Zeile 323
/**
* Turn a unix timestamp in to a "friendly" date/time format for the user.
*

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

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

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

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

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

Zeile 380Zeile 381
	}

$todaysdate = $yesterdaysdate = '';

	}

$todaysdate = $yesterdaysdate = '';

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

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

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

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

Zeile 470Zeile 471
			{
if($todaysdate == $date)
{

			{
if($todaysdate == $date)
{

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

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

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

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

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

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

				}
}


				}
}


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

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

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

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

		}
}
else

		}
}
else

Zeile 495Zeile 521
		{
if($todaysdate == $date)
{

		{
if($todaysdate == $date)
{

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

				$date = $lang->today;

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

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

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

				$date = $lang->yesterday;

			}
}
else

			}
}
else

Zeile 521Zeile 547
	}

return $date;

	}

return $date;

}


}


/**
* Sends an email using PHP's mail function, formatting it appropriately.
*

/**
* Sends an email using PHP's mail function, formatting it appropriately.
*

Zeile 552Zeile 578
		{
require_once MYBB_ROOT."inc/mailhandlers/smtp.php";
$mail = new SmtpMail();

		{
require_once MYBB_ROOT."inc/mailhandlers/smtp.php";
$mail = new SmtpMail();

		}
else

		}
else

		{
require_once MYBB_ROOT."inc/mailhandlers/php.php";
$mail = new PhpMail();

		{
require_once MYBB_ROOT."inc/mailhandlers/php.php";
$mail = new PhpMail();

Zeile 584Zeile 610
}

/**

}

/**

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


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

 *

 *

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

 * @return string The generated code
*/

 * @return string The generated code
*/

function generate_post_check()

function generate_post_check($rotation_shift=0)

{
global $mybb, $session;

{
global $mybb, $session;

 

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

$seed = $rotation;


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

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

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

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


	else
{

	else
{

		return md5($session->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)

		{

		{

			return false;
}
else
{
if(defined("IN_ADMINCP"))
{

			return false;
}
else
{
if(defined("IN_ADMINCP"))
{

				return false;
}
else
{

				return false;
}
else
{

				error($lang->invalid_post_code);
}
}

				error($lang->invalid_post_code);
}
}

	}

	}

	else
{
return true;

	else
{
return true;

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

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

 */

 */

function get_parent_list($fid)
{
global $forum_cache;

function get_parent_list($fid)
{
global $forum_cache;

Zeile 656Zeile 698
		return $forum_cache[$fid]['parentlist'];
}
else

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

	{

	{

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

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

Zeile 672Zeile 714
 * @return string The query string generated
*/
function build_parent_list($fid, $column="fid", $joiner="OR", $parentlist="")

 * @return string The query string generated
*/
function build_parent_list($fid, $column="fid", $joiner="OR", $parentlist="")

{

{

	if(!$parentlist)
{
$parentlist = get_parent_list($fid);

	if(!$parentlist)
{
$parentlist = get_parent_list($fid);

	}


	}


	$parentsexploded = explode(",", $parentlist);
$builtlist = "(";
$sep = '';

	$parentsexploded = explode(",", $parentlist);
$builtlist = "(";
$sep = '';

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

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

	}


	}


	$builtlist .= ")";

return $builtlist;

	$builtlist .= ")";

return $builtlist;

Zeile 749Zeile 791
	}

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

	}

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

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

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

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

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

Zeile 765Zeile 807
 *
* @param string $error The error message to be shown
* @param string $title The title of the message shown in the title of the page and the error table

 *
* @param string $error The error message to be shown
* @param string $title The title of the message shown in the title of the page and the error table

 */

 */

function error($error="", $title="")
{
global $header, $footer, $theme, $headerinclude, $db, $templates, $lang, $mybb, $plugins;

function error($error="", $title="")
{
global $header, $footer, $theme, $headerinclude, $db, $templates, $lang, $mybb, $plugins;





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

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

	{

	{

		$error = $lang->unknown_error;

		$error = $lang->unknown_error;

	}

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

	}

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

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

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

	}


	}


	if(!$title)
{
$title = $mybb->settings['bbname'];

	if(!$title)
{
$title = $mybb->settings['bbname'];

Zeile 795Zeile 837
	add_breadcrumb($lang->error);

eval("\$errorpage = \"".$templates->get("error")."\";");

	add_breadcrumb($lang->error);

eval("\$errorpage = \"".$templates->get("error")."\";");

	output_page($errorpage);


	output_page($errorpage);


	exit;
}


	exit;
}


Zeile 811Zeile 853
function inline_error($errors, $title="", $json_data=array())
{
global $theme, $mybb, $db, $lang, $templates;

function inline_error($errors, $title="", $json_data=array())
{
global $theme, $mybb, $db, $lang, $templates;





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

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

Zeile 842Zeile 884
	$errorlist = '';

foreach($errors as $error)

	$errorlist = '';

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 874Zeile 916
		// Send our headers.
header("Content-type: application/json; charset={$lang->settings['charset']}");
echo json_encode(array("errors" => array($lang->error_nopermission_user_ajax)));

		// Send our headers.
header("Content-type: application/json; charset={$lang->settings['charset']}");
echo json_encode(array("errors" => array($lang->error_nopermission_user_ajax)));

		exit;
}


		exit;
}


	if($mybb->user['uid'])
{
$lang->error_nopermission_user_username = $lang->sprintf($lang->error_nopermission_user_username, htmlspecialchars_uni($mybb->user['username']));

	if($mybb->user['uid'])
{
$lang->error_nopermission_user_username = $lang->sprintf($lang->error_nopermission_user_username, htmlspecialchars_uni($mybb->user['username']));

Zeile 1005Zeile 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 1041Zeile 1094
	}

if($to > $pages)

	}

if($to > $pages)

	{

	{

		$to = $pages;
$from = $pages-$mybb->settings['maxmultipagelinks']+1;
if($from <= 0)

		$to = $pages;
$from = $pages-$mybb->settings['maxmultipagelinks']+1;
if($from <= 0)

Zeile 1085Zeile 1138
		else
{
eval("\$mppage .= \"".$templates->get("multipage_page")."\";");

		else
{
eval("\$mppage .= \"".$templates->get("multipage_page")."\";");

		}
}

		}
}


$end = '';
if($to < $pages)


$end = '';
if($to < $pages)

Zeile 1098Zeile 1151

$page_url = fetch_page_url($url, $pages);
eval("\$end = \"".$templates->get("multipage_end")."\";");


$page_url = fetch_page_url($url, $pages);
eval("\$end = \"".$templates->get("multipage_end")."\";");

	}


	}


	$nextpage = '';
if($page < $pages)
{

	$nextpage = '';
if($page < $pages)
{

Zeile 1114Zeile 1167
		// When the second parameter is set to 1, fetch_page_url thinks it's the first page and removes it from the URL as it's unnecessary
$jump_url = fetch_page_url($url, 1);
eval("\$jumptopage = \"".$templates->get("multipage_jump_page")."\";");

		// When the second parameter is set to 1, fetch_page_url thinks it's the first page and removes it from the URL as it's unnecessary
$jump_url = fetch_page_url($url, 1);
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)

	{

	{

		eval("\$multipage = \"".$templates->get("multipage_breadcrumb")."\";");

		eval("\$multipage = \"".$templates->get("multipage_breadcrumb")."\";");

	}

	}

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

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





	return $multipage;

	return $multipage;

}


}


/**
* Generate a page URL for use by the multipage function
*

/**
* Generate a page URL for use by the multipage function
*

Zeile 1161Zeile 1214
		else
{
$url .= "&amp;";

		else
{
$url .= "&amp;";

		}


		}


		$url .= "page=$page";

		$url .= "page=$page";

	}

	}

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

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





	return $url;
}

/**
* Fetch the permissions for a specific user

	return $url;
}

/**
* 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 == 0)
{

	if($uid === null)
{

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

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

 
	}

// Its a guest. Return the group permissions directly from cache
if($uid == 0)
{
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.

	}

// 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($user_cache[$uid]['permissions'])
{

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

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

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

		}

		}


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


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

		if(!$user_cache[$uid])

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

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

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





		// Collect group permissions.
$gid = $user_cache[$uid]['usergroup'].",".$user_cache[$uid]['additionalgroups'];
$groupperms = usergroup_permissions($gid);

		// Collect group permissions.
$gid = $user_cache[$uid]['usergroup'].",".$user_cache[$uid]['additionalgroups'];
$groupperms = usergroup_permissions($gid);

Zeile 1211Zeile 1270
		// Store group permissions in user cache.
$user_cache[$uid]['permissions'] = $groupperms;
return $groupperms;

		// Store group permissions in user cache.
$user_cache[$uid]['permissions'] = $groupperms;
return $groupperms;

	}

	}

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

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

Zeile 1257Zeile 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

Zeile 1334Zeile 1393

$gid = $user['usergroup'].",".$user['additionalgroups'];
$groupperms = usergroup_permissions($gid);


$gid = $user['usergroup'].",".$user['additionalgroups'];
$groupperms = usergroup_permissions($gid);

		}

		}

		else
{
$gid = $mybb->user['usergroup'];

		else
{
$gid = $mybb->user['usergroup'];

Zeile 1343Zeile 1402
			{
$gid .= ",".$mybb->user['additionalgroups'];
}

			{
$gid .= ",".$mybb->user['additionalgroups'];
}





			$groupperms = $mybb->usergroup;
}
}

if(!is_array($forum_cache))

			$groupperms = $mybb->usergroup;
}
}

if(!is_array($forum_cache))

	{

	{

		$forum_cache = cache_forums();

if(!$forum_cache)

		$forum_cache = cache_forums();

if(!$forum_cache)

Zeile 1381Zeile 1440
			}
}
return $cached_forum_permissions[$gid];

			}
}
return $cached_forum_permissions[$gid];

	}
}

	}
}


/**
* Fetches the permissions for a specific forum/group applying the inheritance scheme.


/**
* Fetches the permissions for a specific forum/group applying the inheritance scheme.

Zeile 1398Zeile 1457
	global $groupscache, $forum_cache, $fpermcache, $mybb, $fpermfields;

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

	global $groupscache, $forum_cache, $fpermcache, $mybb, $fpermfields;

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





	if(empty($fpermcache[$fid])) // This forum has no custom or inherited permissions so lets just return the group permissions
{
return $groupperms;

	if(empty($fpermcache[$fid])) // This forum has no custom or inherited permissions so lets just return the group permissions
{
return $groupperms;

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

			{

			{

				$level_permissions = $groupscache[$gid];

				$level_permissions = $groupscache[$gid];

			}

			}


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


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

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

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

			}


			}


			if($level_permissions["canview"] && empty($level_permissions["canonlyviewownthreads"]))
{
$only_view_own_threads = 0;

			if($level_permissions["canview"] && empty($level_permissions["canonlyviewownthreads"]))
{
$only_view_own_threads = 0;

Zeile 1475Zeile 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 1488Zeile 1591
function check_forum_password($fid, $pid=0, $return=false)
{
global $mybb, $header, $footer, $headerinclude, $theme, $templates, $lang, $forum_cache;

function check_forum_password($fid, $pid=0, $return=false)
{
global $mybb, $header, $footer, $headerinclude, $theme, $templates, $lang, $forum_cache;





	$showform = true;

if(!is_array($forum_cache))

	$showform = true;

if(!is_array($forum_cache))

	{

	{

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

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

	}

	}


// Loop through each of parent forums to ensure we have a password for them too
if(isset($forum_cache[$fid]['parentlist']))


// Loop through each of parent forums to ensure we have a password for them too
if(isset($forum_cache[$fid]['parentlist']))

Zeile 1507Zeile 1610
		rsort($parents);
}
if(!empty($parents))

		rsort($parents);
}
if(!empty($parents))

	{

	{

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

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

Zeile 1515Zeile 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 1540Zeile 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 1761Zeile 1863
				if(isset($modperms[$action]) && $modperms[$action] == 1)
{
return true;

				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 1779Zeile 1937
function get_post_icons()
{
global $mybb, $cache, $icon, $theme, $templates, $lang;

function get_post_icons()
{
global $mybb, $cache, $icon, $theme, $templates, $lang;





	if(isset($mybb->input['icon']))
{
$icon = $mybb->get_input('icon');

	if(isset($mybb->input['icon']))
{
$icon = $mybb->get_input('icon');

Zeile 1788Zeile 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 1810Zeile 1968
		else
{
$checked = '';

		else
{
$checked = '';

		}


		}


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


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


Zeile 1834Zeile 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 1875Zeile 2034
	}

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

	}

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

	{

	{

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

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

	}

	}


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'])
{
$cookie .= "; Secure";

	}

if($mybb->settings['cookiesecureflag'])
{
$cookie .= "; Secure";

	}

$mybb->cookies[$name] = $value;


	}

$mybb->cookies[$name] = $value;


	header($cookie, false);
}


	header($cookie, false);
}


Zeile 1921Zeile 2090
	global $mybb;

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

	global $mybb;

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

	{
return false;
}

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

	{
return false;
}

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


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


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

	}

	}

	else
{
return 0;

	else
{
return 0;

	}
}

/**

	}
}

/**

 * Set a serialised cookie array.
*
* @param string $name The cookie identifier.

 * Set a serialised cookie array.
*
* @param string $name The cookie identifier.

Zeile 1953Zeile 2122
	if(isset($cookie[$name]))
{
$newcookie = my_unserialize($cookie[$name]);

	if(isset($cookie[$name]))
{
$newcookie = my_unserialize($cookie[$name]);

	}

	}

	else
{
$newcookie = array();

	else
{
$newcookie = array();

Zeile 1969Zeile 2138

/*
* Arbitrary limits for _safe_unserialize()


/*
* Arbitrary limits for _safe_unserialize()

 */

 */

define('MAX_SERIALIZED_INPUT_LENGTH', 10240);
define('MAX_SERIALIZED_ARRAY_LENGTH', 256);
define('MAX_SERIALIZED_ARRAY_DEPTH', 5);

define('MAX_SERIALIZED_INPUT_LENGTH', 10240);
define('MAX_SERIALIZED_ARRAY_LENGTH', 256);
define('MAX_SERIALIZED_ARRAY_DEPTH', 5);

Zeile 1997Zeile 2166
		return false;
}


		return false;
}


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

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



/*
* states:


/*
* states:

Zeile 2017Zeile 2185
			$str = substr($str, 1);
}
else if($type == 'N' && $str[1] == ';')

			$str = substr($str, 1);
}
else if($type == 'N' && $str[1] == ';')

		{

		{

			$value = null;
$str = substr($str, 2);
}

			$value = null;
$str = substr($str, 2);
}

Zeile 2268Zeile 2436
{
global $mybb, $lang;


{
global $mybb, $lang;


	$serverload = array();


	$serverload = array();


	// DIRECTORY_SEPARATOR checks if running windows
if(DIRECTORY_SEPARATOR != '\\')
{

	// DIRECTORY_SEPARATOR checks if running windows
if(DIRECTORY_SEPARATOR != '\\')
{

Zeile 2507Zeile 2675
				if((int)$changes[$counter] != 0)
{
$update_query[$counter] = $forum[$counter] + $changes[$counter];

				if((int)$changes[$counter] != 0)
{
$update_query[$counter] = $forum[$counter] + $changes[$counter];

				}
}
else
{
$update_query[$counter] = $changes[$counter];
}

// Less than 0? That's bad
if(isset($update_query[$counter]) && $update_query[$counter] < 0)
{
$update_query[$counter] = 0;
}

				}
}
else
{
$update_query[$counter] = $changes[$counter];
}

// Less than 0? That's bad
if(isset($update_query[$counter]) && $update_query[$counter] < 0)
{
$update_query[$counter] = 0;
}

		}
}


		}
}


Zeile 2838Zeile 3006
 * @return bool
*/
function delete_thread($tid)

 * @return bool
*/
function delete_thread($tid)

{

{

	global $moderation;

	global $moderation;





	if(!is_object($moderation))
{
require_once MYBB_ROOT."inc/class_moderation.php";

	if(!is_object($moderation))
{
require_once MYBB_ROOT."inc/class_moderation.php";

Zeile 2852Zeile 3020

/**
* Deletes a post from the database


/**
* Deletes a post from the database

 *

 *

 * @param int $pid The thread ID
* @return bool
*/
function delete_post($pid)
{
global $moderation;

 * @param int $pid The thread ID
* @return bool
*/
function delete_post($pid)
{
global $moderation;





	if(!is_object($moderation))
{
require_once MYBB_ROOT."inc/class_moderation.php";
$moderation = new Moderation;

	if(!is_object($moderation))
{
require_once MYBB_ROOT."inc/class_moderation.php";
$moderation = new Moderation;

	}


	}


	return $moderation->delete_post($pid);
}


	return $moderation->delete_post($pid);
}


Zeile 2905Zeile 3073
	}

if(!is_array($permissioncache))

	}

if(!is_array($permissioncache))

	{

	{

		$permissioncache = forum_permissions();
}


		$permissioncache = forum_permissions();
}


Zeile 2945Zeile 3113
		if($showextras == 0)
{
$template = "special";

		if($showextras == 0)
{
$template = "special";

		}

		}

		else
{
$template = "advanced";

if(strpos(FORUM_URL, '.html') !== false)

		else
{
$template = "advanced";

if(strpos(FORUM_URL, '.html') !== false)

			{

			{

				$forum_link = "'".str_replace('{fid}', "'+option+'", FORUM_URL)."'";
}
else
{
$forum_link = "'".str_replace('{fid}', "'+option", FORUM_URL);

				$forum_link = "'".str_replace('{fid}', "'+option+'", FORUM_URL)."'";
}
else
{
$forum_link = "'".str_replace('{fid}', "'+option", FORUM_URL);

			}

			}

		}

eval("\$forumjump = \"".$templates->get("forumjump_".$template)."\";");

		}

eval("\$forumjump = \"".$templates->get("forumjump_".$template)."\";");

Zeile 3025Zeile 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 3113Zeile 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 3214Zeile 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 3384Zeile 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 3795Zeile 4026
	{
$pid = (int)$data['pid'];
unset($data['pid']);

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

 
	}

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

	}

// Any remaining extra data - we my_serialize and insert in to its own column
if(is_array($data))
{
$data = my_serialize($data);

	}

// Any remaining extra data - we my_serialize and insert in to its own column
if(is_array($data))
{
$data = my_serialize($data);

	}


	}


	$sql_array = array(
"uid" => (int)$mybb->user['uid'],
"dateline" => TIME_NOW,

	$sql_array = array(
"uid" => (int)$mybb->user['uid'],
"dateline" => TIME_NOW,

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

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

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


















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

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

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

}

/**

}

/**

Zeile 3982Zeile 4236
	elseif($size >= 1099511627776)
{
$size = my_number_format(round(($size / 1099511627776), 2))." ".$lang->size_tb;

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

	}

	}

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

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

Zeile 4005Zeile 4259
	else
{
$size = my_number_format($size)." ".$lang->size_bytes;

	else
{
$size = my_number_format($size)." ".$lang->size_bytes;

	}

	}


return $size;
}


return $size;
}

Zeile 4017Zeile 4271
 * @return string The friendly time duration
*/
function format_time_duration($time)

 * @return string The friendly time duration
*/
function format_time_duration($time)

{

{

	global $lang;

	global $lang;





	if(!is_numeric($time))
{
return $lang->na;

	if(!is_numeric($time))
{
return $lang->na;

Zeile 4028Zeile 4282
	if(round(1000000 * $time, 2) < 1000)
{
$time = number_format(round(1000000 * $time, 2))." μs";

	if(round(1000000 * $time, 2) < 1000)
{
$time = number_format(round(1000000 * $time, 2))." μs";

	}

	}

	elseif(round(1000000 * $time, 2) >= 1000 && round(1000000 * $time, 2) < 1000000)

	elseif(round(1000000 * $time, 2) >= 1000 && round(1000000 * $time, 2) < 1000000)

	{

	{

		$time = number_format(round((1000 * $time), 2))." ms";
}
else

		$time = number_format(round((1000 * $time), 2))." ms";
}
else

Zeile 4040Zeile 4294

return $time;
}


return $time;
}





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

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

Zeile 4074Zeile 4328
				if(my_substr($attach_icons_schemes[$ext], 0, 1) != "/")
{
$attach_icons_schemes[$ext] = "../".$attach_icons_schemes[$ext];

				if(my_substr($attach_icons_schemes[$ext], 0, 1) != "/")
{
$attach_icons_schemes[$ext] = "../".$attach_icons_schemes[$ext];

				}

				}

			}
elseif(defined("IN_PORTAL"))
{

			}
elseif(defined("IN_PORTAL"))
{

Zeile 4096Zeile 4350
	else
{
if(defined("IN_ADMINCP"))

	else
{
if(defined("IN_ADMINCP"))

		{

		{

			$theme['imgdir'] = "../images";

			$theme['imgdir'] = "../images";

		}

		}

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

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





		$icon = "{$theme['imgdir']}/attachtypes/unknown.png";

$name = $lang->unknown;

		$icon = "{$theme['imgdir']}/attachtypes/unknown.png";

$name = $lang->unknown;

	}

	}


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


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

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


		$permissioncache = forum_permissions();
}


	$password_forums = $unviewable = array();

	$unviewable = array();

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

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

		}
else
{

		}
else
{

			$perms = $mybb->usergroup;
}

			$perms = $mybb->usergroup;
}





		$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 4164Zeile 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;

				}
}
}

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;

	return $unviewableforums;

}

/**

}

/**

 * Fixes mktime for dates earlier than 1970
*
* @param string $format The date format to use

 * Fixes mktime for dates earlier than 1970
*
* @param string $format The date format to use

Zeile 4223Zeile 4474
				if(isset($navbits[$key+2]))
{
$sep = $navsep;

				if(isset($navbits[$key+2]))
{
$sep = $navsep;

				}

				}

				else

				else

				{

				{

					$sep = "";
}


					$sep = "";
}


Zeile 4234Zeile 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 4254Zeile 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 4357Zeile 4606

/**
* Resets the breadcrumb navigation to the first item, and clears the rest


/**
* Resets the breadcrumb navigation to the first item, and clears the rest

 */

 */

function reset_breadcrumb()
{
global $navbits;

function reset_breadcrumb()
{
global $navbits;

Zeile 4534Zeile 4783
		echo "<table style=\"background-color: #666;\" width=\"95%\" cellpadding=\"4\" cellspacing=\"1\" align=\"center\">\n";
echo "<tr>\n";
echo "<td style=\"background-color: #ccc;\"><strong>Templates Used (Loaded for this Page) - ".count($templates->cache)." Total</strong></td>\n";

		echo "<table style=\"background-color: #666;\" width=\"95%\" cellpadding=\"4\" cellspacing=\"1\" align=\"center\">\n";
echo "<tr>\n";
echo "<td style=\"background-color: #ccc;\"><strong>Templates Used (Loaded for this Page) - ".count($templates->cache)." Total</strong></td>\n";

		echo "</tr>\n";
echo "<tr>\n";
echo "<td style=\"background: #fff;\">".implode(", ", array_keys($templates->cache))."</td>\n";
echo "</tr>\n";
echo "</table>\n";
echo "<br />\n";
}


		echo "</tr>\n";
echo "<tr>\n";
echo "<td style=\"background: #fff;\">".implode(", ", array_keys($templates->cache))."</td>\n";
echo "</tr>\n";
echo "</table>\n";
echo "<br />\n";
}


	if(count($templates->uncached_templates) > 0)
{
echo "<table style=\"background-color: #666;\" width=\"95%\" cellpadding=\"4\" cellspacing=\"1\" align=\"center\">\n";

	if(count($templates->uncached_templates) > 0)
{
echo "<table style=\"background-color: #666;\" width=\"95%\" cellpadding=\"4\" cellspacing=\"1\" align=\"center\">\n";

Zeile 4568Zeile 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 4935
	$stamp %= $msecs;
$seconds = $stamp;


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


	if($years == 1)


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

	{

	{

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






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

	}

	}

	else if($years > 1)

	elseif($months > 0)

	{

	{

		$nicetime['years'] = $years.$lang_years;





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

	}

	}


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

































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

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

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

	}

	}

	else if($months > 1)



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

	{

	{

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








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

	}


	}


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

if($days == 1)

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










	{

	{

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




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

	}

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

	}

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

Zeile 4813Zeile 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;
}

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

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

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


$user = get_user($uid);

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

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

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


$user = get_user($uid);

if($user['usergroup'] == $leavegroup)
{
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'])

Zeile 4894Zeile 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 4916Zeile 5194
	elseif(!empty($_ENV['PHP_SELF']))
{
$location = htmlspecialchars_uni($_ENV['PHP_SELF']);

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

	}

	}

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

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

	{

	{

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

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

	}

	}

	else

	else

	{

	{

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

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

	}

if($quick)
{

	}

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 4951Zeile 5228
				}

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

				}

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

			}
}


			}
}


		return array('location' => $location, 'form_html' => $form_html, 'form_method' => $mybb->request_method);
}
else
{

		return array('location' => $location, 'form_html' => $form_html, 'form_method' => $mybb->request_method);
}
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');

foreach($post_array as $var)
{

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

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 5030Zeile 5314
		$query = $db->simple_select('themes', 'tid, name, pid, allowedgroups', "pid!='0'");

while($theme = $db->fetch_array($query))

		$query = $db->simple_select('themes', 'tid, name, pid, allowedgroups', "pid!='0'");

while($theme = $db->fetch_array($query))

		{

		{

			$tcache[$theme['pid']][$theme['tid']] = $theme;
}
}

			$tcache[$theme['pid']][$theme['tid']] = $theme;
}
}

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

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

		}

		}


return $themeselect;


return $themeselect;

	}

	}

	else
{
return false;

	else
{
return false;

Zeile 5085Zeile 5369

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


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

 *

 *

 * @param int $tid The theme id of the theme.
* @return boolean|array False if no valid theme, Array with the theme data otherwise
*/

 * @param int $tid The theme id of the theme.
* @return boolean|array False if no valid theme, Array with the theme data otherwise
*/

Zeile 5157Zeile 5441
	else
{
$parts = explode('.', $number);

	else
{
$parts = explode('.', $number);





		if(isset($parts[1]))

		if(isset($parts[1]))

		{

		{

			$decimals = my_strlen($parts[1]);
}
else

			$decimals = my_strlen($parts[1]);
}
else

Zeile 5168Zeile 5452
		}

return number_format((double)$number, $decimals, $mybb->settings['decpoint'], $mybb->settings['thousandssep']);

		}

return number_format((double)$number, $decimals, $mybb->settings['decpoint'], $mybb->settings['thousandssep']);

	}

	}

}

/**

}

/**

Zeile 5191Zeile 5475
	}

if($charset == "utf-8")

	}

if($charset == "utf-8")

	{
return $str;
}


	{
return $str;
}


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

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

Zeile 5203Zeile 5487
	if(!isset($use_mb))
{
$use_mb = function_exists("mb_convert_encoding");

	if(!isset($use_mb))
{
$use_mb = function_exists("mb_convert_encoding");

	}


	}


	if($use_iconv || $use_mb)
{
if($to)

	if($use_iconv || $use_mb)
{
if($to)

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

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

		}

		}

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

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

Zeile 5263Zeile 5547
 * @param int $day The day of the birthday
* @param int $year The year of the bithday
* @return int The numeric day of the week for the birthday

 * @param int $day The day of the birthday
* @param int $year The year of the bithday
* @return int The numeric day of the week for the birthday

 */

 */

function get_weekday($month, $day, $year)
{
$h = 4;

function get_weekday($month, $day, $year)
{
$h = 4;

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

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





			for($m = $j[$k]; $m >= 1; $m--)
{
$h--;

			for($m = $j[$k]; $m >= 1; $m--)
{
$h--;

Zeile 5299Zeile 5583
 *
* @param int $in The year.
* @return array The number of days in each month of that year

 *
* @param int $in The year.
* @return array The number of days in each month of that year

 */

 */

function get_bdays($in)
{
return array(

function get_bdays($in)
{
return array(

		31,

		31,

		($in % 4 == 0 && ($in % 100 > 0 || $in % 400 == 0) ? 29 : 28),

		($in % 4 == 0 && ($in % 100 > 0 || $in % 400 == 0) ? 29 : 28),

		31,
30,
31,

		31,
30,
31,

		30,
31,

		30,
31,

		31,
30,

		31,
30,

		31,
30,
31

		31,
30,
31

Zeile 5358Zeile 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 5625Zeile 5908
	}

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 5638Zeile 5948
function my_strpos($haystack, $needle, $offset=0)
{
if($needle == '')

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

	{
return false;

	{
return false;

	}

if(function_exists("mb_strpos"))

	}

if(function_exists("mb_strpos"))

Zeile 5663Zeile 5973
function my_strtoupper($string)
{
if(function_exists("mb_strtoupper"))

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

	{

	{

		$string = mb_strtoupper($string);

		$string = mb_strtoupper($string);

	}

	}

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

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





	return $string;

	return $string;

}

/**

}

/**

 * Returns any html entities to their original character
*
* @param string $string The string to un-htmlentitize.

 * Returns any html entities to their original character
*
* @param string $string The string to un-htmlentitize.

Zeile 5683Zeile 5993
function unhtmlentities($string)
{
// Replace numeric entities

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

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

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


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


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

Zeile 5700Zeile 6010
 * @return string|bool The characterized ascii. False on failure
*/
function unichr($c)

 * @return string|bool The characterized ascii. False on failure
*/
function unichr($c)

{

{

	if($c <= 0x7F)

	if($c <= 0x7F)

	{

	{

		return chr($c);
}
else if($c <= 0x7FF)

		return chr($c);
}
else if($c <= 0x7FF)

	{

	{

		return chr(0xC0 | $c >> 6) . chr(0x80 | $c & 0x3F);
}
else if($c <= 0xFFFF)
{
return chr(0xE0 | $c >> 12) . chr(0x80 | $c >> 6 & 0x3F)

		return chr(0xC0 | $c >> 6) . chr(0x80 | $c & 0x3F);
}
else if($c <= 0xFFFF)
{
return chr(0xE0 | $c >> 12) . chr(0x80 | $c >> 6 & 0x3F)

									. chr(0x80 | $c & 0x3F);

									. chr(0x80 | $c & 0x3F);

	}
else if($c <= 0x10FFFF)

	}
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
*/
function unichr_callback1($matches)
{
return unichr(hexdec($matches[1]));
}

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

}

/**

}

/**

Zeile 5797Zeile 6129
	if(!$username && $uid == 0)
{
// Return Guest phrase for no UID, no guest nickname

	if(!$username && $uid == 0)
{
// Return Guest phrase for no UID, no guest nickname

		return $lang->guest;

		return htmlspecialchars_uni($lang->guest);

	}
elseif($uid == 0)
{

	}
elseif($uid == 0)
{

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

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

		}

		}

		else
{
$link = THREAD_URL;

		else
{
$link = THREAD_URL;

Zeile 6076Zeile 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 6217Zeile 6549
 * @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']))

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







	{

	{

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







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

if(empty($mybb->cookies['failedlogin']))
{
$failedtime = $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['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)

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

return false;
}

			{
$secsleft = (int)($attempts['loginlockoutexpiry'] - $now);
$hoursleft = floor($secsleft / 3600);
$minsleft = floor(($secsleft / 60) % 60);
$secsleft = floor($secsleft % 60);






		// 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)
{
$update_array = array(
'loginattempts' => 1
);
$db->update_query("users", $update_array, "uid = '{$mybb->user['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;

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

return false;

 
		}
// Unlock if enough time has passed
else {

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

// 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 6312Zeile 6653
 * @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;
}







/**
* 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 6338Zeile 6674
		$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 6355Zeile 6691
{
global $db, $mybb;


{
global $db, $mybb;


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

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

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















	$settings = null;

	$settings = '';

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

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

 

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





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

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

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


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



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


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

Zeile 6476Zeile 6803

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


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

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

	usort($words, 'build_highlight_array_sort');


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


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

Zeile 6498Zeile 6825
	}

return $highlight_cache;

	}

return $highlight_cache;

 
}

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

}

/**

}

/**

Zeile 6520Zeile 6859
		$dest .= chr($src);
}
elseif($src <= 0x07ff)

		$dest .= chr($src);
}
elseif($src <= 0x07ff)

	{

	{

		$dest .= chr(0xc0 | ($src >> 6));
$dest .= chr(0x80 | ($src & 0x003f));
}
elseif($src <= 0xffff)

		$dest .= chr(0xc0 | ($src >> 6));
$dest .= chr(0x80 | ($src & 0x003f));
}
elseif($src <= 0xffff)

	{

	{

		$dest .= chr(0xe0 | ($src >> 12));
$dest .= chr(0x80 | (($src >> 6) & 0x003f));
$dest .= chr(0x80 | ($src & 0x003f));

		$dest .= chr(0xe0 | ($src >> 12));
$dest .= chr(0x80 | (($src >> 6) & 0x003f));
$dest .= chr(0x80 | ($src & 0x003f));

Zeile 6540Zeile 6879
	else
{
// Out of range

	else
{
// Out of range

		return false;

		return false;

	}

return $dest;

	}

return $dest;

Zeile 6586Zeile 6925
{
global $cache, $db;


{
global $cache, $db;


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


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


	if($banned_cache === false)

	if($banned_cache === false)

	{

	{

		// Failed to read cache, see if we can rebuild it
$cache->update_bannedemails();
$banned_cache = $cache->read("bannedemails");

		// Failed to read cache, see if we can rebuild it
$cache->update_bannedemails();
$banned_cache = $cache->read("bannedemails");

Zeile 6601Zeile 6940
		{
// Make regular expression * match
$banned_email['filter'] = str_replace('\*', '(.*)', preg_quote($banned_email['filter'], '#'));

		{
// Make regular expression * match
$banned_email['filter'] = str_replace('\*', '(.*)', preg_quote($banned_email['filter'], '#'));





			if(preg_match("#{$banned_email['filter']}#i", $email))
{
// Updating last use

			if(preg_match("#{$banned_email['filter']}#i", $email))
{
// Updating last use

Zeile 6631Zeile 6970

$banned_ips = $cache->read("bannedips");
if(!is_array($banned_ips))


$banned_ips = $cache->read("bannedips");
if(!is_array($banned_ips))

	{

	{

		return false;
}


		return false;
}


Zeile 6661Zeile 7000
		{
// Updating last use
if($update_lastuse == true)

		{
// Updating last use
if($update_lastuse == true)

			{

			{

				$db->update_query("banfilters", array("lastuse" => TIME_NOW), "fid='{$banned_ip['fid']}'");
}
return true;

				$db->update_query("banfilters", array("lastuse" => TIME_NOW), "fid='{$banned_ip['fid']}'");
}
return true;

Zeile 6739Zeile 7078
	global $mybb, $lang, $templates;

$timezones = get_supported_timezones();

	global $mybb, $lang, $templates;

$timezones = get_supported_timezones();





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

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

Zeile 6817Zeile 7156
	)
{
return false;

	)
{
return false;

	}

	}


$addresses = get_ip_by_hostname($url_components['host']);
$destination_address = $addresses[0];


$addresses = get_ip_by_hostname($url_components['host']);
$destination_address = $addresses[0];

Zeile 6894Zeile 7233
			$curlopt[10203] = array(
$url_components['host'].':'.$url_components['port'].':'.$destination_address
);

			$curlopt[10203] = array(
$url_components['host'].':'.$url_components['port'].':'.$destination_address
);

		}


		}


		if(!empty($post_body))
{
$curlopt[CURLOPT_POST] = 1;

		if(!empty($post_body))
{
$curlopt[CURLOPT_POST] = 1;

Zeile 6914Zeile 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 6975Zeile 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 7039Zeile 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 7446Zeile 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 7727Zeile 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 7798Zeile 8137
				{
$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 8457Zeile 8796
	}

$pm['options'] = array(

	}

$pm['options'] = array(

		"signature" => 0,

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

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

Zeile 8542Zeile 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'], '/\\');

Zeile 8618Zeile 8968

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

 * 

 *

 * @return string                 Striped string
*/
function my_strip_tags($string, $allowable_tags = '')

 * @return string                 Striped string
*/
function my_strip_tags($string, $allowable_tags = '')

Zeile 8645Zeile 8996
 * @return string The escaped string
*/
function my_escape_csv($string, $escape_active_content=true)

 * @return string The escaped string
*/
function my_escape_csv($string, $escape_active_content=true)

{

{

	if($escape_active_content)
{
$active_content_triggers = array('=', '+', '-', '@');
$delimiters = array(',', ';', ':', '|', '^', "\n", "\t", " ");

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

	if($escape_active_content)
{
$active_content_triggers = array('=', '+', '-', '@');
$delimiters = array(',', ';', ':', '|', '^', "\n", "\t", " ");

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





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

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

		}


		}


		foreach($delimiters as $delimiter)

		foreach($delimiters as $delimiter)

		{

		{

			foreach($active_content_triggers as $trigger)

			foreach($active_content_triggers as $trigger)

			{

			{

				$string = str_replace($delimiter.$trigger, $delimiter."'".$trigger, $string);
}
}
}


				$string = str_replace($delimiter.$trigger, $delimiter."'".$trigger, $string);
}
}
}


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

}

}