* Add zentao api get.

This commit is contained in:
caoyanyi
2023-03-02 14:51:35 +08:00
parent 7989ef5e0f
commit a261f37af4
3 changed files with 38 additions and 15 deletions
+32 -9
View File
@@ -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.
*
+5 -5
View File
@@ -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);
+1 -1
View File
@@ -11,7 +11,7 @@
*/
?>
<?php include '../../common/view/header.html.php';?>
<?php js::set('hasInternet', $hasInternet);?>
<?php js::set('hasInternet', false);?>
<div id='mainContent' class='main-content admin'>
<div class="main <?php if(!$hasInternet) echo 'without-internet';?>">
<div class="settings panel">