Vergleich inc/functions.php - 1.8.9 - 1.8.13

  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 343Zeile 343
	{
if(isset($mybb->user['uid']) && $mybb->user['uid'] != 0 && array_key_exists("timezone", $mybb->user))
{

	{
if(isset($mybb->user['uid']) && $mybb->user['uid'] != 0 && array_key_exists("timezone", $mybb->user))
{

			$offset = $mybb->user['timezone'];

			$offset = (float)$mybb->user['timezone'];

			$dstcorrection = $mybb->user['dst'];
}
elseif(defined("IN_ADMINCP"))
{

			$dstcorrection = $mybb->user['dst'];
}
elseif(defined("IN_ADMINCP"))
{

			$offset =  $mybbadmin['timezone'];

			$offset = (float)$mybbadmin['timezone'];

			$dstcorrection = $mybbadmin['dst'];
}
else
{

			$dstcorrection = $mybbadmin['dst'];
}
else
{

			$offset = $mybb->settings['timezoneoffset'];

			$offset = (float)$mybb->settings['timezoneoffset'];

			$dstcorrection = $mybb->settings['dstcorrection'];
}


			$dstcorrection = $mybb->settings['dstcorrection'];
}


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 3781Zeile 3820
	{
$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 3845
		"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);
}

}

/**

}

/**

Zeile 3821Zeile 3883
	elseif($reputation > 0)
{
$reputation_class = "reputation_positive";

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

	}
else
{

	}
else
{

		$reputation_class = "reputation_neutral";
}


		$reputation_class = "reputation_neutral";
}


Zeile 3853Zeile 3915

$warning_class = '';
if($level >= 80)


$warning_class = '';
if($level >= 80)

	{

	{

		$warning_class = "high_warning";

		$warning_class = "high_warning";

	}

	}

	else if($level >= 50)

	else if($level >= 50)

	{

	{

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

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

	}

	}

	else
{
$warning_class = "normal_warning";
}

	else
{
$warning_class = "normal_warning";
}





	eval("\$level = \"".$templates->get("postbit_warninglevel_formatted")."\";");
return $level;

	eval("\$level = \"".$templates->get("postbit_warninglevel_formatted")."\";");
return $level;

}


}


/**
* Fetch the IP address of the current user.
*

/**
* Fetch the IP address of the current user.
*

Zeile 3881Zeile 3943
function get_ip()
{
global $mybb, $plugins;

function get_ip()
{
global $mybb, $plugins;


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


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


if($mybb->settings['ip_forwarded_check'])
{


if($mybb->settings['ip_forwarded_check'])
{

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

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

		}

		}

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

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

Zeile 3909Zeile 3971
					break;
}
}

					break;
}
}

		}
}


		}
}


	if(!$ip)
{
if(isset($_SERVER['HTTP_CLIENT_IP']))

	if(!$ip)
{
if(isset($_SERVER['HTTP_CLIENT_IP']))

Zeile 3940Zeile 4002
	global $lang;

if(!is_numeric($size))

	global $lang;

if(!is_numeric($size))

	{
return $lang->na;
}

	{
return $lang->na;
}


// Yottabyte (1024 Zettabytes)
if($size >= 1208925819614629174706176)


// Yottabyte (1024 Zettabytes)
if($size >= 1208925819614629174706176)

Zeile 4099Zeile 4161
	$icon = htmlspecialchars_uni($icon);
eval("\$attachment_icon = \"".$templates->get("attachment_icon")."\";");
return $attachment_icon;

	$icon = htmlspecialchars_uni($icon);
eval("\$attachment_icon = \"".$templates->get("attachment_icon")."\";");
return $attachment_icon;

}


}


/**
* Get a list of the unviewable forums for the current user
*

/**
* Get a list of the unviewable forums for the current user
*

Zeile 4336Zeile 4398
				}
}
}

				}
}
}

	}


	}


	return 1;
}


	return 1;
}


Zeile 4347Zeile 4409
function reset_breadcrumb()
{
global $navbits;

function reset_breadcrumb()
{
global $navbits;





	$newnav[0]['name'] = $navbits[0]['name'];
$newnav[0]['url'] = $navbits[0]['url'];
if(!empty($navbits[0]['options']))

	$newnav[0]['name'] = $navbits[0]['name'];
$newnav[0]['url'] = $navbits[0]['url'];
if(!empty($navbits[0]['options']))

Zeile 4357Zeile 4419

unset($GLOBALS['navbits']);
$GLOBALS['navbits'] = $newnav;


unset($GLOBALS['navbits']);
$GLOBALS['navbits'] = $newnav;

}

}


/**
* Builds a URL to an archive mode page


/**
* Builds a URL to an archive mode page

Zeile 4367Zeile 4429
 * @return string The URL
*/
function build_archive_link($type="", $id=0)

 * @return string The URL
*/
function build_archive_link($type="", $id=0)

{

{

	global $mybb;

// If the server OS is not Windows and not Apache or the PHP is running as a CGI or we have defined ARCHIVE_QUERY_STRINGS, use query strings - DIRECTORY_SEPARATOR checks if running windows

	global $mybb;

// If the server OS is not Windows and not Apache or the PHP is running as a CGI or we have defined ARCHIVE_QUERY_STRINGS, use query strings - DIRECTORY_SEPARATOR checks if running windows

Zeile 4377Zeile 4439
		$base_url = $mybb->settings['bburl']."/archive/index.php/";
}
else

		$base_url = $mybb->settings['bburl']."/archive/index.php/";
}
else

	{

	{

		$base_url = $mybb->settings['bburl']."/archive/index.php?";
}


		$base_url = $mybb->settings['bburl']."/archive/index.php?";
}


Zeile 4416Zeile 4478

$phptime = format_time_duration($maintimer->totaltime - $db->query_time);
$query_time = format_time_duration($db->query_time);


$phptime = format_time_duration($maintimer->totaltime - $db->query_time);
$query_time = format_time_duration($db->query_time);





	$call_time = format_time_duration($cache->call_time);

$phpversion = PHP_VERSION;

	$call_time = format_time_duration($cache->call_time);

$phpversion = PHP_VERSION;

Zeile 4675Zeile 4737
	$stamp %= $msecs;
$seconds = $stamp;


	$stamp %= $msecs;
$seconds = $stamp;


	if($years == 1)


	// Prevent gross over accuracy ($options parameter will override these)
if($years > 0)

	{

	{

		$nicetime['years'] = "1".$lang_year;






		$options = array_merge(array(
'days' => false,
'hours' => false,
'minutes' => false,
'seconds' => false
), $options);

	}

	}

	else if($years > 1)

	elseif($months > 0)

	{

	{

		$nicetime['years'] = $years.$lang_years;
}

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

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

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







































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

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

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

if(!isset($options['days']) || $options['days'] !== false)
{
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 4750Zeile 4856
	if(is_array($nicetime))
{
return implode(", ", $nicetime);

	if(is_array($nicetime))
{
return implode(", ", $nicetime);

	}
}

	}
}


/**
* Select an alternating row colour based on the previous call to this function


/**
* Select an alternating row colour based on the previous call to this function

Zeile 4766Zeile 4872
	if($alttrow == "trow1" && !$reset)
{
$trow = "trow2";

	if($alttrow == "trow1" && !$reset)
{
$trow = "trow2";

	}

	}

	else
{
$trow = "trow1";

	else
{
$trow = "trow1";

Zeile 4807Zeile 4913
	if(is_array($groups))
{
$comma = '';

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

		foreach($groups as $gid)
{

		foreach($groups as $gid)
{

			if(trim($gid) != "" && $gid != $user['usergroup'] && !isset($donegroup[$gid]))
{
$groupslist .= $comma.$gid;

			if(trim($gid) != "" && $gid != $user['usergroup'] && !isset($donegroup[$gid]))
{
$groupslist .= $comma.$gid;

Zeile 5059Zeile 5165
		else
{
eval("\$themeselect = \"".$templates->get("usercp_themeselector")."\";");

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

		}

		}


return $themeselect;
}


return $themeselect;
}

Zeile 5104Zeile 5210
	}

return $s_theme;

	}

return $s_theme;

}

/**

}

/**

 * Custom function for htmlspecialchars which takes in to account unicode
*
* @param string $message The string to format

 * Custom function for htmlspecialchars which takes in to account unicode
*
* @param string $message The string to format

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

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

	}

	}


if(!isset($use_mb))
{


if(!isset($use_mb))
{

Zeile 5434Zeile 5540
 * @param int $tid The thread id for which to update the first post id.
*/
function update_first_post($tid)

 * @param int $tid The thread id for which to update the first post id.
*/
function update_first_post($tid)

{

{

	global $db;

$query = $db->query("

	global $db;

$query = $db->query("

Zeile 5669Zeile 5775
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 5816
	{
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 5781Zeile 5909
	global $mybb, $lang;

if(!$username && $uid == 0)

	global $mybb, $lang;

if(!$username && $uid == 0)

	{

	{

		// Return Guest phrase for no UID, no guest nickname

		// Return Guest phrase for no UID, no guest nickname

		return $lang->guest;

		return htmlspecialchars_uni($lang->guest);

	}
elseif($uid == 0)
{

	}
elseif($uid == 0)
{

Zeile 5796Zeile 5924
		if(!empty($target))
{
$target = " target=\"{$target}\"";

		if(!empty($target))
{
$target = " target=\"{$target}\"";

		}


		}


		if(!empty($onclick))
{
$onclick = " onclick=\"{$onclick}\"";

		if(!empty($onclick))
{
$onclick = " onclick=\"{$onclick}\"";

Zeile 5825Zeile 5953
	else
{
$link = str_replace("{fid}", $fid, FORUM_URL);

	else
{
$link = str_replace("{fid}", $fid, FORUM_URL);

		return htmlspecialchars_uni($link);
}

		return htmlspecialchars_uni($link);
}

}

/**

}

/**

Zeile 5840Zeile 5968
function get_thread_link($tid, $page=0, $action='')
{
if($page > 1)

function get_thread_link($tid, $page=0, $action='')
{
if($page > 1)

	{

	{

		if($action)

		if($action)

		{

		{

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

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

		}

		}

		else
{
$link = THREAD_URL_PAGED;
}
$link = str_replace("{tid}", $tid, $link);
$link = str_replace("{page}", $page, $link);

		else
{
$link = THREAD_URL_PAGED;
}
$link = str_replace("{tid}", $tid, $link);
$link = str_replace("{page}", $page, $link);

		return htmlspecialchars_uni($link);
}
else

		return htmlspecialchars_uni($link);
}
else

	{
if($action)

	{
if($action)

		{

		{

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

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

		}

		}

		else
{
$link = THREAD_URL;
}
$link = str_replace("{tid}", $tid, $link);

		else
{
$link = THREAD_URL;
}
$link = str_replace("{tid}", $tid, $link);

		return htmlspecialchars_uni($link);
}
}


		return htmlspecialchars_uni($link);
}
}


/**
* Build the post link.
*

/**
* Build the post link.
*

Zeile 5883Zeile 6011
	{
$link = str_replace("{tid}", $tid, THREAD_URL_POST);
$link = str_replace("{pid}", $pid, $link);

	{
$link = str_replace("{tid}", $tid, THREAD_URL_POST);
$link = str_replace("{pid}", $pid, $link);

		return htmlspecialchars_uni($link);

		return htmlspecialchars_uni($link);

	}
else
{

	}
else
{

Zeile 5897Zeile 6025
 *
* @param int $eid The event ID of the event
* @return string The URL of the event

 *
* @param int $eid The event ID of the event
* @return string The URL of the event

 */

 */

function get_event_link($eid)
{
$link = str_replace("{eid}", $eid, EVENT_URL);

function get_event_link($eid)
{
$link = str_replace("{eid}", $eid, EVENT_URL);

Zeile 6242Zeile 6370
		else
{
$failedtime = $mybb->cookies['failedlogin'];

		else
{
$failedtime = $mybb->cookies['failedlogin'];

		}

		}


$secondsleft = $mybb->settings['failedlogintime'] * 60 + $failedtime - $now;
$hoursleft = floor($secondsleft / 3600);


$secondsleft = $mybb->settings['failedlogintime'] * 60 + $failedtime - $now;
$hoursleft = floor($secondsleft / 3600);

Zeile 6253Zeile 6381
		if(empty($failedlogin))
{
my_setcookie('failedlogin', $now);

		if(empty($failedlogin))
{
my_setcookie('failedlogin', $now);

			if($fatal)
{
error($lang->sprintf($lang->failed_login_wait, $hoursleft, $minsleft, $secsleft));

			if($fatal)
{
error($lang->sprintf($lang->failed_login_wait, $hoursleft, $minsleft, $secsleft));

			}

return false;

			}

return false;

Zeile 6282Zeile 6410
			{
error($lang->sprintf($lang->failed_login_wait, $hoursleft, $minsleft, $secsleft));
}

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





			return false;
}
}

			return false;
}
}

Zeile 6296Zeile 6424
 *
* @param string $email The string to check.
* @return boolean True when valid, false when invalid.

 *
* @param string $email The string to check.
* @return boolean True when valid, false when invalid.

 */

 */

function validate_email_format($email)
{
if(strpos($email, ' ') !== false)

function validate_email_format($email)
{
if(strpos($email, ' ') !== false)

Zeile 6341Zeile 6469
{
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 6483
	}

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

// 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 6601
	}

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 6728Zeile 6857

$selected = str_replace("+", "", $selected);
foreach($timezones as $timezone => $label)


$selected = str_replace("+", "", $selected);
foreach($timezones as $timezone => $label)

	{

	{

		$selected_add = "";
if($selected == $timezone)
{

		$selected_add = "";
if($selected == $timezone)
{

Zeile 6777Zeile 6906
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;

			}
}
}

			}
}
}

Zeile 6831Zeile 6971

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 6869Zeile 7034
				if($matches)
{
$data = fetch_remote_file(trim(array_pop($matches)), $post_data, --$max_redirects);

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

				}
}
else
{

				}
}
else
{

				$data = $body;
}
}

				$data = $body;
}
}

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

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

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

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

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

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

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

			{

			{

				$url_components['port'] = 443;
}
}


				$url_components['port'] = 443;
}
}


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

		@stream_set_timeout($fp, 10);
if(!$fp)
{

Zeile 6935Zeile 7125
		if(!empty($post_body))
{
$headers[] = $post_body;

		if(!empty($post_body))
{
$headers[] = $post_body;

		}
else

		}
else

		{
// If we have no post body, we need to add an empty element to make sure we've got \r\n\r\n before the (non-existent) body starts
$headers[] = '';

		{
// If we have no post body, we need to add an empty element to make sure we've got \r\n\r\n before the (non-existent) body starts
$headers[] = '';

		}

		}


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


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

Zeile 6951Zeile 7141
		$data = null;

while(!feof($fp))

		$data = null;

while(!feof($fp))

		{

		{

			$data .= fgets($fp, 12800);
}
fclose($fp);

			$data .= fgets($fp, 12800);
}
fclose($fp);

Zeile 6962Zeile 7152
		$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 6977Zeile 7167
		}

return $data;

		}

