DragonPrime - LoGD Resource Community
Welcome Guest
  • Good evening, Guest.
    Please log in, or register.
  • December 10, 2018, 05:59:32 PM
Home Forums News Downloads Login Register Advanced Search
* * *
DragonPrime Menu
Login
 
 
Resource Pages
Search

Pages: [1]   Go Down
  Print  
Author Topic: URGENT! PHP 5.4.0 causes Game problems and every other issue.  (Read 29375 times)
0 Members and 1 Guest are viewing this topic.
MarcTheSlayer
Mod God
*****
Offline Offline

Posts: 1748


View Profile
« on: April 11, 2012, 08:53:35 AM »

On my test server I upgraded PHP to the latest (v5.4.0 - 1st march 2012) and got a  load of errors what with depreciated features and backward incompatible changes in this new version.

Here are the ones that I've found so far that cause issues. (A full PHP change list can be found at http://uk3.php.net/migration54 for those that are interested).

  • The function session_register() has been removed.
  • Magic quotes have been removed and therefore set_magic_quotes_runtime() raises an E_CORE_ERROR level error.
  • The function split() is deprecated and will probably be removed in the new version.
  • Edit: strtotime() and date() give error messages because date.timezone is not set.

If you have no control over which PHP version is installed on your server, I recommend you make these changes while your game still works instead of finding it doesn't one day and wondering why because the admin has upgraded PHP. Smiley

This is for LotGD v1.1.1 but will apply across many versions, (line numbers may vary).

Fix session_register().
Code:
#
#-----[ OPEN ]-----
#
common.php

#
#-----[ FIND ]------
#
# Line: 91
#
session_register("session");

#
#-----[ REPLACE WITH ]-----
#
//session_register("session");
session_start();
$session = array();

Fix set_magic_quotes_runtime() .
Code:
#
#-----[ OPEN ]-----
#
lib/errorhandling.php

#
#-----[ FIND ]-----
#
# Line: 33
#
set_magic_quotes_runtime(0);

#
#-----[ REPLACE WITH ]-----
#
//set_magic_quotes_runtime(0);

Fix split().
Code:
#
#-----[ OPEN ]-----
#
prefs.php

#
#-----[ FIND ]-----
#
# Line: 233
#
$type = split(",", $x[0]);

#
#-----[ REPLACE WITH ]-----
#
//$type = split(",", $x[0]);
$type = explode(",", $x[0]);

#
#-----[ OPEN ]-----
#
events.php

#
#-----[ FIND ]-----
#
# Line: 47
#
$array = split(":", $specialinc);

#
#-----[ REPLACE WITH ]-----
#
//$array = split(":", $specialinc);
$array = explode(":", $specialinc);

#
#-----[ OPEN ]-----
#
pageparts.php

#
#-----[ FIND ]-----
#
# Line: 71
#
$s = split("x",$size);

#
#-----[ REPLACE WITH ]-----
#
//$s = split("x",$size);
$s = explode("x",$size);

#
#-----[ OPEN ]-----
#
pullurl.php

#
#-----[ FIND ]-----
#
# Line: 31
#
$val = split("\n", $ret);

#
#-----[ REPLACE WITH ]-----
#
//$val = split("\n", $ret);
$val = explode("\n", $ret);


#
#-----[ OPEN ]-----
#
showform.php

#
#-----[ FIND ]-----
#
# Line: 27
#
$info = split(",", $v);

#
#-----[ REPLACE WITH ]-----
#
//$info = split(",", $v);
$info = explode(",", $v);

#
#-----[ FIND ]-----
#
# Line: 31
#
$info = split(",",$val);

#
#-----[ REPLACE WITH ]-----
#
//$info = split(",",$val);
$info = explode(",",$val);


Edit:
Another problem with using a newer version of PHP is strtotime() and also date(). These now require you have a default timezone set.

A list of supported timezones can be found at http://uk3.php.net/manual/en/timezones.php

To fix either of these 2 problems you must either,

a) Set it globally in the php.ini file. This covers the whole server.
Code:
date.timezone = "Europe/London"

b) Add it to the LotGD file /root/lib/local_config.php This covers just your game.
Code:
ini_set('date.timezone', 'Europe/London');

c) Add it to a .htaccess file in your root directory. This covers your whole webspace.
Code:
php_value date.timezone "Europe/London"

Change Europe/London to the timezone nearest to your server.

Please note that these may not work as it depends how your server is configured.

Other Errors:
MySQL error because the type is wrong? http://dragonprime.net/index.php?topic=11805.0

Redirections when trying to do a new install? http://dragonprime.net/index.php?topic=11842.0
Smiley

PayPal.com
Paypal has changed its headers from 1.0 to 1.1 so you need to make a small change to the payment.php file for donations to be recorded.
http://dragonprime.net/index.php?topic=12549.msg104544#msg104544

Code:
#
#-----[ OPEN ]-----
#
payment.php

#
#-----[ FIND ]------
#
# Line: 25
#
$header .= "POST /cgi-bin/webscr HTTP/1.0\r\n";

#
#-----[ REPLACE WITH ]-----
#
$header .= "POST /cgi-bin/webscr HTTP/1.1\r\n";

#
#-----[ FIND ]-----
#
$header .= "Content-Length: " . strlen($req) . "\r\n\r\n";

#
#-----[ AFTER, ADD ]-----
#
$header .= "Host: www.paypal.com\r\n";
$header .= "Connection: close\r\n";
« Last Edit: January 27, 2014, 08:04:34 AM by Afkamm » Logged

Check My Modules for the latest versions.
ArthuruhtrA
Mod God
*****
Offline Offline

Posts: 573


chown -R us ./base


View Profile
« Reply #1 on: April 11, 2012, 09:14:11 AM »

Any chance there can be a LoGD 1.1.2.1 release to prevent these errors from occurring among new installs? Chances are any newcomer will start with an EasyPHP install new enough to have PHP 5.4 and immediately encounter these errors.
Logged

I'm around rarely, If you wish to contact me, please email me.
My Modules, such as can be found here.
staticobj
Militia
**
Offline Offline

Posts: 90

Keep it Simple Stupid


View Profile WWW
« Reply #2 on: April 11, 2012, 11:08:35 AM »

It would be preferable to opt for this snippet if one is to assume no control over the available PHP version:
Code: (PHP)
<?php
if (function_exists("set_magic_quotes_runtime")) set_magic_quotes_runtime(0);

PHP version could be rolled back, user may migrate web hosts, etc. Safe to assume that a user will forget the changes were ever made in any event.
Logged

Want a custom template? Private Message me for a quote.
Click here for web hosting offer. I'm willing to work with you. Please send a Private Message for further details.
www.legacyofdragon.com
MarcTheSlayer
Mod God
*****
Offline Offline

Posts: 1748


View Profile
« Reply #3 on: April 11, 2012, 11:15:00 AM »

True, good advice. Smiley

Edit
Just want to add that even if you use the function exist check, you'll still get depreciated error messages.
« Last Edit: September 27, 2012, 07:13:18 AM by Afkamm » Logged

Check My Modules for the latest versions.
Nder'
Codemeister
****
Offline Offline

Posts: 256


Google is our savior!


View Profile
« Reply #4 on: July 13, 2013, 10:48:06 AM »

Old post but I got bored--Attached are all the edits (and their corresponding files). They're separated into ROOT and LIB just in case someone doesn't know where the particular file came from.

Cheers,
Nder



EDIT:: Added a rawsql.php error. Doctor, could you send me the link to the fix for the file which sends "blah blah blkah just hacked blahblah blah (superuser me thinks).
« Last Edit: July 15, 2013, 04:24:43 PM by Nder' » Logged

insert sympathy here

Message me!
Aeolus
Mod God
*****
Offline Offline

Posts: 1912


You're welcome.


View Profile WWW
« Reply #5 on: July 13, 2013, 06:59:03 PM »

Old post but I got bored--Attached are all the edits (and their corresponding files). They're separated into ROOT and LIB just in case someone doesn't know where the particular file came from.

Cheers,
Nder

Good job! This would be good for beginner admins, but maybe not so much for those who have already edited the core files in question.
Logged

MarcTheSlayer
Mod God
*****
Offline Offline

Posts: 1748


View Profile
« Reply #6 on: July 14, 2013, 05:28:10 AM »

I keep a v1.1.2 copy that have all the these changes plus other "fixes" that have been posted to the bug report forum. Very handy. Smiley
Logged

Check My Modules for the latest versions.
Megan|SaraBeth
Mod God
*****
Offline Offline

Posts: 1065



View Profile WWW
« Reply #7 on: May 12, 2014, 04:23:37 PM »

I keep a v1.1.2 copy that have all the these changes plus other "fixes" that have been posted to the bug report forum. Very handy. Smiley


Could you please upload it for me.  Thanks.
Logged

Nder'
Codemeister
****
Offline Offline

Posts: 256


Google is our savior!


View Profile
« Reply #8 on: May 12, 2014, 04:53:11 PM »

Try Doc's copy for now? When Afkamm posts his copy, we can compare them and add the overlapping (if any) edits to produce a final copy.
Logged

insert sympathy here

Message me!
Megan|SaraBeth
Mod God
*****
Offline Offline

Posts: 1065



View Profile WWW
« Reply #9 on: May 12, 2014, 05:28:58 PM »

Where would I get Doc's copy?
Logged

Nder'
Codemeister
****
Offline Offline

Posts: 256


Google is our savior!


View Profile
« Reply #10 on: May 12, 2014, 05:55:11 PM »

Where would I get Doc's copy?

Sorry. I meant to post it in the original post. Here it is.
Logged

insert sympathy here

Message me!
Pages: [1]   Go Up
  Print  
 
Jump to:  


*
DragonPrime Notices
Play LoGD on Dragonprime

Support Us
No funds raised yet this year
Your help is greatly appreciated!
Recent Topics
DragonPrime LoGD
Who's Online
45 Guests, 0 Users
Home Forums News Downloads Login Register Advanced Search