Vergleich inc/functions.php - 1.6.0 - 1.6.6

  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 5639 2011-10-26 09:16:47Z 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 246Zeile 246

// Fetch emails for this page view - and send them
$query = $db->simple_select("mailqueue", "*", "", array("order_by" => "mid", "order_dir" => "asc", "limit_start" => 0, "limit" => $count));


// Fetch emails for this page view - and send them
$query = $db->simple_select("mailqueue", "*", "", array("order_by" => "mid", "order_dir" => "asc", "limit_start" => 0, "limit" => $count));


$plugins->run_hooks_by_ref("send_mail_queue_mail", $query);

 

while($email = $db->fetch_array($query))
{
// Delete the message from the queue
$db->delete_query("mailqueue", "mid='{$email['mid']}'");



while($email = $db->fetch_array($query))
{
// Delete the message from the queue
$db->delete_query("mailqueue", "mid='{$email['mid']}'");


			my_mail($email['mailto'], $email['subject'], $email['message'], $email['mailfrom'], "", $email['headers']);




			if($db->affected_rows() == 1)
{
my_mail($email['mailto'], $email['subject'], $email['message'], $email['mailfrom'], "", $email['headers']);
}

		}
// Update the mailqueue cache and remove the lock
$cache->update_mailqueue(TIME_NOW, 0);

		}
// Update the mailqueue cache and remove the lock
$cache->update_mailqueue(TIME_NOW, 0);

	}


	}


	$plugins->run_hooks("send_mail_queue_end");
}


	$plugins->run_hooks("send_mail_queue_end");
}


Zeile 270Zeile 271
 * @return string The parsed page.
*/
function parse_page($contents)

 * @return string The parsed page.
*/
function parse_page($contents)

