Vergleich inc/functions.php - 1.8.33 - 1.8.38

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

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

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

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

		return $cached_forum_permissions_permissions[$gid][$fid];
}
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 1679Zeile 1694
{
global $groupscache, $forum_cache, $fpermcache, $mybb, $fpermfields;


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



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


$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

	{

	{

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





		$current_permissions = $groupperms;
}
else
{
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)

			{

			{

				if(empty($current_permissions[$permission]) || $access >= $current_permissions[$permission] || ($access == "yes" && $current_permissions[$permission] == "no"))
{
$current_permissions[$permission] = $access;

				if(empty($current_permissions[$permission]) || $access >= $current_permissions[$permission] || ($access == "yes" && $current_permissions[$permission] == "no"))
{
$current_permissions[$permission] = $access;

Zeile 1735Zeile 1742
			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 1937
	}

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

	}

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

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

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

	}

if(!$parentslist)

	}

if(!$parentslist)

Zeile 2193Zeile 2201
	if(isset($mybb->input['icon']))
{
$icon = $mybb->get_input('icon');

	if(isset($mybb->input['icon']))
{
$icon = $mybb->get_input('icon');

	}


	}


	$iconlist = '';
$no_icons_checked = " checked=\"checked\"";
// read post icons from cache, and sort them accordingly

	$iconlist = '';
$no_icons_checked = " checked=\"checked\"";
// read post icons from cache, and sort them accordingly

Zeile 2591Zeile 2599
 *
* @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);
}


	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;

 
}

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

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

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

Zeile 2723Zeile 2756

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

Zeile 2785Zeile 2818
{
global $cache, $db;
static $stats_changes;

{
global $cache, $db;
static $stats_changes;





	if(empty($stats_changes))
{
// Update stats after all changes are done

	if(empty($stats_changes))
{
// Update stats after all changes are done

Zeile 2816Zeile 2849
		}
$stats = $cache->read("stats");
$changes = $stats_changes;

		}
$stats = $cache->read("stats");
$changes = $stats_changes;

	}

	}

	else

	else

	{

	{

		$stats = $stats_changes;
}


		$stats = $stats_changes;
}


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

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

			// Adding or subtracting from previous value?
