Vergleich inc/functions.php - 1.6.13 - 1.6.18

  Keine Änderungen   Hinzugefügt   Modifiziert   Entfernt
Zeile 21Zeile 21

$contents = parse_page($contents);
$totaltime = $maintimer->stop();


$contents = parse_page($contents);
$totaltime = $maintimer->stop();

 
	$contents = $plugins->run_hooks("pre_output_page", $contents);


if($mybb->usergroup['cancp'] == 1)
{


if($mybb->usergroup['cancp'] == 1)
{

Zeile 83Zeile 84
			$other = "PHP version: $phpversion / Server Load: $serverload / GZip Compression: $gzipen";
$debugstuff = "Generated in $totaltime seconds ($percentphp% PHP / $percentsql% ".$database_server.")<br />SQL Queries: $db->query_count / Global Parsing Time: $globaltime$memory_usage<br />$other<br />[<a href=\"$debuglink\" target=\"_blank\">advanced details</a>]<br />";
$contents = str_replace("<debugstuff>", $debugstuff, $contents);

			$other = "PHP version: $phpversion / Server Load: $serverload / GZip Compression: $gzipen";
$debugstuff = "Generated in $totaltime seconds ($percentphp% PHP / $percentsql% ".$database_server.")<br />SQL Queries: $db->query_count / Global Parsing Time: $globaltime$memory_usage<br />$other<br />[<a href=\"$debuglink\" target=\"_blank\">advanced details</a>]<br />";
$contents = str_replace("<debugstuff>", $debugstuff, $contents);

		}

		}


if($mybb->debug_mode == true)
{


if($mybb->debug_mode == true)
{

Zeile 92Zeile 93
	}

$contents = str_replace("<debugstuff>", "", $contents);

	}

$contents = str_replace("<debugstuff>", "", $contents);

	$contents = $plugins->run_hooks("pre_output_page", $contents);

 

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


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

Zeile 743Zeile 743
		"location2" => 0
);


		"location2" => 0
);


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

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


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


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

Zeile 1329Zeile 1329
/**
* Check the password given on a certain forum for validity
*

/**
* Check the password given on a certain forum for validity
*

 * @param int The forum ID
* @param boolean The Parent ID



 * @param int $fid The forum ID
* @param int $pid The Parent ID
* @param bool $return
* @return bool

 */

 */

function check_forum_password($fid, $pid=0)

function check_forum_password($fid, $pid=0, $return=false)

{
global $mybb, $header, $footer, $headerinclude, $theme, $templates, $lang, $forum_cache;

{
global $mybb, $header, $footer, $headerinclude, $theme, $templates, $lang, $forum_cache;





	$showform = true;

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

	$showform = true;

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

		{

		{

			return false;
}
}

			return false;
}
}

Zeile 1360Zeile 1362
			}

if($forum_cache[$parent_id]['password'] != "")

			}

if($forum_cache[$parent_id]['password'] != "")

			{

			{

				check_forum_password($parent_id, $fid);
}
}

				check_forum_password($parent_id, $fid);
}
}

Zeile 1397Zeile 1399
	else
{
$showform = false;

	else
{
$showform = false;

 
	}

if($return)
{
return $showform;

	}

if($showform)

	}

if($showform)

Zeile 1466Zeile 1473

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



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


	foreach($mod_cache as $fid => $forum)

	foreach($mod_cache as $forumid => $forum)

	{

	{

		if(!is_array($forum) || !in_array($fid, $parentslist))

		if(!is_array($forum) || !in_array($forumid, $parentslist))

		{
// No perms or we're not after this forum
continue;

		{
// No perms or we're not after this forum
continue;

Zeile 1478Zeile 1485
		if(is_array($forum['users'][$uid]))
{
$perm = $forum['users'][$uid];

		if(is_array($forum['users'][$uid]))
{
$perm = $forum['users'][$uid];

			foreach($perm as $action => $value)
{
if(strpos($action, "can") === false)
{
continue;

			foreach($perm as $action => $value)
{
if(strpos($action, "can") === false)
{
continue;

				}

// Figure out the user permissions

				}

// Figure out the user permissions

Zeile 1542Zeile 1549
	}

if($uid == 0)

	}

if($uid == 0)

	{

	{

		return false;
}

$user_perms = user_permissions($uid);
if($user_perms['issupermod'] == 1)
{

		return false;
}

$user_perms = user_permissions($uid);
if($user_perms['issupermod'] == 1)
{

 
		if($fid)
{
$forumpermissions = forum_permissions($fid);
if($forumpermissions['canview'] && $forumpermissions['canviewthreads'] && !$forumpermissions['canonlyviewownthreads'])
{
return true;
}
return false;
}

		return true;
}
else

		return true;
}
else

Zeile 1561Zeile 1577
				foreach($modcache as $modusers)
{
if(isset($modusers['users'][$uid]) && $modusers['users'][$uid]['mid'])

				foreach($modcache as $modusers)
{
if(isset($modusers['users'][$uid]) && $modusers['users'][$uid]['mid'])

					{

					{

						return true;
}
elseif(isset($modusers['usergroups'][$user_perms['gid']]))
{
// Moderating usergroup
return true;

						return true;
}
elseif(isset($modusers['usergroups'][$user_perms['gid']]))
{
// Moderating usergroup
return true;

					}
}
}
return false;

					}
}
}
return false;

		}
else
{
$modperms = get_moderator_permissions($fid, $uid);

if(!$action && $modperms)

		}
else
{
$modperms = get_moderator_permissions($fid, $uid);

if(!$action && $modperms)

			{

			{

				return true;
}
else
{
if($modperms[$action] == 1)

				return true;
}
else
{
if($modperms[$action] == 1)

				{

				{

					return true;

					return true;

				}

				}

				else
{
return false;
}
}

				else
{
return false;
}
}

		}
}
}

/**

		}
}
}

/**

 * Generate a list of the posticons.
*
* @return string The template of posticons.

 * Generate a list of the posticons.
*
* @return string The template of posticons.

Zeile 1643Zeile 1659
			$iconlist .= "<br />";
$listed = 0;
}

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

	}


	}


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

return $posticons;

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

return $posticons;

Zeile 1668Zeile 1684
	}

if($expires == -1)

	}

if($expires == -1)

	{

	{

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

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

Zeile 1693Zeile 1709
	}

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

	}

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

	{

	{

		$cookie .= "; path={$mybb->settings['cookiepath']}";

		$cookie .= "; path={$mybb->settings['cookiepath']}";

	}


	}


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

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

	{

	{

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

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

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

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

	}

	}


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



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


Zeile 1729Zeile 1745

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

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

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

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

	}

	}


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



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


Zeile 1765Zeile 1781
function my_set_array_cookie($name, $id, $value, $expires="")
{
global $mybb;

function my_set_array_cookie($name, $id, $value, $expires="")
{
global $mybb;





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

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





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

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





	// Make sure our current viarables are up-to-date as well
$mybb->cookies['mybb'][$name] = $newcookie;

	// Make sure our current viarables are up-to-date as well
$mybb->cookies['mybb'][$name] = $newcookie;

}

/**

}

/**

 * Verifies that data passed is an array
*
* @param array Data to unserialize

 * Verifies that data passed is an array
*
* @param array Data to unserialize

Zeile 1785Zeile 1801
 */
function my_unserialize($data)
{

 */
function my_unserialize($data)
{

 
	// Do no unserialize objects
if(substr($data, 0, 1) == 'O')
{
return array();
}


	$array = unserialize($data);

if(!is_array($array))

	$array = unserialize($data);

if(!is_array($array))

Zeile 1813Zeile 1835
		{
// 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"))

		{

		{

			$serverload = explode(" ", $load);
$serverload[0] = round($serverload[0], 4);
}
if(!is_numeric($serverload[0]))
{
if(@ini_get('safe_mode') == 'On')

			$serverload = explode(" ", $load);
$serverload[0] = round($serverload[0], 4);
}
if(!is_numeric($serverload[0]))
{
if(@ini_get('safe_mode') == 'On')

			{
return $lang->unknown;
}

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

Zeile 1837Zeile 1859
			}
// PHP disabled functions?
if($func_blacklist = @ini_get('disable_functions'))

			}
// PHP disabled functions?
if($func_blacklist = @ini_get('disable_functions'))

			{

			{

				if(strpos(",".$func_blacklist.",", 'exec') !== false)
{
return $lang->unknown;

				if(strpos(",".$func_blacklist.",", 'exec') !== false)
{
return $lang->unknown;

Zeile 1861Zeile 1883
	$returnload = trim($serverload[0]);

return $returnload;

	$returnload = trim($serverload[0]);

return $returnload;

}

}


/**
* Returns the amount of memory allocated to the script.


/**
* Returns the amount of memory allocated to the script.

Zeile 1958Zeile 1980
 *
* @param int The forum ID
* @param array Array of items being updated (threads, posts, unapprovedthreads, unapprovedposts) and their value (ex, 1, +1, -1)

 *
* @param int The forum ID
* @param array Array of items being updated (threads, posts, unapprovedthreads, unapprovedposts) and their value (ex, 1, +1, -1)

 */

 */

function update_forum_counters($fid, $changes=array())
{
global $db, $cache;

function update_forum_counters($fid, $changes=array())
{
global $db, $cache;

Zeile 2149Zeile 2171

/**
* Update the first post and lastpost data for a specific thread


/**
* Update the first post and lastpost data for a specific thread

 *
* @param int The thread ID
*/

 *
* @param int The thread ID
*/

function update_thread_data($tid)
{
global $db;

function update_thread_data($tid)
{
global $db;





	$thread = get_thread($tid);

// If this is a moved thread marker, don't update it - we need it to stay as it is
if(strpos($thread['closed'], 'moved|') !== false)

	$thread = get_thread($tid);

// If this is a moved thread marker, don't update it - we need it to stay as it is
if(strpos($thread['closed'], 'moved|') !== false)

	{

	{

		return false;
}


		return false;
}


Zeile 2171Zeile 2193
		WHERE p.tid='$tid' AND p.visible='1'
ORDER BY p.dateline DESC
LIMIT 1"

		WHERE p.tid='$tid' AND p.visible='1'
ORDER BY p.dateline DESC
LIMIT 1"

	);

	);

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

$db->free_result($query);

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

$db->free_result($query);

Zeile 2194Zeile 2216
	}

if(!$lastpost['username'])

	}

if(!$lastpost['username'])

	{

	{

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


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


Zeile 2217Zeile 2239
		'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);

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

}

}


function update_forum_count($fid)


function update_forum_count($fid)

{

{

	die("Deprecated function call: update_forum_count");
}
function update_thread_count($tid)
{
die("Deprecated function call: update_thread_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_attachment_count($tid)

{

{

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

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





/**
* Deletes a thread from the database
*
* @param int The thread ID
*/
function delete_thread($tid)

/**
* Deletes a thread from the database
*
* @param int The thread ID
*/
function delete_thread($tid)

{
global $moderation;

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


{
global $moderation;

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


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


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


Zeile 2260Zeile 2282
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 2296Zeile 2318
	}

if(!is_array($jumpfcache))

	}

if(!is_array($jumpfcache))

	{

	{

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

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

Zeile 2342Zeile 2364
					{
$newdepth = $depth."--";
$forumjumpbits .= build_forum_jump($forum['fid'], $selitem, 0, $newdepth, $showextras, $showall);

					{
$newdepth = $depth."--";
$forumjumpbits .= build_forum_jump($forum['fid'], $selitem, 0, $newdepth, $showextras, $showall);

					}
}
}

					}
}
}

		}
}

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

		}
}

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

		{

		{

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

$jumpsel[$selitem] = 'selected="selected"';

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

$jumpsel[$selitem] = 'selected="selected"';

		}

		}


if($showextras == 0)
{


if($showextras == 0)
{

Zeile 2371Zeile 2393
			if(strpos(FORUM_URL, '.html') !== false)
{
$forum_link = "'".str_replace('{fid}', "'+this.options[this.selectedIndex].value+'", FORUM_URL)."'";

			if(strpos(FORUM_URL, '.html') !== false)
{
$forum_link = "'".str_replace('{fid}', "'+this.options[this.selectedIndex].value+'", FORUM_URL)."'";

			}

			}

			else
{
$forum_link = "'".str_replace('{fid}', "'+this.options[this.selectedIndex].value", FORUM_URL);

			else
{
$forum_link = "'".str_replace('{fid}', "'+this.options[this.selectedIndex].value", FORUM_URL);

Zeile 2382Zeile 2404
	}

return $forumjump;

	}

return $forumjump;

}

/**

}

/**

 * Returns the extension of a file.
*
* @param string The filename.

 * Returns the extension of a file.
*
* @param string The filename.

Zeile 2397Zeile 2419

/**
* Generates a random string.


/**
* Generates a random string.

 *

 *

 * @param int The length of the string to generate.
* @return string The random string.
*/

 * @param int The length of the string to generate.
* @return string The random string.
*/

Zeile 2410Zeile 2432
	{
$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 2430Zeile 2452
	if(!is_array($groupscache))
{
$groupscache = $cache->read("usergroups");

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

	}


	}


	if($displaygroup != 0)
{
$usergroup = $displaygroup;

	if($displaygroup != 0)
{
$usergroup = $displaygroup;

	}


	}


	$ugroup = $groupscache[$usergroup];
$format = $ugroup['namestyle'];
$userin = substr_count($format, "{username}");

	$ugroup = $groupscache[$usergroup];
$format = $ugroup['namestyle'];
$userin = substr_count($format, "{username}");

Zeile 2449Zeile 2471
	$format = stripslashes($format);

return str_replace("{username}", $username, $format);

	$format = stripslashes($format);

return str_replace("{username}", $username, $format);

}

}


/**
* Build the javascript based MyCode inserter


/**
* Build the javascript based MyCode inserter

Zeile 2553Zeile 2575
		{
$smilie_cache = $cache->read("smilies");
$smiliecount = count($smilie_cache);

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

		}


		}


		if(!$smiliecache)
{
if(!is_array($smilie_cache))

		if(!$smiliecache)
{
if(!is_array($smilie_cache))

Zeile 2712Zeile 2734
	if($mybb->user['additionalgroups'])
{
$exp = explode(",", $mybb->user['additionalgroups']);

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





		foreach($exp as $group)
{
$groups[] = $group;

		foreach($exp as $group)
{
$groups[] = $group;

Zeile 2732Zeile 2754
			{
// This prefix is not in our forum list
continue;

			{
// This prefix is not in our forum list
continue;

			}

			}

		}

		}





		if($prefix['groups'] != "-1")

		if($prefix['groups'] != "-1")

		{
$prefix_groups = explode(",", $prefix['groups']);


		{
$prefix_groups = explode(",", $prefix['groups']);


			foreach($groups as $group)
{
if(in_array($group, $prefix_groups) && !isset($prefixes[$prefix['pid']]))

			foreach($groups as $group)
{
if(in_array($group, $prefix_groups) && !isset($prefixes[$prefix['pid']]))

Zeile 2758Zeile 2780
	if(empty($prefixes))
{
return false;

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

	}

	}


$prefixselect = "";


$prefixselect = "";

	$multipleselect = "";

 
	if($multiple != 0)
{

	if($multiple != 0)
{

		$multipleselect = " multiple=\"multiple\" size=\"5\"";





		$prefixselect = "<select name=\"threadprefix[]\" multiple=\"multiple\" size=\"5\">\n";
}
else
{
$prefixselect = "<select name=\"threadprefix\">\n";

	}

	}


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

 

if($multiple == 1)
{


if($multiple == 1)
{

Zeile 2987Zeile 3010

$ip = 0;



$ip = 0;


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

	if(!preg_match("#^(10|172\.(1[6-9]|2[0-9]|3[0-1])|192\.168)\.#", $_SERVER['REMOTE_ADDR']))

	{
$ip = $_SERVER['REMOTE_ADDR'];
}

	{
$ip = $_SERVER['REMOTE_ADDR'];
}

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

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

				if(!preg_match("#^(10|172\.16|192\.168)\.#", $val))

				if(!preg_match("#^(10|172\.(1[6-9]|2[0-9]|3[0-1])|192\.168)\.#", $val))

				{
$ip = $val;
break;

				{
$ip = $val;
break;

Zeile 3136Zeile 3159
		{
$icon = str_replace("{theme}", $theme['imgdir'], $attachtypes[$ext]['icon']);
}

		{
$icon = str_replace("{theme}", $theme['imgdir'], $attachtypes[$ext]['icon']);
}

 
		$icon = htmlspecialchars_uni($icon);

		return "<img src=\"{$icon}\" border=\"0\" alt=\".{$ext}\" />";
}
else

		return "<img src=\"{$icon}\" border=\"0\" alt=\".{$ext}\" />";
}
else

Zeile 3147Zeile 3171
		else if(defined("IN_PORTAL"))
{
global $change_dir;

		else if(defined("IN_PORTAL"))
{
global $change_dir;

			$theme['imgdir'] = "{$change_dir}/images";

			$theme['imgdir'] = htmlspecialchars_uni("{$change_dir}/images");

		}

return "<img src=\"{$theme['imgdir']}/attachtypes/unknown.gif\" border=\"0\" alt=\".{$ext}\" />";

		}

return "<img src=\"{$theme['imgdir']}/attachtypes/unknown.gif\" border=\"0\" alt=\".{$ext}\" />";

Zeile 3278Zeile 3302
				$multipage_dropdown = null;
if(!empty($navbit['multipage']))
{

				$multipage_dropdown = null;
if(!empty($navbit['multipage']))
{

 
					if(!$mybb->settings['threadsperpage'] || (int)$mybb->settings['threadsperpage'] < 1)
{
$mybb->settings['threadsperpage'] = 20;
}


					$multipage = multipage($navbit['multipage']['num_threads'], $mybb->settings['threadsperpage'], $navbit['multipage']['current_page'], $navbit['multipage']['url'], true);
if($multipage)
{

					$multipage = multipage($navbit['multipage']['num_threads'], $mybb->settings['threadsperpage'], $navbit['multipage']['current_page'], $navbit['multipage']['url'], true);
if($multipage)
{

Zeile 4668Zeile 4697
	$event['username'] = format_name($event['username'], $event['usergroup'], $event['displaygroup']);
$event_poster = build_profile_link($event['username'], $event['author']);
return $event_poster;

	$event['username'] = format_name($event['username'], $event['usergroup'], $event['displaygroup']);
$event_poster = build_profile_link($event['username'], $event['author']);
return $event_poster;

}

}


/**
* Get the event date.


/**
* Get the event date.

Zeile 4692Zeile 4721
 *
* @param int The user id of the profile.
* @return string The url to the profile.

 *
* @param int The user id of the profile.
* @return string The url to the profile.

 */

 */

function get_profile_link($uid=0)
{
$link = str_replace("{uid}", $uid, PROFILE_URL);

function get_profile_link($uid=0)
{
$link = str_replace("{uid}", $uid, PROFILE_URL);

Zeile 4704Zeile 4733
 *
* @param int The announement id of the announcement.
* @return string The url to the announcement.

 *
* @param int The announement id of the announcement.
* @return string The url to the announcement.

 */

 */

function get_announcement_link($aid=0)
{
$link = str_replace("{aid}", $aid, ANNOUNCEMENT_URL);

function get_announcement_link($aid=0)
{
$link = str_replace("{aid}", $aid, ANNOUNCEMENT_URL);

Zeile 4763Zeile 4792
	if($page > 0)
{
$link = str_replace("{fid}", $fid, FORUM_URL_PAGED);

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

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

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

	}
else
{

	}
else
{

Zeile 4954Zeile 4983
	}

if(!$forum_cache[$fid])

	}

if(!$forum_cache[$fid])

	{
return false;
}


	{
return false;
}


	if($active_override != 1)
{
$parents = explode(",", $forum_cache[$fid]['parentlist']);

	if($active_override != 1)
{
$parents = explode(",", $forum_cache[$fid]['parentlist']);

Zeile 4991Zeile 5020
	if(isset($thread_cache[$tid]) && !$recache)
{
return $thread_cache[$tid];

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

	}
else
{

	}
else
{

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

if($thread)

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

if($thread)

		{

		{

			$thread_cache[$tid] = $thread;
return $thread;
}
else
{
$thread_cache[$tid] = false;

			$thread_cache[$tid] = $thread;
return $thread;
}
else
{
$thread_cache[$tid] = false;

			return false;

			return false;

		}
}
}

		}
}
}

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

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

{

{

	global $db;
static $post_cache;

if(isset($post_cache[$pid]))

	global $db;
static $post_cache;

if(isset($post_cache[$pid]))

	{

	{

		return $post_cache[$pid];
}
else
{
$query = $db->simple_select("posts", "*", "pid='".intval($pid)."'");
$post = $db->fetch_array($query);

		return $post_cache[$pid];
}
else
{
$query = $db->simple_select("posts", "*", "pid='".intval($pid)."'");
$post = $db->fetch_array($query);





		if($post)
{
$post_cache[$pid] = $post;

		if($post)
{
$post_cache[$pid] = $post;

Zeile 5053Zeile 5082
	global $forum_cache, $cache, $inactiveforums;

if(!$forum_cache)

	global $forum_cache, $cache, $inactiveforums;

if(!$forum_cache)

	{

	{

		cache_forums();
}


		cache_forums();
}


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

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

			}
return true;

			}
return true;

		}
}
// Still here - good username

		}
}
// Still here - good username

Zeile 5454Zeile 5483
 * @param string The email address.
* @param boolean True if the 'last used' dateline should be updated if a match is found.
* @return boolean True if banned, false if not banned

 * @param string The email address.
* @param boolean True if the 'last used' dateline should be updated if a match is found.
* @return boolean True if banned, false if not banned

 */

 */

function is_banned_email($email, $update_lastuse=false)
{
global $cache, $db;

function is_banned_email($email, $update_lastuse=false)
{
global $cache, $db;

Zeile 5466Zeile 5495
		// Failed to read cache, see if we can rebuild it
$cache->update_bannedemails();
$banned_cache = $cache->read("bannedemails");

		// Failed to read cache, see if we can rebuild it
$cache->update_bannedemails();
$banned_cache = $cache->read("bannedemails");

	}

	}


if(is_array($banned_cache) && !empty($banned_cache))
{


if(is_array($banned_cache) && !empty($banned_cache))
{

Zeile 5488Zeile 5517
	}

// Still here - good email

	}

// Still here - good email

	return false;
}


	return false;
}


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

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

Zeile 5513Zeile 5542
		if(!$banned_ip['filter'])
{
continue;

		if(!$banned_ip['filter'])
{
continue;

		}


		}


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

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

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

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

 */

 */

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

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

Zeile 5610Zeile 5639
			$label = $lang->sprintf($lang->timezone_gmt_short, $label." ", $time_in_zone);
}
$select .= "<option value=\"{$timezone}\"{$selected_add}>{$label}</option>\n";

			$label = $lang->sprintf($lang->timezone_gmt_short, $label." ", $time_in_zone);
}
$select .= "<option value=\"{$timezone}\"{$selected_add}>{$label}</option>\n";

	}

	}

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

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

