Dominik
2015-12-29 be38365f1c892c99914c408e3a1d8c396a31663e
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)
2 files modified
25 ■■■■ changed files
interface/lib/classes/aps_guicontroller.inc.php 18 ●●●● patch | view | raw | blame | history
interface/lib/classes/remote.d/aps.inc.php 7 ●●●●● patch | view | raw | blame | history
interface/lib/classes/aps_guicontroller.inc.php
@@ -43,6 +43,16 @@
        parent::__construct($app);
    }
    /**
     * Removes www from Domains name
     *
     * @param $filename the file to read
     * @return $sxe a SimpleXMLElement handle
     */
    public function getMainDomain($domain) {
        if (substr($domain, 0, 4) == 'www.') $domain = substr($domain, 4);
        return $domain;
    }
    /**
@@ -344,9 +354,9 @@
        $app->uses('tools_sites');
        $webserver_id = 0;
        $websrv = $app->db->queryOneRecord("SELECT * FROM web_domain WHERE domain = ?", $settings['main_domain']);
        $websrv = $app->db->queryOneRecord("SELECT * FROM web_domain WHERE domain = ?", $this->getMainDomain($settings['main_domain']));
        if(!empty($websrv)) $webserver_id = $websrv['server_id'];
        $customerid = $this->getCustomerIDFromDomain($settings['main_domain']);
        $customerid = $this->getCustomerIDFromDomain($this->getMainDomain($settings['main_domain']));
        if(empty($settings) || empty($webserver_id)) return false;
@@ -565,13 +575,13 @@
            if(in_array($postinput['main_domain'], $domains))
            {
                $docroot = $app->db->queryOneRecord("SELECT document_root FROM web_domain
                    WHERE domain = ?", $postinput['main_domain']);
                    WHERE domain = ?", $this->getMainDomain($postinput['main_domain']));
                $new_path = $docroot['document_root'];
                if(substr($new_path, -1) != '/') $new_path .= '/';
                $new_path .= $main_location;
                // Get the $customerid which belongs to the selected domain
                $customerid = $this->getCustomerIDFromDomain($postinput['main_domain']);
                $customerid = $this->getCustomerIDFromDomain($this->getMainDomain($postinput['main_domain']));
                // First get all domains used for an install, then their loop them
                // and get the corresponding document roots as well as the defined
interface/lib/classes/remote.d/aps.inc.php
@@ -273,8 +273,15 @@
            return false;
        }
    
        if (substr($params['main_domain'], 0, 4) == 'www.') {
            $domain = substr($params['main_domain'], 4);
            $sql = "SELECT * FROM web_domain WHERE domain = ? AND subdomain=?";
            $domain = $app->db->queryOneRecord($sql, $domain, 'www');
        }
        else {
        $sql = "SELECT * FROM web_domain WHERE domain = ?";
        $domain = $app->db->queryOneRecord($sql, $params['main_domain']);
        }
    
        if (!$domain) {
            $this->server->fault('invalid parameters', 'No valid domain given.');