Vergleich inc/functions.php - 1.8.12 - 1.8.18

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

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

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

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

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

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

Zeile 380Zeile 381
	}

$todaysdate = $yesterdaysdate = '';

	}

$todaysdate = $yesterdaysdate = '';

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

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

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

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

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

			{
if($todaysdate == $date)
{

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

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

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

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

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

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

				}
}


				}
}


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

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

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

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

		}
}
else

		}
}
else

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

		{
if($todaysdate == $date)
{

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

				$date = $lang->today;

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

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

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

				$date = $lang->yesterday;

			}
}
else

			}
}
else

Zeile 521Zeile 547
	}

return $date;

	}

return $date;

}


}


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

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

Zeile 554Zeile 580
			$mail = new SmtpMail();
}
else

			$mail = new SmtpMail();
}
else

		{

		{

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

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

		}
}

		}
}


// Using SMTP based mail
if($mybb->settings['mail_handler'] == 'smtp')


// Using SMTP based mail
if($mybb->settings['mail_handler'] == 'smtp')

Zeile 570Zeile 596
	}

// Using PHP based mail()

	}

// Using PHP based mail()

	else

	else

	{
if($mybb->settings['mail_parameters'] != '')
{

	{
if($mybb->settings['mail_parameters'] != '')
{

Zeile 615Zeile 641
	if(generate_post_check() !== $code)
{
if($silent == true)

	if(generate_post_check() !== $code)
{
if($silent == true)

		{
return false;
}

		{
return false;
}

		else
{
if(defined("IN_ADMINCP"))

		else
{
if(defined("IN_ADMINCP"))

Zeile 843Zeile 869

foreach($errors as $error)
{


foreach($errors as $error)
{

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

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

	}

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

	}

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

Zeile 868Zeile 894
	);

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

	);

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


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


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

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

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

Zeile 1011Zeile 1037
	{
return '';
}

	{
return '';
}

 

$page = (int)$page;


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


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

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


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


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

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


if($breadcrumb == true)
{


if($breadcrumb == true)
{

Zeile 1176Zeile 1204
/**
* Fetch the permissions for a specific user
*

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

 * @param int $uid The user ID

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

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

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

function user_permissions($uid=0)

function user_permissions($uid=null)

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

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

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

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

	if($uid == 0)

	if($uid === null)

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

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

 
	}

// Its a guest. Return the group permissions directly from cache
if($uid == 0)
{
return $groupscache[1];

	}

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

	}

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

		if($user_cache[$uid]['permissions'])

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

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

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

		}

		}


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


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

		if(!$user_cache[$uid])

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

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

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

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

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





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

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

Zeile 1216Zeile 1250
	else
{
return $mybb->usergroup;

	else
{
return $mybb->usergroup;

	}

	}

}

/**

}

/**

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

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

	}

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


	}

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


	if(count($groups) == 1)
{
$groupscache[$gid]['all_usergroups'] = $gid;

	if(count($groups) == 1)
{
$groupscache[$gid]['all_usergroups'] = $gid;

Zeile 1244Zeile 1278

$usergroup = array();
$usergroup['all_usergroups'] = $gid;


$usergroup = array();
$usergroup['all_usergroups'] = $gid;





	foreach($groups as $gid)
{
if(trim($gid) == "" || empty($groupscache[$gid]))

	foreach($groups as $gid)
{
if(trim($gid) == "" || empty($groupscache[$gid]))

Zeile 1253Zeile 1287
		}

foreach($groupscache[$gid] as $perm => $access)

		}

foreach($groupscache[$gid] as $perm => $access)

		{

		{

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

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

Zeile 1331Zeile 1365
		if($uid != 0 && $uid != $mybb->user['uid'])
{
$user = get_user($uid);

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





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

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

		}

		}

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

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

Zeile 1345Zeile 1379
			}

$groupperms = $mybb->usergroup;

			}

$groupperms = $mybb->usergroup;

		}
}

		}
}


if(!is_array($forum_cache))
{


if(!is_array($forum_cache))
{

Zeile 1378Zeile 1412
			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);

			}
}

			}
}

		return $cached_forum_permissions[$gid];
}
}

		return $cached_forum_permissions[$gid];
}
}

Zeile 1411Zeile 1445
	foreach($groups as $gid)
{
if(!empty($groupscache[$gid]))

	foreach($groups as $gid)
{
if(!empty($groupscache[$gid]))

		{

		{

			$level_permissions = $fpermcache[$fid][$gid];

// If our permissions arn't inherited we need to figure them out

			$level_permissions = $fpermcache[$fid][$gid];

// If our permissions arn't inherited we need to figure them out

Zeile 1490Zeile 1524
	global $mybb, $header, $footer, $headerinclude, $theme, $templates, $lang, $forum_cache;

$showform = true;

	global $mybb, $header, $footer, $headerinclude, $theme, $templates, $lang, $forum_cache;

$showform = true;





	if(!is_array($forum_cache))

	if(!is_array($forum_cache))

	{

	{

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

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

Zeile 1505Zeile 1539
	{
$parents = explode(',', $forum_cache[$fid]['parentlist']);
rsort($parents);

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

	}

	}

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

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

			{

			{

				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']))
{
$password = $forum_cache[$fid]['password'];

	if(!empty($forum_cache[$fid]['password']))
{
$password = $forum_cache[$fid]['password'];

Zeile 1535Zeile 1569
			else
{
eval("\$pwnote = \"".$templates->get("forumdisplay_password_wrongpass")."\";");

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

				$showform = true;
}

				$showform = true;
}

		}
else
{

		}
else
{

Zeile 1567Zeile 1601
			header("Location: ".$mybb->settings['bburl']."/".get_forum_link($fid));
}
else

			header("Location: ".$mybb->settings['bburl']."/".get_forum_link($fid));
}
else

		{

		{

			$_SERVER['REQUEST_URI'] = htmlspecialchars_uni($_SERVER['REQUEST_URI']);
eval("\$pwform = \"".$templates->get("forumdisplay_password")."\";");
output_page($pwform);

			$_SERVER['REQUEST_URI'] = htmlspecialchars_uni($_SERVER['REQUEST_URI']);
eval("\$pwform = \"".$templates->get("forumdisplay_password")."\";");
output_page($pwform);

Zeile 1597Zeile 1631
	if($uid == 0)
{
return false;

	if($uid == 0)
{
return false;

	}


	}


	if(isset($modpermscache[$fid][$uid]))

	if(isset($modpermscache[$fid][$uid]))

	{

	{

		return $modpermscache[$fid][$uid];

		return $modpermscache[$fid][$uid];

	}

	}


if(!$parentslist)
{
$parentslist = explode(',', get_parent_list($fid));
}


if(!$parentslist)
{
$parentslist = explode(',', get_parent_list($fid));
}





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

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

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

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





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

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

	{

	{

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

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





		foreach($extra_groups as $extra_group)

		foreach($extra_groups as $extra_group)

		{

		{

			$groups[] = $extra_group;
}
}

			$groups[] = $extra_group;
}
}





	$mod_cache = $cache->read("moderators");

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

	$mod_cache = $cache->read("moderators");

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

		{

		{

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

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





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

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

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


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


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

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

Zeile 1676Zeile 1710
				}

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

				}

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

			}

			}

		}
}


		}
}


Zeile 1755Zeile 1789
			if(!$action && $modperms)
{
return true;

			if(!$action && $modperms)
{
return true;

			}

			}

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

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

				}

				}

				else
{
return false;
}
}

				else
{
return false;
}
}

		}
}
}


		}
}
}


/**
* Generate a list of the posticons.
*

/**
* Generate a list of the posticons.
*

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

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

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

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

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

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

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

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

	}

	}

	else
{
$posticons = '';

	else
{
$posticons = '';

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

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

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

 */

 */

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

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

{
global $mybb;


{
global $mybb;


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

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

 
	}

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

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

	}

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

	}

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

Zeile 1997Zeile 2042
		return false;
}


		return false;
}


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

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



/*
* states:


/*
* states:

Zeile 2254Zeile 2298
	if(isset($mbIntEnc))
{
mb_internal_encoding($mbIntEnc);

	if(isset($mbIntEnc))
{
mb_internal_encoding($mbIntEnc);

	}


	}


	return $out;
}


	return $out;
}


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

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

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

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

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

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

		}
}


		}
}


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

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

	global $groupscache, $cache;

	global $groupscache, $cache, $plugins;





	if(!is_array($groupscache))



	static $formattednames = array();

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

	{

	{

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

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





















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

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

$format = "{username}";

if(isset($groupscache[$usergroup]))
{
$ugroup = $groupscache[$usergroup];

if(strpos($ugroup['namestyle'], "{username}") !== false)
{
$format = $ugroup['namestyle'];
}
}

$format = stripslashes($format);

$parameters = compact('username', 'usergroup', 'displaygroup', 'format');

$parameters = $plugins->run_hooks('format_name', $parameters);





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

		$format = $parameters['format'];







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

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



	}


	}


	$format = stripslashes($format);

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

	return $formattednames[$username];



}

/**

}

/**

Zeile 3113Zeile 3173

if($dimensions)
{


if($dimensions)
{

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

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


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


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

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

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


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


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

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

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

			"editor_veoh" => "Veoh",

			"editor_mixer" => "Mixer",

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

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

Zeile 3384Zeile 3444
	}

return $codeinsert;

	}

return $codeinsert;

 
}

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

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

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

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

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

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

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

return $subscription_methods[$subscription_method];

}

/**

}

/**

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

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

			}
}

			}
}


unset($smilie);



unset($smilie);


Zeile 3424Zeile 3531

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


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

			{

			{

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

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

			{

			{

				$smiliecount = $mybb->settings['smilieinsertertot'];
eval("\$getmore = \"".$templates->get("smilieinsert_getmore")."\";");
}

				$smiliecount = $mybb->settings['smilieinsertertot'];
eval("\$getmore = \"".$templates->get("smilieinsert_getmore")."\";");
}

Zeile 3505Zeile 3612
		if($pid > 0 && is_array($prefixes_cache[$pid]))
{
return $prefixes_cache[$pid];

		if($pid > 0 && is_array($prefixes_cache[$pid]))
{
return $prefixes_cache[$pid];

		}

		}


return $prefixes_cache;
}


return $prefixes_cache;
}

Zeile 3536Zeile 3643
	else if(!empty($prefixes_cache))
{
return $prefixes_cache;

	else if(!empty($prefixes_cache))
{
return $prefixes_cache;

	}

return false;
}


	}

return false;
}


/**
* Build the thread prefix selection menu for the current user
*

/**
* Build the thread prefix selection menu for the current user
*

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

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

		return '';

		return '';

	}

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

	}

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

Zeile 3574Zeile 3681
		{
// Decide whether this prefix can be used in our forum
$forums = explode(",", $prefix['forums']);

		{
// Decide whether this prefix can be used in our forum
$forums = explode(",", $prefix['forums']);





			if(!in_array($fid, $forums) && $prefix['pid'] != $previous_pid)
{
// This prefix is not in our forum list

			if(!in_array($fid, $forums) && $prefix['pid'] != $previous_pid)
{
// This prefix is not in our forum list

Zeile 3597Zeile 3704
	$prefixselect = $prefixselect_prefix = '';

if($multiple == 1)

	$prefixselect = $prefixselect_prefix = '';

if($multiple == 1)

	{

	{

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

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

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

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

	}

	}


return $prefixselect;
}


return $prefixselect;
}

Zeile 3795Zeile 3902
	{
$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 3813Zeile 3927
		"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 3824Zeile 3954
 * @return string The formatted repuation
*/
function get_reputation($reputation, $uid=0)

 * @return string The formatted repuation
*/
function get_reputation($reputation, $uid=0)

{

{

	global $theme, $templates;

$display_reputation = $reputation_class = '';
if($reputation < 0)

	global $theme, $templates;

$display_reputation = $reputation_class = '';
if($reputation < 0)

	{

	{

		$reputation_class = "reputation_negative";
}
elseif($reputation > 0)
{
$reputation_class = "reputation_positive";

		$reputation_class = "reputation_negative";
}
elseif($reputation > 0)
{
$reputation_class = "reputation_positive";

	}

	}

	else

	else

	{

	{

		$reputation_class = "reputation_neutral";
}

		$reputation_class = "reputation_neutral";
}





	$reputation = my_number_format($reputation);

if($uid != 0)
{
eval("\$display_reputation = \"".$templates->get("postbit_reputation_formatted_link")."\";");

	$reputation = my_number_format($reputation);

if($uid != 0)
{
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")."\";");

Zeile 3867Zeile 3997

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


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

	{

	{

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

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

Zeile 3899Zeile 4029
	$ip = strtolower($_SERVER['REMOTE_ADDR']);

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

	$ip = strtolower($_SERVER['REMOTE_ADDR']);

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

	{

	{

		$addresses = array();

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

		$addresses = array();

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

Zeile 4167Zeile 4297
				if(isset($password_forums[$parent]) && $mybb->cookies['forumpass'][$parent] !== md5($mybb->user['uid'].$password_forums[$parent]))
{
$pwverified = 0;

				if(isset($password_forums[$parent]) && $mybb->cookies['forumpass'][$parent] !== md5($mybb->user['uid'].$password_forums[$parent]))
{
$pwverified = 0;

				}
}
}


				}
}
}


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

	}

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


return $unviewableforums;
}


return $unviewableforums;
}

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

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

 */

 */

function fix_mktime($format, $year)
{
// Our little work around for the date < 1970 thing.

function fix_mktime($format, $year)
{
// Our little work around for the date < 1970 thing.

Zeile 4221Zeile 4351
			if(isset($navbits[$key+1]))
{
if(isset($navbits[$key+2]))

			if(isset($navbits[$key+1]))
{
if(isset($navbits[$key+2]))

				{

				{

					$sep = $navsep;
}
else

					$sep = $navsep;
}
else

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

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

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

	}

	}


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

 

if($nav)
{


if($nav)
{

Zeile 4689Zeile 4817
	$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;
}
else if($months > 1)
{
$nicetime['months'] = $months.$lang_months;
}

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

if($days == 1)

	elseif($weeks > 0)




















	{

	{

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




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

	}

	}

	else if($days > 1)

	elseif($days > 0)

	{

	{

		$nicetime['days'] = $days.$lang_days;



















































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

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

if(!isset($options['days']) || $options['days'] !== false)
{
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 4759Zeile 4931
		{
$nicetime['seconds'] = $seconds.$lang_seconds;
}

		{
$nicetime['seconds'] = $seconds.$lang_seconds;
}

	}


	}


	if(is_array($nicetime))
{
return implode(", ", $nicetime);

	if(is_array($nicetime))
{
return implode(", ", $nicetime);

Zeile 4780Zeile 4952
	if($alttrow == "trow1" && !$reset)
{
$trow = "trow2";

	if($alttrow == "trow1" && !$reset)
{
$trow = "trow2";

	}

	}

	else
{
$trow = "trow1";
}

	else
{
$trow = "trow1";
}





	$alttrow = $trow;

	$alttrow = $trow;





	return $trow;

	return $trow;

}


}


/**
* Add a user to a specific additional user group.
*

/**
* Add a user to a specific additional user group.
*

Zeile 4801Zeile 4973
function join_usergroup($uid, $joingroup)
{
global $db, $mybb;

function join_usergroup($uid, $joingroup)
{
global $db, $mybb;





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

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

	{

	{

		$user = $mybb->user;

		$user = $mybb->user;

	}

	}

	else
{
$query = $db->simple_select("users", "additionalgroups, usergroup", "uid='".(int)$uid."'");
$user = $db->fetch_array($query);

	else
{
$query = $db->simple_select("users", "additionalgroups, usergroup", "uid='".(int)$uid."'");
$user = $db->fetch_array($query);

	}


	}


	// Build the new list of additional groups for this user and make sure they're in the right format
$usergroups = "";
$usergroups = $user['additionalgroups'].",".$joingroup;

	// Build the new list of additional groups for this user and make sure they're in the right format
$usergroups = "";
$usergroups = $user['additionalgroups'].",".$joingroup;

Zeile 4821Zeile 4993
	if(is_array($groups))
{
$comma = '';

	if(is_array($groups))
{
$comma = '';

		foreach($groups as $gid)

		foreach($groups as $gid)

		{
if(trim($gid) != "" && $gid != $user['usergroup'] && !isset($donegroup[$gid]))
{

		{
if(trim($gid) != "" && $gid != $user['usergroup'] && !isset($donegroup[$gid]))
{

Zeile 4830Zeile 5002
				$donegroup[$gid] = 1;
}
}

				$donegroup[$gid] = 1;
}
}

	}


	}


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

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

Zeile 4871Zeile 5043
				$groupslist .= $comma.$gid;
$comma = ",";
$donegroup[$gid] = 1;

				$groupslist .= $comma.$gid;
$comma = ",";
$donegroup[$gid] = 1;

			}

			}

		}

		}

	}


	}


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

	$dispupdate = "";
if($leavegroup == $user['displaygroup'])
{
$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 4910Zeile 5082
		$location = htmlspecialchars_uni($_SERVER['SCRIPT_NAME']);
}
elseif(!empty($_SERVER['PHP_SELF']))

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

	{

	{

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

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

	}

	}

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

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

	{

	{

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

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

	}

	}

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

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

	}

	}

	else

	else

	{

	{

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

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

	}

	}


if($quick)
{
return $location;
}


if($quick)
{
return $location;
}





	if($fields == true)
{
global $mybb;

	if($fields == true)
{
global $mybb;

Zeile 4951Zeile 5123
				}

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

				}

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

			}
}

			}
}


return array('location' => $location, 'form_html' => $form_html, 'form_method' => $mybb->request_method);
}
else
{
if(isset($_SERVER['QUERY_STRING']))


return array('location' => $location, 'form_html' => $form_html, 'form_method' => $mybb->request_method);
}
else
{
if(isset($_SERVER['QUERY_STRING']))

		{

		{

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

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

		}

		}

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

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

		{

		{

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

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

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

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

		{

		{

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

foreach($post_array as $var)

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

foreach($post_array as $var)

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

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

				}
}

				}
}


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


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

Zeile 5022Zeile 5194
		if(!isset($lang->use_default))
{
$lang->use_default = $lang->lang_select_default;

		if(!isset($lang->use_default))
{
$lang->use_default = $lang->lang_select_default;

		}
}

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

while($theme = $db->fetch_array($query))
{
$tcache[$theme['pid']][$theme['tid']] = $theme;
}
}

		}
}

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

while($theme = $db->fetch_array($query))
{
$tcache[$theme['pid']][$theme['tid']] = $theme;
}
}


if(is_array($tcache[$tid]))
{


if(is_array($tcache[$tid]))
{

Zeile 5044Zeile 5216
			if(is_member($theme['allowedgroups']) || $theme['allowedgroups'] == "all" || $usergroup_override == true)
{
if($theme['tid'] == $selected)

			if(is_member($theme['allowedgroups']) || $theme['allowedgroups'] == "all" || $usergroup_override == true)
{
if($theme['tid'] == $selected)

				{

				{

					$sel = " selected=\"selected\"";
}


					$sel = " selected=\"selected\"";
}


Zeile 5054Zeile 5226
					eval("\$themeselect_option .= \"".$templates->get("usercp_themeselector_option")."\";");
++$num_themes;
$depthit = $depth."--";

					eval("\$themeselect_option .= \"".$templates->get("usercp_themeselector_option")."\";");
++$num_themes;
$depthit = $depth."--";

				}

				}


if(array_key_exists($theme['tid'], $tcache))
{


if(array_key_exists($theme['tid'], $tcache))
{

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

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

		}


		}


		return $themeselect;
}
else

		return $themeselect;
}
else

Zeile 5113Zeile 5285
			{
$s_theme = $theme;
break 2;

			{
$s_theme = $theme;
break 2;

			}
}
}

			}
}
}


return $s_theme;
}


return $s_theme;
}

Zeile 5146Zeile 5318
	global $mybb;

if($number == "-")

	global $mybb;

if($number == "-")

	{

	{

		return $number;
}


		return $number;
}


Zeile 5166Zeile 5338
		{
$decimals = 0;
}

		{
$decimals = 0;
}





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

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

Zeile 5186Zeile 5358
	static $use_iconv;

if(!isset($charset))

	static $use_iconv;

if(!isset($charset))

	{

	{

		$charset = my_strtolower($lang->settings['charset']);

		$charset = my_strtolower($lang->settings['charset']);

	}


	}


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

if(!isset($use_iconv))

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

if(!isset($use_iconv))

	{

	{

		$use_iconv = function_exists("iconv");
}


		$use_iconv = function_exists("iconv");
}


Zeile 5358Zeile 5530
		$lang->month_11,
$lang->month_12
);

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



 

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


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

Zeile 5683Zeile 5854
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 5724Zeile 5895
	{
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 5797Zeile 5990
	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 5902Zeile 6095
	else
{
$link = str_replace("{pid}", $pid, POST_URL);

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

		return htmlspecialchars_uni($link);
}
}

/**

		return htmlspecialchars_uni($link);
}
}

/**

 * Build the event link.
*
* @param int $eid The event ID of the event

 * Build the event link.
*
* @param int $eid The event ID of the event

Zeile 5915Zeile 6108
function get_event_link($eid)
{
$link = str_replace("{eid}", $eid, EVENT_URL);

function get_event_link($eid)
{
$link = str_replace("{eid}", $eid, EVENT_URL);

	return htmlspecialchars_uni($link);
}

/**

	return htmlspecialchars_uni($link);
}

/**

 * Build the link to a specified date on the calendar
*
* @param int $calendar The ID of the calendar

 * Build the link to a specified date on the calendar
*
* @param int $calendar The ID of the calendar

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

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

	{

	{

		$query = $db->simple_select("users", "*", "uid = '{$uid}'");
$user_cache[$uid] = $db->fetch_array($query);


		$query = $db->simple_select("users", "*", "uid = '{$uid}'");
$user_cache[$uid] = $db->fetch_array($query);


Zeile 6016Zeile 6209
	global $mybb, $db;

$username = $db->escape_string(my_strtolower($username));

	global $mybb, $db;

$username = $db->escape_string(my_strtolower($username));





	if(!isset($options['username_method']))
{
$options['username_method'] = 0;

	if(!isset($options['username_method']))
{
$options['username_method'] = 0;

Zeile 6059Zeile 6252
	if(isset($options['exists']))
{
return (bool)$db->num_rows($query);

	if(isset($options['exists']))
{
return (bool)$db->num_rows($query);

	}


	}


	return $db->fetch_array($query);
}


	return $db->fetch_array($query);
}


Zeile 6082Zeile 6275
	}

if(empty($forum_cache[$fid]))

	}

if(empty($forum_cache[$fid]))

	{
return false;
}

	{
return false;
}


if($active_override != 1)
{


if($active_override != 1)
{

Zeile 6102Zeile 6295
	}

return $forum_cache[$fid];

	}

return $forum_cache[$fid];

}


}


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

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

Zeile 6135Zeile 6328
		else
{
$thread_cache[$tid] = false;

		else
{
$thread_cache[$tid] = false;

			return false;
}

			return false;
}

	}
}


	}
}


Zeile 6170Zeile 6363
		else
{
$post_cache[$pid] = false;

		else
{
$post_cache[$pid] = false;

			return false;
}
}
}


			return false;
}
}
}


/**
* Get inactivate forums.
*

/**
* Get inactivate forums.
*

Zeile 6197Zeile 6390
		{
$inactive[] = $fid;
foreach($forum_cache as $fid1 => $forum1)

		{
$inactive[] = $fid;
foreach($forum_cache as $fid1 => $forum1)

			{

			{

				if(my_strpos(",".$forum1['parentlist'].",", ",".$fid.",") !== false && !in_array($fid1, $inactive))
{
$inactive[] = $fid1;

				if(my_strpos(",".$forum1['parentlist'].",", ",".$fid.",") !== false && !in_array($fid1, $inactive))
{
$inactive[] = $fid1;

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

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

function login_attempt_check($fatal = true)

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

{

{

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

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

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

	global $mybb, $lang, $db;
















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



























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

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

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

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

return false;

	}


	}


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

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

		// Set the expiry dateline if not set yet
if($attempts['loginlockoutexpiry'] == 0)










		{

		{

			$failedtime = $now;














			$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))
{
my_setcookie('failedlogin', $now);

		// Are we still locked out?
if($attempts['loginlockoutexpiry'] > $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));
}

return false;
}

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

return false;
}

 
		// Unlock if enough time has passed
else {





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

			if($uid > 0)






			{

			{

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

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

			}

			}

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

return false;


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

return 0;







		}
}

		}
}





	// User can attempt another login

	// User can attempt another login

	return $loginattempts;
}


	return $attempts['loginattempts'];
}


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

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

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

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

{

{

	global $db;

$uid_string = "";
if($uid)
{
$uid_string = " AND uid != '".(int)$uid."'";

	global $db;

$uid_string = "";
if($uid)
{
$uid_string = " AND uid != '".(int)$uid."'";

	}

	}

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

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





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

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

	}


	}


	return false;
}


	return false;
}


Zeile 6355Zeile 6552
{
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'];

Zeile 6379Zeile 6566
	}

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

	}

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

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


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



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


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

Zeile 6476Zeile 6662

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


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

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

	usort($words, 'build_highlight_array_sort');


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


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

Zeile 6498Zeile 6684
	}

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 7446Zeile 7644
 * @param array $array The array of forums
* @return integer The number of sub forums
*/

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

function subforums_count($array)

function subforums_count($array=array())

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

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

Zeile 7727Zeile 7925
	static $time_start;

$time = microtime(true);

	static $time_start;

$time = microtime(true);



 

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


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

Zeile 7798Zeile 7995
				{
$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 8200Zeile 8397
	if($gd_version)
{
return $gd_version;

	if($gd_version)
{
return $gd_version;

	}

	}

	if(!extension_loaded('gd'))
{
return;

	if(!extension_loaded('gd'))
{
return;

Zeile 8245Zeile 8442
		{
$c = ord($input[$i]);
if($c > 128)

		{
$c = ord($input[$i]);
if($c > 128)

			{

			{

				if($c > 247 || $c <= 191)
{
if($return)

				if($c > 247 || $c <= 191)
{
if($return)

					{

					{

						$string .= '?';
continue;

						$string .= '?';
continue;

					}

					}

					else
{
return false;
}
}
elseif($c > 239)

					else
{
return false;
}
}
elseif($c > 239)

				{

				{

					$bytes = 4;
}
elseif($c > 223)

					$bytes = 4;
}
elseif($c > 223)

Zeile 8289Zeile 8486
					$i++;
$b = ord($input[$i]);
if($b < 128 || $b > 191)

					$i++;
$b = ord($input[$i]);
if($b < 128 || $b > 191)

					{

					{

						if($return)
{
$valid = false;

						if($return)
{
$valid = false;

Zeile 8318Zeile 8515
			}
}
$input = $string;

			}
}
$input = $string;

	}

	}

	if($return)

	if($return)

	{
if($allow_mb4)
{

	{
if($allow_mb4)
{

			return $input;

			return $input;

		}

		}

		else
{
return preg_replace("#[^\\x00-\\x7F][\\x80-\\xBF]{3,}#", '?', $input);

		else
{
return preg_replace("#[^\\x00-\\x7F][\\x80-\\xBF]{3,}#", '?', $input);

Zeile 8333Zeile 8530
	else
{
if($allow_mb4)

	else
{
if($allow_mb4)

		{

		{

			return true;
}
else

			return true;
}
else

Zeile 8361Zeile 8558
	}

if(!is_array($pm))

	}

if(!is_array($pm))

	{
return false;

	{
return false;

	}

	}





	if(isset($pm['language']))
{
if($pm['language'] != $mybb->user['language'] && $lang->language_exists($pm['language']))

	if(isset($pm['language']))
{
if($pm['language'] != $mybb->user['language'] && $lang->language_exists($pm['language']))

Zeile 8372Zeile 8569
			// Load user language
$lang->set_language($pm['language']);
$lang->load($pm['language_file']);

			// Load user language
$lang->set_language($pm['language']);
$lang->load($pm['language_file']);





			$revert = true;
}

foreach(array('subject', 'message') as $key)

			$revert = true;
}

foreach(array('subject', 'message') as $key)

		{

		{

			if(is_array($pm[$key]))

			if(is_array($pm[$key]))

			{

			{

				$lang_string = $lang->{$pm[$key][0]};
$num_args = count($pm[$key]);


				$lang_string = $lang->{$pm[$key][0]};
$num_args = count($pm[$key]);


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

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

			}

			}

			else
{
$lang_string = $lang->{$pm[$key]};
}

			else
{
$lang_string = $lang->{$pm[$key]};
}





			$pm[$key] = $lang_string;
}


			$pm[$key] = $lang_string;
}


Zeile 8421Zeile 8618
	if(is_array($toid))
{
$recipients_to = $toid;

	if(is_array($toid))
{
$recipients_to = $toid;

	}

	}

	else

	else

	{

	{

		$recipients_to = array($toid);

		$recipients_to = array($toid);

	}

	}


$recipients_bcc = array();



$recipients_bcc = array();


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

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

	{

	{

		$fromid = 0;
}


		$fromid = 0;
}


Zeile 8457Zeile 8654
	}

$pm['options'] = array(

	}

$pm['options'] = array(

		"signature" => 0,

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

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

Zeile 8618Zeile 8814

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


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

 * 


 *
* @deprecated

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

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

 * 

 *

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

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

Zeile 8659Zeile 8856
		)
{
$string = "'".$string;

		)
{
$string = "'".$string;

		}


		}


		foreach($delimiters as $delimiter)

		foreach($delimiters as $delimiter)

		{

		{

			foreach($active_content_triggers as $trigger)

			foreach($active_content_triggers as $trigger)

			{

			{

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

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


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

return $string;



























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

return $string;
}

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

}

}