企业站点开发后台页面使用X-admin,配置admin.php 作为入口文件,可以直接访问。
application\admin\controller\Index.php
<?php
namespace app\admin\controller;
use app\common\controller\Base;
class Index extends Base
{
public function index(){
return $this->view->fetch();
}
public function welcome(){
return $this->view->fetch();
}
}点击 "运行实例" 按钮查看在线实例
application\admin\view\index\welcome.html
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>欢迎页面-X-admin2.0</title>
<meta name="renderer" content="webkit">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
<link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />
<link rel="stylesheet" href="__ADMIN__/css/font.css">
<link rel="stylesheet" href="__ADMIN__/css/xadmin.css">
</head>
<body>
<div class="x-body layui-anim layui-anim-up">
<blockquote class="layui-elem-quote">欢迎管理员:
<span class="x-red"></span>!当前时间:2018-04-25 20:50:53</blockquote>
<fieldset class="layui-elem-field">
<legend>系统信息</legend>
<div class="layui-field-box">
<table class="layui-table">
<tbody>
<tr>
<th>ThinkPHP版本</th>
<td>{$Think.VERSION}</td></tr>
<tr>
<th>操作系统</th>
<td>{$Think.const.PHP_OS}</td></tr>
<tr>
<th>服务器地址</th>
<td>{$Think.server.server_addr}</td></tr>
<tr>
<th>运行环境</th>
<td>{$Think.server.http_user_agent}</td></tr>
<tr>
<th>PHP版本</th>
<td>{$Think.const.PHP_VERSION}</td></tr>
<tr>
<th>PHP运行方式</th>
<td>cgi-fcgi</td></tr>
<tr>
<th>MYSQL版本</th>
<td>{:getMysqlVersion()}</td></tr>
<tr>
<th>ThinkPHP</th>
<td>{$Think.VERSION}</td></tr>
<tr>
<th>上传附件限制</th>
<td>{:\ini_get('post_max_size')}</td></tr>
<tr>
<th>执行时间限制</th>
<td>{:\ini_get('max_execution_time')}</td></tr>
<tr>
<th>剩余空间</th>
<td>{:\round(disk_free_space("/")/1024/1024/1024,2)}G</td></tr>
</tbody>
</table>
</div>
</fieldset>
</div>
<script>
var _hmt = _hmt || [];
(function() {
var hm = document.createElement("script");
hm.src = "https://hm.baidu.com/hm.js?b393d153aeb26b46e9431fabaf0f6190";
var s = document.getElementsByTagName("script")[0];
s.parentNode.insertBefore(hm, s);
})();
</script>
</body>
</html>点击 "运行实例" 按钮查看在线实例
application\common\controller\Base.php
<?php
namespace app\common\controller;
use think\Controller;
class Base extends Controller
{
protected function initialize()
{
parent::initialize();
$this->filter(function($content){
return str_replace('__ADMIN__','/static/admin',$content);
});
}
}点击 "运行实例" 按钮查看在线实例
application\common.php
<?php
// +----------------------------------------------------------------------
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
// +----------------------------------------------------------------------
// | Copyright (c) 2006-2016 http://thinkphp.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: 流年 <liu21st@gmail.com>
// +----------------------------------------------------------------------
// 应用公共文件
use think\Db;
function getUserName(){
return Db::connect('qiye')->table('user')->value('user_name');
}
function getCurrentTime(){
return date('Y-m-d H:i:s',time());
}
function getMysqlVersion(){
return Db::connect('qiye')->query('SELECT VERSION() AS version')[0]['version'];
}点击 "运行实例" 按钮查看在线实例

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号