/data/home/bxu2404500163/htdocs/app/base/controller/BaseController.php
* @param bool $status 状态
* @param string $jumpUrl 跳转地址
*
* @return array
*/
public function ajaxReturn($data)
{
header('Content-type:text/json');
echo json_encode($data);
exit;
}
/**
* 页面不存在.
*
* @return array 页面信息
*/
protected function error404()
{
throw new \Exception('404页面不存在!', 404);
}
/**
* 通讯错误.
*/
protected function errorBlock()
{
$this->error('通讯发生错误,请稍后刷新后尝试!');
}
//生成分页URL
protected function createPageUrl($paramer = [], $mustParams = [], $page = 1)
{
$paramer = array_filter($paramer);
$paramer = array_flip(array_flip($paramer));
$dir = APP_NAME.'/'.CONTROLLER_NAME.'/'.ACTION_NAME;
$mustParams['page'] = $page;
return match_url($dir, $paramer, $mustParams);
}
/data/home/bxu2404500163/htdocs/app/article/controller/ContentController.php
$this->error404();
}
$model = target('ContentArticle');
//获取内容信息
if (!empty($contentId)) {
$contentInfo = $model->getInfo($contentId);
} elseif (!empty($urlTitle)) {
$where = [];
$where['urltitle'] = $urlTitle;
$contentInfo = $model->getWhereInfo($where);
} else {
$this->error404();
}
$contentId = $contentInfo['content_id'];
//信息判断
if (!is_array($contentInfo)) {
$this->error404();
}
if (!$contentInfo['status']) {
$this->error404();
}
//获取栏目信息
$modelCategory = target('CategoryArticle');
$categoryInfo = $modelCategory->getInfo($contentInfo['class_id']);
if (!is_array($categoryInfo)) {
$this->error404();
}
// 多语言
if (defined('LANG_OPEN') && $categoryInfo['lang'] !== APP_LANG) {
changeLang($categoryInfo['lang'], $_REQUEST['s']);
}
if ($categoryInfo['app'] != APP_NAME) {
$this->error404();
}
//判断跳转
if (!empty($contentInfo['url'])) {
$link = $this->show($contentInfo['url']);
$this->redirect($link, 301);
/data/home/bxu2404500163/htdocs/framework/base/App.php
if (defined('API_STATUS')) {
$controller = '\\app\\api\\controller\\IndexController';
$action = 'index';
} else {
$controller = '\app\\'.APP_NAME.'\controller\\'.CONTROLLER_NAME.'Controller';
$action = ACTION_NAME;
}
//execute action
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';