Vergleich inc/functions.php - 1.8.14 - 1.8.26

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


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


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

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

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

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

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

			$db->query($query);

			$db->write_query($query);

		}
}


		}
}


Zeile 609Zeile 610
}

/**

}

/**

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


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

 *

 *

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

 * @return string The generated code
*/

 * @return string The generated code
*/

function generate_post_check()

function generate_post_check($rotation_shift=0)

{
global $mybb, $session;

{
global $mybb, $session;

 

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

$seed = $rotation;


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

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

	{
return md5($mybb->user['loginkey'].$mybb->user['salt'].$mybb->user['regdate']);

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

	}

	}

	// Guests get a special string

 
	else
{

	else
{

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

		$seed .= $session->sid;

	}

	}

 

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

return md5($seed);

}

/**

}

/**

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

 * Verifies a POST check code is valid (i.e. generated using a rotation number from the past 24 hours)

 *
* @param string $code The incoming POST check code

 *
* @param string $code The incoming POST check code

 * @param boolean $silent Silent mode or not (silent mode will not show the error to the user but returns false)
* @return bool

 * @param boolean $silent Don't show an error to the user
* @return bool|void Result boolean if $silent is true, otherwise shows an error to the user

 */
function verify_post_check($code, $silent=false)
{
global $lang;

 */
function verify_post_check($code, $silent=false)
{
global $lang;

	if(generate_post_check() !== $code)






	if(
generate_post_check() !== $code &&
generate_post_check(-1) !== $code &&
generate_post_check(-2) !== $code &&
generate_post_check(-3) !== $code
)

	{
if($silent == true)
{

	{
if($silent == true)
{

Zeile 775Zeile 792

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


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

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

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

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

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

Zeile 868Zeile 885

foreach($errors as $error)
{


foreach($errors as $error)
{

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

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

	}

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

return $errors;

	}

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

return $errors;

}


}


/**
* Presents the user with a "no permission" page
*/

/**
* Presents the user with a "no permission" page
*/

Zeile 1030Zeile 1047
 */
function multipage($count, $perpage, $page, $url, $breadcrumb=false)
{

 */
function multipage($count, $perpage, $page, $url, $breadcrumb=false)
{

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

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


if($count <= $perpage)
{
return '';
}


if($count <= $perpage)
{
return '';
}

 

$args = array(
'count' => &$count,
'perpage' => &$perpage,
'page' => &$page,
'url' => &$url,
'breadcrumb' => &$breadcrumb,
);
$plugins->run_hooks('multipage', $args);

$page = (int)$page;


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


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





	$pages = ceil($count / $perpage);

$prevpage = '';

	$pages = ceil($count / $perpage);

$prevpage = '';

Zeile 1048Zeile 1076
		$prev = $page-1;
$page_url = fetch_page_url($url, $prev);
eval("\$prevpage = \"".$templates->get("multipage_prevpage")."\";");

		$prev = $page-1;
$page_url = fetch_page_url($url, $prev);
eval("\$prevpage = \"".$templates->get("multipage_prevpage")."\";");

	}

	}


// Maximum number of "page bits" to show
if(!$mybb->settings['maxmultipagelinks'])


// Maximum number of "page bits" to show
if(!$mybb->settings['maxmultipagelinks'])

Zeile 1082Zeile 1110

$start = '';
if($from > 1)


$start = '';
if($from > 1)

	{

	{

		if($from-1 == 1)
{
$lang->multipage_link_start = '';

		if($from-1 == 1)
{
$lang->multipage_link_start = '';

Zeile 1127Zeile 1155

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


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

	{

	{

		$next = $page+1;
$page_url = fetch_page_url($url, $next);
eval("\$nextpage = \"".$templates->get("multipage_nextpage")."\";");

		$next = $page+1;
$page_url = fetch_page_url($url, $next);
eval("\$nextpage = \"".$templates->get("multipage_nextpage")."\";");

	}

	}


$jumptopage = '';
if($pages > ($mybb->settings['maxmultipagelinks']+1) && $mybb->settings['jumptopagemultipage'] == 1)


$jumptopage = '';
if($pages > ($mybb->settings['maxmultipagelinks']+1) && $mybb->settings['jumptopagemultipage'] == 1)

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


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


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


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


	if($breadcrumb == true)

	if($breadcrumb == true)

	{

	{

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

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

Zeile 1189Zeile 1217
		}

$url .= "page=$page";

		}

$url .= "page=$page";

	}
else
{

	}
else
{

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

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





	return $url;
}

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

	return $url;
}

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

 * @param int $uid The user ID

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

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

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

function user_permissions($uid=0)

function user_permissions($uid=null)

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

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

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

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

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

// Its a guest. Return the group permissions directly from cache

	if($uid == 0)
{

	if($uid == 0)
{

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

		return $groupscache[1];

	}

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

	}

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

Zeile 1253Zeile 1287
function usergroup_permissions($gid=0)
{
global $cache, $groupscache, $grouppermignore, $groupzerogreater;

function usergroup_permissions($gid=0)
{
global $cache, $groupscache, $grouppermignore, $groupzerogreater;


if(!is_array($groupscache))
{


if(!is_array($groupscache))
{

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


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


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

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

				{

				{

					$permbit = $usergroup[$perm];
}
else

					$permbit = $usergroup[$perm];
}
else

				{

				{

					$permbit = "";

					$permbit = "";

				}

				}


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


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

				}


				}


				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 1370Zeile 1404
			}

$groupperms = $mybb->usergroup;

			}

$groupperms = $mybb->usergroup;

		}
}

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

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

if(!is_array($fpermcache))

		}
}

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

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

if(!is_array($fpermcache))

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

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

Zeile 1395Zeile 1429
			$cached_forum_permissions_permissions[$gid][$fid] = fetch_forum_permissions($fid, $gid, $groupperms);
}
return $cached_forum_permissions_permissions[$gid][$fid];

			$cached_forum_permissions_permissions[$gid][$fid] = fetch_forum_permissions($fid, $gid, $groupperms);
}
return $cached_forum_permissions_permissions[$gid][$fid];

	}

	}

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

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

