From 3331dcd385d022d14ee69e34c195674957a30ec9 Mon Sep 17 00:00:00 2001 From: WispX <1591788658@qq.com> Date: Fri, 13 Mar 2020 17:57:07 +0800 Subject: [PATCH] :arrow_up: Upgrading dependencies. --- application/index/controller/admin/System.php | 5 ++ extend/Upgrade.php | 59 +++++++++++++++++++ 2 files changed, 64 insertions(+) create mode 100644 extend/Upgrade.php diff --git a/application/index/controller/admin/System.php b/application/index/controller/admin/System.php index a0c357bf..2647bdb7 100644 --- a/application/index/controller/admin/System.php +++ b/application/index/controller/admin/System.php @@ -85,4 +85,9 @@ class System extends Base $this->success('发送成功'); } } + + public function upgrade() + { + (new \Upgrade(app()->getRootPath()))->exec(); + } } diff --git a/extend/Upgrade.php b/extend/Upgrade.php new file mode 100644 index 00000000..dbb6b809 --- /dev/null +++ b/extend/Upgrade.php @@ -0,0 +1,59 @@ +path = $path; + } + + private function getNewest() + { + // TODO 获取最新版本号 + return '1.5.8'; + } + + private function getPackage() + { + // TODO 获取增量包下载链接 + return 'https://api.github.com/repos/wisp-x/lsky-pro/zipball/v1.5.8'; + } + + private function download() + { + set_time_limit(180); + ini_set('max_execution_time', 180); + + $ch = curl_init(); + curl_setopt($ch, CURLOPT_URL, $this->getPackage()); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); + curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 120); + $img = curl_exec($ch); + curl_close($ch); + + file_put_contents($filename, $img); + + unset($img, $url); + return true; + } + + public function exec() + { + dump($this->download());exit; + } +}