Vergleich inc/functions.php - 1.2.0 - 1.2.7

  Keine Änderungen   Hinzugefügt   Modifiziert   Entfernt
Zeile 3Zeile 3
 * MyBB 1.2
* Copyright � 2006 MyBB Group, All Rights Reserved
*

 * MyBB 1.2
* Copyright � 2006 MyBB Group, All Rights Reserved
*

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

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

 *

 *

 * $Id: functions.php 2191 2006-09-03 12:11:04Z chris $

 * $Id: functions.php 3070 2007-05-18 07:44:28Z 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

	}

// Run any shutdown functions if we have them

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
$mailcache = $cache->read("mailqueue");
if($mailcache['queue_size'] > 0 && ($mailcache['locked'] == 0 || $mailcache['locked'] < time()-300))

	$plugins->run_hooks("send_mail_queue_start");

// Check to see if the mail queue has messages needing to be sent
$mailcache = $cache->read("mailqueue");
if($mailcache['queue_size'] > 0 && ($mailcache['locked'] == 0 || $mailcache['locked'] < time()-300))

	{

	{

		// Lock the queue so no other messages can be sent whilst these are (for popular boards)
$cache->updatemailqueue(0, time());

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

		// Lock the queue so no other messages can be sent whilst these are (for popular boards)
$cache->updatemailqueue(0, time());

// 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 286Zeile 321
function my_mail($to, $subject, $message, $from="", $charset="", $headers="")
{
global $db, $mybb, $lang;

function my_mail($to, $subject, $message, $from="", $charset="", $headers="")
{
global $db, $mybb, $lang;





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

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

Zeile 318Zeile 353
	$headers .= "X-Priority: 3\n";
$headers .= "X-MSMail-Priority: Normal\n";
$headers .= "X-Mailer: MyBB\n";

	$headers .= "X-Priority: 3\n";
$headers .= "X-MSMail-Priority: Normal\n";
$headers .= "X-Mailer: MyBB\n";

 
	$headers .= "X-MyBB-Script: {$http_host}{$_SERVER['PHP_SELF']}\n";


// For some reason sendmail/qmail doesn't like \r\n
$sendmail = @ini_get('sendmail_path');


// For some reason sendmail/qmail doesn't like \r\n
$sendmail = @ini_get('sendmail_path');

Zeile 390Zeile 426

/**
* 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 474Zeile 518
		"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("&", "&amp;", $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 541
{
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 511Zeile 555
	if($mybb->settings['redirects'] == "on" && $mybb->user['showredirect'] != "no")
{
$url = str_replace("&amp;", "&", $url);

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

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

		$url = htmlspecialchars($url);

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

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

Zeile 752Zeile 796
	}
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))

	{

	{

		$fpermcache = $cache->read("forumpermissions");
}
if($fid) // Fetch the permissions for a single forum

		$fpermcache = $cache->read("forumpermissions");
}
if($fid) // Fetch the permissions for a single forum

Zeile 765Zeile 813
	else
{
foreach($forum_cache as $forum)

	else
{
foreach($forum_cache as $forum)

		{

		{

			$permissions[$forum['fid']] = fetch_forum_permissions($forum['fid'], $gid, $groupperms);
}
}

			$permissions[$forum['fid']] = fetch_forum_permissions($forum['fid'], $gid, $groupperms);
}
}

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

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

{

{

	global $groupscache, $forum_cache, $fpermcache, $mybb, $fpermfields;

	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)
{
foreach($forumpermissions as $k => $v)
{
$forumpermissions[$k] = 'yes'; // no inherited group, assume one has access
}
}
else

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








			{

			{

				foreach($p as $perm => $access)


				$level_permissions = $fpermcache[$fid][$gid];
foreach($level_permissions as $permission => $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 885
		{
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
{
eval("\$pwnote = \"".$templates->get("forumdisplay_password_wrongpass")."\";");

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

				$showform = 1;
}

				$showform = 1;
}

		}
else
{

		}
else
{

Zeile 867Zeile 912
	}
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 890Zeile 936
	{
$uid = $mybb->user['uid'];
}

	{
$uid = $mybb->user['uid'];
}

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


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

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

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

 
		

		$sql = build_parent_list($fid, "fid", "OR", $parentslist);

		$sql = build_parent_list($fid, "fid", "OR", $parentslist);

		$query = $db->query("
SELECT *
FROM ".TABLE_PREFIX."moderators
WHERE uid='$uid'
AND $sql
");

		$query = $db->simple_select(TABLE_PREFIX."moderators", "*", "uid='{$uid}' AND {$sql}");






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

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

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

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

	}
else
{

	}
else
{

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

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

	}

	}

 
	

	return $perms;
}


	return $perms;
}


Zeile 930Zeile 974
		$uid = $mybb->user['uid'];
}


		$uid = $mybb->user['uid'];
}


	if($mybb->usergroup['issupermod'] == "yes")


	$user_perms = user_permissions($uid);
if($user_perms['issupermod'] == "yes")

	{
return "yes";
}

	{
return "yes";
}

Zeile 938Zeile 983
	{
if(!$fid)
{

	{
if(!$fid)
{

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

			$query = $db->simple_select(TABLE_PREFIX.'moderators', 'COUNT(*) as count', "uid={$uid}", array('limit' => 1));

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

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

			if($modcheck['mid'])

			if($modcheck['count'] > 0)

			{
return "yes";
}

			{
return "yes";
}

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

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

		}
}

		}
}

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

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

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

	global $mybb;

if(!$mybb->settings['cookiepath'])






	{
$mybb->settings['cookiepath'] = "/";
}

	{
$mybb->settings['cookiepath'] = "/";
}

Zeile 1037Zeile 1078
	{
$expires = 0;
}

	{
$expires = 0;
}

	else

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

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

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

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

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

	}
if($mybb->settings['cookiedomain'])



















	}
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']))

	{

	{

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

		$cookie .= "; domain={$mybb->settings['cookiedomain']}";

	}

	}

	else

	if($httponly == true)

	{

	{

		setcookie($name, $value, $expires, $mybb->settings['cookiepath']);

		$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 1140Zeile 1182
	{
return $lang->unknown;
}

	{
return $lang->unknown;
}

	elseif(@file_exists("/proc/loadavg"))

	elseif(@file_exists("/proc/loadavg") && $load = @file_get_contents("/proc/loadavg"))

	{

	{

		$load = @file_get_contents("/proc/loadavg");

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

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

Zeile 1164Zeile 1205
		$returnload = $lang->unknown;
}
return $returnload;

		$returnload = $lang->unknown;
}
return $returnload;

}







































































































































}

/**
* Updates the forum statistics with specific values (or addition/subtraction of the previous value)
*
* @param array Array of items being updated (numthreads,numposts,numusers)
*/
function update_stats($changes=array())
{
global $cache, $db;

$stats = $cache->read("stats");

$counters = array('numthreads','numposts','numusers');
$update = array();
foreach($counters as $counter)
{
if(array_key_exists($counter, $changes))
{
// Adding or subtracting from previous value?
if(substr($changes[$counter], 0, 1) == "+" || substr($changes[$counter], 0, 1) == "-")
{
$new_stats[$counter] = $stats[$counter] + $changes[$counter];
}
else
{
$new_stats[$counter] = $changes[$counter];
}
// Less than 0? That's bad
if($new_stats[$counter] < 0)
{
$new_stats[$counter] = 0;
}
}
}

// Fetch latest user if the user count is changing
if(array_key_exists('numusers', $changes))
{
$query = $db->simple_select(TABLE_PREFIX."users", "uid, username", "", array('order_by' => 'uid', 'order_dir' => 'DESC', 'limit' => 1));
$lastmember = $db->fetch_array($query);
$new_stats['lastuid'] = $lastmember['uid'];
$new_stats['lastusername'] = $lastmember['username'];
}
if(is_array($stats))
{
$stats = array_merge($stats, $new_stats);
}
else
{
$stats = $new_stats;
}
$cache->update("stats", $stats);
}

/**
* Updates the forum counters with a specific value (or addition/subtraction of the previous value)
*
* @param int The forum ID
* @param array Array of items being updated (threads, posts, unapprovedthreads, unapprovedposts) and their value (ex, 1, +1, -1)
*/
function update_forum_counters($fid, $changes=array())
{
global $db, $cache;

$update_query = array();

$counters = array('threads', 'unapprovedthreads', 'posts', 'unapprovedposts');

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

foreach($counters as $counter)
{
if(array_key_exists($counter, $changes))
{
// Adding or subtracting from previous value?
if(substr($changes[$counter], 0, 1) == "+" || substr($changes[$counter], 0, 1) == "-")
{
$update_query[$counter] = $forum[$counter] + $changes[$counter];
}
else
{
$update_query[$counter] = $changes[$counter];
}
// Less than 0? That's bad
if($update_query[$counter] < 0)
{
$update_query[$counter] = 0;
}
}
}

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

// Guess we should update the statistics too?
if($update_query['threads'] || $update_query['posts'])
{
$new_stats = array();
if(array_key_exists('threads', $update_query))
{
$threads_diff = $update_query['threads'] - $forum['threads'];
if($threads_diff > -1)
{
$new_stats['numthreads'] = "+{$threads_diff}";
}
else
{
$new_stats['numthreads'] = "{$threads_diff}";
}
}
if(array_key_exists('posts', $update_query))
{
$posts_diff = $update_query['posts'] - $forum['posts'];
if($posts_diff > -1)
{
$new_stats['numposts'] = "+{$posts_diff}";
}
else
{
$new_stats['numposts'] = "{$posts_diff}";
}
}
update_stats($new_stats);
}

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


/**

/**

 * Update the forum counters for a specific forum

 * Update the last post information for a specific forum

 *
* @param int The forum ID
*/

 *
* @param int The forum ID
*/

function update_forum_count($fid)

function update_forum_lastpost($fid)

{

{

	global $db, $cache;

	global $db;


// Fetch the last post for this forum
$query = $db->query("


// Fetch the last post for this forum
$query = $db->query("

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


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


	// Fetch the number of threads and replies in this forum (Approved only)
$query = $db->query("
SELECT COUNT(*) AS threads, SUM(replies) AS replies
FROM ".TABLE_PREFIX."threads
WHERE fid='$fid' AND visible='1' AND closed NOT LIKE 'moved|%'
");
$count = $db->fetch_array($query);
$count['posts'] = $count['threads'] + $count['replies'];

// Fetch the number of threads and replies in this forum (Unapproved only)
$query = $db->query("
SELECT COUNT(*) AS threads
FROM ".TABLE_PREFIX."threads
WHERE fid='$fid' AND visible='0' AND closed NOT LIKE 'moved|%'
");
$unapproved_count['threads'] = $db->fetch_field($query, "threads");
$query = $db->query("
SELECT SUM(unapprovedposts) AS posts
FROM ".TABLE_PREFIX."threads
WHERE fid='$fid' AND closed NOT LIKE 'moved|%'
");
$unapproved_count['posts'] = $db->fetch_field($query, "posts");

$update_count = array(
"posts" => intval($count['posts']),
"threads" => intval($count['threads']),
"unapprovedposts" => intval($unapproved_count['posts']),
"unapprovedthreads" => intval($unapproved_count['threads']),

	$updated_forum = array(




























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

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

	);

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

/**
* Update the thread counters for a specific thread
*
* @param int The thread ID
*/
function update_thread_count($tid)
{
global $db, $cache;
$query = $db->query("
SELECT COUNT(*) AS replies
FROM ".TABLE_PREFIX."posts
WHERE tid='$tid'
AND visible='1'
");
$replies = $db->fetch_array($query);
$treplies = $replies['replies'] - 1;
if($treplies < 0)

























	);

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

/**
* Updates the thread counters with a specific value (or addition/subtraction of the previous value)
*
* @param int The thread ID
* @param array Array of items being updated (replies, unapprovedposts, attachmentcount) and their value (ex, 1, +1, -1)
*/
function update_thread_counters($tid, $changes=array())
{
global $db;

$update_query = array();

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

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

foreach($counters as $counter)
{
if(array_key_exists($counter, $changes))
{
// Adding or subtracting from previous value?
if(substr($changes[$counter], 0, 1) == "+" || substr($changes[$counter], 0, 1) == "-")
{
$update_query[$counter] = $thread[$counter] + $changes[$counter];
}
else
{
$update_query[$counter] = $changes[$counter];
}
// Less than 0? That's bad
if($update_query[$counter] < 0)
{
$update_query[$counter] = 0;
}
}
}

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

	{

	{

		$treplies = 0;

		$db->update_query(TABLE_PREFIX."threads", $update_query, "tid='".intval($tid)."'");

	}

	}

 

update_thread_data($tid);
}

/**
* Update the first post and lastpost data for a specific thread
*
* @param int The thread ID
*/
function update_thread_data($tid)
{
global $db;

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

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


		FROM ".TABLE_PREFIX."posts p
LEFT JOIN ".TABLE_PREFIX."users u ON (u.uid=p.uid)

		WHERE p.tid='$tid' AND p.visible='1'
ORDER BY p.dateline DESC
LIMIT 1"

		WHERE p.tid='$tid' AND p.visible='1'
ORDER BY p.dateline DESC
LIMIT 1"

Zeile 1254Zeile 1438

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


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


		FROM ".TABLE_PREFIX."posts p
LEFT JOIN ".TABLE_PREFIX."users u ON (u.uid=p.uid)

		WHERE p.tid='$tid'
ORDER BY p.dateline ASC

		WHERE p.tid='$tid'
ORDER BY p.dateline ASC

		LIMIT 0,1

		LIMIT 1

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

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

 


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

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

 


	if(!$lastpost['username'])

	if(!$lastpost['username'])

	{

	{

		$lastpost['username'] = $lastpost['postusername'];
}

		$lastpost['username'] = $lastpost['postusername'];
}

	



	if(!$lastpost['dateline'])
{
$lastpost['username'] = $firstpost['username'];
$lastpost['uid'] = $firstpost['uid'];
$lastpost['dateline'] = $firstpost['dateline'];

	if(!$lastpost['dateline'])
{
$lastpost['username'] = $firstpost['username'];
$lastpost['uid'] = $firstpost['uid'];
$lastpost['dateline'] = $firstpost['dateline'];

	}	

	}


$lastpost['username'] = $db->escape_string($lastpost['username']);
$firstpost['username'] = $db->escape_string($firstpost['username']);


$lastpost['username'] = $db->escape_string($lastpost['username']);
$firstpost['username'] = $db->escape_string($firstpost['username']);

	// Unapproved posts
$query = $db->query("
SELECT COUNT(*) AS totunposts
FROM ".TABLE_PREFIX."posts
WHERE tid='$tid' AND visible='0'
");
$nounposts = $db->fetch_field($query, "totunposts");

// Update the attachment count for this thread
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'
WHERE tid='$tid'
");
}

/**
* Updates the number of attachments for a specific thread
*
* @param int The thread ID
*/
function update_thread_attachment_count($tid)


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

function update_forum_count($fid)
{
die("Depreciated function call: update_forum_count");
}
function update_thread_count($tid)








{

{

	global $db;
$query = $db->query("
SELECT COUNT(*) AS attachment_count
FROM ".TABLE_PREFIX."attachments a LEFT JOIN ".TABLE_PREFIX."posts p ON (a.pid=p.pid)
WHERE p.tid='$tid'
");
$attachment_count = $db->fetch_field($query, "attachment_count");
$db->query("
UPDATE ".TABLE_PREFIX."threads
SET attachmentcount='{$attachment_count}'
WHERE tid='$tid'
");
}


	die("Depreciated function call: update_thread_count");
}
function update_thread_attachment_count($tid)
{
die("Depreciated function call: update_thread_attachment_count");
}









/**
* Deletes a thread from the database
*
* @param int The thread ID
*/
function delete_thread($tid)

/**
* Deletes a thread from the database
*
* @param int The thread ID
*/
function delete_thread($tid)

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

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

	}
return $moderation->delete_thread($tid);
}

	}
return $moderation->delete_thread($tid);
}

Zeile 1350Zeile 1523

/**
* Builds a forum jump menu


/**
* Builds a forum jump menu

 *

 *

 * @param int The parent forum to start with
* @param int The selected item ID
* @param int If we need to add select boxes to this cal or not

 * @param int The parent forum to start with
* @param int The selected item ID
* @param int If we need to add select boxes to this cal or not

Zeile 1380Zeile 1553
			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))

	{

	{

		$permissioncache = forum_permissions();
}
if(is_array($jumpfcache[$pid]))

		$permissioncache = forum_permissions();
}
if(is_array($jumpfcache[$pid]))

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

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

			}

			}

		}
}
if($addselect)

		}
}
if($addselect)

Zeile 1494Zeile 1667
	}
$format = stripslashes($format);
return str_replace("{username}", $username, $format);

	}
$format = stripslashes($format);
return str_replace("{username}", $username, $format);

}

/**

}

/**

 * Build the javascript based MyCode inserter
*
* @return string The MyCode inserter

 * Build the javascript based MyCode inserter
*
* @return string The MyCode inserter

Zeile 1581Zeile 1754
 */
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 1797
					{
$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 1918
		"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 1933
function get_reputation($reputation, $uid=0)
{
global $theme;

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



	

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

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

Zeile 1804Zeile 1976
				{
$ip = $val;
break;

				{
$ip = $val;
break;

				}
}
}
}

				}
}
}
}

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

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

		}

		}

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

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

 

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


	return $ip;
}


	return $ip;
}


Zeile 1837Zeile 2012
		$size = round(($size / 1073741824), 2) . " " . $lang->size_gb;
}
elseif($size >= 1048576)

		$size = round(($size / 1073741824), 2) . " " . $lang->size_gb;
}
elseif($size >= 1048576)

	{

	{

		$size = round(($size / 1048576), 2) . " " . $lang->size_mb;
}
elseif($size >= 1024)
{
$size = round(($size / 1024), 2) . " " . $lang->size_kb;

		$size = round(($size / 1048576), 2) . " " . $lang->size_mb;
}
elseif($size >= 1024)
{
$size = round(($size / 1024), 2) . " " . $lang->size_kb;

	}

	}

	elseif($size == 0)
{
$size = "0 ".$lang->size_bytes;

	elseif($size == 0)
{
$size = "0 ".$lang->size_bytes;

Zeile 1853Zeile 2028
		$size = $size . " " . $lang->size_bytes;
}
return $size;

		$size = $size . " " . $lang->size_bytes;
}
return $size;

}


}


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

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

Zeile 1946Zeile 2121
	$format = str_replace("Y", $year, $format);
$format = str_replace("y", my_substr($year, -2), $format);
return $format;

	$format = str_replace("Y", $year, $format);
$format = str_replace("y", my_substr($year, -2), $format);
return $format;

}

