\
\
@@ -572,7 +580,7 @@ App.Templates.html = {
\
\
diff --git a/web/js/validators.js b/web/js/validators.js
index 82ebd28c..8b1902c0 100644
--- a/web/js/validators.js
+++ b/web/js/validators.js
@@ -25,9 +25,25 @@ App.Validate.getFieldName = function(elm)
}
App.Validate.Rule = {
+ 'statslogin' : function(elm) {
+ if (!!$('#stats-auth-enable').attr('checked') == true) {
+ if ($(elm).val().trim() == '' || $(elm).val().search(/[^a-zA-Z_]+/) != -1) {
+ return {VALID: false, ERROR: App.Validate.getFieldName(elm) + ' is invalid'};
+ }
+ }
+ return {VALID: true};
+ },
+ 'statspassword': function(elm) {
+ if (!!$('#stats-auth-enable').attr('checked') == true) {
+ if ($(elm).val().trim() == '') {
+ return {VALID: false, ERROR: App.Validate.getFieldName(elm) + ' is required'};
+ }
+ }
+ return {VALID: true};
+ },
'username' : function(elm) {
if ($(elm).val().trim() != '' && $(elm).val().search(/[^a-zA-Z_]+/) != -1) {
- return {VALID: false, ERROR: App.Validate.getFieldName(elm) + ' is required'};
+ return {VALID: false, ERROR: App.Validate.getFieldName(elm) + ' is invalid'};
}
return {VALID: true};
},
@@ -173,6 +189,7 @@ App.Validate.displayFormErrors = function(world, elm)
var ref = $('.form-error', elm);
ref.removeClass('hidden');
ref.html(errors_tpl);
+ App.Helpers.scrollTo(ref);
}
App.Validate.getRules = function(elm)
@@ -180,7 +197,8 @@ App.Validate.getRules = function(elm)
try {
var rules_string = $(elm).attr('class');
var rules = [];
- $(rules_string.split(/\s/)).each(function(i, str)
+ var rules_splitted = rules_string.split(/\s/);
+ $(rules_splitted).each(function(i, str)
{
var rule = str.split('rule-');
if (rule.length > 1) {
diff --git a/web/vesta/api/AjaxHandler.php b/web/vesta/api/AjaxHandler.php
index c3f23e9d..beab6ff7 100644
--- a/web/vesta/api/AjaxHandler.php
+++ b/web/vesta/api/AjaxHandler.php
@@ -13,6 +13,7 @@ class AjaxHandler {
static public $instance = null;
const JSON = 'json';
+ const TEXT = 'text';
public $errors = array();
public $status = TRUE;
diff --git a/web/vesta/api/MAIN.class.php b/web/vesta/api/MAIN.class.php
index 44ad6d1a..ad417d37 100644
--- a/web/vesta/api/MAIN.class.php
+++ b/web/vesta/api/MAIN.class.php
@@ -43,7 +43,7 @@ class MAIN extends AjaxHandler
*/
public function getInitialExecute(Request $request)
{
- require_once V_ROOT_DIR . 'api/IP.class.php';
+ /*require_once V_ROOT_DIR . 'api/IP.class.php';
require_once V_ROOT_DIR . 'api/USER.class.php';
// IP
$ip_obj = new IP();
@@ -62,46 +62,96 @@ class MAIN extends AjaxHandler
$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);
+ $data_users = array('user_names' => $user_names);*/
+ $user = VestaSession::getInstance()->getUser();
+ $global_data = array();
+ $totals = array(
+ 'USER' => array('total' => 0, 'blocked' => 0),
+ 'WEB_DOMAIN' => array('total' => 0, 'blocked' => 0),
+ 'MAIL' => array('total' => 0),
+ 'DB' => array('total' => 0, 'blocked' => 0),
+ 'DNS' => array('total' => 0, 'blocked' => 0),
+ 'IP' => array('total' => 0, 'blocked' => 0),
+ 'CRON' => array('total' => 0, 'blocked' => 0)
+ );
- $reply = array(
- 'WEB_DOMAIN' => $this->getWebDomainParams($data_web_domain),
+ // users
+ $rs = Vesta::execute(Vesta::V_LIST_SYS_USERS, null, self::JSON);
+ $data_user = $rs['data'];
+ $global_data['users'] = array();
+ foreach ($data_user as $login_name => $usr) {
+ $totals['USER']['total'] += 1;
+ if ($usr['SUSPENDED'] != 'yes') {
+ $global_data['users'][$login_name] = $login_name;
+ }
+ else {
+ $totals['USER']['blocked'] += 1;
+ }
+ }
+ // web_domains
+ $rs = Vesta::execute(Vesta::V_LIST_WEB_DOMAINS, array('USER' => $user['uid']), self::JSON);
+ $data_web_domain = $rs['data'];
+ foreach ($data_web_domain as $web) {
+ $totals['WEB_DOMAIN']['total'] += 1;
+ }
+ // db
+ $rs = Vesta::execute(Vesta::V_LIST_DB_BASES, array('USER' => $user['uid']), self::JSON);
+ $data_db = $rs['data'];
+ foreach ($data_db as $db) {
+ $totals['DB']['total'] += 1;
+ //$db['SUSPENDED'] == 'yes' ? $totals['DB']['blocked'] += 1 : false;
+ }
+ // dns
+ $rs = Vesta::execute(Vesta::V_LIST_DNS_DOMAINS, array('USER' => $user['uid']), self::JSON);
+ $data_dns = $rs['data'];
+ foreach ($data_dns as $dns) {
+ $totals['DNS']['total'] += 1;
+ }
+ // ip
+ $global_data['ips'] = array();
+ $rs = Vesta::execute(Vesta::V_LIST_SYS_IPS, null, self::JSON);
+ $data_ip = $rs['data'];
+ foreach ($data_ip as $ip => $obj) {
+ $totals['IP']['total'] += 1;
+ $global_data['ips'][$ip] = $ip;
+ }
+ // cron
+ $rs = Vesta::execute(Vesta::V_LIST_CRON_JOBS, array('USER' => $user['uid']), self::JSON);
+ $data_cron = $rs['data'];
+ foreach ($data_cron as $cron) {
+ $totals['CRON']['total'] += 1;
+ $cron['SUSPEND'] == 'yes' ? $totals['CRON']['blocked'] += 1 : false;
+ }
+
+ $reply = array(
+ 'WEB_DOMAIN' => $this->getWebDomainParams($data_web_domin, $global_data),
'CRON' => $this->getCronParams(),
- 'IP' => $this->getIpParams($data_ip),
+ 'IP' => $this->getIpParams($data_ip, $global_data),
'DNS' => $this->getDnsParams(),
'DB' => $this->getDbParams($data_db),
- 'USERS' => $this->getUsersParams($data_users),
- 'totals' => $this->getTotals()
+ 'USERS' => $this->getUsersParams($data_user),
+ 'totals' => $totals
);
return $this->reply(true, $reply);
}
- //
- //
- //
-
- public function getTotals($data = array())
- {
- return array(
- 'USER' => array('total' => 7, 'blocked' => 0),
- 'WEB_DOMAIN' => array('total' => 4, 'blocked' => 0),
- 'MAIL' => array('total' => 0),
- 'DB' => array('total' => 4, 'blocked' => 0),
- 'DNS' => array('total' => 4, 'blocked' => 0),
- 'IP' => array('total' => 2, 'blocked' => 0),
- 'CRON' => array('total' => 5, 'blocked' => 0)
- );
- }
-
/**
* WEB DOMAIN initial params
*
* @params array $data
* @return array
*/
- public function getWebDomainParams($data = array())
+ public function getWebDomainParams($data, $global_data)
{
+ $user = $this->getLoggedUser();
+ $ips = array();
+ //v_list_sys_user_ips vesta
+ $result = Vesta::execute(Vesta::V_LIST_SYS_USER_IPS, array('USER' => $user['uid']), self::JSON);
+ foreach ($result['data'] as $sys_ip => $ip_data) {
+ $ips[$sys_ip] = $sys_ip;
+ }
+
return array(
'TPL' => array('default' => 'default'),
'ALIAS' => array(),
@@ -109,8 +159,8 @@ class MAIN extends AjaxHandler
'webalizer' => 'webalizer',
'awstats' => 'awstats'
),
- 'IP' => $data['ips']
- );
+ 'IP' => $ips
+ );
}
/**
@@ -130,19 +180,23 @@ class MAIN extends AjaxHandler
* @params array $data
* @return array
*/
- public function getIpParams($data = array())
+ public function getIpParams($data = array(), $global_data = array())
{
- $users = array();
- foreach ((array)$data['user_names'] as $user) {
- $users[$user] = $user;
- }
+ $ifaces = array();
+ $result = Vesta::execute(Vesta::V_LIST_SYS_INTERFACES, array(Config::get('response_type')));
+
+ foreach ($result['data'] as $iface) {
+ $ifaces[$iface] = $iface;
+ }
+
return array(
'SYS_USERS' => $users,
'STATUSES' => array(
'shared' => 'shared',
'exclusive' => 'exclusive'
),
- 'INTERFACES' => $data['interfaces'],
+ 'INTERFACES' => $ifaces,
+ 'OWNER' => $global_data['users'],
'MASK' => array(
'255.255.255.0' => '255.255.255.0',
'255.255.255.128' => '255.255.255.128',
@@ -152,8 +206,7 @@ class MAIN extends AjaxHandler
'255.255.255.248' => '255.255.255.248',
'255.255.255.252' => '255.255.255.252',
'255.255.255.255' => '255.255.255.255'
- ),
- 'OWNER' => array('Chuck Norris' => 'Chuck Norris')
+ )
);
}
@@ -211,14 +264,12 @@ class MAIN extends AjaxHandler
'ROLE' => array('user' => 'user'),
'OWNER' => $data['user_names'],
'PACKAGE' => array('default' => 'default'),
- 'NS1' => array('' => ''),
- 'NS2' => array('' => ''),
'SHELL' => array(
- '/bin/sh' => '/bin/sh',
- '/bin/bash' => '/bin/bash',
- '/sbin/nologin' => '/sbin/nologin',
- '/bin/tcsh' => '/bin/tcsh',
- '/bin/csh' => '/bin/csh')
+ 'sh' => 'sh',
+ 'bash' => 'bash',
+ 'nologin' => 'nologin',
+ 'tcsh' => 'tcsh',
+ 'csh' => 'csh')
);
}
diff --git a/web/vesta/api/USER.class.php b/web/vesta/api/USER.class.php
index 784c3229..eac8b9c9 100644
--- a/web/vesta/api/USER.class.php
+++ b/web/vesta/api/USER.class.php
@@ -21,20 +21,23 @@ class USER extends AjaxHandler
{
$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['data'] as $user => $details) {
+ // get reports attribute
+ $result_report = Vesta::execute(Vesta::V_GET_SYS_USER_VALUE, array('USER' => $user, 'VALUE' => 'reports'), self::TEXT);
+ if ($result_report['status'] != true) {
+ $report = null;
+ }
+ else {
+ $report = $result_report['data'];
+ }
$fullname_id = rand(0, count($users)-1);
$fullname = implode('', array($details['FNAME'], ' ', $details['LNAME']));
$nses = $this->getNS($user, $details);
$user_details = array(
- "FNAME" => $details['FNAME'],
- "LNAME" => $details['LNAME'],
+ "FNAME" => $details['FNAME'],
+ "LNAME" => $details['LNAME'],
"LOGIN_NAME" => $user,
"FULLNAME" => $fullname,
"PACKAGE" => $details['PACKAGE'],
@@ -68,7 +71,7 @@ class USER extends AjaxHandler
"DATE" => $details['DATE'],
"U_MAIL_BOXES" => rand(1, 10), // TODO: skid
"U_MAIL_FORWARDERS" => rand(1, 10), // TODO: skid
- "REPORTS_ENABLED" => 'enabled' // TODO: skid
+ "REPORTS_ENABLED" => $report
);
$reply[$user] = array_merge($user_details, $nses);
}
@@ -103,7 +106,9 @@ class USER extends AjaxHandler
$reports_result = $this->setUserReports($spell['LOGIN_NAME'], $spell['REPORTS_ENABLED']);
// NS
$ns_result = $this->setNSentries($spell['LOGIN_NAME'], $spell);
-
+ // Set SHELL
+ $this->setShell($spell['LOGIN_NAME'], $spell['SHELL']);
+
if (!$result['status']) {
$this->errors[] = array($result['error_code'] => $result['error_message']);
}
@@ -147,7 +152,7 @@ class USER extends AjaxHandler
$_USER = $_old['LOGIN_NAME'];
- if ($_old['PASSWORD'] != $_new['PASSWORD']) {
+ if (!empty($_new['PASSWORD']) && $_new['PASSWORD'] != Vesta::SAME_PASSWORD) {
$result = array();
$result = Vesta::execute(Vesta::V_CHANGE_SYS_USER_PASSWORD, array('USER' => $_USER, 'PASSWORD' => $_new['PASSWORD']));
if (!$result['status']) {
@@ -174,14 +179,17 @@ class USER extends AjaxHandler
}
}
+ // Set SHELL
+ $this->setShell($_USER, $_new['SHELL']);
+
$this->setNSentries($_USER, $_new);
$names = array(
'USER' => $_USER,
- 'NAME' => $_new['LOGIN_NAME'],
'FNAME' => $_new['FNAME'],
'LNAME' => $_new['LNAME']
);
+
$result = Vesta::execute(Vesta::V_CHANGE_SYS_USER_NAME, $names);
if (!$result['status']) {
$this->status = FALSE;
@@ -251,4 +259,11 @@ class USER extends AjaxHandler
return $result;
}
+ /**
+ * TODO: handle result set errors
+ */
+ protected function setShell($user, $shell)
+ {
+ $result = Vesta::execute(Vesta::V_CHANGE_SYS_USER_SHELL, array('USER' => $user, 'SHELL' => $shell));
+ }
}
diff --git a/web/vesta/api/WEB_DOMAIN.class.php b/web/vesta/api/WEB_DOMAIN.class.php
index 8b5fdbf9..f2f28599 100644
--- a/web/vesta/api/WEB_DOMAIN.class.php
+++ b/web/vesta/api/WEB_DOMAIN.class.php
@@ -15,10 +15,11 @@ class WEB_DOMAIN extends AjaxHandler
$user = $this->getLoggedUser();
$reply = array();
- $result = Vesta::execute(Vesta::V_LIST_WEB_DOMAINS, array($user['uid'], Config::get('response_type')));
+ $result = Vesta::execute(Vesta::V_LIST_WEB_DOMAINS, array('USER' => $user['uid']), self::JSON);
- foreach($result['data'] as $web_domain => $data)
+ foreach($result['data'] as $web_domain => $record)
{
+//print '
';var_dump($record);die();
$reply[$web_domain] = array(
'IP' => $record['IP'],
'U_DISK' => $record['U_DISK'],
@@ -66,7 +67,7 @@ class WEB_DOMAIN extends AjaxHandler
$this->errors[] = array($result['error_code'] => $result['error_message']);
}
- if ($_s['TPL']) {
+ if (!empty($_s['TPL'])) {
$params = array(
'USER' => $user['uid'],
'DOMAIN' => $_s['DOMAIN'],
@@ -80,8 +81,9 @@ class WEB_DOMAIN extends AjaxHandler
}
}
- if ($_s['ALIAS']) {
- $alias_arr = explode(',', $_s['ALIAS']);
+ if (!empty($_s['ALIAS'])) {
+ $alias = str_replace("\n", "", $_s['ALIAS']);
+ $alias = str_replace("\n", "", $alias);
foreach ($alias_arr as $alias) {
$params = array(
@@ -99,11 +101,11 @@ class WEB_DOMAIN extends AjaxHandler
}
}
- if ($_s['STAT']) {
+ if (!empty($_s['STATS'])) {
$params = array(
'USER' => $user['uid'],
'DOMAIN' => $_s['DOMAIN'],
- 'STAT' => $_s['STAT']);
+ 'STAT' => $_s['STATS'] == 'off' ? false : true);
$result = 0;
$result = Vesta::execute(Vesta::V_ADD_WEB_DOMAIN_STAT, $params);
@@ -112,7 +114,7 @@ class WEB_DOMAIN extends AjaxHandler
}
}
- if ($_s['STAT_AUTH']) {
+ if (!empty($_s['STAT_AUTH'])) {
$params = array(
'USER' => $user['uid'],
'DOMAIN' => $_s['DOMAIN'],
@@ -126,8 +128,7 @@ class WEB_DOMAIN extends AjaxHandler
$this->errors['STAT_AUTH'] = array($result['error_code'] => $result['error_message']);
}
- if (0) {
- if ($_s['SSL']) {
+ /* if ($_s['SSL']) {
$params = array(
'USER' => $user[''],
'DOMAIN' => $_s['DOMAIN'],
@@ -149,9 +150,9 @@ class WEB_DOMAIN extends AjaxHandler
$this->errors['SSL'] = array($result['error_code'] => $result['error_message']);
}
}
- }
+ */
- if ($_s['CREATE_DNS_DOMAIN']) {
+ /*if (!empty($_s['DNS'])) {
$params = array(
'USER' => $user['uid'],
'DNS_DOMAIN' => $_s['DOMAIN'],
@@ -166,10 +167,10 @@ class WEB_DOMAIN extends AjaxHandler
if (!$result['status']) {
$this->errors['DNS_DOMAIN'] = array($result['error_code'] => $result['error_message']);
}
- }
+ }*/
- /*
- if ($_s['CREATE_MAIL_DOMAIN']) {
+
+ /*if (!empty($_s['MAIL'])) {
$params = array(
'USER' => $_user,
'MAIL_DOMAIN' => $_s['DOMAIN'],
@@ -184,8 +185,8 @@ class WEB_DOMAIN extends AjaxHandler
$result = $mail->addExecute($params);
if (!$result['status'])
$this->errors['MAIL_DOMAIN'] = array($result['error_code'] => $result['error_message']);
- }
- */
+ }*/
+
return $this->reply($result['status'], $result['data']);
}
@@ -211,21 +212,6 @@ class WEB_DOMAIN extends AjaxHandler
'DNS_DOMAIN' => $_s['DOMAIN']
);
- require_once V_ROOT_DIR . 'api/DNS.class.php';
- $dns = new DNS();
- $result = $dns->delExecute($params);
-
- if (!$result['status'] && $result['error_code'] != 31) { // domain not found
- $this->errors['DNS'] = array($result['error_code'] => $result['error_message']);
- }
-
- require_once V_ROOT_DIR . 'api/DNS.class.php';
-
- $params = array(
- 'USER' => $user['uid'],
- 'MAIL_DOMAIN' => $_s['DOMAIN']
- );
-
return $this->reply($result['status'], $result['data']);
}
@@ -240,7 +226,7 @@ class WEB_DOMAIN extends AjaxHandler
if ($_old['IP'] != $_new['IP']) {
$result = array();
- $result = Vesta::execute(Vesta::V_CHANGE_WEB_DOMAIN_IP, array('USER' => $_user, 'DOMAIN' => $_DOMAIN, 'IP' => $_new['IP']));
+ $result = Vesta::execute(Vesta::V_CHANGE_WEB_DOMAIN_IP, array('USER' => $user['uid'], 'DOMAIN' => $_DOMAIN, 'IP' => $_new['IP']));
if (!$result['status']) {
$this->status = FALSE;
$this->errors['IP_ADDRESS'] = array($result['error_code'] => $result['error_message']);
@@ -249,7 +235,7 @@ class WEB_DOMAIN extends AjaxHandler
if ($_old['TPL'] != $_new['TPL']) {
$result = array();
- $result = Vesta::execute(Vesta::V_CHANGE_WEB_DOMAIN_TPL, array('USER' => $_user, 'DOMAIN' => $_DOMAIN, 'TPL' => $_new['TPL']));
+ $result = Vesta::execute(Vesta::V_CHANGE_WEB_DOMAIN_TPL, array('USER' => $user['uid'], 'DOMAIN' => $_DOMAIN, 'TPL' => $_new['TPL']));
if (!$result['status']) {
$this->status = FALSE;
$this->errors['TPL'] = array($result['error_code'] => $result['error_message']);
@@ -266,7 +252,7 @@ class WEB_DOMAIN extends AjaxHandler
$deleted = array_diff($old_arr, $new_arr);
foreach ($added as $alias) {
- $result = Vesta::execute(Vesta::V_ADD_WEB_DOMAIN_ALIAS, array('USER' => $_user, 'DOMAIN' => $_DOMAIN, 'ALIAS' => $alias));
+ $result = Vesta::execute(Vesta::V_ADD_WEB_DOMAIN_ALIAS, array('USER' => $user['uid'], 'DOMAIN' => $_DOMAIN, 'ALIAS' => $alias));
if (!$result['status']) {
$this->status = FALSE;
$this->errors['ADD_ALIAS'] = array($result['error_code'] => $result['error_message']);
@@ -274,7 +260,7 @@ class WEB_DOMAIN extends AjaxHandler
}
foreach ($deleted as $alias) {
- $result = Vesta::execute(Vesta::V_DEL_WEB_DOMAIN_ALIAS, array('USER' => $_user, 'DOMAIN' => $_DOMAIN, 'ALIAS' => $alias));
+ $result = Vesta::execute(Vesta::V_DEL_WEB_DOMAIN_ALIAS, array('USER' => $user['uid'], 'DOMAIN' => $_DOMAIN, 'ALIAS' => $alias));
if (!$result['status']) {
$this->status = FALSE;
$this->errors['DEL_ALIAS'] = array($result['error_code'] => $result['error_message']);
@@ -283,26 +269,26 @@ class WEB_DOMAIN extends AjaxHandler
}
- if ($_old['STAT'] != $_new['STAT']) {
+ if (!empty($_new['STAT'])) {
if ($_new['STAT'] == true) {
$result = array();
- $result = Vesta::execute(Vesta::V_ADD_WEB_DOMAIN_STAT, array('USER' => $_user, 'DOMAIN' => $_DOMAIN, 'STAT' => $_new['STAT']));
+ $result = Vesta::execute(Vesta::V_ADD_WEB_DOMAIN_STAT, array('USER' => $user['uid'], 'DOMAIN' => $_DOMAIN, 'STAT' => ($_new['STAT'] == 'off' ? false : true)));
if (!$result['status']) {
$this->status = FALSE;
$this->errors['ADD_STAT'] = array($result['error_code'] => $result['error_message']);
}
}
- if ($_new['STAT'] == false) {
+ if ($_new['STAT'] == 'off') {
$result = array();
- $result = Vesta::execute(Vesta::V_DEL_WEB_DOMAIN_STAT, array('USER' => $_user, 'DOMAIN' => $_DOMAIN));
+ $result = Vesta::execute(Vesta::V_DEL_WEB_DOMAIN_STAT, array('USER' => $user['uid'], 'DOMAIN' => $_DOMAIN));
if (!$result['status']) {
$this->status = FALSE;
$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']));
+ $result = Vesta::execute(Vesta::V_DEL_WEB_DOMAIN_STAT_AUTH, array('USER' => $user['uid'], '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']);
@@ -313,7 +299,7 @@ class WEB_DOMAIN extends AjaxHandler
if ($_old['CGI'] != $_new['CGI']) {
if ($_new['CGI'] == true) {
$result = array();
- $result = Vesta::execute(Vesta::V_ADD_WEB_DOMAIN_CGI, array('USER' => $_user, 'DOMAIN' => $_DOMAIN));
+ $result = Vesta::execute(Vesta::V_ADD_WEB_DOMAIN_CGI, array('USER' => $user['uid'], 'DOMAIN' => $_DOMAIN));
if (!$result['status']) {
$this->status = FALSE;
$this->errors['ADD_CGI'] = array($result['error_code'] => $result['error_message']);
@@ -322,7 +308,7 @@ class WEB_DOMAIN extends AjaxHandler
if ($_new['CGI'] == false) {
$result = array();
- $result = Vesta::execute(Vesta::V_DEL_WEB_DOMAIN_CGI, array('USER' => $_user, 'DOMAIN' => $_DOMAIN));
+ $result = Vesta::execute(Vesta::V_DEL_WEB_DOMAIN_CGI, array('USER' => $user['uid'], 'DOMAIN' => $_DOMAIN));
if (!$result['status']) {
$this->status = FALSE;
$this->errors['DEL_CGI'] = array($result['error_code'] => $result['error_message']);
@@ -333,7 +319,7 @@ class WEB_DOMAIN extends AjaxHandler
if ($_old['ELOG'] != $_new['ELOG']) {
if ($_new['ELOG'] == true) {
$result = array();
- $result = Vesta::execute(Vesta::V_ADD_WEB_DOMAIN_ELOG, array('USER' => $_user, 'DOMAIN' => $_DOMAIN));
+ $result = Vesta::execute(Vesta::V_ADD_WEB_DOMAIN_ELOG, array('USER' => $user['uid'], 'DOMAIN' => $_DOMAIN));
if (!$result['status']) {
$this->status = FALSE;
$this->errors['ADD_ELOG'] = array($result['error_code'] => $result['error_message']);
@@ -342,7 +328,7 @@ class WEB_DOMAIN extends AjaxHandler
if ($_new['ELOG'] == false) {
$result = array();
- $result = Vesta::execute(Vesta::V_DEL_WEB_DOMAIN_ELOG, array('USER' => $_user, 'DOMAIN' => $_DOMAIN));
+ $result = Vesta::execute(Vesta::V_DEL_WEB_DOMAIN_ELOG, array('USER' => $user['uid'], 'DOMAIN' => $_DOMAIN));
if (!$result['status']) {
$this->status = FALSE;
$this->errors['DEL_ELOG'] = array($result['error_code'] => $result['error_message']);
@@ -361,7 +347,7 @@ class WEB_DOMAIN extends AjaxHandler
$user = $this->getLoggedUser();
$params = array(
- 'USER' => $_user['uid'],
+ 'USER' => $user['uid'],
'DOMAIN' => $_s['DOMAIN']
);
diff --git a/web/vesta/app.init.php b/web/vesta/app.init.php
index a4aa2976..f3751944 100644
--- a/web/vesta/app.init.php
+++ b/web/vesta/app.init.php
@@ -3,6 +3,7 @@
define('V_ROOT_DIR', dirname(__FILE__) . DIRECTORY_SEPARATOR);
require_once V_ROOT_DIR . 'config/Config.class.php';
+require_once V_ROOT_DIR . 'core/utils/Utils.class.php';
require_once V_ROOT_DIR . 'core/VestaSession.class.php';
require_once V_ROOT_DIR . 'core/Vesta.class.php';
require_once V_ROOT_DIR . 'core/exceptions/SystemException.class.php';
@@ -21,7 +22,7 @@ require_once V_ROOT_DIR . 'api/AjaxHandler.php';
try {
// Execution
AjaxHandler::makeReply(
- AjaxHandler::getInstance()->dispatch(new Request())
+ AjaxHandler::getInstance()->dispatch(new Request())
);
}
//
diff --git a/web/vesta/core/Vesta.class.php b/web/vesta/core/Vesta.class.php
index 6ac71519..cfe3fafe 100644
--- a/web/vesta/core/Vesta.class.php
+++ b/web/vesta/core/Vesta.class.php
@@ -11,6 +11,8 @@
*/
class Vesta
{
+ const SAME_PASSWORD = '********';
+
// IP
const V_LIST_SYS_IPS = 'v_list_sys_ips';
const V_ADD_SYS_IP = 'v_add_sys_ip';
@@ -46,6 +48,7 @@ class Vesta
const V_DEL_CRON_JOB = 'v_del_sys_cron';
const V_DEL_SYS_USER_REPORTS = 'v_del_sys_user_reports';
// USER
+ const V_GET_SYS_USER_VALUE = 'v_get_sys_user_value';
const V_LIST_SYS_USERS = 'v_list_sys_users';
const V_ADD_SYS_USER = 'v_add_sys_user';
const V_CHANGE_SYS_USER_CONTACT = 'v_change_sys_user_contact';
@@ -57,6 +60,7 @@ class Vesta
const V_DEL_SYS_USER = 'v_del_sys_user';
const V_CHANGE_SYS_USER_NAME = 'v_change_sys_user_name';
// WEB_DOMAIN
+ const V_LIST_SYS_USER_IPS = 'v_list_sys_user_ips';
const V_LIST_WEB_DOMAINS = 'v_list_web_domains';
const V_LIST_WEB_DOMAINS_ALIAS = 'v_list_web_domains_alias';
const V_LIST_WEB_DOMAINS_ELOG = 'v_list_web_domains_elog';
@@ -93,6 +97,7 @@ class Vesta
// DB
const V_LIST_DB_BASES = 'v_list_db_bases';
const V_LIST_DB_HOSTS = 'v_list_db_hosts';
+ const V_LIST_WEB_DOMAIN_ALIAS = 'v_list_web_domain_alias';
const V_ADD_DB_BASE = 'v_add_db_base';
const V_ADD_DB_HOST = 'v_add_db_host';
const V_SUSPEND_DB_BASE = 'v_suspend_db_base';
@@ -113,7 +118,7 @@ class Vesta
* @param array $parameters
* @return string
*/
- static function execute($cmd_command, $parameters=array())
+ static function execute($cmd_command, $parameters=array(), $reply = '')
{
$r = new Request();
$_DEBUG = $r->getParameter("debug", FALSE);
@@ -125,16 +130,12 @@ class Vesta
$params = array(
'sudo' => Config::get('sudo_path'),
'functions' => Config::get('vesta_functions_path'),
- 'parameters' => implode("' '", $parameters),
+ 'parameters' => is_array($parameters) ? "'".implode("' '", $parameters)."'" : $parameters,
+ 'reply' => $reply
);
- if (!isset($params['reply'])) {
- $params['reply'] = '';
- }
-
// e.g.: /usr/bin/sudo /usr/local/vesta/bin/v_list_sys_users vesta json
- $cmd = "{$params['sudo']} {$params['functions']}{$cmd_command} '{$params['parameters']}' {$params['reply']}";
-// print $cmd;//die();
+ $cmd = "{$params['sudo']} {$params['functions']}{$cmd_command} {$params['parameters']} {$params['reply']}";
exec($cmd, $output, $return);
$result = 0;
@@ -152,7 +153,7 @@ class Vesta
"output" => $output,
"return" => $return
);
- if ($debug == 2) {
+ if ($_DEBUG == 2) {
echo ''.$cmd;
echo '
output: '; print_r($output);
echo '
return: '.$return;
@@ -164,8 +165,14 @@ class Vesta
$result['status'] = FALSE;
$result['error_code'] = (int)$return;
$result['error_message'] = implode('', $output);
+
+ return $result;
}
- else {
+
+ if ($reply == 'text') {
+ $result['data'] = implode('', $output);
+ }
+ else {
$result['data'] = json_decode(implode('', $output), true);
}