php files cleaned, php formatting added

This commit is contained in:
Dima Malishev 2011-08-06 16:08:27 +03:00
commit a163413043
9 changed files with 1442 additions and 1602 deletions

View file

@ -1,12 +1,14 @@
<?php
/**
* Ajax Handler
*
* @author vesta, http://vestacp.com/
* @author Dmitry Malishev <dima.malishev@gmail.com>
* @author Dmitry Naumov-Socolov <naumov.socolov@gmail.com>
* @copyright vesta 2010-2011
*/
class AjaxHandler
{
class AjaxHandler {
static public $instance = null;
@ -28,14 +30,12 @@ class AjaxHandler
* return $this->reply($result, $data, $msg, $extra);
*
* @param Request $request
* @return mixed
* @return string
*/
function dispatch($request)
{
function dispatch($request) {
$method = Request::parseAjaxMethod($request);
$inc_file = V_ROOT_DIR . 'api' . DIRECTORY_SEPARATOR . $method['namespace'] . '.class.php';
if (!is_readable($inc_file))
{
if (!is_readable($inc_file)) {
throw new SystemException(Message::INVALID_METHOD);
}
@ -44,8 +44,7 @@ class AjaxHandler
$space = new $method['namespace'];
$method = $method['function'] . 'Execute';
if (!method_exists($space, $method))
{
if (!method_exists($space, $method)) {
throw new SystemException(Message::INVALID_METHOD);
}
@ -53,15 +52,9 @@ class AjaxHandler
}
/**
* Prepare the result of method execution into ajax-readable format
*
* @param boolean $result - result of method execution
* @param array $data - data to be replied
* @param string $message - replied message
* @param array $extra - extra data
* Prepare response for ajax
*/
function reply($result, $data, $message = '', $extra = array())
{
function reply($result, $data, $message = '', $extra = array()) {
return json_encode(array('result' => $result,
'data' => $data,
'message' => $message,
@ -70,12 +63,7 @@ class AjaxHandler
));
}
/**
* TODO: delete this method
* @deprecated
*/
static function makeReply($reply)
{
static function makeReply($reply) {
print $reply;
}
@ -83,43 +71,24 @@ class AjaxHandler
// Error handlers
//
/**
* Generate general error
* @param Exception $error
*/
static function generalError($error)
{
static function generalError($error) {
self::renderGlobalError(Message::ERROR, Message::GENERAL_ERROR, $error);
}
/**
* Generate protection error
* @param Exception $error
*/
static function protectionError($error)
{
static function protectionError($error) {
self::renderGlobalError(Message::ERROR, Message::PROTECTION_ERROR, $error);
}
/**
* Generate system error
* @param Exception $error
*/
static function systemError($error)
{
static function systemError($error) {
self::renderGlobalError(Message::ERROR, Message::SYSTEM_ERROR, $error);
}
/**
* Prepare and render the error
* @param Exception $error
*/
static function renderGlobalError($type, $message, $error)
{
$trace = $error->getTrace();
static function renderGlobalError($type, $message, $error) {
/*$trace = $error->getTrace();
AjaxHandler::makeReply(
AjaxHandler::getInstance()->reply(false, $type, $message . ': ' . $error->getMessage(), $trace[0]['file'] . ' / ' . $trace[0]['line'])
);
);*/
print $message;
}
}

View file

@ -1,32 +1,28 @@
<?php
/**
/*
* CRON
*
* @author Naumov-Socolov <naumov.socolov@gmail.com>
* @author Malishev Dima <dima.malishev@gmail.com>
* @author vesta, http://vestacp.com/
* @author Dmitry Malishev <dima.malishev@gmail.com>
* @author Dmitry Naumov-Socolov <naumov.socolov@gmail.com>
* @copyright vesta 2010-2011
*/
class CRON extends AjaxHandler
{
/**
* List cron entries
* Get CRON entries
*
* @param Request $request
* @return
* @return string - Ajax Reply
*/
public function getListExecute($request)
{
$_user = 'vesta';
$reply = array();
$result = Vesta::execute(Vesta::V_LIST_CRON_JOBS, array($_user, Config::get('response_type')));
$result = Vesta::execute(Vesta::V_LIST_CRON_JOBS,
array($_user, Config::get('response_type')));
foreach ($result['data'] as $id => $record)
{
foreach ($result['data'] as $id => $record) {
$reply[$id] = array(
'CMD' => $record['CMD'],
'MIN' => $record['MIN'],
@ -39,8 +35,7 @@ class CRON extends AjaxHandler
);
}
if (!$result['status'])
{
if (!$result['status']) {
$this->errors[] = array($result['error_code'] => $result['error_message']);
}
@ -48,17 +43,16 @@ class CRON extends AjaxHandler
}
/**
* Add cron entry
* Add CRON entry
*
* @param Request $request
* @return
* @return string - Ajax Reply
*/
public function addExecute($request)
{
$r = new Request();
$_s = $r->getSpell();
$_user = 'vesta';
$params = array(
'USER' => $_user,
'MIN' => $_s['MIN'],
@ -71,20 +65,16 @@ class CRON extends AjaxHandler
$result = Vesta::execute(Vesta::V_ADD_CRON_JOB, $params);
if ($_s['REPORTS'])
{
if ($_s['REPORTS']) {
$result = array();
$result = Vesta::execute(Vesta::V_ADD_SYS_USER_REPORTS,
array('USER' => $_user));
if (!$result['status'])
{
$result = Vesta::execute(Vesta::V_ADD_SYS_USER_REPORTS, array('USER' => $_user));
if (!$result['status']) {
$this->status = FALSE;
$this->errors['REPORTS'] = array($result['error_code'] => $result['error_message']);
}
}
if (!$result['status'])
{
if (!$result['status']) {
$this->errors[] = array($result['error_code'] => $result['error_message']);
}
@ -92,12 +82,12 @@ class CRON extends AjaxHandler
}
/**
* Delete cron entry
* Delete CRON entry
*
* @param Request $request
* @return
* @return string - Ajax Reply
*/
function delExecute($request)
public function delExecute($request)
{
$r = new Request();
$_s = $r->getSpell();
@ -107,10 +97,10 @@ class CRON extends AjaxHandler
'USER' => $_user,
'JOB' => $_s['JOB']
);
$result = Vesta::execute(Vesta::V_DEL_CRON_JOB, $params);
if (!$result['status'])
{
if (!$result['status']) {
$this->errors[] = array($result['error_code'] => $result['error_message']);
}
@ -118,21 +108,19 @@ class CRON extends AjaxHandler
}
/**
* Change cron entry
* Change CRON entry
*
* @param Request $request
* @return
* @return string - Ajax Reply
*/
function changeExecute($request)
public function changeExecute($request)
{
$r = new Request();
$_s = $r->getSpell();
$_old = $_s['old'];
$_new = $_s['new'];
$_user = 'vesta';
$_JOB = $_new['JOB'];
$result = array();
$params = array(
'USER' => $_user,
@ -147,57 +135,52 @@ class CRON extends AjaxHandler
$result = Vesta::execute(Vesta::V_CHANGE_CRON_JOB, $params);
if (!$result['status'])
{
if (!$result['status']) {
$this->errors[] = array($result['error_code'] => $result['error_message']);
}
return $this->reply($result['status'], $result['data']);
}
/**
* Suspend cron entry
* Suspend CRON entry
*
* @param Request $request
* @return
* @return string - Ajax Reply
*/
function suspendExecute($request)
public function suspendExecute($request)
{
$r = new Request();
$_s = $r->getSpell();
$_user = 'vesta';
$_JOB = $_s['JOB'];
$params = array(
'USER' => $_user,
'JOB' => $_JOB
);
$result = Vesta::execute(Vesta::V_SUSPEND_CRON_JOB, $params);
if (!$result['status'])
{
if (!$result['status']) {
$this->errors[] = array($result['error_code'] => $result['error_message']);
}
return $this->reply($result['status'], $result['data']);
}
/**
* Unsuspend cron entry
* Unsuspend CRON entry
*
* @param Request $request
* @return
* @return string - Ajax Reply
*/
function unsuspendExecute($request)
public function unsuspendExecute($request)
{
$r = new Request();
$_s = $r->getSpell();
$_user = 'vesta';
$_JOB = $_s['JOB'];
$params = array(
'USER' => $_user,
'JOB' => $_JOB
@ -205,36 +188,33 @@ class CRON extends AjaxHandler
$result = Vesta::execute(Vesta::V_UNSUSPEND_CRON_JOB, $params);
if (!$result['status'])
{
if (!$result['status']) {
$this->errors[] = array($result['error_code'] => $result['error_message']);
}
return $this->reply($result['status'], $result['data']);
}
/**
* Batch suspend cron entries
* Batch suspend CRON entries
*
* @param Request $request
* @return
* @return string - Ajax Reply
*/
function suspendAllExecute($request)
public function suspendAllExecute($request)
{
$r = new Request();
$_s = $r->getSpell();
$_user = 'vesta';
$_JOB = $_s['JOB'];
$params = array(
'USER' => $_user
);
$result = Vesta::execute(Vesta::V_SUSPEND_CRON_JOBS, $params);
if (!$result['status'])
{
if (!$result['status']) {
$this->errors[] = array($result['error_code'] => $result['error_message']);
}
@ -242,26 +222,23 @@ class CRON extends AjaxHandler
}
/**
* Batch suspend cron entry
* Batch unsuspend CRON entries
*
* @param Request $request
* @return
* @return string - Ajax Reply
*/
function unsuspendAllExecute($request)
public function unsuspendAllExecute($request)
{
$r = new Request();
$_s = $r->getSpell();
$_user = 'vesta';
$params = array(
'USER' => $_user
);
$result = Vesta::execute(Vesta::V_UNSUSPEND_CRON_JOBS, $params);
if (!$result['status'])
{
if (!$result['status']) {
$this->errors[] = array($result['error_code'] => $result['error_message']);
}

View file

@ -3,19 +3,20 @@
/**
* DB
*
* @author Naumov-Socolov <naumov.socolov@gmail.com>
* @author Malishev Dima <dima.malishev@gmail.com>
* @author vesta, http://vestacp.com/
* @copyright vesta 2011
* @author Dmitry Malishev <dima.malishev@gmail.com>
* @author Dmitry Naumov-Socolov <naumov.socolov@gmail.com>
* @copyright vesta 2010-2011
*/
class DB extends AjaxHandler
{
/**
* List entries
* Get DB entries
*
* @param Request $request
* @return
* @return string - Ajax Reply
*/
public function getListExecute($request)
{
@ -23,32 +24,48 @@ class DB extends AjaxHandler
$reply = array();
$result = Vesta::execute(Vesta::V_LIST_DB_BASES, array($_user, Config::get('response_type')));
foreach ($result['data'] as $db => $record)
{
$reply[$db] = array(
foreach ($result['data'] as $db => $record) {
$type = $record['TYPE'];
if (!isset($reply[$type])) {
$reply[$type] = array();
}
$reply[$type][] = array(
'DB' => $db,
'USER' => $record['USER'],
'OWNER' => 'John Travlolta',
'USERS' => (array)$record['USER'],
'HOST' => $record['HOST'],
'TYPE' => $record['TYPE'],
'U_DISK' => $record['U_DISK'],
'DISK' => 2024,
'SUSPEND' => $record['SUSPEND'],
'DATE' => date(Config::get('ui_date_format', strtotime($record['DATE'])))
);
}
if (!$result['status'])
{
if (!$result['status']) {
$this->errors[] = array($result['error_code'] => $result['error_message']);
}
$reply['postgre'][] = array(
'DB' => 'x',
'OWNER' => 'John Travlolta',
'USERS' => array('E'),
'HOST' => 'xxx',
'TYPE' => '34',
'U_DISK' => '0',
'SUSPEND' => 'false',
'DATE' => '2011-01-01'
);
return $this->reply($result['status'], $reply);
}
/**
* Add entry
* Add DB entry
*
* @param Request $request
* @return
* @return string - Ajax Reply
*/
public function addExecute($request)
{
@ -63,15 +80,14 @@ class DB extends AjaxHandler
'DB_PASSWORD' => $_s['DB_PASSWORD'],
'TYPE' => $_s['TYPE']
);
if ($_s['HOST'])
{
if ($_s['HOST']) {
$params['HOST'] = $_s['HOST'];
}
$result = Vesta::execute(Vesta::V_ADD_DB_BASE, $params);
if (!$result['status'])
{
if (!$result['status']) {
$this->errors[] = array($result['error_code'] => $result['error_message']);
}
@ -79,17 +95,16 @@ class DB extends AjaxHandler
}
/**
* Delete entry
* Delete DB entry
*
* @param Request $request
* @return
* @return string - Ajax Reply
*/
public function delExecute($request)
{
$r = new Request();
$_s = $r->getSpell();
$_user = 'vesta';
$params = array(
'USER' => $_user,
'DB' => $_user.'_'.$_s['DB']
@ -97,8 +112,7 @@ class DB extends AjaxHandler
$result = Vesta::execute(Vesta::V_DEL_DB_BASE, $params);
if (!$result['status'])
{
if (!$result['status']) {
$this->errors[] = array($result['error_code'] => $result['error_message']);
}
@ -106,18 +120,16 @@ class DB extends AjaxHandler
}
/**
* Change password
* Change Password
*
* @param Request $request
* @return
* @return string - Ajax Reply
*/
public function changePasswordExecute($request)
{
$r = new Request();
$_s = $r->getSpell();
$_user = 'vesta';
$result = array();
$params = array(
'USER' => $_user,
@ -127,8 +139,7 @@ class DB extends AjaxHandler
$result = Vesta::execute(Vesta::V_CHANGE_DB_PASSWORD, $params);
if (!$result['status'])
{
if (!$result['status']) {
$this->errors[] = array($result['error_code'] => $result['error_message']);
}
@ -136,18 +147,16 @@ class DB extends AjaxHandler
}
/**
* suspend user
* Suspend DB entry
*
* @param Request $request
* @return
* @return string - Ajax Reply
*/
public function suspendExecute($request)
{
$r = new Request();
$_s = $r->getSpell();
$_user = 'vesta';
$params = array(
'USER' => $_user,
'DB' => $_user.'_'.$_s['DB']
@ -155,8 +164,7 @@ class DB extends AjaxHandler
$result = Vesta::execute(Vesta::V_SUSPEND_DB_BASE, $params);
if (!$result['status'])
{
if (!$result['status']) {
$this->errors[] = array($result['error_code'] => $result['error_message']);
}
@ -164,27 +172,23 @@ class DB extends AjaxHandler
}
/**
* unsuspend entry
* Unsuspend DB entry
*
* @param Request $request
* @return
* @return string - Ajax Reply
*/
public function unsuspendExecute($request)
{
$r = new Request();
$_s = $r->getSpell();
$_user = 'vesta';
$params = array(
'USER' => $_user,
'DB' => $_user.'_'.$_s['DB']
);
$result = Vesta::execute(Vesta::V_UNSUSPEND_DB_BASE, $params);
if (!$result['status'])
{
if (!$result['status']) {
$this->errors[] = array($result['error_code'] => $result['error_message']);
}
@ -192,16 +196,15 @@ class DB extends AjaxHandler
}
/**
* Batch suspend entries
* Batch Suspend DB entries
*
* @param Request $request
* @return
* @return string - Ajax Reply
*/
public function suspendAllExecute($request)
{
$r = new Request();
$_s = $r->getSpell();
$_user = 'vesta';
$_JOB = $_s['JOB'];
@ -211,8 +214,7 @@ class DB extends AjaxHandler
$result = Vesta::execute(Vesta::V_SUSPEND_DB_BASES, $params);
if (!$result['status'])
{
if (!$result['status']) {
$this->errors[] = array($result['error_code'] => $result['error_message']);
}
@ -220,26 +222,22 @@ class DB extends AjaxHandler
}
/**
* Batch unsuspend entries
* Batch unsuspend DB entries
*
* @param Request $request
* @return
* @return string - Ajax Reply
*/
public function unsuspendAllExecute($request)
{
$r = new Request();
$_s = $r->getSpell();
$_user = 'vesta';
$params = array(
'USER' => $_user
);
$result = Vesta::execute(Vesta::V_UNSUSPEND_DB_BASES, $params);
if (!$result['status'])
{
if (!$result['status']) {
$this->errors[] = array($result['error_code'] => $result['error_message']);
}

View file

@ -3,27 +3,29 @@
/**
* DNS
*
* @author Naumov-Socolov <naumov.socolov@gmail.com>
* @author Malishev Dima <dima.malishev@gmail.com>
* TODO: Too many "if" statements. Code should be refactored in order to not use a lot of "if" conditions
*
* @author vesta, http://vestacp.com/
* @author Dmitry Malishev <dima.malishev@gmail.com>
* @author Dmitry Naumov-Socolov <naumov.socolov@gmail.com>
* @copyright vesta 2010-2011
*/
class DNS extends AjaxHandler
{
/**
* list entries
* Get DNS entries
*
* @param Request $request
* @return
* @return string - Ajax Reply
*/
public function getListExecute($request) {
public function getListExecute($request)
{
$_user = 'vesta';
$reply = array();
$result = Vesta::execute(Vesta::V_LIST_DNS_DOMAINS, array($_user, Config::get('response_type')));
foreach ($result['data'] as $dns_domain => $details)
{
foreach ($result['data'] as $dns_domain => $details) {
$reply[] = array(
'DNS_DOMAIN' => $dns_domain,
'IP' => $details['IP'],
@ -35,8 +37,8 @@ class DNS extends AjaxHandler
'DATE' => date(Config::get('ui_date_format', strtotime($details['DATE'])))
);
}
if (!$result['status'])
{
if (!$result['status']) {
$this->errors[] = array($result['error_code'] => $result['error_message']);
}
@ -44,22 +46,20 @@ class DNS extends AjaxHandler
}
/**
* List records of entries
* Get DNS records
*
* @param Request $request
* @return
* @return string - Ajax Reply
*/
public function getListRecordsExecute($request)
{
$r = new Request();
$_s = $r->getSpell();
$_user = 'vesta';
$reply = array();
$result = Vesta::execute(Vesta::V_LIST_DNS_DOMAIN_RECORDS, array($_user, $_s['DNS_DOMAIN'], Config::get('response_type')));
foreach ($result['data'] as $record_id => $details)
{
foreach ($result['data'] as $record_id => $details) {
$reply[$record_id] = array(
'RECORD_ID' => $record_id,
'RECORD' => $details['RECORD'],
@ -70,8 +70,7 @@ class DNS extends AjaxHandler
);
}
if (!$result['status'])
{
if (!$result['status']) {
$this->errors[] = array($result['error_code'] => $result['error_message']);
}
@ -79,40 +78,46 @@ class DNS extends AjaxHandler
}
/**
* Add entry
* Add DB entry
*
* v_add_dns_domain user domain ip [template] [exp] [soa] [ttl]
* http://95.163.16.160:8083/dispatch.php?jedi_method=DNS.add&USER=vesta&DOMAIN=dev.vestacp.com&IP_ADDRESS=95.163.16.160&TEMPLATE=default&EXP=01-01-12&SOA=ns1.vestacp.com&TTL=3600
*
* @param Request $request
* @return
* @return string - Ajax Reply
*/
public function addExecute($_spell = false)
{
$r = new Request();
if ($_spell)
{
if ($_spell) {
$_s = $_spell;
}
else
{
else {
$_s = $r->getSpell();
}
$_user = 'vesta';
$params = array(
'USER' => $_user, // TODO: examine if OWNER ???
'USER' => $_user, /// OWNER ???
'DNS_DOMAIN' => $_s['DNS_DOMAIN'],
'IP' => $_s['IP']
);
($_s['TPL']) ? $params['TPL'] = $_s['TPL'] : -1;
($_s['EXP']) ? $params['EXP'] = $_s['EXP'] : -1;
($_s['SOA']) ? $params['SOA'] = $_s['SOA'] : -1;
($_s['TTL']) ? $params['TTL'] = $_s['TTL'] : -1;
// TODO: rewrite this block. Get away from if/if/if/if
if ($_s['TPL']) {
$params['TPL'] = $_s['TPL'];
}
if ($_s['EXP']) {
$params['EXP'] = $_s['EXP'];
}
if ($_s['SOA']) {
$params['SOA'] = $_s['SOA'];
}
if ($_s['TTL']) {
$params['TTL'] = $_s['TTL'];
}
$result = Vesta::execute(Vesta::V_ADD_DNS_DOMAIN, $params);
if (!$result['status'])
{
if (!$result['status']) {
$this->errors[] = array($result['error_code'] => $result['error_message']);
}
@ -120,10 +125,13 @@ class DNS extends AjaxHandler
}
/**
* Add record
* Add DNS record
*
* v_add_dns_domain_record user domain record type value [id]
* http://95.163.16.160:8083/dispatch.php?jedi_method=DNS.addRecord&USER=vesta&DOMAIN=dev.vestacp.com&RECORD=ftp&TYPE=a&VALUE=87.248.190.222
*
* @param Request $request
* @return
* @return string - Ajax Reply
*/
public function addRecordExecute($request)
{
@ -132,7 +140,7 @@ class DNS extends AjaxHandler
$_user = 'vesta';
$params = array(
'USER' => $_s['USER'], // TODO: find out if it's OWNER ???
'USER' => $_s['USER'], /// OWNER ???
'DOMAIN' => $_s['DOMAIN'],
'RECORD' => $_s['RECORD'],
'RECORD_TYPE' => $_s['TYPE'],
@ -142,73 +150,71 @@ class DNS extends AjaxHandler
$result = Vesta::execute(Vesta::V_ADD_DNS_DOMAIN_RECORD, $params);
if (!$result['status'])
{
if (!$result['status']) {
$this->errors[] = array($result['error_code'] => $result['error_message']);
}
return $this->reply($result['status'], $result['data']);
}
/**
* Delete entry
* Delete DNS entry
*
* @param mixed $_spell
* @return
* v_del_dns_domain user domain
* http://95.163.16.160:8083/dispatch.php?jedi_method=DNS.del&USER=vesta&DOMAIN=dev.vestacp.com
*
* @param Request $request
* @return string - Ajax Reply
*/
public function delExecute($_spell = false)
{
$r = new Request();
if ($_spell)
{
if ($_spell) {
$_s = $_spell;
}
else
{
else {
$_s = $r->getSpell();
}
$_user = 'vesta';
$params = array(
'USER' => $_user, // TODO: find out -> OWNER ???
'USER' => $_user, /// OWNER ???
'DOMAIN' => $_s['DNS_DOMAIN'],
);
$result = Vesta::execute(Vesta::V_DEL_DNS_DOMAIN, $params);
if (!$result['status'])
{
if (!$result['status']) {
$this->errors[] = array($result['error_code'] => $result['error_message']);
}
return $this->reply($result['status'], $result['data']);
}
/**
* Delete record
* Add DNS record
*
* v_del_dns_domain_record user domain id
* http://95.163.16.160:8083/dispatch.php?jedi_method=DNS.delRecord&USER=vesta&DOMAIN=dev.vestacp.com&RECORD_ID=9
*
* @param Request $request
* @return
* @return string - Ajax Reply
*/
function delRecordExecute($request)
public function delRecordExecute($request)
{
$r = new Request();
$_s = $r->getSpell();
$_user = 'vesta';
$params = array(
'USER' => $_user, // TODO: find out if -> OWNER ???
'USER' => $_user, // TODO: OWNER ???
'DOMAIN' => $_s['DOMAIN'],
'RECORD_ID' => $_s['RECORD_ID']
);
$result = Vesta::execute(Vesta::V_DEL_DNS_DOMAIN_RECORD, $params);
if (!$result['status'])
{
if (!$result['status']) {
$this->errors[] = array($result['error_code'] => $result['error_message']);
}
@ -216,10 +222,14 @@ class DNS extends AjaxHandler
}
/**
* Change entry
* Change DNS entry
*
* TODO: get away from multiple "if" statements
*
* DNS.change&spell={"old":{"DNS_DOMAIN": "dev.vestacp.com","IP": "95.163.16.160","TPL": "default","TTL": "3377","EXP": "12-12-12","SOA": "ns2.vestacp.com"},"new":{"DNS_DOMAIN": "dev.vestacp.com","IP": "95.163.16.160","TPL": "default","TTL": "3600","EXP": "02-02-12","SOA": "ns1.vestacp.com"}}
*
* @param Request $request
* @return
* @return string - Ajax Reply
*/
public function changeExecute($request)
{
@ -227,69 +237,57 @@ class DNS extends AjaxHandler
$_s = $r->getSpell();
$_old = $_s['old'];
$_new = $_s['new'];
$_user = 'vesta';
$_DNS_DOMAIN = $_new['DNS_DOMAIN'];
if ($_old['IP'] != $_new['IP'])
{
if ($_old['IP'] != $_new['IP']) {
$result = array();
$result = Vesta::execute(Vesta::V_CHANGE_DNS_DOMAIN_IP, array('USER' => $_user, 'DNS_DOMAIN' => $_DNS_DOMAIN, 'IP' => $_new['IP']));
if(!$result['status'])
{
if (!$result['status']) {
$this->status = FALSE;
$this->errors['IP_ADDRESS'] = array($result['error_code'] => $result['error_message']);
}
}
if ($_old['TPL'] != $_new['TPL'])
{
if ($_old['TPL'] != $_new['TPL']) {
$result = array();
$result = Vesta::execute(Vesta::V_CHANGE_DNS_DOMAIN_TPL, array('USER' => $_user, 'DNS_DOMAIN' => $_DNS_DOMAIN, 'IP' => $_new['TPL']));
if(!$result['status'])
{
if (!$result['status']) {
$this->status = FALSE;
$this->errors['TPL'] = array($result['error_code'] => $result['error_message']);
}
}
if ($_old['TTL'] != $_new['TTL'])
{
if ($_old['TTL'] != $_new['TTL']) {
$result = array();
$result = Vesta::execute(Vesta::V_CHANGE_DNS_DOMAIN_TTL, array('USER' => $_user, 'DNS_DOMAIN' => $_DNS_DOMAIN, 'IP' => $_new['TTL']));
if(!$result['status'])
{
if (!$result['status']) {
$this->status = FALSE;
$this->errors['TTL'] = array($result['error_code'] => $result['error_message']);
}
}
if ($_old['EXP'] != $_new['EXP'])
{
if ($_old['EXP'] != $_new['EXP']) {
$result = array();
$result = Vesta::execute(Vesta::V_CHANGE_DNS_DOMAIN_EXP, array('USER' => $_user, 'DNS_DOMAIN' => $_DNS_DOMAIN, 'IP' => $_new['EXP']));
if (!$result['status'])
{
if (!$result['status']) {
$this->status = FALSE;
$this->errors['EXP'] = array($result['error_code'] => $result['error_message']);
}
}
if ($_old['SOA'] != $_new['SOA'])
{
if ($_old['SOA'] != $_new['SOA']) {
$result = array();
$result = Vesta::execute(Vesta::V_CHANGE_DNS_DOMAIN_SOA, array('USER' => $_user, 'DNS_DOMAIN' => $_new['DNS_DOMAIN'], 'IP' => $_new['SOA']));
if (!$result['status'])
{
if (!$result['status']) {
$this->status = FALSE;
$this->errors['SOA'] = array($result['error_code'] => $result['error_message']);
}
}
if (!$this->status)
{
if (!$this->status) {
Vesta::execute(Vesta::V_CHANGE_DNS_DOMAIN_IP, array('USER' => $_user, 'DNS_DOMAIN' => $_DNS_DOMAIN, 'IP' => $_old['IP']));
Vesta::execute(Vesta::V_CHANGE_DNS_DOMAIN_TPL, array('USER' => $_user, 'DNS_DOMAIN' => $_DNS_DOMAIN, 'IP' => $_old['TPL']));
Vesta::execute(Vesta::V_CHANGE_DNS_DOMAIN_TTL, array('USER' => $_user, 'DNS_DOMAIN' => $_DNS_DOMAIN, 'IP' => $_old['TTL']));
@ -301,10 +299,10 @@ class DNS extends AjaxHandler
}
/**
* Change record
* Change DNS record
*
* @param Request $request
* @return
* @return string - Ajax Reply
*/
public function changeRecordsExecute($request)
{
@ -315,30 +313,26 @@ class DNS extends AjaxHandler
$_user = 'vesta';
$_DNS_DOMAIN = $_s['DNS_DOMAIN'];
foreach ($_new as $record_id => $record_data)
{
foreach ($_new as $record_id => $record_data) {
// checking if record existed - update
if(is_array($_old[$record_id]))
{
// TODO: Remove this. is it necessary??!
echo '<br> updating'.$record_id;
$result = Vesta::execute(Vesta::V_CHANGE_DNS_DOMAIN_RECORD, array('USER' => $_user, 'DNS_DOMAIN' => $_DNS_DOMAIN, 'ID' => $record_id, 'RECORD' => $record_data['RECORD'], 'TYPE' => $record_data['RECORD_TYPE'], 'VALUE' => $record_data['RECORD_VALUE']));
if(!$result['status'])
{
if (is_array($_old[$record_id])) {
$result = Vesta::execute(Vesta::V_CHANGE_DNS_DOMAIN_RECORD,
array(
'USER' => $_user,
'DNS_DOMAIN' => $_DNS_DOMAIN,
'ID' => $record_id,
'RECORD' => $record_data['RECORD'],
'TYPE' => $record_data['RECORD_TYPE'],
'VALUE' => $record_data['RECORD_VALUE']
));
if (!$result['status']) {
$this->status = FALSE;
$this->errors[$record_id] = array($result['error_code'] => $result['error_message']);
}
}
else
{
// record is new - add
// TODO: Remove this. is it necessary??!
echo '<br> adding'.$record_id;
else {
$result = Vesta::execute(Vesta::V_ADD_DNS_DOMAIN_RECORD, array('USER' => $_user, 'DNS_DOMAIN' => $_DNS_DOMAIN, 'RECORD' => $record_data['RECORD'], 'TYPE' => $record_data['RECORD_TYPE'], 'VALUE' => $record_data['RECORD_VALUE'], 'ID' => $record_id));
if(!$result['status'])
{
if (!$result['status']) {
$this->status = FALSE;
$this->errors[$record_id] = array($result['error_code'] => $result['error_message']);
}
@ -348,13 +342,16 @@ class DNS extends AjaxHandler
}
// in $_old have remained only record that do not present in new - so they have to be deleted
foreach ($_old as $record_id => $record_data)
{
echo '<br> deleting'.$record_id;
foreach ($_old as $record_id => $record_data) {
/*
$result = Vesta::execute(Vesta::V_DEL_DNS_DOMAIN_RECORD, array('USER' => $_user, 'DNS_DOMAIN' => $_DNS_DOMAIN, 'ID' => $record_id,));
if (!$result['status']) {
$this->status = FALSE;
$this->errors[$record_id] = array($result['error_code'] => $result['error_message']);
}
*/
}
return $this->reply($this->status, '');
}
}

View file

@ -2,34 +2,34 @@
/**
* IP
*
* @author Naumov-Socolov <naumov.socolov@gmail.com>
* @author Malishev Dima <dima.malishev@gmail.com>
* @author vesta, http://vestacp.com/
* @author Dmitry Malishev <dima.malishev@gmail.com>
* @author Dmitry Naumov-Socolov <naumov.socolov@gmail.com>
* @copyright vesta 2010-2011
*/
class IP extends AjaxHandler
{
/**
* List entries
* Get IP entries
*
* @param Request $request
* @return
* @return string - Ajax Reply
*/
public function getListExecute($request)
{
$reply = array();
$result = Vesta::execute(Vesta::V_LIST_SYS_IPS, array(Config::get('response_type')));
foreach ($result['data'] as $ip => $details)
{
$reply[] = array_merge(array(
foreach ($result['data'] as $ip => $details) {
$reply[] = array_merge(
array(
'IP_ADDRESS' => $ip,
'DATE' => date(Config::get('ui_date_format', strtotime($details['DATE'])))
), $details);
}
if (!$result['status'])
{
if (!$result['status']) {
$this->errors[] = array($result['error_code'] => $result['error_message']);
}
@ -37,26 +37,24 @@ class IP extends AjaxHandler
}
/**
* List user ips entries
* Get user's IPs
*
* @param Request $request
* @return
* @return string - Ajax Reply
*/
public function getListUserIpsExecute($request)
{
$reply = array();
$result = Vesta::execute(Vesta::V_LIST_SYS_IPS, array(Config::get('response_type')));
foreach ($result['data'] as $ip => $details)
{
$reply[] = array_merge(array(
foreach ($result['data'] as $ip => $details) {
$reply[] = array_merge(
array(
'IP_ADDRESS' => $ip,
'DATE' => date(Config::get('ui_date_format', strtotime($details['DATE'])))
), $details);
}
if (!$result['status'])
{
if (!$result['status']) {
$this->errors[] = array($result['error_code'] => $result['error_message']);
}
@ -64,10 +62,10 @@ class IP extends AjaxHandler
}
/**
* Add entry
* Add IP entry
*
* @param Request $request
* @return
* @return string - Ajax Reply
*/
public function addExecute($request)
{
@ -86,9 +84,7 @@ class IP extends AjaxHandler
$result = Vesta::execute(Vesta::V_ADD_SYS_IP, $params);
if (!$result['status'])
{
if (!$result['status']) {
$this->errors[] = array($result['error_code'] => $result['error_message']);
}
@ -96,25 +92,23 @@ class IP extends AjaxHandler
}
/**
* Delete entry
* Delete IP entry
*
* @param Request $request
* @return
* @return string - Ajax Reply
*/
public function delExecute($request)
{
$r = new Request();
$_s = $r->getSpell();
$_user = 'vesta';
$params = array(
'IP_ADDRESS' => $_s['IP_ADDRESS']
);
$result = Vesta::execute(Vesta::V_DEL_SYS_IP, $params);
if (!$result['status'])
{
if (!$result['status']) {
$this->errors[] = array($result['error_code'] => $result['error_message']);
}
@ -122,10 +116,10 @@ class IP extends AjaxHandler
}
/**
* Change entry
* Change IP entry
*
* @param Request $request
* @return
* @return string - Ajax Reply
*/
public function changeExecute($request)
{
@ -133,45 +127,36 @@ class IP extends AjaxHandler
$_s = $r->getSpell();
$_old = $_s['old'];
$_new = $_s['new'];
$_user = 'vesta';
if ($_old['OWNER'] != $_new['OWNER'])
{
if ($_old['OWNER'] != $_new['OWNER']) {
$result = array();
$result = Vesta::execute(Vesta::V_CHANGE_SYS_IP_OWNER, array('OWNER' => $_new['OWNER'], 'IP' => $_new['IP_ADDRESS']));
if(!$result['status'])
{
if (!$result['status']) {
$this->status = FALSE;
$this->errors['OWNER'] = array($result['error_code'] => $result['error_message']);
}
}
if ($_old['NAME'] != $_new['NAME'])
{
if ($_old['NAME'] != $_new['NAME']) {
$result = array();
$result = Vesta::execute(Vesta::V_CHANGE_SYS_IP_NAME, array('IP' => $_new['IP_ADDRESS'], 'NAME' => $_new['NAME']));
if (!$result['status'])
{
if (!$result['status']) {
$this->status = FALSE;
$this->errors['NAME'] = array($result['error_code'] => $result['error_message']);
}
}
if ($_old['IP_STATUS'] != $_new['IP_STATUS'])
{
if ($_old['IP_STATUS'] != $_new['IP_STATUS']) {
$result = array();
$result = Vesta::execute(Vesta::V_CHANGE_SYS_IP_STATUS, array('IP' => $_new['IP_ADDRESS'], 'IP_STATUS' => $_new['IP_STATUS']));
if (!$result['status'])
{
if (!$result['status']) {
$this->status = FALSE;
$this->errors['IP_STATUS'] = array($result['error_code'] => $result['error_message']);
}
}
if (!$result['status'])
{
if (!$result['status']) {
$this->errors[] = array($result['error_code'] => $result['error_message']);
}
@ -179,24 +164,21 @@ class IP extends AjaxHandler
}
/**
* Get sys interfaces
* Get Sys interfaces
*
* @param Request $request
* @return
* @return string - Ajax Reply
*/
public function getSysInterfacesExecute($request)
{
$reply = array();
$result = Vesta::execute(Vesta::V_LIST_SYS_INTERFACES, array(Config::get('response_type')));
foreach ($result['data'] as $iface)
{
foreach ($result['data'] as $iface) {
$reply[$iface] = $iface;
}
if (!$result['status'])
{
if (!$result['status']) {
$this->errors[] = array($result['error_code'] => $result['error_message']);
}

View file

@ -9,19 +9,19 @@
* - methods, used for ajax executions must be postfixed with execute keyword
* Eg.: getDnsInformationExecute()
*
* @author Naumov-Socolov <naumov.socolov@gmail.com>
* @author Malishev Dima <dima.malishev@gmail.com>
* @author vesta, http://vestacp.com/
* @author Dmitry Malishev <dima.malishev@gmail.com>
* @author Dmitry Naumov-Socolov <naumov.socolov@gmail.com>
* @copyright vesta 2010-2011
*/
class MAIN extends AjaxHandler
{
/**
* Get version
* Get Version
*
* @param Request $request
* @return
* @return string - Ajax Reply
*/
public function versionExecute($request)
{
@ -35,53 +35,97 @@ class MAIN extends AjaxHandler
}
/**
* Get initial params
* Get Initial params.
* Global constants / variables / configs
*
* @param Request $request
* @return
* @return string - Ajax Reply
*/
public function getInitialExecute($request)
{
require_once V_ROOT_DIR . 'api/IP.class.php';
require_once V_ROOT_DIR . 'api/USER.class.php';
// IP
$ip_obj = new IP();
$user_obj = new USER();
$user_ips = json_decode($ip_obj->getListUserIpsExecute(), TRUE);
foreach ($user_ips['data'] as $ip)
{
foreach ($user_ips['data'] as $ip) {
$ips[$ip['IP_ADDRESS']] = $ip['IP_ADDRESS'];
}
// USER
$user_obj = new USER();
$users = json_decode($user_obj->getListExecute(), TRUE);
$user_names = array_keys($users['data']['data']);
$db_types = array(
'mysql' => 'mysql',
'postgress' => 'postgress'
);
$db_types = array('mysql' => 'mysql', 'postgress' => 'postgress');
$interfaces_arr = json_decode($ip_obj->getSysInterfacesExecute(), TRUE);
$interfaces = $interfaces_arr['data'];
$data_web_domain = array('ips' => $ips);
$data_ip = array('user_names' => $user_names, 'interfaces' => $interfaces);
$data_dns = array('ips' => $ips);
$data_db = array('db_types' => $db_types);
$data_users = array('user_names' => $user_names);
$reply = array(
'WEB_DOMAIN' => array(
'WEB_DOMAIN' => $this->getWebDomainParams($data_web_domain),
'CRON' => $this->getCronParams(),
'IP' => $this->getIpParams($data_ip),
'DNS' => $this->getDnsParams(),
'DB' => $this->getDbParams($data_db),
'USERS' => $this->getUsersParams($data_users)
);
return $this->reply(true, $reply);
}
//
//
//
/**
* WEB DOMAIN initial params
*
* @params array $data
* @return array
*/
public function getWebDomainParams($data = array())
{
return array(
'TPL' => array('default' => 'default'),
'ALIAS' => array(),
'STAT' => array(
'webalizer' => 'webalizer',
'awstats' => 'awstats'),
'IP' => $ips
'awstats' => 'awstats'
),
'CRON' => array(),
'IP' => array(
'SYS_USERS' => $user_names,
'IP' => $data['ips']
);
}
/**
* CRON initial params
*
* @params array $data
* @return array
*/
public function getCronParams($data = array())
{
return array();
}
/**
* IP initial params
*
* @params array $data
* @return array
*/
public function getIpParams($data = array())
{
return array(
'SYS_USERS' => $data['user_names'],
'STATUSES' => array(
'shared' => 'shared',
'exclusive' => 'exclusive'
),
'INTERFACES' => $interfaces,
'INTERFACES' => $data['interfaces'],
'MASK' => array(
'255.255.255.0' => '255.255.255.0',
'255.255.255.128' => '255.255.255.128',
@ -92,13 +136,21 @@ class MAIN extends AjaxHandler
'255.255.255.252' => '255.255.255.252',
'255.255.255.255' => '255.255.255.255'
),
'OWNER' => array()
),
'DNS' => array(
'IP' => $ips,
'TPL' => array(
'default' => 'default'
),
'OWNER' => array('Chuck Norris' => 'Chuck Norris')
);
}
/**
* DNS initial params
*
* @params array $data
* @return array
*/
public function getDnsParams($data = array())
{
return array(
'IP' => $data['ips'],
'TPL' => array('default' => 'default'),
'EXP' => array(),
'SOA' => array(),
'TTL' => array(),
@ -107,13 +159,34 @@ class MAIN extends AjaxHandler
'RECORD_TYPE' => array('a' => 'a', 'reverse' => 'reverse'),
'RECORD_VALUE' => array()
)
),
'DB' => array(
'TYPE' => $db_types
),
'USERS' => array(
);
}
/**
* DB initial params
*
* @params array $data
* @return array
*/
public function getDbParams($data = array())
{
return array(
'TYPE' => $data['db_types'],
'HOST' => array('vestacp.com' => 'vestacp.com', 'askcow.org' => 'askcow.org')
);
}
/**
* Users initial params
*
* @params array $data
* @return array
*/
public function getUsersParams($data = array())
{
return array(
'ROLE' => array('user' => 'user'),
'OWNER' => $user_names,
'OWNER' => $data['user_names'],
'PACKAGE' => array('default' => 'default'),
'NS1' => array('' => ''),
'NS2' => array('' => ''),
@ -123,9 +196,7 @@ class MAIN extends AjaxHandler
'/sbin/nologin' => '/sbin/nologin',
'/bin/tcsh' => '/bin/tcsh',
'/bin/csh' => '/bin/csh')
)
);
}
return $this->reply(true, $reply);
}
}

View file

@ -1,46 +1,35 @@
<?php
/**
* PARAMS
*
* @author Naumov-Socolov <naumov.socolov@gmail.com>
* @author Malishev Dima <dima.malishev@gmail.com>
* @deprecated
*
* @author vesta, http://vestacp.com/
* @author Dmitry Malishev <dima.malishev@gmail.com>
* @author Dmitry Naumov-Socolov <naumov.socolov@gmail.com>
* @copyright vesta 2010-2011
*/
class PARAMS extends AjaxHandler
{
/**
* Get initial params
*
* @param Request $request
* @return
*/
public function getInitialExecute($request)
class PARAMS extends AjaxHandler {
/*
function getInitialExecute($request)
{
require_once V_ROOT_DIR . 'api/IP.class.php';
require_once V_ROOT_DIR . 'api/USER.class.php';
$ip_obj = new IP();
$user_obj = new USER();
$user_ips = json_decode($ip_obj->getListUserIpsExecute(), TRUE);
foreach($user_ips['data'] as $ip)
{
$ips[$ip['IP_ADDRESS']] = $ip['IP_ADDRESS'];
}
require_once V_ROOT_DIR . 'api/USER.class.php';
$user_obj = new USER();
$users = json_decode($user_obj->getListExecute(), TRUE);
$user_names = array_keys($users['data']['data']);
$db_types = array(
'mysql' => 'mysql',
'postgress' => 'postgress'
);
$db_types = array('mysql' => 'mysql', 'postgress' => 'postgress');
$interfaces_arr = json_decode($ip_obj->getSysInterfacesExecute(), TRUE);
$interfaces = $interfaces_arr['data'];
$reply = array(
'WEB_DOMAIN' => array(
'TPL' => array('default' => 'default'),
@ -50,7 +39,9 @@ class PARAMS extends AjaxHandler
'awstats' => 'awstats'),
'IP' => $ips
),
'CRON' => array(),
'IP' => array(
'SYS_USERS' => $user_names,
'STATUSES' => array(
@ -70,23 +61,25 @@ class PARAMS extends AjaxHandler
),
'OWNER' => array()
),
'DNS' => array(
'IP' => $ips,
'TPL' => array(
'default' => 'default'
),
'TPL' => array('default' => 'default'),
'EXP' => array(),
'SOA' => array(),
'TTL' => array(),
'record' => array(
'RECORD' => array(),
'RECORD_TYPE' => array('a' => 'a', 'reverse' => 'reverse'),
'RECORD_TYPE' => array('a' => 'a', 'reverce' => 'reverce'),
'RECORD_VALUE' => array()
)
),
'DB' => array(
'TYPE' => $db_types
'TYPE' => $db_types,
'HOST' => array('vestacp.com' => 'vestacp.com', 'askcow.org' => 'askcow.org')
),
'USERS' => array(
'ROLE' => array('user' => 'user'),
'OWNER' => $user_names,
@ -103,5 +96,5 @@ class PARAMS extends AjaxHandler
);
return $this->reply(true, $reply);
}
}*/
}

View file

@ -2,60 +2,94 @@
/**
* USERS
*
* @author Naumov-Socolov <naumov.socolov@gmail.com>
* @author Malishev Dima <dima.malishev@gmail.com>
* @author vesta, http://vestacp.com/
* @author Dmitry Malishev <dima.malishev@gmail.com>
* @author Dmitry Naumov-Socolov <naumov.socolov@gmail.com>
* @copyright vesta 2010-2011
*/
class USER extends AjaxHandler
{
/**
* Get list
* Get USER entries
*
* @param Request $request
* @return
* @return string - Ajax Reply
*/
public function getListExecute($request)
{
$reply = array();
$result = Vesta::execute(Vesta::V_LIST_SYS_USERS, array(Config::get('response_type')));
$users = array('Han Solo', 'Darth Vader', 'Jabba the Hutt', 'Boba Fett', 'Jango Fett', ' Aurra Sing', 'Padme',
'Tusken Raider', 'General Grievous', 'Wedge Antilles', 'Padme Amidala', 'Bib Fortuna', 'Kyle Katarn',
'Quinlan Vos', 'Princess Leia', 'Obi-Wan Kenobi', 'Han Solo', 'Hondo Ohnaka', 'Noa Briqualon', 'C3P0',
'R2-D2', 'Quinlan Vos', 'Mara Jade' , 'Luke Skywalker', 'Luke Skywalker' , 'Luke Skywalker'
);
foreach ($result as $ip => $details)
{
$reply[] = array(
'interface' => $details['INTERFACE'],
'sys_users' => $details['U_SYS_USERS'],
'web_domains' => $details['U_WEB_DOMAINS'],
'status' => $details['STATUS'],
'ip' => $ip,
'net_mask' => $details['NETMASK'],
'name' => $details['NAME'],
'owner' => $details['OWNER'],
'created_at' => date(Config::get('ui_date_format', strtotime($details['DATE'])))
foreach ($result['data'] as $user => $details) {
$fullname_id = rand(0, count($users)-1);
$fullname = $users[$fullname_id];
$reply[$user] = array(
"LOGIN_NAME" => $user,
"FULLNAME" => $fullname, // TODO skid
"PACKAGE" => $details['PACKAGE'],
"WEB_DOMAINS" => $details['WEB_DOMAINS'],
"WEB_SSL" => $details['WEB_SSL'],
"WEB_ALIASES" => $details['WEB_ALIASES'],
"DATABASES" => $details['DATABASES'],
"MAIL_DOMAINS" => $details['MAIL_DOMAINS'],
"MAIL_BOXES" => $details['MAIL_BOXES'],
"MAIL_FORWARDERS" => $details['MAIL_FORWARDERS'],
"DNS_DOMAINS" => $details['DNS_DOMAINS'],
"DISK_QUOTA" => $details['DISK_QUOTA'],//$disk_quota,
"BANDWIDTH" => $details['BANDWIDTH'],//$bandwidth,
"NS_LIST" => array($details['NS1'], $details['NS2']), // TODO skid
"SHELL" => $details['"SHELL'],
"BACKUPS" => $details['BACKUPS'],
"WEB_TPL" => $details['WEB_TPL'],
"MAX_CHILDS" => $details['MAX_CHILDS'],
"SUSPENDED" => $details['SUSPENDED'],
"OWNER" => $details['OWNER'],
"ROLE" => $details['ROLE'],
"IP_OWNED" => $details['IP_OWNED'],
"U_CHILDS" => $details['U_CHILDS'],
"U_DISK" => $details['U_DISK'],//$u_disk,
"U_BANDWIDTH" => $details['U_BANDWIDTH'],//$u_bandwidth,
"U_WEB_DOMAINS" => $details['U_WEB_DOMAINS'],
"U_WEB_SSL" => $details['U_WEB_SSL'],
"U_DNS_DOMAINS" => $details['U_DNS_DOMAINS'],
"U_DATABASES" => $details['U_DATABASES'],
"U_MAIL_DOMAINS" => $details['U_MAIL_DOMAINS'],
"CONTACT" => $details['CONTACT'],
"DATE" => $details['DATE'],
"U_MAIL_BOXES" => rand(1, 10), // TODO: skid
"U_MAIL_FORWARDERS" => rand(1, 10), // TODO: skid
"REPORTS_ENABLED" => 'enabled' // TODO: skid
);
}
return $this->reply(true, $result);
return $this->reply(TRUE, $reply);
}
/**
* Add action
* Add USER entry
*
* @param Request $request
* @return
* @return string - Ajax Reply
*/
public function addExecute($_spell = false)
public function addExecute($_spell = FALSE)
{
$r = new Request();
if ($_spell)
{
if ($_spell) {
$_s = $_spell;
}
else
{
else {
$_s = $r->getSpell();
}
$_user = 'vesta';
$params = array(
'USER' => $_s['USER'],
@ -69,8 +103,8 @@ class USER extends AjaxHandler
);
$result = Vesta::execute(Vesta::V_ADD_SYS_USER, $params);
if (!$result['status'])
{
if (!$result['status']) {
$this->errors[] = array($result['error_code'] => $result['error_message']);
}
@ -78,30 +112,29 @@ class USER extends AjaxHandler
}
/**
* Delete action
* Delete USER entry
*
* @param Request $request
* @return
* @return string - Ajax Reply
*/
public function delExecute($_spell = false)
{
$r = new Request();
if ($_spell)
{
if ($_spell) {
$_s = $_spell;
}
else
{
else {
$_s = $r->getSpell();
}
$_user = 'vesta';
$params = array(
'USER' => $_s['USER']
);
$result = Vesta::execute(Vesta::V_DEL_SYS_USER, $params);
if (!$result['status'])
{
if (!$result['status']) {
$this->errors[] = array($result['error_code'] => $result['error_message']);
}
@ -109,10 +142,10 @@ class USER extends AjaxHandler
}
/**
* Change action
* Change USER entry
*
* @param Request $request
* @return
* @return string - Ajax Reply
*/
public function changeExecute($request)
{
@ -123,15 +156,12 @@ class USER extends AjaxHandler
$_USER = $_new['USER'];
if($_old['USER'] != $_new['USER'])
{
if ($_old['USER'] != $_new['USER']) {
$result = array();
// creating new user
$result = $this->addExecute($_new);
// deleting old
if ($result['status'])
{
if ($result['status']) {
$result = array();
$result = $this->delExecute($_old);
@ -139,77 +169,59 @@ class USER extends AjaxHandler
}
}
if ($_old['PASSWORD'] != $_new['PASSWORD'])
{
if ($_old['PASSWORD'] != $_new['PASSWORD']) {
$result = array();
$result = Vesta::execute(Vesta::V_CHANGE_SYS_USER_PASSWORD,
array('USER' => $_USER, 'PASSWORD' => $_new['PASSWORD']));
if (!$result['status'])
{
$result = Vesta::execute(Vesta::V_CHANGE_SYS_USER_PASSWORD, array('USER' => $_USER, 'PASSWORD' => $_new['PASSWORD']));
if (!$result['status']) {
$this->status = FALSE;
$this->errors['PASSWORD'] = array($result['error_code'] => $result['error_message']);
}
}
if ($_old['PACKAGE'] != $_new['PACKAGE'])
{
if ($_old['PACKAGE'] != $_new['PACKAGE']) {
$result = array();
$result = Vesta::execute(Vesta::V_CHANGE_SYS_USER_PACKAGE,
array('USER' => $_USER, 'PACKAGE' => $_new['PACKAGE']));
if (!$result['status'])
{
$result = Vesta::execute(Vesta::V_CHANGE_SYS_USER_PACKAGE, array('USER' => $_USER, 'PACKAGE' => $_new['PACKAGE']));
if (!$result['status']) {
$this->status = FALSE;
$this->errors['PACKAGE'] = array($result['error_code'] => $result['error_message']);
}
}
if ($_old['EMAIL'] != $_new['EMAIL'])
{
if ($_old['EMAIL'] != $_new['EMAIL']) {
$result = array();
$result = Vesta::execute(Vesta::V_CHANGE_SYS_USER_CONTACT,
array('USER' => $_USER, 'EMAIL' => $_new['EMAIL']));
if (!$result['status'])
{
$result = Vesta::execute(Vesta::V_CHANGE_SYS_USER_CONTACT, array('USER' => $_USER, 'EMAIL' => $_new['EMAIL']));
if (!$result['status']) {
$this->status = FALSE;
$this->errors['EMAIL'] = array($result['error_code'] => $result['error_message']);
}
}
if ($_old['NS1'] != $_new['NS1'] || $_old['NS2'] != $_new['NS2'])
{
if ($_old['NS1'] != $_new['NS1'] || $_old['NS2'] != $_new['NS2']) {
$result = array();
$result = Vesta::execute(Vesta::V_CHANGE_SYS_USER_NS,
array('USER' => $_USER, 'NS1' => $_new['NS1'], 'NS2' => $_new['NS2']));
if (!$result['status'])
{
$result = Vesta::execute(Vesta::V_CHANGE_SYS_USER_NS, array('USER' => $_USER, 'NS1' => $_new['NS1'], 'NS2' => $_new['NS2']));
if (!$result['status']) {
$this->status = FALSE;
$this->errors['NS'] = array($result['error_code'] => $result['error_message']);
}
}
if ($_old['SHELL'] != $_new['SHELL'])
{
if ($_old['SHELL'] != $_new['SHELL']) {
$result = array();
$result = Vesta::execute(Vesta::V_CHANGE_SYS_USER_SHELL,
array('USER' => $_USER, 'SHELL' => $_new['SHELL']));
if (!$result['status'])
{
$result = Vesta::execute(Vesta::V_CHANGE_SYS_USER_SHELL, array('USER' => $_USER, 'SHELL' => $_new['SHELL']));
if (!$result['status']) {
$this->status = FALSE;
$this->errors['SHELL'] = array($result['error_code'] => $result['error_message']);
}
}
if (!$this->status)
{
if (!$this->status) {
Vesta::execute(Vesta::V_CHANGE_SYS_USER_PASSWORD, array('USER' => $_USER, 'PASSWORD' => $_old['PASSWORD']));
Vesta::execute(Vesta::V_CHANGE_SYS_USER_PACKAGE, array('USER' => $_USER, 'PACKAGE' => $_old['PACKAGE']));
Vesta::execute(Vesta::V_CHANGE_SYS_USER_CONTACT, array('USER' => $_USER, 'EMAIL' => $_old['EMAIL']));
// change role // $result = Vesta::execute(Vesta::V_CHANGE_SYS_USER_PACKAGE, array('USER' => $_USER, 'PACKAGE' => $_new['PACKAGE']));
Vesta::execute(Vesta::V_CHANGE_SYS_USER_NS, array('USER' => $_USER, 'NS1' => $_old['NS1'], 'NS2' => $_old['NS2']));
Vesta::execute(Vesta::V_CHANGE_SYS_USER_SHELL, array('USER' => $_USER, 'SHELL' => $_old['SHELL']));
}
return $this->reply($this->status, '');
}
}

View file

@ -1,28 +1,23 @@
<?php
/**
* DOMAIN
*
* @author Naumov-Socolov <naumov.socolov@gmail.com>
* @author Malishev Dima <dima.malishev@gmail.com>
* @author vesta, http://vestacp.com/
* @author Dmitry Malishev <dima.malishev@gmail.com>
* @author Dmitry Naumov-Socolov <naumov.socolov@gmail.com>
* @copyright vesta 2010-2011
*/
class WEB_DOMAIN extends AjaxHandler
{
/**
* Get list
*
* @param Request $request
* @return
*/
public function getListExecute($request)
class WEB_DOMAIN extends AjaxHandler {
function getListExecute($request)
{
$_user = 'vesta';
$reply = array();
$result = Vesta::execute(Vesta::V_LIST_WEB_DOMAINS, array($_user, Config::get('response_type')));
// echo '<pre>';
// print_r($result);
foreach($result['data'] as $web_domain => $data)
{
$reply[$web_domain] = array(
@ -47,20 +42,14 @@ class WEB_DOMAIN extends AjaxHandler
}
if(!$result['status'])
{
$this->errors[] = array($result['error_code'] => $result['error_message']);
}
return $this->reply($result['status'], $reply);
}
/**
* Add entry
*
* @param Request $request
* @return
*/
public function addExecute($request)
function addExecute($request)
{
$r = new Request();
$_s = $r->getSpell();
@ -75,128 +64,98 @@ class WEB_DOMAIN extends AjaxHandler
$result = Vesta::execute(Vesta::V_ADD_WEB_DOMAIN, $params);
if(!$result['status'])
{
$this->errors[] = array(
$result['error_code'] => $result['error_message']
);
}
$this->errors[] = array($result['error_code'] => $result['error_message']);
// if(0)
if($_s['TPL'])
{
$params = array(
'USER' => $_user,
$params = array('USER' => $_user,
'DOMAIN' => $_s['DOMAIN'],
'TPL' => $_s['TPL']
);
'TPL' => $_s['TPL']);
$result = 0;
$result = Vesta::execute(Vesta::V_CHANGE_WEB_DOMAIN_TPL, $params);
if(!$result['status'])
{
$this->errors['CHANGE_TPL'] = array(
$result['error_code'] => $result['error_message']
);
}
$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,
$params = array('USER' => $_user,
'DOMAIN' => $_s['DOMAIN'],
'ALIAS' => trim($alias)
);
'ALIAS' => trim($alias));
$result = 0;
$result = Vesta::execute(Vesta::V_ADD_WEB_DOMAIN_ALIAS, $params);
if(!$result['status'])
{
$this->errors['ALIAS'] = array(
$result['error_code'] => $result['error_message']
);
}
$this->errors['ALIAS'] = array($result['error_code'] => $result['error_message']);
}
}
// if(0)
if($_s['STAT'])
{
$params = array(
'USER' => $_user,
$params = array('USER' => $_user,
'DOMAIN' => $_s['DOMAIN'],
'STAT' => $_s['STAT']
);
'STAT' => $_s['STAT']);
$result = 0;
$result = Vesta::execute(Vesta::V_ADD_WEB_DOMAIN_STAT, $params);
if(!$result['status'])
{
$this->errors['STATS'] = array(
$result['error_code'] => $result['error_message']
);
}
$this->errors['STATS'] = array($result['error_code'] => $result['error_message']);
}
// if(0)
if($_s['STAT_AUTH'])
{
$params = array(
'USER' => $_user,
$params = array('USER' => $_user,
'DOMAIN' => $_s['DOMAIN'],
'STAT_USER' => $_s['STAT_USER'],
'STAT_PASSWORS' => $_s['STAT_PASSWORD']
);
'STAT_PASSWORS' => $_s['STAT_PASSWORD']);
$result = 0;
$result = Vesta::execute(Vesta::V_ADD_WEB_DOMAIN_STAT_AUTH, $params);
if(!$result['status'])
{
$this->errors['STAT_AUTH'] = array(
$result['error_code'] => $result['error_message']
);
}
$this->errors['STAT_AUTH'] = array($result['error_code'] => $result['error_message']);
}
if(0)
if($_s['SSL'])
{
$params = array(
'USER' => $_user,
$params = array('USER' => $_user,
'DOMAIN' => $_s['DOMAIN'],
'SSL_CERT' => $_s['SSL_CERT']
);
'SSL_CERT' => $_s['SSL_CERT']);
if($_s['SSL_HOME'])
{
$params['SSL_HOME'] = $_s['SSL_HOME'];
}
if($_s['SSL_TEXT'])
{
// TODO: write it up
}
{}
// 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']
);
}
$this->errors['SSL'] = array($result['error_code'] => $result['error_message']);
}
// if(0)
if($_s['CREATE_DNS_DOMAIN'])
{
$params = array(
'USER' => $_user,
$params = array('USER' => $_user,
'DNS_DOMAIN' => $_s['DOMAIN'],
'IP' => $_s['IP']
);
'IP' => $_s['IP']);
require_once V_ROOT_DIR . 'api/DNS.class.php';
@ -204,20 +163,16 @@ class WEB_DOMAIN extends AjaxHandler
$result = 0;
$result = $dns->addExecute($params);
if(!$result['status'])
{
$this->errors['DNS_DOMAIN'] = array(
$result['error_code'] => $result['error_message']
);
}
$this->errors['DNS_DOMAIN'] = array($result['error_code'] => $result['error_message']);
}
if(0)
if($_s['CREATE_MAIL_DOMAIN'])
{
$params = array(
'USER' => $_user,
$params = array('USER' => $_user,
'MAIL_DOMAIN' => $_s['DOMAIN'],
'IP' => $_s['IP']
);
'IP' => $_s['IP']);
require_once V_ROOT_DIR . 'api/MAIL.class.php';
@ -225,23 +180,13 @@ class WEB_DOMAIN extends AjaxHandler
$result = 0;
$result = $mail->addExecute($params);
if(!$result['status'])
{
$this->errors['MAIL_DOMAIN'] = array(
$result['error_code'] => $result['error_message']
);
}
$this->errors['MAIL_DOMAIN'] = array($result['error_code'] => $result['error_message']);
}
return $this->reply($result['status'], $result['data']);
}
/**
* Delete entry
*
* @param Request $request
* @return
*/
public function delExecute($request)
function delExecute($request)
{
$r = new Request();
$_s = $r->getSpell();
@ -255,9 +200,9 @@ class WEB_DOMAIN extends AjaxHandler
$result = Vesta::execute(Vesta::V_DEL_WEB_DOMAIN, $params);
if(!$result['status'])
$this->errors[] = array(
$result['error_code'] => $result['error_message']
);
$this->errors[] = array($result['error_code'] => $result['error_message']);
$params = array(
'USER' => $_user,
@ -269,11 +214,7 @@ class WEB_DOMAIN extends AjaxHandler
$result = $dns->delExecute($params);
if(!$result['status'] && $result['error_code'] != 31) // domain not found
{
$this->errors['DNS'] = array(
$result['error_code'] => $result['error_message']
);
}
$this->errors['DNS'] = array($result['error_code'] => $result['error_message']);
require_once V_ROOT_DIR . 'api/DNS.class.php';
@ -282,16 +223,20 @@ class WEB_DOMAIN extends AjaxHandler
'MAIL_DOMAIN' => $_s['DOMAIN']
);
/*
require_once V_ROOT_DIR . 'api/MAIL.class.php';
$mail = new MAIL();
$result = $mail->delExecute($params);
if(!$result['status'] && $result['error_code'] != 31) // domain not found
$this->errors['MAIL'] = array($result['error_code'] => $result['error_message']);
*/
return $this->reply($result['status'], $result['data']);
}
/**
* Change entry
*
* @param Request $request
* @return
*/
public function changeExecute($request)
function changeExecute($request)
{
$r = new Request();
$_s = $r->getSpell();
@ -304,34 +249,23 @@ 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, 'DOMAIN' => $_DOMAIN, 'IP' => $_new['IP']));
if(!$result['status'])
{
$this->status = FALSE;
$this->errors['IP_ADDRESS'] = array(
$result['error_code'] => $result['error_message']
);
$this->errors['IP_ADDRESS'] = array($result['error_code'] => $result['error_message']);
}
}
if($_old['TPL'] != $_new['TPL'])
{
$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, 'DOMAIN' => $_DOMAIN, 'TPL' => $_new['TPL']));
if(!$result['status'])
{
$this->status = FALSE;
$this->errors['TPL'] = array(
$result['error_code'] => $result['error_message']
);
$this->errors['TPL'] = array($result['error_code'] => $result['error_message']);
}
}
@ -347,32 +281,20 @@ class WEB_DOMAIN extends AjaxHandler
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, 'DOMAIN' => $_DOMAIN, 'ALIAS' => $alias));
if(!$result['status'])
{
$this->status = FALSE;
$this->errors['ADD_ALIAS'] = array(
$result['error_code'] => $result['error_message']
);
$this->errors['ADD_ALIAS'] = array($result['error_code'] => $result['error_message']);
}
}
foreach($deleted as $alias)
{
$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, 'DOMAIN' => $_DOMAIN, 'ALIAS' => $alias));
if(!$result['status'])
{
$this->status = FALSE;
$this->errors['DEL_ALIAS'] = array(
$result['error_code'] => $result['error_message']
);
$this->errors['DEL_ALIAS'] = array($result['error_code'] => $result['error_message']);
}
}
}
@ -383,60 +305,47 @@ class WEB_DOMAIN extends AjaxHandler
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, 'DOMAIN' => $_DOMAIN, 'STAT' => $_new['STAT']));
if(!$result['status'])
{
$this->status = FALSE;
$this->errors['ADD_STAT'] = array(
$result['error_code'] => $result['error_message']
);
$this->errors['ADD_STAT'] = array($result['error_code'] => $result['error_message']);
}
}
if($_new['STAT'] == false)
{
$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, 'DOMAIN' => $_DOMAIN));
if(!$result['status'])
{
$this->status = FALSE;
$this->errors['DEL_STAT'] = array(
$result['error_code'] => $result['error_message']
);
$this->errors['DEL_STAT'] = array($result['error_code'] => $result['error_message']);
}
$result = array();
$result = Vesta::execute(Vesta::V_DEL_WEB_DOMAIN_STAT_AUTH, array(
'USER' => $_user,
'DOMAIN' => $_DOMAIN,
'STAT_USER' => $_new['STAT_USER']
));
$result = Vesta::execute(Vesta::V_DEL_WEB_DOMAIN_STAT_AUTH, array('USER' => $_user, 'DOMAIN' => $_DOMAIN, 'STAT_USER' => $_new['STAT_USER']));
if(!$result['status'])
{
$this->status = FALSE;
$this->errors['DEL_STAT_AUTH'] = array(
$result['error_code'] => $result['error_message']
);
$this->errors['DEL_STAT_AUTH'] = array($result['error_code'] => $result['error_message']);
}
}
}
if(0)
// ssl
if($_old['SSL'] != $_new['SSL'])
{
if($_new['SSL'] == true)
{
// TODO: write it
}
if($_new['SSL'] == false)
{
// TODO: write it
}
}
else
@ -447,33 +356,21 @@ class WEB_DOMAIN extends AjaxHandler
$_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
));
$result = Vesta::execute(Vesta::V_CHANGE_WEB_DOMAIN_CERT, array('USER' => $_user, 'DOMAIN' => $_DOMAIN, 'SSL_CERT' => $_SSL_CERT ));
if(!$result['status'])
{
$this->status = FALSE;
$this->errors['SSL_CERT'] = array(
$result['error_code'] => $result['error_message']
);
$this->errors['SSL_CERT'] = array($result['error_code'] => $result['error_message']);
}
}
if($_old['SSL_HOME'] != $_new['SSL_HOME'])
{
$result = array();
$result = Vesta::execute(Vesta::V_CHANGE_WEB_DOMAIN_SSLHOME, array(
'USER' => $_user,
'DOMAIN' => $_DOMAIN,
'SSL_HOME' => $_new['SSL_HOME']
));
$result = Vesta::execute(Vesta::V_CHANGE_WEB_DOMAIN_SSLHOME, array('USER' => $_user, 'DOMAIN' => $_DOMAIN, 'SSL_HOME' => $_new['SSL_HOME']));
if(!$result['status'])
{
$this->status = FALSE;
$this->errors['SSL_HOME'] = array(
$result['error_code'] => $result['error_message']
);
$this->errors['SSL_HOME'] = array($result['error_code'] => $result['error_message']);
}
}
}
@ -483,31 +380,21 @@ class WEB_DOMAIN extends AjaxHandler
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, 'DOMAIN' => $_DOMAIN));
if(!$result['status'])
{
$this->status = FALSE;
$this->errors['ADD_CGI'] = array(
$result['error_code'] => $result['error_message']
);
$this->errors['ADD_CGI'] = array($result['error_code'] => $result['error_message']);
}
}
if($_new['CGI'] == false)
{
$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, 'DOMAIN' => $_DOMAIN));
if(!$result['status'])
{
$this->status = FALSE;
$this->errors['DEL_CGI'] = array(
$result['error_code'] => $result['error_message']
);
$this->errors['DEL_CGI'] = array($result['error_code'] => $result['error_message']);
}
}
}
@ -517,31 +404,21 @@ class WEB_DOMAIN extends AjaxHandler
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, 'DOMAIN' => $_DOMAIN));
if(!$result['status'])
{
$this->status = FALSE;
$this->errors['ADD_ELOG'] = array(
$result['error_code'] => $result['error_message']
);
$this->errors['ADD_ELOG'] = array($result['error_code'] => $result['error_message']);
}
}
if($_new['ELOG'] == false)
{
$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, 'DOMAIN' => $_DOMAIN));
if(!$result['status'])
{
$this->status = FALSE;
$this->errors['DEL_ELOG'] = array(
$result['error_code'] => $result['error_message']
);
$this->errors['DEL_ELOG'] = array($result['error_code'] => $result['error_message']);
}
}
}
@ -550,13 +427,9 @@ class WEB_DOMAIN extends AjaxHandler
return $this->reply($result['status'], $result['data']);
}
/**
* Suspend entry
*
* @param Request $request
* @return
*/
public function suspendExecute($request)
function suspendExecute($request)
{
$r = new Request();
$_s = $r->getSpell();
@ -571,22 +444,13 @@ class WEB_DOMAIN extends AjaxHandler
$result = Vesta::execute(Vesta::V_SUSPEND_WEB_DOMAIN, $params);
if(!$result['status'])
{
$this->errors[] = array(
$result['error_code'] => $result['error_message']
);
}
$this->errors[] = array($result['error_code'] => $result['error_message']);
return $this->reply($result['status'], $result['data']);
}
/**
* Unsuspend entry
*
* @param Request $request
* @return
*/
public function unsuspendExecute($request)
function unsuspendExecute($request)
{
$r = new Request();
$_s = $r->getSpell();
@ -601,22 +465,14 @@ class WEB_DOMAIN extends AjaxHandler
$result = Vesta::execute(Vesta::V_UNSUSPEND_WEB_DOMAIN, $params);
if(!$result['status'])
{
$this->errors[] = array(
$result['error_code'] => $result['error_message']
);
}
$this->errors[] = array($result['error_code'] => $result['error_message']);
return $this->reply($result['status'], $result['data']);
}
/**
* Batch suspend entries
*
* @param Request $request
* @return
*/
public function suspendAllExecute($request)
function suspendAllExecute($request)
{
$r = new Request();
$_s = $r->getSpell();
@ -630,22 +486,12 @@ class WEB_DOMAIN extends AjaxHandler
$result = Vesta::execute(Vesta::V_SUSPEND_WEB_DOMAINS, $params);
if(!$result['status'])
{
$this->errors[] = array(
$result['error_code'] => $result['error_message']
);
}
$this->errors[] = array($result['error_code'] => $result['error_message']);
return $this->reply($result['status'], $result['data']);
}
/**
* Batch unsuspend entry
*
* @param Request $request
* @return
*/
public function unsuspendAllExecute($request)
function unsuspendAllExecute($request)
{
$r = new Request();
$_s = $r->getSpell();
@ -659,13 +505,8 @@ class WEB_DOMAIN extends AjaxHandler
$result = Vesta::execute(Vesta::V_UNSUSPEND_WEB_DOMAINS, $params);
if(!$result['status'])
{
$this->errors[] = array(
$result['error_code'] => $result['error_message']
);
}
$this->errors[] = array($result['error_code'] => $result['error_message']);
return $this->reply($result['status'], $result['data']);
}
}