/**

}

/**

 * Build the breadcrumb navigation trail from the specified items
*
* @return The formatted breadcrumb navigation trail
*/
function build_breadcrumb()

 * Build the breadcrumb navigation trail from the specified items
*
* @return The formatted breadcrumb navigation trail
*/
function build_breadcrumb()

{

{

	global $nav, $navbits, $templates, $theme, $lang;

	global $nav, $navbits, $templates, $theme, $lang;





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

if(is_array($navbits))

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

if(is_array($navbits))

	{

	{

		reset($navbits);
foreach($navbits as $key => $navbit)
{

		reset($navbits);
foreach($navbits as $key => $navbit)
{

Zeile 1995Zeile 2170
	$navsize = count($navbits);
$navbits[$navsize]['name'] = $name;
$navbits[$navsize]['url'] = $url;

	$navsize = count($navbits);
$navbits[$navsize]['name'] = $name;
$navbits[$navsize]['url'] = $url;

}

}


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


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

Zeile 2035Zeile 2210
					// 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 2135Zeile 2310
	echo "<table bgcolor=\"#666666\" width=\"95%\" cellpadding=\"4\" cellspacing=\"1\" align=\"center\">\n";
echo "<tr>\n";
echo "<td bgcolor=\"#CCCCCC\" colspan=\"4\"><b><span style=\"size:2;\">Page Generation Statistics</span></b></td>\n";

	echo "<table bgcolor=\"#666666\" width=\"95%\" cellpadding=\"4\" cellspacing=\"1\" align=\"center\">\n";
echo "<tr>\n";
echo "<td bgcolor=\"#CCCCCC\" colspan=\"4\"><b><span style=\"size:2;\">Page Generation Statistics</span></b></td>\n";

	echo "</tr>\n";
echo "<tr>\n";

	echo "</tr>\n";
echo "<tr>\n";

	echo "<td bgcolor=\"#EFEFEF\" width=\"25%\"><b><font face=\"Tahoma\" size=\"2\">Page Generation Time:</font></b></td>\n";
echo "<td bgcolor=\"#FEFEFE\" width=\"25%\"><font face=\"Tahoma\" size=\"2\">$totaltime seconds</font></td>\n";
echo "<td bgcolor=\"#EFEFEF\" width=\"25%\"><b><font face=\"Tahoma\" size=\"2\">No. MySQL Queries:</font></b></td>\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\">Page Generation Time:</font></b></td>\n";
echo "<td bgcolor=\"#FEFEFE\" width=\"25%\"><font face=\"Tahoma\" size=\"2\">$totaltime seconds</font></td>\n";
echo "<td bgcolor=\"#EFEFEF\" width=\"25%\"><b><font face=\"Tahoma\" size=\"2\">No. MySQL Queries:</font></b></td>\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";

	echo "</tr>\n";

	echo "</tr>\n";

	echo "<tr>\n";
echo "<td bgcolor=\"#EFEFEF\" width=\"25%\"><b><font face=\"Tahoma\" size=\"2\">Extensions Used:</font></b></td>\n";
echo "<td bgcolor=\"#FEFEFE\" width=\"25%\"><font face=\"Tahoma\" size=\"2\">{$mybb->config['dbtype']}, xml</font></td>\n";
echo "<td bgcolor=\"#EFEFEF\" width=\"25%\"><b><font face=\"Tahoma\" size=\"2\">Global.php Processing Time:</font></b></td>\n";
echo "<td bgcolor=\"#FEFEFE\" width=\"25%\"><font face=\"Tahoma\" size=\"2\">$globaltime seconds</font></td>\n";

	echo "<tr>\n";
echo "<td bgcolor=\"#EFEFEF\" width=\"25%\"><b><font face=\"Tahoma\" size=\"2\">Extensions Used:</font></b></td>\n";
echo "<td bgcolor=\"#FEFEFE\" width=\"25%\"><font face=\"Tahoma\" size=\"2\">{$mybb->config['dbtype']}, xml</font></td>\n";
echo "<td bgcolor=\"#EFEFEF\" width=\"25%\"><b><font face=\"Tahoma\" size=\"2\">Global.php Processing Time:</font></b></td>\n";
echo "<td bgcolor=\"#FEFEFE\" width=\"25%\"><font face=\"Tahoma\" size=\"2\">$globaltime seconds</font></td>\n";

	echo "</tr>\n";

	echo "</tr>\n";

	echo "<tr>\n";
echo "<td bgcolor=\"#EFEFEF\" width=\"25%\"><b><font face=\"Tahoma\" size=\"2\">PHP Version:</font></b></td>\n";
echo "<td bgcolor=\"#FEFEFE\" width=\"25%\"><font face=\"Tahoma\" size=\"2\">$phpversion</font></td>\n";
echo "<td bgcolor=\"#EFEFEF\" width=\"25%\"><b><font face=\"Tahoma\" size=\"2\">Server Load:</font></b></td>\n";
echo "<td bgcolor=\"#FEFEFE\" width=\"25%\"><font face=\"Tahoma\" size=\"2\">$serverload</font></td>\n";

	echo "<tr>\n";
echo "<td bgcolor=\"#EFEFEF\" width=\"25%\"><b><font face=\"Tahoma\" size=\"2\">PHP Version:</font></b></td>\n";
echo "<td bgcolor=\"#FEFEFE\" width=\"25%\"><font face=\"Tahoma\" size=\"2\">$phpversion</font></td>\n";
echo "<td bgcolor=\"#EFEFEF\" width=\"25%\"><b><font face=\"Tahoma\" size=\"2\">Server Load:</font></b></td>\n";
echo "<td bgcolor=\"#FEFEFE\" width=\"25%\"><font face=\"Tahoma\" size=\"2\">$serverload</font></td>\n";

	echo "</tr>\n";

	echo "</tr>\n";

	echo "<tr>\n";
echo "<td bgcolor=\"#EFEFEF\" width=\"25%\"><b><font face=\"Tahoma\" size=\"2\">GZip Encoding Status:</font></b></td>\n";
echo "<td bgcolor=\"#FEFEFE\" width=\"25%\"><font face=\"Tahoma\" size=\"2\">$gzipen</font></td>\n";

	echo "<tr>\n";
echo "<td bgcolor=\"#EFEFEF\" width=\"25%\"><b><font face=\"Tahoma\" size=\"2\">GZip Encoding Status:</font></b></td>\n";
echo "<td bgcolor=\"#FEFEFE\" width=\"25%\"><font face=\"Tahoma\" size=\"2\">$gzipen</font></td>\n";

Zeile 2183Zeile 2358
	echo "<h2>Template Statistics</h2>\n";

if(count($templates->cache) > 0)

	echo "<h2>Template Statistics</h2>\n";

if(count($templates->cache) > 0)

	{
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 "</tr>\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 "<tr>\n";
echo "<td style=\"background: #fff;\">".implode(", ", array_keys($templates->cache))."</td>\n";
echo "</tr>\n";

Zeile 2199Zeile 2374
	{
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 Requiring Additional Calls (Not Cached at Startup) - ".count($templates->uncached_templates)." Total</strong></td>\n";

		echo "<td style=\"background-color: #ccc;\"><strong>Templates Requiring Additional Calls (Not Cached at Startup) - ".count($templates->uncached_templates)." Total</strong></td>\n";

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

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

Zeile 2332Zeile 2507
	}

if($days == 1)

	}

if($days == 1)

	{

	{

		$nicetime['days'] = "1 ".$lang->day;

		$nicetime['days'] = "1 ".$lang->day;

	}

	}

	elseif($days > 1)
{
$nicetime['days'] = $days." ".$lang->days;

	elseif($days > 1)
{
$nicetime['days'] = $days." ".$lang->days;

	}


	}


	if($hours == 1)
{
$nicetime['hours'] = "1 ".$lang->hour;
}
elseif($hours > 1)

	if($hours == 1)
{
$nicetime['hours'] = "1 ".$lang->hour;
}
elseif($hours > 1)

	{

	{

		$nicetime['hours'] = $hours." ".$lang->hours;
}


		$nicetime['hours'] = $hours." ".$lang->hours;
}


Zeile 2356Zeile 2531
	elseif($minutes > 1)
{
$nicetime['minutes'] = $minutes." ".$lang->minutes;

	elseif($minutes > 1)
{
$nicetime['minutes'] = $minutes." ".$lang->minutes;

	}


	}


	if($seconds == 1)
{

	if($seconds == 1)
{

		$nicetime['seconds'] = "1 ".$lang->seconds;

		$nicetime['seconds'] = "1 ".$lang->second;

	}
elseif($seconds > 1)
{

	}
elseif($seconds > 1)
{

Zeile 2382Zeile 2557
{
global $alttrow;
if($alttrow == "trow1" && !$reset)

{
global $alttrow;
if($alttrow == "trow1" && !$reset)

	{

	{

		$trow = "trow2";
}
else

		$trow = "trow2";
}
else

Zeile 2392Zeile 2567
	$alttrow = $trow;
return $trow;
}

	$alttrow = $trow;
return $trow;
}





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

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

Zeile 2403Zeile 2578
{
global $db;
if($uid == $mybb->user['uid'])

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

	{

	{

		$user = $mybb->user;
}
else

		$user = $mybb->user;
}
else

Zeile 2426Zeile 2601
		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->query("

		}
}
$db->query("

Zeile 2477Zeile 2652
				$comma = ",";
$donegroup[$gid] = 1;
}

				$comma = ",";
$donegroup[$gid] = 1;
}

		}
}

		}
}

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

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

Zeile 2502Zeile 2677
		return MYBB_LOCATION;
}
if(isset($_SERVER['REQUEST_URI']))

		return MYBB_LOCATION;
}
if(isset($_SERVER['REQUEST_URI']))

	{

	{

		$location = $_SERVER['REQUEST_URI'];
}
elseif(isset($ENV_['REQUEST_URI']))

		$location = $_SERVER['REQUEST_URI'];
}
elseif(isset($ENV_['REQUEST_URI']))

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

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

		{
$location = $_SERVER['PATH_INFO'];
}

		{
$location = $_SERVER['PATH_INFO'];
}

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

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

		{

		{

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

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

		}

		}

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

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

		}

		}

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

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

		}
}

		}
}


