]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
redirect to sitename.wildcard for SSL
authorEvan Prodromou <evan@status.net>
Sun, 10 Jan 2010 00:19:45 +0000 (16:19 -0800)
committerEvan Prodromou <evan@status.net>
Sun, 10 Jan 2010 00:19:45 +0000 (16:19 -0800)
classes/Status_network.php

index b3117640d843645553c6c74c8a8e576b08a1814e..8dff879dfeb42d59ea2a2b98c52ffe2a49bfc531 100644 (file)
@@ -150,9 +150,18 @@ class Status_network extends DB_DataObject
         }
 
         if (!empty($sn)) {
-            if (!empty($sn->hostname) && 0 != strcasecmp($sn->hostname, $servername)) {
-                $sn->redirectToHostname();
+
+            // Redirect to the right URL
+
+            if (!empty($sn->hostname) &&
+                empty($SERVER['HTTPS']) &&
+                0 != strcasecmp($sn->hostname, $servername)) {
+                $sn->redirectTo('http://'.$sn->hostname.$_SERVER['REQUEST_URI']);
+            } else if (!empty($SERVER['HTTPS']) &&
+                       0 != strcasecmp($sn->sitename.'.'.$wildcard, $servername)) {
+                $sn->redirectTo('https://'.$sn->sitename.'.'.$wildcard.$_SERVER['REQUEST_URI']);
             }
+
             $dbhost = (empty($sn->dbhost)) ? 'localhost' : $sn->dbhost;
             $dbuser = (empty($sn->dbuser)) ? $sn->nickname : $sn->dbuser;
             $dbpass = $sn->dbpass;
@@ -179,11 +188,8 @@ class Status_network extends DB_DataObject
     // (C) 2006 by Heiko Richler  http://www.richler.de/
     // LGPL
 
-    function redirectToHostname()
+    function redirectTo($destination)
     {
-        $destination = 'http://'.$this->hostname;
-        $destination .= $_SERVER['REQUEST_URI'];
-
         $old = 'http'.
           (($_SERVER['HTTPS'] == 'on') ? 'S' : '').
           '://'.