simplified and wrapped internal api calls
Signed-off-by: Michael Kaufmann (d00p) <d00p@froxlor.org>
This commit is contained in:
@@ -331,36 +331,6 @@ abstract class ApiCommand
|
|||||||
return $param_value;
|
return $param_value;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* returns "module::function()" for better error-messages (missing parameter etc.)
|
|
||||||
* makes debugging a whole lot more comfortable
|
|
||||||
*
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
private function getModFunctionString()
|
|
||||||
{
|
|
||||||
$_class = get_called_class();
|
|
||||||
|
|
||||||
$level = 2;
|
|
||||||
if (version_compare(PHP_VERSION, "5.4.0", "<")) {
|
|
||||||
$trace = debug_backtrace();
|
|
||||||
} else {
|
|
||||||
$trace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
|
|
||||||
}
|
|
||||||
while (true) {
|
|
||||||
$class = $trace[$level]['class'];
|
|
||||||
$func = $trace[$level]['function'];
|
|
||||||
if ($class != $_class) {
|
|
||||||
$level ++;
|
|
||||||
if ($level > 5) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
return $class . ':' . $func;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* update value of parameter
|
* update value of parameter
|
||||||
*
|
*
|
||||||
@@ -399,6 +369,24 @@ abstract class ApiCommand
|
|||||||
return $this->mail;
|
return $this->mail;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* call an api-command internally
|
||||||
|
*
|
||||||
|
* @param string $module
|
||||||
|
* @param string $function
|
||||||
|
* @param array|null $params
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
protected function apiCall($command = null, $params = null)
|
||||||
|
{
|
||||||
|
$_command = explode(".", $command);
|
||||||
|
$module = $_command[0];
|
||||||
|
$function = $_command[1];
|
||||||
|
$json_result = $module::getLocal($this->getUserData(), $params)->{$function}();
|
||||||
|
return json_decode($json_result, true)['data'];
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* return api-compatible response in JSON format and send corresponding http-header
|
* return api-compatible response in JSON format and send corresponding http-header
|
||||||
*
|
*
|
||||||
@@ -448,6 +436,35 @@ abstract class ApiCommand
|
|||||||
), true, true);
|
), true, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* returns "module::function()" for better error-messages (missing parameter etc.)
|
||||||
|
* makes debugging a whole lot more comfortable
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
private function getModFunctionString()
|
||||||
|
{
|
||||||
|
$_class = get_called_class();
|
||||||
|
$level = 2;
|
||||||
|
if (version_compare(PHP_VERSION, "5.4.0", "<")) {
|
||||||
|
$trace = debug_backtrace();
|
||||||
|
} else {
|
||||||
|
$trace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
|
||||||
|
}
|
||||||
|
while (true) {
|
||||||
|
$class = $trace[$level]['class'];
|
||||||
|
$func = $trace[$level]['function'];
|
||||||
|
if ($class != $_class) {
|
||||||
|
$level ++;
|
||||||
|
if ($level > 5) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
return $class . ':' . $func;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* read user data from database by api-request-header fields
|
* read user data from database by api-request-header fields
|
||||||
*
|
*
|
||||||
@@ -490,6 +507,13 @@ abstract class ApiCommand
|
|||||||
throw new Exception("Invalid API credentials", 400);
|
throw new Exception("Invalid API credentials", 400);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* run 'trim' function on an array recursively
|
||||||
|
*
|
||||||
|
* @param array $input
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
private function trimArray($input)
|
private function trimArray($input)
|
||||||
{
|
{
|
||||||
if (! is_array($input)) {
|
if (! is_array($input)) {
|
||||||
|
|||||||
@@ -285,10 +285,9 @@ class Admins extends ApiCommand implements ResourceEntity
|
|||||||
$this->logger()->logAction(ADM_ACTION, LOG_WARNING, "[API] added admin '" . $loginname . "'");
|
$this->logger()->logAction(ADM_ACTION, LOG_WARNING, "[API] added admin '" . $loginname . "'");
|
||||||
|
|
||||||
// get all admin-data for return-array
|
// get all admin-data for return-array
|
||||||
$json_result = Admins::getLocal($this->getUserData(), array(
|
$result = $this->apiCall('Admins.get', array(
|
||||||
'id' => $adminid
|
'id' => $adminid
|
||||||
))->get();
|
));
|
||||||
$result = json_decode($json_result, true)['data'];
|
|
||||||
return $this->response(200, "successfull", $result);
|
return $this->response(200, "successfull", $result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -314,12 +313,11 @@ class Admins extends ApiCommand implements ResourceEntity
|
|||||||
$id = $this->getParam('id', true, 0);
|
$id = $this->getParam('id', true, 0);
|
||||||
$ln_optional = ($id <= 0 ? false : true);
|
$ln_optional = ($id <= 0 ? false : true);
|
||||||
$loginname = $this->getParam('loginname', $ln_optional, '');
|
$loginname = $this->getParam('loginname', $ln_optional, '');
|
||||||
|
|
||||||
$json_result = Admins::getLocal($this->getUserData(), array(
|
$result = $this->apiCall('Admins.get', array(
|
||||||
'id' => $id,
|
'id' => $id,
|
||||||
'loginname' => $loginname
|
'loginname' => $loginname
|
||||||
))->get();
|
));
|
||||||
$result = json_decode($json_result, true)['data'];
|
|
||||||
$id = $result['adminid'];
|
$id = $result['adminid'];
|
||||||
|
|
||||||
if ($this->getUserDetail('change_serversettings') == 1 || $result['adminid'] == $this->getUserDetail('adminid')) {
|
if ($this->getUserDetail('change_serversettings') == 1 || $result['adminid'] == $this->getUserDetail('adminid')) {
|
||||||
@@ -553,10 +551,9 @@ class Admins extends ApiCommand implements ResourceEntity
|
|||||||
$this->logger()->logAction(ADM_ACTION, LOG_INFO, "[API] edited admin '" . $result['loginname'] . "'");
|
$this->logger()->logAction(ADM_ACTION, LOG_INFO, "[API] edited admin '" . $result['loginname'] . "'");
|
||||||
|
|
||||||
// get all admin-data for return-array
|
// get all admin-data for return-array
|
||||||
$json_result = Admins::getLocal($this->getUserData(), array(
|
$result = $this->apiCall('Admins.get', array(
|
||||||
'id' => $result['adminid']
|
'id' => $result['adminid']
|
||||||
))->get();
|
));
|
||||||
$result = json_decode($json_result, true)['data'];
|
|
||||||
return $this->response(200, "successfull", $result);
|
return $this->response(200, "successfull", $result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -582,12 +579,11 @@ class Admins extends ApiCommand implements ResourceEntity
|
|||||||
$id = $this->getParam('id', true, 0);
|
$id = $this->getParam('id', true, 0);
|
||||||
$ln_optional = ($id <= 0 ? false : true);
|
$ln_optional = ($id <= 0 ? false : true);
|
||||||
$loginname = $this->getParam('loginname', $ln_optional, '');
|
$loginname = $this->getParam('loginname', $ln_optional, '');
|
||||||
|
|
||||||
$json_result = Admins::getLocal($this->getUserData(), array(
|
$result = $this->apiCall('Admins.get', array(
|
||||||
'id' => $id,
|
'id' => $id,
|
||||||
'loginname' => $loginname
|
'loginname' => $loginname
|
||||||
))->get();
|
));
|
||||||
$result = json_decode($json_result, true)['data'];
|
|
||||||
$id = $result['adminid'];
|
$id = $result['adminid'];
|
||||||
|
|
||||||
// don't be stupid
|
// don't be stupid
|
||||||
@@ -684,11 +680,10 @@ class Admins extends ApiCommand implements ResourceEntity
|
|||||||
$ln_optional = ($id <= 0 ? false : true);
|
$ln_optional = ($id <= 0 ? false : true);
|
||||||
$loginname = $this->getParam('loginname', $ln_optional, '');
|
$loginname = $this->getParam('loginname', $ln_optional, '');
|
||||||
|
|
||||||
$json_result = Admins::getLocal($this->getUserData(), array(
|
$result = $this->apiCall('Admins.get', array(
|
||||||
'id' => $id,
|
'id' => $id,
|
||||||
'loginname' => $loginname
|
'loginname' => $loginname
|
||||||
))->get();
|
));
|
||||||
$result = json_decode($json_result, true)['data'];
|
|
||||||
$id = $result['adminid'];
|
$id = $result['adminid'];
|
||||||
|
|
||||||
$result_stmt = Database::prepare("
|
$result_stmt = Database::prepare("
|
||||||
|
|||||||
@@ -536,8 +536,8 @@ class Customers extends ApiCommand implements ResourceEntity
|
|||||||
);
|
);
|
||||||
$domainid = - 1;
|
$domainid = - 1;
|
||||||
try {
|
try {
|
||||||
$std_domain = Domains::getLocal($this->getUserData(), $ins_data)->add();
|
$std_domain = $this->apiCall('Domains.add', $ins_data);
|
||||||
$domainid = json_decode($std_domain, true)['data']['id'];
|
$domainid = $std_domain['id'];
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
$this->logger()->logAction(ADM_ACTION, LOG_ERR, "[API] Unable to add standard-subdomain: " . $e->getMessage());
|
$this->logger()->logAction(ADM_ACTION, LOG_ERR, "[API] Unable to add standard-subdomain: " . $e->getMessage());
|
||||||
}
|
}
|
||||||
@@ -638,10 +638,9 @@ class Customers extends ApiCommand implements ResourceEntity
|
|||||||
}
|
}
|
||||||
$this->logger()->logAction(ADM_ACTION, LOG_WARNING, "[API] added customer '" . $loginname . "'");
|
$this->logger()->logAction(ADM_ACTION, LOG_WARNING, "[API] added customer '" . $loginname . "'");
|
||||||
|
|
||||||
$json_result = Customers::getLocal($this->getUserData(), array(
|
$result = $this->apiCall('Customers.get', array(
|
||||||
'loginname' => $loginname
|
'loginname' => $loginname
|
||||||
))->get();
|
));
|
||||||
$result = json_decode($json_result, true)['data'];
|
|
||||||
return $this->response(200, "successfull", $result);
|
return $this->response(200, "successfull", $result);
|
||||||
}
|
}
|
||||||
throw new Exception("No more resources available", 406);
|
throw new Exception("No more resources available", 406);
|
||||||
@@ -666,12 +665,11 @@ class Customers extends ApiCommand implements ResourceEntity
|
|||||||
$id = $this->getParam('id', true, 0);
|
$id = $this->getParam('id', true, 0);
|
||||||
$ln_optional = ($id <= 0 ? false : true);
|
$ln_optional = ($id <= 0 ? false : true);
|
||||||
$loginname = $this->getParam('loginname', $ln_optional, '');
|
$loginname = $this->getParam('loginname', $ln_optional, '');
|
||||||
|
|
||||||
$json_result = Customers::getLocal($this->getUserData(), array(
|
$result = $this->apiCall('Customers.get', array(
|
||||||
'id' => $id,
|
'id' => $id,
|
||||||
'loginname' => $loginname
|
'loginname' => $loginname
|
||||||
))->get();
|
));
|
||||||
$result = json_decode($json_result, true)['data'];
|
|
||||||
$id = $result['customerid'];
|
$id = $result['customerid'];
|
||||||
|
|
||||||
if ($this->isAdmin()) {
|
if ($this->isAdmin()) {
|
||||||
@@ -802,8 +800,8 @@ class Customers extends ApiCommand implements ResourceEntity
|
|||||||
);
|
);
|
||||||
$domainid = - 1;
|
$domainid = - 1;
|
||||||
try {
|
try {
|
||||||
$std_domain = Domains::getLocal($this->getUserData(), $ins_data)->add();
|
$std_domain = $this->apiCall('Domains.add', $ins_data);
|
||||||
$domainid = json_decode($std_domain, true)['data']['id'];
|
$domainid = $std_domain['id'];
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
$this->logger()->logAction(ADM_ACTION, LOG_ERR, "[API] Unable to add standard-subdomain: " . $e->getMessage());
|
$this->logger()->logAction(ADM_ACTION, LOG_ERR, "[API] Unable to add standard-subdomain: " . $e->getMessage());
|
||||||
}
|
}
|
||||||
@@ -823,10 +821,10 @@ class Customers extends ApiCommand implements ResourceEntity
|
|||||||
|
|
||||||
if ($createstdsubdomain == '0' && $result['standardsubdomain'] != '0') {
|
if ($createstdsubdomain == '0' && $result['standardsubdomain'] != '0') {
|
||||||
try {
|
try {
|
||||||
$std_domain = Domains::getLocal($this->getUserData(), array(
|
$std_domain = $this->apiCall('Domains.delete', array(
|
||||||
'id' => $result['standardsubdomain'],
|
'id' => $result['standardsubdomain'],
|
||||||
'is_stdsubdomain' => 1
|
'is_stdsubdomain' => 1
|
||||||
))->delete();
|
));
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
$this->logger()->logAction(ADM_ACTION, LOG_ERR, "[API] Unable to delete standard-subdomain: " . $e->getMessage());
|
$this->logger()->logAction(ADM_ACTION, LOG_ERR, "[API] Unable to delete standard-subdomain: " . $e->getMessage());
|
||||||
}
|
}
|
||||||
@@ -1157,21 +1155,19 @@ class Customers extends ApiCommand implements ResourceEntity
|
|||||||
*/
|
*/
|
||||||
if ($this->isAdmin()) {
|
if ($this->isAdmin()) {
|
||||||
if ($move_to_admin > 0 && $move_to_admin != $result['adminid']) {
|
if ($move_to_admin > 0 && $move_to_admin != $result['adminid']) {
|
||||||
$json_result = Customers::getLocal($this->getUserData(), array(
|
$move_result = $this->apiCall('Customers.move', array(
|
||||||
'id' => $result['customerid'],
|
'id' => $result['customerid'],
|
||||||
'adminid' => $move_to_admin
|
'adminid' => $move_to_admin
|
||||||
))->move();
|
));
|
||||||
$move_result = json_decode($json_result, true)['data'];
|
|
||||||
if ($move_result != true) {
|
if ($move_result != true) {
|
||||||
standard_error('moveofcustomerfailed', $move_result, true);
|
standard_error('moveofcustomerfailed', $move_result, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$json_result = Customers::getLocal($this->getUserData(), array(
|
$result = $this->apiCall('Customers.get', array(
|
||||||
'id' => $result['customerid']
|
'id' => $result['customerid']
|
||||||
))->get();
|
));
|
||||||
$result = json_decode($json_result, true)['data'];
|
|
||||||
return $this->response(200, "successfull", $result);
|
return $this->response(200, "successfull", $result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1196,12 +1192,11 @@ class Customers extends ApiCommand implements ResourceEntity
|
|||||||
$ln_optional = ($id <= 0 ? false : true);
|
$ln_optional = ($id <= 0 ? false : true);
|
||||||
$loginname = $this->getParam('loginname', $ln_optional, '');
|
$loginname = $this->getParam('loginname', $ln_optional, '');
|
||||||
$delete_userfiles = $this->getParam('delete_userfiles', true, 0);
|
$delete_userfiles = $this->getParam('delete_userfiles', true, 0);
|
||||||
|
|
||||||
$json_result = Customers::getLocal($this->getUserData(), array(
|
$result = $this->apiCall('Customers.get', array(
|
||||||
'id' => $id,
|
'id' => $id,
|
||||||
'loginname' => $loginname
|
'loginname' => $loginname
|
||||||
))->get();
|
));
|
||||||
$result = json_decode($json_result, true)['data'];
|
|
||||||
$id = $result['customerid'];
|
$id = $result['customerid'];
|
||||||
|
|
||||||
// @fixme use Databases-ApiCommand later
|
// @fixme use Databases-ApiCommand later
|
||||||
@@ -1443,12 +1438,11 @@ class Customers extends ApiCommand implements ResourceEntity
|
|||||||
$id = $this->getParam('id', true, 0);
|
$id = $this->getParam('id', true, 0);
|
||||||
$ln_optional = ($id <= 0 ? false : true);
|
$ln_optional = ($id <= 0 ? false : true);
|
||||||
$loginname = $this->getParam('loginname', $ln_optional, '');
|
$loginname = $this->getParam('loginname', $ln_optional, '');
|
||||||
|
|
||||||
$json_result = Customers::getLocal($this->getUserData(), array(
|
$result = $this->apiCall('Customers.get', array(
|
||||||
'id' => $id,
|
'id' => $id,
|
||||||
'loginname' => $loginname
|
'loginname' => $loginname
|
||||||
))->get();
|
));
|
||||||
$result = json_decode($json_result, true)['data'];
|
|
||||||
$id = $result['customerid'];
|
$id = $result['customerid'];
|
||||||
|
|
||||||
$result_stmt = Database::prepare("
|
$result_stmt = Database::prepare("
|
||||||
@@ -1488,12 +1482,11 @@ class Customers extends ApiCommand implements ResourceEntity
|
|||||||
$id = $this->getParam('id', true, 0);
|
$id = $this->getParam('id', true, 0);
|
||||||
$ln_optional = ($id <= 0 ? false : true);
|
$ln_optional = ($id <= 0 ? false : true);
|
||||||
$loginname = $this->getParam('loginname', $ln_optional, '');
|
$loginname = $this->getParam('loginname', $ln_optional, '');
|
||||||
|
|
||||||
$json_result = Customers::getLocal($this->getUserData(), array(
|
$c_result = $this->apiCall('Customers.get', array(
|
||||||
'id' => $id,
|
'id' => $id,
|
||||||
'loginname' => $loginname
|
'loginname' => $loginname
|
||||||
))->get();
|
));
|
||||||
$c_result = json_decode($json_result, true)['data'];
|
|
||||||
$id = $c_result['customerid'];
|
$id = $c_result['customerid'];
|
||||||
|
|
||||||
// check if target-admin is the current admin
|
// check if target-admin is the current admin
|
||||||
@@ -1502,10 +1495,9 @@ class Customers extends ApiCommand implements ResourceEntity
|
|||||||
}
|
}
|
||||||
|
|
||||||
// get target admin
|
// get target admin
|
||||||
$json_result = Admins::getLocal($this->getUserData(), array(
|
$a_result = $this->apiCall('Admins.get', array(
|
||||||
'id' => $adminid
|
'id' => $adminid
|
||||||
))->get();
|
));
|
||||||
$a_result = json_decode($json_result, true)['data'];
|
|
||||||
|
|
||||||
// Update customer entry
|
// Update customer entry
|
||||||
$updCustomer_stmt = Database::prepare("
|
$updCustomer_stmt = Database::prepare("
|
||||||
@@ -1538,10 +1530,10 @@ class Customers extends ApiCommand implements ResourceEntity
|
|||||||
updateCounters(false);
|
updateCounters(false);
|
||||||
|
|
||||||
$this->logger()->logAction(ADM_ACTION, LOG_INFO, "[API] moved user '" . $c_result['loginname'] . "' from admin/reseller '" . $c_result['adminname'] . " to admin/reseller '" . $a_result['loginname'] . "'");
|
$this->logger()->logAction(ADM_ACTION, LOG_INFO, "[API] moved user '" . $c_result['loginname'] . "' from admin/reseller '" . $c_result['adminname'] . " to admin/reseller '" . $a_result['loginname'] . "'");
|
||||||
$json_result = Customers::getLocal($this->getUserData(), array(
|
|
||||||
|
$result = $this->apiCall('Customers.get', array(
|
||||||
'id' => $c_result['customerid']
|
'id' => $c_result['customerid']
|
||||||
))->get();
|
));
|
||||||
$result = json_decode($json_result, true)['data'];
|
|
||||||
return $this->response(200, "successfull", $result);
|
return $this->response(200, "successfull", $result);
|
||||||
}
|
}
|
||||||
throw new Exception("Not allowed to execute given command.", 403);
|
throw new Exception("Not allowed to execute given command.", 403);
|
||||||
|
|||||||
@@ -178,10 +178,9 @@ class Domains extends ApiCommand implements ResourceEntity
|
|||||||
), '', true);
|
), '', true);
|
||||||
}
|
}
|
||||||
|
|
||||||
$json_result = Customers::getLocal($this->getUserData(), array(
|
$customer = $this->apiCall('Customers.get', array(
|
||||||
'id' => $customerid
|
'id' => $customerid
|
||||||
))->get();
|
));
|
||||||
$customer = json_decode($json_result, true)['data'];
|
|
||||||
|
|
||||||
if ($this->getUserDetail('customers_see_all') == '1') {
|
if ($this->getUserDetail('customers_see_all') == '1') {
|
||||||
$admin_stmt = Database::prepare("
|
$admin_stmt = Database::prepare("
|
||||||
@@ -743,10 +742,9 @@ class Domains extends ApiCommand implements ResourceEntity
|
|||||||
|
|
||||||
$this->logger()->logAction(ADM_ACTION, LOG_WARNING, "[API] added domain '" . $domain . "'");
|
$this->logger()->logAction(ADM_ACTION, LOG_WARNING, "[API] added domain '" . $domain . "'");
|
||||||
|
|
||||||
$json_result = Domains::getLocal($this->getUserData(), array(
|
$result = $this->apiCall('Domains.get', array(
|
||||||
'domainname' => $domain
|
'domainname' => $domain
|
||||||
))->get();
|
));
|
||||||
$result = json_decode($json_result, true)['data'];
|
|
||||||
return $this->response(200, "successfull", $result);
|
return $this->response(200, "successfull", $result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -777,12 +775,11 @@ class Domains extends ApiCommand implements ResourceEntity
|
|||||||
$domainname = $this->getParam('domainname', $dn_optional, '');
|
$domainname = $this->getParam('domainname', $dn_optional, '');
|
||||||
|
|
||||||
// get requested domain
|
// get requested domain
|
||||||
$json_result = Domains::getLocal($this->getUserData(), array(
|
$result = $this->apiCall('Domains.get', array(
|
||||||
'id' => $id,
|
'id' => $id,
|
||||||
'domainname' => $domainname,
|
'domainname' => $domainname,
|
||||||
'no_std_subdomain' => true
|
'no_std_subdomain' => true
|
||||||
))->get();
|
));
|
||||||
$result = json_decode($json_result, true)['data'];
|
|
||||||
$id = $result['id'];
|
$id = $result['id'];
|
||||||
|
|
||||||
// optional parameters
|
// optional parameters
|
||||||
@@ -877,8 +874,7 @@ class Domains extends ApiCommand implements ResourceEntity
|
|||||||
AND (`subdomains_used` + :subdomains <= `subdomains` OR `subdomains` = '-1' )
|
AND (`subdomains_used` + :subdomains <= `subdomains` OR `subdomains` = '-1' )
|
||||||
AND (`emails_used` + :emails <= `emails` OR `emails` = '-1' )
|
AND (`emails_used` + :emails <= `emails` OR `emails` = '-1' )
|
||||||
AND (`email_forwarders_used` + :forwarders <= `email_forwarders` OR `email_forwarders` = '-1' )
|
AND (`email_forwarders_used` + :forwarders <= `email_forwarders` OR `email_forwarders` = '-1' )
|
||||||
AND (`email_accounts_used` + :accounts <= `email_accounts` OR `email_accounts` = '-1' ) " . ($this->getUserDetail('customers_see_all') ? '' : " AND `adminid` = :adminid")
|
AND (`email_accounts_used` + :accounts <= `email_accounts` OR `email_accounts` = '-1' ) " . ($this->getUserDetail('customers_see_all') ? '' : " AND `adminid` = :adminid"));
|
||||||
);
|
|
||||||
$params = array(
|
$params = array(
|
||||||
'customerid' => $customerid,
|
'customerid' => $customerid,
|
||||||
'subdomains' => $subdomains,
|
'subdomains' => $subdomains,
|
||||||
@@ -897,10 +893,9 @@ class Domains extends ApiCommand implements ResourceEntity
|
|||||||
$customerid = $result['customerid'];
|
$customerid = $result['customerid'];
|
||||||
|
|
||||||
// get customer
|
// get customer
|
||||||
$json_result = Customers::getLocal($this->getUserData(), array(
|
$customer = $this->apiCall('Customers.get', array(
|
||||||
'id' => $customerid
|
'id' => $customerid
|
||||||
))->get();
|
));
|
||||||
$customer = json_decode($json_result, true)['data'];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// handle change of admin (move domain from admin to admin)
|
// handle change of admin (move domain from admin to admin)
|
||||||
@@ -1664,11 +1659,10 @@ class Domains extends ApiCommand implements ResourceEntity
|
|||||||
$is_stdsubdomain = $this->getParam('is_stdsubdomain', true, 0);
|
$is_stdsubdomain = $this->getParam('is_stdsubdomain', true, 0);
|
||||||
$remove_subbutmain_domains = $this->getParam('delete_mainsubdomains', true, 0);
|
$remove_subbutmain_domains = $this->getParam('delete_mainsubdomains', true, 0);
|
||||||
|
|
||||||
$json_result = Domains::getLocal($this->getUserData(), array(
|
$result = $this->apiCall('Domains.get', array(
|
||||||
'id' => $id,
|
'id' => $id,
|
||||||
'domainname' => $domainname
|
'domainname' => $domainname
|
||||||
))->get();
|
));
|
||||||
$result = json_decode($json_result, true)['data'];
|
|
||||||
$id = $result['id'];
|
$id = $result['id'];
|
||||||
|
|
||||||
// check for deletion of main-domains which are logically subdomains, #329
|
// check for deletion of main-domains which are logically subdomains, #329
|
||||||
|
|||||||
@@ -192,11 +192,10 @@ class FpmDaemons extends ApiCommand implements ResourceEntity
|
|||||||
|
|
||||||
// required parameter
|
// required parameter
|
||||||
$id = $this->getParam('id');
|
$id = $this->getParam('id');
|
||||||
|
|
||||||
$json_result = PhpSettings::getLocal($this->getUserData(), array(
|
$result = $this->apiCall('PhpSettings.get', array(
|
||||||
'id' => $id
|
'id' => $id
|
||||||
))->get();
|
));
|
||||||
$result = json_decode($json_result, true)['data'];
|
|
||||||
|
|
||||||
// parameters
|
// parameters
|
||||||
$description = $this->getParam('description', true, $result['description']);
|
$description = $this->getParam('description', true, $result['description']);
|
||||||
@@ -283,11 +282,10 @@ class FpmDaemons extends ApiCommand implements ResourceEntity
|
|||||||
if ($id == 1) {
|
if ($id == 1) {
|
||||||
standard_error('cannotdeletedefaultphpconfig', '', true);
|
standard_error('cannotdeletedefaultphpconfig', '', true);
|
||||||
}
|
}
|
||||||
|
|
||||||
$json_result = FpmDaemons::getLocal($this->getUserData(), array(
|
$result = $this->apiCall('FpmDaemons.get', array(
|
||||||
'id' => $id
|
'id' => $id
|
||||||
))->get();
|
));
|
||||||
$result = json_decode($json_result, true)['data'];
|
|
||||||
|
|
||||||
// set default fpm daemon config for all php-config that use this config that is to be deleted
|
// set default fpm daemon config for all php-config that use this config that is to be deleted
|
||||||
$upd_stmt = Database::prepare("
|
$upd_stmt = Database::prepare("
|
||||||
|
|||||||
@@ -84,10 +84,9 @@ class Ftps extends ApiCommand implements ResourceEntity
|
|||||||
if ($this->isAdmin()) {
|
if ($this->isAdmin()) {
|
||||||
// get customer id
|
// get customer id
|
||||||
$customer_id = $this->getParam('customer_id');
|
$customer_id = $this->getParam('customer_id');
|
||||||
$json_result = Customers::getLocal($this->getUserData(), array(
|
$customer = $this->apiCall('Customers.get', array(
|
||||||
'id' => $customer_id
|
'id' => $customer_id
|
||||||
))->get();
|
));
|
||||||
$customer = json_decode($json_result, true)['data'];
|
|
||||||
// check whether the customer has enough resources to get the ftp-user added
|
// check whether the customer has enough resources to get the ftp-user added
|
||||||
if ($customer['ftps_used'] >= $customer['ftps'] && $customer['ftps'] != '-1') {
|
if ($customer['ftps_used'] >= $customer['ftps'] && $customer['ftps'] != '-1') {
|
||||||
throw new Exception("Customer has no more resources available", 406);
|
throw new Exception("Customer has no more resources available", 406);
|
||||||
@@ -254,11 +253,10 @@ class Ftps extends ApiCommand implements ResourceEntity
|
|||||||
$this->mailer()->ClearAddresses();
|
$this->mailer()->ClearAddresses();
|
||||||
}
|
}
|
||||||
$this->logger()->logAction($this->isAdmin() ? ADM_ACTION : USR_ACTION, LOG_WARNING, "[API] added ftp-user '" . $username . "'");
|
$this->logger()->logAction($this->isAdmin() ? ADM_ACTION : USR_ACTION, LOG_WARNING, "[API] added ftp-user '" . $username . "'");
|
||||||
|
|
||||||
$json_result = Ftps::getLocal($this->getUserData(), array(
|
$result = $this->apiCall('Ftps.get', array(
|
||||||
'username' => $username
|
'username' => $username
|
||||||
))->get();
|
));
|
||||||
$result = json_decode($json_result, true)['data'];
|
|
||||||
return $this->response(200, "successfull", $result);
|
return $this->response(200, "successfull", $result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -288,8 +286,8 @@ class Ftps extends ApiCommand implements ResourceEntity
|
|||||||
if ($this->getUserDetail('customers_see_all') == false) {
|
if ($this->getUserDetail('customers_see_all') == false) {
|
||||||
// if it's a reseller or an admin who cannot see all customers, we need to check
|
// if it's a reseller or an admin who cannot see all customers, we need to check
|
||||||
// whether the database belongs to one of his customers
|
// whether the database belongs to one of his customers
|
||||||
$json_result = Customers::getLocal($this->getUserData())->listing();
|
$_custom_list_result = $this->apiCall('Customers.listing');
|
||||||
$custom_list_result = json_decode($json_result, true)['data']['list'];
|
$custom_list_result = $_custom_list_result['list'];
|
||||||
$customer_ids = array();
|
$customer_ids = array();
|
||||||
foreach ($custom_list_result as $customer) {
|
foreach ($custom_list_result as $customer) {
|
||||||
$customer_ids[] = $customer['customerid'];
|
$customer_ids[] = $customer['customerid'];
|
||||||
@@ -336,12 +334,11 @@ class Ftps extends ApiCommand implements ResourceEntity
|
|||||||
$id = $this->getParam('id', true, 0);
|
$id = $this->getParam('id', true, 0);
|
||||||
$un_optional = ($id <= 0 ? false : true);
|
$un_optional = ($id <= 0 ? false : true);
|
||||||
$username = $this->getParam('username', $un_optional, '');
|
$username = $this->getParam('username', $un_optional, '');
|
||||||
|
|
||||||
$json_result = Ftps::getLocal($this->getUserData(), array(
|
$result = $this->apiCall('Ftps.get', array(
|
||||||
'id' => $id,
|
'id' => $id,
|
||||||
'username' => $username
|
'username' => $username
|
||||||
))->get();
|
));
|
||||||
$result = json_decode($json_result, true)['data'];
|
|
||||||
$id = $result['id'];
|
$id = $result['id'];
|
||||||
|
|
||||||
// parameters
|
// parameters
|
||||||
@@ -364,10 +361,9 @@ class Ftps extends ApiCommand implements ResourceEntity
|
|||||||
if ($this->isAdmin()) {
|
if ($this->isAdmin()) {
|
||||||
// get customer id
|
// get customer id
|
||||||
$customer_id = $this->getParam('customer_id');
|
$customer_id = $this->getParam('customer_id');
|
||||||
$json_result = Customers::getLocal($this->getUserData(), array(
|
$customer = $this->apiCall('Customers.get', array(
|
||||||
'id' => $customer_id
|
'id' => $customer_id
|
||||||
))->get();
|
));
|
||||||
$customer = json_decode($json_result, true)['data'];
|
|
||||||
} else {
|
} else {
|
||||||
$customer_id = $this->getUserDetail('customerid');
|
$customer_id = $this->getUserDetail('customerid');
|
||||||
$customer = $this->getUserData();
|
$customer = $this->getUserData();
|
||||||
@@ -430,11 +426,10 @@ class Ftps extends ApiCommand implements ResourceEntity
|
|||||||
"customerid" => $customer['customerid'],
|
"customerid" => $customer['customerid'],
|
||||||
"id" => $id
|
"id" => $id
|
||||||
), true, true);
|
), true, true);
|
||||||
|
|
||||||
$json_result = Ftps::getLocal($this->getUserData(), array(
|
$result = $this->apiCall('Ftps.get', array(
|
||||||
'username' => $result['username']
|
'username' => $result['username']
|
||||||
))->get();
|
));
|
||||||
$result = json_decode($json_result, true)['data'];
|
|
||||||
$this->logger()->logAction($this->isAdmin() ? ADM_ACTION : USR_ACTION, LOG_NOTICE, "[API] updated ftp-user '" . $result['username'] . "'");
|
$this->logger()->logAction($this->isAdmin() ? ADM_ACTION : USR_ACTION, LOG_NOTICE, "[API] updated ftp-user '" . $result['username'] . "'");
|
||||||
return $this->response(200, "successfull", $result);
|
return $this->response(200, "successfull", $result);
|
||||||
}
|
}
|
||||||
@@ -460,16 +455,16 @@ class Ftps extends ApiCommand implements ResourceEntity
|
|||||||
$loginname = $this->getParam('loginname', true, '');
|
$loginname = $this->getParam('loginname', true, '');
|
||||||
|
|
||||||
if (! empty($customerid) || ! empty($loginname)) {
|
if (! empty($customerid) || ! empty($loginname)) {
|
||||||
$json_result = Customers::getLocal($this->getUserData(), array(
|
$_result = $this->apiCall('Customers.get', array(
|
||||||
'id' => $customerid,
|
'id' => $customerid,
|
||||||
'loginname' => $loginname
|
'loginname' => $loginname
|
||||||
))->get();
|
));
|
||||||
$custom_list_result = array(
|
$custom_list_result = array(
|
||||||
json_decode($json_result, true)['data']
|
$_result
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
$json_result = Customers::getLocal($this->getUserData())->listing();
|
$_custom_list_result = $this->apiCall('Customers.listing');
|
||||||
$custom_list_result = json_decode($json_result, true)['data']['list'];
|
$custom_list_result = $_custom_list_result['list'];
|
||||||
}
|
}
|
||||||
$customer_ids = array();
|
$customer_ids = array();
|
||||||
foreach ($custom_list_result as $customer) {
|
foreach ($custom_list_result as $customer) {
|
||||||
@@ -526,19 +521,17 @@ class Ftps extends ApiCommand implements ResourceEntity
|
|||||||
}
|
}
|
||||||
|
|
||||||
// get ftp-user
|
// get ftp-user
|
||||||
$json_result = Ftps::getLocal($this->getUserData(), array(
|
$result = $this->apiCall('Ftps.get', array(
|
||||||
'id' => $id,
|
'id' => $id,
|
||||||
'username' => $username
|
'username' => $username
|
||||||
))->get();
|
));
|
||||||
$result = json_decode($json_result, true)['data'];
|
|
||||||
$id = $result['id'];
|
$id = $result['id'];
|
||||||
|
|
||||||
if ($this->isAdmin()) {
|
if ($this->isAdmin()) {
|
||||||
// get customer-data
|
// get customer-data
|
||||||
$json_result = Customers::getLocal($this->getUserData(), array(
|
$customer_data = $this->apiCall('Customers.get', array(
|
||||||
'id' => $result['customerid']
|
'id' => $result['customerid']
|
||||||
))->get();
|
));
|
||||||
$customer_data = json_decode($json_result, true)['data'];
|
|
||||||
} else {
|
} else {
|
||||||
$customer_data = $this->getUserData();
|
$customer_data = $this->getUserData();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -215,10 +215,9 @@ class IpsAndPorts extends ApiCommand implements ResourceEntity
|
|||||||
}
|
}
|
||||||
$this->logger()->logAction(ADM_ACTION, LOG_WARNING, "[API] added IP/port '" . $ip . ":" . $port . "'");
|
$this->logger()->logAction(ADM_ACTION, LOG_WARNING, "[API] added IP/port '" . $ip . ":" . $port . "'");
|
||||||
// get ip for return-array
|
// get ip for return-array
|
||||||
$json_result = IpsAndPorts::getLocal($this->getUserData(), array(
|
$result = $this->apiCall('IpsAndPorts.get', array(
|
||||||
'id' => $ins_data['id']
|
'id' => $ins_data['id']
|
||||||
))->get();
|
));
|
||||||
$result = json_decode($json_result, true)['data'];
|
|
||||||
return $this->response(200, "successfull", $result);
|
return $this->response(200, "successfull", $result);
|
||||||
}
|
}
|
||||||
throw new Exception("Not allowed to execute given command.", 403);
|
throw new Exception("Not allowed to execute given command.", 403);
|
||||||
@@ -237,11 +236,10 @@ class IpsAndPorts extends ApiCommand implements ResourceEntity
|
|||||||
{
|
{
|
||||||
if ($this->isAdmin() && ($this->getUserDetail('change_serversettings') || ! empty($this->getUserDetail('ip')))) {
|
if ($this->isAdmin() && ($this->getUserDetail('change_serversettings') || ! empty($this->getUserDetail('ip')))) {
|
||||||
$id = $this->getParam('id');
|
$id = $this->getParam('id');
|
||||||
|
|
||||||
$json_result = IpsAndPorts::getLocal($this->getUserData(), array(
|
$result = $this->apiCall('IpsAndPorts.get', array(
|
||||||
'id' => $id
|
'id' => $id
|
||||||
))->get();
|
));
|
||||||
$result = json_decode($json_result, true)['data'];
|
|
||||||
|
|
||||||
$ip = validate_ip2($this->getParam('ip', true, $result['ip']), false, 'invalidip', false, false, false, true);
|
$ip = validate_ip2($this->getParam('ip', true, $result['ip']), false, 'invalidip', false, false, false, true);
|
||||||
$port = validate($this->getParam('port', true, $result['port']), 'port', '/^(([1-9])|([1-9][0-9])|([1-9][0-9][0-9])|([1-9][0-9][0-9][0-9])|([1-5][0-9][0-9][0-9][0-9])|(6[0-4][0-9][0-9][0-9])|(65[0-4][0-9][0-9])|(655[0-2][0-9])|(6553[0-5]))$/Di', array(
|
$port = validate($this->getParam('port', true, $result['port']), 'port', '/^(([1-9])|([1-9][0-9])|([1-9][0-9][0-9])|([1-9][0-9][0-9][0-9])|([1-5][0-9][0-9][0-9][0-9])|(6[0-4][0-9][0-9][0-9])|(65[0-4][0-9][0-9])|(655[0-2][0-9])|(6553[0-5]))$/Di', array(
|
||||||
@@ -373,10 +371,9 @@ class IpsAndPorts extends ApiCommand implements ResourceEntity
|
|||||||
|
|
||||||
$this->logger()->logAction(ADM_ACTION, LOG_WARNING, "[API] changed IP/port from '" . $result['ip'] . ":" . $result['port'] . "' to '" . $ip . ":" . $port . "'");
|
$this->logger()->logAction(ADM_ACTION, LOG_WARNING, "[API] changed IP/port from '" . $result['ip'] . ":" . $result['port'] . "' to '" . $ip . ":" . $port . "'");
|
||||||
|
|
||||||
$json_result = IpsAndPorts::getLocal($this->getUserData(), array(
|
$result = $this->apiCall('IpsAndPorts.get', array(
|
||||||
'id' => $result['id']
|
'id' => $result['id']
|
||||||
))->get();
|
));
|
||||||
$result = json_decode($json_result, true)['data'];
|
|
||||||
return $this->response(200, "successfull", $result);
|
return $this->response(200, "successfull", $result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -397,11 +394,10 @@ class IpsAndPorts extends ApiCommand implements ResourceEntity
|
|||||||
{
|
{
|
||||||
if ($this->isAdmin() && $this->getUserDetail('change_serversettings')) {
|
if ($this->isAdmin() && $this->getUserDetail('change_serversettings')) {
|
||||||
$id = $this->getParam('id');
|
$id = $this->getParam('id');
|
||||||
|
|
||||||
$json_result = IpsAndPorts::getLocal($this->getUserData(), array(
|
$result = $this->apiCall('IpsAndPorts.get', array(
|
||||||
'id' => $id
|
'id' => $id
|
||||||
))->get();
|
));
|
||||||
$result = json_decode($json_result, true)['data'];
|
|
||||||
|
|
||||||
$result_checkdomain_stmt = Database::prepare("
|
$result_checkdomain_stmt = Database::prepare("
|
||||||
SELECT `id_domain` as `id` FROM `" . TABLE_DOMAINTOIP . "` WHERE `id_ipandports` = :id
|
SELECT `id_domain` as `id` FROM `" . TABLE_DOMAINTOIP . "` WHERE `id_ipandports` = :id
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ class Mysqls extends ApiCommand implements ResourceEntity
|
|||||||
if (! isset($sql_root) || ! is_array($sql_root)) {
|
if (! isset($sql_root) || ! is_array($sql_root)) {
|
||||||
throw new ErrorException("Database server with index #" . $dbserver . " is unknown", 404);
|
throw new ErrorException("Database server with index #" . $dbserver . " is unknown", 404);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($sendinfomail != 1) {
|
if ($sendinfomail != 1) {
|
||||||
$sendinfomail = 0;
|
$sendinfomail = 0;
|
||||||
}
|
}
|
||||||
@@ -71,10 +71,9 @@ class Mysqls extends ApiCommand implements ResourceEntity
|
|||||||
if ($this->isAdmin()) {
|
if ($this->isAdmin()) {
|
||||||
// get customer id
|
// get customer id
|
||||||
$customer_id = $this->getParam('customer_id');
|
$customer_id = $this->getParam('customer_id');
|
||||||
$json_result = Customers::getLocal($this->getUserData(), array(
|
$customer = $this->apiCall('Customers.get', array(
|
||||||
'id' => $customer_id
|
'id' => $customer_id
|
||||||
))->get();
|
));
|
||||||
$customer = json_decode($json_result, true)['data'];
|
|
||||||
// check whether the customer has enough resources to get the database added
|
// check whether the customer has enough resources to get the database added
|
||||||
if ($customer['mysqls_used'] >= $customer['mysqls'] && $customer['mysqls'] != '-1') {
|
if ($customer['mysqls_used'] >= $customer['mysqls'] && $customer['mysqls'] != '-1') {
|
||||||
throw new Exception("Customer has no more resources available", 406);
|
throw new Exception("Customer has no more resources available", 406);
|
||||||
@@ -196,10 +195,9 @@ class Mysqls extends ApiCommand implements ResourceEntity
|
|||||||
}
|
}
|
||||||
$this->logger()->logAction($this->isAdmin() ? ADM_ACTION : USR_ACTION, LOG_WARNING, "[API] added mysql-database '" . $username . "'");
|
$this->logger()->logAction($this->isAdmin() ? ADM_ACTION : USR_ACTION, LOG_WARNING, "[API] added mysql-database '" . $username . "'");
|
||||||
|
|
||||||
$json_result = Mysqls::getLocal($this->getUserData(), array(
|
$result = $this->apiCall('Mysqls.get', array(
|
||||||
'dbname' => $username
|
'dbname' => $username
|
||||||
))->get();
|
));
|
||||||
$result = json_decode($json_result, true)['data'];
|
|
||||||
return $this->response(200, "successfull", $result);
|
return $this->response(200, "successfull", $result);
|
||||||
}
|
}
|
||||||
throw new Exception("No more resources available", 406);
|
throw new Exception("No more resources available", 406);
|
||||||
@@ -225,13 +223,13 @@ class Mysqls extends ApiCommand implements ResourceEntity
|
|||||||
$dn_optional = ($id <= 0 ? false : true);
|
$dn_optional = ($id <= 0 ? false : true);
|
||||||
$dbname = $this->getParam('dbname', $dn_optional, '');
|
$dbname = $this->getParam('dbname', $dn_optional, '');
|
||||||
$dbserver = $this->getParam('mysql_server', true, - 1);
|
$dbserver = $this->getParam('mysql_server', true, - 1);
|
||||||
|
|
||||||
if ($this->isAdmin()) {
|
if ($this->isAdmin()) {
|
||||||
if ($this->getUserDetail('customers_see_all') != 1) {
|
if ($this->getUserDetail('customers_see_all') != 1) {
|
||||||
// if it's a reseller or an admin who cannot see all customers, we need to check
|
// if it's a reseller or an admin who cannot see all customers, we need to check
|
||||||
// whether the database belongs to one of his customers
|
// whether the database belongs to one of his customers
|
||||||
$json_result = Customers::getLocal($this->getUserData())->listing();
|
$_custom_list_result = $this->apiCall('Customers.listing');
|
||||||
$custom_list_result = json_decode($json_result, true)['data']['list'];
|
$custom_list_result = $_custom_list_result['list'];
|
||||||
$customer_ids = array();
|
$customer_ids = array();
|
||||||
foreach ($custom_list_result as $customer) {
|
foreach ($custom_list_result as $customer) {
|
||||||
$customer_ids[] = $customer['customerid'];
|
$customer_ids[] = $customer['customerid'];
|
||||||
@@ -311,7 +309,7 @@ class Mysqls extends ApiCommand implements ResourceEntity
|
|||||||
* optional, update password for the database
|
* optional, update password for the database
|
||||||
* @param string $description
|
* @param string $description
|
||||||
* optional, description for database
|
* optional, description for database
|
||||||
*
|
*
|
||||||
* @access admin, customer
|
* @access admin, customer
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
* @return array
|
* @return array
|
||||||
@@ -322,17 +320,16 @@ class Mysqls extends ApiCommand implements ResourceEntity
|
|||||||
$dn_optional = ($id <= 0 ? false : true);
|
$dn_optional = ($id <= 0 ? false : true);
|
||||||
$dbname = $this->getParam('dbname', $dn_optional, '');
|
$dbname = $this->getParam('dbname', $dn_optional, '');
|
||||||
$dbserver = $this->getParam('mysql_server', true, - 1);
|
$dbserver = $this->getParam('mysql_server', true, - 1);
|
||||||
|
|
||||||
if ($this->isAdmin() == false && Settings::IsInList('panel.customer_hide_options', 'mysql')) {
|
if ($this->isAdmin() == false && Settings::IsInList('panel.customer_hide_options', 'mysql')) {
|
||||||
throw new Exception("You cannot access this resource", 405);
|
throw new Exception("You cannot access this resource", 405);
|
||||||
}
|
}
|
||||||
|
|
||||||
$json_result = Mysqls::getLocal($this->getUserData(), array(
|
$result = $this->apiCall('Mysqls.get', array(
|
||||||
'id' => $id,
|
'id' => $id,
|
||||||
'dbname' => $dbname,
|
'dbname' => $dbname,
|
||||||
'mysql_server' => $dbserver
|
'mysql_server' => $dbserver
|
||||||
))->get();
|
));
|
||||||
$result = json_decode($json_result, true)['data'];
|
|
||||||
$id = $result['id'];
|
$id = $result['id'];
|
||||||
|
|
||||||
// paramters
|
// paramters
|
||||||
@@ -352,15 +349,14 @@ class Mysqls extends ApiCommand implements ResourceEntity
|
|||||||
if (! isset($sql_root) || ! is_array($sql_root)) {
|
if (! isset($sql_root) || ! is_array($sql_root)) {
|
||||||
throw new ErrorException("Database server with index #" . $dbserver . " is unknown", 404);
|
throw new ErrorException("Database server with index #" . $dbserver . " is unknown", 404);
|
||||||
}
|
}
|
||||||
|
|
||||||
// get needed customer info to reduce the mysql-usage-counter by one
|
// get needed customer info to reduce the mysql-usage-counter by one
|
||||||
if ($this->isAdmin()) {
|
if ($this->isAdmin()) {
|
||||||
// get customer id
|
// get customer id
|
||||||
$customer_id = $this->getParam('customer_id');
|
$customer_id = $this->getParam('customer_id');
|
||||||
$json_result = Customers::getLocal($this->getUserData(), array(
|
$customer = $this->apiCall('Customers.get', array(
|
||||||
'id' => $result['customerid']
|
'id' => $customer_id
|
||||||
))->get();
|
));
|
||||||
$customer = json_decode($json_result, true)['data'];
|
|
||||||
// check whether the customer has enough resources to get the database added
|
// check whether the customer has enough resources to get the database added
|
||||||
if ($customer['mysqls_used'] >= $customer['mysqls'] && $customer['mysqls'] != '-1') {
|
if ($customer['mysqls_used'] >= $customer['mysqls'] && $customer['mysqls'] != '-1') {
|
||||||
throw new Exception("Customer has no more resources available", 406);
|
throw new Exception("Customer has no more resources available", 406);
|
||||||
@@ -406,7 +402,7 @@ class Mysqls extends ApiCommand implements ResourceEntity
|
|||||||
"id" => $id
|
"id" => $id
|
||||||
);
|
);
|
||||||
Database::pexecute($stmt, $params, true, true);
|
Database::pexecute($stmt, $params, true, true);
|
||||||
|
|
||||||
$this->logger()->logAction($this->isAdmin() ? ADM_ACTION : USR_ACTION, LOG_WARNING, "[API] updated mysql-database '" . $result['databasename'] . "'");
|
$this->logger()->logAction($this->isAdmin() ? ADM_ACTION : USR_ACTION, LOG_WARNING, "[API] updated mysql-database '" . $result['databasename'] . "'");
|
||||||
return $this->response(200, "successfull", $params);
|
return $this->response(200, "successfull", $params);
|
||||||
}
|
}
|
||||||
@@ -436,16 +432,16 @@ class Mysqls extends ApiCommand implements ResourceEntity
|
|||||||
$loginname = $this->getParam('loginname', true, '');
|
$loginname = $this->getParam('loginname', true, '');
|
||||||
|
|
||||||
if (! empty($customer_id) || ! empty($loginname)) {
|
if (! empty($customer_id) || ! empty($loginname)) {
|
||||||
$json_result = Customers::getLocal($this->getUserData(), array(
|
$customer = $this->apiCall('Customers.get', array(
|
||||||
'id' => $customerid,
|
'id' => $customerid,
|
||||||
'loginname' => $loginname
|
'loginname' => $loginname
|
||||||
))->get();
|
));
|
||||||
$custom_list_result = array(
|
$custom_list_result = array(
|
||||||
json_decode($json_result, true)['data']
|
$customer
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
$json_result = Customers::getLocal($this->getUserData())->listing();
|
$_custom_list_result = $this->apiCall('Customers.listing');
|
||||||
$custom_list_result = json_decode($json_result, true)['data']['list'];
|
$custom_list_result = $_custom_list_result['list'];
|
||||||
}
|
}
|
||||||
$customer_ids = array();
|
$customer_ids = array();
|
||||||
foreach ($custom_list_result as $customer) {
|
foreach ($custom_list_result as $customer) {
|
||||||
@@ -526,17 +522,16 @@ class Mysqls extends ApiCommand implements ResourceEntity
|
|||||||
$dn_optional = ($id <= 0 ? false : true);
|
$dn_optional = ($id <= 0 ? false : true);
|
||||||
$dbname = $this->getParam('dbname', $dn_optional, '');
|
$dbname = $this->getParam('dbname', $dn_optional, '');
|
||||||
$dbserver = $this->getParam('mysql_server', true, - 1);
|
$dbserver = $this->getParam('mysql_server', true, - 1);
|
||||||
|
|
||||||
if ($this->isAdmin() == false && Settings::IsInList('panel.customer_hide_options', 'mysql')) {
|
if ($this->isAdmin() == false && Settings::IsInList('panel.customer_hide_options', 'mysql')) {
|
||||||
throw new Exception("You cannot access this resource", 405);
|
throw new Exception("You cannot access this resource", 405);
|
||||||
}
|
}
|
||||||
|
|
||||||
$json_result = Mysqls::getLocal($this->getUserData(), array(
|
$result = $this->apiCall('Mysqls.get', array(
|
||||||
'id' => $id,
|
'id' => $id,
|
||||||
'dbname' => $dbname,
|
'dbname' => $dbname,
|
||||||
'mysql_server' => $dbserver
|
'mysql_server' => $dbserver
|
||||||
))->get();
|
));
|
||||||
$result = json_decode($json_result, true)['data'];
|
|
||||||
$id = $result['id'];
|
$id = $result['id'];
|
||||||
|
|
||||||
// Begin root-session
|
// Begin root-session
|
||||||
@@ -554,10 +549,9 @@ class Mysqls extends ApiCommand implements ResourceEntity
|
|||||||
|
|
||||||
// get needed customer info to reduce the mysql-usage-counter by one
|
// get needed customer info to reduce the mysql-usage-counter by one
|
||||||
if ($this->isAdmin()) {
|
if ($this->isAdmin()) {
|
||||||
$json_result = Customers::getLocal($this->getUserData(), array(
|
$customer = $this->apiCall('Customers.get', array(
|
||||||
'id' => $result['customerid']
|
'id' => $result['customerid']
|
||||||
))->get();
|
));
|
||||||
$customer = json_decode($json_result, true)['data'];
|
|
||||||
$mysql_used = $customer['mysqls_used'];
|
$mysql_used = $customer['mysqls_used'];
|
||||||
$customer_id = $customer['customer_id'];
|
$customer_id = $customer['customer_id'];
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -230,7 +230,11 @@ class PhpSettings extends ApiCommand implements ResourceEntity
|
|||||||
|
|
||||||
inserttask('1');
|
inserttask('1');
|
||||||
$this->logger()->logAction(ADM_ACTION, LOG_INFO, "[API] php setting with description '" . $description . "' has been created by '" . $this->getUserDetail('loginname') . "'");
|
$this->logger()->logAction(ADM_ACTION, LOG_INFO, "[API] php setting with description '" . $description . "' has been created by '" . $this->getUserDetail('loginname') . "'");
|
||||||
return $this->response(200, "successfull", $ins_data);
|
|
||||||
|
$result = $this->apiCall('PhpSettings.get', array(
|
||||||
|
'id' => $ins_data['id']
|
||||||
|
));
|
||||||
|
return $this->response(200, "successfull", $result);
|
||||||
}
|
}
|
||||||
throw new Exception("Not allowed to execute given command.", 403);
|
throw new Exception("Not allowed to execute given command.", 403);
|
||||||
}
|
}
|
||||||
@@ -250,11 +254,10 @@ class PhpSettings extends ApiCommand implements ResourceEntity
|
|||||||
|
|
||||||
// required parameter
|
// required parameter
|
||||||
$id = $this->getParam('id');
|
$id = $this->getParam('id');
|
||||||
|
|
||||||
$json_result = PhpSettings::getLocal($this->getUserData(), array(
|
$result = $this->apiCall('PhpSettings.get', array(
|
||||||
'id' => $id
|
'id' => $id
|
||||||
))->get();
|
));
|
||||||
$result = json_decode($json_result, true)['data'];
|
|
||||||
|
|
||||||
// parameters
|
// parameters
|
||||||
$description = $this->getParam('description', true, $result['description']);
|
$description = $this->getParam('description', true, $result['description']);
|
||||||
@@ -341,7 +344,11 @@ class PhpSettings extends ApiCommand implements ResourceEntity
|
|||||||
|
|
||||||
inserttask('1');
|
inserttask('1');
|
||||||
$this->logger()->logAction(ADM_ACTION, LOG_INFO, "[API] php setting with description '" . $description . "' has been updated by '" . $this->getUserDetail('loginname') . "'");
|
$this->logger()->logAction(ADM_ACTION, LOG_INFO, "[API] php setting with description '" . $description . "' has been updated by '" . $this->getUserDetail('loginname') . "'");
|
||||||
return $this->response(200, "successfull", $upd_data);
|
|
||||||
|
$result = $this->apiCall('PhpSettings.get', array(
|
||||||
|
'id' => $id
|
||||||
|
));
|
||||||
|
return $this->response(200, "successfull", $result);
|
||||||
}
|
}
|
||||||
throw new Exception("Not allowed to execute given command.", 403);
|
throw new Exception("Not allowed to execute given command.", 403);
|
||||||
}
|
}
|
||||||
@@ -359,11 +366,10 @@ class PhpSettings extends ApiCommand implements ResourceEntity
|
|||||||
{
|
{
|
||||||
if ($this->isAdmin() && $this->getUserDetail('change_serversettings') == 1) {
|
if ($this->isAdmin() && $this->getUserDetail('change_serversettings') == 1) {
|
||||||
$id = $this->getParam('id');
|
$id = $this->getParam('id');
|
||||||
|
|
||||||
$json_result = PhpSettings::getLocal($this->getUserData(), array(
|
$result = $this->apiCall('PhpSettings.get', array(
|
||||||
'id' => $id
|
'id' => $id
|
||||||
))->get();
|
));
|
||||||
$result = json_decode($json_result, true)['data'];
|
|
||||||
|
|
||||||
if ((Settings::Get('system.mod_fcgid') == '1' && Settings::Get('system.mod_fcgid_defaultini_ownvhost') == $id) || (Settings::Get('phpfpm.enabled') == '1' && Settings::Get('phpfpm.vhost_defaultini') == $id)) {
|
if ((Settings::Get('system.mod_fcgid') == '1' && Settings::Get('system.mod_fcgid_defaultini_ownvhost') == $id) || (Settings::Get('phpfpm.enabled') == '1' && Settings::Get('phpfpm.vhost_defaultini') == $id)) {
|
||||||
standard_error('cannotdeletehostnamephpconfig', '', true);
|
standard_error('cannotdeletehostnamephpconfig', '', true);
|
||||||
|
|||||||
@@ -80,10 +80,9 @@ class SubDomains extends ApiCommand implements ResourceEntity
|
|||||||
if ($this->isAdmin()) {
|
if ($this->isAdmin()) {
|
||||||
// get customer id
|
// get customer id
|
||||||
$customer_id = $this->getParam('customer_id');
|
$customer_id = $this->getParam('customer_id');
|
||||||
$json_result = Customers::getLocal($this->getUserData(), array(
|
$customer = $this->apiCall('Customers.get', array(
|
||||||
'id' => $customer_id
|
'id' => $customer_id
|
||||||
))->get();
|
));
|
||||||
$customer = json_decode($json_result, true)['data'];
|
|
||||||
// check whether the customer has enough resources to get the subdomain added
|
// check whether the customer has enough resources to get the subdomain added
|
||||||
if ($customer['subdomains_used'] >= $customer['subdomains'] && $customer['subdomains'] != '-1') {
|
if ($customer['subdomains_used'] >= $customer['subdomains'] && $customer['subdomains'] != '-1') {
|
||||||
throw new Exception("Customer has no more resources available", 406);
|
throw new Exception("Customer has no more resources available", 406);
|
||||||
@@ -329,11 +328,10 @@ class SubDomains extends ApiCommand implements ResourceEntity
|
|||||||
Admins::increaseUsage(($this->isAdmin() ? $customer['adminid'] : $this->getUserDetail('adminid')), 'subdomains_used');
|
Admins::increaseUsage(($this->isAdmin() ? $customer['adminid'] : $this->getUserDetail('adminid')), 'subdomains_used');
|
||||||
|
|
||||||
$this->logger()->logAction($this->isAdmin() ? ADM_ACTION : USR_ACTION, LOG_INFO, "[API] added subdomain '" . $completedomain . "'");
|
$this->logger()->logAction($this->isAdmin() ? ADM_ACTION : USR_ACTION, LOG_INFO, "[API] added subdomain '" . $completedomain . "'");
|
||||||
|
|
||||||
$json_result = SubDomains::getLocal($this->getUserData(), array(
|
$result = $this->apiCall('SubDomains.get', array(
|
||||||
'id' => $subdomain_id
|
'id' => $subdomain_id
|
||||||
))->get();
|
));
|
||||||
$result = json_decode($json_result, true)['data'];
|
|
||||||
return $this->response(200, "successfull", $result);
|
return $this->response(200, "successfull", $result);
|
||||||
}
|
}
|
||||||
throw new Exception("No more resources available", 406);
|
throw new Exception("No more resources available", 406);
|
||||||
@@ -367,8 +365,8 @@ class SubDomains extends ApiCommand implements ResourceEntity
|
|||||||
if ($this->getUserDetail('customers_see_all') != 1) {
|
if ($this->getUserDetail('customers_see_all') != 1) {
|
||||||
// if it's a reseller or an admin who cannot see all customers, we need to check
|
// if it's a reseller or an admin who cannot see all customers, we need to check
|
||||||
// whether the database belongs to one of his customers
|
// whether the database belongs to one of his customers
|
||||||
$json_result = Customers::getLocal($this->getUserData())->listing();
|
$_custom_list_result = $this->apiCall('Customers.listing');
|
||||||
$custom_list_result = json_decode($json_result, true)['data']['list'];
|
$custom_list_result = $_custom_list_result['list'];
|
||||||
$customer_ids = array();
|
$customer_ids = array();
|
||||||
foreach ($custom_list_result as $customer) {
|
foreach ($custom_list_result as $customer) {
|
||||||
$customer_ids[] = $customer['customerid'];
|
$customer_ids[] = $customer['customerid'];
|
||||||
@@ -428,16 +426,16 @@ class SubDomains extends ApiCommand implements ResourceEntity
|
|||||||
$loginname = $this->getParam('loginname', true, '');
|
$loginname = $this->getParam('loginname', true, '');
|
||||||
|
|
||||||
if (! empty($customerid) || ! empty($loginname)) {
|
if (! empty($customerid) || ! empty($loginname)) {
|
||||||
$json_result = Customers::getLocal($this->getUserData(), array(
|
$result = $this->apiCall('Customers.get', array(
|
||||||
'id' => $customerid,
|
'id' => $id,
|
||||||
'loginname' => $loginname
|
'loginname' => $loginname
|
||||||
))->get();
|
));
|
||||||
$custom_list_result = array(
|
$custom_list_result = array(
|
||||||
json_decode($json_result, true)['data']
|
$result
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
$json_result = Customers::getLocal($this->getUserData())->listing();
|
$_custom_list_result = $this->apiCall('Customers.listing');
|
||||||
$custom_list_result = json_decode($json_result, true)['data']['list'];
|
$custom_list_result = $_custom_list_result['list'];
|
||||||
}
|
}
|
||||||
$customer_ids = array();
|
$customer_ids = array();
|
||||||
$customer_stdsubs = array();
|
$customer_stdsubs = array();
|
||||||
@@ -505,20 +503,18 @@ class SubDomains extends ApiCommand implements ResourceEntity
|
|||||||
if ($this->isAdmin() == false && Settings::IsInList('panel.customer_hide_options', 'domains')) {
|
if ($this->isAdmin() == false && Settings::IsInList('panel.customer_hide_options', 'domains')) {
|
||||||
throw new Exception("You cannot access this resource", 405);
|
throw new Exception("You cannot access this resource", 405);
|
||||||
}
|
}
|
||||||
|
|
||||||
$json_result = SubDomains::getLocal($this->getUserData(), array(
|
$result = $this->apiCall('SubDomains.get', array(
|
||||||
'id' => $id,
|
'id' => $id,
|
||||||
'domainname' => $domainname
|
'domainname' => $domainname
|
||||||
))->get();
|
));
|
||||||
$result = json_decode($json_result, true)['data'];
|
|
||||||
$id = $result['id'];
|
$id = $result['id'];
|
||||||
|
|
||||||
// get needed customer info to reduce the subdomain-usage-counter by one
|
// get needed customer info to reduce the subdomain-usage-counter by one
|
||||||
if ($this->isAdmin()) {
|
if ($this->isAdmin()) {
|
||||||
$json_result = Customers::getLocal($this->getUserData(), array(
|
$customer = $this->apiCall('Customers.get', array(
|
||||||
'id' => $result['customerid']
|
'id' => $result['customerid']
|
||||||
))->get();
|
));
|
||||||
$customer = json_decode($json_result, true)['data'];
|
|
||||||
$subdomains_used = $customer['subdomains_used'];
|
$subdomains_used = $customer['subdomains_used'];
|
||||||
$customer_id = $customer['customer_id'];
|
$customer_id = $customer['customer_id'];
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user