typo in variable name peardb, reported by Tomas (Closes: #1662444)
[squirrelmail.git] / plugins / change_password / backend / peardb.php
index 58f74c80eb6579e5a1062cde1748b855d951ba2e..376445039b83230f6f9804f442142da10ef92a2d 100644 (file)
@@ -3,22 +3,22 @@
 /**
  * Change password PearDB backend
  *
- * @copyright © 2005-2006 The SquirrelMail Project Team
+ * @copyright © 2005-2007 The SquirrelMail Project Team
  * @license http://opensource.org/licenses/gpl-license.php GNU Public License
  * @version $Id$
  * @package plugins
  * @subpackage change_password
  */
 
-/** load Pear DB. 
- * Global is needed because library must be loaded before configuration 
+/** load Pear DB.
+ * Global is needed because library must be loaded before configuration
  * in order to use DB constants.
  */
 global $cpw_peardb_detect;
 $cpw_peardb_detect=@include_once('DB.php');
 
 /** declare configuration globals */
-global $cpw_peardb_dsn, $cpw_peardb_connect_opts, $cpw_peardb_table, 
+global $cpw_peardb_dsn, $cpw_peardb_connect_opts, $cpw_peardb_table,
  $cpw_peardb_uid_field, $cpw_peardb_domain_field, $cpw_peardb_passwd_field,
  $cpw_peardb_crypted_passwd, $cpw_peardb_debug;
 
@@ -78,7 +78,7 @@ if ( isset($cpw_peardb) && is_array($cpw_peardb) && !empty($cpw_peardb) ) {
     if (isset($cpw_peardb['dsn']))
         $cpw_peardb_dsn=$cpw_peardb['dsn'];
     if (isset($cpw_peardb['connect_opts']))
-        $cpw_peardb_connect_opts=$cpw_peaddb['connect_opts'];
+        $cpw_peardb_connect_opts=$cpw_peardb['connect_opts'];
     if (isset($cpw_peardb['table']))
         $cpw_peardb_table=$cpw_peardb['table'];
     if (isset($cpw_peardb['uid_field']))
@@ -106,30 +106,19 @@ $squirrelmail_plugin_hooks['change_password_init']['peardb'] =
  * Checks if configuration is correct
  */
 function cpw_peardb_init() {
-    global $color, $cpw_peardb_detect, $cpw_peardb_dsn, $cpw_peardb_table;
-
-    /**
-     * If SM_PATH isn't defined, define it.  Required to include files.
-     * @ignore
-     */
-    if (!defined('SM_PATH'))  {
-        define('SM_PATH','../../../');
-    }
-
-    // load error_box() function
-    include_once(SM_PATH . 'functions/display_messages.php');
+    global $oTemplate, $cpw_peardb_detect, $cpw_peardb_dsn, $cpw_peardb_table;
 
     if (! $cpw_peardb_detect) {
-        error_box(_("Plugin is unable to use PHP Pear DB libraries. PHP Pear includes must be available in your PHP include_path setting."),$color);
-        echo "</body></html>\n";
+        error_box(_("Plugin is unable to use PHP Pear DB libraries. PHP Pear includes must be available in your PHP include_path setting."));
+        $oTemplate->display('footer.tpl');
         exit();
     }
 
     // Test required settings
-    if ((is_string($cpw_peardb_dsn) && trim($cpw_peardb_dsn)=='') 
+    if ((is_string($cpw_peardb_dsn) && trim($cpw_peardb_dsn)=='')
         || trim($cpw_peardb_table)=='' ) {
-        error_box(_("Required change password backend configuration options are missing."),$color);
-        echo "</body></html>\n";
+        error_box(_("Required change password backend configuration options are missing."));
+        $oTemplate->display('footer.tpl');
         exit();
     }
 }
@@ -142,7 +131,7 @@ function cpw_peardb_init() {
  */
 function cpw_peardb_dochange($data) {
     global $cpw_peardb_dsn, $cpw_peardb_table, $cpw_peardb_connect_opts, $cpw_peardb_debug,
-        $cpw_peardb_uid_field, $cpw_peardb_passwd_field, $cpw_peardb_domain_field, 
+        $cpw_peardb_uid_field, $cpw_peardb_passwd_field, $cpw_peardb_domain_field,
         $cpw_peardb_crypted_passwd, $domain;
 
     $username = $data['username'];
@@ -159,7 +148,7 @@ function cpw_peardb_dochange($data) {
         $user=$username;
         $user_domain=$domain;
     }
+
     // connect to database and make sure that table exists
     $cpw_db = DB::connect($cpw_peardb_dsn, $cpw_peardb_connect_opts);
     if (PEAR::isError($cpw_db)) {
@@ -187,9 +176,9 @@ function cpw_peardb_dochange($data) {
     $cpw_peardb_passwd_check=false;
     $cpw_peardb_domain_check=(($cpw_peardb_domain_field=='')? true : false);
     foreach($table_info as $key => $field_data) {
-        if ($field_data['name']==$cpw_peardb_uid_field) 
+        if ($field_data['name']==$cpw_peardb_uid_field)
             $cpw_peardb_uid_check=true;
-        if ($field_data['name']==$cpw_peardb_passwd_field) 
+        if ($field_data['name']==$cpw_peardb_passwd_field)
             $cpw_peardb_passwd_check=true;
         if ($cpw_peardb_domain_field!='' && $field_data['name']==$cpw_peardb_domain_field)
             $cpw_peardb_domain_check=true;
@@ -216,7 +205,7 @@ function cpw_peardb_dochange($data) {
         .' FROM '.$cpw_db->quoteIdentifier($cpw_peardb_table)
         .' WHERE '
         .$cpw_db->quoteIdentifier($cpw_peardb_uid_field).'='.$cpw_db->quoteSmart($user)
-        .(($cpw_peardb_domain_field!='') ? 
+        .(($cpw_peardb_domain_field!='') ?
           ' AND '.$cpw_db->quoteIdentifier($cpw_peardb_domain_field).'='.$cpw_db->quoteSmart($user_domain):
           '');
     $cpw_res=$cpw_db->query($query);
@@ -286,7 +275,7 @@ function cpw_peardb_dochange($data) {
         .'='.$cpw_db->quoteSmart($hashed_passwd)
         .' WHERE '.$cpw_db->quoteIdentifier($cpw_peardb_uid_field)
         .'='.$cpw_db->quoteSmart($user)
-        .(($cpw_peardb_domain_field!='') ? 
+        .(($cpw_peardb_domain_field!='') ?
           ' AND '.$cpw_db->quoteIdentifier($cpw_peardb_domain_field).'='.$cpw_db->quoteSmart($user_domain) :
           '');
 
@@ -442,4 +431,3 @@ function cpw_peardb_passwd_hash($password,$crypto,&$msgs,$forced_salt='') {
     }
     return $ret;
 }
-?>
\ No newline at end of file