Vergleich inc/functions.php - 1.4.2 - 1.4.16

  Keine Änderungen   Hinzugefügt   Modifiziert   Entfernt
Zeile 1Zeile 1
<?php
/**
* MyBB 1.4

<?php
/**
* MyBB 1.4

 * Copyright � 2008 MyBB Group, All Rights Reserved

 * Copyright © 2008 MyBB Group, All Rights Reserved

 *
* Website: http://www.mybboard.net
* License: http://www.mybboard.net/about/license
*

 *
* Website: http://www.mybboard.net
* License: http://www.mybboard.net/about/license
*

 * $Id: functions.php 4182 2008-09-07 18:05:30Z Tikitiki $

 * $Id: functions.php 5379 2011-02-21 11:06:42Z Tomm $

 */

/**

 */

/**

Zeile 154Zeile 154
	// If our DB has been deconstructed already (bad PHP 5.2.0), reconstruct
if(!is_object($db))
{

	// If our DB has been deconstructed already (bad PHP 5.2.0), reconstruct
if(!is_object($db))
{

		if(!isset($config))

		if(!isset($config) || empty($config['database']['type']))

		{
require MYBB_ROOT."inc/config.php";
}

		{
require MYBB_ROOT."inc/config.php";
}

Zeile 228Zeile 228
/**
* 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 20)

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

 */
function send_mail_queue($count=10)
{

 */
function send_mail_queue($count=10)
{

Zeile 409Zeile 409
 * @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 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.

 */

 */

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

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

{
global $mybb;
static $mail;

{
global $mybb;
static $mail;

Zeile 451Zeile 454
	}

// Build and send

	}

// Build and send

	$mail->build_message($to, $subject, $message, $from, $charset, $headers, $format, $message_text);

	$mail->build_message($to, $subject, $message, $from, $charset, $headers, $format, $message_text, $return_email);

	return $mail->send();
}


	return $mail->send();
}


Zeile 470Zeile 473
	// Guests get a special string
else
{

	// Guests get a special string
else
{

		return md5($mybb->config['database']['hostname'].$mybb->config['database']['username'].md5($mybb->config['database']['password']));

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

	}
}


	}
}


Zeile 491Zeile 494
		}
else
{

		}
else
{

			error($lang->invalid_post_code);








			if(defined("IN_ADMINCP"))
{
return false;
}
else
{
error($lang->invalid_post_code);
}

		}
}
else
{
return true;

		}
}
else
{
return true;

	}
}

/**

	}
}

/**

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

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

Zeile 516Zeile 526
		return $forumarraycache[$fid]['parentlist'];
}
elseif($forum_cache[$fid])

		return $forumarraycache[$fid]['parentlist'];
}
elseif($forum_cache[$fid])

	{
return $forum_cache[$fid]['parentlist'];
}

	{
return $forum_cache[$fid]['parentlist'];
}

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

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

	}
}

/**

	}
}

/**

 * Build a parent list of a specific forum, suitable for querying
*
* @param int The forum ID

 * Build a parent list of a specific forum, suitable for querying
*
* @param int The forum ID

Zeile 561Zeile 571
 * Load the forum cache in to memory
*
* @param boolean True to force a reload of the cache

 * Load the forum cache in to memory
*
* @param boolean True to force a reload of the cache

 */

 */

function cache_forums($force=false)
{
global $forum_cache, $cache;

function cache_forums($force=false)
{
global $forum_cache, $cache;

Zeile 710Zeile 720
function error_no_permission()
{
global $mybb, $theme, $templates, $db, $lang, $plugins, $session;

function error_no_permission()
{
global $mybb, $theme, $templates, $db, $lang, $plugins, $session;


$time = TIME_NOW;


$time = TIME_NOW;

	$plugins->run_hooks("no_permission");

	$plugins->run_hooks("no_permission");





	$noperm_array = array (
"nopermission" => '1',
"location1" => 0,
"location2" => 0
);

	$noperm_array = array (
"nopermission" => '1',
"location1" => 0,
"location2" => 0
);





	$db->update_query("sessions", $noperm_array, "sid='{$session->sid}'", 1);
$url = htmlspecialchars_uni($_SERVER['REQUEST_URI']);


	$db->update_query("sessions", $noperm_array, "sid='{$session->sid}'", 1);
$url = htmlspecialchars_uni($_SERVER['REQUEST_URI']);


Zeile 728Zeile 738
		// Send our headers.
header("Content-type: text/html; charset={$lang->settings['charset']}");
echo "<error>{$lang->error_nopermission_user_ajax}</error>\n";

		// Send our headers.
header("Content-type: text/html; charset={$lang->settings['charset']}");
echo "<error>{$lang->error_nopermission_user_ajax}</error>\n";

		exit;

		exit;

	}

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

	}

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

Zeile 737Zeile 747
		eval("\$errorpage = \"".$templates->get("error_nopermission_loggedin")."\";");
}
else

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

	{

	{

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


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


Zeile 765Zeile 775
		echo "<script type=\"text/javascript\">\n";
if($message != "")
{

		echo "<script type=\"text/javascript\">\n";
if($message != "")
{

			echo "alert('{$message}');\n";

			echo 'alert("'.addslashes($message).'");';

		}
$url = str_replace("#", "&#", $url);
$url = htmlspecialchars_decode($url);
$url = str_replace(array("\n","\r",";"), "", $url);

		}
$url = str_replace("#", "&#", $url);
$url = htmlspecialchars_decode($url);
$url = str_replace(array("\n","\r",";"), "", $url);

		echo "window.location = '{$url}';\n";

		echo 'window.location = "'.addslashes($url).'";'."\n";

		echo "</script>\n";
exit;
}

if(!$message)

		echo "</script>\n";
exit;
}

if(!$message)

	{

	{

		$message = $lang->redirect;

		$message = $lang->redirect;

	}


	}


	$time = TIME_NOW;
$timenow = my_date($mybb->settings['dateformat'], $time) . " " . my_date($mybb->settings['timeformat'], $time);

if(!$title)
{
$title = $mybb->settings['bbname'];

	$time = TIME_NOW;
$timenow = my_date($mybb->settings['dateformat'], $time) . " " . my_date($mybb->settings['timeformat'], $time);

if(!$title)
{
$title = $mybb->settings['bbname'];

	}


	}


	// 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']))
{

Zeile 799Zeile 809
	}
else
{

	}
else
{

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

 
		$url = htmlspecialchars_decode($url);
$url = str_replace(array("\n","\r",";"), "", $url);


		$url = htmlspecialchars_decode($url);
$url = str_replace(array("\n","\r",";"), "", $url);


Zeile 826Zeile 835
	if($count <= $perpage)
{
return;

	if($count <= $perpage)
{
return;

	}

	}

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

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

Zeile 844Zeile 853
	if(!$mybb->settings['maxmultipagelinks'])
{
$mybb->settings['maxmultipagelinks'] = 5;

	if(!$mybb->settings['maxmultipagelinks'])
{
$mybb->settings['maxmultipagelinks'] = 5;

	}


	}


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


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


Zeile 862Zeile 871
		if($from <= 0)
{
$from = 1;

		if($from <= 0)
{
$from = 1;

		}
}

		}
}


