Vergleich inc/functions.php - 1.4.4 - 1.4.11

  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 4279 2008-11-26 00:01:25Z 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 454Zeile 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 473Zeile 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 494Zeile 494
		}
else
{

		}
else
{

			error($lang->invalid_post_code);








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

		}
}
else

		}
}
else

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

{
global $forum_cache;
static $forumarraycache;





	if($forumarraycache[$fid])

	if($forumarraycache[$fid])

	{

	{

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

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

	}

	}

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

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

	{

	{

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

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

Zeile 570Zeile 577
	global $forum_cache, $cache;

if($force == true)

	global $forum_cache, $cache;

if($force == true)

	{

	{

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

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

Zeile 585Zeile 592
		}
}
return $forum_cache;

		}
}
return $forum_cache;

}

/**

}

/**

 * Generate an array of all child and descendant forums for a specific forum.
*
* @param int The forum ID

 * Generate an array of all child and descendant forums for a specific forum.
*
* @param int The forum ID

Zeile 596Zeile 603
function get_child_list($fid)
{
static $forums_by_parent;

function get_child_list($fid)
{
static $forums_by_parent;





	$forums = array();
if(!is_array($forums_by_parent))
{

	$forums = array();
if(!is_array($forums_by_parent))
{

Zeile 622Zeile 629
		{
$forums = array_merge($forums, $children);
}

		{
$forums = array_merge($forums, $children);
}

	}

	}

	return $forums;
}


	return $forums;
}


Zeile 640Zeile 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']}");

	}

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

		echo "<error>{$error}</error>\n";
exit;
}

Zeile 664Zeile 671
	output_page($errorpage);

exit;

	output_page($errorpage);

exit;

}


}


/**
* Produce an error message for displaying inline on a page
*

/**
* Produce an error message for displaying inline on a page
*

Zeile 703Zeile 710
	}

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

	}

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





	return $errors;
}


	return $errors;
}


Zeile 713Zeile 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;
$plugins->run_hooks("no_permission");


	$time = TIME_NOW;
$plugins->run_hooks("no_permission");


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

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





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


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


Zeile 802Zeile 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 829Zeile 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 847Zeile 853
	if(!$mybb->settings['maxmultipagelinks'])
{
$mybb->settings['maxmultipagelinks'] = 5;

	if(!$mybb->settings['maxmultipagelinks'])
{
$mybb->settings['maxmultipagelinks'] = 5;

	}


	}


	$from = $page-floor($mybb->settings['maxmultipagelinks']/2);
$to = $page+floor($mybb->settings['maxmultipagelinks']/2);


	$from = $page-floor($mybb->settings['maxmultipagelinks']/2);
$to = $page+floor($mybb->settings['maxmultipagelinks']/2);


Zeile 856Zeile 862
	{
$from = 1;
$to = $from+$mybb->settings['maxmultipagelinks']-1;

	{
$from = 1;
$to = $from+$mybb->settings['maxmultipagelinks']-1;

	}

	}


if($to > $pages)
{


if($to > $pages)
{

Zeile 874Zeile 880
	}

if($from > 1)

	}

if($from > 1)

	{

	{

		$page_url = fetch_page_url($url, 1);
eval("\$start = \"".$templates->get("multipage_start")."\";");
}

		$page_url = fetch_page_url($url, 1);
eval("\$start = \"".$templates->get("multipage_start")."\";");
}

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

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

		{

		{

			eval("\$mppage .= \"".$templates->get("multipage_page_current")."\";");
}
else

			eval("\$mppage .= \"".$templates->get("multipage_page_current")."\";");
}
else

Zeile 920Zeile 926
{
// If no page identifier is specified we tack it on to the end of the URL
if(strpos($url, "{page}") === false)

{
// If no page identifier is specified we tack it on to the end of the URL
if(strpos($url, "{page}") === false)

	{

	{

		if(strpos($url, "?") === false)

		if(strpos($url, "?") === false)

		{

		{

			$url .= "?";

			$url .= "?";

		}

		}

		else
{
$url .= "&amp;";
}
$url .= "page=$page";

		else
{
$url .= "&amp;";
}
$url .= "page=$page";

	}

	}

	else
{
$url = str_replace("{page}", $page, $url);

	else
{
$url = str_replace("{page}", $page, $url);

Zeile 949Zeile 955
	global $mybb, $cache, $groupscache, $user_cache;

// If no user id is specified, assume it is the current user

	global $mybb, $cache, $groupscache, $user_cache;

// If no user id is specified, assume it is the current user

	if($uid == 0)
{

	if($uid == 0)
{

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


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


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

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

		}

		}


// Collect group permissions.
$gid = $user_cache[$uid]['usergroup'].",".$user_cache[$uid]['additionalgroups'];


// Collect group permissions.
$gid = $user_cache[$uid]['usergroup'].",".$user_cache[$uid]['additionalgroups'];

Zeile 995Zeile 1001
	global $cache, $groupscache, $grouppermignore, $groupzerogreater;

if(!is_array($groupscache))

	global $cache, $groupscache, $grouppermignore, $groupzerogreater;

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

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

Zeile 1025Zeile 1030
				else
{
$permbit = "";

				else
{
$permbit = "";

				}


				}


				// 0 represents unlimited for numerical group permissions (i.e. private message limit) so take that into account.

				// 0 represents unlimited for numerical group permissions (i.e. private message limit) so take that into account.

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

				if(in_array($perm, $groupzerogreater) && ($access == 0 || $permbit === 0))
{

					$usergroup[$perm] = 0;
continue;

					$usergroup[$perm] = 0;
continue;

				} 

				}


if($access > $permbit || ($access == "yes" && $permbit == "no") || !$permbit) // Keep yes/no for compatibility?
{
$usergroup[$perm] = $access;
}


if($access > $permbit || ($access == "yes" && $permbit == "no") || !$permbit) // Keep yes/no for compatibility?
{
$usergroup[$perm] = $access;
}

			}

			}

		}
}

		}
}





	return $usergroup;
}

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

	return $usergroup;
}

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

 *

 *

 * @param int The group ID to fetch the display properties for
* @return array Array of display properties for the group
*/

 * @param int The group ID to fetch the display properties for
