Vergleich inc/functions.php - 1.2.3 - 1.2.9

  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 2794 2007-02-14 02:37:17Z chris $

 * $Id: functions.php 3177 2007-06-29 07:51:12Z chris $

 */

/**

 */

/**

Zeile 74Zeile 74
			$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");

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

	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) 

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

	{
run_shutdown();
}

	{
run_shutdown();
}

Zeile 95Zeile 98
	global $shutdown_functions;

if(function_exists($name))

	global $shutdown_functions;

if(function_exists($name))

	{

	{

		$shutdown_functions[$name] = $name;
}
}

		$shutdown_functions[$name] = $name;
}
}

Zeile 128Zeile 131
	
// Cache object deconstructed? reconstruct
if(!is_object($cache))

	
// Cache object deconstructed? reconstruct
if(!is_object($cache))

	{

	{

		require_once MYBB_ROOT."inc/class_datacache.php";
$cache = new datacache;
}

		require_once MYBB_ROOT."inc/class_datacache.php";
$cache = new datacache;
}

Zeile 233Zeile 236
		if(my_substr($_SERVER['PHP_SELF'], -strlen("private.php")) != "private.php")
{
$contents = str_replace("<body", "<body onload=\"Javascript:MyBB.newPM()\"", $contents);

		if(my_substr($_SERVER['PHP_SELF'], -strlen("private.php")) != "private.php")
{
$contents = str_replace("<body", "<body onload=\"Javascript:MyBB.newPM()\"", $contents);

		}
}

		}
}

	return $contents;
}


	return $contents;
}


Zeile 268Zeile 271
		{
$offset = $mybbadmin['timezone'];
$dstcorrection = $mybbadmin['dst'];

		{
$offset = $mybbadmin['timezone'];
$dstcorrection = $mybbadmin['dst'];

		}

		}

		else
{
$offset = $mybb->settings['timezoneoffset'];

		else
{
$offset = $mybb->settings['timezoneoffset'];

Zeile 287Zeile 290
	if($offset == "-")
{
$offset = 0;

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

	}

	}

	$date = gmdate($format, $stamp + ($offset * 3600));
if($mybb->settings['dateformat'] == $format && $ty)
{

	$date = gmdate($format, $stamp + ($offset * 3600));
if($mybb->settings['dateformat'] == $format && $ty)
{

Zeile 308Zeile 311

return $date;
}


return $date;
}





/**
* Sends an email using PHP's mail function, formatting it appropriately.
*

/**
* Sends an email using PHP's mail function, formatting it appropriately.
*

Zeile 321Zeile 324
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 335Zeile 338
	$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'])

	{

	{

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

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

	}

	}

	else
{
$http_host = "unknown.local";

	else
{
$http_host = "unknown.local";

Zeile 353Zeile 356
	$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');
if($sendmail)
{
$headers = preg_replace("#(\r\n|\r|\n)#s", "\n", $headers);
$message = preg_replace("#(\r\n|\r|\n)#s", "\n", $message);

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

	}

	}

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

	else
{
$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);
}


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

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

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

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

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

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

	}
}

	}
}


/**
* Build a parent list of a specific forum, suitable for querying


/**
* Build a parent list of a specific forum, suitable for querying

Zeile 500Zeile 504
	}
eval("\$errors = \"".$templates->get("error_inline")."\";");
return $errors;

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

}

}


/**
* Presents the user with a "no permission" page


/**
* Presents the user with a "no permission" page

Zeile 659Zeile 663
		if(!$user_cache[$uid])
{
$user_cache[$uid] = get_user($uid);

		if(!$user_cache[$uid])
{
$user_cache[$uid] = get_user($uid);

		}


		}


		// 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.
$user_cache[$uid]['permissions'] = $groupperms;
return $groupperms;

		$groupperms = usergroup_permissions($gid);

// Store group permissions in user cache.
$user_cache[$uid]['permissions'] = $groupperms;
return $groupperms;

	}

	}

	// This user is the current user, return their permissions
else
{
return $mybb->usergroup;
}
}

	// This user is the current user, return their permissions
else
{
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 690Zeile 698
	{
$groupscache = $cache->read("usergroups");
}

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

 


	$groups = explode(",", $gid);
if(count($groups) == 1)
{

	$groups = explode(",", $gid);
if(count($groups) == 1)
{

Zeile 719Zeile 728
					if($access == 0)
{
$usergroup[$perm] = 0;

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

						$zerogreater = 1;

 
					}

					}

 
					$zerogreater = 1;

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

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

Zeile 766Zeile 775
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($uid == 0)
{
$uid = $mybb->user['uid'];

Zeile 807Zeile 816
	}
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 879Zeile 895
	$showform = 1;

if($password)

	$showform = 1;

if($password)

	{

	{

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

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

				$showform = 0;
}

				$showform = 0;
}

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

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

Zeile 906Zeile 922
		}
}
else

		}
}
else

	{

	{

		$showform = 0;
}
if($showform)

		$showform = 0;
}
if($showform)

Zeile 932Zeile 948
	static $modpermscache;

if($uid < 1)

	static $modpermscache;

if($uid < 1)

	{

	{

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

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

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


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

	{
if(!$parentslist)

	{
if(!$parentslist)

		{

		{

			$parentslist = get_parent_list($fid);
}

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





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

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

Zeile 969Zeile 983
function is_moderator($fid="0", $action="", $uid="0")
{
global $mybb, $db;

function is_moderator($fid="0", $action="", $uid="0")
{
global $mybb, $db;





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


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


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


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

	{
return "yes";
}

	{
return "yes";
}

Zeile 983Zeile 998
	{
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";
}
else
{
return "no";

			{
return "yes";
}
else
{
return "no";

			}
}
else

			}
}
else

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

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

Zeile 1100Zeile 1115
	// 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)

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

		$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['cookiepath']))
{
$cookie .= "; path={$mybb->settings['cookiepath']}";

	}

	}

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

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

	{

	{

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

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

	{

	{

		$cookie .= "; HttpOnly";
}
header($cookie, false);

		$cookie .= "; HttpOnly";
}
header($cookie, false);

Zeile 1151Zeile 1166
	else
{
return 0;

	else
{
return 0;

	}
}


	}
}


/**
* Set a serialised cookie array.
*
* @param string The cookie identifier.
* @param int The cookie content id.
* @param string The value to set the cookie to.

/**
* Set a serialised cookie array.
*
* @param string The cookie identifier.
* @param int The cookie content id.
* @param string The value to set the cookie to.

 */

 */

function my_set_array_cookie($name, $id, $value)
{
$cookie = $_COOKIE['mybb'];

function my_set_array_cookie($name, $id, $value)
{
$cookie = $_COOKIE['mybb'];

Zeile 1174Zeile 1189
 * Returns the serverload of the system.
*
* @return int The serverload of the system.

 * Returns the serverload of the system.
*
* @return int The serverload of the system.

 */

 */

function get_server_load()
{
global $lang;

function get_server_load()
{
global $lang;

	if(strtolower(substr(PHP_OS, 0, 3)) === 'win')
{
return $lang->unknown;
}
elseif(@file_exists("/proc/loadavg"))


$serverload = array();

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


	{

	{

		$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)
{
$load = @exec("uptime");
$load = split("load averages?: ", $load);
$serverload = explode(",", $load[1]);

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

		}
}






























































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

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

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

	else

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














































	{
$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)."'");

	}

	}

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



// Guess we should update the statistics too?
if($update_query['threads'] || $update_query['posts'])

	{

	{

		$returnload = $lang->unknown;


























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

	}

	}

	return $returnload;




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


// Fetch the last post for this forum

	$query = $db->query("

	$query = $db->query("

		SELECT tid, lastpost, lastposter, lastposteruid, subject
FROM ".TABLE_PREFIX."threads
WHERE fid='{$fid}' AND visible='1' AND closed NOT LIKE 'moved|%'

		SELECT tid, lastpost, lastposter, lastposteruid, subject
FROM ".TABLE_PREFIX."threads
WHERE fid='{$fid}' AND visible='1' AND closed NOT LIKE 'moved|%'

Zeile 1227Zeile 1377
	");
$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}'");


















































$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)
{
$db->update_query(TABLE_PREFIX."threads", $update_query, "tid='".intval($tid)."'");
}

update_thread_data($tid);

}

/**

}

/**

 * Update the thread counters for a specific thread

 * Update the first post and lastpost data for a specific thread

 *
* @param int The thread ID
*/

 *
* @param int The thread ID
*/

function update_thread_count($tid)

function update_thread_data($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)
{
$treplies = 0;
}

	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 1296Zeile 1456

$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'])
{
$lastpost['username'] = $lastpost['postusername'];
}

	if(!$lastpost['username'])
{
$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='".intval($lastpost['dateline'])."', lastposter='".$lastpost['username']."', lastposteruid='".intval($lastpost['uid'])."', replies='$treplies', unapprovedposts='$nounposts'
WHERE tid='$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");


}

}


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

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








}

/**

}

/**

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

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

{
global $moderation;

{
global $moderation;

	if(!is_object($moderation))
{
require_once MYBB_ROOT."inc/class_moderation.php";
$moderation = new Moderation;
}
return $moderation->delete_thread($tid);

	if(!is_object($moderation))
{
require_once MYBB_ROOT."inc/class_moderation.php";
$moderation = new Moderation;
}
return $moderation->delete_thread($tid);

}

}


/**
* Deletes a post from the database


/**
* Deletes a post from the database

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

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

		{

		{

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

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

Zeile 1576Zeile 1725
			"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 1860Zeile 2010
			$ip = $_SERVER['REMOTE_ADDR'];
}
}

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

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


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


return $ip;
}


return $ip;
}

Zeile 2012Zeile 2162
			{
if(isset($navbits[$key+2])) { $sep = $navsep; } else { $sep = ""; }
eval("\$nav .= \"".$templates->get("nav_bit")."\";");

			{
if(isset($navbits[$key+2])) { $sep = $navsep; } else { $sep = ""; }
eval("\$nav .= \"".$templates->get("nav_bit")."\";");

			}
}

			}
}

	}
$navsize = count($navbits);
$navbit = $navbits[$navsize-1];

	}
$navsize = count($navbits);
$navbit = $navbits[$navsize-1];

Zeile 2115Zeile 2265
 * @param string The type of page (thread|announcement|forum)
* @param int The ID of the item
* @return string The URL

 * @param string The type of page (thread|announcement|forum)
* @param int The ID of the item
* @return string The URL

 */

 */

function build_archive_link($type, $id="")
{
global $mybb;

function build_archive_link($type, $id="")
{
global $mybb;

Zeile 2243Zeile 2393
	{
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 2269Zeile 2419
		header("Last-Modified: " . gmdate("D, d M Y H:i:s") . "GMT");
header("Cache-Control: no-cache, must-revalidate");
header("Pragma: no-cache");

		header("Last-Modified: " . gmdate("D, d M Y H:i:s") . "GMT");
header("Cache-Control: no-cache, must-revalidate");
header("Pragma: no-cache");

	}
}


	}
}


/**
* Mark specific reported posts of a certain type as dealt with
*

/**
* Mark specific reported posts of a certain type as dealt with
*

Zeile 2290Zeile 2440
				$rids = implode($id, "','");
$rids = "'0','$rids'";
$db->update_query(TABLE_PREFIX."reportedposts", array('reportstatus' => 1), "pid IN($rids) AND reportstatus='0'");

				$rids = implode($id, "','");
$rids = "'0','$rids'";
$db->update_query(TABLE_PREFIX."reportedposts", array('reportstatus' => 1), "pid IN($rids) AND reportstatus='0'");

			}
break;

			}
break;

		case "post":
$db->update_query(TABLE_PREFIX."reportedposts", array('reportstatus' => 1), "pid='$id' AND reportstatus='0'");
break;

		case "post":
$db->update_query(TABLE_PREFIX."reportedposts", array('reportstatus' => 1), "pid='$id' AND reportstatus='0'");
break;

Zeile 2322Zeile 2472
 *
* @param int The timestamp
* @return string The friendly formatted timestamp

 *
* @param int The timestamp
* @return string The friendly formatted timestamp

 */

 */

function nice_time($stamp)
{
global $lang;

function nice_time($stamp)
{
global $lang;

Zeile 2367Zeile 2517
	}

if($weeks == 1)

	}

if($weeks == 1)

	{

	{

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

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

	}

	}


if($days == 1)
{


if($days == 1)
{

Zeile 2404Zeile 2554

if($seconds == 1)
{


if($seconds == 1)
{

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

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

	}
elseif($seconds > 1)
{

	}
elseif($seconds > 1)
{

Zeile 2470Zeile 2620
		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("
UPDATE ".TABLE_PREFIX."users
SET additionalgroups='$groupslist'

	$db->query("
UPDATE ".TABLE_PREFIX."users
SET additionalgroups='$groupslist'

Zeile 2578Zeile 2728
		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 2590Zeile 2740
			{
$addloc[] = $var.'='.$_POST[$var];
}

			{
$addloc[] = $var.'='.$_POST[$var];
}

		}

		}

		if(isset($addlock) && is_array($addloc))
{
$location .= "?".implode("&", $addloc);

		if(isset($addlock) && is_array($addloc))
{
$location .= "?".implode("&", $addloc);

Zeile 2628Zeile 2778
		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]))
{

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

Zeile 2668Zeile 2818
				}

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

				}

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

				{

				{

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

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

Zeile 2681Zeile 2831
		}
}


		}
}


	if(!$tid)

	if($tid == 0)

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

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

Zeile 2697Zeile 2847
 */
