Vergleich inc/functions.php - 1.8.16 - 1.8.20

  Keine Änderungen   Hinzugefügt   Modifiziert   Entfernt
Zeile 18Zeile 18
	global $db, $lang, $theme, $templates, $plugins, $mybb;
global $debug, $templatecache, $templatelist, $maintimer, $globaltime, $parsetime;


	global $db, $lang, $theme, $templates, $plugins, $mybb;
global $debug, $templatecache, $templatelist, $maintimer, $globaltime, $parsetime;


 
	$contents = $plugins->run_hooks("pre_parse_page", $contents);

	$contents = parse_page($contents);
$totaltime = format_time_duration($maintimer->stop());
$contents = $plugins->run_hooks("pre_output_page", $contents);

	$contents = parse_page($contents);
$totaltime = format_time_duration($maintimer->stop());
$contents = $plugins->run_hooks("pre_output_page", $contents);

Zeile 623Zeile 624
	// Guests get a special string
else
{

	// Guests get a special string
else
{

		return md5($session->useragent.$mybb->config['database']['username'].$mybb->settings['internal']['encryption_key']);

		return md5($session->sid.$mybb->config['database']['username'].$mybb->settings['internal']['encryption_key']);

	}
}


	}
}


Zeile 868Zeile 869

foreach($errors as $error)
{


foreach($errors as $error)
{

		$errorlist .= "<li>".$error."</li>\n";

		eval("\$errorlist .= \"".$templates->get("error_inline_item")."\";");

	}

eval("\$errors = \"".$templates->get("error_inline")."\";");

	}

eval("\$errors = \"".$templates->get("error_inline")."\";");

Zeile 1203Zeile 1204
/**
* Fetch the permissions for a specific user
*

/**
* Fetch the permissions for a specific user
*

 * @param int $uid The user ID

 * @param int $uid The user ID, if no user ID is provided then current user's ID will be considered.

 * @return array Array of user permissions for the specified user
*/

 * @return array Array of user permissions for the specified user
*/

function user_permissions($uid=0)

function user_permissions($uid=null)

{
global $mybb, $cache, $groupscache, $user_cache;

// If no user id is specified, assume it is the current user

{
global $mybb, $cache, $groupscache, $user_cache;

// If no user id is specified, assume it is the current user

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

// Its a guest. Return the group permissions directly from cache

	if($uid == 0)
{

	if($uid == 0)
{

		$uid = $mybb->user['uid'];

		return $groupscache[1];

	}

// User id does not match current user, fetch permissions

	}

// User id does not match current user, fetch permissions

Zeile 2035Zeile 2042
		return false;
}


		return false;
}


	$stack = array();
$expected = array();

	$stack = $list = $expected = array();



