From 10eedbe75a2022d65ec349de5f3bd12400191974 Mon Sep 17 00:00:00 2001
From: alecpl <alec@alec.pl>
Date: Thu, 28 Jan 2010 06:27:16 -0500
Subject: [PATCH] - add file/line definitions to raise_error() calls

---
 program/include/rcube_plugin.php     |   12 +++-
 index.php                            |    2 
 program/include/rcube_mdb2.php       |    8 +-
 program/include/rcube_plugin_api.php |   28 +++++++--
 program/steps/mail/spell_pspell.inc  |    2 
 program/include/rcube_imap.php       |   11 ++-
 program/include/rcube_ldap.php       |   12 ++-
 program/include/rcmail.php           |   21 +++----
 program/steps/mail/viewsource.inc    |    4 
 program/include/rcube_template.php   |    4 +
 program/steps/mail/sendmail.inc      |    6 +
 program/include/rcube_config.php     |   17 ++---
 12 files changed, 77 insertions(+), 50 deletions(-)

diff --git a/index.php b/index.php
index a7dd0fe..e3c542b 100644
--- a/index.php
+++ b/index.php
@@ -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))
diff --git a/program/include/rcmail.php b/program/include/rcmail.php
index 28ccb0c..1afb7d7 100644
--- a/program/include/rcmail.php
+++ b/program/include/rcmail.php
@@ -506,17 +506,16 @@
       }
       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 @@
     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 @@
     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);
     }
diff --git a/program/include/rcube_config.php b/program/include/rcube_config.php
index a4f3699..85ff714 100644
--- a/program/include/rcube_config.php
+++ b/program/include/rcube_config.php
@@ -180,7 +180,7 @@
   {
     $this->prop = array_merge($this->prop, $prefs);
   }
-  
+
   
   /**
    * Getter for all config options
@@ -191,6 +191,7 @@
   {
     return $this->prop;
   }
+
 
   /**
    * Return requested DES crypto key.
@@ -204,9 +205,8 @@
     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,15 +217,15 @@
     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 @@
     else
       return "\n";
   }
+  
 
-  
-  
   /**
    * Return the mail domain configured for the given host
    *
diff --git a/program/include/rcube_imap.php b/program/include/rcube_imap.php
index 8d20036..9137ada 100644
--- a/program/include/rcube_imap.php
+++ b/program/include/rcube_imap.php
@@ -105,8 +105,9 @@
     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 @@
     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
diff --git a/program/include/rcube_ldap.php b/program/include/rcube_ldap.php
index 286bbff..2b2bec2 100644
--- a/program/include/rcube_ldap.php
+++ b/program/include/rcube_ldap.php
@@ -84,7 +84,9 @@
     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 @@
         $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 @@
     $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);
 
diff --git a/program/include/rcube_mdb2.php b/program/include/rcube_mdb2.php
index 137ffb2..e8dd7e0 100644
--- a/program/include/rcube_mdb2.php
+++ b/program/include/rcube_mdb2.php
@@ -266,8 +266,9 @@
         $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 @@
       {
       $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);
diff --git a/program/include/rcube_plugin.php b/program/include/rcube_plugin.php
index fac7db5..c5eb884 100644
--- a/program/include/rcube_plugin.php
+++ b/program/include/rcube_plugin.php
@@ -60,7 +60,9 @@
     $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 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;
diff --git a/program/include/rcube_plugin_api.php b/program/include/rcube_plugin_api.php
index 3a8ae52..1eeadce 100644
--- a/program/include/rcube_plugin_api.php
+++ b/program/include/rcube_plugin_api.php
@@ -96,11 +96,15 @@
           }
         }
         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 @@
       
       // 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 @@
     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 @@
       $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 @@
       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 @@
       $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);
     }
   }
   
diff --git a/program/include/rcube_template.php b/program/include/rcube_template.php
index c583f74..fef0eac 100755
--- a/program/include/rcube_template.php
+++ b/program/include/rcube_template.php
@@ -290,7 +290,9 @@
         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);
diff --git a/program/steps/mail/sendmail.inc b/program/steps/mail/sendmail.inc
index 230572f..589c9af 100644
--- a/program/steps/mail/sendmail.inc
+++ b/program/steps/mail/sendmail.inc
@@ -30,8 +30,10 @@
 /****** 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');
 }
diff --git a/program/steps/mail/spell_pspell.inc b/program/steps/mail/spell_pspell.inc
index 578bfe5..b443ed5 100644
--- a/program/steps/mail/spell_pspell.inc
+++ b/program/steps/mail/spell_pspell.inc
@@ -23,7 +23,7 @@
     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');
diff --git a/program/steps/mail/viewsource.inc b/program/steps/mail/viewsource.inc
index a61385d..17e3824 100644
--- a/program/steps/mail/viewsource.inc
+++ b/program/steps/mail/viewsource.inc
@@ -50,9 +50,9 @@
   raise_error(array(
       'code' => 500,
       'type' => 'php',
+      'file' => __FILE__, 'line' => __LINE__,
       'message' => 'Message UID '.$uid.' not found'),
-    true,
-    true);
+    true, true);
 }
 
 exit;

--
Gitblit v1.9.1