Zeile 5634Zeile 5663
	}

if(function_exists("curl_init"))

	}

if(function_exists("curl_init"))

	{

	{

		$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, 0);

		$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, 0);

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

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

		{

		{

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

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

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

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

		}
else

		}
else

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

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

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

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

		}

		}

		else
{
// If we have no post body, we need to add an empty element to make sure we've got \r\n\r\n before the (non-existent) body starts

		else
{
// If we have no post body, we need to add an empty element to make sure we've got \r\n\r\n before the (non-existent) body starts

Zeile 5730Zeile 5759
 * @return boolean True if a super admin, false if not
*/
function is_super_admin($uid)

 * @return boolean True if a super admin, false if not
*/
function is_super_admin($uid)

{
global $mybb;

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






{
static $super_admins;

if(!isset($super_admins))
{
global $mybb;
$super_admins = str_replace(" ", "", $mybb->config['super_admins']);
}

if(my_strpos(",{$super_admins},", ",{$uid},") === false)
{

		return false;

		return false;

	}

	}

	else

	else

	{

	{

		return true;
}

		return true;
}

 
}

/**
* Prevents super administrators being selected in a SELECT.
*
* @param boolean Prefix with an AND?
* @param string The prefix to add to uid when used in a JOIN (e.g. SELECTing users u would mean using 'u' in this argument).
* @return string An addition to the WHERE statement
*/
function not_super_admins($use_and = false, $uid_prefix = '')
{
static $super_admins;

if(!isset($super_admins))
{
global $mybb, $db;
$super_admins = $db->escape_string(str_replace(" ", "", $mybb->config['super_admins']));
}

if($super_admins)
{
$sql_where = '';
if($use_and)
{
$sql_where .= ' AND ';
}

if($uid_prefix != '')
{
$sql_where .= $uid_prefix.'.';
}

$sql_where .= "uid NOT IN({$super_admins})";

return $sql_where;
}
return '';

}

/**

}

/**

Zeile 5769Zeile 5840
			$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)
{
if($string != "")

		$quoted_strings = array($string);
}
foreach($quoted_strings as $string)
{
if($string != "")

		{

		{

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

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

Zeile 5817Zeile 5888
	$ip_string1 = $ip_string2 = "";

if($ip == "*")

	$ip_string1 = $ip_string2 = "";

if($ip == "*")

	{

	{

		return array(my_ip2long('128.0.0.0'), my_ip2long('127.255.255.255'));
}


		return array(my_ip2long('128.0.0.0'), my_ip2long('127.255.255.255'));
}


Zeile 5825Zeile 5896
	{
$ip = str_replace("*", "", $ip);
if(count($ip_bits) == 4)

	{
$ip = str_replace("*", "", $ip);
if(count($ip_bits) == 4)

		{

		{

			return my_ip2long($ip);

			return my_ip2long($ip);

		}
else
{

		}
else
{

			return array(my_ip2long($ip.".0"), my_ip2long($ip.".255"));
}
}

			return array(my_ip2long($ip.".0"), my_ip2long($ip.".255"));
}
}

Zeile 6021Zeile 6092
	}

return @unlink($path);

	}

return @unlink($path);

}


}


/**
* Counts the number of subforums in a array([pid][disporder][fid]) starting from the pid
*

/**
* Counts the number of subforums in a array([pid][disporder][fid]) starting from the pid
*

Zeile 6209Zeile 6280
function secure_seed_rng($count=8)
{
$output = '';

function secure_seed_rng($count=8)
{
$output = '';


// Use OpenSSL when available
// PHP <5.3.4 had a bug which makes that function unusable on Windows
if(function_exists('openssl_random_pseudo_bytes') && version_compare(PHP_VERSION, '5.3.4', '>='))
{
$output = openssl_random_pseudo_bytes($count);















	// DIRECTORY_SEPARATOR checks if running windows
if(DIRECTORY_SEPARATOR != '\\')
{
// Unix/Linux
// Use OpenSSL when available
if(function_exists('openssl_random_pseudo_bytes'))
{
$output = openssl_random_pseudo_bytes($count);
}
// Try mcrypt
elseif(function_exists('mcrypt_create_iv'))
{
$output = mcrypt_create_iv($count, MCRYPT_DEV_URANDOM);
}
// Try /dev/urandom
elseif(@is_readable('/dev/urandom') && ($handle = @fopen('/dev/urandom', 'rb')))
{
$output = @fread($handle, $count);
@fclose($handle);
}

	}

	}

	// Try the unix/linux method
elseif(@is_readable('/dev/urandom') && ($handle = @fopen('/dev/urandom', 'rb')))

	else


	{

	{

		$output = @fread($handle, $count);
@fclose($handle);
}
// Try Windows CAPICOM before using our own generator
elseif(class_exists('COM'))
{
try

		// Windows
// Use OpenSSL when available
// PHP <5.3.4 had a bug which makes that function unusable on Windows
if(function_exists('openssl_random_pseudo_bytes') && version_compare(PHP_VERSION, '5.3.4', '>='))




		{

		{

			$CAPI_Util = new COM('CAPICOM.Utilities.1');
$output = $CAPI_Util->GetRandom($count, 0);
} catch (Exception $ex) {

















			$output = openssl_random_pseudo_bytes($count);
}
// Try mcrypt
elseif(function_exists('mcrypt_create_iv'))
{
$output = mcrypt_create_iv($count, MCRYPT_RAND);
}
// Try Windows CAPICOM before using our own generator
elseif(class_exists('COM'))
{
try
{
$CAPI_Util = new COM('CAPICOM.Utilities.1');
if(is_callable(array($CAPI_Util, 'GetRandom')))
{
$output = $CAPI_Util->GetRandom($count, 0);
}
} catch (Exception $e) {
}

		}
}


		}
}


Zeile 6301Zeile 6398
}

/**

}

/**

 * More robust version of PHP's trim() function. It includes a list of UTF-16 blank characters

 * More robust version of PHP's trim() function. It includes a list of UTF-8 blank characters

 * from http://kb.mozillazine.org/Network.IDN.blacklist_chars
*
* @param string The string to trim from

 * from http://kb.mozillazine.org/Network.IDN.blacklist_chars
*
* @param string The string to trim from

Zeile 6311Zeile 6408
function trim_blank_chrs($string, $charlist=false)
{
$hex_chrs = array(

function trim_blank_chrs($string, $charlist=false)
{
$hex_chrs = array(

		0x20 => 1,
0x09 => 1,
0x0A => 1,
0x0D => 1,
0x0B => 1,
0xAD => 1,
0xA0 => 1,
0xAD => 1,
0xBF => 1,
0x81 => 1,
0x8D => 1,
0x90 => 1,
0x9D => 1,
0xCC => array(0xB7 => 1, 0xB8 => 1), // \x{0337} or \x{0338}
0xE1 => array(0x85 => array(0x9F => 1, 0xA0 => 1)), // \x{115F} or \x{1160}
0xE2 => array(0x80 => array(0x80 => 1, 0x81 => 1, 0x82 => 1, 0x83 => 1, 0x84 => 1, 0x85 => 1, 0x86 => 1, 0x87 => 1, 0x88 => 1, 0x89 => 1, 0x8A => 1, 0x8B => 1, // \x{2000} to \x{200B}
0xA8 => 1, 0xA9 => 1, 0xAA => 1, 0xAB => 1, 0xAC => 1, 0xAD => 1, 0xAE => 1, 0xAF => 1), // \x{2028} to \x{202F}
0x81 => array(0x9F => 1)), // \x{205F}

		0x09 => 1, // \x{0009}
0x0A => 1, // \x{000A}
0x0B => 1, // \x{000B}
0x0D => 1, // \x{000D}
0x20 => 1, // \x{0020}
0xC2 => array(0x81 => 1, 0x8D => 1, 0x90 => 1, 0x9D => 1, 0xA0 => 1, 0xAD => 1), // \x{0081}, \x{008D}, \x{0090}, \x{009D}, \x{00A0}, \x{00AD}
0xCC => array(0xB7 => 1, 0xB8 => 1), // \x{0337}, \x{0338}
0xE1 => array(0x85 => array(0x9F => 1, 0xA0 => 1), 0x9A => array(0x80 => 1), 0xA0 => array(0x8E => 1)), // \x{115F}, \x{1160}, \x{1680}, \x{180E}
0xE2 => array(0x80 => array(0x80 => 1, 0x81 => 1, 0x82 => 1, 0x83 => 1, 0x84 => 1, 0x85 => 1, 0x86 => 1, 0x87 => 1, 0x88 => 1, 0x89 => 1, 0x8A => 1, 0x8B => 1, 0x8C => 1, 0x8D => 1, 0x8E => 1, 0x8F => 1, // \x{2000} - \x{200F}
0xA8 => 1, 0xA9 => 1, 0xAA => 1, 0xAB => 1, 0xAC => 1, 0xAD => 1, 0xAE => 1, 0xAF => 1), // \x{2028} - \x{202F}
0x81 => array(0x9F => 1)), // \x{205F}








		0xE3 => array(0x80 => array(0x80 => 1), // \x{3000}

		0xE3 => array(0x80 => array(0x80 => 1), // \x{3000}

					  0x85 => array(0xA4 => 1)), // \x{3164}

			0x85 => array(0xA4 => 1)), // \x{3164}

		0xEF => array(0xBB => array(0xBF => 1), // \x{FEFF}

		0xEF => array(0xBB => array(0xBF => 1), // \x{FEFF}

					  0xBE => array(0xA0 => 1), // \x{FFA0}
0xBF => array(0xB9 => 1, 0xBA => 1, 0xBB => 1)), // \x{FFF9} to \x{FFFB}

			0xBE => array(0xA0 => 1), // \x{FFA0}
0xBF => array(0xB9 => 1, 0xBA => 1, 0xBB => 1)), // \x{FFF9} - \x{FFFB}

	);

$hex_chrs_rev = array(

	);

$hex_chrs_rev = array(

		0x20 => 1,
0x09 => 1,
0x0A => 1,
0x0D => 1,
0x0B => 1,
0xA0 => array(0xC2 => 1),
0xAD => array(0xC2 => 1),
0xBF => array(0xC2 => 1),
0x81 => array(0xC2 => 1),
0x8D => array(0xC2 => 1),
0x90 => array(0xC2 => 1),
0x9D => array(0xC2 => 1),

		0x09 => 1, // \x{0009}
0x0A => 1, // \x{000A}
0x0B => 1, // \x{000B}
0x0D => 1, // \x{000D}
0x20 => 1, // \x{0020}
0x81 => array(0xC2 => 1, 0x80 => array(0xE2 => 1)), // \x{0081}, \x{2001}
0x8D => array(0xC2 => 1, 0x80 => array(0xE2 => 1)), // \x{008D}, \x{200D}
0x90 => array(0xC2 => 1), // \x{0090}
0x9D => array(0xC2 => 1), // \x{009D}
0xA0 => array(0xC2 => 1, 0x85 => array(0xE1 => 1), 0x81 => array(0xE2 => 1), 0xBE => array(0xEF => 1)), // \x{00A0}, \x{1160}, \x{2060}, \x{FFA0}
0xAD => array(0xC2 => 1, 0x80 => array(0xE2 => 1)), // \x{00AD}, \x{202D}


		0xB8 => array(0xCC => 1), // \x{0338}
0xB7 => array(0xCC => 1), // \x{0337}

		0xB8 => array(0xCC => 1), // \x{0338}
0xB7 => array(0xCC => 1), // \x{0337}

		0xA0 => array(0x85 => array(0xE1 => 1)), // \x{1160}
0x9F => array(0x85 => array(0xE1 => 1), // \x{115F}
0x81 => array(0xE2 => 1)), // \x{205F}
0x80 => array(0x80 => array(0xE3 => 1, 0xE2 => 1)), // \x{3000}, \x{2000}
0x81 => array(0x80 => array(0xE2 => 1)), // \x{2001}

		0x9F => array(0x85 => array(0xE1 => 1), 0x81 => array(0xE2 => 1)), // \x{115F}, \x{205F}
0x80 => array(0x9A => array(0xE1 => 1), 0x80 => array(0xE2 => 1, 0xE3 => 1)), // \x{1680}, \x{2000}, \x{3000}
0x8E => array(0xA0 => array(0xE1 => 1), 0x80 => array(0xE2 => 1)), // \x{180E}, \x{200E}



		0x82 => array(0x80 => array(0xE2 => 1)), // \x{2002}
0x83 => array(0x80 => array(0xE2 => 1)), // \x{2003}
0x84 => array(0x80 => array(0xE2 => 1)), // \x{2004}

		0x82 => array(0x80 => array(0xE2 => 1)), // \x{2002}
0x83 => array(0x80 => array(0xE2 => 1)), // \x{2003}
0x84 => array(0x80 => array(0xE2 => 1)), // \x{2004}

Zeile 6366Zeile 6453
		0x89 => array(0x80 => array(0xE2 => 1)), // \x{2009}
0x8A => array(0x80 => array(0xE2 => 1)), // \x{200A}
0x8B => array(0x80 => array(0xE2 => 1)), // \x{200B}

		0x89 => array(0x80 => array(0xE2 => 1)), // \x{2009}
0x8A => array(0x80 => array(0xE2 => 1)), // \x{200A}
0x8B => array(0x80 => array(0xE2 => 1)), // \x{200B}

 
		0x8C => array(0x80 => array(0xE2 => 1)), // \x{200C}
0x8F => array(0x80 => array(0xE2 => 1)), // \x{200F}

		0xA8 => array(0x80 => array(0xE2 => 1)), // \x{2028}
0xA9 => array(0x80 => array(0xE2 => 1)), // \x{2029}
0xAA => array(0x80 => array(0xE2 => 1)), // \x{202A}
0xAB => array(0x80 => array(0xE2 => 1)), // \x{202B}
0xAC => array(0x80 => array(0xE2 => 1)), // \x{202C}

		0xA8 => array(0x80 => array(0xE2 => 1)), // \x{2028}
0xA9 => array(0x80 => array(0xE2 => 1)), // \x{2029}
0xAA => array(0x80 => array(0xE2 => 1)), // \x{202A}
0xAB => array(0x80 => array(0xE2 => 1)), // \x{202B}
0xAC => array(0x80 => array(0xE2 => 1)), // \x{202C}

		0xAD => array(0x80 => array(0xE2 => 1)), // \x{202D}

 
		0xAE => array(0x80 => array(0xE2 => 1)), // \x{202E}
0xAF => array(0x80 => array(0xE2 => 1)), // \x{202F}
0xA4 => array(0x85 => array(0xE3 => 1)), // \x{3164}
0xBF => array(0xBB => array(0xEF => 1)), // \x{FEFF}

		0xAE => array(0x80 => array(0xE2 => 1)), // \x{202E}
0xAF => array(0x80 => array(0xE2 => 1)), // \x{202F}
0xA4 => array(0x85 => array(0xE3 => 1)), // \x{3164}
0xBF => array(0xBB => array(0xEF => 1)), // \x{FEFF}

		0xA0 => array(0xBE => array(0xEF => 1)), // \x{FFA0}

 
		0xB9 => array(0xBF => array(0xEF => 1)), // \x{FFF9}
0xBA => array(0xBF => array(0xEF => 1)), // \x{FFFA}
0xBB => array(0xBF => array(0xEF => 1)), // \x{FFFB}

		0xB9 => array(0xBF => array(0xEF => 1)), // \x{FFF9}
0xBA => array(0xBF => array(0xEF => 1)), // \x{FFFA}
0xBB => array(0xBF => array(0xEF => 1)), // \x{FFFB}

Zeile 6385Zeile 6472
	// Start from the beginning and work our way in
do
{

	// Start from the beginning and work our way in
do
{

		// Check to see if we have matched a first character in our utf-16 array

		// Check to see if we have matched a first character in our utf-8 array

		$offset = match_sequence($string, $hex_chrs);
if(!$offset)
{

		$offset = match_sequence($string, $hex_chrs);
if(!$offset)
{

Zeile 6400Zeile 6487
	$string = strrev($string);
do
{

	$string = strrev($string);
do
{

		// Check to see if we have matched a first character in our utf-16 array

		// Check to see if we have matched a first character in our utf-8 array

		$offset = match_sequence($string, $hex_chrs_rev);
if(!$offset)
{

		$offset = match_sequence($string, $hex_chrs_rev);
if(!$offset)
{