Vergleich inc/functions.php - 1.4.8 - 1.4.16

  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 4377 2009-06-04 11:33:13Z Tomm $

 * $Id: functions.php 5379 2011-02-21 11:06:42Z Tomm $

 */

/**

 */

/**

Zeile 154Zeile 154
	// If our DB has been deconstructed already (bad PHP 5.2.0), reconstruct
if(!is_object($db))
{

	// If our DB has been deconstructed already (bad PHP 5.2.0), reconstruct
if(!is_object($db))
{

		if(!isset($config))

		if(!isset($config) || empty($config['database']['type']))

		{
require MYBB_ROOT."inc/config.php";
}

		{
require MYBB_ROOT."inc/config.php";
}

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 1267Zeile 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'])
{

Zeile 1299Zeile 1299

if($showform)
{


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 1318Zeile 1325
{
global $mybb, $db;
static $modpermscache;

{
global $mybb, $db;
static $modpermscache;





	if($uid < 1)

	if($uid < 1)

	{

	{

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

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

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

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

	}

	}

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

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

		}


		}


		$sql = build_parent_list($fid, "fid", "OR", $parentslist);
$query = $db->simple_select("moderators", "*", "uid='{$uid}' AND {$sql}");
$perms = $db->fetch_array($query);

		$sql = build_parent_list($fid, "fid", "OR", $parentslist);
$query = $db->simple_select("moderators", "*", "uid='{$uid}' AND {$sql}");
$perms = $db->fetch_array($query);

Zeile 1366Zeile 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)
{


if($uid == 0)
{

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


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


Zeile 1500Zeile 1507
			$expires = 0;
}
else

			$expires = 0;
}
else

		{

		{

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

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

	}

	}

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

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

	}


	}


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

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





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

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





	if($expires > 0)
{
$cookie .= "; expires=".@gmdate('D, d-M-Y H:i:s \\G\\M\\T', $expires);

	if($expires > 0)
{
$cookie .= "; expires=".@gmdate('D, d-M-Y H:i:s \\G\\M\\T', $expires);

Zeile 1539Zeile 1546
	$mybb->cookies[$name] = $value;

header($cookie, false);

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

header($cookie, false);

}

}


/**
* Unset a cookie set by MyBB.


/**
* Unset a cookie set by MyBB.

Zeile 1547Zeile 1554
 * @param string The cookie identifier.
*/
function my_unsetcookie($name)

 * @param string The cookie identifier.
*/
function my_unsetcookie($name)

