Vergleich inc/functions.php - 1.6.3 - 1.6.9

  Keine Änderungen   Hinzugefügt   Modifiziert   Entfernt
Zeile 6Zeile 6
 * Website: http://mybb.com
* License: http://mybb.com/about/license
*

 * Website: http://mybb.com
* License: http://mybb.com/about/license
*

 * $Id: functions.php 5380 2011-02-21 12:04:43Z Tomm $

 * $Id$

 */

/**

 */

/**

Zeile 92Zeile 92
	echo $contents;

$plugins->run_hooks("post_output_page");

	echo $contents;

$plugins->run_hooks("post_output_page");


// If the use shutdown functionality is turned off, run any shutdown related items now.
if($mybb->settings['useshutdownfunc'] == 0 && $mybb->use_shutdown != true)
{
run_shutdown();
}

 
}

/**

}

/**

Zeile 197Zeile 191
	}

// And finally.. plugins

	}

// And finally.. plugins

	if(!is_object($plugins) && !defined("NO_PLUGINS"))

	if(!is_object($plugins) && !defined("NO_PLUGINS") && !($mybb->settings['no_plugins'] == 1))

	{
require_once MYBB_ROOT."inc/class_plugins.php";
$plugins = new pluginSystem;

	{
require_once MYBB_ROOT."inc/class_plugins.php";
$plugins = new pluginSystem;

Zeile 246Zeile 240

// Fetch emails for this page view - and send them
$query = $db->simple_select("mailqueue", "*", "", array("order_by" => "mid", "order_dir" => "asc", "limit_start" => 0, "limit" => $count));


// Fetch emails for this page view - and send them
$query = $db->simple_select("mailqueue", "*", "", array("order_by" => "mid", "order_dir" => "asc", "limit_start" => 0, "limit" => $count));


$plugins->run_hooks_by_ref("send_mail_queue_mail", $query);

 

while($email = $db->fetch_array($query))
{
// Delete the message from the queue
$db->delete_query("mailqueue", "mid='{$email['mid']}'");



while($email = $db->fetch_array($query))
{
// Delete the message from the queue
$db->delete_query("mailqueue", "mid='{$email['mid']}'");


			my_mail($email['mailto'], $email['subject'], $email['message'], $email['mailfrom'], "", $email['headers']);




			if($db->affected_rows() == 1)
{
my_mail($email['mailto'], $email['subject'], $email['message'], $email['mailfrom'], "", $email['headers']);
}

		}
// Update the mailqueue cache and remove the lock
$cache->update_mailqueue(TIME_NOW, 0);

		}
// Update the mailqueue cache and remove the lock
$cache->update_mailqueue(TIME_NOW, 0);

Zeile 272Zeile 267
function parse_page($contents)
{
global $lang, $theme, $mybb, $htmldoctype, $archive_url, $error_handler;

function parse_page($contents)
{
global $lang, $theme, $mybb, $htmldoctype, $archive_url, $error_handler;





	$contents = str_replace('<navigation>', build_breadcrumb(1), $contents);
$contents = str_replace('<archive_url>', $archive_url, $contents);


	$contents = str_replace('<navigation>', build_breadcrumb(1), $contents);
$contents = str_replace('<archive_url>', $archive_url, $contents);


Zeile 293Zeile 288
	}

if($lang->settings['htmllang'])

	}

if($lang->settings['htmllang'])

	{

	{

		$contents = str_replace("<html", "<html xml:lang=\"".$lang->settings['htmllang']."\" lang=\"".$lang->settings['htmllang']."\"", $contents);
}


		$contents = str_replace("<html", "<html xml:lang=\"".$lang->settings['htmllang']."\" lang=\"".$lang->settings['htmllang']."\"", $contents);
}


Zeile 357Zeile 352
	if($offset == "-")
{
$offset = 0;

	if($offset == "-")
{
$offset = 0;

	}

if($adodb == true && function_exists('adodb_date'))

	}

if($adodb == true && function_exists('adodb_date'))

	{
$date = adodb_date($format, $stamp + ($offset * 3600));
}

	{
$date = adodb_date($format, $stamp + ($offset * 3600));
}

Zeile 395Zeile 390

if(is_object($plugins))
{


if(is_object($plugins))
{

		$plugins->run_hooks_by_ref("my_date", $date);

		$date = $plugins->run_hooks("my_date", $date);

	}

return $date;

	}

return $date;

Zeile 534Zeile 529
	{
cache_forums();
return $forum_cache[$fid]['parentlist'];

	{
cache_forums();
return $forum_cache[$fid]['parentlist'];

	}
}


	}
}


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

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

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

{

{

	if(!$parentlist)
{
$parentlist = get_parent_list($fid);
}

	if(!$parentlist)
{
$parentlist = get_parent_list($fid);
}





	$parentsexploded = explode(",", $parentlist);
$builtlist = "(";
$sep = '';

foreach($parentsexploded as $key => $val)

	$parentsexploded = explode(",", $parentlist);
$builtlist = "(";
$sep = '';

foreach($parentsexploded as $key => $val)

	{

	{

		$builtlist .= "$sep$column='$val'";
$sep = " $joiner ";
}

		$builtlist .= "$sep$column='$val'";
$sep = " $joiner ";
}

Zeile 590Zeile 585
		{
$cache->update_forums();
$forum_cache = $cache->read("forums", 1);

		{
$cache->update_forums();
$forum_cache = $cache->read("forums", 1);

		}
}

		}
}

	return $forum_cache;
}


	return $forum_cache;
}


Zeile 623Zeile 618
	}

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

	}

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

	{

	{

		$forums[] = $forum['fid'];
$children = get_child_list($forum['fid']);
if(is_array($children))

		$forums[] = $forum['fid'];
$children = get_child_list($forum['fid']);
if(is_array($children))

Zeile 644Zeile 639
{
global $header, $footer, $theme, $headerinclude, $db, $templates, $lang, $mybb, $plugins;


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


	$plugins->run_hooks_by_ref("error", $error);

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

	if(!$error)
{
$error = $lang->unknown_error;

	if(!$error)
{
$error = $lang->unknown_error;

Zeile 732Zeile 727
	);

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

	);

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

	$url = htmlspecialchars_uni("http://".$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI']);

 

if($mybb->input['ajax'])
{


if($mybb->input['ajax'])
{

Zeile 749Zeile 743
	}
else
{

	}
else
{

 
		// Redirect to where the user came from
$redirect_url = $_SERVER['PHP_SELF'];
if($_SERVER['QUERY_STRING'])
{
$redirect_url .= '?'.$_SERVER['QUERY_STRING'];
}

$redirect_url = htmlspecialchars_uni($redirect_url);

switch($mybb->settings['username_method'])
{
case 0:
$lang_username = $lang->username;
break;
case 1:
$lang_username = $lang->username1;
break;
case 2:
$lang_username = $lang->username2;
break;
default:
$lang_username = $lang->username;
break;
}

		eval("\$errorpage = \"".$templates->get("error_nopermission")."\";");
}


		eval("\$errorpage = \"".$templates->get("error_nopermission")."\";");
}


Zeile 767Zeile 785

$redirect_args = array('url' => &$url, 'message' => &$message, 'title' => &$title);



$redirect_args = array('url' => &$url, 'message' => &$message, 'title' => &$title);


	$plugins->run_hooks_by_ref("redirect", $redirect_args);

	$plugins->run_hooks("redirect", $redirect_args);


if($mybb->input['ajax'])
{


if($mybb->input['ajax'])
{

Zeile 801Zeile 819
	
// Show redirects only if both ACP and UCP settings are enabled, or ACP is enabled, and user is a guest.
if($mybb->settings['redirects'] == 1 && ($mybb->user['showredirect'] != 0 || !$mybb->user['uid']))

	
// Show redirects only if both ACP and UCP settings are enabled, or ACP is enabled, and user is a guest.
if($mybb->settings['redirects'] == 1 && ($mybb->user['showredirect'] != 0 || !$mybb->user['uid']))

	{

	{

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


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


Zeile 815Zeile 833

run_shutdown();



run_shutdown();


		if(my_substr($url, 0, 7) !== 'http://')

		if(my_substr($url, 0, 7) !== 'http://' && my_substr($url, 0, 8) !== 'https://' && my_substr($url, 0, 1) !== '/')

		{
header("Location: {$mybb->settings['bburl']}/{$url}");
}

		{
header("Location: {$mybb->settings['bburl']}/{$url}");
}

Zeile 952Zeile 970

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


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

 *

 *

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

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

Zeile 962Zeile 980
 	{
$find = array(
"-page-{page}",

 	{
$find = array(
"-page-{page}",

			"&amp;page={page}"


			"&amp;page={page}",
"{page}"

		);

// Remove "Page 1" to the defacto URL

		);

// Remove "Page 1" to the defacto URL

		$url = str_replace($find, array("", ""), $url);

		$url = str_replace($find, array("", "", $page), $url);

		return $url;
}
else if(strpos($url, "{page}") === false)

		return $url;
}
else if(strpos($url, "{page}") === false)

Zeile 990Zeile 1009

return $url;
}


return $url;
}





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

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

Zeile 1000Zeile 1019
function user_permissions($uid=0)
{
global $mybb, $cache, $groupscache, $user_cache;

function user_permissions($uid=0)
{
global $mybb, $cache, $groupscache, $user_cache;





	// If no user id is specified, assume it is the current user
if($uid == 0)
{

	// If no user id is specified, assume it is the current user
if($uid == 0)
{

Zeile 1028Zeile 1047

// Store group permissions in user cache.
$user_cache[$uid]['permissions'] = $groupperms;


// Store group permissions in user cache.
$user_cache[$uid]['permissions'] = $groupperms;

		return $groupperms;
}

		return $groupperms;
}

	// This user is the current user, return their permissions
else
{

	// This user is the current user, return their permissions
else
{

Zeile 1178Zeile 1197
	}

if(!is_array($fpermcache))

	}

if(!is_array($fpermcache))

	{
$fpermcache = $cache->read("forumpermissions");

	{
$fpermcache = $cache->read("forumpermissions");

	}

if($fid) // Fetch the permissions for a single forum

	}

if($fid) // Fetch the permissions for a single forum

Zeile 1187Zeile 1206
		if(!$cached_forum_permissions_permissions[$gid][$fid])
{
$cached_forum_permissions_permissions[$gid][$fid] = fetch_forum_permissions($fid, $gid, $groupperms);

		if(!$cached_forum_permissions_permissions[$gid][$fid])
{
$cached_forum_permissions_permissions[$gid][$fid] = fetch_forum_permissions($fid, $gid, $groupperms);

		}

		}

		return $cached_forum_permissions_permissions[$gid][$fid];
}
else

		return $cached_forum_permissions_permissions[$gid][$fid];
}
else

Zeile 1224Zeile 1243
	}

$current_permissions = array();

	}

$current_permissions = array();

 
	$only_view_own_threads = 1;

	
foreach($groups as $gid)
{

	
foreach($groups as $gid)
{

Zeile 1252Zeile 1272
					{
$level_permissions = $groupscache[$gid];
}

					{
$level_permissions = $groupscache[$gid];
}

				}
}


				}
}


			foreach($level_permissions as $permission => $access)
{
if($access >= $current_permissions[$permission] || ($access == "yes" && $current_permissions[$permission] == "no") || !$current_permissions[$permission])
{
$current_permissions[$permission] = $access;
}

			foreach($level_permissions as $permission => $access)
{
if($access >= $current_permissions[$permission] || ($access == "yes" && $current_permissions[$permission] == "no") || !$current_permissions[$permission])
{
$current_permissions[$permission] = $access;
}

			}
}
}













			}

if(!$level_permissions["canonlyviewownthreads"])
{
$only_view_own_threads = 0;
}
}
}

// Figure out if we can view more than our own threads
if($only_view_own_threads == 0)
{
$current_permissions["canonlyviewownthreads"] = 0;
}


	if(count($current_permissions) == 0)
{
$current_permissions = $groupperms;

	if(count($current_permissions) == 0)
{
$current_permissions = $groupperms;

Zeile 1283Zeile 1314
	global $mybb, $header, $footer, $headerinclude, $theme, $templates, $lang, $forum_cache;

$showform = true;

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

$showform = true;

	

	

	if(!is_array($forum_cache))
{
$forum_cache = cache_forums();

	if(!is_array($forum_cache))
{
$forum_cache = cache_forums();

Zeile 1301Zeile 1332
		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;
}


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

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

				$showform = true;
}
}
else
{

				$showform = true;
}
}
else
{

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

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

if($showform)
{
if($pid)

		$showform = false;
}

if($showform)
{
if($pid)

		{

		{

			header("Location: ".$mybb->settings['bburl']."/".get_forum_link($fid));
}
else

			header("Location: ".$mybb->settings['bburl']."/".get_forum_link($fid));
}
else

Zeile 1371Zeile 1402
 */
