Jump to content

Recommended Posts

Ok here is what I have right now:

<?php
$phpver = phpversion();
if ($phpver < '4.1.0') {
$_GET = $HTTP_GET_VARS;
$_POST = $HTTP_POST_VARS;
$_SERVER = $HTTP_SERVER_VARS;
}
if ($phpver >= '4.0.4pl1' && strstr($_SERVER["HTTP_USER_AGENT"],'compatible')) {
if (extension_loaded('zlib')) {
	ob_end_clean();
	ob_start('ob_gzhandler');
}
} else if ($phpver > '4.0') {
if (strstr($HTTP_SERVER_VARS['HTTP_ACCEPT_ENCODING'], 'gzip')) {
	if (extension_loaded('zlib')) {
		$do_gzip_compress = TRUE;
		ob_start(array('ob_gzhandler',5));
		ob_implicit_flush(0);
	}
}
}
$phpver = explode(".", $phpver);
$phpver = "$phpver[0]$phpver[1]";
if ($phpver >= 41) {
$PHP_SELF = $_SERVER['PHP_SELF'];
}

if (!ini_get("register_globals")) {
import_request_variables('GPC');
}

?>

 

Right now I have a client with php 5.1.6 and currently this script makes it freeze up. How can I make this compatable with PHP 5?

 

Thanks,

-Chris

Link to comment
https://forums.phpfreaks.com/topic/45909-config-file-php5-compatability-issue/
Share on other sites

You have

<?php
} else if ($phpver > '4.0') {
if (strstr($HTTP_SERVER_VARS['HTTP_ACCEPT_ENCODING'], 'gzip')) {
?>

Shouldn't that be

<?php
} else if ($phpver > '4.0') {
if (strstr($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip')) {
?>

 

Ken

You are using the older style superglobals. The older style superglobas was dropped with newer shorter superglobals when PHP4.2 was released. When PHP5 was release the devlopers dropped support for the older style superglobals and thus the setting regsiter_long_arrays was introduced and is disabled by default.

 

You may enable this setting in the php.ini (if you can) or by using the ini_set function in your script. However it would be better if you updated your code to use the newer superglobals. YOu'd do this by changing $HTTP_*_VARS to $_*

 

The * masks a word, example POST, GET, SERVER, SESSSION:

 

$HTTP_GET_VARS should be $_GET

$HTTP_POST_VARS should be $_POST

$HTTP_COOKIE_VARS should be $_COOKIE

$HTTP_SESSION_VARS shold be $_SESSION

$HTTP_SERVER_VARS should be $_SERVER

Hey guys, thanks for the help. What I did is just at another statement for php5 ... to do nothing. When I uploaded it everything worked great. Here it is:

<?php
$phpver = phpversion();
if ($phpver < '4.1.0') {
$_GET = $HTTP_GET_VARS;
$_POST = $HTTP_POST_VARS;
$_SERVER = $HTTP_SERVER_VARS;
}

if($phpver > '5.0'){
//Do nothing
}
else if ($phpver >= '4.0.4pl1' && strstr($_SERVER["HTTP_USER_AGENT"],'compatible')) {
if (extension_loaded('zlib')) {
	ob_end_clean();
	ob_start('ob_gzhandler');
}
} else if ($phpver > '4.0') {
if (strstr($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip')) {
	if (extension_loaded('zlib')) {
		$do_gzip_compress = TRUE;
		ob_start(array('ob_gzhandler',5));
		ob_implicit_flush(0);
	}
}
}
$phpver = explode(".", $phpver);
$phpver = "$phpver[0]$phpver[1]";
if ($phpver >= 41) {
$PHP_SELF = $_SERVER['PHP_SELF'];
}

if (!ini_get("register_globals")) {
import_request_variables('GPC');
}

?>

 

Is this right? (it works :))

I'd leave the following out:

if($phpver > '5.0'){
//Do nothing
}

If you're not going to do anything in that statement then leave it out.

 

If you keep it in then your script will not enable output compression, which is what that code sets up.

 

I'd change your code to this:

<?php

$phpver = phpversion();

if ($phpver < '4.1.0')
{
$_GET = $HTTP_GET_VARS;
$_POST = $HTTP_POST_VARS;
$_SERVER = $HTTP_SERVER_VARS;
}

if ($phpver >= '4.0.4pl1' && strstr($_SERVER["HTTP_USER_AGENT"], 'compatible'))
{
if (extension_loaded('zlib'))
    {
	ob_end_clean();
	ob_start('ob_gzhandler');
}
}
else if ($phpver > '4.0')
{
if (strstr($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip'))
    {
	if (extension_loaded('zlib')
        {
		$do_gzip_compress = TRUE;
		ob_start(array('ob_gzhandler',5));
		ob_implicit_flush(0);
	}
}
}

if ($phpver >= '4.1')
{
$PHP_SELF = $_SERVER['PHP_SELF'];
}

if (!ini_get("register_globals")) {
import_request_variables('GPC');
}

?>

 

Now that code will work for PHP4 and PHP5

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.