Vergleich inc/functions.php - 1.8.17 - 1.8.22

  Keine Änderungen   Hinzugefügt   Modifiziert   Entfernt
Zeile 18Zeile 18
	global $db, $lang, $theme, $templates, $plugins, $mybb;
global $debug, $templatecache, $templatelist, $maintimer, $globaltime, $parsetime;


	global $db, $lang, $theme, $templates, $plugins, $mybb;
global $debug, $templatecache, $templatelist, $maintimer, $globaltime, $parsetime;


 
	$contents = $plugins->run_hooks("pre_parse_page", $contents);

	$contents = parse_page($contents);
$totaltime = format_time_duration($maintimer->stop());
$contents = $plugins->run_hooks("pre_output_page", $contents);

	$contents = parse_page($contents);
$totaltime = format_time_duration($maintimer->stop());
$contents = $plugins->run_hooks("pre_output_page", $contents);

Zeile 623Zeile 624
	// Guests get a special string
else
{

	// Guests get a special string
else
{

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

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

	}
}


	}
}


Zeile 868Zeile 869

foreach($errors as $error)
{


foreach($errors as $error)
{

		$errorlist .= "<li>".$error."</li>\n";

		eval("\$errorlist .= \"".$templates->get("error_inline_item")."\";");

	}

eval("\$errors = \"".$templates->get("error_inline")."\";");

	}

eval("\$errors = \"".$templates->get("error_inline")."\";");

Zeile 2041Zeile 2042
		return false;
}


		return false;
}


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

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



