Vergleich inc/functions.php - 1.2.7 - 1.2.14

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

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

 * $Id: functions.php 3070 2007-05-18 07:44:28Z chris $

 * $Id: functions.php 3845 2008-05-18 17:50:09Z Tikitiki $

 */

/**

 */

/**

Zeile 18Zeile 18
{
global $db, $lang, $theme, $plugins, $mybb;
global $querytime, $debug, $templatecache, $templatelist, $maintimer, $globaltime, $parsetime;

{
global $db, $lang, $theme, $plugins, $mybb;
global $querytime, $debug, $templatecache, $templatelist, $maintimer, $globaltime, $parsetime;



 
	$contents = parse_page($contents);
$totaltime = $maintimer->stop();
if($mybb->usergroup['cancp'] == "yes")

	$contents = parse_page($contents);
$totaltime = $maintimer->stop();
if($mybb->usergroup['cancp'] == "yes")

Zeile 74Zeile 73
			$contents = gzip_encode($contents);
}
}

			$contents = gzip_encode($contents);
}
}

 

@header("Content-type: text/html; charset={$lang->settings['charset']}");


	echo $contents;

$plugins->run_hooks("post_output_page");

	echo $contents;

$plugins->run_hooks("post_output_page");





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

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

	}
}

/**

	}
}

/**

 * Adds a function to the list of functions to run on shutdown.
*
* @param string The name of the function.

 * Adds a function to the list of functions to run on shutdown.
*
* @param string The name of the function.

 */

 */

