Vergleich inc/functions.php - 1.6.1 - 1.6.4

  Keine Änderungen   Hinzugefügt   Modifiziert   Entfernt
Zeile 6Zeile 6
 * Website: http://mybb.com
* License: http://mybb.com/about/license
*

 * Website: http://mybb.com
* License: http://mybb.com/about/license
*

 * $Id: functions.php 5172 2010-08-02 23:13:03Z RyanGordon $

 * $Id: functions.php 5490 2011-07-12 13:39:55Z Tomm $

 */

/**

 */

/**

Zeile 197Zeile 197
	}

// And finally.. plugins

	}

// And finally.. plugins

	if(!is_object($plugins) && !defined("NO_PLUGINS"))

	if(!is_object($plugins) && !defined("NO_PLUGINS") && !($mybb->settings['no_plugins'] == 1))

	{
require_once MYBB_ROOT."inc/class_plugins.php";
$plugins = new pluginSystem;

	{
require_once MYBB_ROOT."inc/class_plugins.php";
$plugins = new pluginSystem;

Zeile 732Zeile 732
	);

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

	);

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

	$url = htmlspecialchars_uni("http://".$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI']);

 

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


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

Zeile 962Zeile 961
 	{
$find = array(
"-page-{page}",

 	{
$find = array(
"-page-{page}",

			"&page={page}"


			"&page={page}",
"{page}"

		);

// Remove "Page 1" to the defacto URL

		);

// Remove "Page 1" to the defacto URL

		$url = str_replace($find, array("", ""), $url);

		$url = str_replace($find, array("", "", $page), $url);

		return $url;
}
else if(strpos($url, "{page}") === false)

		return $url;
}
else if(strpos($url, "{page}") === false)

Zeile 1224Zeile 1224
	}

$current_permissions = array();

	}

$current_permissions = array();

 
	$only_view_own_threads = 1;

	
foreach($groups as $gid)
{

	
foreach($groups as $gid)
{

Zeile 1261Zeile 1262
				{
$current_permissions[$permission] = $access;
}

				{
$current_permissions[$permission] = $access;
}

 
			}

if(!$level_permissions["canonlyviewownthreads"])
{
$only_view_own_threads = 0;

			}
}

			}
}

 
	}

// Figure out if we can view more than our own threads
if($only_view_own_threads == 0)
{
$current_permissions["canonlyviewownthreads"] = 0;

	}

if(count($current_permissions) == 0)

	}

if(count($current_permissions) == 0)

Zeile 1288Zeile 1300
	{
$forum_cache = cache_forums();
if(!$forum_cache)

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

		{

		{

			return false;
}
}

			return false;
}
}

Zeile 1331Zeile 1343
		else
{
if(!$mybb->cookies['forumpass'][$fid] || ($mybb->cookies['forumpass'][$fid] && md5($mybb->user['uid'].$password) != $mybb->cookies['forumpass'][$fid]))

		else
{
if(!$mybb->cookies['forumpass'][$fid] || ($mybb->cookies['forumpass'][$fid] && md5($mybb->user['uid'].$password) != $mybb->cookies['forumpass'][$fid]))

			{

			{

				$showform = true;
}
else
{
$showform = false;
}

				$showform = true;
}
else
{
$showform = false;
}

		}
}
else
{

		}
}
else
{

		$showform = false;
}


		$showform = false;
}


Zeile 1352Zeile 1364
			header("Location: ".$mybb->settings['bburl']."/".get_forum_link($fid));
}
else

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

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

Zeile 1371Zeile 1383
 */
