Vergleich inc/functions.php - 1.8.8 - 1.8.24

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


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


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

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

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

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

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

			$db->query($query);

			$db->write_query($query);

		}
}


		}
}


Zeile 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 343Zeile 344
	{
if(isset($mybb->user['uid']) && $mybb->user['uid'] != 0 && array_key_exists("timezone", $mybb->user))
{

	{
if(isset($mybb->user['uid']) && $mybb->user['uid'] != 0 && array_key_exists("timezone", $mybb->user))
{

			$offset = $mybb->user['timezone'];

			$offset = (float)$mybb->user['timezone'];

			$dstcorrection = $mybb->user['dst'];
}
elseif(defined("IN_ADMINCP"))
{

			$dstcorrection = $mybb->user['dst'];
}
elseif(defined("IN_ADMINCP"))
{

			$offset =  $mybbadmin['timezone'];

			$offset = (float)$mybbadmin['timezone'];

			$dstcorrection = $mybbadmin['dst'];
}
else
{

			$dstcorrection = $mybbadmin['dst'];
}
else
{

			$offset = $mybb->settings['timezoneoffset'];

			$offset = (float)$mybb->settings['timezoneoffset'];

			$dstcorrection = $mybb->settings['dstcorrection'];
}


			$dstcorrection = $mybb->settings['dstcorrection'];
}


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 400Zeile 401
	if($format == 'relative')
{
// Relative formats both date and time

	if($format == 'relative')
{
// Relative formats both date and time

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


		if($ty != 2 && abs(TIME_NOW - $stamp) < 3600)
{
$diff = TIME_NOW - $stamp;
$relative = array('prefix' => '', 'minute' => 0, 'plural' => $lang->rel_minutes_plural, 'suffix' => $lang->rel_ago);

		if($ty != 2 && abs(TIME_NOW - $stamp) < 3600)
{
$diff = TIME_NOW - $stamp;
$relative = array('prefix' => '', 'minute' => 0, 'plural' => $lang->rel_minutes_plural, 'suffix' => $lang->rel_ago);


if($diff < 0)
{
$diff = abs($diff);
$relative['suffix'] = '';


if($diff < 0)
{
$diff = abs($diff);
$relative['suffix'] = '';

				$relative['prefix'] = $lang->rel_in;
}


				$relative['prefix'] = $lang->rel_in;
}


Zeile 423Zeile 438
			if($diff <= 60)
{
// Less than a minute

			if($diff <= 60)
{
// Less than a minute

				$relative['prefix'] = $lang->rel_less_than;
}

$date = $lang->sprintf($lang->rel_time, $relative['prefix'], $relative['minute'], $relative['plural'], $relative['suffix']);

				$relative['prefix'] = $lang->rel_less_than;
}

$date = $lang->sprintf($lang->rel_time, $relative['prefix'], $relative['minute'], $relative['plural'], $relative['suffix'], $real_date, $real_time);

		}
elseif($ty != 2 && abs(TIME_NOW - $stamp) < 43200)
{

		}
elseif($ty != 2 && abs(TIME_NOW - $stamp) < 43200)
{

Zeile 448Zeile 463
				$relative['plural'] = $lang->rel_hours_single;
}


				$relative['plural'] = $lang->rel_hours_single;
}


			$date = $lang->sprintf($lang->rel_time, $relative['prefix'], $relative['hour'], $relative['plural'], $relative['suffix']);

			$date = $lang->sprintf($lang->rel_time, $relative['prefix'], $relative['hour'], $relative['plural'], $relative['suffix'], $real_date, $real_time);

		}
else
{
if($ty)

		}
else
{
if($ty)

			{

			{

				if($todaysdate == $date)
{

				if($todaysdate == $date)
{

					$date = $lang->today;

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

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

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

					$date = $lang->yesterday;

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

				}
}


				}
}


Zeile 473Zeile 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 570Zeile 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
else
{
return md5($session->useragent.$mybb->config['database']['username'].$mybb->settings['internal']['encryption_key']);
}
}

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




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

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

return md5($seed);
}

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

			return false;
}
else

Zeile 619Zeile 675
	else
{
return true;

	else
{
return true;

	}
}

	}
}


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


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

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

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

	{
return $forum_cache[$fid]['parentlist'];

	{
return $forum_cache[$fid]['parentlist'];

	}
else
{

	}
else
{

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

	if(!$parentlist)

	{

	{

		$parentlist = get_parent_list($fid);

		$parentlist = get_parent_list($fid);

	}


	}


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

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





	foreach($parentsexploded as $key => $val)
{
$builtlist .= "$sep$column='$val'";
$sep = " $joiner ";

	foreach($parentsexploded as $key => $val)
{
$builtlist .= "$sep$column='$val'";
$sep = " $joiner ";

	}

$builtlist .= ")";

	}

$builtlist .= ")";


return $builtlist;
}


return $builtlist;
}

Zeile 688Zeile 744
function cache_forums($force=false)
{
global $forum_cache, $cache;

function cache_forums($force=false)
{
global $forum_cache, $cache;





	if($force == true)
{
$forum_cache = $cache->read("forums", 1);

	if($force == true)
{
$forum_cache = $cache->read("forums", 1);

Zeile 719Zeile 775

$forums = array();
if(!is_array($forums_by_parent))


$forums = array();
if(!is_array($forums_by_parent))

	{

	{

		$forum_cache = cache_forums();
foreach($forum_cache as $forum)
{

		$forum_cache = cache_forums();
foreach($forum_cache as $forum)
{

Zeile 736Zeile 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 783Zeile 839
	eval("\$errorpage = \"".$templates->get("error")."\";");
output_page($errorpage);


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


	exit;
}


	exit;
}


/**
* Produce an error message for displaying inline on a page
*

/**
* Produce an error message for displaying inline on a page
*

Zeile 799Zeile 855
	global $theme, $mybb, $db, $lang, $templates;

if(!$title)

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

if(!$title)

	{

	{

		$title = $lang->please_correct_errors;
}


		$title = $lang->please_correct_errors;
}


Zeile 828Zeile 884
	$errorlist = '';

foreach($errors as $error)

	$errorlist = '';

foreach($errors as $error)

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

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

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

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


return $errors;
}


return $errors;
}

Zeile 846Zeile 902

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


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





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

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





	$db->update_query("sessions", $noperm_array, "sid='{$session->sid}'");

if($mybb->get_input('ajax', MyBB::INPUT_INT))

	$db->update_query("sessions", $noperm_array, "sid='{$session->sid}'");

if($mybb->get_input('ajax', MyBB::INPUT_INT))

Zeile 861Zeile 917
		header("Content-type: application/json; charset={$lang->settings['charset']}");
echo json_encode(array("errors" => array($lang->error_nopermission_user_ajax)));
exit;

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

	}


	}


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

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

	{

	{

		$lang->error_nopermission_user_username = $lang->sprintf($lang->error_nopermission_user_username, htmlspecialchars_uni($mybb->user['username']));
eval("\$errorpage = \"".$templates->get("error_nopermission_loggedin")."\";");
}

		$lang->error_nopermission_user_username = $lang->sprintf($lang->error_nopermission_user_username, htmlspecialchars_uni($mybb->user['username']));
eval("\$errorpage = \"".$templates->get("error_nopermission_loggedin")."\";");
}

Zeile 875Zeile 931
		if($_SERVER['QUERY_STRING'])
{
$redirect_url .= '?'.$_SERVER['QUERY_STRING'];

		if($_SERVER['QUERY_STRING'])
{
$redirect_url .= '?'.$_SERVER['QUERY_STRING'];

		}

$redirect_url = htmlspecialchars_uni($redirect_url);

		}

$redirect_url = htmlspecialchars_uni($redirect_url);


switch($mybb->settings['username_method'])
{


switch($mybb->settings['username_method'])
{

Zeile 907Zeile 963
 * @param string $message The redirection message to be shown
* @param string $title The title of the redirection page
* @param boolean $force_redirect Force the redirect page regardless of settings

 * @param string $message The redirection message to be shown
* @param string $title The title of the redirection page
* @param boolean $force_redirect Force the redirect page regardless of settings

 */

 */

function redirect($url, $message="", $title="", $force_redirect=false)
{
global $header, $footer, $mybb, $theme, $headerinclude, $templates, $lang, $plugins;

function redirect($url, $message="", $title="", $force_redirect=false)
{
global $header, $footer, $mybb, $theme, $headerinclude, $templates, $lang, $plugins;

Zeile 940Zeile 996
	if(!$message)
{
$message = $lang->redirect;

	if(!$message)
{
$message = $lang->redirect;

	}

	}


$time = TIME_NOW;
$timenow = my_date('relative', $time);


$time = TIME_NOW;
$timenow = my_date('relative', $time);

Zeile 966Zeile 1022

run_shutdown();



run_shutdown();


		if(!my_validate_url($url, true))

		if(!my_validate_url($url, true, true))

		{
header("Location: {$mybb->settings['bburl']}/{$url}");
}

		{
header("Location: {$mybb->settings['bburl']}/{$url}");
}

Zeile 974Zeile 1030
		{
header("Location: {$url}");
}

		{
header("Location: {$url}");
}

	}

	}


exit;
}


exit;
}

Zeile 991Zeile 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 1102Zeile 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 1157Zeile 1224
	}

return $url;

	}

return $url;

}


}


/**
* 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 == 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'];
}

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

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

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

Zeile 1207Zeile 1280

/**
* Fetch the usergroup permissions for a specific group or series of groups combined


/**
* Fetch the usergroup permissions for a specific group or series of groups combined

 *

 *

 * @param int|string $gid A list of groups (Can be a single integer, or a list of groups separated by a comma)
* @return array Array of permissions generated for the groups, containing also a list of comma-separated checked groups under 'all_usergroups' index
*/

 * @param int|string $gid A list of groups (Can be a single integer, or a list of groups separated by a comma)
* @return array Array of permissions generated for the groups, containing also a list of comma-separated checked groups under 'all_usergroups' index
*/

Zeile 1219Zeile 1292
	{
$groupscache = $cache->read("usergroups");
}

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





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

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


if(count($groups) == 1)


if(count($groups) == 1)

	{
$groupscache[$gid]['all_usergroups'] = $gid;
return $groupscache[$gid];

	{
$groupscache[$gid]['all_usergroups'] = $gid;
return $groupscache[$gid];

Zeile 1236Zeile 1309
		if(trim($gid) == "" || empty($groupscache[$gid]))
{
continue;

		if(trim($gid) == "" || empty($groupscache[$gid]))
{
continue;

		}


		}


		foreach($groupscache[$gid] as $perm => $access)
{
if(!in_array($perm, $grouppermignore))
{
if(isset($usergroup[$perm]))

		foreach($groupscache[$gid] as $perm => $access)
{
if(!in_array($perm, $grouppermignore))
{
if(isset($usergroup[$perm]))

				{

				{

					$permbit = $usergroup[$perm];

					$permbit = $usergroup[$perm];

				}

				}

				else
{
$permbit = "";

				else
{
$permbit = "";

Zeile 1253Zeile 1326

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


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

				{

				{

					$usergroup[$perm] = 0;
continue;

					$usergroup[$perm] = 0;
continue;

				}


				}


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

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

Zeile 1268Zeile 1341

return $usergroup;
}


return $usergroup;
}





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

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

Zeile 1278Zeile 1351
function usergroup_displaygroup($gid)
{
global $cache, $groupscache, $displaygroupfields;

function usergroup_displaygroup($gid)
{
global $cache, $groupscache, $displaygroupfields;





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

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

	}


	}


	$displaygroup = array();
$group = $groupscache[$gid];


	$displaygroup = array();
$group = $groupscache[$gid];


Zeile 1345Zeile 1418
	}

if(!is_array($fpermcache))

	}

if(!is_array($fpermcache))

	{

	{

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

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

	}

	}


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


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

Zeile 1360Zeile 1433
	else
{
if(empty($cached_forum_permissions[$gid]))

	else
{
if(empty($cached_forum_permissions[$gid]))

		{

		{

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

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

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

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

				{

				{

					foreach($parents as $parent_id)
{
if(!empty($fpermcache[$parent_id][$gid]))

					foreach($parents as $parent_id)
{
if(!empty($fpermcache[$parent_id][$gid]))

Zeile 1422Zeile 1495
			if(empty($level_permissions))
{
$level_permissions = $groupscache[$gid];

			if(empty($level_permissions))
{
$level_permissions = $groupscache[$gid];

			}

			}


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


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

Zeile 1461Zeile 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 1483Zeile 1600
		if(!$forum_cache)
{
return false;

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

	{

	{

		$parents = explode(',', $forum_cache[$fid]['parentlist']);
rsort($parents);
}

		$parents = explode(',', $forum_cache[$fid]['parentlist']);
rsort($parents);
}

Zeile 1500Zeile 1617
			{
continue;
}

			{
continue;
}


if($forum_cache[$parent_id]['password'] != "")
{
check_forum_password($parent_id, $fid);
}


if($forum_cache[$parent_id]['password'] !== "")
{
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;
}
else

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

			{

			{

				eval("\$pwnote = \"".$templates->get("forumdisplay_password_wrongpass")."\";");

				eval("\$pwnote = \"".$templates->get("forumdisplay_password_wrongpass")."\";");

				$showform = true;
}
}

				$showform = true;
}
}

		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;

			}
else
{
$showform = false;
}
}
}

			}
else
{
$showform = false;
}
}
}

	else
{
$showform = false;

	else
{
$showform = false;

Zeile 1755Zeile 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 1767Zeile 1939
	global $mybb, $cache, $icon, $theme, $templates, $lang;

if(isset($mybb->input['icon']))

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

if(isset($mybb->input['icon']))

	{

	{

		$icon = $mybb->get_input('icon');

		$icon = $mybb->get_input('icon');

	}


	}


	$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 1783Zeile 1955
	krsort($posticons);

foreach($posticons as $dbicon)

	krsort($posticons);

foreach($posticons as $dbicon)

	{

	{

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

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





		if($icon == $dbicon['iid'])

		if($icon == $dbicon['iid'])

		{

		{

			$checked = " checked=\"checked\"";
$no_icons_checked = '';
}

			$checked = " checked=\"checked\"";
$no_icons_checked = '';
}

Zeile 1799Zeile 1971
		}

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

		}

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

	}

	}


if(!empty($iconlist))
{


if(!empty($iconlist))
{

Zeile 1820Zeile 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 1831Zeile 2004
	}

if($expires == -1)

	}

if($expires == -1)

	{

	{

		$expires = 0;

		$expires = 0;

	}

	}

	elseif($expires == "" || $expires == null)

	elseif($expires == "" || $expires == null)

	{

	{

		$expires = TIME_NOW + (60*60*24*365); // Make the cookie expire in a years time

		$expires = TIME_NOW + (60*60*24*365); // Make the cookie expire in a years time

	}

	}

	else
{
$expires = TIME_NOW + (int)$expires;

	else
{
$expires = TIME_NOW + (int)$expires;

Zeile 1846Zeile 2019
	$mybb->settings['cookiepath'] = str_replace(array("\n","\r"), "", $mybb->settings['cookiepath']);
$mybb->settings['cookiedomain'] = str_replace(array("\n","\r"), "", $mybb->settings['cookiedomain']);
$mybb->settings['cookieprefix'] = str_replace(array("\n","\r", " "), "", $mybb->settings['cookieprefix']);

	$mybb->settings['cookiepath'] = str_replace(array("\n","\r"), "", $mybb->settings['cookiepath']);
$mybb->settings['cookiedomain'] = str_replace(array("\n","\r"), "", $mybb->settings['cookiedomain']);
$mybb->settings['cookieprefix'] = str_replace(array("\n","\r", " "), "", $mybb->settings['cookieprefix']);





	// Versions of PHP prior to 5.2 do not support HttpOnly cookies and IE is buggy when specifying a blank domain so set the cookie manually
$cookie = "Set-Cookie: {$mybb->settings['cookieprefix']}{$name}=".urlencode($value);

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

	// Versions of PHP prior to 5.2 do not support HttpOnly cookies and IE is buggy when specifying a blank domain so set the cookie manually
$cookie = "Set-Cookie: {$mybb->settings['cookieprefix']}{$name}=".urlencode($value);

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

	}


	}


	if(!empty($mybb->settings['cookiepath']))
{
$cookie .= "; path={$mybb->settings['cookiepath']}";
}

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

	if(!empty($mybb->settings['cookiepath']))
{
$cookie .= "; path={$mybb->settings['cookiepath']}";
}

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


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
















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

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

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

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


header($cookie, false);
}

/**
* Unset a cookie set by MyBB.


header($cookie, false);
}

/**
* Unset a cookie set by MyBB.

 *

 *

 * @param string $name The cookie identifier.
*/
function my_unsetcookie($name)

 * @param string $name The cookie identifier.
*/
function my_unsetcookie($name)

Zeile 1902Zeile 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];

Zeile 1938Zeile 2126
	else
{
$newcookie = array();

	else
{
$newcookie = array();

	}

	}


$newcookie[$id] = $value;
$newcookie = my_serialize($newcookie);


$newcookie[$id] = $value;
$newcookie = my_serialize($newcookie);

Zeile 1954Zeile 2142
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);





/**
* Credits go to https://github.com/piwik
* Safe unserialize() replacement

/**
* Credits go to https://github.com/piwik
* Safe unserialize() replacement

Zeile 1978Zeile 2166
		return false;
}


		return false;
}


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

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



/*
* states:


/*
* states:

Zeile 2031Zeile 2218
		{
// object or unknown/malformed type
return false;

		{
// object or unknown/malformed type
return false;

		}


		}


		switch($state)
{
case 3: // in array, expecting value or another array

		switch($state)
{
case 3: // in array, expecting value or another array

Zeile 2059Zeile 2246
				}

// missing array value

				}

// missing array value

				return false;

				return false;


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


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

Zeile 2147Zeile 2334
function my_unserialize($str)
{
// Ensure we use the byte count for strings even when strlen() is overloaded by mb_strlen()

function my_unserialize($str)
{
// Ensure we use the byte count for strings even when strlen() is overloaded by mb_strlen()

	if(function_exists('mb_internal_encoding') && (((int)ini_get('mbstring.func_overload')) & 2))
{
$mbIntEnc = mb_internal_encoding();
mb_internal_encoding('ASCII');
}

$out = _safe_unserialize($str);

if(isset($mbIntEnc))
{

	if(function_exists('mb_internal_encoding') && (((int)ini_get('mbstring.func_overload')) & 2))
{
$mbIntEnc = mb_internal_encoding();
mb_internal_encoding('ASCII');
}

$out = _safe_unserialize($str);

if(isset($mbIntEnc))
{

		mb_internal_encoding($mbIntEnc);
}


		mb_internal_encoding($mbIntEnc);
}


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

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

 */

 */

function _safe_serialize( $value )
{
if(is_null($value))

function _safe_serialize( $value )
{
if(is_null($value))

Zeile 2218Zeile 2405
/**
* Credits go to https://github.com/piwik
* Wrapper for _safe_serialize() that handles exceptions and multibyte encoding issue

/**
* Credits go to https://github.com/piwik
* Wrapper for _safe_serialize() that handles exceptions and multibyte encoding issue

 *

 *

 * @param mixed $value
* @return string
*/

 * @param mixed $value
* @return string
*/

Zeile 2233Zeile 2420

$out = _safe_serialize($value);
if(isset($mbIntEnc))


$out = _safe_serialize($value);
if(isset($mbIntEnc))

	{

	{

		mb_internal_encoding($mbIntEnc);
}


		mb_internal_encoding($mbIntEnc);
}


Zeile 2274Zeile 2461

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


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

			{
if(strpos(",".$func_blacklist.",", 'exec') !== false)
{
return $lang->unknown;
}
}

			{
if(strpos(",".$func_blacklist.",", 'exec') !== false)
{
return $lang->unknown;
}
}

			// PHP disabled functions?
if($func_blacklist = @ini_get('disable_functions'))
{

			// PHP disabled functions?
if($func_blacklist = @ini_get('disable_functions'))
{

Zeile 2295Zeile 2482
			if(!is_array($serverload))
{
return $lang->unknown;

			if(!is_array($serverload))
{
return $lang->unknown;

			}

			}

		}

		}

	}

	}

	else
{
return $lang->unknown;

	else
{
return $lang->unknown;

Zeile 2310Zeile 2497

/**
* Returns the amount of memory allocated to the script.


/**
* Returns the amount of memory allocated to the script.

 *

 *

 * @return int The amount of memory allocated to the script.
*/
function get_memory_usage()

 * @return int The amount of memory allocated to the script.
*/
function get_memory_usage()

Zeile 2341Zeile 2528
	{
// Update stats after all changes are done
add_shutdown('update_stats', array(array(), true));

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

	}

	}


if(empty($stats_changes) || $stats_changes['inserted'])
{


if(empty($stats_changes) || $stats_changes['inserted'])
{

Zeile 2355Zeile 2542
			'numdeletedthreads' => '+0',
'inserted' => false // Reset after changes are inserted into cache
);

			'numdeletedthreads' => '+0',
'inserted' => false // Reset after changes are inserted into cache
);

		$stats = $stats_changes;
}

		$stats = $stats_changes;
}


if($force) // Force writing to cache?
{


if($force) // Force writing to cache?
{

Zeile 2401Zeile 2588
					elseif($new_stats[$counter] < 0)
{
$new_stats[$counter] = 0;

					elseif($new_stats[$counter] < 0)
{
$new_stats[$counter] = 0;

					}
}

					}
}

			}
