mirror of
https://github.com/serghey-rodin/vesta.git
synced 2025-08-21 05:44:07 -07:00
Integrated new api interface.
This commit is contained in:
parent
4a9bfc94ad
commit
4306a4fb4f
116 changed files with 10371 additions and 0 deletions
77
web/api/v1/list/backup/index.php
Normal file
77
web/api/v1/list/backup/index.php
Normal file
|
@ -0,0 +1,77 @@
|
|||
<?php
|
||||
error_reporting(NULL);
|
||||
$TAB = 'BACKUP';
|
||||
header('Content-Type: application/json');
|
||||
|
||||
// Main include
|
||||
include($_SERVER['DOCUMENT_ROOT'].'/inc/main.php');
|
||||
top_panel(empty($_SESSION['look']) ? $_SESSION['user'] : $_SESSION['look'], $TAB);
|
||||
|
||||
// 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);
|
||||
|
||||
// render_page($user, $TAB, 'list_backup');
|
||||
} else {
|
||||
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);
|
||||
|
||||
// render_page($user, $TAB, 'list_backup_detail');
|
||||
}
|
||||
|
||||
$backup = $_GET['backup'];
|
||||
|
||||
foreach ($data as $key => $value) {
|
||||
++$i;
|
||||
$web = __('no');
|
||||
$dns = __('no');
|
||||
$mail = __('no');
|
||||
$db = __('no');
|
||||
$cron = __('no');
|
||||
$udir = __('no');
|
||||
|
||||
if (!empty($data[$key]['WEB'])) $web = __('yes');
|
||||
if (!empty($data[$key]['DNS'])) $dns = __('yes');
|
||||
if (!empty($data[$key]['MAIL'])) $mail = __('yes');
|
||||
if (!empty($data[$key]['DB'])) $db = __('yes');
|
||||
if (!empty($data[$key]['CRON'])) $cron = __('yes');
|
||||
if (!empty($data[$key]['UDIR'])) $udir = __('yes');
|
||||
|
||||
$data[$key]['delete_conf'] = __('DELETE_BACKUP_CONFIRMATION', $key);
|
||||
|
||||
if (empty($_GET['backup'])){
|
||||
if ( $i == 1) {
|
||||
$total_amount = __('1 archive');
|
||||
} else {
|
||||
$total_amount = __('%s archives',$i);
|
||||
}
|
||||
} else {
|
||||
$webAr = explode(',',$data[$backup]['WEB']);
|
||||
$dnsAr = explode(',',$data[$backup]['DNS']);
|
||||
$mailAr = explode(',',$data[$backup]['MAIL']);
|
||||
$dbAr = explode(',',$data[$backup]['DB']);
|
||||
$cronAr = explode(',',$data[$backup]['CRON']);
|
||||
$udirAr = explode(',',$data[$backup]['UDIR']);
|
||||
|
||||
$totalLength = count($webAr) + count($dnsAr) + count($mailAr) + count($dbAr) + count($cronAr) + count($udirAr);
|
||||
|
||||
$total_amount = __('%s items', $totalLength);
|
||||
}
|
||||
}
|
||||
|
||||
// Back uri
|
||||
$_SESSION['back'] = $_SERVER['REQUEST_URI'];
|
||||
|
||||
$object = (object)[];
|
||||
$object->data = $data;
|
||||
$object->user = $user;
|
||||
$object->panel = $panel;
|
||||
$object->totalAmount = $total_amount;
|
||||
$object->backup_fav = $_SESSION['favourites']['BACKUP'];
|
||||
|
||||
print json_encode($object);
|
59
web/api/v1/list/cron/index.php
Normal file
59
web/api/v1/list/cron/index.php
Normal file
|
@ -0,0 +1,59 @@
|
|||
<?php
|
||||
error_reporting(NULL);
|
||||
$TAB = 'CRON';
|
||||
header('Content-Type: application/json');
|
||||
|
||||
// Main include
|
||||
include($_SERVER['DOCUMENT_ROOT'].'/inc/main.php');
|
||||
|
||||
top_panel(empty($_SESSION['look']) ? $_SESSION['user'] : $_SESSION['look'], $TAB);
|
||||
|
||||
// Data
|
||||
exec (VESTA_CMD."v-list-cron-jobs $user json", $output, $return_var);
|
||||
$data = json_decode(implode('', $output), true);
|
||||
$data = array_reverse($data,true);
|
||||
unset($output);
|
||||
|
||||
// Render page
|
||||
// render_page($user, $TAB, 'list_cron');
|
||||
|
||||
if($panel[$user]['CRON_REPORTS'] == 'yes') {
|
||||
$cron_reports = __('turn off notifications');
|
||||
} else {
|
||||
$cron_reports = __('turn on notifications');
|
||||
}
|
||||
|
||||
foreach ($data as $key => $value) {
|
||||
++$i;
|
||||
|
||||
if ($data[$key]['SUSPENDED'] == 'yes') {
|
||||
$data[$key]['status'] = 'suspended';
|
||||
$data[$key]['suspend_action'] = 'unsuspend' ;
|
||||
$data[$key]['suspend_conf'] = __('UNSUSPEND_CRON_CONFIRMATION', $key);
|
||||
} else {
|
||||
$data[$key]['status'] = 'active';
|
||||
$data[$key]['suspend_action'] = 'suspend';
|
||||
$data[$key]['suspend_conf'] = __('SUSPEND_CRON_CONFIRMATION', $key);
|
||||
}
|
||||
|
||||
$data[$key]['delete_conf'] = __('DELETE_CRON_CONFIRMATION', $key);
|
||||
|
||||
if ( $i == 1) {
|
||||
$total_amount = __('1 cron job');
|
||||
} else {
|
||||
$total_amount = __('%s cron jobs', $i);
|
||||
}
|
||||
}
|
||||
|
||||
// Back uri
|
||||
$_SESSION['back'] = $_SERVER['REQUEST_URI'];
|
||||
|
||||
$object = (object)[];
|
||||
$object->data = $data;
|
||||
$object->user = $user;
|
||||
$object->panel = $panel;
|
||||
$object->totalAmount = $total_amount;
|
||||
$object->cron_reports = $panel[$user]['CRON_REPORTS'];
|
||||
$object->cron_fav = $_SESSION['favourites']['CRON'];
|
||||
|
||||
print json_encode($object);
|
35
web/api/v1/list/directory/index.php
Normal file
35
web/api/v1/list/directory/index.php
Normal file
|
@ -0,0 +1,35 @@
|
|||
<?php
|
||||
error_reporting(NULL);
|
||||
|
||||
include($_SERVER['DOCUMENT_ROOT'] . "/inc/main.php");
|
||||
|
||||
|
||||
if ((!isset($_SESSION['FILEMANAGER_KEY'])) || (empty($_SESSION['FILEMANAGER_KEY']))) {
|
||||
header("Location: /filemanager-not-purchased/");
|
||||
exit;
|
||||
}
|
||||
|
||||
// Check login_as feature
|
||||
if (($_SESSION['user'] == 'admin') && (!empty($_SESSION['look']))) {
|
||||
$user=$_SESSION['look'];
|
||||
}
|
||||
|
||||
if (empty($panel)) {
|
||||
$command = VESTA_CMD."v-list-user '".$user."' 'json'";
|
||||
exec ($command, $output, $return_var);
|
||||
if ( $return_var > 0 ) {
|
||||
header("Location: /error/");
|
||||
exit;
|
||||
}
|
||||
$panel = json_decode(implode('', $output), true);
|
||||
}
|
||||
|
||||
$path_a = !empty($_REQUEST['dir_a']) ? htmlentities($_REQUEST['dir_a']) : '';
|
||||
$path_b = !empty($_REQUEST['dir_b']) ? htmlentities($_REQUEST['dir_b']) : '';
|
||||
$GLOBAL_JS = '<script type="text/javascript">GLOBAL.START_DIR_A = "' . $path_a . '";</script>';
|
||||
$GLOBAL_JS .= '<script type="text/javascript">GLOBAL.START_DIR_B = "' . $path_b . '";</script>';
|
||||
$GLOBAL_JS .= '<script type="text/javascript">GLOBAL.ROOT_DIR = "' . $panel[$user]['HOME'] . '";</script>';
|
||||
|
||||
|
||||
// Footer
|
||||
include($_SERVER['DOCUMENT_ROOT'].'/templates/file_manager/main.php');
|
72
web/api/v1/list/dns/index.php
Normal file
72
web/api/v1/list/dns/index.php
Normal file
|
@ -0,0 +1,72 @@
|
|||
<?php
|
||||
error_reporting(NULL);
|
||||
$TAB = 'DNS';
|
||||
header("Content-Type: application/json");
|
||||
|
||||
// Main include
|
||||
include($_SERVER['DOCUMENT_ROOT']."/inc/main.php");
|
||||
top_panel(empty($_SESSION['look']) ? $_SESSION['user'] : $_SESSION['look'], $TAB);
|
||||
|
||||
// Data & Render page
|
||||
if (empty($_GET['domain'])){
|
||||
exec (VESTA_CMD."v-list-dns-domains $user json", $output, $return_var);
|
||||
$data = json_decode(implode('', $output), true);
|
||||
$data = array_reverse($data, true);
|
||||
unset($output);
|
||||
|
||||
// render_page($user, $TAB, 'list_dns');
|
||||
} else {
|
||||
exec (VESTA_CMD."v-list-dns-records ".$user." ".escapeshellarg($_GET['domain'])." json", $output, $return_var);
|
||||
$data = json_decode(implode('', $output), true);
|
||||
$data = array_reverse($data, true);
|
||||
unset($output);
|
||||
|
||||
// render_page($user, $TAB, 'list_dns_rec');
|
||||
}
|
||||
|
||||
foreach ($data as $key => $value) {
|
||||
++$i;
|
||||
|
||||
if ( $i == 1) {
|
||||
$total_amount = __('1 domain');
|
||||
} else {
|
||||
$total_amount = __('%s domains', $i);
|
||||
}
|
||||
|
||||
if (!empty($_GET['domain'])){
|
||||
if ( $i == 1) {
|
||||
$total_amount = __('1 record');
|
||||
} else {
|
||||
$total_amount = __('%s records',$i);
|
||||
}
|
||||
|
||||
$data[$key]['delete_conf'] = __('DELETE_RECORD_CONFIRMATION', $data[$key]['RECORD']);
|
||||
} else {
|
||||
$data[$key]['delete_conf'] = __('DELETE_DOMAIN_CONFIRMATION', $key);
|
||||
}
|
||||
|
||||
if ($data[$key]['SUSPENDED'] == 'yes') {
|
||||
$data[$key]['status'] = 'suspended';
|
||||
$data[$key]['suspend_action'] = 'unsuspend' ;
|
||||
$data[$key]['suspend_conf'] = !empty($_GET['domain']) ? __('UNSUSPEND_RECORD_CONFIRMATION', $data[$key]['RECORD']) : __('UNSUSPEND_DOMAIN_CONFIRMATION', $key);
|
||||
} else {
|
||||
$data[$key]['status'] = 'active';
|
||||
$data[$key]['suspend_action'] = 'suspend';
|
||||
$data[$key]['suspend_conf'] = !empty($_GET['domain']) ? __('SUSPEND_RECORD_CONFIRMATION', $data[$key]['RECORD']) : __('SUSPEND_DOMAIN_CONFIRMATION', $key);
|
||||
}
|
||||
|
||||
$data[$key]['RECORDS_I18N'] = __('list records', $data[$key]['RECORDS']);
|
||||
}
|
||||
|
||||
// Back uri
|
||||
$_SESSION['back'] = $_SERVER['REQUEST_URI'];
|
||||
|
||||
$object = (object)[];
|
||||
$object->data = $data;
|
||||
$object->user = $user;
|
||||
$object->panel = $panel;
|
||||
$object->totalAmount = $total_amount;
|
||||
$object->dnsFav = $_SESSION['favourites']['DNS'];
|
||||
$object->dnsRecordsFav = $_SESSION['favourites']['DNS_REC'];
|
||||
|
||||
print json_encode($object);
|
24
web/api/v1/list/favorites/index.php
Normal file
24
web/api/v1/list/favorites/index.php
Normal file
|
@ -0,0 +1,24 @@
|
|||
<?php
|
||||
error_reporting(NULL);
|
||||
include($_SERVER['DOCUMENT_ROOT']."/inc/main.php");
|
||||
|
||||
echo '<br> Favorites: <br>';
|
||||
|
||||
// Data
|
||||
exec (VESTA_CMD."v-list-user-favourites ".$_SESSION['user']." json", $output, $return_var);
|
||||
|
||||
|
||||
// print_r(implode('', $output));
|
||||
// $json = '{ "Favourites": { "USER": "", "WEB": "bulletfarm.com", "DNS": "", "MAIL": "", "DB": "", "CRON": "", "BACKUP": "", "IP": "", "PACKAGE": "", "FIREWALL": ""}}';
|
||||
// $data = json_decode($json, true);
|
||||
|
||||
|
||||
$data = json_decode(implode('', $output).'}', true);
|
||||
$data = array_reverse($data,true);
|
||||
|
||||
print_r($data);
|
||||
// $data = array_reverse($data,true);
|
||||
|
||||
// $data = json_decode(implode('', $output), true);
|
||||
|
||||
?>
|
58
web/api/v1/list/firewall/index.php
Normal file
58
web/api/v1/list/firewall/index.php
Normal file
|
@ -0,0 +1,58 @@
|
|||
<?php
|
||||
error_reporting(NULL);
|
||||
$TAB = 'FIREWALL';
|
||||
|
||||
// Main include
|
||||
include($_SERVER['DOCUMENT_ROOT']."/inc/main.php");
|
||||
top_panel(empty($_SESSION['look']) ? $_SESSION['user'] : $_SESSION['look'], $TAB);
|
||||
header("Content-Type: application/json");
|
||||
|
||||
// Check user
|
||||
if ($_SESSION['user'] != 'admin') {
|
||||
header("Location: /list/user");
|
||||
exit;
|
||||
}
|
||||
|
||||
// Data
|
||||
exec (VESTA_CMD."v-list-firewall json", $output, $return_var);
|
||||
$data = json_decode(implode('', $output), true);
|
||||
$data = array_reverse($data, true);
|
||||
unset($output);
|
||||
|
||||
foreach ($data as $key => $value) {
|
||||
++$i;
|
||||
|
||||
if ($data[$key]['SUSPENDED'] == 'yes') {
|
||||
$data[$key]['status'] = 'suspended';
|
||||
$data[$key]['suspend_action'] = 'unsuspend' ;
|
||||
$data[$key]['suspend_conf'] = __('UNSUSPEND_RULE_CONFIRMATION', $key);
|
||||
} else {
|
||||
$data[$key]['status'] = 'active';
|
||||
$data[$key]['suspend_action'] = 'suspend';
|
||||
$data[$key]['suspend_conf'] = __('SUSPEND_RULE_CONFIRMATION', $key);
|
||||
}
|
||||
|
||||
$data[$key]['delete_conf'] = __('DELETE_RULE_CONFIRMATION', $key);
|
||||
|
||||
if ( $i == 1) {
|
||||
$total_amount = __('1 rule');
|
||||
} else {
|
||||
$total_amount = __('%s rules', $i);
|
||||
}
|
||||
}
|
||||
|
||||
// Render page
|
||||
// render_page($user, $TAB, 'list_firewall');
|
||||
|
||||
// Back uri
|
||||
$_SESSION['back'] = $_SERVER['REQUEST_URI'];
|
||||
|
||||
$object = (object)[];
|
||||
$object->data = $data;
|
||||
$object->user = $user;
|
||||
$object->panel = $panel;
|
||||
$object->totalAmount = $total_amount;
|
||||
$object->firewallExtension = !empty($_SESSION['FIREWALL_EXTENSION']);
|
||||
$object->firewallFav = $_SESSION['favourites']['FIREWALL'];
|
||||
|
||||
print json_encode($object);
|
8
web/api/v1/list/index.php
Normal file
8
web/api/v1/list/index.php
Normal file
|
@ -0,0 +1,8 @@
|
|||
<?php
|
||||
session_start();
|
||||
if (isset($_SESSION['user'])) {
|
||||
header("Location: /list/user/");
|
||||
} else {
|
||||
header("Location: /login/");
|
||||
}
|
||||
?>
|
47
web/api/v1/list/ip/index.php
Normal file
47
web/api/v1/list/ip/index.php
Normal file
|
@ -0,0 +1,47 @@
|
|||
<?php
|
||||
error_reporting(NULL);
|
||||
header('Content-Type: application/json');
|
||||
|
||||
$TAB = 'IP';
|
||||
|
||||
// Main include
|
||||
include($_SERVER['DOCUMENT_ROOT']."/inc/main.php");
|
||||
top_panel(empty($_SESSION['look']) ? $_SESSION['user'] : $_SESSION['look'], $TAB);
|
||||
|
||||
// Check user
|
||||
if ($_SESSION['user'] != 'admin') {
|
||||
header('Location: /list/user');
|
||||
exit;
|
||||
}
|
||||
|
||||
// Data
|
||||
exec (VESTA_CMD."v-list-sys-ips json", $output, $return_var);
|
||||
$data = json_decode(implode('', $output), true);
|
||||
$data = array_reverse($data, true);
|
||||
unset($output);
|
||||
|
||||
foreach ($data as $key => $value) {
|
||||
++$i;
|
||||
if ( $i == 1) {
|
||||
$total_amount = __('1 IP address');
|
||||
} else {
|
||||
$total_amount = __('%s IP addresses',$i);
|
||||
}
|
||||
|
||||
$data[$key]['delete_conf'] = __('DELETE_IP_CONFIRMATION', $key);
|
||||
}
|
||||
|
||||
// Render page
|
||||
// render_page($user, $TAB, 'list_ip');
|
||||
|
||||
// Back uri
|
||||
$_SESSION['back'] = $_SERVER['REQUEST_URI'];
|
||||
|
||||
$object = (object)[];
|
||||
$object->data = $data;
|
||||
$object->user = $user;
|
||||
$object->panel = $panel;
|
||||
$object->totalAmount = $total_amount;
|
||||
$object->ipFav = $_SESSION['favourites']['IP'];
|
||||
|
||||
print json_encode($object);
|
36
web/api/v1/list/log/index.php
Normal file
36
web/api/v1/list/log/index.php
Normal file
|
@ -0,0 +1,36 @@
|
|||
<?php
|
||||
error_reporting(NULL);
|
||||
$TAB = 'LOG';
|
||||
|
||||
// Main include
|
||||
include($_SERVER['DOCUMENT_ROOT']."/inc/main.php");
|
||||
top_panel(empty($_SESSION['look']) ? $_SESSION['user'] : $_SESSION['look'], $TAB);
|
||||
header('Content-Type: application/json');
|
||||
|
||||
// Data
|
||||
exec (VESTA_CMD."v-list-user-log $user json", $output, $return_var);
|
||||
check_error($return_var);
|
||||
$data = json_decode(implode('', $output), true);
|
||||
$data = array_reverse($data);
|
||||
unset($output);
|
||||
|
||||
foreach ($data as $key => $value) {
|
||||
++$i;
|
||||
|
||||
if ( $i == 1) {
|
||||
$total_amount = __('one log record');
|
||||
} else {
|
||||
$total_amount = __('%s log records',$i);
|
||||
}
|
||||
}
|
||||
|
||||
// Render page
|
||||
// render_page($user, $TAB, 'list_log');
|
||||
|
||||
$object = (object)[];
|
||||
$object->data = $data;
|
||||
$object->user = $user;
|
||||
$object->panel = $panel;
|
||||
$object->totalAmount = $total_amount;
|
||||
|
||||
print json_encode($object);
|
78
web/api/v1/list/mail/index.php
Normal file
78
web/api/v1/list/mail/index.php
Normal file
|
@ -0,0 +1,78 @@
|
|||
<?
|
||||
error_reporting(NULL);
|
||||
$TAB = 'MAIL';
|
||||
header("Content-Type: application/json");
|
||||
|
||||
// Main include
|
||||
include($_SERVER['DOCUMENT_ROOT']."/inc/main.php");
|
||||
|
||||
// Data & Render page
|
||||
if (empty($_GET['domain'])){
|
||||
exec (VESTA_CMD."v-list-mail-domains $user json", $output, $return_var);
|
||||
$data = json_decode(implode('', $output), true);
|
||||
$data = array_reverse($data, true);
|
||||
unset($output);
|
||||
|
||||
$favorites = $_SESSION['favourites']['MAIL'];
|
||||
|
||||
// render_page($user, $TAB, 'list_mail');
|
||||
} else {
|
||||
exec (VESTA_CMD."v-list-mail-accounts ".$user." ".escapeshellarg($_GET['domain'])." json", $output, $return_var);
|
||||
$data = json_decode(implode('', $output), true);
|
||||
$data = array_reverse($data, true);
|
||||
unset($output);
|
||||
|
||||
$favorites = $_SESSION['favourites']['MAIL_ACC'];
|
||||
|
||||
// render_page($user, $TAB, 'list_mail_acc');
|
||||
}
|
||||
|
||||
$uname_arr=posix_uname();
|
||||
$hostname=$uname_arr['nodename'];
|
||||
|
||||
top_panel(empty($_SESSION['look']) ? $_SESSION['user'] : $_SESSION['look'], $TAB);
|
||||
|
||||
foreach ($data as $key => $value) {
|
||||
++$i;
|
||||
|
||||
list($http_host, $port) = explode(':', $_SERVER["HTTP_HOST"].":");
|
||||
$webmail = "/webmail/";
|
||||
if (!empty($_SESSION['MAIL_URL'])) $webmail = $_SESSION['MAIL_URL'];
|
||||
|
||||
if ($data[$key]['SUSPENDED'] == 'yes') {
|
||||
$data[$key]['status'] = 'suspended';
|
||||
$data[$key]['suspend_action'] = 'unsuspend' ;
|
||||
$data[$key]['suspend_conf'] = __('UNSUSPEND_DOMAIN_CONFIRMATION', $key);
|
||||
} else {
|
||||
$data[$key]['status'] = 'active';
|
||||
$data[$key]['suspend_action'] = 'suspend';
|
||||
$data[$key]['suspend_conf'] = __('SUSPEND_DOMAIN_CONFIRMATION', $key);
|
||||
}
|
||||
|
||||
if (empty($data[$key]['CATCHALL'])) {
|
||||
$data[$key]['CATCHALL'] = '/dev/null';
|
||||
}
|
||||
|
||||
if (empty($_GET['domain'])){
|
||||
$total_amount = $i === 1 ? __('1 domain') : __('%s domains', $i);
|
||||
} else {
|
||||
$total_amount = $i === 1 ? __('1 mail account') : __('%s mail account', $i);
|
||||
}
|
||||
|
||||
$data[$key]['list_accounts_button'] = __('list accounts', $data[$key]['ACCOUNTS']);
|
||||
$data[$key]['delete_conf'] = __('DELETE_DOMAIN_CONFIRMATION', $key);
|
||||
}
|
||||
|
||||
// Back uri
|
||||
$_SESSION['back'] = $_SERVER['REQUEST_URI'];
|
||||
|
||||
$object = (object)[];
|
||||
$object->data = $data;
|
||||
$object->user = $user;
|
||||
$object->panel = $panel;
|
||||
$object->webmail = $webmail;
|
||||
$object->hostname = $hostname;
|
||||
$object->totalAmount = $total_amount;
|
||||
$object->mailFav = $favorites;
|
||||
|
||||
print json_encode($object);
|
25
web/api/v1/list/notifications/index.php
Normal file
25
web/api/v1/list/notifications/index.php
Normal file
|
@ -0,0 +1,25 @@
|
|||
<?php
|
||||
$TAB = 'NOTIFICATIONS';
|
||||
error_reporting(NULL);
|
||||
|
||||
// Main include
|
||||
include($_SERVER['DOCUMENT_ROOT']."/inc/main.php");
|
||||
|
||||
|
||||
// Data
|
||||
exec (VESTA_CMD."v-list-user-notifications $user json", $output, $return_var);
|
||||
$notifications = json_decode(implode('', $output), true);
|
||||
$notifications = array_reverse($notifications,true);
|
||||
foreach($notifications as $key => $note){
|
||||
$note['ID'] = $key;
|
||||
$notifications[$key] = $note;
|
||||
}
|
||||
|
||||
// Back uri
|
||||
$_SESSION['back'] = $_SERVER['REQUEST_URI'];
|
||||
|
||||
$result = array(
|
||||
'result' => empty($notifications) ? [] : $notifications
|
||||
);
|
||||
|
||||
echo json_encode($result);
|
45
web/api/v1/list/package/index.php
Normal file
45
web/api/v1/list/package/index.php
Normal file
|
@ -0,0 +1,45 @@
|
|||
<?php
|
||||
error_reporting(NULL);
|
||||
$TAB = 'PACKAGE';
|
||||
header("Content-Type: application/json");
|
||||
|
||||
// Main include
|
||||
include($_SERVER['DOCUMENT_ROOT']."/inc/main.php");
|
||||
top_panel(empty($_SESSION['look']) ? $_SESSION['user'] : $_SESSION['look'], $TAB);
|
||||
|
||||
// Check user
|
||||
if ($_SESSION['user'] != 'admin') {
|
||||
header("Location: /list/user");
|
||||
exit;
|
||||
}
|
||||
|
||||
// Data
|
||||
exec (VESTA_CMD."v-list-user-packages json", $output, $return_var);
|
||||
$data = json_decode(implode('', $output), true);
|
||||
unset($output);
|
||||
|
||||
foreach ($data as $key => $value) {
|
||||
++$i;
|
||||
if ( $i == 1) {
|
||||
$total_amount = __('1 package');
|
||||
} else {
|
||||
$total_amount = __('%s packages',$i);
|
||||
}
|
||||
|
||||
$data[$key]['delete_conf'] = __('DELETE_PACKAGE_CONFIRMATION', $key);
|
||||
}
|
||||
|
||||
// Render page
|
||||
// render_page($user, $TAB, 'list_packages');
|
||||
|
||||
// Back uri
|
||||
$_SESSION['back'] = $_SERVER['REQUEST_URI'];
|
||||
|
||||
$object = (object)[];
|
||||
$object->data = $data;
|
||||
$object->user = $user;
|
||||
$object->panel = $panel;
|
||||
$object->totalAmount = $total_amount;
|
||||
$object->packagesFav = $_SESSION['favourites']['PACKAGE'];
|
||||
|
||||
print json_encode($object);
|
102
web/api/v1/list/server/index.php
Normal file
102
web/api/v1/list/server/index.php
Normal file
|
@ -0,0 +1,102 @@
|
|||
<?php
|
||||
error_reporting(NULL);
|
||||
$TAB = 'SERVER';
|
||||
|
||||
// Main include
|
||||
include($_SERVER['DOCUMENT_ROOT']."/inc/main.php");
|
||||
header("Content-Type: application/json");
|
||||
top_panel(empty($_SESSION['look']) ? $_SESSION['user'] : $_SESSION['look'], $TAB);
|
||||
|
||||
// Check user
|
||||
if ($_SESSION['user'] != 'admin') {
|
||||
header("Location: /list/user");
|
||||
exit;
|
||||
}
|
||||
|
||||
// CPU info
|
||||
if (isset($_GET['cpu'])) {
|
||||
$TAB = 'CPU';
|
||||
exec (VESTA_CMD.'v-list-sys-cpu-status', $output, $return_var);
|
||||
$service_log = $output;
|
||||
}
|
||||
|
||||
// Memory info
|
||||
if (isset($_GET['mem'])) {
|
||||
$TAB = 'MEMORY';
|
||||
exec (VESTA_CMD.'v-list-sys-memory-status', $output, $return_var);
|
||||
$service_log = $output;
|
||||
}
|
||||
|
||||
// Disk info
|
||||
if (isset($_GET['disk'])) {
|
||||
$TAB = 'DISK';
|
||||
exec (VESTA_CMD.'v-list-sys-disk-status', $output, $return_var);
|
||||
$service_log = $output;
|
||||
}
|
||||
|
||||
// Network info
|
||||
if (isset($_GET['net'])) {
|
||||
$TAB = 'NETWORK';
|
||||
exec (VESTA_CMD.'v-list-sys-network-status', $output, $return_var);
|
||||
$service_log = $output;
|
||||
}
|
||||
|
||||
// Web info
|
||||
if (isset($_GET['web'])) {
|
||||
$TAB = 'WEB';
|
||||
exec (VESTA_CMD.'v-list-sys-web-status', $output, $return_var);
|
||||
$service_log = $output;
|
||||
}
|
||||
|
||||
|
||||
// DNS info
|
||||
if (isset($_GET['dns'])) {
|
||||
$TAB = 'DNS';
|
||||
exec (VESTA_CMD.'v-list-sys-dns-status', $output, $return_var);
|
||||
$service_log = $output;
|
||||
}
|
||||
|
||||
// Mail info
|
||||
if (isset($_GET['mail'])) {
|
||||
$TAB = 'MAIL';
|
||||
exec (VESTA_CMD.'v-list-sys-mail-status', $output, $return_var);
|
||||
$service_log = $output;
|
||||
}
|
||||
|
||||
// DB info
|
||||
if (isset($_GET['db'])) {
|
||||
$TAB = 'DB';
|
||||
exec (VESTA_CMD.'v-list-sys-db-status', $output, $return_var);
|
||||
$service_log = $output;
|
||||
}
|
||||
|
||||
// Data
|
||||
exec (VESTA_CMD."v-list-sys-info json", $output, $return_var);
|
||||
$sys = json_decode(implode('', $output), true);
|
||||
unset($output);
|
||||
exec (VESTA_CMD."v-list-sys-services json", $output, $return_var);
|
||||
$data = json_decode(implode('', $output), true);
|
||||
unset($output);
|
||||
|
||||
foreach ($data as $key => $value) {
|
||||
if ($data[$key]['STATE'] == 'running') {
|
||||
$data[$key]['action_url'] = '/stop/service/?srv='.$key;
|
||||
} else {
|
||||
$data[$key]['action_url'] = '/start/service/?srv='.$key;
|
||||
}
|
||||
}
|
||||
|
||||
// Render page
|
||||
// render_page($user, $TAB, 'list_services');
|
||||
|
||||
// Back uri
|
||||
$_SESSION['back'] = $_SERVER['REQUEST_URI'];
|
||||
|
||||
$object = (object)[];
|
||||
$object->data = $data;
|
||||
$object->user = $user;
|
||||
$object->sys = $sys;
|
||||
$object->service_log = $service_log;
|
||||
$object->panel = $panel;
|
||||
|
||||
print json_encode($object);
|
58
web/api/v1/list/stats/index.php
Normal file
58
web/api/v1/list/stats/index.php
Normal file
|
@ -0,0 +1,58 @@
|
|||
<?php
|
||||
error_reporting(NULL);
|
||||
$TAB = 'STATS';
|
||||
|
||||
// Main include
|
||||
include($_SERVER['DOCUMENT_ROOT']."/inc/main.php");
|
||||
top_panel(empty($_SESSION['look']) ? $_SESSION['user'] : $_SESSION['look'], $TAB);
|
||||
header('Content-Type: application/json');
|
||||
|
||||
// Data
|
||||
if ($user == 'admin') {
|
||||
if (empty($_GET['user'])) {
|
||||
exec (VESTA_CMD."v-list-users-stats json", $output, $return_var);
|
||||
$data = json_decode(implode('', $output), true);
|
||||
$data = array_reverse($data, true);
|
||||
unset($output);
|
||||
} else {
|
||||
$v_user = escapeshellarg($_GET['user']);
|
||||
exec (VESTA_CMD."v-list-user-stats $v_user json", $output, $return_var);
|
||||
$data = json_decode(implode('', $output), true);
|
||||
$data = array_reverse($data, true);
|
||||
unset($output);
|
||||
}
|
||||
|
||||
exec (VESTA_CMD."v-list-sys-users 'json'", $output, $return_var);
|
||||
$users = json_decode(implode('', $output), true);
|
||||
unset($output);
|
||||
} else {
|
||||
exec (VESTA_CMD."v-list-user-stats $user json", $output, $return_var);
|
||||
$data = json_decode(implode('', $output), true);
|
||||
$data = array_reverse($data, true);
|
||||
unset($output);
|
||||
}
|
||||
|
||||
foreach ($data as $key => $value) {
|
||||
++$i;
|
||||
|
||||
if ( $i == 1) {
|
||||
$total_amount = __('1 month');
|
||||
} else {
|
||||
$total_amount = __('%s months',$i);
|
||||
}
|
||||
}
|
||||
|
||||
// Render page
|
||||
// render_page($user, $TAB, 'list_stats');
|
||||
|
||||
// Back uri
|
||||
$_SESSION['back'] = $_SERVER['REQUEST_URI'];
|
||||
|
||||
$object = (object)[];
|
||||
$object->data = $data;
|
||||
$object->user = $user;
|
||||
$object->panel = $panel;
|
||||
$object->users = $users;
|
||||
$object->totalAmount = $total_amount;
|
||||
|
||||
print json_encode($object);
|
36
web/api/v1/list/updates/index.php
Normal file
36
web/api/v1/list/updates/index.php
Normal file
|
@ -0,0 +1,36 @@
|
|||
<?php
|
||||
error_reporting(NULL);
|
||||
$TAB = 'UPDATES';
|
||||
|
||||
// Main include
|
||||
include($_SERVER['DOCUMENT_ROOT']."/inc/main.php");
|
||||
top_panel(empty($_SESSION['look']) ? $_SESSION['user'] : $_SESSION['look'], $TAB);
|
||||
header('Content-Type: application/json');
|
||||
|
||||
// Check user
|
||||
if ($_SESSION['user'] != 'admin') {
|
||||
header('Location: /list/user');
|
||||
exit;
|
||||
}
|
||||
|
||||
// Data
|
||||
exec (VESTA_CMD."v-list-sys-vesta-updates json", $output, $return_var);
|
||||
$data = json_decode(implode('', $output), true);
|
||||
unset($output);
|
||||
exec (VESTA_CMD."v-list-sys-vesta-autoupdate plain", $output, $return_var);
|
||||
$autoupdate = $output[0];
|
||||
unset($output);
|
||||
|
||||
// Render page
|
||||
// render_page($user, $TAB, 'list_updates');
|
||||
|
||||
// Back uri
|
||||
$_SESSION['back'] = $_SERVER['REQUEST_URI'];
|
||||
|
||||
$object = (object)[];
|
||||
$object->data = $data;
|
||||
$object->user = $user;
|
||||
$object->autoUpdate = $autoupdate;
|
||||
$object->panel = $panel;
|
||||
|
||||
print json_encode($object);
|
56
web/api/v1/list/user/index.php
Normal file
56
web/api/v1/list/user/index.php
Normal file
|
@ -0,0 +1,56 @@
|
|||
<?php
|
||||
error_reporting(NULL);
|
||||
$TAB = 'USER';
|
||||
header("Content-Type: application/json");
|
||||
|
||||
// Main include
|
||||
include($_SERVER['DOCUMENT_ROOT']."/inc/main.php");
|
||||
|
||||
// Data
|
||||
if ($user == 'admin') {
|
||||
exec (VESTA_CMD . "v-list-users json", $output, $return_var);
|
||||
} else {
|
||||
exec (VESTA_CMD . "v-list-user ".$user." json", $output, $return_var);
|
||||
}
|
||||
$data = json_decode(implode('', $output), true);
|
||||
$data = array_reverse($data,true);
|
||||
// Render page
|
||||
top_panel(empty($_SESSION['look']) ? $_SESSION['user'] : $_SESSION['look'], $TAB);
|
||||
// render_page($user, $TAB, 'list_user');
|
||||
|
||||
$_SESSION['back'] = $_SERVER['REQUEST_URI'];
|
||||
|
||||
foreach ($data as $key => $value) {
|
||||
++$i;
|
||||
if ( $i == 1) {
|
||||
$total_amount = __('1 account');
|
||||
} else {
|
||||
$total_amount = __('%s accounts', $i);
|
||||
}
|
||||
|
||||
if ($data[$key]['SUSPENDED'] == 'yes') {
|
||||
$spnd_action = 'unsuspend' ;
|
||||
$spnd_confirmation = 'UNSUSPEND_USER_CONFIRMATION';
|
||||
$data[$key]['spnd_action'] = __($spnd_action);
|
||||
$data[$key]['spnd_conf'] = __($spnd_confirmation, $key);
|
||||
} else {
|
||||
$spnd_action = 'suspend' ;
|
||||
$spnd_confirmation = 'SUSPEND_USER_CONFIRMATION';
|
||||
$data[$key]['spnd_action'] = __($spnd_action);
|
||||
$data[$key]['spnd_conf'] = __($spnd_confirmation, $key);
|
||||
}
|
||||
|
||||
$data[$key]['isChecked'] = false;
|
||||
$data[$key]['delete_conf'] = __('DELETE_USER_CONFIRMATION', $key);
|
||||
}
|
||||
|
||||
$result = array(
|
||||
'data' => $data,
|
||||
'user' => $user,
|
||||
'panel' => $panel,
|
||||
'token' => $_SESSION['token'],
|
||||
'totalAmount' => $total_amount,
|
||||
'userFav' => $_SESSION['favourites']['USER'],
|
||||
);
|
||||
|
||||
echo json_encode($result);
|
29
web/api/v1/list/web-log/index.php
Normal file
29
web/api/v1/list/web-log/index.php
Normal file
|
@ -0,0 +1,29 @@
|
|||
<?php
|
||||
// Init
|
||||
error_reporting(NULL);
|
||||
|
||||
header('Content-Type: application/json');
|
||||
|
||||
include($_SERVER['DOCUMENT_ROOT']."/inc/main.php");
|
||||
|
||||
// Header
|
||||
// include($_SERVER['DOCUMENT_ROOT'].'/templates/admin/list_weblog.html');
|
||||
|
||||
$v_domain = escapeshellarg($_GET['domain']);
|
||||
if ($_GET['type'] == 'access') $type = 'access';
|
||||
if ($_GET['type'] == 'error') $type = 'error';
|
||||
|
||||
$data = exec (VESTA_CMD."v-list-web-domain-".$type."log $user ".$v_domain, $output, $return_var);
|
||||
|
||||
echo json_encode(
|
||||
array(
|
||||
'data' => $data
|
||||
)
|
||||
);
|
||||
|
||||
// if ($return_var == 0 ) {
|
||||
// foreach($output as $file) {
|
||||
// echo htmlentities($file) . "\n";
|
||||
// }
|
||||
// }
|
||||
// echo " </pre>\n</body>\n</html>\n";
|
110
web/api/v1/list/web/index.php
Normal file
110
web/api/v1/list/web/index.php
Normal file
|
@ -0,0 +1,110 @@
|
|||
<?php
|
||||
error_reporting(NULL);
|
||||
$TAB = 'WEB';
|
||||
|
||||
header('Content-Type: application/json');
|
||||
|
||||
// Main include
|
||||
include($_SERVER['DOCUMENT_ROOT']."/inc/main.php");
|
||||
|
||||
// Data
|
||||
exec (VESTA_CMD."v-list-web-domains $user json", $output, $return_var);
|
||||
$data = json_decode(implode('', $output), true);
|
||||
$data = array_reverse($data,true);
|
||||
$ips = json_decode(shell_exec(VESTA_CMD.'v-list-sys-ips json'), true);
|
||||
|
||||
// Render page
|
||||
top_panel(empty($_SESSION['look']) ? $_SESSION['user'] : $_SESSION['look'], $TAB);
|
||||
// render_page($user, $TAB, 'list_web');
|
||||
|
||||
// Back uri
|
||||
$_SESSION['back'] = $_SERVER['REQUEST_URI'];
|
||||
|
||||
foreach ($data as $key => $value) {
|
||||
++$i;
|
||||
|
||||
if ($data[$key]['SUSPENDED'] == 'yes') {
|
||||
$data[$key]['status'] = 'suspended';
|
||||
$data[$key]['spnd_action'] = 'unsuspend' ;
|
||||
$data[$key]['spnd_confirmation'] = __('UNSUSPEND_DOMAIN_CONFIRMATION', $key);
|
||||
} else {
|
||||
$data[$key]['status'] = 'active';
|
||||
$data[$key]['spnd_action'] = 'suspend' ;
|
||||
$data[$key]['spnd_confirmation'] = __('SUSPEND_DOMAIN_CONFIRMATION', $key);
|
||||
}
|
||||
|
||||
if (!empty($data[$key]['SSL_HOME'])) {
|
||||
if ($data[$key]['SSL_HOME'] == 'same') {
|
||||
$data[$key]['SSL_HOME'] = 'public_html';
|
||||
} else {
|
||||
$data[$key]['SSL_HOME'] = 'public_shtml';
|
||||
}
|
||||
} else {
|
||||
$data[$key]['SSL_HOME'] = '';
|
||||
}
|
||||
|
||||
$ftp_user='no';
|
||||
if (!empty($data[$key]['FTP_USER'])) {
|
||||
$ftp_user=$data[$key]['FTP_USER'];
|
||||
}
|
||||
|
||||
if (strlen($ftp_user) > 24 ) {
|
||||
$data[$key]['FTP_USER'] = str_replace(':', ', ', $ftp_user);
|
||||
$data[$key]['FTP_USER'] = substr($ftp_user, 0, 24);
|
||||
$data[$key]['FTP_USER'] = trim($ftp_user, ":");
|
||||
$data[$key]['FTP_USER'] = str_replace(':', ', ', $ftp_user);
|
||||
$data[$key]['FTP_USER'] = $ftp_user.", ...";
|
||||
} else {
|
||||
$data[$key]['FTP_USER'] = str_replace(':', ', ', $ftp_user);
|
||||
}
|
||||
|
||||
if (strlen($data[$key]['PROXY_EXT']) > 24 ) {
|
||||
$data[$key]['PROXY_EXT'] = str_replace(',', ', ', $data[$key]['PROXY_EXT']);
|
||||
$data[$key]['PROXY_EXT'] = substr($data[$key]['PROXY_EXT'], 0, 24);
|
||||
$data[$key]['PROXY_EXT'] = trim($proxy_ext, ",");
|
||||
$data[$key]['PROXY_EXT'] = str_replace(',', ', ', $proxy_ext);
|
||||
$data[$key]['PROXY_EXT'] = $proxy_ext.", ...";
|
||||
} else {
|
||||
$data[$key]['PROXY_EXT'] = '';
|
||||
$data[$key]['PROXY_EXT'] = str_replace(',', ', ', $data[$key]['PROXY_EXT']);
|
||||
}
|
||||
|
||||
$data[$key]['WEB_STATS'] = 'no';
|
||||
if (!empty($data[$key]['STATS'])) {
|
||||
$data[$key]['WEB_STATS'] = $data[$key]['STATS'];
|
||||
}
|
||||
|
||||
$data[$key]['FTP'] = 'no';
|
||||
if (!empty($data[$key]['FTP_USER'])) {
|
||||
$data[$key]['FTP'] = $data[$key]['FTP_USER'];
|
||||
}
|
||||
|
||||
$data[$key]['BACKEND_SUPPORT'] = 'no';
|
||||
if (!empty($data[$key]['BACKEND'])) {
|
||||
$data[$key]['BACKEND_SUPPORT'] = 'yes';
|
||||
}
|
||||
|
||||
$data[$key]['PROXY_SUPPORT'] = 'no';
|
||||
if (!empty($data[$key]['PROXY'])) {
|
||||
$data[$key]['PROXY_SUPPORT'] = 'yes';
|
||||
}
|
||||
|
||||
$data[$key]['delete_confirmation'] = __('DELETE_DOMAIN_CONFIRMATION', $key);
|
||||
|
||||
if ( $i == 1) {
|
||||
$total_amount = __('1 domain');
|
||||
} else {
|
||||
$total_amount = __('%s domains',$i);
|
||||
}
|
||||
}
|
||||
|
||||
$object = (object)[];
|
||||
$object->data = $data;
|
||||
$object->user = $user;
|
||||
$object->panel = $panel;
|
||||
$object->totalAmount = $total_amount;
|
||||
$object->webFav = $_SESSION['favourites']['WEB'];
|
||||
|
||||
print json_encode($object);
|
||||
?>
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue