Vergleich inc/functions.php - 1.8.2 - 1.8.4

  Keine Änderungen   Hinzugefügt   Modifiziert   Entfernt
Zeile 173Zeile 173

if(isset($config))
{


if(isset($config))
{

 
			// Load DB interface
require_once MYBB_ROOT."inc/db_base.php";


			require_once MYBB_ROOT."inc/db_".$config['database']['type'].".php";
switch($config['database']['type'])
{

			require_once MYBB_ROOT."inc/db_".$config['database']['type'].".php";
switch($config['database']['type'])
{

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

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

		if($ty != 2 && (TIME_NOW - $stamp) < 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);

		{
$diff = TIME_NOW - $stamp;
$relative = array('prefix' => '', 'minute' => 0, 'plural' => $lang->rel_minutes_plural, 'suffix' => $lang->rel_ago);

Zeile 425Zeile 428

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


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

		elseif($ty != 2 && (TIME_NOW - $stamp) >= 3600 && (TIME_NOW - $stamp) < 43200)

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

		{
$diff = TIME_NOW - $stamp;
$relative = array('prefix' => '', 'hour' => 0, 'plural' => $lang->rel_hours_plural, 'suffix' => $lang->rel_ago);

		{
$diff = TIME_NOW - $stamp;
$relative = array('prefix' => '', 'hour' => 0, 'plural' => $lang->rel_hours_plural, 'suffix' => $lang->rel_ago);

Zeile 756Zeile 759
	}

// AJAX error message?

	}

// AJAX error message?

	if($mybb->get_input('ajax', 1))

	if($mybb->get_input('ajax', MyBB::INPUT_INT))

	{
// Send our headers.
@header("Content-type: application/json; charset={$lang->settings['charset']}");

	{
// Send our headers.
@header("Content-type: application/json; charset={$lang->settings['charset']}");

Zeile 802Zeile 805
	}

// AJAX error message?

	}

// AJAX error message?

	if($mybb->get_input('ajax', 1))

	if($mybb->get_input('ajax', MyBB::INPUT_INT))

	{
// Send our headers.
@header("Content-type: application/json; charset={$lang->settings['charset']}");

	{
// Send our headers.
@header("Content-type: application/json; charset={$lang->settings['charset']}");

Zeile 848Zeile 851

$db->update_query("sessions", $noperm_array, "sid='{$session->sid}'");



$db->update_query("sessions", $noperm_array, "sid='{$session->sid}'");


	if($mybb->get_input('ajax', 1))

	if($mybb->get_input('ajax', MyBB::INPUT_INT))

	{
// Send our headers.
header("Content-type: application/json; charset={$lang->settings['charset']}");

	{
// Send our headers.
header("Content-type: application/json; charset={$lang->settings['charset']}");

Zeile 909Zeile 912

$plugins->run_hooks("redirect", $redirect_args);



$plugins->run_hooks("redirect", $redirect_args);


	if($mybb->get_input('ajax', 1))

	if($mybb->get_input('ajax', MyBB::INPUT_INT))

	{
// Send our headers.
//@header("Content-type: text/html; charset={$lang->settings['charset']}");

	{
// Send our headers.
//@header("Content-type: text/html; charset={$lang->settings['charset']}");

Zeile 1198Zeile 1201
}

/**

}

/**

 * Fetch the usergroup permissions for a specic group or series of groups combined

 * Fetch the usergroup permissions for a specific group or series of groups combined

 *
* @param mixed A list of groups (Can be a single integer, or a list of groups separated by a comma)
* @return array Array of permissions generated for the groups

 *
* @param mixed A list of groups (Can be a single integer, or a list of groups separated by a comma)
* @return array Array of permissions generated for the groups

Zeile 1213Zeile 1216
	}

$groups = explode(",", $gid);

	}

$groups = explode(",", $gid);



 

if(count($groups) == 1)
{
return $groupscache[$gid];
}


if(count($groups) == 1)
{
return $groupscache[$gid];
}

 
	
$usergroup = array();


foreach($groups as $gid)
{


foreach($groups as $gid)
{

Zeile 1251Zeile 1255
				{
$usergroup[$perm] = $access;
}

				{
$usergroup[$perm] = $access;
}

			}
}
}

			}
}
}


return $usergroup;
}


return $usergroup;
}

Zeile 1279Zeile 1283
	foreach($displaygroupfields as $field)
{
$displaygroup[$field] = $group[$field];

	foreach($displaygroupfields as $field)
{
$displaygroup[$field] = $group[$field];

	}


	}


	return $displaygroup;
}


	return $displaygroup;
}


Zeile 1306Zeile 1310
		if($uid != 0 && $uid != $mybb->user['uid'])
{
$user = get_user($uid);

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





			$gid = $user['usergroup'].",".$user['additionalgroups'];
$groupperms = usergroup_permissions($gid);
}
else
{
$gid = $mybb->user['usergroup'];

			$gid = $user['usergroup'].",".$user['additionalgroups'];
$groupperms = usergroup_permissions($gid);
}
else
{
$gid = $mybb->user['usergroup'];





			if(isset($mybb->user['additionalgroups']))
{
$gid .= ",".$mybb->user['additionalgroups'];
}

$groupperms = $mybb->usergroup;

			if(isset($mybb->user['additionalgroups']))
{
$gid .= ",".$mybb->user['additionalgroups'];
}

$groupperms = $mybb->usergroup;

		}
}

		}
}


if(!is_array($forum_cache))
{


if(!is_array($forum_cache))
{

Zeile 1375Zeile 1379
	$groups = explode(",", $gid);

if(empty($fpermcache[$fid])) // This forum has no custom or inherited permissions so lets just return the group permissions

	$groups = explode(",", $gid);

if(empty($fpermcache[$fid])) // This forum has no custom or inherited permissions so lets just return the group permissions

	{

	{

		return $groupperms;
}

$current_permissions = array();
$only_view_own_threads = 1;

		return $groupperms;
}

$current_permissions = array();
$only_view_own_threads = 1;

 
	$only_reply_own_threads = 1;


foreach($groups as $gid)
{


foreach($groups as $gid)
{

Zeile 1423Zeile 1428
			if($level_permissions["canview"] && empty($level_permissions["canonlyviewownthreads"]))
{
$only_view_own_threads = 0;

			if($level_permissions["canview"] && empty($level_permissions["canonlyviewownthreads"]))
{
$only_view_own_threads = 0;

 
			}

if($level_permissions["canpostreplys"] && empty($level_permissions["canonlyreplyownthreads"]))
{
$only_reply_own_threads = 0;

			}
}
}

// Figure out if we can view more than our own threads
if($only_view_own_threads == 0)

			}
}
}

// Figure out if we can view more than our own threads
if($only_view_own_threads == 0)

	{

	{

		$current_permissions["canonlyviewownthreads"] = 0;

		$current_permissions["canonlyviewownthreads"] = 0;

 
	}

// Figure out if we can reply more than our own threads
if($only_reply_own_threads == 0)
{
$current_permissions["canonlyreplyownthreads"] = 0;

	}

if(count($current_permissions) == 0)

	}

if(count($current_permissions) == 0)

Zeile 1750Zeile 1766
	foreach($posticons as $dbicon)
{
$dbicon['path'] = str_replace("{theme}", $theme['imgdir'], $dbicon['path']);

	foreach($posticons as $dbicon)
{
$dbicon['path'] = str_replace("{theme}", $theme['imgdir'], $dbicon['path']);

		$dbicon['path'] = htmlspecialchars_uni($dbicon['path']);

		$dbicon['path'] = htmlspecialchars_uni($mybb->get_asset_url($dbicon['path']));

		$dbicon['name'] = htmlspecialchars_uni($dbicon['name']);

if($icon == $dbicon['iid'])

		$dbicon['name'] = htmlspecialchars_uni($dbicon['name']);

if($icon == $dbicon['iid'])

		{

		{

			$checked = " checked=\"checked\"";
$no_icons_checked = '';

			$checked = " checked=\"checked\"";
$no_icons_checked = '';

		}

		}

		else
{
$checked = '';
}

		else
{
$checked = '';
}





		eval("\$iconlist .= \"".$templates->get("posticons_icon")."\";");
}

		eval("\$iconlist .= \"".$templates->get("posticons_icon")."\";");
}





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

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





	return $posticons;
}


	return $posticons;
}


Zeile 1780Zeile 1796
 * @param boolean True if setting a HttpOnly cookie (supported by IE, Opera 9, Konqueror)
*/
function my_setcookie($name, $value="", $expires="", $httponly=false)

 * @param boolean True if setting a HttpOnly cookie (supported by IE, Opera 9, Konqueror)
*/
function my_setcookie($name, $value="", $expires="", $httponly=false)

{

{

	global $mybb;

if(!$mybb->settings['cookiepath'])

	global $mybb;

if(!$mybb->settings['cookiepath'])

	{

	{

		$mybb->settings['cookiepath'] = "/";

		$mybb->settings['cookiepath'] = "/";

	}

	}


if($expires == -1)


if($expires == -1)

	{

	{

		$expires = 0;
}
elseif($expires == "" || $expires == null)

		$expires = 0;
}
elseif($expires == "" || $expires == null)

	{

	{

		$expires = TIME_NOW + (60*60*24*365); // Make the cookie expire in a years time
}
else

		$expires = TIME_NOW + (60*60*24*365); // Make the cookie expire in a years time
}
else

Zeile 1831Zeile 1847
	$mybb->cookies[$name] = $value;

header($cookie, false);

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

header($cookie, false);

}

/**

}

/**

 * Unset a cookie set by MyBB.
*
* @param string The cookie identifier.

 * Unset a cookie set by MyBB.
*
* @param string The cookie identifier.

Zeile 1860Zeile 1876
	global $mybb;

if(!isset($mybb->cookies['mybb'][$name]))

	global $mybb;

if(!isset($mybb->cookies['mybb'][$name]))

	{
return false;
}

$cookie = my_unserialize($mybb->cookies['mybb'][$name]);

	{
return false;
}

$cookie = my_unserialize($mybb->cookies['mybb'][$name]);


if(is_array($cookie) && isset($cookie[$id]))
{
return $cookie[$id];


if(is_array($cookie) && isset($cookie[$id]))
{
return $cookie[$id];

	}

	}

	else
{
return 0;

	else
{
return 0;

	}
}

/**

	}
}

/**

 * Set a serialised cookie array.
*
* @param string The cookie identifier.

 * Set a serialised cookie array.
*
* @param string The cookie identifier.

Zeile 1899Zeile 1915
	}

$newcookie[$id] = $value;

	}

$newcookie[$id] = $value;

	$newcookie = serialize($newcookie);

	$newcookie = my_serialize($newcookie);

	my_setcookie("mybb[$name]", addslashes($newcookie), $expires);

// Make sure our current viarables are up-to-date as well
$mybb->cookies['mybb'][$name] = $newcookie;

	my_setcookie("mybb[$name]", addslashes($newcookie), $expires);

// Make sure our current viarables are up-to-date as well
$mybb->cookies['mybb'][$name] = $newcookie;

}












































































































































































































































































}

/*
* Arbitrary limits for _safe_unserialize()
*/
define('MAX_SERIALIZED_INPUT_LENGTH', 10240);
define('MAX_SERIALIZED_ARRAY_LENGTH', 256);
define('MAX_SERIALIZED_ARRAY_DEPTH', 5);

/**
* Credits go to https://github.com/piwik
* Safe unserialize() replacement
* - accepts a strict subset of PHP's native my_serialized representation
* - does not unserialize objects
*
* @param string $str
* @return mixed
* @throw Exception if $str is malformed or contains unsupported types (e.g., resources, objects)
*/
function _safe_unserialize($str)
{
if(strlen($str) > MAX_SERIALIZED_INPUT_LENGTH)
{
// input exceeds MAX_SERIALIZED_INPUT_LENGTH
return false;
}

if(empty($str) || !is_string($str))
{
return false;
}

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

/*
* states:
* 0 - initial state, expecting a single value or array
* 1 - terminal state
* 2 - in array, expecting end of array or a key
* 3 - in array, expecting value or another array
*/
$state = 0;
while($state != 1)
{
$type = isset($str[0]) ? $str[0] : '';

if($type == '}')
{
$str = substr($str, 1);
}
else if($type == 'N' && $str[1] == ';')
{
$value = null;
$str = substr($str, 2);
}
else if($type == 'b' && preg_match('/^b:([01]);/', $str, $matches))
{
$value = $matches[1] == '1' ? true : false;
$str = substr($str, 4);
}
else if($type == 'i' && preg_match('/^i:(-?[0-9]+);(.*)/s', $str, $matches))
{
$value = (int)$matches[1];
$str = $matches[2];
}
else if($type == 'd' && preg_match('/^d:(-?[0-9]+\.?[0-9]*(E[+-][0-9]+)?);(.*)/s', $str, $matches))
{
$value = (float)$matches[1];
$str = $matches[3];
}
else if($type == 's' && preg_match('/^s:([0-9]+):"(.*)/s', $str, $matches) && substr($matches[2], (int)$matches[1], 2) == '";')
{
$value = substr($matches[2], 0, (int)$matches[1]);
$str = substr($matches[2], (int)$matches[1] + 2);
}
else if($type == 'a' && preg_match('/^a:([0-9]+):{(.*)/s', $str, $matches) && $matches[1] < MAX_SERIALIZED_ARRAY_LENGTH)
{
$expectedLength = (int)$matches[1];
$str = $matches[2];
}
else
{
// object or unknown/malformed type
return false;
}

switch($state)
{
case 3: // in array, expecting value or another array
if($type == 'a')
{
if(count($stack) >= MAX_SERIALIZED_ARRAY_DEPTH)
{
// array nesting exceeds MAX_SERIALIZED_ARRAY_DEPTH
return false;
}

$stack[] = &$list;
$list[$key] = array();
$list = &$list[$key];
$expected[] = $expectedLength;
$state = 2;
break;
}
if($type != '}')
{
$list[$key] = $value;
$state = 2;
break;
}

// missing array value
return false;

case 2: // in array, expecting end of array or a key
if($type == '}')
{
if(count($list) < end($expected))
{
// array size less than expected
return false;
}

unset($list);
$list = &$stack[count($stack)-1];
array_pop($stack);

// go to terminal state if we're at the end of the root array
array_pop($expected);
if(count($expected) == 0) {
$state = 1;
}
break;
}
if($type == 'i' || $type == 's')
{
if(count($list) >= MAX_SERIALIZED_ARRAY_LENGTH)
{
// array size exceeds MAX_SERIALIZED_ARRAY_LENGTH
return false;
}
if(count($list) >= end($expected))
{
// array size exceeds expected length
return false;
}

$key = $value;
$state = 3;
break;
}

// illegal array index type
return false;

case 0: // expecting array or value
if($type == 'a')
{
if(count($stack) >= MAX_SERIALIZED_ARRAY_DEPTH)
{
// array nesting exceeds MAX_SERIALIZED_ARRAY_DEPTH
return false;
}

$data = array();
$list = &$data;
$expected[] = $expectedLength;
$state = 2;
break;
}
if($type != '}')
{
$data = $value;
$state = 1;
break;
}

// not in array
return false;
}
}

if(!empty($str))
{
// trailing data in input
return false;
}
return $data;
}

/**
* Credits go to https://github.com/piwik
* Wrapper for _safe_unserialize() that handles exceptions and multibyte encoding issue
*
* @param string $str
* @return mixed
*/
function my_unserialize($str)
{
// Ensure we use the byte count for strings even when strlen() is overloaded by mb_strlen()
if(function_exists('mb_internal_encoding') && (((int)ini_get('mbstring.func_overload')) & 2))
{
$mbIntEnc = mb_internal_encoding();
mb_internal_encoding('ASCII');
}

$out = _safe_unserialize($str);

if(isset($mbIntEnc))
{
mb_internal_encoding($mbIntEnc);
}

return $out;
}

/**
* Credits go to https://github.com/piwik
* Safe serialize() replacement
* - output a strict subset of PHP's native serialized representation
* - does not my_serialize objects
*
* @param mixed $value
* @return string
* @throw Exception if $value is malformed or contains unsupported types (e.g., resources, objects)
*/
function _safe_serialize( $value )
{
if(is_null($value))
{
return 'N;';
}

if(is_bool($value))
{
return 'b:'.(int)$value.';';
}

if(is_int($value))
{
return 'i:'.$value.';';
}

if(is_float($value))
{
return 'd:'.str_replace(',', '.', $value).';';
}

if(is_string($value))
{
return 's:'.strlen($value).':"'.$value.'";';
}

if(is_array($value))
{
$out = '';
foreach($value as $k => $v)
{
$out .= _safe_serialize($k) . _safe_serialize($v);
}

return 'a:'.count($value).':{'.$out.'}';
}

// safe_serialize cannot my_serialize resources or objects
return false;
}


/**


/**

 * Verifies that data passed is an array


 * Credits go to https://github.com/piwik
* Wrapper for _safe_serialize() that handles exceptions and multibyte encoding issue

 *

 *

 * @param array Data to unserialize
* @return array Unserialized data array
*/
function my_unserialize($data)

 * @param mixed $value
* @return string
*/
function my_serialize($value)

{

{

	$array = unserialize($data);

if(!is_array($array))

	// ensure we use the byte count for strings even when strlen() is overloaded by mb_strlen()
if(function_exists('mb_internal_encoding') && (((int)ini_get('mbstring.func_overload')) & 2))


	{

	{

		$array = array();








		$mbIntEnc = mb_internal_encoding();
mb_internal_encoding('ASCII');
}

$out = _safe_serialize($value);
if(isset($mbIntEnc))
{
mb_internal_encoding($mbIntEnc);

	}

	}


return $array;

	
return $out;

}

/**

}

/**

Zeile 1939Zeile 2229
	if(DIRECTORY_SEPARATOR != '\\')
{
if(function_exists("sys_getloadavg"))

	if(DIRECTORY_SEPARATOR != '\\')
{
if(function_exists("sys_getloadavg"))

		{

		{

			// sys_getloadavg() will return an array with [0] being load within the last minute.
$serverload = sys_getloadavg();

			// sys_getloadavg() will return an array with [0] being load within the last minute.
$serverload = sys_getloadavg();

			$serverload[0] = round($serverload[0], 4);
}

			$serverload[0] = round($serverload[0], 4);
}

		else if(@file_exists("/proc/loadavg") && $load = @file_get_contents("/proc/loadavg"))
{
$serverload = explode(" ", $load);

		else if(@file_exists("/proc/loadavg") && $load = @file_get_contents("/proc/loadavg"))
{
$serverload = explode(" ", $load);

Zeile 1952Zeile 2242
		if(!is_numeric($serverload[0]))
{
if($mybb->safemode)

		if(!is_numeric($serverload[0]))
{
if($mybb->safemode)

			{

			{

				return $lang->unknown;

				return $lang->unknown;

			}

			}


// Suhosin likes to throw a warning if exec is disabled then die - weird
if($func_blacklist = @ini_get('suhosin.executor.func.blacklist'))


// Suhosin likes to throw a warning if exec is disabled then die - weird
if($func_blacklist = @ini_get('suhosin.executor.func.blacklist'))

Zeile 1966Zeile 2256
			}
// PHP disabled functions?
if($func_blacklist = @ini_get('disable_functions'))

			}
// PHP disabled functions?
if($func_blacklist = @ini_get('disable_functions'))

			{

			{

				if(strpos(",".$func_blacklist.",", 'exec') !== false)
{
return $lang->unknown;

				if(strpos(",".$func_blacklist.",", 'exec') !== false)
{
return $lang->unknown;

Zeile 1979Zeile 2269
			if(!is_array($serverload))
{
return $lang->unknown;

			if(!is_array($serverload))
{
return $lang->unknown;

			}

			}

		}

		}

	}

	}

	else
{
return $lang->unknown;
}

	else
{
return $lang->unknown;
}





	$returnload = trim($serverload[0]);

	$returnload = trim($serverload[0]);





	return $returnload;

	return $returnload;

}

/**

}

/**

 * Returns the amount of memory allocated to the script.
*
* @return int The amount of memory allocated to the script.

 * Returns the amount of memory allocated to the script.
*
* @return int The amount of memory allocated to the script.

Zeile 2045Zeile 2335
	if($force) // Force writing to cache?
{
if(!empty($changes))

	if($force) // Force writing to cache?
{
if(!empty($changes))

		{

		{

			// Calculate before writing to cache
update_stats($changes);
}

			// Calculate before writing to cache
update_stats($changes);
}

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

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

					}
}
}

					}
}
}

			else
{
$new_stats[$counter] = $changes[$counter];

			else
{
$new_stats[$counter] = $changes[$counter];

Zeile 2116Zeile 2406
	}

if(!empty($new_stats))

	}

if(!empty($new_stats))

	{

	{

		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

Zeile 2184Zeile 2474
			{
$update_query[$counter] = 0;
}

			{
$update_query[$counter] = 0;
}

		}
}


		}
}


	// Only update if we're actually doing something
if(count($update_query) > 0)
{

	// Only update if we're actually doing something
if(count($update_query) > 0)
{

Zeile 2201Zeile 2491
		if($threads_diff > -1)
{
$new_stats['numthreads'] = "+{$threads_diff}";

		if($threads_diff > -1)
{
$new_stats['numthreads'] = "+{$threads_diff}";

		}
else

		}
else

		{
$new_stats['numthreads'] = "{$threads_diff}";

		{
$new_stats['numthreads'] = "{$threads_diff}";

		}

		}

	}

if(array_key_exists('unapprovedthreads', $update_query))

	}

if(array_key_exists('unapprovedthreads', $update_query))

Zeile 2214Zeile 2504
		if($unapprovedthreads_diff > -1)
{
$new_stats['numunapprovedthreads'] = "+{$unapprovedthreads_diff}";

		if($unapprovedthreads_diff > -1)
{
$new_stats['numunapprovedthreads'] = "+{$unapprovedthreads_diff}";

		}
else

		}
else

		{
$new_stats['numunapprovedthreads'] = "{$unapprovedthreads_diff}";

		{
$new_stats['numunapprovedthreads'] = "{$unapprovedthreads_diff}";

		}

		}

	}

if(array_key_exists('posts', $update_query))
{
$posts_diff = $update_query['posts'] - $forum['posts'];
if($posts_diff > -1)

	}

if(array_key_exists('posts', $update_query))
{
$posts_diff = $update_query['posts'] - $forum['posts'];
if($posts_diff > -1)

		{

		{

			$new_stats['numposts'] = "+{$posts_diff}";
}

			$new_stats['numposts'] = "+{$posts_diff}";
}

		else
{
$new_stats['numposts'] = "{$posts_diff}";
}

		else
{
$new_stats['numposts'] = "{$posts_diff}";
}

	}

if(array_key_exists('unapprovedposts', $update_query))

	}

if(array_key_exists('unapprovedposts', $update_query))

Zeile 2244Zeile 2534
		else
{
$new_stats['numunapprovedposts'] = "{$unapprovedposts_diff}";

		else
{
$new_stats['numunapprovedposts'] = "{$unapprovedposts_diff}";

		}
}

		}
}


if(array_key_exists('deletedposts', $update_query))
{


if(array_key_exists('deletedposts', $update_query))
{

Zeile 2253Zeile 2543
		if($deletedposts_diff > -1)
{
$new_stats['numdeletedposts'] = "+{$deletedposts_diff}";

		if($deletedposts_diff > -1)
{
$new_stats['numdeletedposts'] = "+{$deletedposts_diff}";

		}

		}

		else
{
$new_stats['numdeletedposts'] = "{$deletedposts_diff}";

		else
{
$new_stats['numdeletedposts'] = "{$deletedposts_diff}";

		}
}

		}
}


if(array_key_exists('deletedthreads', $update_query))
{
$deletedthreads_diff = $update_query['deletedthreads'] - $forum['deletedthreads'];
if($deletedthreads_diff > -1)


if(array_key_exists('deletedthreads', $update_query))
{
$deletedthreads_diff = $update_query['deletedthreads'] - $forum['deletedthreads'];
if($deletedthreads_diff > -1)

		{

		{

			$new_stats['numdeletedthreads'] = "+{$deletedthreads_diff}";
}
else
{
$new_stats['numdeletedthreads'] = "{$deletedthreads_diff}";
}

			$new_stats['numdeletedthreads'] = "+{$deletedthreads_diff}";
}
else
{
$new_stats['numdeletedthreads'] = "{$deletedthreads_diff}";
}

	}


	}


	if(!empty($new_stats))
{
update_stats($new_stats);

	if(!empty($new_stats))
{
update_stats($new_stats);

Zeile 2285Zeile 2575
 * @param int The forum ID
*/
function update_forum_lastpost($fid)

 * @param int The forum ID
*/
function update_forum_lastpost($fid)

{
global $db;


{
global $db;


	// Fetch the last post for this forum
$query = $db->query("
SELECT tid, lastpost, lastposter, lastposteruid, subject

	// Fetch the last post for this forum
$query = $db->query("
SELECT tid, lastpost, lastposter, lastposteruid, subject

Zeile 2316Zeile 2606
 * @param array Array of items being updated (replies, unapprovedposts, deletedposts, attachmentcount) and their value (ex, 1, +1, -1)
*/
function update_thread_counters($tid, $changes=array())

 * @param array Array of items being updated (replies, unapprovedposts, deletedposts, attachmentcount) and their value (ex, 1, +1, -1)
*/
function update_thread_counters($tid, $changes=array())

{
global $db;

$update_query = array();

{
global $db;

$update_query = array();

	$tid = (int)$tid;

$counters = array('replies', 'unapprovedposts', 'attachmentcount', 'deletedposts', 'attachmentcount');

	$tid = (int)$tid;

$counters = array('replies', 'unapprovedposts', 'attachmentcount', 'deletedposts', 'attachmentcount');

Zeile 2541Zeile 2831
 * @param int The current depth of forums we're at
* @param int Whether or not to show extra items such as User CP, Forum home
* @param boolean Ignore the showinjump setting and show all forums (for moderation pages)

 * @param int The current depth of forums we're at
* @param int Whether or not to show extra items such as User CP, Forum home
* @param boolean Ignore the showinjump setting and show all forums (for moderation pages)

 * @param array Array of permissions

 * @param unknown_type deprecated

 * @param string The name of the forum jump
* @return string Forum jump items
*/
function build_forum_jump($pid="0", $selitem="", $addselect="1", $depth="", $showextras="1", $showall=false, $permissions="", $name="fid")
{

 * @param string The name of the forum jump
* @return string Forum jump items
*/
function build_forum_jump($pid="0", $selitem="", $addselect="1", $depth="", $showextras="1", $showall=false, $permissions="", $name="fid")
{

	global $forum_cache, $jumpfcache, $permissioncache, $mybb, $selecteddone, $forumjump, $forumjumpbits, $gobutton, $theme, $templates, $lang;

	global $forum_cache, $jumpfcache, $permissioncache, $mybb, $forumjump, $forumjumpbits, $gobutton, $theme, $templates, $lang;


$pid = (int)$pid;


$pid = (int)$pid;

	$jumpsel['default'] = '';

if($permissions)
{
$permissions = $mybb->usergroup;
}

 

if(!is_array($jumpfcache))
{


if(!is_array($jumpfcache))
{

Zeile 2592Zeile 2876

if($selitem == $forum['fid'])
{


if($selitem == $forum['fid'])
{

						$optionselected = "selected=\"selected\"";
$selecteddone = 1;

						$optionselected = 'selected="selected"';


					}

$forum['name'] = htmlspecialchars_uni(strip_tags($forum['name']));

					}

$forum['name'] = htmlspecialchars_uni(strip_tags($forum['name']));

Zeile 2612Zeile 2895

if($addselect)
{


if($addselect)
{

		if(!$selecteddone)
{
if(!$selitem)
{
$selitem = "default";
}

$jumpsel[$selitem] = 'selected="selected"';
}


 
		if($showextras == 0)
{
$template = "special";

		if($showextras == 0)
{
$template = "special";

Zeile 2632Zeile 2905

if(strpos(FORUM_URL, '.html') !== false)
{


if(strpos(FORUM_URL, '.html') !== false)
{

				$forum_link = "'".str_replace('{fid}', "'+this.options[this.selectedIndex].value+'", FORUM_URL)."'";

				$forum_link = "'".str_replace('{fid}', "'+option+'", FORUM_URL)."'";

			}
else
{

			}
else
{

				$forum_link = "'".str_replace('{fid}', "'+this.options[this.selectedIndex].value", FORUM_URL);

				$forum_link = "'".str_replace('{fid}', "'+option", FORUM_URL);

			}
}

eval("\$forumjump = \"".$templates->get("forumjump_".$template)."\";");

			}
}

eval("\$forumjump = \"".$templates->get("forumjump_".$template)."\";");

	}

	}


return $forumjump;
}


return $forumjump;
}

Zeile 2667Zeile 2940
{
$set = array("a","A","b","B","c","C","d","D","e","E","f","F","g","G","h","H","i","I","j","J","k","K","l","L","m","M","n","N","o","O","p","P","q","Q","r","R","s","S","t","T","u","U","v","V","w","W","x","X","y","Y","z","Z","1","2","3","4","5","6","7","8","9");
$str = '';

{
$set = array("a","A","b","B","c","C","d","D","e","E","f","F","g","G","h","H","i","I","j","J","k","K","l","L","m","M","n","N","o","O","p","P","q","Q","r","R","s","S","t","T","u","U","v","V","w","W","x","X","y","Y","z","Z","1","2","3","4","5","6","7","8","9");
$str = '';





	for($i = 1; $i <= $length; ++$i)
{
$ch = my_rand(0, count($set)-1);
$str .= $set[$ch];
}

	for($i = 1; $i <= $length; ++$i)
{
$ch = my_rand(0, count($set)-1);
$str .= $set[$ch];
}





	return $str;
}

	return $str;
}





/**
* Formats a username based on their display group
*

/**
* Formats a username based on their display group
*

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

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

	}


	}


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

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

Zeile 2772Zeile 3045
	}

$avatars[$avatar] = array(

	}

$avatars[$avatar] = array(

		'image' => $mybb->get_asset_url($avatar),

		'image' => htmlspecialchars_uni($mybb->get_asset_url($avatar)),

		'width_height' => $avatar_width_height
);


		'width_height' => $avatar_width_height
);


Zeile 2933Zeile 3206
						// Only show the first text to replace in the box
$smilie['find'] = $finds[0];


						// Only show the first text to replace in the box
$smilie['find'] = $finds[0];


						$find = htmlspecialchars_uni($smilie['find']);
$image = $mybb->get_asset_url($smilie['image']);
$image = htmlspecialchars_uni($image);


						$find = str_replace(array('\\', '"'), array('\\\\', '\"'), htmlspecialchars_uni($smilie['find']));
$image = htmlspecialchars_uni($mybb->get_asset_url($smilie['image']));
$image = str_replace(array('\\', '"'), array('\\\\', '\"'), $image);


						if($i < $mybb->settings['smilieinsertertot'])
{
$dropdownsmilies .= '"'.$find.'": "'.$image.'",';

						if($i < $mybb->settings['smilieinsertertot'])
{
$dropdownsmilies .= '"'.$find.'": "'.$image.'",';

Zeile 2947Zeile 3221

for($j = 1; $j < $finds_count; ++$j)
{


for($j = 1; $j < $finds_count; ++$j)
{

							$find = htmlspecialchars_uni($finds[$j]);

							$find = str_replace(array('\\', '"'), array('\\\\', '\"'), htmlspecialchars_uni($finds[$j]));

							$hiddensmilies .= '"'.$find.'": "'.$image.'",';
}
++$i;

							$hiddensmilies .= '"'.$find.'": "'.$image.'",';
}
++$i;

Zeile 2964Zeile 3238
			}

if($mybb->settings['allowalignmycode'] == 1)

			}

if($mybb->settings['allowalignmycode'] == 1)

			{

			{

				$align = "left,center,right,justify|";
}


				$align = "left,center,right,justify|";
}


Zeile 2991Zeile 3265
			if($mybb->settings['allowemailmycode'] == 1)
{
$email = "email,";

			if($mybb->settings['allowemailmycode'] == 1)
{
$email = "email,";

			}


			}


			if($mybb->settings['allowlinkmycode'] == 1)

			if($mybb->settings['allowlinkmycode'] == 1)

			{

			{

				$link = "link,unlink";

				$link = "link,unlink";

			}

			}


if($mybb->settings['allowlistmycode'] == 1)


if($mybb->settings['allowlistmycode'] == 1)

			{

			{

				$list = "bulletlist,orderedlist|";
}

if($mybb->settings['allowcodemycode'] == 1)
{
$code = "code,php,";

				$list = "bulletlist,orderedlist|";
}

if($mybb->settings['allowcodemycode'] == 1)
{
$code = "code,php,";

			}

			}


if($mybb->user['sourceeditor'] == 1)
{


if($mybb->user['sourceeditor'] == 1)
{

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

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

				}
}
}

unset($smilie);

				}
}
}

unset($smilie);


if(is_array($smiliecache))
{


if(is_array($smiliecache))
{

Zeile 3083Zeile 3357
					{
$smilies .= "<tr>\n";
}

					{
$smilies .= "<tr>\n";
}







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


					// Only show the first text to replace in the box
$temp = explode("\n", $smilie['find']); // assign to temporary variable for php 5.3 compatibility
$smilie['find'] = $temp[0];


					// Only show the first text to replace in the box
$temp = explode("\n", $smilie['find']); // assign to temporary variable for php 5.3 compatibility
$smilie['find'] = $temp[0];


					$find = htmlspecialchars_uni($smilie['find']);

					$find = str_replace(array('\\', "'"), array('\\\\', "\'"), htmlspecialchars_uni($smilie['find']));





					$onclick = ' onclick="MyBBEditor.insertText(\' '.$smilie['find'].' \');"';

					$onclick = " onclick=\"MyBBEditor.insertText(' $find ');\"";

					$extra_class = ' smilie_pointer';
eval('$smilie = "'.$templates->get('smilie', 1, 0).'";');
eval("\$smilies .= \"".$templates->get("smilieinsert_smilie")."\";");

					$extra_class = ' smilie_pointer';
eval('$smilie = "'.$templates->get('smilie', 1, 0).'";');
eval("\$smilies .= \"".$templates->get("smilieinsert_smilie")."\";");

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

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

		}

return $prefixes_cache;
}

		}

return $prefixes_cache;
}


$prefix_cache = $cache->read("threadprefixes");


$prefix_cache = $cache->read("threadprefixes");





	if(!is_array($prefix_cache))
{
// No cache

	if(!is_array($prefix_cache))
{
// No cache

Zeile 3157Zeile 3435
		if(!is_array($prefix_cache))
{
return array();

		if(!is_array($prefix_cache))
{
return array();

		}
}


		}
}


	$prefixes_cache = array();
foreach($prefix_cache as $prefix)

	$prefixes_cache = array();
foreach($prefix_cache as $prefix)

	{

	{

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

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

	}

	}


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


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

	}

	}

	else if(!empty($prefixes_cache))
{
return $prefixes_cache;

	else if(!empty($prefixes_cache))
{
return $prefixes_cache;

Zeile 3193Zeile 3471
	if($fid != 'all')
{
$fid = (int)$fid;

	if($fid != 'all')
{
$fid = (int)$fid;

	}


	}


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

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

	{

	{

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

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





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

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





		foreach($exp as $group)

		foreach($exp as $group)

		{

		{

			$groups[] = $group;
}
}

			$groups[] = $group;
}
}

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

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

		{

		{

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


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


Zeile 3238Zeile 3516
				{
// Our group can use this prefix!
$prefixes[$prefix['pid']] = $prefix;

				{
// Our group can use this prefix!
$prefixes[$prefix['pid']] = $prefix;

				}
}
}

				}
}
}

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

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

Zeile 3454Zeile 3732
		unset($data['pid']);
}


		unset($data['pid']);
}


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

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

	if(is_array($data))
{

	if(is_array($data))
{

		$data = serialize($data);

		$data = my_serialize($data);

	}

$sql_array = array(

	}

$sql_array = array(

Zeile 3526Zeile 3804
		$warning_class = "high_warning";
}
else if($level >= 50)

		$warning_class = "high_warning";
}
else if($level >= 50)

	{

	{

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

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

Zeile 3551Zeile 3829
{
global $mybb, $plugins;


{
global $mybb, $plugins;


	$ip = $_SERVER['REMOTE_ADDR'];

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


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


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

Zeile 3559Zeile 3837

if(isset($_SERVER['HTTP_X_FORWARDED_FOR']))
{


if(isset($_SERVER['HTTP_X_FORWARDED_FOR']))
{

			$addresses = explode(',', $_SERVER['HTTP_X_FORWARDED_FOR']);

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

		}
elseif(isset($_SERVER['HTTP_X_REAL_IP']))
{

		}
elseif(isset($_SERVER['HTTP_X_REAL_IP']))
{

			$addresses = explode(',', $_SERVER['HTTP_X_REAL_IP']);

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

		}

if(is_array($addresses))

		}

if(is_array($addresses))

Zeile 3585Zeile 3863
	{
if(isset($_SERVER['HTTP_CLIENT_IP']))
{

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

			$ip = $_SERVER['HTTP_CLIENT_IP'];

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

		}
}


		}
}


Zeile 3704Zeile 3982
 */
function get_attachment_icon($ext)
{

 */
function get_attachment_icon($ext)
{

	global $cache, $attachtypes, $theme, $templates, $lang;

	global $cache, $attachtypes, $theme, $templates, $lang, $mybb;


if(!$attachtypes)
{


if(!$attachtypes)
{

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

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

 
			$icon = $mybb->get_asset_url($icon);

		}
else
{
$icon = str_replace("{theme}", $theme['imgdir'], $attachtypes[$ext]['icon']);

		}
else
{
$icon = str_replace("{theme}", $theme['imgdir'], $attachtypes[$ext]['icon']);

 
			$icon = $mybb->get_asset_url($icon);

		}

$name = htmlspecialchars_uni($attachtypes[$ext]['name']);

		}

$name = htmlspecialchars_uni($attachtypes[$ext]['name']);

Zeile 3751Zeile 4031
		$name = $lang->unknown;
}


		$name = $lang->unknown;
}


 
	$icon = htmlspecialchars_uni($icon);

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

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

Zeile 3763Zeile 4044
 */
function get_unviewable_forums($only_readable_threads=false)
{

 */
function get_unviewable_forums($only_readable_threads=false)
{

	global $forum_cache, $permissioncache, $mybb, $unviewable, $templates, $forumpass;

if(!isset($permissions))
{
$permissions = $mybb->usergroup;
}

	global $forum_cache, $permissioncache, $mybb;







if(!is_array($forum_cache))
{


if(!is_array($forum_cache))
{

Zeile 3776Zeile 4052
	}

if(!is_array($permissioncache))

	}

if(!is_array($permissioncache))

	{

	{

		$permissioncache = forum_permissions();
}


		$permissioncache = forum_permissions();
}


	$unviewableforums = '';
$password_forums = array();

	$password_forums = $unviewable = array();


	foreach($forum_cache as $fid => $forum)
{
if($permissioncache[$forum['fid']])

	foreach($forum_cache as $fid => $forum)
{
if($permissioncache[$forum['fid']])

Zeile 3791Zeile 4066
		else
{
$perms = $mybb->usergroup;

		else
{
$perms = $mybb->usergroup;

		}

		}


$pwverified = 1;



$pwverified = 1;


Zeile 3803Zeile 4078
			}

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

			}

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

		}

		}

		else
{
// Check parents for passwords

		else
{
// Check parents for passwords

Zeile 3814Zeile 4089
				{
$pwverified = 0;
}

				{
$pwverified = 0;
}

			}
}


			}
}


		if($perms['canview'] == 0 || $pwverified == 0 || ($only_readable_threads == true && $perms['canviewthreads'] == 0))
{

		if($perms['canview'] == 0 || $pwverified == 0 || ($only_readable_threads == true && $perms['canviewthreads'] == 0))
{

			if($unviewableforums)
{
$unviewableforums .= ",";
}

$unviewableforums .= "'".$forum['fid']."'";

			$unviewable[] = $forum['fid'];






		}
}

		}
}


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

	
$unviewableforums = implode(',', $unviewable);

return $unviewableforums;


}

/**

}

/**

Zeile 4552Zeile 4821
 *
* @param boolean True to return as "hidden" fields
* @param array Array of fields to ignore if first argument is true

 *
* @param boolean True to return as "hidden" fields
* @param array Array of fields to ignore if first argument is true

 
 * @param boolean True to skip all inputs and return only the file path part of the URL

 * @return string The current URL being accessed
*/

 * @return string The current URL being accessed
*/

function get_current_location($fields=false, $ignore=array())

function get_current_location($fields=false, $ignore=array(), $quick=false)

{
if(defined("MYBB_LOCATION"))
{
return MYBB_LOCATION;
}


{
if(defined("MYBB_LOCATION"))
{
return MYBB_LOCATION;
}


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

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

	{

	{

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

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





	{

	{

		$location = htmlspecialchars_uni($_ENV['PHP_SELF']);









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

	}
else
{

	}
else
{

		$location = htmlspecialchars_uni($_SERVER['PHP_SELF']);






		$location = htmlspecialchars_uni($_ENV['PATH_INFO']);
}

if($quick)
{
return $location;

	}

if($fields == true)

	}

if($fields == true)

Zeile 4598Zeile 4877
				}

$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 4612Zeile 4891
		else if(isset($_ENV['QUERY_STRING']))
{
$location .= "?".htmlspecialchars_uni($_ENV['QUERY_STRING']);

		else if(isset($_ENV['QUERY_STRING']))
{
$location .= "?".htmlspecialchars_uni($_ENV['QUERY_STRING']);

		}

		}


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


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





			foreach($post_array as $var)
{
if(isset($_POST[$var]))

			foreach($post_array as $var)
{
if(isset($_POST[$var]))

Zeile 4637Zeile 4916
					$location .= "&amp;";
}
$location .= implode("&amp;", $addloc);

					$location .= "&amp;";
}
$location .= implode("&amp;", $addloc);

			}
}

if(strlen($location) > 150)
{
$location = substr($location, 0, 150);
}

			}
}







return $location;
}


return $location;
}

Zeile 4803Zeile 5077
		else
{
$decimals = 0;

		else
{
$decimals = 0;

		}


		}


		return number_format((double)$number, $decimals, $mybb->settings['decpoint'], $mybb->settings['thousandssep']);
}
}

		return number_format((double)$number, $decimals, $mybb->settings['decpoint'], $mybb->settings['thousandssep']);
}
}

Zeile 4824Zeile 5098
	static $use_iconv;

if(!isset($charset))

	static $use_iconv;

if(!isset($charset))

	{

	{

		$charset = my_strtolower($lang->settings['charset']);
}

if($charset == "utf-8")

		$charset = my_strtolower($lang->settings['charset']);
}

if($charset == "utf-8")

	{

	{

		return $str;
}

if(!isset($use_iconv))

		return $str;
}

if(!isset($use_iconv))

	{

	{

		$use_iconv = function_exists("iconv");
}


		$use_iconv = function_exists("iconv");
}


Zeile 4844Zeile 5118
	}

if($use_iconv || $use_mb)

	}

if($use_iconv || $use_mb)

	{

	{

		if($to)
{
$from_charset = $lang->settings['charset'];
$to_charset = "UTF-8";

		if($to)
{
$from_charset = $lang->settings['charset'];
$to_charset = "UTF-8";

		}

		}

		else
{
$from_charset = "UTF-8";
$to_charset = $lang->settings['charset'];

		else
{
$from_charset = "UTF-8";
$to_charset = $lang->settings['charset'];

		}

		}

		if($use_iconv)
{
return iconv($from_charset, $to_charset."//IGNORE", $str);

		if($use_iconv)
{
return iconv($from_charset, $to_charset."//IGNORE", $str);

		}
else

		}
else

		{
return @mb_convert_encoding($str, $to_charset, $from_charset);
}

		{
return @mb_convert_encoding($str, $to_charset, $from_charset);
}

Zeile 4869Zeile 5143
		if($to)
{
return utf8_encode($str);

		if($to)
{
return utf8_encode($str);

		}

		}

		else
{
return utf8_decode($str);

		else
{
return utf8_decode($str);

		}
}

		}
}

	else
{
return $str;

	else
{
return $str;

Zeile 4882Zeile 5156
}

/**

}

/**

 * Replacement function for PHP's wordwrap(). This version does not break up HTML tags, URLs or unicode references.
*
* @param string The string to be word wrapped
* @return string The word wraped string

 * DEPRECATED! Please use other alternatives.




 */
function my_wordwrap($message)
{

 */
function my_wordwrap($message)
{

	global $mybb;

if($mybb->settings['wordwrap'] > 0)
{
$message = convert_through_utf8($message);

if(!($new_message = @preg_replace("#(((?>[^\s&/<>\"\\-\[\]])|(&\#[a-z0-9]{1,10};)){{$mybb->settings['wordwrap']}})#u", "$0&#8203;", $message)))
{
$new_message = preg_replace("#(((?>[^\s&/<>\"\\-\[\]])|(&\#[a-z0-9]{1,10};)){{$mybb->settings['wordwrap']}})#", "$0&#8203;", $message);
}

$new_message = convert_through_utf8($new_message, false);

return $new_message;
}


 
	return $message;
}


	return $message;
}


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

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

 
	}

switch($db->type)
{
case 'mysql':
case 'mysqli':
$field = 'username';
$efield = 'email';
break;
default:
$field = 'LOWER(username)';
$efield = 'LOWER(email)';
break;

	}

switch($options['username_method'])
{
case 1:

	}

switch($options['username_method'])
{
case 1:

			$sqlwhere = 'LOWER(email)=\''.$username.'\'';

			$sqlwhere = "{$efield}='{$username}'";

			break;
case 2:

			break;
case 2:

			$sqlwhere = 'LOWER(username)=\''.$username.'\' OR LOWER(email)=\''.$username.'\'';

			$sqlwhere = "{$field}='{$username}' OR {$efield}='{$username}'";

			break;
default:

			break;
default:

			$sqlwhere = 'LOWER(username)=\''.$username.'\'';

			$sqlwhere = "{$field}='{$username}'";

			break;
}


			break;
}


Zeile 5712Zeile 5980
	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]))
{
return false;


if(empty($forum_cache[$fid]))
{
return false;

	}


	}


	if($active_override != 1)
{
$parents = explode(",", $forum_cache[$fid]['parentlist']);

	if($active_override != 1)
{
$parents = explode(",", $forum_cache[$fid]['parentlist']);

Zeile 5729Zeile 5997
				if($forum_cache[$parent]['active'] == 0)
{
return false;

				if($forum_cache[$parent]['active'] == 0)
{
return false;

				}
}
}
}


				}
}
}
}


	return $forum_cache[$fid];
}

	return $forum_cache[$fid];
}





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

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

