Vergleich inc/functions.php - 1.4.1 - 1.4.11

  Keine Änderungen   Hinzugefügt   Modifiziert   Entfernt
Zeile 1Zeile 1
<?php
/**
* MyBB 1.4

<?php
/**
* MyBB 1.4

 * Copyright � 2008 MyBB Group, All Rights Reserved

 * Copyright © 2008 MyBB Group, All Rights Reserved

 *
* Website: http://www.mybboard.net
* License: http://www.mybboard.net/about/license
*

 *
* Website: http://www.mybboard.net
* License: http://www.mybboard.net/about/license
*

 * $Id: functions.php 4116 2008-08-15 15:37:11Z ybwzrd $

 * $Id: functions.php 4562 2009-11-29 22:04:37Z RyanGordon $

 */

/**

 */

/**

Zeile 228Zeile 228
/**
* Sends a specified amount of messages from the mail queue
*

/**
* Sends a specified amount of messages from the mail queue
*

 * @param int The number of messages to send (Defaults to 20)

 * @param int The number of messages to send (Defaults to 10)

 */
function send_mail_queue($count=10)
{

 */
function send_mail_queue($count=10)
{

Zeile 409Zeile 409
 * @param string The from address of the email, if blank, the board name will be used.
* @param string The chracter set being used to send this email.
* @param boolean Do we wish to keep the connection to the mail server alive to send more than one message (SMTP only)

 * @param string The from address of the email, if blank, the board name will be used.
* @param string The chracter set being used to send this email.
* @param boolean Do we wish to keep the connection to the mail server alive to send more than one message (SMTP only)

 
 * @param string The format of the email to be sent (text or html). text is default
* @param string The text message of the email if being sent in html format, for email clients that don't support html
* @param string The email address to return to. Defaults to admin return email address.

 */

 */

function my_mail($to, $subject, $message, $from="", $charset="", $headers="", $keep_alive=false, $format="text", $message_text="")

function my_mail($to, $subject, $message, $from="", $charset="", $headers="", $keep_alive=false, $format="text", $message_text="", $return_email="")

{
global $mybb;
static $mail;

{
global $mybb;
static $mail;

Zeile 451Zeile 454
	}

// Build and send

	}

// Build and send

	$mail->build_message($to, $subject, $message, $from, $charset, $headers, $format, $message_text);

	$mail->build_message($to, $subject, $message, $from, $charset, $headers, $format, $message_text, $return_email);

	return $mail->send();
}


	return $mail->send();
}


Zeile 470Zeile 473
	// Guests get a special string
else
{

	// Guests get a special string
else
{

		return md5($mybb->config['database']['hostname'].$mybb->config['database']['username'].md5($mybb->config['database']['password']));

		return md5($mybb->settings['bburl'].$mybb->config['database']['username'].$mybb->settings['internal']['encryption_key']);

	}
}


	}
}


Zeile 491Zeile 494
		}
else
{

		}
else
{

			error($lang->invalid_post_code);








			if(defined("IN_ADMINCP"))
{
return false;
}
else
{
error($lang->invalid_post_code);
}

		}
}
else
{
return true;

		}
}
else
{
return true;

	}
}

/**

	}
}

/**

 * Return a parent list for the specified forum.
*
* @param int The forum id to get the parent list for.

 * Return a parent list for the specified forum.
*
* @param int The forum id to get the parent list for.

Zeile 516Zeile 526
		return $forumarraycache[$fid]['parentlist'];
}
elseif($forum_cache[$fid])

		return $forumarraycache[$fid]['parentlist'];
}
elseif($forum_cache[$fid])

	{
return $forum_cache[$fid]['parentlist'];
}

	{
return $forum_cache[$fid]['parentlist'];
}

	else
{
cache_forums();
return $forum_cache[$fid]['parentlist'];

	else
{
cache_forums();
return $forum_cache[$fid]['parentlist'];

	}
}

/**

	}
}

/**

 * Build a parent list of a specific forum, suitable for querying
*
* @param int The forum ID

 * Build a parent list of a specific forum, suitable for querying
*
* @param int The forum ID

Zeile 561Zeile 571
 * Load the forum cache in to memory
*
* @param boolean True to force a reload of the cache

 * Load the forum cache in to memory
*
* @param boolean True to force a reload of the cache

 */

 */

function cache_forums($force=false)
{
global $forum_cache, $cache;

function cache_forums($force=false)
{
global $forum_cache, $cache;

Zeile 570Zeile 580
	{
$forum_cache = $cache->read("forums", 1);
return $forum_cache;

	{
$forum_cache = $cache->read("forums", 1);
return $forum_cache;

	}

	}


if(!$forum_cache)
{


if(!$forum_cache)
{

Zeile 579Zeile 589
		{
$cache->update_forums();
$forum_cache = $cache->read("forums", 1);

		{
$cache->update_forums();
$forum_cache = $cache->read("forums", 1);

		}

		}

	}
return $forum_cache;
}

	}
return $forum_cache;
}

Zeile 607Zeile 617
		}
}
if(!is_array($forums_by_parent[$fid]))

		}
}
if(!is_array($forums_by_parent[$fid]))

	{

	{

		return;
}


		return;
}


Zeile 635Zeile 645

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


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

	{

	{

		$error = $lang->unknown_error;
}


		$error = $lang->unknown_error;
}


Zeile 765Zeile 775
		echo "<script type=\"text/javascript\">\n";
if($message != "")
{

		echo "<script type=\"text/javascript\">\n";
if($message != "")
{

			echo "alert('{$message}');\n";

			echo 'alert("'.addslashes($message).'");';

		}
$url = str_replace("#", "&#", $url);
$url = htmlspecialchars_decode($url);
$url = str_replace(array("\n","\r",";"), "", $url);

		}
