Solved

PHP error in code - Function eregi() is deprecated

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Finding (and replacing) text between two strings in Php 7 50
help with PHP array/lists 3 38
Please show me easiest post form. 3 31
Mysql sync between 3-4 mysql db 4 23
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…
I imagine that there are some, like me, who require a way of getting currency exchange rates for implementation in web project from time to time, so I thought I would share a solution that I have developed for this purpose. It turns out that Yaho…
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.

939 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

10 Experts available now in Live!

Get 1:1 Help Now