Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Function ereg_replace() is deprecated


ianric

Recommended Posts

5.3 does no more than create deprecated notices if you came from a decent PHP5.2.X

 

Having said that the build could have done "the usual" in as much as register_globals off, register_long_arrays off.

 

Have you checked those?

 

I just recompiled back to php5.2.12 and everything is working again. I already had register_globals off with php 5.2 but have to check register_long_arrays which I just did and it is nowhere to be found even on php5.2.12.

 

Do you have a list of all the files to be changed for php 5.3? I am lost at github.

 

Thanks!

Link to comment
Share on other sites

  • Replies 137
  • Created
  • Last Reply

my host has upgraded to 5.3.1 and i started to make the changes to fix the problems but then noticed that there were other issues like sessions being recreated on every click, items cant be added to cart, carts which have items get as far as selecting the shipping method and page is just refreshed when clicking continue and the same thing happens when trying to submit the contact us form for example.

 

Just to be sure that it wasn't anything i'd changed i upgraded my testing server to the same versions of php, apache and mysql as my host is using and created a completely clean install using the already modified files that are in this thread and i still have the same problem.

 

Also since i've upgraded my testing server the host has changed to 5.2.12 and the problems still exist

 

Any ideas whats going wrong here?

 

Thanks, Scott

Scott

Link to comment
Share on other sites

my host has upgraded to 5.3.1 and i started to make the changes to fix the problems but then noticed that there were other issues like sessions being recreated on every click, items cant be added to cart, carts which have items get as far as selecting the shipping method and page is just refreshed when clicking continue and the same thing happens when trying to submit the contact us form for example.

 

Just to be sure that it wasn't anything i'd changed i upgraded my testing server to the same versions of php, apache and mysql as my host is using and created a completely clean install using the already modified files that are in this thread and i still have the same problem.

 

Also since i've upgraded my testing server the host has changed to 5.2.12 and the problems still exist

 

Any ideas whats going wrong here?

 

Thanks, Scott

 

Well before you start getting toooooo worried Scott remember that those errors that are kicking out will also cause tep_redirect to fail as headers will already have been sent.

 

Initially you could try the error_reporting thing that I mentioned to Melinda a few posts above you may find that without the errors those functions may work again.

Link to comment
Share on other sites

Anyone that is having problems with PHP 5.3 it would be useful if you could download the snapshot from github with the changes in and test as a clean install, if the problem still persists then I will need more info on your server configuration etc.

Mark Evans

osCommerce Monkey & Lead Guitarist for "Sparky + the Monkeys" (Album on sale in all good record shops)

 

---------------------------------------

Software is like sex: It's better when it's free. (Linus Torvalds)

Link to comment
Share on other sites

Anyone that is having problems with PHP 5.3 it would be useful if you could download the snapshot from github with the changes in and test as a clean install, if the problem still persists then I will need more info on your server configuration etc.

 

Yeah i have problems with the clean install from github, let me know what i can do to help.

 

Scott

Scott

Link to comment
Share on other sites

Well before you start getting toooooo worried Scott remember that those errors that are kicking out will also cause tep_redirect to fail as headers will already have been sent.

 

Initially you could try the error_reporting thing that I mentioned to Melinda a few posts above you may find that without the errors those functions may work again.

 

I'm not actually getting any errors coming up as the github install 'seems' to have them fixed its just the other problems as memtioned in my original post that i'm getting with all my installs (3 live, same 3 local and a fresh local), i did try your suggestion though just in case and it made no difference.

 

I would imagine that most of the issues i have relate to the session issue where i new session is created everytime a link is clicked but i dont know enough about this kind of stuff to say thats definitly the case.

Scott

Link to comment
Share on other sites

mysql 5

php 5.2.12

 

I changed the github files according to Harald's edits and did not run a fresh install but just copied the files over and everything is ok except the admin/tools/cache section.

 

Warning: preg_match() [function.preg-match]: Unknown modifier 'c' in /home/designus/public_html/rc2/admin/cache.php on line 94

 

I have tried several different things for that one line:

 