if($to == 0)
{


if($to == 0)
{

Zeile 990Zeile 999
function usergroup_permissions($gid=0)
{
global $cache, $groupscache, $grouppermignore, $groupzerogreater;

function usergroup_permissions($gid=0)
{
global $cache, $groupscache, $grouppermignore, $groupzerogreater;



	

	if(!is_array($groupscache))

	if(!is_array($groupscache))

	{

	{

		$groupscache = $cache->read("usergroups");

		$groupscache = $cache->read("usergroups");

	}

$groups = explode(",", $gid);

	}







 
	$groups = explode(",", $gid);


if(count($groups) == 1)
{


if(count($groups) == 1)
{

Zeile 1007Zeile 1015
	foreach($groups as $gid)
{
if(trim($gid) == "" || !$groupscache[$gid])

	foreach($groups as $gid)
{
if(trim($gid) == "" || !$groupscache[$gid])

		{

		{

			continue;
}

			continue;
}



		

		foreach($groupscache[$gid] as $perm => $access)
{
if(!in_array($perm, $grouppermignore))

		foreach($groupscache[$gid] as $perm => $access)
{
if(!in_array($perm, $grouppermignore))

			{

			{

				if(isset($usergroup[$perm]))

				if(isset($usergroup[$perm]))

				{

				{

					$permbit = $usergroup[$perm];

					$permbit = $usergroup[$perm];

				}

				}

				else

				else

				{

				{

					$permbit = "";

					$permbit = "";

				}

if(in_array($perm, $groupzerogreater))
{
if($access == 0)
{
$usergroup[$perm] = 0;
continue;
}

				}

// 0 represents unlimited for numerical group permissions (i.e. private message limit) so take that into account.
if(in_array($perm, $groupzerogreater) && ($access == 0 || $permbit === 0))
{
$usergroup[$perm] = 0;
continue;



				}

if($access > $permbit || ($access == "yes" && $permbit == "no") || !$permbit) // Keep yes/no for compatibility?

				}

if($access > $permbit || ($access == "yes" && $permbit == "no") || !$permbit) // Keep yes/no for compatibility?

Zeile 1065Zeile 1071
	foreach($displaygroupfields as $field)
{
$displaygroup[$field] = $group[$field];

	foreach($displaygroupfields as $field)
{
$displaygroup[$field] = $group[$field];

	}


	}


	return $displaygroup;
}


	return $displaygroup;
}


Zeile 1091Zeile 1097
	{
if($uid != 0 && $uid != $mybb->user['uid'])
{

	{
if($uid != 0 && $uid != $mybb->user['uid'])
{

			if($usercache[$uid])

			if(!$usercache[$uid])

			{
$query = $db->simple_select("users", "*", "uid='$uid'");
$usercache[$uid] = $db->fetch_array($query);

			{
$query = $db->simple_select("users", "*", "uid='$uid'");
$usercache[$uid] = $db->fetch_array($query);

			}


			}


			$gid = $usercache[$uid]['usergroup'].",".$usercache[$uid]['additionalgroups'];
$groupperms = usergroup_permissions($gid);
}

			$gid = $usercache[$uid]['usergroup'].",".$usercache[$uid]['additionalgroups'];
$groupperms = usergroup_permissions($gid);
}

Zeile 1261Zeile 1267
	$password = $forum_cache[$fid]['password'];
if($password)
{

	$password = $forum_cache[$fid]['password'];
if($password)
{

		if($mybb->input['pwverify'])

		if($mybb->input['pwverify'] && $pid == 0)

		{
if($password == $mybb->input['pwverify'])
{

		{
if($password == $mybb->input['pwverify'])
{

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

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

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

				$showform = true;
}
}
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 = false;
}

		}
}
else
{
$showform = false;
}

		}
}
else
{
$showform = false;
}


if($showform)
{


if($showform)
{

		$_SERVER['REQUEST_URI'] = htmlspecialchars_uni($_SERVER['REQUEST_URI']);
eval("\$pwform = \"".$templates->get("forumdisplay_password")."\";");
output_page($pwform);








		if($pid)
{
header("Location: ".$mybb->settings['bburl']."/".get_forum_link($fid));
}
else
{
$_SERVER['REQUEST_URI'] = htmlspecialchars_uni($_SERVER['REQUEST_URI']);
eval("\$pwform = \"".$templates->get("forumdisplay_password")."\";");
output_page($pwform);
}

		exit;
}
}

		exit;
}
}

Zeile 1344Zeile 1357
	else
{
$perms = $modpermscache[$fid][$uid];

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

	}


	}


	return $perms;
}


	return $perms;
}


Zeile 1468Zeile 1481

/**
* 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 string The cookie identifier.
* @param string The cookie value.
* @param int The timestamp of the expiry date.

Zeile 1481Zeile 1494
	if(!$mybb->settings['cookiepath'])
{
$mybb->settings['cookiepath'] = "/";

	if(!$mybb->settings['cookiepath'])
{
$mybb->settings['cookiepath'] = "/";

	}


	}


	if($expires == -1)

	if($expires == -1)

	{

	{

		$expires = 0;
}
elseif($expires == "" || $expires == null)
{
if($mybb->user['remember'] == 0)

		$expires = 0;
}
elseif($expires == "" || $expires == null)
{
if($mybb->user['remember'] == 0)

		{

		{

			$expires = 0;

			$expires = 0;

		}

		}

		else
{
$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 + intval($expires);

	else
{
$expires = TIME_NOW + intval($expires);

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

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

	}


	}


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

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





	header($cookie, false);
}

/**
* Unset a cookie set by MyBB.

	header($cookie, false);
}

/**
* 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 1545Zeile 1558
	global $mybb;

$expires = -3600;

	global $mybb;

$expires = -3600;

	my_setcookie($name, "", $expires);

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

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

	{

	{

		return false;

		return false;

	}

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

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

	}

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

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

		return $cookie[$id];
}
else

		return $cookie[$id];
}
else

Zeile 1591Zeile 1604
	
$cookie = $mybb->cookies['mybb'];
$newcookie = unserialize($cookie[$name]);

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

 

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


	$newcookie[$id] = $value;

	$newcookie[$id] = $value;

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




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

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

}

/**

}

/**

Zeile 1615Zeile 1638
			$serverload = explode(" ", $load);
$serverload[0] = round($serverload[0], 4);
}

			$serverload = explode(" ", $load);
$serverload[0] = round($serverload[0], 4);
}

		if(!$serverload)

		if(!is_numeric($serverload[0]))

		{
if(@ini_get('safe_mode') == 'On')
{

		{
if(@ini_get('safe_mode') == 'On')
{

Zeile 1640Zeile 1663
			}

$load = @exec("uptime");

			}

$load = @exec("uptime");

			$load = split("load averages?: ", $load);

			$load = explode("load average: ", $load);

			$serverload = explode(",", $load[1]);
if(!is_array($serverload))
{

			$serverload = explode(",", $load[1]);
if(!is_array($serverload))
{

Zeile 1827Zeile 1850

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


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

 
	
$cache->update_forums();

}

/**

}

/**

Zeile 1897Zeile 1922
			}
}
}

			}
}
}

 
	
$db->free_result($query);


// Only update if we're actually doing something
if(count($update_query) > 0)
{
$db->update_query("threads", $update_query, "tid='".intval($tid)."'");
}


// Only update if we're actually doing something
if(count($update_query) > 0)
{
$db->update_query("threads", $update_query, "tid='".intval($tid)."'");
}

 
	
unset($update_query, $thread);


update_thread_data($tid);
}


update_thread_data($tid);
}

Zeile 1915Zeile 1944
function update_thread_data($tid)
{
global $db;

function update_thread_data($tid)
{
global $db;

	$query = $db->query("

	$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 1924Zeile 1953
		LIMIT 1"
);
$lastpost = $db->fetch_array($query);

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





	
$db->free_result($query);


	$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 1934Zeile 1965
		LIMIT 1
");
$firstpost = $db->fetch_array($query);

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

 
	
$db->free_result($query);


if(!$firstpost['username'])
{


if(!$firstpost['username'])
{

Zeile 1958Zeile 1991
	$update_array = array(
'username' => $firstpost['username'],
'uid' => intval($firstpost['uid']),

	$update_array = array(
'username' => $firstpost['username'],
'uid' => intval($firstpost['uid']),

 
		'dateline' => intval($firstpost['dateline']),

		'lastpost' => intval($lastpost['dateline']),
'lastposter' => $lastpost['username'],
'lastposteruid' => intval($lastpost['uid']),
);
$db->update_query("threads", $update_array, "tid='{$tid}'");

		'lastpost' => intval($lastpost['dateline']),
'lastposter' => $lastpost['username'],
'lastposteruid' => intval($lastpost['uid']),
);
$db->update_query("threads", $update_array, "tid='{$tid}'");

 
	
unset($firstpost, $lastpost, $update_array);

}

function update_forum_count($fid)

}

function update_forum_count($fid)

Zeile 2022Zeile 2058
 * @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 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 array Array of permissions
* @param string The name of the forum jump
* @return string Forum jump items
*/

 * @param array Array of permissions
* @param string The name of the forum jump
* @return string Forum jump items
*/

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

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

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


Zeile 2065Zeile 2102
			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)


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

				{
$optionselected = "";


				{
$optionselected = "";


Zeile 2074Zeile 2111
					{
$optionselected = "selected=\"selected\"";
$selecteddone = 1;

					{
$optionselected = "selected=\"selected\"";
$selecteddone = 1;

					}

					}

					
$forum['name'] = htmlspecialchars_uni(strip_tags($forum['name']));


					
$forum['name'] = htmlspecialchars_uni(strip_tags($forum['name']));


Zeile 2083Zeile 2120
					if($forum_cache[$forum['fid']])
{
$newdepth = $depth."--";

					if($forum_cache[$forum['fid']])
{
$newdepth = $depth."--";

						$forumjumpbits .= build_forum_jump($forum['fid'], $selitem, 0, $newdepth, $showextras);

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

					}
}
}

					}
}
}

Zeile 2126Zeile 2163
function get_extension($file)
{
return my_strtolower(my_substr(strrchr($file, "."), 1));

function get_extension($file)
{
return my_strtolower(my_substr(strrchr($file, "."), 1));

}

}


/**
* Generates a random string.


/**
* Generates a random string.

Zeile 2141Zeile 2178

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


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

		$ch = mt_rand(0, count($set)-1);

		$ch = my_rand(0, count($set)-1);

		$str .= $set[$ch];
}


		$str .= $set[$ch];
}


Zeile 2246Zeile 2283
			}

$editor_language .= "\n";

			}

$editor_language .= "\n";

		}


		}


		$editor_language .= "};";

if(defined("IN_ADMINCP"))
{
global $page;
$codeinsert = $page->build_codebuttons_editor($bind, $editor_language);

		$editor_language .= "};";

if(defined("IN_ADMINCP"))
{
global $page;
$codeinsert = $page->build_codebuttons_editor($bind, $editor_language);

		}

		}

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

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

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

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

		{

		{

			$smilie_cache = $cache->read("smilies");
$smiliecount = count($smilie_cache);
}

			$smilie_cache = $cache->read("smilies");
$smiliecount = count($smilie_cache);
}

Zeile 2305Zeile 2342
			if($mybb->settings['smilieinsertertot'] >= $smiliecount)
{
$mybb->settings['smilieinsertertot'] = $smiliecount;

			if($mybb->settings['smilieinsertertot'] >= $smiliecount)
{
$mybb->settings['smilieinsertertot'] = $smiliecount;

			}

			}

			else if($mybb->settings['smilieinsertertot'] < $smiliecount)
{
$smiliecount = $mybb->settings['smilieinsertertot'];

			else if($mybb->settings['smilieinsertertot'] < $smiliecount)
{
$smiliecount = $mybb->settings['smilieinsertertot'];

Zeile 2526Zeile 2563
	else
{
return $level."%";

	else
{
return $level."%";

	}
}


	}
}


/**
* Fetch the IP address of the current user.
*

/**
* Fetch the IP address of the current user.
*

Zeile 2565Zeile 2602
		{
$ip = '';
}

		{
$ip = '';
}

	}


	}


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

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

Zeile 2603Zeile 2640
	}
// Petabyte (1024 Terabytes)
elseif($size >= 1125899906842624)

	}
// Petabyte (1024 Terabytes)
elseif($size >= 1125899906842624)

	{

	{

		$size = my_number_format(round(($size / 1125899906842624), 2))." ".$lang->size_pb;
}
// Terabyte (1024 Gigabytes)

		$size = my_number_format(round(($size / 1125899906842624), 2))." ".$lang->size_pb;
}
// Terabyte (1024 Gigabytes)

Zeile 2752Zeile 2789
	}

return $unviewableforums;

	}

return $unviewableforums;

}

}


/**
* Fixes mktime for dates earlier than 1970


/**
* Fixes mktime for dates earlier than 1970

Zeile 2866Zeile 2903
				}

$navsize = count($navbits);

				}

$navsize = count($navbits);

				$navbits[$navsize]['name'] = $forumnav['name'];


				// Convert & to &amp;
$navbits[$navsize]['name'] = preg_replace("#&(?!\#[0-9]+;)#si", "&amp;", $forumnav['name']);


if(IN_ARCHIVE == 1)
{


if(IN_ARCHIVE == 1)
{

Zeile 2903Zeile 2941

unset($GLOBALS['navbits']);
$GLOBALS['navbits'] = $newnav;


unset($GLOBALS['navbits']);
$GLOBALS['navbits'] = $newnav;

}


}


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

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

Zeile 2938Zeile 2976
			$url = "{$base_url}forum-{$id}.html";
break;
default:

			$url = "{$base_url}forum-{$id}.html";
break;
default:

			$url = $mybb->setings['bburl']."/archive/index.php";

			$url = $mybb->settings['bburl']."/archive/index.php";

	}

return $url;

	}

return $url;

Zeile 3045Zeile 3083
		echo "<table style=\"background-color: #666;\" width=\"95%\" cellpadding=\"4\" cellspacing=\"1\" align=\"center\">\n";
echo "<tr>\n";
echo "<td style=\"background-color: #ccc;\"><strong>Templates Used (Loaded for this Page) - ".count($templates->cache)." Total</strong></td>\n";

		echo "<table style=\"background-color: #666;\" width=\"95%\" cellpadding=\"4\" cellspacing=\"1\" align=\"center\">\n";
echo "<tr>\n";
echo "<td style=\"background-color: #ccc;\"><strong>Templates Used (Loaded for this Page) - ".count($templates->cache)." Total</strong></td>\n";

		echo "</tr>\n";
echo "<tr>\n";
echo "<td style=\"background: #fff;\">".implode(", ", array_keys($templates->cache))."</td>\n";
echo "</tr>\n";
echo "</table>\n";

		echo "</tr>\n";
echo "<tr>\n";
echo "<td style=\"background: #fff;\">".implode(", ", array_keys($templates->cache))."</td>\n";
echo "</tr>\n";
echo "</table>\n";

		echo "<br />\n";
}


		echo "<br />\n";
}


Zeile 3310Zeile 3348
 */
function join_usergroup($uid, $joingroup)
{

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

	global $db;

	global $db, $mybb;


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


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

	}

	}

	else
{
$query = $db->simple_select("users", "additionalgroups, usergroup", "uid='".intval($uid)."'");
$user = $db->fetch_array($query);
}

	else
{
$query = $db->simple_select("users", "additionalgroups, usergroup", "uid='".intval($uid)."'");
$user = $db->fetch_array($query);
}





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

Zeile 3333Zeile 3371
		foreach($groups as $gid)
{
if(trim($gid) != "" && $gid != $user['usergroup'] && !$donegroup[$gid])

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

			{
$groupslist .= $comma.$gid;
$comma = ",";
$donegroup[$gid] = 1;

			{
$groupslist .= $comma.$gid;
$comma = ",";
$donegroup[$gid] = 1;

			}
}

			}
}

	}

	}





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










	// What's the point in updating if they're the same?