return $data;

	}
else if(empty($post_data))
{
return @implode("", @file($url));

 
	}
else

	}
else

	{

	{

		return false;

		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 $path;
}

return false;

}

/**

}

/**

Zeile 6999Zeile 7231
	static $super_admins;

if(!isset($super_admins))

	static $super_admins;

if(!isset($super_admins))

	{

	{

		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;
}
else
{
return true;

		return false;
}
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 7028Zeile 7260
	global $mybb;

if(empty($groups))

	global $mybb;

if(empty($groups))

	{

	{

		return array();
}


		return array();
}


Zeile 7056Zeile 7288
			if(is_string($groups))
{
$groups = explode(',', $groups);

			if(is_string($groups))
{
$groups = explode(',', $groups);

			}
else
{

			}
else
{

				$groups = (array)$groups;
}
}

				$groups = (array)$groups;
}
}

Zeile 7088Zeile 7320
		if(is_array($escape))
{
function escaped_explode_escape($string)

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

			{

			{

				return preg_quote($string, "#");
}
$escape_preg = "(".implode("|", array_map("escaped_explode_escape", $escape)).")";

				return preg_quote($string, "#");
}
$escape_preg = "(".implode("|", array_map("escaped_explode_escape", $escape)).")";

Zeile 7118Zeile 7350
				{
if($string == "") continue;
$strings[] = trim($string);

				{
if($string == "") continue;
$strings[] = trim($string);

				}
}
}

				}
}
}

		$in_escape = !$in_escape;
}
if(!count($strings))

		$in_escape = !$in_escape;
}
if(!count($strings))

Zeile 7360Zeile 7592
		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;

Zeile 7392Zeile 7624

/**
* Converts a human readable IP address to its packed in_addr representation


/**
* Converts a human readable IP address to its packed in_addr representation

 *

 *

 * @param string $ip The IP to convert
* @return string IP in 32bit or 128bit binary format
*/

 * @param string $ip The IP to convert
