Vergleich inc/functions.php - 1.2.1 - 1.2.4

  Keine Änderungen   Hinzugefügt   Modifiziert   Entfernt
Zeile 6Zeile 6
 * Website: http://www.mybboard.com
* License: http://www.mybboard.com/eula.html
*

 * Website: http://www.mybboard.com
* License: http://www.mybboard.com/eula.html
*

 * $Id: functions.php 2277 2006-09-27 10:26:56Z chris $

 * $Id: functions.php 2794 2007-02-14 02:37:17Z chris $

 */

/**

 */

/**

Zeile 106Zeile 106
 */
function run_shutdown()
{

 */
function run_shutdown()
{

	global $db, $cache, $shutdown_functions, $done_shutdown;

	global $db, $cache, $plugins, $shutdown_functions, $done_shutdown;

	
if($done_shutdown == true)
{
return;
}

	
if($done_shutdown == true)
{
return;
}

 
	
// If our DB has been deconstructed already (bad PHP 5.2.0), reconstruct
if(!is_object($db))
{
require MYBB_ROOT."inc/config.php";
if(isset($config))
{
require_once MYBB_ROOT."inc/db_".$config['dbtype'].".php";
$db = new databaseEngine;
$db->connect($config['hostname'], $config['username'], $config['password']);
$db->select_db($config['database']);
}
}

// Cache object deconstructed? reconstruct
if(!is_object($cache))
{
require_once MYBB_ROOT."inc/class_datacache.php";
$cache = new datacache;
}

// And finaly.. we have the PHP developers to thank for this "hack" which fixes a problem THEY created
if(!is_object($plugins) && !defined("NO_PLUGINS"))
{
require_once MYBB_ROOT."inc/class_plugins.php";
$plugins = new pluginSystem;
$plugins->load();
}


// We have some shutdown queries needing to be run
if(is_array($db->shutdown_queries))


// We have some shutdown queries needing to be run
if(is_array($db->shutdown_queries))

	{

	{

		// Loop through and run them all
foreach($db->shutdown_queries as $query)
{

		// Loop through and run them all
foreach($db->shutdown_queries as $query)
{

Zeile 142Zeile 170
function send_mail_queue($count=10)
{
global $db, $cache, $plugins;

function send_mail_queue($count=10)
{
global $db, $cache, $plugins;



	

	$plugins->run_hooks("send_mail_queue_start");

// Check to see if the mail queue has messages needing to be sent

	$plugins->run_hooks("send_mail_queue_start");

// Check to see if the mail queue has messages needing to be sent

Zeile 254Zeile 282
			{
$offset = "+".$offset;
}

			{
$offset = "+".$offset;
}

		}
}

		}
}

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

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

Zeile 269Zeile 297
		if($todaysdate == $date)
{
$date = $lang->today;

		if($todaysdate == $date)
{
$date = $lang->today;

		}

		}

		elseif($yesterdaysdate == $date)
{
$date = $lang->yesterday;

		elseif($yesterdaysdate == $date)
{
$date = $lang->yesterday;

Zeile 291Zeile 319
 * @param string The chracter set being used to send this email.
*/
function my_mail($to, $subject, $message, $from="", $charset="", $headers="")

 * @param string The chracter set being used to send this email.
*/
function my_mail($to, $subject, $message, $from="", $charset="", $headers="")

{

{

	global $db, $mybb, $lang;

if(empty($charset))

	global $db, $mybb, $lang;

if(empty($charset))

Zeile 397Zeile 425

/**
* Load the forum cache in to memory


/**
* Load the forum cache in to memory

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

 */

 */

function cache_forums()

function cache_forums($force=false)

{
global $forum_cache, $db, $cache;

{
global $forum_cache, $db, $cache;

 
	
if($force == true)
{
$forum_cache = $cache->read("forums", 1);
return $forum_cache;
}


if(!$forum_cache)
{


if(!$forum_cache)
{

Zeile 481Zeile 517
		"location2" => 0
);
$db->update_query(TABLE_PREFIX."sessions", $noperm_array, "sid='".$session->sid."'");

		"location2" => 0
);
$db->update_query(TABLE_PREFIX."sessions", $noperm_array, "sid='".$session->sid."'");

	$url = $_SERVER['REQUEST_URI'];
$url = str_replace("&", "&", $url);

	$url = htmlspecialchars_uni($_SERVER['REQUEST_URI']);


	if($mybb->user['uid'])
{
$lang->error_nopermission_user_5 = sprintf($lang->error_nopermission_user_5, $mybb->user['username']);

	if($mybb->user['uid'])
{
$lang->error_nopermission_user_5 = sprintf($lang->error_nopermission_user_5, $mybb->user['username']);

Zeile 796Zeile 831
function fetch_forum_permissions($fid, $gid, $groupperms)
{
global $groupscache, $forum_cache, $fpermcache, $mybb, $fpermfields;

function fetch_forum_permissions($fid, $gid, $groupperms)
{
global $groupscache, $forum_cache, $fpermcache, $mybb, $fpermfields;

 


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

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

 


	if(!$fpermcache[$fid]) // This forum has no custom or inherited permisssions so lets just return the group permissions
{
return $groupperms;
}

	if(!$fpermcache[$fid]) // This forum has no custom or inherited permisssions so lets just return the group permissions
{
return $groupperms;
}

 
	
$current_permissions = array();


	foreach($groups as $gid)
{

	foreach($groups as $gid)
{

		if($gid && $groupscache[$gid])

		if($groupscache[$gid])

		{

		{

			if(!is_array($fpermcache[$fid][$gid]))


			// If this forum has permissions set
if($fpermcache[$fid][$gid])

			{

			{

				continue;
}
foreach($fpermcache[$fid][$gid] as $perm => $access)
{
if($perm == "fid" || $perm == "gid" || $perm == "pid")

				$level_permissions = $fpermcache[$fid][$gid];
foreach($level_permissions as $permission => $access)




				{

				{

					continue;
}
$permission = $forumpermissions[$perm];
if((is_numeric($access) && $access > $permission) || ($access == "yes" && $permission == "no") || !$permission)
{
$forumpermissions[$perm] = $access;

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



				}
}
}

				}
}
}

	}
if(!isset($forumpermissions))


	}

if(count($current_permissions) == 0)

	{

	{

		$forumpermissions = $groupperms;

		$current_permissions = $groupperms;

	}

	}

	return $forumpermissions;

	return $current_permissions;

}

/**

}

/**

Zeile 835Zeile 872
 *
* @param int The forum ID
* @param string The plain text password for the forum

 *
* @param int The forum ID
* @param string The plain text password for the forum

 */

 */

function check_forum_password($fid, $password="")
{
global $mybb, $header, $footer, $headerinclude, $theme, $templates, $lang;

function check_forum_password($fid, $password="")
{
global $mybb, $header, $footer, $headerinclude, $theme, $templates, $lang;

Zeile 848Zeile 885
			if($password == $mybb->input['pwverify'])
{
my_setcookie("forumpass[$fid]", md5($mybb->user['uid'].$mybb->input['pwverify']), null, true);

			if($password == $mybb->input['pwverify'])
{
my_setcookie("forumpass[$fid]", md5($mybb->user['uid'].$mybb->input['pwverify']), null, true);

				$showform = 0;
}

				$showform = 0;
}

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

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

Zeile 874Zeile 911
	}
if($showform)
{

	}
if($showform)
{

 
		$_SERVER['REQUEST_URI'] = htmlspecialchars_uni($_SERVER['REQUEST_URI']);

		eval("\$pwform = \"".$templates->get("forumdisplay_password")."\";");
output_page($pwform);
exit;

		eval("\$pwform = \"".$templates->get("forumdisplay_password")."\";");
output_page($pwform);
exit;

	}

	}

}

/**

}

/**

Zeile 918Zeile 956
		$perms = $modpermscache[$uid][$fid];
}
return $perms;

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

}

}


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


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

Zeile 948Zeile 986
			$query = $db->simple_select(TABLE_PREFIX.'moderators', 'mid', "uid={$uid}", array('limit' => 1));
$modcheck = $db->fetch_array($query);
if($modcheck['mid'])

			$query = $db->simple_select(TABLE_PREFIX.'moderators', 'mid', "uid={$uid}", array('limit' => 1));
$modcheck = $db->fetch_array($query);
if($modcheck['mid'])

			{

			{

				return "yes";
}
else

				return "yes";
}
else

Zeile 960Zeile 998
		{
$modperms = get_moderator_permissions($fid, $uid);
if(!$action && $modperms)

		{
$modperms = get_moderator_permissions($fid, $uid);
if(!$action && $modperms)

			{

			{

				return "yes";
}
else
{
if($modperms[$action] == "yes")

				return "yes";
}
else
{
if($modperms[$action] == "yes")

				{

				{

					return "yes";
}
else

					return "yes";
}
else

Zeile 977Zeile 1015
		}
}
}

		}
}
}





/**
* Generate a list of the posticons.
*

/**
* Generate a list of the posticons.
*

Zeile 989Zeile 1027

$listed = 0;
if($mybb->input['icon'])


$listed = 0;
if($mybb->input['icon'])

	{

	{

		$icon = $mybb->input['icon'];
}
$no_icons_checked = " checked=\"checked\"";

		$icon = $mybb->input['icon'];
}
$no_icons_checked = " checked=\"checked\"";

Zeile 1001Zeile 1039
	while($dbicon = $db->fetch_array($query))
{
if($icon == $dbicon['iid'])

	while($dbicon = $db->fetch_array($query))
{
if($icon == $dbicon['iid'])

		{

		{

			$iconlist .= "<input type=\"radio\" name=\"icon\" value=\"".$dbicon['iid']."\" checked=\"checked\" /> <img src=\"".$dbicon['path']."\" alt=\"".$dbicon['name']."\" />";
$no_icons_checked = "";
}

			$iconlist .= "<input type=\"radio\" name=\"icon\" value=\"".$dbicon['iid']."\" checked=\"checked\" /> <img src=\"".$dbicon['path']."\" alt=\"".$dbicon['name']."\" />";
$no_icons_checked = "";
}

Zeile 1014Zeile 1052
		{
$iconlist .= "<br />";
$listed = 0;

		{
$iconlist .= "<br />";
$listed = 0;

		}
}

		}
}

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

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












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

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

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

	global $mybb, $sent_header;
if($sent_header || headers_sent())
{
return false;
}


	global $mybb;






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

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

	{

	{

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

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

		{

		{

			$expires = 0;
}
else

			$expires = 0;
}
else

Zeile 1064Zeile 1106
	if(!empty($mybb->settings['cookiepath']))
{
$cookie .= "; path={$mybb->settings['cookiepath']}";

	if(!empty($mybb->settings['cookiepath']))
{
$cookie .= "; path={$mybb->settings['cookiepath']}";

	}

	}

	if(!empty($mybb->settings['cookiedomain']))
{
$cookie .= "; domain={$mybb->settings['cookiedomain']}";

	if(!empty($mybb->settings['cookiedomain']))
{
$cookie .= "; domain={$mybb->settings['cookiedomain']}";

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

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

{
global $mybb, $sent_header;

if($sent_header)
{
return false;
}

$expires = time()-3600;


{
global $mybb;
$expires = -3600;








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


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


Zeile 1121Zeile 1156

/**
* Set a serialised cookie array.


/**
* Set a serialised cookie array.

 *

 *

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

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

Zeile 1268Zeile 1303
	");
$firstpost = $db->fetch_array($query);
if(!$firstpost['username'])

	");
$firstpost = $db->fetch_array($query);
if(!$firstpost['username'])

	{

	{

		$firstpost['username'] = $firstpost['postusername'];
}
if(!$lastpost['username'])

		$firstpost['username'] = $firstpost['postusername'];
}
if(!$lastpost['username'])

Zeile 1297Zeile 1332
	update_thread_attachment_count($tid);
$db->query("
UPDATE ".TABLE_PREFIX."threads

	update_thread_attachment_count($tid);
$db->query("
UPDATE ".TABLE_PREFIX."threads

		SET username='".$firstpost['username']."', uid='".intval($firstpost['uid'])."', lastpost='".$lastpost['dateline']."', lastposter='".$lastpost['username']."', lastposteruid='".intval($lastpost['uid'])."', replies='$treplies', unapprovedposts='$nounposts'

		SET username='".$firstpost['username']."', uid='".intval($firstpost['uid'])."', lastpost='".intval($lastpost['dateline'])."', lastposter='".$lastpost['username']."', lastposteruid='".intval($lastpost['uid'])."', replies='$treplies', unapprovedposts='$nounposts'

		WHERE tid='$tid'
");
}

		WHERE tid='$tid'
");
}

Zeile 1319Zeile 1354
	$db->query("
UPDATE ".TABLE_PREFIX."threads
SET attachmentcount='{$attachment_count}'

	$db->query("
UPDATE ".TABLE_PREFIX."threads
SET attachmentcount='{$attachment_count}'

		WHERE tid='$tid'

		WHERE tid='$tid'

	");
}


	");
}


Zeile 1329Zeile 1364
 * @param int The thread ID
*/
function delete_thread($tid)

 * @param int The thread ID
*/
function delete_thread($tid)

{
global $moderation;
if(!is_object($moderation))
{

{
global $moderation;
if(!is_object($moderation))
{

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

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

Zeile 1353Zeile 1388
		$moderation = new Moderation;
}
return $moderation->delete_post($pid);

		$moderation = new Moderation;
}
return $moderation->delete_post($pid);

}

}


/**
* Builds a forum jump menu


/**
* Builds a forum jump menu

Zeile 1379Zeile 1414
	if(!is_array($jumpfcache))
{
if(!is_array($forum_cache))

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

		{

		{

			cache_forums();
}
foreach($forum_cache as $fid => $forum)

			cache_forums();
}
foreach($forum_cache as $fid => $forum)

Zeile 1387Zeile 1422
			if($forum['active'] != "no")
{
$jumpfcache[$forum['pid']][$forum['disporder']][$forum['fid']] = $forum;

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

			}

			}

		}
}
if(!is_array($permissioncache))

		}
}
if(!is_array($permissioncache))

Zeile 1455Zeile 1490

/**
* Generates a random string.


/**
* Generates a random string.

 *

 *

 * @param int The length of the string to generate.
* @return string The random string.
*/
function random_str($length="8")

 * @param int The length of the string to generate.
* @return string The random string.
*/
function random_str($length="8")

{

{

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

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

	{

	{

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

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

Zeile 1489Zeile 1524
	}

if($displaygroup != 0)

	}

if($displaygroup != 0)

	{

	{

		$usergroup = $displaygroup;
}
$ugroup = $groupscache[$usergroup];

		$usergroup = $displaygroup;
}
$ugroup = $groupscache[$usergroup];

Zeile 1588Zeile 1623
 */
function build_clickable_smilies()
{

 */
function build_clickable_smilies()
{

	global $db, $smiliecache, $theme, $templates, $lang, $mybb;

	global $db, $smiliecache, $theme, $templates, $lang, $mybb, $smiliecount;


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


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

		$smiliecount = 0;






		if(!$smiliecount)
{
$query = $db->simple_select(TABLE_PREFIX."smilies", "COUNT(*) as smilies");
$smiliecount = $db->fetch_field($query, "smilies");
}


		if(!$smiliecache)
{

		if(!$smiliecache)
{

			$query = $db->query("
SELECT *
FROM ".TABLE_PREFIX."smilies
WHERE showclickable != 'no'
ORDER BY disporder
");

			$query = $db->simple_select(TABLE_PREFIX."smilies", "*", "showclickable != 'no'", array('order_by' => 'disporder'));







while($smilie = $db->fetch_array($query))
{
$smiliecache[$smilie['find']] = $smilie['image'];


while($smilie = $db->fetch_array($query))
{
$smiliecache[$smilie['find']] = $smilie['image'];

				$smiliecount++;

 
			}
}
unset($smilie);

			}
}
unset($smilie);

Zeile 1632Zeile 1666
					{
$smilies .= "<tr>\n";
}

					{
$smilies .= "<tr>\n";
}

					$find = $db->escape_string(htmlspecialchars($find));

					$find = htmlspecialchars_uni($find);

					$smilies .= "<td><img src=\"{$image}\" border=\"0\" class=\"smilie\" alt=\"{$find}\" /></td>\n";
$i++;
$counter++;

					$smilies .= "<td><img src=\"{$image}\" border=\"0\" class=\"smilie\" alt=\"{$find}\" /></td>\n";
$i++;
$counter++;

Zeile 1753Zeile 1787
		"tid" => $tid,
"action" => $db->escape_string($action),
"data" => $db->escape_string($data),

		"tid" => $tid,
"action" => $db->escape_string($action),
"data" => $db->escape_string($data),

		"ipaddress" => $session->ipaddress

		"ipaddress" => $db->escape_string($session->ipaddress)

	);
$db->insert_query(TABLE_PREFIX."moderatorlog", $sql_array);
}

	);
$db->insert_query(TABLE_PREFIX."moderatorlog", $sql_array);
}

Zeile 1826Zeile 1860
			$ip = $_SERVER['REMOTE_ADDR'];
}
}

			$ip = $_SERVER['REMOTE_ADDR'];
}
}

 
	global $db;
$ip = $db->escape_string(preg_replace("#([^.0-9 ]*)#", "", $ip));


	return $ip;
}


	return $ip;
}


Zeile 2150Zeile 2187
	echo "<td bgcolor=\"#FEFEFE\" width=\"25%\"><font face=\"Tahoma\" size=\"2\">$db->query_count</font></td>\n";
echo "</tr>\n";
echo "<tr>\n";

	echo "<td bgcolor=\"#FEFEFE\" width=\"25%\"><font face=\"Tahoma\" size=\"2\">$db->query_count</font></td>\n";
echo "</tr>\n";
echo "<tr>\n";

	echo "<td bgcolor=\"#EFEFEF\" width=\"25%\"><b><font face=\"Tahoma\" size=\"2\">PHP Proccessing Time:</font></b></td>\n";

	echo "<td bgcolor=\"#EFEFEF\" width=\"25%\"><b><font face=\"Tahoma\" size=\"2\">PHP Processing Time:</font></b></td>\n";

	echo "<td bgcolor=\"#FEFEFE\" width=\"25%\"><font face=\"Tahoma\" size=\"2\">$phptime seconds ($percentphp%)</font></td>\n";
echo "<td bgcolor=\"#EFEFEF\" width=\"25%\"><b><font face=\"Tahoma\" size=\"2\">MySQL Processing Time:</font></b></td>\n";
echo "<td bgcolor=\"#FEFEFE\" width=\"25%\"><font face=\"Tahoma\" size=\"2\">$querytime seconds ($percentsql%)</font></td>\n";

	echo "<td bgcolor=\"#FEFEFE\" width=\"25%\"><font face=\"Tahoma\" size=\"2\">$phptime seconds ($percentphp%)</font></td>\n";
echo "<td bgcolor=\"#EFEFEF\" width=\"25%\"><b><font face=\"Tahoma\" size=\"2\">MySQL Processing Time:</font></b></td>\n";
echo "<td bgcolor=\"#FEFEFE\" width=\"25%\"><font face=\"Tahoma\" size=\"2\">$querytime seconds ($percentsql%)</font></td>\n";

Zeile 2193Zeile 2230
	{
echo "<table style=\"background-color: #666;\" width=\"95%\" cellpadding=\"4\" cellspacing=\"1\" align=\"center\">\n";
echo "<tr>\n";

	{
echo "<table style=\"background-color: #666;\" width=\"95%\" cellpadding=\"4\" cellspacing=\"1\" align=\"center\">\n";
echo "<tr>\n";

		echo "<td colspan=\"8\" style=\"background-color: #ccc;\"><strong>Templates Used (Loaded for this Page) - ".count($templates->cache)." Total</strong></td>\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 "<tr>\n";
echo "<td style=\"background: #fff;\">".implode(", ", array_keys($templates->cache))."</td>\n";

Zeile 2519Zeile 2556
	else
{
if(isset($_SERVER['PATH_INFO']))

	else
{
if(isset($_SERVER['PATH_INFO']))

		{

		{

			$location = $_SERVER['PATH_INFO'];
}
elseif(isset($_ENV['PATH_INFO']))

			$location = $_SERVER['PATH_INFO'];
}
elseif(isset($_ENV['PATH_INFO']))

Zeile 2529Zeile 2566
		elseif(isset($_ENV['PHP_SELF']))
{
$location = $_ENV['PHP_SELF'];

		elseif(isset($_ENV['PHP_SELF']))
{
$location = $_ENV['PHP_SELF'];

		}

		}

		else
{
$location = $_SERVER['PHP_SELF'];

		else
{
$location = $_SERVER['PHP_SELF'];

Zeile 2539Zeile 2576
			$location .= "?".$_SERVER['QUERY_STRING'];
}
elseif(isset($_ENV['QUERY_STRING']))

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

		{

		{

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

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

Zeile 2560Zeile 2597
		}
}
return $location;

		}
}
return $location;

}

/**

}

/**

 * Build a theme selection menu
*
* @param string The name of the menu

 * Build a theme selection menu
*
* @param string The name of the menu

Zeile 2574Zeile 2611
 */
function build_theme_select($name, $selected="", $tid=0, $depth="", $usergroup_override=0)
{

 */
function build_theme_select($name, $selected="", $tid=0, $depth="", $usergroup_override=0)
{

	global $db, $themeselect, $tcache, $lang, $mybb;


	global $db, $themeselect, $tcache, $lang, $mybb, $limit;


	if($tid == 0)
{
$themeselect = "<select name=\"$name\">";
$themeselect .= "<option value=\"0\">".$lang->use_default."</option>\n";
$themeselect .= "<option value=\"0\">-----------</option>\n";

	if($tid == 0)
{
$themeselect = "<select name=\"$name\">";
$themeselect .= "<option value=\"0\">".$lang->use_default."</option>\n";
$themeselect .= "<option value=\"0\">-----------</option>\n";

	}



		$tid = 1;
}


	if(!is_array($tcache))
{

	if(!is_array($tcache))
{

		$query = $db->query("
SELECT name, pid, tid, allowedgroups
FROM ".TABLE_PREFIX."themes
WHERE pid != 0
ORDER BY pid, name
");

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






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

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

			$tcache[$theme['pid']][] = $theme;

			$tcache[$theme['pid']][$theme['tid']] = $theme;

		}
}

		}
}

	if(is_array($tcache))


	
if(is_array($tcache[$tid]))

	{
// Figure out what groups this user is in
if($mybb->user['additionalgroups'])

	{
// Figure out what groups this user is in
if($mybb->user['additionalgroups'])

Zeile 2603Zeile 2640
		}
$in_groups[] = $mybb->user['usergroup'];


		}
$in_groups[] = $mybb->user['usergroup'];


		foreach($tcache as $misc)

		foreach($tcache[$tid] as $theme)

		{

		{

			foreach($misc as $theme)




			$sel = "";
// Make theme allowed groups into array
$is_allowed = false;
if($theme['allowedgroups'] != "all" && $theme['allowedgroups'] != "")

			{

			{

				$sel = "";
// Make theme allowed groups into array
$is_allowed = false;
if($theme['allowedgroups'] != "all" && $theme['allowedgroups'] != "")

				$allowed_groups = explode(",", $theme['allowedgroups']);
// See if groups user is in is allowed
foreach($allowed_groups as $agid)


				{

				{

					$allowed_groups = explode(",", $theme['allowedgroups']);
// See if groups user is in is allowed
foreach($allowed_groups as $agid)

					if(in_array($agid, $in_groups))



					{

					{

						if(in_array($agid, $in_groups))
{
$is_allowed = true;
break;
}
}
}
// Show theme if allowed, or if override is on
if($is_allowed || $theme['allowedgroups'] == "all" || $usergroup_override == 1)
{
if($theme['tid'] == $selected)
{
$sel = " selected=\"selected\"";
}
if($theme['pid'] != 0)
{
$themeselect .= "<option value=\"".$theme['tid']."\"$sel>".$depth.$theme['name']."</option>";
$depthit = $depth."--";
}
if(array_key_exists($theme['tid'], $tcache))
{
build_theme_select($name, $selected, $theme['tid'], $depthit, $usergroup_override);

						$is_allowed = true;
break;





















					}

					}

 
				}
}

// Show theme if allowed, or if override is on
if($is_allowed || $theme['allowedgroups'] == "all" || $theme['allowedgroups'] == "" || $usergroup_override == 1)
{
if($theme['tid'] == $selected)
{
$sel = " selected=\"selected\"";
}

if($theme['pid'] != 0)
{
$themeselect .= "<option value=\"".$theme['tid']."\"$sel>".$depth.$theme['name']."</option>";
$depthit = $depth."--";
}

if(array_key_exists($theme['tid'], $tcache))
{
build_theme_select($name, $selected, $theme['tid'], $depthit, $usergroup_override);

				}
}
}

				}
}
}

	}


	}


	if(!$tid)
{
$themeselect .= "</select>";
}

	if(!$tid)
{
$themeselect .= "</select>";
}

 
	

	return $themeselect;
}

	return $themeselect;
}



 

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


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

Zeile 2838Zeile 2876
 */
function my_strlen($string)
{

 */
function my_strlen($string)
{

	$string = preg_replace("#&\#(0-9]+);#", "-", $string);
if(function_exists("mb_strlen"))
{
$string_length = mb_strlen($string);
}
else
{
$string_length = strlen($string);
}















    global $lang;

$string = preg_replace("#&\#(0-9]+);#", "-", $string);

if(strtolower($lang->settings['charset']) == "utf-8")
{
// Get rid of any excess RTL and LTR override for they are the workings of the devil
$string = str_replace(dec_to_utf8(8238), "", $string);
$string = str_replace(dec_to_utf8(8237), "", $string);

// Remove dodgy whitspaces
$string = str_replace(chr(0xCA), "", $string);
}
$string = trim($string);

if(function_exists("mb_strlen"))
{
$string_length = mb_strlen($string);
}
else
{
$string_length = strlen($string);
}





	return $string_length;

    return $string_length;

}

/**

}

/**

Zeile 2885Zeile 2937
	}

return $cut_string;

	}

return $cut_string;

 
}

/**
* lowers the case of a string, mb strings accounted for
*
* @param string The string to lower.
* @return int The lowered string.
*/
function my_strtolower($string)
{
if(function_exists("mb_strtolower"))
{
$string = mb_strtolower($string);
}
else
{
$string = strtolower($string);
}

return $string;
}

/**
* Finds a needle in a haystack and returns it position, mb strings accounted for
*
* @param string String to look in (haystack)
* @param string What to look for (needle)
* @param int (optional) How much to offset
* @return int false on needle not found, integer position if found
*/
function my_strpos($haystack, $needle, $offset=0)
{
if($needle == '')
{
return false;
}

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

return $position;
}

/**
* ups the case of a string, mb strings accounted for
*
* @param string The string to up.
* @return int The uped string.
*/
function my_strtoupper($string)
{
if(function_exists("mb_strtoupper"))
{
$string = mb_strtoupper($string);
}
else
{
$string = strtoupper($string);
}

return $string;

}

/**

}

/**

Zeile 2895Zeile 3014
 */
function unhtmlentities($string)
{

 */
function unhtmlentities($string)
{

   // replace numeric entities

   // Replace numeric entities

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

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

   // replace literal entities



// Replace literal entities

   $trans_tbl = get_html_translation_table(HTML_ENTITIES);
$trans_tbl = array_flip($trans_tbl);

   $trans_tbl = get_html_translation_table(HTML_ENTITIES);
$trans_tbl = array_flip($trans_tbl);

 


   return strtr($string, $trans_tbl);
}


   return strtr($string, $trans_tbl);
}


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

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

				if(strpos(",".$forum1['parentlist'].",", ",".$fid.",") !== false)

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

				{

				{

					$inactive[] = $fid;

					$inactive[] = $fid1;

				}
}
}

				}
}
}

Zeile 3265Zeile 3386
*/
function validate_email_format($email)
{

*/
function validate_email_format($email)
{

	if(!preg_match("/^(.+)@[a-zA-Z0-9-]+\.[a-zA-Z0-9.-]+$/si", $email))

	if(!preg_match("/^(.+)@[a-zA-Z0-9-]+\.[a-zA-Z0-9.-]+$/si", $email) || strpos($email, ' ') !== false)

	{
return false;
}

	{
return false;
}

Zeile 3351Zeile 3472
		return false;
}
return $dest;

		return false;
}
return $dest;

 
}

/**
* Return a list of banned usernames.
*
* @return array The array of banned usernames.
*/
function get_banned_usernames()
{
global $mybb;
$banned_usernames = explode(",", $mybb->settings['bannedusernames']);
$banned_usernames = array_map("trim", $banned_usernames);
$banned_usernames = array_map("strtolower", $banned_usernames);
return $banned_usernames;
}

/**
* Checks if a username has been disallowed for registration/use.
*
* @param string The username
* @return boolean True if banned, false if not banned
*/
function is_banned_username($username)
{
$banned_usernames = get_banned_usernames();
if(in_array(strtolower($username), $banned_usernames))
{
return true;
}
else
{
return false;
}
}

/**
* Return a list of banned email addresses.
*
* @return array The array of banned email addresses.
*/
function get_banned_emails()
{
global $mybb;
$banned_emails = explode(",", $mybb->settings['bannedemails']);
$banned_emails = array_map("trim", $banned_emails);
$banned_emails = array_map("strtolower", $banned_emails);
return $banned_emails;
}

/**
* Check if a specific email address has been banned.
*
* @param string The email address.
* @return boolean True if banned, false if not banned
*/
function is_banned_email($email)
{
$banned_emails = get_banned_emails();
$email = strtolower($email);
foreach($banned_emails as $banned_email)
{
if($banned_email != "" && strpos($email, $banned_email) !== false)
{
return true;
}
}
return false;
}

/**
* Return a list of banned IP addresses.
*
* @return array The array of banned IP addresses.
*/
function get_banned_ips()
{
global $mybb;
$banned_ips = explode(",", $mybb->settings['bannedips']);
$banned_ips = array_map("trim", $banned_ips);
return $banned_ips;
}

/**
* Checks if a specific IP address has been banned.
*
* @param string The IP address.
* @return boolean True if banned, false if not banned.
*/
function is_banned_ip($ip_address)
{
$banned_ips = get_banned_ips();
foreach($banned_ips as $banned_ip)
{
if($banned_ip != "" && strpos($ip_address, $banned_ip) !== false)
{
return true;
}
}
return false;

}

/**

}

/**