function get_moderator_permissions($fid, $uid="0", $parentslist="")
{

 */
function get_moderator_permissions($fid, $uid="0", $parentslist="")
{

	global $mybb, $db;

	global $mybb, $cache, $db;

	static $modpermscache;

if($uid < 1)
{

	static $modpermscache;

if($uid < 1)
{

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

if($uid == 0)
{
return false;
}

if(!isset($modpermscache[$fid][$uid]))
{
if(!$parentslist)
{
$parentslist = get_parent_list($fid);
}

// Get user groups
$query = $db->simple_select("users", "usergroup,additionalgroups", "uid='{$uid}'");
$usergroups = $db->fetch_array($query);
$groups = "'{$usergroups['usergroup']}'";
if(!empty($usergroups['additionalgroups']))
{
$groups .= ",'{$usergroups['additionalgroups']}'";
}

$query = $db->simple_select("moderators", "*", "((id IN ({$groups}) AND isgroup='1') OR (id='{$uid}' AND isgroup='0')) AND fid='$fid'");
while($results = $db->fetch_array($query))
{
$perms['caneditposts'] = max($perms['caneditposts'], $results['caneditposts']);
$perms['candeleteposts'] = max($perms['candeleteposts'], $results['candeleteposts']);
$perms['canviewips'] = max($perms['canviewips'], $results['canviewips']);
$perms['canopenclosethreads'] = max($perms['canopenclosethreads'], $results['canopenclosethreads']);
$perms['canmanagethreads'] = max($perms['canmanagethreads'], $results['canmanagethreads']);
$perms['canmovetononmodforum'] = max($perms['canmovetononmodforum'], $results['canmovetononmodforum']);
}

$sql = build_parent_list($fid, "fid", "OR", $parentslist);
$query = $db->simple_select("moderators", "*", "((id IN ({$groups}) AND isgroup='1') OR (id='{$uid}' AND isgroup='0')) AND {$sql}");
$uperms = $db->fetch_array($query);

if(!$uperms && !$perms)
{
return false;
}

//Join the group permissions with the user permissions
$perms['caneditposts'] = max($perms['caneditposts'], $uperms['caneditposts']);
$perms['candeleteposts'] = max($perms['candeleteposts'], $uperms['candeleteposts']);
$perms['canviewips'] = max($perms['canviewips'], $uperms['canviewips']);
$perms['canopenclosethreads'] = max($perms['canopenclosethreads'], $uperms['canopenclosethreads']);
$perms['canmanagethreads'] = max($perms['canmanagethreads'], $uperms['canmanagethreads']);
$perms['canmovetononmodforum'] = max($perms['canmovetononmodforum'], $uperms['canmovetononmodforum']);

$modpermscache[$fid][$uid] = $perms;
}
else
{
$perms = $modpermscache[$fid][$uid];































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

if($uid == 0)
{
return false;
}

if(isset($modpermscache[$fid][$uid]))
{
return $modpermscache[$fid][$uid];
}

if(!$parentslist)
{
$parentslist = explode(',', get_parent_list($fid));
}

// Get user groups
$perms = array();
$user = get_user($uid);

$groups = array($user['usergroup']);

if(!empty($user['additionalgroups']))
{
$extra_groups = explode(",", $user['additionalgroups']);

foreach($extra_groups as $extra_group)
{
$groups[] = $extra_group;
}
}

$mod_cache = $cache->read("moderators");

foreach($mod_cache as $fid => $forum)
{
if(!is_array($forum) || !in_array($fid, $parentslist))
{
// No perms or we're not after this forum
continue;
}

// User settings override usergroup settings
if(is_array($forum['users'][$uid]))
{
$perm = $forum['users'][$uid];
foreach($perm as $action => $value)
{
if(strpos($action, "can") === false)
{
continue;
}

// Figure out the user permissions
if($value == 0)
{
// The user doesn't have permission to set this action
$perms[$action] = 0;
}
else
{
$perms[$action] = max($perm[$action], $perms[$action]);
}
}
}

foreach($groups as $group)
{
if(!is_array($forum['usergroups'][$group]))
{
// There are no permissions set for this group
continue;
}

$perm = $forum['usergroups'][$group];
foreach($perm as $action => $value)
{
if(strpos($action, "can") === false)
{
continue;
}

$perms[$action] = max($perm[$action], $perms[$action]);
}
}

	}

	}

 

$modpermscache[$fid][$uid] = $perms;


return $perms;
}


return $perms;
}

Zeile 1537Zeile 1581
	
foreach($posticons as $dbicon)
{

	
foreach($posticons as $dbicon)
{

 
		$dbicon['path'] = htmlspecialchars_uni($dbicon['path']);
$dbicon['name'] = htmlspecialchars_uni($dbicon['name']);


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

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

Zeile 1556Zeile 1603
	}

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

	}

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





	return $posticons;
}


	return $posticons;
}


Zeile 1569Zeile 1616
 * @param boolean True if setting a HttpOnly cookie (supported by IE, Opera 9, Konqueror)
*/
function my_setcookie($name, $value="", $expires="", $httponly=false)

 * @param boolean True if setting a HttpOnly cookie (supported by IE, Opera 9, Konqueror)
