Vergleich inc/functions.php - 1.8.12 - 1.8.22

  Keine Änderungen   Hinzugefügt   Modifiziert   Entfernt
Zeile 18Zeile 18
	global $db, $lang, $theme, $templates, $plugins, $mybb;
global $debug, $templatecache, $templatelist, $maintimer, $globaltime, $parsetime;


	global $db, $lang, $theme, $templates, $plugins, $mybb;
global $debug, $templatecache, $templatelist, $maintimer, $globaltime, $parsetime;


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

	$contents = parse_page($contents);
$totaltime = format_time_duration($maintimer->stop());
$contents = $plugins->run_hooks("pre_output_page", $contents);

	$contents = parse_page($contents);
$totaltime = format_time_duration($maintimer->stop());
$contents = $plugins->run_hooks("pre_output_page", $contents);

Zeile 322Zeile 323
/**
* Turn a unix timestamp in to a "friendly" date/time format for the user.
*

/**
* Turn a unix timestamp in to a "friendly" date/time format for the user.
*

 * @param string $format A date format according to PHP's date structure.

 * @param string $format A date format (either relative, normal or PHP's date() structure).

 * @param int $stamp The unix timestamp the date should be generated for.
* @param int|string $offset The offset in hours that should be applied to times. (timezones) Or an empty string to determine that automatically
* @param int $ty Whether or not to use today/yesterday formatting.

 * @param int $stamp The unix timestamp the date should be generated for.
* @param int|string $offset The offset in hours that should be applied to times. (timezones) Or an empty string to determine that automatically
* @param int $ty Whether or not to use today/yesterday formatting.

Zeile 380Zeile 381
	}

$todaysdate = $yesterdaysdate = '';

	}

$todaysdate = $yesterdaysdate = '';

	if($ty && ($format == $mybb->settings['dateformat'] || $format == 'relative'))

	if($ty && ($format == $mybb->settings['dateformat'] || $format == 'relative' || $format == 'normal'))

	{
$_stamp = TIME_NOW;
if($adodb == true)

	{
$_stamp = TIME_NOW;
if($adodb == true)

Zeile 470Zeile 471
			{
if($todaysdate == $date)
{

			{
if($todaysdate == $date)
{

					$date = $lang->sprintf($lang->today, $real_date);

					$date = $lang->sprintf($lang->today_rel, $real_date);

				}
else if($yesterdaysdate == $date)
{

				}
else if($yesterdaysdate == $date)
{

					$date = $lang->sprintf($lang->yesterday, $real_date);

					$date = $lang->sprintf($lang->yesterday_rel, $real_date);

				}
}


				}
}


Zeile 487Zeile 488
			{
$date .= gmdate($mybb->settings['timeformat'], $stamp + ($offset * 3600));
}

			{
$date .= gmdate($mybb->settings['timeformat'], $stamp + ($offset * 3600));
}

 
		}
}
elseif($format == 'normal')
{
// Normal format both date and time
if($ty != 2)
{
if($todaysdate == $date)
{
$date = $lang->today;
}
else if($yesterdaysdate == $date)
{
$date = $lang->yesterday;
}
}

$date .= $mybb->settings['datetimesep'];
if($adodb == true)
{
$date .= adodb_date($mybb->settings['timeformat'], $stamp + ($offset * 3600));
}
else
{
$date .= gmdate($mybb->settings['timeformat'], $stamp + ($offset * 3600));

		}
}
else

		}
}
else

Zeile 495Zeile 521
		{
if($todaysdate == $date)
{

		{
if($todaysdate == $date)
{

				$date = $lang->sprintf($lang->today, $real_date);

				$date = $lang->today;

			}
else if($yesterdaysdate == $date)

			}
else if($yesterdaysdate == $date)

			{
$date = $lang->sprintf($lang->yesterday, $real_date);
}
}

			{
$date = $lang->yesterday;
}
}

		else
{
if($adodb == true)
{
$date = adodb_date($format, $stamp + ($offset * 3600));

		else
{
if($adodb == true)
{
$date = adodb_date($format, $stamp + ($offset * 3600));

			}

			}

			else
{
$date = gmdate($format, $stamp + ($offset * 3600));
}

			else
{
$date = gmdate($format, $stamp + ($offset * 3600));
}

		}

		}

	}

if(is_object($plugins))

	}

if(is_object($plugins))

Zeile 545Zeile 571

// Does our object not exist? Create it
if(!is_object($mail))


// Does our object not exist? Create it
if(!is_object($mail))

	{

	{

		require_once MYBB_ROOT."inc/class_mailhandler.php";

if($mybb->settings['mail_handler'] == 'smtp')

		require_once MYBB_ROOT."inc/class_mailhandler.php";

if($mybb->settings['mail_handler'] == 'smtp')

Zeile 575Zeile 601
		if($mybb->settings['mail_parameters'] != '')
{
$mail->additional_parameters = $mybb->settings['mail_parameters'];

		if($mybb->settings['mail_parameters'] != '')
{
$mail->additional_parameters = $mybb->settings['mail_parameters'];

		}
}


		}
}


	// Build and send
$mail->build_message($to, $subject, $message, $from, $charset, $headers, $format, $message_text, $return_email);
return $mail->send();

	// Build and send
$mail->build_message($to, $subject, $message, $from, $charset, $headers, $format, $message_text, $return_email);
return $mail->send();

Zeile 596Zeile 622
		return md5($mybb->user['loginkey'].$mybb->user['salt'].$mybb->user['regdate']);
}
// Guests get a special string

		return md5($mybb->user['loginkey'].$mybb->user['salt'].$mybb->user['regdate']);
}
// Guests get a special string

	else
{
return md5($session->useragent.$mybb->config['database']['username'].$mybb->settings['internal']['encryption_key']);
}
}

	else
{
return md5($session->sid.$mybb->config['database']['username'].$mybb->settings['internal']['encryption_key']);
}
}


/**
* Verifies a POST check code is valid, if not shows an error (silently returns false on silent parameter)


/**
* Verifies a POST check code is valid, if not shows an error (silently returns false on silent parameter)

Zeile 621Zeile 647
		else
{
if(defined("IN_ADMINCP"))

		else
{
if(defined("IN_ADMINCP"))

			{

			{

				return false;
}
else

				return false;
}
else

Zeile 652Zeile 678
		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();

	else
{
cache_forums();

Zeile 664Zeile 690

/**
* Build a parent list of a specific forum, suitable for querying


/**
* Build a parent list of a specific forum, suitable for querying

 *

 *

 * @param int $fid The forum ID
* @param string $column The column name to add to the query
* @param string $joiner The joiner for each forum for querying (OR | AND | etc)

 * @param int $fid The forum ID
* @param string $column The column name to add to the query
* @param string $joiner The joiner for each forum for querying (OR | AND | etc)

Zeile 835Zeile 861
		else
{
echo json_encode(array_merge(array("errors" => $errors), $json_data));

		else
{
echo json_encode(array_merge(array("errors" => $errors), $json_data));

		}
exit;
}

		}
exit;
}


$errorlist = '';


$errorlist = '';





	foreach($errors as $error)
{

	foreach($errors as $error)
{

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

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

	}

	}





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

return $errors;

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

return $errors;

}

}


/**
* Presents the user with a "no permission" page


/**
* Presents the user with a "no permission" page

Zeile 860Zeile 886

$time = TIME_NOW;
$plugins->run_hooks("no_permission");


$time = TIME_NOW;
$plugins->run_hooks("no_permission");





	$noperm_array = array (
"nopermission" => '1',
"location1" => 0,

	$noperm_array = array (
"nopermission" => '1',
"location1" => 0,

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

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





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

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

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

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

Zeile 988Zeile 1014
		{
header("Location: {$url}");
}

		{
header("Location: {$url}");
}

	}

	}


exit;
}


exit;
}

Zeile 1010Zeile 1036
	if($count <= $perpage)
{
return '';

	if($count <= $perpage)
{
return '';

	}




	}

$page = (int)$page;


	$url = str_replace("&amp;", "&", $url);
$url = htmlspecialchars_uni($url);


	$url = str_replace("&amp;", "&", $url);
$url = htmlspecialchars_uni($url);


Zeile 1033Zeile 1061

$from = $page-floor($mybb->settings['maxmultipagelinks']/2);
$to = $page+floor($mybb->settings['maxmultipagelinks']/2);


$from = $page-floor($mybb->settings['maxmultipagelinks']/2);
$to = $page+floor($mybb->settings['maxmultipagelinks']/2);





	if($from <= 0)
{
$from = 1;

	if($from <= 0)
{
$from = 1;

Zeile 1065Zeile 1093

$page_url = fetch_page_url($url, 1);
eval("\$start = \"".$templates->get("multipage_start")."\";");


$page_url = fetch_page_url($url, 1);
eval("\$start = \"".$templates->get("multipage_start")."\";");

	}


	}


	$mppage = '';
for($i = $from; $i <= $to; ++$i)
{

	$mppage = '';
for($i = $from; $i <= $to; ++$i)
{

Zeile 1098Zeile 1126

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

	}

	}


$nextpage = '';
if($page < $pages)


$nextpage = '';
if($page < $pages)

Zeile 1116Zeile 1144
		eval("\$jumptopage = \"".$templates->get("multipage_jump_page")."\";");
}


		eval("\$jumptopage = \"".$templates->get("multipage_jump_page")."\";");
}


	$lang->multipage_pages = $lang->sprintf($lang->multipage_pages, $pages);

	$multipage_pages = $lang->sprintf($lang->multipage_pages, $pages);


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


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

	}

	}

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

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





	return $multipage;
}

/**
* Generate a page URL for use by the multipage function

	return $multipage;
}

/**
* Generate a page URL for use by the multipage function

 *

 *

 * @param string $url The URL being passed
* @param int $page The page number
* @return string

 * @param string $url The URL being passed
* @param int $page The page number
* @return string

Zeile 1164Zeile 1192
		}

$url .= "page=$page";

		}

$url .= "page=$page";

	}

	}

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

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

Zeile 1176Zeile 1204
/**
* Fetch the permissions for a specific user
*

/**
* Fetch the permissions for a specific user
*

 * @param int $uid The user ID

 * @param int $uid The user ID, if no user ID is provided then current user's ID will be considered.

 * @return array Array of user permissions for the specified user
*/

 * @return array Array of user permissions for the specified user
*/

function user_permissions($uid=0)

function user_permissions($uid=null)

{
global $mybb, $cache, $groupscache, $user_cache;

// If no user id is specified, assume it is the current user

{
global $mybb, $cache, $groupscache, $user_cache;

// If no user id is specified, assume it is the current user

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

// Its a guest. Return the group permissions directly from cache

	if($uid == 0)
{

	if($uid == 0)
{

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

		return $groupscache[1];

	}

// User id does not match current user, fetch permissions
if($uid != $mybb->user['uid'])
{
// We've already cached permissions for this user, return them.

	}

// User id does not match current user, fetch permissions
if($uid != $mybb->user['uid'])
{
// We've already cached permissions for this user, return them.

		if($user_cache[$uid]['permissions'])

		if(!empty($user_cache[$uid]['permissions']))

		{
return $user_cache[$uid]['permissions'];
}

// This user was not already cached, fetch their user information.

		{
return $user_cache[$uid]['permissions'];
}

// This user was not already cached, fetch their user information.

		if(!$user_cache[$uid])

		if(empty($user_cache[$uid]))

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

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

Zeile 1788Zeile 1822
	$iconlist = '';
$no_icons_checked = " checked=\"checked\"";
// read post icons from cache, and sort them accordingly

	$iconlist = '';
$no_icons_checked = " checked=\"checked\"";
// read post icons from cache, and sort them accordingly

	$posticons_cache = $cache->read("posticons");

	$posticons_cache = (array)$cache->read("posticons");

	$posticons = array();
foreach($posticons_cache as $posticon)
{

	$posticons = array();
foreach($posticons_cache as $posticon)
{

Zeile 1834Zeile 1868
 * @param string $value The cookie value.
* @param int|string $expires The timestamp of the expiry date.
* @param boolean $httponly True if setting a HttpOnly cookie (supported by the majority of web browsers)

 * @param string $value The cookie value.
* @param int|string $expires The timestamp of the expiry date.
* @param boolean $httponly True if setting a HttpOnly cookie (supported by the majority of web browsers)

 
 * @param string $samesite The samesite attribute to prevent CSRF.

 */

 */

function my_setcookie($name, $value="", $expires="", $httponly=false)

function my_setcookie($name, $value="", $expires="", $httponly=false, $samesite="")

{
global $mybb;


{
global $mybb;


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

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

 
	}

if($samesite != "" && $mybb->settings['cookiesamesiteflag'])
{
$samesite = strtolower($samesite);

if($samesite == "lax" || $samesite == "strict")
{
$cookie .= "; SameSite=".$samesite;
}

	}

if($mybb->settings['cookiesecureflag'])

	}

if($mybb->settings['cookiesecureflag'])

Zeile 1997Zeile 2042
		return false;
}


		return false;
}


	$stack = array();
$expected = array();

	$stack = $list = $expected = array();



/*
* states:


/*
* states:

Zeile 2115Zeile 2159

$key = $value;
$state = 3;


$key = $value;
$state = 3;

					break;

					break;

				}

// illegal array index type

				}

// illegal array index type

Zeile 2134Zeile 2178
					$list = &$data;
$expected[] = $expectedLength;
$state = 2;

					$list = &$data;
$expected[] = $expectedLength;
$state = 2;

					break;

					break;

				}
if($type != '}')
{

				}
if($type != '}')
{

Zeile 2170Zeile 2214
	{
$mbIntEnc = mb_internal_encoding();
mb_internal_encoding('ASCII');

	{
$mbIntEnc = mb_internal_encoding();
mb_internal_encoding('ASCII');

	}

$out = _safe_unserialize($str);


	}

$out = _safe_unserialize($str);


	if(isset($mbIntEnc))
{
mb_internal_encoding($mbIntEnc);

	if(isset($mbIntEnc))
{
mb_internal_encoding($mbIntEnc);

Zeile 2193Zeile 2237
 * @throw Exception if $value is malformed or contains unsupported types (e.g., resources, objects)
*/
function _safe_serialize( $value )

 * @throw Exception if $value is malformed or contains unsupported types (e.g., resources, objects)
*/
function _safe_serialize( $value )

{

{

	if(is_null($value))
{
return 'N;';

	if(is_null($value))
{
return 'N;';

Zeile 2350Zeile 2394
 *
* @param array $changes Array of items being updated (numthreads,numposts,numusers,numunapprovedthreads,numunapprovedposts,numdeletedposts,numdeletedthreads)
* @param boolean $force Force stats update?

 *
* @param array $changes Array of items being updated (numthreads,numposts,numusers,numunapprovedthreads,numunapprovedposts,numdeletedposts,numdeletedthreads)
* @param boolean $force Force stats update?

 */

 */

function update_stats($changes=array(), $force=false)
{
global $cache, $db;

function update_stats($changes=array(), $force=false)
{
global $cache, $db;

Zeile 2388Zeile 2432
		$changes = $stats_changes;
}
else

		$changes = $stats_changes;
}
else

	{

	{

		$stats = $stats_changes;
}


		$stats = $stats_changes;
}


Zeile 2428Zeile 2472
				$new_stats[$counter] = $changes[$counter];
// Less than 0? That's bad
if($new_stats[$counter] < 0)

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

				{

				{

					$new_stats[$counter] = 0;
}
}

					$new_stats[$counter] = 0;
}
}

Zeile 2448Zeile 2492
		$lastmember = $db->fetch_array($query);
$new_stats['lastuid'] = $lastmember['uid'];
$new_stats['lastusername'] = $lastmember['username'] = htmlspecialchars_uni($lastmember['username']);

		$lastmember = $db->fetch_array($query);
$new_stats['lastuid'] = $lastmember['uid'];
$new_stats['lastusername'] = $lastmember['username'] = htmlspecialchars_uni($lastmember['username']);

	}

	}


if(!empty($new_stats))
{


if(!empty($new_stats))
{

Zeile 2507Zeile 2551
				if((int)$changes[$counter] != 0)
{
$update_query[$counter] = $forum[$counter] + $changes[$counter];

				if((int)$changes[$counter] != 0)
{
$update_query[$counter] = $forum[$counter] + $changes[$counter];

				}
}
else
{
$update_query[$counter] = $changes[$counter];
}

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

				}
}
else
{
$update_query[$counter] = $changes[$counter];
}

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

	}

// Only update if we're actually doing something

	}

// Only update if we're actually doing something

Zeile 2550Zeile 2594
		{
$new_stats['numunapprovedthreads'] = "+{$unapprovedthreads_diff}";
}

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

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

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

	}

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

	}

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

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

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

		}
}

		}
}