/*
* states:


/*
* states:

Zeile 3173Zeile 3173

if($dimensions)
{


if($dimensions)
{

		$dimensions = explode("|", $dimensions);

		$dimensions = preg_split('/[|x]/', $dimensions);


if($dimensions[0] && $dimensions[1])
{


if($dimensions[0] && $dimensions[1])
{

			list($max_width, $max_height) = explode('x', $max_dimensions);

			list($max_width, $max_height) = preg_split('/[|x]/', $max_dimensions);


if(!empty($max_dimensions) && ($dimensions[0] > $max_width || $dimensions[1] > $max_height))
{


if(!empty($max_dimensions) && ($dimensions[0] > $max_width || $dimensions[1] > $max_height))
{

Zeile 3274Zeile 3274
			"editor_invalidyoutube" => "Invalid YouTube video",
"editor_dailymotion" => "Dailymotion",
"editor_metacafe" => "MetaCafe",

			"editor_invalidyoutube" => "Invalid YouTube video",
"editor_dailymotion" => "Dailymotion",
"editor_metacafe" => "MetaCafe",

			"editor_veoh" => "Veoh",

			"editor_mixer" => "Mixer",

			"editor_vimeo" => "Vimeo",
"editor_youtube" => "Youtube",
"editor_facebook" => "Facebook",

			"editor_vimeo" => "Vimeo",
"editor_youtube" => "Youtube",
"editor_facebook" => "Facebook",

Zeile 3444Zeile 3444
	}

return $codeinsert;

	}

return $codeinsert;

 
}

/**
* @param int $tid
* @param array $postoptions The options carried with form submit
*
* @return string Predefined / updated subscription method of the thread for the user
*/
function get_subscription_method($tid = 0, $postoptions = array())
{
global $mybb;

$subscription_methods = array('', 'none', 'email', 'pm'); // Define methods
$subscription_method = (int)$mybb->user['subscriptionmethod']; // Set user default

// If no user default method available then reset method
if(!$subscription_method)
{
$subscription_method = 0;
}

// Return user default if no thread id available, in case
if(!(int)$tid || (int)$tid <= 0)
{
return $subscription_methods[$subscription_method];
}

// If method not predefined set using data from database
if(isset($postoptions['subscriptionmethod']))
{
$method = trim($postoptions['subscriptionmethod']);
return (in_array($method, $subscription_methods)) ? $method : $subscription_methods[0];
}
else
{
global $db;

$query = $db->simple_select("threadsubscriptions", "tid, notification", "tid='".(int)$tid."' AND uid='".$mybb->user['uid']."'", array('limit' => 1));
$subscription = $db->fetch_array($query);

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

return $subscription_methods[$subscription_method];

}

/**

}

/**

Zeile 4337Zeile 4384
				eval("\$nav .= \"".$templates->get("nav_bit")."\";");
}
}

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

 
		$navsize = count($navbits);
$navbit = $navbits[$navsize-1];

	}

	}


$activesep = '';
$navsize = count($navbits);
$navbit = $navbits[$navsize-1];

 

if($nav)
{


if($nav)
{

Zeile 6131Zeile 6176
{
global $mybb, $db;
static $user_cache;

{
global $mybb, $db;
static $user_cache;


$uid = (int)$uid;



$uid = (int)$uid;


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

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

Zeile 6386Zeile 6431
	}
// This user has a cookie lockout, show waiting time
elseif($mybb->cookies['lockoutexpiry'] && $mybb->cookies['lockoutexpiry'] > $now)

	}
// This user has a cookie lockout, show waiting time
elseif($mybb->cookies['lockoutexpiry'] && $mybb->cookies['lockoutexpiry'] > $now)

	{	

	{

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

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

Zeile 6427Zeile 6472

// Are we still locked out?
if($attempts['loginlockoutexpiry'] > $now)


// Are we still locked out?
if($attempts['loginlockoutexpiry'] > $now)

		{	

		{

			if($fatal)

			if($fatal)

			{

			{

				$secsleft = (int)($attempts['loginlockoutexpiry'] - $now);
$hoursleft = floor($secsleft / 3600);
$minsleft = floor(($secsleft / 60) % 60);

				$secsleft = (int)($attempts['loginlockoutexpiry'] - $now);
$hoursleft = floor($secsleft / 3600);
$minsleft = floor(($secsleft / 60) % 60);

Zeile 6450Zeile 6495
					"loginlockoutexpiry" => 0
), "uid='{$uid}'");
}

					"loginlockoutexpiry" => 0
), "uid='{$uid}'");
}





			// Wipe the cookie, no matter if a guest or a member
my_unsetcookie('lockoutexpiry');


			// Wipe the cookie, no matter if a guest or a member
my_unsetcookie('lockoutexpiry');


Zeile 6471Zeile 6516
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 6488Zeile 6533
	if($uid)
{
$uid_string = " AND uid != '".(int)$uid."'";

	if($uid)
{
$uid_string = " AND uid != '".(int)$uid."'";

	}

	}

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

Zeile 6516Zeile 6561
	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 6639Zeile 6686
	}

return $highlight_cache;

	}

return $highlight_cache;

}

}


/**
* Sort the word array by length. Largest terms go first and work their way down to the smallest term.


/**
* Sort the word array by length. Largest terms go first and work their way down to the smallest term.

Zeile 6649Zeile 6696
 * @return integer Result of comparison function.
*/
function build_highlight_array_sort($a, $b)

 * @return integer Result of comparison function.
*/
function build_highlight_array_sort($a, $b)

{

{

	return strlen($b) - strlen($a);
}


	return strlen($b) - strlen($a);
}


Zeile 6659Zeile 6706
 *
* @param int $src Decimal value of a character reference
* @return string|bool

 *
* @param int $src Decimal value of a character reference
* @return string|bool

 */

 */

function dec_to_utf8($src)
{
$dest = '';

function dec_to_utf8($src)
{
$dest = '';

Zeile 6722Zeile 6769
				$db->update_query("banfilters", array("lastuse" => TIME_NOW), "fid='{$banned_username['fid']}'");
}
return true;

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

		}
}

		}
}

	// Still here - good username
return false;
}

	// Still here - good username
return false;
}

Zeile 6734Zeile 6781
 * @param string $email The email address.
* @param boolean $update_lastuse True if the 'last used' dateline should be updated if a match is found.
* @return boolean True if banned, false if not banned

 * @param string $email The email address.
* @param boolean $update_lastuse True if the 'last used' dateline should be updated if a match is found.
* @return boolean True if banned, false if not banned

 */

 */

function is_banned_email($email, $update_lastuse=false)
{
global $cache, $db;

function is_banned_email($email, $update_lastuse=false)
{
global $cache, $db;

Zeile 6763Zeile 6810
					$db->update_query("banfilters", array("lastuse" => TIME_NOW), "fid='{$banned_email['fid']}'");
}
return true;

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

			}
}
}

			}
}
}


// Still here - good email
return false;


// Still here - good email
return false;

Zeile 6807Zeile 6854
			}
}
elseif($ip_address == $ip_range)

			}
}
elseif($ip_address == $ip_range)

		{

		{

			$banned = true;
}
if($banned)

			$banned = true;
}
if($banned)

Zeile 7067Zeile 7114

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 7192Zeile 7239

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 7229Zeile 7276
		if($result_set)
{
$addresses = array_column($result_set, 'ip');

		if($result_set)
{
$addresses = array_column($result_set, 'ip');

		}

		}

		else
{
return false;

		else
{
return false;

Zeile 7480Zeile 7527
		"0-6-0" => "6 {$lang->months}",
"0-0-1" => "1 {$lang->year}",
"0-0-2" => "2 {$lang->years}"

		"0-6-0" => "6 {$lang->months}",
"0-0-1" => "1 {$lang->year}",
"0-0-2" => "2 {$lang->years}"

	);

	);


$ban_times = $plugins->run_hooks("functions_fetch_ban_times", $ban_times);



$ban_times = $plugins->run_hooks("functions_fetch_ban_times", $ban_times);


Zeile 7563Zeile 7610
	global $orig_dir;

if(!isset($orig_dir))

	global $orig_dir;

if(!isset($orig_dir))

	{

	{

		$orig_dir = $path;
}


		$orig_dir = $path;
}


Zeile 7583Zeile 7630

// Are we done? Don't delete the main folder too and return true
if($path == $orig_dir)


// Are we done? Don't delete the main folder too and return true
if($path == $orig_dir)

		{

		{

			return true;
}


			return true;
}


Zeile 7599Zeile 7646
 * @param array $array The array of forums
* @return integer The number of sub forums
*/

 * @param array $array The array of forums
* @return integer The number of sub forums
*/

function subforums_count($array)

function subforums_count($array=array())

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

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

	}

	}


return $count;
}


return $count;
}

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

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





		if(!$ip_long)
{
return 0;
}

		if(!$ip_long)
{
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;
}


Zeile 7648Zeile 7695
 * @deprecated
* @param integer $long The IP to convert (will accept 64-bit IPs as well)
* @return string IP in IPv4 format

 * @deprecated
* @param integer $long The IP to convert (will accept 64-bit IPs as well)
* @return string IP in IPv4 format

 */

 */

function my_long2ip($long)
{
// On 64-bit machines is_int will return true. On 32-bit it will return false

function my_long2ip($long)
{
// On 64-bit machines is_int will return true. On 32-bit it will return false

Zeile 7982Zeile 8029
					continue;
}
$bad_verify_files[] = array("status" => "missing", "path" => $file_path);

					continue;
}
$bad_verify_files[] = array("status" => "missing", "path" => $file_path);

			}
}
}

			}
}
}


// uh oh
if($count == 0)


// uh oh
if($count == 0)

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

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

		}


		}


	} while($output > PHP_INT_MAX);

return $output;

	} while($output > PHP_INT_MAX);

return $output;

Zeile 8404Zeile 8451
					{
$string .= '?';
continue;

					{
$string .= '?';
continue;

					}
else

					}
else

					{
return false;
}

					{
return false;
}

Zeile 8437Zeile 8484
				$valid = true;
