Vergleich inc/functions.php - 1.4.1 - 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 4116 2008-08-15 15:37:11Z ybwzrd $

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

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

	}

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



	}

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



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

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





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

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

		{

		{

			continue;
}

			continue;
}



		

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

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

				{

				{

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

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

Zeile 1024Zeile 1027
					$permbit = "";
}


					$permbit = "";
}


				if(in_array($perm, $groupzerogreater))


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

				{

				{

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

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





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


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

Zeile 1126Zeile 1127
	if(!is_array($fpermcache))
{
$fpermcache = $cache->read("forumpermissions");

	if(!is_array($fpermcache))
{
$fpermcache = $cache->read("forumpermissions");

	}

if($fid) // Fetch the permissions for a single forum

	}

if($fid) // Fetch the permissions for a single forum

	{
if(!$cached_forum_permissions_permissions[$gid][$fid])
{

	{
if(!$cached_forum_permissions_permissions[$gid][$fid])
{

Zeile 1137Zeile 1138
		return $cached_forum_permissions_permissions[$gid][$fid];
}
else

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

	{

	{

		if(!$cached_forum_permissions[$gid])
{
foreach($forum_cache as $forum)

		if(!$cached_forum_permissions[$gid])
{
foreach($forum_cache as $forum)

Zeile 1195Zeile 1196
					
// If we STILL don't have forum permissions we use the usergroup itself
if(empty($level_permissions))

					
// If we STILL don't have forum permissions we use the usergroup itself
if(empty($level_permissions))

					{

					{

						$level_permissions = $groupscache[$gid];
}
}

						$level_permissions = $groupscache[$gid];
}
}

Zeile 1328Zeile 1329
		if(!$parentslist)
{
$parentslist = get_parent_list($fid);

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

		}

		}


$sql = build_parent_list($fid, "fid", "OR", $parentslist);
$query = $db->simple_select("moderators", "*", "uid='{$uid}' AND {$sql}");
$perms = $db->fetch_array($query);

if(!$perms)


$sql = build_parent_list($fid, "fid", "OR", $parentslist);
$query = $db->simple_select("moderators", "*", "uid='{$uid}' AND {$sql}");
$perms = $db->fetch_array($query);

if(!$perms)

		{

		{

			return false;
}


			return false;
}


Zeile 1367Zeile 1368
	}

if($uid == 0)

	}

if($uid == 0)

	{

	{

		return false;
}


		return false;
}


Zeile 1392Zeile 1393
				}
}
return false;

				}
}
return false;

		}
else
{

		}
else
{

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

if(!$action && $modperms)
{
return true;

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

if(!$action && $modperms)
{
return true;

			}

			}

			else
{
if($modperms[$action] == 1)

			else
{
if($modperms[$action] == 1)

Zeile 1424Zeile 1425
function get_post_icons()
{
global $mybb, $cache, $icon, $theme, $templates, $lang;

function get_post_icons()
{
global $mybb, $cache, $icon, $theme, $templates, $lang;





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

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

Zeile 1449Zeile 1450
			$no_icons_checked = "";
}
else

			$no_icons_checked = "";
}
else

		{

		{

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

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

		}


		}


		++$listed;
if($listed == 10)
{
$iconlist .= "<br />";
$listed = 0;

		++$listed;
if($listed == 10)
{
$iconlist .= "<br />";
$listed = 0;

		}
}

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

		}
}

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


return $posticons;
}


return $posticons;
}

Zeile 1486Zeile 1487
	if($expires == -1)
{
$expires = 0;

	if($expires == -1)
{
$expires = 0;

	}

	}

	elseif($expires == "" || $expires == null)
{
if($mybb->user['remember'] == 0)

	elseif($expires == "" || $expires == null)
{
if($mybb->user['remember'] == 0)

Zeile 1511Zeile 1512
	$cookie = "Set-Cookie: {$mybb->settings['cookieprefix']}{$name}=".urlencode($value);

if($expires > 0)

	$cookie = "Set-Cookie: {$mybb->settings['cookieprefix']}{$name}=".urlencode($value);

if($expires > 0)

	{

	{

		$cookie .= "; expires=".@gmdate('D, d-M-Y H:i:s \\G\\M\\T', $expires);

		$cookie .= "; expires=".@gmdate('D, d-M-Y H:i:s \\G\\M\\T', $expires);

	}


	}


	if(!empty($mybb->settings['cookiepath']))
{
$cookie .= "; path={$mybb->settings['cookiepath']}";

	if(!empty($mybb->settings['cookiepath']))
{
$cookie .= "; path={$mybb->settings['cookiepath']}";

	}


	}


	if(!empty($mybb->settings['cookiedomain']))

	if(!empty($mybb->settings['cookiedomain']))

	{

	{

		$cookie .= "; domain={$mybb->settings['cookiedomain']}";

		$cookie .= "; domain={$mybb->settings['cookiedomain']}";

	}

	}


if($httponly == true)
{
$cookie .= "; HttpOnly";


if($httponly == true)
{
$cookie .= "; HttpOnly";

	}


	}


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

header($cookie, false);

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

header($cookie, false);

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

{
global $mybb;


{
global $mybb;


	if(!isset($mybb->cookies['mybb'][$name]))
{
return false;
}

	if(!isset($mybb->cookies['mybb'][$name]))
{
return false;
}





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

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

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

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

	{

	{

		return $cookie[$id];

		return $cookie[$id];

	}

	}

	else
{
return 0;
}

	else
{
return 0;
}

}


}


/**
* Set a serialised cookie array.
*

/**
* Set a serialised cookie array.
*

Zeile 1594Zeile 1595
	$newcookie[$id] = $value;
$newcookie = addslashes(serialize($newcookie));
my_setcookie("mybb[$name]", $newcookie);

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

}

/**

}

/**

 * Returns the serverload of the system.
*
* @return int The serverload of the system.

 * Returns the serverload of the system.
*
* @return int The serverload of the system.

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 1872Zeile 1873
	$update_query = array();

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

	$update_query = array();

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





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

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

Zeile 1887Zeile 1888
				$update_query[$counter] = $thread[$counter] + $changes[$counter];
}
else

				$update_query[$counter] = $thread[$counter] + $changes[$counter];
}
else

			{

			{

				$update_query[$counter] = $changes[$counter];
}
// Less than 0? That's bad

				$update_query[$counter] = $changes[$counter];
}
// Less than 0? That's bad

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


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

Zeile 1950Zeile 1959
		$lastpost['username'] = $firstpost['username'];
$lastpost['uid'] = $firstpost['uid'];
$lastpost['dateline'] = $firstpost['dateline'];

		$lastpost['username'] = $firstpost['username'];
$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 1972
		'lastposteruid' => intval($lastpost['uid']),
);
$db->update_query("threads", $update_array, "tid='{$tid}'");

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

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

}

function update_forum_count($fid)

}

function update_forum_count($fid)

{

{

	die("Deprecated function call: update_forum_count");

	die("Deprecated function call: update_forum_count");

}

}

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

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

{

{

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


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


Zeile 1998Zeile 2009

/**
* Deletes a post from the database


/**
* Deletes a post from the database

 *

 *

 * @param int The thread ID
*/
function delete_post($pid, $tid="")

 * @param int The thread ID
*/
function delete_post($pid, $tid="")

Zeile 2040Zeile 2051
	if(!is_array($jumpfcache))
{
if(!is_array($forum_cache))

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

		{

		{

			cache_forums();
}


			cache_forums();
}


Zeile 2065Zeile 2076
			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 = "";

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 3080Zeile 3091
	if($mybb->settings['nocacheheaders'] == 1 && $mybb->settings['standardheaders'] != 1)
{
header("Expires: Sat, 1 Jan 2000 01:00:00 GMT");

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

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

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

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

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

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

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

	global $db;

	global $db, $mybb;


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


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

	}

	}

	else
{

	else
{

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

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

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


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


Zeile 3340Zeile 3351
			}
}
}

			}
}
}


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











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

}

/**

}

/**

Zeile 3355Zeile 3375
	global $db, $mybb, $cache;

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

	global $db, $mybb, $cache;

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

	{
$user = $mybb->user;
}

	{
$user = $mybb->user;
}

	else
{

	else
{

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

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

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

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

	}



	}

$groupslist = "";

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


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


Zeile 3380Zeile 3401
				$donegroup[$gid] = 1;
}
}

				$donegroup[$gid] = 1;
}
}

	}



	}

$dispupdate = "";

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

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





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

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

		WHERE uid='$uid'

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

	");

$cache->update_moderators();

	");

$cache->update_moderators();

Zeile 3404Zeile 3426
 * @return string The current URL being accessed
*/
function get_current_location($fields=false, $ignore=array())

 * @return string The current URL being accessed
*/
function get_current_location($fields=false, $ignore=array())

{

{

	if(defined("MYBB_LOCATION"))
{
return MYBB_LOCATION;

	if(defined("MYBB_LOCATION"))
{
return MYBB_LOCATION;

	}


	}


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

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

		$location = $_SERVER['PATH_INFO'];
}
elseif(!empty($_ENV['PATH_INFO']))
{
$location = $_ENV['PATH_INFO'];

		$location = htmlspecialchars_uni($_SERVER['PATH_INFO']);
}
elseif(!empty($_ENV['PATH_INFO']))
{
$location = htmlspecialchars_uni($_ENV['PATH_INFO']);

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

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

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

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

	}

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

	}

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

		

		

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

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

Zeile 3453Zeile 3475
		}

return array('location' => $location, 'form_html' => $form_html, 'form_method' => $mybb->request_method);

		}

return array('location' => $location, 'form_html' => $form_html, 'form_method' => $mybb->request_method);

	}
else

	}
else

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

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

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

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

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

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

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

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

		}

if((isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] == "POST") || (isset($_ENV['REQUEST_METHOD']) && $_ENV['REQUEST_METHOD'] == "POST"))
{
$post_array = array('action', 'fid', 'pid', 'tid', 'uid', 'eid');

		}

if((isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] == "POST") || (isset($_ENV['REQUEST_METHOD']) && $_ENV['REQUEST_METHOD'] == "POST"))
{
$post_array = array('action', 'fid', 'pid', 'tid', 'uid', 'eid');

	

	

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

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

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

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

				}

				}

			}

			}

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

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

	

 
	
return $location;
}

	
return $location;
}

Zeile 3503Zeile 3524
	global $db, $themeselect, $tcache, $lang, $mybb, $limit;

if($tid == 0)

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

if($tid == 0)

	{

	{

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

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

Zeile 3595Zeile 3616

/**
* Custom function for formatting numbers.


/**
* Custom function for formatting numbers.

 *

 *

 * @param int The number to format.
* @return int The formatted number.
*/
function my_number_format($number)

 * @param int The number to format.
* @return int The formatted number.
*/
function my_number_format($number)

{
global $mybb;

{
global $mybb;


if($number == "-")
{
return $number;


if($number == "-")
{
return $number;

	}


	}


	if(is_int($number))

	if(is_int($number))

	{

	{

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

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

	}
else
{

	}
else
{

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

if(isset($parts[1]))

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

if(isset($parts[1]))

Zeile 3625Zeile 3646
			$decimals = 0;
}


			$decimals = 0;
}


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


































































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

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

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

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

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

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

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

	}
}


	}
}


Zeile 3640Zeile 3726
	global $mybb;

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

	global $mybb;

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

	{
if($mybb->config['db_encoding'] == "utf8" && !preg_match("#[\x80-\xFF]#", $message))
{
$message = preg_replace("#(?>[^\s&/<>\"\\-\.\[\]]{{$mybb->settings['wordwrap']}})#u", "$0 ", $message);
}
else
{
$message = preg_replace("#(?>[^\s&/<>\"\\-\.\[\]]{{$mybb->settings['wordwrap']}})#", "$0 ", $message);
}



	{
$message = convert_through_utf8($message);

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

$new_message = convert_through_utf8($new_message, false);

return $new_message;

	}

return $message;

	}

return $message;

}


}


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

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

