Vergleich inc/functions.php - 1.8.6 - 1.8.7

  Keine Änderungen   Hinzugefügt   Modifiziert   Entfernt
Zeile 2432Zeile 2432
	// Update stats row for today in the database
$todays_stats = array(
"dateline" => mktime(0, 0, 0, date("m"), date("j"), date("Y")),

	// Update stats row for today in the database
$todays_stats = array(
"dateline" => mktime(0, 0, 0, date("m"), date("j"), date("Y")),

		"numusers" => $stats['numusers'],
"numthreads" => $stats['numthreads'],
"numposts" => $stats['numposts']

		"numusers" => (int)$stats['numusers'],
"numthreads" => (int)$stats['numthreads'],
"numposts" => (int)$stats['numposts']

	);
$db->replace_query("stats", $todays_stats, "dateline");


	);
$db->replace_query("stats", $todays_stats, "dateline");


Zeile 3367Zeile 3367
			}
foreach($smilie_cache as $smilie)
{

			}
foreach($smilie_cache as $smilie)
{

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

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




			}
}

unset($smilie);

			}
}

unset($smilie);





		if(is_array($smiliecache))
{
reset($smiliecache);

		if(is_array($smiliecache))
{
reset($smiliecache);





			$getmore = '';
if($mybb->settings['smilieinsertertot'] >= $smiliecount)
{

			$getmore = '';
if($mybb->settings['smilieinsertertot'] >= $smiliecount)
{

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

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

				if($i < $mybb->settings['smilieinsertertot'])

				if($i < $mybb->settings['smilieinsertertot'] && $smilie['showclickable'] != 0)

				{
if($counter == 0)
{
$smilies .= "<tr>\n";

				{
if($counter == 0)
{
$smilies .= "<tr>\n";

					}


					}


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

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

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

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

		}


		}


		return $prefixes_cache;
}


		return $prefixes_cache;
}


Zeile 3505Zeile 3502
}

/**

}

/**

 * Build the thread prefix selection menu

 * Build the thread prefix selection menu for the current user

 *
* @param int|string $fid The forum ID (integer ID or string all)
* @param int|string $selected_pid The selected prefix ID (integer ID or string any)
* @param int $multiple Allow multiple prefix selection

 *
* @param int|string $fid The forum ID (integer ID or string all)
* @param int|string $selected_pid The selected prefix ID (integer ID or string any)
* @param int $multiple Allow multiple prefix selection

 
 *  @param int $previous_pid The previously selected prefix ID

 *  @return string The thread prefix selection menu
*/

 *  @return string The thread prefix selection menu
*/

function build_prefix_select($fid, $selected_pid=0, $multiple=0)

function build_prefix_select($fid, $selected_pid=0, $multiple=0, $previous_pid=0)

{
global $cache, $db, $lang, $mybb, $templates;


{
global $cache, $db, $lang, $mybb, $templates;


Zeile 3524Zeile 3522
	$prefix_cache = build_prefixes(0);
if(empty($prefix_cache))
{

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

		return false; // We've got no prefixes to show
}

$groups = array($mybb->user['usergroup']);
if($mybb->user['additionalgroups'])
{
$exp = explode(",", $mybb->user['additionalgroups']);

foreach($exp as $group)
{
$groups[] = $group;
}

		// We've got no prefixes to show
return '';











	}

// Go through each of our prefixes and decide which ones we can use

	}

// Go through each of our prefixes and decide which ones we can use

Zeile 3543Zeile 3531
	foreach($prefix_cache as $prefix)
{
if($fid != "all" && $prefix['forums'] != "-1")

	foreach($prefix_cache as $prefix)
{
if($fid != "all" && $prefix['forums'] != "-1")

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

if(!in_array($fid, $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;

				// This prefix is not in our forum list
continue;

			}

			}

		}

		}


if($prefix['groups'] != "-1")
{
$prefix_groups = explode(",", $prefix['groups']);

foreach($groups as $group)
{
if(in_array($group, $prefix_groups) && !isset($prefixes[$prefix['pid']]))
{
// Our group can use this prefix!
$prefixes[$prefix['pid']] = $prefix;
}
}
}
else


if(is_member($prefix['groups']) || $prefix['pid'] == $previous_pid)














		{

		{

			// This prefix is for anybody to use...

			// The current user can use this prefix

			$prefixes[$prefix['pid']] = $prefix;

			$prefixes[$prefix['pid']] = $prefix;

		}

		}

	}

if(empty($prefixes))

	}

