Vergleich inc/functions.php - 1.8.19 - 1.8.26

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

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


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

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



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

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


	if(count($groups) == 1)
{
$groupscache[$gid]['all_usergroups'] = $gid;

	if(count($groups) == 1)
{
$groupscache[$gid]['all_usergroups'] = $gid;

Zeile 1334Zeile 1359

$displaygroup = array();
$group = $groupscache[$gid];


$displaygroup = array();
$group = $groupscache[$gid];





	foreach($displaygroupfields as $field)
{
$displaygroup[$field] = $group[$field];

	foreach($displaygroupfields as $field)
{
$displaygroup[$field] = $group[$field];

Zeile 1393Zeile 1418
	}

if(!is_array($fpermcache))

	}

if(!is_array($fpermcache))

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

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

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

		{

		{

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

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

Zeile 1412Zeile 1437
			foreach($forum_cache as $forum)
{
$cached_forum_permissions[$gid][$forum['fid']] = fetch_forum_permissions($forum['fid'], $gid, $groupperms);

			foreach($forum_cache as $forum)
{
$cached_forum_permissions[$gid][$forum['fid']] = fetch_forum_permissions($forum['fid'], $gid, $groupperms);

			}

			}

		}
return $cached_forum_permissions[$gid];
}

		}
return $cached_forum_permissions[$gid];
}

Zeile 1481Zeile 1506
			}

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

			}

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

			{

			{

				$only_view_own_threads = 0;
}


				$only_view_own_threads = 0;
}


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

		$current_permissions = $groupperms;
}
return $current_permissions;

 
}

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

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

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

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

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

}

/**

}

/**

Zeile 1549Zeile 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 1574Zeile 1642
		}
else
{

		}
else
{

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

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

			{
$showform = true;
}

			{
$showform = true;
}

Zeile 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)
{
if(!is_array($forum) || !in_array($forumid, $parentslist))

	foreach($mod_cache as $forumid => $forum)
{
if(!is_array($forum) || !in_array($forumid, $parentslist))

Zeile 1673Zeile 1741
		if(is_array($forum['users'][$uid]))
{
$perm = $forum['users'][$uid];

		if(is_array($forum['users'][$uid]))
{
$perm = $forum['users'][$uid];

			foreach($perm as $action => $value)
{
if(strpos($action, "can") === false)
{
continue;

			foreach($perm as $action => $value)
{
if(strpos($action, "can") === false)
{
continue;

				}

// Figure out the user permissions

				}

// Figure out the user permissions

Zeile 1789Zeile 1857
			if(!$action && $modperms)
{
return true;

			if(!$action && $modperms)
{
return true;

			}

			}

			else

			else

			{

			{

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

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

				{

				{

					return true;
}
else

					return true;
}
else

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 1852Zeile 1976
	if(!empty($iconlist))
{
eval("\$posticons = \"".$templates->get("posticons")."\";");

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

	}
else
{

	}
else
{

		$posticons = '';
}


		$posticons = '';
}


Zeile 1886Zeile 2010
	elseif($expires == "" || $expires == null)
{
$expires = TIME_NOW + (60*60*24*365); // Make the cookie expire in a years time

	elseif($expires == "" || $expires == null)
{
$expires = TIME_NOW + (60*60*24*365); // Make the cookie expire in a years time

	}

	}

	else

	else

	{

	{

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


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


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']))
{
$cookie .= "; domain={$mybb->settings['cookiedomain']}";


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

	}


	}


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

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

	}


	}


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

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

Zeile 2305Zeile 2429

/**
* Returns the serverload of the system.


/**
* Returns the serverload of the system.

 *

 *

 * @return int The serverload of the system.
*/
function get_server_load()

 * @return int The serverload of the system.
*/
function get_server_load()

Zeile 2321Zeile 2445
		{
// sys_getloadavg() will return an array with [0] being load within the last minute.
$serverload = sys_getloadavg();

		{
// sys_getloadavg() will return an array with [0] being load within the last minute.
$serverload = sys_getloadavg();

			$serverload[0] = round($serverload[0], 4);
}

			$serverload[0] = round($serverload[0], 4);
}

		else if(@file_exists("/proc/loadavg") && $load = @file_get_contents("/proc/loadavg"))

		else if(@file_exists("/proc/loadavg") && $load = @file_get_contents("/proc/loadavg"))

		{

		{

			$serverload = explode(" ", $load);
$serverload[0] = round($serverload[0], 4);
}

			$serverload = explode(" ", $load);
$serverload[0] = round($serverload[0], 4);
}

