Vergleich inc/functions.php - 1.8.9 - 1.8.17

  Keine Änderungen   Hinzugefügt   Modifiziert   Entfernt
Zeile 322Zeile 322
/**
* 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 343Zeile 343
	{
if(isset($mybb->user['uid']) && $mybb->user['uid'] != 0 && array_key_exists("timezone", $mybb->user))
{

	{
if(isset($mybb->user['uid']) && $mybb->user['uid'] != 0 && array_key_exists("timezone", $mybb->user))
{

			$offset = $mybb->user['timezone'];

			$offset = (float)$mybb->user['timezone'];

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

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

			$offset =  $mybbadmin['timezone'];

			$offset = (float)$mybbadmin['timezone'];

			$dstcorrection = $mybbadmin['dst'];
}
else
{

			$dstcorrection = $mybbadmin['dst'];
}
else
{

			$offset = $mybb->settings['timezoneoffset'];

			$offset = (float)$mybb->settings['timezoneoffset'];

			$dstcorrection = $mybb->settings['dstcorrection'];
}


			$dstcorrection = $mybb->settings['dstcorrection'];
}


Zeile 380Zeile 380
	}

$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 400Zeile 400
	if($format == 'relative')
{
// Relative formats both date and time

	if($format == 'relative')
{
// Relative formats both date and time

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


		if($ty != 2 && abs(TIME_NOW - $stamp) < 3600)
{
$diff = TIME_NOW - $stamp;
$relative = array('prefix' => '', 'minute' => 0, 'plural' => $lang->rel_minutes_plural, 'suffix' => $lang->rel_ago);

		if($ty != 2 && abs(TIME_NOW - $stamp) < 3600)
{
$diff = TIME_NOW - $stamp;
$relative = array('prefix' => '', 'minute' => 0, 'plural' => $lang->rel_minutes_plural, 'suffix' => $lang->rel_ago);


if($diff < 0)
{
$diff = abs($diff);
$relative['suffix'] = '';
$relative['prefix'] = $lang->rel_in;
}



if($diff < 0)
{
$diff = abs($diff);
$relative['suffix'] = '';
$relative['prefix'] = $lang->rel_in;
}


			$relative['minute'] = floor($diff / 60);

if($relative['minute'] <= 1)

			$relative['minute'] = floor($diff / 60);

if($relative['minute'] <= 1)

Zeile 426Zeile 440
				$relative['prefix'] = $lang->rel_less_than;
}


				$relative['prefix'] = $lang->rel_less_than;
}


			$date = $lang->sprintf($lang->rel_time, $relative['prefix'], $relative['minute'], $relative['plural'], $relative['suffix']);

			$date = $lang->sprintf($lang->rel_time, $relative['prefix'], $relative['minute'], $relative['plural'], $relative['suffix'], $real_date, $real_time);

		}
elseif($ty != 2 && abs(TIME_NOW - $stamp) < 43200)
{

		}
elseif($ty != 2 && abs(TIME_NOW - $stamp) < 43200)
{

Zeile 446Zeile 460
			{
$relative['hour'] = 1;
$relative['plural'] = $lang->rel_hours_single;

			{
$relative['hour'] = 1;
$relative['plural'] = $lang->rel_hours_single;

			}

$date = $lang->sprintf($lang->rel_time, $relative['prefix'], $relative['hour'], $relative['plural'], $relative['suffix']);
}

			}

$date = $lang->sprintf($lang->rel_time, $relative['prefix'], $relative['hour'], $relative['plural'], $relative['suffix'], $real_date, $real_time);
}

		else
{
if($ty)
{
if($todaysdate == $date)

		else
{
if($ty)
{
if($todaysdate == $date)

				{
$date = $lang->today;

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

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

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

					$date = $lang->yesterday;

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

				}

				}

			}


			}


			$date .= $mybb->settings['datetimesep'];
if($adodb == true)

			$date .= $mybb->settings['datetimesep'];
if($adodb == true)

			{

			{

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

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

			}

			}

			else

			else

			{

			{

				$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 497Zeile 536
			else
{
$date = gmdate($format, $stamp + ($offset * 3600));

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

			}
}
}

			}
}
}


if(is_object($plugins))
{


if(is_object($plugins))
{

Zeile 782Zeile 821

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


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


exit;
}

/**


exit;
}

/**

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

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

Zeile 809Zeile 848
	}

// AJAX error message?

	}

// AJAX error message?

	if($mybb->get_input('ajax', MyBB::INPUT_INT))
{

	if($mybb->get_input('ajax', MyBB::INPUT_INT))
{

		// Send our headers.
@header("Content-type: application/json; charset={$lang->settings['charset']}");

if(empty($json_data))

		// Send our headers.
@header("Content-type: application/json; charset={$lang->settings['charset']}");

if(empty($json_data))

		{

		{

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

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

		}
exit;

		}
exit;

	}

$errorlist = '';

	}

$errorlist = '';

Zeile 846Zeile 885

$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 882Zeile 921
		switch($mybb->settings['username_method'])
{
case 0:

		switch($mybb->settings['username_method'])
{
case 0:

				$lang_username = $lang->username;

				$lang_username = $lang->username;

				break;
case 1:
$lang_username = $lang->username1;

				break;
case 1:
$lang_username = $lang->username1;

				break;

				break;

			case 2:
$lang_username = $lang->username2;

			case 2:
$lang_username = $lang->username2;

				break;

				break;

			default:
$lang_username = $lang->username;
break;

			default:
$lang_username = $lang->username;
break;

		}

		}

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


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


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

if($mybb->get_input('ajax', MyBB::INPUT_INT))

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

if($mybb->get_input('ajax', MyBB::INPUT_INT))

	{

	{

		// Send our headers.
//@header("Content-type: text/html; charset={$lang->settings['charset']}");
$data = "<script type=\"text/javascript\">\n";

		// Send our headers.
//@header("Content-type: text/html; charset={$lang->settings['charset']}");
$data = "<script type=\"text/javascript\">\n";

Zeile 940Zeile 979
	if(!$message)
{
$message = $lang->redirect;

	if(!$message)
{
$message = $lang->redirect;

	}


	}


	$time = TIME_NOW;
$timenow = my_date('relative', $time);

	$time = TIME_NOW;
$timenow = my_date('relative', $time);





	if(!$title)
{
$title = $mybb->settings['bbname'];

	if(!$title)
{
$title = $mybb->settings['bbname'];

Zeile 952Zeile 991

// Show redirects only if both ACP and UCP settings are enabled, or ACP is enabled, and user is a guest, or they are forced.
if($force_redirect == true || ($mybb->settings['redirects'] == 1 && ($mybb->user['showredirect'] == 1 || !$mybb->user['uid'])))


// Show redirects only if both ACP and UCP settings are enabled, or ACP is enabled, and user is a guest, or they are forced.
if($force_redirect == true || ($mybb->settings['redirects'] == 1 && ($mybb->user['showredirect'] == 1 || !$mybb->user['uid'])))

	{

	{

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


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


Zeile 966Zeile 1005

run_shutdown();



run_shutdown();


		if(!my_validate_url($url, true))

		if(!my_validate_url($url, true, true))

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

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

Zeile 977Zeile 1016
	}

exit;

	}

exit;

}

/**

}

/**

 * Generate a listing of page - pagination
*
* @param int $count The number of items

 * Generate a listing of page - pagination
*
* @param int $count The number of items

Zeile 992Zeile 1031
function multipage($count, $perpage, $page, $url, $breadcrumb=false)
{
global $theme, $templates, $lang, $mybb;

function multipage($count, $perpage, $page, $url, $breadcrumb=false)
{
global $theme, $templates, $lang, $mybb;





	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 1102Zeile 1143
		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)
{


if($breadcrumb == true)
{

Zeile 1162Zeile 1203
/**
* 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 1774Zeile 1821
	$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 1820Zeile 1867
 * @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 1868Zeile 1916
	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 3011Zeile 3069
 */