Zeile 5754Zeile 6022
	if(isset($thread_cache[$tid]) && !$recache)
{
return $thread_cache[$tid];

	if(isset($thread_cache[$tid]) && !$recache)
{
return $thread_cache[$tid];

	}

	}

	else
{
$query = $db->simple_select("threads", "*", "tid = '{$tid}'");

	else
{
$query = $db->simple_select("threads", "*", "tid = '{$tid}'");

Zeile 5775Zeile 6043

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


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

 *

 *

 * @param int The post id of the post.
* @param boolean Whether or not to recache the post.
* @param array An array of fields to gather from the database

 * @param int The post id of the post.
* @param boolean Whether or not to recache the post.
* @param array An array of fields to gather from the database

Zeile 5789Zeile 6057
	$pid = (int)$pid;

if(isset($post_cache[$pid]))

	$pid = (int)$pid;

if(isset($post_cache[$pid]))

	{

	{

		return $post_cache[$pid];
}
else
{
$query = $db->simple_select("posts", "*", "pid = '{$pid}'");
$post = $db->fetch_array($query);

		return $post_cache[$pid];
}
else
{
$query = $db->simple_select("posts", "*", "pid = '{$pid}'");
$post = $db->fetch_array($query);





		if($post)
{
$post_cache[$pid] = $post;

		if($post)
{
$post_cache[$pid] = $post;

Zeile 5817Zeile 6085
 */
function get_inactive_forums()
{

 */
function get_inactive_forums()
{

	global $forum_cache, $cache, $inactiveforums;


	global $forum_cache, $cache;


	if(!$forum_cache)
{
cache_forums();

	if(!$forum_cache)
{
cache_forums();

Zeile 5840Zeile 6108
			}
}
}

			}
}
}

 
	

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

return $inactiveforums;

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

return $inactiveforums;

Zeile 6281Zeile 6550
		$ip_range = fetch_ip_range($banned_ip['filter']);
if(is_array($ip_range))
{

		$ip_range = fetch_ip_range($banned_ip['filter']);
if(is_array($ip_range))
{

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

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

			{
$banned = true;
}

			{
$banned = true;
}

Zeile 6399Zeile 6668
}

/**

}

/**

 * Fetch the contents of a remote fle.

 * Fetch the contents of a remote file.

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

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

Zeile 6424Zeile 6693
		curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

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

 
		curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);

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

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

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

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

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














$scheme = '';

if($url['scheme'] == 'https')
{
$scheme = 'ssl://';
if($url['port'] == 80)
{
$url['port'] = 443;
}
}

$fp = @fsockopen($scheme.$url['host'], $url['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['path']} HTTP/1.0";
$headers[] = "Content-Length: ".strlen($post_body);
$headers[] = "Content-Type: application/x-www-form-urlencoded";

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

		}
else
{

		}
else
{

			$headers[] = "GET {$url['path']} HTTP/1.0";
}


			$headers[] = "GET {$url['path']} HTTP/1.0";
}


Zeile 6479Zeile 6761
			$headers[] = $post_body;
}
else

			$headers[] = $post_body;
}
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[] = '';
}

$headers = implode("\r\n", $headers);
if(!@fwrite($fp, $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))

		{

		{

			return false;
}
while(!feof($fp))

			return false;
}
while(!feof($fp))

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

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

	}
else
{
return false;
}
}

/**

	}
else
{
return false;
}
}

/**

 * Checks if a particular user is a super administrator.
*
* @param int The user ID to check against the list of super admins
* @return boolean True if a super admin, false if not
*/
function is_super_admin($uid)

 * Checks if a particular user is a super administrator.
*
* @param int The user ID to check against the list of super admins
* @return boolean True if a super admin, false if not
*/
function is_super_admin($uid)

{

{

	static $super_admins;

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

	static $super_admins;

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

	}

	}


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


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

	{

	{

		return true;
}
}

		return true;
}
}

Zeile 6538Zeile 6820
 * Originates from frostschutz's PluginLibrary
* github.com/frostschutz
*

 * Originates from frostschutz's PluginLibrary
* github.com/frostschutz
*

 * @param mixed A selection of groups to check

 * @param mixed A selection of groups to check or -1 for any group

 * @param mixed User to check selection against

 * @param mixed User to check selection against

 * @return mixed Array of groups this user belongs to

 * @return array Array of groups specified in the first param to which the user belongs

 */
function is_member($groups, $user = false)
{
global $mybb;

 */
function is_member($groups, $user = false)
{
global $mybb;

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


if($user == false)
{


if($user == false)
{

Zeile 6560Zeile 6847
	$memberships[] = $user['usergroup'];

if(!is_array($groups))

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

if(!is_array($groups))

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

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

		{

		{

			$groups = (array)$groups;








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

		}
}


		}
}


Zeile 6730Zeile 7024
 * @param string The ban length string
* @param int The optional UNIX timestamp, if 0, current time is used.
* @return int The UNIX timestamp when the ban will be lifted

 * @param string The ban length string
* @param int The optional UNIX timestamp, if 0, current time is used.
* @return int The UNIX timestamp when the ban will be lifted

 */

 */

function ban_date2timestamp($date, $stamp=0)
{
if($stamp == 0)
{
$stamp = TIME_NOW;

function ban_date2timestamp($date, $stamp=0)
{
if($stamp == 0)
{
$stamp = TIME_NOW;

	}

	}

	$d = explode('-', $date);
$nowdate = date("H-j-n-Y", $stamp);
$n = explode('-', $nowdate);

	$d = explode('-', $date);
$nowdate = date("H-j-n-Y", $stamp);
$n = explode('-', $nowdate);

Zeile 6748Zeile 7042

/**
* Expire old warnings in the database.


/**
* Expire old warnings in the database.

 *
*/

 *
*/

function expire_warnings()
{
global $warningshandler;

function expire_warnings()
{
global $warningshandler;

Zeile 6783Zeile 7077
	$result = chmod($file, octdec($mode));
umask($old_umask);
return $result;

	$result = chmod($file, octdec($mode));
umask($old_umask);
return $result;

}


}


/**
* Custom rmdir function to loop through an entire directory and delete all files/folders within
*

/**
* Custom rmdir function to loop through an entire directory and delete all files/folders within
*

Zeile 6798Zeile 7092
	if(!isset($orig_dir))
{
$orig_dir = $path;

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

	}

	}


if(@is_dir($path) && !@is_link($path))
{


if(@is_dir($path) && !@is_link($path))
{

Zeile 6812Zeile 7106
				}
}
@closedir($dh);

				}
}
@closedir($dh);

		}

		}


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


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





		return @rmdir($path);
}


		return @rmdir($path);
}


Zeile 6838Zeile 7132
	foreach($array as $array2)
{
$count += count($array2);

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

	}


	}


	return $count;
}


	return $count;
}


Zeile 6866Zeile 7160
	}

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

	}

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

	{

	{

		$ip_long -= 4294967296;
}

		$ip_long -= 4294967296;
}





	return $ip_long;

	return $ip_long;

}

/**

}

/**

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

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

Zeile 6893Zeile 7187

/**
* 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 The IP to convert
* @return string IP in 32bit or 128bit binary format
*/

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

Zeile 6907Zeile 7201
	{
/**
* 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 6953Zeile 7247
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 6998Zeile 7292
	if(strpos($ipaddress, '*') !== false)
{
if(strpos($ipaddress, ':') !== false)

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

		{

		{

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

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

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

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

		else
{
// IPv4

		else
{
// IPv4

 
			$ip_bits = count(explode('.', $ipaddress));
if($ip_bits < 4)
{
// Support for 127.0.*
$replacement = str_repeat('.*', 4-$ip_bits);
$ipaddress = substr_replace($ipaddress, $replacement, strrpos($ipaddress, '*')+1, 0);
}

			$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 = str_replace('*', '255', $ipaddress);
$lower = str_replace('*', '0', $ipaddress);
}
$upper = my_inet_pton($upper);
$lower = my_inet_pton($lower);
if($upper === false || $lower === false)

		{

		{

			return false;
}
return array($lower, $upper);

			return false;
}
return array($lower, $upper);

Zeile 7086Zeile 7387
		}

return array($ip_lower_pack, $ip_higher_pack);

		}

return array($ip_lower_pack, $ip_higher_pack);

	}

	}

	// Just on IP address
else
{

	// Just on IP address
else
{

Zeile 7130Zeile 7431
 * @return array The bad files
*/
function verify_files($path=MYBB_ROOT, $count=0)

 * @return array The bad files
*/
function verify_files($path=MYBB_ROOT, $count=0)

{

{

	global $mybb, $checksums, $bad_verify_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_ext = array("attach");

	// 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_ext = array("attach");





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

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

	{

	{

		$path = substr($path, 0, -1);
}

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

		$path = substr($path, 0, -1);
}

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

	}

	}


// Make sure that we're in a directory and it's not a symbolic link
if(@is_dir($path) && !@is_link($path))


// Make sure that we're in a directory and it's not a symbolic link
if(@is_dir($path) && !@is_link($path))

Zeile 7220Zeile 7521

/**
* Returns a signed value equal to an integer


/**
* Returns a signed value equal to an integer

 *

 *

 * @param int The integer
* @return string The signed equivalent
*/

 * @param int The integer
* @return string The signed equivalent
*/

Zeile 7249Zeile 7550
	if(DIRECTORY_SEPARATOR != '\\')
{
// Unix/Linux

	if(DIRECTORY_SEPARATOR != '\\')
{
// Unix/Linux

		// Use OpenSSL when available

		// Use OpenSSL when available

		if(function_exists('openssl_random_pseudo_bytes'))
{
$output = openssl_random_pseudo_bytes($count);

		if(function_exists('openssl_random_pseudo_bytes'))
{
$output = openssl_random_pseudo_bytes($count);

Zeile 7484Zeile 7785
	}

return $string;

	}

return $string;

}

/**

}

/**

 * Match a sequence
*
* @param string The string to match from

 * Match a sequence
*
* @param string The string to match from

Zeile 7722Zeile 8023
			}

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

			}

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

		}


		}


		if(isset($revert))
{
// Revert language
$lang->set_language($mybb->user['language']);
$lang->load($pm['language_file']);
}

		if(isset($revert))
{
// Revert language
$lang->set_language($mybb->user['language']);
$lang->load($pm['language_file']);
}

	}


	}


	if(!$pm['subject'] ||!$pm['message'] || !$pm['touid'] || (!$pm['receivepms'] && !$admin_override))
{
return false;

	if(!$pm['subject'] ||!$pm['message'] || !$pm['touid'] || (!$pm['receivepms'] && !$admin_override))
{
return false;

	}

$lang->load('messages');

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

	}

$lang->load('messages');







	$pmhandler = new PMDataHandler();



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

$pmhandler = new PMDataHandler();


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


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

Zeile 7753Zeile 8054
		$recipients_to = $toid;
}
else

		$recipients_to = $toid;
}
else

	{

	{

		$recipients_to = array($toid);

		$recipients_to = array($toid);

	}


	}


	$recipients_bcc = array();

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

	$recipients_bcc = array();

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

	{

	{

		$fromid = (int)$mybb->user['uid'];

		$fromid = (int)$mybb->user['uid'];

	}

	}

	elseif((int)$fromid < 0)
{
$fromid = 0;

	elseif((int)$fromid < 0)
{
$fromid = 0;

	}


	}


	// Build our final PM array
$pm = array(
"subject" => $subject,

	// Build our final PM array
$pm = array(
"subject" => $subject,

Zeile 7782Zeile 8083
	);

if(isset($session))

	);

if(isset($session))

	{

	{

		$pm['ipaddress'] = $session->packedip;
}


		$pm['ipaddress'] = $session->packedip;
}


Zeile 7792Zeile 8093
		"savecopy" => 0,
"readreceipt" => 0
);

		"savecopy" => 0,
"readreceipt" => 0
);





	$pm['saveasdraft'] = 0;

// Admin override
$pmhandler->admin_override = (int)$admin_override;

	$pm['saveasdraft'] = 0;

// Admin override
$pmhandler->admin_override = (int)$admin_override;





	$pmhandler->set_data($pm);

if($pmhandler->validate_pm())

	$pmhandler->set_data($pm);

if($pmhandler->validate_pm())

Zeile 7839Zeile 8140
		'email'     => $db->escape_string($email),
'ipaddress' => $db->escape_binary($ip_address),
'dateline' => (int)TIME_NOW,

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

		'data'      => $db->escape_string(@serialize($data)),

		'data'      => $db->escape_string(@my_serialize($data)),

	);

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

	);

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

 
}

/**
* Copy a file to the CDN.
*
* @param string $file_path The path to the file to upload to the CDN.
*
* @param string $uploaded_path The path the file was uploaded to, reference parameter for when this may be needed.
*
* @return bool Whether the file was copied successfully.
*/
function copy_file_to_cdn($file_path = '', &$uploaded_path = null)
{
global $mybb, $plugins;

$success = false;

$file_path = (string)$file_path;

$real_file_path = realpath($file_path);

$file_dir_path = dirname($real_file_path);
$file_dir_path = str_replace(MYBB_ROOT, '', $file_dir_path);
$file_dir_path = ltrim($file_dir_path, './\\');

$file_name = basename($real_file_path);

if(file_exists($file_path))
{
if($mybb->settings['usecdn'] && !empty($mybb->settings['cdnpath']))
{
$cdn_path = rtrim($mybb->settings['cdnpath'], '/\\');

if(substr($file_dir_path, 0, my_strlen(MYBB_ROOT)) == MYBB_ROOT)
{
$file_dir_path = str_replace(MYBB_ROOT, '', $file_dir_path);
}

$cdn_upload_path = $cdn_path . DIRECTORY_SEPARATOR . $file_dir_path;

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)
{
$success = @copy($file_path, $cdn_upload_path.DIRECTORY_SEPARATOR.$file_name);

if($success)
{
$uploaded_path = $cdn_upload_path;
}
}
}
}

if(is_object($plugins))
{
$hook_args = array(
'file_path' => &$file_path,
'real_file_path' => &$real_file_path,
'file_name' => &$file_name,
'uploaded_path' => &$uploaded_path,
'success' => &$success,
);

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

return $success;

}

}