$url = str_replace("#", "&#", $url);
$url = htmlspecialchars_decode($url);
$url = str_replace(array("\n","\r",";"), "", $url);

		echo "window.location = '{$url}';\n";

		echo 'window.location = "'.addslashes($url).'";'."\n";

		echo "</script>\n";
exit;
}

		echo "</script>\n";
exit;
}

Zeile 799Zeile 809
	}
else
{

	}
else
{

		$url = str_replace("#", "&#", $url);

 
		$url = htmlspecialchars_decode($url);
$url = str_replace(array("\n","\r",";"), "", $url);


		$url = htmlspecialchars_decode($url);
$url = str_replace(array("\n","\r",";"), "", $url);


Zeile 933Zeile 942
		$url = str_replace("{page}", $page, $url);
}
return $url;

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

}

/**

}

/**

 * Fetch the permissions for a specific user
*
* @param int The user ID

 * Fetch the permissions for a specific user
*
* @param int The user ID

Zeile 990Zeile 999
function usergroup_permissions($gid=0)
{
global $cache, $groupscache, $grouppermignore, $groupzerogreater;

function usergroup_permissions($gid=0)
{
global $cache, $groupscache, $grouppermignore, $groupzerogreater;



	

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

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

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

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



 

if(count($groups) == 1)
{


if(count($groups) == 1)
{

Zeile 1009Zeile 1017
		if(trim($gid) == "" || !$groupscache[$gid])
{
continue;

		if(trim($gid) == "" || !$groupscache[$gid])
{
continue;

		}


		}


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

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

Zeile 1020Zeile 1028
					$permbit = $usergroup[$perm];
}
else

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

				{

				{

					$permbit = "";
}


					$permbit = "";
}


				if(in_array($perm, $groupzerogreater))


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

				{

				{

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

					$usergroup[$perm] = 0;
continue;




				}

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

				}

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

Zeile 1042Zeile 1048
	}

return $usergroup;

	}

return $usergroup;

}


}


/**
* Fetch the display group properties for a specific display group
*

/**
* Fetch the display group properties for a specific display group
*

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

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

		{
if($usercache[$uid])
{

		{
if(!$usercache[$uid])
{

				$query = $db->simple_select("users", "*", "uid='$uid'");
$usercache[$uid] = $db->fetch_array($query);
}

				$query = $db->simple_select("users", "*", "uid='$uid'");
$usercache[$uid] = $db->fetch_array($query);
}

Zeile 1216Zeile 1222
		$current_permissions = $groupperms;
}
return $current_permissions;

		$current_permissions = $groupperms;
}
return $current_permissions;

}

}


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


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

Zeile 1229Zeile 1235
	global $mybb, $header, $footer, $headerinclude, $theme, $templates, $lang, $forum_cache;

$showform = true;

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

$showform = true;

	

	

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

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

		}

		}

	}

// Loop through each of parent forums to ensure we have a password for them too

	}

// Loop through each of parent forums to ensure we have a password for them too

Zeile 1249Zeile 1255
			if($parent_id == $fid || $parent_id == $pid)
{
continue;

			if($parent_id == $fid || $parent_id == $pid)
{
continue;

			}

			}

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

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

Zeile 1261Zeile 1267
	$password = $forum_cache[$fid]['password'];
if($password)
{

	$password = $forum_cache[$fid]['password'];
if($password)
{

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

		if($mybb->input['pwverify'] && $pid == 0)

		{
if($password == $mybb->input['pwverify'])

		{
if($password == $mybb->input['pwverify'])

			{

			{

				my_setcookie("forumpass[$fid]", md5($mybb->user['uid'].$mybb->input['pwverify']), null, true);
$showform = false;

				my_setcookie("forumpass[$fid]", md5($mybb->user['uid'].$mybb->input['pwverify']), null, true);
$showform = false;

			}

			}

			else

			else

			{

			{

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

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

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

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

			else
{
$showform = false;
}

			else
{
$showform = false;
}

		}
}
else
{

		}
}
else
{

		$showform = false;
}

if($showform)
{

		$showform = false;
}

if($showform)
{

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








		if($pid)
{
header("Location: ".$mybb->settings['bburl']."/".get_forum_link($fid));
}
else
{
$_SERVER['REQUEST_URI'] = htmlspecialchars_uni($_SERVER['REQUEST_URI']);
eval("\$pwform = \"".$templates->get("forumdisplay_password")."\";");
output_page($pwform);
}

		exit;
}
}

		exit;
}
}

Zeile 1321Zeile 1334
	if($uid == 0)
{
return false;

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

	}

	}

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

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

Zeile 1344Zeile 1357
	else
{
$perms = $modpermscache[$fid][$uid];

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

	}

	}


return $perms;
}


return $perms;
}

Zeile 1360Zeile 1373
function is_moderator($fid="0", $action="", $uid="0")
{
global $mybb, $cache;

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





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

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

Zeile 1406Zeile 1419
				if($modperms[$action] == 1)
{
return true;

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

				}

				}

				else
{
return false;
}
}

				else
{
return false;
}
}

		}
}
}

		}
}
}


/**
* Generate a list of the posticons.


/**
* Generate a list of the posticons.

Zeile 1429Zeile 1442
	if($mybb->input['icon'])
{
$icon = $mybb->input['icon'];

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

	}


	}


	$no_icons_checked = " checked=\"checked\"";
// read post icons from cache, and sort them accordingly
$posticons_cache = $cache->read("posticons");

	$no_icons_checked = " checked=\"checked\"";
// read post icons from cache, and sort them accordingly
$posticons_cache = $cache->read("posticons");

Zeile 1468Zeile 1481

/**
* MyBB setcookie() wrapper.


/**
* MyBB setcookie() wrapper.

 *

 *

 * @param string The cookie identifier.
* @param string The cookie value.
* @param int The timestamp of the expiry date.

 * @param string The cookie identifier.
* @param string The cookie value.
* @param int The timestamp of the expiry date.

Zeile 1592Zeile 1605
	$cookie = $mybb->cookies['mybb'];
$newcookie = unserialize($cookie[$name]);
$newcookie[$id] = $value;

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

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




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

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

}

/**

}

/**

Zeile 1615Zeile 1631
			$serverload = explode(" ", $load);
$serverload[0] = round($serverload[0], 4);
}

			$serverload = explode(" ", $load);
$serverload[0] = round($serverload[0], 4);
}

		if(!$serverload)

		if(!is_numeric($serverload[0]))

		{
if(@ini_get('safe_mode') == 'On')
{

		{
if(@ini_get('safe_mode') == 'On')
{

Zeile 1640Zeile 1656
			}

$load = @exec("uptime");

			}

$load = @exec("uptime");

			$load = split("load averages?: ", $load);

			$load = explode("load average: ", $load);

			$serverload = explode(",", $load[1]);
if(!is_array($serverload))
{

			$serverload = explode(",", $load[1]);
if(!is_array($serverload))
{

Zeile 1827Zeile 1843

// Update last post info
update_forum_lastpost($fid);


// Update last post info
update_forum_lastpost($fid);

 
	
$cache->update_forums();

}

/**

}

/**

Zeile 1897Zeile 1915
			}
}
}

			}
}
}

 
	
$db->free_result($query);


// Only update if we're actually doing something
if(count($update_query) > 0)
{
$db->update_query("threads", $update_query, "tid='".intval($tid)."'");
}


// Only update if we're actually doing something
if(count($update_query) > 0)
{
$db->update_query("threads", $update_query, "tid='".intval($tid)."'");
}

 
	
unset($update_query, $thread);


update_thread_data($tid);
}


update_thread_data($tid);
}

Zeile 1915Zeile 1937
function update_thread_data($tid)
{
global $db;

function update_thread_data($tid)
{
global $db;

	$query = $db->query("

	$query = $db->query("

		SELECT u.uid, u.username, p.username AS postusername, p.dateline
FROM ".TABLE_PREFIX."posts p
LEFT JOIN ".TABLE_PREFIX."users u ON (u.uid=p.uid)

		SELECT u.uid, u.username, p.username AS postusername, p.dateline
FROM ".TABLE_PREFIX."posts p
LEFT JOIN ".TABLE_PREFIX."users u ON (u.uid=p.uid)

Zeile 1924Zeile 1946
		LIMIT 1"
);
$lastpost = $db->fetch_array($query);

		LIMIT 1"
);
$lastpost = $db->fetch_array($query);





	
$db->free_result($query);


	$query = $db->query("
SELECT u.uid, u.username, p.username AS postusername, p.dateline
FROM ".TABLE_PREFIX."posts p

	$query = $db->query("
SELECT u.uid, u.username, p.username AS postusername, p.dateline
FROM ".TABLE_PREFIX."posts p

Zeile 1934Zeile 1958
		LIMIT 1
");
$firstpost = $db->fetch_array($query);

		LIMIT 1
");
$firstpost = $db->fetch_array($query);

 
	
$db->free_result($query);


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


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

Zeile 1958Zeile 1984
	$update_array = array(
'username' => $firstpost['username'],
'uid' => intval($firstpost['uid']),

	$update_array = array(
'username' => $firstpost['username'],
'uid' => intval($firstpost['uid']),

 
		'dateline' => intval($firstpost['dateline']),

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

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

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

}

function update_forum_count($fid)

}

function update_forum_count($fid)

Zeile 1972Zeile 2001
function update_thread_count($tid)
{
die("Deprecated function call: update_thread_count");

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

}

}

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

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

}


}


/**
* Deletes a thread from the database

/**
* Deletes a thread from the database

 *
* @param int The thread ID

 *
* @param int The thread ID

 */
function delete_thread($tid)
{
global $moderation;

 */
function delete_thread($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 2000Zeile 2029
 * Deletes a post from the database
*
* @param int The thread ID

 * Deletes a post from the database
*
* @param int The thread ID

 */

 */

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

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

Zeile 2022Zeile 2051
 * @param int If we need to add select boxes to this cal or not
* @param int The current depth of forums we're at
* @param int Whether or not to show extra items such as User CP, Forum home

 * @param int If we need to add select boxes to this cal or not
* @param int The current depth of forums we're at
* @param int Whether or not to show extra items such as User CP, Forum home

 
 * @param boolean Ignore the showinjump setting and show all forums (for moderation pages)

 * @param array Array of permissions
* @param string The name of the forum jump
* @return string Forum jump items
*/

 * @param array Array of permissions
* @param string The name of the forum jump
* @return string Forum jump items
*/

function build_forum_jump($pid="0", $selitem="", $addselect="1", $depth="", $showextras="1", $permissions="", $name="fid")

function build_forum_jump($pid="0", $selitem="", $addselect="1", $depth="", $showextras="1", $showall=false, $permissions="", $name="fid")

{
global $forum_cache, $jumpfcache, $permissioncache, $mybb, $selecteddone, $forumjump, $forumjumpbits, $gobutton, $theme, $templates, $lang;


{
global $forum_cache, $jumpfcache, $permissioncache, $mybb, $selecteddone, $forumjump, $forumjumpbits, $gobutton, $theme, $templates, $lang;


Zeile 2038Zeile 2068
	}

if(!is_array($jumpfcache))

	}

if(!is_array($jumpfcache))

	{

	{

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

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

Zeile 2051Zeile 2081
				$jumpfcache[$forum['pid']][$forum['disporder']][$forum['fid']] = $forum;
}
}

				$jumpfcache[$forum['pid']][$forum['disporder']][$forum['fid']] = $forum;
}
}

	}


	}


	if(!is_array($permissioncache))
{
$permissioncache = forum_permissions();
}

if(is_array($jumpfcache[$pid]))

	if(!is_array($permissioncache))
{
$permissioncache = forum_permissions();
}

if(is_array($jumpfcache[$pid]))

	{

	{

		foreach($jumpfcache[$pid] as $main)
{
foreach($main as $forum)
{
$perms = $permissioncache[$forum['fid']];


		foreach($jumpfcache[$pid] as $main)
{
foreach($main as $forum)
{
$perms = $permissioncache[$forum['fid']];


				if($forum['fid'] != "0" && ($perms['canview'] != 0 || $mybb->settings['hideprivateforums'] == 0) && $forum['linkto'] == '' && $forum['showinjump'] != 0)

				if($forum['fid'] != "0" && ($perms['canview'] != 0 || $mybb->settings['hideprivateforums'] == 0) && $forum['linkto'] == '' && ($forum['showinjump'] != 0 || $showall == true))

				{
$optionselected = "";


				{
$optionselected = "";


Zeile 2083Zeile 2113
					if($forum_cache[$forum['fid']])
{
$newdepth = $depth."--";

					if($forum_cache[$forum['fid']])
{
$newdepth = $depth."--";

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

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

					}
}
}

					}
}
}

Zeile 2098Zeile 2128
			{
$selitem = "default";
}

			{
$selitem = "default";
}





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

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

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

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

		}

		}

		else
{
$template = "advanced";

		else
{
$template = "advanced";

Zeile 2119Zeile 2149

/**
* Returns the extension of a file.


/**
* Returns the extension of a file.

 *

 *

 * @param string The filename.
* @return string The extension of the file.
*/
function get_extension($file)
{
return my_strtolower(my_substr(strrchr($file, "."), 1));

 * @param string The filename.
* @return string The extension of the file.
*/
function get_extension($file)
{
return my_strtolower(my_substr(strrchr($file, "."), 1));

}


}


/**
* Generates a random string.
*

/**
* Generates a random string.
*

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

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

	}

	}


if($displaygroup != 0)
{


if($displaygroup != 0)
{

Zeile 2177Zeile 2207
	if($userin == 0)
{
$format = "{username}";

	if($userin == 0)
{
$format = "{username}";

	}

	}


$format = stripslashes($format);



$format = stripslashes($format);


Zeile 2292Zeile 2322
				if($smilie['showclickable'] != 0)
{
$smiliecache[$smilie['find']] = $smilie['image'];

				if($smilie['showclickable'] != 0)
{
$smiliecache[$smilie['find']] = $smilie['image'];

				}

				}

			}
}


			}
}


Zeile 2866Zeile 2896
				}

$navsize = count($navbits);

				}

$navsize = count($navbits);

				$navbits[$navsize]['name'] = $forumnav['name'];


				// Convert & to &amp;
$navbits[$navsize]['name'] = preg_replace("#&(?!\#[0-9]+;)#si", "&amp;", $forumnav['name']);


if(IN_ARCHIVE == 1)
{


if(IN_ARCHIVE == 1)
{

Zeile 2938Zeile 2969
			$url = "{$base_url}forum-{$id}.html";
break;
default:

			$url = "{$base_url}forum-{$id}.html";
break;
default:

			$url = $mybb->setings['bburl']."/archive/index.php";

			$url = $mybb->settings['bburl']."/archive/index.php";

	}

return $url;

	}

return $url;

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

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

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

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

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

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

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

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

	global $db;


	global $db, $mybb;


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

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

	{

	{

		$user = $mybb->user;

		$user = $mybb->user;

	}

	}

	else

	else

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

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

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


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


Zeile 3327Zeile 3358
	$usergroups = $user['additionalgroups'].",".$joingroup;
$groupslist = "";
$groups = explode(",", $usergroups);

	$usergroups = $user['additionalgroups'].",".$joingroup;
$groupslist = "";
$groups = explode(",", $usergroups);


if(is_array($groups))
{
foreach($groups as $gid)
{


if(is_array($groups))
{
foreach($groups as $gid)
{

			if(trim($gid) != "" && $gid != $user['usergroup'] && !$donegroup[$gid])
{
$groupslist .= $comma.$gid;

			if(trim($gid) != "" && $gid != $user['usergroup'] && !$donegroup[$gid])
{
$groupslist .= $comma.$gid;

Zeile 3339Zeile 3370
				$donegroup[$gid] = 1;
}
}

				$donegroup[$gid] = 1;
}
}

	}

	}





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










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

}

/**

}

/**

Zeile 3360Zeile 3400
	}
else
{

	}
else
{

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

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

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

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





$groupslist = "";

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


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


Zeile 3372Zeile 3413
	if(is_array($groups))
{
foreach($groups as $gid)

	if(is_array($groups))
{
foreach($groups as $gid)

		{

		{

			if(trim($gid) != "" && $leavegroup != $gid && !$donegroup[$gid])
{
$groupslist .= $comma.$gid;

			if(trim($gid) != "" && $leavegroup != $gid && !$donegroup[$gid])
{
$groupslist .= $comma.$gid;

Zeile 3381Zeile 3422
			}
}
}

			}
}
}




	
$dispupdate = "";

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

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

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

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

		WHERE uid='$uid'

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

	");

$cache->update_moderators();

	");

$cache->update_moderators();

Zeile 3412Zeile 3454

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


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

		$location = $_SERVER['PATH_INFO'];

		$location = htmlspecialchars_uni($_SERVER['PATH_INFO']);

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

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

	{
$location = $_ENV['PATH_INFO'];

	{
$location = htmlspecialchars_uni($_ENV['PATH_INFO']);

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

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

	{
$location = $_ENV['PHP_SELF'];

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

	}
else
{

	}
else
{

		$location = $_SERVER['PHP_SELF'];

		$location = htmlspecialchars_uni($_SERVER['PHP_SELF']);

	}

if($fields == true)

	}

if($fields == true)

Zeile 3438Zeile 3480
		
$form_html = "";
$field_parts = explode('&', $field_parts);

		
$form_html = "";
$field_parts = explode('&', $field_parts);

		

		

		if(!empty($mybb->input))

		if(!empty($mybb->input))

		{

		{

			foreach($mybb->input as $name => $value)
{
if(in_array($name, $ignore))

			foreach($mybb->input as $name => $value)
{
if(in_array($name, $ignore))

Zeile 3458Zeile 3500
	{
if(isset($_SERVER['QUERY_STRING']))
{

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

			$location .= "?".$_SERVER['QUERY_STRING'];
}
else if(isset($_ENV['QUERY_STRING']))
{
$location = "?".$_ENV['QUERY_STRING'];

			$location .= "?".htmlspecialchars_uni($_SERVER['QUERY_STRING']);
}
else if(isset($_ENV['QUERY_STRING']))
{
$location .= "?".htmlspecialchars_uni($_ENV['QUERY_STRING']);

		}

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

		}

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

	

	

			foreach($post_array as $var)

			foreach($post_array as $var)

			{

			{

				if(isset($_POST[$var]))

				if(isset($_POST[$var]))

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

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

			}

if(isset($addloc) && is_array($addloc))
{

			}

if(isset($addloc) && is_array($addloc))
{

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









				if(strpos($location, "?") === false)
{
$location .= "?";
}
else
{
$location .= "&amp;";
}
$location .= implode("&amp;", $addloc);

			}
}

			}
}

	

 
	
return $location;
}

	
return $location;
}

Zeile 3625Zeile 3674
			$decimals = 0;
}


			$decimals = 0;
}


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


































































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

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

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

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

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

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

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

	}
}


	}
}


Zeile 3636Zeile 3750
 * @return string The word wraped string
*/
function my_wordwrap($message)

 * @return string The word wraped string
*/
function my_wordwrap($message)

{

{

	global $mybb;

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

	global $mybb;

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

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

	{
$message = convert_through_utf8($message);

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



		{

		{

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

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

		}

		}

 
		
$new_message = convert_through_utf8($new_message, false);

return $new_message;

	}

return $message;
}

	}

return $message;
}





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

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

Zeile 3688Zeile 3804
					$h = 7;
}
}

					$h = 7;
}
}

		}
}

		}
}

}