$multibytes = $input[$i];
while($bytes > 1)

				$valid = true;
$multibytes = $input[$i];
while($bytes > 1)

				{

				{

					$i++;
$b = ord($input[$i]);
if($b < 128 || $b > 191)

					$i++;
$b = ord($input[$i]);
if($b < 128 || $b > 191)

Zeile 8447Zeile 8494
							$valid = false;
$string .= '?';
break;

							$valid = false;
$string .= '?';
break;

						}

						}

						else
{
return false;
}

						else
{
return false;
}

					}

					}

					else
{
$multibytes .= $input[$i];
}
$bytes--;

					else
{
$multibytes .= $input[$i];
}
$bytes--;

				}

				}

				if($valid)
{
$string .= $multibytes;
}

				if($valid)
{
$string .= $multibytes;
}

			}

			}

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

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

		}

		}

		$input = $string;
}
if($return)
{
if($allow_mb4)

		$input = $string;
}
if($return)
{
if($allow_mb4)

		{

		{

			return $input;
}
else
{

			return $input;
}
else
{

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

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

		}
}
else

		}
}
else

Zeile 8489Zeile 8536
			return true;
}
else

			return true;
}
else

		{

		{

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

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

Zeile 8508Zeile 8555
	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))
{


if(!is_array($pm))
{

Zeile 8531Zeile 8578
		foreach(array('subject', 'message') as $key)
{
if(is_array($pm[$key]))

		foreach(array('subject', 'message') as $key)
{
if(is_array($pm[$key]))

			{

			{

				$lang_string = $lang->{$pm[$key][0]};
$num_args = count($pm[$key]);


				$lang_string = $lang->{$pm[$key][0]};
$num_args = count($pm[$key]);


Zeile 8573Zeile 8620
	if(is_array($toid))
{
$recipients_to = $toid;

	if(is_array($toid))
{
$recipients_to = $toid;

	}

	}

	else
{
$recipients_to = array($toid);

	else
{
$recipients_to = array($toid);

Zeile 8825Zeile 8872
	$string = str_replace('"', '""', $string);

return $string;

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

return $string;

 
}

// Fallback function for 'array_column', PHP < 5.5.0 compatibility
if(!function_exists('array_column'))
{
function array_column($input, $column_key)
{
$values = array();
if(!is_array($input))
{
$input = array($input);
}
foreach($input as $val)
{
if(is_array($val) && isset($val[$column_key]))
{
$values[] = $val[$column_key];
}
elseif(is_object($val) && isset($val->$column_key))
{
$values[] = $val->$column_key;
}
}
return $values;
}
}

/**
* Performs a timing attack safe string comparison.
*
* @param string $known_string The first string to be compared.
* @param string $user_string The second, user-supplied string to be compared.
* @return bool Result of the comparison.
*/
function my_hash_equals($known_string, $user_string)
{
if(version_compare(PHP_VERSION, '5.6.0', '>='))
{
return hash_equals($known_string, $user_string);
}
else
{
$known_string_length = my_strlen($known_string);
$user_string_length = my_strlen($user_string);

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

$result = 0;

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

return $result === 0;
}
}

/**
* Retrieves all referrals for a specified user
*
* @param int uid
* @param int start position
* @param int total entries
* @param bool false (default) only return display info, true for all info
* @return array
*/
function get_user_referrals($uid, $start=0, $limit=0, $full=false)
{
global $db;

$referrals = $query_options = array();
$uid = (int) $uid;

if($uid === 0)
{
return $referrals;
}

if($start && $limit)
{
$query_options['limit_start'] = $start;
}

if($limit)
{
$query_options['limit'] = $limit;
}

$fields = 'uid, username, usergroup, displaygroup, regdate';
if($full === true)
{
$fields = '*';
}

$query = $db->simple_select('users', $fields, "referrer='{$uid}'", $query_options);

while($referral = $db->fetch_array($query))
{
$referrals[] = $referral;
}

return $referrals;

}

}