[sam] lib/Driver/sql.php update

t macek maca02 at atlas.cz
Mon Jun 30 23:38:36 PDT 2003


Hi, I'd like to offer you this update of sql.php. I didn't make a patch, 
because I don't use CVS version and I don't know, if it's usable, because 
of some it's restrictions. It's not perfect, because it doesn't know the 
"?" and "*" in the middle of the adress, but it works. This is only a part 
of the lib/Driver/sql.php and it's "foreach" loop used for saving e-mail 
adresses.

Now I'm using a JavaScript the same regular expressions for revealing non- 
mail-adresses in the user input on the client side in SAM.

Please send me your oppinion about it. Best regards

Maca


-----------------------------------------------------------------------

                foreach ($value as $email_address) {
                    /* Don't save email addresses already in
                     * defaults. */
                    if ($type === SAM_PREFTYPE_USER &&
                        array_key_exists($preference, $this->_defaults) &&
                        in_array($email_address, $this- 
>_defaults[$preference])) {
                        continue;
                    }

                    if (ereg("^[[:alnum:]\._-]+@([[:alnum:]-]{2,}\.) 
+[[:alnum:]-]{2,3}$", $email_address) ||
                        ereg("^\*[@\.]([[:alnum:]-]{2,}\.)+[[:alnum:]- 
]{2,3}$", $email_address) ||
                        ereg("^\*\.[[:alnum:]-]{2,3}$", $email_address)) {
                            $this->_db->query(sprintf('INSERT INTO %s 
(horde_id, username, preference, value) ' .
                                 'VALUES (%s, %s, %s, %s);',
                                 $this->_params['table'],
                                 $this->_db->quote($uid),
                                 $this->_db->quote($username),
                                 $this->_db->quote($preference),
                                 $this->_db->quote($email_address)));
                   }
                }

------------------------------------------


-- 
Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/


More information about the sam mailing list