diff --git a/web/add/cron/index.php b/web/add/cron/index.php index 62cae8f1c..9280f25e3 100644 --- a/web/add/cron/index.php +++ b/web/add/cron/index.php @@ -1,10 +1,9 @@ diff --git a/web/add/dns/index.php b/web/add/dns/index.php index bd890c875..ec9dcbfcf 100644 --- a/web/add/dns/index.php +++ b/web/add/dns/index.php @@ -1,10 +1,9 @@ $value) { $_SESSION[$key] = $value; } -// Header -include($_SERVER['DOCUMENT_ROOT'].'/templates/header.html'); - -// Panel -top_panel($user,$TAB); - -// Display body -include($_SERVER['DOCUMENT_ROOT'].'/templates/admin/edit_server.html'); +// Render page +render_page($user, $TAB, 'admin/edit_server'); // Flush session messages unset($_SESSION['error_msg']); unset($_SESSION['ok_msg']); - -// Footer -include($_SERVER['DOCUMENT_ROOT'].'/templates/footer.html'); diff --git a/web/edit/user/index.php b/web/edit/user/index.php index 2fbd526a5..3c2288e13 100644 --- a/web/edit/user/index.php +++ b/web/edit/user/index.php @@ -1,10 +1,9 @@ ', $output); if (empty($error)) $error = __('Error code:',$return_var); $_SESSION['error_msg'] = $error; - include($_SERVER['DOCUMENT_ROOT'].'/templates/admin/generate_ssl.html'); - include($_SERVER['DOCUMENT_ROOT'].'/templates/footer.html'); + render_page($user, $TAB, 'admin/generate_ssl'); unset($_SESSION['error_msg']); - exit(); + exit; } // OK message @@ -106,6 +97,7 @@ $v_csr = $data[$v_domain]['CSR']; // Back uri $_SESSION['back'] = $_SERVER['REQUEST_URI']; -include($_SERVER['DOCUMENT_ROOT'].'/templates/admin/list_ssl.html'); -include($_SERVER['DOCUMENT_ROOT'].'/templates/footer.html'); +// Render page +render_page($user, $TAB, 'admin/list_ssl'); + unset($_SESSION['ok_msg']); diff --git a/web/inc/main.php b/web/inc/main.php index 4df0ece95..f3f96b872 100644 --- a/web/inc/main.php +++ b/web/inc/main.php @@ -95,6 +95,33 @@ function check_return_code($return_var,$output) { } } +function render_page($user, $TAB, $page) { + $__template_dir = dirname(__DIR__) . '/templates/'; + $__template_base = $__template_dir . str_replace('*', $_SESSION['user'] === 'admin' ? 'admin' : 'user', $page); + + // Header + include($__template_dir . 'header.html'); + + // Panel + top_panel(empty($_SESSION['look']) ? $_SESSION['user'] : $_SESSION['look'], $TAB); + + // Extarct global variables + // I think those variables should be passed via arguments + //* + extract($GLOBALS, EXTR_SKIP); + /*/ + $variables = array_filter($GLOBALS, function($key){return preg_match('/^(v_|[a-z])[a-z\d]+$/', $key);}, ARRAY_FILTER_USE_KEY); + extract($variables, EXTR_OVERWRITE); + //*/ + + // Body + @include($__template_base . '.html'); + + // Footer + $JS_FILE = $__template_base . '.js.html'; + include($__template_dir . 'footer.html'); +} + function top_panel($user, $TAB) { global $panel; $command = VESTA_CMD."v-list-user '".$user."' 'json'"; @@ -107,7 +134,7 @@ function top_panel($user, $TAB) { unset($output); - // getting notifications + // getting notifications $command = VESTA_CMD."v-list-user-notifications '".$user."' 'json'"; exec ($command, $output, $return_var); $notifications = json_decode(implode('', $output), true); @@ -118,7 +145,7 @@ function top_panel($user, $TAB) { } } unset($output); - + if ( $user == 'admin' ) { include(dirname(__FILE__).'/../templates/admin/panel.html'); diff --git a/web/list/backup/exclusions/index.php b/web/list/backup/exclusions/index.php index d03e98614..c533129cb 100644 --- a/web/list/backup/exclusions/index.php +++ b/web/list/backup/exclusions/index.php @@ -3,22 +3,15 @@ error_reporting(NULL); $TAB = 'BACKUP'; // Main include -include($_SERVER['DOCUMENT_ROOT']."/inc/main.php"); - -// Header -include($_SERVER['DOCUMENT_ROOT'].'/templates/header.html'); - -// Panel -top_panel($user,$TAB); +include($_SERVER['DOCUMENT_ROOT'].'/inc/main.php'); // Data exec (VESTA_CMD."v-list-user-backup-exclusions $user json", $output, $return_var); $data = json_decode(implode('', $output), true); unset($output); -include($_SERVER['DOCUMENT_ROOT'].'/templates/admin/list_backup_exclusions.html'); + +// Render page +render_page($user, $TAB, 'admin/list_backup_exclusions'); // Back uri $_SESSION['back'] = $_SERVER['REQUEST_URI']; - -// Footer -include($_SERVER['DOCUMENT_ROOT'].'/templates/footer.html'); diff --git a/web/list/backup/index.php b/web/list/backup/index.php index a79205724..b25284eb1 100644 --- a/web/list/backup/index.php +++ b/web/list/backup/index.php @@ -3,31 +3,24 @@ error_reporting(NULL); $TAB = 'BACKUP'; // Main include -include($_SERVER['DOCUMENT_ROOT']."/inc/main.php"); +include($_SERVER['DOCUMENT_ROOT'].'/inc/main.php'); -// Header -include($_SERVER['DOCUMENT_ROOT'].'/templates/header.html'); - -// Panel -top_panel($user,$TAB); - -// Data +// Data & Render page if (empty($_GET['backup'])){ exec (VESTA_CMD."v-list-user-backups $user json", $output, $return_var); $data = json_decode(implode('', $output), true); $data = array_reverse($data,true); unset($output); - include($_SERVER['DOCUMENT_ROOT'].'/templates/admin/list_backup.html'); + + render_page($user, $TAB, 'admin/list_backup'); } else { - exec (VESTA_CMD."v-list-user-backup $user '".escapeshellarg($_GET['backup'])."' json", $output, $return_var); + exec (VESTA_CMD."v-list-user-backup $user ".escapeshellarg($_GET['backup'])." json", $output, $return_var); $data = json_decode(implode('', $output), true); $data = array_reverse($data,true); unset($output); - include($_SERVER['DOCUMENT_ROOT'].'/templates/admin/list_backup_detail.html'); + + render_page($user, $TAB, 'admin/list_backup_detail'); } // Back uri $_SESSION['back'] = $_SERVER['REQUEST_URI']; - -// Footer -include($_SERVER['DOCUMENT_ROOT'].'/templates/footer.html'); diff --git a/web/list/cron/index.php b/web/list/cron/index.php index 19f66379c..5461ba0bf 100644 --- a/web/list/cron/index.php +++ b/web/list/cron/index.php @@ -1,16 +1,9 @@ - +
@@ -68,7 +49,7 @@ |
- + |
- + |
- + |
- + |
- + |
- + |