Permalink
Browse files

- add file/line definitions to raise_error() calls

  • Loading branch information...
1 parent 4fc7a7e commit 10eedbe75a2022d65ec349de5f3bd12400191974 @alecpl alecpl committed Jan 28, 2010
View
@@ -111,7 +111,7 @@
$RCMAIL->user->ID,
$_SERVER['REMOTE_ADDR']));
}
-
+
// restore original request parameters
$query = array();
if ($url = get_input_value('_url', RCUBE_INPUT_POST))
@@ -506,17 +506,16 @@ function login($username, $pass, $host=NULL)
}
else {
raise_error(array(
- 'code' => 600,
- 'type' => 'php',
+ 'code' => 600, 'type' => 'php',
+ 'file' => __FILE__, 'line' => __LINE__,
'message' => "Failed to create a user record. Maybe aborted by a plugin?"
- ), true, false);
+ ), true, false);
}
}
else {
raise_error(array(
- 'code' => 600,
- 'type' => 'php',
- 'file' => RCMAIL_CONFIG_DIR."/main.inc.php",
+ 'code' => 600, 'type' => 'php',
+ 'file' => __FILE__, 'line' => __LINE__,
'message' => "Acces denied for new user $username. 'auto_create_user' is disabled"
), true, false);
}
@@ -947,9 +946,8 @@ public function encrypt($clear, $key = 'des_key', $base64 = true)
else
{
raise_error(array(
- 'code' => 500,
- 'type' => 'php',
- 'file' => __FILE__,
+ 'code' => 500, 'type' => 'php',
+ 'file' => __FILE__, 'line' => __LINE__,
'message' => "Could not perform encryption; make sure Mcrypt is installed or lib/des.inc is available"
), true, true);
}
@@ -993,9 +991,8 @@ public function decrypt($cipher, $key = 'des_key', $base64 = true)
else
{
raise_error(array(
- 'code' => 500,
- 'type' => 'php',
- 'file' => __FILE__,
+ 'code' => 500, 'type' => 'php',
+ 'file' => __FILE__, 'line' => __LINE__,
'message' => "Could not perform decryption; make sure Mcrypt is installed or lib/des.inc is available"
), true, true);
}
@@ -180,7 +180,7 @@ public function merge($prefs)
{
$this->prop = array_merge($this->prop, $prefs);
}
-
+
/**
* Getter for all config options
@@ -192,6 +192,7 @@ public function all()
return $this->prop;
}
+
/**
* Return requested DES crypto key.
*
@@ -204,9 +205,8 @@ public function get_crypto_key($key)
if (!array_key_exists($key, $this->prop))
{
raise_error(array(
- 'code' => 500,
- 'type' => 'php',
- 'file' => __FILE__,
+ 'code' => 500, 'type' => 'php',
+ 'file' => __FILE__, 'line' => __LINE__,
'message' => "Request for unconfigured crypto key \"$key\""
), true, true);
}
@@ -217,16 +217,16 @@ public function get_crypto_key($key)
if (strlen($key) != 24)
{
raise_error(array(
- 'code' => 500,
- 'type' => 'php',
- 'file' => __FILE__,
+ 'code' => 500, 'type' => 'php',
+ 'file' => __FILE__, 'line' => __LINE__,
'message' => "Configured crypto key \"$key\" is not exactly 24 bytes long"
), true, true);
}
return $key;
}
+
/**
* Try to autodetect operating system and find the correct line endings
*
@@ -244,9 +244,8 @@ public function header_delimiter()
else
return "\n";
}
-
-
+
/**
* Return the mail domain configured for the given host
*
@@ -105,8 +105,9 @@ function connect($host, $user, $pass, $port=143, $use_ssl=null)
if ($use_ssl && extension_loaded('openssl'))
$ICL_SSL = $use_ssl == 'imaps' ? 'ssl' : $use_ssl;
else if ($use_ssl) {
- raise_error(array('code' => 403, 'type' => 'imap', 'file' => __FILE__,
- 'message' => 'Open SSL not available;'), TRUE, FALSE);
+ raise_error(array('code' => 403, 'type' => 'imap',
+ 'file' => __FILE__, 'line' => __LINE__,
+ 'message' => "Open SSL not available"), TRUE, FALSE);
$port = 143;
}
@@ -136,9 +137,9 @@ function connect($host, $user, $pass, $port=143, $use_ssl=null)
else if (!$this->conn && $GLOBALS['iil_error'])
{
$this->error_code = $GLOBALS['iil_errornum'];
- raise_error(array('code' => 403,
- 'type' => 'imap',
- 'message' => $GLOBALS['iil_error']), TRUE, FALSE);
+ raise_error(array('code' => 403, 'type' => 'imap',
+ 'file' => __FILE__, 'line' => __LINE__,
+ 'message' => $GLOBALS['iil_error']), TRUE, FALSE);
}
// get server properties
@@ -84,7 +84,9 @@ function connect()
global $RCMAIL;
if (!function_exists('ldap_connect'))
- raise_error(array('code' => 100, 'type' => 'ldap', 'message' => "No ldap support in this installation of PHP"), true);
+ raise_error(array('code' => 100, 'type' => 'ldap',
+ 'file' => __FILE__, 'line' => __LINE__,
+ 'message' => "No ldap support in this installation of PHP"), true);
if (is_resource($this->conn))
return true;
@@ -140,7 +142,9 @@ function connect()
$this->ready = $this->bind($this->prop['bind_dn'], $this->prop['bind_pass']);
}
else
- raise_error(array('code' => 100, 'type' => 'ldap', 'message' => "Could not connect to any LDAP server, tried $host:{$this->prop[port]} last"), true);
+ raise_error(array('code' => 100, 'type' => 'ldap',
+ 'file' => __FILE__, 'line' => __LINE__,
+ 'message' => "Could not connect to any LDAP server, last tried $host:{$this->prop[port]}"), true);
// See if the directory is writeable.
if ($this->prop['writable']) {
@@ -173,8 +177,8 @@ function bind($dn, $pass)
$this->_debug("S: ".ldap_error($this->conn));
raise_error(array(
- 'code' => ldap_errno($this->conn),
- 'type' => 'ldap',
+ 'code' => ldap_errno($this->conn), 'type' => 'ldap',
+ 'file' => __FILE__, 'line' => __LINE__,
'message' => "Bind failed for dn=$dn: ".ldap_error($this->conn)),
true);
@@ -266,8 +266,9 @@ function _query($query, $offset, $numrows, $params)
$this->db_error = TRUE;
$this->db_error_msg = $q->userinfo;
- raise_error(array('code' => 500, 'type' => 'db', 'line' => __LINE__, 'file' => __FILE__,
- 'message' => $this->db_error_msg), TRUE, TRUE);
+ raise_error(array('code' => 500, 'type' => 'db',
+ 'line' => __LINE__, 'file' => __FILE__,
+ 'message' => $this->db_error_msg), TRUE, TRUE);
}
else
{
@@ -626,7 +627,8 @@ function _add_result($res)
{
$this->db_error = TRUE;
$this->db_error_msg = $res->getMessage();
- raise_error(array('code' => 500, 'type' => 'db', 'line' => __LINE__, 'file' => __FILE__,
+ raise_error(array('code' => 500, 'type' => 'db',
+ 'line' => __LINE__, 'file' => __FILE__,
'message' => $res->getMessage() . " Query: "
. substr(preg_replace('/[\r\n]+\s*/', ' ', $res->userinfo), 0, 512)),
TRUE, FALSE);
@@ -60,7 +60,9 @@ public function load_config($fname = 'config.inc.php')
$fpath = $this->home.'/'.$fname;
$rcmail = rcmail::get_instance();
if (is_file($fpath) && !$rcmail->config->load_from_file($fpath, false)) {
- raise_error(array('code' => 527, 'type' => 'php', 'message' => "Failed to load config from $fpath"), true, false);
+ raise_error(array('code' => 527, 'type' => 'php',
+ 'file' => __FILE__, 'line' => __LINE__,
+ 'message' => "Failed to load config from $fpath"), true, false);
return false;
}
@@ -133,10 +135,14 @@ public function gettext($p)
public function register_task($task)
{
if ($task != asciiwords($task)) {
- raise_error(array('code' => 526, 'type' => 'php', 'message' => "Invalid task name: $task. Only characters [a-z0-9_.-] are allowed"), true, false);
+ raise_error(array('code' => 526, 'type' => 'php',
+ 'file' => __FILE__, 'line' => __LINE__,
+ 'message' => "Invalid task name: $task. Only characters [a-z0-9_.-] are allowed"), true, false);
}
else if (in_array(rcmail::$main_tasks, $task)) {
- raise_error(array('code' => 526, 'type' => 'php', 'message' => "Cannot register taks $task; already taken by another plugin or the application itself"), true, false);
+ raise_error(array('code' => 526, 'type' => 'php',
+ 'file' => __FILE__, 'line' => __LINE__,
+ 'message' => "Cannot register taks $task; already taken by another plugin or the application itself"), true, false);
}
else {
rcmail::$main_tasks[] = $task;
@@ -96,11 +96,15 @@ public function init()
}
}
else {
- raise_error(array('code' => 520, 'type' => 'php', 'message' => "No plugin class $plugin_name found in $fn"), true, false);
+ raise_error(array('code' => 520, 'type' => 'php',
+ 'file' => __FILE__, 'line' => __LINE__,
+ 'message' => "No plugin class $plugin_name found in $fn"), true, false);
}
}
else {
- raise_error(array('code' => 520, 'type' => 'php', 'message' => "Failed to load plugin file $fn"), true, false);
+ raise_error(array('code' => 520, 'type' => 'php',
+ 'file' => __FILE__, 'line' => __LINE__,
+ 'message' => "Failed to load plugin file $fn"), true, false);
}
}
@@ -136,7 +140,9 @@ public function init()
// trigger fatal error if still not loaded
if (!$loaded) {
- raise_error(array('code' => 520, 'type' => 'php', 'message' => "Requried plugin $plugin_name was not loaded"), true, true);
+ raise_error(array('code' => 520, 'type' => 'php',
+ 'file' => __FILE__, 'line' => __LINE__,
+ 'message' => "Requried plugin $plugin_name was not loaded"), true, true);
}
}
@@ -167,7 +173,9 @@ public function register_hook($hook, $callback)
if (is_callable($callback))
$this->handlers[$hook][] = $callback;
else
- raise_error(array('code' => 521, 'type' => 'php', 'message' => "Invalid callback function for $hook"), true, false);
+ raise_error(array('code' => 521, 'type' => 'php',
+ 'file' => __FILE__, 'line' => __LINE__,
+ 'message' => "Invalid callback function for $hook"), true, false);
}
@@ -220,7 +228,9 @@ public function register_action($action, $owner, $callback)
$this->actionmap[$action] = $owner;
}
else {
- raise_error(array('code' => 523, 'type' => 'php', 'message' => "Cannot register action $action; already taken by another plugin"), true, false);
+ raise_error(array('code' => 523, 'type' => 'php',
+ 'file' => __FILE__, 'line' => __LINE__,
+ 'message' => "Cannot register action $action; already taken by another plugin"), true, false);
}
}
@@ -237,7 +247,9 @@ public function exec_action($action)
call_user_func($this->actions[$action]);
}
else {
- raise_error(array('code' => 524, 'type' => 'php', 'message' => "No handler found for action $action"), true, true);
+ raise_error(array('code' => 524, 'type' => 'php',
+ 'file' => __FILE__, 'line' => __LINE__,
+ 'message' => "No handler found for action $action"), true, true);
}
}
@@ -261,7 +273,9 @@ public function register_handler($name, $owner, $callback)
$this->objectsmap[$name] = $owner;
}
else {
- raise_error(array('code' => 525, 'type' => 'php', 'message' => "Cannot register template handler $name; already taken by another plugin"), true, false);
+ raise_error(array('code' => 525, 'type' => 'php',
+ 'file' => __FILE__, 'line' => __LINE__,
+ 'message' => "Cannot register template handler $name; already taken by another plugin"), true, false);
}
}
@@ -290,7 +290,9 @@ public function send($templ = null, $exit = true)
if ($templ != 'iframe') {
// prevent from endless loops
if ($exit != 'recur' && $this->app->plugins->is_processing('render_page')) {
- raise_error(array('code' => 505, 'type' => 'php', 'message' => 'Recursion alert: ignoring output->send()'), true, false);
+ raise_error(array('code' => 505, 'type' => 'php',
+ 'file' => __FILE__, 'line' => __LINE__,
+ 'message' => 'Recursion alert: ignoring output->send()'), true, false);
return;
}
$this->parse($templ, false);
@@ -30,8 +30,10 @@ $savedraft = !empty($_POST['_draft']) ? TRUE : FALSE;
/****** checks ********/
if (!isset($_SESSION['compose']['id'])) {
- raise_error(array('code' => 500, 'type' => 'smtp', 'file' => __FILE__, 'message' => "Invalid compose ID"), true, false);
- console("Sendmail error", $_SESSION['compose']);
+ raise_error(array('code' => 500, 'type' => 'smtp',
+ 'file' => __FILE__, 'line' => __LINE__,
+ 'message' => "Invalid compose ID"), true, false);
+
$OUTPUT->show_message("An internal error occured. Please try again.", 'error');
$OUTPUT->send('iframe');
}
@@ -23,7 +23,7 @@ if (!extension_loaded('pspell')) {
raise_error(array(
'code' => 500,
'type' => 'php',
- 'file' => __FILE__,
+ 'file' => __FILE__, 'line' => __LINE__,
'message' => "Pspell extension not available"), true, false);
header('HTTP/1.1 404 Not Found');
@@ -50,9 +50,9 @@ else
raise_error(array(
'code' => 500,
'type' => 'php',
+ 'file' => __FILE__, 'line' => __LINE__,
'message' => 'Message UID '.$uid.' not found'),
- true,
- true);
+ true, true);
}
exit;

0 comments on commit 10eedbe

Please sign in to comment.