Vergleich inc/functions.php - 1.4.3 - 1.4.7

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

 * $Id: functions.php 4350 2009-04-14 23:14:07Z Tikitiki $

 */

/**

 */

/**

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 625Zeile 635

/**
* Produce a friendly error message page


/**
* Produce a friendly error message page

 *

 *

 * @param string The error message to be shown
* @param string The title of the message shown in the title of the page and the error table
*/

 * @param string The error message to be shown
* @param string The title of the message shown in the title of the page and the error table
*/

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 682Zeile 692
	if(!is_array($errors))
{
$errors = array($errors);

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

	}

	}


// AJAX error message?
if($mybb->input['ajax'])


// AJAX error message?
if($mybb->input['ajax'])

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

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

		exit;
}

		exit;
}


foreach($errors as $error)
{


foreach($errors as $error)
{

Zeile 743Zeile 753

error($errorpage);
}


error($errorpage);
}





/**
* Redirect the user to a given URL with a given message
*

/**
* Redirect the user to a given URL with a given message
*

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

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

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

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

Zeile 767Zeile 777
		{
echo 'alert("'.addslashes($message).'");';
}

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

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

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

		$url = htmlspecialchars_decode($url);
$url = str_replace(array("\n","\r",";"), "", $url);
echo 'window.location = "'.addslashes($url).'";'."\n";

		$url = htmlspecialchars_decode($url);
$url = str_replace(array("\n","\r",";"), "", $url);
echo 'window.location = "'.addslashes($url).'";'."\n";

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


Zeile 809Zeile 818

exit;
}


exit;
}





/**
* Generate a listing of page - pagination
*

/**
* Generate a listing of page - pagination
*

Zeile 826Zeile 835
	if($count <= $perpage)
{
return;

	if($count <= $perpage)
{
return;

	}

	}

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

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

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

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

		{

		{

			$from = 1;
}
}

			$from = 1;
}
}

Zeile 868Zeile 877
	if($to == 0)
{
$to = $pages;

	if($to == 0)
{
$to = $pages;

	}

	}


if($from > 1)
{


if($from > 1)
{

Zeile 877Zeile 886
	}

for($i = $from; $i <= $to; ++$i)

	}

for($i = $from; $i <= $to; ++$i)

	{

	{

		$page_url = fetch_page_url($url, $i);
if($page == $i)
{

		$page_url = fetch_page_url($url, $i);
if($page == $i)
{

Zeile 893Zeile 902
	{
$page_url = fetch_page_url($url, $pages);
eval("\$end = \"".$templates->get("multipage_end")."\";");

	{
$page_url = fetch_page_url($url, $pages);
eval("\$end = \"".$templates->get("multipage_end")."\";");

	}

	}


if($page < $pages)
{


if($page < $pages)
{

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))
{
$groupscache = $cache->read("usergroups");

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

	}


	}


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

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



 

if(count($groups) == 1)
{


if(count($groups) == 1)
{

Zeile 1010Zeile 1018
		{
continue;
}

		{
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 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 1592Zeile 1598
	$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 1624
			$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 1897Zeile 1906
			}
}
}

			}
}
}

 
	
$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 1924Zeile 1937
		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 1934Zeile 1949
		LIMIT 1
");
$firstpost = $db->fetch_array($query);

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

 
	
$db->free_result($query);


if(!$firstpost['username'])
{


if(!$firstpost['username'])
{

Zeile 1941Zeile 1958
	}

if(!$lastpost['username'])

	}

if(!$lastpost['username'])

	{

	{

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


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


Zeile 1951Zeile 1968
		$lastpost['uid'] = $firstpost['uid'];
$lastpost['dateline'] = $firstpost['dateline'];
}

		$lastpost['uid'] = $firstpost['uid'];
$lastpost['dateline'] = $firstpost['dateline'];
}





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


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


Zeile 1963Zeile 1980
		'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 1972Zeile 1991
function update_thread_count($tid)
{
die("Deprecated function call: update_thread_count");

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

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

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

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

{
global $moderation;


{
global $moderation;


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

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

Zeile 2022Zeile 2041
 * @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;


Zeile 2066Zeile 2086
			{
$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 2083Zeile 2103
					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 2124Zeile 2144
 * @return string The extension of the file.
*/
function get_extension($file)

 * @return string The extension of the file.
*/
function get_extension($file)

{

{

	return my_strtolower(my_substr(strrchr($file, "."), 1));
}


	return my_strtolower(my_substr(strrchr($file, "."), 1));
}


Zeile 2140Zeile 2160
	$str = '';

for($i = 1; $i <= $length; ++$i)

	$str = '';

for($i = 1; $i <= $length; ++$i)

	{

	{

		$ch = mt_rand(0, count($set)-1);
$str .= $set[$ch];
}

		$ch = mt_rand(0, count($set)-1);
$str .= $set[$ch];
}

Zeile 2168Zeile 2188
	if($displaygroup != 0)
{
$usergroup = $displaygroup;

	if($displaygroup != 0)
{
$usergroup = $displaygroup;

	}


	}


	$ugroup = $groupscache[$usergroup];
$format = $ugroup['namestyle'];
$userin = substr_count($format, "{username}");

	$ugroup = $groupscache[$usergroup];
$format = $ugroup['namestyle'];
$userin = substr_count($format, "{username}");

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

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

		}
}

		}
}


return $codeinsert;
}


return $codeinsert;
}

Zeile 2404Zeile 2424
				$gzdata .= pack("V", $crc);
$gzdata .= pack("V", $size);
$contents = $gzdata;

				$gzdata .= pack("V", $crc);
$gzdata .= pack("V", $size);
$contents = $gzdata;

			}
}
}

			}
}
}


return $contents;
}


return $contents;
}

Zeile 2430Zeile 2450
	{
$fid = $data['fid'];
unset($data['fid']);

	{
$fid = $data['fid'];
unset($data['fid']);

	}

	}


if($data['tid'] == '')
{


if($data['tid'] == '')
{

Zeile 2446Zeile 2466
	if(is_array($data))
{
$data = serialize($data);

	if(is_array($data))
{
$data = serialize($data);

	}

$time = TIME_NOW;

	}

$time = TIME_NOW;


$sql_array = array(
"uid" => $mybb->user['uid'],


$sql_array = array(
"uid" => $mybb->user['uid'],

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

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

	}

$display_reputation .= "<strong class=\"";


	}

$display_reputation .= "<strong class=\"";


	if($reputation < 0)

	if($reputation < 0)

	{

	{

		$display_reputation .= "reputation_negative";
}
elseif($reputation > 0)
{
$display_reputation .= "reputation_positive";

		$display_reputation .= "reputation_negative";
}
elseif($reputation > 0)
{
$display_reputation .= "reputation_positive";

	}
else
{

	}
else
{

		$display_reputation .= "reputation_neutral";
}

		$display_reputation .= "reputation_neutral";
}





	$display_reputation .= "\">{$reputation}</strong>";

if($uid != 0)
{
$display_reputation .= "</a>";

	$display_reputation .= "\">{$reputation}</strong>";

if($uid != 0)
{
$display_reputation .= "</a>";

	}

	}


return $display_reputation;
}


return $display_reputation;
}

Zeile 2516Zeile 2536
		return "<span class=\"high_warning\">{$level}%</span>";
}
else if($level >= 50)

		return "<span class=\"high_warning\">{$level}%</span>";
}
else if($level >= 50)

	{

	{

		return "<span class=\"moderate_warning\">{$level}%</span>";
}
else if($level >= 25)

		return "<span class=\"moderate_warning\">{$level}%</span>";
}
else if($level >= 25)

Zeile 2550Zeile 2570
				{
$ip = $val;
break;

				{
$ip = $val;
break;

				}
}
}

				}
}
}

	}

if(!isset($ip))

	}

if(!isset($ip))

Zeile 2580Zeile 2600
function get_friendly_size($size)
{
global $lang;

function get_friendly_size($size)
{
global $lang;

	

	

	if(!is_numeric($size))
{
return $lang->na;

	if(!is_numeric($size))
{
return $lang->na;

Zeile 2598Zeile 2618
	}
// Exabyte (1024 Petabytes)
elseif($size >= 1152921504606846976)

	}
// Exabyte (1024 Petabytes)
elseif($size >= 1152921504606846976)

	{

	{

		$size = my_number_format(round(($size / 1152921504606846976), 2))." ".$lang->size_eb;
}
// Petabyte (1024 Terabytes)

		$size = my_number_format(round(($size / 1152921504606846976), 2))." ".$lang->size_eb;
}
// Petabyte (1024 Terabytes)

Zeile 2625Zeile 2645
	elseif($size >= 1024)
{
$size = my_number_format(round(($size / 1024), 2))." ".$lang->size_kb;

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

	}

	}

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

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

Zeile 2769Zeile 2789
	$format = str_replace("y", my_substr($year, -2), $format);

return $format;

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

return $format;

}

/**

}

/**

 * Build the breadcrumb navigation trail from the specified items
*
* @return The formatted breadcrumb navigation trail

 * Build the breadcrumb navigation trail from the specified items
*
* @return The formatted breadcrumb navigation trail

Zeile 2781Zeile 2801
	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 2790Zeile 2810
			if(isset($navbits[$key+1]))
{
if(isset($navbits[$key+2]))

			if(isset($navbits[$key+1]))
{
if(isset($navbits[$key+2]))

				{

				{

					$sep = $navsep;
}
else

					$sep = $navsep;
}
else

Zeile 2815Zeile 2835
	eval("\$donenav = \"".$templates->get("nav")."\";");

return $donenav;

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

return $donenav;

}

/**

}

/**

 * Add a breadcrumb menu item to the list.
*
* @param string The name of the item to add

 * Add a breadcrumb menu item to the list.
*
* @param string The name of the item to add

Zeile 2826Zeile 2846
function add_breadcrumb($name, $url="")
{
global $navbits;

function add_breadcrumb($name, $url="")
{
global $navbits;





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

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

Zeile 2844Zeile 2864
	if(!$pforumcache)
{
if(!is_array($forum_cache))

	if(!$pforumcache)
{
if(!is_array($forum_cache))

		{

		{

			cache_forums();
}


			cache_forums();
}


Zeile 2863Zeile 2883
				if($pforumcache[$forumnav['pid']])
{
build_forum_breadcrumb($forumnav['pid'], $archive);

				if($pforumcache[$forumnav['pid']])
{
build_forum_breadcrumb($forumnav['pid'], $archive);

				}

				}


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


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

Zeile 2872Zeile 2892
				{
// Set up link to forum in breadcrumb.
if($pforumcache[$fid][$forumnav['pid']]['type'] == 'f' || $pforumcache[$fid][$forumnav['pid']]['type'] == 'c')

				{
// Set up link to forum in breadcrumb.
if($pforumcache[$fid][$forumnav['pid']]['type'] == 'f' || $pforumcache[$fid][$forumnav['pid']]['type'] == 'c')

					{

					{

						$navbits[$navsize]['url'] = "{$base_url}forum-".$forumnav['fid'].".html";
}
else

						$navbits[$navsize]['url'] = "{$base_url}forum-".$forumnav['fid'].".html";
}
else

Zeile 2889Zeile 2909
	}

return 1;

	}

return 1;

}

/**

}

/**

 * Resets the breadcrumb navigation to the first item, and clears the rest
*/
function reset_breadcrumb()

 * Resets the breadcrumb navigation to the first item, and clears the rest
*/
function reset_breadcrumb()

Zeile 2900Zeile 2920

$newnav[0]['name'] = $navbits[0]['name'];
$newnav[0]['url'] = $navbits[0]['url'];


$newnav[0]['name'] = $navbits[0]['name'];
$newnav[0]['url'] = $navbits[0]['url'];





	unset($GLOBALS['navbits']);
$GLOBALS['navbits'] = $newnav;
}

	unset($GLOBALS['navbits']);
$GLOBALS['navbits'] = $newnav;
}

Zeile 2918Zeile 2938
	
// If the server OS is not Windows and not Apache or the PHP is running as a CGI or we have defined ARCHIVE_QUERY_STRINGS, use query strings - DIRECTORY_SEPARATOR checks if running windows
if((DIRECTORY_SEPARATOR == '\\' && is_numeric(stripos($_SERVER['SERVER_SOFTWARE'], "apache")) == false) || is_numeric(stripos(SAPI_NAME, "cgi")) !== false || defined("ARCHIVE_QUERY_STRINGS"))

	
// If the server OS is not Windows and not Apache or the PHP is running as a CGI or we have defined ARCHIVE_QUERY_STRINGS, use query strings - DIRECTORY_SEPARATOR checks if running windows
if((DIRECTORY_SEPARATOR == '\\' && is_numeric(stripos($_SERVER['SERVER_SOFTWARE'], "apache")) == false) || is_numeric(stripos(SAPI_NAME, "cgi")) !== false || defined("ARCHIVE_QUERY_STRINGS"))

	{

	{

		$base_url = $mybb->settings['bburl']."/archive/index.php?";
}
else

		$base_url = $mybb->settings['bburl']."/archive/index.php?";
}
else

Zeile 2938Zeile 2958
			$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 3212Zeile 3232
	if($months == 1)
{
$nicetime['months'] = "1".$lang_month;

	if($months == 1)
{
$nicetime['months'] = "1".$lang_month;

	}

	}

	else if($months > 1)
{
$nicetime['months'] = $months.$lang_months;

	else if($months > 1)
{
$nicetime['months'] = $months.$lang_months;

Zeile 3249Zeile 3269
	}

if($options['minutes'] !== false)

	}

if($options['minutes'] !== false)

	{

	{

		if($minutes == 1)

		if($minutes == 1)

		{

		{

			$nicetime['minutes'] = "1".$lang_minute;

			$nicetime['minutes'] = "1".$lang_minute;

		}

		}

		else if($minutes > 1)
{
$nicetime['minutes'] = $minutes.$lang_minutes;

		else if($minutes > 1)
{
$nicetime['minutes'] = $minutes.$lang_minutes;

		}
}

		}
}


if($options['seconds'] !== false)
{


if($options['seconds'] !== false)
{

Zeile 3285Zeile 3305
 * @return string trow1 or trow2 depending on the previous call
*/
function alt_trow($reset=0)

 * @return string trow1 or trow2 depending on the previous call
*/
function alt_trow($reset=0)

{

{

	global $alttrow;

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

	global $alttrow;

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

	{

	{

		$trow = "trow2";
}
else
{
$trow = "trow1";

		$trow = "trow2";
}
else
{
$trow = "trow1";

	}

	}


$alttrow = $trow;


$alttrow = $trow;





	return $trow;
}

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

	return $trow;
}

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

 *

 *

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

 * @param int The user ID
* @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

Zeile 3341Zeile 3361
		}
}


		}
}


	$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 3357Zeile 3386
	if($uid == $mybb->user['uid'])
{
$user = $mybb->user;

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

	}
else
{

	}
else
{

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


$usergroups = "";




	$groupslist = "";

	$groupslist = "";

 
	$usergroups = "";

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

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

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

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





	if(is_array($groups))
{
foreach($groups as $gid)

	if(is_array($groups))
{
foreach($groups as $gid)

Zeile 3382Zeile 3411
			}
}
}

			}
}
}



	

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

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

	}

	}


$db->write_query("
UPDATE ".TABLE_PREFIX."users


$db->write_query("
UPDATE ".TABLE_PREFIX."users

Zeile 3423Zeile 3452
	elseif(!empty($_ENV['PHP_SELF']))
{
$location = htmlspecialchars_uni($_ENV['PHP_SELF']);

	elseif(!empty($_ENV['PHP_SELF']))
{
$location = htmlspecialchars_uni($_ENV['PHP_SELF']);

	}

	}

	else

	else

	{

	{

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

if($fields == true)
{
global $mybb;

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

if($fields == true)
{
global $mybb;

		

		

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

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

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

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

			{

			{

				if(in_array($name, $ignore))
{
continue;

				if(in_array($name, $ignore))
{
continue;

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

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

				{

				{

					$addloc[] = urlencode($var).'='.urlencode($_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 3627Zeile 3664
		}

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 3642Zeile 3744

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)

 *
* @param int The month of the birthday
* @param int The day of the birthday

 *
* @param int The month of the birthday
* @param int The day of the birthday

Zeile 3761Zeile 3865
	$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 3798Zeile 3914
	}

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

	}

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





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

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

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

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

	}

	}

	return $age;
}


	return $age;
}


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

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

{

{

	global $db;

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

	global $db;

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

Zeile 3832Zeile 3948
		"firstpost" => $post['pid']
);
$db->update_query("threads", $firstpostup, "tid='$tid'");

		"firstpost" => $post['pid']
);
$db->update_query("threads", $firstpostup, "tid='$tid'");

}

}


/**
* Checks for the length of a string, mb strings accounted for


/**
* Checks for the length of a string, mb strings accounted for

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

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

		}

		}

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

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

		}
}
else
{

		}
}
else
{

		if($length != "")

		if($length != "")

		{

		{

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

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

		}

		}

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

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

	}


	}


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

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

}

/**

}

/**

 * lowers the case of a string, mb strings accounted for
*
* @param string The string to lower.

 * lowers the case of a string, mb strings accounted for
*
* @param string The string to lower.

Zeile 3923Zeile 4039
function my_strtolower($string)
{
if(function_exists("mb_strtolower"))

function my_strtolower($string)
{
if(function_exists("mb_strtolower"))

	{

	{

		$string = mb_strtolower($string);
}
else

		$string = mb_strtolower($string);
}
else

Zeile 3950Zeile 4066
	}

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;

}


}


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

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

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




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





   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.

}

/**
* Get the event poster.

 *
* @param array The event data array.

 *
* @param array The event data array.

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

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

Zeile 4011Zeile 4160
	$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 4030Zeile 4179

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

/**

 * Get the announcement link.
*
* @param int The announement id of the announcement.

 * Get the announcement link.
*
* @param int The announement id of the announcement.

Zeile 4090Zeile 4239

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

		{

		{

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

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

		}

		}

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

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

		}
}
}


		}
}
}


/**
* Build the forum link.
*

/**
* Build the forum link.
*

Zeile 4129Zeile 4271
	else
{
$link = str_replace("{fid}", $fid, FORUM_URL);

	else
{
$link = str_replace("{fid}", $fid, FORUM_URL);

		return htmlspecialchars_uni($link);

		return htmlspecialchars_uni($link);

	}
}


	}
}


Zeile 4156Zeile 4298
		$link = str_replace("{tid}", $tid, $link);
$link = str_replace("{action}", $action, $link);
$link = str_replace("{page}", $page, $link);

		$link = str_replace("{tid}", $tid, $link);
$link = str_replace("{action}", $action, $link);
$link = str_replace("{page}", $page, $link);

		return htmlspecialchars_uni($link);

		return htmlspecialchars_uni($link);

	}
else
{

	}
else
{

Zeile 4183Zeile 4325
function get_post_link($pid, $tid=0)
{
if($tid > 0)

function get_post_link($pid, $tid=0)
{
if($tid > 0)

	{

	{

		$link = str_replace("{tid}", $tid, THREAD_URL_POST);
$link = str_replace("{pid}", $pid, $link);

		$link = str_replace("{tid}", $tid, THREAD_URL_POST);
$link = str_replace("{pid}", $pid, $link);

		return htmlspecialchars_uni($link);

		return htmlspecialchars_uni($link);

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

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

		return htmlspecialchars_uni($link);

		return htmlspecialchars_uni($link);

	}
}


	}
}


Zeile 4200Zeile 4342
 *
* @param int The event ID of the event
* @return string The URL of the event

 *
* @param int The event ID of the event
* @return string The URL of the event

 */

 */

function get_event_link($eid)
{
$link = str_replace("{eid}", $eid, EVENT_URL);

function get_event_link($eid)
{
$link = str_replace("{eid}", $eid, EVENT_URL);

Zeile 4209Zeile 4351

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

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

Zeile 4227Zeile 4369
		return htmlspecialchars_uni($link);
}
else if($month > 0)

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

	{

	{

		$link = str_replace("{month}", $month, CALENDAR_URL_MONTH);
$link = str_replace("{year}", $year, $link);
$link = str_replace("{calendar}", $calendar, $link);

		$link = str_replace("{month}", $month, CALENDAR_URL_MONTH);
$link = str_replace("{year}", $year, $link);
$link = str_replace("{calendar}", $calendar, $link);

Zeile 4255Zeile 4397
 * @return string The URL of the calendar
*/
function get_calendar_week_link($calendar, $week)

 * @return string The URL of the calendar
*/
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 4263Zeile 4409

/**
* Get the user data of a user id.


/**
* Get the user data of a user id.

 *

 *

 * @param int The user id of the user.
* @return array The users data
*/

 * @param int The user id of the user.
* @return array The users data
*/

Zeile 4279Zeile 4425
		return $mybb->user;
}
elseif(isset($user_cache[$uid]))

		return $mybb->user;
}
elseif(isset($user_cache[$uid]))

	{
return $user_cache[$uid];

	{
return $user_cache[$uid];

	}
else
{

	}
else
{

Zeile 4324Zeile 4470
				if($forum_cache[$parent]['active'] == 0)
{
return false;

				if($forum_cache[$parent]['active'] == 0)
{
return false;

				}
}
}

				}
}
}

	}

return $forum_cache[$fid];

	}

return $forum_cache[$fid];

Zeile 4472Zeile 4618
	else
{
$failedlogin = $cookietime;

	else
{
$failedlogin = $cookietime;

	}

	}


// Work out if the user has had more than the allowed number of login attempts
if($loginattempts > $mybb->settings['failedlogincount'])


// Work out if the user has had more than the allowed number of login attempts
if($loginattempts > $mybb->settings['failedlogincount'])

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

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

		}

		}

		else
{
$failedtime = $mybb->cookies['failedlogin'];

		else
{
$failedtime = $mybb->cookies['failedlogin'];

		}


		}


		$secondsleft = $mybb->settings['failedlogintime'] * 60 + $failedtime - $now;
$hoursleft = floor($secondsleft / 3600);
$minsleft = floor(($secondsleft / 60) % 60);

		$secondsleft = $mybb->settings['failedlogintime'] * 60 + $failedtime - $now;
$hoursleft = floor($secondsleft / 3600);
$minsleft = floor(($secondsleft / 60) % 60);

Zeile 4506Zeile 4652
			}

return false;

			}

return false;

		}

		}


// 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 4621Zeile 4767
	@fclose($file);

$GLOBALS['settings'] = &$mybb->settings;

	@fclose($file);

$GLOBALS['settings'] = &$mybb->settings;

}

}


/**
* Build a PREG compatible array of search highlight terms to replace in posts.


/**
* Build a PREG compatible array of search highlight terms to replace in posts.

Zeile 4838Zeile 4984
	
$banned_ips = $cache->read("bannedips");
if(!is_array($banned_ips))

	
$banned_ips = $cache->read("bannedips");
if(!is_array($banned_ips))

	{
return false;
}


	{
return false;
}


	foreach($banned_ips as $banned_ip)
{
if(!$banned_ip['filter'])

	foreach($banned_ips as $banned_ip)
{
if(!$banned_ip['filter'])

Zeile 4954Zeile 5100
 * @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 5119
		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'])
{
return false;

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

		}

		}

		if(!$url['port'])
{
$url['port'] = 80;

		if(!$url['port'])
{
$url['port'] = 80;

		}

		}

		if(!$url['path'])
{
$url['path'] = "/";

		if(!$url['path'])
{
$url['path'] = "/";

		}

		}

		if($url['query'])
{
$url['path'] .= "?{$url['query']}";

		if($url['query'])
{
$url['path'] .= "?{$url['query']}";

Zeile 4989Zeile 5150
		$fp = @fsockopen($url['host'], $url['port'], $error_no, $error, 10);
@stream_set_timeout($fp, 10);
if(!$fp)

		$fp = @fsockopen($url['host'], $url['port'], $error_no, $error, 10);
@stream_set_timeout($fp, 10);
if(!$fp)

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




















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

		if(!@fwrite($fp, $headers))

		{

		{

			return false;
}
while(!feof($fp))
{
$data .= fgets($fp, 12800);

			return false;
}
while(!feof($fp))
{
$data .= fgets($fp, 12800);

		}

		}

		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

	}
else if(empty($post_data))

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

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

	}
}





	}
else
{
return false;
}
}


/**
* Checks if a particular user is a super administrator.


/**
* Checks if a particular user is a super administrator.

Zeile 5020Zeile 5204
 * @return boolean True if a super admin, false if not
*/
function is_super_admin($uid)

 * @return boolean True if a super admin, false if not
*/
function is_super_admin($uid)

{

{

	global $mybb;

$mybb->config['super_admins'] = str_replace(" ", "", $mybb->config['super_admins']);

	global $mybb;

$mybb->config['super_admins'] = str_replace(" ", "", $mybb->config['super_admins']);

Zeile 5029Zeile 5213
		return false;
}
else

		return false;
}
else

	{

	{

		return true;
}
}

		return true;
}
}

Zeile 5063Zeile 5247
			$escape_preg = preg_quote($escape, "#");
}
$quoted_strings = preg_split("#(?<!\\\){$escape_preg}#", $string);

			$escape_preg = preg_quote($escape, "#");
}
$quoted_strings = preg_split("#(?<!\\\){$escape_preg}#", $string);

	}
else
{

	}
else
{

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

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

Zeile 5075Zeile 5259
			if($in_escape)
{
$strings[] = trim($string);

			if($in_escape)
{
$strings[] = trim($string);

			}

			}

			else
{
$split_strings = explode($delimeter, $string);

			else
{
$split_strings = explode($delimeter, $string);

Zeile 5104Zeile 5288
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 5310
	// 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 5394
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 5409
			"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)."'");

	}
}


	}
}