Browse Source

Merge pull request 'Função ereg do php está obsoleta, usar preg_match' (#14) from bruno/pabx-app:ereg_absoleta into dev

Reviewed-on: SimplesIP/pabx-app#14
Reviewed-by: guilherme.guia <guilherme.guia@simplesip.com.br>
Reviewed-by: douglas.strappasson <douglas.strappasson@simplesip.com.br>
master
bruno 1 year ago
parent
commit
36eca534ae
  1. 4
      include/util/datas.php
  2. 4
      include/util/util.php

4
include/util/datas.php

@ -61,7 +61,7 @@ class CalcDataHora {
switch ($op) { switch ($op) {
case "d": // Padrao: 15/01/2007 case "d": // Padrao: 15/01/2007
$er = "(([0][1-9]|[1-2][0-9]|[3][0-1])\/([0][1-9]|[1][0-2])\/([0-9]{4}))"; $er = "(([0][1-9]|[1-2][0-9]|[3][0-1])\/([0][1-9]|[1][0-2])\/([0-9]{4}))";
if (ereg($er, $data)) { if ( preg_match($er, $data)) {
return 0; return 0;
} else { } else {
return 1; return 1;
@ -69,7 +69,7 @@ class CalcDataHora {
break; break;
case "dh": // Padrao 15/01/2007 10:30:00 case "dh": // Padrao 15/01/2007 10:30:00
$er = "(([0][1-9]|[1-2][0-9]|[3][0-1])\/([0][1-9]|[1][0-2])\/([0-9]{4})*)"; $er = "(([0][1-9]|[1-2][0-9]|[3][0-1])\/([0][1-9]|[1][0-2])\/([0-9]{4})*)";
if (ereg($er, $data)) { if ( preg_match($er, $data)) {
return 0; return 0;
} else { } else {
return 1; return 1;

4
include/util/util.php

@ -40,7 +40,7 @@ function _is_valid($string, $min_length, $max_length, $regex) {
} }
// Does the string entirely consist of characters of $type? // Does the string entirely consist of characters of $type?
if (!eregi("^$regex$", $string)) { if (!preg_match("^$regex$", $string)) {
return(false); return(false);
} }
@ -135,7 +135,7 @@ function contains_bad_words($string) {
function contains_phone_number($string) { function contains_phone_number($string) {
// Check for phone number // Check for phone number
if (ereg("[[:digit:]]{3,10}[\. /\)\(-]*[[:digit:]]{6,10}", $string)) { if (preg_match("[[:digit:]]{3,10}[\. /\)\(-]*[[:digit:]]{6,10}", $string)) {
return(true); return(true);
} }

Loading…
Cancel
Save