if(empty($prefixes))

	{
return false;

	{
return '';

	}

$prefixselect = $prefixselect_prefix = '';

	}

$prefixselect = $prefixselect_prefix = '';

Zeile 3592Zeile 3567

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


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

	{
$default_selected = " selected=\"selected\"";
}

foreach($prefixes as $prefix)

	{
$default_selected = " selected=\"selected\"";
}

foreach($prefixes as $prefix)

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

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

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

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

	}

	}

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

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

Zeile 3621Zeile 3596
}

/**

}

/**

 * Build the thread prefix selection menu for a forum

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

 *
* @param int $fid The forum ID (integer ID)
* @param int $selected_pid The selected prefix ID (integer ID)

 *
* @param int $fid The forum ID (integer ID)
* @param int $selected_pid The selected prefix ID (integer ID)

 
 *  @return string The thread prefix selection menu

 */
function build_forum_prefix_select($fid, $selected_pid=0)
{

 */
function build_forum_prefix_select($fid, $selected_pid=0)
{

Zeile 3635Zeile 3611
	$prefix_cache = build_prefixes(0);
if(empty($prefix_cache))
{

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

		return false; // We've got no prefixes to show


		// We've got no prefixes to show
return '';

	}

// Go through each of our prefixes and decide which ones we can use

	}

// Go through each of our prefixes and decide which ones we can use

Zeile 3662Zeile 3639

if(empty($prefixes))
{


if(empty($prefixes))
{

		return false;

		return '';

	}

$default_selected = array();

	}

$default_selected = array();

Zeile 4555Zeile 4532
		header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
header("Cache-Control: no-cache, must-revalidate");
header("Pragma: no-cache");

		header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
header("Cache-Control: no-cache, must-revalidate");
header("Pragma: no-cache");

	}
}

/**

	}
}

/**

 * Mark specific reported posts of a certain type as dealt with
*
* @param array|int $id An array or int of the ID numbers you're marking as dealt with

 * Mark specific reported posts of a certain type as dealt with
*
* @param array|int $id An array or int of the ID numbers you're marking as dealt with

Zeile 4700Zeile 4677
	}

if($days == 1)

	}

if($days == 1)

	{

	{

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

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

Zeile 4717Zeile 4694
		else if($hours > 1)
{
$nicetime['hours'] = $hours.$lang_hours;

		else if($hours > 1)
{
$nicetime['hours'] = $hours.$lang_hours;

		}

		}

	}

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

	}

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

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

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

		{

		{

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

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

Zeile 4772Zeile 4749
	$alttrow = $trow;

return $trow;

	$alttrow = $trow;

return $trow;

}


}


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

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

Zeile 4782Zeile 4759
 * @return bool
*/
function join_usergroup($uid, $joingroup)

 * @return bool
*/
function join_usergroup($uid, $joingroup)

