Vergleich inc/functions.php - 1.2.0 - 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 2191 2006-09-03 12:11:04Z chris $

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

 */

/**

 */

/**

Zeile 79Zeile 79
	$plugins->run_hooks("post_output_page");

// If the use shutdown functionality is turned off, run any shutdown related items now.

	$plugins->run_hooks("post_output_page");

// If the use shutdown functionality is turned off, run any shutdown related items now.

	if($mybb->settings['useshutdownfunc'] == "no" && $mybb->use_shutdown == true)

	if(($mybb->settings['useshutdownfunc'] == "no" || phpversion() >= '5.0.5') && $mybb->use_shutdown != true) 

	{
run_shutdown();
}

	{
run_shutdown();
}

Zeile 106Zeile 106
 */
function run_shutdown()
{

 */
function run_shutdown()
{

	global $db, $cache, $shutdown_functions;


































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

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

Zeile 115Zeile 148
		foreach($db->shutdown_queries as $query)
{
$db->query($query);

		foreach($db->shutdown_queries as $query)
{
$db->query($query);

		}
}


		}
}


	// Run any shutdown functions if we have them
if(is_array($shutdown_functions))
{

	// Run any shutdown functions if we have them
if(is_array($shutdown_functions))
{

Zeile 126Zeile 159
			$function();
}
}

			$function();
}
}

 
	$done_shutdown = true;

}

/**

}

/**

Zeile 136Zeile 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 148Zeile 182

// Fetch emails for this page view - and send them
$query = $db->simple_select(TABLE_PREFIX."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(TABLE_PREFIX."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))
{

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

			$plugins->run_hooks("send_mail_queue_mail");


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


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


Zeile 269Zeile 304
		}
}


		}
}


	$plugins->run_hooks("my_date");

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


return $date;
}


return $date;
}

Zeile 306Zeile 341
	else if($_SERVER['HTTP_HOST'])
{
$http_host = $_SERVER['HTTP_HOST'];

	else if($_SERVER['HTTP_HOST'])
{
$http_host = $_SERVER['HTTP_HOST'];

	}

	}

	else
{
$http_host = "unknown.local";

	else
{
$http_host = "unknown.local";

Zeile 390Zeile 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 405Zeile 448
		}
}
return $forum_cache;

		}
}
return $forum_cache;

}


}


/**
* Produce a friendly error message page
*

/**
* Produce a friendly error message page
*

Zeile 474Zeile 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 498Zeile 540
{
global $header, $footer, $mybb, $theme, $headerinclude, $templates, $lang, $plugins;


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


 
	$loadpmpopup = false;

	if(!$message)
{
$message = $lang->redirect;

	if(!$message)
{
$message = $lang->redirect;

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

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

	}

	}

	if($mybb->settings['redirects'] == "on" && $mybb->user['showredirect'] != "no")
{
$url = str_replace("&", "&", $url);

	if($mybb->settings['redirects'] == "on" && $mybb->user['showredirect'] != "no")
{
$url = str_replace("&", "&", $url);

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

		$url = htmlspecialchars($url);

		eval("\$redirectpage = \"".$templates->get("redirect")."\";");
output_page($redirectpage);
}

		eval("\$redirectpage = \"".$templates->get("redirect")."\";");
output_page($redirectpage);
}

Zeile 657Zeile 700
		if(trim($gid) == "" || !$groupscache[$gid])
{
continue;

		if(trim($gid) == "" || !$groupscache[$gid])
{
continue;

		}

		}

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

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

Zeile 752Zeile 795
	}
if(!is_array($forum_cache))
{

	}
if(!is_array($forum_cache))
{

		cache_forums();





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

	}
if(!is_array($fpermcache))
{

	}
if(!is_array($fpermcache))
{

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

	// The fix here for better working inheritance was provided by tinywizard - http://windizupdate.com/
// Many thanks.
foreach($fpermfields as $perm)
{
$forumpermissions[$perm] = "no";
}


	
$current_permissions = array();






	foreach($groups as $gid)
{

	foreach($groups as $gid)
{

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

		if($groupscache[$gid])

		{

		{

			$p = is_array($fpermcache[$fid][$gid]) ? $fpermcache[$fid][$gid] : $groupperms;
if($p == NULL)

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

			{

			{

				foreach($forumpermissions as $k => $v)


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

				{

				{

					$forumpermissions[$k] = 'yes';        // no inherited group, assume one has access
}
}
else
{
foreach($p as $perm => $access)
{
if(isset($forumpermissions[$perm]) && $access == 'yes')

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








					{

					{

						$forumpermissions[$perm] = $access;

						$current_permissions[$permission] = $access;

					}
}
}
}
}

					}
}
}
}
}

	return $forumpermissions;






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

}

/**

}

/**

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

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

				my_setcookie("forumpass[$fid]", md5($mybb->user['uid'].$mybb->input['pwverify']));

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

				$showform = 0;
}
else

				$showform = 0;
}
else

Zeile 867Zeile 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 1019Zeile 1064
 * @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.

 
 * @param boolean True if setting a HttpOnly cookie (supported by IE, Opera 9, Konqueror)

 */

 */

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

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

{

{

	global $mybb, $sent_header;

if($sent_header)
{
return false;
}

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

	global $mybb;

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






	{
$expires = 0;

	{
$expires = 0;

	}
else

	}
else if($expires == "" || $expires == null)

	{
if($mybb->user['remember'] == "no")

	{
if($mybb->user['remember'] == "no")

		{

		{

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

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

		}
}
if($mybb->settings['cookiedomain'])
{
setcookie($name, $value, $expires, $mybb->settings['cookiepath'], $mybb->settings['cookiedomain']);
}
else
{
setcookie($name, $value, $expires, $mybb->settings['cookiepath']);
}
}





















		}
}
else
{
$expires = time() + intval($expires);
}

$mybb->settings['cookiepath'] = str_replace(array("\n","\r"), "", $mybb->settings['cookiepath']);
$mybb->settings['cookiedomain'] = str_replace(array("\n","\r"), "", $mybb->settings['cookiedomain']);

// Versions of PHP prior to 5.2 do not support HttpOnly cookies and IE is buggy when specifying a blank domain so set the cookie manually
$cookie = "Set-Cookie: {$name}=".urlencode($value);
if($expires > 0)
{
$cookie .= "; expires=".gmdate('D, d-M-Y H:i:s \\G\\M\\T', $expires);
}
if(!empty($mybb->settings['cookiepath']))
{
$cookie .= "; path={$mybb->settings['cookiepath']}";
}
if(!empty($mybb->settings['cookiedomain']))
{
$cookie .= "; domain={$mybb->settings['cookiedomain']}";
}
if($httponly == true)
{
$cookie .= "; HttpOnly";
}
header($cookie, false);
}


/**
* Unset a cookie set by MyBB.

/**
* Unset a cookie set by MyBB.

 *
* @param string The cookie identifier.
*/

 *
* @param string The cookie identifier.
*/

