Update.php 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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\install\ExtendInstall;
  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. $extend = ExtendInstall::instance($this->app);
  30. $this->rules = unserialize($this->request->post('rules', 'a:0:{}', ''));
  31. $this->ignore = unserialize($this->request->post('ignore', 'a:0:{}', ''));
  32. $this->success('获取当前文件列表成功!', $extend->buildFileList($this->rules, $this->ignore));
  33. }
  34. /**
  35. * 读取线上文件数据
  36. */
  37. public function get()
  38. {
  39. $this->file = $this->app->getRootPath() . decode(input('encode', '0'));
  40. file_exists($this->file) ? $this->success('读取文件成功!', [
  41. 'format' => 'base64', 'content' => base64_encode(file_get_contents($this->file)),
  42. ]) : $this->error('获取文件内容失败!');
  43. }
  44. }