{

{

	global $db, $mybb;

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

	global $db, $mybb;

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

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

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





	if(is_array($groups))
{
$comma = '';

	if(is_array($groups))
{
$comma = '';

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

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


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


$user = get_user($uid);









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


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





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

if(is_array($groups))

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

if(is_array($groups))

	{

	{

		foreach($groups as $gid)
{
if(trim($gid) != "" && $leavegroup != $gid && empty($donegroup[$gid]))

		foreach($groups as $gid)
{
if(trim($gid) != "" && $leavegroup != $gid && empty($donegroup[$gid]))

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

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

	}

	}

	elseif(!empty($_SERVER['PHP_SELF']))
{
$location = htmlspecialchars_uni($_SERVER['PHP_SELF']);

	elseif(!empty($_SERVER['PHP_SELF']))
{
$location = htmlspecialchars_uni($_SERVER['PHP_SELF']);

Zeile 4926Zeile 4896
		global $mybb;

if(!is_array($ignore))

		global $mybb;

if(!is_array($ignore))

		{

		{

			$ignore = array($ignore);
}


			$ignore = array($ignore);
}


Zeile 5145Zeile 5115
	if($number == "-")
{
return $number;

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

	}

	}


if(is_int($number))
{


if(is_int($number))
{

Zeile 6315Zeile 6285
	}
// Valid local characters for email addresses: http://www.remote.org/jochen/mail/info/chars.html
return preg_match("/^[a-zA-Z0-9&*+\-_.{}~^\?=\/]+@[a-zA-Z0-9-]+\.([a-zA-Z0-9-]+\.)*[a-zA-Z0-9-]{2,}$/si", $email);

	}
// Valid local characters for email addresses: http://www.remote.org/jochen/mail/info/chars.html
return preg_match("/^[a-zA-Z0-9&*+\-_.{}~^\?=\/]+@[a-zA-Z0-9-]+\.([a-zA-Z0-9-]+\.)*[a-zA-Z0-9-]{2,}$/si", $email);

}

/**

}

/**

 * Checks to see if the email is already in use by another
*
* @param string $email The email to check.

 * Checks to see if the email is already in use by another
*
* @param string $email The email to check.

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

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





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

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

Zeile 6336Zeile 6306
	$query = $db->simple_select("users", "COUNT(email) as emails", "email = '".$db->escape_string($email)."'{$uid_string}");

if($db->fetch_field($query, "emails") > 0)

	$query = $db->simple_select("users", "COUNT(email) as emails", "email = '".$db->escape_string($email)."'{$uid_string}");

if($db->fetch_field($query, "emails") > 0)

	{

	{

		return true;
}

		return true;
}





	return false;
}

/**
* Rebuilds settings.php

	return false;
}

/**
* Rebuilds settings.php

 *

 *

 */
function rebuild_settings()
{

 */
function rebuild_settings()
{

Zeile 6354Zeile 6324
	if(!file_exists(MYBB_ROOT."inc/settings.php"))
{
$mode = "x";

	if(!file_exists(MYBB_ROOT."inc/settings.php"))
{
$mode = "x";

	}

	}

	else
{
$mode = "w";

	else
{
$mode = "w";

Zeile 6373Zeile 6343
		$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 = @fopen(MYBB_ROOT."inc/settings.php", $mode);
@fwrite($file, $settings);

	$settings = "<"."?php\n/*********************************\ \n  DO NOT EDIT THIS FILE, PLEASE USE\n  THE SETTINGS EDITOR\n\*********************************/\n\n$settings\n";
$file = @fopen(MYBB_ROOT."inc/settings.php", $mode);
@fwrite($file, $settings);

Zeile 6389Zeile 6359
 * @return array PREG compatible array of terms
*/
function build_highlight_array($terms)

 * @return array PREG compatible array of terms
*/
function build_highlight_array($terms)

{
global $mybb;


{
global $mybb;


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

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

Zeile 6424Zeile 6394
			if($phrase != "")
{
if($inquote)

			if($phrase != "")
{
if($inquote)

				{

				{

					$words[] = trim($phrase);
}
else

					$words[] = trim($phrase);
}
else

Zeile 6433Zeile 6403
					if(!is_array($split_words))
{
continue;

					if(!is_array($split_words))
{
continue;

					}

					}

					foreach($split_words as $word)
{
if(!$word || strlen($word) < $mybb->settings['minsearchword'])

					foreach($split_words as $word)
{
if(!$word || strlen($word) < $mybb->settings['minsearchword'])

Zeile 6442Zeile 6412
						}
$words[] = trim($word);
}

						}
$words[] = trim($word);
}

				}

				}

			}
$inquote = !$inquote;
}

			}
$inquote = !$inquote;
}

Zeile 6461Zeile 6431
					continue;
}
$words[] = trim($word);

					continue;
}
$words[] = trim($word);

			}
}
}


			}
}
}


	if(!is_array($words))
{
return false;

	if(!is_array($words))
{
return false;

Zeile 6491Zeile 6461
		$find = "#(?!<.*?)(".preg_quote($word, "#").")(?![^<>]*?>)#ui";
$replacement = "<span class=\"highlight\" style=\"padding-left: 0px; padding-right: 0px;\">$1</span>";
$highlight_cache[$find] = $replacement;

		$find = "#(?!<.*?)(".preg_quote($word, "#").")(?![^<>]*?>)#ui";
$replacement = "<span class=\"highlight\" style=\"padding-left: 0px; padding-right: 0px;\">$1</span>";
$highlight_cache[$find] = $replacement;

	}


	}


	return $highlight_cache;
}


	return $highlight_cache;
}


