SOLVED Call to undefined function eregi

canou83

Well-Known Member
Jul 20, 2016
78
7
8
France
cPanel Access Level
Website Owner
Hello, I have a site that runs and must launch a CRON task all X periods.
This task imports orders into a commercial administration software.

This one is in PHP 5.6 php-fpm on easyapache4

The import of the commands in manual works, but in automatic, task CRON I have this error:

Fatal error: Uncaught Error: Call to undefined function eregi() in /home/xxxxx/public_html/scripts/ecommerce/ws_import.php:32
Stack trace:
#0 {main}
thrown in /home/xxxxx/public_html/scripts/ecommerce/ws_import.php on line 32
Import end dim. mars 18 10:50:02 CET 2018

Line 32 of this file is:

Code:
if (eregi ('([^ \\\ /] +) $', $ script_file, $ reg)) $ script_file = $ reg [1];
Thanks for your help
 

rpvw

Well-Known Member
Jul 18, 2013
1,101
459
113
UK
cPanel Access Level
Root Administrator
The ereg(i) function was DEPRECATED in PHP 5.3.0, and REMOVED in PHP 7.0.0.

You probably should upgrade or rewrite the script to one that uses preg_match instead of eregi

An alternative is to ask your webhost to install a PHP 5.2 version if it is not already available to you, and switch to that.

If your orders > import > administration software principally run on a PHP version higher than 5.2, you will be better using the highest recommended PHP version for the orders and admin software, and re-writing the importation routines to be compatible.

This is not really a cPanel issue, and you will probably get better help from forums like eg Stack Overflow
 
Last edited:
  • Like
Reactions: cPanelMichael

sparek-3

Well-Known Member
Aug 10, 2002
2,007
222
368
cPanel Access Level
Root Administrator
Is this a piece of software that you wrote or that you obtained from some where else (free, commercially licensed, etc)?

If it's something you obtained from some where else, then the script is outdated or abandoned. You need to update the script to the latest version since this version of the script is obviously not written for modern PHP versions and likely has many other security holes that malicious users may be able to abuse. If you are using the latest version, then the script is likely abandoned by it's developer because eregi() has been deprecated for some time. Any developer worth their weight would have resolved this years ago.
 
  • Like
Reactions: cPanelMichael

kdean

Well-Known Member
Oct 19, 2012
369
61
78
Orlando, FL
cPanel Access Level
Root Administrator
Barring updating the code, it's likely that your command line php is just running a later version than the site.

If your cron starts with php or /usr/bin/php or similar you can try changing it to:

/opt/cpanel/ea-php56/root/usr/bin/php

to specifically use the same version as your site.
 
  • Like
Reactions: rpvw

rpvw

Well-Known Member
Jul 18, 2013
1,101
459
113
UK
cPanel Access Level
Root Administrator
I'm going to hazard a guess the file in question is the one detailed at FHenry/speedealing and which would seem to have been first committed to github circa 2011

Perhaps the author can provide you with an up-to-date version - or help you bring your version up-to-date.

The previous suggestion from kdean does rather have some value although I wonder if you shouldn't be calling the PHP 5.2 bianry for the cron job (assuming it is available) if you don't want to get continual error messages.
 
Last edited: