Vergleich inc/functions.php - 1.4.0 - 1.4.4

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

 * Website: http://www.mybboard.net
* License: http://www.mybboard.net/about/license
*

 * $Id: functions.php 4058 2008-08-03 00:37:09Z Tikitiki $

 * $Id: functions.php 4279 2008-11-26 00:01:25Z Tikitiki $

 */

/**

 */

/**

Zeile 162Zeile 162
		if(isset($config))
{
require_once MYBB_ROOT."inc/db_".$config['database']['type'].".php";

		if(isset($config))
{
require_once MYBB_ROOT."inc/db_".$config['database']['type'].".php";

			$db = new databaseEngine;



















			switch($config['database']['type'])
{
case "sqlite3":
$db = new DB_SQLite3;
break;
case "sqlite2":
$db = new DB_SQLite2;
break;
case "pgsql":
$db = new DB_PgSQL;
break;
case "mysqli":
$db = new DB_MySQLi;
break;
default:
$db = new DB_MySQL;
}



			$db->connect($config['database']);
define("TABLE_PREFIX", $config['database']['table_prefix']);
$db->set_table_prefix(TABLE_PREFIX);

			$db->connect($config['database']);
define("TABLE_PREFIX", $config['database']['table_prefix']);
$db->set_table_prefix(TABLE_PREFIX);

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

		foreach($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 201Zeile 219
		foreach($shutdown_functions as $function)
{
$function();

		foreach($shutdown_functions as $function)
{
$function();

		}
}

		}
}


$done_shutdown = true;
}


$done_shutdown = true;
}

Zeile 242Zeile 260
	}

$plugins->run_hooks("send_mail_queue_end");

	}

$plugins->run_hooks("send_mail_queue_end");

}

}


/**
* Parses the contents of a page before outputting it.


/**
* Parses the contents of a page before outputting it.

Zeile 391Zeile 409
 * @param string The from address of the email, if blank, the board name will be used.
* @param string The chracter set being used to send this email.
* @param boolean Do we wish to keep the connection to the mail server alive to send more than one message (SMTP only)

 * @param string The from address of the email, if blank, the board name will be used.
* @param string The chracter set being used to send this email.
* @param boolean Do we wish to keep the connection to the mail server alive to send more than one message (SMTP only)

 
 * @param string The format of the email to be sent (text or html). text is default
* @param string The text message of the email if being sent in html format, for email clients that don't support html
* @param string The email address to return to. Defaults to admin return email address.

 */

 */

function my_mail($to, $subject, $message, $from="", $charset="", $headers="", $keep_alive=false, $format="text", $message_text="")

function my_mail($to, $subject, $message, $from="", $charset="", $headers="", $keep_alive=false, $format="text", $message_text="", $return_email="")

{
global $mybb;
static $mail;

{
global $mybb;
static $mail;

Zeile 452Zeile 473
	// Guests get a special string
else
{

	// Guests get a special string
else
{

		return md5($mybb->config['database']['hostname'].$mybb->config['database']['username'].$mybb->config['database']['password']);

		return md5($mybb->config['database']['hostname'].$mybb->config['database']['username'].md5($mybb->config['database']['password']));

	}
}


	}
}


Zeile 479Zeile 500
	else
{
return true;

	else
{
return true;

	}
}

/**

	}
}

/**

 * Return a parent list for the specified forum.
*
* @param int The forum id to get the parent list for.

 * Return a parent list for the specified forum.
*
* @param int The forum id to get the parent list for.

Zeile 492Zeile 513
{
global $forum_cache;
static $forumarraycache;

{
global $forum_cache;
static $forumarraycache;





	if($forumarraycache[$fid])

	if($forumarraycache[$fid])

	{

	{

		return $forumarraycache[$fid]['parentlist'];

		return $forumarraycache[$fid]['parentlist'];

	}

	}

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

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

	{

	{

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

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

Zeile 522Zeile 543
	if(!$parentlist)
{
$parentlist = get_parent_list($fid);

	if(!$parentlist)
{
$parentlist = get_parent_list($fid);

	}

	}


$parentsexploded = explode(",", $parentlist);
$builtlist = "(";


$parentsexploded = explode(",", $parentlist);
$builtlist = "(";

Zeile 532Zeile 553
	{
$builtlist .= "$sep$column='$val'";
$sep = " $joiner ";

	{
$builtlist .= "$sep$column='$val'";
$sep = " $joiner ";

	}

	}


$builtlist .= ")";



$builtlist .= ")";


Zeile 561Zeile 582
		{
$cache->update_forums();
$forum_cache = $cache->read("forums", 1);

		{
$cache->update_forums();
$forum_cache = $cache->read("forums", 1);

		}
}

		}
}

	return $forum_cache;
}


	return $forum_cache;
}


Zeile 641Zeile 662

eval("\$errorpage = \"".$templates->get("error")."\";");
output_page($errorpage);


eval("\$errorpage = \"".$templates->get("error")."\";");
output_page($errorpage);





	exit;
}


	exit;
}


Zeile 651Zeile 672
 * @param array Array of errors to be shown
* @param string The title of the error message
* @return string The inline error HTML

 * @param array Array of errors to be shown
* @param string The title of the error message
* @return string The inline error HTML

 */

 */

function inline_error($errors, $title="")
{
global $theme, $mybb, $db, $lang, $templates;

function inline_error($errors, $title="")
{
global $theme, $mybb, $db, $lang, $templates;

Zeile 701Zeile 722
		"location1" => 0,
"location2" => 0
);

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





	$db->update_query("sessions", $noperm_array, "sid='{$session->sid}'", 1);
$url = htmlspecialchars_uni($_SERVER['REQUEST_URI']);


	$db->update_query("sessions", $noperm_array, "sid='{$session->sid}'", 1);
$url = htmlspecialchars_uni($_SERVER['REQUEST_URI']);


Zeile 711Zeile 732
		header("Content-type: text/html; charset={$lang->settings['charset']}");
echo "<error>{$lang->error_nopermission_user_ajax}</error>\n";
exit;

		header("Content-type: text/html; charset={$lang->settings['charset']}");
echo "<error>{$lang->error_nopermission_user_ajax}</error>\n";
exit;

	}

	}


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


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

	{

	{

		$lang->error_nopermission_user_5 = $lang->sprintf($lang->error_nopermission_user_5, $mybb->user['username']);
eval("\$errorpage = \"".$templates->get("error_nopermission_loggedin")."\";");
}
else
{
eval("\$errorpage = \"".$templates->get("error_nopermission")."\";");

		$lang->error_nopermission_user_5 = $lang->sprintf($lang->error_nopermission_user_5, $mybb->user['username']);
eval("\$errorpage = \"".$templates->get("error_nopermission_loggedin")."\";");
}
else
{
eval("\$errorpage = \"".$templates->get("error_nopermission")."\";");

	}

	}


