Vergleich inc/functions.php - 1.4.2 - 1.4.4

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

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

 * $Id: functions.php 4182 2008-09-07 18:05:30Z Tikitiki $

 * $Id: functions.php 4279 2008-11-26 00:01:25Z 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 765Zeile 768
		echo "<script type=\"text/javascript\">\n";
if($message != "")
{

		echo "<script type=\"text/javascript\">\n";
if($message != "")
{

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

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

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

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

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

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

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

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

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

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


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

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


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

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



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


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

Zeile 1005Zeile 1008
	}

foreach($groups as $gid)

	}

foreach($groups as $gid)

	{

	{

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

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



		

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

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

Zeile 1020Zeile 1023
					$permbit = $usergroup[$perm];
}
else

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

				{

				{

					$permbit = "";

					$permbit = "";

				}

				}





				if(in_array($perm, $groupzerogreater))


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

				{

				{

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

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





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


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

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

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

	}


	}


	$displaygroup = array();
$group = $groupscache[$gid];

foreach($displaygroupfields as $field)

	$displaygroup = array();
$group = $groupscache[$gid];

foreach($displaygroupfields as $field)

	{

	{

		$displaygroup[$field] = $group[$field];
}


		$displaygroup[$field] = $group[$field];
}


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

if($uid == 0)

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

if($uid == 0)

	{

	{

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

if(!$gid || $gid == 0) // If no group, we need to fetch it
{
if($uid != 0 && $uid != $mybb->user['uid'])

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

if(!$gid || $gid == 0) // If no group, we need to fetch it
{
if($uid != 0 && $uid != $mybb->user['uid'])

		{

		{

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

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

			}


			}


			$gid = $usercache[$uid]['usergroup'].",".$usercache[$uid]['additionalgroups'];
$groupperms = usergroup_permissions($gid);
}
else
{
$gid = $mybb->user['usergroup'];

			$gid = $usercache[$uid]['usergroup'].",".$usercache[$uid]['additionalgroups'];
$groupperms = usergroup_permissions($gid);
}
else
{
$gid = $mybb->user['usergroup'];





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

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





			$groupperms = $mybb->usergroup;

			$groupperms = $mybb->usergroup;

		}
}

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

if(!$forum_cache)
{
return false;

		}
}

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

if(!$forum_cache)
{
return false;

		}
}


		}
}


Zeile 1243Zeile 1244
	$parents = explode(',', $forum_cache[$fid]['parentlist']);
rsort($parents);
if(!empty($parents))

	$parents = explode(',', $forum_cache[$fid]['parentlist']);
rsort($parents);
if(!empty($parents))

	{

	{

		foreach($parents as $parent_id)
{
if($parent_id == $fid || $parent_id == $pid)

		foreach($parents as $parent_id)
{
if($parent_id == $fid || $parent_id == $pid)

Zeile 1367Zeile 1368
	}

if($uid == 0)

	}

if($uid == 0)

	{

	{

		return false;
}


		return false;
}


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

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

			{

			{

				foreach($modcache as $modusers)
{
if(isset($modusers[$uid]) && $modusers[$uid]['mid'])
{
return true;
}

				foreach($modcache as $modusers)
{
if(isset($modusers[$uid]) && $modusers[$uid]['mid'])
{
return true;
}

				}
}

				}
}

			return false;
}
else

			return false;
}
else

Zeile 1413Zeile 1414
				}
}
}

				}
}
}

	}

	}

}

/**

}

/**

Zeile 1429Zeile 1430
	if($mybb->input['icon'])
{
$icon = $mybb->input['icon'];

	if($mybb->input['icon'])
{
$icon = $mybb->input['icon'];

	}

	}


$no_icons_checked = " checked=\"checked\"";
// read post icons from cache, and sort them accordingly


$no_icons_checked = " checked=\"checked\"";
// read post icons from cache, and sort them accordingly

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

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

		}
}


		}
}


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

return $posticons;

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

return $posticons;

Zeile 1484Zeile 1485
	}

if($expires == -1)

	}

if($expires == -1)

	{

	{

		$expires = 0;
}
elseif($expires == "" || $expires == null)

		$expires = 0;
}
elseif($expires == "" || $expires == null)

Zeile 1492Zeile 1493
		if($mybb->user['remember'] == 0)
{
$expires = 0;

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

		}

		}

		else
{
$expires = TIME_NOW + (60*60*24*365); // Make the cookie expire in a years time

		else
{
$expires = TIME_NOW + (60*60*24*365); // Make the cookie expire in a years time

Zeile 1529Zeile 1530
	{
$cookie .= "; HttpOnly";
}

	{
$cookie .= "; HttpOnly";
}

	

	

	$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.
*/
function my_unsetcookie($name)

 * @param string The cookie identifier.
*/
function my_unsetcookie($name)

Zeile 1552Zeile 1553

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


/**
* 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 1562Zeile 1563
	global $mybb;

if(!isset($mybb->cookies['mybb'][$name]))

	global $mybb;

if(!isset($mybb->cookies['mybb'][$name]))

	{

	{

		return false;
}


		return false;
}


Zeile 1576Zeile 1577
	{
return 0;
}

	{
return 0;
}

}

/**

}

/**

 * Set a serialised cookie array.
*
* @param string The cookie identifier.

 * Set a serialised cookie array.
*
* @param string The cookie identifier.

Zeile 1616Zeile 1617
			$serverload[0] = round($serverload[0], 4);
}
if(!$serverload)

			$serverload[0] = round($serverload[0], 4);
}
if(!$serverload)

		{

		{

			if(@ini_get('safe_mode') == 'On')
{
return $lang->unknown;

			if(@ini_get('safe_mode') == 'On')
{
return $lang->unknown;

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

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


foreach($counters as $counter)


foreach($counters as $counter)

	{
if(array_key_exists($counter, $changes))
{

	{
if(array_key_exists($counter, $changes))
{

Zeile 1864Zeile 1865
 *
* @param int The thread ID
* @param array Array of items being updated (replies, unapprovedposts, attachmentcount) and their value (ex, 1, +1, -1)

 *
* @param int The thread ID
* @param array Array of items being updated (replies, unapprovedposts, attachmentcount) and their value (ex, 1, +1, -1)

 */

 */

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

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

Zeile 1878Zeile 1879
	$thread = $db->fetch_array($query);

foreach($counters as $counter)

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

foreach($counters as $counter)

	{

	{

		if(array_key_exists($counter, $changes))
{
// Adding or subtracting from previous value?

		if(array_key_exists($counter, $changes))
{
// Adding or subtracting from previous value?

Zeile 1897Zeile 1898
			}
}
}

			}
}
}

 
	
$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 1929
		LIMIT 1"
);
$lastpost = $db->fetch_array($query);

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





	
$db->free_result($query);


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

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

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

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

 
	
$db->free_result($query);


