瀏覽代碼

In stead of just crashing, give a proper error when PEAR DB functions could
not be included.

Also, from now on I will add a vim comment to the foot of each file I commit
to make sure everyone that edits the file with vim will automatically use the
correct 4-spaces-indentation.

Thijs Kinkhorst 21 年之前
父節點
當前提交
0c7380594b
共有 3 個文件被更改,包括 19 次插入3 次删除
  1. 1 0
      ChangeLog
  2. 9 1
      functions/abook_database.php
  3. 9 2
      functions/db_prefs.php

+ 1 - 0
ChangeLog

@@ -64,6 +64,7 @@ Version 1.5.1 -- CVS
   - Fixed XSS vulnerability in content-type display in the attachment area
   - Fixed XSS vulnerability in content-type display in the attachment area
     of read_body.php discovered by Roman Medina.
     of read_body.php discovered by Roman Medina.
   - Get alternating row colors of addressbook in sync with mailbox list.
   - Get alternating row colors of addressbook in sync with mailbox list.
+  - Give proper error when PEAR DB not found.
 
 
 Version 1.5.0
 Version 1.5.0
 --------------------
 --------------------

+ 9 - 1
functions/abook_database.php

@@ -33,7 +33,13 @@
  */
  */
 
 
 /** Needs the DB functions */   
 /** Needs the DB functions */   
-require_once('DB.php');
+if (!include_once('DB.php')) {
+    // same error also in db_prefs.php
+    require_once(SM_PATH . 'functions/display_messages.php');
+    $error  = _("Could not include PEAR database functions required for the database backend.") . "<br />\n";
+    $error .= _("Please contact your system administrator and report this error.");
+    error_box($error, $color);
+}
 
 
 /**
 /**
  * Undocumented class - stores the addressbook in a sql database
  * Undocumented class - stores the addressbook in a sql database
@@ -345,4 +351,6 @@ class abook_database extends addressbook_backend {
     }
     }
 } /* End of class abook_database */
 } /* End of class abook_database */
 
 
+
+// vim: et ts=4
 ?>
 ?>

+ 9 - 2
functions/db_prefs.php

@@ -36,8 +36,14 @@ define('SMDB_MYSQL', 1);
 /** PostgreSQL */
 /** PostgreSQL */
 define('SMDB_PGSQL', 2);
 define('SMDB_PGSQL', 2);
 
 
-require_once('DB.php');
 require_once(SM_PATH . 'config/config.php');
 require_once(SM_PATH . 'config/config.php');
+if (!include_once('DB.php')) {
+    // same error also in abook_database.php
+    require_once(SM_PATH . 'functions/display_messages.php');
+    $error  = _("Could not include PEAR database functions required for the database backend.") . "<br />\n";
+    $error .= _("Please contact your system administrator and report this error.");
+    error_box($error, $color);
+}
 
 
 global $prefs_are_cached, $prefs_cache;
 global $prefs_are_cached, $prefs_cache;
 
 
@@ -385,4 +391,5 @@ function getSig($data_dir, $username, $number) {
     return getPref($data_dir, $username, $key);
     return getPref($data_dir, $username, $key);
 }
 }
 
 
-?>
+// vim: et ts=4
+?>