Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Function ereg_replace() is deprecated


ianric

Recommended Posts

Yes BUT... with 24 files hit, it's likely that an add-on will fail due to previous file modifications (i.e., you have anything other than vanilla osC). Plus, it takes all of 30 minutes or so if you have a backup copy of your site on your PC (which you should) to search for all the offending function calls and edit them. In the end, no big deal to manually edit the changes. People are welcome to try your add-on, but if they don't have an absolutely vanilla osC, my prediction is that it's likely to fail.

Link to comment
Share on other sites

  • Replies 137
  • Created
  • Last Reply

While this thread stumbles along somewhat aimlessly trying to figure out of to make your current RC2a websites PHP 5.3 compliant, everyone COULD just download the patch notes and the drop on top files for RC2a and spend the time you use posting here to do other things

 

 

Did I mention the patch notes are also included in that contribution so you can make manual edits as well ? <_<

 

 

YES ! I did :blush:

 

 

 

Chris

Link to comment
Share on other sites

  • 3 weeks later...

Yes BUT... with 24 files hit, it's likely that an add-on will fail due to previous file modifications (i.e., you have anything other than vanilla osC). Plus, it takes all of 30 minutes or so if you have a backup copy of your site on your PC (which you should) to search for all the offending function calls and edit them. In the end, no big deal to manually edit the changes. People are welcome to try your add-on, but if they don't have an absolutely vanilla osC, my prediction is that it's likely to fail.

 

I've been reading, with some alarm at first, this thread with interest as I'm about to move to a host who uses PHP 5.3 (from a host that only has 5.0 at the most). So I've been a bit worried about how osC will work and not being experienced at all in PHP I dread having to make manual changes. But, looking at Dunweb's fabulous contribution I think it can be used on a non -Vanilla store, with certain add ons. In case it helps anyone else here's what I've taken a look at:

 

I have the following add ons:

- Complete Review System

- Security Pro

- Sam's Anti-Hacker Mod

- Kiss MT Dynamic SEO Meta Tags

and will be installing

- Download Controller

- Articles Manager

 

Now, looking at the files in those add ons, compared to the files in Dunweb's it appears that only 4 files appear in both add ons: application_top.php, table.php, usps.php,zones.php. I think it would just be a case of comparing those files and carelfully making the required files manually. Then the rest of the files Dunweb's can just be dropped on top as you would for a completely vanilla store.

 

Anyway, that's what I'm hoping will work ;) Gotta do something to make sure the store works:)

 

PS - Do I need to worry about the replacement of $HTTP_GET with $_GET? I saw this mentioned somewhere. There's a tonne of them overall in the store files - couldn't even begin to think of changing them all manually.... >_<

Link to comment
Share on other sites

PS - Do I need to worry about the replacement of $HTTP_GET with $_GET? I saw this mentioned somewhere. There's a tonne of them overall in the store files - couldn't even begin to think of changing them all manually.... >_<

Recent versions of osC (2.2 RC1? and up) have a "compatibility layer" to create $HTTP_GET_VARS from $_GET, if PHP does not supply it. Ditto for POST.

 

If you're changing hosts, inquire as to whether you're also upgrading from MySQL 4 to 5. If so, you'll have to make some patches to fix the JOIN problem.

Link to comment
Share on other sites

it seems there are some ways to fix the errors:

 

1. change ereg_replace() into sprintf()

2. change ereg_replace() into mb_ereg_replace()

3. change ereg_replace() into str_replace()

4. change ereg_replace() into @ereg_replace()

5. change ereg_replace() into preg_match({})

 

but not quite sure difference among them and which code is best for oscommerce?

 

if anyone know it, that would be great.

 

Sean

Link to comment
Share on other sites

Recent versions of osC (2.2 RC1? and up) have a "compatibility layer" to create $HTTP_GET_VARS from $_GET, if PHP does not supply it. Ditto for POST.

 

If you're changing hosts, inquire as to whether you're also upgrading from MySQL 4 to 5. If so, you'll have to make some patches to fix the JOIN problem.

 

Thanks MrPhil. I'm currently using 2.2 RC 2a and MySQL 5,( and my future host is using too), and have not had any problems with it.

Link to comment
Share on other sites

it seems there are some ways to fix the errors:

...

but not quite sure difference among them and which code is best for oscommerce?

Why don't you follow the specific instructions given in this thread (and other threads it points to), rather than trying to figure it out by yourself from scratch?

Link to comment
Share on other sites

