Vergleich inc/functions.php - 1.4.3 - 1.4.10

  Keine Änderungen   Hinzugefügt   Modifiziert   Entfernt
Zeile 1Zeile 1
<?php
/**
* MyBB 1.4

<?php
/**
* MyBB 1.4

 * Copyright � 2008 MyBB Group, All Rights Reserved

 * Copyright © 2008 MyBB Group, All Rights Reserved

 *
* 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 4182 2008-09-07 18:05:30Z Tikitiki $

 * $Id: functions.php 4562 2009-11-29 22:04:37Z RyanGordon $

 */

/**

 */

/**

Zeile 228Zeile 228
/**
* Sends a specified amount of messages from the mail queue
*

/**
* Sends a specified amount of messages from the mail queue
*

 * @param int The number of messages to send (Defaults to 20)

 * @param int The number of messages to send (Defaults to 10)

 */
function send_mail_queue($count=10)
{

 */
function send_mail_queue($count=10)
{

Zeile 409Zeile 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 451Zeile 454
	}

// Build and send

	}

// Build and send

	$mail->build_message($to, $subject, $message, $from, $charset, $headers, $format, $message_text);

	$mail->build_message($to, $subject, $message, $from, $charset, $headers, $format, $message_text, $return_email);

	return $mail->send();
}


	return $mail->send();
}


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

	// Guests get a special string
else
{

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

		return md5($mybb->settings['bburl'].$mybb->config['database']['username'].$mybb->settings['internal']['encryption_key']);

	}
}


	}
}


Zeile 491Zeile 494
		}
else
{

		}
else
{

			error($lang->invalid_post_code);








			if(defined("IN_ADMINCP"))
{
return false;
}
else
{
error($lang->invalid_post_code);
}

		}
}
else

		}
}
else

