Vergleich inc/functions.php - 1.8.35 - 1.8.39

  Keine Änderungen   Hinzugefügt   Modifiziert   Entfernt
Zeile 1644Zeile 1644
			$groupperms = $mybb->usergroup;
}
}

			$groupperms = $mybb->usergroup;
}
}

 
	else 
{
$groupperms = usergroup_permissions($gid);
}


if(!is_array($forum_cache))
{


if(!is_array($forum_cache))
{

Zeile 1694Zeile 1698
{
global $groupscache, $forum_cache, $fpermcache, $mybb, $fpermfields;


{
global $groupscache, $forum_cache, $fpermcache, $mybb, $fpermfields;


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








    if(isset($gid))
{
$groups = explode(",", $gid);
}
else
{
$groups = array();
}


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


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

Zeile 2727Zeile 2738
		{
// 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);








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

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

		}
else if(@file_exists("/proc/loadavg") && $load = @file_get_contents("/proc/loadavg"))
{
$serverload = explode(" ", $load);
$serverload[0] = round($serverload[0], 4);

		}
else if(@file_exists("/proc/loadavg") && $load = @file_get_contents("/proc/loadavg"))
{
$serverload = explode(" ", $load);
$serverload[0] = round($serverload[0], 4);

		}

		}

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

			{
if(strpos(",".$func_blacklist.",", 'exec') !== false)
{

			{
if(strpos(",".$func_blacklist.",", 'exec') !== false)
{

					return $lang->unknown;
}
}
// PHP disabled functions?
if($func_blacklist = @ini_get('disable_functions'))

					return $lang->unknown;
}
}
// 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;
}

			}


			}


			$load = @exec("uptime");
$load = explode("load average: ", $load);
$serverload = explode(",", $load[1]);

			$load = @exec("uptime");
$load = explode("load average: ", $load);
$serverload = explode(",", $load[1]);

Zeile 2775Zeile 2792
	$returnload = trim($serverload[0]);

return $returnload;

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

return $returnload;

}

}


/**
* Returns the amount of memory allocated to the script.


/**
* Returns the amount of memory allocated to the script.

Zeile 2823Zeile 2840
			'numdeletedposts' => '+0',
'numdeletedthreads' => '+0',
'inserted' => false // Reset after changes are inserted into cache

			'numdeletedposts' => '+0',
'numdeletedthreads' => '+0',
'inserted' => false // Reset after changes are inserted into cache

		);
$stats = $stats_changes;

		);
$stats = $stats_changes;

	}

if($force) // Force writing to cache?

	}

if($force) // Force writing to cache?

	{

	{

		if(!empty($changes))
{
// Calculate before writing to cache

		if(!empty($changes))
{
// Calculate before writing to cache

Zeile 2871Zeile 2888
					{
$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 2969Zeile 2986
			{
$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 3068Zeile 3085
 * Update the last post information for a specific forum
*
* @param int $fid The forum ID

 * Update the last post information for a specific forum
*
* @param int $fid The forum ID

 */

 */

