0

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!

chiwangc
  • 3,566
  • 16
  • 26
  • 32

1 Answers1

0

Just add delimiters around the regex:

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

becomes:

preg_replace("~[/\\\\]admin[/\\\\][^/\\\\]+$~", '', __FILE__)
//     here __^                  and here __^
Toto
  • 89,455
  • 62
  • 89
  • 125
  • I've tried that, it doesn't parse the URL.; I think it removes the admin bit from the URL, but I have no clue what the last section of the regex is for. – Gremelin Apr 16 '15 at 14:07
  • @JamesCorthell: Your regex maches: a slash (or backslash) then the literal 'admin' then a slash (or backslash) then anything that is not a slash (or backslash) until the end of the string. – Toto Apr 16 '15 at 14:10