summaryrefslogtreecommitdiff
path: root/classes/Status_network.php
diff options
context:
space:
mode:
Diffstat (limited to 'classes/Status_network.php')
-rw-r--r--classes/Status_network.php28
1 files changed, 28 insertions, 0 deletions
diff --git a/classes/Status_network.php b/classes/Status_network.php
index bf05ad61e..eef27d765 100644
--- a/classes/Status_network.php
+++ b/classes/Status_network.php
@@ -61,6 +61,9 @@ class Status_network extends DB_DataObject
}
if (!empty($sn)) {
+ if (!empty($sn->hostname) && 0 != strcasecmp($sn->hostname, $servername)) {
+ $sn->redirectToHostname();
+ }
$dbhost = (empty($sn->dbhost)) ? 'localhost' : $sn->dbhost;
$dbuser = (empty($sn->dbuser)) ? $sn->nickname : $sn->dbuser;
$dbpass = $sn->dbpass;
@@ -82,4 +85,29 @@ class Status_network extends DB_DataObject
return null;
}
}
+
+ // Code partially mooked from http://www.richler.de/en/php-redirect/
+ // (C) 2006 by Heiko Richler http://www.richler.de/
+ // LGPL
+
+ function redirectToHostname()
+ {
+ $destination = 'http://'.$this->hostname;
+ $destination .= $_SERVER['REQUEST_URI'].
+ $_SERVER['QUERY_STRING'];
+
+ $old = 'http'.
+ (($_SERVER['HTTPS'] == 'on') ? 'S' : '').
+ '://'.
+ $_SERVER['HTTP_HOST'].
+ $_SERVER['REQUEST_URI'].
+ $_SERVER['QUERY_STRING'];
+ if ($old == $destination) { // this would be a loop!
+ // error_log(...) ?
+ return false;
+ }
+
+ common_redirect($destination, 301);
+ // shouldn't get here
+ }
}