- code cleanup (mostly identation fixes)

release-0.6
alecpl 14 years ago
parent 6319670243
commit 2eb7943f2a

@ -5,7 +5,7 @@
| program/include/bugs.inc | | program/include/bugs.inc |
| | | |
| This file is part of the RoudCube Webmail client | | 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 | | Licensed under the GNU GPL |
| | | |
| PURPOSE: | | PURPOSE: |
@ -40,22 +40,21 @@
* @param boolean Terminate script execution * @param boolean Terminate script execution
*/ */
function raise_error($arg=array(), $log=false, $terminate=false) 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) // report bug (if not incompatible browser)
if ($log && $arg['type'] && $arg['message']) if ($log && $arg['type'] && $arg['message'])
log_bug($arg); log_bug($arg);
// display error page and terminate script // display error page and terminate script
if ($terminate) if ($terminate) {
{ $ERROR_CODE = $arg['code'];
$ERROR_CODE = $arg['code']; $ERROR_MESSAGE = $arg['message'];
$ERROR_MESSAGE = $arg['message']; include("program/steps/error.inc");
include("program/steps/error.inc"); exit;
exit;
} }
} }
/** /**
@ -66,46 +65,42 @@ function raise_error($arg=array(), $log=false, $terminate=false)
*/ */
function log_bug($arg_arr) function log_bug($arg_arr)
{ {
global $CONFIG; global $CONFIG;
$program = strtoupper($arg_arr['type']); $program = strtoupper($arg_arr['type']);
// write error to local log file // write error to local log file
if ($CONFIG['debug_level'] & 1) if ($CONFIG['debug_level'] & 1) {
{ $post_query = ($_SERVER['REQUEST_METHOD'] == 'POST' ? '?_task='.urlencode($_POST['_task']).'&_action='.urlencode($_POST['_action']) : '');
$post_query = ($_SERVER['REQUEST_METHOD'] == 'POST' ? '?_task='.urlencode($_POST['_task']).'&_action='.urlencode($_POST['_action']) : ''); $log_entry = sprintf("%s Error: %s%s (%s %s)",
$log_entry = sprintf("%s Error: %s%s (%s %s)", $program,
$program, $arg_arr['message'],
$arg_arr['message'], $arg_arr['file'] ? sprintf(' in %s on line %d', $arg_arr['file'], $arg_arr['line']) : '',
$arg_arr['file'] ? sprintf(' in %s on line %d', $arg_arr['file'], $arg_arr['line']) : '', $_SERVER['REQUEST_METHOD'],
$_SERVER['REQUEST_METHOD'], $_SERVER['REQUEST_URI'] . $post_query);
$_SERVER['REQUEST_URI'] . $post_query);
if (!write_log('errors', $log_entry)) if (!write_log('errors', $log_entry)) {
{ // send error to PHPs error handler if write_log didn't succeed
// send error to PHPs error handler if write_log didn't succeed trigger_error($arg_arr['message']);
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();
}
} }
?> ?>

@ -42,14 +42,14 @@ define('JS_OBJECT_NAME', 'rcmail');
define('RCMAIL_START', microtime(true)); define('RCMAIL_START', microtime(true));
if (!defined('INSTALL_PATH')) { 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'); define('RCMAIL_CONFIG_DIR', INSTALL_PATH . 'config');
// make sure path_separator is defined // make sure path_separator is defined
if (!defined('PATH_SEPARATOR')) { 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 // 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'); $include_path.= ini_get('include_path');
if (set_include_path($include_path) === false) { 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); 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 // set internal encoding for mbstring extension
if(extension_loaded('mbstring')) 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) function rcube_autoload($classname)
{ {
$filename = preg_replace( $filename = preg_replace(
array( array(
'/MDB2_(.+)/', '/MDB2_(.+)/',
'/Mail_(.+)/', '/Mail_(.+)/',
'/Net_(.+)/', '/Net_(.+)/',
'/^html_.+/', '/^html_.+/',
'/^utf8$/', '/^utf8$/',
'/html2text/' '/html2text/'
), ),
array( array(
'MDB2/\\1', 'MDB2/\\1',
'Mail/\\1', 'Mail/\\1',
'Net/\\1', 'Net/\\1',
'html', 'html',
'utf8.class', 'utf8.class',
'lib/html2text' // see #1485505 'lib/html2text' // see #1485505
), ),
$classname $classname
); );
include $filename. '.php'; include $filename. '.php';
} }
spl_autoload_register('rcube_autoload'); spl_autoload_register('rcube_autoload');
@ -113,17 +113,16 @@ spl_autoload_register('rcube_autoload');
*/ */
function rcube_pear_error($err) function rcube_pear_error($err)
{ {
error_log(sprintf("%s (%s): %s", error_log(sprintf("%s (%s): %s",
$err->getMessage(), $err->getMessage(),
$err->getCode(), $err->getCode(),
$err->getUserinfo()), 0); $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 // include global functions
require_once 'include/bugs.inc'; require_once 'include/bugs.inc';
require_once 'include/main.inc'; require_once 'include/main.inc';
require_once 'include/rcube_shared.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');

@ -117,7 +117,7 @@ abstract class rcube_addressbook
*/ */
function set_page($page) 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) 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) 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) 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) 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() 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) function create_group($name)
{ {
/* empty for address books don't supporting groups */ /* empty for address books don't supporting groups */
return false; return false;
} }
/** /**
@ -199,8 +199,8 @@ abstract class rcube_addressbook
*/ */
function delete_group($gid) function delete_group($gid)
{ {
/* empty for address books don't supporting groups */ /* empty for address books don't supporting groups */
return false; return false;
} }
/** /**
@ -212,8 +212,8 @@ abstract class rcube_addressbook
*/ */
function rename_group($gid, $newname) function rename_group($gid, $newname)
{ {
/* empty for address books don't supporting groups */ /* empty for address books don't supporting groups */
return false; return false;
} }
/** /**
@ -225,8 +225,8 @@ abstract class rcube_addressbook
*/ */
function add_to_group($group_id, $ids) function add_to_group($group_id, $ids)
{ {
/* empty for address books don't supporting groups */ /* empty for address books don't supporting groups */
return 0; return 0;
} }
/** /**
@ -238,8 +238,7 @@ abstract class rcube_addressbook
*/ */
function remove_from_group($group_id, $ids) function remove_from_group($group_id, $ids)
{ {
/* empty for address books don't supporting groups */ /* empty for address books don't supporting groups */
return 0; return 0;
} }
} }