if((isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] == "POST") || (isset($_ENV['REQUEST_METHOD']) && $_ENV['REQUEST_METHOD'] == "POST"))
{


if((isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] == "POST") || (isset($_ENV['REQUEST_METHOD']) && $_ENV['REQUEST_METHOD'] == "POST"))
{

Zeile 2566Zeile 2741
 * @return string The theme selection list
*/
function build_theme_select($name, $selected="", $tid=0, $depth="", $usergroup_override=0)

 * @return string The theme selection list
*/
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
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))
{
$tcache[$theme['pid']][$theme['tid']] = $theme;
}
}

		while($theme = $db->fetch_array($query))
{
$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 2776
			$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
foreach($allowed_groups as $agid)

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

Zeile 2611Zeile 2789
					}
}
}

					}
}
}

 
			

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


	}

if($tid)

	{
$themeselect .= "</select>";
}

	{
$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 2649Zeile 2832
	$message = str_replace("<","&lt;",$message);
$message = str_replace(">","&gt;",$message);
$message = str_replace("\"","&quot;",$message);

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

	$message = str_replace("  ", "&nbsp;&nbsp;", $message);

 
	return $message;
}


	return $message;
}


Zeile 2660Zeile 2842
 * @return int The formatted number.
*/
function my_number_format($number)

 * @return int The formatted number.
