Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Function ereg_replace() is deprecated


ianric

Recommended Posts

  • Replies 137
  • Created
  • Last Reply

A few depreciated lines I found - errors when using edit orders

 

$city = split (',', $zip_up);

becomes either

$city = preg_split ('/,/', $zip_up);

or

$city = explode (',', $zip_up);

 

Likewise,

$city = split (',', $zip_up);

becomes

$city = explode (',', $zip_up);

 

$dept_allow = split("[, ]", $codep['configuration_value']);

becomes

$dept_allow = preg_split("/[, ]/", $codep['configuration_value']);

 

$country_zones = split("[,]", $countries_table);

becomes

$country_zones = explode (",", $countries_table);

 

Anyone knows the changes for this?

Trivial, aren't they? Use explode() if it's a single fixed character or string, use preg_split() if it's a regular expression.

Link to comment
Share on other sites

im lost with the new preg function, can anyone help me with these following statements?

 

if ( eregi('cPath', $params) ){

becomes

if ( preg_match('/cPath/i', $params) ){

 

		$pattern = $this->attributes['SEO_REMOVE_ALL_SPEC_CHARS'] == 'true'
					?	"([^[:alnum:]])+"
					:	"([[:punct:]])+";
	$anchor = ereg_replace($pattern, '', strtolower($string));
	$pattern = "([[:space:]]|[[:blank:]])+";
	$anchor = ereg_replace($pattern, '-', $anchor);

becomes

		$pattern = $this->attributes['SEO_REMOVE_ALL_SPEC_CHARS'] == 'true'
					?	"/([^[:alnum:]])+/"
					:	"/([[:punct:]])+/";
	$anchor = preg_replace($pattern, '', strtolower($string));
	$pattern = "/([[:space:]]|[[:blank:]])+/";
	$anchor = preg_replace($pattern, '-', $anchor);

 

			case (@eregi("(".@implode('|', $pattern).")", $this->uri)):
			$this->need_redirect = true;
			break;
		case (@eregi("(".@implode('|', $pattern).")", $this->path_info)):

becomes

			case (@preg_match("~(".@implode('|', $pattern).")~i", $this->uri)):
			$this->need_redirect = true;
			break;
		case (@preg_match("~(".@implode('|', $pattern).")~i", $this->path_info)):

Note that this assumes that none of the $pattern strings contain a tilde ~. If they do, #, /, ! are alternate delimiters you can use. Worst case, if you have no idea what the $pattern will contain, you will need to add code to scan through $pattern and replace ~ by \~ in the original $pattern.

 

I'm not going any further back in time in this thread. If someone is still waiting for an answer, repost your question.

Link to comment
Share on other sites

  • 7 months later...

Hello,

 

It seems that my website is useless due to some errors. It's impossible to buy products, add to cart, etc, etc.

 

INDEX

Accessing the "index" page, I get these errors:

Warning: session_save_path() [function.session-save-path]: SAFE MODE Restriction in effect. The script whose uid/gid is 4408/4393 is not allowed to access /tmp owned by uid/gid 0/0 in /includes/functions/sessions.php on line 169

 

Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /includes/functions/sessions.php:169) in /includes/functions/sessions.php on line 102

 

After some searches I could repair this warnings by changing a row at the table configuration of my DB:

 

Column Column Column

FROM: Session Directory SESSION_WRITE_DIRECTORY /tmp

TO: Session Directory SESSION_WRITE_DIRECTORY SESSION_WRITE_DIRECTORY

 

 

BUY NOW

When I click the "buy now" button, I get another error:

Deprecated: Function ereg() is deprecated in /includes/functions/general.php on line 1096

 

Warning: Cannot modify header information - headers already sent by (output started at /includes/functions/sessions.php:169) in /includes/functions/general.php on line 36

 

More searches and I could fix it by replacing the line 1096 like this:

FROM:

if (ereg('^[0-9]$', $char)) $rand_value .= $char;

TO:

if (preg_match('{^[0-9]$}', $char)) $rand_value .= $char;

 

 

My main question is: am I doing the right fixes or have I being lucky till now?

The more I fix errors, the more they appear...

Is it right? Is my website so out-dated?

 

 

Thank you

E-commerce?

No external links please.

Link to comment
Share on other sites

Try looking in the add-ons section and github there are complete lists of all the changes required.

 

HTH

 

G

Need help installing add ons/contributions, cleaning a hacked site or a bespoke development, check my profile

 

Virus Threat Scanner

My Contributions

Basic install answers.

Click here for Contributions / Add Ons.

UK your site.

Site Move.

Basic design info.

 

For links mentioned in old answers that are no longer here follow this link Useful Threads.

 

If this post was useful, click the Like This button over there ======>>>>>.

Link to comment
Share on other sites

  • 4 weeks later...

Could I get a confirmation please, I dont feel like breaking paypal :)

 

if (!ereg("([C-E]{2})-([A-Z0-9]{17})", $_SESSION['paypal_ec_token'])) {

becomes

if (!preg_match("/([C-E]{2})-([A-Z0-9]{17})/", $_SESSION['paypal_ec_token'])) {

 

cool?

-Dave

Link to comment
Share on other sites

  • 1 month later...

Can anyone help me fix this one in headertags.php?

 

$pageName = ucwords(ereg_replace("[^A-Za-z0-9]", " ", $pageName));

 

Thanks in advance!

 

 

$pageName = ucwords(preg_replace("/[^A-Za-z0-9]/", " ", $pageName));

Link to comment
Share on other sites

Can someone tell me how i fix this?

 

 

function makeActiveLink($originalString){

 

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

return $newString;

}

 

 

Thanks in advance!

Link to comment
Share on other sites

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

becomes

$newString = preg_replace("~[[:alpha:]]+://[^<>[:space:]]+[[:alnum:]/]~","<a href=\"\\0\" target=\"_blank\">\\0</a>", $originalString);

Link to comment
Share on other sites

  • 3 months later...

Anyone interested, for the tracking module line 74

 

$text = eregi("$StartGrab(.*)$EndGrab", $grab_data, $content);

 

becomes

$text = preg_match("/$StartGrab(.*)$EndGrab/i", $grab_data, $content);

Getting the Phoenix off the ground

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...