if(array_key_exists('unapprovedposts', $update_query))
{
$unapprovedposts_diff = $update_query['unapprovedposts'] - $forum['unapprovedposts'];
if($unapprovedposts_diff > -1)


if(array_key_exists('unapprovedposts', $update_query))
{
$unapprovedposts_diff = $update_query['unapprovedposts'] - $forum['unapprovedposts'];
if($unapprovedposts_diff > -1)

		{

		{

			$new_stats['numunapprovedposts'] = "+{$unapprovedposts_diff}";

			$new_stats['numunapprovedposts'] = "+{$unapprovedposts_diff}";

		}

		}

		else
{
$new_stats['numunapprovedposts'] = "{$unapprovedposts_diff}";

		else
{
$new_stats['numunapprovedposts'] = "{$unapprovedposts_diff}";

Zeile 2583Zeile 2627
	}

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

	}

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

	{

	{

		$deletedposts_diff = $update_query['deletedposts'] - $forum['deletedposts'];
if($deletedposts_diff > -1)
{

		$deletedposts_diff = $update_query['deletedposts'] - $forum['deletedposts'];
if($deletedposts_diff > -1)
{

Zeile 2599Zeile 2643
	{
$deletedthreads_diff = $update_query['deletedthreads'] - $forum['deletedthreads'];
if($deletedthreads_diff > -1)

	{
$deletedthreads_diff = $update_query['deletedthreads'] - $forum['deletedthreads'];
if($deletedthreads_diff > -1)

		{

		{

			$new_stats['numdeletedthreads'] = "+{$deletedthreads_diff}";
}
else

			$new_stats['numdeletedthreads'] = "+{$deletedthreads_diff}";
}
else

Zeile 2646Zeile 2690

/**
* Updates the thread counters with a specific value (or addition/subtraction of the previous value)


/**
* Updates the thread counters with a specific value (or addition/subtraction of the previous value)

 *

 *

 * @param int $tid The thread ID
* @param array $changes Array of items being updated (replies, unapprovedposts, deletedposts, attachmentcount) and their value (ex, 1, +1, -1)
*/

 * @param int $tid The thread ID
* @param array $changes Array of items being updated (replies, unapprovedposts, deletedposts, attachmentcount) and their value (ex, 1, +1, -1)
*/

Zeile 2656Zeile 2700

$update_query = array();
$tid = (int)$tid;


$update_query = array();
$tid = (int)$tid;





	$counters = array('replies', 'unapprovedposts', 'attachmentcount', 'deletedposts', 'attachmentcount');

// Fetch above counters for this thread
$query = $db->simple_select("threads", implode(",", $counters), "tid='{$tid}'");
$thread = $db->fetch_array($query);

	$counters = array('replies', 'unapprovedposts', 'attachmentcount', 'deletedposts', 'attachmentcount');

// Fetch above counters for this thread
$query = $db->simple_select("threads", implode(",", $counters), "tid='{$tid}'");
$thread = $db->fetch_array($query);





	foreach($counters as $counter)
{
if(array_key_exists($counter, $changes))
{
if(substr($changes[$counter], 0, 2) == "+-")

	foreach($counters as $counter)
{
if(array_key_exists($counter, $changes))
{
if(substr($changes[$counter], 0, 2) == "+-")

			{

			{

				$changes[$counter] = substr($changes[$counter], 1);
}
// Adding or subtracting from previous value?

				$changes[$counter] = substr($changes[$counter], 1);
}
// Adding or subtracting from previous value?

Zeile 2678Zeile 2722
				{
$update_query[$counter] = $thread[$counter] + $changes[$counter];
}

				{
$update_query[$counter] = $thread[$counter] + $changes[$counter];
}

			}

			}

			else
{
$update_query[$counter] = $changes[$counter];

			else
{
$update_query[$counter] = $changes[$counter];

Zeile 2710Zeile 2754
{
global $db;


{
global $db;


	$thread = get_thread($tid);


	$thread = get_thread($tid);


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

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

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

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

	);

	);

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

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





	$db->free_result($query);

$query = $db->query("

	$db->free_result($query);

$query = $db->query("

Zeile 2741Zeile 2785
	$firstpost = $db->fetch_array($query);

$db->free_result($query);

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

$db->free_result($query);





	if(empty($firstpost['username']))
{
$firstpost['username'] = $firstpost['postusername'];

	if(empty($firstpost['username']))
{
$firstpost['username'] = $firstpost['postusername'];

Zeile 2772Zeile 2816
		'lastposteruid' => (int)$lastpost['uid'],
);
$db->update_query("threads", $update_array, "tid='{$tid}'");

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

}

}


/**
* Updates the user counters with a specific value (or addition/subtraction of the previous value)


/**
* Updates the user counters with a specific value (or addition/subtraction of the previous value)

Zeile 2788Zeile 2832

$counters = array('postnum', 'threadnum');
$uid = (int)$uid;


$counters = array('postnum', 'threadnum');
$uid = (int)$uid;





	// Fetch above counters for this user
$query = $db->simple_select("users", implode(",", $counters), "uid='{$uid}'");
$user = $db->fetch_array($query);

	// Fetch above counters for this user
$query = $db->simple_select("users", implode(",", $counters), "uid='{$uid}'");
$user = $db->fetch_array($query);

Zeile 2819Zeile 2863
			{
$update_query[$counter] = 0;
}

			{
$update_query[$counter] = 0;
}

		}
}

		}
}


$db->free_result($query);



$db->free_result($query);


Zeile 2835Zeile 2879
 * Deletes a thread from the database
*
* @param int $tid The thread ID

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

 * @return bool

 * @return bool

 */
function delete_thread($tid)
{

 */
function delete_thread($tid)
{

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

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

			{

			{

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

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

	}

	}


if(!is_array($permissioncache))
{


if(!is_array($permissioncache))
{

Zeile 2914Zeile 2958
		foreach($jumpfcache[$pid] as $main)
{
foreach($main as $forum)

		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 || $showall == true))

				$perms = $permissioncache[$forum['fid']];

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

Zeile 2961Zeile 3005
		}

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

		}

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

	}


	}


	return $forumjump;

	return $forumjump;

}

/**

}

/**

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

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

Zeile 2975Zeile 3019
function get_extension($file)
{
return my_strtolower(my_substr(strrchr($file, "."), 1));

function get_extension($file)
{
return my_strtolower(my_substr(strrchr($file, "."), 1));

}

/**

}

/**

 * Generates a random string.
*
* @param int $length The length of the string to generate.

 * Generates a random string.
*
* @param int $length The length of the string to generate.

Zeile 3024Zeile 3068
 * @return string The formatted username
*/
function format_name($username, $usergroup, $displaygroup=0)

 * @return string The formatted username
*/
function format_name($username, $usergroup, $displaygroup=0)

{
global $groupscache, $cache;

if(!is_array($groupscache))



{
global $groupscache, $cache, $plugins;

static $formattednames = array();

if(!isset($formattednames[$username]))

	{

	{

		$groupscache = $cache->read("usergroups");
}

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





















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

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

$format = "{username}";

if(isset($groupscache[$usergroup]))
{
$ugroup = $groupscache[$usergroup];

if(strpos($ugroup['namestyle'], "{username}") !== false)
{
$format = $ugroup['namestyle'];
}
}

$format = stripslashes($format);

$parameters = compact('username', 'usergroup', 'displaygroup', 'format');

$parameters = $plugins->run_hooks('format_name', $parameters);





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

		$format = $parameters['format'];







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

		$formattednames[$username] = str_replace("{username}", $username, $format);



	}


	}


	$format = stripslashes($format);

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

	return $formattednames[$username];



}

/**

}

/**

Zeile 3113Zeile 3173

if($dimensions)
{


if($dimensions)
{

		$dimensions = explode("|", $dimensions);

		$dimensions = preg_split('/[|x]/', $dimensions);


if($dimensions[0] && $dimensions[1])
{


if($dimensions[0] && $dimensions[1])
{

			list($max_width, $max_height) = explode('x', $max_dimensions);

			list($max_width, $max_height) = preg_split('/[|x]/', $max_dimensions);


if(!empty($max_dimensions) && ($dimensions[0] > $max_width || $dimensions[1] > $max_height))
{


if(!empty($max_dimensions) && ($dimensions[0] > $max_width || $dimensions[1] > $max_height))
{

Zeile 3214Zeile 3274
			"editor_invalidyoutube" => "Invalid YouTube video",
"editor_dailymotion" => "Dailymotion",
"editor_metacafe" => "MetaCafe",

			"editor_invalidyoutube" => "Invalid YouTube video",
"editor_dailymotion" => "Dailymotion",
"editor_metacafe" => "MetaCafe",

			"editor_veoh" => "Veoh",

			"editor_mixer" => "Mixer",

			"editor_vimeo" => "Vimeo",
"editor_youtube" => "Youtube",
"editor_facebook" => "Facebook",

			"editor_vimeo" => "Vimeo",
"editor_youtube" => "Youtube",
"editor_facebook" => "Facebook",

Zeile 3384Zeile 3444
	}

return $codeinsert;

	}

return $codeinsert;

 
}

/**
* @param int $tid
* @param array $postoptions The options carried with form submit
*
* @return string Predefined / updated subscription method of the thread for the user
*/
function get_subscription_method($tid = 0, $postoptions = array())
{
global $mybb;

$subscription_methods = array('', 'none', 'email', 'pm'); // Define methods
$subscription_method = (int)$mybb->user['subscriptionmethod']; // Set user default

// If no user default method available then reset method
if(!$subscription_method)
{
$subscription_method = 0;
}

// Return user default if no thread id available, in case
if(!(int)$tid || (int)$tid <= 0)
{
return $subscription_methods[$subscription_method];
}

// If method not predefined set using data from database
if(isset($postoptions['subscriptionmethod']))
{
$method = trim($postoptions['subscriptionmethod']);
return (in_array($method, $subscription_methods)) ? $method : $subscription_methods[0];
}
else
{
global $db;

$query = $db->simple_select("threadsubscriptions", "tid, notification", "tid='".(int)$tid."' AND uid='".$mybb->user['uid']."'", array('limit' => 1));
$subscription = $db->fetch_array($query);

if($subscription['tid'])
{
$subscription_method = (int)$subscription['notification'] + 1;
}
}

return $subscription_methods[$subscription_method];

}

/**

}

/**

Zeile 3413Zeile 3520
			{
$smilie['image'] = str_replace("{theme}", $theme['imgdir'], $smilie['image']);
$smiliecache[$smilie['sid']] = $smilie;

			{
$smilie['image'] = str_replace("{theme}", $theme['imgdir'], $smilie['image']);
$smiliecache[$smilie['sid']] = $smilie;

			}
}

			}
}


unset($smilie);



unset($smilie);


Zeile 3424Zeile 3531

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


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

			{

			{

				$mybb->settings['smilieinsertertot'] = $smiliecount;
}
else if($mybb->settings['smilieinsertertot'] < $smiliecount)

				$mybb->settings['smilieinsertertot'] = $smiliecount;
}
else if($mybb->settings['smilieinsertertot'] < $smiliecount)

			{

			{

				$smiliecount = $mybb->settings['smilieinsertertot'];
eval("\$getmore = \"".$templates->get("smilieinsert_getmore")."\";");
}

				$smiliecount = $mybb->settings['smilieinsertertot'];
eval("\$getmore = \"".$templates->get("smilieinsert_getmore")."\";");
}

Zeile 3505Zeile 3612
		if($pid > 0 && is_array($prefixes_cache[$pid]))
{
return $prefixes_cache[$pid];

		if($pid > 0 && is_array($prefixes_cache[$pid]))
{
return $prefixes_cache[$pid];

		}

		}


return $prefixes_cache;
}


return $prefixes_cache;
}

Zeile 3536Zeile 3643
	else if(!empty($prefixes_cache))
{
return $prefixes_cache;

	else if(!empty($prefixes_cache))
{
return $prefixes_cache;

	}

return false;
}


	}

return false;
}


/**
* Build the thread prefix selection menu for the current user
*

/**
* Build the thread prefix selection menu for the current user
*

Zeile 3563Zeile 3670
	if(empty($prefix_cache))
{
// We've got no prefixes to show

	if(empty($prefix_cache))
{
// We've got no prefixes to show

		return '';

		return '';

	}

// Go through each of our prefixes and decide which ones we can use

	}

// Go through each of our prefixes and decide which ones we can use

Zeile 3574Zeile 3681
		{
// Decide whether this prefix can be used in our forum
$forums = explode(",", $prefix['forums']);

		{
// Decide whether this prefix can be used in our forum
$forums = explode(",", $prefix['forums']);





			if(!in_array($fid, $forums) && $prefix['pid'] != $previous_pid)
{
// This prefix is not in our forum list

			if(!in_array($fid, $forums) && $prefix['pid'] != $previous_pid)
{
// This prefix is not in our forum list

Zeile 3597Zeile 3704
	$prefixselect = $prefixselect_prefix = '';

if($multiple == 1)

	$prefixselect = $prefixselect_prefix = '';

if($multiple == 1)

	{

	{

		$any_selected = "";
if($selected_pid == 'any')
{

		$any_selected = "";
if($selected_pid == 'any')
{

Zeile 3630Zeile 3737
	else
{
eval("\$prefixselect = \"".$templates->get("post_prefixselect_single")."\";");

	else
{
eval("\$prefixselect = \"".$templates->get("post_prefixselect_single")."\";");

	}

	}


return $prefixselect;
}


return $prefixselect;
}

Zeile 3795Zeile 3902
	{
$pid = (int)$data['pid'];
unset($data['pid']);

	{
$pid = (int)$data['pid'];
unset($data['pid']);

 
	}

$tids = array();
if(isset($data['tids']))
{
$tids = (array)$data['tids'];
unset($data['tids']);

	}

// Any remaining extra data - we my_serialize and insert in to its own column

	}

// Any remaining extra data - we my_serialize and insert in to its own column

Zeile 3813Zeile 3927
		"data" => $db->escape_string($data),
"ipaddress" => $db->escape_binary($session->packedip)
);

		"data" => $db->escape_string($data),
"ipaddress" => $db->escape_binary($session->packedip)
);

	$db->insert_query("moderatorlog", $sql_array);


















if($tids)
{
$multiple_sql_array = array();

foreach($tids as $tid)
{
$sql_array['tid'] = (int)$tid;
$multiple_sql_array[] = $sql_array;
}

$db->insert_query_multiple("moderatorlog", $multiple_sql_array);
}
else
{
$db->insert_query("moderatorlog", $sql_array);
}

}

/**

}

/**

Zeile 3824Zeile 3954
 * @return string The formatted repuation
*/
function get_reputation($reputation, $uid=0)

 * @return string The formatted repuation
*/
function get_reputation($reputation, $uid=0)

{

{

	global $theme, $templates;

$display_reputation = $reputation_class = '';
if($reputation < 0)

	global $theme, $templates;

$display_reputation = $reputation_class = '';
if($reputation < 0)

	{

	{

		$reputation_class = "reputation_negative";
}
elseif($reputation > 0)
{
$reputation_class = "reputation_positive";

		$reputation_class = "reputation_negative";
}
elseif($reputation > 0)
{
$reputation_class = "reputation_positive";

	}

	}

	else

	else

	{

	{

		$reputation_class = "reputation_neutral";
}

		$reputation_class = "reputation_neutral";
}





	$reputation = my_number_format($reputation);

if($uid != 0)
{
eval("\$display_reputation = \"".$templates->get("postbit_reputation_formatted_link")."\";");

	$reputation = my_number_format($reputation);

if($uid != 0)
{
eval("\$display_reputation = \"".$templates->get("postbit_reputation_formatted_link")."\";");

	}

	}

	else
{
eval("\$display_reputation = \"".$templates->get("postbit_reputation_formatted")."\";");

	else
{
eval("\$display_reputation = \"".$templates->get("postbit_reputation_formatted")."\";");

Zeile 3867Zeile 3997

$warning_class = '';
if($level >= 80)


$warning_class = '';
if($level >= 80)

	{

	{

		$warning_class = "high_warning";
}
else if($level >= 50)

		$warning_class = "high_warning";
}
else if($level >= 50)

Zeile 3899Zeile 4029
	$ip = strtolower($_SERVER['REMOTE_ADDR']);

if($mybb->settings['ip_forwarded_check'])

	$ip = strtolower($_SERVER['REMOTE_ADDR']);

if($mybb->settings['ip_forwarded_check'])

	{

	{

		$addresses = array();

if(isset($_SERVER['HTTP_X_FORWARDED_FOR']))

		$addresses = array();

if(isset($_SERVER['HTTP_X_FORWARDED_FOR']))

Zeile 4167Zeile 4297
				if(isset($password_forums[$parent]) && $mybb->cookies['forumpass'][$parent] !== md5($mybb->user['uid'].$password_forums[$parent]))
{
$pwverified = 0;

				if(isset($password_forums[$parent]) && $mybb->cookies['forumpass'][$parent] !== md5($mybb->user['uid'].$password_forums[$parent]))
{
$pwverified = 0;

				}
}
}


				}
}
}


		if($perms['canview'] == 0 || $pwverified == 0 || ($only_readable_threads == true && $perms['canviewthreads'] == 0))
{
$unviewable[] = $forum['fid'];
}

		if($perms['canview'] == 0 || $pwverified == 0 || ($only_readable_threads == true && $perms['canviewthreads'] == 0))
{
$unviewable[] = $forum['fid'];
}

	}

$unviewableforums = implode(',', $unviewable);

	}

$unviewableforums = implode(',', $unviewable);


return $unviewableforums;
}


return $unviewableforums;
}

Zeile 4188Zeile 4318
 * @param string $format The date format to use
* @param int $year The year of the date
* @return string The correct date format

 * @param string $format The date format to use
* @param int $year 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 4221Zeile 4351
			if(isset($navbits[$key+1]))
{
if(isset($navbits[$key+2]))

			if(isset($navbits[$key+1]))
{
if(isset($navbits[$key+2]))

				{

				{

					$sep = $navsep;
}
else

					$sep = $navsep;
}
else

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

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

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

	}

	}


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

 

if($nav)
{


if($nav)
{

Zeile 4689Zeile 4817
	$stamp %= $msecs;
$seconds = $stamp;


	$stamp %= $msecs;
$seconds = $stamp;


	if($years == 1)


	// Prevent gross over accuracy ($options parameter will override these)
if($years > 0)

	{

	{

		$nicetime['years'] = "1".$lang_year;






		$options = array_merge(array(
'days' => false,
'hours' => false,
'minutes' => false,
'seconds' => false
), $options);

	}

	}

	else if($years > 1)

	elseif($months > 0)

	{

	{

		$nicetime['years'] = $years.$lang_years;





		$options = array_merge(array(
'hours' => false,
'minutes' => false,
'seconds' => false
), $options);

	}

	}


if($months == 1)
{
$nicetime['months'] = "1".$lang_month;
}
else if($months > 1)
{
$nicetime['months'] = $months.$lang_months;
}

if($weeks == 1)
{
$nicetime['weeks'] = "1".$lang_week;
}
else if($weeks > 1)
{
$nicetime['weeks'] = $weeks.$lang_weeks;
}

if($days == 1)
{
$nicetime['days'] = "1".$lang_day;
}
else if($days > 1)
{
$nicetime['days'] = $days.$lang_days;



































	elseif($weeks > 0)
{
$options = array_merge(array(
'minutes' => false,
'seconds' => false
), $options);
}
elseif($days > 0)
{
$options = array_merge(array(
'seconds' => false
), $options);
}

if(!isset($options['years']) || $options['years'] !== false)
{
if($years == 1)
{
$nicetime['years'] = "1".$lang_year;
}
else if($years > 1)
{
$nicetime['years'] = $years.$lang_years;
}
}

if(!isset($options['months']) || $options['months'] !== false)
{
if($months == 1)
{
$nicetime['months'] = "1".$lang_month;
}
else if($months > 1)
{
$nicetime['months'] = $months.$lang_months;
}
}

if(!isset($options['weeks']) || $options['weeks'] !== false)
{
if($weeks == 1)
{
$nicetime['weeks'] = "1".$lang_week;
}
else if($weeks > 1)
{
$nicetime['weeks'] = $weeks.$lang_weeks;
}
}

if(!isset($options['days']) || $options['days'] !== false)
{
if($days == 1)
{
$nicetime['days'] = "1".$lang_day;
}
else if($days > 1)
{
$nicetime['days'] = $days.$lang_days;
}

	}

if(!isset($options['hours']) || $options['hours'] !== false)
{
if($hours == 1)

	}

if(!isset($options['hours']) || $options['hours'] !== false)
{
if($hours == 1)

		{

		{

			$nicetime['hours'] = "1".$lang_hour;
}
else if($hours > 1)
{
$nicetime['hours'] = $hours.$lang_hours;

			$nicetime['hours'] = "1".$lang_hour;
}
else if($hours > 1)
{
$nicetime['hours'] = $hours.$lang_hours;

		}
}


		}
}


	if(!isset($options['minutes']) || $options['minutes'] !== false)
{
if($minutes == 1)

	if(!isset($options['minutes']) || $options['minutes'] !== false)
{
if($minutes == 1)

Zeile 4790Zeile 4962

return $trow;
}


return $trow;
}





/**
* Add a user to a specific additional user group.
*

/**
* Add a user to a specific additional user group.
*

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

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





	if(is_array($groups))
{
$comma = '';
foreach($groups as $gid)
{
if(trim($gid) != "" && $gid != $user['usergroup'] && !isset($donegroup[$gid]))

	if(is_array($groups))
{
$comma = '';
foreach($groups as $gid)
{
if(trim($gid) != "" && $gid != $user['usergroup'] && !isset($donegroup[$gid]))

			{
$groupslist .= $comma.$gid;
$comma = ",";
$donegroup[$gid] = 1;
}
}
}

			{
$groupslist .= $comma.$gid;
$comma = ",";
$donegroup[$gid] = 1;
}
}
}


// What's the point in updating if they're the same?
if($groupslist != $user['additionalgroups'])


// What's the point in updating if they're the same?
if($groupslist != $user['additionalgroups'])

	{

	{

		$db->update_query("users", array('additionalgroups' => $groupslist), "uid='".(int)$uid."'");
return true;
}
else
{
return false;

		$db->update_query("users", array('additionalgroups' => $groupslist), "uid='".(int)$uid."'");
return true;
}
else
{
return false;

	}
}


	}
}


/**
* Remove a user from a specific additional user group
*

/**
* Remove a user from a specific additional user group
*

Zeile 4910Zeile 5082
		$location = htmlspecialchars_uni($_SERVER['SCRIPT_NAME']);
}
elseif(!empty($_SERVER['PHP_SELF']))

		$location = htmlspecialchars_uni($_SERVER['SCRIPT_NAME']);
}
elseif(!empty($_SERVER['PHP_SELF']))

	{

	{

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

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

	}

	}

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

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

	{

	{

		$location = htmlspecialchars_uni($_ENV['PHP_SELF']);
}
elseif(!empty($_SERVER['PATH_INFO']))
{
$location = htmlspecialchars_uni($_SERVER['PATH_INFO']);

		$location = htmlspecialchars_uni($_ENV['PHP_SELF']);
}
elseif(!empty($_SERVER['PATH_INFO']))
{
$location = htmlspecialchars_uni($_SERVER['PATH_INFO']);

	}

	}

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

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

	}


	}


	if($quick)

	if($quick)

	{

	{

		return $location;
}

		return $location;
}





	if($fields == true)
{
global $mybb;

if(!is_array($ignore))

	if($fields == true)
{
global $mybb;

if(!is_array($ignore))

		{

		{

			$ignore = array($ignore);
}


			$ignore = array($ignore);
}


Zeile 4948Zeile 5120
				if(in_array($name, $ignore) || is_array($name) || is_array($value))
{
continue;

				if(in_array($name, $ignore) || is_array($name) || is_array($value))
{
continue;

				}

				}


$form_html .= "<input type=\"hidden\" name=\"".htmlspecialchars_uni($name)."\" value=\"".htmlspecialchars_uni($value)."\" />\n";
}


$form_html .= "<input type=\"hidden\" name=\"".htmlspecialchars_uni($name)."\" value=\"".htmlspecialchars_uni($value)."\" />\n";
}

Zeile 4972Zeile 5144
			$post_array = array('action', 'fid', 'pid', 'tid', 'uid', 'eid');

foreach($post_array as $var)

			$post_array = array('action', 'fid', 'pid', 'tid', 'uid', 'eid');

foreach($post_array as $var)

			{

			{

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

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

Zeile 5022Zeile 5194
		if(!isset($lang->use_default))
{
$lang->use_default = $lang->lang_select_default;

		if(!isset($lang->use_default))
{
$lang->use_default = $lang->lang_select_default;

		}
}

if(!is_array($tcache))
{
$query = $db->simple_select('themes', 'tid, name, pid, allowedgroups', "pid!='0'");

while($theme = $db->fetch_array($query))
{
$tcache[$theme['pid']][$theme['tid']] = $theme;
}
}


		}
}

if(!is_array($tcache))
{
$query = $db->simple_select('themes', 'tid, name, pid, allowedgroups', "pid!='0'");

while($theme = $db->fetch_array($query))
{
$tcache[$theme['pid']][$theme['tid']] = $theme;
}
}


	if(is_array($tcache[$tid]))
{
foreach($tcache[$tid] as $theme)

	if(is_array($tcache[$tid]))
{
foreach($tcache[$tid] as $theme)

Zeile 5060Zeile 5232
				{
build_theme_select($name, $selected, $theme['tid'], $depthit, $usergroup_override, $footer, $count_override);
}

				{
build_theme_select($name, $selected, $theme['tid'], $depthit, $usergroup_override, $footer, $count_override);
}

			}
}

			}
}

	}

if($tid == 1 && ($num_themes > 1 || $count_override == true))

	}

if($tid == 1 && ($num_themes > 1 || $count_override == true))

Zeile 5088Zeile 5260
 *
* @param int $tid The theme id of the theme.
* @return boolean|array False if no valid theme, Array with the theme data otherwise

 *
* @param int $tid The theme id of the theme.
* @return boolean|array False if no valid theme, Array with the theme data otherwise

 */

 */

function get_theme($tid)
{
global $tcache, $db;

function get_theme($tid)
{
global $tcache, $db;





	if(!is_array($tcache))
{
$query = $db->simple_select('themes', 'tid, name, pid, allowedgroups', "pid!='0'");

	if(!is_array($tcache))
{
$query = $db->simple_select('themes', 'tid, name, pid, allowedgroups', "pid!='0'");





		while($theme = $db->fetch_array($query))
{
$tcache[$theme['pid']][$theme['tid']] = $theme;

		while($theme = $db->fetch_array($query))
{
$tcache[$theme['pid']][$theme['tid']] = $theme;

		}
}


		}
}


	$s_theme = false;

foreach($tcache as $themes)

	$s_theme = false;

foreach($tcache as $themes)

Zeile 5142Zeile 5314
 * @return int The formatted number.
*/
function my_number_format($number)

 * @return int The formatted number.
*/
function my_number_format($number)

{

{

	global $mybb;

if($number == "-")

	global $mybb;

if($number == "-")

Zeile 5357Zeile 5529
		$lang->month_10,
$lang->month_11,
$lang->month_12

		$lang->month_10,
$lang->month_11,
$lang->month_12

	);



	);



	// This needs to be in this specific order
$find = array(
'm',

	// This needs to be in this specific order
$find = array(
'm',

Zeile 5576Zeile 5747
	if($handle_entities)
{
$string = unhtmlentities($string);

	if($handle_entities)
{
$string = unhtmlentities($string);

	}

	}

	if(function_exists("mb_substr"))
{
if($length != null)

	if(function_exists("mb_substr"))
{
if($length != null)

Zeile 5683Zeile 5854
function unhtmlentities($string)
{
// Replace numeric entities

function unhtmlentities($string)
{
// Replace numeric entities

	$string = preg_replace_callback('~&#x([0-9a-f]+);~i', create_function('$matches', 'return unichr(hexdec($matches[1]));'), $string);
$string = preg_replace_callback('~&#([0-9]+);~', create_function('$matches', 'return unichr($matches[1]);'), $string);

	$string = preg_replace_callback('~&#x([0-9a-f]+);~i', 'unichr_callback1', $string);
$string = preg_replace_callback('~&#([0-9]+);~', 'unichr_callback2', $string);


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


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

Zeile 5724Zeile 5895
	{
return false;
}

	{
return false;
}

 
}

/**
* Returns any ascii to it's character (utf-8 safe).
*
* @param array $matches Matches.
* @return string|bool The characterized ascii. False on failure
*/
function unichr_callback1($matches)
{
return unichr(hexdec($matches[1]));
}

/**
* Returns any ascii to it's character (utf-8 safe).
*
* @param array $matches Matches.
* @return string|bool The characterized ascii. False on failure
*/
function unichr_callback2($matches)
{
return unichr($matches[1]);

}

/**

}

/**

Zeile 5797Zeile 5990
	if(!$username && $uid == 0)
{
// Return Guest phrase for no UID, no guest nickname

	if(!$username && $uid == 0)
{
// Return Guest phrase for no UID, no guest nickname

		return $lang->guest;

		return htmlspecialchars_uni($lang->guest);

	}
elseif($uid == 0)
{

	}
elseif($uid == 0)
{

Zeile 6082Zeile 6275
	}

if(empty($forum_cache[$fid]))

	}

if(empty($forum_cache[$fid]))

	{
return false;
}


	{
return false;
}


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

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

Zeile 6096Zeile 6289
				if($forum_cache[$parent]['active'] == 0)
{
return false;

				if($forum_cache[$parent]['active'] == 0)
{
return false;

				}
}
}
}


				}
}
}
}


	return $forum_cache[$fid];
}


	return $forum_cache[$fid];
}


Zeile 6131Zeile 6324
		{
$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 6147Zeile 6340
 * @return array|bool The database row of the post. False on failure
*/
function get_post($pid)

 * @return array|bool The database row of the post. False on failure
*/
function get_post($pid)

{

{

	global $db;
static $post_cache;


	global $db;
static $post_cache;


Zeile 6163Zeile 6356
		$post = $db->fetch_array($query);

if($post)

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

if($post)

		{

		{

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

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

Zeile 6209Zeile 6402
	$inactiveforums = implode(",", $inactive);

return $inactiveforums;

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

return $inactiveforums;

}


}


/**
* Checks to make sure a user has not tried to login more times than permitted
*
* @param bool $fatal (Optional) Stop execution if it finds an error with the login. Default is True
* @return bool|int Number of logins when success, false if failed.

/**
* Checks to make sure a user has not tried to login more times than permitted
*
* @param bool $fatal (Optional) Stop execution if it finds an error with the login. Default is True
* @return bool|int Number of logins when success, false if failed.

 */
function login_attempt_check($fatal = true)
{
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.

// Use cookie if possible, otherwise use session
// Find better solution to prevent clearing cookies
$loginattempts = 0;
$failedlogin = 0;

if(!empty($mybb->cookies['loginattempts']))
{
$loginattempts = $mybb->cookies['loginattempts'];
}

if(!empty($mybb->cookies['failedlogin']))
{
$failedlogin = $mybb->cookies['failedlogin'];

 */
function login_attempt_check($uid = 0, $fatal = true)
{
global $mybb, $lang, $db;

$attempts = array();
$uid = (int)$uid;
$now = TIME_NOW;

// Get this user's login attempts and eventual lockout, if a uid is provided
if($uid > 0)
{
$query = $db->simple_select("users", "loginattempts, loginlockoutexpiry", "uid='{$uid}'", 1);
$attempts = $db->fetch_array($query);

if($attempts['loginattempts'] <= 0)
{
return 0;
}






	}

	}


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

	// This user has a cookie lockout, show waiting time
elseif($mybb->cookies['lockoutexpiry'] && $mybb->cookies['lockoutexpiry'] > $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;




		if($fatal)
{
$secsleft = (int)($mybb->cookies['lockoutexpiry'] - $now);
$hoursleft = floor($secsleft / 3600);
$minsleft = floor(($secsleft / 60) % 60);
$secsleft = floor($secsleft % 60);





		if(empty($mybb->cookies['failedlogin']))
{
$failedtime = $now;
}
else
{
$failedtime = $mybb->cookies['failedlogin'];
}

$secondsleft = $mybb->settings['failedlogintime'] * 60 + $failedtime - $now;
$hoursleft = floor($secondsleft / 3600);
$minsleft = floor(($secondsleft / 60) % 60);
$secsleft = floor($secondsleft % 60);

// This value will be empty the first time the user doesn't login in, set it
if(empty($failedlogin))
{
my_setcookie('failedlogin', $now);
if($fatal)
{
error($lang->sprintf($lang->failed_login_wait, $hoursleft, $minsleft, $secsleft));
}

return false;

			error($lang->sprintf($lang->failed_login_wait, $hoursleft, $minsleft, $secsleft));
























		}


		}


		// Work out if the user has waited long enough before letting them login again
if($mybb->cookies['failedlogin'] < ($now - $mybb->settings['failedlogintime'] * 60))






		return false;
}

if($mybb->settings['failedlogincount'] > 0 && $attempts['loginattempts'] >= $mybb->settings['failedlogincount'])
{
// Set the expiry dateline if not set yet
if($attempts['loginlockoutexpiry'] == 0)

		{

		{

			my_setcookie('loginattempts', 1);
my_unsetcookie('failedlogin');
if($mybb->user['uid'] != 0)
{
$update_array = array(
'loginattempts' => 1
);
$db->update_query("users", $update_array, "uid = '{$mybb->user['uid']}'");
}
return 1;









			$attempts['loginlockoutexpiry'] = $now + ((int)$mybb->settings['failedlogintime'] * 60);

// Add a cookie lockout. This is used to prevent access to the login page immediately.
// A deep lockout is issued if he tries to login into a locked out account
my_setcookie('lockoutexpiry', $attempts['loginlockoutexpiry']);

$db->update_query("users", array(
"loginlockoutexpiry" => $attempts['loginlockoutexpiry']
), "uid='{$uid}'");
}

if(empty($mybb->cookies['lockoutexpiry']))
{
$failedtime = $attempts['loginlockoutexpiry'];
}
else
{
$failedtime = $mybb->cookies['lockoutexpiry'];

		}

		}

		// Not waited long enough
else if($mybb->cookies['failedlogin'] > ($now - $mybb->settings['failedlogintime'] * 60))



// Are we still locked out?
if($attempts['loginlockoutexpiry'] > $now)

		{
if($fatal)
{

		{
if($fatal)
{

 
				$secsleft = (int)($attempts['loginlockoutexpiry'] - $now);
$hoursleft = floor($secsleft / 3600);
$minsleft = floor(($secsleft / 60) % 60);
$secsleft = floor($secsleft % 60);


				error($lang->sprintf($lang->failed_login_wait, $hoursleft, $minsleft, $secsleft));
}

return false;

				error($lang->sprintf($lang->failed_login_wait, $hoursleft, $minsleft, $secsleft));
}

return false;

 
		}
// Unlock if enough time has passed
else {

if($uid > 0)
{
$db->update_query("users", array(
"loginattempts" => 0,
"loginlockoutexpiry" => 0
), "uid='{$uid}'");
}

// Wipe the cookie, no matter if a guest or a member
my_unsetcookie('lockoutexpiry');

return 0;

		}
}

		}
}





	// User can attempt another login

	// User can attempt another login

	return $loginattempts;

	return $attempts['loginattempts'];

}

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

}

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

 *

 *

 * @param string $email The string to check.
* @return boolean True when valid, false when invalid.
*/
function validate_email_format($email)
{

 * @param string $email The string to check.
* @return boolean True when valid, false when invalid.
*/
function validate_email_format($email)
{

	if(strpos($email, ' ') !== false)
{
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-]+\.)*[a-zA-Z0-9-]{2,}$/si", $email);

	return filter_var($email, FILTER_VALIDATE_EMAIL) !== false;






}

/**

}

/**

Zeile 6355Zeile 6552
{
global $db, $mybb;


{
global $db, $mybb;


	if(!file_exists(MYBB_ROOT."inc/settings.php"))
{
$mode = "x";
}
else
{
$mode = "w";
}

$options = array(
"order_by" => "title",
"order_dir" => "ASC"
);
$query = $db->simple_select("settings", "value, name", "", $options);

	$query = $db->simple_select("settings", "value, name", "", array(
'order_by' => 'title',
'order_dir' => 'ASC',
));















	$settings = null;

	$settings = '';

	while($setting = $db->fetch_array($query))
{
$mybb->settings[$setting['name']] = $setting['value'];

	while($setting = $db->fetch_array($query))
{
$mybb->settings[$setting['name']] = $setting['value'];

 

$setting['name'] = addcslashes($setting['name'], "\\'");

		$setting['value'] = addcslashes($setting['value'], '\\"$');
$settings .= "\$settings['{$setting['name']}'] = \"{$setting['value']}\";\n";
}

$settings = "<"."?php\n/*********************************\ \n DO NOT EDIT THIS FILE, PLEASE USE\n THE SETTINGS EDITOR\n\*********************************/\n\n$settings\n";

		$setting['value'] = addcslashes($setting['value'], '\\"$');
$settings .= "\$settings['{$setting['name']}'] = \"{$setting['value']}\";\n";
}

$settings = "<"."?php\n/*********************************\ \n DO NOT EDIT THIS FILE, PLEASE USE\n THE SETTINGS EDITOR\n\*********************************/\n\n$settings\n";

	$file = @fopen(MYBB_ROOT."inc/settings.php", $mode);
@fwrite($file, $settings);
@fclose($file);


file_put_contents(MYBB_ROOT.'inc/settings.php', $settings, LOCK_EX);



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


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

Zeile 6391Zeile 6579
 *
* @param string $terms Incoming terms to highlight
* @return array PREG compatible array of terms

 *
* @param string $terms Incoming terms to highlight
* @return array PREG compatible array of terms

 */

 */

function build_highlight_array($terms)
{
global $mybb;

function build_highlight_array($terms)
{
global $mybb;

Zeile 6423Zeile 6611
		$terms = explode("\"", $terms);
$words = array();
foreach($terms as $phrase)

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

		{

		{

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

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

Zeile 6470Zeile 6658
	}

if(!is_array($words))

	}

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

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

	usort($words, 'build_highlight_array_sort');


// 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 6498Zeile 6686
	}

return $highlight_cache;

	}

return $highlight_cache;

 
}

/**
* Sort the word array by length. Largest terms go first and work their way down to the smallest term.
*
* @param string $a First word.
* @param string $b Second word.
* @return integer Result of comparison function.
*/
function build_highlight_array_sort($a, $b)
{
return strlen($b) - strlen($a);

}

/**

}

/**

Zeile 6518Zeile 6718
	elseif($src <= 0x007f)
{
$dest .= chr($src);

	elseif($src <= 0x007f)
{
$dest .= chr($src);

	}

	}

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

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

Zeile 6548Zeile 6748

/**
* Checks if a username has been disallowed for registration/use.


/**
* Checks if a username has been disallowed for registration/use.

 *

 *

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

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

Zeile 6579Zeile 6779
 * Check if a specific email address has been banned.
*
* @param string $email The email address.

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

 * @param boolean $update_lastuse True if the 'last used' dateline should be updated if a match is found.

 * @param boolean $update_lastuse True if the 'last used' dateline should be updated if a match is found.

 * @return boolean True if banned, false if not banned
*/
function is_banned_email($email, $update_lastuse=false)
{
global $cache, $db;


 * @return boolean True if banned, false if not banned
*/
function is_banned_email($email, $update_lastuse=false)
{
global $cache, $db;


	$banned_cache = $cache->read("bannedemails");


	$banned_cache = $cache->read("bannedemails");


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

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

	}


	}


	if(is_array($banned_cache) && !empty($banned_cache))
{
foreach($banned_cache as $banned_email)

	if(is_array($banned_cache) && !empty($banned_cache))
{
foreach($banned_cache as $banned_email)

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

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

		}

$banned = false;


		}

$banned = false;


		$ip_range = fetch_ip_range($banned_ip['filter']);
if(is_array($ip_range))
{

		$ip_range = fetch_ip_range($banned_ip['filter']);
if(is_array($ip_range))
{

Zeile 6914Zeile 7114

if(in_array(curl_getinfo($ch, CURLINFO_HTTP_CODE), array(301, 302)))
{


if(in_array(curl_getinfo($ch, CURLINFO_HTTP_CODE), array(301, 302)))
{

				preg_match('/Location:(.*?)(?:\n|$)/', $header, $matches);

				preg_match('/^Location:(.*?)(?:\n|$)/im', $header, $matches);


if($matches)
{


if($matches)
{

Zeile 7039Zeile 7239

if($max_redirects > 0 && (strstr($status_line, ' 301 ') || strstr($status_line, ' 302 ')))
{


if($max_redirects > 0 && (strstr($status_line, ' 301 ') || strstr($status_line, ' 302 ')))
{

			preg_match('/Location:(.*?)(?:\n|$)/', $header, $matches);

			preg_match('/^Location:(.*?)(?:\n|$)/im', $header, $matches);


if($matches)
{


if($matches)
{

Zeile 7446Zeile 7646
 * @param array $array The array of forums
* @return integer The number of sub forums
*/

 * @param array $array The array of forums
* @return integer The number of sub forums
*/

function subforums_count($array)

function subforums_count($array=array())

{
$count = 0;
foreach($array as $array2)

{
$count = 0;
foreach($array as $array2)

Zeile 7727Zeile 7927
	static $time_start;

$time = microtime(true);

	static $time_start;

$time = microtime(true);



 

// Just starting timer, init and return
if(!$time_start)


// Just starting timer, init and return
if(!$time_start)

Zeile 7798Zeile 7997
				{
$filename = $path."/".$file;
$handle = fopen($filename, "rb");

				{
$filename = $path."/".$file;
$handle = fopen($filename, "rb");

					$contents = '';

					$hashingContext = hash_init('sha512');

					while(!feof($handle))
{

					while(!feof($handle))
{

						$contents .= fread($handle, 8192);

						hash_update($hashingContext, fread($handle, 8192));

					}
fclose($handle);


					}
fclose($handle);


					$md5 = md5($contents);

					$checksum = hash_final($hashingContext);


// Does it match any of our hashes (unix/windows new lines taken into consideration with the hashes)


// Does it match any of our hashes (unix/windows new lines taken into consideration with the hashes)

					if(!in_array($md5, $checksums[$file_path]))

					if(!in_array($checksum, $checksums[$file_path]))

					{
$bad_verify_files[] = array("status" => "changed", "path" => $file_path);
}

					{
$bad_verify_files[] = array("status" => "changed", "path" => $file_path);
}

Zeile 8200Zeile 8399
	if($gd_version)
{
return $gd_version;

	if($gd_version)
{
return $gd_version;

	}

	}

	if(!extension_loaded('gd'))
{
return;

	if(!extension_loaded('gd'))
{
return;

Zeile 8245Zeile 8444
		{
$c = ord($input[$i]);
if($c > 128)

		{
$c = ord($input[$i]);
if($c > 128)

			{

			{

				if($c > 247 || $c <= 191)
{
if($return)

				if($c > 247 || $c <= 191)
{
if($return)

					{

					{

						$string .= '?';
continue;

						$string .= '?';
continue;

					}

					}

					else
{
return false;
}
}
elseif($c > 239)

					else
{
return false;
}
}
elseif($c > 239)

				{

				{

					$bytes = 4;
}
elseif($c > 223)

					$bytes = 4;
}
elseif($c > 223)

Zeile 8289Zeile 8488
					$i++;
$b = ord($input[$i]);
if($b < 128 || $b > 191)

					$i++;
$b = ord($input[$i]);
if($b < 128 || $b > 191)

					{

					{

						if($return)
{
$valid = false;

						if($return)
{
$valid = false;

Zeile 8318Zeile 8517
			}
}
$input = $string;

			}
}
$input = $string;

	}

	}

	if($return)

	if($return)

	{
if($allow_mb4)
{

	{
if($allow_mb4)
{

			return $input;

			return $input;

		}

		}

		else
{
return preg_replace("#[^\\x00-\\x7F][\\x80-\\xBF]{3,}#", '?', $input);

		else
{
return preg_replace("#[^\\x00-\\x7F][\\x80-\\xBF]{3,}#", '?', $input);

Zeile 8333Zeile 8532
	else
{
if($allow_mb4)

	else
{
if($allow_mb4)

		{

		{

			return true;
}
else

			return true;
}
else

Zeile 8361Zeile 8560
	}

if(!is_array($pm))

	}

if(!is_array($pm))

	{
return false;

	{
return false;

	}

	}





	if(isset($pm['language']))
{
if($pm['language'] != $mybb->user['language'] && $lang->language_exists($pm['language']))

	if(isset($pm['language']))
{
if($pm['language'] != $mybb->user['language'] && $lang->language_exists($pm['language']))

Zeile 8372Zeile 8571
			// Load user language
$lang->set_language($pm['language']);
$lang->load($pm['language_file']);

			// Load user language
$lang->set_language($pm['language']);
$lang->load($pm['language_file']);





			$revert = true;
}

foreach(array('subject', 'message') as $key)

			$revert = true;
}

foreach(array('subject', 'message') as $key)

		{

		{

			if(is_array($pm[$key]))

			if(is_array($pm[$key]))

			{

			{

				$lang_string = $lang->{$pm[$key][0]};
$num_args = count($pm[$key]);


				$lang_string = $lang->{$pm[$key][0]};
$num_args = count($pm[$key]);


Zeile 8387Zeile 8586
				{
$lang_string = str_replace('{'.$i.'}', $pm[$key][$i], $lang_string);
}

				{
$lang_string = str_replace('{'.$i.'}', $pm[$key][$i], $lang_string);
}

			}

			}

			else
{
$lang_string = $lang->{$pm[$key]};
}

			else
{
$lang_string = $lang->{$pm[$key]};
}





			$pm[$key] = $lang_string;
}


			$pm[$key] = $lang_string;
}


Zeile 8421Zeile 8620
	if(is_array($toid))
{
$recipients_to = $toid;

	if(is_array($toid))
{
$recipients_to = $toid;

	}

	}

	else

	else

	{

	{

		$recipients_to = array($toid);

		$recipients_to = array($toid);

	}

	}


$recipients_bcc = array();



$recipients_bcc = array();


Zeile 8435Zeile 8634
		$fromid = (int)$mybb->user['uid'];
}
elseif((int)$fromid < 0)

		$fromid = (int)$mybb->user['uid'];
}
elseif((int)$fromid < 0)

	{

	{

		$fromid = 0;
}


		$fromid = 0;
}


Zeile 8457Zeile 8656
	}

$pm['options'] = array(

	}

$pm['options'] = array(

		"signature" => 0,

 
		"disablesmilies" => 0,
"savecopy" => 0,
"readreceipt" => 0

		"disablesmilies" => 0,
"savecopy" => 0,
"readreceipt" => 0

Zeile 8618Zeile 8816

/**
* Strip html tags from string, also removes <script> and <style> contents.


/**
* Strip html tags from string, also removes <script> and <style> contents.

 * 


 *
* @deprecated

 * @param  string $string         String to stripe
* @param string $allowable_tags Allowed html tags

 * @param  string $string         String to stripe
* @param string $allowable_tags Allowed html tags

 * 

 *

 * @return string                 Striped string
*/
function my_strip_tags($string, $allowable_tags = '')

 * @return string                 Striped string
*/
function my_strip_tags($string, $allowable_tags = '')

Zeile 8639Zeile 8838
/**
* Escapes a RFC 4180-compliant CSV string.
* Based on https://github.com/Automattic/camptix/blob/f80725094440bf09861383b8f11e96c177c45789/camptix.php#L2867

/**
* Escapes a RFC 4180-compliant CSV string.
* Based on https://github.com/Automattic/camptix/blob/f80725094440bf09861383b8f11e96c177c45789/camptix.php#L2867

 *

 *

 * @param string $string The string to be escaped
* @param boolean $escape_active_content Whether or not to escape active content trigger characters
* @return string The escaped string

 * @param string $string The string to be escaped
* @param boolean $escape_active_content Whether or not to escape active content trigger characters
* @return string The escaped string

Zeile 8659Zeile 8858
		)
{
$string = "'".$string;

		)
{
$string = "'".$string;

		}


		}


		foreach($delimiters as $delimiter)

		foreach($delimiters as $delimiter)

		{

		{

			foreach($active_content_triggers as $trigger)

			foreach($active_content_triggers as $trigger)

			{

			{

				$string = str_replace($delimiter.$trigger, $delimiter."'".$trigger, $string);
}
}
}


				$string = str_replace($delimiter.$trigger, $delimiter."'".$trigger, $string);
}
}
}


	$string = str_replace('"', '""', $string);

return $string;











































































































	$string = str_replace('"', '""', $string);

return $string;
}

// Fallback function for 'array_column', PHP < 5.5.0 compatibility
if(!function_exists('array_column'))
{
function array_column($input, $column_key)
{
$values = array();
if(!is_array($input))
{
$input = array($input);
}
foreach($input as $val)
{
if(is_array($val) && isset($val[$column_key]))
{
$values[] = $val[$column_key];
}
elseif(is_object($val) && isset($val->$column_key))
{
$values[] = $val->$column_key;
}
}
return $values;
}
}

/**
* Performs a timing attack safe string comparison.
*
* @param string $known_string The first string to be compared.
* @param string $user_string The second, user-supplied string to be compared.
* @return bool Result of the comparison.
*/
function my_hash_equals($known_string, $user_string)
{
if(version_compare(PHP_VERSION, '5.6.0', '>='))
{
return hash_equals($known_string, $user_string);
}
else
{
$known_string_length = my_strlen($known_string);
$user_string_length = my_strlen($user_string);

if($user_string_length != $known_string_length)
{
return false;
}

$result = 0;

for($i = 0; $i < $known_string_length; $i++)
{
$result |= ord($known_string[$i]) ^ ord($user_string[$i]);
}

return $result === 0;
}
}

/**
* Retrieves all referrals for a specified user
*
* @param int uid
* @param int start position
* @param int total entries
* @param bool false (default) only return display info, true for all info
* @return array
*/
function get_user_referrals($uid, $start=0, $limit=0, $full=false)
{
global $db;

$referrals = $query_options = array();
$uid = (int) $uid;

if($uid === 0)
{
return $referrals;
}

if($start && $limit)
{
$query_options['limit_start'] = $start;
}

if($limit)
{
$query_options['limit'] = $limit;
}

$fields = 'uid, username, usergroup, displaygroup, regdate';
if($full === true)
{
$fields = '*';
}

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

while($referral = $db->fetch_array($query))
{
$referrals[] = $referral;
}

return $referrals;

}

}