*/
function my_number_format($number)

{
global $mybb;

{
global $mybb;

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

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

Zeile 2669Zeile 2851
	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']);

	}

	}

	else
{
$parts = explode('.', $number);
if(isset($parts[1]))

	else
{
$parts = explode('.', $number);
if(isset($parts[1]))

		{

		{

			$decimals = my_strlen($parts[1]);
}
else

			$decimals = my_strlen($parts[1]);
}
else

Zeile 2682Zeile 2864
			$decimals = 0;
}
return number_format($number, $decimals, $mybb->settings['decpoint'], $mybb->settings['thousandssep']);

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

	}
}


	}
}


/**
* Replacement function for PHP's wordwrap(). This version does not break up HTML tags, URLs or unicode references.
*

/**
* Replacement function for PHP's wordwrap(). This version does not break up HTML tags, URLs or unicode references.
*

Zeile 2694Zeile 2876
function my_wordwrap($message)
{
global $mybb;

function my_wordwrap($message)
{
global $mybb;





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

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

}

/**

}

/**

 * Workaround for date limitation in PHP to establish the day of a birthday (Provided by meme)
*
* @param int The month of the birthday

 * Workaround for date limitation in PHP to establish the day of a birthday (Provided by meme)
*
* @param int The month of the birthday

Zeile 2775Zeile 2957
 */
