Changeset 3633 in subversion for trunk/roundcubemail/program/include/rcmail.php
- Timestamp:
- May 19, 2010 2:58:42 AM (3 years ago)
- File:
-
- 1 edited
-
trunk/roundcubemail/program/include/rcmail.php (modified) (41 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/roundcubemail/program/include/rcmail.php
r3627 r3633 62 62 return self::$instance; 63 63 } 64 65 64 65 66 66 /** 67 67 * Private constructor … … 71 71 // load configuration 72 72 $this->config = new rcube_config(); 73 73 74 74 register_shutdown_function(array($this, 'shutdown')); 75 75 } 76 77 76 77 78 78 /** 79 79 * Initial startup function … … 127 127 $this->plugins->init(); 128 128 } 129 130 129 130 131 131 /** 132 132 * Setter for application task … … 145 145 $this->task = $task; 146 146 $this->comm_path = $this->url(array('task' => $this->task)); 147 147 148 148 if ($this->output) 149 149 $this->output->set_env('task', $this->task); 150 150 } 151 152 151 152 153 153 /** 154 154 * Setter for system user object … … 161 161 $this->user = $user; 162 162 $GLOBALS['USER'] = $this->user; 163 163 164 164 // overwrite config with user preferences 165 165 $this->config->set_user_prefs((array)$this->user->get_prefs()); 166 166 } 167 167 168 168 $_SESSION['language'] = $this->user->language = $this->language_prop($this->config->get('language', $_SESSION['language'])); 169 169 … … 171 171 setlocale(LC_ALL, $_SESSION['language'] . '.utf8', 'en_US.utf8'); 172 172 173 // workaround for http://bugs.php.net/bug.php?id=18556 174 if (in_array($_SESSION['language'], array('tr_TR', 'ku', 'az_AZ'))) 175 setlocale(LC_CTYPE, 'en_US' . '.utf8'); 176 } 177 178 173 // workaround for http://bugs.php.net/bug.php?id=18556 174 if (in_array($_SESSION['language'], array('tr_TR', 'ku', 'az_AZ'))) 175 setlocale(LC_CTYPE, 'en_US' . '.utf8'); 176 } 177 178 179 179 /** 180 180 * Check the given string and return a valid language code … … 186 186 { 187 187 static $rcube_languages, $rcube_language_aliases; 188 188 189 189 // user HTTP_ACCEPT_LANGUAGE if no language is specified 190 190 if (empty($lang) || $lang == 'auto') { … … 192 192 $lang = str_replace('-', '_', $accept_langs[0]); 193 193 } 194 194 195 195 if (empty($rcube_languages)) { 196 196 @include(INSTALL_PATH . 'program/localization/index.inc'); 197 197 } 198 198 199 199 // check if we have an alias for that language 200 200 if (!isset($rcube_languages[$lang]) && isset($rcube_language_aliases[$lang])) { … … 204 204 else if (!isset($rcube_languages[$lang])) { 205 205 $short = substr($lang, 0, 2); 206 206 207 207 // check if we have an alias for the short language code 208 208 if (!isset($rcube_languages[$short]) && isset($rcube_language_aliases[$short])) { … … 221 221 return $lang; 222 222 } 223 224 223 224 225 225 /** 226 226 * Get the current database connection … … 241 241 return $this->db; 242 242 } 243 244 243 244 245 245 /** 246 246 * Return instance of the internal address book class … … 257 257 258 258 $plugin = $this->plugins->exec_hook('get_address_book', array('id' => $id, 'writeable' => $writeable)); 259 259 260 260 // plugin returned instance of a rcube_addressbook 261 261 if ($plugin['instance'] instanceof rcube_addressbook) { … … 280 280 $contacts = new rcube_contacts($this->db, $this->user->ID); 281 281 } 282 282 283 283 return $contacts; 284 284 } … … 335 335 return $list; 336 336 } 337 338 337 338 339 339 /** 340 340 * Init output object for GUI and add common scripts. … … 368 368 // add some basic label to client 369 369 $this->output->add_label('loading', 'servererror'); 370 370 371 371 return $this->output; 372 372 } 373 374 373 374 375 375 /** 376 376 * Create an output object for JSON responses … … 382 382 if (!($this->output instanceof rcube_json_output)) 383 383 $this->output = new rcube_json_output($this->task); 384 384 385 385 return $this->output; 386 386 } … … 395 395 { 396 396 $this->smtp = new rcube_smtp(); 397 397 398 398 if ($connect) 399 399 $this->smtp->connect(); 400 400 } 401 402 401 402 403 403 /** 404 404 * Create global IMAP object and connect to server … … 412 412 if (is_object($this->imap)) 413 413 return; 414 414 415 415 $this->imap = new rcube_imap($this->db); 416 416 $this->imap->debug_level = $this->config->get('debug_level'); … … 424 424 // set pagesize from config 425 425 $this->imap->set_pagesize($this->config->get('pagesize', 50)); 426 426 427 427 // Setting root and delimiter before establishing the connection 428 // can save time detecting them using NAMESPACE and LIST 428 // can save time detecting them using NAMESPACE and LIST 429 429 $options = array( 430 430 'auth_method' => $this->config->get('imap_auth_type', 'check'), … … 436 436 437 437 $this->imap->set_options($options); 438 438 439 439 // set global object for backward compatibility 440 440 $GLOBALS['IMAP'] = $this->imap; … … 443 443 if ($hook['fetch_headers']) 444 444 $this->imap->fetch_add_headers = $hook['fetch_headers']; 445 445 446 446 // support this parameter for backward compatibility but log warning 447 447 if ($connect) { … … 462 462 if (!$this->imap) 463 463 $this->imap_init(); 464 464 465 465 if ($_SESSION['imap_host'] && !$this->imap->conn->connected()) { 466 466 if (!$this->imap->connect($_SESSION['imap_host'], $_SESSION['username'], $this->decrypt($_SESSION['password']), $_SESSION['imap_port'], $_SESSION['imap_ssl'])) { … … 501 501 ini_set('session.name', 'roundcube_sessid'); 502 502 ini_set('session.use_cookies', 1); 503 ini_set('session.use_only_cookies', 1); 503 ini_set('session.use_only_cookies', 1); 504 504 ini_set('session.serialize_handler', 'php'); 505 505 … … 588 588 $imap_port = 993; 589 589 } 590 590 591 591 $imap_port = $imap_port ? $imap_port : $config['default_port']; 592 592 593 /* Modify username with domain if required 593 /* Modify username with domain if required 594 594 Inspired by Marco <P0L0_notspam_binware.org> 595 595 */ … … 667 667 $_SESSION['password'] = $this->encrypt($pass); 668 668 $_SESSION['login_time'] = mktime(); 669 670 if ( $_REQUEST['_timezone'] != '_default_')669 670 if (isset($_REQUEST['_timezone']) && $_REQUEST['_timezone'] != '_default_') 671 671 $_SESSION['timezone'] = floatval($_REQUEST['_timezone']); 672 672 … … 698 698 $this->imap->set_page($_SESSION['page']); 699 699 } 700 700 701 701 // cache IMAP root and delimiter in session for performance reasons 702 702 $_SESSION['imap_root'] = $this->imap->root_dir; … … 714 714 $default_host = $this->config->get('default_host'); 715 715 $host = null; 716 716 717 717 if (is_array($default_host)) { 718 718 $post_host = get_input_value('_host', RCUBE_INPUT_POST); 719 719 720 720 // direct match in default_host array 721 721 if ($default_host[$post_host] || in_array($post_host, array_values($default_host))) { 722 722 $host = $post_host; 723 723 } 724 724 725 725 // try to select host by mail domain 726 726 list($user, $domain) = explode('@', get_input_value('_user', RCUBE_INPUT_POST)); … … 760 760 if (empty($this->texts)) 761 761 $this->load_language(); 762 762 763 763 // extract attributes 764 764 if (is_string($attrib)) … … 776 776 } 777 777 778 // make text item array 778 // make text item array 779 779 $a_text_item = is_array($text_item) ? $text_item : array('single' => $text_item); 780 780 … … 826 826 { 827 827 $lang = $this->language_prop(($lang ? $lang : $_SESSION['language'])); 828 828 829 829 // load localized texts 830 830 if (empty($this->texts) || $lang != $_SESSION['language']) { … … 850 850 $this->texts = array_merge($this->texts, $messages); 851 851 } 852 852 853 853 $_SESSION['language'] = $lang; 854 854 } … … 929 929 { 930 930 $this->plugins->exec_hook('kill_session'); 931 931 932 932 $this->session->remove(); 933 933 $_SESSION = array('language' => $this->user->language, 'auth_time' => time(), 'temp' => true); … … 943 943 { 944 944 $config = $this->config->all(); 945 946 // on logout action we're not connected to imap server 945 946 // on logout action we're not connected to imap server 947 947 if (($config['logout_purge'] && !empty($config['trash_mbox'])) || $config['logout_expunge']) { 948 948 if (!$this->authenticate_session()) … … 995 995 } 996 996 } 997 998 997 998 999 999 /** 1000 1000 * Generate a unique token to be used in a form request … … 1005 1005 { 1006 1006 $key = $this->task; 1007 1007 1008 1008 if (!$_SESSION['request_tokens'][$key]) 1009 1009 $_SESSION['request_tokens'][$key] = md5(uniqid($key . mt_rand(), true)); 1010 1010 1011 1011 return $_SESSION['request_tokens'][$key]; 1012 1012 } 1013 1014 1013 1014 1015 1015 /** 1016 1016 * Check if the current request contains a valid token … … 1024 1024 return !empty($token) && $_SESSION['request_tokens'][$this->task] == $token; 1025 1025 } 1026 1027 1026 1027 1028 1028 /** 1029 1029 * Create unique authorization hash … … 1067 1067 */ 1068 1068 $clear = pack("a*H2", $clear, "80"); 1069 1069 1070 1070 if (function_exists('mcrypt_module_open') && 1071 1071 ($td = mcrypt_module_open(MCRYPT_TripleDES, "", MCRYPT_MODE_CBC, ""))) … … 1112 1112 if (!$cipher) 1113 1113 return ''; 1114 1114 1115 1115 $cipher = $base64 ? base64_decode($cipher) : $cipher; 1116 1116 … … 1127 1127 else { 1128 1128 @include_once('lib/des.inc'); 1129 1129 1130 1130 if (function_exists('des')) { 1131 1131 $des_iv_size = 8; … … 1148 1148 */ 1149 1149 $clear = substr(rtrim($clear, "\0"), 0, -1); 1150 1150 1151 1151 return $clear; 1152 1152 } … … 1162 1162 if (!is_array($p)) 1163 1163 $p = array('_action' => @func_get_arg(0)); 1164 1164 1165 1165 $task = $p['_task'] ? $p['_task'] : ($p['task'] ? $p['task'] : $this->task); 1166 1166 $p['_task'] = $task;
Note: See TracChangeset
for help on using the changeset viewer.
