Vergleich inc/functions.php - 1.2.11 - 1.2.14

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

 * Website: http://www.mybboard.net
* License: http://www.mybboard.net/eula.html
*

 * $Id: functions.php 3508 2007-11-23 16:10:16Z Tikitiki $

 * $Id: functions.php 3845 2008-05-18 17:50:09Z Tikitiki $

 */

/**

 */

/**

Zeile 378Zeile 378
	}

mail($to, $subject, $message, $headers);

	}

mail($to, $subject, $message, $headers);

 
}

/**
* Generates a unique code for POST requests to prevent XSS/CSRF attacks
*
* @return string The generated code
*/
function generate_post_check()
{
global $mybb;
if($mybb->user['uid'])
{
return md5($mybb->user['loginkey'].$mybb->user['salt'].$mybb->user['regdate']);
}
// Guests get a special string
else
{
return md5($mybb->config['hostname'].$mybb->config['username'].$mybb->config['password']);
}
}

/**
* Verifies a POST check code is valid, if not shows an error (silently returns false on silent parameter)
*
* @param string The incoming POST check code
* @param boolean Silent mode or not (silent mode will not show the error to the user but returns false)
*/
function verify_post_check($code, $silent=false)
{
global $lang;
if(generate_post_check() != $code)
{
if($silent == true)
{
return false;
}
else
{
error($lang->invalid_post_code);
}
}
else
{
return true;
}

}

/**

}

/**

Zeile 501Zeile 546
		$title = $lang->please_correct_errors;
}
if(!is_array($errors))

		$title = $lang->please_correct_errors;
}
if(!is_array($errors))

	{

	{

		$errors = array($errors);
}
foreach($errors as $error)

		$errors = array($errors);
}
foreach($errors as $error)

Zeile 622Zeile 667
		elseif($page == $pages-3)
{
$to = $page+3;

		elseif($page == $pages-3)
{
$to = $page+3;

		}

		}

		else
{
$to = $page+4;

		else
{
$to = $page+4;

Zeile 699Zeile 744
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);

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

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

		{

		{

			continue;
}
foreach($groupscache[$gid] as $perm => $access)

			continue;
}
foreach($groupscache[$gid] as $perm => $access)

Zeile 723Zeile 768
				if(isset($usergroup[$perm]))
{
$permbit = $usergroup[$perm];

				if(isset($usergroup[$perm]))
{
$permbit = $usergroup[$perm];

				}

				}

				else
{
$permbit = "";

				else
{
$permbit = "";

				}


				}


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

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

Zeile 741Zeile 786
				if($access > $permbit || ($access == "yes" && $permbit == "no") || !$permbit)
{
$usergroup[$perm] = $access;

				if($access > $permbit || ($access == "yes" && $permbit == "no") || !$permbit)
{
$usergroup[$perm] = $access;

				}
}
}

				}
}
}

	}
return $usergroup;

	}
return $usergroup;

}

/**

}

/**

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

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

 */

 */

