summaryrefslogtreecommitdiff
path: root/program/include
diff options
context:
space:
mode:
Diffstat (limited to 'program/include')
-rw-r--r--program/include/bugs.inc101
-rwxr-xr-xprogram/include/iniset.php63
-rw-r--r--program/include/rcube_addressbook.php33
-rw-r--r--program/include/rcube_config.php486
-rw-r--r--program/include/rcube_html_page.php32
-rw-r--r--program/include/rcube_json_output.php35
-rw-r--r--program/include/rcube_result_set.php71
-rw-r--r--program/include/rcube_sqlite.inc66
-rwxr-xr-xprogram/include/rcube_template.php26
9 files changed, 455 insertions, 458 deletions
diff --git a/program/include/bugs.inc b/program/include/bugs.inc
index 8b926e0d6..cf5855e8e 100644
--- a/program/include/bugs.inc
+++ b/program/include/bugs.inc
@@ -5,7 +5,7 @@
| program/include/bugs.inc |
| |
| This file is part of the RoudCube Webmail client |
- | Copyright (C) 2005-2009, RoudCube Dev - Switzerland |
+ | Copyright (C) 2005-2010, RoudCube Dev - Switzerland |
| Licensed under the GNU GPL |
| |
| PURPOSE: |
@@ -40,22 +40,21 @@
* @param boolean Terminate script execution
*/
function raise_error($arg=array(), $log=false, $terminate=false)
- {
- global $__page_content, $CONFIG, $OUTPUT, $ERROR_CODE, $ERROR_MESSAGE;
+{
+ global $__page_content, $CONFIG, $OUTPUT, $ERROR_CODE, $ERROR_MESSAGE;
- // report bug (if not incompatible browser)
- if ($log && $arg['type'] && $arg['message'])
- log_bug($arg);
-
- // display error page and terminate script
- if ($terminate)
- {
- $ERROR_CODE = $arg['code'];
- $ERROR_MESSAGE = $arg['message'];
- include("program/steps/error.inc");
- exit;
+ // report bug (if not incompatible browser)
+ if ($log && $arg['type'] && $arg['message'])
+ log_bug($arg);
+
+ // display error page and terminate script
+ if ($terminate) {
+ $ERROR_CODE = $arg['code'];
+ $ERROR_MESSAGE = $arg['message'];
+ include("program/steps/error.inc");
+ exit;
}
- }
+}
/**
@@ -66,46 +65,42 @@ function raise_error($arg=array(), $log=false, $terminate=false)
*/
function log_bug($arg_arr)
{
- global $CONFIG;
- $program = strtoupper($arg_arr['type']);
-
- // write error to local log file
- if ($CONFIG['debug_level'] & 1)
- {
- $post_query = ($_SERVER['REQUEST_METHOD'] == 'POST' ? '?_task='.urlencode($_POST['_task']).'&_action='.urlencode($_POST['_action']) : '');
- $log_entry = sprintf("%s Error: %s%s (%s %s)",
- $program,
- $arg_arr['message'],
- $arg_arr['file'] ? sprintf(' in %s on line %d', $arg_arr['file'], $arg_arr['line']) : '',
- $_SERVER['REQUEST_METHOD'],
- $_SERVER['REQUEST_URI'] . $post_query);
+ global $CONFIG;
+ $program = strtoupper($arg_arr['type']);
+
+ // write error to local log file
+ if ($CONFIG['debug_level'] & 1) {
+ $post_query = ($_SERVER['REQUEST_METHOD'] == 'POST' ? '?_task='.urlencode($_POST['_task']).'&_action='.urlencode($_POST['_action']) : '');
+ $log_entry = sprintf("%s Error: %s%s (%s %s)",
+ $program,
+ $arg_arr['message'],
+ $arg_arr['file'] ? sprintf(' in %s on line %d', $arg_arr['file'], $arg_arr['line']) : '',
+ $_SERVER['REQUEST_METHOD'],
+ $_SERVER['REQUEST_URI'] . $post_query);
- if (!write_log('errors', $log_entry))
- {
- // send error to PHPs error handler if write_log didn't succeed
- trigger_error($arg_arr['message']);
+ if (!write_log('errors', $log_entry)) {
+ // send error to PHPs error handler if write_log didn't succeed
+ trigger_error($arg_arr['message']);
+ }
+ }
+
+ // resport the bug to the global bug reporting system
+ if ($CONFIG['debug_level'] & 2) {
+ // TODO: Send error via HTTP
+ }
+
+ // show error if debug_mode is on
+ if ($CONFIG['debug_level'] & 4) {
+ print "<b>$program Error";
+
+ if (!empty($arg_arr['file']) && !empty($arg_arr['line']))
+ print " in $arg_arr[file] ($arg_arr[line])";
+
+ print ':</b>&nbsp;';
+ print nl2br($arg_arr['message']);
+ print '<br />';
+ flush();
}
- }
-
- // resport the bug to the global bug reporting system
- if ($CONFIG['debug_level'] & 2)
- {
- // TODO: Send error via HTTP
- }
-
- // show error if debug_mode is on
- if ($CONFIG['debug_level'] & 4)
- {
- print "<b>$program Error";
-
- if (!empty($arg_arr['file']) && !empty($arg_arr['line']))
- print " in $arg_arr[file] ($arg_arr[line])";
-
- print ":</b>&nbsp;";
- print nl2br($arg_arr['message']);
- print '<br />';
- flush();
- }
}
?>
diff --git a/program/include/iniset.php b/program/include/iniset.php
index 5f7c59d1f..29b2cce87 100755
--- a/program/include/iniset.php
+++ b/program/include/iniset.php
@@ -42,14 +42,14 @@ define('JS_OBJECT_NAME', 'rcmail');
define('RCMAIL_START', microtime(true));
if (!defined('INSTALL_PATH')) {
- define('INSTALL_PATH', dirname($_SERVER['SCRIPT_FILENAME']).'/');
+ define('INSTALL_PATH', dirname($_SERVER['SCRIPT_FILENAME']).'/');
}
define('RCMAIL_CONFIG_DIR', INSTALL_PATH . 'config');
// make sure path_separator is defined
if (!defined('PATH_SEPARATOR')) {
- define('PATH_SEPARATOR', (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN') ? ';' : ':');
+ define('PATH_SEPARATOR', (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN') ? ';' : ':');
}
// RC include folders MUST be included FIRST to avoid other
@@ -62,7 +62,7 @@ $include_path.= INSTALL_PATH . 'program/include' . PATH_SEPARATOR;
$include_path.= ini_get('include_path');
if (set_include_path($include_path) === false) {
- die('Fatal error: ini_set/set_include_path does not work.');
+ die('Fatal error: ini_set/set_include_path does not work.');
}
ini_set('error_reporting', E_ALL&~E_NOTICE);
@@ -73,7 +73,7 @@ ini_set('error_reporting', E_ALL&~E_NOTICE);
// set internal encoding for mbstring extension
if(extension_loaded('mbstring'))
- mb_internal_encoding(RCMAIL_CHARSET);
+ mb_internal_encoding(RCMAIL_CHARSET);
/**
@@ -84,26 +84,26 @@ if(extension_loaded('mbstring'))
*/
function rcube_autoload($classname)
{
- $filename = preg_replace(
- array(
- '/MDB2_(.+)/',
- '/Mail_(.+)/',
- '/Net_(.+)/',
- '/^html_.+/',
- '/^utf8$/',
- '/html2text/'
- ),
- array(
- 'MDB2/\\1',
- 'Mail/\\1',
- 'Net/\\1',
- 'html',
- 'utf8.class',
- 'lib/html2text' // see #1485505
- ),
- $classname
- );
- include $filename. '.php';
+ $filename = preg_replace(
+ array(
+ '/MDB2_(.+)/',
+ '/Mail_(.+)/',
+ '/Net_(.+)/',
+ '/^html_.+/',
+ '/^utf8$/',
+ '/html2text/'
+ ),
+ array(
+ 'MDB2/\\1',
+ 'Mail/\\1',
+ 'Net/\\1',
+ 'html',
+ 'utf8.class',
+ 'lib/html2text' // see #1485505
+ ),
+ $classname
+ );
+ include $filename. '.php';
}
spl_autoload_register('rcube_autoload');
@@ -113,17 +113,16 @@ spl_autoload_register('rcube_autoload');
*/
function rcube_pear_error($err)
{
- error_log(sprintf("%s (%s): %s",
- $err->getMessage(),
- $err->getCode(),
- $err->getUserinfo()), 0);
+ error_log(sprintf("%s (%s): %s",
+ $err->getMessage(),
+ $err->getCode(),
+ $err->getUserinfo()), 0);
}
+// set PEAR error handling (will also load the PEAR main class)
+PEAR::setErrorHandling(PEAR_ERROR_CALLBACK, 'rcube_pear_error');
+
// include global functions
require_once 'include/bugs.inc';
require_once 'include/main.inc';
require_once 'include/rcube_shared.inc';
-
-
-// set PEAR error handling (will also load the PEAR main class)
-PEAR::setErrorHandling(PEAR_ERROR_CALLBACK, 'rcube_pear_error');
diff --git a/program/include/rcube_addressbook.php b/program/include/rcube_addressbook.php
index b9f9f29ed..790c8c80a 100644
--- a/program/include/rcube_addressbook.php
+++ b/program/include/rcube_addressbook.php
@@ -117,7 +117,7 @@ abstract class rcube_addressbook
*/
function set_page($page)
{
- $this->list_page = (int)$page;
+ $this->list_page = (int)$page;
}
/**
@@ -128,7 +128,7 @@ abstract class rcube_addressbook
*/
function set_pagesize($size)
{
- $this->page_size = (int)$size;
+ $this->page_size = (int)$size;
}
/**
@@ -146,7 +146,7 @@ abstract class rcube_addressbook
*/
function insert($save_data, $check=false)
{
- /* empty for read-only address books */
+ /* empty for read-only address books */
}
/**
@@ -158,7 +158,7 @@ abstract class rcube_addressbook
*/
function update($id, $save_cols)
{
- /* empty for read-only address books */
+ /* empty for read-only address books */
}
/**
@@ -168,7 +168,7 @@ abstract class rcube_addressbook
*/
function delete($ids)
{
- /* empty for read-only address books */
+ /* empty for read-only address books */
}
/**
@@ -176,7 +176,7 @@ abstract class rcube_addressbook
*/
function delete_all()
{
- /* empty for read-only address books */
+ /* empty for read-only address books */
}
/**
@@ -187,8 +187,8 @@ abstract class rcube_addressbook
*/
function create_group($name)
{
- /* empty for address books don't supporting groups */
- return false;
+ /* empty for address books don't supporting groups */
+ return false;
}
/**
@@ -199,8 +199,8 @@ abstract class rcube_addressbook
*/
function delete_group($gid)
{
- /* empty for address books don't supporting groups */
- return false;
+ /* empty for address books don't supporting groups */
+ return false;
}
/**
@@ -212,8 +212,8 @@ abstract class rcube_addressbook
*/
function rename_group($gid, $newname)
{
- /* empty for address books don't supporting groups */
- return false;
+ /* empty for address books don't supporting groups */
+ return false;
}
/**
@@ -225,8 +225,8 @@ abstract class rcube_addressbook
*/
function add_to_group($group_id, $ids)
{
- /* empty for address books don't supporting groups */
- return 0;
+ /* empty for address books don't supporting groups */
+ return 0;
}
/**
@@ -238,8 +238,7 @@ abstract class rcube_addressbook
*/
function remove_from_group($group_id, $ids)
{
- /* empty for address books don't supporting groups */
- return 0;
+ /* empty for address books don't supporting groups */
+ return 0;
}
}
- \ No newline at end of file
diff --git a/program/include/rcube_config.php b/program/include/rcube_config.php
index 1e2aae33a..bd53517c1 100644
--- a/program/include/rcube_config.php
+++ b/program/include/rcube_config.php
@@ -5,7 +5,7 @@
| program/include/rcube_config.php |
| |
| This file is part of the RoundCube Webmail client |
- | Copyright (C) 2008-2009, RoundCube Dev. - Switzerland |
+ | Copyright (C) 2008-2010, RoundCube Dev. - Switzerland |
| Licensed under the GNU GPL |
| |
| PURPOSE: |
@@ -26,271 +26,271 @@
*/
class rcube_config
{
- private $prop = array();
- private $errors = array();
- private $userprefs = array();
-
-
- /**
- * Object constructor
- */
- public function __construct()
- {
- $this->load();
- }
-
-
- /**
- * Load config from local config file
- *
- * @todo Remove global $CONFIG
- */
- private function load()
- {
- // start output buffering, we don't need any output yet,
- // it'll be cleared after reading of config files, etc.
- ob_start();
+ private $prop = array();
+ private $errors = array();
+ private $userprefs = array();
+
+
+ /**
+ * Object constructor
+ */
+ public function __construct()
+ {
+ $this->load();
+ }
+
+
+ /**
+ * Load config from local config file
+ *
+ * @todo Remove global $CONFIG
+ */
+ private function load()
+ {
+ // start output buffering, we don't need any output yet,
+ // it'll be cleared after reading of config files, etc.
+ ob_start();
- // load main config file
- if (!$this->load_from_file(RCMAIL_CONFIG_DIR . '/main.inc.php'))
- $this->errors[] = 'main.inc.php was not found.';
+ // load main config file
+ if (!$this->load_from_file(RCMAIL_CONFIG_DIR . '/main.inc.php'))
+ $this->errors[] = 'main.inc.php was not found.';
- // load database config
- if (!$this->load_from_file(RCMAIL_CONFIG_DIR . '/db.inc.php'))
- $this->errors[] = 'db.inc.php was not found.';
+ // load database config
+ if (!$this->load_from_file(RCMAIL_CONFIG_DIR . '/db.inc.php'))
+ $this->errors[] = 'db.inc.php was not found.';
- // load host-specific configuration
- $this->load_host_config();
-
- // set skin (with fallback to old 'skin_path' property)
- if (empty($this->prop['skin']) && !empty($this->prop['skin_path']))
- $this->prop['skin'] = str_replace('skins/', '', unslashify($this->prop['skin_path']));
- else if (empty($this->prop['skin']))
- $this->prop['skin'] = 'default';
-
- // fix paths
- $this->prop['log_dir'] = $this->prop['log_dir'] ? realpath(unslashify($this->prop['log_dir'])) : INSTALL_PATH . 'logs';
- $this->prop['temp_dir'] = $this->prop['temp_dir'] ? realpath(unslashify($this->prop['temp_dir'])) : INSTALL_PATH . 'temp';
+ // load host-specific configuration
+ $this->load_host_config();
+
+ // set skin (with fallback to old 'skin_path' property)
+ if (empty($this->prop['skin']) && !empty($this->prop['skin_path']))
+ $this->prop['skin'] = str_replace('skins/', '', unslashify($this->prop['skin_path']));
+ else if (empty($this->prop['skin']))
+ $this->prop['skin'] = 'default';
+
+ // fix paths
+ $this->prop['log_dir'] = $this->prop['log_dir'] ? realpath(unslashify($this->prop['log_dir'])) : INSTALL_PATH . 'logs';
+ $this->prop['temp_dir'] = $this->prop['temp_dir'] ? realpath(unslashify($this->prop['temp_dir'])) : INSTALL_PATH . 'temp';
- // fix default imap folders encoding
- foreach (array('drafts_mbox', 'junk_mbox', 'sent_mbox', 'trash_mbox') as $folder)
- $this->prop[$folder] = rcube_charset_convert($this->prop[$folder], RCMAIL_CHARSET, 'UTF7-IMAP');
-
- if (!empty($this->prop['default_imap_folders']))
- foreach ($this->prop['default_imap_folders'] as $n => $folder)
- $this->prop['default_imap_folders'][$n] = rcube_charset_convert($folder, RCMAIL_CHARSET, 'UTF7-IMAP');
-
- // set PHP error logging according to config
- if ($this->prop['debug_level'] & 1) {
- ini_set('log_errors', 1);
-
- if ($this->prop['log_driver'] == 'syslog') {
- ini_set('error_log', 'syslog');
- } else {
- ini_set('error_log', $this->prop['log_dir'].'/errors');
- }
+ // fix default imap folders encoding
+ foreach (array('drafts_mbox', 'junk_mbox', 'sent_mbox', 'trash_mbox') as $folder)
+ $this->prop[$folder] = rcube_charset_convert($this->prop[$folder], RCMAIL_CHARSET, 'UTF7-IMAP');
+
+ if (!empty($this->prop['default_imap_folders']))
+ foreach ($this->prop['default_imap_folders'] as $n => $folder)
+ $this->prop['default_imap_folders'][$n] = rcube_charset_convert($folder, RCMAIL_CHARSET, 'UTF7-IMAP');
+
+ // set PHP error logging according to config
+ if ($this->prop['debug_level'] & 1) {
+ ini_set('log_errors', 1);
+
+ if ($this->prop['log_driver'] == 'syslog') {
+ ini_set('error_log', 'syslog');
+ }
+ else {
+ ini_set('error_log', $this->prop['log_dir'].'/errors');
+ }
+ }
+ if ($this->prop['debug_level'] & 4) {
+ ini_set('display_errors', 1);
+ }
+ else {
+ ini_set('display_errors', 0);
+ }
+
+ // clear output buffer
+ ob_end_clean();
+
+ // export config data
+ $GLOBALS['CONFIG'] = &$this->prop;
}
- if ($this->prop['debug_level'] & 4) {
- ini_set('display_errors', 1);
+
+ /**
+ * Load a host-specific config file if configured
+ * This will merge the host specific configuration with the given one
+ */
+ private function load_host_config()
+ {
+ $fname = null;
+
+ if (is_array($this->prop['include_host_config'])) {
+ $fname = $this->prop['include_host_config'][$_SERVER['HTTP_HOST']];
+ }
+ else if (!empty($this->prop['include_host_config'])) {
+ $fname = preg_replace('/[^a-z0-9\.\-_]/i', '', $_SERVER['HTTP_HOST']) . '.inc.php';
+ }
+
+ if ($fname) {
+ $this->load_from_file(RCMAIL_CONFIG_DIR . '/' . $fname);
+ }
}
- else {
- ini_set('display_errors', 0);
+
+
+ /**
+ * Read configuration from a file
+ * and merge with the already stored config values
+ *
+ * @param string Full path to the config file to be loaded
+ * @return booelan True on success, false on failure
+ */
+ public function load_from_file($fpath)
+ {
+ if (is_file($fpath) && is_readable($fpath)) {
+ include($fpath);
+ if (is_array($rcmail_config)) {
+ $this->prop = array_merge($this->prop, $rcmail_config, $this->userprefs);
+ return true;
+ }
+ }
+
+ return false;
}
-
- // clear output buffer
- ob_end_clean();
- // export config data
- $GLOBALS['CONFIG'] = &$this->prop;
- }
-
-
- /**
- * Load a host-specific config file if configured
- * This will merge the host specific configuration with the given one
- */
- private function load_host_config()
- {
- $fname = null;
-
- if (is_array($this->prop['include_host_config'])) {
- $fname = $this->prop['include_host_config'][$_SERVER['HTTP_HOST']];
+
+ /**
+ * Getter for a specific config parameter
+ *
+ * @param string Parameter name
+ * @param mixed Default value if not set
+ * @return mixed The requested config value
+ */
+ public function get($name, $def = null)
+ {
+ return isset($this->prop[$name]) ? $this->prop[$name] : $def;
}
- else if (!empty($this->prop['include_host_config'])) {
- $fname = preg_replace('/[^a-z0-9\.\-_]/i', '', $_SERVER['HTTP_HOST']) . '.inc.php';
+
+
+ /**
+ * Setter for a config parameter
+ *
+ * @param string Parameter name
+ * @param mixed Parameter value
+ */
+ public function set($name, $value)
+ {
+ $this->prop[$name] = $value;
}
- if ($fname) {
- $this->load_from_file(RCMAIL_CONFIG_DIR . '/' . $fname);
+
+ /**
+ * Override config options with the given values (eg. user prefs)
+ *
+ * @param array Hash array with config props to merge over
+ */
+ public function merge($prefs)
+ {
+ $this->prop = array_merge($this->prop, $prefs, $this->userprefs);
}
- }
-
-
- /**
- * Read configuration from a file
- * and merge with the already stored config values
- *
- * @param string Full path to the config file to be loaded
- * @return booelan True on success, false on failure
- */
- public function load_from_file($fpath)
- {
- if (is_file($fpath) && is_readable($fpath)) {
- include($fpath);
- if (is_array($rcmail_config)) {
- $this->prop = array_merge($this->prop, $rcmail_config, $this->userprefs);
- return true;
- }
+
+
+ /**
+ * Merge the given prefs over the current config
+ * and make sure that they survive further merging.
+ *
+ * @param array Hash array with user prefs
+ */
+ public function set_user_prefs($prefs)
+ {
+ $this->userprefs = $prefs;
+ $this->prop = array_merge($this->prop, $prefs);
}
-
- return false;
- }
-
-
- /**
- * Getter for a specific config parameter
- *
- * @param string Parameter name
- * @param mixed Default value if not set
- * @return mixed The requested config value
- */
- public function get($name, $def = null)
- {
- return isset($this->prop[$name]) ? $this->prop[$name] : $def;
- }
-
-
- /**
- * Setter for a config parameter
- *
- * @param string Parameter name
- * @param mixed Parameter value
- */
- public function set($name, $value)
- {
- $this->prop[$name] = $value;
- }
-
-
- /**
- * Override config options with the given values (eg. user prefs)
- *
- * @param array Hash array with config props to merge over
- */
- public function merge($prefs)
- {
- $this->prop = array_merge($this->prop, $prefs, $this->userprefs);
- }
-
-
- /**
- * Merge the given prefs over the current config
- * and make sure that they survive further merging.
- *
- * @param array Hash array with user prefs
- */
- public function set_user_prefs($prefs)
- {
- $this->userprefs = $prefs;
- $this->prop = array_merge($this->prop, $prefs);
- }
-
- /**
- * Getter for all config options
- *
- * @return array Hash array containg all config properties
- */
- public function all()
- {
- return $this->prop;
- }
-
-
- /**
- * Return requested DES crypto key.
- *
- * @param string Crypto key name
- * @return string Crypto key
- */
- public function get_crypto_key($key)
- {
- // Bomb out if the requested key does not exist
- if (!array_key_exists($key, $this->prop))
+
+ /**
+ * Getter for all config options
+ *
+ * @return array Hash array containg all config properties
+ */
+ public function all()
{
- raise_error(array(
- 'code' => 500, 'type' => 'php',
- 'file' => __FILE__, 'line' => __LINE__,
- 'message' => "Request for unconfigured crypto key \"$key\""
- ), true, true);
+ return $this->prop;
}
-
- $key = $this->prop[$key];
-
- // Bomb out if the configured key is not exactly 24 bytes long
- if (strlen($key) != 24)
+
+
+ /**
+ * Return requested DES crypto key.
+ *
+ * @param string Crypto key name
+ * @return string Crypto key
+ */
+ public function get_crypto_key($key)
{
- raise_error(array(
- 'code' => 500, 'type' => 'php',
- 'file' => __FILE__, 'line' => __LINE__,
- 'message' => "Configured crypto key \"$key\" is not exactly 24 bytes long"
- ), true, true);
+ // Bomb out if the requested key does not exist
+ if (!array_key_exists($key, $this->prop)) {
+ raise_error(array(
+ 'code' => 500, 'type' => 'php',
+ 'file' => __FILE__, 'line' => __LINE__,
+ 'message' => "Request for unconfigured crypto key \"$key\""
+ ), true, true);
+ }
+
+ $key = $this->prop[$key];
+
+ // Bomb out if the configured key is not exactly 24 bytes long
+ if (strlen($key) != 24) {
+ raise_error(array(
+ 'code' => 500, 'type' => 'php',
+ 'file' => __FILE__, 'line' => __LINE__,
+ 'message' => "Configured crypto key '$key' is not exactly 24 bytes long"
+ ), true, true);
+ }
+
+ return $key;
}
- return $key;
- }
-
-
- /**
- * Try to autodetect operating system and find the correct line endings
- *
- * @return string The appropriate mail header delimiter
- */
- public function header_delimiter()
- {
- // use the configured delimiter for headers
- if (!empty($this->prop['mail_header_delimiter']))
- return $this->prop['mail_header_delimiter'];
- else if (strtolower(substr(PHP_OS, 0, 3)) == 'win')
- return "\r\n";
- else if (strtolower(substr(PHP_OS, 0, 3)) == 'mac')
- return "\r\n";
- else
- return "\n";
- }
-
- /**
- * Return the mail domain configured for the given host
- *
- * @param string IMAP host
- * @return string Resolved SMTP host
- */
- public function mail_domain($host)
- {
- $domain = $host;
-
- if (is_array($this->prop['mail_domain'])) {
- if (isset($this->prop['mail_domain'][$host]))
- $domain = $this->prop['mail_domain'][$host];
+ /**
+ * Try to autodetect operating system and find the correct line endings
+ *
+ * @return string The appropriate mail header delimiter
+ */
+ public function header_delimiter()
+ {
+ // use the configured delimiter for headers
+ if (!empty($this->prop['mail_header_delimiter']))
+ return $this->prop['mail_header_delimiter'];
+
+ $php_os = strtolower(substr(PHP_OS, 0, 3));
+
+ if ($php_os == 'win')
+ return "\r\n";
+
+ if ($php_os == 'mac')
+ return "\r\n";
+
+ return "\n";
}
- else if (!empty($this->prop['mail_domain']))
- $domain = $this->prop['mail_domain'];
+
+
+ /**
+ * Return the mail domain configured for the given host
+ *
+ * @param string IMAP host
+ * @return string Resolved SMTP host
+ */
+ public function mail_domain($host)
+ {
+ $domain = $host;
+
+ if (is_array($this->prop['mail_domain'])) {
+ if (isset($this->prop['mail_domain'][$host]))
+ $domain = $this->prop['mail_domain'][$host];
+ }
+ else if (!empty($this->prop['mail_domain']))
+ $domain = $this->prop['mail_domain'];
- return $domain;
- }
+ return $domain;
+ }
- /**
- * Getter for error state
- *
- * @return mixed Error message on error, False if no errors
- */
- public function get_error()
- {
- return empty($this->errors) ? false : join("\n", $this->errors);
- }
-
+ /**
+ * Getter for error state
+ *
+ * @return mixed Error message on error, False if no errors
+ */
+ public function get_error()
+ {
+ return empty($this->errors) ? false : join("\n", $this->errors);
+ }
}
-
diff --git a/program/include/rcube_html_page.php b/program/include/rcube_html_page.php
index 628104324..0395f6f35 100644
--- a/program/include/rcube_html_page.php
+++ b/program/include/rcube_html_page.php
@@ -56,7 +56,7 @@ class rcube_html_page
static $sa_files = array();
if (!preg_match('|^https?://|i', $file) && $file[0] != '/')
- $file = $this->scripts_path . $file . (($fs = @filemtime($this->scripts_path . $file)) ? '?s='.$fs : '');
+ $file = $this->scripts_path . $file . (($fs = @filemtime($this->scripts_path . $file)) ? '?s='.$fs : '');
if (in_array($file, $sa_files)) {
return;
@@ -130,11 +130,11 @@ class rcube_html_page
public function reset()
{
$this->script_files = array();
- $this->scripts = array();
- $this->title = '';
- $this->header = '';
- $this->footer = '';
- $this->body = '';
+ $this->scripts = array();
+ $this->title = '';
+ $this->header = '';
+ $this->footer = '';
+ $this->body = '';
}
/**
@@ -248,17 +248,17 @@ class rcube_html_page
// reset those global vars
$__page_header = $__page_footer = '';
- $this->base_path = $base_path;
+ $this->base_path = $base_path;
// correct absolute paths in images and other tags
- // add timestamp to .js and .css filename
+ // add timestamp to .js and .css filename
$output = preg_replace_callback('!(src|href|background)=(["\']?)([a-z0-9/_.-]+)(["\'\s>])!i',
array($this, 'file_callback'), $output);
$output = str_replace('$__skin_path', $base_path, $output);
if ($this->charset != RCMAIL_CHARSET)
- echo rcube_charset_convert($output, RCMAIL_CHARSET, $this->charset);
- else
- echo $output;
+ echo rcube_charset_convert($output, RCMAIL_CHARSET, $this->charset);
+ else
+ echo $output;
}
/**
@@ -266,17 +266,17 @@ class rcube_html_page
*/
private function file_callback($matches)
{
- $file = $matches[3];
+ $file = $matches[3];
// correct absolute paths
- if ($file[0] == '/')
- $file = $this->base_path . $file;
+ if ($file[0] == '/')
+ $file = $this->base_path . $file;
// add file modification timestamp
- if (preg_match('/\.(js|css)$/', $file))
+ if (preg_match('/\.(js|css)$/', $file))
$file .= '?s=' . @filemtime($file);
- return sprintf("%s=%s%s%s", $matches[1], $matches[2], $file, $matches[4]);
+ return sprintf("%s=%s%s%s", $matches[1], $matches[2], $file, $matches[4]);
}
}
diff --git a/program/include/rcube_json_output.php b/program/include/rcube_json_output.php
index 399de1efe..31eaa87a8 100644
--- a/program/include/rcube_json_output.php
+++ b/program/include/rcube_json_output.php
@@ -5,7 +5,7 @@
| program/include/rcube_json_output.php |
| |
| This file is part of the RoundCube Webmail client |
- | Copyright (C) 2008-2009, RoundCube Dev. - Switzerland |
+ | Copyright (C) 2008-2010, RoundCube Dev. - Switzerland |
| Licensed under the GNU GPL |
| |
| PURPOSE: |
@@ -47,8 +47,8 @@ class rcube_json_output
{
$this->config = rcmail::get_instance()->config;
}
-
-
+
+
/**
* Set environment variable
*
@@ -59,7 +59,8 @@ class rcube_json_output
{
$this->env[$name] = $value;
}
-
+
+
/**
* Issue command to set page title
*
@@ -71,6 +72,7 @@ class rcube_json_output
$this->command('set_pagetitle', empty($name) ? $title : $name.' :: '.$title);
}
+
/**
* @ignore
*/
@@ -103,6 +105,7 @@ class rcube_json_output
// ignore
}
+
/**
* Register a list of template object handlers
*
@@ -113,8 +116,8 @@ class rcube_json_output
{
// ignore
}
-
-
+
+
/**
* Call a client method
*
@@ -145,7 +148,7 @@ class rcube_json_output
$this->texts[$name] = rcube_label($name);
}
}
-
+
/**
* Invoke display_message command
@@ -167,7 +170,8 @@ class rcube_json_output
);
}
}
-
+
+
/**
* Delete all stored env variables and commands
*/
@@ -177,7 +181,8 @@ class rcube_json_output
$this->texts = array();
$this->commands = array();
}
-
+
+
/**
* Redirect to a certain url
*
@@ -227,21 +232,21 @@ class rcube_json_output
$response = array('action' => $rcmail->action, 'unlock' => (bool)$_REQUEST['_unlock']);
if (!empty($this->env))
- $response['env'] = $this->env;
+ $response['env'] = $this->env;
if (!empty($this->texts))
- $response['texts'] = $this->texts;
+ $response['texts'] = $this->texts;
// send function calls
$response['exec'] = $this->get_js_commands() . $add;
if (!empty($this->callbacks))
- $response['callbacks'] = $this->callbacks;
+ $response['callbacks'] = $this->callbacks;
echo json_serialize($response);
}
-
-
+
+
/**
* Return executable javascript code for all registered commands
*
@@ -267,5 +272,3 @@ class rcube_json_output
return $out;
}
}
-
-
diff --git a/program/include/rcube_result_set.php b/program/include/rcube_result_set.php
index 7255776eb..499fb6ac2 100644
--- a/program/include/rcube_result_set.php
+++ b/program/include/rcube_result_set.php
@@ -5,7 +5,7 @@
| program/include/rcube_result_set.php |
| |
| This file is part of the RoundCube Webmail client |
- | Copyright (C) 2006-2009, RoundCube Dev. - Switzerland |
+ | Copyright (C) 2006-2010, RoundCube Dev. - Switzerland |
| Licensed under the GNU GPL |
| |
| PURPOSE: |
@@ -28,42 +28,43 @@
*/
class rcube_result_set
{
- var $count = 0;
- var $first = 0;
- var $current = 0;
- var $records = array();
-
- function __construct($c=0, $f=0)
- {
- $this->count = (int)$c;
- $this->first = (int)$f;
- }
-
- function add($rec)
- {
- $this->records[] = $rec;
- }
+ var $count = 0;
+ var $first = 0;
+ var $current = 0;
+ var $records = array();
+
+
+ function __construct($c=0, $f=0)
+ {
+ $this->count = (int)$c;
+ $this->first = (int)$f;
+ }
+
+ function add($rec)
+ {
+ $this->records[] = $rec;
+ }
- function iterate()
- {
- return $this->records[$this->current++];
- }
+ function iterate()
+ {
+ return $this->records[$this->current++];
+ }
- function first()
- {
- $this->current = 0;
- return $this->records[$this->current++];
- }
+ function first()
+ {
+ $this->current = 0;
+ return $this->records[$this->current++];
+ }
- // alias
- function next()
- {
- return $this->iterate();
- }
+ // alias for iterate()
+ function next()
+ {
+ return $this->iterate();
+ }
- function seek($i)
- {
- $this->current = $i;
- }
+ function seek($i)
+ {
+ $this->current = $i;
+ }
-} \ No newline at end of file
+}
diff --git a/program/include/rcube_sqlite.inc b/program/include/rcube_sqlite.inc
index 7cb5dc2f1..cc8086518 100644
--- a/program/include/rcube_sqlite.inc
+++ b/program/include/rcube_sqlite.inc
@@ -5,7 +5,7 @@
| program/include/rcube_sqlite.inc |
| |
| This file is part of the RoundCube Webmail client |
- | Copyright (C) 2005-2007, RoundCube Dev. - Switzerland |
+ | Copyright (C) 2005-2010, RoundCube Dev. - Switzerland |
| Licensed under the GNU GPL |
| |
| PURPOSE: |
@@ -28,50 +28,50 @@
function rcube_sqlite_from_unixtime($timestamp)
- {
- $timestamp = trim($timestamp);
- if (!preg_match("/^[0-9]+$/is", $timestamp))
- $ret = strtotime($timestamp);
- else
- $ret = $timestamp;
+{
+ $timestamp = trim($timestamp);
+ if (!preg_match('/^[0-9]+$/is', $timestamp))
+ $ret = strtotime($timestamp);
+ else
+ $ret = $timestamp;
- $ret = date("Y-m-d H:i:s", $ret);
- rcube_sqlite_debug("FROM_UNIXTIME ($timestamp) = $ret");
- return $ret;
- }
+ $ret = date('Y-m-d H:i:s', $ret);
+ rcube_sqlite_debug("FROM_UNIXTIME ($timestamp) = $ret");
+ return $ret;
+}
-function rcube_sqlite_unix_timestamp($timestamp="")
- {
- $timestamp = trim($timestamp);
- if (!$timestamp)
- $ret = time();
- else if (!preg_match("/^[0-9]+$/is", $timestamp))
- $ret = strtotime($timestamp);
- else
- $ret = $timestamp;
+function rcube_sqlite_unix_timestamp($timestamp='')
+{
+ $timestamp = trim($timestamp);
+ if (!$timestamp)
+ $ret = time();
+ else if (!preg_match('/^[0-9]+$/is', $timestamp))
+ $ret = strtotime($timestamp);
+ else
+ $ret = $timestamp;
- rcube_sqlite_debug("UNIX_TIMESTAMP ($timestamp) = $ret");
- return $ret;
- }
+ rcube_sqlite_debug("UNIX_TIMESTAMP ($timestamp) = $ret");
+ return $ret;
+}
function rcube_sqlite_now()
- {
- rcube_sqlite_debug("NOW() = ".date("Y-m-d H:i:s"));
- return date("Y-m-d H:i:s");
- }
+{
+ rcube_sqlite_debug("NOW() = ".date("Y-m-d H:i:s"));
+ return date("Y-m-d H:i:s");
+}
function rcube_sqlite_md5($str)
- {
- return md5($str);
- }
+{
+ return md5($str);
+}
function rcube_sqlite_debug($str)
- {
- //console($str);
- }
+{
+ //console($str);
+}
?>
diff --git a/program/include/rcube_template.php b/program/include/rcube_template.php
index 8b8f7a981..2f1740dc9 100755
--- a/program/include/rcube_template.php
+++ b/program/include/rcube_template.php
@@ -5,7 +5,7 @@
| program/include/rcube_template.php |
| |
| This file is part of the RoundCube Webmail client |
- | Copyright (C) 2006-2009, RoundCube Dev. - Switzerland |
+ | Copyright (C) 2006-2010, RoundCube Dev. - Switzerland |
| Licensed under the GNU GPL |
| |
| PURPOSE: |
@@ -536,7 +536,7 @@ class rcube_template extends rcube_html_page
/**
- *
+ * Inserts hidden field with CSRF-prevention-token into POST forms
*/
private function alter_form_tag($matches)
{
@@ -1124,7 +1124,7 @@ class rcube_template extends rcube_html_page
$attrib['id'] = 'rcmqsearchbox';
}
if ($attrib['type'] == 'search' && !$this->browser->khtml) {
- unset($attrib['type'], $attrib['results']);
+ unset($attrib['type'], $attrib['results']);
}
$input_q = new html_inputfield($attrib);
@@ -1138,7 +1138,7 @@ class rcube_template extends rcube_html_page
'name' => "rcmqsearchform",
'onsubmit' => JS_OBJECT_NAME . ".command('search');return false;",
'style' => "display:inline"),
- $out);
+ $out);
}
return $out;
@@ -1215,15 +1215,15 @@ class rcube_template extends rcube_html_page
);
if (!empty($_POST['_charset']))
- $set = $_POST['_charset'];
- else if (!empty($attrib['selected']))
- $set = $attrib['selected'];
- else
- $set = $this->get_charset();
-
- $set = strtoupper($set);
- if (!isset($charsets[$set]))
- $charsets[$set] = $set;
+ $set = $_POST['_charset'];
+ else if (!empty($attrib['selected']))
+ $set = $attrib['selected'];
+ else
+ $set = $this->get_charset();
+
+ $set = strtoupper($set);
+ if (!isset($charsets[$set]))
+ $charsets[$set] = $set;
$select = new html_select($field_attrib);
$select->add(array_values($charsets), array_keys($charsets));