Zeile 2337Zeile 2461

// Suhosin likes to throw a warning if exec is disabled then die - weird
if($func_blacklist = @ini_get('suhosin.executor.func.blacklist'))


// Suhosin likes to throw a warning if exec is disabled then die - weird
if($func_blacklist = @ini_get('suhosin.executor.func.blacklist'))

			{
if(strpos(",".$func_blacklist.",", 'exec') !== false)

			{
if(strpos(",".$func_blacklist.",", 'exec') !== false)

				{
return $lang->unknown;
}

				{
return $lang->unknown;
}

Zeile 2369Zeile 2493
	$returnload = trim($serverload[0]);

return $returnload;

	$returnload = trim($serverload[0]);

return $returnload;

}


}


/**
* Returns the amount of memory allocated to the script.
*

/**
* Returns the amount of memory allocated to the script.
*

Zeile 2418Zeile 2542
			'numdeletedthreads' => '+0',
'inserted' => false // Reset after changes are inserted into cache
);

			'numdeletedthreads' => '+0',
'inserted' => false // Reset after changes are inserted into cache
);

		$stats = $stats_changes;

		$stats = $stats_changes;

	}

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

	}

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

	{

	{

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

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

Zeile 2434Zeile 2558
	else
{
$stats = $stats_changes;

	else
{
$stats = $stats_changes;

	}

	}


$new_stats = array();
$counters = array('numthreads', 'numunapprovedthreads', 'numposts', 'numunapprovedposts', 'numusers', 'numdeletedposts', 'numdeletedthreads');


$new_stats = array();
$counters = array('numthreads', 'numunapprovedthreads', 'numposts', 'numunapprovedposts', 'numusers', 'numdeletedposts', 'numdeletedthreads');

Zeile 2465Zeile 2589
					{
$new_stats[$counter] = 0;
}

					{
$new_stats[$counter] = 0;
}

				}
}
else

				}
}
else

			{
$new_stats[$counter] = $changes[$counter];
// Less than 0? That's bad

			{
$new_stats[$counter] = $changes[$counter];
// Less than 0? That's bad

Zeile 2483Zeile 2607
	{
$stats_changes = array_merge($stats, $new_stats); // Overwrite changed values
return;

	{
$stats_changes = array_merge($stats, $new_stats); // Overwrite changed values
return;

	}

	}


// Fetch latest user if the user count is changing
if(array_key_exists('numusers', $changes))


// Fetch latest user if the user count is changing
if(array_key_exists('numusers', $changes))

	{

	{

		$query = $db->simple_select("users", "uid, username", "", array('order_by' => 'regdate', 'order_dir' => 'DESC', 'limit' => 1));
$lastmember = $db->fetch_array($query);
$new_stats['lastuid'] = $lastmember['uid'];

		$query = $db->simple_select("users", "uid, username", "", array('order_by' => 'regdate', 'order_dir' => 'DESC', 'limit' => 1));
$lastmember = $db->fetch_array($query);
$new_stats['lastuid'] = $lastmember['uid'];

Zeile 2499Zeile 2623
		if(is_array($stats))
{
$stats = array_merge($stats, $new_stats); // Overwrite changed values

		if(is_array($stats))
{
$stats = array_merge($stats, $new_stats); // Overwrite changed values

		}

		}

		else
{
$stats = $new_stats;

		else
{
$stats = $new_stats;

Zeile 2547Zeile 2671
			}
// Adding or subtracting from previous value?
if(substr($changes[$counter], 0, 1) == "+" || substr($changes[$counter], 0, 1) == "-")

			}
// Adding or subtracting from previous value?
if(substr($changes[$counter], 0, 1) == "+" || substr($changes[$counter], 0, 1) == "-")

			{

			{

				if((int)$changes[$counter] != 0)
{
$update_query[$counter] = $forum[$counter] + $changes[$counter];

				if((int)$changes[$counter] != 0)
{
$update_query[$counter] = $forum[$counter] + $changes[$counter];

Zeile 2563Zeile 2687
			{
$update_query[$counter] = 0;
}

			{
$update_query[$counter] = 0;
}

		}
}


		}
}


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

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

Zeile 2578Zeile 2702
	{
$threads_diff = $update_query['threads'] - $forum['threads'];
if($threads_diff > -1)

	{
$threads_diff = $update_query['threads'] - $forum['threads'];
if($threads_diff > -1)

		{

		{

			$new_stats['numthreads'] = "+{$threads_diff}";

			$new_stats['numthreads'] = "+{$threads_diff}";

		}
else

		}
else

		{
$new_stats['numthreads'] = "{$threads_diff}";
}

		{
$new_stats['numthreads'] = "{$threads_diff}";
}

Zeile 2593Zeile 2717
		if($unapprovedthreads_diff > -1)
{
$new_stats['numunapprovedthreads'] = "+{$unapprovedthreads_diff}";

		if($unapprovedthreads_diff > -1)
{
$new_stats['numunapprovedthreads'] = "+{$unapprovedthreads_diff}";

		}
else

		}
else

		{
$new_stats['numunapprovedthreads'] = "{$unapprovedthreads_diff}";
}

		{
$new_stats['numunapprovedthreads'] = "{$unapprovedthreads_diff}";
}

Zeile 2604Zeile 2728
	{
$posts_diff = $update_query['posts'] - $forum['posts'];
if($posts_diff > -1)

	{
$posts_diff = $update_query['posts'] - $forum['posts'];
if($posts_diff > -1)

		{

		{

			$new_stats['numposts'] = "+{$posts_diff}";
}
else
{
$new_stats['numposts'] = "{$posts_diff}";

			$new_stats['numposts'] = "+{$posts_diff}";
}
else
{
$new_stats['numposts'] = "{$posts_diff}";

		}

		}

	}

if(array_key_exists('unapprovedposts', $update_query))

	}

if(array_key_exists('unapprovedposts', $update_query))

Zeile 2656Zeile 2780
	{
update_stats($new_stats);
}

	{
update_stats($new_stats);
}

}

/**

}

/**

 * Update the last post information for a specific forum
*
* @param int $fid The forum ID

 * Update the last post information for a specific forum
*
* @param int $fid The forum ID

Zeile 2690Zeile 2814

/**
* Updates the thread counters with a specific value (or addition/subtraction of the previous value)


/**
* Updates the thread counters with a specific value (or addition/subtraction of the previous value)

 *
* @param int $tid The thread ID

 *
* @param int $tid The thread ID

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

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

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

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

		}
else

		}
else

		{
$template = "advanced";

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

		{
$template = "advanced";

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

		}


		}


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

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





	return $forumjump;
}


	return $forumjump;
}


Zeile 3015Zeile 3139
 *
* @param string $file The filename.
* @return string The extension of the file.

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

 */

 */

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

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

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

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

		}

		}


if($displaygroup != 0)


if($displaygroup != 0)

		{

		{

			$usergroup = $displaygroup;
}

			$usergroup = $displaygroup;
}





		$format = "{username}";

if(isset($groupscache[$usergroup]))
{
$ugroup = $groupscache[$usergroup];

		$format = "{username}";

if(isset($groupscache[$usergroup]))
{
$ugroup = $groupscache[$usergroup];





			if(strpos($ugroup['namestyle'], "{username}") !== false)
{
$format = $ugroup['namestyle'];
}
}

			if(strpos($ugroup['namestyle'], "{username}") !== false)
{
$format = $ugroup['namestyle'];
}
}





		$format = stripslashes($format);

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

		$format = stripslashes($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 3150Zeile 3274
	if(!$max_dimensions)
{
$max_dimensions = $mybb->settings['maxavatardims'];

	if(!$max_dimensions)
{
$max_dimensions = $mybb->settings['maxavatardims'];

	}


	}


	// An empty key wouldn't work so we need to add a fall back
$key = $dimensions;
if(empty($key))

	// An empty key wouldn't work so we need to add a fall back
$key = $dimensions;
if(empty($key))

	{

	{

		$key = 'default';

		$key = 'default';

	}

	}

	$key2 = $max_dimensions;
if(empty($key2))
{
$key2 = 'default';

	$key2 = $max_dimensions;
if(empty($key2))
{
$key2 = 'default';

	}


	}


	if(isset($avatars[$avatar][$key][$key2]))
{
return $avatars[$avatar][$key][$key2];

	if(isset($avatars[$avatar][$key][$key2]))
{
return $avatars[$avatar][$key][$key2];

Zeile 3188Zeile 3312
			else
{
$avatar_width_height = "width=\"{$dimensions[0]}\" height=\"{$dimensions[1]}\"";

			else
{
$avatar_width_height = "width=\"{$dimensions[0]}\" height=\"{$dimensions[1]}\"";

			}
}
}

			}
}
}


