Changeset 2eb7943 in github
- Timestamp:
- Apr 23, 2010 7:25:37 AM (3 years ago)
- Branches:
- master, HEAD, courier-fix, dev-browser-capabilities, pdo, release-0.6, release-0.7, release-0.8
- Children:
- a03c9809
- Parents:
- 6319670
- Location:
- program/include
- Files:
-
- 9 edited
-
bugs.inc (modified) (3 diffs)
-
iniset.php (modified) (7 diffs)
-
rcube_addressbook.php (modified) (11 diffs)
-
rcube_config.php (modified) (2 diffs)
-
rcube_html_page.php (modified) (5 diffs)
-
rcube_json_output.php (modified) (12 diffs)
-
rcube_result_set.php (modified) (2 diffs)
-
rcube_sqlite.inc (modified) (2 diffs)
-
rcube_template.php (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
program/include/bugs.inc
r4a941f7 r2eb7943 6 6 | | 7 7 | This file is part of the RoudCube Webmail client | 8 | Copyright (C) 2005-20 09, RoudCube Dev - Switzerland |8 | Copyright (C) 2005-2010, RoudCube Dev - Switzerland | 9 9 | Licensed under the GNU GPL | 10 10 | | … … 41 41 */ 42 42 function raise_error($arg=array(), $log=false, $terminate=false) 43 {44 global $__page_content, $CONFIG, $OUTPUT, $ERROR_CODE, $ERROR_MESSAGE;43 { 44 global $__page_content, $CONFIG, $OUTPUT, $ERROR_CODE, $ERROR_MESSAGE; 45 45 46 // report bug (if not incompatible browser)47 if ($log && $arg['type'] && $arg['message'])48 log_bug($arg);46 // report bug (if not incompatible browser) 47 if ($log && $arg['type'] && $arg['message']) 48 log_bug($arg); 49 49 50 // display error page and terminate script 51 if ($terminate) 52 { 53 $ERROR_CODE = $arg['code']; 54 $ERROR_MESSAGE = $arg['message']; 55 include("program/steps/error.inc"); 56 exit; 50 // display error page and terminate script 51 if ($terminate) { 52 $ERROR_CODE = $arg['code']; 53 $ERROR_MESSAGE = $arg['message']; 54 include("program/steps/error.inc"); 55 exit; 57 56 } 58 }57 } 59 58 60 59 … … 67 66 function log_bug($arg_arr) 68 67 { 69 global $CONFIG;70 $program = strtoupper($arg_arr['type']);68 global $CONFIG; 69 $program = strtoupper($arg_arr['type']); 71 70 72 // write error to local log file 73 if ($CONFIG['debug_level'] & 1) 74 { 75 $post_query = ($_SERVER['REQUEST_METHOD'] == 'POST' ? '?_task='.urlencode($_POST['_task']).'&_action='.urlencode($_POST['_action']) : ''); 76 $log_entry = sprintf("%s Error: %s%s (%s %s)", 77 $program, 78 $arg_arr['message'], 79 $arg_arr['file'] ? sprintf(' in %s on line %d', $arg_arr['file'], $arg_arr['line']) : '', 80 $_SERVER['REQUEST_METHOD'], 81 $_SERVER['REQUEST_URI'] . $post_query); 71 // write error to local log file 72 if ($CONFIG['debug_level'] & 1) { 73 $post_query = ($_SERVER['REQUEST_METHOD'] == 'POST' ? '?_task='.urlencode($_POST['_task']).'&_action='.urlencode($_POST['_action']) : ''); 74 $log_entry = sprintf("%s Error: %s%s (%s %s)", 75 $program, 76 $arg_arr['message'], 77 $arg_arr['file'] ? sprintf(' in %s on line %d', $arg_arr['file'], $arg_arr['line']) : '', 78 $_SERVER['REQUEST_METHOD'], 79 $_SERVER['REQUEST_URI'] . $post_query); 82 80 83 if (!write_log('errors', $log_entry))84 {85 // send error to PHPs error handler if write_log didn't succeed86 trigger_error($arg_arr['message']);81 if (!write_log('errors', $log_entry)) { 82 // send error to PHPs error handler if write_log didn't succeed 83 trigger_error($arg_arr['message']); 84 } 87 85 } 88 }89 86 90 // resport the bug to the global bug reporting system 91 if ($CONFIG['debug_level'] & 2) 92 { 93 // TODO: Send error via HTTP 94 } 87 // resport the bug to the global bug reporting system 88 if ($CONFIG['debug_level'] & 2) { 89 // TODO: Send error via HTTP 90 } 95 91 96 // show error if debug_mode is on 97 if ($CONFIG['debug_level'] & 4) 98 { 99 print "<b>$program Error"; 92 // show error if debug_mode is on 93 if ($CONFIG['debug_level'] & 4) { 94 print "<b>$program Error"; 100 95 101 if (!empty($arg_arr['file']) && !empty($arg_arr['line']))102 print " in $arg_arr[file] ($arg_arr[line])";96 if (!empty($arg_arr['file']) && !empty($arg_arr['line'])) 97 print " in $arg_arr[file] ($arg_arr[line])"; 103 98 104 print ":</b> ";105 print nl2br($arg_arr['message']);106 print '<br />';107 flush();108 }99 print ':</b> '; 100 print nl2br($arg_arr['message']); 101 print '<br />'; 102 flush(); 103 } 109 104 } 110 105 -
program/include/iniset.php
rcd96fd6 r2eb7943 43 43 44 44 if (!defined('INSTALL_PATH')) { 45 define('INSTALL_PATH', dirname($_SERVER['SCRIPT_FILENAME']).'/');45 define('INSTALL_PATH', dirname($_SERVER['SCRIPT_FILENAME']).'/'); 46 46 } 47 47 … … 50 50 // make sure path_separator is defined 51 51 if (!defined('PATH_SEPARATOR')) { 52 define('PATH_SEPARATOR', (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN') ? ';' : ':');52 define('PATH_SEPARATOR', (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN') ? ';' : ':'); 53 53 } 54 54 … … 63 63 64 64 if (set_include_path($include_path) === false) { 65 die('Fatal error: ini_set/set_include_path does not work.');65 die('Fatal error: ini_set/set_include_path does not work.'); 66 66 } 67 67 … … 74 74 // set internal encoding for mbstring extension 75 75 if(extension_loaded('mbstring')) 76 mb_internal_encoding(RCMAIL_CHARSET);76 mb_internal_encoding(RCMAIL_CHARSET); 77 77 78 78 … … 85 85 function rcube_autoload($classname) 86 86 { 87 $filename = preg_replace(88 array(89 '/MDB2_(.+)/',90 '/Mail_(.+)/',91 '/Net_(.+)/',92 '/^html_.+/',93 '/^utf8$/',94 '/html2text/'95 ),96 array(97 'MDB2/\\1',98 'Mail/\\1',99 'Net/\\1',100 'html',101 'utf8.class',102 'lib/html2text' // see #1485505103 ),104 $classname105 );106 include $filename. '.php';87 $filename = preg_replace( 88 array( 89 '/MDB2_(.+)/', 90 '/Mail_(.+)/', 91 '/Net_(.+)/', 92 '/^html_.+/', 93 '/^utf8$/', 94 '/html2text/' 95 ), 96 array( 97 'MDB2/\\1', 98 'Mail/\\1', 99 'Net/\\1', 100 'html', 101 'utf8.class', 102 'lib/html2text' // see #1485505 103 ), 104 $classname 105 ); 106 include $filename. '.php'; 107 107 } 108 108 … … 114 114 function rcube_pear_error($err) 115 115 { 116 error_log(sprintf("%s (%s): %s",117 $err->getMessage(),118 $err->getCode(),119 $err->getUserinfo()), 0);116 error_log(sprintf("%s (%s): %s", 117 $err->getMessage(), 118 $err->getCode(), 119 $err->getUserinfo()), 0); 120 120 } 121 122 // set PEAR error handling (will also load the PEAR main class) 123 PEAR::setErrorHandling(PEAR_ERROR_CALLBACK, 'rcube_pear_error'); 121 124 122 125 // include global functions … … 124 127 require_once 'include/main.inc'; 125 128 require_once 'include/rcube_shared.inc'; 126 127 128 // set PEAR error handling (will also load the PEAR main class)129 PEAR::setErrorHandling(PEAR_ERROR_CALLBACK, 'rcube_pear_error'); -
program/include/rcube_addressbook.php
r04adaac r2eb7943 118 118 function set_page($page) 119 119 { 120 $this->list_page = (int)$page;120 $this->list_page = (int)$page; 121 121 } 122 122 … … 129 129 function set_pagesize($size) 130 130 { 131 $this->page_size = (int)$size;131 $this->page_size = (int)$size; 132 132 } 133 133 … … 147 147 function insert($save_data, $check=false) 148 148 { 149 /* empty for read-only address books */149 /* empty for read-only address books */ 150 150 } 151 151 … … 159 159 function update($id, $save_cols) 160 160 { 161 /* empty for read-only address books */161 /* empty for read-only address books */ 162 162 } 163 163 … … 169 169 function delete($ids) 170 170 { 171 /* empty for read-only address books */171 /* empty for read-only address books */ 172 172 } 173 173 … … 177 177 function delete_all() 178 178 { 179 /* empty for read-only address books */179 /* empty for read-only address books */ 180 180 } 181 181 … … 188 188 function create_group($name) 189 189 { 190 /* empty for address books don't supporting groups */191 return false;190 /* empty for address books don't supporting groups */ 191 return false; 192 192 } 193 193 … … 200 200 function delete_group($gid) 201 201 { 202 /* empty for address books don't supporting groups */203 return false;202 /* empty for address books don't supporting groups */ 203 return false; 204 204 } 205 205 … … 213 213 function rename_group($gid, $newname) 214 214 { 215 /* empty for address books don't supporting groups */216 return false;215 /* empty for address books don't supporting groups */ 216 return false; 217 217 } 218 218 … … 226 226 function add_to_group($group_id, $ids) 227 227 { 228 /* empty for address books don't supporting groups */229 return 0;228 /* empty for address books don't supporting groups */ 229 return 0; 230 230 } 231 231 … … 239 239 function remove_from_group($group_id, $ids) 240 240 { 241 /* empty for address books don't supporting groups */242 return 0;241 /* empty for address books don't supporting groups */ 242 return 0; 243 243 } 244 244 } 245 -
program/include/rcube_config.php
rb545d3e r2eb7943 6 6 | | 7 7 | This file is part of the RoundCube Webmail client | 8 | Copyright (C) 2008-20 09, RoundCube Dev. - Switzerland |8 | Copyright (C) 2008-2010, RoundCube Dev. - Switzerland | 9 9 | Licensed under the GNU GPL | 10 10 | | … … 27 27 class rcube_config 28 28 { 29 private $prop = array(); 30 private $errors = array(); 31 private $userprefs = array(); 32 33 34 /** 35 * Object constructor 36 */ 37 public function __construct() 38 { 39 $this->load(); 40 } 41 42 43 /** 44 * Load config from local config file 45 * 46 * @todo Remove global $CONFIG 47 */ 48 private function load() 49 { 50 // start output buffering, we don't need any output yet, 51 // it'll be cleared after reading of config files, etc. 52 ob_start(); 53 54 // load main config file 55 if (!$this->load_from_file(RCMAIL_CONFIG_DIR . '/main.inc.php')) 56 $this->errors[] = 'main.inc.php was not found.'; 57 58 // load database config 59 if (!$this->load_from_file(RCMAIL_CONFIG_DIR . '/db.inc.php')) 60 $this->errors[] = 'db.inc.php was not found.'; 61 62 // load host-specific configuration 63 $this->load_host_config(); 64 65 // set skin (with fallback to old 'skin_path' property) 66 if (empty($this->prop['skin']) && !empty($this->prop['skin_path'])) 67 $this->prop['skin'] = str_replace('skins/', '', unslashify($this->prop['skin_path'])); 68 else if (empty($this->prop['skin'])) 69 $this->prop['skin'] = 'default'; 70 71 // fix paths 72 $this->prop['log_dir'] = $this->prop['log_dir'] ? realpath(unslashify($this->prop['log_dir'])) : INSTALL_PATH . 'logs'; 73 $this->prop['temp_dir'] = $this->prop['temp_dir'] ? realpath(unslashify($this->prop['temp_dir'])) : INSTALL_PATH . 'temp'; 74 75 // fix default imap folders encoding 76 foreach (array('drafts_mbox', 'junk_mbox', 'sent_mbox', 'trash_mbox') as $folder) 77 $this->prop[$folder] = rcube_charset_convert($this->prop[$folder], RCMAIL_CHARSET, 'UTF7-IMAP'); 78 79 if (!empty($this->prop['default_imap_folders'])) 80 foreach ($this->prop['default_imap_folders'] as $n => $folder) 81 $this->prop['default_imap_folders'][$n] = rcube_charset_convert($folder, RCMAIL_CHARSET, 'UTF7-IMAP'); 82 83 // set PHP error logging according to config 84 if ($this->prop['debug_level'] & 1) { 85 ini_set('log_errors', 1); 86 87 if ($this->prop['log_driver'] == 'syslog') { 88 ini_set('error_log', 'syslog'); 89 } else { 90 ini_set('error_log', $this->prop['log_dir'].'/errors'); 91 } 92 } 93 if ($this->prop['debug_level'] & 4) { 94 ini_set('display_errors', 1); 95 } 96 else { 97 ini_set('display_errors', 0); 98 } 99 100 // clear output buffer 101 ob_end_clean(); 102 103 // export config data 104 $GLOBALS['CONFIG'] = &$this->prop; 105 } 29 private $prop = array(); 30 private $errors = array(); 31 private $userprefs = array(); 32 33 34 /** 35 * Object constructor 36 */ 37 public function __construct() 38 { 39 $this->load(); 40 } 41 42 43 /** 44 * Load config from local config file 45 * 46 * @todo Remove global $CONFIG 47 */ 48 private function load() 49 { 50 // start output buffering, we don't need any output yet, 51 // it'll be cleared after reading of config files, etc. 52 ob_start(); 53 54 // load main config file 55 if (!$this->load_from_file(RCMAIL_CONFIG_DIR . '/main.inc.php')) 56 $this->errors[] = 'main.inc.php was not found.'; 57 58 // load database config 59 if (!$this->load_from_file(RCMAIL_CONFIG_DIR . '/db.inc.php')) 60 $this->errors[] = 'db.inc.php was not found.'; 61 62 // load host-specific configuration 63 $this->load_host_config(); 64 65 // set skin (with fallback to old 'skin_path' property) 66 if (empty($this->prop['skin']) && !empty($this->prop['skin_path'])) 67 $this->prop['skin'] = str_replace('skins/', '', unslashify($this->prop['skin_path'])); 68 else if (empty($this->prop['skin'])) 69 $this->prop['skin'] = 'default'; 70 71 // fix paths 72 $this->prop['log_dir'] = $this->prop['log_dir'] ? realpath(unslashify($this->prop['log_dir'])) : INSTALL_PATH . 'logs'; 73 $this->prop['temp_dir'] = $this->prop['temp_dir'] ? realpath(unslashify($this->prop['temp_dir'])) : INSTALL_PATH . 'temp'; 74 75 // fix default imap folders encoding 76 foreach (array('drafts_mbox', 'junk_mbox', 'sent_mbox', 'trash_mbox') as $folder) 77 $this->prop[$folder] = rcube_charset_convert($this->prop[$folder], RCMAIL_CHARSET, 'UTF7-IMAP'); 78 79 if (!empty($this->prop['default_imap_folders'])) 80 foreach ($this->prop['default_imap_folders'] as $n => $folder) 81 $this->prop['default_imap_folders'][$n] = rcube_charset_convert($folder, RCMAIL_CHARSET, 'UTF7-IMAP'); 82 83 // set PHP error logging according to config 84 if ($this->prop['debug_level'] & 1) { 85 ini_set('log_errors', 1); 86 87 if ($this->prop['log_driver'] == 'syslog') { 88 ini_set('error_log', 'syslog'); 89 } 90 else { 91 ini_set('error_log', $this->prop['log_dir'].'/errors'); 92 } 93 } 94 if ($this->prop['debug_level'] & 4) { 95 ini_set('display_errors', 1); 96 } 97 else { 98 ini_set('display_errors', 0); 99 } 100 101 // clear output buffer 102 ob_end_clean(); 103 104 // export config data 105 $GLOBALS['CONFIG'] = &$this->prop; 106 } 107 108 /** 109 * Load a host-specific config file if configured 110 * This will merge the host specific configuration with the given one 111 */ 112 private function load_host_config() 113 { 114 $fname = null; 115 116 if (is_array($this->prop['include_host_config'])) { 117 $fname = $this->prop['include_host_config'][$_SERVER['HTTP_HOST']]; 118 } 119 else if (!empty($this->prop['include_host_config'])) { 120 $fname = preg_replace('/[^a-z0-9\.\-_]/i', '', $_SERVER['HTTP_HOST']) . '.inc.php'; 121 } 122 123 if ($fname) { 124 $this->load_from_file(RCMAIL_CONFIG_DIR . '/' . $fname); 125 } 126 } 127 128 129 /** 130 * Read configuration from a file 131 * and merge with the already stored config values 132 * 133 * @param string Full path to the config file to be loaded 134 * @return booelan True on success, false on failure 135 */ 136 public function load_from_file($fpath) 137 { 138 if (is_file($fpath) && is_readable($fpath)) { 139 include($fpath); 140 if (is_array($rcmail_config)) { 141 $this->prop = array_merge($this->prop, $rcmail_config, $this->userprefs); 142 return true; 143 } 144 } 145 146 return false; 147 } 148 149 150 /** 151 * Getter for a specific config parameter 152 * 153 * @param string Parameter name 154 * @param mixed Default value if not set 155 * @return mixed The requested config value 156 */ 157 public function get($name, $def = null) 158 { 159 return isset($this->prop[$name]) ? $this->prop[$name] : $def; 160 } 161 162 163 /** 164 * Setter for a config parameter 165 * 166 * @param string Parameter name 167 * @param mixed Parameter value 168 */ 169 public function set($name, $value) 170 { 171 $this->prop[$name] = $value; 172 } 173 174 175 /** 176 * Override config options with the given values (eg. user prefs) 177 * 178 * @param array Hash array with config props to merge over 179 */ 180 public function merge($prefs) 181 { 182 $this->prop = array_merge($this->prop, $prefs, $this->userprefs); 183 } 184 185 186 /** 187 * Merge the given prefs over the current config 188 * and make sure that they survive further merging. 189 * 190 * @param array Hash array with user prefs 191 */ 192 public function set_user_prefs($prefs) 193 { 194 $this->userprefs = $prefs; 195 $this->prop = array_merge($this->prop, $prefs); 196 } 197 198 199 /** 200 * Getter for all config options 201 * 202 * @return array Hash array containg all config properties 203 */ 204 public function all() 205 { 206 return $this->prop; 207 } 208 209 210 /** 211 * Return requested DES crypto key. 212 * 213 * @param string Crypto key name 214 * @return string Crypto key 215 */ 216 public function get_crypto_key($key) 217 { 218 // Bomb out if the requested key does not exist 219 if (!array_key_exists($key, $this->prop)) { 220 raise_error(array( 221 'code' => 500, 'type' => 'php', 222 'file' => __FILE__, 'line' => __LINE__, 223 'message' => "Request for unconfigured crypto key \"$key\"" 224 ), true, true); 225 } 226 227 $key = $this->prop[$key]; 228 229 // Bomb out if the configured key is not exactly 24 bytes long 230 if (strlen($key) != 24) { 231 raise_error(array( 232 'code' => 500, 'type' => 'php', 233 'file' => __FILE__, 'line' => __LINE__, 234 'message' => "Configured crypto key '$key' is not exactly 24 bytes long" 235 ), true, true); 236 } 237 238 return $key; 239 } 240 241 242 /** 243 * Try to autodetect operating system and find the correct line endings 244 * 245 * @return string The appropriate mail header delimiter 246 */ 247 public function header_delimiter() 248 { 249 // use the configured delimiter for headers 250 if (!empty($this->prop['mail_header_delimiter'])) 251 return $this->prop['mail_header_delimiter']; 252 253 $php_os = strtolower(substr(PHP_OS, 0, 3)); 254 255 if ($php_os == 'win') 256 return "\r\n"; 257 258 if ($php_os == 'mac') 259 return "\r\n"; 260 261 return "\n"; 262 } 263 264 265 /** 266 * Return the mail domain configured for the given host 267 * 268 * @param string IMAP host 269 * @return string Resolved SMTP host 270 */ 271 public function mail_domain($host) 272 { 273 $domain = $host; 274 275 if (is_array($this->prop['mail_domain'])) { 276 if (isset($this->prop['mail_domain'][$host])) 277 $domain = $this->prop['mail_domain'][$host]; 278 } 279 else if (!empty($this->prop['mail_domain'])) 280 $domain = $this->prop['mail_domain']; 281 282 return $domain; 283 } 106 284 107 285 108 /** 109 * Load a host-specific config file if configured 110 * This will merge the host specific configuration with the given one 111 */ 112 private function load_host_config() 113 { 114 $fname = null; 115 116 if (is_array($this->prop['include_host_config'])) { 117 $fname = $this->prop['include_host_config'][$_SERVER['HTTP_HOST']]; 118 } 119 else if (!empty($this->prop['include_host_config'])) { 120 $fname = preg_replace('/[^a-z0-9\.\-_]/i', '', $_SERVER['HTTP_HOST']) . '.inc.php'; 121 } 122 123 if ($fname) { 124 $this->load_from_file(RCMAIL_CONFIG_DIR . '/' . $fname); 125 } 126 } 127 128 129 /** 130 * Read configuration from a file 131 * and merge with the already stored config values 132 * 133 * @param string Full path to the config file to be loaded 134 * @return booelan True on success, false on failure 135 */ 136 public function load_from_file($fpath) 137 { 138 if (is_file($fpath) && is_readable($fpath)) { 139 include($fpath); 140 if (is_array($rcmail_config)) { 141 $this->prop = array_merge($this->prop, $rcmail_config, $this->userprefs); 142 return true; 143 } 144 } 145 146 return false; 147 } 148 149 150 /** 151 * Getter for a specific config parameter 152 * 153 * @param string Parameter name 154 * @param mixed Default value if not set 155 * @return mixed The requested config value 156 */ 157 public function get($name, $def = null) 158 { 159 return isset($this->prop[$name]) ? $this->prop[$name] : $def; 160 } 161 162 163 /** 164 * Setter for a config parameter 165 * 166 * @param string Parameter name 167 * @param mixed Parameter value 168 */ 169 public function set($name, $value) 170 { 171 $this->prop[$name] = $value; 172 } 173 174 175 /** 176 * Override config options with the given values (eg. user prefs) 177 * 178 * @param array Hash array with config props to merge over 179 */ 180 public function merge($prefs) 181 { 182 $this->prop = array_merge($this->prop, $prefs, $this->userprefs); 183 } 184 185 186 /** 187 * Merge the given prefs over the current config 188 * and make sure that they survive further merging. 189 * 190 * @param array Hash array with user prefs 191 */ 192 public function set_user_prefs($prefs) 193 { 194 $this->userprefs = $prefs; 195 $this->prop = array_merge($this->prop, $prefs); 196 } 197 198 199 /** 200 * Getter for all config options 201 * 202 * @return array Hash array containg all config properties 203 */ 204 public function all() 205 { 206 return $this->prop; 207 } 208 209 210 /** 211 * Return requested DES crypto key. 212 * 213 * @param string Crypto key name 214 * @return string Crypto key 215 */ 216 public function get_crypto_key($key) 217 { 218 // Bomb out if the requested key does not exist 219 if (!array_key_exists($key, $this->prop)) 220 { 221 raise_error(array( 222 'code' => 500, 'type' => 'php', 223 'file' => __FILE__, 'line' => __LINE__, 224 'message' => "Request for unconfigured crypto key \"$key\"" 225 ), true, true); 226 } 227 228 $key = $this->prop[$key]; 229 230 // Bomb out if the configured key is not exactly 24 bytes long 231 if (strlen($key) != 24) 232 { 233 raise_error(array( 234 'code' => 500, 'type' => 'php', 235 'file' => __FILE__, 'line' => __LINE__, 236 'message' => "Configured crypto key \"$key\" is not exactly 24 bytes long" 237 ), true, true); 238 } 239 240 return $key; 241 } 242 243 244 /** 245 * Try to autodetect operating system and find the correct line endings 246 * 247 * @return string The appropriate mail header delimiter 248 */ 249 public function header_delimiter() 250 { 251 // use the configured delimiter for headers 252 if (!empty($this->prop['mail_header_delimiter'])) 253 return $this->prop['mail_header_delimiter']; 254 else if (strtolower(substr(PHP_OS, 0, 3)) == 'win') 255 return "\r\n"; 256 else if (strtolower(substr(PHP_OS, 0, 3)) == 'mac') 257 return "\r\n"; 258 else 259 return "\n"; 260 } 261 262 263 /** 264 * Return the mail domain configured for the given host 265 * 266 * @param string IMAP host 267 * @return string Resolved SMTP host 268 */ 269 public function mail_domain($host) 270 { 271 $domain = $host; 272 273 if (is_array($this->prop['mail_domain'])) { 274 if (isset($this->prop['mail_domain'][$host])) 275 $domain = $this->prop['mail_domain'][$host]; 276 } 277 else if (!empty($this->prop['mail_domain'])) 278 $domain = $this->prop['mail_domain']; 279 280 return $domain; 281 } 282 283 284 /** 285 * Getter for error state 286 * 287 * @return mixed Error message on error, False if no errors 288 */ 289 public function get_error() 290 { 291 return empty($this->errors) ? false : join("\n", $this->errors); 292 } 293 286 /** 287 * Getter for error state 288 * 289 * @return mixed Error message on error, False if no errors 290 */ 291 public function get_error() 292 { 293 return empty($this->errors) ? false : join("\n", $this->errors); 294 } 294 295 295 296 } 296 -
program/include/rcube_html_page.php
r74be739 r2eb7943 57 57 58 58 if (!preg_match('|^https?://|i', $file) && $file[0] != '/') 59 $file = $this->scripts_path . $file . (($fs = @filemtime($this->scripts_path . $file)) ? '?s='.$fs : '');59 $file = $this->scripts_path . $file . (($fs = @filemtime($this->scripts_path . $file)) ? '?s='.$fs : ''); 60 60 61 61 if (in_array($file, $sa_files)) { … … 131 131 { 132 132 $this->script_files = array(); 133 $this->scripts = array();134 $this->title = '';135 $this->header = '';136 $this->footer = '';137 $this->body = '';133 $this->scripts = array(); 134 $this->title = ''; 135 $this->header = ''; 136 $this->footer = ''; 137 $this->body = ''; 138 138 } 139 139 … … 249 249 $__page_header = $__page_footer = ''; 250 250 251 $this->base_path = $base_path;251 $this->base_path = $base_path; 252 252 // correct absolute paths in images and other tags 253 // add timestamp to .js and .css filename253 // add timestamp to .js and .css filename 254 254 $output = preg_replace_callback('!(src|href|background)=(["\']?)([a-z0-9/_.-]+)(["\'\s>])!i', 255 255 array($this, 'file_callback'), $output); … … 257 257 258 258 if ($this->charset != RCMAIL_CHARSET) 259 echo rcube_charset_convert($output, RCMAIL_CHARSET, $this->charset);260 else261 echo $output;259 echo rcube_charset_convert($output, RCMAIL_CHARSET, $this->charset); 260 else 261 echo $output; 262 262 } 263 263 … … 267 267 private function file_callback($matches) 268 268 { 269 $file = $matches[3];269 $file = $matches[3]; 270 270 271 271 // correct absolute paths 272 if ($file[0] == '/')273 $file = $this->base_path . $file;272 if ($file[0] == '/') 273 $file = $this->base_path . $file; 274 274 275 275 // add file modification timestamp 276 if (preg_match('/\.(js|css)$/', $file))276 if (preg_match('/\.(js|css)$/', $file)) 277 277 $file .= '?s=' . @filemtime($file); 278 278 279 return sprintf("%s=%s%s%s", $matches[1], $matches[2], $file, $matches[4]);279 return sprintf("%s=%s%s%s", $matches[1], $matches[2], $file, $matches[4]); 280 280 } 281 281 } -
program/include/rcube_json_output.php
r1d786c8 r2eb7943 6 6 | | 7 7 | This file is part of the RoundCube Webmail client | 8 | Copyright (C) 2008-20 09, RoundCube Dev. - Switzerland |8 | Copyright (C) 2008-2010, RoundCube Dev. - Switzerland | 9 9 | Licensed under the GNU GPL | 10 10 | | … … 48 48 $this->config = rcmail::get_instance()->config; 49 49 } 50 51 50 51 52 52 /** 53 53 * Set environment variable … … 60 60 $this->env[$name] = $value; 61 61 } 62 62 63 63 64 /** 64 65 * Issue command to set page title … … 71 72 $this->command('set_pagetitle', empty($name) ? $title : $name.' :: '.$title); 72 73 } 74 73 75 74 76 /** … … 104 106 } 105 107 108 106 109 /** 107 110 * Register a list of template object handlers … … 114 117 // ignore 115 118 } 116 117 119 120 118 121 /** 119 122 * Call a client method … … 146 149 } 147 150 } 148 151 149 152 150 153 /** … … 168 171 } 169 172 } 170 173 174 171 175 /** 172 176 * Delete all stored env variables and commands … … 178 182 $this->commands = array(); 179 183 } 180 184 185 181 186 /** 182 187 * Redirect to a certain url … … 228 233 229 234 if (!empty($this->env)) 230 $response['env'] = $this->env;235 $response['env'] = $this->env; 231 236 232 237 if (!empty($this->texts)) 233 $response['texts'] = $this->texts;238 $response['texts'] = $this->texts; 234 239 235 240 // send function calls … … 237 242 238 243 if (!empty($this->callbacks)) 239 $response['callbacks'] = $this->callbacks;244 $response['callbacks'] = $this->callbacks; 240 245 241 246 echo json_serialize($response); 242 247 } 243 244 248 249 245 250 /** 246 251 * Return executable javascript code for all registered commands … … 268 273 } 269 274 } 270 271 -
program/include/rcube_result_set.php
r638fb8a r2eb7943 6 6 | | 7 7 | This file is part of the RoundCube Webmail client | 8 | Copyright (C) 2006-20 09, RoundCube Dev. - Switzerland |8 | Copyright (C) 2006-2010, RoundCube Dev. - Switzerland | 9 9 | Licensed under the GNU GPL | 10 10 | | … … 29 29 class rcube_result_set 30 30 { 31 var $count = 0; 32 var $first = 0; 33 var $current = 0; 34 var $records = array(); 31 var $count = 0; 32 var $first = 0; 33 var $current = 0; 34 var $records = array(); 35 36 37 function __construct($c=0, $f=0) 38 { 39 $this->count = (int)$c; 40 $this->first = (int)$f; 41 } 42 43 function add($rec) 44 { 45 $this->records[] = $rec; 46 } 35 47 36 function __construct($c=0, $f=0) 37 { 38 $this->count = (int)$c; 39 $this->first = (int)$f; 40 } 48 function iterate() 49 { 50 return $this->records[$this->current++]; 51 } 41 52 42 function add($rec) 43 { 44 $this->records[] = $rec; 45 } 53 function first() 54 { 55 $this->current = 0; 56 return $this->records[$this->current++]; 57 } 46 58 47 function iterate() 48 { 49 return $this->records[$this->current++]; 50 } 59 // alias for iterate() 60 function next() 61 { 62 return $this->iterate(); 63 } 51 64 52 function first() 53 { 54 $this->current = 0; 55 return $this->records[$this->current++]; 56 } 57 58 // alias 59 function next() 60 { 61 return $this->iterate(); 62 } 63 64 function seek($i) 65 { 66 $this->current = $i; 67 } 65 function seek($i) 66 { 67 $this->current = $i; 68 } 68 69 69 70 } -
program/include/rcube_sqlite.inc
r5349b78 r2eb7943 6 6 | | 7 7 | This file is part of the RoundCube Webmail client | 8 | Copyright (C) 2005-20 07, RoundCube Dev. - Switzerland |8 | Copyright (C) 2005-2010, RoundCube Dev. - Switzerland | 9 9 | Licensed under the GNU GPL | 10 10 | | … … 29 29 30 30 function rcube_sqlite_from_unixtime($timestamp) 31 {32 $timestamp = trim($timestamp);33 if (!preg_match("/^[0-9]+$/is", $timestamp))34 $ret = strtotime($timestamp);35 else36 $ret = $timestamp;31 { 32 $timestamp = trim($timestamp); 33 if (!preg_match('/^[0-9]+$/is', $timestamp)) 34 $ret = strtotime($timestamp); 35 else 36 $ret = $timestamp; 37 37 38 $ret = date("Y-m-d H:i:s", $ret);39 rcube_sqlite_debug("FROM_UNIXTIME ($timestamp) = $ret");40 return $ret;41 }38 $ret = date('Y-m-d H:i:s', $ret); 39 rcube_sqlite_debug("FROM_UNIXTIME ($timestamp) = $ret"); 40 return $ret; 41 } 42 42 43 43 44 function rcube_sqlite_unix_timestamp($timestamp= "")45 {46 $timestamp = trim($timestamp);47 if (!$timestamp)48 $ret = time();49 else if (!preg_match("/^[0-9]+$/is", $timestamp))50 $ret = strtotime($timestamp);51 else52 $ret = $timestamp;44 function rcube_sqlite_unix_timestamp($timestamp='') 45 { 46 $timestamp = trim($timestamp); 47 if (!$timestamp) 48 $ret = time(); 49 else if (!preg_match('/^[0-9]+$/is', $timestamp)) 50 $ret = strtotime($timestamp); 51 else 52 $ret = $timestamp; 53 53 54 rcube_sqlite_debug("UNIX_TIMESTAMP ($timestamp) = $ret");55 return $ret;56 }54 rcube_sqlite_debug("UNIX_TIMESTAMP ($timestamp) = $ret"); 55 return $ret; 56 } 57 57 58 58 59 59 function rcube_sqlite_now() 60 {61 rcube_sqlite_debug("NOW() = ".date("Y-m-d H:i:s"));62 return date("Y-m-d H:i:s");63 }60 { 61 rcube_sqlite_debug("NOW() = ".date("Y-m-d H:i:s")); 62 return date("Y-m-d H:i:s"); 63 } 64 64 65 65 66 66 function rcube_sqlite_md5($str) 67 {68 return md5($str);69 }67 { 68 return md5($str); 69 } 70 70 71 71 72 72 function rcube_sqlite_debug($str) 73 {74 //console($str);75 }73 { 74 //console($str); 75 } 76 76 77 77 ?> -
program/include/rcube_template.php
rf3e1010 r2eb7943 6 6 | | 7 7 | This file is part of the RoundCube Webmail client | 8 | Copyright (C) 2006-20 09, RoundCube Dev. - Switzerland |8 | Copyright (C) 2006-2010, RoundCube Dev. - Switzerland | 9 9 | Licensed under the GNU GPL | 10 10 | | … … 537 537 538 538 /** 539 * 539 * Inserts hidden field with CSRF-prevention-token into POST forms 540 540 */ 541 541 private function alter_form_tag($matches) … … 1125 1125 } 1126 1126 if ($attrib['type'] == 'search' && !$this->browser->khtml) { 1127 unset($attrib['type'], $attrib['results']);1127 unset($attrib['type'], $attrib['results']); 1128 1128 } 1129 1129 … … 1139 1139 'onsubmit' => JS_OBJECT_NAME . ".command('search');return false;", 1140 1140 'style' => "display:inline"), 1141 $out);1141 $out); 1142 1142 } 1143 1143 … … 1216 1216 1217 1217 if (!empty($_POST['_charset'])) 1218 $set = $_POST['_charset'];1219 else if (!empty($attrib['selected']))1220 $set = $attrib['selected'];1221 else1222 $set = $this->get_charset();1223 1224 $set = strtoupper($set);1225 if (!isset($charsets[$set]))1226 $charsets[$set] = $set;1218 $set = $_POST['_charset']; 1219 else if (!empty($attrib['selected'])) 1220 $set = $attrib['selected']; 1221 else 1222 $set = $this->get_charset(); 1223 1224 $set = strtoupper($set); 1225 if (!isset($charsets[$set])) 1226 $charsets[$set] = $set; 1227 1227 1228 1228 $select = new html_select($field_attrib);
Note: See TracChangeset
for help on using the changeset viewer.
