From d7b4cfbe184a16ae2bcd049278ea5be8fe8a8e19 Mon Sep 17 00:00:00 2001 From: zenggang Date: Mon, 7 Aug 2023 06:53:59 +0000 Subject: [PATCH] * Fix bugs --- config/config.php | 9 +- lib/requests/Requests/Cookie/Jar.php | 10 +- lib/requests/Requests/Response/Headers.php | 6 +- .../Utility/CaseInsensitiveDictionary.php | 10 +- lib/scm/scm.class.php | 4 +- module/gitea/control.php | 2 +- module/gogs/control.php | 2 +- module/install/model.php | 21 +- module/install/ui/step2.html.php | 200 ++++++++++++++++++ module/jenkins/control.php | 2 +- module/sonarqube/control.php | 2 +- 11 files changed, 239 insertions(+), 29 deletions(-) create mode 100644 module/install/ui/step2.html.php diff --git a/config/config.php b/config/config.php index 04e717ffe3..5ddd4c57f1 100644 --- a/config/config.php +++ b/config/config.php @@ -164,15 +164,16 @@ $config->maxCount = 500; $config->moreLinks = array(); /* 渠成平台设置。CNE Api settings. */ -$config->inQuickon = false; -$config->inContainer = false; +$config->inQuickon = getenv('IN_QUICKON'); +$config->inContainer = getenv('IN_CONTAINER'); +$config->k8space = 'quickon-system'; $config->demoAccounts = ''; // 用于演示的账号列表,该账号安装的应用30钟后会自动删除。 In account list for demo, app instance of demo will be removed in 30 minutes. $config->demoAppLife = 30; // Demo安装的应用实例存续时长(分钟)。The minutes life of instance which demo account installed. $config->CNE = new stdclass(); $config->CNE->api = new stdclass(); -$config->CNE->api->host = ''; +$config->CNE->api->host = getenv('CNE_API_HOST'); $config->CNE->api->auth = 'X-Auth-Token'; -$config->CNE->api->token = 'reiquai7pei7thei4iePe5ait3Kaiquu'; // Please set token in my.php. +$config->CNE->api->token = getenv('CNE_API_TOKEN'); // Please set token in my.php. $config->CNE->api->headers = array('Content-Type: application/json'); $config->CNE->api->channel = 'stable'; diff --git a/lib/requests/Requests/Cookie/Jar.php b/lib/requests/Requests/Cookie/Jar.php index a816f90a0a..bc3b748a65 100644 --- a/lib/requests/Requests/Cookie/Jar.php +++ b/lib/requests/Requests/Cookie/Jar.php @@ -60,7 +60,7 @@ class Requests_Cookie_Jar implements ArrayAccess, IteratorAggregate { * @param string $key Item key * @return boolean Does the item exist? */ - public function offsetExists($key) { + public function offsetExists($key): bool { return isset($this->cookies[$key]); } @@ -70,7 +70,7 @@ class Requests_Cookie_Jar implements ArrayAccess, IteratorAggregate { * @param string $key Item key * @return string|null Item value (null if offsetExists is false) */ - public function offsetGet($key) { + public function offsetGet($key): string|null { if (!isset($this->cookies[$key])) { return null; } @@ -86,7 +86,7 @@ class Requests_Cookie_Jar implements ArrayAccess, IteratorAggregate { * @param string $key Item name * @param string $value Item value */ - public function offsetSet($key, $value) { + public function offsetSet($key, $value): void { if ($key === null) { throw new Requests_Exception('Object is a dictionary, not a list', 'invalidset'); } @@ -99,7 +99,7 @@ class Requests_Cookie_Jar implements ArrayAccess, IteratorAggregate { * * @param string $key */ - public function offsetUnset($key) { + public function offsetUnset($key): void { unset($this->cookies[$key]); } @@ -108,7 +108,7 @@ class Requests_Cookie_Jar implements ArrayAccess, IteratorAggregate { * * @return ArrayIterator */ - public function getIterator() { + public function getIterator(): ArrayIterator { return new ArrayIterator($this->cookies); } diff --git a/lib/requests/Requests/Response/Headers.php b/lib/requests/Requests/Response/Headers.php index 12db128ae5..e3740b711a 100644 --- a/lib/requests/Requests/Response/Headers.php +++ b/lib/requests/Requests/Response/Headers.php @@ -23,7 +23,7 @@ class Requests_Response_Headers extends Requests_Utility_CaseInsensitiveDictiona * @param string $key * @return string|null Header value */ - public function offsetGet($key) { + public function offsetGet($key): string|null { $key = strtolower($key); if (!isset($this->data[$key])) { return null; @@ -40,7 +40,7 @@ class Requests_Response_Headers extends Requests_Utility_CaseInsensitiveDictiona * @param string $key Item name * @param string $value Item value */ - public function offsetSet($key, $value) { + public function offsetSet($key, $value): void { if ($key === null) { throw new Requests_Exception('Object is a dictionary, not a list', 'invalidset'); } @@ -92,7 +92,7 @@ class Requests_Response_Headers extends Requests_Utility_CaseInsensitiveDictiona * Converts the internal * @return ArrayIterator */ - public function getIterator() { + public function getIterator(): ArrayIterator { return new Requests_Utility_FilteredIterator($this->data, array($this, 'flatten')); } } diff --git a/lib/requests/Requests/Utility/CaseInsensitiveDictionary.php b/lib/requests/Requests/Utility/CaseInsensitiveDictionary.php index 7eebeb7a72..4914480c54 100644 --- a/lib/requests/Requests/Utility/CaseInsensitiveDictionary.php +++ b/lib/requests/Requests/Utility/CaseInsensitiveDictionary.php @@ -37,7 +37,7 @@ class Requests_Utility_CaseInsensitiveDictionary implements ArrayAccess, Iterato * @param string $key Item key * @return boolean Does the item exist? */ - public function offsetExists($key) { + public function offsetExists($key): bool { $key = strtolower($key); return isset($this->data[$key]); } @@ -48,7 +48,7 @@ class Requests_Utility_CaseInsensitiveDictionary implements ArrayAccess, Iterato * @param string $key Item key * @return string|null Item value (null if offsetExists is false) */ - public function offsetGet($key) { + public function offsetGet($key): string|null { $key = strtolower($key); if (!isset($this->data[$key])) { return null; @@ -65,7 +65,7 @@ class Requests_Utility_CaseInsensitiveDictionary implements ArrayAccess, Iterato * @param string $key Item name * @param string $value Item value */ - public function offsetSet($key, $value) { + public function offsetSet($key, $value): void { if ($key === null) { throw new Requests_Exception('Object is a dictionary, not a list', 'invalidset'); } @@ -79,7 +79,7 @@ class Requests_Utility_CaseInsensitiveDictionary implements ArrayAccess, Iterato * * @param string $key */ - public function offsetUnset($key) { + public function offsetUnset($key): void { unset($this->data[strtolower($key)]); } @@ -88,7 +88,7 @@ class Requests_Utility_CaseInsensitiveDictionary implements ArrayAccess, Iterato * * @return ArrayIterator */ - public function getIterator() { + public function getIterator(): ArrayIterator { return new ArrayIterator($this->data); } diff --git a/lib/scm/scm.class.php b/lib/scm/scm.class.php index 2527a5d021..5991306153 100644 --- a/lib/scm/scm.class.php +++ b/lib/scm/scm.class.php @@ -15,9 +15,7 @@ class scm $className = $repo->SCM; if($className == 'Git') $className = 'GitRepo'; if(!class_exists($className)) require(strtolower($className) . '.class.php'); - $repoRoot = $repo->path; - if('Subversion' == $className && !empty($repo->prefix)) $repoRoot = substr($repo->path, 0, strlen($repo->path) - strlen($repo->prefix)); - $this->engine = new $className($repo->client, $repoRoot, $repo->account, $repo->password, $repo->encoding, $repo); + $this->engine = new $className($repo->client, $className == 'Gitlab' ? $repo->apiPath : $repo->path, $repo->account, $repo->password, $repo->encoding, $repo); } /** diff --git a/module/gitea/control.php b/module/gitea/control.php index 73c3a73d99..37365980d8 100644 --- a/module/gitea/control.php +++ b/module/gitea/control.php @@ -82,7 +82,7 @@ class gitea extends control if(dao::isError()) return $this->send(array('result' => 'fail', 'message' => dao::getError())); $actionID = $this->loadModel('action')->create('gitea', $giteaID, 'created'); - return $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'locate' => inlink('browse'))); + return $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'locate' => $this->createLink('space', 'browse'))); } $this->view->title = $this->lang->gitea->common . $this->lang->colon . $this->lang->gitea->lblCreate; diff --git a/module/gogs/control.php b/module/gogs/control.php index ca82ec2fb7..77ef72dfcd 100644 --- a/module/gogs/control.php +++ b/module/gogs/control.php @@ -81,7 +81,7 @@ class gogs extends control if(dao::isError()) return $this->send(array('result' => 'fail', 'message' => dao::getError())); $actionID = $this->loadModel('action')->create('gogs', $gogsID, 'created'); - return $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'locate' => inlink('browse'))); + return $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'locate' => $this->createLink('space', 'browse'))); } $this->view->title = $this->lang->gogs->common . $this->lang->colon . $this->lang->gogs->lblCreate; diff --git a/module/install/model.php b/module/install/model.php index 07f055ffbd..c357da7a63 100644 --- a/module/install/model.php +++ b/module/install/model.php @@ -334,12 +334,23 @@ class installModel extends model public function setDBParam() { $this->config->db->driver = $this->post->dbDriver; - $this->config->db->host = $this->post->dbHost; + if($this->config->inQuickon) + { + $this->config->db->host = getenv('ZT_MYSQL_HOST'); + $this->config->db->user = getenv('ZT_MYSQL_USER'); + $this->config->db->encoding = 'UTF8'; + $this->config->db->password = getenv('ZT_MYSQL_PASSWORD'); + $this->config->db->port = getenv('ZT_MYSQL_PORT'); + } + else + { + $this->config->db->host = $this->post->dbHost; + $this->config->db->user = $this->post->dbUser; + $this->config->db->encoding = $this->post->dbEncoding; + $this->config->db->password = $this->post->dbPassword; + $this->config->db->port = $this->post->dbPort; + } $this->config->db->name = $this->post->dbName; - $this->config->db->user = $this->post->dbUser; - $this->config->db->encoding = $this->post->dbEncoding; - $this->config->db->password = $this->post->dbPassword; - $this->config->db->port = $this->post->dbPort; $this->config->db->prefix = $this->post->dbPrefix; } diff --git a/module/install/ui/step2.html.php b/module/install/ui/step2.html.php new file mode 100644 index 0000000000..994a8eae6a --- /dev/null +++ b/module/install/ui/step2.html.php @@ -0,0 +1,200 @@ + + * @package install + * @link https://www.zentao.net + */ +namespace zin; + +include $this->app->getConfigRoot() . 'timezones.php'; + +set::zui(true); + +div +( + set::id('main'), + div + ( + set::id('mainContent'), + panel + ( + setClass('py-2'), + set::title($lang->install->setConfig), + form + ( + set::submitBtnText($lang->install->next), + set::actions(array('submit')), + h::table + ( + setClass('table bordered'), + h::tr + ( + h::th + ( + width('1/5'), + $lang->install->key + ), + h::th($lang->install->value), + h::th(), + ), + h::tr + ( + h::th($lang->install->timezone), + h::td + ( + picker + ( + set::name('timezone'), + set::items($timezoneList), + set::value($config->timezone), + ), + ), + h::td(), + ), + h::tr + ( + h::th($lang->install->defaultLang), + h::td + ( + picker + ( + set::name('defaultLang'), + set::items($config->langs), + set::value($app->getClientLang()), + ), + ), + h::td(), + ), + $config->edition != 'open' ? h::tr + ( + $config->inQuickon ? setClass('hidden') : null, + h::th($lang->install->dbDriver), + h::td + ( + picker + ( + set::name('dbDriver'), + set::items($lang->install->dbDriverList), + set::value('mysql'), + ), + ), + h::td(), + ) : input + ( + setClass('hidden'), + set::name('dbDriver'), + set::value('mysql'), + ), + h::tr + ( + $config->inQuickon ? setClass('hidden') : null, + h::th($lang->install->dbHost), + h::td + ( + input + ( + set::name('dbHost'), + set::value($dbHost), + ), + ), + h::td($lang->install->dbHostNote), + ), + h::tr + ( + $config->inQuickon ? setClass('hidden') : null, + h::th($lang->install->dbPort), + h::td + ( + input + ( + set::name('dbPort'), + set::value($dbPort), + ), + ), + ), + h::tr + ( + $config->inQuickon ? setClass('hidden') : null, + h::th($lang->install->dbEncoding), + h::td + ( + input + ( + set::name('dbEncoding'), + set::value($this->config->db->encoding), + ), + ), + h::td(), + ), + h::tr + ( + $config->inQuickon ? setClass('hidden') : null, + h::th($lang->install->dbUser), + h::td + ( + input + ( + set::name('dbUser'), + set::value($dbUser), + ), + ), + h::td(), + ), + h::tr + ( + $config->inQuickon ? setClass('hidden') : null, + h::th($lang->install->dbPassword), + h::td + ( + input + ( + set::name('dbPassword'), + set::value($dbPassword), + ), + ), + h::td(), + ), + h::tr + ( + h::th($lang->install->dbName), + h::td + ( + input + ( + set::name('dbName'), + set::value($dbName), + ), + ), + h::td(), + ), + h::tr + ( + h::th($lang->install->dbPrefix), + h::td + ( + input + ( + set::name('dbPrefix'), + set::value('zt_'), + ), + ), + h::td + ( + checkbox + ( + set::text($lang->install->clearDB), + set::name('clearDB'), + ), + ), + ), + ), + ), + ), + ), +); + +render('pagebase'); diff --git a/module/jenkins/control.php b/module/jenkins/control.php index 6b3db5d861..e46b78a74d 100644 --- a/module/jenkins/control.php +++ b/module/jenkins/control.php @@ -70,7 +70,7 @@ class jenkins extends control if(dao::isError()) return $this->send(array('result' => 'fail', 'message' => dao::getError())); if($this->viewType == 'json') return $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'id' => $jenkinsID)); - return $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'locate' => inlink('browse'))); + return $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'locate' => $this->createLink('space', 'browse'))); } $this->view->title = $this->lang->jenkins->common . $this->lang->colon . $this->lang->jenkins->create; diff --git a/module/sonarqube/control.php b/module/sonarqube/control.php index dae6dd7320..3e0ff91f50 100644 --- a/module/sonarqube/control.php +++ b/module/sonarqube/control.php @@ -145,7 +145,7 @@ class sonarqube extends control if(dao::isError()) return $this->send(array('result' => 'fail', 'message' => dao::getError())); $this->loadModel('action')->create('sonarqube', $sonarqubeID, 'created'); - return $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'locate' => inlink('browse'))); + return $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'locate' => $this->createLink('space', 'browse'))); } $this->view->title = $this->lang->sonarqube->common . $this->lang->colon . $this->lang->sonarqube->createServer;