Skip to content

Commit 664e240

Browse files
authored
hestiacp#2444 [Bug] "Error" Adding database + hestiacp#1092 (hestiacp#2638)
* Add extra check to see if user is allowed to create a DB * Fix hestiacp#1092 remove traces left behind
1 parent f6aaaea commit 664e240

File tree

6 files changed

+33
-12
lines changed

6 files changed

+33
-12
lines changed

web/src/app/System/HestiaApp.php

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,13 +160,26 @@ public function userOwnsDomain(string $domain): bool
160160
return $this->runUser('v-list-web-domain', [$domain, 'json']);
161161
}
162162

163+
public function checkDatabaseLimit(){
164+
$status = $this -> runUser('v-list-user', ['json'], $result);
165+
$result -> json[$this -> user()];
166+
if($result -> json[$this -> user()]['DATABASES'] != "unlimited" ){
167+
if($result -> json[$this -> user()]['DATABASES'] - $result -> json[$this -> user()]['U_DATABASES'] < 1){
168+
return false;
169+
}
170+
}
171+
return true;
172+
}
163173
public function databaseAdd(string $dbname, string $dbuser, string $dbpass, string $charset = 'utf8mb4')
164174
{
165175
$v_password = tempnam("/tmp", "hst");
166176
$fp = fopen($v_password, "w");
167177
fwrite($fp, $dbpass."\n");
168178
fclose($fp);
169179
$status = $this->runUser('v-add-database', [$dbname, $dbuser, $v_password, 'mysql', 'localhost', $charset]);
180+
if(!$status){
181+
$this->errors[] = _('Unable to add databse!');
182+
}
170183
unlink($v_password);
171184
return $status;
172185
}
@@ -267,7 +280,10 @@ public function archiveExtract(string $src, string $path, $skip_components=null)
267280
}
268281
$archive_file = $download_result->file;
269282
}
270-
271-
return $this->runUser('v-extract-fs-archive', [$archive_file, $path, null, $skip_components]);
283+
284+
$result = $this->runUser('v-extract-fs-archive', [$archive_file, $path, null, $skip_components]);
285+
unlink($archive_file);
286+
287+
return $result;
272288
}
273289
}

web/src/app/WebApp/AppWizard.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,11 @@ public function execute(array $options)
100100
if(empty($options['database_password'])) {
101101
$options['database_password'] = bin2hex(random_bytes(10));
102102
}
103+
104+
if(!$this->appcontext->checkDatabaseLimit()) {
105+
$this->errors[] = _('Unable to add databse! Limit reached!');
106+
return false;
107+
}
103108

104109
if(!$this->appcontext->databaseAdd($options['database_name'], $options['database_user'], $options['database_password'])) {
105110
$this->errors[] = "Error adding database";

web/src/app/WebApp/Installers/MediaWiki/MediaWikiSetup.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class MediaWikiSetup extends BaseSetup
2727
],
2828
'database' => true,
2929
'resources' => [
30-
'archive' => [ 'src' => 'https://releases.wikimedia.org/mediawiki/1.37/mediawiki-1.37.1.zip' ],
30+
'archive' => [ 'src' => 'https://releases.wikimedia.org/mediawiki/1.37/mediawiki-1.37.2.zip' ],
3131
],
3232
'server' => [
3333
'nginx' => [
@@ -56,7 +56,7 @@ public function install(array $options = null)
5656
$webDomain = ($sslEnabled ? "https://" : "http://") . $this->domain . "/";
5757

5858
$this->appcontext->runUser('v-copy-fs-directory', [
59-
$this->getDocRoot($this->extractsubdir . "/mediawiki-1.36.1/."),
59+
$this->getDocRoot($this->extractsubdir . "/mediawiki-1.37.2/."),
6060
$this->getDocRoot()], $result);
6161
$php_version = $this -> appcontext -> getSupportedPHP($this -> config['server']['php']['supported']);
6262
$this->appcontext->runUser('v-run-cli-cmd', ["/usr/bin/php$php_version",

web/src/app/WebApp/Installers/Nextcloud/NextcloudSetup.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ class NextcloudSetup extends BaseSetup
1010
'name' => 'Nextcloud',
1111
'group' => 'cloud',
1212
'enabled' => true,
13-
'version' => '23.0.2',
13+
'version' => 'latest',
1414
'thumbnail' => 'nextcloud-thumb.png'
1515
];
1616

@@ -23,14 +23,14 @@ class NextcloudSetup extends BaseSetup
2323
],
2424
'database' => true,
2525
'resources' => [
26-
'archive' => [ 'src' => 'https://download.nextcloud.com/server/releases/nextcloud-23.0.2.tar.bz2' ]
26+
'archive' => [ 'src' => 'https://download.nextcloud.com/server/releases/latest.tar.bz2' ]
2727
],
2828
'server' => [
2929
'nginx' => [
3030
'template' => 'owncloud'
3131
],
3232
'php' => [
33-
'supported' => [ '7.3','7.4','8.0' ],
33+
'supported' => [ '7.3','7.4','8.0','8.1' ],
3434
]
3535
],
3636
];

web/src/app/WebApp/Installers/Opencart/OpencartSetup.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ class OpencartSetup extends BaseSetup
1010
'name' => 'Opencart',
1111
'group' => 'ecommerce',
1212
'enabled' => true,
13-
'version' => '3.0.3.8',
13+
'version' => '4.0.0.0',
1414
'thumbnail' => 'opencart-thumb.png'
1515
];
1616

@@ -25,14 +25,14 @@ class OpencartSetup extends BaseSetup
2525
],
2626
'database' => true,
2727
'resources' => [
28-
'archive' => [ 'src' => 'https://github.com/opencart/opencart/releases/download/3.0.3.8/opencart-3.0.3.8.zip' ],
28+
'archive' => [ 'src' => 'https://github.com/opencart/opencart/releases/download/4.0.0.0/opencart-4.0.0.0.zip' ],
2929
],
3030
'server' => [
3131
'nginx' => [
3232
'template' => 'opencart'
3333
],
3434
'php' => [
35-
'supported' => [ '7.3','7.4' ],
35+
'supported' => [ '7.4','8.0','8.1' ],
3636
]
3737
],
3838
];

web/src/app/WebApp/Installers/Prestashop/PrestashopSetup.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ class PrestashopSetup extends BaseSetup
1010
'name' => 'Prestashop',
1111
'group' => 'ecommerce',
1212
'enabled' => true,
13-
'version' => '1.7.8.4',
13+
'version' => '1.7.8.6',
1414
'thumbnail' => 'prestashop-thumb.png'
1515
];
1616

@@ -26,7 +26,7 @@ class PrestashopSetup extends BaseSetup
2626
],
2727
'database' => true,
2828
'resources' => [
29-
'archive' => [ 'src' => 'https://github.com/PrestaShop/PrestaShop/releases/download/1.7.8.4/prestashop_1.7.8.4.zip' ],
29+
'archive' => [ 'src' => 'https://github.com/PrestaShop/PrestaShop/releases/download/1.7.8.6/prestashop_1.7.8.6.zip' ],
3030
],
3131
'server' => [
3232
'nginx' => [

0 commit comments

Comments
 (0)