| | |
| | | | | |
| | | +-------------------------------------------------------------------------+ |
| | | | Author: Thomas Bruederli <roundcube@gmail.com> | |
| | | | Author: Aleksander Machniak <alec@alec.pl> | |
| | | +-------------------------------------------------------------------------+ |
| | | */ |
| | | |
| | |
| | | // check if https is required (for login) and redirect if necessary |
| | | if (empty($_SESSION['user_id']) && ($force_https = $RCMAIL->config->get('force_https', false))) { |
| | | $https_port = is_bool($force_https) ? 443 : $force_https; |
| | | |
| | | if (!rcube_utils::https_check($https_port)) { |
| | | $host = preg_replace('/:[0-9]+$/', '', $_SERVER['HTTP_HOST']); |
| | | $host .= ($https_port != 443 ? ':' . $https_port : ''); |
| | | |
| | | header('Location: https://' . $host . $_SERVER['REQUEST_URI']); |
| | | exit; |
| | | } |
| | |
| | | )); |
| | | |
| | | // Login |
| | | if ($auth['valid'] && !$auth['abort'] && |
| | | $RCMAIL->login($auth['user'], $auth['pass'], $auth['host'], $auth['cookiecheck']) |
| | | if ($auth['valid'] && !$auth['abort'] |
| | | && $RCMAIL->login($auth['user'], $auth['pass'], $auth['host'], $auth['cookiecheck']) |
| | | ) { |
| | | // create new session ID, don't destroy the current session |
| | | // it was destroyed already by $RCMAIL->kill_session() above |
| | |
| | | parse_str($url, $query); |
| | | |
| | | // prevent endless looping on login page |
| | | if ($query['_task'] == 'login') |
| | | if ($query['_task'] == 'login') { |
| | | unset($query['_task']); |
| | | } |
| | | |
| | | // prevent redirect to compose with specified ID (#1488226) |
| | | if ($query['_action'] == 'compose' && !empty($query['_id'])) |
| | | if ($query['_action'] == 'compose' && !empty($query['_id'])) { |
| | | $query = array(); |
| | | } |
| | | } |
| | | |
| | | // allow plugins to control the redirect url after login success |
| | |
| | | |
| | | $error_message = $error_labels[$error_code] ? $error_labels[$error_code] : 'loginfailed'; |
| | | |
| | | $OUTPUT->show_message($error_message, 'warning'); |
| | | |
| | | // log failed login |
| | | $RCMAIL->log_login($auth['user'], true, $error_code); |
| | | |
| | | $OUTPUT->show_message($error_message, 'warning'); |
| | | $RCMAIL->plugins->exec_hook('login_failed', array( |
| | | 'code' => $error_code, 'host' => $auth['host'], 'user' => $auth['user'])); |
| | | |
| | | $RCMAIL->kill_session(); |
| | | } |
| | | } |
| | | |
| | | // end session (after optional referer check) |
| | | else if ($RCMAIL->task == 'logout' && isset($_SESSION['user_id']) && (!$RCMAIL->config->get('referer_check') || rcube_utils::check_referer())) { |
| | | else if ($RCMAIL->task == 'logout' && isset($_SESSION['user_id']) |
| | | && (!$RCMAIL->config->get('referer_check') || rcube_utils::check_referer()) |
| | | ) { |
| | | $userdata = array( |
| | | 'user' => $_SESSION['username'], |
| | | 'host' => $_SESSION['storage_host'], |
| | | 'lang' => $RCMAIL->user->language, |
| | | ); |
| | | |
| | | $OUTPUT->show_message('loggedout'); |
| | | |
| | | $RCMAIL->logout_actions(); |
| | | $RCMAIL->kill_session(); |
| | | $RCMAIL->plugins->exec_hook('logout_after', $userdata); |
| | |
| | | if (empty($RCMAIL->user->ID)) { |
| | | // log session failures |
| | | $task = rcube_utils::get_input_value('_task', rcube_utils::INPUT_GPC); |
| | | if ($task && !in_array($task, array('login','logout')) && !$session_error && ($sess_id = $_COOKIE[ini_get('session.name')])) { |
| | | $RCMAIL->session->log("Aborted session " . $sess_id . "; no valid session data found"); |
| | | |
| | | if ($task && !in_array($task, array('login','logout')) |
| | | && !$session_error && ($sess_id = $_COOKIE[ini_get('session.name')]) |
| | | ) { |
| | | $RCMAIL->session->log("Aborted session $sess_id; no valid session data found"); |
| | | $session_error = true; |
| | | } |
| | | |
| | |
| | | html::p(null, "Please <b>remove</b> the whole <tt>installer</tt> folder from the Roundcube directory because . |
| | | these files may expose sensitive configuration data like server passwords and encryption keys |
| | | to the public. Make sure you cannot access the <a href=\"./installer/\">installer script</a> from your browser.") |
| | | ) |
| | | ); |
| | | )); |
| | | } |
| | | |
| | | if ($session_error || $_REQUEST['_err'] == 'session') { |
| | |
| | | $plugin = $RCMAIL->plugins->exec_hook('unauthenticated', array('task' => 'login', 'error' => $session_error)); |
| | | |
| | | $RCMAIL->set_task($plugin['task']); |
| | | |
| | | $OUTPUT->send($plugin['task']); |
| | | } |
| | | // CSRF prevention |
| | |
| | | |
| | | |
| | | // include task specific functions |
| | | if (is_file($incfile = INSTALL_PATH . 'program/steps/'.$RCMAIL->task.'/func.inc')) |
| | | if (is_file($incfile = INSTALL_PATH . 'program/steps/'.$RCMAIL->task.'/func.inc')) { |
| | | include_once $incfile; |
| | | } |
| | | |
| | | // allow 5 "redirects" to another action |
| | | $redirects = 0; $incstep = null; |
| | |
| | | // parse main template (default) |
| | | $OUTPUT->send($RCMAIL->task); |
| | | |
| | | |
| | | // if we arrive here, something went wrong |
| | | rcmail::raise_error(array( |
| | | 'code' => 404, |
| | |
| | | 'line' => __LINE__, |
| | | 'file' => __FILE__, |
| | | 'message' => "Invalid request"), true, true); |
| | | |