Solved

PHP error in code - Function eregi() is deprecated

Posted on 2013-05-12
3
471 Views
Last Modified: 2013-05-12
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
Comment
Question by:sabecs
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 83

Accepted Solution

by:
Dave Baldwin earned 500 total points
ID: 39160377
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
 

Author Closing Comment

by:sabecs
ID: 39160400
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
 
LVL 83

Expert Comment

by:Dave Baldwin
ID: 39160490
You're welcome, glad to help.
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

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.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit (http://en.wikipedia.org/wiki/PHPUnit) and similar technologies have enjoyed wide adoption, making it possib…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question