*/
function my_setcookie($name, $value="", $expires="", $httponly=false)

{
global $mybb;


{
global $mybb;


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

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

	{

	{

		$mybb->settings['cookiepath'] = "/";
}

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

		$mybb->settings['cookiepath'] = "/";
}

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

	}

	}

	elseif($expires == "" || $expires == null)

	elseif($expires == "" || $expires == null)

	{

	{

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

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

	}

	}

	else
{
$expires = TIME_NOW + intval($expires);

	else
{
$expires = TIME_NOW + intval($expires);

	}


	}


	$mybb->settings['cookiepath'] = str_replace(array("\n","\r"), "", $mybb->settings['cookiepath']);
$mybb->settings['cookiedomain'] = str_replace(array("\n","\r"), "", $mybb->settings['cookiedomain']);
$mybb->settings['cookieprefix'] = str_replace(array("\n","\r", " "), "", $mybb->settings['cookieprefix']);

	$mybb->settings['cookiepath'] = str_replace(array("\n","\r"), "", $mybb->settings['cookiepath']);
$mybb->settings['cookiedomain'] = str_replace(array("\n","\r"), "", $mybb->settings['cookiedomain']);
$mybb->settings['cookieprefix'] = str_replace(array("\n","\r", " "), "", $mybb->settings['cookieprefix']);





	// Versions of PHP prior to 5.2 do not support HttpOnly cookies and IE is buggy when specifying a blank domain so set the cookie manually
$cookie = "Set-Cookie: {$mybb->settings['cookieprefix']}{$name}=".urlencode($value);

if($expires > 0)

	// Versions of PHP prior to 5.2 do not support HttpOnly cookies and IE is buggy when specifying a blank domain so set the cookie manually
$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']))
{
$cookie .= "; domain={$mybb->settings['cookiedomain']}";

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

Zeile 1639Zeile 1686

/**
* 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 1711Zeile 1758
		{
// sys_getloadavg() will return an array with [0] being load within the last minute.
$serverload = sys_getloadavg();

		{
// sys_getloadavg() will return an array with [0] being load within the last minute.
$serverload = sys_getloadavg();

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

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

		}
else if(@file_exists("/proc/loadavg") && $load = @file_get_contents("/proc/loadavg"))
{

		}
else if(@file_exists("/proc/loadavg") && $load = @file_get_contents("/proc/loadavg"))
{

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

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





	foreach($counters as $counter)
{
if(array_key_exists($counter, $changes))

	foreach($counters as $counter)
{
if(array_key_exists($counter, $changes))

Zeile 1867Zeile 1914
			
// Less than 0? That's bad
if(!$update_query[$counter])

			
// Less than 0? That's bad
if(!$update_query[$counter])

			{

			{

				$update_query[$counter] = 0;
}
}

				$update_query[$counter] = 0;
}
}

Zeile 1875Zeile 1922

// Only update if we're actually doing something
if(count($update_query) > 0)


// Only update if we're actually doing something
if(count($update_query) > 0)

	{

	{

		$db->update_query("forums", $update_query, "fid='".intval($fid)."'");
}


		$db->update_query("forums", $update_query, "fid='".intval($fid)."'");
}


Zeile 1884Zeile 1931
	{
$new_stats = array();
if(array_key_exists('threads', $update_query))

	{
$new_stats = array();
if(array_key_exists('threads', $update_query))

		{

		{

			$threads_diff = $update_query['threads'] - $forum['threads'];
if($threads_diff > -1)

			$threads_diff = $update_query['threads'] - $forum['threads'];
if($threads_diff > -1)

			{

			{

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

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

			}

			}

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

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

			}

			}

		}

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

		}

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

Zeile 1919Zeile 1966
			else
{
$new_stats['numposts'] = "{$posts_diff}";

			else
{
$new_stats['numposts'] = "{$posts_diff}";

			}
}

			}
}

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

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

Zeile 1947Zeile 1994
 * Update the last post information for a specific forum
*
* @param int The forum ID

 * Update the last post information for a specific forum
*
* @param int The forum ID

 */

 */

function update_forum_lastpost($fid)
{
global $db;

function update_forum_lastpost($fid)
{
global $db;

Zeile 1990Zeile 2037
	// 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);

	

	

	foreach($counters as $counter)
{
if(array_key_exists($counter, $changes))

	foreach($counters as $counter)
{
if(array_key_exists($counter, $changes))

Zeile 2130Zeile 2177
function delete_post($pid, $tid="")
{
global $moderation;

function delete_post($pid, $tid="")
{
global $moderation;





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

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

Zeile 2270Zeile 2317
	{
$ch = my_rand(0, count($set)-1);
$str .= $set[$ch];

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

	}

	}


return $str;
}


return $str;
}

Zeile 2409Zeile 2456
	global $cache, $smiliecache, $theme, $templates, $lang, $mybb, $smiliecount;

if($mybb->settings['smilieinserter'] != 0 && $mybb->settings['smilieinsertercols'] && $mybb->settings['smilieinsertertot'])

	global $cache, $smiliecache, $theme, $templates, $lang, $mybb, $smiliecount;

if($mybb->settings['smilieinserter'] != 0 && $mybb->settings['smilieinsertercols'] && $mybb->settings['smilieinsertertot'])

	{

	{

		if(!$smiliecount)
{
$smilie_cache = $cache->read("smilies");

		if(!$smiliecount)
{
$smilie_cache = $cache->read("smilies");

Zeile 2492Zeile 2539
	}

return $clickablesmilies;

	}

return $clickablesmilies;

 
}

/**
* Builds thread prefixes and returns a selected prefix (or all)
*
* @param int The prefix ID (0 to return all)
* @return array The thread prefix's values (or all thread prefixes)
*/
function build_prefixes($pid=0)
{
global $cache;
static $prefixes_cache;

if(is_array($prefixes_cache))
{
if($pid > 0 && is_array($prefixes_cache[$pid]))
{
return $prefixes_cache[$pid];
}

return $prefixes_cache;
}

$prefix_cache = $cache->read("threadprefixes");

if($prefix_cache === false)
{
return false;
}

$prefixes_cache = array();
foreach($prefix_cache as $prefix)
{
$prefixes_cache[$prefix['pid']] = $prefix;
}

if($pid != 0 && is_array($prefixes_cache[$pid]))
{
return $prefixes_cache[$pid];
}
else if(!empty($prefixes_cache))
{
return $prefixes_cache;
}

return false;

}

/**

}

/**

Zeile 2503Zeile 2596
 */
function build_prefix_select($fid, $selected_pid=0, $multiple=0)
{

 */
function build_prefix_select($fid, $selected_pid=0, $multiple=0)
{

	global $db, $lang, $mybb;

	global $cache, $db, $lang, $mybb;

	
if($fid != 'all')
{
$fid = intval($fid);
}


	
if($fid != 'all')
{
$fid = intval($fid);
}


	// Does this user have additional groups?







	$prefix_cache = build_prefixes(0);
if(!$prefix_cache)
{
return false; // We've got no prefixes to show
}

$groups = array($mybb->user['usergroup']);

	if($mybb->user['additionalgroups'])

	if($mybb->user['additionalgroups'])

	{

	{

		$exp = explode(",", $mybb->user['additionalgroups']);

		$exp = explode(",", $mybb->user['additionalgroups']);


// Because we like apostrophes...
$imps = array();





		foreach($exp as $group)
{

		foreach($exp as $group)
{

			$imps[] = "'{$group}'";
}

$additional_groups = implode(",", $imps);
$extra_sql = "groups IN ({$additional_groups}) OR ";
}
else
{
$extra_sql = '';
}

switch($db->type)
{
case "pgsql":
case "sqlite":
$whereforum = "";
if($fid != 'all')
{
$whereforum = " AND (','||forums||',' LIKE '%,{$fid},%' OR ','||forums||',' LIKE '%,-1,%' OR forums='')";
}

$query = $db->query("
SELECT pid, prefix
FROM ".TABLE_PREFIX."threadprefixes
WHERE ({$extra_sql}','||groups||',' LIKE '%,{$mybb->user['usergroup']},%' OR ','||groups||',' LIKE '%,-1,%' OR groups='')
{$whereforum}
");
break;
default:
$whereforum = "";
if($fid != 'all')
{
$whereforum = " AND (CONCAT(',',forums,',') LIKE '%,{$fid},%' OR CONCAT(',',forums,',') LIKE '%,-1,%' OR forums='')";
}

$query = $db->query("
SELECT pid, prefix
FROM ".TABLE_PREFIX."threadprefixes
WHERE ({$extra_sql}CONCAT(',',groups,',') LIKE '%,{$mybb->user['usergroup']},%' OR CONCAT(',',groups,',') LIKE '%,-1,%' OR groups='')
{$whereforum}
");
}

$prefixselect = "";

if($db->num_rows($query) > 0)
{
$multipleselect = "";
if($multiple != 0)
{
$multipleselect = " multiple=\"multiple\" size=\"5\"";
}

$prefixselect = "<select name=\"threadprefix\"{$multipleselect}>\n";

if($multiple == 1)
{
$any_selected = "";
if($selected_pid == 'any')
{
$any_selected = " selected=\"selected\"";
}

$prefixselect .= "<option value=\"any\"".$any_selected.">".$lang->any_prefix."</option>\n";
}

$default_selected = "";
if((intval($selected_pid) == 0) && $selected_pid != 'any')
{
$default_selected = " selected=\"selected\"";
}

$prefixselect .= "<option value=\"0\"".$default_selected.">".$lang->no_prefix."</option>\n";

while($prefix = $db->fetch_array($query))
{
$selected = "";
if($prefix['pid'] == $selected_pid)

			$groups[] = $group;
}
}

// Go through each of our prefixes and decide which ones we can use
$prefixes = array();
foreach($prefix_cache as $prefix)
{
if($fid != "all" && $prefix['forums'] != "-1")
{
// Decide whether this prefix can be used in our forum
$forums = explode(",", $prefix['forums']);

if(!in_array($fid, $forums))
{
// This prefix is not in our forum list
continue;
}
}

if($prefix['groups'] != "-1")
{
$prefix_groups = explode(",", $prefix['groups']);

foreach($groups as $group)






















































			{

			{

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

$prefixselect .= "<option value=\"".$prefix['pid']."\"".$selected.">".htmlspecialchars_uni($prefix['prefix'])."</option>\n";


















































				if(in_array($group, $prefix_groups) && !isset($prefixes[$prefix['pid']]))
{
// Our group can use this prefix!
$prefixes[$prefix['pid']] = $prefix;
}
}
}
else
{
// This prefix is for anybody to use...
$prefixes[$prefix['pid']] = $prefix;
}
}

if(empty($prefixes))
{
return false;
}

$prefixselect = "";
$multipleselect = "";
if($multiple != 0)
{
$multipleselect = " multiple=\"multiple\" size=\"5\"";
}

$prefixselect = "<select name=\"threadprefix\"{$multipleselect}>\n";

if($multiple == 1)
{
$any_selected = "";
if($selected_pid == 'any')
{
$any_selected = " selected=\"selected\"";
}

$prefixselect .= "<option value=\"any\"".$any_selected.">".$lang->any_prefix."</option>\n";
}

$default_selected = "";
if((intval($selected_pid) == 0) && $selected_pid != 'any')
{
$default_selected = " selected=\"selected\"";
}

$prefixselect .= "<option value=\"0\"".$default_selected.">".$lang->no_prefix."</option>\n";

foreach($prefixes as $prefix)
{
$selected = "";
if($prefix['pid'] == $selected_pid)
{
$selected = " selected=\"selected\"";

		}

		}

		
$prefixselect .= "</select>\n&nbsp;";


$prefixselect .= "<option value=\"".$prefix['pid']."\"".$selected.">".htmlspecialchars_uni($prefix['prefix'])."</option>\n";

	}

	}

	




$prefixselect .= "</select>\n&nbsp;";


	return $prefixselect;
}


	return $prefixselect;
}


Zeile 2634Zeile 2729
		}

if(my_strpos(" ".$httpaccept_encoding, "gzip"))

		}

if(my_strpos(" ".$httpaccept_encoding, "gzip"))

		{

		{

			$encoding = "gzip";
}


			$encoding = "gzip";
}


Zeile 2676Zeile 2771
	if($data['fid'] == '')
{
$fid = 0;

	if($data['fid'] == '')
{
$fid = 0;

	}
else
{

	}
else
{

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

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

Zeile 2787Zeile 2882
 */
function get_ip()
{

 */
function get_ip()
{

	if(isset($_SERVER['REMOTE_ADDR']))
{
$ip = $_SERVER['REMOTE_ADDR'];
}
elseif(isset($_SERVER['HTTP_X_FORWARDED_FOR']))
{
if(preg_match_all("#[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}#s", $_SERVER['HTTP_X_FORWARDED_FOR'], $addresses))















    global $mybb, $plugins;

$ip = 0;

if(!preg_match("#^(10|172\.16|192\.168)\.#", $_SERVER['REMOTE_ADDR']))
{
$ip = $_SERVER['REMOTE_ADDR'];
}

if($mybb->settings['ip_forwarded_check'])
{
if(isset($_SERVER['HTTP_X_FORWARDED_FOR']))
{
preg_match_all("#[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}#s", $_SERVER['HTTP_X_FORWARDED_FOR'], $addresses);
}
elseif(isset($_SERVER['HTTP_X_REAL_IP']))
{
preg_match_all("#[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}#s", $_SERVER['HTTP_X_REAL_IP'], $addresses);
}

if(is_array($addresses[0]))

		{
foreach($addresses[0] as $key => $val)
{

		{
foreach($addresses[0] as $key => $val)
{

Zeile 2804Zeile 2913
				}
}
}

				}
}
}

	}

if(!isset($ip))
{
if(isset($_SERVER['HTTP_CLIENT_IP']))
{
$ip = $_SERVER['HTTP_CLIENT_IP'];
}
else
{
$ip = '';
}
}


    }

if(!$ip)
{
if(isset($_SERVER['HTTP_CLIENT_IP']))
{
$ip = $_SERVER['HTTP_CLIENT_IP'];
}
}

if($plugins)
{
$plugins->run_hooks("get_ip", array("ip" => &$ip));
}





	$ip = preg_replace("#([^.0-9 ]*)#", "", $ip);
return $ip;
}

    return $ip;
}



/**
* Fetch the friendly size (GB, MB, KB, B) for a specified file size.


/**
* Fetch the friendly size (GB, MB, KB, B) for a specified file size.

Zeile 3168Zeile 3277
					$navbits[$navsize]['url'] = get_forum_link($forumnav['fid'], $multipage['current_page']);

$navbits[$navsize]['multipage'] = $multipage;

					$navbits[$navsize]['url'] = get_forum_link($forumnav['fid'], $multipage['current_page']);

$navbits[$navsize]['multipage'] = $multipage;

					$navbits[$navsize]['multipage']['url'] = get_forum_link($forumnav['fid']);

					$navbits[$navsize]['multipage']['url'] = str_replace('{fid}', $forumnav['fid'], FORUM_URL_PAGED);

				}
else
{

				}
else
{

Zeile 3368Zeile 3477
{
global $mybb;


{
global $mybb;


	if($mybb->settings['nocacheheaders'] == 1 && $mybb->settings['standardheaders'] != 1)

	if($mybb->settings['nocacheheaders'] == 1)

	{
header("Expires: Sat, 1 Jan 2000 01:00:00 GMT");
header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");

	{
header("Expires: Sat, 1 Jan 2000 01:00:00 GMT");
header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");

Zeile 3586Zeile 3695
	else
{
$trow = "trow1";

	else
{
$trow = "trow1";

	}


	}


	$alttrow = $trow;

return $trow;

	$alttrow = $trow;

return $trow;

Zeile 4022Zeile 4131
	{
$message = convert_through_utf8($message);


	{
$message = convert_through_utf8($message);


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

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

		{

		{

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

			$new_message = preg_replace("#(((?>[^\s&/<>\"\\-\[\]])|(&\#[a-z0-9]{1,10};)){{$mybb->settings['wordwrap']}})#", "$0&#8203;", $message);	

		}

$new_message = convert_through_utf8($new_message, false);

		}

$new_message = convert_through_utf8($new_message, false);

Zeile 4151Zeile 4260
		'M',
);


		'M',
);


 
	$html = array(
'&#109;',
'&#99;',
'&#68;',
'&#121;',
'&#89;',
'&#106;',
'&#83;',
'&#70;',
'&#108;',
'&#77;',
);

$bdays = str_replace($find, $html, $bdays);
$bmonth = str_replace($find, $html, $bmonth);


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

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

Zeile 4185Zeile 4310
{
$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));

	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 = $year-$bday[2];

if(($month == $bday[1] && $day < $bday[0]) || $month < $bday[1])

	{

	{

		--$age;
}
return $age;

		--$age;
}
return $age;

Zeile 4218Zeile 4343
			"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']
);
$db->update_query("threads", $firstpostup, "tid='$tid'");

	$firstpostup = array(
"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 4243Zeile 4368
        // Get rid of any excess RTL and LTR override for they are the workings of the devil
$string = str_replace(dec_to_utf8(8238), "", $string);
$string = str_replace(dec_to_utf8(8237), "", $string);

        // Get rid of any excess RTL and LTR override for they are the workings of the devil
$string = str_replace(dec_to_utf8(8238), "", $string);
$string = str_replace(dec_to_utf8(8237), "", $string);





        // Remove dodgy whitespaces
$string = str_replace(chr(0xCA), "", $string);
}

        // Remove dodgy whitespaces
$string = str_replace(chr(0xCA), "", $string);
}

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

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

		}
}
else
{

		}
}
else
{

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

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

Zeile 4423Zeile 4548
	{
return false;
}

	{
return false;
}

}

/**

}

/**

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

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

Zeile 4443Zeile 4568
 *
* @param array The event data array.
* @return string The event date.

 *
* @param array The event data array.
* @return string The event date.

 */

 */

function get_event_date($event)
{
$event_date = explode("-", $event['date']);

function get_event_date($event)
{
$event_date = explode("-", $event['date']);

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

return $event_date;

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

return $event_date;

}

}


/**
* Get the profile link.


/**
* Get the profile link.

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

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

{

{

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

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

Zeile 4494Zeile 4619
	{
// Return Guest phrase for no UID, no guest nickname
return $lang->guest;

	{
// Return Guest phrase for no UID, no guest nickname
return $lang->guest;

	}

	}

	elseif($uid == 0)
{
// Return the guest's nickname if user is a guest but has a nickname

	elseif($uid == 0)
{
// Return the guest's nickname if user is a guest but has a nickname

Zeile 4519Zeile 4644

/**
* 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 4527Zeile 4652
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 4562Zeile 4687
		}
$link = str_replace("{tid}", $tid, $link);
$link = str_replace("{page}", $page, $link);

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

		return htmlspecialchars_uni($link);
}

		return htmlspecialchars_uni($link);
}

	else
{
if($action)

	else
{
if($action)

Zeile 4700Zeile 4825
		return $user_cache[$uid];
}
}

		return $user_cache[$uid];
}
}



 

/**
* Get the forum of a specific forum id.


/**
* Get the forum of a specific forum id.

Zeile 5147Zeile 5271
}

/**

}

/**

 * Converts a decimal reference of a character to its UTF-8 equivilant

 * Converts a decimal reference of a character to its UTF-8 equivalent

 * (Code by Anne van Kesteren, http://annevankesteren.nl/2005/05/character-references)
*
* @param string Decimal value of a character reference

 * (Code by Anne van Kesteren, http://annevankesteren.nl/2005/05/character-references)
*
* @param string Decimal value of a character reference

Zeile 5229Zeile 5353
 */
function is_banned_email($email, $update_lastuse=false)
{

 */
function is_banned_email($email, $update_lastuse=false)
{

	global $db;
$query = $db->simple_select("banfilters", "*", "type='3'");
while($banned_email = $db->fetch_array($query))









	global $cache, $db;

$banned_cache = $cache->read("bannedemails");

if(!$banned_cache)
{
$cache->update_bannedemails();
$banned_cache = $cache->read("bannedemails");
}

foreach($banned_cache as $banned_email)

	{
// Make regular expression * match
$banned_email['filter'] = str_replace('\*', '(.*)', preg_quote($banned_email['filter'], '#'));

	{
// 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(preg_match("#{$banned_email['filter']}#i", $email))
{
// Updating last use

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

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

		{

		{

			continue;
}


			continue;
}


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

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

	}
else
{
return false;

	}
else
{
return false;

	}
}


	}
}


Zeile 5489Zeile 5622
	if(my_strpos(",{$mybb->config['super_admins']},", ",{$uid},") === false)
{
return false;

	if(my_strpos(",{$mybb->config['super_admins']},", ",{$uid},") === false)
{
return false;

	}

	}

	else
{
return true;

	else
{
return true;

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

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

			}
else
{

			}
else
{

				$split_strings = explode($delimeter, $string);
foreach($split_strings as $string)
{

				$split_strings = explode($delimeter, $string);
foreach($split_strings as $string)
{

Zeile 5561Zeile 5694
 * Fetch an IPv4 long formatted range for searching IPv4 IP addresses.
*
* @param string The IP address to convert to a range based LONG

 * Fetch an IPv4 long formatted range for searching IPv4 IP addresses.
*
* @param string The IP address to convert to a range based LONG

 * @rturn mixed If a full IP address is provided, the ip2long equivilent, otherwise an array of the upper & lower extremities of the IP

 * @rturn mixed If a full IP address is provided, the ip2long equivalent, otherwise an array of the upper & lower extremities of the IP

 */
function fetch_longipv4_range($ip)
{

 */
function fetch_longipv4_range($ip)
{

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

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

}

/**
* Unicode function for php function chr()
*
* @param string The character
* @return mixed The unicoded chr()
*/
function unicode_chr($c)
{
if($c <= 0x7F)
{
return chr($c);
}
elseif($c <= 0x7FF)
{
return chr(0xC0 | $c >> 6) . chr(0x80 | $c & 0x3F);
}
elseif($c <= 0xFFFF)
{
return chr(0xE0 | $c >> 12) . chr(0x80 | $c >> 6 & 0x3F)
. chr(0x80 | $c & 0x3F);
}
elseif($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 5776Zeile 5876
function my_rmdir_recursive($path, $ignore=array())
{
global $orig_dir;

function my_rmdir_recursive($path, $ignore=array())
{
global $orig_dir;

	

	

	if(!isset($orig_dir))
{
$orig_dir = $path;

	if(!isset($orig_dir))
{
$orig_dir = $path;

Zeile 5798Zeile 5898
		
// Are we done? Don't delete the main folder too and return true
if($path == $orig_dir)

		
// Are we done? Don't delete the main folder too and return true
if($path == $orig_dir)

		{

		{

			return true;
}


			return true;
}


Zeile 5813Zeile 5913
 *
* @param array The array of forums
* @return integer The number of sub forums

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

function subforums_count($array)
{
$count = 0;
foreach($array as $array2)
{
$count += count($array2);

	}

	}

	
return $count;
}

	
return $count;
}

Zeile 5834Zeile 5934
 */
function my_ip2long($ip)
{

 */
function my_ip2long($ip)
{

	$ip = ip2long($ip);
if($ip >= 2147483648) // Won't occur on 32-bit PHP












	$ip_long = ip2long($ip);

if(!$ip_long)
{
$ip_long = sprintf("%u", ip2long($ip));

if(!$ip_long)
{
return 0;
}
}

if($ip_long >= 2147483648) // Won't occur on 32-bit PHP

	{

	{

		$ip -= 4294967296;

		$ip_long -= 4294967296;

	}

	}

	return $ip;



return $ip_long;

}

/**

}

/**

Zeile 5959Zeile 6071
 * Returns a signed value equal to an integer
*
* @param int The integer

 * Returns a signed value equal to an integer
*
* @param int The integer

 * @return string The signed equivallent

 * @return string The signed equivalent

 */
function signed($int)
{

 */
function signed($int)
{

Zeile 5977Zeile 6089
 * Returns a securely generated seed for PHP's RNG (Random Number Generator)
*
* @param int Length of the seed bytes (8 is default. Provides good cryptographic variance)

 * Returns a securely generated seed for PHP's RNG (Random Number Generator)
*
* @param int Length of the seed bytes (8 is default. Provides good cryptographic variance)

 * @return int An integer equivilent of a secure hexadecimal seed

 * @return int An integer equivalent of a secure hexadecimal seed

 */
function secure_seed_rng($count=8)
{

 */
function secure_seed_rng($count=8)
{

Zeile 6017Zeile 6129
 * @param int Optional lowest value to be returned (default: 0) 
* @param int Optional highest value to be returned (default: mt_getrandmax())
* @param boolean True forces it to reseed the RNG first

 * @param int Optional lowest value to be returned (default: 0) 
* @param int Optional highest value to be returned (default: mt_getrandmax())
* @param boolean True forces it to reseed the RNG first

 * @return int An integer equivilent of a secure hexadecimal seed

 * @return int An integer equivalent of a secure hexadecimal seed

 */
function my_rand($min=null, $max=null, $force_seed=false)
{

 */
function my_rand($min=null, $max=null, $force_seed=false)
{