Solved

PHP error in code - Function eregi() is deprecated

Posted on 2013-05-12
3
472 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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
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.

732 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