else
{

			}
else
{

Zeile 2643Zeile 2830
	// Fetch above counters for this thread
$query = $db->simple_select("threads", implode(",", $counters), "tid='{$tid}'");
$thread = $db->fetch_array($query);

	// Fetch above counters for this thread
$query = $db->simple_select("threads", implode(",", $counters), "tid='{$tid}'");
$thread = $db->fetch_array($query);


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


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

				$changes[$counter] = substr($changes[$counter], 1);
}
// Adding or subtracting from previous value?

				$changes[$counter] = substr($changes[$counter], 1);
}
// Adding or subtracting from previous value?

Zeile 2679Zeile 2866
	if(count($update_query) > 0)
{
$db->update_query("threads", $update_query, "tid='{$tid}'");

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

	}
}

	}
}


/**
* Update the first post and lastpost data for a specific thread


/**
* Update the first post and lastpost data for a specific thread

Zeile 2726Zeile 2913
	if(empty($firstpost['username']))
{
$firstpost['username'] = $firstpost['postusername'];

	if(empty($firstpost['username']))
{
$firstpost['username'] = $firstpost['postusername'];

	}


	}


	if(empty($lastpost['username']))

	if(empty($lastpost['username']))

	{

	{

		$lastpost['username'] = $lastpost['postusername'];

		$lastpost['username'] = $lastpost['postusername'];

	}

	}


if(empty($lastpost['dateline']))
{


if(empty($lastpost['dateline']))
{

Zeile 2742Zeile 2929

$lastpost['username'] = $db->escape_string($lastpost['username']);
$firstpost['username'] = $db->escape_string($firstpost['username']);


$lastpost['username'] = $db->escape_string($lastpost['username']);
$firstpost['username'] = $db->escape_string($firstpost['username']);





	$update_array = array(
'firstpost' => (int)$firstpost['pid'],
'username' => $firstpost['username'],

	$update_array = array(
'firstpost' => (int)$firstpost['pid'],
'username' => $firstpost['username'],

Zeile 2773Zeile 2960
	// Fetch above counters for this user
$query = $db->simple_select("users", implode(",", $counters), "uid='{$uid}'");
$user = $db->fetch_array($query);

	// Fetch above counters for this user
$query = $db->simple_select("users", implode(",", $counters), "uid='{$uid}'");
$user = $db->fetch_array($query);





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

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

Zeile 3006Zeile 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))
{
$groupscache = $cache->read("usergroups");
}

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

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

	static $formattednames = array();

if(!isset($formattednames[$username]))
{
if(!is_array($groupscache))
{
$groupscache = $cache->read("usergroups");
}

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





	if($userin == 0)
{

 
		$format = "{username}";

		$format = "{username}";

	}

$format = stripslashes($format);

 




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






















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

$format = $parameters['format'];

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

return $formattednames[$username];

}

/**

}

/**

Zeile 3048Zeile 3251
	if(!isset($avatars))
{
$avatars = array();

	if(!isset($avatars))
{
$avatars = array();

 
	}

if(my_strpos($avatar, '://') !== false && !$mybb->settings['allowremoteavatars'])
{
// Remote avatar, but remote avatars are disallowed.
$avatar = null;

	}

if(!$avatar)

	}

if(!$avatar)

Zeile 3088Zeile 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 3189Zeile 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 3278Zeile 3487
							$hiddensmilies .= '"'.$find.'": "'.$image.'",';
}
elseif($i < $mybb->settings['smilieinsertertot'])

							$hiddensmilies .= '"'.$find.'": "'.$image.'",';
}
elseif($i < $mybb->settings['smilieinsertertot'])

						{

						{

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

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

Zeile 3294Zeile 3503
						}
}
}

						}
}
}

			}

			}


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



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


Zeile 3325Zeile 3534
			}

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

			}

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

			{

			{

				$removeformat = "removeformat|";

				$removeformat = "removeformat|";

			}

			}


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


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

			}


			}


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

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

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

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

			{

			{

				$list = "bulletlist,orderedlist|";

				$list = "bulletlist,orderedlist|";

			}

			}


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


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

			}


			}


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

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

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

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

		}
















































		}
}

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

	return $subscription_methods[$subscription_method];

}

/**

}

/**

Zeile 3401Zeile 3657
			if($mybb->settings['smilieinsertertot'] >= $smiliecount)
{
$mybb->settings['smilieinsertertot'] = $smiliecount;

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

			}

			}

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

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

Zeile 3605Zeile 3861
	else
{
eval("\$prefixselect = \"".$templates->get("post_prefixselect_single")."\";");

	else
{
eval("\$prefixselect = \"".$templates->get("post_prefixselect_single")."\";");

	}

return $prefixselect;

	}

return $prefixselect;

}

/**

}

/**

Zeile 3621Zeile 3877
{
global $cache, $db, $lang, $mybb, $templates;


{
global $cache, $db, $lang, $mybb, $templates;


	$fid = (int)$fid;


	$fid = (int)$fid;


	$prefix_cache = build_prefixes(0);
if(empty($prefix_cache))
{

	$prefix_cache = build_prefixes(0);
if(empty($prefix_cache))
{

Zeile 3633Zeile 3889
	// Go through each of our prefixes and decide which ones we can use
$prefixes = array();
foreach($prefix_cache as $prefix)

	// Go through each of our prefixes and decide which ones we can use
$prefixes = array();
foreach($prefix_cache as $prefix)

	{

	{

		if($prefix['forums'] != "-1")
{
// Decide whether this prefix can be used in our forum

		if($prefix['forums'] != "-1")
{
// Decide whether this prefix can be used in our forum

Zeile 3646Zeile 3902
			}
}
else

			}
}
else

		{

		{

			// This prefix is for anybody to use...
$prefixes[$prefix['pid']] = $prefix;
}

			// This prefix is for anybody to use...
$prefixes[$prefix['pid']] = $prefix;
}

	}


	}


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

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

Zeile 3659Zeile 3915

$default_selected = array();
$selected_pid = (int)$selected_pid;


$default_selected = array();
$selected_pid = (int)$selected_pid;





	if($selected_pid == 0)

	if($selected_pid == 0)

	{

	{

		$default_selected['all'] = ' selected="selected"';

		$default_selected['all'] = ' selected="selected"';

	}

	}

	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)
{
$default_selected['any'] = ' selected="selected"';

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

	}


	}


	foreach($prefixes as $prefix)
{
$selected = '';

	foreach($prefixes as $prefix)
{
$selected = '';

Zeile 3710Zeile 3966
		if(my_strpos(" ".$httpaccept_encoding, "x-gzip"))
{
$encoding = "x-gzip";

		if(my_strpos(" ".$httpaccept_encoding, "x-gzip"))
{
$encoding = "x-gzip";

		}

		}


if(my_strpos(" ".$httpaccept_encoding, "gzip"))
{


if(my_strpos(" ".$httpaccept_encoding, "gzip"))
{

Zeile 3735Zeile 3991
				$gzdata .= pack("V", $size);
$contents = $gzdata;
}

				$gzdata .= pack("V", $size);
$contents = $gzdata;
}

		}
}

		}
}


return $contents;
}


return $contents;
}

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

	}

// Any remaining extra data - we my_serialize and insert in to its own column

Zeile 3788Zeile 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 3814Zeile 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)

	{

	{

		eval("\$display_reputation = \"".$templates->get("postbit_reputation_formatted_link")."\";");

		eval("\$display_reputation = \"".$templates->get("postbit_reputation_formatted_link")."\";");

	}

	}

	else
{
eval("\$display_reputation = \"".$templates->get("postbit_reputation_formatted")."\";");

	else
{
eval("\$display_reputation = \"".$templates->get("postbit_reputation_formatted")."\";");

	}


	}


	return $display_reputation;
}


	return $display_reputation;
}


Zeile 3839Zeile 4118
function get_colored_warning_level($level)
{
global $templates;

function get_colored_warning_level($level)
{
global $templates;





	$warning_class = '';
if($level >= 80)

	$warning_class = '';
if($level >= 80)

	{

	{

		$warning_class = "high_warning";
}
else if($level >= 50)
{
$warning_class = "moderate_warning";

		$warning_class = "high_warning";
}
else if($level >= 50)
{
$warning_class = "moderate_warning";

	}

	}

	else if($level >= 25)
{
$warning_class = "low_warning";

	else if($level >= 25)
{
$warning_class = "low_warning";

	}

	}

	else
{
$warning_class = "normal_warning";

	else
{
$warning_class = "normal_warning";

Zeile 3916Zeile 4195
	}

return $ip;

	}

return $ip;

}


}


/**
* Fetch the friendly size (GB, MB, KB, B) for a specified file size.
*

/**
* Fetch the friendly size (GB, MB, KB, B) for a specified file size.
*

Zeile 4110Zeile 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 4120Zeile 4399
		else
{
$perms = $mybb->usergroup;

		else
{
$perms = $mybb->usergroup;

		}

$pwverified = 1;

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

		}

$pwverified = 1;












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



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

		}
else
{

		}
else
{

Zeile 4139Zeile 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))
{
$unviewable[] = $forum['fid'];
}
}


if($perms['canview'] == 0 || $pwverified == 0 || ($only_readable_threads == true && $perms['canviewthreads'] == 0))
{
$unviewable[] = $forum['fid'];
}
}





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

return $unviewableforums;

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

return $unviewableforums;

}

}


/**
* Fixes mktime for dates earlier than 1970


/**
* Fixes mktime for dates earlier than 1970

Zeile 4229Zeile 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 4543Zeile 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 4664Zeile 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 4830Zeile 5145
	global $db, $mybb, $cache;

$user = get_user($uid);

	global $db, $mybb, $cache;

$user = get_user($uid);

 

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


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


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

Zeile 4855Zeile 5175
	{
$dispupdate = ", displaygroup=usergroup";
}

	{
$dispupdate = ", displaygroup=usergroup";
}





	$db->write_query("
UPDATE ".TABLE_PREFIX."users
SET additionalgroups='$groupslist' $dispupdate

	$db->write_query("
UPDATE ".TABLE_PREFIX."users
SET additionalgroups='$groupslist' $dispupdate

Zeile 4863Zeile 5183
	");

$cache->update_moderators();

	");

$cache->update_moderators();

}

}


/**
* 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 4895Zeile 5217
	elseif(!empty($_SERVER['PATH_INFO']))
{
$location = htmlspecialchars_uni($_SERVER['PATH_INFO']);

	elseif(!empty($_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)
{
return $location;
}

	if($quick)
{
return $location;
}









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


	if($fields == true)
{

	if($fields == true)
{

		global $mybb;

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

 

$form_html = '';
if(!empty($mybb->input))
{
foreach($mybb->input as $name => $value)


$form_html = '';
if(!empty($mybb->input))
{
foreach($mybb->input as $name => $value)

			{

			{

				if(in_array($name, $ignore) || is_array($name) || is_array($value))
{
continue;

				if(in_array($name, $ignore) || is_array($name) || is_array($value))
{
continue;

Zeile 4933Zeile 5254
	}
else
{

	}
else
{

 
		$parameters = array();


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

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

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

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

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

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

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






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

parse_str($current_query_string, $current_parameters);





		if((isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] == "POST") || (isset($_ENV['REQUEST_METHOD']) && $_ENV['REQUEST_METHOD'] == "POST"))

		foreach($current_parameters as $name => $value)

		{

		{

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

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

if(isset($addloc) && is_array($addloc))

			if(!in_array($name, $ignore))











			{

			{

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

				$parameters[$name] = $value;









			}

			}

 
		}

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

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

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

		}

return $location;

		}

return $location;

Zeile 5001Zeile 5329
	}

if(!is_array($tcache))

	}

if(!is_array($tcache))

	{

	{

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

Zeile 5024Zeile 5352
				}

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

				}

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

				{

				{

					$theme['name'] = htmlspecialchars_uni($theme['name']);
eval("\$themeselect_option .= \"".$templates->get("usercp_themeselector_option")."\";");
++$num_themes;

					$theme['name'] = htmlspecialchars_uni($theme['name']);
eval("\$themeselect_option .= \"".$templates->get("usercp_themeselector_option")."\";");
++$num_themes;

Zeile 5055Zeile 5383
	else
{
return false;

	else
{
return false;

	}
}


	}
}


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

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

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

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



 

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


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

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

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

	{

	{

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

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

Zeile 5404Zeile 5731
	if(!$bday[2])
{
return;

	if(!$bday[2])
{
return;

	}

	}


list($day, $month, $year) = explode("-", my_date("j-n-Y", TIME_NOW, 0, 0));


list($day, $month, $year) = explode("-", my_date("j-n-Y", TIME_NOW, 0, 0));





	$age = $year-$bday[2];

	$age = $year-$bday[2];





	if(($month == $bday[1] && $day < $bday[0]) || $month < $bday[1])
{
--$age;
}
return $age;

	if(($month == $bday[1] && $day < $bday[0]) || $month < $bday[1])
{
--$age;
}
return $age;

}


}


/**
* Updates the first posts in a thread.
*

/**
* Updates the first posts in a thread.
*

Zeile 5600Zeile 5927
	}

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 5658Zeile 6012
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 5699Zeile 6053
	{
return false;
}

	{
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 5734Zeile 6110

/**
* Get the profile link.


/**
* Get the profile link.

 *

 *

 * @param int $uid The user id of the profile.
* @return string The url to the profile.
*/

 * @param int $uid The user id of the profile.
