[ Index ] |
|
Code source de IMP H3 (4.1.5) |
1 <?php 2 /** 3 * Login screen for IMP. 4 * 5 * $Horde: imp/login.php,v 2.222.2.10 2007/01/02 13:54:54 jan Exp $ 6 * 7 * Copyright 1999-2007 Charles J. Hagenbuch <chuck@horde.org> 8 * Copyright 1999-2007 Jon Parise <jon@horde.org> 9 * 10 * See the enclosed file COPYING for license information (GPL). If you 11 * did not receive this file, see http://www.fsf.org/copyleft/gpl.html. 12 */ 13 14 @define('AUTH_HANDLER', true); 15 @define('IMP_BASE', dirname(__FILE__)); 16 $authentication = 'none'; 17 require_once IMP_BASE . '/lib/base.php'; 18 require IMP_BASE . '/config/servers.php'; 19 20 /* Get an Auth object. */ 21 $imp_auth = (Auth::getProvider() == 'imp'); 22 $auth = &Auth::singleton($conf['auth']['driver']); 23 $logout_reason = $auth->getLogoutReason(); 24 25 $autologin = Util::getFormData('autologin', false); 26 $actionID = (Util::getFormData('action') == 'compose') ? 'login_compose' : Util::getFormData('actionID'); 27 $server_key = Util::getFormData('server_key'); 28 $url_param = Util::getFormData('url'); 29 30 /* Handle cases where we already have a session. */ 31 if (!empty($_SESSION['imp']) && is_array($_SESSION['imp'])) { 32 if ($logout_reason) { 33 /* Log logout requests now. */ 34 if ($logout_reason == AUTH_REASON_LOGOUT) { 35 $entry = sprintf('Logout for %s [%s] from {%s:%s}', 36 $_SESSION['imp']['uniquser'], 37 $_SERVER['REMOTE_ADDR'], $_SESSION['imp']['server'], 38 $_SESSION['imp']['port']); 39 } else { 40 $entry = $_SERVER['REMOTE_ADDR'] . ' ' . $auth->getLogoutReasonString(); 41 } 42 Horde::logMessage($entry, __FILE__, __LINE__, PEAR_LOG_NOTICE); 43 44 $language = (isset($prefs)) ? $prefs->getValue('language') : NLS::select(); 45 46 unset($_SESSION['imp']); 47 48 /* Cleanup preferences. */ 49 if (isset($prefs)) { 50 $prefs->cleanup($imp_auth); 51 } 52 53 if ($imp_auth) { 54 Auth::clearAuth(); 55 @session_destroy(); 56 Horde::setupSessionHandler(); 57 @session_start(); 58 } 59 60 NLS::setLang($language); 61 62 /* Hook to preselect the correct language in the widget. */ 63 $_GET['new_lang'] = $language; 64 65 $registry->loadPrefs('horde'); 66 $registry->loadPrefs(); 67 } else { 68 require_once IMP_BASE . '/lib/Session.php'; 69 header('Location: ' . IMP_Session::getInitialUrl($actionID, false)); 70 exit; 71 } 72 } 73 74 /* Log session timeouts. */ 75 if ($logout_reason == AUTH_REASON_SESSION) { 76 $entry = sprintf('Session timeout for client [%s]', $_SERVER['REMOTE_ADDR']); 77 Horde::logMessage($entry, __FILE__, __LINE__, PEAR_LOG_NOTICE); 78 79 /* Make sure everything is really cleared. */ 80 Auth::clearAuth(); 81 unset($_SESSION['imp']); 82 } 83 84 /* Redirect the user on logout if redirection is enabled. */ 85 if ($logout_reason == AUTH_REASON_LOGOUT && 86 ($conf['user']['redirect_on_logout'] || 87 !empty($conf['auth']['redirect_on_logout']))) { 88 if (!empty($conf['auth']['redirect_on_logout'])) { 89 $url = Auth::addLogoutParameters($conf['auth']['redirect_on_logout'], AUTH_REASON_LOGOUT); 90 } else { 91 $url = Auth::addLogoutParameters($conf['user']['redirect_on_logout'], AUTH_REASON_LOGOUT); 92 } 93 if (!isset($_COOKIE[session_name()])) { 94 $url = Util::addParameter($url, session_name(), session_id()); 95 } 96 header('Location: ' . $url); 97 exit; 98 } 99 100 /* Redirect the user if an alternate login page has been specified. */ 101 if (!empty($conf['auth']['alternate_login'])) { 102 $url = Auth::addLogoutParameters($conf['auth']['alternate_login']); 103 if (!isset($_COOKIE[session_name()])) { 104 $url = Util::addParameter($url, session_name(), session_id(), false); 105 } 106 if ($url_param) { 107 $url = Util::addParameter($url, 'url', $url_param, false); 108 } 109 header('Location: ' . $url); 110 exit; 111 } elseif ($conf['user']['alternate_login']) { 112 $url = Auth::addLogoutParameters($conf['user']['alternate_login']); 113 if (!isset($_COOKIE[session_name()])) { 114 $url = Util::addParameter($url, session_name(), session_id(), false); 115 } 116 header('Location: ' . $url); 117 exit; 118 } 119 120 /* Initialize the password key(s). If we are doing Horde auth as well, 121 * make sure that the Horde auth key gets set. */ 122 Secret::setKey('imp'); 123 if ($imp_auth) { 124 Secret::setKey('auth'); 125 } 126 127 $used_servers = $servers; 128 if ($conf['server']['server_list'] != 'shown') { 129 $server_key = Util::getFormData('server_key'); 130 if (is_null($server_key)) { 131 /* Grab some default values from the first entry in 132 * config/servers.php. */ 133 $server_key = IMP::getAutoLoginServer(true); 134 } 135 $used_servers = array($server_key => $servers[$server_key]); 136 $autologin = Util::getFormData('autologin'); 137 } 138 139 if (!$logout_reason && IMP::canAutoLogin($server_key, $autologin)) { 140 $url = Horde::applicationUrl('redirect.php', true); 141 $params = array('actionID' => 'login', 'autologin' => true); 142 if (count($used_servers) == 1) { 143 reset($used_servers); 144 list($server_key, $curServer) = each($used_servers); 145 $params['server_key'] = $server_key; 146 } 147 $url = Util::addParameter($url, $params, null, false); 148 header('Location: ' . $url); 149 exit; 150 } 151 152 $title = sprintf(_("Welcome to %s"), $registry->get('name', ($imp_auth) ? 'horde' : null)); 153 154 if ($logout_reason && $imp_auth && $conf['menu']['always']) { 155 $notification->push('setFocus();if (window.parent.frames.horde_menu) window.parent.frames.horde_menu.location.reload();', 'javascript'); 156 } else { 157 $notification->push('setFocus()', 'javascript'); 158 } 159 160 $formAction = Horde::url('redirect.php', false, -1, true); 161 $formData = null; 162 163 $reason = $auth->getLogoutReasonString(); 164 165 /* Add some javascript. */ 166 Horde::addScriptFile('enter_key_trap.js', 'horde', true); 167 168 /* Do we need to do IE version detection? */ 169 if (!Auth::getAuth() && 170 ($browser->getBrowser() == 'msie') && 171 ($browser->getMajor() >= 5)) { 172 $ie_clientcaps = true; 173 } 174 175 require_once 'Horde/Menu.php'; 176 require IMP_TEMPLATES . '/common-header.inc'; 177 require IMP_TEMPLATES . '/login/login.inc'; 178 if (@is_readable(IMP_BASE . '/config/motd.php')) { 179 require IMP_BASE . '/config/motd.php'; 180 } 181 require $registry->get('templates', 'horde') . '/common-footer.inc';
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Thu Nov 29 12:30:07 2007 | par Balluche grâce à PHPXref 0.7 |
![]() |