if(!$firstpost['username'])
{
$firstpost['username'] = $firstpost['postusername'];


if(!$firstpost['username'])
{
$firstpost['username'] = $firstpost['postusername'];

	}


	}


	if(!$lastpost['username'])

	if(!$lastpost['username'])

	{

	{

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

if(!$lastpost['dateline'])

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

if(!$lastpost['dateline'])

	{

	{

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

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

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

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

}



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


function update_forum_count($fid)
{
die("Deprecated function call: update_forum_count");


function update_forum_count($fid)
{
die("Deprecated function call: update_forum_count");

}

}

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

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

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

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

{
global $moderation;

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

{
global $moderation;

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


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


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

Zeile 2031Zeile 2042
	global $forum_cache, $jumpfcache, $permissioncache, $mybb, $selecteddone, $forumjump, $forumjumpbits, $gobutton, $theme, $templates, $lang;

$pid = intval($pid);

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

$pid = intval($pid);





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

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

Zeile 2054Zeile 2065
	}

if(!is_array($permissioncache))

	}

if(!is_array($permissioncache))

	{

	{

		$permissioncache = forum_permissions();
}

if(is_array($jumpfcache[$pid]))
{
foreach($jumpfcache[$pid] as $main)

		$permissioncache = forum_permissions();
}

if(is_array($jumpfcache[$pid]))
{
foreach($jumpfcache[$pid] as $main)

		{

		{

			foreach($main as $forum)
{
$perms = $permissioncache[$forum['fid']];

			foreach($main as $forum)
{
$perms = $permissioncache[$forum['fid']];





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

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





					if($selitem == $forum['fid'])
{
$optionselected = "selected=\"selected\"";

					if($selitem == $forum['fid'])
{
$optionselected = "selected=\"selected\"";

Zeile 2115Zeile 2126
	}

return $forumjump;

	}

return $forumjump;

}


}


/**
* Returns the extension of a file.
*

/**
* Returns the extension of a file.
*

Zeile 2241Zeile 2252
			$editor_language .= "\t{$js_lang_string}: \"{$string}\"";

if($editor_lang_strings[$key+1])

			$editor_language .= "\t{$js_lang_string}: \"{$string}\"";

if($editor_lang_strings[$key+1])

			{

			{

				$editor_language .= ",";
}


				$editor_language .= ",";
}


Zeile 2491Zeile 2502
	else
{
$display_reputation .= "reputation_neutral";

	else
{
$display_reputation .= "reputation_neutral";

	}

	}


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



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


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

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

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

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

	}

return $url;

	}

return $url;

Zeile 3310Zeile 3321
 */
function join_usergroup($uid, $joingroup)
{

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

	global $db;

	global $db, $mybb;


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


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

Zeile 3341Zeile 3352
		}
}


		}
}


	$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 3364Zeile 3384
		$user = $db->fetch_array($query);
}


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


	$usergroups = "";

 
	$groupslist = "";

	$groupslist = "";

 
	$usergroups = "";

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

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

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

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

Zeile 3382Zeile 3402
			}
}
}

			}
}
}



	

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

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

Zeile 3423Zeile 3443
	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']);
}

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

Zeile 3446Zeile 3466
			foreach($mybb->input as $name => $value)
{
if(in_array($name, $ignore))

			foreach($mybb->input as $name => $value)
{
if(in_array($name, $ignore))

				{

				{

					continue;
}


					continue;
}


Zeile 3491Zeile 3511

/**
* Build a theme selection menu


/**
* Build a theme selection menu

 *

 *

 * @param string The name of the menu
* @param int The ID of the selected theme
* @param int The ID of the parent theme to select from

 * @param string The name of the menu
* @param int The ID of the selected theme
* @param int The ID of the parent theme to select from

Zeile 3553Zeile 3573
			if($is_allowed || $theme['allowedgroups'] == "all" || $theme['allowedgroups'] == "" || $usergroup_override == 1)
{
if($theme['tid'] == $selected)

			if($is_allowed || $theme['allowedgroups'] == "all" || $theme['allowedgroups'] == "" || $usergroup_override == 1)
{
if($theme['tid'] == $selected)

				{

				{

					$sel = " selected=\"selected\"";
}


					$sel = " selected=\"selected\"";
}


Zeile 3627Zeile 3647
		}

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 3635Zeile 3720
 *
* @param string The string to be word wrapped
* @return string The word wraped string

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

 */

 */

function my_wordwrap($message)
{
global $mybb;

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

function my_wordwrap($message)
{
global $mybb;

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

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



	{
$message = 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;

Zeile 3674Zeile 3761
		for($k = 11; $k >= 0; $k--)
{
$l = ($k + 1);

		for($k = 11; $k >= 0; $k--)
{
$l = ($k + 1);





			for($m = $j[$k]; $m >= 1; $m--)
{
$h--;

if($i == $year && $l == $month && $m == $day)

			for($m = $j[$k]; $m >= 1; $m--)
{
$h--;

if($i == $year && $l == $month && $m == $day)

				{

				{

					return $h;
}


					return $h;
}


Zeile 3767Zeile 3854
		'S',
'l',
'F',

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

 
		'M',

	);

$replace = array(

	);

$replace = array(

Zeile 3778Zeile 3866
		($bd == 1 || $bd == 21 || $bd == 31 ? 'st' : ($bd == 2 || $bd == 22 ? 'nd' : ($bd == 3 || $bd == 23 ? 'rd' : 'th'))),
$bdays[$wd],
$bmonth[$bm-1],

		($bd == 1 || $bd == 21 || $bd == 31 ? 'st' : ($bd == 2 || $bd == 22 ? 'nd' : ($bd == 3 || $bd == 23 ? 'rd' : 'th'))),
$bdays[$wd],
$bmonth[$bm-1],

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

	);

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

	);

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

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

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

	}

	}

	return $age;
}


	return $age;
}


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

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

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








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

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

return strtr($string, $trans_tbl);
}





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

return strtr($string, $trans_tbl);



























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

}

/**

}

/**

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

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

			global $mybb;

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

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

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








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

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

		{

		{

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

			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 4124Zeile 4239
	{
$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
{

	}
else
{

Zeile 4148Zeile 4263
		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 4256Zeile 4371
 */
function get_calendar_week_link($calendar, $week)
{

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

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

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

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

Zeile 4346Zeile 4465
	if(isset($thread_cache[$tid]))
{
return $thread_cache[$tid];

	if(isset($thread_cache[$tid]))
{
return $thread_cache[$tid];

	}
else
{

	}
else
{

		$query = $db->simple_select("threads", "*", "tid='".intval($tid)."'");
$thread = $db->fetch_array($query);

		$query = $db->simple_select("threads", "*", "tid='".intval($tid)."'");
$thread = $db->fetch_array($query);





		if($thread)
{
$thread_cache[$tid] = $thread;
return $thread;

		if($thread)
{
$thread_cache[$tid] = $thread;
return $thread;

		}
else

		}
else

		{
$thread_cache[$tid] = false;

		{
$thread_cache[$tid] = false;

			return false;
}
}
}

			return false;
}
}
}


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


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

Zeile 4375Zeile 4494
{
global $db;
static $post_cache;

{
global $db;
static $post_cache;





	if(isset($post_cache[$pid]))
{
return $post_cache[$pid];

	if(isset($post_cache[$pid]))
{
return $post_cache[$pid];

Zeile 4394Zeile 4513
		{
$post_cache[$pid] = false;
return false;

		{
$post_cache[$pid] = false;
return false;

		}
}
}

/**

		}
}
}

/**

 * Get inactivate forums.
*
* @return string The comma separated values of the inactivate forum.

 * Get inactivate forums.
*
* @return string The comma separated values of the inactivate forum.

Zeile 4500Zeile 4619
		{
my_setcookie('failedlogin', $now);


		{
my_setcookie('failedlogin', $now);


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


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


			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 4691Zeile 4810
				continue;
}
$words[] = trim($word);

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

		}

}

		}

}


if(!is_array($words))
{


if(!is_array($words))
{

Zeile 4817Zeile 4936
			if($update_lastuse == true)
{
$db->update_query("banfilters", array("lastuse" => TIME_NOW), "fid='{$banned_email['fid']}'");

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

			}
return true;

			}
return true;

		}
}
// Still here - good email

		}
}
// Still here - good email

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

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

function fetch_remote_file($url)

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

{

{

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


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

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

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

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

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

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

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

	else if(function_exists("fsockopen"))

 	else if(function_exists("fsockopen"))

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

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

Zeile 4975Zeile 5109
			return false;
}
if(!$url['port'])

			return false;
}
if(!$url['port'])

		{

		{

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

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

		}

		}

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

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

Zeile 4992Zeile 5126
		{
return false;
}

		{
return false;
}

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




















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

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

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

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

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

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

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

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

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

	}
else
{

	}
else
{

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

		return false;

	}
}


	}
}