Browse Source

Merge branch 'feature/user-roles' into feature/disable-user-login

Kristan Kenney 5 years ago
parent
commit
270cc5f579

+ 1 - 0
CHANGELOG.md

@@ -45,6 +45,7 @@ All notable changes to this project will be documented in this file.
 - Disabled changing backup folder via Web UI because it used symbolic link instead of mount causing issues with restore mail / user files.
 - Fixed XSS vulnerability in `v-add-sys-ip` and user history log (thanks **@numanturle**).
 - Fixed remote code execution vulnerability which could occur when deleting SSH keys (thanks **@numanturle**).
+- Improve how Quick install of web apps are handled and allow users added apps to be maintained in list view. 
 
 ## [1.3.5] - Service Release
 ### Features

+ 14 - 13
web/add/webapp/index.php

@@ -30,24 +30,12 @@ if(!in_array($v_domain, $user_domains)) {
     exit;
 }
 
-$v_web_apps = [
-    [ 'name'=>'Wordpress', 'group'=>'cms', 'enabled'=>true, 'version'=>'latest', 'thumbnail'=>'/images/webapps/wp-thumb.png' ],
-    [ 'name'=>'Drupal',    'group'=>'cms', 'enabled'=>false,'version'=>'latest', 'thumbnail'=>'/images/webapps/drupal-thumb.png' ],
-    [ 'name'=>'Joomla',    'group'=>'cms', 'enabled'=>false,'version'=>'latest', 'thumbnail'=>'/images/webapps/joomla-thumb.png' ],
-
-    [ 'name'=>'Opencart',   'group'=>'ecommerce', 'enabled'=>true,  'version'=>'3.0.3.3', 'thumbnail'=>'/images/webapps/opencart-thumb.png' ],
-    [ 'name'=>'Prestashop', 'group'=>'ecommerce', 'enabled'=>true, 'version'=>'1.7.7.1', 'thumbnail'=>'/images/webapps/prestashop-thumb.png' ],
-
-    [ 'name'=>'Laravel', 'group'=>'starter', 'enabled'=>true, 'version'=>'7.x', 'thumbnail'=>'/images/webapps/laravel-thumb.png' ],
-    [ 'name'=>'Symfony', 'group'=>'starter', 'enabled'=>true, 'version'=>'4.3.x', 'thumbnail'=>'/images/webapps/symfony-thumb.png' ],
-];
-
 // Check GET request
 if (!empty($_GET['app'])) {
     $app = basename($_GET['app']);
     
     $hestia = new \Hestia\System\HestiaApp();
-    $app_installer_class = '\Hestia\WebApp\Installers\\' . $app . 'Setup';
+    $app_installer_class = '\Hestia\WebApp\Installers\\'.$app.'\\' . $app . 'Setup';
     if(class_exists($app_installer_class)) {
         try {
             $app_installer = new $app_installer_class($v_domain, $hestia);
@@ -94,6 +82,19 @@ if (!empty($_POST['ok']) && !empty($app) ) {
 if(!empty($installer)) {
     render_page($user, $TAB, 'setup_webapp');
 } else {
+    $appInstallers = glob(__DIR__.'/../../src/app/WebApp/Installers/*/*.php');
+    $v_web_apps = array();
+    foreach($appInstallers as $app){
+        $hestia = new \Hestia\System\HestiaApp();
+        if( preg_match('/Installers\/([a-zA-Z0-0].*)\/([a-zA-Z0-0].*).php/', $app, $matches)){
+            if ($matches[1] != "Resources"){
+                $app_installer_class = '\Hestia\WebApp\Installers\\'.$matches[1].'\\' . $matches[1] . 'Setup';
+                $app_installer = new $app_installer_class($v_domain, $hestia);
+                $v_web_apps[] = $app_installer -> info();
+                
+            }
+        }
+    }
     render_page($user, $TAB, 'list_webapps');
 }
 

BIN
web/images/webapps/joomla-thumb.jpg


BIN
web/images/webapps/magento-thumb.png


+ 4 - 1
web/src/app/WebApp/Installers/BaseSetup.php

@@ -14,7 +14,10 @@ abstract class BaseSetup implements InstallerInterface {
 
     protected $domain;
     protected $extractsubdir;
-
+    
+    public function info(){
+        return $this -> appInfo;
+    }
     public function __construct($domain, HestiaApp $appcontext)
     {
         if(filter_var($domain, FILTER_VALIDATE_DOMAIN) === false) {

+ 32 - 0
web/src/app/WebApp/Installers/Drupal/DrupalSetup.php

@@ -0,0 +1,32 @@
+<?php
+
+namespace Hestia\WebApp\Installers\Drupal;
+
+use \Hestia\WebApp\Installers\BaseSetup as BaseSetup;
+
+class DrupalSetup extends BaseSetup {
+
+    protected $appname = 'drupal';
+    
+    protected $appInfo = [ 
+        'name' => 'Drupal',
+        'group' => 'cms',
+        'enabled' => false,
+        'version' => 'latest',
+        'thumbnail' => 'drupal-thumb.png'
+    ];
+    
+    protected $config = [
+        'form' => [
+        ],
+        'database' => true,
+        'resources' => [
+           
+        ],
+    ];
+
+    public function install(array $options=null) : bool
+    {
+        exit( "Installer missing" );
+    }
+}

+ 0 - 0
web/images/webapps/drupal-thumb.png → web/src/app/WebApp/Installers/Drupal/drupal-thumb.png


+ 32 - 0
web/src/app/WebApp/Installers/Joomla/JoomlaSetup.php

@@ -0,0 +1,32 @@
+<?php
+
+namespace Hestia\WebApp\Installers\Joomla;
+
+use \Hestia\WebApp\Installers\BaseSetup as BaseSetup;
+
+class JoomlaSetup extends BaseSetup {
+
+    protected $appname = 'joomla';
+    
+    protected $appInfo = [ 
+        'name' => 'Joomla',
+        'group' => 'cms',
+        'enabled' => false,
+        'version' => 'latest',
+        'thumbnail' => 'joomla-thumb.png'
+    ];
+    
+    protected $config = [
+        'form' => [
+        ],
+        'database' => true,
+        'resources' => [
+        
+        ],
+    ];
+
+    public function install(array $options=null) : bool
+    {
+        exit( "Installer missing" );
+    }
+}

+ 0 - 0
web/images/webapps/joomla-thumb.png → web/src/app/WebApp/Installers/Joomla/joomla-thumb.png


+ 12 - 2
web/src/app/WebApp/Installers/LaravelSetup.php → web/src/app/WebApp/Installers/Laravel/LaravelSetup.php

@@ -1,11 +1,21 @@
 <?php
 
-namespace Hestia\WebApp\Installers;
+namespace Hestia\WebApp\Installers\Laravel;
+
+use \Hestia\WebApp\Installers\BaseSetup as BaseSetup;
 
 class LaravelSetup extends BaseSetup {
 
     protected $appname = 'laravel';
-
+    
+    protected $appInfo = [ 
+        'name' => 'Laravel',
+        'group' => 'framework',
+        'enabled' => true,
+        'version' => '7.x',
+        'thumbnail' => 'laravel-thumb.png'
+    ];
+    
     protected $config = [
         'form' => [
         ],

+ 0 - 0
web/images/webapps/laravel-thumb.png → web/src/app/WebApp/Installers/Laravel/laravel-thumb.png


+ 12 - 2
web/src/app/WebApp/Installers/OpencartSetup.php → web/src/app/WebApp/Installers/Opencart/OpencartSetup.php

@@ -1,9 +1,19 @@
 <?php
 
-namespace Hestia\WebApp\Installers;
+namespace Hestia\WebApp\Installers\Opencart;
+
+use \Hestia\WebApp\Installers\BaseSetup as BaseSetup;
 
 class OpencartSetup extends BaseSetup {
 
+    protected $appInfo = [ 
+        'name' => 'Opencart',
+        'group' => 'ecommerce',
+        'enabled' => true,
+        'version' => '3.0.3.3',
+        'thumbnail' => 'opencart-thumb.png'
+    ];
+    
     protected $appname = 'opencart';
     protected $extractsubdir="/tmp-opencart";
 
@@ -18,7 +28,7 @@ class OpencartSetup extends BaseSetup {
             'archive'  => [ 'src' => 'https://github.com/opencart/opencart/releases/download/3.0.3.3/opencart-3.0.3.3.zip' ],
         ],
     ];
-
+    
     public function install(array $options = null) : bool
     {
         parent::install($options);

+ 0 - 0
web/images/webapps/opencart-thumb.png → web/src/app/WebApp/Installers/Opencart/opencart-thumb.png


+ 11 - 1
web/src/app/WebApp/Installers/PrestashopSetup.php → web/src/app/WebApp/Installers/Prestashop/PrestashopSetup.php

@@ -1,9 +1,19 @@
 <?php
 
-namespace Hestia\WebApp\Installers;
+namespace Hestia\WebApp\Installers\Prestashop;
+
+use \Hestia\WebApp\Installers\BaseSetup as BaseSetup;
 
 class PrestashopSetup extends BaseSetup {
 
+    protected $appInfo = [ 
+        'name' => 'Prestashop',
+        'group' => 'ecommerce',
+        'enabled' => true,
+        'version' => '1.7.7.1',
+        'thumbnail' => 'prestashop-thumb.png'
+    ];
+    
     protected $appname = 'prestashop';
     protected $extractsubdir="/tmp-prestashop";
 

+ 0 - 0
web/images/webapps/prestashop-thumb.png → web/src/app/WebApp/Installers/Prestashop/prestashop-thumb.png


+ 12 - 2
web/src/app/WebApp/Installers/SymfonySetup.php → web/src/app/WebApp/Installers/Symfony/SymfonySetup.php

@@ -1,9 +1,19 @@
 <?php
 
-namespace Hestia\WebApp\Installers;
+namespace Hestia\WebApp\Installers\Symfony;
 
-class SymfonySetup extends BaseSetup {
+use \Hestia\WebApp\Installers\BaseSetup as BaseSetup;
 
+class SymfonySetup extends BaseSetup {
+    
+    protected $appInfo = [ 
+        'name' => 'Symfony',
+        'group' => 'framework',
+        'enabled' => true,
+        'version' => '5.2',
+        'thumbnail' => 'symfony-thumb.png'
+    ];
+    
     protected $appname = 'symfony';
 
     protected $config = [

+ 0 - 0
web/images/webapps/symfony-thumb.png → web/src/app/WebApp/Installers/Symfony/symfony-thumb.png


+ 11 - 2
web/src/app/WebApp/Installers/WordpressSetup.php → web/src/app/WebApp/Installers/Wordpress/WordpressSetup.php

@@ -1,11 +1,20 @@
 <?php
 
-namespace Hestia\WebApp\Installers;
+namespace Hestia\WebApp\Installers\Wordpress;
 
 use Hestia\System\Util;
+use \Hestia\WebApp\Installers\BaseSetup as BaseSetup;
 
 class WordpressSetup extends BaseSetup {
 
+    protected $appInfo = [ 
+        'name' => 'Wordpress',
+        'group' => 'cms',
+        'enabled' => true,
+        'version' => 'latest',
+        'thumbnail' => 'wp-thumb.png'
+    ];
+    
     protected $appname = 'wordpress';
     protected $config = [
         'form' => [
@@ -25,7 +34,7 @@ class WordpressSetup extends BaseSetup {
         ],
         
     ];
-
+    
     public function install(array $options = null)
     {
         parent::install($options);

+ 0 - 0
web/images/webapps/wp-thumb.png → web/src/app/WebApp/Installers/Wordpress/wp-thumb.png


+ 4 - 4
web/templates/pages/list_webapps.html

@@ -40,11 +40,11 @@
         <div class="app-list cards">
             <?php foreach($v_web_apps as $webapp):?>
                 <div class="card <?=($webapp['enabled']?'':'disable')?>" >
-                    <span class="card-thumb"><img src="<?=$webapp['thumbnail']?>"></span>
+                    <span class="card-thumb"><img src="/src/app/WebApp/Installers/<?=$webapp['name'];?>/<?=$webapp['thumbnail'];?>"></span>
                     <div class="card-details">
-                        <p class="card-title"><?=$webapp['name']?></p>
-                        <p><?=_('version')?>: <?=$webapp['version']?></p>
-                        <a href="/add/webapp/?app=<?=$webapp['name']?>&domain=<?=$v_domain?>" class="ui-button cancel" dir="ltr"><?=_('Setup')?></a>
+                        <p class="card-title"><?=$webapp['name'];?></p>
+                        <p><?=_('version')?>: <?=$webapp['version'];?></p>
+                        <a href="/add/webapp/?app=<?=$webapp['name'];?>&domain=<?=$v_domain?>" class="ui-button cancel" dir="ltr"><?=_('Setup')?></a>
                     </div>
                 </div>
             <?php endforeach; ?>