Index.php 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. <?php
  2. declare(strict_types=1);
  3. namespace app\sys\controller;
  4. use think\facade\App;
  5. use think\facade\Db;
  6. use think\facade\Config;
  7. use think\facade\View;
  8. class Index extends Base
  9. {
  10. public function index()
  11. {
  12. // 系统信息
  13. $mysqlVersion = Db::query('SELECT VERSION() AS ver');
  14. $config = [
  15. 'url' => $_SERVER['HTTP_HOST'],
  16. 'document_root' => $_SERVER['DOCUMENT_ROOT'],
  17. 'server_os' => PHP_OS,
  18. 'server_port' => $_SERVER['SERVER_PORT'],
  19. 'server_ip' => isset($_SERVER['SERVER_ADDR']) ? $_SERVER['SERVER_ADDR'] : '',
  20. 'server_soft' => $_SERVER['SERVER_SOFTWARE'],
  21. 'php_version' => PHP_VERSION,
  22. 'mysql_version' => $mysqlVersion[0]['ver'],
  23. 'max_upload_size' => ini_get('upload_max_filesize'),
  24. 'tp_version' => App::version(),
  25. ];
  26. View::assign([
  27. 'config' => $config,
  28. // 'user' => $user,
  29. // 'message' => $message ?? 0,
  30. // 'messageCatUrl' => $messageCatUrl,
  31. 'indexTips' => $this->getIndexTips(),
  32. ]);
  33. return View::fetch('index');
  34. }
  35. // 检查提示信息
  36. private function getIndexTips()
  37. {
  38. $user = $this->getSysUser();
  39. $defaultPassword = Config::get('app.default_password') ?: 'admin';
  40. if ($user->password == md5($defaultPassword . $user->salt)) {
  41. return '<h6 class="mb-0"><i class="icon fas fa-fw fa-exclamation-triangle"></i> 请尽快修改后台初始密码!</h6>';
  42. }
  43. return '';
  44. }
  45. public function usedspace()
  46. {
  47. if ($this->request->isAjax()) {
  48. $dirname = $this->app->getRootPath();
  49. $dirsize = get_dir_size($dirname);
  50. return ['code' => 0, 'size' => format_bytes($dirsize)];
  51. }
  52. }
  53. public function clearcache()
  54. {
  55. if ($this->request->isAjax()) {
  56. $runtime_path = $this->app->getRootPath() . 'runtime' . DIRECTORY_SEPARATOR;
  57. try {
  58. $cache_dir = $runtime_path . 'cache' . DIRECTORY_SEPARATOR;
  59. $admin_dir = $runtime_path . 'admin' . DIRECTORY_SEPARATOR;
  60. $index_dir = $runtime_path . 'index' . DIRECTORY_SEPARATOR;
  61. $api_dir = $runtime_path . 'api' . DIRECTORY_SEPARATOR;
  62. deldir($cache_dir);
  63. deldir($admin_dir);
  64. deldir($index_dir);
  65. deldir($api_dir);
  66. } catch (\Exception $e) {
  67. return ['code' => 0, 'msg' => $e->getMessage()];
  68. }
  69. return ['code' => 1, 'msg' => '清除成功'];
  70. }
  71. }
  72. // 刷新栏目页
  73. // public function reClass($classid)
  74. // {
  75. // $classess = Enewsclass::with('module')->field("classid, bclassid,classname,modid,classpath,islast,islist,listtempid,classurl")->order('classid desc')->select();
  76. // $publicpath = app()->getRootPath() . 'public/';
  77. // foreach ($classess as $key => $class) {
  78. // if ($class->islast == 1) { // 列表模板, 其他的再说
  79. // $model = "\app\common\model\\" . $class->modelName;
  80. // $path = $publicpath . $class->classpath;
  81. // if (!file_exists($path)) {
  82. // mkdir($path, 0755, true);
  83. // }
  84. // $listpage = 25; // 每页25条
  85. // // $total =
  86. // }
  87. // }
  88. // }
  89. }