Vergleich inc/functions.php - 1.8.15 - 1.8.17

  Keine Änderungen   Hinzugefügt   Modifiziert   Entfernt
Zeile 1036Zeile 1036
	{
return '';
}

	{
return '';
}

 

$page = (int)$page;


$url = str_replace("&", "&", $url);
$url = htmlspecialchars_uni($url);


$url = str_replace("&", "&", $url);
$url = htmlspecialchars_uni($url);

Zeile 1066Zeile 1068
	}

if($to > $pages)

	}

if($to > $pages)

	{

	{

		$to = $pages;
$from = $pages-$mybb->settings['maxmultipagelinks']+1;
if($from <= 0)

		$to = $pages;
$from = $pages-$mybb->settings['maxmultipagelinks']+1;
if($from <= 0)

Zeile 1110Zeile 1112
		else
{
eval("\$mppage .= \"".$templates->get("multipage_page")."\";");

		else
{
eval("\$mppage .= \"".$templates->get("multipage_page")."\";");

		}
}

		}
}


$end = '';
if($to < $pages)


$end = '';
if($to < $pages)

Zeile 1139Zeile 1141
		// When the second parameter is set to 1, fetch_page_url thinks it's the first page and removes it from the URL as it's unnecessary
$jump_url = fetch_page_url($url, 1);
eval("\$jumptopage = \"".$templates->get("multipage_jump_page")."\";");

		// When the second parameter is set to 1, fetch_page_url thinks it's the first page and removes it from the URL as it's unnecessary
$jump_url = fetch_page_url($url, 1);
eval("\$jumptopage = \"".$templates->get("multipage_jump_page")."\";");

	}

$lang->multipage_pages = $lang->sprintf($lang->multipage_pages, $pages);


	}