{

{

	global $lang, $theme, $mybb, $htmldoctype, $archive_url, $error_handler;

$contents = str_replace('<navigation>', build_breadcrumb(1), $contents);

	global $lang, $theme, $mybb, $htmldoctype, $archive_url, $error_handler;

$contents = str_replace('<navigation>', build_breadcrumb(1), $contents);

Zeile 290Zeile 291
	if($lang->settings['rtl'] == 1)
{
$contents = str_replace("<html", "<html dir=\"rtl\"", $contents);

	if($lang->settings['rtl'] == 1)
{
$contents = str_replace("<html", "<html dir=\"rtl\"", $contents);

	}


	}


	if($lang->settings['htmllang'])
{
$contents = str_replace("<html", "<html xml:lang=\"".$lang->settings['htmllang']."\" lang=\"".$lang->settings['htmllang']."\"", $contents);

	if($lang->settings['htmllang'])
{
$contents = str_replace("<html", "<html xml:lang=\"".$lang->settings['htmllang']."\" lang=\"".$lang->settings['htmllang']."\"", $contents);

Zeile 333Zeile 334
			$dstcorrection = $mybb->user['dst'];
}
elseif(defined("IN_ADMINCP"))

			$dstcorrection = $mybb->user['dst'];
}
elseif(defined("IN_ADMINCP"))

		{

		{

			$offset =  $mybbadmin['timezone'];
$dstcorrection = $mybbadmin['dst'];
}

			$offset =  $mybbadmin['timezone'];
$dstcorrection = $mybbadmin['dst'];
}

Zeile 395Zeile 396

if(is_object($plugins))
{


if(is_object($plugins))
{

		$plugins->run_hooks_by_ref("my_date", $date);

		$date = $plugins->run_hooks("my_date", $date);

	}

return $date;

	}

return $date;

Zeile 502Zeile 503
			else
{
error($lang->invalid_post_code);

			else
{
error($lang->invalid_post_code);

			}
}
}

			}
}
}

	else
{
return true;

	else
{
return true;

Zeile 644Zeile 645
{
global $header, $footer, $theme, $headerinclude, $db, $templates, $lang, $mybb, $plugins;


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


	$plugins->run_hooks_by_ref("error", $error);

	$error = $plugins->run_hooks("error", $error);

	if(!$error)
{
$error = $lang->unknown_error;

	if(!$error)
{
$error = $lang->unknown_error;

Zeile 670Zeile 671

eval("\$errorpage = \"".$templates->get("error")."\";");
output_page($errorpage);


eval("\$errorpage = \"".$templates->get("error")."\";");
output_page($errorpage);


exit;
}

/**


exit;
}

/**

 * Produce an error message for displaying inline on a page
*
* @param array Array of errors to be shown

 * Produce an error message for displaying inline on a page
*
* @param array Array of errors to be shown

Zeile 696Zeile 697
	}

// AJAX error message?

	}

// AJAX error message?

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

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

	{
$error = implode("\n\n", $errors);
// Send our headers.

	{
$error = implode("\n\n", $errors);
// Send our headers.

Zeile 706Zeile 707
	}

foreach($errors as $error)

	}

foreach($errors as $error)

	{

	{

		$errorlist .= "<li>".$error."</li>\n";
}


		$errorlist .= "<li>".$error."</li>\n";
}


Zeile 732Zeile 733
	);

$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 749Zeile 749
	}
else
{

	}
else
{

 
		// Redirect to where the user came from
if($_SERVER['HTTP_REFERER'])
{
$redirect_url = htmlentities($_SERVER['HTTP_REFERER']);
}
else
{
$redirect_url = '';
}


		eval("\$errorpage = \"".$templates->get("error_nopermission")."\";");
}


		eval("\$errorpage = \"".$templates->get("error_nopermission")."\";");
}


Zeile 760Zeile 770
 *
* @param string The URL to redirect the user to
* @param string The redirection message to be shown

 *
* @param string The URL to redirect the user to
* @param string The redirection message to be shown

 */

 */

function redirect($url, $message="", $title="")
{
global $header, $footer, $mybb, $theme, $headerinclude, $templates, $lang, $plugins;

$redirect_args = array('url' => &$url, 'message' => &$message, 'title' => &$title);


function redirect($url, $message="", $title="")
{
global $header, $footer, $mybb, $theme, $headerinclude, $templates, $lang, $plugins;

$redirect_args = array('url' => &$url, 'message' => &$message, 'title' => &$title);


	$plugins->run_hooks_by_ref("redirect", $redirect_args);

	$plugins->run_hooks("redirect", $redirect_args);


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


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

Zeile 815Zeile 825

run_shutdown();



run_shutdown();


		if(my_substr($url, 0, 7) !== 'http://')

		if(my_substr($url, 0, 7) !== 'http://' && my_substr($url, 0, 8) !== 'https://')

		{
header("Location: {$mybb->settings['bburl']}/{$url}");
}

		{
header("Location: {$mybb->settings['bburl']}/{$url}");
}

Zeile 928Zeile 938

$page_url = fetch_page_url($url, $pages);
eval("\$end = \"".$templates->get("multipage_end")."\";");


$page_url = fetch_page_url($url, $pages);
eval("\$end = \"".$templates->get("multipage_end")."\";");

	}

if($page < $pages)
{

	}

if($page < $pages)
{

		$next = $page+1;
$page_url = fetch_page_url($url, $next);
eval("\$nextpage = \"".$templates->get("multipage_nextpage")."\";");

		$next = $page+1;
$page_url = fetch_page_url($url, $next);
eval("\$nextpage = \"".$templates->get("multipage_nextpage")."\";");

Zeile 941Zeile 951
	if($breadcrumb == true)
{
eval("\$multipage = \"".$templates->get("multipage_breadcrumb")."\";");

	if($breadcrumb == true)
{
eval("\$multipage = \"".$templates->get("multipage_breadcrumb")."\";");

	}
else

	}
else

	{
eval("\$multipage = \"".$templates->get("multipage")."\";");
}

	{
eval("\$multipage = \"".$templates->get("multipage")."\";");
}

Zeile 958Zeile 968
 */
function fetch_page_url($url, $page)
{

 */
function fetch_page_url($url, $page)
{

	// If no page identifier is specified we tack it on to the end of the URL
if(strpos($url, "{page}") === false)












	if($page <= 1)
{
$find = array(
"-page-{page}",
"&amp;page={page}",
"{page}"
);

// Remove "Page 1" to the defacto URL
$url = str_replace($find, array("", "", $page), $url);
return $url;
}
else if(strpos($url, "{page}") === false)

	{

	{

 
		// If no page identifier is specified we tack it on to the end of the URL

		if(strpos($url, "?") === false)
{
$url .= "?";

		if(strpos($url, "?") === false)
{
$url .= "?";

Zeile 969Zeile 991
		{
$url .= "&amp;";
}

		{
$url .= "&amp;";
}

 


		$url .= "page=$page";

		$url .= "page=$page";

	}

	}

	else
{
$url = str_replace("{page}", $page, $url);
}

	else
{
$url = str_replace("{page}", $page, $url);
}

 


	return $url;
}


	return $url;
}


Zeile 987Zeile 1011
function user_permissions($uid=0)
{
global $mybb, $cache, $groupscache, $user_cache;

function user_permissions($uid=0)
{
global $mybb, $cache, $groupscache, $user_cache;





	// If no user id is specified, assume it is the current user
if($uid == 0)
{

	// If no user id is specified, assume it is the current user
if($uid == 0)
{

Zeile 1008Zeile 1032
		{
$user_cache[$uid] = get_user($uid);
}

		{
$user_cache[$uid] = get_user($uid);
}





		// Collect group permissions.
$gid = $user_cache[$uid]['usergroup'].",".$user_cache[$uid]['additionalgroups'];
$groupperms = usergroup_permissions($gid);

		// Collect group permissions.
$gid = $user_cache[$uid]['usergroup'].",".$user_cache[$uid]['additionalgroups'];
$groupperms = usergroup_permissions($gid);

Zeile 1018Zeile 1042
		return $groupperms;
}
// This user is the current user, return their permissions

		return $groupperms;
}
// This user is the current user, return their permissions

	else

	else

	{
return $mybb->usergroup;
}

	{
return $mybb->usergroup;
}

Zeile 1187Zeile 1211
			}
}
return $cached_forum_permissions[$gid];

			}
}
return $cached_forum_permissions[$gid];

	}

	}

}

/**

}

/**

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

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

	}


	}


	$current_permissions = array();

	$current_permissions = array();

 
	$only_view_own_threads = 1;

	
foreach($groups as $gid)
{

	
foreach($groups as $gid)
{

Zeile 1249Zeile 1274
					$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 1272Zeile 1308
	$showform = true;

if(!is_array($forum_cache))

	$showform = true;

if(!is_array($forum_cache))

	{

	{

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

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

Zeile 1312Zeile 1348
			else
{
eval("\$pwnote = \"".$templates->get("forumdisplay_password_wrongpass")."\";");

			else
{
eval("\$pwnote = \"".$templates->get("forumdisplay_password_wrongpass")."\";");

				$showform = true;
}
}
else

				$showform = true;
}
}
else

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

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

			{

			{

				$showform = true;

				$showform = true;

			}

			}

			else
{
$showform = false;
}

			else
{
$showform = false;
}

		}
}

		}
}

	else
{
$showform = false;

	else
{
$showform = false;

Zeile 1357Zeile 1393
 * @return array Array of moderator permissions for the specific forum
*/
function get_moderator_permissions($fid, $uid="0", $parentslist="")

 * @return array Array of moderator permissions for the specific forum
*/
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)
{

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

if($uid == 0)
{

		return false;
}

		return false;
}

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






























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(!$parentslist)
{
$parentslist = get_parent_list($fid);


























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

		}

		}

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


foreach($groups as $group)





		{

		{

			$groups .= ",'{$usergroups['additionalgroups']}'";
















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

		}

		}

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

 
	}

	}

 

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


return $perms;


return $perms;

}


}


/**
* Checks if a moderator has permissions to perform an action in a specific forum
*

/**
* Checks if a moderator has permissions to perform an action in a specific forum
*

Zeile 1443Zeile 1511
	}

if($uid == 0)

	}

if($uid == 0)

	{

	{

		return false;
}


		return false;
}


Zeile 1463Zeile 1531
				{
if(isset($modusers['users'][$uid]) && $modusers['users'][$uid]['mid'])
{

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

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

						return true;
}
}

						return true;
}
}

Zeile 1519Zeile 1592
	
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 1632Zeile 1708
	
if(!isset($mybb->cookies['mybb'][$name]))
{

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

		return false;
}

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

if(isset($cookie[$id]))
{
return $cookie[$id];
}
else
{
return 0;

		return false;
}

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

if(is_array($cookie) && isset($cookie[$id]))
{
return $cookie[$id];
}
else
{
return 0;

	}
}

	}
}





/**
* Set a serialised cookie array.
*

/**
* Set a serialised cookie array.
*

Zeile 1654Zeile 1730
 * @param int The cookie content id.
* @param string The value to set the cookie to.
*/

 * @param int The cookie content id.
* @param string The value to set the cookie to.
*/

function my_set_array_cookie($name, $id, $value)

function my_set_array_cookie($name, $id, $value, $expires="")