if($groupslist != $user['additionalgroups'])
{
$db->update_query("users", array('additionalgroups' => $groupslist), "uid='".intval($uid)."'");
return true;
}
else
{
return false;
}

}

}





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

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

Zeile 3364Zeile 3411
		$user = $db->fetch_array($query);
}


		$user = $db->fetch_array($query);
}


	$usergroups = "";

 
	$groupslist = "";

	$groupslist = "";

 
	$usergroups = "";

	$usergroups = $user['additionalgroups'].",";

$groups = explode(",", $user['additionalgroups']);

	$usergroups = $user['additionalgroups'].",";

$groups = explode(",", $user['additionalgroups']);

Zeile 3382Zeile 3429
			}
}
}

			}
}
}



	

	$dispupdate = "";
if($leavegroup == $user['displaygroup'])
{

	$dispupdate = "";
if($leavegroup == $user['displaygroup'])
{

Zeile 3481Zeile 3528
	
if(isset($addloc) && is_array($addloc))
{

	
if(isset($addloc) && is_array($addloc))
{

				$location .= "?".implode("&", $addloc);









				if(strpos($location, "?") === false)
{
$location .= "?";
}
else
{
$location .= "&amp;";
}
$location .= implode("&amp;", $addloc);

			}
}


			}
}