$multipage_pages = $lang->sprintf($lang->multipage_pages, $pages);


	if($breadcrumb == true)

	if($breadcrumb == true)

	{

	{

		eval("\$multipage = \"".$templates->get("multipage_breadcrumb")."\";");

		eval("\$multipage = \"".$templates->get("multipage_breadcrumb")."\";");

	}

	}

	else
{
eval("\$multipage = \"".$templates->get("multipage")."\";");

	else
{
eval("\$multipage = \"".$templates->get("multipage")."\";");

Zeile 1157Zeile 1159

/**
* Generate a page URL for use by the multipage function


/**
* Generate a page URL for use by the multipage function

 *

 *

 * @param string $url The URL being passed
* @param int $page The page number
* @return string

 * @param string $url The URL being passed
* @param int $page The page number
* @return string

Zeile 1186Zeile 1188
		else
{
$url .= "&amp;";

		else
{
$url .= "&amp;";

		}


		}


		$url .= "page=$page";

		$url .= "page=$page";

	}

	}

	else
{
$url = str_replace("{page}", $page, $url);
}

	else
{
$url = str_replace("{page}", $page, $url);
}





	return $url;
}

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

	return $url;
}

/**
* 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 1278Zeile 1286
		}

foreach($groupscache[$gid] as $perm => $access)

		}

foreach($groupscache[$gid] as $perm => $access)

		{

		{

			if(!in_array($perm, $grouppermignore))
{
if(isset($usergroup[$perm]))

			if(!in_array($perm, $grouppermignore))
{
if(isset($usergroup[$perm]))

Zeile 1517Zeile 1525
	$showform = true;

if(!is_array($forum_cache))

	$showform = true;

if(!is_array($forum_cache))

	{

	{

		$forum_cache = cache_forums();
if(!$forum_cache)
{
return false;
}

		$forum_cache = cache_forums();
if(!$forum_cache)
{
return false;
}

	}

	}


// Loop through each of parent forums to ensure we have a password for them too
if(isset($forum_cache[$fid]['parentlist']))


// Loop through each of parent forums to ensure we have a password for them too
if(isset($forum_cache[$fid]['parentlist']))

Zeile 1532Zeile 1540
		rsort($parents);
}
if(!empty($parents))

		rsort($parents);
}
if(!empty($parents))

	{

	{

		foreach($parents as $parent_id)
{
if($parent_id == $fid || $parent_id == $pid)

		foreach($parents as $parent_id)
{
if($parent_id == $fid || $parent_id == $pid)

Zeile 1560Zeile 1568
			else
{
eval("\$pwnote = \"".$templates->get("forumdisplay_password_wrongpass")."\";");

			else
{
eval("\$pwnote = \"".$templates->get("forumdisplay_password_wrongpass")."\";");

				$showform = true;
}
}

				$showform = true;
}
}

		else
{
if(!$mybb->cookies['forumpass'][$fid] || ($mybb->cookies['forumpass'][$fid] && md5($mybb->user['uid'].$password) !== $mybb->cookies['forumpass'][$fid]))

		else
{
if(!$mybb->cookies['forumpass'][$fid] || ($mybb->cookies['forumpass'][$fid] && md5($mybb->user['uid'].$password) !== $mybb->cookies['forumpass'][$fid]))

Zeile 1622Zeile 1630
	if($uid == 0)
{
return false;

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

	}

	}


if(isset($modpermscache[$fid][$uid]))
{
return $modpermscache[$fid][$uid];


if(isset($modpermscache[$fid][$uid]))
{
return $modpermscache[$fid][$uid];

	}


	}


	if(!$parentslist)
{
$parentslist = explode(',', get_parent_list($fid));

	if(!$parentslist)
{
$parentslist = explode(',', get_parent_list($fid));

Zeile 1637Zeile 1645
	// Get user groups
$perms = array();
$user = get_user($uid);

	// Get user groups
$perms = array();
$user = get_user($uid);





	$groups = array($user['usergroup']);

if(!empty($user['additionalgroups']))

	$groups = array($user['usergroup']);

if(!empty($user['additionalgroups']))

Zeile 1813Zeile 1821
	$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

	$posticons_cache = $cache->read("posticons");

	$posticons_cache = (array)$cache->read("posticons");

	$posticons = array();
foreach($posticons_cache as $posticon)
{

	$posticons = array();
foreach($posticons_cache as $posticon)
{

Zeile 1859Zeile 1867
 * @param string $value The cookie value.
* @param int|string $expires The timestamp of the expiry date.
* @param boolean $httponly True if setting a HttpOnly cookie (supported by the majority of web browsers)

 * @param string $value The cookie value.
* @param int|string $expires The timestamp of the expiry date.
* @param boolean $httponly True if setting a HttpOnly cookie (supported by the majority of web browsers)

 
 * @param string $samesite The samesite attribute to prevent CSRF.

 */

 */

function my_setcookie($name, $value="", $expires="", $httponly=false)

function my_setcookie($name, $value="", $expires="", $httponly=false, $samesite="")

{
global $mybb;


{
global $mybb;


Zeile 1907Zeile 1916
	if($httponly == true)
{
$cookie .= "; HttpOnly";

	if($httponly == true)
{
$cookie .= "; HttpOnly";

 
	}

if($samesite != "" && $mybb->settings['cookiesamesiteflag'])
{
$samesite = strtolower($samesite);

if($samesite == "lax" || $samesite == "strict")
{
$cookie .= "; SameSite=".$samesite;
}

	}

if($mybb->settings['cookiesecureflag'])

	}

if($mybb->settings['cookiesecureflag'])

Zeile 1942Zeile 1961
 * @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]))

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

	{

	{

		return false;

		return false;

	}

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

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

	}

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

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

		return $cookie[$id];
}
else

		return $cookie[$id];
}
else

Zeile 1976Zeile 1995

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


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

	{

	{

		$newcookie = my_unserialize($cookie[$name]);

		$newcookie = my_unserialize($cookie[$name]);

	}

	}

	else
{
$newcookie = array();

	else
{
$newcookie = array();

Zeile 1987Zeile 2006
	$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);





	// 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 1998Zeile 2017
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);





/**
* Credits go to https://github.com/piwik
* Safe unserialize() replacement

/**
* Credits go to https://github.com/piwik
* Safe unserialize() replacement

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

	if(is_float($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 2253Zeile 2272
		}

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 2282Zeile 2301
	}

return $out;

	}

return $out;

}


}


/**
* Returns the serverload of the system.
*

/**
* Returns the serverload of the system.
*

Zeile 2312Zeile 2331
		if(!is_numeric($serverload[0]))
{
if($mybb->safemode)

		if(!is_numeric($serverload[0]))
{
if($mybb->safemode)

			{
return $lang->unknown;

			{
return $lang->unknown;

			}

// Suhosin likes to throw a warning if exec is disabled then die - weird

			}

// Suhosin likes to throw a warning if exec is disabled then die - weird

Zeile 2358Zeile 2377
 * @return int The amount of memory allocated to the script.
*/
function get_memory_usage()

 * @return int The amount of memory allocated to the script.
