diff --git a/web/vesta/api/AjaxHandler.php b/web/vesta/api/AjaxHandler.php index 827b1328a..c3f23e9d3 100644 --- a/web/vesta/api/AjaxHandler.php +++ b/web/vesta/api/AjaxHandler.php @@ -9,11 +9,12 @@ * @copyright vesta 2010-2011 */ class AjaxHandler { - + static public $instance = null; - public $errors = array(); - public $status = TRUE; + const JSON = 'json'; + public $errors = array(); + public $status = TRUE; /** * Grab current instance or create it @@ -37,7 +38,8 @@ class AjaxHandler { * @param Request $request * @return string */ - function dispatch($request) { + public function dispatch(Request $request) + { $method = Request::parseAjaxMethod($request); $inc_file = V_ROOT_DIR . 'api' . DIRECTORY_SEPARATOR . $method['namespace'] . '.class.php'; if (!is_readable($inc_file)) { @@ -59,7 +61,8 @@ class AjaxHandler { /** * Prepare response for ajax */ - function reply($result, $data, $message = '', $extra = array()) { + public function reply($result, $data, $message = '', $extra = array()) + { return json_encode(array('result' => $result, 'data' => $data, 'message' => $message, @@ -68,7 +71,8 @@ class AjaxHandler { )); } - static function makeReply($reply) { + static function makeReply($reply) + { print $reply; } @@ -93,7 +97,7 @@ class AjaxHandler { AjaxHandler::makeReply( AjaxHandler::getInstance()->reply(false, $type, $message . ': ' . $error->getMessage(), $trace[0]['file'] . ' / ' . $trace[0]['line']) );*/ - print $message; + print $message; } } diff --git a/web/vesta/api/CRON.class.php b/web/vesta/api/CRON.class.php index d66fdee3b..e2ad7778c 100644 --- a/web/vesta/api/CRON.class.php +++ b/web/vesta/api/CRON.class.php @@ -16,7 +16,7 @@ class CRON extends AjaxHandler * @param Request $request * @return string - Ajax Reply */ - public function getListExecute($request) + public function getListExecute(Request $request) { $user = $this->getLoggedUser(); $reply = array(); @@ -32,7 +32,7 @@ class CRON extends AjaxHandler 'WDAY' => $record['WDAY'], 'SUSPENDED' => $record['SUSPEND'], 'DATE' => date(Config::get('ui_date_format', strtotime($record['DATE']))), - 'JOB' => $id + 'JOB' => $id ); } @@ -51,8 +51,8 @@ class CRON extends AjaxHandler */ public function addExecute(Request $request) { - $user = $this->getLoggedUser(); - $spell = $request->getParameter('spell'); + $user = $this->getLoggedUser(); + $spell = $request->getParameter('spell'); $params = array( 'USER' => $user['uid'], 'MIN' => $spell['MIN'], @@ -89,8 +89,8 @@ class CRON extends AjaxHandler */ public function deleteExecute(Request $request) { - $user = $this->getLoggedUser(); - $spell = $request->getParameter('spell'); + $user = $this->getLoggedUser(); + $spell = $request->getParameter('spell'); $params = array( 'USER' => $user['uid'], 'JOB' => $spell['JOB'] @@ -113,7 +113,7 @@ class CRON extends AjaxHandler */ public function changeExecute(Request $request) { - $user = $this->getLoggedUser(); + $user = $this->getLoggedUser(); $_old = $request->getParameter('old'); $_new = $request->getParameter('new'); $result = array(); @@ -147,7 +147,7 @@ class CRON extends AjaxHandler public function suspendExecute(Request $request) { $user = $this->getLoggedUser(); - $spell = $request->getParameter('spell'); + $spell = $request->getParameter('spell'); $params = array( 'USER' => $user['uid'], 'JOB' => $spell['JOB'] @@ -168,10 +168,10 @@ class CRON extends AjaxHandler * @param Request $request * @return string - Ajax Reply */ - public function unsuspendExecute($request) + public function unsuspendExecute(Request $request) { - $user = $this->getLoggedUser(); - $spell = $request->getParameter('spell'); + $user = $this->getLoggedUser(); + $spell = $request->getParameter('spell'); $params = array( 'USER' => $user['uid'], 'JOB' => $spell['JOB'] @@ -185,55 +185,5 @@ class CRON extends AjaxHandler return $this->reply($result['status'], $result['data']); } - - - /** - * Batch suspend CRON entries - * - * @param Request $request - * @return string - Ajax Reply - */ - /*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']) { - $this->errors[] = array($result['error_code'] => $result['error_message']); - } - - return $this->reply($result['status'], $result['data']); - }*/ - - /** - * Batch unsuspend CRON entries - * - * @param Request $request - * @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_CRON_JOBS, $params); - - if (!$result['status']) { - $this->errors[] = array($result['error_code'] => $result['error_message']); - } - - return $this->reply($result['status'], $result['data']); - }*/ } diff --git a/web/vesta/api/DB.class.php b/web/vesta/api/DB.class.php index d0a393294..dd34de21e 100644 --- a/web/vesta/api/DB.class.php +++ b/web/vesta/api/DB.class.php @@ -18,21 +18,21 @@ class DB extends AjaxHandler * @param Request $request * @return string - Ajax Reply */ - public function getListExecute($request) + public function getListExecute(Request $request) { - $_user = 'vesta'; + $user = $this->getLoggedUser(); $reply = array(); - $result = Vesta::execute(Vesta::V_LIST_DB_BASES, array($_user, Config::get('response_type'))); + $result = Vesta::execute(Vesta::V_LIST_DB_BASES, array($user['uid'], Config::get('response_type'))); foreach ($result['data'] as $db => $record) { $type = $record['TYPE']; if (!isset($reply[$type])) { $reply[$type] = array(); } - $reply[$type][] = array( 'DB' => $db, - 'OWNER' => 'John Travlolta', + 'OWNER' => $record['USER'], + 'USER' => $record['USER'], 'USERS' => (array)$record['USER'], 'HOST' => $record['HOST'], 'TYPE' => $record['TYPE'], @@ -47,17 +47,6 @@ class DB extends AjaxHandler $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); } @@ -67,23 +56,21 @@ class DB extends AjaxHandler * @param Request $request * @return string - Ajax Reply */ - public function addExecute($request) + public function addExecute(Request $request) { - $r = new Request(); - $_s = $r->getSpell(); - $_user = 'vesta'; - + $user = $this->getLoggedUser(); + $_s = $request->getParameter('spell'); $params = array( - 'USER' => $_user, + 'USER' => $user['uid'], 'DB' => $_s['DB'], - 'DB_USER' => $_s['DB_USER'], - 'DB_PASSWORD' => $_s['DB_PASSWORD'], + 'DB_USER' => $_s['USER'], + 'DB_PASSWORD' => $_s['PASSWORD'], 'TYPE' => $_s['TYPE'] ); - - if ($_s['HOST']) { + // TODO: do not user it. Will be used in later releases + /*if ($_s['HOST']) { $params['HOST'] = $_s['HOST']; - } + }*/ $result = Vesta::execute(Vesta::V_ADD_DB_BASE, $params); @@ -100,14 +87,13 @@ class DB extends AjaxHandler * @param Request $request * @return string - Ajax Reply */ - public function delExecute($request) + public function deleteExecute(Request $request) { - $r = new Request(); - $_s = $r->getSpell(); - $_user = 'vesta'; + $_s = $request->getParameter('spell'); + $user = $this->getLoggedUser(); $params = array( - 'USER' => $_user, - 'DB' => $_user.'_'.$_s['DB'] + 'USER' => $user['uid'], + 'DB' => $_s['DB'] ); $result = Vesta::execute(Vesta::V_DEL_DB_BASE, $params); @@ -125,16 +111,15 @@ class DB extends AjaxHandler * @param Request $request * @return string - Ajax Reply */ - public function changePasswordExecute($request) + public function changeExecute(Request $request) { - $r = new Request(); - $_s = $r->getSpell(); - $_user = 'vesta'; + $_s = $request->getParameter('new'); + $user = $this->getLoggedUser(); $result = array(); $params = array( - 'USER' => $_user, - 'DB' => $_user.'_'.$_s['DB'], - 'PASSWORD' => $_s['DB_PASSWORD'] + 'USER' => $user['uid'], + 'DB' => $_s['DB'], + 'PASSWORD' => $_s['PASSWORD'] ); $result = Vesta::execute(Vesta::V_CHANGE_DB_PASSWORD, $params); @@ -145,103 +130,5 @@ class DB extends AjaxHandler return $this->reply($result['status'], $result['data']); } - - /** - * Suspend DB entry - * - * @param Request $request - * @return string - Ajax Reply - */ - public function suspendExecute($request) - { - $r = new Request(); - $_s = $r->getSpell(); - $_user = 'vesta'; - $params = array( - 'USER' => $_user, - 'DB' => $_user.'_'.$_s['DB'] - ); - - $result = Vesta::execute(Vesta::V_SUSPEND_DB_BASE, $params); - - if (!$result['status']) { - $this->errors[] = array($result['error_code'] => $result['error_message']); - } - - return $this->reply($result['status'], $result['data']); - } - - /** - * Unsuspend DB entry - * - * @param Request $request - * @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']) { - $this->errors[] = array($result['error_code'] => $result['error_message']); - } - - return $this->reply($result['status'], $result['data']); - } - - /** - * Batch Suspend DB entries - * - * @param Request $request - * @return string - Ajax Reply - */ - 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_DB_BASES, $params); - - if (!$result['status']) { - $this->errors[] = array($result['error_code'] => $result['error_message']); - } - - return $this->reply($result['status'], $result['data']); - } - - /** - * Batch unsuspend DB entries - * - * @param Request $request - * @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']) { - $this->errors[] = array($result['error_code'] => $result['error_message']); - } - - return $this->reply($result['status'], $result['data']); - } - + } diff --git a/web/vesta/api/DNS.class.php b/web/vesta/api/DNS.class.php index 0c1e89f3b..b2c10b41e 100644 --- a/web/vesta/api/DNS.class.php +++ b/web/vesta/api/DNS.class.php @@ -20,9 +20,9 @@ class DNS extends AjaxHandler * @param Request $request * @return string - Ajax Reply */ - public function getListExecute($request) + public function getListExecute(Request $request) { - $user = $this->getLoggedUser(); + $user = $this->getLoggedUser(); $reply = array(); $result = Vesta::execute(Vesta::V_LIST_DNS_DOMAINS, array($user['uid'], Config::get('response_type'))); foreach ($result['data'] as $dns_domain => $details) { @@ -51,21 +51,27 @@ class DNS extends AjaxHandler * @param Request $request * @return string - Ajax Reply */ - public function getListRecordsExecute($request) + public function getListRecordsExecute(Request $request) { $_s = $request->getParameter('spell'); $user = $this->getLoggedUser(); $reply = array(); - $result = Vesta::execute(Vesta::V_LIST_DNS_DOMAIN_RECORDS, array($user['uid'], $_s['DNS_DOMAIN'], Config::get('response_type'))); + $params = array( + 'USER' => $user['uid'], + 'DOMAIN' => $_s['DNS_DOMAIN'] + ); + + $result = Vesta::execute(Vesta::V_LIST_DNS_DOMAIN_RECORDS, $params, self::JSON); foreach ($result['data'] as $record_id => $details) { $reply[$record_id] = array( - 'RECORD_ID' => $record_id, - 'RECORD' => $details['RECORD'], - 'RECORD_TYPE' => $details['TYPE'], - 'RECORD_VALUE' => $details['VALUE'], - 'SUSPEND' => $details['SUSPEND'], - 'DATE' => date(Config::get('ui_date_format', strtotime($details['DATE']))) + 'ID' => $record_id, + 'RECORD_ID' => $record_id, + 'RECORD' => $details['RECORD'], + 'RECORD_TYPE' => $details['TYPE'], + 'RECORD_VALUE' => str_replace('"', '', $details['VALUE']), + 'SUSPEND' => $details['SUSPEND'], + 'DATE' => date(Config::get('ui_date_format', strtotime($details['DATE']))) ); } @@ -85,14 +91,14 @@ class DNS extends AjaxHandler * @param Request $request * @return string - Ajax Reply */ - public function addExecute($request) + public function addExecute(Request $request) { - $user = $this->getLoggedUser(); - $_s = $request->getParameter('spell'); + $user = $this->getLoggedUser(); + $_s = $request->getParameter('spell'); $params = array( - 'USER' => $user['uid'], /// OWNER ??? + 'USER' => $user['uid'], /// OWNER ??? 'DNS_DOMAIN' => $_s['DNS_DOMAIN'], - 'IP' => $_s['IP'] + 'IP' => $_s['IP'] ); // TODO: rewrite this block. Get away from if/if/if/if if ($_s['TPL']) { @@ -107,7 +113,7 @@ class DNS extends AjaxHandler if ($_s['TTL']) { $params['TTL'] = $_s['TTL']; } - + $result = Vesta::execute(Vesta::V_ADD_DNS_DOMAIN, $params); if (!$result['status']) { $this->errors[] = array($result['error_code'] => $result['error_message']); @@ -125,13 +131,13 @@ class DNS extends AjaxHandler * @param Request $request * @return string - Ajax Reply */ - public function addRecordExecute($request) + public function addRecordExecute(Request $request) { - $user = $this->getLoggedUser(); - $_s = $request->getParameter('spell'); - + $user = $this->getLoggedUser(); + $_s = $request->getParameter('spell'); + $params = array( - 'USER' => $user['uid'], /// OWNER ??? + 'USER' => $user['uid'], 'DOMAIN' => $_s['DOMAIN'], 'RECORD' => $_s['RECORD'], 'RECORD_TYPE' => $_s['TYPE'], @@ -140,7 +146,7 @@ class DNS extends AjaxHandler ); $result = Vesta::execute(Vesta::V_ADD_DNS_DOMAIN_RECORD, $params); - + if (!$result['status']) { $this->errors[] = array($result['error_code'] => $result['error_message']); } @@ -157,15 +163,15 @@ class DNS extends AjaxHandler * @param Request $request * @return string - Ajax Reply */ - public function deleteExecute($request) + public function deleteExecute(Request $request) { - $user = $this->getLoggedUser(); - $_s = $request->getParameter('spell'); - $params = array( + $user = $this->getLoggedUser(); + $_s = $request->getParameter('spell'); + $params = array( 'USER' => $user['uid'], /// OWNER ??? 'DOMAIN' => $_s['DNS_DOMAIN'], ); - + $result = Vesta::execute(Vesta::V_DEL_DNS_DOMAIN, $params); if (!$result['status']) { @@ -184,19 +190,20 @@ class DNS extends AjaxHandler * @param Request $request * @return string - Ajax Reply */ - public function delRecordExecute($request) + public function deleteRecordExecute(Request $request) { $_s = $request->getParameter('spell'); + $dns = $request->getParameter('dns'); $user = $this->getLoggedUser(); - + $params = array( 'USER' => $user['uid'], // TODO: OWNER ??? - 'DOMAIN' => $_s['DOMAIN'], + 'DOMAIN' => $dns['DNS_DOMAIN'], 'RECORD_ID' => $_s['RECORD_ID'] ); - + $result = Vesta::execute(Vesta::V_DEL_DNS_DOMAIN_RECORD, $params); - + if (!$result['status']) { $this->errors[] = array($result['error_code'] => $result['error_message']); } @@ -214,14 +221,14 @@ class DNS extends AjaxHandler * @param Request $request * @return string - Ajax Reply */ - public function changeExecute($request) - { + public function changeExecute(Request $request) + { $_old = $request->getParameter('old'); $_new = $request->getParameter('new'); $user = $this->getLoggedUser(); $_DNS_DOMAIN = $_old['DNS_DOMAIN']; - + if ($_old['IP'] != $_new['IP']) { $result = array(); @@ -231,7 +238,7 @@ class DNS extends AjaxHandler $this->errors['IP_ADDRESS'] = array($result['error_code'] => $result['error_message']); } } - + if ($_old['TPL'] != $_new['TPL']) { $result = array(); $result = Vesta::execute(Vesta::V_CHANGE_DNS_DOMAIN_TPL, array('USER' => $user['uid'], 'DNS_DOMAIN' => $_DNS_DOMAIN, 'IP' => $_new['TPL'])); @@ -240,7 +247,7 @@ class DNS extends AjaxHandler $this->errors['TPL'] = array($result['error_code'] => $result['error_message']); } } - + if ($_old['TTL'] != $_new['TTL']) { $result = array(); $result = Vesta::execute(Vesta::V_CHANGE_DNS_DOMAIN_TTL, array('USER' => $user['uid'], 'DNS_DOMAIN' => $_DNS_DOMAIN, 'IP' => $_new['TTL'])); @@ -258,7 +265,7 @@ class DNS extends AjaxHandler $this->errors['EXP'] = array($result['error_code'] => $result['error_message']); } } - + if ($_old['SOA'] != $_new['SOA']) { $result = array(); $result = Vesta::execute(Vesta::V_CHANGE_DNS_DOMAIN_SOA, array('USER' => $user['uid'], 'DNS_DOMAIN' => $_new['DNS_DOMAIN'], 'IP' => $_new['SOA'])); @@ -268,7 +275,7 @@ class DNS extends AjaxHandler } } - if (!$this->status) { + if (!$this->status) { Vesta::execute(Vesta::V_CHANGE_DNS_DOMAIN_IP, array('USER' => $user['uid'], 'DNS_DOMAIN' => $_DNS_DOMAIN, 'IP' => $_old['IP'])); Vesta::execute(Vesta::V_CHANGE_DNS_DOMAIN_TPL, array('USER' => $user['uid'], 'DNS_DOMAIN' => $_DNS_DOMAIN, 'IP' => $_old['TPL'])); Vesta::execute(Vesta::V_CHANGE_DNS_DOMAIN_TTL, array('USER' => $user['uid'], 'DNS_DOMAIN' => $_DNS_DOMAIN, 'IP' => $_old['TTL'])); @@ -285,50 +292,76 @@ class DNS extends AjaxHandler * @param Request $request * @return string - Ajax Reply */ - public function changeRecordsExecute($request) + public function changeRecordsExecute(Request $request) { - $_old = $request->getParameter('old'); - $_new = $request->getParameter('new'); - $user = $this->getLoggedUser(); - $_DNS_DOMAIN = $_s['DNS_DOMAIN']; + $records = $request->getParameter('spell'); + $dns = $request->getParameter('dns'); + $user = $this->getLoggedUser(); + $domain = $dns['DNS_DOMAIN']; - foreach ($_new as $record_id => $record_data) { - // checking if record existed - update - if (is_array($_old[$record_id])) { - $result = Vesta::execute(Vesta::V_CHANGE_DNS_DOMAIN_RECORD, - array( - 'USER' => $user['uid'], - '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 { - $result = Vesta::execute(Vesta::V_ADD_DNS_DOMAIN_RECORD, array('USER' => $user['uid'], 'DNS_DOMAIN' => $_DNS_DOMAIN, 'RECORD' => $record_data['RECORD'], 'TYPE' => $record_data['RECORD_TYPE'], 'VALUE' => $record_data['RECORD_VALUE'], 'ID' => $record_id)); - if (!$result['status']) { - $this->status = FALSE; - $this->errors[$record_id] = array($result['error_code'] => $result['error_message']); - } - } + // Get current records + $curr_records = array(); + $params = array( + 'USER' => $user['uid'], + 'DOMAIN' => $domain + ); - unset($_old[$record_id]); + $result = Vesta::execute(Vesta::V_LIST_DNS_DOMAIN_RECORDS, $params, self::JSON); + foreach ($result['data'] as $record_id => $details) { + $curr_records[] = $record_id; } - // 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) { - /* - $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']); + $new_records = array(); + foreach ($records as $record) { + if ((int)$record['RECORD_ID'] > 0) { + $new_records[] = $record['RECORD_ID']; } - */ + } + + $delete = array_diff(array_values($curr_records), array_values($new_records)); + foreach ($records as $record) { + if (((int)$record['RECORD_ID'] > 0) == false) { + $params = array( + 'USER' => $user['uid'], + 'DOMAIN' => $domain, + 'RECORD' => $record['RECORD'], + 'RECORD_TYPE' => $record['RECORD_TYPE'], + 'RECORD_VALUE' => $record['RECORD_VALUE'] + ); + + $result = Vesta::execute(Vesta::V_ADD_DNS_DOMAIN_RECORD, $params); + if (!$result['status']) { + $this->status = FALSE; + $this->errors[$record_id] = array($result['error_code'] => $result['error_message']); + } + } + else { + $params = array( + 'USER' => $user['uid'], + 'DOMAIN' => $domain, + 'ID' => (int)$record['RECORD_ID'], + 'RECORD' => $record['RECORD'], + 'RECORD_TYPE' => $record['RECORD_TYPE'], + 'RECORD_VALUE' => $record['RECORD_VALUE'] + ); + $result = Vesta::execute(Vesta::V_CHANGE_DNS_DOMAIN_RECORD, $params); + if (!$result['status']) { + $this->status = FALSE; + $this->errors[$record_id] = array($result['error_code'] => $result['error_message']); + } + } + } + foreach ($delete as $record_id) { + $params = array( + 'USER' => $user['uid'], + 'DOMAIN' => $domain, + 'ID' => $record_id + ); + $result = Vesta::execute(Vesta::V_DEL_DNS_DOMAIN_RECORD, $params); + if (!$result['status']) { + $this->status = FALSE; + $this->errors[$record_id] = array($result['error_code'] => $result['error_message']); + } } return $this->reply($this->status, ''); diff --git a/web/vesta/api/IP.class.php b/web/vesta/api/IP.class.php index d82fceaf3..0aa3e6620 100644 --- a/web/vesta/api/IP.class.php +++ b/web/vesta/api/IP.class.php @@ -20,7 +20,7 @@ class IP extends AjaxHandler public function getListExecute(Request $request) { $reply = array(); - $result = Vesta::execute(Vesta::V_LIST_SYS_IPS, array(Config::get('response_type'))); + $result = Vesta::execute(Vesta::V_LIST_SYS_IPS, array(Config::get('response_type'))); foreach ($result['data'] as $ip => $details) { $reply[] = array_merge( array( @@ -28,11 +28,11 @@ class IP extends AjaxHandler 'DATE' => date(Config::get('ui_date_format', strtotime($details['DATE']))) ), $details); } - + if (!$result['status']) { $this->errors[] = array($result['error_code'] => $result['error_message']); } - + return $this->reply($result['status'], $reply); } @@ -53,11 +53,11 @@ class IP extends AjaxHandler 'DATE' => date(Config::get('ui_date_format', strtotime($details['DATE']))) ), $details); } - + if (!$result['status']) { $this->errors[] = array($result['error_code'] => $result['error_message']); } - + return $this->reply($result['status'], $reply); } @@ -69,15 +69,14 @@ class IP extends AjaxHandler */ public function addExecute(Request $request) { - $user = $this->getLoggedUser(); - $spell = $request->getParameter('spell'); + $user = $this->getLoggedUser(); + $spell = $request->getParameter('spell'); $params = array( 'IP_ADDRESS' => $spell['IP_ADDRESS'], - 'MASK' => $spell['NETMASK'], + 'MASK' => $spell['NETMASK'], 'INTERFACE' => $spell['INTERFACE'], 'OWNER' => $spell['OWNER'], - 'IP_STATUS' => $spell['STATUS'] - //'IP_NAME' => $spell['NAME'] + 'IP_STATUS' => $spell['STATUS'] ); $result = Vesta::execute(Vesta::V_ADD_SYS_IP, $params); @@ -97,8 +96,8 @@ class IP extends AjaxHandler */ public function deleteExecute(Request $request) { - $spell = $request->getParameter('spell'); - $user = $this->getLoggedUser(); + $spell = $request->getParameter('spell'); + $user = $this->getLoggedUser(); $params = array( 'IP_ADDRESS' => $spell['IP_ADDRESS'] ); @@ -120,10 +119,13 @@ class IP extends AjaxHandler */ public function changeExecute(Request $request) { - $user = $this->getLoggedUser(); + $user = $this->getLoggedUser(); $_old = $request->getParameter('old'); $_new = $request->getParameter('new'); + $this->status = TRUE; + $this->errors = array(); + if ($_old['OWNER'] != $_new['OWNER']) { $result = array(); $result = Vesta::execute(Vesta::V_CHANGE_SYS_IP_OWNER, array('OWNER' => $_new['OWNER'], 'IP' => $_new['IP_ADDRESS'])); @@ -133,7 +135,7 @@ class IP extends AjaxHandler } } - // TODO: Handle NAME parameter + // TODO: Handle NAME parameter /*if ($_old['NAME'] != $_new['NAME']) { $result = array(); $result = Vesta::execute(Vesta::V_CHANGE_SYS_IP_NAME, array('IP' => $_new['IP_ADDRESS'], 'NAME' => $_new['NAME'])); @@ -156,7 +158,7 @@ class IP extends AjaxHandler $this->errors[] = array($result['error_code'] => $result['error_message']); } - return $this->reply($result['status'], $result['data']); + return $this->reply($this->status, $this->errors); } /** @@ -165,19 +167,19 @@ class IP extends AjaxHandler * @param Request $request * @return string - Ajax Reply */ - public function getSysInterfacesExecute($request) + public function getSysInterfacesExecute(Request $request) { $reply = array(); - $result = Vesta::execute(Vesta::V_LIST_SYS_INTERFACES, array(Config::get('response_type'))); + $result = Vesta::execute(Vesta::V_LIST_SYS_INTERFACES, array(Config::get('response_type'))); foreach ($result['data'] as $iface) { $reply[$iface] = $iface; } - + if (!$result['status']) { $this->errors[] = array($result['error_code'] => $result['error_message']); } - + return $this->reply($result['status'], $reply); } diff --git a/web/vesta/api/MAIN.class.php b/web/vesta/api/MAIN.class.php index 983cf8774..1d996c300 100644 --- a/web/vesta/api/MAIN.class.php +++ b/web/vesta/api/MAIN.class.php @@ -23,7 +23,7 @@ class MAIN extends AjaxHandler * @param Request $request * @return string - Ajax Reply */ - public function versionExecute($request) + public function versionExecute(Request $request) { $result = array( 'version' => '1.0', @@ -41,7 +41,7 @@ class MAIN extends AjaxHandler * @param Request $request * @return string - Ajax Reply */ - public function getInitialExecute($request) + public function getInitialExecute(Request $request) { require_once V_ROOT_DIR . 'api/IP.class.php'; require_once V_ROOT_DIR . 'api/USER.class.php'; @@ -55,7 +55,6 @@ class MAIN extends AjaxHandler $user_obj = new USER(); $users = json_decode($user_obj->getListExecute($request), TRUE); $user_names = array_keys($users['data']); - $db_types = array('mysql' => 'mysql', 'postgress' => 'postgress'); $interfaces_arr = json_decode($ip_obj->getSysInterfacesExecute($request), TRUE); $interfaces = $interfaces_arr['data']; @@ -133,10 +132,10 @@ class MAIN extends AjaxHandler */ public function getIpParams($data = array()) { - $users = array(); - foreach ((array)$data['user_names'] as $user) { - $users[$user] = $user; - } + $users = array(); + foreach ((array)$data['user_names'] as $user) { + $users[$user] = $user; + } return array( 'SYS_USERS' => $users, 'STATUSES' => array( @@ -174,7 +173,7 @@ class MAIN extends AjaxHandler 'TTL' => array(), 'record' => array( 'RECORD' => array(), - 'RECORD_TYPE' => array('a' => 'a', 'reverse' => 'reverse'), + 'RECORD_TYPE' => array('A' => 'A', 'NS' => 'NS', 'MX' => 'MX', 'TXT' => 'TXT'), 'RECORD_VALUE' => array() ) ); @@ -188,8 +187,9 @@ class MAIN extends AjaxHandler */ public function getDbParams($data = array()) { + $db_types = array('mysql' => 'mysql', 'postgre' => 'postgre'); return array( - 'TYPE' => $data['db_types'], + 'TYPE' => $db_types, 'HOST' => array('vestacp.com' => 'vestacp.com', 'askcow.org' => 'askcow.org') ); } diff --git a/web/vesta/api/PARAMS.class.php b/web/vesta/api/PARAMS.class.php index 076a8c7a1..42f20519f 100644 --- a/web/vesta/api/PARAMS.class.php +++ b/web/vesta/api/PARAMS.class.php @@ -9,92 +9,7 @@ * @author Dmitry Naumov-Socolov * @copyright vesta 2010-2011 */ -class PARAMS extends AjaxHandler { - /* - function getInitialExecute($request) - { - require_once V_ROOT_DIR . 'api/IP.class.php'; - $ip_obj = new IP(); - $user_ips = json_decode($ip_obj->getListUserIpsExecute(), TRUE); - 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'); - - $interfaces_arr = json_decode($ip_obj->getSysInterfacesExecute(), TRUE); - $interfaces = $interfaces_arr['data']; - - - $reply = array( - 'WEB_DOMAIN' => array( - 'TPL' => array('default' => 'default'), - 'ALIAS' => array(), - 'STAT' => array( - 'webalizer' => 'webalizer', - 'awstats' => 'awstats'), - 'IP' => $ips - ), - - 'CRON' => array(), - - 'IP' => array( - 'SYS_USERS' => $user_names, - 'STATUSES' => array( - 'shared' => 'shared', - 'exclusive' => 'exclusive' - ), - 'INTERFACES' => $interfaces, - 'MASK' => array( - '255.255.255.0' => '255.255.255.0', - '255.255.255.128' => '255.255.255.128', - '255.255.255.192' => '255.255.255.192', - '255.255.255.224' => '255.255.255.224', - '255.255.255.240' => '255.255.255.240', - '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() - ), - - 'DNS' => array( - 'IP' => $ips, - 'TPL' => array('default' => 'default'), - 'EXP' => array(), - 'SOA' => array(), - 'TTL' => array(), - 'record' => array( - 'RECORD' => array(), - 'RECORD_TYPE' => array('a' => 'a', 'reverce' => 'reverce'), - 'RECORD_VALUE' => array() - ) - ), - - 'DB' => array( - 'TYPE' => $db_types, - 'HOST' => array('vestacp.com' => 'vestacp.com', 'askcow.org' => 'askcow.org') - ), - - 'USERS' => array( - 'ROLE' => array('user' => 'user'), - 'OWNER' => $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') - ) - ); - - return $this->reply(true, $reply); - }*/ +class PARAMS extends AjaxHandler +{ + } diff --git a/web/vesta/api/USER.class.php b/web/vesta/api/USER.class.php index 513f9c58e..784c3229e 100644 --- a/web/vesta/api/USER.class.php +++ b/web/vesta/api/USER.class.php @@ -30,13 +30,13 @@ class USER extends AjaxHandler foreach ($result['data'] as $user => $details) { $fullname_id = rand(0, count($users)-1); $fullname = implode('', array($details['FNAME'], ' ', $details['LNAME'])); - //if ($user == 'TestGOOD') {var_dump($details);die();} - $nses = $this->getNS($user, $details); + + $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, // TODO skid + "FULLNAME" => $fullname, "PACKAGE" => $details['PACKAGE'], "WEB_DOMAINS" => $details['WEB_DOMAINS'], "WEB_SSL" => $details['WEB_SSL'], @@ -46,9 +46,8 @@ class USER extends AjaxHandler "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 + "DISK_QUOTA" => $details['DISK_QUOTA'], + "BANDWIDTH" => $details['BANDWIDTH'], "SHELL" => $details['SHELL'], "BACKUPS" => $details['BACKUPS'], "WEB_TPL" => $details['WEB_TPL'], @@ -67,13 +66,12 @@ class USER extends AjaxHandler "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 ); - $reply[$user] = array_merge($user_details, $nses); - } + $reply[$user] = array_merge($user_details, $nses); + } return $this->reply(TRUE, $reply); } @@ -95,17 +93,17 @@ class USER extends AjaxHandler 'ROLE' => $spell['ROLE'], 'OWNER' => $user['uid'], 'PACKAGE' => $spell['PACKAGE'], - 'FNAME' => $spell['FNAME'], - 'LNAME' => $spell['LNAME'] + 'FNAME' => $spell['FNAME'], + 'LNAME' => $spell['LNAME'] ); - $result = Vesta::execute(Vesta::V_ADD_SYS_USER, $params); - // Reports - $enable_reports = Utils::getCheckboxBooleanValue($spell['REPORTS_ENABLED']); - $reports_result = $this->setUserReports($spell['LOGIN_NAME'], $spell['REPORTS_ENABLED']); - // NS - $ns_result = $this->setNSentries($spell['LOGIN_NAME'], $spell); - + $result = Vesta::execute(Vesta::V_ADD_SYS_USER, $params); + // Reports + $enable_reports = Utils::getCheckboxBooleanValue($spell['REPORTS_ENABLED']); + $reports_result = $this->setUserReports($spell['LOGIN_NAME'], $spell['REPORTS_ENABLED']); + // NS + $ns_result = $this->setNSentries($spell['LOGIN_NAME'], $spell); + if (!$result['status']) { $this->errors[] = array($result['error_code'] => $result['error_message']); } @@ -122,7 +120,7 @@ class USER extends AjaxHandler public function deleteExecute(Request $request) { $user = $this->getLoggedUser(); - $spell = $request->getParameter('spell'); + $spell = $request->getParameter('spell'); $params = array( 'USER' => $spell['LOGIN_NAME'] ); @@ -142,10 +140,10 @@ class USER extends AjaxHandler * @param Request $request * @return string - Ajax Reply */ - public function changeExecute($request) + public function changeExecute(Request $request) { - $_new = $request->getParameter('new'); - $_old = $request->getParameter('old'); + $_new = $request->getParameter('new'); + $_old = $request->getParameter('old'); $_USER = $_old['LOGIN_NAME']; @@ -176,16 +174,16 @@ class USER extends AjaxHandler } } - $this->setNSentries($_USER, $_new); + $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']) { + $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; $this->errors['NAMES'] = array($result['error_code'] => $result['error_message']); } @@ -201,10 +199,10 @@ class USER extends AjaxHandler 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'])); - 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'])); + 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'])); + 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, ''); @@ -212,45 +210,45 @@ class USER extends AjaxHandler protected function setUserReports($user, $enabled) { - if ($enabled === true) { - $result = Vesta::execute(Vesta::V_ADD_SYS_USER_REPORTS, array('USER' => $user)); - } - else { - $result = Vesta::execute(Vesta::V_DEL_SYS_USER_REPORTS, array('USER' => $user)); - } + if ($enabled === true) { + $result = Vesta::execute(Vesta::V_ADD_SYS_USER_REPORTS, array('USER' => $user)); + } + else { + $result = Vesta::execute(Vesta::V_DEL_SYS_USER_REPORTS, array('USER' => $user)); + } - return $result['status']; + return $result['status']; } protected function setNSentries($user, $data) { - $ns = array(); - $ns['USER'] = $user; - $ns['NS1'] = $data['NS1']; - $ns['NS2'] = $data['NS2']; - $ns['NS3'] = isset($data['NS3']) ? $data['NS3'] : ''; - $ns['NS4'] = isset($data['NS4']) ? $data['NS4'] : ''; - $ns['NS5'] = isset($data['NS5']) ? $data['NS5'] : ''; - $ns['NS6'] = isset($data['NS6']) ? $data['NS6'] : ''; - $ns['NS7'] = isset($data['NS7']) ? $data['NS7'] : ''; - $ns['NS8'] = isset($data['NS8']) ? $data['NS8'] : ''; + $ns = array(); + $ns['USER'] = $user; + $ns['NS1'] = $data['NS1']; + $ns['NS2'] = $data['NS2']; + $ns['NS3'] = isset($data['NS3']) ? $data['NS3'] : ''; + $ns['NS4'] = isset($data['NS4']) ? $data['NS4'] : ''; + $ns['NS5'] = isset($data['NS5']) ? $data['NS5'] : ''; + $ns['NS6'] = isset($data['NS6']) ? $data['NS6'] : ''; + $ns['NS7'] = isset($data['NS7']) ? $data['NS7'] : ''; + $ns['NS8'] = isset($data['NS8']) ? $data['NS8'] : ''; - $result = Vesta::execute(Vesta::V_CHANGE_SYS_USER_NS, $ns); + $result = Vesta::execute(Vesta::V_CHANGE_SYS_USER_NS, $ns); - return $result['status']; + return $result['status']; } protected function getNS($user, $data) { - $result = array(); - $ns_str = $data['NS']; - $ns_list = explode(',', $ns_str); - - foreach (range(0, 7) as $index) { - $result['NS'.($index + 1)] = @trim(@$ns_list[$index]); - } - - return $result; + $result = array(); + $ns_str = $data['NS']; + $ns_list = explode(',', $ns_str); + + foreach (range(0, 7) as $index) { + $result['NS'.($index + 1)] = @trim(@$ns_list[$index]); + } + + return $result; } } diff --git a/web/vesta/api/WEB_DOMAIN.class.php b/web/vesta/api/WEB_DOMAIN.class.php index 062a06250..4a176bb8e 100644 --- a/web/vesta/api/WEB_DOMAIN.class.php +++ b/web/vesta/api/WEB_DOMAIN.class.php @@ -7,506 +7,390 @@ * @author Dmitry Naumov-Socolov * @copyright vesta 2010-2011 */ -class WEB_DOMAIN extends AjaxHandler { - function getListExecute($request) +class WEB_DOMAIN extends AjaxHandler +{ + + public function getListExecute(Request $request) { - $_user = 'vesta'; - $reply = array(); - - $result = Vesta::execute(Vesta::V_LIST_WEB_DOMAINS, array($_user, Config::get('response_type'))); - - // echo '
';
-      //      print_r($result);
-      
-      foreach($result['data'] as $web_domain => $data)
-	{
-	  $reply[$web_domain] = array(
-				      'IP' => $record['IP'],
-				      'U_DISK' => $record['U_DISK'],
-				      'U_BANDWIDTH' => $record['U_BANDWIDTH'],
-				      'TPL' => $record['TPL'],
-				      'ALIAS' => $record['ALIAS'],
-				      'PHP' => $record['PHP'],
-				      'CGI' => $record['CGI'],
-				      'ELOG' => $record['ELOG'],
-				      'STATS' => $record['STATS'],
-				      'STATS_AUTH' => $record['STATS_AUTH'],
-				      'SSL' => $record['SSL'],
-				      'SSL_HOME' => $record['SSL_HOME'],
-				      'SSL_CERT' => $record['SSL_CERT'],
-				      'NGINX' => $record['NGINX'],
-				      'NGINX_EXT' => $record['NGINX_EXT'],
-				      'SUSPEND' => $record['SUSPEND'],
-				      'DATE' => date(Config::get('ui_date_format', strtotime($record['DATE'])))
-				      );
-	}
-      
-      if(!$result['status'])
-	$this->errors[] = array($result['error_code'] => $result['error_message']);
-      
-      return $this->reply($result['status'], $reply);
+        $user = $this->getLoggedUser();
+        $reply = array();
+
+        $result = Vesta::execute(Vesta::V_LIST_WEB_DOMAINS, array($user['uid'], Config::get('response_type')));
+
+        foreach($result['data'] as $web_domain => $data)
+        {
+            $reply[$web_domain] = array(
+                                      'IP'          => $record['IP'],
+                                      'U_DISK'      => $record['U_DISK'],
+                                      'U_BANDWIDTH' => $record['U_BANDWIDTH'],
+                                      'TPL'         => $record['TPL'],
+                                      'ALIAS'       => $record['ALIAS'],
+                                      'PHP'         => $record['PHP'],
+                                      'CGI'         => $record['CGI'],
+                                      'ELOG'        => $record['ELOG'],
+                                      'STATS'       => $record['STATS'],
+                                      'STATS_AUTH'  => $record['STATS_AUTH'],
+                                      'SSL'         => $record['SSL'],
+                                      'SSL_HOME'    => $record['SSL_HOME'],
+                                      'SSL_CERT'    => $record['SSL_CERT'],
+                                      'NGINX'       => $record['NGINX'],
+                                      'NGINX_EXT'   => $record['NGINX_EXT'],
+                                      'SUSPEND'     => $record['SUSPEND'],
+                                      'DATE'        => date(Config::get('ui_date_format', strtotime($record['DATE'])))
+                                  );
+        }
+
+        if (!$result['status']) {
+            $this->errors[] = array($result['error_code'] => $result['error_message']);
+        }
+
+        return $this->reply($result['status'], $reply);
     }
     
     
     
-    function addExecute($request) 
+    public function addExecute(Request $request) 
     {
-      $r = new Request();
-      $_s = $r->getSpell();
-      $_user = 'vesta';
+        $_s = $request->getParameter('spell');
+        $user = $this->getLoggedUser();
 
-      $params = array(
-		      'USER' => $_user,
-		      'DOMAIN' => $_s['DOMAIN'],
-		      'IP' => $_s['IP']
-		      );
-      
-      $result = Vesta::execute(Vesta::V_ADD_WEB_DOMAIN, $params);
-      
-      if(!$result['status'])
-	$this->errors[] = array($result['error_code'] => $result['error_message']);
-      
-      
-      
-      //    if(0)
-      if($_s['TPL'])
-	{
-	  $params = array('USER' => $_user,
-			'DOMAIN' => $_s['DOMAIN'],
-			  '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(0)
-      if($_s['ALIAS'])
-	{
-	$alias_arr = explode(',', $_s['ALIAS']);
-	
-	foreach($alias_arr as $alias)
-	  {
-	    $params = array('USER' => $_user,
-			    'DOMAIN' => $_s['DOMAIN'],
-			    '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(0)
-      if($_s['STAT'])
-	{
-	  $params = array('USER' => $_user,
-			  'DOMAIN' => $_s['DOMAIN'],
-			  '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(0)
-      if($_s['STAT_AUTH'])
-	{
-	  $params = array('USER' => $_user,
-			  'DOMAIN' => $_s['DOMAIN'],
-			  'STAT_USER' => $_s['STAT_USER'],
-			  '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']);
-	}
+        $params = array(
+                      'USER'   => $user['uid'],
+                      'DOMAIN' => $_s['DOMAIN'],
+                      'IP'     => $_s['IP']
+                  );
+        
+        $result = Vesta::execute(Vesta::V_ADD_WEB_DOMAIN, $params);
 
-      if(0)
-	if($_s['SSL'])
-	  {
-	    $params = array('USER' => $_user,
-			    'DOMAIN' => $_s['DOMAIN'],
-			    'SSL_CERT' => $_s['SSL_CERT']);
-	    
-	    if($_s['SSL_HOME'])
-	      $params['SSL_HOME'] = $_s['SSL_HOME'];
-	    
-	    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[] = array($result['error_code'] => $result['error_message']);
+        }
+
+        if ($_s['TPL']) {
+            $params = array(
+                        'USER'   => $user['uid'],
+                        'DOMAIN' => $_s['DOMAIN'],
+                        '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(0)
-      if($_s['CREATE_DNS_DOMAIN'])
-	{
-	  $params = array('USER' => $_user,
-			  'DNS_DOMAIN' => $_s['DOMAIN'],
-			  '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 ($_s['ALIAS']) {
+            $alias_arr = explode(',', $_s['ALIAS']);
+
+            foreach ($alias_arr as $alias) {
+                $params = array(
+                            'USER'   => $user['uid'],
+                            'DOMAIN' => $_s['DOMAIN'],
+                            '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 ($_s['STAT']) {
+            $params = array(
+                        'USER'   => $user['uid'],
+                        'DOMAIN' => $_s['DOMAIN'],
+                        '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 ($_s['STAT_AUTH']) {
+            $params = array(
+                        'USER'          => $user['uid'],
+                        'DOMAIN'        => $_s['DOMAIN'],
+                        'STAT_USER'     => $_s['STAT_USER'],
+                        '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 (0) {
+            if ($_s['SSL']) {
+                $params = array(
+                            'USER'     => $user[''],
+                            'DOMAIN'   => $_s['DOMAIN'],
+                            'SSL_CERT' => $_s['SSL_CERT']
+                          );
+
+            if ($_s['SSL_HOME']) {
+                $params['SSL_HOME'] = $_s['SSL_HOME'];
+            }
+
+            if ($_s['SSL_TEXT']) {
+                // TODO: implement
+            }
+
+            $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(0)
-	if($_s['CREATE_MAIL_DOMAIN'])
-	  {
-	    $params = array('USER' => $_user,
-			    'MAIL_DOMAIN' => $_s['DOMAIN'],
-			    '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 ($_s['CREATE_DNS_DOMAIN']) {
+            $params = array(
+                        'USER'       => $user['uid'],
+                        'DNS_DOMAIN' => $_s['DOMAIN'],
+                        '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']);
+            }
+        }
       
-      return $this->reply($result['status'], $result['data']);
+        /*
+        if ($_s['CREATE_MAIL_DOMAIN']) {
+            $params = array(
+                        'USER'        => $_user,
+                        'MAIL_DOMAIN' => $_s['DOMAIN'],
+                        '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']);
+        }
+        */
+      
+        return $this->reply($result['status'], $result['data']);
     }
     
-    function delExecute($request) 
+    public function deleteExecute(Request $request) 
     {
-      $r = new Request();
-      $_s = $r->getSpell();
-      $_user = 'vesta';
-      
-      $params = array(
-		      'USER' => $_user,
-		      'DOMAIN' => $_s['DOMAIN']
-		      );
-      
-      $result = Vesta::execute(Vesta::V_DEL_WEB_DOMAIN, $params);
-      
-      if(!$result['status'])
-	$this->errors[] = array($result['error_code'] => $result['error_message']);
+        $_s = $request->getParameter('spell');
+        $user = $this->getLoggedUser();
 
+        $params = array(
+                    'USER'   => $user['uid'],
+                    'DOMAIN' => $_s['DOMAIN']
+                  );
+      
+        $result = Vesta::execute(Vesta::V_DEL_WEB_DOMAIN, $params);
+      
+        if (!$result['status']) {
+            $this->errors[] = array($result['error_code'] => $result['error_message']);
+        }
 
-
-    $params = array(
-		    'USER' => $_user,
-		    'DNS_DOMAIN' => $_s['DOMAIN']
-		    );
+        $params = array(
+                    'USER'       => $_user,
+                    'DNS_DOMAIN' => $_s['DOMAIN']
+                  );
    
-    require_once V_ROOT_DIR . 'api/DNS.class.php';
-    $dns = new DNS();
-    $result = $dns->delExecute($params);
+        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']);
+        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';
+        require_once V_ROOT_DIR . 'api/DNS.class.php';
 
-    $params = array(
-		    'USER' => $_user,
-		    'MAIL_DOMAIN' => $_s['DOMAIN']
-		    );
+        $params = array(
+                    'USER'        => $user['uid'],
+                    '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']);
-  }
+        return $this->reply($result['status'], $result['data']);
+    }
   
+    public function changeExecute(Request $request)
+    {        
+        $_s = $request->getParameter('spell');
+        $_old = $request->getParameter('old');
+        $_new = $request->getParameter('new');
+
+        $user = $this->getLoggedUser();
+        $_DOMAIN = $_new['DOMAIN'];
     
-  
-  function changeExecute($request)
-  {
-    $r = new Request();
-    $_s = $r->getSpell();
-    $_old = $_s['old'];
-    $_new = $_s['new'];
+        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']) {
+                $this->status = FALSE;
+                $this->errors['IP_ADDRESS'] = array($result['error_code'] => $result['error_message']);
+            }
+        }
 
-    $_user = 'vesta';
-    $_DOMAIN = $_new['DOMAIN'];
+        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']) {
+                $this->status = FALSE;
+                $this->errors['TPL'] = array($result['error_code'] => $result['error_message']);
+            }
+        }
+
+        if ($_old['ALIAS'] != $_new['ALIAS']) {
+            $result = array();
+
+            $old_arr = explode(',', $_old['ALIAS']);
+            $new_arr = explode(',', $_new['ALIAS']);
+
+            $added = array_diff($new_arr, $old_arr);
+            $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));
+                if (!$result['status']) {
+                    $this->status = FALSE;
+                    $this->errors['ADD_ALIAS'] = array($result['error_code'] => $result['error_message']);
+                }
+            }
+        
+            foreach ($deleted as $alias) {
+                $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']);
+                }
+            }
+        }
+
+
+        if ($_old['STAT'] != $_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']));
+                if (!$result['status']) {
+                    $this->status = FALSE;
+                    $this->errors['ADD_STAT'] = array($result['error_code'] => $result['error_message']);
+                }
+            }
+
+            if ($_new['STAT'] == false) {
+                $result = array();
+                $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']);
+                }
+                $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']) {
+                    $this->status = FALSE;
+                    $this->errors['DEL_STAT_AUTH'] = array($result['error_code'] => $result['error_message']);
+                }
+            }
+        }
+
+        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));
+                if (!$result['status']) {
+                    $this->status = FALSE;
+                    $this->errors['ADD_CGI'] = array($result['error_code'] => $result['error_message']);
+                }
+            }
+            
+            if ($_new['CGI'] == false) {
+                $result = array();
+                $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']);
+                }
+            }
+        }
+
+        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));
+                if (!$result['status']) {
+                    $this->status = FALSE;
+                    $this->errors['ADD_ELOG'] = array($result['error_code'] => $result['error_message']);
+                }
+            }
+        
+            if ($_new['ELOG'] == false) {
+                $result = array();
+                $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']);
+                }
+            }
+        }
+
+        return $this->reply($result['status'], $result['data']);
+    }
+
+
+
+    public function suspendExecute(Request $request)
+    {    
+        $_s = $request->getParameter('spell');
+        $user = $this->getLoggedUser();
+
+        $params = array(
+                    'USER' => $_user['uid'],
+                    'DOMAIN' => $_s['DOMAIN']
+                  );
+
+        $result = Vesta::execute(Vesta::V_SUSPEND_WEB_DOMAIN, $params);
+
+        if (!$result['status']) {
+            $this->errors[] = array($result['error_code'] => $result['error_message']);
+        }
+
+        return $this->reply($result['status'], $result['data']);
+    }
+
+
+    public function unsuspendExecute(Request $request)
+    {        
+        $_s = $request->getParameter('spell');
+        $user = $this->getLoggedUser();
     
-    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'])
-	  {
-	    $this->status = FALSE;
-	    $this->errors['IP_ADDRESS'] = array($result['error_code'] => $result['error_message']);
-	  }
-      }
-
-
-    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'])
-	  {
-	    $this->status = FALSE;
-	    $this->errors['TPL'] = array($result['error_code'] => $result['error_message']);
-	  }
-      }
-
-    if($_old['ALIAS'] != $_new['ALIAS'])
-      {
-	$result = array();
-
-	$old_arr = explode(',', $_old['ALIAS']);
-	$new_arr = explode(',', $_new['ALIAS']);
-
-	$added = array_diff($new_arr, $old_arr);
-	$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));
-	    if(!$result['status'])
-	      {
-		$this->status = FALSE;
-		$this->errors['ADD_ALIAS'] = array($result['error_code'] => $result['error_message']);
-	      }
-	  }
-	foreach($deleted as $alias)
-	  {
-	    $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']);
-	      }
-	  }
-      }
-
-
-    if($_old['STAT'] != $_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']));
-	    if(!$result['status'])
-	      {
-		$this->status = FALSE;
-		$this->errors['ADD_STAT'] = array($result['error_code'] => $result['error_message']);
-	      }
-	  }
-
-	if($_new['STAT'] == false)
-	  {
-	    $result = array();
-	    $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']);
-	      }
-	    $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'])
-	      {
-		$this->status = FALSE;
-		$this->errors['DEL_STAT_AUTH'] = array($result['error_code'] => $result['error_message']);
-	      }
-	  }
-      }
-
-    if(0)
-    // ssl
-    if($_old['SSL'] != $_new['SSL'])
-      {
-	if($_new['SSL'] == true)
-	  {
-
-
-	  }
-	if($_new['SSL'] == false)
-	  {
-
-
-	  }
-      }
-    else
-      {
-	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'])
-	    {
-	      $this->status = FALSE;
-	      $this->errors['SSL_CERT'] = array($result['error_code'] => $result['error_message']);
-	    }
-	  }
-	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'])
-	      {
-		$this->status = FALSE;
-		$this->errors['SSL_HOME'] = array($result['error_code'] => $result['error_message']);
-	      }
-	  }
-      }
-
-    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));
-	  if(!$result['status'])
-	    {
-	      $this->status = FALSE;
-	      $this->errors['ADD_CGI'] = array($result['error_code'] => $result['error_message']);
-	    }
-	}
-	if($_new['CGI'] == false)
-	{
-	  $result = array();
-	  $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']);
-	    }
-	}
-      }
-
-    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));
-	  if(!$result['status'])
-	    {
-	      $this->status = FALSE;
-	      $this->errors['ADD_ELOG'] = array($result['error_code'] => $result['error_message']);
-	    }
-	}
-	if($_new['ELOG'] == false)
-	{
-	  $result = array();
-	  $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']);
-	    }
-	}
-      }
-
-
-    return $this->reply($result['status'], $result['data']);
-  }
-
-
-
-  function suspendExecute($request)
-  {
-    $r = new Request();
-    $_s = $r->getSpell();
-
-    $_user = 'vesta';
+        $params = array(
+                    'USER'   => $user['uid'],
+                    'DOMAIN' => $_s['DOMAIN']
+                  );
     
-    $params = array(
-		    'USER' => $_user,
-		    'DOMAIN' => $_s['DOMAIN']
-		    );
+        $result = Vesta::execute(Vesta::V_UNSUSPEND_WEB_DOMAIN, $params);
     
-    $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']);
+    }
     