* @return array Array of display properties for the group
*/

Zeile 1066Zeile 1071
	foreach($displaygroupfields as $field)
{
$displaygroup[$field] = $group[$field];

	foreach($displaygroupfields as $field)
{
$displaygroup[$field] = $group[$field];

	}

	}


return $displaygroup;
}


return $displaygroup;
}

Zeile 1092Zeile 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 1104Zeile 1109
		else
{
$gid = $mybb->user['usergroup'];

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





			if(isset($mybb->user['additionalgroups']))
{
$gid .= ",".$mybb->user['additionalgroups'];

			if(isset($mybb->user['additionalgroups']))
{
$gid .= ",".$mybb->user['additionalgroups'];

Zeile 1262Zeile 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 1284Zeile 1289
			else
{
$showform = false;

			else
{
$showform = false;

			}
}
}
else
{

			}
}
}
else
{

		$showform = false;
}

if($showform)
{

		$showform = false;
}

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 1313Zeile 1325
{
global $mybb, $db;
static $modpermscache;

{
global $mybb, $db;
static $modpermscache;





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

if($uid == 0)

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

if($uid == 0)

	{

	{

		return false;
}


		return false;
}


Zeile 1348Zeile 1360
	}

return $perms;

	}

return $perms;

}

/**

}

/**

 * Checks if a moderator has permissions to perform an action in a specific forum
*
* @param int The forum ID (0 assumes global)

 * Checks if a moderator has permissions to perform an action in a specific forum
*
* @param int The forum ID (0 assumes global)

Zeile 1532Zeile 1544
	}

$mybb->cookies[$name] = $value;

	}

$mybb->cookies[$name] = $value;





	header($cookie, false);
}

/**
* Unset a cookie set by MyBB.

	header($cookie, false);
}

/**
* Unset a cookie set by MyBB.

 *
* @param string The cookie identifier.
*/

 *
* @param string The cookie identifier.
*/

function my_unsetcookie($name)
{
global $mybb;

$expires = -3600;

function my_unsetcookie($name)
{
global $mybb;

$expires = -3600;

	my_setcookie($name, "", $expires);


	my_setcookie($name, "", $expires);


	unset($mybb->cookies[$name]);
}

/**
* Get the contents from a serialised cookie array.

	unset($mybb->cookies[$name]);
}

/**
* Get the contents from a serialised cookie array.

 *
* @param string The cookie identifier.
* @param int The cookie content id.

 *
* @param string The cookie identifier.
* @param int The cookie content id.

 * @return array|boolean The cookie id's content array or false when non-existent.
*/
function my_get_array_cookie($name, $id)

 * @return array|boolean The cookie id's content array or false when non-existent.
*/
function my_get_array_cookie($name, $id)

Zeile 1570Zeile 1582
	$cookie = unserialize($mybb->cookies['mybb'][$name]);

if(isset($cookie[$id]))

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

if(isset($cookie[$id]))

	{

	{

		return $cookie[$id];
}
else

		return $cookie[$id];
}
else

Zeile 1593Zeile 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 1616Zeile 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 1641Zeile 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 1828Zeile 1843

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


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

 
	
$cache->update_forums();

}

