Vergleich inc/functions.php - 1.8.12 - 1.8.15

  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 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 470Zeile 470
			{
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 487
			{
$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 520
		{
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

			}
}
else

Zeile 521Zeile 546
	}

return $date;

	}

return $date;

}


}


/**
* Sends an email using PHP's mail function, formatting it appropriately.
*

/**
* Sends an email using PHP's mail function, formatting it appropriately.
*

Zeile 554Zeile 579
			$mail = new SmtpMail();
}
else

			$mail = new SmtpMail();
}
else

		{

		{

			require_once MYBB_ROOT."inc/mailhandlers/php.php";
$mail = new PhpMail();

			require_once MYBB_ROOT."inc/mailhandlers/php.php";
$mail = new PhpMail();

		}
}

		}
}


// Using SMTP based mail
if($mybb->settings['mail_handler'] == 'smtp')


// Using SMTP based mail
if($mybb->settings['mail_handler'] == 'smtp')

Zeile 570Zeile 595
	}

// Using PHP based mail()

	}

// Using PHP based mail()

	else

	else

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

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

Zeile 615Zeile 640
	if(generate_post_check() !== $code)
{
if($silent == true)

	if(generate_post_check() !== $code)
{
if($silent == true)

		{
return false;
}

		{
return false;
}

		else
{
if(defined("IN_ADMINCP"))

		else
{
if(defined("IN_ADMINCP"))

Zeile 868Zeile 893
	);

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

	);

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


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

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

Zeile 995Zeile 1020

/**
* Generate a listing of page - pagination


/**
* Generate a listing of page - pagination

 *

 *

 * @param int $count The number of items
* @param int $perpage The number of items to be shown per page
* @param int $page The current page number

 * @param int $count The number of items
* @param int $perpage The number of items to be shown per page
* @param int $page The current page number

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

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

	}

	}


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


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

Zeile 1041Zeile 1066
	}

if($to > $pages)

	}

if($to > $pages)

	{
$to = $pages;

	{
$to = $pages;

		$from = $pages-$mybb->settings['maxmultipagelinks']+1;
if($from <= 0)
{
$from = 1;
}

		$from = $pages-$mybb->settings['maxmultipagelinks']+1;
if($from <= 0)
{
$from = 1;
}

	}

	}


if($to == 0)
{


if($to == 0)
{

Zeile 1057Zeile 1082

$start = '';
if($from > 1)


$start = '';
if($from > 1)

	{

	{

		if($from-1 == 1)
{
$lang->multipage_link_start = '';

		if($from-1 == 1)
{
$lang->multipage_link_start = '';

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

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

	}
else

	}
else

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

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





	return $multipage;
}


	return $multipage;
}


Zeile 1138Zeile 1163
 * @return string
*/
function fetch_page_url($url, $page)

 * @return string
*/
function fetch_page_url($url, $page)

{

{

	if($page <= 1)
{
$find = array(

	if($page <= 1)
{
$find = array(

Zeile 1185Zeile 1210

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


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

	{

	{

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


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


Zeile 1193Zeile 1218
	if($uid != $mybb->user['uid'])
{
// We've already cached permissions for this user, return them.

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

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

		}

		}


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


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





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

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

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

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

	}

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


	}

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


	if(count($groups) == 1)

	if(count($groups) == 1)

	{

	{

		$groupscache[$gid]['all_usergroups'] = $gid;
return $groupscache[$gid];
}

		$groupscache[$gid]['all_usergroups'] = $gid;
return $groupscache[$gid];
}





	$usergroup = array();
$usergroup['all_usergroups'] = $gid;


	$usergroup = array();
$usergroup['all_usergroups'] = $gid;


Zeile 1250Zeile 1275
		if(trim($gid) == "" || empty($groupscache[$gid]))
{
continue;

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

		}

		}


foreach($groupscache[$gid] as $perm => $access)
{


foreach($groupscache[$gid] as $perm => $access)
{

Zeile 1281Zeile 1306
	}

return $usergroup;

	}

return $usergroup;

}


}


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

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

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

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

		{

		{

			$user = get_user($uid);

			$user = get_user($uid);





			$gid = $user['usergroup'].",".$user['additionalgroups'];
$groupperms = usergroup_permissions($gid);
}

			$gid = $user['usergroup'].",".$user['additionalgroups'];
$groupperms = usergroup_permissions($gid);
}

Zeile 1345Zeile 1370
			}

$groupperms = $mybb->usergroup;

			}