function htmlspecialchars_uni($message)
{

 */
function htmlspecialchars_uni($message)
{

	$message = preg_replace("#&(?!\#[0-9]+;)#si", "&amp;", $message); // Fix & but allow unicode

	$message = preg_replace("#&([^\#])(?![a-z1-4]{1,10};)#i", "&#038;$1", $message); // Fix & but allow unicode

	$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 2827Zeile 2976
 */
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;

}

/**
* Updates the first posts in a thread.

}

/**
* Updates the first posts in a thread.

 *

 *

 * @param int The thread id for which to update the first post id.
*/
function update_first_post($tid)

 * @param int The thread id for which to update the first post id.
*/
function update_first_post($tid)

Zeile 2877Zeile 3028
function my_strlen($string)
{
global $lang;

function my_strlen($string)
{
global $lang;





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

if(strtolower($lang->settings['charset']) == "utf-8")

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

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

Zeile 2890Zeile 3041
        $string = str_replace(chr(0xCA), "", $string);
}
$string = trim($string);

        $string = str_replace(chr(0xCA), "", $string);
}
$string = trim($string);





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

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

Zeile 2914Zeile 3065
function my_substr($string, $start, $length="")
{
if(function_exists("mb_substr"))

function my_substr($string, $start, $length="")
{
if(function_exists("mb_substr"))

	{
if($length != "")

	{
if($length != "")

		{
$cut_string = mb_substr($string, $start, $length);

		{
$cut_string = mb_substr($string, $start, $length);

		}

		}

		else
{
$cut_string = mb_substr($string, $start);

		else
{
$cut_string = mb_substr($string, $start);

		}

		}

	}
else
{
if($length != "")

	}
else
{
if($length != "")

		{

		{

			$cut_string = substr($string, $start, $length);
}
else

			$cut_string = substr($string, $start, $length);
}
else

Zeile 2950Zeile 3101
	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);
}


Zeile 3027Zeile 3178

/**
* Get the event poster.


/**
* Get the event poster.

 *
* @param array The event data array.

 *
* @param array The event data array.

 * @return string The link to the event poster.
*/
function get_event_poster($event)

 * @return string The link to the event poster.
*/
function get_event_poster($event)

Zeile 3043Zeile 3194
	}

return $event_poster;

	}

return $event_poster;

}


}


/**
* Get the event date.
*

/**
* Get the event date.
*

Zeile 3062Zeile 3213

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

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

Zeile 3078Zeile 3229
 * @param string The Username of the profile.
* @param int The user id of the profile.
* @param string The target frame

 * @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;

if(!$username && $uid == 0)

{
global $lang;

if(!$username && $uid == 0)

	{

	{

		// Return Guest phrase for no UID, no guest nickname
return $lang->guest;
}
elseif($uid == 0)

		// Return Guest phrase for no UID, no guest nickname
return $lang->guest;
}
elseif($uid == 0)

	{

	{

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

Zeile 3101Zeile 3253
		{
$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>";
}
}

/**

 * Build the forum link.
*
* @param int The forum id of the forum.

 * Build the forum link.
*
* @param int The forum id of the forum.

Zeile 3113Zeile 3269
 * @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)
{

{
if($page > 0)
{

		$forum_link = str_replace("{fid}", $fid, FORUM_URL_PAGED);
return str_replace("{page}", $page, $forum_link);

		$forum_link = str_replace("{fid}", $fid, FORUM_URL_PAGED);
return str_replace("{page}", $page, $forum_link);

	}
else

	}
else

	{
return str_replace("{fid}", $fid, FORUM_URL);
}

	{
return str_replace("{fid}", $fid, FORUM_URL);
}

Zeile 3142Zeile 3298
	else
{
return str_replace("{tid}", $tid, THREAD_URL);

	else
{
return str_replace("{tid}", $tid, THREAD_URL);

	}

	}

}

/**

}

/**

Zeile 3350Zeile 3506
		if(empty($failedlogin))
{
my_setcookie('failedlogin', $now);

		if(empty($failedlogin))
{
my_setcookie('failedlogin', $now);

			if($fatal)
{
error(sprintf($lang->failed_login_wait, $hoursleft, $minsleft, $secsleft));
}
return false;
}

			if($fatal)
{
error(sprintf($lang->failed_login_wait, $hoursleft, $minsleft, $secsleft));
}
return false;
}

		// Work out if the user has waited long enough before letting them login again
if($_COOKIE['failedlogin'] < $now - $mybb->settings['failedlogintime'] * 60)
{

		// Work out if the user has waited long enough before letting them login again
if($_COOKIE['failedlogin'] < $now - $mybb->settings['failedlogintime'] * 60)
{

Zeile 3386Zeile 3542
*/
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 3407Zeile 3561
	if(!file_exists(MYBB_ROOT."inc/settings.php"))
{
$mode = "x";

	if(!file_exists(MYBB_ROOT."inc/settings.php"))
{
$mode = "x";

	}
else
{

	}
else
{

		$mode = "w";
}
$options = array(

		$mode = "w";
}
$options = array(

Zeile 3420Zeile 3574

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 3571Zeile 3725
		}
}
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));
}

}

/**

}

/**