Просмотр исходного кода

#2444 [Bug] "Error" Adding database + #1092 (#2638)

* Add extra check to see if user is allowed to create a DB

* Fix #1092  remove traces left behind
Jaap Marcus 3 лет назад
Родитель
Сommit
664e240304

+ 18 - 2
web/src/app/System/HestiaApp.php

@@ -160,6 +160,16 @@ class HestiaApp
         return $this->runUser('v-list-web-domain', [$domain, 'json']);
     }
 
+    public function checkDatabaseLimit(){
+        $status = $this -> runUser('v-list-user', ['json'], $result);
+        $result -> json[$this -> user()];
+        if($result -> json[$this -> user()]['DATABASES'] != "unlimited" ){
+            if($result -> json[$this -> user()]['DATABASES'] - $result -> json[$this -> user()]['U_DATABASES'] < 1){
+                return false;
+            } 
+        } 
+        return true;
+    }
     public function databaseAdd(string $dbname, string $dbuser, string $dbpass, string $charset = 'utf8mb4')
     {
         $v_password = tempnam("/tmp", "hst");
@@ -167,6 +177,9 @@ class HestiaApp
         fwrite($fp, $dbpass."\n");
         fclose($fp);
         $status = $this->runUser('v-add-database', [$dbname, $dbuser, $v_password, 'mysql', 'localhost', $charset]);
+        if(!$status){
+            $this->errors[] = _('Unable to add databse!');
+        }
         unlink($v_password);
         return $status;
     }
@@ -267,7 +280,10 @@ class HestiaApp
             }
             $archive_file = $download_result->file;
         }
-
-        return $this->runUser('v-extract-fs-archive', [$archive_file, $path, null, $skip_components]);
+        
+        $result = $this->runUser('v-extract-fs-archive', [$archive_file, $path, null, $skip_components]);
+        unlink($archive_file);
+        
+        return $result;
     }
 }

+ 5 - 0
web/src/app/WebApp/AppWizard.php

@@ -100,6 +100,11 @@ class AppWizard {
             if(empty($options['database_password'])) {
                 $options['database_password'] = bin2hex(random_bytes(10));
             }
+            
+            if(!$this->appcontext->checkDatabaseLimit()) {
+                $this->errors[] = _('Unable to add databse! Limit reached!');
+                return false;
+            }
 
             if(!$this->appcontext->databaseAdd($options['database_name'], $options['database_user'], $options['database_password'])) {
                 $this->errors[] = "Error adding database";

+ 2 - 2
web/src/app/WebApp/Installers/MediaWiki/MediaWikiSetup.php

@@ -27,7 +27,7 @@ class MediaWikiSetup extends BaseSetup
             ],
         'database' => true,
         'resources' => [
-            'archive'  => [ 'src' => 'https://releases.wikimedia.org/mediawiki/1.37/mediawiki-1.37.1.zip' ],
+            'archive'  => [ 'src' => 'https://releases.wikimedia.org/mediawiki/1.37/mediawiki-1.37.2.zip' ],
         ],
         'server' => [
             'nginx' => [
@@ -56,7 +56,7 @@ class MediaWikiSetup extends BaseSetup
         $webDomain = ($sslEnabled ? "https://" : "http://") . $this->domain . "/";
 
         $this->appcontext->runUser('v-copy-fs-directory', [
-            $this->getDocRoot($this->extractsubdir . "/mediawiki-1.36.1/."),
+            $this->getDocRoot($this->extractsubdir . "/mediawiki-1.37.2/."),
             $this->getDocRoot()], $result);
         $php_version = $this -> appcontext -> getSupportedPHP($this -> config['server']['php']['supported']);
         $this->appcontext->runUser('v-run-cli-cmd', ["/usr/bin/php$php_version",

+ 3 - 3
web/src/app/WebApp/Installers/Nextcloud/NextcloudSetup.php

@@ -10,7 +10,7 @@ class NextcloudSetup extends BaseSetup
         'name' => 'Nextcloud',
         'group' => 'cloud',
         'enabled' => true,
-        'version' => '23.0.2',
+        'version' => 'latest',
         'thumbnail' => 'nextcloud-thumb.png'
     ];
 
@@ -23,14 +23,14 @@ class NextcloudSetup extends BaseSetup
             ],
         'database' => true,
         'resources' => [
-            'archive'  => [ 'src' => 'https://download.nextcloud.com/server/releases/nextcloud-23.0.2.tar.bz2' ]
+            'archive'  => [ 'src' => 'https://download.nextcloud.com/server/releases/latest.tar.bz2' ]
         ],
         'server' => [
             'nginx' => [
                 'template' => 'owncloud'
             ],
             'php' => [ 
-                'supported' => [ '7.3','7.4','8.0' ],
+                'supported' => [ '7.3','7.4','8.0','8.1' ],
             ]
         ], 
     ];

+ 3 - 3
web/src/app/WebApp/Installers/Opencart/OpencartSetup.php

@@ -10,7 +10,7 @@ class OpencartSetup extends BaseSetup
         'name' => 'Opencart',
         'group' => 'ecommerce',
         'enabled' => true,
-        'version' => '3.0.3.8',
+        'version' => '4.0.0.0',
         'thumbnail' => 'opencart-thumb.png'
     ];
 
@@ -25,14 +25,14 @@ class OpencartSetup extends BaseSetup
             ],
         'database' => true,
         'resources' => [
-            'archive'  => [ 'src' => 'https://github.com/opencart/opencart/releases/download/3.0.3.8/opencart-3.0.3.8.zip' ],
+            'archive'  => [ 'src' => 'https://github.com/opencart/opencart/releases/download/4.0.0.0/opencart-4.0.0.0.zip' ],
         ],
         'server' => [
             'nginx' => [
                 'template' => 'opencart'
             ],
             'php' => [ 
-                'supported' => [ '7.3','7.4' ],
+                'supported' => [ '7.4','8.0','8.1' ],
             ]
         ], 
     ];

+ 2 - 2
web/src/app/WebApp/Installers/Prestashop/PrestashopSetup.php

@@ -10,7 +10,7 @@ class PrestashopSetup extends BaseSetup
         'name' => 'Prestashop',
         'group' => 'ecommerce',
         'enabled' => true,
-        'version' => '1.7.8.4',
+        'version' => '1.7.8.6',
         'thumbnail' => 'prestashop-thumb.png'
     ];
 
@@ -26,7 +26,7 @@ class PrestashopSetup extends BaseSetup
             ],
         'database' => true,
         'resources' => [
-            'archive'  => [ 'src' => 'https://github.com/PrestaShop/PrestaShop/releases/download/1.7.8.4/prestashop_1.7.8.4.zip' ],
+            'archive'  => [ 'src' => 'https://github.com/PrestaShop/PrestaShop/releases/download/1.7.8.6/prestashop_1.7.8.6.zip' ],
         ],
         'server' => [
             'nginx' => [