Vergleich inc/functions.php - 1.8.15 - 1.8.24

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


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


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

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

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

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

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

			$db->query($query);

			$db->write_query($query);

		}
}


		}
}


Zeile 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']);
}
// Guests get a special string

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


	else
{

	else
{

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

		$seed .= $session->sid;

	}

	}

 

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

return md5($seed);

}

/**

}

/**

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

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

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

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

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

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

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

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

	if(generate_post_check() !== $code)






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

	{
if($silent == true)
{

	{
if($silent == true)
{

Zeile 653Zeile 670
			{
error($lang->invalid_post_code);
}

			{
error($lang->invalid_post_code);
}

		}

		}

	}
else
{

	}
else
{

Zeile 684Zeile 701
	{
cache_forums();
return $forum_cache[$fid]['parentlist'];

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

	}
}

	}
}


/**
* Build a parent list of a specific forum, suitable for querying


/**
* Build a parent list of a specific forum, suitable for querying

Zeile 701Zeile 718
	if(!$parentlist)
{
$parentlist = get_parent_list($fid);

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

	}


	}


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

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





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

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





	$builtlist .= ")";

	$builtlist .= ")";





	return $builtlist;

	return $builtlist;

}


}


/**
* Load the forum cache in to memory
*

/**
* Load the forum cache in to memory
*

Zeile 732Zeile 749
	{
$forum_cache = $cache->read("forums", 1);
return $forum_cache;

	{
$forum_cache = $cache->read("forums", 1);
return $forum_cache;

	}


	}


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

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

Zeile 748Zeile 765

/**
* Generate an array of all child and descendant forums for a specific forum.


/**
* Generate an array of all child and descendant forums for a specific forum.

 *

 *

 * @param int $fid The forum ID
* @return Array of descendants
*/

 * @param int $fid The forum ID
* @return Array of descendants
*/

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

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

		exit;
}

if(!$title)

		exit;
}

if(!$title)

	{
$title = $mybb->settings['bbname'];
}

	{
$title = $mybb->settings['bbname'];
}

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

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

	}


	}


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

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

Zeile 868Zeile 885

foreach($errors as $error)
{


foreach($errors as $error)
{

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

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

	}

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

return $errors;

	}

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

return $errors;

}

/**

}

/**

 * Presents the user with a "no permission" page
*/
function error_no_permission()

 * Presents the user with a "no permission" page
*/
function error_no_permission()

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

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

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

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


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


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

 

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

$page = (int)$page;


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


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

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


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


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

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


