Vergleich inc/functions.php - 1.8.17 - 1.8.23

  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)

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

if($breadcrumb == true)

	{

	{

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

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

	}
else
{

	}
else
{

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


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


Zeile 1182Zeile 1208
	{
// 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)

		{

		{

			$url .= "?";

			$url .= "?";

		}

		}

		else
{
$url .= "&amp;";

		else
{
$url .= "&amp;";

Zeile 1198Zeile 1224
	}

return $url;

	}

return $url;

}

}


/**
* Fetch the permissions for a specific user


/**
* Fetch the permissions for a specific user

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

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

	}


	}


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

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





	// User id does not match current user, fetch permissions
if($uid != $mybb->user['uid'])
{

	// User id does not match current user, fetch permissions
if($uid != $mybb->user['uid'])
{

Zeile 1229Zeile 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 1261Zeile 1287
function usergroup_permissions($gid=0)
{
global $cache, $groupscache, $grouppermignore, $groupzerogreater;

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


if(!is_array($groupscache))


if(!is_array($groupscache))

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

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

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

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

				{

				{

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

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

				{

				{

					$permbit = "";

					$permbit = "";

				}

				}


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


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

				}


				}


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

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

Zeile 1378Zeile 1404
			}

$groupperms = $mybb->usergroup;

			}

$groupperms = $mybb->usergroup;

		}
}

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

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

		}
}

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

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


if(!is_array($fpermcache))
{


if(!is_array($fpermcache))
{

Zeile 1405Zeile 1431
		return $cached_forum_permissions_permissions[$gid][$fid];
}
else

		return $cached_forum_permissions_permissions[$gid][$fid];
}
else

	{

	{

		if(empty($cached_forum_permissions[$gid]))
{
foreach($forum_cache as $forum)

		if(empty($cached_forum_permissions[$gid]))
{
foreach($forum_cache as $forum)

Zeile 1420Zeile 1446
/**
* Fetches the permissions for a specific forum/group applying the inheritance scheme.
* Called by forum_permissions()

/**
* Fetches the permissions for a specific forum/group applying the inheritance scheme.
* Called by forum_permissions()

 *
* @param int $fid The forum ID

 *
* @param int $fid The forum ID

 * @param string $gid A comma separated list of usergroups
* @param array $groupperms Group permissions
* @return array Permissions for this forum

 * @param string $gid A comma separated list of usergroups
* @param array $groupperms Group permissions
* @return array Permissions for this forum

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

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

				{

				{

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

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

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

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

			}

			}


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


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

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

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

			}

			}


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


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

Zeile 1485Zeile 1511
			}

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

			}

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

			{

			{

				$only_reply_own_threads = 0;
}
}

				$only_reply_own_threads = 0;
}
}

	}

	}


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


Zeile 1501Zeile 1527
	if($only_reply_own_threads == 0)
{
$current_permissions["canonlyreplyownthreads"] = 0;

	if($only_reply_own_threads == 0)
{
$current_permissions["canonlyreplyownthreads"] = 0;

	}

	}


if(count($current_permissions) == 0)
{
$current_permissions = $groupperms;
}
return $current_permissions;


if(count($current_permissions) == 0)
{
$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 1587
 * @param int $pid The Parent ID
* @param bool $return
* @return bool

 * @param int $pid The Parent ID
* @param bool $return
* @return bool

 */

 */

function check_forum_password($fid, $pid=0, $return=false)
{
global $mybb, $header, $footer, $headerinclude, $theme, $templates, $lang, $forum_cache;

function check_forum_password($fid, $pid=0, $return=false)
{
global $mybb, $header, $footer, $headerinclude, $theme, $templates, $lang, $forum_cache;

Zeile 1548Zeile 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 1568Zeile 1637
			else
{
eval("\$pwnote = \"".$templates->get("forumdisplay_password_wrongpass")."\";");

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

				$showform = true;
}

				$showform = true;
}

		}
else
{

		}
else
{

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

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

				$showform = true;

				$showform = true;

			}

			}

			else
{
$showform = false;

			else
{
$showform = false;

Zeile 1586Zeile 1655
	else
{
$showform = false;

	else
{
$showform = false;

	}

	}


if($return)
{


if($return)
{

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

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

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

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

	{

	{

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

foreach($extra_groups as $extra_group)

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

foreach($extra_groups as $extra_group)

Zeile 1706Zeile 1775
				if(strpos($action, "can") === false)
{
continue;

				if(strpos($action, "can") === false)
{
continue;

				}

				}


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


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

Zeile 1714Zeile 1783
	}

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

	}

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





	return $perms;
}


	return $perms;
}


Zeile 1725Zeile 1794
 * @param string $action The action tyring to be performed. (blank assumes any action at all)
* @param int $uid The user ID (0 assumes current user)
* @return bool Returns true if the user has permission, false if they do not

 * @param string $action The action tyring to be performed. (blank assumes any action at all)
* @param int $uid The user ID (0 assumes current user)
* @return bool Returns true if the user has permission, false if they do not

 */

 */

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

	}

	}


if($uid == 0)
{


if($uid == 0)
{

Zeile 1744Zeile 1813
	if($user_perms['issupermod'] == 1)
{
if($fid)

	if($user_perms['issupermod'] == 1)
{
if($fid)

		{

		{

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

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

Zeile 1782Zeile 1851
			return false;
}
else

			return false;
}
else

		{

		{

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

if(!$action && $modperms)

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

if(!$action && $modperms)

Zeile 1790Zeile 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 1802Zeile 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 2041Zeile 2166
		return false;
}


		return false;
}


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

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



/*
* states:


/*
* states:

Zeile 3173Zeile 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 3274Zeile 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 3444Zeile 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 3454Zeile 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 3466Zeile 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 3539Zeile 3710
		else
{
$clickablesmilies = "";

		else
{
$clickablesmilies = "";

		}

		}

	}
else
{

	}
else
{

Zeile 3662Zeile 3833
		if($selected_pid == 'any')
{
$any_selected = " selected=\"selected\"";

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

		}
}

		}
}


$default_selected = "";
if(((int)$selected_pid == 0) && $selected_pid != 'any')


$default_selected = "";
if(((int)$selected_pid == 0) && $selected_pid != 'any')

Zeile 3672Zeile 3843
	}

foreach($prefixes as $prefix)

	}

foreach($prefixes as $prefix)

	{

	{

		$selected = "";
if($prefix['pid'] == $selected_pid)
{

		$selected = "";
if($prefix['pid'] == $selected_pid)
{

Zeile 3681Zeile 3852

$prefix['prefix'] = htmlspecialchars_uni($prefix['prefix']);
eval("\$prefixselect_prefix .= \"".$templates->get("post_prefixselect_prefix")."\";");


$prefix['prefix'] = htmlspecialchars_uni($prefix['prefix']);
eval("\$prefixselect_prefix .= \"".$templates->get("post_prefixselect_prefix")."\";");

	}


	}


	if($multiple != 0)
{
eval("\$prefixselect = \"".$templates->get("post_prefixselect_multiple")."\";");

	if($multiple != 0)
{
eval("\$prefixselect = \"".$templates->get("post_prefixselect_multiple")."\";");

	}

	}

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

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

	}

return $prefixselect;
}


	}

return $prefixselect;
}


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

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

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

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

		return '';
}


		return '';
}


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

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

Zeile 3734Zeile 3905
		{
// This prefix is for anybody to use...
$prefixes[$prefix['pid']] = $prefix;

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

		}
}


		}
}


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

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

Zeile 3744Zeile 3915

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


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





	if($selected_pid == 0)

	if($selected_pid == 0)

	{

	{

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

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

	}

	}

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

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

	{

	{

		$default_selected['any'] = ' selected="selected"';
}


		$default_selected['any'] = ' selected="selected"';
}


Zeile 3772Zeile 3943

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


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

}

/**

}

/**

 * Gzip encodes text to a specified level
*
* @param string $contents The string to encode

 * Gzip encodes text to a specified level
*
* @param string $contents The string to encode

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

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

	}


	}


	return $display_reputation;
}


	return $display_reputation;
}


Zeile 3952Zeile 4123
	if($level >= 80)
{
$warning_class = "high_warning";

	if($level >= 80)
{
$warning_class = "high_warning";

	}

	}

	else if($level >= 50)

	else if($level >= 50)

	{

	{

		$warning_class = "moderate_warning";

		$warning_class = "moderate_warning";

	}

	}

	else if($level >= 25)

	else if($level >= 25)

	{

	{

		$warning_class = "low_warning";
}
else

		$warning_class = "low_warning";
}
else

	{

	{

		$warning_class = "normal_warning";
}


		$warning_class = "normal_warning";
}


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

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

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

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

	{

	{

		$addresses = array();

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

		$addresses = array();

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

		{

		{

			$addresses = explode(',', strtolower($_SERVER['HTTP_X_FORWARDED_FOR']));

			$addresses = explode(',', strtolower($_SERVER['HTTP_X_FORWARDED_FOR']));

		}

		}

		elseif(isset($_SERVER['HTTP_X_REAL_IP']))
{
$addresses = explode(',', strtolower($_SERVER['HTTP_X_REAL_IP']));

		elseif(isset($_SERVER['HTTP_X_REAL_IP']))
{
$addresses = explode(',', strtolower($_SERVER['HTTP_X_REAL_IP']));

		}

		}


if(is_array($addresses))
{


if(is_array($addresses))
{

Zeile 4012Zeile 4183
	if(!$ip)
{
if(isset($_SERVER['HTTP_CLIENT_IP']))

	if(!$ip)
{
if(isset($_SERVER['HTTP_CLIENT_IP']))

		{
$ip = strtolower($_SERVER['HTTP_CLIENT_IP']);
}

		{
$ip = strtolower($_SERVER['HTTP_CLIENT_IP']);
}

	}

if($plugins)

	}

if($plugins)

Zeile 4218Zeile 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 4232Zeile 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 4247Zeile 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 4337Zeile 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 4651Zeile 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 4982Zeile 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 5021Zeile 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 5054Zeile 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 5085Zeile 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 5372Zeile 5548

/**
* DEPRECATED! Please use other alternatives.


/**
* DEPRECATED! Please use other alternatives.

 *
* @deprecated

 *
* @deprecated

 * @param string $message
*
* @return string

 * @param string $message
*
* @return string

Zeile 5562Zeile 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 5751Zeile 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 6224Zeile 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 6386Zeile 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 6427Zeile 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 6467Zeile 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 6483Zeile 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 6516Zeile 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 7067Zeile 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 7128Zeile 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 7137Zeile 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 7163Zeile 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 7174Zeile 7380
		if(!@fwrite($fp, $headers))
{
return false;

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

		}


		}


		$data = null;

while(!feof($fp))

		$data = null;

while(!feof($fp))

Zeile 7192Zeile 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 7205Zeile 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 7223Zeile 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 7253Zeile 7459
	if($path = ini_get('curl.cainfo'))
{
return $path;

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

	}


	}


	return false;
}


	return false;
}


Zeile 7265Zeile 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 7296Zeile 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 7316Zeile 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 7358Zeile 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 7380Zeile 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 7549Zeile 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 7559Zeile 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 7579Zeile 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 7599Zeile 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 7634Zeile 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 7665Zeile 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 7695Zeile 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 7718Zeile 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 7739Zeile 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 7750Zeile 7956
					array('::', '(int)"$1"?"$1":"0$1"'),
$r);
return $r;

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

		}

		}

		return false;
}
}

		return false;
}
}

Zeile 7770Zeile 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 7803Zeile 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 7821Zeile 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 7867Zeile 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 7931Zeile 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 7990Zeile 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 8056Zeile 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 8074Zeile 8280
				if ($crypto_strong == false)
{
$output = null;

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

				}
}
}

				}
}
}

	}
else
{

	}
else
{

Zeile 8108Zeile 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 8138Zeile 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 8185Zeile 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 8693Zeile 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 8825Zeile 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;

}

}