Zeile 1425Zeile 1459
	$groups = explode(",", $gid);

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

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

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

	{

	{

		return $groupperms;
}


		return $groupperms;
}


Zeile 1454Zeile 1488
							break;
}
}

							break;
}
}

				}
}

				}
}


// If we STILL don't have forum permissions we use the usergroup itself
if(empty($level_permissions))


// If we STILL don't have forum permissions we use the usergroup itself
if(empty($level_permissions))

			{

			{

				$level_permissions = $groupscache[$gid];
}


				$level_permissions = $groupscache[$gid];
}


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

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

			}


			}


			if($level_permissions["canview"] && empty($level_permissions["canonlyviewownthreads"]))

			if($level_permissions["canview"] && empty($level_permissions["canonlyviewownthreads"]))

			{

			{

				$only_view_own_threads = 0;

				$only_view_own_threads = 0;

			}

			}


if($level_permissions["canpostreplys"] && empty($level_permissions["canonlyreplyownthreads"]))
{


if($level_permissions["canpostreplys"] && empty($level_permissions["canonlyreplyownthreads"]))
{

Zeile 1485Zeile 1519

// Figure out if we can view more than our own threads
if($only_view_own_threads == 0)


// Figure out if we can view more than our own threads
if($only_view_own_threads == 0)

	{

	{

		$current_permissions["canonlyviewownthreads"] = 0;

		$current_permissions["canonlyviewownthreads"] = 0;

	}

	}


// Figure out if we can reply more than our own threads
if($only_reply_own_threads == 0)


// Figure out if we can reply more than our own threads
if($only_reply_own_threads == 0)

	{

	{

		$current_permissions["canonlyreplyownthreads"] = 0;

		$current_permissions["canonlyreplyownthreads"] = 0;

	}


	}


	if(count($current_permissions) == 0)

	if(count($current_permissions) == 0)

	{

	{

		$current_permissions = $groupperms;

		$current_permissions = $groupperms;

	}

	}

	return $current_permissions;

	return $current_permissions;

 
}

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

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

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

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

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

}

/**

}

/**

Zeile 1540Zeile 1618
				continue;
}


				continue;
}


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

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

			{
check_forum_password($parent_id, $fid);
}
}
}


			{
check_forum_password($parent_id, $fid);
}
}
}


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

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

	{

	{

		$password = $forum_cache[$fid]['password'];

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

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

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

			if(my_hash_equals($forum_cache[$fid]['password'], $mybb->get_input('pwverify')))

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

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

Zeile 1565Zeile 1642
		}
else
{

		}
else
{

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

			if(!forum_password_validated($forum_cache[$fid]))

			{
$showform = true;
}

			{
$showform = true;
}

Zeile 1636Zeile 1713

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


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

	$user = get_user($uid);

	$user = get_user($uid);


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



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


Zeile 1794Zeile 1871
			}
}
}

			}
}
}

 
}

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

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

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

$user_perms = user_permissions($uid);

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

$fids = array();

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

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

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

return $fids;

}

/**

}

/**

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

	if(isset($mybb->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[$posticon['name']] = $posticon;
}
krsort($posticons);

	$posticons = array();
foreach($posticons_cache as $posticon)
{
$posticons[$posticon['name']] = $posticon;
}
krsort($posticons);





	foreach($posticons as $dbicon)
{
$dbicon['path'] = str_replace("{theme}", $theme['imgdir'], $dbicon['path']);

	foreach($posticons as $dbicon)
{
$dbicon['path'] = str_replace("{theme}", $theme['imgdir'], $dbicon['path']);

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

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

	}

	}

	else
{
$posticons = '';

	else
{
$posticons = '';

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

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

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

 */

 */

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

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