if($breadcrumb == true)
{


if($breadcrumb == true)
{

Zeile 1201Zeile 1229
/**
* Fetch the permissions for a specific user
*

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

 * @param int $uid The user ID

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

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

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

function user_permissions($uid=0)

function user_permissions($uid=null)

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

// 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
if($uid != $mybb->user['uid'])
{
// We've already cached permissions for this user, return them.
if(!empty($user_cache[$uid]['permissions']))

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

		{

		{

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


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


Zeile 1239Zeile 1273
	}
// This user is the current user, return their permissions
else

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

	{

	{

		return $mybb->usergroup;
}
}

		return $mybb->usergroup;
}
}

Zeile 1254Zeile 1288
{
global $cache, $groupscache, $grouppermignore, $groupzerogreater;


{
global $cache, $groupscache, $grouppermignore, $groupzerogreater;


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

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

if(count($groups) == 1)

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

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

if(count($groups) == 1)

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

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





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


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


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

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

		}


		}


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

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

				{

				{

					$permbit = $usergroup[$perm];

					$permbit = $usergroup[$perm];

				}

				}

				else
{
$permbit = "";

				else
{
$permbit = "";

Zeile 1292Zeile 1326

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


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

				{

				{

					$usergroup[$perm] = 0;
continue;

					$usergroup[$perm] = 0;
continue;

				}

				}


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


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

Zeile 1304Zeile 1338
			}
}
}

			}
}
}





	return $usergroup;

	return $usergroup;

}


}


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

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

Zeile 1354Zeile 1388
	if(!$gid || $gid == 0) // If no group, we need to fetch it
{
if($uid != 0 && $uid != $mybb->user['uid'])

	if(!$gid || $gid == 0) // If no group, we need to fetch it
{
if($uid != 0 && $uid != $mybb->user['uid'])

		{

		{

			$user = get_user($uid);

			$user = get_user($uid);





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

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

Zeile 1370Zeile 1404
			}

$groupperms = $mybb->usergroup;

			}

$groupperms = $mybb->usergroup;

		}
}

		}
}


if(!is_array($forum_cache))


if(!is_array($forum_cache))

	{
$forum_cache = cache_forums();

	{
$forum_cache = cache_forums();


if(!$forum_cache)
{


if(!$forum_cache)
{

Zeile 1384Zeile 1418
	}

if(!is_array($fpermcache))

	}

if(!is_array($fpermcache))

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

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

	}

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

	}

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

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

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

	}


	}


	$current_permissions = array();
$only_view_own_threads = 1;
$only_reply_own_threads = 1;

	$current_permissions = array();
$only_view_own_threads = 1;
$only_reply_own_threads = 1;

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 1643Zeile 1720
	if(!empty($user['additionalgroups']))
{
$extra_groups = explode(",", $user['additionalgroups']);

	if(!empty($user['additionalgroups']))
{
$extra_groups = explode(",", $user['additionalgroups']);





		foreach($extra_groups as $extra_group)
{
$groups[] = $extra_group;

		foreach($extra_groups as $extra_group)
{
$groups[] = $extra_group;

Zeile 1676Zeile 1753
				{
// The user doesn't have permission to set this action
$perms[$action] = 0;

				{
// The user doesn't have permission to set this action
$perms[$action] = 0;

				}

				}

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

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

				}
}
}


				}
}
}


		foreach($groups as $group)
{
if(!is_array($forum['usergroups'][$group]))

		foreach($groups as $group)
{
if(!is_array($forum['usergroups'][$group]))

			{

			{

				// There are no permissions set for this group
continue;

				// There are no permissions set for this group
continue;

			}


			}


			$perm = $forum['usergroups'][$group];
foreach($perm as $action => $value)
{

			$perm = $forum['usergroups'][$group];
foreach($perm as $action => $value)
{

Zeile 1699Zeile 1776
				{
continue;
}

				{
continue;
}





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

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

Zeile 1708Zeile 1785
	$modpermscache[$fid][$uid] = $perms;

return $perms;

	$modpermscache[$fid][$uid] = $perms;

return $perms;

}


}


/**
* Checks if a moderator has permissions to perform an action in a specific forum
*

/**
* Checks if a moderator has permissions to perform an action in a specific forum
*

Zeile 1721Zeile 1798
function is_moderator($fid=0, $action="", $uid=0)
{
global $mybb, $cache;

function is_moderator($fid=0, $action="", $uid=0)
{
global $mybb, $cache;


if($uid == 0)
{


if($uid == 0)
{

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


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


Zeile 1739Zeile 1816
		{
$forumpermissions = forum_permissions($fid);
if($forumpermissions['canview'] && $forumpermissions['canviewthreads'] && !$forumpermissions['canonlyviewownthreads'])

		{
$forumpermissions = forum_permissions($fid);
if($forumpermissions['canview'] && $forumpermissions['canviewthreads'] && !$forumpermissions['canonlyviewownthreads'])

			{
return true;
}

			{
return true;
}

			return false;
}
return true;

			return false;
}
return true;

Zeile 1758Zeile 1835
					if(isset($modusers['users'][$uid]) && $modusers['users'][$uid]['mid'] && (!$action || !empty($modusers['users'][$uid][$action])))
{
return true;

					if(isset($modusers['users'][$uid]) && $modusers['users'][$uid]['mid'] && (!$action || !empty($modusers['users'][$uid][$action])))
{
return true;

					}

					}


$groups = explode(',', $user_perms['all_usergroups']);



$groups = explode(',', $user_perms['all_usergroups']);


Zeile 1772Zeile 1849
				}
}
return false;

				}
}
return false;

		}
else
{

		}
else
{

			$modperms = get_moderator_permissions($fid, $uid);

if(!$action && $modperms)

			$modperms = get_moderator_permissions($fid, $uid);

if(!$action && $modperms)

Zeile 1782Zeile 1859
				return true;
}
else

				return true;
}
else

			{

			{

				if(isset($modperms[$action]) && $modperms[$action] == 1)

				if(isset($modperms[$action]) && $modperms[$action] == 1)

				{

				{

					return true;

					return true;

				}

				}

				else
{
return false;

				else
{
return false;

Zeile 1794Zeile 1871
			}
}
}

			}
}
}

 
}

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

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

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

$user_perms = user_permissions($uid);

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

$fids = array();

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

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

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

return $fids;

}

/**

}

/**

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

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

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

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

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

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

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

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

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

 */

 */

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

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

{
global $mybb;


{
global $mybb;


Zeile 1874Zeile 2008
		$expires = 0;
}
elseif($expires == "" || $expires == null)

		$expires = 0;
}
elseif($expires == "" || $expires == null)

	{

	{

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

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

	{

	{

		$expires = TIME_NOW + (int)$expires;
}


		$expires = TIME_NOW + (int)$expires;
}


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

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

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

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

	}


	}


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

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

	}


	}


	if($httponly == true)

	if($httponly == true)

	{

	{

		$cookie .= "; HttpOnly";

		$cookie .= "; HttpOnly";

 
	}

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

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

	}

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

	}

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