{
global $mybb;

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

{
global $mybb;

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

 

if(!is_array($newcookie))
{
// Burnt / malformed cookie - reset
$newcookie = array();
}


	$newcookie[$id] = $value;
$newcookie = serialize($newcookie);

	$newcookie[$id] = $value;
$newcookie = serialize($newcookie);

	my_setcookie("mybb[$name]", addslashes($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;

Zeile 1694Zeile 1777
			$serverload[0] = round($serverload[0], 4);
}
if(!is_numeric($serverload[0]))

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

		{

		{

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

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

Zeile 1765Zeile 1848
			{
$new_stats[$counter] = $changes[$counter];
}

			{
$new_stats[$counter] = $changes[$counter];
}

			// Less than 0? That's bad
if($new_stats[$counter] < 0)
{
$new_stats[$counter] = 0;
}

			// Less than 0? That's bad
if($new_stats[$counter] < 0)
{
$new_stats[$counter] = 0;
}

		}
}

// Fetch latest user if the user count is changing
if(array_key_exists('numusers', $changes))

		}
}

// Fetch latest user if the user count is changing
if(array_key_exists('numusers', $changes))

	{

	{

		$query = $db->simple_select("users", "uid, username", "", array('order_by' => 'uid', 'order_dir' => 'DESC', 'limit' => 1));
$lastmember = $db->fetch_array($query);
$new_stats['lastuid'] = $lastmember['uid'];
$new_stats['lastusername'] = $lastmember['username'];

		$query = $db->simple_select("users", "uid, username", "", array('order_by' => 'uid', 'order_dir' => 'DESC', 'limit' => 1));
$lastmember = $db->fetch_array($query);
$new_stats['lastuid'] = $lastmember['uid'];
$new_stats['lastusername'] = $lastmember['username'];

	}


	}


	if(empty($new_stats))
{
return;

	if(empty($new_stats))
{
return;

Zeile 1792Zeile 1875
		$stats = array_merge($stats, $new_stats);
}
else

		$stats = array_merge($stats, $new_stats);
}
else

	{

	{

		$stats = $new_stats;
}


		$stats = $new_stats;
}


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

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





	$update_query = array();

$counters = array('threads','unapprovedthreads','posts','unapprovedposts');

	$update_query = array();

$counters = array('threads','unapprovedthreads','posts','unapprovedposts');

Zeile 1832Zeile 1915
		{
// Adding or subtracting from previous value?
if(substr($changes[$counter], 0, 1) == "+" || substr($changes[$counter], 0, 1) == "-")

		{
// Adding or subtracting from previous value?
if(substr($changes[$counter], 0, 1) == "+" || substr($changes[$counter], 0, 1) == "-")

			{

			{

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

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

Zeile 1841Zeile 1924
			}

// Less than 0? That's bad

			}

// Less than 0? That's bad

			if($update_query[$counter] < 0)

			if(!$update_query[$counter])

			{
$update_query[$counter] = 0;
}

			{
$update_query[$counter] = 0;
}

Zeile 2322Zeile 2405
			"editor_enter_image",
"editor_enter_video_url",
"editor_video_dailymotion",

			"editor_enter_image",
"editor_enter_video_url",
"editor_video_dailymotion",

			"editor_video_googlevideo",

 
			"editor_video_metacafe",
"editor_video_myspacetv",
"editor_video_vimeo",

			"editor_video_metacafe",
"editor_video_myspacetv",
"editor_video_vimeo",

Zeile 2341Zeile 2423
		);
$editor_language = "var editor_language = {\n";


		);
$editor_language = "var editor_language = {\n";


		$plugins->run_hooks_by_ref("mycode_add_codebuttons", $editor_lang_strings);

		$editor_lang_strings = $plugins->run_hooks("mycode_add_codebuttons", $editor_lang_strings);


foreach($editor_lang_strings as $key => $lang_string)
{


foreach($editor_lang_strings as $key => $lang_string)
{

Zeile 2467Zeile 2549
	}

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(!is_array($prefix_cache))
{
// No cache
$prefix_cache = $cache->read("threadprefixes", true);

if(!is_array($prefix_cache))
{
return array();
}
}

$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 2478Zeile 2612
 */
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?
if($mybb->user['additionalgroups'])







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

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

		{
$groups[] = $group;
}








	}

	}


switch($db->type)




// Go through each of our prefixes and decide which ones we can use
$prefixes = array();
foreach($prefix_cache as $prefix)

	{

	{

		case "pgsql":
case "sqlite":
$whereforum = "";
if($fid != 'all')














		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)

			{

			{

				$whereforum = " AND (','||forums||',' LIKE '%,{$fid},%' OR ','||forums||',' LIKE '%,-1,%' OR forums='')";





				if(in_array($group, $prefix_groups) && !isset($prefixes[$prefix['pid']]))
{
// Our group can use this prefix!
$prefixes[$prefix['pid']] = $prefix;
}

			}

			}

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

		}
else
{
// This prefix is for anybody to use...
$prefixes[$prefix['pid']] = $prefix;
}
}

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











	}

	}

	



	$prefixselect = "";

	$prefixselect = "";

	
if($db->num_rows($query) > 0)

	$multipleselect = "";
if($multiple != 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')

		{

		{

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

			$any_selected = " selected=\"selected\"";














		}

		}

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








$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 = "";
if($prefix['pid'] == $selected_pid)
{
$selected = " selected=\"selected\"";
}

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

			$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 2646Zeile 2782
function log_moderator_action($data, $action="")
{
global $mybb, $db, $session;

function log_moderator_action($data, $action="")
{
global $mybb, $db, $session;





	// If the fid or tid is not set, set it at 0 so MySQL doesn't choke on it.
if($data['fid'] == '')
{

	// If the fid or tid is not set, set it at 0 so MySQL doesn't choke on it.
if($data['fid'] == '')
{

Zeile 2762Zeile 2898
 */
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 2776Zeile 2926
				{
$ip = $val;
break;

				{
$ip = $val;
break;

				}
}

				}
}

		}

		}

	}

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









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





    if($plugins)
{
$plugins->run_hooks("get_ip", array("ip" => $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 2945Zeile 3095
		$permissioncache = forum_permissions();
}


		$permissioncache = forum_permissions();
}


 
	$password_forums = array();

	foreach($forum_cache as $fid => $forum)
{
if($permissioncache[$forum['fid']])

	foreach($forum_cache as $fid => $forum)
{
if($permissioncache[$forum['fid']])

Zeile 2963Zeile 3114
			if($mybb->cookies['forumpass'][$forum['fid']] != md5($mybb->user['uid'].$forum['password']))
{
$pwverified = 0;

			if($mybb->cookies['forumpass'][$forum['fid']] != md5($mybb->user['uid'].$forum['password']))
{
$pwverified = 0;

 
			}

$password_forums[$forum['fid']] = $forum['password'];
}
else
{
// Check parents for passwords
$parents = explode(",", $forum['parentlist']);
foreach($parents as $parent)
{
if(isset($password_forums[$parent]) && $mybb->cookies['forumpass'][$parent] != md5($mybb->user['uid'].$password_forums[$parent]))
{
$pwverified = 0;
}

			}
}


			}
}


Zeile 3038Zeile 3203
						$sep = $multipage_dropdown.$sep;
}
}

						$sep = $multipage_dropdown.$sep;
}
}

				






// Replace page 1 URLs
$navbit['url'] = str_replace("-page-1.html", ".html", $navbit['url']);
$navbit['url'] = preg_replace("/&amp;page=1$/", "", $navbit['url']);


				eval("\$nav .= \"".$templates->get("nav_bit")."\";");
}
}

				eval("\$nav .= \"".$templates->get("nav_bit")."\";");
}
}

Zeile 3128Zeile 3297
					$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 3328Zeile 3497
{
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 3736Zeile 3905
				if(isset($_POST[$var]))
{
$addloc[] = urlencode($var).'='.urlencode($_POST[$var]);

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

				}
}


				}
}


			if(isset($addloc) && is_array($addloc))
{
if(strpos($location, "?") === false)

			if(isset($addloc) && is_array($addloc))
{
if(strpos($location, "?") === false)

Zeile 3752Zeile 3921
				$location .= implode("&amp;", $addloc);
}
}

				$location .= implode("&amp;", $addloc);
}
}

	







if(strlen($location) > 150)
{
$location = substr($location, 0, 150);
}


		return $location;
}
}

		return $location;
}
}

Zeile 3770Zeile 3944
function build_theme_select($name, $selected="", $tid=0, $depth="", $usergroup_override=false)
{
global $db, $themeselect, $tcache, $lang, $mybb, $limit;

function build_theme_select($name, $selected="", $tid=0, $depth="", $usergroup_override=false)
{
global $db, $themeselect, $tcache, $lang, $mybb, $limit;





	if($tid == 0)
{
$themeselect = "<select name=\"$name\">";

	if($tid == 0)
{
$themeselect = "<select name=\"$name\">";

Zeile 3823Zeile 3997
				if($theme['tid'] == $selected)
{
$sel = " selected=\"selected\"";

				if($theme['tid'] == $selected)
{
$sel = " selected=\"selected\"";

				}

				}


if($theme['pid'] != 0)
{


if($theme['pid'] != 0)
{

Zeile 3845Zeile 4019
	}

return $themeselect;

	}

return $themeselect;

}

}


/**
* Custom function for htmlspecialchars which takes in to account unicode


/**
* Custom function for htmlspecialchars which takes in to account unicode

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

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

	}

	}

	
if($charset == "utf-8")
{

	
if($charset == "utf-8")
{

Zeile 3977Zeile 4151
	{
$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 4101Zeile 4275
		'Y',
'j',
'S',

		'Y',
'j',
'S',

		'l',

 
		'F',

		'F',

 
		'l',

		'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 4114Zeile 4304
		$by,
($bd[0] == 0 ? my_substr($bd, 1) : $bd),
($bd == 1 || $bd == 21 || $bd == 31 ? 'st' : ($bd == 2 || $bd == 22 ? 'nd' : ($bd == 3 || $bd == 23 ? 'rd' : 'th'))),

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

		$wd,

 
		$bmonth[$bm-1],

		$bmonth[$bm-1],

 
		$wd,

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


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


Zeile 4401Zeile 4591
 */
function get_event_date($event)
{

 */
function get_event_date($event)
{

 
	global $mybb;


	$event_date = explode("-", $event['date']);
$event_date = mktime(0, 0, 0, $event_date[1], $event_date[0], $event_date[2]);
$event_date = my_date($mybb->settings['dateformat'], $event_date);

	$event_date = explode("-", $event['date']);
$event_date = mktime(0, 0, 0, $event_date[1], $event_date[0], $event_date[2]);
$event_date = my_date($mybb->settings['dateformat'], $event_date);

Zeile 4417Zeile 4609
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);

	return htmlspecialchars_uni($link);
}

	return htmlspecialchars_uni($link);
}


/**
* Get the announcement link.


/**
* Get the announcement link.

Zeile 4440Zeile 4632
 * @param string The target frame
* @param string Any onclick javascript.
* @return string The complete profile link.

 * @param string The target frame
* @param string Any onclick javascript.
* @return string The complete profile link.

 */

 */

function build_profile_link($username="", $uid=0, $target="", $onclick="")
{
global $mybb, $lang;

function build_profile_link($username="", $uid=0, $target="", $onclick="")
{
global $mybb, $lang;

Zeile 4461Zeile 4653
		if(!empty($target))
{
$target = " target=\"{$target}\"";

		if(!empty($target))
{
$target = " target=\"{$target}\"";

		}


		}


		if(!empty($onclick))
{
$onclick = " onclick=\"{$onclick}\"";
}

return "<a href=\"{$mybb->settings['bburl']}/".get_profile_link($uid)."\"{$target}{$onclick}>{$username}</a>";

		if(!empty($onclick))
{
$onclick = " onclick=\"{$onclick}\"";
}

return "<a href=\"{$mybb->settings['bburl']}/".get_profile_link($uid)."\"{$target}{$onclick}>{$username}</a>";

	}
}

/**

	}
}

/**

 * Build the forum link.
*
* @param int The forum id of the forum.

 * Build the forum link.
*
* @param int The forum id of the forum.

Zeile 4482Zeile 4674
function get_forum_link($fid, $page=0)
{
if($page > 0)

function get_forum_link($fid, $page=0)
{
if($page > 0)

	{

	{

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

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

Zeile 4503Zeile 4695
 * @return string The url to the thread.
*/
function get_thread_link($tid, $page=0, $action='')

 * @return string The url to the thread.
*/
function get_thread_link($tid, $page=0, $action='')

{

{

	if($page > 1)
{
if($action)

	if($page > 1)
{
if($action)

Zeile 4514Zeile 4706
		else
{
$link = THREAD_URL_PAGED;

		else
{
$link = THREAD_URL_PAGED;

		}

		}

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

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

Zeile 4525Zeile 4717
		{
$link = THREAD_URL_ACTION;
$link = str_replace("{action}", $action, $link);

		{
$link = THREAD_URL_ACTION;
$link = str_replace("{action}", $action, $link);

		}

		}

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

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

		return htmlspecialchars_uni($link);
}
}

/**

		return htmlspecialchars_uni($link);
}
}

/**

 * Build the post link.
*
* @param int The post ID of the post

 * Build the post link.
*
* @param int The post ID of the post

Zeile 4588Zeile 4780
		return htmlspecialchars_uni($link);
}
else if($month > 0)

		return htmlspecialchars_uni($link);
}
else if($month > 0)

	{

	{

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

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

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

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

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

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

		return htmlspecialchars_uni($link);

		return htmlspecialchars_uni($link);

	}
else
{

	}
else
{

Zeile 4655Zeile 4847
		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 4672Zeile 4863
	if(!isset($forum_cache) || is_array($forum_cache))
{
$forum_cache = $cache->read("forums");

	if(!isset($forum_cache) || is_array($forum_cache))
{
$forum_cache = $cache->read("forums");

	}

	}


if(!$forum_cache[$fid])
{


if(!$forum_cache[$fid])
{

Zeile 4691Zeile 4882
					return false;
}
}

					return false;
}
}

		}
}

		}
}


return $forum_cache[$fid];
}


return $forum_cache[$fid];
}

Zeile 4703Zeile 4894
 * @param int The thread id of the thread.
* @param boolean Whether or not to recache the thread.
* @return string The database row of the thread.

 * @param int The thread id of the thread.
* @param boolean Whether or not to recache the thread.
* @return string The database row of the thread.

 */

 */

function get_thread($tid, $recache = false)
{
global $db;

function get_thread($tid, $recache = false)
{
global $db;

Zeile 4712Zeile 4903
	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);

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

Zeile 4722Zeile 4913
		{
$thread_cache[$tid] = $thread;
return $thread;

		{
$thread_cache[$tid] = $thread;
return $thread;

		}
else

		}
else

		{
$thread_cache[$tid] = false;
return false;

		{
$thread_cache[$tid] = false;
return false;

Zeile 4755Zeile 4946
		{
$post_cache[$pid] = $post;
return $post;

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

		}
else
{

		}
else
{

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

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

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

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

 */

 */

function get_inactive_forums()
{
global $forum_cache, $cache, $inactiveforums;

function get_inactive_forums()
{
global $forum_cache, $cache, $inactiveforums;





	if(!$forum_cache)
{
cache_forums();

	if(!$forum_cache)
{
cache_forums();

	}

$inactive = array();


	}

$inactive = array();


	foreach($forum_cache as $fid => $forum)
{
if($forum['active'] == 0)

	foreach($forum_cache as $fid => $forum)
{
if($forum['active'] == 0)

Zeile 4811Zeile 5002
	global $mybb, $lang, $session, $db;

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

	global $mybb, $lang, $session, $db;

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

	{

	{

		return 1;
}
// Note: Number of logins is defaulted to 1, because using 0 seems to clear cookie data. Not really a problem as long as we account for 1 being default.

		return 1;
}
// Note: Number of logins is defaulted to 1, because using 0 seems to clear cookie data. Not really a problem as long as we account for 1 being default.

Zeile 4821Zeile 5012
	// Also use the greater of the two numbers present, stops people using scripts with altered cookie data to stay the same
$cookielogins = intval($mybb->cookies['loginattempts']);
$cookietime = $mybb->cookies['failedlogin'];

	// Also use the greater of the two numbers present, stops people using scripts with altered cookie data to stay the same
$cookielogins = intval($mybb->cookies['loginattempts']);
$cookietime = $mybb->cookies['failedlogin'];





	if(empty($cookielogins) || $cookielogins < $session->logins)

	if(empty($cookielogins) || $cookielogins < $session->logins)

	{

	{

		$loginattempts = $session->logins;
}
else

		$loginattempts = $session->logins;
}
else

Zeile 4832Zeile 5023
	}

if(empty($cookietime) || $cookietime < $session->failedlogin)

	}

if(empty($cookietime) || $cookietime < $session->failedlogin)

	{

	{

		$failedlogin = $session->failedlogin;

		$failedlogin = $session->failedlogin;

	}

	}

	else
{
$failedlogin = $cookietime;

	else
{
$failedlogin = $cookietime;

Zeile 4842Zeile 5033

// Work out if the user has had more than the allowed number of login attempts
if($loginattempts > $mybb->settings['failedlogincount'])


// Work out if the user has had more than the allowed number of login attempts
if($loginattempts > $mybb->settings['failedlogincount'])

	{

	{

		// If so, then we need to work out if they can try to login again
// Some maths to work out how long they have left and display it to them
$now = TIME_NOW;

		// If so, then we need to work out if they can try to login again
// Some maths to work out how long they have left and display it to them
$now = TIME_NOW;

Zeile 4935Zeile 5126
	{
$uid_string = " AND uid != '".intval($uid)."'";
}

	{
$uid_string = " AND uid != '".intval($uid)."'";
}

	$query = $db->simple_select("users", "COUNT(email) as emails", "email = '".$db->escape_string(my_strtolower($email))."'{$uid_string}");

	$query = $db->simple_select("users", "COUNT(email) as emails", "email = '".$db->escape_string($email)."'{$uid_string}");

	
if($db->fetch_field($query, "emails") > 0)
{

	
if($db->fetch_field($query, "emails") > 0)
{

Zeile 5005Zeile 5196
	{
$mybb->settings['minsearchword'] = 3;
}

	{
$mybb->settings['minsearchword'] = 3;
}

 

if(is_array($terms))
{
$terms = implode(' ', $terms);
}


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


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

Zeile 5055Zeile 5251
	{
$terms = htmlspecialchars_uni($terms);
$split_words = preg_split("#\s{1,}#", $terms, -1);

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

		if(!is_array($split_words))

		if(is_array($split_words))

		{

		{

			continue;
}
foreach($split_words as $word)
{
if(!$word || strlen($word) < $mybb->settings['minsearchword'])

			foreach($split_words as $word)





			{

			{

				continue;





				if(!$word || strlen($word) < $mybb->settings['minsearchword'])
{
continue;
}
$words[] = trim($word);

			}

			}

			$words[] = trim($word);

 
		}

		}



 
	}

if(!is_array($words))

	}

if(!is_array($words))

	{

	{

		return false;
}


		return false;
}


Zeile 5099Zeile 5293
	}

return $highlight_cache;

	}

return $highlight_cache;

}


}


/**

/**

 * 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 5112Zeile 5306
	$dest = '';

if($src < 0)

	$dest = '';

if($src < 0)

	{

	{

  		return false;
}
elseif($src <= 0x007f)

  		return false;
}
elseif($src <= 0x007f)

	{

	{

		$dest .= chr($src);
}
elseif($src <= 0x07ff)
{
$dest .= chr(0xc0 | ($src >> 6));

		$dest .= chr($src);
}
elseif($src <= 0x07ff)
{
$dest .= chr(0xc0 | ($src >> 6));

		$dest .= chr(0x80 | ($src & 0x003f));

		$dest .= chr(0x80 | ($src & 0x003f));

	}
elseif($src <= 0xffff)
{

	}
elseif($src <= 0xffff)
{

Zeile 5141Zeile 5335
	{
// Out of range
return false;

	{
// Out of range
return false;

	}


	}


	return $dest;
}


	return $dest;
}


Zeile 5150Zeile 5344
 * Checks if a username has been disallowed for registration/use.
*
* @param string The username

 * Checks if a username has been disallowed for registration/use.
*
* @param string The username

 * @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 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_username($username, $update_lastuse=false)
{
global $db;

function is_banned_username($username, $update_lastuse=false)
{
global $db;

Zeile 5183Zeile 5377
 * @return boolean True if banned, false if not banned
*/
function is_banned_email($email, $update_lastuse=false)

 * @return boolean True if banned, false if not banned
*/
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 5400Zeile 5603
		
$headers[] = "Host: {$url['host']}";
$headers[] = "Connection: Close";

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

		$headers[] = "\r\n";

		$headers[] = '';

		
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
$headers[] = '';

		}

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

		}

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

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

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

	}
else
{
return false;
}
}

	}
else
{
return false;
}
}


/**
* Checks if a particular user is a super administrator.


/**
* Checks if a particular user is a super administrator.

Zeile 5470Zeile 5678
		if(is_array($escape))
{
function escaped_explode_escape($string)

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

			{

			{

				return preg_quote($string, "#");
}
$escape_preg = "(".implode("|", array_map("escaped_explode_escape", $escape)).")";

				return preg_quote($string, "#");
}
$escape_preg = "(".implode("|", array_map("escaped_explode_escape", $escape)).")";

Zeile 5510Zeile 5718
		return $original;
}
return $strings;

		return $original;
}
return $strings;

}

/**

}

/**

 * 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 5592Zeile 5800
		"0-0-2" => "2 {$lang->years}"
);


		"0-0-2" => "2 {$lang->years}"
);


	$plugins->run_hooks_by_ref("functions_fetch_ban_times", $ban_times);

	$ban_times = $plugins->run_hooks("functions_fetch_ban_times", $ban_times);


$ban_times['---'] = $lang->permanent;
return $ban_times;


$ban_times['---'] = $lang->permanent;
return $ban_times;

}

/**

}

/**

 * Format a ban length in to a UNIX timestamp.
*
* @param string The ban length string

 * Format a ban length in to a UNIX timestamp.
*
* @param string The ban length string

Zeile 5622Zeile 5830

/**
* Expire old warnings in the database.


/**
* Expire old warnings in the database.

 *
*/

 *
*/

function expire_warnings()
{
global $db;

function expire_warnings()
{
global $db;

Zeile 5640Zeile 5848
	{
$updated_warning = array(
"expired" => 1

	{
$updated_warning = array(
"expired" => 1

		);

		);

		$db->update_query("warnings", $updated_warning, "wid='{$warning['wid']}'");

if(array_key_exists($warning['uid'], $users))

		$db->update_query("warnings", $updated_warning, "wid='{$warning['wid']}'");

if(array_key_exists($warning['uid'], $users))

		{

		{

			$users[$warning['uid']] -= $warning['points'];
}
else

			$users[$warning['uid']] -= $warning['points'];
}
else

		{

		{

			$users[$warning['uid']] = $warning['warningpoints']-$warning['points'];
}
}

			$users[$warning['uid']] = $warning['warningpoints']-$warning['points'];
}
}

Zeile 5665Zeile 5873
		);
$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 5789Zeile 5964
 */
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 5914Zeile 6101
 * 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 5932Zeile 6119
 * 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 5972Zeile 6159
 * @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)
{

Zeile 6028Zeile 6215
		0x0A => 1,
0x0D => 1,
0x0B => 1,

		0x0A => 1,
0x0D => 1,
0x0B => 1,

 
		0xAD => 1,
0xC2 => array(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}

		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}

Zeile 6046Zeile 6241
		0x0A => 1,
0x0D => 1,
0x0B => 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),

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

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