/**

}

/**

Zeile 3760Zeile 3876
	$find = array(
'm',
'd',

	$find = array(
'm',
'd',

 
		'D',

		'y',
'Y',
'j',
'S',
'l',
'F',

		'y',
'Y',
'j',
'S',
'l',
'F',

 
		'M',

	);

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

	);

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

 
		($wd == 2 ? my_substr($bdays[$wd], 0, 4) : ($wd == 4 ? my_substr($bdays[$wd], 0, 5) : my_substr($bdays[$wd], 0, 3))),

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

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

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

		($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],

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

	);

	);

 
	
// Do we have the full month in our output?
// If so there's no need for the short month
if(strpos($display, 'F') !== false)
{
array_pop($find);
array_pop($replace);
}

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

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

Zeile 3797Zeile 3925
	}

list($day, $month, $year) = explode("-", my_date("j-n-Y", TIME_NOW, 0, 0));

	}

list($day, $month, $year) = explode("-", my_date("j-n-Y", TIME_NOW, 0, 0));





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

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

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

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

Zeile 3805Zeile 3933
		--$age;
}
return $age;

		--$age;
}
return $age;

}

/**

}

/**

 * Updates the first posts in a thread.
*
* @param int The thread id for which to update the first post id.

 * Updates the first posts in a thread.
*
* @param int The thread id for which to update the first post id.

Zeile 3987Zeile 4115
 * @return int The un-htmlentitied' string.
*/
function unhtmlentities($string)

 * @return int The un-htmlentitied' string.
*/
function unhtmlentities($string)

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








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

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

return strtr($string, $trans_tbl);
}





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

return strtr($string, $trans_tbl);



























/**
* Returns any ascii to it's character (utf-8 safe).
*
* @param string The ascii to characterize.
* @return int The characterized ascii.
*/
function unichr($c)
{
if($c <= 0x7F)
{
return chr($c);
}
else if($c <= 0x7FF)
{
return chr(0xC0 | $c >> 6) . chr(0x80 | $c & 0x3F);
}
else if($c <= 0xFFFF)
{
return chr(0xE0 | $c >> 12) . chr(0x80 | $c >> 6 & 0x3F)
. chr(0x80 | $c & 0x3F);
}
else if($c <= 0x10FFFF)
{
return chr(0xF0 | $c >> 18) . chr(0x80 | $c >> 12 & 0x3F)
. chr(0x80 | $c >> 6 & 0x3F)
. chr(0x80 | $c & 0x3F);
}
else
{
return false;
}

}

/**

}

/**

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

return $event_date;

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

return $event_date;

}

/**

}

/**

 * Get the profile link.
*
* @param int The user id of the profile.

 * Get the profile link.
*
* @param int The user id of the profile.

Zeile 4046Zeile 4207
 * @return string The url to the announcement.
*/
function get_announcement_link($aid=0)

 * @return string The url to the announcement.
*/
function get_announcement_link($aid=0)

{

{

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

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

Zeile 4065Zeile 4226
	global $lang;

if(!$username && $uid == 0)

	global $lang;

if(!$username && $uid == 0)

	{

	{

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

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

Zeile 4078Zeile 4239
	{
// Build the profile link for the registered user
if(!empty($target))

	{
// Build the profile link for the registered user
if(!empty($target))

		{

		{

			$target = " target=\"{$target}\"";
}


			$target = " target=\"{$target}\"";
}


Zeile 4090Zeile 4251
		// If we're in the archive, link back a directory
if(IN_ARCHIVE == 1)
{

		// If we're in the archive, link back a directory
if(IN_ARCHIVE == 1)
{

			global $mybb;

if($mybb->settings['seourls'] == "yes" || ($mybb->settings['seourls'] == "auto" && $_SERVER['SEO_SUPPORT'] == 1))
{
return "<a href=\"../../".get_profile_link($uid)."\"{$target}{$onclick}>{$username}</a>";
}

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

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








		}
elseif(IN_ADMINCP == 1)
{

		}
elseif(IN_ADMINCP == 1)
{

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

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

		}

		}

	}
}


	}
}


Zeile 4255Zeile 4409
 */
function get_calendar_week_link($calendar, $week)
{

 */
function get_calendar_week_link($calendar, $week)
{

 
	if($week < 0)
{
$week = str_replace('-', "n", $week);
}

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

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

Zeile 4329Zeile 4487
	}

return $forum_cache[$fid];

	}

return $forum_cache[$fid];

}


}


/**
* Get the thread of a thread id.
*

/**
* Get the thread of a thread id.
*

Zeile 4508Zeile 4666
		}

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

		}

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

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

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

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

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

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

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

			return 1;
}
// Not waited long enough

			return 1;
}
// Not waited long enough

		else

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

		{
if($fatal)
{

		{
if($fatal)
{

Zeile 4528Zeile 4686

return false;
}


return false;
}

	}


	}


	// User can attempt another login
return $loginattempts;

	// User can attempt another login
return $loginattempts;

}


}


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

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

Zeile 4547Zeile 4705
		return false;
}
// Valid local characters for email addresses: http://www.remote.org/jochen/mail/info/chars.html

		return false;
}
// Valid local characters for email addresses: http://www.remote.org/jochen/mail/info/chars.html

	return preg_match("/^[a-zA-Z0-9&*+\-_.{}~^\?=\/]+@[a-zA-Z0-9-]+\.[a-zA-Z0-9.-]+$/si", $email);

	return preg_match("/^[a-zA-Z0-9&*+\-_.{}~^\?=\/]+@[a-zA-Z0-9-]+\.([a-zA-Z0-9-]+\.)*[a-zA-Z0-9-]{2,}$/si", $email);

}

/**

}

/**

Zeile 4556Zeile 4714
 * @param string The email to check.
* @param string User ID of the user (updating only)
* @return boolean True when in use, false when not.

 * @param string The email to check.
* @param string User ID of the user (updating only)
* @return boolean True when in use, false when not.

 */

 */

function email_already_in_use($email, $uid="")
{
global $db;

function email_already_in_use($email, $uid="")
{
global $db;

Zeile 4574Zeile 4732
	}

return false;

	}

return false;

}


}


/*
* DEPRECATED! ONLY INCLUDED FOR COMPATIBILITY PURPOSES.
*/
function rebuildsettings()
{
rebuild_settings();

/*
* DEPRECATED! ONLY INCLUDED FOR COMPATIBILITY PURPOSES.
*/
function rebuildsettings()
{
rebuild_settings();

}

/**

}

/**

 * Rebuilds settings.php
*
*/

 * Rebuilds settings.php
*
*/

Zeile 4593Zeile 4751
	global $db, $mybb;

if(!file_exists(MYBB_ROOT."inc/settings.php"))

	global $db, $mybb;

if(!file_exists(MYBB_ROOT."inc/settings.php"))

	{

	{

		$mode = "x";
}
else

		$mode = "x";
}
else

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

 */
function build_highlight_array($terms)
{

	$terms = htmlspecialchars_uni($terms);







	global $mybb;

if($mybb->settings['minsearchword'] < 1)
{
$mybb->settings['minsearchword'] = 3;
}


	// 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 4641Zeile 4804
		"~"
);
$terms = str_replace($bad_characters, '', $terms);

		"~"
);
$terms = str_replace($bad_characters, '', $terms);





	// Check if this is a "series of words" - should be treated as an EXACT match
