Solved

PHP error in code - Function eregi() is deprecated

Posted on 2013-05-12
3
464 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
  • 2
3 Comments
 
LVL 82

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 82

Expert Comment

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

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Introduction Many web sites contain image galleries; a common design for these galleries includes a page with a collection of thumbnail images.  You can click on each of the thumbnail images to see the larger version of the image.  This is easily i…
These days socially coordinated efforts have turned into a critical requirement for enterprises.
The viewer will learn how to count occurrences of each item in an array.
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.

758 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now