{
global $mybb;

if(!$mybb->settings['cookiepath'])
{
$mybb->settings['cookiepath'] = "/";

{
global $mybb;

if(!$mybb->settings['cookiepath'])
{
$mybb->settings['cookiepath'] = "/";

	}

	}


if($expires == -1)
{


if($expires == -1)
{

Zeile 1890Zeile 2024
	$cookie = "Set-Cookie: {$mybb->settings['cookieprefix']}{$name}=".urlencode($value);

if($expires > 0)

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


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


Zeile 1907Zeile 2041
	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 1915Zeile 2059
	}

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

	}

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

 *
* @param string $name The cookie identifier.

 */
function my_unsetcookie($name)
{

 */
function my_unsetcookie($name)
{

Zeile 1930Zeile 2074

$expires = -3600;
my_setcookie($name, "", $expires);


$expires = -3600;
my_setcookie($name, "", $expires);





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

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

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

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

 *
* @param string $name The cookie identifier.

 *
* @param string $name The cookie identifier.

 * @param int $id The cookie content id.
* @return array|boolean The cookie id's content array or false when non-existent.
*/

 * @param int $id The cookie content id.
* @return array|boolean The cookie id's content array or false when non-existent.
*/

Zeile 1949Zeile 2093
	{
return false;
}

	{
return false;
}





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

if(is_array($cookie) && isset($cookie[$id]))

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

if(is_array($cookie) && isset($cookie[$id]))

	{

	{

		return $cookie[$id];

		return $cookie[$id];

	}

	}

	else
{
return 0;

	else
{
return 0;

Zeile 1969Zeile 2113
 * @param int $id The cookie content id.
* @param string $value The value to set the cookie to.
* @param int|string $expires The timestamp of the expiry date.

 * @param int $id The cookie content id.
* @param string $value The value to set the cookie to.
* @param int|string $expires The timestamp of the expiry date.

 */

 */

function my_set_array_cookie($name, $id, $value, $expires="")
{
global $mybb;

function my_set_array_cookie($name, $id, $value, $expires="")
{
global $mybb;

Zeile 2014Zeile 2158
	if(strlen($str) > MAX_SERIALIZED_INPUT_LENGTH)
{
// input exceeds MAX_SERIALIZED_INPUT_LENGTH

	if(strlen($str) > MAX_SERIALIZED_INPUT_LENGTH)
{
// input exceeds MAX_SERIALIZED_INPUT_LENGTH

		return false;
}

		return false;
}


if(empty($str) || !is_string($str))
{
return false;
}



if(empty($str) || !is_string($str))
{
return false;
}


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

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



/*
* states:


/*
* states:

Zeile 2645Zeile 2788
 * @param int $fid The forum ID
*/
function update_forum_lastpost($fid)

 * @param int $fid The forum ID
*/
function update_forum_lastpost($fid)

{

{

	global $db;

// Fetch the last post for this forum

	global $db;

// Fetch the last post for this forum

Zeile 2676Zeile 2819
 * @param array $changes Array of items being updated (replies, unapprovedposts, deletedposts, attachmentcount) and their value (ex, 1, +1, -1)
*/
function update_thread_counters($tid, $changes=array())

 * @param array $changes Array of items being updated (replies, unapprovedposts, deletedposts, attachmentcount) and their value (ex, 1, +1, -1)
*/
function update_thread_counters($tid, $changes=array())

{

{

	global $db;

$update_query = array();

	global $db;

$update_query = array();

Zeile 2707Zeile 2850
			else
{
$update_query[$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;
}
}

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

	}


	}


	$db->free_result($query);

// Only update if we're actually doing something
if(count($update_query) > 0)
{
$db->update_query("threads", $update_query, "tid='{$tid}'");

	$db->free_result($query);

// Only update if we're actually doing something
if(count($update_query) > 0)
{
$db->update_query("threads", $update_query, "tid='{$tid}'");

	}

	}

}

/**

}

/**

Zeile 2752Zeile 2895
		LIMIT 1"
);
$lastpost = $db->fetch_array($query);

		LIMIT 1"
);
$lastpost = $db->fetch_array($query);


$db->free_result($query);



$db->free_result($query);


	$query = $db->query("
SELECT u.uid, u.username, p.pid, p.username AS postusername, p.dateline
FROM ".TABLE_PREFIX."posts p

	$query = $db->query("
SELECT u.uid, u.username, p.pid, p.username AS postusername, p.dateline
FROM ".TABLE_PREFIX."posts p

Zeile 2764Zeile 2907
		LIMIT 1
");
$firstpost = $db->fetch_array($query);

		LIMIT 1
");
$firstpost = $db->fetch_array($query);





	$db->free_result($query);

	$db->free_result($query);





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

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

	}


	}


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

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

Zeile 3022Zeile 3165

// At least one big letter
$str[] = $set[my_rand(10, 35)];


// At least one big letter
$str[] = $set[my_rand(10, 35)];





		// At least one small letter
$str[] = $set[my_rand(36, 61)];

		// At least one small letter
$str[] = $set[my_rand(36, 61)];





		$length -= 3;

		$length -= 3;

	}


	}


	for($i = 0; $i < $length; ++$i)
{
$str[] = $set[my_rand(0, 61)];

	for($i = 0; $i < $length; ++$i)
{
$str[] = $set[my_rand(0, 61)];

	}


	}


	// Make sure they're in random order and convert them to a string
shuffle($str);


	// Make sure they're in random order and convert them to a string
shuffle($str);


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

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

	global $groupscache, $cache;

	global $groupscache, $cache, $plugins;





	if(!is_array($groupscache))



	static $formattednames = array();

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

	{

	{

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
























		if(!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');





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

		$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 3138Zeile 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 3239Zeile 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 3286Zeile 3445
				if(!$smiliecache)
{
if(!isset($smilie_cache) || !is_array($smilie_cache))

				if(!$smiliecache)
{
if(!isset($smilie_cache) || !is_array($smilie_cache))

					{

					{

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

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

					}

					}

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

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

				}


				}


				if($mybb->settings['smilieinserter'] && $mybb->settings['smilieinsertercols'] && $mybb->settings['smilieinsertertot'] && !empty($smiliecache))
{
$emoticon = ",emoticon";
}
$emoticons_enabled = "true";

				if($mybb->settings['smilieinserter'] && $mybb->settings['smilieinsertercols'] && $mybb->settings['smilieinsertertot'] && !empty($smiliecache))
{
$emoticon = ",emoticon";
}
$emoticons_enabled = "true";





				unset($smilie);

if(is_array($smiliecache))

				unset($smilie);

if(is_array($smiliecache))

Zeile 3344Zeile 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 = "";


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

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

			{

			{

				$basic1 = "bold,italic,underline,strike|";
$basic2 = "horizontalrule,";

				$basic1 = "bold,italic,underline,strike|";
$basic2 = "horizontalrule,";

			}


			}


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

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

			{

			{

				$align = "left,center,right,justify|";
}

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

				$align = "left,center,right,justify|";
}

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

			}


			}


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

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

			{

			{

				$size = "size,";

				$size = "size,";

			}

			}


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


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

			}


			}


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

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

			}


			}


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

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

			{

			{

				$email = "email,";

				$email = "email,";

			}

			}


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


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

			}


			}


			if($mybb->settings['allowlistmycode'] == 1)
{
$list = "bulletlist,orderedlist|";

			if($mybb->settings['allowlistmycode'] == 1)
{
$list = "bulletlist,orderedlist|";

			}


			}


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

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

			{

			{

				$code = "code,php,";

				$code = "code,php,";

			}

			}


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


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





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

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





	return $codeinsert;

	return $codeinsert;

}

/**
















































}

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

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

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

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

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

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

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

return $subscription_methods[$subscription_method];
}

/**

 * Build the javascript clickable smilie inserter
*
* @return string The clickable smilies list

 * Build the javascript clickable smilie inserter
*
* @return string The clickable smilies list

Zeile 3662Zeile 3868

/**
* Build the thread prefix selection menu for a forum without group permission checks


/**
* Build the thread prefix selection menu for a forum without group permission checks

 *

 *

 *  @param int $fid The forum ID (integer ID)
* @param int $selected_pid The selected prefix ID (integer ID)
* @return string The thread prefix selection menu

 *  @param int $fid The forum ID (integer ID)
* @param int $selected_pid The selected prefix ID (integer ID)
* @return string The thread prefix selection menu

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

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

		return '';
}

		return '';
}


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


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

Zeile 3693Zeile 3899
			{
// This forum can use this prefix!
$prefixes[$prefix['pid']] = $prefix;

			{
// This forum can use this prefix!
$prefixes[$prefix['pid']] = $prefix;

			}

			}

		}
else
{

		}
else
{

Zeile 3738Zeile 3944
	eval('$prefixselect = "'.$templates->get("forumdisplay_threadlist_prefixes").'";');
return $prefixselect;
}

	eval('$prefixselect = "'.$templates->get("forumdisplay_threadlist_prefixes").'";');
return $prefixselect;
}





/**
* Gzip encodes text to a specified level
*

/**
* Gzip encodes text to a specified level
*

Zeile 3753Zeile 3959
		$httpaccept_encoding = '';

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

		$httpaccept_encoding = '';

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

		{

		{

			$httpaccept_encoding = $_SERVER['HTTP_ACCEPT_ENCODING'];
}


			$httpaccept_encoding = $_SERVER['HTTP_ACCEPT_ENCODING'];
}


Zeile 3784Zeile 3990
				$gzdata .= pack("V", $crc);
$gzdata .= pack("V", $size);
$contents = $gzdata;

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

			}
}
}


			}
}
}


	return $contents;
}


	return $contents;
}


Zeile 3803Zeile 4009

$fid = 0;
if(isset($data['fid']))


$fid = 0;
if(isset($data['fid']))

	{

	{

		$fid = (int)$data['fid'];
unset($data['fid']);
}

		$fid = (int)$data['fid'];
unset($data['fid']);
}

Zeile 3833Zeile 4039
	if(is_array($data))
{
$data = my_serialize($data);

	if(is_array($data))
{
$data = my_serialize($data);

	}


	}


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

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

Zeile 3866Zeile 4072

/**
* Get the formatted reputation for a user.


/**
* Get the formatted reputation for a user.

 *

 *

 * @param int $reputation The reputation value
* @param int $uid The user ID (if not specified, the generated reputation will not be a link)
* @return string The formatted repuation

 * @param int $reputation The reputation value
* @param int $uid The user ID (if not specified, the generated reputation will not be a link)
* @return string The formatted repuation

Zeile 3877Zeile 4083

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


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

	{

	{

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

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

	{

	{

		$reputation_class = "reputation_positive";
}
else

		$reputation_class = "reputation_positive";
}
else

Zeile 3912Zeile 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)
{

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

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

}


}


/**
* Get a list of the unviewable forums for the current user
*

/**
* Get a list of the unviewable forums for the current user
*

Zeile 4176Zeile 4382
	if(!is_array($forum_cache))
{
cache_forums();

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

	}

	}


if(!is_array($permissioncache))
{
$permissioncache = forum_permissions();
}



if(!is_array($permissioncache))
{
$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']])

		{

		{

			$perms = $permissioncache[$forum['fid']];
}
else
{
$perms = $mybb->usergroup;

			$perms = $permissioncache[$forum['fid']];
}
else
{
$perms = $mybb->usergroup;

		}


		}


		$pwverified = 1;


		$pwverified = 1;


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

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


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





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

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

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

			{
if(!forum_password_validated($forum_cache[$parent], true))
{

					$pwverified = 0;

					$pwverified = 0;

 
					break;

				}
}

				}
}

		}

		}


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


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

Zeile 4228Zeile 4431
	$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 4260Zeile 4463

$i = 0;
$activesep = '';


$i = 0;
$activesep = '';





	if(is_array($navbits))
{
reset($navbits);

	if(is_array($navbits))
{
reset($navbits);

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

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

				{

				{

					$sep = $navsep;

					$sep = $navsep;

				}

				}

				else
{
$sep = "";

				else
{
$sep = "";

				}


				}


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

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

					{

					{

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

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

					}

					}


$multipage = multipage($navbit['multipage']['num_threads'], $mybb->settings['threadsperpage'], $navbit['multipage']['current_page'], $navbit['multipage']['url'], true);
if($multipage)


$multipage = multipage($navbit['multipage']['num_threads'], $mybb->settings['threadsperpage'], $navbit['multipage']['current_page'], $navbit['multipage']['url'], true);
if($multipage)

Zeile 4292Zeile 4495
						++$i;
eval("\$multipage_dropdown = \"".$templates->get("nav_dropdown")."\";");
$sep = $multipage_dropdown.$sep;

						++$i;
eval("\$multipage_dropdown = \"".$templates->get("nav_dropdown")."\";");
$sep = $multipage_dropdown.$sep;

					}
}


					}
}


				// Replace page 1 URLs
$navbit['url'] = str_replace("-page-1.html", ".html", $navbit['url']);
$navbit['url'] = preg_replace("/&amp;page=1$/", "", $navbit['url']);

				// Replace page 1 URLs
$navbit['url'] = str_replace("-page-1.html", ".html", $navbit['url']);
$navbit['url'] = preg_replace("/&amp;page=1$/", "", $navbit['url']);





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

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

	}

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

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




if($nav)
{


if($nav)
{

Zeile 4314Zeile 4515
	}

eval("\$activebit = \"".$templates->get("nav_bit_active")."\";");

	}

eval("\$activebit = \"".$templates->get("nav_bit_active")."\";");

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

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


return $donenav;
}


return $donenav;
}

Zeile 4377Zeile 4578
				{
// Set up link to forum in breadcrumb.
if($pforumcache[$fid][$forumnav['pid']]['type'] == 'f' || $pforumcache[$fid][$forumnav['pid']]['type'] == 'c')

				{
// Set up link to forum in breadcrumb.
if($pforumcache[$fid][$forumnav['pid']]['type'] == 'f' || $pforumcache[$fid][$forumnav['pid']]['type'] == 'c')

					{

					{

						$navbits[$navsize]['url'] = "{$base_url}forum-".$forumnav['fid'].".html";
}
else

						$navbits[$navsize]['url'] = "{$base_url}forum-".$forumnav['fid'].".html";
}
else

Zeile 4423Zeile 4624

/**
* Builds a URL to an archive mode page


/**
* Builds a URL to an archive mode page

 *

 *

 * @param string $type The type of page (thread|announcement|forum)
* @param int $id The ID of the item
* @return string The URL

 * @param string $type The type of page (thread|announcement|forum)
* @param int $id The ID of the item
* @return string The URL

Zeile 4616Zeile 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 4678Zeile 4876
 * @return string The friendly formatted timestamp
*/
function nice_time($stamp, $options=array())

 * @return string The friendly formatted timestamp
*/
function nice_time($stamp, $options=array())

{

{

	global $lang;

$ysecs = 365*24*60*60;

	global $lang;

$ysecs = 365*24*60*60;

Zeile 4739Zeile 4937

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


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

	{

	{

		$options = array_merge(array(
'days' => false,
'hours' => false,

		$options = array_merge(array(
'days' => false,
'hours' => false,

Zeile 4770Zeile 4968
	}

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

	}

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

	{

	{

		if($years == 1)
{
$nicetime['years'] = "1".$lang_year;

		if($years == 1)
{
$nicetime['years'] = "1".$lang_year;

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

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

		}

		}

		else if($months > 1)

		else if($months > 1)

		{

		{

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

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

		}
}


		}
}


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

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

		{

		{

			$nicetime['weeks'] = "1".$lang_week;

			$nicetime['weeks'] = "1".$lang_week;

		}

		}

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

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

		}
}


		}
}


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

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

		{

		{

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

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

		}

		}

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

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

		}
}


		}
}


	if(!isset($options['hours']) || $options['hours'] !== false)
{
if($hours == 1)
{
$nicetime['hours'] = "1".$lang_hour;

	if(!isset($options['hours']) || $options['hours'] !== false)
{
if($hours == 1)
{
$nicetime['hours'] = "1".$lang_hour;

		}

		}

		else if($hours > 1)
{
$nicetime['hours'] = $hours.$lang_hours;

		else if($hours > 1)
{
$nicetime['hours'] = $hours.$lang_hours;

		}
}


		}
}


	if(!isset($options['minutes']) || $options['minutes'] !== false)
{
if($minutes == 1)

	if(!isset($options['minutes']) || $options['minutes'] !== false)
{
if($minutes == 1)

		{

		{

			$nicetime['minutes'] = "1".$lang_minute;

			$nicetime['minutes'] = "1".$lang_minute;

		}

		}

		else if($minutes > 1)
{
$nicetime['minutes'] = $minutes.$lang_minutes;

		else if($minutes > 1)
{
$nicetime['minutes'] = $minutes.$lang_minutes;

Zeile 4842Zeile 5040
	}

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

	}

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

	{

	{

		if($seconds == 1)
{
$nicetime['seconds'] = "1".$lang_second;

		if($seconds == 1)
{
$nicetime['seconds'] = "1".$lang_second;

Zeile 4882Zeile 5080

return $trow;
}


return $trow;
}





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

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

Zeile 4905Zeile 5103
	}

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

	}

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

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







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

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





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

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

















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

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

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

Zeile 4948Zeile 5137

$user = get_user($uid);



$user = get_user($uid);


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

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

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

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

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

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







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


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

	{
$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 4986Zeile 5170
 * Get the current location taking in to account different web serves and systems
*
* @param boolean $fields True to return as "hidden" fields

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

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

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

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

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

 * @return string The current URL being accessed

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

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

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

 
	global $mybb;


	if(defined("MYBB_LOCATION"))

	if(defined("MYBB_LOCATION"))

	{

	{

		return MYBB_LOCATION;

		return MYBB_LOCATION;

	}

	}


if(!empty($_SERVER['SCRIPT_NAME']))


if(!empty($_SERVER['SCRIPT_NAME']))

	{

	{

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

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

	}

	}

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

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

	{

	{

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

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

	}

	}

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

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

	{

	{

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

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

	}

	}

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

if($quick)

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

if($quick)

	{

	{

		return $location;
}

		return $location;
}









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


	if($fields == true)
{

	if($fields == true)
{

		global $mybb;

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

 

$form_html = '';
if(!empty($mybb->input))
{
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 5050Zeile 5235
	}
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);

foreach($current_parameters as $name => $value)
{
if(!in_array($name, $ignore))
{
$parameters[$name] = $value;
}

		}


		}


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

		if($mybb->request_method === 'post')

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

foreach($post_array as $var)
{

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

foreach($post_array as $var)
{

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

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

				{

				{

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

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

				}

				}

			}

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

 
			}

			}

 
		}

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

		}

return $location;

		}

return $location;

Zeile 5091Zeile 5283

/**
* Build a theme selection menu


/**
* Build a theme selection menu

 *

 *

 * @param string $name The name of the menu
* @param int $selected The ID of the selected theme
* @param int $tid The ID of the parent theme to select from

 * @param string $name The name of the menu
* @param int $selected The ID of the selected theme
* @param int $tid The ID of the parent theme to select from

Zeile 5450Zeile 5642
		$lang->month_11,
$lang->month_12
);

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



 

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


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

Zeile 5465Zeile 5656
		'F',
'l',
'M',

		'F',
'l',
'M',

	);


	);


	$html = array(
'&#109;',
'&#110;',

	$html = array(
'&#109;',
'&#110;',

Zeile 5545Zeile 5736

$query = $db->query("
SELECT u.uid, u.username, p.pid, p.username AS postusername, p.dateline


$query = $db->query("
SELECT u.uid, u.username, p.pid, p.username AS postusername, p.dateline

		FROM ".TABLE_PREFIX."posts p

		FROM ".TABLE_PREFIX."posts p

		LEFT JOIN ".TABLE_PREFIX."users u ON (u.uid=p.uid)
WHERE p.tid='$tid'
ORDER BY p.dateline ASC

		LEFT JOIN ".TABLE_PREFIX."users u ON (u.uid=p.uid)
WHERE p.tid='$tid'
ORDER BY p.dateline ASC

Zeile 5576Zeile 5767
function update_last_post($tid)
{
global $db;

function update_last_post($tid)
{
global $db;





	$query = $db->query("
SELECT u.uid, u.username, p.username AS postusername, p.dateline
FROM ".TABLE_PREFIX."posts p

	$query = $db->query("
SELECT u.uid, u.username, p.username AS postusername, p.dateline
FROM ".TABLE_PREFIX."posts p

Zeile 5586Zeile 5777
		LIMIT 1"
);
$lastpost = $db->fetch_array($query);

		LIMIT 1"
);
$lastpost = $db->fetch_array($query);





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

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

	}


	}


	if(empty($lastpost['dateline']))
{
$query = $db->query("

	if(empty($lastpost['dateline']))
{
$query = $db->query("

Zeile 5607Zeile 5798
		$lastpost['username'] = $firstpost['username'];
$lastpost['uid'] = $firstpost['uid'];
$lastpost['dateline'] = $firstpost['dateline'];

		$lastpost['username'] = $firstpost['username'];
$lastpost['uid'] = $firstpost['uid'];
$lastpost['dateline'] = $firstpost['dateline'];

	}

	}


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



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


Zeile 5652Zeile 5843
	}

return $string_length;

	}

return $string_length;

}

/**

}

/**

 * Cuts a string at a specified point, mb strings accounted for
*
* @param string $string The string to cut.

 * Cuts a string at a specified point, mb strings accounted for
*
* @param string $string The string to cut.

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

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

	{
if($length != null)
{

	{
if($length != null)
{

			$cut_string = mb_substr($string, $start, $length);

			$cut_string = mb_substr($string, $start, $length);

		}

		}

		else

		else

		{

		{

			$cut_string = mb_substr($string, $start);
}
}

			$cut_string = mb_substr($string, $start);
}
}

Zeile 5685Zeile 5876
		if($length != null)
{
$cut_string = substr($string, $start, $length);

		if($length != null)
{
$cut_string = substr($string, $start, $length);

		}

		}

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

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

	}


	}


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

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

Zeile 5701Zeile 5892

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


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

 *

 *

 * @param string $string The string to lower.
* @return string The lowered string.
*/

 * @param string $string The string to lower.
* @return string The lowered string.
*/

Zeile 5713Zeile 5904
	}
else
{

	}
else
{

		$string = strtolower($string);




























		$string = strtolower($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 $string;

	return $position;

}

/**

}

/**

Zeile 6190Zeile 6408
	global $cache;
static $forum_cache;


	global $cache;
static $forum_cache;


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

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

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

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

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

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

function login_attempt_check($fatal = true)

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

{

{

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

	global $mybb, $lang, $db;





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

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

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

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

// Work out if the user has had more than the allowed number of login attempts
if($loginattempts > $mybb->settings['failedlogincount'])
{
// If so, then we need to work out if they can try to login again
// Some maths to work out how long they have left and display it to them
$now = TIME_NOW;

if(empty($mybb->cookies['failedlogin']))
{
$failedtime = $now;




















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

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

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

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

return false;
}

if($mybb->settings['failedlogincount'] > 0 && $attempts['loginattempts'] >= $mybb->settings['failedlogincount'])
{
// Set the expiry dateline if not set yet
if($attempts['loginlockoutexpiry'] == 0)
{
$attempts['loginlockoutexpiry'] = $now + ((int)$mybb->settings['failedlogintime'] * 60);

// Add a cookie lockout. This is used to prevent access to the login page immediately.
// A deep lockout is issued if he tries to login into a locked out account
my_setcookie('lockoutexpiry', $attempts['loginlockoutexpiry']);

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

if(empty($mybb->cookies['lockoutexpiry']))
{
$failedtime = $attempts['loginlockoutexpiry'];

		}
else

		}
else

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

		{
$failedtime = $mybb->cookies['lockoutexpiry'];

		}


		}


		$secondsleft = $mybb->settings['failedlogintime'] * 60 + $failedtime - $now;
$hoursleft = floor($secondsleft / 3600);
$minsleft = floor(($secondsleft / 60) % 60);
$secsleft = floor($secondsleft % 60);

// This value will be empty the first time the user doesn't login in, set it
if(empty($failedlogin))

		// Are we still locked out?
if($attempts['loginlockoutexpiry'] > $now)






		{

		{

			my_setcookie('failedlogin', $now);

 
			if($fatal)
{

			if($fatal)
{

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


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

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)
{
$update_array = array(
'loginattempts' => 1
);
$db->update_query("users", $update_array, "uid = '{$mybb->user['uid']}'");
}
return 1;
}
// Not waited long enough
else if($mybb->cookies['failedlogin'] > ($now - $mybb->settings['failedlogintime'] * 60))
{
if($fatal)

			if($uid > 0)


















			{

			{

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




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

			}


			}


			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 6424Zeile 6651
 *
* @param string $email The string to check.
* @return boolean True when valid, false when invalid.

 *
* @param string $email The string to check.
* @return boolean True when valid, false when invalid.

 */

 */

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 6452Zeile 6674
		$uid_string = " AND uid != '".(int)$uid."'";
}
$query = $db->simple_select("users", "COUNT(email) as emails", "email = '".$db->escape_string($email)."'{$uid_string}");

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





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

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

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

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

 

$setting['name'] = addcslashes($setting['name'], "\\'");

		$setting['value'] = addcslashes($setting['value'], '\\"$');
$settings .= "\$settings['{$setting['name']}'] = \"{$setting['value']}\";\n";
}

		$setting['value'] = addcslashes($setting['value'], '\\"$');
$settings .= "\$settings['{$setting['name']}'] = \"{$setting['value']}\";\n";
}

Zeile 7029Zeile 7253

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


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

				preg_match('/Location:(.*?)(?:\n|$)/', $header, $matches);

				preg_match('/^Location:(.*?)(?:\n|$)/im', $header, $matches);


if($matches)
{


if($matches)
{

Zeile 7090Zeile 7314
					'ssl' => array(
'verify_peer' => false,
'verify_peer_name' => false,

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

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

					),
));
}

					),
));
}