$avatars[$avatar][$key][$key2] = array(
'image' => htmlspecialchars_uni($mybb->get_asset_url($avatar)),


$avatars[$avatar][$key][$key2] = array(
'image' => htmlspecialchars_uni($mybb->get_asset_url($avatar)),

Zeile 3489Zeile 3613
			$subscription_method = (int)$subscription['notification'] + 1;
}
}

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

	



	return $subscription_methods[$subscription_method];
}


	return $subscription_methods[$subscription_method];
}


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 4985Zeile 5103
	}

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

	}

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

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







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

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





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

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

















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

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

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

	}

	}

}

}





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

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

Zeile 5025Zeile 5134
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);


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

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

if(is_array($groups))

	if($user['usergroup'] == $leavegroup)







	{

	{

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

		return false;









	}

	}

 

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

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


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


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

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

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

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

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

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

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

 * @return string The current URL being accessed

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

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

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

 
	global $mybb;


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

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

Zeile 5103Zeile 5209
		return $location;
}


		return $location;
}


	if($fields == true)

	if(!is_array($ignore))

	{

	{

		global $mybb;


		$ignore = array($ignore);
}





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

	if($fields == true)
{




$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 5123Zeile 5228
				}

$form_html .= "<input type=\"hidden\" name=\"".htmlspecialchars_uni($name)."\" value=\"".htmlspecialchars_uni($value)."\" />\n";

				}

$form_html .= "<input type=\"hidden\" name=\"".htmlspecialchars_uni($name)."\" value=\"".htmlspecialchars_uni($value)."\" />\n";

			}
}


			}
}


		return array('location' => $location, 'form_html' => $form_html, 'form_method' => $mybb->request_method);
}
else
{

		return array('location' => $location, 'form_html' => $form_html, 'form_method' => $mybb->request_method);
}
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']);
}

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














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

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

foreach($post_array as $var)
{

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

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

				{

				{

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

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

				}
}

				}
}

 
		}





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

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










		}

return $location;

		}

return $location;

Zeile 5312Zeile 5424
 *
* @param int $number The number to format.
* @return int The formatted number.

 *
* @param int $number The number to format.
* @return int The formatted number.

 */

 */

