mirror of
https://github.com/myvesta/vesta
synced 2025-08-21 13:54:28 -07:00
Merge branch 'master' of github.com:serghey-rodin/vesta
This commit is contained in:
commit
924e277abd
24 changed files with 2269 additions and 2196 deletions
192
web/css/main.css
192
web/css/main.css
|
@ -3,7 +3,7 @@ Title : Vesta
|
|||
Author : Eugen Lobicov, eugen.lobicov@gmail.com
|
||||
|
||||
created : November 27, 2009
|
||||
last updated : March 14, 2011
|
||||
last updated : July 10, 2011
|
||||
- - - - - - - - - - - - - - - - - - */
|
||||
|
||||
html{
|
||||
|
@ -23,12 +23,8 @@ body{
|
|||
border:1px solid red;
|
||||
border:solid #a9aa98;
|
||||
border-width:0 2px;
|
||||
/* padding:0 0 0 10px;
|
||||
background:url(../images/bg-left.gif) repeat-y;*/
|
||||
}
|
||||
.outer{
|
||||
/* padding:0 10px 0 0;
|
||||
background:url(../images/bg-right.gif) repeat-y 100% 0;*/
|
||||
padding-bottom:58px;
|
||||
background:#fff url(../images/footer-bg.gif) repeat-x 0 100%;
|
||||
}
|
||||
|
@ -1076,6 +1072,11 @@ input::-moz-focus-inner{
|
|||
font-size:12px;
|
||||
color:#777;
|
||||
}
|
||||
.prop-value-collapsed-childs{
|
||||
padding-right:15px;
|
||||
background:url(../images/group-values-collapsed.png) no-repeat 100% 5px;
|
||||
cursor:pointer;
|
||||
}
|
||||
.show-records{
|
||||
display:inline-block;
|
||||
padding-right:15px;
|
||||
|
@ -1095,6 +1096,36 @@ input::-moz-focus-inner{
|
|||
cursor:pointer;
|
||||
}
|
||||
|
||||
.prop-box_group-values{
|
||||
display:block;
|
||||
}
|
||||
.prop-box_group-values .prop-title{
|
||||
float: left;
|
||||
margin:2px 0 0;
|
||||
}
|
||||
.prop-box_group-values .group-values{
|
||||
float:left;
|
||||
margin-left:3px;
|
||||
}
|
||||
.group-values .prop-value{
|
||||
display:block;
|
||||
}
|
||||
.group-values__bullet .prop-value{
|
||||
padding-left:15px;
|
||||
background:url(../images/group-value-bullet.png) no-repeat 5px 8px;
|
||||
}
|
||||
.group-values .group-switcher{
|
||||
padding-right:15px;
|
||||
background:url(../images/group-values-collapsed.png) no-repeat 100% 4px;
|
||||
}
|
||||
.group-values .group-values-count{
|
||||
font-size:12px;
|
||||
font-style:italic;
|
||||
color:#cdcdcd;
|
||||
border-bottom:1px solid #c9cac4;
|
||||
cursor:pointer;
|
||||
}
|
||||
|
||||
.props-additional .owner-box{
|
||||
padding-left:45px;
|
||||
}
|
||||
|
@ -1258,6 +1289,9 @@ input::-moz-focus-inner{
|
|||
width:230px;
|
||||
cursor:pointer;
|
||||
}
|
||||
.b-new-entry_dns .ttl-field{
|
||||
width:75px;
|
||||
}
|
||||
.generate-pwd,
|
||||
.context-settings{
|
||||
position:relative;
|
||||
|
@ -1600,11 +1634,7 @@ input::-moz-focus-inner{
|
|||
.domains-list .ip-adr-box .prop-box{
|
||||
margin-left:20px;
|
||||
}
|
||||
/* .domains-list .ip-adr-box .prop-value{
|
||||
padding:0;
|
||||
cursor:pointer;
|
||||
border-bottom:1px solid #cbcbbf;
|
||||
} */
|
||||
|
||||
.domains-list .props-additional{
|
||||
width:230px;
|
||||
padding-top:0;
|
||||
|
@ -1676,6 +1706,107 @@ input::-moz-focus-inner{
|
|||
background-color:#9fec00;
|
||||
}
|
||||
|
||||
/* New graphs */
|
||||
.stats-box{
|
||||
position:relative;
|
||||
margin-left:-25px;
|
||||
padding-left:25px;
|
||||
background:url(../images/stats-brace.png) no-repeat 0 50%;
|
||||
}
|
||||
.stats-box-title{
|
||||
position:absolute;
|
||||
top:50%;
|
||||
left:-65px;
|
||||
margin-top:-10px;
|
||||
padding-right:25px;
|
||||
text-transform:uppercase;
|
||||
font-size:9px;
|
||||
line-height:12px;
|
||||
background:url(../images/stats-curve.png) no-repeat 100% 50%;
|
||||
color:#acacac;
|
||||
border-bottom:1px solid #acacac;
|
||||
}
|
||||
.b-usage-box2{
|
||||
display:block;
|
||||
margin:0 0 22px;
|
||||
position:relative;
|
||||
}
|
||||
.b-usage-box2 .prop-title{
|
||||
float:left;
|
||||
margin:2px 15px 0 0;
|
||||
}
|
||||
.b-usage-box2 .usage-box{
|
||||
float:left;
|
||||
}
|
||||
.b-usage-box2 .value-box{
|
||||
padding-top:11px;
|
||||
float:left;
|
||||
width:85px;
|
||||
}
|
||||
.b-usage-box2 .max-size{
|
||||
position:relative;
|
||||
top:11px;
|
||||
float:right;
|
||||
padding:7px 0 0 3px;
|
||||
border-left:1px solid #B7B7B9;
|
||||
font-size:10px;
|
||||
line-height:1;
|
||||
color:#acacac;
|
||||
}
|
||||
.b-usage-box2 .max-size .units{
|
||||
font-size:10px;
|
||||
color:#acacac;
|
||||
}
|
||||
.b-usage-box2 .graph{
|
||||
position:relative;
|
||||
border:solid #b7b7b9;
|
||||
border-width:1px 0 1px 1px;
|
||||
font-size:0;
|
||||
line-height:0;
|
||||
}
|
||||
.b-usage-box2 .value{
|
||||
position:absolute;
|
||||
top:-15px;
|
||||
left:0;
|
||||
z-index:10;
|
||||
display:block;
|
||||
white-space:nowrap;
|
||||
padding:0 0 7px 3px;
|
||||
font-size:11px;
|
||||
line-height:1;
|
||||
background:url(../images/bar-value-mark.png) no-repeat 0 100%;
|
||||
color:#797979;
|
||||
}
|
||||
.b-usage-box2 .value-size{
|
||||
padding-left:3px;
|
||||
}
|
||||
.b-usage-box2 .graph .bar{
|
||||
position:relative;
|
||||
display:block;
|
||||
height:2px;
|
||||
background-color:#9fec00;
|
||||
}
|
||||
|
||||
/* Overdraft */
|
||||
.b-usage-box2 .overdraft{}
|
||||
|
||||
.b-usage-box2 .overdraft .value{
|
||||
margin-left:-1px;
|
||||
color:#F00;
|
||||
}
|
||||
|
||||
.b-usage-box2 .bar_overdraft{
|
||||
position:absolute;
|
||||
top:-1px;
|
||||
z-index:5;
|
||||
display:block;
|
||||
height:2px;
|
||||
border:solid #b7b7b9;
|
||||
border-width:1px 0;
|
||||
background:#ff9934 url(../images/overrun-border.png) no-repeat 100% 0;
|
||||
}
|
||||
|
||||
|
||||
.domains-list .disk-usage{
|
||||
margin:0 0 6px;
|
||||
}
|
||||
|
@ -1829,7 +1960,7 @@ input::-moz-focus-inner{
|
|||
padding:0 3px 0 0;
|
||||
}
|
||||
|
||||
/* Cron list
|
||||
/* Users list
|
||||
- - - - - - - - - - - - - - - - - - - */
|
||||
.users-list{}
|
||||
|
||||
|
@ -1841,9 +1972,11 @@ input::-moz-focus-inner{
|
|||
}
|
||||
.users-list .props-main{
|
||||
width:345px;
|
||||
width:330px;
|
||||
}
|
||||
.users-list .username-box{
|
||||
padding-top:6px;
|
||||
margin:0 0 15px;
|
||||
}
|
||||
.users-list .username-box .user{
|
||||
position:relative;
|
||||
|
@ -1866,6 +1999,7 @@ input::-moz-focus-inner{
|
|||
|
||||
.users-list .props-additional{
|
||||
width:200px;
|
||||
width:225px;
|
||||
}
|
||||
.users-list .props-additional .prop-box,
|
||||
.users-list .props-ext .prop-box{
|
||||
|
@ -1875,6 +2009,12 @@ input::-moz-focus-inner{
|
|||
.users-list .props-additional .ns2-box{
|
||||
padding-left:27px;
|
||||
}
|
||||
/* .users-list .ns-list-box{
|
||||
padding-left:40px;
|
||||
}*/
|
||||
.users-list .ns-list-box .group-switcher{
|
||||
padding-left:15px;
|
||||
}
|
||||
.users-list .props-additional .ns1-box .prop-title,
|
||||
.users-list .props-additional .ns2-box .prop-title{
|
||||
display: inline;
|
||||
|
@ -1887,11 +2027,16 @@ input::-moz-focus-inner{
|
|||
}
|
||||
|
||||
.users-list .props-ext{
|
||||
width:200px;
|
||||
width:190px;
|
||||
}
|
||||
|
||||
.users-list .db-box,
|
||||
.users-list .dnsdomains-box{
|
||||
margin-top:35px;
|
||||
}
|
||||
|
||||
.username-box .prop-box{
|
||||
position:relative;
|
||||
/* top:6px;*/
|
||||
margin:0;
|
||||
}
|
||||
.user-details{
|
||||
|
@ -1904,6 +2049,14 @@ input::-moz-focus-inner{
|
|||
.user-details .user-reports{
|
||||
color:#9c9c9c;
|
||||
}
|
||||
.user-details-box .prop-box{
|
||||
margin:0 0 5px;
|
||||
}
|
||||
.user-details-box .user-name .prop-value,
|
||||
.user-details-box .user-email{
|
||||
font-style:italic;
|
||||
color:#706f6b;
|
||||
}
|
||||
|
||||
/* DB list
|
||||
- - - - - - - - - - - - - - - - - - - */
|
||||
|
@ -2262,3 +2415,16 @@ input::-moz-focus-inner{
|
|||
.users-list .suspended-row .user-backups-box .prop-title:active{
|
||||
color:#ccc;
|
||||
}
|
||||
|
||||
|
||||
select{
|
||||
background-color: white;
|
||||
width:265px;
|
||||
margin:0;
|
||||
padding:6px 7px;
|
||||
border:2px solid #b8c2c3;
|
||||
color:#555;
|
||||
font-family:Arial, Helvetica, sans-serif;
|
||||
font-size:14px;
|
||||
font-weight:bold;
|
||||
}
|
||||
|
|
|
@ -1,10 +1,8 @@
|
|||
$(document).ready(function(){
|
||||
try{
|
||||
App.Utils.detectBrowser();
|
||||
|
||||
App.Env.world = 'USER';
|
||||
App.Env.world = 'CRON';
|
||||
App.Pages.init();
|
||||
|
||||
App.Ref.init();
|
||||
|
||||
//App.View.start();
|
||||
|
|
|
@ -13,6 +13,8 @@ App.i18n.getMessage = function(key)
|
|||
App.Constants.IP_FORM_ID = 'ip-form';
|
||||
App.Constants.DNS_FORM_ID = 'dns-form';
|
||||
App.Constants.USER_FORM_ID = 'user-form';
|
||||
App.Constants.WEB_DOMAIN_FORM_ID = 'web_domain-form';
|
||||
App.Constants.DB_FORM_ID = 'db-form';
|
||||
|
||||
App.Settings.ajax_url = 1;
|
||||
App.Settings.uri = location.href.replace('index.html', '');
|
||||
|
|
|
@ -105,13 +105,8 @@ App.Actions.save_form = function(evt) {
|
|||
var values = App.Helpers.getFormValues(elm);
|
||||
if(App.Validate.form(values, $('#'+elm_id))) {
|
||||
App.Model.add(values, source);
|
||||
//var form_id = App.Constants[App.Env.world + '_FORM_ID'];
|
||||
//$('#'+form_id).remove();
|
||||
App.Model.update(values, source, elm);
|
||||
}
|
||||
/*if(App.Validate.form(values, $('#'+elm_id))) {
|
||||
App.Model.update(values, source);
|
||||
}*/
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -148,6 +143,16 @@ App.Actions.cancel_form = function(evt, params) {
|
|||
App.Helpers.updateScreen();
|
||||
}
|
||||
|
||||
App.Actions.suspend = function(evt)
|
||||
{
|
||||
alert('Suspend?');
|
||||
}
|
||||
|
||||
App.Actions.unsuspend = function(evt)
|
||||
{
|
||||
alert('Unsuspend?');
|
||||
}
|
||||
|
||||
// do_action_form_help
|
||||
App.Actions.showFormHelp = function(evt) {
|
||||
var tpl_name = App.Env.world + '_form';
|
||||
|
@ -188,3 +193,39 @@ App.Actions.generate_pass = function()
|
|||
{
|
||||
$('.password').val(App.Helpers.generatePassword());
|
||||
}
|
||||
|
||||
App.Actions.toggle_section = function(evt)
|
||||
{
|
||||
var elm = $(evt.target);
|
||||
var ref = $(elm).parents('.form-options-group:first');
|
||||
fb.log(ref);
|
||||
if ($('.sub_section:first', ref).hasClass('hidden')) {
|
||||
$('.sub_section:first', ref).removeClass('hidden');
|
||||
$('.group-header:first', ref).removeClass('collapsed').addClass('expanded');
|
||||
}
|
||||
else {
|
||||
$('.sub_section:first', ref).addClass('hidden');
|
||||
$('.group-header:first', ref).removeClass('expanded').addClass('collapsed');
|
||||
}
|
||||
}
|
||||
|
||||
App.Actions.close_inner_popup = function(evt)
|
||||
{
|
||||
App.Helpers.closeInnerPopup();
|
||||
}
|
||||
|
||||
App.Actions.open_inner_popup = function(evt)
|
||||
{
|
||||
var elm = $(evt.target);
|
||||
App.Helpers.openInnerPopup(elm, $(elm).next('.inner-popup-html').val());
|
||||
}
|
||||
|
||||
App.Actions.add_db_user = function(evt)
|
||||
{
|
||||
alert('TODO');
|
||||
}
|
||||
|
||||
App.Actions.backup_db = function(evt)
|
||||
{
|
||||
alert('TODO');
|
||||
}
|
||||
|
|
|
@ -1,3 +1,44 @@
|
|||
|
||||
|
||||
App.Helpers.getMbHumanMeasure = function(val)
|
||||
{
|
||||
return App.Helpers.getMbHuman(val, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Currently no bytes are used, minimal value is in MB
|
||||
* uncomment in case we will use bytes instead
|
||||
*/
|
||||
App.Helpers.getMbHuman = function(val, only_measure)
|
||||
{
|
||||
var bytes = val * 1024 * 1024;
|
||||
var kilobyte = 1024;
|
||||
var megabyte = kilobyte * 1024;
|
||||
var gigabyte = megabyte * 1024;
|
||||
var terabyte = gigabyte * 1024;
|
||||
var precision = 0;
|
||||
|
||||
/*if ((bytes >= 0) && (bytes < kilobyte)) {
|
||||
return bytes + ' B';
|
||||
|
||||
} else if ((bytes >= kilobyte) && (bytes < megabyte)) {
|
||||
return (bytes / kilobyte).toFixed(precision) + ' KB';
|
||||
|
||||
} else */
|
||||
if ((bytes >= megabyte) && (bytes < gigabyte)) {
|
||||
return only_measure ? 'MB' : (bytes / megabyte).toFixed(precision);
|
||||
|
||||
} else if ((bytes >= gigabyte) && (bytes < terabyte)) {
|
||||
return only_measure ? 'GB' : (bytes / gigabyte).toFixed(precision);
|
||||
|
||||
} else if (bytes >= terabyte) {
|
||||
return only_measure ? 'TB' : (bytes / terabyte).toFixed(precision);
|
||||
|
||||
} else {
|
||||
return only_measure ? 'MB' : bytes;
|
||||
}
|
||||
}
|
||||
|
||||
App.Helpers.getFirst = function(obj)
|
||||
{
|
||||
try{ // TODO: remove try / catch
|
||||
|
@ -101,22 +142,6 @@ App.Helpers.showConsoleHint = function()
|
|||
// TODO:
|
||||
}
|
||||
|
||||
|
||||
// UTILS
|
||||
App.Utils.generatePasswordHash = function(length)
|
||||
{
|
||||
var length = length || 11;
|
||||
var chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890!~.";
|
||||
var pass = "";
|
||||
for(var x=0;x<length;x++)
|
||||
{
|
||||
var i = Math.floor(Math.random() * 62);
|
||||
pass += chars.charAt(i);
|
||||
}
|
||||
|
||||
return pass;
|
||||
}
|
||||
|
||||
App.Helpers.markBrowserDetails = function()
|
||||
{
|
||||
var b = App.Env.BROWSER;
|
||||
|
@ -194,12 +219,12 @@ App.Helpers.liveValidate = function()
|
|||
|
||||
App.Helpers.generatePassword = function()
|
||||
{
|
||||
var length = 12;
|
||||
var chars = "abcdefghijklmn.-%$#&-opqrstuvwxyz.-%$#&-ABCDEFGHIJKLMNOPQRSTUV.-%$#&-WXYZ1234567890.-%$#&-";
|
||||
var length = 8;
|
||||
var chars = "aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ0123456789";
|
||||
var pass = "";
|
||||
|
||||
for (x=0;x<length;x++) {
|
||||
var i = Math.floor(Math.random() * 62);
|
||||
var i = Math.floor(Math.random() * chars.length);
|
||||
pass += chars.charAt(i);
|
||||
}
|
||||
|
||||
|
@ -210,3 +235,21 @@ App.Helpers.Warn = function(msg)
|
|||
{
|
||||
alert(msg);
|
||||
}
|
||||
|
||||
App.Helpers.openInnerPopup = function(elm, html)
|
||||
{
|
||||
App.Helpers.closeInnerPopup();
|
||||
|
||||
var offset = $(elm).offset();
|
||||
var tpl = App.Templates.get('inner_popup', 'general');
|
||||
tpl.set(':CONTENT', html);
|
||||
tpl.set(':LEFT', offset.left);
|
||||
tpl.set(':TOP', offset.top);
|
||||
|
||||
$(document.body).append(tpl.finalize());
|
||||
}
|
||||
|
||||
App.Helpers.closeInnerPopup = function(evt)
|
||||
{
|
||||
$('#inner-popup').remove();
|
||||
}
|
||||
|
|
216
web/js/html.js
216
web/js/html.js
|
@ -2,7 +2,7 @@ App.HTML.setTplKeys = function(tpl, o, empty)
|
|||
{
|
||||
var empty = empty || '-';
|
||||
fb.log(empty);
|
||||
tpl.set(':source', $.toJSON(o))
|
||||
tpl.set(':source', $.toJSON(o).replace(/'/gi, "\\'"))
|
||||
$(o).each(function(i, object)
|
||||
{
|
||||
$.each(o, function(key)
|
||||
|
@ -95,7 +95,7 @@ App.HTML.Build.dns_form = function(options, id)
|
|||
}
|
||||
|
||||
App.HTML.Build.ip_form = function(options, id)
|
||||
{
|
||||
{try{
|
||||
if('undefined' == typeof App.Env.initialParams) {
|
||||
return alert('PLease wait a bit. Some background processes are not yet executed. Thank you for patience.');
|
||||
}
|
||||
|
@ -118,42 +118,10 @@ App.HTML.Build.ip_form = function(options, id)
|
|||
tpl.set(':NAME', options.NAME || '');
|
||||
|
||||
tpl = App.HTML.Build.ip_selects(tpl, options);
|
||||
|
||||
}catch(e){fb.error(e);}
|
||||
return tpl.finalize();
|
||||
}
|
||||
|
||||
App.HTML.Build.ip_selects = function(tpl, options)
|
||||
{
|
||||
// OWNER
|
||||
var opts = App.HTML.Build.options(App.Env.initialParams.IP.SYS_USERS, options.OWNER);
|
||||
tpl.set(':owner_options', opts);
|
||||
|
||||
// STATUS
|
||||
var opts = App.HTML.Build.options(App.Env.initialParams.IP.STATUSES, options.STATUS);
|
||||
tpl.set(':status_options', opts);
|
||||
|
||||
// INTERFACE
|
||||
var opts = App.HTML.Build.options(App.Env.initialParams.IP.INTERFACES, options.INTERFACE);
|
||||
tpl.set(':interface_options', opts);
|
||||
|
||||
return tpl;
|
||||
}
|
||||
|
||||
App.HTML.Build.dns_selects = function(tpl, options)
|
||||
{
|
||||
try {
|
||||
// TPL
|
||||
var obj = App.Env.initialParams.DNS.TPL;
|
||||
var opts = App.HTML.Build.options(obj, options.TPL);
|
||||
tpl.set(':TPL', opts);
|
||||
tpl.set(':TPL_DEFAULT_VALUE', options.TPL || App.Helpers.getFirstKey(obj));
|
||||
}
|
||||
catch (e) {
|
||||
return '';
|
||||
}
|
||||
|
||||
return tpl;
|
||||
}
|
||||
|
||||
App.HTML.Build.options = function(initial, default_value)
|
||||
{
|
||||
|
@ -196,10 +164,10 @@ App.HTML.Build.dns_entry = function(o, is_new)
|
|||
}
|
||||
|
||||
if (App.Constants.SUSPENDED_YES == o.SUSPEND) {
|
||||
var sub_tpl = App.Templates.get('SUSPENDED_TPL_ENABLED', 'dns');
|
||||
var sub_tpl = App.Templates.get('SUSPENDED_TPL_NOT_SUSPENDED', 'general');
|
||||
}
|
||||
else {
|
||||
var sub_tpl = App.Templates.get('SUSPENDED_TPL_DISABLED', 'dns');
|
||||
var sub_tpl = App.Templates.get('SUSPENDED_TPL_SUSPENDED', 'general');
|
||||
}
|
||||
|
||||
tpl.set(':SUSPENDED_TPL', sub_tpl.finalize());
|
||||
|
@ -210,19 +178,23 @@ App.HTML.Build.dns_entry = function(o, is_new)
|
|||
App.HTML.Build.user_entry = function(o, key)
|
||||
{
|
||||
var processed_data = {
|
||||
'NICKNAME': key,
|
||||
'BANDWIDTH_PERCENTS': 90,
|
||||
'U_DISK_PERCENTS': 80
|
||||
'NICKNAME' : key,
|
||||
'U_DISK_PERCENTAGE' : o.U_DISK > 0 ? o.U_DISK / o.DISK_QUOTA * 100 : 0.01,
|
||||
'U_BANDWIDTH_PERCENTAGE': o.U_BANDWIDTH > 0 ? o.U_BANDWIDTH / o.BANDWIDTH * 100 : 0.01,
|
||||
'DISK_QUOTA_MEASURE' : App.Helpers.getMbHumanMeasure(o.DISK_QUOTA),
|
||||
'BANDWIDTH_MEASURE' : App.Helpers.getMbHumanMeasure(o.BANDWIDTH),
|
||||
'BANDWIDTH' : App.Helpers.getMbHuman(o.BANDWIDTH),
|
||||
'DISK_QUOTA' : App.Helpers.getMbHuman(o.DISK_QUOTA)
|
||||
};
|
||||
var o = $.extend(o, processed_data);
|
||||
var tpl = App.Templates.get('ENTRY', 'user');
|
||||
tpl = App.HTML.setTplKeys(tpl, o);
|
||||
|
||||
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_SUSPENDED', 'general');
|
||||
}
|
||||
else {
|
||||
var sub_tpl = App.Templates.get('SUSPENDED_TPL_DISABLED', 'ip');
|
||||
var sub_tpl = App.Templates.get('SUSPENDED_TPL_NOT_SUSPENDED', 'general');
|
||||
}
|
||||
tpl.set(':SUSPENDED_TPL', sub_tpl.finalize());
|
||||
|
||||
|
@ -258,27 +230,47 @@ App.HTML.Build.user_form = function(options, id)
|
|||
|
||||
App.HTML.Build.web_domain_entry = function(o, key)
|
||||
{
|
||||
// TODO:
|
||||
/*<span class="domain-name">~!:ALIAS~!,</span>\
|
||||
<span class="domain-name">naumov-socolov.org.md,</span>\
|
||||
<span class="domain-name">naumov-socolov.to</span>\*/
|
||||
var processed_data = {
|
||||
DOMAIN: key
|
||||
};
|
||||
var o = $.extend(o, processed_data);
|
||||
//fb.info(o);
|
||||
var tpl = App.Templates.get('ENTRY', 'web_domain');
|
||||
tpl = App.HTML.setTplKeys(tpl, o);
|
||||
|
||||
/*if (App.Constants.SUSPENDED_YES == o.SUSPENDED) {
|
||||
var sub_tpl = App.Templates.get('SUSPENDED_TPL_ENABLED', 'ip');
|
||||
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_DISABLED', 'ip');
|
||||
var sub_tpl = App.Templates.get('SUSPENDED_TPL_NOT_SUSPENDED', 'general');
|
||||
}
|
||||
tpl.set(':SUSPENDED_TPL', sub_tpl.finalize());
|
||||
|
||||
return tpl.finalize();
|
||||
}
|
||||
|
||||
App.HTML.Build.web_domain_form = function(options, id)
|
||||
{
|
||||
if('undefined' == typeof App.Env.initialParams) {
|
||||
return alert('PLease wait a bit. Some background processes are not yet executed. Thank you for patience.');
|
||||
}
|
||||
var tpl = App.Templates.get('FORM', 'web_domain');
|
||||
tpl.set(':source', options);
|
||||
tpl.set(':id', id || '');
|
||||
options = App.Helpers.evalJSON(options) || {};
|
||||
if (App.Helpers.isEmpty(options)) {
|
||||
tpl.set(':title', 'New user');
|
||||
tpl.set(':save_button', 'ADD');
|
||||
}
|
||||
else {
|
||||
tpl.set(':title', 'Edit user');
|
||||
tpl.set(':save_button', 'SAVE');
|
||||
}
|
||||
|
||||
tpl.set(':SUSPENDED_TPL', sub_tpl.finalize());
|
||||
*/
|
||||
options = !App.Helpers.isEmpty(options) ? options : {'CONTACT':'', 'PASSWORD':'','LOGIN_NAME':'','NS':''};
|
||||
|
||||
tpl = App.HTML.setTplKeys(tpl, options, true);
|
||||
tpl = App.HTML.Build.user_selects(tpl, options);
|
||||
|
||||
return tpl.finalize();
|
||||
}
|
||||
|
||||
|
@ -296,16 +288,56 @@ App.HTML.Build.mail_entry = function(o, key)
|
|||
|
||||
App.HTML.Build.db_entry = function(o, key)
|
||||
{
|
||||
var user_list_html = [];
|
||||
$(o['USERS']).each(function(i, o)
|
||||
{
|
||||
var tpl = App.Templates.get('USER_ITEM', 'db');
|
||||
tpl.set(':NAME', o);
|
||||
user_list_html.push(tpl.finalize());
|
||||
});
|
||||
var wrapper = App.Templates.get('USER_ITEMS_WRAPPER', 'db');
|
||||
wrapper.set(':CONTENT', user_list_html.done());
|
||||
var processed_data = {
|
||||
DOMAIN: key
|
||||
'USER_LIST': wrapper.finalize(),
|
||||
'USERS': o['USERS'].length || 0,
|
||||
'U_DISK_PERCENTAGE' : o.U_DISK > 0 ? o.U_DISK / o.DISK * 100 : 0.01,
|
||||
'DISK_MEASURE': App.Helpers.getMbHumanMeasure(o.DISK),
|
||||
'DISK': App.Helpers.getMbHuman(o.DISK)
|
||||
};
|
||||
var o = $.extend(o, processed_data);
|
||||
|
||||
var tpl = App.Templates.get('ENTRY', 'db');
|
||||
tpl = App.HTML.setTplKeys(tpl, o);
|
||||
|
||||
return tpl.finalize();
|
||||
}
|
||||
|
||||
App.HTML.Build.db_form = function(options, id)
|
||||
{
|
||||
if('undefined' == typeof App.Env.initialParams) {
|
||||
return alert('PLease wait a bit. Some background processes are not yet executed. Thank you for patience.');
|
||||
}
|
||||
var tpl = App.Templates.get('FORM', 'db');
|
||||
tpl.set(':source', options);
|
||||
tpl.set(':id', id || '');
|
||||
options = App.Helpers.evalJSON(options) || {};
|
||||
if (App.Helpers.isEmpty(options)) {
|
||||
tpl.set(':title', 'New database');
|
||||
tpl.set(':save_button', 'ADD');
|
||||
}
|
||||
else {
|
||||
tpl.set(':title', 'Edit database "'+options.DB+'"');
|
||||
tpl.set(':save_button', 'SAVE');
|
||||
}
|
||||
|
||||
options = !App.Helpers.isEmpty(options) ? options : {'DB':'', 'USER':'','FORM':'', 'PASSWORD': ''};
|
||||
|
||||
tpl = App.HTML.setTplKeys(tpl, options, true);
|
||||
tpl = App.HTML.Build.db_selects(tpl, options);
|
||||
|
||||
return tpl.finalize();
|
||||
}
|
||||
|
||||
App.HTML.Build.cron_entry = function(o, key)
|
||||
{
|
||||
var processed_data = {
|
||||
|
@ -315,6 +347,14 @@ App.HTML.Build.cron_entry = function(o, key)
|
|||
var tpl = App.Templates.get('ENTRY', 'cron');
|
||||
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());
|
||||
|
||||
return tpl.finalize();
|
||||
}
|
||||
|
||||
|
@ -354,6 +394,7 @@ App.HTML.Build.user_selects = function(tpl, options)
|
|||
var tpl = App.Templates.get('select_option', 'general');
|
||||
tpl.set(':VALUE', val);
|
||||
tpl.set(':TEXT', pkg[val]);
|
||||
tpl.set(':SELECTED', val == options.PACKAGE ? 'selected="selected"' : '');
|
||||
acc[acc.length++] = tpl.finalize();
|
||||
});
|
||||
tpl.set(':PACKAGE_OPTIONS', acc.done());
|
||||
|
@ -365,6 +406,7 @@ App.HTML.Build.user_selects = function(tpl, options)
|
|||
var tpl = App.Templates.get('select_option', 'general');
|
||||
tpl.set(':VALUE', val);
|
||||
tpl.set(':TEXT', roles[val]);
|
||||
tpl.set(':SELECTED', val == options.ROLE ? 'selected="selected"' : '');
|
||||
acc[acc.length++] = tpl.finalize();
|
||||
});
|
||||
tpl.set(':ROLE_OPTIONS', acc.done());
|
||||
|
@ -376,6 +418,7 @@ App.HTML.Build.user_selects = function(tpl, options)
|
|||
var tpl = App.Templates.get('select_option', 'general');
|
||||
tpl.set(':VALUE', val);
|
||||
tpl.set(':TEXT', shell[val]);
|
||||
tpl.set(':SELECTED', val == options.SHELL ? 'selected="selected"' : '');
|
||||
acc[acc.length++] = tpl.finalize();
|
||||
});
|
||||
tpl.set(':SHELL_OPTIONS', acc.done());
|
||||
|
@ -383,3 +426,70 @@ App.HTML.Build.user_selects = function(tpl, options)
|
|||
return tpl;
|
||||
}
|
||||
|
||||
App.HTML.Build.db_selects = function(tpl, options)
|
||||
{
|
||||
var acc = [];
|
||||
// PACKAGE
|
||||
var items = App.Env.initialParams.DB.TYPE;
|
||||
$.each(items, function(val)
|
||||
{
|
||||
var tpl = App.Templates.get('select_option', 'general');
|
||||
tpl.set(':VALUE', val);
|
||||
tpl.set(':TEXT', items[val]);
|
||||
tpl.set(':SELECTED', val == options.TYPE ? 'selected="selected"' : '');
|
||||
acc[acc.length++] = tpl.finalize();
|
||||
});
|
||||
tpl.set(':TYPE_OPTIONS', acc.done());
|
||||
// ROLE
|
||||
acc = [];
|
||||
var items = App.Env.initialParams.DB.HOST;
|
||||
$.each(items, function(val)
|
||||
{
|
||||
var tpl = App.Templates.get('select_option', 'general');
|
||||
tpl.set(':VALUE', val);
|
||||
tpl.set(':TEXT', items[val]);
|
||||
tpl.set(':SELECTED', val == options.HOST ? 'selected="selected"' : '');
|
||||
acc[acc.length++] = tpl.finalize();
|
||||
});
|
||||
tpl.set(':HOST_OPTIONS', acc.done());
|
||||
|
||||
return tpl;
|
||||
}
|
||||
|
||||
App.HTML.Build.ip_selects = function(tpl, options)
|
||||
{
|
||||
// OWNER
|
||||
var users = App.Env.initialParams.IP.SYS_USERS || ['Skid'];
|
||||
var opts = App.HTML.Build.options(users, options.OWNER);
|
||||
tpl.set(':owner_options', opts);
|
||||
|
||||
// STATUS
|
||||
var opts = App.HTML.Build.options(App.Env.initialParams.IP.STATUSES, options.STATUS);
|
||||
tpl.set(':status_options', opts);
|
||||
|
||||
// INTERFACE
|
||||
var opts = App.HTML.Build.options(App.Env.initialParams.IP.INTERFACES, options.INTERFACE);
|
||||
tpl.set(':interface_options', opts);
|
||||
|
||||
return tpl;
|
||||
}
|
||||
|
||||
App.HTML.Build.dns_selects = function(tpl, options)
|
||||
{
|
||||
try {
|
||||
// TPL
|
||||
var obj = App.Env.initialParams.DNS.TPL;
|
||||
var opts = App.HTML.Build.options(obj, options.TPL);
|
||||
tpl.set(':TPL', opts);
|
||||
tpl.set(':TPL_DEFAULT_VALUE', options.TPL || App.Helpers.getFirstKey(obj));
|
||||
}
|
||||
catch (e) {
|
||||
return '';
|
||||
}
|
||||
|
||||
return tpl;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -20,12 +20,40 @@ App.Model.WEB_DOMAIN.loadList = function()
|
|||
|
||||
App.Model.MAIL.loadList = function()
|
||||
{
|
||||
App.Ajax.request('MAIL.getList', {}, App.View.listItems);
|
||||
//App.Ajax.request('MAIL.getList', {}, App.View.listItems);
|
||||
App.Ref.CONTENT.html('<center><h1 style="padding-top: 20px;font-size: 28px;">Under maintanance</h1></center>');
|
||||
}
|
||||
|
||||
App.Model.DB.loadList = function()
|
||||
{
|
||||
App.Ajax.request('DB.getList', {}, App.View.listItems);
|
||||
App.Ajax.request('DB.getList', {}, function(reply)
|
||||
{
|
||||
var acc = [];
|
||||
var build_method = App.Env.getWorldName() + '_entry';
|
||||
var data = reply.data;
|
||||
// TODO: fix it data.data
|
||||
$.each(data, function(key)
|
||||
{
|
||||
var db_list = data[key];
|
||||
fb.warn('KEY: %o', key);
|
||||
fb.warn('DATA: %o', data[key]);
|
||||
var tpl_divider = App.Templates.get('DIVIDER', 'db');
|
||||
tpl_divider.set(':TYPE', key);
|
||||
acc[acc.length++] = tpl_divider.finalize();
|
||||
$(db_list).each(function(i, o)
|
||||
{
|
||||
acc[acc.length++] = App.HTML.Build[build_method](o, key);
|
||||
});
|
||||
|
||||
/*var o = data[key];
|
||||
fb.warn(key);
|
||||
acc[acc.length++] = App.HTML.Build[build_method](o, key);*/
|
||||
});
|
||||
|
||||
var html = acc.done().wrapperize('ENTRIES_WRAPPER', App.Env.getWorldName());
|
||||
App.Ref.CONTENT.html(html);
|
||||
App.Helpers.updateScreen();
|
||||
});
|
||||
}
|
||||
|
||||
App.Model.CRON.loadList = function()
|
||||
|
@ -71,7 +99,7 @@ App.Model.remove = function(world, elm)
|
|||
}
|
||||
|
||||
App.Model.update = function(values, source_json, elm)
|
||||
{ alert(source_json);
|
||||
{
|
||||
var method = App.Settings.getMethodName('update');
|
||||
var build_method = App.Env.getWorldName() + '_entry';
|
||||
App.Ajax.request(method, {
|
||||
|
|
|
@ -16,13 +16,23 @@ App.Templates.html = {
|
|||
"Well," the farmer said, "I didn\'t have anymore rope, so I took off my belt and tied her tail to the rafter. In that moment, my pants fell down and my wife walked in ... Some things you just can\'t explain."']
|
||||
},
|
||||
general: {
|
||||
loading: ['<div id="loading" style="top: 0;font-size:19px;font-weight: bol;position:absolute;width: 150px; background-color:yellow;z-index: 9999; padding: 8px;left: 50%;margin-left:-75px;">\
|
||||
loading: ['<div id="loading" style="top: 0;font-size:19px;font-weight: bol;position:fixed;width: 150px; background-color:yellow;z-index: 9999; padding: 8px;left: 50%;margin-left:-75px;">\
|
||||
<center>Loading...</center>\
|
||||
</div>'],
|
||||
popup: ['<div class="black_overlay" id="popup-bg"></div>\
|
||||
<div class="popup_content" id="popup"><button class="do_action_close_popup">close</button>~!:content~!</div>'],
|
||||
inner_popup: ['<div id="inner-popup" style="left:~!:LEFT~!px;top:~!:TOP~!px;z-index:1000;display:block;" class="d-popup d-popup-ns-list">\
|
||||
<div class="d-popup-inner">\
|
||||
<span class="close do_action_close_inner_popup">×</span>\
|
||||
<div class="d-popup-content">\
|
||||
~!:CONTENT~!\
|
||||
</div>\
|
||||
</div>\
|
||||
</div>'],
|
||||
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_SUSPENDED : ['<span class="ip-status-info ip-enabled-status do_action_unsuspend"><span class="ip-status-text do_action_unsuspend">disabled</span></span>']
|
||||
},
|
||||
popup: {
|
||||
error: ['<div class="error"><center><h1 style="color: red;">Important: An Error Has Occured.</h1><hr></center> Something went wrong and some of your actions can be not saved in system. Mostly, it happens when you have network connection errors.<br>, 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>']
|
||||
|
@ -70,13 +80,10 @@ App.Templates.html = {
|
|||
<div class="form-row buttons-row cc">\
|
||||
<input type="submit" value="~!:save_button~!" class="add-entry-btn do_action_save_form" name="save">\
|
||||
<span class="cancel-btn do_action_cancel_form">Cancel</span>\
|
||||
<span class="help-btn do_action_form_help">Help</span>\
|
||||
<a class="help-btn" href="http://vestacp.com/docs/dns/" target="_blank">Help</a>\
|
||||
</div>\
|
||||
</div>'
|
||||
],
|
||||
SUSPENDED_TPL_ENABLED : ['<span class="ip-status-info ip-enabled-status"><span class="ip-status-text">enabled</span></span>\
|
||||
<span class="delete-entry"><span class="delete-entry-text do_action_delete_ip">delete</span></span>'],
|
||||
SUSPENDED_TPL_DISABLED : ['<span class="ip-status-info ip-suspended-status do_action_delete_dns"><span class="ip-status-text">suspended</span></span>'],
|
||||
ENTRIES_WRAPPER: ['<div class="dns-list items-list">~!:content~!</div>'],
|
||||
ENTRY: ['<div class="row dns-details-row ~!:CHECKED~!">\
|
||||
<input type="hidden" name="source" class="source" value=\'~!:source~!\'>\
|
||||
|
@ -162,8 +169,9 @@ App.Templates.html = {
|
|||
FORM: ['\
|
||||
<div class="b-new-entry b-new-entry_ip" id="~!:id~!">\
|
||||
<input type="hidden" name="source" class="source" value=\'~!:source~!\'>\
|
||||
<input type="hidden" name="target" class="target" value=\'~!:target~!\'>\
|
||||
<div class="entry-header">~!:title~!</div>\
|
||||
<div class="errors">\
|
||||
<div class="form-error">\
|
||||
</div>\
|
||||
<div class="form-row cc">\
|
||||
<label for="#" class="field-label">ip address:</label>\
|
||||
|
@ -171,26 +179,25 @@ App.Templates.html = {
|
|||
</div>\
|
||||
<div class="form-row cc">\
|
||||
<label for="#" class="field-label">owner:</label>\
|
||||
<span class="select" id="select2">vesta</span>\
|
||||
<select name="OWNER" class="styled OWNER">\
|
||||
<select name="OWNER" class="not-styled OWNER">\
|
||||
~!:owner_options~!\
|
||||
</select>\
|
||||
</div>\
|
||||
<div class="form-row cc">\
|
||||
<label for="#" class="field-label">status:</label>\
|
||||
<span class="select" id="select">shared</span>\
|
||||
<select class="styled status" name="STATUS">\
|
||||
<!-- span class="select" id="select">shared</span -->\
|
||||
<select class="not-styled status" name="STATUS">\
|
||||
~!:status_options~!\
|
||||
</select>\
|
||||
</div>\
|
||||
<div class="form-row cc">\
|
||||
<label for="#" class="field-label">name:</label>\
|
||||
<input type="text" name="NAME" value="" class="text-field">\
|
||||
<input type="text" name="NAME" value="~!:NAME~!" class="text-field">\
|
||||
</div>\
|
||||
<div class="form-row cc">\
|
||||
<label for="#" class="field-label">interface:</label>\
|
||||
<span class="select" id="select">eth1</span>\
|
||||
<select class="styled interface" name="INTERFACE">\
|
||||
<!-- span class="select" id="select">eth1</span -->\
|
||||
<select class="not-styled interface" name="INTERFACE">\
|
||||
~!:interface_options~!\
|
||||
</select>\
|
||||
</div>\
|
||||
|
@ -203,7 +210,7 @@ App.Templates.html = {
|
|||
<div class="form-row buttons-row cc">\
|
||||
<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="help-btn">Help</span>\
|
||||
<a class="help-btn" href="http://vestacp.com/docs/ip/" target="_blank">Help</a>\
|
||||
</div>\
|
||||
</div>\
|
||||
'],
|
||||
|
@ -216,6 +223,7 @@ App.Templates.html = {
|
|||
<div class="check-this"></div>\
|
||||
<div class="row-operations">\
|
||||
~!:SUSPENDED_TPL~!\
|
||||
<span class="delete-entry do_action_delete_entry"><span class="delete-entry-text do_action_delete_entry">delete</span></span>\
|
||||
</div>\
|
||||
</div>\
|
||||
<div class="row-meta">\
|
||||
|
@ -224,7 +232,7 @@ App.Templates.html = {
|
|||
<div class="row-details cc">\
|
||||
<div class="ip-props-main">\
|
||||
<div class="ip-adr-box">\
|
||||
<span class="ip-adr">~!:IP_ADDRESS~!</span>\
|
||||
<span class="ip-adr do_action_edit">~!:IP_ADDRESS~!</span>\
|
||||
</div>\
|
||||
<span class="prop-box">\
|
||||
<span class="prop-title">netmask:</span>\
|
||||
|
@ -273,7 +281,7 @@ App.Templates.html = {
|
|||
<input type="hidden" name="source" class="source" value=\'~!:source~!\'>\
|
||||
<input type="hidden" name="target" class="target" value=\'\'>\
|
||||
<div class="entry-header">~!:title~!</div>\
|
||||
<div class="form-error hidden">\
|
||||
<div class="form-error">\
|
||||
</div>\
|
||||
<div class="form-row cc">\
|
||||
<label for="#" class="field-label">username:</label>\
|
||||
|
@ -393,7 +401,7 @@ App.Templates.html = {
|
|||
<div class="value-box">\
|
||||
<span class="value">~!:U_BANDWIDTH~!</span>\
|
||||
<div class="graph low">\
|
||||
<span style="width:30%;" class="bar"></span>\
|
||||
<span style="width:~!:U_BANDWIDTH_PERCENTAGE~!%;" class="bar"></span>\
|
||||
</div>\
|
||||
</div>\
|
||||
<div class="max-size">~!:BANDWIDTH~!<span class="units">~!:BANDWIDTH_MEASURE~!</span></div>\
|
||||
|
@ -462,13 +470,118 @@ App.Templates.html = {
|
|||
</div>']
|
||||
},
|
||||
web_domain: {
|
||||
FORM: ['<div id="~!:id~!" class="b-new-entry b-new-entry_domain">\
|
||||
<input type="hidden" class="source" name="source" value=\'~!:source~!\' />\
|
||||
<input type="hidden" class="target" name="target" value="" />\
|
||||
<div class="entry-header">~!:title~!</div>\
|
||||
<div class="form-error">\
|
||||
</div>\
|
||||
<div class="form-row cc">\
|
||||
<label for="#" class="field-label">domain:</label>\
|
||||
<input type="text" name="DOMAIN" class="text-field" value="~!:DOMAIN~!">\
|
||||
</div>\
|
||||
<div class="form-row cc">\
|
||||
<label for="#" class="field-label">ip:</label>\
|
||||
<div class="">\
|
||||
<select name="IP">\
|
||||
~!:IP_OPTIONS~!\
|
||||
</select>\
|
||||
</div>\
|
||||
</div>\
|
||||
<!-- advanced options -->\
|
||||
<div class="form-options-group">\
|
||||
<div class="group-header cc collapsed">\
|
||||
<span class="group-title-outer do_action_toggle_section">\
|
||||
<span class="group-title do_action_toggle_section">Advanced options</span>\
|
||||
</span> \
|
||||
</div>\
|
||||
<div class="sub_section hidden">\
|
||||
<div class="form-row cc adv_opts">\
|
||||
<label for="#" class="field-label">template:</label>\
|
||||
<select class="not-styled" name="TPL">\
|
||||
~!:TPL_OPTIONS~!\
|
||||
</select>\
|
||||
</div>\
|
||||
<div class="form-row cc">\
|
||||
<label for="#" class="field-label">alias list:</label>\
|
||||
<textarea name="ALIAS" class="textarea">~!:ALIAS~!</textarea>\
|
||||
</div>\
|
||||
\
|
||||
<div class="form-row cc">\
|
||||
<label for="#" class="field-label">statistics:</label>\
|
||||
<input type="checkbox" name="STATS" ~!:stats_checked~!="" value="~!:STATS~!" class="styled">\
|
||||
</div>\
|
||||
<div class="stats-settings">\
|
||||
<div class="form-row cc">\
|
||||
<label for="#" class="field-label">stats auth:</label>\
|
||||
<input type="checkbox" name="STATS_AUTH" ~!:stats_auth_checked~!="" value="~!:STATS_AUTH~!" class="styled">\
|
||||
</div>\
|
||||
<div class="form-row cc">\
|
||||
<label for="#" class="field-label">login:</label>\
|
||||
<input type="text" class="text-field" name="STATS_LOGIN" value="~!:STATS_LOGIN~!">\
|
||||
</div>\
|
||||
<div class="form-row pwd-box cc">\
|
||||
<label for="#" class="field-label">password:</label>\
|
||||
<input type="text" value="~!:STATS_PASSWORD~!" name="STATS_PASSWORD" class="text-field password">\
|
||||
<span class="generate-pwd do_action_generate_pass">Generate</span>\
|
||||
</div>\
|
||||
</div><!-- // stats settings -->\
|
||||
<div class="form-row cc">\
|
||||
<label for="#" class="field-label">ssl:</label>\
|
||||
<input type="checkbox" class="styled" ~!:ssl_checked~!="" value="~!SSL~!">\
|
||||
</div>\
|
||||
<div class="form-row cc">\
|
||||
<label for="#" class="field-label">ssl home:</label>\
|
||||
<input type="text" name="SSL_HOME" class="text-field" value="~!:SSL_HOME~!">\
|
||||
</div>\
|
||||
<div class="form-row ssl-crtfct-box cc">\
|
||||
<label for="#" class="field-label">ssl certificate: <span class="remark">(upload file or insert text)</span></label>\
|
||||
<input type="file" value="" size="43" class="file-upload">\
|
||||
<textarea name="SSL_CERT" class="textarea">~!:SSL_CERT~!</textarea>\
|
||||
</div>\
|
||||
</div><!-- // advanced options -->\
|
||||
</div>\
|
||||
<div class="form-options-group">\
|
||||
<div class="group-header cc collapsed">\
|
||||
<span class="group-title-outer do_action_toggle_section">\
|
||||
<span class="group-title do_action_toggle_section">DNS options</span>\
|
||||
</span> \
|
||||
</div>\
|
||||
<div class="sub_section hidden">\
|
||||
<div class="form-row cc">\
|
||||
<label for="#" class="field-label">create dns domain:</label>\
|
||||
<input type="checkbox" value="" class="not-styled">\
|
||||
</div>\
|
||||
</div><!-- DNS options -->\
|
||||
<div class="form-options-group">\
|
||||
<div class="group-header cc collapsed">\
|
||||
<span class="group-title-outer do_action_toggle_section">\
|
||||
<span class="group-title do_action_toggle_section">Mail options</span>\
|
||||
</span> \
|
||||
</div>\
|
||||
<div class="sub_section hidden">\
|
||||
<div class="form-row cc">\
|
||||
<label for="#" class="field-label">create mail domain:</label>\
|
||||
<input type="checkbox" value="" class="not-styled">\
|
||||
</div>\
|
||||
</div>\
|
||||
</div>\
|
||||
</div><!-- Mail options -->\
|
||||
<div class="form-row buttons-row cc">\
|
||||
<input type="submit" value="~!:save_button~!" class="add-entry-btn">\
|
||||
<span class="cancel-btn do_action_cancel_form">Cancel</span>\
|
||||
<a target="_blank" href="http://vestacp.com/docs/web/" class="help-btn">Help</a>\
|
||||
</div>\
|
||||
</div>'],
|
||||
ENTRIES_WRAPPER: ['<div class="domains-list items-list">~!:content~!</div>'],
|
||||
ENTRY: ['<div class="row first-row domain-details-row">\
|
||||
<input type="hidden" class="source" name="source" value=\'~!:source~!\' />\
|
||||
<input type="hidden" class="target" name="target" value="" />\
|
||||
<div class="row-actions-box cc">\
|
||||
<div class="check-this check-control"></div>\
|
||||
<div class="row-operations">\
|
||||
<span class="ip-status-info ip-enabled-status"><span class="ip-status-text">enabled</span></span>\
|
||||
<span class="delete-entry"><span class="delete-entry-text">delete</span></span>\
|
||||
~!:SUSPENDED_TPL~!\
|
||||
<span class="delete-entry do_action_delete_entry"><span class="delete-entry-text do_action_delete_entry">delete</span></span>\
|
||||
</div>\
|
||||
</div>\
|
||||
<div class="row-meta">\
|
||||
|
@ -476,7 +589,7 @@ App.Templates.html = {
|
|||
</div>\
|
||||
<div class="row-details cc">\
|
||||
<div class="names">\
|
||||
<strong class="domain-name primary">~!:DOMAIN~!</strong>\
|
||||
<strong class="domain-name primary do_action_edit">~!:DOMAIN~!</strong>\
|
||||
<span class="alias-title">Alias:</span>\
|
||||
~!:ALIAS~!\
|
||||
</div>\
|
||||
|
@ -551,8 +664,57 @@ App.Templates.html = {
|
|||
</div>']
|
||||
},
|
||||
db: {
|
||||
USER_ITEMS_WRAPPER: ['<div class="db-user-box cc">~!:CONTENT~!</div>'],
|
||||
USER_ITEM: ['<span class="db-user-wrap">\
|
||||
<span class="db-user">~!:NAME~!</span>\
|
||||
</span>\
|
||||
<span class="change-pwd do_action_change_db_user_password">change password</span>'],
|
||||
DIVIDER: ['<div class="db-devider">\
|
||||
<span class="db-devider-title">\
|
||||
<span class="db-devider-outer">\
|
||||
<span class="db-devider-inner">~!:TYPE~!</span>\
|
||||
</span>\
|
||||
</span>\
|
||||
</div>'],
|
||||
ENTRIES_WRAPPER: ['<div class="db-list">~!:content~!</div>'],
|
||||
ENTRY: ['<div class="row first-row db-details-row">\
|
||||
FORM: ['<div id="~!:id~!" class="b-new-entry b-new-entry_db">\
|
||||
<input type="hidden" name="source" class="source" value=\'~!:source~!\'>\
|
||||
<input type="hidden" name="target" class="target" value=\'\'>\
|
||||
<div class="entry-header">~!:title~!</div>\
|
||||
<div class="form-error">\
|
||||
</div>\
|
||||
<div class="form-row cc">\
|
||||
<label for="#" class="field-label">db type:</label>\
|
||||
<select name="TYPE" class="not-styled">~!:TYPE_OPTIONS~!</select>\
|
||||
</div>\
|
||||
<div class="form-row cc">\
|
||||
<label for="#" class="field-label">db name:</label>\
|
||||
<input type="text" class="text-field" name="DB" value="~!:DB~!">\
|
||||
</div>\
|
||||
<div class="db-credentials ">\
|
||||
<div class="form-row cc user">\
|
||||
<label for="#" class="field-label">username</label>\
|
||||
<input type="text" name="USER" class="text-field" value="~!:USER~!">\
|
||||
</div>\
|
||||
<div class="form-row pwd-box cc psw">\
|
||||
<label for="#" class="field-label">password:</label>\
|
||||
<input type="text" name="PASSWORD" class="text-field password" value="~!:PASSWORD~!">\
|
||||
<span class="generate-pwd do_action_generate_pass">Generate</span>\
|
||||
</div>\
|
||||
</div>\
|
||||
<div class="form-row cc">\
|
||||
<label for="#" class="field-label">db host:</label>\
|
||||
<select name="HOST">~!:HOST_OPTIONS~!</select>\
|
||||
</div>\
|
||||
<div class="form-row buttons-row cc">\
|
||||
<input type="submit" value="~!:save_button~!" class="add-entry-btn do_action_save_form">\
|
||||
<span class="cancel-btn do_action_cancel_form">Cancel</span>\
|
||||
<a target="_blank" href="http://vestacp.com/docs/db/" class="help-btn">Help</a>\
|
||||
</div>\
|
||||
</div>'],
|
||||
ENTRY: ['<div class="row ~!:FIRST_ROW_CLASS~! db-details-row">\
|
||||
<input type="hidden" name="source" class="source" value=\'~!:source~!\'>\
|
||||
<input type="hidden" name="target" class="target" value=\'\'>\
|
||||
<div class="row-actions-box cc">\
|
||||
<div class="check-this check-control"></div>\
|
||||
<div class="row-operations">\
|
||||
|
@ -562,7 +724,7 @@ App.Templates.html = {
|
|||
<div class="row-meta">\
|
||||
<div class="ownership">\
|
||||
<span class="prop-box">\
|
||||
<span class="prop-value">Javier Henneman</span>\
|
||||
<span class="prop-value">~!:OWNER~!</span>\
|
||||
</span>\
|
||||
</div>\
|
||||
<div class="entry-created">~!:DATE~!</div>\
|
||||
|
@ -570,36 +732,30 @@ App.Templates.html = {
|
|||
<div class="row-details cc">\
|
||||
<div class="props-main">\
|
||||
<div class="db-name-box">\
|
||||
<span class="db-name">~!:DB_NAME~!</span>\
|
||||
<span class="db-name do_action_edit">~!:DB~!</span>\
|
||||
</div>\
|
||||
</div>\
|
||||
<div class="props-additional">\
|
||||
<div class="db-user-box cc">\
|
||||
<span class="db-user-wrap">\
|
||||
<span class="db-user">~!:USER~!</span>\
|
||||
<span class="db-user-wrap backup-db do_action_open_inner_popup">\
|
||||
Users: ~!:USERS~!\
|
||||
</span>\
|
||||
<span class="change-pwd">change password</span> \
|
||||
<textarea class="inner-popup-html hidden">~!:USER_LIST~!</textarea>\
|
||||
</div>\
|
||||
<div class="db-user-box cc">\
|
||||
<span class="db-user-wrap">\
|
||||
<span class="db-user">socialmediaexaminer (read only)</span>\
|
||||
</span>\
|
||||
<span class="change-pwd">change password</span> \
|
||||
</div>\
|
||||
<span class="add-db-user">Add user</span>\
|
||||
<span class="add-db-user do_action_add_db_user">Add user</span>\
|
||||
</div>\
|
||||
<div class="props-ext">\
|
||||
<span class="backup-db">backup</span>\
|
||||
<span class="backup-db do_action_backup_db">backup</span>\
|
||||
<!-- disk usage block -->\
|
||||
<div class="b-usage-box disk-usage cc">\
|
||||
<div class="usage-box">\
|
||||
<div class="value-box">\
|
||||
<span class="value">~!:U_DISK~!</span>\
|
||||
<span class="value">~!:U_DISK~! Mb</span>\
|
||||
<div class="graph middle">\
|
||||
<span style="width:55%;" class="bar"></span>\
|
||||
<span style="width:~!:U_DISK_PERCENTAGE~!%;" class="bar"></span>\
|
||||
</div>\
|
||||
</div>\
|
||||
<div class="max-size">~!:DISK~! <span class="units">Mb</span></div>\
|
||||
<div class="max-size">~!:DISK~! <span class="units">~!:DISK_MEASURE~!</span></div>\
|
||||
</div>\
|
||||
</div><!-- // disk usage block -->\
|
||||
</div>\
|
||||
|
@ -612,8 +768,8 @@ App.Templates.html = {
|
|||
<div class="row-actions-box cc">\
|
||||
<div class="check-this check-control"></div>\
|
||||
<div class="row-operations">\
|
||||
<span class="ip-status-info ip-enabled-status"><span class="ip-status-text">enabled</span></span>\
|
||||
<span class="delete-entry"><span class="delete-entry-text">delete</span></span>\
|
||||
~!:SUSPENDED_TPL~!\
|
||||
<span class="delete-entry do_action_delete_entry"><span class="delete-entry-text do_action_delete_entry">delete</span></span>\
|
||||
</div>\
|
||||
</div>\
|
||||
<div class="row-meta">\
|
||||
|
@ -643,7 +799,7 @@ App.Templates.html = {
|
|||
</span>\
|
||||
</div>\
|
||||
<div class="cron-command-box">\
|
||||
<strong class="cron-command-line">~!:CMD~!</strong>\
|
||||
<strong class="cron-command-line do_action_edit">~!:CMD~!</strong>\
|
||||
</div>\
|
||||
<div class="cron-reported-to">\
|
||||
<span class="prop-box cron-report-box">\
|
||||
|
|
|
@ -1,12 +1,14 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Ajax Handler
|
||||
*
|
||||
* @author vesta, http://vestacp.com/
|
||||
* @author Dmitry Malishev <dima.malishev@gmail.com>
|
||||
* @author Dmitry Naumov-Socolov <naumov.socolov@gmail.com>
|
||||
* @copyright vesta 2010-2011
|
||||
*/
|
||||
class AjaxHandler
|
||||
{
|
||||
class AjaxHandler {
|
||||
|
||||
static public $instance = null;
|
||||
|
||||
|
@ -28,14 +30,12 @@ class AjaxHandler
|
|||
* return $this->reply($result, $data, $msg, $extra);
|
||||
*
|
||||
* @param Request $request
|
||||
* @return mixed
|
||||
* @return string
|
||||
*/
|
||||
function dispatch($request)
|
||||
{
|
||||
function dispatch($request) {
|
||||
$method = Request::parseAjaxMethod($request);
|
||||
$inc_file = V_ROOT_DIR . 'api' . DIRECTORY_SEPARATOR . $method['namespace'] . '.class.php';
|
||||
if (!is_readable($inc_file))
|
||||
{
|
||||
if (!is_readable($inc_file)) {
|
||||
throw new SystemException(Message::INVALID_METHOD);
|
||||
}
|
||||
|
||||
|
@ -44,8 +44,7 @@ class AjaxHandler
|
|||
$space = new $method['namespace'];
|
||||
$method = $method['function'] . 'Execute';
|
||||
|
||||
if (!method_exists($space, $method))
|
||||
{
|
||||
if (!method_exists($space, $method)) {
|
||||
throw new SystemException(Message::INVALID_METHOD);
|
||||
}
|
||||
|
||||
|
@ -53,15 +52,9 @@ class AjaxHandler
|
|||
}
|
||||
|
||||
/**
|
||||
* Prepare the result of method execution into ajax-readable format
|
||||
*
|
||||
* @param boolean $result - result of method execution
|
||||
* @param array $data - data to be replied
|
||||
* @param string $message - replied message
|
||||
* @param array $extra - extra data
|
||||
* Prepare response for ajax
|
||||
*/
|
||||
function reply($result, $data, $message = '', $extra = array())
|
||||
{
|
||||
function reply($result, $data, $message = '', $extra = array()) {
|
||||
return json_encode(array('result' => $result,
|
||||
'data' => $data,
|
||||
'message' => $message,
|
||||
|
@ -70,12 +63,7 @@ class AjaxHandler
|
|||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO: delete this method
|
||||
* @deprecated
|
||||
*/
|
||||
static function makeReply($reply)
|
||||
{
|
||||
static function makeReply($reply) {
|
||||
print $reply;
|
||||
}
|
||||
|
||||
|
@ -83,43 +71,24 @@ class AjaxHandler
|
|||
// Error handlers
|
||||
//
|
||||
|
||||
/**
|
||||
* Generate general error
|
||||
* @param Exception $error
|
||||
*/
|
||||
static function generalError($error)
|
||||
{
|
||||
static function generalError($error) {
|
||||
self::renderGlobalError(Message::ERROR, Message::GENERAL_ERROR, $error);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate protection error
|
||||
* @param Exception $error
|
||||
*/
|
||||
static function protectionError($error)
|
||||
{
|
||||
static function protectionError($error) {
|
||||
self::renderGlobalError(Message::ERROR, Message::PROTECTION_ERROR, $error);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate system error
|
||||
* @param Exception $error
|
||||
*/
|
||||
static function systemError($error)
|
||||
{
|
||||
static function systemError($error) {
|
||||
self::renderGlobalError(Message::ERROR, Message::SYSTEM_ERROR, $error);
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepare and render the error
|
||||
* @param Exception $error
|
||||
*/
|
||||
static function renderGlobalError($type, $message, $error)
|
||||
{
|
||||
$trace = $error->getTrace();
|
||||
static function renderGlobalError($type, $message, $error) {
|
||||
/*$trace = $error->getTrace();
|
||||
AjaxHandler::makeReply(
|
||||
AjaxHandler::getInstance()->reply(false, $type, $message . ': ' . $error->getMessage(), $trace[0]['file'] . ' / ' . $trace[0]['line'])
|
||||
);
|
||||
);*/
|
||||
print $message;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,32 +1,28 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
/*
|
||||
* CRON
|
||||
*
|
||||
* @author Naumov-Socolov <naumov.socolov@gmail.com>
|
||||
* @author Malishev Dima <dima.malishev@gmail.com>
|
||||
* @author vesta, http://vestacp.com/
|
||||
* @author Dmitry Malishev <dima.malishev@gmail.com>
|
||||
* @author Dmitry Naumov-Socolov <naumov.socolov@gmail.com>
|
||||
* @copyright vesta 2010-2011
|
||||
*/
|
||||
|
||||
class CRON extends AjaxHandler
|
||||
{
|
||||
|
||||
/**
|
||||
* List cron entries
|
||||
* Get CRON entries
|
||||
*
|
||||
* @param Request $request
|
||||
* @return
|
||||
* @return string - Ajax Reply
|
||||
*/
|
||||
public function getListExecute($request)
|
||||
{
|
||||
$_user = 'vesta';
|
||||
$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, Config::get('response_type')));
|
||||
|
||||
foreach ($result['data'] as $id => $record)
|
||||
{
|
||||
foreach ($result['data'] as $id => $record) {
|
||||
$reply[$id] = array(
|
||||
'CMD' => $record['CMD'],
|
||||
'MIN' => $record['MIN'],
|
||||
|
@ -39,8 +35,7 @@ class CRON extends AjaxHandler
|
|||
);
|
||||
}
|
||||
|
||||
if (!$result['status'])
|
||||
{
|
||||
if (!$result['status']) {
|
||||
$this->errors[] = array($result['error_code'] => $result['error_message']);
|
||||
}
|
||||
|
||||
|
@ -48,17 +43,16 @@ class CRON extends AjaxHandler
|
|||
}
|
||||
|
||||
/**
|
||||
* Add cron entry
|
||||
* Add CRON entry
|
||||
*
|
||||
* @param Request $request
|
||||
* @return
|
||||
* @return string - Ajax Reply
|
||||
*/
|
||||
public function addExecute($request)
|
||||
{
|
||||
$r = new Request();
|
||||
$_s = $r->getSpell();
|
||||
$_user = 'vesta';
|
||||
|
||||
$params = array(
|
||||
'USER' => $_user,
|
||||
'MIN' => $_s['MIN'],
|
||||
|
@ -71,20 +65,16 @@ class CRON extends AjaxHandler
|
|||
|
||||
$result = Vesta::execute(Vesta::V_ADD_CRON_JOB, $params);
|
||||
|
||||
if ($_s['REPORTS'])
|
||||
{
|
||||
if ($_s['REPORTS']) {
|
||||
$result = array();
|
||||
$result = Vesta::execute(Vesta::V_ADD_SYS_USER_REPORTS,
|
||||
array('USER' => $_user));
|
||||
if (!$result['status'])
|
||||
{
|
||||
$result = Vesta::execute(Vesta::V_ADD_SYS_USER_REPORTS, array('USER' => $_user));
|
||||
if (!$result['status']) {
|
||||
$this->status = FALSE;
|
||||
$this->errors['REPORTS'] = array($result['error_code'] => $result['error_message']);
|
||||
}
|
||||
}
|
||||
|
||||
if (!$result['status'])
|
||||
{
|
||||
if (!$result['status']) {
|
||||
$this->errors[] = array($result['error_code'] => $result['error_message']);
|
||||
}
|
||||
|
||||
|
@ -92,12 +82,12 @@ class CRON extends AjaxHandler
|
|||
}
|
||||
|
||||
/**
|
||||
* Delete cron entry
|
||||
* Delete CRON entry
|
||||
*
|
||||
* @param Request $request
|
||||
* @return
|
||||
* @return string - Ajax Reply
|
||||
*/
|
||||
function delExecute($request)
|
||||
public function delExecute($request)
|
||||
{
|
||||
$r = new Request();
|
||||
$_s = $r->getSpell();
|
||||
|
@ -107,10 +97,10 @@ class CRON extends AjaxHandler
|
|||
'USER' => $_user,
|
||||
'JOB' => $_s['JOB']
|
||||
);
|
||||
|
||||
$result = Vesta::execute(Vesta::V_DEL_CRON_JOB, $params);
|
||||
|
||||
if (!$result['status'])
|
||||
{
|
||||
if (!$result['status']) {
|
||||
$this->errors[] = array($result['error_code'] => $result['error_message']);
|
||||
}
|
||||
|
||||
|
@ -118,21 +108,19 @@ class CRON extends AjaxHandler
|
|||
}
|
||||
|
||||
/**
|
||||
* Change cron entry
|
||||
* Change CRON entry
|
||||
*
|
||||
* @param Request $request
|
||||
* @return
|
||||
* @return string - Ajax Reply
|
||||
*/
|
||||
function changeExecute($request)
|
||||
public function changeExecute($request)
|
||||
{
|
||||
$r = new Request();
|
||||
$_s = $r->getSpell();
|
||||
$_old = $_s['old'];
|
||||
$_new = $_s['new'];
|
||||
|
||||
$_user = 'vesta';
|
||||
$_JOB = $_new['JOB'];
|
||||
|
||||
$result = array();
|
||||
$params = array(
|
||||
'USER' => $_user,
|
||||
|
@ -147,57 +135,52 @@ class CRON extends AjaxHandler
|
|||
|
||||
$result = Vesta::execute(Vesta::V_CHANGE_CRON_JOB, $params);
|
||||
|
||||
if (!$result['status'])
|
||||
{
|
||||
if (!$result['status']) {
|
||||
$this->errors[] = array($result['error_code'] => $result['error_message']);
|
||||
}
|
||||
|
||||
return $this->reply($result['status'], $result['data']);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Suspend cron entry
|
||||
* Suspend CRON entry
|
||||
*
|
||||
* @param Request $request
|
||||
* @return
|
||||
* @return string - Ajax Reply
|
||||
*/
|
||||
function suspendExecute($request)
|
||||
public function suspendExecute($request)
|
||||
{
|
||||
$r = new Request();
|
||||
$_s = $r->getSpell();
|
||||
|
||||
$_user = 'vesta';
|
||||
$_JOB = $_s['JOB'];
|
||||
|
||||
$params = array(
|
||||
'USER' => $_user,
|
||||
'JOB' => $_JOB
|
||||
);
|
||||
|
||||
$result = Vesta::execute(Vesta::V_SUSPEND_CRON_JOB, $params);
|
||||
if (!$result['status'])
|
||||
{
|
||||
|
||||
if (!$result['status']) {
|
||||
$this->errors[] = array($result['error_code'] => $result['error_message']);
|
||||
}
|
||||
|
||||
return $this->reply($result['status'], $result['data']);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Unsuspend cron entry
|
||||
* Unsuspend CRON entry
|
||||
*
|
||||
* @param Request $request
|
||||
* @return
|
||||
* @return string - Ajax Reply
|
||||
*/
|
||||
function unsuspendExecute($request)
|
||||
public function unsuspendExecute($request)
|
||||
{
|
||||
$r = new Request();
|
||||
$_s = $r->getSpell();
|
||||
|
||||
$_user = 'vesta';
|
||||
$_JOB = $_s['JOB'];
|
||||
|
||||
$params = array(
|
||||
'USER' => $_user,
|
||||
'JOB' => $_JOB
|
||||
|
@ -205,36 +188,33 @@ class CRON extends AjaxHandler
|
|||
|
||||
$result = Vesta::execute(Vesta::V_UNSUSPEND_CRON_JOB, $params);
|
||||
|
||||
if (!$result['status'])
|
||||
{
|
||||
if (!$result['status']) {
|
||||
$this->errors[] = array($result['error_code'] => $result['error_message']);
|
||||
}
|
||||
|
||||
return $this->reply($result['status'], $result['data']);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Batch suspend cron entries
|
||||
* Batch suspend CRON entries
|
||||
*
|
||||
* @param Request $request
|
||||
* @return
|
||||
* @return string - Ajax Reply
|
||||
*/
|
||||
function suspendAllExecute($request)
|
||||
public function suspendAllExecute($request)
|
||||
{
|
||||
$r = new Request();
|
||||
$_s = $r->getSpell();
|
||||
|
||||
$_user = 'vesta';
|
||||
$_JOB = $_s['JOB'];
|
||||
|
||||
$params = array(
|
||||
'USER' => $_user
|
||||
);
|
||||
|
||||
$result = Vesta::execute(Vesta::V_SUSPEND_CRON_JOBS, $params);
|
||||
|
||||
if (!$result['status'])
|
||||
{
|
||||
if (!$result['status']) {
|
||||
$this->errors[] = array($result['error_code'] => $result['error_message']);
|
||||
}
|
||||
|
||||
|
@ -242,26 +222,23 @@ class CRON extends AjaxHandler
|
|||
}
|
||||
|
||||
/**
|
||||
* Batch suspend cron entry
|
||||
* Batch unsuspend CRON entries
|
||||
*
|
||||
* @param Request $request
|
||||
* @return
|
||||
* @return string - Ajax Reply
|
||||
*/
|
||||
function unsuspendAllExecute($request)
|
||||
public function unsuspendAllExecute($request)
|
||||
{
|
||||
$r = new Request();
|
||||
$_s = $r->getSpell();
|
||||
|
||||
$_user = 'vesta';
|
||||
|
||||
$params = array(
|
||||
'USER' => $_user
|
||||
);
|
||||
|
||||
$result = Vesta::execute(Vesta::V_UNSUSPEND_CRON_JOBS, $params);
|
||||
|
||||
if (!$result['status'])
|
||||
{
|
||||
if (!$result['status']) {
|
||||
$this->errors[] = array($result['error_code'] => $result['error_message']);
|
||||
}
|
||||
|
||||
|
|
|
@ -3,19 +3,20 @@
|
|||
/**
|
||||
* DB
|
||||
*
|
||||
* @author Naumov-Socolov <naumov.socolov@gmail.com>
|
||||
* @author Malishev Dima <dima.malishev@gmail.com>
|
||||
* @author vesta, http://vestacp.com/
|
||||
* @copyright vesta 2011
|
||||
* @author Dmitry Malishev <dima.malishev@gmail.com>
|
||||
* @author Dmitry Naumov-Socolov <naumov.socolov@gmail.com>
|
||||
* @copyright vesta 2010-2011
|
||||
*/
|
||||
|
||||
class DB extends AjaxHandler
|
||||
{
|
||||
|
||||
/**
|
||||
* List entries
|
||||
* Get DB entries
|
||||
*
|
||||
* @param Request $request
|
||||
* @return
|
||||
* @return string - Ajax Reply
|
||||
*/
|
||||
public function getListExecute($request)
|
||||
{
|
||||
|
@ -23,32 +24,48 @@ class DB extends AjaxHandler
|
|||
$reply = array();
|
||||
$result = Vesta::execute(Vesta::V_LIST_DB_BASES, array($_user, Config::get('response_type')));
|
||||
|
||||
foreach ($result['data'] as $db => $record)
|
||||
{
|
||||
$reply[$db] = array(
|
||||
foreach ($result['data'] as $db => $record) {
|
||||
$type = $record['TYPE'];
|
||||
if (!isset($reply[$type])) {
|
||||
$reply[$type] = array();
|
||||
}
|
||||
|
||||
$reply[$type][] = array(
|
||||
'DB' => $db,
|
||||
'USER' => $record['USER'],
|
||||
'OWNER' => 'John Travlolta',
|
||||
'USERS' => (array)$record['USER'],
|
||||
'HOST' => $record['HOST'],
|
||||
'TYPE' => $record['TYPE'],
|
||||
'U_DISK' => $record['U_DISK'],
|
||||
'DISK' => 2024,
|
||||
'SUSPEND' => $record['SUSPEND'],
|
||||
'DATE' => date(Config::get('ui_date_format', strtotime($record['DATE'])))
|
||||
);
|
||||
}
|
||||
|
||||
if (!$result['status'])
|
||||
{
|
||||
if (!$result['status']) {
|
||||
$this->errors[] = array($result['error_code'] => $result['error_message']);
|
||||
}
|
||||
|
||||
$reply['postgre'][] = array(
|
||||
'DB' => 'x',
|
||||
'OWNER' => 'John Travlolta',
|
||||
'USERS' => array('E'),
|
||||
'HOST' => 'xxx',
|
||||
'TYPE' => '34',
|
||||
'U_DISK' => '0',
|
||||
'SUSPEND' => 'false',
|
||||
'DATE' => '2011-01-01'
|
||||
);
|
||||
|
||||
return $this->reply($result['status'], $reply);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add entry
|
||||
* Add DB entry
|
||||
*
|
||||
* @param Request $request
|
||||
* @return
|
||||
* @return string - Ajax Reply
|
||||
*/
|
||||
public function addExecute($request)
|
||||
{
|
||||
|
@ -63,15 +80,14 @@ class DB extends AjaxHandler
|
|||
'DB_PASSWORD' => $_s['DB_PASSWORD'],
|
||||
'TYPE' => $_s['TYPE']
|
||||
);
|
||||
if ($_s['HOST'])
|
||||
{
|
||||
|
||||
if ($_s['HOST']) {
|
||||
$params['HOST'] = $_s['HOST'];
|
||||
}
|
||||
|
||||
$result = Vesta::execute(Vesta::V_ADD_DB_BASE, $params);
|
||||
|
||||
if (!$result['status'])
|
||||
{
|
||||
if (!$result['status']) {
|
||||
$this->errors[] = array($result['error_code'] => $result['error_message']);
|
||||
}
|
||||
|
||||
|
@ -79,17 +95,16 @@ class DB extends AjaxHandler
|
|||
}
|
||||
|
||||
/**
|
||||
* Delete entry
|
||||
* Delete DB entry
|
||||
*
|
||||
* @param Request $request
|
||||
* @return
|
||||
* @return string - Ajax Reply
|
||||
*/
|
||||
public function delExecute($request)
|
||||
{
|
||||
$r = new Request();
|
||||
$_s = $r->getSpell();
|
||||
$_user = 'vesta';
|
||||
|
||||
$params = array(
|
||||
'USER' => $_user,
|
||||
'DB' => $_user.'_'.$_s['DB']
|
||||
|
@ -97,8 +112,7 @@ class DB extends AjaxHandler
|
|||
|
||||
$result = Vesta::execute(Vesta::V_DEL_DB_BASE, $params);
|
||||
|
||||
if (!$result['status'])
|
||||
{
|
||||
if (!$result['status']) {
|
||||
$this->errors[] = array($result['error_code'] => $result['error_message']);
|
||||
}
|
||||
|
||||
|
@ -106,18 +120,16 @@ class DB extends AjaxHandler
|
|||
}
|
||||
|
||||
/**
|
||||
* Change password
|
||||
* Change Password
|
||||
*
|
||||
* @param Request $request
|
||||
* @return
|
||||
* @return string - Ajax Reply
|
||||
*/
|
||||
public function changePasswordExecute($request)
|
||||
{
|
||||
$r = new Request();
|
||||
$_s = $r->getSpell();
|
||||
|
||||
$_user = 'vesta';
|
||||
|
||||
$result = array();
|
||||
$params = array(
|
||||
'USER' => $_user,
|
||||
|
@ -127,8 +139,7 @@ class DB extends AjaxHandler
|
|||
|
||||
$result = Vesta::execute(Vesta::V_CHANGE_DB_PASSWORD, $params);
|
||||
|
||||
if (!$result['status'])
|
||||
{
|
||||
if (!$result['status']) {
|
||||
$this->errors[] = array($result['error_code'] => $result['error_message']);
|
||||
}
|
||||
|
||||
|
@ -136,18 +147,16 @@ class DB extends AjaxHandler
|
|||
}
|
||||
|
||||
/**
|
||||
* suspend user
|
||||
* Suspend DB entry
|
||||
*
|
||||
* @param Request $request
|
||||
* @return
|
||||
* @return string - Ajax Reply
|
||||
*/
|
||||
public function suspendExecute($request)
|
||||
{
|
||||
$r = new Request();
|
||||
$_s = $r->getSpell();
|
||||
|
||||
$_user = 'vesta';
|
||||
|
||||
$params = array(
|
||||
'USER' => $_user,
|
||||
'DB' => $_user.'_'.$_s['DB']
|
||||
|
@ -155,8 +164,7 @@ class DB extends AjaxHandler
|
|||
|
||||
$result = Vesta::execute(Vesta::V_SUSPEND_DB_BASE, $params);
|
||||
|
||||
if (!$result['status'])
|
||||
{
|
||||
if (!$result['status']) {
|
||||
$this->errors[] = array($result['error_code'] => $result['error_message']);
|
||||
}
|
||||
|
||||
|
@ -164,27 +172,23 @@ class DB extends AjaxHandler
|
|||
}
|
||||
|
||||
/**
|
||||
* unsuspend entry
|
||||
* Unsuspend DB entry
|
||||
*
|
||||
* @param Request $request
|
||||
* @return
|
||||
* @return string - Ajax Reply
|
||||
*/
|
||||
public function unsuspendExecute($request)
|
||||
{
|
||||
$r = new Request();
|
||||
$_s = $r->getSpell();
|
||||
|
||||
$_user = 'vesta';
|
||||
|
||||
$params = array(
|
||||
'USER' => $_user,
|
||||
'DB' => $_user.'_'.$_s['DB']
|
||||
);
|
||||
|
||||
$result = Vesta::execute(Vesta::V_UNSUSPEND_DB_BASE, $params);
|
||||
|
||||
if (!$result['status'])
|
||||
{
|
||||
if (!$result['status']) {
|
||||
$this->errors[] = array($result['error_code'] => $result['error_message']);
|
||||
}
|
||||
|
||||
|
@ -192,16 +196,15 @@ class DB extends AjaxHandler
|
|||
}
|
||||
|
||||
/**
|
||||
* Batch suspend entries
|
||||
* Batch Suspend DB entries
|
||||
*
|
||||
* @param Request $request
|
||||
* @return
|
||||
* @return string - Ajax Reply
|
||||
*/
|
||||
public function suspendAllExecute($request)
|
||||
{
|
||||
$r = new Request();
|
||||
$_s = $r->getSpell();
|
||||
|
||||
$_user = 'vesta';
|
||||
$_JOB = $_s['JOB'];
|
||||
|
||||
|
@ -211,8 +214,7 @@ class DB extends AjaxHandler
|
|||
|
||||
$result = Vesta::execute(Vesta::V_SUSPEND_DB_BASES, $params);
|
||||
|
||||
if (!$result['status'])
|
||||
{
|
||||
if (!$result['status']) {
|
||||
$this->errors[] = array($result['error_code'] => $result['error_message']);
|
||||
}
|
||||
|
||||
|
@ -220,26 +222,22 @@ class DB extends AjaxHandler
|
|||
}
|
||||
|
||||
/**
|
||||
* Batch unsuspend entries
|
||||
* Batch unsuspend DB entries
|
||||
*
|
||||
* @param Request $request
|
||||
* @return
|
||||
* @return string - Ajax Reply
|
||||
*/
|
||||
public function unsuspendAllExecute($request)
|
||||
{
|
||||
$r = new Request();
|
||||
$_s = $r->getSpell();
|
||||
|
||||
$_user = 'vesta';
|
||||
|
||||
$params = array(
|
||||
'USER' => $_user
|
||||
);
|
||||
|
||||
$result = Vesta::execute(Vesta::V_UNSUSPEND_DB_BASES, $params);
|
||||
|
||||
if (!$result['status'])
|
||||
{
|
||||
if (!$result['status']) {
|
||||
$this->errors[] = array($result['error_code'] => $result['error_message']);
|
||||
}
|
||||
|
||||
|
|
|
@ -3,27 +3,29 @@
|
|||
/**
|
||||
* DNS
|
||||
*
|
||||
* @author Naumov-Socolov <naumov.socolov@gmail.com>
|
||||
* @author Malishev Dima <dima.malishev@gmail.com>
|
||||
* TODO: Too many "if" statements. Code should be refactored in order to not use a lot of "if" conditions
|
||||
*
|
||||
* @author vesta, http://vestacp.com/
|
||||
* @author Dmitry Malishev <dima.malishev@gmail.com>
|
||||
* @author Dmitry Naumov-Socolov <naumov.socolov@gmail.com>
|
||||
* @copyright vesta 2010-2011
|
||||
*/
|
||||
|
||||
class DNS extends AjaxHandler
|
||||
{
|
||||
|
||||
/**
|
||||
* list entries
|
||||
* Get DNS entries
|
||||
*
|
||||
* @param Request $request
|
||||
* @return
|
||||
* @return string - Ajax Reply
|
||||
*/
|
||||
public function getListExecute($request) {
|
||||
public function getListExecute($request)
|
||||
{
|
||||
$_user = 'vesta';
|
||||
$reply = array();
|
||||
|
||||
$result = Vesta::execute(Vesta::V_LIST_DNS_DOMAINS, array($_user, Config::get('response_type')));
|
||||
foreach ($result['data'] as $dns_domain => $details)
|
||||
{
|
||||
foreach ($result['data'] as $dns_domain => $details) {
|
||||
$reply[] = array(
|
||||
'DNS_DOMAIN' => $dns_domain,
|
||||
'IP' => $details['IP'],
|
||||
|
@ -35,8 +37,8 @@ class DNS extends AjaxHandler
|
|||
'DATE' => date(Config::get('ui_date_format', strtotime($details['DATE'])))
|
||||
);
|
||||
}
|
||||
if (!$result['status'])
|
||||
{
|
||||
|
||||
if (!$result['status']) {
|
||||
$this->errors[] = array($result['error_code'] => $result['error_message']);
|
||||
}
|
||||
|
||||
|
@ -44,22 +46,20 @@ class DNS extends AjaxHandler
|
|||
}
|
||||
|
||||
/**
|
||||
* List records of entries
|
||||
* Get DNS records
|
||||
*
|
||||
* @param Request $request
|
||||
* @return
|
||||
* @return string - Ajax Reply
|
||||
*/
|
||||
public function getListRecordsExecute($request)
|
||||
{
|
||||
$r = new Request();
|
||||
$_s = $r->getSpell();
|
||||
$_user = 'vesta';
|
||||
|
||||
$reply = array();
|
||||
|
||||
$result = Vesta::execute(Vesta::V_LIST_DNS_DOMAIN_RECORDS, array($_user, $_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(
|
||||
'RECORD_ID' => $record_id,
|
||||
'RECORD' => $details['RECORD'],
|
||||
|
@ -70,8 +70,7 @@ class DNS extends AjaxHandler
|
|||
);
|
||||
}
|
||||
|
||||
if (!$result['status'])
|
||||
{
|
||||
if (!$result['status']) {
|
||||
$this->errors[] = array($result['error_code'] => $result['error_message']);
|
||||
}
|
||||
|
||||
|
@ -79,40 +78,46 @@ class DNS extends AjaxHandler
|
|||
}
|
||||
|
||||
/**
|
||||
* Add entry
|
||||
* Add DB entry
|
||||
*
|
||||
* 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
|
||||
*
|
||||
* @param Request $request
|
||||
* @return
|
||||
* @return string - Ajax Reply
|
||||
*/
|
||||
public function addExecute($_spell = false)
|
||||
{
|
||||
$r = new Request();
|
||||
if ($_spell)
|
||||
{
|
||||
if ($_spell) {
|
||||
$_s = $_spell;
|
||||
}
|
||||
else
|
||||
{
|
||||
else {
|
||||
$_s = $r->getSpell();
|
||||
}
|
||||
|
||||
$_user = 'vesta';
|
||||
$params = array(
|
||||
'USER' => $_user, // TODO: examine if OWNER ???
|
||||
'USER' => $_user, /// OWNER ???
|
||||
'DNS_DOMAIN' => $_s['DNS_DOMAIN'],
|
||||
'IP' => $_s['IP']
|
||||
);
|
||||
($_s['TPL']) ? $params['TPL'] = $_s['TPL'] : -1;
|
||||
($_s['EXP']) ? $params['EXP'] = $_s['EXP'] : -1;
|
||||
($_s['SOA']) ? $params['SOA'] = $_s['SOA'] : -1;
|
||||
($_s['TTL']) ? $params['TTL'] = $_s['TTL'] : -1;
|
||||
// TODO: rewrite this block. Get away from if/if/if/if
|
||||
if ($_s['TPL']) {
|
||||
$params['TPL'] = $_s['TPL'];
|
||||
}
|
||||
if ($_s['EXP']) {
|
||||
$params['EXP'] = $_s['EXP'];
|
||||
}
|
||||
if ($_s['SOA']) {
|
||||
$params['SOA'] = $_s['SOA'];
|
||||
}
|
||||
if ($_s['TTL']) {
|
||||
$params['TTL'] = $_s['TTL'];
|
||||
}
|
||||
|
||||
$result = Vesta::execute(Vesta::V_ADD_DNS_DOMAIN, $params);
|
||||
if (!$result['status'])
|
||||
{
|
||||
if (!$result['status']) {
|
||||
$this->errors[] = array($result['error_code'] => $result['error_message']);
|
||||
}
|
||||
|
||||
|
@ -120,10 +125,13 @@ class DNS extends AjaxHandler
|
|||
}
|
||||
|
||||
/**
|
||||
* Add record
|
||||
* Add DNS record
|
||||
*
|
||||
* v_add_dns_domain_record user domain record type value [id]
|
||||
* http://95.163.16.160:8083/dispatch.php?jedi_method=DNS.addRecord&USER=vesta&DOMAIN=dev.vestacp.com&RECORD=ftp&TYPE=a&VALUE=87.248.190.222
|
||||
*
|
||||
* @param Request $request
|
||||
* @return
|
||||
* @return string - Ajax Reply
|
||||
*/
|
||||
public function addRecordExecute($request)
|
||||
{
|
||||
|
@ -132,7 +140,7 @@ class DNS extends AjaxHandler
|
|||
$_user = 'vesta';
|
||||
|
||||
$params = array(
|
||||
'USER' => $_s['USER'], // TODO: find out if it's OWNER ???
|
||||
'USER' => $_s['USER'], /// OWNER ???
|
||||
'DOMAIN' => $_s['DOMAIN'],
|
||||
'RECORD' => $_s['RECORD'],
|
||||
'RECORD_TYPE' => $_s['TYPE'],
|
||||
|
@ -142,73 +150,71 @@ class DNS extends AjaxHandler
|
|||
|
||||
$result = Vesta::execute(Vesta::V_ADD_DNS_DOMAIN_RECORD, $params);
|
||||
|
||||
if (!$result['status'])
|
||||
{
|
||||
if (!$result['status']) {
|
||||
$this->errors[] = array($result['error_code'] => $result['error_message']);
|
||||
}
|
||||
|
||||
return $this->reply($result['status'], $result['data']);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Delete entry
|
||||
* Delete DNS entry
|
||||
*
|
||||
* @param mixed $_spell
|
||||
* @return
|
||||
* v_del_dns_domain user domain
|
||||
* http://95.163.16.160:8083/dispatch.php?jedi_method=DNS.del&USER=vesta&DOMAIN=dev.vestacp.com
|
||||
*
|
||||
* @param Request $request
|
||||
* @return string - Ajax Reply
|
||||
*/
|
||||
public function delExecute($_spell = false)
|
||||
{
|
||||
$r = new Request();
|
||||
if ($_spell)
|
||||
{
|
||||
if ($_spell) {
|
||||
$_s = $_spell;
|
||||
}
|
||||
else
|
||||
{
|
||||
else {
|
||||
$_s = $r->getSpell();
|
||||
}
|
||||
|
||||
$_user = 'vesta';
|
||||
$params = array(
|
||||
'USER' => $_user, // TODO: find out -> OWNER ???
|
||||
'USER' => $_user, /// OWNER ???
|
||||
'DOMAIN' => $_s['DNS_DOMAIN'],
|
||||
);
|
||||
|
||||
$result = Vesta::execute(Vesta::V_DEL_DNS_DOMAIN, $params);
|
||||
|
||||
if (!$result['status'])
|
||||
{
|
||||
if (!$result['status']) {
|
||||
$this->errors[] = array($result['error_code'] => $result['error_message']);
|
||||
}
|
||||
|
||||
return $this->reply($result['status'], $result['data']);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Delete record
|
||||
* Add DNS record
|
||||
*
|
||||
* v_del_dns_domain_record user domain id
|
||||
* http://95.163.16.160:8083/dispatch.php?jedi_method=DNS.delRecord&USER=vesta&DOMAIN=dev.vestacp.com&RECORD_ID=9
|
||||
*
|
||||
* @param Request $request
|
||||
* @return
|
||||
* @return string - Ajax Reply
|
||||
*/
|
||||
function delRecordExecute($request)
|
||||
public function delRecordExecute($request)
|
||||
{
|
||||
$r = new Request();
|
||||
$_s = $r->getSpell();
|
||||
$_user = 'vesta';
|
||||
|
||||
$params = array(
|
||||
'USER' => $_user, // TODO: find out if -> OWNER ???
|
||||
'USER' => $_user, // TODO: OWNER ???
|
||||
'DOMAIN' => $_s['DOMAIN'],
|
||||
'RECORD_ID' => $_s['RECORD_ID']
|
||||
);
|
||||
|
||||
$result = Vesta::execute(Vesta::V_DEL_DNS_DOMAIN_RECORD, $params);
|
||||
|
||||
if (!$result['status'])
|
||||
{
|
||||
if (!$result['status']) {
|
||||
$this->errors[] = array($result['error_code'] => $result['error_message']);
|
||||
}
|
||||
|
||||
|
@ -216,10 +222,14 @@ class DNS extends AjaxHandler
|
|||
}
|
||||
|
||||
/**
|
||||
* Change entry
|
||||
* Change DNS entry
|
||||
*
|
||||
* TODO: get away from multiple "if" statements
|
||||
*
|
||||
* DNS.change&spell={"old":{"DNS_DOMAIN": "dev.vestacp.com","IP": "95.163.16.160","TPL": "default","TTL": "3377","EXP": "12-12-12","SOA": "ns2.vestacp.com"},"new":{"DNS_DOMAIN": "dev.vestacp.com","IP": "95.163.16.160","TPL": "default","TTL": "3600","EXP": "02-02-12","SOA": "ns1.vestacp.com"}}
|
||||
*
|
||||
* @param Request $request
|
||||
* @return
|
||||
* @return string - Ajax Reply
|
||||
*/
|
||||
public function changeExecute($request)
|
||||
{
|
||||
|
@ -227,69 +237,57 @@ class DNS extends AjaxHandler
|
|||
$_s = $r->getSpell();
|
||||
$_old = $_s['old'];
|
||||
$_new = $_s['new'];
|
||||
|
||||
$_user = 'vesta';
|
||||
|
||||
$_DNS_DOMAIN = $_new['DNS_DOMAIN'];
|
||||
|
||||
|
||||
if ($_old['IP'] != $_new['IP'])
|
||||
{
|
||||
if ($_old['IP'] != $_new['IP']) {
|
||||
$result = array();
|
||||
|
||||
$result = Vesta::execute(Vesta::V_CHANGE_DNS_DOMAIN_IP, array('USER' => $_user, 'DNS_DOMAIN' => $_DNS_DOMAIN, 'IP' => $_new['IP']));
|
||||
if(!$result['status'])
|
||||
{
|
||||
if (!$result['status']) {
|
||||
$this->status = FALSE;
|
||||
$this->errors['IP_ADDRESS'] = array($result['error_code'] => $result['error_message']);
|
||||
}
|
||||
}
|
||||
|
||||
if ($_old['TPL'] != $_new['TPL'])
|
||||
{
|
||||
if ($_old['TPL'] != $_new['TPL']) {
|
||||
$result = array();
|
||||
$result = Vesta::execute(Vesta::V_CHANGE_DNS_DOMAIN_TPL, array('USER' => $_user, 'DNS_DOMAIN' => $_DNS_DOMAIN, 'IP' => $_new['TPL']));
|
||||
if(!$result['status'])
|
||||
{
|
||||
if (!$result['status']) {
|
||||
$this->status = FALSE;
|
||||
$this->errors['TPL'] = array($result['error_code'] => $result['error_message']);
|
||||
}
|
||||
}
|
||||
|
||||
if ($_old['TTL'] != $_new['TTL'])
|
||||
{
|
||||
if ($_old['TTL'] != $_new['TTL']) {
|
||||
$result = array();
|
||||
$result = Vesta::execute(Vesta::V_CHANGE_DNS_DOMAIN_TTL, array('USER' => $_user, 'DNS_DOMAIN' => $_DNS_DOMAIN, 'IP' => $_new['TTL']));
|
||||
if(!$result['status'])
|
||||
{
|
||||
if (!$result['status']) {
|
||||
$this->status = FALSE;
|
||||
$this->errors['TTL'] = array($result['error_code'] => $result['error_message']);
|
||||
}
|
||||
}
|
||||
|
||||
if ($_old['EXP'] != $_new['EXP'])
|
||||
{
|
||||
if ($_old['EXP'] != $_new['EXP']) {
|
||||
$result = array();
|
||||
$result = Vesta::execute(Vesta::V_CHANGE_DNS_DOMAIN_EXP, array('USER' => $_user, 'DNS_DOMAIN' => $_DNS_DOMAIN, 'IP' => $_new['EXP']));
|
||||
if (!$result['status'])
|
||||
{
|
||||
if (!$result['status']) {
|
||||
$this->status = FALSE;
|
||||
$this->errors['EXP'] = array($result['error_code'] => $result['error_message']);
|
||||
}
|
||||
}
|
||||
|
||||
if ($_old['SOA'] != $_new['SOA'])
|
||||
{
|
||||
if ($_old['SOA'] != $_new['SOA']) {
|
||||
$result = array();
|
||||
$result = Vesta::execute(Vesta::V_CHANGE_DNS_DOMAIN_SOA, array('USER' => $_user, 'DNS_DOMAIN' => $_new['DNS_DOMAIN'], 'IP' => $_new['SOA']));
|
||||
if (!$result['status'])
|
||||
{
|
||||
if (!$result['status']) {
|
||||
$this->status = FALSE;
|
||||
$this->errors['SOA'] = array($result['error_code'] => $result['error_message']);
|
||||
}
|
||||
}
|
||||
|
||||
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_TPL, array('USER' => $_user, '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']));
|
||||
|
@ -301,10 +299,10 @@ class DNS extends AjaxHandler
|
|||
}
|
||||
|
||||
/**
|
||||
* Change record
|
||||
* Change DNS record
|
||||
*
|
||||
* @param Request $request
|
||||
* @return
|
||||
* @return string - Ajax Reply
|
||||
*/
|
||||
public function changeRecordsExecute($request)
|
||||
{
|
||||
|
@ -315,30 +313,26 @@ class DNS extends AjaxHandler
|
|||
$_user = 'vesta';
|
||||
$_DNS_DOMAIN = $_s['DNS_DOMAIN'];
|
||||
|
||||
foreach ($_new as $record_id => $record_data)
|
||||
{
|
||||
foreach ($_new as $record_id => $record_data) {
|
||||
// checking if record existed - update
|
||||
if(is_array($_old[$record_id]))
|
||||
{
|
||||
// TODO: Remove this. is it necessary??!
|
||||
echo '<br> updating'.$record_id;
|
||||
|
||||
$result = Vesta::execute(Vesta::V_CHANGE_DNS_DOMAIN_RECORD, array('USER' => $_user, 'DNS_DOMAIN' => $_DNS_DOMAIN, 'ID' => $record_id, 'RECORD' => $record_data['RECORD'], 'TYPE' => $record_data['RECORD_TYPE'], 'VALUE' => $record_data['RECORD_VALUE']));
|
||||
if(!$result['status'])
|
||||
{
|
||||
if (is_array($_old[$record_id])) {
|
||||
$result = Vesta::execute(Vesta::V_CHANGE_DNS_DOMAIN_RECORD,
|
||||
array(
|
||||
'USER' => $_user,
|
||||
'DNS_DOMAIN' => $_DNS_DOMAIN,
|
||||
'ID' => $record_id,
|
||||
'RECORD' => $record_data['RECORD'],
|
||||
'TYPE' => $record_data['RECORD_TYPE'],
|
||||
'VALUE' => $record_data['RECORD_VALUE']
|
||||
));
|
||||
if (!$result['status']) {
|
||||
$this->status = FALSE;
|
||||
$this->errors[$record_id] = array($result['error_code'] => $result['error_message']);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// record is new - add
|
||||
// TODO: Remove this. is it necessary??!
|
||||
echo '<br> adding'.$record_id;
|
||||
|
||||
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));
|
||||
if(!$result['status'])
|
||||
{
|
||||
if (!$result['status']) {
|
||||
$this->status = FALSE;
|
||||
$this->errors[$record_id] = array($result['error_code'] => $result['error_message']);
|
||||
}
|
||||
|
@ -348,13 +342,16 @@ class DNS extends AjaxHandler
|
|||
}
|
||||
|
||||
// in $_old have remained only record that do not present in new - so they have to be deleted
|
||||
foreach ($_old as $record_id => $record_data)
|
||||
{
|
||||
echo '<br> deleting'.$record_id;
|
||||
foreach ($_old as $record_id => $record_data) {
|
||||
/*
|
||||
$result = Vesta::execute(Vesta::V_DEL_DNS_DOMAIN_RECORD, array('USER' => $_user, 'DNS_DOMAIN' => $_DNS_DOMAIN, 'ID' => $record_id,));
|
||||
if (!$result['status']) {
|
||||
$this->status = FALSE;
|
||||
$this->errors[$record_id] = array($result['error_code'] => $result['error_message']);
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
return $this->reply($this->status, '');
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -2,34 +2,34 @@
|
|||
/**
|
||||
* IP
|
||||
*
|
||||
* @author Naumov-Socolov <naumov.socolov@gmail.com>
|
||||
* @author Malishev Dima <dima.malishev@gmail.com>
|
||||
* @author vesta, http://vestacp.com/
|
||||
* @author Dmitry Malishev <dima.malishev@gmail.com>
|
||||
* @author Dmitry Naumov-Socolov <naumov.socolov@gmail.com>
|
||||
* @copyright vesta 2010-2011
|
||||
*/
|
||||
|
||||
class IP extends AjaxHandler
|
||||
{
|
||||
|
||||
/**
|
||||
* List entries
|
||||
* Get IP entries
|
||||
*
|
||||
* @param Request $request
|
||||
* @return
|
||||
* @return string - Ajax Reply
|
||||
*/
|
||||
public function getListExecute($request)
|
||||
{
|
||||
$reply = array();
|
||||
|
||||
$result = Vesta::execute(Vesta::V_LIST_SYS_IPS, array(Config::get('response_type')));
|
||||
foreach ($result['data'] as $ip => $details)
|
||||
{
|
||||
$reply[] = array_merge(array(
|
||||
foreach ($result['data'] as $ip => $details) {
|
||||
$reply[] = array_merge(
|
||||
array(
|
||||
'IP_ADDRESS' => $ip,
|
||||
'DATE' => date(Config::get('ui_date_format', strtotime($details['DATE'])))
|
||||
), $details);
|
||||
}
|
||||
|
||||
if (!$result['status'])
|
||||
{
|
||||
if (!$result['status']) {
|
||||
$this->errors[] = array($result['error_code'] => $result['error_message']);
|
||||
}
|
||||
|
||||
|
@ -37,26 +37,24 @@ class IP extends AjaxHandler
|
|||
}
|
||||
|
||||
/**
|
||||
* List user ips entries
|
||||
* Get user's IPs
|
||||
*
|
||||
* @param Request $request
|
||||
* @return
|
||||
* @return string - Ajax Reply
|
||||
*/
|
||||
public function getListUserIpsExecute($request)
|
||||
{
|
||||
$reply = array();
|
||||
|
||||
$result = Vesta::execute(Vesta::V_LIST_SYS_IPS, array(Config::get('response_type')));
|
||||
foreach ($result['data'] as $ip => $details)
|
||||
{
|
||||
$reply[] = array_merge(array(
|
||||
foreach ($result['data'] as $ip => $details) {
|
||||
$reply[] = array_merge(
|
||||
array(
|
||||
'IP_ADDRESS' => $ip,
|
||||
'DATE' => date(Config::get('ui_date_format', strtotime($details['DATE'])))
|
||||
), $details);
|
||||
}
|
||||
|
||||
if (!$result['status'])
|
||||
{
|
||||
if (!$result['status']) {
|
||||
$this->errors[] = array($result['error_code'] => $result['error_message']);
|
||||
}
|
||||
|
||||
|
@ -64,10 +62,10 @@ class IP extends AjaxHandler
|
|||
}
|
||||
|
||||
/**
|
||||
* Add entry
|
||||
* Add IP entry
|
||||
*
|
||||
* @param Request $request
|
||||
* @return
|
||||
* @return string - Ajax Reply
|
||||
*/
|
||||
public function addExecute($request)
|
||||
{
|
||||
|
@ -86,9 +84,7 @@ class IP extends AjaxHandler
|
|||
|
||||
$result = Vesta::execute(Vesta::V_ADD_SYS_IP, $params);
|
||||
|
||||
|
||||
if (!$result['status'])
|
||||
{
|
||||
if (!$result['status']) {
|
||||
$this->errors[] = array($result['error_code'] => $result['error_message']);
|
||||
}
|
||||
|
||||
|
@ -96,25 +92,23 @@ class IP extends AjaxHandler
|
|||
}
|
||||
|
||||
/**
|
||||
* Delete entry
|
||||
* Delete IP entry
|
||||
*
|
||||
* @param Request $request
|
||||
* @return
|
||||
* @return string - Ajax Reply
|
||||
*/
|
||||
public function delExecute($request)
|
||||
{
|
||||
$r = new Request();
|
||||
$_s = $r->getSpell();
|
||||
$_user = 'vesta';
|
||||
|
||||
$params = array(
|
||||
'IP_ADDRESS' => $_s['IP_ADDRESS']
|
||||
);
|
||||
|
||||
$result = Vesta::execute(Vesta::V_DEL_SYS_IP, $params);
|
||||
|
||||
if (!$result['status'])
|
||||
{
|
||||
if (!$result['status']) {
|
||||
$this->errors[] = array($result['error_code'] => $result['error_message']);
|
||||
}
|
||||
|
||||
|
@ -122,10 +116,10 @@ class IP extends AjaxHandler
|
|||
}
|
||||
|
||||
/**
|
||||
* Change entry
|
||||
* Change IP entry
|
||||
*
|
||||
* @param Request $request
|
||||
* @return
|
||||
* @return string - Ajax Reply
|
||||
*/
|
||||
public function changeExecute($request)
|
||||
{
|
||||
|
@ -133,45 +127,36 @@ class IP extends AjaxHandler
|
|||
$_s = $r->getSpell();
|
||||
$_old = $_s['old'];
|
||||
$_new = $_s['new'];
|
||||
|
||||
$_user = 'vesta';
|
||||
|
||||
if ($_old['OWNER'] != $_new['OWNER'])
|
||||
{
|
||||
if ($_old['OWNER'] != $_new['OWNER']) {
|
||||
$result = array();
|
||||
$result = Vesta::execute(Vesta::V_CHANGE_SYS_IP_OWNER, array('OWNER' => $_new['OWNER'], 'IP' => $_new['IP_ADDRESS']));
|
||||
if(!$result['status'])
|
||||
{
|
||||
if (!$result['status']) {
|
||||
$this->status = FALSE;
|
||||
$this->errors['OWNER'] = array($result['error_code'] => $result['error_message']);
|
||||
}
|
||||
}
|
||||
|
||||
if ($_old['NAME'] != $_new['NAME'])
|
||||
{
|
||||
if ($_old['NAME'] != $_new['NAME']) {
|
||||
$result = array();
|
||||
$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->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 = Vesta::execute(Vesta::V_CHANGE_SYS_IP_STATUS, array('IP' => $_new['IP_ADDRESS'], 'IP_STATUS' => $_new['IP_STATUS']));
|
||||
if (!$result['status'])
|
||||
{
|
||||
if (!$result['status']) {
|
||||
$this->status = FALSE;
|
||||
$this->errors['IP_STATUS'] = array($result['error_code'] => $result['error_message']);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (!$result['status'])
|
||||
{
|
||||
if (!$result['status']) {
|
||||
$this->errors[] = array($result['error_code'] => $result['error_message']);
|
||||
}
|
||||
|
||||
|
@ -179,24 +164,21 @@ class IP extends AjaxHandler
|
|||
}
|
||||
|
||||
/**
|
||||
* Get sys interfaces
|
||||
* Get Sys interfaces
|
||||
*
|
||||
* @param Request $request
|
||||
* @return
|
||||
* @return string - Ajax Reply
|
||||
*/
|
||||
public function getSysInterfacesExecute($request)
|
||||
{
|
||||
$reply = array();
|
||||
|
||||
$result = Vesta::execute(Vesta::V_LIST_SYS_INTERFACES, array(Config::get('response_type')));
|
||||
|
||||
foreach ($result['data'] as $iface)
|
||||
{
|
||||
foreach ($result['data'] as $iface) {
|
||||
$reply[$iface] = $iface;
|
||||
}
|
||||
|
||||
if (!$result['status'])
|
||||
{
|
||||
if (!$result['status']) {
|
||||
$this->errors[] = array($result['error_code'] => $result['error_message']);
|
||||
}
|
||||
|
||||
|
|
|
@ -9,19 +9,19 @@
|
|||
* - methods, used for ajax executions must be postfixed with execute keyword
|
||||
* Eg.: getDnsInformationExecute()
|
||||
*
|
||||
* @author Naumov-Socolov <naumov.socolov@gmail.com>
|
||||
* @author Malishev Dima <dima.malishev@gmail.com>
|
||||
* @author vesta, http://vestacp.com/
|
||||
* @author Dmitry Malishev <dima.malishev@gmail.com>
|
||||
* @author Dmitry Naumov-Socolov <naumov.socolov@gmail.com>
|
||||
* @copyright vesta 2010-2011
|
||||
*/
|
||||
class MAIN extends AjaxHandler
|
||||
{
|
||||
|
||||
/**
|
||||
* Get version
|
||||
* Get Version
|
||||
*
|
||||
* @param Request $request
|
||||
* @return
|
||||
* @return string - Ajax Reply
|
||||
*/
|
||||
public function versionExecute($request)
|
||||
{
|
||||
|
@ -35,53 +35,97 @@ class MAIN extends AjaxHandler
|
|||
}
|
||||
|
||||
/**
|
||||
* Get initial params
|
||||
* Get Initial params.
|
||||
* Global constants / variables / configs
|
||||
*
|
||||
* @param Request $request
|
||||
* @return
|
||||
* @return string - Ajax Reply
|
||||
*/
|
||||
public function getInitialExecute($request)
|
||||
{
|
||||
require_once V_ROOT_DIR . 'api/IP.class.php';
|
||||
require_once V_ROOT_DIR . 'api/USER.class.php';
|
||||
|
||||
// IP
|
||||
$ip_obj = new IP();
|
||||
$user_obj = new USER();
|
||||
|
||||
$user_ips = json_decode($ip_obj->getListUserIpsExecute(), TRUE);
|
||||
foreach ($user_ips['data'] as $ip)
|
||||
{
|
||||
foreach ($user_ips['data'] as $ip) {
|
||||
$ips[$ip['IP_ADDRESS']] = $ip['IP_ADDRESS'];
|
||||
}
|
||||
|
||||
// USER
|
||||
$user_obj = new USER();
|
||||
$users = json_decode($user_obj->getListExecute(), TRUE);
|
||||
$user_names = array_keys($users['data']['data']);
|
||||
$db_types = array(
|
||||
'mysql' => 'mysql',
|
||||
'postgress' => 'postgress'
|
||||
);
|
||||
|
||||
$db_types = array('mysql' => 'mysql', 'postgress' => 'postgress');
|
||||
$interfaces_arr = json_decode($ip_obj->getSysInterfacesExecute(), TRUE);
|
||||
$interfaces = $interfaces_arr['data'];
|
||||
|
||||
$data_web_domain = array('ips' => $ips);
|
||||
$data_ip = array('user_names' => $user_names, 'interfaces' => $interfaces);
|
||||
$data_dns = array('ips' => $ips);
|
||||
$data_db = array('db_types' => $db_types);
|
||||
$data_users = array('user_names' => $user_names);
|
||||
|
||||
$reply = array(
|
||||
'WEB_DOMAIN' => array(
|
||||
'WEB_DOMAIN' => $this->getWebDomainParams($data_web_domain),
|
||||
'CRON' => $this->getCronParams(),
|
||||
'IP' => $this->getIpParams($data_ip),
|
||||
'DNS' => $this->getDnsParams(),
|
||||
'DB' => $this->getDbParams($data_db),
|
||||
'USERS' => $this->getUsersParams($data_users)
|
||||
);
|
||||
|
||||
return $this->reply(true, $reply);
|
||||
}
|
||||
|
||||
//
|
||||
//
|
||||
//
|
||||
|
||||
/**
|
||||
* WEB DOMAIN initial params
|
||||
*
|
||||
* @params array $data
|
||||
* @return array
|
||||
*/
|
||||
public function getWebDomainParams($data = array())
|
||||
{
|
||||
return array(
|
||||
'TPL' => array('default' => 'default'),
|
||||
'ALIAS' => array(),
|
||||
'STAT' => array(
|
||||
'webalizer' => 'webalizer',
|
||||
'awstats' => 'awstats'),
|
||||
'IP' => $ips
|
||||
'awstats' => 'awstats'
|
||||
),
|
||||
'CRON' => array(),
|
||||
'IP' => array(
|
||||
'SYS_USERS' => $user_names,
|
||||
'IP' => $data['ips']
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* CRON initial params
|
||||
*
|
||||
* @params array $data
|
||||
* @return array
|
||||
*/
|
||||
public function getCronParams($data = array())
|
||||
{
|
||||
return array();
|
||||
}
|
||||
|
||||
/**
|
||||
* IP initial params
|
||||
*
|
||||
* @params array $data
|
||||
* @return array
|
||||
*/
|
||||
public function getIpParams($data = array())
|
||||
{
|
||||
return array(
|
||||
'SYS_USERS' => $data['user_names'],
|
||||
'STATUSES' => array(
|
||||
'shared' => 'shared',
|
||||
'exclusive' => 'exclusive'
|
||||
),
|
||||
'INTERFACES' => $interfaces,
|
||||
'INTERFACES' => $data['interfaces'],
|
||||
'MASK' => array(
|
||||
'255.255.255.0' => '255.255.255.0',
|
||||
'255.255.255.128' => '255.255.255.128',
|
||||
|
@ -92,13 +136,21 @@ class MAIN extends AjaxHandler
|
|||
'255.255.255.252' => '255.255.255.252',
|
||||
'255.255.255.255' => '255.255.255.255'
|
||||
),
|
||||
'OWNER' => array()
|
||||
),
|
||||
'DNS' => array(
|
||||
'IP' => $ips,
|
||||
'TPL' => array(
|
||||
'default' => 'default'
|
||||
),
|
||||
'OWNER' => array('Chuck Norris' => 'Chuck Norris')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* DNS initial params
|
||||
*
|
||||
* @params array $data
|
||||
* @return array
|
||||
*/
|
||||
public function getDnsParams($data = array())
|
||||
{
|
||||
return array(
|
||||
'IP' => $data['ips'],
|
||||
'TPL' => array('default' => 'default'),
|
||||
'EXP' => array(),
|
||||
'SOA' => array(),
|
||||
'TTL' => array(),
|
||||
|
@ -107,13 +159,34 @@ class MAIN extends AjaxHandler
|
|||
'RECORD_TYPE' => array('a' => 'a', 'reverse' => 'reverse'),
|
||||
'RECORD_VALUE' => array()
|
||||
)
|
||||
),
|
||||
'DB' => array(
|
||||
'TYPE' => $db_types
|
||||
),
|
||||
'USERS' => array(
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* DB initial params
|
||||
*
|
||||
* @params array $data
|
||||
* @return array
|
||||
*/
|
||||
public function getDbParams($data = array())
|
||||
{
|
||||
return array(
|
||||
'TYPE' => $data['db_types'],
|
||||
'HOST' => array('vestacp.com' => 'vestacp.com', 'askcow.org' => 'askcow.org')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Users initial params
|
||||
*
|
||||
* @params array $data
|
||||
* @return array
|
||||
*/
|
||||
public function getUsersParams($data = array())
|
||||
{
|
||||
return array(
|
||||
'ROLE' => array('user' => 'user'),
|
||||
'OWNER' => $user_names,
|
||||
'OWNER' => $data['user_names'],
|
||||
'PACKAGE' => array('default' => 'default'),
|
||||
'NS1' => array('' => ''),
|
||||
'NS2' => array('' => ''),
|
||||
|
@ -123,9 +196,7 @@ class MAIN extends AjaxHandler
|
|||
'/sbin/nologin' => '/sbin/nologin',
|
||||
'/bin/tcsh' => '/bin/tcsh',
|
||||
'/bin/csh' => '/bin/csh')
|
||||
)
|
||||
);
|
||||
|
||||
return $this->reply(true, $reply);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,46 +1,35 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* PARAMS
|
||||
*
|
||||
* @author Naumov-Socolov <naumov.socolov@gmail.com>
|
||||
* @author Malishev Dima <dima.malishev@gmail.com>
|
||||
* @deprecated
|
||||
*
|
||||
* @author vesta, http://vestacp.com/
|
||||
* @author Dmitry Malishev <dima.malishev@gmail.com>
|
||||
* @author Dmitry Naumov-Socolov <naumov.socolov@gmail.com>
|
||||
* @copyright vesta 2010-2011
|
||||
*/
|
||||
class PARAMS extends AjaxHandler
|
||||
{
|
||||
/**
|
||||
* Get initial params
|
||||
*
|
||||
* @param Request $request
|
||||
* @return
|
||||
*/
|
||||
public function getInitialExecute($request)
|
||||
class PARAMS extends AjaxHandler {
|
||||
/*
|
||||
function getInitialExecute($request)
|
||||
{
|
||||
require_once V_ROOT_DIR . 'api/IP.class.php';
|
||||
require_once V_ROOT_DIR . 'api/USER.class.php';
|
||||
|
||||
$ip_obj = new IP();
|
||||
$user_obj = new USER();
|
||||
|
||||
$user_ips = json_decode($ip_obj->getListUserIpsExecute(), TRUE);
|
||||
foreach ($user_ips['data'] as $ip)
|
||||
{
|
||||
foreach($user_ips['data'] as $ip)
|
||||
$ips[$ip['IP_ADDRESS']] = $ip['IP_ADDRESS'];
|
||||
}
|
||||
|
||||
require_once V_ROOT_DIR . 'api/USER.class.php';
|
||||
$user_obj = new USER();
|
||||
$users = json_decode($user_obj->getListExecute(), TRUE);
|
||||
$user_names = array_keys($users['data']['data']);
|
||||
|
||||
$db_types = array(
|
||||
'mysql' => 'mysql',
|
||||
'postgress' => 'postgress'
|
||||
);
|
||||
$db_types = array('mysql' => 'mysql', 'postgress' => 'postgress');
|
||||
|
||||
$interfaces_arr = json_decode($ip_obj->getSysInterfacesExecute(), TRUE);
|
||||
$interfaces = $interfaces_arr['data'];
|
||||
|
||||
|
||||
$reply = array(
|
||||
'WEB_DOMAIN' => array(
|
||||
'TPL' => array('default' => 'default'),
|
||||
|
@ -50,7 +39,9 @@ class PARAMS extends AjaxHandler
|
|||
'awstats' => 'awstats'),
|
||||
'IP' => $ips
|
||||
),
|
||||
|
||||
'CRON' => array(),
|
||||
|
||||
'IP' => array(
|
||||
'SYS_USERS' => $user_names,
|
||||
'STATUSES' => array(
|
||||
|
@ -70,23 +61,25 @@ class PARAMS extends AjaxHandler
|
|||
),
|
||||
'OWNER' => array()
|
||||
),
|
||||
|
||||
'DNS' => array(
|
||||
'IP' => $ips,
|
||||
'TPL' => array(
|
||||
'default' => 'default'
|
||||
),
|
||||
'TPL' => array('default' => 'default'),
|
||||
'EXP' => array(),
|
||||
'SOA' => array(),
|
||||
'TTL' => array(),
|
||||
'record' => array(
|
||||
'RECORD' => array(),
|
||||
'RECORD_TYPE' => array('a' => 'a', 'reverse' => 'reverse'),
|
||||
'RECORD_TYPE' => array('a' => 'a', 'reverce' => 'reverce'),
|
||||
'RECORD_VALUE' => array()
|
||||
)
|
||||
),
|
||||
|
||||
'DB' => array(
|
||||
'TYPE' => $db_types
|
||||
'TYPE' => $db_types,
|
||||
'HOST' => array('vestacp.com' => 'vestacp.com', 'askcow.org' => 'askcow.org')
|
||||
),
|
||||
|
||||
'USERS' => array(
|
||||
'ROLE' => array('user' => 'user'),
|
||||
'OWNER' => $user_names,
|
||||
|
@ -103,5 +96,5 @@ class PARAMS extends AjaxHandler
|
|||
);
|
||||
|
||||
return $this->reply(true, $reply);
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
|
|
@ -2,60 +2,94 @@
|
|||
/**
|
||||
* USERS
|
||||
*
|
||||
* @author Naumov-Socolov <naumov.socolov@gmail.com>
|
||||
* @author Malishev Dima <dima.malishev@gmail.com>
|
||||
* @author vesta, http://vestacp.com/
|
||||
* @author Dmitry Malishev <dima.malishev@gmail.com>
|
||||
* @author Dmitry Naumov-Socolov <naumov.socolov@gmail.com>
|
||||
* @copyright vesta 2010-2011
|
||||
*/
|
||||
|
||||
class USER extends AjaxHandler
|
||||
{
|
||||
|
||||
/**
|
||||
* Get list
|
||||
* Get USER entries
|
||||
*
|
||||
* @param Request $request
|
||||
* @return
|
||||
* @return string - Ajax Reply
|
||||
*/
|
||||
public function getListExecute($request)
|
||||
{
|
||||
$reply = array();
|
||||
$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 as $ip => $details)
|
||||
{
|
||||
$reply[] = array(
|
||||
'interface' => $details['INTERFACE'],
|
||||
'sys_users' => $details['U_SYS_USERS'],
|
||||
'web_domains' => $details['U_WEB_DOMAINS'],
|
||||
'status' => $details['STATUS'],
|
||||
'ip' => $ip,
|
||||
'net_mask' => $details['NETMASK'],
|
||||
'name' => $details['NAME'],
|
||||
'owner' => $details['OWNER'],
|
||||
'created_at' => date(Config::get('ui_date_format', strtotime($details['DATE'])))
|
||||
foreach ($result['data'] as $user => $details) {
|
||||
$fullname_id = rand(0, count($users)-1);
|
||||
$fullname = $users[$fullname_id];
|
||||
|
||||
$reply[$user] = array(
|
||||
"LOGIN_NAME" => $user,
|
||||
"FULLNAME" => $fullname, // TODO skid
|
||||
"PACKAGE" => $details['PACKAGE'],
|
||||
"WEB_DOMAINS" => $details['WEB_DOMAINS'],
|
||||
"WEB_SSL" => $details['WEB_SSL'],
|
||||
"WEB_ALIASES" => $details['WEB_ALIASES'],
|
||||
"DATABASES" => $details['DATABASES'],
|
||||
"MAIL_DOMAINS" => $details['MAIL_DOMAINS'],
|
||||
"MAIL_BOXES" => $details['MAIL_BOXES'],
|
||||
"MAIL_FORWARDERS" => $details['MAIL_FORWARDERS'],
|
||||
"DNS_DOMAINS" => $details['DNS_DOMAINS'],
|
||||
"DISK_QUOTA" => $details['DISK_QUOTA'],//$disk_quota,
|
||||
"BANDWIDTH" => $details['BANDWIDTH'],//$bandwidth,
|
||||
"NS_LIST" => array($details['NS1'], $details['NS2']), // TODO skid
|
||||
"SHELL" => $details['"SHELL'],
|
||||
"BACKUPS" => $details['BACKUPS'],
|
||||
"WEB_TPL" => $details['WEB_TPL'],
|
||||
"MAX_CHILDS" => $details['MAX_CHILDS'],
|
||||
"SUSPENDED" => $details['SUSPENDED'],
|
||||
"OWNER" => $details['OWNER'],
|
||||
"ROLE" => $details['ROLE'],
|
||||
"IP_OWNED" => $details['IP_OWNED'],
|
||||
"U_CHILDS" => $details['U_CHILDS'],
|
||||
"U_DISK" => $details['U_DISK'],//$u_disk,
|
||||
"U_BANDWIDTH" => $details['U_BANDWIDTH'],//$u_bandwidth,
|
||||
"U_WEB_DOMAINS" => $details['U_WEB_DOMAINS'],
|
||||
"U_WEB_SSL" => $details['U_WEB_SSL'],
|
||||
"U_DNS_DOMAINS" => $details['U_DNS_DOMAINS'],
|
||||
"U_DATABASES" => $details['U_DATABASES'],
|
||||
"U_MAIL_DOMAINS" => $details['U_MAIL_DOMAINS'],
|
||||
"CONTACT" => $details['CONTACT'],
|
||||
"DATE" => $details['DATE'],
|
||||
|
||||
"U_MAIL_BOXES" => rand(1, 10), // TODO: skid
|
||||
"U_MAIL_FORWARDERS" => rand(1, 10), // TODO: skid
|
||||
"REPORTS_ENABLED" => 'enabled' // TODO: skid
|
||||
);
|
||||
}
|
||||
|
||||
return $this->reply(true, $result);
|
||||
return $this->reply(TRUE, $reply);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add action
|
||||
* Add USER entry
|
||||
*
|
||||
* @param Request $request
|
||||
* @return
|
||||
* @return string - Ajax Reply
|
||||
*/
|
||||
public function addExecute($_spell = false)
|
||||
public function addExecute($_spell = FALSE)
|
||||
{
|
||||
$r = new Request();
|
||||
if ($_spell)
|
||||
{
|
||||
if ($_spell) {
|
||||
$_s = $_spell;
|
||||
}
|
||||
else
|
||||
{
|
||||
else {
|
||||
$_s = $r->getSpell();
|
||||
}
|
||||
|
||||
$_user = 'vesta';
|
||||
$params = array(
|
||||
'USER' => $_s['USER'],
|
||||
|
@ -69,8 +103,8 @@ class USER extends AjaxHandler
|
|||
);
|
||||
|
||||
$result = Vesta::execute(Vesta::V_ADD_SYS_USER, $params);
|
||||
if (!$result['status'])
|
||||
{
|
||||
|
||||
if (!$result['status']) {
|
||||
$this->errors[] = array($result['error_code'] => $result['error_message']);
|
||||
}
|
||||
|
||||
|
@ -78,30 +112,29 @@ class USER extends AjaxHandler
|
|||
}
|
||||
|
||||
/**
|
||||
* Delete action
|
||||
* Delete USER entry
|
||||
*
|
||||
* @param Request $request
|
||||
* @return
|
||||
* @return string - Ajax Reply
|
||||
*/
|
||||
public function delExecute($_spell = false)
|
||||
{
|
||||
$r = new Request();
|
||||
if ($_spell)
|
||||
{
|
||||
if ($_spell) {
|
||||
$_s = $_spell;
|
||||
}
|
||||
else
|
||||
{
|
||||
else {
|
||||
$_s = $r->getSpell();
|
||||
}
|
||||
|
||||
$_user = 'vesta';
|
||||
$params = array(
|
||||
'USER' => $_s['USER']
|
||||
);
|
||||
|
||||
$result = Vesta::execute(Vesta::V_DEL_SYS_USER, $params);
|
||||
|
||||
if (!$result['status'])
|
||||
{
|
||||
if (!$result['status']) {
|
||||
$this->errors[] = array($result['error_code'] => $result['error_message']);
|
||||
}
|
||||
|
||||
|
@ -109,10 +142,10 @@ class USER extends AjaxHandler
|
|||
}
|
||||
|
||||
/**
|
||||
* Change action
|
||||
* Change USER entry
|
||||
*
|
||||
* @param Request $request
|
||||
* @return
|
||||
* @return string - Ajax Reply
|
||||
*/
|
||||
public function changeExecute($request)
|
||||
{
|
||||
|
@ -123,15 +156,12 @@ class USER extends AjaxHandler
|
|||
|
||||
$_USER = $_new['USER'];
|
||||
|
||||
if($_old['USER'] != $_new['USER'])
|
||||
{
|
||||
if ($_old['USER'] != $_new['USER']) {
|
||||
$result = array();
|
||||
// creating new user
|
||||
$result = $this->addExecute($_new);
|
||||
|
||||
// deleting old
|
||||
if ($result['status'])
|
||||
{
|
||||
if ($result['status']) {
|
||||
$result = array();
|
||||
|
||||
$result = $this->delExecute($_old);
|
||||
|
@ -139,77 +169,59 @@ class USER extends AjaxHandler
|
|||
}
|
||||
}
|
||||
|
||||
if ($_old['PASSWORD'] != $_new['PASSWORD'])
|
||||
{
|
||||
if ($_old['PASSWORD'] != $_new['PASSWORD']) {
|
||||
$result = array();
|
||||
$result = Vesta::execute(Vesta::V_CHANGE_SYS_USER_PASSWORD,
|
||||
array('USER' => $_USER, 'PASSWORD' => $_new['PASSWORD']));
|
||||
if (!$result['status'])
|
||||
{
|
||||
$result = Vesta::execute(Vesta::V_CHANGE_SYS_USER_PASSWORD, array('USER' => $_USER, 'PASSWORD' => $_new['PASSWORD']));
|
||||
if (!$result['status']) {
|
||||
$this->status = FALSE;
|
||||
$this->errors['PASSWORD'] = array($result['error_code'] => $result['error_message']);
|
||||
}
|
||||
}
|
||||
|
||||
if ($_old['PACKAGE'] != $_new['PACKAGE'])
|
||||
{
|
||||
if ($_old['PACKAGE'] != $_new['PACKAGE']) {
|
||||
$result = array();
|
||||
$result = Vesta::execute(Vesta::V_CHANGE_SYS_USER_PACKAGE,
|
||||
array('USER' => $_USER, 'PACKAGE' => $_new['PACKAGE']));
|
||||
if (!$result['status'])
|
||||
{
|
||||
$result = Vesta::execute(Vesta::V_CHANGE_SYS_USER_PACKAGE, array('USER' => $_USER, 'PACKAGE' => $_new['PACKAGE']));
|
||||
if (!$result['status']) {
|
||||
$this->status = FALSE;
|
||||
$this->errors['PACKAGE'] = array($result['error_code'] => $result['error_message']);
|
||||
}
|
||||
}
|
||||
|
||||
if ($_old['EMAIL'] != $_new['EMAIL'])
|
||||
{
|
||||
if ($_old['EMAIL'] != $_new['EMAIL']) {
|
||||
$result = array();
|
||||
$result = Vesta::execute(Vesta::V_CHANGE_SYS_USER_CONTACT,
|
||||
array('USER' => $_USER, 'EMAIL' => $_new['EMAIL']));
|
||||
if (!$result['status'])
|
||||
{
|
||||
$result = Vesta::execute(Vesta::V_CHANGE_SYS_USER_CONTACT, array('USER' => $_USER, 'EMAIL' => $_new['EMAIL']));
|
||||
if (!$result['status']) {
|
||||
$this->status = FALSE;
|
||||
$this->errors['EMAIL'] = array($result['error_code'] => $result['error_message']);
|
||||
}
|
||||
}
|
||||
|
||||
if ($_old['NS1'] != $_new['NS1'] || $_old['NS2'] != $_new['NS2'])
|
||||
{
|
||||
if ($_old['NS1'] != $_new['NS1'] || $_old['NS2'] != $_new['NS2']) {
|
||||
$result = array();
|
||||
$result = Vesta::execute(Vesta::V_CHANGE_SYS_USER_NS,
|
||||
array('USER' => $_USER, 'NS1' => $_new['NS1'], 'NS2' => $_new['NS2']));
|
||||
if (!$result['status'])
|
||||
{
|
||||
$result = Vesta::execute(Vesta::V_CHANGE_SYS_USER_NS, array('USER' => $_USER, 'NS1' => $_new['NS1'], 'NS2' => $_new['NS2']));
|
||||
if (!$result['status']) {
|
||||
$this->status = FALSE;
|
||||
$this->errors['NS'] = array($result['error_code'] => $result['error_message']);
|
||||
}
|
||||
}
|
||||
|
||||
if ($_old['SHELL'] != $_new['SHELL'])
|
||||
{
|
||||
if ($_old['SHELL'] != $_new['SHELL']) {
|
||||
$result = array();
|
||||
$result = Vesta::execute(Vesta::V_CHANGE_SYS_USER_SHELL,
|
||||
array('USER' => $_USER, 'SHELL' => $_new['SHELL']));
|
||||
if (!$result['status'])
|
||||
{
|
||||
$result = Vesta::execute(Vesta::V_CHANGE_SYS_USER_SHELL, array('USER' => $_USER, 'SHELL' => $_new['SHELL']));
|
||||
if (!$result['status']) {
|
||||
$this->status = FALSE;
|
||||
$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_PACKAGE, array('USER' => $_USER, 'PACKAGE' => $_old['PACKAGE']));
|
||||
Vesta::execute(Vesta::V_CHANGE_SYS_USER_CONTACT, array('USER' => $_USER, 'EMAIL' => $_old['EMAIL']));
|
||||
// change role // $result = Vesta::execute(Vesta::V_CHANGE_SYS_USER_PACKAGE, array('USER' => $_USER, 'PACKAGE' => $_new['PACKAGE']));
|
||||
Vesta::execute(Vesta::V_CHANGE_SYS_USER_NS, array('USER' => $_USER, 'NS1' => $_old['NS1'], 'NS2' => $_old['NS2']));
|
||||
Vesta::execute(Vesta::V_CHANGE_SYS_USER_SHELL, array('USER' => $_USER, 'SHELL' => $_old['SHELL']));
|
||||
}
|
||||
|
||||
return $this->reply($this->status, '');
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,29 +1,24 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* DOMAIN
|
||||
*
|
||||
* @author Naumov-Socolov <naumov.socolov@gmail.com>
|
||||
* @author Malishev Dima <dima.malishev@gmail.com>
|
||||
* @author vesta, http://vestacp.com/
|
||||
* @author Dmitry Malishev <dima.malishev@gmail.com>
|
||||
* @author Dmitry Naumov-Socolov <naumov.socolov@gmail.com>
|
||||
* @copyright vesta 2010-2011
|
||||
*/
|
||||
class WEB_DOMAIN extends AjaxHandler
|
||||
{
|
||||
|
||||
/**
|
||||
* Get list
|
||||
*
|
||||
* @param Request $request
|
||||
* @return
|
||||
*/
|
||||
public function getListExecute($request)
|
||||
class WEB_DOMAIN extends AjaxHandler {
|
||||
function getListExecute($request)
|
||||
{
|
||||
$_user = 'vesta';
|
||||
$reply = array();
|
||||
|
||||
$result = Vesta::execute(Vesta::V_LIST_WEB_DOMAINS, array($_user, Config::get('response_type')));
|
||||
foreach ($result['data'] as $web_domain => $data)
|
||||
|
||||
// echo '<pre>';
|
||||
// print_r($result);
|
||||
|
||||
foreach($result['data'] as $web_domain => $data)
|
||||
{
|
||||
$reply[$web_domain] = array(
|
||||
'IP' => $record['IP'],
|
||||
|
@ -46,21 +41,15 @@ class WEB_DOMAIN extends AjaxHandler
|
|||
);
|
||||
}
|
||||
|
||||
if (!$result['status'])
|
||||
{
|
||||
if(!$result['status'])
|
||||
$this->errors[] = array($result['error_code'] => $result['error_message']);
|
||||
}
|
||||
|
||||
return $this->reply($result['status'], $reply);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add entry
|
||||
*
|
||||
* @param Request $request
|
||||
* @return
|
||||
*/
|
||||
public function addExecute($request)
|
||||
|
||||
|
||||
function addExecute($request)
|
||||
{
|
||||
$r = new Request();
|
||||
$_s = $r->getSpell();
|
||||
|
@ -74,174 +63,130 @@ class WEB_DOMAIN extends AjaxHandler
|
|||
|
||||
$result = Vesta::execute(Vesta::V_ADD_WEB_DOMAIN, $params);
|
||||
|
||||
if (!$result['status'])
|
||||
{
|
||||
$this->errors[] = array(
|
||||
$result['error_code'] => $result['error_message']
|
||||
);
|
||||
}
|
||||
if(!$result['status'])
|
||||
$this->errors[] = array($result['error_code'] => $result['error_message']);
|
||||
|
||||
if ($_s['TPL'])
|
||||
|
||||
|
||||
// if(0)
|
||||
if($_s['TPL'])
|
||||
{
|
||||
$params = array(
|
||||
'USER' => $_user,
|
||||
$params = array('USER' => $_user,
|
||||
'DOMAIN' => $_s['DOMAIN'],
|
||||
'TPL' => $_s['TPL']
|
||||
);
|
||||
'TPL' => $_s['TPL']);
|
||||
$result = 0;
|
||||
$result = Vesta::execute(Vesta::V_CHANGE_WEB_DOMAIN_TPL, $params);
|
||||
|
||||
if (!$result['status'])
|
||||
{
|
||||
$this->errors['CHANGE_TPL'] = array(
|
||||
$result['error_code'] => $result['error_message']
|
||||
);
|
||||
}
|
||||
if(!$result['status'])
|
||||
$this->errors['CHANGE_TPL'] = array($result['error_code'] => $result['error_message']);
|
||||
}
|
||||
|
||||
if ($_s['ALIAS'])
|
||||
// if(0)
|
||||
if($_s['ALIAS'])
|
||||
{
|
||||
$alias_arr = explode(',', $_s['ALIAS']);
|
||||
|
||||
foreach ($alias_arr as $alias)
|
||||
foreach($alias_arr as $alias)
|
||||
{
|
||||
$params = array(
|
||||
'USER' => $_user,
|
||||
$params = array('USER' => $_user,
|
||||
'DOMAIN' => $_s['DOMAIN'],
|
||||
'ALIAS' => trim($alias)
|
||||
);
|
||||
'ALIAS' => trim($alias));
|
||||
$result = 0;
|
||||
|
||||
$result = Vesta::execute(Vesta::V_ADD_WEB_DOMAIN_ALIAS, $params);
|
||||
|
||||
if (!$result['status'])
|
||||
{
|
||||
$this->errors['ALIAS'] = array(
|
||||
$result['error_code'] => $result['error_message']
|
||||
);
|
||||
}
|
||||
if(!$result['status'])
|
||||
$this->errors['ALIAS'] = array($result['error_code'] => $result['error_message']);
|
||||
}
|
||||
}
|
||||
|
||||
if ($_s['STAT'])
|
||||
// if(0)
|
||||
if($_s['STAT'])
|
||||
{
|
||||
$params = array(
|
||||
'USER' => $_user,
|
||||
$params = array('USER' => $_user,
|
||||
'DOMAIN' => $_s['DOMAIN'],
|
||||
'STAT' => $_s['STAT']
|
||||
);
|
||||
'STAT' => $_s['STAT']);
|
||||
$result = 0;
|
||||
$result = Vesta::execute(Vesta::V_ADD_WEB_DOMAIN_STAT, $params);
|
||||
|
||||
if (!$result['status'])
|
||||
{
|
||||
$this->errors['STATS'] = array(
|
||||
$result['error_code'] => $result['error_message']
|
||||
);
|
||||
}
|
||||
if(!$result['status'])
|
||||
$this->errors['STATS'] = array($result['error_code'] => $result['error_message']);
|
||||
}
|
||||
|
||||
if ($_s['STAT_AUTH'])
|
||||
// if(0)
|
||||
if($_s['STAT_AUTH'])
|
||||
{
|
||||
$params = array(
|
||||
'USER' => $_user,
|
||||
$params = array('USER' => $_user,
|
||||
'DOMAIN' => $_s['DOMAIN'],
|
||||
'STAT_USER' => $_s['STAT_USER'],
|
||||
'STAT_PASSWORS' => $_s['STAT_PASSWORD']
|
||||
);
|
||||
'STAT_PASSWORS' => $_s['STAT_PASSWORD']);
|
||||
$result = 0;
|
||||
$result = Vesta::execute(Vesta::V_ADD_WEB_DOMAIN_STAT_AUTH, $params);
|
||||
|
||||
if (!$result['status'])
|
||||
{
|
||||
$this->errors['STAT_AUTH'] = array(
|
||||
$result['error_code'] => $result['error_message']
|
||||
);
|
||||
}
|
||||
if(!$result['status'])
|
||||
$this->errors['STAT_AUTH'] = array($result['error_code'] => $result['error_message']);
|
||||
}
|
||||
|
||||
|
||||
if ($_s['SSL'])
|
||||
if(0)
|
||||
if($_s['SSL'])
|
||||
{
|
||||
$params = array(
|
||||
'USER' => $_user,
|
||||
$params = array('USER' => $_user,
|
||||
'DOMAIN' => $_s['DOMAIN'],
|
||||
'SSL_CERT' => $_s['SSL_CERT']
|
||||
);
|
||||
'SSL_CERT' => $_s['SSL_CERT']);
|
||||
|
||||
if ($_s['SSL_HOME'])
|
||||
{
|
||||
if($_s['SSL_HOME'])
|
||||
$params['SSL_HOME'] = $_s['SSL_HOME'];
|
||||
}
|
||||
|
||||
if ($_s['SSL_TEXT'])
|
||||
{
|
||||
// TODO: write it up
|
||||
}
|
||||
if($_s['SSL_TEXT'])
|
||||
{}
|
||||
// if($_FILES['SSL_CERT'])
|
||||
// $ssl_text = file_get_contents($_FILES...);
|
||||
|
||||
|
||||
$result = 0;
|
||||
$result = Vesta::execute(Vesta::V_ADD_WEB_DOMAIN_SSL, $params);
|
||||
|
||||
if (!$result['status'])
|
||||
{
|
||||
$this->errors['SSL'] = array(
|
||||
$result['error_code'] => $result['error_message']
|
||||
);
|
||||
}
|
||||
if(!$result['status'])
|
||||
$this->errors['SSL'] = array($result['error_code'] => $result['error_message']);
|
||||
}
|
||||
|
||||
if ($_s['CREATE_DNS_DOMAIN'])
|
||||
// if(0)
|
||||
if($_s['CREATE_DNS_DOMAIN'])
|
||||
{
|
||||
$params = array(
|
||||
'USER' => $_user,
|
||||
$params = array('USER' => $_user,
|
||||
'DNS_DOMAIN' => $_s['DOMAIN'],
|
||||
'IP' => $_s['IP']
|
||||
);
|
||||
'IP' => $_s['IP']);
|
||||
|
||||
require_once V_ROOT_DIR . 'api/DNS.class.php';
|
||||
|
||||
$dns = new DNS();
|
||||
$result = 0;
|
||||
$result = $dns->addExecute($params);
|
||||
if (!$result['status'])
|
||||
{
|
||||
$this->errors['DNS_DOMAIN'] = array(
|
||||
$result['error_code'] => $result['error_message']
|
||||
);
|
||||
}
|
||||
if(!$result['status'])
|
||||
$this->errors['DNS_DOMAIN'] = array($result['error_code'] => $result['error_message']);
|
||||
}
|
||||
|
||||
if ($_s['CREATE_MAIL_DOMAIN'])
|
||||
if(0)
|
||||
if($_s['CREATE_MAIL_DOMAIN'])
|
||||
{
|
||||
$params = array(
|
||||
'USER' => $_user,
|
||||
$params = array('USER' => $_user,
|
||||
'MAIL_DOMAIN' => $_s['DOMAIN'],
|
||||
'IP' => $_s['IP']
|
||||
);
|
||||
'IP' => $_s['IP']);
|
||||
|
||||
|
||||
require_once V_ROOT_DIR . 'api/MAIL.class.php';
|
||||
|
||||
$mail = new MAIL();
|
||||
$result = 0;
|
||||
$result = $mail->addExecute($params);
|
||||
if (!$result['status'])
|
||||
{
|
||||
$this->errors['MAIL_DOMAIN'] = array(
|
||||
$result['error_code'] => $result['error_message']
|
||||
);
|
||||
}
|
||||
if(!$result['status'])
|
||||
$this->errors['MAIL_DOMAIN'] = array($result['error_code'] => $result['error_message']);
|
||||
}
|
||||
|
||||
return $this->reply($result['status'], $result['data']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete entry
|
||||
*
|
||||
* @param Request $request
|
||||
* @return
|
||||
*/
|
||||
public function delExecute($request)
|
||||
function delExecute($request)
|
||||
{
|
||||
$r = new Request();
|
||||
$_s = $r->getSpell();
|
||||
|
@ -254,10 +199,10 @@ class WEB_DOMAIN extends AjaxHandler
|
|||
|
||||
$result = Vesta::execute(Vesta::V_DEL_WEB_DOMAIN, $params);
|
||||
|
||||
if (!$result['status'])
|
||||
$this->errors[] = array(
|
||||
$result['error_code'] => $result['error_message']
|
||||
);
|
||||
if(!$result['status'])
|
||||
$this->errors[] = array($result['error_code'] => $result['error_message']);
|
||||
|
||||
|
||||
|
||||
$params = array(
|
||||
'USER' => $_user,
|
||||
|
@ -268,12 +213,8 @@ class WEB_DOMAIN extends AjaxHandler
|
|||
$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']
|
||||
);
|
||||
}
|
||||
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';
|
||||
|
||||
|
@ -282,16 +223,20 @@ class WEB_DOMAIN extends AjaxHandler
|
|||
'MAIL_DOMAIN' => $_s['DOMAIN']
|
||||
);
|
||||
|
||||
/*
|
||||
require_once V_ROOT_DIR . 'api/MAIL.class.php';
|
||||
$mail = new MAIL();
|
||||
$result = $mail->delExecute($params);
|
||||
|
||||
if(!$result['status'] && $result['error_code'] != 31) // domain not found
|
||||
$this->errors['MAIL'] = array($result['error_code'] => $result['error_message']);
|
||||
*/
|
||||
return $this->reply($result['status'], $result['data']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Change entry
|
||||
*
|
||||
* @param Request $request
|
||||
* @return
|
||||
*/
|
||||
public function changeExecute($request)
|
||||
|
||||
|
||||
function changeExecute($request)
|
||||
{
|
||||
$r = new Request();
|
||||
$_s = $r->getSpell();
|
||||
|
@ -301,41 +246,30 @@ class WEB_DOMAIN extends AjaxHandler
|
|||
$_user = 'vesta';
|
||||
$_DOMAIN = $_new['DOMAIN'];
|
||||
|
||||
if ($_old['IP'] != $_new['IP'])
|
||||
if($_old['IP'] != $_new['IP'])
|
||||
{
|
||||
$result = array();
|
||||
$result = Vesta::execute(Vesta::V_CHANGE_WEB_DOMAIN_IP, array(
|
||||
'USER' => $_user,
|
||||
'DOMAIN' => $_DOMAIN,
|
||||
'IP' => $_new['IP']
|
||||
));
|
||||
if (!$result['status'])
|
||||
$result = Vesta::execute(Vesta::V_CHANGE_WEB_DOMAIN_IP, array('USER' => $_user, 'DOMAIN' => $_DOMAIN, 'IP' => $_new['IP']));
|
||||
if(!$result['status'])
|
||||
{
|
||||
$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']);
|
||||
}
|
||||
}
|
||||
|
||||
if ($_old['TPL'] != $_new['TPL'])
|
||||
|
||||
if($_old['TPL'] != $_new['TPL'])
|
||||
{
|
||||
$result = array();
|
||||
$result = Vesta::execute(Vesta::V_CHANGE_WEB_DOMAIN_TPL, array(
|
||||
'USER' => $_user,
|
||||
'DOMAIN' => $_DOMAIN,
|
||||
'TPL' => $_new['TPL']
|
||||
));
|
||||
if (!$result['status'])
|
||||
$result = Vesta::execute(Vesta::V_CHANGE_WEB_DOMAIN_TPL, array('USER' => $_user, 'DOMAIN' => $_DOMAIN, 'TPL' => $_new['TPL']));
|
||||
if(!$result['status'])
|
||||
{
|
||||
$this->status = FALSE;
|
||||
$this->errors['TPL'] = array(
|
||||
$result['error_code'] => $result['error_message']
|
||||
);
|
||||
$this->errors['TPL'] = array($result['error_code'] => $result['error_message']);
|
||||
}
|
||||
}
|
||||
|
||||
if ($_old['ALIAS'] != $_new['ALIAS'])
|
||||
if($_old['ALIAS'] != $_new['ALIAS'])
|
||||
{
|
||||
$result = array();
|
||||
|
||||
|
@ -345,203 +279,146 @@ class WEB_DOMAIN extends AjaxHandler
|
|||
$added = array_diff($new_arr, $old_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
|
||||
));
|
||||
if (!$result['status'])
|
||||
$result = Vesta::execute(Vesta::V_ADD_WEB_DOMAIN_ALIAS, array('USER' => $_user, 'DOMAIN' => $_DOMAIN, 'ALIAS' => $alias));
|
||||
if(!$result['status'])
|
||||
{
|
||||
$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']);
|
||||
}
|
||||
}
|
||||
foreach ($deleted as $alias)
|
||||
foreach($deleted as $alias)
|
||||
{
|
||||
$result = Vesta::execute(Vesta::V_DEL_WEB_DOMAIN_ALIAS, array(
|
||||
'USER' => $_user,
|
||||
'DOMAIN' => $_DOMAIN,
|
||||
'ALIAS' => $alias
|
||||
));
|
||||
if (!$result['status'])
|
||||
$result = Vesta::execute(Vesta::V_DEL_WEB_DOMAIN_ALIAS, array('USER' => $_user, 'DOMAIN' => $_DOMAIN, 'ALIAS' => $alias));
|
||||
if(!$result['status'])
|
||||
{
|
||||
$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']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ($_old['STAT'] != $_new['STAT'])
|
||||
if($_old['STAT'] != $_new['STAT'])
|
||||
{
|
||||
if ($_new['STAT'] == true)
|
||||
if($_new['STAT'] == true)
|
||||
{
|
||||
$result = array();
|
||||
$result = Vesta::execute(Vesta::V_ADD_WEB_DOMAIN_STAT, array(
|
||||
'USER' => $_user,
|
||||
'DOMAIN' => $_DOMAIN,
|
||||
'STAT' => $_new['STAT']
|
||||
));
|
||||
if (!$result['status'])
|
||||
$result = Vesta::execute(Vesta::V_ADD_WEB_DOMAIN_STAT, array('USER' => $_user, 'DOMAIN' => $_DOMAIN, 'STAT' => $_new['STAT']));
|
||||
if(!$result['status'])
|
||||
{
|
||||
$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'] == false)
|
||||
{
|
||||
$result = array();
|
||||
$result = Vesta::execute(Vesta::V_DEL_WEB_DOMAIN_STAT, array(
|
||||
'USER' => $_user,
|
||||
'DOMAIN' => $_DOMAIN
|
||||
));
|
||||
if (!$result['status'])
|
||||
$result = Vesta::execute(Vesta::V_DEL_WEB_DOMAIN_STAT, array('USER' => $_user, 'DOMAIN' => $_DOMAIN));
|
||||
if(!$result['status'])
|
||||
{
|
||||
$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 = Vesta::execute(Vesta::V_DEL_WEB_DOMAIN_STAT_AUTH, array(
|
||||
'USER' => $_user,
|
||||
'DOMAIN' => $_DOMAIN,
|
||||
'STAT_USER' => $_new['STAT_USER']
|
||||
));
|
||||
if (!$result['status'])
|
||||
$result = Vesta::execute(Vesta::V_DEL_WEB_DOMAIN_STAT_AUTH, array('USER' => $_user, 'DOMAIN' => $_DOMAIN, 'STAT_USER' => $_new['STAT_USER']));
|
||||
if(!$result['status'])
|
||||
{
|
||||
$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']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($_old['SSL'] != $_new['SSL'])
|
||||
if(0)
|
||||
// ssl
|
||||
if($_old['SSL'] != $_new['SSL'])
|
||||
{
|
||||
if ($_new['SSL'] == true)
|
||||
if($_new['SSL'] == true)
|
||||
{
|
||||
// TODO: write it
|
||||
|
||||
|
||||
}
|
||||
if ($_new['SSL'] == false)
|
||||
if($_new['SSL'] == false)
|
||||
{
|
||||
// TODO: write it
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($_old['SSL_CERT'] != $_new['SSL_CERT'])
|
||||
if($_old['SSL_CERT'] != $_new['SSL_CERT'])
|
||||
{
|
||||
$result = array();
|
||||
$_SSL_CERT = $_new['SSL_CERT'];
|
||||
// or read uploaded tmp file
|
||||
|
||||
$result = Vesta::execute(Vesta::V_CHANGE_WEB_DOMAIN_CERT, array(
|
||||
'USER' => $_user,
|
||||
'DOMAIN' => $_DOMAIN,
|
||||
'SSL_CERT' => $_SSL_CERT
|
||||
));
|
||||
if (!$result['status'])
|
||||
$result = Vesta::execute(Vesta::V_CHANGE_WEB_DOMAIN_CERT, array('USER' => $_user, 'DOMAIN' => $_DOMAIN, 'SSL_CERT' => $_SSL_CERT ));
|
||||
if(!$result['status'])
|
||||
{
|
||||
$this->status = FALSE;
|
||||
$this->errors['SSL_CERT'] = array(
|
||||
$result['error_code'] => $result['error_message']
|
||||
);
|
||||
$this->errors['SSL_CERT'] = array($result['error_code'] => $result['error_message']);
|
||||
}
|
||||
}
|
||||
if ($_old['SSL_HOME'] != $_new['SSL_HOME'])
|
||||
if($_old['SSL_HOME'] != $_new['SSL_HOME'])
|
||||
{
|
||||
$result = array();
|
||||
$result = Vesta::execute(Vesta::V_CHANGE_WEB_DOMAIN_SSLHOME, array(
|
||||
'USER' => $_user,
|
||||
'DOMAIN' => $_DOMAIN,
|
||||
'SSL_HOME' => $_new['SSL_HOME']
|
||||
));
|
||||
if (!$result['status'])
|
||||
$result = Vesta::execute(Vesta::V_CHANGE_WEB_DOMAIN_SSLHOME, array('USER' => $_user, 'DOMAIN' => $_DOMAIN, 'SSL_HOME' => $_new['SSL_HOME']));
|
||||
if(!$result['status'])
|
||||
{
|
||||
$this->status = FALSE;
|
||||
$this->errors['SSL_HOME'] = array(
|
||||
$result['error_code'] => $result['error_message']
|
||||
);
|
||||
$this->errors['SSL_HOME'] = array($result['error_code'] => $result['error_message']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($_old['CGI'] != $_new['CGI'])
|
||||
if($_old['CGI'] != $_new['CGI'])
|
||||
{
|
||||
if ($_new['CGI'] == true)
|
||||
if($_new['CGI'] == true)
|
||||
{
|
||||
$result = array();
|
||||
$result = Vesta::execute(Vesta::V_ADD_WEB_DOMAIN_CGI, array(
|
||||
'USER' => $_user,
|
||||
'DOMAIN' => $_DOMAIN
|
||||
));
|
||||
if (!$result['status'])
|
||||
$result = Vesta::execute(Vesta::V_ADD_WEB_DOMAIN_CGI, array('USER' => $_user, 'DOMAIN' => $_DOMAIN));
|
||||
if(!$result['status'])
|
||||
{
|
||||
$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']);
|
||||
}
|
||||
}
|
||||
if ($_new['CGI'] == false)
|
||||
if($_new['CGI'] == false)
|
||||
{
|
||||
$result = array();
|
||||
$result = Vesta::execute(Vesta::V_DEL_WEB_DOMAIN_CGI, array(
|
||||
'USER' => $_user,
|
||||
'DOMAIN' => $_DOMAIN
|
||||
));
|
||||
if (!$result['status'])
|
||||
$result = Vesta::execute(Vesta::V_DEL_WEB_DOMAIN_CGI, array('USER' => $_user, 'DOMAIN' => $_DOMAIN));
|
||||
if(!$result['status'])
|
||||
{
|
||||
$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']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($_old['ELOG'] != $_new['ELOG'])
|
||||
if($_old['ELOG'] != $_new['ELOG'])
|
||||
{
|
||||
if ($_new['ELOG'] == true)
|
||||
if($_new['ELOG'] == true)
|
||||
{
|
||||
$result = array();
|
||||
$result = Vesta::execute(Vesta::V_ADD_WEB_DOMAIN_ELOG, array(
|
||||
'USER' => $_user,
|
||||
'DOMAIN' => $_DOMAIN
|
||||
));
|
||||
if (!$result['status'])
|
||||
$result = Vesta::execute(Vesta::V_ADD_WEB_DOMAIN_ELOG, array('USER' => $_user, 'DOMAIN' => $_DOMAIN));
|
||||
if(!$result['status'])
|
||||
{
|
||||
$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']);
|
||||
}
|
||||
}
|
||||
if ($_new['ELOG'] == false)
|
||||
if($_new['ELOG'] == false)
|
||||
{
|
||||
$result = array();
|
||||
$result = Vesta::execute(Vesta::V_DEL_WEB_DOMAIN_ELOG, array(
|
||||
'USER' => $_user,
|
||||
'DOMAIN' => $_DOMAIN
|
||||
));
|
||||
if (!$result['status'])
|
||||
$result = Vesta::execute(Vesta::V_DEL_WEB_DOMAIN_ELOG, array('USER' => $_user, 'DOMAIN' => $_DOMAIN));
|
||||
if(!$result['status'])
|
||||
{
|
||||
$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']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -550,13 +427,9 @@ class WEB_DOMAIN extends AjaxHandler
|
|||
return $this->reply($result['status'], $result['data']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Suspend entry
|
||||
*
|
||||
* @param Request $request
|
||||
* @return
|
||||
*/
|
||||
public function suspendExecute($request)
|
||||
|
||||
|
||||
function suspendExecute($request)
|
||||
{
|
||||
$r = new Request();
|
||||
$_s = $r->getSpell();
|
||||
|
@ -570,23 +443,14 @@ class WEB_DOMAIN extends AjaxHandler
|
|||
|
||||
$result = Vesta::execute(Vesta::V_SUSPEND_WEB_DOMAIN, $params);
|
||||
|
||||
if (!$result['status'])
|
||||
{
|
||||
$this->errors[] = array(
|
||||
$result['error_code'] => $result['error_message']
|
||||
);
|
||||
}
|
||||
if(!$result['status'])
|
||||
$this->errors[] = array($result['error_code'] => $result['error_message']);
|
||||
|
||||
return $this->reply($result['status'], $result['data']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Unsuspend entry
|
||||
*
|
||||
* @param Request $request
|
||||
* @return
|
||||
*/
|
||||
public function unsuspendExecute($request)
|
||||
|
||||
function unsuspendExecute($request)
|
||||
{
|
||||
$r = new Request();
|
||||
$_s = $r->getSpell();
|
||||
|
@ -600,23 +464,15 @@ class WEB_DOMAIN extends AjaxHandler
|
|||
|
||||
$result = Vesta::execute(Vesta::V_UNSUSPEND_WEB_DOMAIN, $params);
|
||||
|
||||
if (!$result['status'])
|
||||
{
|
||||
$this->errors[] = array(
|
||||
$result['error_code'] => $result['error_message']
|
||||
);
|
||||
}
|
||||
if(!$result['status'])
|
||||
$this->errors[] = array($result['error_code'] => $result['error_message']);
|
||||
|
||||
return $this->reply($result['status'], $result['data']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Batch suspend entries
|
||||
*
|
||||
* @param Request $request
|
||||
* @return
|
||||
*/
|
||||
public function suspendAllExecute($request)
|
||||
|
||||
|
||||
function suspendAllExecute($request)
|
||||
{
|
||||
$r = new Request();
|
||||
$_s = $r->getSpell();
|
||||
|
@ -629,23 +485,13 @@ class WEB_DOMAIN extends AjaxHandler
|
|||
|
||||
$result = Vesta::execute(Vesta::V_SUSPEND_WEB_DOMAINS, $params);
|
||||
|
||||
if (!$result['status'])
|
||||
{
|
||||
$this->errors[] = array(
|
||||
$result['error_code'] => $result['error_message']
|
||||
);
|
||||
}
|
||||
if(!$result['status'])
|
||||
$this->errors[] = array($result['error_code'] => $result['error_message']);
|
||||
|
||||
return $this->reply($result['status'], $result['data']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Batch unsuspend entry
|
||||
*
|
||||
* @param Request $request
|
||||
* @return
|
||||
*/
|
||||
public function unsuspendAllExecute($request)
|
||||
function unsuspendAllExecute($request)
|
||||
{
|
||||
$r = new Request();
|
||||
$_s = $r->getSpell();
|
||||
|
@ -658,14 +504,9 @@ class WEB_DOMAIN extends AjaxHandler
|
|||
|
||||
$result = Vesta::execute(Vesta::V_UNSUSPEND_WEB_DOMAINS, $params);
|
||||
|
||||
if (!$result['status'])
|
||||
{
|
||||
$this->errors[] = array(
|
||||
$result['error_code'] => $result['error_message']
|
||||
);
|
||||
}
|
||||
if(!$result['status'])
|
||||
$this->errors[] = array($result['error_code'] => $result['error_message']);
|
||||
|
||||
return $this->reply($result['status'], $result['data']);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -5,8 +5,8 @@
|
|||
*
|
||||
* Reads, manipulate configs
|
||||
*
|
||||
* @author Malishev Dima <dima.malishev@gmail.com>
|
||||
* @author vesta, http://vestacp.com/
|
||||
* @author Dmitry Malishev <dima.malishev@gmail.com>
|
||||
* @copyright vesta 2010-2011
|
||||
*/
|
||||
class Config
|
||||
|
|
|
@ -1,86 +0,0 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Request
|
||||
*
|
||||
* Holds parameters, decorating them and providing easy access
|
||||
*
|
||||
* @author vesta, http://vestacp.com/
|
||||
* @copyright vesta 2010
|
||||
*/
|
||||
class Request {
|
||||
|
||||
protected $server = array();
|
||||
protected $post = array();
|
||||
protected $get = array();
|
||||
protected $global = array();
|
||||
protected $_merged = array();
|
||||
protected $_spell = array();
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function __construct() {
|
||||
$this->post = $_POST;
|
||||
$this->get = $_GET;
|
||||
$this->server = $_SERVER;
|
||||
|
||||
$this->mergeContainers();
|
||||
}
|
||||
|
||||
/**
|
||||
* Merge holders into single holder
|
||||
*/
|
||||
function mergeContainers() {
|
||||
$this->_merged = array_merge($this->server, $this->post, $this->get, $this->global);
|
||||
$this->_spell = json_decode($this->_merged['spell'], true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get parameter
|
||||
*
|
||||
* @param <string> $key
|
||||
* @param <mixed> $default
|
||||
* @return <mixed>
|
||||
*
|
||||
*/
|
||||
function getParameter($key, $default=false) {
|
||||
return isset($this->_merged[$key]) ? $this->_merged[$key] : $default;
|
||||
// return isset($this->_spell[$key]) ? $this->_spell[$key] : $default;
|
||||
}
|
||||
|
||||
function getSpell() {
|
||||
return $this->_spell;
|
||||
}
|
||||
|
||||
function hasParameter($key, $default=false) {
|
||||
return isset($this->_merged[$key]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if request is post
|
||||
*
|
||||
* TODO: write the method
|
||||
*
|
||||
* @return <boolean>
|
||||
*/
|
||||
function isPost() {
|
||||
return true;
|
||||
}
|
||||
|
||||
static function parseAjaxMethod($request) {
|
||||
if (!$request->hasParameter('jedi_method')) {
|
||||
throw new ProtectionException(Message::INVALID_METHOD);
|
||||
}
|
||||
|
||||
$method = explode('.', $request->getParameter('jedi_method'));
|
||||
|
||||
if (count($method) != 2) {
|
||||
throw new ProtectionException(Message::INVALID_METHOD);
|
||||
}
|
||||
|
||||
return array('namespace' => ucfirst($method[0]), 'function' => strtolower($method[1]));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -4,9 +4,9 @@
|
|||
* Api Main class
|
||||
* Calls / Executes native vesta methods
|
||||
*
|
||||
* @author Malishev Dima <dima.malishev@gmail.com>
|
||||
* @author Naumov-Socolov <naumov.socolov@gmail.com>
|
||||
* @author vesta, http://vestacp.com/
|
||||
* @author Dmitry Malishev <dima.malishev@gmail.com>
|
||||
* @author Dmitry Naumov-Socolov <naumov.socolov@gmail.com>
|
||||
* @copyright vesta 2010-2011
|
||||
*/
|
||||
class Vesta
|
||||
|
@ -117,8 +117,7 @@ class Vesta
|
|||
$r = new Request();
|
||||
$_DEBUG = $r->getParameter("debug", FALSE);
|
||||
|
||||
if (!isset($cmd_command))
|
||||
{
|
||||
if (!isset($cmd_command)) {
|
||||
throw new ProtectionException('No function name passed into Vesta::execute'); // TODO: move msg to Messages::
|
||||
}
|
||||
|
||||
|
@ -134,22 +133,21 @@ class Vesta
|
|||
exec($cmd, $output, $return);
|
||||
|
||||
$result = 0;
|
||||
$result = array('status' => TRUE,
|
||||
$result = array(
|
||||
'status' => TRUE,
|
||||
'data' => '',
|
||||
'error_code' => '',
|
||||
'error_message' => ''
|
||||
);
|
||||
|
||||
// TODO: please remove this later :)
|
||||
if ($_DEBUG)
|
||||
{
|
||||
if ($_DEBUG) {
|
||||
$result['debug'] = array(
|
||||
"cmd" => $cmd,
|
||||
"output" => $output,
|
||||
"return" => $return
|
||||
);
|
||||
if ($debug == 2)
|
||||
{
|
||||
if ($debug == 2) {
|
||||
echo '<p>'.$cmd;
|
||||
echo '<br> output: '; print_r($output);
|
||||
echo '<br> return: '.$return;
|
||||
|
@ -157,14 +155,12 @@ class Vesta
|
|||
}
|
||||
}
|
||||
|
||||
if (!!(int)$return)
|
||||
{
|
||||
if (!!(int)$return) {
|
||||
$result['status'] = FALSE;
|
||||
$result['error_code'] = (int)$return;
|
||||
$result['error_message'] = implode('', $output);
|
||||
}
|
||||
else
|
||||
{
|
||||
else {
|
||||
$result['data'] = json_decode(implode('', $output), true);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,221 +0,0 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
*
|
||||
* @author vesta, http://vestacp.com/
|
||||
* @copyright vesta 2010
|
||||
*/
|
||||
class Vesta {
|
||||
// ====================== IP ===========================
|
||||
const V_LIST_SYS_IPS = 'v_list_sys_ips';
|
||||
|
||||
// adding
|
||||
const V_ADD_SYS_IP = 'v_add_sys_ip';
|
||||
const V_ADD_SYS_USER_IP = 'v_add_sys_user_ip';
|
||||
|
||||
// changing
|
||||
const V_CHANGE_SYS_IP_OWNER = 'v_change_sys_ip_owner';
|
||||
const V_CHANGE_SYS_IP_NAME = 'v_change_sys_ip_name';
|
||||
|
||||
// deleting
|
||||
const V_DEL_SYS_IP = 'v_del_sys_ip';
|
||||
|
||||
// service
|
||||
const V_UPD_SYS_IP = 'v_upd_sys_ip';
|
||||
const V_LIST_SYS_INTERFACES = 'v_list_sys_interfaces';
|
||||
|
||||
// ======================= DNS =========================
|
||||
const V_LIST_DNS_DOMAINS = 'v_list_dns_domains';
|
||||
const V_LIST_DNS_DOMAIN_RECORDS = 'v_list_dns_domain';
|
||||
|
||||
// adding
|
||||
const V_ADD_DNS_DOMAIN = 'v_add_dns_domain';
|
||||
const V_ADD_DNS_DOMAIN_RECORD = 'v_add_dns_domain_record';
|
||||
|
||||
// changing
|
||||
const V_CHANGE_DNS_DOMAIN_IP = 'v_change_dns_domain_ip';
|
||||
const V_CHANGE_DNS_DOMAIN_SOA = 'v_change_dns_domain_soa';
|
||||
const V_CHANGE_DNS_DOMAIN_TPL = 'v_change_dns_domain_tpl';
|
||||
const V_CHANGE_DNS_DOMAIN_TTL = 'v_change_dns_domain_ttl';
|
||||
const V_CHANGE_DNS_DOMAIN_EXP = 'v_change_dns_domain_exp';
|
||||
const V_CHANGE_DNS_DOMAIN_RECORD = 'v_change_dns_domain_record';
|
||||
|
||||
// deleting
|
||||
const V_DEL_DNS_DOMAIN = 'v_del_dns_domain';
|
||||
const V_DEL_DNS_DOMAIN_RECORD = 'v_del_dns_domain_record';
|
||||
|
||||
|
||||
|
||||
// ======================= CRON =========================
|
||||
const V_LIST_CRON_JOBS = 'v_list_sys_cron';
|
||||
|
||||
// adding
|
||||
const V_ADD_CRON_JOB = 'v_add_sys_cron';
|
||||
const V_ADD_SYS_USER_REPORTS = 'v_add_sys_user_reports';
|
||||
|
||||
// changing
|
||||
const V_CHANGE_CRON_JOB = 'v_change_sys_cron_job';
|
||||
const V_SUSPEND_CRON_JOB = 'v_suspend_sys_cron_job';
|
||||
const V_SUSPEND_CRON_JOBS = 'v_suspend_sys_cron_jobs';
|
||||
const V_UNSUSPEND_CRON_JOB = 'v_unsuspend_sys_cron_job';
|
||||
const V_UNSUSPEND_CRON_JOBS = 'v_unsuspend_sys_cron_jobs';
|
||||
|
||||
// deleting
|
||||
const V_DEL_CRON_JOB = 'v_del_sys_cron';
|
||||
const V_DEL_SYS_USER_REPORTS = 'v_del_sys_user_reports';
|
||||
|
||||
|
||||
|
||||
// ======================= USER =========================
|
||||
const V_LIST_SYS_USERS = 'v_list_sys_users';
|
||||
|
||||
// adding
|
||||
const V_ADD_SYS_USER = 'v_add_sys_user';
|
||||
|
||||
// changing
|
||||
const V_CHANGE_SYS_USER_CONTACT = 'v_change_sys_user_contact';
|
||||
const V_CHANGE_SYS_USER_NS = 'v_change_sys_user_ns';
|
||||
const V_CHANGE_SYS_USER_PACKAGE = 'v_change_sys_user_package';
|
||||
const V_CHANGE_SYS_USER_PASSWORD = 'v_change_sys_user_password';
|
||||
const V_CHANGE_SYS_USER_SHELL = 'v_change_sys_user_shell';
|
||||
const V_CHANGE_SYS_USER_ROLE = 'v_change_sys_user_role';
|
||||
|
||||
// deleting
|
||||
const V_DEL_SYS_USER = 'v_del_sys_user';
|
||||
|
||||
|
||||
// ======================= WEB_DOMAIN =========================
|
||||
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_ELOG = 'v_list_web_domains_elog';
|
||||
const V_LIST_WEB_DOMAINS_PROXY = 'v_list_web_domains_proxy';
|
||||
const V_LIST_WEB_DOMAINS_SSL = 'v_list_web_domains_ssl';
|
||||
const V_LIST_WEB_DOMAINS_STATS = 'v_list_web_domains_stats';
|
||||
const V_LIST_WEB_TEMPLATES = 'v_list_web_templates';
|
||||
|
||||
// adding
|
||||
const V_ADD_WEB_DOMAIN = 'v_add_web_domain';
|
||||
const V_ADD_WEB_DOMAIN_ALIAS = 'v_add_web_domain_alias';
|
||||
|
||||
// changing
|
||||
const V_ADD_WEB_DOMAIN_STAT = 'v_add_web_domain_stat';
|
||||
const V_ADD_WEB_DOMAIN_STAT_AUTH = 'v_add_web_domain_stat_auth';
|
||||
const V_ADD_WEB_DOMAIN_SSL = 'v_add_web_domain_ssl';
|
||||
const V_ADD_WEB_DOMAIN_ELOG = 'v_add_web_domain_elog';
|
||||
const V_ADD_WEB_DOMAIN_CGI = 'v_add_web_domain_cgi';
|
||||
|
||||
const V_CHANGE_WEB_DOMAIN_IP = 'v_change_web_domain_ip';
|
||||
const V_CHANGE_WEB_DOMAIN_SSLCERT = 'v_change_web_domain_sslcert';
|
||||
const V_CHANGE_WEB_DOMAIN_SSLHOME = 'v_change_web_domain_sslhome';
|
||||
const V_CHANGE_WEB_DOMAIN_TPL = 'v_change_web_domain_tpl';
|
||||
|
||||
const V_DEL_WEB_DOMAIN_CGI = 'v_del_web_domain_cgi';
|
||||
const V_DEL_WEB_DOMAIN_ELOG = 'v_del_web_domain_elog';
|
||||
const V_DEL_WEB_DOMAIN_SSL = 'v_del_web_domain_ssl';
|
||||
const V_DEL_WEB_DOMAIN_STAT = 'v_del_web_domain_stat';
|
||||
const V_DEL_WEB_DOMAIN_STAT_AUTH = 'v_del_web_domain_stat_auth';
|
||||
const V_DEL_WEB_DOMAIN_ALIAS = 'v_del_web_domain_alias';
|
||||
|
||||
const V_SUSPEND_WEB_DOMAIN = 'v_suspend_web_domain';
|
||||
const V_SUSPEND_WEB_DOMAINS = 'v_suspend_web_domains';
|
||||
const V_UNSUSPEND_WEB_DOMAIN = 'v_unsuspend_web_domain';
|
||||
const V_UNSUSPEND_WEB_DOMAINS = 'v_unsuspend_web_domains';
|
||||
const V_UPD_WEB_DOMAIN_DISK = 'v_upd_web_domain_disk';
|
||||
const V_UPD_WEB_DOMAINS_DISK = 'v_upd_web_domains_disk';
|
||||
const V_UPD_WEB_DOMAIN_TRAFF = 'v_upd_web_domain_traff';
|
||||
const V_UPD_WEB_DOMAINS_TRAFF = 'v_upd_web_domains_traff';
|
||||
|
||||
// deleting
|
||||
const V_DEL_WEB_DOMAIN = 'v_del_web_domain';
|
||||
|
||||
|
||||
// ======================= DB =========================
|
||||
// list
|
||||
const V_LIST_DB_BASES = 'v_list_db_bases';
|
||||
const V_LIST_DB_HOSTS = 'v_list_db_hosts';
|
||||
|
||||
// adding
|
||||
const V_ADD_DB_BASE = 'v_add_db_base';
|
||||
const V_ADD_DB_HOST = 'v_add_db_host';
|
||||
|
||||
// changing
|
||||
const V_SUSPEND_DB_BASE = 'v_suspend_db_base';
|
||||
const V_SUSPEND_DB_BASES = 'v_suspend_db_bases';
|
||||
const V_UNSUSPEND_DB_BASE = 'v_unsuspend_db_base';
|
||||
const V_UNSUSPEND_DB_BASES = 'v_unsuspend_db_bases';
|
||||
const V_CHANGE_DB_PASSWORD = 'v_change_db_password';
|
||||
|
||||
// deleting
|
||||
const V_DEL_DB_BASE = 'v_del_db_base';
|
||||
const V_DEL_DB_HOST = 'v_del_db_host';
|
||||
|
||||
// service
|
||||
const V_UPD_DB_BASE_DISK = 'v_upd_db_base_disk';
|
||||
const V_UPD_DB_BASES_DISK = 'v_upd_db_bases_disk';
|
||||
|
||||
|
||||
// ======================================================
|
||||
|
||||
const PARAM_DELIMETER = ' ';
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
static function execute($cmd_command, $parameters=array()) {
|
||||
$r = new Request();
|
||||
$debug = $r->getParameter("debug", FALSE);
|
||||
|
||||
if (!isset($cmd_command)) {
|
||||
throw new ProtectionException('No function name passed into Vesta::execute'); // TODO: move msg to Messages::
|
||||
}
|
||||
|
||||
$params = array(
|
||||
'sudo' => Config::get('sudo_path'),
|
||||
'functions' => Config::get('vesta_functions_path'),
|
||||
'parameters' => implode("' '", $parameters),
|
||||
// 'reply' => Config::get('response_type')
|
||||
);
|
||||
|
||||
|
||||
$cmd = "{$params['sudo']} {$params['functions']}{$cmd_command} '{$params['parameters']}' {$params['reply']}";
|
||||
// /usr/bin/sudo /usr/local/vesta/bin/v_list_sys_users vesta json
|
||||
exec($cmd, $output, $return);
|
||||
|
||||
$result = 0;
|
||||
$result = array('status' => TRUE,
|
||||
'data' => '',
|
||||
'error_code' => '',
|
||||
'error_message' => ''
|
||||
);
|
||||
|
||||
if($debug)
|
||||
{
|
||||
$result['debug'] = array(
|
||||
"cmd" => $cmd,
|
||||
"output" => $output,
|
||||
"return" => $return
|
||||
);
|
||||
if($debug == 2)
|
||||
{
|
||||
echo '<p>'.$cmd;
|
||||
echo '<br> output: '; print_r($output);
|
||||
echo '<br> return: '.$return;
|
||||
echo '</p>';
|
||||
}
|
||||
}
|
||||
|
||||
if(!!(int)$return)
|
||||
{
|
||||
$result['status'] = FALSE;
|
||||
$result['error_code'] = (int)$return;
|
||||
$result['error_message'] = implode('', $output);
|
||||
}
|
||||
else
|
||||
{
|
||||
$result['data'] = json_decode(implode('', $output), true);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
|
@ -5,8 +5,8 @@
|
|||
*
|
||||
* Thrown if unexpected action or behaviour detected
|
||||
*
|
||||
* @author Malishev Dima <dima.malishev@gmail.com>
|
||||
* @author vesta, http://vestacp.com/
|
||||
* @author Dmitry Malishev <dima.malishev@gmail.com>
|
||||
* @copyright vesta 2010-2011
|
||||
*/
|
||||
class ProtectionException extends Exception
|
||||
|
|
|
@ -7,8 +7,8 @@
|
|||
* - system error occured
|
||||
* - unpredictable scenarios
|
||||
*
|
||||
* @author Malishev Dima <dima.malishev@gmail.com>
|
||||
* @author vesta, http://vestacp.com/
|
||||
* @author Dmitry Malishev <dima.malishev@gmail.com>
|
||||
* @copyright vesta 2010-2011
|
||||
*/
|
||||
class SystemException extends Exception {
|
||||
|
|
|
@ -5,8 +5,8 @@
|
|||
*
|
||||
* Contains messages, that are used in the code.
|
||||
*
|
||||
* @author Malishev Dima <dima.malishev@gmail.com>
|
||||
* @author vesta, http://vestacp.com/
|
||||
* @author Dmitry Malishev <dima.malishev@gmail.com>
|
||||
* @copyright vesta 2010-2011
|
||||
*/
|
||||
class Message
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue