| | |
| | | /* |
| | | +-------------------------------------------------------------------------+ |
| | | | Roundcube Webmail IMAP Client | |
| | | | Version 0.9-git | |
| | | | Version 0.9.1 | |
| | | | | |
| | | | Copyright (C) 2005-2012, The Roundcube Dev Team | |
| | | | Copyright (C) 2005-2013, The Roundcube Dev Team | |
| | | | | |
| | | | This program is free software: you can redistribute it and/or modify | |
| | | | it under the terms of the GNU General Public License (with exceptions | |
| | |
| | | } |
| | | |
| | | // end session (after optional referer check) |
| | | else if ($RCMAIL->task == 'logout' && isset($_SESSION['user_id']) && (!$RCMAIL->config->get('referer_check') || rcmail::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'], |
| | |
| | | // CSRF prevention |
| | | else { |
| | | // don't check for valid request tokens in these actions |
| | | $request_check_whitelist = array('login'=>1, 'spell'=>1); |
| | | $request_check_whitelist = array('login'=>1, 'spell'=>1, 'spell_html'=>1); |
| | | |
| | | // check client X-header to verify request origin |
| | | if ($OUTPUT->ajax_call) { |
| | | if (rcube_utils::request_header('X-Roundcube-Request') != $RCMAIL->get_request_token()) { |
| | | header('HTTP/1.1 403 Forbidden'); |
| | | die("Invalid Request"); |
| | | if (!$request_check_whitelist[$RCMAIL->action]) { |
| | | // check client X-header to verify request origin |
| | | if ($OUTPUT->ajax_call) { |
| | | if (rcube_utils::request_header('X-Roundcube-Request') != $RCMAIL->get_request_token()) { |
| | | header('HTTP/1.1 403 Forbidden'); |
| | | die("Invalid Request"); |
| | | } |
| | | } |
| | | } |
| | | // check request token in POST form submissions |
| | | else if (!empty($_POST) && !$request_check_whitelist[$RCMAIL->action] && !$RCMAIL->check_request()) { |
| | | $OUTPUT->show_message('invalidrequest', 'error'); |
| | | $OUTPUT->send($RCMAIL->task); |
| | | } |
| | | // check request token in POST form submissions |
| | | else if (!empty($_POST) && !$RCMAIL->check_request()) { |
| | | $OUTPUT->show_message('invalidrequest', 'error'); |
| | | $OUTPUT->send($RCMAIL->task); |
| | | } |
| | | |
| | | // check referer if configured |
| | | if (!$request_check_whitelist[$RCMAIL->action] && $RCMAIL->config->get('referer_check') && !rcmail::check_referer()) { |
| | | raise_error(array( |
| | | 'code' => 403, |
| | | 'type' => 'php', |
| | | 'message' => "Referer check failed"), true, true); |
| | | // check referer if configured |
| | | if ($RCMAIL->config->get('referer_check') && !rcube_utils::check_referer()) { |
| | | raise_error(array( |
| | | 'code' => 403, 'type' => 'php', |
| | | 'message' => "Referer check failed"), true, true); |
| | | } |
| | | } |
| | | } |
| | | |
| | |
| | | $plugin = $RCMAIL->plugins->exec_hook('ready', array('task' => $RCMAIL->task, 'action' => $RCMAIL->action)); |
| | | $RCMAIL->set_task($plugin['task']); |
| | | $RCMAIL->action = $plugin['action']; |
| | | |
| | | |
| | | // handle special actions |
| | | if ($RCMAIL->action == 'keep-alive') { |
| | |
| | | else if (($stepfile = $RCMAIL->get_action_file()) |
| | | && is_file($incfile = INSTALL_PATH . 'program/steps/'.$RCMAIL->task.'/'.$stepfile) |
| | | ) { |
| | | include $incfile; |
| | | // include action file only once (in case it don't exit) |
| | | include_once $incfile; |
| | | $redirects++; |
| | | } |
| | | else { |
| | |
| | | } |
| | | } |
| | | |
| | | if ($RCMAIL->action == 'refresh') { |
| | | $RCMAIL->plugins->exec_hook('refresh', array()); |
| | | } |
| | | |
| | | // parse main template (default) |
| | | $OUTPUT->send($RCMAIL->task); |