Vergleich inc/functions.php - 1.8.33 - 1.8.36

  Keine Änderungen   Hinzugefügt   Modifiziert   Entfernt
Zeile 588Zeile 588
			}
}


			}
}


		$plugins->run_hooks('my_mailhandler_builtin_after_init', $my_mailhandler_builtin);




		if(isset($plugins) && is_object($plugins))
{
$plugins->run_hooks('my_mailhandler_builtin_after_init', $my_mailhandler_builtin);
}


return $my_mailhandler_builtin;
}


return $my_mailhandler_builtin;
}

Zeile 598Zeile 601
	{
require_once MYBB_ROOT . "inc/class_mailhandler.php";


	{
require_once MYBB_ROOT . "inc/class_mailhandler.php";


		$plugins->run_hooks('my_mailhandler_init', $my_mailhandler);





		if(isset($plugins) && is_object($plugins))
{
$plugins->run_hooks('my_mailhandler_init', $my_mailhandler);
}


		// If no plugin has ever created the mail handler, resort to use the built-in one.
if(!is_object($my_mailhandler) || !($my_mailhandler instanceof MailHandler))
{
$my_mailhandler = &get_my_mailhandler(true);

		// If no plugin has ever created the mail handler, resort to use the built-in one.
if(!is_object($my_mailhandler) || !($my_mailhandler instanceof MailHandler))
{
$my_mailhandler = &get_my_mailhandler(true);

		}
}


		}
}


	return $my_mailhandler;
}


	return $my_mailhandler;
}


Zeile 664Zeile 670
		'continue_process' => &$continue_process,
);


		'continue_process' => &$continue_process,
);


	$plugins->run_hooks('my_mail_pre_build_message', $my_mail_parameters);




	if(isset($plugins) && is_object($plugins))
{
$plugins->run_hooks('my_mail_pre_build_message', $my_mail_parameters);
}


// Build the mail message.
$mail->build_message($to, $subject, $message, $from, $charset, $headers, $format, $message_text, $return_email);



// Build the mail message.
$mail->build_message($to, $subject, $message, $from, $charset, $headers, $format, $message_text, $return_email);


	$plugins->run_hooks('my_mail_pre_send', $my_mail_parameters);





	if(isset($plugins) && is_object($plugins))
{
$plugins->run_hooks('my_mail_pre_send', $my_mail_parameters);
}


	// Check if the hooked plugins still suggest to send the mail.
if($continue_process)
{
$is_mail_sent = $mail->send();

	// Check if the hooked plugins still suggest to send the mail.
if($continue_process)
{
$is_mail_sent = $mail->send();

	}

	}





	$plugins->run_hooks('my_mail_post_send', $my_mail_parameters);




	if(isset($plugins) && is_object($plugins))
{
$plugins->run_hooks('my_mail_post_send', $my_mail_parameters);
}


return $is_mail_sent;
}


return $is_mail_sent;
}

Zeile 692Zeile 707
function generate_post_check($rotation_shift=0)
{
global $mybb, $session;

function generate_post_check($rotation_shift=0)
{
global $mybb, $session;





	$rotation_interval = 6 * 3600;
$rotation = floor(TIME_NOW / $rotation_interval) + $rotation_shift;


	$rotation_interval = 6 * 3600;
$rotation = floor(TIME_NOW / $rotation_interval) + $rotation_shift;


Zeile 725Zeile 740
 * @return bool|void Result boolean if $silent is true, otherwise shows an error to the user
*/
function verify_post_check($code, $silent=false)

 * @return bool|void Result boolean if $silent is true, otherwise shows an error to the user
*/
function verify_post_check($code, $silent=false)

{

{

	global $lang;
if(
generate_post_check() !== $code &&

	global $lang;
if(
generate_post_check() !== $code &&

Zeile 988Zeile 1003
		"nopermission" => '1',
"location1" => 0,
"location2" => 0

		"nopermission" => '1',
"location1" => 0,
"location2" => 0

	);

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

	);

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


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


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

Zeile 1650Zeile 1665
		if(empty($cached_forum_permissions_permissions[$gid][$fid]))
{
$cached_forum_permissions_permissions[$gid][$fid] = fetch_forum_permissions($fid, $gid, $groupperms);

		if(empty($cached_forum_permissions_permissions[$gid][$fid]))
{
$cached_forum_permissions_permissions[$gid][$fid] = fetch_forum_permissions($fid, $gid, $groupperms);

		}
return $cached_forum_permissions_permissions[$gid][$fid];

		}
return $cached_forum_permissions_permissions[$gid][$fid];

	}
else
{

	}
else
{

Zeile 1660Zeile 1675
			foreach($forum_cache as $forum)
{
$cached_forum_permissions[$gid][$forum['fid']] = fetch_forum_permissions($forum['fid'], $gid, $groupperms);

			foreach($forum_cache as $forum)
{
$cached_forum_permissions[$gid][$forum['fid']] = fetch_forum_permissions($forum['fid'], $gid, $groupperms);

			}

			}

		}
return $cached_forum_permissions[$gid];
}

		}
return $cached_forum_permissions[$gid];
}

Zeile 1680Zeile 1695
	global $groupscache, $forum_cache, $fpermcache, $mybb, $fpermfields;

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

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

$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;
$only_reply_own_threads = 1;



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


	foreach($groups as $gid)





	if(empty($fpermcache[$fid])) // This forum has no custom or inherited permissions so lets just return the group permissions
{
$current_permissions = $groupperms;
}
else

	{

	{

		if(!empty($groupscache[$gid]))

		foreach($groups as $gid)

		{

		{

			$level_permissions = array();

// If our permissions arn't inherited we need to figure them out
if(empty($fpermcache[$fid][$gid]))
{
$parents = explode(',', $forum_cache[$fid]['parentlist']);
rsort($parents);
if(!empty($parents))
{
foreach($parents as $parent_id)
{
if(!empty($fpermcache[$parent_id][$gid]))
{
$level_permissions = $fpermcache[$parent_id][$gid];
break;
}
}
}
}
else
{

			// If this forum has custom or inherited permissions for the currently looped group.
if(!empty($fpermcache[$fid][$gid]))
{



















				$level_permissions = $fpermcache[$fid][$gid];
}

				$level_permissions = $fpermcache[$fid][$gid];
}


// If we STILL don't have forum permissions we use the usergroup itself
if(empty($level_permissions))

			// Or, use the group permission instead, if available. Some forum permissions not existing here will be added back later.
else if(!empty($groupscache[$gid]))


			{
$level_permissions = $groupscache[$gid];

			{
$level_permissions = $groupscache[$gid];

 
			}
// No permission is available for the currently looped group, probably we have bad data here.
else
{
continue;

			}

foreach($level_permissions as $permission => $access)

			}

foreach($level_permissions as $permission => $access)

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

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

	}








if(count($current_permissions) == 0)
{
$current_permissions = $groupperms;
}
}


	// Figure out if we can view more than our own threads

	// Figure out if we can view more than our own threads

	if($only_view_own_threads == 0)
{

	if($only_view_own_threads == 0 || !isset($current_permissions["canonlyviewownthreads"]))
{

		$current_permissions["canonlyviewownthreads"] = 0;

		$current_permissions["canonlyviewownthreads"] = 0;

	}


	}


	// Figure out if we can reply more than our own threads

	// Figure out if we can reply more than our own threads

	if($only_reply_own_threads == 0)
{

	if($only_reply_own_threads == 0 || !isset($current_permissions["canonlyreplyownthreads"]))
{

		$current_permissions["canonlyreplyownthreads"] = 0;

		$current_permissions["canonlyreplyownthreads"] = 0;

	}

	}





	if(count($current_permissions) == 0)
{
$current_permissions = $groupperms;
}

 
	return $current_permissions;
}


	return $current_permissions;
}


Zeile 1929Zeile 1930
	}

if(isset($modpermscache[$fid][$uid]))

	}

if(isset($modpermscache[$fid][$uid]))

	{
return $modpermscache[$fid][$uid];
}

	{
return $modpermscache[$fid][$uid];
}


if(!$parentslist)
{


if(!$parentslist)
{

Zeile 1981Zeile 1982
				}
// Figure out the user permissions
else if($value == 0)

				}
// Figure out the user permissions
else if($value == 0)

				{

				{

					// The user doesn't have permission to set this action
$perms[$action] = 0;
}

					// The user doesn't have permission to set this action
$perms[$action] = 0;
}

Zeile 1997Zeile 1998
			if(empty($forum['usergroups'][$group]) || !is_array($forum['usergroups'][$group]))
{
// There are no permissions set for this group

			if(empty($forum['usergroups'][$group]) || !is_array($forum['usergroups'][$group]))
{
// There are no permissions set for this group

				continue;

				continue;

			}

$perm = $forum['usergroups'][$group];

			}

$perm = $forum['usergroups'][$group];

Zeile 2045Zeile 2046
	if($uid == 0)
{
return false;

	if($uid == 0)
{
return false;

	}

$user_perms = user_permissions($uid);

	}

$user_perms = user_permissions($uid);


$hook_args = array(
'fid' => $fid,


$hook_args = array(
'fid' => $fid,

Zeile 2063Zeile 2064
	}

if(!empty($user_perms['issupermod']) && $user_perms['issupermod'] == 1)

	}

if(!empty($user_perms['issupermod']) && $user_perms['issupermod'] == 1)

	{

	{

		if($fid)
{
$forumpermissions = forum_permissions($fid);

		if($fid)
{
$forumpermissions = forum_permissions($fid);

Zeile 2328Zeile 2329
	my_setcookie($name, "", $expires);

unset($mybb->cookies[$name]);

	my_setcookie($name, "", $expires);

unset($mybb->cookies[$name]);

}


}


/**
* Get the contents from a serialised cookie array.
*

/**
* Get the contents from a serialised cookie array.
*

Zeile 2340Zeile 2341
function my_get_array_cookie($name, $id)
{
global $mybb;

function my_get_array_cookie($name, $id)
{
global $mybb;





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

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

	{
return false;
}


	{
return false;
}


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

if(is_array($cookie) && isset($cookie[$id]))

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

if(is_array($cookie) && isset($cookie[$id]))

Zeile 2377Zeile 2378
	else
{
$newcookie = array();

	else
{
$newcookie = array();

	}


	}


	$newcookie[$id] = $value;
$newcookie = my_serialize($newcookie);
my_setcookie("mybb[$name]", addslashes($newcookie), $expires);

	$newcookie[$id] = $value;
$newcookie = my_serialize($newcookie);
my_setcookie("mybb[$name]", addslashes($newcookie), $expires);





	if(isset($mybb->cookies['mybb']) && !is_array($mybb->cookies['mybb']))
{
$mybb->cookies['mybb'] = array();

	if(isset($mybb->cookies['mybb']) && !is_array($mybb->cookies['mybb']))
{
$mybb->cookies['mybb'] = array();

Zeile 2394Zeile 2395

/*
* Arbitrary limits for _safe_unserialize()


/*
* Arbitrary limits for _safe_unserialize()

 */

 */

define('MAX_SERIALIZED_INPUT_LENGTH', 10240);
define('MAX_SERIALIZED_ARRAY_LENGTH', 256);
define('MAX_SERIALIZED_ARRAY_DEPTH', 5);

define('MAX_SERIALIZED_INPUT_LENGTH', 10240);
define('MAX_SERIALIZED_ARRAY_LENGTH', 256);
define('MAX_SERIALIZED_ARRAY_DEPTH', 5);

Zeile 2460Zeile 2461
		{
$value = (float)$matches[1];
$str = $matches[3];

		{
$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) == '";')

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

			$value = substr($matches[2], 0, (int)$matches[1]);
$str = substr($matches[2], (int)$matches[1] + 2);
}

Zeile 2476Zeile 2477
			$str = $matches[2];
}
else

			$str = $matches[2];
}
else

		{

		{

			// object or unknown/malformed type
return false;
}

			// object or unknown/malformed type
return false;
}

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

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

						return false;
}


						return false;
}


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

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





				// illegal array index type
return false;


				// illegal array index type
return false;


Zeile 2558Zeile 2559
						// array nesting exceeds MAX_SERIALIZED_ARRAY_DEPTH
return false;
}

						// array nesting exceeds MAX_SERIALIZED_ARRAY_DEPTH
return false;
}





					$data = array();
$list = &$data;
$expected[] = $expectedLength;

					$data = array();
$list = &$data;
$expected[] = $expectedLength;

Zeile 2591Zeile 2592
 *
* @param string $str
* @param bool $unlimited

 *
* @param string $str
* @param bool $unlimited

 * @return mixed
*/

 * @return mixed
*/