Zeile 3626Zeile 3681
			$decimals = 0;
}


			$decimals = 0;
}


		return number_format($number, $decimals, $mybb->settings['decpoint'], $mybb->settings['thousandssep']);


































































		return number_format((double)$number, $decimals, $mybb->settings['decpoint'], $mybb->settings['thousandssep']);
}
}

function convert_through_utf8($str, $to=true)
{
global $lang;
static $charset;
static $use_mb;
static $use_iconv;

if(!isset($charset))
{
$charset = my_strtolower($lang->settings['charset']);
}

if($charset == "utf-8")
{
return $str;
}

if(!isset($use_iconv))
{
$use_iconv = function_exists("iconv");
}

if(!isset($use_mb))
{
$use_mb = function_exists("mb_convert_encoding");
}

if($use_iconv || $use_mb)
{
if($to)
{
$from_charset = $lang->settings['charset'];
$to_charset = "UTF-8";
}
else
{
$from_charset = "UTF-8";
$to_charset = $lang->settings['charset'];
}
if($use_iconv)
{
return iconv($from_charset, $to_charset."//IGNORE", $str);
}
else
{
return @mb_convert_encoding($str, $to_charset, $from_charset);
}
}
elseif($charset == "iso-8859-1" && function_exists("utf8_encode"))
{
if($to)
{
return utf8_encode($str);
}
else
{
return utf8_decode($str);
}
}
else
{
return $str;

	}
}


	}
}