/*
* states:


/*
* states:

Zeile 3107Zeile 3113

/**
* Formats an avatar to a certain dimension


/**
* Formats an avatar to a certain dimension

 *

 *

 * @param string $avatar The avatar file name
* @param string $dimensions Dimensions of the avatar, width x height (e.g. 44|44)
* @param string $max_dimensions The maximum dimensions of the formatted avatar

 * @param string $avatar The avatar file name
* @param string $dimensions Dimensions of the avatar, width x height (e.g. 44|44)
* @param string $max_dimensions The maximum dimensions of the formatted avatar

Zeile 3167Zeile 3173

if($dimensions)
{


if($dimensions)
{

		$dimensions = explode("|", $dimensions);

		$dimensions = preg_split('/[|x]/', $dimensions);


if($dimensions[0] && $dimensions[1])
{


if($dimensions[0] && $dimensions[1])
{

			list($max_width, $max_height) = explode('x', $max_dimensions);

			list($max_width, $max_height) = preg_split('/[|x]/', $max_dimensions);


if(!empty($max_dimensions) && ($dimensions[0] > $max_width || $dimensions[1] > $max_height))
{


if(!empty($max_dimensions) && ($dimensions[0] > $max_width || $dimensions[1] > $max_height))
{

Zeile 3268Zeile 3274
			"editor_invalidyoutube" => "Invalid YouTube video",
"editor_dailymotion" => "Dailymotion",
"editor_metacafe" => "MetaCafe",

			"editor_invalidyoutube" => "Invalid YouTube video",
"editor_dailymotion" => "Dailymotion",
"editor_metacafe" => "MetaCafe",

			"editor_veoh" => "Veoh",

			"editor_mixer" => "Mixer",

			"editor_vimeo" => "Vimeo",
"editor_youtube" => "Youtube",
"editor_facebook" => "Facebook",

			"editor_vimeo" => "Vimeo",
"editor_youtube" => "Youtube",
"editor_facebook" => "Facebook",

Zeile 3315Zeile 3321
				if(!$smiliecache)
{
if(!isset($smilie_cache) || !is_array($smilie_cache))

				if(!$smiliecache)
{
if(!isset($smilie_cache) || !is_array($smilie_cache))

					{

					{

						$smilie_cache = $cache->read("smilies");
}
foreach($smilie_cache as $smilie)

						$smilie_cache = $cache->read("smilies");
}
foreach($smilie_cache as $smilie)

Zeile 3396Zeile 3402
			if($mybb->settings['allowsizemycode'] == 1)
{
$size = "size,";

			if($mybb->settings['allowsizemycode'] == 1)
{
$size = "size,";

			}


			}


			if($mybb->settings['allowcolormycode'] == 1)
{
$color = "color,";

			if($mybb->settings['allowcolormycode'] == 1)
{
$color = "color,";

			}


			}


			if($mybb->settings['allowfontmycode'] == 1 || $mybb->settings['allowsizemycode'] == 1 || $mybb->settings['allowcolormycode'] == 1)
{
$removeformat = "removeformat|";

			if($mybb->settings['allowfontmycode'] == 1 || $mybb->settings['allowsizemycode'] == 1 || $mybb->settings['allowcolormycode'] == 1)
{
$removeformat = "removeformat|";

			}


			}


			if($mybb->settings['allowemailmycode'] == 1)
{
$email = "email,";

			if($mybb->settings['allowemailmycode'] == 1)
{
$email = "email,";

			}


			}


			if($mybb->settings['allowlinkmycode'] == 1)
{
$link = "link,unlink";

			if($mybb->settings['allowlinkmycode'] == 1)
{
$link = "link,unlink";

			}


			}


			if($mybb->settings['allowlistmycode'] == 1)
{
$list = "bulletlist,orderedlist|";

			if($mybb->settings['allowlistmycode'] == 1)
{
$list = "bulletlist,orderedlist|";

			}


			}


			if($mybb->settings['allowcodemycode'] == 1)
{
$code = "code,php,";

			if($mybb->settings['allowcodemycode'] == 1)
{
$code = "code,php,";

			}


			}


			if($mybb->user['sourceeditor'] == 1)
{
$sourcemode = "MyBBEditor.sourceMode(true);";
}

			if($mybb->user['sourceeditor'] == 1)
{
$sourcemode = "MyBBEditor.sourceMode(true);";
}





			eval("\$codeinsert = \"".$templates->get("codebuttons")."\";");
}
}


			eval("\$codeinsert = \"".$templates->get("codebuttons")."\";");
}
}


	return $codeinsert;
















































	return $codeinsert;
}

/**
* @param int $tid
* @param array $postoptions The options carried with form submit
*
* @return string Predefined / updated subscription method of the thread for the user
*/
function get_subscription_method($tid = 0, $postoptions = array())
{
global $mybb;

$subscription_methods = array('', 'none', 'email', 'pm'); // Define methods
$subscription_method = (int)$mybb->user['subscriptionmethod']; // Set user default

// If no user default method available then reset method
if(!$subscription_method)
{
$subscription_method = 0;
}

// Return user default if no thread id available, in case
if(!(int)$tid || (int)$tid <= 0)
{
return $subscription_methods[$subscription_method];
}

// If method not predefined set using data from database
if(isset($postoptions['subscriptionmethod']))
{
$method = trim($postoptions['subscriptionmethod']);
return (in_array($method, $subscription_methods)) ? $method : $subscription_methods[0];
}
else
{
global $db;

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

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

return $subscription_methods[$subscription_method];

}

/**

}

/**

Zeile 4331Zeile 4384
				eval("\$nav .= \"".$templates->get("nav_bit")."\";");
}
}

				eval("\$nav .= \"".$templates->get("nav_bit")."\";");
}
}

 
		$navsize = count($navbits);
$navbit = $navbits[$navsize-1];

	}

	}


$activesep = '';
$navsize = count($navbits);
$navbit = $navbits[$navsize-1];

 

if($nav)
{


if($nav)
{

Zeile 5960Zeile 6011
		}

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.
*
* @param int $fid The forum id of the forum.

 * Build the forum link.
*
* @param int $fid The forum id of the forum.

Zeile 5971Zeile 6022
 * @return string The url to the forum.
*/
function get_forum_link($fid, $page=0)

 * @return string The url to the forum.
*/
function get_forum_link($fid, $page=0)

{

{

	if($page > 0)
{
$link = str_replace("{fid}", $fid, FORUM_URL_PAGED);

	if($page > 0)
{
$link = str_replace("{fid}", $fid, FORUM_URL_PAGED);

		$link = str_replace("{page}", $page, $link);
return htmlspecialchars_uni($link);
}
else

		$link = str_replace("{page}", $page, $link);
return htmlspecialchars_uni($link);
}
else

	{
$link = str_replace("{fid}", $fid, FORUM_URL);
return htmlspecialchars_uni($link);

	{
$link = str_replace("{fid}", $fid, FORUM_URL);
return htmlspecialchars_uni($link);

Zeile 5996Zeile 6047
function get_thread_link($tid, $page=0, $action='')
{
if($page > 1)

function get_thread_link($tid, $page=0, $action='')
{
if($page > 1)

	{
if($action)
{
$link = THREAD_URL_ACTION;

	{
if($action)
{
$link = THREAD_URL_ACTION;

			$link = str_replace("{action}", $action, $link);
}
else

			$link = str_replace("{action}", $action, $link);
}
else

Zeile 6013Zeile 6064
	else
{
if($action)

	else
{
if($action)

		{

		{

			$link = THREAD_URL_ACTION;
$link = str_replace("{action}", $action, $link);
}
else
{
$link = THREAD_URL;

			$link = THREAD_URL_ACTION;
$link = str_replace("{action}", $action, $link);
}
else
{
$link = THREAD_URL;

		}

		}

		$link = str_replace("{tid}", $tid, $link);

		$link = str_replace("{tid}", $tid, $link);

		return htmlspecialchars_uni($link);
}
}

/**

		return htmlspecialchars_uni($link);
}
}

/**

 * Build the post link.
*
* @param int $pid The post ID of the post

 * Build the post link.
*
* @param int $pid The post ID of the post

Zeile 6039Zeile 6090
	{
$link = str_replace("{tid}", $tid, THREAD_URL_POST);
$link = str_replace("{pid}", $pid, $link);

	{
$link = str_replace("{tid}", $tid, THREAD_URL_POST);
$link = str_replace("{pid}", $pid, $link);

		return htmlspecialchars_uni($link);
}

		return htmlspecialchars_uni($link);
}

	else
{
$link = str_replace("{pid}", $pid, POST_URL);
return htmlspecialchars_uni($link);
}

	else
{
$link = str_replace("{pid}", $pid, POST_URL);
return htmlspecialchars_uni($link);
}

}


}


/**
* Build the event link.
*

/**
* Build the event link.
*

Zeile 6076Zeile 6127
		$link = str_replace("{month}", $month, CALENDAR_URL_DAY);
$link = str_replace("{year}", $year, $link);
$link = str_replace("{day}", $day, $link);

		$link = str_replace("{month}", $month, CALENDAR_URL_DAY);
$link = str_replace("{year}", $year, $link);
$link = str_replace("{day}", $day, $link);

		$link = str_replace("{calendar}", $calendar, $link);
return htmlspecialchars_uni($link);

		$link = str_replace("{calendar}", $calendar, $link);
return htmlspecialchars_uni($link);

	}
else if($month > 0)
{
$link = str_replace("{month}", $month, CALENDAR_URL_MONTH);
$link = str_replace("{year}", $year, $link);
$link = str_replace("{calendar}", $calendar, $link);

	}
else if($month > 0)
{
$link = str_replace("{month}", $month, CALENDAR_URL_MONTH);
$link = str_replace("{year}", $year, $link);
$link = str_replace("{calendar}", $calendar, $link);

		return htmlspecialchars_uni($link);
}

		return htmlspecialchars_uni($link);
}

	/* Not implemented
else if($year > 0)
{

	/* Not implemented
else if($year > 0)
{

Zeile 6099Zeile 6150

/**
* Build the link to a specified week on the calendar


/**
* Build the link to a specified week on the calendar

 *

 *

 * @param int $calendar The ID of the calendar
* @param int $week The week
* @return string The URL of the calendar

 * @param int $calendar The ID of the calendar
* @param int $week The week
* @return string The URL of the calendar

Zeile 6133Zeile 6184
		return $mybb->user;
}
elseif(isset($user_cache[$uid]))

		return $mybb->user;
}
elseif(isset($user_cache[$uid]))

	{
return $user_cache[$uid];

	{
return $user_cache[$uid];

	}
elseif($uid > 0)
{

	}
elseif($uid > 0)
{

Zeile 6248Zeile 6299

/**
* Get the thread of a thread id.


/**
* Get the thread of a thread id.

 *

 *

 * @param int $tid The thread id of the thread.
* @param boolean $recache Whether or not to recache the thread.
* @return array|bool The database row of the thread. False on failure

 * @param int $tid The thread id of the thread.
* @param boolean $recache Whether or not to recache the thread.
* @return array|bool The database row of the thread. False on failure

Zeile 6263Zeile 6314
	if(isset($thread_cache[$tid]) && !$recache)
{
return $thread_cache[$tid];

	if(isset($thread_cache[$tid]) && !$recache)
{
return $thread_cache[$tid];

	}

	}

	else
{
$query = $db->simple_select("threads", "*", "tid = '{$tid}'");
$thread = $db->fetch_array($query);

if($thread)

	else
{
$query = $db->simple_select("threads", "*", "tid = '{$tid}'");
$thread = $db->fetch_array($query);

if($thread)

		{

		{

			$thread_cache[$tid] = $thread;
return $thread;
}

			$thread_cache[$tid] = $thread;
return $thread;
}

Zeile 6305Zeile 6356
		$post = $db->fetch_array($query);

if($post)

		$post = $db->fetch_array($query);

if($post)

		{

		{

			$post_cache[$pid] = $post;
return $post;
}

			$post_cache[$pid] = $post;
return $post;
}

Zeile 6313Zeile 6364
		{
$post_cache[$pid] = false;
return false;

		{
$post_cache[$pid] = false;
return false;

		}

		}

	}
}


	}
}


Zeile 6327Zeile 6378
	global $forum_cache, $cache;

if(!$forum_cache)

	global $forum_cache, $cache;

if(!$forum_cache)

	{

	{

		cache_forums();
}


		cache_forums();
}


Zeile 6362Zeile 6413
function login_attempt_check($uid = 0, $fatal = true)
{
global $mybb, $lang, $db;

function login_attempt_check($uid = 0, $fatal = true)
{
global $mybb, $lang, $db;





	$attempts = array();
$uid = (int)$uid;
$now = TIME_NOW;

	$attempts = array();
$uid = (int)$uid;
$now = TIME_NOW;

Zeile 6376Zeile 6427
		if($attempts['loginattempts'] <= 0)
{
return 0;

		if($attempts['loginattempts'] <= 0)
{
return 0;

		}
}

		}
}

	// This user has a cookie lockout, show waiting time
elseif($mybb->cookies['lockoutexpiry'] && $mybb->cookies['lockoutexpiry'] > $now)

	// This user has a cookie lockout, show waiting time
elseif($mybb->cookies['lockoutexpiry'] && $mybb->cookies['lockoutexpiry'] > $now)

	{	

	{

		if($fatal)
{
$secsleft = (int)($mybb->cookies['lockoutexpiry'] - $now);

		if($fatal)
{
$secsleft = (int)($mybb->cookies['lockoutexpiry'] - $now);

Zeile 6413Zeile 6464
		if(empty($mybb->cookies['lockoutexpiry']))
{
$failedtime = $attempts['loginlockoutexpiry'];

		if(empty($mybb->cookies['lockoutexpiry']))
{
$failedtime = $attempts['loginlockoutexpiry'];

		}

		}

		else

		else

		{

		{

			$failedtime = $mybb->cookies['lockoutexpiry'];
}

// Are we still locked out?
if($attempts['loginlockoutexpiry'] > $now)

			$failedtime = $mybb->cookies['lockoutexpiry'];
}

// Are we still locked out?
if($attempts['loginlockoutexpiry'] > $now)

		{	

		{

			if($fatal)
{
$secsleft = (int)($attempts['loginlockoutexpiry'] - $now);

			if($fatal)
{
$secsleft = (int)($attempts['loginlockoutexpiry'] - $now);

Zeile 7593Zeile 7644
 * @param array $array The array of forums
* @return integer The number of sub forums
*/

 * @param array $array The array of forums
* @return integer The number of sub forums
*/

function subforums_count($array)

function subforums_count($array=array())

{
$count = 0;
foreach($array as $array2)

{
$count = 0;
foreach($array as $array2)

Zeile 7868Zeile 7919
 * Time how long it takes for a particular piece of code to run. Place calls above & below the block of code.
*
* @return float The time taken

 * Time how long it takes for a particular piece of code to run. Place calls above & below the block of code.
*
* @return float The time taken

 */

 */

function get_execution_time()
{
static $time_start;

function get_execution_time()
{
static $time_start;

Zeile 7925Zeile 7976
			while(($file = @readdir($dh)) !== false)
{
if(in_array($file, $ignore) || in_array(get_extension($file), $ignore_ext))

			while(($file = @readdir($dh)) !== false)
{
if(in_array($file, $ignore) || in_array(get_extension($file), $ignore_ext))

				{

				{

					continue;
}


					continue;
}


Zeile 7984Zeile 8035
	if($count == 0)
{
return $bad_verify_files;

	if($count == 0)
{
return $bad_verify_files;

	}
}

/**

	}
}

/**

 * Returns a signed value equal to an integer
*
* @param int $int The integer

 * Returns a signed value equal to an integer
*
* @param int $int The integer

Zeile 8461Zeile 8512
			else
{
$string .= $input[$i];

			else
{
$string .= $input[$i];

			}
}

			}
}

		$input = $string;

		$input = $string;

	}

	}

	if($return)
{
if($allow_mb4)
{
return $input;

	if($return)
{
if($allow_mb4)
{
return $input;

		}

		}

		else
{
return preg_replace("#[^\\x00-\\x7F][\\x80-\\xBF]{3,}#", '?', $input);

		else
{
return preg_replace("#[^\\x00-\\x7F][\\x80-\\xBF]{3,}#", '?', $input);

		}
}
else
{

		}
}
else
{

		if($allow_mb4)
{
return true;

		if($allow_mb4)
{
return true;

Zeile 8507Zeile 8558
	}

if(!is_array($pm))

	}

if(!is_array($pm))

	{

	{

		return false;
}


		return false;
}


Zeile 8567Zeile 8618
	if(is_array($toid))
{
$recipients_to = $toid;

	if(is_array($toid))
{
$recipients_to = $toid;

	}

	}

	else

	else

	{

	{

		$recipients_to = array($toid);

		$recipients_to = array($toid);

	}

	}


$recipients_bcc = array();



$recipients_bcc = array();


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

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

	{

	{

		$fromid = 0;
}


		$fromid = 0;
}


Zeile 8819Zeile 8870
	$string = str_replace('"', '""', $string);

return $string;

	$string = str_replace('"', '""', $string);

return $string;

 
}

// Fallback function for 'array_column', PHP < 5.5.0 compatibility
if(!function_exists('array_column'))
{
function array_column($input, $column_key)
{
$values = array();
if(!is_array($input))
{
$input = array($input);
}
foreach($input as $val)
{
if(is_array($val) && isset($val[$column_key]))
{
$values[] = $val[$column_key];
}
elseif(is_object($val) && isset($val->$column_key))
{
$values[] = $val->$column_key;
}
}
return $values;
}
}

/**
* Performs a timing attack safe string comparison.
*
* @param string $known_string The first string to be compared.
* @param string $user_string The second, user-supplied string to be compared.
* @return bool Result of the comparison.
*/
function my_hash_equals($known_string, $user_string)
{
if(version_compare(PHP_VERSION, '5.6.0', '>='))
{
return hash_equals($known_string, $user_string);
}
else
{
$known_string_length = my_strlen($known_string);
$user_string_length = my_strlen($user_string);

if($user_string_length != $known_string_length)
{
return false;
}

$result = 0;

for($i = 0; $i < $known_string_length; $i++)
{
$result |= ord($known_string[$i]) ^ ord($user_string[$i]);
}

return $result === 0;
}
}

/**
* Retrieves all referrals for a specified user
*
* @param int uid
* @param int start position
* @param int total entries
* @param bool false (default) only return display info, true for all info
* @return array
*/
function get_user_referrals($uid, $start=0, $limit=0, $full=false)
{
global $db;

$referrals = $query_options = array();
$uid = (int) $uid;

if($uid === 0)
{
return $referrals;
}

if($start && $limit)
{
$query_options['limit_start'] = $start;
}

if($limit)
{
$query_options['limit'] = $limit;
}

$fields = 'uid, username, usergroup, displaygroup, regdate';
if($full === true)
{
$fields = '*';
}

$query = $db->simple_select('users', $fields, "referrer='{$uid}'", $query_options);

while($referral = $db->fetch_array($query))
{
$referrals[] = $referral;
}

return $referrals;

}

}