• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 486
  • Last Modified:

PHP error in code - Function eregi() is deprecated

Hi,
I am receiving a PHP error after upgrade to PHP 5.3 as below.

Any ideas on what I should change the code too would be appreciated.

Thanks,

Andrew

Deprecated: Function eregi() is deprecated in /home/entertai/public_html/news/wp-content/plugins/captcha/captcha.php on line 1360

// Avoid being called directly
if (eregi(basename(__FILE__),$_SERVER['PHP_SELF'])) {
	echo '<html><body>';
	echo 'Direct module access forbidden. <br />';
	echo 'Captcha! extension v', Captcha::version(), ' for WordPress by <a href="http://www.boriel.com">Boriel</a> <br />';
	echo '</body></html>';
    exit;
}

Open in new window

0
sabecs
Asked:
sabecs
  • 2
1 Solution
 
Dave BaldwinFixer of ProblemsCommented:
preg_match http://us2.php.net/manual/en/function.preg-match.php is the recommended replacement.  It is not identical though, you will have to make some changes in your regex strings.  Referenced from http://us2.php.net/manual/en/function.eregi.php

That must be some old code to still have that.  You might want to look at a possible upgrade.
0
 
sabecsAuthor Commented:
Thanks Dave, following code worked.

$file = basename(__FILE__);      
if(preg_match("/".preg_quote($file)."/i",$_SERVER['PHP_SELF'])) {      
      echo '<html><body>';
      echo 'Direct module access forbidden. <br />';
      echo 'Captcha! extension v', Captcha::version(), ' for WordPress by <a href="http://www.boriel.com">Boriel</a> <br />';
      echo '</body></html>';
    exit;
}
0
 
Dave BaldwinFixer of ProblemsCommented:
You're welcome, glad to help.
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now