function format_name($username, $usergroup, $displaygroup=0)
{

 */
function format_name($username, $usergroup, $displaygroup=0)
{

	global $groupscache, $cache;

	global $groupscache, $cache, $plugins;





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

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

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

if($userin == 0)

	static $formattednames = array();

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













	{

	{

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

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


		$format = "{username}";

		$format = "{username}";

	}

 




	$format = stripslashes($format);




















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

$format = $parameters['format'];

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





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

	return $formattednames[$username];

}

/**

}

/**

Zeile 3056Zeile 3130
	}

if(my_strpos($avatar, '://') !== false && !$mybb->settings['allowremoteavatars'])

	}

if(my_strpos($avatar, '://') !== false && !$mybb->settings['allowremoteavatars'])

	{

	{

		// Remote avatar, but remote avatars are disallowed.
$avatar = null;
}

		// Remote avatar, but remote avatars are disallowed.
$avatar = null;
}

Zeile 3067Zeile 3141
		if(defined('IN_ADMINCP'))
{
$theme['imgdir'] = '../images';

		if(defined('IN_ADMINCP'))
{
$theme['imgdir'] = '../images';

		}


		}


		$avatar = str_replace('{theme}', $theme['imgdir'], $mybb->settings['useravatar']);
$dimensions = $mybb->settings['useravatardims'];

		$avatar = str_replace('{theme}', $theme['imgdir'], $mybb->settings['useravatar']);
$dimensions = $mybb->settings['useravatardims'];

	}


	}


	if(!$max_dimensions)
{
$max_dimensions = $mybb->settings['maxavatardims'];

	if(!$max_dimensions)
{
$max_dimensions = $mybb->settings['maxavatardims'];

Zeile 3096Zeile 3170
	}

$avatar_width_height = '';

	}

$avatar_width_height = '';





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

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

Zeile 3114Zeile 3188
			else
{
$avatar_width_height = "width=\"{$dimensions[0]}\" height=\"{$dimensions[1]}\"";

			else
{
$avatar_width_height = "width=\"{$dimensions[0]}\" height=\"{$dimensions[1]}\"";

			}
}
}

			}
}
}


$avatars[$avatar][$key][$key2] = array(
'image' => htmlspecialchars_uni($mybb->get_asset_url($avatar)),


$avatars[$avatar][$key][$key2] = array(
'image' => htmlspecialchars_uni($mybb->get_asset_url($avatar)),

Zeile 3212Zeile 3286
		$editor_language = "(function ($) {\n$.sceditor.locale[\"mybblang\"] = {\n";

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

		$editor_language = "(function ($) {\n$.sceditor.locale[\"mybblang\"] = {\n";

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





		$editor_languages_count = count($editor_lang_strings);
$i = 0;
foreach($editor_lang_strings as $lang_string => $key)

		$editor_languages_count = count($editor_lang_strings);
$i = 0;
foreach($editor_lang_strings as $lang_string => $key)

Zeile 3228Zeile 3302
			}

$editor_language .= "\n";

			}

$editor_language .= "\n";

		}

$editor_language .= "}})(jQuery);";

		}

$editor_language .= "}})(jQuery);";


if(defined("IN_ADMINCP"))
{


if(defined("IN_ADMINCP"))
{

Zeile 3260Zeile 3334
				if($mybb->settings['smilieinserter'] && $mybb->settings['smilieinsertercols'] && $mybb->settings['smilieinsertertot'] && !empty($smiliecache))
{
$emoticon = ",emoticon";

				if($mybb->settings['smilieinserter'] && $mybb->settings['smilieinsertercols'] && $mybb->settings['smilieinsertertot'] && !empty($smiliecache))
{
$emoticon = ",emoticon";

				}

				}

				$emoticons_enabled = "true";

unset($smilie);

				$emoticons_enabled = "true";

unset($smilie);

Zeile 3296Zeile 3370
						else
{
$moresmilies .= '"'.$find.'": "'.$image.'",';

						else
{
$moresmilies .= '"'.$find.'": "'.$image.'",';

						}

						}


for($j = 1; $j < $finds_count; ++$j)
{


for($j = 1; $j < $finds_count; ++$j)
{

Zeile 3308Zeile 3382
			}

$basic1 = $basic2 = $align = $font = $size = $color = $removeformat = $email = $link = $list = $code = $sourcemode = "";

			}

$basic1 = $basic2 = $align = $font = $size = $color = $removeformat = $email = $link = $list = $code = $sourcemode = "";





			if($mybb->settings['allowbasicmycode'] == 1)
{
$basic1 = "bold,italic,underline,strike|";
$basic2 = "horizontalrule,";

			if($mybb->settings['allowbasicmycode'] == 1)
{
$basic1 = "bold,italic,underline,strike|";
$basic2 = "horizontalrule,";

			}


			}


			if($mybb->settings['allowalignmycode'] == 1)
{
$align = "left,center,right,justify|";

			if($mybb->settings['allowalignmycode'] == 1)
{
$align = "left,center,right,justify|";

Zeile 3326Zeile 3400
			}

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

			}

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

			{

			{

				$size = "size,";
}


				$size = "size,";
}


Zeile 3338Zeile 3412
			if($mybb->settings['allowfontmycode'] == 1 || $mybb->settings['allowsizemycode'] == 1 || $mybb->settings['allowcolormycode'] == 1)
{
$removeformat = "removeformat|";

			if($mybb->settings['allowfontmycode'] == 1 || $mybb->settings['allowsizemycode'] == 1 || $mybb->settings['allowcolormycode'] == 1)
{
$removeformat = "removeformat|";

			}


			}


			if($mybb->settings['allowemailmycode'] == 1)
{
$email = "email,";

			if($mybb->settings['allowemailmycode'] == 1)
{
$email = "email,";

			}


			}


			if($mybb->settings['allowlinkmycode'] == 1)
{
$link = "link,unlink";

			if($mybb->settings['allowlinkmycode'] == 1)
{
$link = "link,unlink";

Zeile 3356Zeile 3430
			}

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

			}

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

			{

			{

				$code = "code,php,";
}

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

				$code = "code,php,";
}

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

			{

			{

				$sourcemode = "MyBBEditor.sourceMode(true);";
}

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

				$sourcemode = "MyBBEditor.sourceMode(true);";
}

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

		}

		}

	}

return $codeinsert;

	}

return $codeinsert;

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

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

		}


		}


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

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

Zeile 3399Zeile 3473
			{
$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);


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

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

Zeile 3781Zeile 3855
	{
$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
if(is_array($data))
{
$data = my_serialize($data);

	}

// Any remaining extra data - we my_serialize and insert in to its own column
if(is_array($data))
{
$data = my_serialize($data);

	}


	}


	$sql_array = array(
"uid" => (int)$mybb->user['uid'],
"dateline" => TIME_NOW,

	$sql_array = array(
"uid" => (int)$mybb->user['uid'],
"dateline" => TIME_NOW,

Zeile 3799Zeile 3880
		"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 4025Zeile 4122
	}

return $time;

	}

return $time;

}


}


/**
* Get the attachment icon for a specific file extension
*

/**
* Get the attachment icon for a specific file extension
*

Zeile 4274Zeile 4371

/**
* Build the forum breadcrumb nagiation (the navigation to a specific forum including all parent forums)


/**
* Build the forum breadcrumb nagiation (the navigation to a specific forum including all parent forums)

 *

 *

 * @param int $fid The forum ID to build the navigation for
* @param array $multipage The multipage drop down array of information
* @return int Returns 1 in every case. Kept for compatibility

 * @param int $fid The forum ID to build the navigation for
* @param array $multipage The multipage drop down array of information
* @return int Returns 1 in every case. Kept for compatibility

Zeile 4288Zeile 4385
		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 4397Zeile 4494
	}

return $url;

	}

return $url;

}


}


/**
* Prints a debug information page
*/

/**
* Prints a debug information page
*/

Zeile 4426Zeile 4523
	if($mybb->settings['gzipoutput'] != 0)
{
$gzipen = "Enabled";

	if($mybb->settings['gzipoutput'] != 0)
{
$gzipen = "Enabled";

	}
else

	}
else

	{
$gzipen = "Disabled";
}

	{
$gzipen = "Disabled";
}

Zeile 4443Zeile 4540
	echo "<h1>MyBB Debug Information</h1>\n";
echo "<h2>Page Generation</h2>\n";
echo "<table bgcolor=\"#666666\" width=\"95%\" cellpadding=\"4\" cellspacing=\"1\" align=\"center\">\n";

	echo "<h1>MyBB Debug Information</h1>\n";
echo "<h2>Page Generation</h2>\n";
echo "<table bgcolor=\"#666666\" width=\"95%\" cellpadding=\"4\" cellspacing=\"1\" align=\"center\">\n";

	echo "<tr>\n";

	echo "<tr>\n";

	echo "<td bgcolor=\"#cccccc\" colspan=\"4\"><b><span style=\"size:2;\">Page Generation Statistics</span></b></td>\n";

	echo "<td bgcolor=\"#cccccc\" colspan=\"4\"><b><span style=\"size:2;\">Page Generation Statistics</span></b></td>\n";

	echo "</tr>\n";
echo "<tr>\n";

	echo "</tr>\n";
echo "<tr>\n";

	echo "<td bgcolor=\"#efefef\" width=\"25%\"><b><span style=\"font-family: tahoma; font-size: 12px;\">Page Generation Time:</span></b></td>\n";
echo "<td bgcolor=\"#fefefe\" width=\"25%\"><span style=\"font-family: tahoma; font-size: 12px;\">$totaltime</span></td>\n";
echo "<td bgcolor=\"#efefef\" width=\"25%\"><b><span style=\"font-family: tahoma; font-size: 12px;\">No. DB Queries:</span></b></td>\n";
echo "<td bgcolor=\"#fefefe\" width=\"25%\"><span style=\"font-family: tahoma; font-size: 12px;\">$db->query_count</span></td>\n";

	echo "<td bgcolor=\"#efefef\" width=\"25%\"><b><span style=\"font-family: tahoma; font-size: 12px;\">Page Generation Time:</span></b></td>\n";
echo "<td bgcolor=\"#fefefe\" width=\"25%\"><span style=\"font-family: tahoma; font-size: 12px;\">$totaltime</span></td>\n";
echo "<td bgcolor=\"#efefef\" width=\"25%\"><b><span style=\"font-family: tahoma; font-size: 12px;\">No. DB Queries:</span></b></td>\n";
echo "<td bgcolor=\"#fefefe\" width=\"25%\"><span style=\"font-family: tahoma; font-size: 12px;\">$db->query_count</span></td>\n";

	echo "</tr>\n";

	echo "</tr>\n";

	echo "<tr>\n";
echo "<td bgcolor=\"#efefef\" width=\"25%\"><b><span style=\"font-family: tahoma; font-size: 12px;\">PHP Processing Time:</span></b></td>\n";
echo "<td bgcolor=\"#fefefe\" width=\"25%\"><span style=\"font-family: tahoma; font-size: 12px;\">$phptime ($percentphp%)</span></td>\n";
echo "<td bgcolor=\"#efefef\" width=\"25%\"><b><span style=\"font-family: tahoma; font-size: 12px;\">DB Processing Time:</span></b></td>\n";
echo "<td bgcolor=\"#fefefe\" width=\"25%\"><span style=\"font-family: tahoma; font-size: 12px;\">$query_time ($percentsql%)</span></td>\n";

	echo "<tr>\n";
echo "<td bgcolor=\"#efefef\" width=\"25%\"><b><span style=\"font-family: tahoma; font-size: 12px;\">PHP Processing Time:</span></b></td>\n";
echo "<td bgcolor=\"#fefefe\" width=\"25%\"><span style=\"font-family: tahoma; font-size: 12px;\">$phptime ($percentphp%)</span></td>\n";
echo "<td bgcolor=\"#efefef\" width=\"25%\"><b><span style=\"font-family: tahoma; font-size: 12px;\">DB Processing Time:</span></b></td>\n";
echo "<td bgcolor=\"#fefefe\" width=\"25%\"><span style=\"font-family: tahoma; font-size: 12px;\">$query_time ($percentsql%)</span></td>\n";

	echo "</tr>\n";
echo "<tr>\n";

	echo "</tr>\n";
echo "<tr>\n";

	echo "<td bgcolor=\"#efefef\" width=\"25%\"><b><span style=\"font-family: tahoma; font-size: 12px;\">Extensions Used:</span></b></td>\n";
echo "<td bgcolor=\"#fefefe\" width=\"25%\"><span style=\"font-family: tahoma; font-size: 12px;\">{$mybb->config['database']['type']}, xml</span></td>\n";
echo "<td bgcolor=\"#efefef\" width=\"25%\"><b><span style=\"font-family: tahoma; font-size: 12px;\">Global.php Processing Time:</span></b></td>\n";

	echo "<td bgcolor=\"#efefef\" width=\"25%\"><b><span style=\"font-family: tahoma; font-size: 12px;\">Extensions Used:</span></b></td>\n";
echo "<td bgcolor=\"#fefefe\" width=\"25%\"><span style=\"font-family: tahoma; font-size: 12px;\">{$mybb->config['database']['type']}, xml</span></td>\n";
echo "<td bgcolor=\"#efefef\" width=\"25%\"><b><span style=\"font-family: tahoma; font-size: 12px;\">Global.php Processing Time:</span></b></td>\n";

Zeile 4520Zeile 4617
		echo "<table style=\"background-color: #666;\" width=\"95%\" cellpadding=\"4\" cellspacing=\"1\" align=\"center\">\n";
echo "<tr>\n";
echo "<td style=\"background-color: #ccc;\"><strong>Templates Used (Loaded for this Page) - ".count($templates->cache)." Total</strong></td>\n";

		echo "<table style=\"background-color: #666;\" width=\"95%\" cellpadding=\"4\" cellspacing=\"1\" align=\"center\">\n";
echo "<tr>\n";
echo "<td style=\"background-color: #ccc;\"><strong>Templates Used (Loaded for this Page) - ".count($templates->cache)." Total</strong></td>\n";

		echo "</tr>\n";
echo "<tr>\n";
echo "<td style=\"background: #fff;\">".implode(", ", array_keys($templates->cache))."</td>\n";
echo "</tr>\n";

		echo "</tr>\n";
echo "<tr>\n";
echo "<td style=\"background: #fff;\">".implode(", ", array_keys($templates->cache))."</td>\n";
echo "</tr>\n";

		echo "</table>\n";
echo "<br />\n";
}

		echo "</table>\n";
echo "<br />\n";
}