function get_age($birthday)
{

 */
function get_age($birthday)
{

        $bday = explode("-", $birthday);
if($bday[2] < 1970)
{
$years = 1970-$bday[2];
$year = $bday[2]+($years*2);
$stamp = mktime(0, 0, 0, $bday[1], $bday[0], $year)-($years*31556926*2);
}
else
{
$stamp = mktime(0, 0, 0, $bday[1], $bday[0], $bday[2]);
}
$age = floor((time()-$stamp)/31556926);
return $age;



	$bday = explode("-", $birthday);
if(!$bday[2])
{
return;
}

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

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

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

}

/**

}

/**

Zeile 2824Zeile 3008
 */
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 3069
	}

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 3146
 */
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 3432
			$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 3518
*/
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 3285Zeile 3552

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


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

		$setting['value'] = str_replace("\"", "\\\"", $setting['value']);
$settings .= "\$settings['".$setting['name']."'] = \"".$setting['value']."\";\n";

 
		$mybb->settings[$setting['name']] = $setting['value'];

		$mybb->settings[$setting['name']] = $setting['value'];

 
		$setting['value'] = addcslashes($setting['value'], '\\"$');
$settings .= "\$settings['{$setting['name']}'] = \"{$setting['value']}\";\n";

	}
$settings = "<"."?php\n/*********************************\ \n DO NOT EDIT THIS FILE, PLEASE USE\n THE SETTINGS EDITOR\n\*********************************/\n\n$settings\n?".">";
$file = @fopen(MYBB_ROOT."inc/settings.php", $mode);

	}
$settings = "<"."?php\n/*********************************\ \n DO NOT EDIT THIS FILE, PLEASE USE\n THE SETTINGS EDITOR\n\*********************************/\n\n$settings\n?".">";
$file = @fopen(MYBB_ROOT."inc/settings.php", $mode);

Zeile 3337Zeile 3604
		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;

}

/**

}

/**