mirror of
https://github.com/serghey-rodin/vesta.git
synced 2025-08-20 21:34:11 -07:00
PHP code formatted + made more readable
This commit is contained in:
parent
4301323162
commit
c11a9b3e01
18 changed files with 2328 additions and 1891 deletions
|
@ -1,49 +1,6 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
function error_dumper($errno, $errstr, $errfile, $errline)
|
require dirname(__FILE__) . DIRECTORY_SEPARATOR . 'vesta/core/utils/error_logger.php'
|
||||||
{
|
require dirname(__FILE__) . DIRECTORY_SEPARATOR . 'vesta/app.init.php';
|
||||||
if (!(error_reporting() & $errno)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
$log = fopen('/tmp/vesta.php.log', 'a+');
|
|
||||||
|
|
||||||
switch ($errno) {
|
|
||||||
case E_USER_ERROR:
|
|
||||||
$o = "ERROR: [$errno] $errstr\n";
|
|
||||||
$o.= " Fatal error on line $errline in file $errfile";
|
|
||||||
$o.= ", PHP " . PHP_VERSION . " (" . PHP_OS . ")\n";
|
|
||||||
$o.= "Aborting...\n";
|
|
||||||
fwrite($log, $o);
|
|
||||||
fclose($log);
|
|
||||||
exit(1);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case E_USER_WARNING:
|
|
||||||
$o = "WARNING: [$errno] $errstr\n";
|
|
||||||
fwrite($log, $o);
|
|
||||||
fclose($log);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case E_USER_NOTICE:
|
|
||||||
$o = "NOTICE: [$errno] $errstr\n";
|
|
||||||
fwrite($log, $o);
|
|
||||||
fclose($log);
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
$o = "Unknown error type: [$errno] $errstr\n";
|
|
||||||
fwrite($log, $o);
|
|
||||||
fclose($log);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Don't execute PHP internal error handler */
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
set_error_handler('error_dumper');
|
|
||||||
|
|
||||||
require dirname(__FILE__).DIRECTORY_SEPARATOR.'vesta/app.init.php';
|
|
||||||
|
|
||||||
?>
|
?>
|
|
@ -1,12 +1,12 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Ajax Handler
|
* Ajax Handler
|
||||||
*
|
*
|
||||||
* @author vesta, http://vestacp.com/
|
* @author vesta, http://vestacp.com/
|
||||||
* @copyright vesta 2010
|
* @copyright vesta 2010-2011
|
||||||
*/
|
*/
|
||||||
class AjaxHandler {
|
class AjaxHandler
|
||||||
|
{
|
||||||
|
|
||||||
static public $instance = null;
|
static public $instance = null;
|
||||||
|
|
||||||
|
@ -16,9 +16,10 @@ class AjaxHandler {
|
||||||
/**
|
/**
|
||||||
* Grab current instance or create it
|
* Grab current instance or create it
|
||||||
*
|
*
|
||||||
* @return <type>
|
* @return AjaxHandler
|
||||||
*/
|
*/
|
||||||
static function getInstance($request=null) {
|
static function getInstance($request=null)
|
||||||
|
{
|
||||||
return null == self::$instance ? self::$instance = new self() : self::$instance;
|
return null == self::$instance ? self::$instance = new self() : self::$instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -26,13 +27,15 @@ class AjaxHandler {
|
||||||
* Called functions should reply in the following way
|
* Called functions should reply in the following way
|
||||||
* return $this->reply($result, $data, $msg, $extra);
|
* return $this->reply($result, $data, $msg, $extra);
|
||||||
*
|
*
|
||||||
* @param type $request
|
* @param Request $request
|
||||||
* @return type
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
function dispatch($request) {
|
function dispatch($request)
|
||||||
|
{
|
||||||
$method = Request::parseAjaxMethod($request);
|
$method = Request::parseAjaxMethod($request);
|
||||||
$inc_file = V_ROOT_DIR . 'api' . DIRECTORY_SEPARATOR . $method['namespace'] . '.class.php';
|
$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);
|
throw new SystemException(Message::INVALID_METHOD);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -41,14 +44,24 @@ class AjaxHandler {
|
||||||
$space = new $method['namespace'];
|
$space = new $method['namespace'];
|
||||||
$method = $method['function'] . 'Execute';
|
$method = $method['function'] . 'Execute';
|
||||||
|
|
||||||
if (!method_exists($space, $method)) {
|
if (!method_exists($space, $method))
|
||||||
|
{
|
||||||
throw new SystemException(Message::INVALID_METHOD);
|
throw new SystemException(Message::INVALID_METHOD);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $space->$method($request);
|
return $space->$method($request);
|
||||||
}
|
}
|
||||||
|
|
||||||
function reply($result, $data, $message = '', $extra = array()) {
|
/**
|
||||||
|
* 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
|
||||||
|
*/
|
||||||
|
function reply($result, $data, $message = '', $extra = array())
|
||||||
|
{
|
||||||
return json_encode(array('result' => $result,
|
return json_encode(array('result' => $result,
|
||||||
'data' => $data,
|
'data' => $data,
|
||||||
'message' => $message,
|
'message' => $message,
|
||||||
|
@ -57,7 +70,12 @@ class AjaxHandler {
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
static function makeReply($reply) {
|
/**
|
||||||
|
* TODO: delete this method
|
||||||
|
* @deprecated
|
||||||
|
*/
|
||||||
|
static function makeReply($reply)
|
||||||
|
{
|
||||||
print $reply;
|
print $reply;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -65,19 +83,39 @@ class AjaxHandler {
|
||||||
// Error handlers
|
// Error handlers
|
||||||
//
|
//
|
||||||
|
|
||||||
static function generalError($error) {
|
/**
|
||||||
|
* Generate general error
|
||||||
|
* @param Exception $error
|
||||||
|
*/
|
||||||
|
static function generalError($error)
|
||||||
|
{
|
||||||
self::renderGlobalError(Message::ERROR, Message::GENERAL_ERROR, $error);
|
self::renderGlobalError(Message::ERROR, Message::GENERAL_ERROR, $error);
|
||||||
}
|
}
|
||||||
|
|
||||||
static function protectionError($error) {
|
/**
|
||||||
|
* Generate protection error
|
||||||
|
* @param Exception $error
|
||||||
|
*/
|
||||||
|
static function protectionError($error)
|
||||||
|
{
|
||||||
self::renderGlobalError(Message::ERROR, Message::PROTECTION_ERROR, $error);
|
self::renderGlobalError(Message::ERROR, Message::PROTECTION_ERROR, $error);
|
||||||
}
|
}
|
||||||
|
|
||||||
static function systemError($error) {
|
/**
|
||||||
|
* Generate system error
|
||||||
|
* @param Exception $error
|
||||||
|
*/
|
||||||
|
static function systemError($error)
|
||||||
|
{
|
||||||
self::renderGlobalError(Message::ERROR, Message::SYSTEM_ERROR, $error);
|
self::renderGlobalError(Message::ERROR, Message::SYSTEM_ERROR, $error);
|
||||||
}
|
}
|
||||||
|
|
||||||
static function renderGlobalError($type, $message, $error) {
|
/**
|
||||||
|
* Prepare and render the error
|
||||||
|
* @param Exception $error
|
||||||
|
*/
|
||||||
|
static function renderGlobalError($type, $message, $error)
|
||||||
|
{
|
||||||
$trace = $error->getTrace();
|
$trace = $error->getTrace();
|
||||||
AjaxHandler::makeReply(
|
AjaxHandler::makeReply(
|
||||||
AjaxHandler::getInstance()->reply(false, $type, $message . ': ' . $error->getMessage(), $trace[0]['file'] . ' / ' . $trace[0]['line'])
|
AjaxHandler::getInstance()->reply(false, $type, $message . ': ' . $error->getMessage(), $trace[0]['file'] . ' / ' . $trace[0]['line'])
|
||||||
|
|
|
@ -1,22 +1,31 @@
|
||||||
<?php
|
<?php
|
||||||
/*
|
|
||||||
|
/**
|
||||||
* CRON
|
* CRON
|
||||||
*
|
*
|
||||||
|
* @author Naumov-Socolov <naumov.socolov@gmail.com>
|
||||||
|
* @author Malishev Dima <dima.malishev@gmail.com>
|
||||||
* @author vesta, http://vestacp.com/
|
* @author vesta, http://vestacp.com/
|
||||||
* @copyright vesta 2010
|
* @copyright vesta 2010-2011
|
||||||
*/
|
*/
|
||||||
class CRON extends AjaxHandler {
|
class CRON extends AjaxHandler
|
||||||
function getListExecute($request)
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* List cron entries
|
||||||
|
*
|
||||||
|
* @param Request $request
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public function getListExecute($request)
|
||||||
{
|
{
|
||||||
$_user = 'vesta';
|
$_user = 'vesta';
|
||||||
$reply = array();
|
$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')));
|
||||||
|
|
||||||
// echo '<pre>';
|
foreach ($result['data'] as $id => $record)
|
||||||
// print_r($result);
|
|
||||||
|
|
||||||
foreach($result['data'] as $id => $record)
|
|
||||||
{
|
{
|
||||||
$reply[$id] = array(
|
$reply[$id] = array(
|
||||||
'CMD' => $record['CMD'],
|
'CMD' => $record['CMD'],
|
||||||
|
@ -30,15 +39,21 @@ class CRON extends AjaxHandler {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!$result['status'])
|
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'], $reply);
|
return $this->reply($result['status'], $reply);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add cron entry
|
||||||
function addExecute($request)
|
*
|
||||||
|
* @param Request $request
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public function addExecute($request)
|
||||||
{
|
{
|
||||||
$r = new Request();
|
$r = new Request();
|
||||||
$_s = $r->getSpell();
|
$_s = $r->getSpell();
|
||||||
|
@ -56,26 +71,32 @@ class CRON extends AjaxHandler {
|
||||||
|
|
||||||
$result = Vesta::execute(Vesta::V_ADD_CRON_JOB, $params);
|
$result = Vesta::execute(Vesta::V_ADD_CRON_JOB, $params);
|
||||||
|
|
||||||
|
if ($_s['REPORTS'])
|
||||||
if($_s['REPORTS'])
|
|
||||||
{
|
{
|
||||||
$result = array();
|
$result = array();
|
||||||
$result = Vesta::execute(Vesta::V_ADD_SYS_USER_REPORTS, array('USER' => $_user));
|
$result = Vesta::execute(Vesta::V_ADD_SYS_USER_REPORTS,
|
||||||
if(!$result['status'])
|
array('USER' => $_user));
|
||||||
|
if (!$result['status'])
|
||||||
{
|
{
|
||||||
$this->status = FALSE;
|
$this->status = FALSE;
|
||||||
$this->errors['REPORTS'] = array($result['error_code'] => $result['error_message']);
|
$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']);
|
$this->errors[] = array($result['error_code'] => $result['error_message']);
|
||||||
|
}
|
||||||
|
|
||||||
return $this->reply($result['status'], $result['data']);
|
return $this->reply($result['status'], $result['data']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Delete cron entry
|
||||||
|
*
|
||||||
|
* @param Request $request
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
function delExecute($request)
|
function delExecute($request)
|
||||||
{
|
{
|
||||||
$r = new Request();
|
$r = new Request();
|
||||||
|
@ -86,17 +107,22 @@ class CRON extends AjaxHandler {
|
||||||
'USER' => $_user,
|
'USER' => $_user,
|
||||||
'JOB' => $_s['JOB']
|
'JOB' => $_s['JOB']
|
||||||
);
|
);
|
||||||
|
|
||||||
$result = Vesta::execute(Vesta::V_DEL_CRON_JOB, $params);
|
$result = Vesta::execute(Vesta::V_DEL_CRON_JOB, $params);
|
||||||
|
|
||||||
if(!$result['status'])
|
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']);
|
return $this->reply($result['status'], $result['data']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Change cron entry
|
||||||
|
*
|
||||||
|
* @param Request $request
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
function changeExecute($request)
|
function changeExecute($request)
|
||||||
{
|
{
|
||||||
$r = new Request();
|
$r = new Request();
|
||||||
|
@ -121,16 +147,20 @@ class CRON extends AjaxHandler {
|
||||||
|
|
||||||
$result = Vesta::execute(Vesta::V_CHANGE_CRON_JOB, $params);
|
$result = Vesta::execute(Vesta::V_CHANGE_CRON_JOB, $params);
|
||||||
|
|
||||||
|
if (!$result['status'])
|
||||||
|
{
|
||||||
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']);
|
return $this->reply($result['status'], $result['data']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Suspend cron entry
|
||||||
|
*
|
||||||
|
* @param Request $request
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
function suspendExecute($request)
|
function suspendExecute($request)
|
||||||
{
|
{
|
||||||
$r = new Request();
|
$r = new Request();
|
||||||
|
@ -145,15 +175,21 @@ class CRON extends AjaxHandler {
|
||||||
);
|
);
|
||||||
|
|
||||||
$result = Vesta::execute(Vesta::V_SUSPEND_CRON_JOB, $params);
|
$result = Vesta::execute(Vesta::V_SUSPEND_CRON_JOB, $params);
|
||||||
|
if (!$result['status'])
|
||||||
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']);
|
return $this->reply($result['status'], $result['data']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Unsuspend cron entry
|
||||||
|
*
|
||||||
|
* @param Request $request
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
function unsuspendExecute($request)
|
function unsuspendExecute($request)
|
||||||
{
|
{
|
||||||
$r = new Request();
|
$r = new Request();
|
||||||
|
@ -169,14 +205,20 @@ class CRON extends AjaxHandler {
|
||||||
|
|
||||||
$result = Vesta::execute(Vesta::V_UNSUSPEND_CRON_JOB, $params);
|
$result = Vesta::execute(Vesta::V_UNSUSPEND_CRON_JOB, $params);
|
||||||
|
|
||||||
if(!$result['status'])
|
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']);
|
return $this->reply($result['status'], $result['data']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Batch suspend cron entries
|
||||||
|
*
|
||||||
|
* @param Request $request
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
function suspendAllExecute($request)
|
function suspendAllExecute($request)
|
||||||
{
|
{
|
||||||
$r = new Request();
|
$r = new Request();
|
||||||
|
@ -191,14 +233,20 @@ class CRON extends AjaxHandler {
|
||||||
|
|
||||||
$result = Vesta::execute(Vesta::V_SUSPEND_CRON_JOBS, $params);
|
$result = Vesta::execute(Vesta::V_SUSPEND_CRON_JOBS, $params);
|
||||||
|
|
||||||
if(!$result['status'])
|
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']);
|
return $this->reply($result['status'], $result['data']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Batch suspend cron entry
|
||||||
|
*
|
||||||
|
* @param Request $request
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
function unsuspendAllExecute($request)
|
function unsuspendAllExecute($request)
|
||||||
{
|
{
|
||||||
$r = new Request();
|
$r = new Request();
|
||||||
|
@ -212,8 +260,10 @@ class CRON extends AjaxHandler {
|
||||||
|
|
||||||
$result = Vesta::execute(Vesta::V_UNSUSPEND_CRON_JOBS, $params);
|
$result = Vesta::execute(Vesta::V_UNSUSPEND_CRON_JOBS, $params);
|
||||||
|
|
||||||
if(!$result['status'])
|
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']);
|
return $this->reply($result['status'], $result['data']);
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,21 +3,27 @@
|
||||||
/**
|
/**
|
||||||
* DB
|
* DB
|
||||||
*
|
*
|
||||||
|
* @author Naumov-Socolov <naumov.socolov@gmail.com>
|
||||||
|
* @author Malishev Dima <dima.malishev@gmail.com>
|
||||||
* @author vesta, http://vestacp.com/
|
* @author vesta, http://vestacp.com/
|
||||||
* @copyright vesta 2011
|
* @copyright vesta 2011
|
||||||
*/
|
*/
|
||||||
class DB extends AjaxHandler {
|
class DB extends AjaxHandler
|
||||||
function getListExecute($request)
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* List entries
|
||||||
|
*
|
||||||
|
* @param Request $request
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public function getListExecute($request)
|
||||||
{
|
{
|
||||||
$_user = 'vesta';
|
$_user = 'vesta';
|
||||||
$reply = array();
|
$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, Config::get('response_type')));
|
||||||
|
|
||||||
// echo '<pre>';
|
foreach ($result['data'] as $db => $record)
|
||||||
// print_r($result);
|
|
||||||
|
|
||||||
foreach($result['data'] as $db => $record)
|
|
||||||
{
|
{
|
||||||
$reply[$db] = array(
|
$reply[$db] = array(
|
||||||
'DB' => $db,
|
'DB' => $db,
|
||||||
|
@ -30,13 +36,21 @@ class DB extends AjaxHandler {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!$result['status'])
|
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'], $reply);
|
return $this->reply($result['status'], $reply);
|
||||||
}
|
}
|
||||||
|
|
||||||
function addExecute($request)
|
/**
|
||||||
|
* Add entry
|
||||||
|
*
|
||||||
|
* @param Request $request
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public function addExecute($request)
|
||||||
{
|
{
|
||||||
$r = new Request();
|
$r = new Request();
|
||||||
$_s = $r->getSpell();
|
$_s = $r->getSpell();
|
||||||
|
@ -49,21 +63,28 @@ class DB extends AjaxHandler {
|
||||||
'DB_PASSWORD' => $_s['DB_PASSWORD'],
|
'DB_PASSWORD' => $_s['DB_PASSWORD'],
|
||||||
'TYPE' => $_s['TYPE']
|
'TYPE' => $_s['TYPE']
|
||||||
);
|
);
|
||||||
if($_s['HOST'])
|
if ($_s['HOST'])
|
||||||
|
{
|
||||||
$params['HOST'] = $_s['HOST'];
|
$params['HOST'] = $_s['HOST'];
|
||||||
|
}
|
||||||
|
|
||||||
$result = Vesta::execute(Vesta::V_ADD_DB_BASE, $params);
|
$result = Vesta::execute(Vesta::V_ADD_DB_BASE, $params);
|
||||||
|
|
||||||
|
if (!$result['status'])
|
||||||
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']);
|
return $this->reply($result['status'], $result['data']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Delete entry
|
||||||
function delExecute($request)
|
*
|
||||||
|
* @param Request $request
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public function delExecute($request)
|
||||||
{
|
{
|
||||||
$r = new Request();
|
$r = new Request();
|
||||||
$_s = $r->getSpell();
|
$_s = $r->getSpell();
|
||||||
|
@ -76,15 +97,21 @@ class DB extends AjaxHandler {
|
||||||
|
|
||||||
$result = Vesta::execute(Vesta::V_DEL_DB_BASE, $params);
|
$result = Vesta::execute(Vesta::V_DEL_DB_BASE, $params);
|
||||||
|
|
||||||
if(!$result['status'])
|
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']);
|
return $this->reply($result['status'], $result['data']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Change password
|
||||||
function changePasswordExecute($request)
|
*
|
||||||
|
* @param Request $request
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public function changePasswordExecute($request)
|
||||||
{
|
{
|
||||||
$r = new Request();
|
$r = new Request();
|
||||||
$_s = $r->getSpell();
|
$_s = $r->getSpell();
|
||||||
|
@ -100,15 +127,21 @@ class DB extends AjaxHandler {
|
||||||
|
|
||||||
$result = Vesta::execute(Vesta::V_CHANGE_DB_PASSWORD, $params);
|
$result = Vesta::execute(Vesta::V_CHANGE_DB_PASSWORD, $params);
|
||||||
|
|
||||||
if(!$result['status'])
|
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']);
|
return $this->reply($result['status'], $result['data']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* suspend user
|
||||||
function suspendExecute($request)
|
*
|
||||||
|
* @param Request $request
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public function suspendExecute($request)
|
||||||
{
|
{
|
||||||
$r = new Request();
|
$r = new Request();
|
||||||
$_s = $r->getSpell();
|
$_s = $r->getSpell();
|
||||||
|
@ -122,15 +155,21 @@ class DB extends AjaxHandler {
|
||||||
|
|
||||||
$result = Vesta::execute(Vesta::V_SUSPEND_DB_BASE, $params);
|
$result = Vesta::execute(Vesta::V_SUSPEND_DB_BASE, $params);
|
||||||
|
|
||||||
if(!$result['status'])
|
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']);
|
return $this->reply($result['status'], $result['data']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* unsuspend entry
|
||||||
function unsuspendExecute($request)
|
*
|
||||||
|
* @param Request $request
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public function unsuspendExecute($request)
|
||||||
{
|
{
|
||||||
$r = new Request();
|
$r = new Request();
|
||||||
$_s = $r->getSpell();
|
$_s = $r->getSpell();
|
||||||
|
@ -144,15 +183,21 @@ class DB extends AjaxHandler {
|
||||||
|
|
||||||
$result = Vesta::execute(Vesta::V_UNSUSPEND_DB_BASE, $params);
|
$result = Vesta::execute(Vesta::V_UNSUSPEND_DB_BASE, $params);
|
||||||
|
|
||||||
if(!$result['status'])
|
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']);
|
return $this->reply($result['status'], $result['data']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Batch suspend entries
|
||||||
function suspendAllExecute($request)
|
*
|
||||||
|
* @param Request $request
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public function suspendAllExecute($request)
|
||||||
{
|
{
|
||||||
$r = new Request();
|
$r = new Request();
|
||||||
$_s = $r->getSpell();
|
$_s = $r->getSpell();
|
||||||
|
@ -166,15 +211,21 @@ class DB extends AjaxHandler {
|
||||||
|
|
||||||
$result = Vesta::execute(Vesta::V_SUSPEND_DB_BASES, $params);
|
$result = Vesta::execute(Vesta::V_SUSPEND_DB_BASES, $params);
|
||||||
|
|
||||||
if(!$result['status'])
|
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']);
|
return $this->reply($result['status'], $result['data']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Batch unsuspend entries
|
||||||
function unsuspendAllExecute($request)
|
*
|
||||||
|
* @param Request $request
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public function unsuspendAllExecute($request)
|
||||||
{
|
{
|
||||||
$r = new Request();
|
$r = new Request();
|
||||||
$_s = $r->getSpell();
|
$_s = $r->getSpell();
|
||||||
|
@ -187,8 +238,10 @@ class DB extends AjaxHandler {
|
||||||
|
|
||||||
$result = Vesta::execute(Vesta::V_UNSUSPEND_DB_BASES, $params);
|
$result = Vesta::execute(Vesta::V_UNSUSPEND_DB_BASES, $params);
|
||||||
|
|
||||||
if(!$result['status'])
|
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']);
|
return $this->reply($result['status'], $result['data']);
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,17 +3,27 @@
|
||||||
/**
|
/**
|
||||||
* DNS
|
* DNS
|
||||||
*
|
*
|
||||||
|
* @author Naumov-Socolov <naumov.socolov@gmail.com>
|
||||||
|
* @author Malishev Dima <dima.malishev@gmail.com>
|
||||||
* @author vesta, http://vestacp.com/
|
* @author vesta, http://vestacp.com/
|
||||||
* @copyright vesta 2010
|
* @copyright vesta 2010-2011
|
||||||
*/
|
*/
|
||||||
|
class DNS extends AjaxHandler
|
||||||
|
{
|
||||||
|
|
||||||
class DNS extends AjaxHandler {
|
/**
|
||||||
function getListExecute($request) {
|
* list entries
|
||||||
|
*
|
||||||
|
* @param Request $request
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public function getListExecute($request) {
|
||||||
$_user = 'vesta';
|
$_user = 'vesta';
|
||||||
$reply = array();
|
$reply = array();
|
||||||
|
|
||||||
$result = Vesta::execute(Vesta::V_LIST_DNS_DOMAINS, array($_user, Config::get('response_type')));
|
$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(
|
$reply[] = array(
|
||||||
'DNS_DOMAIN' => $dns_domain,
|
'DNS_DOMAIN' => $dns_domain,
|
||||||
'IP' => $details['IP'],
|
'IP' => $details['IP'],
|
||||||
|
@ -22,17 +32,25 @@ class DNS extends AjaxHandler {
|
||||||
'EXP' => $details['EXP'],
|
'EXP' => $details['EXP'],
|
||||||
'SOA' => $details['SOA'],
|
'SOA' => $details['SOA'],
|
||||||
'SUSPEND' => $details['SUSPEND'],
|
'SUSPEND' => $details['SUSPEND'],
|
||||||
// 'OWNER' => $details['OWNER'],
|
|
||||||
'DATE' => date(Config::get('ui_date_format', strtotime($details['DATE'])))
|
'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']);
|
$this->errors[] = array($result['error_code'] => $result['error_message']);
|
||||||
|
}
|
||||||
|
|
||||||
return $this->reply($result['status'], $reply);
|
return $this->reply($result['status'], $reply);
|
||||||
}
|
}
|
||||||
|
|
||||||
function getListRecordsExecute($request) {
|
/**
|
||||||
|
* List records of entries
|
||||||
|
*
|
||||||
|
* @param Request $request
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public function getListRecordsExecute($request)
|
||||||
|
{
|
||||||
$r = new Request();
|
$r = new Request();
|
||||||
$_s = $r->getSpell();
|
$_s = $r->getSpell();
|
||||||
$_user = 'vesta';
|
$_user = 'vesta';
|
||||||
|
@ -40,7 +58,8 @@ class DNS extends AjaxHandler {
|
||||||
$reply = array();
|
$reply = array();
|
||||||
|
|
||||||
$result = Vesta::execute(Vesta::V_LIST_DNS_DOMAIN_RECORDS, array($_user, $_s['DNS_DOMAIN'], Config::get('response_type')));
|
$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(
|
$reply[$record_id] = array(
|
||||||
'RECORD_ID' => $record_id,
|
'RECORD_ID' => $record_id,
|
||||||
'RECORD' => $details['RECORD'],
|
'RECORD' => $details['RECORD'],
|
||||||
|
@ -51,49 +70,69 @@ class DNS extends AjaxHandler {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!$result['status'])
|
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'], $reply);
|
return $this->reply($result['status'], $reply);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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
|
* Add entry
|
||||||
function addExecute($_spell = false)
|
*
|
||||||
|
* 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
|
||||||
|
*/
|
||||||
|
public function addExecute($_spell = false)
|
||||||
{
|
{
|
||||||
$r = new Request();
|
$r = new Request();
|
||||||
if($_spell)
|
if ($_spell)
|
||||||
|
{
|
||||||
$_s = $_spell;
|
$_s = $_spell;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
$_s = $r->getSpell();
|
$_s = $r->getSpell();
|
||||||
|
}
|
||||||
|
|
||||||
$_user = 'vesta';
|
$_user = 'vesta';
|
||||||
|
|
||||||
$params = array(
|
$params = array(
|
||||||
'USER' => $_user, /// OWNER ???
|
'USER' => $_user, // TODO: examine if OWNER ???
|
||||||
'DNS_DOMAIN' => $_s['DNS_DOMAIN'],
|
'DNS_DOMAIN' => $_s['DNS_DOMAIN'],
|
||||||
'IP' => $_s['IP']);
|
'IP' => $_s['IP']
|
||||||
if($_s['TPL']) $params['TPL'] = $_s['TPL'];
|
);
|
||||||
if($_s['EXP']) $params['EXP'] = $_s['EXP'];
|
($_s['TPL']) ? $params['TPL'] = $_s['TPL'] : -1;
|
||||||
if($_s['SOA']) $params['SOA'] = $_s['SOA'];
|
($_s['EXP']) ? $params['EXP'] = $_s['EXP'] : -1;
|
||||||
if($_s['TTL']) $params['TTL'] = $_s['TTL'];
|
($_s['SOA']) ? $params['SOA'] = $_s['SOA'] : -1;
|
||||||
|
($_s['TTL']) ? $params['TTL'] = $_s['TTL'] : -1;
|
||||||
|
|
||||||
$result = Vesta::execute(Vesta::V_ADD_DNS_DOMAIN, $params);
|
$result = Vesta::execute(Vesta::V_ADD_DNS_DOMAIN, $params);
|
||||||
if(!$result['status'])
|
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']);
|
return $this->reply($result['status'], $result['data']);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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
|
* Add record
|
||||||
function addRecordExecute($request) {
|
*
|
||||||
|
* @param Request $request
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public function addRecordExecute($request)
|
||||||
|
{
|
||||||
$r = new Request();
|
$r = new Request();
|
||||||
$_s = $r->getSpell();
|
$_s = $r->getSpell();
|
||||||
$_user = 'vesta';
|
$_user = 'vesta';
|
||||||
|
|
||||||
$params = array(
|
$params = array(
|
||||||
'USER' => $_s['USER'], /// OWNER ???
|
'USER' => $_s['USER'], // TODO: find out if it's OWNER ???
|
||||||
'DOMAIN' => $_s['DOMAIN'],
|
'DOMAIN' => $_s['DOMAIN'],
|
||||||
'RECORD' => $_s['RECORD'],
|
'RECORD' => $_s['RECORD'],
|
||||||
'RECORD_TYPE' => $_s['TYPE'],
|
'RECORD_TYPE' => $_s['TYPE'],
|
||||||
|
@ -101,70 +140,88 @@ class DNS extends AjaxHandler {
|
||||||
'RECORD_ID' => $_s['RECORD_ID']
|
'RECORD_ID' => $_s['RECORD_ID']
|
||||||
);
|
);
|
||||||
|
|
||||||
// print_r($params);
|
|
||||||
|
|
||||||
$result = Vesta::execute(Vesta::V_ADD_DNS_DOMAIN_RECORD, $params);
|
$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']);
|
$this->errors[] = array($result['error_code'] => $result['error_message']);
|
||||||
|
}
|
||||||
|
|
||||||
return $this->reply($result['status'], $result['data']);
|
return $this->reply($result['status'], $result['data']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// v_del_dns_domain user domain
|
/**
|
||||||
// http://95.163.16.160:8083/dispatch.php?jedi_method=DNS.del&USER=vesta&DOMAIN=dev.vestacp.com
|
* Delete entry
|
||||||
function delExecute($_spell = false)
|
*
|
||||||
|
* @param mixed $_spell
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public function delExecute($_spell = false)
|
||||||
{
|
{
|
||||||
$r = new Request();
|
$r = new Request();
|
||||||
if($_spell)
|
if ($_spell)
|
||||||
|
{
|
||||||
$_s = $_spell;
|
$_s = $_spell;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
$_s = $r->getSpell();
|
$_s = $r->getSpell();
|
||||||
|
}
|
||||||
|
|
||||||
$_user = 'vesta';
|
$_user = 'vesta';
|
||||||
|
|
||||||
$params = array(
|
$params = array(
|
||||||
'USER' => $_user, /// OWNER ???
|
'USER' => $_user, // TODO: find out -> OWNER ???
|
||||||
'DOMAIN' => $_s['DNS_DOMAIN'],
|
'DOMAIN' => $_s['DNS_DOMAIN'],
|
||||||
);
|
);
|
||||||
|
|
||||||
$result = Vesta::execute(Vesta::V_DEL_DNS_DOMAIN, $params);
|
$result = Vesta::execute(Vesta::V_DEL_DNS_DOMAIN, $params);
|
||||||
|
|
||||||
if(!$result['status'])
|
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']);
|
return $this->reply($result['status'], $result['data']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// 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
|
* Delete record
|
||||||
function delRecordExecute($request) {
|
*
|
||||||
|
* @param Request $request
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
function delRecordExecute($request)
|
||||||
|
{
|
||||||
$r = new Request();
|
$r = new Request();
|
||||||
$_s = $r->getSpell();
|
$_s = $r->getSpell();
|
||||||
$_user = 'vesta';
|
$_user = 'vesta';
|
||||||
|
|
||||||
$params = array(
|
$params = array(
|
||||||
'USER' => $_user, /// OWNER ???
|
'USER' => $_user, // TODO: find out if -> OWNER ???
|
||||||
'DOMAIN' => $_s['DOMAIN'],
|
'DOMAIN' => $_s['DOMAIN'],
|
||||||
'RECORD_ID' => $_s['RECORD_ID']
|
'RECORD_ID' => $_s['RECORD_ID']
|
||||||
);
|
);
|
||||||
|
|
||||||
$result = Vesta::execute(Vesta::V_DEL_DNS_DOMAIN_RECORD, $params);
|
$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']);
|
$this->errors[] = array($result['error_code'] => $result['error_message']);
|
||||||
|
}
|
||||||
|
|
||||||
return $this->reply($result['status'], $result['data']);
|
return $this->reply($result['status'], $result['data']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Change entry
|
||||||
// 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
|
||||||
function changeExecute($request)
|
* @return
|
||||||
|
*/
|
||||||
|
public function changeExecute($request)
|
||||||
{
|
{
|
||||||
$r = new Request();
|
$r = new Request();
|
||||||
$_s = $r->getSpell();
|
$_s = $r->getSpell();
|
||||||
|
@ -176,7 +233,7 @@ class DNS extends AjaxHandler {
|
||||||
$_DNS_DOMAIN = $_new['DNS_DOMAIN'];
|
$_DNS_DOMAIN = $_new['DNS_DOMAIN'];
|
||||||
|
|
||||||
|
|
||||||
if($_old['IP'] != $_new['IP'])
|
if ($_old['IP'] != $_new['IP'])
|
||||||
{
|
{
|
||||||
$result = array();
|
$result = array();
|
||||||
$result = Vesta::execute(Vesta::V_CHANGE_DNS_DOMAIN_IP, array('USER' => $_user, 'DNS_DOMAIN' => $_DNS_DOMAIN, 'IP' => $_new['IP']));
|
$result = Vesta::execute(Vesta::V_CHANGE_DNS_DOMAIN_IP, array('USER' => $_user, 'DNS_DOMAIN' => $_DNS_DOMAIN, 'IP' => $_new['IP']));
|
||||||
|
@ -187,7 +244,7 @@ class DNS extends AjaxHandler {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if($_old['TPL'] != $_new['TPL'])
|
if ($_old['TPL'] != $_new['TPL'])
|
||||||
{
|
{
|
||||||
$result = array();
|
$result = array();
|
||||||
$result = Vesta::execute(Vesta::V_CHANGE_DNS_DOMAIN_TPL, array('USER' => $_user, 'DNS_DOMAIN' => $_DNS_DOMAIN, 'IP' => $_new['TPL']));
|
$result = Vesta::execute(Vesta::V_CHANGE_DNS_DOMAIN_TPL, array('USER' => $_user, 'DNS_DOMAIN' => $_DNS_DOMAIN, 'IP' => $_new['TPL']));
|
||||||
|
@ -198,7 +255,7 @@ class DNS extends AjaxHandler {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if($_old['TTL'] != $_new['TTL'])
|
if ($_old['TTL'] != $_new['TTL'])
|
||||||
{
|
{
|
||||||
$result = array();
|
$result = array();
|
||||||
$result = Vesta::execute(Vesta::V_CHANGE_DNS_DOMAIN_TTL, array('USER' => $_user, 'DNS_DOMAIN' => $_DNS_DOMAIN, 'IP' => $_new['TTL']));
|
$result = Vesta::execute(Vesta::V_CHANGE_DNS_DOMAIN_TTL, array('USER' => $_user, 'DNS_DOMAIN' => $_DNS_DOMAIN, 'IP' => $_new['TTL']));
|
||||||
|
@ -209,29 +266,29 @@ class DNS extends AjaxHandler {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if($_old['EXP'] != $_new['EXP'])
|
if ($_old['EXP'] != $_new['EXP'])
|
||||||
{
|
{
|
||||||
$result = array();
|
$result = array();
|
||||||
$result = Vesta::execute(Vesta::V_CHANGE_DNS_DOMAIN_EXP, array('USER' => $_user, 'DNS_DOMAIN' => $_DNS_DOMAIN, 'IP' => $_new['EXP']));
|
$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->status = FALSE;
|
||||||
$this->errors['EXP'] = array($result['error_code'] => $result['error_message']);
|
$this->errors['EXP'] = array($result['error_code'] => $result['error_message']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if($_old['SOA'] != $_new['SOA'])
|
if ($_old['SOA'] != $_new['SOA'])
|
||||||
{
|
{
|
||||||
$result = array();
|
$result = array();
|
||||||
$result = Vesta::execute(Vesta::V_CHANGE_DNS_DOMAIN_SOA, array('USER' => $_user, 'DNS_DOMAIN' => $_new['DNS_DOMAIN'], 'IP' => $_new['SOA']));
|
$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->status = FALSE;
|
||||||
$this->errors['SOA'] = array($result['error_code'] => $result['error_message']);
|
$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_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_TPL, array('USER' => $_user, 'DNS_DOMAIN' => $_DNS_DOMAIN, 'IP' => $_old['TPL']));
|
||||||
|
@ -243,28 +300,27 @@ class DNS extends AjaxHandler {
|
||||||
return $this->reply($this->status, '');
|
return $this->reply($this->status, '');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Change record
|
||||||
function changeRecordsExecute($request)
|
*
|
||||||
|
* @param Request $request
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public function changeRecordsExecute($request)
|
||||||
{
|
{
|
||||||
$r = new Request();
|
$r = new Request();
|
||||||
$_s = $r->getSpell();
|
$_s = $r->getSpell();
|
||||||
$_old = $_s['old'];
|
$_old = $_s['old'];
|
||||||
$_new = $_s['new'];
|
$_new = $_s['new'];
|
||||||
|
|
||||||
// echo '<pre>';
|
|
||||||
// print_r($_new);
|
|
||||||
// print_r($_old);
|
|
||||||
|
|
||||||
$_user = 'vesta';
|
$_user = 'vesta';
|
||||||
|
|
||||||
$_DNS_DOMAIN = $_s['DNS_DOMAIN'];
|
$_DNS_DOMAIN = $_s['DNS_DOMAIN'];
|
||||||
|
|
||||||
foreach($_new as $record_id => $record_data)
|
foreach ($_new as $record_id => $record_data)
|
||||||
{
|
{
|
||||||
// checking if record existed - update
|
// checking if record existed - update
|
||||||
if(is_array($_old[$record_id]))
|
if(is_array($_old[$record_id]))
|
||||||
{
|
{
|
||||||
|
// TODO: Remove this. is it necessary??!
|
||||||
echo '<br> updating'.$record_id;
|
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']));
|
$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']));
|
||||||
|
@ -277,6 +333,7 @@ class DNS extends AjaxHandler {
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// record is new - add
|
// record is new - add
|
||||||
|
// TODO: Remove this. is it necessary??!
|
||||||
echo '<br> adding'.$record_id;
|
echo '<br> adding'.$record_id;
|
||||||
|
|
||||||
$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));
|
$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));
|
||||||
|
@ -287,24 +344,17 @@ class DNS extends AjaxHandler {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
unset($_old[$record_id]);
|
unset($_old[$record_id]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// in $_old have remained only record that do not present in new - so they have to be deleted
|
// 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)
|
foreach ($_old as $record_id => $record_data)
|
||||||
{
|
{
|
||||||
echo '<br> deleting'.$record_id;
|
echo '<br> deleting'.$record_id;
|
||||||
/*
|
|
||||||
$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, '');
|
return $this->reply($this->status, '');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,53 +2,74 @@
|
||||||
/**
|
/**
|
||||||
* IP
|
* IP
|
||||||
*
|
*
|
||||||
|
* @author Naumov-Socolov <naumov.socolov@gmail.com>
|
||||||
|
* @author Malishev Dima <dima.malishev@gmail.com>
|
||||||
* @author vesta, http://vestacp.com/
|
* @author vesta, http://vestacp.com/
|
||||||
* @copyright vesta 2010
|
* @copyright vesta 2010-2011
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
class IP extends AjaxHandler
|
class IP extends AjaxHandler
|
||||||
{
|
{
|
||||||
function getListExecute($request)
|
/**
|
||||||
|
* List entries
|
||||||
|
*
|
||||||
|
* @param Request $request
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public function getListExecute($request)
|
||||||
{
|
{
|
||||||
$reply = array();
|
$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) {
|
foreach ($result['data'] as $ip => $details)
|
||||||
$reply[] = array_merge(
|
{
|
||||||
array(
|
$reply[] = array_merge(array(
|
||||||
'IP_ADDRESS' => $ip,
|
'IP_ADDRESS' => $ip,
|
||||||
'DATE' => date(Config::get('ui_date_format', strtotime($details['DATE'])))
|
'DATE' => date(Config::get('ui_date_format', strtotime($details['DATE'])))
|
||||||
), $details);
|
), $details);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!$result['status'])
|
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'], $reply);
|
return $this->reply($result['status'], $reply);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
function getListUserIpsExecute($request)
|
* List user ips entries
|
||||||
|
*
|
||||||
|
* @param Request $request
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public function getListUserIpsExecute($request)
|
||||||
{
|
{
|
||||||
$reply = array();
|
$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) {
|
foreach ($result['data'] as $ip => $details)
|
||||||
$reply[] = array_merge(
|
{
|
||||||
array(
|
$reply[] = array_merge(array(
|
||||||
'IP_ADDRESS' => $ip,
|
'IP_ADDRESS' => $ip,
|
||||||
'DATE' => date(Config::get('ui_date_format', strtotime($details['DATE'])))
|
'DATE' => date(Config::get('ui_date_format', strtotime($details['DATE'])))
|
||||||
), $details);
|
), $details);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!$result['status'])
|
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'], $reply);
|
return $this->reply($result['status'], $reply);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
function addExecute($request)
|
* Add entry
|
||||||
|
*
|
||||||
|
* @param Request $request
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public function addExecute($request)
|
||||||
{
|
{
|
||||||
$r = new Request();
|
$r = new Request();
|
||||||
$_s = $r->getSpell();
|
$_s = $r->getSpell();
|
||||||
|
@ -66,13 +87,21 @@ class IP extends AjaxHandler
|
||||||
$result = Vesta::execute(Vesta::V_ADD_SYS_IP, $params);
|
$result = Vesta::execute(Vesta::V_ADD_SYS_IP, $params);
|
||||||
|
|
||||||
|
|
||||||
if(!$result['status'])
|
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']);
|
return $this->reply($result['status'], $result['data']);
|
||||||
}
|
}
|
||||||
|
|
||||||
function delExecute($request)
|
/**
|
||||||
|
* Delete entry
|
||||||
|
*
|
||||||
|
* @param Request $request
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public function delExecute($request)
|
||||||
{
|
{
|
||||||
$r = new Request();
|
$r = new Request();
|
||||||
$_s = $r->getSpell();
|
$_s = $r->getSpell();
|
||||||
|
@ -84,15 +113,21 @@ class IP extends AjaxHandler
|
||||||
|
|
||||||
$result = Vesta::execute(Vesta::V_DEL_SYS_IP, $params);
|
$result = Vesta::execute(Vesta::V_DEL_SYS_IP, $params);
|
||||||
|
|
||||||
if(!$result['status'])
|
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']);
|
return $this->reply($result['status'], $result['data']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Change entry
|
||||||
function changeExecute($request)
|
*
|
||||||
|
* @param Request $request
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public function changeExecute($request)
|
||||||
{
|
{
|
||||||
$r = new Request();
|
$r = new Request();
|
||||||
$_s = $r->getSpell();
|
$_s = $r->getSpell();
|
||||||
|
@ -101,8 +136,7 @@ class IP extends AjaxHandler
|
||||||
|
|
||||||
$_user = 'vesta';
|
$_user = 'vesta';
|
||||||
|
|
||||||
|
if ($_old['OWNER'] != $_new['OWNER'])
|
||||||
if($_old['OWNER'] != $_new['OWNER'])
|
|
||||||
{
|
{
|
||||||
$result = array();
|
$result = array();
|
||||||
$result = Vesta::execute(Vesta::V_CHANGE_SYS_IP_OWNER, array('OWNER' => $_new['OWNER'], 'IP' => $_new['IP_ADDRESS']));
|
$result = Vesta::execute(Vesta::V_CHANGE_SYS_IP_OWNER, array('OWNER' => $_new['OWNER'], 'IP' => $_new['IP_ADDRESS']));
|
||||||
|
@ -113,22 +147,22 @@ class IP extends AjaxHandler
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if($_old['NAME'] != $_new['NAME'])
|
if ($_old['NAME'] != $_new['NAME'])
|
||||||
{
|
{
|
||||||
$result = array();
|
$result = array();
|
||||||
$result = Vesta::execute(Vesta::V_CHANGE_SYS_IP_NAME, array('IP' => $_new['IP_ADDRESS'], 'NAME' => $_new['NAME']));
|
$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->status = FALSE;
|
||||||
$this->errors['NAME'] = array($result['error_code'] => $result['error_message']);
|
$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 = array();
|
||||||
$result = Vesta::execute(Vesta::V_CHANGE_SYS_IP_STATUS, array('IP' => $_new['IP_ADDRESS'], 'IP_STATUS' => $_new['IP_STATUS']));
|
$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->status = FALSE;
|
||||||
$this->errors['IP_STATUS'] = array($result['error_code'] => $result['error_message']);
|
$this->errors['IP_STATUS'] = array($result['error_code'] => $result['error_message']);
|
||||||
|
@ -136,24 +170,35 @@ class IP extends AjaxHandler
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if(!$result['status'])
|
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']);
|
return $this->reply($result['status'], $result['data']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
function getSysInterfacesExecute($request)
|
* Get sys interfaces
|
||||||
|
*
|
||||||
|
* @param Request $request
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public function getSysInterfacesExecute($request)
|
||||||
{
|
{
|
||||||
$reply = array();
|
$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)
|
foreach ($result['data'] as $iface)
|
||||||
|
{
|
||||||
$reply[$iface] = $iface;
|
$reply[$iface] = $iface;
|
||||||
|
}
|
||||||
|
|
||||||
if(!$result['status'])
|
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'], $reply);
|
return $this->reply($result['status'], $reply);
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,33 +9,57 @@
|
||||||
* - methods, used for ajax executions must be postfixed with execute keyword
|
* - methods, used for ajax executions must be postfixed with execute keyword
|
||||||
* Eg.: getDnsInformationExecute()
|
* Eg.: getDnsInformationExecute()
|
||||||
*
|
*
|
||||||
|
* @author Naumov-Socolov <naumov.socolov@gmail.com>
|
||||||
|
* @author Malishev Dima <dima.malishev@gmail.com>
|
||||||
* @author vesta, http://vestacp.com/
|
* @author vesta, http://vestacp.com/
|
||||||
* @copyright vesta 2010
|
* @copyright vesta 2010-2011
|
||||||
*/
|
*/
|
||||||
class MAIN extends AjaxHandler {
|
class MAIN extends AjaxHandler
|
||||||
|
{
|
||||||
|
|
||||||
function versionExecute($request) {
|
/**
|
||||||
$result = array('version' => '1.0',
|
* Get version
|
||||||
|
*
|
||||||
|
* @param Request $request
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public function versionExecute($request)
|
||||||
|
{
|
||||||
|
$result = array(
|
||||||
|
'version' => '1.0',
|
||||||
'author' => 'http://vestacp.com/',
|
'author' => 'http://vestacp.com/',
|
||||||
'docs' => 'http://vestacp.com/docs');
|
'docs' => 'http://vestacp.com/docs'
|
||||||
|
);
|
||||||
|
|
||||||
return $this->reply(true, $result);
|
return $this->reply(true, $result);
|
||||||
}
|
}
|
||||||
|
|
||||||
function getInitialExecute($request)
|
/**
|
||||||
|
* Get initial params
|
||||||
|
*
|
||||||
|
* @param Request $request
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public function getInitialExecute($request)
|
||||||
{
|
{
|
||||||
require_once V_ROOT_DIR . 'api/IP.class.php';
|
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';
|
require_once V_ROOT_DIR . 'api/USER.class.php';
|
||||||
|
|
||||||
|
$ip_obj = new IP();
|
||||||
$user_obj = new USER();
|
$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'];
|
||||||
|
}
|
||||||
|
|
||||||
$users = json_decode($user_obj->getListExecute(), TRUE);
|
$users = json_decode($user_obj->getListExecute(), TRUE);
|
||||||
$user_names = array_keys($users['data']['data']);
|
$user_names = array_keys($users['data']['data']);
|
||||||
|
$db_types = array(
|
||||||
$db_types = array('mysql' => 'mysql', 'postgress' => 'postgress');
|
'mysql' => 'mysql',
|
||||||
|
'postgress' => 'postgress'
|
||||||
|
);
|
||||||
|
|
||||||
$interfaces_arr = json_decode($ip_obj->getSysInterfacesExecute(), TRUE);
|
$interfaces_arr = json_decode($ip_obj->getSysInterfacesExecute(), TRUE);
|
||||||
$interfaces = $interfaces_arr['data'];
|
$interfaces = $interfaces_arr['data'];
|
||||||
|
@ -50,9 +74,7 @@ class MAIN extends AjaxHandler {
|
||||||
'awstats' => 'awstats'),
|
'awstats' => 'awstats'),
|
||||||
'IP' => $ips
|
'IP' => $ips
|
||||||
),
|
),
|
||||||
|
|
||||||
'CRON' => array(),
|
'CRON' => array(),
|
||||||
|
|
||||||
'IP' => array(
|
'IP' => array(
|
||||||
'SYS_USERS' => $user_names,
|
'SYS_USERS' => $user_names,
|
||||||
'STATUSES' => array(
|
'STATUSES' => array(
|
||||||
|
@ -72,10 +94,11 @@ class MAIN extends AjaxHandler {
|
||||||
),
|
),
|
||||||
'OWNER' => array()
|
'OWNER' => array()
|
||||||
),
|
),
|
||||||
|
|
||||||
'DNS' => array(
|
'DNS' => array(
|
||||||
'IP' => $ips,
|
'IP' => $ips,
|
||||||
'TPL' => array('default' => 'default'),
|
'TPL' => array(
|
||||||
|
'default' => 'default'
|
||||||
|
),
|
||||||
'EXP' => array(),
|
'EXP' => array(),
|
||||||
'SOA' => array(),
|
'SOA' => array(),
|
||||||
'TTL' => array(),
|
'TTL' => array(),
|
||||||
|
@ -85,11 +108,9 @@ class MAIN extends AjaxHandler {
|
||||||
'RECORD_VALUE' => array()
|
'RECORD_VALUE' => array()
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
|
|
||||||
'DB' => array(
|
'DB' => array(
|
||||||
'TYPE' => $db_types
|
'TYPE' => $db_types
|
||||||
),
|
),
|
||||||
|
|
||||||
'USERS' => array(
|
'USERS' => array(
|
||||||
'ROLE' => array('user' => 'user'),
|
'ROLE' => array('user' => 'user'),
|
||||||
'OWNER' => $user_names,
|
'OWNER' => $user_names,
|
||||||
|
|
|
@ -1,30 +1,46 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PARAMS
|
* PARAMS
|
||||||
*
|
*
|
||||||
|
* @author Naumov-Socolov <naumov.socolov@gmail.com>
|
||||||
|
* @author Malishev Dima <dima.malishev@gmail.com>
|
||||||
* @author vesta, http://vestacp.com/
|
* @author vesta, http://vestacp.com/
|
||||||
* @copyright vesta 2011
|
* @copyright vesta 2010-2011
|
||||||
*/
|
*/
|
||||||
class PARAMS extends AjaxHandler {
|
class PARAMS extends AjaxHandler
|
||||||
function getInitialExecute($request)
|
{
|
||||||
|
/**
|
||||||
|
* Get initial params
|
||||||
|
*
|
||||||
|
* @param Request $request
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public function getInitialExecute($request)
|
||||||
{
|
{
|
||||||
require_once V_ROOT_DIR . 'api/IP.class.php';
|
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';
|
require_once V_ROOT_DIR . 'api/USER.class.php';
|
||||||
|
|
||||||
|
$ip_obj = new IP();
|
||||||
$user_obj = new USER();
|
$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'];
|
||||||
|
}
|
||||||
|
|
||||||
$users = json_decode($user_obj->getListExecute(), TRUE);
|
$users = json_decode($user_obj->getListExecute(), TRUE);
|
||||||
$user_names = array_keys($users['data']['data']);
|
$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_arr = json_decode($ip_obj->getSysInterfacesExecute(), TRUE);
|
||||||
$interfaces = $interfaces_arr['data'];
|
$interfaces = $interfaces_arr['data'];
|
||||||
|
|
||||||
|
|
||||||
$reply = array(
|
$reply = array(
|
||||||
'WEB_DOMAIN' => array(
|
'WEB_DOMAIN' => array(
|
||||||
'TPL' => array('default' => 'default'),
|
'TPL' => array('default' => 'default'),
|
||||||
|
@ -34,9 +50,7 @@ class PARAMS extends AjaxHandler {
|
||||||
'awstats' => 'awstats'),
|
'awstats' => 'awstats'),
|
||||||
'IP' => $ips
|
'IP' => $ips
|
||||||
),
|
),
|
||||||
|
|
||||||
'CRON' => array(),
|
'CRON' => array(),
|
||||||
|
|
||||||
'IP' => array(
|
'IP' => array(
|
||||||
'SYS_USERS' => $user_names,
|
'SYS_USERS' => $user_names,
|
||||||
'STATUSES' => array(
|
'STATUSES' => array(
|
||||||
|
@ -56,24 +70,23 @@ class PARAMS extends AjaxHandler {
|
||||||
),
|
),
|
||||||
'OWNER' => array()
|
'OWNER' => array()
|
||||||
),
|
),
|
||||||
|
|
||||||
'DNS' => array(
|
'DNS' => array(
|
||||||
'IP' => $ips,
|
'IP' => $ips,
|
||||||
'TPL' => array('default' => 'default'),
|
'TPL' => array(
|
||||||
|
'default' => 'default'
|
||||||
|
),
|
||||||
'EXP' => array(),
|
'EXP' => array(),
|
||||||
'SOA' => array(),
|
'SOA' => array(),
|
||||||
'TTL' => array(),
|
'TTL' => array(),
|
||||||
'record' => array(
|
'record' => array(
|
||||||
'RECORD' => array(),
|
'RECORD' => array(),
|
||||||
'RECORD_TYPE' => array('a' => 'a', 'reverce' => 'reverce'),
|
'RECORD_TYPE' => array('a' => 'a', 'reverse' => 'reverse'),
|
||||||
'RECORD_VALUE' => array()
|
'RECORD_VALUE' => array()
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
|
|
||||||
'DB' => array(
|
'DB' => array(
|
||||||
'TYPE' => $db_types
|
'TYPE' => $db_types
|
||||||
),
|
),
|
||||||
|
|
||||||
'USERS' => array(
|
'USERS' => array(
|
||||||
'ROLE' => array('user' => 'user'),
|
'ROLE' => array('user' => 'user'),
|
||||||
'OWNER' => $user_names,
|
'OWNER' => $user_names,
|
||||||
|
|
|
@ -2,17 +2,27 @@
|
||||||
/**
|
/**
|
||||||
* USERS
|
* USERS
|
||||||
*
|
*
|
||||||
|
* @author Naumov-Socolov <naumov.socolov@gmail.com>
|
||||||
|
* @author Malishev Dima <dima.malishev@gmail.com>
|
||||||
* @author vesta, http://vestacp.com/
|
* @author vesta, http://vestacp.com/
|
||||||
* @copyright vesta 2010
|
* @copyright vesta 2010-2011
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
class USER extends AjaxHandler {
|
class USER extends AjaxHandler
|
||||||
function getListExecute($request) {
|
{
|
||||||
$reply = array();
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get list
|
||||||
|
*
|
||||||
|
* @param Request $request
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public function getListExecute($request)
|
||||||
|
{
|
||||||
|
$reply = array();
|
||||||
$result = Vesta::execute(Vesta::V_LIST_SYS_USERS, array(Config::get('response_type')));
|
$result = Vesta::execute(Vesta::V_LIST_SYS_USERS, array(Config::get('response_type')));
|
||||||
|
|
||||||
foreach($result as $ip => $details){
|
foreach ($result as $ip => $details)
|
||||||
|
{
|
||||||
$reply[] = array(
|
$reply[] = array(
|
||||||
'interface' => $details['INTERFACE'],
|
'interface' => $details['INTERFACE'],
|
||||||
'sys_users' => $details['U_SYS_USERS'],
|
'sys_users' => $details['U_SYS_USERS'],
|
||||||
|
@ -23,68 +33,30 @@ class USER extends AjaxHandler {
|
||||||
'name' => $details['NAME'],
|
'name' => $details['NAME'],
|
||||||
'owner' => $details['OWNER'],
|
'owner' => $details['OWNER'],
|
||||||
'created_at' => date(Config::get('ui_date_format', strtotime($details['DATE'])))
|
'created_at' => date(Config::get('ui_date_format', strtotime($details['DATE'])))
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
|
|
||||||
"PACKAGE": "default",
|
|
||||||
"WEB_DOMAINS": "10",
|
|
||||||
"WEB_SSL": "10",
|
|
||||||
"WEB_ALIASES": "10",
|
|
||||||
"DATABASES": "10",
|
|
||||||
"MAIL_DOMAINS": "10",
|
|
||||||
"MAIL_BOXES": "30",
|
|
||||||
"MAIL_FORWARDERS": "30",
|
|
||||||
"DNS_DOMAINS": "10",
|
|
||||||
"DISK_QUOTA": "10000",
|
|
||||||
"BANDWIDTH": "10000",
|
|
||||||
"NS1": "ns1.localhost",
|
|
||||||
"NS2": "ns2.localhost",
|
|
||||||
"SHELL": "bash",
|
|
||||||
"BACKUPS": "3",
|
|
||||||
"TEMPLATES": "default, phpcgi, unlim",
|
|
||||||
"MAX_CHILDS": "300",
|
|
||||||
"SUSPENDED": "no",
|
|
||||||
"OWNER": "vesta",
|
|
||||||
"ROLE": "admin",
|
|
||||||
"IP_OWNED": "1",
|
|
||||||
"U_CHILDS": "0",
|
|
||||||
"U_DISK": "1",
|
|
||||||
"U_BANDWIDTH": "0",
|
|
||||||
"U_WEB_DOMAINS": "1",
|
|
||||||
"U_WEB_SSL": "0",
|
|
||||||
"U_DNS_DOMAINS": "3",
|
|
||||||
"U_DATABASES": "0",
|
|
||||||
"U_MAIL_DOMAINS": "0",
|
|
||||||
"CONTACT": "vesta@localhost",
|
|
||||||
"DATE": "01-04-11"
|
|
||||||
|
|
||||||
*/
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->reply(true, $result);
|
return $this->reply(true, $result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add action
|
||||||
function addExecute($_spell = false)
|
*
|
||||||
|
* @param Request $request
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public function addExecute($_spell = false)
|
||||||
{
|
{
|
||||||
$r = new Request();
|
$r = new Request();
|
||||||
if($_spell)
|
if ($_spell)
|
||||||
|
{
|
||||||
$_s = $_spell;
|
$_s = $_spell;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
$_s = $r->getSpell();
|
$_s = $r->getSpell();
|
||||||
|
}
|
||||||
|
|
||||||
$_user = 'vesta';
|
$_user = 'vesta';
|
||||||
|
|
||||||
// $_s['ROLE'] = 'user';
|
|
||||||
// reseller
|
|
||||||
// admin
|
|
||||||
|
|
||||||
// package: default
|
|
||||||
|
|
||||||
$params = array(
|
$params = array(
|
||||||
'USER' => $_s['USER'],
|
'USER' => $_s['USER'],
|
||||||
'PASSWORD' => $_s['PASSWORD'],
|
'PASSWORD' => $_s['PASSWORD'],
|
||||||
|
@ -97,40 +69,52 @@ class USER extends AjaxHandler {
|
||||||
);
|
);
|
||||||
|
|
||||||
$result = Vesta::execute(Vesta::V_ADD_SYS_USER, $params);
|
$result = Vesta::execute(Vesta::V_ADD_SYS_USER, $params);
|
||||||
|
if (!$result['status'])
|
||||||
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']);
|
return $this->reply($result['status'], $result['data']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Delete action
|
||||||
function delExecute($_spell = false)
|
*
|
||||||
|
* @param Request $request
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public function delExecute($_spell = false)
|
||||||
{
|
{
|
||||||
$r = new Request();
|
$r = new Request();
|
||||||
if($_spell)
|
if ($_spell)
|
||||||
|
{
|
||||||
$_s = $_spell;
|
$_s = $_spell;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
$_s = $r->getSpell();
|
$_s = $r->getSpell();
|
||||||
|
}
|
||||||
$_user = 'vesta';
|
$_user = 'vesta';
|
||||||
|
|
||||||
$params = array(
|
$params = array(
|
||||||
'USER' => $_s['USER']
|
'USER' => $_s['USER']
|
||||||
);
|
);
|
||||||
|
|
||||||
$result = Vesta::execute(Vesta::V_DEL_SYS_USER, $params);
|
$result = Vesta::execute(Vesta::V_DEL_SYS_USER, $params);
|
||||||
|
|
||||||
if(!$result['status'])
|
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']);
|
return $this->reply($result['status'], $result['data']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Change action
|
||||||
function changeExecute($request)
|
*
|
||||||
|
* @param Request $request
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public function changeExecute($request)
|
||||||
{
|
{
|
||||||
$r = new Request();
|
$r = new Request();
|
||||||
$_s = $r->getSpell();
|
$_s = $r->getSpell();
|
||||||
|
@ -141,13 +125,12 @@ class USER extends AjaxHandler {
|
||||||
|
|
||||||
if($_old['USER'] != $_new['USER'])
|
if($_old['USER'] != $_new['USER'])
|
||||||
{
|
{
|
||||||
|
|
||||||
$result = array();
|
$result = array();
|
||||||
// creating new user
|
// creating new user
|
||||||
$result = $this->addExecute($_new);
|
$result = $this->addExecute($_new);
|
||||||
|
|
||||||
// deleting old
|
// deleting old
|
||||||
if($result['status'])
|
if ($result['status'])
|
||||||
{
|
{
|
||||||
$result = array();
|
$result = array();
|
||||||
|
|
||||||
|
@ -156,77 +139,67 @@ class USER extends AjaxHandler {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if($_old['PASSWORD'] != $_new['PASSWORD'])
|
if ($_old['PASSWORD'] != $_new['PASSWORD'])
|
||||||
{
|
{
|
||||||
$result = array();
|
$result = array();
|
||||||
$result = Vesta::execute(Vesta::V_CHANGE_SYS_USER_PASSWORD, array('USER' => $_USER, 'PASSWORD' => $_new['PASSWORD']));
|
$result = Vesta::execute(Vesta::V_CHANGE_SYS_USER_PASSWORD,
|
||||||
if(!$result['status'])
|
array('USER' => $_USER, 'PASSWORD' => $_new['PASSWORD']));
|
||||||
|
if (!$result['status'])
|
||||||
{
|
{
|
||||||
$this->status = FALSE;
|
$this->status = FALSE;
|
||||||
$this->errors['PASSWORD'] = array($result['error_code'] => $result['error_message']);
|
$this->errors['PASSWORD'] = array($result['error_code'] => $result['error_message']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if($_old['PACKAGE'] != $_new['PACKAGE'])
|
if ($_old['PACKAGE'] != $_new['PACKAGE'])
|
||||||
{
|
{
|
||||||
$result = array();
|
$result = array();
|
||||||
$result = Vesta::execute(Vesta::V_CHANGE_SYS_USER_PACKAGE, array('USER' => $_USER, 'PACKAGE' => $_new['PACKAGE']));
|
$result = Vesta::execute(Vesta::V_CHANGE_SYS_USER_PACKAGE,
|
||||||
if(!$result['status'])
|
array('USER' => $_USER, 'PACKAGE' => $_new['PACKAGE']));
|
||||||
|
if (!$result['status'])
|
||||||
{
|
{
|
||||||
$this->status = FALSE;
|
$this->status = FALSE;
|
||||||
$this->errors['PACKAGE'] = array($result['error_code'] => $result['error_message']);
|
$this->errors['PACKAGE'] = array($result['error_code'] => $result['error_message']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
if ($_old['EMAIL'] != $_new['EMAIL'])
|
||||||
if($_old['ROLE'] != $_new['ROLE'])
|
|
||||||
{
|
|
||||||
echo '<br> role';
|
|
||||||
|
|
||||||
$result = array();
|
|
||||||
$result = Vesta::execute(Vesta::V_CHANGE_SYS_USER_ROLE, array('USER' => $_USER, 'ROLE' => $_new['ROLE']));
|
|
||||||
if(!$result['status'])
|
|
||||||
{
|
|
||||||
$this->status = FALSE;
|
|
||||||
$this->errors['ROLE'] = array($result['error_code'] => $result['error_message']);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
if($_old['EMAIL'] != $_new['EMAIL'])
|
|
||||||
{
|
{
|
||||||
$result = array();
|
$result = array();
|
||||||
$result = Vesta::execute(Vesta::V_CHANGE_SYS_USER_CONTACT, array('USER' => $_USER, 'EMAIL' => $_new['EMAIL']));
|
$result = Vesta::execute(Vesta::V_CHANGE_SYS_USER_CONTACT,
|
||||||
if(!$result['status'])
|
array('USER' => $_USER, 'EMAIL' => $_new['EMAIL']));
|
||||||
|
if (!$result['status'])
|
||||||
{
|
{
|
||||||
$this->status = FALSE;
|
$this->status = FALSE;
|
||||||
$this->errors['EMAIL'] = array($result['error_code'] => $result['error_message']);
|
$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 = array();
|
||||||
$result = Vesta::execute(Vesta::V_CHANGE_SYS_USER_NS, array('USER' => $_USER, 'NS1' => $_new['NS1'], 'NS2' => $_new['NS2']));
|
$result = Vesta::execute(Vesta::V_CHANGE_SYS_USER_NS,
|
||||||
if(!$result['status'])
|
array('USER' => $_USER, 'NS1' => $_new['NS1'], 'NS2' => $_new['NS2']));
|
||||||
|
if (!$result['status'])
|
||||||
{
|
{
|
||||||
$this->status = FALSE;
|
$this->status = FALSE;
|
||||||
$this->errors['NS'] = array($result['error_code'] => $result['error_message']);
|
$this->errors['NS'] = array($result['error_code'] => $result['error_message']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if($_old['SHELL'] != $_new['SHELL'])
|
if ($_old['SHELL'] != $_new['SHELL'])
|
||||||
{
|
{
|
||||||
$result = array();
|
$result = array();
|
||||||
$result = Vesta::execute(Vesta::V_CHANGE_SYS_USER_SHELL, array('USER' => $_USER, 'SHELL' => $_new['SHELL']));
|
$result = Vesta::execute(Vesta::V_CHANGE_SYS_USER_SHELL,
|
||||||
if(!$result['status'])
|
array('USER' => $_USER, 'SHELL' => $_new['SHELL']));
|
||||||
|
if (!$result['status'])
|
||||||
{
|
{
|
||||||
$this->status = FALSE;
|
$this->status = FALSE;
|
||||||
$this->errors['SHELL'] = array($result['error_code'] => $result['error_message']);
|
$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_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_PACKAGE, array('USER' => $_USER, 'PACKAGE' => $_old['PACKAGE']));
|
||||||
|
@ -239,6 +212,4 @@ class USER extends AjaxHandler {
|
||||||
return $this->reply($this->status, '');
|
return $this->reply($this->status, '');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
|
@ -1,22 +1,29 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* DOMAIN
|
* DOMAIN
|
||||||
*
|
*
|
||||||
|
* @author Naumov-Socolov <naumov.socolov@gmail.com>
|
||||||
|
* @author Malishev Dima <dima.malishev@gmail.com>
|
||||||
* @author vesta, http://vestacp.com/
|
* @author vesta, http://vestacp.com/
|
||||||
* @copyright vesta 2011
|
* @copyright vesta 2010-2011
|
||||||
*/
|
*/
|
||||||
class WEB_DOMAIN extends AjaxHandler {
|
class WEB_DOMAIN extends AjaxHandler
|
||||||
function getListExecute($request)
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get list
|
||||||
|
*
|
||||||
|
* @param Request $request
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public function getListExecute($request)
|
||||||
{
|
{
|
||||||
$_user = 'vesta';
|
$_user = 'vesta';
|
||||||
$reply = array();
|
$reply = array();
|
||||||
|
|
||||||
$result = Vesta::execute(Vesta::V_LIST_WEB_DOMAINS, array($_user, Config::get('response_type')));
|
$result = Vesta::execute(Vesta::V_LIST_WEB_DOMAINS, array($_user, Config::get('response_type')));
|
||||||
|
foreach ($result['data'] as $web_domain => $data)
|
||||||
// echo '<pre>';
|
|
||||||
// print_r($result);
|
|
||||||
|
|
||||||
foreach($result['data'] as $web_domain => $data)
|
|
||||||
{
|
{
|
||||||
$reply[$web_domain] = array(
|
$reply[$web_domain] = array(
|
||||||
'IP' => $record['IP'],
|
'IP' => $record['IP'],
|
||||||
|
@ -39,15 +46,21 @@ class WEB_DOMAIN extends AjaxHandler {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!$result['status'])
|
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'], $reply);
|
return $this->reply($result['status'], $reply);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add entry
|
||||||
function addExecute($request)
|
*
|
||||||
|
* @param Request $request
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public function addExecute($request)
|
||||||
{
|
{
|
||||||
$r = new Request();
|
$r = new Request();
|
||||||
$_s = $r->getSpell();
|
$_s = $r->getSpell();
|
||||||
|
@ -61,130 +74,174 @@ class WEB_DOMAIN extends AjaxHandler {
|
||||||
|
|
||||||
$result = Vesta::execute(Vesta::V_ADD_WEB_DOMAIN, $params);
|
$result = Vesta::execute(Vesta::V_ADD_WEB_DOMAIN, $params);
|
||||||
|
|
||||||
if(!$result['status'])
|
if (!$result['status'])
|
||||||
$this->errors[] = array($result['error_code'] => $result['error_message']);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// if(0)
|
|
||||||
if($_s['TPL'])
|
|
||||||
{
|
{
|
||||||
$params = array('USER' => $_user,
|
$this->errors[] = array(
|
||||||
|
$result['error_code'] => $result['error_message']
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($_s['TPL'])
|
||||||
|
{
|
||||||
|
$params = array(
|
||||||
|
'USER' => $_user,
|
||||||
'DOMAIN' => $_s['DOMAIN'],
|
'DOMAIN' => $_s['DOMAIN'],
|
||||||
'TPL' => $_s['TPL']);
|
'TPL' => $_s['TPL']
|
||||||
|
);
|
||||||
$result = 0;
|
$result = 0;
|
||||||
$result = Vesta::execute(Vesta::V_CHANGE_WEB_DOMAIN_TPL, $params);
|
$result = Vesta::execute(Vesta::V_CHANGE_WEB_DOMAIN_TPL, $params);
|
||||||
|
|
||||||
if(!$result['status'])
|
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'])
|
||||||
if($_s['ALIAS'])
|
|
||||||
{
|
{
|
||||||
$alias_arr = explode(',', $_s['ALIAS']);
|
$alias_arr = explode(',', $_s['ALIAS']);
|
||||||
|
|
||||||
foreach($alias_arr as $alias)
|
foreach ($alias_arr as $alias)
|
||||||
{
|
{
|
||||||
$params = array('USER' => $_user,
|
$params = array(
|
||||||
|
'USER' => $_user,
|
||||||
'DOMAIN' => $_s['DOMAIN'],
|
'DOMAIN' => $_s['DOMAIN'],
|
||||||
'ALIAS' => trim($alias));
|
'ALIAS' => trim($alias)
|
||||||
|
);
|
||||||
$result = 0;
|
$result = 0;
|
||||||
|
|
||||||
$result = Vesta::execute(Vesta::V_ADD_WEB_DOMAIN_ALIAS, $params);
|
$result = Vesta::execute(Vesta::V_ADD_WEB_DOMAIN_ALIAS, $params);
|
||||||
|
|
||||||
if(!$result['status'])
|
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'])
|
||||||
if($_s['STAT'])
|
|
||||||
{
|
{
|
||||||
$params = array('USER' => $_user,
|
$params = array(
|
||||||
|
'USER' => $_user,
|
||||||
'DOMAIN' => $_s['DOMAIN'],
|
'DOMAIN' => $_s['DOMAIN'],
|
||||||
'STAT' => $_s['STAT']);
|
'STAT' => $_s['STAT']
|
||||||
|
);
|
||||||
$result = 0;
|
$result = 0;
|
||||||
$result = Vesta::execute(Vesta::V_ADD_WEB_DOMAIN_STAT, $params);
|
$result = Vesta::execute(Vesta::V_ADD_WEB_DOMAIN_STAT, $params);
|
||||||
|
|
||||||
if(!$result['status'])
|
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'])
|
||||||
if($_s['STAT_AUTH'])
|
|
||||||
{
|
{
|
||||||
$params = array('USER' => $_user,
|
$params = array(
|
||||||
|
'USER' => $_user,
|
||||||
'DOMAIN' => $_s['DOMAIN'],
|
'DOMAIN' => $_s['DOMAIN'],
|
||||||
'STAT_USER' => $_s['STAT_USER'],
|
'STAT_USER' => $_s['STAT_USER'],
|
||||||
'STAT_PASSWORS' => $_s['STAT_PASSWORD']);
|
'STAT_PASSWORS' => $_s['STAT_PASSWORD']
|
||||||
|
);
|
||||||
$result = 0;
|
$result = 0;
|
||||||
$result = Vesta::execute(Vesta::V_ADD_WEB_DOMAIN_STAT_AUTH, $params);
|
$result = Vesta::execute(Vesta::V_ADD_WEB_DOMAIN_STAT_AUTH, $params);
|
||||||
|
|
||||||
if(!$result['status'])
|
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'])
|
if ($_s['SSL'])
|
||||||
{
|
{
|
||||||
$params = array('USER' => $_user,
|
$params = array(
|
||||||
|
'USER' => $_user,
|
||||||
'DOMAIN' => $_s['DOMAIN'],
|
'DOMAIN' => $_s['DOMAIN'],
|
||||||
'SSL_CERT' => $_s['SSL_CERT']);
|
'SSL_CERT' => $_s['SSL_CERT']
|
||||||
|
);
|
||||||
|
|
||||||
if($_s['SSL_HOME'])
|
if ($_s['SSL_HOME'])
|
||||||
|
{
|
||||||
$params['SSL_HOME'] = $_s['SSL_HOME'];
|
$params['SSL_HOME'] = $_s['SSL_HOME'];
|
||||||
|
}
|
||||||
|
|
||||||
if($_s['SSL_TEXT'])
|
if ($_s['SSL_TEXT'])
|
||||||
{}
|
{
|
||||||
// if($_FILES['SSL_CERT'])
|
// TODO: write it up
|
||||||
// $ssl_text = file_get_contents($_FILES...);
|
}
|
||||||
|
|
||||||
|
|
||||||
$result = 0;
|
$result = 0;
|
||||||
$result = Vesta::execute(Vesta::V_ADD_WEB_DOMAIN_SSL, $params);
|
$result = Vesta::execute(Vesta::V_ADD_WEB_DOMAIN_SSL, $params);
|
||||||
|
|
||||||
if(!$result['status'])
|
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'])
|
||||||
if($_s['CREATE_DNS_DOMAIN'])
|
|
||||||
{
|
{
|
||||||
$params = array('USER' => $_user,
|
$params = array(
|
||||||
|
'USER' => $_user,
|
||||||
'DNS_DOMAIN' => $_s['DOMAIN'],
|
'DNS_DOMAIN' => $_s['DOMAIN'],
|
||||||
'IP' => $_s['IP']);
|
'IP' => $_s['IP']
|
||||||
|
);
|
||||||
|
|
||||||
require_once V_ROOT_DIR . 'api/DNS.class.php';
|
require_once V_ROOT_DIR . 'api/DNS.class.php';
|
||||||
|
|
||||||
$dns = new DNS();
|
$dns = new DNS();
|
||||||
$result = 0;
|
$result = 0;
|
||||||
$result = $dns->addExecute($params);
|
$result = $dns->addExecute($params);
|
||||||
if(!$result['status'])
|
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'])
|
||||||
if($_s['CREATE_MAIL_DOMAIN'])
|
|
||||||
{
|
{
|
||||||
$params = array('USER' => $_user,
|
$params = array(
|
||||||
|
'USER' => $_user,
|
||||||
'MAIL_DOMAIN' => $_s['DOMAIN'],
|
'MAIL_DOMAIN' => $_s['DOMAIN'],
|
||||||
'IP' => $_s['IP']);
|
'IP' => $_s['IP']
|
||||||
|
);
|
||||||
|
|
||||||
require_once V_ROOT_DIR . 'api/MAIL.class.php';
|
require_once V_ROOT_DIR . 'api/MAIL.class.php';
|
||||||
|
|
||||||
$mail = new MAIL();
|
$mail = new MAIL();
|
||||||
$result = 0;
|
$result = 0;
|
||||||
$result = $mail->addExecute($params);
|
$result = $mail->addExecute($params);
|
||||||
if(!$result['status'])
|
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']);
|
return $this->reply($result['status'], $result['data']);
|
||||||
}
|
}
|
||||||
|
|
||||||
function delExecute($request)
|
/**
|
||||||
|
* Delete entry
|
||||||
|
*
|
||||||
|
* @param Request $request
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public function delExecute($request)
|
||||||
{
|
{
|
||||||
$r = new Request();
|
$r = new Request();
|
||||||
$_s = $r->getSpell();
|
$_s = $r->getSpell();
|
||||||
|
@ -197,10 +254,10 @@ class WEB_DOMAIN extends AjaxHandler {
|
||||||
|
|
||||||
$result = Vesta::execute(Vesta::V_DEL_WEB_DOMAIN, $params);
|
$result = Vesta::execute(Vesta::V_DEL_WEB_DOMAIN, $params);
|
||||||
|
|
||||||
if(!$result['status'])
|
if (!$result['status'])
|
||||||
$this->errors[] = array($result['error_code'] => $result['error_message']);
|
$this->errors[] = array(
|
||||||
|
$result['error_code'] => $result['error_message']
|
||||||
|
);
|
||||||
|
|
||||||
$params = array(
|
$params = array(
|
||||||
'USER' => $_user,
|
'USER' => $_user,
|
||||||
|
@ -211,8 +268,12 @@ class WEB_DOMAIN extends AjaxHandler {
|
||||||
$dns = new DNS();
|
$dns = new DNS();
|
||||||
$result = $dns->delExecute($params);
|
$result = $dns->delExecute($params);
|
||||||
|
|
||||||
if(!$result['status'] && $result['error_code'] != 31) // domain not found
|
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';
|
require_once V_ROOT_DIR . 'api/DNS.class.php';
|
||||||
|
|
||||||
|
@ -221,20 +282,16 @@ class WEB_DOMAIN extends AjaxHandler {
|
||||||
'MAIL_DOMAIN' => $_s['DOMAIN']
|
'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']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Change entry
|
||||||
function changeExecute($request)
|
*
|
||||||
|
* @param Request $request
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public function changeExecute($request)
|
||||||
{
|
{
|
||||||
$r = new Request();
|
$r = new Request();
|
||||||
$_s = $r->getSpell();
|
$_s = $r->getSpell();
|
||||||
|
@ -244,30 +301,41 @@ class WEB_DOMAIN extends AjaxHandler {
|
||||||
$_user = 'vesta';
|
$_user = 'vesta';
|
||||||
$_DOMAIN = $_new['DOMAIN'];
|
$_DOMAIN = $_new['DOMAIN'];
|
||||||
|
|
||||||
if($_old['IP'] != $_new['IP'])
|
if ($_old['IP'] != $_new['IP'])
|
||||||
{
|
{
|
||||||
$result = array();
|
$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(
|
||||||
if(!$result['status'])
|
'USER' => $_user,
|
||||||
|
'DOMAIN' => $_DOMAIN,
|
||||||
|
'IP' => $_new['IP']
|
||||||
|
));
|
||||||
|
if (!$result['status'])
|
||||||
{
|
{
|
||||||
$this->status = FALSE;
|
$this->status = FALSE;
|
||||||
$this->errors['IP_ADDRESS'] = array($result['error_code'] => $result['error_message']);
|
$this->errors['IP_ADDRESS'] = array(
|
||||||
|
$result['error_code'] => $result['error_message']
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($_old['TPL'] != $_new['TPL'])
|
||||||
if($_old['TPL'] != $_new['TPL'])
|
|
||||||
{
|
{
|
||||||
$result = array();
|
$result = 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(
|
||||||
if(!$result['status'])
|
'USER' => $_user,
|
||||||
|
'DOMAIN' => $_DOMAIN,
|
||||||
|
'TPL' => $_new['TPL']
|
||||||
|
));
|
||||||
|
if (!$result['status'])
|
||||||
{
|
{
|
||||||
$this->status = FALSE;
|
$this->status = FALSE;
|
||||||
$this->errors['TPL'] = array($result['error_code'] => $result['error_message']);
|
$this->errors['TPL'] = array(
|
||||||
|
$result['error_code'] => $result['error_message']
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if($_old['ALIAS'] != $_new['ALIAS'])
|
if ($_old['ALIAS'] != $_new['ALIAS'])
|
||||||
{
|
{
|
||||||
$result = array();
|
$result = array();
|
||||||
|
|
||||||
|
@ -277,146 +345,203 @@ class WEB_DOMAIN extends AjaxHandler {
|
||||||
$added = array_diff($new_arr, $old_arr);
|
$added = array_diff($new_arr, $old_arr);
|
||||||
$deleted = array_diff($old_arr, $new_arr);
|
$deleted = array_diff($old_arr, $new_arr);
|
||||||
|
|
||||||
foreach($added as $alias)
|
foreach ($added as $alias)
|
||||||
{
|
{
|
||||||
$result = Vesta::execute(Vesta::V_ADD_WEB_DOMAIN_ALIAS, array('USER' => $_user, 'DOMAIN' => $_DOMAIN, 'ALIAS' => $alias));
|
$result = Vesta::execute(Vesta::V_ADD_WEB_DOMAIN_ALIAS, array(
|
||||||
if(!$result['status'])
|
'USER' => $_user,
|
||||||
|
'DOMAIN' => $_DOMAIN,
|
||||||
|
'ALIAS' => $alias
|
||||||
|
));
|
||||||
|
if (!$result['status'])
|
||||||
{
|
{
|
||||||
$this->status = FALSE;
|
$this->status = FALSE;
|
||||||
$this->errors['ADD_ALIAS'] = array($result['error_code'] => $result['error_message']);
|
$this->errors['ADD_ALIAS'] = array(
|
||||||
|
$result['error_code'] => $result['error_message']
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
foreach($deleted as $alias)
|
foreach ($deleted as $alias)
|
||||||
{
|
{
|
||||||
$result = Vesta::execute(Vesta::V_DEL_WEB_DOMAIN_ALIAS, array('USER' => $_user, 'DOMAIN' => $_DOMAIN, 'ALIAS' => $alias));
|
$result = Vesta::execute(Vesta::V_DEL_WEB_DOMAIN_ALIAS, array(
|
||||||
if(!$result['status'])
|
'USER' => $_user,
|
||||||
|
'DOMAIN' => $_DOMAIN,
|
||||||
|
'ALIAS' => $alias
|
||||||
|
));
|
||||||
|
if (!$result['status'])
|
||||||
{
|
{
|
||||||
$this->status = FALSE;
|
$this->status = FALSE;
|
||||||
$this->errors['DEL_ALIAS'] = array($result['error_code'] => $result['error_message']);
|
$this->errors['DEL_ALIAS'] = array(
|
||||||
|
$result['error_code'] => $result['error_message']
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if($_old['STAT'] != $_new['STAT'])
|
if ($_old['STAT'] != $_new['STAT'])
|
||||||
{
|
{
|
||||||
if($_new['STAT'] == true)
|
if ($_new['STAT'] == true)
|
||||||
{
|
{
|
||||||
$result = array();
|
$result = 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(
|
||||||
if(!$result['status'])
|
'USER' => $_user,
|
||||||
|
'DOMAIN' => $_DOMAIN,
|
||||||
|
'STAT' => $_new['STAT']
|
||||||
|
));
|
||||||
|
if (!$result['status'])
|
||||||
{
|
{
|
||||||
$this->status = FALSE;
|
$this->status = FALSE;
|
||||||
$this->errors['ADD_STAT'] = array($result['error_code'] => $result['error_message']);
|
$this->errors['ADD_STAT'] = array(
|
||||||
|
$result['error_code'] => $result['error_message']
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if($_new['STAT'] == false)
|
if ($_new['STAT'] == false)
|
||||||
{
|
{
|
||||||
$result = array();
|
$result = 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(
|
||||||
if(!$result['status'])
|
'USER' => $_user,
|
||||||
|
'DOMAIN' => $_DOMAIN
|
||||||
|
));
|
||||||
|
if (!$result['status'])
|
||||||
{
|
{
|
||||||
$this->status = FALSE;
|
$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 = 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(
|
||||||
if(!$result['status'])
|
'USER' => $_user,
|
||||||
|
'DOMAIN' => $_DOMAIN,
|
||||||
|
'STAT_USER' => $_new['STAT_USER']
|
||||||
|
));
|
||||||
|
if (!$result['status'])
|
||||||
{
|
{
|
||||||
$this->status = FALSE;
|
$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)
|
if ($_old['SSL'] != $_new['SSL'])
|
||||||
// ssl
|
|
||||||
if($_old['SSL'] != $_new['SSL'])
|
|
||||||
{
|
{
|
||||||
if($_new['SSL'] == true)
|
if ($_new['SSL'] == true)
|
||||||
{
|
{
|
||||||
|
// TODO: write it
|
||||||
|
|
||||||
}
|
}
|
||||||
if($_new['SSL'] == false)
|
if ($_new['SSL'] == false)
|
||||||
{
|
{
|
||||||
|
// TODO: write it
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if($_old['SSL_CERT'] != $_new['SSL_CERT'])
|
if ($_old['SSL_CERT'] != $_new['SSL_CERT'])
|
||||||
{
|
{
|
||||||
$result = array();
|
$result = array();
|
||||||
$_SSL_CERT = $_new['SSL_CERT'];
|
$_SSL_CERT = $_new['SSL_CERT'];
|
||||||
// or read uploaded tmp file
|
// 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(
|
||||||
if(!$result['status'])
|
'USER' => $_user,
|
||||||
|
'DOMAIN' => $_DOMAIN,
|
||||||
|
'SSL_CERT' => $_SSL_CERT
|
||||||
|
));
|
||||||
|
if (!$result['status'])
|
||||||
{
|
{
|
||||||
$this->status = FALSE;
|
$this->status = FALSE;
|
||||||
$this->errors['SSL_CERT'] = array($result['error_code'] => $result['error_message']);
|
$this->errors['SSL_CERT'] = array(
|
||||||
|
$result['error_code'] => $result['error_message']
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if($_old['SSL_HOME'] != $_new['SSL_HOME'])
|
if ($_old['SSL_HOME'] != $_new['SSL_HOME'])
|
||||||
{
|
{
|
||||||
$result = array();
|
$result = 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(
|
||||||
if(!$result['status'])
|
'USER' => $_user,
|
||||||
|
'DOMAIN' => $_DOMAIN,
|
||||||
|
'SSL_HOME' => $_new['SSL_HOME']
|
||||||
|
));
|
||||||
|
if (!$result['status'])
|
||||||
{
|
{
|
||||||
$this->status = FALSE;
|
$this->status = FALSE;
|
||||||
$this->errors['SSL_HOME'] = array($result['error_code'] => $result['error_message']);
|
$this->errors['SSL_HOME'] = array(
|
||||||
|
$result['error_code'] => $result['error_message']
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if($_old['CGI'] != $_new['CGI'])
|
if ($_old['CGI'] != $_new['CGI'])
|
||||||
{
|
{
|
||||||
if($_new['CGI'] == true)
|
if ($_new['CGI'] == true)
|
||||||
{
|
{
|
||||||
$result = array();
|
$result = 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(
|
||||||
if(!$result['status'])
|
'USER' => $_user,
|
||||||
|
'DOMAIN' => $_DOMAIN
|
||||||
|
));
|
||||||
|
if (!$result['status'])
|
||||||
{
|
{
|
||||||
$this->status = FALSE;
|
$this->status = FALSE;
|
||||||
$this->errors['ADD_CGI'] = array($result['error_code'] => $result['error_message']);
|
$this->errors['ADD_CGI'] = array(
|
||||||
|
$result['error_code'] => $result['error_message']
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if($_new['CGI'] == false)
|
if ($_new['CGI'] == false)
|
||||||
{
|
{
|
||||||
$result = array();
|
$result = 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(
|
||||||
if(!$result['status'])
|
'USER' => $_user,
|
||||||
|
'DOMAIN' => $_DOMAIN
|
||||||
|
));
|
||||||
|
if (!$result['status'])
|
||||||
{
|
{
|
||||||
$this->status = FALSE;
|
$this->status = FALSE;
|
||||||
$this->errors['DEL_CGI'] = array($result['error_code'] => $result['error_message']);
|
$this->errors['DEL_CGI'] = array(
|
||||||
|
$result['error_code'] => $result['error_message']
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if($_old['ELOG'] != $_new['ELOG'])
|
if ($_old['ELOG'] != $_new['ELOG'])
|
||||||
{
|
{
|
||||||
if($_new['ELOG'] == true)
|
if ($_new['ELOG'] == true)
|
||||||
{
|
{
|
||||||
$result = array();
|
$result = 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(
|
||||||
if(!$result['status'])
|
'USER' => $_user,
|
||||||
|
'DOMAIN' => $_DOMAIN
|
||||||
|
));
|
||||||
|
if (!$result['status'])
|
||||||
{
|
{
|
||||||
$this->status = FALSE;
|
$this->status = FALSE;
|
||||||
$this->errors['ADD_ELOG'] = array($result['error_code'] => $result['error_message']);
|
$this->errors['ADD_ELOG'] = array(
|
||||||
|
$result['error_code'] => $result['error_message']
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if($_new['ELOG'] == false)
|
if ($_new['ELOG'] == false)
|
||||||
{
|
{
|
||||||
$result = array();
|
$result = 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(
|
||||||
if(!$result['status'])
|
'USER' => $_user,
|
||||||
|
'DOMAIN' => $_DOMAIN
|
||||||
|
));
|
||||||
|
if (!$result['status'])
|
||||||
{
|
{
|
||||||
$this->status = FALSE;
|
$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']
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -425,9 +550,13 @@ class WEB_DOMAIN extends AjaxHandler {
|
||||||
return $this->reply($result['status'], $result['data']);
|
return $this->reply($result['status'], $result['data']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Suspend entry
|
||||||
function suspendExecute($request)
|
*
|
||||||
|
* @param Request $request
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public function suspendExecute($request)
|
||||||
{
|
{
|
||||||
$r = new Request();
|
$r = new Request();
|
||||||
$_s = $r->getSpell();
|
$_s = $r->getSpell();
|
||||||
|
@ -441,14 +570,23 @@ class WEB_DOMAIN extends AjaxHandler {
|
||||||
|
|
||||||
$result = Vesta::execute(Vesta::V_SUSPEND_WEB_DOMAIN, $params);
|
$result = Vesta::execute(Vesta::V_SUSPEND_WEB_DOMAIN, $params);
|
||||||
|
|
||||||
if(!$result['status'])
|
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']);
|
return $this->reply($result['status'], $result['data']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
function unsuspendExecute($request)
|
* Unsuspend entry
|
||||||
|
*
|
||||||
|
* @param Request $request
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public function unsuspendExecute($request)
|
||||||
{
|
{
|
||||||
$r = new Request();
|
$r = new Request();
|
||||||
$_s = $r->getSpell();
|
$_s = $r->getSpell();
|
||||||
|
@ -462,15 +600,23 @@ class WEB_DOMAIN extends AjaxHandler {
|
||||||
|
|
||||||
$result = Vesta::execute(Vesta::V_UNSUSPEND_WEB_DOMAIN, $params);
|
$result = Vesta::execute(Vesta::V_UNSUSPEND_WEB_DOMAIN, $params);
|
||||||
|
|
||||||
if(!$result['status'])
|
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']);
|
return $this->reply($result['status'], $result['data']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Batch suspend entries
|
||||||
function suspendAllExecute($request)
|
*
|
||||||
|
* @param Request $request
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public function suspendAllExecute($request)
|
||||||
{
|
{
|
||||||
$r = new Request();
|
$r = new Request();
|
||||||
$_s = $r->getSpell();
|
$_s = $r->getSpell();
|
||||||
|
@ -483,13 +629,23 @@ class WEB_DOMAIN extends AjaxHandler {
|
||||||
|
|
||||||
$result = Vesta::execute(Vesta::V_SUSPEND_WEB_DOMAINS, $params);
|
$result = Vesta::execute(Vesta::V_SUSPEND_WEB_DOMAINS, $params);
|
||||||
|
|
||||||
if(!$result['status'])
|
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']);
|
return $this->reply($result['status'], $result['data']);
|
||||||
}
|
}
|
||||||
|
|
||||||
function unsuspendAllExecute($request)
|
/**
|
||||||
|
* Batch unsuspend entry
|
||||||
|
*
|
||||||
|
* @param Request $request
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public function unsuspendAllExecute($request)
|
||||||
{
|
{
|
||||||
$r = new Request();
|
$r = new Request();
|
||||||
$_s = $r->getSpell();
|
$_s = $r->getSpell();
|
||||||
|
@ -502,9 +658,14 @@ class WEB_DOMAIN extends AjaxHandler {
|
||||||
|
|
||||||
$result = Vesta::execute(Vesta::V_UNSUSPEND_WEB_DOMAINS, $params);
|
$result = Vesta::execute(Vesta::V_UNSUSPEND_WEB_DOMAINS, $params);
|
||||||
|
|
||||||
if(!$result['status'])
|
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']);
|
return $this->reply($result['status'], $result['data']);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -13,8 +13,9 @@ require_once V_ROOT_DIR . 'api/AjaxHandler.php';
|
||||||
/**
|
/**
|
||||||
* App execution
|
* App execution
|
||||||
*
|
*
|
||||||
|
* @author Malishev Dima <dima.malishev@gmail.com>
|
||||||
* @author vesta, http://vestacp.com/
|
* @author vesta, http://vestacp.com/
|
||||||
* @copyright vesta 2010
|
* @copyright vesta 2010-2011
|
||||||
*/
|
*/
|
||||||
try {
|
try {
|
||||||
// Execution
|
// Execution
|
||||||
|
|
|
@ -1,28 +1,58 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
class Config {
|
/**
|
||||||
|
* Config class
|
||||||
|
*
|
||||||
|
* Reads, manipulate configs
|
||||||
|
*
|
||||||
|
* @author Malishev Dima <dima.malishev@gmail.com>
|
||||||
|
* @author vesta, http://vestacp.com/
|
||||||
|
* @copyright vesta 2010-2011
|
||||||
|
*/
|
||||||
|
class Config
|
||||||
|
{
|
||||||
|
|
||||||
protected $_config = array();
|
protected $_config = array();
|
||||||
static public $instance = null;
|
static public $instance = null;
|
||||||
|
|
||||||
public function __construct() {
|
/**
|
||||||
|
* Config constructor
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
$this->_config = parse_ini_file(V_ROOT_DIR.'config'.DIRECTORY_SEPARATOR.'vesta_config.ini');
|
$this->_config = parse_ini_file(V_ROOT_DIR.'config'.DIRECTORY_SEPARATOR.'vesta_config.ini');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getParameter($key){
|
/**
|
||||||
|
* get config parameter
|
||||||
|
*
|
||||||
|
* @param string $key
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function getParameter($key)
|
||||||
|
{
|
||||||
return isset($this->_config[$key]) ? $this->_config[$key] : false;
|
return isset($this->_config[$key]) ? $this->_config[$key] : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Grab current instance or create it
|
* Grab current instance or create it
|
||||||
*
|
*
|
||||||
* @return <type>
|
* @return Config
|
||||||
*/
|
*/
|
||||||
static function getInstance($request=null) {
|
static public function getInstance($request = null)
|
||||||
|
{
|
||||||
return null == self::$instance ? self::$instance = new self() : self::$instance;
|
return null == self::$instance ? self::$instance = new self() : self::$instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
static function get($key){
|
/**
|
||||||
|
* Shortcut method: get config parameter
|
||||||
|
*
|
||||||
|
* @param string $key
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
static public function get($key)
|
||||||
|
{
|
||||||
$ref = self::getInstance();
|
$ref = self::getInstance();
|
||||||
|
|
||||||
return $ref->getParameter($key);
|
return $ref->getParameter($key);
|
||||||
|
|
|
@ -5,10 +5,12 @@
|
||||||
*
|
*
|
||||||
* Holds parameters, decorating them and providing easy access
|
* Holds parameters, decorating them and providing easy access
|
||||||
*
|
*
|
||||||
|
* @author Malishev Dima <dima.malishev@gmail.com>
|
||||||
* @author vesta, http://vestacp.com/
|
* @author vesta, http://vestacp.com/
|
||||||
* @copyright vesta 2010
|
* @copyright vesta 2010-2011
|
||||||
*/
|
*/
|
||||||
class Request {
|
class Request
|
||||||
|
{
|
||||||
|
|
||||||
protected $server = array();
|
protected $server = array();
|
||||||
protected $post = array();
|
protected $post = array();
|
||||||
|
@ -20,7 +22,8 @@ class Request {
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public function __construct() {
|
public function __construct()
|
||||||
|
{
|
||||||
$this->post = $_POST;
|
$this->post = $_POST;
|
||||||
$this->get = $_GET;
|
$this->get = $_GET;
|
||||||
$this->server = $_SERVER;
|
$this->server = $_SERVER;
|
||||||
|
@ -31,29 +34,47 @@ class Request {
|
||||||
/**
|
/**
|
||||||
* Merge holders into single holder
|
* Merge holders into single holder
|
||||||
*/
|
*/
|
||||||
function mergeContainers() {
|
public function mergeContainers()
|
||||||
$this->_merged = array_merge($this->server, $this->post, $this->get, $this->global);
|
{
|
||||||
|
$this->_merged = array_merge($this->server,
|
||||||
|
$this->post,
|
||||||
|
$this->get,
|
||||||
|
$this->global);
|
||||||
$this->_spell = json_decode($this->_merged['spell'], true);
|
$this->_spell = json_decode($this->_merged['spell'], true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get parameter
|
* Get parameter
|
||||||
*
|
*
|
||||||
* @param <string> $key
|
* @param string $key
|
||||||
* @param <mixed> $default
|
* @param mixed $default
|
||||||
* @return <mixed>
|
* @return mixed
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
function getParameter($key, $default=false) {
|
public function getParameter($key, $default=false)
|
||||||
|
{
|
||||||
return isset($this->_merged[$key]) ? $this->_merged[$key] : $default;
|
return isset($this->_merged[$key]) ? $this->_merged[$key] : $default;
|
||||||
// return isset($this->_spell[$key]) ? $this->_spell[$key] : $default;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function getSpell() {
|
/**
|
||||||
|
* Get spell variable from parameters
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function getSpell()
|
||||||
|
{
|
||||||
return $this->_spell;
|
return $this->_spell;
|
||||||
}
|
}
|
||||||
|
|
||||||
function hasParameter($key, $default=false) {
|
/**
|
||||||
|
* Check if parameter is set
|
||||||
|
*
|
||||||
|
* @param string $key
|
||||||
|
* @param mixed $default
|
||||||
|
* @return mixed
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public function hasParameter($key, $default=false)
|
||||||
|
{
|
||||||
return isset($this->_merged[$key]);
|
return isset($this->_merged[$key]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -62,20 +83,32 @@ class Request {
|
||||||
*
|
*
|
||||||
* TODO: write the method
|
* TODO: write the method
|
||||||
*
|
*
|
||||||
* @return <boolean>
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
function isPost() {
|
public function isPost()
|
||||||
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static function parseAjaxMethod($request) {
|
/**
|
||||||
if (!$request->hasParameter('jedi_method')) {
|
* Dissassemble ajax method
|
||||||
|
* Breaks ajax requested method param into "ENTITY"."ACTION"
|
||||||
|
* for instance DNS.getList into "namespase" => DNS, "function" => "getList"
|
||||||
|
* for triggering ($DNS->getListExecuty();)
|
||||||
|
*
|
||||||
|
* TODO: write the method
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
static public function parseAjaxMethod($request)
|
||||||
|
{
|
||||||
|
if (!$request->hasParameter('jedi_method'))
|
||||||
|
{
|
||||||
throw new ProtectionException(Message::INVALID_METHOD);
|
throw new ProtectionException(Message::INVALID_METHOD);
|
||||||
}
|
}
|
||||||
|
|
||||||
$method = explode('.', $request->getParameter('jedi_method'));
|
$method = explode('.', $request->getParameter('jedi_method'));
|
||||||
|
if (count($method) != 2)
|
||||||
if (count($method) != 2) {
|
{
|
||||||
throw new ProtectionException(Message::INVALID_METHOD);
|
throw new ProtectionException(Message::INVALID_METHOD);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,121 +1,85 @@
|
||||||
<?php
|
<?php
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author vesta, http://vestacp.com/
|
|
||||||
* @copyright vesta 2010
|
|
||||||
*/
|
|
||||||
class Vesta {
|
|
||||||
// ====================== IP ===========================
|
|
||||||
const V_LIST_SYS_IPS = 'v_list_sys_ips';
|
|
||||||
|
|
||||||
// adding
|
/**
|
||||||
|
* Api Main class
|
||||||
|
* Calls / Executes native vesta methods
|
||||||
|
*
|
||||||
|
* @author Malishev Dima <dima.malishev@gmail.com>
|
||||||
|
* @author Naumov-Socolov <naumov.socolov@gmail.com>
|
||||||
|
* @author vesta, http://vestacp.com/
|
||||||
|
* @copyright vesta 2010-2011
|
||||||
|
*/
|
||||||
|
class Vesta
|
||||||
|
{
|
||||||
|
// IP
|
||||||
|
const V_LIST_SYS_IPS = 'v_list_sys_ips';
|
||||||
const V_ADD_SYS_IP = 'v_add_sys_ip';
|
const V_ADD_SYS_IP = 'v_add_sys_ip';
|
||||||
const V_ADD_SYS_USER_IP = 'v_add_sys_user_ip';
|
const V_ADD_SYS_USER_IP = 'v_add_sys_user_ip';
|
||||||
|
|
||||||
// changing
|
|
||||||
const V_CHANGE_SYS_IP_OWNER = 'v_change_sys_ip_owner';
|
const V_CHANGE_SYS_IP_OWNER = 'v_change_sys_ip_owner';
|
||||||
const V_CHANGE_SYS_IP_NAME = 'v_change_sys_ip_name';
|
const V_CHANGE_SYS_IP_NAME = 'v_change_sys_ip_name';
|
||||||
const V_CHANGE_SYS_IP_STATUS = 'v_change_sys_ip_status';
|
const V_CHANGE_SYS_IP_STATUS = 'v_change_sys_ip_status';
|
||||||
// deleting
|
|
||||||
const V_DEL_SYS_IP = 'v_del_sys_ip';
|
const V_DEL_SYS_IP = 'v_del_sys_ip';
|
||||||
|
|
||||||
// service
|
|
||||||
const V_UPD_SYS_IP = 'v_upd_sys_ip';
|
const V_UPD_SYS_IP = 'v_upd_sys_ip';
|
||||||
const V_LIST_SYS_INTERFACES = 'v_list_sys_interfaces';
|
const V_LIST_SYS_INTERFACES = 'v_list_sys_interfaces';
|
||||||
|
// DNS
|
||||||
// ======================= DNS =========================
|
|
||||||
const V_LIST_DNS_DOMAINS = 'v_list_dns_domains';
|
const V_LIST_DNS_DOMAINS = 'v_list_dns_domains';
|
||||||
const V_LIST_DNS_DOMAIN_RECORDS = 'v_list_dns_domain';
|
const V_LIST_DNS_DOMAIN_RECORDS = 'v_list_dns_domain';
|
||||||
|
|
||||||
// adding
|
|
||||||
const V_ADD_DNS_DOMAIN = 'v_add_dns_domain';
|
const V_ADD_DNS_DOMAIN = 'v_add_dns_domain';
|
||||||
const V_ADD_DNS_DOMAIN_RECORD = 'v_add_dns_domain_record';
|
const V_ADD_DNS_DOMAIN_RECORD = 'v_add_dns_domain_record';
|
||||||
|
|
||||||
// changing
|
|
||||||
const V_CHANGE_DNS_DOMAIN_IP = 'v_change_dns_domain_ip';
|
const V_CHANGE_DNS_DOMAIN_IP = 'v_change_dns_domain_ip';
|
||||||
const V_CHANGE_DNS_DOMAIN_SOA = 'v_change_dns_domain_soa';
|
const V_CHANGE_DNS_DOMAIN_SOA = 'v_change_dns_domain_soa';
|
||||||
const V_CHANGE_DNS_DOMAIN_TPL = 'v_change_dns_domain_tpl';
|
const V_CHANGE_DNS_DOMAIN_TPL = 'v_change_dns_domain_tpl';
|
||||||
const V_CHANGE_DNS_DOMAIN_TTL = 'v_change_dns_domain_ttl';
|
const V_CHANGE_DNS_DOMAIN_TTL = 'v_change_dns_domain_ttl';
|
||||||
const V_CHANGE_DNS_DOMAIN_EXP = 'v_change_dns_domain_exp';
|
const V_CHANGE_DNS_DOMAIN_EXP = 'v_change_dns_domain_exp';
|
||||||
const V_CHANGE_DNS_DOMAIN_RECORD = 'v_change_dns_domain_record';
|
const V_CHANGE_DNS_DOMAIN_RECORD = 'v_change_dns_domain_record';
|
||||||
|
|
||||||
// deleting
|
|
||||||
const V_DEL_DNS_DOMAIN = 'v_del_dns_domain';
|
const V_DEL_DNS_DOMAIN = 'v_del_dns_domain';
|
||||||
const V_DEL_DNS_DOMAIN_RECORD = 'v_del_dns_domain_record';
|
const V_DEL_DNS_DOMAIN_RECORD = 'v_del_dns_domain_record';
|
||||||
|
// CRON
|
||||||
|
|
||||||
|
|
||||||
// ======================= CRON =========================
|
|
||||||
const V_LIST_CRON_JOBS = 'v_list_sys_cron';
|
const V_LIST_CRON_JOBS = 'v_list_sys_cron';
|
||||||
|
|
||||||
// adding
|
|
||||||
const V_ADD_CRON_JOB = 'v_add_sys_cron';
|
const V_ADD_CRON_JOB = 'v_add_sys_cron';
|
||||||
const V_ADD_SYS_USER_REPORTS = 'v_add_sys_user_reports';
|
const V_ADD_SYS_USER_REPORTS = 'v_add_sys_user_reports';
|
||||||
|
|
||||||
// changing
|
|
||||||
const V_CHANGE_CRON_JOB = 'v_change_sys_cron_job';
|
const V_CHANGE_CRON_JOB = 'v_change_sys_cron_job';
|
||||||
const V_SUSPEND_CRON_JOB = 'v_suspend_sys_cron_job';
|
const V_SUSPEND_CRON_JOB = 'v_suspend_sys_cron_job';
|
||||||
const V_SUSPEND_CRON_JOBS = 'v_suspend_sys_cron_jobs';
|
const V_SUSPEND_CRON_JOBS = 'v_suspend_sys_cron_jobs';
|
||||||
const V_UNSUSPEND_CRON_JOB = 'v_unsuspend_sys_cron_job';
|
const V_UNSUSPEND_CRON_JOB = 'v_unsuspend_sys_cron_job';
|
||||||
const V_UNSUSPEND_CRON_JOBS = 'v_unsuspend_sys_cron_jobs';
|
const V_UNSUSPEND_CRON_JOBS = 'v_unsuspend_sys_cron_jobs';
|
||||||
|
|
||||||
// deleting
|
|
||||||
const V_DEL_CRON_JOB = 'v_del_sys_cron';
|
const V_DEL_CRON_JOB = 'v_del_sys_cron';
|
||||||
const V_DEL_SYS_USER_REPORTS = 'v_del_sys_user_reports';
|
const V_DEL_SYS_USER_REPORTS = 'v_del_sys_user_reports';
|
||||||
|
// USER
|
||||||
|
|
||||||
|
|
||||||
// ======================= USER =========================
|
|
||||||
const V_LIST_SYS_USERS = 'v_list_sys_users';
|
const V_LIST_SYS_USERS = 'v_list_sys_users';
|
||||||
|
|
||||||
// adding
|
|
||||||
const V_ADD_SYS_USER = 'v_add_sys_user';
|
const V_ADD_SYS_USER = 'v_add_sys_user';
|
||||||
|
|
||||||
// changing
|
|
||||||
const V_CHANGE_SYS_USER_CONTACT = 'v_change_sys_user_contact';
|
const V_CHANGE_SYS_USER_CONTACT = 'v_change_sys_user_contact';
|
||||||
const V_CHANGE_SYS_USER_NS = 'v_change_sys_user_ns';
|
const V_CHANGE_SYS_USER_NS = 'v_change_sys_user_ns';
|
||||||
const V_CHANGE_SYS_USER_PACKAGE = 'v_change_sys_user_package';
|
const V_CHANGE_SYS_USER_PACKAGE = 'v_change_sys_user_package';
|
||||||
const V_CHANGE_SYS_USER_PASSWORD = 'v_change_sys_user_password';
|
const V_CHANGE_SYS_USER_PASSWORD = 'v_change_sys_user_password';
|
||||||
const V_CHANGE_SYS_USER_SHELL = 'v_change_sys_user_shell';
|
const V_CHANGE_SYS_USER_SHELL = 'v_change_sys_user_shell';
|
||||||
const V_CHANGE_SYS_USER_ROLE = 'v_change_sys_user_role';
|
const V_CHANGE_SYS_USER_ROLE = 'v_change_sys_user_role';
|
||||||
|
|
||||||
// deleting
|
|
||||||
const V_DEL_SYS_USER = 'v_del_sys_user';
|
const V_DEL_SYS_USER = 'v_del_sys_user';
|
||||||
|
// WEB_DOMAIN
|
||||||
|
|
||||||
// ======================= WEB_DOMAIN =========================
|
|
||||||
const V_LIST_WEB_DOMAINS = 'v_list_web_domains';
|
const V_LIST_WEB_DOMAINS = 'v_list_web_domains';
|
||||||
|
|
||||||
const V_LIST_WEB_DOMAINS_ALIAS = 'v_list_web_domains_alias';
|
const V_LIST_WEB_DOMAINS_ALIAS = 'v_list_web_domains_alias';
|
||||||
const V_LIST_WEB_DOMAINS_ELOG = 'v_list_web_domains_elog';
|
const V_LIST_WEB_DOMAINS_ELOG = 'v_list_web_domains_elog';
|
||||||
const V_LIST_WEB_DOMAINS_PROXY = 'v_list_web_domains_proxy';
|
const V_LIST_WEB_DOMAINS_PROXY = 'v_list_web_domains_proxy';
|
||||||
const V_LIST_WEB_DOMAINS_SSL = 'v_list_web_domains_ssl';
|
const V_LIST_WEB_DOMAINS_SSL = 'v_list_web_domains_ssl';
|
||||||
const V_LIST_WEB_DOMAINS_STATS = 'v_list_web_domains_stats';
|
const V_LIST_WEB_DOMAINS_STATS = 'v_list_web_domains_stats';
|
||||||
const V_LIST_WEB_TEMPLATES = 'v_list_web_templates';
|
const V_LIST_WEB_TEMPLATES = 'v_list_web_templates';
|
||||||
|
|
||||||
// adding
|
|
||||||
const V_ADD_WEB_DOMAIN = 'v_add_web_domain';
|
const V_ADD_WEB_DOMAIN = 'v_add_web_domain';
|
||||||
const V_ADD_WEB_DOMAIN_ALIAS = 'v_add_web_domain_alias';
|
const V_ADD_WEB_DOMAIN_ALIAS = 'v_add_web_domain_alias';
|
||||||
|
|
||||||
// changing
|
|
||||||
const V_ADD_WEB_DOMAIN_STAT = 'v_add_web_domain_stat';
|
const V_ADD_WEB_DOMAIN_STAT = 'v_add_web_domain_stat';
|
||||||
const V_ADD_WEB_DOMAIN_STAT_AUTH = 'v_add_web_domain_stat_auth';
|
const V_ADD_WEB_DOMAIN_STAT_AUTH = 'v_add_web_domain_stat_auth';
|
||||||
const V_ADD_WEB_DOMAIN_SSL = 'v_add_web_domain_ssl';
|
const V_ADD_WEB_DOMAIN_SSL = 'v_add_web_domain_ssl';
|
||||||
const V_ADD_WEB_DOMAIN_ELOG = 'v_add_web_domain_elog';
|
const V_ADD_WEB_DOMAIN_ELOG = 'v_add_web_domain_elog';
|
||||||
const V_ADD_WEB_DOMAIN_CGI = 'v_add_web_domain_cgi';
|
const V_ADD_WEB_DOMAIN_CGI = 'v_add_web_domain_cgi';
|
||||||
|
|
||||||
const V_CHANGE_WEB_DOMAIN_IP = 'v_change_web_domain_ip';
|
const V_CHANGE_WEB_DOMAIN_IP = 'v_change_web_domain_ip';
|
||||||
const V_CHANGE_WEB_DOMAIN_SSLCERT = 'v_change_web_domain_sslcert';
|
const V_CHANGE_WEB_DOMAIN_SSLCERT = 'v_change_web_domain_sslcert';
|
||||||
const V_CHANGE_WEB_DOMAIN_SSLHOME = 'v_change_web_domain_sslhome';
|
const V_CHANGE_WEB_DOMAIN_SSLHOME = 'v_change_web_domain_sslhome';
|
||||||
const V_CHANGE_WEB_DOMAIN_TPL = 'v_change_web_domain_tpl';
|
const V_CHANGE_WEB_DOMAIN_TPL = 'v_change_web_domain_tpl';
|
||||||
|
|
||||||
const V_DEL_WEB_DOMAIN_CGI = 'v_del_web_domain_cgi';
|
const V_DEL_WEB_DOMAIN_CGI = 'v_del_web_domain_cgi';
|
||||||
const V_DEL_WEB_DOMAIN_ELOG = 'v_del_web_domain_elog';
|
const V_DEL_WEB_DOMAIN_ELOG = 'v_del_web_domain_elog';
|
||||||
const V_DEL_WEB_DOMAIN_SSL = 'v_del_web_domain_ssl';
|
const V_DEL_WEB_DOMAIN_SSL = 'v_del_web_domain_ssl';
|
||||||
const V_DEL_WEB_DOMAIN_STAT = 'v_del_web_domain_stat';
|
const V_DEL_WEB_DOMAIN_STAT = 'v_del_web_domain_stat';
|
||||||
const V_DEL_WEB_DOMAIN_STAT_AUTH = 'v_del_web_domain_stat_auth';
|
const V_DEL_WEB_DOMAIN_STAT_AUTH = 'v_del_web_domain_stat_auth';
|
||||||
const V_DEL_WEB_DOMAIN_ALIAS = 'v_del_web_domain_alias';
|
const V_DEL_WEB_DOMAIN_ALIAS = 'v_del_web_domain_alias';
|
||||||
|
|
||||||
const V_SUSPEND_WEB_DOMAIN = 'v_suspend_web_domain';
|
const V_SUSPEND_WEB_DOMAIN = 'v_suspend_web_domain';
|
||||||
const V_SUSPEND_WEB_DOMAINS = 'v_suspend_web_domains';
|
const V_SUSPEND_WEB_DOMAINS = 'v_suspend_web_domains';
|
||||||
const V_UNSUSPEND_WEB_DOMAIN = 'v_unsuspend_web_domain';
|
const V_UNSUSPEND_WEB_DOMAIN = 'v_unsuspend_web_domain';
|
||||||
|
@ -124,48 +88,37 @@ class Vesta {
|
||||||
const V_UPD_WEB_DOMAINS_DISK = 'v_upd_web_domains_disk';
|
const V_UPD_WEB_DOMAINS_DISK = 'v_upd_web_domains_disk';
|
||||||
const V_UPD_WEB_DOMAIN_TRAFF = 'v_upd_web_domain_traff';
|
const V_UPD_WEB_DOMAIN_TRAFF = 'v_upd_web_domain_traff';
|
||||||
const V_UPD_WEB_DOMAINS_TRAFF = 'v_upd_web_domains_traff';
|
const V_UPD_WEB_DOMAINS_TRAFF = 'v_upd_web_domains_traff';
|
||||||
|
|
||||||
// deleting
|
|
||||||
const V_DEL_WEB_DOMAIN = 'v_del_web_domain';
|
const V_DEL_WEB_DOMAIN = 'v_del_web_domain';
|
||||||
|
// DB
|
||||||
|
|
||||||
// ======================= DB =========================
|
|
||||||
// list
|
|
||||||
const V_LIST_DB_BASES = 'v_list_db_bases';
|
const V_LIST_DB_BASES = 'v_list_db_bases';
|
||||||
const V_LIST_DB_HOSTS = 'v_list_db_hosts';
|
const V_LIST_DB_HOSTS = 'v_list_db_hosts';
|
||||||
|
|
||||||
// adding
|
|
||||||
const V_ADD_DB_BASE = 'v_add_db_base';
|
const V_ADD_DB_BASE = 'v_add_db_base';
|
||||||
const V_ADD_DB_HOST = 'v_add_db_host';
|
const V_ADD_DB_HOST = 'v_add_db_host';
|
||||||
|
|
||||||
// changing
|
|
||||||
const V_SUSPEND_DB_BASE = 'v_suspend_db_base';
|
const V_SUSPEND_DB_BASE = 'v_suspend_db_base';
|
||||||
const V_SUSPEND_DB_BASES = 'v_suspend_db_bases';
|
const V_SUSPEND_DB_BASES = 'v_suspend_db_bases';
|
||||||
const V_UNSUSPEND_DB_BASE = 'v_unsuspend_db_base';
|
const V_UNSUSPEND_DB_BASE = 'v_unsuspend_db_base';
|
||||||
const V_UNSUSPEND_DB_BASES = 'v_unsuspend_db_bases';
|
const V_UNSUSPEND_DB_BASES = 'v_unsuspend_db_bases';
|
||||||
const V_CHANGE_DB_PASSWORD = 'v_change_db_password';
|
const V_CHANGE_DB_PASSWORD = 'v_change_db_password';
|
||||||
|
|
||||||
// deleting
|
|
||||||
const V_DEL_DB_BASE = 'v_del_db_base';
|
const V_DEL_DB_BASE = 'v_del_db_base';
|
||||||
const V_DEL_DB_HOST = 'v_del_db_host';
|
const V_DEL_DB_HOST = 'v_del_db_host';
|
||||||
|
|
||||||
// service
|
|
||||||
const V_UPD_DB_BASE_DISK = 'v_upd_db_base_disk';
|
const V_UPD_DB_BASE_DISK = 'v_upd_db_base_disk';
|
||||||
const V_UPD_DB_BASES_DISK = 'v_upd_db_bases_disk';
|
const V_UPD_DB_BASES_DISK = 'v_upd_db_bases_disk';
|
||||||
|
|
||||||
|
|
||||||
// ======================================================
|
|
||||||
|
|
||||||
const PARAM_DELIMETER = ' ';
|
const PARAM_DELIMETER = ' ';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Execute vesta command
|
||||||
*
|
*
|
||||||
|
* @param string $cms_command
|
||||||
|
* @param array $parameters
|
||||||
|
* @return string
|
||||||
*/
|
*/
|
||||||
static function execute($cmd_command, $parameters=array()) {
|
static function execute($cmd_command, $parameters=array())
|
||||||
|
{
|
||||||
$r = new Request();
|
$r = new Request();
|
||||||
$debug = $r->getParameter("debug", FALSE);
|
$_DEBUG = $r->getParameter("debug", FALSE);
|
||||||
|
|
||||||
if (!isset($cmd_command)) {
|
if (!isset($cmd_command))
|
||||||
|
{
|
||||||
throw new ProtectionException('No function name passed into Vesta::execute'); // TODO: move msg to Messages::
|
throw new ProtectionException('No function name passed into Vesta::execute'); // TODO: move msg to Messages::
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -173,12 +126,11 @@ class Vesta {
|
||||||
'sudo' => Config::get('sudo_path'),
|
'sudo' => Config::get('sudo_path'),
|
||||||
'functions' => Config::get('vesta_functions_path'),
|
'functions' => Config::get('vesta_functions_path'),
|
||||||
'parameters' => implode("' '", $parameters),
|
'parameters' => implode("' '", $parameters),
|
||||||
// 'reply' => Config::get('response_type')
|
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// e.g.: /usr/bin/sudo /usr/local/vesta/bin/v_list_sys_users vesta json
|
||||||
$cmd = "{$params['sudo']} {$params['functions']}{$cmd_command} '{$params['parameters']}' {$params['reply']}";
|
$cmd = "{$params['sudo']} {$params['functions']}{$cmd_command} '{$params['parameters']}' {$params['reply']}";
|
||||||
// /usr/bin/sudo /usr/local/vesta/bin/v_list_sys_users vesta json
|
|
||||||
exec($cmd, $output, $return);
|
exec($cmd, $output, $return);
|
||||||
|
|
||||||
$result = 0;
|
$result = 0;
|
||||||
|
@ -188,14 +140,15 @@ class Vesta {
|
||||||
'error_message' => ''
|
'error_message' => ''
|
||||||
);
|
);
|
||||||
|
|
||||||
if($debug)
|
// TODO: please remove this later :)
|
||||||
|
if ($_DEBUG)
|
||||||
{
|
{
|
||||||
$result['debug'] = array(
|
$result['debug'] = array(
|
||||||
"cmd" => $cmd,
|
"cmd" => $cmd,
|
||||||
"output" => $output,
|
"output" => $output,
|
||||||
"return" => $return
|
"return" => $return
|
||||||
);
|
);
|
||||||
if($debug == 2)
|
if ($debug == 2)
|
||||||
{
|
{
|
||||||
echo '<p>'.$cmd;
|
echo '<p>'.$cmd;
|
||||||
echo '<br> output: '; print_r($output);
|
echo '<br> output: '; print_r($output);
|
||||||
|
@ -204,7 +157,7 @@ class Vesta {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!!(int)$return)
|
if (!!(int)$return)
|
||||||
{
|
{
|
||||||
$result['status'] = FALSE;
|
$result['status'] = FALSE;
|
||||||
$result['error_code'] = (int)$return;
|
$result['error_code'] = (int)$return;
|
||||||
|
|
|
@ -5,17 +5,27 @@
|
||||||
*
|
*
|
||||||
* Thrown if unexpected action or behaviour detected
|
* Thrown if unexpected action or behaviour detected
|
||||||
*
|
*
|
||||||
|
* @author Malishev Dima <dima.malishev@gmail.com>
|
||||||
* @author vesta, http://vestacp.com/
|
* @author vesta, http://vestacp.com/
|
||||||
* @copyright vesta 2010
|
* @copyright vesta 2010-2011
|
||||||
*/
|
*/
|
||||||
class ProtectionException extends Exception {
|
class ProtectionException extends Exception
|
||||||
|
{
|
||||||
const CODE_GENERAL = 0;
|
const CODE_GENERAL = 0;
|
||||||
|
|
||||||
public function __construct($message, $code=self::CODE_GENERAL, $previous=null) {
|
/**
|
||||||
|
* Protection exception
|
||||||
|
*/
|
||||||
|
public function __construct($message, $code=self::CODE_GENERAL, $previous=null)
|
||||||
|
{
|
||||||
parent::__construct($message, $code, $previous);
|
parent::__construct($message, $code, $previous);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function __toString() {
|
/**
|
||||||
|
* Renders error message
|
||||||
|
*/
|
||||||
|
public function __toString()
|
||||||
|
{
|
||||||
print $this->message;
|
print $this->message;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,8 +7,9 @@
|
||||||
* - system error occured
|
* - system error occured
|
||||||
* - unpredictable scenarios
|
* - unpredictable scenarios
|
||||||
*
|
*
|
||||||
|
* @author Malishev Dima <dima.malishev@gmail.com>
|
||||||
* @author vesta, http://vestacp.com/
|
* @author vesta, http://vestacp.com/
|
||||||
* @copyright vesta 2010
|
* @copyright vesta 2010-2011
|
||||||
*/
|
*/
|
||||||
class SystemException extends Exception {
|
class SystemException extends Exception {
|
||||||
const CODE_GENERAL = 0;
|
const CODE_GENERAL = 0;
|
||||||
|
|
|
@ -5,19 +5,22 @@
|
||||||
*
|
*
|
||||||
* Contains messages, that are used in the code.
|
* Contains messages, that are used in the code.
|
||||||
*
|
*
|
||||||
|
* @author Malishev Dima <dima.malishev@gmail.com>
|
||||||
* @author vesta, http://vestacp.com/
|
* @author vesta, http://vestacp.com/
|
||||||
* @copyright vesta 2010
|
* @copyright vesta 2010-2011
|
||||||
*/
|
*/
|
||||||
class Message {
|
class Message
|
||||||
|
{
|
||||||
|
|
||||||
|
const ERROR = 'error';
|
||||||
const REQUEST_INVALID = 'Malformed request';
|
const REQUEST_INVALID = 'Malformed request';
|
||||||
const GENERAL_ERROR = 'General protection fault';
|
|
||||||
const REQUEST_IS_NOT_POST = 'Request is not POST';
|
const REQUEST_IS_NOT_POST = 'Request is not POST';
|
||||||
|
const GENERAL_ERROR = 'General protection fault';
|
||||||
const METHOD_NOT_EXIST = 'Message not exist';
|
const METHOD_NOT_EXIST = 'Message not exist';
|
||||||
const INVALID_METHOD = 'Method Invalid';
|
const INVALID_METHOD = 'Method Invalid';
|
||||||
const SYSTEM_ERROR = 'System Error';
|
const SYSTEM_ERROR = 'System Error';
|
||||||
const PROTECTION_ERROR = 'Protection error';
|
const PROTECTION_ERROR = 'Protection error';
|
||||||
|
|
||||||
const ERROR = 'error';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
47
web/vesta/core/utils/error_logger.php
Normal file
47
web/vesta/core/utils/error_logger.php
Normal file
|
@ -0,0 +1,47 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
function error_dumper($errno, $errstr, $errfile, $errline)
|
||||||
|
{
|
||||||
|
if (!(error_reporting() & $errno)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$log = fopen('/tmp/vesta.php.log', 'a+');
|
||||||
|
|
||||||
|
switch ($errno) {
|
||||||
|
case E_USER_ERROR:
|
||||||
|
$o = "ERROR: [$errno] $errstr\n";
|
||||||
|
$o.= " Fatal error on line $errline in file $errfile";
|
||||||
|
$o.= ", PHP " . PHP_VERSION . " (" . PHP_OS . ")\n";
|
||||||
|
$o.= "Aborting...\n";
|
||||||
|
fwrite($log, $o);
|
||||||
|
fclose($log);
|
||||||
|
exit(1);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case E_USER_WARNING:
|
||||||
|
$o = "WARNING: [$errno] $errstr\n";
|
||||||
|
fwrite($log, $o);
|
||||||
|
fclose($log);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case E_USER_NOTICE:
|
||||||
|
$o = "NOTICE: [$errno] $errstr\n";
|
||||||
|
fwrite($log, $o);
|
||||||
|
fclose($log);
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
$o = "Unknown error type: [$errno] $errstr\n";
|
||||||
|
fwrite($log, $o);
|
||||||
|
fclose($log);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Don't execute PHP internal error handler */
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
set_error_handler('error_dumper');
|
||||||
|
|
||||||
|
?>
|
Loading…
Add table
Add a link
Reference in a new issue