1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 |
- <?php
- namespace app\admin\controller\api;
- use library\command\Sync;
- use library\Controller;
- class Update extends Controller
- {
-
- protected function initialize()
- {
- $domain = $this->app->request->host(true);
- $isDemo = is_numeric(stripos($domain, 'thinkadmin.top'));
- $isLocal = in_array($domain, ['127.0.0.1', 'localhost']);
- if (!$isLocal && !$isDemo) $this->error('只允许访问本地或官方代码!');
- }
-
- public function tree()
- {
- $sync = new Sync('Update');
- $this->success('获取当前文件列表成功!', $sync->build());
- }
-
- public function read($encode)
- {
- $this->file = env('root_path') . decode($encode);
- if (file_exists($this->file)) {
- $this->success('读取文件成功!', [
- 'format' => 'base64',
- 'content' => base64_encode(file_get_contents($this->file)),
- ]);
- } else {
- $this->error('获取文件内容失败!');
- }
- }
- }
|