Zeile 4675Zeile 4772
	$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(!isset($options['hours']) || $options['hours'] !== false)

Zeile 4718Zeile 4859
			$nicetime['hours'] = "1".$lang_hour;
}
else if($hours > 1)

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

		{

		{

			$nicetime['hours'] = $hours.$lang_hours;
}
}

			$nicetime['hours'] = $hours.$lang_hours;
}
}

Zeile 4750Zeile 4891
	if(is_array($nicetime))
{
return implode(", ", $nicetime);

	if(is_array($nicetime))
{
return implode(", ", $nicetime);

	}
}

/**

	}
}

/**

 * Select an alternating row colour based on the previous call to this function
*
* @param int $reset 1 to reset the row to trow1.

 * Select an alternating row colour based on the previous call to this function
*
* @param int $reset 1 to reset the row to trow1.

Zeile 4764Zeile 4905
	global $alttrow;

if($alttrow == "trow1" && !$reset)

	global $alttrow;

if($alttrow == "trow1" && !$reset)

	{

	{

		$trow = "trow2";
}
else

		$trow = "trow2";
}
else

Zeile 4787Zeile 4928
function join_usergroup($uid, $joingroup)
{
global $db, $mybb;

function join_usergroup($uid, $joingroup)
{
global $db, $mybb;





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

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

Zeile 4810Zeile 4951
		foreach($groups as $gid)
{
if(trim($gid) != "" && $gid != $user['usergroup'] && !isset($donegroup[$gid]))

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

Zeile 4863Zeile 5004

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


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

	{

	{

		$dispupdate = ", displaygroup=usergroup";
}


		$dispupdate = ", displaygroup=usergroup";
}


Zeile 4894Zeile 5035
	if(!empty($_SERVER['SCRIPT_NAME']))
{
$location = htmlspecialchars_uni($_SERVER['SCRIPT_NAME']);

	if(!empty($_SERVER['SCRIPT_NAME']))
{
$location = htmlspecialchars_uni($_SERVER['SCRIPT_NAME']);

	}

	}

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

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

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

	}

	}

	elseif(!empty($_SERVER['PATH_INFO']))

	elseif(!empty($_SERVER['PATH_INFO']))

	{

	{

		$location = htmlspecialchars_uni($_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)
{
return $location;

	if($quick)
{
return $location;

Zeile 5344Zeile 5485
		$lang->month_11,
$lang->month_12
);

		$lang->month_11,
$lang->month_12
);



 

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


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

Zeile 5408Zeile 5548
 *
* @param string $birthday The birthday of a user.
* @return int The age of a user with that birthday.

 *
* @param string $birthday The birthday of a user.
* @return int The age of a user with that birthday.

 */

 */

function get_age($birthday)
{
$bday = explode("-", $birthday);

function get_age($birthday)
{
$bday = explode("-", $birthday);

Zeile 5669Zeile 5809
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 5710Zeile 5850
	{
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 5717Zeile 5879
 *
* @param array $event The event data array.
* @return string The link to the event poster.

 *
* @param array $event The event data array.
* @return string The link to the event poster.

 */

 */

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

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

}

/**

}

/**

 * Get the event date.
*
* @param array $event The event data array.

 * Get the event date.
*
* @param array $event The event data array.

Zeile 5735Zeile 5897
function get_event_date($event)
{
global $mybb;

function get_event_date($event)
{
global $mybb;





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

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





	return $event_date;
}


	return $event_date;
}


Zeile 5748Zeile 5910
 *
* @param int $uid The user id of the profile.
* @return string The url to the profile.

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

 */

 */

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

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

Zeile 5775Zeile 5937
 * @param string $target The target frame
* @param string $onclick Any onclick javascript.
* @return string The complete profile link.

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

 */

 */

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

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

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

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

	{

	{

		// Return Guest phrase for no UID, no guest nickname

		// Return Guest phrase for no UID, no guest nickname

		return $lang->guest;
}

		return htmlspecialchars_uni($lang->guest);
}

	elseif($uid == 0)
{
// Return the guest's nickname if user is a guest but has a nickname
return $username;

	elseif($uid == 0)
{
// Return the guest's nickname if user is a guest but has a nickname
return $username;

	}
else

	}
else

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

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

		{

		{

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

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

		}


		}


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

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

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

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

	}

	}

}

/**

}

/**

Zeile 5840Zeile 6002
function get_thread_link($tid, $page=0, $action='')
{
if($page > 1)

function get_thread_link($tid, $page=0, $action='')
{
if($page > 1)

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

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

		{
$link = THREAD_URL_PAGED;
}

		{
$link = THREAD_URL_PAGED;
}

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

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

		}
else
{

		}
else
{

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

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

Zeile 5888Zeile 6050
	else
{
$link = str_replace("{pid}", $pid, POST_URL);

	else
{
$link = str_replace("{pid}", $pid, POST_URL);

		return htmlspecialchars_uni($link);
}
}


		return htmlspecialchars_uni($link);
}
}


/**
* Build the event link.
*

/**
* Build the event link.
*

Zeile 5947Zeile 6109
 * @param int $calendar The ID of the calendar
* @param int $week The week
* @return string The URL of the calendar

 * @param int $calendar The ID of the calendar
* @param int $week The week
* @return string The URL of the calendar

 */

 */

