//
// Outputs the contents of a page rendering variables
//
function outputpage($contents)
{
global $db, $lang, $settings, $theme, $plugins, $mybb, $mybbuser, $mybbgroup;
global $querytime, $debug, $templatecache, $templatelist, $maintimer, $globaltime, $parsetime;
$ptimer = new timer();
$contents = parsepage($contents);
$parsetime = $ptimer->stop();
$totaltime = $maintimer->stop();
if($mybbgroup['cancp'] == "yes")
{
$phptime = $maintimer->format($maintimer->totaltime - $querytime);
$querytime = $maintimer->format($querytime);
$percentphp = number_format((($phptime/$maintimer->totaltime)*100), 2);
$percentsql = number_format((($querytime/$maintimer->totaltime)*100), 2);
$phpversion = phpversion();
$serverload = serverload();
if(strstr(getenv("REQUEST_URI"), "?"))
{
$debuglink = htmlspecialchars(getenv("REQUEST_URI")) . "&debug=1";
}
else
{
$debuglink = htmlspecialchars(getenv("REQUEST_URI")) . "?debug=1";
}
if($mybb->settings['gzipoutput'] != "no")
{
$gzipen = "Enabled";
}
else
{
$gzipen = "Disabled";
}
$other = "PHP version: $phpversion / Server Load: $serverload / GZip Compression: $gzipen";
$debugstuff = "Generated in $totaltime seconds ($percentphp% PHP / $percentsql% MySQL)<br />MySQL Queries: $db->query_count / Parsing $parsetime / Global Parsing Time: $globaltime<br />$other<br />[<a href=\"$debuglink\" target=\"_blank\">advanced details</a>]<br />";
$contents = str_replace("<debugstuff>", $debugstuff, $contents);
if($mybb->input['debug'])
{
debugpage();
}
}
else
{
$contents = str_replace("<debugstuff>", "", $contents);
}
$contents = $plugins->run_hooks("pre_output_page", $contents);
if($mybb->settings['gzipoutput'] != "no")
{
$contents = gzipencode($contents, $mybb->settings['gziplevel']);
}
echo $contents;
$plugins->run_hooks("post_output_page");
if(NO_SHUTDOWN)
{
run_shutdown();
}
}