开源 企业版 高校版 私有云 模力方舟 AI 队友
代码拉取完成,页面将自动刷新
forked from mz/mzphp2
加入 Gitee
与超过 1400万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
已有帐号? 立即登录
文件
master
分支 (1)
master
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
项目仓库所选许可证以仓库主分支所使用许可证为准
master
分支 (1)
master
克隆/下载
克隆/下载
提示
下载代码请复制以下命令到终端执行
为确保你提交的代码身份被 Gitee 正确识别,请执行以下命令完成配置
初次使用 SSH 协议进行代码克隆、推送等操作时,需按下述提示完成 SSH 配置
1 生成 RSA 密钥
2 获取 RSA 公钥内容,并配置到 SSH公钥
在 Gitee 上使用 SVN,请访问 使用指南
使用 HTTPS 协议时,命令行会出现如下账号密码验证步骤。基于安全考虑,Gitee 建议 配置并使用私人令牌 替代登录密码进行克隆、推送等操作
Username for 'https://gitee.com': userName
Password for 'https://userName@gitee.com': # 私人令牌
master
分支 (1)
master
mzphp2
/
mzphp
/
debug
/
debug.class.php
mzphp2
/
mzphp
/
debug
/
debug.class.php
debug.class.php 9.74 KB
一键复制 编辑 原始数据 按行查看 历史
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290
<?php
// debug class
class debug {
public static function init() {
error_reporting(E_ALL ^ E_DEPRECATED);
function_exists('ini_set') && ini_set('error_reporting', E_ALL) && ini_set('display_errors', 'ON');
register_shutdown_function(array('debug', 'shutdown_handler')); // 程序关闭时执行
set_error_handler(array('debug', 'error_handler')); // 设置错误处理方法
set_exception_handler(array('debug', 'exception_handler')); // 设置异常处理方法
}
/**
* 程序关闭时执行
*/
public static function shutdown_handler() {
if (empty($_SERVER['_exception'])) {
if ($e = error_get_last()) {
core::ob_clean();
$message = $e['message'];
$file = $e['file'];
$line = $e['line'];
if (core::R('ajax')) {
if (!DEBUG) {
$len = strlen($_SERVER['DOCUMENT_ROOT']);
$file = substr($file, $len);
}
$mz_error = "[error] : $message File: $file [$line]";
echo json_encode(array('mz_error' => $mz_error));
} else {
self::sys_error('[error] : ' . $message, $file, $line);
}
}
}
}
/**
* 输出系统错误
*
* @param string $message 错误消息
* @param string $file 错误文件
* @param int $line 错误行号
*/
public static function sys_error($message, $file, $line) {
include FRAMEWORK_PATH . 'debug/error.php';
}
/**
* exception
*/
public static function exception_handler($e) {
DEBUG && $_SERVER['_exception'] = 1; // 只输出一次
// 第1步正确定位
$trace = $e->getTrace();
if (!empty($trace) && $trace[0]['function'] == 'error_handler' && $trace[0]['class'] == 'debug') {
$message = $e->getMessage();
$file = $trace[0]['args'][2];
$line = $trace[0]['args'][3];
} else {
$message = '[exception] : ' . $e->getMessage();
$file = $e->getFile();
$line = $e->getLine();
}
$message = strip_tags($message);
// 第2步写日志 (暂不使用 error_log() )
//log::write("$message File: $file [$line]");
// 第3步根据情况输出错误信息
try {
core::ob_clean();
self::exception($message, $file, $line, $e->getTraceAsString());
} catch (Exception $e) {
echo get_class($e) . " thrown within the exception handler. Message: " . $e->getMessage() . " on line " . $e->getLine();
}
}
/**
* 错误处理
*
* @param string $errno 错误类型
* @param string $errstr 错误消息
* @param string $errfile 错误文件
* @param int $errline 错误行号
*/
public static function error_handler($errno, $errstr, $errfile, $errline) {
if (!empty($_SERVER['exception'])) return;
// 兼容 php 5.3 以下版本
defined('E_DEPRECATED') || define('E_DEPRECATED', 8192);
defined('E_USER_DEPRECATED') || define('E_USER_DEPRECATED', 16384);
$error_type = array(
E_ERROR => '运行错误',
E_WARNING => '运行警告',
E_PARSE => '语法错误',
E_NOTICE => '运行通知',
E_CORE_ERROR => '初始错误',
E_CORE_WARNING => '初始警告',
E_COMPILE_ERROR => '编译错误',
E_COMPILE_WARNING => '编译警告',
E_USER_ERROR => '用户定义的错误',
E_USER_WARNING => '用户定义的警告',
E_USER_NOTICE => '用户定义的通知',
E_STRICT => '代码标准建议',
E_RECOVERABLE_ERROR => '致命错误',
E_DEPRECATED => '代码警告',
E_USER_DEPRECATED => '用户定义的代码警告',
);
$errno_str = isset($error_type[$errno]) ? $error_type[$errno] : '未知错误';
$s = "[$errno_str] : $errstr";
// 线上模式放宽一些,只记录日志,不中断程序执行
if (!in_array($errno, array(E_WARNING, E_NOTICE, E_USER_NOTICE, E_DEPRECATED))) {
//log::write($s);
throw new Exception($s);
}
}
public static function process() {
if (DEBUG || DEBUG_INFO) {
include FRAMEWORK_PATH . 'debug/trace.php';
}
}
/**
* 数组转换成HTML代码 (支持双行变色)
*
* @param array $arr 一维数组
* @param int $type 显示类型
* @param boot $html 是否转换为 HTML 实体
* @return string
*/
public static function arr2str($arr, $type = 3, $html = TRUE) {
$s = '';
$i = 0;
if (!$arr) {
return '';
}
foreach ($arr as $k => $v) {
switch ($type) {
case 0:
$k = '';
break;
case 1:
$k = "$k ";
break;
case 2:
$k = "<span>$k</span>";
break;
default:
$k = "$k = ";
}
$i++;
$c = $i % 2 == 0 ? ' class="even"' : '';
$html && is_string($v) && $v = htmlspecialchars($v);
if (is_array($v) || is_object($v)) {
$v = print_r($v, 1);
}
$s .= "\r\n<li$c>$k$v</li>";
}
return $s;
}
/**
* 输出异常信息
*
* @param string $message 异常消息
* @param string $file 异常文件
* @param int $line 异常行号
* @param string $tracestr 异常追踪信息
*/
public static function exception($message, $file, $line, $tracestr) {
if (core::is_cmd()) {
include FRAMEWORK_PATH . 'debug/exception_cmd.php';
} else {
include FRAMEWORK_PATH . 'debug/exception.php';
}
}
/*
// 异常CODE,用来标示是哪个模块产生的异常。暂时不需要。
const APP_EXCEPTION_CODE_ERROR_HANDLE = 1;
const APP_EXCEPTION_CODE_MYSQL = 2;
const APP_EXCEPTION_CODE_LOG = 3;
*/
public static function format_exception($e) {
$trace = $e->getTrace();
// 如果是 error_handle ,弹出第一个元素。
if (!empty($trace) && $trace[0]['function'] == 'error_handle' && $trace[0]['class'] == 'core') {
//array_shift($trace);
$line = $trace[0]['args'][3];
$file = $trace[0]['args'][2];
$message = $trace[0]['args'][1];
} else {
$line = $e->getLine();
$file = $e->getFile();
$message = $e->getMessage();
}
$backtracelist = array();
foreach ($trace as $k => $v) {
$args = $comma = '';
if (!empty($v['args'])) {
if (DEBUG) {
if ($v['function'] == 'error_handle') {
$v['class'] = '';
$v['function'] = '';
$args = '';
} else {
foreach ((array)$v['args'] as $arg) {
if (is_string($arg)) {
$args .= $comma . "'$arg'";
} elseif (is_object($arg)) {
$args .= $comma . "Object";
} elseif (is_array($arg)) {
// 针对XN 优化
if (!isset($arg['db'])) {
$arg = print_r($arg, 1);
} else {
$arg = '$conf';
}
//$arg = str_replace(array("\t", ' '), array('&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;', '&nbsp;'), $arg);
//$arg = nl2br($arg);
$args .= $comma . $arg;
} else {
$args .= $comma . '' . ($arg === NULL ? 'NULL' : $arg);
}
$comma = ', ';
}
}
} else {
$args = '';
}
}
!isset($v['file']) && $v['file'] = '';
!isset($v['line']) && $v['line'] = '';
!isset($v['function']) && $v['function'] = '';
!isset($v['class']) && $v['class'] = '';
!isset($v['type']) && $v['type'] = '';
$backtracelist[] = array(
'file' => $v['file'],
'line' => $v['line'],
'function' => $v['function'],
'class' => $v['class'],
'type' => $v['type'],
'args' => $args,
);
}
// array_shift($backtracelist);
// array_shift($backtracelist);
$codelist = self::get_code($file, $line);
return array(
'line' => $line,
'file' => $file,
'codelist' => $codelist,
'message' => $message,
'backtracelist' => $backtracelist,
);
}
public static function get_code($file, $line) {
$arr = file($file);
$arr2 = array_slice($arr, max(0, $line - 5), 10, true);
if (!core::is_cmd()) {
/*
foreach ($arr2 as &$v) {
$v = htmlspecialchars($v);
$v = str_replace(' ', '&nbsp;', $v);
$v = str_replace(' ', '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;', $v);
}
*/
}
return $arr2;
}
}
?>
Loading...
举报
举报成功
我们将于2个工作日内通过站内信反馈结果给你!
请认真填写举报原因,尽可能描述详细。
请选择举报类型
取消
发送
误判申诉

此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。

如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。

取消
提交

简介

mzphp :第一款支持 scss 语法和 css sprite 的 php 框架
取消

发行版

暂无发行版

贡献者

全部

近期动态

不能加载更多了
编辑仓库简介
简介内容
主页
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/case-code/mzphp2.git
git@gitee.com:case-code/mzphp2.git
case-code
mzphp2
mzphp2
master
点此查找更多帮助

搜索帮助

评论
仓库举报
回到顶部
登录提示
该操作需登录 Gitee 帐号,请先登录后再操作。
立即登录
没有帐号,去注册

AltStyle によって変換されたページ (->オリジナル) /