Zeile 3669Zeile 3757
	for($i = 1969; $i >= $year; $i--)
{
$j = get_bdays($i);

	for($i = 1969; $i >= $year; $i--)
{
$j = get_bdays($i);





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

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

Zeile 3686Zeile 3774
				if($h == 0)
{
$h = 7;

				if($h == 0)
{
$h = 7;

				}
}
}
}

				}
}
}
}

}

/**

}

/**

Zeile 3766Zeile 3854
		'S',
'l',
'F',

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

 
		'M',

	);

$replace = array(

	);

$replace = array(

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

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

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

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

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

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

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

	);

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

	);

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

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

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

	}

	}


$firstpostup = array(
"firstpost" => $post['pid']


$firstpostup = array(
"firstpost" => $post['pid']

Zeile 3842Zeile 3932
function my_strlen($string)
{
global $lang;

function my_strlen($string)
{
global $lang;





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

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

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

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

Zeile 3859Zeile 3949
    if(function_exists("mb_strlen"))
{
$string_length = mb_strlen($string);

    if(function_exists("mb_strlen"))
{
$string_length = mb_strlen($string);

    }

    }

    else
{
$string_length = strlen($string);

    else
{
$string_length = strlen($string);

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

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

		}

		}

	}
else
{

	}
else
{

Zeile 3924Zeile 4014
	if(function_exists("mb_strtolower"))
{
$string = mb_strtolower($string);

	if(function_exists("mb_strtolower"))
{
$string = mb_strtolower($string);

	}

	}

	else
{
$string = strtolower($string);

	else
{
$string = strtolower($string);

Zeile 3949Zeile 4039
	}

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 3967Zeile 4057
 * @return int The uped string.
*/
function my_strtoupper($string)

 * @return int The uped string.
*/
function my_strtoupper($string)

