PHP Deprecated: Function eregi() is deprecated

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

PHP Deprecated: Function eregi() is deprecated

Juergen Nickelsen-3
As already mentioned on squirrelmail-users, we recently moved our
SquirrelMail installation from Debian Squeeze to Wheezy, which implies a
move from PHP 5.3 to PHP 5.4.

When using the "add_address" plugin (1.0.3, which is the most recent I
could find), I see the following message in the error log, which may or
may not have been there with previous PHP version as well:

"""
PHP Deprecated:  Function eregi() is deprecated in
/home/webmail/src/squirrelmail/plugins/add_address/functions.php on line
718, referer: [...]
"""

Well, yes, eregi() is deprecated. So I propose the following change,
which seems to work for me:

--- a/plugins/add_address/functions.php
+++ b/plugins/add_address/functions.php
@@ -715,7 +715,7 @@ function aa_validate_email($email, $verify)

    // check formatting
    //
-   if (!eregi('^' . $Email_RegExp_Match . '$', $email))
+   if (!preg_match('/^' . addcslashes($Email_RegExp_Match, '/') .
'$/i', $email))
       return FALSE;


Is this correct? Any caveats regarding this solution?

Mit freundlichem Gruß,
Jürgen Nickelsen.

--
<[hidden email]> Tel +49.30.838-50740 Fax -450740
Zentraleinrichtung fuer Datenverarbeitung, Central Systems (Unix)
Freie Universitaet Berlin, Fabeckstrasse 32, 14195 Berlin, DE


------------------------------------------------------------------------------
New Year. New Location. New Benefits. New Data Center in Ashburn, VA.
GigeNET is offering a free month of service with a new server in Ashburn.
Choose from 2 high performing configs, both with 100TB of bandwidth.
Higher redundancy.Lower latency.Increased capacity.Completely compliant.
http://p.sf.net/sfu/gigenet
-----
squirrelmail-plugins mailing list
Posting guidelines: http://squirrelmail.org/postingguidelines
List address: [hidden email]
List archives: http://news.gmane.org/gmane.mail.squirrelmail.plugins
List info (subscribe/unsubscribe/change options): https://lists.sourceforge.net/lists/listinfo/squirrelmail-plugins

smime.p7s (7K) Download Attachment
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: PHP Deprecated: Function eregi() is deprecated

Paul Lesniewski
> PHP Deprecated:  Function eregi() is deprecated in
> /home/webmail/src/squirrelmail/plugins/add_address/functions.php on line
> 718, referer: [...]
>
> --- a/plugins/add_address/functions.php
> +++ b/plugins/add_address/functions.php
> @@ -715,7 +715,7 @@ function aa_validate_email($email, $verify)
>
>     // check formatting
>     //
> -   if (!eregi('^' . $Email_RegExp_Match . '$', $email))
> +   if (!preg_match('/^' . addcslashes($Email_RegExp_Match, '/') .
> '$/i', $email))
>        return FALSE;
>
>
> Is this correct? Any caveats regarding this solution?

I don't think you need addcslashes.  This should do the job:

if (!preg_match('/^' . $Email_RegExp_Match . '$/i', $email))

--
Paul Lesniewski
SquirrelMail Team
Please support Open Source Software by donating to SquirrelMail!
http://squirrelmail.org/donate_paul_lesniewski.php

------------------------------------------------------------------------------
New Year. New Location. New Benefits. New Data Center in Ashburn, VA.
GigeNET is offering a free month of service with a new server in Ashburn.
Choose from 2 high performing configs, both with 100TB of bandwidth.
Higher redundancy.Lower latency.Increased capacity.Completely compliant.
http://p.sf.net/sfu/gigenet
-----
squirrelmail-plugins mailing list
Posting guidelines: http://squirrelmail.org/postingguidelines
List address: [hidden email]
List archives: http://news.gmane.org/gmane.mail.squirrelmail.plugins
List info (subscribe/unsubscribe/change options): https://lists.sourceforge.net/lists/listinfo/squirrelmail-plugins
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: PHP Deprecated: Function eregi() is deprecated

Juergen Nickelsen-3
On 18.01.2015 03:11, Paul Lesniewski wrote:

>> -   if (!eregi('^' . $Email_RegExp_Match . '$', $email))
>> +   if (!preg_match('/^' . addcslashes($Email_RegExp_Match, '/') .
[...]
>
> I don't think you need addcslashes.  This should do the job:
>
> if (!preg_match('/^' . $Email_RegExp_Match . '$/i', $email))

I do, because the regular expression contains a slash. Omitting
addcslashes() not only gives me a warning message...

[Mon Jan 19 12:47:40 2015] [error] [client 130.133.10.14] PHP Warning:
preg_match(): Unknown modifier '=' in
/home/webmail/src/squirrelmail/plugins/add_address/functions.php on line
723, referer:
https://webmail.zedat.fu-berlin.de:8445/src/read_body.php?mailbox=INBOX&passed_id=102723&startMessage=1

... and the addresses I want to "Add to address book" are marked as
"maybe invalid", because the regular expression itself contains slashes.
So the addcslashes() is definitely needed.

Best regards, Jürgen.

--
<[hidden email]> Tel +49.30.838-50740 Fax -450740
Zentraleinrichtung fuer Datenverarbeitung, Central Systems (Unix)
Freie Universitaet Berlin, Fabeckstrasse 32, 14195 Berlin, DE


------------------------------------------------------------------------------
New Year. New Location. New Benefits. New Data Center in Ashburn, VA.
GigeNET is offering a free month of service with a new server in Ashburn.
Choose from 2 high performing configs, both with 100TB of bandwidth.
Higher redundancy.Lower latency.Increased capacity.Completely compliant.
http://p.sf.net/sfu/gigenet
-----
squirrelmail-plugins mailing list
Posting guidelines: http://squirrelmail.org/postingguidelines
List address: [hidden email]
List archives: http://news.gmane.org/gmane.mail.squirrelmail.plugins
List info (subscribe/unsubscribe/change options): https://lists.sourceforge.net/lists/listinfo/squirrelmail-plugins

smime.p7s (7K) Download Attachment
Loading...