function my_number_format($number)
{
global $mybb;

function my_number_format($number)
{
global $mybb;





	if($number == "-")
{
return $number;
}

if(is_int($number))

	if($number == "-")
{
return $number;
}

if(is_int($number))

	{

	{

		return number_format($number, 0, $mybb->settings['decpoint'], $mybb->settings['thousandssep']);
}
else

		return number_format($number, 0, $mybb->settings['decpoint'], $mybb->settings['thousandssep']);
}
else

Zeile 5331Zeile 5443
		$parts = explode('.', $number);

if(isset($parts[1]))

		$parts = explode('.', $number);

if(isset($parts[1]))

		{

		{

			$decimals = my_strlen($parts[1]);

			$decimals = my_strlen($parts[1]);

		}
else
{

		}
else
{

			$decimals = 0;
}


			$decimals = 0;
}


Zeile 5370Zeile 5482
	if(!isset($use_iconv))
{
$use_iconv = function_exists("iconv");

	if(!isset($use_iconv))
{
$use_iconv = function_exists("iconv");

	}


	}


	if(!isset($use_mb))

	if(!isset($use_mb))

	{

	{

		$use_mb = function_exists("mb_convert_encoding");
}


		$use_mb = function_exists("mb_convert_encoding");
}


Zeile 5383Zeile 5495
		{
$from_charset = $lang->settings['charset'];
$to_charset = "UTF-8";

		{
$from_charset = $lang->settings['charset'];
$to_charset = "UTF-8";

		}

		}

		else
{
$from_charset = "UTF-8";

		else
{
$from_charset = "UTF-8";

Zeile 5407Zeile 5519
		else
{
return utf8_decode($str);

		else
{
return utf8_decode($str);

		}
}

		}
}

	else
{
return $str;

	else
{
return $str;

Zeile 5417Zeile 5529

/**
* DEPRECATED! Please use other alternatives.


/**
* DEPRECATED! Please use other alternatives.

 *
* @deprecated

 *
* @deprecated

 * @param string $message

 * @param string $message

 *

 *

 * @return string
*/
function my_wordwrap($message)
{
return $message;

 * @return string
*/
function my_wordwrap($message)
{
return $message;

}

/**
* Workaround for date limitation in PHP to establish the day of a birthday (Provided by meme)
*

}

/**
* Workaround for date limitation in PHP to establish the day of a birthday (Provided by meme)
*

 * @param int $month The month of the birthday
* @param int $day The day of the birthday
* @param int $year The year of the bithday

 * @param int $month The month of the birthday
* @param int $day The day of the birthday
* @param int $year The year of the bithday

Zeile 5464Zeile 5576
			}
}
}

			}
}
}

}

/**

}

/**

 * Workaround for date limitation in PHP to establish the day of a birthday (Provided by meme)
*
* @param int $in The year.

 * Workaround for date limitation in PHP to establish the day of a birthday (Provided by meme)
*
* @param int $in The year.

Zeile 5477Zeile 5589
	return array(
31,
($in % 4 == 0 && ($in % 100 > 0 || $in % 400 == 0) ? 29 : 28),

	return array(
31,
($in % 4 == 0 && ($in % 100 > 0 || $in % 400 == 0) ? 29 : 28),

		31,
30,

		31,
30,

		31,
30,
31,

		31,
30,
31,

Zeile 5503Zeile 5615
 * @return string The formatted birthday
*/
function format_bdays($display, $bm, $bd, $by, $wd)

 * @return string The formatted birthday
*/
function format_bdays($display, $bm, $bd, $by, $wd)

{
global $lang;


{
global $lang;


	$bdays = array(
$lang->sunday,
$lang->monday,

	$bdays = array(
$lang->sunday,
$lang->monday,

Zeile 5529Zeile 5641
		$lang->month_10,
$lang->month_11,
$lang->month_12

		$lang->month_10,
$lang->month_11,
$lang->month_12

	);


	);


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

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

Zeile 5600Zeile 5712
	if(!$bday[2])
{
return;

	if(!$bday[2])
{
return;

	}

list($day, $month, $year) = explode("-", my_date("j-n-Y", TIME_NOW, 0, 0));

	}

list($day, $month, $year) = explode("-", my_date("j-n-Y", TIME_NOW, 0, 0));


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



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


Zeile 5796Zeile 5908
	}

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 6408
	global $cache;
static $forum_cache;


	global $cache;
static $forum_cache;


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

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

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

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

Zeile 6431Zeile 6570
	}
// 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);
$hoursleft = floor($secsleft / 3600);
$minsleft = floor(($secsleft / 60) % 60);
$secsleft = floor($secsleft % 60);

		if($fatal)
{
$secsleft = (int)($mybb->cookies['lockoutexpiry'] - $now);
$hoursleft = floor($secsleft / 3600);
$minsleft = floor(($secsleft / 60) % 60);
$secsleft = floor($secsleft % 60);





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

return false;
}

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

return false;
}





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

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





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

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

Zeile 6472Zeile 6611

// 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 6484Zeile 6623
			}

return false;

			}

return false;

		}

		}

		// Unlock if enough time has passed
else {


		// Unlock if enough time has passed
else {


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

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

 

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

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

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

	}


	}


	$settings = "<"."?php\n/*********************************\ \n  DO NOT EDIT THIS FILE, PLEASE USE\n  THE SETTINGS EDITOR\n\*********************************/\n\n$settings\n";

file_put_contents(MYBB_ROOT.'inc/settings.php', $settings, LOCK_EX);

	$settings = "<"."?php\n/*********************************\ \n  DO NOT EDIT THIS FILE, PLEASE USE\n  THE SETTINGS EDITOR\n\*********************************/\n\n$settings\n";

file_put_contents(MYBB_ROOT.'inc/settings.php', $settings, LOCK_EX);





	$GLOBALS['settings'] = &$mybb->settings;
}

	$GLOBALS['settings'] = &$mybb->settings;
}