Zeile 510Zeile 520
{
global $forum_cache;
static $forumarraycache;

{
global $forum_cache;
static $forumarraycache;





	if($forumarraycache[$fid])
{
return $forumarraycache[$fid]['parentlist'];

	if($forumarraycache[$fid])
{
return $forumarraycache[$fid]['parentlist'];

Zeile 528Zeile 538

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


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

 *

 *

 * @param int The forum ID
* @param string The column name to add to the query
* @param string The joiner for each forum for querying (OR | AND | etc)

 * @param int The forum ID
* @param string The column name to add to the query
* @param string The joiner for each forum for querying (OR | AND | etc)

Zeile 538Zeile 548
function build_parent_list($fid, $column="fid", $joiner="OR", $parentlist="")
{
if(!$parentlist)

function build_parent_list($fid, $column="fid", $joiner="OR", $parentlist="")
{
if(!$parentlist)

	{

	{

		$parentlist = get_parent_list($fid);
}


		$parentlist = get_parent_list($fid);
}


Zeile 565Zeile 575
function cache_forums($force=false)
{
global $forum_cache, $cache;

function cache_forums($force=false)
{
global $forum_cache, $cache;

	

	

	if($force == true)

	if($force == true)

	{

	{

		$forum_cache = $cache->read("forums", 1);
return $forum_cache;
}

if(!$forum_cache)

		$forum_cache = $cache->read("forums", 1);
return $forum_cache;
}

if(!$forum_cache)

	{

	{

		$forum_cache = $cache->read("forums");
if(!$forum_cache)
{

		$forum_cache = $cache->read("forums");
if(!$forum_cache)
{

Zeile 582Zeile 592
		}
}
return $forum_cache;

		}
}
return $forum_cache;

}

}


/**
* Generate an array of all child and descendant forums for a specific forum.


/**
* Generate an array of all child and descendant forums for a specific forum.

Zeile 591Zeile 601
 * @param return Array of descendants
*/
function get_child_list($fid)

 * @param return Array of descendants
*/
function get_child_list($fid)

{

{

	static $forums_by_parent;

$forums = array();

	static $forums_by_parent;

$forums = array();

Zeile 609Zeile 619
	if(!is_array($forums_by_parent[$fid]))
{
return;

	if(!is_array($forums_by_parent[$fid]))
{
return;

	}

	}

	
foreach($forums_by_parent[$fid] as $forum)
{

	
foreach($forums_by_parent[$fid] as $forum)
{

Zeile 637Zeile 647
	if(!$error)
{
$error = $lang->unknown_error;

	if(!$error)
{
$error = $lang->unknown_error;

	}

// AJAX error message?
if($mybb->input['ajax'])
{
// Send our headers.
@header("Content-type: text/html; charset={$lang->settings['charset']}");
echo "<error>{$error}</error>\n";
exit;
}

if(!$title)

	}

// AJAX error message?
if($mybb->input['ajax'])
{
// Send our headers.
@header("Content-type: text/html; charset={$lang->settings['charset']}");
echo "<error>{$error}</error>\n";
exit;
}

if(!$title)

	{
$title = $mybb->settings['bbname'];
}

	{
$title = $mybb->settings['bbname'];
}

Zeile 675Zeile 685
	global $theme, $mybb, $db, $lang, $templates;

if(!$title)

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

if(!$title)

	{

	{

		$title = $lang->please_correct_errors;
}


		$title = $lang->please_correct_errors;
}


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

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

	}


	}


	foreach($errors as $error)
{
$errorlist .= "<li>".$error."</li>\n";

	foreach($errors as $error)
{
$errorlist .= "<li>".$error."</li>\n";

Zeile 710Zeile 720
function error_no_permission()
{
global $mybb, $theme, $templates, $db, $lang, $plugins, $session;

function error_no_permission()
{
global $mybb, $theme, $templates, $db, $lang, $plugins, $session;


$time = TIME_NOW;


$time = TIME_NOW;

	$plugins->run_hooks("no_permission");

$noperm_array = array (

	$plugins->run_hooks("no_permission");

$noperm_array = array (

Zeile 728Zeile 738
		// Send our headers.
header("Content-type: text/html; charset={$lang->settings['charset']}");
echo "<error>{$lang->error_nopermission_user_ajax}</error>\n";

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

		exit;
}


		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 757Zeile 767
	$redirect_args = array('url' => &$url, 'message' => &$message, 'title' => &$title);

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

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

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





	if($mybb->input['ajax'])
{
// Send our headers.

	if($mybb->input['ajax'])
{
// Send our headers.

Zeile 784Zeile 794
	$timenow = my_date($mybb->settings['dateformat'], $time) . " " . my_date($mybb->settings['timeformat'], $time);

if(!$title)

	$timenow = my_date($mybb->settings['dateformat'], $time) . " " . my_date($mybb->settings['timeformat'], $time);

if(!$title)

	{

	{

		$title = $mybb->settings['bbname'];
}


		$title = $mybb->settings['bbname'];
}


Zeile 799Zeile 809
	}
else
{

	}
else
{

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

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

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





		run_shutdown();
header("Location: $url");
}

		run_shutdown();
header("Location: $url");
}

Zeile 838Zeile 847
		$prev = $page-1;
$page_url = fetch_page_url($url, $prev);
eval("\$prevpage = \"".$templates->get("multipage_prevpage")."\";");

		$prev = $page-1;
$page_url = fetch_page_url($url, $prev);
eval("\$prevpage = \"".$templates->get("multipage_prevpage")."\";");

	}

	}


// Maximum number of "page bits" to show
if(!$mybb->settings['maxmultipagelinks'])


// Maximum number of "page bits" to show
if(!$mybb->settings['maxmultipagelinks'])

Zeile 856Zeile 865
	}

if($to > $pages)

	}

if($to > $pages)

	{
$to = $pages;

	{
$to = $pages;

		$from = $pages-$mybb->settings['maxmultipagelinks']+1;
if($from <= 0)
{

		$from = $pages-$mybb->settings['maxmultipagelinks']+1;
if($from <= 0)
{

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

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



	

	if(!is_array($groupscache))

	if(!is_array($groupscache))

	{

	{

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

		$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])
{
continue;

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

		}


		}


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

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

Zeile 1024Zeile 1032
					$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 || $permbit === 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 1042Zeile 1048
	}

return $usergroup;

	}

return $usergroup;

}

}


/**
* Fetch the display group properties for a specific display group


/**
* Fetch the display group properties for a specific display group

Zeile 1051Zeile 1057
 * @return array Array of display properties for the group
*/
function usergroup_displaygroup($gid)

 * @return array Array of display properties for the group
*/
function usergroup_displaygroup($gid)

{

{

	global $cache, $groupscache, $displaygroupfields;

if(!is_array($groupscache))

	global $cache, $groupscache, $displaygroupfields;

if(!is_array($groupscache))

Zeile 1079Zeile 1085
 * @return array Forum permissions for the specific forum or forums
*/
function forum_permissions($fid=0, $uid=0, $gid=0)

 * @return array Forum permissions for the specific forum or forums
*/
function forum_permissions($fid=0, $uid=0, $gid=0)

{

{

	global $db, $cache, $groupscache, $forum_cache, $fpermcache, $mybb, $usercache, $cached_forum_permissions_permissions, $cached_forum_permissions;

if($uid == 0)

	global $db, $cache, $groupscache, $forum_cache, $fpermcache, $mybb, $usercache, $cached_forum_permissions_permissions, $cached_forum_permissions;

if($uid == 0)

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

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

			if($usercache[$uid])

			if(!$usercache[$uid])

			{
$query = $db->simple_select("users", "*", "uid='$uid'");
$usercache[$uid] = $db->fetch_array($query);

			{
$query = $db->simple_select("users", "*", "uid='$uid'");
$usercache[$uid] = $db->fetch_array($query);

Zeile 1114Zeile 1120
	}

if(!is_array($forum_cache))

	}

if(!is_array($forum_cache))

	{
$forum_cache = cache_forums();

	{
$forum_cache = cache_forums();


if(!$forum_cache)
{


if(!$forum_cache)
{

Zeile 1124Zeile 1130
	}

if(!is_array($fpermcache))

	}

if(!is_array($fpermcache))

	{

	{

		$fpermcache = $cache->read("forumpermissions");
}


		$fpermcache = $cache->read("forumpermissions");
}


Zeile 1133Zeile 1139
		if(!$cached_forum_permissions_permissions[$gid][$fid])
{
$cached_forum_permissions_permissions[$gid][$fid] = fetch_forum_permissions($fid, $gid, $groupperms);

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

		}

		}

		return $cached_forum_permissions_permissions[$gid][$fid];
}
else

		return $cached_forum_permissions_permissions[$gid][$fid];
}
else

Zeile 1152Zeile 1158
/**
* Fetches the permissions for a specific forum/group applying the inheritance scheme.
* Called by forum_permissions()

/**
* Fetches the permissions for a specific forum/group applying the inheritance scheme.
* Called by forum_permissions()

 *
* @param int The forum ID

 *
* @param int The forum ID

 * @param string A comma separated list of usergroups
* @param array Group permissions
* @return array Permissions for this forum

 * @param string A comma separated list of usergroups
* @param array Group permissions
* @return array Permissions for this forum

Zeile 1261Zeile 1267
	$password = $forum_cache[$fid]['password'];
if($password)
{

	$password = $forum_cache[$fid]['password'];
if($password)
{

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

		if($mybb->input['pwverify'] && $pid == 0)

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

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

Zeile 1293Zeile 1299

if($showform)
{


if($showform)
{

		$_SERVER['REQUEST_URI'] = htmlspecialchars_uni($_SERVER['REQUEST_URI']);
eval("\$pwform = \"".$templates->get("forumdisplay_password")."\";");
output_page($pwform);








		if($pid)
{
header("Location: ".$mybb->settings['bburl']."/".get_forum_link($fid));
}
else
{
$_SERVER['REQUEST_URI'] = htmlspecialchars_uni($_SERVER['REQUEST_URI']);
eval("\$pwform = \"".$templates->get("forumdisplay_password")."\";");
output_page($pwform);
}

		exit;
}
}

		exit;
}
}

Zeile 1375Zeile 1388
	if($user_perms['issupermod'] == 1)
{
return true;

	if($user_perms['issupermod'] == 1)
{
return true;

	}
else

	}
else

	{
if(!$fid)
{

	{
if(!$fid)
{

Zeile 1392Zeile 1405
				}
}
return false;

				}
}
return false;

		}

		}

		else
{
$modperms = get_moderator_permissions($fid, $uid);

		else
{
$modperms = get_moderator_permissions($fid, $uid);

Zeile 1447Zeile 1460
		{
$iconlist .= "<label><input type=\"radio\" name=\"icon\" value=\"".$dbicon['iid']."\" checked=\"checked\" /> <img src=\"".$dbicon['path']."\" alt=\"".$dbicon['name']."\" /></label>";
$no_icons_checked = "";

		{
$iconlist .= "<label><input type=\"radio\" name=\"icon\" value=\"".$dbicon['iid']."\" checked=\"checked\" /> <img src=\"".$dbicon['path']."\" alt=\"".$dbicon['name']."\" /></label>";
$no_icons_checked = "";

		}
else
{

		}
else
{

			$iconlist .= "<label><input type=\"radio\" name=\"icon\" value=\"".$dbicon['iid']."\" /> <img src=\"".$dbicon['path']."\" alt=\"".$dbicon['name']."\" /></label>";
}


			$iconlist .= "<label><input type=\"radio\" name=\"icon\" value=\"".$dbicon['iid']."\" /> <img src=\"".$dbicon['path']."\" alt=\"".$dbicon['name']."\" /></label>";
}


Zeile 1592Zeile 1605
	$cookie = $mybb->cookies['mybb'];
$newcookie = unserialize($cookie[$name]);
$newcookie[$id] = $value;

	$cookie = $mybb->cookies['mybb'];
$newcookie = unserialize($cookie[$name]);
$newcookie[$id] = $value;

	$newcookie = addslashes(serialize($newcookie));
my_setcookie("mybb[$name]", $newcookie);




	$newcookie = serialize($newcookie);
my_setcookie("mybb[$name]", addslashes($newcookie));

// Make sure our current viarables are up-to-date as well
$mybb->cookies['mybb'][$name] = $newcookie;

}

/**

}

/**

Zeile 1615Zeile 1631
			$serverload = explode(" ", $load);
$serverload[0] = round($serverload[0], 4);
}

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

		if(!$serverload)

		if(!is_numeric($serverload[0]))

		{
if(@ini_get('safe_mode') == 'On')
{

		{
if(@ini_get('safe_mode') == 'On')
{

Zeile 1640Zeile 1656
			}

$load = @exec("uptime");

			}

$load = @exec("uptime");

			$load = split("load averages?: ", $load);

			$load = explode("load average: ", $load);

			$serverload = explode(",", $load[1]);
if(!is_array($serverload))
{

			$serverload = explode(",", $load[1]);
if(!is_array($serverload))
{

Zeile 1671Zeile 1687

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


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

	foreach($counters as $counter)
{

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

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

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

Zeile 1704Zeile 1720
	if(is_array($stats))
{
$stats = array_merge($stats, $new_stats);

	if(is_array($stats))
{
$stats = array_merge($stats, $new_stats);

	}

	}

	else
{
$stats = $new_stats;

	else
{
$stats = $new_stats;

Zeile 1721Zeile 1737

$cache->update("stats", $stats, "dateline");
}


$cache->update("stats", $stats, "dateline");
}





/**
* Updates the forum counters with a specific value (or addition/subtraction of the previous value)
*

/**
* Updates the forum counters with a specific value (or addition/subtraction of the previous value)
*

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

	// Fetch above counters for this forum
$query = $db->simple_select("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) == "-")


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

			{
$update_query[$counter] = $forum[$counter] + $changes[$counter];

			}

			}

			else
{
$update_query[$counter] = $changes[$counter];
}
// Less than 0? That's bad
if($update_query[$counter] < 0)

			else
{
$update_query[$counter] = $changes[$counter];
}
// Less than 0? That's bad
if($update_query[$counter] < 0)

			{

			{

				$update_query[$counter] = 0;
}
}

				$update_query[$counter] = 0;
}
}

Zeile 1781Zeile 1797
			else
{
$new_stats['numthreads'] = "{$threads_diff}";

			else
{
$new_stats['numthreads'] = "{$threads_diff}";

			}
}

			}
}

		
if(array_key_exists('unapprovedthreads', $update_query))
{

		
if(array_key_exists('unapprovedthreads', $update_query))
{

Zeile 1790Zeile 1806
			if($unapprovedthreads_diff > -1)
{
$new_stats['numunapprovedthreads'] = "+{$unapprovedthreads_diff}";

			if($unapprovedthreads_diff > -1)
{
$new_stats['numunapprovedthreads'] = "+{$unapprovedthreads_diff}";

			}
else

			}
else

			{
$new_stats['numunapprovedthreads'] = "{$unapprovedthreads_diff}";
}

			{
$new_stats['numunapprovedthreads'] = "{$unapprovedthreads_diff}";
}

Zeile 1816Zeile 1832
			if($unapprovedposts_diff > -1)
{
$new_stats['numunapprovedposts'] = "+{$unapprovedposts_diff}";

			if($unapprovedposts_diff > -1)
{
$new_stats['numunapprovedposts'] = "+{$unapprovedposts_diff}";

			}
else
{

			}
else
{

				$new_stats['numunapprovedposts'] = "{$unapprovedposts_diff}";
}
}

				$new_stats['numunapprovedposts'] = "{$unapprovedposts_diff}";
}
}

Zeile 1827Zeile 1843

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


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

 
	
$cache->update_forums();

}

/**

}

/**

Zeile 1897Zeile 1915
			}
}
}

			}
}
}

 
	
$db->free_result($query);


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


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

 
	
unset($update_query, $thread);


update_thread_data($tid);
}


update_thread_data($tid);
}

Zeile 1922Zeile 1944
		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"

	);

	);

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

	$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 1934Zeile 1958
		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 1958Zeile 1984
	$update_array = array(
'username' => $firstpost['username'],
'uid' => intval($firstpost['uid']),

	$update_array = array(
'username' => $firstpost['username'],
'uid' => intval($firstpost['uid']),

 
		'dateline' => intval($firstpost['dateline']),

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

		'lastpost' => intval($lastpost['dateline']),
'lastposter' => $lastpost['username'],
'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)

{

{

	die("Deprecated function call: update_forum_count");

	die("Deprecated function call: update_forum_count");

}

}

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

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

{

{

	die("Deprecated function call: update_thread_attachment_count");
}


	die("Deprecated function call: update_thread_attachment_count");
}


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

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

{
global $moderation;

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


{
global $moderation;

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


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


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


Zeile 2009Zeile 2038
	{
require_once MYBB_ROOT."inc/class_moderation.php";
$moderation = new Moderation;

	{
require_once MYBB_ROOT."inc/class_moderation.php";
$moderation = new Moderation;

	}


	}


	return $moderation->delete_post($pid);
}


	return $moderation->delete_post($pid);
}


Zeile 2022Zeile 2051
 * @param int If we need to add select boxes to this cal or not
* @param int The current depth of forums we're at
* @param int Whether or not to show extra items such as User CP, Forum home

 * @param int If we need to add select boxes to this cal or not
* @param int The current depth of forums we're at
* @param int Whether or not to show extra items such as User CP, Forum home

 
 * @param boolean Ignore the showinjump setting and show all forums (for moderation pages)

 * @param array Array of permissions
* @param string The name of the forum jump
* @return string Forum jump items
*/

 * @param array Array of permissions
* @param string The name of the forum jump
* @return string Forum jump items
*/

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

function build_forum_jump($pid="0", $selitem="", $addselect="1", $depth="", $showextras="1", $showall=false, $permissions="", $name="fid")

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


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


	$pid = intval($pid);


	$pid = intval($pid);


	if($permissions)
{
$permissions = $mybb->usergroup;
}

if(!is_array($jumpfcache))

	if($permissions)
{
$permissions = $mybb->usergroup;
}

if(!is_array($jumpfcache))

	{

	{

		if(!is_array($forum_cache))
{
cache_forums();

		if(!is_array($forum_cache))
{
cache_forums();

Zeile 2054Zeile 2084
	}

if(!is_array($permissioncache))

	}

if(!is_array($permissioncache))

	{
$permissioncache = forum_permissions();

	{
$permissioncache = forum_permissions();

	}

if(is_array($jumpfcache[$pid]))

	}

if(is_array($jumpfcache[$pid]))

Zeile 2066Zeile 2096
			{
$perms = $permissioncache[$forum['fid']];


			{
$perms = $permissioncache[$forum['fid']];


				if($forum['fid'] != "0" && ($perms['canview'] != 0 || $mybb->settings['hideprivateforums'] == 0) && $forum['linkto'] == '' && $forum['showinjump'] != 0)

				if($forum['fid'] != "0" && ($perms['canview'] != 0 || $mybb->settings['hideprivateforums'] == 0) && $forum['linkto'] == '' && ($forum['showinjump'] != 0 || $showall == true))

				{
$optionselected = "";


				{
$optionselected = "";


Zeile 2074Zeile 2104
					{
$optionselected = "selected=\"selected\"";
$selecteddone = 1;

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

					}

					}

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


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


Zeile 2083Zeile 2113
					if($forum_cache[$forum['fid']])
{
$newdepth = $depth."--";

					if($forum_cache[$forum['fid']])
{
$newdepth = $depth."--";

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

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

					}
}
}

					}
}
}

Zeile 2093Zeile 2123
	if($addselect)
{
if(!$selecteddone)

	if($addselect)
{
if(!$selecteddone)

		{

		{

			if(!$selitem)
{
$selitem = "default";

			if(!$selitem)
{
$selitem = "default";

Zeile 2112Zeile 2142
		}

eval("\$forumjump = \"".$templates->get("forumjump_".$template)."\";");

		}

eval("\$forumjump = \"".$templates->get("forumjump_".$template)."\";");

	}


	}


	return $forumjump;
}


	return $forumjump;
}


Zeile 2258Zeile 2288
		else
{
eval("\$codeinsert = \"".$templates->get("codebuttons")."\";");

		else
{
eval("\$codeinsert = \"".$templates->get("codebuttons")."\";");

		}
}

		}
}


return $codeinsert;
}


return $codeinsert;
}

Zeile 2866Zeile 2896
				}

$navsize = count($navbits);

				}

$navsize = count($navbits);

				$navbits[$navsize]['name'] = $forumnav['name'];


				// Convert & to &amp;
$navbits[$navsize]['name'] = preg_replace("#&(?!\#[0-9]+;)#si", "&amp;", $forumnav['name']);


if(IN_ARCHIVE == 1)
{


if(IN_ARCHIVE == 1)
{

Zeile 2938Zeile 2969
			$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 3310Zeile 3341
 */
function join_usergroup($uid, $joingroup)
{

 */
function join_usergroup($uid, $joingroup)
{

	global $db;

	global $db, $mybb;


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


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

Zeile 3333Zeile 3364
		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->update_query("users", array('additionalgroups' => $groupslist), "uid='".intval($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 3355Zeile 3395
	global $db, $mybb, $cache;

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

	global $db, $mybb, $cache;

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

	{

	{

		$user = $mybb->user;
}
else

		$user = $mybb->user;
}
else

Zeile 3363Zeile 3403
		$query = $db->simple_select("users", "*", "uid='".intval($uid)."'");
$user = $db->fetch_array($query);
}

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





$groupslist = "";

	$usergroups = "";

	$usergroups = "";

	$groupslist = "";

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

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





	$groups = explode(",", $user['additionalgroups']);

	$groups = explode(",", $user['additionalgroups']);


if(is_array($groups))


if(is_array($groups))

	{
foreach($groups as $gid)
{

	{
foreach($groups as $gid)
{

Zeile 3382Zeile 3422
			}
}
}

			}
}
}



	

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

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

	{

	{

		$dispupdate = ", displaygroup=usergroup";
}


		$dispupdate = ", displaygroup=usergroup";
}


Zeile 3415Zeile 3455
	if(!empty($_SERVER['PATH_INFO']))
{
$location = htmlspecialchars_uni($_SERVER['PATH_INFO']);

	if(!empty($_SERVER['PATH_INFO']))
{
$location = htmlspecialchars_uni($_SERVER['PATH_INFO']);

	}

	}

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

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

	{

	{

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

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

	}

	}

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

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

	{

	{

		$location = htmlspecialchars_uni($_ENV['PHP_SELF']);

		$location = htmlspecialchars_uni($_ENV['PHP_SELF']);

	}

	}

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

if($fields == true)

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

if($fields == true)

	{

	{

		global $mybb;

		global $mybb;

		

		

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

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

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

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

		

		

		if(!empty($mybb->input))
{
foreach($mybb->input as $name => $value)

		if(!empty($mybb->input))
{
foreach($mybb->input as $name => $value)

Zeile 3476Zeile 3516
				if(isset($_POST[$var]))
{
$addloc[] = urlencode($var).'='.urlencode($_POST[$var]);

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

				}

				}

			}

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

			}

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

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









				if(strpos($location, "?") === false)
{
$location .= "?";
}
else
{
$location .= "&amp;";
}
$location .= implode("&amp;", $addloc);

			}
}


			}
}


Zeile 3504Zeile 3552
	global $db, $themeselect, $tcache, $lang, $mybb, $limit;

if($tid == 0)

	global $db, $themeselect, $tcache, $lang, $mybb, $limit;

if($tid == 0)

	{

	{

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

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

Zeile 3514Zeile 3562
	if(!is_array($tcache))
{
$query = $db->simple_select("themes", "name, pid, tid, allowedgroups", "pid != '0'", array('order_by' => 'pid, name'));

	if(!is_array($tcache))
{
$query = $db->simple_select("themes", "name, pid, tid, allowedgroups", "pid != '0'", array('order_by' => 'pid, name'));





		while($theme = $db->fetch_array($query))
{
$tcache[$theme['pid']][$theme['tid']] = $theme;

		while($theme = $db->fetch_array($query))
{
$tcache[$theme['pid']][$theme['tid']] = $theme;

Zeile 3577Zeile 3625
	}

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 3596Zeile 3644

/**
* Custom function for formatting numbers.


/**
* Custom function for formatting numbers.

 *

 *

 * @param int The number to format.
* @return int The formatted number.
*/

 * @param int The number to format.
* @return int The formatted number.
*/

Zeile 3605Zeile 3653
	global $mybb;

if($number == "-")

	global $mybb;

if($number == "-")

	{

	{

		return $number;

		return $number;

	}

	}


if(is_int($number))


if(is_int($number))

	{

	{

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

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

	}
else
{

	}
else
{

		$parts = explode('.', $number);

if(isset($parts[1]))

		$parts = explode('.', $number);

if(isset($parts[1]))

Zeile 3626Zeile 3674
			$decimals = 0;
}


			$decimals = 0;
}


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


































































		return number_format((double)$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 3642Zeile 3755

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


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

		if($mybb->config['db_encoding'] == "utf8" && !preg_match("#[\x80-\xFF]#", $message))



		$message = convert_through_utf8($message);

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

		{

		{

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

}


}


/**
* Workaround for date limitation in PHP to establish the day of a birthday (Provided by meme)
*

/**
* Workaround for date limitation in PHP to establish the day of a birthday (Provided by meme)
*

Zeile 3761Zeile 3876
	$find = array(
'm',
'd',

	$find = array(
'm',
'd',

 
		'D',

		'y',
'Y',
'j',
'S',
'l',
'F',

		'y',
'Y',
'j',
'S',
'l',
'F',

 
		'M',

	);

$replace = array(
sprintf('%02s', $bm),
sprintf('%02s', $bd),

	);

$replace = array(
sprintf('%02s', $bm),
sprintf('%02s', $bd),

 
		($wd == 2 ? my_substr($bdays[$wd], 0, 4) : ($wd == 4 ? my_substr($bdays[$wd], 0, 5) : my_substr($bdays[$wd], 0, 3))),

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

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

		$bdays[$wd],

		$wd,

		$bmonth[$bm-1],

		$bmonth[$bm-1],

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

	);

	);

 
	
// Do we have the full month in our output?
// If so there's no need for the short month
if(strpos($display, 'F') !== false)
{
array_pop($find);
array_pop($replace);
}

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

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

Zeile 3947Zeile 4074
	if($needle == '')
{
return false;

	if($needle == '')
{
return false;

	}


	}


	if(function_exists("mb_strpos"))

	if(function_exists("mb_strpos"))

	{

	{

		$position = mb_strpos($haystack, $needle, $offset);

		$position = mb_strpos($haystack, $needle, $offset);

	}

	}

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

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

	}


	}


	return $position;
}


	return $position;
}


Zeile 3966Zeile 4093
 *
* @param string The string to up.
* @return int The uped string.

 *
* @param string The string to up.
* @return int The uped string.

 */

 */

function my_strtoupper($string)
{
if(function_exists("mb_strtoupper"))

function my_strtoupper($string)
{
if(function_exists("mb_strtoupper"))

Zeile 3988Zeile 4115
 * @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 literal entities
$trans_tbl = get_html_translation_table(HTML_ENTITIES);
$trans_tbl = array_flip($trans_tbl);

return strtr($string, $trans_tbl);
}

/**


































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

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

/**

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

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

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

return $event_date;

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

return $event_date;

}


}


/**
* Get the profile link.
*

/**
* Get the profile link.
*

Zeile 4035Zeile 4195
 * @return string The url to the profile.
*/
function get_profile_link($uid=0)

 * @return string The url to the profile.
*/
function get_profile_link($uid=0)

{

{

	$link = str_replace("{uid}", $uid, PROFILE_URL);
return htmlspecialchars_uni($link);
}

/**
* Get the announcement link.

	$link = str_replace("{uid}", $uid, PROFILE_URL);
return htmlspecialchars_uni($link);
}

/**
* Get the announcement link.

 *

 *

 * @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.
*/

Zeile 4064Zeile 4224
function build_profile_link($username="", $uid=0, $target="", $onclick="")
{
global $lang;

function build_profile_link($username="", $uid=0, $target="", $onclick="")
{
global $lang;





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

	if(!$username && $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 4086Zeile 4246
		if(!empty($onclick))
{
$onclick = " onclick=\"{$onclick}\"";

		if(!empty($onclick))
{
$onclick = " onclick=\"{$onclick}\"";

		}

		}


// 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 4256Zeile 4409
 */
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 4393Zeile 4550
		else
{
$post_cache[$pid] = false;

		else
{
$post_cache[$pid] = false;

			return false;
}
}
}

			return false;
}
}
}


/**
* Get inactivate forums.


/**
* Get inactivate forums.

Zeile 4404Zeile 4561
 * @return string The comma separated values of the inactivate forum.
*/
function get_inactive_forums()

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

{

{

	global $forum_cache, $cache, $inactiveforums;

	global $forum_cache, $cache, $inactiveforums;





	if(!$forum_cache)
{
cache_forums();

	if(!$forum_cache)
{
cache_forums();

	}

$inactive = array();

	}

$inactive = array();


foreach($forum_cache as $fid => $forum)
{


foreach($forum_cache as $fid => $forum)
{

Zeile 4427Zeile 4584
				}
}
}

				}
}
}

	}

	}

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

return $inactiveforums;

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

return $inactiveforums;

Zeile 4457Zeile 4614
	$cookietime = $mybb->cookies['failedlogin'];

if(empty($cookielogins) || $cookielogins < $session->logins)

	$cookietime = $mybb->cookies['failedlogin'];

if(empty($cookielogins) || $cookielogins < $session->logins)

	{

	{

		$loginattempts = $session->logins;
}
else

		$loginattempts = $session->logins;
}
else

Zeile 4480Zeile 4637
		// If so, then we need to work out if they can try to login again
// Some maths to work out how long they have left and display it to them
$now = TIME_NOW;

		// If so, then we need to work out if they can try to login again
// Some maths to work out how long they have left and display it to them
$now = TIME_NOW;





		if(empty($mybb->cookies['failedlogin']))
{
$failedtime = $now;

		if(empty($mybb->cookies['failedlogin']))
{
$failedtime = $now;

Zeile 4509Zeile 4666
		}

// 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 4548Zeile 4705
		return false;
}
// Valid local characters for email addresses: http://www.remote.org/jochen/mail/info/chars.html

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

	return preg_match("/^[a-zA-Z0-9&*+\-_.{}~^\?=\/]+@[a-zA-Z0-9-]+\.([a-zA-Z0-9-]+\.)*[a-zA-Z0-9-]{2,}$/si", $email);

}

/**

}

/**

Zeile 4631Zeile 4788
 */
function build_highlight_array($terms)
{

 */
function build_highlight_array($terms)
{

 
	global $mybb;

if($mybb->settings['minsearchword'] < 1)
{
$mybb->settings['minsearchword'] = 3;
}


	// 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 4647Zeile 4811
		$inquote = false;
$terms = explode("\"", $terms);
foreach($terms as $phrase)

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

		{

		{

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

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

					$words[] = "\"".trim($phrase)."\"";

					$words[] = trim($phrase);

				}
else
{

				}
else
{

Zeile 4664Zeile 4828
					}
foreach($split_words as $word)
{

					}
foreach($split_words as $word)
{

						if(!$word)

						if(!$word || strlen($word) < $mybb->settings['minsearchword'])

						{
continue;
}

						{
continue;
}

Zeile 4673Zeile 4837
				}
}
$inquote = !$inquote;

				}
}
$inquote = !$inquote;

		}

		}

	}
// Otherwise just a simple search query with no phrases
else

	}
// Otherwise just a simple search query with no phrases
else

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

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

		{

		{

			continue;
}
foreach($split_words as $word)
{

			continue;
}
foreach($split_words as $word)
{

			if(!$word)

			if(!$word || strlen($word) < $mybb->settings['minsearchword'])

			{
continue;
}

			{
continue;
}

Zeile 4699Zeile 4863
	{
return false;
}

	{
return false;
}

 
	
// Sort the word array by length. Largest terms go first and work their way down to the smallest term.
// This resolves problems like "test tes" where "tes" will be highlighted first, then "test" can't be highlighted because of the changed html
usort($words, create_function('$a,$b','return strlen($b) - strlen($a);'));


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

Zeile 4714Zeile 4882
		}

// Now make PREG compatible

		}

// Now make PREG compatible

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

		$find = "#(?!<.*?)(".preg_quote($word, "#").")(?![^<>]*?>)#i";
$replacement = "<span class=\"highlight\" style=\"padding-left: 0px; padding-right: 0px;\">$1</span>";

		$highlight_cache[$find] = $replacement;
}


		$highlight_cache[$find] = $replacement;
}


Zeile 4954Zeile 5122
 * @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 4963Zeile 5141
		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 4983Zeile 5166
			$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 4992Zeile 5175
		{
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 5006Zeile 5208
		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 5069Zeile 5275
		$quoted_strings = array($string);
}
foreach($quoted_strings as $string)

		$quoted_strings = array($string);
}
foreach($quoted_strings as $string)

	{

	{

		if($string != "") 
{
if($in_escape)

		if($string != "") 
{
if($in_escape)

Zeile 5087Zeile 5293
			}
}
$in_escape = !$in_escape;

			}
}
$in_escape = !$in_escape;

	}

	}

	if(!count($strings))
{
return $original;

	if(!count($strings))
{
return $original;

	}

	}

	return $strings;
}


	return $strings;
}


Zeile 5104Zeile 5310
function fetch_longipv4_range($ip)
{
$ip_bits = explode(".", $ip);

function fetch_longipv4_range($ip)
{
$ip_bits = explode(".", $ip);

 
	$ip_string1 = $ip_string2 = "";





	if($ip == "*") return array(ip2long(0), ip2long(255));




	if($ip == "*")
{
return array(ip2long('0.0.0.0'), ip2long('255.255.255.255'));
}


if(strpos($ip, ".*") === false)
{


if(strpos($ip, ".*") === false)
{

Zeile 5122Zeile 5332
	// Wildcard based IP provided
else
{

	// Wildcard based IP provided
else
{

 
		$sep = "";

		foreach($ip_bits as $piece)
{
if($piece == "*")
{

		foreach($ip_bits as $piece)
{
if($piece == "*")
{

				return array(ip2long($ip_string."0"), ip2long($ip_string."255"));


				$ip_string1 .= $sep."0";
$ip_string2 .= $sep."255";

			}
else
{

			}
else
{

				$ip_string .= $piece.".";


				$ip_string1 .= $sep.$piece;
$ip_string2 .= $sep.$piece;

			}

			}

 
			$sep = ".";

		}

		}

 
		return array(ip2long($ip_string1), ip2long($ip_string2));

	}
}


	}
}


Zeile 5201Zeile 5416
function expire_warnings()
{
global $db;

function expire_warnings()
{
global $db;

 
	
$users = array();


	$query = $db->query("
SELECT w.wid, w.uid, w.points, u.warningpoints
FROM ".TABLE_PREFIX."warnings w

	$query = $db->query("
SELECT w.wid, w.uid, w.points, u.warningpoints
FROM ".TABLE_PREFIX."warnings w

Zeile 5213Zeile 5431
			"expired" => 1
);
$db->update_query("warnings", $updated_warning, "wid='{$warning['wid']}'");

			"expired" => 1
);
$db->update_query("warnings", $updated_warning, "wid='{$warning['wid']}'");

		$warning['warningpoints'] -= $warning['points'];
if($warning['warningpoints'] < 0)













		
if(array_key_exists($warning['uid'], $users))
{
$users[$warning['uid']] -= $warning['points'];
}
else
{
$users[$warning['uid']] = $warning['warningpoints']-$warning['points'];
}
}

foreach($users as $uid => $warningpoints)
{
if($warningpoints < 0)

		{

		{

			$warning['warningpoints'] = 0;

			$warningpoints = 0;

		}

		}

 
		

		$updated_user = array(

		$updated_user = array(

			"warningpoints" => intval($warning['warningpoints'])

			"warningpoints" => intval($warningpoints)

		);

		);

		$db->update_query("users", $updated_user, "uid='{$warning['uid']}'");

		$db->update_query("users", $updated_user, "uid='".intval($uid)."'");

	}
}


	}
}