Zeile 3637Zeile 3757
 * @return string The word wraped string
*/
function my_wordwrap($message)

 * @return string The word wraped string
*/
function my_wordwrap($message)

{

{

	global $mybb;

if($mybb->settings['wordwrap'] > 0)

	global $mybb;

if($mybb->settings['wordwrap'] > 0)

	{
if($mybb->config['db_encoding'] == "utf8" && !preg_match("#[\x80-\xFF]#", $message))
{
$message = preg_replace("#(?>[^\s&/<>\"\\-\.\[\]]{{$mybb->settings['wordwrap']}})#u", "$0 ", $message);
}
else

	{
$message = convert_through_utf8($message);

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



		{

		{

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

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

		}

		}

 
		
$new_message = convert_through_utf8($new_message, false);

return $new_message;

	}

return $message;
}

	}

return $message;
}





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

Zeile 3682Zeile 3804
				if($i == $year && $l == $month && $m == $day)
{
return $h;

				if($i == $year && $l == $month && $m == $day)
{
return $h;

				}

				}


if($h == 0)
{
$h = 7;
}
}


if($h == 0)
{
$h = 7;
}
}

		}

		}

	}
}


	}
}


Zeile 3761Zeile 3883
	$find = array(
'm',
'd',

	$find = array(
'm',
'd',

 
		'D',

		'y',
'Y',
'j',
'S',
'l',
'F',

		'y',
'Y',
'j',
'S',
'l',
'F',

 
		'M',

	);

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

	);

$replace = array(
sprintf('%02s', $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),
$by,
($bd[0] == 0 ? my_substr($bd, 1) : $bd),
($bd == 1 || $bd == 21 || $bd == 31 ? 'st' : ($bd == 2 || $bd == 22 ? 'nd' : ($bd == 3 || $bd == 23 ? 'rd' : 'th'))),

		my_substr($by, 2),
$by,
($bd[0] == 0 ? my_substr($bd, 1) : $bd),
($bd == 1 || $bd == 21 || $bd == 31 ? 'st' : ($bd == 2 || $bd == 22 ? 'nd' : ($bd == 3 || $bd == 23 ? 'rd' : 'th'))),

		$bdays[$wd],

		$wd,

		$bmonth[$bm-1],

		$bmonth[$bm-1],

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

	);

	);

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

	
return str_replace($find, $replace, $display);
}

	
return str_replace($find, $replace, $display);
}

Zeile 3798Zeile 3932
	}

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

	}

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





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

