/data/home/bxu2404500163/htdocs/app/base/controller/ErrorController.php
<?php
namespace app\base\controller;
use framework\base\Controller;
class ErrorController extends Controller
{
public function error404($e = null)
{
header('HTTP/1.1 404 Not Found');
header('status: 404 Not Found');
$this->error($e);
}
public function error($e = null)
{
//关闭调试或者是线上版本,不显示详细错误
if (false == config('DEBUG') || 'production' == config('ENV')) {
$home = new \app\home\controller\IndexController();
$home->error404();
} else {
throw $e;
}
}
}
/data/home/bxu2404500163/htdocs/app/base/controller/ErrorController.php
<?php
namespace app\base\controller;
use framework\base\Controller;
class ErrorController extends Controller
{
public function error404($e = null)
{
header('HTTP/1.1 404 Not Found');
header('status: 404 Not Found');
$this->error($e);
}
public function error($e = null)
{
//关闭调试或者是线上版本,不显示详细错误
if (false == config('DEBUG') || 'production' == config('ENV')) {
$home = new \app\home\controller\IndexController();
$home->error404();
} else {
throw $e;
}
}
}
/data/home/bxu2404500163/htdocs/app/base/hook/AppHook.php
Hook::listen('CheckAdminLang');
}
}
$this->startTime = microtime(true);
}
public function appEnd()
{
//echo microtime(true) - $this->startTime ;
}
public function appError($e)
{
if (404 == $e->getCode()) {
$action = 'error404';
} else {
$action = 'error';
}
obj('app\base\controller\ErrorController')->$action($e);
}
public function routeParseUrl($rewriteRule, $rewriteOn)
{
}
public function actionBefore($obj, $action)
{
}
public function actionAfter($obj, $action)
{
}
}
/data/home/bxu2404500163/htdocs/framework/base/Hook.php
return false;
}
foreach (self::$tags[$tag] as $class) {
$result = self::exec($class, $tag, $params);
if (false === $result) {
break;
}
}
return true;
}
protected static function exec($class, $method, $params)
{
static $objArr = [];
if (!isset($objArr[$class])) {
$objArr[$class] = new $class();
}
return call_user_func_array([$objArr[$class], $method], (array) $params);
}
}
/data/home/bxu2404500163/htdocs/framework/base/Hook.php
return false;
}
foreach (self::$tags[$tag] as $class) {
$result = self::exec($class, $tag, $params);
if (false === $result) {
break;
}
}
return true;
}
protected static function exec($class, $method, $params)
{
static $objArr = [];
if (!isset($objArr[$class])) {
$objArr[$class] = new $class();
}
return call_user_func_array([$objArr[$class], $method], (array) $params);
}
}
/data/home/bxu2404500163/htdocs/framework/base/Hook.php
continue;
}
$class = substr($file, $pos + 1, -4);
$class = "\\app\\base\\hook\\{$class}";
$methods = get_class_methods($class);
foreach ((array) $methods as $method) {
self::$tags[$method][] = $class;
}
}
}
public static function listen($tag, $params = [], &$result = null)
{
if (!isset(self::$tags[$tag])) {
return false;
}
foreach (self::$tags[$tag] as $class) {
$result = self::exec($class, $tag, $params);
if (false === $result) {
break;
}
}
return true;
}
protected static function exec($class, $method, $params)
{
static $objArr = [];
if (!isset($objArr[$class])) {
$objArr[$class] = new $class();
}
return call_user_func_array([$objArr[$class], $method], (array) $params);
}
}
/data/home/bxu2404500163/htdocs/framework/base/App.php
if (!class_exists($controller)) {
throw new \Exception("Controller '{$controller}' not found", 404);
}
$obj = new $controller();
if (!method_exists($obj, $action)) {
throw new \Exception("Action '{$controller}::{$action}()' not found", 404);
}
Hook::listen('actionBefore', [$obj, $action]);
$obj->$action();
Hook::listen('actionAfter', [$obj, $action]);
} catch (\Exception $e) {
// //关闭调试或者是线上版本,不显示详细错误
// if (false==config('DEBUG') || 'production' == config('ENV')) {
// $home = new \app\home\controller\IndexController();
// $home->error404();
// } else {
// throw $e;
// }
Hook::listen('appError', [$e]);
}
Hook::listen('appEnd');
}
}
/data/home/bxu2404500163/htdocs/framework/core.php
foreach (glob($fileDIR.'*.php') as $file) {
$fileList[$fileDIR][] = $file;
}
}
$fileBase = $baseDir.str_replace('\\', DIRECTORY_SEPARATOR, $namespace).DIRECTORY_SEPARATOR.$className;
foreach ($fileList[$fileDIR] as $file) {
if (false !== stripos($file, $fileBase)) {
require $file;
return true;
}
}
}
}
return false;
});
App::run();
/data/home/bxu2404500163/htdocs/index.php
<?php
if (version_compare(PHP_VERSION, '5.6.0', '<')) {
header('Content-Type: text/html; charset=UTF-8');
echo 'PHP环境不能低于5.6';
exit;
}
require 'framework/core.php';