Vergleich inc/functions.php - 1.8.13 - 1.8.15

  Keine Änderungen   Hinzugefügt   Modifiziert   Entfernt
Zeile 3050Zeile 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))



	static $formattednames = array();

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

	{

	{

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

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





















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

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

$format = "{username}";

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

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

$format = stripslashes($format);

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

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





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

		$format = $parameters['format'];







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

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



	}


	}


	$format = stripslashes($format);

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

	return $formattednames[$username];



}

/**

}

/**

Zeile 3901Zeile 3917
	}

return $display_reputation;

	}

return $display_reputation;

}

/**

}

/**

 * Fetch a color coded version of a warning level (based on it's percentage)
*
* @param int $level The warning level (percentage of 100)

 * Fetch a color coded version of a warning level (based on it's percentage)
*
* @param int $level The warning level (percentage of 100)

Zeile 4324Zeile 4340
 *
* @param string $name The name of the item to add
* @param string $url The URL of the item to add

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

 */

 */

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

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

Zeile 4480Zeile 4496
	$query_time = format_time_duration($db->query_time);

$call_time = format_time_duration($cache->call_time);

	$query_time = format_time_duration($db->query_time);

$call_time = format_time_duration($cache->call_time);





	$phpversion = PHP_VERSION;

	$phpversion = PHP_VERSION;





	$serverload = get_server_load();

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

	$serverload = get_server_load();

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

	{

	{

		$gzipen = "Enabled";
}
else

		$gzipen = "Enabled";
}
else

Zeile 4505Zeile 4521
	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 "</tr>\n";
echo "<tr>\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";

Zeile 4531Zeile 4547
	echo "<td bgcolor=\"#fefefe\" width=\"25%\"><span style=\"font-family: tahoma; font-size: 12px;\">$phpversion</span></td>\n";
echo "<td bgcolor=\"#efefef\" width=\"25%\"><b><span style=\"font-family: tahoma; font-size: 12px;\">Server Load:</span></b></td>\n";
echo "<td bgcolor=\"#fefefe\" width=\"25%\"><span style=\"font-family: tahoma; font-size: 12px;\">$serverload</span></td>\n";

	echo "<td bgcolor=\"#fefefe\" width=\"25%\"><span style=\"font-family: tahoma; font-size: 12px;\">$phpversion</span></td>\n";
echo "<td bgcolor=\"#efefef\" width=\"25%\"><b><span style=\"font-family: tahoma; font-size: 12px;\">Server Load:</span></b></td>\n";
echo "<td bgcolor=\"#fefefe\" width=\"25%\"><span style=\"font-family: tahoma; font-size: 12px;\">$serverload</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;\">GZip Encoding Status:</span></b></td>\n";
echo "<td bgcolor=\"#fefefe\" width=\"25%\"><span style=\"font-family: tahoma; font-size: 12px;\">$gzipen</span></td>\n";
echo "<td bgcolor=\"#efefef\" width=\"25%\"><b><span style=\"font-family: tahoma; font-size: 12px;\">No. Templates Used:</span></b></td>\n";
echo "<td bgcolor=\"#fefefe\" width=\"25%\"><span style=\"font-family: tahoma; font-size: 12px;\">".count($templates->cache)." (".(int)count(explode(",", $templatelist))." Cached / ".(int)count($templates->uncached_templates)." Manually Loaded)</span></td>\n";

	echo "<td bgcolor=\"#efefef\" width=\"25%\"><b><span style=\"font-family: tahoma; font-size: 12px;\">GZip Encoding Status:</span></b></td>\n";
echo "<td bgcolor=\"#fefefe\" width=\"25%\"><span style=\"font-family: tahoma; font-size: 12px;\">$gzipen</span></td>\n";
echo "<td bgcolor=\"#efefef\" width=\"25%\"><b><span style=\"font-family: tahoma; font-size: 12px;\">No. Templates Used:</span></b></td>\n";
echo "<td bgcolor=\"#fefefe\" width=\"25%\"><span style=\"font-family: tahoma; font-size: 12px;\">".count($templates->cache)." (".(int)count(explode(",", $templatelist))." Cached / ".(int)count($templates->uncached_templates)." Manually Loaded)</span></td>\n";

	echo "</tr>\n";

	echo "</tr>\n";


