From b52434c188e56ee12f7c1823876ce8ae064854e3 Mon Sep 17 00:00:00 2001 From: alec Date: Tue, 13 Oct 2009 08:40:21 +0000 Subject: - Option 'force_https' replaced by 'force_https' plugin - added option 'force_https_port' in 'force_https' plugin (#1486091) git-svn-id: https://svn.roundcube.net/trunk@3038 208e9e7b-5314-0410-a742-e7e81cd9613c --- roundcubemail/plugins/force_https/force_https.php | 38 +++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 roundcubemail/plugins/force_https/force_https.php (limited to 'roundcubemail/plugins/force_https') diff --git a/roundcubemail/plugins/force_https/force_https.php b/roundcubemail/plugins/force_https/force_https.php new file mode 100644 index 000000000..67552570e --- /dev/null +++ b/roundcubemail/plugins/force_https/force_https.php @@ -0,0 +1,38 @@ + + */ +class force_https extends rcube_plugin +{ + function init() + { + $this->add_hook('startup', array($this, 'redirect')); + } + + function redirect($args) + { + $config = rcmail::get_instance()->config; + + $port = (int) $config->get('force_https_port', 443); + + // check if https is required (for login) and redirect if necessary + if (empty($_SESSION['user_id']) && !$config->get('use_https') + && (!isset($_SERVER['HTTPS']) || $_SERVER['SERVER_PORT'] != $port)) + { + header('Location: https://' . $_SERVER['HTTP_HOST'] . ($port != 443 ? ":$port" : '') . $_SERVER['REQUEST_URI']); + exit; + } + + return $args; + } +} + +?> -- cgit v1.2.3