$groupperms = $mybb->usergroup;

		}
}


		}
}


	if(!is_array($forum_cache))

	if(!is_array($forum_cache))

	{

	{

		$forum_cache = cache_forums();

		$forum_cache = cache_forums();





		if(!$forum_cache)
{
return false;

		if(!$forum_cache)
{
return false;

Zeile 1361Zeile 1386
	if(!is_array($fpermcache))
{
$fpermcache = $cache->read("forumpermissions");

	if(!is_array($fpermcache))
{
$fpermcache = $cache->read("forumpermissions");

	}

	}


if($fid) // Fetch the permissions for a single forum
{


if($fid) // Fetch the permissions for a single forum
{

Zeile 1376Zeile 1401
		if(empty($cached_forum_permissions[$gid]))
{
foreach($forum_cache as $forum)

		if(empty($cached_forum_permissions[$gid]))
{
foreach($forum_cache as $forum)

			{

			{

				$cached_forum_permissions[$gid][$forum['fid']] = fetch_forum_permissions($forum['fid'], $gid, $groupperms);
}
}

				$cached_forum_permissions[$gid][$forum['fid']] = fetch_forum_permissions($forum['fid'], $gid, $groupperms);
}
}

Zeile 1439Zeile 1464
			}

foreach($level_permissions as $permission => $access)

			}

foreach($level_permissions as $permission => $access)

			{

			{

				if(empty($current_permissions[$permission]) || $access >= $current_permissions[$permission] || ($access == "yes" && $current_permissions[$permission] == "no"))
{
$current_permissions[$permission] = $access;
}

				if(empty($current_permissions[$permission]) || $access >= $current_permissions[$permission] || ($access == "yes" && $current_permissions[$permission] == "no"))
{
$current_permissions[$permission] = $access;
}

			}


			}


			if($level_permissions["canview"] && empty($level_permissions["canonlyviewownthreads"]))

			if($level_permissions["canview"] && empty($level_permissions["canonlyviewownthreads"]))

			{

			{

				$only_view_own_threads = 0;

				$only_view_own_threads = 0;

			}

			}


if($level_permissions["canpostreplys"] && empty($level_permissions["canonlyreplyownthreads"]))
{
$only_reply_own_threads = 0;
}


if($level_permissions["canpostreplys"] && empty($level_permissions["canonlyreplyownthreads"]))
{
$only_reply_own_threads = 0;
}

		}
}


		}
}


	// Figure out if we can view more than our own threads
if($only_view_own_threads == 0)
{
$current_permissions["canonlyviewownthreads"] = 0;

	// Figure out if we can view more than our own threads
if($only_view_own_threads == 0)
{
$current_permissions["canonlyviewownthreads"] = 0;

	}


	}


	// Figure out if we can reply more than our own threads
if($only_reply_own_threads == 0)
{

	// Figure out if we can reply more than our own threads
if($only_reply_own_threads == 0)
{

Zeile 1471Zeile 1496
	}

if(count($current_permissions) == 0)

	}

if(count($current_permissions) == 0)

	{

	{

		$current_permissions = $groupperms;
}
return $current_permissions;

		$current_permissions = $groupperms;
}
return $current_permissions;

Zeile 1502Zeile 1527

// Loop through each of parent forums to ensure we have a password for them too
if(isset($forum_cache[$fid]['parentlist']))


// Loop through each of parent forums to ensure we have a password for them too
if(isset($forum_cache[$fid]['parentlist']))

	{

	{

		$parents = explode(',', $forum_cache[$fid]['parentlist']);
rsort($parents);
}

		$parents = explode(',', $forum_cache[$fid]['parentlist']);
rsort($parents);
}

Zeile 1753Zeile 1778
			$modperms = get_moderator_permissions($fid, $uid);

if(!$action && $modperms)

			$modperms = get_moderator_permissions($fid, $uid);

if(!$action && $modperms)

			{

			{

				return true;

				return true;

			}

			}

			else
{
if(isset($modperms[$action]) && $modperms[$action] == 1)

			else
{
if(isset($modperms[$action]) && $modperms[$action] == 1)

Zeile 1767Zeile 1792
					return false;
}
}

					return false;
}
}

		}
}

		}
}

}

}





/**
* Generate a list of the posticons.
*

/**
* Generate a list of the posticons.
*

Zeile 1783Zeile 1808
	if(isset($mybb->input['icon']))
{
$icon = $mybb->get_input('icon');

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

	}

	}


$iconlist = '';
$no_icons_checked = " checked=\"checked\"";


$iconlist = '';
$no_icons_checked = " checked=\"checked\"";

Zeile 1813Zeile 1838
		}

eval("\$iconlist .= \"".$templates->get("posticons_icon")."\";");

		}

eval("\$iconlist .= \"".$templates->get("posticons_icon")."\";");

	}


	}


	if(!empty($iconlist))
{
eval("\$posticons = \"".$templates->get("posticons")."\";");

	if(!empty($iconlist))
{
eval("\$posticons = \"".$templates->get("posticons")."\";");

Zeile 1845Zeile 1870
	}

if($expires == -1)

	}

if($expires == -1)

	{

	{

		$expires = 0;
}
elseif($expires == "" || $expires == null)

		$expires = 0;
}
elseif($expires == "" || $expires == null)

Zeile 1877Zeile 1902
	if(!empty($mybb->settings['cookiedomain']))
{
$cookie .= "; domain={$mybb->settings['cookiedomain']}";

	if(!empty($mybb->settings['cookiedomain']))
{
$cookie .= "; domain={$mybb->settings['cookiedomain']}";

	}


	}


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

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

Zeile 2254Zeile 2279
	if(isset($mbIntEnc))
{
mb_internal_encoding($mbIntEnc);

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

	}


	}


	return $out;
}


	return $out;
}


Zeile 2507Zeile 2532
				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];
}

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


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


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

Zeile 2642Zeile 2667
	);

$db->update_query("forums", $updated_forum, "fid='{$fid}'");

	);

$db->update_query("forums", $updated_forum, "fid='{$fid}'");

}

/**

}

/**

 * Updates the thread counters with a specific value (or addition/subtraction of the previous value)
*
* @param int $tid The thread ID

 * Updates the thread counters with a specific value (or addition/subtraction of the previous value)
*
* @param int $tid The thread ID

Zeile 2658Zeile 2683
	$tid = (int)$tid;

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

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

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

Zeile 2682Zeile 2707
			else
{
$update_query[$counter] = $changes[$counter];

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

			}

			}


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


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

Zeile 2690Zeile 2715
				$update_query[$counter] = 0;
}
}

				$update_query[$counter] = 0;
}
}

	}

	}


$db->free_result($query);



$db->free_result($query);


Zeile 2707Zeile 2732
 * @param int $tid The thread ID
*/
function update_thread_data($tid)

 * @param int $tid The thread ID
*/
function update_thread_data($tid)

{
global $db;

$thread = get_thread($tid);

{
global $db;

$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 2838Zeile 2863
 * @return bool
*/
function delete_thread($tid)

 * @return bool
*/
function delete_thread($tid)

{
global $moderation;

if(!is_object($moderation))

{
global $moderation;

if(!is_object($moderation))

	{
require_once MYBB_ROOT."inc/class_moderation.php";
$moderation = new Moderation;
}

return $moderation->delete_thread($tid);

	{
require_once MYBB_ROOT."inc/class_moderation.php";
$moderation = new Moderation;
}

return $moderation->delete_thread($tid);

}

/**

}

/**

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

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

Zeile 2891Zeile 2916
	if(!is_array($jumpfcache))
{
if(!is_array($forum_cache))

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

		{

		{

			cache_forums();
}


			cache_forums();
}


Zeile 2907Zeile 2932
	if(!is_array($permissioncache))
{
$permissioncache = forum_permissions();

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

	}

	}


if(isset($jumpfcache[$pid]) && is_array($jumpfcache[$pid]))
{


if(isset($jumpfcache[$pid]) && is_array($jumpfcache[$pid]))
{

Zeile 2916Zeile 2941
			foreach($main as $forum)
{
$perms = $permissioncache[$forum['fid']];

			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))
{
$optionselected = "";

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

Zeile 2924Zeile 2949
					if($selitem == $forum['fid'])
{
$optionselected = 'selected="selected"';

					if($selitem == $forum['fid'])
{
$optionselected = 'selected="selected"';

					}

					}


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



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


Zeile 2949Zeile 2974
		else
{
$template = "advanced";

		else
{
$template = "advanced";





			if(strpos(FORUM_URL, '.html') !== false)
{
$forum_link = "'".str_replace('{fid}', "'+option+'", FORUM_URL)."'";

			if(strpos(FORUM_URL, '.html') !== false)
{
$forum_link = "'".str_replace('{fid}', "'+option+'", FORUM_URL)."'";

Zeile 2973Zeile 2998
 * @return string The extension of the file.
*/
function get_extension($file)

 * @return string The extension of the file.
*/
function get_extension($file)

{

{

	return my_strtolower(my_substr(strrchr($file, "."), 1));
}


	return my_strtolower(my_substr(strrchr($file, "."), 1));
}


Zeile 3014Zeile 3039

return implode($str);
}


return implode($str);
}





/**
* Formats a username based on their display group
*

/**
* Formats a username based on their display group
*

Zeile 3025Zeile 3050
 */
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 3795Zeile 3836
	{
$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 3813Zeile 3861
		"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 4689Zeile 4753
	$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;

































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

	}

	}

	else if($months > 1)