/**
* Build a PREG compatible array of search highlight terms to replace in posts.
*

/**
* Build a PREG compatible array of search highlight terms to replace in posts.
*

Zeile 6585Zeile 6726
	if($mybb->settings['minsearchword'] < 1)
{
$mybb->settings['minsearchword'] = 3;

	if($mybb->settings['minsearchword'] < 1)
{
$mybb->settings['minsearchword'] = 3;

	}


	}


	if(is_array($terms))
{
$terms = implode(' ', $terms);

	if(is_array($terms))
{
$terms = implode(' ', $terms);

	}


	}


	// Strip out any characters that shouldn't be included
$bad_characters = array(
"(",

	// Strip out any characters that shouldn't be included
$bad_characters = array(
"(",

Zeile 6645Zeile 6786
		if(is_array($split_words))
{
foreach($split_words as $word)

		if(is_array($split_words))
{
foreach($split_words as $word)

			{

			{

				if(!$word || strlen($word) < $mybb->settings['minsearchword'])
{
continue;

				if(!$word || strlen($word) < $mybb->settings['minsearchword'])
{
continue;

Zeile 6861Zeile 7002
			if($update_lastuse == true)
{
$db->update_query("banfilters", array("lastuse" => TIME_NOW), "fid='{$banned_ip['fid']}'");

			if($update_lastuse == true)
{
$db->update_query("banfilters", array("lastuse" => TIME_NOW), "fid='{$banned_ip['fid']}'");

			}
return true;
}
}


			}
return true;
}
}


	// Still here - good ip
return false;
}

	// Still here - good ip
return false;
}

Zeile 7057Zeile 7198
		$fetch_header = $max_redirects > 0;

$ch = curl_init();

		$fetch_header = $max_redirects > 0;

$ch = curl_init();





		$curlopt = array(
CURLOPT_URL => $url,
CURLOPT_HEADER => $fetch_header,

		$curlopt = array(
CURLOPT_URL => $url,
CURLOPT_HEADER => $fetch_header,

Zeile 7067Zeile 7208
		);

if($ca_bundle_path = get_ca_bundle_path())

		);

if($ca_bundle_path = get_ca_bundle_path())

		{

		{

			$curlopt[CURLOPT_SSL_VERIFYPEER] = 1;
$curlopt[CURLOPT_CAINFO] = $ca_bundle_path;
}
else

			$curlopt[CURLOPT_SSL_VERIFYPEER] = 1;
$curlopt[CURLOPT_CAINFO] = $ca_bundle_path;
}
else

		{

		{

			$curlopt[CURLOPT_SSL_VERIFYPEER] = 0;
}


			$curlopt[CURLOPT_SSL_VERIFYPEER] = 0;
}


Zeile 7095Zeile 7236
		}

if(!empty($post_body))

		}

if(!empty($post_body))

		{

		{

			$curlopt[CURLOPT_POST] = 1;
$curlopt[CURLOPT_POSTFIELDS] = $post_body;
}

			$curlopt[CURLOPT_POST] = 1;
$curlopt[CURLOPT_POSTFIELDS] = $post_body;
}

Zeile 7112Zeile 7253

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


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

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

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


if($matches)
{


if($matches)
{

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

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

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

					),
));
}

					),
));
}

Zeile 7237Zeile 7379

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


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

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

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


if($matches)
{


if($matches)
{

Zeile 8738Zeile 8880

if(file_exists($file_path))
{


if(file_exists($file_path))
{

 

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


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

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

Zeile 8783Zeile 8937
	}

return $success;

	}

return $success;

}

/**

}

/**

 * Validate an url
*
* @param string $url The url to validate.

 * Validate an url
*
* @param string $url The url to validate.

Zeile 8831Zeile 8985
	);
$string = preg_replace($pattern, '', $string);
return strip_tags($string, $allowable_tags);

	);
$string = preg_replace($pattern, '', $string);
return strip_tags($string, $allowable_tags);

}

/**

}

/**

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

Zeile 8856Zeile 9010
		)
{
$string = "'".$string;

		)
{
$string = "'".$string;

		}


		}


		foreach($delimiters as $delimiter)
{
foreach($active_content_triggers as $trigger)

		foreach($delimiters as $delimiter)
{
foreach($active_content_triggers as $trigger)

Zeile 8866Zeile 9020
			}
}
}

			}
}
}





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

return $string;

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

return $string;

Zeile 8881Zeile 9035
 		if(!is_array($input))
{
$input = array($input);

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

		}

		}

 		foreach($input as $val)
{
if(is_array($val) && isset($val[$column_key]))
{
$values[] = $val[$column_key];

 		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;

			elseif(is_object($val) && isset($val->$column_key))
{
$values[] = $val->$column_key;

Zeile 8905Zeile 9059
 * @return bool Result of the comparison.
*/
function my_hash_equals($known_string, $user_string)

 * @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

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

		$known_string_length = my_strlen($known_string);
$user_string_length = my_strlen($user_string);





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

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

		}

$result = 0;

		}

$result = 0;


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


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





		return $result === 0;
}

		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;

}

}