Jump to content
Latest News: (loading..)

Archived

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

ianric

Function ereg_replace() is deprecated

Recommended Posts

Everything you need to know: http://us.php.net/manual/en/migration53.deprecated.php

 

$meta_description = ereg_replace('<[^>]*>', '', $product_meta['products_description']);

becomes

$meta_description = preg_replace('/<[^>]*>/', '', $product_meta['products_description']);


If you are running the "official" osC 2.3.4 or 2.3.4.1 download, your installation is obsolete! Get (stable) Frozen or (unstable) Edge. See also the naming convention and the latest community-supported responsive "Edge" release

Share this post


Link to post
Share on other sites

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.


If you are running the "official" osC 2.3.4 or 2.3.4.1 download, your installation is obsolete! Get (stable) Frozen or (unstable) Edge. See also the naming convention and the latest community-supported responsive "Edge" release

Share this post


Link to post
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.


If you are running the "official" osC 2.3.4 or 2.3.4.1 download, your installation is obsolete! Get (stable) Frozen or (unstable) Edge. See also the naming convention and the latest community-supported responsive "Edge" release

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
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 ======>>>>>.

Share this post


Link to post
Share on other sites

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

 

HTH

 

G

where is it?


E-commerce?

No external links please.

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

@@Roaddoctor

 

That looks about right to me

 

 

 

 

Chris


:|: Was this post helpful ? Click the LIKE THIS button :|:

 

See my Profile to learn more about add ons, templates, support plans and custom coding (click here)

Share this post


Link to post
Share on other sites

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));

Share this post


Link to post
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!

Share this post


Link to post
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);


If you are running the "official" osC 2.3.4 or 2.3.4.1 download, your installation is obsolete! Get (stable) Frozen or (unstable) Edge. See also the naming convention and the latest community-supported responsive "Edge" release

Share this post


Link to post
Share on other sites

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);


Thanks to all source contributors, 2.3.4 Edge just works fine

https://github.com/gburton/Responsive-osCommerce/archive/master.zip

Share this post


Link to post
Share on other sites

×