*/
function get_memory_usage()

{

{

	if(function_exists('memory_get_peak_usage'))
{
return memory_get_peak_usage(true);

	if(function_exists('memory_get_peak_usage'))
{
return memory_get_peak_usage(true);

Zeile 2702Zeile 2721
				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
{
$update_query[$counter] = $changes[$counter];
}

// Less than 0? That's bad
if(isset($update_query[$counter]) && $update_query[$counter] < 0)
{
$update_query[$counter] = 0;
}
}
}

$db->free_result($query);

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

$db->free_result($query);


// 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 2732Zeile 2751
 * @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);

Zeile 2837Zeile 2856
			else
{
$update_query[$counter] = $changes[$counter];

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

			}

			}


// Less than 0? That's bad
if(isset($update_query[$counter]) && $update_query[$counter] < 0)


// Less than 0? That's bad
if(isset($update_query[$counter]) && $update_query[$counter] < 0)

Zeile 2863Zeile 2882
 * @return bool
*/
function delete_thread($tid)

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

{
global $moderation;

if(!is_object($moderation))
{

{
global $moderation;

if(!is_object($moderation))
{

		require_once MYBB_ROOT."inc/class_moderation.php";
$moderation = new Moderation;
}

		require_once MYBB_ROOT."inc/class_moderation.php";
$moderation = new Moderation;
}





	return $moderation->delete_thread($tid);
}


	return $moderation->delete_thread($tid);
}


Zeile 2882Zeile 2901
 * @return bool
*/
function delete_post($pid)

 * @return bool
*/
function delete_post($pid)

{

{

	global $moderation;

if(!is_object($moderation))

	global $moderation;

if(!is_object($moderation))

Zeile 2912Zeile 2931
	global $forum_cache, $jumpfcache, $permissioncache, $mybb, $forumjump, $forumjumpbits, $gobutton, $theme, $templates, $lang;

$pid = (int)$pid;

	global $forum_cache, $jumpfcache, $permissioncache, $mybb, $forumjump, $forumjumpbits, $gobutton, $theme, $templates, $lang;

$pid = (int)$pid;





	if(!is_array($jumpfcache))
{
if(!is_array($forum_cache))

	if(!is_array($jumpfcache))
{
if(!is_array($forum_cache))

		{

		{

			cache_forums();

			cache_forums();

		}

		}


foreach($forum_cache as $fid => $forum)
{


foreach($forum_cache as $fid => $forum)
{

Zeile 2927Zeile 2946
				$jumpfcache[$forum['pid']][$forum['disporder']][$forum['fid']] = $forum;
}
}

				$jumpfcache[$forum['pid']][$forum['disporder']][$forum['fid']] = $forum;
}
}

	}

	}