@ -5,7 +5,7 @@
| program/include/rcube_config.php | | program/include/rcube_config.php |
| | | |
| This file is part of the RoundCube Webmail client | | 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 | | Licensed under the GNU GPL |
| | | |
| PURPOSE: | | PURPOSE: |
@ -26,271 +26,271 @@
*/ */
class rcube_config class rcube_config
{ {
private $prop = array(); private $prop = array();
private $errors = array(); private $errors = array();
private $userprefs = array(); private $userprefs = array();
/** /**
* Object constructor * Object constructor
*/ */
public function __construct() public function __construct()
{ {
$this->load(); $this->load();
} }
/** /**
* Load config from local config file * Load config from local config file
* *
* @todo Remove global $CONFIG * @todo Remove global $CONFIG
*/ */
private function load() private function load()
{ {
// start output buffering, we don't need any output yet, // start output buffering, we don't need any output yet,
// it'll be cleared after reading of config files, etc. // it'll be cleared after reading of config files, etc.
ob_start(); ob_start();
// load main config file // load main config file
if (!$this->load_from_file(RCMAIL_CONFIG_DIR . '/main.inc.php')) if (!$this->load_from_file(RCMAIL_CONFIG_DIR . '/main.inc.php'))
$this->errors[] = 'main.inc.php was not found.'; $this->errors[] = 'main.inc.php was not found.';
// load database config // load database config
if (!$this->load_from_file(RCMAIL_CONFIG_DIR . '/db.inc.php')) if (!$this->load_from_file(RCMAIL_CONFIG_DIR . '/db.inc.php'))
$this->errors[] = 'db.inc.php was not found.'; $this->errors[] = 'db.inc.php was not found.';
// load host-specific configuration // load host-specific configuration
$this->load_host_config(); $this->load_host_config();
// set skin (with fallback to old 'skin_path' property) // set skin (with fallback to old 'skin_path' property)
if (empty($this->prop['skin']) && !empty($this->prop['skin_path'])) if (empty($this->prop['skin']) && !empty($this->prop['skin_path']))
$this->prop['skin'] = str_replace('skins/', '', unslashify($this->prop['skin_path'])); $this->prop['skin'] = str_replace('skins/', '', unslashify($this->prop['skin_path']));
else if (empty($this->prop['skin'])) else if (empty($this->prop['skin']))
$this->prop['skin'] = 'default'; $this->prop['skin'] = 'default';
// fix paths // fix paths
$this->prop['log_dir'] = $this->prop['log_dir'] ? realpath(unslashify($this->prop['log_dir'])) : INSTALL_PATH . 'logs'; $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'; $this->prop['temp_dir'] = $this->prop['temp_dir'] ? realpath(unslashify($this->prop['temp_dir'])) : INSTALL_PATH . 'temp';
// fix default imap folders encoding // fix default imap folders encoding
foreach (array('drafts_mbox', 'junk_mbox', 'sent_mbox', 'trash_mbox') as $folder) 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'); $this->prop[$folder] = rcube_charset_convert($this->prop[$folder], RCMAIL_CHARSET, 'UTF7-IMAP');
if (!empty($this->prop['default_imap_folders'])) if (!empty($this->prop['default_imap_folders']))
foreach ($this->prop['default_imap_folders'] as $n => $folder) foreach ($this->prop['default_imap_folders'] as $n => $folder)
$this->prop['default_imap_folders'][$n] = rcube_charset_convert($folder, RCMAIL_CHARSET, 'UTF7-IMAP'); $this->prop['default_imap_folders'][$n] = rcube_charset_convert($folder, RCMAIL_CHARSET, 'UTF7-IMAP');
// set PHP error logging according to config // set PHP error logging according to config
if ($this->prop['debug_level'] & 1) { if ($this->prop['debug_level'] & 1) {
ini_set('log_errors', 1); ini_set('log_errors', 1);
if ($this->prop['log_driver'] == 'syslog') { if ($this->prop['log_driver'] == 'syslog') {
ini_set('error_log', 'syslog'); ini_set('error_log', 'syslog');
} else { }
ini_set('error_log', $this->prop['log_dir'].'/errors'); 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; /**
} * Getter for a specific config parameter
*
* @param string Parameter name
/** * @param mixed Default value if not set
* Load a host-specific config file if configured * @return mixed The requested config value
* This will merge the host specific configuration with the given one */
*/ public function get($name, $def = null)
private function load_host_config() {
{ return isset($this->prop[$name]) ? $this->prop[$name] : $def;
$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';
/**
* 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);
} }
}
/**
/** * Merge the given prefs over the current config
* Read configuration from a file * and make sure that they survive further merging.
* and merge with the already stored config values *
* * @param array Hash array with user prefs
* @param string Full path to the config file to be loaded */
* @return booelan True on success, false on failure public function set_user_prefs($prefs)
*/ {
public function load_from_file($fpath) $this->userprefs = $prefs;
{ $this->prop = array_merge($this->prop, $prefs);
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;
}
/**
* 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 * Getter for all config options
* *
* @return array Hash array containg all config properties * @return array Hash array containg all config properties
*/ */
public function all() 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))
{ {
raise_error(array( return $this->prop;
'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 * Return requested DES crypto key.
if (strlen($key) != 24) *
* @param string Crypto key name
* @return string Crypto key
*/
public function get_crypto_key($key)
{ {
raise_error(array( // Bomb out if the requested key does not exist
'code' => 500, 'type' => 'php', if (!array_key_exists($key, $this->prop)) {
'file' => __FILE__, 'line' => __LINE__, raise_error(array(
'message' => "Configured crypto key \"$key\" is not exactly 24 bytes long" 'code' => 500, 'type' => 'php',
), true, true); '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 * Try to autodetect operating system and find the correct line endings
* *
* @param string IMAP host * @return string The appropriate mail header delimiter
* @return string Resolved SMTP host */
*/ public function header_delimiter()
public function mail_domain($host) {
{ // use the configured delimiter for headers
$domain = $host; if (!empty($this->prop['mail_header_delimiter']))
return $this->prop['mail_header_delimiter'];
if (is_array($this->prop['mail_domain'])) {
if (isset($this->prop['mail_domain'][$host])) $php_os = strtolower(substr(PHP_OS, 0, 3));
$domain = $this->prop['mail_domain'][$host];
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 * Getter for error state
* *
* @return mixed Error message on error, False if no errors * @return mixed Error message on error, False if no errors
*/ */
public function get_error() public function get_error()
{ {
return empty($this->errors) ? false : join("\n", $this->errors); return empty($this->errors) ? false : join("\n", $this->errors);
} }
} }

@ -56,7 +56,7 @@ class rcube_html_page
static $sa_files = array(); static $sa_files = array();
if (!preg_match('|^https?://|i', $file) && $file[0] != '/') 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)) { if (in_array($file, $sa_files)) {
return; return;
@ -130,11 +130,11 @@ class rcube_html_page
public function reset() public function reset()
{ {
$this->script_files = array(); $this->script_files = array();
$this->scripts = array(); $this->scripts = array();
$this->title = ''; $this->title = '';
$this->header = ''; $this->header = '';
$this->footer = ''; $this->footer = '';
$this->body = ''; $this->body = '';
} }
/** /**
@ -248,17 +248,17 @@ class rcube_html_page
// reset those global vars // reset those global vars
$__page_header = $__page_footer = ''; $__page_header = $__page_footer = '';
$this->base_path = $base_path; $this->base_path = $base_path;
// correct absolute paths in images and other tags // 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', $output = preg_replace_callback('!(src|href|background)=(["\']?)([a-z0-9/_.-]+)(["\'\s>])!i',
array($this, 'file_callback'), $output); array($this, 'file_callback'), $output);
$output = str_replace('$__skin_path', $base_path, $output); $output = str_replace('$__skin_path', $base_path, $output);
if ($this->charset != RCMAIL_CHARSET) if ($this->charset != RCMAIL_CHARSET)
echo rcube_charset_convert($output, RCMAIL_CHARSET, $this->charset); echo rcube_charset_convert($output, RCMAIL_CHARSET, $this->charset);
else else
echo $output; echo $output;
} }
/** /**
@ -266,17 +266,17 @@ class rcube_html_page
*/ */
private function file_callback($matches) private function file_callback($matches)
{ {
$file = $matches[3]; $file = $matches[3];
// correct absolute paths // correct absolute paths
if ($file[0] == '/') if ($file[0] == '/')
$file = $this->base_path . $file; $file = $this->base_path . $file;
// add file modification timestamp // add file modification timestamp
if (preg_match('/\.(js|css)$/', $file)) if (preg_match('/\.(js|css)$/', $file))
$file .= '?s=' . @filemtime($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]);
} }
} }

@ -5,7 +5,7 @@
| program/include/rcube_json_output.php | | program/include/rcube_json_output.php |
| | | |
| This file is part of the RoundCube Webmail client | | 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 | | Licensed under the GNU GPL |
| | | |
| PURPOSE: | | PURPOSE: |
@ -47,8 +47,8 @@ class rcube_json_output
{ {
$this->config = rcmail::get_instance()->config; $this->config = rcmail::get_instance()->config;
} }
/** /**
* Set environment variable * Set environment variable
* *
@ -59,7 +59,8 @@ class rcube_json_output
{ {
$this->env[$name] = $value; $this->env[$name] = $value;
} }
/** /**
* Issue command to set page title * Issue command to set page title
* *
@ -71,6 +72,7 @@ class rcube_json_output
$this->command('set_pagetitle', empty($name) ? $title : $name.' :: '.$title); $this->command('set_pagetitle', empty($name) ? $title : $name.' :: '.$title);
} }
/** /**
* @ignore * @ignore
*/ */
@ -103,6 +105,7 @@ class rcube_json_output
// ignore // ignore
} }
/** /**
* Register a list of template object handlers * Register a list of template object handlers
* *
@ -113,8 +116,8 @@ class rcube_json_output
{ {
// ignore // ignore
} }
/** /**
* Call a client method * Call a client method
* *
@ -145,7 +148,7 @@ class rcube_json_output
$this->texts[$name] = rcube_label($name); $this->texts[$name] = rcube_label($name);
} }
} }
/** /**
* Invoke display_message command * Invoke display_message command
@ -167,7 +170,8 @@ class rcube_json_output
); );
} }
} }
/** /**
* Delete all stored env variables and commands * Delete all stored env variables and commands
*/ */
@ -177,7 +181,8 @@ class rcube_json_output
$this->texts = array(); $this->texts = array();
$this->commands = array(); $this->commands = array();
} }
/** /**
* Redirect to a certain url * Redirect to a certain url
* *
@ -227,21 +232,21 @@ class rcube_json_output
$response = array('action' => $rcmail->action, 'unlock' => (bool)$_REQUEST['_unlock']); $response = array('action' => $rcmail->action, 'unlock' => (bool)$_REQUEST['_unlock']);
if (!empty($this->env)) if (!empty($this->env))
$response['env'] = $this->env; $response['env'] = $this->env;
if (!empty($this->texts)) if (!empty($this->texts))
$response['texts'] = $this->texts; $response['texts'] = $this->texts;
// send function calls // send function calls
$response['exec'] = $this->get_js_commands() . $add; $response['exec'] = $this->get_js_commands() . $add;
if (!empty($this->callbacks)) if (!empty($this->callbacks))
$response['callbacks'] = $this->callbacks; $response['callbacks'] = $this->callbacks;
echo json_serialize($response); echo json_serialize($response);
} }
/** /**
* Return executable javascript code for all registered commands * Return executable javascript code for all registered commands
* *
@ -267,5 +272,3 @@ class rcube_json_output
return $out; return $out;
} }
} }

@ -5,7 +5,7 @@
| program/include/rcube_result_set.php | | program/include/rcube_result_set.php |
| | | |
| This file is part of the RoundCube Webmail client | | 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 | | Licensed under the GNU GPL |
| | | |
| PURPOSE: | | PURPOSE: |
@ -28,42 +28,43 @@
*/ */
class rcube_result_set class rcube_result_set
{ {
var $count = 0; var $count = 0;
var $first = 0; var $first = 0;
var $current = 0; var $current = 0;
var $records = array(); var $records = array();
function __construct($c=0, $f=0)
{ function __construct($c=0, $f=0)
$this->count = (int)$c; {
$this->first = (int)$f; $this->count = (int)$c;
} $this->first = (int)$f;
}
function add($rec)
{ function add($rec)
$this->records[] = $rec; {
} $this->records[] = $rec;
}
function iterate() function iterate()
{ {
return $this->records[$this->current++]; return $this->records[$this->current++];
} }
function first() function first()
{ {
$this->current = 0; $this->current = 0;
return $this->records[$this->current++]; return $this->records[$this->current++];
} }
// alias // alias for iterate()
function next() function next()
{ {
return $this->iterate(); return $this->iterate();
} }
function seek($i) function seek($i)
{ {
$this->current = $i; $this->current = $i;
} }
} }

@ -5,7 +5,7 @@
| program/include/rcube_sqlite.inc | | program/include/rcube_sqlite.inc |
| | | |
| This file is part of the RoundCube Webmail client | | 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 | | Licensed under the GNU GPL |
| | | |
| PURPOSE: | | PURPOSE: |
@ -28,50 +28,50 @@
function rcube_sqlite_from_unixtime($timestamp) function rcube_sqlite_from_unixtime($timestamp)
{ {
$timestamp = trim($timestamp); $timestamp = trim($timestamp);
if (!preg_match("/^[0-9]+$/is", $timestamp)) if (!preg_match('/^[0-9]+$/is', $timestamp))
$ret = strtotime($timestamp); $ret = strtotime($timestamp);
else else
$ret = $timestamp; $ret = $timestamp;
$ret = date("Y-m-d H:i:s", $ret); $ret = date('Y-m-d H:i:s', $ret);
rcube_sqlite_debug("FROM_UNIXTIME ($timestamp) = $ret"); rcube_sqlite_debug("FROM_UNIXTIME ($timestamp) = $ret");
return $ret; return $ret;
} }
function rcube_sqlite_unix_timestamp($timestamp="") function rcube_sqlite_unix_timestamp($timestamp='')
{ {
$timestamp = trim($timestamp); $timestamp = trim($timestamp);
if (!$timestamp) if (!$timestamp)
$ret = time(); $ret = time();
else if (!preg_match("/^[0-9]+$/is", $timestamp)) else if (!preg_match('/^[0-9]+$/is', $timestamp))
$ret = strtotime($timestamp); $ret = strtotime($timestamp);
else else
$ret = $timestamp; $ret = $timestamp;
rcube_sqlite_debug("UNIX_TIMESTAMP ($timestamp) = $ret"); rcube_sqlite_debug("UNIX_TIMESTAMP ($timestamp) = $ret");
return $ret; return $ret;
} }
function rcube_sqlite_now() function rcube_sqlite_now()
{ {
rcube_sqlite_debug("NOW() = ".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"); return date("Y-m-d H:i:s");
} }
function rcube_sqlite_md5($str) function rcube_sqlite_md5($str)
{ {
return md5($str); return md5($str);
} }
function rcube_sqlite_debug($str) function rcube_sqlite_debug($str)
{ {
//console($str); //console($str);
} }
?> ?>

@ -5,7 +5,7 @@
| program/include/rcube_template.php | | program/include/rcube_template.php |
| | | |
| This file is part of the RoundCube Webmail client | | 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 | | Licensed under the GNU GPL |
| | | |
| PURPOSE: | | 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) private function alter_form_tag($matches)
{ {
@ -1124,7 +1124,7 @@ class rcube_template extends rcube_html_page
$attrib['id'] = 'rcmqsearchbox'; $attrib['id'] = 'rcmqsearchbox';
} }
if ($attrib['type'] == 'search' && !$this->browser->khtml) { if ($attrib['type'] == 'search' && !$this->browser->khtml) {
unset($attrib['type'], $attrib['results']); unset($attrib['type'], $attrib['results']);
} }
$input_q = new html_inputfield($attrib); $input_q = new html_inputfield($attrib);
@ -1138,7 +1138,7 @@ class rcube_template extends rcube_html_page
'name' => "rcmqsearchform", 'name' => "rcmqsearchform",
'onsubmit' => JS_OBJECT_NAME . ".command('search');return false;", 'onsubmit' => JS_OBJECT_NAME . ".command('search');return false;",
'style' => "display:inline"), 'style' => "display:inline"),
$out); $out);
} }
return $out; return $out;
@ -1215,15 +1215,15 @@ class rcube_template extends rcube_html_page
); );
if (!empty($_POST['_charset'])) if (!empty($_POST['_charset']))
$set = $_POST['_charset']; $set = $_POST['_charset'];
else if (!empty($attrib['selected'])) else if (!empty($attrib['selected']))
$set = $attrib['selected']; $set = $attrib['selected'];
else else
$set = $this->get_charset(); $set = $this->get_charset();
$set = strtoupper($set); $set = strtoupper($set);
if (!isset($charsets[$set])) if (!isset($charsets[$set]))
$charsets[$set] = $set; $charsets[$set] = $set;
$select = new html_select($field_attrib); $select = new html_select($field_attrib);
$select->add(array_values($charsets), array_keys($charsets)); $select->add(array_values($charsets), array_keys($charsets));

Loading…
Cancel
Save