if(($month == $bday[1] && $day < $bday[0]) || $month < $bday[1])
{
--$age;

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

if(($month == $bday[1] && $day < $bday[0]) || $month < $bday[1])
{
--$age;

	}

	}

	return $age;
}


	return $age;
}


Zeile 3988Zeile 4122
 * @return int The un-htmlentitied' string.
*/
function unhtmlentities($string)

 * @return int The un-htmlentitied' string.
*/
function unhtmlentities($string)

{
// Replace numeric entities
$string = preg_replace('~&#x([0-9a-f]+);~ei', 'chr(hexdec("\\1"))', $string);
$string = preg_replace('~&#([0-9]+);~e', 'chr(\\1)', $string);

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

return strtr($string, $trans_tbl);
}

/**


































{	
// Replace numeric entities
$string = preg_replace('~&#x([0-9a-f]+);~ei', 'unichr(hexdec("\\1"))', $string);
$string = preg_replace('~&#([0-9]+);~e', 'unichr("\\1")', $string);

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

return strtr($string, $trans_tbl);
}

/**
* Returns any ascii to it's character (utf-8 safe).
*
* @param string The ascii to characterize.
* @return int The characterized ascii.
*/
function unichr($c)
{
if($c <= 0x7F)
{
return chr($c);
}
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)
. chr(0x80 | $c & 0x3F);
}
else if($c <= 0x10FFFF)
{
return chr(0xF0 | $c >> 18) . chr(0x80 | $c >> 12 & 0x3F)
. chr(0x80 | $c >> 6 & 0x3F)
. chr(0x80 | $c & 0x3F);
}
else
{
return false;
}
}

/**

 * Get the event poster.
*
* @param array The event data array.

 * Get the event poster.
*
* @param array The event data array.

Zeile 4011Zeile 4178
	$event['username'] = format_name($event['username'], $event['usergroup'], $event['displaygroup']);
$event_poster = build_profile_link($event['username'], $event['author']);
return $event_poster;

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

}

}


/**
* Get the event date.


/**
* Get the event date.

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

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

	return htmlspecialchars_uni($link);
}


	return htmlspecialchars_uni($link);
}


/**
* Get the announcement link.
*

/**
* Get the announcement link.
*

Zeile 4084Zeile 4251
		}

if(!empty($onclick))

		}

if(!empty($onclick))

		{

		{

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

// If we're in the archive, link back a directory
if(IN_ARCHIVE == 1)
{

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

// If we're in the archive, link back a directory
if(IN_ARCHIVE == 1)
{

			global $mybb;

if($mybb->settings['seourls'] == "yes" || ($mybb->settings['seourls'] == "auto" && $_SERVER['SEO_SUPPORT'] == 1))
{
return "<a href=\"../../".get_profile_link($uid)."\"{$target}{$onclick}>{$username}</a>";
}

return "<a href=\"../".get_profile_link($uid)."\"{$target}{$onclick}>{$username}</a>";

			return "<a href=\"../../".get_profile_link($uid)."\"{$target}{$onclick}>{$username}</a>";








		}
elseif(IN_ADMINCP == 1)
{

		}
elseif(IN_ADMINCP == 1)
{

Zeile 4256Zeile 4416
 */
function get_calendar_week_link($calendar, $week)
{

 */
function get_calendar_week_link($calendar, $week)
{

 
	if($week < 0)
{
$week = str_replace('-', "n", $week);
}

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

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

Zeile 4283Zeile 4447
		return $user_cache[$uid];
}
else

		return $user_cache[$uid];
}
else

	{

	{

		$query = $db->simple_select("users", "*", "uid='{$uid}'");
$user_cache[$uid] = $db->fetch_array($query);


		$query = $db->simple_select("users", "*", "uid='{$uid}'");
$user_cache[$uid] = $db->fetch_array($query);


Zeile 4291Zeile 4455
	}
}


	}
}






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

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

Zeile 4310Zeile 4474
	}

if(!$forum_cache[$fid])

	}

if(!$forum_cache[$fid])

	{

	{

		return false;
}


		return false;
}


Zeile 4326Zeile 4490
					return false;
}
}

					return false;
}
}

		}
}


		}
}


	return $forum_cache[$fid];
}


	return $forum_cache[$fid];
}


Zeile 4353Zeile 4517
		$thread = $db->fetch_array($query);

if($thread)

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

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

/**

 * Get the post of a post id.
*
* @param int The post id of the post.

 * Get the post of a post id.
*
* @param int The post id of the post.

Zeile 4509Zeile 4673
		}

// Work out if the user has waited long enough before letting them login again

		}

// Work out if the user has waited long enough before letting them login again

		if($mybb->cookies['failedlogin'] < $now - $mybb->settings['failedlogintime'] * 60)

		if($mybb->cookies['failedlogin'] < ($now - $mybb->settings['failedlogintime'] * 60) && $mybb->user['uid'] != 0)

		{
my_setcookie('loginattempts', 1);
my_unsetcookie('failedlogin');
$update_array = array(
'loginattempts' => 1
);

		{
my_setcookie('loginattempts', 1);
my_unsetcookie('failedlogin');
$update_array = array(
'loginattempts' => 1
);

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

			$db->update_query("users", $update_array, "uid = '{$mybb->user['uid']}'");

			return 1;
}
// Not waited long enough

			return 1;
}
// Not waited long enough

		else

		else if($mybb->cookies['failedlogin'] > ($now - $mybb->settings['failedlogintime'] * 60))

		{
if($fatal)
{

		{
if($fatal)
{

Zeile 4548Zeile 4712
		return false;
}
// Valid local characters for email addresses: http://www.remote.org/jochen/mail/info/chars.html

		return false;
}
// Valid local characters for email addresses: http://www.remote.org/jochen/mail/info/chars.html

	return preg_match("/^[a-zA-Z0-9&*+\-_.{}~^\?=\/]+@[a-zA-Z0-9-]+\.[a-zA-Z0-9.-]+$/si", $email);

	return preg_match("/^[a-zA-Z0-9&*+\-_.{}~^\?=\/]+@[a-zA-Z0-9-]+\.([a-zA-Z0-9-]+\.)*[a-zA-Z0-9-]{2,}$/si", $email);

}

/**

}

/**

Zeile 4631Zeile 4795
 */