if (preg_match('/^/' . $cached_file_unlink, $cache_file)) {
if (preg_match('/^' . $cached_file_unlink, $cache_file)) {

 

and it gives me tons of errors on the cache page and at the very bottom I get this error whenever I click one of those cache triangles:

Warning: Cannot modify header information - headers already sent by (output started at /home/designus/public_html/rc2/admin/includes/functions/general.php:942) in /home/designus/public_html/rc2/admin/includes/functions/general.php on line 22

 

Now, I haven't updated to php 5.3.1 again because we had so many problems yesterday but thought I would check it on php 5.2.12. Probably doesn't help to know but wanted to see if the ereg and eregi changes would be affected.

 

If there are not any updates for 2.2rc2a for problems like this then how does a business person use an unreliable program when keeping their server updated?

Link to comment
Share on other sites

I have tried several different things for that one line:

 

don't assume i'm right on this as i've not tried it but i'm fairly sure the / needs to be at the beginning and the end of the string which would make it

if (preg_match('/^' . $cached_file_unlink . '/', $cache_file)) {

Scott

Link to comment
Share on other sites

That line change removed the errors from the main cache page but when you click on any of those triangles all the errors come back.

 

Also, I am not getting response emails from the forum.

Link to comment
Share on other sites

@ProdigyMotorsport is correct in the fix. Take what's in the github listings with many grains of salt. If you are careful to read through everything, there are many iterations of fixes there -- fixes applied to fixes applied to fixes. Make sure you have all of them in place before proceeding. Read http://www.oscommerce.com/forums/topic/341737-function-ereg-replace-is-deprecated/page__view__findpost__p__1447311 and http://www.oscommerce.com/forums/topic/342525-page-script-error/page__p__1430745entry1430745 to be sure you've found all the references and fixes.

Link to comment
Share on other sites

I cannot possibly help my clients with this kind of updating and trying to fix something that should have been updated long ago.

 

I will leave the php 5.2.12 on for now.

Link to comment
Share on other sites

Yeah i have problems with the clean install from github, let me know what i can do to help.

 

Scott

 

To diagnose further I will need to have your server configuration info and also how you have configured osCommerce.. for example sessions in db or filesystem?

 

If you can get me the output of phpinfo() and also your configure.php files with the passwords etc removed and then uploaded them as a zip or tar file then PM me the link I will see if I can recreate the problem.

Mark Evans

osCommerce Monkey & Lead Guitarist for "Sparky + the Monkeys" (Album on sale in all good record shops)

 

---------------------------------------

Software is like sex: It's better when it's free. (Linus Torvalds)

Link to comment
Share on other sites

I put

 

<?php

phpinfo();

?>

 

in a .php page and now get this:

 

Warning: phpinfo() has been disabled for security reasons in /home/designus/public_html/php.php on line 2

 

What is wrong?

Link to comment
Share on other sites

I put

 

<?php

phpinfo();

?>

 

in a .php page and now get this:

 

Warning: phpinfo() has been disabled for security reasons in /home/designus/public_html/php.php on line 2

 

What is wrong?

Hi you can get server info from admin>tools>server info

 

Steve

Link to comment
Share on other sites

mysql 5

php 5.2.12

 

I changed the github files according to Harald's edits and did not run a fresh install but just copied the files over and everything is ok except the admin/tools/cache section.

 

 

 

I have tried several different things for that one line:

 

 

 

 

and it gives me tons of errors on the cache page and at the very bottom I get this error whenever I click one of those cache triangles:

 

 

Now, I haven't updated to php 5.3.1 again because we had so many problems yesterday but thought I would check it on php 5.2.12. Probably doesn't help to know but wanted to see if the ereg and eregi changes would be affected.

 

If there are not any updates for 2.2rc2a for problems like this then how does a business person use an unreliable program when keeping their server updated?

 

Hi if there is already a / in the criteria add a before it \

 

ie '/a-f'

 

becomes

'/\/a-f'

 

Steve

Link to comment
Share on other sites

Hi all,

 

Can anyone help out with this

i changed

<?php if (eregi('^(.*)' . tep_session_name() . '=[a-f,0-9]+[&]*(.*)', $whos_online['last_page_url'], $array)) { echo $array[1] . $array[2]; } else { echo $whos_online['last_page_url']; } ?>

 

to

<?php if (preg_match('/^(.*)/i' . tep_session_name() . '=[a-f,0-9]+[&]*(.*)', $whos_online['last_page_url'], $array)) { echo $array[1] . $array[2]; } else { echo $whos_online['last_page_url']; } ?>

 

but i get this warning

 

PHP Warning: preg_match(): Unknown modifier 'o' in /srv/www/htdocs/store/admin/index.php im using a modified index.php

 

Steve

Hi

 

Big Thanks to all those who replied to my post above

 

Steve

Link to comment
Share on other sites

The tools/server info does not show the php info any longer for some reason.

 

Steve what is this for?

 

Hi if there is already a / in the criteria add a before it \

ie '/a-f'

becomes
'/\/a-f'

Link to comment
Share on other sites

The tools/server info does not show the php info any longer for some reason.

 

Steve what is this for?

 

Hi if there is already a / in the criteria add a before it \

ie '/a-f'

becomes
'/\/a-f'

here is an example below from checkout_process.php

as you can see it already has / in it so we have to add backslash so it is not read as the end delimiter ie

 

$email_order=ereg_replace("[[:alpha:]]+://[^<>[:space:]]+[[:alnum:]/]","<a href=\"\\0\">\\0</a>", $email_order);

becomes

$email_order=preg_replace("/[[:alpha:]]+:\/\/[^<>[:space:]]+[[:alnum:]\/]/","<a href=\"\\0\">\\0</a>", $email_order);

or even better use | as delimiters

$email_order=preg_replace("|[[:alpha:]]+://[^<>[:space:]]+[[:alnum:]/]|","<a href=\"\\0\">\\0</a>", $email_order);

 

Steve

Link to comment
Share on other sites

Hi,

 

I am going through pci compliance checks and had to update my pho veriosn so now all the old ereg are not accepted.

 

I have found a fair few alread and replaced them.

 

I am now stuggling with the gift module and the following in classes shopping_cart.php

 

 

if (ereg('^GIFT', $gv_result['products_model'])) {

 

I need to know what I would convert this to, can anyone please advise.

 

Thanks

Getting better with mods but no programmer am I.

Link to comment
Share on other sites

What's there to struggle over? Change this "ereg" just like all the others --

if (ereg('^GIFT', $gv_result['products_model'])) {

becomes

if (preg_match('/^GIFT/', $gv_result['products_model'])) {

Link to comment
Share on other sites

lol when you dont know how to drive a car you maybe able to start the engine but doesnt mean you can drive it properly...lol

 

I dont know what the protocl is supposed to be.

 

 

Thanks

Hi Johnny,

 

This might help you out

 

To migrate ereg():

 

ereg('\.([^\.]*$)', $this->file_src_name, $extension);

 

becomes

 

preg_match('/\.([^\.]*$)/', $this->file_src_name, $extension);

 

Notice that I wrapped the pattern (\.([^\.]*$)) around / /, which are RegExp delimiters. If you find yourself escaping / too much (for an URL for example), you might want to use the # delimiter instead.

 

To migrate ereg_replace():

$this->file_dst_name_body = ereg_replace('[^A-Za-z0-9_]', '', $this->file_dst_name_body);

 

becomes

 

$this->file_dst_name_body = preg_replace('/[^A-Za-z0-9_]/', '', $this->file_dst_name_body);

 

Again, I just added delimiters to the pattern.

If you are using eregi functions (which are the case-insensitive version of ereg), you’ll notice there’re no equivalent pregi functions. This is because this functionality is handled by RegExp modifiers.

 

Basically, to make the pattern match characters in a case-insensitive way, append i after the delimiter:

 

eregi('\.([^\.]*$)', $this->file_src_name, $extension);

 

becomes

preg_match('/\.([^\.]*$)/i', $this->file_src_name, $extension);

 

full credit to http://www.devthought.com/tumble/2009/06/fix-ereg-is-deprecated-errors-in-php-53/ for making that post

 

Steve

Link to comment
Share on other sites

What's there to struggle over? Change this "ereg" just like all the others --

if (ereg('^GIFT', $gv_result['products_model'])) {

becomes

if (preg_match('/^GIFT/', $gv_result['products_model'])) {

 

and to be totally honest the PCRE engine is being loaded where not necessary.

 

If you just want to check if a string is present you don't use preg_match you use the much faster strpos.

 

if ( false !== strpos( $gv_result['products_model'], 'GIFT' ) ) {

Link to comment
Share on other sites

Deprecated: Function eregi() is deprecated in /path_to_admin/includes/classes/language.php on line 87

 

Deprecated: Function eregi() is deprecated in /path_to_admin/includes/classes/language.php on line 87

 

Deprecated: Function eregi() is deprecated in /path_to_admin/includes/classes/language.php on line 87

 

Deprecated: Function eregi() is deprecated in /path_to_admin/includes/classes/language.php on line 87

 

Deprecated: Function eregi() is deprecated in /path_to_admin/includes/classes/language.php on line 87

 

Deprecated: Function eregi() is deprecated in /path_to_admin/includes/classes/language.php on line 87

 

Warning: Cannot modify header information - headers already sent by (output started at /path_to_admin/includes/classes/language.php:87) in /path_to_admin/includes/functions/general.php

 

 

What shoud i do? it's comming up when im trying to log in.

_______________________________________________________________________________________________________________________-

 

 

Warning: preg_match() [function.preg-match]: No ending delimiter '^' found in /path_to_shop/includes/functions/general.php on line 1129

 

Warning: preg_match() [function.preg-match]: No ending delimiter '^' found in /path_to_shop/includes/functions/general.php on line 1129

 

Warning: preg_match() [function.preg-match]: No ending delimiter '^' found in /path_to_shop/includes/functions/general.php on line 1129

 

Warning: preg_match() [function.preg-match]: No ending delimiter '^' found in /path_to_shop/includes/functions/general.php on line 1129

 

Warning: preg_match() [function.preg-match]: No ending delimiter '^' found in /path_to_shop/includes/functions/general.php on line 1129

 

Warning: preg_match() [function.preg-match]: No ending delimiter '^' found in /path_to_shop/includes/functions/general.php on line 1129

 

 

This is comming up when i am trying to purchase an item..

 

Please help!

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...