if(!is_array($permissioncache))
{


if(!is_array($permissioncache))
{

Zeile 2956Zeile 2975
					eval("\$forumjumpbits .= \"".$templates->get("forumjump_bit")."\";");

if($forum_cache[$forum['fid']])

					eval("\$forumjumpbits .= \"".$templates->get("forumjump_bit")."\";");

if($forum_cache[$forum['fid']])

					{

					{

						$newdepth = $depth."--";
$forumjumpbits .= build_forum_jump($forum['fid'], $selitem, 0, $newdepth, $showextras, $showall);
}

						$newdepth = $depth."--";
$forumjumpbits .= build_forum_jump($forum['fid'], $selitem, 0, $newdepth, $showextras, $showall);
}

Zeile 2970Zeile 2989
		if($showextras == 0)
{
$template = "special";

		if($showextras == 0)
{
$template = "special";

		}

		}

		else
{
$template = "advanced";

		else
{
$template = "advanced";

Zeile 3000Zeile 3019
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.


/**
* Generates a random string.

Zeile 3030Zeile 3049
	}

for($i = 0; $i < $length; ++$i)

	}

for($i = 0; $i < $length; ++$i)

	{

	{

		$str[] = $set[my_rand(0, 61)];
}


		$str[] = $set[my_rand(0, 61)];
}


Zeile 3059Zeile 3078
		if(!is_array($groupscache))
{
$groupscache = $cache->read("usergroups");

		if(!is_array($groupscache))
{
$groupscache = $cache->read("usergroups");

		}


		}


		if($displaygroup != 0)

		if($displaygroup != 0)

		{

		{

			$usergroup = $displaygroup;

			$usergroup = $displaygroup;

		}

		}


$format = "{username}";


$format = "{username}";





		if(isset($groupscache[$usergroup]))
{
$ugroup = $groupscache[$usergroup];

		if(isset($groupscache[$usergroup]))
{
$ugroup = $groupscache[$usergroup];

Zeile 3075Zeile 3094
			if(strpos($ugroup['namestyle'], "{username}") !== false)
{
$format = $ugroup['namestyle'];

			if(strpos($ugroup['namestyle'], "{username}") !== false)
{
$format = $ugroup['namestyle'];

			}
}

			}
}


$format = stripslashes($format);



$format = stripslashes($format);


Zeile 3435Zeile 3454
function build_clickable_smilies()
{
global $cache, $smiliecache, $theme, $templates, $lang, $mybb, $smiliecount;

function build_clickable_smilies()
{
global $cache, $smiliecache, $theme, $templates, $lang, $mybb, $smiliecount;





	if($mybb->settings['smilieinserter'] != 0 && $mybb->settings['smilieinsertercols'] && $mybb->settings['smilieinsertertot'])
{
if(!$smiliecount)

	if($mybb->settings['smilieinserter'] != 0 && $mybb->settings['smilieinsertercols'] && $mybb->settings['smilieinsertertot'])
{
if(!$smiliecount)

Zeile 3671Zeile 3690
	else
{
eval("\$prefixselect = \"".$templates->get("post_prefixselect_single")."\";");

	else
{
eval("\$prefixselect = \"".$templates->get("post_prefixselect_single")."\";");

	}

return $prefixselect;
}


	}

return $prefixselect;
}


/**
* Build the thread prefix selection menu for a forum without group permission checks
*

/**
* Build the thread prefix selection menu for a forum without group permission checks
*

Zeile 3914Zeile 3933
	else
{
eval("\$display_reputation = \"".$templates->get("postbit_reputation_formatted")."\";");

	else
{
eval("\$display_reputation = \"".$templates->get("postbit_reputation_formatted")."\";");

	}

	}


return $display_reputation;
}


return $display_reputation;
}

Zeile 5466Zeile 5485
		$lang->month_11,
$lang->month_12
);

		$lang->month_11,
$lang->month_12
);



 

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


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

Zeile 5495Zeile 5513
		'&#70;',
'&#108;',
'&#77;',

		'&#70;',
'&#108;',
'&#77;',

	);

	);


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


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

Zeile 5512Zeile 5530
		$bmonth[$bm-1],
$wd,
($bm == 9 ? my_substr($bmonth[$bm-1], 0, 4) : my_substr($bmonth[$bm-1], 0, 3)),

		$bmonth[$bm-1],
$wd,
($bm == 9 ? my_substr($bmonth[$bm-1], 0, 4) : my_substr($bmonth[$bm-1], 0, 3)),

	);

	);


// Do we have the full month in our output?
// If so there's no need for the short month
if(strpos($display, 'F') !== false)


// Do we have the full month in our output?
// If so there's no need for the short month
if(strpos($display, 'F') !== false)

	{

	{

		array_pop($find);
array_pop($replace);
}

		array_pop($find);
array_pop($replace);
}

Zeile 5537Zeile 5555
	if(!$bday[2])
{
return;

	if(!$bday[2])
{
return;

	}

list($day, $month, $year) = explode("-", my_date("j-n-Y", TIME_NOW, 0, 0));

	}

list($day, $month, $year) = explode("-", my_date("j-n-Y", TIME_NOW, 0, 0));


$age = $year-$bday[2];



$age = $year-$bday[2];


Zeile 5556Zeile 5574
 * @param int $tid The thread id for which to update the first post id.
*/
function update_first_post($tid)

 * @param int $tid The thread id for which to update the first post id.
*/
function update_first_post($tid)

{
global $db;

{
global $db;


$query = $db->query("
SELECT u.uid, u.username, p.pid, p.username AS postusername, p.dateline


$query = $db->query("
SELECT u.uid, u.username, p.pid, p.username AS postusername, p.dateline

Zeile 5574Zeile 5592
		$firstpost['username'] = $firstpost['postusername'];
}
$firstpost['username'] = $db->escape_string($firstpost['username']);

		$firstpost['username'] = $firstpost['postusername'];
}
$firstpost['username'] = $db->escape_string($firstpost['username']);





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

	$update_array = array(
'firstpost' => (int)$firstpost['pid'],
'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}'");
}


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

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





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

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

Zeile 5690Zeile 5708
		if($length != null)
{
$cut_string = mb_substr($string, $start, $length);

		if($length != null)
{
$cut_string = mb_substr($string, $start, $length);

		}
else
{

		}
else
{

			$cut_string = mb_substr($string, $start);
}
}

			$cut_string = mb_substr($string, $start);
}
}

Zeile 5709Zeile 5727
	}

if($handle_entities)

	}

if($handle_entities)

	{

	{

		$cut_string = htmlspecialchars_uni($cut_string);
}
return $cut_string;

		$cut_string = htmlspecialchars_uni($cut_string);
}
return $cut_string;

}

/**

}

/**

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

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

Zeile 5726Zeile 5744
	if(function_exists("mb_strtolower"))
{
$string = mb_strtolower($string);

	if(function_exists("mb_strtolower"))
{
$string = mb_strtolower($string);

	}

	}

	else
{
$string = strtolower($string);

	else
{
$string = strtolower($string);

Zeile 5737Zeile 5755

/**
* Finds a needle in a haystack and returns it position, mb strings accounted for


/**
* Finds a needle in a haystack and returns it position, mb strings accounted for

 *

 *

 * @param string $haystack String to look in (haystack)
* @param string $needle What to look for (needle)
* @param int $offset (optional) How much to offset
* @return int|bool false on needle not found, integer position if found

 * @param string $haystack String to look in (haystack)
* @param string $needle What to look for (needle)
* @param int $offset (optional) How much to offset
* @return int|bool false on needle not found, integer position if found

 */

 */

function my_strpos($haystack, $needle, $offset=0)
{
if($needle == '')

function my_strpos($haystack, $needle, $offset=0)
{
if($needle == '')

Zeile 5753Zeile 5771
	if(function_exists("mb_strpos"))
{
$position = mb_strpos($haystack, $needle, $offset);

	if(function_exists("mb_strpos"))
{
$position = mb_strpos($haystack, $needle, $offset);

	}

	}

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

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

	}


	}


	return $position;
}


	return $position;
}


