Skip to content

Commit be38365

Browse files
author
Dominik
committed
Posibility to change main-domain of aps-instance over remote (in interface maindomain is always the websites domain but over remote it's now possible to set an alias oder subdomain, that will be used in instance-settings. Important if e.g. wordpress-installation should run unter an aliasdomain instead of the websites domain)
1 parent 982cb63 commit be38365

File tree

2 files changed

+24
-7
lines changed

2 files changed

+24
-7
lines changed

interface/lib/classes/aps_guicontroller.inc.php

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,17 @@ public function __construct($app)
4343
parent::__construct($app);
4444
}
4545

46-
46+
/**
47+
* Removes www from Domains name
48+
*
49+
* @param $filename the file to read
50+
* @return $sxe a SimpleXMLElement handle
51+
*/
52+
public function getMainDomain($domain) {
53+
if (substr($domain, 0, 4) == 'www.') $domain = substr($domain, 4);
54+
return $domain;
55+
}
56+
4757

4858
/**
4959
* Reads in a package metadata file and registers it's namespaces
@@ -344,9 +354,9 @@ public function createPackageInstance($settings, $packageid)
344354
$app->uses('tools_sites');
345355

346356
$webserver_id = 0;
347-
$websrv = $app->db->queryOneRecord("SELECT * FROM web_domain WHERE domain = ?", $settings['main_domain']);
357+
$websrv = $app->db->queryOneRecord("SELECT * FROM web_domain WHERE domain = ?", $this->getMainDomain($settings['main_domain']));
348358
if(!empty($websrv)) $webserver_id = $websrv['server_id'];
349-
$customerid = $this->getCustomerIDFromDomain($settings['main_domain']);
359+
$customerid = $this->getCustomerIDFromDomain($this->getMainDomain($settings['main_domain']));
350360

351361
if(empty($settings) || empty($webserver_id)) return false;
352362

@@ -565,13 +575,13 @@ public function validateInstallerInput($postinput, $pkg_details, $domains, $sett
565575
if(in_array($postinput['main_domain'], $domains))
566576
{
567577
$docroot = $app->db->queryOneRecord("SELECT document_root FROM web_domain
568-
WHERE domain = ?", $postinput['main_domain']);
578+
WHERE domain = ?", $this->getMainDomain($postinput['main_domain']));
569579
$new_path = $docroot['document_root'];
570580
if(substr($new_path, -1) != '/') $new_path .= '/';
571581
$new_path .= $main_location;
572582

573583
// Get the $customerid which belongs to the selected domain
574-
$customerid = $this->getCustomerIDFromDomain($postinput['main_domain']);
584+
$customerid = $this->getCustomerIDFromDomain($this->getMainDomain($postinput['main_domain']));
575585

576586
// First get all domains used for an install, then their loop them
577587
// and get the corresponding document roots as well as the defined

interface/lib/classes/remote.d/aps.inc.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -273,8 +273,15 @@ public function sites_aps_install_package($session_id, $primary_id, $params)
273273
return false;
274274
}
275275

276-
$sql = "SELECT * FROM web_domain WHERE domain = ?";
277-
$domain = $app->db->queryOneRecord($sql, $params['main_domain']);
276+
if (substr($params['main_domain'], 0, 4) == 'www.') {
277+
$domain = substr($params['main_domain'], 4);
278+
$sql = "SELECT * FROM web_domain WHERE domain = ? AND subdomain=?";
279+
$domain = $app->db->queryOneRecord($sql, $domain, 'www');
280+
}
281+
else {
282+
$sql = "SELECT * FROM web_domain WHERE domain = ?";
283+
$domain = $app->db->queryOneRecord($sql, $params['main_domain']);
284+
}
278285

279286
if (!$domain) {
280287
$this->server->fault('invalid parameters', 'No valid domain given.');

0 commit comments

Comments
 (0)