USERS / CRON / IP ready. DNS (partly). JS form validators written. Added functionality

This commit is contained in:
Dima Malishev 2011-09-03 18:20:14 +03:00
parent ea5a8a2659
commit 04c7a8b545
15 changed files with 568 additions and 297 deletions

View file

@ -8,7 +8,6 @@ App.i18n.getMessage = function(key)
} }
// Constants // Constants
App.Constants.IP_FORM_ID = 'ip-form'; App.Constants.IP_FORM_ID = 'ip-form';
App.Constants.DNS_FORM_ID = 'dns-form'; App.Constants.DNS_FORM_ID = 'dns-form';
@ -16,26 +15,31 @@ App.Constants.USER_FORM_ID = 'user-form';
App.Constants.WEB_DOMAIN_FORM_ID = 'web_domain-form'; App.Constants.WEB_DOMAIN_FORM_ID = 'web_domain-form';
App.Constants.DB_FORM_ID = 'db-form'; App.Constants.DB_FORM_ID = 'db-form';
App.Constants.CRON_FORM_ID = 'cron-form'; App.Constants.CRON_FORM_ID = 'cron-form';
App.Constants.IP = 'IP';
App.Constants.DNS = 'DNS';
App.Constants.SUSPENDED_YES = 'yes';
App.Constants.DNS_TEMPLATES = {'default': 'Default'};
// Settings
App.Settings.USER_VISIBLE_NS = 2;
App.Settings.NS_MIN = 2;
App.Settings.NS_MAX = 8;
App.Settings.ajax_url = 1; 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.Constants.SUSPENDED_YES = 'yes';
App.Constants.IP = 'IP';
App.Constants.DNS = 'DNS';
App.Constants.DNS_TEMPLATES = {'default': 'Default'};
// Messages
App.Messages.total_dns_records = {single: 'total record', plural: 'total records'}; App.Messages.total_dns_records = {single: 'total record', plural: 'total records'};
App.Messages.get = function(key, plural) { App.Messages.get = function(key, plural) {
if ('undefined' != typeof App.Messages[key]) { if ('undefined' != typeof App.Messages[key]) {
return plural ? App.Messages[key].plural : App.Messages[key].single; return plural ? App.Messages[key].plural : App.Messages[key].single;
} }
} }
// Empty
App.Empty = {};
App.Empty.USER = {'CONTACT':'', 'PASSWORD':'','LOGIN_NAME':'','LNAME':'', 'FNAME':'','NS1':'','NS2':'','NS3':'','NS4':'','NS5':'','NS6':'','NS7':'','NS8':''};
App.Settings.getMethodName = function(action) App.Settings.getMethodName = function(action)
{ {

View file

@ -104,7 +104,6 @@ App.Actions.save_form = function(evt) {
var source = $(elm).find('.source').val(); var source = $(elm).find('.source').val();
var values = App.Helpers.getFormValues(elm); var values = App.Helpers.getFormValues(elm);
if(App.Validate.form(values, $('#'+elm_id))) { if(App.Validate.form(values, $('#'+elm_id))) {
App.Model.add(values, source);
App.Model.update(values, source, elm); App.Model.update(values, source, elm);
} }
} }
@ -146,12 +145,49 @@ App.Actions.cancel_form = function(evt, params) {
App.Actions.suspend = function(evt) App.Actions.suspend = function(evt)
{ {
alert('Suspend?'); var confirmed = confirm('Suspend?');
if (!confirmed) {
return ;
}
var elm = $(evt.target);
var row = elm.parents('.row');
var options = row.find('.source').val();
App.Ajax.request(App.Env.world+'.suspend', {spell: options}, function(reply) {
if (reply.result) {
//var tpl = App.Templates.get('SUSPENDED_TPL_SUSPENDED', 'general');
//$(elm).replaceWith(tpl.finalize());
App.Pages.prepareHTML();
App.Helpers.updateScreen();
}
else {
return App.Helpers.alert('Failed to suspend');
}
});
} }
App.Actions.unsuspend = function(evt) App.Actions.unsuspend = function(evt)
{ {
alert('Unsuspend?'); var confirmed = confirm('Unsuspend?');
if (!confirmed) {
return ;
}
var elm = $(evt.target);
var row = elm.parents('.row');
var options = row.find('.source').val();
App.Ajax.request(App.Env.world+'.unsuspend', {spell: options}, function(reply) {
if (reply.result) {
//var tpl = App.Templates.get('SUSPENDED_TPL_NOT_SUSPENDED', 'general');
//$(elm).replaceWith(tpl.finalize());
App.Pages.prepareHTML();
App.Helpers.updateScreen();
}
else {
return App.Helpers.alert('Failed to suspend');
}
});
} }
// do_action_form_help // do_action_form_help
@ -230,3 +266,56 @@ App.Actions.backup_db = function(evt)
{ {
alert('TODO'); alert('TODO');
} }
App.Actions.add_form_ns = function(evt)
{
var elm = $(evt.target);
form = elm.parents('.form:first');
var total_nses = $(form).find('.ns-entry').length;
if (total_nses == App.Settings.NS_MAX) {
return App.Helpers.alert('Maximum number of NS cannot be more than ' + App.Settings.NS_MAX);
}
var tpl = App.Templates.get('NS_INPUT', 'user');
tpl.set(':NAME', '');
tpl.set(':NS_LABEL', 'NS');
elm.before(tpl.finalize());
if ((total_nses + 1) == App.Settings.NS_MAX ) { // added last NS
$('.additional-ns-add', form).addClass('hidden');
}
$(form).find('.ns-entry').each(function(i, o)
{
$(o).find('label').text('NS #' + (i + 1));
$(o).find('input').attr('name', 'NS' + (i + 1));
});
}
App.Actions.delete_ns = function(evt)
{
var elm = $(evt.target);
form = elm.parents('.form:first');
var total_nses = $(form).find('.ns-entry').length;
if (total_nses == App.Settings.NS_MIN) {
return App.Helpers.alert('Minimum number of NS is ' + App.Settings.NS_MIN);
}
var form = elm.parents('.form:first');
$(elm).parents('.form:first').find('.additional-ns-add').removeClass('hidden');
$(elm).parents('.ns-entry').remove();
$(form).find('.ns-entry').each(function(i, o)
{
$(o).find('label').text('NS #' + (i + 1));
$(o).find('input').attr('name', 'NS' + (i + 1));
});
}
App.Actions.view_full_ns_list = function(evt)
{
var elm = $(evt.target);
App.Helpers.openInnerPopup(elm, $(elm).parents('.prop-box').find('.ns-full-list:first').html());
}

View file

@ -1,6 +1,6 @@
App.HTML.setTplKeys = function(tpl, o, empty) App.HTML.setTplKeys = function(tpl, o, empty)
{ {
var empty = empty || '-'; var empty = empty || '';
fb.log(empty); fb.log(empty);
tpl.set(':source', $.toJSON(o).replace(/'/gi, "\\'")) tpl.set(':source', $.toJSON(o).replace(/'/gi, "\\'"))
$(o).each(function(i, object) $(o).each(function(i, object)
@ -12,7 +12,7 @@ App.HTML.setTplKeys = function(tpl, o, empty)
tpl.set(':' + key, val || ''); tpl.set(':' + key, val || '');
} }
else { else {
tpl.set(':' + key, val || '-'); tpl.set(':' + key, val || '');
} }
}); });
}); });
@ -138,14 +138,14 @@ App.HTML.Build.ip_entry = function(o)
var tpl = App.Templates.get('ENTRY', 'ip'); var tpl = App.Templates.get('ENTRY', 'ip');
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.SUSPENDED) {
var sub_tpl = App.Templates.get('SUSPENDED_TPL_ENABLED', 'ip'); var sub_tpl = App.Templates.get('SUSPENDED_TPL_ENABLED', 'ip');
} }
else { else {
var sub_tpl = App.Templates.get('SUSPENDED_TPL_DISABLED', 'ip'); var sub_tpl = App.Templates.get('SUSPENDED_TPL_DISABLED', 'ip');
} }*/
tpl.set(':SUSPENDED_TPL', sub_tpl.finalize()); tpl.set(':SUSPENDED_TPL', '');
return tpl.finalize(); return tpl.finalize();
} }
@ -163,14 +163,14 @@ App.HTML.Build.dns_entry = function(o, is_new)
tpl.set(':DATE', now.format("d.mm.yyyy")); tpl.set(':DATE', now.format("d.mm.yyyy"));
} }
if (App.Constants.SUSPENDED_YES == o.SUSPEND) { /*if (App.Constants.SUSPENDED_YES == o.SUSPEND) {
var sub_tpl = App.Templates.get('SUSPENDED_TPL_NOT_SUSPENDED', 'general'); var sub_tpl = App.Templates.get('SUSPENDED_TPL_NOT_SUSPENDED', 'general');
} }
else { else {
var sub_tpl = App.Templates.get('SUSPENDED_TPL_SUSPENDED', 'general'); var sub_tpl = App.Templates.get('SUSPENDED_TPL_SUSPENDED', 'general');
} }*/
tpl.set(':SUSPENDED_TPL', sub_tpl.finalize()); tpl.set(':SUSPENDED_TPL', '');
return tpl.finalize(); return tpl.finalize();
} }
@ -190,13 +190,41 @@ 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) { /*if (App.Constants.SUSPENDED_YES == o.SUSPENDED) {
var sub_tpl = App.Templates.get('SUSPENDED_TPL_SUSPENDED', 'general'); var sub_tpl = App.Templates.get('SUSPENDED_TPL_SUSPENDED', 'general');
} }
else { else {
var sub_tpl = App.Templates.get('SUSPENDED_TPL_NOT_SUSPENDED', 'general'); var sub_tpl = App.Templates.get('SUSPENDED_TPL_NOT_SUSPENDED', 'general');
}*/
tpl.set(':SUSPENDED_TPL', '');//sub_tpl.finalize());
var ns = [];
var ns_full = [];
fb.info(o);
$([1,2,3,4,5,6,7,8]).each(function(i, index)
{
if (o['NS'+index].trim() != '') {
var tpl_ns = App.Templates.get('NS_RECORD', 'user');
tpl_ns.set(':NAME', o['NS'+index]);
var tpl_finalized = tpl_ns.finalize();
ns_full[ns_full.length++] = tpl_finalized;
if (i < App.Settings.USER_VISIBLE_NS) {
ns[ns.length++] = tpl_finalized;
} }
tpl.set(':SUSPENDED_TPL', sub_tpl.finalize()); }
});
if (ns_full.length <= App.Settings.USER_VISIBLE_NS) {
tpl.set(':NS', ns.done());
}
else {
var ns_custom = App.Templates.get('NS_MINIMIZED', 'user');
ns_custom.set(':NS_MINI', ns.done());
ns_custom.set(':NS_FULL', ns_full.done());
ns_custom.set(':MORE_NUMBER', Math.abs(App.Settings.USER_VISIBLE_NS - ns_full.length));
tpl.set(':NS', ns_custom.finalize());
}
return tpl.finalize(); return tpl.finalize();
} }
@ -220,7 +248,22 @@ App.HTML.Build.user_form = function(options, id)
tpl.set(':save_button', 'SAVE'); tpl.set(':save_button', 'SAVE');
} }
options = !App.Helpers.isEmpty(options) ? options : {'CONTACT':'', 'PASSWORD':'','LOGIN_NAME':'','LNAME':'', 'FNAME':''}; options = !App.Helpers.isEmpty(options) ? options : App.Empty.USER;
// NS
var ns = [];
$([3,4,5,6,7,8]).each(function(i, index)
{fb.warn(options);
if (options['NS'+index].trim() != '') {
var tpl_ns = App.Templates.get('NS_INPUT', 'user');
tpl_ns.set(':NS_LABEL', 'NS #' + (index));
tpl_ns.set(':NAME', options['NS'+index]);
ns[ns.length++] = tpl_ns.finalize();
}
});
ns[ns.length++] = App.Templates.get('PLUS_ONE_NS', 'user').finalize();
tpl.set(':NS', ns.done());
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);
@ -491,7 +534,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 || ['Skid']; var users = App.Env.initialParams.IP.SYS_USERS;
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);