function build_highlight_array($terms)
{

 */
function build_highlight_array($terms)
{

 
	global $mybb;

if($mybb->settings['minsearchword'] < 1)
{
$mybb->settings['minsearchword'] = 3;
}


	// 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 4653Zeile 4824
			{
if($inquote)
{

			{
if($inquote)
{

					$words[] = "\"".trim($phrase)."\"";

					$words[] = trim($phrase);

				}
else
{

				}
else
{

Zeile 4664Zeile 4835
					}
foreach($split_words as $word)
{

					}
foreach($split_words as $word)
{

						if(!$word)

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

						{
continue;
}

						{
continue;
}

Zeile 4686Zeile 4857
		}
foreach($split_words as $word)
{

		}
foreach($split_words as $word)
{

			if(!$word)

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

			{
continue;
}

			{
continue;
}

Zeile 4699Zeile 4870
	{
return false;
}

	{
return false;
}

 
	
// Sort the word array by length. Largest terms go first and work their way down to the smallest term.
// This resolves problems like "test tes" where "tes" will be highlighted first, then "test" can't be highlighted because of the changed html
usort($words, create_function('$a,$b','return strlen($b) - strlen($a);'));


// Loop through our words to build the PREG compatible strings
foreach($words as $word)


// Loop through our words to build the PREG compatible strings
foreach($words as $word)

Zeile 4714Zeile 4889
		}

// Now make PREG compatible

		}

// Now make PREG compatible

		$find = "#(^|>)([^<]*)(".preg_quote($word, "#").")#i";
$replacement = "$1$2<span class=\"highlight\">$3</span>";

		$find = "#(?!<.*?)(".preg_quote($word, "#").")(?![^<>]*?>)#i";
$replacement = "<span class=\"highlight\" style=\"padding-left: 0px; padding-right: 0px;\">$1</span>";

		$highlight_cache[$find] = $replacement;
}


		$highlight_cache[$find] = $replacement;
}


Zeile 4954Zeile 5129
 * @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)

function fetch_remote_file($url, $post_data=array())

{

{

 
	$post_body = '';
if(!empty($post_data))
{
foreach($post_data as $key => $val)
{
$post_body .= '&'.urlencode($key).'='.urlencode($val);
}
$post_body = ltrim($post_body, '&');
}


	if(function_exists("curl_init"))
{
$ch = curl_init();

	if(function_exists("curl_init"))
{
$ch = curl_init();

Zeile 4963Zeile 5148
		curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

		curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

 
		if(!empty($post_body))
{
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_body);
}

		$data = curl_exec($ch);
curl_close($ch);
return $data;
}

		$data = curl_exec($ch);
curl_close($ch);
return $data;
}

	else if(function_exists("fsockopen"))

 	else if(function_exists("fsockopen"))

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

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

Zeile 4983Zeile 5173
			$url['path'] = "/";
}
if($url['query'])

			$url['path'] = "/";
}
if($url['query'])

		{

		{

			$url['path'] .= "?{$url['query']}";
}
$fp = @fsockopen($url['host'], $url['port'], $error_no, $error, 10);

			$url['path'] .= "?{$url['query']}";
}
$fp = @fsockopen($url['host'], $url['port'], $error_no, $error, 10);

Zeile 4992Zeile 5182
		{
return false;
}

		{
return false;
}

		$headers = "GET {$url['path']} HTTP/1.1\r\n";
$headers .= "Host: {$url['host']}\r\n";
$headers .= "Connection: Close\r\n\r\n";




















		$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";
}
else
{
$headers[] = "GET {$url['path']} HTTP/1.0";
}

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

if(!empty($post_body))
{
$headers[] = $post_body;
}

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

		if(!@fwrite($fp, $headers))
{
return false;

		if(!@fwrite($fp, $headers))
{
return false;

Zeile 5007Zeile 5216
		$data = explode("\r\n\r\n", $data, 2);
return $data[1];
}

		$data = explode("\r\n\r\n", $data, 2);
return $data[1];
}

	else

	else if(empty($post_data))

	{
return @implode("", @file($url));

	{
return @implode("", @file($url));

	}
}






	}
else
{
return false;
}
}


/**
* Checks if a particular user is a super administrator.
*
* @param int The user ID to check against the list of super admins
* @return boolean True if a super admin, false if not

/**
* Checks if a particular user is a super administrator.
*
* @param int 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)
{
global $mybb;

function is_super_admin($uid)
{
global $mybb;

Zeile 5029Zeile 5242
		return false;
}
else

		return false;
}
else

	{

	{

		return true;
}
}

		return true;
}
}

Zeile 5051Zeile 5264
	if($escape)
{
if(is_array($escape))

	if($escape)
{
if(is_array($escape))

		{

		{

			function escaped_explode_escape($string)
{
return preg_quote($string, "#");
}
$escape_preg = "(".implode("|", array_map("escaped_explode_escape", $escape)).")";

			function escaped_explode_escape($string)
{
return preg_quote($string, "#");
}
$escape_preg = "(".implode("|", array_map("escaped_explode_escape", $escape)).")";

		}

		}

		else
{
$escape_preg = preg_quote($escape, "#");
}
$quoted_strings = preg_split("#(?<!\\\){$escape_preg}#", $string);

		else
{
$escape_preg = preg_quote($escape, "#");
}
$quoted_strings = preg_split("#(?<!\\\){$escape_preg}#", $string);

	}

	}

	else
{
$quoted_strings = array($string);
}
foreach($quoted_strings as $string)

	else
{
$quoted_strings = array($string);
}
foreach($quoted_strings as $string)

	{

	{

		if($string != "") 
{
if($in_escape)

		if($string != "") 
{
if($in_escape)

Zeile 5097Zeile 5310

/**
* Fetch an IPv4 long formatted range for searching IPv4 IP addresses.


/**
* 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
*/
function fetch_longipv4_range($ip)
{
$ip_bits = explode(".", $ip);

 * @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
*/
function fetch_longipv4_range($ip)
{
$ip_bits = explode(".", $ip);

 
	$ip_string1 = $ip_string2 = "";





	if($ip == "*") return array(ip2long(0), ip2long(255));




	if($ip == "*")
{
return array(ip2long('0.0.0.0'), ip2long('255.255.255.255'));
}


if(strpos($ip, ".*") === false)
{


if(strpos($ip, ".*") === false)
{

Zeile 5122Zeile 5339
	// Wildcard based IP provided
else
{

	// Wildcard based IP provided
else
{

 
		$sep = "";

		foreach($ip_bits as $piece)
{
if($piece == "*")
{

		foreach($ip_bits as $piece)
{
if($piece == "*")
{

				return array(ip2long($ip_string."0"), ip2long($ip_string."255"));


				$ip_string1 .= $sep."0";
$ip_string2 .= $sep."255";

			}
else
{

			}
else
{

				$ip_string .= $piece.".";


				$ip_string1 .= $sep.$piece;
$ip_string2 .= $sep.$piece;

			}

			}

 
			$sep = ".";

		}

		}

 
		return array(ip2long($ip_string1), ip2long($ip_string2));

	}
}


	}
}


Zeile 5192Zeile 5414
	$n[2] += $d[1];
$n[3] += $d[2];
return mktime(date("G"), date("i"), 0, $n[2], $n[1], $n[3]);

	$n[2] += $d[1];
$n[3] += $d[2];
return mktime(date("G"), date("i"), 0, $n[2], $n[1], $n[3]);

}

}


/**
* Expire old warnings in the database.


/**
* Expire old warnings in the database.

Zeile 5201Zeile 5423
function expire_warnings()
{
global $db;

function expire_warnings()
{
global $db;

 
	
$users = array();


	$query = $db->query("
SELECT w.wid, w.uid, w.points, u.warningpoints
FROM ".TABLE_PREFIX."warnings w

	$query = $db->query("
SELECT w.wid, w.uid, w.points, u.warningpoints
FROM ".TABLE_PREFIX."warnings w

Zeile 5213Zeile 5438
			"expired" => 1
);
$db->update_query("warnings", $updated_warning, "wid='{$warning['wid']}'");

			"expired" => 1
);
$db->update_query("warnings", $updated_warning, "wid='{$warning['wid']}'");

		$warning['warningpoints'] -= $warning['points'];
if($warning['warningpoints'] < 0)













		
if(array_key_exists($warning['uid'], $users))
{
$users[$warning['uid']] -= $warning['points'];
}
else
{
$users[$warning['uid']] = $warning['warningpoints']-$warning['points'];
}
}

foreach($users as $uid => $warningpoints)
{
if($warningpoints < 0)

		{

		{

			$warning['warningpoints'] = 0;

			$warningpoints = 0;

		}

		}

 
		

		$updated_user = array(

		$updated_user = array(

			"warningpoints" => intval($warning['warningpoints'])

			"warningpoints" => intval($warningpoints)

		);

		);

		$db->update_query("users", $updated_user, "uid='{$warning['uid']}'");

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

	}
}


	}
}


Zeile 5289Zeile 5527
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 5336Zeile 5574
	}

return $count;

	}

return $count;

 
}

/**
* 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
*/
function secure_seed_rng($count=8)
{
$output = '';

// Try the unix/linux method
if(@is_readable('/dev/urandom') && ($handle = @fopen('/dev/urandom', 'rb')))
{
$output = @fread($handle, $count);
@fclose($handle);
}

// Didn't work? Do we still not have enough bytes? Use our own (less secure) rng generator
if(strlen($output) < $count)
{
$output = '';

// Close to what PHP basically uses internally to seed, but not quite.
$unique_state = microtime().@getmypid();

for($i = 0; $i < $count; $i += 16)
{
$unique_state = md5(microtime().$unique_state);
$output .= pack('H*', md5($unique_state));
}
}

// /dev/urandom and openssl will always be twice as long as $count. base64_encode will roughly take up 33% more space but crc32 will put it to 32 characters
$output = hexdec(substr(dechex(crc32(base64_encode($output))), 0, $count));

return $output;
}

/**
* 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
* @return int An integer equivilent of a secure hexadecimal seed
*/
function my_rand($min=null, $max=null, $force_seed=false)
{
static $seeded = false;
static $obfuscator = 0;

if($seeded == false || $force_seed == true)
{
mt_srand(secure_seed_rng());
$seeded = true;

$obfuscator = abs((int) secure_seed_rng());

// Ensure that $obfuscator is <= mt_getrandmax() for 64 bit systems.
if($obfuscator > mt_getrandmax())
{
$obfuscator -= mt_getrandmax();
}
}

if($min !== null && $max !== null)
{
$distance = $max - $min;
if ($distance > 0)
{
return $min + (int)((float)($distance + 1) * (float)(mt_rand() ^ $obfuscator) / (mt_getrandmax() + 1));
}
else
{
return mt_rand($min, $max);
}
}
else
{
$val = mt_rand() ^ $obfuscator;
return $val;
}

}

?>

}

?>