Zeile 2022Zeile 2166
		return false;
}


		return false;
}


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

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



/*
* states:


/*
* states:

Zeile 3154Zeile 3297

if($dimensions)
{


if($dimensions)
{

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

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


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


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

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

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


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


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

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

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

			"editor_veoh" => "Veoh",

			"editor_mixer" => "Mixer",

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

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

Zeile 3425Zeile 3568
	}

return $codeinsert;

	}

return $codeinsert;

 
}

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

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

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

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

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

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

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

return $subscription_methods[$subscription_method];

}

/**

}

/**

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

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





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

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

		{

		{

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

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

Zeile 3447Zeile 3637
		if(!$smiliecache)
{
if(!is_array($smilie_cache))

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

			{

			{

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

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

			}
}

unset($smilie);


			}
}

unset($smilie);


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

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

Zeile 3546Zeile 3736
		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;
}


	$prefix_cache = $cache->read("threadprefixes");

if(!is_array($prefix_cache))

	$prefix_cache = $cache->read("threadprefixes");

if(!is_array($prefix_cache))

	{

	{

		// No cache
$prefix_cache = $cache->read("threadprefixes", true);


		// No cache
$prefix_cache = $cache->read("threadprefixes", true);


Zeile 3562Zeile 3752
		{
return array();
}

		{
return array();
}

	}

	}


$prefixes_cache = array();
foreach($prefix_cache as $prefix)


$prefixes_cache = array();
foreach($prefix_cache as $prefix)

	{

	{

		$prefixes_cache[$prefix['pid']] = $prefix;
}


		$prefixes_cache[$prefix['pid']] = $prefix;
}


Zeile 3581Zeile 3771

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 3671Zeile 3861
	else
{
eval("\$prefixselect = \"".$templates->get("post_prefixselect_single")."\";");

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

	}


	}


	return $prefixselect;
}


	return $prefixselect;
}


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


		$permissioncache = forum_permissions();
}


	$password_forums = $unviewable = array();

	$unviewable = array();

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

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

Zeile 4213Zeile 4403

$pwverified = 1;



$pwverified = 1;


		if($forum['password'] != "")



if(!forum_password_validated($forum, true))

		{

		{

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

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

			$pwverified = 0;






		}
else
{

		}
else
{

Zeile 4228Zeile 4414
			$parents = explode(",", $forum['parentlist']);
foreach($parents as $parent)
{

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

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

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

				{
$pwverified = 0;

				{
$pwverified = 0;

 
					break;

				}
}
}

				}
}
}

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

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

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

	}

	}


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

 

if($nav)
{
eval("\$activesep = \"".$templates->get("nav_sep_active")."\";");
}


if($nav)
{
eval("\$activesep = \"".$templates->get("nav_sep_active")."\";");
}





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

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





	return $donenav;

	return $donenav;

}

/**

}

/**

 * Add a breadcrumb menu item to the list.
*
* @param string $name The name of the item to add

 * Add a breadcrumb menu item to the list.
*
* @param string $name The name of the item to add

Zeile 4348Zeile 4533
	$navsize = count($navbits);
$navbits[$navsize]['name'] = $name;
$navbits[$navsize]['url'] = $url;

	$navsize = count($navbits);
$navbits[$navsize]['name'] = $name;
$navbits[$navsize]['url'] = $url;

}


}


/**
* Build the forum breadcrumb nagiation (the navigation to a specific forum including all parent forums)
*

/**
* Build the forum breadcrumb nagiation (the navigation to a specific forum including all parent forums)
*

Zeile 4435Zeile 4620

unset($GLOBALS['navbits']);
$GLOBALS['navbits'] = $newnav;


unset($GLOBALS['navbits']);
$GLOBALS['navbits'] = $newnav;

}

/**

}

/**

 * Builds a URL to an archive mode page
*
* @param string $type The type of page (thread|announcement|forum)

 * Builds a URL to an archive mode page
*
* @param string $type The type of page (thread|announcement|forum)

Zeile 4453Zeile 4638
	if($mybb->settings['seourls_archive'] == 1)
{
$base_url = $mybb->settings['bburl']."/archive/index.php/";

	if($mybb->settings['seourls_archive'] == 1)
{
$base_url = $mybb->settings['bburl']."/archive/index.php/";

	}

	}

	else
{
$base_url = $mybb->settings['bburl']."/archive/index.php?";

	else
{
$base_url = $mybb->settings['bburl']."/archive/index.php?";

Zeile 4500Zeile 4685
	$phpversion = PHP_VERSION;

$serverload = get_server_load();

	$phpversion = PHP_VERSION;

$serverload = get_server_load();





	if($mybb->settings['gzipoutput'] != 0)
{
$gzipen = "Enabled";

	if($mybb->settings['gzipoutput'] != 0)
{
$gzipen = "Enabled";

Zeile 4563Zeile 4748
	else
{
$memory_usage = get_friendly_size($memory_usage)." ({$memory_usage} bytes)";

	else
{
$memory_usage = get_friendly_size($memory_usage)." ({$memory_usage} bytes)";

	}

	}

	$memory_limit = @ini_get("memory_limit");
echo "<tr>\n";
echo "<td bgcolor=\"#EFEFEF\" width=\"25%\"><b><span style=\"font-family: tahoma; font-size: 12px;\">Memory Usage:</span></b></td>\n";

	$memory_limit = @ini_get("memory_limit");
echo "<tr>\n";
echo "<td bgcolor=\"#EFEFEF\" width=\"25%\"><b><span style=\"font-family: tahoma; font-size: 12px;\">Memory Usage:</span></b></td>\n";

Zeile 4594Zeile 4779
	echo "<h2>Template Statistics</h2>\n";

if(count($templates->cache) > 0)

	echo "<h2>Template Statistics</h2>\n";

if(count($templates->cache) > 0)

	{
echo "<table style=\"background-color: #666;\" width=\"95%\" cellpadding=\"4\" cellspacing=\"1\" align=\"center\">\n";

	{
echo "<table style=\"background-color: #666;\" width=\"95%\" cellpadding=\"4\" cellspacing=\"1\" align=\"center\">\n";

		echo "<tr>\n";
echo "<td style=\"background-color: #ccc;\"><strong>Templates Used (Loaded for this Page) - ".count($templates->cache)." Total</strong></td>\n";

		echo "<tr>\n";
echo "<td style=\"background-color: #ccc;\"><strong>Templates Used (Loaded for this Page) - ".count($templates->cache)." Total</strong></td>\n";

		echo "</tr>\n";
echo "<tr>\n";

		echo "</tr>\n";
echo "<tr>\n";

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

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

Zeile 4611Zeile 4796
		echo "<table style=\"background-color: #666;\" width=\"95%\" cellpadding=\"4\" cellspacing=\"1\" align=\"center\">\n";
echo "<tr>\n";
echo "<td style=\"background-color: #ccc;\"><strong>Templates Requiring Additional Calls (Not Cached at Startup) - ".count($templates->uncached_templates)." Total</strong></td>\n";

		echo "<table style=\"background-color: #666;\" width=\"95%\" cellpadding=\"4\" cellspacing=\"1\" align=\"center\">\n";
echo "<tr>\n";
echo "<td style=\"background-color: #ccc;\"><strong>Templates Requiring Additional Calls (Not Cached at Startup) - ".count($templates->uncached_templates)." Total</strong></td>\n";

		echo "</tr>\n";

		echo "</tr>\n";

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

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

Zeile 4632Zeile 4817

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


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

		header("Expires: Sat, 1 Jan 2000 01:00:00 GMT");
header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
header("Cache-Control: no-cache, must-revalidate");
header("Pragma: no-cache");

		header("Cache-Control: no-cache, private");




	}
}


	}
}


Zeile 4646Zeile 4828
 * @param string $type The type of item the above IDs are for - post, posts, thread, threads, forum, all
*/
function mark_reports($id, $type="post")

 * @param string $type The type of item the above IDs are for - post, posts, thread, threads, forum, all
