<?php
/**
* MyBB 1.8
* Copyright 2014 MyBB Group, All Rights Reserved
*
* Website: http://www.mybb.com
* License: http://www.mybb.com/about/license
*
*/
/**
* 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");
}
/**
* Adds a function or class to the list of code to run on shutdown.
*
* @param string|array $name The name of the function.
* @param mixed $arguments Either an array of arguments for the function or one argument
* @return boolean True if function exists, otherwise false.
*/
function add_shutdown($name, $arguments=array())
{
global $shutdown_functions;
if(!is_array($shutdown_functions))
{
$shutdown_functions = array();
}
if(!is_array($arguments))
{
$arguments = array($arguments);
}
if(is_array($name) && method_exists($name[0], $name[1]))
{
$shutdown_functions[] = array('function' => $name, 'arguments' => $arguments);
return true;
}
else if(!is_array($name) && function_exists($name))
{
$shutdown_functions[] = array('function' => $name, 'arguments' => $arguments);
return true;
}
return false;
}
/**
* Runs the shutdown items after the page has been sent to the browser.
*
*/
function run_shutdown()
{
global $config, $db, $cache, $plugins, $error_handler, $shutdown_functions, $shutdown_queries, $done_shutdown, $mybb;
if($done_shutdown == true || !$config || (isset($error_handler) && $error_handler->has_errors))
{
return;
}
if(empty($shutdown_queries) && empty($shutdown_functions))
{
// Nothing to do
return;
}
// Missing the core? Build
if(!is_object($mybb))
{
require_once MYBB_ROOT."inc/class_core.php";
$mybb = new MyBB;
// Load the settings
require MYBB_ROOT."inc/settings.php";
$mybb->settings = &$settings;
}
// If our DB has been deconstructed already (bad PHP 5.2.0), reconstruct
if(!is_object($db))
{
if(!isset($config) || empty($config['database']['type']))
{
require MYBB_ROOT."inc/config.php";
}
if(isset($config))
{
// Load DB interface
require_once MYBB_ROOT."inc/db_base.php";
require_once MYBB_ROOT."inc/db_".$config['database']['type'].".php";
switch($config['database']['type'])
{
case "sqlite":
$db = new DB_SQLite;
break;
case "pgsql":
$db = new DB_PgSQL;
break;
case "mysqli":
$db = new DB_MySQLi;
break;
default:
$db = new DB_MySQL;
}
$db->connect($config['database']);
if(!defined("TABLE_PREFIX"))
{
define("TABLE_PREFIX", $config['database']['table_prefix']);
}
$db->set_table_prefix(TABLE_PREFIX);
}
}
// Cache object deconstructed? reconstruct
if(!is_object($cache))
{
require_once MYBB_ROOT."inc/class_datacache.php";
$cache = new datacache;
$cache->cache();
}
// And finally.. plugins
if(!is_object($plugins) && !defined("NO_PLUGINS") && !($mybb->settings['no_plugins'] == 1))
{
require_once MYBB_ROOT."inc/class_plugins.php";
$plugins = new pluginSystem;
$plugins->load();
}
// We have some shutdown queries needing to be run
if(is_array($shutdown_queries))
{
// Loop through and run them all
foreach($shutdown_queries as $query)
{
$db->query($query);
}
}
// Run any shutdown functions if we have them
if(is_array($shutdown_functions))
{
foreach($shutdown_functions as $function)
{
call_user_func_array($function['function'], $function['arguments']);
}
}
$done_shutdown = true;
}
/**
* Sends a specified amount of messages from the mail queue
*
* @param int $count The number of messages to send (Defaults to 10)
*/
function send_mail_queue($count=10)
{
global $db, $cache, $plugins;
$plugins->run_hooks("send_mail_queue_start");
// Check to see if the mail queue has messages needing to be sent
$mailcache = $cache->read("mailqueue");
if($mailcache['queue_size'] > 0 && ($mailcache['locked'] == 0 || $mailcache['locked'] < TIME_NOW-300))
{
// Lock the queue so no other messages can be sent whilst these are (for popular boards)
$cache->update_mailqueue(0, TIME_NOW);
// Fetch emails for this page view - and send them
$query = $db->simple_select("mailqueue", "*", "", array("order_by" => "mid", "order_dir" => "asc", "limit_start" => 0, "limit" => $count));
while($email = $db->fetch_array($query))
{
// Delete the message from the queue
$db->delete_query("mailqueue", "mid='{$email['mid']}'");
if($db->affected_rows() == 1)
{
my_mail($email['mailto'], $email['subject'], $email['message'], $email['mailfrom'], "", $email['headers'], true);
}
}
// Update the mailqueue cache and remove the lock
$cache->update_mailqueue(TIME_NOW, 0);
}
$plugins->run_hooks("send_mail_queue_end");
}
/**
* Parses the contents of a page before outputting it.
*
* @param string $contents The contents of the page.
* @return string The parsed page.
*/
function parse_page($contents)
{
global $lang, $theme, $mybb, $htmldoctype, $archive_url, $error_handler;
$contents = str_replace('<navigation>', build_breadcrumb(), $contents);
$contents = str_replace('<archive_url>', $archive_url, $contents);
if($htmldoctype)
{
$contents = $htmldoctype.$contents;
}
else
{
$contents = "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
mybb.zip_delphi mysql_mybb_mybb_com (782个子文件)
office.css 26KB
office-toolbar.css 25KB
main.css 23KB
buttons.css 20KB
select2.css 19KB
monocons.css 17KB
jquery-ui.min.css 16KB
modern.css 16KB
square.css 15KB
jquery-ui.theme.min.css 14KB
mybb.css 13KB
default.css 12KB
codemirror.css 7KB
stylesheet.css 6KB
stylesheet.css 4KB
login.css 3KB
jquery.sceditor.buttons.css 2KB
jquery.sceditor.monocons.css 2KB
jquery.sceditor.default.css 2KB
jquery.sceditor.modern.css 2KB
jquery.sceditor.office.css 2KB
jquery.sceditor.square.css 2KB
jquery.sceditor.mybb.css 2KB
jquery.sceditor.office-toolbar.css 2KB
screen.css 2KB
print.css 2KB
mybb.css 2KB
config.css 1KB
forum.css 1KB
jquery-ui.structure.min.css 1KB
jquery.sceditor.default.min.css 943B
modal.css 904B
user.css 877B
style.css 557B
dialog-mybb.css 510B
dialog.css 502B
popup.css 468B
home.css 447B
foldgutter.css 435B
matchesonscrollbar.css 188B
monocons.eot 8KB
spinner_big.gif 7KB
spinner_big.gif 6KB
select2-spinner.gif 2KB
animated-overlay.gif 2KB
spinner.gif 2KB
spinner.gif 2KB
.htaccess 142B
说明.htm 4KB
license.html 43KB
read_me.html 11KB
install.html 5KB
less.html 4KB
upgrade.html 3KB
index.html 3KB
scss.html 3KB
json-ld.html 2KB
credits.html 2KB
typescript.html 2KB
index.html 74B
index.html 74B
index.html 74B
index.html 67B
index.html 67B
index.html 67B
index.html 67B
index.html 67B
index.html 67B
index.html 67B
index.html 67B
index.html 67B
index.html 67B
index.html 67B
index.html 67B
index.html 67B
index.html 67B
index.html 67B
index.html 67B
index.html 67B
index.html 67B
index.html 67B
index.html 67B
index.html 67B
index.html 67B
index.html 67B
index.html 67B
index.html 67B
index.html 67B
index.html 67B
index.html 67B
index.html 67B
index.html 67B
index.html 67B
index.html 67B
index.html 67B
index.html 67B
index.html 67B
index.html 67B
index.html 67B
index.html 67B
共 782 条
- 1
- 2
- 3
- 4
- 5
- 6
- 8
资源评论
刘良运
- 粉丝: 66
- 资源: 1万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- pta题库答案c语言之排序4统计工龄.zip
- pta题库答案c语言之树结构7堆中的路径.zip
- pta题库答案c语言之树结构3TreeTraversalsAgain.zip
- pta题库答案c语言之树结构2ListLeaves.zip
- pta题库答案c语言之树结构1树的同构.zip
- 基于C++实现民航飞行与地图简易管理系统可执行程序+说明+详细注释.zip
- pta题库答案c语言之复杂度1最大子列和问题.zip
- 三维装箱问题(Three-Dimensional Bin Packing Problem,3D-BPP)是一个经典的组合优化问题
- 以下是一些关于Linux线程同步的基本概念和方法.txt
- 以下是一个简化的示例,它使用pygame库来模拟烟花动画的框架.txt
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功