View file

@ -77,6 +77,7 @@ App.Model.add = function(values, source_json)
App.Ref.CONTENT..replaceWith(tpl);*/ App.Ref.CONTENT..replaceWith(tpl);*/
// todo: reply.data; // todo: reply.data;
App.Pages.prepareHTML(); App.Pages.prepareHTML();
App.Helpers.updateScreen();
} }
}); });
} }
@ -114,8 +115,11 @@ App.Model.update = function(values, source_json, elm)
App.Helpers.Warn('Changes were not applied'); App.Helpers.Warn('Changes were not applied');
} }
else { else {
var tpl = App.HTML.Build[build_method](reply.data); /*var tpl = App.HTML.Build[build_method](reply.data);
$(elm).replaceWith(tpl); $(elm).replaceWith(tpl);
App.Helpers.updateScreen();*/
// todo: reply.data;
App.Pages.prepareHTML();
App.Helpers.updateScreen(); App.Helpers.updateScreen();
} }
// TODO: ! // TODO: !

View file

@ -32,7 +32,7 @@ App.Templates.html = {
select_option: ['<option ~!:SELECTED~! value="~!:VALUE~!">~!:TEXT~!</option>'], select_option: ['<option ~!:SELECTED~! value="~!:VALUE~!">~!:TEXT~!</option>'],
error_elm: ['<div class="error-box">~!:ERROR~!</div>'], error_elm: ['<div class="error-box">~!:ERROR~!</div>'],
SUSPENDED_TPL_NOT_SUSPENDED : ['<span class="ip-status-info ip-enabled-status do_action_suspend"><span class="ip-status-text do_action_suspend">enabled</span></span>'], SUSPENDED_TPL_NOT_SUSPENDED : ['<span class="ip-status-info ip-enabled-status do_action_suspend"><span class="ip-status-text do_action_suspend">enabled</span></span>'],
SUSPENDED_TPL_SUSPENDED : ['<span class="ip-status-info ip-enabled-status do_action_unsuspend"><span class="ip-status-text do_action_unsuspend">disabled</span></span>'] SUSPENDED_TPL_SUSPENDED : ['<span class="ip-status-info ip-suspended-status do_action_unsuspend"><span class="ip-status-text do_action_unsuspend">suspended</span></span>']
}, },
popup: { popup: {
error: ['<div class="error"><center><h1 style="color: red;">Important: An Error Has Occured.</h1><hr></center>&nbsp;&nbsp;&nbsp;&nbsp;Something went wrong and some of your actions can be not saved in system. Mostly, it happens when you have network connection errors.<br>,&nbsp;&nbsp;&nbsp;&nbsp;However, please notify us about the situation. It would be helpfull if you will write us approximate time the error occured and last actions you were performing. You send your petition on <a href="mail_to">this email: BLABLA</a>,<br><br><center><span style="color: rgb(92, 92, 92);">Sorry for inconvinience. (We recommend you to reload the page)</span></center></div>'] error: ['<div class="error"><center><h1 style="color: red;">Important: An Error Has Occured.</h1><hr></center>&nbsp;&nbsp;&nbsp;&nbsp;Something went wrong and some of your actions can be not saved in system. Mostly, it happens when you have network connection errors.<br>,&nbsp;&nbsp;&nbsp;&nbsp;However, please notify us about the situation. It would be helpfull if you will write us approximate time the error occured and last actions you were performing. You send your petition on <a href="mail_to">this email: BLABLA</a>,<br><br><center><span style="color: rgb(92, 92, 92);">Sorry for inconvinience. (We recommend you to reload the page)</span></center></div>']
@ -47,17 +47,17 @@ App.Templates.html = {
<input type="hidden" name="source" class="source" value=~!:source~!>\ <input type="hidden" name="source" class="source" value=~!:source~!>\
<input type="hidden" name="target" class="target" value=\'\'>\ <input type="hidden" name="target" class="target" value=\'\'>\
<div class="entry-header">~!:title~!</div>\ <div class="entry-header">~!:title~!</div>\
<div class="errors">\ <div class="form-error hidden">\
</div>\ </div>\
<div class="form-row cc">\ <div class="form-row cc">\
<input type="hidden" value="~!:DATE~!" name="DATE">\ <input type="hidden" value="~!:DATE~!" name="DATE">\
<label for="#" class="field-label">domain:</label>\ <label for="#" class="field-label">domain:</label>\
<input type="text" name="DNS_DOMAIN" value="~!:DNS_DOMAIN~!" class="text-field DNS_DOMAIN">\ <input type="text" name="DNS_DOMAIN" value="~!:DNS_DOMAIN~!" class="text-field rule-required rule-domain">\
</div>\ </div>\
<div class="form-row cc">\ <div class="form-row cc">\
<label for="#" class="field-label">ip address:</label>\ <label for="#" class="field-label">ip address:</label>\
<div class="autocomplete-box">\ <div class="autocomplete-box">\
<input type="text" name="IP" value="~!:IP~!" class="text-field IP">\ <input type="text" name="IP" value="~!:IP~!" class="text-field rule-required rule-ip">\
<i class="arrow">&nbsp;</i>\ <i class="arrow">&nbsp;</i>\
</div>\ </div>\
</div>\ </div>\
@ -71,11 +71,11 @@ App.Templates.html = {
</div>\ </div>\
<div class="form-row cc">\ <div class="form-row cc">\
<label for="#" class="field-label">ttl:</label>\ <label for="#" class="field-label">ttl:</label>\
<input type="text" value="~!:TTL~!" name="TTL" class="text-field ttl-field">\ <input type="text" value="~!:TTL~!" name="TTL" class="text-field ttl-field rule-required rule-numeric">\
</div>\ </div>\
<div class="form-row cc">\ <div class="form-row cc">\
<label for="#" class="field-label">soa:</label>\ <label for="#" class="field-label">soa:</label>\
<input type="text" value="~!:SOA~!" name="SOA" class="text-field">\ <input type="text" value="~!:SOA~!" name="SOA" class="text-field rule-required rule-numeric">\
</div>\ </div>\
<div class="form-row buttons-row cc">\ <div class="form-row buttons-row cc">\
<input type="submit" value="~!:save_button~!" class="add-entry-btn do_action_save_form" name="save">\ <input type="submit" value="~!:save_button~!" class="add-entry-btn do_action_save_form" name="save">\
@ -171,11 +171,11 @@ App.Templates.html = {
<input type="hidden" name="source" class="source" value=\'~!:source~!\'>\ <input type="hidden" name="source" class="source" value=\'~!:source~!\'>\
<input type="hidden" name="target" class="target" value=\'~!:target~!\'>\ <input type="hidden" name="target" class="target" value=\'~!:target~!\'>\
<div class="entry-header">~!:title~!</div>\ <div class="entry-header">~!:title~!</div>\
<div class="form-error">\ <div class="form-error hidden">\
</div>\ </div>\
<div class="form-row cc">\ <div class="form-row cc">\
<label for="#" class="field-label">ip address:</label>\ <label for="#" class="field-label">ip address:</label>\
<input type="text" value="~!:IP_ADDRESS~!" name="IP_ADDRESS" class="text-field">\ <input type="text" value="~!:IP_ADDRESS~!" name="IP_ADDRESS" class="text-field rule-required rule-ip">\
</div>\ </div>\
<div class="form-row cc">\ <div class="form-row cc">\
<label for="#" class="field-label">owner:</label>\ <label for="#" class="field-label">owner:</label>\
@ -192,7 +192,7 @@ App.Templates.html = {
</div>\ </div>\
<div class="form-row cc">\ <div class="form-row cc">\
<label for="#" class="field-label">name:</label>\ <label for="#" class="field-label">name:</label>\
<input type="text" name="NAME" value="~!:NAME~!" class="text-field">\ <input type="text" name="NAME" value="~!:NAME~!" class="text-field rule-abc">\
</div>\ </div>\
<div class="form-row cc">\ <div class="form-row cc">\
<label for="#" class="field-label">interface:</label>\ <label for="#" class="field-label">interface:</label>\
@ -276,12 +276,24 @@ App.Templates.html = {
SUSPENDED_TPL_DISABLED : ['<span class="ip-status-info ip-suspended-status do_action_delete_ip"><span class="ip-status-text">suspended</span></span>'] SUSPENDED_TPL_DISABLED : ['<span class="ip-status-info ip-suspended-status do_action_delete_ip"><span class="ip-status-text">suspended</span></span>']
}, },
user: { user: {
NS_MINIMIZED: ['~!:NS_MINI~!\
<span class="group-switcher">\
<span class="group-values-count do_action_view_full_ns_list">~!:MORE_NUMBER~! more</span>\
</span><span class="hidden ns-full-list"><span class="group-values group-values__bullet">~!:NS_FULL~!</span></span>'],
/*NS_RECORD_POPUP_WRAP: ['<ul class="d-popup-items">~!:CONTENT~!</ul>'],
NS_RECORD_POPUP: ['<li class="item">~!:NAME~!</li>'],*/
NS_RECORD: ['<span class="prop-value">~!:NAME~!</span>'],
NS_INPUT: ['<div class="form-row ns-entry cc"><label for="#" class="field-label">~!:NS_LABEL~!:</label>\
<input type="text" value="~!:NAME~!" name="" class="text-field ns-input rule-required rule-ns">\
<button class="do_action_delete_ns">Delete</button>\
</div>'],
PLUS_ONE_NS: ['<button class="additional-ns-add do_action_add_form_ns">Add additional NS</button>'],
ENTRIES_WRAPPER: ['<div class="users-list items-list">~!:content~!</div>'], ENTRIES_WRAPPER: ['<div class="users-list items-list">~!:content~!</div>'],
FORM: ['<div id="~!:id~!" class="b-new-entry b-new-entry_user">\ FORM: ['<div id="~!:id~!" class="b-new-entry b-new-entry_user form">\
<input type="hidden" name="source" class="source" value=\'~!:source~!\'>\ <input type="hidden" name="source" class="source" value=\'~!:source~!\'>\
<input type="hidden" name="target" class="target" value=\'\'>\ <input type="hidden" name="target" class="target" value=\'\'>\
<div class="entry-header">~!:title~!</div>\ <div class="entry-header">~!:title~!</div>\
<div class="form-error">\ <div class="form-error hidden">\
</div>\ </div>\
<div class="form-row cc">\ <div class="form-row cc">\
<label for="#" class="field-label">username:</label>\ <label for="#" class="field-label">username:</label>\
@ -320,20 +332,21 @@ App.Templates.html = {
</div>\ </div>\
<div class="form-row cc">\ <div class="form-row cc">\
<label for="#" class="field-label">Firstname:</label>\ <label for="#" class="field-label">Firstname:</label>\
<input type="text" name="FNAME" class="not-styled rule-abc rule-required" value="~!:FNAME~!">\ <input type="text" name="FNAME" class="not-styled text-field rule-abc rule-required" value="~!:FNAME~!">\
</div>\ </div>\
<div class="form-row cc">\ <div class="form-row cc">\
<label for="#" class="field-label">Lastname:</label>\ <label for="#" class="field-label">Lastname:</label>\
<input type="text" name="LNAME" class="not-styled rule-abc rule-required" value="~!:LNAME~!">\ <input type="text" name="LNAME" class="not-styled text-field rule-abc rule-required" value="~!:LNAME~!">\
</div>\ </div>\
<div class="form-row cc hidden">\ <div class="form-row ns-entry cc">\
<label for="#" class="field-label">ns1:</label>\ <label for="#" class="field-label">NS #1:</label>\
<input type="text" name="NS" class="text-field" value="~!:NS~!">\ <input type="text" value="~!:NS1~!" name="NS1" class="text-field rule-required rule-ns">\
</div>\ </div>\
<!-- div class="form-row cc">\ <div class="form-row ns-entry cc">\
<label for="#" class="field-label">ns2:</label>\ <label for="#" class="field-label">NS #2:</label>\
<input type="text" value="custom-edge-cdn2.digital-photography-school.com" class="text-field">\ <input type="text" value="~!:NS2~!" name="NS2" class="text-field rule-required rule-ns">\
</div -->\ </div>\
~!:NS~!\
<div class="form-row buttons-row cc">\ <div class="form-row buttons-row cc">\
<input type="submit" value="~!:save_button~!" name="save" class="add-entry-btn do_action_save_form">\ <input type="submit" value="~!:save_button~!" name="save" class="add-entry-btn do_action_save_form">\
<span class="cancel-btn do_action_cancel_form">Cancel</span>\ <span class="cancel-btn do_action_cancel_form">Cancel</span>\
@ -365,7 +378,7 @@ App.Templates.html = {
<div class="username-box">\ <div class="username-box">\
<span class="user">\ <span class="user">\
<span class="nickname do_action_edit">~!:LOGIN_NAME~!</span>\ <span class="nickname do_action_edit">~!:LOGIN_NAME~!</span>\
<span class="role">~!:FNAME~! ~!:LNAME~!</span>\ <span class="role"></span>\
<span class="role">(~!:ROLE~!)</span>\ <span class="role">(~!:ROLE~!)</span>\
</span>\ </span>\
<span class="prop-box template-box">\ <span class="prop-box template-box">\
@ -472,7 +485,8 @@ App.Templates.html = {
</span>\ </span>\
<span class="prop-box prop-box_group-values cc ns-list-box">\ <span class="prop-box prop-box_group-values cc ns-list-box">\
<span class="prop-title">ns list:</span>\ <span class="prop-title">ns list:</span>\
<span class="group-values group-values__bullet">~!:NS~!</span>\ <span class="group-values group-values__bullet">\
~!:NS~!</span>\
</span>\ </span>\
</div>\ </div>\
</div><!-- // .row-details -->\ </div><!-- // .row-details -->\
@ -776,7 +790,7 @@ App.Templates.html = {
<input type="hidden" name="source" class="source" value=\'~!:source~!\'>\ <input type="hidden" name="source" class="source" value=\'~!:source~!\'>\
<input type="hidden" name="target" class="target" value=\'\'>\ <input type="hidden" name="target" class="target" value=\'\'>\
<div class="entry-header">~!:title~!</div>\ <div class="entry-header">~!:title~!</div>\
<div class="form-error">\ <div class="form-error hidden">\
<div class="error-box">\ <div class="error-box">\
</div>\ </div>\
</div>\ </div>\
@ -785,39 +799,39 @@ App.Templates.html = {
<div class="field-box cron-minute-box">\ <div class="field-box cron-minute-box">\
<label for="#" class="field-label ">minute:<br>(0&mdash;59)</label>\ <label for="#" class="field-label ">minute:<br>(0&mdash;59)</label>\
<div class="field-box-inner cc">\ <div class="field-box-inner cc">\
<input type="text" value="~!:MIN~!" name="MIN" class="text-field">\ <input type="text" value="~!:MIN~!" name="MIN" class="text-field rule-required rule-minute">\
</div>\ </div>\
</div>\ </div>\
<div class="field-box cron-hour-box">\ <div class="field-box cron-hour-box">\
<label for="#" class="field-label">hour:<br>(0&mdash;23)</label>\ <label for="#" class="field-label">hour:<br>(0&mdash;23)</label>\
<div class="field-box-inner cc">\ <div class="field-box-inner cc">\
<input type="text" value="~!:HOUR~!" name="HOUR" class="text-field">\ <input type="text" value="~!:HOUR~!" name="HOUR" class="text-field rule-required rule-hour">\
</div>\ </div>\
</div>\ </div>\
<div class="field-box cron-day-box">\ <div class="field-box cron-day-box">\
<label for="#" class="field-label">day of Month:<br>(1&mdash;31)</label>\ <label for="#" class="field-label">day of Month:<br>(1&mdash;31)</label>\
<div class="field-box-inner cc">\ <div class="field-box-inner cc">\
<input type="text" value="~!:DAY~!" name="DAY" class="text-field">\ <input type="text" value="~!:DAY~!" name="DAY" class="text-field rule-required rule-day">\
</div>\ </div>\
</div>\ </div>\
<div class="field-box cron-month-box">\ <div class="field-box cron-month-box">\
<label for="#" class="field-label">Month:<br>(1&mdash;12)(Jan&mdash;Dec)</label>\ <label for="#" class="field-label">Month:<br>(1&mdash;12)(Jan&mdash;Dec)</label>\
<div class="field-box-inner cc">\ <div class="field-box-inner cc">\
<input type="text" value="~!:MONTH~!" name="MONTH" class="text-field">\ <input type="text" value="~!:MONTH~!" name="MONTH" class="text-field rule-required rule-month">\
</div>\ </div>\
</div>\ </div>\
<div class="field-box cron-week-box">\ <div class="field-box cron-week-box">\
<label for="#" class="field-label">day of Week:<br>(1&mdash;7)(Sun&mdash;Sat)</label>\ <label for="#" class="field-label">day of Week:<br>(1&mdash;7)(Sun&mdash;Sat)</label>\
<div class="field-box-inner cc">\ <div class="field-box-inner cc">\
<input type="text" value="~!:WDAY~!" name="WDAY" class="text-field">\ <input type="text" value="~!:WDAY~!" name="WDAY" class="text-field rule-required rule-wday">\
</div>\ </div>\
</div>\ </div>\
</div>\ </div>\
<div class="form-row cc">\ <div class="form-row cc">\
<label for="#" class="field-label">command:</label>\ <label for="#" class="field-label">command:</label>\
<textarea class="textarea" name="CMD">~!:CMD~!</textarea>\ <textarea class="textarea rule-required" name="CMD">~!:CMD~!</textarea>\
</div>\ </div>\
<div class="form-row cc">\ <div class="form-row cc hidden">\
<label for="#" class="field-label">report to: <span class="remark">(devide by comma ",")</span></label>\ <label for="#" class="field-label">report to: <span class="remark">(devide by comma ",")</span></label>\
<textarea class="textarea" name="REPORT_TO"></textarea>\ <textarea class="textarea" name="REPORT_TO"></textarea>\
</div>\ </div>\
@ -867,7 +881,7 @@ App.Templates.html = {
<div class="cron-command-box">\ <div class="cron-command-box">\
<strong class="cron-command-line do_action_edit">~!:CMD~!</strong>\ <strong class="cron-command-line do_action_edit">~!:CMD~!</strong>\
</div>\ </div>\
<div class="cron-reported-to">\ <div class="cron-reported-to hidden">\
<span class="prop-box cron-report-box">\ <span class="prop-box cron-report-box">\
<span class="prop-title">reported to:</span>\ <span class="prop-title">reported to:</span>\
<span class="prop-value">naumov.socolov@gmail.com,</span>\ <span class="prop-value">naumov.socolov@gmail.com,</span>\

View file

@ -16,8 +16,12 @@ App.Validate.Is = {
App.Validate.getFieldName = function(elm) App.Validate.getFieldName = function(elm)
{ {
fb.log(elm); fb.log(elm);
fb.warn($(elm).prev('label').text()); var txt_label = $(elm).prev('label').text();
return ['<strong>', $(elm).prev('label').text(), '</strong>'].join(''); if (txt_label.trim() == '') {
txt_label = $(elm).parents('.field-box').select('label:first').text();
}
return ['<strong>', txt_label, '</strong>'].join('');
} }
App.Validate.Rule = { App.Validate.Rule = {
@ -27,15 +31,21 @@ App.Validate.Rule = {
} }
return {VALID: true}; return {VALID: true};
}, },
'numeric': function(elm) {
if ($(elm).val().trim() != '' && isNaN(parseInt($(elm).val(), 10))) {
return {VALID: false, ERROR: App.Validate.getFieldName(elm) + ' is incorrect'};
}
return {VALID: true};
},
'no-spaces': function(elm) { 'no-spaces': function(elm) {
if ($(elm).val().search(/\s/) != -1) { if ($(elm).val().trim() != '' && $(elm).val().search(/\s/) != -1) {
return {VALID: false, ERROR: App.Validate.getFieldName(elm) + ' cannot contain spaces'}; return {VALID: false, ERROR: App.Validate.getFieldName(elm) + ' cannot contain spaces'};
} }
return {VALID: true}; return {VALID: true};
}, },
'abc': function(elm) { 'abc': function(elm) {
if ($(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) + ' must contain only letters'}; return {VALID: false, ERROR: App.Validate.getFieldName(elm) + ' must contain only letters without spaces or other symbols'};
} }
return {VALID: true}; return {VALID: true};
}, },
@ -44,6 +54,74 @@ App.Validate.Rule = {
return {VALID: false, ERROR: App.Validate.getFieldName(elm) + ' not a valid email'}; return {VALID: false, ERROR: App.Validate.getFieldName(elm) + ' not a valid email'};
} }
return {VALID: true}; return {VALID: true};
},
'ip': function(elm) {
if ($(elm).val().trim() != '' && (/^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$/).test($(elm).val()) == false) {
return {VALID: false, ERROR: App.Validate.getFieldName(elm) + ' not a valid IP value'};
}
return {VALID: true};
},
'domain': function(elm) {
if ($(elm).val().trim() != '' && (/^([a-z0-9\.])*[a-z0-9][a-z0-9\-]+[a-z0-9](\.[a-z]{2,4})+$/).test($(elm).val()) == false) {
return {VALID: false, ERROR: App.Validate.getFieldName(elm) + ' not a valid domain name'};
}
return {VALID: true};
},
'ns': function(elm) {
if ($(elm).val().trim() != '' && (/^([a-z0-9\.])*[a-z0-9][a-z0-9\-]+[a-z0-9](\.[a-z]{2,4})+$/).test($(elm).val()) == false) {
return {VALID: false, ERROR: App.Validate.getFieldName(elm) + ' not a valid NS name'};
}
return {VALID: true};
},
'minute': function(elm) {
if ($(elm).val() == '*') {
return {VALID: true};
}
var minute = parseInt($(elm).val(), 10);
if (minute > 60 || minute < 0) {
return {VALID: false, ERROR: App.Validate.getFieldName(elm) + ' wrong minute value'};
}
return {VALID: true};
},
'hour': function(elm) {
if ($(elm).val() == '*') {
return {VALID: true};
}
var hour = parseInt($(elm).val(), 10);
if (hour > 60 || hour < 0) {
return {VALID: false, ERROR: App.Validate.getFieldName(elm) + ' wrong hour value'};
}
return {VALID: true};
},
'wday': function(elm) {
if ($(elm).val() == '*') {
return {VALID: true};
}
var wday = parseInt($(elm).val(), 10);
if (wday > 7 || wday < 1) {
return {VALID: false, ERROR: App.Validate.getFieldName(elm) + ' wrong week day value'};
}
return {VALID: true};
},
'month': function(elm) {
if ($(elm).val() == '*') {
return {VALID: true};
}
var month = parseInt($(elm).val(), 10);
if (month > 1 || month < 12) {
return {VALID: false, ERROR: App.Validate.getFieldName(elm) + ' wrong month value'};
}
return {VALID: true};
},
'day': function(elm) {
if ($(elm).val() == '*') {
return {VALID: true};
}
var day = parseInt($(elm).val(), 10);
if (day > 31 || day < 1) {
return {VALID: false, ERROR: App.Validate.getFieldName(elm) + ' wrong day value'};
}
return {VALID: true};
} }
} }
@ -54,6 +132,11 @@ App.Validate.form = function(world, elm)
App.Env.FormError = []; App.Env.FormError = [];
$(elm).find('select, input, textarea').each(function(i, field) $(elm).find('select, input, textarea').each(function(i, field)
{ {
if ($(field).attr('type') == 'checkbox') {
var value = $(field).attr('checked') ? 'on' : 'off';
$(field).val(value);
}
if ($.inArray($(field).attr('name'), ['target', 'source', 'save']) != -1) { if ($.inArray($(field).attr('name'), ['target', 'source', 'save']) != -1) {
//return; // pass //return; // pass
} }
@ -96,6 +179,7 @@ App.Validate.displayFormErrors = function(world, elm)
App.Validate.getRules = function(elm) App.Validate.getRules = function(elm)
{ {
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) $(rules_string.split(/\s/)).each(function(i, str)
@ -108,6 +192,11 @@ App.Validate.getRules = function(elm)
return rules; return rules;
} }
catch(e) {
return [];
}
}

View file

@ -18,9 +18,9 @@ class CRON extends AjaxHandler
*/ */
public function getListExecute($request) public function getListExecute($request)
{ {
$_user = 'vesta'; $user = $this->getLoggedUser();
$reply = array(); $reply = array();
$result = Vesta::execute(Vesta::V_LIST_CRON_JOBS, array($_user, Config::get('response_type'))); $result = Vesta::execute(Vesta::V_LIST_CRON_JOBS, array($user['uid'], Config::get('response_type')));
foreach ($result['data'] as $id => $record) { foreach ($result['data'] as $id => $record) {
$reply[$id] = array( $reply[$id] = array(
@ -30,8 +30,9 @@ class CRON extends AjaxHandler
'DAY' => $record['DAY'], 'DAY' => $record['DAY'],
'MONTH' => $record['MONTH'], 'MONTH' => $record['MONTH'],
'WDAY' => $record['WDAY'], 'WDAY' => $record['WDAY'],
'SUSPEND' => $record['SUSPEND'], 'SUSPENDED' => $record['SUSPEND'],
'DATE' => date(Config::get('ui_date_format', strtotime($record['DATE']))) 'DATE' => date(Config::get('ui_date_format', strtotime($record['DATE']))),
'JOB' => $id
); );
} }
@ -48,26 +49,25 @@ class CRON extends AjaxHandler
* @param Request $request * @param Request $request
* @return string - Ajax Reply * @return string - Ajax Reply
*/ */
public function addExecute($request) public function addExecute(Request $request)
{ {
$r = new Request(); $user = $this->getLoggedUser();
$_s = $r->getSpell(); $spell = $request->getParameter('spell');
$_user = 'vesta';
$params = array( $params = array(
'USER' => $_user, 'USER' => $user['uid'],
'MIN' => $_s['MIN'], 'MIN' => $spell['MIN'],
'HOUR' => $_s['HOUR'], 'HOUR' => $spell['HOUR'],
'DAY' => $_s['DAY'], 'DAY' => $spell['DAY'],
'MONTH' => $_s['MONTH'], 'MONTH' => $spell['MONTH'],
'WDAY' => $_s['WDAY'], 'WDAY' => $spell['WDAY'],
'CMD' => $_s['CMD'] 'CMD' => $spell['CMD']
); );
$result = Vesta::execute(Vesta::V_ADD_CRON_JOB, $params); $result = Vesta::execute(Vesta::V_ADD_CRON_JOB, $params);
if ($_s['REPORTS']) { if ($spell['REPORTS']) {
$result = array(); $result = array();
$result = Vesta::execute(Vesta::V_ADD_SYS_USER_REPORTS, array('USER' => $_user)); $result = Vesta::execute(Vesta::V_ADD_SYS_USER_REPORTS, array('USER' => $user['uid']));
if (!$result['status']) { if (!$result['status']) {
$this->status = FALSE; $this->status = FALSE;
$this->errors['REPORTS'] = array($result['error_code'] => $result['error_message']); $this->errors['REPORTS'] = array($result['error_code'] => $result['error_message']);
@ -87,15 +87,13 @@ class CRON extends AjaxHandler
* @param Request $request * @param Request $request
* @return string - Ajax Reply * @return string - Ajax Reply
*/ */
public function delExecute($request) public function deleteExecute(Request $request)
{ {
$r = new Request(); $user = $this->getLoggedUser();
$_s = $r->getSpell(); $spell = $request->getParameter('spell');
$_user = 'vesta';
$params = array( $params = array(
'USER' => $_user, 'USER' => $user['uid'],
'JOB' => $_s['JOB'] 'JOB' => $spell['JOB']
); );
$result = Vesta::execute(Vesta::V_DEL_CRON_JOB, $params); $result = Vesta::execute(Vesta::V_DEL_CRON_JOB, $params);
@ -113,18 +111,15 @@ class CRON extends AjaxHandler
* @param Request $request * @param Request $request
* @return string - Ajax Reply * @return string - Ajax Reply
*/ */
public function changeExecute($request) public function changeExecute(Request $request)
{ {
$r = new Request(); $user = $this->getLoggedUser();
$_s = $r->getSpell(); $_old = $request->getParameter('old');
$_old = $_s['old']; $_new = $request->getParameter('new');
$_new = $_s['new'];
$_user = 'vesta';
$_JOB = $_new['JOB'];
$result = array(); $result = array();
$params = array( $params = array(
'USER' => $_user, 'USER' => $user['uid'],
'JOB' => $_JOB, 'JOB' => $_old['JOB'],
'MIN' => $_new['MIN'], 'MIN' => $_new['MIN'],
'HOUR' => $_new['HOUR'], 'HOUR' => $_new['HOUR'],
'DAY' => $_new['DAY'], 'DAY' => $_new['DAY'],
@ -149,15 +144,13 @@ class CRON extends AjaxHandler
* @param Request $request * @param Request $request
* @return string - Ajax Reply * @return string - Ajax Reply
*/ */
public function suspendExecute($request) public function suspendExecute(Request $request)
{ {
$r = new Request(); $user = $this->getLoggedUser();
$_s = $r->getSpell(); $spell = $request->getParameter('spell');
$_user = 'vesta';
$_JOB = $_s['JOB'];
$params = array( $params = array(
'USER' => $_user, 'USER' => $user['uid'],
'JOB' => $_JOB 'JOB' => $spell['JOB']
); );
$result = Vesta::execute(Vesta::V_SUSPEND_CRON_JOB, $params); $result = Vesta::execute(Vesta::V_SUSPEND_CRON_JOB, $params);
@ -177,13 +170,11 @@ class CRON extends AjaxHandler
*/ */
public function unsuspendExecute($request) public function unsuspendExecute($request)
{ {
$r = new Request(); $user = $this->getLoggedUser();
$_s = $r->getSpell(); $spell = $request->getParameter('spell');
$_user = 'vesta';
$_JOB = $_s['JOB'];
$params = array( $params = array(
'USER' => $_user, 'USER' => $user['uid'],
'JOB' => $_JOB 'JOB' => $spell['JOB']
); );
$result = Vesta::execute(Vesta::V_UNSUSPEND_CRON_JOB, $params); $result = Vesta::execute(Vesta::V_UNSUSPEND_CRON_JOB, $params);
@ -202,7 +193,7 @@ class CRON extends AjaxHandler
* @param Request $request * @param Request $request
* @return string - Ajax Reply * @return string - Ajax Reply
*/ */
public function suspendAllExecute($request) /*public function suspendAllExecute($request)
{ {
$r = new Request(); $r = new Request();
$_s = $r->getSpell(); $_s = $r->getSpell();
@ -219,7 +210,7 @@ class CRON extends AjaxHandler
} }
return $this->reply($result['status'], $result['data']); return $this->reply($result['status'], $result['data']);
} }*/
/** /**
* Batch unsuspend CRON entries * Batch unsuspend CRON entries
@ -227,7 +218,7 @@ class CRON extends AjaxHandler
* @param Request $request * @param Request $request
* @return string - Ajax Reply * @return string - Ajax Reply
*/ */
public function unsuspendAllExecute($request) /*public function unsuspendAllExecute($request)
{ {
$r = new Request(); $r = new Request();
$_s = $r->getSpell(); $_s = $r->getSpell();
@ -243,6 +234,6 @@ class CRON extends AjaxHandler
} }
return $this->reply($result['status'], $result['data']); return $this->reply($result['status'], $result['data']);
} }*/
} }

View file

@ -22,9 +22,9 @@ class DNS extends AjaxHandler
*/ */
public function getListExecute($request) public function getListExecute($request)
{ {
$_user = 'vesta'; $user = $this->getLoggedUser();
$reply = array(); $reply = array();
$result = Vesta::execute(Vesta::V_LIST_DNS_DOMAINS, array($_user, Config::get('response_type'))); $result = Vesta::execute(Vesta::V_LIST_DNS_DOMAINS, array($user['uid'], Config::get('response_type')));
foreach ($result['data'] as $dns_domain => $details) { foreach ($result['data'] as $dns_domain => $details) {
$reply[] = array( $reply[] = array(
'DNS_DOMAIN' => $dns_domain, 'DNS_DOMAIN' => $dns_domain,
@ -53,12 +53,11 @@ class DNS extends AjaxHandler
*/ */
public function getListRecordsExecute($request) public function getListRecordsExecute($request)
{ {
$r = new Request(); $_s = $request->getParameter('spell');
$_s = $r->getSpell(); $user = $this->getLoggedUser();
$_user = 'vesta';
$reply = array(); $reply = array();
$result = Vesta::execute(Vesta::V_LIST_DNS_DOMAIN_RECORDS, array($_user, $_s['DNS_DOMAIN'], Config::get('response_type'))); $result = Vesta::execute(Vesta::V_LIST_DNS_DOMAIN_RECORDS, array($user['uid'], $_s['DNS_DOMAIN'], Config::get('response_type')));
foreach ($result['data'] as $record_id => $details) { foreach ($result['data'] as $record_id => $details) {
$reply[$record_id] = array( $reply[$record_id] = array(
'RECORD_ID' => $record_id, 'RECORD_ID' => $record_id,
@ -78,7 +77,7 @@ class DNS extends AjaxHandler
} }
/** /**
* Add DB entry * Add DNS entry
* *
* v_add_dns_domain user domain ip [template] [exp] [soa] [ttl] * v_add_dns_domain user domain ip [template] [exp] [soa] [ttl]
* http://95.163.16.160:8083/dispatch.php?jedi_method=DNS.add&USER=vesta&DOMAIN=dev.vestacp.com&IP_ADDRESS=95.163.16.160&TEMPLATE=default&EXP=01-01-12&SOA=ns1.vestacp.com&TTL=3600 * http://95.163.16.160:8083/dispatch.php?jedi_method=DNS.add&USER=vesta&DOMAIN=dev.vestacp.com&IP_ADDRESS=95.163.16.160&TEMPLATE=default&EXP=01-01-12&SOA=ns1.vestacp.com&TTL=3600
@ -86,19 +85,12 @@ class DNS extends AjaxHandler
* @param Request $request * @param Request $request
* @return string - Ajax Reply * @return string - Ajax Reply
*/ */
public function addExecute($_spell = false) public function addExecute($request)
{ {
$r = new Request(); $user = $this->getLoggedUser();
if ($_spell) { $_s = $request->getParameter('spell');
$_s = $_spell;
}
else {
$_s = $r->getSpell();
}
$_user = 'vesta';
$params = array( $params = array(
'USER' => $_user, /// OWNER ??? 'USER' => $user['uid'], /// OWNER ???
'DNS_DOMAIN' => $_s['DNS_DOMAIN'], 'DNS_DOMAIN' => $_s['DNS_DOMAIN'],
'IP' => $_s['IP'] 'IP' => $_s['IP']
); );
@ -135,12 +127,11 @@ class DNS extends AjaxHandler
*/ */
public function addRecordExecute($request) public function addRecordExecute($request)
{ {
$r = new Request(); $user = $this->getLoggedUser();
$_s = $r->getSpell(); $_s = $request->getParameter('spell');
$_user = 'vesta';
$params = array( $params = array(
'USER' => $_s['USER'], /// OWNER ??? 'USER' => $user['uid'], /// OWNER ???
'DOMAIN' => $_s['DOMAIN'], 'DOMAIN' => $_s['DOMAIN'],
'RECORD' => $_s['RECORD'], 'RECORD' => $_s['RECORD'],
'RECORD_TYPE' => $_s['TYPE'], 'RECORD_TYPE' => $_s['TYPE'],
@ -166,19 +157,12 @@ class DNS extends AjaxHandler
* @param Request $request * @param Request $request
* @return string - Ajax Reply * @return string - Ajax Reply
*/ */
public function delExecute($_spell = false) public function deleteExecute($request)
{ {
$r = new Request(); $user = $this->getLoggedUser();
if ($_spell) { $_s = $request->getParameter('spell');
$_s = $_spell;
}
else {
$_s = $r->getSpell();
}
$_user = 'vesta';
$params = array( $params = array(
'USER' => $_user, /// OWNER ??? 'USER' => $user['uid'], /// OWNER ???
'DOMAIN' => $_s['DNS_DOMAIN'], 'DOMAIN' => $_s['DNS_DOMAIN'],
); );
@ -202,12 +186,11 @@ class DNS extends AjaxHandler
*/ */
public function delRecordExecute($request) public function delRecordExecute($request)
{ {
$r = new Request(); $_s = $request->getParameter('spell');
$_s = $r->getSpell(); $user = $this->getLoggedUser();
$_user = 'vesta';
$params = array( $params = array(
'USER' => $_user, // TODO: OWNER ??? 'USER' => $user['uid'], // TODO: OWNER ???
'DOMAIN' => $_s['DOMAIN'], 'DOMAIN' => $_s['DOMAIN'],
'RECORD_ID' => $_s['RECORD_ID'] 'RECORD_ID' => $_s['RECORD_ID']
); );
@ -233,18 +216,16 @@ class DNS extends AjaxHandler
*/ */
public function changeExecute($request) public function changeExecute($request)
{ {
$r = new Request(); $_old = $request->getParameter('old');
$_s = $r->getSpell(); $_new = $request->getParameter('new');
$_old = $_s['old']; $user = $this->getLoggedUser();
$_new = $_s['new']; $_DNS_DOMAIN = $_old['DNS_DOMAIN'];
$_user = 'vesta';
$_DNS_DOMAIN = $_new['DNS_DOMAIN'];
if ($_old['IP'] != $_new['IP']) { if ($_old['IP'] != $_new['IP']) {
$result = array(); $result = array();
$result = Vesta::execute(Vesta::V_CHANGE_DNS_DOMAIN_IP, array('USER' => $_user, 'DNS_DOMAIN' => $_DNS_DOMAIN, 'IP' => $_new['IP'])); $result = Vesta::execute(Vesta::V_CHANGE_DNS_DOMAIN_IP, array('USER' => $user['uid'], 'DNS_DOMAIN' => $_DNS_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']);
@ -253,7 +234,7 @@ class DNS extends AjaxHandler
if ($_old['TPL'] != $_new['TPL']) { if ($_old['TPL'] != $_new['TPL']) {
$result = array(); $result = array();
$result = Vesta::execute(Vesta::V_CHANGE_DNS_DOMAIN_TPL, array('USER' => $_user, 'DNS_DOMAIN' => $_DNS_DOMAIN, 'IP' => $_new['TPL'])); $result = Vesta::execute(Vesta::V_CHANGE_DNS_DOMAIN_TPL, array('USER' => $user['uid'], 'DNS_DOMAIN' => $_DNS_DOMAIN, 'IP' => $_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']);
@ -262,7 +243,7 @@ class DNS extends AjaxHandler
if ($_old['TTL'] != $_new['TTL']) { if ($_old['TTL'] != $_new['TTL']) {
$result = array(); $result = array();
$result = Vesta::execute(Vesta::V_CHANGE_DNS_DOMAIN_TTL, array('USER' => $_user, 'DNS_DOMAIN' => $_DNS_DOMAIN, 'IP' => $_new['TTL'])); $result = Vesta::execute(Vesta::V_CHANGE_DNS_DOMAIN_TTL, array('USER' => $user['uid'], 'DNS_DOMAIN' => $_DNS_DOMAIN, 'IP' => $_new['TTL']));
if (!$result['status']) { if (!$result['status']) {
$this->status = FALSE; $this->status = FALSE;
$this->errors['TTL'] = array($result['error_code'] => $result['error_message']); $this->errors['TTL'] = array($result['error_code'] => $result['error_message']);
@ -271,7 +252,7 @@ class DNS extends AjaxHandler
if ($_old['EXP'] != $_new['EXP']) { if ($_old['EXP'] != $_new['EXP']) {
$result = array(); $result = array();
$result = Vesta::execute(Vesta::V_CHANGE_DNS_DOMAIN_EXP, array('USER' => $_user, 'DNS_DOMAIN' => $_DNS_DOMAIN, 'IP' => $_new['EXP'])); $result = Vesta::execute(Vesta::V_CHANGE_DNS_DOMAIN_EXP, array('USER' => $user['uid'], 'DNS_DOMAIN' => $_DNS_DOMAIN, 'IP' => $_new['EXP']));
if (!$result['status']) { if (!$result['status']) {
$this->status = FALSE; $this->status = FALSE;
$this->errors['EXP'] = array($result['error_code'] => $result['error_message']); $this->errors['EXP'] = array($result['error_code'] => $result['error_message']);
@ -280,7 +261,7 @@ class DNS extends AjaxHandler
if ($_old['SOA'] != $_new['SOA']) { if ($_old['SOA'] != $_new['SOA']) {
$result = array(); $result = array();
$result = Vesta::execute(Vesta::V_CHANGE_DNS_DOMAIN_SOA, array('USER' => $_user, 'DNS_DOMAIN' => $_new['DNS_DOMAIN'], 'IP' => $_new['SOA'])); $result = Vesta::execute(Vesta::V_CHANGE_DNS_DOMAIN_SOA, array('USER' => $user['uid'], 'DNS_DOMAIN' => $_new['DNS_DOMAIN'], 'IP' => $_new['SOA']));
if (!$result['status']) { if (!$result['status']) {
$this->status = FALSE; $this->status = FALSE;
$this->errors['SOA'] = array($result['error_code'] => $result['error_message']); $this->errors['SOA'] = array($result['error_code'] => $result['error_message']);
@ -288,11 +269,11 @@ class DNS extends AjaxHandler
} }
if (!$this->status) { if (!$this->status) {
Vesta::execute(Vesta::V_CHANGE_DNS_DOMAIN_IP, array('USER' => $_user, 'DNS_DOMAIN' => $_DNS_DOMAIN, 'IP' => $_old['IP'])); Vesta::execute(Vesta::V_CHANGE_DNS_DOMAIN_IP, array('USER' => $user['uid'], 'DNS_DOMAIN' => $_DNS_DOMAIN, 'IP' => $_old['IP']));
Vesta::execute(Vesta::V_CHANGE_DNS_DOMAIN_TPL, array('USER' => $_user, 'DNS_DOMAIN' => $_DNS_DOMAIN, 'IP' => $_old['TPL'])); Vesta::execute(Vesta::V_CHANGE_DNS_DOMAIN_TPL, array('USER' => $user['uid'], 'DNS_DOMAIN' => $_DNS_DOMAIN, 'IP' => $_old['TPL']));
Vesta::execute(Vesta::V_CHANGE_DNS_DOMAIN_TTL, array('USER' => $_user, 'DNS_DOMAIN' => $_DNS_DOMAIN, 'IP' => $_old['TTL'])); Vesta::execute(Vesta::V_CHANGE_DNS_DOMAIN_TTL, array('USER' => $user['uid'], 'DNS_DOMAIN' => $_DNS_DOMAIN, 'IP' => $_old['TTL']));
Vesta::execute(Vesta::V_CHANGE_DNS_DOMAIN_EXP, array('USER' => $_user, 'DNS_DOMAIN' => $_DNS_DOMAIN, 'IP' => $_old['EXP'])); Vesta::execute(Vesta::V_CHANGE_DNS_DOMAIN_EXP, array('USER' => $user['uid'], 'DNS_DOMAIN' => $_DNS_DOMAIN, 'IP' => $_old['EXP']));
Vesta::execute(Vesta::V_CHANGE_DNS_DOMAIN_SOA, array('USER' => $_user, 'DNS_DOMAIN' => $_new['DNS_DOMAIN'], 'IP' => $_old['SOA'])); Vesta::execute(Vesta::V_CHANGE_DNS_DOMAIN_SOA, array('USER' => $user['uid'], 'DNS_DOMAIN' => $_new['DNS_DOMAIN'], 'IP' => $_old['SOA']));
} }
return $this->reply($this->status, ''); return $this->reply($this->status, '');
@ -306,11 +287,9 @@ class DNS extends AjaxHandler
*/ */
public function changeRecordsExecute($request) public function changeRecordsExecute($request)
{ {
$r = new Request(); $_old = $request->getParameter('old');
$_s = $r->getSpell(); $_new = $request->getParameter('new');
$_old = $_s['old']; $user = $this->getLoggedUser();
$_new = $_s['new'];
$_user = 'vesta';
$_DNS_DOMAIN = $_s['DNS_DOMAIN']; $_DNS_DOMAIN = $_s['DNS_DOMAIN'];
foreach ($_new as $record_id => $record_data) { foreach ($_new as $record_id => $record_data) {
@ -318,7 +297,7 @@ class DNS extends AjaxHandler
if (is_array($_old[$record_id])) { if (is_array($_old[$record_id])) {
$result = Vesta::execute(Vesta::V_CHANGE_DNS_DOMAIN_RECORD, $result = Vesta::execute(Vesta::V_CHANGE_DNS_DOMAIN_RECORD,
array( array(
'USER' => $_user, 'USER' => $user['uid'],
'DNS_DOMAIN' => $_DNS_DOMAIN, 'DNS_DOMAIN' => $_DNS_DOMAIN,
'ID' => $record_id, 'ID' => $record_id,
'RECORD' => $record_data['RECORD'], 'RECORD' => $record_data['RECORD'],
@ -331,7 +310,7 @@ class DNS extends AjaxHandler
} }
} }
else { else {
$result = Vesta::execute(Vesta::V_ADD_DNS_DOMAIN_RECORD, array('USER' => $_user, 'DNS_DOMAIN' => $_DNS_DOMAIN, 'RECORD' => $record_data['RECORD'], 'TYPE' => $record_data['RECORD_TYPE'], 'VALUE' => $record_data['RECORD_VALUE'], 'ID' => $record_id)); $result = Vesta::execute(Vesta::V_ADD_DNS_DOMAIN_RECORD, array('USER' => $user['uid'], 'DNS_DOMAIN' => $_DNS_DOMAIN, 'RECORD' => $record_data['RECORD'], 'TYPE' => $record_data['RECORD_TYPE'], 'VALUE' => $record_data['RECORD_VALUE'], 'ID' => $record_id));
if (!$result['status']) { if (!$result['status']) {
$this->status = FALSE; $this->status = FALSE;
$this->errors[$record_id] = array($result['error_code'] => $result['error_message']); $this->errors[$record_id] = array($result['error_code'] => $result['error_message']);

View file

@ -17,7 +17,7 @@ class IP extends AjaxHandler
* @param Request $request * @param Request $request
* @return string - Ajax Reply * @return string - Ajax Reply
*/ */
public function getListExecute($request) public function getListExecute(Request $request)
{ {
$reply = array(); $reply = array();
$result = Vesta::execute(Vesta::V_LIST_SYS_IPS, array(Config::get('response_type'))); $result = Vesta::execute(Vesta::V_LIST_SYS_IPS, array(Config::get('response_type')));
@ -42,7 +42,7 @@ class IP extends AjaxHandler
* @param Request $request * @param Request $request
* @return string - Ajax Reply * @return string - Ajax Reply
*/ */
public function getListUserIpsExecute($request) public function getListUserIpsExecute(Request $request)
{ {
$reply = array(); $reply = array();
$result = Vesta::execute(Vesta::V_LIST_SYS_IPS, array(Config::get('response_type'))); $result = Vesta::execute(Vesta::V_LIST_SYS_IPS, array(Config::get('response_type')));
@ -67,19 +67,17 @@ class IP extends AjaxHandler
* @param Request $request * @param Request $request
* @return string - Ajax Reply * @return string - Ajax Reply
*/ */
public function addExecute($request) public function addExecute(Request $request)
{ {
$r = new Request(); $user = $this->getLoggedUser();
$_s = $r->getSpell(); $spell = $request->getParameter('spell');
$_user = 'vesta';
$params = array( $params = array(
'IP_ADDRESS' => $_s['IP_ADDRESS'], 'IP_ADDRESS' => $spell['IP_ADDRESS'],
'MASK' => $_s['MASK'], 'MASK' => $spell['NETMASK'],
'INTERFACE' => $_s['INTERFACE'], 'INTERFACE' => $spell['INTERFACE'],
'OWNER' => $_s['OWNER'], 'OWNER' => $spell['OWNER'],
'IP_STATUS' => $_s['IP_STATUS'], 'IP_STATUS' => $spell['STATUS']
'IP_NAME' => $_s['IP_NAME'] //'IP_NAME' => $spell['NAME']
); );
$result = Vesta::execute(Vesta::V_ADD_SYS_IP, $params); $result = Vesta::execute(Vesta::V_ADD_SYS_IP, $params);
@ -97,13 +95,12 @@ class IP extends AjaxHandler
* @param Request $request * @param Request $request
* @return string - Ajax Reply * @return string - Ajax Reply
*/ */
public function delExecute($request) public function deleteExecute(Request $request)
{ {
$r = new Request(); $spell = $request->getParameter('spell');
$_s = $r->getSpell(); $user = $this->getLoggedUser();
$_user = 'vesta';
$params = array( $params = array(
'IP_ADDRESS' => $_s['IP_ADDRESS'] 'IP_ADDRESS' => $spell['IP_ADDRESS']
); );
$result = Vesta::execute(Vesta::V_DEL_SYS_IP, $params); $result = Vesta::execute(Vesta::V_DEL_SYS_IP, $params);
@ -121,13 +118,11 @@ class IP extends AjaxHandler
* @param Request $request * @param Request $request
* @return string - Ajax Reply * @return string - Ajax Reply
*/ */
public function changeExecute($request) public function changeExecute(Request $request)
{ {
$r = new Request(); $user = $this->getLoggedUser();
$_s = $r->getSpell(); $_old = $request->getParameter('old');
$_old = $_s['old']; $_new = $request->getParameter('new');
$_new = $_s['new'];
$_user = 'vesta';
if ($_old['OWNER'] != $_new['OWNER']) { if ($_old['OWNER'] != $_new['OWNER']) {
$result = array(); $result = array();
@ -138,14 +133,15 @@ class IP extends AjaxHandler
} }
} }
if ($_old['NAME'] != $_new['NAME']) { // TODO: Handle NAME parameter
/*if ($_old['NAME'] != $_new['NAME']) {
$result = array(); $result = array();
$result = Vesta::execute(Vesta::V_CHANGE_SYS_IP_NAME, array('IP' => $_new['IP_ADDRESS'], 'NAME' => $_new['NAME'])); $result = Vesta::execute(Vesta::V_CHANGE_SYS_IP_NAME, array('IP' => $_new['IP_ADDRESS'], 'NAME' => $_new['NAME']));
if (!$result['status']) { if (!$result['status']) {
$this->status = FALSE; $this->status = FALSE;
$this->errors['NAME'] = array($result['error_code'] => $result['error_message']); $this->errors['NAME'] = array($result['error_code'] => $result['error_message']);
} }
} }*/
if ($_old['IP_STATUS'] != $_new['IP_STATUS']) { if ($_old['IP_STATUS'] != $_new['IP_STATUS']) {
$result = array(); $result = array();

View file

@ -47,16 +47,16 @@ class MAIN extends AjaxHandler
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();
$user_ips = json_decode($ip_obj->getListUserIpsExecute(), TRUE); $user_ips = json_decode($ip_obj->getListUserIpsExecute($request), TRUE);
foreach ($user_ips['data'] as $ip) { foreach ($user_ips['data'] as $ip) {
$ips[$ip['IP_ADDRESS']] = $ip['IP_ADDRESS']; $ips[$ip['IP_ADDRESS']] = $ip['IP_ADDRESS'];
} }
// USER // USER
$user_obj = new USER(); $user_obj = new USER();
$users = json_decode($user_obj->getListExecute(), TRUE); $users = json_decode($user_obj->getListExecute($request), TRUE);
$user_names = array_keys($users['data']['data']); $user_names = array_keys($users['data']);
$db_types = array('mysql' => 'mysql', 'postgress' => 'postgress'); $db_types = array('mysql' => 'mysql', 'postgress' => 'postgress');
$interfaces_arr = json_decode($ip_obj->getSysInterfacesExecute(), TRUE); $interfaces_arr = json_decode($ip_obj->getSysInterfacesExecute($request), TRUE);
$interfaces = $interfaces_arr['data']; $interfaces = $interfaces_arr['data'];
$data_web_domain = array('ips' => $ips); $data_web_domain = array('ips' => $ips);
@ -133,8 +133,12 @@ class MAIN extends AjaxHandler
*/ */
public function getIpParams($data = array()) public function getIpParams($data = array())
{ {
$users = array();
foreach ((array)$data['user_names'] as $user) {
$users[$user] = $user;
}
return array( return array(
'SYS_USERS' => $data['user_names'], 'SYS_USERS' => $users,
'STATUSES' => array( 'STATUSES' => array(
'shared' => 'shared', 'shared' => 'shared',
'exclusive' => 'exclusive' 'exclusive' => 'exclusive'
@ -163,7 +167,7 @@ class MAIN extends AjaxHandler
public function getDnsParams($data = array()) public function getDnsParams($data = array())
{ {
return array( return array(
'IP' => $data['ips'], 'IP' => @$data['ips'],
'TPL' => array('default' => 'default'), 'TPL' => array('default' => 'default'),
'EXP' => array(), 'EXP' => array(),
'SOA' => array(), 'SOA' => array(),

View file

@ -29,9 +29,12 @@ class USER extends AjaxHandler
foreach ($result['data'] as $user => $details) { foreach ($result['data'] as $user => $details) {
$fullname_id = rand(0, count($users)-1); $fullname_id = rand(0, count($users)-1);
$fullname = $users[$fullname_id]; $fullname = implode('', array($details['FNAME'], ' ', $details['LNAME']));
//if ($user == 'TestGOOD') {var_dump($details);die();}
$reply[$user] = array( $nses = $this->getNS($user, $details);
$user_details = array(
"FNAME" => $details['FNAME'],
"LNAME" => $details['LNAME'],
"LOGIN_NAME" => $user, "LOGIN_NAME" => $user,
"FULLNAME" => $fullname, // TODO skid "FULLNAME" => $fullname, // TODO skid
"PACKAGE" => $details['PACKAGE'], "PACKAGE" => $details['PACKAGE'],
@ -45,8 +48,8 @@ class USER extends AjaxHandler
"DNS_DOMAINS" => $details['DNS_DOMAINS'], "DNS_DOMAINS" => $details['DNS_DOMAINS'],
"DISK_QUOTA" => $details['DISK_QUOTA'],//$disk_quota, "DISK_QUOTA" => $details['DISK_QUOTA'],//$disk_quota,
"BANDWIDTH" => $details['BANDWIDTH'],//$bandwidth, "BANDWIDTH" => $details['BANDWIDTH'],//$bandwidth,
"NS_LIST" => array($details['NS1'], $details['NS2']), // TODO skid //"NS_LIST" => array($details['NS1'], $details['NS2']), // TODO skid
"SHELL" => $details['"SHELL'], "SHELL" => $details['SHELL'],
"BACKUPS" => $details['BACKUPS'], "BACKUPS" => $details['BACKUPS'],
"WEB_TPL" => $details['WEB_TPL'], "WEB_TPL" => $details['WEB_TPL'],
"MAX_CHILDS" => $details['MAX_CHILDS'], "MAX_CHILDS" => $details['MAX_CHILDS'],
@ -69,6 +72,7 @@ class USER extends AjaxHandler
"U_MAIL_FORWARDERS" => rand(1, 10), // TODO: skid "U_MAIL_FORWARDERS" => rand(1, 10), // TODO: skid
"REPORTS_ENABLED" => 'enabled' // TODO: skid "REPORTS_ENABLED" => 'enabled' // TODO: skid
); );
$reply[$user] = array_merge($user_details, $nses);
} }
return $this->reply(TRUE, $reply); return $this->reply(TRUE, $reply);
@ -85,17 +89,22 @@ class USER extends AjaxHandler
$spell = $request->getParameter('spell'); $spell = $request->getParameter('spell');
$user = $this->getLoggedUser(); $user = $this->getLoggedUser();
$params = array( $params = array(
'USER' => $spell['USER'], 'USER' => $spell['LOGIN_NAME'],
'PASSWORD' => $spell['PASSWORD'], 'PASSWORD' => $spell['PASSWORD'],
'EMAIL' => $spell['EMAIL'], 'EMAIL' => $spell['CONTACT'],
'ROLE' => $spell['ROLE'], 'ROLE' => $spell['ROLE'],
'OWNER' => $user['uid'], 'OWNER' => $user['uid'],
'PACKAGE' => $spell['PACKAGE'], 'PACKAGE' => $spell['PACKAGE'],
'NS1' => $spell['NS1'], 'FNAME' => $spell['FNAME'],
'NS2' => $spell['NS2'] 'LNAME' => $spell['LNAME']
); );
$result = Vesta::execute(Vesta::V_ADD_SYS_USER, $params); $result = Vesta::execute(Vesta::V_ADD_SYS_USER, $params);
// Reports
$enable_reports = Utils::getCheckboxBooleanValue($spell['REPORTS_ENABLED']);
$reports_result = $this->setUserReports($spell['LOGIN_NAME'], $spell['REPORTS_ENABLED']);
// NS
$ns_result = $this->setNSentries($spell['LOGIN_NAME'], $spell);
if (!$result['status']) { if (!$result['status']) {
$this->errors[] = array($result['error_code'] => $result['error_message']); $this->errors[] = array($result['error_code'] => $result['error_message']);
@ -110,19 +119,12 @@ class USER extends AjaxHandler
* @param Request $request * @param Request $request
* @return string - Ajax Reply * @return string - Ajax Reply
*/ */
public function delExecute($_spell = false) public function deleteExecute(Request $request)
{ {
$r = new Request(); $user = $this->getLoggedUser();
if ($_spell) { $spell = $request->getParameter('spell');
$_s = $_spell;
}
else {
$_s = $r->getSpell();
}
$_user = 'vesta';
$params = array( $params = array(
'USER' => $_s['USER'] 'USER' => $spell['LOGIN_NAME']
); );
$result = Vesta::execute(Vesta::V_DEL_SYS_USER, $params); $result = Vesta::execute(Vesta::V_DEL_SYS_USER, $params);
@ -142,25 +144,10 @@ class USER extends AjaxHandler
*/ */
public function changeExecute($request) public function changeExecute($request)
{ {
$r = new Request(); $_new = $request->getParameter('new');
$_s = $r->getSpell(); $_old = $request->getParameter('old');
$_old = $_s['old'];
$_new = $_s['new'];
$_USER = $_new['USER']; $_USER = $_old['LOGIN_NAME'];
if ($_old['USER'] != $_new['USER']) {
$result = array();
// creating new user
$result = $this->addExecute($_new);
// deleting old
if ($result['status']) {
$result = array();
$result = $this->delExecute($_old);
return $this->reply($this->status, '');
}
}
if ($_old['PASSWORD'] != $_new['PASSWORD']) { if ($_old['PASSWORD'] != $_new['PASSWORD']) {
$result = array(); $result = array();
@ -180,32 +167,37 @@ class USER extends AjaxHandler
} }
} }
if ($_old['EMAIL'] != $_new['EMAIL']) { if ($_old['CONTACT'] != $_new['CONTACT']) {
$result = array(); $result = array();
$result = Vesta::execute(Vesta::V_CHANGE_SYS_USER_CONTACT, array('USER' => $_USER, 'EMAIL' => $_new['EMAIL'])); $result = Vesta::execute(Vesta::V_CHANGE_SYS_USER_CONTACT, array('USER' => $_USER, 'EMAIL' => $_new['CONTACT']));
if (!$result['status']) { if (!$result['status']) {
$this->status = FALSE; $this->status = FALSE;
$this->errors['EMAIL'] = array($result['error_code'] => $result['error_message']); $this->errors['EMAIL'] = array($result['error_code'] => $result['error_message']);
} }
} }
if ($_old['NS1'] != $_new['NS1'] || $_old['NS2'] != $_new['NS2']) { $this->setNSentries($_USER, $_new);
$result = array();
$result = Vesta::execute(Vesta::V_CHANGE_SYS_USER_NS, array('USER' => $_USER, 'NS1' => $_new['NS1'], 'NS2' => $_new['NS2'])); $names = array(
'USER' => $_USER,
'NAME' => $_new['LOGIN_NAME'],
'FNAME' => $_new['FNAME'],
'LNAME' => $_new['LNAME']
);
$result = Vesta::execute(Vesta::V_CHANGE_SYS_USER_NAME, $names);
if (!$result['status']) { if (!$result['status']) {
$this->status = FALSE; $this->status = FALSE;
$this->errors['NS'] = array($result['error_code'] => $result['error_message']); $this->errors['NAMES'] = array($result['error_code'] => $result['error_message']);
}
} }
if ($_old['SHELL'] != $_new['SHELL']) { /*if ($_old['SHELL'] != $_new['SHELL']) {
$result = array(); $result = array();
$result = Vesta::execute(Vesta::V_CHANGE_SYS_USER_SHELL, array('USER' => $_USER, 'SHELL' => $_new['SHELL'])); $result = Vesta::execute(Vesta::V_CHANGE_SYS_USER_SHELL, array('USER' => $_USER, 'SHELL' => $_new['SHELL']));
if (!$result['status']) { if (!$result['status']) {
$this->status = FALSE; $this->status = FALSE;
$this->errors['SHELL'] = array($result['error_code'] => $result['error_message']); $this->errors['SHELL'] = array($result['error_code'] => $result['error_message']);
} }
} }*/
if (!$this->status) { if (!$this->status) {
Vesta::execute(Vesta::V_CHANGE_SYS_USER_PASSWORD, array('USER' => $_USER, 'PASSWORD' => $_old['PASSWORD'])); Vesta::execute(Vesta::V_CHANGE_SYS_USER_PASSWORD, array('USER' => $_USER, 'PASSWORD' => $_old['PASSWORD']));
@ -217,4 +209,48 @@ class USER extends AjaxHandler
return $this->reply($this->status, ''); return $this->reply($this->status, '');
} }
protected function setUserReports($user, $enabled)
{
if ($enabled === true) {
$result = Vesta::execute(Vesta::V_ADD_SYS_USER_REPORTS, array('USER' => $user));
}
else {
$result = Vesta::execute(Vesta::V_DEL_SYS_USER_REPORTS, array('USER' => $user));
}
return $result['status'];
}
protected function setNSentries($user, $data)
{
$ns = array();
$ns['USER'] = $user;
$ns['NS1'] = $data['NS1'];
$ns['NS2'] = $data['NS2'];
$ns['NS3'] = isset($data['NS3']) ? $data['NS3'] : '';
$ns['NS4'] = isset($data['NS4']) ? $data['NS4'] : '';
$ns['NS5'] = isset($data['NS5']) ? $data['NS5'] : '';
$ns['NS6'] = isset($data['NS6']) ? $data['NS6'] : '';
$ns['NS7'] = isset($data['NS7']) ? $data['NS7'] : '';
$ns['NS8'] = isset($data['NS8']) ? $data['NS8'] : '';
$result = Vesta::execute(Vesta::V_CHANGE_SYS_USER_NS, $ns);
return $result['status'];
}
protected function getNS($user, $data)
{
$result = array();
$ns_str = $data['NS'];
$ns_list = explode(',', $ns_str);
foreach (range(0, 7) as $index) {
$result['NS'.($index + 1)] = @trim(@$ns_list[$index]);
}
return $result;
}
} }

View file

@ -1,5 +1,17 @@
<?php <?php
$url = "http://dev.vestacp.com:8083/dispatch.php";
$useragent = "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)";
$ch = curl_init();
curl_setopt($ch, CURLOPT_USERAGENT, $useragent);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($_POST));
$result= curl_exec ($ch);
curl_close ($ch);
die();
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';

View file

@ -17,7 +17,7 @@ class Request
protected $get = array(); protected $get = array();
protected $global = array(); protected $global = array();
protected $_merged = array(); protected $_merged = array();
protected $_spell = array(); //protected $_spell = array();
/** /**
* *
@ -40,7 +40,7 @@ class Request
$this->post, $this->post,
$this->get, $this->get,
$this->global); $this->global);
$this->_spell = json_decode($this->_merged['spell'], true); //$this->_spell = json_decode($this->_merged['spell'], true);
} }
/** /**
@ -52,7 +52,12 @@ class Request
*/ */
public function getParameter($key, $default=false) public function getParameter($key, $default=false)
{ {
return isset($this->_merged[$key]) ? $this->_merged[$key] : $default; $param = isset($this->_merged[$key]) ? $this->_merged[$key] : $default;
if ($json = @json_decode($param, true)) {
return $json;
}
return $param;
} }
/** /**
@ -60,10 +65,10 @@ class Request
* *
* @return array * @return array
*/ */
public function getSpell() /*public function getSpell()
{ {
return $this->_spell; return $this->_spell;
} }*/
/** /**
* Check if parameter is set * Check if parameter is set

View file

@ -55,6 +55,7 @@ class Vesta
const V_CHANGE_SYS_USER_SHELL = 'v_change_sys_user_shell'; const V_CHANGE_SYS_USER_SHELL = 'v_change_sys_user_shell';
const V_CHANGE_SYS_USER_ROLE = 'v_change_sys_user_role'; const V_CHANGE_SYS_USER_ROLE = 'v_change_sys_user_role';
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';
// WEB_DOMAIN // WEB_DOMAIN
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';
@ -127,9 +128,13 @@ class Vesta
'parameters' => implode("' '", $parameters), 'parameters' => implode("' '", $parameters),
); );
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;

View file

@ -10,7 +10,7 @@ function error_dumper($errno, $errstr, $errfile, $errline)
switch ($errno) { switch ($errno) {
case E_USER_ERROR: case E_USER_ERROR:
$o = "ERROR: [$errno] $errstr\n"; $o = date('Y-m-d H:i:s')."ERROR: $errstr [$errfile $errline]\n";
$o.= " Fatal error on line $errline in file $errfile"; $o.= " Fatal error on line $errline in file $errfile";
$o.= ", PHP " . PHP_VERSION . " (" . PHP_OS . ")\n"; $o.= ", PHP " . PHP_VERSION . " (" . PHP_OS . ")\n";
$o.= "Aborting...\n"; $o.= "Aborting...\n";
@ -20,19 +20,19 @@ function error_dumper($errno, $errstr, $errfile, $errline)
break; break;
case E_USER_WARNING: case E_USER_WARNING:
$o = "WARNING: [$errno] $errstr\n"; $o = date('Y-m-d H:i:s')."WARNING: $errstr [$errfile $errline]\n";
fwrite($log, $o); fwrite($log, $o);
fclose($log); fclose($log);
break; break;
case E_USER_NOTICE: case E_USER_NOTICE:
$o = "NOTICE: [$errno] $errstr\n"; $o = date('Y-m-d H:i:s')."NOTICE: $errstr [$errfile $errline]\n";
fwrite($log, $o); fwrite($log, $o);
fclose($log); fclose($log);
break; break;
default: default:
$o = "Unknown error type: [$errno] $errstr\n"; $o = date('Y-m-d H:i:s')."Unknown error type: $errstr [$errfile $errline]\n";
fwrite($log, $o); fwrite($log, $o);
fclose($log); fclose($log);
break; break;