function usergroup_displaygroup($gid)
{
global $cache, $groupscache, $displaygroupfields;

function usergroup_displaygroup($gid)
{
global $cache, $groupscache, $displaygroupfields;

Zeile 783Zeile 828
{
global $db, $cache, $groupscache, $forum_cache, $fpermcache, $mybb, $usercache, $fpermissionscache;
static $cached_forum_permissions;

{
global $db, $cache, $groupscache, $forum_cache, $fpermcache, $mybb, $usercache, $fpermissionscache;
static $cached_forum_permissions;

	if($uid == 0)

	if($uid == 0)

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

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

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

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

		{
if($usercache[$uid])
{

		{
if($usercache[$uid])
{

Zeile 824Zeile 869
	if($fid) // Fetch the permissions for a single forum
{
if(!$cached_forum_permissions[$gid][$fid])

	if($fid) // Fetch the permissions for a single forum
{
if(!$cached_forum_permissions[$gid][$fid])

		{

		{

			$cached_forum_permissions_permissions[$gid][$fid] = fetch_forum_permissions($fid, $gid, $groupperms);
}
return $cached_forum_permissions_permissions[$gid][$fid];

			$cached_forum_permissions_permissions[$gid][$fid] = fetch_forum_permissions($fid, $gid, $groupperms);
}
return $cached_forum_permissions_permissions[$gid][$fid];

	}

	}

	else
{
if(!$cached_forum_permissions[$gid])

	else
{
if(!$cached_forum_permissions[$gid])

Zeile 856Zeile 901
	global $groupscache, $forum_cache, $fpermcache, $mybb, $fpermfields;

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

	global $groupscache, $forum_cache, $fpermcache, $mybb, $fpermfields;

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



	

	if(!$fpermcache[$fid]) // This forum has no custom or inherited permisssions so lets just return the group permissions
{

	if(!$fpermcache[$fid]) // This forum has no custom or inherited permisssions so lets just return the group permissions
{

 
		$groupperms['fid'] = $fid;
$groupperms['gid'] = $gid;

		return $groupperms;
}


		return $groupperms;
}


Zeile 868Zeile 915
	{
if($groupscache[$gid])
{

	{
if($groupscache[$gid])
{

			// If this forum has permissions set
if($fpermcache[$fid][$gid])


























			$level_permissions = $fpermcache[$fid][$gid];

// If our permissions arn't inherited we need to figure them out
if(empty($level_permissions))
{
$parents = explode(',', $forum_cache[$fid]['parentlist']);
rsort($parents);
if(!empty($parents))
{
foreach($parents as $parent_id)
{
if(!empty($fpermcache[$parent_id][$gid]))
{
$level_permissions = $fpermcache[$parent_id][$gid];
break;
}
}

// If we STILL don't have forum permissions we use the usergroup itself
if(empty($level_permissions))
{
$level_permissions = $groupscache[$gid];
}
}
}

foreach($level_permissions as $permission => $access)

			{

			{

				$level_permissions = $fpermcache[$fid][$gid];
foreach($level_permissions as $permission => $access)

				if($access >= $current_permissions[$permission] || ($access == "yes" && $current_permissions[$permission] == "no") || !$current_permissions[$permission])


				{

				{

					if($access >= $current_permissions[$permission] || ($access == "yes" && $current_permissions[$permission] == "no") || !$current_permissions[$permission])
{
$current_permissions[$permission] = $access;
}

					$current_permissions[$permission] = $access;




				}
}
}

				}
}
}

Zeile 951Zeile 1019
			if(!$_COOKIE['forumpass'][$fid] || ($_COOKIE['forumpass'][$fid] && md5($mybb->user['uid'].$password) != $_COOKIE['forumpass'][$fid]))
{
$showform = true;

			if(!$_COOKIE['forumpass'][$fid] || ($_COOKIE['forumpass'][$fid] && md5($mybb->user['uid'].$password) != $_COOKIE['forumpass'][$fid]))
{
$showform = true;

			}

			}

			else
{
$showform = false;

			else
{
$showform = false;

Zeile 961Zeile 1029
	else
{
$showform = false;

	else
{
$showform = false;

	}

	}


if($showform)
{


if($showform)
{

Zeile 971Zeile 1039
		exit;
}
}

		exit;
}
}





/**
* Return the permissions for a moderator in a specific forum
*

/**
* Return the permissions for a moderator in a specific forum
*

Zeile 991Zeile 1059
	}

if(!isset($modpermscache[$fid][$uid]))

	}

if(!isset($modpermscache[$fid][$uid]))

	{

	{

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

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

Zeile 1001Zeile 1069
		$query = $db->simple_select(TABLE_PREFIX."moderators", "*", "uid='{$uid}' AND {$sql}");
$perms = $db->fetch_array($query);
$modpermscache[$fid][$uid] = $perms;

		$query = $db->simple_select(TABLE_PREFIX."moderators", "*", "uid='{$uid}' AND {$sql}");
$perms = $db->fetch_array($query);
$modpermscache[$fid][$uid] = $perms;

	}

	}

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

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

Zeile 1021Zeile 1089
function is_moderator($fid="0", $action="", $uid="0")
{
global $mybb, $db;

function is_moderator($fid="0", $action="", $uid="0")
{
global $mybb, $db;





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

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

Zeile 1031Zeile 1099
	if($user_perms['issupermod'] == "yes")
{
return "yes";

	if($user_perms['issupermod'] == "yes")
{
return "yes";

	}

	}

	else
{
if(!$fid)

	else
{
if(!$fid)

Zeile 1039Zeile 1107
			$query = $db->simple_select(TABLE_PREFIX.'moderators', 'COUNT(*) as count', "uid={$uid}", array('limit' => 1));
$modcheck = $db->fetch_array($query);
if($modcheck['count'] > 0)

			$query = $db->simple_select(TABLE_PREFIX.'moderators', 'COUNT(*) as count', "uid={$uid}", array('limit' => 1));
$modcheck = $db->fetch_array($query);
if($modcheck['count'] > 0)

			{
return "yes";
}

			{
return "yes";
}

			else
{
return "no";

			else
{
return "no";

			}
}

			}
}

		else
{
$modperms = get_moderator_permissions($fid, $uid);
if(!$action && $modperms)

		else
{
$modperms = get_moderator_permissions($fid, $uid);
if(!$action && $modperms)

			{

			{

				return "yes";
}
else

				return "yes";
}
else

Zeile 1071Zeile 1139

/**
* Generate a list of the posticons.


/**
* Generate a list of the posticons.

 *

 *

 * @return string The template of posticons.
*/
function get_post_icons()

 * @return string The template of posticons.
*/
function get_post_icons()

Zeile 1080Zeile 1148

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


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

	{

	{

		$icon = $mybb->input['icon'];
}
$no_icons_checked = " checked=\"checked\"";

		$icon = $mybb->input['icon'];
}
$no_icons_checked = " checked=\"checked\"";

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

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

		}

		}

		$listed++;
if($listed == 9)
{

		$listed++;
if($listed == 9)
{

Zeile 1109Zeile 1177
	}
eval("\$posticons = \"".$templates->get("posticons")."\";");
return $posticons;

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

}

/**

}

/**

 * MyBB setcookie() wrapper.
*
* @param string The cookie identifier.

 * MyBB setcookie() wrapper.
*
* @param string The cookie identifier.

Zeile 1191Zeile 1259
 * @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)

{

{

	if(!isset($_COOKIE['mybb'][$name]))
{
return false;

	if(!isset($_COOKIE['mybb'][$name]))
{
return false;

	}

	}

	$cookie = unserialize($_COOKIE['mybb'][$name]);
if(isset($cookie[$id]))
{
return $cookie[$id];

	$cookie = unserialize($_COOKIE['mybb'][$name]);
if(isset($cookie[$id]))
{
return $cookie[$id];

	}

	}

	else
{
return 0;
}

	else
{
return 0;
}

}

}


/**
* Set a serialised cookie array.


/**
* Set a serialised cookie array.

Zeile 1215Zeile 1283
 * @param string The value to set the cookie to.
*/
function my_set_array_cookie($name, $id, $value)

 * @param string The value to set the cookie to.
*/
function my_set_array_cookie($name, $id, $value)

{

{

	$cookie = $_COOKIE['mybb'];
$newcookie = unserialize($cookie[$name]);
$newcookie[$id] = $value;

	$cookie = $_COOKIE['mybb'];
$newcookie = unserialize($cookie[$name]);
$newcookie[$id] = $value;

Zeile 1231Zeile 1299
function get_server_load()
{
global $lang;

function get_server_load()
{
global $lang;





	$serverload = array();

if(my_strtolower(substr(PHP_OS, 0, 3)) !== 'win')

	$serverload = array();

if(my_strtolower(substr(PHP_OS, 0, 3)) !== 'win')

Zeile 1243Zeile 1311
		}
if(!$serverload)
{

		}
if(!$serverload)
{

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


			// Suhosin likes to throw a warning if exec is disabled then die - weird
if($func_blacklist = @ini_get('suhosin.executor.func.blacklist'))

			// Suhosin likes to throw a warning if exec is disabled then die - weird
if($func_blacklist = @ini_get('suhosin.executor.func.blacklist'))

			{
if(strpos(",".$func_blacklist.",", 'exec') !== false)
{

			{
if(strpos(",".$func_blacklist.",", 'exec') !== false)
{

					return $lang->unknown;
}
}
// PHP disabled functions?

					return $lang->unknown;
}
}
// PHP disabled functions?

			if($func_blacklist = @ini_get('disabled_functions'))

			if($func_blacklist = @ini_get('disable_functions'))

			{
if(strpos(",".$func_blacklist.",", 'exec') !== false)
{

			{
if(strpos(",".$func_blacklist.",", 'exec') !== false)
{

Zeile 1265Zeile 1338
			if(!is_array($serverload))
{
return $lang->unknown;

			if(!is_array($serverload))
{
return $lang->unknown;

			}
}
}
else

			}
}
}
else

	{
return $lang->unknown;
}

	{
return $lang->unknown;
}

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

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


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


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

			if(substr($changes[$counter], 0, 1) == "+" || substr($changes[$counter], 0, 1) == "-")
{
$update_query[$counter] = $forum[$counter] + $changes[$counter];

			if(substr($changes[$counter], 0, 1) == "+" || substr($changes[$counter], 0, 1) == "-")
{
$update_query[$counter] = $forum[$counter] + $changes[$counter];

Zeile 1556Zeile 1629
function update_thread_count($tid)
{
die("Depreciated function call: update_thread_count");

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

}

}

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

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

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

	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']];

Zeile 1658Zeile 1731
						$forumjumpbits .= build_forum_jump($forum['fid'], $selitem, 0, $newdepth, $showextras);
}
}

						$forumjumpbits .= build_forum_jump($forum['fid'], $selitem, 0, $newdepth, $showextras);
}
}

			}
}

			}
}

	}
if($addselect)
{
if(!$selecteddone)

	}
if($addselect)
{
if(!$selecteddone)

		{

		{

			if(!$selitem)
{
$selitem = "default";

			if(!$selitem)
{
$selitem = "default";

Zeile 1674Zeile 1747
		if($showextras == 0)
{
$template = "special";

		if($showextras == 0)
{
$template = "special";

		}
else
{

		}
else
{

			$template = "advanced";
}
eval("\$forumjump = \"".$templates->get("forumjump_".$template)."\";");

			$template = "advanced";
}
eval("\$forumjump = \"".$templates->get("forumjump_".$template)."\";");

Zeile 1998Zeile 2071
		"ipaddress" => $db->escape_string($session->ipaddress)
);
$db->insert_query(TABLE_PREFIX."moderatorlog", $sql_array);

		"ipaddress" => $db->escape_string($session->ipaddress)
);
$db->insert_query(TABLE_PREFIX."moderatorlog", $sql_array);

}

}


/**
* Get the formatted reputation for a user.


/**
* Get the formatted reputation for a user.

Zeile 2965Zeile 3038

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


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

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








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

	}
return $message;
}

	}
return $message;
}

Zeile 3053Zeile 3133

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



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


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

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

	{
--$age;
}

	{
--$age;
}