function get_moderator_permissions($fid, $uid="0", $parentslist="")
{

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

	global $mybb, $db;

	global $mybb, $cache, $db;

	static $modpermscache;

if($uid < 1)

	static $modpermscache;

if($uid < 1)

Zeile 1383Zeile 1414
	{
return false;
}

	{
return false;
}

	
if(!isset($modpermscache[$fid][$uid]))
{
if(!$parentslist)




















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

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

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

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

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

foreach($extra_groups as $extra_group)

		{

		{

			$parentslist = get_parent_list($fid);
}

// Get user groups
$query = $db->simple_select("users", "usergroup,additionalgroups", "uid='{$uid}'");
$usergroups = $db->fetch_array($query);
$groups = "'{$usergroups['usergroup']}'";
if(!empty($usergroups['additionalgroups']))


			$groups[] = $extra_group;
}
}

$mod_cache = $cache->read("moderators");

foreach($mod_cache as $fid => $forum)
{
if(!is_array($forum) || !in_array($fid, $parentslist))

		{

		{

			$groups .= ",'{$usergroups['additionalgroups']}'";














































			// No perms or we're not after this forum
continue;
}

// User settings override usergroup settings
if(is_array($forum['users'][$uid]))
{
$perm = $forum['users'][$uid];
foreach($perm as $action => $value)
{
if(strpos($action, "can") === false)
{
continue;
}

// Figure out the user permissions
if($value == 0)
{
// The user doesn't have permission to set this action
$perms[$action] = 0;
}
else
{
$perms[$action] = max($perm[$action], $perms[$action]);
}
}
}

foreach($groups as $group)
{
if(!is_array($forum['usergroups'][$group]))
{
// There are no permissions set for this group
continue;
}

$perm = $forum['usergroups'][$group];
foreach($perm as $action => $value)
{
if(strpos($action, "can") === false)
{
continue;
}

$perms[$action] = max($perm[$action], $perms[$action]);
}

		}

		}

		
$query = $db->simple_select("moderators", "*", "((id IN ({$groups}) AND isgroup='1') OR (id='{$uid}' AND isgroup='0')) AND fid='$fid'");
while($results = $db->fetch_array($query))
{
$perms['caneditposts'] = max($perms['caneditposts'], $results['caneditposts']);
$perms['candeleteposts'] = max($perms['candeleteposts'], $results['candeleteposts']);
$perms['canviewips'] = max($perms['canviewips'], $results['canviewips']);
$perms['canopenclosethreads'] = max($perms['canopenclosethreads'], $results['canopenclosethreads']);
$perms['canmanagethreads'] = max($perms['canmanagethreads'], $results['canmanagethreads']);
$perms['canmovetononmodforum'] = max($perms['canmovetononmodforum'], $results['canmovetononmodforum']);
}

$sql = build_parent_list($fid, "fid", "OR", $parentslist);
$query = $db->simple_select("moderators", "*", "((id IN ({$groups}) AND isgroup='1') OR (id='{$uid}' AND isgroup='0')) AND {$sql}");
$uperms = $db->fetch_array($query);

if(!$uperms && !$perms)
{
return false;
}

//Join the group permissions with the user permissions
$perms['caneditposts'] = max($perms['caneditposts'], $uperms['caneditposts']);
$perms['candeleteposts'] = max($perms['candeleteposts'], $uperms['candeleteposts']);
$perms['canviewips'] = max($perms['canviewips'], $uperms['canviewips']);
$perms['canopenclosethreads'] = max($perms['canopenclosethreads'], $uperms['canopenclosethreads']);
$perms['canmanagethreads'] = max($perms['canmanagethreads'], $uperms['canmanagethreads']);
$perms['canmovetononmodforum'] = max($perms['canmovetononmodforum'], $uperms['canmovetononmodforum']);

$modpermscache[$fid][$uid] = $perms;
}
else
{
$perms = $modpermscache[$fid][$uid];

 
	}

	}

 