Zeile 6510Zeile 6480
	if($src < 0)
{
return false;

	if($src < 0)
{
return false;

	}

	}

	elseif($src <= 0x007f)

	elseif($src <= 0x007f)

	{

	{

		$dest .= chr($src);

		$dest .= chr($src);

	}

	}

	elseif($src <= 0x07ff)
{
$dest .= chr(0xc0 | ($src >> 6));

	elseif($src <= 0x07ff)
{
$dest .= chr(0xc0 | ($src >> 6));

		$dest .= chr(0x80 | ($src & 0x003f));
}

		$dest .= chr(0x80 | ($src & 0x003f));
}

	elseif($src <= 0xffff)
{
$dest .= chr(0xe0 | ($src >> 12));

	elseif($src <= 0xffff)
{
$dest .= chr(0xe0 | ($src >> 12));

Zeile 6536Zeile 6506
	else
{
// Out of range

	else
{
// Out of range

		return false;
}

		return false;
}


return $dest;
}


return $dest;
}

Zeile 6757Zeile 6727
					$label = str_replace(".", ":", $label);
$label = str_replace(":5", ":30", $label);
$label = str_replace(":75", ":45", $label);

					$label = str_replace(".", ":", $label);
$label = str_replace(":5", ":30", $label);
$label = str_replace(":75", ":45", $label);

				}

				}

				else
{
$label .= ":00";

				else
{
$label .= ":00";

Zeile 6768Zeile 6738
		}

eval("\$timezone_option .= \"".$templates->get("usercp_options_timezone_option")."\";");

		}

eval("\$timezone_option .= \"".$templates->get("usercp_options_timezone_option")."\";");

	}


	}


	eval("\$select = \"".$templates->get("usercp_options_timezone")."\";");
return $select;
}

	eval("\$select = \"".$templates->get("usercp_options_timezone")."\";");
return $select;
}

Zeile 6779Zeile 6749
 *
* @param string $url The URL of the remote file
* @param array $post_data The array of post data

 *
* @param string $url The URL of the remote file
* @param array $post_data The array of post data

 
 * @param int $max_redirects Number of maximum redirects

 * @return string|bool The remote file contents. False on failure
*/

 * @return string|bool The remote file contents. False on failure
*/

function fetch_remote_file($url, $post_data=array())

function fetch_remote_file($url, $post_data=array(), $max_redirects=20)

{

{

 
	global $mybb;


	$post_body = '';
if(!empty($post_data))
{
foreach($post_data as $key => $val)

	$post_body = '';
if(!empty($post_data))
{
foreach($post_data as $key => $val)

		{

		{

			$post_body .= '&'.urlencode($key).'='.urlencode($val);
}
$post_body = ltrim($post_body, '&');
}

			$post_body .= '&'.urlencode($key).'='.urlencode($val);
}
$post_body = ltrim($post_body, '&');
}





	if(function_exists("curl_init"))
{

	if(function_exists("curl_init"))
{

 
		$can_followlocation = @ini_get('open_basedir') === '' && !$mybb->safemode;

$request_header = $max_redirects != 0 && !$can_followlocation;


		$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);

		$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);

		curl_setopt($ch, CURLOPT_HEADER, 0);

		curl_setopt($ch, CURLOPT_HEADER, $request_header);

		curl_setopt($ch, CURLOPT_TIMEOUT, 10);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

		curl_setopt($ch, CURLOPT_TIMEOUT, 10);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

		curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);








		curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);

if($max_redirects != 0 && $can_followlocation)
{
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_MAXREDIRS, $max_redirects);
}


		if(!empty($post_body))

		if(!empty($post_body))

		{

		{

			curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_body);
}

			curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_body);
}

		$data = curl_exec($ch);





























$response = curl_exec($ch);

if($request_header)
{
$header_size = curl_getinfo($ch, CURLINFO_HEADER_SIZE);
$header = substr($response, 0, $header_size);
$body = substr($response, $header_size);

if(in_array(curl_getinfo($ch, CURLINFO_HTTP_CODE), array(301, 302)))
{
preg_match('/Location:(.*?)(?:\n|$)/', $header, $matches);

if($matches)
{
$data = fetch_remote_file(trim(array_pop($matches)), $post_data, --$max_redirects);
}
}
else
{
$data = $body;
}
}
else
{
$data = $response;
}


		curl_close($ch);
return $data;
}

		curl_close($ch);
return $data;
}

