| | |
| | | |
| | | /* |
| | | +-----------------------------------------------------------------------+ |
| | | | program/include/rcube.php | |
| | | | | |
| | | | This file is part of the Roundcube Webmail client | |
| | | | Copyright (C) 2008-2012, The Roundcube Dev Team | |
| | | | Copyright (C) 2011-2012, Kolab Systems AG | |
| | |
| | | $sess_domain = $this->config->get('session_domain'); |
| | | $sess_path = $this->config->get('session_path'); |
| | | $lifetime = $this->config->get('session_lifetime', 0) * 60; |
| | | $is_secure = $this->config->get('use_https') || rcube_utils::https_check(); |
| | | |
| | | // set session domain |
| | | if ($sess_domain) { |
| | |
| | | ini_set('session.gc_maxlifetime', $lifetime * 2); |
| | | } |
| | | |
| | | ini_set('session.cookie_secure', rcube_utils::https_check()); |
| | | ini_set('session.cookie_secure', $is_secure); |
| | | ini_set('session.name', $sess_name ? $sess_name : 'roundcube_sessid'); |
| | | ini_set('session.use_cookies', 1); |
| | | ini_set('session.use_only_cookies', 1); |
| | |
| | | |
| | | $this->session->set_secret($this->config->get('des_key') . dirname($_SERVER['SCRIPT_NAME'])); |
| | | $this->session->set_ip_check($this->config->get('ip_check')); |
| | | |
| | | if ($this->config->get('session_auth_name')) { |
| | | $this->session->set_cookiename($this->config->get('session_auth_name')); |
| | | } |
| | | |
| | | // start PHP session (if not in CLI mode) |
| | | if ($_SERVER['REMOTE_ADDR']) { |
| | |
| | | * - code: Error code (required) |
| | | * - type: Error type [php|db|imap|javascript] (required) |
| | | * - message: Error message |
| | | * - file: File where error occured |
| | | * - line: Line where error occured |
| | | * - file: File where error occurred |
| | | * - line: Line where error occurred |
| | | * @param boolean True to log the error |
| | | * @param boolean Terminate script execution |
| | | */ |
| | |
| | | { |
| | | // handle PHP exceptions |
| | | if (is_object($arg) && is_a($arg, 'Exception')) { |
| | | $err = array( |
| | | $arg = array( |
| | | 'type' => 'php', |
| | | 'code' => $arg->getCode(), |
| | | 'line' => $arg->getLine(), |
| | | 'file' => $arg->getFile(), |
| | | 'message' => $arg->getMessage(), |
| | | ); |
| | | $arg = $err; |
| | | } |
| | | else if (is_string($arg)) { |
| | | $arg = array('message' => $arg, 'type' => 'php'); |
| | | } |
| | | |
| | | if (empty($arg['code'])) { |
| | | $arg['code'] = 500; |
| | | } |
| | | |
| | | // installer |
| | |
| | | return; |
| | | } |
| | | |
| | | if (($log || $terminate) && $arg['type'] && $arg['message']) { |
| | | $cli = php_sapi_name() == 'cli'; |
| | | |
| | | if (($log || $terminate) && !$cli && $arg['type'] && $arg['message']) { |
| | | $arg['fatal'] = $terminate; |
| | | self::log_bug($arg); |
| | | } |
| | | |
| | | // display error page and terminate script |
| | | if ($terminate && is_object(self::$instance->output)) { |
| | | self::$instance->output->raise_error($arg['code'], $arg['message']); |
| | | // terminate script |
| | | if ($terminate) { |
| | | // display error page |
| | | if (is_object(self::$instance->output)) { |
| | | self::$instance->output->raise_error($arg['code'], $arg['message']); |
| | | } |
| | | else if ($cli) { |
| | | fwrite(STDERR, 'ERROR: ' . $arg['message']); |
| | | } |
| | | |
| | | exit(1); |
| | | } |
| | | } |
| | | |
| | |
| | | |
| | | if (!self::write_log('errors', $log_entry)) { |
| | | // send error to PHPs error handler if write_log didn't succeed |
| | | trigger_error($arg_arr['message']); |
| | | trigger_error($arg_arr['message'], E_USER_WARNING); |
| | | } |
| | | } |
| | | |
| | |
| | | return $this->decrypt($_SESSION['password']); |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * Getter for logged user language code. |
| | | * |
| | | * @return string User language code |
| | | */ |
| | | public function get_user_language() |
| | | { |
| | | if (is_object($this->user)) { |
| | | return $this->user->language; |
| | | } |
| | | else if (isset($_SESSION['language'])) { |
| | | return $_SESSION['language']; |
| | | } |
| | | } |
| | | |
| | | } |
| | | |
| | | |