add more api documenation
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
This commit is contained in:
@@ -108,6 +108,72 @@ class Domains extends ApiCommand implements ResourceEntity
|
||||
/**
|
||||
* add new domain entry
|
||||
*
|
||||
* @param string $domain
|
||||
* domain-name
|
||||
* @param int $customerid
|
||||
* @param int $adminid
|
||||
* optional, default is the calling admin's ID
|
||||
* @param array $ipandport
|
||||
* optional list of ip/ports to assign to domain, default is system-default-ips
|
||||
* @param bool $subcanemaildomain
|
||||
* optional, allow subdomains of this domain as email domains, default 0 (false)
|
||||
* @param bool $isemaildomain
|
||||
* optional, allow email usage with this domain, default 0 (false)
|
||||
* @param bool $email_only
|
||||
* optional, restrict domain to email usage, default 0 (false)
|
||||
* @param int $selectserveralias
|
||||
* optional, 0 = wildcard, 1 = www-alias, 2 = none, default 0
|
||||
* @param bool $speciallogfile
|
||||
* optional, whether to create an exclusive web-logfile for this domain, default 0 (false)
|
||||
* @param int $alias
|
||||
* optional, domain-id of a domain that the new domain should be an alias of, default 0 (none)
|
||||
* @param bool $issubof
|
||||
* optional, domain-id of a domain this domain is a subdomain of (required for webserver-cronjob to generate the correct order), default 0 (none)
|
||||
* @param string $registration_date
|
||||
* optional, date of domain registration in form of YYYY-MM-DD, default empty (none)
|
||||
* @param string $termination_date
|
||||
* optional, date of domain termination in form of YYYY-MM-DD, default empty (none)
|
||||
* @param bool $caneditdomain
|
||||
* optional, whether to allow the customer to edit domain settings, default 0 (false)
|
||||
* @param bool $isbinddomain
|
||||
* optional, whether to generate a dns-zone or not (only of nameserver is activated), default 0 (false)
|
||||
* @param string $zonefile
|
||||
* optional, custom dns zone filename (only of nameserver is activated), default empty (auto-generated)
|
||||
* @param bool $dkim
|
||||
* optional, currently not in use, default 0 (false)
|
||||
* @param string $specialsettings
|
||||
* optional, custom webserver vhost-content which is added to the generated vhost, default empty
|
||||
* @param bool $notryfiles
|
||||
* optional, [nginx only] do not generate the default try-files directive, default 0 (false)
|
||||
* @param string $documentroot
|
||||
* optional, specify homedir of domain by specifying a directory (relative to customer-docroot), be aware, if path starts with / it it considered a full path, not relative to customer-docroot. Also specifying a URL is possible here (redirect), default empty (autogenerated)
|
||||
* @param bool $phpenabled
|
||||
* optional, whether php is enabled for this domain, default 0 (false)
|
||||
* @param bool $openbasedir
|
||||
* optional, whether to activate openbasedir restriction for this domain, default 0 (false)
|
||||
* @param int $phpsettingid
|
||||
* optional, specify php-configuration that is being used by id, default 1 (system-default)
|
||||
* @param int $mod_fcgid_starter
|
||||
* optional number of fcgid-starters if FCGID is used, default is -1
|
||||
* @param int $mod_fcgid_maxrequests
|
||||
* optional number of fcgid-maxrequests if FCGID is used, default is -1
|
||||
* @param bool $ssl_redirect
|
||||
* optional, whether to generate a https-redirect or not, default false; requires SSL to be enabled
|
||||
* @param bool $letsencrypt
|
||||
* optional, whether to generate a Let's Encrypt certificate for this domain, default false; requires SSL to be enabled
|
||||
* @param array $ssl_ipandport
|
||||
* optional, list of ssl-enabled ip/port id's to assign to this domain
|
||||
* @param bool $http2
|
||||
* optional, whether to enable http/2 for this domain (requires to be enabled in the settings), default 0 (false)
|
||||
* @param int $hsts_maxage
|
||||
* optional max-age value for HSTS header
|
||||
* @param bool $hsts_sub
|
||||
* optional whether or not to add subdomains to the HSTS header
|
||||
* @param bool $hsts_preload
|
||||
* optional whether or not to preload HSTS header value
|
||||
* @param bool $ocsp_stapling
|
||||
* optional whether to enable oscp-stapling for this domain. default ß (false), requires SSL
|
||||
*
|
||||
* @access admin
|
||||
* @throws Exception
|
||||
* @return array
|
||||
@@ -181,16 +247,17 @@ class Domains extends ApiCommand implements ResourceEntity
|
||||
'id' => $customerid
|
||||
));
|
||||
|
||||
if ($this->getUserDetail('customers_see_all') == '1') {
|
||||
if ($this->getUserDetail('customers_see_all') == '1' && $adminid != $this->getUserDetail('adminid')) {
|
||||
$admin_stmt = Database::prepare("
|
||||
SELECT * FROM `" . TABLE_PANEL_ADMINS . "`
|
||||
WHERE `adminid` = :adminid AND (`domains_used` < `domains` OR `domains` = '-1')");
|
||||
$admin = Database::pexecute_first($admin_stmt, array(
|
||||
'adminid' => $adminid
|
||||
), true, true);
|
||||
} else {
|
||||
$adminid = $this->getUserDetail('adminid');
|
||||
$admin = $this->getUserData();
|
||||
if (empty($admin)) {
|
||||
dynamic_error("Selected admin cannot have any more domains or could not be found");
|
||||
}
|
||||
unset($admin);
|
||||
}
|
||||
|
||||
// set default path if admin/reseller has "change_serversettings == false" but we still
|
||||
@@ -232,7 +299,7 @@ class Domains extends ApiCommand implements ResourceEntity
|
||||
|
||||
// If path is empty and 'Use domain name as default value for DocumentRoot path' is enabled in settings,
|
||||
// set default path to subdomain or domain name
|
||||
if ($documentroot != '') {
|
||||
if (! empty($documentroot)) {
|
||||
if (substr($documentroot, 0, 1) != '/' && ! preg_match('/^https?\:\/\//', $documentroot)) {
|
||||
$documentroot = $_documentroot . '/' . $documentroot;
|
||||
}
|
||||
@@ -609,6 +676,76 @@ class Domains extends ApiCommand implements ResourceEntity
|
||||
* optional, the domain-id
|
||||
* @param string $domainname
|
||||
* optional, the domainname
|
||||
* @param int $customerid
|
||||
* optional customer-id
|
||||
* @param int $adminid
|
||||
* optional, default is the calling admin's ID
|
||||
* @param array $ipandport
|
||||
* optional list of ip/ports to assign to domain, default is system-default-ips
|
||||
* @param bool $subcanemaildomain
|
||||
* optional, allow subdomains of this domain as email domains, default 0 (false)
|
||||
* @param bool $isemaildomain
|
||||
* optional, allow email usage with this domain, default 0 (false)
|
||||
* @param bool $email_only
|
||||
* optional, restrict domain to email usage, default 0 (false)
|
||||
* @param int $selectserveralias
|
||||
* optional, 0 = wildcard, 1 = www-alias, 2 = none, default 0
|
||||
* @param bool $speciallogfile
|
||||
* optional, whether to create an exclusive web-logfile for this domain, default 0 (false)
|
||||
* @param bool $speciallogverified
|
||||
* optional, when setting $speciallogfile to false, this needs to be set to true to confirm the action, default 0 (false)
|
||||
* @param int $alias
|
||||
* optional, domain-id of a domain that the new domain should be an alias of, default 0 (none)
|
||||
* @param bool $issubof
|
||||
* optional, domain-id of a domain this domain is a subdomain of (required for webserver-cronjob to generate the correct order), default 0 (none)
|
||||
* @param string $registration_date
|
||||
* optional, date of domain registration in form of YYYY-MM-DD, default empty (none)
|
||||
* @param string $termination_date
|
||||
* optional, date of domain termination in form of YYYY-MM-DD, default empty (none)
|
||||
* @param bool $caneditdomain
|
||||
* optional, whether to allow the customer to edit domain settings, default 0 (false)
|
||||
* @param bool $isbinddomain
|
||||
* optional, whether to generate a dns-zone or not (only of nameserver is activated), default 0 (false)
|
||||
* @param string $zonefile
|
||||
* optional, custom dns zone filename (only of nameserver is activated), default empty (auto-generated)
|
||||
* @param bool $dkim
|
||||
* optional, currently not in use, default 0 (false)
|
||||
* @param string $specialsettings
|
||||
* optional, custom webserver vhost-content which is added to the generated vhost, default empty
|
||||
* @param bool $specialsettingsforsubdomains
|
||||
* optional, whether to apply specialsettings to all subdomains of this domain, default 0 (false)
|
||||
* @param bool $notryfiles
|
||||
* optional, [nginx only] do not generate the default try-files directive, default 0 (false)
|
||||
* @param string $documentroot
|
||||
* optional, specify homedir of domain by specifying a directory (relative to customer-docroot), be aware, if path starts with / it it considered a full path, not relative to customer-docroot. Also specifying a URL is possible here (redirect), default empty (autogenerated)
|
||||
* @param bool $phpenabled
|
||||
* optional, whether php is enabled for this domain, default 0 (false)
|
||||
* @param bool $phpsettingsforsubdomains
|
||||
* optional, whether to apply php-setting to apply to all subdomains of this domain, default 0 (false)
|
||||
* @param bool $openbasedir
|
||||
* optional, whether to activate openbasedir restriction for this domain, default 0 (false)
|
||||
* @param int $phpsettingid
|
||||
* optional, specify php-configuration that is being used by id, default 1 (system-default)
|
||||
* @param int $mod_fcgid_starter
|
||||
* optional number of fcgid-starters if FCGID is used, default is -1
|
||||
* @param int $mod_fcgid_maxrequests
|
||||
* optional number of fcgid-maxrequests if FCGID is used, default is -1
|
||||
* @param bool $ssl_redirect
|
||||
* optional, whether to generate a https-redirect or not, default false; requires SSL to be enabled
|
||||
* @param bool $letsencrypt
|
||||
* optional, whether to generate a Let's Encrypt certificate for this domain, default false; requires SSL to be enabled
|
||||
* @param array $ssl_ipandport
|
||||
* optional, list of ssl-enabled ip/port id's to assign to this domain
|
||||
* @param bool $http2
|
||||
* optional, whether to enable http/2 for this domain (requires to be enabled in the settings), default 0 (false)
|
||||
* @param int $hsts_maxage
|
||||
* optional max-age value for HSTS header
|
||||
* @param bool $hsts_sub
|
||||
* optional whether or not to add subdomains to the HSTS header
|
||||
* @param bool $hsts_preload
|
||||
* optional whether or not to preload HSTS header value
|
||||
* @param bool $ocsp_stapling
|
||||
* optional whether to enable oscp-stapling for this domain. default ß (false), requires SSL
|
||||
*
|
||||
* @access admin
|
||||
* @throws Exception
|
||||
@@ -616,7 +753,7 @@ class Domains extends ApiCommand implements ResourceEntity
|
||||
*/
|
||||
public function update()
|
||||
{
|
||||
if ($this->isAdmin() && $this->getUserDetail('change_serversettings')) {
|
||||
if ($this->isAdmin()) {
|
||||
|
||||
// parameters
|
||||
$id = $this->getParam('id', true, 0);
|
||||
@@ -1266,10 +1403,7 @@ class Domains extends ApiCommand implements ResourceEntity
|
||||
");
|
||||
Database::pexecute($_update_stmt, $_update_data, true, true);
|
||||
|
||||
// FIXME check how many we got and if the amount of assigned IP's
|
||||
// has changed so we can insert a config-rebuild task if only
|
||||
// the ip's of this domain were changed
|
||||
// -> for now, always insert a rebuild-task
|
||||
// insert a rebuild-task
|
||||
inserttask('1');
|
||||
|
||||
// Cleanup domain <-> ip mapping
|
||||
@@ -1347,7 +1481,7 @@ class Domains extends ApiCommand implements ResourceEntity
|
||||
if ($aliasdomain === 0) {
|
||||
// in case the wwwserveralias is set on a main domain, $aliasdomain is 0
|
||||
// --> the call just above to triggerLetsEncryptCSRForAliasDestinationDomain
|
||||
// is a noop...let's repeat it with the domain id of the main domain
|
||||
// is a noop...let's repeat it with the domain id of the main domain
|
||||
triggerLetsEncryptCSRForAliasDestinationDomain($id, $this->logger());
|
||||
}
|
||||
}
|
||||
@@ -1553,7 +1687,7 @@ class Domains extends ApiCommand implements ResourceEntity
|
||||
$aip_param = array();
|
||||
if ($this->getUserDetail('ip') != "-1") {
|
||||
// handle multiple-ip-array
|
||||
$additional_ip_condition = " AND `ip` IN (".implode(",", json_decode($this->getUserDetail('ip'), true)).") ";
|
||||
$additional_ip_condition = " AND `ip` IN (" . implode(",", json_decode($this->getUserDetail('ip'), true)) . ") ";
|
||||
}
|
||||
|
||||
if (! empty($p_ipandports) && is_array($p_ipandports)) {
|
||||
|
||||
@@ -41,6 +41,12 @@ class SubDomains extends ApiCommand implements ResourceEntity
|
||||
* optional, whether to generate a https-redirect or not, default false; requires SSL to be enabled
|
||||
* @param bool $letsencrypt
|
||||
* optional, whether to generate a Let's Encrypt certificate for this domain, default false; requires SSL to be enabled
|
||||
* @param int $hsts_maxage
|
||||
* optional max-age value for HSTS header, default 0
|
||||
* @param bool $hsts_sub
|
||||
* optional whether or not to add subdomains to the HSTS header, default 0
|
||||
* @param bool $hsts_preload
|
||||
* optional whether or not to preload HSTS header value, default 0
|
||||
* @param int $customerid
|
||||
* required when called as admin, not needed when called as customer
|
||||
*
|
||||
@@ -149,6 +155,7 @@ class SubDomains extends ApiCommand implements ResourceEntity
|
||||
}
|
||||
|
||||
// validate / correct path/url of domain
|
||||
$_doredirect = false;
|
||||
$path = $this->validateDomainDocumentRoot($path, $url, $customer, $completedomain, $_doredirect);
|
||||
|
||||
if ($openbasedir_path != 1) {
|
||||
@@ -349,7 +356,7 @@ class SubDomains extends ApiCommand implements ResourceEntity
|
||||
$result_stmt = Database::prepare("
|
||||
SELECT d.*, pd.`subcanemaildomain`, pd.`isbinddomain` as subisbinddomain
|
||||
FROM `" . TABLE_PANEL_DOMAINS . "` d, `" . TABLE_PANEL_DOMAINS . "` pd
|
||||
WHERE " . ($id > 0 ? "d.`id` = :iddn" : "d.`domain` = :iddn") . " AND d.`customerid` IN (".implode(", ", $customer_ids).")
|
||||
WHERE " . ($id > 0 ? "d.`id` = :iddn" : "d.`domain` = :iddn") . " AND d.`customerid` IN (" . implode(", ", $customer_ids) . ")
|
||||
AND ((d.`parentdomainid`!='0' AND pd.`id` = d.`parentdomainid`) OR (d.`parentdomainid`='0' AND pd.`id` = d.`id`))
|
||||
");
|
||||
$params = array(
|
||||
@@ -400,6 +407,34 @@ class SubDomains extends ApiCommand implements ResourceEntity
|
||||
* optional, the domain-id
|
||||
* @param string $domainname
|
||||
* optional, the domainname
|
||||
* @param int $alias
|
||||
* optional, domain-id of a domain that the new domain should be an alias of
|
||||
* @param string $path
|
||||
* optional, destination path relative to the customers-homedir, default is customers-homedir
|
||||
* @param string $url
|
||||
* optional, overwrites path value with an URL to generate a redirect, alternatively use the path parameter also for URLs
|
||||
* @param int $selectserveralias
|
||||
* optional, 0 = wildcard, 1 = www-alias, 2 = none
|
||||
* @param bool $isemaildomain
|
||||
* optional
|
||||
* @param int $openbasedir_path
|
||||
* optional, either 0 for customers-homedir or 1 for domains-docroot
|
||||
* @param int $phpsettingid
|
||||
* optional, php-settings-id, if empty the $domain value is used
|
||||
* @param int $redirectcode
|
||||
* optional, redirect-code-id from TABLE_PANEL_REDIRECTCODES
|
||||
* @param bool $ssl_redirect
|
||||
* optional, whether to generate a https-redirect or not, default false; requires SSL to be enabled
|
||||
* @param bool $letsencrypt
|
||||
* optional, whether to generate a Let's Encrypt certificate for this domain, default false; requires SSL to be enabled
|
||||
* @param int $hsts_maxage
|
||||
* optional max-age value for HSTS header
|
||||
* @param bool $hsts_sub
|
||||
* optional whether or not to add subdomains to the HSTS header
|
||||
* @param bool $hsts_preload
|
||||
* optional whether or not to preload HSTS header value
|
||||
* @param int $customerid
|
||||
* required when called as admin, not needed when called as customer
|
||||
*
|
||||
* @access admin, customer
|
||||
* @throws Exception
|
||||
@@ -476,6 +511,7 @@ class SubDomains extends ApiCommand implements ResourceEntity
|
||||
}
|
||||
|
||||
// validate / correct path/url of domain
|
||||
$_doredirect = false;
|
||||
$path = $this->validateDomainDocumentRoot($path, $url, $customer, $result['domain'], $_doredirect);
|
||||
|
||||
// set alias-fields according to selected alias mode
|
||||
@@ -718,7 +754,7 @@ class SubDomains extends ApiCommand implements ResourceEntity
|
||||
// get needed customer info to reduce the subdomain-usage-counter by one
|
||||
$customer = $this->getCustomerData();
|
||||
|
||||
if (!$this->isAdmin() && $result['caneditdomain'] == 0) {
|
||||
if (! $this->isAdmin() && $result['caneditdomain'] == 0) {
|
||||
throw new Exception("You cannot edit this resource", 405);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user