DragonPrime - LoGD Resource Community
Welcome Guest
  • Good morning, Guest.
    Please log in, or register.
  • October 24, 2014, 11:47:36 AM
Home Forums News Links Downloads Login Register Advanced Search
* * *
DragonPrime Menu
Login
 
 
Resource Pages
IRC Channels
Search

Pages: [1]   Go Down
  Print  
Author Topic: LoGD with PHP 5  (Read 8769 times)
0 Members and 1 Guest are viewing this topic.
anpera
Guest
« on: August 15, 2004, 01:07:36 PM »

Ok, this is the first try to make LotGD 0.9.7 compatible with PHP 5. The following list contains changes worked out by Zarzal and me. Those are the necessary changes only! There are still a lot of lines that are not  clean to PHP 5 but it runs smooth anyway. With those changes LotGD works with all available PHP versions above 4.3.4. It even works if the PHP developers decide to make "now" a real "now" again.

We don't give any guaranties. Wink

("->" stands for "replace the above with".)

Code:
about.php:

$time = (strtotime(date("1971-m-d H:i:s",strtotime("now -".getsetting("gameoffsetseconds",0)." seconds"))))*getsetting("daysperday",4) % strtotime("1971-01-01 00:00:00");

->

$time = (strtotime(date("1971-m-d H:i:s",strtotime(date("r")."-".getsetting("gameoffsetseconds",0)." seconds"))))*getsetting("daysperday",4) % strtotime("1971-01-01 00:00:00");

--

"Next new gameday: ".date("h:i:s a",strtotime("+$realsecstotomorrow seconds"))." (".date("H\\h i\\m s\\s",strtotime("1970-01-01 00:00:00 + $realsecstotomorrow seconds"))."),viewonly",

->

"Next new gameday: ".date("h:i:s a",strtotime(date("r")."+$realsecstotomorrow seconds"))." (".date("H\\h i\\m s\\s",strtotime("1970-01-01 00:00:00 + $realsecstotomorrow seconds"))."),viewonly",
Code:
common.php:

$sql="SELECT name,alive,location,sex,level,laston,loggedin,lastip,uniqueid FROM accounts WHERE locked=0 AND loggedin=1 AND laston>'".date("Y-m-d H:i:s",strtotime("-".getsetting("LOGINTIMEOUT",900)." seconds"))."' ORDER BY level DESC";

->

$sql="SELECT name,alive,location,sex,level,laston,loggedin,lastip,uniqueid FROM accounts WHERE locked=0 AND loggedin=1 AND laston>'".date("Y-m-d H:i:s",strtotime(date("r")."-".getsetting("LOGINTIMEOUT",900)." seconds"))."' ORDER BY level DESC";

--

$time = convertgametime(strtotime("now"));

->

$time = convertgametime(strtotime(date("r")));

--

function convertgametime($intime){
   $time = (strtotime(date("1971-m-d H:i:s",strtotime("-".getsetting("gameoffsetseconds",0)." seconds",$intime))))*getsetting("daysperday",4) % strtotime("1971-01-01 00:00:00");
   return $time;
}

->

function convertgametime($intime){
   $multi = getsetting("daysperday",4);
   $offset = getsetting("gameoffsetseconds",0);
   $fixtime = mktime(0,0,0-$offset,date("m")-$multi,date("d"),date("Y"));
   $time=$multi*(strtotime(date("Y-m-d H:i:s",$intime))-$fixtime);
   $time=strtotime(date("Y-m-d H:i:s",$time)."+".($multi*date("I",$intime))." hour");
   $time=strtotime(date("Y-m-d H:i:s",$time)."-".date("I",$time). " hour");
   $time=strtotime(date("Y-m-d H:i:s",$time)."+".(23-$multi)." hour");
   return $time;
}

--

$sql = "DELETE from debuglog WHERE date <'".date("Y-m-d H:i:s",strtotime("-".(getsetting("expirecontent",180)/10)." days"))."'";

->

$sql = "DELETE from debuglog WHERE date <'".date("Y-m-d H:i:s",strtotime(date("r")."-".(getsetting("expirecontent",180)/10)." days"))."'";

--

if (strtotime("-".getsetting("LOGINTIMEOUT",900)." seconds") > $session['lasthit'] && $session['lasthit']>0 && $session[loggedin]){

->

if (strtotime(date("r")."-".getsetting("LOGINTIMEOUT",900)." seconds") > $session['lasthit'] && $session['lasthit']>0 && $session[loggedin]){

--

$session[lasthit]=strtotime("now");

->

$session[lasthit]=strtotime(date("r"));
Code:
configuration.php:

$time = (strtotime(date("1971-m-d H:i:s",strtotime("now -".getsetting("gameoffsetseconds",0)." seconds"))))*getsetting("daysperday",4) % strtotime("1971-01-01 00:00:00");

->

$time = (strtotime(date("1971-m-d H:i:s",strtotime(date("r")."-".getsetting("gameoffsetseconds",0)." seconds"))))*getsetting("daysperday",4) % strtotime("1971-01-01 00:00:00");

--

"Last new day: ".date("h:i:s a",strtotime("-$realsecssofartoday seconds")).",viewonly",
"Next new day: ".date("h:i:s a",strtotime("+$realsecstotomorrow seconds")).",viewonly",

->

"Last new day: ".date("h:i:s a",strtotime(date("r")."-$realsecssofartoday seconds")).",viewonly",
"Next new day: ".date("h:i:s a",strtotime(date("r")."+$realsecstotomorrow seconds")).",viewonly",
Code:
dag.php:

$laston=round((strtotime("0 days")-strtotime($row[laston])) / 86400,0)." days";

->

$laston=round((strtotime(date("r"))-strtotime($row[laston])) / 86400,0)." days";
Code:
inn.php:

$pvptimeout = date("Y-m-d H:i:s",strtotime("-$pvptime seconds"));

->

$pvptimeout = date("Y-m-d H:i:s",strtotime(date("r")."-$pvptime seconds"));

--

(laston < '".date("Y-m-d H:i:s",strtotime("-".getsetting("LOGINTIMEOUT",900)." sec"))."' OR loggedin=0) AND

->

(laston < '".date("Y-m-d H:i:s",strtotime(date("r")."-".getsetting("LOGINTIMEOUT",900)." sec"))."' OR loggedin=0) AND
Code:
list.php:

$sql = "SELECT acctid,name,login,alive,location,sex,level,laston,loggedin,race FROM accounts WHERE locked=0 AND loggedin=1 AND laston>'".date("Y-m-d H:i:s",strtotime("-".getsetting("LOGINTIMEOUT",900)." seconds"))."' ORDER BY level DESC, dragonkills DESC, login ASC";

->

$sql = "SELECT acctid,name,login,alive,location,sex,level,laston,loggedin,race FROM accounts WHERE locked=0 AND loggedin=1 AND laston>'".date("Y-m-d H:i:s",strtotime(date("r")."-".getsetting("LOGINTIMEOUT",900)." seconds"))."' ORDER BY level DESC, dragonkills DESC, login ASC";

--

$laston=round((strtotime("0 days")-strtotime($row[laston])) / 86400,0)." days";

->

$laston=round((strtotime(date("r"))-strtotime($row[laston])) / 86400,0)." days";
Code:
logdnet.php:

if (strtotime($row[lastupdate])<strtotime("-1 minutes")){

->

if (strtotime($row[lastupdate])<strtotime(date("r")."-1 minutes")){
Code:
login.php:

$sql="SELECT laston,loggedin FROM accounts WHERE locked=0 AND loggedin=1 AND laston>'".date("Y-m-d H:i:s",strtotime("-".getsetting("LOGINTIMEOUT",900)." seconds"))."' ORDER BY level DESC";

->

$sql="SELECT laston,loggedin FROM accounts WHERE locked=0 AND loggedin=1 AND laston>'".date("Y-m-d H:i:s",strtotime(date("r")."-".getsetting("LOGINTIMEOUT",900)." seconds"))."' ORDER BY level DESC";

--

$sql = "INSERT INTO bans VALUES ('{$_SERVER['REMOTE_ADDR']}','','".date("Y-m-d H:i:s",strtotime("+".($c*3)." hours"))."','Automatic System Ban: Too many failed login attempts.')";

->

$sql = "INSERT INTO bans VALUES ('{$_SERVER['REMOTE_ADDR']}','','".date("Y-m-d H:i:s",strtotime(date("r")."+".($c*3)." hours"))."','Automatic System Ban: Too many failed login attempts.')";
Code:
pvp.php:

$pvptimeout = date("Y-m-d H:i:s",strtotime("-$pvptime seconds"));

->

$pvptimeout = date("Y-m-d H:i:s",strtotime(date("r")."-$pvptime seconds"));

--

(laston < '".date("Y-m-d H:i:s",strtotime("-".getsetting("LOGINTIMEOUT",900)." sec"))."' OR loggedin=0) AND

->

(laston < '".date("Y-m-d H:i:s",strtotime(date("r")."-".getsetting("LOGINTIMEOUT",900)." sec"))."' OR loggedin=0) AND

--

if (strtotime($row[laston]) > strtotime("-".getsetting("LOGINTIMEOUT",900)." sec") && $row[loggedin]){

->

if (strtotime($row[laston]) > strtotime(date("r")."-".getsetting("LOGINTIMEOUT",900)." sec") && $row[loggedin]){
Code:
referers.php

$sql = "DELETE FROM referers WHERE last<'".date("Y-m-d H:i:s",strtotime("-".getsetting("expirecontent",180)." days"))."'";
         
->

$sql = "DELETE FROM referers WHERE last<'".date("Y-m-d H:i:s",strtotime(date ("r")."-".getsetting("expirecontent",180)." days"))."'";

--

$diffsecs = strtotime("now")-strtotime($row['last']);

->

$diffsecs = strtotime(date("r"))-strtotime($row['last']);
Code:
superuser.php:

$laston=round((strtotime("0 days")-strtotime($row[laston])) / 86400,0)." Tage";

->

$laston=round((strtotime(date("r"))-strtotime($row[laston])) / 86400,0)." Tage";
Code:
user.php:

$sql = "UPDATE accounts SET lasthit='".date("Y-m-d H:i:s",strtotime("-".(86500/getsetting("daysperday",4))." seconds"))."' WHERE acctid='$_GET[userid]'";

->

$sql = "UPDATE accounts SET lasthit='".date("Y-m-d H:i:s",strtotime(date("r")."-".(86500/getsetting("daysperday",4))." seconds"))."' WHERE acctid='$_GET[userid]'";

--

$sql.=",\"".((int)$_POST[duration]==0?"0000-00-00":date("Y-m-d",strtotime("+$_POST[duration] days")))."\",";

->

$sql.=",\"".((int)$_POST[duration]==0?"0000-00-00":date("Y-m-d",strtotime(date("r")."+$_POST[duration] days")))."\",";

--

$expire=round((strtotime($row[banexpire])-strtotime("now")) / 86400,0)." days";

->

$expire=round((strtotime($row[banexpire])-strtotime(date("r"))) / 86400,0)." days";

--

$laston=round((strtotime("0 days")-strtotime($row[laston])) / 86400,0)." days";

->

$laston=round((strtotime(date("r"))-strtotime($row[laston])) / 86400,0)." days";
Code:
special/darkhorse.php

(3x):
$HTTP_GET_VARS[try]

-> (3x):
$HTTP_GET_VARS['try']
Code:
special/oldmanbet.php

(2x):
$HTTP_GET_VARS[try]

-> (2x):
$HTTP_GET_VARS['try']

You can use the same (or similar) changes in 0.9.8 prerelease to make it PHP 5 compatible.
If you find something we missed please let us know.
Logged
strider
Guest
« Reply #1 on: August 18, 2004, 04:20:04 PM »

Absolutely brilliant m'dear sire.
Logged
Bocchama
Guest
« Reply #2 on: July 23, 2006, 06:31:23 PM »

have you try it for 1.1.0?

i have that kind of problem too, well i quess i'll try it first
Logged
XChrisX
Global Moderator
Mod God
*****
Offline Offline

Posts: 4647

Be aware of the squirrel!


View Profile WWW
« Reply #3 on: July 23, 2006, 09:12:13 PM »

You have seen this thread is almost two years old? In fact, 1.1.0 should work (UNTESTED!) with the newest PHP5 version.
Logged

Running for more than three years now:
Apollon
Captain of the Guard
***
Offline Offline

Posts: 139


This life is one of the hardest!


View Profile WWW
« Reply #4 on: July 25, 2006, 03:41:49 PM »

For 0.97:

There has been a change in the newest Version of PhP 5.1.2, so if your Provider should upgrade, you have to do the same as above, but instead of

Code:
strtotime(date("r")

you have to change to

Code:
strtotime(date("c")

I changed my webspace from a server with PhP 4 to a server with PhP 5.1.2, so I got these problems. If anyone else should get it, here is the solution for it... Smiley
Logged

I am the country, my eyes am the sky, my limbs the trees, I am the rock, the depth of water. I am not here, in order to control mother nature or exploit her. I am even nature.
(Hopi)
linuxcat
Guest
« Reply #5 on: December 20, 2006, 03:40:51 PM »

I am running LoGD 1.1.0 with PHP 5.1.1.  I had the frozen clock.  The fix was to delete the spaces in 2 lines of lib/datetime.php.
Code:

strtotime(gmdate("Y-m-d H:i:s O",$ret['gametime'])." + 1 day");
->
strtotime(gmdate("Y-m-d H:i:s O",$ret['gametime'])." +1 day");

and

return strtotime("{$details['now']} + {$details['realsecstotomorrow']} seconds");
->
return strtotime("{$details['now']} +{$details['realsecstotomorrow']} seconds");

PHP 5.1.1's strtotime can not handle the space after the +
There is a third "+ " in that section of code, but it is commented out.
I now have a correctly working countdown until the next new day.  Everything else seems to work fine.

EDIT: Woops I completely forgot I also made 1 change to common.php, though this might be a php.ini problem.  Near the top of the file I added:
Code:

ini_set('include_path', '/full/path/to/lotgd');

Otherwise I got tons of include_once() errors.
« Last Edit: December 20, 2006, 03:48:15 PM by linuxcat » Logged
Nightborn
Guest
« Reply #6 on: December 20, 2006, 11:41:21 PM »

Code:
PHP 5.2.0-7 (cli) (built: Nov 24 2006 16:29:03)
Copyright (c) 1997-2006 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2006 Zend Technologies
    with eAccelerator v0.9.5, Copyright (c) 2004-2006 eAccelerator, by eAccelerator

is what I use.

No frozen clock, no include_once errors, nothing. not a single line of code change in the core necessary.
Logged
XChrisX
Global Moderator
Mod God
*****
Offline Offline

Posts: 4647

Be aware of the squirrel!


View Profile WWW
« Reply #7 on: December 21, 2006, 12:08:05 AM »

That's because the time function in earlier PHP5 functions where buggy... Wink
Logged

Running for more than three years now:
Elessa
Faerie
Mod God
*****
Offline Offline

Posts: 3598


short, sweet and to the point


View Profile
« Reply #8 on: December 21, 2006, 08:29:26 AM »

I am running LoGD 1.1.0 with PHP 5.1.1.  I had the frozen clock.  The fix was to delete the spaces in 2 lines of lib/datetime.php.

hmmmm... as this is applicable to v 1.1.0, not v 0.9.7 i believe this fix is not relevent to this thread.
Logged

Uuma ma ten rashwe, ta tuluva a lle

Play the latest beta version here on LoGD DragonPrime - Axebridge
Lightbringer
Member
Codemeister
****
Offline Offline

Posts: 263


Life's a lich and then you don't die...damn unlife


View Profile
« Reply #9 on: April 05, 2009, 05:33:38 PM »

Just a slight amendment to the changes required in superuser.php..

Quote
superuser.php:

$laston=round((strtotime("0 days")-strtotime($row[laston])) / 86400,0)." Tage";

->

$laston=round((strtotime(date("r"))-strtotime($row[laston])) / 86400,0)." Tage";

Obviously taken from the german version..

just change 'Tage' to 'days' unless you are running the german version of 0.9.7 +jt
Logged

________________________ _____________________

Lightbringer
PHP/SQL/VB.NET/C#/AJAX Developer
Lightbringer
Member
Codemeister
****
Offline Offline

Posts: 263


Life's a lich and then you don't die...damn unlife


View Profile
« Reply #10 on: July 25, 2013, 04:41:16 PM »

Hey guys

Just working on putting another server up and have come across a few hurdles again (which, believe it or not, is a good thing) so I have fixed all of these. I thought I would start once again with 0.9.7+jt so that I can get back in the swing of things.

I'll start with a list of all the griefs that I have encountered thus far..

  • Deprecated PHP Functions
  • Deprecated MySQL Functions

Deprecated PHP Functions

* magic_quotes_runtime
      In dbwrapper.php - Line 4
FIND:
Code:
if (!get_magic_quotes_gpc()){
set_magic_quotes($_GET);
set_magic_quotes($_POST);
set_magic_quotes($_SESSION);
set_magic_quotes($_COOKIE);
set_magic_quotes($HTTP_GET_VARS);
set_magic_quotes($HTTP_POST_VARS);
set_magic_quotes($HTTP_COOKIE_VARS);
ini_set("magic_quotes_gpc",1);
}
set_magic_quotes_runtime(0);

function set_magic_quotes(&$vars) {
//eval("\$vars_val =& \$GLOBALS[$vars]$suffix;");
if (is_array($vars)) {
reset($vars);
while (list($key,$val) = each($vars))
set_magic_quotes($vars[$key]);
}else{
$vars = addslashes($vars);
//eval("\$GLOBALS$suffix = \$vars_val;");
}
}
REPLACE WITH:
Code:
/* if (!get_magic_quotes_gpc()){
set_magic_quotes($_GET);
set_magic_quotes($_POST);
set_magic_quotes($_SESSION);
set_magic_quotes($_COOKIE);
set_magic_quotes($HTTP_GET_VARS);
set_magic_quotes($HTTP_POST_VARS);
set_magic_quotes($HTTP_COOKIE_VARS);
ini_set("magic_quotes_gpc",1);
}
set_magic_quotes_runtime(0);

function set_magic_quotes(&$vars) {
//eval("\$vars_val =& \$GLOBALS[$vars]$suffix;");
if (is_array($vars)) {
reset($vars);
while (list($key,$val) = each($vars))
set_magic_quotes($vars[$key]);
}else{
$vars = addslashes($vars);
//eval("\$GLOBALS$suffix = \$vars_val;");
}
}
*/

Note that this ignore the magic_quotes_runtime function entirely..have yet to find the updated function and not observing this function can be a bit of a security hole for sql injection. Comment out at your own risk!!!

* split()
      In common.php - Line 824

FIND:

Code:
$fulltemplate = split("<!--!",$fulltemplate);

REPLACE WITH:

Code:
$fulltemplate = explode("<!--!",$fulltemplate);

Note: replace split with explode in the following locations to completely eradicate any /visible/ erros. There is likely more in function libraries and such, however, I have not found any other that impact the game...

badword.php - Line 51
Icreatures.php - Line 57 & 69

* session_register
      In common.php - Line 824

FIND:

Code:
session_register("session");

REPLACE WITH:

Code:
session_start();
$session =& $_SESSION['session'];

Deprecated MySQL Functions
* Declaration of storage engine in INSERT statements

In the create.sql, replace all instances of the following;

Code:
TYPE=MyISAM
with
Code:
ENGINE=MyISAM

Code:
TYPE=INNODB
with
Code:
ENGINE=INNODB

This will remove all errors associated with running the old core on PHP5
« Last Edit: July 25, 2013, 05:26:50 PM by Lightbringer » Logged

________________________ _____________________

Lightbringer
PHP/SQL/VB.NET/C#/AJAX Developer
The Doctor
Mod God
*****
Offline Offline

Posts: 1500



View Profile WWW
« Reply #11 on: July 25, 2013, 07:51:33 PM »

Are all these things not listed here and here?
« Last Edit: July 25, 2013, 07:55:03 PM by The Doctor » Logged

Lightbringer
Member
Codemeister
****
Offline Offline

Posts: 263


Life's a lich and then you don't die...damn unlife


View Profile
« Reply #12 on: July 25, 2013, 08:01:16 PM »

Possibly..I did not check the forums for 1.*.*

I was specifically referring to LoGD 0.9.7

I know it is unsupported, but there are some of us who have been here since then and with myself coming back after a long absence, I am going back to the most stable release pre modulification (yes, I invented a word) to get back into the swing of it.

If you want, I can delete tis topic, but having all this stuff might be handy for someone in the future..not everyone has migrated or wants to migrate to the newer patch levels.

The fact you specified two separate locations in your reply illustrates my point, don't you think?
Logged

________________________ _____________________

Lightbringer
PHP/SQL/VB.NET/C#/AJAX Developer
Pages: [1]   Go Up
  Print  
 
Jump to:  


*
DragonPrime Notices
Please take the time to read the FAQ and browse the DragonPedia

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