function get_calendar_week_link($calendar, $week)
{
if($week < 0)

function get_calendar_week_link($calendar, $week)
{
if($week < 0)

Zeile 5975Zeile 6137
	if(!empty($mybb->user) && $uid == $mybb->user['uid'])
{
return $mybb->user;

	if(!empty($mybb->user) && $uid == $mybb->user['uid'])
{
return $mybb->user;

	}

	}

	elseif(isset($user_cache[$uid]))
{
return $user_cache[$uid];

	elseif(isset($user_cache[$uid]))
{
return $user_cache[$uid];

Zeile 6203Zeile 6365
 * @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.
*/

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

function login_attempt_check($uid = 0, $fatal = true)

{

{

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

	global $mybb, $lang, $db;





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






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

	{

	{

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

		$query = $db->simple_select("users", "loginattempts, loginlockoutexpiry", "uid='{$uid}'", 1);
$attempts = $db->fetch_array($query);





















	// Work out if the user has had more than the allowed number of login attempts
if($loginattempts > $mybb->settings['failedlogincount'])
{
// If so, then we need to work out if they can try to login again
// Some maths to work out how long they have left and display it to them
$now = TIME_NOW;

if(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;

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





























		}

		}

 
	}
// This user has a cookie lockout, show waiting time
elseif($mybb->cookies['lockoutexpiry'] && $mybb->cookies['lockoutexpiry'] > $now)
{
if($fatal)
{
$secsleft = (int)($mybb->cookies['lockoutexpiry'] - $now);
$hoursleft = floor($secsleft / 3600);
$minsleft = floor(($secsleft / 60) % 60);
$secsleft = floor($secsleft % 60);





		// Work out if the user has waited long enough before letting them login again
if($mybb->cookies['failedlogin'] < ($now - $mybb->settings['failedlogintime'] * 60))
{
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;
}
// Not waited long enough
else if($mybb->cookies['failedlogin'] > ($now - $mybb->settings['failedlogintime'] * 60))












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

return false;
}

if($mybb->settings['failedlogincount'] > 0 && $attempts['loginattempts'] >= $mybb->settings['failedlogincount'])
{
// Set the expiry dateline if not set yet
if($attempts['loginlockoutexpiry'] == 0)
{
$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'];
}

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

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

			}


			}


			return false;

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

}

/**

}

/**

Zeile 6299Zeile 6470
 */
function validate_email_format($email)
{

 */
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 6313Zeile 6479
 * @param string $email The email to check.
* @param int $uid User ID of the user (updating only)
* @return boolean True when in use, false when not.

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

 */

 */

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

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

Zeile 6341Zeile 6507
{
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'];

Zeile 6365Zeile 6521
	}

$settings = "<"."?php\n/*********************************\ \n DO NOT EDIT THIS FILE, PLEASE USE\n THE SETTINGS EDITOR\n\*********************************/\n\n$settings\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 6462Zeile 6617

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


// 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 6484Zeile 6639
	}

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 6777Zeile 6944
function fetch_remote_file($url, $post_data=array(), $max_redirects=20)
{
global $mybb, $config;

function fetch_remote_file($url, $post_data=array(), $max_redirects=20)
{
global $mybb, $config;

 

if(!my_validate_url($url, true))
{
return false;
}


$url_components = @parse_url($url);


$url_components = @parse_url($url);

 

if(!isset($url_components['scheme']))
{
$url_components['scheme'] = 'https';
}
if(!isset($url_components['port']))
{
$url_components['port'] = $url_components['scheme'] == 'https' ? 443 : 80;
}


if(
!$url_components ||
empty($url_components['host']) ||
(!empty($url_components['scheme']) && !in_array($url_components['scheme'], array('http', 'https'))) ||


if(
!$url_components ||
empty($url_components['host']) ||
(!empty($url_components['scheme']) && !in_array($url_components['scheme'], array('http', 'https'))) ||

		(!empty($url_components['port']) && !in_array($url_components['port'], array(80, 8080, 443))) ||

		(!in_array($url_components['port'], array(80, 8080, 443))) ||

		(!empty($config['disallowed_remote_hosts']) && in_array($url_components['host'], $config['disallowed_remote_hosts']))
)
{
return false;
}

		(!empty($config['disallowed_remote_hosts']) && in_array($url_components['host'], $config['disallowed_remote_hosts']))
)
{
return false;
}

 

$addresses = get_ip_by_hostname($url_components['host']);
$destination_address = $addresses[0];


if(!empty($config['disallowed_remote_addresses']))


if(!empty($config['disallowed_remote_addresses']))

	{
$addresses = gethostbynamel($url_components['host']);
if($addresses)

	{
foreach($config['disallowed_remote_addresses'] as $disallowed_address)


		{

		{

			foreach($config['disallowed_remote_addresses'] as $disallowed_address)





			$ip_range = fetch_ip_range($disallowed_address);

$packed_address = my_inet_pton($destination_address);

if(is_array($ip_range))

			{

			{

				$ip_range = fetch_ip_range($disallowed_address);
foreach($addresses as $address)

				if(strcmp($ip_range[0], $packed_address) <= 0 && strcmp($ip_range[1], $packed_address) >= 0)


				{

				{

					$packed_address = my_inet_pton($address);

if(is_array($ip_range))
{
if(strcmp($ip_range[0], $packed_address) <= 0 && strcmp($ip_range[1], $packed_address) >= 0)
{
return false;
}
}
elseif($address == $disallowed_address)
{
return false;
}

					return false;













				}

				}

 
			}
elseif($destination_address == $disallowed_address)
{
return false;

			}
}
}

$post_body = '';
if(!empty($post_data))

			}
}
}

$post_body = '';
if(!empty($post_data))

	{

	{

		foreach($post_data as $key => $val)
{
$post_body .= '&'.urlencode($key).'='.urlencode($val);

		foreach($post_data as $key => $val)
{
$post_body .= '&'.urlencode($key).'='.urlencode($val);

Zeile 6831Zeile 7009

if(function_exists("curl_init"))
{


if(function_exists("curl_init"))
{

		$can_followlocation = @ini_get('open_basedir') === '' && !$mybb->safemode;

$request_header = $max_redirects != 0 && !$can_followlocation;

		$fetch_header = $max_redirects > 0;




$ch = curl_init();


$ch = curl_init();

		curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, $request_header);
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);

if($max_redirects != 0 && $can_followlocation)
{
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_MAXREDIRS, $max_redirects);
}




























$curlopt = array(
CURLOPT_URL => $url,
CURLOPT_HEADER => $fetch_header,
CURLOPT_TIMEOUT => 10,
CURLOPT_RETURNTRANSFER => 1,
CURLOPT_FOLLOWLOCATION => 0,
);

if($ca_bundle_path = get_ca_bundle_path())
{
$curlopt[CURLOPT_SSL_VERIFYPEER] = 1;
$curlopt[CURLOPT_CAINFO] = $ca_bundle_path;
}
else
{
$curlopt[CURLOPT_SSL_VERIFYPEER] = 0;
}

$curl_version_info = curl_version();
$curl_version = $curl_version_info['version'];

if(version_compare(PHP_VERSION, '7.0.7', '>=') && version_compare($curl_version, '7.49', '>='))
{
// CURLOPT_CONNECT_TO
$curlopt[10243] = array(
$url_components['host'].':'.$url_components['port'].':'.$destination_address
);
}
elseif(version_compare(PHP_VERSION, '5.5', '>=') && version_compare($curl_version, '7.21.3', '>='))
{
// CURLOPT_RESOLVE
$curlopt[10203] = array(
$url_components['host'].':'.$url_components['port'].':'.$destination_address
);
}


		if(!empty($post_body))
{

		if(!empty($post_body))
{

			curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_body);

			$curlopt[CURLOPT_POST] = 1;
$curlopt[CURLOPT_POSTFIELDS] = $post_body;

		}

		}

 

curl_setopt_array($ch, $curlopt);


$response = curl_exec($ch);



$response = curl_exec($ch);


		if($request_header)

		if($fetch_header)

		{
$header_size = curl_getinfo($ch, CURLINFO_HEADER_SIZE);
$header = substr($response, 0, $header_size);

		{
$header_size = curl_getinfo($ch, CURLINFO_HEADER_SIZE);
$header = substr($response, 0, $header_size);

Zeile 6886Zeile 7089
	}
else if(function_exists("fsockopen"))
{

	}
else if(function_exists("fsockopen"))
{

		if(!isset($url_components['port']))
{
$url_components['port'] = 80;
}

 
		if(!isset($url_components['path']))

		if(!isset($url_components['path']))

		{

		{

			$url_components['path'] = "/";

			$url_components['path'] = "/";

		}

		}

		if(isset($url_components['query']))
{
$url_components['path'] .= "?{$url_components['query']}";

		if(isset($url_components['query']))
{
$url_components['path'] .= "?{$url_components['query']}";

		}

$scheme = '';


		}

$scheme = '';


		if($url_components['scheme'] == 'https')

		if($url_components['scheme'] == 'https')

		{

		{

			$scheme = 'ssl://';
if($url_components['port'] == 80)

			$scheme = 'ssl://';
if($url_components['port'] == 80)

			{

			{

				$url_components['port'] = 443;
}
}


				$url_components['port'] = 443;
}
}


		$fp = @fsockopen($scheme.$url_components['host'], $url_components['port'], $error_no, $error, 10);






























		if(function_exists('stream_context_create'))
{
if($url_components['scheme'] == 'https' && $ca_bundle_path = get_ca_bundle_path())
{
$context = stream_context_create(array(
'ssl' => array(
'verify_peer' => true,
'verify_peer_name' => true,
'peer_name' => $url_components['host'],
'cafile' => $ca_bundle_path,
),
));
}
else
{
$context = stream_context_create(array(
'ssl' => array(
'verify_peer' => false,
'verify_peer_name' => false,
),
));
}

$fp = @stream_socket_client($scheme.$destination_address.':'.(int)$url_components['port'], $error_no, $error, 10, STREAM_CLIENT_CONNECT, $context);
}
else
{
$fp = @fsockopen($scheme.$url_components['host'], (int)$url_components['port'], $error_no, $error, 10);
}


		@stream_set_timeout($fp, 10);
if(!$fp)
{

		@stream_set_timeout($fp, 10);
if(!$fp)
{

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

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

		}
else
{

		}
else
{

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

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





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

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

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

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

		}

		}

		else

		else

		{

		{

			// If we have no post body, we need to add an empty element to make sure we've got \r\n\r\n before the (non-existent) body starts
$headers[] = '';

			// If we have no post body, we need to add an empty element to make sure we've got \r\n\r\n before the (non-existent) body starts
$headers[] = '';

		}


		}


		$headers = implode("\r\n", $headers);
if(!@fwrite($fp, $headers))

		$headers = implode("\r\n", $headers);
if(!@fwrite($fp, $headers))

		{
return false;
}


		{
return false;
}


		$data = null;

while(!feof($fp))

		$data = null;

while(!feof($fp))

Zeile 6962Zeile 7190
		$status_line = current(explode("\n\n", $header, 1));
$body = $data[1];


		$status_line = current(explode("\n\n", $header, 1));
$body = $data[1];


		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|$)/', $header, $matches);


Zeile 6973Zeile 7201
		}
else
{

		}
else
{

			$data = $body;
































			$data = $body;
}

return $data;
}
else
{
return false;
}
}

/**
* Resolves a hostname into a set of IP addresses.
*
* @param string $hostname The hostname to be resolved
* @return array|bool The resulting IP addresses. False on failure
*/
function get_ip_by_hostname($hostname)
{
$addresses = @gethostbynamel($hostname);

if(!$addresses)
{
$result_set = @dns_get_record($hostname, DNS_A | DNS_AAAA);

if($result_set)
{
$addresses = array_column($result_set, 'ip');
}
else
{
return false;

		}

		}


return $data;
}
else if(empty($post_data))














	}

return $addresses;
}

/**
* Returns the location of the CA bundle defined in the PHP configuration.
*
* @return string|bool The location of the CA bundle, false if not set
*/
function get_ca_bundle_path()
{
if($path = ini_get('openssl.cafile'))
{
return $path;
}
if($path = ini_get('curl.cainfo'))

	{

	{

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

		return $path;





	}

	}

 

return false;

}

/**

}

/**

Zeile 7122Zeile 7392
			}
}
$in_escape = !$in_escape;

			}
}
$in_escape = !$in_escape;

	}

	}

	if(!count($strings))
{
return $original;

	if(!count($strings))
{
return $original;

Zeile 7179Zeile 7449
			$sep = ".";
}
return array(ip2long($ip_string1), ip2long($ip_string2));

			$sep = ".";
}
return array(ip2long($ip_string1), ip2long($ip_string2));

	}
}


	}
}


/**
* Fetch a list of ban times for a user account.
*

/**
* Fetch a list of ban times for a user account.
*

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

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





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

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

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

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

Zeile 7242Zeile 7512

/**
* Expire old warnings in the database.


/**
* Expire old warnings in the database.

 *
* @return bool

 *
* @return bool

 */
function expire_warnings()
{

 */
function expire_warnings()
{

Zeile 7289Zeile 7559
 * @return bool
*/
function my_rmdir_recursive($path, $ignore=array())

 * @return bool
*/
function my_rmdir_recursive($path, $ignore=array())

{

{

	global $orig_dir;

if(!isset($orig_dir))

	global $orig_dir;

if(!isset($orig_dir))

Zeile 7318Zeile 7588
		}

return @rmdir($path);

		}

return @rmdir($path);

	}


	}


	return @unlink($path);
}


	return @unlink($path);
}


Zeile 7364Zeile 7634
	}

if($ip_long >= 2147483648) // Won't occur on 32-bit PHP

	}

if($ip_long >= 2147483648) // Won't occur on 32-bit PHP

	{

	{

		$ip_long -= 4294967296;
}


		$ip_long -= 4294967296;
}


Zeile 7378Zeile 7648
 * @deprecated
* @param integer $long The IP to convert (will accept 64-bit IPs as well)
* @return string IP in IPv4 format

 * @deprecated
* @param integer $long The IP to convert (will accept 64-bit IPs as well)
* @return string IP in IPv4 format

 */

 */

function my_long2ip($long)
{
// On 64-bit machines is_int will return true. On 32-bit it will return false

function my_long2ip($long)
{
// On 64-bit machines is_int will return true. On 32-bit it will return false

Zeile 7392Zeile 7662

/**
* Converts a human readable IP address to its packed in_addr representation


/**
* Converts a human readable IP address to its packed in_addr representation

 *

 *

 * @param string $ip The IP to convert
* @return string IP in 32bit or 128bit binary format
*/

 * @param string $ip The IP to convert
* @return string IP in 32bit or 128bit binary format
*/

Zeile 7406Zeile 7676
	{
/**
* Replace inet_pton()

	{
/**
* Replace inet_pton()

		 *
* @category PHP

		 *
* @category PHP

		 * @package     PHP_Compat
* @license LGPL - http://www.gnu.org/licenses/lgpl.html
* @copyright 2004-2007 Aidan Lister <aidan@php.net>, Arpad Ray <arpad@php.net>

		 * @package     PHP_Compat
* @license LGPL - http://www.gnu.org/licenses/lgpl.html
* @copyright 2004-2007 Aidan Lister <aidan@php.net>, Arpad Ray <arpad@php.net>

Zeile 7480Zeile 7750
					array('::', '(int)"$1"?"$1":"0$1"'),
$r);
return $r;

					array('::', '(int)"$1"?"$1":"0$1"'),
$r);
return $r;

		}
return false;
}
}

/**

		}
return false;
}
}

/**

 * Fetch an binary formatted range for searching IPv4 and IPv6 IP addresses.
*
* @param string $ipaddress The IP address to convert to a range

 * Fetch an binary formatted range for searching IPv4 and IPv6 IP addresses.
*
* @param string $ipaddress The IP address to convert to a range

Zeile 7500Zeile 7770
		{
// IPv6
$upper = str_replace('*', 'ffff', $ipaddress);

		{
// IPv6
$upper = str_replace('*', 'ffff', $ipaddress);

			$lower = str_replace('*', '0', $ipaddress);
}

			$lower = str_replace('*', '0', $ipaddress);
}

		else
{
// IPv4

		else
{
// IPv4

Zeile 7564Zeile 7834
			$bit = decbin(ord($ip_pack[$i]));
$bit = str_pad($bit, 8, '0', STR_PAD_LEFT);
$ip_bits .= $bit;

			$bit = decbin(ord($ip_pack[$i]));
$bit = str_pad($bit, 8, '0', STR_PAD_LEFT);
$ip_bits .= $bit;

		}

		}


// Significative bits (from the ip range)
$ip_bits = substr($ip_bits, 0, $ip_range);


// Significative bits (from the ip range)
$ip_bits = substr($ip_bits, 0, $ip_range);

Zeile 7609Zeile 7879
{
static $time_start;


{
static $time_start;


	$time = microtime(true);



	$time = microtime(true);



	// Just starting timer, init and return
if(!$time_start)
{
$time_start = $time;
return;

	// Just starting timer, init and return
if(!$time_start)
{
$time_start = $time;
return;

	}

	}

	// Timer has run, return execution time
else
{

	// Timer has run, return execution time
else
{

Zeile 7625Zeile 7894
		if($total < 0) $total = 0;
$time_start = 0;
return $total;

		if($total < 0) $total = 0;
$time_start = 0;
return $total;

	}
}


	}
}


/**
* Processes a checksum list on MyBB files and returns a result set
*

/**
* Processes a checksum list on MyBB files and returns a result set
*

Zeile 7640Zeile 7909
	global $mybb, $checksums, $bad_verify_files;

// We don't need to check these types of files

	global $mybb, $checksums, $bad_verify_files;

// We don't need to check these types of files

	$ignore = array(".", "..", ".svn", "config.php", "settings.php", "Thumb.db", "config.default.php", "lock", "htaccess.txt", "logo.gif", "logo.png");

	$ignore = array(".", "..", ".svn", "config.php", "settings.php", "Thumb.db", "config.default.php", "lock", "htaccess.txt", "htaccess-nginx.txt", "logo.gif", "logo.png");

	$ignore_ext = array("attach");

if(substr($path, -1, 1) == "/")

	$ignore_ext = array("attach");

if(substr($path, -1, 1) == "/")

Zeile 7674Zeile 7943
				}

// We only need the last part of the path (from the MyBB directory to the file. i.e. inc/functions.php)

				}

// We only need the last part of the path (from the MyBB directory to the file. i.e. inc/functions.php)

				$file_path = ".".str_replace(substr(MYBB_ROOT, 0, -1), "", $path)."/".$file;

				$file_path = ".".str_replace(substr(MYBB_ROOT, 0, -1), "", $path)."/".$file;


// Does this file even exist in our official list? Perhaps it's a plugin
if(array_key_exists($file_path, $checksums))
{
$filename = $path."/".$file;
$handle = fopen($filename, "rb");


// Does this file even exist in our official list? Perhaps it's a plugin
if(array_key_exists($file_path, $checksums))
{
$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 7739Zeile 8008
	else
{
return "+$int";

	else
{
return "+$int";

	}

	}

}

/**

}

/**

Zeile 7766Zeile 8035
		{
$output = @fread($handle, $bytes);
@fclose($handle);

		{
$output = @fread($handle, $bytes);
@fclose($handle);

		}
}
else
{
return $output;

		}
}
else
{
return $output;

	}

if(strlen($output) < $bytes)

	}

if(strlen($output) < $bytes)

Zeile 7817Zeile 8086
	if(strlen($output) < $bytes)
{
if(class_exists('COM'))

	if(strlen($output) < $bytes)
{
if(class_exists('COM'))

		{

		{

			try
{
$CAPI_Util = new COM('CAPICOM.Utilities.1');

			try
{
$CAPI_Util = new COM('CAPICOM.Utilities.1');

Zeile 7827Zeile 8096
				}
} catch (Exception $e) {
}

				}
} catch (Exception $e) {
}

		}
}
else
{
return $output;
}

		}
}
else
{
return $output;
}


if(strlen($output) < $bytes)
{
// Close to what PHP basically uses internally to seed, but not quite.
$unique_state = microtime().@getmypid();



if(strlen($output) < $bytes)
{
// Close to what PHP basically uses internally to seed, but not quite.
$unique_state = microtime().@getmypid();


		$rounds = ceil($bytes / 16);


		$rounds = ceil($bytes / 16);


		for($i = 0; $i < $rounds; $i++)
{
$unique_state = md5(microtime().$unique_state);

		for($i = 0; $i < $rounds; $i++)
{
$unique_state = md5(microtime().$unique_state);

Zeile 7849Zeile 8118

$output = substr($output, 0, ($bytes * 2));



$output = substr($output, 0, ($bytes * 2));


		$output = pack('H*', $output);

return $output;
}

		$output = pack('H*', $output);

return $output;
}

	else
{
return $output;

	else
{
return $output;

Zeile 7863Zeile 8132
 * Returns a securely generated seed integer
*
* @return int An integer equivalent of a secure hexadecimal seed

 * Returns a securely generated seed integer
*
* @return int An integer equivalent of a secure hexadecimal seed

 */

 */

function secure_seed_rng()
{
$bytes = PHP_INT_SIZE;

function secure_seed_rng()
{
$bytes = PHP_INT_SIZE;

Zeile 8340Zeile 8609
	}

$pm['options'] = array(

	}

$pm['options'] = array(

		"signature" => 0,

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

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

Zeile 8356Zeile 8624
	if($pmhandler->validate_pm())
{
$pmhandler->insert_pm();

	if($pmhandler->validate_pm())
{
$pmhandler->insert_pm();

		return true;
}

return false;
}


		return true;
}

return false;
}


/**
* Log a user spam block from StopForumSpam (or other spam service providers...)
*

/**
* Log a user spam block from StopForumSpam (or other spam service providers...)
*

Zeile 8408Zeile 8676
 * @return bool Whether the file was copied successfully.
*/
function copy_file_to_cdn($file_path = '', &$uploaded_path = null)

 * @return bool Whether the file was copied successfully.
*/
function copy_file_to_cdn($file_path = '', &$uploaded_path = null)

{

{

	global $mybb, $plugins;

$success = false;

	global $mybb, $plugins;

$success = false;

Zeile 8439Zeile 8707
			if(!($dir_exists = is_dir($cdn_upload_path)))
{
$dir_exists = @mkdir($cdn_upload_path, 0777, true);

			if(!($dir_exists = is_dir($cdn_upload_path)))
{
$dir_exists = @mkdir($cdn_upload_path, 0777, true);

			}


			}


			if($dir_exists)
{
if(($cdn_upload_path = realpath($cdn_upload_path)) !== false)

			if($dir_exists)
{
if(($cdn_upload_path = realpath($cdn_upload_path)) !== false)

Zeile 8452Zeile 8720
						$uploaded_path = $cdn_upload_path;
}
}

						$uploaded_path = $cdn_upload_path;
}
}

			}
}


			}
}


		if(is_object($plugins))
{
$hook_args = array(

		if(is_object($plugins))
{
$hook_args = array(

Zeile 8464Zeile 8732
				'uploaded_path' => &$uploaded_path,
'success' => &$success,
);

				'uploaded_path' => &$uploaded_path,
'success' => &$success,
);





			$plugins->run_hooks('copy_file_to_cdn_end', $hook_args);
}
}

return $success;

			$plugins->run_hooks('copy_file_to_cdn_end', $hook_args);
}
}

