require_once HORDE_BASE . '/lib/core.php';
/* Notification system. */
-$notification = &Horde_Notification::singleton();
+$notification = Horde_Notification::singleton();
$notification->attach('status');
/* Registry. */
try {
$registry->pushApp('babel', !defined('AUTH_HANDLER'));
} catch (Horde_Exception $e) {
- if ($e->getCode() == 'permission_denied') {
- Horde::authenticationFailureRedirect();
- }
- throw $e;
+ Horde_Auth::authenticationFailureRedirect('babel', $e);
}
$conf = &$GLOBALS['conf'];
try {
$registry->pushApp('chora', !defined('AUTH_HANDLER'));
} catch (Horde_Exception $e) {
- if ($e->getCode() == 'permission_denied') {
- Horde::authenticationFailureRedirect();
- }
- throw $e;
+ Horde_Auth::authenticationFailureRedirect('chora', $e);
}
$conf = &$GLOBALS['conf'];
define('CHORA_TEMPLATES', $registry->get('templates'));
$notification = &Horde_Notification::singleton();
$notification->attach('status');
-// Chora base library.
-require_once CHORA_BASE . '/lib/Chora.php';
-
// Initialize objects, path, etc.
Chora::initialize();
-// Start compression, if requested.
+// Start compression.
Horde::compressOutput();
try {
$registry->pushApp('crumb', !defined('AUTH_HANDLER'));
} catch (Horde_Exception $e) {
- if ($e->getCode() == 'permission_denied') {
- Horde::authenticationFailureRedirect();
- }
- throw $e;
+ Horde_Auth::authenticationFailureRedirect('crumb', $e);
}
$conf = &$GLOBALS['conf'];
@define('CRUMB_TEMPLATES', $registry->get('templates'));
// Notification system.
-$notification = &Horde_Notification::singleton();
+$notification = Horde_Notification::singleton();
$notification->attach('status');
// Define the base file path of Crumb.
@define('CRUMB_BASE', dirname(__FILE__) . '/..');
-// Crumb base library
-require_once CRUMB_BASE . '/lib/Crumb.php';
-
// Crumb driver
-require_once CRUMB_BASE . '/lib/Driver.php';
$crumb_driver = Crumb_Driver::factory();
// Start output compression.
* @author Duck <duck@obala.net>
* @package Folks
*/
-define('HORDE_BASE', dirname(__FILE__) . '/..');
-require_once HORDE_BASE . '/lib/base.php';
+require_once dirname(__FILE__) . '/../lib/base.php';
require_once 'Horde/Loader.php';
require_once './lib/Block/Layout/View/js.php';
-if (!Horde_Auth::isAuthenticated()) {
- Horde::authenticationFailureRedirect();
-}
-
// Load layout from preferences.
$layout_pref = unserialize($prefs->getValue('portal_layout'));
if (!is_array($layout_pref)) {
* @author Duck <duck@obala.net>
* @package Folks
*/
-define('HORDE_BASE', dirname(__FILE__) . '/..');
-require_once HORDE_BASE . '/lib/base.php';
-require_once 'Horde/Loader.php';
-
-if (!Horde_Auth::isAuthenticated()) {
- Horde::authenticationFailureRedirect();
-}
+require_once dirname(__FILE__) . '/../lib/base.php';
$layout = array();
$params = Horde_Util::getPost('params');
try {
$registry->pushApp('fima', !defined('AUTH_HANDLER'));
} catch (Horde_Exception $e) {
- if ($e->getCode() == 'permission_denied') {
- Horde::authenticationFailureRedirect();
- }
- throw $e;
+ Horde_Auth::authenticationFailureRedirect('fima', $e);
}
$conf = &$GLOBALS['conf'];
@define('FIMA_TEMPLATES', $registry->get('templates'));
}
// Notification system.
-$notification = &Horde_Notification::singleton();
+$notification = Horde_Notification::singleton();
$notification->attach('status');
// Fima base library
-require_once FIMA_BASE . '/lib/Fima.php';
require_once FIMA_BASE . '/lib/Driver.php';
// Horde libraries.
Horde_Nls::setTimeZone();
// Create a share instance.
-require_once 'Horde/Share.php';
-$GLOBALS['fima_shares'] = &Horde_Share::singleton($registry->getApp());
+$GLOBALS['fima_shares'] = Horde_Share::singleton($registry->getApp());
Fima::initialize();
require_once FOLKS_BASE . '/lib/Friends.php';
if (!Horde_Auth::isAuthenticated()) {
- Horde::authenticationFailureRedirect();
+ Horde_Auth::authenticationFailureRedirect('folks');
}
$user = Horde_Util::getGet('user');
require_once FOLKS_BASE . '/lib/Friends.php';
if (!Horde_Auth::isAuthenticated()) {
- Horde::authenticationFailureRedirect();
+ Horde_Auth::authenticationFailureRedirect('folks');
}
$user = Horde_Util::getGet('user');
*/
if (!Horde_Auth::isAuthenticated()) {
- Horde::authenticationFailureRedirect();
+ Horde_Auth::authenticationFailureRedirect('folks');
}
$vars = Horde_Variables::getDefaultVariables();
require_once FOLKS_BASE . '/lib/Forms/Activity.php';
if (!Horde_Auth::isAuthenticated()) {
- Horde::authenticationFailureRedirect();
+ Horde_Auth::authenticationFailureRedirect('folks');
}
$title = _("Friends");
try {
$registry->pushApp('folks', !defined('AUTH_HANDLER'));
} catch (Horde_Exception $e) {
- if ($e->getCode() == 'permission_denied') {
- Horde::authenticationFailureRedirect();
- }
- throw $e;
+ Horde_Auth::authenticationFailureRedirect('folks', $e);
}
$conf = &$GLOBALS['conf'];
define('FOLKS_TEMPLATES', $registry->get('templates'));
// Notification system.
-$notification = &Horde_Notification::singleton();
+$notification = Horde_Notification::singleton();
$notification->attach('status');
// Define the base file path of Folks.
define('FOLKS_BASE', dirname(__FILE__) . '/..');
}
-// Folks base library
-require_once FOLKS_BASE . '/lib/Folks.php';
-require_once FOLKS_BASE . '/lib/Driver.php';
$GLOBALS['folks_driver'] = Folks_Driver::factory();
// Cache
require_once dirname(__FILE__) . '/lib/base.php';
-if (!Horde_Auth::isAuthenticated()) {
- Horde::authenticationFailureRedirect();
-}
-
$user = Horde_Util::getFormData('user');
if (empty($user)) {
$notification->push(_("User is not selected"), 'horde.warning');
require_once dirname(__FILE__) . '/../lib/base.php';
-if (!Horde_Auth::getAuth()) {
- Horde::authenticationFailureRedirect();
-}
-
/* Keys - these are obtained when registering for the service */
$consumer_key = '********';
$consumer_secret = '*********';
// The following actions do not need write access to the session and
// should be opened read-only for performance reasons.
if (in_array($action, array('chunkContent', 'Html2Text', 'Text2Html', 'GetReplyData', 'FetchmailDialog'))) {
- $session_control = 'readonly';
+ $imp_session_control = 'readonly';
}
-$dimp_logout = ($action == 'LogOut');
+$imp_dimp_logout = ($action == 'LogOut');
$session_timeout = 'json';
require_once IMP_BASE . '/lib/base.php';
// We do not need to be authenticated to get the file. Most users won't send
// linked attachments just to other IMP users.
-@define('AUTH_HANDLER', true);
-$authentication = 'none';
-$session_control = 'none';
+$imp_authentication = 'none';
+$imp_session_control = 'none';
require_once dirname(__FILE__) . '/lib/base.php';
$self_url = Horde::selfUrl(false, true, true);
// Initialize the VFS.
$vfsroot = VFS::singleton($conf['vfs']['type'], Horde::getDriverConfig('vfs', $conf['vfs']['type']));
-if (is_a($vfsroot, 'PEAR_Error')) {
+if ($vfsroot instanceof PEAR_Error) {
throw new Horde_Exception(sprintf(_("Could not create the VFS backend: %s"), $vfsroot->getMessage()));
}
$cacheID = $imp_compose->getCacheId();
$title = _("Message Composition");
+$mimp_render = new Horde_Mobile();
$mimp_render->set('title', $title);
$select_list = $identity->getSelectList();
}
-$compose_page = true;
-$session_control = 'netscape';
+$imp_compose_page = true;
+$imp_session_control = 'netscape';
require_once dirname(__FILE__) . '/lib/base.php';
/* The message headers and text. */
virtual users hook? If so, make sure you define _imp_hook_vinfo() in
hooks.php. The hook will be used to set $_SESSION['imp']['user'] at login
time. There are examples in hooks.php.dist.">false</configboolean>
- <configboolean name="postlogin" required="false" desc="Should we
- run a custom function post-login? If so, make sure you define
- _imp_hook_postlogin() in hooks.php. The hook can be used to do anything
- after the session is established but before we redirect to the initial
- login page. There are examples in hooks.php.dist.">false</configboolean>
<configboolean name="postsent" required="false" desc="Should we
run a custom function after sending a message? If so, make sure you define
_imp_hook_postsent() in hooks.php. The hook will be used to do anything
// }
// }
-// Here is an example _imp_hook_postlogin function to redirect to a
-// custom server after login.
-
-// if (!function_exists('_imp_hook_postlogin')) {
-// function _imp_hook_postlogin($actionID, $isLogin)
-// {
-// header('Location: http://mail' . mt_rand(1, 9) . '.example.com/horde/');
-// exit;
-// }
-// }
-
// This is an example for a post-sending hook that performs an action after
// a message has been sent successfully.
// $message = Base Horde_Mime_part object.
+++ /dev/null
-<?php
-/**
- * This file contains any "Message Of The Day" Type information.
- * It will be included below the login form on the login page.
- *
- * $Id$
- */
-
-/**
- * Example code for switching between HTTP and HTTPS.
- * Contributed by: James <james@james-web.net>
- * To use, uncomment and modify these variables:
- *
- * $SERVER_SSL_PORT - Port on which your SSL server listens (Usually 443)
- * $SERVER_HTTP_PORT - Port on which your HTTP server listens (Usually 80)
- * $SERVER_SSL_URL - Full URL to your HTTPS server and Horde directory
- * $SERVER_HTTP_URL - Full URL to your HTTP server and Horde directory
- */
-
-// $SERVER_SSL_PORT = 443;
-// $SERVER_HTTP_PORT = 80;
-// $SERVER_SSL_URL = 'https://www.example.com';
-// $SERVER_HTTP_URL = 'http://www.example.com';
-//
-// $port = $_SERVER['SERVER_PORT'];
-//
-// echo '<br /><div align="center" class="light">';
-//
-// switch ($port) {
-// case $SERVER_SSL_PORT:
-// echo _("You are currently using Secure HTTPS<br />");
-// break;
-//
-// case $SERVER_HTTP_PORT:
-// echo _("You are currently using Standard HTTP<br />");
-// break;
-// }
-//
-// echo '<a class="small" href="' . $SERVER_HTTP_URL . '" target="_parent">' . _("Click here for Standard HTTP") . '</a> - <a class="small" href="' . $SERVER_SSL_URL . '" target="_parent">' . _("Click here for Secure HTTPS") . '</a></div>';
-
-?>
-<br />
-<table width="100%"><tr><td align="center"><?php echo Horde::img('horde-power1.png', _("Powered by Horde"), '', $registry->getImageDir('horde')) ?></td></tr></table>
* @package IMP
*/
-$authentication = 'horde';
+$imp_authentication = 'horde';
require_once dirname(__FILE__) . '/lib/base.php';
/* Get the lists of address books through the API. */
v5.0-git
--------
+[mms] Logins now handled by Horde login handler.
[mms] When generating and sending compressed ZIP data, use server-side temp
streams to minimize memory usage.
[mms] Decode bodypart data on server if possible (RFC 3516).
$refresh_url = Horde::applicationUrl('folders.php', true);
$refresh_time = $prefs->getValue('refresh_time');
-/* Other variables. */
-$open_compose_window = null;
-
/* Run through the action handlers. */
$actionID = Horde_Util::getFormData('actionID');
if ($actionID) {
}
break;
-case 'login_compose':
- $open_compose_window = IMP::openComposeWin();
- break;
-
case 'delete_folder_confirm':
case 'folders_empty_mailbox_confirm':
if (!empty($folder_list)) {
/* No need for extra template - close out the tags here. */
echo '</form></div>';
-if ($open_compose_window === false) {
- if (!isset($options)) {
- $options = array();
- }
- Horde::addScriptFile('imp.js', 'imp', true);
- Horde::addInlineScript(IMP::popupIMPString('compose.php', array_merge(array('popup' => 1), $options, IMP::getComposeArgs())));
-}
-
$notification->notify(array('listeners' => 'audio'));
require $registry->get('templates', 'horde') . '/common-footer.inc';
array('servers.php' => 'This file controls the default settings for IMP, and also defines the list of available servers if you are using the server list.'));
}
-require IMP_BASE . '/redirect.php';
+// Will redirect to login page if not authenticated.
+require_once IMP_BASE . '/lib/base.php';
+
+// Load initial page as defined by view mode & preferences.
+require IMP_Auth::getInitialPage();
var ImpLogin = {
// The following variables are defined in login.php:
- // autologin_url, dimp_sel, imp_auth, lang_url, show_list
+ // dimp_sel, server_key_error
- _reload: function()
+ submit: function(parentfunc)
{
- window.top.document.location = this.autologin_url + $F('server_key');
- },
-
- submit: function()
- {
- if (this.show_list && $F('server_key').startsWith('_')) {
+ if ($('imp_server_key') && $F('imp_server_key').startsWith('_')) {
+ alert(this.server_key_error);
+ $('imp_server_key').focus();
return;
}
- if (!$F('imapuser')) {
- alert(IMP.text.login_username);
- $('imapuser').focus();
- } else if (!$F('pass')) {
- alert(IMP.text.login_password);
- $('pass').focus();
- } else {
- $('loginButton').disable();
- if (this.ie_clientcaps) {
- try {
- $('ie_version').setValue(objCCaps.getComponentVersion("{89820200-ECBD-11CF-8B85-00AA005B4383}","componentid"));
- } catch (e) { }
- }
- $('imp_login').submit();
- }
- },
-
- _selectLang: function()
- {
- // We need to reload the login page here, but only if the user hasn't
- // already entered a username and password.
- if (!$F('imapuser') && !$F('pass')) {
- var params = { new_lang: $F('new_lang') };
- if (this.lang_url) {
- params.url = this.lang_url;
- }
- self.location = 'login.php?' + Object.toQueryString(params);
- }
- },
-
- /* Removes any leading hash that might be on a location string. */
- _removeHash: function(h)
- {
- return (Object.isString(h) && h.startsWith("#")) ? h.substring(1) : h;
+ parentfunc();
},
onDomLoad: function()
{
- if (this.imp_auth) {
- if (parent.frames.horde_main) {
- if (this.nomenu) {
- parent.location = self.location;
- } else {
- document.imp_login.target = '_parent';
- }
- }
- }
-
/* Activate dynamic view. */
- var o = $('select_view').down('option[value=dimp]').show();
+ var o = $('imp_select_view').down('option[value=dimp]').show();
if (this.dimp_sel) {
o.writeAttribute('selected', 'selected');
}
-
- document.observe('change', this._changeHandler.bindAsEventListener(this));
- document.observe('click', this._clickHandler.bindAsEventListener(this));
-
- // Need to capture hash information if it exists in URL
- if (location.hash) {
- $('anchor_string').setValue(this._removeHash(location.hash));
- }
-
- if (!$F('imapuser')) {
- $('imapuser').focus();
- } else {
- $('pass').focus();
- }
-
- if (this.reloadmenu && window.parent.frames.horde_menu) {
- window.parent.frames.horde_menu.location.reload();
- }
- },
-
- _changeHandler: function(e)
- {
- switch (e.element().readAttribute('id')) {
- case 'new_lang':
- this._selectLang();
- break;
-
- case 'server_key':
- this._reload();
- break;
- }
- },
-
- _clickHandler: function(e)
- {
- if (e.isRightClick()) {
- return;
- }
-
- var elt = e.element();
-
- while (Object.isElement(elt)) {
- switch (elt.readAttribute('id')) {
- case 'btn_login':
- this._reload();
- break;
-
- case 'loginButton':
- this.submit();
- break;
- }
-
- elt = elt.up();
- }
}
-
};
+HordeLogin.submit = HordeLogin.submit.wrap(ImpLogin.submit.bind(ImpLogin));
document.observe('dom:loaded', ImpLogin.onDomLoad.bind(ImpLogin));
<?php
/**
- * The Horde_Auth:: class provides an IMP implementation of the Horde
- * authentication system.
+ * The IMP_Auth:: class provides authentication for IMP.
*
- * Required parameters: NONE
- * Optional parameters: NONE
- *
- * Copyright 2003-2009 The Horde Project (http://www.horde.org/)
+ * Copyright 1999-2009 The Horde Project (http://www.horde.org/)
*
* See the enclosed file COPYING for license information (LGPL). If you
* did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
*
+ * @author Chuck Hagenbuch <chuck@horde.org>
+ * @author Jon Parise <jon@horde.org>
* @author Michael Slusarz <slusarz@horde.org>
- * @package Horde_Auth
+ * @package IMP
*/
-class IMP_Auth extends Horde_Auth_Base
+class IMP_Auth
{
/**
- * Find out if a set of login credentials are valid, and if
- * requested, mark the user as logged in in the current session.
+ * The preferred server based on the value from the login form.
*
- * @param string $userID The userID to check.
- * @param array $credentials The credentials to check.
- * @param boolean $login Whether to log the user in. If false, we'll
- * only test the credentials and won't modify
- * the current session.
+ * @var string
+ */
+ static public $prefServer = null;
+
+ /**
+ * The auth type to use.
*
- * @return boolean Whether or not the credentials are valid.
+ * @var string
*/
- public function authenticate($userID = null, $credentials = array(),
- $login = false)
- {
- return parent::authenticate($userID, $credentials, $login && (Horde_Auth::getProvider() == 'imp'));
- }
+ static public $authType = null;
/**
- * Find out if a set of login credentials are valid.
+ * Authenticate to the mail server.
*
- * @param string $userID The userID to check.
- * @param array $credentials An array of login credentials.
+ * @param array $credentials An array of login credentials. If empty,
+ * attempts to login to the cached session.
+ * <pre>
+ * 'password' - (string) The user password.
+ * 'server' - (string) The server key to use (from servers.php).
+ * 'userid' - (string) The username.
+ * </pre>
*
- * @throws Horde_Exception
+ * @return boolean True if session was created, false if pre-existing
+ * session used.
+ * @throws Horde_Auth_Exception
*/
- protected function _authenticate($userID, $credentials)
+ static public function authenticate($credentials = array())
{
+ $retval = false;
+
+ // Do 'horde' authentication.
+ if (self::$authType == 'horde') {
+ if (Horde_Auth::getAuth()) {
+ return false;
+ }
+ throw new Horde_Auth_Exception('', Horde_Auth::REASON_FAILED);
+ }
+
// Check for valid IMAP Client object.
if (!$GLOBALS['imp_imap']->ob) {
- // Attempt to create IMAP Client object
- $key = isset($credentials['server']) ? $credentials['server'] : IMP_Session::getAutoLoginServer();
- if (is_null($key) ||
- !isset($credentials['password']) ||
- !$GLOBALS['imp_imap']->createImapObject($userID, $credentials['password'], $key)) {
- IMP::loginLogMessage('failed', __FILE__, __LINE__);
- throw new Horde_Exception('', Horde_Auth::REASON_FAILED);
+ if (!isset($credentials['userid']) ||
+ !isset($credentials['password'])) {
+ throw new Horde_Auth_Exception('', Horde_Auth::REASON_BADLOGIN);
+ }
+
+ if (!isset($credentials['server'])) {
+ $credentials['server'] = self::getAutoLoginServer();
+ }
+
+ /* _createSession() will create the imp session variable, so there
+ * is no concern for an infinite loop here. */
+ if (!isset($_SESSION['imp'])) {
+ self::_createSession($credentials);
+ $retval = true;
+ } elseif (!$GLOBALS['imp_imap']->createImapObject($credentials['userid'], $credentials['password'], $credentials['server'])) {
+ self::logMessage('failed', __FILE__, __LINE__);
+ throw new Horde_Auth_Exception('', Horde_Auth::REASON_FAILED);
}
}
try {
- $GLOBALS['imp_imap']->ob->login();
+ if ($retval !== true) {
+ $GLOBALS['imp_imap']->ob->login();
+ }
} catch (Horde_Imap_Client_Exception $e) {
- IMP::loginLogMessage($e->getMessage(), __FILE__, __LINE__);
+ self::logMessage($e->getMessage(), __FILE__, __LINE__);
if ($e->getCode() == Horde_Imap_Client_Exception::SERVER_CONNECT) {
- throw new Horde_Exception(_("Could not connect to the remote server."));
+ throw new Horde_Auth_Exception(_("Could not connect to the remote server."));
}
- throw new Horde_Exception('', Horde_Auth::REASON_BADLOGIN);
+ throw new Horde_Auth_Exception($e->getMessage());
+ }
+
+ if (!empty($_SESSION['imp']['logintasks'])) {
+ self::_loginTasks();
}
+
+ return $retval;
}
+
+ /**
+ * Perform transparent authentication.
+ *
+ * @return boolean Whether transparent login is supported.
+ * @throws Horde_Auth_Exception
+ */
+ static public function transparent()
+ {
+ $credentials = self::_canAutoLogin();
+ if ($credentials === false) {
+ return false;
+ }
+
+ self::_createSession($credentials);
+ return true;
+ }
+
+ /**
+ * Log login related message.
+ *
+ * @param string $status Either 'login', 'logout', 'failed', or an
+ * error message.
+ * @param string $file The file where the error occurred.
+ * @param integer $line The line where the error occurred.
+ * @param integer $level The logging level.
+ */
+ static public function logMessage($status, $file, $line,
+ $level = PEAR_LOG_ERR)
+ {
+ switch ($status) {
+ case 'login':
+ $status_msg = 'Login success';
+ break;
+
+ case 'logout':
+ $status_msg = 'Logout';
+ break;
+
+ case 'failed':
+ $status_msg = 'FAILED LOGIN';
+ break;
+
+ default:
+ $status_msg = $status;
+ break;
+ }
+
+ $imp_imap = $GLOBALS['imp_imap']->ob;
+
+ $msg = sprintf(
+ $status_msg . ' for %s [%s]%s to {%s:%s [%s]}',
+ empty($_SESSION['imp']['uniquser']) ? '' : $_SESSION['imp']['uniquser'],
+ $_SERVER['REMOTE_ADDR'],
+ empty($_SERVER['HTTP_X_FORWARDED_FOR']) ? '' : ' (forwarded for [' . $_SERVER['HTTP_X_FORWARDED_FOR'] . '])',
+ $imp_imap ? $imp_imap->getParam('hostspec') : '',
+ $imp_imap ? $imp_imap->getParam('port') : '',
+ empty($_SESSION['imp']['protocol']) ? '' : $_SESSION['imp']['protocol']
+ );
+
+ Horde::logMessage($msg, $file, $line, $level);
+ }
+
+ /**
+ * Set up the IMP session. Handle authentication, if required, and only do
+ * enough work to see if the user can log in.
+ *
+ * Creates the 'imp' session variable with the following entries:
+ * 'cache' -- Various IMP libraries can use this variable to cache
+ * data.
+ * 'file_upload' -- If file uploads are allowed, the max size.
+ * 'filteravail' -- Can we apply filters manually?
+ * 'imap' -- Config for various IMAP resources (acl, admin,
+ * namespace, quota)
+ * 'imap_ob' -- The serialized Horde_Imap_Client object.
+ * 'logintasks' -- Have the login tasks been completed?
+ * 'maildomain' -- See config/servers.php.
+ * 'notepadavail' -- Is listing of notepads available?
+ * 'protocol' -- Either 'imap' or 'pop'.
+ * 'rteavail' -- Is the HTML editor available?
+ * 'search' -- Settings used by the IMP_Search library.
+ * 'server_key' -- Server used to login.
+ * 'smime' -- Settings related to the S/MIME viewer.
+ * 'smtp' -- SMTP options ('host' and 'port')
+ * 'showunsub' -- Show unsusubscribed mailboxes on the folders screen.
+ * 'tasklistavail' -- Is listing of tasklists available?
+ * 'uniquser' -- The unique user name.
+ * 'view' -- The imp view mode (currently dimp, imp, or mimp)
+ *
+ * @param array $credentials An array of login credentials.
+ * <pre>
+ * 'password' - (string) The user password.
+ * 'server' - (string) The server key to use (from servers.php).
+ * 'userid' - (string) The username.
+ * </pre>
+ *
+ * @throws Horde_Auth_Exception
+ */
+ static protected function _createSession($credentials)
+ {
+ global $conf;
+
+ /* Create the imp session variable. */
+ $_SESSION['imp'] = array(
+ 'cache' => array(),
+ 'imap' => array(),
+ 'logintasks' => false,
+ 'server_key' => $credentials['server'],
+ 'showunsub' => false
+ );
+ $sess = &$_SESSION['imp'];
+
+ /* Run the username through virtualhost expansion functions if
+ * necessary. */
+ if (!empty($conf['hooks']['vinfo'])) {
+ try {
+ $credentials['userid'] = Horde::callHook('_imp_hook_vinfo', array('username', $credentials['userid']), 'imp');
+ } catch (Horde_Exception $e) {}
+ }
+
+ /* Load the server configuration. */
+ $ptr = $GLOBALS['imp_imap']->loadServerConfig($credentials['server']);
+ if ($ptr === false) {
+ throw new Horde_Auth_Exception('', Horde_Auth::REASON_FAILED);
+ }
+
+ /* Determine the unique user name. */
+ if (Horde_Auth::isAuthenticated()) {
+ $sess['uniquser'] = Horde_Auth::removeHook(Horde_Auth::getAuth());
+ } else {
+ $sess['uniquser'] = $credentials['userid'];
+ if (!empty($ptr['realm'])) {
+ $sess['uniquser'] .= '@' . $ptr['realm'];
+ }
+ }
+
+ /* Do necessary authentication now. */
+ try {
+ self::authenticate(array(
+ 'password' => $credentials['password'],
+ 'server' => $credentials['server'],
+ 'userid' => $sess['uniquser']
+ ));
+ } catch (Horde_Auth_Exception $e) {
+ unset($_SESSION['imp']);
+ throw $e;
+ }
+
+ /* Set the protocol. */
+ $sess['protocol'] = isset($ptr['protocol'])
+ ? $ptr['protocol']
+ : 'imap';
+
+ /* Set the maildomain. */
+ $maildomain = $GLOBALS['prefs']->getValue('mail_domain');
+ $sess['maildomain'] = $maildomain
+ ? $maildomain
+ : $ptr['maildomain'];
+
+ /* Store some basic IMAP server information. */
+ if ($sess['protocol'] == 'imap') {
+ foreach (array('acl', 'admin', 'namespace', 'quota') as $val) {
+ if (isset($ptr[$val])) {
+ $sess['imap'][$val] = $ptr[$val];
+
+ /* 'admin' and 'quota' have password entries - encrypt
+ * these entries in the session if they exist. */
+ if (isset($ptr[$val]['params']['password'])) {
+ $sess['imap'][$val]['params']['password'] = Horde_Secret::write(Horde_Secret::getKey('imp'), $ptr[$val]['params']['password']);
+ }
+ }
+ }
+ }
+
+ /* Set the SMTP options, if needed. */
+ if ($conf['mailer']['type'] == 'smtp') {
+ $sess['smtp'] = array();
+ foreach (array('smtphost' => 'host', 'smtpport' => 'port') as $key => $val) {
+ if (!empty($ptr[$key])) {
+ $sess['smtp'][$val] = $ptr[$key];
+ }
+ }
+ }
+
+ /* Does the server allow file uploads? If yes, store the
+ * value, in bytes, of the maximum file size. */
+ $sess['file_upload'] = $GLOBALS['browser']->allowFileUploads();
+
+ /* Is the 'mail/canApplyFilters' API call available? */
+ $registry = Horde_Registry::singleton();
+ try {
+ if ($registry->call('mail/canApplyFilters')) {
+ $sess['filteravail'] = true;
+ }
+ } catch (Horde_Exception $e) {}
+
+ /* Is the 'tasks/listTasklists' call available? */
+ if ($conf['tasklist']['use_tasklist'] &&
+ $registry->hasMethod('tasks/listTasklists')) {
+ $sess['tasklistavail'] = true;
+ }
+
+ /* Is the 'notes/listNotepads' call available? */
+ if ($conf['notepad']['use_notepad'] &&
+ $registry->hasMethod('notes/listNotepads')) {
+ $sess['notepadavail'] = true;
+ }
+
+ /* Is the HTML editor available? */
+ $imp_ui = new IMP_UI_Compose();
+ $editor = $imp_ui->initRTE(null, true);
+ $sess['rteavail'] = $editor->supportedByBrowser();
+
+ /* Set up search information for the session. */
+ $GLOBALS['imp_search']->sessionSetup();
+
+ IMP_Auth::logMessage('login', __FILE__, __LINE__, PEAR_LOG_NOTICE);
+ }
+
+ /**
+ * Perform IMP login tasks.
+ */
+ static protected function _loginTasks()
+ {
+ /* Do login tasks. */
+ $tasks = Horde_LoginTasks::singleton('imp', Horde::selfUrl(true, true, true));
+ $tasks->runTasks();
+
+ /* If the user wants to run filters on login, make sure they get
+ run. */
+ if ($GLOBALS['prefs']->getValue('filter_on_login')) {
+ /* Run filters. */
+ $imp_filter = new IMP_Filter();
+ $imp_filter->filter('INBOX');
+ }
+
+ /* Check for drafts due to session timeouts. */
+ $imp_compose = IMP_Compose::singleton();
+ $imp_compose->recoverSessionExpireDraft();
+
+ $_SESSION['imp']['logintasks'] = true;
+ }
+
+ /**
+ * Returns the autologin server key.
+ *
+ * @return string The server key, or null if none available.
+ */
+ static public function getAutoLoginServer()
+ {
+ if (($servers = IMP_Imap::loadServerConfig()) === false) {
+ return null;
+ }
+
+ $server_key = null;
+ foreach ($servers as $key => $val) {
+ if (is_null($server_key) && substr($key, 0, 1) != '_') {
+ $server_key = $key;
+ }
+ if (self::isPreferredServer($val, $key)) {
+ $server_key = $key;
+ break;
+ }
+ }
+
+ return $server_key;
+ }
+
+ /**
+ * Determines if the given mail server is the "preferred" mail server for
+ * this web server. This decision is based on the global 'SERVER_NAME'
+ * and 'HTTP_HOST' server variables and the contents of the 'preferred'
+ * field in the server's definition. The 'preferred' field may take a
+ * single value or an array of multiple values.
+ *
+ * @param string $server A complete server entry from the $servers hash.
+ * @param string $key The server key entry.
+ *
+ * @return boolean True if this entry is "preferred".
+ */
+ static public function isPreferredServer($server, $key = null)
+ {
+ if (!is_null(self::$prefServer)) {
+ return ($key == self::$prefServer);
+ }
+
+ if (!empty($server['preferred'])) {
+ if (is_array($server['preferred'])) {
+ if (in_array($_SERVER['SERVER_NAME'], $server['preferred']) ||
+ in_array($_SERVER['HTTP_HOST'], $server['preferred'])) {
+ return true;
+ }
+ } elseif (($server['preferred'] == $_SERVER['SERVER_NAME']) ||
+ ($server['preferred'] == $_SERVER['HTTP_HOST'])) {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ /**
+ * Returns whether we can log in without a login screen for $server_key.
+ *
+ * @param string $server_key The server to check. Defaults to the
+ * autologin server.
+ * @param boolean $force If true, check $server_key even if there is
+ * more than one server available.
+ *
+ * @return array The credentials needed to login ('userId', 'password',
+ * 'server') or false if autologin not available.
+ */
+ static protected function _canAutoLogin($server_key = null, $force = false)
+ {
+ if (($servers = $GLOBALS['imp_imap']->loadServerConfig()) === false) {
+ return false;
+ }
+
+ if (is_null($server_key) || !$force) {
+ $auto_server = self::getAutoLoginServer();
+ if (is_null($server_key)) {
+ $server_key = $auto_server;
+ }
+ }
+
+ if ((!empty($auto_server) || $force) &&
+ Horde_Auth::getAuth() &&
+ !empty($servers[$server_key]['hordeauth'])) {
+ return array(
+ 'userId' => ((strcasecmp($servers[$server_key]['hordeauth'], 'full') == 0)
+ ? Horde_Auth::getAuth()
+ : Horde_Auth::getBareAuth()),
+ 'password' => Horde_Auth::getCredential('password'),
+ 'server' => $server_key
+ );
+ }
+
+ return false;
+ }
+
+ /**
+ * Returns the initial page.
+ *
+ * @param boolean $url Return a URL instead of a file path.
+ *
+ * @return string Either the file path or a URL to the initial page.
+ */
+ static public function getInitialPage($url = false)
+ {
+ switch ($_SESSION['imp']['view']) {
+ case 'dimp':
+ $page = 'index-dimp.php';
+ break;
+
+ case 'mimp':
+ $page = 'mailbox-mimp.php';
+ break;
+
+ default:
+ $init_url = ($_SESSION['imp']['protocol'] == 'pop')
+ ? 'INBOX'
+ : $GLOBALS['prefs']->getValue('initial_page');
+
+ $imp_search = new IMP_Search();
+
+ if (!$GLOBALS['prefs']->getValue('use_vinbox') &&
+ $imp_search->isVINBOXFolder($init_url)) {
+ $init_url = 'folders.php';
+ } elseif (($imp_search->createSearchID($init_url) == $init_url) &&
+ !$imp_search->isVFolder($init_url)) {
+ $init_url = 'INBOX';
+ if (!$GLOBALS['prefs']->isLocked('initial_page')) {
+ $GLOBALS['prefs']->setValue('initial_page', $init_url);
+ }
+ }
+
+ switch ($init_url) {
+ case 'folders.php':
+ $page = $init_url;
+ break;
+
+ default:
+ // TODO: Directly load mailbox.php
+ header('Location: ' . Horde_Util::addParameter(Horde::applicationUrl('mailbox.php', true), array('mailbox' => $init_url)));
+ exit;
+ }
+ }
+
+ return $url
+ ? Horde::applicationUrl($page, true)
+ : IMP_BASE . '/' . $page;
+ }
+
}
function _content()
{
- if (!IMP::checkAuthentication(true)) {
- return '';
+ $GLOBALS['imp_authentication'] = 'throw';
+ try {
+ require_once dirname(__FILE__) . '/../base.php';
+ } catch (Horde_Exception $e) {
+ return;
}
/* Filter on INBOX display, if requested. */
function _content()
{
- $GLOBALS['authentication'] = 'none';
- require_once dirname(__FILE__) . '/../base.php';
-
- if (!IMP::checkAuthentication(true)) {
- return '';
+ $GLOBALS['imp_authentication'] = 'throw';
+ try {
+ require_once dirname(__FILE__) . '/../base.php';
+ } catch (Horde_Exception $e) {
+ return;
}
/* Filter on INBOX display, if requested. */
{
global $notification, $prefs, $registry;
- $GLOBALS['authentication'] = 'none';
- require dirname(__FILE__) . '/../base.php';
+ $GLOBALS['imp_authentication'] = 'throw';
+ try {
+ require_once dirname(__FILE__) . '/../base.php';
+ } catch (Horde_Exception $e) {
+ return;
+ }
$html = '<table cellspacing="0" width="100%">';
- if (!IMP::checkAuthentication(true)) {
- return $html . '<tr><td class="text">' . Horde::link(Horde::applicationUrl('index.php', true), sprintf(_("Log in to %s"), $registry->applications['imp']['name'])) . sprintf(_("Log in to %s"), $registry->applications['imp']['name']) . '</a></td></tr></table>';
- }
-
/* Filter on INBOX display, if requested. */
if ($prefs->getValue('filter_on_display')) {
$imp_filter = new IMP_Filter();
function _buildTree(&$tree, $indent = 0, $parent = null)
{
- $GLOBALS['authentication'] = 'none';
- require_once dirname(__FILE__) . '/../base.php';
-
- /* Abort immediately if we're not currently logged in. */
- if (!IMP::checkAuthentication(true)) {
+ $GLOBALS['imp_authentication'] = 'throw';
+ try {
+ require_once dirname(__FILE__) . '/../base.php';
+ } catch (Horde_Exception $e) {
return;
}
}
return isset($_SESSION['imp']['cache']['pgp'][$type][$id])
- ? Horde_Secret::read(IMP::getAuthKey(), $_SESSION['imp']['cache']['pgp'][$type][$id])
+ ? Horde_Secret::read(Horde_Secret::getKey('imp'), $_SESSION['imp']['cache']['pgp'][$type][$id])
: null;
}
$id = 'personal';
}
- $_SESSION['imp']['cache']['pgp'][$type][$id] = Horde_Secret::write(IMP::getAuthKey(), $passphrase);
+ $_SESSION['imp']['cache']['pgp'][$type][$id] = Horde_Secret::write(Horde_Secret::getKey('imp'), $passphrase);
return true;
}
}
if (isset($_SESSION['imp']['smime']['passphrase'])) {
- return Horde_Secret::read(IMP::getAuthKey(), $_SESSION['imp']['smime']['passphrase']);
+ return Horde_Secret::read(Horde_Secret::getKey('imp'), $_SESSION['imp']['smime']['passphrase']);
} elseif (isset($_SESSION['imp']['smime']['null_passphrase'])) {
return ($_SESSION['imp']['smime']['null_passphrase']) ? null : false;
} else {
if (!isset($_SESSION['imp']['smime'])) {
$_SESSION['imp']['smime'] = array();
}
- $_SESSION['imp']['smime']['passphrase'] = Horde_Secret::write(IMP::getAuthKey(), $passphrase);
+ $_SESSION['imp']['smime']['passphrase'] = Horde_Secret::write(Horde_Secret::getKey('imp'), $passphrase);
return true;
}
/* hideDeletedMsgs() cache. */
static private $_delhide = null;
- /* getAuthKey() cache. */
- static private $_authkey = null;
-
/* filesystemGC() cache. */
static private $_dirlist = array();
/**
- * Makes sure the user has been authenticated to view the page.
- *
- * @param boolean $return If this is true, return false instead of
- * exiting/redirecting if authentication fails.
- * @param boolean $hordeauth Just check for Horde auth and don't bother
- * the IMAP server.
- *
- * @return boolean True on success, false on error.
- */
- static public function checkAuthentication($return = false,
- $hordeauth = false)
- {
- if ($hordeauth) {
- $reason = Horde_Auth::isAuthenticated();
- } else {
- $auth_imp = new IMP_Auth();
- $reason = $auth_imp->authenticate(null, array(), false);
- }
-
- if ($reason === true) {
- return true;
- } elseif ($return) {
- return false;
- }
-
- if (Horde_Util::getFormData('popup')) {
- Horde_Util::closeWindowJS();
- } else {
- $url = Horde_Util::addParameter(self::getLogoutUrl(null, true), 'url', Horde::selfUrl(true));
- header('Location: ' . $url);
- }
- exit;
- }
-
- /**
* Returns the plain text label that is displayed for the current mailbox,
* replacing virtual search mailboxes with an appropriate description and
* removing namespace and mailbox prefix information from what is shown to
$spam_folder = self::folderPref($prefs->getValue('spam_folder'), true);
- $menu = new Horde_Menu(Horde_Menu::MASK_ALL & ~Horde_Menu::MASK_LOGIN);
+ $menu = new Horde_Menu();
$menu->add(self::generateIMPUrl($menu_mailbox_url, 'INBOX'), _("_Inbox"), 'folders/inbox.png');
$menu->add(Horde::applicationUrl('filterprefs.php'), _("Fi_lters"), 'filters.png');
}
- /* Logout. If IMP can auto login or IMP is providing authentication,
- * then we only show the logout link if the sidebar isn't shown or if
- * the configuration says to always show the current user a logout
- * link. */
- $impAuth = ((Horde_Auth::getProvider() == 'imp') || $_SESSION['imp']['autologin']);
- if (!$impAuth ||
- !$prefs->getValue('show_sidebar') ||
- Horde::showService('logout')) {
- /* If IMP provides authentication and the sidebar isn't always on,
- * target the main frame for logout to hide the sidebar while
- * logged out. */
- $logout_target = ($impAuth) ? '_parent' : null;
-
- /* If IMP doesn't provide Horde authentication then we need to use
- * IMP's logout screen since logging out should *not* end a Horde
- * session. */
- $logout_url = self::getLogoutUrl();
-
- $id = $menu->add($logout_url, _("_Log out"), 'logout.png', $registry->getImageDir('horde'), $logout_target);
- $menu->setPosition($id, Horde_Menu::POS_LAST);
- }
-
return ($type == 'object') ? $menu : $menu->render();
}
}
/**
- * Returns the proper logout URL for logging out of IMP.
- *
- * @param integer $reason
- * @param boolean $force Force URL to IMP login page.
- *
- * @return string The logout URL.
- */
- static public function getLogoutUrl($reason = null, $force = false)
- {
- $params = array_filter(array(
- 'server_key' => isset($_SESSION['imp']['server_key']) ?
- $_SESSION['imp']['server_key'] :
- Horde_Util::getFormData('server_key'),
- 'language' => Horde_Util::getFormData('language')
- ));
-
- if ($force ||
- !((Horde_Auth::getProvider() != 'imp') || !$_SESSION['imp']['autologin'])) {
- $url = $GLOBALS['registry']->get('webroot', 'imp') . '/login.php';
- } else {
- $url = Horde::getServiceLink('logout', 'horde', true);
- }
-
- $url = (!is_null($reason) && is_array($reason))
- ? Horde_Auth::addLogoutParameters($url, $reason[0], $reason[1])
- : Horde_Auth::addLogoutParameters($url, $reason);
-
- if (!empty($params)) {
- $url = Horde_Util::addParameter($url, $params, null, false);
- }
-
- return $url;
- }
-
- /**
* Output the javascript needed to call the IMP popup JS function.
*
* @param string $url The IMP page to load.
}
/**
- * Log login related message.
- *
- * @param string $status Either 'login', 'logout', or 'failed'.
- * @param string $file The file where the error occurred.
- * @param integer $line The line where the error occurred.
- * @param integer $level The logging level.
- */
- static public function loginLogMessage($status, $file, $line,
- $level = PEAR_LOG_ERR)
- {
- switch ($status) {
- case 'login':
- $status_msg = 'Login success';
- break;
-
- case 'logout':
- $status_msg = 'Logout';
- break;
-
- case 'failed':
- $status_msg = 'FAILED LOGIN';
- break;
-
- default:
- $status_msg = $status;
- break;
- }
-
- $imp_imap = $GLOBALS['imp_imap']->ob;
-
- $msg = sprintf(
- $status_msg . ' for %s [%s]%s to {%s:%s [%s]}',
- (!empty($_SESSION['imp']['uniquser'])) ? $_SESSION['imp']['uniquser'] : '',
- $_SERVER['REMOTE_ADDR'],
- (empty($_SERVER['HTTP_X_FORWARDED_FOR'])) ? '' : ' (forwarded for [' . $_SERVER['HTTP_X_FORWARDED_FOR'] . '])',
- (!is_null($imp_imap)) ? $imp_imap->getParam('hostspec') : '',
- (!is_null($imp_imap)) ? $imp_imap->getParam('port') : '',
- (!empty($_SESSION['imp']['protocol'])) ? $_SESSION['imp']['protocol'] : ''
- );
-
- Horde::logMessage($msg, $file, $line, $level);
- }
-
- /**
* Outputs the necessary script tags, honoring local configuration
* choices as to script caching.
*/
}
/**
- * Return the key used for [en|de]crypting auth credentials.
- *
- * @return string The secret key.
- */
- static public function getAuthKey()
- {
- $key = &self::$_authkey;
-
- if (is_null($key)) {
- $key = Horde_Secret::getKey(Horde_Auth::getProvider() == 'imp' ? 'auth' : 'imp');
- }
- return $key;
- }
-
- /**
* Returns a Horde_Cache object (if configured) and handles any errors
* associated with creating the object.
*
static public function canCompose()
{
try {
- return empty($conf['hooks']['disable_compose']) ||
- !Horde::callHook('_imp_hook_disable_compose', array(), 'imp');
+ return empty($conf['hooks']['disable_compose']) || !Horde::callHook('_imp_hook_disable_compose', array(), 'imp');
} catch (Horde_Exception $e) {
return true;
}
return false;
}
- Horde_Imap_Client::$encryptKey = IMP::getAuthKey();
+ Horde_Imap_Client::$encryptKey = Horde_Secret::getKey('imp');
$old_error = error_reporting(0);
$this->ob = unserialize($_SESSION['imp']['imap_ob']);
$this->_namespaces = (empty($GLOBALS['conf']['user']['allow_folders'])) ? array() : $ns;
}
- if (!isset($_SESSION['imp']['cache']['tree'])) {
- $imp_cache = IMP::getCache();
- $_SESSION['imp']['cache']['tree'] = $imp_cache
- ? uniqid(mt_rand() . Horde_Auth::getAuth())
- : null;
+ $imp_cache = IMP::getCache();
+ if ($imp_cache) {
+ $_SESSION['imp']['cache']['tree'] = uniqid(mt_rand() . Horde_Auth::getAuth());
}
/* Must set these values here because PHP 5 does not allow assignment
{
/* We only need to store the object if using Horde_Cache and the tree
* has changed. */
- if (empty($this->_changed) ||
- is_null($_SESSION['imp']['cache']['tree'])) {
- return;
+ if (!empty($this->_changed) &&
+ isset($_SESSION['imp']['cache']['tree'])) {
+ $imp_cache = IMP::getCache();
+ $imp_cache->set($_SESSION['imp']['cache']['tree'], serialize($this), 86400);
}
-
- $imp_cache = IMP::getCache();
- $imp_cache->set($_SESSION['imp']['cache']['tree'], serialize($this), 86400);
}
/**
// $items[Horde_Util::addParameter($options_link, 'mobile', 1, false)] = _("Options");
// }
- $logout_link = IMP::getLogoutUrl(Horde_Auth::REASON_LOGOUT);
- if (!empty($logout_link)) {
- $items[$logout_link] = _("Log out");
- }
+ $items[Horde::getServiceLink('logout')] = _("Log out");
foreach ($items as $link => $label) {
$menu->add(new Horde_Mobile_link($label, $link));
/* If 'password' exists in params, it has been encrypted in the
* session so we need to decrypt. */
if (isset($this->_params['password'])) {
- $this->_params['password'] = Horde_Secret::read(IMP::getAuthKey(), $this->_params['password']);
+ $this->_params['password'] = Horde_Secret::read(Horde_Secret::getKey('imp'), $this->_params['password']);
}
}
+++ /dev/null
-<?php
-/**
- * Functions required to create/initialize an IMP session.
- *
- * Copyright 1999-2009 The Horde Project (http://www.horde.org/)
- *
- * See the enclosed file COPYING for license information (GPL). If you
- * did not receive this file, see http://www.fsf.org/copyleft/gpl.html.
- *
- * @author Chuck Hagenbuch <chuck@horde.org>
- * @author Jon Parise <jon@horde.org>
- * @author Michael Slusarz <slusarz@horde.org>
- * @package IMP
- */
-class IMP_Session
-{
- /**
- * The preferred server based on the value from the login form.
- *
- * @var string
- */
- static public $prefServer = null;
-
- /**
- * Take information posted from a login attempt and try setting up
- * an initial IMP session. Handle Horde authentication, if
- * required, and only do enough work to see if the user can log
- * in. This function should only be called once, when the user
- * first logs in. On success, logs a message to the Horde log.
- *
- * Creates the 'imp' session variable with the following entries:
- * 'autologin' -- Is autologin available?
- * 'cache' -- Various IMP libraries can use this variable to cache
- * data.
- * 'file_upload' -- If file uploads are allowed, the max size.
- * 'filteravail' -- Can we apply filters manually?
- * 'imap' -- Config for various IMAP resources (acl, admin,
- * namespace, quota)
- * 'imap_ob' -- The serialized Horde_Imap_Client object.
- * 'logintasks' -- Have the login tasks been completed?
- * 'maildomain' -- See config/servers.php.
- * 'notepadavail' -- Is listing of notepads available?
- * 'protocol' -- Either 'imap' or 'pop'.
- * 'rteavail' -- Is the HTML editor available?
- * 'search' -- Settings used by the IMP_Search library.
- * 'server_key' -- Server used to login.
- * 'smime' -- Settings related to the S/MIME viewer.
- * 'smtp' -- SMTP options ('host' and 'port')
- * 'showunsub' -- Show unsusubscribed mailboxes on the folders screen.
- * 'tasklistavail' -- Is listing of tasklists available?
- * 'uniquser' -- The unique user name.
- * 'view' -- The imp view mode (currently dimp, imp, or mimp)
- *
- * @param string $imapuser The username of the user.
- * @param string $password The password of the user.
- * @param string $server The server to use (see config/servers.php).
- *
- * @return boolean True on success, false on failure.
- */
- static public function createSession($imapuser, $password, $server)
- {
- global $conf, $registry;
-
- /* We need both a username and password. */
- if (!strlen($imapuser) || !strlen($password)) {
- return false;
- }
-
- /* Create the imp session variable. */
- $_SESSION['imp'] = array(
- 'cache' => array(),
- 'imap' => array(),
- 'logintasks' => false,
- 'server_key' => $server,
- 'showunsub' => false
- );
- $sess = &$_SESSION['imp'];
-
- /* Run the username through virtualhost expansion functions if
- * necessary. */
- if (!empty($conf['hooks']['vinfo'])) {
- try {
- $newUser = Horde::callHook('_imp_hook_vinfo', array('username', $imapuser), 'imp');
- if (strlen($newUser)) {
- $imapuser = $newUser;
- }
- } catch (Horde_Exception $e) {}
- }
-
- /* Load the server configuration. */
- $ptr = $GLOBALS['imp_imap']->loadServerConfig($server);
- if ($ptr === false) {
- return false;
- }
-
- /* Determine the unique user name. */
- if (Horde_Auth::isAuthenticated()) {
- $sess['uniquser'] = Horde_Auth::removeHook(Horde_Auth::getAuth());
- } else {
- $sess['uniquser'] = $imapuser;
- if (!empty($ptr['realm'])) {
- $sess['uniquser'] .= '@' . $ptr['realm'];
- }
- }
-
- /* Create the Horde_Imap_Client object now. */
- if ($GLOBALS['imp_imap']->createImapObject($imapuser, $password, $server) === false) {
- unset($_SESSION['imp']);
- return false;
- }
-
- /* Do necessary authentication now (since Horde_Auth:: may need to set
- * values in Horde-land). */
- $auth_imp = new IMP_Auth();
- if ($auth_imp->authenticate($sess['uniquser'], array('password' => $password), true) !== true) {
- unset($_SESSION['imp']);
- return false;
- }
-
- /* Set the protocol. */
- $sess['protocol'] = isset($ptr['protocol']) ? $ptr['protocol'] : 'imap';
-
- /* Set the maildomain. */
- $maildomain = $GLOBALS['prefs']->getValue('mail_domain');
- $sess['maildomain'] = ($maildomain) ? $maildomain : $ptr['maildomain'];
-
- /* Store some basic IMAP server information. */
- if ($sess['protocol'] == 'imap') {
- foreach (array('acl', 'admin', 'namespace', 'quota') as $val) {
- if (isset($ptr[$val])) {
- $sess['imap'][$val] = $ptr[$val];
-
- /* 'admin' and 'quota' have password entries - encrypt
- * these entries in the session if they exist. */
- if (isset($ptr[$val]['params']['password'])) {
- $sess['imap'][$val]['params']['password'] = Horde_Secret::write(IMP::getAuthKey(), $ptr[$val]['params']['password']);
- }
- }
- }
- }
-
- /* Set the SMTP options, if needed. */
- if ($conf['mailer']['type'] == 'smtp') {
- $sess['smtp'] = array();
- foreach (array('smtphost' => 'host', 'smtpport' => 'port') as $key => $val) {
- if (!empty($ptr[$key])) {
- $sess['smtp'][$val] = $ptr[$key];
- }
- }
- }
-
- /* Does the server allow file uploads? If yes, store the
- * value, in bytes, of the maximum file size. */
- $sess['file_upload'] = $GLOBALS['browser']->allowFileUploads();
-
- /* Is the 'mail/canApplyFilters' API call available? */
- try {
- if ($registry->call('mail/canApplyFilters')) {
- $sess['filteravail'] = true;
- }
- } catch (Horde_Exception $e) {}
-
- /* Is the 'tasks/listTasklists' call available? */
- if ($conf['tasklist']['use_tasklist'] &&
- $registry->hasMethod('tasks/listTasklists')) {
- $sess['tasklistavail'] = true;
- }
-
- /* Is the 'notes/listNotepads' call available? */
- if ($conf['notepad']['use_notepad'] &&
- $registry->hasMethod('notes/listNotepads')) {
- $sess['notepadavail'] = true;
- }
-
- /* Is the HTML editor available? */
- $imp_ui = new IMP_UI_Compose();
- $editor = $imp_ui->initRTE(null, true);
- $sess['rteavail'] = $editor->supportedByBrowser();
-
- /* Cache autologin check. */
- $sess['autologin'] = self::canAutologin();
-
- /* Set up search information for the session. */
- $GLOBALS['imp_search']->sessionSetup();
-
- IMP::loginLogMessage('login', __FILE__, __LINE__, PEAR_LOG_NOTICE);
-
- return true;
- }
-
- /**
- * Perform IMP login tasks.
- *
- * @param string $url The URL to use for the Horde_LoginTasks redirect.
- */
- static public function loginTasks($url = null)
- {
- if (!empty($_SESSION['imp']['logintasks'])) {
- return;
- }
-
- /* Do login tasks. */
- $tasks = Horde_LoginTasks::singleton('imp', is_null($url) ? Horde::selfUrl(true, true, true) : $url);
- $tasks->runTasks();
-
- /* If the user wants to run filters on login, make sure they get
- run. */
- if ($GLOBALS['prefs']->getValue('filter_on_login')) {
- /* Run filters. */
- $imp_filter = new IMP_Filter();
- $imp_filter->filter('INBOX');
- }
-
- /* Check for drafts due to session timeouts. */
- $imp_compose = IMP_Compose::singleton();
- $imp_compose->recoverSessionExpireDraft();
-
- $_SESSION['imp']['logintasks'] = true;
- }
-
- /**
- * Returns the autologin server key.
- *
- * @return string The server key, or null if none available.
- */
- static public function getAutoLoginServer()
- {
- if (($servers = IMP_Imap::loadServerConfig()) === false) {
- return null;
- }
-
- $server_key = null;
- foreach ($servers as $key => $val) {
- if (is_null($server_key) && substr($key, 0, 1) != '_') {
- $server_key = $key;
- }
- if (self::isPreferredServer($val, $key)) {
- $server_key = $key;
- break;
- }
- }
-
- return $server_key;
- }
-
- /**
- * Returns whether we can log in without a login screen for $server_key.
- *
- * @param string $server_key The server to check. Defaults to the
- * autologin server.
- * @param boolean $force If true, check $server_key even if there is
- * more than one server available.
- *
- * @return mixed The autologin user if autologin is available, or false.
- */
- static public function canAutoLogin($server_key = null, $force = false)
- {
- if (($servers = $GLOBALS['imp_imap']->loadServerConfig()) === false) {
- return false;
- }
-
- if (is_null($server_key) || !$force) {
- $auto_server = self::getAutoLoginServer();
- if (is_null($server_key)) {
- $server_key = $auto_server;
- }
- }
-
- if ((!empty($auto_server) || $force) &&
- Horde_Auth::getAuth() &&
- !empty($servers[$server_key]['hordeauth'])) {
- return (strcasecmp($servers[$server_key]['hordeauth'], 'full') == 0)
- ? Horde_Auth::getAuth()
- : Horde_Auth::getBareAuth();
- }
-
- return false;
- }
-
- /**
- * Determines if the given mail server is the "preferred" mail server for
- * this web server. This decision is based on the global 'SERVER_NAME'
- * and 'HTTP_HOST' server variables and the contents of the 'preferred'
- * field in the server's definition. The 'preferred' field may take a
- * single value or an array of multiple values.
- *
- * @param string $server A complete server entry from the $servers hash.
- * @param string $key The server key entry.
- *
- * @return boolean True if this entry is "preferred".
- */
- static public function isPreferredServer($server, $key = null)
- {
- if (!is_null(self::$prefServer)) {
- return ($key == self::$prefServer);
- }
-
- if (!empty($server['preferred'])) {
- if (is_array($server['preferred'])) {
- if (in_array($_SERVER['SERVER_NAME'], $server['preferred']) ||
- in_array($_SERVER['HTTP_HOST'], $server['preferred'])) {
- return true;
- }
- } elseif (($server['preferred'] == $_SERVER['SERVER_NAME']) ||
- ($server['preferred'] == $_SERVER['HTTP_HOST'])) {
- return true;
- }
- }
-
- return false;
- }
-
- /**
- * Returns the initial URL.
- *
- * @param string $actionID The action ID to perform on the initial page.
- * @param boolean $encode If true the argument separator gets encoded.
- *
- * @return string The initial URL.
- */
- static public function getInitialUrl($actionID = null, $encode = true)
- {
- /* TODO: For now, redirect MIMP to mailbox page. */
- if ($_SESSION['imp']['view'] == 'mimp') {
- $url = Horde_Util::addParameter(Horde::applicationUrl('mailbox-mimp.php', true), array('mailbox' => 'INBOX'));
- if (!empty($actionID)) {
- $url = Horde_Util::addParameter($url, array('actionID' => $actionID), null, false);
- }
- return $url;
- }
-
- /* Redirect DIMP to index page. */
- if ($_SESSION['imp']['view'] == 'dimp') {
- return Horde::applicationUrl('index-dimp.php', true);
- }
-
- $init_url = ($_SESSION['imp']['protocol'] == 'pop')
- ? 'INBOX'
- : $GLOBALS['prefs']->getValue('initial_page');
-
- $imp_search = new IMP_Search();
-
- if (!$GLOBALS['prefs']->getValue('use_vinbox') &&
- $imp_search->isVINBOXFolder($init_url)) {
- $init_url = 'folders.php';
- } elseif (($imp_search->createSearchID($init_url) == $init_url) &&
- !$imp_search->isVFolder($init_url)) {
- $init_url = 'INBOX';
- if (!$GLOBALS['prefs']->isLocked('initial_page')) {
- $GLOBALS['prefs']->setValue('initial_page', $init_url);
- }
- }
-
- if ($init_url == 'folders.php') {
- $url = Horde_Util::addParameter(Horde::applicationUrl($init_url, !$encode), array_merge(array('folders_token' => Horde::getRequestToken('imp.folders')), IMP::getComposeArgs()), null, $encode);
- } else {
- $url = Horde_Util::addParameter(Horde::applicationUrl('mailbox.php', !$encode), array_merge(array('mailbox' => $init_url, 'mailbox_token' => Horde::getRequestToken('imp.mailbox')), IMP::getComposeArgs()), null, $encode);
- }
-
- if (!empty($actionID)) {
- $url = Horde_Util::addParameter($url, 'actionID', $actionID, $encode);
- }
-
- return $url;
- }
-}
'type' => '{urn:horde}hashHash'
),
- /* Horde_Auth_Application method. */
+ /* Horde_Auth_Application methods. */
+ 'authLoginParams' => array(
+ 'args' => array(),
+ 'checkperms' => false,
+ 'type' => '{urn:horde}hashHash'
+ ),
+
'authAuthenticate' => array(
'args' => array(
'userID' => 'string',
),
'checkperms' => false,
'type' => 'boolean'
+ ),
+
+ 'authTransparent' => array(
+ 'args' => array(),
+ 'checkperms' => false,
+ 'type' => 'boolean'
)
);
*/
function _imp_batchCompose($args = array(), $extra = array())
{
- $GLOBALS['authentication'] = 'none';
+ $GLOBALS['imp_authentication'] = 'none';
require_once dirname(__FILE__) . '/base.php';
$links = array();
*/
function _imp_folderlist()
{
- $GLOBALS['authentication'] = 'none';
- require_once dirname(__FILE__) . '/base.php';
-
- if (IMP::checkAuthentication(true)) {
- $imp_folder = IMP_Folder::singleton();
- return $imp_folder->flist();
+ try {
+ $GLOBALS['imp_authentication'] = 'throw';
+ require_once dirname(__FILE__) . '/base.php';
+ } catch (Horde_Exception $e) {
+ return false;
}
- return false;
+ $imp_folder = IMP_Folder::singleton();
+ return $imp_folder->flist();
}
/**
*/
function _imp_createFolder($folder)
{
- $GLOBALS['authentication'] = 'none';
- require_once dirname(__FILE__) . '/base.php';
-
- if (IMP::checkAuthentication(true)) {
- $imp_folder = IMP_Folder::singleton();
- return $imp_folder->create(IMP::appendNamespace($folder), $GLOBALS['prefs']->getValue('subscribe'));
+ try {
+ $GLOBALS['imp_authentication'] = 'throw';
+ require_once dirname(__FILE__) . '/base.php';
+ } catch (Horde_Exception $e) {
+ return false;
}
- return false;
+ $imp_folder = IMP_Folder::singleton();
+ return $imp_folder->create(IMP::appendNamespace($folder), $GLOBALS['prefs']->getValue('subscribe'));
}
/**
*/
function _imp_deleteMessages($mailbox, $indices)
{
- $GLOBALS['authentication'] = 'none';
- require_once dirname(__FILE__) . '/base.php';
-
- if (IMP::checkAuthentication(true)) {
- $imp_message = IMP_Message::singleton();
- return $imp_message->delete(array($mailbox => $indices), array('nuke' => true));
+ try {
+ $GLOBALS['imp_authentication'] = 'throw';
+ require_once dirname(__FILE__) . '/base.php';
+ } catch (Horde_Exception $e) {
+ return false;
}
- return false;
+ $imp_message = IMP_Message::singleton();
+ return $imp_message->delete(array($mailbox => $indices), array('nuke' => true));
}
/**
*/
function _imp_copyMessages($mailbox, $indices, $target)
{
- $GLOBALS['authentication'] = 'none';
- require_once dirname(__FILE__) . '/base.php';
-
- if (IMP::checkAuthentication(true)) {
- $imp_message = IMP_Message::singleton();
- return $imp_message->copy($target, 'copy', array($mailbox => $indices), true);
+ try {
+ $GLOBALS['imp_authentication'] = 'throw';
+ require_once dirname(__FILE__) . '/base.php';
+ } catch (Horde_Exception $e) {
+ return false;
}
- return false;
+ $imp_message = IMP_Message::singleton();
+ return $imp_message->copy($target, 'copy', array($mailbox => $indices), true);
}
/**
*/
function _imp_moveMessages($mailbox, $indices, $target)
{
- $GLOBALS['authentication'] = 'none';
- require_once dirname(__FILE__) . '/base.php';
-
- if (IMP::checkAuthentication(true)) {
- $imp_message = IMP_Message::singleton();
- return $imp_message->copy($target, 'move', array($mailbox => $indices), true);
+ try {
+ $GLOBALS['imp_authentication'] = 'throw';
+ require_once dirname(__FILE__) . '/base.php';
+ } catch (Horde_Exception $e) {
+ return false;
}
- return false;
+ $imp_message = IMP_Message::singleton();
+ return $imp_message->copy($target, 'move', array($mailbox => $indices), true);
}
/**
*/
function _imp_flagMessages($mailbox, $indices, $flags, $set)
{
- $GLOBALS['authentication'] = 'none';
- require_once dirname(__FILE__) . '/base.php';
-
- if (IMP::checkAuthentication(true)) {
- $imp_message = IMP_Message::singleton();
- return $imp_message->flag($flags, 'move', array($mailbox => $indices), $set);
+ try {
+ $GLOBALS['imp_authentication'] = 'throw';
+ require_once dirname(__FILE__) . '/base.php';
+ } catch (Horde_Exception $e) {
+ return false;
}
- return false;
+ $imp_message = IMP_Message::singleton();
+ return $imp_message->flag($flags, 'move', array($mailbox => $indices), $set);
}
/**
*/
function _imp_msgEnvelope($mailbox, $indices)
{
- $GLOBALS['authentication'] = 'none';
- require_once dirname(__FILE__) . '/base.php';
+ try {
+ $GLOBALS['imp_authentication'] = 'throw';
+ require_once dirname(__FILE__) . '/base.php';
+ } catch (Horde_Exception $e) {
+ return false;
+ }
- return IMP::checkAuthentication(true)
- ? $GLOBALS['imp_imap']->ob->fetch($mailbox, array(Horde_Imap_Client::FETCH_ENVELOPE => true), array('ids' => $indices))
- : false;
+ return $GLOBALS['imp_imap']->ob->fetch($mailbox, array(Horde_Imap_Client::FETCH_ENVELOPE => true), array('ids' => $indices));
}
/**
*/
function _imp_searchMailbox($mailbox, $query)
{
- $GLOBALS['authentication'] = 'none';
- require_once dirname(__FILE__) . '/base.php';
+ try {
+ $GLOBALS['imp_authentication'] = 'throw';
+ require_once dirname(__FILE__) . '/base.php';
+ } catch (Horde_Exception $e) {
+ return false;
+ }
- return IMP::checkAuthentication(true)
- ? $GLOBALS['imp_search']->runSearchQuery($query, $mailbox)
- : false;
+ return $GLOBALS['imp_search']->runSearchQuery($query, $mailbox);
}
/**
*/
function _imp_mailboxCacheId($mailbox)
{
- $GLOBALS['authentication'] = 'none';
- require_once dirname(__FILE__) . '/base.php';
+ try {
+ $GLOBALS['imp_authentication'] = 'throw';
+ require_once dirname(__FILE__) . '/base.php';
+ } catch (Horde_Exception $e) {
+ return false;
+ }
- return IMP::checkAuthentication(true)
- ? $GLOBALS['imp_imap']->ob->getCacheId($mailbox)
- : null;
+ return $GLOBALS['imp_imap']->ob->getCacheId($mailbox);
}
/**
*/
function _imp_server()
{
- $GLOBALS['authentication'] = 'none';
- require_once dirname(__FILE__) . '/base.php';
-
- if (IMP::checkAuthentication(true)) {
- $imap_obj = unserialize($_SESSION['imp']['imap_ob']);
- return array(
- 'hostspec' => $imap_obj->getParam('hostspec'),
- 'port' => $imap_obj->getParam('port'),
- 'protocol' => $_SESSION['imp']['protocol'],
- 'secure' => $imap_obj->getParam('secure')
- );
+ try {
+ $GLOBALS['imp_authentication'] = 'throw';
+ require_once dirname(__FILE__) . '/base.php';
+ } catch (Horde_Exception $e) {
+ return null;
}
- return null;
+ $imap_obj = unserialize($_SESSION['imp']['imap_ob']);
+ return array(
+ 'hostspec' => $imap_obj->getParam('hostspec'),
+ 'port' => $imap_obj->getParam('port'),
+ 'protocol' => $_SESSION['imp']['protocol'],
+ 'secure' => $imap_obj->getParam('secure')
+ );
}
/**
function _imp_favouriteRecipients($limit,
$filter = array('new', 'forward', 'reply', 'redirect'))
{
- $GLOBALS['authentication'] = 'none';
+ $GLOBALS['imp_authentication'] = 'none';
require_once dirname(__FILE__) . '/base.php';
if ($GLOBALS['conf']['sentmail']['driver'] != 'none') {
*/
function _imp_changeLanguage()
{
- $GLOBALS['authentication'] = 'none';
- require_once dirname(__FILE__) . '/base.php';
-
- if (IMP::checkAuthentication(true)) {
- $imp_folder = IMP_Folder::singleton();
- $imp_folder->clearFlistCache();
- $imaptree = IMP_Imap_Tree::singleton();
- $imaptree->init();
- $GLOBALS['imp_search']->sessionSetup(true);
+ try {
+ $GLOBALS['imp_authentication'] = 'throw';
+ require_once dirname(__FILE__) . '/base.php';
+ } catch (Horde_Exception $e) {
+ return;
}
+
+ $imp_folder = IMP_Folder::singleton();
+ $imp_folder->clearFlistCache();
+ $imaptree = IMP_Imap_Tree::singleton();
+ $imaptree->init();
+ $GLOBALS['imp_search']->sessionSetup(true);
}
/**
*/
function _imp_cacheOutput($params)
{
- $GLOBALS['authentication'] = 'none';
- require_once dirname(__FILE__) . '/base.php';
+ try {
+ $GLOBALS['imp_authentication'] = 'throw';
+ require_once dirname(__FILE__) . '/base.php';
+ } catch (Horde_Exception $e) {
+ throw new Horde_Exception('No cache data available');
+ }
+
+ switch ($params['id']) {
+ case 'fckeditor':
+ return array(
+ 'data' =>
+ 'FCKConfig.ToolbarSets["ImpToolbar"] = ' . $GLOBALS['prefs']->getValue('fckeditor_buttons') . ";\n" .
+ /* To more closely match "normal" textarea behavior, send
+ * send <BR> on enter instead of <P>. */
+ "FCKConfig.EnterMode = \'br\';\n" .
+ 'FCKConfig.ShiftEnterMode = \'p\';',
+ 'type' => 'text/javascript'
+ );
+ }
+}
- if (IMP::checkAuthentication(true)) {
- switch ($params['id']) {
- case 'fckeditor':
- return array(
- 'data' =>
- 'FCKConfig.ToolbarSets["ImpToolbar"] = ' . $GLOBALS['prefs']->getValue('fckeditor_buttons') . ";\n" .
- // To more closely match "normal" textarea behavior,
- // send <BR> on enter instead of <P>.
- "FCKConfig.EnterMode = \'br\';\n" .
- 'FCKConfig.ShiftEnterMode = \'p\';',
- 'type' => 'text/javascript'
- );
+/*
+ * TODO
+ */
+function _imp_authLoginParams()
+{
+ $params = array();
+
+ if ($GLOBALS['conf']['server']['server_list'] == 'shown') {
+ $servers = IMP_Imap::loadServerConfig();
+ $server_list = array();
+ foreach ($servers as $key => $val) {
+ $server_list[$key] = array('name' => $val['name']);
}
+ $params['imp_server_key'] = array(
+ 'label' => _("Server"),
+ 'selected' => Horde_Util::getFormData('imp_server_key', IMP_Auth::getAutoLoginServer()),
+ 'type' => 'select',
+ 'value' => $server_list
+ );
}
- throw new Horde_Exception('No cache data available');
+ /* If dimp/mimp are available, show selection of alternate views. */
+ if (!empty($GLOBALS['conf']['user']['select_view'])) {
+ $views = array();
+ if (!($view_cookie = Horde_Util::getFormData('imp_select_view'))) {
+ if (isset($_COOKIE['default_imp_view'])) {
+ $view_cookie = $_COOKIE['default_imp_view'];
+ } else {
+ $browser = Horde_Browser::singleton();
+ $view_cookie = $browser->isMobile() ? 'mimp' : 'imp';
+ }
+ }
+
+ $params['imp_select_view'] = array(
+ 'label' => _("Mode"),
+ 'type' => 'select',
+ 'value' => array(
+ 'imp' => array(
+ 'name' => _("Traditional"),
+ 'selected' => $view_cookie == 'imp'
+ ),
+ 'dimp' => array(
+ 'hidden' => true,
+ 'name' => _("Dynamic")
+ // Dimp selected is handled by javascript (dimp_sel)
+ ),
+ 'mimp' => array(
+ 'name' => _("Minimalist"),
+ 'selected' => $view_cookie == 'mimp'
+ )
+ )
+ );
+ }
+
+ return array(
+ 'js_code' => array(
+ 'ImpLogin.dimp_sel=' . intval($view_cookie == 'dimp'),
+ 'ImpLogin.server_key_error=' . Horde_Serialize::serialize(_("Please choose a mail server."), Horde_Serialize::JSON)
+ ),
+ 'js_files' => array(
+ array('login.js', 'imp')
+ ),
+ 'params' => $params
+ );
}
/**
* Tries to authenticate with the mail server and create a mail session.
*
- * @param string $userID The username of the user.
- * @param array $credentials Credentials of the user. Only allowed key:
+ * @param string $userId The username of the user.
+ * @param array $credentials Credentials of the user. Allowed keys:
+ * 'imp_select_view', 'imp_server_key',
* 'password'.
- * @param array $params Additional parameters. Only allowed key:
- * 'server'.
*
- * @return boolean True on success, false on failure.
+ * @throws Horde_Auth_Exception
*/
-function _imp_authAuthenticate($userID, $credentials, $params = array())
+function _imp_authAuthenticate($userId, $credentials)
{
- $GLOBALS['authentication'] = 'none';
- $GLOBALS['noset_view'] = true;
+ $GLOBALS['imp_authentication'] = 'none';
require_once dirname(__FILE__) . '/base.php';
- $server_key = empty($params['server'])
- ? IMP_Session::getAutoLoginServer()
- : $params['server'];
+ $new_session = IMP_Auth::authenticate(array(
+ 'password' => $credentials['password'],
+ 'server' => !empty($credentials['imp_server_key']) ? $credentials['imp_server_key'] : '',
+ 'userid' => $userId
+ ));
+
+ if ($new_session) {
+ global $conf;
+
+ /* Set view in session/cookie. */
+ $view = empty($conf['user']['select_view'])
+ ? (empty($conf['user']['force_view']) ? 'imp' : $conf['user']['force_view'])
+ : (empty($credentials['imp_select_view']) ? 'imp' : $credentials['imp_select_view']);
+
+ setcookie('default_imp_view', $view, time() + 30 * 86400,
+ $conf['cookie']['path'],
+ $conf['cookie']['domain']);
+
+ $_SESSION['imp']['view'] = $view;
+ }
+}
+
+/**
+ * Tries to transparently authenticate with the mail server and create a mail
+ * session.
+ *
+ * @return boolean Whether transparent login is supported.
+ * @throws Horde_Auth_Exception
+ */
+function _imp_authTransparent()
+{
+ /* Transparent auth is a bit goofy - we most likely have reached this
+ * code from the pushApp() call in base.php already. As such, some of the
+ * IMP init has not yet been done, so we need to do the necessary init
+ * here or else things will fail in IMP_Auth. */
+ $GLOBALS['imp_authentication'] = 'none';
+ require_once dirname(__FILE__) . '/base.php';
+ if (!isset($GLOBALS['imp_imap'])) {
+ $GLOBALS['imp_imap'] = new IMP_Imap();
+ }
+ if (!isset($GLOBALS['imp_search'])) {
+ $GLOBALS['imp_search'] = new IMP_Search();
+ }
+
+ if (IMP_Auth::transparent() === false) {
+ return false;
+ }
+
+ /* Set view in session. */
+ $_SESSION['imp']['view'] = empty($GLOBALS['conf']['user']['select_view'])
+ ? (empty($GLOBALS['conf']['user']['force_view']) ? 'imp' : $GLOBALS['conf']['user']['force_view'])
+ : 'imp';
- return IMP_Session::createSession($userID, $credentials['password'], $server_key);
+ return true;
}
/**
- * Adds a set of authentication credentials.
+ * Adds a user defined by authentication credentials.
*
* @param string $userId The userId to add.
* @param array $credentials An array of login credentials. For IMAP,
$params = array_merge($params, $_SESSION['imp']['admin']['params']);
if (isset($params['admin_password'])) {
- $params['admin_password'] = Horde_Secret::read(IMP::getAuthKey(), $params['admin_password']);
+ $params['admin_password'] = Horde_Secret::read(Horde_Secret::getKey('imp'), $params['admin_password']);
}
$auth = Horde_Auth::singleton('imap', $params);
$auth->addUser($userId, $credentials);
}
/**
- * Deletes a set of authentication credentials.
+ * Deletes a user defined by authentication credentials.
*
* @param string $userId The userId to delete.
*
$params = array_merge($params, $_SESSION['imp']['admin']['params']);
if (isset($params['admin_password'])) {
- $params['admin_password'] = Horde_Secret::read(IMP::getAuthKey(), $params['admin_password']);
+ $params['admin_password'] = Horde_Secret::read(Horde_Secret::getKey('imp'), $params['admin_password']);
}
$auth = Horde_Auth::singleton('imap', $params);
$auth->removeUser($userId);
$params = array_merge($params, $_SESSION['imp']['admin']['params']);
if (isset($params['admin_password'])) {
- $params['admin_password'] = Horde_Secret::read(IMP::getAuthKey(), $params['admin_password']);
+ $params['admin_password'] = Horde_Secret::read(Horde_Secret::getKey('imp'), $params['admin_password']);
}
$auth = Horde_Auth::singleton('imap', $params);
return $auth->listUsers();
* IMP base inclusion file. This file brings in all of the dependencies that
* every IMP script will need, and sets up objects that all scripts use.
*
- * The following variables, defined in the script that calls this one, are
- * used:
- * $authentication - The type of authentication to use:
- * 'horde' - Only use horde authentication
- * 'none' - Do not authenticate
- * Default - Authenticate to IMAP/POP server
- * $compose_page - If true, we are on IMP's compose page
- * $dimp_logout - Logout and redirect to the login page.
- * $login_page - If true, we are on IMP's login page
- * $mimp_debug - If true, output text/plain version of page.
- * $no_compress - Controls whether the page should be compressed
- * $session_control - Sets special session control limitations
+ * The following global variables are used:
+ * <pre>
+ * imp_authentication - The type of authentication to use:
+ * 'horde' - Only use horde authentication
+ * 'none' - Do not authenticate
+ * 'throw' - Authenticate to IMAP/POP server; on no auth, throw a
+ * Horde_Exception
+ * Default - Authenticate to IMAP/POP server; on no auth redirect to login
+ * screen
+ * imp_compose_page - If true, we are on IMP's compose page
+ * imp_dimp_logout - Logout and redirect to the login page.
+ * imp_no_compress - Controls whether the page should be compressed
+ * imp_session_control - Sets special session control limitations:
+ * <pre>
+ * 'netscape'
+ * 'none'
+ * 'readonly'
+ * </pre>
*
* Global variables defined:
* $imp_imap - An IMP_Imap object
* $imp_mbox - Current mailbox information
* $imp_notify - A Horde_Notification_Listener object
* $imp_search - An IMP_Search object
- * $mimp_render - (MIMP view only) A Horde_Mobile object
*
* Copyright 1999-2009 The Horde Project (http://www.horde.org/)
*
// Registry.
$s_ctrl = 0;
-switch (Horde_Util::nonInputVar('session_control')) {
+switch (Horde_Util::nonInputVar('imp_session_control')) {
case 'netscape':
if ($browser->isBrowser('mozilla')) {
session_cache_limiter('private, must-revalidate');
}
$registry = Horde_Registry::singleton($s_ctrl);
-// We explicitly do not check application permissions for the compose
-// and login pages, since those are handled below and need to fall through
-// to IMP-specific code.
-$compose_page = Horde_Util::nonInputVar('compose_page');
-try {
- $registry->pushApp('imp', !(defined('AUTH_HANDLER') || $compose_page));
-} catch (Horde_Exception $e) {
- if ($e->getCode() == 'permission_denied') {
- Horde::authenticationFailureRedirect();
- }
- throw $e;
-}
-
-$conf = &$GLOBALS['conf'];
-if (!defined('IMP_TEMPLATES')) {
- define('IMP_TEMPLATES', $registry->get('templates'));
-}
-
-// TODO: Remove once this can be autoloaded
-require_once 'Horde/Identity.php';
-
-// Initialize global $imp_imap object.
-if (!isset($GLOBALS['imp_imap'])) {
- $GLOBALS['imp_imap'] = new IMP_Imap();
-}
-
-// Start compression.
-if (!Horde_Util::nonInputVar('no_compress')) {
- Horde::compressOutput();
-}
-
-// If IMP isn't responsible for Horde auth, and no one is logged into
-// Horde, redirect to the login screen. If this is a compose window
-// that just timed out, store the draft.
-if (!(Horde_Auth::isAuthenticated() || (Horde_Auth::getProvider() == 'imp'))) {
- if ($compose_page) {
- $imp_compose = IMP_Compose::singleton();
- $imp_compose->sessionExpireDraft();
- }
- Horde::authenticationFailureRedirect();
-}
-
// Determine view mode.
$viewmode = isset($_SESSION['imp']['view'])
? $_SESSION['imp']['view']
: 'imp';
-$authentication = Horde_Util::nonInputVar('authentication', 0);
-if ($authentication !== 'none') {
- // If we've reached this point and have valid login credentials
- // but don't actually have an IMP session, then we need to go
- // through redirect.php to ensure that everything gets set up
- // properly. Single-signon and transparent authentication setups
- // are likely to trigger this case.
- if (empty($_SESSION['imp'])) {
- if ($compose_page) {
- $imp_compose = IMP_Compose::singleton();
- $imp_compose->sessionExpireDraft();
- require IMP_BASE . '/login.php';
- } else {
- require IMP_BASE . '/redirect.php';
- }
- exit;
- }
+// Handle dimp logout requests.
+if (($viewmode == 'dimp') && Horde_Util::nonInputVar('imp_dimp_logout')) {
+ Horde::redirect(str_replace('&', '&', Horde::getServiceLink('logout')));
+}
- if ($compose_page) {
- if (!IMP::checkAuthentication(true, ($authentication === 'horde'))) {
- $imp_compose = IMP_Compose::singleton();
- $imp_compose->sessionExpireDraft();
- require IMP_BASE . '/login.php';
- exit;
+// Determine imp authentication type.
+$authentication = Horde_Util::nonInputVar('imp_authentication');
+if ($authentication == 'horde') {
+ IMP_Auth::$authType = 'horde';
+}
+
+try {
+ $registry->pushApp('imp', ($authentication != 'none'));
+} catch (Horde_Exception $e) {
+ if ($e->getCode() == Horde_Registry::AUTH_FAILURE) {
+ if ($authentication == 'throw') {
+ throw $e;
}
- } elseif ($viewmode == 'dimp') {
- // Handle session timeouts
- if (!IMP::checkAuthentication(true)) {
+
+ if ($viewmode == 'dimp') {
+ // Handle session timeouts
switch (Horde_Util::nonInputVar('session_timeout')) {
case 'json':
$GLOBALS['notification']->push(null, 'dimp.timeout');
Horde::sendHTTPResponse(Horde::prepareResponse(), 'json');
- // Fall through
+ exit;
case 'none':
exit;
default:
- Horde::redirect(Horde_Util::addParameter(Horde::url($GLOBALS['registry']->get('webroot', 'imp') . '/redirect.php'), 'url', Horde::selfUrl(true)));
+ // TODO: Redirect to login screen
+ exit;
}
}
- } else {
- IMP::checkAuthentication(false, ($authentication === 'horde'));
+
+ if (Horde_Util::nonInputVar('imp_compose_page')) {
+ $imp_compose = IMP_Compose::singleton();
+ $imp_compose->sessionExpireDraft();
+ }
}
- /* Some stuff that only needs to be initialized if we are
- * authenticated. */
+ Horde_Auth::authenticationFailureRedirect('imp', $e);
+}
+
+$conf = &$GLOBALS['conf'];
+if (!defined('IMP_TEMPLATES')) {
+ define('IMP_TEMPLATES', $registry->get('templates'));
+}
+
+// Start compression.
+if (!Horde_Util::nonInputVar('imp_no_compress')) {
+ Horde::compressOutput();
+}
+
+/* Some stuff that only needs to be initialized if we are authenticated. */
+// TODO: Remove once this can be autoloaded
+require_once 'Horde/Identity.php';
+
+// Initialize global $imp_imap object.
+if (!isset($GLOBALS['imp_imap'])) {
+ $GLOBALS['imp_imap'] = new IMP_Imap();
+}
+
+if ($authentication !== 'none') {
// Initialize some message parsing variables.
Horde_Mime::$brokenRFC2231 = !empty($GLOBALS['conf']['mailformat']['brokenrfc2231']);
}
}
-// Handle logout requests
-if (($viewmode == 'dimp') && Horde_Util::nonInputVar('dimp_logout')) {
- Horde::redirect(str_replace('&', '&', IMP::getLogoutUrl()));
-}
-
-// Notification system.
$notification = Horde_Notification::singleton();
-if (($viewmode == 'mimp') ||
- (Horde_Util::nonInputVar('login_page') && $GLOBALS['browser']->isMobile())) {
+if ($viewmode == 'mimp') {
$GLOBALS['imp_notify'] = $notification->attach('status', null, 'Horde_Notification_Listener_Mobile');
} else {
$GLOBALS['imp_notify'] = $notification->attach('status', array('viewmode' => $viewmode), 'IMP_Notification_Listener_Status');
// Initialize IMP_Search object.
$GLOBALS['imp_search'] = new IMP_Search(array('id' => (isset($_SESSION['imp']) && IMP_Search::isSearchMbox($GLOBALS['imp_mbox']['mailbox'])) ? $GLOBALS['imp_mbox']['mailbox'] : null));
-
-if ($viewmode == 'mimp') {
- // Mobile markup renderer.
- $debug = Horde_Util::nonInputVar('mimp_debug');
- $GLOBALS['mimp_render'] = new Horde_Mobile(null, $debug);
- $GLOBALS['mimp_render']->set('debug', !empty($debug));
-} elseif (empty($_SESSION['imp']['logintasks']) &&
- ($authentication !== 'none') &&
- !defined('AUTH_HANDLER')) {
- /* This captures all login tasks requests other than the IMP
- * authentication + frameset case which needs to be handled in
- * redirect.php. */
- IMP_Session::loginTasks();
-}
/* Make sure we have an active IMAP stream. */
try {
- $res = $GLOBALS['registry']->call('mail/server');
+ $GLOBALS['registry']->call('mail/server');
} catch (Horde_Exception $e) {
- $res = false;
-}
-
-if (!$res) {
- header('Location: ' . Horde_Util::addParameter(Horde::applicationUrl('redirect.php'), 'url', Horde::selfUrl(true)));
- exit;
+ // TODO: Send to login screen
+ throw $e;
}
/* Add necessary javascript files here (so they are added to the document
+++ /dev/null
-<?php
-/**
- * Login screen for IMP.
- *
- * Copyright 1999-2009 The Horde Project (http://www.horde.org/)
- *
- * See the enclosed file COPYING for license information (GPL). If you
- * did not receive this file, see http://www.fsf.org/copyleft/gpl.html.
- *
- * @author Chuck Hagenbuch <chuck@horde.org>
- * @author Michael Slusarz <slusarz@horde.org>
- * @package IMP
- */
-
-@define('AUTH_HANDLER', true);
-$authentication = 'none';
-$login_page = true;
-require_once dirname(__FILE__) . '/lib/base.php';
-
-/* Set the 'preferred' server. */
-$pref_server = Horde_Util::getFormData('server');
-if (!empty($pref_server)) {
- IMP_Session::$prefServer = $pref_server;
-}
-
-/* Get an Auth object. */
-$imp_auth = (Horde_Auth::getProvider() == 'imp');
-$auth = Horde_Auth::singleton($conf['auth']['driver']);
-$logout_reason = Horde_Auth::getLogoutReason();
-
-$actionID = (Horde_Util::getFormData('action') == 'compose') ? 'login_compose' : Horde_Util::getFormData('actionID');
-$url_param = Horde_Util::getFormData('url');
-
-$load_frameset = intval($imp_auth && empty($conf['menu']['always']));
-
-/* Handle cases where we already have a session. */
-if (!empty($_SESSION['imp']) && is_array($_SESSION['imp'])) {
- if ($logout_reason) {
- /* Log logout requests now. */
- if ($logout_reason == Horde_Auth::REASON_LOGOUT) {
- IMP::loginLogMessage('logout', __FILE__, __LINE__, PEAR_LOG_NOTICE);
- } else {
- Horde::logMessage($_SERVER['REMOTE_ADDR'] . ' ' . Horde_Auth::getLogoutReasonString(), __FILE__, __LINE__, PEAR_LOG_NOTICE);
- }
-
- $language = (isset($prefs)) ? $prefs->getValue('language') : Horde_Nls::select();
-
- unset($_SESSION['imp']);
-
- /* Cleanup preferences. */
- if (isset($prefs)) {
- $prefs->cleanup($imp_auth);
- }
-
- if ($imp_auth) {
- Horde_Auth::clearAuth();
- @session_destroy();
- $registry->setupSessionHandler();
- @session_start();
- }
-
- Horde_Nls::setLang($language);
-
- /* Hook to preselect the correct language in the widget. */
- $_GET['new_lang'] = $language;
-
- $registry->loadPrefs('horde');
- $registry->loadPrefs();
- } else {
- if ($url_param) {
- $url = Horde::applicationUrl('redirect.php', true);
- $params = array('url' => $url_param);
- $url = Horde_Util::addParameter($url, $params, null, false);
- } else {
- $url = IMP_Session::getInitialUrl($actionID, false);
- }
- header('Location: ' . $url);
- exit;
- }
-}
-
-/* Log session timeouts. */
-if ($logout_reason == Horde_Auth::REASON_SESSION) {
- $entry = sprintf('Session timeout for client [%s]', $_SERVER['REMOTE_ADDR']);
- Horde::logMessage($entry, __FILE__, __LINE__, PEAR_LOG_NOTICE);
-
- /* Make sure everything is really cleared. */
- Horde_Auth::clearAuth();
- unset($_SESSION['imp']);
-}
-
-/* Redirect the user on logout if redirection is enabled. */
-if ($logout_reason == Horde_Auth::REASON_LOGOUT &&
- (!empty($conf['user']['redirect_on_logout']) ||
- !empty($conf['auth']['redirect_on_logout']))) {
- if (!empty($conf['auth']['redirect_on_logout'])) {
- $url = Horde_Auth::addLogoutParameters($conf['auth']['redirect_on_logout'], Horde_Auth::REASON_LOGOUT);
- } else {
- $url = Horde_Auth::addLogoutParameters($conf['user']['redirect_on_logout'], Horde_Auth::REASON_LOGOUT);
- }
- if (!isset($_COOKIE[session_name()])) {
- $url = Horde_Util::addParameter($url, session_name(), session_id());
- }
- header('Location: ' . $url);
- exit;
-}
-
-/* Redirect the user if an alternate login page has been specified. */
-if (!empty($conf['auth']['alternate_login'])) {
- $url = Horde_Auth::addLogoutParameters($conf['auth']['alternate_login']);
- if (!isset($_COOKIE[session_name()])) {
- $url = Horde_Util::addParameter($url, session_name(), session_id(), false);
- }
- if ($url_param) {
- $url = Horde_Util::addParameter($url, 'url', $url_param, false);
- }
- header('Location: ' . $url);
- exit;
-} elseif (!empty($conf['user']['alternate_login'])) {
- $url = Horde_Auth::addLogoutParameters($conf['user']['alternate_login']);
- if (!isset($_COOKIE[session_name()])) {
- $url = Horde_Util::addParameter($url, session_name(), session_id(), false);
- }
- header('Location: ' . $url);
- exit;
-}
-
-/* Initialize the password key. If we are doing Horde auth as well,
- * make sure that the Horde auth key gets set instead. */
-Horde_Secret::setKey($imp_auth ? 'auth' : 'imp');
-
-$autologin = Horde_Util::getFormData('autologin', false);
-$server_key = Horde_Util::getFormData('server_key', IMP_Session::getAutoLoginServer());
-if (($servers = $GLOBALS['imp_imap']->loadServerConfig()) === false) {
- $servers = array();
-}
-$used_servers = $servers;
-if ($conf['server']['server_list'] != 'shown') {
- $used_servers = array($server_key => $servers[$server_key]);
-}
-
-if (!$logout_reason && IMP_Session::canAutoLogin($server_key, $autologin)) {
- $url = Horde::applicationUrl('redirect.php', true);
- $params = array('actionID' => 'login', 'autologin' => true, 'url' => $url_param);
- if (count($used_servers) == 1) {
- $params['server_key'] = key($used_servers);
- }
- $url = Horde_Util::addParameter($url, $params, null, false);
- header('Location: ' . $url);
- exit;
-}
-
-$title = sprintf(_("Welcome to %s"), $registry->get('name', ($imp_auth) ? 'horde' : null));
-
-if ($logout_reason) {
- $notification->push(str_replace('<br />', ' ', Horde_Auth::getLogoutReasonString()), 'horde.message');
-}
-
-/* Build the <select> widget for the servers and hordeauth servers lists. */
-$show_list = ($conf['server']['server_list'] == 'shown');
-if ($show_list) {
- $hordeauth_servers_list = $servers_list = array();
- $isAuth = Horde_Auth::isAuthenticated();
- foreach ($servers as $key => $val) {
- $entry = array(
- 'sel' => ($server_key == $key) || IMP_Session::isPreferredServer($val, $key),
- 'val' => $key,
- 'name' => $val['name']
- );
-
- if (empty($val['hordeauth']) || !$isAuth) {
- $servers_list[] = $entry;
- } elseif ($isAuth) {
- $hordeauth_servers_list[] = $entry;
- }
- }
-}
-
-$lang_url = null;
-$choose_language = ($imp_auth && !$prefs->isLocked('language'));
-if ($choose_language) {
- $_SESSION['horde_language'] = Horde_Nls::select();
- $langs = array();
- foreach (Horde_Nls::$config['languages'] as $key => $val) {
- $langs[] = array(
- 'sel' => ($key == $_SESSION['horde_language']),
- 'val' => $key,
- 'name' => $val
- );
- }
-
- if (!empty($url_param)) {
- $lang_url = urlencode($url_param);
- }
-}
-
-/* If DIMP/MIMP are available, show selection of alternate views. */
-$views = array();
-if (!empty($conf['user']['select_view'])) {
- $view_cookie = isset($_COOKIE['default_imp_view'])
- ? $_COOKIE['default_imp_view']
- : ($browser->isMobile() ? 'mimp' : 'imp');
- $views = array(
- array(
- 'sel' => $view_cookie == 'imp',
- 'val' => 'imp',
- 'name' => _("Traditional")
- ),
- array(
- 'val' => 'dimp',
- 'name' => _("Dynamic"),
- 'hide' => true
- ),
- array(
- 'sel' => $view_cookie == 'mimp',
- 'val' => 'mimp',
- 'name' => _("Minimalist")
- )
- );
-
- /* Dimp selection is handled by javascript. */
- $dimp_sel = ($view_cookie == 'dimp');
-}
-
-/* Mobile login page. */
-if ($browser->isMobile()) {
- require_once 'Horde/Mobile.php';
-
- /* Build the <select> widget for the servers list. */
- if ($show_list) {
- $server_select = new Horde_Mobile_select('server', 'popup', _("Server:"));
- foreach ($servers_list as $val) {
- $server_select->add($val['name'], $val['val'], $val['sel']);
- }
- }
-
- /* Build the <select> widget containing the available languages. */
- if ($choose_language) {
- // Language names are already encoded.
- $lang_select = new Horde_Mobile_select('new_lang', 'popup', _("Language:"));
- $lang_select->set('htmlchars', true);
- foreach ($langs as $val) {
- $lang_select->add($val['name'], $val['val'], $val['sel']);
- }
- }
-
- /* Build the <select> widget containing the available views. */
- if (!empty($views)) {
- $view_select = new Horde_Mobile_select('select_view', 'popup', _("Mode:"));
- foreach ($views as $val) {
- $view_select->add($val['name'], $val['val'], $val['sel']);
- }
- }
-
- require IMP_TEMPLATES . '/login/mobile.inc';
- exit;
-}
-
-$display_list = ($show_list && !empty($hordeauth_servers_list));
-
-/* Prepare the login template. */
-$t = new Horde_Template();
-$t->setOption('gettext', true);
-$tabindex = 0;
-
-$t->set('action', Horde::url('redirect.php', false, -1, true));
-$t->set('imp_auth', intval($imp_auth));
-$t->set('formInput', Horde_Util::formInput());
-$t->set('actionID', htmlspecialchars($actionID));
-$t->set('url', htmlspecialchars($url_param));
-$t->set('autologin', intval($autologin));
-$t->set('anchor_string', htmlspecialchars(Horde_Util::getFormData('anchor_string')));
-$t->set('server_key', (!$display_list) ? htmlspecialchars($server_key) : null);
-
-/* Do we need to do IE version detection? */
-$t->set('ie_clientcaps', (!Horde_Auth::getAuth() && ($browser->getBrowser() == 'msie') && ($browser->getMajor() >= 5)));
-
-$extra_hidden = array();
-foreach (IMP::getComposeArgs() as $arg => $value) {
- $extra_hidden[] = array('name' => htmlspecialchars($arg), 'value' => htmlspecialchars($value));
-}
-$t->set('extra_hidden', $extra_hidden);
-
-$menu = new Horde_Menu(Horde_Menu::MASK_NONE);
-$t->set('menu', $menu->render());
-$t->set('title', sprintf(_("Welcome to %s"), $registry->get('name', ($imp_auth) ? 'horde' : null)));
-
-ob_start();
-$notification->notify(array('listeners' => 'status'));
-$t->set('notification_output', ob_get_contents());
-ob_end_clean();
-
-$t->set('display_list', $display_list);
-if ($display_list) {
- $t->set('hsl_skey_tabindex', ++$tabindex);
- $t->set('hsl', $hordeauth_servers_list);
- $t->set('hsl_tabindex', ++$tabindex);
-}
-
-$t->set('server_list', ($show_list && !empty($servers_list)));
-if ($t->get('server_list')) {
- $t->set('slist_tabindex', ++$tabindex);
- $t->set('slist', $servers_list);
-}
-
-$t->set('username_tabindex', ++$tabindex);
-$t->set('username', htmlspecialchars(Horde_Util::getFormData('imapuser')));
-$t->set('user_vinfo', null);
-if (!empty($conf['hooks']['vinfo'])) {
- $t->set('user_vinfo', Horde::callHook('_imp_hook_vinfo', array('vdomain'), 'imp'));
-}
-$t->set('password_tabindex', ++$tabindex);
-
-$t->set('choose_language', $choose_language);
-if ($choose_language) {
- $t->set('langs_tabindex', ++$tabindex);
- $t->set('langs', $langs);
-}
-
-$t->set('select_view', !empty($views));
-if ($t->get('select_view')) {
- $t->set('view_tabindex', ++$tabindex);
- $t->set('views', $views);
-}
-
-$t->set('login_tabindex', ++$tabindex);
-$t->set('login', _("Login"));
-
-$t->set('signup_link', false);
-if ($conf['signup']['allow'] && isset($auth) && $auth->hasCapability('add')) {
- $t->set('signup_text', _("Don't have an account? Sign up."));
- $t->set('signup_link', Horde::link(Horde_Util::addParameter(Horde::url($registry->get('webroot', 'horde') . '/signup.php'), 'url', $url_param), $t->get('signup_text'), 'light'));
-}
-
-$login_page = true;
-Horde::addScriptFile('prototype.js', 'horde', true);
-Horde::addScriptFile('login.js', 'imp', true);
-require IMP_TEMPLATES . '/common-header.inc';
-
-$charset = Horde_Nls::getCharset();
-$login_params = $autologin
- ? array('autologin' => $autologin, 'server_key' => '')
- : array('server_key' => '');
-
-Horde::addInlineScript(array(
- 'ImpLogin.autologin_url = ' . Horde_Serialize::serialize(Horde_Util::addParameter(Horde::selfUrl(), $login_params, null, false), Horde_Serialize::JSON, $charset),
- 'ImpLogin.ie_clientcaps = ' . intval($t->get('ie_clientcaps')),
- 'ImpLogin.imp_auth = ' . intval($imp_auth),
- 'ImpLogin.lang_url = ' . Horde_Serialize::serialize($lang_url, Horde_Serialize::JSON, $charset),
- 'ImpLogin.nomenu = ' . $load_frameset,
- 'ImpLogin.reloadmenu = ' . intval($logout_reason && $load_frameset),
- 'ImpLogin.show_list = ' . intval($show_list),
- 'ImpLogin.dimp_sel = ' . intval($dimp_sel),
-));
-
-echo $t->fetch(IMP_TEMPLATES . '/login/login.html');
-
-try {
- Horde::loadConfiguration('motd.php', null, null, true);
-} catch (Horde_Exception $e) {}
-require $registry->get('templates', 'horde') . '/common-footer.inc';
/* Generate mailbox summary string. */
$title = IMP::getLabel($imp_mbox['mailbox']);
+$mimp_render = new Horde_Mobile();
$mimp_render->set('title', $title);
if ($pageOb['msgcount']) {
$msgcount = $pageOb['msgcount'];
$redirect = Horde_Util::addParameter(IMP::generateIMPUrl('thread.php', $imp_mbox['mailbox'], null, null, false), array('mode' => 'msgview', 'msglist' => $GLOBALS['imp_imap']->ob->utils->toSequenceString(IMP::parseIndicesList($indices), array('mailbox' => true))), null, false);
header('Location: ' . $redirect);
exit;
-
-case 'login_compose':
- $open_compose_window = IMP::openComposeWin();
- break;
}
/* Token to use in requests */
$mailbox_link = Horde_Util::addParameter(IMP::generateIMPUrl('mailbox-mimp.php', $imp_mbox['mailbox']), array('s' => $msgindex));
$self_link = IMP::generateIMPUrl('message-mimp.php', $imp_mbox['mailbox'], $index, $mailbox_name);
+/* Init render object. */
+$mimp_render = new Horde_Mobile();
+
/* Output download confirmation screen. */
$atc_id = Horde_Util::getFormData('atc');
if (($actionID == 'c') && !is_null($atc_id)) {
+++ /dev/null
-<?php
-/**
- * Copyright 1999-2009 The Horde Project (http://www.horde.org/)
- *
- * See the enclosed file COPYING for license information (GPL). If you
- * did not receive this file, see http://www.fsf.org/copyleft/gpl.html.
- *
- * @author Chuck Hagenbuch <chuck@horde.org>
- * @package IMP
- */
-
-function _framesetUrl($url)
-{
- if (!empty($conf['menu']['always']) ||
- $GLOBALS['prefs']->getValue('show_sidebar')) {
- $url = Horde_Util::addParameter(Horde::applicationUrl($GLOBALS['registry']->get('webroot', 'horde') . '/index.php', true), array('url' => _addAnchor($url, 'param')), null, false);
-
- /* Need to do a loginTasks check here because we must display login
- * tasks before frameset is loaded. */
- IMP_Session::loginTasks($url);
- }
-
- return $url;
-}
-
-function _newSessionUrl($actionID)
-{
- $url = '';
- $addActionID = true;
-
- if ($GLOBALS['url_in']) {
- $url = Horde::url(Horde_Util::removeParameter($GLOBALS['url_in'], session_name()), true);
- } elseif (Horde_Auth::getProvider() == 'imp') {
- $url = Horde::applicationUrl($GLOBALS['registry']->get('webroot', 'horde') . '/', true);
-
- /* Force the initial page to IMP if we're logging in to compose a
- * message. */
- if ($actionID == 'login_compose') {
- $url = Horde_Util::addParameter($url, 'url', _addAnchor(IMP_Session::getInitialUrl($actionID, false), 'param'));
- $addActionID = false;
- }
- } else {
- $url = IMP_Session::getInitialUrl($actionID, false);
- if ($GLOBALS['isLogin']) {
- /* Don't show popup window in initial page. */
- $url = Horde_Util::addParameter($url, 'no_newmail_popup', 1, false);
- }
- }
-
- if ($addActionID && $actionID) {
- /* Preserve the actionID. */
- $url = Horde_Util::addParameter($url, 'actionID', $actionID, false);
- }
-
- return $url;
-}
-
-function _redirect($url)
-{
- Horde::redirect(_addAnchor($url, 'url'));
-}
-
-/* Add anchor to outgoing URL. */
-function _addAnchor($url, $type)
-{
- switch ($type) {
- case 'param':
- if (!empty($GLOBALS['url_anchor'])) {
- $url .= '#' . $GLOBALS['url_anchor'];
- }
- break;
-
- case 'url':
- $anchor = Horde_Util::getFormData('anchor_string');
- if (!empty($anchor)) {
- $url .= '#' . $anchor;
- } else {
- return _addAnchor($url, 'param');
- }
- break;
- }
-
- return $url;
-}
-
-@define('AUTH_HANDLER', true);
-$authentication = 'none';
-require_once dirname(__FILE__) . '/lib/base.php';
-
-$actionID = (Horde_Util::getFormData('action') == 'compose') ? 'login_compose' : Horde_Util::getFormData('actionID');
-$autologin = Horde_Util::getFormData('autologin');
-$imapuser = Horde_Util::getPost('imapuser');
-$pass = Horde_Util::getPost('pass');
-if (!empty($autologin)) {
- $imapuser = IMP_Session::canAutoLogin();
- $pass = Horde_Auth::getCredential('password');
-}
-$isLogin = empty($_SESSION['imp']['logintasks']);
-
-/* Get URL/Anchor strings now. */
-$url_anchor = null;
-$url_in = $url_form = Horde_Util::getFormData('url');
-if (($pos = strrpos($url_in, '#')) !== false) {
- $url_anchor = substr($url_in, $pos + 1);
- $url_in = substr($url_in, 0, $pos);
-}
-
-/* If we already have a session: */
-if (isset($_SESSION['imp']) && is_array($_SESSION['imp'])) {
- /* Make sure that if a username was specified, it is the current
- * username. */
- if ((!is_null($imapuser) && ($imapuser != $_SESSION['imp']['user'])) ||
- (!is_null($pass) && ($pass != $GLOBALS['imp_imap']->ob->getParam('password')))) {
- /* Disable the old session. */
- unset($_SESSION['imp']);
- _redirect(IMP::getLogoutUrl(Horde_Auth::REASON_FAILED, true));
- }
-
- $url = $url_in;
- if (empty($url_in)) {
- $url = IMP_Session::getInitialUrl($actionID, false);
- } elseif (!empty($actionID)) {
- $url = Horde_Util::addParameter($url_in, 'actionID', $actionID, false);
- }
-
- /* Don't show popup window in initial page. */
- if ($isLogin) {
- $url = Horde_Util::addParameter($url, 'no_newmail_popup', 1, false);
- }
-
- _redirect(_framesetUrl($url));
-}
-
-/* Create a new session if we're given the proper parameters. */
-if (!is_null($imapuser) && !is_null($pass)) {
- if (Horde_Auth::getProvider() == 'imp') {
- /* Destroy any existing session on login and make sure to use a new
- * session ID, to avoid session fixation issues. */
- $registry->getCleanSession();
- }
-
- if (IMP_Session::createSession($imapuser, $pass, Horde_Util::getFormData('server_key', IMP_Session::getAutoLoginServer()))) {
- $ie_version = Horde_Util::getFormData('ie_version');
- if ($ie_version) {
- $browser->setIEVersion($ie_version);
- }
-
- if (($horde_language = Horde_Util::getFormData('new_lang'))) {
- $_SESSION['horde_language'] = $horde_language;
- }
-
- $view = empty($conf['user']['select_view'])
- ? (empty($conf['user']['force_view']) ? 'imp' : $conf['user']['force_view'])
- : Horde_Util::getFormData('select_view', 'imp');
-
- setcookie('default_imp_view', $view, time() + 30 * 86400,
- $conf['cookie']['path'],
- $conf['cookie']['domain']);
- $_SESSION['imp']['view'] = $view;
-
- if (!empty($conf['hooks']['postlogin'])) {
- Horde::callHook('_imp_hook_postlogin', array($actionID, $isLogin), 'imp');
- }
-
- _redirect(_framesetUrl(_newSessionUrl($actionID)));
- }
-
- _redirect(IMP::getLogoutUrl(null, true));
-}
-
-/* No session, and no login attempt. Just go to the login page. */
-require IMP_BASE . '/login.php';
* @package IMP
*/
-$authentication = 'none';
-@define('AUTH_HANDLER', true);
-require_once dirname(__FILE__) . '/lib/base.php';
-
-$auth = Horde_Auth::singleton($conf['auth']['driver']);
-if ((!Horde_Auth::getAuth() || !IMP::checkAuthentication(true)) &&
- (!isset($_SERVER['PHP_AUTH_USER']) ||
- !$auth->authenticate($_SERVER['PHP_AUTH_USER'], array('password' => isset($_SERVER['PHP_AUTH_PW']) ? $_SERVER['PHP_AUTH_PW'] : null)))) {
+$imp_authentication = 'throw';
+try {
+ require_once dirname(__FILE__) . '/lib/base.php';
+} catch (Horde_Exception $e) {
+ //!$auth->authenticate($_SERVER['PHP_AUTH_USER'], array('password' => isset($_SERVER['PHP_AUTH_PW']) ? $_SERVER['PHP_AUTH_PW'] : null)))) {
header('WWW-Authenticate: Basic realm="IMP RSS Interface"');
header('HTTP/1.0 401 Unauthorized');
echo '401 Unauthorized';
+++ /dev/null
-REGEDIT4
-
-[HKEY_LOCAL_MACHINE\SOFTWARE\Clients\Mail]
-@="Imp"
-
-[HKEY_LOCAL_MACHINE\SOFTWARE\Clients\Mail\Imp]
-@="IMP"
-
-[HKEY_LOCAL_MACHINE\SOFTWARE\Clients\Mail\Imp\Protocols]
-
-[HKEY_LOCAL_MACHINE\SOFTWARE\Clients\Mail\Imp\Protocols\mailto]
-"EditFlags"=hex:02,00,00,00
-"URL Protocol"=""
-@="URL:MailTo Protocol"
-
-[HKEY_LOCAL_MACHINE\SOFTWARE\Clients\Mail\Imp\Protocols\mailto\shell]
-
-[HKEY_LOCAL_MACHINE\SOFTWARE\Clients\Mail\Imp\Protocols\mailto\shell\open]
-
-[HKEY_LOCAL_MACHINE\SOFTWARE\Clients\Mail\Imp\Protocols\mailto\shell\open\command]
-@="Rundll32.exe Url.dll,FileProtocolHandler webmail.example.com/horde/imp/?actionID=login_compose&to=%L"
-
-[HKEY_LOCAL_MACHINE\SOFTWARE\Clients\Mail\Imp\shell]
-
-[HKEY_LOCAL_MACHINE\SOFTWARE\Clients\Mail\Imp\shell\open]
-
-[HKEY_LOCAL_MACHINE\SOFTWARE\Clients\Mail\Imp\shell\open\command]
-@="Rundll32.exe Url.dll,FileProtocolHandler webmail.example.com/horde/imp"
+++ /dev/null
-<?php
-define('AUTH_HANDLER', true);
-$authentication = 'none';
-require_once '/lib/base.php';
-
-/* Set up the password encryption token. */
-Horde_Secret::setKey(Horde_Auth::getProvider() == 'imp' ? 'auth' : 'imp');
-
-/* Use the first server defined in servers.php. */
-// CUSTOMIZE THIS
-
-$server_key = 'localhost';
-$url = '/';
-// $url = '/' . $registry->get('initial_page','horde');
-
-?>
-
-<!-- CUSTOMIZE THIS -->
-<form action="<?php echo Horde::applicationUrl('redirect.php') ?>" method="post">
-User: <input name="imapuser" type="text" size="20" /><br />
-Pass: <input name="pass" type="password" size="20" /><br />
-<input type="hidden" name="url" value="<?php echo $url ?>" />
-<input type="submit" value="Log in" />
-</form>
* @package IMP
*/
-$authentication = 'horde';
+$imp_authentication = 'horde';
require_once dirname(__FILE__) . '/lib/base.php';
require_once 'Horde/Prefs/UI.php';
<?php
+$mimp_render = new Horde_Mobile();
$mimp_render->set('title', $title);
$c = &$mimp_render->add(new Horde_Mobile_card('m', $title));
$c->softkey('#o', _("Menu"));
$app_urls[$app] = Horde::url($GLOBALS['registry']->getInitialPage($app), true);
}
-require IMP_BASE . '/config/portal.php';
+include IMP_BASE . '/config/portal.php';
foreach ($dimp_block_list as $block) {
if ($block['ob'] instanceof Horde_Block) {
$app = $block['ob']->getApp();
'URI_MESSAGE' => Horde::applicationUrl('message-dimp.php'),
'URI_PREFS' => Horde::url($horde_webroot . '/services/prefs/', true, -1),
'URI_PREFS_IMP' => str_replace('&', '&', Horde_Util::addParameter(Horde::getServiceLink('options', 'imp'), array('nomenu' => 1))),
- 'URI_TIMEOUT' => Horde_Auth::addLogoutParameters($horde_webroot . '/login.php', Horde_Auth::REASON_SESSION),
+ 'URI_TIMEOUT' => Horde_Auth::getLogoutUrl(array('reason' => Horde_Auth::REASON_SESSION)),
'URI_VIEW' => Horde::applicationUrl('view.php', true, -1),
'SESSION_ID' => defined('SID') ? SID : '',
+++ /dev/null
-<form name="imp_login" id="imp_login" action="<tag:action />" method="post"<if:imp_auth> target="_parent"</if:imp_auth>>
-<tag:formInput />
-<input type="hidden" name="actionID" value="<tag:actionID />" />
-<input type="hidden" name="url" value="<tag:url />" />
-<input type="hidden" name="autologin" value="<tag:autologin />" />
-<input type="hidden" name="anchor_string" id="anchor_string" value="<tag:anchor_string />" />
-<if:ie_clientcaps>
-<input type="hidden" name="ie_version" id="ie_version" value="" />
-</if:ie_clientcaps>
-<if:server_key>
-<input type="hidden" name="server_key" value="<tag:server_key />" />
-</if:server_key>
-<loop:extra_hidden>
-<input type="hidden" name="<tag:extra_hidden.name />" value="<tag:extra_hidden.value />" />
-</loop:extra_hidden>
-
-<div id="menu">
-<if:menu>
- <span class="rightAlign"><tag:menu /></span>
-</if:menu>
- <h1 align="center"><tag:title /></h1>
-</div>
-
-<tag:notification_output />
-
-<table width="100%">
- <tr>
- <td align="center">
- <table align="center">
-<if:display_list>
- <tr>
- <td class="light rightAlign"><label for="server_key"><strong><gettext>Server</gettext></strong></label></td>
- <td class="light leftAlign">
- <select tabindex="<tag:hsl_skey_tabindex />" id="server_key" name="server_key">
-<loop:hsl>
- <option value="<tag:hsl.val />"<if:hsl.sel> selected="selected"</if:hsl.sel>><tag:hsl.name /></option>
-</loop:hsl>
- </select>
- <input id="btn_login" tabindex="<tag:hsl_tabindex />" type="button" class="button" value="<tag:login />" />
- </td>
- </tr>
-</if:display_list>
-
-<if:server_list>
- <tr>
- <td class="light rightAlign"><label for="server"><strong><gettext>Server</gettext></strong></label></td>
- <td class="light leftAlign">
- <select tabindex="<tag:slist_tabindex />" id="server_key" name="server_key">
-<loop:slist>
- <option value="<tag:slist.val />"<if:slist.sel> selected="selected"</if:slist.sel>><tag:slist.name /></option>
-</loop:slist>
- </select>
- </td>
- </tr>
-</if:server_list>
-
- <tr>
- <td class="light rightAlign"><label for="imapuser"><strong><gettext>Username</gettext></strong></label></td>
- <td class="light leftAlign" nowrap="nowrap">
- <input type="text" tabindex="<tag:username_tabindex />" id="imapuser" name="imapuser" value="<tag:username />" style="direction:ltr" /> <if:user_vinfo><strong>@<tag:user_vinfo /></strong></if:user_vinfo>
- </td>
- </tr>
-
- <tr>
- <td class="light rightAlign"><label for="pass"><strong><gettext>Password</gettext></strong></label></td>
- <td class="leftAlign">
- <input type="password" tabindex="<tag:password_tabindex />" id="pass" name="pass" style="direction:ltr" />
- </td>
- </tr>
-
-<if:choose_language>
- <tr>
- <td class="light rightAlign"><label for="new_lang"><strong><gettext>Language</gettext></strong></label></td>
- <td class="light leftAlign">
- <select tabindex="<tag:langs_tabindex />" id="new_lang" name="new_lang">
-<loop:langs>
- <option value="<tag:langs.val />" <if:langs.sel>selected="selected"</if:langs.sel>><tag:langs.name /></option>
-</loop:langs>
- </select>
- </td>
- </tr>
-</if:choose_language>
-
-<if:select_view>
- <tr>
- <td class="light rightAlign"><label for="select_view"><strong><gettext>Mode</gettext></strong></label></td>
- <td class="light leftAlign">
- <select tabindex="<tag:view_tabindex />" id="select_view" name="select_view">
-<loop:views>
- <option value="<tag:views.val />"<if:views.hide> style="display:none"<else:views.hide><if:views.sel> selected="selected"</if:views.sel></else:views.hide></if:views.hide>><tag:views.name /></option>
-</loop:views>
- </select>
- </td>
- </tr>
-</if:select_view>
-
- <tr>
- <td> </td>
- <td class="light leftAlign">
- <input type="submit" class="button" name="loginButton" id="loginButton" tabindex="<tag:login_tabindex />" value="<tag:login />" />
- </td>
- </tr>
-
-<if:signup_link>
- <tr>
- <td> </td>
- <td class="light">
- <tag:signup_link /><tag:signup_text></a>
- </td>
- </tr>
-</if:signup_link>
- </table>
- </td>
- </tr>
-</table>
-</form>
+++ /dev/null
-<?php
-
-$m = new Horde_Mobile(_("Log in"));
-
-$c = &$m->add(new Horde_Mobile_card());
-
-$imp_notify->setMobileObject($c);
-
-$c->add(new Horde_Mobile_text(sprintf(_("Welcome to %s"), ($imp_auth) ? $registry->get('name',' horde') : $registry->get('name'))));
-
-$f = &$c->add(new Horde_Mobile_form(Horde::applicationUrl('redirect.php', false, -1)));
-$f->add(new Horde_Mobile_input('imapuser', htmlspecialchars(Horde_Util::getFormData('imapuser')), _("Username: ")));
-
-// Add a password input, and set the type accordingly.
-$p = &$f->add(new Horde_Mobile_input('pass', '', _("Password: ")));
-$p->set('type', 'password');
-
-if (!empty($server_select)) {
- $f->add($server_select);
-}
-
-if (!empty($protocol_select)) {
- $f->add($protocol_select);
-}
-
-if (!empty($lang_select)) {
- $f->add($lang_select);
-}
-
-if (!empty($view_select)) {
- $f->add($view_select);
-}
-
-// Submit button.
-$f->add(new Horde_Mobile_submit(_("Log in")));
-
-if (!empty($actionID)) {
- $f->add(new Horde_Mobile_hidden('actionID', $actionID));
-}
-if (!empty($url_param)) {
- $f->add(new Horde_Mobile_hidden('url', $url_param));
-}
-
-// Add the form to the page.
-$m->add($f);
-
-// Display everything.
-$m->display();
$title .= ' [' . _("Read-Only") . ']';
}
+$mimp_render = new Horde_Mobile();
$c = &$mimp_render->add(new Horde_Mobile_card('m', $title));
$c->softkey('#o', _("Menu"));
/* Don't compress if we are already sending in compressed format. */
if ((isset($_GET['actionID']) && ($_GET['actionID'] == 'download_all')) ||
!empty($_GET['zip'])) {
- $no_compress = true;
+ $imp_no_compress = true;
}
-$session_control = 'readonly';
+$imp_session_control = 'readonly';
require_once dirname(__FILE__) . '/lib/base.php';
$actionID = Horde_Util::getFormData('actionID');
try {
$registry->pushApp('ingo', !defined('AUTH_HANDLER'));
} catch (Horde_Exception $e) {
- if ($e->getCode() == 'permission_denied') {
- Horde::authenticationFailureRedirect();
- }
- throw $e;
+ Horde_Auth::authenticationFailureRedirect('ingo', $e);
}
$conf = &$GLOBALS['conf'];
$notification = Horde_Notification::singleton();
$notification->attach('status');
-// Redirect the user to the Horde login page if they haven't authenticated.
-if (!Horde_Auth::isAuthenticated() && !defined('AUTH_HANDLER')) {
- Horde::authenticationFailureRedirect();
-}
-
// Start compression.
Horde::compressOutput();
try {
$registry->pushApp('jeta', !defined('AUTH_HANDLER'));
} catch (Horde_Exception $e) {
- if ($e->getCode() == 'permission_denied') {
- Horde::authenticationFailureRedirect();
- }
- throw $e;
+ Horde_Auth::authenticationFailureRedirect('jeta', $e);
}
$conf = &$GLOBALS['conf'];
try {
$registry->pushApp('kastalia', !defined('AUTH_HANDLER'));
} catch (Horde_Exception $e) {
- if ($e->getCode() == 'permission_denied') {
- Horde::authenticationFailureRedirect();
- }
- throw $e;
+ Horde_Auth::authenticationFailureRedirect('kastalia', $e);
}
//################### </MANUELLER ANMELDE CHECK (WENN base.php NICHT INCLUDIERT WIRD)> ###################
try {
$registry->pushApp('kastalia', !defined('AUTH_HANDLER'));
} catch (Horde_Exception $e) {
- if ($e->getCode() == 'permission_denied') {
- Horde::authenticationFailureRedirect();
- }
- throw $e;
+ Horde_Auth::authenticationFailureRedirect('kastalia', $e);
}
$conf = &$GLOBALS['conf'];
@define('KASTALIA_TEMPLATES', $registry->get('templates'));
// Notification system.
-$notification = &Horde_Notification::singleton();
+$notification = Horde_Notification::singleton();
$notification->attach('status');
// Define the base file path of Kastalia.
@define('KASTALIA_BASE', dirname(__FILE__) . '/..');
-// Kastalia base library
-require_once KASTALIA_BASE . '/lib/Kastalia.php';
-
// Start output compression.
Horde::compressOutput();
try {
$registry->pushApp('kronolith', !defined('AUTH_HANDLER'));
} catch (Horde_Exception $e) {
- if ($e->getCode() == 'permission_denied') {
- Horde::authenticationFailureRedirect();
- }
- throw $e;
+ Horde_Auth::authenticationFailureRedirect('kronolith', $e);
}
$conf = &$GLOBALS['conf'];
define('KRONOLITH_TEMPLATES', $registry->get('templates'));
// Is logged it?
if (!Horde_Auth::isAuthenticated()) {
$notification->push(_("Only authenticated users can post news."), 'horde.warning');
- Horde::authenticationFailureRedirect();
+ Horde_Auth::authenticationFailureRedirect('news');
}
// Default vars
/* Only admin should be using this. */
if (!Horde_Auth::isAdmin('news:admin')) {
$notification->push(_("You are not authorised for this action."), 'horde.warning');
- Horde::authenticationFailureRedirect();
+ Horde_Auth::authenticationFailureRedirect('news');
}
$vars = Horde_Variables::getDefaultVariables();
try {
$registry->pushApp('news', !defined('AUTH_HANDLER'));
} catch (Horde_Exception $e) {
- if ($e->getCode() == 'permission_denied') {
- Horde::authenticationFailureRedirect();
- }
- throw $e;
+ Horde_Auth::authenticationFailureRedirect('news', $e);
}
$conf = &$GLOBALS['conf'];
define('NEWS_TEMPLATES', $registry->get('templates'));
// Notification system.
-$notification = &Horde_Notification::singleton();
+$notification = Horde_Notification::singleton();
$notification->attach('status');
// Define the base file path of News.
}
// Cache
-$GLOBALS['cache'] = &Horde_Cache::singleton($GLOBALS['conf']['cache']['driver'],
- Horde::getDriverConfig('cache', $GLOBALS['conf']['cache']['driver']));
+$GLOBALS['cache'] = Horde_Cache::singleton($GLOBALS['conf']['cache']['driver'],
+ Horde::getDriverConfig('cache', $GLOBALS['conf']['cache']['driver']));
// Set up News drivers.
$GLOBALS['news'] = News_Driver::factory();
require_once dirname(__FILE__) . '/lib/base.php';
if (!Horde_Auth::isAuthenticated()) {
- Horde::authenticationFailureRedirect();
+ Horde_Auth::authenticationFailureRedirect('news');
}
$id = Horde_Util::getFormData('id', 0);
try {
$registry->pushApp('skoli', !defined('AUTH_HANDLER'));
} catch (Horde_Exception $e) {
- if ($e->getCode() == 'permission_denied') {
- Horde::authenticationFailureRedirect();
- }
- throw $e;
+ Horde_Auth::authenticationFailureRedirect('skoli', $e);
}
$conf = &$GLOBALS['conf'];
@define('SKOLI_TEMPLATES', $registry->get('templates'));
try {
$registry->pushApp('timeobjects', !defined('AUTH_HANDLER'));
} catch (Horde_Exception $e) {
- if ($e->getCode() == 'permission_denied') {
- Horde::authenticationFailureRedirect();
- }
- throw $e;
+ Horde_Auth::authenticationFailureRedirect('timeobjects', $e);
}
if (!defined('TIMEOBJECTS_BASE')) {
* need, and sets up objects that all scripts use.
*/
-
// Determine BASE directories.
require_once dirname(__FILE__) . '/base.load.php';
try {
$registry->pushApp('turba', !defined('AUTH_HANDLER'));
} catch (Horde_Exception $e) {
- if ($e->getCode() == 'permission_denied') {
- Horde::authenticationFailureRedirect();
- }
- throw $e;
+ Horde_Auth::authenticationFailureRedirect('turba', $e);
}
$conf = $GLOBALS['conf'];
define('TURBA_TEMPLATES', $registry->get('templates'));