mirror of
https://github.com/Froxlor/Froxlor.git
synced 2024-09-21 10:27:29 +00:00
added Subdomains.add; minor fixes and enhancements
Signed-off-by: Michael Kaufmann (d00p) <d00p@froxlor.org>
This commit is contained in:
parent
6318e5514b
commit
a038e35e45
@ -205,229 +205,12 @@ if ($page == 'overview') {
|
||||
} elseif ($action == 'add') {
|
||||
if ($userinfo['subdomains_used'] < $userinfo['subdomains'] || $userinfo['subdomains'] == '-1') {
|
||||
if (isset($_POST['send']) && $_POST['send'] == 'send') {
|
||||
|
||||
if (substr($_POST['subdomain'], 0, 4) == 'xn--') {
|
||||
standard_error('domain_nopunycode');
|
||||
}
|
||||
|
||||
$subdomain = $idna_convert->encode(preg_replace(array('/\:(\d)+$/', '/^https?\:\/\//'), '', validate($_POST['subdomain'], 'subdomain', '', 'subdomainiswrong')));
|
||||
$domain = $_POST['domain'];
|
||||
$domain_stmt = Database::prepare("SELECT * FROM `" . TABLE_PANEL_DOMAINS . "`
|
||||
WHERE `domain` = :domain
|
||||
AND `customerid` = :customerid
|
||||
AND `parentdomainid` = '0'
|
||||
AND `email_only` = '0'
|
||||
AND `caneditdomain` = '1'"
|
||||
);
|
||||
$domain_check = Database::pexecute_first($domain_stmt, array("domain" => $domain, "customerid" => $userinfo['customerid']));
|
||||
|
||||
$completedomain = $subdomain . '.' . $domain;
|
||||
|
||||
if (Settings::Get('system.validate_domain') && ! validateDomain($completedomain)) {
|
||||
standard_error(array(
|
||||
'stringiswrong',
|
||||
'mydomain'
|
||||
));
|
||||
}
|
||||
|
||||
if ($completedomain == Settings::Get('system.hostname')) {
|
||||
standard_error('admin_domain_emailsystemhostname');
|
||||
}
|
||||
|
||||
$completedomain_stmt = Database::prepare("SELECT * FROM `" . TABLE_PANEL_DOMAINS . "`
|
||||
WHERE `domain` = :domain
|
||||
AND `customerid` = :customerid
|
||||
AND `email_only` = '0'
|
||||
AND `caneditdomain` = '1'"
|
||||
);
|
||||
$completedomain_check = Database::pexecute_first($completedomain_stmt, array("domain" => $completedomain, "customerid" => $userinfo['customerid']));
|
||||
|
||||
$aliasdomain = intval($_POST['alias']);
|
||||
$aliasdomain_check = array('id' => 0);
|
||||
$_doredirect = false;
|
||||
|
||||
if ($aliasdomain != 0) {
|
||||
// also check ip/port combination to be the same, #176
|
||||
$aliasdomain_stmt = Database::prepare("SELECT `d`.`id` FROM `" . TABLE_PANEL_DOMAINS . "` `d` , `" . TABLE_PANEL_CUSTOMERS . "` `c` , `".TABLE_DOMAINTOIP."` `dip`
|
||||
WHERE `d`.`aliasdomain` IS NULL
|
||||
AND `d`.`id` = :id
|
||||
AND `c`.`standardsubdomain` <> `d`.`id`
|
||||
AND `d`.`customerid` = :customerid
|
||||
AND `c`.`customerid` = `d`.`customerid`
|
||||
AND `d`.`id` = `dip`.`id_domain`
|
||||
AND `dip`.`id_ipandports`
|
||||
IN (SELECT `id_ipandports` FROM `".TABLE_DOMAINTOIP."`
|
||||
WHERE `id_domain` = :id )
|
||||
GROUP BY `d`.`domain`
|
||||
ORDER BY `d`.`domain` ASC;"
|
||||
);
|
||||
$aliasdomain_check = Database::pexecute_first($aliasdomain_stmt, array("id" => $aliasdomain, "customerid" => $userinfo['customerid']));
|
||||
triggerLetsEncryptCSRForAliasDestinationDomain($aliasdomain, $log);
|
||||
}
|
||||
|
||||
if (isset($_POST['url']) && $_POST['url'] != '' && validateUrl($_POST['url'])) {
|
||||
$path = $_POST['url'];
|
||||
$_doredirect = true;
|
||||
} else {
|
||||
$path = validate($_POST['path'], 'path');
|
||||
}
|
||||
|
||||
if (!preg_match('/^https?\:\/\//', $path) || !validateUrl($path)) {
|
||||
if (strstr($path, ":") !== FALSE) {
|
||||
standard_error('pathmaynotcontaincolon');
|
||||
}
|
||||
// If path is empty or '/' and 'Use domain name as default value for DocumentRoot path' is enabled in settings,
|
||||
// set default path to subdomain or domain name
|
||||
if ((($path == '') || ($path == '/')) && Settings::Get('system.documentroot_use_default_value') == 1) {
|
||||
$path = makeCorrectDir($userinfo['documentroot'] . '/' . $completedomain);
|
||||
} else {
|
||||
$path = makeCorrectDir($userinfo['documentroot'] . '/' . $path);
|
||||
}
|
||||
} else {
|
||||
$_doredirect = true;
|
||||
}
|
||||
|
||||
$openbasedir_path = '0';
|
||||
if (isset($_POST['openbasedir_path']) && $_POST['openbasedir_path'] == '1') {
|
||||
$openbasedir_path = '1';
|
||||
}
|
||||
|
||||
$ssl_redirect = '0';
|
||||
if (isset($_POST['ssl_redirect']) && $_POST['ssl_redirect'] == '1') {
|
||||
// a ssl-redirect only works if there actually is a
|
||||
// ssl ip/port assigned to the domain
|
||||
if (domainHasSslIpPort($domain_check['id']) == true) {
|
||||
$ssl_redirect = '1';
|
||||
$_doredirect = true;
|
||||
} else {
|
||||
standard_error('sslredirectonlypossiblewithsslipport');
|
||||
}
|
||||
}
|
||||
|
||||
$letsencrypt = '0';
|
||||
if (isset($_POST['letsencrypt']) && $_POST['letsencrypt'] == '1') {
|
||||
// let's encrypt only works if there actually is a
|
||||
// ssl ip/port assigned to the domain
|
||||
if (domainHasSslIpPort($domain_check['id']) == true) {
|
||||
$letsencrypt = '1';
|
||||
} else {
|
||||
standard_error('letsencryptonlypossiblewithsslipport');
|
||||
}
|
||||
}
|
||||
|
||||
// Temporarily deactivate ssl_redirect until Let's Encrypt certificate was generated
|
||||
if ($ssl_redirect > 0 && $letsencrypt == 1) {
|
||||
$ssl_redirect = 2;
|
||||
}
|
||||
|
||||
// HSTS
|
||||
$hsts_maxage = isset($_POST['hsts_maxage']) ? (int)$_POST['hsts_maxage'] : 0;
|
||||
$hsts_sub = isset($_POST['hsts_sub']) && (int)$_POST['hsts_sub'] == 1 ? 1 : 0;
|
||||
$hsts_preload = isset($_POST['hsts_preload']) && (int)$_POST['hsts_preload'] == 1 ? 1 : 0;
|
||||
|
||||
if ($path == '') {
|
||||
standard_error('patherror');
|
||||
} elseif ($subdomain == '') {
|
||||
standard_error(array('stringisempty', 'domainname'));
|
||||
} elseif ($subdomain == 'www' && $domain_check['wwwserveralias'] == '1') {
|
||||
standard_error('wwwnotallowed');
|
||||
} elseif ($domain == '') {
|
||||
standard_error('domaincantbeempty');
|
||||
} elseif (strtolower($completedomain_check['domain']) == strtolower($completedomain)) {
|
||||
standard_error('domainexistalready', $completedomain);
|
||||
} elseif (strtolower($domain_check['domain']) != strtolower($domain)) {
|
||||
standard_error('maindomainnonexist', $domain);
|
||||
} elseif ($aliasdomain_check['id'] != $aliasdomain) {
|
||||
standard_error('domainisaliasorothercustomer');
|
||||
} else {
|
||||
// get the phpsettingid from parentdomain, #107
|
||||
$phpsid_stmt = Database::prepare("SELECT `phpsettingid` FROM `".TABLE_PANEL_DOMAINS."`
|
||||
WHERE `id` = :id"
|
||||
);
|
||||
Database::pexecute($phpsid_stmt, array("id" => $domain_check['id']));
|
||||
$phpsid_result = $phpsid_stmt->fetch(PDO::FETCH_ASSOC);
|
||||
|
||||
if (!isset($phpsid_result['phpsettingid']) || (int)$phpsid_result['phpsettingid'] <= 0) {
|
||||
// assign default config
|
||||
$phpsid_result['phpsettingid'] = 1;
|
||||
}
|
||||
// check whether the customer has chosen its own php-config
|
||||
if (isset($_POST['phpsettingid']) && intval($_POST['phpsettingid']) != $phpsid_result['phpsettingid']) {
|
||||
$phpsid_result['phpsettingid'] = intval($_POST['phpsettingid']);
|
||||
}
|
||||
|
||||
$stmt = Database::prepare("INSERT INTO `" . TABLE_PANEL_DOMAINS . "` SET
|
||||
`customerid` = :customerid,
|
||||
`domain` = :domain,
|
||||
`documentroot` = :documentroot,
|
||||
`aliasdomain` = :aliasdomain,
|
||||
`parentdomainid` = :parentdomainid,
|
||||
`wwwserveralias` = :wwwserveralias,
|
||||
`isemaildomain` = :isemaildomain,
|
||||
`iswildcarddomain` = :iswildcarddomain,
|
||||
`phpenabled` = :phpenabled,
|
||||
`openbasedir` = :openbasedir,
|
||||
`openbasedir_path` = :openbasedir_path,
|
||||
`speciallogfile` = :speciallogfile,
|
||||
`specialsettings` = :specialsettings,
|
||||
`ssl_redirect` = :ssl_redirect,
|
||||
`phpsettingid` = :phpsettingid,
|
||||
`letsencrypt` = :letsencrypt,
|
||||
`hsts` = :hsts,
|
||||
`hsts_sub` = :hsts_sub,
|
||||
`hsts_preload` = :hsts_preload"
|
||||
);
|
||||
$params = array(
|
||||
"customerid" => $userinfo['customerid'],
|
||||
"domain" => $completedomain,
|
||||
"documentroot" => $path,
|
||||
"aliasdomain" => $aliasdomain != 0 ? $aliasdomain : null,
|
||||
"parentdomainid" => $domain_check['id'],
|
||||
"wwwserveralias" => $domain_check['wwwserveralias'] == '1' ? '1' : '0',
|
||||
"iswildcarddomain" => $domain_check['iswildcarddomain'] == '1' ? '1' : '0',
|
||||
"isemaildomain" => $domain_check['subcanemaildomain'] == '3' ? '1' : '0',
|
||||
"openbasedir" => $domain_check['openbasedir'],
|
||||
"openbasedir_path" => $openbasedir_path,
|
||||
"phpenabled" => $domain_check['phpenabled'],
|
||||
"speciallogfile" => $domain_check['speciallogfile'],
|
||||
"specialsettings" => $domain_check['specialsettings'],
|
||||
"ssl_redirect" => $ssl_redirect,
|
||||
"phpsettingid" => $phpsid_result['phpsettingid'],
|
||||
"letsencrypt" => $letsencrypt,
|
||||
"hsts" => $hsts_maxage,
|
||||
"hsts_sub" => $hsts_sub,
|
||||
"hsts_preload" => $hsts_preload
|
||||
);
|
||||
Database::pexecute($stmt, $params);
|
||||
|
||||
if ($_doredirect) {
|
||||
$did = Database::lastInsertId();
|
||||
$redirect = isset($_POST['redirectcode']) ? (int)$_POST['redirectcode'] : Settings::Get('customredirect.default');
|
||||
addRedirectToDomain($did, $redirect);
|
||||
}
|
||||
|
||||
$stmt = Database::prepare("INSERT INTO `".TABLE_DOMAINTOIP."`
|
||||
(`id_domain`, `id_ipandports`)
|
||||
SELECT LAST_INSERT_ID(), `id_ipandports`
|
||||
FROM `".TABLE_DOMAINTOIP."`
|
||||
WHERE `id_domain` = :id_domain"
|
||||
);
|
||||
Database::pexecute($stmt, array("id_domain" => $domain_check['id']));
|
||||
|
||||
$stmt = Database::prepare("UPDATE `" . TABLE_PANEL_CUSTOMERS . "`
|
||||
SET `subdomains_used` = `subdomains_used` + 1
|
||||
WHERE `customerid` = :customerid"
|
||||
);
|
||||
Database::pexecute($stmt, array("customerid" => $userinfo['customerid']));
|
||||
|
||||
$log->logAction(USR_ACTION, LOG_INFO, "added subdomain '" . $completedomain . "'");
|
||||
inserttask('1');
|
||||
|
||||
// Using nameserver, insert a task which rebuilds the server config
|
||||
inserttask('4');
|
||||
|
||||
redirectTo($filename, array('page' => $page, 's' => $s));
|
||||
try {
|
||||
SubDomains::getLocal($userinfo, $_POST)->add();
|
||||
} catch (Exception $e) {
|
||||
dynamic_error($e->getMessage());
|
||||
}
|
||||
redirectTo($filename, array('page' => $page, 's' => $s));
|
||||
} else {
|
||||
$stmt = Database::prepare("SELECT `id`, `domain`, `documentroot`, `ssl_redirect`,`isemaildomain`,`letsencrypt` FROM `" . TABLE_PANEL_DOMAINS . "`
|
||||
WHERE `customerid` = :customerid
|
||||
|
@ -339,25 +339,25 @@ abstract class ApiCommand
|
||||
*/
|
||||
private function getModFunctionString()
|
||||
{
|
||||
$_c = get_called_class();
|
||||
$_class = get_called_class();
|
||||
|
||||
$level = 2;
|
||||
if (version_compare(PHP_VERSION, "5.4.0", "<")) {
|
||||
$t = debug_backtrace();
|
||||
$trace = debug_backtrace();
|
||||
} else {
|
||||
$t = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
|
||||
$trace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
|
||||
}
|
||||
while (true) {
|
||||
$c = $t[$level]['class'];
|
||||
$f = $t[$level]['function'];
|
||||
if ($c != get_called_class()) {
|
||||
$class = $trace[$level]['class'];
|
||||
$func = $trace[$level]['function'];
|
||||
if ($class != $_class) {
|
||||
$level ++;
|
||||
if ($level > 5) {
|
||||
break;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
return $c . ':' . $f;
|
||||
return $class . ':' . $func;
|
||||
}
|
||||
}
|
||||
|
||||
@ -426,6 +426,28 @@ abstract class ApiCommand
|
||||
return $json_response;
|
||||
}
|
||||
|
||||
/**
|
||||
* increase/decrease a resource field for customers/admins
|
||||
*
|
||||
* @param string $table
|
||||
* @param string $keyfield
|
||||
* @param int $key
|
||||
* @param string $op
|
||||
* @param string $resource
|
||||
* @param string $extra
|
||||
*/
|
||||
protected static function updateResourceUsage($table = null, $keyfield = null, $key = null, $op = '+', $resource = null, $extra = null)
|
||||
{
|
||||
$stmt = Database::prepare("
|
||||
UPDATE `" . $table . "`
|
||||
SET `" . $resource . "` = `" . $resource . "` " . $op . " 1 " . $extra . "
|
||||
WHERE `" . $keyfield . "` = :key
|
||||
");
|
||||
Database::pexecute($stmt, array(
|
||||
'key' => $key
|
||||
), true, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* read user data from database by api-request-header fields
|
||||
*
|
||||
|
@ -124,7 +124,7 @@ class Admins extends ApiCommand implements ResourceEntity
|
||||
$tickets_see_all = $this->getParam('tickets_see_all', true, 0);
|
||||
$caneditphpsettings = $this->getParam('caneditphpsettings', true, 0);
|
||||
$change_serversettings = $this->getParam('change_serversettings', true, 0);
|
||||
$ipaddress = $this->getParam('ipaddress', true, -1);
|
||||
$ipaddress = $this->getParam('ipaddress', true, - 1);
|
||||
|
||||
// validation
|
||||
$name = validate($name, 'name', '', '', array(), true);
|
||||
@ -244,7 +244,7 @@ class Admins extends ApiCommand implements ResourceEntity
|
||||
'tickets' => $tickets,
|
||||
'tickets_see_all' => $tickets_see_all,
|
||||
'mysqls' => $mysqls,
|
||||
'ip' => empty($ipaddress) ? "" : (is_array($ipaddress) && $ipaddress > 0 ? json_encode($ipaddress) : -1),
|
||||
'ip' => empty($ipaddress) ? "" : (is_array($ipaddress) && $ipaddress > 0 ? json_encode($ipaddress) : - 1),
|
||||
'theme' => $_theme,
|
||||
'custom_notes' => $custom_notes,
|
||||
'custom_notes_show' => $custom_notes_show
|
||||
@ -354,7 +354,7 @@ class Admins extends ApiCommand implements ResourceEntity
|
||||
$change_serversettings = $result['change_serversettings'];
|
||||
$diskspace = $result['diskspace'];
|
||||
$traffic = $result['traffic'];
|
||||
$ipaddress = ($result['ip'] != -1 ? json_decode($result['ip'], true) : -1);
|
||||
$ipaddress = ($result['ip'] != - 1 ? json_decode($result['ip'], true) : - 1);
|
||||
} else {
|
||||
$deactivated = $this->getParam('deactivated', true, $result['deactivated']);
|
||||
|
||||
@ -377,7 +377,7 @@ class Admins extends ApiCommand implements ResourceEntity
|
||||
$tickets_see_all = $this->getParam('tickets_see_all', true, $result['tickets_see_all']);
|
||||
$caneditphpsettings = $this->getParam('caneditphpsettings', true, $result['caneditphpsettings']);
|
||||
$change_serversettings = $this->getParam('change_serversettings', true, $result['change_serversettings']);
|
||||
$ipaddress = $this->getParam('ipaddress', true, ($result['ip'] != -1 ? json_decode($result['ip'], true) : -1));
|
||||
$ipaddress = $this->getParam('ipaddress', true, ($result['ip'] != - 1 ? json_decode($result['ip'], true) : - 1));
|
||||
|
||||
$diskspace = $diskspace * 1024;
|
||||
$traffic = $traffic * 1024 * 1024;
|
||||
@ -512,7 +512,7 @@ class Admins extends ApiCommand implements ResourceEntity
|
||||
'tickets' => $tickets,
|
||||
'tickets_see_all' => $tickets_see_all,
|
||||
'mysqls' => $mysqls,
|
||||
'ip' => empty($ipaddress) ? "" : (is_array($ipaddress) && $ipaddress > 0 ? json_encode($ipaddress) : -1),
|
||||
'ip' => empty($ipaddress) ? "" : (is_array($ipaddress) && $ipaddress > 0 ? json_encode($ipaddress) : - 1),
|
||||
'deactivated' => $deactivated,
|
||||
'custom_notes' => $custom_notes,
|
||||
'custom_notes_show' => $custom_notes_show,
|
||||
@ -684,4 +684,30 @@ class Admins extends ApiCommand implements ResourceEntity
|
||||
}
|
||||
throw new Exception("Not allowed to execute given command.", 403);
|
||||
}
|
||||
|
||||
/**
|
||||
* increase resource-usage
|
||||
*
|
||||
* @param int $customerid
|
||||
* @param string $resource
|
||||
* @param string $extra
|
||||
* optional, default empty
|
||||
*/
|
||||
public static function increaseUsage($adminid = 0, $resource = null, $extra = '')
|
||||
{
|
||||
self::updateResourceUsage(TABLE_PANEL_ADMINS, 'adminid', $adminid, '+', $resource, $extra);
|
||||
}
|
||||
|
||||
/**
|
||||
* decrease resource-usage
|
||||
*
|
||||
* @param int $customerid
|
||||
* @param string $resource
|
||||
* @param string $extra
|
||||
* optional, default empty
|
||||
*/
|
||||
public static function decreaseUsage($adminid = 0, $resource = null, $extra = '')
|
||||
{
|
||||
self::updateResourceUsage(TABLE_PANEL_ADMINS, 'adminid', $adminid, '-', $resource, $extra);
|
||||
}
|
||||
}
|
||||
|
@ -76,7 +76,7 @@ class Customers extends ApiCommand implements ResourceEntity
|
||||
$result_stmt = Database::prepare("
|
||||
SELECT `c`.*, `a`.`loginname` AS `adminname`
|
||||
FROM `" . TABLE_PANEL_CUSTOMERS . "` `c`, `" . TABLE_PANEL_ADMINS . "` `a`
|
||||
WHERE " . ($id > 0 ? "`c`.`customerid` = :idln" : "`c`.`loginname` = :idln") . ($this->getUserDetail('customers_see_all') ? '' : " AND `c`.`adminid` = :adminid"). " AND `c`.`adminid` = `a`.`adminid`");
|
||||
WHERE " . ($id > 0 ? "`c`.`customerid` = :idln" : "`c`.`loginname` = :idln") . ($this->getUserDetail('customers_see_all') ? '' : " AND `c`.`adminid` = :adminid") . " AND `c`.`adminid` = `a`.`adminid`");
|
||||
$params = array(
|
||||
'idln' => ($id <= 0 ? $loginname : $id)
|
||||
);
|
||||
@ -208,7 +208,7 @@ class Customers extends ApiCommand implements ResourceEntity
|
||||
if (((($this->getUserDetail('diskspace_used') + $diskspace) > $this->getUserDetail('diskspace')) && ($this->getUserDetail('diskspace') / 1024) != '-1') || ((($this->getUserDetail('mysqls_used') + $mysqls) > $this->getUserDetail('mysqls')) && $this->getUserDetail('mysqls') != '-1') || ((($this->getUserDetail('emails_used') + $emails) > $this->getUserDetail('emails')) && $this->getUserDetail('emails') != '-1') || ((($this->getUserDetail('email_accounts_used') + $email_accounts) > $this->getUserDetail('email_accounts')) && $this->getUserDetail('email_accounts') != '-1') || ((($this->getUserDetail('email_forwarders_used') + $email_forwarders) > $this->getUserDetail('email_forwarders')) && $this->getUserDetail('email_forwarders') != '-1') || ((($this->getUserDetail('email_quota_used') + $email_quota) > $this->getUserDetail('email_quota')) && $this->getUserDetail('email_quota') != '-1' && Settings::Get('system.mail_quota_enabled') == '1') || ((($this->getUserDetail('ftps_used') + $ftps) > $this->getUserDetail('ftps')) && $this->getUserDetail('ftps') != '-1') || ((($this->getUserDetail('tickets_used') + $tickets) > $this->getUserDetail('tickets')) && $this->getUserDetail('tickets') != '-1') || ((($this->getUserDetail('subdomains_used') + $subdomains) > $this->getUserDetail('subdomains')) && $this->getUserDetail('subdomains') != '-1') || (($diskspace / 1024) == '-1' && ($this->getUserDetail('diskspace') / 1024) != '-1') || ($mysqls == '-1' && $this->getUserDetail('mysqls') != '-1') || ($emails == '-1' && $this->getUserDetail('emails') != '-1') || ($email_accounts == '-1' && $this->getUserDetail('email_accounts') != '-1') || ($email_forwarders == '-1' && $this->getUserDetail('email_forwarders') != '-1') || ($email_quota == '-1' && $this->getUserDetail('email_quota') != '-1' && Settings::Get('system.mail_quota_enabled') == '1') || ($ftps == '-1' && $this->getUserDetail('ftps') != '-1') || ($tickets == '-1' && $this->getUserDetail('tickets') != '-1') || ($subdomains == '-1' && $this->getUserDetail('subdomains') != '-1')) {
|
||||
standard_error('youcantallocatemorethanyouhave', '', true);
|
||||
}
|
||||
|
||||
|
||||
if (! validateEmail($email)) {
|
||||
standard_error('emailiswrong', $email, true);
|
||||
} else {
|
||||
@ -755,10 +755,10 @@ class Customers extends ApiCommand implements ResourceEntity
|
||||
}
|
||||
|
||||
if ($this->isAdmin()) {
|
||||
|
||||
|
||||
$diskspace = $diskspace * 1024;
|
||||
$traffic = $traffic * 1024 * 1024;
|
||||
|
||||
|
||||
if (((($this->getUserDetail('diskspace_used') + $diskspace - $result['diskspace']) > $this->getUserDetail('diskspace')) && ($this->getUserDetail('diskspace') / 1024) != '-1') || ((($this->getUserDetail('mysqls_used') + $mysqls - $result['mysqls']) > $this->getUserDetail('mysqls')) && $this->getUserDetail('mysqls') != '-1') || ((($this->getUserDetail('emails_used') + $emails - $result['emails']) > $this->getUserDetail('emails')) && $this->getUserDetail('emails') != '-1') || ((($this->getUserDetail('email_accounts_used') + $email_accounts - $result['email_accounts']) > $this->getUserDetail('email_accounts')) && $this->getUserDetail('email_accounts') != '-1') || ((($this->getUserDetail('email_forwarders_used') + $email_forwarders - $result['email_forwarders']) > $this->getUserDetail('email_forwarders')) && $this->getUserDetail('email_forwarders') != '-1') || ((($this->getUserDetail('email_quota_used') + $email_quota - $result['email_quota']) > $this->getUserDetail('email_quota')) && $this->getUserDetail('email_quota') != '-1' && Settings::Get('system.mail_quota_enabled') == '1') || ((($this->getUserDetail('ftps_used') + $ftps - $result['ftps']) > $this->getUserDetail('ftps')) && $this->getUserDetail('ftps') != '-1') || ((($this->getUserDetail('tickets_used') + $tickets - $result['tickets']) > $this->getUserDetail('tickets')) && $this->getUserDetail('tickets') != '-1') || ((($this->getUserDetail('subdomains_used') + $subdomains - $result['subdomains']) > $this->getUserDetail('subdomains')) && $this->getUserDetail('subdomains') != '-1') || (($diskspace / 1024) == '-1' && ($this->getUserDetail('diskspace') / 1024) != '-1') || ($mysqls == '-1' && $this->getUserDetail('mysqls') != '-1') || ($emails == '-1' && $this->getUserDetail('emails') != '-1') || ($email_accounts == '-1' && $this->getUserDetail('email_accounts') != '-1') || ($email_forwarders == '-1' && $this->getUserDetail('email_forwarders') != '-1') || ($email_quota == '-1' && $this->getUserDetail('email_quota') != '-1' && Settings::Get('system.mail_quota_enabled') == '1') || ($ftps == '-1' && $this->getUserDetail('ftps') != '-1') || ($tickets == '-1' && $this->getUserDetail('tickets') != '-1') || ($subdomains == '-1' && $this->getUserDetail('subdomains') != '-1')) {
|
||||
standard_error('youcantallocatemorethanyouhave', '', true);
|
||||
}
|
||||
@ -1533,4 +1533,30 @@ class Customers extends ApiCommand implements ResourceEntity
|
||||
}
|
||||
throw new Exception("Not allowed to execute given command.", 403);
|
||||
}
|
||||
|
||||
/**
|
||||
* increase resource-usage
|
||||
*
|
||||
* @param int $customerid
|
||||
* @param string $resource
|
||||
* @param string $extra
|
||||
* optional, default empty
|
||||
*/
|
||||
public static function increaseUsage($customerid = 0, $resource = null, $extra = '')
|
||||
{
|
||||
self::updateResourceUsage(TABLE_PANEL_CUSTOMERS, 'customerid', $customerid, '+', $resource, $extra);
|
||||
}
|
||||
|
||||
/**
|
||||
* decrease resource-usage
|
||||
*
|
||||
* @param int $customerid
|
||||
* @param string $resource
|
||||
* @param string $extra
|
||||
* optional, default empty
|
||||
*/
|
||||
public static function decreaseUsage($customerid = 0, $resource = null, $extra = '')
|
||||
{
|
||||
self::updateResourceUsage(TABLE_PANEL_CUSTOMERS, 'customerid', $customerid, '-', $resource, $extra);
|
||||
}
|
||||
}
|
||||
|
@ -311,7 +311,7 @@ class Froxlor extends ApiCommand
|
||||
'type' => $r[1],
|
||||
'desc' => (isset($r[2]) ? trim($r[2]) : '')
|
||||
);
|
||||
}
|
||||
} // check throws-section
|
||||
elseif (! empty($c) && strpos($c, '@throws') === false) {
|
||||
if (substr($c, 0, 3) == "/**") {
|
||||
continue;
|
||||
|
@ -183,26 +183,14 @@ class Ftps extends ApiCommand implements ResourceEntity
|
||||
"guid" => $customer['guid']
|
||||
);
|
||||
Database::pexecute($stmt, $params, true, true);
|
||||
|
||||
// update customer usage
|
||||
Customers::increaseUsage($customer_id, 'ftps_used');
|
||||
Customers::increaseUsage($customer_id, 'ftp_lastaccountnumber');
|
||||
|
||||
$stmt = Database::prepare("
|
||||
UPDATE `" . TABLE_PANEL_CUSTOMERS . "`
|
||||
SET `ftps_used` = `ftps_used` + 1,
|
||||
`ftp_lastaccountnumber` = `ftp_lastaccountnumber` + 1
|
||||
WHERE `customerid` = :customerid
|
||||
");
|
||||
Database::pexecute($stmt, array(
|
||||
"customerid" => $customer_id
|
||||
), true, true);
|
||||
|
||||
$stmt = Database::prepare("
|
||||
UPDATE `" . TABLE_PANEL_ADMINS . "`
|
||||
SET `ftps_used` = `ftps_used` + 1
|
||||
WHERE `adminid` = :adminid
|
||||
");
|
||||
Database::pexecute($stmt, array(
|
||||
"adminid" => $customer['adminid']
|
||||
), true, true);
|
||||
|
||||
// update admin usage
|
||||
Admins::increaseUsage($customer['adminid'], 'ftps_used');
|
||||
|
||||
$this->logger()->logAction($this->isAdmin() ? ADM_ACTION : USR_ACTION, LOG_INFO, "[API] added ftp-account '" . $username . " (" . $path . ")'");
|
||||
inserttask(5);
|
||||
|
||||
@ -614,21 +602,9 @@ class Ftps extends ApiCommand implements ResourceEntity
|
||||
|
||||
// decrease ftp-user usage for customer
|
||||
$resetaccnumber = ($customer_data['ftps_used'] == '1') ? " , `ftp_lastaccountnumber`='0'" : '';
|
||||
$stmt = Database::prepare("UPDATE `" . TABLE_PANEL_CUSTOMERS . "`
|
||||
SET `ftps_used` = `ftps_used` - 1 $resetaccnumber
|
||||
WHERE `customerid` = :customerid");
|
||||
Database::pexecute($stmt, array(
|
||||
"customerid" => $customer_data['customerid']
|
||||
), true, true);
|
||||
Customers::decreaseUsage($customer_id, 'ftps_used', $resetaccnumber);
|
||||
// update admin usage
|
||||
$stmt = Database::prepare("
|
||||
UPDATE `" . TABLE_PANEL_ADMINS . "`
|
||||
SET `mysqls_used` = `mysqls_used` - 1
|
||||
WHERE `adminid` = :adminid
|
||||
");
|
||||
Database::pexecute($stmt, array(
|
||||
"adminid" => ($this->isAdmin() ? $customer_data['adminid'] : $this->getUserDetail('adminid'))
|
||||
), true, true);
|
||||
Admins::decreaseUsage(($this->isAdmin() ? $customer_data['adminid'] : $this->getUserDetail('adminid')), 'ftps_used');
|
||||
|
||||
$this->logger()->logAction($this->isAdmin() ? ADM_ACTION : USR_ACTION, LOG_WARNING, "[API] deleted ftp-user '" . $result['username'] . "'");
|
||||
return $this->response(200, "successfull", $result);
|
||||
|
@ -62,14 +62,7 @@ class Mysqls extends ApiCommand implements ResourceEntity
|
||||
if (! isset($sql_root) || ! is_array($sql_root)) {
|
||||
throw new ErrorException("Database server with index #" . $dbserver . " is unknown", 404);
|
||||
}
|
||||
|
||||
if ($password == '') {
|
||||
standard_error(array(
|
||||
'stringisempty',
|
||||
'mysql_password'
|
||||
), '', true);
|
||||
}
|
||||
|
||||
|
||||
if ($sendinfomail != 1) {
|
||||
$sendinfomail = 0;
|
||||
}
|
||||
@ -123,24 +116,11 @@ class Mysqls extends ApiCommand implements ResourceEntity
|
||||
$params['id'] = $databaseid;
|
||||
|
||||
// update customer usage
|
||||
$stmt = Database::prepare("
|
||||
UPDATE `" . TABLE_PANEL_CUSTOMERS . "`
|
||||
SET `mysqls_used` = `mysqls_used` + 1, `mysql_lastaccountnumber` = `mysql_lastaccountnumber` + 1
|
||||
WHERE `customerid` = :customerid
|
||||
");
|
||||
Database::pexecute($stmt, array(
|
||||
"customerid" => ($this->isAdmin() ? $customer['customerid'] : $this->getUserDetail('customerid'))
|
||||
), true, true);
|
||||
Customers::increaseUsage(($this->isAdmin() ? $customer['customerid'] : $this->getUserDetail('customerid')), 'mysqls_used');
|
||||
Customers::increaseUsage(($this->isAdmin() ? $customer['customerid'] : $this->getUserDetail('customerid')), 'mysql_lastaccountnumber');
|
||||
|
||||
// update admin usage
|
||||
$stmt = Database::prepare("
|
||||
UPDATE `" . TABLE_PANEL_ADMINS . "`
|
||||
SET `mysqls_used` = `mysqls_used` + 1
|
||||
WHERE `adminid` = :adminid
|
||||
");
|
||||
Database::pexecute($stmt, array(
|
||||
"adminid" => $this->getUserDetail('adminid')
|
||||
), true, true);
|
||||
Admins::increaseUsage($this->getUserDetail('adminid'), 'mysqls_used');
|
||||
|
||||
// send info-mail?
|
||||
if ($sendinfomail == 1) {
|
||||
@ -586,23 +566,9 @@ class Mysqls extends ApiCommand implements ResourceEntity
|
||||
}
|
||||
// reduce mysql-usage-counter
|
||||
$resetaccnumber = ($mysql_used == '1') ? " , `mysql_lastaccountnumber` = '0' " : '';
|
||||
$stmt = Database::prepare("
|
||||
UPDATE `" . TABLE_PANEL_CUSTOMERS . "`
|
||||
SET `mysqls_used` = `mysqls_used` - 1 " . $resetaccnumber . "
|
||||
WHERE `customerid` = :customerid
|
||||
");
|
||||
Database::pexecute($stmt, array(
|
||||
"customerid" => $customer_id
|
||||
), true, true);
|
||||
Customers::decreaseUsage($customer_id, 'mysqls_used', $resetaccnumber);
|
||||
// update admin usage
|
||||
$stmt = Database::prepare("
|
||||
UPDATE `" . TABLE_PANEL_ADMINS . "`
|
||||
SET `mysqls_used` = `mysqls_used` - 1
|
||||
WHERE `adminid` = :adminid
|
||||
");
|
||||
Database::pexecute($stmt, array(
|
||||
"adminid" => ($this->isAdmin() ? $customer['adminid'] : $this->getUserDetail('adminid')),
|
||||
), true, true);
|
||||
Admins::decreaseUsage(($this->isAdmin() ? $customer['adminid'] : $this->getUserDetail('adminid')), 'mysqls_used');
|
||||
|
||||
$this->logger()->logAction($this->isAdmin() ? ADM_ACTION : USR_ACTION, LOG_WARNING, "[API] deleted database '" . $result['databasename'] . "'");
|
||||
return $this->response(200, "successfull", $result);
|
||||
|
@ -18,9 +18,318 @@
|
||||
class Subdomains extends ApiCommand implements ResourceEntity
|
||||
{
|
||||
|
||||
/**
|
||||
* add a new subdomain
|
||||
*
|
||||
* @param string $subdomain
|
||||
* part before domain.tld to create as subdomain
|
||||
* @param string $domain
|
||||
* domainname of main-domain
|
||||
* @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 string $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 $customer_id
|
||||
* required when called as admin, not needed when called as customer
|
||||
*
|
||||
* @access admin, customer
|
||||
* @throws Exception
|
||||
* @return array
|
||||
*/
|
||||
public function add()
|
||||
{
|
||||
throw new Exception("Not available yet.", 501);
|
||||
if ($this->getUserDetail('subdomains_used') < $this->getUserDetail('subdomains') || $this->getUserDetail('subdomains') == '-1') {
|
||||
// parameters
|
||||
$subdomain = $this->getParam('subdomain');
|
||||
$domain = $this->getParam('domain');
|
||||
|
||||
// optional parameters
|
||||
$aliasdomain = $this->getParam('alias', true, 0);
|
||||
$path = $this->getParam('path', true, '');
|
||||
$url = $this->getParam('url', true, '');
|
||||
$openbasedir_path = $this->getParam('openbasedir_path', true, 1);
|
||||
$phpsettingid = $this->getParam('phpsettingid', true, 0);
|
||||
$redirectcode = $this->getParam('redirectcode', true, Settings::Get('customredirect.default'));
|
||||
if (Settings::Get('system.use_ssl')) {
|
||||
$ssl_redirect = $this->getParam('ssl_redirect', true, 0);
|
||||
$letsencrypt = $this->getParam('letsencrypt', true, 0);
|
||||
$hsts_maxage = $this->getParam('hsts_maxage', true, 0);
|
||||
$hsts_sub = $this->getParam('hsts_sub', true, 0);
|
||||
$hsts_preload = $this->getParam('hsts_preload', true, 0);
|
||||
} else {
|
||||
$ssl_redirect = 0;
|
||||
$letsencrypt = 0;
|
||||
$hsts_maxage = 0;
|
||||
$hsts_sub = 0;
|
||||
$hsts_preload = 0;
|
||||
}
|
||||
|
||||
// get needed customer info to reduce the mysql-usage-counter by one
|
||||
if ($this->isAdmin()) {
|
||||
// get customer id
|
||||
$customer_id = $this->getParam('customer_id');
|
||||
$json_result = Customers::getLocal($this->getUserData(), array(
|
||||
'id' => $customer_id
|
||||
))->get();
|
||||
$customer = json_decode($json_result, true)['data'];
|
||||
// check whether the customer has enough resources to get the subdomain added
|
||||
if ($customer['subdomains_used'] >= $customer['subdomains'] && $customer['subdomains'] != '-1') {
|
||||
throw new Exception("Customer has no more resources available", 406);
|
||||
}
|
||||
} else {
|
||||
$customer_id = $this->getUserDetail('customerid');
|
||||
$customer = $this->getUserData();
|
||||
}
|
||||
|
||||
// validation
|
||||
if (substr($subdomain, 0, 4) == 'xn--') {
|
||||
standard_error('domain_nopunycode', '', true);
|
||||
}
|
||||
|
||||
$idna_convert = new idna_convert_wrapper();
|
||||
$subdomain = $idna_convert->encode(preg_replace(array(
|
||||
'/\:(\d)+$/',
|
||||
'/^https?\:\/\//'
|
||||
), '', validate($subdomain, 'subdomain', '', 'subdomainiswrong', array(), true)));
|
||||
|
||||
// merge the two parts together
|
||||
$completedomain = $subdomain . '.' . $domain;
|
||||
|
||||
if (Settings::Get('system.validate_domain') && ! validateDomain($completedomain)) {
|
||||
standard_error(array(
|
||||
'stringiswrong',
|
||||
'mydomain'
|
||||
), '', true);
|
||||
}
|
||||
if ($completedomain == Settings::Get('system.hostname')) {
|
||||
standard_error('admin_domain_emailsystemhostname', '', true);
|
||||
}
|
||||
|
||||
// check whether the domain already exists
|
||||
try {
|
||||
$json_result = SubDomains::getLocal($this->getUserData(), array(
|
||||
'domainname' => $completedomain
|
||||
))->get();
|
||||
// no exception so far - domain exists
|
||||
standard_error('domainexistalready', $completedomain, true);
|
||||
} catch (Exception $e) {
|
||||
// all good, domain does not exist
|
||||
}
|
||||
|
||||
// alias domain checked?
|
||||
if ($aliasdomain != 0) {
|
||||
// also check ip/port combination to be the same, #176
|
||||
$aliasdomain_stmt = Database::prepare("
|
||||
SELECT `d`.`id` FROM `" . TABLE_PANEL_DOMAINS . "` `d` , `" . TABLE_PANEL_CUSTOMERS . "` `c` , `" . TABLE_DOMAINTOIP . "` `dip`
|
||||
WHERE `d`.`aliasdomain` IS NULL
|
||||
AND `d`.`id` = :id
|
||||
AND `c`.`standardsubdomain` <> `d`.`id`
|
||||
AND `d`.`customerid` = :customerid
|
||||
AND `c`.`customerid` = `d`.`customerid`
|
||||
AND `d`.`id` = `dip`.`id_domain`
|
||||
AND `dip`.`id_ipandports`
|
||||
IN (SELECT `id_ipandports` FROM `" . TABLE_DOMAINTOIP . "` WHERE `id_domain` = :id )
|
||||
GROUP BY `d`.`domain`
|
||||
ORDER BY `d`.`domain` ASC
|
||||
");
|
||||
$aliasdomain_check = Database::pexecute_first($aliasdomain_stmt, array(
|
||||
"id" => $aliasdomain,
|
||||
"customerid" => $customer_id
|
||||
), true, true);
|
||||
if ($aliasdomain_check['id'] != $aliasdomain) {
|
||||
standard_error('domainisaliasorothercustomer', '', true);
|
||||
}
|
||||
triggerLetsEncryptCSRForAliasDestinationDomain($aliasdomain, $this->logger());
|
||||
}
|
||||
|
||||
// check whether an URL was specified
|
||||
$_doredirect = false;
|
||||
if (! empty($url) && validateUrl($url)) {
|
||||
$path = $url;
|
||||
$_doredirect = true;
|
||||
} else {
|
||||
$path = validate($path, 'path', '', '', array(), true);
|
||||
}
|
||||
|
||||
// check whether path is a real path
|
||||
if (! preg_match('/^https?\:\/\//', $path) || ! validateUrl($path)) {
|
||||
if (strstr($path, ":") !== false) {
|
||||
standard_error('pathmaynotcontaincolon', '', true);
|
||||
}
|
||||
// If path is empty or '/' and 'Use domain name as default value for DocumentRoot path' is enabled in settings,
|
||||
// set default path to subdomain or domain name
|
||||
if ((($path == '') || ($path == '/')) && Settings::Get('system.documentroot_use_default_value') == 1) {
|
||||
$path = makeCorrectDir($customer['documentroot'] . '/' . $completedomain);
|
||||
} else {
|
||||
$path = makeCorrectDir($customer['documentroot'] . '/' . $path);
|
||||
}
|
||||
} else {
|
||||
// no it's not, create a redirect
|
||||
$_doredirect = true;
|
||||
}
|
||||
|
||||
if ($openbasedir_path != 1) {
|
||||
$openbasedir_path = 0;
|
||||
}
|
||||
|
||||
// get main domain for various checks
|
||||
$domain_stmt = Database::prepare("
|
||||
SELECT * FROM `" . TABLE_PANEL_DOMAINS . "`
|
||||
WHERE `domain` = :domain
|
||||
AND `customerid` = :customerid
|
||||
AND `parentdomainid` = '0'
|
||||
AND `email_only` = '0'
|
||||
AND `caneditdomain` = '1'
|
||||
");
|
||||
$domain_check = Database::pexecute_first($domain_stmt, array(
|
||||
"domain" => $domain,
|
||||
"customerid" => $customer['customerid']
|
||||
), true, true);
|
||||
|
||||
if (! $domain_check) {
|
||||
// the given main-domain
|
||||
standard_error('maindomainnonexist', $domain, true);
|
||||
} elseif ($subdomain == 'www' && $domain_check['wwwserveralias'] == '1') {
|
||||
// you cannot add 'www' as subdomain when the maindomain generates a www-alias
|
||||
standard_error('wwwnotallowed', '', true);
|
||||
} elseif (strtolower($completedomain_check['domain']) == strtolower($completedomain)) {
|
||||
// the domain does already exist as main-domain
|
||||
standard_error('domainexistalready', $completedomain, true);
|
||||
}
|
||||
|
||||
if ($ssl_redirect != 0) {
|
||||
// a ssl-redirect only works if there actually is a
|
||||
// ssl ip/port assigned to the domain
|
||||
if (domainHasSslIpPort($domain_check['id']) == true) {
|
||||
$ssl_redirect = '1';
|
||||
$_doredirect = true;
|
||||
} else {
|
||||
standard_error('sslredirectonlypossiblewithsslipport', '', true);
|
||||
}
|
||||
}
|
||||
|
||||
if ($letsencrypt != 0) {
|
||||
// let's encrypt only works if there actually is a
|
||||
// ssl ip/port assigned to the domain
|
||||
if (domainHasSslIpPort($domain_check['id']) == true) {
|
||||
$letsencrypt = '1';
|
||||
} else {
|
||||
standard_error('letsencryptonlypossiblewithsslipport', '', true);
|
||||
}
|
||||
}
|
||||
|
||||
// Temporarily deactivate ssl_redirect until Let's Encrypt certificate was generated
|
||||
if ($ssl_redirect > 0 && $letsencrypt == 1) {
|
||||
$ssl_redirect = 2;
|
||||
}
|
||||
|
||||
// get the phpsettingid from parentdomain, #107
|
||||
$phpsid_stmt = Database::prepare("
|
||||
SELECT `phpsettingid` FROM `" . TABLE_PANEL_DOMAINS . "` WHERE `id` = :id
|
||||
");
|
||||
$phpsid_result = Database::pexecute_first($phpsid_stmt, array(
|
||||
"id" => $domain_check['id']
|
||||
), true, true);
|
||||
|
||||
if (! isset($phpsid_result['phpsettingid']) || (int) $phpsid_result['phpsettingid'] <= 0) {
|
||||
// assign default config
|
||||
$phpsid_result['phpsettingid'] = 1;
|
||||
}
|
||||
// check whether the customer has chosen its own php-config
|
||||
if ($phpsettingid > 0 && $phpsettingid != $phpsid_result['phpsettingid']) {
|
||||
$phpsid_result['phpsettingid'] = intval($phpsettingid);
|
||||
}
|
||||
|
||||
// acutall insert domain
|
||||
$stmt = Database::prepare("
|
||||
INSERT INTO `" . TABLE_PANEL_DOMAINS . "` SET
|
||||
`customerid` = :customerid,
|
||||
`domain` = :domain,
|
||||
`documentroot` = :documentroot,
|
||||
`aliasdomain` = :aliasdomain,
|
||||
`parentdomainid` = :parentdomainid,
|
||||
`wwwserveralias` = :wwwserveralias,
|
||||
`isemaildomain` = :isemaildomain,
|
||||
`iswildcarddomain` = :iswildcarddomain,
|
||||
`phpenabled` = :phpenabled,
|
||||
`openbasedir` = :openbasedir,
|
||||
`openbasedir_path` = :openbasedir_path,
|
||||
`speciallogfile` = :speciallogfile,
|
||||
`specialsettings` = :specialsettings,
|
||||
`ssl_redirect` = :ssl_redirect,
|
||||
`phpsettingid` = :phpsettingid,
|
||||
`letsencrypt` = :letsencrypt,
|
||||
`hsts` = :hsts,
|
||||
`hsts_sub` = :hsts_sub,
|
||||
`hsts_preload` = :hsts_preload
|
||||
");
|
||||
$params = array(
|
||||
"customerid" => $customer['customerid'],
|
||||
"domain" => $completedomain,
|
||||
"documentroot" => $path,
|
||||
"aliasdomain" => $aliasdomain != 0 ? $aliasdomain : null,
|
||||
"parentdomainid" => $domain_check['id'],
|
||||
"wwwserveralias" => $domain_check['wwwserveralias'] == '1' ? '1' : '0',
|
||||
"iswildcarddomain" => $domain_check['iswildcarddomain'] == '1' ? '1' : '0',
|
||||
"isemaildomain" => $domain_check['subcanemaildomain'] == '3' ? '1' : '0',
|
||||
"openbasedir" => $domain_check['openbasedir'],
|
||||
"openbasedir_path" => $openbasedir_path,
|
||||
"phpenabled" => $domain_check['phpenabled'],
|
||||
"speciallogfile" => $domain_check['speciallogfile'],
|
||||
"specialsettings" => $domain_check['specialsettings'],
|
||||
"ssl_redirect" => $ssl_redirect,
|
||||
"phpsettingid" => $phpsid_result['phpsettingid'],
|
||||
"letsencrypt" => $letsencrypt,
|
||||
"hsts" => $hsts_maxage,
|
||||
"hsts_sub" => $hsts_sub,
|
||||
"hsts_preload" => $hsts_preload
|
||||
);
|
||||
Database::pexecute($stmt, $params, true, true);
|
||||
$subdomain_id = Database::lastInsertId();
|
||||
|
||||
$stmt = Database::prepare("
|
||||
INSERT INTO `" . TABLE_DOMAINTOIP . "`
|
||||
(`id_domain`, `id_ipandports`)
|
||||
SELECT LAST_INSERT_ID(), `id_ipandports`
|
||||
FROM `" . TABLE_DOMAINTOIP . "`
|
||||
WHERE `id_domain` = :id_domain
|
||||
");
|
||||
Database::pexecute($stmt, array(
|
||||
"id_domain" => $domain_check['id']
|
||||
));
|
||||
|
||||
if ($_doredirect) {
|
||||
addRedirectToDomain($subdomain_id, $redirectcode);
|
||||
}
|
||||
|
||||
inserttask('1');
|
||||
// Using nameserver, insert a task which rebuilds the server config
|
||||
inserttask('4');
|
||||
|
||||
Customers::increaseUsage($customer['customerid'], '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 . "'");
|
||||
|
||||
$json_result = Subdomains::getLocal($this->getUserData(), array(
|
||||
'id' => $subdomain_id
|
||||
))->get();
|
||||
$result = json_decode($json_result, true)['data'];
|
||||
return $this->response(200, "successfull", $result);
|
||||
}
|
||||
throw new Exception("No more resources available", 406);
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user