$modpermscache[$fid][$uid] = $perms;


return $perms;
}


return $perms;
}

Zeile 1537Zeile 1600
	
foreach($posticons as $dbicon)
{

	
foreach($posticons as $dbicon)
{

 
		$dbicon['path'] = htmlspecialchars_uni($dbicon['path']);
$dbicon['name'] = htmlspecialchars_uni($dbicon['name']);


		if($icon == $dbicon['iid'])
{
$iconlist .= "<label><input type=\"radio\" name=\"icon\" value=\"".$dbicon['iid']."\" checked=\"checked\" /> <img src=\"".$dbicon['path']."\" alt=\"".$dbicon['name']."\" /></label>";

		if($icon == $dbicon['iid'])
{
$iconlist .= "<label><input type=\"radio\" name=\"icon\" value=\"".$dbicon['iid']."\" checked=\"checked\" /> <img src=\"".$dbicon['path']."\" alt=\"".$dbicon['name']."\" /></label>";

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

return $posticons;

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

return $posticons;

}

}


/**
* MyBB setcookie() wrapper.


/**
* MyBB setcookie() wrapper.

Zeile 1580Zeile 1646
	if($expires == -1)
{
$expires = 0;

	if($expires == -1)
{
$expires = 0;

	}

	}

	elseif($expires == "" || $expires == null)
{
$expires = TIME_NOW + (60*60*24*365); // Make the cookie expire in a years time

	elseif($expires == "" || $expires == null)
{
$expires = TIME_NOW + (60*60*24*365); // Make the cookie expire in a years time

Zeile 1624Zeile 1690

/**
* Unset a cookie set by MyBB.


/**
* Unset a cookie set by MyBB.

 *

 *

 * @param string The cookie identifier.
*/
function my_unsetcookie($name)

 * @param string The cookie identifier.
*/
function my_unsetcookie($name)

Zeile 1639Zeile 1705

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


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

 *

 *

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

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

{
global $mybb;


{
global $mybb;


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


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


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

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


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


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

Zeile 1662Zeile 1728
	else
{
return 0;

	else
{
return 0;

	}
}

	}
}


/**
* Set a serialised cookie array.


/**
* Set a serialised cookie array.

Zeile 1672Zeile 1738
 * @param int The cookie content id.
* @param string The value to set the cookie to.
*/

 * @param int The cookie content id.
* @param string The value to set the cookie to.
*/

function my_set_array_cookie($name, $id, $value)

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

{
global $mybb;

$cookie = $mybb->cookies['mybb'];

{
global $mybb;

$cookie = $mybb->cookies['mybb'];

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

if(!is_array($newcookie))
{
// Burnt / malformed cookie - reset
$newcookie = array();
}

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








$newcookie[$id] = $value;
$newcookie = serialize($newcookie);


$newcookie[$id] = $value;
$newcookie = serialize($newcookie);

	my_setcookie("mybb[$name]", addslashes($newcookie));


	my_setcookie("mybb[$name]", addslashes($newcookie), $expires);


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

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

 

/**
* Verifies that data passed is an array
*
* @param array Data to unserialize
* @return array Unserialized data array
*/
function my_unserialize($data)
{
$array = unserialize($data);

if(!is_array($array))
{
$array = array();
}

return $array;
}


/**
* Returns the serverload of the system.


/**
* Returns the serverload of the system.

Zeile 1805Zeile 1883
		$lastmember = $db->fetch_array($query);
$new_stats['lastuid'] = $lastmember['uid'];
$new_stats['lastusername'] = $lastmember['username'];

		$lastmember = $db->fetch_array($query);
$new_stats['lastuid'] = $lastmember['uid'];
$new_stats['lastusername'] = $lastmember['username'];

	}


	}


	if(empty($new_stats))

	if(empty($new_stats))

	{

	{

		return;
}


		return;
}


Zeile 1817Zeile 1895
		$stats = array_merge($stats, $new_stats);
}
else

		$stats = array_merge($stats, $new_stats);
}
else

	{

	{

		$stats = $new_stats;
}


		$stats = $new_stats;
}


Zeile 1850Zeile 1928
	// Fetch above counters for this forum
$query = $db->simple_select("forums", implode(",", $counters), "fid='{$fid}'");
$forum = $db->fetch_array($query);

	// Fetch above counters for this forum
$query = $db->simple_select("forums", implode(",", $counters), "fid='{$fid}'");
$forum = $db->fetch_array($query);





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

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

			{

			{

				$update_query[$counter] = $forum[$counter] + $changes[$counter];
}

				$update_query[$counter] = $forum[$counter] + $changes[$counter];
}

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

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

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

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

Zeile 1871Zeile 1949
				$update_query[$counter] = 0;
}
}

				$update_query[$counter] = 0;
}
}

	}


	}


	// Only update if we're actually doing something
if(count($update_query) > 0)
{

	// Only update if we're actually doing something
if(count($update_query) > 0)
{

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

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

			}

			}

		}

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

		}

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

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

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

			}
else

			}
else

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

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

Zeile 1936Zeile 2014
		}
update_stats($new_stats);
}

		}
update_stats($new_stats);
}





	// Update last post info
update_forum_lastpost($fid);


	// Update last post info
update_forum_lastpost($fid);


Zeile 1947Zeile 2025
 * Update the last post information for a specific forum
*
* @param int The forum ID

 * Update the last post information for a specific forum
*
* @param int The forum ID

 */

 */

function update_forum_lastpost($fid)
{
global $db;

function update_forum_lastpost($fid)
{
global $db;

Zeile 1969Zeile 2047
		"lastposttid" => intval($lastpost['tid']),
"lastpostsubject" => $db->escape_string($lastpost['subject'])
);

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





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


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


Zeile 1980Zeile 2058
 * @param array Array of items being updated (replies, unapprovedposts, attachmentcount) and their value (ex, 1, +1, -1)
*/
function update_thread_counters($tid, $changes=array())

 * @param array Array of items being updated (replies, unapprovedposts, attachmentcount) and their value (ex, 1, +1, -1)
*/
function update_thread_counters($tid, $changes=array())

{
global $db;

{
global $db;


$update_query = array();



$update_query = array();


Zeile 2001Zeile 2079
				$update_query[$counter] = $thread[$counter] + $changes[$counter];
}
else

				$update_query[$counter] = $thread[$counter] + $changes[$counter];
}
else

			{

			{

				$update_query[$counter] = $changes[$counter];
}


				$update_query[$counter] = $changes[$counter];
}


Zeile 2014Zeile 2092
	}

$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 2034Zeile 2112
function update_thread_data($tid)
{
global $db;

function update_thread_data($tid)
{
global $db;

 

$thread = get_thread($tid);

// If this is a moved thread marker, don't update it - we need it to stay as it is
if(strpos($thread['closed'], 'moved|') !== false)
{
return false;
}


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

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

Zeile 2157Zeile 2244
{
global $forum_cache, $jumpfcache, $permissioncache, $mybb, $selecteddone, $forumjump, $forumjumpbits, $gobutton, $theme, $templates, $lang;


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


	$pid = intval($pid);


	$pid = intval($pid);


	if($permissions)
{
$permissions = $mybb->usergroup;

	if($permissions)
{
$permissions = $mybb->usergroup;

Zeile 2167Zeile 2254
	if(!is_array($jumpfcache))
{
if(!is_array($forum_cache))

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

		{

		{

			cache_forums();

			cache_forums();

		}

		}


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


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

			}
}
}

			}
}
}


if(!is_array($permissioncache))
{


if(!is_array($permissioncache))
{

Zeile 2222Zeile 2309
		if(!$selecteddone)
{
if(!$selitem)

		if(!$selecteddone)
{
if(!$selitem)

			{

			{

				$selitem = "default";
}


				$selitem = "default";
}


Zeile 2236Zeile 2323
		else
{
$template = "advanced";

		else
{
$template = "advanced";

 

if(strpos(FORUM_URL, '.html') !== false)
{
$forum_link = "'".str_replace('{fid}', "'+this.options[this.selectedIndex].value+'", FORUM_URL)."'";
}
else
{
$forum_link = "'".str_replace('{fid}', "'+this.options[this.selectedIndex].value", 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.
*

Zeile 2347Zeile 2443
			"editor_enter_image",
"editor_enter_video_url",
"editor_video_dailymotion",

			"editor_enter_image",
"editor_enter_video_url",
"editor_video_dailymotion",

			"editor_video_googlevideo",

 
			"editor_video_metacafe",
"editor_video_myspacetv",
"editor_video_vimeo",

			"editor_video_metacafe",
"editor_video_myspacetv",
"editor_video_vimeo",

Zeile 2366Zeile 2461
		);
$editor_language = "var editor_language = {\n";


		);
$editor_language = "var editor_language = {\n";


		$plugins->run_hooks_by_ref("mycode_add_codebuttons", $editor_lang_strings);

		$editor_lang_strings = $plugins->run_hooks("mycode_add_codebuttons", $editor_lang_strings);


foreach($editor_lang_strings as $key => $lang_string)
{


foreach($editor_lang_strings as $key => $lang_string)
{

Zeile 2421Zeile 2516
			if(!is_array($smilie_cache))
{
$smilie_cache = $cache->read("smilies");

			if(!is_array($smilie_cache))
{
$smilie_cache = $cache->read("smilies");

			}

			}

			foreach($smilie_cache as $smilie)
{
if($smilie['showclickable'] != 0)
{
$smiliecache[$smilie['find']] = $smilie['image'];

			foreach($smilie_cache as $smilie)
{
if($smilie['showclickable'] != 0)
{
$smiliecache[$smilie['find']] = $smilie['image'];

				}
}
}

unset($smilie);


				}
}
}

unset($smilie);


		if(is_array($smiliecache))
{
reset($smiliecache);

		if(is_array($smiliecache))
{
reset($smiliecache);

Zeile 2487Zeile 2582
		}
}
else

		}
}
else

	{

	{

		$clickablesmilies = "";
}


		$clickablesmilies = "";
}


	return $clickablesmilies;





















































	return $clickablesmilies;
}

/**
* Builds thread prefixes and returns a selected prefix (or all)
*
* @param int The prefix ID (0 to return all)
* @return array The thread prefix's values (or all thread prefixes)
*/
function build_prefixes($pid=0)
{
global $cache;
static $prefixes_cache;

if(is_array($prefixes_cache))
{
if($pid > 0 && is_array($prefixes_cache[$pid]))
{
return $prefixes_cache[$pid];
}

return $prefixes_cache;
}

$prefix_cache = $cache->read("threadprefixes");

if(!is_array($prefix_cache))
{
// No cache
$prefix_cache = $cache->read("threadprefixes", true);

if(!is_array($prefix_cache))
{
return array();
}
}

$prefixes_cache = array();
foreach($prefix_cache as $prefix)
{
$prefixes_cache[$prefix['pid']] = $prefix;
}

if($pid != 0 && is_array($prefixes_cache[$pid]))
{
return $prefixes_cache[$pid];
}
else if(!empty($prefixes_cache))
{
return $prefixes_cache;
}

return false;

}

/**

}

/**

Zeile 2503Zeile 2650
 */
function build_prefix_select($fid, $selected_pid=0, $multiple=0)
{

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

	global $db, $lang, $mybb;

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

	
if($fid != 'all')
{
$fid = intval($fid);

	
if($fid != 'all')
{
$fid = intval($fid);

	}

// Does this user have additional groups?







	}

$prefix_cache = build_prefixes(0);
if(!$prefix_cache)
{
return false; // We've got no prefixes to show
}

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

	if($mybb->user['additionalgroups'])

	if($mybb->user['additionalgroups'])

	{

	{

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

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


// Because we like apostrophes...
$imps = array();





		foreach($exp as $group)

		foreach($exp as $group)

		{
$imps[] = "'{$group}'";
}

$additional_groups = implode(",", $imps);
$extra_sql = "groups IN ({$additional_groups}) OR ";
}
else
{
$extra_sql = '';

		{
$groups[] = $group;
}








	}

	}


switch($db->type)




// Go through each of our prefixes and decide which ones we can use
$prefixes = array();
foreach($prefix_cache as $prefix)

	{

	{

		case "pgsql":
case "sqlite":
$whereforum = "";
if($fid != 'all')














		if($fid != "all" && $prefix['forums'] != "-1")
{
// Decide whether this prefix can be used in our forum
$forums = explode(",", $prefix['forums']);

if(!in_array($fid, $forums))
{
// This prefix is not in our forum list
continue;
}
}

if($prefix['groups'] != "-1")
{
$prefix_groups = explode(",", $prefix['groups']);

foreach($groups as $group)

			{

			{

				$whereforum = " AND (','||forums||',' LIKE '%,{$fid},%' OR ','||forums||',' LIKE '%,-1,%' OR forums='')";





				if(in_array($group, $prefix_groups) && !isset($prefixes[$prefix['pid']]))
{
// Our group can use this prefix!
$prefixes[$prefix['pid']] = $prefix;
}

			}

			}

			
$query = $db->query("
SELECT pid, prefix
FROM ".TABLE_PREFIX."threadprefixes
WHERE ({$extra_sql}','||groups||',' LIKE '%,{$mybb->user['usergroup']},%' OR ','||groups||',' LIKE '%,-1,%' OR groups='')
{$whereforum}
");
break;
default:
$whereforum = "";
if($fid != 'all')
{
$whereforum = " AND (CONCAT(',',forums,',') LIKE '%,{$fid},%' OR CONCAT(',',forums,',') LIKE '%,-1,%' OR forums='')";
}

$query = $db->query("
SELECT pid, prefix
FROM ".TABLE_PREFIX."threadprefixes
WHERE ({$extra_sql}CONCAT(',',groups,',') LIKE '%,{$mybb->user['usergroup']},%' OR CONCAT(',',groups,',') LIKE '%,-1,%' OR groups='')
{$whereforum}
");
}

$prefixselect = "";

if($db->num_rows($query) > 0)
{
$multipleselect = "";
if($multiple != 0)

		}
else




























		{

		{

			$multipleselect = " multiple=\"multiple\" size=\"5\"";


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

		}

		}

		
$prefixselect = "<select name=\"threadprefix\"{$multipleselect}>\n";

if($multiple == 1)
{
$any_selected = "";
if($selected_pid == 'any')
{
$any_selected = " selected=\"selected\"";
}

$prefixselect .= "<option value=\"any\"".$any_selected.">".$lang->any_prefix."</option>\n";
}

$default_selected = "";
if((intval($selected_pid) == 0) && $selected_pid != 'any')
{
$default_selected = " selected=\"selected\"";
}

$prefixselect .= "<option value=\"0\"".$default_selected.">".$lang->no_prefix."</option>\n";

while($prefix = $db->fetch_array($query))
{
$selected = "";
if($prefix['pid'] == $selected_pid)
{
$selected = " selected=\"selected\"";
}

$prefixselect .= "<option value=\"".$prefix['pid']."\"".$selected.">".htmlspecialchars_uni($prefix['prefix'])."</option>\n";











	}

if(empty($prefixes))
{
return false;
}

$prefixselect = "";
$multipleselect = "";
if($multiple != 0)
{
$multipleselect = " multiple=\"multiple\" size=\"5\"";
}

$prefixselect = "<select name=\"threadprefix\"{$multipleselect}>\n";

if($multiple == 1)
{
$any_selected = "";
if($selected_pid == 'any')
{
$any_selected = " selected=\"selected\"";
}

$prefixselect .= "<option value=\"any\"".$any_selected.">".$lang->any_prefix."</option>\n";
}

$default_selected = "";
if((intval($selected_pid) == 0) && $selected_pid != 'any')
{
$default_selected = " selected=\"selected\"";
}

$prefixselect .= "<option value=\"0\"".$default_selected.">".$lang->no_prefix."</option>\n";

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

		}

		}

		
$prefixselect .= "</select>\n&nbsp;";


$prefixselect .= "<option value=\"".$prefix['pid']."\"".$selected.">".htmlspecialchars_uni($prefix['prefix'])."</option>\n";

	}

	}

	




$prefixselect .= "</select>\n&nbsp;";


	return $prefixselect;
}


	return $prefixselect;
}


Zeile 2634Zeile 2783
		}

if(my_strpos(" ".$httpaccept_encoding, "gzip"))

		}

if(my_strpos(" ".$httpaccept_encoding, "gzip"))

		{

		{

			$encoding = "gzip";
}

			$encoding = "gzip";
}





		if(isset($encoding))
{
header("Content-Encoding: $encoding");

		if(isset($encoding))
{
header("Content-Encoding: $encoding");

Zeile 2645Zeile 2794
			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 2787Zeile 2936
 */
function get_ip()
{

 */
function get_ip()
{

	if(isset($_SERVER['REMOTE_ADDR']))
{
$ip = $_SERVER['REMOTE_ADDR'];
}
elseif(isset($_SERVER['HTTP_X_FORWARDED_FOR']))
{
if(preg_match_all("#[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}#s", $_SERVER['HTTP_X_FORWARDED_FOR'], $addresses))















    global $mybb, $plugins;

$ip = 0;

if(!preg_match("#^(10|172\.16|192\.168)\.#", $_SERVER['REMOTE_ADDR']))
{
$ip = $_SERVER['REMOTE_ADDR'];
}

if($mybb->settings['ip_forwarded_check'])
{
if(isset($_SERVER['HTTP_X_FORWARDED_FOR']))
{
preg_match_all("#[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}#s", $_SERVER['HTTP_X_FORWARDED_FOR'], $addresses);
}
elseif(isset($_SERVER['HTTP_X_REAL_IP']))
{
preg_match_all("#[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}#s", $_SERVER['HTTP_X_REAL_IP'], $addresses);
}

if(is_array($addresses[0]))

		{
foreach($addresses[0] as $key => $val)
{

		{
foreach($addresses[0] as $key => $val)
{

Zeile 2804Zeile 2967
				}
}
}

				}
}
}

	}









    }

if(!$ip)
{
if(isset($_SERVER['HTTP_CLIENT_IP']))
{
$ip = $_SERVER['HTTP_CLIENT_IP'];
}
}





	if(!isset($ip))
{
if(isset($_SERVER['HTTP_CLIENT_IP']))
{
$ip = $_SERVER['HTTP_CLIENT_IP'];
}
else
{
$ip = '';
}
}

    if($plugins)
{
$ip_array = array("ip" => &$ip); // Used for backwards compatibility on this hook with the updated run_hooks() function.
$plugins->run_hooks("get_ip", $ip_array);
}











	$ip = preg_replace("#([^.0-9 ]*)#", "", $ip);
return $ip;

    return $ip;


}

/**

}

/**

Zeile 2917Zeile 3081
			}
}
elseif(defined("IN_PORTAL"))

			}
}
elseif(defined("IN_PORTAL"))

		{
global $change_dir;

		{
global $change_dir;

			$icon = $change_dir."/".str_replace("{theme}", $theme['imgdir'], $attachtypes[$ext]['icon']);
}
else

			$icon = $change_dir."/".str_replace("{theme}", $theme['imgdir'], $attachtypes[$ext]['icon']);
}
else

Zeile 2958Zeile 3122
	if(!$permissions)
{
$permissions = $mybb->usergroup;

	if(!$permissions)
{
$permissions = $mybb->usergroup;

	}


	}


	if(!is_array($forum_cache))
{
cache_forums();

	if(!is_array($forum_cache))
{
cache_forums();

Zeile 2980Zeile 3144
		else
{
$perms = $mybb->usergroup;

		else
{
$perms = $mybb->usergroup;

		}

		}


$pwverified = 1;



$pwverified = 1;


Zeile 3002Zeile 3166
				if(isset($password_forums[$parent]) && $mybb->cookies['forumpass'][$parent] != md5($mybb->user['uid'].$password_forums[$parent]))
{
$pwverified = 0;

				if(isset($password_forums[$parent]) && $mybb->cookies['forumpass'][$parent] != md5($mybb->user['uid'].$password_forums[$parent]))
{
$pwverified = 0;

				}
}
}


				}
}
}


		if($perms['canview'] == 0 || $pwverified == 0 || ($only_readable_threads == true && $perms['canviewthreads'] == 0))
{
if($unviewableforums)

		if($perms['canview'] == 0 || $pwverified == 0 || ($only_readable_threads == true && $perms['canviewthreads'] == 0))
{
if($unviewableforums)

Zeile 3014Zeile 3178
			}

$unviewableforums .= "'".$forum['fid']."'";

			}

$unviewableforums .= "'".$forum['fid']."'";

		}
}


		}
}


	return $unviewableforums;
}


	return $unviewableforums;
}


Zeile 3060Zeile 3224
				if(isset($navbits[$key+2]))
{
$sep = $navsep;

				if(isset($navbits[$key+2]))
{
$sep = $navsep;

				}

				}

				else
{
$sep = "";

				else
{
$sep = "";

Zeile 3078Zeile 3242
						$sep = $multipage_dropdown.$sep;
}
}

						$sep = $multipage_dropdown.$sep;
}
}

				






// Replace page 1 URLs
$navbit['url'] = str_replace("-page-1.html", ".html", $navbit['url']);
$navbit['url'] = preg_replace("/&amp;page=1$/", "", $navbit['url']);


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

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

	}

	}


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


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

Zeile 3093Zeile 3261
	}

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

	}

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

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

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


return $donenav;
}


return $donenav;
}

Zeile 3168Zeile 3336
					$navbits[$navsize]['url'] = get_forum_link($forumnav['fid'], $multipage['current_page']);

$navbits[$navsize]['multipage'] = $multipage;

					$navbits[$navsize]['url'] = get_forum_link($forumnav['fid'], $multipage['current_page']);

$navbits[$navsize]['multipage'] = $multipage;

					$navbits[$navsize]['multipage']['url'] = get_forum_link($forumnav['fid']);

					$navbits[$navsize]['multipage']['url'] = str_replace('{fid}', $forumnav['fid'], FORUM_URL_PAGED);

				}
else
{

				}
else
{

Zeile 3368Zeile 3536
{
global $mybb;


{
global $mybb;


	if($mybb->settings['nocacheheaders'] == 1 && $mybb->settings['standardheaders'] != 1)

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

	{
header("Expires: Sat, 1 Jan 2000 01:00:00 GMT");
header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");

	{
header("Expires: Sat, 1 Jan 2000 01:00:00 GMT");
header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");

Zeile 3616Zeile 3784
	// Build the new list of additional groups for this user and make sure they're in the right format
$usergroups = "";
$usergroups = $user['additionalgroups'].",".$joingroup;

	// Build the new list of additional groups for this user and make sure they're in the right format
$usergroups = "";
$usergroups = $user['additionalgroups'].",".$joingroup;

	$groupslist = "";
$groups = explode(",", $usergroups);

if(is_array($groups))
{
foreach($groups as $gid)

	$groupslist = "";
$groups = explode(",", $usergroups);

if(is_array($groups))
{
foreach($groups as $gid)

		{
if(trim($gid) != "" && $gid != $user['usergroup'] && !$donegroup[$gid])
{

		{
if(trim($gid) != "" && $gid != $user['usergroup'] && !$donegroup[$gid])
{

Zeile 3637Zeile 3805
	{
$db->update_query("users", array('additionalgroups' => $groupslist), "uid='".intval($uid)."'");
return true;

	{
$db->update_query("users", array('additionalgroups' => $groupslist), "uid='".intval($uid)."'");
return true;

	}
else
{
return false;
}
}


	}
else
{
return false;
}
}


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

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

Zeile 3708Zeile 3876
function get_current_location($fields=false, $ignore=array())
{
if(defined("MYBB_LOCATION"))

function get_current_location($fields=false, $ignore=array())
{
if(defined("MYBB_LOCATION"))

	{

	{

		return MYBB_LOCATION;

		return MYBB_LOCATION;

	}

	}


if(!empty($_SERVER['PATH_INFO']))


if(!empty($_SERVER['PATH_INFO']))

	{

	{

		$location = htmlspecialchars_uni($_SERVER['PATH_INFO']);
}
elseif(!empty($_ENV['PATH_INFO']))
{
$location = htmlspecialchars_uni($_ENV['PATH_INFO']);

		$location = htmlspecialchars_uni($_SERVER['PATH_INFO']);
}
elseif(!empty($_ENV['PATH_INFO']))
{
$location = htmlspecialchars_uni($_ENV['PATH_INFO']);

	}

	}

	elseif(!empty($_ENV['PHP_SELF']))
{
$location = htmlspecialchars_uni($_ENV['PHP_SELF']);

	elseif(!empty($_ENV['PHP_SELF']))
{
$location = htmlspecialchars_uni($_ENV['PHP_SELF']);

Zeile 3751Zeile 3919
				}

$form_html .= "<input type=\"hidden\" name=\"".htmlspecialchars((string)$name)."\" value=\"".htmlspecialchars((string)$value)."\" />\n";

				}

$form_html .= "<input type=\"hidden\" name=\"".htmlspecialchars((string)$name)."\" value=\"".htmlspecialchars((string)$value)."\" />\n";

			}
}

			}
}

		
return array('location' => $location, 'form_html' => $form_html, 'form_method' => $mybb->request_method);
}

		
return array('location' => $location, 'form_html' => $form_html, 'form_method' => $mybb->request_method);
}

Zeile 3763Zeile 3931
			$location .= "?".htmlspecialchars_uni($_SERVER['QUERY_STRING']);
}
else if(isset($_ENV['QUERY_STRING']))

			$location .= "?".htmlspecialchars_uni($_SERVER['QUERY_STRING']);
}
else if(isset($_ENV['QUERY_STRING']))

		{

		{

			$location .= "?".htmlspecialchars_uni($_ENV['QUERY_STRING']);
}


			$location .= "?".htmlspecialchars_uni($_ENV['QUERY_STRING']);
}


Zeile 3774Zeile 3942
			foreach($post_array as $var)
{
if(isset($_POST[$var]))

			foreach($post_array as $var)
{
if(isset($_POST[$var]))

				{

				{

					$addloc[] = urlencode($var).'='.urlencode($_POST[$var]);
}
}

					$addloc[] = urlencode($var).'='.urlencode($_POST[$var]);
}
}

Zeile 3796Zeile 3964
		if(strlen($location) > 150)
{
$location = substr($location, 0, 150);

		if(strlen($location) > 150)
{
$location = substr($location, 0, 150);

		}

		}


return $location;
}


return $location;
}

Zeile 3971Zeile 4139
	}

if($use_iconv || $use_mb)

	}

if($use_iconv || $use_mb)

	{

	{

		if($to)
{
$from_charset = $lang->settings['charset'];

		if($to)
{
$from_charset = $lang->settings['charset'];

Zeile 4022Zeile 4190
	{
$message = convert_through_utf8($message);


	{
$message = convert_through_utf8($message);


		if(!($new_message = @preg_replace("#(?>[^\s&/<>\"\\-\.\[\]]{{$mybb->settings['wordwrap']}})#u", "$0&#8203;", $message)))

		if(!($new_message = @preg_replace("#(((?>[^\s&/<>\"\\-\[\]])|(&\#[a-z0-9]{1,10};)){{$mybb->settings['wordwrap']}})#u", "$0&#8203;", $message)))

		{

		{

			$new_message = preg_replace("#(?>[^\s&/<>\"\\-\.\[\]]{{$mybb->settings['wordwrap']}})#", "$0&#8203;", $message);	

			$new_message = preg_replace("#(((?>[^\s&/<>\"\\-\[\]])|(&\#[a-z0-9]{1,10};)){{$mybb->settings['wordwrap']}})#", "$0&#8203;", $message);	

		}

$new_message = convert_through_utf8($new_message, false);

		}

$new_message = convert_through_utf8($new_message, false);

Zeile 4149Zeile 4317
		'F',
'l',
'M',

		'F',
'l',
'M',

	);














	);

$html = array(
'&#109;',
'&#99;',
'&#68;',
'&#121;',
'&#89;',
'&#106;',
'&#83;',
'&#70;',
'&#108;',
'&#77;',
);





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


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

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

Zeile 4321Zeile 4505
	else
{
$string = strtolower($string);

	else
{
$string = strtolower($string);

	}

return $string;
}

	}

return $string;
}


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

Zeile 4335Zeile 4519
 * @return int false on needle not found, integer position if found
*/
function my_strpos($haystack, $needle, $offset=0)

 * @return int false on needle not found, integer position if found
*/
function my_strpos($haystack, $needle, $offset=0)

{

{

	if($needle == '')

	if($needle == '')

	{

	{

		return false;

		return false;

	}

	}


if(function_exists("mb_strpos"))


if(function_exists("mb_strpos"))

	{

	{

		$position = mb_strpos($haystack, $needle, $offset);

		$position = mb_strpos($haystack, $needle, $offset);

	}
else
{

	}
else
{

		$position = strpos($haystack, $needle, $offset);
}


		$position = strpos($haystack, $needle, $offset);
}


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

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

	{

	{

        return chr($c);

        return chr($c);

    }

    }

	else if($c <= 0x7FF)

	else if($c <= 0x7FF)

	{

	{

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

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

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

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

    }
else if($c <= 0x10FFFF)
{

    }
else if($c <= 0x10FFFF)
{

Zeile 4446Zeile 4630
 */
function get_event_date($event)
{

 */
function get_event_date($event)
{

 
	global $mybb;


	$event_date = explode("-", $event['date']);
$event_date = mktime(0, 0, 0, $event_date[1], $event_date[0], $event_date[2]);
$event_date = my_date($mybb->settings['dateformat'], $event_date);

	$event_date = explode("-", $event['date']);
$event_date = mktime(0, 0, 0, $event_date[1], $event_date[0], $event_date[2]);
$event_date = my_date($mybb->settings['dateformat'], $event_date);





	return $event_date;
}

/**
* Get the profile link.

	return $event_date;
}

/**
* Get the profile link.

 *

 *

 * @param int The user id of the profile.
* @return string The url to the profile.
*/

 * @param int The user id of the profile.
* @return string The url to the profile.
*/

Zeile 4499Zeile 4685
	{
// Return the guest's nickname if user is a guest but has a nickname
return $username;

	{
// Return the guest's nickname if user is a guest but has a nickname
return $username;

	}

	}

	else
{
// Build the profile link for the registered user

	else
{
// Build the profile link for the registered user

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

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

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

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

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

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

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

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

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

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

		}
else
{

		}
else
{

Zeile 4587Zeile 4773
 * @param int The thread id of the post.
*/
function get_post_link($pid, $tid=0)

 * @param int The thread id of the post.
*/
function get_post_link($pid, $tid=0)

{

{

	if($tid > 0)
{
$link = str_replace("{tid}", $tid, THREAD_URL_POST);

	if($tid > 0)
{
$link = str_replace("{tid}", $tid, THREAD_URL_POST);

Zeile 4700Zeile 4886
		return $user_cache[$uid];
}
}

		return $user_cache[$uid];
}
}



 

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


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

Zeile 4762Zeile 4947
	{
$query = $db->simple_select("threads", "*", "tid='".intval($tid)."'");
$thread = $db->fetch_array($query);

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





		if($thread)

		if($thread)

		{

		{

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

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

		}

		}

		else
{
$thread_cache[$tid] = false;

		else
{
$thread_cache[$tid] = false;

			return false;
}
}

			return false;
}
}

}

/**

}

/**

Zeile 4795Zeile 4980
	{
$query = $db->simple_select("posts", "*", "pid='".intval($pid)."'");
$post = $db->fetch_array($query);

	{
$query = $db->simple_select("posts", "*", "pid='".intval($pid)."'");
$post = $db->fetch_array($query);





		if($post)

		if($post)

		{

		{

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

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

Zeile 4805Zeile 4990
		{
$post_cache[$pid] = false;
return false;

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

		}
}

		}
}

}

/**

}

/**

Zeile 4817Zeile 5002
function get_inactive_forums()
{
global $forum_cache, $cache, $inactiveforums;

function get_inactive_forums()
{
global $forum_cache, $cache, $inactiveforums;





	if(!$forum_cache)
{
cache_forums();

	if(!$forum_cache)
{
cache_forums();

Zeile 4850Zeile 5035
 *
* @param bool (Optional) The function will 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 (Optional) The function will stop execution if it finds an error with the login. Default is True
* @return bool Number of logins when success, false if failed.

 */

 */

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

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

Zeile 5050Zeile 5235
	{
$mybb->settings['minsearchword'] = 3;
}

	{
$mybb->settings['minsearchword'] = 3;
}

 

if(is_array($terms))
{
$terms = implode(' ', $terms);
}


// Strip out any characters that shouldn't be included
$bad_characters = array(


// Strip out any characters that shouldn't be included
$bad_characters = array(

Zeile 5074Zeile 5264
				if($inquote)
{
$words[] = trim($phrase);

				if($inquote)
{
$words[] = trim($phrase);

				}

				}

				else
{
$split_words = preg_split("#\s{1,}#", $phrase, -1);
if(!is_array($split_words))
{
continue;

				else
{
$split_words = preg_split("#\s{1,}#", $phrase, -1);
if(!is_array($split_words))
{
continue;

					}

					}

					foreach($split_words as $word)
{
if(!$word || strlen($word) < $mybb->settings['minsearchword'])

					foreach($split_words as $word)
{
if(!$word || strlen($word) < $mybb->settings['minsearchword'])

Zeile 5100Zeile 5290
	{
$terms = htmlspecialchars_uni($terms);
$split_words = preg_split("#\s{1,}#", $terms, -1);

	{
$terms = htmlspecialchars_uni($terms);
$split_words = preg_split("#\s{1,}#", $terms, -1);

		if(!is_array($split_words))

		if(is_array($split_words))

		{

		{

			continue;
}
foreach($split_words as $word)
{
if(!$word || strlen($word) < $mybb->settings['minsearchword'])

			foreach($split_words as $word)





			{

			{

				continue;





				if(!$word || strlen($word) < $mybb->settings['minsearchword'])
{
continue;
}
$words[] = trim($word);

			}

			}

			$words[] = trim($word);

 
		}

		}



 
	}

if(!is_array($words))

	}

if(!is_array($words))

	{

	{

		return false;
}


		return false;
}


Zeile 5138Zeile 5326
		}

// Now make PREG compatible

		}

// Now make PREG compatible

		$find = "#(?!<.*?)(".preg_quote($word, "#").")(?![^<>]*?>)#i";

		$find = "#(?!<.*?)(".preg_quote($word, "#").")(?![^<>]*?>)#ui";

		$replacement = "<span class=\"highlight\" style=\"padding-left: 0px; padding-right: 0px;\">$1</span>";
$highlight_cache[$find] = $replacement;
}

		$replacement = "<span class=\"highlight\" style=\"padding-left: 0px; padding-right: 0px;\">$1</span>";
$highlight_cache[$find] = $replacement;
}

Zeile 5147Zeile 5335
}

/**

}

/**

 * Converts a decimal reference of a character to its UTF-8 equivilant

 * 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

 * (Code by Anne van Kesteren, http://annevankesteren.nl/2005/05/character-references)
*
* @param string Decimal value of a character reference

Zeile 5181Zeile 5369
		$dest .= chr(0x80 | (($src >> 12) & 0x3f));
$dest .= chr(0x80 | (($src >> 6) & 0x3f));
$dest .= chr(0x80 | ($src & 0x3f));

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

	}

	}

	else
{
// Out of range

	else
{
// Out of range

Zeile 5203Zeile 5391
	global $db;
$query = $db->simple_select('banfilters', 'filter, fid', "type='2'");
while($banned_username = $db->fetch_array($query))

	global $db;
$query = $db->simple_select('banfilters', 'filter, fid', "type='2'");
while($banned_username = $db->fetch_array($query))

	{
// Make regular expression * match

	{
// Make regular expression * match

		$banned_username['filter'] = str_replace('\*', '(.*)', preg_quote($banned_username['filter'], '#'));
if(preg_match("#(^|\b){$banned_username['filter']}($|\b)#i", $username))
{

		$banned_username['filter'] = str_replace('\*', '(.*)', preg_quote($banned_username['filter'], '#'));
if(preg_match("#(^|\b){$banned_username['filter']}($|\b)#i", $username))
{

Zeile 5212Zeile 5400
			if($update_lastuse == true)
{
$db->update_query("banfilters", array("lastuse" => TIME_NOW), "fid='{$banned_username['fid']}'");

			if($update_lastuse == true)
{
$db->update_query("banfilters", array("lastuse" => TIME_NOW), "fid='{$banned_username['fid']}'");

			}

			}

			return true;
}
}

			return true;
}
}

Zeile 5228Zeile 5416
 * @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)

{
global $db;
$query = $db->simple_select("banfilters", "*", "type='3'");
while($banned_email = $db->fetch_array($query))
{
// Make regular expression * match
$banned_email['filter'] = str_replace('\*', '(.*)', preg_quote($banned_email['filter'], '#'));
if(preg_match("#{$banned_email['filter']}#i", $email))








{
global $cache, $db;

$banned_cache = $cache->read("bannedemails");

if($banned_cache === false)
{
// Failed to read cache, see if we can rebuild it
$cache->update_bannedemails();
$banned_cache = $cache->read("bannedemails");
}

if(is_array($banned_cache) && !empty($banned_cache))
{
foreach($banned_cache as $banned_email)

		{

		{

			// Updating last use
if($update_lastuse == true)



			// Make regular expression * match
$banned_email['filter'] = str_replace('\*', '(.*)', preg_quote($banned_email['filter'], '#'));

if(preg_match("#{$banned_email['filter']}#i", $email))

			{

			{

				$db->update_query("banfilters", array("lastuse" => TIME_NOW), "fid='{$banned_email['fid']}'");






				// Updating last use
if($update_lastuse == true)
{
$db->update_query("banfilters", array("lastuse" => TIME_NOW), "fid='{$banned_email['fid']}'");
}
return true;

			}

			}

			return true;

 
		}
}

		}
}

 


	// Still here - good email
return false;
}

	// Still here - good email
return false;
}

Zeile 5264Zeile 5466
	if(!is_array($banned_ips))
{
return false;

	if(!is_array($banned_ips))
{
return false;

	}

	}

	
foreach($banned_ips as $banned_ip)
{

	
foreach($banned_ips as $banned_ip)
{

Zeile 5275Zeile 5477
		
// Make regular expression * match
$banned_ip['filter'] = str_replace('\*', '(.*)', preg_quote($banned_ip['filter'], '#'));

		
// Make regular expression * match
$banned_ip['filter'] = str_replace('\*', '(.*)', preg_quote($banned_ip['filter'], '#'));

		if(preg_match("#{$banned_ip['filter']}#i", $ip_address))

		if(preg_match("#^{$banned_ip['filter']}$#i", $ip_address))

		{
// Updating last use
if($update_lastuse == true)

		{
// Updating last use
if($update_lastuse == true)

Zeile 5285Zeile 5487
			return true;
}
}

			return true;
}
}

 


	// Still here - good ip
return false;
}

	// Still here - good ip
return false;
}

Zeile 5377Zeile 5580
 *
* @param string The URL of the remote file
* @return string The remote file contents.

 *
* @param string The URL of the remote file
* @return string The remote file contents.

 */

 */

function fetch_remote_file($url, $post_data=array())
{
$post_body = '';

function fetch_remote_file($url, $post_data=array())
{
$post_body = '';

Zeile 5410Zeile 5613
	{
$url = @parse_url($url);
if(!$url['host'])

	{
$url = @parse_url($url);
if(!$url['host'])

		{
return false;
}

		{
return false;
}

		if(!$url['port'])
{
$url['port'] = 80;

		if(!$url['port'])
{
$url['port'] = 80;

Zeile 5430Zeile 5633
		if(!$fp)
{
return false;

		if(!$fp)
{
return false;

		}

		}

		$headers = array();
if(!empty($post_body))

		$headers = array();
if(!empty($post_body))

		{

		{

			$headers[] = "POST {$url['path']} HTTP/1.0";
$headers[] = "Content-Length: ".strlen($post_body);
$headers[] = "Content-Type: application/x-www-form-urlencoded";
}

			$headers[] = "POST {$url['path']} HTTP/1.0";
$headers[] = "Content-Length: ".strlen($post_body);
$headers[] = "Content-Type: application/x-www-form-urlencoded";
}

		else
{
$headers[] = "GET {$url['path']} HTTP/1.0";
}


		else
{
$headers[] = "GET {$url['path']} HTTP/1.0";
}


		$headers[] = "Host: {$url['host']}";
$headers[] = "Connection: Close";

		$headers[] = "Host: {$url['host']}";
$headers[] = "Connection: Close";

		$headers[] = "\r\n";

		$headers[] = '';

		
if(!empty($post_body))

		
if(!empty($post_body))

		{

		{

			$headers[] = $post_body;

			$headers[] = $post_body;

 
		}
else
{
// If we have no post body, we need to add an empty element to make sure we've got \r\n\r\n before the (non-existent) body starts
$headers[] = '';

		}

$headers = implode("\r\n", $headers);

		}

$headers = implode("\r\n", $headers);

Zeile 5561Zeile 5769
 * Fetch an IPv4 long formatted range for searching IPv4 IP addresses.
*
* @param string The IP address to convert to a range based LONG

 * 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 equivilent, otherwise an array of the upper & lower extremities of the IP

 * @rturn mixed 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 5636Zeile 5844
		"0-0-1" => "1 {$lang->year}",
"0-0-2" => "2 {$lang->years}"
);

		"0-0-1" => "1 {$lang->year}",
"0-0-2" => "2 {$lang->years}"
);


$plugins->run_hooks_by_ref("functions_fetch_ban_times", $ban_times);


$ban_times = $plugins->run_hooks("functions_fetch_ban_times", $ban_times);


$ban_times['---'] = $lang->permanent;
return $ban_times;


$ban_times['---'] = $lang->permanent;
return $ban_times;

Zeile 5649Zeile 5857
 * @param string The ban length string
* @param int The optional UNIX timestamp, if 0, current time is used.
* @return int The UNIX timestamp when the ban will be lifted

 * @param string The ban length string
* @param int 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)
{
if($stamp == 0)

function ban_date2timestamp($date, $stamp=0)
{
if($stamp == 0)

Zeile 5710Zeile 5918
		);
$db->update_query("users", $updated_user, "uid='".intval($uid)."'");
}

		);
$db->update_query("users", $updated_user, "uid='".intval($uid)."'");
}

}

/**
* Unicode function for php function chr()
*
* @param string The character
* @return mixed The unicoded chr()
*/
function unicode_chr($c)
{
if($c <= 0x7F)
{
return chr($c);
}
elseif($c <= 0x7FF)
{
return chr(0xC0 | $c >> 6) . chr(0x80 | $c & 0x3F);
}
elseif($c <= 0xFFFF)
{
return chr(0xE0 | $c >> 12) . chr(0x80 | $c >> 6 & 0x3F)
. chr(0x80 | $c & 0x3F);
}
elseif($c <= 0x10FFFF)
{
return chr(0xF0 | $c >> 18) . chr(0x80 | $c >> 12 & 0x3F)
. chr(0x80 | $c >> 6 & 0x3F)
. chr(0x80 | $c & 0x3F);
}
else
{
return false;
}

 
}

/**

}

/**

Zeile 5757Zeile 5932
	if(substr($mode, 0, 1) != '0' || strlen($mode) !== 4)
{
return false;

	if(substr($mode, 0, 1) != '0' || strlen($mode) !== 4)
{
return false;

	}

	}

	$old_umask = umask(0);

// We convert the octal string to a decimal number because passing a octal string doesn't work with chmod

	$old_umask = umask(0);

// We convert the octal string to a decimal number because passing a octal string doesn't work with chmod

Zeile 5765Zeile 5940
	$result = chmod($file, octdec($mode));
umask($old_umask);
return $result;

	$result = chmod($file, octdec($mode));
umask($old_umask);
return $result;

}


}


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

Zeile 5776Zeile 5951
function my_rmdir_recursive($path, $ignore=array())
{
global $orig_dir;

function my_rmdir_recursive($path, $ignore=array())
{
global $orig_dir;

	

	

	if(!isset($orig_dir))
{
$orig_dir = $path;

	if(!isset($orig_dir))
{
$orig_dir = $path;

Zeile 5806Zeile 5981
    }

return @unlink($path);

    }

return @unlink($path);

}

}


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

Zeile 5834Zeile 6009
 */
function my_ip2long($ip)
{

 */
function my_ip2long($ip)
{

	$ip = ip2long($ip);
if($ip >= 2147483648) // Won't occur on 32-bit PHP












	$ip_long = ip2long($ip);

if(!$ip_long)
{
$ip_long = sprintf("%u", ip2long($ip));

if(!$ip_long)
{
return 0;
}
}

if($ip_long >= 2147483648) // Won't occur on 32-bit PHP

	{

	{

		$ip -= 4294967296;

		$ip_long -= 4294967296;

	}

	}

	return $ip;



return $ip_long;

}

/**

}

/**

Zeile 5959Zeile 6146
 * Returns a signed value equal to an integer
*
* @param int The integer

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

 * @return string The signed equivallent

 * @return string The signed equivalent

 */
function signed($int)
{

 */
function signed($int)
{

Zeile 5977Zeile 6164
 * 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)

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

 * @return int An integer equivilent of a secure hexadecimal seed

 * @return int An integer equivalent of a secure hexadecimal seed

 */
function secure_seed_rng($count=8)
{

 */
function secure_seed_rng($count=8)
{

Zeile 6017Zeile 6204
 * @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 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

 * @return int An integer equivilent of a secure hexadecimal seed

 * @return int An integer equivalent of a secure hexadecimal seed

 */
function my_rand($min=null, $max=null, $force_seed=false)
{

 */
function my_rand($min=null, $max=null, $force_seed=false)
{

Zeile 6073Zeile 6260
		0x0A => 1,
0x0D => 1,
0x0B => 1,

		0x0A => 1,
0x0D => 1,
0x0B => 1,

 
		0xAD => 1,
0xA0 => 1,
0xAD => 1,
0xBF => 1,
0x81 => 1,
0x8D => 1,
0x90 => 1,
0x9D => 1,

		0xCC => array(0xB7 => 1, 0xB8 => 1), // \x{0337} or \x{0338}
0xE1 => array(0x85 => array(0x9F => 1, 0xA0 => 1)), // \x{115F} or \x{1160}
0xE2 => array(0x80 => array(0x80 => 1, 0x81 => 1, 0x82 => 1, 0x83 => 1, 0x84 => 1, 0x85 => 1, 0x86 => 1, 0x87 => 1, 0x88 => 1, 0x89 => 1, 0x8A => 1, 0x8B => 1, // \x{2000} to \x{200B}

		0xCC => array(0xB7 => 1, 0xB8 => 1), // \x{0337} or \x{0338}
0xE1 => array(0x85 => array(0x9F => 1, 0xA0 => 1)), // \x{115F} or \x{1160}
0xE2 => array(0x80 => array(0x80 => 1, 0x81 => 1, 0x82 => 1, 0x83 => 1, 0x84 => 1, 0x85 => 1, 0x86 => 1, 0x87 => 1, 0x88 => 1, 0x89 => 1, 0x8A => 1, 0x8B => 1, // \x{2000} to \x{200B}

Zeile 6091Zeile 6286
		0x0A => 1,
0x0D => 1,
0x0B => 1,

		0x0A => 1,
0x0D => 1,
0x0B => 1,

 
		0xA0 => array(0xC2 => 1),
0xAD => array(0xC2 => 1),
0xBF => array(0xC2 => 1),
0x81 => array(0xC2 => 1),
0x8D => array(0xC2 => 1),
0x90 => array(0xC2 => 1),
0x9D => array(0xC2 => 1),

		0xB8 => array(0xCC => 1), // \x{0338}
0xB7 => array(0xCC => 1), // \x{0337}
0xA0 => array(0x85 => array(0xE1 => 1)), // \x{1160}

		0xB8 => array(0xCC => 1), // \x{0338}
0xB7 => array(0xCC => 1), // \x{0337}
0xA0 => array(0x85 => array(0xE1 => 1)), // \x{1160}