[geeklog-cvs] geeklog-1.3/public_html usersettings.php,1.58,1.59

geeklog-cvs-admin at lists.geeklog.net geeklog-cvs-admin at lists.geeklog.net
Tue May 20 04:55:56 EDT 2003


Update of /usr/cvs/geeklog/geeklog-1.3/public_html
In directory internal.geeklog.net:/tmp/cvs-serv29863

Modified Files:
	usersettings.php 
Log Message:
Added check for existing email address.


Index: usersettings.php
===================================================================
RCS file: /usr/cvs/geeklog/geeklog-1.3/public_html/usersettings.php,v
retrieving revision 1.58
retrieving revision 1.59
diff -C2 -d -r1.58 -r1.59
*** usersettings.php	14 May 2003 10:48:52 -0000	1.58
--- usersettings.php	20 May 2003 08:55:54 -0000	1.59
***************
*** 446,449 ****
--- 446,474 ----
  
  /**
+ * Check if an email address already exists in the database
+ *
+ * @param   email   string   email address to check
+ * @param   uid     int      user id of current user
+ * @return          bool     true = exists, false = does not exist
+ *
+ */
+ function emailAddressExists ($email, $uid)
+ {
+     global $_TABLES;
+ 
+     $result = DB_query ("SELECT uid FROM {$_TABLES['users']} WHERE email = '{$email}'");
+     $numrows = DB_numRows ($result);
+     for ($i = 0; $i < $numrows; $i++) {
+         $A = DB_fetchArray ($result);
+         if ($A['uid'] != $uid) {
+             // email address is already in use for another account
+             return true;
+         }
+     }
+ 
+     return false;
+ }
+ 
+ /**
  * Saves the user's information back to the database
  *
***************
*** 486,490 ****
      $A['pgpkey'] = strip_tags (COM_stripslashes ($A['pgpkey']));
  
!     if (COM_isEmail ($A['email'])) {
          if ($_US_VERBOSE) {
              COM_errorLog('cooktime = ' . $A['cooktime'],1);
--- 511,521 ----
      $A['pgpkey'] = strip_tags (COM_stripslashes ($A['pgpkey']));
  
!     if (!COM_isEmail ($A['email'])) {
!         return COM_refresh ($_CONF['site_url']
!                 . '/usersettings.php?mode=edit&msg=52');
!     } else if (emailAddressExists ($A['email'], $_USER['uid'])) {
!         return COM_refresh ($_CONF['site_url']
!                 . '/usersettings.php?mode=edit&msg=56');
!     } else {
          if ($_US_VERBOSE) {
              COM_errorLog('cooktime = ' . $A['cooktime'],1);
***************
*** 602,608 ****
          return COM_refresh ($_CONF['site_url']
                  . '/usersettings.php?mode=edit&msg=5');
-     } else {
-         return COM_refresh ($_CONF['site_url']
-                 . '/usersettings.php?mode=edit&msg=52');
      }
  }
--- 633,636 ----





More information about the geeklog-cvs mailing list