Why don't you follow the specific instructions given in this thread (and other threads it points to), rather than trying to figure it out by yourself from scratch?

 

 

Thank you for you words, it really helpful for us to develop contributions from scratch.

Link to comment
Share on other sites

Recent versions of osC (2.2 RC1? and up) have a "compatibility layer" to create $HTTP_GET_VARS from $_GET, if PHP does not supply it. Ditto for POST.

 

If you're changing hosts, inquire as to whether you're also upgrading from MySQL 4 to 5. If so, you'll have to make some patches to fix the JOIN problem.

 

Having looked a bit further into this I've discovered multiple instances of code can easily be changed using Notepad++ (marvellous program!!!). So...am I correct in thinking that I would literally just have to change $HTTP_GET_VARS to $_GET (i.e not have to add any dots, dashes, slashes or anything else anywhere) if I wanted to change to it be sure my store code was up to date?

Link to comment
Share on other sites

Replacing all instances of $HTTP_GET_VARS by $_GET; and all $HTTP_POST_VARS by $_POST, and likewise for $_COOKIE, $_SESSION, $_FILES, $_SERVER; ought to work. I think that's what compatibility.php basically does.

Link to comment
Share on other sites

Replacing all instances of $HTTP_GET_VARS by $_GET; and all $HTTP_POST_VARS by $_POST, and likewise for $_COOKIE, $_SESSION, $_FILES, $_SERVER; ought to work. I think that's what compatibility.php basically does.

 

Thanks so much for the information MrPhil, much appreciated :). I didn't realize that file was there or what it did. Thankfully it means I don't have to make any changes, since the file takes care of it all - and therefore it looks like it should be okay too for PHP6 as apparantely HTTP_*_VARS will definately be gone under it. Of course there might be other changes by then, but we'll deal with that when we get to it - maybe even osC version 3 will be released by then....

Link to comment
Share on other sites

  • 3 weeks later...

Try changing

  function tep_sanitize_string($string) {
$string = ereg_replace(' +', ' ', trim($string));

return preg_replace("/[<>]/", '_', $string);
 }

to

  function tep_sanitize_string($string) {
$string = preg_replace('{ +}', ' ', trim($string));

return preg_replace("/[<>]/", '_', $string);
 }

and see if that does what you want.

 

Hi,

 

I was having the same problem too and made ur suggested change but now my form is telling me I didn't complete the required* fields, when they are actually completed.

Plus I get a black window with hyperlinks in blue like it's an error message in the wrong colour?

 

Sorry I'm new to this.

 

Thanks

Link to comment
Share on other sites

$string = preg_replace('{ +}', ' ', trim($string));

is wrong. You need the same character to begin and end the pattern string:

$string = preg_replace('/ +/', ' ', trim($string));

Just be careful that the delimiter (here '/') is not found in the pattern itself. If it is, you either escape the use of / inside the pattern (\/), or you use a different delimiter: #, !, *, etc. not found in the pattern.

Link to comment
Share on other sites

  • 4 months later...

I have a similar problem ... I recently started using VegaDNS , and everything was fine, but I get errors in the scripts (Deprecated: Function ereg() is deprecated in /var/www/html/vegadns/src/config.php on line 73 Deprecated: Function ereg() is deprecated in /var/www/html/vegadns/src/functions.php on line 19 Deprecated: Function ereg() is deprecated in /var/www/html/vegadns/src/connect.php on line 19 )... here the scripts:

 

config.php on line 73

if(!ereg(".*/index.php$", $_SERVER['PHP_SELF']) 
   && !preg(".*/axfr_get.php$", $_SERVER['PHP_SELF'])) {
   header("Location:../index.php");
   exit;
}

?>

functions.php on line 19

if(!ereg(".*/index.php$", $_SERVER['PHP_SELF'])) {
   header("Location:../index.php");
   exit;
}

 

connect.php on line 19

if(!ereg(".*/index.php$", $_SERVER['PHP_SELF'])) {
   header("Location:../index.php");
   exit;
}

 

I have tried to change in many ways, but still error ... any suggestions?

Link to comment
Share on other sites

I have a similar problem ... I recently started using VegaDNS , and everything was fine, but I get errors in the scripts (Deprecated: Function ereg() is deprecated in /var/www/html/vegadns/src/config.php on line 73 Deprecated: Function ereg() is deprecated in /var/www/html/vegadns/src/functions.php on line 19 Deprecated: Function ereg() is deprecated in /var/www/html/vegadns/src/connect.php on line 19 )... here the scripts:

 

config.php on line 73

if(!ereg(".*/index.php$", $_SERVER['PHP_SELF']) 
   && !preg(".*/axfr_get.php$", $_SERVER['PHP_SELF'])) {
   header("Location:../index.php");
   exit;
}

?>

functions.php on line 19

if(!ereg(".*/index.php$", $_SERVER['PHP_SELF'])) {
   header("Location:../index.php");
   exit;
}

 

connect.php on line 19

if(!ereg(".*/index.php$", $_SERVER['PHP_SELF'])) {
   header("Location:../index.php");
   exit;
}

 

I have tried to change in many ways, but still error ... any suggestions?

Compare your files with the patch >>here.

Link to comment
Share on other sites

  • 3 weeks later...

Bo,

 

 

That contribution contains MANUAL update instructions as well, for those who have modified stores. However, it does not cover any non-compliant contribution instructions. Just the updates to the base code.

 

 

 

Chris

Link to comment
Share on other sites

look yr search for google for this as ereg_replace() is not compatible with latest version of php.

its there in language.php file where this need to be changed .

thats what I remember now

1X1blank.jpg

 

I cant find anything on google. Any help?

Link to comment
Share on other sites

its there in language.php file where this need to be changed .

 

No, language files are just definitions. There is no deprecated code in any of the default language files.

 

 

Chris

Link to comment
Share on other sites

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

 

 

function is_cPath_string($params){
	if ( eregi('cPath', $params) ){
		return true;
	} else {
		return false;
	}
} # end function

 

function strip($string){
	if ( is_array($this->attributes['SEO_CHAR_CONVERT_SET']) ) $string = strtr($string, $this->attributes['SEO_CHAR_CONVERT_SET']);
	$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);
	return $this->short_name($anchor); // return the short filtered name 
} # end function

 

function need_redirect(){		
	foreach( $this->reg_anchors as $param => $value){
		$pattern[] = $param;
	}
	switch(true){
		case ($this->is_attribute_string($this->uri)):
			$this->need_redirect = false;
			break;
		case ($this->uri != $this->real_uri && !$this->not_null($this->path_info)):
			$this->need_redirect = false;
			break;
		case (is_numeric(strpos($this->uri, '.htm'))):
			$this->need_redirect = false;
			break;
		case (@eregi("(".@implode('|', $pattern).")", $this->uri)):
			$this->need_redirect = true;
			break;
		case (@eregi("(".@implode('|', $pattern).")", $this->path_info)):
			$this->need_redirect = true;
			break;
		default:
			break;			
	} # end switch
	$this->attributes['SEO_REDIRECT']['NEED_REDIRECT'] = $this->need_redirect ? 'true' : 'false';
} # end function set_seopage

Professionally Done Module Install's

Custom Modules

Support USA Coder's. And Get The Job Done Right!

Link to comment
Share on other sites

  • 2 weeks later...

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

 

				$zip_up = MODULE_SHIPPING_DLYC_CITY;
	$zip_up = strtoupper($zip_up);
	$zip_up = str_replace (' ', '', $zip_up);
	$city = split (',', $zip_up);		
	$order->delivery['city'] = strtoupper($order->delivery['city']);
	$order->delivery['city'] = str_replace (' ', '', $order->delivery['city']);

 

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

 

And

 

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

 

and

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

 

Anyone knows the changes for this?

Getting the Phoenix off the ground

Link to comment
Share on other sites

  • 1 month later...

Hello,

 

Trying to remove all the problems gerarding PHP 5.3.x i have one problem i can't solve. Perhaps someone here can help me.

 

I'm using the Include HTML 1.7.1 addon.

 

This puts some lines in different files.

 

// Lines added for Include HTML and Text Box Contribution V. 1.0

$html_file = DIR_WS_LANGUAGES . $language . '/html/' . basename($PHP_SELF,".php") . '.html';

$html = implode("", file($html_file));

echo ereg_replace("(<!doctype([^>]+)>)|(<[/]?html>)|(<head>(.*)?</head>)|(<[/]?body([^>]+)?>)", '', $html);

 

Can someone tell me with what i can replace the last line with ereg_replace??

 

Thank you

Greetings,

 

Henk Bartels

Link to comment
Share on other sites

  • 1 year later...

Hi all,

 

I've managed to fix a number of deprecated issues successfully, but I'm stuck on this one...

 

Deprecated: Function ereg_replace() is deprecated in easy_meta_tags.php on line 47

 

The offending line is:

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

Can someone please point me in the right direction?

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...