if(!isset($options['weeks']) || $options['weeks'] !== false)

	{

	{

		$nicetime['months'] = $months.$lang_months;








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

	}


	}


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

if($days == 1)

	if(!isset($options['days']) || $options['days'] !== false)










	{

	{

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




		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 5683Zeile 5791
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 5832
	{
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 5738Zeile 5868
	$event['username'] = format_name($event['username'], $event['usergroup'], $event['displaygroup']);
$event_poster = build_profile_link($event['username'], $event['author']);
return $event_poster;

	$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 5753Zeile 5883
	$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 5766Zeile 5896
function get_profile_link($uid=0)
{
$link = str_replace("{uid}", $uid, PROFILE_URL);

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

	return htmlspecialchars_uni($link);
}

	return htmlspecialchars_uni($link);
}


/**
* Get the announcement link.


/**
* Get the announcement link.

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

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

}


}


/**
* Build the profile link.
*

/**
* Build the profile link.
*

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

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





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

	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)

	elseif($uid == 0)

	{

	{

		// Return the guest's nickname if user is a guest but has a nickname
return $username;
}

		// Return the guest's nickname if user is a guest but has a nickname
return $username;
}

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

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

		{

		{

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


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


Zeile 5833Zeile 5963
	if($page > 0)
{
$link = str_replace("{fid}", $fid, FORUM_URL_PAGED);

	if($page > 0)
{
$link = str_replace("{fid}", $fid, FORUM_URL_PAGED);

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

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

	}
else
{

	}
else
{

Zeile 6154Zeile 6284
	$pid = (int)$pid;

if(isset($post_cache[$pid]))

	$pid = (int)$pid;

if(isset($post_cache[$pid]))

	{

	{

		return $post_cache[$pid];
}
else

		return $post_cache[$pid];
}
else

Zeile 6313Zeile 6443
 */
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 6329Zeile 6454
 * @return boolean True when in use, false when not.
*/
function email_already_in_use($email, $uid=0)

 * @return boolean True when in use, false when not.
*/
function email_already_in_use($email, $uid=0)

{

{

	global $db;

$uid_string = "";
if($uid)

	global $db;

$uid_string = "";
if($uid)

	{

	{

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

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

Zeile 6354Zeile 6479
function rebuild_settings()
{
global $db, $mybb;

function rebuild_settings()
{
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);

$settings = null;


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

$settings = '';











	while($setting = $db->fetch_array($query))
{
$mybb->settings[$setting['name']] = $setting['value'];
$setting['value'] = addcslashes($setting['value'], '\\"$');
$settings .= "\$settings['{$setting['name']}'] = \"{$setting['value']}\";\n";

	while($setting = $db->fetch_array($query))
{
$mybb->settings[$setting['name']] = $setting['value'];
$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);


	}

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

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



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


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


Zeile 6423Zeile 6537
		$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 6449Zeile 6563
				}
}
$inquote = !$inquote;

				}
}
$inquote = !$inquote;

		}

		}

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

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

Zeile 6476Zeile 6590

// 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)
{
$word = trim($word);

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





		$word = my_strtolower($word);

		$word = my_strtolower($word);





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

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

		}


		}


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

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





	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 6570Zeile 6696
			}
return true;
}

			}
return true;
}

	}

	}

	// Still here - good username
return false;
}

	// Still here - good username
return false;
}

Zeile 6596Zeile 6722
	}

if(is_array($banned_cache) && !empty($banned_cache))

	}

if(is_array($banned_cache) && !empty($banned_cache))

	{

	{

		foreach($banned_cache as $banned_email)
{
// Make regular expression * match

		foreach($banned_cache as $banned_email)
{
// Make regular expression * match

Zeile 7798Zeile 7924
				{
$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 8618Zeile 8744

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


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

 * 

 *

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