-4

Deprecated: Function eregi() is deprecated in /home/hjlhvqyy/public_html/fastseoindia/klib/class.kValidate.php on line 107

Deprecated: Function eregi() is deprecated in /home/hjlhvqyy/public_html/fastseoindia/klib/class.kValidate.php on line 109

Deprecated: Function eregi() is deprecated in /home/hjlhvqyy/public_html/fastseoindia/klib/class.kValidate.php on line 110

Deprecated: Function eregi() is deprecated in /home/hjlhvqyy/public_html/fastseoindia/klib/class.kValidate.php on line 111

Deprecated: Function ereg() is deprecated in /home/hjlhvqyy/public_html/fastseoindia/klib/class.kValidate.php on line 92

below is code

function is_email($string) 
{
    $string = trim($string);
    $result = ereg(
        '^([A-Za-z0-9_!]|\\-|\\.)+'. 
        '@'.
        '(([A-Za-z0-9_]|\\-)+\\.)+'.
        '[A-Za-z]{2,4}$',
        $string
    ); //line 92

    return($result);
}

function is_url($urladdr)
{
    $regexp = "^(https?://)";
    $regexp .= "?(([0-9a-z_!~*'().&=+$%-]+:)?[0-9a-z_!~*'().&=+$%-]+@)?";
    $regexp .= "(([0-9]{1,3}\.){3}[0-9]{1,3}";
    $regexp .= "|";
    $regexp .= "([0-9a-z_!~*'()-]+\.)*";
    $regexp .= "([0-9a-z][0-9a-z-]{0,61})?[0-9a-z]\.";
    $regexp .= "[a-z]{2,6})";
    $regexp .= "(:[0-9]{1,4})?";
    $regexp .= "((/?)|";
    $regexp .= "(/[0-9a-z_!~*'().;?:@&=+$,%#-]+)+/?)$";

    if (eregi( $regexp,$urladdr )) { // line 107
        if (!eregi( "^https?://",$urladdr )) {
            $urladdr = "http://".$urladdr; //line 109
        }

        if (!eregi( "^https?://.+/",$urladdr )) { // line 110
            $urladdr .= "/";
        }

        if ((eregi( "/[0-9a-z~_-]+$",$urladdr)) && (!eregi( "[\?;&=+\$,#]",$urladdr))) {
            $urladdr .= "/";
        }

        return ($urladdr);
    } else  {
        return false;
    }
}

please.... this code is work but after refresh... it saved... but on when we click on save button it show this warning then after refresh the page it works.... means directly save the settings

Community
  • 1
  • 1

3 Answers3

1

Well, the error pretty much says it all - the function ereg() has been deprecated, you should replace it with preg_match.

Pankucins
  • 1,690
  • 1
  • 16
  • 25
  • thank you it worked in line 109, 110 & 111 but when i set it on line 92 with preg_match() it give error for mail id is invalid and for line 107 it give url is invalid... plz help – saiyyedfardeen Nov 05 '13 at 07:46
  • If you're running PHP version 5.2 or higher, why not use http://php.net/manual/en/function.filter-var.php ? That's what I'd go for, otherwise I can't help you with the regular expressions at the moment, sorry. – Pankucins Nov 05 '13 at 07:52
  • `"my friend i'm not a developer`". Then you probably need to hire one. – vascowhite Nov 05 '13 at 08:41
  • okey... if you not solving my problem then why all are giving votes down to my question.... huh??? – saiyyedfardeen Nov 05 '13 at 08:45
  • @saiyyedfardeen because it is a very bad question. Basically you dumped some old code and asked us to fix it. Stackoverflow doesn't work like that. You need to try something, before trying you need to learn. So if you can't develop then start learning. If you don't want to learn then stop posting bad questions. You will prevent downvotes and save us some time/facepalms. – HamZa Nov 05 '13 at 08:51
  • it is done...... I just configured my my config.php and it words.... – saiyyedfardeen Nov 05 '13 at 08:57
1

The patterns for preg_match need delimiters. I suggest () for them. After the closing delimiter you can provide options like "i" for case insensitive matches

function is_email($string) 
{
    $string = trim($string);
    $result = preg_match(
        '(
          ^([A-Za-z0-9_!]|\\-|\\.)+
          @
          (([A-Za-z0-9_]|\\-)+\\.)+
          [A-Za-z]{2,4}$
        )Dx',
        $string
    ); //line 92  
    return($result);
}  
function is_url($urladdr)
{
    $regexp = "(
      ^(https?://)
      ?(([0-9a-z_!~*'().&=+$%-]+:)?[0-9a-z_!~*'().&=+$%-]+@)?
      (([0-9]{1,3}\.){3}[0-9]{1,3}
      |
      ([0-9a-z_!~*'()-]+\.)*
      ([0-9a-z][0-9a-z-]{0,61})?[0-9a-z]\.
      [a-z]{2,6})
      (:[0-9]{1,4})?
      ((/?)|
      (/[0-9a-z_!~*'().;?:@&=+$,%#-]+)+/?)$
      )Dix";  
    if (preg_match( $regexp,$urladdr )) { // line 107
        if (!preg_match( "(^https?://)Di",$urladdr )) {
            $urladdr = "http://".$urladdr; //line 109
        }  
        if (!preg_match( "(^https?://.+/)Di",$urladdr )) { // line 110
            $urladdr .= "/";
        }  
        if ((preg_match( "(/[0-9a-z~_-]+$)Di",$urladdr)) && (!preg_match( "([\?;&=+\$,#])Di",$urladdr))) {
            $urladdr .= "/";
        }  
        return ($urladdr);
    } else  {
        return false;
    }
}
ThW
  • 19,120
  • 3
  • 22
  • 44
0

You can use the char "@" to avoid the warning (but it's not recomended):

$result = @ereg();

The best option is replace with the function preg_match().

joan16v
  • 5,055
  • 4
  • 49
  • 49