- 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,7 +40,7 @@
* @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)
@ -48,14 +48,13 @@ function raise_error($arg=array(), $log=false, $terminate=false)
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;
} }
} }
/** /**
@ -70,8 +69,7 @@ function log_bug($arg_arr)
$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,
@ -80,28 +78,25 @@ function log_bug($arg_arr)
$_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 // resport the bug to the global bug reporting system
if ($CONFIG['debug_level'] & 2) if ($CONFIG['debug_level'] & 2) {
{
// TODO: Send error via HTTP // TODO: Send error via HTTP
} }
// show error if debug_mode is on // show error if debug_mode is on
if ($CONFIG['debug_level'] & 4) if ($CONFIG['debug_level'] & 4) {
{
print "<b>$program Error"; print "<b>$program Error";
if (!empty($arg_arr['file']) && !empty($arg_arr['line'])) if (!empty($arg_arr['file']) && !empty($arg_arr['line']))
print " in $arg_arr[file] ($arg_arr[line])"; print " in $arg_arr[file] ($arg_arr[line])";
print ":</b>&nbsp;"; print ':</b>&nbsp;';
print nl2br($arg_arr['message']); print nl2br($arg_arr['message']);
print '<br />'; print '<br />';
flush(); flush();

@ -119,11 +119,10 @@ function rcube_pear_error($err)
$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');

@ -242,4 +242,3 @@ abstract class rcube_addressbook
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: |
@ -86,7 +86,8 @@ class rcube_config
if ($this->prop['log_driver'] == 'syslog') { if ($this->prop['log_driver'] == 'syslog') {
ini_set('error_log', 'syslog'); ini_set('error_log', 'syslog');
} else { }
else {
ini_set('error_log', $this->prop['log_dir'].'/errors'); ini_set('error_log', $this->prop['log_dir'].'/errors');
} }
} }
@ -104,7 +105,6 @@ class rcube_config
$GLOBALS['CONFIG'] = &$this->prop; $GLOBALS['CONFIG'] = &$this->prop;
} }
/** /**
* Load a host-specific config file if configured * Load a host-specific config file if configured
* This will merge the host specific configuration with the given one * This will merge the host specific configuration with the given one
@ -216,8 +216,7 @@ class rcube_config
public function get_crypto_key($key) public function get_crypto_key($key)
{ {
// Bomb out if the requested key does not exist // Bomb out if the requested key does not exist
if (!array_key_exists($key, $this->prop)) if (!array_key_exists($key, $this->prop)) {
{
raise_error(array( raise_error(array(
'code' => 500, 'type' => 'php', 'code' => 500, 'type' => 'php',
'file' => __FILE__, 'line' => __LINE__, 'file' => __FILE__, 'line' => __LINE__,
@ -228,12 +227,11 @@ class rcube_config
$key = $this->prop[$key]; $key = $this->prop[$key];
// Bomb out if the configured key is not exactly 24 bytes long // Bomb out if the configured key is not exactly 24 bytes long
if (strlen($key) != 24) if (strlen($key) != 24) {
{
raise_error(array( raise_error(array(
'code' => 500, 'type' => 'php', 'code' => 500, 'type' => 'php',
'file' => __FILE__, 'line' => __LINE__, 'file' => __FILE__, 'line' => __LINE__,
'message' => "Configured crypto key \"$key\" is not exactly 24 bytes long" 'message' => "Configured crypto key '$key' is not exactly 24 bytes long"
), true, true); ), true, true);
} }
@ -251,11 +249,15 @@ class rcube_config
// use the configured delimiter for headers // use the configured delimiter for headers
if (!empty($this->prop['mail_header_delimiter'])) if (!empty($this->prop['mail_header_delimiter']))
return $this->prop['mail_header_delimiter']; return $this->prop['mail_header_delimiter'];
else if (strtolower(substr(PHP_OS, 0, 3)) == 'win')
$php_os = strtolower(substr(PHP_OS, 0, 3));
if ($php_os == 'win')
return "\r\n"; return "\r\n";
else if (strtolower(substr(PHP_OS, 0, 3)) == 'mac')
if ($php_os == 'mac')
return "\r\n"; return "\r\n";
else
return "\n"; return "\n";
} }
@ -291,6 +293,4 @@ class rcube_config
return empty($this->errors) ? false : join("\n", $this->errors); return empty($this->errors) ? false : join("\n", $this->errors);
} }
} }

@ -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: |
@ -60,6 +60,7 @@ 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
* *
@ -168,6 +171,7 @@ class rcube_json_output
} }
} }
/** /**
* Delete all stored env variables and commands * Delete all stored env variables and commands
*/ */
@ -178,6 +182,7 @@ class rcube_json_output
$this->commands = array(); $this->commands = array();
} }
/** /**
* Redirect to a certain url * Redirect to a certain url
* *
@ -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: |
@ -33,6 +33,7 @@ class rcube_result_set
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->count = (int)$c;
@ -55,7 +56,7 @@ class rcube_result_set
return $this->records[$this->current++]; return $this->records[$this->current++];
} }
// alias // alias for iterate()
function next() function next()
{ {
return $this->iterate(); return $this->iterate();

@ -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)
{ {

Loading…
Cancel
Save