mirror of
https://github.com/myvesta/vesta
synced 2025-07-30 11:39:44 -07:00
Session handling
This commit is contained in:
parent
e1011048bd
commit
b1ea8b2726
10 changed files with 243 additions and 91 deletions
|
@ -1,3 +1,26 @@
|
|||
App.Actions.authorize = function()
|
||||
{
|
||||
if ($('#authorize-form').length > 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
App.View.popup('login');
|
||||
}
|
||||
|
||||
App.Actions.do_authorise = function()
|
||||
{
|
||||
$('#authorize-error').text('');
|
||||
App.Ajax.request('MAIN.signin', {'login':$('#authorize-login').val(), 'password':$('#authorize-login'.val())}, function(reply)
|
||||
{
|
||||
if (reply.result) {
|
||||
location.href = '';
|
||||
}
|
||||
else {
|
||||
$('#authorize-error').text(reply.message);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
App.Actions.delete_entry = function(evt)
|
||||
{
|
||||
var confirmed = confirm(App.i18n.getMessage('confirm'));
|
||||
|
@ -351,3 +374,14 @@ App.Actions.view_template_info = function(evt)
|
|||
}
|
||||
});
|
||||
}
|
||||
|
||||
App.Actions.toggle_stats_block = function(evt)
|
||||
{
|
||||
var elm = $(evt.target);
|
||||
if (!!elm.attr('checked')) {
|
||||
elm.parents('.stats-settings').find('.stats-block').removeClass('hidden');
|
||||
}
|
||||
else {
|
||||
elm.parents('.stats-settings').find('.stats-block').addClass('hidden');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -191,8 +191,9 @@ App.Ajax.request = function(jedi_method, data, callback)
|
|||
reply = jsonParse(reply);
|
||||
|
||||
if (reply.result == 'NOT_AUTHORISED') {
|
||||
|
||||
return alert('NOT AUTH');
|
||||
$('#content').html('<center><h1 style="font-size: 18px;color:red;">Not Authorized</h1></center>');
|
||||
App.Helpers.afterAjax();
|
||||
return App.Actions.authorize();
|
||||
}
|
||||
|
||||
//timer.start();
|
||||
|
|
|
@ -296,6 +296,13 @@ App.HTML.Build.web_domain_entry = function(o, key)
|
|||
}
|
||||
tpl.set(':SUSPENDED_TPL', sub_tpl.finalize());
|
||||
|
||||
if (o.STATS_LOGIN.trim() != '') {
|
||||
tpl.set(':STATS_AUTH', '+auth');
|
||||
}
|
||||
else {
|
||||
tpl.set(':STATS_AUTH', '');
|
||||
}
|
||||
|
||||
return tpl.finalize();
|
||||
}
|
||||
|
||||
|
@ -304,6 +311,12 @@ 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 in_edit = false;
|
||||
if (!App.Helpers.isEmpty(options)) {
|
||||
in_edit = true;
|
||||
}
|
||||
|
||||
var tpl = App.Templates.get('FORM', 'web_domain');
|
||||
tpl.set(':source', options);
|
||||
tpl.set(':id', id || '');
|
||||
|
@ -318,10 +331,32 @@ App.HTML.Build.web_domain_form = function(options, id)
|
|||
}
|
||||
|
||||
options = !App.Helpers.isEmpty(options) ? options : App.Empty.WEB_DOMAIN;
|
||||
|
||||
if (in_edit == true) {
|
||||
options.STATS_PASSWORD = options.STATS_LOGIN.trim() != '' ? App.Settings.PASSWORD_IMMUTE : '';
|
||||
}
|
||||
tpl = App.HTML.setTplKeys(tpl, options, true);
|
||||
tpl = App.HTML.Build.web_domain_selects(tpl, options);
|
||||
|
||||
if (options.CGI == 'yes') {
|
||||
tpl.set(':CHECKED_CGI', 'checked="checked"');
|
||||
}
|
||||
|
||||
if (options.ELOG == 'yes') {
|
||||
tpl.set(':CHECKED_ELOG', 'checked="checked"');
|
||||
}
|
||||
|
||||
if (options.STATS_LOGIN.trim() != '') {
|
||||
tpl.set(':STAT_AUTH', 'checked="checked"');
|
||||
tpl.set(':ACTIVE_LOGIN', '');
|
||||
tpl.set(':ACTIVE_PASSWORD', '');
|
||||
tpl.set(':stats_auth_checked', 'checked="checked"');
|
||||
}
|
||||
else {
|
||||
tpl.set(':ACTIVE_LOGIN', 'hidden');
|
||||
tpl.set(':ACTIVE_PASSWORD', 'hidden');
|
||||
tpl.set(':stats_auth_checked', '');
|
||||
}
|
||||
|
||||
return tpl.finalize();
|
||||
}
|
||||
|
||||
|
@ -601,6 +636,14 @@ App.HTML.Build.web_domain_selects = function(tpl, options)
|
|||
var obj = App.Env.initialParams.WEB_DOMAIN.TPL;
|
||||
var opts = App.HTML.Build.options(obj, options.TPL);
|
||||
tpl.set(':TPL_OPTIONS', opts);
|
||||
|
||||
// TPL
|
||||
var obj = App.Env.initialParams.WEB_DOMAIN.STAT;
|
||||
var opts = App.HTML.Build.options(obj, options.STAT);
|
||||
tpl.set(':STAT_OPTIONS', opts);
|
||||
|
||||
|
||||
//<input type="checkbox" name="STATS" ~!:stats_checked~!="" value="~!:STATS~!" class="not-styled">\
|
||||
}
|
||||
catch (e) {
|
||||
return tpl;
|
||||
|
|
|
@ -35,7 +35,8 @@ App.Templates.html = {
|
|||
SUSPENDED_TPL_SUSPENDED : ['<span class="ip-status-info ip-suspended-status do_action_unsuspend"><span class="ip-status-text do_action_unsuspend">suspended</span></span>']
|
||||
},
|
||||
popup: {
|
||||
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>']
|
||||
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>'],
|
||||
login: ['<div class="error" id="authorize-form"><center><h1 style="color: red;">Please authorize.</h1><hr><div id="auth-error" style="color:red"></div>Login: <input type="text" id="authorize-login" / ><br/>Password: <input type="password" id="authorize-password"/><br /><button class="do_action_do_authorize">Log in</button></center></center></div>']
|
||||
},
|
||||
dates: {
|
||||
'lock_plan_date' : ['<button class="do.savePlanDate(~!:task_id~!)">Lock plan dates</button><button class="do.lockPlanDate(~!:task_id~!)">Lock plan dates</button>'],
|
||||
|
@ -511,13 +512,11 @@ App.Templates.html = {
|
|||
</select>\
|
||||
</div>\
|
||||
</div>\
|
||||
<div class="form-row cc">\
|
||||
<label for="#" class="field-label">CGI:</label>\
|
||||
<input type="checkbox" value="~!:CGI~!" ~!:CHECKED_CGI~! name="CGI" class="not-styled">\
|
||||
</div>\
|
||||
<div class="form-row cc">\
|
||||
<label for="#" class="field-label">ELOG:</label>\
|
||||
<input type="checkbox" value="~!:ELOG~!" ~!:CHECKED_ELOG~! name="ELOG" class="not-styled">\
|
||||
<div class="form-row cc adv_opts">\
|
||||
<label for="#" class="field-label">template:</label>\
|
||||
<select class="not-styled" name="TPL">\
|
||||
~!:TPL_OPTIONS~!\
|
||||
</select>\
|
||||
</div>\
|
||||
<!-- advanced options -->\
|
||||
<div class="form-options-group">\
|
||||
|
@ -527,11 +526,13 @@ App.Templates.html = {
|
|||
</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 class="form-row cc">\
|
||||
<label for="#" class="field-label">CGI:</label>\
|
||||
<input type="checkbox" value="~!:CGI~!" ~!:CHECKED_CGI~! name="CGI" class="not-styled">\
|
||||
</div>\
|
||||
<div class="form-row cc">\
|
||||
<label for="#" class="field-label">ELOG:</label>\
|
||||
<input type="checkbox" value="~!:ELOG~!" ~!:CHECKED_ELOG~! name="ELOG" class="not-styled">\
|
||||
</div>\
|
||||
<div class="form-row cc">\
|
||||
<label for="#" class="field-label">alias list:</label>\
|
||||
|
@ -539,18 +540,18 @@ App.Templates.html = {
|
|||
</div>\
|
||||
<div class="form-row cc">\
|
||||
<label for="#" class="field-label">statistics:</label>\
|
||||
<input type="checkbox" name="STATS" ~!:stats_checked~!="" value="~!:STATS~!" class="not-styled">\
|
||||
<select name="STAT">~!:STAT_OPTIONS~!</select>\
|
||||
</div>\
|
||||
<div class="stats-settings">\
|
||||
<div class="form-row cc">\
|
||||
<label for="#" class="field-label">stats auth:</label>\
|
||||
<input id="stats-auth-enable" type="checkbox" name="STATS_AUTH" ~!:stats_auth_checked~!="" value="~!:STATS_AUTH~!" class="not-styled">\
|
||||
<input id="stats-auth-enable" type="checkbox" name="STATS_AUTH" ~!:stats_auth_checked~!="" value="~!:STATS_AUTH~!" class="not-styled do_action_toggle_stats_block">\
|
||||
</div>\
|
||||
<div class="form-row cc">\
|
||||
<div class="form-row stats-block ~!:ACTIVE_LOGIN~! cc">\
|
||||
<label for="#" class="field-label">stats login:</label>\
|
||||
<input type="text" class="text-field rule-statslogin" name="STATS_LOGIN" value="~!:STATS_LOGIN~!">\
|
||||
</div>\
|
||||
<div class="form-row pwd-box cc">\
|
||||
<div class="form-row pwd-box ~!:ACTIVE_PASSWORD~! stats-block cc">\
|
||||
<label for="#" class="field-label">password:</label>\
|
||||
<input type="text" value="~!:STATS_PASSWORD~!" name="STATS_PASSWORD" class="text-field rule-statspassword password">\
|
||||
<span class="generate-pwd do_action_generate_pass">Generate</span>\
|
||||
|
@ -576,7 +577,7 @@ App.Templates.html = {
|
|||
</div>\
|
||||
</div><!-- // advanced options -->\
|
||||
</div>\
|
||||
<div class="form-options-group">\
|
||||
<div class="form-options-group hidden">\
|
||||
<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>\
|
||||
|
@ -588,7 +589,7 @@ App.Templates.html = {
|
|||
<input type="checkbox" value="~!:DNS~!" ~!:CHECKED_DNS~! name="DNS" class="not-styled">\
|
||||
</div>\
|
||||
</div><!-- DNS options -->\
|
||||
<div class="form-options-group">\
|
||||
<div class="form-options-group hidden">\
|
||||
<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>\
|
||||
|
@ -678,7 +679,7 @@ App.Templates.html = {
|
|||
</span>\
|
||||
<span class="prop-box stats-box">\
|
||||
<span class="prop-title">stats:</span>\
|
||||
<span class="prop-value">~!:STATS~!</span>\
|
||||
<span class="prop-value">~!:STAT~!</span>\
|
||||
<span class="stats-auth stats-auth-on">\
|
||||
<span class="stats-auth-text">~!:STATS_AUTH~!</span>\
|
||||
</span>\
|
||||
|
|
|
@ -30,7 +30,7 @@ App.Validate.Rule = {
|
|||
if ($(elm).val().trim() == '' || $(elm).val().search(/[^a-zA-Z_]+/) != -1) {
|
||||
return {VALID: false, ERROR: App.Validate.getFieldName(elm) + ' is invalid'};
|
||||
}
|
||||
if ($(elm).val().trim() != '' || $(elm).val().length > App.Settings.FIELD_MAX_LEN) {
|
||||
if ($(elm).val().trim() != '' && $(elm).val().length > App.Settings.FIELD_MAX_LEN) {
|
||||
return {VALID: false, ERROR: App.Validate.getFieldName(elm) + ' too long'};
|
||||
}
|
||||
}
|
||||
|
@ -41,7 +41,7 @@ App.Validate.Rule = {
|
|||
if ($(elm).val().trim() == '') {
|
||||
return {VALID: false, ERROR: App.Validate.getFieldName(elm) + ' is required'};
|
||||
}
|
||||
if ($(elm).val().trim() != '' || $(elm).val().length > App.Settings.FIELD_MAX_LEN) {
|
||||
if ($(elm).val().trim() != '' && $(elm).val().length > App.Settings.FIELD_MAX_LEN) {
|
||||
return {VALID: false, ERROR: App.Validate.getFieldName(elm) + ' too long'};
|
||||
}
|
||||
}
|
||||
|
@ -51,7 +51,7 @@ App.Validate.Rule = {
|
|||
if ($(elm).val().trim() != '' && $(elm).val().search(/[^a-zA-Z_]+/) != -1) {
|
||||
return {VALID: false, ERROR: App.Validate.getFieldName(elm) + ' is invalid'};
|
||||
}
|
||||
if ($(elm).val().trim() != '' || $(elm).val().length > App.Settings.FIELD_MAX_LEN) {
|
||||
if ($(elm).val().trim() != '' && $(elm).val().length > App.Settings.FIELD_MAX_LEN) {
|
||||
return {VALID: false, ERROR: App.Validate.getFieldName(elm) + ' too long'};
|
||||
}
|
||||
return {VALID: true};
|
||||
|
@ -78,7 +78,7 @@ App.Validate.Rule = {
|
|||
if ($(elm).val().trim() != '' && $(elm).val().search(/[^a-zA-Z]+/) != -1) {
|
||||
return {VALID: false, ERROR: App.Validate.getFieldName(elm) + ' must contain only letters without spaces or other symbols'};
|
||||
}
|
||||
if ($(elm).val().trim() != '' || $(elm).val().length > App.Settings.FIELD_MAX_LEN) {
|
||||
if ($(elm).val().trim() != '' && $(elm).val().length > App.Settings.FIELD_MAX_LEN) {
|
||||
return {VALID: false, ERROR: App.Validate.getFieldName(elm) + ' too long'};
|
||||
}
|
||||
return {VALID: true};
|
||||
|
@ -87,7 +87,7 @@ App.Validate.Rule = {
|
|||
if ($(elm).val().search(/^\s*[\w\-\+_]+(\.[\w\-\+_]+)*\@[\w\-\+_]+\.[\w\-\+_]+(\.[\w\-\+_]+)*\s*$/) == -1) {
|
||||
return {VALID: false, ERROR: App.Validate.getFieldName(elm) + ' not a valid email'};
|
||||
}
|
||||
if ($(elm).val().trim() == '' || $(elm).val().length > App.Settings.FIELD_MAX_LEN) {
|
||||
if ($(elm).val().trim() == '' && $(elm).val().length > App.Settings.FIELD_MAX_LEN) {
|
||||
return {VALID: false, ERROR: App.Validate.getFieldName(elm) + ' too long'};
|
||||
}
|
||||
return {VALID: true};
|
||||
|
@ -109,7 +109,7 @@ App.Validate.Rule = {
|
|||
if ($(elm).val().trim() != '' && (/^([a-z0-9\.])*[a-z0-9][a-z0-9\-]+[a-z0-9](\.[a-z]{2,4})+$/).test($(elm).val()) == false) {
|
||||
return {VALID: false, ERROR: App.Validate.getFieldName(elm) + ' not a valid NS name'};
|
||||
}
|
||||
if ($(elm).val().trim() == '' || $(elm).val().length > App.Settings.FIELD_MAX_LEN) {
|
||||
if ($(elm).val().trim() == '' && $(elm).val().length > App.Settings.FIELD_MAX_LEN) {
|
||||
return {VALID: false, ERROR: App.Validate.getFieldName(elm) + ' too long'};
|
||||
}
|
||||
return {VALID: true};
|
||||
|
@ -118,7 +118,7 @@ App.Validate.Rule = {
|
|||
if ($(elm).val().trim() != '' && $(elm).val().search(/[^0-9\/\*-,]+/) != -1) {
|
||||
return {VALID: false, ERROR: App.Validate.getFieldName(elm) + ' wrong minute value'};
|
||||
}
|
||||
if ($(elm).val().trim() == '' || $(elm).val().length > App.Settings.MINUTE_MAX_LEN) {
|
||||
if ($(elm).val().trim() == '' && $(elm).val().length > App.Settings.MINUTE_MAX_LEN) {
|
||||
return {VALID: false, ERROR: App.Validate.getFieldName(elm) + ' invalid'};
|
||||
}
|
||||
return {VALID: true};
|
||||
|
@ -130,7 +130,7 @@ App.Validate.Rule = {
|
|||
if ($(elm).val().trim() != '' && $(elm).val().search(/[^0-9\/\*-,]+/) != -1) {
|
||||
return {VALID: false, ERROR: App.Validate.getFieldName(elm) + ' wrong hour value'};
|
||||
}
|
||||
if ($(elm).val().trim() == '' || $(elm).val().length > App.Settings.HOURS_MAX_LEN) {
|
||||
if ($(elm).val().trim() == '' && $(elm).val().length > App.Settings.HOURS_MAX_LEN) {
|
||||
return {VALID: false, ERROR: App.Validate.getFieldName(elm) + ' invalid'};
|
||||
}
|
||||
return {VALID: true};
|
||||
|
@ -142,7 +142,7 @@ App.Validate.Rule = {
|
|||
if ($(elm).val().trim() != '' && $(elm).val().search(/[^123456\/\*-,]+/) != -1) {
|
||||
return {VALID: false, ERROR: App.Validate.getFieldName(elm) + ' wrong week day value'};
|
||||
}
|
||||
if ($(elm).val().trim() == '' || $(elm).val().length > App.Settings.WDAY_MAX_LEN) {
|
||||
if ($(elm).val().trim() == '' && $(elm).val().length > App.Settings.WDAY_MAX_LEN) {
|
||||
return {VALID: false, ERROR: App.Validate.getFieldName(elm) + ' invalid'};
|
||||
}
|
||||
return {VALID: true};
|
||||
|
@ -154,7 +154,7 @@ App.Validate.Rule = {
|
|||
if ($(elm).val().trim() != '' && $(elm).val().search(/[^0-9\/\*-,]+/) != -1) {
|
||||
return {VALID: false, ERROR: App.Validate.getFieldName(elm) + ' wrong month value'};
|
||||
}
|
||||
if ($(elm).val().trim() == '' || $(elm).val().length > App.Settings.MONTH_MAX_LEN) {
|
||||
if ($(elm).val().trim() == '' && $(elm).val().length > App.Settings.MONTH_MAX_LEN) {
|
||||
return {VALID: false, ERROR: App.Validate.getFieldName(elm) + ' invalid'};
|
||||
}
|
||||
return {VALID: true};
|
||||
|
@ -166,7 +166,7 @@ App.Validate.Rule = {
|
|||
if ($(elm).val().trim() != '' && $(elm).val().search(/[^0-9\/\*-,]+/) != -1) {
|
||||
return {VALID: false, ERROR: App.Validate.getFieldName(elm) + ' wrong day value'};
|
||||
}
|
||||
if ($(elm).val().trim() == '' || $(elm).val().length > App.Settings.DAY_MAX_LEN) {
|
||||
if ($(elm).val().trim() == '' && $(elm).val().length > App.Settings.DAY_MAX_LEN) {
|
||||
return {VALID: false, ERROR: App.Validate.getFieldName(elm) + ' invalid'};
|
||||
}
|
||||
return {VALID: true};
|
||||
|
|
|
@ -42,13 +42,14 @@ class AjaxHandler {
|
|||
public function dispatch(Request $request)
|
||||
{
|
||||
$method = Request::parseAjaxMethod($request);
|
||||
if (!in_array($method['namespace'].'.'.$method['function'], array('MAIN.signin', 'MAIN.logout'))) {
|
||||
$user = $this->getLoggedUser();
|
||||
}
|
||||
|
||||
$inc_file = V_ROOT_DIR . 'api' . DIRECTORY_SEPARATOR . $method['namespace'] . '.class.php';
|
||||
if (!is_readable($inc_file)) {
|
||||
throw new SystemException(Message::INVALID_METHOD);
|
||||
}
|
||||
|
||||
// return $this->reply('NOT_AUTHORISED');
|
||||
|
||||
require $inc_file;
|
||||
|
||||
$space = new $method['namespace'];
|
||||
|
|
|
@ -17,6 +17,8 @@
|
|||
class MAIN extends AjaxHandler
|
||||
{
|
||||
|
||||
protected $templates = null;
|
||||
|
||||
/**
|
||||
* Get Version
|
||||
*
|
||||
|
@ -34,6 +36,20 @@ class MAIN extends AjaxHandler
|
|||
return $this->reply(true, $result);
|
||||
}
|
||||
|
||||
public function signinExecute($request)
|
||||
{
|
||||
$login = $request->getParameter('login');
|
||||
$password = $request->getParameter('password');
|
||||
|
||||
$result = Vesta::execute('v_check_sys_user_password', array('USER' => $login, 'PASSWORD' => $password));
|
||||
if ($result['status'] == true) {
|
||||
return $this->reply(VestaSession::authorize($login));
|
||||
}
|
||||
else {
|
||||
return $this->reply(false, 'Incorrect login / password');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Initial params.
|
||||
* Global constants / variables / configs
|
||||
|
@ -43,26 +59,6 @@ class MAIN extends AjaxHandler
|
|||
*/
|
||||
public function getInitialExecute(Request $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_ips = json_decode($ip_obj->getListUserIpsExecute($request), TRUE);
|
||||
foreach ($user_ips['data'] as $ip) {
|
||||
$ips[$ip['IP_ADDRESS']] = $ip['IP_ADDRESS'];
|
||||
}
|
||||
// USER
|
||||
$user_obj = new USER();
|
||||
$users = json_decode($user_obj->getListExecute($request), TRUE);
|
||||
$user_names = array_keys($users['data']);
|
||||
$interfaces_arr = json_decode($ip_obj->getSysInterfacesExecute($request), 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' => $this->getDBTypes());
|
||||
$data_users = array('user_names' => $user_names);*/
|
||||
$user = VestaSession::getInstance()->getUser();
|
||||
$global_data = array();
|
||||
$totals = array(
|
||||
|
@ -136,6 +132,25 @@ class MAIN extends AjaxHandler
|
|||
return $this->reply(true, $reply);
|
||||
}
|
||||
|
||||
protected function getTemplates()
|
||||
{
|
||||
if (null != $this->templates) {
|
||||
return $this->templates;
|
||||
}
|
||||
else {
|
||||
$user = $this->getLoggedUser();
|
||||
$this->templates = array();
|
||||
//v_list_web_templates vesta json
|
||||
$result = Vesta::execute('v_list_web_templates', array('USER' => $user['uid']), self::JSON);
|
||||
// TODO: handle errors!
|
||||
foreach ($result['data'] as $tpl => $description) {
|
||||
$this->templates[$tpl] = $tpl;
|
||||
}
|
||||
|
||||
return $this->templates;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* WEB DOMAIN initial params
|
||||
*
|
||||
|
@ -146,7 +161,6 @@ class MAIN extends AjaxHandler
|
|||
{
|
||||
$user = $this->getLoggedUser();
|
||||
$ips = array();
|
||||
//v_list_sys_user_ips vesta
|
||||
$result = Vesta::execute(Vesta::V_LIST_SYS_USER_IPS, array('USER' => $user['uid']), self::JSON);
|
||||
foreach ($result['data'] as $sys_ip => $ip_data) {
|
||||
$ips[$sys_ip] = $sys_ip;
|
||||
|
@ -157,9 +171,10 @@ class MAIN extends AjaxHandler
|
|||
}
|
||||
|
||||
return array(
|
||||
'TPL' => array('default' => 'default'),
|
||||
'TPL' => $this->getTemplates(),
|
||||
'ALIAS' => array(),
|
||||
'STAT' => array(
|
||||
'none' => 'none',
|
||||
'webalizer' => 'webalizer',
|
||||
'awstats' => 'awstats'
|
||||
),
|
||||
|
@ -224,7 +239,7 @@ class MAIN extends AjaxHandler
|
|||
{
|
||||
return array(
|
||||
'IP' => @$data['ips'],
|
||||
'TPL' => array('default' => 'default'),
|
||||
'TPL' => $this->getTemplates(),
|
||||
'EXP' => array(),
|
||||
'SOA' => array(),
|
||||
'TTL' => array(),
|
||||
|
|
|
@ -17,10 +17,15 @@ class WEB_DOMAIN extends AjaxHandler
|
|||
|
||||
$result = Vesta::execute(Vesta::V_LIST_WEB_DOMAINS, array('USER' => $user['uid']), self::JSON);
|
||||
|
||||
$stat = array();
|
||||
$result_stat = Vesta::execute('v_list_web_domains_stats', array('USER' => $user['uid']), self::JSON);
|
||||
|
||||
foreach ($result_stat['data'] as $w_d => $w_d_details) {
|
||||
$stat[$w_d] = $w_d_details;
|
||||
}
|
||||
foreach($result['data'] as $web_domain => $record)
|
||||
{
|
||||
//print '<pre>';var_dump($record);die();
|
||||
$reply[$web_domain] = array(
|
||||
$web_details = array(
|
||||
'IP' => $record['IP'],
|
||||
'U_DISK' => $record['U_DISK'],
|
||||
'U_BANDWIDTH' => $record['U_BANDWIDTH'],
|
||||
|
@ -29,8 +34,8 @@ class WEB_DOMAIN extends AjaxHandler
|
|||
'PHP' => $record['PHP'],
|
||||
'CGI' => $record['CGI'],
|
||||
'ELOG' => $record['ELOG'],
|
||||
'STATS' => $record['STATS'],
|
||||
'STATS_AUTH' => $record['STATS_AUTH'],
|
||||
'STAT' => $record['STATS'],
|
||||
'STATS_LOGIN' => $record['STATS_AUTH'],
|
||||
'SSL' => $record['SSL'],
|
||||
'SSL_HOME' => $record['SSL_HOME'],
|
||||
'SSL_CERT' => $record['SSL_CERT'],
|
||||
|
@ -39,6 +44,8 @@ class WEB_DOMAIN extends AjaxHandler
|
|||
'SUSPEND' => $record['SUSPEND'],
|
||||
'DATE' => date(Config::get('ui_date_format', strtotime($record['DATE'])))
|
||||
);
|
||||
$web_details['STAT'] == '' ? $web_details['STAT'] = 'none' : true;
|
||||
$reply[$web_domain] = $web_details;
|
||||
}
|
||||
|
||||
if (!$result['status']) {
|
||||
|
@ -101,11 +108,11 @@ class WEB_DOMAIN extends AjaxHandler
|
|||
}
|
||||
}
|
||||
|
||||
if (!empty($_s['STATS'])) {
|
||||
if (!empty($_s['STATS']) && @$_s['STATS'] != 'none') {
|
||||
$params = array(
|
||||
'USER' => $user['uid'],
|
||||
'DOMAIN' => $_s['DOMAIN'],
|
||||
'STAT' => $_s['STATS'] == 'off' ? false : true);
|
||||
'STAT' => $_s['STAT']);
|
||||
$result = 0;
|
||||
$result = Vesta::execute(Vesta::V_ADD_WEB_DOMAIN_STAT, $params);
|
||||
|
||||
|
@ -114,7 +121,7 @@ class WEB_DOMAIN extends AjaxHandler
|
|||
}
|
||||
}
|
||||
|
||||
if (!empty($_s['STAT_AUTH'])) {
|
||||
if (!empty($_s['STAT_AUTH']) && @Utils::getCheckboxBooleanValue($_s['STATS_AUTH'])) {
|
||||
$params = array(
|
||||
'USER' => $user['uid'],
|
||||
'DOMAIN' => $_s['DOMAIN'],
|
||||
|
@ -128,7 +135,29 @@ class WEB_DOMAIN extends AjaxHandler
|
|||
$this->errors['STAT_AUTH'] = array($result['error_code'] => $result['error_message']);
|
||||
}
|
||||
|
||||
/* if ($_s['SSL']) {
|
||||
if (!empty($_new['CGI'])) {
|
||||
if (Utils::getCheckboxBooleanValue($_new['CGI'])) {
|
||||
$result = array();
|
||||
$result = Vesta::execute(Vesta::V_ADD_WEB_DOMAIN_CGI, array('USER' => $user['uid'], 'DOMAIN' => $_DOMAIN));
|
||||
if (!$result['status']) {
|
||||
$this->status = FALSE;
|
||||
$this->errors['ADD_CGI'] = array($result['error_code'] => $result['error_message']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($_new['ELOG'])) {
|
||||
if (Utils::getCheckboxBooleanValue($_new['ELOG'])) {
|
||||
$result = array();
|
||||
$result = Vesta::execute(Vesta::V_ADD_WEB_DOMAIN_ELOG, array('USER' => $user['uid'], 'DOMAIN' => $_DOMAIN));
|
||||
if (!$result['status']) {
|
||||
$this->status = FALSE;
|
||||
$this->errors['ADD_ELOG'] = array($result['error_code'] => $result['error_message']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*if ($_s['SSL']) {
|
||||
$params = array(
|
||||
'USER' => $user[''],
|
||||
'DOMAIN' => $_s['DOMAIN'],
|
||||
|
@ -139,10 +168,6 @@ class WEB_DOMAIN extends AjaxHandler
|
|||
$params['SSL_HOME'] = $_s['SSL_HOME'];
|
||||
}
|
||||
|
||||
if ($_s['SSL_TEXT']) {
|
||||
// TODO: implement
|
||||
}
|
||||
|
||||
$result = 0;
|
||||
$result = Vesta::execute(Vesta::V_ADD_WEB_DOMAIN_SSL, $params);
|
||||
|
||||
|
@ -150,7 +175,9 @@ class WEB_DOMAIN extends AjaxHandler
|
|||
$this->errors['SSL'] = array($result['error_code'] => $result['error_message']);
|
||||
}
|
||||
}
|
||||
*/
|
||||
if ($_s['SSL_HOME']) {
|
||||
|
||||
}*/
|
||||
|
||||
/*if (!empty($_s['DNS'])) {
|
||||
$params = array(
|
||||
|
@ -221,6 +248,11 @@ class WEB_DOMAIN extends AjaxHandler
|
|||
$_old = $request->getParameter('old');
|
||||
$_new = $request->getParameter('new');
|
||||
|
||||
$_old['ELOG'] = $_old['ELOG'] == 'yes' ? 'on' : 'off';
|
||||
$_old['CGI'] = $_old['CGI'] == 'yes' ? 'on' : 'off';
|
||||
$_old['AUTH'] = $_old['AUTH'] == 'yes' ? 'on' : 'off';
|
||||
$_old['SSL'] = $_old['SSL'] == 'yes' ? 'on' : 'off';
|
||||
|
||||
$user = $this->getLoggedUser();
|
||||
$_DOMAIN = $_new['DOMAIN'];
|
||||
|
||||
|
@ -269,17 +301,31 @@ class WEB_DOMAIN extends AjaxHandler
|
|||
}
|
||||
|
||||
|
||||
if (!empty($_new['STAT'])) {
|
||||
if ($_new['STAT'] == true) {
|
||||
if (($_old['STATH_AUTH'] != $_new['STAT_AUTH']) && !empty($_s['STAT_AUTH']) && @Utils::getCheckboxBooleanValue($_s['STATS_AUTH'])) {
|
||||
$params = array(
|
||||
'USER' => $user['uid'],
|
||||
'DOMAIN' => $_DOMAIN,
|
||||
'STAT_USER' => $_new['STAT_USER'],
|
||||
'STAT_PASSWORS' => $_new['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 (($_old['STAT'] != $_new['STAT'])) {
|
||||
if ($_new['STAT'] != 'none') {
|
||||
$result = array();
|
||||
$result = Vesta::execute(Vesta::V_ADD_WEB_DOMAIN_STAT, array('USER' => $user['uid'], 'DOMAIN' => $_DOMAIN, 'STAT' => ($_new['STAT'] == 'off' ? false : true)));
|
||||
$result = Vesta::execute(Vesta::V_ADD_WEB_DOMAIN_STAT, array('USER' => $user['uid'], 'DOMAIN' => $_DOMAIN, 'STAT' => $_new['STAT']));
|
||||
if (!$result['status']) {
|
||||
$this->status = FALSE;
|
||||
$this->errors['ADD_STAT'] = array($result['error_code'] => $result['error_message']);
|
||||
}
|
||||
}
|
||||
|
||||
if ($_new['STAT'] == 'off') {
|
||||
else {
|
||||
$result = array();
|
||||
$result = Vesta::execute(Vesta::V_DEL_WEB_DOMAIN_STAT, array('USER' => $user['uid'], 'DOMAIN' => $_DOMAIN));
|
||||
if (!$result['status']) {
|
||||
|
@ -296,8 +342,8 @@ class WEB_DOMAIN extends AjaxHandler
|
|||
}
|
||||
}
|
||||
|
||||
if ($_old['CGI'] != $_new['CGI']) {
|
||||
if ($_new['CGI'] == true) {
|
||||
if (($_old['CGI'] != $_new['CGI'])) {
|
||||
if (Utils::getCheckboxBooleanValue($_new['CGI'])) {
|
||||
$result = array();
|
||||
$result = Vesta::execute(Vesta::V_ADD_WEB_DOMAIN_CGI, array('USER' => $user['uid'], 'DOMAIN' => $_DOMAIN));
|
||||
if (!$result['status']) {
|
||||
|
@ -305,8 +351,7 @@ class WEB_DOMAIN extends AjaxHandler
|
|||
$this->errors['ADD_CGI'] = array($result['error_code'] => $result['error_message']);
|
||||
}
|
||||
}
|
||||
|
||||
if ($_new['CGI'] == false) {
|
||||
else {
|
||||
$result = array();
|
||||
$result = Vesta::execute(Vesta::V_DEL_WEB_DOMAIN_CGI, array('USER' => $user['uid'], 'DOMAIN' => $_DOMAIN));
|
||||
if (!$result['status']) {
|
||||
|
@ -316,8 +361,8 @@ class WEB_DOMAIN extends AjaxHandler
|
|||
}
|
||||
}
|
||||
|
||||
if ($_old['ELOG'] != $_new['ELOG']) {
|
||||
if ($_new['ELOG'] == true) {
|
||||
if (($_old['ELOG'] != $_new['ELOG'])) {
|
||||
if (Utils::getCheckboxBooleanValue($_new['ELOG'])) {
|
||||
$result = array();
|
||||
$result = Vesta::execute(Vesta::V_ADD_WEB_DOMAIN_ELOG, array('USER' => $user['uid'], 'DOMAIN' => $_DOMAIN));
|
||||
if (!$result['status']) {
|
||||
|
@ -325,8 +370,7 @@ class WEB_DOMAIN extends AjaxHandler
|
|||
$this->errors['ADD_ELOG'] = array($result['error_code'] => $result['error_message']);
|
||||
}
|
||||
}
|
||||
|
||||
if ($_new['ELOG'] == false) {
|
||||
else {
|
||||
$result = array();
|
||||
$result = Vesta::execute(Vesta::V_DEL_WEB_DOMAIN_ELOG, array('USER' => $user['uid'], 'DOMAIN' => $_DOMAIN));
|
||||
if (!$result['status']) {
|
||||
|
|
|
@ -12,6 +12,8 @@ require_once V_ROOT_DIR . 'core/utils/Message.class.php';
|
|||
require_once V_ROOT_DIR . 'core/Request.class.php';
|
||||
require_once V_ROOT_DIR . 'api/AjaxHandler.php';
|
||||
|
||||
VestaSession::start();
|
||||
|
||||
/**
|
||||
* App execution
|
||||
*
|
||||
|
|
|
@ -5,9 +5,9 @@ class VestaSession
|
|||
|
||||
static public $instance = null;
|
||||
|
||||
public function __construct()
|
||||
static function start()
|
||||
{
|
||||
//session_start();
|
||||
session_start();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -20,10 +20,21 @@ class VestaSession
|
|||
return null == self::$instance ? self::$instance = new self() : self::$instance;
|
||||
}
|
||||
|
||||
static function authorize($username)
|
||||
{
|
||||
$_SESSION['user'] = $username;
|
||||
return true;
|
||||
}
|
||||
|
||||
public function getUser()
|
||||
{
|
||||
//var_dump($_SESSION);die();
|
||||
return array('uid' => 'vesta');
|
||||
if (isset($_SESSION['user'])) {
|
||||
return array('uid' => $_SESSION['user']);
|
||||
}
|
||||
|
||||
print '{"result": "NOT_AUTHORISED"}';
|
||||
exit;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue