Vergleich inc/functions.php - 1.8.36 - 1.8.38

  Keine Änderungen   Hinzugefügt   Modifiziert   Entfernt
Zeile 1694Zeile 1694
{
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 2734
		{
// 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();

 

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[0] = round($serverload[0], 4);
}
else if(@file_exists("/proc/loadavg") && $load = @file_get_contents("/proc/loadavg"))

Zeile 2871Zeile 2884
					{
$new_stats[$counter] = 0;
}

					{
$new_stats[$counter] = 0;
}

				}

				}

			}
else
{

			}
else
{

Zeile 2924Zeile 2937
	$cache->update("stats", $stats, "dateline");
$stats_changes['inserted'] = true;
}

	$cache->update("stats", $stats, "dateline");
$stats_changes['inserted'] = true;
}





/**
* Updates the forum counters with a specific value (or addition/subtraction of the previous value)
*

/**
* Updates the forum counters with a specific value (or addition/subtraction of the previous value)
*

Zeile 2942Zeile 2955
	// 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))
{


foreach($counters as $counter)
{
if(array_key_exists($counter, $changes))
{

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

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

Zeile 3170Zeile 3183
 * @param int $tid The thread ID
*/
function update_thread_data($tid)

 * @param int $tid The thread ID
*/
function update_thread_data($tid)

{
global $db;


{
global $db;


	$thread = get_thread($tid);

	$thread = get_thread($tid);





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

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

	}

$query = $db->query("

	}

$query = $db->query("

		SELECT u.uid, u.username, 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.username AS postusername, p.dateline
FROM ".TABLE_PREFIX."posts p
LEFT JOIN ".TABLE_PREFIX."users u ON (u.uid=p.uid)

Zeile 3190Zeile 3203
		LIMIT 1"
);
$lastpost = $db->fetch_array($query);

		LIMIT 1"
);
$lastpost = $db->fetch_array($query);





	$db->free_result($query);

$query = $db->query("

	$db->free_result($query);

$query = $db->query("

Zeile 3208Zeile 3221
	if(empty($firstpost['username']))
{
$firstpost['username'] = $firstpost['postusername'];

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

	}


	}


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

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

Zeile 3246Zeile 3259
function update_user_counters($uid, $changes=array())
{
global $db;

function update_user_counters($uid, $changes=array())
{
global $db;





	$update_query = array();

	$update_query = array();





	$counters = array('postnum', 'threadnum');
$uid = (int)$uid;

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

	$counters = array('postnum', 'threadnum');
$uid = (int)$uid;

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

	
if($user)
{
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;
}

			}
}

			}
}

	}

$db->free_result($query);

	}

$db->free_result($query);


// Only update if we're actually doing something
if(count($update_query) > 0)
{
$db->update_query("users", $update_query, "uid='{$uid}'");


// Only update if we're actually doing something
if(count($update_query) > 0)
{
$db->update_query("users", $update_query, "uid='{$uid}'");

	}
}


	}
}


/**
* Deletes a thread from the database
*

/**
* Deletes a thread from the database
*

Zeile 3301Zeile 3317
 * @return bool
*/
function delete_thread($tid)

 * @return bool
*/
function delete_thread($tid)

{
global $moderation;


{
global $moderation;


	if(!is_object($moderation))
{
require_once MYBB_ROOT."inc/class_moderation.php";
$moderation = new Moderation;
}

	if(!is_object($moderation))
{
require_once MYBB_ROOT."inc/class_moderation.php";
$moderation = new Moderation;
}





	return $moderation->delete_thread($tid);

	return $moderation->delete_thread($tid);

}


}


