Vergleich inc/functions.php - 1.8.5 - 1.8.6

  Keine Änderungen   Hinzugefügt   Modifiziert   Entfernt
Zeile 11Zeile 11
/**
* Outputs a page directly to the browser, parsing anything which needs to be parsed.
*

/**
* Outputs a page directly to the browser, parsing anything which needs to be parsed.
*

 * @param string The contents of the page.

 * @param string $contents The contents of the page.

 */
function output_page($contents)
{

 */
function output_page($contents)
{

Zeile 101Zeile 101
/**
* Adds a function or class to the list of code to run on shutdown.
*

/**
* Adds a function or class to the list of code to run on shutdown.
*

 * @param mixed The name of the function.
* @param mixed An array of arguments for the function

 * @param string|array $name The name of the function.
* @param mixed $arguments Either an array of arguments for the function or one argument

 * @return boolean True if function exists, otherwise false.
*/
function add_shutdown($name, $arguments=array())

 * @return boolean True if function exists, otherwise false.
*/
function add_shutdown($name, $arguments=array())

Zeile 242Zeile 242
/**
* Sends a specified amount of messages from the mail queue
*

/**
* Sends a specified amount of messages from the mail queue
*

 * @param int The number of messages to send (Defaults to 10)

 * @param int $count The number of messages to send (Defaults to 10)

 */
function send_mail_queue($count=10)
{

 */
function send_mail_queue($count=10)
{

Zeile 280Zeile 280
/**
* Parses the contents of a page before outputting it.
*

/**
* Parses the contents of a page before outputting it.
*

 * @param string The contents of the page.

 * @param string $contents The contents of the page.

 * @return string The parsed page.
*/
function parse_page($contents)

 * @return string The parsed page.
*/
function parse_page($contents)

Zeile 322Zeile 322
/**
* Turn a unix timestamp in to a "friendly" date/time format for the user.
*

/**
* Turn a unix timestamp in to a "friendly" date/time format for the user.
*

 * @param string A date format according to PHP's date structure.
* @param int The unix timestamp the date should be generated for.
* @param int The offset in hours that should be applied to times. (timezones)
* @param int Whether or not to use today/yesterday formatting.
* @param boolean Whether or not to use the adodb time class for < 1970 or > 2038 times

 * @param string $format A date format according to PHP's date structure.
* @param int $stamp The unix timestamp the date should be generated for.
* @param int|string $offset The offset in hours that should be applied to times. (timezones) Or an empty string to determine that automatically
* @param int $ty Whether or not to use today/yesterday formatting.
* @param boolean $adodb Whether or not to use the adodb time class for < 1970 or > 2038 times

 * @return string The formatted timestamp.
*/

 * @return string The formatted timestamp.
*/

function my_date($format, $stamp="", $offset="", $ty=1, $adodb=false)

function my_date($format, $stamp=0, $offset="", $ty=1, $adodb=false)

{
global $mybb, $lang, $mybbadmin, $plugins;


{
global $mybb, $lang, $mybbadmin, $plugins;


Zeile 512Zeile 512
/**
* Sends an email using PHP's mail function, formatting it appropriately.
*

/**
* Sends an email using PHP's mail function, formatting it appropriately.
*

 * @param string Address the email should be addressed to.
* @param string The subject of the email being sent.
* @param string The message being sent.
* @param string The from address of the email, if blank, the board name will be used.
* @param string The chracter set being used to send this email.
* @param boolean Do we wish to keep the connection to the mail server alive to send more than one message (SMTP only)
* @param string The format of the email to be sent (text or html). text is default
* @param string The text message of the email if being sent in html format, for email clients that don't support html
* @param string The email address to return to. Defaults to admin return email address.



 * @param string $to Address the email should be addressed to.
* @param string $subject The subject of the email being sent.
* @param string $message The message being sent.
* @param string $from The from address of the email, if blank, the board name will be used.
* @param string $charset The chracter set being used to send this email.
* @param string $headers
* @param boolean $keep_alive Do we wish to keep the connection to the mail server alive to send more than one message (SMTP only)
* @param string $format The format of the email to be sent (text or html). text is default
* @param string $message_text The text message of the email if being sent in html format, for email clients that don't support html
* @param string $return_email The email address to return to. Defaults to admin return email address.
* @return bool

 */
function my_mail($to, $subject, $message, $from="", $charset="", $headers="", $keep_alive=false, $format="text", $message_text="", $return_email="")
{

 */
function my_mail($to, $subject, $message, $from="", $charset="", $headers="", $keep_alive=false, $format="text", $message_text="", $return_email="")
{

Zeile 589Zeile 591
/**
* Verifies a POST check code is valid, if not shows an error (silently returns false on silent parameter)
*

/**
* Verifies a POST check code is valid, if not shows an error (silently returns false on silent parameter)
*

 * @param string The incoming POST check code
* @param boolean Silent mode or not (silent mode will not show the error to the user but returns false)


 * @param string $code The incoming POST check code
* @param boolean $silent Silent mode or not (silent mode will not show the error to the user but returns false)
* @return bool

 */
function verify_post_check($code, $silent=false)
{

 */
function verify_post_check($code, $silent=false)
{

Zeile 622Zeile 625
/**
* Return a parent list for the specified forum.
*

/**
* Return a parent list for the specified forum.
*

 * @param int The forum id to get the parent list for.

 * @param int $fid The forum id to get the parent list for.

 * @return string The comma-separated parent list.
*/
function get_parent_list($fid)

 * @return string The comma-separated parent list.
*/
function get_parent_list($fid)

Zeile 648Zeile 651
/**
* Build a parent list of a specific forum, suitable for querying
*

/**
* Build a parent list of a specific forum, suitable for querying
*

 * @param int The forum ID
* @param string The column name to add to the query
* @param string The joiner for each forum for querying (OR | AND | etc)
* @param string The parent list of the forum - if you have it

 * @param int $fid The forum ID
* @param string $column The column name to add to the query
* @param string $joiner The joiner for each forum for querying (OR | AND | etc)
* @param string $parentlist The parent list of the forum - if you have it

 * @return string The query string generated
*/
function build_parent_list($fid, $column="fid", $joiner="OR", $parentlist="")

 * @return string The query string generated
*/
function build_parent_list($fid, $column="fid", $joiner="OR", $parentlist="")

Zeile 679Zeile 682
/**
* Load the forum cache in to memory
*

/**
* Load the forum cache in to memory
*

 * @param boolean True to force a reload of the cache


 * @param boolean $force True to force a reload of the cache
* @return array The forum cache

 */
function cache_forums($force=false)
{

 */
function cache_forums($force=false)
{

Zeile 706Zeile 710
/**
* Generate an array of all child and descendant forums for a specific forum.
*

/**
* Generate an array of all child and descendant forums for a specific forum.
*

 * @param int The forum ID
* @param return Array of descendants

 * @param int $fid The forum ID
* @return Array of descendants

 */
function get_child_list($fid)
{

 */
function get_child_list($fid)
{

Zeile 727Zeile 731
	}
if(!is_array($forums_by_parent[$fid]))
{

	}
if(!is_array($forums_by_parent[$fid]))
{

		return;

		return $forums;

	}

foreach($forums_by_parent[$fid] as $forum)

	}

foreach($forums_by_parent[$fid] as $forum)

Zeile 737Zeile 741
		if(is_array($children))
{
$forums = array_merge($forums, $children);

		if(is_array($children))
{
$forums = array_merge($forums, $children);

		}
}

		}
}

	return $forums;
}

/**
* Produce a friendly error message page
*

	return $forums;
}

/**
* Produce a friendly error message page
*

 * @param string The error message to be shown
* @param string The title of the message shown in the title of the page and the error table

 * @param string $error The error message to be shown
* @param string $title The title of the message shown in the title of the page and the error table

 */
function error($error="", $title="")
{
global $header, $footer, $theme, $headerinclude, $db, $templates, $lang, $mybb, $plugins;

 */
function error($error="", $title="")
{
global $header, $footer, $theme, $headerinclude, $db, $templates, $lang, $mybb, $plugins;





	$error = $plugins->run_hooks("error", $error);
if(!$error)
{

	$error = $plugins->run_hooks("error", $error);
if(!$error)
{

Zeile 785Zeile 789
/**
* Produce an error message for displaying inline on a page
*

/**
* Produce an error message for displaying inline on a page
*

 * @param array Array of errors to be shown
* @param string The title of the error message
* @param string JSON data to be encoded (we may want to send more data; e.g. newreply.php uses this for CAPTCHA)

 * @param array $errors Array of errors to be shown
* @param string $title The title of the error message
* @param array $json_data JSON data to be encoded (we may want to send more data; e.g. newreply.php uses this for CAPTCHA)

 * @return string The inline error HTML
*/
function inline_error($errors, $title="", $json_data=array())

 * @return string The inline error HTML
*/
function inline_error($errors, $title="", $json_data=array())

Zeile 800Zeile 804
	}

if(!is_array($errors))

	}

if(!is_array($errors))

	{

	{

		$errors = array($errors);
}


		$errors = array($errors);
}


Zeile 824Zeile 828
	$errorlist = '';

foreach($errors as $error)

	$errorlist = '';

foreach($errors as $error)

	{

	{

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


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


Zeile 899Zeile 903
/**
* Redirect the user to a given URL with a given message
*

/**
* Redirect the user to a given URL with a given message
*

 * @param string The URL to redirect the user to
* @param string The redirection message to be shown
* @param string The title of the redirection page
* @param boolean Force the redirect page regardless of settings

 * @param string $url The URL to redirect the user to
* @param string $message The redirection message to be shown
* @param string $title The title of the redirection page
* @param boolean $force_redirect Force the redirect page regardless of settings

 */
function redirect($url, $message="", $title="", $force_redirect=false)
{

 */
function redirect($url, $message="", $title="", $force_redirect=false)
{

Zeile 978Zeile 982
/**
* Generate a listing of page - pagination
*

/**
* Generate a listing of page - pagination
*

 * @param int The number of items
* @param int The number of items to be shown per page
* @param int The current page number
* @param string The URL to have page numbers tacked on to (If {page} is specified, the value will be replaced with the page #)
* @param boolean Whether or not the multipage is being shown in the navigation breadcrumb

 * @param int $count The number of items
* @param int $perpage The number of items to be shown per page
* @param int $page The current page number
* @param string $url The URL to have page numbers tacked on to (If {page} is specified, the value will be replaced with the page #)
* @param boolean $breadcrumb Whether or not the multipage is being shown in the navigation breadcrumb

 * @return string The generated pagination
*/
function multipage($count, $perpage, $page, $url, $breadcrumb=false)

 * @return string The generated pagination
*/
function multipage($count, $perpage, $page, $url, $breadcrumb=false)

Zeile 991Zeile 995

if($count <= $perpage)
{


if($count <= $perpage)
{

		return;

		return '';

	}

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

	}

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

Zeile 1017Zeile 1021
	$to = $page+floor($mybb->settings['maxmultipagelinks']/2);

if($from <= 0)

	$to = $page+floor($mybb->settings['maxmultipagelinks']/2);

if($from <= 0)

	{

	{

		$from = 1;
$to = $from+$mybb->settings['maxmultipagelinks']-1;
}

		$from = 1;
$to = $from+$mybb->settings['maxmultipagelinks']-1;
}

Zeile 1039Zeile 1043

$start = '';
if($from > 1)


$start = '';
if($from > 1)

	{

	{

		if($from-1 == 1)
{
$lang->multipage_link_start = '';

		if($from-1 == 1)
{
$lang->multipage_link_start = '';

Zeile 1084Zeile 1088

$nextpage = '';
if($page < $pages)


$nextpage = '';
if($page < $pages)

	{

	{

		$next = $page+1;
$page_url = fetch_page_url($url, $next);
eval("\$nextpage = \"".$templates->get("multipage_nextpage")."\";");

		$next = $page+1;
$page_url = fetch_page_url($url, $next);
eval("\$nextpage = \"".$templates->get("multipage_nextpage")."\";");

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

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

	}


	}


	return $multipage;
}

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

	return $multipage;
}

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

 * @param string The URL being passed
* @param int The page number


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

 */
function fetch_page_url($url, $page)
{

 */
function fetch_page_url($url, $page)
{

Zeile 1131Zeile 1136
		// Remove "Page 1" to the defacto URL
$url = str_replace($find, array("", "", $page), $url);
return $url;

		// Remove "Page 1" to the defacto URL
$url = str_replace($find, array("", "", $page), $url);
return $url;

	}

	}

	else if(strpos($url, "{page}") === false)
{
// If no page identifier is specified we tack it on to the end of the URL
if(strpos($url, "?") === false)

	else if(strpos($url, "{page}") === false)
{
// If no page identifier is specified we tack it on to the end of the URL
if(strpos($url, "?") === false)

		{

		{

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

			$url .= "?";
}
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;

	return $url;

}

/**

}

/**

 * Fetch the permissions for a specific user
*

 * Fetch the permissions for a specific user
*

 * @param int The user ID

 * @param int $uid The user ID

 * @return array Array of user permissions for the specified user
*/
function user_permissions($uid=0)

 * @return array Array of user permissions for the specified user
*/
function user_permissions($uid=0)

Zeile 1177Zeile 1182
		if($user_cache[$uid]['permissions'])
{
return $user_cache[$uid]['permissions'];

		if($user_cache[$uid]['permissions'])
{
return $user_cache[$uid]['permissions'];

		}


		}


		// This user was not already cached, fetch their user information.
if(!$user_cache[$uid])
{

		// This user was not already cached, fetch their user information.
if(!$user_cache[$uid])
{

Zeile 1202Zeile 1207

/**
* Fetch the usergroup permissions for a specific group or series of groups combined


/**
* Fetch the usergroup permissions for a specific group or series of groups combined

 *
* @param mixed A list of groups (Can be a single integer, or a list of groups separated by a comma)

 *
* @param int|string $gid A list of groups (Can be a single integer, or a list of groups separated by a comma)

 * @return array Array of permissions generated for the groups
*/
function usergroup_permissions($gid=0)

 * @return array Array of permissions generated for the groups
*/
function usergroup_permissions($gid=0)

Zeile 1265Zeile 1270
/**
* Fetch the display group properties for a specific display group
*

/**
* Fetch the display group properties for a specific display group
*

 * @param int The group ID to fetch the display properties for

 * @param int $gid The group ID to fetch the display properties for

 * @return array Array of display properties for the group
*/
function usergroup_displaygroup($gid)

 * @return array Array of display properties for the group
*/
function usergroup_displaygroup($gid)

Zeile 1291Zeile 1296
/**
* Build the forum permissions for a specific forum, user or group
*

/**
* Build the forum permissions for a specific forum, user or group
*

 * @param int The forum ID to build permissions for (0 builds for all forums)
* @param int The user to build the permissions for (0 will select the uid automatically)
* @param int The group of the user to build permissions for (0 will fetch it)

 * @param int $fid The forum ID to build permissions for (0 builds for all forums)
* @param int $uid The user to build the permissions for (0 will select the uid automatically)
* @param int $gid The group of the user to build permissions for (0 will fetch it)

 * @return array Forum permissions for the specific forum or forums
*/
function forum_permissions($fid=0, $uid=0, $gid=0)

 * @return array Forum permissions for the specific forum or forums
*/
function forum_permissions($fid=0, $uid=0, $gid=0)

Zeile 1367Zeile 1372
 * Fetches the permissions for a specific forum/group applying the inheritance scheme.
* Called by forum_permissions()
*

 * Fetches the permissions for a specific forum/group applying the inheritance scheme.
* Called by forum_permissions()
*

 * @param int The forum ID
* @param string A comma separated list of usergroups
* @param array Group permissions

 * @param int $fid The forum ID
* @param string $gid A comma separated list of usergroups
* @param array $groupperms Group permissions

 * @return array Permissions for this forum
*/
function fetch_forum_permissions($fid, $gid, $groupperms)

 * @return array Permissions for this forum
*/
function fetch_forum_permissions($fid, $gid, $groupperms)

Zeile 1459Zeile 1464
/**
* Check the password given on a certain forum for validity
*

/**
* Check the password given on a certain forum for validity
*

 * @param int The forum ID
* @param boolean The Parent ID



 * @param int $fid The forum ID
* @param int $pid The Parent ID
* @param bool $return
* @return bool

 */

 */

function check_forum_password($fid, $pid=0)

function check_forum_password($fid, $pid=0, $return=false)

{
global $mybb, $header, $footer, $headerinclude, $theme, $templates, $lang, $forum_cache;


{
global $mybb, $header, $footer, $headerinclude, $theme, $templates, $lang, $forum_cache;


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

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

			{
continue;
}

			{
continue;
}


if($forum_cache[$parent_id]['password'] != "")
{


if($forum_cache[$parent_id]['password'] != "")
{

Zeile 1512Zeile 1519
			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]))

			{

			{

				$showform = true;
}
else
{
$showform = false;
}

				$showform = true;
}
else
{
$showform = false;
}

		}
}

		}
}

	else

	else

	{

	{

		$showform = false;

		$showform = false;

 
	}

if($return)
{
return $showform;

	}

if($showform)

	}

if($showform)

Zeile 1551Zeile 1563
/**
* Return the permissions for a moderator in a specific forum
*

/**
* Return the permissions for a moderator in a specific forum
*

 * @param fid The forum ID
* @param uid The user ID to fetch permissions for (0 assumes current logged in user)
* @param string The parent list for the forum (if blank, will be fetched)

 * @param int $fid The forum ID
* @param int $uid The user ID to fetch permissions for (0 assumes current logged in user)
* @param string $parentslist The parent list for the forum (if blank, will be fetched)

 * @return array Array of moderator permissions for the specific forum
*/

 * @return array Array of moderator permissions for the specific forum
*/

function get_moderator_permissions($fid, $uid="0", $parentslist="")

function get_moderator_permissions($fid, $uid=0, $parentslist="")

{
global $mybb, $cache, $db;
static $modpermscache;

{
global $mybb, $cache, $db;
static $modpermscache;

Zeile 1574Zeile 1586
	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));
}





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

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

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

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





	if(!empty($user['additionalgroups']))
{
$extra_groups = explode(",", $user['additionalgroups']);

	if(!empty($user['additionalgroups']))
{
$extra_groups = explode(",", $user['additionalgroups']);

Zeile 1660Zeile 1672
/**
* Checks if a moderator has permissions to perform an action in a specific forum
*

/**
* Checks if a moderator has permissions to perform an action in a specific forum
*

 * @param int The forum ID (0 assumes global)
* @param string The action tyring to be performed. (blank assumes any action at all)
* @param int The user ID (0 assumes current user)

 * @param int $fid The forum ID (0 assumes global)
* @param string $action The action tyring to be performed. (blank assumes any action at all)
* @param int $uid The user ID (0 assumes current user)

 * @return bool Returns true if the user has permission, false if they do not
*/

 * @return bool Returns true if the user has permission, false if they do not
*/

function is_moderator($fid="0", $action="", $uid="0")

function is_moderator($fid=0, $action="", $uid=0)

{
global $mybb, $cache;


{
global $mybb, $cache;


Zeile 1773Zeile 1785
		{
$checked = " checked=\"checked\"";
$no_icons_checked = '';

		{
$checked = " checked=\"checked\"";
$no_icons_checked = '';

		}
else

		}
else

		{
$checked = '';
}

		{
$checked = '';
}

Zeile 1785Zeile 1797
	eval("\$posticons = \"".$templates->get("posticons")."\";");

return $posticons;

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

return $posticons;

}


}


/**
* MyBB setcookie() wrapper.
*

/**
* MyBB setcookie() wrapper.
*

 * @param string The cookie identifier.
* @param string The cookie value.
* @param int The timestamp of the expiry date.
* @param boolean True if setting a HttpOnly cookie (supported by IE, Opera 9, Konqueror)

 * @param string $name The cookie identifier.
* @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)

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

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

Zeile 1813Zeile 1825
		$expires = TIME_NOW + (60*60*24*365); // Make the cookie expire in a years time
}
else

		$expires = TIME_NOW + (60*60*24*365); // Make the cookie expire in a years time
}
else

	{

	{

		$expires = TIME_NOW + (int)$expires;
}


		$expires = TIME_NOW + (int)$expires;
}


Zeile 1847Zeile 1859
	$mybb->cookies[$name] = $value;

header($cookie, false);

	$mybb->cookies[$name] = $value;

header($cookie, false);

}

}


/**
* Unset a cookie set by MyBB.
*


/**
* Unset a cookie set by MyBB.
*

 * @param string The cookie identifier.

 * @param string $name The cookie identifier.

 */
function my_unsetcookie($name)
{

 */
function my_unsetcookie($name)
{

Zeile 1860Zeile 1872

$expires = -3600;
my_setcookie($name, "", $expires);


$expires = -3600;
my_setcookie($name, "", $expires);





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

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

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

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

 * @param string The cookie identifier.
* @param int The cookie content id.

 * @param string $name The cookie identifier.
* @param int $id The cookie content id.

 * @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]))
{

Zeile 1895Zeile 1907
/**
* Set a serialised cookie array.
*

/**
* Set a serialised cookie array.
*

 * @param string The cookie identifier.
* @param int The cookie content id.
* @param string The value to set the cookie to.
* @param int The timestamp of the expiry date.

 * @param string $name The cookie identifier.
* @param int $id The cookie content id.
* @param string $value The value to set the cookie to.
* @param int|string $expires The timestamp of the expiry date.

 */
function my_set_array_cookie($name, $id, $value, $expires="")
{

 */
function my_set_array_cookie($name, $id, $value, $expires="")
{

Zeile 2060Zeile 2072
					if(count($list) >= MAX_SERIALIZED_ARRAY_LENGTH)
{
// array size exceeds MAX_SERIALIZED_ARRAY_LENGTH

					if(count($list) >= MAX_SERIALIZED_ARRAY_LENGTH)
{
// array size exceeds MAX_SERIALIZED_ARRAY_LENGTH

						return false;
}

						return false;
}

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

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

Zeile 2084Zeile 2096
						// array nesting exceeds MAX_SERIALIZED_ARRAY_DEPTH
return false;
}

						// array nesting exceeds MAX_SERIALIZED_ARRAY_DEPTH
return false;
}





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

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

Zeile 2107Zeile 2119
	{
// trailing data in input
return false;

	{
// trailing data in input
return false;

	}

	}

	return $data;
}


	return $data;
}


Zeile 2119Zeile 2131
 * @return mixed
*/
function my_unserialize($str)

 * @return mixed
*/
function my_unserialize($str)

{

{

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

	// Ensure we use the byte count for strings even when strlen() is overloaded by mb_strlen()
if(function_exists('mb_internal_encoding') && (((int)ini_get('mbstring.func_overload')) & 2))
{
$mbIntEnc = mb_internal_encoding();
mb_internal_encoding('ASCII');
}





	$out = _safe_unserialize($str);

if(isset($mbIntEnc))

	$out = _safe_unserialize($str);

if(isset($mbIntEnc))

	{

	{

		mb_internal_encoding($mbIntEnc);
}


		mb_internal_encoding($mbIntEnc);
}


Zeile 2152Zeile 2164
	if(is_null($value))
{
return 'N;';

	if(is_null($value))
{
return 'N;';

	}


	}


	if(is_bool($value))

	if(is_bool($value))

	{

	{

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

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

	}


	}


	if(is_int($value))
{
return 'i:'.$value.';';

	if(is_int($value))
{
return 'i:'.$value.';';

	}


	}


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

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

Zeile 2242Zeile 2254
		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
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'))
{

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

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

			{

			{

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

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

Zeile 2275Zeile 2287
	else
{
return $lang->unknown;

	else
{
return $lang->unknown;

	}

$returnload = trim($serverload[0]);

	}

$returnload = trim($serverload[0]);


return $returnload;
}


return $returnload;
}

Zeile 2303Zeile 2315
/**
* Updates the forum statistics with specific values (or addition/subtraction of the previous value)
*

/**
* Updates the forum statistics with specific values (or addition/subtraction of the previous value)
*

 * @param array Array of items being updated (numthreads,numposts,numusers,numunapprovedthreads,numunapprovedposts,numdeletedposts,numdeletedthreads)
* @param boolean Force stats update?

 * @param array $changes Array of items being updated (numthreads,numposts,numusers,numunapprovedthreads,numunapprovedposts,numdeletedposts,numdeletedthreads)
* @param boolean $force Force stats update?

 */
function update_stats($changes=array(), $force=false)
{
global $cache, $db;
static $stats_changes;

 */
function update_stats($changes=array(), $force=false)
{
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 2329Zeile 2341
			'numdeletedthreads' => '+0',
'inserted' => false // Reset after changes are inserted into cache
);

			'numdeletedthreads' => '+0',
'inserted' => false // Reset after changes are inserted into cache
);

		$stats = $stats_changes;
}


		$stats = $stats_changes;
}


	if($force) // Force writing to cache?
{
if(!empty($changes))

	if($force) // Force writing to cache?
{
if(!empty($changes))

Zeile 2352Zeile 2364
	foreach($counters as $counter)
{
if(array_key_exists($counter, $changes))

	foreach($counters as $counter)
{
if(array_key_exists($counter, $changes))

		{

		{

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

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

Zeile 2394Zeile 2406
	{
$stats_changes = array_merge($stats, $new_stats); // Overwrite changed values
return;

	{
$stats_changes = array_merge($stats, $new_stats); // Overwrite changed values
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 2414Zeile 2426
		else
{
$stats = $new_stats;

		else
{
$stats = $new_stats;

		}
}

		}
}


// Update stats row for today in the database
$todays_stats = array(


// Update stats row for today in the database
$todays_stats = array(

Zeile 2433Zeile 2445
/**
* Updates the forum counters with a specific value (or addition/subtraction of the previous value)
*

/**
* Updates the forum counters with a specific value (or addition/subtraction of the previous value)
*

 * @param int The forum ID
* @param array Array of items being updated (threads, posts, unapprovedthreads, unapprovedposts, deletedposts, deletedthreads) and their value (ex, 1, +1, -1)

 * @param int $fid The forum ID
* @param array $changes Array of items being updated (threads, posts, unapprovedthreads, unapprovedposts, deletedposts, deletedthreads) and their value (ex, 1, +1, -1)

 */
function update_forum_counters($fid, $changes=array())
{

 */
function update_forum_counters($fid, $changes=array())
{

Zeile 2449Zeile 2461
	$forum = $db->fetch_array($query);

foreach($counters as $counter)

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

foreach($counters as $counter)

	{

	{

		if(array_key_exists($counter, $changes))
{
if(substr($changes[$counter], 0, 2) == "+-")

		if(array_key_exists($counter, $changes))
{
if(substr($changes[$counter], 0, 2) == "+-")

Zeile 2491Zeile 2503
		if($threads_diff > -1)
{
$new_stats['numthreads'] = "+{$threads_diff}";

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

		}

		}

		else
{
$new_stats['numthreads'] = "{$threads_diff}";

		else
{
$new_stats['numthreads'] = "{$threads_diff}";

Zeile 2501Zeile 2513
	if(array_key_exists('unapprovedthreads', $update_query))
{
$unapprovedthreads_diff = $update_query['unapprovedthreads'] - $forum['unapprovedthreads'];

	if(array_key_exists('unapprovedthreads', $update_query))
{
$unapprovedthreads_diff = $update_query['unapprovedthreads'] - $forum['unapprovedthreads'];

		if($unapprovedthreads_diff > -1)

		if($unapprovedthreads_diff > -1)

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

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

Zeile 2521Zeile 2533
		else
{
$new_stats['numposts'] = "{$posts_diff}";

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

		}

		}

	}

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

	}

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

		{

		{

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

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

		}
else
{

		}
else
{

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

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

Zeile 2572Zeile 2584
/**
* Update the last post information for a specific forum
*

/**
* Update the last post information for a specific forum
*

 * @param int The forum ID

 * @param int $fid The forum ID

 */
function update_forum_lastpost($fid)
{

 */
function update_forum_lastpost($fid)
{

Zeile 2585Zeile 2597
		WHERE fid='{$fid}' AND visible='1' AND closed NOT LIKE 'moved|%'
ORDER BY lastpost DESC
LIMIT 0, 1

		WHERE fid='{$fid}' AND visible='1' AND closed NOT LIKE 'moved|%'
ORDER BY lastpost DESC
LIMIT 0, 1

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


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


	$updated_forum = array(
"lastpost" => (int)$lastpost['lastpost'],
"lastposter" => $db->escape_string($lastpost['lastposter']),

	$updated_forum = array(
"lastpost" => (int)$lastpost['lastpost'],
"lastposter" => $db->escape_string($lastpost['lastposter']),

Zeile 2595Zeile 2607
		"lastposttid" => (int)$lastpost['tid'],
"lastpostsubject" => $db->escape_string($lastpost['subject'])
);

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





	$db->update_query("forums", $updated_forum, "fid='{$fid}'");
}

/**
* Updates the thread counters with a specific value (or addition/subtraction of the previous value)
*

	$db->update_query("forums", $updated_forum, "fid='{$fid}'");
}

/**
* Updates the thread counters with a specific value (or addition/subtraction of the previous value)
*

 * @param int The thread ID
* @param array Array of items being updated (replies, unapprovedposts, deletedposts, attachmentcount) and their value (ex, 1, +1, -1)

 * @param int $tid The thread ID
* @param array $changes Array of items being updated (replies, unapprovedposts, deletedposts, attachmentcount) and their value (ex, 1, +1, -1)

 */
function update_thread_counters($tid, $changes=array())

 */
function update_thread_counters($tid, $changes=array())

{
global $db;

{
global $db;


$update_query = array();
$tid = (int)$tid;


$update_query = array();
$tid = (int)$tid;





	$counters = array('replies', 'unapprovedposts', 'attachmentcount', 'deletedposts', 'attachmentcount');

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

	$counters = array('replies', 'unapprovedposts', 'attachmentcount', 'deletedposts', 'attachmentcount');

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

	foreach($counters as $counter)
{
if(array_key_exists($counter, $changes))

Zeile 2637Zeile 2649
			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)
{
$update_query[$counter] = 0;
}
}

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

	}

$db->free_result($query);

	}

$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 2659Zeile 2671
/**
* Update the first post and lastpost data for a specific thread
*

/**
* Update the first post and lastpost data for a specific thread
*

 * @param int The thread ID

 * @param int $tid The thread ID

 */
function update_thread_data($tid)
{

 */
function update_thread_data($tid)
{

Zeile 2669Zeile 2681

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

	{
return false;
}

$query = $db->query("

	{
return;
}

$query = $db->query("

		SELECT u.uid, u.username, p.username AS postusername, p.dateline
FROM ".TABLE_PREFIX."posts p
LEFT JOIN ".TABLE_PREFIX."users u ON (u.uid=p.uid)

		SELECT u.uid, u.username, p.username AS postusername, p.dateline
FROM ".TABLE_PREFIX."posts p
LEFT JOIN ".TABLE_PREFIX."users u ON (u.uid=p.uid)

Zeile 2732Zeile 2744
/**
* Updates the user counters with a specific value (or addition/subtraction of the previous value)
*

/**
* Updates the user counters with a specific value (or addition/subtraction of the previous value)
*

 * @param int The user ID
* @param array Array of items being updated (postnum, threadnum) and their value (ex, 1, +1, -1)

 * @param int $uid The user ID
* @param array $changes Array of items being updated (postnum, threadnum) and their value (ex, 1, +1, -1)

 */
function update_user_counters($uid, $changes=array())
{

 */
function update_user_counters($uid, $changes=array())
{

Zeile 2789Zeile 2801
/**
* Deletes a thread from the database
*

/**
* Deletes a thread from the database
*

 * @param int The thread ID


 * @param int $tid The thread ID
* @return bool

 */
function delete_thread($tid)
{

 */
function delete_thread($tid)
{

Zeile 2807Zeile 2820
/**
* Deletes a post from the database
*

/**
* Deletes a post from the database
*

 * @param int The thread ID


 * @param int $pid The thread ID
* @return bool

 */
function delete_post($pid)
{

 */
function delete_post($pid)
{

Zeile 2825Zeile 2839
/**
* Builds a forum jump menu
*

/**
* Builds a forum jump menu
*

 * @param int The parent forum to start with
* @param int The selected item ID
* @param int If we need to add select boxes to this cal or not
* @param int The current depth of forums we're at
* @param int Whether or not to show extra items such as User CP, Forum home
* @param boolean Ignore the showinjump setting and show all forums (for moderation pages)
* @param unknown_type deprecated
* @param string The name of the forum jump

 * @param int $pid The parent forum to start with
* @param int $selitem The selected item ID
* @param int $addselect If we need to add select boxes to this cal or not
* @param string $depth The current depth of forums we're at
* @param int $showextras Whether or not to show extra items such as User CP, Forum home
* @param boolean $showall Ignore the showinjump setting and show all forums (for moderation pages)
* @param mixed $permissions deprecated
* @param string $name The name of the forum jump

 * @return string Forum jump items
*/

 * @return string Forum jump items
*/

function build_forum_jump($pid="0", $selitem="", $addselect="1", $depth="", $showextras="1", $showall=false, $permissions="", $name="fid")

function build_forum_jump($pid=0, $selitem=0, $addselect=1, $depth="", $showextras=1, $showall=false, $permissions="", $name="fid")

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


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


Zeile 2853Zeile 2867
			if($forum['active'] != 0)
{
$jumpfcache[$forum['pid']][$forum['disporder']][$forum['fid']] = $forum;

			if($forum['active'] != 0)
{
$jumpfcache[$forum['pid']][$forum['disporder']][$forum['fid']] = $forum;

			}
}
}


			}
}
}


	if(!is_array($permissioncache))
{
$permissioncache = forum_permissions();

	if(!is_array($permissioncache))
{
$permissioncache = forum_permissions();

Zeile 2865Zeile 2879
	if(isset($jumpfcache[$pid]) && is_array($jumpfcache[$pid]))
{
foreach($jumpfcache[$pid] as $main)

	if(isset($jumpfcache[$pid]) && is_array($jumpfcache[$pid]))
{
foreach($jumpfcache[$pid] as $main)

		{

		{

			foreach($main as $forum)
{
$perms = $permissioncache[$forum['fid']];

			foreach($main as $forum)
{
$perms = $permissioncache[$forum['fid']];





				if($forum['fid'] != "0" && ($perms['canview'] != 0 || $mybb->settings['hideprivateforums'] == 0) && $forum['linkto'] == '' && ($forum['showinjump'] != 0 || $showall == true))
{
$optionselected = "";

if($selitem == $forum['fid'])

				if($forum['fid'] != "0" && ($perms['canview'] != 0 || $mybb->settings['hideprivateforums'] == 0) && $forum['linkto'] == '' && ($forum['showinjump'] != 0 || $showall == true))
{
$optionselected = "";

if($selitem == $forum['fid'])

					{

					{

						$optionselected = 'selected="selected"';
}


						$optionselected = 'selected="selected"';
}


Zeile 2896Zeile 2910
	if($addselect)
{
if($showextras == 0)

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

		{

		{

			$template = "special";
}
else

			$template = "special";
}
else

Zeile 2906Zeile 2920
			if(strpos(FORUM_URL, '.html') !== false)
{
$forum_link = "'".str_replace('{fid}', "'+option+'", FORUM_URL)."'";

			if(strpos(FORUM_URL, '.html') !== false)
{
$forum_link = "'".str_replace('{fid}', "'+option+'", FORUM_URL)."'";

			}

			}

			else
{
$forum_link = "'".str_replace('{fid}', "'+option", FORUM_URL);
}
}

			else
{
$forum_link = "'".str_replace('{fid}', "'+option", FORUM_URL);
}
}





		eval("\$forumjump = \"".$templates->get("forumjump_".$template)."\";");
}

return $forumjump;

		eval("\$forumjump = \"".$templates->get("forumjump_".$template)."\";");
}

return $forumjump;

}

}


/**
* Returns the extension of a file.
*


/**
* Returns the extension of a file.
*

 * @param string The filename.

 * @param string $file The filename.

 * @return string The extension of the file.
*/
function get_extension($file)

 * @return string The extension of the file.
*/
function get_extension($file)

Zeile 2933Zeile 2947
/**
* Generates a random string.
*

/**
* Generates a random string.
*

 * @param int The length of the string to generate.


 * @param int $length The length of the string to generate.
* @param bool $complex Whether to return complex string. Defaults to false

 * @return string The random string.
*/

 * @return string The random string.
*/

function random_str($length="8")

function random_str($length=8, $complex=false)

{

{

	$set = array("a","A","b","B","c","C","d","D","e","E","f","F","g","G","h","H","i","I","j","J","k","K","l","L","m","M","n","N","o","O","p","P","q","Q","r","R","s","S","t","T","u","U","v","V","w","W","x","X","y","Y","z","Z","1","2","3","4","5","6","7","8","9");
$str = '';

	$set = array_merge(range(0, 9), range('A', 'Z'), range('a', 'z'));
$str = array();





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


	// Complex strings have always at least 3 characters, even if $length < 3
if($complex == true)

	{

	{

		$ch = my_rand(0, count($set)-1);
$str .= $set[$ch];














		// At least one number
$str[] = $set[my_rand(0, 9)];

// At least one big letter
$str[] = $set[my_rand(10, 35)];

// At least one small letter
$str[] = $set[my_rand(36, 61)];

$length -= 3;
}

for($i = 0; $i < $length; ++$i)
{
$str[] = $set[my_rand(0, 61)];

	}

	}

 
	
// Make sure they're in random order and convert them to a string
shuffle($str);





	return $str;

	return implode($str);

}

/**
* Formats a username based on their display group
*

}

/**
* Formats a username based on their display group
*

 * @param string The username
* @param int The usergroup for the user (if not specified, will be fetched)
* @param int The display group for the user (if not specified, will be fetched)

 * @param string $username The username
* @param int $usergroup The usergroup for the user
* @param int $displaygroup The display group for the user

 * @return string The formatted username
*/

 * @return string The formatted username
*/

function format_name($username, $usergroup, $displaygroup="")

function format_name($username, $usergroup, $displaygroup=0)

{
global $groupscache, $cache;


{
global $groupscache, $cache;


Zeile 2989Zeile 3021
/**
* Formats an avatar to a certain dimension
*

/**
* Formats an avatar to a certain dimension
*

 * @param string The avatar file name
* @param string Dimensions of the avatar, width x height (e.g. 44|44)
* @param string 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

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

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

Zeile 3180Zeile 3212
			// Smilies
$emoticon = "";
$emoticons_enabled = "false";

			// Smilies
$emoticon = "";
$emoticons_enabled = "false";

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

			if($smilies)

			{

			{

				$emoticon = ",emoticon";




				if($mybb->settings['smilieinserter'] && $mybb->settings['smilieinsertercols'] && $mybb->settings['smilieinsertertot'])
{
$emoticon = ",emoticon";
}

				$emoticons_enabled = "true";

if(!$smiliecache)

				$emoticons_enabled = "true";

if(!$smiliecache)

Zeile 3193Zeile 3228
					}
foreach($smilie_cache as $smilie)
{

					}
foreach($smilie_cache as $smilie)
{

						if($smilie['showclickable'] != 0)
{
$smilie['image'] = str_replace("{theme}", $theme['imgdir'], $smilie['image']);
$smiliecache[$smilie['sid']] = $smilie;
}

						$smilie['image'] = str_replace("{theme}", $theme['imgdir'], $smilie['image']);
$smiliecache[$smilie['sid']] = $smilie;




					}
}


					}
}


Zeile 3221Zeile 3253
						$find = str_replace(array('\\', '"'), array('\\\\', '\"'), htmlspecialchars_uni($smilie['find']));
$image = htmlspecialchars_uni($mybb->get_asset_url($smilie['image']));
$image = str_replace(array('\\', '"'), array('\\\\', '\"'), $image);

						$find = str_replace(array('\\', '"'), array('\\\\', '\"'), htmlspecialchars_uni($smilie['find']));
$image = htmlspecialchars_uni($mybb->get_asset_url($smilie['image']));
$image = str_replace(array('\\', '"'), array('\\\\', '\"'), $image);


if($i < $mybb->settings['smilieinsertertot'])
{






if(!$mybb->settings['smilieinserter'] || !$mybb->settings['smilieinsertercols'] || !$mybb->settings['smilieinsertertot'] || !$smilie['showclickable'])
{
$hiddensmilies .= '"'.$find.'": "'.$image.'",';
}
elseif($i < $mybb->settings['smilieinsertertot'])
{

							$dropdownsmilies .= '"'.$find.'": "'.$image.'",';

							$dropdownsmilies .= '"'.$find.'": "'.$image.'",';

						}


							++$i;
}

						else
{
$moresmilies .= '"'.$find.'": "'.$image.'",';

						else
{
$moresmilies .= '"'.$find.'": "'.$image.'",';

						}

						}


for($j = 1; $j < $finds_count; ++$j)
{
$find = str_replace(array('\\', '"'), array('\\\\', '\"'), htmlspecialchars_uni($finds[$j]));
$hiddensmilies .= '"'.$find.'": "'.$image.'",';
}


for($j = 1; $j < $finds_count; ++$j)
{
$find = str_replace(array('\\', '"'), array('\\\\', '\"'), htmlspecialchars_uni($finds[$j]));
$hiddensmilies .= '"'.$find.'": "'.$image.'",';
}

						++$i;

 
					}
}

					}
}

			}

$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|";
$basic2 = "horizontalrule,";


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

			}


			}


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

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

			{

			{

				$align = "left,center,right,justify|";

				$align = "left,center,right,justify|";

			}


			}


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

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

			}


			}


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

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

			{

			{

				$size = "size,";
}

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

				$size = "size,";
}

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

			}

			}


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


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

Zeile 3285Zeile 3321
			}

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

			}

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

			{

			{

				$list = "bulletlist,orderedlist|";
}


				$list = "bulletlist,orderedlist|";
}


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

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

			{

			{

				if($smilie['showclickable'] != 0)
{
$smilie['image'] = str_replace("{theme}", $theme['imgdir'], $smilie['image']);

				if($smilie['showclickable'] != 0)
{
$smilie['image'] = str_replace("{theme}", $theme['imgdir'], $smilie['image']);

Zeile 3419Zeile 3455
/**
* Builds thread prefixes and returns a selected prefix (or all)
*

/**
* Builds thread prefixes and returns a selected prefix (or all)
*

 *  @param int The prefix ID (0 to return all)

 *  @param int $pid The prefix ID (0 to return all)

 *  @return array The thread prefix's values (or all thread prefixes)
*/
function build_prefixes($pid=0)

 *  @return array The thread prefix's values (or all thread prefixes)
*/
function build_prefixes($pid=0)

Zeile 3471Zeile 3507
/**
* Build the thread prefix selection menu
*

/**
* Build the thread prefix selection menu
*

 *  @param mixed The forum ID (integer ID or string all)
* @param mixed The selected prefix ID (integer ID or string any)
* @param int Allow multiple prefix selection

 *  @param int|string $fid The forum ID (integer ID or string all)
* @param int|string $selected_pid The selected prefix ID (integer ID or string any)
* @param int $multiple Allow multiple prefix selection

 *  @return string The thread prefix selection menu
*/
function build_prefix_select($fid, $selected_pid=0, $multiple=0)

 *  @return string The thread prefix selection menu
*/
function build_prefix_select($fid, $selected_pid=0, $multiple=0)

{

{

	global $cache, $db, $lang, $mybb, $templates;

if($fid != 'all')

	global $cache, $db, $lang, $mybb, $templates;

if($fid != 'all')

Zeile 3495Zeile 3531
	if($mybb->user['additionalgroups'])
{
$exp = explode(",", $mybb->user['additionalgroups']);

	if($mybb->user['additionalgroups'])
{
$exp = explode(",", $mybb->user['additionalgroups']);





		foreach($exp as $group)
{
$groups[] = $group;

		foreach($exp as $group)
{
$groups[] = $group;

Zeile 3549Zeile 3585
	{
$any_selected = "";
if($selected_pid == 'any')

	{
$any_selected = "";
if($selected_pid == 'any')

		{

		{

			$any_selected = " selected=\"selected\"";
}
}

			$any_selected = " selected=\"selected\"";
}
}

Zeile 3566Zeile 3602
		if($prefix['pid'] == $selected_pid)
{
$selected = " selected=\"selected\"";

		if($prefix['pid'] == $selected_pid)
{
$selected = " selected=\"selected\"";

		}


		}


		$prefix['prefix'] = htmlspecialchars_uni($prefix['prefix']);
eval("\$prefixselect_prefix .= \"".$templates->get("post_prefixselect_prefix")."\";");

		$prefix['prefix'] = htmlspecialchars_uni($prefix['prefix']);
eval("\$prefixselect_prefix .= \"".$templates->get("post_prefixselect_prefix")."\";");

	}

	}


if($multiple != 0)
{
eval("\$prefixselect = \"".$templates->get("post_prefixselect_multiple")."\";");


if($multiple != 0)
{
eval("\$prefixselect = \"".$templates->get("post_prefixselect_multiple")."\";");

	}

	}

	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
*

/**
* Build the thread prefix selection menu for a forum
*

 *  @param mixed The forum ID (integer ID)
* @param mixed The selected prefix ID (integer ID)

 *  @param int $fid The forum ID (integer ID)
* @param int $selected_pid The selected prefix ID (integer ID)

 */
function build_forum_prefix_select($fid, $selected_pid=0)
{

 */
function build_forum_prefix_select($fid, $selected_pid=0)
{

Zeile 3621Zeile 3657
		{
// This prefix is for anybody to use...
$prefixes[$prefix['pid']] = $prefix;

		{
// This prefix is for anybody to use...
$prefixes[$prefix['pid']] = $prefix;

		}
}

		}
}


if(empty($prefixes))
{


if(empty($prefixes))
{

Zeile 3649Zeile 3685
	{
$selected = '';
if($prefix['pid'] == $selected_pid)

	{
$selected = '';
if($prefix['pid'] == $selected_pid)

		{

		{

			$selected = ' selected="selected"';
}


			$selected = ' selected="selected"';
}


Zeile 3664Zeile 3700
/**
* Gzip encodes text to a specified level
*

/**
* Gzip encodes text to a specified level
*

 * @param string The string to encode
* @param int The level (1-9) to encode at

 * @param string $contents The string to encode
* @param int $level The level (1-9) to encode at

 * @return string The encoded string
*/
function gzip_encode($contents, $level=1)

 * @return string The encoded string
*/
function gzip_encode($contents, $level=1)

Zeile 3677Zeile 3713
		if(isset($_SERVER['HTTP_ACCEPT_ENCODING']))
{
$httpaccept_encoding = $_SERVER['HTTP_ACCEPT_ENCODING'];

		if(isset($_SERVER['HTTP_ACCEPT_ENCODING']))
{
$httpaccept_encoding = $_SERVER['HTTP_ACCEPT_ENCODING'];

		}


		}


		if(my_strpos(" ".$httpaccept_encoding, "x-gzip"))
{
$encoding = "x-gzip";

		if(my_strpos(" ".$httpaccept_encoding, "x-gzip"))
{
$encoding = "x-gzip";

Zeile 3696Zeile 3732
			if(function_exists("gzencode"))
{
$contents = gzencode($contents, $level);

			if(function_exists("gzencode"))
{
$contents = gzencode($contents, $level);

			}

			}

			else
{
$size = strlen($contents);

			else
{
$size = strlen($contents);

Zeile 3716Zeile 3752
/**
* Log the actions of a moderator.
*

/**
* Log the actions of a moderator.
*

 * @param array The data of the moderator's action.
* @param string The message to enter for the action the moderator performed.

 * @param array $data The data of the moderator's action.
* @param string $action The message to enter for the action the moderator performed.

 */
function log_moderator_action($data, $action="")
{

 */
function log_moderator_action($data, $action="")
{

Zeile 3725Zeile 3761

$fid = 0;
if(isset($data['fid']))


$fid = 0;
if(isset($data['fid']))

	{

	{

		$fid = (int)$data['fid'];
unset($data['fid']);
}

		$fid = (int)$data['fid'];
unset($data['fid']);
}

Zeile 3742Zeile 3778
	{
$pid = (int)$data['pid'];
unset($data['pid']);

	{
$pid = (int)$data['pid'];
unset($data['pid']);

	}


	}


	// Any remaining extra data - we my_serialize and insert in to its own column
if(is_array($data))
{

	// Any remaining extra data - we my_serialize and insert in to its own column
if(is_array($data))
{

Zeile 3766Zeile 3802
/**
* Get the formatted reputation for a user.
*

/**
* Get the formatted reputation for a user.
*

 * @param int The reputation value
* @param int The user ID (if not specified, the generated reputation will not be a link)

 * @param int $reputation The reputation value
* @param int $uid The user ID (if not specified, the generated reputation will not be a link)

 * @return string The formatted repuation
*/
function get_reputation($reputation, $uid=0)

 * @return string The formatted repuation
*/
function get_reputation($reputation, $uid=0)

{

{

	global $theme, $templates;

$display_reputation = $reputation_class = '';

	global $theme, $templates;

$display_reputation = $reputation_class = '';

Zeile 3805Zeile 3841
/**
* Fetch a color coded version of a warning level (based on it's percentage)
*

/**
* Fetch a color coded version of a warning level (based on it's percentage)
*

 * @param int The warning level (percentage of 100)

 * @param int $level The warning level (percentage of 100)

 * @return string Formatted warning level
*/
function get_colored_warning_level($level)

 * @return string Formatted warning level
*/
function get_colored_warning_level($level)

Zeile 3893Zeile 3929
/**
* Fetch the friendly size (GB, MB, KB, B) for a specified file size.
*

/**
* Fetch the friendly size (GB, MB, KB, B) for a specified file size.
*

 * @param int The size in bytes

 * @param int $size The size in bytes

 * @return string The friendly file size
*/
function get_friendly_size($size)

 * @return string The friendly file size
*/
function get_friendly_size($size)

Zeile 3960Zeile 3996
/**
* Format a decimal number in to microseconds, milliseconds, or seconds.
*

/**
* Format a decimal number in to microseconds, milliseconds, or seconds.
*

 * @param int The time in microseconds

 * @param int $time The time in microseconds

 * @return string The friendly time duration
*/
function format_time_duration($time)

 * @return string The friendly time duration
*/
function format_time_duration($time)

Zeile 3991Zeile 4027
/**
* Get the attachment icon for a specific file extension
*

/**
* Get the attachment icon for a specific file extension
*

 * @param string The file extension

 * @param string $ext The file extension

 * @return string The attachment icon
*/
function get_attachment_icon($ext)

 * @return string The attachment icon
*/
function get_attachment_icon($ext)

Zeile 4065Zeile 4101
/**
* Get a list of the unviewable forums for the current user
*

/**
* Get a list of the unviewable forums for the current user
*

 * @param boolean Set to true to only fetch those forums for which users can actually read a thread in.

 * @param boolean $only_readable_threads Set to true to only fetch those forums for which users can actually read a thread in.

 * @return string Comma separated values list of the forum IDs which the user cannot view
*/
function get_unviewable_forums($only_readable_threads=false)

 * @return string Comma separated values list of the forum IDs which the user cannot view
*/
function get_unviewable_forums($only_readable_threads=false)

Zeile 4132Zeile 4168
/**
* Fixes mktime for dates earlier than 1970
*

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

 * @param string The date format to use
* @param int The year of the date

 * @param string $format The date format to use
* @param int $year The year of the date

 * @return string The correct date format
*/
function fix_mktime($format, $year)

 * @return string The correct date format
*/
function fix_mktime($format, $year)

Zeile 4149Zeile 4185
/**
* Build the breadcrumb navigation trail from the specified items
*

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

 * @return The formatted breadcrumb navigation trail

 * @return string The formatted breadcrumb navigation trail

 */
function build_breadcrumb()
{

 */
function build_breadcrumb()
{

Zeile 4221Zeile 4257
/**
* Add a breadcrumb menu item to the list.
*

/**
* Add a breadcrumb menu item to the list.
*

 * @param string The name of the item to add
* @param string The URL of the item to add

 * @param string $name The name of the item to add
* @param string $url The URL of the item to add

 */
function add_breadcrumb($name, $url="")
{

 */
function add_breadcrumb($name, $url="")
{

Zeile 4236Zeile 4272
/**
* Build the forum breadcrumb nagiation (the navigation to a specific forum including all parent forums)
*

/**
* Build the forum breadcrumb nagiation (the navigation to a specific forum including all parent forums)
*

 * @param int The forum ID to build the navigation for
* @param array The multipage drop down array of information


 * @param int $fid The forum ID to build the navigation for
* @param array $multipage The multipage drop down array of information
* @return int Returns 1 in every case. Kept for compatibility

 */
function build_forum_breadcrumb($fid, $multipage=array())
{

 */
function build_forum_breadcrumb($fid, $multipage=array())
{

Zeile 4322Zeile 4359
/**
* Builds a URL to an archive mode page
*

/**
* Builds a URL to an archive mode page
*

 * @param string The type of page (thread|announcement|forum)
* @param int The ID of the item

 * @param string $type The type of page (thread|announcement|forum)
* @param int $id The ID of the item

 * @return string The URL
*/

 * @return string The URL
*/

function build_archive_link($type="", $id="")

function build_archive_link($type="", $id=0)

{
global $mybb;


{
global $mybb;


Zeile 4524Zeile 4561
/**
* Mark specific reported posts of a certain type as dealt with
*

/**
* Mark specific reported posts of a certain type as dealt with
*

 * @param mixed An array or int of the ID numbers you're marking as dealt with
* @param string The type of item the above IDs are for - post, posts, thread, threads, forum, all

 * @param array|int $id An array or int of the ID numbers you're marking as dealt with
* @param string $type The type of item the above IDs are for - post, posts, thread, threads, forum, all

 */
function mark_reports($id, $type="post")
{

 */
function mark_reports($id, $type="post")
{

Zeile 4571Zeile 4608
/**
* Fetch a friendly x days, y months etc date stamp from a timestamp
*

/**
* Fetch a friendly x days, y months etc date stamp from a timestamp
*

 * @param int The timestamp
* @param array Array of options

 * @param int $stamp The timestamp
* @param array $options Array of options

 * @return string The friendly formatted timestamp
*/
function nice_time($stamp, $options=array())

 * @return string The friendly formatted timestamp
*/
function nice_time($stamp, $options=array())

Zeile 4716Zeile 4753
/**
* Select an alternating row colour based on the previous call to this function
*

/**
* Select an alternating row colour based on the previous call to this function
*

 * @param int 1 to reset the row to trow1.

 * @param int $reset 1 to reset the row to trow1.

 * @return string trow1 or trow2 depending on the previous call
*/
function alt_trow($reset=0)

 * @return string trow1 or trow2 depending on the previous call
*/
function alt_trow($reset=0)

Zeile 4740Zeile 4777
/**
* Add a user to a specific additional user group.
*

/**
* Add a user to a specific additional user group.
*

 * @param int The user ID
* @param int The user group ID to join


 * @param int $uid The user ID
* @param int $joingroup The user group ID to join
* @return bool

 */
function join_usergroup($uid, $joingroup)
{

 */
function join_usergroup($uid, $joingroup)
{

Zeile 4792Zeile 4830
/**
* Remove a user from a specific additional user group
*

/**
* Remove a user from a specific additional user group
*

 * @param int The user ID
* @param int The user group ID

 * @param int $uid The user ID
* @param int $leavegroup The user group ID

 */
function leave_usergroup($uid, $leavegroup)
{

 */
function leave_usergroup($uid, $leavegroup)
{

Zeile 4845Zeile 4883
/**
* Get the current location taking in to account different web serves and systems
*

/**
* Get the current location taking in to account different web serves and systems
*

 * @param boolean True to return as "hidden" fields
* @param array Array of fields to ignore if first argument is true
* @param boolean True to skip all inputs and return only the file path part of the URL

 * @param boolean $fields True to return as "hidden" fields
* @param array $ignore Array of fields to ignore if first argument is true
* @param boolean $quick True to skip all inputs and return only the file path part of the URL

 * @return string The current URL being accessed
*/
function get_current_location($fields=false, $ignore=array(), $quick=false)

 * @return string The current URL being accessed
*/
function get_current_location($fields=false, $ignore=array(), $quick=false)

Zeile 4952Zeile 4990
/**
* Build a theme selection menu
*

/**
* Build a theme selection menu
*

 * @param string The name of the menu
* @param int The ID of the selected theme
* @param int The ID of the parent theme to select from
* @param int The current selection depth
* @param boolean Whether or not to override usergroup permissions (true to override)
* @param boolean Whether or not theme select is in the footer (true if it is)
* @param boolean Whether or not to override output based on theme count (true to override)

 * @param string $name The name of the menu
* @param int $selected The ID of the selected theme
* @param int $tid The ID of the parent theme to select from
* @param string $depth The current selection depth
* @param boolean $usergroup_override Whether or not to override usergroup permissions (true to override)
* @param boolean $footer Whether or not theme select is in the footer (true if it is)
* @param boolean $count_override Whether or not to override output based on theme count (true to override)

 * @return string The theme selection list
*/

 * @return string The theme selection list
*/

function build_theme_select($name, $selected="", $tid=0, $depth="", $usergroup_override=false, $footer=false, $count_override=false)

function build_theme_select($name, $selected=-1, $tid=0, $depth="", $usergroup_override=false, $footer=false, $count_override=false)

{
global $db, $themeselect, $tcache, $lang, $mybb, $limit, $templates, $num_themes, $themeselect_option;


{
global $db, $themeselect, $tcache, $lang, $mybb, $limit, $templates, $num_themes, $themeselect_option;


Zeile 4979Zeile 5017

if(!is_array($tcache))
{


if(!is_array($tcache))
{

		$query = $db->simple_select("themes", "name, pid, tid, allowedgroups", "pid != '0'", array('order_by' => 'pid, name'));

		$query = $db->simple_select('themes', 'tid, name, pid, allowedgroups', "pid!='0'");


while($theme = $db->fetch_array($query))
{


while($theme = $db->fetch_array($query))
{

Zeile 4999Zeile 5037
		foreach($tcache[$tid] as $theme)
{
$sel = "";

		foreach($tcache[$tid] as $theme)
{
$sel = "";

			// Make theme allowed groups into array
$is_allowed = false;
if($theme['allowedgroups'] != "all")
{
$allowed_groups = explode(",", $theme['allowedgroups']);
// See if groups user is in is allowed
foreach($allowed_groups as $agid)
{
if(in_array($agid, $in_groups))
{
$is_allowed = true;
break;
}
}
}


 
			// Show theme if allowed, or if override is on

			// Show theme if allowed, or if override is on

			if($is_allowed || $theme['allowedgroups'] == "all" || $usergroup_override == true)

			if(is_member($theme['allowedgroups']) || $theme['allowedgroups'] == "all" || $usergroup_override == true)

			{
if($theme['tid'] == $selected)

			{
if($theme['tid'] == $selected)

				{

				{

					$sel = " selected=\"selected\"";
}


					$sel = " selected=\"selected\"";
}


Zeile 5029Zeile 5051
					eval("\$themeselect_option .= \"".$templates->get("usercp_themeselector_option")."\";");
++$num_themes;
$depthit = $depth."--";

					eval("\$themeselect_option .= \"".$templates->get("usercp_themeselector_option")."\";");
++$num_themes;
$depthit = $depth."--";

				}

				}


if(array_key_exists($theme['tid'], $tcache))
{


if(array_key_exists($theme['tid'], $tcache))
{

					build_theme_select($name, $selected, $theme['tid'], $depthit, $usergroup_override, $footer);

					build_theme_select($name, $selected, $theme['tid'], $depthit, $usergroup_override, $footer, $count_override);

				}
}

				}
}

		}

		}

	}

	}





	if($tid == 1 && ($num_themes > 1 || $count_override == true))
{
if($footer == true)
{
eval("\$themeselect = \"".$templates->get("footer_themeselector")."\";");

	if($tid == 1 && ($num_themes > 1 || $count_override == true))
{
if($footer == true)
{
eval("\$themeselect = \"".$templates->get("footer_themeselector")."\";");

		}

		}

		else
{
eval("\$themeselect = \"".$templates->get("usercp_themeselector")."\";");
}

return $themeselect;

		else
{
eval("\$themeselect = \"".$templates->get("usercp_themeselector")."\";");
}

return $themeselect;

	}

	}

	else
{
return false;
}

	else
{
return false;
}

 
}

/**
* Get the theme data of a theme id.
*
* @param int $tid The theme id of the theme.
* @return boolean|array False if no valid theme, Array with the theme data otherwise
*/
function get_theme($tid)
{
global $tcache, $db;

if(!is_array($tcache))
{
$query = $db->simple_select('themes', 'tid, name, pid, allowedgroups', "pid!='0'");

while($theme = $db->fetch_array($query))
{
$tcache[$theme['pid']][$theme['tid']] = $theme;
}
}

$s_theme = false;

foreach($tcache as $themes)
{
foreach($themes as $theme)
{
if($tid == $theme['tid'])
{
$s_theme = $theme;
break 2;
}
}
}

return $s_theme;

}

/**
* Custom function for htmlspecialchars which takes in to account unicode
*

}

/**
* Custom function for htmlspecialchars which takes in to account unicode
*

 * @param string The string to format

 * @param string $message The string to format

 * @return string The string with htmlspecialchars applied
*/
function htmlspecialchars_uni($message)

 * @return string The string with htmlspecialchars applied
*/
function htmlspecialchars_uni($message)

Zeile 5071Zeile 5130
	$message = str_replace(">", "&gt;", $message);
$message = str_replace("\"", "&quot;", $message);
return $message;

	$message = str_replace(">", "&gt;", $message);
$message = str_replace("\"", "&quot;", $message);
return $message;

}

/**

}

/**

 * Custom function for formatting numbers.
*

 * Custom function for formatting numbers.
*

 * @param int The number to format.

 * @param int $number The number to format.

 * @return int The formatted number.
*/
function my_number_format($number)
{
global $mybb;

 * @return int The formatted number.
*/
function my_number_format($number)
{
global $mybb;





	if($number == "-")
{
return $number;

	if($number == "-")
{
return $number;

Zeile 5095Zeile 5154
	else
{
$parts = explode('.', $number);

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





		if(isset($parts[1]))
{
$decimals = my_strlen($parts[1]);

		if(isset($parts[1]))
{
$decimals = my_strlen($parts[1]);

Zeile 5112Zeile 5171
/**
* Converts a string of text to or from UTF-8.
*

/**
* Converts a string of text to or from UTF-8.
*

 * @param string The string of text to convert
* @param boolean Whether or not the string is being converted to or from UTF-8 (true if converting to)

 * @param string $str The string of text to convert
* @param boolean $to Whether or not the string is being converted to or from UTF-8 (true if converting to)

 * @return string The converted string
*/
function convert_through_utf8($str, $to=true)

 * @return string The converted string
*/
function convert_through_utf8($str, $to=true)

Zeile 5183Zeile 5242

/**
* DEPRECATED! Please use other alternatives.


/**
* DEPRECATED! Please use other alternatives.

 
 *
* @deprecated
* @param string $message
*
* @return string

 */
function my_wordwrap($message)
{

 */
function my_wordwrap($message)
{

Zeile 5192Zeile 5256
/**
* Workaround for date limitation in PHP to establish the day of a birthday (Provided by meme)
*

/**
* Workaround for date limitation in PHP to establish the day of a birthday (Provided by meme)
*

 * @param int The month of the birthday
* @param int The day of the birthday
* @param int The year of the bithday

 * @param int $month The month of the birthday
* @param int $day The day of the birthday
* @param int $year The year of the bithday

 * @return int The numeric day of the week for the birthday
*/
function get_weekday($month, $day, $year)

 * @return int The numeric day of the week for the birthday
*/
function get_weekday($month, $day, $year)

Zeile 5230Zeile 5294
/**
* Workaround for date limitation in PHP to establish the day of a birthday (Provided by meme)
*

/**
* Workaround for date limitation in PHP to establish the day of a birthday (Provided by meme)
*

 * @param int The year.

 * @param int $in The year.

 * @return array The number of days in each month of that year
*/
function get_bdays($in)

 * @return array The number of days in each month of that year
*/
function get_bdays($in)

Zeile 5252Zeile 5316
}

/**

}

/**

 
 * DEPRECATED! Please use mktime()!

 * Formats a birthday appropriately
*

 * Formats a birthday appropriately
*

 * @param string The PHP date format string
* @param int The month of the birthday
* @param int The day of the birthday
* @param int The year of the birthday
* @param int The weekday of the birthday


 * @deprecated
* @param string $display The PHP date format string
* @param int $bm The month of the birthday
* @param int $bd The day of the birthday
* @param int $by The year of the birthday
* @param int $wd The weekday of the birthday

 * @return string The formatted birthday
*/
function format_bdays($display, $bm, $bd, $by, $wd)

 * @return string The formatted birthday
*/
function format_bdays($display, $bm, $bd, $by, $wd)

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

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

 
		'n',

		'd',
'D',
'y',

		'd',
'D',
'y',

Zeile 5307Zeile 5374

$html = array(
'&#109;',


$html = array(
'&#109;',

 
		'&#110;',

		'&#99;',
'&#68;',
'&#121;',

		'&#99;',
'&#68;',
'&#121;',

Zeile 5323Zeile 5391

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


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

 
		$bm,

		sprintf('%02s', $bd),
($wd == 2 ? my_substr($bdays[$wd], 0, 4) : ($wd == 4 ? my_substr($bdays[$wd], 0, 5) : my_substr($bdays[$wd], 0, 3))),
my_substr($by, 2),

		sprintf('%02s', $bd),
($wd == 2 ? my_substr($bdays[$wd], 0, 4) : ($wd == 4 ? my_substr($bdays[$wd], 0, 5) : my_substr($bdays[$wd], 0, 3))),
my_substr($by, 2),

Zeile 5348Zeile 5417
/**
* Returns the age of a user with specified birthday.
*

/**
* Returns the age of a user with specified birthday.
*

 * @param string The birthday of a user.
* @return float The age of a user with that birthday.

 * @param string $birthday The birthday of a user.
* @return int The age of a user with that birthday.

 */
function get_age($birthday)
{

 */
function get_age($birthday)
{

Zeile 5373Zeile 5442
/**
* Updates the first posts in a thread.
*

/**
* Updates the first posts in a thread.
*

 * @param int The thread id for which to update the first post id.

 * @param int $tid The thread id for which to update the first post id.

 */
function update_first_post($tid)
{

 */
function update_first_post($tid)
{

Zeile 5407Zeile 5476
/**
* Updates the last posts in a thread.
*

/**
* Updates the last posts in a thread.
*

 * @param int The thread id for which to update the last post id.

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

 */
function update_last_post($tid)
{

 */
function update_last_post($tid)
{

Zeile 5458Zeile 5527
/**
* Checks for the length of a string, mb strings accounted for
*

/**
* Checks for the length of a string, mb strings accounted for
*

 * @param string The string to check the length of.

 * @param string $string The string to check the length of.

 * @return int The length of the string.
*/
function my_strlen($string)

 * @return int The length of the string.
*/
function my_strlen($string)

Zeile 5493Zeile 5562
/**
* Cuts a string at a specified point, mb strings accounted for
*

/**
* Cuts a string at a specified point, mb strings accounted for
*

 * @param string The string to cut.
* @param int Where to cut
* @param int (optional) How much to cut
* @param bool (optional) Properly handle HTML entities?
* @return int The cut part of the string.

 * @param string $string The string to cut.
* @param int $start Where to cut
* @param int $length (optional) How much to cut
* @param bool $handle_entities (optional) Properly handle HTML entities?
* @return string The cut part of the string.

 */

 */

function my_substr($string, $start, $length="", $handle_entities = false)

function my_substr($string, $start, $length=null, $handle_entities = false)

{
if($handle_entities)
{

{
if($handle_entities)
{

Zeile 5507Zeile 5576
	}
if(function_exists("mb_substr"))
{

	}
if(function_exists("mb_substr"))
{

		if($length != "")

		if($length != null)

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

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

Zeile 5518Zeile 5587
	}
else
{

	}
else
{

		if($length != "")

		if($length != null)

		{
$cut_string = substr($string, $start, $length);
}

		{
$cut_string = substr($string, $start, $length);
}

Zeile 5538Zeile 5607
/**
* Lowers the case of a string, mb strings accounted for
*

/**
* Lowers the case of a string, mb strings accounted for
*

 * @param string The string to lower.
* @return int The lowered string.

 * @param string $string The string to lower.
* @return string The lowered string.

 */
function my_strtolower($string)
{

 */
function my_strtolower($string)
{

Zeile 5558Zeile 5627
/**
* 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 String to look in (haystack)
* @param string What to look for (needle)
* @param int (optional) How much to offset
* @return int 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)
{

 */
function my_strpos($haystack, $needle, $offset=0)
{

Zeile 5585Zeile 5654
/**
* Ups the case of a string, mb strings accounted for
*

/**
* Ups the case of a string, mb strings accounted for
*

 * @param string The string to up.
* @return int The uped string.

 * @param string $string The string to up.
* @return string The uped string.

 */
function my_strtoupper($string)
{

 */
function my_strtoupper($string)
{

Zeile 5605Zeile 5674
/**
* Returns any html entities to their original character
*

/**
* Returns any html entities to their original character
*

 * @param string The string to un-htmlentitize.
* @return int The un-htmlentitied' string.

 * @param string $string The string to un-htmlentitize.
* @return string The un-htmlentitied' string.

 */
function unhtmlentities($string)
{

 */
function unhtmlentities($string)
{

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

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

 * @param string The ascii to characterize.
* @return int The characterized ascii.

 * @param int $c The ascii to characterize.
* @return string|bool The characterized ascii. False on failure

 */
function unichr($c)
{

 */
function unichr($c)
{

Zeile 5657Zeile 5726
/**
* Get the event poster.
*

/**
* Get the event poster.
*

 * @param array The event data array.

 * @param array $event The event data array.

 * @return string The link to the event poster.
*/
function get_event_poster($event)

 * @return string The link to the event poster.
*/
function get_event_poster($event)

Zeile 5670Zeile 5739
/**
* Get the event date.
*

/**
* Get the event date.
*

 * @param array The event data array.

 * @param array $event The event data array.

 * @return string The event date.
*/
function get_event_date($event)

 * @return string The event date.
*/
function get_event_date($event)

Zeile 5687Zeile 5756
/**
* Get the profile link.
*

/**
* Get the profile link.
*

 * @param int The user id of the profile.

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

 * @return string The url to the profile.
*/
function get_profile_link($uid=0)

 * @return string The url to the profile.
*/
function get_profile_link($uid=0)

Zeile 5699Zeile 5768
/**
* Get the announcement link.
*

/**
* Get the announcement link.
*

 * @param int The announement id of the announcement.

 * @param int $aid The announement id of the announcement.

 * @return string The url to the announcement.
*/
function get_announcement_link($aid=0)

 * @return string The url to the announcement.
*/
function get_announcement_link($aid=0)

Zeile 5711Zeile 5780
/**
* Build the profile link.
*

/**
* Build the profile link.
*

 * @param string The Username of the profile.
* @param int The user id of the profile.
* @param string The target frame
* @param string Any onclick javascript.

 * @param string $username The Username of the profile.
* @param int $uid The user id of the profile.
* @param string $target The target frame
* @param string $onclick Any onclick javascript.

 * @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="")

Zeile 5751Zeile 5820
/**
* Build the forum link.
*

/**
* Build the forum link.
*

 * @param int The forum id of the forum.
* @param int (Optional) The page number of the forum.

 * @param int $fid The forum id of the forum.
* @param int $page (Optional) The page number of the forum.

 * @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)

Zeile 5773Zeile 5842
/**
* Build the thread link.
*

/**
* Build the thread link.
*

 * @param int The thread id of the thread.
* @param int (Optional) The page number of the thread.
* @param string (Optional) The action we're performing (ex, lastpost, newpost, etc)

 * @param int $tid The thread id of the thread.
* @param int $page (Optional) The page number of the thread.
* @param string $action (Optional) The action we're performing (ex, lastpost, newpost, etc)

 * @return string The url to the thread.
*/
function get_thread_link($tid, $page=0, $action='')

 * @return string The url to the thread.
*/
function get_thread_link($tid, $page=0, $action='')

Zeile 5814Zeile 5883
/**
* Build the post link.
*

/**
* Build the post link.
*

 * @param int The post ID of the post
* @param int The thread id of the post.

 * @param int $pid The post ID of the post
* @param int $tid The thread id of the post.

 * @return string The url to the post.
*/
function get_post_link($pid, $tid=0)

 * @return string The url to the post.
*/
function get_post_link($pid, $tid=0)

Zeile 5836Zeile 5905
/**
* Build the event link.
*

/**
* Build the event link.
*

 * @param int The event ID of the event

 * @param int $eid The event ID of the event

 * @return string The URL of the event
*/
function get_event_link($eid)

 * @return string The URL of the event
*/
function get_event_link($eid)

Zeile 5848Zeile 5917
/**
* Build the link to a specified date on the calendar
*

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

 * @param int The ID of the calendar
* @param int The year
* @param int The month
* @param int The day (optional)

 * @param int $calendar The ID of the calendar
* @param int $year The year
* @param int $month The month
* @param int $day The day (optional)

 * @return string The URL of the calendar
*/
function get_calendar_link($calendar, $year=0, $month=0, $day=0)

 * @return string The URL of the calendar
*/
function get_calendar_link($calendar, $year=0, $month=0, $day=0)

Zeile 5885Zeile 5954
/**
* Build the link to a specified week on the calendar
*

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

 * @param int The ID of the calendar
* @param int The year
* @param int The week

 * @param int $calendar The ID of the calendar
* @param int $week The week


 * @return string The URL of the calendar
*/
function get_calendar_week_link($calendar, $week)

 * @return string The URL of the calendar
*/
function get_calendar_week_link($calendar, $week)

Zeile 5904Zeile 5972
/**
* Get the user data of an user id.
*

/**
* Get the user data of an user id.
*

 * @param int The user id of the user.

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

 * @return array The users data
*/
function get_user($uid)

 * @return array The users data
*/
function get_user($uid)

Zeile 5935Zeile 6003
/**
* Get the user data of an user username.
*

/**
* Get the user data of an user username.
*

 * @param string The user username of the user.


 * @param string $username The user username of the user.
* @param array $options

 * @return array The users data
*/
function get_user_by_username($username, $options=array())

 * @return array The users data
*/
function get_user_by_username($username, $options=array())

Zeile 5994Zeile 6063
/**
* Get the forum of a specific forum id.
*

/**
* Get the forum of a specific forum id.
*

 * @param int The forum id of the forum.
* @param int (Optional) If set to 1, will override the active forum status
* @return array The database row of a forum.

 * @param int $fid The forum id of the forum.
* @param int $active_override (Optional) If set to 1, will override the active forum status
* @return array|bool The database row of a forum. False on failure

 */
function get_forum($fid, $active_override=0)
{

 */
function get_forum($fid, $active_override=0)
{

Zeile 6034Zeile 6103
/**
* Get the thread of a thread id.
*

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

 * @param int The thread id of the thread.
* @param boolean Whether or not to recache the thread.
* @return string The database row of the thread.

 * @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

 */
function get_thread($tid, $recache = false)
{

 */
function get_thread($tid, $recache = false)
{

Zeile 6070Zeile 6139
/**
* Get the post of a post id.
*

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

 * @param int The post id of the post.
* @param boolean Whether or not to recache the post.
* @param array An array of fields to gather from the database
* @return string The database row of the post.

 * @param int $pid The post id of the post.
* @return array|bool The database row of the post. False on failure



 */
function get_post($pid)
{

 */
function get_post($pid)
{

Zeile 6143Zeile 6210
/**
* Checks to make sure a user has not tried to login more times than permitted
*

/**
* Checks to make sure a user has not tried to login more times than permitted
*

 * @param bool (Optional) Stop execution if it finds an error with the login. Default is True
* @return bool 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($fatal = true)
{

Zeile 6237Zeile 6304
/**
* Validates the format of an email address.
*

/**
* Validates the format of an email address.
*

 * @param string The string to check.

 * @param string $email The string to check.

 * @return boolean True when valid, false when invalid.
*/
function validate_email_format($email)

 * @return boolean True when valid, false when invalid.
*/
function validate_email_format($email)

Zeile 6253Zeile 6320
/**
* Checks to see if the email is already in use by another
*

/**
* Checks to see if the email is already in use by another
*

 * @param string The email to check.
* @param string User ID of the user (updating only)

 * @param string $email The email to check.
* @param int $uid User ID of the user (updating only)

 * @return boolean True when in use, false when not.
*/

 * @return boolean True when in use, false when not.
*/

function email_already_in_use($email, $uid="")

function email_already_in_use($email, $uid=0)

{
global $db;


{
global $db;


Zeile 6318Zeile 6385
/**
* Build a PREG compatible array of search highlight terms to replace in posts.
*

/**
* Build a PREG compatible array of search highlight terms to replace in posts.
*

 * @param string Incoming terms to highlight

 * @param string $terms Incoming terms to highlight

 * @return array PREG compatible array of terms
*/
function build_highlight_array($terms)

 * @return array PREG compatible array of terms
*/
function build_highlight_array($terms)

Zeile 6433Zeile 6500
 * Converts a decimal reference of a character to its UTF-8 equivalent
* (Code by Anne van Kesteren, http://annevankesteren.nl/2005/05/character-references)
*

 * Converts a decimal reference of a character to its UTF-8 equivalent
* (Code by Anne van Kesteren, http://annevankesteren.nl/2005/05/character-references)
*

 * @param string Decimal value of a character reference


 * @param int $src Decimal value of a character reference
* @return string|bool

 */
function dec_to_utf8($src)
{

 */
function dec_to_utf8($src)
{

Zeile 6477Zeile 6545
/**
* Checks if a username has been disallowed for registration/use.
*

/**
* Checks if a username has been disallowed for registration/use.
*

 * @param string The username
* @param boolean True if the 'last used' dateline should be updated if a match is found.

 * @param string $username The username
* @param boolean $update_lastuse True if the 'last used' dateline should be updated if a match is found.

 * @return boolean True if banned, false if not banned
*/
function is_banned_username($username, $update_lastuse=false)

 * @return boolean True if banned, false if not banned
*/
function is_banned_username($username, $update_lastuse=false)

Zeile 6506Zeile 6574
/**
* Check if a specific email address has been banned.
*

/**
* Check if a specific email address has been banned.
*

 * @param string The email address.
* @param boolean True if the 'last used' dateline should be updated if a match is found.

 * @param string $email The email address.
* @param boolean $update_lastuse True if the 'last used' dateline should be updated if a match is found.

 * @return boolean True if banned, false if not banned
*/
function is_banned_email($email, $update_lastuse=false)

 * @return boolean True if banned, false if not banned
*/
function is_banned_email($email, $update_lastuse=false)

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

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

 * @param string The IP address.
* @param boolean True if the 'last used' dateline should be updated if a match is found.

 * @param string $ip_address The IP address.
* @param boolean $update_lastuse True if the 'last used' dateline should be updated if a match is found.

 * @return boolean True if banned, false if not banned.
*/
function is_banned_ip($ip_address, $update_lastuse=false)

 * @return boolean True if banned, false if not banned.
*/
function is_banned_ip($ip_address, $update_lastuse=false)

Zeile 6601Zeile 6669
}

/**

}

/**

 * Build a time zone selection list.

 * Returns an array of supported timezones

 *

 *

 * @param string The name of the select
* @param int The selected time zone (defaults to GMT)
* @param boolean True to generate a "short" list with just timezone and current time

 * @return string[] Key is timezone offset, Value the language description



 */

 */

function build_timezone_select($name, $selected=0, $short=false)

function get_supported_timezones()

{

{

	global $mybb, $lang, $templates;


	global $lang;


	$timezones = array(
"-12" => $lang->timezone_gmt_minus_1200,
"-11" => $lang->timezone_gmt_minus_1100,

	$timezones = array(
"-12" => $lang->timezone_gmt_minus_1200,
"-11" => $lang->timezone_gmt_minus_1100,

Zeile 6652Zeile 6717
		"13" => $lang->timezone_gmt_1300,
"14" => $lang->timezone_gmt_1400
);

		"13" => $lang->timezone_gmt_1300,
"14" => $lang->timezone_gmt_1400
);

 
	return $timezones;
}

/**
* Build a time zone selection list.
*
* @param string $name The name of the select
* @param int $selected The selected time zone (defaults to GMT)
* @param boolean $short True to generate a "short" list with just timezone and current time
* @return string
*/
function build_timezone_select($name, $selected=0, $short=false)
{
global $mybb, $lang, $templates;

$timezones = get_supported_timezones();


$selected = str_replace("+", "", $selected);
foreach($timezones as $timezone => $label)
{
$selected_add = "";
if($selected == $timezone)


$selected = str_replace("+", "", $selected);
foreach($timezones as $timezone => $label)
{
$selected_add = "";
if($selected == $timezone)

		{

		{

			$selected_add = " selected=\"selected\"";
}
if($short == true)
{
$label = '';
if($timezone != 0)

			$selected_add = " selected=\"selected\"";
}
if($short == true)
{
$label = '';
if($timezone != 0)

			{

			{

				$label = $timezone;
if($timezone > 0)

				$label = $timezone;
if($timezone > 0)

				{

				{

					$label = "+{$label}";
}
if(strpos($timezone, ".") !== false)

					$label = "+{$label}";
}
if(strpos($timezone, ".") !== false)

				{

				{

					$label = str_replace(".", ":", $label);
$label = str_replace(":5", ":30", $label);
$label = str_replace(":75", ":45", $label);

					$label = str_replace(".", ":", $label);
$label = str_replace(":5", ":30", $label);
$label = str_replace(":75", ":45", $label);

				}

				}

				else
{
$label .= ":00";

				else
{
$label .= ":00";

Zeile 6695Zeile 6776

/**
* Fetch the contents of a remote file.


/**
* Fetch the contents of a remote file.

 *
* @param string The URL of the remote file
* @param array The array of post data
* @return string The remote file contents.
*/

 *
* @param string $url The URL of the remote file
* @param array $post_data The array of post data
* @return string|bool The remote file contents. False on failure
*/

function fetch_remote_file($url, $post_data=array())
{
$post_body = '';

function fetch_remote_file($url, $post_data=array())
{
$post_body = '';

Zeile 6730Zeile 6811
		return $data;
}
else if(function_exists("fsockopen"))

		return $data;
}
else if(function_exists("fsockopen"))

	{

	{

		$url = @parse_url($url);
if(!$url['host'])
{

		$url = @parse_url($url);
if(!$url['host'])
{

Zeile 6818Zeile 6899
/**
* Checks if a particular user is a super administrator.
*

/**
* Checks if a particular user is a super administrator.
*

 * @param int The user ID to check against the list of super admins

 * @param int $uid The user ID to check against the list of super admins

 * @return boolean True if a super admin, false if not
*/
function is_super_admin($uid)
{
static $super_admins;

 * @return boolean True if a super admin, false if not
*/
function is_super_admin($uid)
{
static $super_admins;





	if(!isset($super_admins))
{
global $mybb;

	if(!isset($super_admins))
{
global $mybb;

Zeile 6832Zeile 6913
	}

if(my_strpos(",{$super_admins},", ",{$uid},") === false)

	}

if(my_strpos(",{$super_admins},", ",{$uid},") === false)

	{

	{

		return false;
}
else

		return false;
}
else

	{

	{

		return true;
}
}

		return true;
}
}

Zeile 6846Zeile 6927
 * Originates from frostschutz's PluginLibrary
* github.com/frostschutz
*

 * Originates from frostschutz's PluginLibrary
* github.com/frostschutz
*

 * @param mixed A selection of groups to check or -1 for any group
* @param mixed User to check selection against

 * @param array|int|string A selection of groups (as array or comma seperated) to check or -1 for any group
* @param bool|array|int False assumes the current user. Otherwise an user array or an id can be passed

 * @return array Array of groups specified in the first param to which the user belongs
*/
function is_member($groups, $user = false)

 * @return array Array of groups specified in the first param to which the user belongs
*/
function is_member($groups, $user = false)

Zeile 6857Zeile 6938
	if(empty($groups))
{
return array();

	if(empty($groups))
{
return array();

	}	

	}


if($user == false)
{


if($user == false)
{

Zeile 6900Zeile 6981
 * Split a string based on the specified delimeter, ignoring said delimeter in escaped strings.
* Ex: the "quick brown fox" jumped, could return 1 => the, 2 => quick brown fox, 3 => jumped
*

 * Split a string based on the specified delimeter, ignoring said delimeter in escaped strings.
* Ex: the "quick brown fox" jumped, could return 1 => the, 2 => quick brown fox, 3 => jumped
*

 * @param string The delimeter to split by
* @param string The string to split
* @param string The escape character or string if we have one.

 * @param string $delimeter The delimeter to split by
* @param string $string The string to split
* @param string $escape The escape character or string if we have one.

 * @return array Array of split string
*/
function escaped_explode($delimeter, $string, $escape="")

 * @return array Array of split string
*/
function escaped_explode($delimeter, $string, $escape="")

Zeile 6961Zeile 7042
 * DEPRECATED! Please use IPv6 compatible fetch_ip_range!
* Fetch an IPv4 long formatted range for searching IPv4 IP addresses.
*

 * DEPRECATED! Please use IPv6 compatible fetch_ip_range!
* Fetch an IPv4 long formatted range for searching IPv4 IP addresses.
*

 * @param string The IP address to convert to a range based LONG
* @rturn mixed If a full IP address is provided, the ip2long equivalent, otherwise an array of the upper & lower extremities of the IP


 * @deprecated
* @param string $ip The IP address to convert to a range based LONG
* @return string|array If a full IP address is provided, the ip2long equivalent, otherwise an array of the upper & lower extremities of the IP

 */
function fetch_longipv4_range($ip)
{

 */
function fetch_longipv4_range($ip)
{

Zeile 7047Zeile 7129
/**
* Format a ban length in to a UNIX timestamp.
*

/**
* Format a ban length in to a UNIX timestamp.
*

 * @param string The ban length string
* @param int The optional UNIX timestamp, if 0, current time is used.

 * @param string $date The ban length string
* @param int $stamp The optional UNIX timestamp, if 0, current time is used.

 * @return int The UNIX timestamp when the ban will be lifted
*/
function ban_date2timestamp($date, $stamp=0)

 * @return int The UNIX timestamp when the ban will be lifted
*/
function ban_date2timestamp($date, $stamp=0)

Zeile 7063Zeile 7145
	$n[1] += $d[0];
$n[2] += $d[1];
$n[3] += $d[2];

	$n[1] += $d[0];
$n[2] += $d[1];
$n[3] += $d[2];

	return mktime(date("G"), date("i"), 0, $n[2], $n[1], $n[3]);

	return mktime(date("G", $stamp), date("i", $stamp), 0, $n[2], $n[1], $n[3]);

}

/**
* Expire old warnings in the database.
*

}

/**
* Expire old warnings in the database.
*

 
 * @return bool

 */
function expire_warnings()
{

 */
function expire_warnings()
{

Zeile 7086Zeile 7169
/**
* Custom chmod function to fix problems with hosts who's server configurations screw up umasks
*

/**
* Custom chmod function to fix problems with hosts who's server configurations screw up umasks
*

 * @param string The file to chmod
* @param string The mode to chmod(i.e. 0666)


 * @param string $file The file to chmod
* @param string $mode The mode to chmod(i.e. 0666)
* @return bool

 */
function my_chmod($file, $mode)
{

 */
function my_chmod($file, $mode)
{

Zeile 7108Zeile 7192
/**
* Custom rmdir function to loop through an entire directory and delete all files/folders within
*

/**
* Custom rmdir function to loop through an entire directory and delete all files/folders within
*

 * @param string The path to the directory
* @param array Any files you wish to ignore (optional)


 * @param string $path The path to the directory
* @param array $ignore Any files you wish to ignore (optional)
* @return bool

 */
function my_rmdir_recursive($path, $ignore=array())
{

 */
function my_rmdir_recursive($path, $ignore=array())
{

Zeile 7149Zeile 7234
/**
* Counts the number of subforums in a array([pid][disporder][fid]) starting from the pid
*

/**
* Counts the number of subforums in a array([pid][disporder][fid]) starting from the pid
*

 * @param array The array of forums

 * @param array $array The array of forums

 * @return integer The number of sub forums
*/
function subforums_count($array)

 * @return integer The number of sub forums
*/
function subforums_count($array)

Zeile 7168Zeile 7253
 * Fix for PHP's ip2long to guarantee a 32-bit signed integer value is produced (this is aimed
* at 64-bit versions of PHP)
*

 * Fix for PHP's ip2long to guarantee a 32-bit signed integer value is produced (this is aimed
* at 64-bit versions of PHP)
*

 * @param string The IP to convert


 * @deprecated
* @param string $ip The IP to convert

 * @return integer IP in 32-bit signed format
*/
function my_ip2long($ip)

 * @return integer IP in 32-bit signed format
*/
function my_ip2long($ip)

Zeile 7197Zeile 7283
 * DEPRECATED! Please use IPv6 compatible my_inet_ntop!
* As above, fix for PHP's long2ip on 64-bit versions
*

 * DEPRECATED! Please use IPv6 compatible my_inet_ntop!
* As above, fix for PHP's long2ip on 64-bit versions
*

 * @param integer The IP to convert (will accept 64-bit IPs as well)


 * @deprecated
* @param integer $long The IP to convert (will accept 64-bit IPs as well)

 * @return string IP in IPv4 format
*/
function my_long2ip($long)

 * @return string IP in IPv4 format
*/
function my_long2ip($long)

Zeile 7214Zeile 7301
/**
* Converts a human readable IP address to its packed in_addr representation
*

/**
* Converts a human readable IP address to its packed in_addr representation
*

 * @param string The IP to convert

 * @param string $ip The IP to convert

 * @return string IP in 32bit or 128bit binary format
*/
function my_inet_pton($ip)

 * @return string IP in 32bit or 128bit binary format
*/
function my_inet_pton($ip)

Zeile 7267Zeile 7354
/**
* Converts a packed internet address to a human readable representation
*

/**
* Converts a packed internet address to a human readable representation
*

 * @param string IP in 32bit or 128bit binary format

 * @param string $ip IP in 32bit or 128bit binary format

 * @return string IP in human readable format
*/
function my_inet_ntop($ip)

 * @return string IP in human readable format
*/
function my_inet_ntop($ip)

Zeile 7309Zeile 7396
/**
* Fetch an binary formatted range for searching IPv4 and IPv6 IP addresses.
*

/**
* Fetch an binary formatted range for searching IPv4 and IPv6 IP addresses.
*

 * @param string The IP address to convert to a range
* @rturn mixed If a full IP address is provided, the in_addr representation, otherwise an array of the upper & lower extremities of the IP

 * @param string $ipaddress The IP address to convert to a range
* @return string|array|bool If a full IP address is provided, the in_addr representation, otherwise an array of the upper & lower extremities of the IP. False on failure

 */
function fetch_ip_range($ipaddress)
{

 */
function fetch_ip_range($ipaddress)
{

Zeile 7452Zeile 7539
/**
* Processes a checksum list on MyBB files and returns a result set
*

/**
* Processes a checksum list on MyBB files and returns a result set
*

 * @param array The array of checksums and their corresponding files
* @param int The count of files

 * @param string $path The base path
* @param int $count The count of files

 * @return array The bad files
*/
function verify_files($path=MYBB_ROOT, $count=0)

 * @return array The bad files
*/
function verify_files($path=MYBB_ROOT, $count=0)

Zeile 7548Zeile 7635
/**
* Returns a signed value equal to an integer
*

/**
* Returns a signed value equal to an integer
*

 * @param int The integer

 * @param int $int The integer

 * @return string The signed equivalent
*/
function signed($int)

 * @return string The signed equivalent
*/
function signed($int)

Zeile 7566Zeile 7653
/**
* Returns a securely generated seed for PHP's RNG (Random Number Generator)
*

/**
* Returns a securely generated seed for PHP's RNG (Random Number Generator)
*

 * @param int Length of the seed bytes (8 is default. Provides good cryptographic variance)

 * @param int $count Length of the seed bytes (8 is default. Provides good cryptographic variance)

 * @return int An integer equivalent of a secure hexadecimal seed
*/
function secure_seed_rng($count=8)

 * @return int An integer equivalent of a secure hexadecimal seed
*/
function secure_seed_rng($count=8)

Zeile 7646Zeile 7733
/**
* Wrapper function for mt_rand. Automatically seeds using a secure seed once.
*

/**
* Wrapper function for mt_rand. Automatically seeds using a secure seed once.
*

 * @param int Optional lowest value to be returned (default: 0)
* @param int Optional highest value to be returned (default: mt_getrandmax())
* @param boolean True forces it to reseed the RNG first

 * @param int $min Optional lowest value to be returned (default: 0)
* @param int $max Optional highest value to be returned (default: mt_getrandmax())
* @param boolean $force_seed True forces it to reseed the RNG first

 * @return int An integer equivalent of a secure hexadecimal seed
*/
function my_rand($min=null, $max=null, $force_seed=false)

 * @return int An integer equivalent of a secure hexadecimal seed
*/
function my_rand($min=null, $max=null, $force_seed=false)

Zeile 7693Zeile 7780
 * More robust version of PHP's trim() function. It includes a list of UTF-8 blank characters
* from http://kb.mozillazine.org/Network.IDN.blacklist_chars
*

 * More robust version of PHP's trim() function. It includes a list of UTF-8 blank characters
* from http://kb.mozillazine.org/Network.IDN.blacklist_chars
*

 * @param string The string to trim from
* @param string Optional. The stripped characters can also be specified using the charlist parameter

 * @param string $string The string to trim from
* @param string $charlist Optional. The stripped characters can also be specified using the charlist parameter

 * @return string The trimmed string
*/

 * @return string The trimmed string
*/

function trim_blank_chrs($string, $charlist=false)

function trim_blank_chrs($string, $charlist="")

{
$hex_chrs = array(
0x09 => 1, // \x{0009}

{
$hex_chrs = array(
0x09 => 1, // \x{0009}

Zeile 7791Zeile 7878
	while(++$i);
$string = strrev($string);


	while(++$i);
$string = strrev($string);


	if($charlist !== false)

	if($charlist)

	{
$string = trim($string, $charlist);
}

	{
$string = trim($string, $charlist);
}

Zeile 7806Zeile 7893
/**
* Match a sequence
*

/**
* Match a sequence
*

 * @param string The string to match from
* @param array The array to match from
* @param int Number in the string
* @param int Number of matches

 * @param string $string The string to match from
* @param array $array The array to match from
* @param int $i Number in the string
* @param int $n Number of matches

 * @return int The number matched
*/
function match_sequence($string, $array, $i=0, $n=0)

 * @return int The number matched
*/
function match_sequence($string, $array, $i=0, $n=0)

Zeile 7876Zeile 7963
/*
* Validates an UTF-8 string.
*

/*
* Validates an UTF-8 string.
*

 * @param string The string to be checked
* @param boolean Allow 4 byte UTF-8 characters?
* @param boolean Return the cleaned string?
* @return string/boolean Cleaned string or boolean

 * @param string $input The string to be checked
* @param boolean $allow_mb4 Allow 4 byte UTF-8 characters?
* @param boolean $return Return the cleaned string?
* @return string|boolean Cleaned string or boolean

 */
function validate_utf8_string($input, $allow_mb4=true, $return=true)
{

 */
function validate_utf8_string($input, $allow_mb4=true, $return=true)
{

Zeile 7993Zeile 8080
/**
* Send a Private Message to a user.
*

/**
* Send a Private Message to a user.
*

 * @param array Array containing: 'subject', 'message', 'touid' and 'receivepms' (the latter should reflect the value found in the users table: receivepms and receivefrombuddy)
* @param int Sender UID (0 if you want to use $mybb->user['uid'] or -1 to use MyBB Engine)
* @param bool Whether or not do override user defined options for receiving PMs

 * @param array $pm Array containing: 'subject', 'message', 'touid' and 'receivepms' (the latter should reflect the value found in the users table: receivepms and receivefrombuddy)
* @param int $fromid Sender UID (0 if you want to use $mybb->user['uid'] or -1 to use MyBB Engine)
* @param bool $admin_override Whether or not do override user defined options for receiving PMs

 * @return bool True if PM sent
*/
function send_pm($pm, $fromid = 0, $admin_override=false)

 * @return bool True if PM sent
*/
function send_pm($pm, $fromid = 0, $admin_override=false)