Skip to content

Commit 39f6348

Browse files
committed
Enable composer autoloader and change folder structure
1 parent 4a0ab75 commit 39f6348

30 files changed

+966
-189
lines changed

web/add/webapp/index.php

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
<?php
2-
error_reporting(NULL);
32
ob_start();
43
$TAB = 'WEB';
54

65
// Main include
76
include($_SERVER['DOCUMENT_ROOT']."/inc/main.php");
7+
require_once $_SERVER['DOCUMENT_ROOT']."/src/init.php";
88

99
// Check domain argument
1010
if (empty($_GET['domain'])) {
@@ -45,10 +45,13 @@
4545

4646
// Check GET request
4747
if (!empty($_GET['app'])) {
48-
require 'installer.php';
48+
$app = basename($_GET['app']);
49+
4950
try {
50-
$hestia = new HestiaApp();
51-
$installer = new AppInstaller($_GET['app'], $v_domain, $hestia);
51+
$hestia = new \Hestia\System\HestiaApp();
52+
$app_installer_class = '\Hestia\WebApp\Installers\\' . $app . 'Setup';
53+
$app_installer = new $app_installer_class($v_domain, $hestia);
54+
$installer = new \Hestia\WebApp\AppWizard($app_installer, $v_domain, $hestia);
5255
} catch (Exception $e) {
5356
$_SESSION['error_msg'] = $e->getMessage();
5457
header('Location: /add/webapp/?domain=' . $v_domain);
@@ -58,7 +61,7 @@
5861
}
5962

6063
// Check POST request
61-
if (!empty($_POST['ok']) && !empty($_GET['app']) ) {
64+
if (!empty($_POST['ok']) && !empty($app) ) {
6265

6366
// Check token
6467
if ((!isset($_POST['token'])) || ($_SESSION['token'] != $_POST['token'])) {
@@ -70,21 +73,22 @@
7073
try{
7174
if (!$installer->execute($_POST)){
7275
$result = $installer->getStatus();
73-
$_SESSION['error_msg'] = implode(PHP_EOL, $result);
76+
if(!empty($result))
77+
$_SESSION['error_msg'] = implode(PHP_EOL, $result);
7478
} else {
75-
$_SESSION['ok_msg'] = htmlspecialchars($_GET['app']) . " App was installed succesfully !";
79+
$_SESSION['ok_msg'] = htmlspecialchars($app) . " App was installed succesfully !";
7680
header('Location: /add/webapp/?domain=' . $v_domain);
7781
exit();
7882
}
7983
} catch (Exception $e) {
80-
$_SESSION['error_msg'] = $e->getMessage();
81-
header('Location: /add/webapp/?app='.rawurlencode($_GET['app']).'&domain=' . $v_domain);
82-
exit();
84+
$_SESSION['error_msg'] = $e->getMessage();
85+
header('Location: /add/webapp/?app='.rawurlencode($app).'&domain=' . $v_domain);
86+
exit();
8387
}
8488
}
8589
}
8690

87-
if($installer) {
91+
if(!empty($installer)) {
8892
render_page($user, $TAB, 'setup_webapp');
8993
} else {
9094
render_page($user, $TAB, 'add_webapp');

web/add/webapp/installer/BaseSetup.php

Lines changed: 0 additions & 91 deletions
This file was deleted.

web/src/.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
vendor/filp
2+
vendor/psr
3+
vendor/composer/installed.json

web/src/app/Models/DnsDomain.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Hestia\Models;
6+
7+
class MailDomain extends Model
8+
{
9+
10+
}

web/src/app/Models/MailDomain.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Hestia\Models;
6+
7+
class MailDomain extends Model
8+
{
9+
10+
}

web/src/app/Models/Model.php

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Hestia\Models;
6+
7+
class Model {
8+
9+
public function __construct() {
10+
11+
}
12+
13+
public static function all()
14+
{
15+
16+
}
17+
}
18+
19+
/**
20+
* Minimal list of models required
21+
*
22+
* User
23+
*
24+
* WebDomain
25+
*
26+
* MailDomain
27+
* `-MailAccount
28+
*
29+
* DNSDomain
30+
* `-DNSRecord
31+
*
32+
* Database
33+
*
34+
*/

web/src/app/Models/User.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Hestia\Models;
6+
7+
class User extends Model
8+
{
9+
10+
}

web/src/app/Models/WebDomain.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Hestia\Models;
6+
7+
class WebDomain extends Model
8+
{
9+
10+
}

0 commit comments

Comments
 (0)