Vergleich inc/functions.php - 1.8.10 - 1.8.15

  Keine Änderungen   Hinzugefügt   Modifiziert   Entfernt
Zeile 322Zeile 322
/**
* Turn a unix timestamp in to a "friendly" date/time format for the user.
*

/**
* Turn a unix timestamp in to a "friendly" date/time format for the user.
*

 * @param string $format A date format according to PHP's date structure.

 * @param string $format A date format (either relative, normal or PHP's date() structure).

 * @param int $stamp The unix timestamp the date should be generated for.
* @param int|string $offset The offset in hours that should be applied to times. (timezones) Or an empty string to determine that automatically
* @param int $ty Whether or not to use today/yesterday formatting.

 * @param int $stamp The unix timestamp the date should be generated for.
* @param int|string $offset The offset in hours that should be applied to times. (timezones) Or an empty string to determine that automatically
* @param int $ty Whether or not to use today/yesterday formatting.

Zeile 380Zeile 380
	}

$todaysdate = $yesterdaysdate = '';

	}

$todaysdate = $yesterdaysdate = '';

	if($ty && ($format == $mybb->settings['dateformat'] || $format == 'relative'))

	if($ty && ($format == $mybb->settings['dateformat'] || $format == 'relative' || $format == 'normal'))

	{
$_stamp = TIME_NOW;
if($adodb == true)

	{
$_stamp = TIME_NOW;
if($adodb == true)

Zeile 400Zeile 400
	if($format == 'relative')
{
// Relative formats both date and time

	if($format == 'relative')
{
// Relative formats both date and time

 
		$real_date = $real_time = '';
if($adodb == true)
{
$real_date = adodb_date($mybb->settings['dateformat'], $stamp + ($offset * 3600));
$real_time = $mybb->settings['datetimesep'];
$real_time .= adodb_date($mybb->settings['timeformat'], $stamp + ($offset * 3600));
}
else
{
$real_date = gmdate($mybb->settings['dateformat'], $stamp + ($offset * 3600));
$real_time = $mybb->settings['datetimesep'];
$real_time .= gmdate($mybb->settings['timeformat'], $stamp + ($offset * 3600));
}


		if($ty != 2 && abs(TIME_NOW - $stamp) < 3600)
{
$diff = TIME_NOW - $stamp;
$relative = array('prefix' => '', 'minute' => 0, 'plural' => $lang->rel_minutes_plural, 'suffix' => $lang->rel_ago);

		if($ty != 2 && abs(TIME_NOW - $stamp) < 3600)
{
$diff = TIME_NOW - $stamp;
$relative = array('prefix' => '', 'minute' => 0, 'plural' => $lang->rel_minutes_plural, 'suffix' => $lang->rel_ago);


if($diff < 0)
{
$diff = abs($diff);
$relative['suffix'] = '';


if($diff < 0)
{
$diff = abs($diff);
$relative['suffix'] = '';

				$relative['prefix'] = $lang->rel_in;
}


				$relative['prefix'] = $lang->rel_in;
}


Zeile 423Zeile 437
			if($diff <= 60)
{
// Less than a minute

			if($diff <= 60)
{
// Less than a minute

				$relative['prefix'] = $lang->rel_less_than;
}

$date = $lang->sprintf($lang->rel_time, $relative['prefix'], $relative['minute'], $relative['plural'], $relative['suffix']);

				$relative['prefix'] = $lang->rel_less_than;
}

$date = $lang->sprintf($lang->rel_time, $relative['prefix'], $relative['minute'], $relative['plural'], $relative['suffix'], $real_date, $real_time);

		}
elseif($ty != 2 && abs(TIME_NOW - $stamp) < 43200)
{

		}
elseif($ty != 2 && abs(TIME_NOW - $stamp) < 43200)
{

Zeile 448Zeile 462
				$relative['plural'] = $lang->rel_hours_single;
}


				$relative['plural'] = $lang->rel_hours_single;
}


			$date = $lang->sprintf($lang->rel_time, $relative['prefix'], $relative['hour'], $relative['plural'], $relative['suffix']);

			$date = $lang->sprintf($lang->rel_time, $relative['prefix'], $relative['hour'], $relative['plural'], $relative['suffix'], $real_date, $real_time);

		}
else
{
if($ty)

		}
else
{
if($ty)

			{

			{

				if($todaysdate == $date)
{

				if($todaysdate == $date)
{

					$date = $lang->today;

					$date = $lang->sprintf($lang->today_rel, $real_date);

				}
else if($yesterdaysdate == $date)
{

				}
else if($yesterdaysdate == $date)
{

					$date = $lang->yesterday;

					$date = $lang->sprintf($lang->yesterday_rel, $real_date);

				}
}


				}
}


Zeile 473Zeile 487
			{
$date .= gmdate($mybb->settings['timeformat'], $stamp + ($offset * 3600));
}

			{
$date .= gmdate($mybb->settings['timeformat'], $stamp + ($offset * 3600));
}

 
		}
}
elseif($format == 'normal')
{
// Normal format both date and time
if($ty != 2)
{
if($todaysdate == $date)
{
$date = $lang->today;
}
else if($yesterdaysdate == $date)
{
$date = $lang->yesterday;
}
}

$date .= $mybb->settings['datetimesep'];
if($adodb == true)
{
$date .= adodb_date($mybb->settings['timeformat'], $stamp + ($offset * 3600));
}
else
{
$date .= gmdate($mybb->settings['timeformat'], $stamp + ($offset * 3600));

		}
}
else

		}
}
else

Zeile 966Zeile 1005

run_shutdown();



run_shutdown();


		if(!my_validate_url($url, true))

		if(!my_validate_url($url, true, true))

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

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

Zeile 1179Zeile 1218
	if($uid != $mybb->user['uid'])
{
// We've already cached permissions for this user, return them.

	if($uid != $mybb->user['uid'])
{
// We've already cached permissions for this user, return them.

		if($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.

		{
return $user_cache[$uid]['permissions'];
}

// This user was not already cached, fetch their user information.

		if(!$user_cache[$uid])

		if(empty($user_cache[$uid]))

		{
$user_cache[$uid] = get_user($uid);
}

		{
$user_cache[$uid] = get_user($uid);
}

Zeile 3011Zeile 3050
 */