Zeile 6817Zeile 6828
		{
return false;
}

		{
return false;
}

		if(!$url['port'])

		if(!isset($url['port']))

		{
$url['port'] = 80;
}

		{
$url['port'] = 80;
}

		if(!$url['path'])

		if(!isset($url['path']))

		{
$url['path'] = "/";
}

		{
$url['path'] = "/";
}

		if($url['query'])

		if(isset($url['query']))

		{
$url['path'] .= "?{$url['query']}";
}

		{
$url['path'] .= "?{$url['query']}";
}

Zeile 6878Zeile 6889
		{
return false;
}

		{
return false;
}

 

$data = null;


		while(!feof($fp))
{
$data .= fgets($fp, 12800);
}
fclose($fp);

		while(!feof($fp))
{
$data .= fgets($fp, 12800);
}
fclose($fp);

 


		$data = explode("\r\n\r\n", $data, 2);

		$data = explode("\r\n\r\n", $data, 2);

		return $data[1];





















$header = $data[0];
$status_line = current(explode("\n\n", $header, 1));
$body = $data[1];

if($max_redirects != 0 && (strstr($status_line, ' 301 ') || strstr($status_line, ' 302 ')))
{
preg_match('/Location:(.*?)(?:\n|$)/', $header, $matches);

if($matches)
{
$data = fetch_remote_file(trim(array_pop($matches)), $post_data, --$max_redirects);
}
}
else
{
$data = $body;
}

return $data;

	}
else if(empty($post_data))

	}
else if(empty($post_data))

	{

	{

		return @implode("", @file($url));
}
else

		return @implode("", @file($url));
}
else

	{

	{

		return false;
}
}

		return false;
}
}





/**
* Checks if a particular user is a super administrator.
*

/**
* Checks if a particular user is a super administrator.
*

Zeile 6910Zeile 6944
	{
global $mybb;
$super_admins = str_replace(" ", "", $mybb->config['super_admins']);

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

	}


	}


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

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

	{

	{

		return false;

		return false;

	}

	}

	else
{
return true;

	else
{
return true;

	}
}


	}
}


/**
* Checks if a user is a member of a particular group
* Originates from frostschutz's PluginLibrary

/**
* Checks if a user is a member of a particular group
* Originates from frostschutz's PluginLibrary

Zeile 6938Zeile 6972
	if(empty($groups))
{
return array();

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

	}


	}


	if($user == false)

	if($user == false)

	{

	{

		$user = $mybb->user;
}
else if(!is_array($user))
{
// Assume it's a UID
$user = get_user($user);

		$user = $mybb->user;
}
else if(!is_array($user))
{
// Assume it's a UID
$user = get_user($user);

	}

	}


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


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

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

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

		}

		}

		else
{
if(is_string($groups))

		else
{
if(is_string($groups))

Zeile 6985Zeile 7019
 * @param string $string The string to split
* @param string $escape The escape character or string if we have one.
* @return array Array of split string

 * @param string $string The string to split
* @param string $escape The escape character or string if we have one.
* @return array Array of split string

 */

 */

function escaped_explode($delimeter, $string, $escape="")
{
$strings = array();

function escaped_explode($delimeter, $string, $escape="")
{
$strings = array();

Zeile 7203Zeile 7237
	if(!isset($orig_dir))
{
$orig_dir = $path;

	if(!isset($orig_dir))
{
$orig_dir = $path;

	}


	}


	if(@is_dir($path) && !@is_link($path))
{
if($dh = @opendir($path))

	if(@is_dir($path) && !@is_link($path))
{
if($dh = @opendir($path))

Zeile 7223Zeile 7257
		if($path == $orig_dir)
{
return true;

		if($path == $orig_dir)
{
return true;

		}

		}


return @rmdir($path);
}


return @rmdir($path);
}

Zeile 7241Zeile 7275
{
$count = 0;
foreach($array as $array2)

{
$count = 0;
foreach($array as $array2)

	{

	{

		$count += count($array2);
}


		$count += count($array2);
}


Zeile 7260Zeile 7294
function my_ip2long($ip)
{
$ip_long = ip2long($ip);

function my_ip2long($ip)
{
$ip_long = ip2long($ip);





	if(!$ip_long)
{
$ip_long = sprintf("%u", ip2long($ip));

	if(!$ip_long)
{
$ip_long = sprintf("%u", ip2long($ip));

Zeile 7269Zeile 7303
		{
return 0;
}

		{
return 0;
}

	}


	}


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

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





	return $ip_long;

	return $ip_long;

}


}


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

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

Zeile 7294Zeile 7328
	{
// We have a 64-bit system
$long += 4294967296;

	{
// We have a 64-bit system
$long += 4294967296;

	}

	}

	return long2ip($long);
}


	return long2ip($long);
}


Zeile 7348Zeile 7382
		$r = call_user_func_array('pack', $r);

return $r;

		$r = call_user_func_array('pack', $r);

return $r;

	}
}

/**

	}
}

/**

 * Converts a packed internet address to a human readable representation
*
* @param string $ip IP in 32bit or 128bit binary format

 * Converts a packed internet address to a human readable representation
*
* @param string $ip IP in 32bit or 128bit binary format

Zeile 7497Zeile 7531
			$chr = substr($ip_higher_bits, $i, 8);
$chr = chr( bindec($chr) );
$ip_higher_pack .= $chr;

			$chr = substr($ip_higher_bits, $i, 8);
$chr = chr( bindec($chr) );
$ip_higher_pack .= $chr;

		}

		}


return array($ip_lower_pack, $ip_higher_pack);


return array($ip_lower_pack, $ip_higher_pack);

	}

	}

	// Just on IP address
else
{
return my_inet_pton($ipaddress);

	// Just on IP address
else
{
return my_inet_pton($ipaddress);

	}
}

	}
}


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


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

Zeile 7533Zeile 7567
		if($total < 0) $total = 0;
$time_start = 0;
return $total;

		if($total < 0) $total = 0;
$time_start = 0;
return $total;

	}

	}

}

/**

}

/**

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

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

				{
continue;

				{
continue;

				}

// Recurse through the directory tree

				}

// Recurse through the directory tree

Zeile 7607Zeile 7641
				unset($checksums[$file_path]);
}
@closedir($dh);

				unset($checksums[$file_path]);
}
@closedir($dh);

		}
}

		}
}


if($count == 0)
{


if($count == 0)
{

Zeile 7643Zeile 7677
	if($int < 0)
{
return "$int";

	if($int < 0)
{
return "$int";

	}
else

	}
else

	{
return "+$int";

	{
return "+$int";

	}
}

/**
* Returns a securely generated seed for PHP's RNG (Random Number Generator)
*
* @param int $count Length of the seed bytes (8 is default. Provides good cryptographic variance)
* @return int An integer equivalent of a secure hexadecimal seed
*/
function secure_seed_rng($count=8)
{
$output = '';
// DIRECTORY_SEPARATOR checks if running windows
if(DIRECTORY_SEPARATOR != '\\')
{
// Unix/Linux
// Use OpenSSL when available
if(function_exists('openssl_random_pseudo_bytes'))
{
$output = openssl_random_pseudo_bytes($count);
}
// Try mcrypt
elseif(function_exists('mcrypt_create_iv'))

	}
}

/**
* Returns a securely generated seed
*
* @return string A secure binary seed
*/
function secure_binary_seed_rng($bytes)
{
$output = null;

if(version_compare(PHP_VERSION, '7.0', '>='))
{
try









		{

		{

			$output = mcrypt_create_iv($count, MCRYPT_DEV_URANDOM);


			$output = random_bytes($bytes);
} catch (Exception $e) {

		}

		}

		// Try /dev/urandom
elseif(@is_readable('/dev/urandom') && ($handle = @fopen('/dev/urandom', 'rb')))




	}

if(strlen($output) < $bytes)
{
if(@is_readable('/dev/urandom') && ($handle = @fopen('/dev/urandom', 'rb')))

		{

		{

			$output = @fread($handle, $count);

			$output = @fread($handle, $bytes);

			@fclose($handle);

			@fclose($handle);

		}
}
else
{
// Windows
// Use OpenSSL when available
// PHP <5.3.4 had a bug which makes that function unusable on Windows
if(function_exists('openssl_random_pseudo_bytes') && version_compare(PHP_VERSION, '5.3.4', '>='))
























		}
}
else
{
return $output;
}

if(strlen($output) < $bytes)
{
if(function_exists('mcrypt_create_iv'))
{
if (DIRECTORY_SEPARATOR == '/')
{
$source = MCRYPT_DEV_URANDOM;
}
else
{
$source = MCRYPT_RAND;
}

$output = @mcrypt_create_iv($bytes, $source);
}
}
else
{
return $output;
}

if(strlen($output) < $bytes)
{
if(function_exists('openssl_random_pseudo_bytes'))

		{

		{

			$output = openssl_random_pseudo_bytes($count);









			// PHP <5.3.4 had a bug which makes that function unusable on Windows
if ((DIRECTORY_SEPARATOR == '/') || version_compare(PHP_VERSION, '5.3.4', '>='))
{
$output = openssl_random_pseudo_bytes($bytes, $crypto_strong);
if ($crypto_strong == false)
{
$output = null;
}
}

		}

		}

		// Try mcrypt
elseif(function_exists('mcrypt_create_iv'))
{
$output = mcrypt_create_iv($count, MCRYPT_RAND);
}
// Try Windows CAPICOM before using our own generator
elseif(class_exists('COM'))



	}
else
{
return $output;
}

if(strlen($output) < $bytes)
{
if(class_exists('COM'))

		{
try
{
$CAPI_Util = new COM('CAPICOM.Utilities.1');
if(is_callable(array($CAPI_Util, 'GetRandom')))
{

		{
try
{
$CAPI_Util = new COM('CAPICOM.Utilities.1');
if(is_callable(array($CAPI_Util, 'GetRandom')))
{

					$output = $CAPI_Util->GetRandom($count, 0);

					$output = $CAPI_Util->GetRandom($bytes, 0);

				}
} catch (Exception $e) {
}

				}
} catch (Exception $e) {
}

		}
}





		}
}
else
{
return $output;
}





	// Didn't work? Do we still not have enough bytes? Use our own (less secure) rng generator
if(strlen($output) < $count)

	if(strlen($output) < $bytes)


	{

	{

		$output = '';


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


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


		for($i = 0; $i < $count; $i += 16)



		$rounds = ceil($bytes / 16);

for($i = 0; $i < $rounds; $i++)

		{
$unique_state = md5(microtime().$unique_state);

		{
$unique_state = md5(microtime().$unique_state);

			$output .= pack('H*', md5($unique_state));
}
}

// /dev/urandom and openssl will always be twice as long as $count. base64_encode will roughly take up 33% more space but crc32 will put it to 32 characters
$output = hexdec(substr(dechex(crc32(base64_encode($output))), 0, $count));

			$output .= md5($unique_state);
}

$output = substr($output, 0, ($bytes * 2));







	return $output;
}

		$output = pack('H*', $output);






/**
* Wrapper function for mt_rand. Automatically seeds using a secure seed once.
*
* @param int $min Optional lowest value to be returned (default: 0)
* @param int $max Optional highest value to be returned (default: mt_getrandmax())
* @param boolean $force_seed True forces it to reseed the RNG first






		return $output;
}
else
{
return $output;
}
}

/**
* Returns a securely generated seed integer
*

 * @return int An integer equivalent of a secure hexadecimal seed
*/

 * @return int An integer equivalent of a secure hexadecimal seed
*/

function my_rand($min=null, $max=null, $force_seed=false)

function secure_seed_rng()

{

{

	static $seeded = false;
static $obfuscator = 0;

	$bytes = PHP_INT_SIZE;






	if($seeded == false || $force_seed == true)

	do

	{

	{

		mt_srand(secure_seed_rng());
$seeded = true;

$obfuscator = abs((int) secure_seed_rng());

// Ensure that $obfuscator is <= mt_getrandmax() for 64 bit systems.
if($obfuscator > mt_getrandmax())
{
$obfuscator -= mt_getrandmax();
}
}

if($min !== null && $max !== null)
{
$distance = $max - $min;
if($distance > 0)
{
return $min + (int)((float)($distance + 1) * (float)(mt_rand() ^ $obfuscator) / (mt_getrandmax() + 1));
}


$output = secure_binary_seed_rng($bytes);

// convert binary data to a decimal number
if ($bytes == 4)
{
$elements = unpack('i', $output);
$output = abs($elements[1]);
}











		else
{

		else
{

			return mt_rand($min, $max);


			$elements = unpack('N2', $output);
$output = abs($elements[1] << 32 | $elements[2]);

		}

		}

	}
else






















} while($output > PHP_INT_MAX);

return $output;
}

/**
* Generates a cryptographically secure random number.
*
* @param int $min Optional lowest value to be returned (default: 0)
* @param int $max Optional highest value to be returned (default: PHP_INT_MAX)
*/
function my_rand($min=0, $max=PHP_INT_MAX)
{
// backward compatibility
if($min === null || $max === null || $max < $min)
{
$min = 0;
$max = PHP_INT_MAX;
}

if(version_compare(PHP_VERSION, '7.0', '>='))

	{

	{

		$val = mt_rand() ^ $obfuscator;
return $val;









		try
{
$result = random_int($min, $max);
} catch (Exception $e) {
}

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

	}

	}

 

$seed = secure_seed_rng();

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

}

/**

}

/**

Zeile 7917Zeile 8008
			return match_sequence($string, $level, $i, $n);
}
return $n;

			return match_sequence($string, $level, $i, $n);
}
return $n;

	}

	}


return 0;
}


return 0;
}

Zeile 7934Zeile 8025
	if($gd_version)
{
return $gd_version;

	if($gd_version)
{
return $gd_version;

	}

	}

	if(!extension_loaded('gd'))
{
return;

	if(!extension_loaded('gd'))
{
return;

Zeile 7986Zeile 8077
					{
$string .= '?';
continue;

					{
$string .= '?';
continue;

					}
else
{
return false;
}

					}
else
{
return false;
}

				}
elseif($c > 239)
{

				}
elseif($c > 239)
{

Zeile 8045Zeile 8136
				{
$string .= $multibytes;
}

				{
$string .= $multibytes;
}

			}

			}

			else
{
$string .= $input[$i];

			else
{
$string .= $input[$i];

Zeile 8062Zeile 8153
		else
{
return preg_replace("#[^\\x00-\\x7F][\\x80-\\xBF]{3,}#", '?', $input);

		else
{
return preg_replace("#[^\\x00-\\x7F][\\x80-\\xBF]{3,}#", '?', $input);

		}
}

		}
}

	else
{
if($allow_mb4)

	else
{
if($allow_mb4)

		{

		{

			return true;
}
else
{
return !preg_match("#[^\\x00-\\x7F][\\x80-\\xBF]{3,}#", $input);

			return true;
}
else
{
return !preg_match("#[^\\x00-\\x7F][\\x80-\\xBF]{3,}#", $input);

		}

		}

	}
}


	}
}


Zeile 8090Zeile 8181
	global $lang, $mybb, $db, $session;

if($mybb->settings['enablepms'] == 0)

	global $lang, $mybb, $db, $session;

if($mybb->settings['enablepms'] == 0)

	{
return false;
}


	{
return false;
}


	if(!is_array($pm))
{
return false;
}

if(isset($pm['language']))

	if(!is_array($pm))
{
return false;
}

if(isset($pm['language']))

	{

	{

		if($pm['language'] != $mybb->user['language'] && $lang->language_exists($pm['language']))
{
// Load user language
$lang->set_language($pm['language']);
$lang->load($pm['language_file']);

		if($pm['language'] != $mybb->user['language'] && $lang->language_exists($pm['language']))
{
// Load user language
$lang->set_language($pm['language']);
$lang->load($pm['language_file']);





			$revert = true;

			$revert = true;

		}


		}


		foreach(array('subject', 'message') as $key)
{

		foreach(array('subject', 'message') as $key)
{

			$lang_string = $pm[$key];

 
			if(is_array($pm[$key]))
{

			if(is_array($pm[$key]))
{

 
				$lang_string = $lang->{$pm[$key][0]};

				$num_args = count($pm[$key]);

for($i = 1; $i < $num_args; $i++)
{

				$num_args = count($pm[$key]);

for($i = 1; $i < $num_args; $i++)
{

					$lang->{$pm[$key][0]} = str_replace('{'.$i.'}', $pm[$key][$i], $lang->{$pm[$key][0]});

					$lang_string = str_replace('{'.$i.'}', $pm[$key][$i], $lang_string);

				}

				}


$lang_string = $pm[$key][0];



			}
else
{
$lang_string = $lang->{$pm[$key]};

			}


			}


			$pm[$key] = $lang->{$lang_string};

			$pm[$key] = $lang_string;

		}

if(isset($revert))

		}

if(isset($revert))

Zeile 8140Zeile 8233
	{
return false;
}

	{
return false;
}


$lang->load('messages');

 

require_once MYBB_ROOT."inc/datahandlers/pm.php";



require_once MYBB_ROOT."inc/datahandlers/pm.php";