Vergleich inc/functions.php - 1.8.16 - 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

 *
* @param int $fid The forum ID

 * @return Array of descendants
*/
function get_child_list($fid)

 * @return Array of descendants
*/
function get_child_list($fid)

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 813Zeile 830
	if(!$title)
{
$title = $mybb->settings['bbname'];

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

	}


	}


	$timenow = my_date('relative', TIME_NOW);
reset_breadcrumb();
add_breadcrumb($lang->error);

	$timenow = my_date('relative', TIME_NOW);
reset_breadcrumb();
add_breadcrumb($lang->error);

Zeile 845Zeile 862
	if(!is_array($errors))
{
$errors = array($errors);

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

	}


	}


	// AJAX error message?
if($mybb->get_input('ajax', MyBB::INPUT_INT))
{

	// AJAX error message?
if($mybb->get_input('ajax', MyBB::INPUT_INT))
{

Zeile 854Zeile 871
		@header("Content-type: application/json; charset={$lang->settings['charset']}");

if(empty($json_data))

		@header("Content-type: application/json; charset={$lang->settings['charset']}");

if(empty($json_data))

		{

		{

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

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

		}

		}

		else
{
echo json_encode(array_merge(array("errors" => $errors), $json_data));
}
exit;

		else
{
echo json_encode(array_merge(array("errors" => $errors), $json_data));
}
exit;

	}

	}


$errorlist = '';

foreach($errors as $error)
{


$errorlist = '';

foreach($errors as $error)
{

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

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

	}

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

	}

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

Zeile 878Zeile 895

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


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

 */

 */

function error_no_permission()
{
global $mybb, $theme, $templates, $db, $lang, $plugins, $session;

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

function error_no_permission()
{
global $mybb, $theme, $templates, $db, $lang, $plugins, $session;

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





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

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





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

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


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


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

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

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

Zeile 974Zeile 991
		@header("Content-type: application/json; charset={$lang->settings['charset']}");
echo json_encode(array("data" => $data));
exit;

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

	}

	}


if(!$message)
{


if(!$message)
{

Zeile 1006Zeile 1023
		run_shutdown();

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

		run_shutdown();

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

		{

		{

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

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

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;



$page = (int)$page;


Zeile 1103Zeile 1129
			if($breadcrumb == true)
{
eval("\$mppage .= \"".$templates->get("multipage_page_link_current")."\";");

			if($breadcrumb == true)
{
eval("\$mppage .= \"".$templates->get("multipage_page_link_current")."\";");

			}

			}

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

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

Zeile 1133Zeile 1159
		$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)
{
// When the second parameter is set to 1, fetch_page_url thinks it's the first page and removes it from the URL as it's unnecessary
$jump_url = fetch_page_url($url, 1);
eval("\$jumptopage = \"".$templates->get("multipage_jump_page")."\";");

	$jumptopage = '';
if($pages > ($mybb->settings['maxmultipagelinks']+1) && $mybb->settings['jumptopagemultipage'] == 1)
{
// When the second parameter is set to 1, fetch_page_url thinks it's the first page and removes it from the URL as it's unnecessary
$jump_url = fetch_page_url($url, 1);
eval("\$jumptopage = \"".$templates->get("multipage_jump_page")."\";");

	}

	}


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

if($breadcrumb == true)
{
eval("\$multipage = \"".$templates->get("multipage_breadcrumb")."\";");


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

if($breadcrumb == true)
{
eval("\$multipage = \"".$templates->get("multipage_breadcrumb")."\";");

	}

	}

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

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





	return $multipage;
}


	return $multipage;
}


Zeile 1163Zeile 1189
 * @param string $url The URL being passed
* @param int $page The page number
* @return string

 * @param string $url The URL being passed
* @param int $page The page number
* @return string

 */

 */

function fetch_page_url($url, $page)
{
if($page <= 1)

function fetch_page_url($url, $page)
{
if($page <= 1)

Zeile 1179Zeile 1205
		return $url;
}
else if(strpos($url, "{page}") === false)

		return $url;
}
else if(strpos($url, "{page}") === false)

	{

	{

		// If no page identifier is specified we tack it on to the end of the URL
if(strpos($url, "?") === false)
{

		// If no page identifier is specified we tack it on to the end of the URL
if(strpos($url, "?") === false)
{

Zeile 1203Zeile 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 == 0)
{

	if($uid === null)
{

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

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

 
	}

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

	}

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

	}

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

Zeile 1223Zeile 1255
		if(!empty($user_cache[$uid]['permissions']))
{
return $user_cache[$uid]['permissions'];

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

		}


		}


		// This user was not already cached, fetch their user information.
if(empty($user_cache[$uid]))
{

		// This user was not already cached, fetch their user information.
if(empty($user_cache[$uid]))
{

Zeile 1255Zeile 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))
{
$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 1277Zeile 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 1294Zeile 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 1306Zeile 1338
			}
}
}

			}
}
}





	return $usergroup;

	return $usergroup;

}

/**

}

/**

 * Fetch the display group properties for a specific display group
*
* @param int $gid The group ID to fetch the display properties for

 * Fetch the display group properties for a specific display group
*
* @param int $gid The group ID to fetch the display properties for

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

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





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

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

		}

		}

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

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

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

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





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


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


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

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

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

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

	{
if(empty($cached_forum_permissions_permissions[$gid][$fid]))
{

	{
if(empty($cached_forum_permissions_permissions[$gid][$fid]))
{

Zeile 1423Zeile 1455
function fetch_forum_permissions($fid, $gid, $groupperms)
{
global $groupscache, $forum_cache, $fpermcache, $mybb, $fpermfields;

function fetch_forum_permissions($fid, $gid, $groupperms)
{
global $groupscache, $forum_cache, $fpermcache, $mybb, $fpermfields;





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

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

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

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

Zeile 1502Zeile 1534
		$current_permissions = $groupperms;
}
return $current_permissions;

		$current_permissions = $groupperms;
}
return $current_permissions;

 
}

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

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

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

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

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

}

/**

}

/**

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

$showform = true;

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

$showform = true;





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

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

Zeile 1542Zeile 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 1563Zeile 1638
			{
eval("\$pwnote = \"".$templates->get("forumdisplay_password_wrongpass")."\";");
$showform = true;

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

			}
}
else
{
if(!$mybb->cookies['forumpass'][$fid] || ($mybb->cookies['forumpass'][$fid] && md5($mybb->user['uid'].$password) !== $mybb->cookies['forumpass'][$fid]))
{
$showform = true;
}

			}
}
else
{
if(!forum_password_validated($forum_cache[$fid]))
{
$showform = true;
}

			else
{
$showform = false;
}
}

			else
{
$showform = false;
}
}

	}

	}

	else

	else

	{

	{

		$showform = false;
}

if($return)
{
return $showform;

		$showform = false;
}

if($return)
{
return $showform;

	}


	}


	if($showform)
{
if($pid)

	if($showform)
{
if($pid)

		{

		{

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

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

		}

		}

		else
{
$_SERVER['REQUEST_URI'] = htmlspecialchars_uni($_SERVER['REQUEST_URI']);

		else
{
$_SERVER['REQUEST_URI'] = htmlspecialchars_uni($_SERVER['REQUEST_URI']);

Zeile 1602Zeile 1677
		exit;
}
}

		exit;
}
}





/**
* Return the permissions for a moderator in a specific forum
*

/**
* Return the permissions for a moderator in a specific forum
*

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

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

		}

		}

	}

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

	}

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

Zeile 1796Zeile 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 2031Zeile 2162
	}

if(empty($str) || !is_string($str))

	}

if(empty($str) || !is_string($str))

	{
return false;

	{
return false;

	}


	}


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

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



/*
* states:


/*
* states:

Zeile 2098Zeile 2228
					if(count($stack) >= MAX_SERIALIZED_ARRAY_DEPTH)
{
// array nesting exceeds MAX_SERIALIZED_ARRAY_DEPTH

					if(count($stack) >= MAX_SERIALIZED_ARRAY_DEPTH)
{
// array nesting exceeds MAX_SERIALIZED_ARRAY_DEPTH

						return false;

						return false;

					}

$stack[] = &$list;
$list[$key] = array();
$list = &$list[$key];
$expected[] = $expectedLength;

					}

$stack[] = &$list;
$list[$key] = array();
$list = &$list[$key];
$expected[] = $expectedLength;

					$state = 2;
break;

					$state = 2;
break;

				}
if($type != '}')
{
$list[$key] = $value;
$state = 2;

				}
if($type != '}')
{
$list[$key] = $value;
$state = 2;

					break;
}


					break;
}


				// missing array value
return false;


				// missing array value
return false;


Zeile 2130Zeile 2260
					unset($list);
$list = &$stack[count($stack)-1];
array_pop($stack);

					unset($list);
$list = &$stack[count($stack)-1];
array_pop($stack);





					// go to terminal state if we're at the end of the root array
array_pop($expected);
if(count($expected) == 0) {

					// go to terminal state if we're at the end of the root array
array_pop($expected);
if(count($expected) == 0) {

Zeile 2161Zeile 2291

case 0: // expecting array or value
if($type == 'a')


case 0: // expecting array or value
if($type == 'a')

				{

				{

					if(count($stack) >= MAX_SERIALIZED_ARRAY_DEPTH)
{
// array nesting exceeds MAX_SERIALIZED_ARRAY_DEPTH

					if(count($stack) >= MAX_SERIALIZED_ARRAY_DEPTH)
{
// array nesting exceeds MAX_SERIALIZED_ARRAY_DEPTH

Zeile 2416Zeile 2546
	}

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

	}

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

	{

	{

		if(!empty($changes))
{
// Calculate before writing to cache

		if(!empty($changes))
{
// Calculate before writing to cache

Zeile 2668Zeile 2798
		WHERE fid='{$fid}' AND visible='1' AND closed NOT LIKE 'moved|%'
ORDER BY lastpost DESC
LIMIT 0, 1

		WHERE fid='{$fid}' AND visible='1' AND closed NOT LIKE 'moved|%'
ORDER BY lastpost DESC
LIMIT 0, 1

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


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


	$updated_forum = array(
"lastpost" => (int)$lastpost['lastpost'],
"lastposter" => $db->escape_string($lastpost['lastposter']),

	$updated_forum = array(
"lastpost" => (int)$lastpost['lastpost'],
"lastposter" => $db->escape_string($lastpost['lastposter']),

Zeile 2689Zeile 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;


{
global $db;


	$update_query = array();
$tid = (int)$tid;


	$update_query = array();
$tid = (int)$tid;


Zeile 2763Zeile 2893
		WHERE p.tid='$tid' AND p.visible='1'
ORDER BY p.dateline DESC
LIMIT 1"

		WHERE p.tid='$tid' AND p.visible='1'
ORDER BY p.dateline DESC
LIMIT 1"

	);
$lastpost = $db->fetch_array($query);

$db->free_result($query);

	);
$lastpost = $db->fetch_array($query);

$db->free_result($query);


$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

Zeile 2786Zeile 2916
	}

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

	}

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

	{

	{

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


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


Zeile 2821Zeile 2951
function update_user_counters($uid, $changes=array())
{
global $db;

function update_user_counters($uid, $changes=array())
{
global $db;





	$update_query = array();

$counters = array('postnum', 'threadnum');

	$update_query = array();

$counters = array('postnum', 'threadnum');

Zeile 2856Zeile 2986
			if(isset($update_query[$counter]) && $update_query[$counter] < 0)
{
$update_query[$counter] = 0;

			if(isset($update_query[$counter]) && $update_query[$counter] < 0)
{
$update_query[$counter] = 0;

			}
}
}

$db->free_result($query);


			}
}
}

$db->free_result($query);


	// Only update if we're actually doing something
if(count($update_query) > 0)
{

	// Only update if we're actually doing something
if(count($update_query) > 0)
{

Zeile 3051Zeile 3181
	shuffle($str);

return implode($str);

	shuffle($str);

return implode($str);

}


}


/**
* Formats a username based on their display group
*

/**
* Formats a username based on their display group
*

Zeile 3167Zeile 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 3268Zeile 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 3438Zeile 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 4212Zeile 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 4226Zeile 4403

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

		}
else
{

Zeile 4241Zeile 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 4331Zeile 4505
				eval("\$nav .= \"".$templates->get("nav_bit")."\";");
}
}

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

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

	}

	}


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

 

if($nav)
{


if($nav)
{

Zeile 4645Zeile 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 4976Zeile 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 5015Zeile 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 5048Zeile 5224
	}

if($quick)

	}

if($quick)

	{

	{

		return $location;

		return $location;

 
	}

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

	}

if($fields == true)
{

	}

if($fields == true)
{

		global $mybb;

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

 

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


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

Zeile 5079Zeile 5254
	}
else
{

	}
else
{

 
		$parameters = array();


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

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

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

			$current_query_string = $_SERVER['QUERY_STRING'];





		}

		}


if((isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] == "POST") || (isset($_ENV['REQUEST_METHOD']) && $_ENV['REQUEST_METHOD'] == "POST"))
{
$post_array = array('action', 'fid', 'pid', 'tid', 'uid', 'eid');


















		else if(isset($_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($mybb->request_method === 'post')
{
$post_array = array('action', 'fid', 'pid', 'tid', 'uid', 'eid');


foreach($post_array as $var)
{


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 5366Zeile 5548

/**
* DEPRECATED! Please use other alternatives.


/**
* DEPRECATED! Please use other alternatives.

 *
* @deprecated

 *
* @deprecated

 * @param string $message
*
* @return string

 * @param string $message
*
* @return string

Zeile 5556Zeile 5738
	$age = $year-$bday[2];

if(($month == $bday[1] && $day < $bday[0]) || $month < $bday[1])

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

if(($month == $bday[1] && $day < $bday[0]) || $month < $bday[1])

	{

	{

		--$age;
}
return $age;

		--$age;
}
return $age;

Zeile 5745Zeile 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 6218Zeile 6427
	global $cache;
static $forum_cache;


	global $cache;
static $forum_cache;


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

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

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

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

Zeile 6380Zeile 6589
	}
// This user has a cookie lockout, show waiting time
elseif($mybb->cookies['lockoutexpiry'] && $mybb->cookies['lockoutexpiry'] > $now)

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

		if($fatal)
{
$secsleft = (int)($mybb->cookies['lockoutexpiry'] - $now);

Zeile 6421Zeile 6630

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


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

		{	

		{

			if($fatal)
{
$secsleft = (int)($attempts['loginlockoutexpiry'] - $now);

			if($fatal)
{
$secsleft = (int)($attempts['loginlockoutexpiry'] - $now);

Zeile 6461Zeile 6670
 *
* @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)

{

{

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


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


Zeile 6477Zeile 6686
function email_already_in_use($email, $uid=0)
{
global $db;

function email_already_in_use($email, $uid=0)
{
global $db;





	$uid_string = "";
if($uid)
{

	$uid_string = "";
if($uid)
{

Zeile 6510Zeile 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 7061Zeile 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 7122Zeile 7333
					'ssl' => array(
'verify_peer' => false,
'verify_peer_name' => false,

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

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

					),
));
}

					),
));
}

Zeile 7131Zeile 7343
		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)

		{

		{

			return false;
}
$headers = array();

			return false;
}
$headers = array();

		if(!empty($post_body))
{

		if(!empty($post_body))
{

			$headers[] = "POST {$url_components['path']} HTTP/1.0";
$headers[] = "Content-Length: ".strlen($post_body);
$headers[] = "Content-Type: application/x-www-form-urlencoded";

			$headers[] = "POST {$url_components['path']} HTTP/1.0";
$headers[] = "Content-Length: ".strlen($post_body);
$headers[] = "Content-Type: application/x-www-form-urlencoded";

Zeile 7157Zeile 7369
		if(!empty($post_body))
{
$headers[] = $post_body;

		if(!empty($post_body))
{
$headers[] = $post_body;

		}
else
{

		}
else
{

			// If we have no post body, we need to add an empty element to make sure we've got \r\n\r\n before the (non-existent) body starts
$headers[] = '';
}

			// If we have no post body, we need to add an empty element to make sure we've got \r\n\r\n before the (non-existent) body starts
$headers[] = '';
}

Zeile 7168Zeile 7380
		if(!@fwrite($fp, $headers))
{
return false;

		if(!@fwrite($fp, $headers))
{
return false;

		}


		}


		$data = null;

while(!feof($fp))

		$data = null;

while(!feof($fp))

Zeile 7186Zeile 7398

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

return $data;

		}

return $data;

	}
else
{
return false;
}
}

/**

	}
else
{
return false;
}
}

/**

 * Resolves a hostname into a set of IP addresses.
*
* @param string $hostname The hostname to be resolved

 * Resolves a hostname into a set of IP addresses.
*
* @param string $hostname The hostname to be resolved

Zeile 7217Zeile 7429
	$addresses = @gethostbynamel($hostname);

if(!$addresses)

	$addresses = @gethostbynamel($hostname);

if(!$addresses)

	{

	{

		$result_set = @dns_get_record($hostname, DNS_A | DNS_AAAA);

if($result_set)

		$result_set = @dns_get_record($hostname, DNS_A | DNS_AAAA);

if($result_set)

Zeile 7247Zeile 7459
	if($path = ini_get('curl.cainfo'))
{
return $path;

	if($path = ini_get('curl.cainfo'))
{
return $path;

	}


	}


	return false;
}


	return false;
}


Zeile 7259Zeile 7471
 * @return boolean True if a super admin, false if not
*/
function is_super_admin($uid)

 * @return boolean True if a super admin, false if not
*/
function is_super_admin($uid)

{

{

	static $super_admins;

	static $super_admins;





	if(!isset($super_admins))

	if(!isset($super_admins))

	{

	{

		global $mybb;
$super_admins = str_replace(" ", "", $mybb->config['super_admins']);
}

if(my_strpos(",{$super_admins},", ",{$uid},") === false)

		global $mybb;
$super_admins = str_replace(" ", "", $mybb->config['super_admins']);
}

if(my_strpos(",{$super_admins},", ",{$uid},") === false)

	{

	{

		return false;
}
else

		return false;
}
else

Zeile 7290Zeile 7502
function is_member($groups, $user = false)
{
global $mybb;

function is_member($groups, $user = false)
{
global $mybb;





	if(empty($groups))
{
return array();

	if(empty($groups))
{
return array();

Zeile 7310Zeile 7522
	$memberships[] = $user['usergroup'];

if(!is_array($groups))

	$memberships[] = $user['usergroup'];

if(!is_array($groups))

	{

	{

		if((int)$groups == -1)
{
return $memberships;

		if((int)$groups == -1)
{
return $memberships;

Zeile 7352Zeile 7564
		if(is_array($escape))
{
function escaped_explode_escape($string)

		if(is_array($escape))
{
function escaped_explode_escape($string)

			{

			{

				return preg_quote($string, "#");
}
$escape_preg = "(".implode("|", array_map("escaped_explode_escape", $escape)).")";

				return preg_quote($string, "#");
}
$escape_preg = "(".implode("|", array_map("escaped_explode_escape", $escape)).")";

Zeile 7374Zeile 7586
			if($in_escape)
{
$strings[] = trim($string);

			if($in_escape)
{
$strings[] = trim($string);

			}

			}

			else
{
$split_strings = explode($delimeter, $string);

			else
{
$split_strings = explode($delimeter, $string);

Zeile 7543Zeile 7755
	$result = chmod($file, octdec($mode));
umask($old_umask);
return $result;

	$result = chmod($file, octdec($mode));
umask($old_umask);
return $result;

}

}


/**
* Custom rmdir function to loop through an entire directory and delete all files/folders within


/**
* Custom rmdir function to loop through an entire directory and delete all files/folders within

Zeile 7553Zeile 7765
 * @return bool
*/
function my_rmdir_recursive($path, $ignore=array())

 * @return bool
*/
function my_rmdir_recursive($path, $ignore=array())

{

{

	global $orig_dir;

if(!isset($orig_dir))

	global $orig_dir;

if(!isset($orig_dir))

Zeile 7573Zeile 7785
				}
}
@closedir($dh);

				}
}
@closedir($dh);

		}


		}


		// Are we done? Don't delete the main folder too and return true
if($path == $orig_dir)
{

		// Are we done? Don't delete the main folder too and return true
if($path == $orig_dir)
{

Zeile 7593Zeile 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 7628Zeile 7840
	}

if($ip_long >= 2147483648) // Won't occur on 32-bit PHP

	}

if($ip_long >= 2147483648) // Won't occur on 32-bit PHP

	{

	{

		$ip_long -= 4294967296;
}

		$ip_long -= 4294967296;
}





	return $ip_long;
}

/**
* DEPRECATED! Please use IPv6 compatible my_inet_ntop!
* As above, fix for PHP's long2ip on 64-bit versions

	return $ip_long;
}

/**
* DEPRECATED! Please use IPv6 compatible my_inet_ntop!
* As above, fix for PHP's long2ip on 64-bit versions

 *

 *

 * @deprecated
* @param integer $long The IP to convert (will accept 64-bit IPs as well)
* @return string IP in IPv4 format

 * @deprecated
* @param integer $long The IP to convert (will accept 64-bit IPs as well)
* @return string IP in IPv4 format

Zeile 7659Zeile 7871
 *
* @param string $ip The IP to convert
* @return string IP in 32bit or 128bit binary format

 *
* @param string $ip The IP to convert
* @return string IP in 32bit or 128bit binary format

 */

 */

function my_inet_pton($ip)
{
if(function_exists('inet_pton'))

function my_inet_pton($ip)
{
if(function_exists('inet_pton'))

Zeile 7689Zeile 7901
		if($delim_count < 1 || $delim_count > 7)
{
return false;

		if($delim_count < 1 || $delim_count > 7)
{
return false;

		}


		}


		$r = explode(':', $ip);
$rcount = count($r);
if(($doub = array_search('', $r, 1)) !== false)

		$r = explode(':', $ip);
$rcount = count($r);
if(($doub = array_search('', $r, 1)) !== false)

Zeile 7712Zeile 7924
 *
* @param string $ip IP in 32bit or 128bit binary format
* @return string IP in human readable format

 *
* @param string $ip IP in 32bit or 128bit binary format
* @return string IP in human readable format

 */

 */

function my_inet_ntop($ip)
{
if(function_exists('inet_ntop'))

function my_inet_ntop($ip)
{
if(function_exists('inet_ntop'))

Zeile 7733Zeile 7945
		 * @version     $Revision: 269597 $
*/
switch(strlen($ip))

		 * @version     $Revision: 269597 $
*/
switch(strlen($ip))

		{

		{

			case 4:
list(,$r) = unpack('N', $ip);
return long2ip($r);

			case 4:
list(,$r) = unpack('N', $ip);
return long2ip($r);

Zeile 7744Zeile 7956
					array('::', '(int)"$1"?"$1":"0$1"'),
$r);
return $r;

					array('::', '(int)"$1"?"$1":"0$1"'),
$r);
return $r;

		}

		}

		return false;
}
}

		return false;
}
}

Zeile 7764Zeile 7976
		{
// IPv6
$upper = str_replace('*', 'ffff', $ipaddress);

		{
// IPv6
$upper = str_replace('*', 'ffff', $ipaddress);

			$lower = str_replace('*', '0', $ipaddress);
}

			$lower = str_replace('*', '0', $ipaddress);
}

		else
{
// IPv4

		else
{
// IPv4

Zeile 7797Zeile 8009
		if(empty($ip_address) || empty($ip_range))
{
// Invalid input

		if(empty($ip_address) || empty($ip_range))
{
// Invalid input

			return false;
}
else

			return false;
}
else

		{
$ip_address = my_inet_pton($ip_address);


		{
$ip_address = my_inet_pton($ip_address);


Zeile 7815Zeile 8027
		 * Author: NewEraCracker
* License: Public Domain
*/

		 * Author: NewEraCracker
* License: Public Domain
*/





		// Pack IP, Set some vars
$ip_pack = $ip_address;
$ip_pack_size = strlen($ip_pack);

		// Pack IP, Set some vars
$ip_pack = $ip_address;
$ip_pack_size = strlen($ip_pack);

Zeile 7861Zeile 8073
	else
{
return my_inet_pton($ipaddress);

	else
{
return my_inet_pton($ipaddress);

	}
}


	}
}


/**
* Time how long it takes for a particular piece of code to run. Place calls above & below the block of code.
*

/**
* Time how long it takes for a particular piece of code to run. Place calls above & below the block of code.
*

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

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

				{
continue;
}

				{
continue;
}


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


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

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

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

	}
}

/**

	}
}

/**

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

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

Zeile 8050Zeile 8262
			}

$output = @mcrypt_create_iv($bytes, $source);

			}

$output = @mcrypt_create_iv($bytes, $source);

		}
}
else
{
return $output;

		}
}
else
{
return $output;

	}

if(strlen($output) < $bytes)

	}

if(strlen($output) < $bytes)

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

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

				}
}
}

				}
}
}

	}
else
{

	}
else
{

Zeile 8102Zeile 8314
		// Close to what PHP basically uses internally to seed, but not quite.
$unique_state = microtime().@getmypid();


		// Close to what PHP basically uses internally to seed, but not quite.
$unique_state = microtime().@getmypid();


		$rounds = ceil($bytes / 16);


		$rounds = ceil($bytes / 16);


		for($i = 0; $i < $rounds; $i++)
{
$unique_state = md5(microtime().$unique_state);

		for($i = 0; $i < $rounds; $i++)
{
$unique_state = md5(microtime().$unique_state);

Zeile 8132Zeile 8344
	$bytes = PHP_INT_SIZE;

do

	$bytes = PHP_INT_SIZE;

do

	{

$output = secure_binary_seed_rng($bytes);

	{

$output = secure_binary_seed_rng($bytes);


// convert binary data to a decimal number
if ($bytes == 4)


// convert binary data to a decimal number
if ($bytes == 4)

Zeile 8179Zeile 8391
		if(isset($result))
{
return $result;

		if(isset($result))
{
return $result;

		}
}

$seed = secure_seed_rng();

		}
}

$seed = secure_seed_rng();


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


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

Zeile 8687Zeile 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 8819Zeile 9043
	$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;

}

}