| | |
| | | */ |
| | | public $action = ''; |
| | | public $comm_path = './'; |
| | | public $filename = ''; |
| | | |
| | | private $address_books = array(); |
| | | private $action_map = array(); |
| | |
| | | /** |
| | | * This implements the 'singleton' design pattern |
| | | * |
| | | * @param string Environment name to run (e.g. live, dev, test) |
| | | * @return rcmail The one and only instance |
| | | */ |
| | | static function get_instance() |
| | | static function get_instance($env = '') |
| | | { |
| | | if (!self::$instance || !is_a(self::$instance, 'rcmail')) { |
| | | self::$instance = new rcmail(); |
| | | self::$instance = new rcmail($env); |
| | | self::$instance->startup(); // init AFTER object was linked with self::$instance |
| | | } |
| | | |
| | |
| | | protected function startup() |
| | | { |
| | | $this->init(self::INIT_WITH_DB | self::INIT_WITH_PLUGINS); |
| | | |
| | | // set filename if not index.php |
| | | if (($basename = basename($_SERVER['SCRIPT_FILENAME'])) && $basename != 'index.php') |
| | | $this->filename = $basename; |
| | | |
| | | // start session |
| | | $this->session_init(); |
| | |
| | | setlocale(LC_ALL, $lang . '.utf8', $lang . '.UTF-8', 'en_US.utf8', 'en_US.UTF-8'); |
| | | |
| | | // workaround for http://bugs.php.net/bug.php?id=18556 |
| | | if (in_array($lang, array('tr_TR', 'ku', 'az_AZ'))) { |
| | | if (version_compare(PHP_VERSION, '5.5.0', '<') && in_array($lang, array('tr_TR', 'ku', 'az_AZ'))) { |
| | | setlocale(LC_CTYPE, 'en_US.utf8', 'en_US.UTF-8'); |
| | | } |
| | | } |
| | |
| | | } |
| | | |
| | | return $contacts; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * Return identifier of the address book object |
| | | * |
| | | * @param rcube_addressbook Addressbook source object |
| | | * |
| | | * @return string Source identifier |
| | | */ |
| | | public function get_address_book_id($object) |
| | | { |
| | | foreach ($this->address_books as $index => $book) { |
| | | if ($book === $object) { |
| | | return $index; |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | |
| | | $p['_task'] = $task; |
| | | unset($p['task']); |
| | | |
| | | $url = './'; |
| | | $url = './' . $this->filename; |
| | | $delm = '?'; |
| | | foreach (array_reverse($p) as $key => $val) { |
| | | if ($val !== '' && $val !== null) { |
| | |
| | | /** |
| | | * Write login data (name, ID, IP address) to the 'userlogins' log file. |
| | | */ |
| | | public function log_login() |
| | | public function log_login($user, $failed_login = false, $error_code = 0) |
| | | { |
| | | if (!$this->config->get('log_logins')) { |
| | | return; |
| | | } |
| | | |
| | | $user_name = $this->get_user_name(); |
| | | $user_id = $this->get_user_id(); |
| | | // failed login |
| | | if ($failed_login) { |
| | | $message = sprintf('Failed login for %s from %s in session %s (error: %d)', |
| | | $user, rcube_utils::remote_ip(), session_id(), $error_code); |
| | | } |
| | | // successful login |
| | | else { |
| | | $user_name = $this->get_user_name(); |
| | | $user_id = $this->get_user_id(); |
| | | |
| | | if (!$user_id) { |
| | | return; |
| | | if (!$user_id) { |
| | | return; |
| | | } |
| | | |
| | | $message = sprintf('Successful login for %s (ID: %d) from %s in session %s', |
| | | $user_name, $user_id, rcube_utils::remote_ip(), session_id()); |
| | | } |
| | | |
| | | self::write_log('userlogins', |
| | | sprintf('Successful login for %s (ID: %d) from %s in session %s', |
| | | $user_name, $user_id, rcube_utils::remote_ip(), session_id())); |
| | | // log login |
| | | self::write_log('userlogins', $message); |
| | | } |
| | | |
| | | |
| | |
| | | public function upload_init() |
| | | { |
| | | // Enable upload progress bar |
| | | if (($seconds = $this->config->get('upload_progress')) && ini_get('apc.rfc1867')) { |
| | | $rfc1867 = filter_var(ini_get('apc.rfc1867'), FILTER_VALIDATE_BOOLEAN); |
| | | if ($rfc1867 && ($seconds = $this->config->get('upload_progress'))) { |
| | | if ($field_name = ini_get('apc.rfc1867_name')) { |
| | | $this->output->set_env('upload_progress_name', $field_name); |
| | | $this->output->set_env('upload_progress_time', (int) $seconds); |