function add_shutdown($name)
{
global $shutdown_functions;

function add_shutdown($name)
{
global $shutdown_functions;





	if(function_exists($name))
{
$shutdown_functions[$name] = $name;

	if(function_exists($name))
{
$shutdown_functions[$name] = $name;

Zeile 105Zeile 107
 *
*/
function run_shutdown()

 *
*/
function run_shutdown()

{

{

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

if($done_shutdown == true)

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

if($done_shutdown == true)

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

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

	{

	{

		require MYBB_ROOT."inc/config.php";
if(isset($config))
{

		require MYBB_ROOT."inc/config.php";
if(isset($config))
{

Zeile 131Zeile 133
	{
require_once MYBB_ROOT."inc/class_datacache.php";
$cache = new datacache;

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

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

Zeile 148Zeile 150
		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 219Zeile 221
	{
$contents = "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n".$contents;
}

	{
$contents = "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n".$contents;
}

 
	
$contents = str_replace("<html", "<html xmlns=\"http://www.w3.org/1999/xhtml\"", $contents);


	if($lang->settings['rtl'] == 1)
{
$contents = str_replace("<html", "<html dir=\"rtl\"", $contents);
}
if($lang->settings['htmllang'])

	if($lang->settings['rtl'] == 1)
{
$contents = str_replace("<html", "<html dir=\"rtl\"", $contents);
}
if($lang->settings['htmllang'])

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

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


if($loadpmpopup)
{


if($loadpmpopup)
{

Zeile 236Zeile 241
		}
}
return $contents;

		}
}
return $contents;

}


}


/**
* Turn a unix timestamp in to a "friendly" date/time format for the user.
*

/**
* Turn a unix timestamp in to a "friendly" date/time format for the user.
*

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

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

	}

	}


// Build mail headers
if(my_strlen(trim($from)) == 0)
{
$from = "\"".$mybb->settings['bbname']." Mailer\" <".$mybb->settings['adminemail'].">";


// Build mail headers
if(my_strlen(trim($from)) == 0)
{
$from = "\"".$mybb->settings['bbname']." Mailer\" <".$mybb->settings['adminemail'].">";

	}

	}

	$headers .= "From: {$from}\n";
$headers .= "Return-Path: {$mybb->settings['adminemail']}\n";
if($_SERVER['SERVER_NAME'])

	$headers .= "From: {$from}\n";
$headers .= "Return-Path: {$mybb->settings['adminemail']}\n";
if($_SERVER['SERVER_NAME'])

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

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

	}
else

	}
else

	{
$http_host = "unknown.local";
}

	{
$http_host = "unknown.local";
}

Zeile 353Zeile 358
	$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";

 
	if(defined("IN_ADMINCP"))
{
$_SERVER['PHP_SELF'] = str_replace($mybb->config['admin_dir']."/", "admin-", $_SERVER['PHP_SELF']);
}

	$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');
if($sendmail)

	$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');
if($sendmail)

	{

	{

		$headers = preg_replace("#(\r\n|\r|\n)#s", "\n", $headers);
$message = preg_replace("#(\r\n|\r|\n)#s", "\n", $message);

		$headers = preg_replace("#(\r\n|\r|\n)#s", "\n", $headers);
$message = preg_replace("#(\r\n|\r|\n)#s", "\n", $message);

	}
else
{

	}
else
{

		$headers = preg_replace("#(\r\n|\r|\n)#s", "\r\n", $headers);
$message = preg_replace("#(\r\n|\r|\n)#s", "\r\n", $message);

		$headers = preg_replace("#(\r\n|\r|\n)#s", "\r\n", $headers);
$message = preg_replace("#(\r\n|\r|\n)#s", "\r\n", $message);

	}


	}


	mail($to, $subject, $message, $headers);

	mail($to, $subject, $message, $headers);

 
}

/**
* Generates a unique code for POST requests to prevent XSS/CSRF attacks
*
* @return string The generated code
*/
function generate_post_check()
{
global $mybb;
if($mybb->user['uid'])
{
return md5($mybb->user['loginkey'].$mybb->user['salt'].$mybb->user['regdate']);
}
// Guests get a special string
else
{
return md5($mybb->config['hostname'].$mybb->config['username'].$mybb->config['password']);
}
}

/**
* Verifies a POST check code is valid, if not shows an error (silently returns false on silent parameter)
*
* @param string The incoming POST check code
* @param boolean Silent mode or not (silent mode will not show the error to the user but returns false)
*/
function verify_post_check($code, $silent=false)
{
global $lang;
if(generate_post_check() != $code)
{
if($silent == true)
{
return false;
}
else
{
error($lang->invalid_post_code);
}
}
else
{
return true;
}

}

/**

}

/**

Zeile 517Zeile 571
		"location1" => 0,
"location2" => 0
);

		"location1" => 0,
"location2" => 0
);

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

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

	$url = htmlspecialchars_uni($_SERVER['REQUEST_URI']);
if($mybb->user['uid'])
{

	$url = htmlspecialchars_uni($_SERVER['REQUEST_URI']);
if($mybb->user['uid'])
{

Zeile 663Zeile 717
		}

// Collect group permissions.

		}

// Collect group permissions.

		$gid = $user_cache[$uid]['usergroup'].",".$user_cache[$uid]['additionalgroups'];





		$gid = $user_cache[$uid]['usergroup'];
if($user_cache[$uid]['additionalgroups'])
{
$gid .= ",".$user_cache[$uid]['additionalgroups'];
}

		$groupperms = usergroup_permissions($gid);

// Store group permissions in user cache.

		$groupperms = usergroup_permissions($gid);

// Store group permissions in user cache.

Zeile 672Zeile 730
	}
// This user is the current user, return their permissions
else

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

	{

	{

		return $mybb->usergroup;
}
}

		return $mybb->usergroup;
}
}





/**
* Fetch the usergroup permissions for a specic group or series of groups combined
*

/**
* Fetch the usergroup permissions for a specic group or series of groups combined
*

Zeile 691Zeile 749
	{
$groupscache = $cache->read("usergroups");
}

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

 


	$groups = explode(",", $gid);
if(count($groups) == 1)
{
return $groupscache[$gid];

	$groups = explode(",", $gid);
if(count($groups) == 1)
{
return $groupscache[$gid];

	}
foreach($groups as $gid)
{

	}
foreach($groups as $gid)
{

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

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

Zeile 714Zeile 773
				{
$permbit = "";
}

				{
$permbit = "";
}

				$zerogreater = 0;



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

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

						$zerogreater = 1;

						continue;

					}
}

					}
}

				if(($access > $permbit || ($access == "yes" && $permbit == "no") || !$permbit) && $zerogreater != 1)



if($access > $permbit || ($access == "yes" && $permbit == "no") || !$permbit)

				{
$usergroup[$perm] = $access;
}

				{
$usergroup[$perm] = $access;
}

Zeile 731Zeile 791
		}
}
return $usergroup;

		}
}
return $usergroup;

}

/**

}

/**

 * Fetch the display group properties for a specific display group
*
* @param int The group ID to fetch the display properties for

 * Fetch the display group properties for a specific display group
*
* @param int The group ID to fetch the display properties for

Zeile 767Zeile 827
function forum_permissions($fid=0, $uid=0, $gid=0)
{
global $db, $cache, $groupscache, $forum_cache, $fpermcache, $mybb, $usercache, $fpermissionscache;

function forum_permissions($fid=0, $uid=0, $gid=0)
{
global $db, $cache, $groupscache, $forum_cache, $fpermcache, $mybb, $usercache, $fpermissionscache;



	static $cached_forum_permissions;

	if($uid == 0)
{
$uid = $mybb->user['uid'];
}
if(!$gid || $gid == 0) // If no group, we need to fetch it

	if($uid == 0)
{
$uid = $mybb->user['uid'];
}
if(!$gid || $gid == 0) // If no group, we need to fetch it

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

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

		{
if($usercache[$uid])

		{
if($usercache[$uid])

			{

			{

				$query = $db->query("SELECT * FROM ".TABLE_PREFIX."users WHERE uid='$uid'");
$usercache[$uid] = $db->fetch_array($query);

				$query = $db->query("SELECT * FROM ".TABLE_PREFIX."users WHERE uid='$uid'");
$usercache[$uid] = $db->fetch_array($query);

			}

			}

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

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

		}

		}

		else
{
$gid = $mybb->user['usergroup'];

		else
{
$gid = $mybb->user['usergroup'];

Zeile 792Zeile 852
				$gid .= ",".$mybb->user['additionalgroups'];
}
$groupperms = $mybb->usergroup;

				$gid .= ",".$mybb->user['additionalgroups'];
}
$groupperms = $mybb->usergroup;

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

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

	}
if(!is_array($fpermcache))
{
$fpermcache = $cache->read("forumpermissions");

	}
if(!is_array($fpermcache))
{
$fpermcache = $cache->read("forumpermissions");

	}

	}

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

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

		$permissions = fetch_forum_permissions($fid, $gid, $groupperms);





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

	}
else
{

	}
else
{

		foreach($forum_cache as $forum)

		if(!$cached_forum_permissions[$gid])

		{

		{

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




			foreach($forum_cache as $forum)
{
$cached_forum_permissions[$gid][$forum['fid']] = fetch_forum_permissions($forum['fid'], $gid, $groupperms);
}

		}

		}

 
		return $cached_forum_permissions[$gid];

	}

	}

	return $permissions;

 
}

/**

}

/**

Zeile 834Zeile 901
	global $groupscache, $forum_cache, $fpermcache, $mybb, $fpermfields;

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

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

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



	

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

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

 
		$groupperms['fid'] = $fid;
$groupperms['gid'] = $gid;

		return $groupperms;

		return $groupperms;

	}

	}

	
$current_permissions = array();

foreach($groups as $gid)
{
if($groupscache[$gid])

	
$current_permissions = array();

foreach($groups as $gid)
{
if($groupscache[$gid])

		{
// If this forum has permissions set
if($fpermcache[$fid][$gid])
{
$level_permissions = $fpermcache[$fid][$gid];
foreach($level_permissions as $permission => $access)
{
if($access >= $current_permissions[$permission] || ($access == "yes" && $current_permissions[$permission] == "no") || !$current_permissions[$permission])
{
$current_permissions[$permission] = $access;








		{
$level_permissions = $fpermcache[$fid][$gid];

// If our permissions arn't inherited we need to figure them out
if(empty($level_permissions))
{
$parents = explode(',', $forum_cache[$fid]['parentlist']);
rsort($parents);
if(!empty($parents))
{
foreach($parents as $parent_id)
{
if(!empty($fpermcache[$parent_id][$gid]))
{
$level_permissions = $fpermcache[$parent_id][$gid];
break;
}

					}

					}

 
					
// If we STILL don't have forum permissions we use the usergroup itself
if(empty($level_permissions))
{
$level_permissions = $groupscache[$gid];
}
}
}

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

				}

				}

			}
}
}

			}
}
}

	
if(count($current_permissions) == 0)

	
if(count($current_permissions) == 0)

	{
$current_permissions = $groupperms;

	{
$current_permissions = $groupperms;

	}
return $current_permissions;
}

	}
return $current_permissions;
}





/**
* Check the password given on a certain forum for validity
*
* @param int The forum ID

/**
* Check the password given on a certain forum for validity
*
* @param int The forum ID

 * @param string The plain text password for the forum

 * @param boolean The Parent ID

 */

 */

function check_forum_password($fid, $password="")

function check_forum_password($fid, $pid=0)

{

{

	global $mybb, $header, $footer, $headerinclude, $theme, $templates, $lang;
$showform = 1;











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

$showform = true;

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





 
	// Loop through each of parent forums to ensure we have a password for them too
$parents = explode(',', $forum_cache[$fid]['parentlist']);
rsort($parents);
if(!empty($parents))
{
foreach($parents as $parent_id)
{
if($parent_id == $fid || $parent_id == $pid)
{
continue;
}

if($forum_cache[$parent_id]['password'] != "")
{
check_forum_password($parent_id, $fid);
}
}
}

$password = $forum_cache[$fid]['password'];

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

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

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

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

				$showform = 0;

				$showform = false;

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

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

				$showform = 1;

				$showform = true;

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

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

				$showform = 1;

				$showform = true;

			}
else
{

			}
else
{

				$showform = 0;

				$showform = false;

			}
}
}
else
{

			}
}
}
else
{

		$showform = 0;

		$showform = false;

	}

	}

 


	if($showform)
{
$_SERVER['REQUEST_URI'] = htmlspecialchars_uni($_SERVER['REQUEST_URI']);

	if($showform)
{
$_SERVER['REQUEST_URI'] = htmlspecialchars_uni($_SERVER['REQUEST_URI']);

Zeile 952Zeile 1073
	else
{
$perms = $modpermscache[$fid][$uid];

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

	}

	}

	
return $perms;
}

	
return $perms;
}

Zeile 1178Zeile 1299
function get_server_load()
{
global $lang;

function get_server_load()
{
global $lang;

	if(strtolower(substr(PHP_OS, 0, 3)) === 'win')





$serverload = array();

if(my_strtolower(substr(PHP_OS, 0, 3)) !== 'win')

	{

	{

		return $lang->unknown;
}
elseif(@file_exists("/proc/loadavg") && $load = @file_get_contents("/proc/loadavg"))
{
$serverload = explode(" ", $load);
$serverload[0] = round($serverload[0], 4);

		if(@file_exists("/proc/loadavg") && $load = @file_get_contents("/proc/loadavg"))
{
$serverload = explode(" ", $load);
$serverload[0] = round($serverload[0], 4);
}


		if(!$serverload)
{

		if(!$serverload)
{

 
			if(@ini_get('safe_mode') == 'On')
{
return $lang->unknown;
}

// Suhosin likes to throw a warning if exec is disabled then die - weird
if($func_blacklist = @ini_get('suhosin.executor.func.blacklist'))
{
if(strpos(",".$func_blacklist.",", 'exec') !== false)
{
return $lang->unknown;
}
}
// PHP disabled functions?
if($func_blacklist = @ini_get('disable_functions'))
{
if(strpos(",".$func_blacklist.",", 'exec') !== false)
{
return $lang->unknown;
}
}

			$load = @exec("uptime");
$load = split("load averages?: ", $load);
$serverload = explode(",", $load[1]);

			$load = @exec("uptime");
$load = split("load averages?: ", $load);
$serverload = explode(",", $load[1]);

 
			if(!is_array($serverload))
{
return $lang->unknown;
}

		}

		}

	}

	}

	else
{

	else
{

		$load = @exec("uptime");
$load = split("load averages?: ", $load);
$serverload = explode(",", $load[1]);

		return $lang->unknown;



	}

	}

 


	$returnload = trim($serverload[0]);

	$returnload = trim($serverload[0]);

	if(!$returnload)
{
$returnload = $lang->unknown;
}






	return $returnload;
}

	return $returnload;
}

 



/**
* Updates the forum statistics with specific values (or addition/subtraction of the previous value)
*


/**
* Updates the forum statistics with specific values (or addition/subtraction of the previous value)
*

 * @param array Array of items being updated (numthreads,numposts,numusers)

 * @param array Array of items being updated (numthreads,numposts,numusers,lastuser)

 */
function update_stats($changes=array())
{

 */
function update_stats($changes=array())
{

Zeile 1218Zeile 1363

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



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


	$counters = array('numthreads','numposts','numusers');

	$counters = array('numthreads', 'numposts', 'numusers');

	$update = array();
foreach($counters as $counter)
{

	$update = array();
foreach($counters as $counter)
{

Zeile 1242Zeile 1387
	}

// Fetch latest user if the user count is changing

	}

// Fetch latest user if the user count is changing

	if(array_key_exists('numusers', $changes))

	if(array_key_exists('numusers', $changes) || array_key_exists('lastuser', $changes))

	{
$query = $db->simple_select(TABLE_PREFIX."users", "uid, username", "", array('order_by' => 'uid', 'order_dir' => 'DESC', 'limit' => 1));
$lastmember = $db->fetch_array($query);

	{
$query = $db->simple_select(TABLE_PREFIX."users", "uid, username", "", array('order_by' => 'uid', 'order_dir' => 'DESC', 'limit' => 1));
$lastmember = $db->fetch_array($query);

Zeile 1286Zeile 1431
			if(substr($changes[$counter], 0, 1) == "+" || substr($changes[$counter], 0, 1) == "-")
{
$update_query[$counter] = $forum[$counter] + $changes[$counter];

			if(substr($changes[$counter], 0, 1) == "+" || substr($changes[$counter], 0, 1) == "-")
{
$update_query[$counter] = $forum[$counter] + $changes[$counter];

			}
else
{

			}
else
{

				$update_query[$counter] = $changes[$counter];
}
// Less than 0? That's bad

				$update_query[$counter] = $changes[$counter];
}
// Less than 0? That's bad

Zeile 1306Zeile 1451
	}

// Guess we should update the statistics too?

	}

// Guess we should update the statistics too?

	if($update_query['threads'] || $update_query['posts'])

	if(isset($update_query['threads']) || isset($update_query['posts']))

	{
$new_stats = array();
if(array_key_exists('threads', $update_query))

	{
$new_stats = array();
if(array_key_exists('threads', $update_query))

Zeile 1332Zeile 1477
			{
$new_stats['numposts'] = "{$posts_diff}";
}

			{
$new_stats['numposts'] = "{$posts_diff}";
}

		}


		}	


		update_stats($new_stats);
}

		update_stats($new_stats);
}



	

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

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

Zeile 1535Zeile 1681
 */
function build_forum_jump($pid="0", $selitem="", $addselect="1", $depth="", $showextras="1", $permissions="", $name="fid")
{

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

	global $db, $forum_cache, $fjumpcache, $permissioncache, $mybb, $selecteddone, $forumjump, $forumjumpbits, $gobutton, $theme, $templates, $lang;

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


$pid = intval($pid);
if($permissions)


$pid = intval($pid);
if($permissions)

Zeile 1575Zeile 1721
						$optionselected = "selected=\"selected\"";
$selecteddone = 1;
}

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

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


					eval("\$forumjumpbits .= \"".$templates->get("forumjump_bit")."\";");
if($forum_cache[$forum['fid']])
{

					eval("\$forumjumpbits .= \"".$templates->get("forumjump_bit")."\";");
if($forum_cache[$forum['fid']])
{

Zeile 1707Zeile 1856
			"editor_size_x_small",
"editor_size_small",
"editor_size_medium",

			"editor_size_x_small",
"editor_size_small",
"editor_size_medium",

 
			"editor_size_large",

			"editor_size_x_large",
"editor_size_xx_large",
"editor_color_white",

			"editor_size_x_large",
"editor_size_xx_large",
"editor_color_white",

Zeile 2044Zeile 2194
	{
$attachtypes = $cache->read("attachtypes");
}

	{
$attachtypes = $cache->read("attachtypes");
}

 
	
$directory = "";

if(defined("IN_PORTAL"))
{
global $change_dir;
$directory = $change_dir."/";
}


	$ext = strtolower($ext);
if($attachtypes[$ext]['icon'])
{

	$ext = strtolower($ext);
if($attachtypes[$ext]['icon'])
{

		return "<img src=\"".$attachtypes[$ext]['icon']."\" border=\"0\" alt=\".$ext File\" />";

		return "<img src=\"{$directory}".$attachtypes[$ext]['icon']."\" border=\"0\" alt=\".$ext File\" />";

	}
else
{

	}
else
{

		return "<img src=\"images/attachtypes/unknown.gif\" border=\"0\" alt=\".$ext File\" />";

		return "<img src=\"{$directory}images/attachtypes/unknown.gif\" border=\"0\" alt=\".$ext File\" />";

	}
}


	}
}


Zeile 2300Zeile 2459
		$gzipen = "Disabled";
}
echo "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n";

		$gzipen = "Disabled";
}
echo "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n";

	echo "<html lang=\"en\">";

	echo "<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\" lang=\"en\">";

	echo "<head>";
echo "<title>MyBB Debug Information</title>";
echo "</head>";

	echo "<head>";
echo "<title>MyBB Debug Information</title>";
echo "</head>";

Zeile 2812Zeile 2971
		}
}


		}
}


	if($tid)

	if($tid == 0)

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

return $themeselect;

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

return $themeselect;

}

}


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


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

Zeile 2864Zeile 3023
			$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 2879Zeile 3038

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


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

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








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

	}
return $message;
}

	}
return $message;
}

Zeile 2967Zeile 3133

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



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


	if(($month == $bday[1] && $day < $bday[1]) || $month < $bday[1])

	if(($month == $bday[1] && $day < $bday[0]) || $month < $bday[1])

	{
--$age;
}

	{
--$age;
}

Zeile 3082Zeile 3248
	if(function_exists("mb_strtolower"))
{
$string = mb_strtolower($string);

	if(function_exists("mb_strtolower"))
{
$string = mb_strtolower($string);

	}
else

	}
else

	{
$string = strtolower($string);

	{
$string = strtolower($string);

	}

return $string;
}


	}

return $string;
}


/**
* Finds a needle in a haystack and returns it position, mb strings accounted for
*

/**
* Finds a needle in a haystack and returns it position, mb strings accounted for
*

Zeile 3109Zeile 3275
	if(function_exists("mb_strpos"))
{
$position = mb_strpos($haystack, $needle, $offset);

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

	}
else

	}
else

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

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

Zeile 3136Zeile 3302
	}

return $string;

	}

return $string;

}

}


/**
* Returns any html entities to their original character
*
* @param string The string to un-htmlentitize.
* @return int The un-htmlentitied' string.


/**
* Returns any html entities to their original character
*
* @param string The string to un-htmlentitize.
* @return int The un-htmlentitied' string.

 */

 */

