/** * Outputs a page directly to the browser, parsing anything which needs to be parsed. * * @param string The contents of the page. */ function output_page($contents) { global $db, $lang, $theme, $plugins, $mybb; global $debug, $templatecache, $templatelist, $maintimer, $globaltime, $parsetime; $contents = parse_page($contents); $totaltime = $maintimer->stop(); if ($mybb->usergroup['cancp'] == 1) { if ($mybb->settings['extraadmininfo'] != 0) { $phptime = $maintimer->format($maintimer->totaltime - $db->query_time); $query_time = $maintimer->format($db->query_time); if ($maintimer->totaltime > 0) { $percentphp = number_format($phptime / $maintimer->totaltime * 100, 2); $percentsql = number_format($query_time / $maintimer->totaltime * 100, 2); } else { // if we've got a super fast script... all we can do is assume something $percentphp = 0; $percentsql = 0; } $phpversion = phpversion(); $serverload = get_server_load(); if (my_strpos(getenv("REQUEST_URI"), "?")) { $debuglink = htmlspecialchars(getenv("REQUEST_URI")) . "&debug=1"; } else { $debuglink = htmlspecialchars(getenv("REQUEST_URI")) . "?debug=1"; } if ($mybb->settings['gzipoutput'] != 0) { $gzipen = "Enabled"; } else { $gzipen = "Disabled"; } if (function_exists("memory_get_usage")) { $memory_usage = " / Memory Usage: " . get_friendly_size(memory_get_peak_usage(true)); } $other = "PHP version: {$phpversion} / Server Load: {$serverload} / GZip Compression: {$gzipen}"; $debugstuff = "Generated in {$totaltime} seconds ({$percentphp}% PHP / {$percentsql}% MySQL)<br />SQL Queries: {$db->query_count} / Global Parsing Time: {$globaltime}{$memory_usage}<br />{$other}<br />[<a href=\"{$debuglink}\" target=\"_blank\">advanced details</a>]<br />"; $contents = str_replace("<debugstuff>", $debugstuff, $contents); } if ($mybb->debug_mode == true) { debug_page(); } } $contents = str_replace("<debugstuff>", "", $contents); $contents = $plugins->run_hooks("pre_output_page", $contents); if ($mybb->settings['gzipoutput'] == 1) { if (version_compare(PHP_VERSION, '4.2.0', '>=')) { $contents = gzip_encode($contents, $mybb->settings['gziplevel']); } else { $contents = gzip_encode($contents); } } @header("Content-type: text/html; charset={$lang->settings['charset']}"); echo $contents; $plugins->run_hooks("post_output_page"); // If the use shutdown functionality is turned off, run any shutdown related items now. if ($mybb->settings['useshutdownfunc'] == 0 && $mybb->use_shutdown != true) { run_shutdown(); } }
/** * Outputs a page directly to the browser, parsing anything which needs to be parsed. * * @param string The contents of the page. */ function output_page($contents) { global $db, $lang, $theme, $plugins, $mybb; global $debug, $templatecache, $templatelist, $maintimer, $globaltime, $parsetime; $contents = parse_page($contents); $totaltime = $maintimer->stop(); $contents = $plugins->run_hooks("pre_output_page", $contents); if ($mybb->usergroup['cancp'] == 1) { if ($mybb->settings['extraadmininfo'] != 0) { $phptime = $maintimer->format($maintimer->totaltime - $db->query_time); $query_time = $maintimer->format($db->query_time); if ($maintimer->totaltime > 0) { $percentphp = number_format($phptime / $maintimer->totaltime * 100, 2); $percentsql = number_format($query_time / $maintimer->totaltime * 100, 2); } else { // if we've got a super fast script... all we can do is assume something $percentphp = 0; $percentsql = 0; } $phpversion = PHP_VERSION; $serverload = get_server_load(); if (my_strpos(getenv("REQUEST_URI"), "?")) { $debuglink = htmlspecialchars_uni(getenv("REQUEST_URI")) . "&debug=1"; } else { $debuglink = htmlspecialchars_uni(getenv("REQUEST_URI")) . "?debug=1"; } if ($mybb->settings['gzipoutput'] != 0) { $gzipen = "Enabled"; } else { $gzipen = "Disabled"; } $memory_usage = get_memory_usage(); if ($memory_usage) { $memory_usage = " / Memory Usage: " . get_friendly_size($memory_usage); } else { $memory_usage = ''; } // MySQLi is still MySQL, so present it that way to the user $database_server = $db->short_title; if ($database_server == 'MySQLi') { $database_server = 'MySQL'; } $other = "PHP version: {$phpversion} / Server Load: {$serverload} / GZip Compression: {$gzipen}"; $debugstuff = "Generated in {$totaltime} seconds ({$percentphp}% PHP / {$percentsql}% " . $database_server . ")<br />SQL Queries: {$db->query_count} / Global Parsing Time: {$globaltime}{$memory_usage}<br />{$other}<br />[<a href=\"{$debuglink}\" target=\"_blank\">advanced details</a>]<br />"; $contents = str_replace("<debugstuff>", $debugstuff, $contents); } if ($mybb->debug_mode == true) { debug_page(); } } $contents = str_replace("<debugstuff>", "", $contents); if ($mybb->settings['gzipoutput'] == 1) { $contents = gzip_encode($contents, $mybb->settings['gziplevel']); } @header("Content-type: text/html; charset={$lang->settings['charset']}"); echo $contents; $plugins->run_hooks("post_output_page"); }
/** * Outputs a page directly to the browser, parsing anything which needs to be parsed. * * @param string $contents The contents of the page. */ function output_page($contents) { global $db, $lang, $theme, $templates, $plugins, $mybb; global $debug, $templatecache, $templatelist, $maintimer, $globaltime, $parsetime; $contents = parse_page($contents); $totaltime = format_time_duration($maintimer->stop()); $contents = $plugins->run_hooks("pre_output_page", $contents); if ($mybb->usergroup['cancp'] == 1 || $mybb->dev_mode == 1) { if ($mybb->settings['extraadmininfo'] != 0) { $phptime = $maintimer->totaltime - $db->query_time; $query_time = $db->query_time; if ($maintimer->totaltime > 0) { $percentphp = number_format($phptime / $maintimer->totaltime * 100, 2); $percentsql = number_format($query_time / $maintimer->totaltime * 100, 2); } else { // if we've got a super fast script... all we can do is assume something $percentphp = 0; $percentsql = 0; } $serverload = get_server_load(); if (my_strpos(getenv("REQUEST_URI"), "?")) { $debuglink = htmlspecialchars_uni(getenv("REQUEST_URI")) . "&debug=1"; } else { $debuglink = htmlspecialchars_uni(getenv("REQUEST_URI")) . "?debug=1"; } $memory_usage = get_memory_usage(); if ($memory_usage) { $memory_usage = $lang->sprintf($lang->debug_memory_usage, get_friendly_size($memory_usage)); } else { $memory_usage = ''; } // MySQLi is still MySQL, so present it that way to the user $database_server = $db->short_title; if ($database_server == 'MySQLi') { $database_server = 'MySQL'; } $generated_in = $lang->sprintf($lang->debug_generated_in, $totaltime); $debug_weight = $lang->sprintf($lang->debug_weight, $percentphp, $percentsql, $database_server); $sql_queries = $lang->sprintf($lang->debug_sql_queries, $db->query_count); $server_load = $lang->sprintf($lang->debug_server_load, $serverload); eval("\$debugstuff = \"" . $templates->get("debug_summary") . "\";"); $contents = str_replace("<debugstuff>", $debugstuff, $contents); } if ($mybb->debug_mode == true) { debug_page(); } } $contents = str_replace("<debugstuff>", "", $contents); if ($mybb->settings['gzipoutput'] == 1) { $contents = gzip_encode($contents, $mybb->settings['gziplevel']); } @header("Content-type: text/html; charset={$lang->settings['charset']}"); echo $contents; $plugins->run_hooks("post_output_page"); }
function prostats_run_feed() { global $mybb, $db, $templates, $theme, $lang, $unviewables, $parser, $session, $lightbulb, $trow, $newestposts_cols_name, $newestposts_cols, $colspan, $feeditem; if (!$mybb->settings['ps_enable'] || !$mybb->settings['ps_xml_feed']) { return false; } if ($mybb->settings['ps_hidefrombots'] && !empty($session->is_spider)) { return false; } if (!is_object($parser)) { require_once MYBB_ROOT . 'inc/class_parser.php'; $parser = new postParser(); } $seo = 0; if ($mybb->settings['seourls'] == "yes" || $mybb->settings['seourls'] == "auto" && $_SERVER['SEO_SUPPORT'] == 1) { $seo = 1; } ps_GetNewestPosts($mybb->settings['ps_num_rows'], true); //echo '<pre>';print_r($feeditem);echo '</pre>';exit;//just for test! ;-) /* $feeditem { [tid] [fuid] [fid] [bulb] [lasttime] [datetime] [subject] [username] [username_formed] [lastposter_uid] [lastposter_uname] [lastposter_uname_formed] [lastposter_profile] [forumname] [forumname_long] } */ $xml_feed = '<?xml version="1.0" encoding="UTF-8"?>'; $xml_feed .= '<ProStats>'; $xml_feed .= '<bburl>' . $mybb->settings['bburl'] . '</bburl>'; $xml_feed .= '<seo>' . intval($seo) . '</seo>'; foreach ($feeditem as $key => $value) { $xml_feed .= '<record num="' . ($key + 1) . '">'; $xml_feed .= '<tid>' . $feeditem[$key]['tid'] . '</tid>'; $xml_feed .= '<fuid>' . $feeditem[$key]['fuid'] . '</fuid>'; $xml_feed .= '<fid>' . $feeditem[$key]['fid'] . '</fid>'; $xml_feed .= '<bulb>' . $feeditem[$key]['bulb'] . '</bulb>'; $xml_feed .= '<lasttime>' . $feeditem[$key]['lasttime'] . '</lasttime>'; $xml_feed .= '<datetime>' . htmlspecialchars_uni($feeditem[$key]['datetime']) . '</datetime>'; $xml_feed .= '<subject>' . htmlspecialchars_uni($feeditem[$key]['subject']) . '</subject>'; $xml_feed .= '<longsubject>' . htmlspecialchars_uni($feeditem[$key]['subject_long']) . '</longsubject>'; $xml_feed .= '<uname>' . htmlspecialchars_uni($feeditem[$key]['username']) . '</uname>'; $xml_feed .= '<uname2>' . htmlspecialchars_uni($feeditem[$key]['username_formed']) . '</uname2>'; $xml_feed .= '<luid>' . $feeditem[$key]['lastposter_uid'] . '</luid>'; $xml_feed .= '<luname>' . htmlspecialchars_uni($feeditem[$key]['lastposter_uname']) . '</luname>'; $xml_feed .= '<luname2>' . htmlspecialchars_uni($feeditem[$key]['lastposter_uname_formed']) . '</luname2>'; $xml_feed .= '<fname>' . htmlspecialchars_uni($feeditem[$key]['forumname']) . '</fname>'; $xml_feed .= '<ffullname>' . htmlspecialchars_uni($feeditem[$key]['forumname_long']) . '</ffullname>'; $xml_feed .= '</record>'; } $xml_feed .= '</ProStats>'; if ($mybb->settings['gzipoutput'] == 1) { if (version_compare(PHP_VERSION, '4.2.0', '>=')) { $xml_feed = gzip_encode($xml_feed, $mybb->settings['gziplevel']); } else { $xml_feed = gzip_encode($xml_feed); } } header("content-type: text/xml"); echo $xml_feed; }