function my_unsetcookie($name)
{

function my_unsetcookie($name)
{

	global $mybb, $sent_header;

if($sent_header)
{
return false;
}

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

if($mybb->settings['cookiedomain'])
{
@setcookie($name, "", $expires, $mybb->settings['cookiepath'], $mybb->settings['cookiedomain']);
}
else
{
@setcookie($name, "", $expires, $mybb->settings['cookiepath']);
}

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



















}

/**

}

/**

Zeile 1109Zeile 1151
	else
{
return 0;

	else
{
return 0;

	}
}

/**

	}
}

/**

 * Set a serialised cookie array.
*
* @param string The cookie identifier.

 * Set a serialised cookie array.
*
* @param string The cookie identifier.

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

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

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

Zeile 1290Zeile 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 1322Zeile 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))
{
require_once MYBB_ROOT."inc/class_moderation.php";

{
global $moderation;
if(!is_object($moderation))
{
require_once MYBB_ROOT."inc/class_moderation.php";

		$moderation = new Moderation;
}
return $moderation->delete_thread($tid);

		$moderation = new Moderation;
}
return $moderation->delete_thread($tid);

}


}


/**
* Deletes a post from the database
*

/**
* Deletes a post from the database
*

Zeile 1359Zeile 1401
 * @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")
{
global $db, $forum_cache, $fjumpcache, $permissioncache, $mybb, $selecteddone, $forumjump, $forumjumpbits, $gobutton, $theme, $templates, $lang;

function build_forum_jump($pid="0", $selitem="", $addselect="1", $depth="", $showextras="1", $permissions="", $name="fid")
{
global $db, $forum_cache, $fjumpcache, $permissioncache, $mybb, $selecteddone, $forumjump, $forumjumpbits, $gobutton, $theme, $templates, $lang;

Zeile 1423Zeile 1465
			$jumpsel[$selitem] = "selected";
}
if($showextras == 0)

			$jumpsel[$selitem] = "selected";
}
if($showextras == 0)

		{

		{

			$template = "special";
}
else

			$template = "special";
}
else

Zeile 1581Zeile 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 1625Zeile 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 1746Zeile 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 1761Zeile 1802
function get_reputation($reputation, $uid=0)
{
global $theme;

function get_reputation($reputation, $uid=0)
{
global $theme;



	

	if($uid != 0)

	if($uid != 0)

	{

	{

		$display_reputation = "<a href=\"reputation.php?uid={$uid}\">";
}
$display_reputation .= "<strong class=\"";
if($reputation < 0)

		$display_reputation = "<a href=\"reputation.php?uid={$uid}\">";
}
$display_reputation .= "<strong class=\"";
if($reputation < 0)

	{

	{

		$display_reputation .= "reputation_negative";
}
else if($reputation > 0)

		$display_reputation .= "reputation_negative";
}
else if($reputation > 0)

Zeile 1797Zeile 1838
	if(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))

	if(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))

		{

		{

			foreach($addresses[0] as $key => $val)
{
if(!preg_match("#^(10|172\.16|192\.168)\.#", $val))

			foreach($addresses[0] as $key => $val)
{
if(!preg_match("#^(10|172\.16|192\.168)\.#", $val))

Zeile 1811Zeile 1852
	if(!isset($ip))
{
if(isset($_SERVER['HTTP_CLIENT_IP']))

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

		{

		{

			$ip = $_SERVER['HTTP_CLIENT_IP'];

			$ip = $_SERVER['HTTP_CLIENT_IP'];

		}

		}

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

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

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


	return $ip;
}


	return $ip;
}


Zeile 2035Zeile 2079
					// Set up link to forum in breadcrumb.
if($pforumcache[$fid][$forumnav['pid']]['type'] == 'f' || $pforumcache[$fid][$forumnav['pid']]['type'] == 'c')
{

					// Set up link to forum in breadcrumb.
if($pforumcache[$fid][$forumnav['pid']]['type'] == 'f' || $pforumcache[$fid][$forumnav['pid']]['type'] == 'c')
{

						$navbits[$navsize]['url'] = "{$base_url}/forum-".$forumnav['fid'].".html";

						$navbits[$navsize]['url'] = "{$base_url}forum-".$forumnav['fid'].".html";

					}
else
{

					}
else
{

Zeile 2143Zeile 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 2186Zeile 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 2526Zeile 2570
		else
{
$location = $_SERVER['PHP_SELF'];

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

		}

		}

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

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

		{

		{

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

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

Zeile 2567Zeile 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)

	if($tid == 0)

	{

	{

		$themeselect = "<select name=\"$name\">";
$themeselect .= "<option value=\"0\">".$lang->use_default."</option>\n";
$themeselect .= "<option value=\"0\">-----------</option>\n";

		$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
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['tid']] = $theme;

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

		}

		}

	}

	}

 
	

	if(is_array($tcache[$tid]))
{
// Figure out what groups this user is in

	if(is_array($tcache[$tid]))
{
// Figure out what groups this user is in

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




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

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

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

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

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

Zeile 2598Zeile 2645
			$sel = "";
// Make theme allowed groups into array
$is_allowed = false;

			$sel = "";
// Make theme allowed groups into array
$is_allowed = false;

			if($theme['allowedgroups'] != "all")

			if($theme['allowedgroups'] != "all" && $theme['allowedgroups'] != "")

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

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

Zeile 2611Zeile 2658
					}
}
}

					}
}
}

 
			

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

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

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

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

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

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

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

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

				}

				}

 
				

				if($theme['pid'] != 0)
{

				if($theme['pid'] != 0)
{

					$themeselect .= "<option value=\"".$theme['tid']."\" $sel>".$depth.$theme['name']."</option>";

					$themeselect .= "<option value=\"".$theme['tid']."\"$sel>".$depth.$theme['name']."</option>";

					$depthit = $depth."--";
}

					$depthit = $depth."--";
}

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


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

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

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

 
	

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

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

 
	

	return $themeselect;
}


	return $themeselect;
}


Zeile 2665Zeile 2717
	if($number == "-")
{
return $number;

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

	}

	}

	if(is_int($number))
{
return number_format($number, 0, $mybb->settings['decpoint'], $mybb->settings['thousandssep']);

	if(is_int($number))
{
return number_format($number, 0, $mybb->settings['decpoint'], $mybb->settings['thousandssep']);

Zeile 2794Zeile 2846
 * Updates the first posts in a thread.
*
* @param int The thread id for which to update the first post id.

 * Updates the first posts in a thread.
*
* @param int The thread id for which to update the first post id.

 */

 */

function update_first_post($tid)
{
global $db;

function update_first_post($tid)
{
global $db;

Zeile 2824Zeile 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 2871Zeile 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 2881Zeile 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 3165Zeile 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 3251Zeile 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 3337Zeile 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;

}

/**

}

/**