Zeile 5780Zeile 5798
	}

return $string;

	}

return $string;

}

/**

}

/**

 * Returns any html entities to their original character
*
* @param string $string The string to un-htmlentitize.

 * Returns any html entities to their original character
*
* @param string $string The string to un-htmlentitize.

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

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





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

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

Zeile 5810Zeile 5828
function unichr($c)
{
if($c <= 0x7F)

function unichr($c)
{
if($c <= 0x7F)

	{

	{

		return chr($c);
}
else if($c <= 0x7FF)

		return chr($c);
}
else if($c <= 0x7FF)

Zeile 5820Zeile 5838
	else if($c <= 0xFFFF)
{
return chr(0xE0 | $c >> 12) . chr(0x80 | $c >> 6 & 0x3F)

	else if($c <= 0xFFFF)
{
return chr(0xE0 | $c >> 12) . chr(0x80 | $c >> 6 & 0x3F)

									. chr(0x80 | $c & 0x3F);
}

									. chr(0x80 | $c & 0x3F);
}

	else if($c <= 0x10FFFF)

	else if($c <= 0x10FFFF)

	{

	{

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

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

	}
else
{

	}
else
{

		return false;
}

		return false;
}

}

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

}

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

 *
* @param array $matches Matches.
* @return string|bool The characterized ascii. False on failure

 *
* @param array $matches Matches.
* @return string|bool The characterized ascii. False on failure

Zeile 5843Zeile 5861
function unichr_callback1($matches)
{
return unichr(hexdec($matches[1]));

function unichr_callback1($matches)
{
return unichr(hexdec($matches[1]));

}


}


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

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

Zeile 5852Zeile 5870
 * @return string|bool The characterized ascii. False on failure
*/
function unichr_callback2($matches)

 * @return string|bool The characterized ascii. False on failure
*/
function unichr_callback2($matches)

{

{

	return unichr($matches[1]);
}


	return unichr($matches[1]);
}


Zeile 5861Zeile 5879
 *
* @param array $event The event data array.
* @return string The link to the event poster.

 *
* @param array $event The event data array.
* @return string The link to the event poster.

 */

 */

function get_event_poster($event)
{
$event['username'] = htmlspecialchars_uni($event['username']);
$event['username'] = format_name($event['username'], $event['usergroup'], $event['displaygroup']);
$event_poster = build_profile_link($event['username'], $event['author']);
return $event_poster;

function get_event_poster($event)
{
$event['username'] = htmlspecialchars_uni($event['username']);
$event['username'] = format_name($event['username'], $event['usergroup'], $event['displaygroup']);
$event_poster = build_profile_link($event['username'], $event['author']);
return $event_poster;

}

/**

}

/**

 * Get the event date.
*
* @param array $event The event data array.

 * Get the event date.
*
* @param array $event The event data array.

Zeile 5885Zeile 5903
	$event_date = my_date($mybb->settings['dateformat'], $event_date);

return $event_date;

	$event_date = my_date($mybb->settings['dateformat'], $event_date);

return $event_date;

}

/**

}

/**

 * Get the profile link.
*
* @param int $uid The user id of the profile.

 * Get the profile link.
*
* @param int $uid The user id of the profile.

Zeile 5896Zeile 5914
function get_profile_link($uid=0)
{
$link = str_replace("{uid}", $uid, PROFILE_URL);

function get_profile_link($uid=0)
{
$link = str_replace("{uid}", $uid, PROFILE_URL);

	return htmlspecialchars_uni($link);
}

/**

	return htmlspecialchars_uni($link);
}

/**

 * Get the announcement link.
*
* @param int $aid The announement id of the announcement.
* @return string The url to the announcement.

 * Get the announcement link.
*
* @param int $aid The announement id of the announcement.
* @return string The url to the announcement.

 */

 */

function get_announcement_link($aid=0)
{
$link = str_replace("{aid}", $aid, ANNOUNCEMENT_URL);

function get_announcement_link($aid=0)
{
$link = str_replace("{aid}", $aid, ANNOUNCEMENT_URL);

Zeile 5921Zeile 5939
 * @return string The complete profile link.
*/
function build_profile_link($username="", $uid=0, $target="", $onclick="")

 * @return string The complete profile link.
*/
function build_profile_link($username="", $uid=0, $target="", $onclick="")

{

{

	global $mybb, $lang;

if(!$username && $uid == 0)

	global $mybb, $lang;

if(!$username && $uid == 0)

Zeile 5946Zeile 5964
		{
$onclick = " onclick=\"{$onclick}\"";
}

		{
$onclick = " onclick=\"{$onclick}\"";
}





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

Zeile 5963Zeile 5981
	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("{fid}", $fid, FORUM_URL);
return htmlspecialchars_uni($link);

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

	}
}


	}
}


Zeile 6107Zeile 6125
 * Get the user data of an user id.
*
* @param int $uid The user id of the user.

 * Get the user data of an user id.
*
* @param int $uid The user id of the user.

 * @return array The users data
*/

 * @return array The users data
*/

function get_user($uid)
{
global $mybb, $db;

function get_user($uid)
{
global $mybb, $db;

Zeile 6317Zeile 6335
	if(!$forum_cache)
{
cache_forums();

	if(!$forum_cache)
{
cache_forums();

	}


	}


	$inactive = array();

foreach($forum_cache as $fid => $forum)

	$inactive = array();

foreach($forum_cache as $fid => $forum)

Zeile 6327Zeile 6345
		{
$inactive[] = $fid;
foreach($forum_cache as $fid1 => $forum1)

		{
$inactive[] = $fid;
foreach($forum_cache as $fid1 => $forum1)

			{

			{

				if(my_strpos(",".$forum1['parentlist'].",", ",".$fid.",") !== false && !in_array($fid1, $inactive))
{
$inactive[] = $fid1;
}

				if(my_strpos(",".$forum1['parentlist'].",", ",".$fid.",") !== false && !in_array($fid1, $inactive))
{
$inactive[] = $fid1;
}

			}
}
}

$inactiveforums = implode(",", $inactive);

			}
}
}

$inactiveforums = implode(",", $inactive);


return $inactiveforums;
}


return $inactiveforums;
}

Zeile 6347Zeile 6365
 * @param bool $fatal (Optional) Stop execution if it finds an error with the login. Default is True
* @return bool|int Number of logins when success, false if failed.
*/

 * @param bool $fatal (Optional) Stop execution if it finds an error with the login. Default is True
* @return bool|int Number of logins when success, false if failed.
*/

function login_attempt_check($fatal = true)

function login_attempt_check($uid = 0, $fatal = true)

{

{

	global $mybb, $lang, $session, $db;

if($mybb->settings['failedlogincount'] == 0)
{
return 1;
}
// Note: Number of logins is defaulted to 1, because using 0 seems to clear cookie data. Not really a problem as long as we account for 1 being default.

// Use cookie if possible, otherwise use session
// Find better solution to prevent clearing cookies
$loginattempts = 0;
$failedlogin = 0;

if(!empty($mybb->cookies['loginattempts']))
{
$loginattempts = $mybb->cookies['loginattempts'];
}

if(!empty($mybb->cookies['failedlogin']))
{
$failedlogin = $mybb->cookies['failedlogin'];
}

// Work out if the user has had more than the allowed number of login attempts
if($loginattempts > $mybb->settings['failedlogincount'])

	global $mybb, $lang, $db;

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

// Get this user's login attempts and eventual lockout, if a uid is provided
if($uid > 0)


















	{

	{

		// If so, then we need to work out if they can try to login again
// Some maths to work out how long they have left and display it to them
$now = TIME_NOW;

if(empty($mybb->cookies['failedlogin']))








		$query = $db->simple_select("users", "loginattempts, loginlockoutexpiry", "uid='{$uid}'", 1);
$attempts = $db->fetch_array($query);

if($attempts['loginattempts'] <= 0)
{
return 0;
}
}
// This user has a cookie lockout, show waiting time
elseif($mybb->cookies['lockoutexpiry'] && $mybb->cookies['lockoutexpiry'] > $now)
{
if($fatal)

		{

		{

			$failedtime = $now;






























			$secsleft = (int)($mybb->cookies['lockoutexpiry'] - $now);
$hoursleft = floor($secsleft / 3600);
$minsleft = floor(($secsleft / 60) % 60);
$secsleft = floor($secsleft % 60);

error($lang->sprintf($lang->failed_login_wait, $hoursleft, $minsleft, $secsleft));
}

return false;
}

if($mybb->settings['failedlogincount'] > 0 && $attempts['loginattempts'] >= $mybb->settings['failedlogincount'])
{
// Set the expiry dateline if not set yet
if($attempts['loginlockoutexpiry'] == 0)
{
$attempts['loginlockoutexpiry'] = $now + ((int)$mybb->settings['failedlogintime'] * 60);

// Add a cookie lockout. This is used to prevent access to the login page immediately.
// A deep lockout is issued if he tries to login into a locked out account
my_setcookie('lockoutexpiry', $attempts['loginlockoutexpiry']);

$db->update_query("users", array(
"loginlockoutexpiry" => $attempts['loginlockoutexpiry']
), "uid='{$uid}'");
}

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

		}
else
{

		}
else
{

			$failedtime = $mybb->cookies['failedlogin'];

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

		}


		}


		$secondsleft = $mybb->settings['failedlogintime'] * 60 + $failedtime - $now;
$hoursleft = floor($secondsleft / 3600);
$minsleft = floor(($secondsleft / 60) % 60);
$secsleft = floor($secondsleft % 60);

// This value will be empty the first time the user doesn't login in, set it
if(empty($failedlogin))
{
my_setcookie('failedlogin', $now);

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







			if($fatal)

			if($fatal)

			{






			{
$secsleft = (int)($attempts['loginlockoutexpiry'] - $now);
$hoursleft = floor($secsleft / 3600);
$minsleft = floor(($secsleft / 60) % 60);
$secsleft = floor($secsleft % 60);


				error($lang->sprintf($lang->failed_login_wait, $hoursleft, $minsleft, $secsleft));
}

				error($lang->sprintf($lang->failed_login_wait, $hoursleft, $minsleft, $secsleft));
}





			return false;
}

			return false;
}

 
		// Unlock if enough time has passed
else {





		// Work out if the user has waited long enough before letting them login again
if($mybb->cookies['failedlogin'] < ($now - $mybb->settings['failedlogintime'] * 60))
{
my_setcookie('loginattempts', 1);
my_unsetcookie('failedlogin');
if($mybb->user['uid'] != 0)

			if($uid > 0)






			{

			{

				$update_array = array(
'loginattempts' => 1
);
$db->update_query("users", $update_array, "uid = '{$mybb->user['uid']}'");
}
return 1;
}
// Not waited long enough
else if($mybb->cookies['failedlogin'] > ($now - $mybb->settings['failedlogintime'] * 60))
{
if($fatal)
{
error($lang->sprintf($lang->failed_login_wait, $hoursleft, $minsleft, $secsleft));

				$db->update_query("users", array(
"loginattempts" => 0,
"loginlockoutexpiry" => 0
), "uid='{$uid}'");










			}


			}


			return false;




			// Wipe the cookie, no matter if a guest or a member
my_unsetcookie('lockoutexpiry');

return 0;

		}
}

// User can attempt another login

		}
}

// User can attempt another login

	return $loginattempts;

	return $attempts['loginattempts'];

}

/**

}

/**

Zeile 7786Zeile 7813
			{
// Invalid IP address
return false;

			{
// Invalid IP address
return false;

			}

			}

		}

/**

		}

/**

Zeile 7815Zeile 7842
		// Some calculations
$ip_lower_bits = str_pad($ip_bits, $ip_bits_size, '0', STR_PAD_RIGHT);
$ip_higher_bits = str_pad($ip_bits, $ip_bits_size, '1', STR_PAD_RIGHT);

		// Some calculations
$ip_lower_bits = str_pad($ip_bits, $ip_bits_size, '0', STR_PAD_RIGHT);
$ip_higher_bits = str_pad($ip_bits, $ip_bits_size, '1', STR_PAD_RIGHT);





		// Lower IP
$ip_lower_pack = '';
for($i=0; $i < $ip_bits_size; $i=$i+8)

		// Lower IP
$ip_lower_pack = '';
for($i=0; $i < $ip_bits_size; $i=$i+8)

Zeile 7853Zeile 7880
	static $time_start;

$time = microtime(true);

	static $time_start;

$time = microtime(true);



 

// Just starting timer, init and return
if(!$time_start)
{
$time_start = $time;
return;


// Just starting timer, init and return
if(!$time_start)
{
$time_start = $time;
return;

	}

	}

	// Timer has run, return execution time
else
{

	// Timer has run, return execution time
else
{

Zeile 7889Zeile 7915
	if(substr($path, -1, 1) == "/")
{
$path = substr($path, 0, -1);

	if(substr($path, -1, 1) == "/")
{
$path = substr($path, 0, -1);

	}


	}


	if(!is_array($bad_verify_files))

	if(!is_array($bad_verify_files))

	{

	{

		$bad_verify_files = array();
}


		$bad_verify_files = array();
}


Zeile 7905Zeile 7931
			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;

				}

// Recurse through the directory tree

				}

// Recurse through the directory tree

Zeile 8385Zeile 8411
					}
}
elseif($c > 239)

					}
}
elseif($c > 239)

				{

				{

					$bytes = 4;
}
elseif($c > 223)

					$bytes = 4;
}
elseif($c > 223)

Zeile 8583Zeile 8609
	}

$pm['options'] = array(

	}

$pm['options'] = array(

		"signature" => 0,

 
		"disablesmilies" => 0,
"savecopy" => 0,
"readreceipt" => 0

		"disablesmilies" => 0,
"savecopy" => 0,
"readreceipt" => 0

Zeile 8745Zeile 8770
/**
* Strip html tags from string, also removes <script> and <style> contents.
*

/**
* Strip html tags from string, also removes <script> and <style> contents.
*

 
 * @deprecated

 * @param  string $string         String to stripe
* @param string $allowable_tags Allowed html tags
*

 * @param  string $string         String to stripe
* @param string $allowable_tags Allowed html tags
*