ereg_replace to preg_replace and OpenX

88 views Asked by At

I have a client who is running OpenX (formerly PHPAdsNew), which is no longer being developed, and is not compatible with newer versions of PHP (as ereg and its variants are depreciated); the issue here is that I can't really tell what the ereg is supposed to be replacing to rewrite the line.

The old code is:

define ('phpAds_path', ereg_replace("[/\\\\]admin[/\\\\][^/\\\\]+$", '', __FILE__));

I would be very greatful for anyone's ideas!

1

There are 1 answers

2
Toto On

Just add delimiters around the regex:

ereg_replace("[/\\\\]admin[/\\\\][^/\\\\]+$", '', __FILE__)

becomes:

preg_replace("~[/\\\\]admin[/\\\\][^/\\\\]+$~", '', __FILE__)
//     here __^                  and here __^