function unhtmlentities($string)
{
// Replace numeric entities

function unhtmlentities($string)
{
// Replace numeric entities

Zeile 3155Zeile 3321
   $trans_tbl = array_flip($trans_tbl);

return strtr($string, $trans_tbl);

   $trans_tbl = array_flip($trans_tbl);

return strtr($string, $trans_tbl);

}

/**

}

/**

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

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

Zeile 3190Zeile 3356
	$event_date = my_date($mybb->settings['dateformat'], $event_date);

return $event_date;

	$event_date = my_date($mybb->settings['dateformat'], $event_date);

return $event_date;

}

}


/**
* Get the profile link.


/**
* Get the profile link.

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

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

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

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

}

/**

}

/**

 * Build the profile link.
*
* @param string The Username of the profile.
* @param int The user id of the profile.
* @param string The target frame

 * Build the profile link.
*
* @param string The Username of the profile.
* @param int The user id of the profile.
* @param string The target frame

 
 * @param string Any onclick javascript.

 * @return string The url to the profile.
*/

 * @return string The url to the profile.
*/

function build_profile_link($username="", $uid=0, $target="")

function build_profile_link($username="", $uid=0, $target="", $onclick="")

{
global $lang;


{
global $lang;


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

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

	}

	}

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

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

Zeile 3233Zeile 3400
		{
$target = " target=\"{$target}\"";
}

		{
$target = " target=\"{$target}\"";
}

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





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

	}
}


	}
}


Zeile 3245Zeile 3416
 * @return string The url to the forum.
*/
function get_forum_link($fid, $page=0)

 * @return string The url to the forum.
*/
function get_forum_link($fid, $page=0)

{

{

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

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

Zeile 3278Zeile 3449
}

/**

}

/**

 * Get the username of a user id.

 * Get the user data of a user id.

 *
* @param int The user id of the user.

 *
* @param int The user id of the user.

 * @return string The username of the user.

 * @return array The user data.

 */
function get_user($uid)
{

 */
function get_user($uid)
{

Zeile 3359Zeile 3530
	if(isset($thread_cache[$tid]))
{
return $thread_cache[$tid];

	if(isset($thread_cache[$tid]))
{
return $thread_cache[$tid];

	}
else
{

	}
else
{

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


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


Zeile 3369Zeile 3540
		{
$thread_cache[$tid] = $thread;
return $thread;

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

		}

		}

		else
{
$thread_cache[$tid] = false;

		else
{
$thread_cache[$tid] = false;

			return false;
}
}
}

			return false;
}
}
}


/**
* Get the post of a post id.
*
* @param int The post id of the post.
* @return string The database row of the post.


/**
* Get the post of a post id.
*
* @param int The post id of the post.
* @return string The database row of the post.

 */

 */

function get_post($pid)
{
global $db;
static $post_cache;

if(isset($post_cache[$pid]))

function get_post($pid)
{
global $db;
static $post_cache;

if(isset($post_cache[$pid]))

	{

	{

		return $post_cache[$pid];
}
else
{
$query = $db->simple_select(TABLE_PREFIX."posts", "*", "pid='".intval($pid)."'");
$post = $db->fetch_array($query);

		return $post_cache[$pid];
}
else
{
$query = $db->simple_select(TABLE_PREFIX."posts", "*", "pid='".intval($pid)."'");
$post = $db->fetch_array($query);





		if($post)
{
$post_cache[$pid] = $post;

		if($post)
{
$post_cache[$pid] = $post;

Zeile 3417Zeile 3588
 * @return string The comma seperated values of the inactivate forum.
*/
function get_inactive_forums()

 * @return string The comma seperated values of the inactivate forum.
*/
function get_inactive_forums()

{
global $forum_cache, $db, $cache, $inactiveforums;

{
global $forum_cache, $db, $cache, $inactiveforums;


if(!$forum_cache)
{


if(!$forum_cache)
{

Zeile 3518Zeile 3689
*/
function validate_email_format($email)
{

*/
function validate_email_format($email)
{

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

	if(strpos($email, ' ') !== false)

	{
return false;
}

	{
return false;
}

	else
{
return true;
}

	// Valid local characters for email addresses: http://www.remote.org/jochen/mail/info/chars.html
return preg_match("/^[a-zA-Z0-9&*+\-_.{}~^\?=\/]+@[a-zA-Z0-9-]+\.[a-zA-Z0-9.-]+$/si", $email);



}

/**

}

/**

Zeile 3645Zeile 3814
 * @return array The array of banned email addresses.
*/
function get_banned_emails()

 * @return array The array of banned email addresses.
*/
function get_banned_emails()

{
global $mybb;

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

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

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

	$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 true;

		}
}
return false;

		}
}
return false;

Zeile 3688Zeile 3857

/**
* Checks if a specific IP address has been banned.


/**
* Checks if a specific IP address has been banned.

 *

 *

 * @param string The IP address.
* @return boolean True if banned, false if not banned.
*/

 * @param string The IP address.
* @return boolean True if banned, false if not banned.
*/

Zeile 3703Zeile 3872
		}
}
return false;

		}
}
return false;

 
}

/**
* Fetch the contents of a remote fle.
*
* @param string The URL of the remote file
* @return string The remote file contents.
*/
function fetch_remote_file($url)
{
if(function_exists("curl_init"))
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$data = curl_exec($ch);
curl_close($ch);
return $data;
}
else if(function_exists("fsockopen"))
{
$url = parse_url($url);
if(!$url['host'])
{
return false;
}
if(!$url['port'])
{
$url['port'] = 80;
}
if(!$url['path'])
{
$url['path'] = "/";
}
if($url['query'])
{
$url['path'] .= "?{$url['path']}";
}
$fp = @fsockopen($url['host'], $url['port'], $error_no, $error, 10);
@stream_set_timeout($fp, 10);
if(!$fp)
{
return false;
}
$headers = "GET {$url['path']} HTTP/1.1\r\n";
$headers .= "Host: {$url['host']}\r\n";
$headers .= "Connection: Close\r\n\r\n";
if(!@fwrite($fp, $headers))
{
return false;
}
while(!feof($fp))
{
$data .= fgets($fp, 12800);
}
fclose($fp);
$data = explode("\r\n\r\n", $data, 2);
return $data[1];
}
else
{
return @implode("", @file($url));
}
}

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

}

/**

}

/**