}
/**
- * Throws exception if not using a secure connection.
- *
- * @throws Horde_Exception
- */
- public function requireSecureConnection()
- {
- if ($GLOBALS['browser']->usingSSLConnection()) {
- return;
- }
-
- if (!empty($GLOBALS['conf']['safe_ips'])) {
- if (reset($GLOBALS['conf']['safe_ips']) == '*') {
- return;
- }
-
- /* $_SERVER['HTTP_X_FORWARDED_FOR'] is user data and not
- * reliable. We dont' consult it for safe IPs. We also
- * have to assume that if it is present, the user is
- * coming through a proxy server. If so, we don't count
- * any non-SSL connection as safe, no matter the source
- * IP. */
- if (!isset($_SERVER['HTTP_X_FORWARDED_FOR'])) {
- $remote_addr = $_SERVER['REMOTE_ADDR'];
- foreach ($GLOBALS['conf']['safe_ips'] as $safe_ip) {
- $safe_ip = preg_replace('/(\.0)*$/', '', $safe_ip);
- if (strpos($remote_addr, $safe_ip) === 0) {
- return;
- }
- }
- }
- }
-
- throw new Horde_Exception (_("The encryption features require a secure web connection."));
- }
-
- /**
* Encrypt the requested data.
* This method should be provided by all classes that extend Horde_Crypt.
*