Update.php 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | ThinkAdmin
  4. // +----------------------------------------------------------------------
  5. // | 版权所有 2014~2019 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
  6. // +----------------------------------------------------------------------
  7. // | 官方网站: http://demo.thinkadmin.top
  8. // +----------------------------------------------------------------------
  9. // | 开源协议 ( https://mit-license.org )
  10. // +----------------------------------------------------------------------
  11. // | gitee 代码仓库:https://gitee.com/zoujingli/ThinkAdmin
  12. // | github 代码仓库:https://github.com/zoujingli/ThinkAdmin
  13. // +----------------------------------------------------------------------
  14. namespace app\admin\controller\api;
  15. use think\admin\Controller;
  16. /**
  17. * 系统更新接口
  18. * Class Update
  19. * @package app\admin\controller\api
  20. */
  21. class Update extends Controller
  22. {
  23. /**
  24. * 获取文件列表
  25. */
  26. public function tree()
  27. {
  28. $plugs = new \think\admin\plugs\Plugs();
  29. $this->success('获取当前文件列表成功!', $plugs->buildFileList([
  30. 'think', 'app/admin', 'public/static',
  31. ], ['public/static/self']));
  32. }
  33. /**
  34. * 读取线上文件数据
  35. * @param string $encode
  36. */
  37. public function get($encode)
  38. {
  39. $this->file = dirname($this->app->getAppPath()) . '/' . decode($encode);
  40. if (file_exists($this->file)) {
  41. $this->success('读取文件成功!', [
  42. 'format' => 'base64', 'content' => base64_encode(file_get_contents($this->file)),
  43. ]);
  44. } else {
  45. $this->error('获取文件内容失败!');
  46. }
  47. }
  48. }