function my_unserialize($str, $unlimited = true)
{
// Ensure we use the byte count for strings even when strlen() is overloaded by mb_strlen()

function my_unserialize($str, $unlimited = true)
{
// 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, $unlimited);

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

return $out;




















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

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

return $out;
}

/**
* Unserializes data using PHP's `unserialize()`, and its safety options if possible.
* This function should only be used for values from trusted sources.
*
* @param string $str
* @return mixed
*/
function native_unserialize($str)
{
if(version_compare(PHP_VERSION, '7.0.0', '>='))
{
return unserialize($str, array('allowed_classes' => false));
}
else
{
return unserialize($str);
}

}

/**

}

/**

Zeile 2625Zeile 2645
function _safe_serialize( $value )
{
if(is_null($value))

function _safe_serialize( $value )
{
if(is_null($value))

	{

	{

		return 'N;';

		return 'N;';

	}


	}


	if(is_bool($value))

	if(is_bool($value))

	{

	{

		return 'b:'.(int)$value.';';

		return 'b:'.(int)$value.';';

	}

	}


if(is_int($value))
{


if(is_int($value))
{

Zeile 2642Zeile 2662
	if(is_float($value))
{
return 'd:'.str_replace(',', '.', $value).';';

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

	}

	}


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


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





	if(is_array($value))
{
$out = '';

	if(is_array($value))
{
$out = '';

Zeile 2658Zeile 2678
		}

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

		}

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

	}

	}


// safe_serialize cannot my_serialize resources or objects
return false;


// safe_serialize cannot my_serialize resources or objects
return false;

Zeile 2675Zeile 2695
{
// 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))

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

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

Zeile 2707Zeile 2727
		{
// 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"))

		else if(@file_exists("/proc/loadavg") && $load = @file_get_contents("/proc/loadavg"))

		{

		{

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

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

Zeile 2723Zeile 2743

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

				{
return $lang->unknown;
}

Zeile 2989Zeile 3009
	if(array_key_exists('posts', $update_query))
{
$posts_diff = $update_query['posts'] - $forum['posts'];

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

		if($posts_diff > -1)

		if($posts_diff > -1)

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

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

Zeile 3005Zeile 3025
		if($unapprovedposts_diff > -1)
{
$new_stats['numunapprovedposts'] = "+{$unapprovedposts_diff}";

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

		}

		}

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

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

Zeile 3120Zeile 3140
				if((int)$changes[$counter] != 0)
{
$update_query[$counter] = $thread[$counter] + $changes[$counter];

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

				}
}
else

				}
}
else

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

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

Zeile 3386Zeile 3406
	if($addselect)
{
if($showextras == 0)

	if($addselect)
{
if($showextras == 0)

		{

		{

			$template = "special";
}
else

			$template = "special";
}
else

Zeile 3418Zeile 3438
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 3503Zeile 3523
		$parameters = $plugins->run_hooks('format_name', $parameters);

$format = $parameters['format'];

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

$format = $parameters['format'];





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


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


Zeile 3519Zeile 3539
 * @return array Information for the formatted avatar
*/
function format_avatar($avatar, $dimensions = '', $max_dimensions = '')

 * @return array Information for the formatted avatar
*/
function format_avatar($avatar, $dimensions = '', $max_dimensions = '')

{

{

	global $mybb, $theme;
static $avatars;


	global $mybb, $theme;
static $avatars;


Zeile 3783Zeile 3803
			$basic1 = $basic2 = $align = $font = $size = $color = $removeformat = $email = $link = $list = $code = $sourcemode = "";

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

			$basic1 = $basic2 = $align = $font = $size = $color = $removeformat = $email = $link = $list = $code = $sourcemode = "";

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

			{

			{

				$basic1 = "bold,italic,underline,strike|";
$basic2 = "horizontalrule,";
}

				$basic1 = "bold,italic,underline,strike|";
$basic2 = "horizontalrule,";
}

Zeile 5899Zeile 5919
		$lang->thursday,
$lang->friday,
$lang->saturday

		$lang->thursday,
$lang->friday,
$lang->saturday

	);

	);


$bmonth = array(
$lang->month_1,


$bmonth = array(
$lang->month_1,

Zeile 9030Zeile 9050
		}
}


		}
}


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

	if(empty($pm['subject']) || empty($pm['message']) || empty($pm['touid']) || (empty($pm['receivepms']) && !$admin_override))

	{
return false;
}

	{
return false;
}

Zeile 9054Zeile 9074
	}

$recipients_bcc = array();

	}

$recipients_bcc = array();

 

// Workaround for eliminating PHP warnings in PHP 8. Ref: https://github.com/mybb/mybb/issues/4630#issuecomment-1369144163
if(isset($pm['sender']['uid']) && $pm['sender']['uid'] === -1 && $fromid === -1)
{
$sender = array(
"uid" => 0,
"username" => ''
);
}


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


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

	{

	{

		$fromid = (int)$mybb->user['uid'];
}
elseif((int)$fromid < 0)

		$fromid = (int)$mybb->user['uid'];
}
elseif((int)$fromid < 0)

Zeile 9076Zeile 9105
		"do" => '',
"pmid" => ''
);

		"do" => '',
"pmid" => ''
);

 

// (continued) Workaround for eliminating PHP warnings in PHP 8. Ref: https://github.com/mybb/mybb/issues/4630#issuecomment-1369144163
if(isset($sender))
{
$pm['sender'] = $sender;
}


if(isset($session))
{


if(isset($session))
{