-    return $this->reply($result['status'], $result['data']);
-  }
-
-
-  function unsuspendExecute($request)
-  {
-    $r = new Request();
-    $_s = $r->getSpell();
-
-    $_user = 'vesta';
-    
-    $params = array(
-		    'USER' => $_user,
-		    'DOMAIN' => $_s['DOMAIN']
-		    );
-    
-    $result = Vesta::execute(Vesta::V_UNSUSPEND_WEB_DOMAIN, $params);
-    
-    if(!$result['status'])
-      $this->errors[] = array($result['error_code'] => $result['error_message']);
-    
-    return $this->reply($result['status'], $result['data']);
-  }
-
-
-
-  function suspendAllExecute($request)
-  {
-    $r = new Request();
-    $_s = $r->getSpell();
-
-    $_user = 'vesta';
-    
-    $params = array(
-		    'USER' => $_user
-		    );
-    
-    $result = Vesta::execute(Vesta::V_SUSPEND_WEB_DOMAINS, $params);
-    
-    if(!$result['status'])
-      $this->errors[] = array($result['error_code'] => $result['error_message']);
-    
-    return $this->reply($result['status'], $result['data']);
-  }
-
-  function unsuspendAllExecute($request)
-  {
-    $r = new Request();
-    $_s = $r->getSpell();
-
-    $_user = 'vesta';
-    
-    $params = array(
-		    'USER' => $_user
-		    );
-    
-    $result = Vesta::execute(Vesta::V_UNSUSPEND_WEB_DOMAINS, $params);
-    
-    if(!$result['status'])
-      $this->errors[] = array($result['error_code'] => $result['error_message']);
-    
-    return $this->reply($result['status'], $result['data']);
-  }
 }
diff --git a/web/vesta/app.init.php b/web/vesta/app.init.php
index a4aa29760..90c54c9e3 100644
--- a/web/vesta/app.init.php
+++ b/web/vesta/app.init.php
@@ -1,5 +1,17 @@