DragonPrime - LoGD Resource Community
Welcome Guest
  • Good evening, Guest.
    Please log in, or register.
  • May 19, 2013, 06:12:08 PM
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 6202 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: 3592


short, sweet and to the point


View Profile WWW
« 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: 258


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
Pages: [1]   Go Up
  Print  
 
Jump to:  


*
DragonPrime Notices
Play LoGD on Dragonprime

Support Us
$100 raised this year
Your help is greatly appreciated!
Who's Online
19 Guests, 0 Users
DragonPrime LoGD
Recent Topics
Home Forums News Links Downloads Login Register Advanced Search