if(substr($changes[$counter], 0, 1) == "+" || substr($changes[$counter], 0, 1) == "-")
{

Zeile 2839Zeile 2872
				{
$new_stats[$counter] = $stats[$counter] + $changes[$counter];
if(!$force && (substr($stats[$counter], 0, 1) == "+" || substr($stats[$counter], 0, 1) == "-"))

				{
$new_stats[$counter] = $stats[$counter] + $changes[$counter];
if(!$force && (substr($stats[$counter], 0, 1) == "+" || substr($stats[$counter], 0, 1) == "-"))

					{

					{

						// We had relative values? Then it is still relative
if($new_stats[$counter] >= 0)
{
$new_stats[$counter] = "+{$new_stats[$counter]}";
}

						// We had relative values? Then it is still relative
if($new_stats[$counter] >= 0)
{
$new_stats[$counter] = "+{$new_stats[$counter]}";
}

					}

					}

					// Less than 0? That's bad

					// Less than 0? That's bad

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

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

			{
$new_stats[$counter] = $changes[$counter];
// Less than 0? That's bad

			{
$new_stats[$counter] = $changes[$counter];
// Less than 0? That's bad

Zeile 2868Zeile 2901
	if(!$force)
{
$stats_changes = array_merge($stats, $new_stats); // Overwrite changed values

	if(!$force)
{
$stats_changes = array_merge($stats, $new_stats); // Overwrite changed values

		return;
}


		return;
}


	// Fetch latest user if the user count is changing
if(array_key_exists('numusers', $changes))
{

	// Fetch latest user if the user count is changing
if(array_key_exists('numusers', $changes))
{

Zeile 2885Zeile 2918
		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

		}
else

		}
else

		{
$stats = $new_stats;
}

		{
$stats = $new_stats;
}

Zeile 2918Zeile 2951
	$update_query = array();

$counters = array('threads', 'unapprovedthreads', 'posts', 'unapprovedposts', 'deletedposts', 'deletedthreads');

	$update_query = array();

$counters = array('threads', 'unapprovedthreads', 'posts', 'unapprovedposts', 'deletedposts', 'deletedthreads');





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

Zeile 2949Zeile 2982
			{
$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 2979Zeile 3012
		if($unapprovedthreads_diff > -1)
{
$new_stats['numunapprovedthreads'] = "+{$unapprovedthreads_diff}";

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

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

		}
else
{
$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 3009Zeile 3042
		else
{
$new_stats['numunapprovedposts'] = "{$unapprovedposts_diff}";

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

		}
}

		}
}


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


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

		{

		{

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

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

		}

		}

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

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

Zeile 3026Zeile 3059
	}

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

	}

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

	{

	{

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

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

Zeile 3041Zeile 3074
	if(!empty($new_stats))
{
update_stats($new_stats);

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

	}

	}

}

/**

}

/**

Zeile 3072Zeile 3105
			"lastposteruid" => (int)$lastpost['lastposteruid'],
"lastposttid" => (int)$lastpost['tid'],
"lastpostsubject" => $db->escape_string($lastpost['subject']),

			"lastposteruid" => (int)$lastpost['lastposteruid'],
"lastposttid" => (int)$lastpost['tid'],
"lastpostsubject" => $db->escape_string($lastpost['subject']),

		);
}

		);
}

	else {
$updated_forum = array(
"lastpost" => 0,

	else {
$updated_forum = array(
"lastpost" => 0,

Zeile 3105Zeile 3138
	// Fetch above counters for this thread
$query = $db->simple_select("threads", implode(",", $counters), "tid='{$tid}'");
$thread = $db->fetch_array($query);

	// Fetch above counters for this thread
$query = $db->simple_select("threads", implode(",", $counters), "tid='{$tid}'");
$thread = $db->fetch_array($query);


foreach($counters as $counter)
{
if(array_key_exists($counter, $changes))
{
if(substr($changes[$counter], 0, 2) == "+-")
{
$changes[$counter] = substr($changes[$counter], 1);
}
// Adding or subtracting from previous value?


foreach($counters as $counter)
{
if(array_key_exists($counter, $changes))
{
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((int)$changes[$counter] != 0)
{
$update_query[$counter] = $thread[$counter] + $changes[$counter];

			if(substr($changes[$counter], 0, 1) == "+" || substr($changes[$counter], 0, 1) == "-")
{
if((int)$changes[$counter] != 0)
{
$update_query[$counter] = $thread[$counter] + $changes[$counter];

				}
}

				}
}

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

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

Zeile 3150Zeile 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;

$thread = get_thread($tid);

{
global $db;

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


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

Zeile 3186Zeile 3219
	$db->free_result($query);

if(empty($firstpost['username']))

	$db->free_result($query);

if(empty($firstpost['username']))

	{

	{

		$firstpost['username'] = $firstpost['postusername'];
}


		$firstpost['username'] = $firstpost['postusername'];
}


Zeile 3235Zeile 3268
	// 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(array_key_exists($counter, $changes))
{
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((int)$changes[$counter] != 0)








	
if($user)
{
foreach($counters as $counter)
{
if(array_key_exists($counter, $changes))
{
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((int)$changes[$counter] != 0)
{
$update_query[$counter] = $user[$counter] + $changes[$counter];
}
}
else

				{

				{

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

					$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 3775Zeile 3811
						{
$find = str_replace(array('\\', '"'), array('\\\\', '\"'), htmlspecialchars_uni($finds[$j]));
$hiddensmilies .= '"'.$find.'": "'.$image.'",';

						{
$find = str_replace(array('\\', '"'), array('\\\\', '\"'), htmlspecialchars_uni($finds[$j]));
$hiddensmilies .= '"'.$find.'": "'.$image.'",';

						}
}
}
}

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


						}
}
}
}

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


			if($mybb->settings['allowbasicmycode'] == 1)
{
$basic1 = "bold,italic,underline,strike|";

			if($mybb->settings['allowbasicmycode'] == 1)
{
$basic1 = "bold,italic,underline,strike|";

Zeile 3883Zeile 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 4045Zeile 4081
	}

return false;

	}

return false;

}

/**

}

/**

 * Build the thread prefix selection menu for the current user
*
* @param int|string $fid The forum ID (integer ID or string all)

 * Build the thread prefix selection menu for the current user
*
* @param int|string $fid The forum ID (integer ID or string all)

Zeile 4444Zeile 4480
		if(is_array($addresses))
{
foreach($addresses as $val)

		if(is_array($addresses))
{
foreach($addresses as $val)

			{

			{

				$val = trim($val);
// Validate IP address and exclude private addresses
if(my_inet_ntop(my_inet_pton($val)) == $val && !preg_match("#^(10\.|172\.(1[6-9]|2[0-9]|3[0-1])\.|192\.168\.|fe80:|fe[c-f][0-f]:|f[c-d][0-f]{2}:)#", $val))

				$val = trim($val);
// Validate IP address and exclude private addresses
if(my_inet_ntop(my_inet_pton($val)) == $val && !preg_match("#^(10\.|172\.(1[6-9]|2[0-9]|3[0-1])\.|192\.168\.|fe80:|fe[c-f][0-f]:|f[c-d][0-f]{2}:)#", $val))

Zeile 4510Zeile 4546
	}
// Terabyte (1024 Gigabytes)
elseif($size >= 1099511627776)

	}
// Terabyte (1024 Gigabytes)
elseif($size >= 1099511627776)

	{

	{

		$size = my_number_format(round(($size / 1099511627776), 2))." ".$lang->size_tb;
}
// Gigabyte (1024 Megabytes)
elseif($size >= 1073741824)

		$size = my_number_format(round(($size / 1099511627776), 2))." ".$lang->size_tb;
}
// Gigabyte (1024 Megabytes)
elseif($size >= 1073741824)

	{

	{

		$size = my_number_format(round(($size / 1073741824), 2))." ".$lang->size_gb;

		$size = my_number_format(round(($size / 1073741824), 2))." ".$lang->size_gb;

	}

	}

	// Megabyte (1024 Kilobytes)
elseif($size >= 1048576)
{

	// Megabyte (1024 Kilobytes)
elseif($size >= 1048576)
{

Zeile 4527Zeile 4563
	elseif($size >= 1024)
{
$size = my_number_format(round(($size / 1024), 2))." ".$lang->size_kb;

	elseif($size >= 1024)
{
$size = my_number_format(round(($size / 1024), 2))." ".$lang->size_kb;

	}

	}

	elseif($size == 0)
{
$size = "0 ".$lang->size_bytes;

	elseif($size == 0)
{
$size = "0 ".$lang->size_bytes;

Zeile 4560Zeile 4596
		$time = number_format(round(1000000 * $time, 2))." μs";
}
elseif(round(1000000 * $time, 2) >= 1000 && round(1000000 * $time, 2) < 1000000)

		$time = number_format(round(1000000 * $time, 2))." μs";
}
elseif(round(1000000 * $time, 2) >= 1000 && round(1000000 * $time, 2) < 1000000)

	{

	{

		$time = number_format(round((1000 * $time), 2))." ms";

		$time = number_format(round((1000 * $time), 2))." ms";

	}

	}

	else
{
$time = round($time, 3)." seconds";

	else
{
$time = round($time, 3)." seconds";

Zeile 4576Zeile 4612
 *
* @param string $ext The file extension
* @return string The attachment icon

 *
* @param string $ext The file extension
* @return string The attachment icon

 */

 */

function get_attachment_icon($ext)
{
global $cache, $attachtypes, $theme, $templates, $lang, $mybb;

function get_attachment_icon($ext)
{
global $cache, $attachtypes, $theme, $templates, $lang, $mybb;





	if(!$attachtypes)

	if(!$attachtypes)

	{

	{

		$attachtypes = $cache->read("attachtypes");
}


		$attachtypes = $cache->read("attachtypes");
}


Zeile 4592Zeile 4628
	{
static $attach_icons_schemes = array();
if(!isset($attach_icons_schemes[$ext]))

	{
static $attach_icons_schemes = array();
if(!isset($attach_icons_schemes[$ext]))

		{

		{

			$attach_icons_schemes[$ext] = parse_url($attachtypes[$ext]['icon']);
if(!empty($attach_icons_schemes[$ext]['scheme']))
{

			$attach_icons_schemes[$ext] = parse_url($attachtypes[$ext]['icon']);
if(!empty($attach_icons_schemes[$ext]['scheme']))
{

Zeile 4707Zeile 4743
	$unviewableforums = implode(',', $unviewable);

return $unviewableforums;

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

return $unviewableforums;

}


}


/**
* Fixes mktime for dates earlier than 1970
*

/**
* Fixes mktime for dates earlier than 1970
*

Zeile 4724Zeile 4760
	$format = str_replace("y", my_substr($year, -2), $format);

return $format;

	$format = str_replace("y", my_substr($year, -2), $format);

return $format;

}


}


/**
* Build the breadcrumb navigation trail from the specified items
*

/**
* Build the breadcrumb navigation trail from the specified items
*

Zeile 4741Zeile 4777
	$activesep = '';

if(is_array($navbits))

	$activesep = '';

if(is_array($navbits))

	{

	{

		reset($navbits);
foreach($navbits as $key => $navbit)
{

		reset($navbits);
foreach($navbits as $key => $navbit)
{

Zeile 4840Zeile 4876
		foreach($pforumcache[$fid] as $key => $forumnav)
{
if($fid == $forumnav['fid'])

		foreach($pforumcache[$fid] as $key => $forumnav)
{
if($fid == $forumnav['fid'])

			{

			{

				if(!empty($pforumcache[$forumnav['pid']]))
{
build_forum_breadcrumb($forumnav['pid']);

				if(!empty($pforumcache[$forumnav['pid']]))
{
build_forum_breadcrumb($forumnav['pid']);

Zeile 5237Zeile 5273
		), $options);
}
elseif($days > 0)

		), $options);
}
elseif($days > 0)

	{

	{

		$options = array_merge(array(
'seconds' => false
), $options);
}

		$options = array_merge(array(
'seconds' => false
), $options);
}





	$nicetime = array();

if(!isset($options['years']) || $options['years'] !== false)
{
if($years == 1)

	$nicetime = array();

if(!isset($options['years']) || $options['years'] !== false)
{
if($years == 1)

		{

		{

			$nicetime['years'] = "1".$lang_year;
}
else if($years > 1)
{
$nicetime['years'] = $years.$lang_years;

			$nicetime['years'] = "1".$lang_year;
}
else if($years > 1)
{
$nicetime['years'] = $years.$lang_years;

		}
}


		}
}


	if(!isset($options['months']) || $options['months'] !== false)
{
if($months == 1)

	if(!isset($options['months']) || $options['months'] !== false)
{
if($months == 1)

		{

		{

			$nicetime['months'] = "1".$lang_month;

			$nicetime['months'] = "1".$lang_month;

		}

		}

		else if($months > 1)
{
$nicetime['months'] = $months.$lang_months;

		else if($months > 1)
{
$nicetime['months'] = $months.$lang_months;

Zeile 5270Zeile 5306
	}

if(!isset($options['weeks']) || $options['weeks'] !== false)

	}

if(!isset($options['weeks']) || $options['weeks'] !== false)

	{

	{

		if($weeks == 1)
{
$nicetime['weeks'] = "1".$lang_week;

		if($weeks == 1)
{
$nicetime['weeks'] = "1".$lang_week;

Zeile 5302Zeile 5338
		else if($hours > 1)
{
$nicetime['hours'] = $hours.$lang_hours;

		else if($hours > 1)
{
$nicetime['hours'] = $hours.$lang_hours;

		}
}

		}
}


if(!isset($options['minutes']) || $options['minutes'] !== false)


if(!isset($options['minutes']) || $options['minutes'] !== false)

	{

	{

		if($minutes == 1)

		if($minutes == 1)

		{

		{

			$nicetime['minutes'] = "1".$lang_minute;

			$nicetime['minutes'] = "1".$lang_minute;

		}

		}

		else if($minutes > 1)
{
$nicetime['minutes'] = $minutes.$lang_minutes;

		else if($minutes > 1)
{
$nicetime['minutes'] = $minutes.$lang_minutes;

Zeile 5320Zeile 5356
	if(!isset($options['seconds']) || $options['seconds'] !== false)
{
if($seconds == 1)

	if(!isset($options['seconds']) || $options['seconds'] !== false)
{
if($seconds == 1)

		{

		{

			$nicetime['seconds'] = "1".$lang_second;
}
else if($seconds > 1)

			$nicetime['seconds'] = "1".$lang_second;
}
else if($seconds > 1)

Zeile 5354Zeile 5390
		$trow = "trow1";
}


		$trow = "trow1";
}


	$alttrow = $trow;


	$alttrow = $trow;


	return $trow;
}


	return $trow;
}


Zeile 5369Zeile 5405
function join_usergroup($uid, $joingroup)
{
global $db, $mybb;

function join_usergroup($uid, $joingroup)
{
global $db, $mybb;





	if($uid == $mybb->user['uid'])
{
$user = $mybb->user;

	if($uid == $mybb->user['uid'])
{
$user = $mybb->user;

Zeile 5633Zeile 5669
		}

return $themeselect;

		}

return $themeselect;

	}
else

	}
else

	{
return false;
}

	{
return false;
}

Zeile 5713Zeile 5749
	}
else
{

	}
else
{

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








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


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


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

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

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

	);

	);


$bmonth = array(
$lang->month_1,


$bmonth = array(
$lang->month_1,

Zeile 5914Zeile 5957
		$lang->month_10,
$lang->month_11,
$lang->month_12

		$lang->month_10,
$lang->month_11,
$lang->month_12

	);


	);


	// This needs to be in this specific order
$find = array(
'm',

	// This needs to be in this specific order
$find = array(
'm',

Zeile 5947Zeile 5990

$bdays = str_replace($find, $html, $bdays);
$bmonth = str_replace($find, $html, $bmonth);


$bdays = str_replace($find, $html, $bdays);
$bmonth = str_replace($find, $html, $bmonth);





	$replace = array(
sprintf('%02s', $bm),
$bm,

	$replace = array(
sprintf('%02s', $bm),
$bm,

Zeile 6028Zeile 6071
		'username' => $firstpost['username'],
'uid' => (int)$firstpost['uid'],
'dateline' => (int)$firstpost['dateline']

		'username' => $firstpost['username'],
'uid' => (int)$firstpost['uid'],
'dateline' => (int)$firstpost['dateline']

	);
$db->update_query("threads", $update_array, "tid='{$tid}'");
}

/**

	);
$db->update_query("threads", $update_array, "tid='{$tid}'");
}

/**

 * Updates the last posts in a thread.
*
* @param int $tid The thread id for which to update the last post id.

 * Updates the last posts in a thread.
*
* @param int $tid The thread id for which to update the last post id.

Zeile 6100Zeile 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 6428Zeile 6471
		}

return "<a href=\"{$mybb->settings['bburl']}/".get_profile_link($uid)."\"{$target}{$onclick}>{$username}</a>";

		}

return "<a href=\"{$mybb->settings['bburl']}/".get_profile_link($uid)."\"{$target}{$onclick}>{$username}</a>";

	}
}

	}
}


/**
* Build the forum link.


/**
* Build the forum link.

Zeile 6692Zeile 6735
	}

if(empty($forum_cache[$fid]))

	}

if(empty($forum_cache[$fid]))

	{
return false;

	{
return false;

	}

if($active_override != 1)

	}

if($active_override != 1)

Zeile 6957Zeile 7000
		$uid_string = " AND uid != '".(int)$uid."'";
}
$query = $db->simple_select("users", "COUNT(email) as emails", "email = '".$db->escape_string($email)."'{$uid_string}");

		$uid_string = " AND uid != '".(int)$uid."'";
}
$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;

	if($db->fetch_field($query, "emails") > 0)
{
return true;

Zeile 7025Zeile 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 7077Zeile 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 7097Zeile 7137

// Special boolean operators should be stripped
if($word == "" || $word == "or" || $word == "not" || $word == "and")


// Special boolean operators should be stripped
if($word == "" || $word == "or" || $word == "not" || $word == "and")

		{
continue;
}

		{
continue;
}


// Now make PREG compatible
$find = "/(?<!&|&#)\b([[:alnum:]]*)(".preg_quote($word, "/").")(?![^<>]*?>)/ui";


// Now make PREG compatible
$find = "/(?<!&|&#)\b([[:alnum:]]*)(".preg_quote($word, "/").")(?![^<>]*?>)/ui";

Zeile 7108Zeile 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 7134Zeile 7174
	$dest = '';

if($src < 0)

	$dest = '';

if($src < 0)

	{

	{

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

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

Zeile 7151Zeile 7191
		$dest .= chr(0xe0 | ($src >> 12));
$dest .= chr(0x80 | (($src >> 6) & 0x003f));
$dest .= chr(0x80 | ($src & 0x003f));

		$dest .= chr(0xe0 | ($src >> 12));
$dest .= chr(0x80 | (($src >> 6) & 0x003f));
$dest .= chr(0x80 | ($src & 0x003f));

	}

	}

	elseif($src <= 0x10ffff)
{
$dest .= chr(0xf0 | ($src >> 18));

	elseif($src <= 0x10ffff)
{
$dest .= chr(0xf0 | ($src >> 18));

Zeile 7166Zeile 7206
	}

return $dest;

	}

return $dest;

}

/**

}

/**

 * Checks if a username has been disallowed for registration/use.
*
* @param string $username The username

 * Checks if a username has been disallowed for registration/use.
*
* @param string $username The username

Zeile 7237Zeile 7277
	}

// Still here - good email

	}

// Still here - good email

	return false;
}

	return false;
}


/**
* Checks if a specific IP address has been banned.


/**
* Checks if a specific IP address has been banned.

Zeile 7517Zeile 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))

Zeile 9030Zeile 9075
		}
}


		}
}


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

$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 9130
		"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))
{