*/
function mark_reports($id, $type="post")

{

{

	global $db, $cache, $plugins;

switch($type)

	global $db, $cache, $plugins;

switch($type)

Zeile 4694Zeile 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 4884Zeile 5066
function alt_trow($reset=0)
{
global $alttrow;

function alt_trow($reset=0)
{
global $alttrow;





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

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

Zeile 4932Zeile 5114
		foreach($groups as $gid)
{
if(trim($gid) != "" && $gid != $user['usergroup'] && !isset($donegroup[$gid]))

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

			{

			{

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

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

Zeile 4963Zeile 5145
	global $db, $mybb, $cache;

$user = get_user($uid);

	global $db, $mybb, $cache;

$user = get_user($uid);

 

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


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


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

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

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

			}

			}

		}
}


		}
}


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

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

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

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

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

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

 * @return string The current URL being accessed

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

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

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

 
	global $mybb;


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

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

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

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

	}

	}

	else

	else

	{

	{

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

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

	}


	}


	if($quick)
{
return $location;

	if($quick)
{
return $location;

 
	}

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

	}

if($fields == true)

	}

if($fields == true)

	{
global $mybb;

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

	{








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


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

Zeile 5066Zeile 5254
	}
else
{

	}
else
{

 
		$parameters = array();


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

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

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

			$current_query_string = $_SERVER['QUERY_STRING'];

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

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

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














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

parse_str($current_query_string, $current_parameters);

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]))
{
$addloc[] = urlencode($var).'='.urlencode($_POST[$var]);
}
}

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

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













				{

				{

					$location .= "&amp;";

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

				}

				}

				$location .= implode("&amp;", $addloc);

 
			}

			}

 
		}

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

		}

