<?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 = $plugins->run_hooks("pre_parse_page", $contents);
$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->write_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-transitional.dtd\">\n".$contents;
}
$contents = str_replace("<html", "<html xmlns=\"http://www.w3.org/1999/xhtml\"", $contents);
if($lang->settings['rtl'] == 1)
{
$contents = str_replace("<html", "<html dir=\"rtl\"", $co
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
基于PHP的MyBB开源php论坛系统源码.zip (762个子文件)
main.css 22KB
select2.css 19KB
jquery-ui.min.css 16KB
jquery-ui.theme.min.css 14KB
office.css 13KB
office-toolbar.css 13KB
mybb.css 12KB
square.css 10KB
modern.css 10KB
default.css 9KB
defaultdark.css 9KB
codemirror.css 8KB
stylesheet.css 6KB
stylesheet.css 4KB
login.css 3KB
jquery.sceditor.square.css 2KB
jquery.sceditor.office.css 2KB
jquery.sceditor.mybb.css 2KB
jquery.sceditor.office-toolbar.css 2KB
jquery.sceditor.default.css 2KB
jquery.sceditor.modern.css 2KB
screen.css 2KB
print.css 2KB
mybb.css 2KB
modal.css 1KB
config.css 1KB
forum.css 1KB
default.min.css 1017B
user.css 877B
style.css 557B
dialog-mybb.css 509B
dialog.css 507B
popup.css 468B
home.css 447B
foldgutter.css 435B
jquery-ui.structure.min.css 251B
matchesonscrollbar.css 188B
spinner_big.gif 7KB
spinner_big.gif 6KB
select2-spinner.gif 2KB
spinner.gif 2KB
spinner.gif 2KB
.htaccess 136B
license.html 42KB
read_me.html 11KB
install.html 5KB
less.html 4KB
upgrade.html 3KB
gss.html 3KB
scss.html 3KB
index.html 3KB
json-ld.html 2KB
credits.html 2KB
typescript.html 2KB
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
index.html 67B
index.html 67B
index.html 67B
index.html 67B
index.html 67B
index.html 67B
index.html 67B
index.html 67B
共 762 条
- 1
- 2
- 3
- 4
- 5
- 6
- 8
资源评论
毕业_设计
- 粉丝: 1979
- 资源: 1万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功