Zeile 7154Zeile 7379

if($max_redirects > 0 && (strstr($status_line, ' 301 ') || strstr($status_line, ' 302 ')))
{


if($max_redirects > 0 && (strstr($status_line, ' 301 ') || strstr($status_line, ' 302 ')))
{

			preg_match('/Location:(.*?)(?:\n|$)/', $header, $matches);

			preg_match('/^Location:(.*?)(?:\n|$)/im', $header, $matches);


if($matches)
{


if($matches)
{

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

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

function subforums_count($array)

function subforums_count($array=array())

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

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

Zeile 7842Zeile 8067
	static $time_start;

$time = microtime(true);

	static $time_start;

$time = microtime(true);



 

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


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

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

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

					$contents = '';

					$hashingContext = hash_init('sha512');

					while(!feof($handle))
{

					while(!feof($handle))
{

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

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

					}
fclose($handle);


					}
fclose($handle);


					$md5 = md5($contents);

					$checksum = hash_final($hashingContext);


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


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

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

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

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

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

Zeile 8572Zeile 8796
	}

$pm['options'] = array(

	}

$pm['options'] = array(

		"signature" => 0,

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

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

Zeile 8657Zeile 8880

if(file_exists($file_path))
{


if(file_exists($file_path))
{

 

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


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

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

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

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

 
 * @deprecated

 * @param  string $string         String to stripe
* @param string $allowable_tags Allowed html tags
*
* @return string Striped string
*/
function my_strip_tags($string, $allowable_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 = '')

{

{

	$pattern = array(
'@(&lt;)style[^(&gt;)]*?(&gt;).*?(&lt;)/style(&gt;)@siu',
'@(&lt;)script[^(&gt;)]*?.*?(&lt;)/script(&gt;)@siu',

	$pattern = array(
'@(&lt;)style[^(&gt;)]*?(&gt;).*?(&lt;)/style(&gt;)@siu',
'@(&lt;)script[^(&gt;)]*?.*?(&lt;)/script(&gt;)@siu',

Zeile 8754Zeile 8990
/**
* Escapes a RFC 4180-compliant CSV string.
* Based on https://github.com/Automattic/camptix/blob/f80725094440bf09861383b8f11e96c177c45789/camptix.php#L2867

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

 * @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($escape_active_content)
{
$active_content_triggers = array('=', '+', '-', '@');
$delimiters = array(',', ';', ':', '|', '^', "\n", "\t", " ");

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





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

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

		}


		}


		foreach($delimiters as $delimiter)

		foreach($delimiters as $delimiter)

		{

		{

			foreach($active_content_triggers as $trigger)

			foreach($active_content_triggers as $trigger)

			{

			{

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


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


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

return $string;











































































































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

return $string;
}

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

/**
* Performs a timing attack safe string comparison.
*
* @param string $known_string The first string to be compared.
* @param string $user_string The second, user-supplied string to be compared.
* @return bool Result of the comparison.
*/
function my_hash_equals($known_string, $user_string)
{
if(version_compare(PHP_VERSION, '5.6.0', '>='))
{
return hash_equals($known_string, $user_string);
}
else
{
$known_string_length = my_strlen($known_string);
$user_string_length = my_strlen($user_string);

if($user_string_length != $known_string_length)
{
return false;
}

$result = 0;

for($i = 0; $i < $known_string_length; $i++)
{
$result |= ord($known_string[$i]) ^ ord($user_string[$i]);
}

return $result === 0;
}
}

/**
* Retrieves all referrals for a specified user
*
* @param int uid
* @param int start position
* @param int total entries
* @param bool false (default) only return display info, true for all info
* @return array
*/
function get_user_referrals($uid, $start=0, $limit=0, $full=false)
{
global $db;

$referrals = $query_options = array();
$uid = (int) $uid;

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

if($start && $limit)
{
$query_options['limit_start'] = $start;
}

if($limit)
{
$query_options['limit'] = $limit;
}

$fields = 'uid, username, usergroup, displaygroup, regdate';
if($full === true)
{
$fields = '*';
}

$query = $db->simple_select('users', $fields, "referrer='{$uid}'", $query_options);

while($referral = $db->fetch_array($query))
{
$referrals[] = $referral;
}

return $referrals;

}

}