return $success;

}

/**

}

/**

 * Validate an url

 * Validate an url

 *

 *

 * @param string $url The url to validate.
* @param bool $relative_path Whether or not the url could be a relative path.

 * @param string $url The url to validate.
* @param bool $relative_path Whether or not the url could be a relative path.

 
 * @param bool $allow_local Whether or not the url could be pointing to local networks.

 *
* @return bool Whether this is a valid url.
*/

 *
* @return bool Whether this is a valid url.
*/

function my_validate_url($url, $relative_path=false)

function my_validate_url($url, $relative_path=false, $allow_local=false)

{

{

	if($relative_path && my_substr($url, 0, 1) == '/' || preg_match('_^(?:(?:https?|ftp)://)(?:\S+(?::\S*)?@)?(?:(?!(?:10|127)(?:\.\d{1,3}){3})(?!(?:169\.254|192\.168)(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z\x{00a1}-\x{ffff}0-9]-*)*[a-z\x{00a1}-\x{ffff}0-9]+)(?:\.(?:[a-z\x{00a1}-\x{ffff}0-9]-*)*[a-z\x{00a1}-\x{ffff}0-9]+)*(?:\.(?:[a-z\x{00a1}-\x{ffff}]{2,}))\.?)(?::\d{2,5})?(?:[/?#]\S*)?$_iuS', $url))
















































	if($allow_local)
{
$regex = '_^(?:(?:https?|ftp)://)(?:\S+(?::\S*)?@)?(?:(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:localhost|(?:(?:[a-z\x{00a1}-\x{ffff}0-9]-*)*[a-z\x{00a1}-\x{ffff}0-9]+)(?:\.(?:[a-z\x{00a1}-\x{ffff}0-9]-*)*[a-z\x{00a1}-\x{ffff}0-9]+)*(?:\.(?:[a-z\x{00a1}-\x{ffff}]{2,}))\.?))(?::\d{2,5})?(?:[/?#]\S*)?$_iuS';
}
else
{
$regex = '_^(?:(?:https?|ftp)://)(?:\S+(?::\S*)?@)?(?:(?!(?:10|127)(?:\.\d{1,3}){3})(?!(?:169\.254|192\.168)(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z\x{00a1}-\x{ffff}0-9]-*)*[a-z\x{00a1}-\x{ffff}0-9]+)(?:\.(?:[a-z\x{00a1}-\x{ffff}0-9]-*)*[a-z\x{00a1}-\x{ffff}0-9]+)*(?:\.(?:[a-z\x{00a1}-\x{ffff}]{2,}))\.?)(?::\d{2,5})?(?:[/?#]\S*)?$_iuS';
}

if($relative_path && my_substr($url, 0, 1) == '/' || preg_match($regex, $url))
{
return true;
}
return false;
}

/**
* 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
*
* @return string Striped string
*/
function my_strip_tags($string, $allowable_tags = '')
{
$pattern = array(
'@(&lt;)style[^(&gt;)]*?(&gt;).*?(&lt;)/style(&gt;)@siu',
'@(&lt;)script[^(&gt;)]*?.*?(&lt;)/script(&gt;)@siu',
'@<style[^>]*?>.*?</style>@siu',
'@<script[^>]*?.*?</script>@siu',
);
$string = preg_replace($pattern, '', $string);
return strip_tags($string, $allowable_tags);
}

/**
* 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
*/
function my_escape_csv($string, $escape_active_content=true)
{
if($escape_active_content)

	{

	{

		return true;




















		$active_content_triggers = array('=', '+', '-', '@');
$delimiters = array(',', ';', ':', '|', '^', "\n", "\t", " ");

$first_character = mb_substr($string, 0, 1);

if(
in_array($first_character, $active_content_triggers, true) ||
in_array($first_character, $delimiters, true)
)
{
$string = "'".$string;
}

foreach($delimiters as $delimiter)
{
foreach($active_content_triggers as $trigger)
{
$string = str_replace($delimiter.$trigger, $delimiter."'".$trigger, $string);
}
}

	}


	}


	return false;



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

return $string;

}

}