Update.php 1.8 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. use think\admin\service\InstallService;
  17. /**
  18. * 安装服务端支持
  19. * Class Update
  20. * @package app\admin\controller\api
  21. */
  22. class Update extends Controller
  23. {
  24. /**
  25. * 获取文件列表
  26. */
  27. public function tree()
  28. {
  29. $this->rules = unserialize($this->request->post('rules', 'a:0:{}', ''));
  30. $this->ignore = unserialize($this->request->post('ignore', 'a:0:{}', ''));
  31. $this->success('获取文件列表成功!', InstallService::instance()->getList($this->rules, $this->ignore));
  32. }
  33. /**
  34. * 读取文件内容
  35. */
  36. public function get()
  37. {
  38. $this->file = $this->app->getRootPath() . decode(input('encode', '0'));
  39. if (file_exists($this->file)) {
  40. $this->success('读取文件成功!', [
  41. 'content' => base64_encode(file_get_contents($this->file)),
  42. ]);
  43. } else {
  44. $this->error('读取文件内容失败!');
  45. }
  46. }
  47. }