From 0ea079d604ef1f34cc47646ab23176a3c66f16ee Mon Sep 17 00:00:00 2001
From: Aleksander Machniak <alec@alec.pl>
Date: Mon, 13 Oct 2014 08:41:55 -0400
Subject: [PATCH] dirname(__FILE__) -> __DIR__

---
 program/include/rcmail.php |   35 ++++++++++++++---------------------
 1 files changed, 14 insertions(+), 21 deletions(-)

diff --git a/program/include/rcmail.php b/program/include/rcmail.php
index 52b53e9..221b50a 100644
--- a/program/include/rcmail.php
+++ b/program/include/rcmail.php
@@ -116,11 +116,13 @@
             $_SESSION['task'] = $this->task;
         }
 
-        // init output class
-        if (!empty($_REQUEST['_remote']))
+        // init output class (not in CLI mode)
+        if (!empty($_REQUEST['_remote'])) {
             $GLOBALS['OUTPUT'] = $this->json_init();
-        else
+        }
+        else if ($_SERVER['REMOTE_ADDR']) {
             $GLOBALS['OUTPUT'] = $this->load_gui(!empty($_REQUEST['_framed']));
+        }
 
         // load plugins
         $this->plugins->init($this, $this->task);
@@ -827,26 +829,17 @@
         }
 
         if ($absolute || $full) {
-            $prefix = '';
-
-            // prepend protocol://hostname:port
-            if ($full) {
-                $schema = 'http';
-                $default_port = 80;
-                if (rcube_utils::https_check()) {
-                    $schema = 'https';
-                    $default_port = 443;
-                }
-                $prefix = $schema . '://' . preg_replace('/:\d+$/', '', $_SERVER['HTTP_HOST']);
-                if ($_SERVER['SERVER_PORT'] != $default_port) {
-                  $prefix .= ':' . $_SERVER['SERVER_PORT'];
-                }
-            }
-
             // add base path to this Roundcube installation
             $base_path = preg_replace('![^/]+$!', '', strval($_SERVER['SCRIPT_NAME']));
             if ($base_path == '') $base_path = '/';
-            $prefix .= $base_path;
+            $prefix = $base_path;
+
+            // prepend protocol://hostname:port
+            if ($full) {
+                $prefix = rcube_utils::resolve_url($prefix);
+            }
+
+            $prefix = rtrim($prefix, '/') . '/';
         }
         else {
             $prefix = './';
@@ -1809,7 +1802,7 @@
             $error = 'errorreadonly';
         }
         else if ($res_code == rcube_storage::OVERQUOTA) {
-            $error = 'errorroverquota';
+            $error = 'erroroverquota';
         }
         else if ($err_code && ($err_str = $this->storage->get_error_str())) {
             // try to detect access rights problem and display appropriate message

--
Gitblit v1.9.1