function format_name($username, $usergroup, $displaygroup=0)
{

 */
function format_name($username, $usergroup, $displaygroup=0)
{

	global $groupscache, $cache;

	global $groupscache, $cache, $plugins;





	if(!is_array($groupscache))



	static $formattednames = array();

if(!isset($formattednames[$username]))

	{

	{

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

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





















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

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

$format = "{username}";

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

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

$format = stripslashes($format);

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

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





	$ugroup = $groupscache[$usergroup];
$format = $ugroup['namestyle'];
$userin = substr_count($format, "{username}");

		$format = $parameters['format'];







	if($userin == 0)
{
$format = "{username}";

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



	}


	}


	$format = stripslashes($format);

return str_replace("{username}", $username, $format);

	return $formattednames[$username];



}

/**

}

/**

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

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

 
	}

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

	}

// Any remaining extra data - we my_serialize and insert in to its own column

	}

// Any remaining extra data - we my_serialize and insert in to its own column

Zeile 3799Zeile 3861
		"data" => $db->escape_string($data),
"ipaddress" => $db->escape_binary($session->packedip)
);

		"data" => $db->escape_string($data),
"ipaddress" => $db->escape_binary($session->packedip)
);

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


















if($tids)
{
$multiple_sql_array = array();

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

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

}

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

}

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

 *

 *

 * @param int $reputation The reputation value
* @param int $uid The user ID (if not specified, the generated reputation will not be a link)
* @return string The formatted repuation

 * @param int $reputation The reputation value
* @param int $uid The user ID (if not specified, the generated reputation will not be a link)
* @return string The formatted repuation

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

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

	{

	{

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


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


Zeile 3863Zeile 3941
	else if($level >= 25)
{
$warning_class = "low_warning";

	else if($level >= 25)
{
$warning_class = "low_warning";

	}
else

	}
else

	{
$warning_class = "normal_warning";
}

	{
$warning_class = "normal_warning";
}

Zeile 4025Zeile 4103
	}

return $time;

	}

return $time;

}

}


/**
* Get the attachment icon for a specific file extension


/**
* Get the attachment icon for a specific file extension

Zeile 4183Zeile 4261
	$format = str_replace("y", my_substr($year, -2), $format);

return $format;

	$format = str_replace("y", my_substr($year, -2), $format);

return $format;

}

/**

}

/**

 * Build the breadcrumb navigation trail from the specified items
*
* @return string The formatted breadcrumb navigation trail

 * Build the breadcrumb navigation trail from the specified items
*
* @return string The formatted breadcrumb navigation trail

Zeile 4236Zeile 4314
				// Replace page 1 URLs
$navbit['url'] = str_replace("-page-1.html", ".html", $navbit['url']);
$navbit['url'] = preg_replace("/&amp;page=1$/", "", $navbit['url']);

				// Replace page 1 URLs
$navbit['url'] = str_replace("-page-1.html", ".html", $navbit['url']);
$navbit['url'] = preg_replace("/&amp;page=1$/", "", $navbit['url']);





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

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

Zeile 4264Zeile 4342
 * @param string $url The URL of the item to add
*/
function add_breadcrumb($name, $url="")

 * @param string $url The URL of the item to add
*/
function add_breadcrumb($name, $url="")

{
global $navbits;


{
global $navbits;


	$navsize = count($navbits);
$navbits[$navsize]['name'] = $name;
$navbits[$navsize]['url'] = $url;

	$navsize = count($navbits);
$navbits[$navsize]['name'] = $name;
$navbits[$navsize]['url'] = $url;

Zeile 4426Zeile 4504
	if($mybb->settings['gzipoutput'] != 0)
{
$gzipen = "Enabled";

	if($mybb->settings['gzipoutput'] != 0)
{
$gzipen = "Enabled";

	}

	}

	else
{
$gzipen = "Disabled";

	else
{
$gzipen = "Disabled";

Zeile 4492Zeile 4570
	echo "<td bgcolor=\"#FEFEFE\" width=\"25%\"><span style=\"font-family: tahoma; font-size: 12px;\">{$memory_usage}</span></td>\n";
echo "<td bgcolor=\"#EFEFEF\" width=\"25%\"><b><span style=\"font-family: tahoma; font-size: 12px;\">Memory Limit:</span></b></td>\n";
echo "<td bgcolor=\"#FEFEFE\" width=\"25%\"><span style=\"font-family: tahoma; font-size: 12px;\">{$memory_limit}</span></td>\n";

	echo "<td bgcolor=\"#FEFEFE\" width=\"25%\"><span style=\"font-family: tahoma; font-size: 12px;\">{$memory_usage}</span></td>\n";
echo "<td bgcolor=\"#EFEFEF\" width=\"25%\"><b><span style=\"font-family: tahoma; font-size: 12px;\">Memory Limit:</span></b></td>\n";
echo "<td bgcolor=\"#FEFEFE\" width=\"25%\"><span style=\"font-family: tahoma; font-size: 12px;\">{$memory_limit}</span></td>\n";

	echo "</tr>\n";

echo "</table>\n";


	echo "</tr>\n";

echo "</table>\n";


	echo "<h2>Database Connections (".count($db->connections)." Total) </h2>\n";
echo "<table style=\"background-color: #666;\" width=\"95%\" cellpadding=\"4\" cellspacing=\"1\" align=\"center\">\n";
echo "<tr>\n";

	echo "<h2>Database Connections (".count($db->connections)." Total) </h2>\n";
echo "<table style=\"background-color: #666;\" width=\"95%\" cellpadding=\"4\" cellspacing=\"1\" align=\"center\">\n";
echo "<tr>\n";

Zeile 4511Zeile 4589
	{
echo "<h2>Cache Calls (".$cache->call_count." Total, ".$call_time.") </h2>\n";
echo $cache->cache_debug;

	{
echo "<h2>Cache Calls (".$cache->call_count." Total, ".$call_time.") </h2>\n";
echo $cache->cache_debug;

	}


	}


	echo "<h2>Template Statistics</h2>\n";

if(count($templates->cache) > 0)

	echo "<h2>Template Statistics</h2>\n";

if(count($templates->cache) > 0)

Zeile 4520Zeile 4598
		echo "<table style=\"background-color: #666;\" width=\"95%\" cellpadding=\"4\" cellspacing=\"1\" align=\"center\">\n";
echo "<tr>\n";
echo "<td style=\"background-color: #ccc;\"><strong>Templates Used (Loaded for this Page) - ".count($templates->cache)." Total</strong></td>\n";

		echo "<table style=\"background-color: #666;\" width=\"95%\" cellpadding=\"4\" cellspacing=\"1\" align=\"center\">\n";
echo "<tr>\n";
echo "<td style=\"background-color: #ccc;\"><strong>Templates Used (Loaded for this Page) - ".count($templates->cache)." Total</strong></td>\n";

		echo "</tr>\n";
echo "<tr>\n";
echo "<td style=\"background: #fff;\">".implode(", ", array_keys($templates->cache))."</td>\n";
echo "</tr>\n";
echo "</table>\n";
echo "<br />\n";
}

		echo "</tr>\n";
echo "<tr>\n";
echo "<td style=\"background: #fff;\">".implode(", ", array_keys($templates->cache))."</td>\n";
echo "</tr>\n";
echo "</table>\n";
echo "<br />\n";
}


if(count($templates->uncached_templates) > 0)
{
echo "<table style=\"background-color: #666;\" width=\"95%\" cellpadding=\"4\" cellspacing=\"1\" align=\"center\">\n";


if(count($templates->uncached_templates) > 0)
{
echo "<table style=\"background-color: #666;\" width=\"95%\" cellpadding=\"4\" cellspacing=\"1\" align=\"center\">\n";

		echo "<tr>\n";

		echo "<tr>\n";

		echo "<td style=\"background-color: #ccc;\"><strong>Templates Requiring Additional Calls (Not Cached at Startup) - ".count($templates->uncached_templates)." Total</strong></td>\n";
echo "</tr>\n";
echo "<tr>\n";

		echo "<td style=\"background-color: #ccc;\"><strong>Templates Requiring Additional Calls (Not Cached at Startup) - ".count($templates->uncached_templates)." Total</strong></td>\n";
echo "</tr>\n";
echo "<tr>\n";

Zeile 4558Zeile 4636
		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


/**
* Mark specific reported posts of a certain type as dealt with

Zeile 4659Zeile 4737
		$lang_minutes = " ".$lang->minutes;
$lang_second = " ".$lang->second;
$lang_seconds = " ".$lang->seconds;

		$lang_minutes = " ".$lang->minutes;
$lang_second = " ".$lang->second;
$lang_seconds = " ".$lang->seconds;

	}

	}


$years = floor($stamp/$ysecs);
$stamp %= $ysecs;


$years = floor($stamp/$ysecs);
$stamp %= $ysecs;

Zeile 4674Zeile 4752
	$minutes = floor($stamp/$msecs);
$stamp %= $msecs;
$seconds = $stamp;

	$minutes = floor($stamp/$msecs);
$stamp %= $msecs;
$seconds = $stamp;


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

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
































// Prevent gross over accuracy ($options parameter will override these)
if($years > 0)
{
$options = array_merge(array(
'days' => false,
'hours' => false,
'minutes' => false,
'seconds' => false
), $options);
}
elseif($months > 0)
{
$options = array_merge(array(
'hours' => false,
'minutes' => false,
'seconds' => false
), $options);
}
elseif($weeks > 0)
{
$options = array_merge(array(
'minutes' => false,
'seconds' => false
), $options);
}
elseif($days > 0)
{
$options = array_merge(array(
'seconds' => false
), $options);
}

if(!isset($options['years']) || $options['years'] !== false)
{
if($years == 1)
{
$nicetime['years'] = "1".$lang_year;
}
else if($years > 1)
{
$nicetime['years'] = $years.$lang_years;
}

	}

	}

	else if($months > 1)



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

	{

	{

		$nicetime['months'] = $months.$lang_months;








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

	}


	}


	if($weeks == 1)

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

	{

	{

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




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

	}


	}


	if($days == 1)

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

	{

	{

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




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

	}

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

	}

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

Zeile 5669Zeile 5791
function unhtmlentities($string)
{
// Replace numeric entities

function unhtmlentities($string)
{
// Replace numeric entities

	$string = preg_replace_callback('~&#x([0-9a-f]+);~i', create_function('$matches', 'return unichr(hexdec($matches[1]));'), $string);
$string = preg_replace_callback('~&#([0-9]+);~', create_function('$matches', 'return unichr($matches[1]);'), $string);

	$string = preg_replace_callback('~&#x([0-9a-f]+);~i', 'unichr_callback1', $string);
$string = preg_replace_callback('~&#([0-9]+);~', 'unichr_callback2', $string);


// Replace literal entities
$trans_tbl = get_html_translation_table(HTML_ENTITIES);


// Replace literal entities
$trans_tbl = get_html_translation_table(HTML_ENTITIES);

Zeile 5710Zeile 5832
	{
return false;
}

	{
return false;
}

 
}

/**
* Returns any ascii to it's character (utf-8 safe).
*
* @param array $matches Matches.
* @return string|bool The characterized ascii. False on failure
*/
function unichr_callback1($matches)
{
return unichr(hexdec($matches[1]));
}

/**
* Returns any ascii to it's character (utf-8 safe).
*
* @param array $matches Matches.
* @return string|bool The characterized ascii. False on failure
*/
function unichr_callback2($matches)
{
return unichr($matches[1]);

}

/**

}

/**

Zeile 5783Zeile 5927
	if(!$username && $uid == 0)
{
// Return Guest phrase for no UID, no guest nickname

	if(!$username && $uid == 0)
{
// Return Guest phrase for no UID, no guest nickname

		return $lang->guest;

		return htmlspecialchars_uni($lang->guest);

	}
elseif($uid == 0)
{

	}
elseif($uid == 0)
{

Zeile 5953Zeile 6097
	if($week < 0)
{
$week = str_replace('-', "n", $week);

	if($week < 0)
{
$week = str_replace('-', "n", $week);

	}

	}

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

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

Zeile 6002Zeile 6146
	global $mybb, $db;

$username = $db->escape_string(my_strtolower($username));

	global $mybb, $db;

$username = $db->escape_string(my_strtolower($username));





	if(!isset($options['username_method']))
{
$options['username_method'] = 0;

	if(!isset($options['username_method']))
{
$options['username_method'] = 0;

Zeile 6032Zeile 6176
		default:
$sqlwhere = "{$field}='{$username}'";
break;

		default:
$sqlwhere = "{$field}='{$username}'";
break;

	}


	}


	$fields = array('uid');
if(isset($options['fields']))
{

	$fields = array('uid');
if(isset($options['fields']))
{

Zeile 6188Zeile 6332
				{
$inactive[] = $fid1;
}

				{
$inactive[] = $fid1;
}

			}
}
}

$inactiveforums = implode(",", $inactive);


			}
}
}

$inactiveforums = implode(",", $inactive);


	return $inactiveforums;
}


	return $inactiveforums;
}


Zeile 6299Zeile 6443
 */
function validate_email_format($email)
{

 */
function validate_email_format($email)
{

	if(strpos($email, ' ') !== false)
{
return false;
}
// 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);

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






}

/**

}

/**

Zeile 6322Zeile 6461
	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 6341Zeile 6480
{
global $db, $mybb;


{
global $db, $mybb;


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

$options = array(
"order_by" => "title",
"order_dir" => "ASC"
);
$query = $db->simple_select("settings", "value, name", "", $options);

	$query = $db->simple_select("settings", "value, name", "", array(
'order_by' => 'title',
'order_dir' => 'ASC',
));















	$settings = null;

	$settings = '';

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

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

Zeile 6365Zeile 6494
	}

$settings = "<"."?php\n/*********************************\ \n DO NOT EDIT THIS FILE, PLEASE USE\n THE SETTINGS EDITOR\n\*********************************/\n\n$settings\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);
@fclose($file);


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



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


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

Zeile 6462Zeile 6590

// Sort the word array by length. Largest terms go first and work their way down to the smallest term.
// This resolves problems like "test tes" where "tes" will be highlighted first, then "test" can't be highlighted because of the changed html


// Sort the word array by length. Largest terms go first and work their way down to the smallest term.
// This resolves problems like "test tes" where "tes" will be highlighted first, then "test" can't be highlighted because of the changed html

	usort($words, create_function('$a,$b', 'return strlen($b) - strlen($a);'));

	usort($words, 'build_highlight_array_sort');


// Loop through our words to build the PREG compatible strings
foreach($words as $word)


// Loop through our words to build the PREG compatible strings
foreach($words as $word)

Zeile 6484Zeile 6612
	}

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.
*
* @param string $a First word.
* @param string $b Second word.
* @return integer Result of comparison function.
*/
function build_highlight_array_sort($a, $b)
{
return strlen($b) - strlen($a);

}

/**

}

/**

Zeile 6777Zeile 6917
function fetch_remote_file($url, $post_data=array(), $max_redirects=20)
{
global $mybb, $config;

function fetch_remote_file($url, $post_data=array(), $max_redirects=20)
{
global $mybb, $config;

 

if(!my_validate_url($url, true))
{
return false;
}


$url_components = @parse_url($url);


$url_components = @parse_url($url);

 

if(!isset($url_components['scheme']))
{
$url_components['scheme'] = 'https';
}
if(!isset($url_components['port']))
{
$url_components['port'] = $url_components['scheme'] == 'https' ? 443 : 80;
}


if(
!$url_components ||
empty($url_components['host']) ||
(!empty($url_components['scheme']) && !in_array($url_components['scheme'], array('http', 'https'))) ||


if(
!$url_components ||
empty($url_components['host']) ||
(!empty($url_components['scheme']) && !in_array($url_components['scheme'], array('http', 'https'))) ||

		(!empty($url_components['port']) && !in_array($url_components['port'], array(80, 8080, 443))) ||

		(!in_array($url_components['port'], array(80, 8080, 443))) ||

		(!empty($config['disallowed_remote_hosts']) && in_array($url_components['host'], $config['disallowed_remote_hosts']))
)
{
return false;
}

		(!empty($config['disallowed_remote_hosts']) && in_array($url_components['host'], $config['disallowed_remote_hosts']))
)
{
return false;
}

 

$addresses = get_ip_by_hostname($url_components['host']);
$destination_address = $addresses[0];


if(!empty($config['disallowed_remote_addresses']))


if(!empty($config['disallowed_remote_addresses']))

	{
$addresses = gethostbynamel($url_components['host']);
if($addresses)

	{
foreach($config['disallowed_remote_addresses'] as $disallowed_address)


		{

		{

			foreach($config['disallowed_remote_addresses'] as $disallowed_address)





			$ip_range = fetch_ip_range($disallowed_address);

$packed_address = my_inet_pton($destination_address);

if(is_array($ip_range))

			{

			{

				$ip_range = fetch_ip_range($disallowed_address);
foreach($addresses as $address)

				if(strcmp($ip_range[0], $packed_address) <= 0 && strcmp($ip_range[1], $packed_address) >= 0)


				{

				{

					$packed_address = my_inet_pton($address);

if(is_array($ip_range))
{
if(strcmp($ip_range[0], $packed_address) <= 0 && strcmp($ip_range[1], $packed_address) >= 0)
{
return false;
}
}
elseif($address == $disallowed_address)
{
return false;
}

					return false;













				}

				}

 
			}
elseif($destination_address == $disallowed_address)
{
return false;

			}
}
}

$post_body = '';
if(!empty($post_data))

			}
}
}

$post_body = '';
if(!empty($post_data))

	{

	{

		foreach($post_data as $key => $val)
{
$post_body .= '&'.urlencode($key).'='.urlencode($val);

		foreach($post_data as $key => $val)
{
$post_body .= '&'.urlencode($key).'='.urlencode($val);

Zeile 6831Zeile 6982

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;

		$fetch_header = $max_redirects > 0;




$ch = curl_init();


$ch = curl_init();

		curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, $request_header);
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
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);
}




























$curlopt = array(
CURLOPT_URL => $url,
CURLOPT_HEADER => $fetch_header,
CURLOPT_TIMEOUT => 10,
CURLOPT_RETURNTRANSFER => 1,
CURLOPT_FOLLOWLOCATION => 0,
);

if($ca_bundle_path = get_ca_bundle_path())
{
$curlopt[CURLOPT_SSL_VERIFYPEER] = 1;
$curlopt[CURLOPT_CAINFO] = $ca_bundle_path;
}
else
{
$curlopt[CURLOPT_SSL_VERIFYPEER] = 0;
}

$curl_version_info = curl_version();
$curl_version = $curl_version_info['version'];

if(version_compare(PHP_VERSION, '7.0.7', '>=') && version_compare($curl_version, '7.49', '>='))
{
// CURLOPT_CONNECT_TO
$curlopt[10243] = array(
$url_components['host'].':'.$url_components['port'].':'.$destination_address
);
}
elseif(version_compare(PHP_VERSION, '5.5', '>=') && version_compare($curl_version, '7.21.3', '>='))
{
// CURLOPT_RESOLVE
$curlopt[10203] = array(
$url_components['host'].':'.$url_components['port'].':'.$destination_address
);
}


		if(!empty($post_body))
{

		if(!empty($post_body))
{

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

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

		}

		}

 

curl_setopt_array($ch, $curlopt);


$response = curl_exec($ch);



$response = curl_exec($ch);


		if($request_header)

		if($fetch_header)

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

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

Zeile 6886Zeile 7062
	}
else if(function_exists("fsockopen"))
{

	}
else if(function_exists("fsockopen"))
{

		if(!isset($url_components['port']))
{
$url_components['port'] = 80;
}
if(!isset($url_components['path']))

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





		{
$url_components['path'] = "/";
}
if(isset($url_components['query']))

		{
$url_components['path'] = "/";
}
if(isset($url_components['query']))

		{

		{

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

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





		$scheme = '';

if($url_components['scheme'] == 'https')

		$scheme = '';

if($url_components['scheme'] == 'https')

		{

		{

			$scheme = 'ssl://';
if($url_components['port'] == 80)
{

			$scheme = 'ssl://';
if($url_components['port'] == 80)
{

Zeile 6910Zeile 7082
			}
}


			}
}


		$fp = @fsockopen($scheme.$url_components['host'], $url_components['port'], $error_no, $error, 10);






























		if(function_exists('stream_context_create'))
{
if($url_components['scheme'] == 'https' && $ca_bundle_path = get_ca_bundle_path())
{
$context = stream_context_create(array(
'ssl' => array(
'verify_peer' => true,
'verify_peer_name' => true,
'peer_name' => $url_components['host'],
'cafile' => $ca_bundle_path,
),
));
}
else
{
$context = stream_context_create(array(
'ssl' => array(
'verify_peer' => false,
'verify_peer_name' => false,
),
));
}

$fp = @stream_socket_client($scheme.$destination_address.':'.(int)$url_components['port'], $error_no, $error, 10, STREAM_CLIENT_CONNECT, $context);
}
else
{
$fp = @fsockopen($scheme.$url_components['host'], (int)$url_components['port'], $error_no, $error, 10);
}


		@stream_set_timeout($fp, 10);
if(!$fp)
{
return false;
}
$headers = array();

		@stream_set_timeout($fp, 10);
if(!$fp)
{
return false;
}
$headers = array();

		if(!empty($post_body))

		if(!empty($post_body))

		{
$headers[] = "POST {$url_components['path']} HTTP/1.0";
$headers[] = "Content-Length: ".strlen($post_body);

		{
$headers[] = "POST {$url_components['path']} HTTP/1.0";
$headers[] = "Content-Length: ".strlen($post_body);

Zeile 6944Zeile 7145

$headers = implode("\r\n", $headers);
if(!@fwrite($fp, $headers))


$headers = implode("\r\n", $headers);
if(!@fwrite($fp, $headers))

		{
return false;
}

		{
return false;
}


$data = null;



$data = null;


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


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


		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|$)/', $header, $matches);


Zeile 6978Zeile 7179

return $data;
}


return $data;
}

	else if(empty($post_data))













































	else
{
return false;
}
}

/**
* Resolves a hostname into a set of IP addresses.
*
* @param string $hostname The hostname to be resolved
* @return array|bool The resulting IP addresses. False on failure
*/
function get_ip_by_hostname($hostname)
{
$addresses = @gethostbynamel($hostname);

if(!$addresses)
{
$result_set = @dns_get_record($hostname, DNS_A | DNS_AAAA);

if($result_set)
{
$addresses = array_column($result_set, 'ip');
}
else
{
return false;
}
}

return $addresses;
}

/**
* Returns the location of the CA bundle defined in the PHP configuration.
*
* @return string|bool The location of the CA bundle, false if not set
*/
function get_ca_bundle_path()
{
if($path = ini_get('openssl.cafile'))
{
return $path;
}
if($path = ini_get('curl.cainfo'))

	{

	{

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

		return $path;





	}

	}

 

return false;

}

/**

}

/**

Zeile 7003Zeile 7246
		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)
{
return false;
}


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

	else
{
return true;

	else
{
return true;

Zeile 7084Zeile 7327
	$original = $string;
$in_escape = false;
if($escape)

	$original = $string;
$in_escape = false;
if($escape)

	{

	{

		if(is_array($escape))
{
function escaped_explode_escape($string)

		if(is_array($escape))
{
function escaped_explode_escape($string)

Zeile 7128Zeile 7371
		return $original;
}
return $strings;

		return $original;
}
return $strings;

}


}


/**
* DEPRECATED! Please use IPv6 compatible fetch_ip_range!
* Fetch an IPv4 long formatted range for searching IPv4 IP addresses.

/**
* DEPRECATED! Please use IPv6 compatible fetch_ip_range!
* Fetch an IPv4 long formatted range for searching IPv4 IP addresses.

Zeile 7497Zeile 7740
	if(strpos($ipaddress, '*') !== false)
{
if(strpos($ipaddress, ':') !== false)

	if(strpos($ipaddress, '*') !== false)
{
if(strpos($ipaddress, ':') !== false)

		{

		{

			// IPv6
$upper = str_replace('*', 'ffff', $ipaddress);
$lower = str_replace('*', '0', $ipaddress);

			// IPv6
$upper = str_replace('*', 'ffff', $ipaddress);
$lower = str_replace('*', '0', $ipaddress);

Zeile 7681Zeile 7924
				{
$filename = $path."/".$file;
$handle = fopen($filename, "rb");

				{
$filename = $path."/".$file;
$handle = fopen($filename, "rb");

					$contents = '';

					$hashingContext = hash_init('sha512');

					while(!feof($handle))
{

					while(!feof($handle))
{

						$contents .= fread($handle, 8192);

						hash_update($hashingContext, fread($handle, 8192));

					}
fclose($handle);


					}
fclose($handle);


					$md5 = md5($contents);

					$checksum = hash_final($hashingContext);


// Does it match any of our hashes (unix/windows new lines taken into consideration with the hashes)


// Does it match any of our hashes (unix/windows new lines taken into consideration with the hashes)

					if(!in_array($md5, $checksums[$file_path]))

					if(!in_array($checksum, $checksums[$file_path]))

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

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

Zeile 7750Zeile 7993
function secure_binary_seed_rng($bytes)
{
$output = null;

function secure_binary_seed_rng($bytes)
{
$output = null;


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


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

		try
{
$output = random_bytes($bytes);

		try
{
$output = random_bytes($bytes);

Zeile 8002Zeile 8245
	{
// Check to see if we have matched a first character in our utf-8 array
$offset = match_sequence($string, $hex_chrs);

	{
// Check to see if we have matched a first character in our utf-8 array
$offset = match_sequence($string, $hex_chrs);

		if(!$offset)

		if(!$offset)

		{
// If not, then we must have a "good" character and we don't need to do anymore processing
break;

		{
// If not, then we must have a "good" character and we don't need to do anymore processing
break;

Zeile 8018Zeile 8261
		// Check to see if we have matched a first character in our utf-8 array
$offset = match_sequence($string, $hex_chrs_rev);
if(!$offset)

		// Check to see if we have matched a first character in our utf-8 array
$offset = match_sequence($string, $hex_chrs_rev);
if(!$offset)

		{

		{

			// If not, then we must have a "good" character and we don't need to do anymore processing
break;
}

			// If not, then we must have a "good" character and we don't need to do anymore processing
break;
}

Zeile 8028Zeile 8271
	$string = strrev($string);

if($charlist)

	$string = strrev($string);

if($charlist)

	{

	{

		$string = trim($string, $charlist);
}
else
{
$string = trim($string);

		$string = trim($string, $charlist);
}
else
{
$string = trim($string);

	}

	}


return $string;
}


return $string;
}

Zeile 8081Zeile 8324
	static $gd_version;

if($gd_version)

	static $gd_version;

if($gd_version)

	{

	{

		return $gd_version;
}
if(!extension_loaded('gd'))

		return $gd_version;
}
if(!extension_loaded('gd'))

Zeile 8128Zeile 8371
		{
$c = ord($input[$i]);
if($c > 128)

		{
$c = ord($input[$i]);
if($c > 128)

			{

			{

				if($c > 247 || $c <= 191)
{
if($return)

				if($c > 247 || $c <= 191)
{
if($return)

Zeile 8378Zeile 8621
	if(!is_array($data))
{
$data = array($data);

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

	}


	}


	if(!$ip_address)
{
$ip_address = get_ip();

	if(!$ip_address)
{
$ip_address = get_ip();

Zeile 8393Zeile 8636
		'ipaddress' => $db->escape_binary($ip_address),
'dateline' => (int)TIME_NOW,
'data' => $db->escape_string(@my_serialize($data)),

		'ipaddress' => $db->escape_binary($ip_address),
'dateline' => (int)TIME_NOW,
'data' => $db->escape_string(@my_serialize($data)),

	);


	);


	return (bool)$db->insert_query('spamlog', $insert_array);
}

/**
* Copy a file to the CDN.
*

	return (bool)$db->insert_query('spamlog', $insert_array);
}

/**
* Copy a file to the CDN.
*

 * @param string $file_path     The path to the file to upload to the CDN.
*

 * @param string $file_path     The path to the file to upload to the CDN.
*

 * @param string $uploaded_path The path the file was uploaded to, reference parameter for when this may be needed.
*
* @return bool Whether the file was copied successfully.

 * @param string $uploaded_path The path the file was uploaded to, reference parameter for when this may be needed.
*
* @return bool Whether the file was copied successfully.

Zeile 8410Zeile 8653
function copy_file_to_cdn($file_path = '', &$uploaded_path = null)
{
global $mybb, $plugins;

function copy_file_to_cdn($file_path = '', &$uploaded_path = null)
{
global $mybb, $plugins;





	$success = false;

$file_path = (string)$file_path;

	$success = false;

$file_path = (string)$file_path;

Zeile 8470Zeile 8713
	}

return $success;

	}

return $success;

}

/**

}

/**

 * Validate an url

 * Validate an url

 *

 *

 * @param string $url The url to validate.
* @param bool $relative_path Whether or not the url could be a relative path.

 * @param string $url The url to validate.
* @param bool $relative_path Whether or not the url could be a relative path.

 
 * @param bool $allow_local Whether or not the url could be pointing to local networks.

 *
* @return bool Whether this is a valid url.
*/

 *
* @return bool Whether this is a valid url.
*/

function my_validate_url($url, $relative_path=false)

function my_validate_url($url, $relative_path=false, $allow_local=false)

{

{

	if($relative_path && my_substr($url, 0, 1) == '/' || preg_match('_^(?:(?:https?|ftp)://)(?:\S+(?::\S*)?@)?(?:(?!(?:10|127)(?:\.\d{1,3}){3})(?!(?:169\.254|192\.168)(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z\x{00a1}-\x{ffff}0-9]-*)*[a-z\x{00a1}-\x{ffff}0-9]+)(?:\.(?:[a-z\x{00a1}-\x{ffff}0-9]-*)*[a-z\x{00a1}-\x{ffff}0-9]+)*(?:\.(?:[a-z\x{00a1}-\x{ffff}]{2,}))\.?)(?::\d{2,5})?(?:[/?#]\S*)?$_iuS', $url))










	if($allow_local)
{
$regex = '_^(?:(?:https?|ftp)://)(?:\S+(?::\S*)?@)?(?:(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:localhost|(?:(?:[a-z\x{00a1}-\x{ffff}0-9]-*)*[a-z\x{00a1}-\x{ffff}0-9]+)(?:\.(?:[a-z\x{00a1}-\x{ffff}0-9]-*)*[a-z\x{00a1}-\x{ffff}0-9]+)*(?:\.(?:[a-z\x{00a1}-\x{ffff}]{2,}))\.?))(?::\d{2,5})?(?:[/?#]\S*)?$_iuS';
}
else
{
$regex = '_^(?:(?:https?|ftp)://)(?:\S+(?::\S*)?@)?(?:(?!(?:10|127)(?:\.\d{1,3}){3})(?!(?:169\.254|192\.168)(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z\x{00a1}-\x{ffff}0-9]-*)*[a-z\x{00a1}-\x{ffff}0-9]+)(?:\.(?:[a-z\x{00a1}-\x{ffff}0-9]-*)*[a-z\x{00a1}-\x{ffff}0-9]+)*(?:\.(?:[a-z\x{00a1}-\x{ffff}]{2,}))\.?)(?::\d{2,5})?(?:[/?#]\S*)?$_iuS';
}

if($relative_path && my_substr($url, 0, 1) == '/' || preg_match($regex, $url))

	{
return true;
}

	{
return true;
}



 
	return false;

	return false;

}

/**

}

/**

 * Strip html tags from string, also removes <script> and <style> contents.

 * Strip html tags from string, also removes <script> and <style> contents.

 * 

 *

 * @param  string $string         String to stripe
* @param string $allowable_tags Allowed html tags

 * @param  string $string         String to stripe
* @param string $allowable_tags Allowed html tags

 * 

 *

 * @return string                 Striped string
*/
function my_strip_tags($string, $allowable_tags = '')

 * @return string                 Striped string
*/
function my_strip_tags($string, $allowable_tags = '')

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

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

 
}

/**
* Escapes a RFC 4180-compliant CSV string.
* Based on https://github.com/Automattic/camptix/blob/f80725094440bf09861383b8f11e96c177c45789/camptix.php#L2867
*
* @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
*/
function my_escape_csv($string, $escape_active_content=true)
{
if($escape_active_content)
{
$active_content_triggers = array('=', '+', '-', '@');
$delimiters = array(',', ';', ':', '|', '^', "\n", "\t", " ");

$first_character = mb_substr($string, 0, 1);

if(
in_array($first_character, $active_content_triggers, true) ||
in_array($first_character, $delimiters, true)
)
{
$string = "'".$string;
}

foreach($delimiters as $delimiter)
{
foreach($active_content_triggers as $trigger)
{
$string = str_replace($delimiter.$trigger, $delimiter."'".$trigger, $string);
}
}
}

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

return $string;

}

}