{

{

	if(function_exists("mb_strtoupper"))
{
$string = mb_strtoupper($string);

	if(function_exists("mb_strtoupper"))
{
$string = mb_strtoupper($string);

	}

	}

	else
{
$string = strtoupper($string);

	else
{
$string = strtoupper($string);

Zeile 3981Zeile 4071
}

/**

}

/**

 * Returns any html entities to their original character




















 * Returns any html entities to their original character
*
* @param string The string to un-htmlentitize.
* @return int The un-htmlentitied' string.
*/
function unhtmlentities($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);
}

/**
* Returns any ascii to it's character (utf-8 safe).

 *

 *

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

 * @param string The ascii to characterize.
* @return int The characterized ascii.

 */

 */

function unhtmlentities($string)

function unichr($c)

{

{

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

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

return strtr($string, $trans_tbl);















    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 4090Zeile 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>";

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

		}
else

		}
else

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

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

Zeile 4112Zeile 4228

/**
* Build the forum link.


/**
* Build the forum link.

 *

 *

 * @param int The forum id of the forum.
* @param int (Optional) The page number of the forum.
* @return string The url to the forum.

 * @param int The forum id of the forum.
* @param int (Optional) The page number of the forum.
* @return string The url to the forum.

Zeile 4120Zeile 4236
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);
return htmlspecialchars_uni($link);

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

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

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

	{
if($action)
{

	{
if($action)
{

			$link = THREAD_URL_PAGED_ACTION;
}
else

			$link = THREAD_URL_PAGED_ACTION;
}
else

Zeile 4169Zeile 4285
			$link = THREAD_URL;
}
$link = str_replace("{tid}", $tid, $link);

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

		return htmlspecialchars_uni($link);
}

		return htmlspecialchars_uni($link);
}

}

/**

}

/**

Zeile 4196Zeile 4312

/**
* Build the event link.


/**
* Build the event link.

 *

 *

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

Zeile 4229Zeile 4345
	{
$link = str_replace("{month}", $month, CALENDAR_URL_MONTH);
$link = str_replace("{year}", $year, $link);

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

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

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

	else if($year > 0)
{
$link = str_replace("{year}", $year, CALENDAR_URL_YEAR);
$link = str_replace("{calendar}", $calendar, $link);

	else if($year > 0)
{
$link = str_replace("{year}", $year, CALENDAR_URL_YEAR);
$link = str_replace("{calendar}", $calendar, $link);

		return htmlspecialchars_uni($link);
}

		return htmlspecialchars_uni($link);
}

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

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

	}

	}

}

/**

}

/**

Zeile 4255Zeile 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 4508Zeile 4628
		}

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

		}

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

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

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

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

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

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

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

			return 1;
}
// Not waited long enough

			return 1;
}
// Not waited long enough

		else

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

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

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





			return false;
}
}

// User can attempt another login
return $loginattempts;

			return false;
}
}

// User can attempt another login
return $loginattempts;

}


}


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

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

Zeile 4558Zeile 4678
 * @return boolean True when in use, false when not.
*/
function email_already_in_use($email, $uid="")

 * @return boolean True when in use, false when not.
*/
function email_already_in_use($email, $uid="")

{

{

	global $db;

$uid_string = "";

	global $db;

$uid_string = "";

Zeile 4582Zeile 4702
function rebuildsettings()
{
rebuild_settings();

function rebuildsettings()
{
rebuild_settings();

}

}


/**
* Rebuilds settings.php


/**
* Rebuilds settings.php

Zeile 4599Zeile 4719
	else
{
$mode = "w";

	else
{
$mode = "w";

	}


	}


	$options = array(
"order_by" => "title",
"order_dir" => "ASC"
);
$query = $db->simple_select("settings", "value, name", "", $options);

	$options = array(
"order_by" => "title",
"order_dir" => "ASC"
);
$query = $db->simple_select("settings", "value, name", "", $options);





	while($setting = $db->fetch_array($query))
{
$mybb->settings[$setting['name']] = $setting['value'];

	while($setting = $db->fetch_array($query))
{
$mybb->settings[$setting['name']] = $setting['value'];

Zeile 4618Zeile 4738
	$file = @fopen(MYBB_ROOT."inc/settings.php", $mode);
@fwrite($file, $settings);
@fclose($file);

	$file = @fopen(MYBB_ROOT."inc/settings.php", $mode);
@fwrite($file, $settings);
@fclose($file);





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


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


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

 */
function build_highlight_array($terms)
{

	$terms = htmlspecialchars_uni($terms);


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

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

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

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

 
			$phrase = htmlspecialchars_uni($phrase);

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

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

Zeile 4678Zeile 4797
	// Otherwise just a simple search query with no phrases
else
{

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

 
		$terms = htmlspecialchars_uni($terms);

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

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

Zeile 4953Zeile 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 4962Zeile 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 4982Zeile 5117
			$url['path'] = "/";
}
if($url['query'])

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

		{

		{

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

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

Zeile 4991Zeile 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 5160
		$data = explode("\r\n\r\n", $data, 2);
return $data[1];
}

		$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 5048Zeile 5206
	$original = $string;
$in_escape = false;
if($escape)

	$original = $string;
$in_escape = false;
if($escape)

	{

	{

		if(is_array($escape))
{
function escaped_explode_escape($string)

		if(is_array($escape))
{
function escaped_explode_escape($string)

Zeile 5058Zeile 5216
			$escape_preg = "(".implode("|", array_map("escaped_explode_escape", $escape)).")";
}
else

			$escape_preg = "(".implode("|", array_map("escaped_explode_escape", $escape)).")";
}
else

		{

		{

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

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

	{

	{

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

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

Zeile 5086Zeile 5244
			}
}
$in_escape = !$in_escape;

			}
}
$in_escape = !$in_escape;

	}

	}

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

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

}


}


/**
* Fetch an IPv4 long formatted range for searching IPv4 IP addresses.
*

/**
* Fetch an IPv4 long formatted range for searching IPv4 IP addresses.
*

Zeile 5183Zeile 5341
	if($stamp == 0)
{
$stamp = TIME_NOW;

	if($stamp == 0)
{
$stamp = TIME_NOW;

	}

	}

	$d = explode('-', $date);
$nowdate = date("H-j-n-Y", $stamp);
$n = explode('-', $nowdate);

	$d = explode('-', $date);
$nowdate = date("H-j-n-Y", $stamp);
$n = explode('-', $nowdate);

Zeile 5318Zeile 5476
    }

return @unlink($path);

    }

return @unlink($path);

 
}

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

return $count;

}

?>

}

?>