{

{

	global $mybb;

$expires = -3600;

	global $mybb;

$expires = -3600;

Zeile 1564Zeile 1571
 * @return array|boolean The cookie id's content array or false when non-existent.
*/
function my_get_array_cookie($name, $id)

 * @return array|boolean The cookie id's content array or false when non-existent.
*/
function my_get_array_cookie($name, $id)

{
global $mybb;


{
global $mybb;


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

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

Zeile 1574Zeile 1581

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



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


	if(isset($cookie[$id]))

	if(is_array($cookie) && isset($cookie[$id]))

	{
return $cookie[$id];
}
else
{
return 0;

	{
return $cookie[$id];
}
else
{
return 0;

	}
}

/**

	}
}

/**

 * Set a serialised cookie array.
*
* @param string The cookie identifier.

 * Set a serialised cookie array.
*
* @param string The cookie identifier.

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

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

{

{

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

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

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

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

			{

			{

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

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

Zeile 1646Zeile 1660
				{
return $lang->unknown;
}

				{
return $lang->unknown;
}

			}


			}


			$load = @exec("uptime");

			$load = @exec("uptime");

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

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

			$serverload = explode(",", $load[1]);
if(!is_array($serverload))
{
return $lang->unknown;

			$serverload = explode(",", $load[1]);
if(!is_array($serverload))
{
return $lang->unknown;

			}
}
}

			}
}
}

	else
{
return $lang->unknown;
}

	else
{
return $lang->unknown;
}


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


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


return $returnload;
}


return $returnload;
}

Zeile 1677Zeile 1691
	global $cache, $db;

$stats = $cache->read("stats");

	global $cache, $db;

$stats = $cache->read("stats");





	$counters = array('numthreads','numunapprovedthreads','numposts','numunapprovedposts','numusers');
$update = array();
foreach($counters as $counter)

	$counters = array('numthreads','numunapprovedthreads','numposts','numunapprovedposts','numusers');
$update = array();
foreach($counters as $counter)

Zeile 1692Zeile 1706
			else
{
$new_stats[$counter] = $changes[$counter];

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

Zeile 1742Zeile 1756
	global $db, $cache;

$update_query = array();

	global $db, $cache;

$update_query = array();





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

// Fetch above counters for this forum

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

// Fetch above counters for this forum

Zeile 1766Zeile 1780
			if($update_query[$counter] < 0)
{
$update_query[$counter] = 0;

			if($update_query[$counter] < 0)
{
$update_query[$counter] = 0;

			}

			}

		}
}


		}
}


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

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

			}
}

			}
}

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

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

Zeile 1799Zeile 1813
			if($unapprovedthreads_diff > -1)
{
$new_stats['numunapprovedthreads'] = "+{$unapprovedthreads_diff}";

			if($unapprovedthreads_diff > -1)
{
$new_stats['numunapprovedthreads'] = "+{$unapprovedthreads_diff}";

			}

			}

			else
{
$new_stats['numunapprovedthreads'] = "{$unapprovedthreads_diff}";

			else
{
$new_stats['numunapprovedthreads'] = "{$unapprovedthreads_diff}";

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

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

			}

			}

		}

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

		}

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

Zeile 1832Zeile 1846
			}
}
update_stats($new_stats);

			}
}
update_stats($new_stats);

	}

	}


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


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

 
	
$cache->update_forums();

}

/**

}

/**

Zeile 1975Zeile 1991
	$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']),

		'lastpost' => intval($lastpost['dateline']),
'lastposter' => $lastpost['username'],
'lastposteruid' => intval($lastpost['uid']),

Zeile 2031Zeile 2048
	}

return $moderation->delete_post($pid);

	}

return $moderation->delete_post($pid);

}

}


/**
* Builds a forum jump menu


/**
* Builds a forum jump menu

Zeile 2055Zeile 2072
	if($permissions)
{
$permissions = $mybb->usergroup;

	if($permissions)
{
$permissions = $mybb->usergroup;

	}


	}


	if(!is_array($jumpfcache))
{
if(!is_array($forum_cache))

	if(!is_array($jumpfcache))
{
if(!is_array($forum_cache))

Zeile 2097Zeile 2114
					}

$forum['name'] = htmlspecialchars_uni(strip_tags($forum['name']));

					}

$forum['name'] = htmlspecialchars_uni(strip_tags($forum['name']));





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

if($forum_cache[$forum['fid']])

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

if($forum_cache[$forum['fid']])

Zeile 2113Zeile 2130
	if($addselect)
{
if(!$selecteddone)

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

		{

		{

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

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





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

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

		}


		}


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

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

Zeile 2135Zeile 2152
	}

return $forumjump;

	}

return $forumjump;

}

/**

}

/**

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

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

Zeile 2161Zeile 2178

for($i = 1; $i <= $length; ++$i)
{


for($i = 1; $i <= $length; ++$i)
{

		$ch = mt_rand(0, count($set)-1);

		$ch = my_rand(0, count($set)-1);

		$str .= $set[$ch];

		$str .= $set[$ch];

	}


	}


	return $str;
}


	return $str;
}


Zeile 2296Zeile 2313
	if($mybb->settings['smilieinserter'] != 0 && $mybb->settings['smilieinsertercols'] && $mybb->settings['smilieinsertertot'])
{
if(!$smiliecount)

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

		{

		{

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

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

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

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

				}
}

				}
}

		}

		}





		unset($smilie);

if(is_array($smiliecache))
{
reset($smiliecache);

		unset($smilie);

if(is_array($smiliecache))
{
reset($smiliecache);





			if($mybb->settings['smilieinsertertot'] >= $smiliecount)
{
$mybb->settings['smilieinsertertot'] = $smiliecount;

			if($mybb->settings['smilieinsertertot'] >= $smiliecount)
{
$mybb->settings['smilieinsertertot'] = $smiliecount;

Zeile 2362Zeile 2379
			{
$colspan = $mybb->settings['smilieinsertercols'] - $counter;
$smilies .= "<td colspan=\"{$colspan}\">&nbsp;</td>\n</tr>\n";

			{
$colspan = $mybb->settings['smilieinsertercols'] - $counter;
$smilies .= "<td colspan=\"{$colspan}\">&nbsp;</td>\n</tr>\n";

			}

			}


eval("\$clickablesmilies = \"".$templates->get("smilieinsert")."\";");
}


eval("\$clickablesmilies = \"".$templates->get("smilieinsert")."\";");
}

Zeile 2395Zeile 2412
		if(isset($_SERVER['HTTP_ACCEPT_ENCODING']))
{
$httpaccept_encoding = $_SERVER['HTTP_ACCEPT_ENCODING'];

		if(isset($_SERVER['HTTP_ACCEPT_ENCODING']))
{
$httpaccept_encoding = $_SERVER['HTTP_ACCEPT_ENCODING'];

		}


		}


		if(my_strpos(" ".$httpaccept_encoding, "x-gzip"))
{
$encoding = "x-gzip";

		if(my_strpos(" ".$httpaccept_encoding, "x-gzip"))
{
$encoding = "x-gzip";

Zeile 2429Zeile 2446
	}

return $contents;

	}

return $contents;

}

}


/**
* Log the actions of a moderator.


/**
* Log the actions of a moderator.

Zeile 2561Zeile 2578
		$ip = $_SERVER['REMOTE_ADDR'];
}
elseif(isset($_SERVER['HTTP_X_FORWARDED_FOR']))

		$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))
{
foreach($addresses[0] as $key => $val)

		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))
{
foreach($addresses[0] as $key => $val)

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

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

		}

		}

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

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

Zeile 2732Zeile 2749
	if(!is_array($forum_cache))
{
cache_forums();

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

	}

	}


if(!is_array($permissioncache))
{


if(!is_array($permissioncache))
{

Zeile 2748Zeile 2765
		else
{
$perms = $mybb->usergroup;

		else
{
$perms = $mybb->usergroup;

		}


		}


		$pwverified = 1;

		$pwverified = 1;





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

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

			}
}


			}
}


		if($perms['canview'] == 0 || $pwverified == 0 || ($only_readable_threads == true && $perms['canviewthreads'] == 0))
{
if($unviewableforums)

		if($perms['canview'] == 0 || $pwverified == 0 || ($only_readable_threads == true && $perms['canviewthreads'] == 0))
{
if($unviewableforums)

Zeile 2772Zeile 2789
	}

return $unviewableforums;

	}

return $unviewableforums;

}

}


/**
* Fixes mktime for dates earlier than 1970


/**
* Fixes mktime for dates earlier than 1970

Zeile 2780Zeile 2797
 * @param string The date format to use
* @param int The year of the date
* @return string The correct date format

 * @param string The date format to use
* @param int The year of the date
* @return string The correct date format

 */

 */

function fix_mktime($format, $year)
{
// Our little work around for the date < 1970 thing.

function fix_mktime($format, $year)
{
// Our little work around for the date < 1970 thing.

Zeile 2812Zeile 2829
				if(isset($navbits[$key+2]))
{
$sep = $navsep;

				if(isset($navbits[$key+2]))
{
$sep = $navsep;

				}

				}

				else
{
$sep = "";
}

				else
{
$sep = "";
}





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

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

		}
}

$navsize = count($navbits);
$navbit = $navbits[$navsize-1];


		}
}

$navsize = count($navbits);
$navbit = $navbits[$navsize-1];


	if($nav)
{
eval("\$activesep = \"".$templates->get("nav_sep_active")."\";");

	if($nav)
{
eval("\$activesep = \"".$templates->get("nav_sep_active")."\";");

Zeile 2842Zeile 2859
 *
* @param string The name of the item to add
* @param string The URL of the item to add

 *
* @param string The name of the item to add
* @param string The URL of the item to add

 */

 */

function add_breadcrumb($name, $url="")
{
global $navbits;

function add_breadcrumb($name, $url="")
{
global $navbits;

Zeile 2866Zeile 2883
		if(!is_array($forum_cache))
{
cache_forums();

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

		}


		}


		foreach($forum_cache as $key => $val)
{
$pforumcache[$val['fid']][$val['pid']] = $val;

		foreach($forum_cache as $key => $val)
{
$pforumcache[$val['fid']][$val['pid']] = $val;

Zeile 2886Zeile 2903
				}

$navsize = count($navbits);

				}

$navsize = count($navbits);

				$navbits[$navsize]['name'] = htmlspecialchars_uni($forumnav['name']);


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


if(IN_ARCHIVE == 1)
{
// Set up link to forum in breadcrumb.
if($pforumcache[$fid][$forumnav['pid']]['type'] == 'f' || $pforumcache[$fid][$forumnav['pid']]['type'] == 'c')


if(IN_ARCHIVE == 1)
{
// Set up link to forum in breadcrumb.
if($pforumcache[$fid][$forumnav['pid']]['type'] == 'f' || $pforumcache[$fid][$forumnav['pid']]['type'] == 'c')

					{

					{

						$navbits[$navsize]['url'] = "{$base_url}forum-".$forumnav['fid'].".html";
}
else

						$navbits[$navsize]['url'] = "{$base_url}forum-".$forumnav['fid'].".html";
}
else

Zeile 3663Zeile 3681
			$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']);

	}
}


	}
}


Zeile 4480Zeile 4498

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


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

 *

 *

 * @param int The thread id of the thread.
* @return string The database row of the thread.
*/
function get_thread($tid)

 * @param int The thread id of the thread.
* @return string The database row of the thread.
*/
function get_thread($tid)

{
global $db;

{
global $db;

	static $thread_cache;

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

	static $thread_cache;

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

	}

	}

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

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





		if($thread)
{
$thread_cache[$tid] = $thread;

		if($thread)
{
$thread_cache[$tid] = $thread;

Zeile 4525Zeile 4543
	if(isset($post_cache[$pid]))
{
return $post_cache[$pid];

	if(isset($post_cache[$pid]))
{
return $post_cache[$pid];

	}

	}

	else
{
$query = $db->simple_select("posts", "*", "pid='".intval($pid)."'");

	else
{
$query = $db->simple_select("posts", "*", "pid='".intval($pid)."'");

Zeile 4537Zeile 4555
			return $post;
}
else

			return $post;
}
else

		{

		{

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

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

Zeile 4554Zeile 4572
	global $forum_cache, $cache, $inactiveforums;

if(!$forum_cache)

	global $forum_cache, $cache, $inactiveforums;

if(!$forum_cache)

	{

	{

		cache_forums();
}


		cache_forums();
}


Zeile 4570Zeile 4588
				if(my_strpos(",".$forum1['parentlist'].",", ",".$fid.",") !== false && !in_array($fid1, $inactive))
{
$inactive[] = $fid1;

				if(my_strpos(",".$forum1['parentlist'].",", ",".$fid.",") !== false && !in_array($fid1, $inactive))
{
$inactive[] = $fid1;

				}

				}

			}
}
}
$inactiveforums = implode(",", $inactive);

			}
}
}
$inactiveforums = implode(",", $inactive);





	return $inactiveforums;
}


	return $inactiveforums;
}