* @return string The url to the profile.
*/

Zeile 5772Zeile 6148
	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 5790Zeile 6166
		if(!empty($onclick))
{
$onclick = " onclick=\"{$onclick}\"";

		if(!empty($onclick))
{
$onclick = " onclick=\"{$onclick}\"";

		}

		}


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

Zeile 5806Zeile 6182
function get_forum_link($fid, $page=0)
{
if($page > 0)

function get_forum_link($fid, $page=0)
{
if($page > 0)

	{

	{

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

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

Zeile 5867Zeile 6243
 * @return string The url to the post.
*/
function get_post_link($pid, $tid=0)

 * @return string The url to the post.
*/
function get_post_link($pid, $tid=0)

{

{

	if($tid > 0)

	if($tid > 0)

	{

	{

		$link = str_replace("{tid}", $tid, THREAD_URL_POST);
$link = str_replace("{pid}", $pid, $link);

		$link = str_replace("{tid}", $tid, THREAD_URL_POST);
$link = str_replace("{pid}", $pid, $link);

		return htmlspecialchars_uni($link);
}

		return htmlspecialchars_uni($link);
}

	else
{
$link = str_replace("{pid}", $pid, POST_URL);

	else
{
$link = str_replace("{pid}", $pid, POST_URL);

Zeile 5883Zeile 6259

/**
* Build the event link.


/**
* Build the event link.

 *

 *

 * @param int $eid The event ID of the event
* @return string The URL of the event
*/

 * @param int $eid The event ID of the event
* @return string The URL of the event
*/

Zeile 5913Zeile 6289
		return htmlspecialchars_uni($link);
}
else if($month > 0)

		return htmlspecialchars_uni($link);
}
else if($month > 0)

	{

	{

		$link = str_replace("{month}", $month, CALENDAR_URL_MONTH);
$link = str_replace("{year}", $year, $link);
$link = str_replace("{calendar}", $calendar, $link);

		$link = str_replace("{month}", $month, CALENDAR_URL_MONTH);
$link = str_replace("{year}", $year, $link);
$link = str_replace("{calendar}", $calendar, $link);

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


	global $cache;
static $forum_cache;


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

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

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

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

Zeile 6192Zeile 6568
 * @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)

















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

	{

	{

		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($fatal)
{
$secsleft = (int)($mybb->cookies['lockoutexpiry'] - $now);
$hoursleft = floor($secsleft / 3600);
$minsleft = floor(($secsleft / 60) % 60);
$secsleft = floor($secsleft % 60);







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

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







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




		return false;
}

if($mybb->settings['failedlogincount'] > 0 && $attempts['loginattempts'] >= $mybb->settings['failedlogincount'])

	{

	{

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





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

}

/**

}

/**

Zeile 6288Zeile 6673
 */
function validate_email_format($email)
{

 */
function validate_email_format($email)
{

	if(strpos($email, ' ') !== false)
{
return false;
}
// Valid local characters for email addresses: http://www.remote.org/jochen/mail/info/chars.html
return preg_match("/^[a-zA-Z0-9&*+\-_.{}~^\?=\/]+@[a-zA-Z0-9-]+\.([a-zA-Z0-9-]+\.)*[a-zA-Z0-9-]{2,}$/si", $email);

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






}

/**

}

/**

Zeile 6330Zeile 6710
{
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";
}

$settings = "<"."?php\n/*********************************\ \n DO NOT EDIT THIS FILE, PLEASE USE\n THE SETTINGS EDITOR\n\*********************************/\n\n$settings\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";

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





/**
* Build a PREG compatible array of search highlight terms to replace in posts.
*

/**
* Build a PREG compatible array of search highlight terms to replace in posts.
*

Zeile 6374Zeile 6745
	if($mybb->settings['minsearchword'] < 1)
{
$mybb->settings['minsearchword'] = 3;

	if($mybb->settings['minsearchword'] < 1)
{
$mybb->settings['minsearchword'] = 3;

	}

	}


if(is_array($terms))
{


if(is_array($terms))
{

Zeile 6403Zeile 6774
			if($phrase != "")
{
if($inquote)

			if($phrase != "")
{
if($inquote)

				{

				{

					$words[] = trim($phrase);
}
else

					$words[] = trim($phrase);
}
else

Zeile 6432Zeile 6803
		$terms = htmlspecialchars_uni($terms);
$split_words = preg_split("#\s{1,}#", $terms, -1);
if(is_array($split_words))

		$terms = htmlspecialchars_uni($terms);
$split_words = preg_split("#\s{1,}#", $terms, -1);
if(is_array($split_words))

		{

		{

			foreach($split_words as $word)
{
if(!$word || strlen($word) < $mybb->settings['minsearchword'])

			foreach($split_words as $word)
{
if(!$word || strlen($word) < $mybb->settings['minsearchword'])

Zeile 6451Zeile 6822

// 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 6462Zeile 6833

// Special boolean operators should be stripped
if($word == "" || $word == "or" || $word == "not" || $word == "and")


// Special boolean operators should be stripped
if($word == "" || $word == "or" || $word == "not" || $word == "and")

		{
continue;

		{
continue;

		}

// Now make PREG compatible
$find = "#(?!<.*?)(".preg_quote($word, "#").")(?![^<>]*?>)#ui";
$replacement = "<span class=\"highlight\" style=\"padding-left: 0px; padding-right: 0px;\">$1</span>";
$highlight_cache[$find] = $replacement;

		}

// Now make PREG compatible
$find = "#(?!<.*?)(".preg_quote($word, "#").")(?![^<>]*?>)#ui";
$replacement = "<span class=\"highlight\" style=\"padding-left: 0px; padding-right: 0px;\">$1</span>";
$highlight_cache[$find] = $replacement;

	}


	}


	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 6491Zeile 6874
		return false;
}
elseif($src <= 0x007f)

		return false;
}
elseif($src <= 0x007f)

	{
$dest .= chr($src);
}

	{
$dest .= chr($src);
}

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

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

Zeile 6523Zeile 6906

/**
* Checks if a username has been disallowed for registration/use.


/**
* Checks if a username has been disallowed for registration/use.

 *

 *

 * @param string $username The username
* @param boolean $update_lastuse True if the 'last used' dateline should be updated if a match is found.
* @return boolean True if banned, false if not banned

 * @param string $username The username
* @param boolean $update_lastuse True if the 'last used' dateline should be updated if a match is found.
* @return boolean True if banned, false if not banned

Zeile 6583Zeile 6966
				if($update_lastuse == true)
{
$db->update_query("banfilters", array("lastuse" => TIME_NOW), "fid='{$banned_email['fid']}'");

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

				}

				}

				return true;
}
}

				return true;
}
}

Zeile 6703Zeile 7086

/**
* Build a time zone selection list.


/**
* Build a time zone selection list.

 *

 *

 * @param string $name The name of the select
* @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

 * @param string $name The name of the select
* @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

Zeile 6767Zeile 7150
{
global $mybb, $config;


{
global $mybb, $config;


	$url_components = @parse_url($url);















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

$url_components = @parse_url($url);

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


if(
!$url_components ||
empty($url_components['host']) ||
(!empty($url_components['scheme']) && !in_array($url_components['scheme'], array('http', 'https'))) ||


if(
!$url_components ||
empty($url_components['host']) ||
(!empty($url_components['scheme']) && !in_array($url_components['scheme'], array('http', 'https'))) ||

		(!empty($url_components['port']) && !in_array($url_components['port'], array(80, 8080, 443))) ||

		(!in_array($url_components['port'], array(80, 8080, 443))) ||

		(!empty($config['disallowed_remote_hosts']) && in_array($url_components['host'], $config['disallowed_remote_hosts']))
)
{
return false;
}

		(!empty($config['disallowed_remote_hosts']) && in_array($url_components['host'], $config['disallowed_remote_hosts']))
)
{
return false;
}

 

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


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


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

	{
$addresses = gethostbynamel($url_components['host']);
if($addresses)
{
foreach($config['disallowed_remote_addresses'] as $disallowed_address)




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

$packed_address = my_inet_pton($destination_address);

if(is_array($ip_range))

			{

			{

				$ip_range = fetch_ip_range($disallowed_address);
foreach($addresses as $address)

				if(strcmp($ip_range[0], $packed_address) <= 0 && strcmp($ip_range[1], $packed_address) >= 0)


				{

				{

					$packed_address = my_inet_pton($address);

if(is_array($ip_range))
{
if(strcmp($ip_range[0], $packed_address) <= 0 && strcmp($ip_range[1], $packed_address) >= 0)
{
return false;
}
}
elseif($address == $disallowed_address)
{
return false;
}

					return false;













				}
}

				}
}

		}
}





			elseif($destination_address == $disallowed_address)
{
return false;
}
}
}


$post_body = '';
if(!empty($post_data))
{
foreach($post_data as $key => $val)


$post_body = '';
if(!empty($post_data))
{
foreach($post_data as $key => $val)

		{

		{

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

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

		}

		}

		$post_body = ltrim($post_body, '&');
}

		$post_body = ltrim($post_body, '&');
}





	if(function_exists("curl_init"))

	if(function_exists("curl_init"))

	{
$can_followlocation = @ini_get('open_basedir') === '' && !$mybb->safemode;

$request_header = $max_redirects != 0 && !$can_followlocation;

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, $request_header);
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);

if($max_redirects != 0 && $can_followlocation)
{
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_MAXREDIRS, $max_redirects);
}

if(!empty($post_body))
{
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_body);
}

$response = curl_exec($ch);

if($request_header)
{


























	{
$fetch_header = $max_redirects > 0;

$ch = curl_init();

$curlopt = array(
CURLOPT_URL => $url,
CURLOPT_HEADER => $fetch_header,
CURLOPT_TIMEOUT => 10,
CURLOPT_RETURNTRANSFER => 1,
CURLOPT_FOLLOWLOCATION => 0,
);

if($ca_bundle_path = get_ca_bundle_path())
{
$curlopt[CURLOPT_SSL_VERIFYPEER] = 1;
$curlopt[CURLOPT_CAINFO] = $ca_bundle_path;
}
else
{
$curlopt[CURLOPT_SSL_VERIFYPEER] = 0;
}

$curl_version_info = curl_version();
$curl_version = $curl_version_info['version'];

if(version_compare(PHP_VERSION, '7.0.7', '>=') && version_compare($curl_version, '7.49', '>='))
{
// CURLOPT_CONNECT_TO
$curlopt[10243] = array(
$url_components['host'].':'.$url_components['port'].':'.$destination_address
);
}
elseif(version_compare(PHP_VERSION, '5.5', '>=') && version_compare($curl_version, '7.21.3', '>='))
{
// CURLOPT_RESOLVE
$curlopt[10203] = array(
$url_components['host'].':'.$url_components['port'].':'.$destination_address
);
}

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

curl_setopt_array($ch, $curlopt);

$response = curl_exec($ch);

if($fetch_header)
{

			$header_size = curl_getinfo($ch, CURLINFO_HEADER_SIZE);
$header = substr($response, 0, $header_size);
$body = substr($response, $header_size);

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

			$header_size = curl_getinfo($ch, CURLINFO_HEADER_SIZE);
$header = substr($response, 0, $header_size);
$body = substr($response, $header_size);

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)
{
$data = fetch_remote_file(trim(array_pop($matches)), $post_data, --$max_redirects);
}


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

			}

			}

			else
{
$data = $body;

			else
{
$data = $body;

			}
}
else

			}
}
else

		{
$data = $response;
}

		{
$data = $response;
}

Zeile 6875Zeile 7294
	}
else if(function_exists("fsockopen"))
{

	}
else if(function_exists("fsockopen"))
{

		if(!isset($url_components['port']))
{
$url_components['port'] = 80;
}

 
		if(!isset($url_components['path']))
{
$url_components['path'] = "/";

		if(!isset($url_components['path']))
{
$url_components['path'] = "/";

Zeile 6891Zeile 7306
		$scheme = '';

if($url_components['scheme'] == 'https')

		$scheme = '';

if($url_components['scheme'] == 'https')

		{

		{

			$scheme = 'ssl://';
if($url_components['port'] == 80)

			$scheme = 'ssl://';
if($url_components['port'] == 80)

			{

			{

				$url_components['port'] = 443;
}
}


				$url_components['port'] = 443;
}
}


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































		if(function_exists('stream_context_create'))
{
if($url_components['scheme'] == 'https' && $ca_bundle_path = get_ca_bundle_path())
{
$context = stream_context_create(array(
'ssl' => array(
'verify_peer' => true,
'verify_peer_name' => true,
'peer_name' => $url_components['host'],
'cafile' => $ca_bundle_path,
),
));
}
else
{
$context = stream_context_create(array(
'ssl' => array(
'verify_peer' => false,
'verify_peer_name' => false,
'peer_name' => $url_components['host'],
),
));
}

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


		@stream_set_timeout($fp, 10);
if(!$fp)
{

		@stream_set_timeout($fp, 10);
if(!$fp)
{

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


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


		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 6966Zeile 7411
		}

return $data;

		}

return $data;

	}
else if(empty($post_data))
{
return @implode("", @file($url));

 
	}
else

	}
else

	{

	{

		return false;
}

		return false;
}

 
}

/**
* Resolves a hostname into a set of IP addresses.
*
* @param string $hostname The hostname to be resolved
* @return array|bool The resulting IP addresses. False on failure
*/
function get_ip_by_hostname($hostname)
{
$addresses = @gethostbynamel($hostname);

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

if($result_set)
{
$addresses = array_column($result_set, 'ip');
}
else
{
return false;
}
}

return $addresses;
}

/**
* Returns the location of the CA bundle defined in the PHP configuration.
*
* @return string|bool The location of the CA bundle, false if not set
*/
function get_ca_bundle_path()
{
if($path = ini_get('openssl.cafile'))
{
return $path;
}
if($path = ini_get('curl.cainfo'))
{
return $path;
}

return false;

}

/**

}

/**

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

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

function subforums_count($array)

function subforums_count($array=array())

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

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

Zeile 7599Zeile 8086
	static $time_start;

$time = microtime(true);

	static $time_start;

$time = microtime(true);



 

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


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

Zeile 7629Zeile 8115
	global $mybb, $checksums, $bad_verify_files;

// We don't need to check these types of files

	global $mybb, $checksums, $bad_verify_files;

// We don't need to check these types of files

	$ignore = array(".", "..", ".svn", "config.php", "settings.php", "Thumb.db", "config.default.php", "lock", "htaccess.txt", "logo.gif", "logo.png");

	$ignore = array(".", "..", ".svn", "config.php", "settings.php", "Thumb.db", "config.default.php", "lock", "htaccess.txt", "htaccess-nginx.txt", "logo.gif", "logo.png");

	$ignore_ext = array("attach");

if(substr($path, -1, 1) == "/")

	$ignore_ext = array("attach");

if(substr($path, -1, 1) == "/")

Zeile 7640Zeile 8126
	if(!is_array($bad_verify_files))
{
$bad_verify_files = array();

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

	}

	}


// Make sure that we're in a directory and it's not a symbolic link
if(@is_dir($path) && !@is_link($path))


// Make sure that we're in a directory and it's not a symbolic link
if(@is_dir($path) && !@is_link($path))

Zeile 7651Zeile 8137
			while(($file = @readdir($dh)) !== false)
{
if(in_array($file, $ignore) || in_array(get_extension($file), $ignore_ext))

			while(($file = @readdir($dh)) !== false)
{
if(in_array($file, $ignore) || in_array(get_extension($file), $ignore_ext))

				{
continue;
}

				{
continue;
}


// Recurse through the directory tree
if(is_dir($path."/".$file))


// Recurse through the directory tree
if(is_dir($path."/".$file))

Zeile 7670Zeile 8156
				{
$filename = $path."/".$file;
$handle = fopen($filename, "rb");

				{
$filename = $path."/".$file;
$handle = fopen($filename, "rb");

					$contents = '';

					$hashingContext = hash_init('sha512');

					while(!feof($handle))
{

					while(!feof($handle))
{

						$contents .= fread($handle, 8192);

						hash_update($hashingContext, fread($handle, 8192));

					}
fclose($handle);


					}
fclose($handle);


					$md5 = md5($contents);

					$checksum = hash_final($hashingContext);


// Does it match any of our hashes (unix/windows new lines taken into consideration with the hashes)


// Does it match any of our hashes (unix/windows new lines taken into consideration with the hashes)

					if(!in_array($md5, $checksums[$file_path]))

					if(!in_array($checksum, $checksums[$file_path]))

					{
$bad_verify_files[] = array("status" => "changed", "path" => $file_path);
}

					{
$bad_verify_files[] = array("status" => "changed", "path" => $file_path);
}

Zeile 7710Zeile 8196
	if($count == 0)
{
return $bad_verify_files;

	if($count == 0)
{
return $bad_verify_files;

	}
}

/**

	}
}

/**

 * Returns a signed value equal to an integer
*
* @param int $int The integer

 * Returns a signed value equal to an integer
*
* @param int $int The integer

Zeile 7746Zeile 8232
		{
$output = random_bytes($bytes);
} catch (Exception $e) {

		{
$output = random_bytes($bytes);
} catch (Exception $e) {

		}
}

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

		}
}

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

		if(@is_readable('/dev/urandom') && ($handle = @fopen('/dev/urandom', 'rb')))
{
$output = @fread($handle, $bytes);
@fclose($handle);

		if(@is_readable('/dev/urandom') && ($handle = @fopen('/dev/urandom', 'rb')))
{
$output = @fread($handle, $bytes);
@fclose($handle);

		}
}
else
{
return $output;
}

if(strlen($output) < $bytes)

		}
}
else
{
return $output;
}

if(strlen($output) < $bytes)

	{
if(function_exists('mcrypt_create_iv'))
{

	{
if(function_exists('mcrypt_create_iv'))
{

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

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

				}
}
}
}
else
{
return $output;
}

				}
}
}
}
else
{
return $output;
}


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


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

Zeile 7815Zeile 8301
					$output = $CAPI_Util->GetRandom($bytes, 0);
}
} catch (Exception $e) {

					$output = $CAPI_Util->GetRandom($bytes, 0);
}
} catch (Exception $e) {

			}
}
}
else
{
return $output;
}


			}
}
}
else
{
return $output;
}


	if(strlen($output) < $bytes)
{
// Close to what PHP basically uses internally to seed, but not quite.

	if(strlen($output) < $bytes)
{
// Close to what PHP basically uses internally to seed, but not quite.

Zeile 8148Zeile 8634
					{
$string .= '?';
break;

					{
$string .= '?';
break;

					}

					}

					else
{
return false;

					else
{
return false;

Zeile 8228Zeile 8714
	global $lang, $mybb, $db, $session;

if($mybb->settings['enablepms'] == 0)

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

if($mybb->settings['enablepms'] == 0)

	{
return false;

	{
return false;

	}

if(!is_array($pm))

	}

if(!is_array($pm))

Zeile 8256Zeile 8742
				$num_args = count($pm[$key]);

for($i = 1; $i < $num_args; $i++)

				$num_args = count($pm[$key]);

for($i = 1; $i < $num_args; $i++)

				{

				{

					$lang_string = str_replace('{'.$i.'}', $pm[$key][$i], $lang_string);
}
}

					$lang_string = str_replace('{'.$i.'}', $pm[$key][$i], $lang_string);
}
}

Zeile 8329Zeile 8815
	}

$pm['options'] = array(

	}

$pm['options'] = array(

		"signature" => 0,

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

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

Zeile 8414Zeile 8899

if(file_exists($file_path))
{


if(file_exists($file_path))
{

 

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


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

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

Zeile 8421Zeile 8918
			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;

			}

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


if(!($dir_exists = is_dir($cdn_upload_path)))
{
$dir_exists = @mkdir($cdn_upload_path, 0777, true);

			}


			}


			if($dir_exists)
{
if(($cdn_upload_path = realpath($cdn_upload_path)) !== false)

			if($dir_exists)
{
if(($cdn_upload_path = realpath($cdn_upload_path)) !== false)

Zeile 8459Zeile 8956
	}

return $success;

	}

return $success;

}

}


/**
* Validate an url
*
* @param string $url The url to validate.
* @param bool $relative_path Whether or not the url could be a relative path.


/**
* Validate an url
*
* @param string $url The url to validate.
* @param bool $relative_path Whether or not the url could be a relative path.

 
 * @param bool $allow_local Whether or not the url could be pointing to local networks.

 *
* @return bool Whether this is a valid url.
*/

 *
* @return bool Whether this is a valid url.
*/

function my_validate_url($url, $relative_path=false)

function my_validate_url($url, $relative_path=false, $allow_local=false)

{

{

	if($relative_path && my_substr($url, 0, 1) == '/' || preg_match('_^(?:(?:https?|ftp)://)(?:\S+(?::\S*)?@)?(?:(?!(?:10|127)(?:\.\d{1,3}){3})(?!(?:169\.254|192\.168)(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[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]))|(?:(?:[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', $url))










	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';
}
else
{
$regex = '_^(?:(?:https?|ftp)://)(?:\S+(?::\S*)?@)?(?:(?!(?:10|127)(?:\.\d{1,3}){3})(?!(?:169\.254|192\.168)(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[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]))|(?:(?:[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($relative_path && my_substr($url, 0, 1) == '/' || preg_match($regex, $url))

	{
return true;

	{
return true;

 
	}
return false;
}

/**
* 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
*
* @return string Striped string
*/
function my_strip_tags($string, $allowable_tags = '')
{
$pattern = array(
'@(&lt;)style[^(&gt;)]*?(&gt;).*?(&lt;)/style(&gt;)@siu',
'@(&lt;)script[^(&gt;)]*?.*?(&lt;)/script(&gt;)@siu',
'@<style[^>]*?>.*?</style>@siu',
'@<script[^>]*?.*?</script>@siu',
);
$string = preg_replace($pattern, '', $string);
return strip_tags($string, $allowable_tags);
}

/**
* Escapes a RFC 4180-compliant CSV string.
* Based on https://github.com/Automattic/camptix/blob/f80725094440bf09861383b8f11e96c177c45789/camptix.php#L2867
*
* @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)
{
$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;
}

foreach($delimiters as $delimiter)
{
foreach($active_content_triggers as $trigger)
{
$string = str_replace($delimiter.$trigger, $delimiter."'".$trigger, $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 false;

	return $referrals;

}

}