| | |
| | | |
| | | // set class options |
| | | $options = array( |
| | | 'auth_type' => $this->config->get("{$driver}_auth_type", 'check'), |
| | | 'auth_cid' => $this->config->get("{$driver}_auth_cid"), |
| | | 'auth_pw' => $this->config->get("{$driver}_auth_pw"), |
| | | 'debug' => (bool) $this->config->get("{$driver}_debug"), |
| | | 'force_caps' => (bool) $this->config->get("{$driver}_force_caps"), |
| | | 'disabled_caps' => $this->config->get("{$driver}_disabled_caps"), |
| | | 'timeout' => (int) $this->config->get("{$driver}_timeout"), |
| | | 'skip_deleted' => (bool) $this->config->get('skip_deleted'), |
| | | 'driver' => $driver, |
| | | 'auth_type' => $this->config->get("{$driver}_auth_type", 'check'), |
| | | 'auth_cid' => $this->config->get("{$driver}_auth_cid"), |
| | | 'auth_pw' => $this->config->get("{$driver}_auth_pw"), |
| | | 'debug' => (bool) $this->config->get("{$driver}_debug"), |
| | | 'force_caps' => (bool) $this->config->get("{$driver}_force_caps"), |
| | | 'disabled_caps' => $this->config->get("{$driver}_disabled_caps"), |
| | | 'socket_options' => $this->config->get("{$driver}_conn_options"), |
| | | 'timeout' => (int) $this->config->get("{$driver}_timeout"), |
| | | 'skip_deleted' => (bool) $this->config->get('skip_deleted'), |
| | | 'driver' => $driver, |
| | | ); |
| | | |
| | | if (!empty($_SESSION['storage_host'])) { |
| | |
| | | /** |
| | | * Load a localization package |
| | | * |
| | | * @param string Language ID |
| | | * @param array Additional text labels/messages |
| | | * @param string $lang Language ID |
| | | * @param array $add Additional text labels/messages |
| | | * @param array $merge Additional text labels/messages to merge |
| | | */ |
| | | public function load_language($lang = null, $add = array()) |
| | | public function load_language($lang = null, $add = array(), $merge = array()) |
| | | { |
| | | $lang = $this->language_prop(($lang ? $lang : $_SESSION['language'])); |
| | | |
| | |
| | | // append additional texts (from plugin) |
| | | if (is_array($add) && !empty($add)) { |
| | | $this->texts += $add; |
| | | } |
| | | |
| | | // merge additional texts (from plugin) |
| | | if (is_array($merge) && !empty($merge)) { |
| | | $this->texts = array_merge($this->texts, $merge); |
| | | } |
| | | } |
| | | |
| | |
| | | // log_driver == 'file' is assumed here |
| | | |
| | | $line = sprintf("[%s]: %s\n", $date, $line); |
| | | $log_dir = self::$instance ? self::$instance->config->get('log_dir') : null; |
| | | $log_dir = null; |
| | | |
| | | // per-user logging is activated |
| | | if (self::$instance && self::$instance->config->get('per_user_logging', false) && self::$instance->get_user_id()) { |
| | | $log_dir = self::$instance->get_user_log_dir(); |
| | | if (empty($log_dir)) |
| | | return false; |
| | | } |
| | | else if (!empty($log['dir'])) { |
| | | $log_dir = $log['dir']; |
| | | } |
| | | else if (self::$instance) { |
| | | $log_dir = self::$instance->config->get('log_dir'); |
| | | } |
| | | |
| | | if (empty($log_dir)) { |
| | | $log_dir = RCUBE_INSTALL_PATH . 'logs'; |
| | |
| | | // handle PHP exceptions |
| | | if (is_object($arg) && is_a($arg, 'Exception')) { |
| | | $arg = array( |
| | | 'type' => 'php', |
| | | 'code' => $arg->getCode(), |
| | | 'line' => $arg->getLine(), |
| | | 'file' => $arg->getFile(), |
| | |
| | | ); |
| | | } |
| | | else if (is_string($arg)) { |
| | | $arg = array('message' => $arg, 'type' => 'php'); |
| | | $arg = array('message' => $arg); |
| | | } |
| | | |
| | | if (empty($arg['code'])) { |
| | |
| | | |
| | | $cli = php_sapi_name() == 'cli'; |
| | | |
| | | if (($log || $terminate) && !$cli && $arg['type'] && $arg['message']) { |
| | | if (($log || $terminate) && !$cli && $arg['message']) { |
| | | $arg['fatal'] = $terminate; |
| | | self::log_bug($arg); |
| | | } |
| | |
| | | */ |
| | | public static function log_bug($arg_arr) |
| | | { |
| | | $program = strtoupper($arg_arr['type']); |
| | | $program = strtoupper(!empty($arg_arr['type']) ? $arg_arr['type'] : 'php'); |
| | | $level = self::get_instance()->config->get('debug_level'); |
| | | |
| | | // disable errors for ajax requests, write to log instead (#1487831) |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * Get the per-user log directory |
| | | */ |
| | | protected function get_user_log_dir() |
| | | { |
| | | $log_dir = $this->config->get('log_dir', RCUBE_INSTALL_PATH . 'logs'); |
| | | $user_name = $this->get_user_name(); |
| | | $user_log_dir = $log_dir . '/' . $user_name; |
| | | |
| | | return !empty($user_name) && is_writable($user_log_dir) ? $user_log_dir : false; |
| | | } |
| | | |
| | | /** |
| | | * Getter for logged user language code. |
| | |
| | | )); |
| | | |
| | | if ($plugin['abort']) { |
| | | if (!empty($plugin['error'])) { |
| | | $error = $plugin['error']; |
| | | } |
| | | if (!empty($plugin['body_file'])) { |
| | | $body_file = $plugin['body_file']; |
| | | } |
| | | |
| | | return isset($plugin['result']) ? $plugin['result'] : false; |
| | | } |
| | | |
| | |
| | | // send thru SMTP server using custom SMTP library |
| | | if ($this->config->get('smtp_server')) { |
| | | // generate list of recipients |
| | | $a_recipients = array($mailto); |
| | | $a_recipients = (array) $mailto; |
| | | |
| | | if (strlen($headers['Cc'])) |
| | | $a_recipients[] = $headers['Cc']; |
| | |
| | | // remove MDN headers after sending |
| | | unset($headers['Return-Receipt-To'], $headers['Disposition-Notification-To']); |
| | | |
| | | // get all recipients |
| | | if ($headers['Cc']) |
| | | $mailto .= $headers['Cc']; |
| | | if ($headers['Bcc']) |
| | | $mailto .= $headers['Bcc']; |
| | | if (preg_match_all('/<([^@]+@[^>]+)>/', $mailto, $m)) |
| | | $mailto = implode(', ', array_unique($m[1])); |
| | | |
| | | if ($this->config->get('smtp_log')) { |
| | | // get all recipient addresses |
| | | if (is_array($mailto)) { |
| | | $mailto = implode(',', $mailto); |
| | | } |
| | | if ($headers['Cc']) { |
| | | $mailto .= ',' . $headers['Cc']; |
| | | } |
| | | if ($headers['Bcc']) { |
| | | $mailto .= ',' . $headers['Bcc']; |
| | | } |
| | | |
| | | $mailto = rcube_mime::decode_address_list($mailto, null, false, null, true); |
| | | |
| | | self::write_log('sendmail', sprintf("User %s [%s]; Message for %s; %s", |
| | | $this->user->get_username(), |
| | | $_SERVER['REMOTE_ADDR'], |
| | | $mailto, |
| | | rcube_utils::remote_addr(), |
| | | implode(', ', $mailto), |
| | | !empty($response) ? join('; ', $response) : '')); |
| | | } |
| | | } |