if(my_strpos($terms, "\"") !== false)
{

	// Check if this is a "series of words" - should be treated as an EXACT match
if(my_strpos($terms, "\"") !== false)
{

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

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

 
			$phrase = htmlspecialchars_uni($phrase);

			if($phrase != "")

			if($phrase != "")

			{

			{

				if($inquote)
{

				if($inquote)
{

					$words[] = "\"".trim($phrase)."\"";

					$words[] = trim($phrase);

				}
else
{

				}
else
{

Zeile 4664Zeile 4828
					}
foreach($split_words as $word)
{

					}
foreach($split_words as $word)
{

						if(!$word)

						if(!$word || strlen($word) < $mybb->settings['minsearchword'])

						{
continue;
}

						{
continue;
}

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

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

 
		$terms = htmlspecialchars_uni($terms);

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

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

		{

		{

			continue;
}
foreach($split_words as $word)
{

			continue;
}
foreach($split_words as $word)
{

			if(!$word)

			if(!$word || strlen($word) < $mybb->settings['minsearchword'])

			{
continue;
}

			{
continue;
}

Zeile 4698Zeile 4863
	{
return false;
}

	{
return false;
}

 
	
// Sort the word array by length. Largest terms go first and work their way down to the smallest term.
// This resolves problems like "test tes" where "tes" will be highlighted first, then "test" can't be highlighted because of the changed html
usort($words, create_function('$a,$b','return strlen($b) - strlen($a);'));


// Loop through our words to build the PREG compatible strings
foreach($words as $word)


// Loop through our words to build the PREG compatible strings
foreach($words as $word)

Zeile 4708Zeile 4877
	
// Special boolean operators should be stripped
if($word == "" || $word == "or" || $word == "not" || $word == "and")

	
// Special boolean operators should be stripped
if($word == "" || $word == "or" || $word == "not" || $word == "and")

		{

		{

			continue;
}

// Now make PREG compatible

			continue;
}

// Now make PREG compatible

		$find = "#(^|>)([^<]*)(".preg_quote($word, "#").")#i";
$replacement = "$1$2<span class=\"highlight\">$3</span>";

		$find = "#(?!<.*?)(".preg_quote($word, "#").")(?![^<>]*?>)#i";
$replacement = "<span class=\"highlight\" style=\"padding-left: 0px; padding-right: 0px;\">$1</span>";

		$highlight_cache[$find] = $replacement;
}


		$highlight_cache[$find] = $replacement;
}


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

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

	{

	{

		$dest .= chr($src);

		$dest .= chr($src);

	}

	}

	elseif($src <= 0x07ff)

	elseif($src <= 0x07ff)

	{

	{

		$dest .= chr(0xc0 | ($src >> 6));
$dest .= chr(0x80 | ($src & 0x003f));
}
elseif($src <= 0xffff)

		$dest .= chr(0xc0 | ($src >> 6));
$dest .= chr(0x80 | ($src & 0x003f));
}
elseif($src <= 0xffff)

	{

	{

		$dest .= chr(0xe0 | ($src >> 12));
$dest .= chr(0x80 | (($src >> 6) & 0x003f));
$dest .= chr(0x80 | ($src & 0x003f));

		$dest .= chr(0xe0 | ($src >> 12));
$dest .= chr(0x80 | (($src >> 6) & 0x003f));
$dest .= chr(0x80 | ($src & 0x003f));

Zeile 4782Zeile 4951
		// Make regular expression * match
$banned_username['filter'] = str_replace('\*', '(.*)', preg_quote($banned_username['filter'], '#'));
if(preg_match("#{$banned_username['filter']}#i", $username))

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

		{
// Updating last use
if($update_lastuse == true)
{

		{
// Updating last use
if($update_lastuse == true)
{

				$db->update_query("banfilters", array("lastuse" => TIME_NOW), "fid='{$banned_username['fid']}'");
}
return true;
}
}
// Still here - good username

				$db->update_query("banfilters", array("lastuse" => TIME_NOW), "fid='{$banned_username['fid']}'");
}
return true;
}
}
// Still here - good username

	return false;
}

/**

	return false;
}

/**

 * Check if a specific email address has been banned.
*
* @param string The email address.

 * Check if a specific email address has been banned.
*
* @param string The email address.

Zeile 4811Zeile 4980
		// Make regular expression * match
$banned_email['filter'] = str_replace('\*', '(.*)', preg_quote($banned_email['filter'], '#'));
if(preg_match("#{$banned_email['filter']}#i", $email))

		// 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($update_lastuse == true)

		{
// Updating last use
if($update_lastuse == true)

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

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

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

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

			}
return true;
}
}

			}
return true;
}
}

	// Still here - good ip
return false;
}

	// Still here - good ip
return false;
}

Zeile 4953Zeile 5122
 * @param string The URL of the remote file
* @return string The remote file contents.
*/

 * @param string The URL of the remote file
* @return string The remote file contents.
*/

function fetch_remote_file($url)

function fetch_remote_file($url, $post_data=array())

{

{

 
	$post_body = '';
if(!empty($post_data))
{
foreach($post_data as $key => $val)
{
$post_body .= '&'.urlencode($key).'='.urlencode($val);
}
$post_body = ltrim($post_body, '&');
}


	if(function_exists("curl_init"))
{
$ch = curl_init();

	if(function_exists("curl_init"))
{
$ch = curl_init();

Zeile 4962Zeile 5141
		curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

		curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

 
		if(!empty($post_body))
{
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_body);
}

		$data = curl_exec($ch);
curl_close($ch);
return $data;
}

		$data = curl_exec($ch);
curl_close($ch);
return $data;
}

	else if(function_exists("fsockopen"))

 	else if(function_exists("fsockopen"))

	{
$url = @parse_url($url);
if(!$url['host'])

	{
$url = @parse_url($url);
if(!$url['host'])

Zeile 4976Zeile 5160
		if(!$url['port'])
{
$url['port'] = 80;

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

		}

		}

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

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

		{

		{

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

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

		{
return false;





















		{
return false;
}
$headers = array();
if(!empty($post_body))
{
$headers[] = "POST {$url['path']} HTTP/1.0";
$headers[] = "Content-Length: ".strlen($post_body);
$headers[] = "Content-Type: application/x-www-form-urlencoded";
}
else
{
$headers[] = "GET {$url['path']} HTTP/1.0";
}

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

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

		}

		}

		$headers = "GET {$url['path']} HTTP/1.1\r\n";
$headers .= "Host: {$url['host']}\r\n";
$headers .= "Connection: Close\r\n\r\n";

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


		if(!@fwrite($fp, $headers))
{
return false;

		if(!@fwrite($fp, $headers))
{
return false;

Zeile 5006Zeile 5209
		$data = explode("\r\n\r\n", $data, 2);
return $data[1];
}

		$data = explode("\r\n\r\n", $data, 2);
return $data[1];
}

	else

	else if(empty($post_data))

	{
return @implode("", @file($url));

	{
return @implode("", @file($url));

	}
}

/**





	}
else
{
return false;
}
}

/**

 * Checks if a particular user is a super administrator.
*
* @param int The user ID to check against the list of super admins

 * Checks if a particular user is a super administrator.
*
* @param int The user ID to check against the list of super admins

Zeile 5103Zeile 5310
function fetch_longipv4_range($ip)
{
$ip_bits = explode(".", $ip);

function fetch_longipv4_range($ip)
{
$ip_bits = explode(".", $ip);

 
	$ip_string1 = $ip_string2 = "";





	if($ip == "*") return array(ip2long(0), ip2long(255));




	if($ip == "*")
{
return array(ip2long('0.0.0.0'), ip2long('255.255.255.255'));
}


if(strpos($ip, ".*") === false)
{


if(strpos($ip, ".*") === false)
{

Zeile 5112Zeile 5323
		if(count($ip_bits) == 4)
{
return ip2long($ip);

		if(count($ip_bits) == 4)
{
return ip2long($ip);

		}

		}

		else
{
return array(ip2long($ip.".0"), ip2long($ip.".255"));

		else
{
return array(ip2long($ip.".0"), ip2long($ip.".255"));

Zeile 5121Zeile 5332
	// Wildcard based IP provided
else
{

	// Wildcard based IP provided
else
{

 
		$sep = "";

		foreach($ip_bits as $piece)
{
if($piece == "*")
{

		foreach($ip_bits as $piece)
{
if($piece == "*")
{

				return array(ip2long($ip_string."0"), ip2long($ip_string."255"));


				$ip_string1 .= $sep."0";
$ip_string2 .= $sep."255";

			}
else
{

			}
else
{

				$ip_string .= $piece.".";


				$ip_string1 .= $sep.$piece;
$ip_string2 .= $sep.$piece;

			}

			}

 
			$sep = ".";

		}

		}

 
		return array(ip2long($ip_string1), ip2long($ip_string2));

	}
}


	}
}


Zeile 5164Zeile 5380
		"0-0-1" => "1 {$lang->year}",
"0-0-2" => "2 {$lang->years}"
);

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





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

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

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

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

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

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

	}

	}

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

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

Zeile 5191Zeile 5407
	$n[2] += $d[1];
$n[3] += $d[2];
return mktime(date("G"), date("i"), 0, $n[2], $n[1], $n[3]);

	$n[2] += $d[1];
$n[3] += $d[2];
return mktime(date("G"), date("i"), 0, $n[2], $n[1], $n[3]);

}


}


/**
* Expire old warnings in the database.
*

/**
* Expire old warnings in the database.
*

Zeile 5200Zeile 5416
function expire_warnings()
{
global $db;

function expire_warnings()
{
global $db;

 
	
$users = array();


	$query = $db->query("
SELECT w.wid, w.uid, w.points, u.warningpoints
FROM ".TABLE_PREFIX."warnings w

	$query = $db->query("
SELECT w.wid, w.uid, w.points, u.warningpoints
FROM ".TABLE_PREFIX."warnings w

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

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

		$warning['warningpoints'] -= $warning['points'];
if($warning['warningpoints'] < 0)













		
if(array_key_exists($warning['uid'], $users))
{
$users[$warning['uid']] -= $warning['points'];
}
else
{
$users[$warning['uid']] = $warning['warningpoints']-$warning['points'];
}
}

foreach($users as $uid => $warningpoints)
{
if($warningpoints < 0)

		{

		{

			$warning['warningpoints'] = 0;

			$warningpoints = 0;

		}

		}

 
		

		$updated_user = array(

		$updated_user = array(

			"warningpoints" => intval($warning['warningpoints'])

			"warningpoints" => intval($warningpoints)

		);

		);

		$db->update_query("users", $updated_user, "uid='{$warning['uid']}'");

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

	}
}


	}
}


Zeile 5243Zeile 5475
    elseif($c <= 0xFFFF)
{
return chr(0xE0 | $c >> 12) . chr(0x80 | $c >> 6 & 0x3F)

    elseif($c <= 0xFFFF)
{
return chr(0xE0 | $c >> 12) . chr(0x80 | $c >> 6 & 0x3F)

                                    . chr(0x80 | $c & 0x3F);

                                    . chr(0x80 | $c & 0x3F);

    }
elseif($c <= 0x10FFFF)
{

    }
elseif($c <= 0x10FFFF)
{

Zeile 5262Zeile 5494
 *
* @param string The file to chmod
* @param string The mode to chmod(i.e. 0666)

 *
* @param string The file to chmod
* @param string The mode to chmod(i.e. 0666)

 */

 */

function my_chmod($file, $mode)
{
// Passing $mode as an octal number causes strlen and substr to return incorrect values. Instead pass as a string

function my_chmod($file, $mode)
{
// Passing $mode as an octal number causes strlen and substr to return incorrect values. Instead pass as a string

Zeile 5271Zeile 5503
		return false;
}
$old_umask = umask(0);

		return false;
}
$old_umask = umask(0);

	

	

	// We convert the octal string to a decimal number because passing a octal string doesn't work with chmod
// and type casting subsequently removes the prepended 0 which is needed for octal numbers
$result = chmod($file, octdec($mode));

	// We convert the octal string to a decimal number because passing a octal string doesn't work with chmod
// and type casting subsequently removes the prepended 0 which is needed for octal numbers
$result = chmod($file, octdec($mode));

Zeile 5290Zeile 5522
	global $orig_dir;

if(!isset($orig_dir))

	global $orig_dir;

if(!isset($orig_dir))

	{

	{

		$orig_dir = $path;
}


		$orig_dir = $path;
}


Zeile 5318Zeile 5550
    }

return @unlink($path);

    }

return @unlink($path);

 
}

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

return $count;

}

?>

}

?>