mirror of
https://github.com/myvesta/vesta
synced 2025-07-10 23:33:13 -07:00
Php+Js update set
This commit is contained in:
parent
257423147e
commit
eb2e896a8e
11 changed files with 249 additions and 140 deletions
|
@ -28,6 +28,7 @@ App.Settings.ajax_url = 1;
|
||||||
App.Settings.uri = location.href.replace('index.html', '');
|
App.Settings.uri = location.href.replace('index.html', '');
|
||||||
App.Settings.popup_conf = { 'centered' : true, 'bgcolor' : '#FF0000', 'lightboxSpeed' : 'fast', 'destroyOnClose': true };
|
App.Settings.popup_conf = { 'centered' : true, 'bgcolor' : '#FF0000', 'lightboxSpeed' : 'fast', 'destroyOnClose': true };
|
||||||
|
|
||||||
|
App.Settings.PASSWORD_IMMUTE = '********';
|
||||||
|
|
||||||
// Messages
|
// Messages
|
||||||
App.Messages.total_dns_records = {single: 'total record', plural: 'total records'};
|
App.Messages.total_dns_records = {single: 'total record', plural: 'total records'};
|
||||||
|
@ -42,12 +43,14 @@ App.Settings.Imutable = {};
|
||||||
App.Settings.Imutable.USER = ['LOGIN_NAME'];
|
App.Settings.Imutable.USER = ['LOGIN_NAME'];
|
||||||
App.Settings.Imutable.DB = ['DB', 'TYPE', 'USER'];
|
App.Settings.Imutable.DB = ['DB', 'TYPE', 'USER'];
|
||||||
App.Settings.Imutable.DNS = ['DNS_DOMAIN'];
|
App.Settings.Imutable.DNS = ['DNS_DOMAIN'];
|
||||||
|
App.Settings.Imutable.IP = ['INTERFACE'];
|
||||||
|
|
||||||
|
|
||||||
// Empty
|
// Empty
|
||||||
App.Empty = {};
|
App.Empty = {};
|
||||||
App.Empty.USER = {'CONTACT':'', 'PASSWORD':'','LOGIN_NAME':'','LNAME':'', 'FNAME':'','NS1':'','NS2':'','NS3':'','NS4':'','NS5':'','NS6':'','NS7':'','NS8':''};
|
App.Empty.USER = {'CONTACT':'', 'PASSWORD':'','LOGIN_NAME':'','LNAME':'', 'FNAME':'','NS1':'','NS2':'','NS3':'','NS4':'','NS5':'','NS6':'','NS7':'','NS8':''};
|
||||||
App.Empty.WEB_DOMAIN = {'CONTACT':'', 'PASSWORD':'','LOGIN_NAME':'','NS':'', 'DOMAIN':'','SSL_CERT':'','SSL_HOME':'','STATS_PASSWORD':'','STATS_LOGIN':'','ALIAS':''};
|
App.Empty.WEB_DOMAIN = {'CONTACT':'', 'PASSWORD':'','LOGIN_NAME':'','NS':'', 'DOMAIN':'','SSL_CERT':'','SSL_HOME':'','STATS_PASSWORD':'','STATS_LOGIN':'','ALIAS':''};
|
||||||
|
App.Empty.DB = {'DB':'', 'USER':'','FORM':'', 'PASSWORD': ''};
|
||||||
|
|
||||||
App.Settings.getMethodName = function(action)
|
App.Settings.getMethodName = function(action)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,4 +1,17 @@
|
||||||
|
App.Helpers.scrollTo = function(elm)
|
||||||
|
{
|
||||||
|
fb.log(elm);
|
||||||
|
var scroll_to = $(elm).offset().top;
|
||||||
|
if (scroll_to > 1000) {
|
||||||
|
var scroll_time = 300;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
var scroll_time = 550;
|
||||||
|
}
|
||||||
|
$('html, body').animate({
|
||||||
|
'scrollTop': scroll_to
|
||||||
|
}, scroll_time);
|
||||||
|
}
|
||||||
|
|
||||||
App.Helpers.getMbHumanMeasure = function(val)
|
App.Helpers.getMbHumanMeasure = function(val)
|
||||||
{
|
{
|
||||||
|
@ -201,7 +214,7 @@ App.Helpers.getFormValuesFromElement = function(ref)
|
||||||
|
|
||||||
App.Helpers.updateScreen = function()
|
App.Helpers.updateScreen = function()
|
||||||
{
|
{
|
||||||
Custom.init();
|
//Custom.init();
|
||||||
App.Ajax.request('MAIN.getInitial', {}, function(reply){
|
App.Ajax.request('MAIN.getInitial', {}, function(reply){
|
||||||
App.Env.initialParams = reply.data;
|
App.Env.initialParams = reply.data;
|
||||||
App.Helpers.updateInitial();
|
App.Helpers.updateInitial();
|
||||||
|
|
|
@ -190,12 +190,6 @@ App.HTML.Build.user_entry = function(o, key)
|
||||||
var tpl = App.Templates.get('ENTRY', 'user');
|
var tpl = App.Templates.get('ENTRY', 'user');
|
||||||
tpl = App.HTML.setTplKeys(tpl, o);
|
tpl = App.HTML.setTplKeys(tpl, o);
|
||||||
|
|
||||||
/*if (App.Constants.SUSPENDED_YES == o.SUSPENDED) {
|
|
||||||
var sub_tpl = App.Templates.get('SUSPENDED_TPL_SUSPENDED', 'general');
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
var sub_tpl = App.Templates.get('SUSPENDED_TPL_NOT_SUSPENDED', 'general');
|
|
||||||
}*/
|
|
||||||
tpl.set(':SUSPENDED_TPL', '');//sub_tpl.finalize());
|
tpl.set(':SUSPENDED_TPL', '');//sub_tpl.finalize());
|
||||||
|
|
||||||
var ns = [];
|
var ns = [];
|
||||||
|
@ -225,6 +219,7 @@ App.HTML.Build.user_entry = function(o, key)
|
||||||
tpl.set(':NS', ns_custom.finalize());
|
tpl.set(':NS', ns_custom.finalize());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
tpl.set(':REPORTS_ENABLED', o.REPORTS_ENABLED == 'yes' ? 'enabled' : 'DISABLED');
|
||||||
|
|
||||||
return tpl.finalize();
|
return tpl.finalize();
|
||||||
}
|
}
|
||||||
|
@ -232,6 +227,10 @@ App.HTML.Build.user_entry = function(o, key)
|
||||||
|
|
||||||
App.HTML.Build.user_form = function(options, id)
|
App.HTML.Build.user_form = function(options, id)
|
||||||
{
|
{
|
||||||
|
var in_edit = false;
|
||||||
|
if (!App.Helpers.isEmpty(options)) {
|
||||||
|
in_edit = true;
|
||||||
|
}
|
||||||
if('undefined' == typeof App.Env.initialParams) {
|
if('undefined' == typeof App.Env.initialParams) {
|
||||||
return alert('Please wait a bit. Some background processes are not yet executed. Thank you for patience.');
|
return alert('Please wait a bit. Some background processes are not yet executed. Thank you for patience.');
|
||||||
}
|
}
|
||||||
|
@ -253,7 +252,7 @@ App.HTML.Build.user_form = function(options, id)
|
||||||
// NS
|
// NS
|
||||||
var ns = [];
|
var ns = [];
|
||||||
$([3,4,5,6,7,8]).each(function(i, index)
|
$([3,4,5,6,7,8]).each(function(i, index)
|
||||||
{fb.warn(options);
|
{
|
||||||
if (options['NS'+index].trim() != '') {
|
if (options['NS'+index].trim() != '') {
|
||||||
var tpl_ns = App.Templates.get('NS_INPUT', 'user');
|
var tpl_ns = App.Templates.get('NS_INPUT', 'user');
|
||||||
tpl_ns.set(':NS_LABEL', 'NS #' + (index));
|
tpl_ns.set(':NS_LABEL', 'NS #' + (index));
|
||||||
|
@ -264,7 +263,9 @@ App.HTML.Build.user_form = function(options, id)
|
||||||
ns[ns.length++] = App.Templates.get('PLUS_ONE_NS', 'user').finalize();
|
ns[ns.length++] = App.Templates.get('PLUS_ONE_NS', 'user').finalize();
|
||||||
|
|
||||||
tpl.set(':NS', ns.done());
|
tpl.set(':NS', ns.done());
|
||||||
|
if (in_edit == true) {
|
||||||
|
options.PASSWORD = App.Settings.PASSWORD_IMMUTE;
|
||||||
|
}
|
||||||
tpl = App.HTML.setTplKeys(tpl, options, true);
|
tpl = App.HTML.setTplKeys(tpl, options, true);
|
||||||
tpl = App.HTML.Build.user_selects(tpl, options);
|
tpl = App.HTML.Build.user_selects(tpl, options);
|
||||||
|
|
||||||
|
@ -287,7 +288,7 @@ App.HTML.Build.web_domain_entry = function(o, key)
|
||||||
var tpl = App.Templates.get('ENTRY', 'web_domain');
|
var tpl = App.Templates.get('ENTRY', 'web_domain');
|
||||||
tpl = App.HTML.setTplKeys(tpl, o);
|
tpl = App.HTML.setTplKeys(tpl, o);
|
||||||
|
|
||||||
if (App.Constants.SUSPENDED_YES == o.SUSPENDED) {
|
if (App.Constants.SUSPENDED_YES == o.SUSPEND) {
|
||||||
var sub_tpl = App.Templates.get('SUSPENDED_TPL_SUSPENDED', 'general');
|
var sub_tpl = App.Templates.get('SUSPENDED_TPL_SUSPENDED', 'general');
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -364,6 +365,10 @@ App.HTML.Build.db_entry = function(o, key)
|
||||||
|
|
||||||
App.HTML.Build.db_form = function(options, id)
|
App.HTML.Build.db_form = function(options, id)
|
||||||
{
|
{
|
||||||
|
var in_edit = false;
|
||||||
|
if (!App.Helpers.isEmpty(options)) {
|
||||||
|
in_edit = true;
|
||||||
|
}
|
||||||
if('undefined' == typeof App.Env.initialParams) {
|
if('undefined' == typeof App.Env.initialParams) {
|
||||||
return alert('PLease wait a bit. Some background processes are not yet executed. Thank you for patience.');
|
return alert('PLease wait a bit. Some background processes are not yet executed. Thank you for patience.');
|
||||||
}
|
}
|
||||||
|
@ -380,12 +385,13 @@ App.HTML.Build.db_form = function(options, id)
|
||||||
tpl.set(':save_button', 'SAVE');
|
tpl.set(':save_button', 'SAVE');
|
||||||
}
|
}
|
||||||
|
|
||||||
options = !App.Helpers.isEmpty(options) ? options : {'DB':'', 'USER':'','FORM':'', 'PASSWORD': ''};
|
options = !App.Helpers.isEmpty(options) ? options : App.Empty.DB;
|
||||||
|
if (in_edit == true) {
|
||||||
|
options.PASSWORD = App.Settings.PASSWORD_IMMUTE;
|
||||||
|
}
|
||||||
tpl = App.HTML.setTplKeys(tpl, options, true);
|
tpl = App.HTML.setTplKeys(tpl, options, true);
|
||||||
tpl = App.HTML.Build.db_selects(tpl, options);
|
tpl = App.HTML.Build.db_selects(tpl, options);
|
||||||
|
|
||||||
tpl.set(':PASSWORD', '');
|
|
||||||
|
|
||||||
return tpl.finalize();
|
return tpl.finalize();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -542,7 +548,7 @@ App.HTML.Build.db_selects = function(tpl, options)
|
||||||
App.HTML.Build.ip_selects = function(tpl, options)
|
App.HTML.Build.ip_selects = function(tpl, options)
|
||||||
{
|
{
|
||||||
// OWNER
|
// OWNER
|
||||||
var users = App.Env.initialParams.IP.SYS_USERS;
|
var users = App.Env.initialParams.IP.OWNER;
|
||||||
var opts = App.HTML.Build.options(users, options.OWNER);
|
var opts = App.HTML.Build.options(users, options.OWNER);
|
||||||
tpl.set(':owner_options', opts);
|
tpl.set(':owner_options', opts);
|
||||||
|
|
||||||
|
|
|
@ -310,7 +310,7 @@ App.Templates.html = {
|
||||||
~!:PACKAGE_OPTIONS~!\
|
~!:PACKAGE_OPTIONS~!\
|
||||||
</select>\
|
</select>\
|
||||||
</div>\
|
</div>\
|
||||||
<div class="form-row cc hidden">\
|
<div class="form-row cc">\
|
||||||
<label for="#" class="field-label">shell:</label>\
|
<label for="#" class="field-label">shell:</label>\
|
||||||
<select class="not-styled" name="SHELL">\
|
<select class="not-styled" name="SHELL">\
|
||||||
~!:SHELL_OPTIONS~!\
|
~!:SHELL_OPTIONS~!\
|
||||||
|
@ -511,6 +511,14 @@ App.Templates.html = {
|
||||||
</select>\
|
</select>\
|
||||||
</div>\
|
</div>\
|
||||||
</div>\
|
</div>\
|
||||||
|
<div class="form-row cc">\
|
||||||
|
<label for="#" class="field-label">CGI:</label>\
|
||||||
|
<input type="checkbox" value="~!:CGI~!" ~!:CHECKED_CGI~! name="CGI" class="not-styled">\
|
||||||
|
</div>\
|
||||||
|
<div class="form-row cc">\
|
||||||
|
<label for="#" class="field-label">ELOG:</label>\
|
||||||
|
<input type="checkbox" value="~!:ELOG~!" ~!:CHECKED_ELOG~! name="ELOG" class="not-styled">\
|
||||||
|
</div>\
|
||||||
<!-- advanced options -->\
|
<!-- advanced options -->\
|
||||||
<div class="form-options-group">\
|
<div class="form-options-group">\
|
||||||
<div class="group-header cc collapsed">\
|
<div class="group-header cc collapsed">\
|
||||||
|
@ -531,26 +539,26 @@ App.Templates.html = {
|
||||||
</div>\
|
</div>\
|
||||||
<div class="form-row cc">\
|
<div class="form-row cc">\
|
||||||
<label for="#" class="field-label">statistics:</label>\
|
<label for="#" class="field-label">statistics:</label>\
|
||||||
<input type="checkbox" name="STATS" ~!:stats_checked~!="" value="~!:STATS~!" class="styled">\
|
<input type="checkbox" name="STATS" ~!:stats_checked~!="" value="~!:STATS~!" class="not-styled">\
|
||||||
</div>\
|
</div>\
|
||||||
<div class="stats-settings">\
|
<div class="stats-settings">\
|
||||||
<div class="form-row cc">\
|
<div class="form-row cc">\
|
||||||
<label for="#" class="field-label">stats auth:</label>\
|
<label for="#" class="field-label">stats auth:</label>\
|
||||||
<input type="checkbox" name="STATS_AUTH" ~!:stats_auth_checked~!="" value="~!:STATS_AUTH~!" class="styled">\
|
<input id="stats-auth-enable" type="checkbox" name="STATS_AUTH" ~!:stats_auth_checked~!="" value="~!:STATS_AUTH~!" class="not-styled">\
|
||||||
</div>\
|
</div>\
|
||||||
<div class="form-row cc">\
|
<div class="form-row cc">\
|
||||||
<label for="#" class="field-label">login:</label>\
|
<label for="#" class="field-label">stats login:</label>\
|
||||||
<input type="text" class="text-field rule-username" name="STATS_LOGIN" value="~!:STATS_LOGIN~!">\
|
<input type="text" class="text-field rule-statslogin" name="STATS_LOGIN" value="~!:STATS_LOGIN~!">\
|
||||||
</div>\
|
</div>\
|
||||||
<div class="form-row pwd-box cc">\
|
<div class="form-row pwd-box cc">\
|
||||||
<label for="#" class="field-label">password:</label>\
|
<label for="#" class="field-label">password:</label>\
|
||||||
<input type="text" value="~!:STATS_PASSWORD~!" name="STATS_PASSWORD" class="text-field rule-password">\
|
<input type="text" value="~!:STATS_PASSWORD~!" name="STATS_PASSWORD" class="text-field rule-statspassword password">\
|
||||||
<span class="generate-pwd do_action_generate_pass">Generate</span>\
|
<span class="generate-pwd do_action_generate_pass">Generate</span>\
|
||||||
</div>\
|
</div>\
|
||||||
</div><!-- // stats settings -->\
|
</div><!-- // stats settings -->\
|
||||||
<div class="form-row cc">\
|
<div class="form-row cc">\
|
||||||
<label for="#" class="field-label">ssl:</label>\
|
<label for="#" class="field-label">ssl:</label>\
|
||||||
<input type="checkbox" class="styled" ~!:ssl_checked~!="" value="~!SSL~!">\
|
<input type="checkbox" name="SSL" class="styled" ~!:ssl_checked~!="" value="~!SSL~!">\
|
||||||
</div>\
|
</div>\
|
||||||
<div class="form-row cc">\
|
<div class="form-row cc">\
|
||||||
<label for="#" class="field-label">ssl home:</label>\
|
<label for="#" class="field-label">ssl home:</label>\
|
||||||
|
@ -572,7 +580,7 @@ App.Templates.html = {
|
||||||
<div class="sub_section hidden">\
|
<div class="sub_section hidden">\
|
||||||
<div class="form-row cc">\
|
<div class="form-row cc">\
|
||||||
<label for="#" class="field-label">create dns domain:</label>\
|
<label for="#" class="field-label">create dns domain:</label>\
|
||||||
<input type="checkbox" value="" class="not-styled">\
|
<input type="checkbox" value="~!:DNS~!" ~!:CHECKED_DNS~! name="DNS" class="not-styled">\
|
||||||
</div>\
|
</div>\
|
||||||
</div><!-- DNS options -->\
|
</div><!-- DNS options -->\
|
||||||
<div class="form-options-group">\
|
<div class="form-options-group">\
|
||||||
|
@ -584,7 +592,7 @@ App.Templates.html = {
|
||||||
<div class="sub_section hidden">\
|
<div class="sub_section hidden">\
|
||||||
<div class="form-row cc">\
|
<div class="form-row cc">\
|
||||||
<label for="#" class="field-label">create mail domain:</label>\
|
<label for="#" class="field-label">create mail domain:</label>\
|
||||||
<input type="checkbox" value="" class="not-styled">\
|
<input type="checkbox" value="~!:MAIL~!" ~!:CHECKED_MAIL~! name="MAIL" class="not-styled">\
|
||||||
</div>\
|
</div>\
|
||||||
</div>\
|
</div>\
|
||||||
</div>\
|
</div>\
|
||||||
|
|
|
@ -25,9 +25,25 @@ App.Validate.getFieldName = function(elm)
|
||||||
}
|
}
|
||||||
|
|
||||||
App.Validate.Rule = {
|
App.Validate.Rule = {
|
||||||
|
'statslogin' : function(elm) {
|
||||||
|
if (!!$('#stats-auth-enable').attr('checked') == true) {
|
||||||
|
if ($(elm).val().trim() == '' || $(elm).val().search(/[^a-zA-Z_]+/) != -1) {
|
||||||
|
return {VALID: false, ERROR: App.Validate.getFieldName(elm) + ' is invalid'};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return {VALID: true};
|
||||||
|
},
|
||||||
|
'statspassword': function(elm) {
|
||||||
|
if (!!$('#stats-auth-enable').attr('checked') == true) {
|
||||||
|
if ($(elm).val().trim() == '') {
|
||||||
|
return {VALID: false, ERROR: App.Validate.getFieldName(elm) + ' is required'};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return {VALID: true};
|
||||||
|
},
|
||||||
'username' : function(elm) {
|
'username' : function(elm) {
|
||||||
if ($(elm).val().trim() != '' && $(elm).val().search(/[^a-zA-Z_]+/) != -1) {
|
if ($(elm).val().trim() != '' && $(elm).val().search(/[^a-zA-Z_]+/) != -1) {
|
||||||
return {VALID: false, ERROR: App.Validate.getFieldName(elm) + ' is required'};
|
return {VALID: false, ERROR: App.Validate.getFieldName(elm) + ' is invalid'};
|
||||||
}
|
}
|
||||||
return {VALID: true};
|
return {VALID: true};
|
||||||
},
|
},
|
||||||
|
@ -173,6 +189,7 @@ App.Validate.displayFormErrors = function(world, elm)
|
||||||
var ref = $('.form-error', elm);
|
var ref = $('.form-error', elm);
|
||||||
ref.removeClass('hidden');
|
ref.removeClass('hidden');
|
||||||
ref.html(errors_tpl);
|
ref.html(errors_tpl);
|
||||||
|
App.Helpers.scrollTo(ref);
|
||||||
}
|
}
|
||||||
|
|
||||||
App.Validate.getRules = function(elm)
|
App.Validate.getRules = function(elm)
|
||||||
|
@ -180,7 +197,8 @@ App.Validate.getRules = function(elm)
|
||||||
try {
|
try {
|
||||||
var rules_string = $(elm).attr('class');
|
var rules_string = $(elm).attr('class');
|
||||||
var rules = [];
|
var rules = [];
|
||||||
$(rules_string.split(/\s/)).each(function(i, str)
|
var rules_splitted = rules_string.split(/\s/);
|
||||||
|
$(rules_splitted).each(function(i, str)
|
||||||
{
|
{
|
||||||
var rule = str.split('rule-');
|
var rule = str.split('rule-');
|
||||||
if (rule.length > 1) {
|
if (rule.length > 1) {
|
||||||
|
|
|
@ -13,6 +13,7 @@ class AjaxHandler {
|
||||||
static public $instance = null;
|
static public $instance = null;
|
||||||
|
|
||||||
const JSON = 'json';
|
const JSON = 'json';
|
||||||
|
const TEXT = 'text';
|
||||||
public $errors = array();
|
public $errors = array();
|
||||||
public $status = TRUE;
|
public $status = TRUE;
|
||||||
|
|
||||||
|
|
|
@ -43,7 +43,7 @@ class MAIN extends AjaxHandler
|
||||||
*/
|
*/
|
||||||
public function getInitialExecute(Request $request)
|
public function getInitialExecute(Request $request)
|
||||||
{
|
{
|
||||||
require_once V_ROOT_DIR . 'api/IP.class.php';
|
/*require_once V_ROOT_DIR . 'api/IP.class.php';
|
||||||
require_once V_ROOT_DIR . 'api/USER.class.php';
|
require_once V_ROOT_DIR . 'api/USER.class.php';
|
||||||
// IP
|
// IP
|
||||||
$ip_obj = new IP();
|
$ip_obj = new IP();
|
||||||
|
@ -62,46 +62,96 @@ class MAIN extends AjaxHandler
|
||||||
$data_ip = array('user_names' => $user_names, 'interfaces' => $interfaces);
|
$data_ip = array('user_names' => $user_names, 'interfaces' => $interfaces);
|
||||||
$data_dns = array('ips' => $ips);
|
$data_dns = array('ips' => $ips);
|
||||||
$data_db = array('db_types' => $this->getDBTypes());
|
$data_db = array('db_types' => $this->getDBTypes());
|
||||||
$data_users = array('user_names' => $user_names);
|
$data_users = array('user_names' => $user_names);*/
|
||||||
|
$user = VestaSession::getInstance()->getUser();
|
||||||
|
$global_data = array();
|
||||||
|
$totals = array(
|
||||||
|
'USER' => array('total' => 0, 'blocked' => 0),
|
||||||
|
'WEB_DOMAIN' => array('total' => 0, 'blocked' => 0),
|
||||||
|
'MAIL' => array('total' => 0),
|
||||||
|
'DB' => array('total' => 0, 'blocked' => 0),
|
||||||
|
'DNS' => array('total' => 0, 'blocked' => 0),
|
||||||
|
'IP' => array('total' => 0, 'blocked' => 0),
|
||||||
|
'CRON' => array('total' => 0, 'blocked' => 0)
|
||||||
|
);
|
||||||
|
|
||||||
|
// users
|
||||||
|
$rs = Vesta::execute(Vesta::V_LIST_SYS_USERS, null, self::JSON);
|
||||||
|
$data_user = $rs['data'];
|
||||||
|
$global_data['users'] = array();
|
||||||
|
foreach ($data_user as $login_name => $usr) {
|
||||||
|
$totals['USER']['total'] += 1;
|
||||||
|
if ($usr['SUSPENDED'] != 'yes') {
|
||||||
|
$global_data['users'][$login_name] = $login_name;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$totals['USER']['blocked'] += 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// web_domains
|
||||||
|
$rs = Vesta::execute(Vesta::V_LIST_WEB_DOMAINS, array('USER' => $user['uid']), self::JSON);
|
||||||
|
$data_web_domain = $rs['data'];
|
||||||
|
foreach ($data_web_domain as $web) {
|
||||||
|
$totals['WEB_DOMAIN']['total'] += 1;
|
||||||
|
}
|
||||||
|
// db
|
||||||
|
$rs = Vesta::execute(Vesta::V_LIST_DB_BASES, array('USER' => $user['uid']), self::JSON);
|
||||||
|
$data_db = $rs['data'];
|
||||||
|
foreach ($data_db as $db) {
|
||||||
|
$totals['DB']['total'] += 1;
|
||||||
|
//$db['SUSPENDED'] == 'yes' ? $totals['DB']['blocked'] += 1 : false;
|
||||||
|
}
|
||||||
|
// dns
|
||||||
|
$rs = Vesta::execute(Vesta::V_LIST_DNS_DOMAINS, array('USER' => $user['uid']), self::JSON);
|
||||||
|
$data_dns = $rs['data'];
|
||||||
|
foreach ($data_dns as $dns) {
|
||||||
|
$totals['DNS']['total'] += 1;
|
||||||
|
}
|
||||||
|
// ip
|
||||||
|
$global_data['ips'] = array();
|
||||||
|
$rs = Vesta::execute(Vesta::V_LIST_SYS_IPS, null, self::JSON);
|
||||||
|
$data_ip = $rs['data'];
|
||||||
|
foreach ($data_ip as $ip => $obj) {
|
||||||
|
$totals['IP']['total'] += 1;
|
||||||
|
$global_data['ips'][$ip] = $ip;
|
||||||
|
}
|
||||||
|
// cron
|
||||||
|
$rs = Vesta::execute(Vesta::V_LIST_CRON_JOBS, array('USER' => $user['uid']), self::JSON);
|
||||||
|
$data_cron = $rs['data'];
|
||||||
|
foreach ($data_cron as $cron) {
|
||||||
|
$totals['CRON']['total'] += 1;
|
||||||
|
$cron['SUSPEND'] == 'yes' ? $totals['CRON']['blocked'] += 1 : false;
|
||||||
|
}
|
||||||
|
|
||||||
$reply = array(
|
$reply = array(
|
||||||
'WEB_DOMAIN' => $this->getWebDomainParams($data_web_domain),
|
'WEB_DOMAIN' => $this->getWebDomainParams($data_web_domin, $global_data),
|
||||||
'CRON' => $this->getCronParams(),
|
'CRON' => $this->getCronParams(),
|
||||||
'IP' => $this->getIpParams($data_ip),
|
'IP' => $this->getIpParams($data_ip, $global_data),
|
||||||
'DNS' => $this->getDnsParams(),
|
'DNS' => $this->getDnsParams(),
|
||||||
'DB' => $this->getDbParams($data_db),
|
'DB' => $this->getDbParams($data_db),
|
||||||
'USERS' => $this->getUsersParams($data_users),
|
'USERS' => $this->getUsersParams($data_user),
|
||||||
'totals' => $this->getTotals()
|
'totals' => $totals
|
||||||
);
|
);
|
||||||
|
|
||||||
return $this->reply(true, $reply);
|
return $this->reply(true, $reply);
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//
|
|
||||||
|
|
||||||
public function getTotals($data = array())
|
|
||||||
{
|
|
||||||
return array(
|
|
||||||
'USER' => array('total' => 7, 'blocked' => 0),
|
|
||||||
'WEB_DOMAIN' => array('total' => 4, 'blocked' => 0),
|
|
||||||
'MAIL' => array('total' => 0),
|
|
||||||
'DB' => array('total' => 4, 'blocked' => 0),
|
|
||||||
'DNS' => array('total' => 4, 'blocked' => 0),
|
|
||||||
'IP' => array('total' => 2, 'blocked' => 0),
|
|
||||||
'CRON' => array('total' => 5, 'blocked' => 0)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* WEB DOMAIN initial params
|
* WEB DOMAIN initial params
|
||||||
*
|
*
|
||||||
* @params array $data
|
* @params array $data
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function getWebDomainParams($data = array())
|
public function getWebDomainParams($data, $global_data)
|
||||||
{
|
{
|
||||||
|
$user = $this->getLoggedUser();
|
||||||
|
$ips = array();
|
||||||
|
//v_list_sys_user_ips vesta
|
||||||
|
$result = Vesta::execute(Vesta::V_LIST_SYS_USER_IPS, array('USER' => $user['uid']), self::JSON);
|
||||||
|
foreach ($result['data'] as $sys_ip => $ip_data) {
|
||||||
|
$ips[$sys_ip] = $sys_ip;
|
||||||
|
}
|
||||||
|
|
||||||
return array(
|
return array(
|
||||||
'TPL' => array('default' => 'default'),
|
'TPL' => array('default' => 'default'),
|
||||||
'ALIAS' => array(),
|
'ALIAS' => array(),
|
||||||
|
@ -109,7 +159,7 @@ class MAIN extends AjaxHandler
|
||||||
'webalizer' => 'webalizer',
|
'webalizer' => 'webalizer',
|
||||||
'awstats' => 'awstats'
|
'awstats' => 'awstats'
|
||||||
),
|
),
|
||||||
'IP' => $data['ips']
|
'IP' => $ips
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -130,19 +180,23 @@ class MAIN extends AjaxHandler
|
||||||
* @params array $data
|
* @params array $data
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function getIpParams($data = array())
|
public function getIpParams($data = array(), $global_data = array())
|
||||||
{
|
{
|
||||||
$users = array();
|
$ifaces = array();
|
||||||
foreach ((array)$data['user_names'] as $user) {
|
$result = Vesta::execute(Vesta::V_LIST_SYS_INTERFACES, array(Config::get('response_type')));
|
||||||
$users[$user] = $user;
|
|
||||||
|
foreach ($result['data'] as $iface) {
|
||||||
|
$ifaces[$iface] = $iface;
|
||||||
}
|
}
|
||||||
|
|
||||||
return array(
|
return array(
|
||||||
'SYS_USERS' => $users,
|
'SYS_USERS' => $users,
|
||||||
'STATUSES' => array(
|
'STATUSES' => array(
|
||||||
'shared' => 'shared',
|
'shared' => 'shared',
|
||||||
'exclusive' => 'exclusive'
|
'exclusive' => 'exclusive'
|
||||||
),
|
),
|
||||||
'INTERFACES' => $data['interfaces'],
|
'INTERFACES' => $ifaces,
|
||||||
|
'OWNER' => $global_data['users'],
|
||||||
'MASK' => array(
|
'MASK' => array(
|
||||||
'255.255.255.0' => '255.255.255.0',
|
'255.255.255.0' => '255.255.255.0',
|
||||||
'255.255.255.128' => '255.255.255.128',
|
'255.255.255.128' => '255.255.255.128',
|
||||||
|
@ -152,8 +206,7 @@ class MAIN extends AjaxHandler
|
||||||
'255.255.255.248' => '255.255.255.248',
|
'255.255.255.248' => '255.255.255.248',
|
||||||
'255.255.255.252' => '255.255.255.252',
|
'255.255.255.252' => '255.255.255.252',
|
||||||
'255.255.255.255' => '255.255.255.255'
|
'255.255.255.255' => '255.255.255.255'
|
||||||
),
|
)
|
||||||
'OWNER' => array('Chuck Norris' => 'Chuck Norris')
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -211,14 +264,12 @@ class MAIN extends AjaxHandler
|
||||||
'ROLE' => array('user' => 'user'),
|
'ROLE' => array('user' => 'user'),
|
||||||
'OWNER' => $data['user_names'],
|
'OWNER' => $data['user_names'],
|
||||||
'PACKAGE' => array('default' => 'default'),
|
'PACKAGE' => array('default' => 'default'),
|
||||||
'NS1' => array('' => ''),
|
|
||||||
'NS2' => array('' => ''),
|
|
||||||
'SHELL' => array(
|
'SHELL' => array(
|
||||||
'/bin/sh' => '/bin/sh',
|
'sh' => 'sh',
|
||||||
'/bin/bash' => '/bin/bash',
|
'bash' => 'bash',
|
||||||
'/sbin/nologin' => '/sbin/nologin',
|
'nologin' => 'nologin',
|
||||||
'/bin/tcsh' => '/bin/tcsh',
|
'tcsh' => 'tcsh',
|
||||||
'/bin/csh' => '/bin/csh')
|
'csh' => 'csh')
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -21,13 +21,16 @@ class USER extends AjaxHandler
|
||||||
{
|
{
|
||||||
$reply = array();
|
$reply = array();
|
||||||
$result = Vesta::execute(Vesta::V_LIST_SYS_USERS, array(Config::get('response_type')));
|
$result = Vesta::execute(Vesta::V_LIST_SYS_USERS, array(Config::get('response_type')));
|
||||||
$users = array('Han Solo', 'Darth Vader', 'Jabba the Hutt', 'Boba Fett', 'Jango Fett', ' Aurra Sing', 'Padme',
|
|
||||||
'Tusken Raider', 'General Grievous', 'Wedge Antilles', 'Padme Amidala', 'Bib Fortuna', 'Kyle Katarn',
|
|
||||||
'Quinlan Vos', 'Princess Leia', 'Obi-Wan Kenobi', 'Han Solo', 'Hondo Ohnaka', 'Noa Briqualon', 'C3P0',
|
|
||||||
'R2-D2', 'Quinlan Vos', 'Mara Jade' , 'Luke Skywalker', 'Luke Skywalker' , 'Luke Skywalker'
|
|
||||||
);
|
|
||||||
|
|
||||||
foreach ($result['data'] as $user => $details) {
|
foreach ($result['data'] as $user => $details) {
|
||||||
|
// get reports attribute
|
||||||
|
$result_report = Vesta::execute(Vesta::V_GET_SYS_USER_VALUE, array('USER' => $user, 'VALUE' => 'reports'), self::TEXT);
|
||||||
|
if ($result_report['status'] != true) {
|
||||||
|
$report = null;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$report = $result_report['data'];
|
||||||
|
}
|
||||||
$fullname_id = rand(0, count($users)-1);
|
$fullname_id = rand(0, count($users)-1);
|
||||||
$fullname = implode('', array($details['FNAME'], ' ', $details['LNAME']));
|
$fullname = implode('', array($details['FNAME'], ' ', $details['LNAME']));
|
||||||
|
|
||||||
|
@ -68,7 +71,7 @@ class USER extends AjaxHandler
|
||||||
"DATE" => $details['DATE'],
|
"DATE" => $details['DATE'],
|
||||||
"U_MAIL_BOXES" => rand(1, 10), // TODO: skid
|
"U_MAIL_BOXES" => rand(1, 10), // TODO: skid
|
||||||
"U_MAIL_FORWARDERS" => rand(1, 10), // TODO: skid
|
"U_MAIL_FORWARDERS" => rand(1, 10), // TODO: skid
|
||||||
"REPORTS_ENABLED" => 'enabled' // TODO: skid
|
"REPORTS_ENABLED" => $report
|
||||||
);
|
);
|
||||||
$reply[$user] = array_merge($user_details, $nses);
|
$reply[$user] = array_merge($user_details, $nses);
|
||||||
}
|
}
|
||||||
|
@ -103,6 +106,8 @@ class USER extends AjaxHandler
|
||||||
$reports_result = $this->setUserReports($spell['LOGIN_NAME'], $spell['REPORTS_ENABLED']);
|
$reports_result = $this->setUserReports($spell['LOGIN_NAME'], $spell['REPORTS_ENABLED']);
|
||||||
// NS
|
// NS
|
||||||
$ns_result = $this->setNSentries($spell['LOGIN_NAME'], $spell);
|
$ns_result = $this->setNSentries($spell['LOGIN_NAME'], $spell);
|
||||||
|
// Set SHELL
|
||||||
|
$this->setShell($spell['LOGIN_NAME'], $spell['SHELL']);
|
||||||
|
|
||||||
if (!$result['status']) {
|
if (!$result['status']) {
|
||||||
$this->errors[] = array($result['error_code'] => $result['error_message']);
|
$this->errors[] = array($result['error_code'] => $result['error_message']);
|
||||||
|
@ -147,7 +152,7 @@ class USER extends AjaxHandler
|
||||||
|
|
||||||
$_USER = $_old['LOGIN_NAME'];
|
$_USER = $_old['LOGIN_NAME'];
|
||||||
|
|
||||||
if ($_old['PASSWORD'] != $_new['PASSWORD']) {
|
if (!empty($_new['PASSWORD']) && $_new['PASSWORD'] != Vesta::SAME_PASSWORD) {
|
||||||
$result = array();
|
$result = array();
|
||||||
$result = Vesta::execute(Vesta::V_CHANGE_SYS_USER_PASSWORD, array('USER' => $_USER, 'PASSWORD' => $_new['PASSWORD']));
|
$result = Vesta::execute(Vesta::V_CHANGE_SYS_USER_PASSWORD, array('USER' => $_USER, 'PASSWORD' => $_new['PASSWORD']));
|
||||||
if (!$result['status']) {
|
if (!$result['status']) {
|
||||||
|
@ -174,14 +179,17 @@ class USER extends AjaxHandler
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Set SHELL
|
||||||
|
$this->setShell($_USER, $_new['SHELL']);
|
||||||
|
|
||||||
$this->setNSentries($_USER, $_new);
|
$this->setNSentries($_USER, $_new);
|
||||||
|
|
||||||
$names = array(
|
$names = array(
|
||||||
'USER' => $_USER,
|
'USER' => $_USER,
|
||||||
'NAME' => $_new['LOGIN_NAME'],
|
|
||||||
'FNAME' => $_new['FNAME'],
|
'FNAME' => $_new['FNAME'],
|
||||||
'LNAME' => $_new['LNAME']
|
'LNAME' => $_new['LNAME']
|
||||||
);
|
);
|
||||||
|
|
||||||
$result = Vesta::execute(Vesta::V_CHANGE_SYS_USER_NAME, $names);
|
$result = Vesta::execute(Vesta::V_CHANGE_SYS_USER_NAME, $names);
|
||||||
if (!$result['status']) {
|
if (!$result['status']) {
|
||||||
$this->status = FALSE;
|
$this->status = FALSE;
|
||||||
|
@ -251,4 +259,11 @@ class USER extends AjaxHandler
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* TODO: handle result set errors
|
||||||
|
*/
|
||||||
|
protected function setShell($user, $shell)
|
||||||
|
{
|
||||||
|
$result = Vesta::execute(Vesta::V_CHANGE_SYS_USER_SHELL, array('USER' => $user, 'SHELL' => $shell));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,10 +15,11 @@ class WEB_DOMAIN extends AjaxHandler
|
||||||
$user = $this->getLoggedUser();
|
$user = $this->getLoggedUser();
|
||||||
$reply = array();
|
$reply = array();
|
||||||
|
|
||||||
$result = Vesta::execute(Vesta::V_LIST_WEB_DOMAINS, array($user['uid'], Config::get('response_type')));
|
$result = Vesta::execute(Vesta::V_LIST_WEB_DOMAINS, array('USER' => $user['uid']), self::JSON);
|
||||||
|
|
||||||
foreach($result['data'] as $web_domain => $data)
|
foreach($result['data'] as $web_domain => $record)
|
||||||
{
|
{
|
||||||
|
//print '<pre>';var_dump($record);die();
|
||||||
$reply[$web_domain] = array(
|
$reply[$web_domain] = array(
|
||||||
'IP' => $record['IP'],
|
'IP' => $record['IP'],
|
||||||
'U_DISK' => $record['U_DISK'],
|
'U_DISK' => $record['U_DISK'],
|
||||||
|
@ -66,7 +67,7 @@ class WEB_DOMAIN extends AjaxHandler
|
||||||
$this->errors[] = array($result['error_code'] => $result['error_message']);
|
$this->errors[] = array($result['error_code'] => $result['error_message']);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($_s['TPL']) {
|
if (!empty($_s['TPL'])) {
|
||||||
$params = array(
|
$params = array(
|
||||||
'USER' => $user['uid'],
|
'USER' => $user['uid'],
|
||||||
'DOMAIN' => $_s['DOMAIN'],
|
'DOMAIN' => $_s['DOMAIN'],
|
||||||
|
@ -80,8 +81,9 @@ class WEB_DOMAIN extends AjaxHandler
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($_s['ALIAS']) {
|
if (!empty($_s['ALIAS'])) {
|
||||||
$alias_arr = explode(',', $_s['ALIAS']);
|
$alias = str_replace("\n", "", $_s['ALIAS']);
|
||||||
|
$alias = str_replace("\n", "", $alias);
|
||||||
|
|
||||||
foreach ($alias_arr as $alias) {
|
foreach ($alias_arr as $alias) {
|
||||||
$params = array(
|
$params = array(
|
||||||
|
@ -99,11 +101,11 @@ class WEB_DOMAIN extends AjaxHandler
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($_s['STAT']) {
|
if (!empty($_s['STATS'])) {
|
||||||
$params = array(
|
$params = array(
|
||||||
'USER' => $user['uid'],
|
'USER' => $user['uid'],
|
||||||
'DOMAIN' => $_s['DOMAIN'],
|
'DOMAIN' => $_s['DOMAIN'],
|
||||||
'STAT' => $_s['STAT']);
|
'STAT' => $_s['STATS'] == 'off' ? false : true);
|
||||||
$result = 0;
|
$result = 0;
|
||||||
$result = Vesta::execute(Vesta::V_ADD_WEB_DOMAIN_STAT, $params);
|
$result = Vesta::execute(Vesta::V_ADD_WEB_DOMAIN_STAT, $params);
|
||||||
|
|
||||||
|
@ -112,7 +114,7 @@ class WEB_DOMAIN extends AjaxHandler
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($_s['STAT_AUTH']) {
|
if (!empty($_s['STAT_AUTH'])) {
|
||||||
$params = array(
|
$params = array(
|
||||||
'USER' => $user['uid'],
|
'USER' => $user['uid'],
|
||||||
'DOMAIN' => $_s['DOMAIN'],
|
'DOMAIN' => $_s['DOMAIN'],
|
||||||
|
@ -126,8 +128,7 @@ class WEB_DOMAIN extends AjaxHandler
|
||||||
$this->errors['STAT_AUTH'] = array($result['error_code'] => $result['error_message']);
|
$this->errors['STAT_AUTH'] = array($result['error_code'] => $result['error_message']);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (0) {
|
/* if ($_s['SSL']) {
|
||||||
if ($_s['SSL']) {
|
|
||||||
$params = array(
|
$params = array(
|
||||||
'USER' => $user[''],
|
'USER' => $user[''],
|
||||||
'DOMAIN' => $_s['DOMAIN'],
|
'DOMAIN' => $_s['DOMAIN'],
|
||||||
|
@ -149,9 +150,9 @@ class WEB_DOMAIN extends AjaxHandler
|
||||||
$this->errors['SSL'] = array($result['error_code'] => $result['error_message']);
|
$this->errors['SSL'] = array($result['error_code'] => $result['error_message']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
*/
|
||||||
|
|
||||||
if ($_s['CREATE_DNS_DOMAIN']) {
|
/*if (!empty($_s['DNS'])) {
|
||||||
$params = array(
|
$params = array(
|
||||||
'USER' => $user['uid'],
|
'USER' => $user['uid'],
|
||||||
'DNS_DOMAIN' => $_s['DOMAIN'],
|
'DNS_DOMAIN' => $_s['DOMAIN'],
|
||||||
|
@ -166,10 +167,10 @@ class WEB_DOMAIN extends AjaxHandler
|
||||||
if (!$result['status']) {
|
if (!$result['status']) {
|
||||||
$this->errors['DNS_DOMAIN'] = array($result['error_code'] => $result['error_message']);
|
$this->errors['DNS_DOMAIN'] = array($result['error_code'] => $result['error_message']);
|
||||||
}
|
}
|
||||||
}
|
}*/
|
||||||
|
|
||||||
/*
|
|
||||||
if ($_s['CREATE_MAIL_DOMAIN']) {
|
/*if (!empty($_s['MAIL'])) {
|
||||||
$params = array(
|
$params = array(
|
||||||
'USER' => $_user,
|
'USER' => $_user,
|
||||||
'MAIL_DOMAIN' => $_s['DOMAIN'],
|
'MAIL_DOMAIN' => $_s['DOMAIN'],
|
||||||
|
@ -184,8 +185,8 @@ class WEB_DOMAIN extends AjaxHandler
|
||||||
$result = $mail->addExecute($params);
|
$result = $mail->addExecute($params);
|
||||||
if (!$result['status'])
|
if (!$result['status'])
|
||||||
$this->errors['MAIL_DOMAIN'] = array($result['error_code'] => $result['error_message']);
|
$this->errors['MAIL_DOMAIN'] = array($result['error_code'] => $result['error_message']);
|
||||||
}
|
}*/
|
||||||
*/
|
|
||||||
|
|
||||||
return $this->reply($result['status'], $result['data']);
|
return $this->reply($result['status'], $result['data']);
|
||||||
}
|
}
|
||||||
|
@ -211,21 +212,6 @@ class WEB_DOMAIN extends AjaxHandler
|
||||||
'DNS_DOMAIN' => $_s['DOMAIN']
|
'DNS_DOMAIN' => $_s['DOMAIN']
|
||||||
);
|
);
|
||||||
|
|
||||||
require_once V_ROOT_DIR . 'api/DNS.class.php';
|
|
||||||
$dns = new DNS();
|
|
||||||
$result = $dns->delExecute($params);
|
|
||||||
|
|
||||||
if (!$result['status'] && $result['error_code'] != 31) { // domain not found
|
|
||||||
$this->errors['DNS'] = array($result['error_code'] => $result['error_message']);
|
|
||||||
}
|
|
||||||
|
|
||||||
require_once V_ROOT_DIR . 'api/DNS.class.php';
|
|
||||||
|
|
||||||
$params = array(
|
|
||||||
'USER' => $user['uid'],
|
|
||||||
'MAIL_DOMAIN' => $_s['DOMAIN']
|
|
||||||
);
|
|
||||||
|
|
||||||
return $this->reply($result['status'], $result['data']);
|
return $this->reply($result['status'], $result['data']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -240,7 +226,7 @@ class WEB_DOMAIN extends AjaxHandler
|
||||||
|
|
||||||
if ($_old['IP'] != $_new['IP']) {
|
if ($_old['IP'] != $_new['IP']) {
|
||||||
$result = array();
|
$result = array();
|
||||||
$result = Vesta::execute(Vesta::V_CHANGE_WEB_DOMAIN_IP, array('USER' => $_user, 'DOMAIN' => $_DOMAIN, 'IP' => $_new['IP']));
|
$result = Vesta::execute(Vesta::V_CHANGE_WEB_DOMAIN_IP, array('USER' => $user['uid'], 'DOMAIN' => $_DOMAIN, 'IP' => $_new['IP']));
|
||||||
if (!$result['status']) {
|
if (!$result['status']) {
|
||||||
$this->status = FALSE;
|
$this->status = FALSE;
|
||||||
$this->errors['IP_ADDRESS'] = array($result['error_code'] => $result['error_message']);
|
$this->errors['IP_ADDRESS'] = array($result['error_code'] => $result['error_message']);
|
||||||
|
@ -249,7 +235,7 @@ class WEB_DOMAIN extends AjaxHandler
|
||||||
|
|
||||||
if ($_old['TPL'] != $_new['TPL']) {
|
if ($_old['TPL'] != $_new['TPL']) {
|
||||||
$result = array();
|
$result = array();
|
||||||
$result = Vesta::execute(Vesta::V_CHANGE_WEB_DOMAIN_TPL, array('USER' => $_user, 'DOMAIN' => $_DOMAIN, 'TPL' => $_new['TPL']));
|
$result = Vesta::execute(Vesta::V_CHANGE_WEB_DOMAIN_TPL, array('USER' => $user['uid'], 'DOMAIN' => $_DOMAIN, 'TPL' => $_new['TPL']));
|
||||||
if (!$result['status']) {
|
if (!$result['status']) {
|
||||||
$this->status = FALSE;
|
$this->status = FALSE;
|
||||||
$this->errors['TPL'] = array($result['error_code'] => $result['error_message']);
|
$this->errors['TPL'] = array($result['error_code'] => $result['error_message']);
|
||||||
|
@ -266,7 +252,7 @@ class WEB_DOMAIN extends AjaxHandler
|
||||||
$deleted = array_diff($old_arr, $new_arr);
|
$deleted = array_diff($old_arr, $new_arr);
|
||||||
|
|
||||||
foreach ($added as $alias) {
|
foreach ($added as $alias) {
|
||||||
$result = Vesta::execute(Vesta::V_ADD_WEB_DOMAIN_ALIAS, array('USER' => $_user, 'DOMAIN' => $_DOMAIN, 'ALIAS' => $alias));
|
$result = Vesta::execute(Vesta::V_ADD_WEB_DOMAIN_ALIAS, array('USER' => $user['uid'], 'DOMAIN' => $_DOMAIN, 'ALIAS' => $alias));
|
||||||
if (!$result['status']) {
|
if (!$result['status']) {
|
||||||
$this->status = FALSE;
|
$this->status = FALSE;
|
||||||
$this->errors['ADD_ALIAS'] = array($result['error_code'] => $result['error_message']);
|
$this->errors['ADD_ALIAS'] = array($result['error_code'] => $result['error_message']);
|
||||||
|
@ -274,7 +260,7 @@ class WEB_DOMAIN extends AjaxHandler
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($deleted as $alias) {
|
foreach ($deleted as $alias) {
|
||||||
$result = Vesta::execute(Vesta::V_DEL_WEB_DOMAIN_ALIAS, array('USER' => $_user, 'DOMAIN' => $_DOMAIN, 'ALIAS' => $alias));
|
$result = Vesta::execute(Vesta::V_DEL_WEB_DOMAIN_ALIAS, array('USER' => $user['uid'], 'DOMAIN' => $_DOMAIN, 'ALIAS' => $alias));
|
||||||
if (!$result['status']) {
|
if (!$result['status']) {
|
||||||
$this->status = FALSE;
|
$this->status = FALSE;
|
||||||
$this->errors['DEL_ALIAS'] = array($result['error_code'] => $result['error_message']);
|
$this->errors['DEL_ALIAS'] = array($result['error_code'] => $result['error_message']);
|
||||||
|
@ -283,26 +269,26 @@ class WEB_DOMAIN extends AjaxHandler
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if ($_old['STAT'] != $_new['STAT']) {
|
if (!empty($_new['STAT'])) {
|
||||||
if ($_new['STAT'] == true) {
|
if ($_new['STAT'] == true) {
|
||||||
$result = array();
|
$result = array();
|
||||||
$result = Vesta::execute(Vesta::V_ADD_WEB_DOMAIN_STAT, array('USER' => $_user, 'DOMAIN' => $_DOMAIN, 'STAT' => $_new['STAT']));
|
$result = Vesta::execute(Vesta::V_ADD_WEB_DOMAIN_STAT, array('USER' => $user['uid'], 'DOMAIN' => $_DOMAIN, 'STAT' => ($_new['STAT'] == 'off' ? false : true)));
|
||||||
if (!$result['status']) {
|
if (!$result['status']) {
|
||||||
$this->status = FALSE;
|
$this->status = FALSE;
|
||||||
$this->errors['ADD_STAT'] = array($result['error_code'] => $result['error_message']);
|
$this->errors['ADD_STAT'] = array($result['error_code'] => $result['error_message']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($_new['STAT'] == false) {
|
if ($_new['STAT'] == 'off') {
|
||||||
$result = array();
|
$result = array();
|
||||||
$result = Vesta::execute(Vesta::V_DEL_WEB_DOMAIN_STAT, array('USER' => $_user, 'DOMAIN' => $_DOMAIN));
|
$result = Vesta::execute(Vesta::V_DEL_WEB_DOMAIN_STAT, array('USER' => $user['uid'], 'DOMAIN' => $_DOMAIN));
|
||||||
if (!$result['status']) {
|
if (!$result['status']) {
|
||||||
$this->status = FALSE;
|
$this->status = FALSE;
|
||||||
$this->errors['DEL_STAT'] = array($result['error_code'] => $result['error_message']);
|
$this->errors['DEL_STAT'] = array($result['error_code'] => $result['error_message']);
|
||||||
}
|
}
|
||||||
$result = array();
|
$result = array();
|
||||||
|
|
||||||
$result = Vesta::execute(Vesta::V_DEL_WEB_DOMAIN_STAT_AUTH, array('USER' => $_user, 'DOMAIN' => $_DOMAIN, 'STAT_USER' => $_new['STAT_USER']));
|
$result = Vesta::execute(Vesta::V_DEL_WEB_DOMAIN_STAT_AUTH, array('USER' => $user['uid'], 'DOMAIN' => $_DOMAIN, 'STAT_USER' => $_new['STAT_USER']));
|
||||||
if (!$result['status']) {
|
if (!$result['status']) {
|
||||||
$this->status = FALSE;
|
$this->status = FALSE;
|
||||||
$this->errors['DEL_STAT_AUTH'] = array($result['error_code'] => $result['error_message']);
|
$this->errors['DEL_STAT_AUTH'] = array($result['error_code'] => $result['error_message']);
|
||||||
|
@ -313,7 +299,7 @@ class WEB_DOMAIN extends AjaxHandler
|
||||||
if ($_old['CGI'] != $_new['CGI']) {
|
if ($_old['CGI'] != $_new['CGI']) {
|
||||||
if ($_new['CGI'] == true) {
|
if ($_new['CGI'] == true) {
|
||||||
$result = array();
|
$result = array();
|
||||||
$result = Vesta::execute(Vesta::V_ADD_WEB_DOMAIN_CGI, array('USER' => $_user, 'DOMAIN' => $_DOMAIN));
|
$result = Vesta::execute(Vesta::V_ADD_WEB_DOMAIN_CGI, array('USER' => $user['uid'], 'DOMAIN' => $_DOMAIN));
|
||||||
if (!$result['status']) {
|
if (!$result['status']) {
|
||||||
$this->status = FALSE;
|
$this->status = FALSE;
|
||||||
$this->errors['ADD_CGI'] = array($result['error_code'] => $result['error_message']);
|
$this->errors['ADD_CGI'] = array($result['error_code'] => $result['error_message']);
|
||||||
|
@ -322,7 +308,7 @@ class WEB_DOMAIN extends AjaxHandler
|
||||||
|
|
||||||
if ($_new['CGI'] == false) {
|
if ($_new['CGI'] == false) {
|
||||||
$result = array();
|
$result = array();
|
||||||
$result = Vesta::execute(Vesta::V_DEL_WEB_DOMAIN_CGI, array('USER' => $_user, 'DOMAIN' => $_DOMAIN));
|
$result = Vesta::execute(Vesta::V_DEL_WEB_DOMAIN_CGI, array('USER' => $user['uid'], 'DOMAIN' => $_DOMAIN));
|
||||||
if (!$result['status']) {
|
if (!$result['status']) {
|
||||||
$this->status = FALSE;
|
$this->status = FALSE;
|
||||||
$this->errors['DEL_CGI'] = array($result['error_code'] => $result['error_message']);
|
$this->errors['DEL_CGI'] = array($result['error_code'] => $result['error_message']);
|
||||||
|
@ -333,7 +319,7 @@ class WEB_DOMAIN extends AjaxHandler
|
||||||
if ($_old['ELOG'] != $_new['ELOG']) {
|
if ($_old['ELOG'] != $_new['ELOG']) {
|
||||||
if ($_new['ELOG'] == true) {
|
if ($_new['ELOG'] == true) {
|
||||||
$result = array();
|
$result = array();
|
||||||
$result = Vesta::execute(Vesta::V_ADD_WEB_DOMAIN_ELOG, array('USER' => $_user, 'DOMAIN' => $_DOMAIN));
|
$result = Vesta::execute(Vesta::V_ADD_WEB_DOMAIN_ELOG, array('USER' => $user['uid'], 'DOMAIN' => $_DOMAIN));
|
||||||
if (!$result['status']) {
|
if (!$result['status']) {
|
||||||
$this->status = FALSE;
|
$this->status = FALSE;
|
||||||
$this->errors['ADD_ELOG'] = array($result['error_code'] => $result['error_message']);
|
$this->errors['ADD_ELOG'] = array($result['error_code'] => $result['error_message']);
|
||||||
|
@ -342,7 +328,7 @@ class WEB_DOMAIN extends AjaxHandler
|
||||||
|
|
||||||
if ($_new['ELOG'] == false) {
|
if ($_new['ELOG'] == false) {
|
||||||
$result = array();
|
$result = array();
|
||||||
$result = Vesta::execute(Vesta::V_DEL_WEB_DOMAIN_ELOG, array('USER' => $_user, 'DOMAIN' => $_DOMAIN));
|
$result = Vesta::execute(Vesta::V_DEL_WEB_DOMAIN_ELOG, array('USER' => $user['uid'], 'DOMAIN' => $_DOMAIN));
|
||||||
if (!$result['status']) {
|
if (!$result['status']) {
|
||||||
$this->status = FALSE;
|
$this->status = FALSE;
|
||||||
$this->errors['DEL_ELOG'] = array($result['error_code'] => $result['error_message']);
|
$this->errors['DEL_ELOG'] = array($result['error_code'] => $result['error_message']);
|
||||||
|
@ -361,7 +347,7 @@ class WEB_DOMAIN extends AjaxHandler
|
||||||
$user = $this->getLoggedUser();
|
$user = $this->getLoggedUser();
|
||||||
|
|
||||||
$params = array(
|
$params = array(
|
||||||
'USER' => $_user['uid'],
|
'USER' => $user['uid'],
|
||||||
'DOMAIN' => $_s['DOMAIN']
|
'DOMAIN' => $_s['DOMAIN']
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
define('V_ROOT_DIR', dirname(__FILE__) . DIRECTORY_SEPARATOR);
|
define('V_ROOT_DIR', dirname(__FILE__) . DIRECTORY_SEPARATOR);
|
||||||
|
|
||||||
require_once V_ROOT_DIR . 'config/Config.class.php';
|
require_once V_ROOT_DIR . 'config/Config.class.php';
|
||||||
|
require_once V_ROOT_DIR . 'core/utils/Utils.class.php';
|
||||||
require_once V_ROOT_DIR . 'core/VestaSession.class.php';
|
require_once V_ROOT_DIR . 'core/VestaSession.class.php';
|
||||||
require_once V_ROOT_DIR . 'core/Vesta.class.php';
|
require_once V_ROOT_DIR . 'core/Vesta.class.php';
|
||||||
require_once V_ROOT_DIR . 'core/exceptions/SystemException.class.php';
|
require_once V_ROOT_DIR . 'core/exceptions/SystemException.class.php';
|
||||||
|
|
|
@ -11,6 +11,8 @@
|
||||||
*/
|
*/
|
||||||
class Vesta
|
class Vesta
|
||||||
{
|
{
|
||||||
|
const SAME_PASSWORD = '********';
|
||||||
|
|
||||||
// IP
|
// IP
|
||||||
const V_LIST_SYS_IPS = 'v_list_sys_ips';
|
const V_LIST_SYS_IPS = 'v_list_sys_ips';
|
||||||
const V_ADD_SYS_IP = 'v_add_sys_ip';
|
const V_ADD_SYS_IP = 'v_add_sys_ip';
|
||||||
|
@ -46,6 +48,7 @@ class Vesta
|
||||||
const V_DEL_CRON_JOB = 'v_del_sys_cron';
|
const V_DEL_CRON_JOB = 'v_del_sys_cron';
|
||||||
const V_DEL_SYS_USER_REPORTS = 'v_del_sys_user_reports';
|
const V_DEL_SYS_USER_REPORTS = 'v_del_sys_user_reports';
|
||||||
// USER
|
// USER
|
||||||
|
const V_GET_SYS_USER_VALUE = 'v_get_sys_user_value';
|
||||||
const V_LIST_SYS_USERS = 'v_list_sys_users';
|
const V_LIST_SYS_USERS = 'v_list_sys_users';
|
||||||
const V_ADD_SYS_USER = 'v_add_sys_user';
|
const V_ADD_SYS_USER = 'v_add_sys_user';
|
||||||
const V_CHANGE_SYS_USER_CONTACT = 'v_change_sys_user_contact';
|
const V_CHANGE_SYS_USER_CONTACT = 'v_change_sys_user_contact';
|
||||||
|
@ -57,6 +60,7 @@ class Vesta
|
||||||
const V_DEL_SYS_USER = 'v_del_sys_user';
|
const V_DEL_SYS_USER = 'v_del_sys_user';
|
||||||
const V_CHANGE_SYS_USER_NAME = 'v_change_sys_user_name';
|
const V_CHANGE_SYS_USER_NAME = 'v_change_sys_user_name';
|
||||||
// WEB_DOMAIN
|
// WEB_DOMAIN
|
||||||
|
const V_LIST_SYS_USER_IPS = 'v_list_sys_user_ips';
|
||||||
const V_LIST_WEB_DOMAINS = 'v_list_web_domains';
|
const V_LIST_WEB_DOMAINS = 'v_list_web_domains';
|
||||||
const V_LIST_WEB_DOMAINS_ALIAS = 'v_list_web_domains_alias';
|
const V_LIST_WEB_DOMAINS_ALIAS = 'v_list_web_domains_alias';
|
||||||
const V_LIST_WEB_DOMAINS_ELOG = 'v_list_web_domains_elog';
|
const V_LIST_WEB_DOMAINS_ELOG = 'v_list_web_domains_elog';
|
||||||
|
@ -93,6 +97,7 @@ class Vesta
|
||||||
// DB
|
// DB
|
||||||
const V_LIST_DB_BASES = 'v_list_db_bases';
|
const V_LIST_DB_BASES = 'v_list_db_bases';
|
||||||
const V_LIST_DB_HOSTS = 'v_list_db_hosts';
|
const V_LIST_DB_HOSTS = 'v_list_db_hosts';
|
||||||
|
const V_LIST_WEB_DOMAIN_ALIAS = 'v_list_web_domain_alias';
|
||||||
const V_ADD_DB_BASE = 'v_add_db_base';
|
const V_ADD_DB_BASE = 'v_add_db_base';
|
||||||
const V_ADD_DB_HOST = 'v_add_db_host';
|
const V_ADD_DB_HOST = 'v_add_db_host';
|
||||||
const V_SUSPEND_DB_BASE = 'v_suspend_db_base';
|
const V_SUSPEND_DB_BASE = 'v_suspend_db_base';
|
||||||
|
@ -113,7 +118,7 @@ class Vesta
|
||||||
* @param array $parameters
|
* @param array $parameters
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
static function execute($cmd_command, $parameters=array())
|
static function execute($cmd_command, $parameters=array(), $reply = '')
|
||||||
{
|
{
|
||||||
$r = new Request();
|
$r = new Request();
|
||||||
$_DEBUG = $r->getParameter("debug", FALSE);
|
$_DEBUG = $r->getParameter("debug", FALSE);
|
||||||
|
@ -125,16 +130,12 @@ class Vesta
|
||||||
$params = array(
|
$params = array(
|
||||||
'sudo' => Config::get('sudo_path'),
|
'sudo' => Config::get('sudo_path'),
|
||||||
'functions' => Config::get('vesta_functions_path'),
|
'functions' => Config::get('vesta_functions_path'),
|
||||||
'parameters' => implode("' '", $parameters),
|
'parameters' => is_array($parameters) ? "'".implode("' '", $parameters)."'" : $parameters,
|
||||||
|
'reply' => $reply
|
||||||
);
|
);
|
||||||
|
|
||||||
if (!isset($params['reply'])) {
|
|
||||||
$params['reply'] = '';
|
|
||||||
}
|
|
||||||
|
|
||||||
// e.g.: /usr/bin/sudo /usr/local/vesta/bin/v_list_sys_users vesta json
|
// e.g.: /usr/bin/sudo /usr/local/vesta/bin/v_list_sys_users vesta json
|
||||||
$cmd = "{$params['sudo']} {$params['functions']}{$cmd_command} '{$params['parameters']}' {$params['reply']}";
|
$cmd = "{$params['sudo']} {$params['functions']}{$cmd_command} {$params['parameters']} {$params['reply']}";
|
||||||
// print $cmd;//die();
|
|
||||||
exec($cmd, $output, $return);
|
exec($cmd, $output, $return);
|
||||||
|
|
||||||
$result = 0;
|
$result = 0;
|
||||||
|
@ -152,7 +153,7 @@ class Vesta
|
||||||
"output" => $output,
|
"output" => $output,
|
||||||
"return" => $return
|
"return" => $return
|
||||||
);
|
);
|
||||||
if ($debug == 2) {
|
if ($_DEBUG == 2) {
|
||||||
echo '<p>'.$cmd;
|
echo '<p>'.$cmd;
|
||||||
echo '<br> output: '; print_r($output);
|
echo '<br> output: '; print_r($output);
|
||||||
echo '<br> return: '.$return;
|
echo '<br> return: '.$return;
|
||||||
|
@ -164,6 +165,12 @@ class Vesta
|
||||||
$result['status'] = FALSE;
|
$result['status'] = FALSE;
|
||||||
$result['error_code'] = (int)$return;
|
$result['error_code'] = (int)$return;
|
||||||
$result['error_message'] = implode('', $output);
|
$result['error_message'] = implode('', $output);
|
||||||
|
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($reply == 'text') {
|
||||||
|
$result['data'] = implode('', $output);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$result['data'] = json_decode(implode('', $output), true);
|
$result['data'] = json_decode(implode('', $output), true);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue