Vergleich inc/functions.php - 1.8.18 - 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 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
{
header("Location: {$url}");

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

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;

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


$page = (int)$page;

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





	$pages = ceil($count / $perpage);

$prevpage = '';
if($page > 1)

	$pages = ceil($count / $perpage);

$prevpage = '';
if($page > 1)

	{

	{

		$prev = $page-1;
$page_url = fetch_page_url($url, $prev);
eval("\$prevpage = \"".$templates->get("multipage_prevpage")."\";");

		$prev = $page-1;
$page_url = fetch_page_url($url, $prev);
eval("\$prevpage = \"".$templates->get("multipage_prevpage")."\";");

	}

	}


// Maximum number of "page bits" to show
if(!$mybb->settings['maxmultipagelinks'])
{
$mybb->settings['maxmultipagelinks'] = 5;


// Maximum number of "page bits" to show
if(!$mybb->settings['maxmultipagelinks'])
{
$mybb->settings['maxmultipagelinks'] = 5;

	}


	}


	$from = $page-floor($mybb->settings['maxmultipagelinks']/2);
$to = $page+floor($mybb->settings['maxmultipagelinks']/2);


	$from = $page-floor($mybb->settings['maxmultipagelinks']/2);
$to = $page+floor($mybb->settings['maxmultipagelinks']/2);


Zeile 1089Zeile 1114
		if($from-1 == 1)
{
$lang->multipage_link_start = '';

		if($from-1 == 1)
{
$lang->multipage_link_start = '';

		}


		}


		$page_url = fetch_page_url($url, 1);
eval("\$start = \"".$templates->get("multipage_start")."\";");
}

		$page_url = fetch_page_url($url, 1);
eval("\$start = \"".$templates->get("multipage_start")."\";");
}

Zeile 1138Zeile 1163

$jumptopage = '';
if($pages > ($mybb->settings['maxmultipagelinks']+1) && $mybb->settings['jumptopagemultipage'] == 1)


$jumptopage = '';
if($pages > ($mybb->settings['maxmultipagelinks']+1) && $mybb->settings['jumptopagemultipage'] == 1)

	{

	{

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

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

	}

	}


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

if($breadcrumb == true)


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

if($breadcrumb == true)

	{

	{

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

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

	}

	}

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

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

	}


	}


	return $multipage;
}


	return $multipage;
}


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

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

	{

	{

		$find = array(
"-page-{page}",
"&amp;page={page}",

		$find = array(
"-page-{page}",
"&amp;page={page}",

Zeile 1199Zeile 1224
	}

return $url;

	}

return $url;

}


}


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

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

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

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

	}


	}


	// Its a guest. Return the group permissions directly from cache
if($uid == 0)
{

	// Its a guest. Return the group permissions directly from cache
if($uid == 0)
{

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

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

		}

		}


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


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

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


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


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


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


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

if(count($groups) == 1)

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

if(count($groups) == 1)

Zeile 1315Zeile 1340
	}

return $usergroup;

	}

return $usergroup;

}


}


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

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

Zeile 1326Zeile 1351
function usergroup_displaygroup($gid)
{
global $cache, $groupscache, $displaygroupfields;

function usergroup_displaygroup($gid)
{
global $cache, $groupscache, $displaygroupfields;





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

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

	}


	}


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


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


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

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

		{

		{

			$user = get_user($uid);

			$user = get_user($uid);





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

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

Zeile 1379Zeile 1404
			}

$groupperms = $mybb->usergroup;

			}

$groupperms = $mybb->usergroup;

		}
}

		}
}


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


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





		if(!$forum_cache)
{
return false;

		if(!$forum_cache)
{
return false;

Zeile 1393Zeile 1418
	}

if(!is_array($fpermcache))

	}

if(!is_array($fpermcache))

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

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


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


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

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

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

			{

			{

				$cached_forum_permissions[$gid][$forum['fid']] = fetch_forum_permissions($forum['fid'], $gid, $groupperms);
}
}

				$cached_forum_permissions[$gid][$forum['fid']] = fetch_forum_permissions($forum['fid'], $gid, $groupperms);
}
}

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)

	if(count($current_permissions) == 0)

	{

	{

		$current_permissions = $groupperms;

		$current_permissions = $groupperms;

	}

	}

	return $current_permissions;

	return $current_permissions;

 
}

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

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

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

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

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

}

/**

}

/**

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

		{

		{

			// No perms or we're not after this forum
continue;
}

			// No perms or we're not after this forum
continue;
}

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)

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

				{
continue;
}

				{
continue;
}

Zeile 1710Zeile 1778
				}

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

				}

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

			}
}

			}
}

	}

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

	}

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

Zeile 1728Zeile 1796
 * @return bool Returns true if the user has permission, false if they do not
*/
function is_moderator($fid=0, $action="", $uid=0)

 * @return bool Returns true if the user has permission, false if they do not
*/
function is_moderator($fid=0, $action="", $uid=0)

{
global $mybb, $cache;

if($uid == 0)
{

{
global $mybb, $cache;

if($uid == 0)
{

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

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

	}

	}


if($uid == 0)


if($uid == 0)

	{

	{

		return false;
}


		return false;
}


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

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

			{

			{

				return true;
}
return false;

				return true;
}
return false;

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 3456Zeile 3580
{
global $mybb;


{
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 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 3543Zeile 3667
			$smilies = '';
$counter = 0;
$i = 0;

			$smilies = '';
$counter = 0;
$i = 0;





			$extra_class = '';
foreach($smiliecache as $smilie)
{

			$extra_class = '';
foreach($smiliecache as $smilie)
{

Zeile 3598Zeile 3722

/**
* Builds thread prefixes and returns a selected prefix (or all)


/**
* Builds thread prefixes and returns a selected prefix (or all)

 *

 *

 *  @param int $pid The prefix ID (0 to return all)
* @return array The thread prefix's values (or all thread prefixes)
*/

 *  @param int $pid The prefix ID (0 to return all)
* @return array The thread prefix's values (or all thread prefixes)
*/

Zeile 3681Zeile 3805
		{
// Decide whether this prefix can be used in our forum
$forums = explode(",", $prefix['forums']);

		{
// Decide whether this prefix can be used in our forum
$forums = explode(",", $prefix['forums']);





			if(!in_array($fid, $forums) && $prefix['pid'] != $previous_pid)
{
// This prefix is not in our forum list
continue;
}

			if(!in_array($fid, $forums) && $prefix['pid'] != $previous_pid)
{
// This prefix is not in our forum list
continue;
}

		}


		}


		if(is_member($prefix['groups']) || $prefix['pid'] == $previous_pid)
{
// The current user can use this prefix
$prefixes[$prefix['pid']] = $prefix;

		if(is_member($prefix['groups']) || $prefix['pid'] == $previous_pid)
{
// The current user can use this prefix
$prefixes[$prefix['pid']] = $prefix;

		}
}


		}
}


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

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

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

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

		}
}


		}
}


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

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

Zeile 3856Zeile 3980
			if(function_exists("gzencode"))
{
$contents = gzencode($contents, $level);

			if(function_exists("gzencode"))
{
$contents = gzencode($contents, $level);

			}

			}

			else
{
$size = strlen($contents);

			else
{
$size = strlen($contents);

Zeile 3902Zeile 4026
	{
$pid = (int)$data['pid'];
unset($data['pid']);

	{
$pid = (int)$data['pid'];
unset($data['pid']);

	}

	}


$tids = array();
if(isset($data['tids']))


$tids = array();
if(isset($data['tids']))

Zeile 3929Zeile 4053
	);

if($tids)

	);

if($tids)

	{

	{

		$multiple_sql_array = array();

foreach($tids as $tid)

		$multiple_sql_array = array();

foreach($tids as $tid)

Zeile 3956Zeile 4080
function get_reputation($reputation, $uid=0)
{
global $theme, $templates;

function get_reputation($reputation, $uid=0)
{
global $theme, $templates;





	$display_reputation = $reputation_class = '';
if($reputation < 0)

	$display_reputation = $reputation_class = '';
if($reputation < 0)

	{

	{

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

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

	}

	}

	else
{
$reputation_class = "reputation_neutral";
}

	else
{
$reputation_class = "reputation_neutral";
}





	$reputation = my_number_format($reputation);

if($uid != 0)

	$reputation = my_number_format($reputation);

if($uid != 0)

	{

	{

		eval("\$display_reputation = \"".$templates->get("postbit_reputation_formatted_link")."\";");
}
else

		eval("\$display_reputation = \"".$templates->get("postbit_reputation_formatted_link")."\";");
}
else

Zeile 4001Zeile 4125
		$warning_class = "high_warning";
}
else if($level >= 50)

		$warning_class = "high_warning";
}
else if($level >= 50)

	{

	{

		$warning_class = "moderate_warning";

		$warning_class = "moderate_warning";

	}

	}

	else if($level >= 25)

	else if($level >= 25)

	{

	{

		$warning_class = "low_warning";
}
else

		$warning_class = "low_warning";
}
else

	{

	{

		$warning_class = "normal_warning";
}


		$warning_class = "normal_warning";
}


Zeile 4027Zeile 4151
	global $mybb, $plugins;

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

	global $mybb, $plugins;

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





	if($mybb->settings['ip_forwarded_check'])
{
$addresses = array();

	if($mybb->settings['ip_forwarded_check'])
{
$addresses = array();

Zeile 4035Zeile 4159
		if(isset($_SERVER['HTTP_X_FORWARDED_FOR']))
{
$addresses = explode(',', strtolower($_SERVER['HTTP_X_FORWARDED_FOR']));

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

		}

		}

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

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

Zeile 4053Zeile 4177
					break;
}
}

					break;
}
}

		}
}

		}
}


if(!$ip)
{


if(!$ip)
{

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

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

	}


	}


	if($plugins)
{
$ip_array = array("ip" => &$ip); // Used for backwards compatibility on this hook with the updated run_hooks() function.
$plugins->run_hooks("get_ip", $ip_array);
}

	if($plugins)
{
$ip_array = array("ip" => &$ip); // Used for backwards compatibility on this hook with the updated run_hooks() function.
$plugins->run_hooks("get_ip", $ip_array);
}





	return $ip;

	return $ip;

}

/**

}

/**

 * Fetch the friendly size (GB, MB, KB, B) for a specified file size.
*
* @param int $size The size in bytes

 * Fetch the friendly size (GB, MB, KB, B) for a specified file size.
*
* @param int $size The size in bytes

Zeile 4217Zeile 4341
				$attach_icons_schemes[$ext] = str_replace("{theme}", $theme['imgdir'], $attachtypes[$ext]['icon']);
$attach_icons_schemes[$ext] = $mybb->get_asset_url($attach_icons_schemes[$ext]);
}

				$attach_icons_schemes[$ext] = str_replace("{theme}", $theme['imgdir'], $attachtypes[$ext]['icon']);
$attach_icons_schemes[$ext] = $mybb->get_asset_url($attach_icons_schemes[$ext]);
}

		}


		}


		$icon = $attach_icons_schemes[$ext];

$name = htmlspecialchars_uni($attachtypes[$ext]['name']);

		$icon = $attach_icons_schemes[$ext];

$name = htmlspecialchars_uni($attachtypes[$ext]['name']);

Zeile 4236Zeile 4360
		}

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

		}

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





		$name = $lang->unknown;
}


		$name = $lang->unknown;
}


Zeile 4254Zeile 4378
function get_unviewable_forums($only_readable_threads=false)
{
global $forum_cache, $permissioncache, $mybb;

function get_unviewable_forums($only_readable_threads=false)
{
global $forum_cache, $permissioncache, $mybb;





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

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

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']])
{
$perms = $permissioncache[$forum['fid']];

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

		}
else
{

		}
else
{

			$perms = $mybb->usergroup;
}

			$perms = $mybb->usergroup;
}





		$pwverified = 1;


		$pwverified = 1;


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

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


if(!forum_password_validated($forum, true))
{
$pwverified = 0;





		}
else
{

		}
else
{

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

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']);
}
else if(isset($_ENV['QUERY_STRING']))
{
$location .= "?".htmlspecialchars_uni($_ENV['QUERY_STRING']);
}














		{
$current_query_string = $_SERVER['QUERY_STRING'];
}
else if(isset($_ENV['QUERY_STRING']))
{
$current_query_string = $_ENV['QUERY_STRING'];
} else
{
$current_query_string = '';
}

parse_str($current_query_string, $current_parameters);

foreach($current_parameters as $name => $value)
{
if(!in_array($name, $ignore))
{
$parameters[$name] = $value;
}
}





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

		if($mybb->request_method === 'post')

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

foreach($post_array as $var)
{

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

foreach($post_array as $var)
{

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

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

				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 5194Zeile 5306
		if(!isset($lang->use_default))
{
$lang->use_default = $lang->lang_select_default;

		if(!isset($lang->use_default))
{
$lang->use_default = $lang->lang_select_default;

		}
}

		}
}


if(!is_array($tcache))
{


if(!is_array($tcache))
{

Zeile 5218Zeile 5330
				if($theme['tid'] == $selected)
{
$sel = " selected=\"selected\"";

				if($theme['tid'] == $selected)
{
$sel = " selected=\"selected\"";

				}


				}


				if($theme['pid'] != 0)
{
$theme['name'] = htmlspecialchars_uni($theme['name']);

				if($theme['pid'] != 0)
{
$theme['name'] = htmlspecialchars_uni($theme['name']);

Zeile 5514Zeile 5626
		$lang->thursday,
$lang->friday,
$lang->saturday

		$lang->thursday,
$lang->friday,
$lang->saturday

	);


	);


	$bmonth = array(
$lang->month_1,
$lang->month_2,

	$bmonth = array(
$lang->month_1,
$lang->month_2,

Zeile 5562Zeile 5674

$bdays = str_replace($find, $html, $bdays);
$bmonth = str_replace($find, $html, $bmonth);


$bdays = str_replace($find, $html, $bdays);
$bmonth = str_replace($find, $html, $bmonth);





	$replace = array(
sprintf('%02s', $bm),
$bm,

	$replace = array(
sprintf('%02s', $bm),
$bm,

Zeile 5586Zeile 5698
	}

return str_replace($find, $replace, $display);

	}

return str_replace($find, $replace, $display);

}

}


/**
* Returns the age of a user with specified birthday.


/**
* Returns the age of a user with specified birthday.

Zeile 5598Zeile 5710
{
$bday = explode("-", $birthday);
if(!$bday[2])

{
$bday = explode("-", $birthday);
if(!$bday[2])

	{

	{

		return;

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

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

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

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

Zeile 5611Zeile 5723
		--$age;
}
return $age;

		--$age;
}
return $age;

}

/**

}

/**

 * Updates the first posts in a thread.
*
* @param int $tid The thread id for which to update the first post id.

 * Updates the first posts in a thread.
*
* @param int $tid The thread id for which to update the first post id.

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 5809Zeile 5948
function my_strpos($haystack, $needle, $offset=0)
{
if($needle == '')

function my_strpos($haystack, $needle, $offset=0)
{
if($needle == '')

	{
return false;

	{
return false;

	}

if(function_exists("mb_strpos"))

	}

if(function_exists("mb_strpos"))

Zeile 6067Zeile 6206
		{
$link = THREAD_URL_ACTION;
$link = str_replace("{action}", $action, $link);

		{
$link = THREAD_URL_ACTION;
$link = str_replace("{action}", $action, $link);

		}

		}

		else
{
$link = THREAD_URL;

		else
{
$link = THREAD_URL;

Zeile 6095Zeile 6234
	else
{
$link = str_replace("{pid}", $pid, POST_URL);

	else
{
$link = str_replace("{pid}", $pid, POST_URL);

		return htmlspecialchars_uni($link);
}
}


		return htmlspecialchars_uni($link);
}
}


/**
* Build the event link.
*

/**
* Build the event link.
*

Zeile 6113Zeile 6252

/**
* Build the link to a specified date on the calendar


/**
* Build the link to a specified date on the calendar

 *
* @param int $calendar The ID of the calendar

 *
* @param int $calendar The ID of the calendar

 * @param int $year The year
* @param int $month The month
* @param int $day The day (optional)

 * @param int $year The year
* @param int $month The month
* @param int $day The day (optional)

Zeile 6145Zeile 6284
	{
$link = str_replace("{calendar}", $calendar, CALENDAR_URL);
return htmlspecialchars_uni($link);

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

	}
}

	}
}


/**
* Build the link to a specified week on the calendar


/**
* Build the link to a specified week on the calendar

Zeile 6178Zeile 6317
	static $user_cache;

$uid = (int)$uid;

	static $user_cache;

$uid = (int)$uid;





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

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

	{

	{

		return $mybb->user;

		return $mybb->user;

	}

	}

	elseif(isset($user_cache[$uid]))

	elseif(isset($user_cache[$uid]))

	{
return $user_cache[$uid];
}

	{
return $user_cache[$uid];
}

	elseif($uid > 0)
{
$query = $db->simple_select("users", "*", "uid = '{$uid}'");

	elseif($uid > 0)
{
$query = $db->simple_select("users", "*", "uid = '{$uid}'");

Zeile 6195Zeile 6334
		return $user_cache[$uid];
}
return array();

		return $user_cache[$uid];
}
return array();

}


}


/**
* Get the user data of an user username.
*

/**
* Get the user data of an user username.
*

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 6277Zeile 6416
	if(empty($forum_cache[$fid]))
{
return false;

	if(empty($forum_cache[$fid]))
{
return false;

	}


	}


	if($active_override != 1)
{
$parents = explode(",", $forum_cache[$fid]['parentlist']);

	if($active_override != 1)
{
$parents = explode(",", $forum_cache[$fid]['parentlist']);

Zeile 6292Zeile 6431
				}
}
}

				}
}
}

	}


	}


	return $forum_cache[$fid];
}


	return $forum_cache[$fid];
}


Zeile 6324Zeile 6463
		{
$thread_cache[$tid] = $thread;
return $thread;

		{
$thread_cache[$tid] = $thread;
return $thread;

		}
else

		}
else

		{
$thread_cache[$tid] = false;
return false;

		{
$thread_cache[$tid] = false;
return false;

Zeile 6364Zeile 6503
		{
$post_cache[$pid] = false;
return false;

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

		}
}

		}
}

}

}





/**
* Get inactivate forums.
*

/**
* Get inactivate forums.
*

Zeile 6378Zeile 6517
	global $forum_cache, $cache;

if(!$forum_cache)

	global $forum_cache, $cache;

if(!$forum_cache)

	{

	{

		cache_forums();
}


		cache_forums();
}


Zeile 6417Zeile 6556
	$attempts = array();
$uid = (int)$uid;
$now = TIME_NOW;

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





	// Get this user's login attempts and eventual lockout, if a uid is provided
if($uid > 0)
{

	// Get this user's login attempts and eventual lockout, if a uid is provided
if($uid > 0)
{

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

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

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 6505Zeile 6644

// User can attempt another login
return $attempts['loginattempts'];


// User can attempt another login
return $attempts['loginattempts'];

}

}


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


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

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

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

}

}


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


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

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

Zeile 6710Zeile 6851
	$dest = '';

if($src < 0)

	$dest = '';

if($src < 0)

	{
return false;
}

	{
return false;
}

	elseif($src <= 0x007f)
{
$dest .= chr($src);

	elseif($src <= 0x007f)
{
$dest .= chr($src);

Zeile 6742Zeile 6883
	}

return $dest;

	}

return $dest;

}

/**

}

/**

 * Checks if a username has been disallowed for registration/use.
*
* @param string $username The username

 * Checks if a username has been disallowed for registration/use.
*
* @param string $username The username

Zeile 6760Zeile 6901
		// Make regular expression * match
$banned_username['filter'] = str_replace('\*', '(.*)', preg_quote($banned_username['filter'], '#'));
if(preg_match("#(^|\b){$banned_username['filter']}($|\b)#i", $username))

		// Make regular expression * match
$banned_username['filter'] = str_replace('\*', '(.*)', preg_quote($banned_username['filter'], '#'));
if(preg_match("#(^|\b){$banned_username['filter']}($|\b)#i", $username))

		{

		{

			// Updating last use
if($update_lastuse == true)
{

			// Updating last use
if($update_lastuse == true)
{

Zeile 6791Zeile 6932
		// Failed to read cache, see if we can rebuild it
$cache->update_bannedemails();
$banned_cache = $cache->read("bannedemails");

		// Failed to read cache, see if we can rebuild it
$cache->update_bannedemails();
$banned_cache = $cache->read("bannedemails");

	}


	}


	if(is_array($banned_cache) && !empty($banned_cache))
{
foreach($banned_cache as $banned_email)

	if(is_array($banned_cache) && !empty($banned_cache))
{
foreach($banned_cache as $banned_email)

Zeile 6839Zeile 6980
		if(!$banned_ip['filter'])
{
continue;

		if(!$banned_ip['filter'])
{
continue;

		}


		}


		$banned = false;

$ip_range = fetch_ip_range($banned_ip['filter']);

		$banned = false;

$ip_range = fetch_ip_range($banned_ip['filter']);

Zeile 6922Zeile 7063
		"14" => $lang->timezone_gmt_1400
);
return $timezones;

		"14" => $lang->timezone_gmt_1400
);
return $timezones;

}


}


/**
* Build a time zone selection list.
*

/**
* Build a time zone selection list.
*

Zeile 6955Zeile 7096
				if($timezone > 0)
{
$label = "+{$label}";

				if($timezone > 0)
{
$label = "+{$label}";

				}

				}

				if(strpos($timezone, ".") !== false)
{
$label = str_replace(".", ":", $label);

				if(strpos($timezone, ".") !== false)
{
$label = str_replace(".", ":", $label);

Zeile 6965Zeile 7106
				else
{
$label .= ":00";

				else
{
$label .= ":00";

				}

				}

			}
$time_in_zone = my_date($mybb->settings['timeformat'], TIME_NOW, $timezone);
$label = $lang->sprintf($lang->timezone_gmt_short, $label." ", $time_in_zone);

			}
$time_in_zone = my_date($mybb->settings['timeformat'], TIME_NOW, $timezone);
$label = $lang->sprintf($lang->timezone_gmt_short, $label." ", $time_in_zone);

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 8777Zeile 8931
				'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 8990
/**
* 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 9049
		}
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;

}

}