* @return string IP in 32bit or 128bit binary format
*/

Zeile 7406Zeile 7638
	{
/**
* Replace inet_pton()

	{
/**
* Replace inet_pton()

		 *
* @category PHP

		 *
* @category PHP

		 * @package     PHP_Compat
* @license LGPL - http://www.gnu.org/licenses/lgpl.html
* @copyright 2004-2007 Aidan Lister <aidan@php.net>, Arpad Ray <arpad@php.net>

		 * @package     PHP_Compat
* @license LGPL - http://www.gnu.org/licenses/lgpl.html
* @copyright 2004-2007 Aidan Lister <aidan@php.net>, Arpad Ray <arpad@php.net>

Zeile 7422Zeile 7654
		}

$delim_count = substr_count($ip, ':');

		}

$delim_count = substr_count($ip, ':');

		if($delim_count < 1 || $delim_count > 7)

		if($delim_count < 1 || $delim_count > 7)

		{
return false;
}

		{
return false;
}

Zeile 7452Zeile 7684
function my_inet_ntop($ip)
{
if(function_exists('inet_ntop'))

function my_inet_ntop($ip)
{
if(function_exists('inet_ntop'))

	{

	{

		return @inet_ntop($ip);
}
else

		return @inet_ntop($ip);
}
else

Zeile 7480Zeile 7712
					array('::', '(int)"$1"?"$1":"0$1"'),
$r);
return $r;

					array('::', '(int)"$1"?"$1":"0$1"'),
$r);
return $r;

		}
return false;
}

		}
return false;
}

}

/**

}

/**

Zeile 7514Zeile 7746
			}
$upper = str_replace('*', '255', $ipaddress);
$lower = str_replace('*', '0', $ipaddress);

			}
$upper = str_replace('*', '255', $ipaddress);
$lower = str_replace('*', '0', $ipaddress);

		}

		}

		$upper = my_inet_pton($upper);
$lower = my_inet_pton($lower);
if($upper === false || $lower === false)

		$upper = my_inet_pton($upper);
$lower = my_inet_pton($lower);
if($upper === false || $lower === false)

Zeile 7544Zeile 7776
				// Invalid IP address
return false;
}

				// Invalid IP address
return false;
}

		}


		}


		/**
* Taken from: https://github.com/NewEraCracker/php_work/blob/master/ipRangeCalculate.php
* Author: NewEraCracker

		/**
* Taken from: https://github.com/NewEraCracker/php_work/blob/master/ipRangeCalculate.php
* Author: NewEraCracker

Zeile 7608Zeile 7840
function get_execution_time()
{
static $time_start;

function get_execution_time()
{
static $time_start;





	$time = microtime(true);



	$time = microtime(true);



Zeile 7640Zeile 7872
	global $mybb, $checksums, $bad_verify_files;

// We don't need to check these types of files

	global $mybb, $checksums, $bad_verify_files;

// We don't need to check these types of files

	$ignore = array(".", "..", ".svn", "config.php", "settings.php", "Thumb.db", "config.default.php", "lock", "htaccess.txt", "logo.gif", "logo.png");

	$ignore = array(".", "..", ".svn", "config.php", "settings.php", "Thumb.db", "config.default.php", "lock", "htaccess.txt", "htaccess-nginx.txt", "logo.gif", "logo.png");

	$ignore_ext = array("attach");

if(substr($path, -1, 1) == "/")

	$ignore_ext = array("attach");

if(substr($path, -1, 1) == "/")

Zeile 7852Zeile 8084
		$output = pack('H*', $output);

return $output;

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

return $output;

	}
else
{
return $output;
}
}

/**

	}
else
{
return $output;
}
}

/**

 * Returns a securely generated seed integer
*
* @return int An integer equivalent of a secure hexadecimal seed

 * Returns a securely generated seed integer
*
* @return int An integer equivalent of a secure hexadecimal seed

Zeile 8235Zeile 8467
 * @return bool True if PM sent
*/
function send_pm($pm, $fromid = 0, $admin_override=false)

 * @return bool True if PM sent
*/
function send_pm($pm, $fromid = 0, $admin_override=false)

{

{

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

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

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

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

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

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





				for($i = 1; $i < $num_args; $i++)
{
$lang_string = str_replace('{'.$i.'}', $pm[$key][$i], $lang_string);

				for($i = 1; $i < $num_args; $i++)
{
$lang_string = str_replace('{'.$i.'}', $pm[$key][$i], $lang_string);

Zeile 8295Zeile 8527
	require_once MYBB_ROOT."inc/datahandlers/pm.php";

$pmhandler = new PMDataHandler();

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

$pmhandler = new PMDataHandler();





	$subject = $pm['subject'];
$message = $pm['message'];
$toid = $pm['touid'];

	$subject = $pm['subject'];
$message = $pm['message'];
$toid = $pm['touid'];





	// Our recipients
if(is_array($toid))
{
$recipients_to = $toid;

	// Our recipients
if(is_array($toid))
{
$recipients_to = $toid;

	}

	}

	else
{
$recipients_to = array($toid);

	else
{
$recipients_to = array($toid);

	}

$recipients_bcc = array();

	}

$recipients_bcc = array();


// Determine user ID
if((int)$fromid == 0)


// Determine user ID
if((int)$fromid == 0)

Zeile 8356Zeile 8588
	if($pmhandler->validate_pm())
{
$pmhandler->insert_pm();

	if($pmhandler->validate_pm())
{
$pmhandler->insert_pm();

		return true;
}

return false;
}

		return true;
}

return false;
}


/**
* Log a user spam block from StopForumSpam (or other spam service providers...)


/**
* Log a user spam block from StopForumSpam (or other spam service providers...)

Zeile 8376Zeile 8608
	global $db, $session;

if(!is_array($data))

	global $db, $session;

if(!is_array($data))

	{

	{

		$data = array($data);
}


		$data = array($data);
}


Zeile 8439Zeile 8671
			if(!($dir_exists = is_dir($cdn_upload_path)))
{
$dir_exists = @mkdir($cdn_upload_path, 0777, true);

			if(!($dir_exists = is_dir($cdn_upload_path)))
{
$dir_exists = @mkdir($cdn_upload_path, 0777, true);

			}


			}


			if($dir_exists)
{
if(($cdn_upload_path = realpath($cdn_upload_path)) !== false)

			if($dir_exists)
{
if(($cdn_upload_path = realpath($cdn_upload_path)) !== false)

Zeile 8452Zeile 8684
						$uploaded_path = $cdn_upload_path;
}
}

						$uploaded_path = $cdn_upload_path;
}
}

			}
}


			}
}


		if(is_object($plugins))
{
$hook_args = array(

		if(is_object($plugins))
{
$hook_args = array(

Zeile 8464Zeile 8696
				'uploaded_path' => &$uploaded_path,
'success' => &$success,
);

				'uploaded_path' => &$uploaded_path,
'success' => &$success,
);





			$plugins->run_hooks('copy_file_to_cdn_end', $hook_args);
}
}

return $success;

			$plugins->run_hooks('copy_file_to_cdn_end', $hook_args);
}
}

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

/**
* Strip html tags from string, also removes <script> and <style> contents.
*
* @param string $string String to stripe
* @param string $allowable_tags Allowed html tags
*
* @return string Striped string
*/
function my_strip_tags($string, $allowable_tags = '')
{
$pattern = array(
'@(&lt;)style[^(&gt;)]*?(&gt;).*?(&lt;)/style(&gt;)@siu',
'@(&lt;)script[^(&gt;)]*?.*?(&lt;)/script(&gt;)@siu',
'@<style[^>]*?>.*?</style>@siu',
'@<script[^>]*?.*?</script>@siu',
);
$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)

	{

	{

		return true;




















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

	}


	}


	return false;



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

return $string;

}

}