Skip to contentSkip to conversation

ereg() removed in PHP 7.0

PATCH New Chris Knadle 1 participant 1 message May 24, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ereg() removed in PHP 7.0

Debian is transitioning from PHP 5 to PHP 7.0, and PHP 5 is soon to be removed. The current mlmmj PHP code has 2 to calls to ereg() functions which were deprecated in PHP 5.3.0 and removed from PHP 7.0.0, thus requiring modification. Attached is a patch that does this.

Note that the regex in contrib/web/php-user/mlmmj.php for matching email addresses could also use updating to allow for the full range of special characters that are allowed in email addresses:

https://tools.ietf.org/html/rfc5322#section-3.4.1

Right now it looks like these special characters might not be accepted by the regex AFAICT:
! # $ % & ' * + / = ? ^ ` { | } ~

Thanks
-- Chris

Signature · 2 lines
Chris Knadle
[email protected]

Description: Update for PHP 5 -> PHP 7 transition
ereg() and eregi() were deprecated with PHP 5.3.0 and removed in PHP 7.0.0
https://secure.php.net/manual/en/function.ereg.php
https://secure.php.net/manual/en/function.eregi.php
Also remove min 2, max 4 character TLD portion of regex, as there are top-level domains > 4 chars now.
Thanks to Ron Guerin <[email protected]> for his help with the PHP regexes.
Author: Christopher Knadle <[email protected]>
Bug-Debian: https://bugs.debian.org/821532
Bug-Debian: https://bugs.debian.org/821533
Last-Updated: 2016-05-22

contrib/web/php-user/mlmmj.php +1 -1
@@ -37,7 +37,7 @@
 
     function is_email($string="") 
 	{
-	    if (eregi("^[a-z0-9\._-]+".chr(64)."+[a-z0-9\._-]+\.+[a-z]{2,4}$", $string)) 
+	    if (preg_match(chr(7)."^[a-z0-9\._-]+@+[a-z0-9\._-]+\.+[a-z]+$".chr(7).'i', $string)) 
 	    { 
 		return TRUE; 
 	    }
contrib/web/php-admin/htdocs/index.php +1 -1
@@ -37,7 +37,7 @@
 
 # use scandir to have alphabetical order
 foreach (scandir($topdir) as $file) {
-    if (!ereg("^\.",$file))
+    if (substr($file,0,1) != '.')
     {
 	$lists .= "<p>".htmlentities($file)."<br/>\n";
 	$lists .= "<a href=\"edit.php?list=".urlencode($file)."\">Config</a> - <a href=\"subscribers.php?list=".urlencode($file)."\">Subscribers</a>\n";