return $location;

		}

return $location;

	}
}

	}
}


/**
* Build a theme selection menu


/**
* Build a theme selection menu

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

	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;

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

Zeile 5169Zeile 5364
					build_theme_select($name, $selected, $theme['tid'], $depthit, $usergroup_override, $footer, $count_override);
}
}

					build_theme_select($name, $selected, $theme['tid'], $depthit, $usergroup_override, $footer, $count_override);
}
}

		}

		}

	}

	}





	if($tid == 1 && ($num_themes > 1 || $count_override == true))
{
if($footer == true)

	if($tid == 1 && ($num_themes > 1 || $count_override == true))
{
if($footer == true)

		{

		{

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

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

		}


		}


		return $themeselect;
}
else

		return $themeselect;
}
else

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

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

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

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

		{

		{

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

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

Zeile 5230Zeile 5425

/**
* Custom function for htmlspecialchars which takes in to account unicode


/**
* Custom function for htmlspecialchars which takes in to account unicode

 *

 *

 * @param string $message The string to format
* @return string The string with htmlspecialchars applied
*/

 * @param string $message The string to format
* @return string The string with htmlspecialchars applied
*/

Zeile 5242Zeile 5437
	$message = str_replace("\"", "&quot;", $message);
return $message;
}

	$message = str_replace("\"", "&quot;", $message);
return $message;
}





/**
* Custom function for formatting numbers.
*

/**
* Custom function for formatting numbers.
*

Zeile 5254Zeile 5449
	global $mybb;

if($number == "-")

	global $mybb;

if($number == "-")

	{

	{

		return $number;
}


		return $number;
}


Zeile 5276Zeile 5471
		}

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

		}

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

	}
}

	}
}


/**
* Converts a string of text to or from UTF-8.


/**
* Converts a string of text to or from UTF-8.

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

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



 

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


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

Zeile 5733Zeile 5927
	}

return $string;

	}

return $string;

 
}

/**
* Finds a needle in a haystack and returns it position, mb strings accounted for, case insensitive
*
* @param string $haystack String to look in (haystack)
* @param string $needle What to look for (needle)
* @param int $offset (optional) How much to offset
* @return int|bool false on needle not found, integer position if found
*/
function my_stripos($haystack, $needle, $offset=0)
{
if($needle == '')
{
return false;
}

if(function_exists("mb_stripos"))
{
$position = mb_stripos($haystack, $needle, $offset);
}
else
{
$position = stripos($haystack, $needle, $offset);
}

return $position;

}

/**

}

/**

Zeile 5913Zeile 6134

/**
* Build the profile link.


/**
* Build the profile link.

 *

 *

 * @param string $username The Username of the profile.
* @param int $uid The user id of the profile.
* @param string $target The target frame

 * @param string $username The Username of the profile.
* @param int $uid The user id of the profile.
* @param string $target The target frame

Zeile 6091Zeile 6312
 * @param int $calendar The ID of the calendar
* @param int $week The week
* @return string The URL of the calendar

 * @param int $calendar The ID of the calendar
* @param int $week The week
* @return string The URL of the calendar

 */

 */

function get_calendar_week_link($calendar, $week)
{
if($week < 0)

function get_calendar_week_link($calendar, $week)
{
if($week < 0)

Zeile 6101Zeile 6322
	$link = str_replace("{week}", $week, CALENDAR_URL_WEEK);
$link = str_replace("{calendar}", $calendar, $link);
return htmlspecialchars_uni($link);

	$link = str_replace("{week}", $week, CALENDAR_URL_WEEK);
$link = str_replace("{calendar}", $calendar, $link);
return htmlspecialchars_uni($link);

}

/**

}

/**

 * Get the user data of an user id.
*
* @param int $uid The user id of the user.

 * Get the user data of an user id.
*
* @param int $uid The user id of the user.

Zeile 6114Zeile 6335
	global $mybb, $db;
static $user_cache;


	global $mybb, $db;
static $user_cache;


	$uid = (int)$uid;


	$uid = (int)$uid;


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

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

	{

	{

		return $mybb->user;

		return $mybb->user;

	}

	}

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

	elseif(isset($user_cache[$uid]))
{
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 6158Zeile 6379
		case 'mysqli':
$field = 'username';
$efield = 'email';

		case 'mysqli':
$field = 'username';
$efield = 'email';

			break;

			break;

		default:
$field = 'LOWER(username)';
$efield = 'LOWER(email)';

		default:
$field = 'LOWER(username)';
$efield = 'LOWER(email)';

Zeile 6169Zeile 6390
	{
case 1:
$sqlwhere = "{$efield}='{$username}'";

	{
case 1:
$sqlwhere = "{$efield}='{$username}'";

			break;

			break;

		case 2:
$sqlwhere = "{$field}='{$username}' OR {$efield}='{$username}'";

		case 2:
$sqlwhere = "{$field}='{$username}' OR {$efield}='{$username}'";

			break;

			break;

		default:
$sqlwhere = "{$field}='{$username}'";
break;

		default:
$sqlwhere = "{$field}='{$username}'";
break;

Zeile 6180Zeile 6401

$fields = array('uid');
if(isset($options['fields']))


$fields = array('uid');
if(isset($options['fields']))

	{

	{

		$fields = array_merge((array)$options['fields'], $fields);

		$fields = array_merge((array)$options['fields'], $fields);

	}

$query = $db->simple_select('users', implode(',', array_unique($fields)), $sqlwhere, array('limit' => 1));

	}

$query = $db->simple_select('users', implode(',', array_unique($fields)), $sqlwhere, array('limit' => 1));


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 6200Zeile 6421
 * @param int $fid The forum id of the forum.
* @param int $active_override (Optional) If set to 1, will override the active forum status
* @return array|bool The database row of a forum. False on failure

 * @param int $fid The forum id of the forum.
* @param int $active_override (Optional) If set to 1, will override the active forum status
* @return array|bool The database row of a forum. False on failure

 */

 */

function get_forum($fid, $active_override=0)
{
global $cache;
static $forum_cache;

function get_forum($fid, $active_override=0)
{
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");
}

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

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

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

	{

	{

		return false;
}


		return false;
}


Zeile 6232Zeile 6453
	}

return $forum_cache[$fid];

	}

return $forum_cache[$fid];

}


}


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

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

Zeile 6265Zeile 6486
		else
{
$thread_cache[$tid] = false;

		else
{
$thread_cache[$tid] = false;

			return false;
}
}
}

/**

			return false;
}
}
}

/**

 * Get the post of a post id.
*
* @param int $pid The post id of the post.
* @return array|bool The database row of the post. False on failure

 * Get the post of a post id.
*
* @param int $pid The post id of the post.
* @return array|bool The database row of the post. False on failure

 */

 */

function get_post($pid)
{
global $db;

function get_post($pid)
{
global $db;

Zeile 6301Zeile 6522
		{
$post_cache[$pid] = false;
return false;

		{
$post_cache[$pid] = false;
return false;

		}
}
}

/**

		}
}
}

/**

 * Get inactivate forums.
*
* @return string The comma separated values of the inactivate forum.

 * Get inactivate forums.
*
* @return string The comma separated values of the inactivate forum.

Zeile 6315Zeile 6536
	global $forum_cache, $cache;

if(!$forum_cache)

	global $forum_cache, $cache;

if(!$forum_cache)

	{

	{

		cache_forums();
}


		cache_forums();
}


Zeile 6334Zeile 6555
				}
}
}

				}
}
}

	}

$inactiveforums = implode(",", $inactive);

	}

$inactiveforums = implode(",", $inactive);


return $inactiveforums;
}


return $inactiveforums;
}





/**
* Checks to make sure a user has not tried to login more times than permitted
*
* @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.

/**
* Checks to make sure a user has not tried to login more times than permitted
*
* @param bool $fatal (Optional) Stop execution if it finds an error with the login. Default is True
* @return bool|int Number of logins when success, false if failed.

 */
function login_attempt_check($fatal = true)
{
global $mybb, $lang, $session, $db;

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

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

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

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

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

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




















 */
function login_attempt_check($uid = 0, $fatal = true)
{
global $mybb, $lang, $db;

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

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

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

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

return false;
}

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

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

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

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

		else
{

		else
{

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

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

		}


		}


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

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

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






		{

		{

			my_setcookie('failedlogin', $now);

 
			if($fatal)

			if($fatal)

			{






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


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

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

			}


			}


			return false;

			return false;

		}

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

		}
// Unlock if enough time has passed
else {

if($uid > 0)




			{

			{

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

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

			}

			}

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

return false;


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

return 0;







		}
}