$memory_usage = get_memory_usage();
if(!$memory_usage)
{
$memory_usage = $lang->unknown;


$memory_usage = get_memory_usage();
if(!$memory_usage)
{
$memory_usage = $lang->unknown;

	}

	}

	else
{
$memory_usage = get_friendly_size($memory_usage)." ({$memory_usage} bytes)";

	else
{
$memory_usage = get_friendly_size($memory_usage)." ({$memory_usage} bytes)";

Zeile 4554Zeile 4570
	echo "<td bgcolor=\"#FEFEFE\" width=\"25%\"><span style=\"font-family: tahoma; font-size: 12px;\">{$memory_usage}</span></td>\n";
echo "<td bgcolor=\"#EFEFEF\" width=\"25%\"><b><span style=\"font-family: tahoma; font-size: 12px;\">Memory Limit:</span></b></td>\n";
echo "<td bgcolor=\"#FEFEFE\" width=\"25%\"><span style=\"font-family: tahoma; font-size: 12px;\">{$memory_limit}</span></td>\n";

	echo "<td bgcolor=\"#FEFEFE\" width=\"25%\"><span style=\"font-family: tahoma; font-size: 12px;\">{$memory_usage}</span></td>\n";
echo "<td bgcolor=\"#EFEFEF\" width=\"25%\"><b><span style=\"font-family: tahoma; font-size: 12px;\">Memory Limit:</span></b></td>\n";
echo "<td bgcolor=\"#FEFEFE\" width=\"25%\"><span style=\"font-family: tahoma; font-size: 12px;\">{$memory_limit}</span></td>\n";

	echo "</tr>\n";

echo "</table>\n";

	echo "</tr>\n";

echo "</table>\n";


echo "<h2>Database Connections (".count($db->connections)." Total) </h2>\n";
echo "<table style=\"background-color: #666;\" width=\"95%\" cellpadding=\"4\" cellspacing=\"1\" align=\"center\">\n";


echo "<h2>Database Connections (".count($db->connections)." Total) </h2>\n";
echo "<table style=\"background-color: #666;\" width=\"95%\" cellpadding=\"4\" cellspacing=\"1\" align=\"center\">\n";

Zeile 4582Zeile 4598
		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 4605Zeile 4621
	echo "</body>";
echo "</html>";
exit;

	echo "</body>";
echo "</html>";
exit;

}

}


/**
* Outputs the correct page headers.
*/
function send_page_headers()


/**
* Outputs the correct page headers.
*/
function send_page_headers()

{

{

	global $mybb;

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

	global $mybb;

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

Zeile 4636Zeile 4652
	switch($type)
{
case "posts":

	switch($type)
{
case "posts":

			if(is_array($id))
{

			if(is_array($id))
{

				$rids = implode($id, "','");
$rids = "'0','$rids'";
$db->update_query("reportedcontent", array('reportstatus' => 1), "id IN($rids) AND reportstatus='0' AND (type = 'post' OR type = '')");
}
break;
case "post":

				$rids = implode($id, "','");
$rids = "'0','$rids'";
$db->update_query("reportedcontent", array('reportstatus' => 1), "id IN($rids) AND reportstatus='0' AND (type = 'post' OR type = '')");
}
break;
case "post":

			$db->update_query("reportedcontent", array('reportstatus' => 1), "id='$id' AND reportstatus='0' AND (type = 'post' OR type = '')");

			$db->update_query("reportedcontent", array('reportstatus' => 1), "id='$id' AND reportstatus='0' AND (type = 'post' OR type = '')");

			break;
case "threads":
if(is_array($id))

			break;
case "threads":
if(is_array($id))

Zeile 4689Zeile 4705
	$msecs = 60;

if(isset($options['short']))

	$msecs = 60;

if(isset($options['short']))

	{

	{

		$lang_year = $lang->year_short;
$lang_years = $lang->years_short;
$lang_month = $lang->month_short;

		$lang_year = $lang->year_short;
$lang_years = $lang->years_short;
$lang_month = $lang->month_short;

Zeile 4722Zeile 4738
		$lang_second = " ".$lang->second;
$lang_seconds = " ".$lang->seconds;
}

		$lang_second = " ".$lang->second;
$lang_seconds = " ".$lang->seconds;
}





	$years = floor($stamp/$ysecs);
$stamp %= $ysecs;
$months = floor($stamp/$mosecs);

	$years = floor($stamp/$ysecs);
$stamp %= $ysecs;
$months = floor($stamp/$mosecs);

Zeile 4742Zeile 4758
	{
$options = array_merge(array(
'days' => false,

	{
$options = array_merge(array(
'days' => false,

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

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

	}
elseif($months > 0)
{
$options = array_merge(array(
'hours' => false,

	}
elseif($months > 0)
{
$options = array_merge(array(
'hours' => false,

			'minutes' => false,
'seconds' => false

			'minutes' => false,
'seconds' => false

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

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

			'seconds' => false

			'seconds' => false

		), $options);
}
elseif($days > 0)

		), $options);
}
elseif($days > 0)

Zeile 4772Zeile 4788
	if(!isset($options['years']) || $options['years'] !== false)
{
if($years == 1)

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

		{

		{

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

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

		}

		}

		else if($years > 1)
{
$nicetime['years'] = $years.$lang_years;

		else if($years > 1)
{
$nicetime['years'] = $years.$lang_years;

		}
}

		}
}


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


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

Zeile 4798Zeile 4814
		if($weeks == 1)
{
$nicetime['weeks'] = "1".$lang_week;

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

		}

		}

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

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

		}
}


		}
}


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

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

		}

		}

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

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

Zeile 4830Zeile 4846
	}

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

	}

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

	{

	{

		if($minutes == 1)

		if($minutes == 1)

		{

		{

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

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

		{

		{

			$nicetime['minutes'] = $minutes.$lang_minutes;
}
}

			$nicetime['minutes'] = $minutes.$lang_minutes;
}
}

Zeile 4850Zeile 4866
		else if($seconds > 1)
{
$nicetime['seconds'] = $seconds.$lang_seconds;

		else if($seconds > 1)
{
$nicetime['seconds'] = $seconds.$lang_seconds;

		}
}


		}
}


	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.
* @return string trow1 or trow2 depending on the previous call

/**
* Select an alternating row colour based on the previous call to this function
*
* @param int $reset 1 to reset the row to trow1.
* @return string trow1 or trow2 depending on the previous call

 */

 */

function alt_trow($reset=0)
{
global $alttrow;

function alt_trow($reset=0)
{
global $alttrow;

Zeile 4876Zeile 4892
	else
{
$trow = "trow1";

	else
{
$trow = "trow1";

	}


	}


	$alttrow = $trow;

return $trow;

	$alttrow = $trow;

return $trow;

Zeile 4902Zeile 4918
	{
$query = $db->simple_select("users", "additionalgroups, usergroup", "uid='".(int)$uid."'");
$user = $db->fetch_array($query);

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

	}


	}


	// Build the new list of additional groups for this user and make sure they're in the right format
$usergroups = "";
$usergroups = $user['additionalgroups'].",".$joingroup;

	// Build the new list of additional groups for this user and make sure they're in the right format
$usergroups = "";
$usergroups = $user['additionalgroups'].",".$joingroup;

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

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

		}

		}

	}

	}





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

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





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

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

		}
}


		}
}


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

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

Zeile 5138Zeile 5154
				if($theme['tid'] == $selected)
{
$sel = " selected=\"selected\"";

				if($theme['tid'] == $selected)
{
$sel = " selected=\"selected\"";

				}


				}


				if($theme['pid'] != 0)
{
$theme['name'] = htmlspecialchars_uni($theme['name']);

				if($theme['pid'] != 0)
{
$theme['name'] = htmlspecialchars_uni($theme['name']);

Zeile 5165Zeile 5181
		else
{
eval("\$themeselect = \"".$templates->get("usercp_themeselector")."\";");

		else
{
eval("\$themeselect = \"".$templates->get("usercp_themeselector")."\";");

		}


		}


		return $themeselect;
}
else

		return $themeselect;
}
else

Zeile 6008Zeile 6024
function get_post_link($pid, $tid=0)
{
if($tid > 0)

function get_post_link($pid, $tid=0)
{
if($tid > 0)

	{

	{

		$link = str_replace("{tid}", $tid, THREAD_URL_POST);
$link = str_replace("{pid}", $pid, $link);
return htmlspecialchars_uni($link);

		$link = str_replace("{tid}", $tid, THREAD_URL_POST);
$link = str_replace("{pid}", $pid, $link);
return htmlspecialchars_uni($link);

Zeile 6060Zeile 6076
	}
/* Not implemented
else if($year > 0)

	}
/* Not implemented
else if($year > 0)

	{

	{

	}*/
else
{
$link = str_replace("{calendar}", $calendar, CALENDAR_URL);
return htmlspecialchars_uni($link);

	}*/
else
{
$link = str_replace("{calendar}", $calendar, CALENDAR_URL);
return htmlspecialchars_uni($link);

	}

	}

}

/**

}

/**

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

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

	{

	{

		$week = str_replace('-', "n", $week);
}
$link = str_replace("{week}", $week, CALENDAR_URL_WEEK);

		$week = str_replace('-', "n", $week);
}
$link = str_replace("{week}", $week, CALENDAR_URL_WEEK);

Zeile 6105Zeile 6121
		return $mybb->user;
}
elseif(isset($user_cache[$uid]))

		return $mybb->user;
}
elseif(isset($user_cache[$uid]))

	{

	{

		return $user_cache[$uid];
}
elseif($uid > 0)
{
$query = $db->simple_select("users", "*", "uid = '{$uid}'");
$user_cache[$uid] = $db->fetch_array($query);

		return $user_cache[$uid];
}
elseif($uid > 0)
{
$query = $db->simple_select("users", "*", "uid = '{$uid}'");
$user_cache[$uid] = $db->fetch_array($query);





		return $user_cache[$uid];
}
return array();

		return $user_cache[$uid];
}
return array();

Zeile 6216Zeile 6232
	}

return $forum_cache[$fid];

	}

return $forum_cache[$fid];

}


}


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

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

Zeile 6427Zeile 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 7913Zeile 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);
}