Vergleich inc/functions.php - 1.8.18 - 1.8.24

  Keine Änderungen   Hinzugefügt   Modifiziert   Entfernt
Zeile 224Zeile 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 610Zeile 610
}

/**

}

/**

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


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

 *

 *

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

 * @return string The generated code
*/

 * @return string The generated code
*/

function generate_post_check()

function generate_post_check($rotation_shift=0)

{
global $mybb, $session;

{
global $mybb, $session;

 

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

$seed = $rotation;


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

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

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

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

	}

	}

	// Guests get a special string

 
	else
{

	else
{

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

		$seed .= $session->sid;

	}

	}

 

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

return md5($seed);

}

/**

}

/**

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

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

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

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

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

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

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

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

	if(generate_post_check() !== $code)






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

	{
if($silent == true)
{

	{
if($silent == true)
{

Zeile 776Zeile 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 881Zeile 897
 * Presents the user with a "no permission" page
*/
function error_no_permission()

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

{

{

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

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





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

	$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']}");
echo json_encode(array("errors" => array($lang->error_nopermission_user_ajax)));

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

Zeile 975Zeile 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)

	{

	{

		$message = $lang->redirect;

		$message = $lang->redirect;

	}

	}


$time = TIME_NOW;
$timenow = my_date('relative', $time);


$time = TIME_NOW;
$timenow = my_date('relative', $time);





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

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

Zeile 992Zeile 1008

// Show redirects only if both ACP and UCP settings are enabled, or ACP is enabled, and user is a guest, or they are forced.
if($force_redirect == true || ($mybb->settings['redirects'] == 1 && ($mybb->user['showredirect'] == 1 || !$mybb->user['uid'])))


// Show redirects only if both ACP and UCP settings are enabled, or ACP is enabled, and user is a guest, or they are forced.
if($force_redirect == true || ($mybb->settings['redirects'] == 1 && ($mybb->user['showredirect'] == 1 || !$mybb->user['uid'])))

	{

	{

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


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


Zeile 1009Zeile 1025
		if(!my_validate_url($url, true, true))
{
header("Location: {$mybb->settings['bburl']}/{$url}");

		if(!my_validate_url($url, true, true))
{
header("Location: {$mybb->settings['bburl']}/{$url}");

		}
else

		}
else

		{
header("Location: {$url}");
}

		{
header("Location: {$url}");
}

	}

	}


exit;
}


exit;
}

Zeile 1031Zeile 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 1263Zeile 1288
{
global $cache, $groupscache, $grouppermignore, $groupzerogreater;


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


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

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

if(count($groups) == 1)

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

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

if(count($groups) == 1)

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

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





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


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


Zeile 1284Zeile 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 1301Zeile 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 1313Zeile 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 1365Zeile 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 1377Zeile 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 1430Zeile 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 1478Zeile 1503
				{
$current_permissions[$permission] = $access;
}

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

			}

			}


if($level_permissions["canview"] && empty($level_permissions["canonlyviewownthreads"]))
{
$only_view_own_threads = 0;


if($level_permissions["canview"] && empty($level_permissions["canonlyviewownthreads"]))
{
$only_view_own_threads = 0;

			}


			}


			if($level_permissions["canpostreplys"] && empty($level_permissions["canonlyreplyownthreads"]))
{
$only_reply_own_threads = 0;

			if($level_permissions["canpostreplys"] && empty($level_permissions["canonlyreplyownthreads"]))
{
$only_reply_own_threads = 0;

Zeile 1494Zeile 1519

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


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

	{

	{

		$current_permissions["canonlyviewownthreads"] = 0;

		$current_permissions["canonlyviewownthreads"] = 0;

	}

	}


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


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

	{

	{

		$current_permissions["canonlyreplyownthreads"] = 0;

		$current_permissions["canonlyreplyownthreads"] = 0;

	}

	}


if(count($current_permissions) == 0)
{
$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 1522Zeile 1591
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;





	$showform = true;

if(!is_array($forum_cache))

	$showform = true;

if(!is_array($forum_cache))

	{

	{

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

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

	}

	}


// Loop through each of parent forums to ensure we have a password for them too
if(isset($forum_cache[$fid]['parentlist']))


// Loop through each of parent forums to ensure we have a password for them too
if(isset($forum_cache[$fid]['parentlist']))

Zeile 1541Zeile 1610
		rsort($parents);
}
if(!empty($parents))

		rsort($parents);
}
if(!empty($parents))

	{

	{

		foreach($parents as $parent_id)
{
if($parent_id == $fid || $parent_id == $pid)
{
continue;

		foreach($parents as $parent_id)
{
if($parent_id == $fid || $parent_id == $pid)
{
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;

			}

			}

			else

			else

			{

			{

				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 1609Zeile 1677
		exit;
}
}

		exit;
}
}





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

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

Zeile 1624Zeile 1692
	static $modpermscache;

if($uid < 1)

	static $modpermscache;

if($uid < 1)

	{

	{

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


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


Zeile 1656Zeile 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");


foreach($mod_cache as $forumid => $forum)
{


foreach($mod_cache as $forumid => $forum)
{

Zeile 1803Zeile 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 1847Zeile 1971
		}

eval("\$iconlist .= \"".$templates->get("posticons_icon")."\";");

		}

eval("\$iconlist .= \"".$templates->get("posticons_icon")."\";");

	}

	}


if(!empty($iconlist))
{


if(!empty($iconlist))
{

Zeile 1875Zeile 1999
	global $mybb;

if(!$mybb->settings['cookiepath'])

	global $mybb;

if(!$mybb->settings['cookiepath'])

	{

	{

		$mybb->settings['cookiepath'] = "/";
}


		$mybb->settings['cookiepath'] = "/";
}


Zeile 1902Zeile 2026
	if($expires > 0)
{
$cookie .= "; expires=".@gmdate('D, d-M-Y H:i:s \\G\\M\\T', $expires);

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

	}


	}


	if(!empty($mybb->settings['cookiepath']))

	if(!empty($mybb->settings['cookiepath']))

	{

	{

		$cookie .= "; path={$mybb->settings['cookiepath']}";

		$cookie .= "; path={$mybb->settings['cookiepath']}";

	}

	}


if(!empty($mybb->settings['cookiedomain']))


if(!empty($mybb->settings['cookiedomain']))

	{

	{

		$cookie .= "; domain={$mybb->settings['cookiedomain']}";
}

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

		$cookie .= "; domain={$mybb->settings['cookiedomain']}";
}

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

	}

	}


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


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

Zeile 2301Zeile 2425
	}

return $out;

	}

return $out;

}

/**

}

/**

 * Returns the serverload of the system.
*
* @return int The serverload of the system.

 * Returns the serverload of the system.
*
* @return int The serverload of the system.

Zeile 2686Zeile 2810
	);

$db->update_query("forums", $updated_forum, "fid='{$fid}'");

	);

$db->update_query("forums", $updated_forum, "fid='{$fid}'");

}

/**

}

/**

 * Updates the thread counters with a specific value (or addition/subtraction of the previous value)
*
* @param int $tid The thread ID

 * Updates the thread counters with a specific value (or addition/subtraction of the previous value)
*
* @param int $tid The thread ID

Zeile 2734Zeile 2858
				$update_query[$counter] = 0;
}
}

				$update_query[$counter] = 0;
}
}

	}


	}


	$db->free_result($query);

// Only update if we're actually doing something

	$db->free_result($query);

// Only update if we're actually doing something

Zeile 2814Zeile 2938
		'lastpost' => (int)$lastpost['dateline'],
'lastposter' => $lastpost['username'],
'lastposteruid' => (int)$lastpost['uid'],

		'lastpost' => (int)$lastpost['dateline'],
'lastposter' => $lastpost['username'],
'lastposteruid' => (int)$lastpost['uid'],

	);

	);

	$db->update_query("threads", $update_array, "tid='{$tid}'");
}


	$db->update_query("threads", $update_array, "tid='{$tid}'");
}


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

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





	$update_query = array();

	$update_query = array();





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


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


Zeile 2877Zeile 3001

/**
* Deletes a thread from the database


/**
* Deletes a thread from the database

 *

 *

 * @param int $tid The thread ID
* @return bool
*/
function delete_thread($tid)
{
global $moderation;

 * @param int $tid The thread ID
* @return bool
*/
function delete_thread($tid)
{
global $moderation;





	if(!is_object($moderation))
{
require_once MYBB_ROOT."inc/class_moderation.php";
$moderation = new Moderation;
}

	if(!is_object($moderation))
{
require_once MYBB_ROOT."inc/class_moderation.php";
$moderation = new Moderation;
}





	return $moderation->delete_thread($tid);

	return $moderation->delete_thread($tid);

}


}


/**
* Deletes a post from the database
*

/**
* Deletes a post from the database
*

Zeile 2909Zeile 3033
		require_once MYBB_ROOT."inc/class_moderation.php";
$moderation = new Moderation;
}

		require_once MYBB_ROOT."inc/class_moderation.php";
$moderation = new Moderation;
}





	return $moderation->delete_post($pid);
}


	return $moderation->delete_post($pid);
}


Zeile 2942Zeile 3066
		foreach($forum_cache as $fid => $forum)
{
if($forum['active'] != 0)

		foreach($forum_cache as $fid => $forum)
{
if($forum['active'] != 0)

			{

			{

				$jumpfcache[$forum['pid']][$forum['disporder']][$forum['fid']] = $forum;
}
}

				$jumpfcache[$forum['pid']][$forum['disporder']][$forum['fid']] = $forum;
}
}

Zeile 2973Zeile 3097
					$forum['name'] = htmlspecialchars_uni(strip_tags($forum['name']));

eval("\$forumjumpbits .= \"".$templates->get("forumjump_bit")."\";");

					$forum['name'] = htmlspecialchars_uni(strip_tags($forum['name']));

eval("\$forumjumpbits .= \"".$templates->get("forumjump_bit")."\";");





					if($forum_cache[$forum['fid']])
{
$newdepth = $depth."--";

					if($forum_cache[$forum['fid']])
{
$newdepth = $depth."--";

Zeile 2989Zeile 3113
		if($showextras == 0)
{
$template = "special";

		if($showextras == 0)
{
$template = "special";

		}

		}

		else
{
$template = "advanced";

		else
{
$template = "advanced";





			if(strpos(FORUM_URL, '.html') !== false)

			if(strpos(FORUM_URL, '.html') !== false)

			{

			{

				$forum_link = "'".str_replace('{fid}', "'+option+'", FORUM_URL)."'";

				$forum_link = "'".str_replace('{fid}', "'+option+'", FORUM_URL)."'";

			}

			}

			else
{
$forum_link = "'".str_replace('{fid}', "'+option", FORUM_URL);

			else
{
$forum_link = "'".str_replace('{fid}', "'+option", FORUM_URL);

Zeile 3005Zeile 3129
		}

eval("\$forumjump = \"".$templates->get("forumjump_".$template)."\";");

		}

eval("\$forumjump = \"".$templates->get("forumjump_".$template)."\";");

	}


	}


	return $forumjump;

	return $forumjump;

}

/**

}

/**

 * Returns the extension of a file.
*
* @param string $file The filename.

 * Returns the extension of a file.
*
* @param string $file The filename.

Zeile 3019Zeile 3143
function get_extension($file)
{
return my_strtolower(my_substr(strrchr($file, "."), 1));

function get_extension($file)
{
return my_strtolower(my_substr(strrchr($file, "."), 1));

}

/**

}

/**

 * Generates a random string.
*
* @param int $length The length of the string to generate.

 * Generates a random string.
*
* @param int $length The length of the string to generate.

Zeile 3070Zeile 3194
function format_name($username, $usergroup, $displaygroup=0)
{
global $groupscache, $cache, $plugins;

function format_name($username, $usergroup, $displaygroup=0)
{
global $groupscache, $cache, $plugins;





	static $formattednames = array();

	static $formattednames = array();





	if(!isset($formattednames[$username]))
{
if(!is_array($groupscache))

	if(!isset($formattednames[$username]))
{
if(!is_array($groupscache))

		{

		{

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

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

		}


		}


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

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

		}

$format = "{username}";

		}

$format = "{username}";


if(isset($groupscache[$usergroup]))
{


if(isset($groupscache[$usergroup]))
{

Zeile 3101Zeile 3225

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



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


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


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


		$format = $parameters['format'];

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

		$format = $parameters['format'];

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

Zeile 3133Zeile 3257
	{
// Remote avatar, but remote avatars are disallowed.
$avatar = null;

	{
// Remote avatar, but remote avatars are disallowed.
$avatar = null;

	}

	}


if(!$avatar)
{


if(!$avatar)
{

Zeile 3165Zeile 3289
	}

if(isset($avatars[$avatar][$key][$key2]))

	}

if(isset($avatars[$avatar][$key][$key2]))

	{

	{

		return $avatars[$avatar][$key][$key2];
}


		return $avatars[$avatar][$key][$key2];
}


Zeile 3198Zeile 3322
	);

return $avatars[$avatar][$key][$key2];

	);

return $avatars[$avatar][$key][$key2];

}

}


/**
* Build the javascript based MyCode inserter.


/**
* Build the javascript based MyCode inserter.

Zeile 3455Zeile 3579
function get_subscription_method($tid = 0, $postoptions = array())
{
global $mybb;

function get_subscription_method($tid = 0, $postoptions = array())
{
global $mybb;


$subscription_methods = array('dont', 'none', 'email', 'pm'); // Define methods


$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

	$subscription_method = (int)$mybb->user['subscriptionmethod']; // Set user default

// If no user default method available then reset method

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

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

		}

		}

	}

	}

	



	return $subscription_methods[$subscription_method];
}


	return $subscription_methods[$subscription_method];
}


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

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

			}

			}

		}

unset($smilie);

		}

unset($smilie);

Zeile 3552Zeile 3676
					$smilie['image'] = str_replace("{theme}", $theme['imgdir'], $smilie['image']);
$smilie['image'] = htmlspecialchars_uni($mybb->get_asset_url($smilie['image']));
$smilie['name'] = htmlspecialchars_uni($smilie['name']);

					$smilie['image'] = str_replace("{theme}", $theme['imgdir'], $smilie['image']);
$smilie['image'] = htmlspecialchars_uni($mybb->get_asset_url($smilie['image']));
$smilie['name'] = htmlspecialchars_uni($smilie['name']);





					// Only show the first text to replace in the box
$temp = explode("\n", $smilie['find']); // assign to temporary variable for php 5.3 compatibility
$smilie['find'] = $temp[0];

					// Only show the first text to replace in the box
$temp = explode("\n", $smilie['find']); // assign to temporary variable for php 5.3 compatibility
$smilie['find'] = $temp[0];

Zeile 3584Zeile 3708
			eval("\$clickablesmilies = \"".$templates->get("smilieinsert")."\";");
}
else

			eval("\$clickablesmilies = \"".$templates->get("smilieinsert")."\";");
}
else

		{

		{

			$clickablesmilies = "";
}
}

			$clickablesmilies = "";
}
}

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

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

		}

return $prefixes_cache;
}

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

		}

return $prefixes_cache;
}

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


if(!is_array($prefix_cache))
{


if(!is_array($prefix_cache))
{

Zeile 3631Zeile 3755
	}

$prefixes_cache = array();

	}

$prefixes_cache = array();

	foreach($prefix_cache as $prefix)
{

	foreach($prefix_cache as $prefix)
{

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


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


Zeile 3664Zeile 3788
	if($fid != 'all')
{
$fid = (int)$fid;

	if($fid != 'all')
{
$fid = (int)$fid;

	}

	}


$prefix_cache = build_prefixes(0);
if(empty($prefix_cache))


$prefix_cache = build_prefixes(0);
if(empty($prefix_cache))

Zeile 3713Zeile 3837
	}

$default_selected = "";

	}

$default_selected = "";

	if(((int)$selected_pid == 0) && $selected_pid != 'any')
{
$default_selected = " selected=\"selected\"";
}

foreach($prefixes as $prefix)
{

	if(((int)$selected_pid == 0) && $selected_pid != 'any')
{
$default_selected = " selected=\"selected\"";
}

foreach($prefixes as $prefix)
{

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

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

Zeile 3752Zeile 3876
function build_forum_prefix_select($fid, $selected_pid=0)
{
global $cache, $db, $lang, $mybb, $templates;

function build_forum_prefix_select($fid, $selected_pid=0)
{
global $cache, $db, $lang, $mybb, $templates;





	$fid = (int)$fid;

$prefix_cache = build_prefixes(0);

	$fid = (int)$fid;

$prefix_cache = build_prefixes(0);

Zeile 3816Zeile 3940
		$prefix['prefix'] = htmlspecialchars_uni($prefix['prefix']);
eval('$prefixselect_prefix .= "'.$templates->get("forumdisplay_threadlist_prefixes_prefix").'";');
}

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





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

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

Zeile 3847Zeile 3971
		if(my_strpos(" ".$httpaccept_encoding, "gzip"))
{
$encoding = "gzip";

		if(my_strpos(" ".$httpaccept_encoding, "gzip"))
{
$encoding = "gzip";

		}


		}


		if(isset($encoding))
{
header("Content-Encoding: $encoding");

		if(isset($encoding))
{
header("Content-Encoding: $encoding");

Zeile 3913Zeile 4037

// Any remaining extra data - we my_serialize and insert in to its own column
if(is_array($data))


// Any remaining extra data - we my_serialize and insert in to its own column
if(is_array($data))

	{

	{

		$data = my_serialize($data);
}


		$data = my_serialize($data);
}


Zeile 3929Zeile 4053
	);

if($tids)

	);

if($tids)

	{

	{

		$multiple_sql_array = array();

		$multiple_sql_array = array();





		foreach($tids as $tid)
{
$sql_array['tid'] = (int)$tid;

		foreach($tids as $tid)
{
$sql_array['tid'] = (int)$tid;

Zeile 3939Zeile 4063
		}

$db->insert_query_multiple("moderatorlog", $multiple_sql_array);

		}

$db->insert_query_multiple("moderatorlog", $multiple_sql_array);

	}

	}

	else
{
$db->insert_query("moderatorlog", $sql_array);
}
}

	else
{
$db->insert_query("moderatorlog", $sql_array);
}
}





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

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

Zeile 3961Zeile 4085
	if($reputation < 0)
{
$reputation_class = "reputation_negative";

	if($reputation < 0)
{
$reputation_class = "reputation_negative";

	}

	}

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

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

	}
else

	}
else

	{
$reputation_class = "reputation_neutral";

	{
$reputation_class = "reputation_neutral";

	}


	}


	$reputation = my_number_format($reputation);

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

	$reputation = my_number_format($reputation);

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

	}
else

	}
else

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

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

Zeile 4009Zeile 4133
		$warning_class = "low_warning";
}
else

		$warning_class = "low_warning";
}
else

	{

	{

		$warning_class = "normal_warning";
}


		$warning_class = "normal_warning";
}


Zeile 4025Zeile 4149
function get_ip()
{
global $mybb, $plugins;

function get_ip()
{
global $mybb, $plugins;





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

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

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

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

Zeile 4057Zeile 4181
	}

if(!$ip)

	}

if(!$ip)

	{

	{

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

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

Zeile 4105Zeile 4229
	}
// Petabyte (1024 Terabytes)
elseif($size >= 1125899906842624)

	}
// Petabyte (1024 Terabytes)
elseif($size >= 1125899906842624)

	{

	{

		$size = my_number_format(round(($size / 1125899906842624), 2))." ".$lang->size_pb;

		$size = my_number_format(round(($size / 1125899906842624), 2))." ".$lang->size_pb;

	}

	}

	// Terabyte (1024 Gigabytes)
elseif($size >= 1099511627776)
{
$size = my_number_format(round(($size / 1099511627776), 2))." ".$lang->size_tb;

	// Terabyte (1024 Gigabytes)
elseif($size >= 1099511627776)
{
$size = my_number_format(round(($size / 1099511627776), 2))." ".$lang->size_tb;

	}

	}

	// Gigabyte (1024 Megabytes)
elseif($size >= 1073741824)
{

	// Gigabyte (1024 Megabytes)
elseif($size >= 1073741824)
{

Zeile 4120Zeile 4244
	}
// Megabyte (1024 Kilobytes)
elseif($size >= 1048576)

	}
// Megabyte (1024 Kilobytes)
elseif($size >= 1048576)

	{

	{

		$size = my_number_format(round(($size / 1048576), 2))." ".$lang->size_mb;
}
// Kilobyte (1024 bytes)
elseif($size >= 1024)

		$size = my_number_format(round(($size / 1048576), 2))." ".$lang->size_mb;
}
// Kilobyte (1024 bytes)
elseif($size >= 1024)

	{

	{

		$size = my_number_format(round(($size / 1024), 2))." ".$lang->size_kb;

		$size = my_number_format(round(($size / 1024), 2))." ".$lang->size_kb;

	}

	}

	elseif($size == 0)

	elseif($size == 0)

	{

	{

		$size = "0 ".$lang->size_bytes;

		$size = "0 ".$lang->size_bytes;

	}

	}

	else
{
$size = my_number_format($size)." ".$lang->size_bytes;

	else
{
$size = my_number_format($size)." ".$lang->size_bytes;

	}


	}


	return $size;
}


	return $size;
}


Zeile 4184Zeile 4308
	if(!$attachtypes)
{
$attachtypes = $cache->read("attachtypes");

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

	}

	}


$ext = my_strtolower($ext);



$ext = my_strtolower($ext);


Zeile 4233Zeile 4357
		{
global $change_dir;
$theme['imgdir'] = "{$change_dir}/images";

		{
global $change_dir;
$theme['imgdir'] = "{$change_dir}/images";

		}


		}


		$icon = "{$theme['imgdir']}/attachtypes/unknown.png";

$name = $lang->unknown;

		$icon = "{$theme['imgdir']}/attachtypes/unknown.png";

$name = $lang->unknown;

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

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

{

{

	global $lang;

$ysecs = 365*24*60*60;

	global $lang;

$ysecs = 365*24*60*60;

Zeile 4822Zeile 4940
	{
$options = array_merge(array(
'days' => false,

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

			'hours' => false,

			'hours' => false,

			'minutes' => false,
'seconds' => false
), $options);

			'minutes' => false,
'seconds' => false
), $options);

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

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

		}

		}

		else if($years > 1)

		else if($years > 1)

		{

		{

			$nicetime['years'] = $years.$lang_years;

			$nicetime['years'] = $years.$lang_years;

		}

		}

	}

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

	}

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

		{

		{

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

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

		}
}


		}
}


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

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

		{

		{

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

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

		}

		}

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

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

Zeile 4886Zeile 5004
	}

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

	}

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

	{

	{

		if($days == 1)
{
$nicetime['days'] = "1".$lang_day;

		if($days == 1)
{
$nicetime['days'] = "1".$lang_day;

Zeile 4916Zeile 5034
			$nicetime['minutes'] = "1".$lang_minute;
}
else if($minutes > 1)

			$nicetime['minutes'] = "1".$lang_minute;
}
else if($minutes > 1)

		{

		{

			$nicetime['minutes'] = $minutes.$lang_minutes;

			$nicetime['minutes'] = $minutes.$lang_minutes;

		}
}

		}
}


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


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

		{

		{

			$nicetime['seconds'] = "1".$lang_second;

			$nicetime['seconds'] = "1".$lang_second;

		}

		}

		else if($seconds > 1)
{
$nicetime['seconds'] = $seconds.$lang_seconds;

		else if($seconds > 1)
{
$nicetime['seconds'] = $seconds.$lang_seconds;

		}
}


		}
}


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

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

Zeile 4961Zeile 5079
	$alttrow = $trow;

return $trow;

	$alttrow = $trow;

return $trow;

}


}


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

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

Zeile 4977Zeile 5095
	if($uid == $mybb->user['uid'])
{
$user = $mybb->user;

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

	}
else

	}
else

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

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

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

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

	}
else
{
return false;
}
}

	}
else
{
return false;
}
}


/**
* Remove a user from a specific additional user group


/**
* Remove a user from a specific additional user group

Zeile 5025Zeile 5143
function leave_usergroup($uid, $leavegroup)
{
global $db, $mybb, $cache;

function leave_usergroup($uid, $leavegroup)
{
global $db, $mybb, $cache;





	$user = get_user($uid);

	$user = get_user($uid);

 

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


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


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

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

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

			}
}
}


			}
}
}


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

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

Zeile 5066Zeile 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"))

	if(defined("MYBB_LOCATION"))

	{

	{

		return MYBB_LOCATION;
}

if(!empty($_SERVER['SCRIPT_NAME']))
{
$location = htmlspecialchars_uni($_SERVER['SCRIPT_NAME']);

		return MYBB_LOCATION;
}

if(!empty($_SERVER['SCRIPT_NAME']))
{
$location = htmlspecialchars_uni($_SERVER['SCRIPT_NAME']);

	}

	}

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

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

	{

	{

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

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

	}

	}

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

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

	{

	{

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

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

	}

	}

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

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

	{

	{

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

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

	}


	}


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

		{

		{

			foreach($mybb->input as $name => $value)
{
if(in_array($name, $ignore) || is_array($name) || is_array($value))

			foreach($mybb->input as $name => $value)
{
if(in_array($name, $ignore) || is_array($name) || is_array($value))

Zeile 5130Zeile 5254
	}
else
{

	}
else
{

 
		$parameters = array();


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

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

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

			$current_query_string = $_SERVER['QUERY_STRING'];

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

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

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






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

parse_str($current_query_string, $current_parameters);





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









		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)

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

foreach($post_array as $var)

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

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

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









				{

				{

					$location .= "?";

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

				}

				}

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

 
			}

			}

 
		}

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

		}

return $location;

		}

return $location;

Zeile 5412Zeile 5543
	else
{
return $str;

	else
{
return $str;

	}

	}

}

/**

}

/**

Zeile 5796Zeile 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 6269Zeile 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 6431Zeile 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 6472Zeile 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 6512Zeile 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 6528Zeile 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 6561Zeile 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 7112Zeile 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 7173Zeile 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 7237Zeile 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 8738Zeile 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 8777Zeile 8950
				'uploaded_path' => &$uploaded_path,
'success' => &$success,
);

				'uploaded_path' => &$uploaded_path,
'success' => &$success,
);





			$plugins->run_hooks('copy_file_to_cdn_end', $hook_args);
}
}

			$plugins->run_hooks('copy_file_to_cdn_end', $hook_args);
}
}

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

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

 *

 *

 * @param string $string The string to be escaped
* @param boolean $escape_active_content Whether or not to escape active content trigger characters
* @return string The escaped string

 * @param string $string The string to be escaped
* @param boolean $escape_active_content Whether or not to escape active content trigger characters
* @return string The escaped string

Zeile 8895Zeile 9068
		}
return $values;
}

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

}

}