From 59830fc795440fd636865f30cb7ed1e2d29f4a55 Mon Sep 17 00:00:00 2001 From: Thierry Parmentelat Date: Wed, 31 Mar 2010 15:03:52 +0000 Subject: [PATCH] ereg is deprecated in f12 --- drupal-hacks/user.module | 11 +++++++---- planetlab/includes/plc_functions.php | 9 ++++++--- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/drupal-hacks/user.module b/drupal-hacks/user.module index 430e08a..ce3e56f 100644 --- a/drupal-hacks/user.module +++ b/drupal-hacks/user.module @@ -233,8 +233,8 @@ function user_validate_name($name) { if (!strlen($name)) return t('You must enter a username.'); if (substr($name, 0, 1) == ' ') return t('The username cannot begin with a space.'); if (substr($name, -1) == ' ') return t('The username cannot end with a space.'); - if (ereg(' ', $name)) return t('The username cannot contain multiple spaces in a row.'); - if (ereg("[^\x80-\xF7 [:alnum:]@_.-]", $name)) return t('The username contains an illegal character.'); + if (preg_match('/ /', $name)) return t('The username cannot contain multiple spaces in a row.'); + if (preg_match("/[^\x80-\xF7 [:alnum:]@_.-]/", $name)) return t('The username contains an illegal character.'); if (preg_match('/[\x{80}-\x{A0}'. // Non-printable ISO-8859-1 + NBSP '\x{AD}'. // Soft-hyphen '\x{2000}-\x{200F}'. // Various space characters @@ -247,8 +247,11 @@ function user_validate_name($name) { $name)) { return t('The username contains an illegal character.'); } - if (ereg('@', $name) && !eregi('@([0-9a-z](-?[0-9a-z])*.)+[a-z]{2}([zmuvtg]|fo|me)?$', $name)) return t('The username is not a valid authentication ID.'); - if (strlen($name) > 56) return t('The username %name is too long: it must be less than 56 characters.', array('%name' => theme('placeholder', $name))); + if (preg_match('/@/', $name) && !preg_match('/@([0-9a-z](-?[0-9a-z])*.)+[a-z]{2}([zmuvtg]|fo|me)?$/i', $name)) + return t('The username is not a valid authentication ID.'); + if (strlen($name) > 56) + return t('The username %name is too long: it must be less than 56 characters.', + array('%name' => theme('placeholder', $name))); } function user_validate_mail($mail) { diff --git a/planetlab/includes/plc_functions.php b/planetlab/includes/plc_functions.php index 658cc86..9ebf7c9 100644 --- a/planetlab/includes/plc_functions.php +++ b/planetlab/includes/plc_functions.php @@ -223,16 +223,19 @@ function topdomain ($hostname) { return $exploded[0]; } +// with php-5.3 on f12, ereg is marked deprecated, using PCRE instead +// looks unused function is_valid_email_addr ($email) { - if (ereg("^.+@.+\\..+$", $email) ) { + if (preg_match("/^.+@.+\\..+$/", $email) ) { return true; } else { return false; } } +// looks unused function is_valid_url ($url) { - if (ereg("^(http|https)://.+\..+$", strtolower($url) ) ) { + if (preg_match("/^(http|https):\/\/.+\..+$/", strtolower($url) ) ) { return true; } else { return false; @@ -240,7 +243,7 @@ function is_valid_url ($url) { } function is_valid_ip ($ip) { - if (ereg("^([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$", $ip ) ) { + if (preg_match("/^([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/", $ip ) ) { // it's at least in the right format, now check to see if // each part is equal to less than 255 $parts= explode( '.', $ip ); -- 2.43.0