function update_forum_lastpost($fid)
{
global $db;

function update_forum_lastpost($fid)
{
global $db;

Zeile 3085Zeile 3102
	if($db->num_rows($query) > 0)
{
$lastpost = $db->fetch_array($query);

	if($db->num_rows($query) > 0)
{
$lastpost = $db->fetch_array($query);





		$updated_forum = array(
"lastpost" => (int)$lastpost['lastpost'],
"lastposter" => $db->escape_string($lastpost['lastposter']),

		$updated_forum = array(
"lastpost" => (int)$lastpost['lastpost'],
"lastposter" => $db->escape_string($lastpost['lastposter']),

Zeile 3114Zeile 3131
 * @param array $changes 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 $changes 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;


{
global $db;


	$update_query = array();
$tid = (int)$tid;


	$update_query = array();
$tid = (int)$tid;


Zeile 3131Zeile 3148
		if(array_key_exists($counter, $changes))
{
if(substr($changes[$counter], 0, 2) == "+-")

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

			{

			{

				$changes[$counter] = substr($changes[$counter], 1);
}
// Adding or subtracting from previous value?

				$changes[$counter] = substr($changes[$counter], 1);
}
// Adding or subtracting from previous value?

Zeile 3145Zeile 3162
			else
{
$update_query[$counter] = $changes[$counter];

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

// Only update if we're actually doing something

	$db->free_result($query);

// Only update if we're actually doing something

Zeile 3177Zeile 3194

// If this is a moved thread marker, don't update it - we need it to stay as it is
if(strpos($thread['closed'], 'moved|') !== false)


// If this is a moved thread marker, don't update it - we need it to stay as it is
if(strpos($thread['closed'], 'moved|') !== false)

	{

	{

		return;
}


		return;
}


Zeile 3255Zeile 3272
	// Fetch above counters for this user
$query = $db->simple_select("users", implode(",", $counters), "uid='{$uid}'");
$user = $db->fetch_array($query);

	// Fetch above counters for this user
$query = $db->simple_select("users", implode(",", $counters), "uid='{$uid}'");
$user = $db->fetch_array($query);


foreach($counters as $counter)

	
if($user)

	{

	{

		if(array_key_exists($counter, $changes))

		foreach($counters as $counter)

		{

		{

			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(array_key_exists($counter, $changes))






			{

			{

				if((int)$changes[$counter] != 0)

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

				{

				{

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













					$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] = $user[$counter] + $changes[$counter];
}
}
else
{
$update_query[$counter] = $changes[$counter];

				}

				}

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

			}
}
}

			}
}
}

Zeile 3311Zeile 3331
	}

return $moderation->delete_thread($tid);

	}

return $moderation->delete_thread($tid);

}

/**

}

/**

 * Deletes a post from the database
*
* @param int $pid The thread ID

 * Deletes a post from the database
*
* @param int $pid The thread ID

Zeile 3438Zeile 3458
function get_extension($file)
{
return my_strtolower(my_substr(strrchr($file, "."), 1));

function get_extension($file)
{
return my_strtolower(my_substr(strrchr($file, "."), 1));

}

/**

}

/**

 * Generates a random string.
*
* @param int $length The length of the string to generate.

 * Generates a random string.
*
* @param int $length The length of the string to generate.

Zeile 3448Zeile 3468
 * @return string The random string.
*/
function random_str($length=8, $complex=false)

 * @return string The random string.
*/
function random_str($length=8, $complex=false)

{

{

	$set = array_merge(range(0, 9), range('A', 'Z'), range('a', 'z'));
$str = array();


	$set = array_merge(range(0, 9), range('A', 'Z'), range('a', 'z'));
$str = array();


Zeile 3502Zeile 3522
		if($displaygroup != 0)
{
$usergroup = $displaygroup;

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

		}


		}


		$format = "{username}";

if(isset($groupscache[$usergroup]))

		$format = "{username}";

if(isset($groupscache[$usergroup]))

Zeile 3519Zeile 3539
		$format = stripslashes($format);

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

		$format = stripslashes($format);

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





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

$format = $parameters['format'];

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

$format = $parameters['format'];

Zeile 3567Zeile 3587
	}

if(!$max_dimensions)

	}

if(!$max_dimensions)

	{

	{

		$max_dimensions = $mybb->settings['maxavatardims'];
}

// An empty key wouldn't work so we need to add a fall back
$key = $dimensions;
if(empty($key))

		$max_dimensions = $mybb->settings['maxavatardims'];
}

// An empty key wouldn't work so we need to add a fall back
$key = $dimensions;
if(empty($key))

	{

	{

		$key = 'default';

		$key = 'default';

	}

	}

	$key2 = $max_dimensions;
if(empty($key2))
{
$key2 = 'default';

	$key2 = $max_dimensions;
if(empty($key2))
{
$key2 = 'default';

	}


	}


	if(isset($avatars[$avatar][$key][$key2]))
{
return $avatars[$avatar][$key][$key2];

	if(isset($avatars[$avatar][$key][$key2]))
{
return $avatars[$avatar][$key][$key2];

Zeile 3630Zeile 3650
function build_mycode_inserter($bind="message", $smilies = true)
{
global $db, $mybb, $theme, $templates, $lang, $plugins, $smiliecache, $cache;

function build_mycode_inserter($bind="message", $smilies = true)
{
global $db, $mybb, $theme, $templates, $lang, $plugins, $smiliecache, $cache;

 

$codeinsert = '';


if($mybb->settings['bbcodeinserter'] != 0)
{


if($mybb->settings['bbcodeinserter'] != 0)
{

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


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


		if(!empty($subscription) && $subscription['tid'])

		if($subscription)

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

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

Zeile 4589Zeile 4611
	}

return $time;

	}

return $time;

}

}


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


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

Zeile 5733Zeile 5755
	}
else
{

	}
else
{

		$parts = explode('.', $number);








        if(isset($number))
{
$parts = explode('.', $number);
}
else
{
$parts = array();
}


if(isset($parts[1]))
{


if(isset($parts[1]))
{

Zeile 6120Zeile 6149

$string = preg_replace("#&\#([0-9]+);#", "-", $string);



$string = preg_replace("#&\#([0-9]+);#", "-", $string);


	if(strtolower($lang->settings['charset']) == "utf-8")

	if(isset($lang->settings['charset']) && strtolower($lang->settings['charset']) == "utf-8")

	{
// Get rid of any excess RTL and LTR override for they are the workings of the devil
$string = str_replace(dec_to_utf8(8238), "", $string);

	{
// Get rid of any excess RTL and LTR override for they are the workings of the devil
$string = str_replace(dec_to_utf8(8238), "", $string);

Zeile 7045Zeile 7074
		"~"
);
$terms = str_replace($bad_characters, '', $terms);

		"~"
);
$terms = str_replace($bad_characters, '', $terms);

 
	$words = array();


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


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

 
		foreach($terms as $phrase)
{
$phrase = htmlspecialchars_uni($phrase);

		foreach($terms as $phrase)
{
$phrase = htmlspecialchars_uni($phrase);

Zeile 7097Zeile 7126
				$words[] = trim($word);
}
}

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

	}

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
usort($words, 'build_highlight_array_sort');

	}

// 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, 'build_highlight_array_sort');

 

$highlight_cache = array();


// 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 7128Zeile 7154
	}

return $highlight_cache;

	}

return $highlight_cache;

}

}


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


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

Zeile 7141Zeile 7167
{
return strlen($b) - strlen($a);
}

{
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 7154Zeile 7180
	$dest = '';

if($src < 0)

	$dest = '';

if($src < 0)

	{

	{

		return false;
}
elseif($src <= 0x007f)

		return false;
}
elseif($src <= 0x007f)

Zeile 7209Zeile 7235
			if($update_lastuse == true)
{
$db->update_query("banfilters", array("lastuse" => TIME_NOW), "fid='{$banned_username['fid']}'");

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

			}

			}

			return true;
}
}

			return true;
}
}

Zeile 7318Zeile 7344
 * Returns an array of supported timezones
*
* @return string[] Key is timezone offset, Value the language description

 * Returns an array of supported timezones
*
* @return string[] Key is timezone offset, Value the language description

 */

 */

function get_supported_timezones()
{
global $lang;

function get_supported_timezones()
{
global $lang;

Zeile 7537Zeile 7563
			$curlopt[10203] = array(
$url_components['host'].':'.$url_components['port'].':'.$destination_address
);

			$curlopt[10203] = array(
$url_components['host'].':'.$url_components['port'].':'.$destination_address
);

 
		}

if(defined('CURLOPT_DISALLOW_USERNAME_IN_URL'))
{
$curlopt[CURLOPT_DISALLOW_USERNAME_IN_URL] = true;

		}

if(!empty($post_body))

		}

if(!empty($post_body))