Vergleich inc/functions.php - 1.8.8 - 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 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 1868Zeile 1907
	if($httponly == true)
{
$cookie .= "; HttpOnly";

	if($httponly == true)
{
$cookie .= "; HttpOnly";

 
	}

if($mybb->settings['cookiesecureflag'])
{
$cookie .= "; Secure";

	}

$mybb->cookies[$name] = $value;

	}

$mybb->cookies[$name] = $value;

Zeile 2067Zeile 2111
					if(count($list) < end($expected))
{
// array size less than expected

					if(count($list) < end($expected))
{
// array size less than expected

						return false;

						return false;

					}

unset($list);

					}

unset($list);

Zeile 2091Zeile 2135
					if(count($list) >= end($expected))
{
// array size exceeds expected length

					if(count($list) >= end($expected))
{
// array size exceeds expected length

						return false;

						return false;

					}

$key = $value;

					}

$key = $value;

Zeile 2115Zeile 2159
					$list = &$data;
$expected[] = $expectedLength;
$state = 2;

					$list = &$data;
$expected[] = $expectedLength;
$state = 2;

					break;
}

					break;
}

				if($type != '}')
{
$data = $value;

				if($type != '}')
{
$data = $value;

Zeile 2133Zeile 2177
	{
// trailing data in input
return false;

	{
// trailing data in input
return false;

	}

	}

	return $data;
}


	return $data;
}


Zeile 2401Zeile 2445
					elseif($new_stats[$counter] < 0)
{
$new_stats[$counter] = 0;

					elseif($new_stats[$counter] < 0)
{
$new_stats[$counter] = 0;

					}
}
}
else

					}
}
}
else

			{
$new_stats[$counter] = $changes[$counter];
// Less than 0? That's bad

			{
$new_stats[$counter] = $changes[$counter];
// Less than 0? That's bad

Zeile 2436Zeile 2480
		if(is_array($stats))
{
$stats = array_merge($stats, $new_stats); // Overwrite changed values

		if(is_array($stats))
{
$stats = array_merge($stats, $new_stats); // Overwrite changed values

		}

		}

		else
{
$stats = $new_stats;

		else
{
$stats = $new_stats;

Zeile 2473Zeile 2517
	// Fetch above counters for this forum
$query = $db->simple_select("forums", implode(",", $counters), "fid='{$fid}'");
$forum = $db->fetch_array($query);

	// Fetch above counters for this forum
$query = $db->simple_select("forums", implode(",", $counters), "fid='{$fid}'");
$forum = $db->fetch_array($query);


foreach($counters as $counter)
{
if(array_key_exists($counter, $changes))
{
if(substr($changes[$counter], 0, 2) == "+-")
{
$changes[$counter] = substr($changes[$counter], 1);
}
// Adding or subtracting from previous value?
if(substr($changes[$counter], 0, 1) == "+" || substr($changes[$counter], 0, 1) == "-")
{


foreach($counters as $counter)
{
if(array_key_exists($counter, $changes))
{
if(substr($changes[$counter], 0, 2) == "+-")
{
$changes[$counter] = substr($changes[$counter], 1);
}
// Adding or subtracting from previous value?
if(substr($changes[$counter], 0, 1) == "+" || substr($changes[$counter], 0, 1) == "-")
{

				if((int)$changes[$counter] != 0)
{
$update_query[$counter] = $forum[$counter] + $changes[$counter];

				if((int)$changes[$counter] != 0)
{
$update_query[$counter] = $forum[$counter] + $changes[$counter];

Zeile 2719Zeile 2763
		ORDER BY p.dateline ASC
LIMIT 1
");

		ORDER BY p.dateline ASC
LIMIT 1
");

	$firstpost = $db->fetch_array($query);

$db->free_result($query);

	$firstpost = $db->fetch_array($query);

$db->free_result($query);


if(empty($firstpost['username']))


if(empty($firstpost['username']))

	{

	{

		$firstpost['username'] = $firstpost['postusername'];
}

if(empty($lastpost['username']))
{
$lastpost['username'] = $lastpost['postusername'];

		$firstpost['username'] = $firstpost['postusername'];
}

if(empty($lastpost['username']))
{
$lastpost['username'] = $lastpost['postusername'];

	}

	}


if(empty($lastpost['dateline']))
{


if(empty($lastpost['dateline']))
{

Zeile 2781Zeile 2825
			if(substr($changes[$counter], 0, 2) == "+-")
{
$changes[$counter] = substr($changes[$counter], 1);

			if(substr($changes[$counter], 0, 2) == "+-")
{
$changes[$counter] = substr($changes[$counter], 1);

			}

			}

			// Adding or subtracting from previous value?
if(substr($changes[$counter], 0, 1) == "+" || substr($changes[$counter], 0, 1) == "-")
{

			// Adding or subtracting from previous value?
if(substr($changes[$counter], 0, 1) == "+" || substr($changes[$counter], 0, 1) == "-")
{

Zeile 2791Zeile 2835
				}
}
else

				}
}
else

			{

			{

				$update_query[$counter] = $changes[$counter];

				$update_query[$counter] = $changes[$counter];

			}

			}


// Less than 0? That's bad
if(isset($update_query[$counter]) && $update_query[$counter] < 0)
{
$update_query[$counter] = 0;


// Less than 0? That's bad
if(isset($update_query[$counter]) && $update_query[$counter] < 0)
{
$update_query[$counter] = 0;

			}
}
}

			}
}
}


$db->free_result($query);



$db->free_result($query);


Zeile 3006Zeile 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))
{
$groupscache = $cache->read("usergroups");
}

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

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

	static $formattednames = array();

















	if($userin == 0)

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

	{

	{

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

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


		$format = "{username}";

		$format = "{username}";

	}

$format = stripslashes($format);

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





















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

$format = $parameters['format'];

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

return $formattednames[$username];
}


/**
* Formats an avatar to a certain dimension
*

/**
* Formats an avatar to a certain dimension
*

Zeile 3048Zeile 3108
	if(!isset($avatars))
{
$avatars = array();

	if(!isset($avatars))
{
$avatars = array();

 
	}

if(my_strpos($avatar, '://') !== false && !$mybb->settings['allowremoteavatars'])
{
// Remote avatar, but remote avatars are disallowed.
$avatar = null;

	}

if(!$avatar)

	}

if(!$avatar)

Zeile 3770Zeile 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 3788Zeile 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);
}

}

/**

}

/**

Zeile 3810Zeile 3899
	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 3842Zeile 3931

$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 3870Zeile 3959
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 3880Zeile 3969
		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 3898Zeile 3987
					break;
}
}

					break;
}
}

		}
}


		}
}


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

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

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

	{

	{

		$size = my_number_format(round(($size / 1208925819614629174706176), 2))." ".$lang->size_yb;
}
// Zetabyte (1024 Exabytes)
elseif($size >= 1180591620717411303424)
{
$size = my_number_format(round(($size / 1180591620717411303424), 2))." ".$lang->size_zb;

		$size = my_number_format(round(($size / 1208925819614629174706176), 2))." ".$lang->size_yb;
}
// Zetabyte (1024 Exabytes)
elseif($size >= 1180591620717411303424)
{
$size = my_number_format(round(($size / 1180591620717411303424), 2))." ".$lang->size_zb;

	}

	}

	// Exabyte (1024 Petabytes)
elseif($size >= 1152921504606846976)

	// Exabyte (1024 Petabytes)
elseif($size >= 1152921504606846976)

	{

	{

		$size = my_number_format(round(($size / 1152921504606846976), 2))." ".$lang->size_eb;
}
// Petabyte (1024 Terabytes)
elseif($size >= 1125899906842624)
{
$size = my_number_format(round(($size / 1125899906842624), 2))." ".$lang->size_pb;

		$size = my_number_format(round(($size / 1152921504606846976), 2))." ".$lang->size_eb;
}
// Petabyte (1024 Terabytes)
elseif($size >= 1125899906842624)
{
$size = my_number_format(round(($size / 1125899906842624), 2))." ".$lang->size_pb;

	}

	}

	// Terabyte (1024 Gigabytes)
elseif($size >= 1099511627776)

	// Terabyte (1024 Gigabytes)
elseif($size >= 1099511627776)

	{

	{

		$size = my_number_format(round(($size / 1099511627776), 2))." ".$lang->size_tb;
}
// Gigabyte (1024 Megabytes)
elseif($size >= 1073741824)
{
$size = my_number_format(round(($size / 1073741824), 2))." ".$lang->size_gb;

		$size = my_number_format(round(($size / 1099511627776), 2))." ".$lang->size_tb;
}
// Gigabyte (1024 Megabytes)
elseif($size >= 1073741824)
{
$size = my_number_format(round(($size / 1073741824), 2))." ".$lang->size_gb;

	}

	}

	// Megabyte (1024 Kilobytes)
elseif($size >= 1048576)

	// Megabyte (1024 Kilobytes)
elseif($size >= 1048576)

	{

	{

		$size = my_number_format(round(($size / 1048576), 2))." ".$lang->size_mb;
}
// Kilobyte (1024 bytes)
elseif($size >= 1024)
{
$size = my_number_format(round(($size / 1024), 2))." ".$lang->size_kb;

		$size = my_number_format(round(($size / 1048576), 2))." ".$lang->size_mb;
}
// Kilobyte (1024 bytes)
elseif($size >= 1024)
{
$size = my_number_format(round(($size / 1024), 2))." ".$lang->size_kb;

	}

	}

	elseif($size == 0)
{
$size = "0 ".$lang->size_bytes;

	elseif($size == 0)
{
$size = "0 ".$lang->size_bytes;

Zeile 4011Zeile 4100
	else
{
$time = round($time, 3)." seconds";

	else
{
$time = round($time, 3)." seconds";

	}


	}


	return $time;
}


	return $time;
}


Zeile 4029Zeile 4118
	if(!$attachtypes)
{
$attachtypes = $cache->read("attachtypes");

	if(!$attachtypes)
{
$attachtypes = $cache->read("attachtypes");

	}

$ext = my_strtolower($ext);


	}

$ext = my_strtolower($ext);


	if($attachtypes[$ext]['icon'])
{
static $attach_icons_schemes = array();

	if($attachtypes[$ext]['icon'])
{
static $attach_icons_schemes = array();

Zeile 4042Zeile 4131
			if(!empty($attach_icons_schemes[$ext]['scheme']))
{
$attach_icons_schemes[$ext] = $attachtypes[$ext]['icon'];

			if(!empty($attach_icons_schemes[$ext]['scheme']))
{
$attach_icons_schemes[$ext] = $attachtypes[$ext]['icon'];

			}

			}

			elseif(defined("IN_ADMINCP"))
{
$attach_icons_schemes[$ext] = str_replace("{theme}", "", $attachtypes[$ext]['icon']);

			elseif(defined("IN_ADMINCP"))
{
$attach_icons_schemes[$ext] = str_replace("{theme}", "", $attachtypes[$ext]['icon']);

Zeile 4052Zeile 4141
				}
}
elseif(defined("IN_PORTAL"))

				}
}
elseif(defined("IN_PORTAL"))

			{

			{

				global $change_dir;
$attach_icons_schemes[$ext] = $change_dir."/".str_replace("{theme}", $theme['imgdir'], $attachtypes[$ext]['icon']);

				global $change_dir;
$attach_icons_schemes[$ext] = $change_dir."/".str_replace("{theme}", $theme['imgdir'], $attachtypes[$ext]['icon']);

				$attach_icons_schemes[$ext] = $mybb->get_asset_url($attach_icons_schemes[$ext]);
}

				$attach_icons_schemes[$ext] = $mybb->get_asset_url($attach_icons_schemes[$ext]);
}

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

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

		}

		}


$icon = $attach_icons_schemes[$ext];



$icon = $attach_icons_schemes[$ext];


Zeile 4092Zeile 4181

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


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

 *

 *

 * @param boolean $only_readable_threads Set to true to only fetch those forums for which users can actually read a thread in.
* @return string Comma separated values list of the forum IDs which the user cannot view
*/

 * @param boolean $only_readable_threads Set to true to only fetch those forums for which users can actually read a thread in.
* @return string Comma separated values list of the forum IDs which the user cannot view
*/

Zeile 4120Zeile 4209
		else
{
$perms = $mybb->usergroup;

		else
{
$perms = $mybb->usergroup;

		}

$pwverified = 1;

		}

$pwverified = 1;


if($forum['password'] != "")
{


if($forum['password'] != "")
{

Zeile 4132Zeile 4221
			}

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

			}

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

		}

		}

		else
{
// Check parents for passwords

		else
{
// Check parents for passwords

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


/**
* Build the breadcrumb navigation trail from the specified items

Zeile 4332Zeile 4421

/**
* Resets the breadcrumb navigation to the first item, and clears the rest


/**
* Resets the breadcrumb navigation to the first item, and clears the rest

 */

 */

function reset_breadcrumb()
{
global $navbits;

function reset_breadcrumb()
{
global $navbits;

Zeile 4342Zeile 4431
	if(!empty($navbits[0]['options']))
{
$newnav[0]['options'] = $navbits[0]['options'];

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

	}

	}


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


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

Zeile 4362Zeile 4451
	// 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
//if((DIRECTORY_SEPARATOR == '\\' && is_numeric(stripos($_SERVER['SERVER_SOFTWARE'], "apache")) == false) || is_numeric(stripos(SAPI_NAME, "cgi")) !== false || defined("ARCHIVE_QUERY_STRINGS"))
if($mybb->settings['seourls_archive'] == 1)

	// 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
//if((DIRECTORY_SEPARATOR == '\\' && is_numeric(stripos($_SERVER['SERVER_SOFTWARE'], "apache")) == false) || is_numeric(stripos(SAPI_NAME, "cgi")) !== false || defined("ARCHIVE_QUERY_STRINGS"))
if($mybb->settings['seourls_archive'] == 1)

	{

	{

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

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

Zeile 4402Zeile 4491

$percentphp = number_format((($phptime/$maintimer->totaltime)*100), 2);
$percentsql = number_format((($query_time/$maintimer->totaltime)*100), 2);


$percentphp = number_format((($phptime/$maintimer->totaltime)*100), 2);
$percentsql = number_format((($query_time/$maintimer->totaltime)*100), 2);





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

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





	$phpversion = PHP_VERSION;

$serverload = get_server_load();

	$phpversion = PHP_VERSION;

$serverload = get_server_load();





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

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

Zeile 4458Zeile 4547
	echo "<td bgcolor=\"#fefefe\" width=\"25%\"><span style=\"font-family: tahoma; font-size: 12px;\">$phpversion</span></td>\n";
echo "<td bgcolor=\"#efefef\" width=\"25%\"><b><span style=\"font-family: tahoma; font-size: 12px;\">Server Load:</span></b></td>\n";
echo "<td bgcolor=\"#fefefe\" width=\"25%\"><span style=\"font-family: tahoma; font-size: 12px;\">$serverload</span></td>\n";

	echo "<td bgcolor=\"#fefefe\" width=\"25%\"><span style=\"font-family: tahoma; font-size: 12px;\">$phpversion</span></td>\n";
echo "<td bgcolor=\"#efefef\" width=\"25%\"><b><span style=\"font-family: tahoma; font-size: 12px;\">Server Load:</span></b></td>\n";
echo "<td bgcolor=\"#fefefe\" width=\"25%\"><span style=\"font-family: tahoma; font-size: 12px;\">$serverload</span></td>\n";

	echo "</tr>\n";

	echo "</tr>\n";

	echo "<tr>\n";
echo "<td bgcolor=\"#efefef\" width=\"25%\"><b><span style=\"font-family: tahoma; font-size: 12px;\">GZip Encoding Status:</span></b></td>\n";
echo "<td bgcolor=\"#fefefe\" width=\"25%\"><span style=\"font-family: tahoma; font-size: 12px;\">$gzipen</span></td>\n";

	echo "<tr>\n";
echo "<td bgcolor=\"#efefef\" width=\"25%\"><b><span style=\"font-family: tahoma; font-size: 12px;\">GZip Encoding Status:</span></b></td>\n";
echo "<td bgcolor=\"#fefefe\" width=\"25%\"><span style=\"font-family: tahoma; font-size: 12px;\">$gzipen</span></td>\n";

Zeile 4468Zeile 4557

$memory_usage = get_memory_usage();
if(!$memory_usage)


$memory_usage = get_memory_usage();
if(!$memory_usage)

	{

	{

		$memory_usage = $lang->unknown;
}
else
{
$memory_usage = get_friendly_size($memory_usage)." ({$memory_usage} bytes)";

		$memory_usage = $lang->unknown;
}
else
{
$memory_usage = get_friendly_size($memory_usage)." ({$memory_usage} bytes)";

	}

	}

	$memory_limit = @ini_get("memory_limit");
echo "<tr>\n";
echo "<td bgcolor=\"#EFEFEF\" width=\"25%\"><b><span style=\"font-family: tahoma; font-size: 12px;\">Memory Usage:</span></b></td>\n";

	$memory_limit = @ini_get("memory_limit");
echo "<tr>\n";
echo "<td bgcolor=\"#EFEFEF\" width=\"25%\"><b><span style=\"font-family: tahoma; font-size: 12px;\">Memory Usage:</span></b></td>\n";

Zeile 4505Zeile 4594
	echo "<h2>Template Statistics</h2>\n";

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

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

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

	{

	{

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

Zeile 4536Zeile 4625

/**
* Outputs the correct page headers.


/**
* Outputs the correct page headers.

 */

 */

function send_page_headers()
{
global $mybb;

function send_page_headers()
{
global $mybb;

Zeile 4664Zeile 4753
	$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 4713Zeile 4846
	}

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

	}

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

	{

	{

		if($minutes == 1)
{
$nicetime['minutes'] = "1".$lang_minute;

		if($minutes == 1)
{
$nicetime['minutes'] = "1".$lang_minute;

Zeile 4799Zeile 4932
		foreach($groups as $gid)
{
if(trim($gid) != "" && $gid != $user['usergroup'] && !isset($donegroup[$gid]))

		foreach($groups as $gid)
{
if(trim($gid) != "" && $gid != $user['usergroup'] && !isset($donegroup[$gid]))

			{
$groupslist .= $comma.$gid;
$comma = ",";
$donegroup[$gid] = 1;

			{
$groupslist .= $comma.$gid;
$comma = ",";
$donegroup[$gid] = 1;

			}
}
}

			}
}
}

Zeile 4816Zeile 4949
	else
{
return false;

	else
{
return false;

	}
}


	}
}


/**
* Remove a user from a specific additional user group
*

/**
* Remove a user from a specific additional user group
*

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

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





	$user = get_user($uid);

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

	$user = get_user($uid);

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





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

if(is_array($groups))

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

if(is_array($groups))

Zeile 4847Zeile 4980
				$comma = ",";
$donegroup[$gid] = 1;
}

				$comma = ",";
$donegroup[$gid] = 1;
}

		}
}


		}
}


	$dispupdate = "";
if($leavegroup == $user['displaygroup'])
{

	$dispupdate = "";
if($leavegroup == $user['displaygroup'])
{

Zeile 4881Zeile 5014
	}

if(!empty($_SERVER['SCRIPT_NAME']))

	}

if(!empty($_SERVER['SCRIPT_NAME']))

	{

	{

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

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

Zeile 4926Zeile 5059
				}

$form_html .= "<input type=\"hidden\" name=\"".htmlspecialchars_uni($name)."\" value=\"".htmlspecialchars_uni($value)."\" />\n";

				}

$form_html .= "<input type=\"hidden\" name=\"".htmlspecialchars_uni($name)."\" value=\"".htmlspecialchars_uni($value)."\" />\n";

			}
}

			}
}


return array('location' => $location, 'form_html' => $form_html, 'form_method' => $mybb->request_method);
}


return array('location' => $location, 'form_html' => $form_html, 'form_method' => $mybb->request_method);
}

Zeile 4943Zeile 5076
		}

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

		}

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

		{

		{

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

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





			foreach($post_array as $var)

			foreach($post_array as $var)

			{

			{

				if(isset($_POST[$var]))

				if(isset($_POST[$var]))

				{

				{

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

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

Zeile 4959Zeile 5092
				if(strpos($location, "?") === false)
{
$location .= "?";

				if(strpos($location, "?") === false)
{
$location .= "?";

				}

				}

				else
{
$location .= "&amp;";

				else
{
$location .= "&amp;";

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

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

				}

				}


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


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

Zeile 5051Zeile 5184
		}

return $themeselect;

		}

return $themeselect;

	}
else

	}
else

	{
return false;
}

	{
return false;
}

Zeile 5423Zeile 5556
 * @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("

		SELECT u.uid, u.username, p.pid, p.username AS postusername, p.dateline
FROM ".TABLE_PREFIX."posts p
LEFT JOIN ".TABLE_PREFIX."users u ON (u.uid=p.uid)

		SELECT u.uid, u.username, p.pid, p.username AS postusername, p.dateline
FROM ".TABLE_PREFIX."posts p
LEFT JOIN ".TABLE_PREFIX."users u ON (u.uid=p.uid)

Zeile 5441Zeile 5574
		$firstpost['username'] = $firstpost['postusername'];
}
$firstpost['username'] = $db->escape_string($firstpost['username']);

		$firstpost['username'] = $firstpost['postusername'];
}
$firstpost['username'] = $db->escape_string($firstpost['username']);


$update_array = array(


$update_array = array(

		'firstpost' => (int)$firstpost['pid'],
'username' => $firstpost['username'],
'uid' => (int)$firstpost['uid'],

		'firstpost' => (int)$firstpost['pid'],
'username' => $firstpost['username'],
'uid' => (int)$firstpost['uid'],

Zeile 5473Zeile 5606
	if(empty($lastpost['username']))
{
$lastpost['username'] = $lastpost['postusername'];

	if(empty($lastpost['username']))
{
$lastpost['username'] = $lastpost['postusername'];

	}

	}


if(empty($lastpost['dateline']))
{


if(empty($lastpost['dateline']))
{

Zeile 5551Zeile 5684
	if($handle_entities)
{
$string = unhtmlentities($string);

	if($handle_entities)
{
$string = unhtmlentities($string);

	}

	}

	if(function_exists("mb_substr"))
{
if($length != null)

	if(function_exists("mb_substr"))
{
if($length != null)

Zeile 5658Zeile 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 5699Zeile 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 5713Zeile 5868
	$event['username'] = format_name($event['username'], $event['usergroup'], $event['displaygroup']);
$event_poster = build_profile_link($event['username'], $event['author']);
return $event_poster;

	$event['username'] = format_name($event['username'], $event['usergroup'], $event['displaygroup']);
$event_poster = build_profile_link($event['username'], $event['author']);
return $event_poster;

}


}


/**
* Get the event date.
*

/**
* Get the event date.
*

Zeile 5772Zeile 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 5804Zeile 5959
 * @return string The url to the forum.
*/
function get_forum_link($fid, $page=0)

 * @return string The url to the forum.
*/
function get_forum_link($fid, $page=0)

{

{

	if($page > 0)
{
$link = str_replace("{fid}", $fid, FORUM_URL_PAGED);

	if($page > 0)
{
$link = str_replace("{fid}", $fid, FORUM_URL_PAGED);

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

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

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

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

		else
{
$link = THREAD_URL_PAGED;

		else
{
$link = THREAD_URL_PAGED;

Zeile 5865Zeile 6020
 * @param int $pid The post ID of the post
* @param int $tid The thread id of the post.
* @return string The url to the post.

 * @param int $pid The post ID of the post
* @param int $tid The thread id of the post.
* @return string The url to the post.

 */

 */

function get_post_link($pid, $tid=0)
{
if($tid > 0)

function get_post_link($pid, $tid=0)
{
if($tid > 0)

	{

	{

		$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
{
$link = str_replace("{pid}", $pid, POST_URL);

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

		return htmlspecialchars_uni($link);
}
}


		return htmlspecialchars_uni($link);
}
}


/**
* Build the event link.
*

/**
* Build the event link.
*

Zeile 5909Zeile 6064
		$link = str_replace("{month}", $month, CALENDAR_URL_DAY);
$link = str_replace("{year}", $year, $link);
$link = str_replace("{day}", $day, $link);

		$link = str_replace("{month}", $month, CALENDAR_URL_DAY);
$link = str_replace("{year}", $year, $link);
$link = str_replace("{day}", $day, $link);

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

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

	else if($month > 0)

	else if($month > 0)

	{

	{

		$link = str_replace("{month}", $month, CALENDAR_URL_MONTH);
$link = str_replace("{year}", $year, $link);
$link = str_replace("{calendar}", $calendar, $link);

		$link = str_replace("{month}", $month, CALENDAR_URL_MONTH);
$link = str_replace("{year}", $year, $link);
$link = str_replace("{calendar}", $calendar, $link);

		return htmlspecialchars_uni($link);

		return htmlspecialchars_uni($link);

	}
/* Not implemented
else if($year > 0)

	}
/* Not implemented
else if($year > 0)

	{

	{

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

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

	}
}


	}
}


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

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

Zeile 6007Zeile 6162
		default:
$field = 'LOWER(username)';
$efield = 'LOWER(email)';

		default:
$field = 'LOWER(username)';
$efield = 'LOWER(email)';

			break;
}

			break;
}


switch($options['username_method'])
{


switch($options['username_method'])
{

Zeile 6054Zeile 6209
	if(!isset($forum_cache) || is_array($forum_cache))
{
$forum_cache = $cache->read("forums");

	if(!isset($forum_cache) || is_array($forum_cache))
{
$forum_cache = $cache->read("forums");

	}

	}


if(empty($forum_cache[$fid]))
{


if(empty($forum_cache[$fid]))
{

Zeile 6069Zeile 6224
			foreach($parents as $parent)
{
if($forum_cache[$parent]['active'] == 0)

			foreach($parents as $parent)
{
if($forum_cache[$parent]['active'] == 0)

				{

				{

					return false;
}
}

					return false;
}
}

Zeile 6110Zeile 6265
		else
{
$thread_cache[$tid] = false;

		else
{
$thread_cache[$tid] = false;

			return false;
}
}
}


			return false;
}
}
}


/**
* Get the post of a post id.
*

/**
* Get the post of a post id.
*

Zeile 6160Zeile 6315
	global $forum_cache, $cache;

if(!$forum_cache)

	global $forum_cache, $cache;

if(!$forum_cache)

	{

	{

		cache_forums();

		cache_forums();

	}

	}


$inactive = array();



$inactive = array();


Zeile 6176Zeile 6331
				if(my_strpos(",".$forum1['parentlist'].",", ",".$fid.",") !== false && !in_array($fid1, $inactive))
{
$inactive[] = $fid1;

				if(my_strpos(",".$forum1['parentlist'].",", ",".$fid.",") !== false && !in_array($fid1, $inactive))
{
$inactive[] = $fid1;

				}
}
}
}

				}
}
}
}


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



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


Zeile 6193Zeile 6348
 * @return bool|int Number of logins when success, false if failed.
*/
function login_attempt_check($fatal = true)

 * @return bool|int Number of logins when success, false if failed.
*/
function login_attempt_check($fatal = true)

{

{

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

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

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

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

Zeile 6242Zeile 6397
		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));
}

return false;
}


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

return false;
}


		// Work out if the user has waited long enough before letting them login again
if($mybb->cookies['failedlogin'] < ($now - $mybb->settings['failedlogintime'] * 60))
{

		// Work out if the user has waited long enough before letting them login again
if($mybb->cookies['failedlogin'] < ($now - $mybb->settings['failedlogintime'] * 60))
{

Zeile 6263Zeile 6418
				$db->update_query("users", $update_array, "uid = '{$mybb->user['uid']}'");
}
return 1;

				$db->update_query("users", $update_array, "uid = '{$mybb->user['uid']}'");
}
return 1;

		}

		}

		// Not waited long enough
else if($mybb->cookies['failedlogin'] > ($now - $mybb->settings['failedlogintime'] * 60))
{

		// Not waited long enough
else if($mybb->cookies['failedlogin'] > ($now - $mybb->settings['failedlogintime'] * 60))
{

Zeile 6288Zeile 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 6330Zeile 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 6354Zeile 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 6370Zeile 6509
function build_highlight_array($terms)
{
global $mybb;

function build_highlight_array($terms)
{
global $mybb;





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

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

Zeile 6393Zeile 6532

// Check if this is a "series of words" - should be treated as an EXACT match
if(my_strpos($terms, "\"") !== false)


// Check if this is a "series of words" - should be treated as an EXACT match
if(my_strpos($terms, "\"") !== false)

	{

	{

		$inquote = false;
$terms = explode("\"", $terms);
$words = array();

		$inquote = false;
$terms = explode("\"", $terms);
$words = array();

Zeile 6405Zeile 6544
				if($inquote)
{
$words[] = trim($phrase);

				if($inquote)
{
$words[] = trim($phrase);

				}

				}

				else
{
$split_words = preg_split("#\s{1,}#", $phrase, -1);

				else
{
$split_words = preg_split("#\s{1,}#", $phrase, -1);

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

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

			}
}
}

			}
}
}


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


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





	// 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 6459Zeile 6598
		$word = trim($word);

$word = my_strtolower($word);

		$word = trim($word);

$word = my_strtolower($word);





		// Special boolean operators should be stripped
if($word == "" || $word == "or" || $word == "not" || $word == "and")
{
continue;
}

		// Special boolean operators should be stripped
if($word == "" || $word == "or" || $word == "not" || $word == "and")
{
continue;
}





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

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





	return $highlight_cache;

	return $highlight_cache;

}

/**













}

/**
* 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);
}

/**

 * Converts a decimal reference of a character to its UTF-8 equivalent
* (Code by Anne van Kesteren, http://annevankesteren.nl/2005/05/character-references)
*

 * Converts a decimal reference of a character to its UTF-8 equivalent
* (Code by Anne van Kesteren, http://annevankesteren.nl/2005/05/character-references)
*

Zeile 6506Zeile 6657
		$dest .= chr(0x80 | ($src & 0x003f));
}
elseif($src <= 0x10ffff)

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

	{

	{

		$dest .= chr(0xf0 | ($src >> 18));
$dest .= chr(0x80 | (($src >> 12) & 0x3f));
$dest .= chr(0x80 | (($src >> 6) & 0x3f));

		$dest .= chr(0xf0 | ($src >> 18));
$dest .= chr(0x80 | (($src >> 12) & 0x3f));
$dest .= chr(0x80 | (($src >> 6) & 0x3f));

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

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

	}

	}


if(is_array($banned_cache) && !empty($banned_cache))
{


if(is_array($banned_cache) && !empty($banned_cache))
{

Zeile 6767Zeile 6918
{
global $mybb, $config;


{
global $mybb, $config;


	$url_components = @parse_url($url);















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

$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))
{
foreach($post_data as $key => $val)


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

		{

		{

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

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

		}

		}

		$post_body = ltrim($post_body, '&');
}

		$post_body = ltrim($post_body, '&');
}





	if(function_exists("curl_init"))

	if(function_exists("curl_init"))

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

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

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
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);
}

if(!empty($post_body))
{
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_body);
























	{
$fetch_header = $max_redirects > 0;

$ch = curl_init();

$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))
{
$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 6875Zeile 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']))
{
$url_components['path'] = "/";

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

Zeile 6899Zeile 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[] = "Content-Type: application/x-www-form-urlencoded";

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

Zeile 6935Zeile 7147
		if(!@fwrite($fp, $headers))
{
return false;

		if(!@fwrite($fp, $headers))
{
return false;

		}

$data = null;


		}

$data = null;


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

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

Zeile 6951Zeile 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 6966Zeile 7178
		}

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


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


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

Zeile 6988Zeile 7242
	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']);
}

Zeile 7019Zeile 7273
	if(empty($groups))
{
return array();

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

	}

	}


if($user == false)
{


if($user == false)
{

Zeile 7035Zeile 7289
	$memberships[] = $user['usergroup'];

if(!is_array($groups))

	$memberships[] = $user['usergroup'];

if(!is_array($groups))

	{

	{

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

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

Zeile 7043Zeile 7297
		else
{
if(is_string($groups))

		else
{
if(is_string($groups))

			{

			{

				$groups = explode(',', $groups);

				$groups = explode(',', $groups);

			}

			}

			else
{
$groups = (array)$groups;

			else
{
$groups = (array)$groups;

			}
}
}

			}
}
}


$groups = array_filter(array_map('intval', $groups));



$groups = array_filter(array_map('intval', $groups));


Zeile 7097Zeile 7351
		if($string != "")
{
if($in_escape)

		if($string != "")
{
if($in_escape)

			{

			{

				$strings[] = trim($string);
}
else

				$strings[] = trim($string);
}
else

Zeile 7347Zeile 7601
		$ip_long = sprintf("%u", ip2long($ip));

if(!$ip_long)

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

if(!$ip_long)

		{

		{

			return 0;
}
}

			return 0;
}
}

Zeile 7377Zeile 7631
		$long += 4294967296;
}
return long2ip($long);

		$long += 4294967296;
}
return long2ip($long);

}

}


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


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

Zeile 7388Zeile 7642
function my_inet_pton($ip)
{
if(function_exists('inet_pton'))

function my_inet_pton($ip)
{
if(function_exists('inet_pton'))

	{

	{

		return @inet_pton($ip);

		return @inet_pton($ip);

	}
else
{

	}
else
{

		/**
* Replace inet_pton()
*

		/**
* Replace inet_pton()
*

Zeile 7422Zeile 7676
		{
$length = (!$doub || $doub == $rcount - 1 ? 2 : 1);
array_splice($r, $doub, $length, array_fill(0, 8 + $length - $rcount, 0));

		{
$length = (!$doub || $doub == $rcount - 1 ? 2 : 1);
array_splice($r, $doub, $length, array_fill(0, 8 + $length - $rcount, 0));

		}


		}


		$r = array_map('hexdec', $r);
array_unshift($r, 'n*');
$r = call_user_func_array('pack', $r);

		$r = array_map('hexdec', $r);
array_unshift($r, 'n*');
$r = call_user_func_array('pack', $r);

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

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

		}
return false;
}

		}
return false;
}

}

/**

}

/**

Zeile 7629Zeile 7883
	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 7670Zeile 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 7724Zeile 7978
	if($int < 0)
{
return "$int";

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

	}
else
{

	}
else
{

		return "+$int";
}
}

		return "+$int";
}
}

Zeile 8100Zeile 8354

/*
* Validates an UTF-8 string.


/*
* Validates an UTF-8 string.

 *

 *

 * @param string $input The string to be checked
* @param boolean $allow_mb4 Allow 4 byte UTF-8 characters?
* @param boolean $return Return the cleaned string?

 * @param string $input The string to be checked
* @param boolean $allow_mb4 Allow 4 byte UTF-8 characters?
* @param boolean $return Return the cleaned string?

Zeile 8345Zeile 8599
	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 8397Zeile 8651
 * @return bool Whether the file was copied successfully.
*/
function copy_file_to_cdn($file_path = '', &$uploaded_path = null)

 * @return bool Whether the file was copied successfully.
*/
function copy_file_to_cdn($file_path = '', &$uploaded_path = null)

{

{

	global $mybb, $plugins;

$success = false;

	global $mybb, $plugins;

$success = false;

Zeile 8428Zeile 8682
			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 8441Zeile 8695
						$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 8453Zeile 8707
				'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;

}

}