Vergleich inc/functions.php - 1.8.32 - 1.8.34

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





	// If our mail handler doesn't exist, create it.
if(!is_object($my_mailhandler))
{
require_once MYBB_ROOT . "inc/class_mailhandler.php";


	// If our mail handler doesn't exist, create it.
if(!is_object($my_mailhandler))
{
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))


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

Zeile 663Zeile 669
		'is_mail_sent' => &$is_mail_sent,
'continue_process' => &$continue_process,
);

		'is_mail_sent' => &$is_mail_sent,
'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)

	// Check if the hooked plugins still suggest to send the mail.
if($continue_process)

	{

	{

		$is_mail_sent = $mail->send();

		$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 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 2085Zeile 2086
				foreach($modcache as $modusers)
{
if(isset($modusers['users'][$uid]) && $modusers['users'][$uid]['mid'] && (!$action || !empty($modusers['users'][$uid][$action])))

				foreach($modcache as $modusers)
{
if(isset($modusers['users'][$uid]) && $modusers['users'][$uid]['mid'] && (!$action || !empty($modusers['users'][$uid][$action])))

					{

					{

						return true;
}


						return true;
}


Zeile 2338Zeile 2339
 * @return array|boolean The cookie id's content array or false when non-existent.
*/
function my_get_array_cookie($name, $id)

 * @return array|boolean The cookie id's content array or false when non-existent.
*/
function my_get_array_cookie($name, $id)

{
global $mybb;

{
global $mybb;


if(!isset($mybb->cookies['mybb'][$name]))
{
return false;


if(!isset($mybb->cookies['mybb'][$name]))
{
return false;

	}

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

	}

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


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


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

Zeile 2355Zeile 2356
	else
{
return 0;

	else
{
return 0;

	}
}

	}
}


/**
* Set a serialised cookie array.


/**
* Set a serialised cookie array.

Zeile 2371Zeile 2372
	global $mybb;

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

	global $mybb;

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

	{
$newcookie = my_unserialize($mybb->cookies['mybb'][$name]);
}

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

	else

	else

	{

	{

		$newcookie = array();

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

	}


	}


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

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

Zeile 2406Zeile 2407
 * - does not unserialize objects
*
* @param string $str

 * - does not unserialize objects
*
* @param string $str

 
 * @param bool $unlimited Whether to apply limits defined in MAX_SERIALIZED_* constants

 * @return mixed
* @throw Exception if $str is malformed or contains unsupported types (e.g., resources, objects)
*/

 * @return mixed
* @throw Exception if $str is malformed or contains unsupported types (e.g., resources, objects)
*/

function _safe_unserialize($str)

function _safe_unserialize($str, $unlimited = true)

{

{

	if(strlen($str) > MAX_SERIALIZED_INPUT_LENGTH)

	if(!$unlimited && strlen($str) > MAX_SERIALIZED_INPUT_LENGTH)

	{
// input exceeds MAX_SERIALIZED_INPUT_LENGTH
return false;

	{
// input exceeds MAX_SERIALIZED_INPUT_LENGTH
return false;

Zeile 2465Zeile 2467
			$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);
}

		else if($type == 'a' && preg_match('/^a:([0-9]+):{(.*)/s', $str, $matches) && $matches[1] < MAX_SERIALIZED_ARRAY_LENGTH)





		else if(
$type == 'a' &&
preg_match('/^a:([0-9]+):{(.*)/s', $str, $matches) &&
($unlimited || $matches[1] < MAX_SERIALIZED_ARRAY_LENGTH)
)

		{
$expectedLength = (int)$matches[1];
$str = $matches[2];

		{
$expectedLength = (int)$matches[1];
$str = $matches[2];

Zeile 2481Zeile 2487
			case 3: // in array, expecting value or another array
if($type == 'a')
{

			case 3: // in array, expecting value or another array
if($type == 'a')
{

					if(count($stack) >= MAX_SERIALIZED_ARRAY_DEPTH)

					if(!$unlimited && count($stack) >= MAX_SERIALIZED_ARRAY_DEPTH)

					{
// array nesting exceeds MAX_SERIALIZED_ARRAY_DEPTH
return false;

					{
// array nesting exceeds MAX_SERIALIZED_ARRAY_DEPTH
return false;

Zeile 2526Zeile 2532
				}
if($type == 'i' || $type == 's')
{

				}
if($type == 'i' || $type == 's')
{

					if(count($list) >= MAX_SERIALIZED_ARRAY_LENGTH)

					if(!$unlimited && count($list) >= MAX_SERIALIZED_ARRAY_LENGTH)

					{
// array size exceeds MAX_SERIALIZED_ARRAY_LENGTH
return false;

					{
// array size exceeds MAX_SERIALIZED_ARRAY_LENGTH
return false;

Zeile 2548Zeile 2554
			case 0: // expecting array or value
if($type == 'a')
{

			case 0: // expecting array or value
if($type == 'a')
{

					if(count($stack) >= MAX_SERIALIZED_ARRAY_DEPTH)

					if(!$unlimited && count($stack) >= MAX_SERIALIZED_ARRAY_DEPTH)

					{
// array nesting exceeds MAX_SERIALIZED_ARRAY_DEPTH
return false;

					{
// array nesting exceeds MAX_SERIALIZED_ARRAY_DEPTH
return false;

Zeile 2585Zeile 2591
 * Wrapper for _safe_unserialize() that handles exceptions and multibyte encoding issue
*
* @param string $str

 * Wrapper for _safe_unserialize() that handles exceptions and multibyte encoding issue
*
* @param string $str

 
 * @param bool $unlimited

 * @return mixed
*/

 * @return mixed
*/

function my_unserialize($str)

function my_unserialize($str, $unlimited = true)

{
// Ensure we use the byte count for strings even when strlen() is overloaded by mb_strlen()

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


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


	return $out;
}


Zeile 2634Zeile 2641
	}

if(is_float($value))

	}

if(is_float($value))

	{

	{

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

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

	}


	}


	if(is_string($value))

	if(is_string($value))

	{

	{

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


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


Zeile 2649Zeile 2656
		foreach($value as $k => $v)
{
$out .= _safe_serialize($k) . _safe_serialize($v);

		foreach($value as $k => $v)
{
$out .= _safe_serialize($k) . _safe_serialize($v);

		}


		}


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


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


Zeile 2713Zeile 2720
			if($mybb->safemode)
{
return $lang->unknown;

			if($mybb->safemode)
{
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)
{
return $lang->unknown;
}

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

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

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

Zeile 2729Zeile 2736
				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);


$load = @exec("uptime");
$load = explode("load average: ", $load);

Zeile 4843Zeile 4850
				$navsize = count($navbits);
// Convert & to &amp;
$navbits[$navsize]['name'] = preg_replace("#&(?!\#[0-9]+;)#si", "&amp;", $forumnav['name']);

				$navsize = count($navbits);
// Convert & to &amp;
$navbits[$navsize]['name'] = preg_replace("#&(?!\#[0-9]+;)#si", "&amp;", $forumnav['name']);





				if(defined("IN_ARCHIVE"))
{
// Set up link to forum in breadcrumb.

				if(defined("IN_ARCHIVE"))
{
// Set up link to forum in breadcrumb.

Zeile 6953Zeile 6960
	$query = $db->simple_select("users", "COUNT(email) as emails", "email = '".$db->escape_string($email)."'{$uid_string}");

if($db->fetch_field($query, "emails") > 0)

	$query = $db->simple_select("users", "COUNT(email) as emails", "email = '".$db->escape_string($email)."'{$uid_string}");

if($db->fetch_field($query, "emails") > 0)

	{
return true;
}


	{
return true;
}


	return false;
}


	return false;
}


Zeile 9024Zeile 9031
		}
}


		}
}


	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 9048Zeile 9055
	}

$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 9070Zeile 9086
		"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))
{