/**
* Deletes a post from the database
*

/**
* Deletes a post from the database
*

Zeile 3330Zeile 3346
	}

return $moderation->delete_post($pid);

	}

return $moderation->delete_post($pid);

}

}


/**
* Builds a forum jump menu


/**
* Builds a forum jump menu

Zeile 3903Zeile 3919
		$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 5130Zeile 5146
	switch($type)
{
case "posts":

	switch($type)
{
case "posts":

			if(is_array($id))
{

			if(is_array($id))
{

				$rids = implode("','", $id);
$rids = "'0','$rids'";
$db->update_query("reportedcontent", array('reportstatus' => 1), "id IN($rids) AND reportstatus='0' AND (type = 'post' OR type = '')");

				$rids = implode("','", $id);
$rids = "'0','$rids'";
$db->update_query("reportedcontent", array('reportstatus' => 1), "id IN($rids) AND reportstatus='0' AND (type = 'post' OR type = '')");

Zeile 5352Zeile 5368
	if(!empty($nicetime))
{
return implode(", ", $nicetime);

	if(!empty($nicetime))
{
return implode(", ", $nicetime);

	}
}


	}
}


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

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

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


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


	if($quick)
{
return $location;
}


	if($quick)
{
return $location;
}


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

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

Zeile 5534Zeile 5550
	else
{
$parameters = array();

	else
{
$parameters = array();





		if(isset($_SERVER['QUERY_STRING']))

		if(isset($_SERVER['QUERY_STRING']))

		{

		{

			$current_query_string = $_SERVER['QUERY_STRING'];
}
else if(isset($_ENV['QUERY_STRING']))
{
$current_query_string = $_ENV['QUERY_STRING'];
} else

			$current_query_string = $_SERVER['QUERY_STRING'];
}
else if(isset($_ENV['QUERY_STRING']))
{
$current_query_string = $_ENV['QUERY_STRING'];
} else

		{

		{

			$current_query_string = '';
}

			$current_query_string = '';
}





		parse_str($current_query_string, $current_parameters);

foreach($current_parameters as $name => $value)
{
if(!in_array($name, $ignore))

		parse_str($current_query_string, $current_parameters);

foreach($current_parameters as $name => $value)
{
if(!in_array($name, $ignore))

			{

			{

				$parameters[$name] = $value;
}
}

				$parameters[$name] = $value;
}
}

Zeile 5576Zeile 5592
		}

return $location;

		}

return $location;

	}
}

/**

	}
}

/**

 * Build a theme selection menu
*
* @param string $name The name of the menu

 * Build a theme selection menu
*
* @param string $name The name of the menu

Zeile 5626Zeile 5642
				}

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

				}

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

				{

				{

					$theme['name'] = htmlspecialchars_uni($theme['name']);
eval("\$themeselect_option .= \"".$templates->get("usercp_themeselector_option")."\";");
++$num_themes;

					$theme['name'] = htmlspecialchars_uni($theme['name']);
eval("\$themeselect_option .= \"".$templates->get("usercp_themeselector_option")."\";");
++$num_themes;

Zeile 5653Zeile 5669
		}

return $themeselect;

		}

return $themeselect;

	}
else

	}
else

	{
return false;
}

	{
return false;
}

Zeile 5673Zeile 5689
	if(!is_array($tcache))
{
$query = $db->simple_select('themes', 'tid, name, pid, allowedgroups', "pid!='0'");

	if(!is_array($tcache))
{
$query = $db->simple_select('themes', 'tid, name, pid, allowedgroups', "pid!='0'");





		while($theme = $db->fetch_array($query))
{
$tcache[$theme['pid']][$theme['tid']] = $theme;

		while($theme = $db->fetch_array($query))
{
$tcache[$theme['pid']][$theme['tid']] = $theme;

Zeile 5683Zeile 5699
	$s_theme = false;

foreach($tcache as $themes)

	$s_theme = false;

foreach($tcache as $themes)

	{

	{

		foreach($themes as $theme)
{
if($tid == $theme['tid'])

		foreach($themes as $theme)
{
if($tid == $theme['tid'])

Zeile 5692Zeile 5708
				break 2;
}
}

				break 2;
}
}

	}

	}


return $s_theme;
}


return $s_theme;
}

Zeile 5711Zeile 5727
	$message = str_replace("\"", "&quot;", $message);
return $message;
}

	$message = str_replace("\"", "&quot;", $message);
return $message;
}





/**
* Custom function for formatting numbers.
*

/**
* Custom function for formatting numbers.
*

Zeile 5730Zeile 5746
	if(is_int($number))
{
return number_format($number, 0, $mybb->settings['decpoint'], $mybb->settings['thousandssep']);

	if(is_int($number))
{
return number_format($number, 0, $mybb->settings['decpoint'], $mybb->settings['thousandssep']);

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








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


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


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

Zeile 6120Zeile 6143

$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 6251Zeile 6274
	}

if(function_exists("mb_strpos"))

	}

if(function_exists("mb_strpos"))

	{
$position = mb_strpos($haystack, $needle, $offset);
}

	{
$position = mb_strpos($haystack, $needle, $offset);
}

	else
{
$position = strpos($haystack, $needle, $offset);
}

	else
{
$position = strpos($haystack, $needle, $offset);
}





	return $position;

	return $position;

}

/**

}

/**

 * Ups the case of a string, mb strings accounted for
*
* @param string $string The string to up.

 * Ups the case of a string, mb strings accounted for
*
* @param string $string The string to up.

Zeile 6271Zeile 6294
function my_strtoupper($string)
{
if(function_exists("mb_strtoupper"))

function my_strtoupper($string)
{
if(function_exists("mb_strtoupper"))

	{

	{

		$string = mb_strtoupper($string);

		$string = mb_strtoupper($string);

	}

	}

	else
{
$string = strtoupper($string);
}

return $string;

	else
{
$string = strtoupper($string);
}

return $string;

}

}


/**
* Returns any html entities to their original character


/**
* Returns any html entities to their original character

Zeile 6289Zeile 6312
 * @return string The un-htmlentitied' string.
*/
function unhtmlentities($string)

 * @return string The un-htmlentitied' string.
*/
function unhtmlentities($string)

{

{

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

	// Replace numeric entities
$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);
$trans_tbl = array_flip($trans_tbl);

return strtr($string, $trans_tbl);

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

return strtr($string, $trans_tbl);

}

}


/**
* Returns any ascii to it's character (utf-8 safe).


/**
* Returns any ascii to it's character (utf-8 safe).

Zeile 6327Zeile 6350
		return chr(0xF0 | $c >> 18) . chr(0x80 | $c >> 12 & 0x3F)
. chr(0x80 | $c >> 6 & 0x3F)
. chr(0x80 | $c & 0x3F);

		return chr(0xF0 | $c >> 18) . chr(0x80 | $c >> 12 & 0x3F)
. chr(0x80 | $c >> 6 & 0x3F)
. chr(0x80 | $c & 0x3F);

	}
else
{
return false;
}
}

/**

	}
else
{
return false;
}
}

/**

 * Returns any ascii to it's character (utf-8 safe).
*
* @param array $matches Matches.

 * Returns any ascii to it's character (utf-8 safe).
*
* @param array $matches Matches.

Zeile 7045Zeile 7068
		"~"
);
$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 7120
				$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 7148
	}

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 7161
{
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 7174
	$dest = '';

if($src < 0)

	$dest = '';

if($src < 0)

	{

	{

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

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

Zeile 7209Zeile 7229
			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 7338
 * 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 7557
			$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))