Zeile 4591Zeile 4609
	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 4614Zeile 4632
	if(empty($cookietime) || $cookietime < $session->failedlogin)
{
$failedlogin = $session->failedlogin;

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

	}
else

	}
else

	{
$failedlogin = $cookietime;
}

	{
$failedlogin = $cookietime;
}

Zeile 4694Zeile 4712
		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 4751Zeile 4769
	$options = array(
"order_by" => "title",
"order_dir" => "ASC"

	$options = array(
"order_by" => "title",
"order_dir" => "ASC"

	);

	);

	$query = $db->simple_select("settings", "value, name", "", $options);

while($setting = $db->fetch_array($query))

	$query = $db->simple_select("settings", "value, name", "", $options);

while($setting = $db->fetch_array($query))

Zeile 4768Zeile 4786

$GLOBALS['settings'] = &$mybb->settings;
}


$GLOBALS['settings'] = &$mybb->settings;
}





/**
* Build a PREG compatible array of search highlight terms to replace in posts.
*

/**
* Build a PREG compatible array of search highlight terms to replace in posts.
*

Zeile 4777Zeile 4795
 */
function build_highlight_array($terms)
{

 */
function build_highlight_array($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 4796Zeile 4821
		{
$phrase = htmlspecialchars_uni($phrase);
if($phrase != "")

		{
$phrase = htmlspecialchars_uni($phrase);
if($phrase != "")

			{

			{

				if($inquote)
{

				if($inquote)
{

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

					$words[] = trim($phrase);

				}
else
{

				}
else
{

Zeile 4810Zeile 4835
					}
foreach($split_words as $word)
{

					}
foreach($split_words as $word)
{

						if(!$word)

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

						{
continue;
}

						{
continue;
}

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

		$terms = htmlspecialchars_uni($terms);
$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;
}
$words[] = trim($word);
}


			{
continue;
}
$words[] = trim($word);
}


	}


	}


	if(!is_array($words))
{
return false;
}

	if(!is_array($words))
{
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 4860Zeile 4889
		}

// Now make PREG compatible

		}

// 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 5545Zeile 5574
	}

return $count;

	}