// User can attempt another login

		}
}

// User can attempt another login

	return $loginattempts;
}

	return $attempts['loginattempts'];
}


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


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

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

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

}

}


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


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

Zeile 6489Zeile 6719
	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 7040Zeile 7272

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


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

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

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


if($matches)
{


if($matches)
{

Zeile 7101Zeile 7333
					'ssl' => array(
'verify_peer' => false,
'verify_peer_name' => false,

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

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

					),
));
}

					),
));
}





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

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

		}

		}

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

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

		}


		}


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

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

Zeile 7154Zeile 7387
		while(!feof($fp))
{
$data .= fgets($fp, 12800);

		while(!feof($fp))
{
$data .= fgets($fp, 12800);

		}

		}

		fclose($fp);

		fclose($fp);





		$data = explode("\r\n\r\n", $data, 2);

		$data = explode("\r\n\r\n", $data, 2);





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

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





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

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

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


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


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

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

Zeile 7187Zeile 7420

/**
* Resolves a hostname into a set of IP addresses.


/**
* Resolves a hostname into a set of IP addresses.

 *

 *

 * @param string $hostname The hostname to be resolved
* @return array|bool The resulting IP addresses. False on failure
*/

 * @param string $hostname The hostname to be resolved
* @return array|bool The resulting IP addresses. False on failure
*/

Zeile 7358Zeile 7591
			{
$split_strings = explode($delimeter, $string);
foreach($split_strings as $string)

			{
$split_strings = explode($delimeter, $string);
foreach($split_strings as $string)

				{

				{

					if($string == "") continue;
$strings[] = trim($string);
}

					if($string == "") continue;
$strings[] = trim($string);
}

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

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

function subforums_count($array)

function subforums_count($array=array())

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

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

Zeile 7786Zeile 8019
			{
// Invalid IP address
return false;

			{
// Invalid IP address
return false;

			}

			}

		}

/**

		}

/**

Zeile 7833Zeile 8066
			$chr = chr( bindec($chr) );
$ip_higher_pack .= $chr;
}

			$chr = chr( bindec($chr) );
$ip_higher_pack .= $chr;
}





		return array($ip_lower_pack, $ip_higher_pack);
}
// Just on IP address

		return array($ip_lower_pack, $ip_higher_pack);
}
// Just on IP address

Zeile 7853Zeile 8086
	static $time_start;

$time = microtime(true);

	static $time_start;

$time = microtime(true);



 

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


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

Zeile 7881Zeile 8113
function verify_files($path=MYBB_ROOT, $count=0)
{
global $mybb, $checksums, $bad_verify_files;

function verify_files($path=MYBB_ROOT, $count=0)
{
global $mybb, $checksums, $bad_verify_files;





	// We don't need to check these types of files
$ignore = array(".", "..", ".svn", "config.php", "settings.php", "Thumb.db", "config.default.php", "lock", "htaccess.txt", "htaccess-nginx.txt", "logo.gif", "logo.png");
$ignore_ext = array("attach");

	// We don't need to check these types of files
$ignore = array(".", "..", ".svn", "config.php", "settings.php", "Thumb.db", "config.default.php", "lock", "htaccess.txt", "htaccess-nginx.txt", "logo.gif", "logo.png");
$ignore_ext = array("attach");

Zeile 7913Zeile 8145
				if(is_dir($path."/".$file))
{
verify_files($path."/".$file, ($count+1));

				if(is_dir($path."/".$file))
{
verify_files($path."/".$file, ($count+1));

					continue;

					continue;

				}

// We only need the last part of the path (from the MyBB directory to the file. i.e. inc/functions.php)

				}

// We only need the last part of the path (from the MyBB directory to the file. i.e. inc/functions.php)

Zeile 8166Zeile 8398

$distance = $max - $min;
return $min + floor($distance * ($seed / PHP_INT_MAX) );


$distance = $max - $min;
return $min + floor($distance * ($seed / PHP_INT_MAX) );

}

}


/**
* More robust version of PHP's trim() function. It includes a list of UTF-8 blank characters


/**
* More robust version of PHP's trim() function. It includes a list of UTF-8 blank characters

Zeile 8179Zeile 8411
function trim_blank_chrs($string, $charlist="")
{
$hex_chrs = array(

function trim_blank_chrs($string, $charlist="")
{
$hex_chrs = array(

		0x09 => 1, // \x{0009}
0x0A => 1, // \x{000A}
0x0B => 1, // \x{000B}
0x0D => 1, // \x{000D}

		0x09 => 1, // \x{0009}
0x0A => 1, // \x{000A}
0x0B => 1, // \x{000B}
0x0D => 1, // \x{000D}

		0x20 => 1, // \x{0020}
0xC2 => array(0x81 => 1, 0x8D => 1, 0x90 => 1, 0x9D => 1, 0xA0 => 1, 0xAD => 1), // \x{0081}, \x{008D}, \x{0090}, \x{009D}, \x{00A0}, \x{00AD}
0xCC => array(0xB7 => 1, 0xB8 => 1), // \x{0337}, \x{0338}

		0x20 => 1, // \x{0020}
0xC2 => array(0x81 => 1, 0x8D => 1, 0x90 => 1, 0x9D => 1, 0xA0 => 1, 0xAD => 1), // \x{0081}, \x{008D}, \x{0090}, \x{009D}, \x{00A0}, \x{00AD}
0xCC => array(0xB7 => 1, 0xB8 => 1), // \x{0337}, \x{0338}

Zeile 8245Zeile 8477
	{
// Check to see if we have matched a first character in our utf-8 array
$offset = match_sequence($string, $hex_chrs);

	{
// Check to see if we have matched a first character in our utf-8 array
$offset = match_sequence($string, $hex_chrs);

		if(!$offset)

		if(!$offset)

		{
// If not, then we must have a "good" character and we don't need to do anymore processing
break;

		{
// If not, then we must have a "good" character and we don't need to do anymore processing
break;

Zeile 8292Zeile 8524
 * @return int The number matched
*/
function match_sequence($string, $array, $i=0, $n=0)

 * @return int The number matched
*/
function match_sequence($string, $array, $i=0, $n=0)

{

{

	if($string === "")
{
return 0;

	if($string === "")
{
return 0;

Zeile 8545Zeile 8777

// Our recipients
if(is_array($toid))


// Our recipients
if(is_array($toid))

	{

	{

		$recipients_to = $toid;

		$recipients_to = $toid;

	}

	}

	else

	else

	{

	{

		$recipients_to = array($toid);

		$recipients_to = array($toid);

	}

	}


$recipients_bcc = array();



$recipients_bcc = array();


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

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

	{

	{

		$fromid = 0;
}

		$fromid = 0;
}





	// Build our final PM array
$pm = array(
"subject" => $subject,

	// Build our final PM array
$pm = array(
"subject" => $subject,

Zeile 8575Zeile 8807
		"bccid" => $recipients_bcc,
"do" => '',
"pmid" => ''

		"bccid" => $recipients_bcc,
"do" => '',
"pmid" => ''

	);


	);


	if(isset($session))
{
$pm['ipaddress'] = $session->packedip;
}

$pm['options'] = array(

	if(isset($session))
{
$pm['ipaddress'] = $session->packedip;
}

$pm['options'] = array(

		"signature" => 0,

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

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

Zeile 8607Zeile 8838

/**
* Log a user spam block from StopForumSpam (or other spam service providers...)


/**
* Log a user spam block from StopForumSpam (or other spam service providers...)

 *

 *

 * @param string $username The username that the user was using.
* @param string $email The email address the user was using.
* @param string $ip_address The IP addres of the user.

 * @param string $username The username that the user was using.
* @param string $email The email address the user was using.
* @param string $ip_address The IP addres of the user.

Zeile 8617Zeile 8848
function log_spam_block($username = '', $email = '', $ip_address = '', $data = array())
{
global $db, $session;

function log_spam_block($username = '', $email = '', $ip_address = '', $data = array())
{
global $db, $session;





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

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

	}


	}


	if(!$ip_address)
{
$ip_address = get_ip();

	if(!$ip_address)
{
$ip_address = get_ip();

Zeile 8637Zeile 8868
		'dateline'  => (int)TIME_NOW,
'data' => $db->escape_string(@my_serialize($data)),
);

		'dateline'  => (int)TIME_NOW,
'data' => $db->escape_string(@my_serialize($data)),
);





	return (bool)$db->insert_query('spamlog', $insert_array);
}


	return (bool)$db->insert_query('spamlog', $insert_array);
}


Zeile 8668Zeile 8899

if(file_exists($file_path))
{


if(file_exists($file_path))
{

 

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


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

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

Zeile 8745Zeile 8988
/**
* 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 8765Zeile 9009
/**
* 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;

}

}