0

the same error has propped up within these admincp files i am trying to set up on my server. how can i resolve them?

Deprecated: Function eregi() is deprecated in C:\xampp\htdocs\speedyautos\admincp\system_cls.php on line 152 (lines 152-155 shown)

if (!eregi("install", $_SERVER['REQUEST_URI']) && !eregi("install", $_SERVER['PHP_SELF']))
                {
                                exit("No " . TABLE_PREFIX . "db.php Present. Please run Install first");
                }

Deprecated: Function eregi() is deprecated in C:\xampp\htdocs\speedyautos\admincp\system_cls.php on line 177 (lines 177-184 shown)

if (!eregi("install", $_SERVER['REQUEST_URI']) && !eregi("install", $_SERVER['PHP_SELF']) && !eregi("upgrade", $_SERVER['PHP_SELF']) && !eregi("admincp", $_SERVER['REQUEST_URI']) && !eregi("searchjs.php", $_SERVER['REQUEST_URI']) && !eregi("locationjs.php", $_SERVER['REQUEST_URI']))
{
                register_shutdown_function("SysTime");
                if (!verifysession() && ($SystemInfo->_systemstatus['User_Signup'] != "F" || $SystemInfo->_systemstatus['Seller_Signup'] != "F" || $SystemInfo->_systemstatus['Dealer_Signup'] != "F"))
                {
                                eval("\$loginlink = \"" . $Template->gettemplate("register_link") . "\";");
                }
}

Deprecated: Function eregi() is deprecated in C:\xampp\htdocs\speedyautos\admincp\func.php on line 447 (lines 442-451 shown)

if (!$GLOBALS['noshutdownfunc'])
                {
                                register_shutdown_function("CleanSessionTbl");
                }

} elseif (!eregi("install", $_SERVER['REQUEST_URI']) AND !eregi("install", $_SERVER['PHP_SELF']))
{
                echo "Please delete the install.php file";
                exit;
}

many thanks in advance!

methuselah
  • 12,766
  • 47
  • 165
  • 315
  • Canonical Question: [Converting ereg expressions to preg](http://stackoverflow.com/questions/6270004/converting-ereg-expressions-to-preg) – hakre May 04 '12 at 00:40

5 Answers5

3

Normally, you should use the preg_* family of regular expression matching. However, most of your ereg calls actually just search case insensitive. Instead of

!eregi("install", $_SERVER['PHP_SELF'])

use

stripos($_SERVER['PHP_SELF'], 'install') === false

. With preg_match, this would look like this:

!preg_match('/install/i', $_SERVER['PHP_SELF'])
phihag
  • 278,196
  • 72
  • 453
  • 469
1

Change eregi("install", $_SERVER['REQUEST_URI']) to preg_match("/install/i", $_SERVER['REQUEST_URI']).

smottt
  • 3,272
  • 11
  • 37
  • 44
1

Your concerns come a bit late. These functions have been deprecated since around PHP4. It's just the error messages which are new. If that's all you care about, then set error_reporting() or the error_level in the php.ini

You can convert almost any ereg() function into a preg_match() by simply adding some /regex/ delimiters. In your specific examples you can however just use stripos() by switching the arguments:

 stripos($_SERVER['REQUEST_URI'], "install")
mario
  • 144,265
  • 20
  • 237
  • 291
1

If that's all the regex you use with eregi, use strpos:

if (strpos($string_to_search_in, "install") === FALSE)  // Notice the three =
     echo("not found :(");
else
     echo("Found!");

If you use a more advanced regex you can do strtolower in the strings where you search in before the regexp's call.

Terseus
  • 2,082
  • 15
  • 22
1

It looks like the code you're trying to use was designed for an older version of PHP.

Your best bet is going to be contacting the author and asking for a bug fix.

Failing that, if you're feeling adventurous and want to dive into the wonderful world of regexes, you can go through every single file and convert the eregi calls to preg_match calls, taking into account the different syntax that PCRE has compared to POSIX regular expressions. It looks like a few of these are abusing regexes, and can be replaced with more simple string matches, like stripos.

If that seems like a bit much work, you can also change the error_reporting level to exclude E_DEPRECATED. You can do this at the script level, or at the PHP configuration level. I'd recommend doing it at the script level -- chances are that there's a call to error_reporting somewhere in the init routines.

Charles
  • 50,943
  • 13
  • 104
  • 142