From a261f37af4a4287a3eb007072e9a95ee64a7be7d Mon Sep 17 00:00:00 2001 From: caoyanyi Date: Thu, 2 Mar 2023 14:51:35 +0800 Subject: [PATCH] * Add zentao api get. --- module/admin/control.php | 41 +++++++++++++++++++++++++------- module/admin/model.php | 10 ++++---- module/admin/view/index.html.php | 2 +- 3 files changed, 38 insertions(+), 15 deletions(-) diff --git a/module/admin/control.php b/module/admin/control.php index 2a38dac0ef..ed73da9f31 100755 --- a/module/admin/control.php +++ b/module/admin/control.php @@ -53,23 +53,46 @@ class admin extends control $this->loadModel('misc'); - $hasInternet = $this->admin->checkInternet(); - $clientLang = $this->app->getClientLang(); - $langNotCN = common::checkNotCN(); - $dateUsed = $this->admin->genDateUsed(); + $clientLang = $this->app->getClientLang(); + $langNotCN = common::checkNotCN(); + $dateUsed = $this->admin->genDateUsed(); $this->view->title = $this->lang->admin->common; $this->view->position[] = $this->lang->admin->index; - $this->view->plugins = $this->admin->getExtensionsByAPI('plugin', $langNotCN ? 5 : 6, $hasInternet); - $this->view->patches = $this->admin->getExtensionsByAPI('patch', 5, $hasInternet); + $this->view->plugins = $this->admin->getExtensionsByAPI('plugin'); + $this->view->patches = $this->admin->getExtensionsByAPI('patch'); $this->view->dateUsed = $dateUsed; - $this->view->hasInternet = $hasInternet; - $this->view->dynamics = ($hasInternet and !$langNotCN) ? $this->admin->getDynamicsByAPI(3) : array(); - $this->view->publicClass = ($hasInternet and !$langNotCN) ? $this->admin->getPublicClassByAPI(3) : array(); + $this->view->dynamics = array(); + $this->view->publicClass = array(); $this->view->langNotCN = $langNotCN; $this->display(); } + /** + * Get zentao.net data by api. + * + * @access public + * @return void + */ + public function ajaxGetZentaoData() + { + $hasInternet = $this->admin->checkInternet(); + $langNotCN = common::checkNotCN(); + + $data['result'] = $hasInternet ? 'success' : 'fail'; + $data['data'] = new stdClass(); + + if($hasInternet) + { + $data['data']->plugins = $this->admin->getExtensionsByAPI('plugin', $langNotCN ? 5 : 6, true); + $data['data']->patches = $this->admin->getExtensionsByAPI('patch', 5, true); + $data['data']->dynamics = !$langNotCN ? $this->admin->getDynamicsByAPI(3) : array(); + $data['data']->publicClass = !$langNotCN ? $this->admin->getPublicClassByAPI(3) : array(); + } + + return $this->send($data); + } + /** * Ignore notice of register and bind. * diff --git a/module/admin/model.php b/module/admin/model.php index a85a8f49a6..0ed3137ced 100755 --- a/module/admin/model.php +++ b/module/admin/model.php @@ -514,7 +514,7 @@ class adminModel extends model * @access public * @return array */ - public function getExtensionsByAPI($type = 'plugin', $limit = 6, $hasInternet = true) + public function getExtensionsByAPI($type = 'plugin', $limit = 6, $hasInternet = false) { if($hasInternet) { @@ -643,11 +643,11 @@ class adminModel extends model */ public function checkInternet() { - $timeoutMS = 400; - $curl = curl_init(); + $timeout = 3; + $curl = curl_init(); curl_setopt($curl, CURLOPT_URL, $this->config->admin->apiSite); - curl_setopt($curl, CURLOPT_TIMEOUT_MS, $timeoutMS); - curl_setopt($curl, CURLOPT_CONNECTTIMEOUT_MS, $timeoutMS); + curl_setopt($curl, CURLOPT_TIMEOUT, $timeout); + curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, $timeout); curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE); curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE); curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, FALSE); diff --git a/module/admin/view/index.html.php b/module/admin/view/index.html.php index 594c0b0270..b675190512 100755 --- a/module/admin/view/index.html.php +++ b/module/admin/view/index.html.php @@ -11,7 +11,7 @@ */ ?> - +