123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107 |
- <?php
- declare(strict_types=1);
- namespace app\sys\controller;
- use think\facade\App;
- use think\facade\Db;
- use think\facade\Config;
- use think\facade\View;
- class Index extends Base
- {
- public function index()
- {
- // 系统信息
- $mysqlVersion = Db::query('SELECT VERSION() AS ver');
- $config = [
- 'url' => $_SERVER['HTTP_HOST'],
- 'document_root' => $_SERVER['DOCUMENT_ROOT'],
- 'server_os' => PHP_OS,
- 'server_port' => $_SERVER['SERVER_PORT'],
- 'server_ip' => isset($_SERVER['SERVER_ADDR']) ? $_SERVER['SERVER_ADDR'] : '',
- 'server_soft' => $_SERVER['SERVER_SOFTWARE'],
- 'php_version' => PHP_VERSION,
- 'mysql_version' => $mysqlVersion[0]['ver'],
- 'max_upload_size' => ini_get('upload_max_filesize'),
- 'tp_version' => App::version(),
- ];
- View::assign([
- 'config' => $config,
- // 'user' => $user,
- // 'message' => $message ?? 0,
- // 'messageCatUrl' => $messageCatUrl,
- 'indexTips' => $this->getIndexTips(),
- ]);
- return View::fetch('index');
- }
- // 检查提示信息
- private function getIndexTips()
- {
- $user = $this->getSysUser();
- $defaultPassword = Config::get('app.default_password') ?: 'admin';
- if ($user->password == md5($defaultPassword . $user->salt)) {
- return '<h6 class="mb-0"><i class="icon fas fa-fw fa-exclamation-triangle"></i> 请尽快修改后台初始密码!</h6>';
- }
- return '';
- }
- public function usedspace()
- {
- if ($this->request->isAjax()) {
- $dirname = $this->app->getRootPath();
- $dirsize = get_dir_size($dirname);
- return ['code' => 0, 'size' => format_bytes($dirsize)];
- }
- }
- public function clearcache()
- {
- if ($this->request->isAjax()) {
- $runtime_path = $this->app->getRootPath() . 'runtime' . DIRECTORY_SEPARATOR;
- try {
- $cache_dir = $runtime_path . 'cache' . DIRECTORY_SEPARATOR;
- $admin_dir = $runtime_path . 'admin' . DIRECTORY_SEPARATOR;
- $index_dir = $runtime_path . 'index' . DIRECTORY_SEPARATOR;
- $api_dir = $runtime_path . 'api' . DIRECTORY_SEPARATOR;
- deldir($cache_dir);
- deldir($admin_dir);
- deldir($index_dir);
- deldir($api_dir);
- } catch (\Exception $e) {
- return ['code' => 0, 'msg' => $e->getMessage()];
- }
- return ['code' => 1, 'msg' => '清除成功'];
- }
- }
- // 刷新栏目页
- // public function reClass($classid)
- // {
- // $classess = Enewsclass::with('module')->field("classid, bclassid,classname,modid,classpath,islast,islist,listtempid,classurl")->order('classid desc')->select();
- // $publicpath = app()->getRootPath() . 'public/';
- // foreach ($classess as $key => $class) {
- // if ($class->islast == 1) { // 列表模板, 其他的再说
- // $model = "\app\common\model\\" . $class->modelName;
- // $path = $publicpath . $class->classpath;
- // if (!file_exists($path)) {
- // mkdir($path, 0755, true);
- // }
- // $listpage = 25; // 每页25条
- // // $total =
- // }
- // }
- // }
- }
|