增加跳转函数
This commit is contained in:
parent
b24ca3de02
commit
4c1449a23f
@ -2,7 +2,8 @@
|
|||||||
declare(strict_types = 1);
|
declare(strict_types = 1);
|
||||||
|
|
||||||
namespace app\admin;
|
namespace app\admin;
|
||||||
|
use think\exception\HttpResponseException;
|
||||||
|
use think\facade\Request;
|
||||||
use think\App;
|
use think\App;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -53,4 +54,115 @@ abstract class BaseController
|
|||||||
{
|
{
|
||||||
$this->param = $this->request->param();
|
$this->param = $this->request->param();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// 以下为新增,为了使用旧版的 success error redirect 跳转 start
|
||||||
|
//
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 操作成功跳转的快捷方法
|
||||||
|
* @access protected
|
||||||
|
* @param mixed $msg 提示信息
|
||||||
|
* @param string $url 跳转的URL地址
|
||||||
|
* @param mixed $data 返回的数据
|
||||||
|
* @param integer $wait 跳转等待时间
|
||||||
|
* @param array $header 发送的Header信息
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
protected function success($msg = '', string $url = null, $data = '', int $wait = 3, array $header = [])
|
||||||
|
{
|
||||||
|
if (is_null($url) && isset($_SERVER["HTTP_REFERER"])) {
|
||||||
|
$url = $_SERVER["HTTP_REFERER"];
|
||||||
|
} elseif ($url) {
|
||||||
|
$url = (strpos($url, '://') || 0 === strpos($url, '/')) ? $url : app('route')->buildUrl($url);
|
||||||
|
}
|
||||||
|
|
||||||
|
$result = [
|
||||||
|
'code' => 1,
|
||||||
|
'msg' => $msg,
|
||||||
|
'data' => $data,
|
||||||
|
'url' => $url,
|
||||||
|
'wait' => $wait,
|
||||||
|
];
|
||||||
|
|
||||||
|
$type = $this->getResponseType();
|
||||||
|
if ($type == 'html'){
|
||||||
|
$response = view($this->app->config->get('app.dispatch_success_tmpl'), $result);
|
||||||
|
} else if ($type == 'json') {
|
||||||
|
$response = json($result);
|
||||||
|
}
|
||||||
|
throw new HttpResponseException($response);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 操作错误跳转的快捷方法
|
||||||
|
* @access protected
|
||||||
|
* @param mixed $msg 提示信息
|
||||||
|
* @param string $url 跳转的URL地址
|
||||||
|
* @param mixed $data 返回的数据
|
||||||
|
* @param integer $wait 跳转等待时间
|
||||||
|
* @param array $header 发送的Header信息
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
protected function error($msg = '', string $url = null, $data = '', int $wait = 3, array $header = [])
|
||||||
|
{
|
||||||
|
if (is_null($url)) {
|
||||||
|
$url = $this->request->isAjax() ? '' : 'javascript:history.back(-1);';
|
||||||
|
} elseif ($url) {
|
||||||
|
$url = (strpos($url, '://') || 0 === strpos($url, '/')) ? $url : $this->app->route->buildUrl($url);
|
||||||
|
}
|
||||||
|
|
||||||
|
$result = [
|
||||||
|
'code' => 0,
|
||||||
|
'msg' => $msg,
|
||||||
|
'data' => $data,
|
||||||
|
'url' => $url,
|
||||||
|
'wait' => $wait,
|
||||||
|
];
|
||||||
|
|
||||||
|
$type = $this->getResponseType();
|
||||||
|
if ($type == 'html'){
|
||||||
|
$response = view($this->app->config->get('app.dispatch_error_tmpl'), $result);
|
||||||
|
} else if ($type == 'json') {
|
||||||
|
$response = json($result);
|
||||||
|
}
|
||||||
|
throw new HttpResponseException($response);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* URL重定向 自带重定向无效
|
||||||
|
* @access protected
|
||||||
|
* @param string $url 跳转的URL表达式
|
||||||
|
* @param array|integer $params 其它URL参数
|
||||||
|
* @param integer $code http code
|
||||||
|
* @param array $with 隐式传参
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
protected function redirect($url, $params = [], $code = 302, $with = [])
|
||||||
|
{
|
||||||
|
$response = Response::create($url, 'redirect');
|
||||||
|
|
||||||
|
if (is_integer($params)) {
|
||||||
|
$code = $params;
|
||||||
|
$params = [];
|
||||||
|
}
|
||||||
|
|
||||||
|
$response->code($code)->params($params)->with($with);
|
||||||
|
|
||||||
|
throw new HttpResponseException($response);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取当前的response 输出类型
|
||||||
|
* @access protected
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
protected function getResponseType()
|
||||||
|
{
|
||||||
|
return $this->request->isJson() || $this->request->isAjax() ? 'json' : 'html';
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// 以上为新增,为了使用旧版的 success error redirect 跳转 end
|
||||||
|
//
|
||||||
}
|
}
|
||||||
|
@ -125,7 +125,7 @@ class Database extends BaseController
|
|||||||
# 将反斜杠 替换成正斜杠
|
# 将反斜杠 替换成正斜杠
|
||||||
$file_path = str_replace('\\','/',$file_path);
|
$file_path = str_replace('\\','/',$file_path);
|
||||||
if(!file_exists($file_path)){
|
if(!file_exists($file_path)){
|
||||||
echo "下载文件不存在!";exit; //如果提示这个错误,很可能你的路径不对,可以打印$file_sub_path查看
|
$this->error('下载文件不存在!');exit; //如果提示这个错误,很可能你的路径不对,可以打印$file_sub_path查看
|
||||||
}
|
}
|
||||||
$fp = fopen($file_path,"r"); // 以可读的方式打开这个文件
|
$fp = fopen($file_path,"r"); // 以可读的方式打开这个文件
|
||||||
# 如果出现图片无法打开,可以在这个位置添加函数
|
# 如果出现图片无法打开,可以在这个位置添加函数
|
||||||
|
@ -243,3 +243,22 @@ function get_file($id)
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 判断是否是手机浏览器
|
||||||
|
*/
|
||||||
|
function isMobile()
|
||||||
|
{
|
||||||
|
if (isset($_SERVER['HTTP_VIA']) && stristr($_SERVER['HTTP_VIA'], "wap")) {
|
||||||
|
return true;
|
||||||
|
} elseif (isset($_SERVER['HTTP_ACCEPT']) && strpos(strtoupper($_SERVER['HTTP_ACCEPT']), "VND.WAP.WML")) {
|
||||||
|
return true;
|
||||||
|
} elseif (isset($_SERVER['HTTP_X_WAP_PROFILE']) || isset($_SERVER['HTTP_PROFILE'])) {
|
||||||
|
return true;
|
||||||
|
} elseif (isset($_SERVER['HTTP_USER_AGENT']) && preg_match('/(blackberry|configuration\/cldc|hp |hp-|htc |htc_|htc-|iemobile|kindle|midp|mmp|motorola|mobile|nokia|opera mini|opera |Googlebot-Mobile|YahooSeeker\/M1A1-R2D2|android|iphone|ipod|mobi|palm|palmos|pocket|portalmmm|ppc;|smartphone|sonyericsson|sqh|spv|symbian|treo|up.browser|up.link|vodafone|windows ce|xda |xda_)/i', $_SERVER['HTTP_USER_AGENT'])) {
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -35,4 +35,8 @@ return [
|
|||||||
'session_user' => 'gougu_user',
|
'session_user' => 'gougu_user',
|
||||||
|
|
||||||
'session_admin' => 'gougu_admin',
|
'session_admin' => 'gougu_admin',
|
||||||
|
|
||||||
|
// 默认跳转页面对应的模板文件【新增】
|
||||||
|
'dispatch_success_tmpl' => app()->getRootPath() . '/public/tpl/dispatch_jump.tpl',
|
||||||
|
'dispatch_error_tmpl' => app()->getRootPath() . '/public/tpl/dispatch_jump.tpl',
|
||||||
];
|
];
|
||||||
|
10
public/tpl/default_index.tpl
Normal file
10
public/tpl/default_index.tpl
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
<?php
|
||||||
|
namespace {$app}\{$module}{layer};
|
||||||
|
|
||||||
|
class Index{$suffix}
|
||||||
|
{
|
||||||
|
public function index()
|
||||||
|
{
|
||||||
|
return '<style type="text/css">*{ padding: 0; margin: 0; } div{ padding: 4px 48px;} a{color:#2E5CD5;cursor: pointer;text-decoration: none} a:hover{text-decoration:underline; } body{ background: #fff; font-family: "Century Gothic","Microsoft yahei"; color: #333;font-size:18px;} h1{ font-size: 100px; font-weight: normal; margin-bottom: 12px; } p{ line-height: 1.6em; font-size: 42px }</style><div style="padding: 24px 48px;"> <h1>:)</h1><p> ThinkPHP V5<br/><span style="font-size:30px">十年磨一剑 - 为API开发设计的高性能框架</span></p><span style="font-size:22px;">[ V5.0 版本由 <a href="http://www.qiniu.com" target="qiniu">七牛云</a> 独家赞助发布 ]</span></div><script type="text/javascript" src="http://tajs.qq.com/stats?sId=9347272" charset="UTF-8"></script><script type="text/javascript" src="http://ad.topthink.com/Public/static/client.js"></script><thinkad id="ad_bd568ce7058a1091"></thinkad>';
|
||||||
|
}
|
||||||
|
}
|
69
public/tpl/dispatch_jump.tpl
Normal file
69
public/tpl/dispatch_jump.tpl
Normal file
@ -0,0 +1,69 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||||
|
<meta name="renderer" content="webkit"/>
|
||||||
|
<meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
|
||||||
|
<title>跳转提示</title>
|
||||||
|
<?php if(isMobile()==true){?>
|
||||||
|
<style type="text/css">
|
||||||
|
body, h1, h2, p,dl,dd,dt{margin: 0;padding: 0;font: 15px/1.5 微软雅黑,tahoma,arial;}
|
||||||
|
body{background:#efefef;}
|
||||||
|
h1, h2, h3, h4, h5, h6 {font-size: 100%;cursor:default;}
|
||||||
|
ul, ol {list-style: none outside none;}
|
||||||
|
a {text-decoration: none;color:#447BC4}
|
||||||
|
a:hover {text-decoration: underline;}
|
||||||
|
.ip-attack{width:100%; margin:200px auto 0;}
|
||||||
|
.ip-attack dl{ background:#fff; padding:30px; border-radius:8px;border: 1px solid #ddd;-webkit-box-shadow: 0 0 8px #ddd;-moz-box-shadow: 0 0 8px #ddd;box-shadow: 0 0 8px #ddd;}
|
||||||
|
.ip-attack dt{text-align:center;}
|
||||||
|
.ip-attack dd{font-size:16px; color:#333; text-align:center;}
|
||||||
|
.tips{text-align:center; font-size:14px; line-height:50px; color:#999;}
|
||||||
|
</style>
|
||||||
|
<?php }else{ ?>
|
||||||
|
<style type="text/css">
|
||||||
|
body, h1, h2, p,dl,dd,dt{margin: 0;padding: 0;font: 15px/1.5 微软雅黑,tahoma,arial;}
|
||||||
|
body{background:#efefef;}
|
||||||
|
h1, h2, h3, h4, h5, h6 {font-size: 100%;cursor:default;}
|
||||||
|
ul, ol {list-style: none outside none;}
|
||||||
|
a {text-decoration: none;color:#447BC4}
|
||||||
|
a:hover {text-decoration: underline;}
|
||||||
|
.ip-attack{width:600px; margin:200px auto 0;}
|
||||||
|
.ip-attack dl{ background:#fff; padding:30px; border-radius:8px;border: 1px solid #ddd;-webkit-box-shadow: 0 0 8px #ddd;-moz-box-shadow: 0 0 8px #ddd;box-shadow: 0 0 8px #ddd;}
|
||||||
|
.ip-attack dt{text-align:center;}
|
||||||
|
.ip-attack dd{font-size:16px; color:#333; text-align:center;}
|
||||||
|
.tips{text-align:center; font-size:14px; line-height:50px; color:#999;}
|
||||||
|
</style>
|
||||||
|
<?php }?>
|
||||||
|
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div class="ip-attack"><dl>
|
||||||
|
<?php switch ($code) {?>
|
||||||
|
<?php case 1:?>
|
||||||
|
<dt style="color: green"><?php echo(strip_tags($msg));?></dt>
|
||||||
|
<?php break;?>
|
||||||
|
<?php case 0:?>
|
||||||
|
<dt style="color: red"><?php echo(strip_tags($msg));?></dt>
|
||||||
|
<?php break;?>
|
||||||
|
<?php } ?>
|
||||||
|
<br>
|
||||||
|
<dt>
|
||||||
|
页面自动 <a id="href" href="<?php echo($url);?>">跳转</a>,等待时间: <b id="wait"><?php echo($wait);?></b>
|
||||||
|
</dt></dl>
|
||||||
|
</div>
|
||||||
|
<script type="text/javascript">
|
||||||
|
(function(){
|
||||||
|
var wait = document.getElementById('wait'),
|
||||||
|
href = document.getElementById('href').href;
|
||||||
|
var interval = setInterval(function(){
|
||||||
|
var time = --wait.innerHTML;
|
||||||
|
if(time <= 0) {
|
||||||
|
location.href = href;
|
||||||
|
clearInterval(interval);
|
||||||
|
};
|
||||||
|
}, 1000);
|
||||||
|
})();
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
71
public/tpl/page_trace.tpl
Normal file
71
public/tpl/page_trace.tpl
Normal file
File diff suppressed because one or more lines are too long
537
public/tpl/think_exception.tpl
Normal file
537
public/tpl/think_exception.tpl
Normal file
@ -0,0 +1,537 @@
|
|||||||
|
<?php
|
||||||
|
if(!function_exists('parse_padding')){
|
||||||
|
function parse_padding($source)
|
||||||
|
{
|
||||||
|
$length = strlen(strval(count($source['source']) + $source['first']));
|
||||||
|
return 40 + ($length - 1) * 8;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!function_exists('parse_class')){
|
||||||
|
function parse_class($name)
|
||||||
|
{
|
||||||
|
$names = explode('\\', $name);
|
||||||
|
return '<abbr title="'.$name.'">'.end($names).'</abbr>';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!function_exists('parse_file')){
|
||||||
|
function parse_file($file, $line)
|
||||||
|
{
|
||||||
|
return '<a class="toggle" title="'."{$file} line {$line}".'">'.basename($file)." line {$line}".'</a>';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!function_exists('parse_args')){
|
||||||
|
function parse_args($args)
|
||||||
|
{
|
||||||
|
$result = [];
|
||||||
|
|
||||||
|
foreach ($args as $key => $item) {
|
||||||
|
switch (true) {
|
||||||
|
case is_object($item):
|
||||||
|
$value = sprintf('<em>object</em>(%s)', parse_class(get_class($item)));
|
||||||
|
break;
|
||||||
|
case is_array($item):
|
||||||
|
if(count($item) > 3){
|
||||||
|
$value = sprintf('[%s, ...]', parse_args(array_slice($item, 0, 3)));
|
||||||
|
} else {
|
||||||
|
$value = sprintf('[%s]', parse_args($item));
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case is_string($item):
|
||||||
|
if(strlen($item) > 20){
|
||||||
|
$value = sprintf(
|
||||||
|
'\'<a class="toggle" title="%s">%s...</a>\'',
|
||||||
|
htmlentities($item),
|
||||||
|
htmlentities(substr($item, 0, 20))
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
$value = sprintf("'%s'", htmlentities($item));
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case is_int($item):
|
||||||
|
case is_float($item):
|
||||||
|
$value = $item;
|
||||||
|
break;
|
||||||
|
case is_null($item):
|
||||||
|
$value = '<em>null</em>';
|
||||||
|
break;
|
||||||
|
case is_bool($item):
|
||||||
|
$value = '<em>' . ($item ? 'true' : 'false') . '</em>';
|
||||||
|
break;
|
||||||
|
case is_resource($item):
|
||||||
|
$value = '<em>resource</em>';
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
$value = htmlentities(str_replace("\n", '', var_export(strval($item), true)));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
$result[] = is_int($key) ? $value : "'{$key}' => {$value}";
|
||||||
|
}
|
||||||
|
|
||||||
|
return implode(', ', $result);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<title><?php echo \think\Lang::get('System Error'); ?></title>
|
||||||
|
<meta name="robots" content="noindex,nofollow" />
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
|
||||||
|
<style>
|
||||||
|
/* Base */
|
||||||
|
body {
|
||||||
|
color: #333;
|
||||||
|
font: 14px Verdana, "Helvetica Neue", helvetica, Arial, 'Microsoft YaHei', sans-serif;
|
||||||
|
margin: 0;
|
||||||
|
padding: 0 20px 20px;
|
||||||
|
word-break: break-word;
|
||||||
|
}
|
||||||
|
h1{
|
||||||
|
margin: 10px 0 0;
|
||||||
|
font-size: 28px;
|
||||||
|
font-weight: 500;
|
||||||
|
line-height: 32px;
|
||||||
|
}
|
||||||
|
h2{
|
||||||
|
color: #4288ce;
|
||||||
|
font-weight: 400;
|
||||||
|
padding: 6px 0;
|
||||||
|
margin: 6px 0 0;
|
||||||
|
font-size: 18px;
|
||||||
|
border-bottom: 1px solid #eee;
|
||||||
|
}
|
||||||
|
h3.subheading {
|
||||||
|
color: #4288ce;
|
||||||
|
margin: 6px 0 0;
|
||||||
|
font-weight: 400;
|
||||||
|
}
|
||||||
|
h3{
|
||||||
|
margin: 12px;
|
||||||
|
font-size: 16px;
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
abbr{
|
||||||
|
cursor: help;
|
||||||
|
text-decoration: underline;
|
||||||
|
text-decoration-style: dotted;
|
||||||
|
}
|
||||||
|
a{
|
||||||
|
color: #868686;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
a:hover{
|
||||||
|
text-decoration: underline;
|
||||||
|
}
|
||||||
|
.line-error{
|
||||||
|
background: #f8cbcb;
|
||||||
|
}
|
||||||
|
|
||||||
|
.echo table {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.echo pre {
|
||||||
|
padding: 16px;
|
||||||
|
overflow: auto;
|
||||||
|
font-size: 85%;
|
||||||
|
line-height: 1.45;
|
||||||
|
background-color: #f7f7f7;
|
||||||
|
border: 0;
|
||||||
|
border-radius: 3px;
|
||||||
|
font-family: Consolas, "Liberation Mono", Menlo, Courier, monospace;
|
||||||
|
}
|
||||||
|
|
||||||
|
.echo pre > pre {
|
||||||
|
padding: 0;
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
/* Layout */
|
||||||
|
.col-md-3 {
|
||||||
|
width: 25%;
|
||||||
|
}
|
||||||
|
.col-md-9 {
|
||||||
|
width: 75%;
|
||||||
|
}
|
||||||
|
[class^="col-md-"] {
|
||||||
|
float: left;
|
||||||
|
}
|
||||||
|
.clearfix {
|
||||||
|
clear:both;
|
||||||
|
}
|
||||||
|
@media only screen
|
||||||
|
and (min-device-width : 375px)
|
||||||
|
and (max-device-width : 667px) {
|
||||||
|
.col-md-3,
|
||||||
|
.col-md-9 {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/* Exception Info */
|
||||||
|
.exception {
|
||||||
|
margin-top: 20px;
|
||||||
|
}
|
||||||
|
.exception .message{
|
||||||
|
padding: 12px;
|
||||||
|
border: 1px solid #ddd;
|
||||||
|
border-bottom: 0 none;
|
||||||
|
line-height: 18px;
|
||||||
|
font-size:16px;
|
||||||
|
border-top-left-radius: 4px;
|
||||||
|
border-top-right-radius: 4px;
|
||||||
|
font-family: Consolas,"Liberation Mono",Courier,Verdana,"微软雅黑";
|
||||||
|
}
|
||||||
|
|
||||||
|
.exception .code{
|
||||||
|
float: left;
|
||||||
|
text-align: center;
|
||||||
|
color: #fff;
|
||||||
|
margin-right: 12px;
|
||||||
|
padding: 16px;
|
||||||
|
border-radius: 4px;
|
||||||
|
background: #999;
|
||||||
|
}
|
||||||
|
.exception .source-code{
|
||||||
|
padding: 6px;
|
||||||
|
border: 1px solid #ddd;
|
||||||
|
|
||||||
|
background: #f9f9f9;
|
||||||
|
overflow-x: auto;
|
||||||
|
|
||||||
|
}
|
||||||
|
.exception .source-code pre{
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
.exception .source-code pre ol{
|
||||||
|
margin: 0;
|
||||||
|
color: #4288ce;
|
||||||
|
display: inline-block;
|
||||||
|
min-width: 100%;
|
||||||
|
box-sizing: border-box;
|
||||||
|
font-size:14px;
|
||||||
|
font-family: "Century Gothic",Consolas,"Liberation Mono",Courier,Verdana;
|
||||||
|
padding-left: <?php echo (isset($source) && !empty($source)) ? parse_padding($source) : 40; ?>px;
|
||||||
|
}
|
||||||
|
.exception .source-code pre li{
|
||||||
|
border-left: 1px solid #ddd;
|
||||||
|
height: 18px;
|
||||||
|
line-height: 18px;
|
||||||
|
}
|
||||||
|
.exception .source-code pre code{
|
||||||
|
color: #333;
|
||||||
|
height: 100%;
|
||||||
|
display: inline-block;
|
||||||
|
border-left: 1px solid #fff;
|
||||||
|
font-size:14px;
|
||||||
|
font-family: Consolas,"Liberation Mono",Courier,Verdana,"微软雅黑";
|
||||||
|
}
|
||||||
|
.exception .trace{
|
||||||
|
padding: 6px;
|
||||||
|
border: 1px solid #ddd;
|
||||||
|
border-top: 0 none;
|
||||||
|
line-height: 16px;
|
||||||
|
font-size:14px;
|
||||||
|
font-family: Consolas,"Liberation Mono",Courier,Verdana,"微软雅黑";
|
||||||
|
}
|
||||||
|
.exception .trace ol{
|
||||||
|
margin: 12px;
|
||||||
|
}
|
||||||
|
.exception .trace ol li{
|
||||||
|
padding: 2px 4px;
|
||||||
|
}
|
||||||
|
.exception div:last-child{
|
||||||
|
border-bottom-left-radius: 4px;
|
||||||
|
border-bottom-right-radius: 4px;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Exception Variables */
|
||||||
|
.exception-var table{
|
||||||
|
width: 100%;
|
||||||
|
margin: 12px 0;
|
||||||
|
box-sizing: border-box;
|
||||||
|
table-layout:fixed;
|
||||||
|
word-wrap:break-word;
|
||||||
|
}
|
||||||
|
.exception-var table caption{
|
||||||
|
text-align: left;
|
||||||
|
font-size: 16px;
|
||||||
|
font-weight: bold;
|
||||||
|
padding: 6px 0;
|
||||||
|
}
|
||||||
|
.exception-var table caption small{
|
||||||
|
font-weight: 300;
|
||||||
|
display: inline-block;
|
||||||
|
margin-left: 10px;
|
||||||
|
color: #ccc;
|
||||||
|
}
|
||||||
|
.exception-var table tbody{
|
||||||
|
font-size: 13px;
|
||||||
|
font-family: Consolas,"Liberation Mono",Courier,"微软雅黑";
|
||||||
|
}
|
||||||
|
.exception-var table td{
|
||||||
|
padding: 0 6px;
|
||||||
|
vertical-align: top;
|
||||||
|
word-break: break-all;
|
||||||
|
}
|
||||||
|
.exception-var table td:first-child{
|
||||||
|
width: 28%;
|
||||||
|
font-weight: bold;
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
.exception-var table td pre{
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Copyright Info */
|
||||||
|
.copyright{
|
||||||
|
margin-top: 24px;
|
||||||
|
padding: 12px 0;
|
||||||
|
border-top: 1px solid #eee;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* SPAN elements with the classes below are added by prettyprint. */
|
||||||
|
pre.prettyprint .pln { color: #000 } /* plain text */
|
||||||
|
pre.prettyprint .str { color: #080 } /* string content */
|
||||||
|
pre.prettyprint .kwd { color: #008 } /* a keyword */
|
||||||
|
pre.prettyprint .com { color: #800 } /* a comment */
|
||||||
|
pre.prettyprint .typ { color: #606 } /* a type name */
|
||||||
|
pre.prettyprint .lit { color: #066 } /* a literal value */
|
||||||
|
/* punctuation, lisp open bracket, lisp close bracket */
|
||||||
|
pre.prettyprint .pun, pre.prettyprint .opn, pre.prettyprint .clo { color: #660 }
|
||||||
|
pre.prettyprint .tag { color: #008 } /* a markup tag name */
|
||||||
|
pre.prettyprint .atn { color: #606 } /* a markup attribute name */
|
||||||
|
pre.prettyprint .atv { color: #080 } /* a markup attribute value */
|
||||||
|
pre.prettyprint .dec, pre.prettyprint .var { color: #606 } /* a declaration; a variable name */
|
||||||
|
pre.prettyprint .fun { color: red } /* a function name */
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div class="echo">
|
||||||
|
<?php echo $echo;?>
|
||||||
|
</div>
|
||||||
|
<?php if(\think\App::$debug) { ?>
|
||||||
|
<div class="exception">
|
||||||
|
<div class="message">
|
||||||
|
|
||||||
|
<div class="info">
|
||||||
|
<div>
|
||||||
|
<h2>[<?php echo $code; ?>] <?php echo sprintf('%s in %s', parse_class($name), parse_file($file, $line)); ?></h2>
|
||||||
|
</div>
|
||||||
|
<div><h1><?php echo nl2br(htmlentities($message)); ?></h1></div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<?php if(!empty($source)){?>
|
||||||
|
<div class="source-code">
|
||||||
|
<pre class="prettyprint lang-php"><ol start="<?php echo $source['first']; ?>"><?php foreach ((array) $source['source'] as $key => $value) { ?><li class="line-<?php echo $key + $source['first']; ?>"><code><?php echo htmlentities($value); ?></code></li><?php } ?></ol></pre>
|
||||||
|
</div>
|
||||||
|
<?php }?>
|
||||||
|
<div class="trace">
|
||||||
|
<h2>Call Stack</h2>
|
||||||
|
<ol>
|
||||||
|
<li><?php echo sprintf('in %s', parse_file($file, $line)); ?></li>
|
||||||
|
<?php foreach ((array) $trace as $value) { ?>
|
||||||
|
<li>
|
||||||
|
<?php
|
||||||
|
// Show Function
|
||||||
|
if($value['function']){
|
||||||
|
echo sprintf(
|
||||||
|
'at %s%s%s(%s)',
|
||||||
|
isset($value['class']) ? parse_class($value['class']) : '',
|
||||||
|
isset($value['type']) ? $value['type'] : '',
|
||||||
|
$value['function'],
|
||||||
|
isset($value['args'])?parse_args($value['args']):''
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Show line
|
||||||
|
if (isset($value['file']) && isset($value['line'])) {
|
||||||
|
echo sprintf(' in %s', parse_file($value['file'], $value['line']));
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
</li>
|
||||||
|
<?php } ?>
|
||||||
|
</ol>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<?php } else { ?>
|
||||||
|
<div class="exception">
|
||||||
|
|
||||||
|
<div class="info"><h1><?php echo htmlentities($message); ?></h1></div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<?php } ?>
|
||||||
|
|
||||||
|
<?php if(!empty($datas)){ ?>
|
||||||
|
<div class="exception-var">
|
||||||
|
<h2>Exception Datas</h2>
|
||||||
|
<?php foreach ((array) $datas as $label => $value) { ?>
|
||||||
|
<table>
|
||||||
|
<?php if(empty($value)){ ?>
|
||||||
|
<caption><?php echo $label; ?><small>empty</small></caption>
|
||||||
|
<?php } else { ?>
|
||||||
|
<caption><?php echo $label; ?></caption>
|
||||||
|
<tbody>
|
||||||
|
<?php foreach ((array) $value as $key => $val) { ?>
|
||||||
|
<tr>
|
||||||
|
<td><?php echo htmlentities($key); ?></td>
|
||||||
|
<td>
|
||||||
|
<?php
|
||||||
|
if(is_array($val) || is_object($val)){
|
||||||
|
echo htmlentities(json_encode($val, JSON_PRETTY_PRINT));
|
||||||
|
} else if(is_bool($val)) {
|
||||||
|
echo $val ? 'true' : 'false';
|
||||||
|
} else if(is_scalar($val)) {
|
||||||
|
echo htmlentities($val);
|
||||||
|
} else {
|
||||||
|
echo 'Resource';
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<?php } ?>
|
||||||
|
</tbody>
|
||||||
|
<?php } ?>
|
||||||
|
</table>
|
||||||
|
<?php } ?>
|
||||||
|
</div>
|
||||||
|
<?php } ?>
|
||||||
|
|
||||||
|
<?php if(!empty($tables)){ ?>
|
||||||
|
<div class="exception-var">
|
||||||
|
<h2>Environment Variables</h2>
|
||||||
|
<?php foreach ((array) $tables as $label => $value) { ?>
|
||||||
|
<div>
|
||||||
|
<?php if(empty($value)){ ?>
|
||||||
|
<div class="clearfix">
|
||||||
|
<div class="col-md-3"><strong><?php echo $label; ?></strong></div>
|
||||||
|
<div class="col-md-9"><small>empty</small></div>
|
||||||
|
</div>
|
||||||
|
<?php } else { ?>
|
||||||
|
<h3 class="subheading"><?php echo $label; ?></h3>
|
||||||
|
<div>
|
||||||
|
<?php foreach ((array) $value as $key => $val) { ?>
|
||||||
|
<div class="clearfix">
|
||||||
|
<div class="col-md-3"><strong><?php echo htmlentities($key); ?></strong></div>
|
||||||
|
<div class="col-md-9"><small>
|
||||||
|
<?php
|
||||||
|
if(is_array($val) || is_object($val)){
|
||||||
|
echo htmlentities(json_encode($val, JSON_PRETTY_PRINT));
|
||||||
|
} else if(is_bool($val)) {
|
||||||
|
echo $val ? 'true' : 'false';
|
||||||
|
} else if(is_scalar($val)) {
|
||||||
|
echo htmlentities($val);
|
||||||
|
} else {
|
||||||
|
echo 'Resource';
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
</small></div>
|
||||||
|
</div>
|
||||||
|
<?php } ?>
|
||||||
|
</div>
|
||||||
|
<?php } ?>
|
||||||
|
</div>
|
||||||
|
<?php } ?>
|
||||||
|
</div>
|
||||||
|
<?php } ?>
|
||||||
|
|
||||||
|
<div class="copyright">
|
||||||
|
<a title="官方网站" href="http://www.thinkphp.cn">ThinkPHP</a>
|
||||||
|
<span>V<?php echo THINK_VERSION; ?></span>
|
||||||
|
<span>{ 十年磨一剑-为API开发设计的高性能框架 }</span>
|
||||||
|
</div>
|
||||||
|
<?php if(\think\App::$debug) { ?>
|
||||||
|
<script>
|
||||||
|
var LINE = <?php echo $line; ?>;
|
||||||
|
|
||||||
|
function $(selector, node){
|
||||||
|
var elements;
|
||||||
|
|
||||||
|
node = node || document;
|
||||||
|
if(document.querySelectorAll){
|
||||||
|
elements = node.querySelectorAll(selector);
|
||||||
|
} else {
|
||||||
|
switch(selector.substr(0, 1)){
|
||||||
|
case '#':
|
||||||
|
elements = [node.getElementById(selector.substr(1))];
|
||||||
|
break;
|
||||||
|
case '.':
|
||||||
|
if(document.getElementsByClassName){
|
||||||
|
elements = node.getElementsByClassName(selector.substr(1));
|
||||||
|
} else {
|
||||||
|
elements = get_elements_by_class(selector.substr(1), node);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
elements = node.getElementsByTagName();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return elements;
|
||||||
|
|
||||||
|
function get_elements_by_class(search_class, node, tag) {
|
||||||
|
var elements = [], eles,
|
||||||
|
pattern = new RegExp('(^|\\s)' + search_class + '(\\s|$)');
|
||||||
|
|
||||||
|
node = node || document;
|
||||||
|
tag = tag || '*';
|
||||||
|
|
||||||
|
eles = node.getElementsByTagName(tag);
|
||||||
|
for(var i = 0; i < eles.length; i++) {
|
||||||
|
if(pattern.test(eles[i].className)) {
|
||||||
|
elements.push(eles[i])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return elements;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$.getScript = function(src, func){
|
||||||
|
var script = document.createElement('script');
|
||||||
|
|
||||||
|
script.async = 'async';
|
||||||
|
script.src = src;
|
||||||
|
script.onload = func || function(){};
|
||||||
|
|
||||||
|
$('head')[0].appendChild(script);
|
||||||
|
}
|
||||||
|
|
||||||
|
;(function(){
|
||||||
|
var files = $('.toggle');
|
||||||
|
var ol = $('ol', $('.prettyprint')[0]);
|
||||||
|
var li = $('li', ol[0]);
|
||||||
|
|
||||||
|
// 短路径和长路径变换
|
||||||
|
for(var i = 0; i < files.length; i++){
|
||||||
|
files[i].ondblclick = function(){
|
||||||
|
var title = this.title;
|
||||||
|
|
||||||
|
this.title = this.innerHTML;
|
||||||
|
this.innerHTML = title;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 设置出错行
|
||||||
|
var err_line = $('.line-' + LINE, ol[0])[0];
|
||||||
|
err_line.className = err_line.className + ' line-error';
|
||||||
|
|
||||||
|
$.getScript('//cdn.bootcss.com/prettify/r298/prettify.min.js', function(){
|
||||||
|
prettyPrint();
|
||||||
|
|
||||||
|
// 解决Firefox浏览器一个很诡异的问题
|
||||||
|
// 当代码高亮后,ol的行号莫名其妙的错位
|
||||||
|
// 但是只要刷新li里面的html重新渲染就没有问题了
|
||||||
|
if(window.navigator.userAgent.indexOf('Firefox') >= 0){
|
||||||
|
ol[0].innerHTML = ol[0].innerHTML;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
})();
|
||||||
|
</script>
|
||||||
|
<?php } ?>
|
||||||
|
</body>
|
||||||
|
</html>
|
Loading…
x
Reference in New Issue
Block a user