|
1 | 1 | <?php |
2 | | -error_reporting(NULL); |
3 | 2 | ob_start(); |
4 | 3 | $TAB = 'WEB'; |
5 | 4 |
|
6 | 5 | // Main include |
7 | 6 | include($_SERVER['DOCUMENT_ROOT']."/inc/main.php"); |
| 7 | +require_once $_SERVER['DOCUMENT_ROOT']."/src/init.php"; |
8 | 8 |
|
9 | 9 | // Check domain argument |
10 | 10 | if (empty($_GET['domain'])) { |
|
45 | 45 |
|
46 | 46 | // Check GET request |
47 | 47 | if (!empty($_GET['app'])) { |
48 | | - require 'installer.php'; |
| 48 | + $app = basename($_GET['app']); |
| 49 | + |
49 | 50 | 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); |
52 | 55 | } catch (Exception $e) { |
53 | 56 | $_SESSION['error_msg'] = $e->getMessage(); |
54 | 57 | header('Location: /add/webapp/?domain=' . $v_domain); |
|
58 | 61 | } |
59 | 62 |
|
60 | 63 | // Check POST request |
61 | | -if (!empty($_POST['ok']) && !empty($_GET['app']) ) { |
| 64 | +if (!empty($_POST['ok']) && !empty($app) ) { |
62 | 65 |
|
63 | 66 | // Check token |
64 | 67 | if ((!isset($_POST['token'])) || ($_SESSION['token'] != $_POST['token'])) { |
|
70 | 73 | try{ |
71 | 74 | if (!$installer->execute($_POST)){ |
72 | 75 | $result = $installer->getStatus(); |
73 | | - $_SESSION['error_msg'] = implode(PHP_EOL, $result); |
| 76 | + if(!empty($result)) |
| 77 | + $_SESSION['error_msg'] = implode(PHP_EOL, $result); |
74 | 78 | } else { |
75 | | - $_SESSION['ok_msg'] = htmlspecialchars($_GET['app']) . " App was installed succesfully !"; |
| 79 | + $_SESSION['ok_msg'] = htmlspecialchars($app) . " App was installed succesfully !"; |
76 | 80 | header('Location: /add/webapp/?domain=' . $v_domain); |
77 | 81 | exit(); |
78 | 82 | } |
79 | 83 | } 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(); |
83 | 87 | } |
84 | 88 | } |
85 | 89 | } |
86 | 90 |
|
87 | | -if($installer) { |
| 91 | +if(!empty($installer)) { |
88 | 92 | render_page($user, $TAB, 'setup_webapp'); |
89 | 93 | } else { |
90 | 94 | render_page($user, $TAB, 'add_webapp'); |
|
0 commit comments