/**

}

/**

Zeile 1967Zeile 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']),

		'lastpost' => intval($lastpost['dateline']),
'lastposter' => $lastpost['username'],
'lastposteruid' => intval($lastpost['uid']),

Zeile 2033Zeile 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;


Zeile 2077Zeile 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 2094Zeile 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 2877Zeile 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 3501Zeile 3521
	
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 3522Zeile 3550
function build_theme_select($name, $selected="", $tid=0, $depth="", $usergroup_override=0)
{
global $db, $themeselect, $tcache, $lang, $mybb, $limit;

function build_theme_select($name, $selected="", $tid=0, $depth="", $usergroup_override=0)
{
global $db, $themeselect, $tcache, $lang, $mybb, $limit;





	if($tid == 0)
{
$themeselect = "<select name=\"$name\">";

	if($tid == 0)
{
$themeselect = "<select name=\"$name\">";

Zeile 3542Zeile 3570
	}

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

	}

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

	{

	{

		// Figure out what groups this user is in
if($mybb->user['additionalgroups'])
{

		// Figure out what groups this user is in
if($mybb->user['additionalgroups'])
{

Zeile 3646Zeile 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']);

	}
}


	}
}


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

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

 
		'D',

		'y',
'Y',
'j',

		'y',
'Y',
'j',

Zeile 3860Zeile 3889
	$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],
($bm == 9 ? my_substr($bmonth[$bm-1], 0, 4) : my_substr($bmonth[$bm-1], 0, 3)),
);

		$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 3882Zeile 3920
{
$bday = explode("-", $birthday);
if(!$bday[2])

{
$bday = explode("-", $birthday);
if(!$bday[2])

	{

	{

		return;
}

		return;
}





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

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

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

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





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

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

Zeile 3921Zeile 3959
		"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
*
* @param string The string to check the length of.

 * Checks for the length of a string, mb strings accounted for
*
* @param string The string to check the length of.

Zeile 3978Zeile 4016
		if($length != "")
{
$cut_string = mb_substr($string, $start, $length);

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

		}
else
{

		}
else
{

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

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

Zeile 3999Zeile 4037
	if($handle_entities)
{
$cut_string = htmlspecialchars_uni($cut_string);

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

	}

	}

	return $cut_string;
}


	return $cut_string;
}


Zeile 4018Zeile 4056
	else
{
$string = strtolower($string);

	else
{
$string = strtolower($string);

	}

	}


return $string;
}


return $string;
}

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

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

	}


	}


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

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

Zeile 4066Zeile 4104
	{
$string = strtoupper($string);
}

	{
$string = strtoupper($string);
}





	return $string;
}


	return $string;
}


Zeile 4075Zeile 4113
 *
* @param string The string to un-htmlentitize.
* @return int The un-htmlentitied' string.

 *
* @param string The string to un-htmlentitize.
* @return int The un-htmlentitied' string.

 */

 */

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

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

Zeile 4102Zeile 4140
        return chr($c);
}
else if($c <= 0x7FF)

        return chr($c);
}
else if($c <= 0x7FF)

	{

	{

        return chr(0xC0 | $c >> 6) . chr(0x80 | $c & 0x3F);

        return chr(0xC0 | $c >> 6) . chr(0x80 | $c & 0x3F);

    }

    }

	else if($c <= 0xFFFF)

	else if($c <= 0xFFFF)

	{

	{

        return chr(0xE0 | $c >> 12) . chr(0x80 | $c >> 6 & 0x3F)
. chr(0x80 | $c & 0x3F);
}
else if($c <= 0x10FFFF)

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

        return chr(0xF0 | $c >> 18) . chr(0x80 | $c >> 12 & 0x3F)
. chr(0x80 | $c >> 6 & 0x3F)
. chr(0x80 | $c & 0x3F);

    }

    }

	else
{
return false;
}

	else
{
return false;
}

}

}


/**
* Get the event poster.


/**
* Get the event poster.

Zeile 4129Zeile 4167
 * @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)

{

{

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

Zeile 4148Zeile 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.
*
* @param int The user id of the profile.
* @return string The url to the profile.
*/
function get_profile_link($uid=0)

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

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

Zeile 4203Zeile 4241
		if(!empty($target))
{
$target = " target=\"{$target}\"";

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

		}


		}


		if(!empty($onclick))

		if(!empty($onclick))

		{

		{

			$onclick = " onclick=\"{$onclick}\"";
}

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

			$onclick = " onclick=\"{$onclick}\"";
}

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

		{

		{

			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.
*
* @param int The forum id of the forum.

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

Zeile 4236Zeile 4274
function get_forum_link($fid, $page=0)
{
if($page > 0)

function get_forum_link($fid, $page=0)
{
if($page > 0)

	{

	{

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

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

		return htmlspecialchars_uni($link);
}

		return htmlspecialchars_uni($link);
}

	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 4255Zeile 4293
 * @param int (Optional) The page number of the thread.
* @param string (Optional) The action we're performing (ex, lastpost, newpost, etc)
* @return string The url to the thread.

 * @param int (Optional) The page number of the thread.
* @param string (Optional) The action we're performing (ex, lastpost, newpost, etc)
* @return string The url to the thread.

 */

 */

function get_thread_link($tid, $page=0, $action='')
{
if($page > 1)

function get_thread_link($tid, $page=0, $action='')
{
if($page > 1)

Zeile 4263Zeile 4301
		if($action)
{
$link = THREAD_URL_PAGED_ACTION;

		if($action)
{
$link = THREAD_URL_PAGED_ACTION;

		}
else

		}
else

		{
$link = THREAD_URL_PAGED;
}

		{
$link = THREAD_URL_PAGED;
}

Zeile 4274Zeile 4312
		return htmlspecialchars_uni($link);
}
else

		return htmlspecialchars_uni($link);
}
else

	{

	{

		if($action)
{
$link = THREAD_URL_ACTION;

		if($action)
{
$link = THREAD_URL_ACTION;

Zeile 4301Zeile 4339
	{
$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);

Zeile 4312Zeile 4350

/**
* Build the event link.


/**
* Build the event link.

 *

 *

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

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

	return htmlspecialchars_uni($link);
}


	return htmlspecialchars_uni($link);
}


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

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

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

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

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

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

	else if($month > 0)
{
$link = str_replace("{month}", $month, CALENDAR_URL_MONTH);

	else if($month > 0)
{
$link = str_replace("{month}", $month, CALENDAR_URL_MONTH);

Zeile 4378Zeile 4416
	$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);

}

}


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


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

Zeile 4407Zeile 4445
		$user_cache[$uid] = $db->fetch_array($query);

return $user_cache[$uid];

		$user_cache[$uid] = $db->fetch_array($query);

return $user_cache[$uid];

	}

	}

}



}



Zeile 4453Zeile 4491

/**
* Get the thread of a thread id.


/**
* Get the thread of a thread id.

 *

 *

 * @param int The thread id of the thread.
* @return string The database row of the thread.
*/

 * @param int The thread id of the thread.
* @return string The database row of the thread.
*/

Zeile 4463Zeile 4501
	static $thread_cache;

if(isset($thread_cache[$tid]))

	static $thread_cache;

if(isset($thread_cache[$tid]))

	{

	{

		return $thread_cache[$tid];
}
else

		return $thread_cache[$tid];
}
else

Zeile 4472Zeile 4510
		$thread = $db->fetch_array($query);

if($thread)

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

if($thread)

		{

		{

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

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

		}

		}

		else
{
$thread_cache[$tid] = false;

		else
{
$thread_cache[$tid] = false;

			return false;
}
}
}

			return false;
}
}
}


/**
* Get the post of a post id.


/**
* Get the post of a post id.

Zeile 4491Zeile 4529
 * @return string The database row of the post.
*/
function get_post($pid)

 * @return string The database row of the post.
*/
function get_post($pid)

{

{

	global $db;
static $post_cache;


	global $db;
static $post_cache;


Zeile 4529Zeile 4567
	if(!$forum_cache)
{
cache_forums();

	if(!$forum_cache)
{
cache_forums();

	}

	}


$inactive = array();



$inactive = array();


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

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





	return $inactiveforums;
}


	return $inactiveforums;
}


Zeile 4605Zeile 4643
			$failedtime = $now;
}
else

			$failedtime = $now;
}
else

		{

		{

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


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


Zeile 4667Zeile 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 4750Zeile 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 4757Zeile 4802
		"+",
"-",
"~"

		"+",
"-",
"~"

	);

	);

	$terms = str_replace($bad_characters, '', $terms);

// Check if this is a "series of words" - should be treated as an EXACT match

	$terms = str_replace($bad_characters, '', $terms);

// Check if this is a "series of words" - should be treated as an EXACT match

Zeile 4771Zeile 4816
			if($phrase != "")
{
if($inquote)

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

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

				{
$words[] = trim($phrase);
}

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

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

					}

					}

					foreach($split_words as $word)
{

					foreach($split_words as $word)
{

						if(!$word)

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

						{
continue;
}

						{
continue;
}

Zeile 4802Zeile 4847
		if(!is_array($split_words))
{
continue;

		if(!is_array($split_words))
{
continue;

		}

		}

		foreach($split_words as $word)
{

		foreach($split_words as $word)
{

			if(!$word)

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

			{
continue;
}

			{
continue;
}

Zeile 4818Zeile 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 4833Zeile 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 4912Zeile 4961
		}
}
// Still here - good username

		}
}
// Still here - good username

	return false;
}


	return false;
}


/**
* Check if a specific email address has been banned.
*

/**
* Check if a specific email address has been banned.
*

Zeile 4931Zeile 4980
		// Make regular expression * match
$banned_email['filter'] = str_replace('\*', '(.*)', preg_quote($banned_email['filter'], '#'));
if(preg_match("#{$banned_email['filter']}#i", $email))

		// Make regular expression * match
$banned_email['filter'] = str_replace('\*', '(.*)', preg_quote($banned_email['filter'], '#'));
if(preg_match("#{$banned_email['filter']}#i", $email))

		{
// Updating last use
if($update_lastuse == true)

		{
// Updating last use
if($update_lastuse == true)

			{
$db->update_query("banfilters", array("lastuse" => TIME_NOW), "fid='{$banned_email['fid']}'");
}

			{
$db->update_query("banfilters", array("lastuse" => TIME_NOW), "fid='{$banned_email['fid']}'");
}

Zeile 4941Zeile 4990
		}
}
// Still here - good email

		}
}
// Still here - good email

	return false;
}


	return false;
}


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

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

Zeile 4990Zeile 5039
 * @param string The name of the select
* @param int The selected time zone (defaults to GMT)
* @param boolean True to generate a "short" list with just timezone and current time

 * @param string The name of the select
* @param int The selected time zone (defaults to GMT)
* @param boolean True to generate a "short" list with just timezone and current time

 */

 */

function build_timezone_select($name, $selected=0, $short=false)
{
global $mybb, $lang;

function build_timezone_select($name, $selected=0, $short=false)
{
global $mybb, $lang;

Zeile 5037Zeile 5086
		if($selected == $timezone)
{
$selected_add = " selected=\"selected\"";

		if($selected == $timezone)
{
$selected_add = " selected=\"selected\"";

		}

		}

		if($short == true)
{
$label = '';

		if($short == true)
{
$label = '';

Zeile 5047Zeile 5096
				if($timezone > 0)
{
$label = "+{$label}";

				if($timezone > 0)
{
$label = "+{$label}";

				}

				}

				if(strpos($timezone, ".") !== false)
{
$label = str_replace(".", ":", $label);

				if(strpos($timezone, ".") !== false)
{
$label = str_replace(".", ":", $label);

Zeile 5065Zeile 5114
	}
$select .= "</select>";
return $select;

	}
$select .= "</select>";
return $select;

}

}


/**
* Fetch the contents of a remote fle.


/**
* Fetch the contents of a remote fle.

Zeile 5113Zeile 5162
			$url['port'] = 80;
}
if(!$url['path'])

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

		{

		{

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

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

Zeile 5132Zeile 5181
			$headers[] = "POST {$url['path']} HTTP/1.0";
$headers[] = "Content-Length: ".strlen($post_body);
$headers[] = "Content-Type: application/x-www-form-urlencoded";

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

		else
{
$headers[] = "GET {$url['path']} HTTP/1.0";

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

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

		

		

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

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

Zeile 5261Zeile 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 5279Zeile 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 5358Zeile 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 5370Zeile 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)."'");

	}
}


	}
}