error($errorpage);
}


error($errorpage);
}

Zeile 731Zeile 752
 *
* @param string The URL to redirect the user to
* @param string The redirection message to be shown

 *
* @param string The URL to redirect the user to
* @param string The redirection message to be shown

 */

 */

function redirect($url, $message="", $title="")
{
global $header, $footer, $mybb, $theme, $headerinclude, $templates, $lang, $plugins;

function redirect($url, $message="", $title="")
{
global $header, $footer, $mybb, $theme, $headerinclude, $templates, $lang, $plugins;





	$redirect_args = array('url' => &$url, 'message' => &$message, 'title' => &$title);

$plugins->run_hooks_by_ref("redirect", $redirect_args);

if($mybb->input['ajax'])

	$redirect_args = array('url' => &$url, 'message' => &$message, 'title' => &$title);

$plugins->run_hooks_by_ref("redirect", $redirect_args);

if($mybb->input['ajax'])

	{

	{

		// Send our headers.
@header("Content-type: text/html; charset={$lang->settings['charset']}");
echo "<script type=\"text/javascript\">\n";
if($message != "")
{

		// Send our headers.
@header("Content-type: text/html; charset={$lang->settings['charset']}");
echo "<script type=\"text/javascript\">\n";
if($message != "")
{

			echo "alert('{$message}');\n";

			echo 'alert("'.addslashes($message).'");';

		}
$url = str_replace("#", "&#", $url);
$url = htmlspecialchars_decode($url);
$url = str_replace(array("\n","\r",";"), "", $url);

		}
$url = str_replace("#", "&#", $url);
$url = htmlspecialchars_decode($url);
$url = str_replace(array("\n","\r",";"), "", $url);

		echo "window.location = '{$url}';\n";

		echo 'window.location = "'.addslashes($url).'";'."\n";

		echo "</script>\n";
exit;
}

		echo "</script>\n";
exit;
}

Zeile 802Zeile 823
 * @return string The generated pagination
*/
function multipage($count, $perpage, $page, $url)

 * @return string The generated pagination
*/
function multipage($count, $perpage, $page, $url)

{

{

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

if($count <= $perpage)

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

if($count <= $perpage)

Zeile 972Zeile 993
function usergroup_permissions($gid=0)
{
global $cache, $groupscache, $grouppermignore, $groupzerogreater;

function usergroup_permissions($gid=0)
{
global $cache, $groupscache, $grouppermignore, $groupzerogreater;



	

	if(!is_array($groupscache))
{
$groupscache = $cache->read("usergroups");

	if(!is_array($groupscache))
{
$groupscache = $cache->read("usergroups");

	}

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



	}

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



	if(count($groups) == 1)
{
return $groupscache[$gid];
}

	if(count($groups) == 1)
{
return $groupscache[$gid];
}





	foreach($groups as $gid)
{
if(trim($gid) == "" || !$groupscache[$gid])

	foreach($groups as $gid)
{
if(trim($gid) == "" || !$groupscache[$gid])

		{

		{

			continue;
}

			continue;
}



		

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

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

				{

				{

					$permbit = $usergroup[$perm];
}
else

					$permbit = $usergroup[$perm];
}
else

Zeile 1006Zeile 1027
					$permbit = "";
}


					$permbit = "";
}


				if(in_array($perm, $groupzerogreater))


				// 0 represents unlimited for numerical group permissions (i.e. private message limit) so take that into account.
if(in_array($perm, $groupzerogreater) && ($access == 0 || $usergroup[$perm] == 0))

				{

				{

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

					$usergroup[$perm] = 0;
continue;
}





if($access > $permbit || ($access == "yes" && $permbit == "no") || !$permbit) // Keep yes/no for compatibility?
{


if($access > $permbit || ($access == "yes" && $permbit == "no") || !$permbit) // Keep yes/no for compatibility?
{

Zeile 1071Zeile 1090

if(!$gid || $gid == 0) // If no group, we need to fetch it
{


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

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

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

	}
}

/**

	}
}

/**

 * Return the permissions for a moderator in a specific forum
*
* @param fid The forum ID

 * Return the permissions for a moderator in a specific forum
*
* @param fid The forum ID

Zeile 1296Zeile 1315
	static $modpermscache;

if($uid < 1)

	static $modpermscache;

if($uid < 1)

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

if($uid == 0)
{
return false;

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

if($uid == 0)
{
return false;

	}

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

	}

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

Zeile 1322Zeile 1341
		}

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

		}

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

	}

	}

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

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

Zeile 1342Zeile 1361
function is_moderator($fid="0", $action="", $uid="0")
{
global $mybb, $cache;

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





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

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

Zeile 1361Zeile 1380
	else
{
if(!$fid)

	else
{
if(!$fid)

		{

		{

			$modcache = $cache->read('moderators');
if(!empty($modcache))
{

			$modcache = $cache->read('moderators');
if(!empty($modcache))
{

Zeile 1371Zeile 1390
					{
return true;
}

					{
return true;
}

				}

				}

			}
return false;
}

			}
return false;
}

Zeile 1420Zeile 1439
	foreach($posticons_cache as $posticon)
{
$posticons[$posticon['name']] = $posticon;

	foreach($posticons_cache as $posticon)
{
$posticons[$posticon['name']] = $posticon;

	}

	}

	krsort($posticons);

foreach($posticons as $dbicon)

	krsort($posticons);

foreach($posticons as $dbicon)

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

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

		}
}

		}
}


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



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


Zeile 1627Zeile 1646
			if(!is_array($serverload))
{
return $lang->unknown;

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

			}
}
}
else

			}
}
}
else

	{
return $lang->unknown;
}

	{
return $lang->unknown;
}

Zeile 1817Zeile 1836
 * @param int The forum ID
*/
function update_forum_lastpost($fid)

 * @param int The forum ID
*/
function update_forum_lastpost($fid)

{
global $db;

{
global $db;


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


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

Zeile 1850Zeile 1869
function update_thread_counters($tid, $changes=array())
{
global $db;

function update_thread_counters($tid, $changes=array())
{
global $db;





	$update_query = array();


	$update_query = array();


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

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


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


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

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

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

			}

			}

			else
{
$update_query[$counter] = $changes[$counter];

			else
{
$update_query[$counter] = $changes[$counter];

Zeile 1879Zeile 1898
			}
}
}

			}
}
}

 
	
$db->free_result($query);


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


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

	{

	{

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

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

 
	
unset($update_query, $thread);


update_thread_data($tid);
}


update_thread_data($tid);
}

Zeile 1897Zeile 1920
function update_thread_data($tid)
{
global $db;

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)
WHERE p.tid='$tid' AND p.visible='1'

		FROM ".TABLE_PREFIX."posts p
LEFT JOIN ".TABLE_PREFIX."users u ON (u.uid=p.uid)
WHERE p.tid='$tid' AND p.visible='1'

Zeile 1906Zeile 1929
		LIMIT 1"
);
$lastpost = $db->fetch_array($query);

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





	
$db->free_result($query);


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

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

Zeile 1916Zeile 1941
		LIMIT 1
");
$firstpost = $db->fetch_array($query);

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





	
$db->free_result($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'];

Zeile 1945Zeile 1972
		'lastposteruid' => intval($lastpost['uid']),
);
$db->update_query("threads", $update_array, "tid='{$tid}'");

		'lastposteruid' => intval($lastpost['uid']),
);
$db->update_query("threads", $update_array, "tid='{$tid}'");

 
	
unset($firstpost, $lastpost, $update_array);

}

function update_forum_count($fid)

}

function update_forum_count($fid)

Zeile 2710Zeile 2739
		else
{
$perms = $mybb->usergroup;

		else
{
$perms = $mybb->usergroup;

		}

$pwverified = 1;


		}

$pwverified = 1;


		if($forum['password'] != "")
{
if($mybb->cookies['forumpass'][$forum['fid']] != md5($mybb->user['uid'].$forum['password']))

		if($forum['password'] != "")
{
if($mybb->cookies['forumpass'][$forum['fid']] != md5($mybb->user['uid'].$forum['password']))

Zeile 2723Zeile 2752
		}

if($perms['canview'] == 0 || $pwverified == 0 || ($only_readable_threads == true && $perms['canviewthreads'] == 0))

		}

if($perms['canview'] == 0 || $pwverified == 0 || ($only_readable_threads == true && $perms['canviewthreads'] == 0))

		{

		{

			if($unviewableforums)
{
$unviewableforums .= ",";

			if($unviewableforums)
{
$unviewableforums .= ",";

Zeile 2763Zeile 2792
	global $nav, $navbits, $templates, $theme, $lang;

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

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

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





	if(is_array($navbits))
{
reset($navbits);

	if(is_array($navbits))
{
reset($navbits);

Zeile 2791Zeile 2820
	if($nav)
{
eval("\$activesep = \"".$templates->get("nav_sep_active")."\";");

	if($nav)
{
eval("\$activesep = \"".$templates->get("nav_sep_active")."\";");

	}


	}


	eval("\$activebit = \"".$templates->get("nav_bit_active")."\";");
eval("\$donenav = \"".$templates->get("nav")."\";");


	eval("\$activebit = \"".$templates->get("nav_bit_active")."\";");
eval("\$donenav = \"".$templates->get("nav")."\";");


Zeile 2920Zeile 2949
			$url = "{$base_url}forum-{$id}.html";
break;
default:

			$url = "{$base_url}forum-{$id}.html";
break;
default:

			$url = $mybb->setings['bburl']."/archive/index.php";

			$url = $mybb->settings['bburl']."/archive/index.php";

	}

return $url;

	}

return $url;

Zeile 3027Zeile 3056
		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 "<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 "</tr>\n";
echo "<tr>\n";

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

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

Zeile 3038Zeile 3067
	if(count($templates->uncached_templates > 0))
{
echo "<table style=\"background-color: #666;\" width=\"95%\" cellpadding=\"4\" cellspacing=\"1\" align=\"center\">\n";

	if(count($templates->uncached_templates > 0))
{
echo "<table style=\"background-color: #666;\" width=\"95%\" cellpadding=\"4\" cellspacing=\"1\" align=\"center\">\n";

		echo "<tr>\n";

		echo "<tr>\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-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";

Zeile 3058Zeile 3087
function send_page_headers()
{
global $mybb;

function send_page_headers()
{
global $mybb;





	if($mybb->settings['nocacheheaders'] == 1 && $mybb->settings['standardheaders'] != 1)
{
header("Expires: Sat, 1 Jan 2000 01:00:00 GMT");

	if($mybb->settings['nocacheheaders'] == 1 && $mybb->settings['standardheaders'] != 1)
{
header("Expires: Sat, 1 Jan 2000 01:00:00 GMT");

		header("Last-Modified: ".gmdate("D, d M Y H:i:s")."GMT");

		header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");

		header("Cache-Control: no-cache, must-revalidate");
header("Pragma: no-cache");
}

		header("Cache-Control: no-cache, must-revalidate");
header("Pragma: no-cache");
}

Zeile 3089Zeile 3118
			}
break;
case "post":

			}
break;
case "post":

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

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

			break;
case "threads":
if(is_array($id))

			break;
case "threads":
if(is_array($id))

Zeile 3108Zeile 3137
		case "all":
$db->update_query("reportedposts", array('reportstatus' => 1), "reportstatus='0'");
break;

		case "all":
$db->update_query("reportedposts", array('reportstatus' => 1), "reportstatus='0'");
break;

	}

	}


$arguments = array('id' => $id, 'type' => $type);
$plugins->run_hooks("mark_reports", $arguments);


$arguments = array('id' => $id, 'type' => $type);
$plugins->run_hooks("mark_reports", $arguments);

Zeile 3265Zeile 3294
 *
* @param int 1 to reset the row to trow1.
* @return string trow1 or trow2 depending on the previous call

 *
* @param int 1 to reset the row to trow1.
* @return string trow1 or trow2 depending on the previous call

 */

 */

function alt_trow($reset=0)
{
global $alttrow;

if($alttrow == "trow1" && !$reset)

function alt_trow($reset=0)
{
global $alttrow;

if($alttrow == "trow1" && !$reset)

	{

	{

		$trow = "trow2";

		$trow = "trow2";

	}
else
{

	}
else
{

		$trow = "trow1";
}


		$trow = "trow1";
}


Zeile 3291Zeile 3320
 * @param int The user group ID to join
*/
function join_usergroup($uid, $joingroup)

 * @param int The user group ID to join
*/
function join_usergroup($uid, $joingroup)

{
global $db;

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

{
global $db, $mybb;

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

		$user = $mybb->user;
}
else
{

		$user = $mybb->user;
}
else
{

		$query = $db->simple_select("users", "additionalgroups, usergroup", "uid='{$uid}'");

		$query = $db->simple_select("users", "additionalgroups, usergroup", "uid='".intval($uid)."'");

		$user = $db->fetch_array($query);
}


		$user = $db->fetch_array($query);
}


Zeile 3323Zeile 3352
		}
}


		}
}


	$db->update_query("users", array('additionalgroups' => $groupslist), "uid='$uid'");










	// What's the point in updating if they're the same?
if($groupslist != $user['additionalgroups'])
{
$db->update_query("users", array('additionalgroups' => $groupslist), "uid='".intval($uid)."'");
return true;
}
else
{
return false;
}

}

/**

}

/**

Zeile 3342Zeile 3380
	}
else
{

	}
else
{

		$query = $db->simple_select("users", "*", "uid='{$uid}'");

		$query = $db->simple_select("users", "*", "uid='".intval($uid)."'");

		$user = $db->fetch_array($query);
}


		$user = $db->fetch_array($query);
}


 
	$groupslist = "";

	$usergroups = "";
$usergroups = $user['additionalgroups'].",";


	$usergroups = "";
$usergroups = $user['additionalgroups'].",";


Zeile 3363Zeile 3402
			}
}
}

			}
}
}




	
$dispupdate = "";

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

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

Zeile 3372Zeile 3412
	$db->write_query("
UPDATE ".TABLE_PREFIX."users
SET additionalgroups='$groupslist' $dispupdate

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

		WHERE uid='$uid'

		WHERE uid='".intval($uid)."'

	");

$cache->update_moderators();

	");

$cache->update_moderators();

Zeile 3393Zeile 3433
	}

if(!empty($_SERVER['PATH_INFO']))

	}

if(!empty($_SERVER['PATH_INFO']))

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

	{
$location = htmlspecialchars_uni($_SERVER['PATH_INFO']);
}

	elseif(!empty($_ENV['PATH_INFO']))

	elseif(!empty($_ENV['PATH_INFO']))

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

	{
$location = htmlspecialchars_uni($_ENV['PATH_INFO']);
}

	elseif(!empty($_ENV['PHP_SELF']))

	elseif(!empty($_ENV['PHP_SELF']))

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

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

	}

if($fields == true)

	}

if($fields == true)

Zeile 3416Zeile 3456
		if(!is_array($ignore))
{
$ignore = array($ignore);

		if(!is_array($ignore))
{
$ignore = array($ignore);

		}

		}

		
$form_html = "";
$field_parts = explode('&', $field_parts);

		
$form_html = "";
$field_parts = explode('&', $field_parts);

Zeile 3440Zeile 3480
	{
if(isset($_SERVER['QUERY_STRING']))
{

	{
if(isset($_SERVER['QUERY_STRING']))
{

			$location .= "?".$_SERVER['QUERY_STRING'];

			$location .= "?".htmlspecialchars_uni($_SERVER['QUERY_STRING']);

		}
else if(isset($_ENV['QUERY_STRING']))
{

		}
else if(isset($_ENV['QUERY_STRING']))
{

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

			$location .= "?".htmlspecialchars_uni($_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"))

		{

		{

			$post_array = array('action', 'fid', 'pid', 'tid', 'uid', 'eid');

			$post_array = array('action', 'fid', 'pid', 'tid', 'uid', 'eid');

	

	

			foreach($post_array as $var)
{
if(isset($_POST[$var]))

			foreach($post_array as $var)
{
if(isset($_POST[$var]))

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

if(isset($addlock) && is_array($addloc))

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

if(isset($addloc) && is_array($addloc))

			{
$location .= "?".implode("&", $addloc);
}
}

			{
$location .= "?".implode("&", $addloc);
}
}

	

 
	
return $location;
}
}

	
return $location;
}
}





/**
* Build a theme selection menu
*

/**
* Build a theme selection menu
*

Zeile 3527Zeile 3566
						$is_allowed = true;
break;
}

						$is_allowed = true;
break;
}

				}
}

				}
}


// Show theme if allowed, or if override is on
if($is_allowed || $theme['allowedgroups'] == "all" || $theme['allowedgroups'] == "" || $usergroup_override == 1)


// Show theme if allowed, or if override is on
if($is_allowed || $theme['allowedgroups'] == "all" || $theme['allowedgroups'] == "" || $usergroup_override == 1)

Zeile 3558Zeile 3597
	}

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 3567Zeile 3606
 * @return string The string with htmlspecialchars applied
*/
function htmlspecialchars_uni($message)

 * @return string The string with htmlspecialchars applied
*/
function htmlspecialchars_uni($message)

{

{

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

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

Zeile 3605Zeile 3644
		else
{
$decimals = 0;

		else
{
$decimals = 0;

		}


		}


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

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

 
	}
}

function convert_through_utf8($str, $to=true)
{
global $lang;
static $charset;
static $use_mb;
static $use_iconv;

if(!isset($charset))
{
$charset = my_strtolower($lang->settings['charset']);
}

if($charset == "utf-8")
{
return $str;
}

if(!isset($use_iconv))
{
$use_iconv = function_exists("iconv");
}

if(!isset($use_mb))
{
$use_mb = function_exists("mb_convert_encoding");
}

if($use_iconv || $use_mb)
{
if($to)
{
$from_charset = $lang->settings['charset'];
$to_charset = "UTF-8";
}
else
{
$from_charset = "UTF-8";
$to_charset = $lang->settings['charset'];
}
if($use_iconv)
{
return iconv($from_charset, $to_charset."//IGNORE", $str);
}
else
{
return @mb_convert_encoding($str, $to_charset, $from_charset);
}
}
elseif($charset == "iso-8859-1" && function_exists("utf8_encode"))
{
if($to)
{
return utf8_encode($str);
}
else
{
return utf8_decode($str);
}
}
else
{
return $str;

	}
}


	}
}


Zeile 3616Zeile 3720
 *
* @param string The string to be word wrapped
* @return string The word wraped string

 *
* @param string The string to be word wrapped
* @return string The word wraped string

 */

 */

function my_wordwrap($message)
{
global $mybb;

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

function my_wordwrap($message)
{
global $mybb;

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

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

	{
$message = convert_through_utf8($message);

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



		}

		}

 
		
$new_message = convert_through_utf8($new_message, false);

return $new_message;

	}

return $message;

	}

return $message;

Zeile 3685Zeile 3791
	return array(
31,
($in % 4 == 0 && ($in % 100 > 0 || $in % 400 == 0) ? 29 : 28),

	return array(
31,
($in % 4 == 0 && ($in % 100 > 0 || $in % 400 == 0) ? 29 : 28),

		31,
30,
31,

		31,
30,
31,

		30,
31,
31,

		30,
31,
31,

Zeile 3748Zeile 3854
		'S',
'l',
'F',

		'S',
'l',
'F',

 
		'M',

	);

$replace = array(

	);

$replace = array(

Zeile 3756Zeile 3863
		my_substr($by, 2),
$by,
($bd[0] == 0 ? my_substr($bd, 1) : $bd),

		my_substr($by, 2),
$by,
($bd[0] == 0 ? my_substr($bd, 1) : $bd),

		($db == 1 || $db == 21 || $db == 31 ? 'st' : ($db == 2 || $db == 22 ? 'nd' : ($db == 3 || $db == 23 ? 'rd' : 'th'))),

		($bd == 1 || $bd == 21 || $bd == 31 ? 'st' : ($bd == 2 || $bd == 22 ? 'nd' : ($bd == 3 || $bd == 23 ? 'rd' : 'th'))),

		$bdays[$wd],
$bmonth[$bm-1],

		$bdays[$wd],
$bmonth[$bm-1],

 
		($bm == 9 ? my_substr($bmonth[$bm-1], 0, 4) :  my_substr($bmonth[$bm-1], 0, 3)),

	);

return str_replace($find, $replace, $display);

	);

return str_replace($find, $replace, $display);

Zeile 3798Zeile 3906
{
global $db;


{
global $db;


	$query = $db->simple_select("posts", "pid", "tid='{$tid}'", array('order_by' => 'dateline', 'limit' => 1));

	$query = $db->simple_select("posts", "pid,replyto", "tid='{$tid}'", array('order_by' => 'dateline', 'limit' => 1));

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

if($post['replyto'] != 0)

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

if($post['replyto'] != 0)

Zeile 3806Zeile 3914
		$replyto_update = array(
"replyto" => 0
);

		$replyto_update = array(
"replyto" => 0
);

		$db->update_query("threads", $replyto_update, "pid='{$post['pid']}'");

		$db->update_query("posts", $replyto_update, "pid='{$post['pid']}'");

	}

$firstpostup = array(

	}

$firstpostup = array(

Zeile 3825Zeile 3933
{
global $lang;


{
global $lang;


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

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


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


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

Zeile 3835Zeile 3943

// Remove dodgy whitespaces
$string = str_replace(chr(0xCA), "", $string);


// Remove dodgy whitespaces
$string = str_replace(chr(0xCA), "", $string);

		$string = str_replace("  ", " ", $string);

 
    }
$string = trim($string);


    }
$string = trim($string);


Zeile 3849Zeile 3956
    }

return $string_length;

    }