return $count;

 
}

/**
* 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
*/
function secure_seed_rng($count=8)
{
$output = '';

// Try the unix/linux method
if(@is_readable('/dev/urandom') && ($handle = @fopen('/dev/urandom', 'rb')))
{
$output = @fread($handle, $count);
@fclose($handle);
}

// Didn't work? Do we still not have enough bytes? Use our own (less secure) rng generator
if(strlen($output) < $count)
{
$output = '';

// Close to what PHP basically uses internally to seed, but not quite.
$unique_state = microtime().@getmypid();

for($i = 0; $i < $count; $i += 16)
{
$unique_state = md5(microtime().$unique_state);
$output .= pack('H*', md5($unique_state));
}
}

// /dev/urandom and openssl will always be twice as long as $count. base64_encode will roughly take up 33% more space but crc32 will put it to 32 characters
$output = hexdec(substr(dechex(crc32(base64_encode($output))), 0, $count));

return $output;
}

/**
* Wrapper function for mt_rand. Automatically seeds using a secure seed once.
*
* @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
*/
function my_rand($min=null, $max=null, $force_seed=false)
{
static $seeded = false;
static $obfuscator = 0;

if($seeded == false || $force_seed == true)
{
mt_srand(secure_seed_rng());
$seeded = true;

$obfuscator = abs((int) secure_seed_rng());

// Ensure that $obfuscator is <= mt_getrandmax() for 64 bit systems.
if($obfuscator > mt_getrandmax())
{
$obfuscator -= mt_getrandmax();
}
}

if($min !== null && $max !== null)
{
$distance = $max - $min;
if ($distance > 0)
{
return $min + (int)((float)($distance + 1) * (float)(mt_rand() ^ $obfuscator) / (mt_getrandmax() + 1));
}
else
{
return mt_rand($min, $max);
}
}
else
{
$val = mt_rand() ^ $obfuscator;
return $val;
}

}

?>

}

?>