| | |
| | | * This implements the 'singleton' design pattern |
| | | * |
| | | * @param integer Options to initialize with this instance. See rcube::INIT_WITH_* constants |
| | | * @param string Environment name to run (e.g. live, dev, test) |
| | | * |
| | | * @return rcube The one and only instance |
| | | */ |
| | | static function get_instance($mode = 0) |
| | | static function get_instance($mode = 0, $env = '') |
| | | { |
| | | if (!self::$instance) { |
| | | self::$instance = new rcube(); |
| | | self::$instance = new rcube($env); |
| | | self::$instance->init($mode); |
| | | } |
| | | |
| | |
| | | /** |
| | | * Private constructor |
| | | */ |
| | | protected function __construct() |
| | | protected function __construct($env = '') |
| | | { |
| | | // load configuration |
| | | $this->config = new rcube_config; |
| | | $this->config = new rcube_config($env); |
| | | $this->plugins = new rcube_dummy_plugin_api; |
| | | |
| | | register_shutdown_function(array($this, 'shutdown')); |
| | |
| | | '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, |
| | |
| | | $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']) { |
| | | $this->session->start(); |
| | |
| | | |
| | | if ($tmp && ($dir = opendir($tmp))) { |
| | | while (($fname = readdir($dir)) !== false) { |
| | | if ($fname{0} == '.') { |
| | | if ($fname[0] == '.') { |
| | | continue; |
| | | } |
| | | |
| | | if (filemtime($tmp.'/'.$fname) < $expire) { |
| | | if (@filemtime($tmp.'/'.$fname) < $expire) { |
| | | @unlink($tmp.'/'.$fname); |
| | | } |
| | | } |
| | |
| | | $subject = str_replace("\r\n", $delim, $subject); |
| | | } |
| | | |
| | | if (ini_get('safe_mode')) |
| | | if (filter_var(ini_get('safe_mode'), FILTER_VALIDATE_BOOLEAN)) |
| | | $sent = mail($to, $subject, $msg_body, $header_str); |
| | | else |
| | | $sent = mail($to, $subject, $msg_body, $header_str, "-f$from"); |