Fix baseurl for images and javascript
[banana.git] / banana / page.inc.php
index 883865c..7d313ef 100644 (file)
@@ -7,7 +7,9 @@
 * Copyright: See COPYING files that comes with this distribution
 ********************************************************************************/
 
-require_once 'smarty/libs/Smarty.class.php';
+if (!include_once('Smarty.class.php')) {
+    require_once 'smarty/libs/Smarty.class.php';
+}
 
 class BananaPage extends Smarty
 {
@@ -228,7 +230,7 @@ class BananaPage extends Smarty
             return $res;
         }   
         $proto = empty($_SERVER['HTTPS']) ? 'http://' : 'https://';
-        $host  = $_SERVER['HTTP_HOST'];
+        $host  = Banana::$baseurl ? Banana::$baseurl : $_SERVER['SERVER_NAME'];
         $file  = $_SERVER['PHP_SELF'];
     
         if (count($params) != 0) {
@@ -320,7 +322,7 @@ class BananaPage extends Smarty
         }
 
         $proto = empty($_SERVER['HTTPS']) ? 'http://' : 'https://';
-        $host  = $_SERVER['HTTP_HOST'];
+        $host  = Banana::$baseurl ? Banana::$baseurl : $_SERVER['SERVER_NAME'];
         $file  = dirname($_SERVER['PHP_SELF']) . '/img/' . $img;
         $url   = $proto . $host . $file;
 
@@ -342,7 +344,7 @@ class BananaPage extends Smarty
         }
 
         $proto = empty($_SERVER['HTTPS']) ? 'http://' : 'https://';
-        $host  = $_SERVER['HTTP_HOST'];
+        $host  = Banana::$baseurl ? Banana::$baseurl : $_SERVER['SERVER_NAME'];
         $file  = dirname($_SERVER['PHP_SELF']) . '/javascript/' . $src . '.js';
         $url   = $proto . $host . $file;