return $string_length;

}

}


/**
* Cuts a string at a specified point, mb strings accounted for


/**
* Cuts a string at a specified point, mb strings accounted for

Zeile 3859Zeile 3966
 * @param int (optional) How much to cut
* @param bool (optional) Properly handle HTML entities?
* @return int The cut part of the string.

 * @param int (optional) How much to cut
* @param bool (optional) Properly handle HTML entities?
* @return int The cut part of the string.

 */

 */

function my_substr($string, $start, $length="", $handle_entities = false)
{
if($handle_entities)

function my_substr($string, $start, $length="", $handle_entities = false)
{
if($handle_entities)

	{

	{

		$string = unhtmlentities($string);
}
if(function_exists("mb_substr"))

		$string = unhtmlentities($string);
}
if(function_exists("mb_substr"))

	{
if($length != "")
{

	{
if($length != "")
{

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

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

Zeile 3887Zeile 3994
		{
$cut_string = substr($string, $start);
}

		{
$cut_string = substr($string, $start);
}

	}


	}


	if($handle_entities)
{
$cut_string = htmlspecialchars_uni($cut_string);

	if($handle_entities)
{
$cut_string = htmlspecialchars_uni($cut_string);

Zeile 3898Zeile 4005

/**
* lowers the case of a string, mb strings accounted for


/**
* lowers the case of a string, mb strings accounted for

 *

 *

 * @param string The string to lower.
* @return int The lowered string.
*/

 * @param string The string to lower.
* @return int The lowered string.
*/

Zeile 3927Zeile 4034
function my_strpos($haystack, $needle, $offset=0)
{
if($needle == '')

function my_strpos($haystack, $needle, $offset=0)
{
if($needle == '')

	{

	{

		return false;
}


		return false;
}


Zeile 3970Zeile 4077
 * @return int The un-htmlentitied' string.
*/
function unhtmlentities($string)

 * @return int The un-htmlentitied' string.
*/
function unhtmlentities($string)

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








{	
// Replace numeric entities
$string = preg_replace('~&#x([0-9a-f]+);~ei', 'unichr(hexdec("\\1"))', $string);
$string = preg_replace('~&#([0-9]+);~e', 'unichr("\\1")', $string);

// Replace literal entities
$trans_tbl = get_html_translation_table(HTML_ENTITIES);
$trans_tbl = array_flip($trans_tbl);

return strtr($string, $trans_tbl);
}





   // Replace literal entities
$trans_tbl = get_html_translation_table(HTML_ENTITIES);
$trans_tbl = array_flip($trans_tbl);

return strtr($string, $trans_tbl);



























/**
* Returns any ascii to it's character (utf-8 safe).
*
* @param string The ascii to characterize.
* @return int The characterized ascii.
*/
function unichr($c)
{
if($c <= 0x7F)
{
return chr($c);
}
else if($c <= 0x7FF)
{
return chr(0xC0 | $c >> 6) . chr(0x80 | $c & 0x3F);
}
else if($c <= 0xFFFF)
{
return chr(0xE0 | $c >> 12) . chr(0x80 | $c >> 6 & 0x3F)
. chr(0x80 | $c & 0x3F);
}
else if($c <= 0x10FFFF)
{
return chr(0xF0 | $c >> 18) . chr(0x80 | $c >> 12 & 0x3F)
. chr(0x80 | $c >> 6 & 0x3F)
. chr(0x80 | $c & 0x3F);
}
else
{
return false;
}

}

/**

}

/**

Zeile 3993Zeile 4133
	$event['username'] = format_name($event['username'], $event['usergroup'], $event['displaygroup']);
$event_poster = build_profile_link($event['username'], $event['author']);
return $event_poster;

	$event['username'] = format_name($event['username'], $event['usergroup'], $event['displaygroup']);
$event_poster = build_profile_link($event['username'], $event['author']);
return $event_poster;

}

}


/**
* Get the event date.


/**
* Get the event date.

Zeile 4012Zeile 4152

/**
* Get the profile link.


/**
* Get the profile link.

 *

 *

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

 * @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 htmlspecialchars_uni($link);

	return htmlspecialchars_uni($link);

}

/**

}

/**

Zeile 4027Zeile 4167
 *
* @param int The announement id of the announcement.
* @return string The url to the announcement.

 *
* @param int The announement id of the announcement.
* @return string The url to the announcement.

 */

 */

function get_announcement_link($aid=0)
{
$link = str_replace("{aid}", $aid, ANNOUNCEMENT_URL);

function get_announcement_link($aid=0)
{
$link = str_replace("{aid}", $aid, ANNOUNCEMENT_URL);

Zeile 4073Zeile 4213
		// If we're in the archive, link back a directory
if(IN_ARCHIVE == 1)
{

		// If we're in the archive, link back a directory
if(IN_ARCHIVE == 1)
{

			global $mybb;

if($mybb->settings['seourls'] == "yes" || ($mybb->settings['seourls'] == "auto" && $_SERVER['SEO_SUPPORT'] == 1))
{
return "<a href=\"../../".get_profile_link($uid)."\"{$target}{$onclick}>{$username}</a>";
}

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

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








		}
elseif(IN_ADMINCP == 1)
{

		}
elseif(IN_ADMINCP == 1)
{

Zeile 4173Zeile 4306
	else
{
$link = str_replace("{pid}", $pid, POST_URL);

	else
{
$link = str_replace("{pid}", $pid, POST_URL);

		return htmlspecialchars_uni($link);
}
}

/**

		return htmlspecialchars_uni($link);
}
}

/**

 * Build the event link.
*
* @param int The event ID of the event

 * Build the event link.
*
* @param int The event ID of the event

Zeile 4191Zeile 4324

/**
* Build the link to a specified date on the calendar


/**
* Build the link to a specified date on the calendar

 *
* @param int The ID of the calendar
* @param int The year

 *
* @param int The ID of the calendar
* @param int The year

 * @param int The month
* @param int The day (optional)
* @return string The URL of the calendar

 * @param int The month
* @param int The day (optional)
* @return string The URL of the calendar

Zeile 4201Zeile 4334
function get_calendar_link($calendar, $year=0, $month=0, $day=0)
{
if($day > 0)

function get_calendar_link($calendar, $year=0, $month=0, $day=0)
{
if($day > 0)

	{

	{

		$link = str_replace("{month}", $month, CALENDAR_URL_DAY);
$link = str_replace("{year}", $year, $link);
$link = str_replace("{day}", $day, $link);

		$link = str_replace("{month}", $month, CALENDAR_URL_DAY);
$link = str_replace("{year}", $year, $link);
$link = str_replace("{day}", $day, $link);

Zeile 4216Zeile 4349
		return htmlspecialchars_uni($link);
}
else if($year > 0)

		return htmlspecialchars_uni($link);
}
else if($year > 0)

	{

	{

		$link = str_replace("{year}", $year, CALENDAR_URL_YEAR);
$link = str_replace("{calendar}", $calendar, $link);
return htmlspecialchars_uni($link);

		$link = str_replace("{year}", $year, CALENDAR_URL_YEAR);
$link = str_replace("{calendar}", $calendar, $link);
return htmlspecialchars_uni($link);

Zeile 4238Zeile 4371
 */
function get_calendar_week_link($calendar, $week)
{

 */
function get_calendar_week_link($calendar, $week)
{

 
	if($week < 0)
{
$week = str_replace('-', "n", $week);
}

	$link = str_replace("{week}", $week, CALENDAR_URL_WEEK);
$link = str_replace("{calendar}", $calendar, $link);
return htmlspecialchars_uni($link);

	$link = str_replace("{week}", $week, CALENDAR_URL_WEEK);
$link = str_replace("{calendar}", $calendar, $link);
return htmlspecialchars_uni($link);

Zeile 4411Zeile 4548
		}
}
$inactiveforums = implode(",", $inactive);

		}
}
$inactiveforums = implode(",", $inactive);





	return $inactiveforums;
}


	return $inactiveforums;
}


Zeile 4491Zeile 4628
		}

// Work out if the user has waited long enough before letting them login again

		}

// Work out if the user has waited long enough before letting them login again

		if($mybb->cookies['failedlogin'] < $now - $mybb->settings['failedlogintime'] * 60)

		if($mybb->cookies['failedlogin'] < ($now - $mybb->settings['failedlogintime'] * 60) && $mybb->user['uid'] != 0)

		{
my_setcookie('loginattempts', 1);
my_unsetcookie('failedlogin');
$update_array = array(
'loginattempts' => 1
);

		{
my_setcookie('loginattempts', 1);
my_unsetcookie('failedlogin');
$update_array = array(
'loginattempts' => 1
);

			$db->update_query("sessions", $update_array, "sid = '{$session->sid}'");

			$db->update_query("users", $update_array, "uid = '{$mybb->user['uid']}'");

			return 1;
}
// Not waited long enough

			return 1;
}
// Not waited long enough

		else

		else if($mybb->cookies['failedlogin'] > ($now - $mybb->settings['failedlogintime'] * 60))

		{
if($fatal)
{

		{
if($fatal)
{

Zeile 4519Zeile 4656

/**
* Validates the format of an email address.


/**
* Validates the format of an email address.

 *

 *

 * @param string The string to check.
* @return boolean True when valid, false when invalid.
*/

 * @param string The string to check.
* @return boolean True when valid, false when invalid.
*/

Zeile 4528Zeile 4665
	if(strpos($email, ' ') !== false)
{
return false;

	if(strpos($email, ' ') !== false)
{
return false;

	}

	}

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

	// 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 4563Zeile 4700
 * DEPRECATED! ONLY INCLUDED FOR COMPATIBILITY PURPOSES.
*/
function rebuildsettings()

 * DEPRECATED! ONLY INCLUDED FOR COMPATIBILITY PURPOSES.
*/
function rebuildsettings()

{

{

	rebuild_settings();
}


	rebuild_settings();
}


Zeile 4572Zeile 4709
 *
*/
function rebuild_settings()

 *
*/
function rebuild_settings()

{

{

	global $db, $mybb;

if(!file_exists(MYBB_ROOT."inc/settings.php"))

	global $db, $mybb;

if(!file_exists(MYBB_ROOT."inc/settings.php"))

	{

	{

		$mode = "x";

		$mode = "x";

	}

	}

	else
{
$mode = "w";

	else
{
$mode = "w";

	}

	}


$options = array(
"order_by" => "title",


$options = array(
"order_by" => "title",

Zeile 4613Zeile 4750
 */
function build_highlight_array($terms)
{

 */
function build_highlight_array($terms)
{

	$terms = htmlspecialchars_uni($terms);


 
	// Strip out any characters that shouldn't be included
$bad_characters = array(
"(",

	// Strip out any characters that shouldn't be included
$bad_characters = array(
"(",

Zeile 4632Zeile 4767
		$terms = explode("\"", $terms);
foreach($terms as $phrase)
{

		$terms = explode("\"", $terms);
foreach($terms as $phrase)
{

 
			$phrase = htmlspecialchars_uni($phrase);

			if($phrase != "")
{
if($inquote)

			if($phrase != "")
{
if($inquote)

Zeile 4653Zeile 4789
						}
$words[] = trim($word);
}

						}
$words[] = trim($word);
}

				}
}

				}
}

			$inquote = !$inquote;
}
}
// Otherwise just a simple search query with no phrases
else
{

			$inquote = !$inquote;
}
}
// Otherwise just a simple search query with no phrases
else
{

 
		$terms = htmlspecialchars_uni($terms);

		$split_words = preg_split("#\s{1,}#", $terms, -1);
if(!is_array($split_words))

		$split_words = preg_split("#\s{1,}#", $terms, -1);
if(!is_array($split_words))

		{
continue;

		{
continue;

		}
foreach($split_words as $word)
{

		}
foreach($split_words as $word)
{

Zeile 4673Zeile 4810
				continue;
}
$words[] = trim($word);

				continue;
}
$words[] = trim($word);

		}

}


		}

}


	if(!is_array($words))
{
return false;

	if(!is_array($words))
{
return false;

Zeile 4684Zeile 4821

// Loop through our words to build the PREG compatible strings
foreach($words as $word)


// Loop through our words to build the PREG compatible strings
foreach($words as $word)

	{

	{

		$word = trim($word);

$word = my_strtolower($word);

		$word = trim($word);

$word = my_strtolower($word);

Zeile 4694Zeile 4831
		{
continue;
}

		{
continue;
}





		// Now make PREG compatible
$find = "#(^|>)([^<]*)(".preg_quote($word, "#").")#i";
$replacement = "$1$2<span class=\"highlight\">$3</span>";

		// Now make PREG compatible
$find = "#(^|>)([^<]*)(".preg_quote($word, "#").")#i";
$replacement = "$1$2<span class=\"highlight\">$3</span>";

Zeile 4734Zeile 4871
		$dest .= chr(0x80 | ($src & 0x003f));
}
elseif($src <= 0x10ffff)

		$dest .= chr(0x80 | ($src & 0x003f));
}
elseif($src <= 0x10ffff)

	{

	{

		$dest .= chr(0xf0 | ($src >> 18));
$dest .= chr(0x80 | (($src >> 12) & 0x3f));
$dest .= chr(0x80 | (($src >> 6) & 0x3f));

		$dest .= chr(0xf0 | ($src >> 18));
$dest .= chr(0x80 | (($src >> 12) & 0x3f));
$dest .= chr(0x80 | (($src >> 6) & 0x3f));

Zeile 4744Zeile 4881
	{
// Out of range
return false;

	{
// Out of range
return false;

	}


	}


	return $dest;
}


	return $dest;
}


Zeile 4753Zeile 4890
 * Checks if a username has been disallowed for registration/use.
*
* @param string The username

 * Checks if a username has been disallowed for registration/use.
*
* @param string The username

 * @param boolean True if the 'last used' dateline should be updated if a match is found.
* @return boolean True if banned, false if not banned

 * @param boolean True if the 'last used' dateline should be updated if a match is found.
* @return boolean True if banned, false if not banned

 */
function is_banned_username($username, $update_lastuse=false)
{

 */
function is_banned_username($username, $update_lastuse=false)
{

Zeile 4813Zeile 4950
 * @param string The IP address.
* @param boolean True if the 'last used' dateline should be updated if a match is found.
* @return boolean True if banned, false if not banned.

 * @param string The IP address.
* @param boolean True if the 'last used' dateline should be updated if a match is found.
* @return boolean True if banned, false if not banned.

 */

 */

function is_banned_ip($ip_address, $update_lastuse=false)
{
global $db, $cache;

function is_banned_ip($ip_address, $update_lastuse=false)
{
global $db, $cache;

Zeile 4936Zeile 5073
 * @param string The URL of the remote file
* @return string The remote file contents.
*/

 * @param string The URL of the remote file
* @return string The remote file contents.
*/

function fetch_remote_file($url)

function fetch_remote_file($url, $post_data=array())

{

{

 
	$post_body = '';
if(!empty($post_data))
{
foreach($post_data as $key => $val)
{
$post_body .= '&'.urlencode($key).'='.urlencode($val);
}
$post_body = ltrim($post_body, '&');
}


	if(function_exists("curl_init"))
{
$ch = curl_init();

	if(function_exists("curl_init"))
{
$ch = curl_init();

Zeile 4945Zeile 5092
		curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

		curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

 
		if(!empty($post_body))
{
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_body);
}

		$data = curl_exec($ch);
curl_close($ch);
return $data;
}

		$data = curl_exec($ch);
curl_close($ch);
return $data;
}

	else if(function_exists("fsockopen"))

 	else if(function_exists("fsockopen"))

	{
$url = @parse_url($url);
if(!$url['host'])

	{
$url = @parse_url($url);
if(!$url['host'])

Zeile 4965Zeile 5117
			$url['path'] = "/";
}
if($url['query'])

			$url['path'] = "/";
}
if($url['query'])

		{

		{

			$url['path'] .= "?{$url['query']}";
}
$fp = @fsockopen($url['host'], $url['port'], $error_no, $error, 10);

			$url['path'] .= "?{$url['query']}";
}
$fp = @fsockopen($url['host'], $url['port'], $error_no, $error, 10);

Zeile 4974Zeile 5126
		{
return false;
}

		{
return false;
}

		$headers = "GET {$url['path']} HTTP/1.1\r\n";
$headers .= "Host: {$url['host']}\r\n";
$headers .= "Connection: Close\r\n\r\n";




















		$headers = array();
if(!empty($post_body))
{
$headers[] = "POST {$url['path']} HTTP/1.0";
$headers[] = "Content-Length: ".strlen($post_body);
$headers[] = "Content-Type: application/x-www-form-urlencoded";
}
else
{
$headers[] = "GET {$url['path']} HTTP/1.0";
}

$headers[] = "Host: {$url['host']}";
$headers[] = "Connection: Close";
$headers[] = "\r\n";

if(!empty($post_body))
{
$headers[] = $post_body;
}

$headers = implode("\r\n", $headers);

		if(!@fwrite($fp, $headers))
{
return false;

		if(!@fwrite($fp, $headers))
{
return false;

Zeile 4988Zeile 5159
		fclose($fp);
$data = explode("\r\n\r\n", $data, 2);
return $data[1];

		fclose($fp);
$data = explode("\r\n\r\n", $data, 2);
return $data[1];

 
	}
else if(empty($post_data))
{
return @implode("", @file($url));

	}
else
{

	}
else
{

		return @implode("", @file($url));

		return false;

	}
}


	}
}


Zeile 5244Zeile 5419
 * Custom chmod function to fix problems with hosts who's server configurations screw up umasks
*
* @param string The file to chmod

 * Custom chmod function to fix problems with hosts who's server configurations screw up umasks
*
* @param string The file to chmod

 * @param octal The mode to chmod(i.e. 0666)

 * @param string The mode to chmod(i.e. 0666)

 */
function my_chmod($file, $mode)
{

 */
function my_chmod($file, $mode)
{

 
	// Passing $mode as an octal number causes strlen and substr to return incorrect values. Instead pass as a string

	if(substr($mode, 0, 1) != '0' || strlen($mode) !== 4)
{
return false;
}
$old_umask = umask(0);

	if(substr($mode, 0, 1) != '0' || strlen($mode) !== 4)
{
return false;
}
$old_umask = umask(0);

	$result = chmod($file, $mode);




	
// We convert the octal string to a decimal number because passing a octal string doesn't work with chmod
// and type casting subsequently removes the prepended 0 which is needed for octal numbers
$result = chmod($file, octdec($mode));

	umask($old_umask);
return $result;
}

	umask($old_umask);
return $result;
}

Zeile 5286Zeile 5465
            }
@closedir($dh);
}

            }
@closedir($dh);
}

		

		

		// Are we done? Don't delete the main folder too and return true
if($path == $orig_dir)
{

		// Are we done? Don't delete the main folder too and return true
if($path == $orig_dir)
{

Zeile 5297Zeile 5476
    }

return @unlink($path);

    }

return @unlink($path);

 
}

/**
* Counts the number of subforums in a array([pid][disporder][fid]) starting from the pid
*
* @param array The array of forums
* @return integer The number of sub forums
*/
function subforums_count($array)
{
$count = 0;
foreach($array as $array2)
{
$count += count($array2);
}

return $count;

}

?>

}

?>