diff --git a/COPYING b/COPYING index 4bc8da0..6626ba0 100644 --- a/COPYING +++ b/COPYING @@ -1,4 +1,4 @@ -MyPHPpa (c) 2003 Jens Beyer, khan@web.de +MyPHPpa (c) 2003, 2007 Jens Beyer, khan@web.de The following license GPL 2 or newer applize to all code in and below this directory except for the 'battlecalc' who's diff --git a/README b/README index 579fcce..d83f3ea 100644 --- a/README +++ b/README @@ -3,7 +3,9 @@ You will need a Unix machine (probably linux) to run this. I've run it on a MySQL-3 (You need to create a database there - mine was named planetarion), and PHP-4. -(NB: for mysql-4 you might need to convert some names) + +Version 0.8.16 is an update to run on PHP-5 (eg 5.1) and +MySQL-4.1/5.0 (the 5.0 is less tested as is 0.8.16 at all). To edit: diff --git a/TODO-session_handling.txt b/TODO-session_handling.txt new file mode 100644 index 0000000..8b679f4 --- /dev/null +++ b/TODO-session_handling.txt @@ -0,0 +1,90 @@ + +Session Handling V2 für MyPHPPa +------------------------------- + +Was bisher geschah +------------------ + +Session-handling V1 ist ein Sessionmanagement auf cookies, ihrer +Lebensdauer und den darin gespeicherten Userbezogenen Daten simples +Authentifizierungssystem. +Vorteil: +- Für PHP < 4.1 einfach zu realisieren (in späteren Versionen sind cookies + per default keine globalen Variablen mehr). +Nachteil: +- Userdaten werden im Cookie auf Clientseite abgelegt. +- Nur Lebensdauer der Session wird DB-gestüzt auf Serverseite kontrolliert +- Jeder Request muss im Applikationscode gegen die DB authentifiziert werden + + +Wie soll es werden +------------------ + +Session-handling V2 soll auf dem PHP-Sessionmanagement basieren - im +speziellen implementiert unter PHP 5 ohne Rückwärtskompatibilität. + +Anforderung: +- Keine userbezogenen Daten auf Clientseite +- Einfache Intergration in MyPHPpa +- Weitere sessionbezogenen Informationen innerhalb der Session (lokal) + speichern +- Vereinfachung der Request-Authentifizierung +- Loadbalancer fähige Session + +Technisches Konzept +------------------- +Das eigentliche Session-handling wird von PHP5 übernommen; auf Clientseite +wird lediglich eine SessionID (per Cookie oder URL) verwaltet während das +Sessionmodul des Applikationscodes die lokal gehaltenen Autorisierungsdaten +erstellt und überprüft. +Im ersten Schritt wird das eigentliche Sessionmodule mit Session-Datenfiles +unter /tmp realisiert. Später kann hierzu eine DB-basierende Methode +hinzukommen um die Forderung nach Rechnerübergreifenden Sessions nachzukommen. + +Sessiondaten: +- PlanetId +- Sessiontimeout (Nicht mehr DB-gestüzt) +- ClientIP (Neu: überprüfung) + +Folgende Usecases sind zu berücksichtigen: +- Login, Keine Session registriert + * Session erstellen +- Login, Session regged + -> last > session-timeout ? + * Neue session erstellen + Failure +- Pagerequest, Session + - Session valid ? IP korrekt ? + * Renew + Session beenden + +Funktionen: + session_init # init (pre-)session settings + session_cache_expire() + session_start() + + session_create # create new user session + _find_session # check if user has a session + + session_check # check if session is valid/alive + _session_ip_check # check the embedded IP versus this request + + session_destroy # destroy this session context + + session_flush # flush and close session handling for this request + + # Maybe + session_store # put a variable into the session + session_retrieve # get the data back + +Prototypen: +int session_init(); + +int session_create(); + int _find_session(); + +int session_check(); + int _session_ip_check(); + +int session_destroy(); +void session_flush(); \ No newline at end of file diff --git a/online/admin.php b/online/admin.php index 411812a..df06a2c 100644 --- a/online/admin.php +++ b/online/admin.php @@ -2,7 +2,7 @@ /* * MyPHPpa - * Copyright (C) 2003 Jens Beyer + * Copyright (C) 2003, 2007 Jens Beyer * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/online/admin/aalist.php b/online/admin/aalist.php index e0a4a56..432e5f1 100644 --- a/online/admin/aalist.php +++ b/online/admin/aalist.php @@ -2,7 +2,7 @@ /* * MyPHPpa - * Copyright (C) 2003 Jens Beyer + * Copyright (C) 2003, 2007 Jens Beyer * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -38,7 +38,7 @@ $myrow["alliance_id"] = 0; print_alliance_status ($all); } else { - $ref = "$PHP_SELF?allid="; + $ref = "$_SERVER[PHP_SELF]?allid="; list_alliances_admin($ref); } diff --git a/online/admin/admform.php b/online/admin/admform.php index 5d3899f..22b7538 100644 --- a/online/admin/admform.php +++ b/online/admin/admform.php @@ -2,7 +2,7 @@ /* * MyPHPpa - * Copyright (C) 2003 Jens Beyer + * Copyright (C) 2003, 2007 Jens Beyer * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -40,16 +40,16 @@ function submit_values($id, $values, $table) { global $db; $q = "select * from $table WHERE id = '$id'"; - $result = mysql_query ($q, $db); + $result = mysqli_query ($db, $q ); - if (mysql_num_rows($result) > 0) { + if (mysqli_num_rows($result) > 0) { $q = "UPDATE $table set $values WHERE id='$id'"; } else { $q = "INSERT INTO $table set $values"; } echo "$q
"; - $result = mysql_query ($q, $db); + $result = mysqli_query ($db, $q ); if (!$result) { echo "Update/insert into $table ". diff --git a/online/admin/admhead.php b/online/admin/admhead.php index 5033c7e..4fd57a7 100644 --- a/online/admin/admhead.php +++ b/online/admin/admhead.php @@ -2,7 +2,7 @@ /* * MyPHPpa - * Copyright (C) 2003 Jens Beyer + * Copyright (C) 2003, 2007 Jens Beyer * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -20,8 +20,8 @@ */ require_once "../auth_check.php"; - require_once "../options.php"; + pre_auth($Username,$Password,$Planetid,$Valid); require_once "../dblogon.php"; @@ -35,14 +35,14 @@ require_once "../header.php"; -if ($extra_header) { +if (ISSET($extra_header)) { my_header($extra_header,0,0); } else { my_header("",0,0); } -mysql_query("UPDATE user set last=NOW(),last_tick='$mytick',". - "ip='$HTTP_SERVER_VARS[REMOTE_ADDR]' ". - "WHERE planet_id='$Planetid'"); +mysqli_query($db, "UPDATE user set last=NOW(),last_tick='$mytick'". + "ip='$_SERVER[REMOTE_ADDR]' ". + "WHERE planet_id='$Planetid'"); ?> diff --git a/online/admin/admmain.php b/online/admin/admmain.php index 6b2c636..27d3920 100644 --- a/online/admin/admmain.php +++ b/online/admin/admmain.php @@ -2,7 +2,7 @@ /* * MyPHPpa - * Copyright (C) 2003 Jens Beyer + * Copyright (C) 2003, 2007 Jens Beyer * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -30,38 +30,38 @@ "; $q = "SELECT count(*) FROM planet WHERE mode=0"; -$res = mysql_query($q, $db); -$rowm = mysql_fetch_row($res); +$res = mysqli_query($db, $q ); +$rowm = mysqli_fetch_row($res); echo "Banned: $rowm[0] planets
"; $q = "SELECT count(*) FROM news"; -$res = mysql_query($q, $db); -$row = mysql_fetch_row($res); +$res = mysqli_query($db, $q ); +$row = mysqli_fetch_row($res); echo "News: $row[0] entries
"; $q = "SELECT count(*) FROM journal"; -$res = mysql_query($q, $db); -$row = mysql_fetch_row($res); +$res = mysqli_query($db, $q ); +$row = mysqli_fetch_row($res); echo "Journal: $row[0] entries
"; $q = "SELECT count(*) FROM logging"; -$res = mysql_query($q, $db); -$row = mysql_fetch_row($res); +$res = mysqli_query($db, $q ); +$row = mysqli_fetch_row($res); echo "logging: $row[0] entries
"; diff --git a/online/admin/admnav.php b/online/admin/admnav.php index e426c8a..998a203 100644 --- a/online/admin/admnav.php +++ b/online/admin/admnav.php @@ -2,7 +2,7 @@ /* * MyPHPpa - * Copyright (C) 2003 Jens Beyer + * Copyright (C) 2003, 2007 Jens Beyer * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -36,89 +36,89 @@ require_once "../header.php"; -if ($extra_header) { +if (ISSET($extra_header)) { my_header($extra_header,0); } else { my_header("",0); } -mysql_query("UPDATE user set last=NOW(),last_tick='$mytick',". - "ip='$HTTP_SERVER_VARS[REMOTE_ADDR]' ". - "WHERE planet_id='$Planetid'"); +mysqli_query($db, "UPDATE user set last=NOW(),last_tick='$mytick'". + "ip='$_SERVER[REMOTE_ADDR]' ". + "WHERE planet_id='$Planetid'"); if ($Planetid==1) { -?> -
- - + ?> +
+
+ - + - - + + - - + + - - + + - - + + - + -
Administration
Player Info Player Log Ban Player Player Mail Planet News
Politics Alliances A Members A Forum Player Top
Delete Player Ban IP Idle New Idle old Player move
Scans Units Res/Con Set Highscore Optimize
Galpic Shuffle Reset All Havoc Expand
-
-
- -
- - +
+
+
+ +
+ + - + - - + + - + -
Administration
Player Info Player Log Idle New Idle old Ban IP
Politics Alliances A Members A Forum Player Top
-
-
+ + +
-"; require_once "../footerf.php"; ?> diff --git a/online/admin/afor.php b/online/admin/afor.php index 7ee6cf6..978e326 100644 --- a/online/admin/afor.php +++ b/online/admin/afor.php @@ -2,7 +2,7 @@ /* * MyPHPpa - * Copyright (C) 2003 Jens Beyer + * Copyright (C) 2003, 2007 Jens Beyer * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -31,14 +31,14 @@ function pval ($val) { echo "
\n"; -if ($fthread && $Planetid<=2) { - $res = mysql_query("SELECT gal_id-1024 FROM politics ". +if (ISSET($fthread) && $Planetid<=2) { + $res = mysqli_query("SELECT gal_id-1024 FROM politics ". "WHERE id='$fthread'", $db); - $row = mysql_fetch_row($res); + $row = mysqli_fetch_row($res); $allid = $row[0]; } -if ($allid && $Planetid<=2) { +if (ISSET($allid) && $Planetid<=2) { $myrow["alliance_id"] = $allid; $myrow["status"] = 0; @@ -54,7 +54,7 @@ function pval ($val) { forum_submit ($fstyle, $fid, $fthread); - if ($fthread) { + if (ISSET($fthread)) { forum_show_thread ($fstyle, $fid, $fthread); } else { forum_list_thread ($fstyle, $fid); @@ -62,7 +62,7 @@ function pval ($val) { } else { - $ref = "$PHP_SELF?allid="; + $ref = "$_SERVER[PHP_SELF]?allid="; list_alliances_admin($ref); } diff --git a/online/admin/amem.php b/online/admin/amem.php index fd1ca77..0b71d93 100644 --- a/online/admin/amem.php +++ b/online/admin/amem.php @@ -2,7 +2,7 @@ /* * MyPHPpa - * Copyright (C) 2003 Jens Beyer + * Copyright (C) 2003, 2007 Jens Beyer * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -27,11 +27,11 @@ function pval ($val) { } require_once "../alliance_func.inc"; -require_once "../planet_util.php"; +require_once "../planet_util.inc"; echo "
\n"; -if ($allid && $Planetid<=2) { +if (ISSET($allid) && $Planetid<=2) { $myrow["alliance_id"] = $allid; $myrow["status"] = 0; @@ -42,7 +42,7 @@ function pval ($val) { "Forum

\n"; list_alliance_members($all); } else { - $ref = "$PHP_SELF?allid="; + $ref = "$_SERVER[PHP_SELF]?allid="; list_alliances_admin($ref); } diff --git a/online/admin/apol.php b/online/admin/apol.php index 83905c1..74c5c50 100644 --- a/online/admin/apol.php +++ b/online/admin/apol.php @@ -2,7 +2,7 @@ /* * MyPHPpa - * Copyright (C) 2003 Jens Beyer + * Copyright (C) 2003, 2007 Jens Beyer * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -31,24 +31,25 @@ function pval ($val) { require_once "../forum.inc"; -if ($fthread && $Planetid<=2) { - $res = mysql_query("SELECT gal_id FROM politics ". - "WHERE id='$fthread'", $db); - $row = mysql_fetch_row($res); +if (ISSET($fthread) && $Planetid<=2) { + $res = mysqli_query($db, "SELECT gal_id FROM politics ". + "WHERE id='$fthread'" ); + $row = mysqli_fetch_row($res); $galid = $row[0]; } echo "
\n"; -if ($galid && $Planetid<=2) { +if (ISSET($galid) && $Planetid<=2) { + // buggy. need $myrow[x] / [y] to be from gal. $fstyle = 1; forum_init ($fstyle, $galid); forum_submit ($fstyle, $galid, $fthread); - if ($fthread) { + if (ISSET($fthread)) { forum_show_thread ($fstyle, $galid, $fthread); } else { forum_list_thread ($fstyle, $galid); @@ -58,8 +59,8 @@ function pval ($val) { } else { $q = "SELECT x,y,name,id,members FROM galaxy ". "WHERE members>0 ORDER by x,y"; - $res = mysql_query ($q, $db); - $n = mysql_num_rows($res); + $res = mysqli_query ($db, $q ); + $n = mysqli_num_rows($res); if ($res && $n>0) { echo << @@ -67,10 +68,10 @@ function pval ($val) { Coords MembersName EOF; - while ($row=mysql_fetch_row($res)) { + while ($row=mysqli_fetch_row($res)) { echo "($row[0]:$row[1])". "$row[4]". - "$row[2]\n"; + "$row[2]\n"; } echo "\n"; } else { diff --git a/online/admin/expand.php b/online/admin/expand.php index 4effb48..1bd01ff 100644 --- a/online/admin/expand.php +++ b/online/admin/expand.php @@ -2,7 +2,7 @@ /* * MyPHPpa - * Copyright (C) 2003 Jens Beyer + * Copyright (C) 2003, 2007 Jens Beyer * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -30,15 +30,15 @@ function expand_universe () { for ($i=1; $i<=$universe_size;$i++) { for ($j=1; $j<=$cluster_size;$j++) { - $result = mysql_query ("SELECT id FROM galaxy ". - "WHERE x='$i' AND y='$j'", $db); + $result = mysqli_query ($db, "SELECT id FROM galaxy ". + "WHERE x='$i' AND y='$j'" ); if ($result) { - if (mysql_num_rows($result) == 1) { + if (mysqli_num_rows($result) == 1) { echo "gal $i:$j exist
"; } else { echo "creating gal $i:$j
"; - $result = mysql_query ("INSERT INTO galaxy set x='$i',y='$j'", $db); + $result = mysqli_query ($db, "INSERT INTO galaxy set x='$i',y='$j'" ); } } } diff --git a/online/admin/freset.php b/online/admin/freset.php index 5d7e062..111cae2 100644 --- a/online/admin/freset.php +++ b/online/admin/freset.php @@ -2,7 +2,7 @@ /* * MyPHPpa - * Copyright (C) 2003 Jens Beyer + * Copyright (C) 2003, 2007 Jens Beyer * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -26,10 +26,10 @@ function create_gal ($x, $y) { global $db; - $result = mysql_query ("SELECT id FROM galaxy WHERE x='$x' AND y='$y'", $db); + $result = mysqli_query ($db, "SELECT id FROM galaxy WHERE x='$x' AND y='$y'" ); - if ($result && (mysql_num_rows($result) == 0)) { - $result = mysql_query ("INSERT INTO galaxy set x='$x',y='$y'", $db); + if ($result && (mysqli_num_rows($result) == 0)) { + $result = mysqli_query ($db, "INSERT INTO galaxy set x='$x',y='$y'" ); } } @@ -40,7 +40,7 @@ function trunc_table ($table) { if (file_exists('/tmp/ticker.run') || $table=="") { echo "Cant do that now!
"; } else { - $result = mysql_query ("TRUNCATE TABLE $dbname.$table", $db); + $result = mysqli_query ($db, "TRUNCATE TABLE $dbname.$table" ); if ($result) echo "truncated $table...
\n"; } } @@ -48,44 +48,44 @@ function trunc_table ($table) { function create_admin () { global $db; - $result = mysql_query("INSERT into user ". - "SET login='admin',password='admin'," . - "email='myphppa@web.de',planet_id='1'",$db); + $result = mysqli_query($db, "INSERT into user ". + "SET login='admin',password='admin4'," . + "email='myphppa@web.de',planet_id='1'"); if (!$result) { echo "Failed to insert admin
"; return; } - $result = mysql_query("INSERT into user ". - "SET login='moderator',password='moderator'," . - "email='myphppa@web.de',planet_id='2'",$db); + $result = mysqli_query($db, "INSERT into user ". + "SET login='moderator',password='moderator4'," . + "email='myphppa@web.de',planet_id='2'"); if (!$result) { echo "Failed to insert moderator
"; return; } - $result = mysql_query("INSERT into planet set planetname='here'," . - "leader='Admin',mode=0xF2,x=1,y=1,z=1", $db); - $planet_id = mysql_insert_id ($db); + $result = mysqli_query($db, "INSERT into planet set planetname='here'," . + "leader='Admin',mode=0xF2,x=1,y=1,z=1" ); + $planet_id = mysqli_insert_id ($db); /* signup date, first tick */ - $result = mysql_query("UPDATE user SET planet_id='$planet_id',". + $result = mysqli_query($db, "UPDATE user SET planet_id='$planet_id',". "signup=NOW(),first_tick=0,last=NOW() WHERE ". - "login='admin' AND password='admin'", $db); + "login='admin' AND password='admin'" ); create_user ($planet_id); - $result = mysql_query("INSERT into planet set planetname='the game'," . - "leader='Moderator',mode=0xF2,x=1,y=1,z=2", $db); - $planet_id = mysql_insert_id ($db); + $result = mysqli_query($db, "INSERT into planet set planetname='the game'," . + "leader='Moderator',mode=0xF2,x=1,y=1,z=2" ); + $planet_id = mysqli_insert_id ($db); /* signup date, first tick */ - $result = mysql_query("UPDATE user SET planet_id='$planet_id',". + $result = mysqli_query($db, "UPDATE user SET planet_id='$planet_id',". "signup=NOW(),first_tick=0,last=NOW() WHERE ". - "login='moderator' AND password='moderator'", $db); + "login='moderator' AND password='moderator'" ); create_user ($planet_id); - $result = mysql_query("UPDATE galaxy SET members=2, name='My Galaxy' ". - "WHERE id=1", $db); + $result = mysqli_query($db, "UPDATE galaxy SET members=2, name='My Galaxy' ". + "WHERE id=1" ); } ?> @@ -95,7 +95,7 @@ function create_admin () { \n"; @@ -138,7 +138,7 @@ function create_admin () { } else { ?>
-
+"> diff --git a/online/admin/galpic.php b/online/admin/galpic.php index c98e650..88d13ce 100644 --- a/online/admin/galpic.php +++ b/online/admin/galpic.php @@ -2,7 +2,7 @@ /* * MyPHPpa - * Copyright (C) 2003 Jens Beyer + * Copyright (C) 2003, 2007 Jens Beyer * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -22,21 +22,21 @@ require_once "admhead.php"; require_once "admform.php"; -if ($rid) { +if (ISSET($rid)) { $q = "UPDATE galaxy set pic='' WHERE id=$rid"; - $res = mysql_query ($q, $db); + $res = mysqli_query ($db, $q ); echo "Pic of [$rid] deleted
\n"; } $q = "SELECT x, y, gc, pic, id FROM galaxy where pic!=''"; - $res = mysql_query($q, $db); + $res = mysqli_query($db, $q ); - if ($res && mysql_num_rows($res)>0) { + if ($res && mysqli_num_rows($res)>0) { echo "
You really want to recreate theuniverse ?
You will have to signup again after this
\n"; - while ($row=mysql_fetch_row($res)) { + while ($row=mysqli_fetch_row($res)) { echo "\n"; - echo "\n"; + echo "\n"; echo "\n"; } echo "
($row[0],$row[1])RemoveRemove
\n"; diff --git a/online/admin/havoc.php b/online/admin/havoc.php index 51cc428..8def17c 100644 --- a/online/admin/havoc.php +++ b/online/admin/havoc.php @@ -2,7 +2,7 @@ /* * MyPHPpa - * Copyright (C) 2003 Jens Beyer + * Copyright (C) 2003, 2007 Jens Beyer * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -34,43 +34,43 @@ die; } else { -$res = mysql_query("SELECT leader, planetname, x, y, z, score,". +$res = mysqli_query($db, "SELECT leader, planetname, x, y, z, score,". "metalroids+crystalroids+eoniumroids+uniniroids ". "FROM planet WHERE mode!=0 AND mode!=4 ". - "ORDER BY score DESC LIMIT 1", $db); + "ORDER BY score DESC LIMIT 1" ); $high = 0; -if ($res && mysql_num_rows($res)>0) { - $row = mysql_fetch_row($res); +if ($res && mysqli_num_rows($res)>0) { + $row = mysqli_fetch_row($res); // $rnd = substr($round,-2,2); // $q = "INSERT INTO highscore set round=$rnd,leader='$row[0]',". // "planetname='$row[1]',coords='$row[2]:$row[3]:$row[4]',score=$row[5],". // "roids=$row[6],date=now()"; // echo "[$q]
"; -// mysql_query ($q,$db); +// mysqli_query ($db, $q); $high = $row[5]; } else { echo "Failed"; die; } -//$res = mysql_query("SELECT x, y, SUM(score) AS sc, SUM(metalroids + ". +//$res = mysqli_query($db, "SELECT x, y, SUM(score) AS sc, SUM(metalroids + ". // "crystalroids + eoniumroids + uniniroids) " . // "FROM planet WHERE mode != 0 GROUP by x, y ". -// "ORDER BY sc DESC LIMIT 1", $db); -//if ($res && mysql_num_rows($res)>0) { -// $row = mysql_fetch_row($res); -// $re = mysql_query("SELECT name FROM galaxy ". -// "WHERE x='$row[0]' AND y='$row[1]'", $db); -// $ro = mysql_fetch_row($re); +// "ORDER BY sc DESC LIMIT 1" ); +//if ($res && mysqli_num_rows($res)>0) { +// $row = mysqli_fetch_row($res); +// $re = mysqli_query($db, "SELECT name FROM galaxy ". +// "WHERE x='$row[0]' AND y='$row[1]'" ); +// $ro = mysqli_fetch_row($re); // $q = "INSERT INTO highscore_gal set round=$rnd,galname='$ro[0]',". // "coords='$row[0]:$row[1]',score=$row[2],roids=$row[3],date=now()"; // echo "[$q]
"; -// mysql_query ($q,$db); +// mysqli_query ($db, $q); //} -mysql_query("UPDATE planet SET mode=1 WHERE mode=4 OR mode=0", $db); +mysqli_query($db, "UPDATE planet SET mode=1 WHERE mode=4 OR mode=0" ); echo "Removed vacation
"; $q = "UPDATE planet set metal=metal+30000000000". @@ -83,7 +83,7 @@ "WHERE mode!=0"; echo "[$q]
"; -mysql_query ($q,$db); +mysqli_query ($db, $q); echo "Updated score.
"; } diff --git a/online/admin/high.php b/online/admin/high.php index 7da8676..de75d25 100644 --- a/online/admin/high.php +++ b/online/admin/high.php @@ -2,7 +2,7 @@ /* * MyPHPpa - * Copyright (C) 2003 Jens Beyer + * Copyright (C) 2003, 2007 Jens Beyer * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -34,39 +34,39 @@ die; } else { -$res = mysql_query("SELECT leader, planetname, x, y, z, score,". +$res = mysqli_query($db, "SELECT leader, planetname, x, y, z, score,". "metalroids+crystalroids+eoniumroids+uniniroids ". "FROM planet WHERE mode!=0 AND mode!=4 ". - "ORDER BY score DESC LIMIT 1", $db); + "ORDER BY score DESC LIMIT 1" ); $rnd = substr($round,-2,2); -if ($res && mysql_num_rows($res)>0) { - $row = mysql_fetch_row($res); +if ($res && mysqli_num_rows($res)>0) { + $row = mysqli_fetch_row($res); $q = "INSERT INTO highscore set round=$rnd,leader='$row[0]',". "planetname='$row[1]',coords='$row[2]:$row[3]:$row[4]',score=$row[5],". "roids=$row[6],date=now()"; echo "[$q]
"; - mysql_query ($q,$db); + mysqli_query ($db, $q); echo "Player Highscore done"; } else { echo "Player Highscore Failed"; die; } -$res = mysql_query("SELECT x, y, SUM(score) AS sc, SUM(metalroids + ". +$res = mysqli_query($db, "SELECT x, y, SUM(score) AS sc, SUM(metalroids + ". "crystalroids + eoniumroids + uniniroids) " . "FROM planet WHERE mode != 0 GROUP by x, y ". - "ORDER BY sc DESC LIMIT 1", $db); -if ($res && mysql_num_rows($res)>0) { - $row = mysql_fetch_row($res); - $re = mysql_query("SELECT name FROM galaxy ". - "WHERE x='$row[0]' AND y='$row[1]'", $db); - $ro = mysql_fetch_row($re); + "ORDER BY sc DESC LIMIT 1" ); +if ($res && mysqli_num_rows($res)>0) { + $row = mysqli_fetch_row($res); + $re = mysqli_query($db, "SELECT name FROM galaxy ". + "WHERE x='$row[0]' AND y='$row[1]'" ); + $ro = mysqli_fetch_row($re); $q = "INSERT INTO highscore_gal set round=$rnd,galname='$ro[0]',". "coords='$row[0]:$row[1]',score=$row[2],roids=$row[3],date=now()"; echo "[$q]
"; - mysql_query ($q,$db); + mysqli_query ($db, $q); echo "Galaxy Highscore done"; } else { echo "Galaxy Highscore Failed"; @@ -80,16 +80,16 @@ "AND alliance.id=planet.alliance_id ". "GROUP BY alliance.id ORDER BY a_score DESC LIMIT 1"; -$res = mysql_query($q, $db); +$res = mysqli_query($db, $q ); -if ($res && mysql_num_rows($res)>0) { - $row = mysql_fetch_row($res); +if ($res && mysqli_num_rows($res)>0) { + $row = mysqli_fetch_row($res); $q = "INSERT INTO highscore_alliance set round=$rnd,tag='$row[0]',". "hcname='$row[1]',members=$row[2],score=$row[3],roids=$row[4],". "name='$row[5]',date=now()"; echo "[$q]
"; - mysql_query ($q,$db); + mysqli_query ($db, $q); echo "Alliance highscore done"; diff --git a/online/admin/ipban.php b/online/admin/ipban.php index 80fb070..328e4d8 100644 --- a/online/admin/ipban.php +++ b/online/admin/ipban.php @@ -2,7 +2,7 @@ /* * MyPHPpa - * Copyright (C) 2003 Jens Beyer + * Copyright (C) 2003, 2007 Jens Beyer * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -22,22 +22,22 @@ require_once "admhead.php"; require_once "admform.php"; -if ($submit) echo "Found submit
"; -if ($playerid) echo "Playerid $playerid
"; -if ($verification) echo "Verification: $verification
"; +if (ISSET($submit)) echo "Found submit
"; +if (ISSET($playerid)) echo "Playerid $playerid
"; +if (ISSET($verification)) echo "Verification: $verification
"; -if ($submit && $ip ) { +if (ISSET($submit) && ISSET($ip) ) { - if ($verification && $verification==$ip) { + if (ISSET($verification) && $verification==$ip) { $q = "INSERT INTO iptables set ip='$ip',comment='$comment'"; - mysql_query ($q, $db); + mysqli_query ($db, $q ); echo "
IP banned
"; } else { echo << - +
Really ban this IP?$ip
Yes
Yes
EOF; @@ -47,7 +47,7 @@
- + diff --git a/online/admin/mpdelete.php b/online/admin/mpdelete.php index 903dc9b..d9a9bb5 100644 --- a/online/admin/mpdelete.php +++ b/online/admin/mpdelete.php @@ -2,7 +2,7 @@ /* * MyPHPpa - * Copyright (C) 2003 Jens Beyer + * Copyright (C) 2003, 2007 Jens Beyer * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -27,69 +27,69 @@ for ($playerid=608;$playerid<685; $playerid++) { $q = "SELECT x,y FROM planet WHERE id='$playerid'"; - $result = mysql_query ($q, $db); - if ($result && mysql_num_rows($result) > 0) { - $prow = mysql_fetch_row($result); + $result = mysqli_query ($q, $db); + if ($result && mysqli_num_rows($result) > 0) { + $prow = mysqli_fetch_row($result); $q = "UPDATE user SET password='delete' WHERE planet_id='$playerid'"; - mysql_query ($q, $db); + mysqli_query ($q, $db); $q = "DELETE FROM rc_build WHERE planet_id='$playerid'"; - mysql_query ($q, $db); + mysqli_query ($q, $db); $q = "DELETE FROM rc WHERE planet_id='$playerid'"; - mysql_query ($q, $db); + mysqli_query ($q, $db); $q = "DELETE FROM scan_build WHERE planet_id='$playerid'"; - mysql_query ($q, $db); + mysqli_query ($q, $db); $q = "DELETE FROM scan WHERE planet_id='$playerid'"; - mysql_query ($q, $db); + mysqli_query ($q, $db); $q = "DELETE FROM pds_build WHERE planet_id='$playerid'"; - mysql_query ($q, $db); + mysqli_query ($q, $db); $q = "DELETE FROM pds WHERE planet_id='$playerid'"; - mysql_query ($q, $db); + mysqli_query ($q, $db); $q = "DELETE FROM unit_build WHERE planet_id='$playerid'"; - mysql_query ($q, $db); + mysqli_query ($q, $db); // eigentlich alle msg durchsehen $q = "SELECT id FROM mail WHERE sender_id='$playerid' OR ". "planet_id='$playerid'"; - $res = mysql_query ($q, $db); - while ($mr = mysql_fetch_row($res)) { - mysql_query ("DELETE FROM msg WHERE mail_id='$row[0]'", $db); + $res = mysqli_query ($q, $db); + while ($mr = mysqli_fetch_row($res)) { + mysqli_query ("DELETE FROM msg WHERE mail_id='$row[0]'", $db); } $q = "DELETE FROM mail WHERE sender_id='$playerid' OR ". "planet_id='$playerid'"; - mysql_query ($q, $db); + mysqli_query ($q, $db); // $q = "UPDATE msg SET planet_id=0,folder=0 WHERE planet_id='$playerid'"; - // mysql_query ($q, $db); + // mysqli_query ($q, $db); // $q = "UPDATE mail SET sender_id=0 WHERE sender_id='$playerid'"; - // mysql_query ($q, $db); + // mysqli_query ($q, $db); // $q = "UPDATE mail SET planet_id=0 WHERE planet_id='$playerid'"; - mysql_query ($q, $db); + mysqli_query ($q, $db); $q = "DELETE FROM news WHERE planet_id='$playerid'"; - mysql_query ($q, $db); + mysqli_query ($q, $db); $q = "SELECT fleet_id FROM fleet WHERE planet_id='$playerid'"; - $result = mysql_query ($q, $db); - if ($result && mysql_num_rows($result) > 0) { - while ($row = mysql_fetch_row($result)) { + $result = mysqli_query ($q, $db); + if ($result && mysqli_num_rows($result) > 0) { + while ($row = mysqli_fetch_row($result)) { $q = "DELETE FROM units WHERE id='$row[0]'"; - mysql_query ($q, $db); + mysqli_query ($q, $db); } } $q = "DELETE FROM fleet WHERE planet_id='$playerid'"; - mysql_query ($q, $db); + mysqli_query ($q, $db); $q = "DELETE FROM user WHERE planet_id='$playerid'"; - mysql_query ($q, $db); + mysqli_query ($q, $db); $q = "DELETE FROM planet WHERE id='$playerid'"; - mysql_query ($q, $db); + mysqli_query ($q, $db); $q = "UPDATE galaxy set members=members-1 where x='$prow[0]' ". "AND y='$prow[1]'"; - mysql_query ($q, $db); + mysqli_query ($q, $db); $q = "UPDATE galaxy set gc=0 where x='$prow[0]' ". "AND y='$prow[1]' AND gc='$playerid'"; - mysql_query ($q, $db); + mysqli_query ($q, $db); $q = "UPDATE planet set vote=0 WHERE vote='$playerid' ". "AND x='$prow[0]' AND y='$prow[1]'"; - mysql_query ($q, $db); + mysqli_query ($q, $db); echo "
Planet $playerid deleted
"; } else { diff --git a/online/admin/npa.css b/online/admin/npa.css new file mode 100644 index 0000000..0cbf5d8 --- /dev/null +++ b/online/admin/npa.css @@ -0,0 +1,242 @@ + + diff --git a/online/admin/npb.css b/online/admin/npb.css new file mode 100644 index 0000000..1b7ed25 --- /dev/null +++ b/online/admin/npb.css @@ -0,0 +1,237 @@ + + diff --git a/online/admin/opt.php b/online/admin/opt.php index 2b2ec43..4075b19 100644 --- a/online/admin/opt.php +++ b/online/admin/opt.php @@ -2,7 +2,7 @@ /* * MyPHPpa - * Copyright (C) 2003 Jens Beyer + * Copyright (C) 2003, 2007 Jens Beyer * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -33,11 +33,11 @@ function t() { echo "
"; echo "Optimizing
"; -$res = mysql_query ("SHOW tables",$db); +$res = mysqli_query ($db, "SHOW tables"); -while ($row=mysql_fetch_row($res)) { +while ($row=mysqli_fetch_row($res)) { echo "Table: $row[0] ..."; - mysql_query ("OPTIMIZE TABLE $row[0]", $db); + mysqli_query ($db, "OPTIMIZE TABLE $row[0]" ); t (); echo "
"; } diff --git a/online/admin/pban.php b/online/admin/pban.php index b5ef5a7..fb0f33b 100644 --- a/online/admin/pban.php +++ b/online/admin/pban.php @@ -2,7 +2,7 @@ /* * MyPHPpa - * Copyright (C) 2003 Jens Beyer + * Copyright (C) 2003, 2007 Jens Beyer * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -23,26 +23,26 @@ require_once "admform.php"; require_once "../logging.php"; -if ($submit) echo "Found submit
"; -if ($playerid) echo "Playerid $playerid
"; -if ($verification) echo "Verification: $verification
"; +if (ISSET($submit)) echo "Found submit
"; +if (ISSET($playerid)) echo "Playerid $playerid
"; +if (ISSET($verification)) echo "Verification: $verification
"; -if ($submit && $playerid && $playerid != 1) { +if (ISSET($submit) && ISSET($playerid) && $playerid != 1) { - if ($verification && $verification==$playerid) { + if (ISSET($verification) && $verification==$playerid) { $q = "UPDATE planet set mode=0 WHERE id='$playerid'"; - mysql_query ($q, $db); + mysqli_query ($db, $q ); // echo "DEBUG: $q (not executed)
"; echo "
Planet banned
"; do_log_id ($playerid,2,5,"$reason"); } else { $q = "SELECT leader,planetname,x,y,z FROM planet WHERE id='$playerid'"; - $result = mysql_query ($q, $db); - if ($result && mysql_num_rows($result) > 0) { - $row = mysql_fetch_row($result); + $result = mysqli_query ($db, $q ); + if ($result && mysqli_num_rows($result) > 0) { + $row = mysqli_fetch_row($result); echo << - +
Enter target id:
0) { - while ($row = mysql_fetch_row($result)) { +if ($result && mysqli_num_rows($result) > 0) { + while ($row = mysqli_fetch_row($result)) { echo "\n"; echo "". "". @@ -147,10 +144,10 @@ $q = "SELECT round,tag,name,hcname,members,score,roids,". "date_format(date,'%e %b %y') as dat ". "FROM highscore_alliance ORDER BY round DESC"; -$res = mysql_query($q, $db); +$res = mysqli_query($db, $q ); -if ($res && mysql_num_rows($res)>0) { - while( ($row = mysql_fetch_array($res)) ) { +if ($res && mysqli_num_rows($res)>0) { + while( ($row = mysqli_fetch_array($res)) ) { $sc = pval ($row["score"]); echo << diff --git a/online/index.php b/online/index.php index c2a17d7..eab2612 100644 --- a/online/index.php +++ b/online/index.php @@ -2,7 +2,7 @@ /* * MyPHPpa - * Copyright (C) 2003 Jens Beyer + * Copyright (C) 2003, 2007 Jens Beyer * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -29,7 +29,7 @@ $imgpath="true"; require "header.php"; -if ($submit && $game_closed) { +if (ISSET($submit) && $game_closed) { if ($login!="admin") { $login = ""; $password = ""; @@ -41,35 +41,35 @@ die; } -$result = mysql_query("SELECT tick FROM general"); -$mtrow = mysql_fetch_row($result); +$result = mysqli_query($db, "SELECT tick FROM general"); +$mtrow = mysqli_fetch_row($result); $mytick = $mtrow[0]; -if ($submit && $login && $password) { +if (ISSET($submit) && $login && $password) { - $result = mysql_query("SELECT user.planet_id, planet.mode, " . + $result = mysqli_query($db, "SELECT user.planet_id, planet.mode, " . "user.last + interval 5 minute < now(), ". "user.last IS NOT NULL ". "FROM user, planet ". "WHERE login='$login' ". "AND password='$password' " . - "AND planet.id=user.planet_id", $db); + "AND planet.id=user.planet_id" ); - if (mysql_num_rows($result) == 1) { - $myrow = mysql_fetch_row($result); + if (mysqli_num_rows($result) == 1) { + $myrow = mysqli_fetch_row($result); if (($myrow[1] & 0x0F) == 4 ) { // Vacation mode - $result = mysql_query("SELECT last_sleep+INTERVAL 48 HOUR > now(), ". + $result = mysqli_query($db, "SELECT last_sleep+INTERVAL 48 HOUR > now(), ". "last_sleep+INTERVAL 48 HOUR FROM user ". - "WHERE planet_id='$myrow[0]'", $db); + "WHERE planet_id='$myrow[0]'" ); if ($result) { - $stat = mysql_fetch_row($result); + $stat = mysqli_fetch_row($result); if ($stat[0] == 1) { my_header($topscript,0,0); echo "



\n"; echo "Your account is in Vacation until ". "$stat[1]
"; @@ -83,18 +83,18 @@ } } else if (($myrow[1] & 0x0F) == 3 && $force != 1) { // sleep mode - $result = mysql_query("SELECT last_sleep+INTERVAL 6 HOUR < now(), ". + $result = mysqli_query($db, "SELECT last_sleep+INTERVAL 6 HOUR < now(), ". "last_sleep+INTERVAL 6 HOUR FROM user ". - "WHERE planet_id='$myrow[0]'", $db); + "WHERE planet_id='$myrow[0]'" ); if ($result) { - $stat = mysql_fetch_row($result); + $stat = mysqli_fetch_row($result); if ($stat[0] == 0) { my_header("",0,0); echo "





\n"; echo "
Your account is in sleep mode until ". "$stat[1]\n"; - echo "


\n"; + echo "


\n"; echo ""; echo ""; echo ""; @@ -108,7 +108,7 @@ // just logged out my_header("",0,0); echo "



\n"; echo "
Really ban this player?  @@ -67,7 +67,7 @@
- + diff --git a/online/admin/pdelete.php b/online/admin/pdelete.php index 4cb098d..2f7a08b 100644 --- a/online/admin/pdelete.php +++ b/online/admin/pdelete.php @@ -2,7 +2,7 @@ /* * MyPHPpa - * Copyright (C) 2003 Jens Beyer + * Copyright (C) 2003, 2007 Jens Beyer * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -23,108 +23,108 @@ require_once "admform.php"; -if ($submit) echo "Found submit
"; -if ($playerid) echo "Playerid $playerid
"; -if ($verification) echo "Verification: $verification
"; +if (ISSET($submit)) echo "Found submit
"; +if (ISSET($playerid)) echo "Playerid $playerid
"; +if (ISSET($verification)) echo "Verification: $verification
"; -if ($submit && $playerid && $playerid != 1) { +if (ISSET($submit) && ISSET($playerid) && $playerid != 1) { - if ($verification && $verification==$playerid) { + if (ISSET($verification) && $verification==$playerid) { $q = "SELECT x,y,alliance_id FROM planet WHERE id='$playerid'"; - $result = mysql_query ($q, $db); - if ($result && mysql_num_rows($result) > 0) { - $prow = mysql_fetch_row($result); + $result = mysqli_query ($db, $q ); + if ($result && mysqli_num_rows($result) > 0) { + $prow = mysqli_fetch_row($result); if ($prow[2] != 0) { $q = "SELECT hc FROM alliance WHERE id='$prow[2]' AND hc='$playerid'"; - $res = mysql_query ($q, $db); - if ($res && mysql_num_rows($result) > 0) { + $res = mysqli_query ($db, $q ); + if ($res && mysqli_num_rows($result) > 0) { // this is an HC .. deleting alliance - mysql_query("UPDATE planet SET alliance_id=0,status=status&0xFD ". - "WHERE alliance_id='$prow[2]'", $db); - mysql_query("DELETE FROM alliance WHERE id='$prow[2]'", $db); + mysqli_query($db, "UPDATE planet SET alliance_id=0,status=status&0xFD ". + "WHERE alliance_id='$prow[2]'" ); + mysqli_query($db, "DELETE FROM alliance WHERE id='$prow[2]'" ); echo "Alliance deleted .."; } } $q = "UPDATE user SET password='delete' WHERE planet_id='$playerid'"; - mysql_query ($q, $db); + mysqli_query ($db, $q ); $q = "DELETE FROM rc_build WHERE planet_id='$playerid'"; - mysql_query ($q, $db); + mysqli_query ($db, $q ); $q = "DELETE FROM rc WHERE planet_id='$playerid'"; - mysql_query ($q, $db); + mysqli_query ($db, $q ); $q = "DELETE FROM scan_build WHERE planet_id='$playerid'"; - mysql_query ($q, $db); + mysqli_query ($db, $q ); $q = "DELETE FROM journal WHERE planet_id='$playerid'"; - mysql_query ($q, $db); + mysqli_query ($db, $q ); $q = "DELETE FROM journal WHERE target_id='$playerid'"; - mysql_query ($q, $db); + mysqli_query ($db, $q ); $q = "DELETE FROM scan WHERE planet_id='$playerid'"; - mysql_query ($q, $db); + mysqli_query ($db, $q ); $q = "DELETE FROM pds_build WHERE planet_id='$playerid'"; - mysql_query ($q, $db); + mysqli_query ($db, $q ); $q = "DELETE FROM pds WHERE planet_id='$playerid'"; - mysql_query ($q, $db); + mysqli_query ($db, $q ); $q = "DELETE FROM unit_build WHERE planet_id='$playerid'"; - mysql_query ($q, $db); + mysqli_query ($db, $q ); // eigentlich alle msg durchsehen $q = "SELECT id FROM mail WHERE sender_id='$playerid' OR ". "planet_id='$playerid'"; - $res = mysql_query ($q, $db); - while ($mr = mysql_fetch_row($res)) { - mysql_query ("DELETE FROM msg WHERE mail_id='$row[0]'", $db); + $res = mysqli_query ($db, $q ); + while ($mr = mysqli_fetch_row($res)) { + mysqli_query ($db, "DELETE FROM msg WHERE mail_id='$row[0]'" ); } $q = "DELETE FROM mail WHERE sender_id='$playerid' OR ". "planet_id='$playerid'"; - mysql_query ($q, $db); + mysqli_query ($db, $q ); // $q = "UPDATE msg SET planet_id=0,folder=0 WHERE planet_id='$playerid'"; - // mysql_query ($q, $db); + // mysqli_query ($db, $q ); // $q = "UPDATE mail SET sender_id=0 WHERE sender_id='$playerid'"; - // mysql_query ($q, $db); + // mysqli_query ($db, $q ); // $q = "UPDATE mail SET planet_id=0 WHERE planet_id='$playerid'"; - mysql_query ($q, $db); + mysqli_query ($db, $q ); $q = "DELETE FROM news WHERE planet_id='$playerid'"; - mysql_query ($q, $db); + mysqli_query ($db, $q ); $q = "SELECT fleet_id FROM fleet WHERE planet_id='$playerid'"; - $result = mysql_query ($q, $db); - if ($result && mysql_num_rows($result) > 0) { - while ($row = mysql_fetch_row($result)) { + $result = mysqli_query ($db, $q ); + if ($result && mysqli_num_rows($result) > 0) { + while ($row = mysqli_fetch_row($result)) { $q = "DELETE FROM units WHERE id='$row[0]'"; - mysql_query ($q, $db); + mysqli_query ($db, $q ); } } $q = "DELETE FROM fleet WHERE planet_id='$playerid'"; - mysql_query ($q, $db); + mysqli_query ($db, $q ); $q = "DELETE FROM user WHERE planet_id='$playerid'"; - mysql_query ($q, $db); + mysqli_query ($db, $q ); $q = "DELETE FROM planet WHERE id='$playerid'"; - mysql_query ($q, $db); + mysqli_query ($db, $q ); $q = "SELECT exile_id FROM galaxy WHERE x='$prow[0]' ". "AND y='$prow[1]' AND exile_id='$playerid'"; - $res = mysql_query ($q, $db); - if ($res && mysql_num_rows($result) > 0) { - mysql_query ("UPDATE planet SET exile_vote=0 ". - "WHERE x='$prow[0]' AND y='$prow[1]'", $db); - mysql_query ("UPDATE galaxy SET exile_date=0,exile_id=0 ". - "WHERE x='$prow[0]' AND y='$prow[1]'", $db); + $res = mysqli_query ($db, $q ); + if ($res && mysqli_num_rows($result) > 0) { + mysqli_query ($db, "UPDATE planet SET exile_vote=0 ". + "WHERE x='$prow[0]' AND y='$prow[1]'" ); + mysqli_query ($db, "UPDATE galaxy SET exile_date=0,exile_id=0 ". + "WHERE x='$prow[0]' AND y='$prow[1]'" ); } $q = "UPDATE galaxy set members=members-1 where x='$prow[0]' ". "AND y='$prow[1]'"; - mysql_query ($q, $db); + mysqli_query ($db, $q ); $q = "UPDATE galaxy set gc=0,moc=0 where x='$prow[0]' ". "AND y='$prow[1]' AND gc='$playerid'"; - mysql_query ($q, $db); + mysqli_query ($db, $q ); $q = "UPDATE galaxy set moc=0 where x='$prow[0]' ". "AND y='$prow[1]' AND moc='$playerid'"; - mysql_query ($q, $db); + mysqli_query ($db, $q ); $q = "UPDATE planet set vote=0 WHERE vote='$playerid' ". "AND x='$prow[0]' AND y='$prow[1]'"; - mysql_query ($q, $db); + mysqli_query ($db, $q ); echo "
Planet deleted
"; } else { @@ -132,15 +132,15 @@ } } else { $q = "SELECT leader,planetname,x,y,z FROM planet WHERE id='$playerid'"; - $result = mysql_query ($q, $db); + $result = mysqli_query ($db, $q ); - if ($result && mysql_num_rows($result) > 0) { - $row = mysql_fetch_row($result); + if ($result && mysqli_num_rows($result) > 0) { + $row = mysqli_fetch_row($result); echo "
\n". "
Enter target id:
". "". "". - "". + "". "
Really delete this player?
$row[0] of $row[1] ($row[2]:$row[3]:$row[4])
Yes
Yes
"; } else { echo "
No such Planet
"; @@ -151,7 +151,7 @@
- + diff --git a/online/admin/pidle.php b/online/admin/pidle.php index 8d259f3..ead0f91 100644 --- a/online/admin/pidle.php +++ b/online/admin/pidle.php @@ -2,7 +2,7 @@ /* * MyPHPpa - * Copyright (C) 2003 Jens Beyer + * Copyright (C) 2003, 2007 Jens Beyer * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -29,11 +29,11 @@ function idle_players () { "UNIX_TIMESTAMP(user.signup) as delta,user.last ,user.signup ". " from planet,user where planet_id=id and uniniroids = 3 and ". "metalroids=0 and crystalroids=0 order by last,signup"; - $res = mysql_query($q, $db); + $res = mysqli_query($db, $q ); - if (!$res || mysql_num_rows($res) == 0) + if (!$res || mysqli_num_rows($res) == 0) return; - while ($row=mysql_fetch_array($res)) { + while ($row=mysqli_fetch_array($res)) { echo "". "". "". diff --git a/online/admin/pidle2.php b/online/admin/pidle2.php index ed584e6..e581fd7 100644 --- a/online/admin/pidle2.php +++ b/online/admin/pidle2.php @@ -2,7 +2,7 @@ /* * MyPHPpa - * Copyright (C) 2003 Jens Beyer + * Copyright (C) 2003, 2007 Jens Beyer * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -30,11 +30,11 @@ function idle_players () { "metalroids,crystalroids,eoniumroids,uniniroids ". "from planet,user where planet_id=id ". "order by last,signup limit 20"; - $res = mysql_query($q, $db); + $res = mysqli_query($db, $q ); - if (!$res || mysql_num_rows($res) == 0) + if (!$res || mysqli_num_rows($res) == 0) return; - while ($row=mysql_fetch_array($res)) { + while ($row=mysqli_fetch_array($res)) { echo "". "". "". diff --git a/online/admin/pinfo.php b/online/admin/pinfo.php index c9e83cd..87cef2d 100644 --- a/online/admin/pinfo.php +++ b/online/admin/pinfo.php @@ -2,7 +2,7 @@ /* * MyPHPpa - * Copyright (C) 2003 Jens Beyer + * Copyright (C) 2003, 2007 Jens Beyer * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -19,7 +19,7 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -require_once "../popup_header.php"; +require_once "../popup_header.inc"; require_once "admhead.php"; require_once "admform.php"; require_once "../res_calc.php"; @@ -29,18 +29,17 @@ function pval ($val) { } function print_list_row ($row) { - global $PHP_SELF; echo ""; echo ""; echo ""; echo ""; - echo ""; - if ($row[mode]==0) { + echo ""; + if ($row["mode"]==0) { echo ""; } -if ($submit && $playerid && $playerid !="") { +if (ISSET($submit) && ISSET($playerid) && $playerid !="") { $q = "SELECT leader FROM planet WHERE id='$playerid'"; - $result = mysql_query ($q, $db); + $result = mysqli_query ($db, $q ); - if ($result && mysql_num_rows($result) > 0) { - $row = mysql_fetch_row($result); + if ($result && mysqli_num_rows($result) > 0) { + $row = mysqli_fetch_row($result); $id = $playerid; $pleader = $row[0]; } else { @@ -71,7 +70,7 @@ function print_list_row ($row) {
Enter target id:
$row[0]$row[1]
$row[0]$row[1]
$row[login]$row[password]$row[ip]$row[leader]$row[leader]$row[planetname]"; } else { echo "$row[planetname]"; - switch ($row[mode]) { + switch ($row["mode"]) { case 242: echo "*"; break; case 2: echo "*"; break; case 4: echo "#"; break; @@ -51,12 +50,12 @@ function print_list_row ($row) { echo "$row[id]
- +"> @@ -85,7 +84,7 @@ function print_list_row ($row) { if ($id <0) { - if ($order && $order!="") { + if (ISSET($order) && $order!="") { if ($order == "coords") $order = "x,y,z"; $q = "SELECT login, password, ip, leader, planetname, x, y, z, id, mode ". @@ -95,20 +94,20 @@ function print_list_row ($row) { $q = "SELECT login, password, ip, leader, planetname, x, y, z, id, mode ". "FROM user, planet WHERE planet_id=id order by x,y,z"; } - $result = mysql_query ($q, $db); + $result = mysqli_query ($db, $q ); - if ($result && mysql_num_rows($result) > 0) { + if ($result && mysqli_num_rows($result) > 0) { echo "
Enter target leader:
". ""; - echo "". - "". - "". - "". - "". - "". - ""; - - while ($row=mysql_fetch_array($result)) { + echo "". + "". + "". + "". + "". + "". + ""; + + while ($row=mysqli_fetch_array($result)) { print_list_row ($row); } @@ -129,10 +128,10 @@ function print_list_row ($row) { "uptime ". "FROM user, planet WHERE planet_id='$id' AND id=planet_id"; - $result = mysql_query ($q, $db); + $result = mysqli_query ($db, $q ); - if ($result && mysql_num_rows($result) > 0) { - $row=mysql_fetch_array($result); + if ($result && mysqli_num_rows($result) > 0) { + $row=mysqli_fetch_array($result); echo "
Global Message Options
loginpasswordipleaderplanetnamecoordsid
loginpasswordipleaderplanetnamecoordsid
". ""; echo ""; echo ""; @@ -157,10 +156,10 @@ function print_list_row ($row) { echo ""; echo ""; echo ""; - if($row[del] == 1) { + if($row["del"] == 1) { echo ""; } else { - switch ($row[mode] & 0xF) { + switch ($row["mode"] & 0xF) { case 0: echo ""; break; case 1: echo ""; break; case 2: echo ""; break; @@ -169,7 +168,7 @@ function print_list_row ($row) { } } echo ""; - if (($row[mode] & 0xF) != 2) { + if (($row["mode"] & 0xF) != 2) { echo ""; } else { echo ""; - echo ""; + (calc_per_roid ($row["metalroids"],$row["roid_modifier"]) + $inc[0]) . " M : ". + (calc_per_roid ($row["crystalroids"],$row["roid_modifier"]) + $inc[1]) . " C : ". + (calc_per_roid ($row["eoniumroids"],$row["roid_modifier"]) +$inc[2]) . " E"; + echo ""; echo ""; - if ($row[ip] != "") - echo ""; + if ($row["ip"] != "") + echo ""; else echo ""; echo " +
". @@ -144,10 +143,10 @@ function print_list_row ($row) { echo "
Planetname$row[planetname]
Coords$row[x]:$row[y]:$row[z]
Alliance"; - if ($row[alliance_id]==0) echo "None"; + if ($row["alliance_id"]==0) echo "None"; else { - $r = mysql_query ("SELECT tag FROM alliance WHERE id=$row[alliance_id]",$db); - $ro=mysql_fetch_array($r); + $r = mysqli_query ($db, "SELECT tag FROM alliance WHERE id=$row[alliance_id]"); + $ro=mysqli_fetch_array($r); echo "[$ro[0]]"; } echo "
Image path$row[uimg]
Last Post$row[upost] ($row[uerr] errors)
Modedeleted: $row[deldate] + 12 hoursbannedofflineonline
Last login$row[login_date]
Uptime$row[uptime]
Uptime$row[uptime] + $row[upnow]"; @@ -183,14 +182,14 @@ function print_list_row ($row) { $inc = get_planet_income(); echo "
Income". - (calc_per_roid ($row[metalroids],$row[roid_modifier]) + $inc[0]) . " M : ". - (calc_per_roid ($row[crystalroids],$row[roid_modifier]) + $inc[1]) . " C : ". - (calc_per_roid ($row[eoniumroids],$row[roid_modifier]) +$inc[2]) . " E
Resources". pval($row[metal]) . " M , ". - pval($row[crystal]) . " C, ". pval($row[eonium]) . " E
Resources". pval($row["metal"]) . " M , ". + pval($row["crystal"]) . " C, ". pval($row["eonium"]) . " E
IP$row[ip]
Hostname".gethostbyaddr($row[ip])."
Hostname".gethostbyaddr($row["ip"])."
Hostname
". @@ -199,7 +198,7 @@ function print_list_row ($row) { "News | ". "Mail | ". "Delete | "; - if ($row[mode] == 0) { + if ($row["mode"] == 0) { echo "UnBan | "; } else { echo "Ban | "; diff --git a/online/admin/plog.php b/online/admin/plog.php index 981fd51..5428894 100644 --- a/online/admin/plog.php +++ b/online/admin/plog.php @@ -2,7 +2,7 @@ /* * MyPHPpa - * Copyright (C) 2003 Jens Beyer + * Copyright (C) 2003, 2007 Jens Beyer * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -22,12 +22,12 @@ require_once "admhead.php"; require_once "admform.php"; -if ($submit && $playerid && $playerid !="") { +if (ISSET($submit) && ISSET($playerid) && $playerid !="") { $q = "SELECT leader,planetname FROM planet WHERE id='$playerid'"; - $result = mysql_query ($q, $db); + $result = mysqli_query ($db, $q ); - if ($result && mysql_num_rows($result) > 0) { - $row = mysql_fetch_row($result); + if ($result && mysqli_num_rows($result) > 0) { + $row = mysqli_fetch_row($result); $id = $playerid; $pleader = $row[0]; $pname = $row[1]; @@ -45,7 +45,7 @@
- +"> @@ -58,10 +58,10 @@ 0) + echo "$_SERVER[PHP_SELF]?submit=1&playerid=$id"; else - echo $PHP_SELF; + echo $_SERVER["PHP_SELF"]; ?>"> -> +> \n + +
Enter target leader:
Filter \n"; - if ($data!="") + if (ISSET($data) && $data!="") echo "\n"; else echo "\n"; - while ($row=mysql_fetch_array($result)) { + while ($row=mysqli_fetch_array($result)) { echo ""; } else { if ($row[1]==1 && $row[2]==1) - echo ""; + echo ""; else echo ""; } diff --git a/online/admin/plog2.php b/online/admin/plog2.php index 9d030fd..d9e5087 100644 --- a/online/admin/plog2.php +++ b/online/admin/plog2.php @@ -2,7 +2,7 @@ /* * MyPHPpa - * Copyright (C) 2003 Jens Beyer + * Copyright (C) 2003, 2007 Jens Beyer * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -24,10 +24,10 @@ if ($submit && $playerid && $playerid !="") { $q = "SELECT leader,planetname FROM planet WHERE id='$playerid'"; - $result = mysql_query ($q, $db); + $result = mysqli_query ($db, $q ); - if ($result && mysql_num_rows($result) > 0) { - $row = mysql_fetch_row($result); + if ($result && mysqli_num_rows($result) > 0) { + $row = mysqli_fetch_row($result); $id = $playerid; $pleader = $row[0]; $pname = $row[1]; @@ -44,7 +44,7 @@
". "Logging: [$data]
". "Logging: $pleader of $pname
$row[0]"; // class switch($row[1]) { @@ -255,12 +257,12 @@ if ($row[3] != "") { $data = $row[3]; if ( ereg ("([^\[]*)\[([0-9]*)].*", $data, $out_id)) { - // echo "$out_id[1] ["; + // echo "$out_id[1] ["; echo "$out_id[1] ["; echo "$out_id[2]]$row[3]$row[3]$row[3]
- +"> @@ -58,9 +58,9 @@ "> -
Enter target leader: Filter \n"; if ($data!="") echo "\n"; - while ($row=mysql_fetch_array($result)) { + while ($row=mysqli_fetch_array($result)) { echo ""; } else - echo ""; + echo ""; } else echo ""; diff --git a/online/admin/pmail.php b/online/admin/pmail.php index 571d3d4..abf4342 100644 --- a/online/admin/pmail.php +++ b/online/admin/pmail.php @@ -2,7 +2,7 @@ /* * MyPHPpa - * Copyright (C) 2003 Jens Beyer + * Copyright (C) 2003, 2007 Jens Beyer * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -41,17 +41,17 @@ function print_mail ($r) { } -if ($submit && $pleader && $pleader !="") { +if (ISSET($submit) && ISSET($pleader) && $pleader !="") { $q = "SELECT id FROM planet WHERE leader LIKE '$pleader'"; - $result = mysql_query ($q, $db); + $result = mysqli_query ($db, $q ); - if ($result && mysql_num_rows($result) > 0) { - $row = mysql_fetch_row($result); + if ($result && mysqli_num_rows($result) > 0) { + $row = mysqli_fetch_row($result); $id = $row[0]; } else { $id = $Planetid; } -} if ($submit && $playerid && $playerid !="") { +} if (ISSET($submit) && ISSET($playerid) && $playerid !="") { $id = $playerid; } else { $id = $Planetid; @@ -62,7 +62,7 @@ function print_mail ($r) {
". @@ -181,7 +181,7 @@ else echo "
". "Logging: $pleader of $pname
$row[0]"; // class switch($row[1]) { @@ -227,10 +227,10 @@ if ($row[3] != "") { $data = $row[3]; if ( ereg ("([^\[]*)\[([0-9]*)].*", $data, $out_id)) { - echo "$out_id[1] ["; + echo "$out_id[1] ["; echo "$out_id[2]]$row[3]$row[3]
- +"> @@ -73,9 +73,9 @@ function print_mail ($r) {
0) { - $row=mysql_fetch_array($result); +$result = mysqli_query ($db, "SELECT leader FROM planet WHERE id='$id'" ); +if ($result && mysqli_num_rows($result) > 0) { + $row=mysqli_fetch_array($result); $pleader = $row[0]; } else { $pleader = "MySQL error"; @@ -99,10 +99,10 @@ function print_mail ($r) { "AND ps.id=mail.sender_id AND pr.id=mail.planet_id ". "ORDER BY mail.date DESC"; -$result = mysql_query ($q, $db); +$result = mysqli_query ($db, $q ); -if ($result && mysql_num_rows($result) > 0) { - while ($row=mysql_fetch_array($result)) { +if ($result && mysqli_num_rows($result) > 0) { + while ($row=mysqli_fetch_array($result)) { print_mail ($row); } } diff --git a/online/admin/pmove.php b/online/admin/pmove.php index d660e62..bdacb59 100644 --- a/online/admin/pmove.php +++ b/online/admin/pmove.php @@ -2,7 +2,7 @@ /* * MyPHPpa - * Copyright (C) 2003 Jens Beyer + * Copyright (C) 2003, 2007 Jens Beyer * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -22,7 +22,7 @@ require_once "admhead.php"; require_once "admform.php"; -require_once "../planet_util.php"; +require_once "../planet_util.inc"; require_once "../player_move.php"; function clean_galaxy ($sx, $sy) { @@ -41,9 +41,9 @@ function clean_galaxy ($sx, $sy) { echo "Move failed!!"; } } elseif ($sx && $sy) { - $res = mysql_query ("SELECT z FROM planet WHERE x=$sx AND y=$sy", $db); - if ($res && mysql_num_rows($res)>0) { - while($row=mysql_fetch_row($res)) { + $res = mysqli_query ($db, "SELECT z FROM planet WHERE x=$sx AND y=$sy" ); + if ($res && mysqli_num_rows($res)>0) { + while($row=mysqli_fetch_row($res)) { $resx = player_move ($sx, $sy, $row[0]); if($resx) { $new = get_coord_name ($resx); @@ -58,7 +58,7 @@ function clean_galaxy ($sx, $sy) { } else { ?>
- +">
Enter target leader:
";; } -if ($submit && $pleader && $pleader !="") { +if (ISSET($submit) && ISSET($pleader) && $pleader !="") { $q = "SELECT id FROM planet WHERE leader LIKE '$pleader'"; - $result = mysql_query ($q, $db); + $result = mysqli_query ($db, $q ); - if ($result && mysql_num_rows($result) > 0) { - $row = mysql_fetch_row($result); + if ($result && mysqli_num_rows($result) > 0) { + $row = mysqli_fetch_row($result); $id = $row[0]; } else { $id = $Planetid; } -} if ($submit && $playerid && $playerid !="") { +} if (ISSET($submit) && ISSET($playerid) && $playerid !="") { $id = $playerid; } else { $id = $Planetid; @@ -62,7 +62,7 @@ function print_news_head ($date, $type, $tick) {
Wich coords do you want to move where ?
From:  diff --git a/online/admin/pnews.php b/online/admin/pnews.php index 4c23f9b..ea7cf24 100644 --- a/online/admin/pnews.php +++ b/online/admin/pnews.php @@ -2,7 +2,7 @@ /* * MyPHPpa - * Copyright (C) 2003 Jens Beyer + * Copyright (C) 2003, 2007 Jens Beyer * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -41,17 +41,17 @@ function print_news_head ($date, $type, $tick) { "$date CET, MyT $tick, $txt
- +"> @@ -79,10 +79,10 @@ function print_news_head ($date, $type, $tick) { $q = "SELECT date,type,text,tick from news WHERE planet_id='$id' ". "ORDER BY date DESC"; -$result = mysql_query ($q, $db); +$result = mysqli_query ($db, $q ); -if ($result && mysql_num_rows($result) > 0) { - while ($row = mysql_fetch_row($result)) { +if ($result && mysqli_num_rows($result) > 0) { + while ($row = mysqli_fetch_row($result)) { print_news_head ($row[0], $row[1], $row[3]); echo ""; } diff --git a/online/admin/popup_header.php b/online/admin/popup_header.php index 26c588c..79738cd 100644 --- a/online/admin/popup_header.php +++ b/online/admin/popup_header.php @@ -2,7 +2,7 @@ /* * MyPHPpa - * Copyright (C) 2003 Jens Beyer + * Copyright (C) 2003, 2007 Jens Beyer * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/online/admin/pshuffle.php b/online/admin/pshuffle.php index 27e425d..c0fece9 100644 --- a/online/admin/pshuffle.php +++ b/online/admin/pshuffle.php @@ -2,7 +2,7 @@ /* * MyPHPpa - * Copyright (C) 2003 Jens Beyer + * Copyright (C) 2003, 2007 Jens Beyer * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -31,53 +31,53 @@ $q = "UPDATE galaxy set gc=0, members=0, name='Far Far Away', ". "text=NULL, pic=NULL, metal=0, crystal=0, eonium=0 WHERE id>1"; -$res = mysql_query($q, $db); +$res = mysqli_query($db, $q ); echo "resetting Players..
"; -$res = mysql_query("ALTER TABLE planet DROP index x_y_z", $db); +$res = mysqli_query($db, "ALTER TABLE planet DROP index x_y_z" ); echo "Index dropped
"; $q = "UPDATE planet set x=0,y=0,z=0,vote=0 WHERE id>2"; -$res = mysql_query($q, $db); +$res = mysqli_query($db, $q ); $q = "SELECT id FROM planet WHERE id>2"; -$res = mysql_query($q, $db); +$res = mysqli_query($db, $q ); -$num = mysql_num_rows($res); +$num = mysqli_num_rows($res); $cluster_needed = (int) ceil(($num - ($cluster_size-1)*$gal_size)/($cluster_size*$gal_size))+1; -while ($rid = mysql_fetch_row($res)) { +while ($rid = mysqli_fetch_row($res)) { $x = 0; $y = 0; $z = 0; get_new_coords($x,$y,$z,$cluster_needed); - mysql_query ("UPDATE planet SET x=$x,y=$y,z=$z ". - "WHERE id=$rid[0]", $db); + mysqli_query ($db, "UPDATE planet SET x=$x,y=$y,z=$z ". + "WHERE id=$rid[0]" ); echo "$rid[0] -> $x:$y:$z
"; - mysql_query ("UPDATE galaxy SET members=members+1 ". - "WHERE x=$x AND y=$y", $db); + mysqli_query ($db, "UPDATE galaxy SET members=members+1 ". + "WHERE x=$x AND y=$y" ); } -$res = mysql_query("ALTER TABLE planet ADD unique x_y_z (x,y,z)",$db); +$res = mysqli_query($db, "ALTER TABLE planet ADD unique x_y_z (x,y,z)"); echo "Index generated
"; $q = "SELECT id FROM politics WHERE gal_id!=0 and gal_id<1024"; -$res = mysql_query($q, $db); -while ($rid = mysql_fetch_row($res)) { - mysql_query("DELETE FROM poltext WHERE thread_id=$rid[0]", $db); +$res = mysqli_query($db, $q ); +while ($rid = mysqli_fetch_row($res)) { + mysqli_query($db, "DELETE FROM poltext WHERE thread_id=$rid[0]" ); } $q = "DELETE FROM politics WHERE gal_id!=0"; -$res = mysql_query($q, $db); +$res = mysqli_query($db, $q ); echo "done
"; } else { ?>
- +">
Enter target leader:
 $row[2]
diff --git a/online/admin/ptop.php b/online/admin/ptop.php index 0baf18c..b8c889a 100644 --- a/online/admin/ptop.php +++ b/online/admin/ptop.php @@ -2,7 +2,7 @@ /* * MyPHPpa - * Copyright (C) 2003 Jens Beyer + * Copyright (C) 2003, 2007 Jens Beyer * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -30,11 +30,11 @@ function pval ($val) { "FLOOR(score+(metal+crystal+eonium)*0.09) AS sc ". "FROM planet WHERE mode!=0 ORDER BY sc DESC LIMIT 10"; -$result = mysql_query ($q, $db); +$result = mysqli_query ($db, $q ); echo "
You really want to shuffle the universe ?
\n"; echo "\n"; -while ($row=mysql_fetch_array($result)) { +while ($row=mysqli_fetch_array($result)) { echo "\n"; diff --git a/online/admin/punban.php b/online/admin/punban.php index 142a7e1..a5b2215 100644 --- a/online/admin/punban.php +++ b/online/admin/punban.php @@ -2,7 +2,7 @@ /* * MyPHPpa - * Copyright (C) 2003 Jens Beyer + * Copyright (C) 2003, 2007 Jens Beyer * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -23,25 +23,25 @@ require_once "admform.php"; require_once "../logging.php"; -if ($submit) echo "Found submit
"; -if ($playerid) echo "Playerid $playerid
"; -if ($verification) echo "Verification: $verification
"; +if (ISSET($submit)) echo "Found submit
"; +if (ISSET($playerid)) echo "Playerid $playerid
"; +if (ISSET($verification)) echo "Verification: $verification
"; -if ($submit && $playerid && $playerid != 1) { +if (ISSET($submit) && ISSET($playerid) && $playerid != 1) { - if ($verification && $verification==$playerid) { + if (ISSET($verification) && $verification==$playerid) { $q = "UPDATE planet set mode=1 WHERE id='$playerid'"; - mysql_query ($q, $db); + mysqli_query ($db, $q ); echo "
Planet unbanned
"; do_log_id ($playerid,2,6,""); } else { $q = "SELECT leader,planetname,x,y,z FROM planet WHERE id='$playerid'"; - $result = mysql_query ($q, $db); - if ($result && mysql_num_rows($result) > 0) { - $row = mysql_fetch_row($result); + $result = mysqli_query ($db, $q ); + if ($result && mysqli_num_rows($result) > 0) { + $row = mysqli_fetch_row($result); echo << - +
CoordsScoreResScoreTotal Score
$row[x]:$row[y]:$row[z]". pval($row["score"]) ."". pval($row["rc"]). "". pval($row["sc"]) ."
-
Really unban this player?  @@ -63,7 +63,7 @@
- + diff --git a/online/admin/rc.php b/online/admin/rc.php index ea5e6d0..e0103ad 100644 --- a/online/admin/rc.php +++ b/online/admin/rc.php @@ -2,7 +2,7 @@ /* * MyPHPpa - * Copyright (C) 2003 Jens Beyer + * Copyright (C) 2003, 2007 Jens Beyer * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -22,21 +22,21 @@ require_once "admhead.php"; require_once "admform.php"; -if (($research || $construction || $rc) && $name ) { +if ((ISSET($research) || ISSET($construction) || ISSET($rc)) && ISSET($name) ) { $table = "rc_class"; $values = "id='$id',name='$name'"; - if ($description) $values .= ",description='$description'"; - if ($metal) $values .= ",metal='$metal'"; - if ($crystal) $values .= ",crystal='$crystal'"; - if ($eonium) $values .= ",eonium='$eonium'"; - if ($build_ticks) $values .= ",build_ticks='$build_ticks'"; - if ($construct_id) $values .= ",construct_id='$construct_id'"; - if ($research_id) $values .= ",research_id='$research_id'"; - if ($rc_id) $values .= ",rc_id='$rc_id'"; - if ($block_id) $values .= ",block_id='$block_id'"; - if ($type) $values .= ",type='$type'"; + if (ISSET($description)) $values .= ",description='$description'"; + if (ISSET($metal)) $values .= ",metal='$metal'"; + if (ISSET($crystal)) $values .= ",crystal='$crystal'"; + if (ISSET($eonium)) $values .= ",eonium='$eonium'"; + if (ISSET($build_ticks)) $values .= ",build_ticks='$build_ticks'"; + if (ISSET($construct_id)) $values .= ",construct_id='$construct_id'"; + if (ISSET($research_id)) $values .= ",research_id='$research_id'"; + if (ISSET($rc_id)) $values .= ",rc_id='$rc_id'"; + if (ISSET($block_id)) $values .= ",block_id='$block_id'"; + if (ISSET($type)) $values .= ",type='$type'"; submit_values ($id, $values, $table); } @@ -57,15 +57,15 @@ 0) { - while ($myres = mysql_fetch_row($result)) { +$result = mysqli_query($db, "SELECT * FROM rc_class ORDER BY id"); +if (mysqli_num_rows($result) > 0) { + while ($myres = mysqli_fetch_row($result)) { print_admin_row ($myres, 10); } } ?> - +"> Description 0) { - while ($myres = mysql_fetch_row($result)) { +if ($result && mysqli_num_rows($result) > 0) { + while ($myres = mysqli_fetch_row($result)) { print_admin_row ($myres, 8); } } ?> - +"> Description 0) { - while ($myres = mysql_fetch_row($result)) { + "rc_id,description FROM unit_class ORDER BY id"); +if ($result && mysqli_num_rows($result) > 0) { + while ($myres = mysqli_fetch_row($result)) { print_admin_row ($myres, 22); } } ?> - +"> $row[0] of $row[1]"; } @@ -40,23 +42,23 @@ function select_list ($exclude=0) { } function vote_rows ($vmin, &$table_stub) { - global $db, $myrow, $galcommander_id, $galcommander_name; + global $db, $myrow, $galcommander_id, $galcommander_name, $Planetid; $table_stub = ""; $q = "SELECT leader, planetname, vote, id FROM planet ". "WHERE x=$myrow[x] AND y=$myrow[y] ORDER BY z ASC"; - $result = mysql_query ($q, $db); - // $cnt = mysql_num_rows($result); + $result = mysqli_query ($db, $q ); + // $cnt = mysqli_num_rows($result); $select = "". @@ -255,22 +257,23 @@ function calc_exile_cost() { } } - if ($mytick>0 && $startexile && $exilevote && $myrow["id"] == $galcommander_id) { + if ($mytick>0 && ISSET($startexile) && ISSET($exilevote) + && $myrow["id"] == $galcommander_id) { $ecost = calc_exile_cost(); - $res = mysql_query("SELECT x,y,z FROM planet WHERE id='$exilevote' ". - "AND x=$myrow[x] and y=$myrow[y]", $db); + $res = mysqli_query($db, "SELECT x,y,z FROM planet WHERE id='$exilevote' ". + "AND x=$myrow[x] and y=$myrow[y]" ); - if ($res && mysql_num_rows($res)>0) { + if ($res && mysqli_num_rows($res)>0) { // check for res and take it $pay = 0; $q = "SELECT metal, crystal, eonium FROM galaxy ". "WHERE x='$myrow[x]' AND y='$myrow[y]'"; - $res = mysql_query ($q, $db); + $res = mysqli_query ($db, $q ); if ($res) { - $grow = mysql_fetch_row($res); + $grow = mysqli_fetch_row($res); if (($grow[0]+$grow[1]+$grow[2]) > $ecost) { // ok we have enough @@ -291,8 +294,8 @@ function calc_exile_cost() { } else { $ge -= $ecost; } - mysql_query ("UPDATE galaxy SET metal='$gm',crystal='$gc',eonium='$ge' ". - "WHERE x=$myrow[x] and y=$myrow[y]", $db); + mysqli_query ($db, "UPDATE galaxy SET metal='$gm',crystal='$gc',eonium='$ge' ". + "WHERE x=$myrow[x] and y=$myrow[y]" ); $pay = 1; } else { // not evaluated ! @@ -303,29 +306,29 @@ function calc_exile_cost() { if ( $pay==1 ) { // reset - mysql_query ("UPDATE planet SET exile_vote=0 ". - "WHERE x=$myrow[x] and y=$myrow[y]",$db); + mysqli_query ($db, "UPDATE planet SET exile_vote=0 ". + "WHERE x=$myrow[x] and y=$myrow[y]"); // start - mysql_query("UPDATE galaxy SET exile_id=$exilevote, ". + mysqli_query($db, "UPDATE galaxy SET exile_id=$exilevote, ". "exile_date=now() + INTERVAL 18 HOUR ". - "WHERE x=$myrow[x] and y=$myrow[y]", $db); + "WHERE x=$myrow[x] and y=$myrow[y]" ); // send info $nmsg = "$myrow[leader] of $myrow[planetname] has started an exile ". "vote on You. It will run for 18 hours from now."; insert_into_news ($exilevote, 10, $nmsg); // set my vote - mysql_query ("UPDATE planet SET exile_vote=1 WHERE id='$Planetid'",$db); + mysqli_query ($db, "UPDATE planet SET exile_vote=1 WHERE id='$Planetid'"); $myrow["exile_vote"] = 1; } } else { // CLEAR - mysql_query ("UPDATE planet SET exile_vote=0 ". - "WHERE x=$myrow[x] and y=$myrow[y]",$db); - mysql_query("UPDATE galaxy SET exile_id=0, ". + mysqli_query ($db, "UPDATE planet SET exile_vote=0 ". + "WHERE x=$myrow[x] and y=$myrow[y]"); + mysqli_query($db, "UPDATE galaxy SET exile_id=0, ". "exile_date=0 ". - "WHERE x=$myrow[x] and y=$myrow[y]", $db); + "WHERE x=$myrow[x] and y=$myrow[y]" ); } } } @@ -336,7 +339,7 @@ function calc_exile_cost() { ?>
- +">
Enter target id:
Minister of Communication
@@ -361,36 +364,36 @@ function calc_exile_cost() { echo ""; - $res = mysql_query ("UPDATE galaxy set gc='$galcommander_id' WHERE ". - "x='$myrow[x]' AND y='$myrow[y]'", $db); + $res = mysqli_query ($db, "UPDATE galaxy set gc='$galcommander_id' WHERE ". + "x='$myrow[x]' AND y='$myrow[y]'" ); } else { - $res = mysql_query ("UPDATE galaxy set gc=0,moc=0 ". - "WHERE x='$myrow[x]' AND y='$myrow[y]'", $db); + $res = mysqli_query ($db, "UPDATE galaxy set gc=0,moc=0 ". + "WHERE x='$myrow[x]' AND y='$myrow[y]'" ); } } echo "
Change GC Vote
". "Your GC is $galcommander_name
\n\n
\n"; -$res = mysql_query ("SELECT exile_id, date_format(exile_date,'%D %b %H:%i CEST') ". +$res = mysqli_query ($db, "SELECT exile_id, date_format(exile_date,'%D %b %H:%i CEST') ". "AS exile_date FROM galaxy ". - "WHERE x=$myrow[x] and y=$myrow[y] AND exile_id!=0", $db); + "WHERE x=$myrow[x] and y=$myrow[y] AND exile_id!=0" ); -if ($mytick>0 && $res && mysql_num_rows($res)>0) { +if ($mytick>0 && $res && mysqli_num_rows($res)>0) { if ($exvote) { - mysql_query ("UPDATE planet SET exile_vote='$myexvote' WHERE id='$Planetid'", $db); + mysqli_query ($db, "UPDATE planet SET exile_vote='$myexvote' WHERE id='$Planetid'" ); $myrow["exile_vote"] = $myexvote; } - $row = mysql_fetch_row($res); + $row = mysqli_fetch_row($res); $exwho = get_coord_name ($row[0]); if ($myrow["exile_vote"] == 1) $check_yes = "checked"; else $check_no = "checked"; - $res = mysql_query("SELECT count(*) FROM planet ". - "WHERE x=$myrow[x] and y=$myrow[y] AND exile_vote=1", $db); - $rex = mysql_fetch_row($res); + $res = mysqli_query($db, "SELECT count(*) FROM planet ". + "WHERE x=$myrow[x] and y=$myrow[y] AND exile_vote=1" ); + $rex = mysqli_fetch_row($res); $yes_vote = $rex[0]; $no_vote = $count - $yes_vote; $yes_percent = ((1000 * $yes_vote) / $count) * 1. / 10.; @@ -398,7 +401,7 @@ function calc_exile_cost() { echo << -
+
Exile voting
There is an exile vote running against $exwho[leader] of @@ -421,12 +424,12 @@ function calc_exile_cost() { EOF; } -if ($galcommander_id == $myrow[id]) { +if ($galcommander_id == $myrow["id"]) { $exile_cost = calc_exile_cost(); echo << + \n"; } if ($all["hc"] != $myrow["id"]) { - echo "". + echo "". "\n"; @@ -93,9 +93,9 @@ function delete_alliance () { } $myrow["alliance_id"] = 0; - mysql_query("UPDATE planet SET alliance_id=0,status=status&0xFD ". - "WHERE alliance_id='$all[id]'", $db); - mysql_query("DELETE FROM alliance WHERE id='$all[id]'", $db); + mysqli_query($db, "UPDATE planet SET alliance_id=0,status=status&0xFD ". + "WHERE alliance_id='$all[id]'" ); + mysqli_query($db, "DELETE FROM alliance WHERE id='$all[id]'" ); $msg = "Alliance '[$all[tag]] $all[name]' deleted."; $all = 0; @@ -108,9 +108,9 @@ function list_alliances() { $q = "SELECT tag,name,hcname,members ". "FROM alliance WHERE members>2 OR tag='ADM' ORDER BY members DESC"; - $res = mysql_query( $q, $db); + $res = mysqli_query($db, $q ); - if (!$res || mysql_num_rows($res)==0) { + if (!$res || mysqli_num_rows($res)==0) { echo "No alliances found.
"; return; } @@ -120,7 +120,7 @@ function list_alliances() { "". "\n"; - while ($row=mysql_fetch_row($res)) { + while ($row=mysqli_fetch_row($res)) { echo "". "". "". "\n"; - while ($row=mysql_fetch_row($res)) { - $r_ctl = mysql_query("SELECT COUNT(*) FROM planet WHERE alliance_id=$row[4]", $db); - $r_row = mysql_fetch_row($r_ctl); + while ($row=mysqli_fetch_row($res)) { + $r_ctl = mysqli_query($db, "SELECT COUNT(*) FROM planet WHERE alliance_id=$row[4]" ); + $r_row = mysqli_fetch_row($r_ctl); echo "". "". @@ -164,7 +164,7 @@ function untrusted_msg() { } function list_alliance_members ($all) { - global $db, $myrow, $PHP_SELF; + global $db, $myrow; if (!$all["status"]) { untrusted_msg(); @@ -173,9 +173,9 @@ function list_alliance_members ($all) { $q = "SELECT leader,planetname,x,y,z,id,score,status,mode,has_hostile ". "FROM planet WHERE alliance_id='$all[id]' ORDER BY x,y,z"; - $res = mysql_query( $q, $db); + $res = mysqli_query($db, $q ); - if (!$res || mysql_num_rows($res)==0) { + if (!$res || mysqli_num_rows($res)==0) { echo "No alliance members for $all[tag] found."; return; } @@ -184,7 +184,7 @@ function list_alliance_members ($all) { "\n". "\n"; - while ($row=mysql_fetch_row($res)) { + while ($row=mysqli_fetch_row($res)) { if (($row[8]&0xF) == 2) $online = " * "; else $online = ""; echo " @@ -160,71 +162,71 @@ function ResetBtnClick( form, notscores )
Commander options
diff --git a/online/allforum.php b/online/allforum.php index 30cabd4..d661253 100644 --- a/online/allforum.php +++ b/online/allforum.php @@ -2,7 +2,7 @@ /* * MyPHPpa - * Copyright (C) 2003 Jens Beyer + * Copyright (C) 2003, 2007 Jens Beyer * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -27,6 +27,8 @@ $all = get_alliance(); +if (!ISSET($msg)) $msg = ""; + if ($all) { $fstyle = 2; // alliance $fid = $all["id"] + 1024; @@ -43,7 +45,11 @@ if ($all) { - $msg .= forum_submit ($fstyle, $fid, $fthread); + if (ISSET($fthread)) { + $msg .= forum_submit ($fstyle, $fid, $fthread); + } else { + $msg .= forum_submit ($fstyle, $fid, 0); + } $ftitle = forum_title ($fstyle); @@ -54,7 +60,7 @@ if (!$all["status"]) { untrusted_msg(); } else { - if ($fthread) { + if (ISSET($fthread)) { forum_show_thread ($fstyle, $fid, $fthread); } else { forum_list_thread ($fstyle, $fid); diff --git a/online/alliance.php b/online/alliance.php index 7850216..26f9876 100644 --- a/online/alliance.php +++ b/online/alliance.php @@ -2,7 +2,7 @@ /* * MyPHPpa - * Copyright (C) 2003 Jens Beyer + * Copyright (C) 2003, 2007 Jens Beyer * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -19,10 +19,10 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -require "popup_header.php"; +require "popup_header.inc"; require "standard.php"; -require "planet_util.php"; +require "planet_util.inc"; require "news_util.php"; include_once "alliance_func.inc"; @@ -30,22 +30,22 @@ $all = get_alliance (); -if ($ncreate && $myrow["alliance_id"] == 0) +if (ISSET($ncreate) && $myrow["alliance_id"] == 0) $msg .= create_alliance ($nhc, $ntag, $nname); -if ($ojoin && $osecret && $osecret!="") +if (ISSET($ojoin) && ISSET($osecret) && $osecret!="") $msg .= join_alliance ($osecret); -if ($oquit) +if (ISSET($oquit)) $msg .= leave_alliance(); -if ($osec) +if (ISSET($osec)) $msg .= change_secret (); -if ($odel) +if (ISSET($odel)) $msg .= delete_alliance(); -if ($oela && $offa) +if (ISSET($oela) && ISSET($offa)) $msg .= elect_offa($offa); /* top table is written now */ diff --git a/online/alliance_func.inc b/online/alliance_func.inc index e06a8a4..cbe6a97 100644 --- a/online/alliance_func.inc +++ b/online/alliance_func.inc @@ -2,7 +2,7 @@ /* * MyPHPpa - * Copyright (C) 2003 Jens Beyer + * Copyright (C) 2003, 2007 Jens Beyer * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -22,12 +22,12 @@ function get_alliance () { global $db, $myrow; - if ($myrow[alliance_id] == 0) return 0; + if ($myrow["alliance_id"] == 0) return 0; $q = "SELECT * FROM alliance WHERE id='$myrow[alliance_id]'"; - $res = mysql_query( $q, $db); + $res = mysqli_query($db, $q ); if ($res) - $all = mysql_fetch_array($res); + $all = mysqli_fetch_array($res); else return 0; $all["status"] = !($myrow["status"] & 2); @@ -41,9 +41,9 @@ function print_alliance_status ($all) { if (!$all) return; $q = "SELECT * FROM planet WHERE id='$all[hc]'"; - $res = mysql_query( $q, $db); + $res = mysqli_query($db, $q ); if ($res) - $hc = mysql_fetch_array($res); + $hc = mysqli_fetch_array($res); else { echo "HC missing in DB!"; return; @@ -77,7 +77,7 @@ EOF; " $all[secret]
". "". "
TagMembersNameHC Name
[$row[0]]$row[3]$row[1]"; return; } @@ -146,9 +146,9 @@ function list_alliances_admin($ref) { "IdNameHC Name
[$row[0]]$row[3] ($r_row[0])$row[4]$row[1]
Member listing [$all[tag]]
CoordsNameScore
(" . @@ -206,11 +206,11 @@ function list_alliance_members ($all) { && $row[5] != $myrow["id"]) { if ($myrow["id"] == $all["hc"]) { - echo " [kick]"; + echo " [kick]"; } if ($row[7] & 2) { - echo " [trust]"; + echo " [trust]"; } } @@ -230,15 +230,15 @@ function leave_alliance () { "left your alliance."; insert_into_news ($all["hc"], 11, $text); - mysql_query( "UPDATE planet SET alliance_id=0,status=status&0xFD ". - "WHERE id='$Planetid'", $db); + mysqli_query($db, "UPDATE planet SET alliance_id=0,status=status&0xFD ". + "WHERE id='$Planetid'" ); // affected rows abfragen if ( $Planetid == $all["offa"]) { - mysql_query( "UPDATE alliance SET members=members-1, offa=NULL ". - "WHERE id='$myrow[alliance_id]'", $db); + mysqli_query($db, "UPDATE alliance SET members=members-1, offa=NULL ". + "WHERE id='$myrow[alliance_id]'" ); } else { - mysql_query( "UPDATE alliance SET members=members-1 ". - "WHERE id='$myrow[alliance_id]'", $db); + mysqli_query($db, "UPDATE alliance SET members=members-1 ". + "WHERE id='$myrow[alliance_id]'" ); } $myrow["alliance_id"] = 0; $all = 0; @@ -255,11 +255,11 @@ function kick_alliance ($kid) { if (!$all || $all["hc"] != $Planetid) return "You are not allowed to do this."; - mysql_query( "UPDATE planet SET alliance_id=0,status=status&0xFD ". - "WHERE id='$kid' AND alliance_id='$myrow[alliance_id]'", $db); + mysqli_query($db, "UPDATE planet SET alliance_id=0,status=status&0xFD ". + "WHERE id='$kid' AND alliance_id='$myrow[alliance_id]'" ); // affected rows abfragen - mysql_query( "UPDATE alliance SET members=members-1 ". - "WHERE id='$myrow[alliance_id]'", $db); + mysqli_query($db, "UPDATE alliance SET members=members-1 ". + "WHERE id='$myrow[alliance_id]'" ); $all["members"] -= 1; $text = "You are no longer member of [$all[tag]]."; insert_into_news ($kid, 11, $text); @@ -273,15 +273,15 @@ function join_alliance ($sec) { } $q = "SELECT id FROM alliance WHERE secret='$sec'"; - $res = mysql_query( $q, $db); - if (!$res || mysql_num_rows($res)==0) { + $res = mysqli_query($db, $q ); + if (!$res || mysqli_num_rows($res)==0) { return "No such alliance!."; } - $row=mysql_fetch_row($res); + $row=mysqli_fetch_row($res); - mysql_query( "UPDATE planet SET alliance_id='$row[0]',status=status|2 ". - "WHERE id='$myrow[id]'", $db); - mysql_query( "UPDATE alliance SET members=members+1 WHERE id='$row[0]'", $db); + mysqli_query($db, "UPDATE planet SET alliance_id='$row[0]',status=status|2 ". + "WHERE id='$myrow[id]'" ); + mysqli_query($db, "UPDATE alliance SET members=members+1 WHERE id='$row[0]'" ); $myrow["alliance_id"] = $row[0]; $myrow["status"] = $myrow["status"] | 2; @@ -297,13 +297,13 @@ function join_alliance ($sec) { } function off_menu () { - global $PHP_SELF, $Planetid, $all; + global $Planetid, $all; if (!$all || $all["offa"] != $Planetid) return; echo << -
+ @@ -327,8 +327,8 @@ function elect_offa($offa_id) { if ($all["offa"] == $offa_id) return; if ($all["offa"] > 0) { - mysql_query ("UPDATE alliance SET offa=0 ". - "WHERE id=$all[id]", $db); + mysqli_query ($db, "UPDATE alliance SET offa=0 ". + "WHERE id=$all[id]" ); $msg = "You are not longer Officer in the alliance [$all[tag]]."; insert_into_news ($all["offa"], 11, $msg); $all["offa"] = 0; @@ -337,13 +337,13 @@ function elect_offa($offa_id) { $q = "SELECT x, y, z, leader, planetname FROM planet ". "WHERE id=$offa_id AND alliance_id=$all[id] AND status&2 = 0"; - $res = mysql_query ($q, $db); + $res = mysqli_query ($db, $q ); - if ($res && mysql_num_rows($res)) { - $row = mysql_fetch_row($res); + if ($res && mysqli_num_rows($res)) { + $row = mysqli_fetch_row($res); - mysql_query ("UPDATE alliance SET offa='$offa_id' ". - "WHERE id=$all[id]", $db); + mysqli_query ($db, "UPDATE alliance SET offa='$offa_id' ". + "WHERE id=$all[id]" ); $all["offa"] = $offa_id; $msg = "You are now Officer in the alliance [$all[tag]]."; @@ -362,12 +362,12 @@ function select_offa () { $select = ""; $q = "SELECT x, y, z, leader, planetname, id FROM planet ". "WHERE alliance_id=$all[id] AND status&2 = 0"; - $res = mysql_query ($q, $db); + $res = mysqli_query ($db, $q ); - if ($res && mysql_num_rows($res)) { + if ($res && mysqli_num_rows($res)) { $select = "
Officer options
@@ -426,10 +426,9 @@ EOF; } function join_menu () { - global $PHP_SELF; echo << +
HC options
@@ -445,10 +444,9 @@ EOF; } function create_menu () { - global $PHP_SELF; echo << +
Join an existing alliance
@@ -510,20 +508,20 @@ function create_alliance ($nhc, $ntag, $nname) { // check if tag/name is new $q = "SELECT id FROM alliance ". "WHERE hcname='$nhc' OR name='$nname' OR tag='$ntag'"; - $res = mysql_query ($q, $db); + $res = mysqli_query ($db, $q ); - if ($res && mysql_num_rows($res)==0) { + if ($res && mysqli_num_rows($res)==0) { // create alliance $pw_tmp = md5 (uniqid (rand())); $pw = substr($pw_tmp, 0, 8); $q = "INSERT INTO alliance SET tag='$ntag', hcname='$nhc', ". "members=1, name='$nname', secret='$pw', hc=$myrow[id]"; - $res = mysql_query ($q, $db); - $alid = mysql_insert_id ($db); + $res = mysqli_query ($db, $q ); + $alid = mysqli_insert_id ($db); - mysql_query("UPDATE planet set alliance_id='$alid' ". - "WHERE id='$Planetid'",$db); + mysqli_query($db, "UPDATE planet set alliance_id='$alid' ". + "WHERE id='$Planetid'"); $myrow["alliance_id"] = $alid; @@ -555,8 +553,8 @@ function change_secret () { $pw_tmp = md5 (uniqid (rand())); $pw = substr($pw_tmp, 0, 8); - mysql_query ("UPDATE alliance SET secret='$pw' ". - "WHERE id='$myrow[alliance_id]'", $db); + mysqli_query ($db, "UPDATE alliance SET secret='$pw' ". + "WHERE id='$myrow[alliance_id]'" ); $msg = "Alliance secret updated."; $all["secret"] = $pw; @@ -569,15 +567,15 @@ function trust_member ($mid) { if (!$all || ($all["hc"] != $Planetid && $all["offa"] != $Planetid)) return "You arent allowed to do this"; - mysql_query ("UPDATE planet SET status=status&0xFD ". - "WHERE alliance_id='$myrow[alliance_id]' AND id='$mid' ", $db); - $n = mysql_affected_rows ($db); + mysqli_query ($db, "UPDATE planet SET status=status&0xFD ". + "WHERE alliance_id='$myrow[alliance_id]' AND id='$mid' " ); + $n = mysqli_affected_rows ($db); - $res = mysql_query("SELECT leader,planetname FROM planet ". - "WHERE id='$mid' ", $db); - if (!$res || mysql_num_rows($res) == 0) + $res = mysqli_query($db, "SELECT leader,planetname FROM planet ". + "WHERE id='$mid' " ); + if (!$res || mysqli_num_rows($res) == 0) return "No such planet!"; - $row = mysql_fetch_row($res); + $row = mysqli_fetch_row($res); if ($n == 1) { $msg = "$row[0] of $row[1] now is trusted member of [$all[tag]]."; diff --git a/online/alllist.php b/online/alllist.php index d00abaf..ad268b4 100644 --- a/online/alllist.php +++ b/online/alllist.php @@ -2,7 +2,7 @@ /* * MyPHPpa - * Copyright (C) 2003 Jens Beyer + * Copyright (C) 2003, 2007 Jens Beyer * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -19,13 +19,14 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -require "popup_header.php"; +require "popup_header.inc"; require "standard.php"; include_once "alliance_func.inc"; /* top table is written now */ top_header($myrow); +if (!ISSET($msg)) $msg = ""; titlebox("Alliance listing", $msg); echo "
\n"; diff --git a/online/allmembers.php b/online/allmembers.php index 0ef5707..c8e6bda 100644 --- a/online/allmembers.php +++ b/online/allmembers.php @@ -2,7 +2,7 @@ /* * MyPHPpa - * Copyright (C) 2003 Jens Beyer + * Copyright (C) 2003, 2007 Jens Beyer * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -20,7 +20,7 @@ */ require "standard.php"; -require "planet_util.php"; +require "planet_util.inc"; require "news_util.php"; include_once "alliance_func.inc"; @@ -28,10 +28,10 @@ $all = get_alliance (); -if ($all && $otrust && $otrust!=0) +if ($all && ISSET($otrust) && $otrust!=0) $msg .= trust_member($otrust); -if ($all && $okick && $okick!=0 && $okick != $Planetid) +if ($all && ISSET($okick) && $okick!=0 && $okick != $Planetid) $msg .= kick_alliance($okick); /* top table is written now */ @@ -47,14 +47,12 @@ "
Create a new alliance
HC public name
You arent Member of an alliance". "
\n"; - } else { if ($all["status"]) list_alliance_members($all); else untrusted_msg(); - } ?> diff --git a/online/aposting.php b/online/aposting.php index 605c81c..ddf2661 100644 --- a/online/aposting.php +++ b/online/aposting.php @@ -2,7 +2,7 @@ /* * MyPHPpa - * Copyright (C) 2003 Jens Beyer + * Copyright (C) 2003, 2007 Jens Beyer * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -19,205 +19,7 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -if ($nowin && $nowin == 1) { - $close_script = ""; -} else { - $close_script="\n"; -} +$post_type = 2; -if ($create) { - $extra_header = " Create new thread\n$close_script"; - $mail_id = $reply; -} else if ($reply) { - $extra_header = " Reply\n$close_script"; -} else { - $extra_header = " Edit\n$close_script"; -} -require "standard_pop.php"; - -if ($submit) { - require "post_func.inc"; - check_post(); -} - -require "planet_util.php"; -require "logging.php"; - -$gal_id = $myrow["alliance_id"] + 1024; - -if ($submit) { - - if ((("$subject"!="") || $reply || $edit) - && "$text"!="") { - - if (!$reply && !$edit) { - $q = "INSERT INTO politics SET planet_id='$Planetid', date=NOW(),". - "subject='$subject',gal_id='$gal_id',creator='$myrow[leader]'"; - $result = mysql_query ($q, $db); - $thid = mysql_insert_id ($db); - - } else { - // check if id is valid - - if ($reply) { - $postid = $reply; - $q = "SELECT gal_id FROM politics ". - "WHERE id='$reply' AND gal_id='$gal_id'"; - } else { - $postid = $edit; - $q = "SELECT gal_id FROM politics,poltext ". - "WHERE poltext.id='$edit' AND politics.id=poltext.thread_id ". - "AND gal_id='$gal_id'"; - } - $result = mysql_query ($q, $db); - - if ($result && mysql_num_rows($result) == 1) { - $thid = $postid; - - if ($reply) { - $q = "UPDATE politics SET date=NOW(),planet_id='$Planetid', ". - "replies=replies+1 WHERE id='$thid'"; - $result = mysql_query ($q, $db); - - $q = "UPDATE planet set has_politics = has_politics | 2 ". - "WHERE alliance_id='$myrow[alliance_id]' AND id!='$Planetid'"; - $result = mysql_query ($q, $db); - } - } else { - echo "Wrong parameter found - this incidence will be reported
"; - $q = "INSERT INTO news set planet_id=1,date=now(),type=10,". - "text='Alliance Forum warning\npid: $Planetid\ntext=$text\n'"; - $result = mysql_query ($q, $db); - do_log_me (3, 1, "Wrong alliance forum post"); - } - } - - if ($thid) { - if (!$edit) { - $q = "INSERT INTO poltext SET thread_id='$thid',text='$text',". - "planet_id='$Planetid',date=NOW()"; - $msg = "Successfully posted"; - } else { - // edit - $dbtext = $text . "\n*** Edited ***"; - $q = "UPDATE poltext SET text='$dbtext' ". - "WHERE id='$thid' AND planet_id='$Planetid'"; - $text = $dbtext; - $msg = "Successfully edited your post"; - } - $result = mysql_query ($q, $db); - - } - - } else { - echo "You have to suply all fields
"; - } -} - -echo "

"; -if ($msg) { - echo "$msg
"; -} -?> - -"> - - -"; -} else if ($edit) { - // needs check for planetid - - $q = "SELECT subject,text FROM politics, poltext ". - "WHERE politics.id=poltext.thread_id AND poltext.id='$edit'"; - $result = mysql_query ($q, $db); - - if ($result && mysql_num_rows($result) == 1) { - $row=mysql_fetch_array($result); - - $subject = ereg_replace ("<", "<",$row[0]); - $text = ereg_replace ("<", "<",$row[1]); - } else { - $subject = "Empty"; - } - - echo "Aliance Forum: Edit Posting"; - -} else { - $text = ""; - echo "Alliance Forum: New thread"; -} - -?> - - - - -
-
Subject: - -"; -} else { - echo "$subject"; -} -?> - -
- -
- -     - -     -
- - -
-Return to thread\n"; - else - echo "Return to Alliance Forum\n"; - } else { - echo "Close this Window\n"; - } - -echo "
\n\n"; - -require "footer.php"; +include "post.inc"; ?> diff --git a/online/auth_check.php b/online/auth_check.php index 29b10f7..979c444 100644 --- a/online/auth_check.php +++ b/online/auth_check.php @@ -2,7 +2,7 @@ /* * MyPHPpa - * Copyright (C) 2003 Jens Beyer + * Copyright (C) 2003, 2007 Jens Beyer * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -38,23 +38,23 @@ function pre_auth($Username,$Password,$Planetid,$Valid) { function db_auth($db,$Username,$Password,$Planetid) { global $mysettings; - $result = mysql_query("SELECT user.last,user.settings ". + $result = mysqli_query($db, "SELECT user.last,user.settings ". "FROM user, planet ". "WHERE user.login='$Username' ". "AND md5(user.password)='$Password' ". "AND user.planet_id='$Planetid' ". "AND user.planet_id = planet.id ". "AND (planet.mode&0xF) = 2 ". - "AND now() < user.last + INTERVAL 30 MINUTE",$db); + "AND now() < user.last + INTERVAL 30 MINUTE"); - if (mysql_num_rows($result) != 1) { - mysql_query("UPDATE user SET uptime=". + if (mysqli_num_rows($result) != 1) { + mysqli_query($db, "UPDATE user SET uptime=". "SEC_TO_TIME(UNIX_TIMESTAMP(last) - UNIX_TIMESTAMP(login_date) + ". "TIME_TO_SEC(uptime)) ". - "WHERE planet_id='$Planetid' AND (mode&0xF) = 2", $db); + "WHERE planet_id='$Planetid' AND (mode&0xF) = 2" ); - mysql_query("UPDATE planet SET mode=((mode & 0xF0) + 1) ". - "WHERE id='$Planetid' AND (mode&0xF) = 2", $db); + mysqli_query($db, "UPDATE planet SET mode=((mode & 0xF0) + 1) ". + "WHERE id='$Planetid' AND (mode&0xF) = 2" ); setcookie("Username",""); setcookie("Password",""); @@ -62,7 +62,7 @@ function db_auth($db,$Username,$Password,$Planetid) { Header("Location: error.php"); die; } else { - $row = mysql_fetch_row($result); + $row = mysqli_fetch_row($result); $mysettings = $row[1]; } } diff --git a/online/battlecalc/BC.php b/online/battlecalc/BC.php index b9dcd9f..2bad575 100644 --- a/online/battlecalc/BC.php +++ b/online/battlecalc/BC.php @@ -1,120 +1,122 @@ - - -.css> -MyPHPpa Battle Calculator - + + + .css> + MyPHPpa Battle Calculator + -Code library temporary unavailable.. if this persists for more then 15 minutes, please mail khan
"); +if ( !function_exists("FillFleet") ) + die ("
Code library temporary unavailable.. if this persists for more then 15 minutes, please mail khan
"); - if ( !$NumCalcs ) - $NumCalcs = 1; + if ( !ISSET($NumCalcs) ) + $NumCalcs = 1; - if ( $Checker ) - { - FillFleet( "Load", $HTTP_POST_VARS ); - if ( $Addtype != "att" && $Addtype != "def" && $Addtype != "skip" ) - MainLoop( $NumCalcs); - } - else - FillFleet( "New", $HTTP_POST_VARS ); + if ( ISSET($Checker) && $Checker ) +{ + FillFleet( "Load", $_POST ); + if ( $Addtype != "att" && $Addtype != "def" && $Addtype != "skip" ) + MainLoop( $NumCalcs); +} +else +FillFleet( "New", $_POST ); ?> @@ -129,21 +131,21 @@ function ResetBtnClick( form, notscores ) 0 ) : ?> - + - - - + + +
- - + +
- Version , last update: , Original Made by Joror, (c) WolfPack 2001, hits since installment - - [Mail creator] - - [Orig.: BC Mirrors] - +Version , last update: , Original Made by Joror, (c) WolfPack 2001, hits since installment + +[Mail creator] + +[Orig.: BC Mirrors] +
- + - + - - + + - - - - + + + + +Choose a battlecalc-style : +>WolfPack +>Pilkara.com style (red) + >Old Elysium style (blue) + >Old Concordium style (old PA colors) +
- - - MyPHPpa Battle Calculator
- - (disclaimer: calculations are based on average, so calculations on small numbers may have a significant difference with reality) - -
+ +"> +MyPHPpa Battle Calculator
+ +(disclaimer: calculations are based on average, so calculations on small numbers may have a significant difference with reality) + +
- Mouseover Legend : Primary target, Secondary target, Tertiary target - +Mouseover Legend : Primary target, Secondary target, Tertiary target +
Defending ForcesAttacking ForcesDefending ForcesAttacking Forces
NameAmountLostStunnedNameAmountLostStunnedNameAmountLostStunnedNameAmountLostStunned
- - - - - -
- Ticks to calculate  > - - Show calculation logs - - Show totals
-
+ + + + + +
+Ticks to calculate  > + +Show calculation logs + +Show totals
+
- Paste a unit scan/overview count/battle report : - - - - -
For military screen pastes : - Base Fleet - Fleet 1 - Fleet 2 - Fleet 3 +Paste a unit scan/overview count/battle report : + + + + +
For military screen pastes : +Base Fleet +Fleet 1 +Fleet 2 +Fleet 3
- Choose a battlecalc-style : - >WolfPack - >Pilkara.com style (red) - >Old Elysium style (blue) - >Old Concordium style (old PA colors) -
@@ -246,41 +248,41 @@ function ResetBtnClick( form, notscores )

- + +
+
- +No data."; +if ( $CalcLog == "" ) + $CalcLog = "
No data.
"; - echo ""; + echo ""; + ?> +
Calculator logs for this combat:
Calculator logs for this combat:
$CalcLog
$CalcLog
+
+
+ -
-
-
- - - + diff --git a/online/battlecalc/BCcode.php b/online/battlecalc/BCcode.php index 011341d..2249364 100644 --- a/online/battlecalc/BCcode.php +++ b/online/battlecalc/BCcode.php @@ -28,7 +28,7 @@ /* Paste text */ $PasteText = ""; - function CreateShipGroup( $ShipGroup, $ShipType, $BeginAmount) + function CreateShipGroup( &$ShipGroup, $ShipType, $BeginAmount) { $ShipGroup["Type"] = $ShipType; $ShipGroup["BeginAmount"] = $BeginAmount; @@ -49,23 +49,23 @@ function CalcLog( $InputString, $deepness = 1 ) $CalcLog .= $InputString; } - function AddTotals ( $Type, $Total, $Amount ) + function AddTotals ( $Type, &$Total, $Amount ) { - $Total["Amount"] += $Amount; - $Total["Fuel"] += $Amount * $Type["Fuel"]; - $Total["Crystal"] += $Amount * $Type["Crystal"]; - $Total["Metal"] += $Amount * $Type["Metal"]; - $Total["Eonium"] += $Amount * $Type["Eonium"]; - $Total["Worth"] += $Amount * ( $Type["Crystal"] + $Type["Metal"] + $Type["Eonium"] ) / 10; + $Total["Amount"] = (ISSET($Total) && array_key_exists("Amount", $Total)?$Total["Amount"]:0) + $Amount; + $Total["Fuel"] = (ISSET($Total) && array_key_exists("Fuel", $Total )?$Total["Fuel"] :0) + $Amount * $Type["Fuel"]; + $Total["Crystal"] = (ISSET($Total) && array_key_exists("Crystal", $Total )?$Total["Crystal"] :0) + $Amount * $Type["Crystal"]; + $Total["Metal"] = (ISSET($Total) && array_key_exists("Metal", $Total )?$Total["Metal"] :0) + $Amount * $Type["Metal"]; + $Total["Eonium"] = (ISSET($Total) && array_key_exists("Eonium", $Total )?$Total["Eonium"] :0) + $Amount * $Type["Eonium"]; + $Total["Worth"] = (ISSET($Total) && array_key_exists("Worth", $Total )?$Total["Worth"] :0) + $Amount * ( $Type["Crystal"] + $Type["Metal"] + $Type["Eonium"] ) / 10; if ( $Type["ShipClass"] == "RO" && $Type["Name"] != "Uninitiated roid" ) - $Total["Worth"] += $Amount * 1500; + $Total["Worth"] = (ISSET($Total) && array_key_exists("Worth", $Total )?$Total["Worth"] :0) + $Amount * 1500; } - function CalcTotals ( $Flt, $t, $Totals ) + function CalcTotals ( $Flt, $t, &$Totals ) { - AddTotals( $Flt["Ships"][$t]["Type"], &$Totals["TotalShips"], $Flt["Ships"][$t]["BeginAmount"] ); - AddTotals( $Flt["Ships"][$t]["Type"], &$Totals["TotalLost"], $Flt["Ships"][$t]["BeginAmount"]- $Flt["Ships"][$t]["Amount"] ); /* Removed " + $Flt[$t]["Gained"]" */ - AddTotals( $Flt["Ships"][$t]["Type"], &$Totals["TotalStunned"], $Flt["Ships"][$t]["Stunned"] ); + AddTotals( $Flt["Ships"][$t]["Type"], $Totals["TotalShips"], $Flt["Ships"][$t]["BeginAmount"] ); + AddTotals( $Flt["Ships"][$t]["Type"], $Totals["TotalLost"], $Flt["Ships"][$t]["BeginAmount"]- $Flt["Ships"][$t]["Amount"] ); /* Removed " + $Flt[$t]["Gained"]" */ + AddTotals( $Flt["Ships"][$t]["Type"], $Totals["TotalStunned"], $Flt["Ships"][$t]["Stunned"] ); } @@ -77,24 +77,24 @@ function MainLoop ( $NumCalcs ) { $CalcLogBuffer[0] = "
TICK ". ($t+1) ."
"; - ClearHitsStuns( &$Fleet[0]["Ships"] ); - ClearHitsStuns( &$Fleet[1]["Ships"] ); + ClearHitsStuns( $Fleet[0]["Ships"] ); + ClearHitsStuns( $Fleet[1]["Ships"] ); for( $InitCount = 0; $InitCount < 16; $InitCount++ ) { - ActInitiative( &$Fleet[0], &$Fleet[1], $InitCount, 0 ); - ActInitiative( &$Fleet[1], &$Fleet[0], $InitCount, 1 ); - CleanUp( &$Fleet[0] ); - CleanUp( &$Fleet[1] ); + ActInitiative( $Fleet[0], $Fleet[1], $InitCount, 0 ); + ActInitiative( $Fleet[1], $Fleet[0], $InitCount, 1 ); + CleanUp( $Fleet[0] ); + CleanUp( $Fleet[1] ); } $Fleet[0]["Totals"] = null; $Fleet[1]["Totals"] = null; for ( $x = 0; $x < count($Fleet[0]["Ships"]); $x++ ) - CalcTotals( $Fleet[0], $x, &$Fleet[0]["Totals"] ); + CalcTotals( $Fleet[0], $x, $Fleet[0]["Totals"] ); for ( $x = 0; $x < count($Fleet[1]["Ships"]); $x++ ) - CalcTotals( $Fleet[1], $x, &$Fleet[1]["Totals"] ); + CalcTotals( $Fleet[1], $x, $Fleet[1]["Totals"] ); if ( $Fleet[0]["PlanetScore"] != 0 ) $Fleet[0]["PlanetScore"] -= round($Fleet[0]["Totals"]["TotalLost"]["Worth"]); @@ -114,12 +114,12 @@ function MainLoop ( $NumCalcs ) } - function ActInitiative ( $AttFlt, $DefFlt, $InitCount, $who ) + function ActInitiative ( &$AttFlt, &$DefFlt, $InitCount, $who ) { global $CalcLogBuffer; - $Att = &$AttFlt[Ships]; - $Def = &$DefFlt[Ships]; + $Att = &$AttFlt["Ships"]; + $Def = &$DefFlt["Ships"]; for( $t = 0; $t < count($Att); $t++ ) { @@ -129,8 +129,8 @@ function ActInitiative ( $AttFlt, $DefFlt, $InitCount, $who ) $CalcLogBuffer[1] = "
Acting out initiative $InitCount :
"; - CalcLog ( "
Acting out initiative $InitCount : ($Att[Side]) ". $Att[$t]["Type"]["Name"] ."
"); - CalcLog ( "Total Guns : $Guns
"); + CalcLog ( "
Acting out initiative $InitCount : (".(array_key_exists("Side",$Att)?$Att["Side"]:0).") ". $Att[$t]["Type"]["Name"] ."
"); + CalcLog ( "Total Guns : ".(ISSET($Guns)?$Guns:0)."
"); $CalcLogBuffer[3] = ""; $Done = false; @@ -144,7 +144,7 @@ function ActInitiative ( $AttFlt, $DefFlt, $InitCount, $who ) else $CalcLogBuffer[2] = "Primary targets:
"; - list( $GunsLeft, $Done) = AttackTargets( &$AttFlt, &$Att[$t] , &$DefFlt, &$Def, $Att[$t]["Type"]["Target1"], $GunsLeft ); + list( $GunsLeft, $Done) = AttackTargets( $AttFlt, $Att[$t] , $DefFlt, $Def, $Att[$t]["Type"]["Target1"], $GunsLeft ); CalcLog ( "
Guns left after target1 : $GunsLeft
"); $CalcLogBuffer[3] = "Restshots!"; } @@ -159,7 +159,7 @@ function ActInitiative ( $AttFlt, $DefFlt, $InitCount, $who ) $CalcLogBuffer[2] = "Secondary targets (rest shots):
"; else $CalcLogBuffer[2] = "Secondary targets:
"; - list( $GunsLeft, $Done) = AttackTargets( &$AttFlt, &$Att[$t] , &$DefFlt, &$Def, $Att[$t]["Type"]["Target2"], $GunsLeft ); + list( $GunsLeft, $Done) = AttackTargets( $AttFlt, $Att[$t] , $DefFlt, $Def, $Att[$t]["Type"]["Target2"], $GunsLeft ); CalcLog ( "
Guns left after target2 : $GunsLeft
"); $CalcLogBuffer[3] = "Restshots!"; } @@ -175,7 +175,7 @@ function ActInitiative ( $AttFlt, $DefFlt, $InitCount, $who ) else $CalcLogBuffer[2] = "Tertiary targets:
"; - list( $GunsLeft, $Done) = AttackTargets( &$AttFlt, &$Att[$t] , &$DefFlt, &$Def, $Att[$t]["Type"]["Target3"], $GunsLeft ); + list( $GunsLeft, $Done) = AttackTargets( $AttFlt, $Att[$t] , $DefFlt, $Def, $Att[$t]["Type"]["Target3"], $GunsLeft ); CalcLog ( "
Guns left after target3 : $GunsLeft
"); $CalcLogBuffer[3] = "Restshots!"; } @@ -187,8 +187,8 @@ function ActInitiative ( $AttFlt, $DefFlt, $InitCount, $who ) if ( $InitCount == 0 ) { - CleanUp( &$AttFlt ); - CleanUp( &$DefFlt ); + CleanUp( $AttFlt ); + CleanUp( $DefFlt ); } } } @@ -218,7 +218,7 @@ function IsTarget ( $AttType, $DefType, $Target ) return false; } - function AttackTargets( $AttFlt, $Att, $DefFlt, $Def, $Target, $inGuns ) + function AttackTargets( &$AttFlt, &$Att, &$DefFlt, &$Def, $Target, $inGuns ) { global $CalcType, $Warning, $CalcLogBuffer, $RoidChance, $RoidChanceHistory, $CapRule; @@ -330,8 +330,11 @@ function AttackTargets( $AttFlt, $Att, $DefFlt, $Def, $Target, $inGuns ) $CalcLogBuffer[1] = null; $CalcLogBuffer[2] = null; } - $ShotsFiredNow = ResolveAvgShots( $FiringOnThese, &$Att, &$Def[$t], &$Def, $RoidChance); - $ShotsUsed += $ShotsFiredNow; + $ShotsFiredNow = ResolveAvgShots( $FiringOnThese, $Att, $Def[$t], $Def, $RoidChance); + if (ISSET($ShotsUsed)) + $ShotsUsed += $ShotsFiredNow; + else + $ShotsUsed = $ShotsFiredNow; if ( $ShotsFiredNow < $FiringOnThese ) CalcLog( ", ".( $FiringOnThese - $ShotsFiredNow )." guns unused.
", 2 ); @@ -360,7 +363,7 @@ function AttackTargets( $AttFlt, $Att, $DefFlt, $Def, $Target, $inGuns ) return array($inGuns-$ShotsUsed, false); } - function ResolveAvgShots( $FiringOnThese, $AttShips, $DefShips, $Def, $RoidChance ) + function ResolveAvgShots( $FiringOnThese, &$AttShips, &$DefShips, &$Def, $RoidChance ) { global $CalcLogBuffer; @@ -542,7 +545,7 @@ function ResolveShot( $AttShips, $DefShips ) // $DefShips["BeingStolen"] = true; } - function CleanUp( $DefFlt ) + function CleanUp( &$DefFlt ) { $Def = &$DefFlt["Ships"]; $DefFlt["Totals"] = null; @@ -578,11 +581,11 @@ function CleanUp( $DefFlt ) $Def[$t]["ToBeStunned"] = 0; $Def[$t]["TargetNr"] = 0; - CalcTotals( &$DefFlt, $t, &$DefFlt["Totals"] ); + CalcTotals( $DefFlt, $t, $DefFlt["Totals"] ); } } - function ClearHitsStuns ( $Flt ) + function ClearHitsStuns ( &$Flt ) { for ( $t = 0; $t < count($Flt); $t++ ) { @@ -607,10 +610,13 @@ function GetJSTargets ( $Att, $AttNr, $Def, $Side, $Target ) for( $t = 0; $t < count($Def); $t++ ) { - if ( IsTarget( $Att[$AttNr]["Type"], $Def[$t]["Type"], $Att[$AttNr]["Type"][$Target] ) ) + if ( array_key_exists ($AttNr, $Att) + && IsTarget( $Att[$AttNr]["Type"], + $Def[$t]["Type"], + $Att[$AttNr]["Type"][$Target] ) ) { - if ( $Tel++ > 0 ) $ArrayStr .= ","; - $ArrayStr .= $t; + if ( $Tel++ > 0 ) $ArrayStr .= ","; + $ArrayStr .= $t; } } @@ -623,7 +629,7 @@ function GetJSTargets ( $Att, $AttNr, $Def, $Side, $Target ) } - function WriteJSInfo( $Att, $Def, $Side ) + function WriteJSInfo( &$Att, &$Def, $Side ) { echo " ShipTargets[$Side] = new Array;\n"; @@ -695,7 +701,7 @@ function MakeResult( $amount, $report, $report_in_place )
Planet score points @@ -822,8 +828,14 @@ function MakeResult( $amount, $report, $report_in_place ) { $MaxGrab += floor($RoidChance*$BeginAmount); $BeginAmount -= floor($RoidChance*$BeginAmount); - $GrabMax[$i] += floor($RoidChance*$BeginAmount); - $GrabActual[$i] += $Def[$tt]["BeginAmount"] - $Def[$tt]["Amount"]; + if (ISSET($GrabMax) && array_key_exists($i, $GrabMax)) + $GrabMax[$i] += floor($RoidChance*$BeginAmount); + else + $GrabMax[$i] = floor($RoidChance*$BeginAmount); + if (ISSET($GrabActual) && array_key_exists($i, $GrabActual)) + $GrabActual[$i] += $Def[$tt]["BeginAmount"] - $Def[$tt]["Amount"]; + else + $GrabActual[$i] = $Def[$tt]["BeginAmount"] - $Def[$tt]["Amount"]; } $text[] = "". $RoidGrab ." ". $Def[$tt]["Type"]["Name"] ."s, ". $MaxGrab ." max"; @@ -897,68 +909,68 @@ function FillFleet( $Command, $Array ) $Fleet[1]["Totals"] = null; /* Edit input value for netscape */ - $Array[input] = preg_replace( "/^\x20+(.*)$/m", "\\1", $Array[input]); - $Array[input] = preg_replace( "/\n\r/", "\n \r", $Array[input]); - /* Edit input value for opera & netscape finish */ - $Array[input] = preg_replace( "/\r\n/", " ", $Array[input]); + $Array["input"] = preg_replace( "/^\x20+(.*)$/m", "\\1", $Array["input"]); + $Array["input"] = preg_replace( "/\n\r/", "\n \r", $Array["input"]); + /* Edit input value for opera & netscape finish */ + $Array["input"] = preg_replace( "/\r\n/", " ", $Array["input"]); - $PasteText = $Array[input]; + $PasteText = $Array["input"]; /* process unit scan/overview/military pastes */ - if ( $Array[input] && $Array[Addtype] != "BattleReport" ) + if ( $Array["input"] && $Array["Addtype"] != "BattleReport" ) { - // $Array[input] = preg_replace( "/\r/", " ", $Array[input]); - // $Array[input] = preg_replace( "/\n/", " ", $Array[input]); - if ( $Array[fleetbase] || $Array[fleet1] || $Array[fleet2] || $Array[fleet3] ) - preg_match_all( "/(\w*\s?[\w]+)\s([0-9]+|\s)\s([0-9]+|\s)\s([0-9]+|\s)\s([0-9]+|\s)([^0-9a-zA-Z]|$)/iU", $Array[input], $output, PREG_SET_ORDER ); + // $Array["input"] = preg_replace( "/\r/", " ", $Array["input"]); + // $Array["input"] = preg_replace( "/\n/", " ", $Array["input"]); + if ( $Array["fleetbase"] || $Array["fleet1"] || $Array["fleet2"] || $Array["fleet3"] ) + preg_match_all( "/(\w*\s?[\w]+)\s([0-9]+|\s)\s([0-9]+|\s)\s([0-9]+|\s)\s([0-9]+|\s)([^0-9a-zA-Z]|$)/iU", $Array["input"], $output, PREG_SET_ORDER ); else - preg_match_all( "/(\w*\s?[\w]+)\s([0-9]+)([^0-9]|$)/isU", $Array[input], $output, PREG_SET_ORDER ); + preg_match_all( "/(\w*\s?[\w]+)\s([0-9]+)([^0-9]|$)/isU", $Array["input"], $output, PREG_SET_ORDER ); foreach ( (array)$output as $row ) { - if ( $Array[fleetbase] || $Array[fleet1] || $Array[fleet2] || $Array[fleet3] ) + if ( $Array["fleetbase"] || $Array["fleet1"] || $Array["fleet2"] || $Array["fleet3"] ) { - if ( $Array[fleetbase] ) + if ( $Array["fleetbase"] ) $row[2] = (int)$row[2]; else $row[2] = 0; - if ( $Array[fleet1] ) + if ( $Array["fleet1"] ) $row[2] += (int)$row[3]; - if ( $Array[fleet2] ) + if ( $Array["fleet2"] ) $row[2] += (int)$row[4]; - if ( $Array[fleet3] ) + if ( $Array["fleet3"] ) $row[2] += (int)$row[5]; } switch ( trim($row[1]) ) { - case "Metal" : $ShipAddArray[$Array[Addtype]]["Metal roid"] = $row[2]; break; - case "Metal Asteroids" : $ShipAddArray[$Array[Addtype]]["Metal roid"] = $row[2]; break; - case "Crystal" : $ShipAddArray[$Array[Addtype]]["Crystal roid"] = $row[2]; break; - case "Crystal Asteroids" : $ShipAddArray[$Array[Addtype]]["Crystal roid"] = $row[2]; break; - case "Eonium" : $ShipAddArray[$Array[Addtype]]["Eonium roid"] = $row[2]; break; - case "Eonium Asteroids" : $ShipAddArray[$Array[Addtype]]["Eonium roid"] = $row[2]; break; + case "Metal" : $ShipAddArray[$Array["Addtype"]]["Metal roid"] = $row[2]; break; + case "Metal Asteroids" : $ShipAddArray[$Array["Addtype"]]["Metal roid"] = $row[2]; break; + case "Crystal" : $ShipAddArray[$Array["Addtype"]]["Crystal roid"] = $row[2]; break; + case "Crystal Asteroids" : $ShipAddArray[$Array["Addtype"]]["Crystal roid"] = $row[2]; break; + case "Eonium" : $ShipAddArray[$Array["Addtype"]]["Eonium roid"] = $row[2]; break; + case "Eonium Asteroids" : $ShipAddArray[$Array["Addtype"]]["Eonium roid"] = $row[2]; break; case "Resource" : case "Unknown" : case "Uninitiated" : - case "Unknown Asteroids" : $ShipAddArray[$Array[Addtype]]["Uninitiated roid"] = $row[2]; break; + case "Unknown Asteroids" : $ShipAddArray[$Array["Addtype"]]["Uninitiated roid"] = $row[2]; break; case "Roid Score" : - case "Score" : $Array[$Array[Addtype][0]."planetscore"] = $row[2]; break; - default : $ShipAddArray[$Array[Addtype]][trim("$row[1]")] = $row[2]; + case "Score" : $Array[$Array["Addtype"][0]."planetscore"] = $row[2]; break; + default : $ShipAddArray[$Array["Addtype"]][trim("$row[1]")] = $row[2]; } } } /* process battle report */ - if ( $Array[input] && $Array[Addtype] == "BattleReport") + if ( $Array["input"] && $Array["Addtype"] == "BattleReport") { - // $Array[input] = preg_replace( "/\n\r/", "\n \r", $Array[input]); - // $Array[input] = preg_replace( "/\r\n/", " ", $Array[input]); + // $Array["input"] = preg_replace( "/\n\r/", "\n \r", $Array["input"]); + // $Array["input"] = preg_replace( "/\r\n/", " ", $Array["input"]); global $NumCalcs; - preg_match_all( "|(\w*\s?[\w]+)\s*((\s[0-9]+)+)|", $Array[input], $output, PREG_SET_ORDER ); + preg_match_all( "|(\w*\s?[\w]+)\s*((\s[0-9]+)+)|", $Array["input"], $output, PREG_SET_ORDER ); if ( $NumCalcs != 1 ) { @@ -975,7 +987,7 @@ function FillFleet( $Command, $Array ) case "Eonium" : $ShipType = "Eonium roid"; break; case "Unknown" : case "Resource" : $ShipType = "Uninitiated roid"; break; - case "Score" : $Array[planetscore] = $row[2];break; + case "Score" : $Array["planetscore"] = $row[2];break; default : $ShipType = trim($row[1]); } @@ -1005,10 +1017,10 @@ function FillFleet( $Command, $Array ) } } } - $Fleet[0]["PlanetScore"] = $Array[aplanetscore]; - $Fleet[0]["PlanetScoreRatio"] = $Array[aplanetscoreratio]; - $Fleet[1]["PlanetScore"] = $Array[dplanetscore]; - $Fleet[1]["PlanetScoreRatio"] = $Array[dplanetscoreratio]; + $Fleet[0]["PlanetScore"] = $Array["aplanetscore"]; + $Fleet[0]["PlanetScoreRatio"] = $Array["aplanetscoreratio"]; + $Fleet[1]["PlanetScore"] = $Array["dplanetscore"]; + $Fleet[1]["PlanetScoreRatio"] = $Array["dplanetscoreratio"]; } @@ -1021,34 +1033,38 @@ function FillFleet( $Command, $Array ) if ( $key[0] == "t" ) { /* clear values if inserting battlereport */ - if ( $Array[Addtype] == "BattleReport" ) + if ( $Array["Addtype"] == "BattleReport" ) $value = 0; if ( $key[1] == "a" ) { - if ( $Array[Addtype] ) + if ( $Array["Addtype"] ) { + if (ISSET($ShipAddArray)) $value += $ShipAddArray["att"][$ShipTypes[$tel_att]["Name"]]; - CreateShipGroup( &$Fleet[0]["Ships"][$tel_att], $ShipTypes[$tel_att], $value); - CalcTotals( $Fleet[0], $tel_att, &$Fleet[0]["Totals"] ); + } + CreateShipGroup( $Fleet[0]["Ships"][$tel_att], $ShipTypes[$tel_att], $value); + CalcTotals( $Fleet[0], $tel_att, $Fleet[0]["Totals"] ); $tel_att++; } elseif ( $key[1] == "d" ) { - if ( $Array[Addtype] ) + if ( $Array["Addtype"] ){ + if (ISSET($ShipAddArray)) $value += $ShipAddArray["def"][$ShipTypes[$tel_def]["Name"]]; - CreateShipGroup( &$Fleet[1]["Ships"][$tel_def], $ShipTypes[$tel_def], $value); - CalcTotals( $Fleet[1], $tel_def, &$Fleet[1]["Totals"] ); + } + CreateShipGroup( $Fleet[1]["Ships"][$tel_def], $ShipTypes[$tel_def], $value); + CalcTotals( $Fleet[1], $tel_def, $Fleet[1]["Totals"] ); $tel_def++; } } } - $Fleet[0]["PlanetScore"] = $Array[aplanetscore]; - $Fleet[0]["PlanetScoreRatio"] = $Array[aplanetscoreratio]; - $Fleet[1]["PlanetScore"] = $Array[dplanetscore]; - $Fleet[1]["PlanetScoreRatio"] = $Array[dplanetscoreratio]; + $Fleet[0]["PlanetScore"] = (array_key_exists("aplanetscore",$Array)?$Array["aplanetscore"]:0); + $Fleet[0]["PlanetScoreRatio"] = (array_key_exists("aplanetscoreratio", $Array)?$Array["aplanetscoreratio"]:0); + $Fleet[1]["PlanetScore"] = (array_key_exists("dplanetscore", $Array)?$Array["dplanetscore"]:0); + $Fleet[1]["PlanetScoreRatio"] = (array_key_exists("dplanetscoreratio", $Array)?$Array["dplanetscoreratio"]:0); } if ( $Command == "New" ) @@ -1058,9 +1074,9 @@ function FillFleet( $Command, $Array ) for( $t = 0; $t < count($ShipTypes); $t++ ) { if ( $ShipTypes[$t]["Init"] <= 2 && $y == 0 && $ShipTypes[$t]["Special"] != "Anti PDS" ) continue; - CreateShipGroup( &$Fleet[$y]["Ships"][$t], $ShipTypes[$t], 0 ); + CreateShipGroup( $Fleet[$y]["Ships"][$t], $ShipTypes[$t], 0 ); - CalcTotals( $Fleet[$y], $t, &$Fleet[$y]["Totals"] ); + CalcTotals( $Fleet[$y], $t, $Fleet[$y]["Totals"] ); } } $Fleet[0]["PlanetScore"] = 0; diff --git a/online/battlecalc/ShipTypes.php b/online/battlecalc/ShipTypes.php index 27de965..6cd2ffd 100644 --- a/online/battlecalc/ShipTypes.php +++ b/online/battlecalc/ShipTypes.php @@ -1,5 +1,5 @@ $TypeNr, @@ -27,34 +27,34 @@ function CreateShipType( $ShipType, $TypeNr, $Name, $FormName, $ShipClass, $T1, } $ShipTypes = Array(); - CreateShipType( &$ShipTypes[0], 0, "Interceptor", "interceptor", "FI", "FR", "CO", "FI", 8, 30, 30, 1, 2, 3, 50, 1250, 0, 0, 10, 2, "None"); - CreateShipType( &$ShipTypes[1], 1, "Phoenix", "pheonix", "CO", "CR", "DE", "FR", 6, 25, 10, 1, 12, 12, 65, 2000, 500, 0, 25, 3, "None"); - CreateShipType( &$ShipTypes[2], 2, "War Frigate", "warfrigate", "FR", "CO", "FI", "-", 10, 20, 25, 3, 5, 30, 75, 5500, 1500, 0, 80, 4, "None"); - CreateShipType( &$ShipTypes[3], 3, "Devastor", "devastor", "DE", "BS", "CR", "DE", 7, 15, 5, 3, 25, 70, 80, 12000, 4000, 0, 175, 4, "None"); - CreateShipType( &$ShipTypes[4], 4, "Star Cruiser", "starcruiser","CR", "FR", "CO", "-", 11, 10, 15, 8, 15, 155, 85, 24000, 6000, 0, 350, 5, "None"); - CreateShipType( &$ShipTypes[5], 5, "Dreadnaught", "dreadnaught", "BS", "FI", "CO", "-", 9, 5, 30,100, 2, 400, 90, 70000, 16000, 0, 700, 5, "None"); - CreateShipType( &$ShipTypes[6], 6, "Spider", "spider", "FI", "CO", "FR", "-", 5, 30, 0, 1, 1, 2, 45, 0, 1250, 0, 10, 2, "EMPs"); - CreateShipType( &$ShipTypes[7], 7, "Wraith", "wraith", "CO", "CR", "DE", "FR", 12, 25, 15, 1, 12, 12, 65, 2000, 1000, 0, 30, 2, "Cloaked"); - CreateShipType( &$ShipTypes[8], 8, "Black Widow", "blackwidow", "FR", "CO", "FI", "-", 4, 20, 0, 5, 1, 30, 70, 2000, 5000, 0, 80, 4, "EMPs"); - CreateShipType( &$ShipTypes[9], 9, "Ghost", "ghost", "DE", "BS", "CR", "DE", 13, 15, 5, 3, 25, 70, 75, 9000, 7000, 0, 175, 4, "Cloaked"); - CreateShipType( &$ShipTypes[10], 10, "Tarantula", "tarantula", "CR", "CR", "DE", "FR", 3, 8, 0, 6, 1, 135, 70, 14000, 12000, 0, 350, 5, "EMPs"); - CreateShipType( &$ShipTypes[11], 11, "Spectre", "spectre", "BS", "FI", "CO", "-", 14, 5, 30,100, 2, 350, 85, 53000, 33000, 0, 700, 5, "Cloaked"); - CreateShipType( &$ShipTypes[12], 12, "Astro Pod", "astropod", "FR", "RO", "-", "-", 15, 18, 0, 1, 1, 12, 65, 1750, 500, 500, 125, 4, "Steals roids"); + CreateShipType( $ShipTypes[0], 0, "Interceptor", "interceptor", "FI", "FR", "CO", "FI", 8, 30, 30, 1, 2, 3, 50, 1250, 0, 0, 10, 2, "None"); + CreateShipType( $ShipTypes[1], 1, "Phoenix", "pheonix", "CO", "CR", "DE", "FR", 6, 25, 10, 1, 12, 12, 65, 2000, 500, 0, 25, 3, "None"); + CreateShipType( $ShipTypes[2], 2, "War Frigate", "warfrigate", "FR", "CO", "FI", "-", 10, 20, 25, 3, 5, 30, 75, 5500, 1500, 0, 80, 4, "None"); + CreateShipType( $ShipTypes[3], 3, "Devastor", "devastor", "DE", "BS", "CR", "DE", 7, 15, 5, 3, 25, 70, 80, 12000, 4000, 0, 175, 4, "None"); + CreateShipType( $ShipTypes[4], 4, "Star Cruiser", "starcruiser","CR", "FR", "CO", "-", 11, 10, 15, 8, 15, 155, 85, 24000, 6000, 0, 350, 5, "None"); + CreateShipType( $ShipTypes[5], 5, "Dreadnaught", "dreadnaught", "BS", "FI", "CO", "-", 9, 5, 30,100, 2, 400, 90, 70000, 16000, 0, 700, 5, "None"); + CreateShipType( $ShipTypes[6], 6, "Spider", "spider", "FI", "CO", "FR", "-", 5, 30, 0, 1, 1, 2, 45, 0, 1250, 0, 10, 2, "EMPs"); + CreateShipType( $ShipTypes[7], 7, "Wraith", "wraith", "CO", "CR", "DE", "FR", 12, 25, 15, 1, 12, 12, 65, 2000, 1000, 0, 30, 2, "Cloaked"); + CreateShipType( $ShipTypes[8], 8, "Black Widow", "blackwidow", "FR", "CO", "FI", "-", 4, 20, 0, 5, 1, 30, 70, 2000, 5000, 0, 80, 4, "EMPs"); + CreateShipType( $ShipTypes[9], 9, "Ghost", "ghost", "DE", "BS", "CR", "DE", 13, 15, 5, 3, 25, 70, 75, 9000, 7000, 0, 175, 4, "Cloaked"); + CreateShipType( $ShipTypes[10], 10, "Tarantula", "tarantula", "CR", "CR", "DE", "FR", 3, 8, 0, 6, 1, 135, 70, 14000, 12000, 0, 350, 5, "EMPs"); + CreateShipType( $ShipTypes[11], 11, "Spectre", "spectre", "BS", "FI", "CO", "-", 14, 5, 30,100, 2, 350, 85, 53000, 33000, 0, 700, 5, "Cloaked"); + CreateShipType( $ShipTypes[12], 12, "Astro Pod", "astropod", "FR", "RO", "-", "-", 15, 18, 0, 1, 1, 12, 65, 1750, 500, 500, 125, 4, "Steals roids"); - CreateShipType( &$ShipTypes[13], 20, "Planetary Missile", "missile", "MI", "*", "-", "-", 1, 50, 65, 12, 1, 1, 5, 200, 200, 250, 8, 1, "Anti PDS"); + CreateShipType( $ShipTypes[13], 20, "Planetary Missile", "missile", "MI", "*", "-", "-", 1, 50, 65, 12, 1, 1, 5, 200, 200, 250, 8, 1, "Anti PDS"); - CreateShipType( &$ShipTypes[14], 13, "Meson Cannon", "mesoncannon", "FI", "CO", "FI", "-", 2, 1, 30, 1, 2, 8, 100, 350, 350, 350, 0, 0, "PDS"); - CreateShipType( &$ShipTypes[15], 14, "Hyperon Turret", "hyperonturret", "FI", "FR", "CO", "-", 2, 1, 25, 1, 10, 16, 100, 1000, 1000, 1000, 0, 0, "PDS"); - CreateShipType( &$ShipTypes[16], 15, "Neutron Emitter","neutronemitter","CO", "DE", "FR", "-", 2, 1, 20, 1, 20, 32, 100, 2000, 2000, 2000, 0, 0, "PDS"); - CreateShipType( &$ShipTypes[17], 16, "Photon Cannon", "photoncannon", "CO", "CR", "DE", "-", 2, 1, 15, 1, 50, 64, 100, 3500, 3500, 3500, 0, 0, "PDS"); - CreateShipType( &$ShipTypes[18], 17, "ION Turret", "ionturret", "FR", "BS", "CR", "-", 2, 1, 5, 1, 75, 96, 100, 5000, 5000, 5000, 0, 0, "PDS"); - CreateShipType( &$ShipTypes[19], 18, "Missile Launcher","misslauncher", "DE", "-", "-", "-", 2, 1, 0, 1, 0, 48, 100, 1500, 1500, 5000, 0, 0, "PDS"); - CreateShipType( &$ShipTypes[20], 19, "Missile Cannon", "misscannon", "CO", "MI", "-", "-", 0, 1, 30, 10, 1, 8, 100, 750, 750, 750, 0, 0, "PDS"); + CreateShipType( $ShipTypes[14], 13, "Meson Cannon", "mesoncannon", "FI", "CO", "FI", "-", 2, 1, 30, 1, 2, 8, 100, 350, 350, 350, 0, 0, "PDS"); + CreateShipType( $ShipTypes[15], 14, "Hyperon Turret", "hyperonturret", "FI", "FR", "CO", "-", 2, 1, 25, 1, 10, 16, 100, 1000, 1000, 1000, 0, 0, "PDS"); + CreateShipType( $ShipTypes[16], 15, "Neutron Emitter","neutronemitter","CO", "DE", "FR", "-", 2, 1, 20, 1, 20, 32, 100, 2000, 2000, 2000, 0, 0, "PDS"); + CreateShipType( $ShipTypes[17], 16, "Photon Cannon", "photoncannon", "CO", "CR", "DE", "-", 2, 1, 15, 1, 50, 64, 100, 3500, 3500, 3500, 0, 0, "PDS"); + CreateShipType( $ShipTypes[18], 17, "ION Turret", "ionturret", "FR", "BS", "CR", "-", 2, 1, 5, 1, 75, 96, 100, 5000, 5000, 5000, 0, 0, "PDS"); + CreateShipType( $ShipTypes[19], 18, "Missile Launcher","misslauncher", "DE", "-", "-", "-", 2, 1, 0, 1, 0, 48, 100, 1500, 1500, 5000, 0, 0, "PDS"); + CreateShipType( $ShipTypes[20], 19, "Missile Cannon", "misscannon", "CO", "MI", "-", "-", 0, 1, 30, 10, 1, 8, 100, 750, 750, 750, 0, 0, "PDS"); - CreateShipType( &$ShipTypes[21], 18, "Metal roid", "metalroid", "RO", "-", "-", "-", 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "Roid"); - CreateShipType( &$ShipTypes[22], 19, "Crystal roid", "crystalroid", "RO", "-", "-", "-", 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "Roid"); - CreateShipType( &$ShipTypes[23], 20, "Eonium roid", "eoniumroid", "RO", "-", "-", "-", 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "Roid"); - CreateShipType( &$ShipTypes[24], 21, "Uninitiated roid","uninitroid", "RO", "-", "-", "-", 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "Roid"); + CreateShipType( $ShipTypes[21], 18, "Metal roid", "metalroid", "RO", "-", "-", "-", 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "Roid"); + CreateShipType( $ShipTypes[22], 19, "Crystal roid", "crystalroid", "RO", "-", "-", "-", 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "Roid"); + CreateShipType( $ShipTypes[23], 20, "Eonium roid", "eoniumroid", "RO", "-", "-", "-", 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "Roid"); + CreateShipType( $ShipTypes[24], 21, "Uninitiated roid","uninitroid", "RO", "-", "-", "-", 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "Roid"); $TypeReal["FI"] = "Fighter"; $TypeReal["CO"] = "Corvette"; diff --git a/online/battlecalc/install.txt b/online/battlecalc/install.txt deleted file mode 100644 index bd0b2cf..0000000 --- a/online/battlecalc/install.txt +++ /dev/null @@ -1,45 +0,0 @@ -/* - * install.txt, how-to install the Shoq Battlecalc v2.1b - * Original creator : Daan Broekhof (daan@parse.nl) aka Joror - */ - -TAKE HEED OF THE FOLLOWING POINTS: -- feel free to edit the code but keep a reference to the original maker, -- minimally needed to run : php4.0pl2 or higher, -- please inform me when you set up a server and want to mirror it for the general public, - it will posted on the main battlecalc page on shoq as a validated mirror, -- if you can't copy'n'paste then I won't even try to help you install a battlecalc :), -- pardon my codestyle, this was a project I started as one of my first PHP experiments, - and has been updated from that base *continuously* the last year ;), -- respect the opensource inititive, respect the PA crew - -Now, to install: - -1- copy all files to a directory on your server using ftp or whatever -2- Should be working now.. browse to your directory, if it's not working, look if your php - version is php4.0pl2 or higher, -3- Edit the news.php file, put in your own news, main bug news will still be at - http://battlecalc.shoq.com, if you leave the news.php empty, no newsblock is shown -4- Send me a mail (daan@parse.nl) informing me that you successfully installed the BC, - in that mail you can: - - Express your wish to get a mail when I put out a new BC version, - - Express your wish to be included in the mirror list, - (please include info on server whereabouts (ie continent) and speed/availability) - - Express your undying gratitude to me and make a sacrificial offering in my honor, - burning 10 bucks in paper money (or the equivalent in your country) in holy - attirement of the gift bestowed upon thee. - -5- (optional) Log functions : - For the somewhat more 'experienced' I've included a very basic logging system, to - switch it on you have to: - - Make the file 'logs.php' to world writable. [do : 'chmod 666 logs.php'] - - well that's it really.. - To check the stats out, just run 'logcount.php'. At the moment this file is *not* - protected with any password orso, to change that, edit the 'logcount.php' file and - change these line : - $username = ""; ==> $username = "clarkkentis"; - $password = ""; ==> $username = "superman"; - Or any other combo that strickes you fancy... - - - \ No newline at end of file diff --git a/online/battlecalc/logcount.php b/online/battlecalc/logcount.php deleted file mode 100644 index b4fd3f2..0000000 --- a/online/battlecalc/logcount.php +++ /dev/null @@ -1,168 +0,0 @@ - deny access. - Header( "WWW-Authenticate: Basic Realm=\"BC logcount\""); - Header( "HTTP/1.0 401 Unauthorized"); - echo "

Access Denied

"; - exit; - } - - $logfile = "logs.php"; - - if ( filesize($logfile) == 0 ) - die( "Zippo in the logfiles... perhaps you should read the install.txt again, hmmm?" ); - - if (!$hits ) - $hits = 60000; - -?> - -
-Get the last hits -
- $nowis ) - $lasthours[$h]++; - $daysoftheweek[date("l", $data["time"])]++; - $days[date("M j", $data["time"])]++; - $visitors++; - - $binarydata = fread( $fp, 4 ); - } - fclose( $fp ); - - list($msec, $sec) = split( " ", microtime()); - $itime = $msec + $sec; - $diff = $itime - $utime; - - echo "Took me ". round($diff,2) ." freaking seconds! That is almost ". ceil($diff/60) ." minute(s)..
"; - - ksort($hours); - ksort($lasthours); - - echo "Pagehits : ". $pagehits .", Unique visitors : ". $visitors .", Logfile size : ". filesize($logfile) ."

"; - - $row = 0; - - /* hours */ - echo ""; - echo ""; - foreach ( (array)$hours as $hour => $count ) - { - if ( $tel++ == 12 ) $row++; - $row1[$row] .= ""; - $row2[$row] .= ""; - if ( $max < $count ) - $max = $count; - } - for ( $i = 0; $i < sizeof($row1); $i++ ) - echo "". $row1[$i] ."". $row2[$i] .""; - echo "
Hourly hits
$hour:00$count

"; - echo ""; - foreach ( (array)$hours as $hour => $count ) - echo ""; - echo ""; - echo "



". $hour ."
-". $max ."

"; - - $tel = 0;$row = 0;unset($row1);unset($row2); $max = 0; - - /* daysoftheweek */ - echo ""; - echo ""; - foreach ( (array)$daysoftheweek as $dayoftheweek => $count ) - { - $row1[$row] .= ""; - $row2[$row] .= ""; - if ( $max < $count ) - $max = $count; - } - for ( $i = 0; $i < sizeof($row1); $i++ ) - echo "". $row1[$i] ."". $row2[$i] .""; - echo "
Hits per day of the week
$dayoftheweek$count

"; - echo ""; - foreach ( (array)$daysoftheweek as $dayoftheweek => $count ) - echo ""; - echo ""; - echo "



". substr($dayoftheweek,0,3) ."
-". $max ."

"; - - - $tel = 0;$row = 0;unset($row1);unset($row2); $max = 0; - - /* days */ - echo ""; - echo ""; - foreach ( (array)$days as $day => $count ) - { - if ( $tel++ == 12 ) $row++; - $row1[$row] .= ""; - $row2[$row] .= ""; - if ( $max < $count ) - $max = $count; - } - for ( $i = 0; $i < sizeof($row1); $i++ ) - echo "". $row1[$i] ."". $row2[$i] .""; - echo "
Hits per day of the week
$day$count

"; - echo ""; - foreach ( (array)$days as $day => $count ) - echo ""; - echo ""; - echo "



". substr($day,-2,2) ."
-". $max ."

"; - - - $tel = 0;$row = 0;unset($row1);unset($row2); $max = 0; - - /* hours */ - echo ""; - echo ""; - foreach ( (array)$lasthours as $hour => $count ) - { - if ( $tel++ == 12 ) $row++; - $row1[$row] .= ""; - $row2[$row] .= ""; - if ( $max < $count ) - $max = $count; - } - for ( $i = 0; $i < sizeof($row1); $i++ ) - echo "". $row1[$i] ."". $row2[$i] .""; - echo "
Hourly hits today
$hour:00$count

"; - echo ""; - foreach ( (array)$lasthours as $hour => $count ) - echo ""; - echo ""; - echo "



". $hour ."
-". $max ."

"; - -?> - \ No newline at end of file diff --git a/online/check_ip.php b/online/check_ip.php index 7de314e..43bdbaf 100644 --- a/online/check_ip.php +++ b/online/check_ip.php @@ -2,7 +2,7 @@ /* * MyPHPpa - * Copyright (C) 2003 Jens Beyer + * Copyright (C) 2003, 2007 Jens Beyer * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -24,10 +24,10 @@ function check_ip($ip) { $q = "SELECT * FROM iptables WHERE ip = '$ip'"; - $res = mysql_query ($q, $db); - if ($res && mysql_num_rows($res) > 0) { + $res = mysqli_query ($db, $q ); + if ($res && mysqli_num_rows($res) > 0) { $q = "INSERT INTO news set planet_id=1,date=now(),type=10,text='IP check matched: $ip'"; - mysql_query ($q, $db); + mysqli_query ($db, $q ); return 0; } diff --git a/online/new.php b/online/clear_cookies.php similarity index 95% rename from online/new.php rename to online/clear_cookies.php index 1f9e314..15cc27f 100644 --- a/online/new.php +++ b/online/clear_cookies.php @@ -2,7 +2,7 @@ /* * MyPHPpa - * Copyright (C) 2003 Jens Beyer + * Copyright (C) 2003, 2007 Jens Beyer * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/online/construct.php b/online/construct.php index afa12d7..5f756c1 100644 --- a/online/construct.php +++ b/online/construct.php @@ -2,7 +2,7 @@ /* * MyPHPpa - * Copyright (C) 2003 Jens Beyer + * Copyright (C) 2003, 2007 Jens Beyer * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -30,11 +30,10 @@ function print_rc_row ($row, $status) { global $Planetid, $db; - global $PHP_SELF; if ($row[7] !=0) { - $r = mysql_query ("SELECT name from rc_class WHERE id='$row[7]'", $db); - $myr = mysql_fetch_row($r); + $r = mysqli_query ($db, "SELECT name from rc_class WHERE id='$row[7]'" ); + $myr = mysqli_fetch_row($r); $blocked_name = $myr[0]; } @@ -43,12 +42,13 @@ function print_rc_row ($row, $status) { echo "
$row[1]
Cost: $row[2] Metal, $row[3] Crystal"; if ($row[8] != 0) echo ", $row[8] Eonium"; - if ($blocked_name) echo "
Disables $blockedname"; + if (ISSET($blocked_name)) + echo "
Disables $blockedname"; echo "
"; if ($row[5] == 2) { - $rb = mysql_query ("SELECT build_ticks from rc_build ". - "WHERE planet_id='$Planetid' AND rc_id='$row[6]'", $db); - $myb = mysql_fetch_row($rb); + $rb = mysqli_query ($db, "SELECT build_ticks from rc_build ". + "WHERE planet_id='$Planetid' AND rc_id='$row[6]'" ); + $myb = mysqli_fetch_row($rb); echo "$myb[0] ticks"; } else { echo "$row[4] ticks"; @@ -61,7 +61,7 @@ function print_rc_row ($row, $status) { case 1: if ($status) { echo "Other construction in progress"; } else { - echo "Construct"; + echo "Construct"; } break; case -1: echo "Blocked"; break; @@ -75,11 +75,11 @@ function build_construct ($id) { global $myrow; /* resources */ global $Planetid, $db, $msg; - $res = mysql_query ("SELECT metal, crystal, eonium ". - "FROM rc_class WHERE id='$id'", $db); + $res = mysqli_query ($db, "SELECT metal, crystal, eonium ". + "FROM rc_class WHERE id='$id'" ); - if (mysql_num_rows($res) == 1) { - $price = mysql_fetch_row($res); + if (mysqli_num_rows($res) == 1) { + $price = mysqli_fetch_row($res); if ( $myrow["metal"] < $price[0] || $myrow["crystal"] < $price[1] || $myrow["eonium"] < $price[2] ) { @@ -88,24 +88,24 @@ function build_construct ($id) { return 0; } - $res = mysql_query("UPDATE rc set status=2 ". - "WHERE rc_id='$id' AND status=1 AND planet_id='$Planetid'", $db); + $res = mysqli_query($db, "UPDATE rc set status=2 ". + "WHERE rc_id='$id' AND status=1 AND planet_id='$Planetid'" ); - if (!$res || mysql_affected_rows($db)!=1) { + if (!$res || mysqli_affected_rows($db)!=1) { $msg .= "Can't construct that now"; return 0; } else { - $res = mysql_query("INSERT DELAYED INTO rc_build (planet_id,rc_id,build_ticks) ". + $res = mysqli_query($db, "INSERT DELAYED INTO rc_build (planet_id,rc_id,build_ticks) ". "SELECT '$Planetid','$id',build_ticks from rc_class ". - "WHERE id='$id'", $db); + "WHERE id='$id'" ); $myrow["metal"] -= $price[0]; $myrow["crystal"] -= $price[1]; $myrow["eonium"] -= $price[2]; $q = "UPDATE planet SET metal='$myrow[metal]',crystal='$myrow[crystal]',". "eonium='$myrow[eonium]' where id='$Planetid'"; - $res = mysql_query($q, $db); + $res = mysqli_query($db, $q ); } return 1; @@ -118,26 +118,28 @@ function build_construct ($id) { * wird aber auch gebraucht um festzustellen ob research ueberhaupt moeglich ist */ $researching = 0; -$result = mysql_query ("SELECT status from rc, rc_class where rc.planet_id='$Planetid' ". - "AND rc.rc_id=rc_class.id AND rc_class.type=1 AND rc.status=2", - $db); -if (mysql_num_rows($result) > 0) $researching = 1; +$result = mysqli_query ($db, "SELECT status from rc, rc_class where rc.planet_id='$Planetid' ". + "AND rc.rc_id=rc_class.id AND rc_class.type=1 AND rc.status=2"); +if (mysqli_num_rows($result) > 0) $researching = 1; -if ($id && $researching == 0) { +if (ISSET($id) && $researching == 0) { $researching = build_construct($id); } -if ($toggle) { +if (ISSET($toggle)) { if ($toggle==1) $mysettings -= 128; else $mysettings += 128; - mysql_query ("UPDATE user SET settings='$mysettings' ". - "WHERE planet_id='$Planetid'",$db); + mysqli_query ($db, "UPDATE user SET settings='$mysettings' ". + "WHERE planet_id='$Planetid'"); } /* top table is written now */ top_header($myrow); -titlebox("Construction",$msg); +if (ISSET($msg) && $msg != "") + titlebox("Construction",$msg); +else + titlebox("Construction"); if ($mysettings & 128) { $rc_status = "rc.status IN (1,2)"; @@ -150,7 +152,7 @@ function build_construct ($id) { echo << -
+
Toggle visibility
@@ -166,9 +168,9 @@ function build_construct ($id) { "FROM rc, rc_class WHERE rc.planet_id = '$Planetid' and rc_class.type=1 ". "AND rc.rc_id = rc_class.id AND $rc_status ORDER BY rc_class.id"; -$result = mysql_query( $q, $db); -if (mysql_num_rows($result) > 0) { - while ($myres = mysql_fetch_row($result)) { +$result = mysqli_query($db, $q ); +if (mysqli_num_rows($result) > 0) { + while ($myres = mysqli_fetch_row($result)) { print_rc_row ($myres, $researching); } } else { diff --git a/online/create_user.php b/online/create_user.php index 7c65162..856345c 100644 --- a/online/create_user.php +++ b/online/create_user.php @@ -2,7 +2,7 @@ /* * MyPHPpa - * Copyright (C) 2003 Jens Beyer + * Copyright (C) 2003, 2007 Jens Beyer * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -39,11 +39,11 @@ function create_user ($pid) { $q = "INSERT INTO rc (planet_id, rc_id, status) ". "SELECT '$pid', id, NOT rc_id FROM rc_class"; - $result = mysql_query ($q, $db); + $result = mysqli_query ($db, $q ); if (!$result) echo "Error in Create_user $pid Research"; $q = "UPDATE rc SET status=3 WHERE planet_id='$pid' AND rc_id=0 "; - $result = mysql_query ($q, $db); + $result = mysqli_query ($db, $q ); if (!$result) echo "Error in Create_user $pid Research (0)"; @@ -54,7 +54,7 @@ function create_user ($pid) { for ($i=0; $i<=$number_of_fleets; $i++) { $q = "INSERT INTO fleet set planet_id='$pid',num='$i'"; - $result = mysql_query ($q, $db); + $result = mysqli_query ($db, $q ); if (!$result) echo "Error in Create_user $pid Fleets"; } @@ -67,7 +67,7 @@ function create_user ($pid) { "planet_c='$start_resource[planet_c]',planet_e='$start_resource[planet_e]' ". "WHERE id='$pid'"; - $result = mysql_query ($q, $db); + $result = mysqli_query ($db, $q ); if (!$result) echo "Error in Create_user $pid Initial resources"; /* @@ -75,7 +75,7 @@ function create_user ($pid) { */ $q = "INSERT INTO scan (planet_id,wave_id,num) ". "SELECT '$pid',id,0 FROM scan_class AS sc WHERE rc_id=0"; - $result = mysql_query ($q, $db); + $result = mysqli_query ($db, $q ); if (!$result) echo "Error in Create_user $pid Initial scans"; diff --git a/online/dblogon.php b/online/dblogon.php index e316c47..880d2e3 100644 --- a/online/dblogon.php +++ b/online/dblogon.php @@ -2,7 +2,7 @@ /* * MyPHPpa - * Copyright (C) 2003 Jens Beyer + * Copyright (C) 2003, 2007 Jens Beyer * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -19,10 +19,10 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -$db = mysql_pconnect ("$dbhost:$dbport:$dbsock", $dbuser, $dbpass) +$db = mysqli_connect ($dbhost, $dbuser, $dbpass, $dbname, $dbport, $dbsock) or die ("Could not connect to database"); -mysql_select_db($dbname,$db); +mysqli_select_db($db, $dbname); /* fixme, get current tick */ diff --git a/online/emacs.m b/online/emacs.m new file mode 100644 index 0000000..7eea96d --- /dev/null +++ b/online/emacs.m @@ -0,0 +1,6 @@ +(fset 'macro-isset + [escape ?b ?( backspace ?I ?S ?S ?E ?T ?( escape ?f ?)]) +(fset 'macro-mysqli-query + [?\C-s ?m ?y ?s ?q ?l ?i ?_ ?q ?u ?e ?r ?y left ?\C-s ?( right left ?$ ?d ?b ?, ? ?\C-s ?) ?\; left left ?\C-? ?\C-? ?\C-? ?\C-r ?, ?\C-d]) +(global-set-key "\M-i" 'macro-isset) +(global-set-key "\M-m" 'macro-mysqli-query) diff --git a/online/error.php b/online/error.php index 6ff93ee..c4e8171 100644 --- a/online/error.php +++ b/online/error.php @@ -2,7 +2,7 @@ /* * MyPHPpa - * Copyright (C) 2003 Jens Beyer + * Copyright (C) 2003, 2007 Jens Beyer * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -38,7 +38,7 @@

- +

There seems to be an ERROR - perhaps your session timed out (30 mins)
diff --git a/online/fleet_util.php b/online/fleet_util.php index b9f7098..04c68bc 100644 --- a/online/fleet_util.php +++ b/online/fleet_util.php @@ -2,7 +2,7 @@ /* * MyPHPpa - * Copyright (C) 2003 Jens Beyer + * Copyright (C) 2003, 2007 Jens Beyer * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -26,8 +26,8 @@ function get_eta ($fleet_num) { "WHERE fleet.planet_id='$Planetid' AND units.id=fleet.fleet_id ". "AND fleet.num='$fleet_num' AND uc.id=units.unit_id"; - $result = mysql_query($q, $db); - $row = mysql_fetch_row($result); + $result = mysqli_query($db, $q ); + $row = mysqli_fetch_row($result); $eta = $row[0]; // ticker sets modifier @@ -61,9 +61,9 @@ function get_fuel ($fleet_num) { $fuel = 0; - $result = mysql_query($q, $db); - if ($result && mysql_num_rows($result) == 1) { - $row = mysql_fetch_row($result); + $result = mysqli_query($db, $q ); + if ($result && mysqli_num_rows($result) == 1) { + $row = mysqli_fetch_row($result); if ($row && $row[0]) $fuel = $row[0]; } @@ -94,9 +94,9 @@ function fetch_fleet_sum ($fleet_id) $q = "SELECT SUM(units.num) FROM units, unit_class AS uc ". "WHERE units.unit_id=uc.id AND uc.class!=3 AND units.id='$fleet_id'"; - $result = mysql_query( $q, $db); + $result = mysqli_query($db, $q ); if ($result) { - $mynum = mysql_fetch_row ($result); + $mynum = mysqli_fetch_row ($result); return $mynum[0]; } else { return 0; diff --git a/online/footer.inc b/online/footer.inc index ac33569..2ac954a 100644 --- a/online/footer.inc +++ b/online/footer.inc @@ -2,7 +2,7 @@ /* * MyPHPpa - * Copyright (C) 2003 Jens Beyer + * Copyright (C) 2003, 2007 Jens Beyer * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/online/footer.php b/online/footer.php index 3a8730b..3bc8c7e 100644 --- a/online/footer.php +++ b/online/footer.php @@ -4,7 +4,7 @@ /* * MyPHPpa - * Copyright (C) 2003 Jens Beyer + * Copyright (C) 2003, 2007 Jens Beyer * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/online/footerf.php b/online/footerf.php index 9deca1e..1ab0813 100644 --- a/online/footerf.php +++ b/online/footerf.php @@ -2,7 +2,7 @@ /* * MyPHPpa - * Copyright (C) 2003 Jens Beyer + * Copyright (C) 2003, 2007 Jens Beyer * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/online/forum.inc b/online/forum.inc index 2d4c163..5399289 100644 --- a/online/forum.inc +++ b/online/forum.inc @@ -2,7 +2,7 @@ /* * MyPHPpa - * Copyright (C) 2003 Jens Beyer + * Copyright (C) 2003, 2007 Jens Beyer * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -42,7 +42,7 @@ function post_ref ($fstyle, $title, $opt) { } function print_thread_line($row, $authorized) { - global $PHP_SELF, $Planetid, $fcreator; + global $Planetid, $fcreator; $tdmod_1 = ""; $tdmod_2 = ""; @@ -56,16 +56,16 @@ function print_thread_line($row, $authorized) { if ($row[4] == $fcreator || $Planetid == $authorized) { echo "
". - "". + "". "". "". "". "". - "". + "". "\n"; } else { echo "". - "". + "". "". "". "". @@ -109,10 +109,10 @@ function print_threads ($fstyle, $gal_id,$authorized) { "WHERE gal_id='$gal_id' ORDER by d DESC"; } - $result = mysql_query ($q, $db); + $result = mysqli_query ($db, $q ); - if ($result && mysql_num_rows($result) > 0) { - while ($row = mysql_fetch_row($result)) { + if ($result && mysqli_num_rows($result) > 0) { + while ($row = mysqli_fetch_row($result)) { print_thread_line($row,$authorized); } } else { @@ -122,7 +122,7 @@ function print_threads ($fstyle, $gal_id,$authorized) { } function show_thread_post ($fstyle, $row, $thread, $authorized) { - global $Planetid, $fcreator, $PHP_SELF; + global $Planetid, $fcreator; $txt = ereg_replace ("<", "<", $row[2]); $text = ereg_replace ("\n", "
", $txt); @@ -138,11 +138,11 @@ function show_thread_post ($fstyle, $row, $thread, $authorized) { } if ($fcreator == $row[0]) { - echo "
". + echo "
". "Delete | ". post_ref($fstyle, "Edit_posting","edit=$row[4]") . "Edit"; } else if ($Planetid == $authorized) { - echo "
". + echo "
". "Delete"; } @@ -177,10 +177,10 @@ EOF; $q .= "ORDER by d ASC"; } - $result = mysql_query ($q, $db); + $result = mysqli_query ($db, $q ); - if ($result && mysql_num_rows($result) > 0) { - while ($row = mysql_fetch_row($result)) { + if ($result && mysqli_num_rows($result) > 0) { + while ($row = mysqli_fetch_row($result)) { show_thread_post($fstyle, $row, $fthread,$authorized); } } @@ -195,12 +195,12 @@ function delete_thread ($thread_id, $gal_id, $authorized) { $q = "DELETE FROM politics WHERE id='$thread_id' AND gal_id='$gal_id' ". "AND (creator='$fcreator' OR '$Planetid'='$authorized')"; - $result = mysql_query ($q, $db); + $result = mysqli_query ($db, $q ); - if(mysql_affected_rows($db) == 1) { + if(mysqli_affected_rows($db) == 1) { $qp = "DELETE FROM poltext WHERE thread_id='$thread_id' ". "AND gal_id='$gal_id'"; - $result = mysql_query ($qp, $db); + $result = mysqli_query ($db, $qp ); } } @@ -209,12 +209,12 @@ function delete_posting ($thread_id, $post_id, $gal_id, $authorized) { $q = "DELETE FROM poltext WHERE id='$post_id' AND thread_id='$thread_id' ". "AND (planet_id='$Planetid' OR '$Planetid'='$authorized')"; - $result = mysql_query ($q, $db); + $result = mysqli_query ($db, $q ); - if(mysql_affected_rows($db) == 1) { + if(mysqli_affected_rows($db) == 1) { $q = "UPDATE politics SET replies=replies-1 ". "WHERE poltext.id='$post_id' AND politics.id=poltext.thread_id"; - $result = mysql_query ($q, $db); + $result = mysqli_query ($db, $q ); } } @@ -225,10 +225,10 @@ function check_valid ($thread_id, $gal_id) { $q ="SELECT subject FROM politics ". "WHERE gal_id='$gal_id' AND id='$thread_id' "; - $result = mysql_query ($q, $db); + $result = mysqli_query ($db, $q ); - if ($result && mysql_num_rows($result) > 0) { - while ($row = mysql_fetch_row($result)) { + if ($result && mysqli_num_rows($result) > 0) { + while ($row = mysqli_fetch_row($result)) { $subject=$row[0]; } return 1; @@ -247,8 +247,8 @@ function forum_head_line ($fstyle, $fid) { } case 1: { $q = "SELECT name,x,y FROM galaxy WHERE id='$fid'"; - $res = mysql_query ($q, $db); - $grow = mysql_fetch_array($res); + $res = mysqli_query ($db, $q ); + $grow = mysqli_fetch_array($res); $ret = "Politics: $grow[name] ($grow[x]:$grow[y])"; break; } @@ -267,19 +267,19 @@ function forum_head_line ($fstyle, $fid) { } function forum_head ($fstyle, $fid, $fthread=0) { - global $subject, $PHP_SELF; + global $subject; if ($fthread==0) { $menu = post_ref($fstyle, "Create_Posting","create=1") . - "Create new thread | Reload"; + "Create new thread | Reload"; $fline = ""; } else { $menu = post_ref($fstyle, "Create_Posting", "reply=$fthread") . "Post follow up". - " | Reload". - " | Overview"; + " | Reload". + " | Overview"; $fline = ""; } @@ -314,14 +314,14 @@ function forum_init ($fstyle, $fid) { // politics - reset light $q ="UPDATE planet SET has_politics=$myrow[has_politics] & 0xfe ". "WHERE id='$Planetid'"; - $result = mysql_query ($q, $db); + $result = mysqli_query ($db, $q ); $myrow["has_politics"] = $myrow["has_politics"] & 0xfe; $q = "SELECT moc FROM galaxy WHERE x='$myrow[x]' AND y='$myrow[y]'"; - $result = mysql_query ($q, $db); + $result = mysqli_query ($db, $q ); - if ($result && mysql_num_rows($result)>0) { - $row = mysql_fetch_row($result); + if ($result && mysqli_num_rows($result)>0) { + $row = mysqli_fetch_row($result); if ($row[0] == $Planetid) $authorized = $Planetid; } @@ -329,23 +329,23 @@ function forum_init ($fstyle, $fid) { // politics - reset light $q ="UPDATE planet SET has_politics=$myrow[has_politics] & 0xfd ". "WHERE id='$Planetid'"; - $result = mysql_query ($q, $db); + $result = mysqli_query ($db, $q ); $myrow["has_politics"] = $myrow["has_politics"] & 0xfd; $q = "SELECT hc FROM alliance WHERE id=$myrow[alliance_id]"; - $result = mysql_query ($q, $db); + $result = mysqli_query ($db, $q ); - if ($result && mysql_num_rows($result)>0) { - $row = mysql_fetch_row($result); + if ($result && mysqli_num_rows($result)>0) { + $row = mysqli_fetch_row($result); if ($row[0] == $Planetid) $authorized = $Planetid; } } else if ($fstyle==3) { $q = "SELECT hcname,tag FROM alliance ". "WHERE alliance.id = $myrow[alliance_id]"; - $result = mysql_query ($q, $db); - if ($result && mysql_num_rows($result)>0) { - $row = mysql_fetch_row($result); + $result = mysqli_query ($db, $q ); + if ($result && mysqli_num_rows($result)>0) { + $row = mysqli_fetch_row($result); $fcreator = $row[0]; $fcoords = "[$row[1]]"; } else { diff --git a/online/forum.php b/online/forum.php index b30d217..3c83385 100644 --- a/online/forum.php +++ b/online/forum.php @@ -2,7 +2,7 @@ /* * MyPHPpa - * Copyright (C) 2003 Jens Beyer + * Copyright (C) 2003, 2007 Jens Beyer * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -27,11 +27,16 @@ $fstyle = 0; $fid = 0; +if (!ISSET($msg)) $msg = ""; $msg .= forum_init ($fstyle, $fid); top_header ($myrow); -$msg .= forum_submit ($fstyle, $fid, $fthread); +if (ISSET($fthread)) { + $msg .= forum_submit ($fstyle, $fid, $fthread); +} else { + $msg .= forum_submit ($fstyle, $fid, 0); +} $ftitle = forum_title ($fstyle); @@ -39,7 +44,7 @@ echo "
\n"; -if ($fthread) { +if (ISSET($fthread)) { forum_show_thread ($fstyle, $fid, $fthread); } else { forum_list_thread ($fstyle, $fid); diff --git a/online/forump.php b/online/forump.php index 9953a68..255f598 100644 --- a/online/forump.php +++ b/online/forump.php @@ -2,7 +2,7 @@ /* * MyPHPpa - * Copyright (C) 2003 Jens Beyer + * Copyright (C) 2003, 2007 Jens Beyer * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -19,198 +19,7 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -if ($nowin && $nowin == 1) { - $close_script = ""; -} else { - $close_script="\n"; -} +$post_type = 0; -if ($create) { - $extra_header = " Create new thread\n$close_script"; - $mail_id = $reply; -} else if ($reply) { - $extra_header = " Reply\n$close_script"; -} else { - $extra_header = " Edit\n$close_script"; -} -require "standard_pop.php"; - -if ($submit) { - require "post_func.inc"; - check_post(); -} - -require "planet_util.php"; -require "logging.php"; - -if ($submit) { - - if ((("$subject"!="") || $reply || $edit) - && "$text"!="") { - - if (!$reply && !$edit) { - $q = "INSERT INTO politics SET planet_id='$Planetid', date=NOW(),". - "subject='$subject',gal_id=0,creator='$myrow[leader]'"; - $result = mysql_query ($q, $db); - $thid = mysql_insert_id ($db); - - } else { - // check if id is valid - - if ($reply) { - $postid = $reply; - $q = "SELECT gal_id FROM politics ". - "WHERE id='$reply' AND gal_id=0"; - } else { - $postid = $edit; - $q = "SELECT gal_id FROM politics,poltext ". - "WHERE poltext.id='$edit' AND politics.id=poltext.thread_id ". - "AND gal_id=0"; - } - $result = mysql_query ($q, $db); - - if ($result && mysql_num_rows($result) == 1) { - $thid = $postid; - - if ($reply) { - $q = "UPDATE politics SET date=NOW(),planet_id='$Planetid', ". - "replies=replies+1 WHERE id='$thid'"; - $result = mysql_query ($q, $db); - } - } else { - echo "Wrong parameter found - this incidence will be reported
"; - $q = "INSERT INTO news set planet_id=1,date=now(),type=10,". - "text='Forum warning\npid: $Planetid\ntext=$text\n'"; - $result = mysql_query ($q, $db); - do_log_me (3, 1, "Wrong forum post"); - } - } - - if ($thid) { - if (!$edit) { - $q = "INSERT INTO poltext SET thread_id='$thid',text='$text',". - "planet_id='$Planetid',date=NOW()"; - $msg = "Successfully posted"; - } else { - // edit - $dbtext = $text . "\n*** Edited ***"; - $q = "UPDATE poltext SET text='$dbtext' ". - "WHERE id='$thid' AND planet_id='$Planetid'"; - $text = $dbtext; - $msg = "Successfully edited your post"; - } - $result = mysql_query ($q, $db); - - } - - } else { - echo "You have to suply all fields
"; - } -} - -echo "

"; -if ($msg) { - echo "$msg
"; -} -?> - -
"> - -
$row[1]$row[1]$row[4]$row[5]$thread_leader$row[2]DD
$row[1]$row[1]$row[4]$row[5]$thread_leader" . forum_head_line ($fstyle, $fid) . "Subject: $subject
-"; -} else if ($edit) { - // needs check for planetid - - $q = "SELECT subject,text FROM politics, poltext ". - "WHERE politics.id=poltext.thread_id AND poltext.id='$edit'"; - $result = mysql_query ($q, $db); - - if ($result && mysql_num_rows($result) == 1) { - $row=mysql_fetch_array($result); - - $subject = ereg_replace ("<", "<",$row[0]); - $text = ereg_replace ("<", "<",$row[1]); - } else { - $subject = "Empty"; - } - - echo "Forum: Edit Posting"; -} else { - $text=""; - echo "Forum: New thread"; -} - -?> - - - - -
-
Subject: - -"; -} else { - echo "$subject"; -} -?> - -
- -
- -     - -     -
- - -
-Return to thread\n"; - else - echo "Return to forum\n"; - } else { - echo "Close this Window\n"; - } - -echo "
\n\n"; - -require "footer.php"; +include "post.inc"; ?> diff --git a/online/gal_report.inc b/online/gal_report.inc index 638915f..0dc2194 100644 --- a/online/gal_report.inc +++ b/online/gal_report.inc @@ -2,7 +2,7 @@ /* * MyPHPpa - * Copyright (C) 2003 Jens Beyer + * Copyright (C) 2003, 2007 Jens Beyer * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -96,9 +96,9 @@ function get_alliance_tag($aid) { if ($aid == 0) return ""; - $res = mysql_query("SELECT tag FROM alliance WHERE id='$aid'",$db); - if ($res && mysql_num_rows($res)>0) { - $row = mysql_fetch_row($res); + $res = mysqli_query($db, "SELECT tag FROM alliance WHERE id='$aid'"); + if ($res && mysqli_num_rows($res)>0) { + $row = mysqli_fetch_row($res); return "$row[0]"; } else { return ""; @@ -114,10 +114,10 @@ function get_scan_data ($x, $y) { "AND scan.wave_id!=1 AND scan.wave_id!=3 AND ". "scan.wave_id!=6 AND scan.num>0"; - $result = mysql_query ($q, $db); + $result = mysqli_query ($db, $q ); - if ($result && mysql_num_rows($result) > 0) { - while ($row=mysql_fetch_row ($result)) { + if ($result && mysqli_num_rows($result) > 0) { + while ($row=mysqli_fetch_row ($result)) { if ($row[0] > 1 && $row[0] != 6 && $row[0] != 3 ) { $n = $row[1][0]; if ( $mysettings & 64 && ! $override_settings) { @@ -138,16 +138,16 @@ function print_gal_report ($x, $y) { global $db, $Planetid, $myrow; - $result = mysql_query ("SELECT z, leader, planetname, score, ". + $result = mysqli_query ($db, "SELECT z, leader, planetname, score, ". "metalroids+crystalroids+eoniumroids+uniniroids ". "AS roids, planet.id, mode, planet.id=gc, alliance_id, ". "planet.id=moc ". "FROM planet, galaxy ". "WHERE planet.x='$x' AND planet.y='$y' AND ". "planet.x=galaxy.x AND galaxy.y=planet.y ". - "ORDER BY z ASC", $db); + "ORDER BY z ASC" ); - if (mysql_num_rows($result) == 0) { + if (mysqli_num_rows($result) == 0) { /* empty,invalid Sector */ echo "
". @@ -158,7 +158,7 @@ function print_gal_report ($x, $y) { $tag = get_alliance_tag($myrow["alliance_id"]); else $tag = ""; - while ($mygal=mysql_fetch_row ($result)) { + while ($mygal=mysqli_fetch_row ($result)) { print_gal_row ($mygal, $x, $y, $scans, $tag); } } diff --git a/online/galaxy.php b/online/galaxy.php index f883c0c..4de8dd4 100644 --- a/online/galaxy.php +++ b/online/galaxy.php @@ -2,7 +2,7 @@ /* * MyPHPpa - * Copyright (C) 2003 Jens Beyer + * Copyright (C) 2003, 2007 Jens Beyer * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -19,7 +19,7 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -require "popup_header.php"; +require "popup_header.inc"; $extra_header .= "\n\n"; -} +$post_type = 3; -if ($create) { - $extra_header = " Create new thread\n$close_script"; - $mail_id = $reply; -} else if ($reply) { - $extra_header = " Reply\n$close_script"; -} else { - $extra_header = " Edit\n$close_script"; -} -require "standard_pop.php"; - -if ($submit) { - require "post_func.inc"; - check_post(); -} - -require "planet_util.php"; -require "logging.php"; - -function get_alliance () { - global $db, $myrow; - - if ($myrow[alliance_id] == 0) return 0; - - $q = "SELECT * FROM alliance WHERE id='$myrow[alliance_id]'"; - $res = mysql_query( $q, $db); - if ($res) - $all = mysql_fetch_array($res); - else - return 0; - $all["status"] = !($myrow["status"] & 2); - - return $all; -} - -$all = get_alliance(); - -if ($all && $all["hc"] == $Planetid && - ($all["members"] > 2 || $Planetid<=2)) { - $gal_id = 1023; -} else { - echo "You are not allowed to be here."; - die; -} - -if ($submit) { - - if ((("$subject"!="") || $reply || $edit) - && "$text"!="") { - - if (!$reply && !$edit) { - $q = "INSERT INTO politics SET planet_id='$Planetid', date=NOW(),". - "subject='$subject',gal_id='$gal_id',creator='$all[hcname]'"; - $result = mysql_query ($q, $db); - $thid = mysql_insert_id ($db); - - } else { - // check if id is valid - - if ($reply) { - $postid = $reply; - $q = "SELECT gal_id FROM politics ". - "WHERE id='$reply' AND gal_id='$gal_id'"; - } else { - $postid = $edit; - $q = "SELECT gal_id FROM politics,poltext ". - "WHERE poltext.id='$edit' AND politics.id=poltext.thread_id ". - "AND gal_id='$gal_id'"; - } - $result = mysql_query ($q, $db); - - if ($result && mysql_num_rows($result) == 1) { - $thid = $postid; - - if ($reply) { - $q = "UPDATE politics SET date=NOW(),planet_id='$Planetid', ". - "replies=replies+1 WHERE id='$thid'"; - $result = mysql_query ($q, $db); - - $q = "UPDATE planet set has_politics = has_politics | 2 ". - "WHERE alliance_id='$myrow[alliance_id]' AND id!='$Planetid'"; - $result = mysql_query ($q, $db); - } - } else { - echo "Wrong parameter found - this incidence will be reported
"; - $q = "INSERT INTO news set planet_id=1,date=now(),type=10,". - "text='Alliance Forum warning\npid: $Planetid\ntext=$text\n'"; - $result = mysql_query ($q, $db); - do_log_me (3, 1, "Wrong alliance forum post"); - } - } - - if ($thid) { - if (!$edit) { - $q = "INSERT INTO poltext SET thread_id='$thid',text='$text',". - "planet_id='$Planetid',date=NOW()"; - $msg = "Successfully posted"; - } else { - // edit - $dbtext = $text . "\n*** Edited ***"; - $q = "UPDATE poltext SET text='$dbtext' ". - "WHERE id='$thid' AND planet_id='$Planetid'"; - $text = $dbtext; - $msg = "Successfully edited your post"; - } - $result = mysql_query ($q, $db); - - } - - } else { - echo "You have to suply all fields
"; - } -} - -echo "

"; -if ($msg) { - echo "$msg
"; -} -?> - -
"> - - -"; -} else if ($edit) { - // needs check for planetid - - $q = "SELECT subject,text FROM politics, poltext ". - "WHERE politics.id=poltext.thread_id AND poltext.id='$edit'"; - $result = mysql_query ($q, $db); - - if ($result && mysql_num_rows($result) == 1) { - $row=mysql_fetch_array($result); - - $subject = ereg_replace ("<", "<",$row[0]); - $text = ereg_replace ("<", "<",$row[1]); - } else { - $subject = "Empty"; - } - - echo "HC Aliance Forum: Edit Posting"; - -} else { - $text = ""; - echo "HC Alliance Forum: New thread"; -} - -?> - - - - -
-
Subject: - -"; -} else { - echo "$subject"; -} -?> - -
- -
- -     - -     -
-
- -
-Return to thread\n"; - else - echo "Return to HC Forum\n"; - } else { - echo "Close this Window\n"; - } - -echo "
\n\n"; - -require "footer.php"; +include "post.inc"; ?> diff --git a/online/header.php b/online/header.php index e8c6ff0..38aa13a 100644 --- a/online/header.php +++ b/online/header.php @@ -2,7 +2,7 @@ /* * MyPHPpa - * Copyright (C) 2003 Jens Beyer + * Copyright (C) 2003, 2007 Jens Beyer * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -82,7 +82,7 @@ function MyTick() { } else { echo " $game $version\n"; } - if ($imgpath && $imgpath != "") { + if (ISSET($imgpath) && $imgpath != "") { if ($mysettings&32) echo " "; else diff --git a/online/headerf.php b/online/headerf.php index c51ed01..69def10 100644 --- a/online/headerf.php +++ b/online/headerf.php @@ -2,7 +2,7 @@ /* * MyPHPpa - * Copyright (C) 2003 Jens Beyer + * Copyright (C) 2003, 2007 Jens Beyer * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -37,7 +37,7 @@ "; else diff --git a/online/help.php b/online/help.php index 38e4dc6..a325a80 100644 --- a/online/help.php +++ b/online/help.php @@ -2,7 +2,7 @@ /* * MyPHPpa - * Copyright (C) 2003 Jens Beyer + * Copyright (C) 2003, 2007 Jens Beyer * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/online/help_form.php b/online/help_form.php index 2415c9f..3091d70 100644 --- a/online/help_form.php +++ b/online/help_form.php @@ -2,7 +2,7 @@ /* * MyPHPpa - * Copyright (C) 2003 Jens Beyer + * Copyright (C) 2003, 2007 Jens Beyer * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/online/help_general.php b/online/help_general.php index fe90d52..882a620 100644 --- a/online/help_general.php +++ b/online/help_general.php @@ -2,7 +2,7 @@ /* * MyPHPpa - * Copyright (C) 2003 Jens Beyer + * Copyright (C) 2003, 2007 Jens Beyer * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -49,6 +49,8 @@
 
As far as possible standard language is english.
 
By logging into this game You accept these terms.
 
Khan, 1. Nov 2002
Last update: 11. Mar 2003
diff --git a/online/help_goal.php b/online/help_goal.php index a97f146..81b0cde 100644 --- a/online/help_goal.php +++ b/online/help_goal.php @@ -2,7 +2,7 @@ /* * MyPHPpa - * Copyright (C) 2003 Jens Beyer + * Copyright (C) 2003, 2007 Jens Beyer * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/online/help_links.php b/online/help_links.php index 59dd925..a777288 100644 --- a/online/help_links.php +++ b/online/help_links.php @@ -2,7 +2,7 @@ /* * MyPHPpa - * Copyright (C) 2003 Jens Beyer + * Copyright (C) 2003, 2007 Jens Beyer * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -64,18 +64,14 @@
For all who didnt know it - Real PA is still alive
diff --git a/online/help_rc.php b/online/help_rc.php index fc97690..a980a51 100644 --- a/online/help_rc.php +++ b/online/help_rc.php @@ -2,7 +2,7 @@ /* * MyPHPpa - * Copyright (C) 2003 Jens Beyer + * Copyright (C) 2003, 2007 Jens Beyer * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -30,9 +30,9 @@ function fetch_name ($id) { global $db; - $res = mysql_query ("SELECT name,type,block_id FROM rc_class WHERE id='$id'", $db); + $res = mysqli_query ("SELECT name,type,block_id FROM rc_class WHERE id='$id'", $db); if ($res) - $row = mysql_fetch_row($res); + $row = mysqli_fetch_row($res); return $row; } diff --git a/online/help_startup.php b/online/help_startup.php index 99726b4..223676f 100644 --- a/online/help_startup.php +++ b/online/help_startup.php @@ -2,7 +2,7 @@ /* * MyPHPpa - * Copyright (C) 2003 Jens Beyer + * Copyright (C) 2003, 2007 Jens Beyer * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/online/help_stat.php b/online/help_stat.php index 019eaa1..c13721e 100644 --- a/online/help_stat.php +++ b/online/help_stat.php @@ -2,7 +2,7 @@ /* * MyPHPpa - * Copyright (C) 2003 Jens Beyer + * Copyright (C) 2003, 2007 Jens Beyer * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -61,13 +61,13 @@
Speed
$row[0]"; diff --git a/online/help_story.php b/online/help_story.php index 8bd6181..a22247c 100644 --- a/online/help_story.php +++ b/online/help_story.php @@ -2,7 +2,7 @@ /* * MyPHPpa - * Copyright (C) 2003 Jens Beyer + * Copyright (C) 2003, 2007 Jens Beyer * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/online/highscore.php b/online/highscore.php index c3cbbfa..0d847df 100644 --- a/online/highscore.php +++ b/online/highscore.php @@ -2,7 +2,7 @@ /* * MyPHPpa - * Copyright (C) 2003 Jens Beyer + * Copyright (C) 2003, 2007 Jens Beyer * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -31,11 +31,11 @@ - + - + - + @@ -43,12 +43,12 @@
EOF; -if ($type=="galaxy") { +if (!ISSET($type)){ + $rtype = 1; +} else if ($type=="galaxy") { $rtype = 2; } else if ($type=="alliance") { $rtype = 3; -} else { - $rtype = 1; } if ($rtype == 1) { @@ -68,11 +68,11 @@ $q = "SELECT round,leader,planetname,coords,score,roids,". "date_format(date,'%e %b %y') FROM highscore ORDER BY round DESC"; -$res = mysql_query($q, $db); +$res = mysqli_query($db, $q ); -if ($res && mysql_num_rows($res)>0) { +if ($res && mysqli_num_rows($res)>0) { - while( ($row = mysql_fetch_row($res)) ) { + while( ($row = mysqli_fetch_row($res)) ) { echo "". "". @@ -85,11 +85,8 @@ } echo << - +
 
PlayerPlayer
GalaxiesGalaxies
AllianceAlliance
 
$row[0]$row[1]Sorry, previous rounds haven't been recorded.
round 15: arse war
-round 14: xata of oblivion
-round 13: blade
-round 2: Queen of the Universe +
Sorry, old highscores have been deleted.
round 2: Queen of the Universe
@@ -111,11 +108,11 @@ $q = "SELECT round,galname,coords,score,roids,". "date_format(date,'%e %b %y') FROM highscore_gal ORDER BY round DESC"; -$res = mysql_query($q, $db); +$res = mysqli_query($db, $q ); -if ($res && mysql_num_rows($res)>0) { +if ($res && mysqli_num_rows($res)>0) { - while( ($row = mysql_fetch_row($res)) ) { + while( ($row = mysqli_fetch_row($res)) ) { echo "
$row[0]$row[1]
\n"; echo "
Your account is already logged in or ". @@ -118,19 +118,18 @@ echo "
"; die; } else if ($myrow[1] == 0) { - $res = mysql_query ("SELECT data FROM logging ". - "WHERE class=2 and type=5 and planet_id='$myrow[0]'", - $db); + $res = mysqli_query ($db, "SELECT data FROM logging ". + "WHERE class=2 and type=5 and planet_id='$myrow[0]'" ); $reason = "Unspecified"; - if ($res && mysql_num_rows($res)>0) { - $ro = mysql_fetch_row($res); + if ($res && mysqli_num_rows($res)>0) { + $ro = mysqli_fetch_row($res); $reason=$ro[0]; } setcookie("Username",""); my_header($topscript,0,0); echo "



\n"; echo "Your account has been banned, reason: \"$reason\"
". "Have a look at the ". @@ -143,14 +142,14 @@ setcookie("Planetid",$myrow[0]); setcookie("Valid",md5($round),time()+432000); - $result = mysql_query("UPDATE planet SET mode=((mode & 0xF0) + 2) ". - "WHERE id='$myrow[0]'", $db); + $result = mysqli_query($db, "UPDATE planet SET mode=((mode & 0xF0) + 2) ". + "WHERE id='$myrow[0]'" ); if (($myrow[1] & 0x0F) == 2) { - $result = mysql_query("UPDATE user SET last=NOW() ". - "WHERE planet_id='$myrow[0]'", $db); + $result = mysqli_query($db, "UPDATE user SET last=NOW() ". + "WHERE planet_id='$myrow[0]'" ); } else { - $result = mysql_query("UPDATE user SET last=NOW(),login_date=NOW() ". - "WHERE planet_id='$myrow[0]'", $db); + $result = mysqli_query($db, "UPDATE user SET last=NOW(),login_date=NOW() ". + "WHERE planet_id='$myrow[0]'" ); } do_log_id($myrow[0], 1, 1, get_ip()); do_log_id($myrow[0], 1, 2, get_type()); @@ -163,11 +162,11 @@ } } -$result = mysql_query("SELECT COUNT(*) from user",$db); -$myrow = mysql_fetch_row($result); +$result = mysqli_query($db, "SELECT COUNT(*) from user"); +$myrow = mysqli_fetch_row($result); $numuser = $myrow[0]; -$result = mysql_query("SELECT COUNT(*) from planet where mode=2 OR mode=0xF2",$db); -$myrow = mysql_fetch_row($result); +$result = mysqli_query($db, "SELECT COUNT(*) from planet where mode=2 OR mode=0xF2"); +$myrow = mysqli_fetch_row($result); $numonline = $myrow[0]; @@ -184,12 +183,12 @@ my_header($topscript,0,0); -echo "




\n"; echo << +
EOF; @@ -199,7 +198,7 @@ echo "

Game is currently ". "closed

\n"; } else { - if ($submit) { + if (ISSET($submit)) { /* Failed login */ echo "

Wrong Login ". "or Password !!

\n"; @@ -235,7 +234,7 @@
- + diff --git a/online/index_msg.inc b/online/index_msg.inc index bc5d31f..302f4c7 100644 --- a/online/index_msg.inc +++ b/online/index_msg.inc @@ -1,5 +1,5 @@ MyPHPpa
-Copyright (C) 2003 Jens Beyer
+Copyright (C) 2003, 2007 Jens Beyer
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/online/journal.php b/online/journal.php index dd788bb..c8a20cd 100644 --- a/online/journal.php +++ b/online/journal.php @@ -2,7 +2,7 @@ /* * MyPHPpa - * Copyright (C) 2003 Jens Beyer + * Copyright (C) 2003, 2007 Jens Beyer * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -20,23 +20,23 @@ */ require "standard.php"; -require_once "planet_util.php"; +require_once "planet_util.inc"; -if ($clear && $clear != "") { - mysql_query ("DELETE LOW_PRIORITY FROM journal ". - "WHERE planet_id='$Planetid'", $db); +if (ISSET($clear) && $clear != "") { + mysqli_query ($db, "DELETE LOW_PRIORITY FROM journal ". + "WHERE planet_id='$Planetid'" ); } -if ($hide && $hide != 0) { - mysql_query ("DELETE LOW_PRIORITY FROM journal ". - "WHERE planet_id='$Planetid' AND target_id='$hide'", $db); +if (ISSET($hide) && $hide != 0) { + mysqli_query ($db, "DELETE LOW_PRIORITY FROM journal ". + "WHERE planet_id='$Planetid' AND target_id='$hide'" ); } /* top table is written now */ top_header($myrow); $msg = ""; -if ($clear && $clear != "") { +if (ISSET($clear) && $clear != "") { $msg = "Journal set to clear\n
\n"; } @@ -45,7 +45,7 @@
0) { +if (ISSET($tid) && $tid>0) { $who = get_coord_name ($tid); echo <<
+ Overview + Clear @@ -69,10 +69,10 @@ $q = "SELECT type,tick,date,data FROM journal WHERE planet_id='$Planetid' ". "AND target_id='$tid' AND hidden=0"; - $result = mysql_query ($q, $db); + $result = mysqli_query ($db, $q ); - if ($result && mysql_num_rows($result) > 0) { - while ($row = mysql_fetch_row($result)) { + if ($result && mysqli_num_rows($result) > 0) { + while ($row = mysqli_fetch_row($result)) { echo "
\n$row[3]\n"; } } else { @@ -86,17 +86,17 @@
Login:  - Overview - Clear $who[x]:$who[y]
+Clear all entries EOF; - echo "\n\n". "\n". "". - "\n"; @@ -105,11 +105,11 @@ "FROM journal WHERE planet_id='$Planetid' ". "AND hidden=0 GROUP BY target_id"; - if ($date) { + if (ISSET($date)) { $q .= " ORDER BY d "; if ($date==1) $q .= "DESC"; else $q .= "ASC"; - } else if ($coords) { + } else if (ISSET($coords)) { $q = "SELECT target_id, count(*), sum(type), ". "date_format(max(journal.date),'%D %b %H:%i'), ". "max(journal.date) as d ". @@ -120,17 +120,17 @@ else $q .= "x DESC, y DESC, z DESC"; } - $result = mysql_query ($q, $db); + $result = mysqli_query ($db, $q ); - if ($result && mysql_num_rows($result) > 0) { - while ($row = mysql_fetch_row($result)) { + if ($result && mysqli_num_rows($result) > 0) { + while ($row = mysqli_fetch_row($result)) { $who = get_coord_name ($row[0]); echo "". - "". ""; diff --git a/online/logging.php b/online/logging.php index 363a03c..8a9b986 100644 --- a/online/logging.php +++ b/online/logging.php @@ -2,7 +2,7 @@ /* * MyPHPpa - * Copyright (C) 2003 Jens Beyer + * Copyright (C) 2003, 2007 Jens Beyer * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -22,15 +22,15 @@ function do_log_id ($id, $class, $event, $data) { global $db; - mysql_query ("INSERT INTO logging SET planet_id='$id', stamp=NOW(),". - "type='$event', class='$class', data='$data'", $db); + mysqli_query ($db, "INSERT INTO logging SET planet_id='$id', stamp=NOW(),". + "type='$event', class='$class', data='$data'" ); } function do_log_me ($class, $event, $data) { global $db, $Planetid; - $r=mysql_query ("INSERT INTO logging SET planet_id='$Planetid',". - "stamp=NOW(),type='$event', class='$class', data='$data'", $db); + $r=mysqli_query ($db, "INSERT INTO logging SET planet_id='$Planetid',". + "stamp=NOW(),type='$event', class='$class', data='$data'" ); } ?> diff --git a/online/logout.php b/online/logout.php index bd47af2..dec12ad 100644 --- a/online/logout.php +++ b/online/logout.php @@ -2,7 +2,7 @@ /* * MyPHPpa - * Copyright (C) 2003 Jens Beyer + * Copyright (C) 2003, 2007 Jens Beyer * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -24,12 +24,12 @@ require "logging.php"; if ( $Planetid>0 ) { - $result = mysql_query("UPDATE user SET uptime=". + $result = mysqli_query($db, "UPDATE user SET uptime=". "SEC_TO_TIME(UNIX_TIMESTAMP(last) - UNIX_TIMESTAMP(login_date) + ". "TIME_TO_SEC(uptime)) ". - "WHERE planet_id='$Planetid' AND (mode&0xF) = 2",$db); - $result = mysql_query("UPDATE planet SET mode=((mode & 0xF0) + 1) ". - "WHERE id='$Planetid' AND (mode&0xF) = 2", $db); + "WHERE planet_id='$Planetid' AND (mode&0xF) = 2"); + $result = mysqli_query($db, "UPDATE planet SET mode=((mode & 0xF0) + 1) ". + "WHERE id='$Planetid' AND (mode&0xF) = 2" ); do_log_me(2, 1,""); // event:logout=2, class:login/out=1 } diff --git a/online/main.php b/online/main.php index 95c04c8..ce8d94d 100644 --- a/online/main.php +++ b/online/main.php @@ -2,7 +2,7 @@ /* * MyPHPpa - * Copyright (C) 2003 Jens Beyer + * Copyright (C) 2003, 2007 Jens Beyer * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -35,11 +35,11 @@ require "dblogon.php"; -$result = mysql_query("SELECT login,settings FROM user ". +$result = mysqli_query($db, "SELECT login,settings FROM user ". "WHERE login='$Username' AND md5(password)='$Password' ". - "AND planet_id='$Planetid'",$db); + "AND planet_id='$Planetid'"); -if (!result || mysql_num_rows($result) != 1) { +if (!$result || mysqli_num_rows($result) != 1) { setcookie("Username",""); setcookie("Password",""); diff --git a/online/market.php b/online/market.php index c9496c6..ce643bd 100644 --- a/online/market.php +++ b/online/market.php @@ -2,7 +2,7 @@ /* * MyPHPpa - * Copyright (C) 2003 Jens Beyer + * Copyright (C) 2003, 2007 Jens Beyer * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -91,7 +91,7 @@ function get_market_price ($num, $price) { $q = "UPDATE planet SET metal='$myrow[metal]',crystal='$myrow[crystal]',". "eonium='$myrow[eonium]' where id='$Planetid'"; - $result = mysql_query($q, $db); + $result = mysqli_query($db, $q ); $msg .= $q . "
"; return $result; @@ -107,7 +107,7 @@ function pay_market_price ($num, $price) { $q = "UPDATE planet SET metal='$myrow[metal]',crystal='$myrow[crystal]',". "eonium='$myrow[eonium]' where id='$Planetid'"; - $result = mysql_query($q, $db); + $result = mysqli_query($db, $q ); return $result; } @@ -125,11 +125,11 @@ function trade_ship_unit ($unit, $num) { "WHERE uc.id='$unit' AND uc.rc_id=rc.rc_id ". "AND rc.status=3 AND rc.planet_id='$Planetid'"; - $res = mysql_query($q, $db); + $res = mysqli_query($db, $q ); $msg .= $q ."
"; - if ($res && mysql_num_rows($res) == 1) { - $price = mysql_fetch_row($res); + if ($res && mysqli_num_rows($res) == 1) { + $price = mysqli_fetch_row($res); $factor = get_factor(); for ($i=0; $i<3; $i++) $price[$i] *= $factor; @@ -147,27 +147,27 @@ function trade_ship_unit ($unit, $num) { "AND units.id=fleet.fleet_id AND units.unit_id='$unit'"; $msg .= $q . "
"; - $res = mysql_query ($q, $db); - $nrow = mysql_fetch_row($res); + $res = mysqli_query ($db, $q ); + $nrow = mysqli_fetch_row($res); $num = $nrow[0]; if ($num >0) { - // mysql_query ("UPDATE market set num=num-'$num' ". - // "WHERE unit_id='$unit' AND type=1", $db); - mysql_query ("UPDATE market set num=num+'$num' ". - "WHERE unit_id='$unit' AND type=1", $db); + // mysqli_query ($db, "UPDATE market set num=num-'$num' ". + // "WHERE unit_id='$unit' AND type=1" ); + mysqli_query ($db, "UPDATE market set num=num+'$num' ". + "WHERE unit_id='$unit' AND type=1" ); // $msg .= "Ordering $num Units
"; // pay_market_price($num, $price); $msg .= "Selling $num Units ($nrow[1])
"; get_market_price($num, $price); - // mysql_query ("INSERT INTO units (id,num,unit_id) ". + // mysqli_query ($db, "INSERT INTO units (id,num,unit_id) ". // "SELECT fleet_id,'$num','$unit' ". - // "FROM fleet WHERE num=0 AND planet_id='$Planetid'", $db); - mysql_query ("UPDATE units set num=num-'$num' ". - "WHERE id='$nrow[1]' AND unit_id='$unit'", $db); + // "FROM fleet WHERE num=0 AND planet_id='$Planetid'" ); + mysqli_query ($db, "UPDATE units set num=num-'$num' ". + "WHERE id='$nrow[1]' AND unit_id='$unit'" ); } else { $msg .= "No units available!"; @@ -197,21 +197,21 @@ function market_all($q, $qq, $name, $str_type, $qb=0) { global $Planetid, $db, $page; - $result = mysql_query ($q, $db); - if ($result && mysql_num_rows($result) > 0) { + $result = mysqli_query ($db, $q ); + if ($result && mysqli_num_rows($result) > 0) { market_table_head($name, $qb); - while ($myunit = mysql_fetch_row($result)) { + while ($myunit = mysqli_fetch_row($result)) { - $nr = mysql_query ( $qq ."'$myunit[0]' AND planet_id='$Planetid'", $db); + $nr = mysqli_query ($db, $qq ."'$myunit[0]' AND planet_id='$Planetid'" ); - $stock = mysql_fetch_row ($nr); + $stock = mysqli_fetch_row ($nr); if ( !$stock[0]) $stock[0] = 0; if ($qb) { - $nr = mysql_query ( $qb ."'$myunit[0]' AND planet_id='$Planetid'", $db); - $base = mysql_fetch_row ($nr); + $nr = mysqli_query ($db, $qb ."'$myunit[0]' AND planet_id='$Planetid'" ); + $base = mysqli_fetch_row ($nr); if ( !$base[0]) $base[0] = 0; print_unit_row ($myunit, $stock[0], $str_type, $base[0]); @@ -240,10 +240,10 @@ function market_all($q, $qq, $name, $str_type, $qb=0) $msg = ""; // rc_id=91 == Market House -$res = mysql_query ("SELECT status FROM rc ". - "WHERE rc_id=91 AND status=3 AND planet_id='$Planetid'", $db); +$res = mysqli_query ($db, "SELECT status FROM rc ". + "WHERE rc_id=91 AND status=3 AND planet_id='$Planetid'" ); -if (!$res || mysql_num_rows($res)==0) { +if (!$res || mysqli_num_rows($res)==0) { $msg = "You didnt build a Trading Unit"; $fail=1; } else { @@ -294,14 +294,14 @@ function market_all($q, $qq, $name, $str_type, $qb=0) echo << - +
Private Journal Overview
-Clear all entries
CoordsTargetCountTypeLast
". "". "$who[x]:$who[y]:$who[z]". + "". "$who[leader] of $who[planetname]$row[1]
Market Place
Sell | Buy
Sell | Buy
EOF; if ($page) - echo ""; + echo ""; else - echo ""; + echo ""; /* ship market */ $q = "SELECT uc.id, uc.name, uc.metal, uc.crystal, uc.eonium, m.num ". diff --git a/online/messages.php b/online/messages.php index 8a453ae..35c5916 100644 --- a/online/messages.php +++ b/online/messages.php @@ -2,7 +2,7 @@ /* * MyPHPpa - * Copyright (C) 2003 Jens Beyer + * Copyright (C) 2003, 2007 Jens Beyer * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -19,21 +19,26 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -require "popup_header.php"; +require "popup_header.inc"; require "standard.php"; -require "planet_util.php"; +require "planet_util.inc"; function make_popup_link ($title, $link, $arg) { - global $myrow, $PHP_SELF; - if ($myrow["no_popup"] == 1) { - return "$PHP_SELF?$arg"; + global $myrow; + + // not used or not usefull + /* + if ($myrow["no_popup"] == 1) { + return "$_SERVER[PHP_SELF]?$arg"; } else { return "javascript:popupWindow('$title','$link?$arg',340,700)"; } + */ + return "javascript:popupWindow('$title','$link?$arg',340,700)"; } function print_mail ($r) { - global $PHP_SELF, $Planetid, $folder; + global $Planetid, $folder; $id = $r["id"]; $txt = ereg_replace ("<", "<", $r["text"]); @@ -41,7 +46,7 @@ function print_mail ($r) { if ($r["sender"] == $Planetid) { $ir = get_coord_name($r["receiver"]); - $info = "To: $ir[leader] of $r[planetname] ($ir[x]:$ir[y]:$ir[z])"; + $info = "To: $ir[leader] of $ir[planetname] ($ir[x]:$ir[y]:$ir[z])"; } else { $ir = get_coord_name($r["sender"]); $info = "From: $ir[leader] of $ir[planetname] ($ir[x]:$ir[y]:$ir[z])"; @@ -64,16 +69,16 @@ function print_mail ($r) { echo "Forward | ". - "Delete"; + "Delete"; if ($folder != 3) - echo " | Save"; + echo " | Save"; echo "
"; } function print_td ($text, $cp, $link="", $jscript=0) { - global $browser_type, $PHP_SELF, $imgpath; + global $browser_type, $imgpath; $width = (100. / 6. ) * $cp; @@ -113,7 +118,7 @@ function print_td ($text, $cp, $link="", $jscript=0) { } function msg_menu ($folder) { - global $PHP_SELF, $Planetid, $db; + global $Planetid, $db; echo << @@ -131,10 +136,10 @@ function msg_menu ($folder) { $q = "SELECT folder, count(*) FROM msg ". "WHERE planet_id='$Planetid' AND folder!=0 GROUP BY folder"; - $result = mysql_query ($q, $db); + $result = mysqli_query ($db, $q ); - if ($result && mysql_num_rows($result) > 0) { - while(($row=mysql_fetch_array($result))) { + if ($result && mysqli_num_rows($result) > 0) { + while(($row=mysqli_fetch_array($result))) { $num[$row[0]] = $row[1]; } } @@ -148,24 +153,24 @@ function msg_menu ($folder) { if ($i==$folder) { print_td("$name : $num[$i]", 2); } else { - print_td("$name : $num[$i]", 2, "$PHP_SELF?folder=$i"); + print_td("$name : $num[$i]", 2, "$_SERVER[PHP_SELF]?folder=$i"); } } echo "\n"; print_td("Delete all messages in current folder",3, - "$PHP_SELF?folder=$folder&delete_all=1"); + "$_SERVER[PHP_SELF]?folder=$folder&delete_all=1"); if ($folder != 3) { print_td ("Save all messages in current folder", 3, - "$PHP_SELF?folder=$folder&save_all=1"); + "$_SERVER[PHP_SELF]?folder=$folder&save_all=1"); } else { print_td ("Save all messages in current folder", 3); if ($folder == 1) { $q = "UPDATE msg SET old=1 WHERE planet_id='$Planetid' ". "AND folder=1"; - mysql_query ($q, $db); + mysqli_query ($db, $q ); } } echo "\n"; @@ -199,52 +204,52 @@ function moc_menu ($x, $y) { /* clear has_mail flag if present */ if ($myrow["has_mail"] == 1) { $myrow["has_mail"] = 0; - mysql_query ("UPDATE planet SET has_mail=0 WHERE id='$Planetid'", $db); + mysqli_query ($db, "UPDATE planet SET has_mail=0 WHERE id='$Planetid'" ); } /* top table is written now */ top_header($myrow); -if (!$folder) $folder=1; +if (!ISSET($folder)) $folder=1; -if ($delete) { +if (ISSET($delete)) { // if mail is sent to myself it doesnt work :-( $q = "UPDATE msg SET folder=0 WHERE mail_id='$delete' AND planet_id='$Planetid' ". "AND folder='$folder'"; - $res = mysql_query($q, $db); - if (mysql_affected_rows()) { - $res = mysql_query("UPDATE mail SET ref=ref-1 ". - "WHERE id='$delete'", $db); + $res = mysqli_query($db, $q ); + if (mysqli_affected_rows($db)) { + $res = mysqli_query($db, "UPDATE mail SET ref=ref-1 ". + "WHERE id='$delete'" ); } } -if ($delete_all) { +if (ISSET($delete_all)) { $q = "SELECT mail_id FROM msg ". "WHERE planet_id='$Planetid' AND folder='$folder'"; - $res = mysql_query($q, $db); + $res = mysqli_query($db, $q ); - if ($res && mysql_num_rows($res) > 0) { - while($row=mysql_fetch_row($res)) { - mysql_query("UPDATE mail SET ref=ref-1 ". - "WHERE id='$row[0]'", $db); + if ($res && mysqli_num_rows($res) > 0) { + while($row=mysqli_fetch_row($res)) { + mysqli_query($db, "UPDATE mail SET ref=ref-1 ". + "WHERE id='$row[0]'" ); } - $res = mysql_query("UPDATE msg SET folder=0 ". + $res = mysqli_query($db, "UPDATE msg SET folder=0 ". "WHERE planet_id='$Planetid' ". - "AND folder='$folder'", $db); + "AND folder='$folder'" ); } } -if ($save && $folder!=3) { - $res = mysql_query("UPDATE msg SET folder=3 ". +if (ISSET($save) && $folder!=3) { + $res = mysqli_query($db, "UPDATE msg SET folder=3 ". "WHERE mail_id='$save' AND planet_id='$Planetid' ". - "AND folder='$folder'", $db); + "AND folder='$folder'" ); } -if ($save_all && $folder!=3) { - $res = mysql_query("UPDATE msg SET folder=3 ". +if (ISSET($save_all) && $folder!=3) { + $res = mysqli_query($db, "UPDATE msg SET folder=3 ". "WHERE planet_id='$Planetid' ". - "AND folder='$folder'", $db); + "AND folder='$folder'" ); } titlebox("Messages"); @@ -252,12 +257,12 @@ function moc_menu ($x, $y) { msg_menu($folder); $q = "SELECT moc FROM galaxy WHERE x='$myrow[x]' AND y='$myrow[y]' AND moc='$Planetid'"; -$res = mysql_query($q, $db); -if (mysql_num_rows($res) == 1 || $Planetid==1) { - moc_menu($myrow[x], $myrow[y]); +$res = mysqli_query($db, $q ); +if (mysqli_num_rows($res) == 1 || $Planetid==1) { + moc_menu($myrow["x"], $myrow["y"]); } -if ($new || $reply || $forward || $send_to) { +if (ISSET($new) || ISSET($reply) || ISSET($forward) || ISSET($send_to)) { send_message_form(650); } else { $q = "SELECT mail.id AS id, mail.date AS date, mail.subject AS subject, ". @@ -267,10 +272,10 @@ function moc_menu ($x, $y) { "AND mail.id=msg.mail_id ". "ORDER BY mail.date DESC"; - $result = mysql_query ($q, $db); + $result = mysqli_query ($db, $q ); - if ($result && mysql_num_rows($result) > 0) { - while ($row=mysql_fetch_array($result)) { + if ($result && mysqli_num_rows($result) > 0) { + while ($row=mysqli_fetch_array($result)) { print_mail ($row); } } diff --git a/online/military.php b/online/military.php index 830cd36..a4f26fc 100644 --- a/online/military.php +++ b/online/military.php @@ -2,7 +2,7 @@ /* * MyPHPpa - * Copyright (C) 2003 Jens Beyer + * Copyright (C) 2003, 2007 Jens Beyer * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -20,7 +20,7 @@ */ require "standard.php"; -require "planet_util.php"; +require "planet_util.inc"; require "fleet_util.php"; require "news_util.php"; require "logging.php"; @@ -39,7 +39,7 @@ function set_hostile ($id, $dir) { "WHERE x='$coords[x]' AND y='$coords[y]'". "AND id!='$id'"; - $result = mysql_query ($q, $db); + $result = mysqli_query ($db, $q ); if ($dir > 0) { $q = "UPDATE planet SET has_hostile=has_hostile+1 ". @@ -50,7 +50,7 @@ function set_hostile ($id, $dir) { $q = "UPDATE planet SET has_hostile=has_hostile-1 ". "WHERE id='$id'"; - $result = mysql_query ($q, $db); + $result = mysqli_query ($db, $q ); } function set_friendly ($id, $dir) { @@ -66,7 +66,7 @@ function set_friendly ($id, $dir) { $q = "UPDATE planet SET has_friendly=has_friendly-1 ". "WHERE id='$id'"; - $result = mysql_query ($q, $db); + $result = mysqli_query ($db, $q ); } function check_self_attack ($id, $type) { @@ -76,9 +76,9 @@ function check_self_attack ($id, $type) { $q = "SELECT fleet_id FROM fleet WHERE planet_id='$Planetid' ". "AND target_id='$id' AND type ".$t; - $result = mysql_query ($q, $db); + $result = mysqli_query ($db, $q ); - if ($result && mysql_num_rows($result)>0) + if ($result && mysqli_num_rows($result)>0) return 1; else return 0; @@ -92,10 +92,10 @@ function get_attac_fleet ($id) { "WHERE fleet.target_id='$id' AND fleet.type>10 ". "AND fleet.fleet_id=units.id AND units.unit_id=unit_class.id"; - $result = mysql_query ($q, $db); + $result = mysqli_query ($db, $q ); - if ($result && mysql_num_rows($result)>0) { - $row = mysql_fetch_row ($result); + if ($result && mysqli_num_rows($result)>0) { + $row = mysqli_fetch_row ($result); return $row[0]; } else return 0; @@ -104,11 +104,11 @@ function get_attac_fleet ($id) { function get_num_units ($fleet_id, $unit_id) { global $db; - $res = mysql_query ("SELECT SUM(num) from units ". - "WHERE id=$fleet_id AND unit_id=$unit_id",$db); + $res = mysqli_query ($db, "SELECT SUM(num) from units ". + "WHERE id=$fleet_id AND unit_id=$unit_id"); - if ($res && mysql_num_rows($res) >0) { - $r = mysql_fetch_row($res); + if ($res && mysqli_num_rows($res) >0) { + $r = mysqli_fetch_row($res); return $r[0]; } return 0; @@ -173,15 +173,15 @@ function transfer_ship ($type, $num, $from, $to) { if ($from == 255) $from = 0; if ($to == 255) $to = 0; - $result = mysql_query ("SELECT num, fleet_id FROM fleet where target_id=0 ". + $result = mysqli_query ($db, "SELECT num, fleet_id FROM fleet where target_id=0 ". "AND ticks=0 AND planet_id='$Planetid' ". - "AND (num=$from or num=$to)", $db); - if (!$result || mysql_num_rows($result) != 2) { + "AND (num=$from or num=$to)" ); + if (!$result || mysqli_num_rows($result) != 2) { return "Due to military blabla Fleets must reside in home ". "sector to transfer ships
\n"; } - while ($row = mysql_fetch_row($result)) + while ($row = mysqli_fetch_row($result)) $fleet[$row[0]] = $row[1]; if ($type == 255) { @@ -189,43 +189,43 @@ function transfer_ship ($type, $num, $from, $to) { $q = "UPDATE units SET id='$fleet[$to]' WHERE id='$fleet[$from]' ". "AND unit_id!=$missile_id"; - $result = mysql_query ($q, $db); + $result = mysqli_query ($db, $q ); if (!$result) return "Fleet movement failed
\n"; } else { // // Hier lock start - mysql_query ("LOCK TABLES units WRITE", $db); + mysqli_query ($db, "LOCK TABLES units WRITE" ); $q = "SELECT SUM(num) FROM units ". "WHERE id='$fleet[$from]' AND unit_id='$type'"; - $result = mysql_query($q, $db); + $result = mysqli_query($db, $q ); - if ($result && mysql_num_rows($result)==1) { - $row = mysql_fetch_row($result); + if ($result && mysqli_num_rows($result)==1) { + $row = mysqli_fetch_row($result); if ($row[0] > 0) { if ($num == 0) $num = $row[0]; $q = "DELETE FROM units where id='$fleet[$from]' AND unit_id='$type'"; - $result = mysql_query($q, $db); + $result = mysqli_query($db, $q ); if ($row[0] > $num) { $rest = $row[0] - $num; $q = "INSERT INTO units SET id='$fleet[$from]',". "num='$rest',unit_id='$type'"; - $result = mysql_query($q, $db); + $result = mysqli_query($db, $q ); $row[0] = $num; } $q = "INSERT INTO units SET id='$fleet[$to]',". "num='$row[0]',unit_id='$type'"; - $result = mysql_query($q, $db); + $result = mysqli_query($db, $q ); } } // Hier lock end // - mysql_query ("UNLOCK TABLES", $db); + mysqli_query ($db, "UNLOCK TABLES" ); } return ""; @@ -295,15 +295,15 @@ function send_fleet ($flnum, $order, $x, $y, $z) { global $db, $Planetid, $myrow, $havoc; $msg = ""; - if ($x==$myrow[x] && $y==$myrow[y] && $z==$myrow[z]) { + if ($x==$myrow["x"] && $y==$myrow["y"] && $z==$myrow["z"]) { return "Target coords banned ;-)"; } $q = "SELECT sum(units.num) FROM units,fleet WHERE fleet.planet_id='$Planetid' ". "AND fleet.num='$flnum' AND fleet.fleet_id=units.id"; - $result = mysql_query($q, $db); - if ($result && mysql_num_rows($result) > 0) { - $row = mysql_fetch_row ($result); + $result = mysqli_query($db, $q ); + if ($result && mysqli_num_rows($result) > 0) { + $row = mysqli_fetch_row ($result); if ($row[0]<1) return "You dont have ships in your fleet"; } else { @@ -312,12 +312,12 @@ function send_fleet ($flnum, $order, $x, $y, $z) { if ($order == 255) { - $result = mysql_query("SELECT target_id,ticks,type,full_eta FROM fleet ". + $result = mysqli_query($db, "SELECT target_id,ticks,type,full_eta FROM fleet ". "WHERE planet_id='$Planetid' AND num='$flnum' ". - "AND target_id!=0", $db); + "AND target_id!=0" ); - if ($result && mysql_num_rows($result) > 0) { - $row = mysql_fetch_row ($result); + if ($result && mysqli_num_rows($result) > 0) { + $row = mysqli_fetch_row ($result); if ($row[2]<10) { set_friendly($row[0],-1); @@ -328,25 +328,25 @@ function send_fleet ($flnum, $order, $x, $y, $z) { do_log_me (4,8,"Recall Att: [$row[0]]"); do_log_id ($row[0],4,9,"Recall Hostile: [$Planetid]"); } - /* $result = mysql_query ($q, $db); + /* $result = mysqli_query ($db, $q ); */ $eta = $row[3] - $row[1]; - $result = mysql_query("UPDATE fleet set target_id=0,type=0, ". + $result = mysqli_query($db, "UPDATE fleet set target_id=0,type=0, ". "ticks='$eta',full_eta=0 ". "WHERE planet_id='$Planetid' ". - "AND num='$flnum'", $db); + "AND num='$flnum'" ); send_msg_fleet_recall ($row[0], $eta, $row[2]); } return $msg; } else { - $result = mysql_query("SELECT target_id, ticks, full_eta FROM fleet ". - "WHERE planet_id='$Planetid' AND num='$flnum'", $db); + $result = mysqli_query($db, "SELECT target_id, ticks, full_eta FROM fleet ". + "WHERE planet_id='$Planetid' AND num='$flnum'" ); $row[0] = -1; if ($result) - $row = mysql_fetch_row ($result); + $row = mysqli_fetch_row ($result); if ($row[0] || $row[1] || $row[2] ) { return "Fleet $flnum is not at home (ETA $row[1])"; @@ -377,11 +377,11 @@ function send_fleet ($flnum, $order, $x, $y, $z) { "type='$order',full_eta='$eta' ". "WHERE num=$flnum AND planet_id='$Planetid'"; - $result = mysql_query ($q, $db); + $result = mysqli_query ($db, $q ); $myrow["eonium"] -= $fuel; - $result = mysql_query ("UPDATE planet SET eonium='$myrow[eonium]' ". - "WHERE id='$Planetid'", $db); + $result = mysqli_query ($db, "UPDATE planet SET eonium='$myrow[eonium]' ". + "WHERE id='$Planetid'" ); if ($order<10) { set_friendly($target_id,1); @@ -407,8 +407,8 @@ function send_missile ($num, $x, $y, $z) { $q = "SELECT target_id,fleet_id FROM fleet ". "WHERE planet_id=$Planetid AND num=$number_of_fleets"; - $res = mysql_query ($q, $db); - $row = mysql_fetch_row($res); + $res = mysqli_query ($db, $q ); + $row = mysqli_fetch_row($res); if ($row[0] != 0) { return "Your Missile turrets still track current launch"; } else { @@ -422,10 +422,10 @@ function send_missile ($num, $x, $y, $z) { $q = "SELECT sum(units.num) FROM units,fleet ". "WHERE units.id=fleet.fleet_id AND fleet.num=0 ". "AND units.unit_id=$missile_id AND fleet.planet_id=$Planetid"; - $res = mysql_query ($q, $db); + $res = mysqli_query ($db, $q ); - if ($res && mysql_num_rows($res) > 0) { - $row = mysql_fetch_row($res); + if ($res && mysqli_num_rows($res) > 0) { + $row = mysqli_fetch_row($res); $base_missile = $row[0]; if ($base_missile==0) @@ -442,9 +442,9 @@ function send_missile ($num, $x, $y, $z) { // check for launchers $q = "SELECT num FROM pds WHERE planet_id=$Planetid and pds_id=25"; - $res = mysql_query ($q, $db); - if ($res && mysql_num_rows($res) > 0) { - $row = mysql_fetch_row($res); + $res = mysqli_query ($db, $q ); + if ($res && mysqli_num_rows($res) > 0) { + $row = mysqli_fetch_row($res); if ($row[0]==0) return "You dont have any Missile Launchers."; if ($row[0]<$num) $num = $row[0]; @@ -459,38 +459,38 @@ function send_missile ($num, $x, $y, $z) { if ($msg != "") return $msg; // base fleet id - $res = mysql_query ("SELECT fleet_id FROM fleet ". - "WHERE planet_id=$Planetid and num=0", $db); - $row = mysql_fetch_row ($res); + $res = mysqli_query ($db, "SELECT fleet_id FROM fleet ". + "WHERE planet_id=$Planetid and num=0" ); + $row = mysqli_fetch_row ($res); $base_id = $row[0]; // Hier lock start - mysql_query ("LOCK TABLES units WRITE", $db); + mysqli_query ($db, "LOCK TABLES units WRITE" ); // safety: also nochmal base number - $res = mysql_query ("SELECT sum(num) FROM units ". - "WHERE id=$base_id AND unit_id=$missile_id ", $db); - $row = mysql_fetch_row ($res); + $res = mysqli_query ($db, "SELECT sum(num) FROM units ". + "WHERE id=$base_id AND unit_id=$missile_id " ); + $row = mysqli_fetch_row ($res); $bn = $row[0]; // weg mit den alten aus der base - mysql_query ("DELETE FROM units WHERE id=$base_id AND unit_id=$missile_id", $db); + mysqli_query ($db, "DELETE FROM units WHERE id=$base_id AND unit_id=$missile_id" ); if ($bn != $num) { - mysql_query ("INSERT INTO units VALUES($base_id,$missile_id,". - ($bn - $num).")", $db); + mysqli_query ($db, "INSERT INTO units VALUES($base_id,$missile_id,". + ($bn - $num).")" ); } - mysql_query ("INSERT INTO units VALUES ($fleet_id, $missile_id, $num)", $db); + mysqli_query ($db, "INSERT INTO units VALUES ($fleet_id, $missile_id, $num)" ); // Hier lock end // - mysql_query ("UNLOCK TABLES", $db); + mysqli_query ($db, "UNLOCK TABLES" ); $fuel = get_target_fuel ($fleet_id, $x, $y, $z); if ($myrow["eonium"] < $fuel) { - mysql_query ("UPDATE units SET id=$base_id ". - "WHERE id=$fleet_id", $db); + mysqli_query ($db, "UPDATE units SET id=$base_id ". + "WHERE id=$fleet_id" ); return "Not enough Fuel ($fuel > $myrow[eonium]) ". "for Target ($x, $y, $z)[$order]"; @@ -499,12 +499,12 @@ function send_missile ($num, $x, $y, $z) { $eta = get_target_eta ($fleet_id, $x, $y, $z); - mysql_query ("UPDATE fleet SET target_id=$target_id,full_eta=$eta,". - "ticks=$eta,type=11 WHERE fleet_id=$fleet_id", $db); + mysqli_query ($db, "UPDATE fleet SET target_id=$target_id,full_eta=$eta,". + "ticks=$eta,type=11 WHERE fleet_id=$fleet_id" ); $myrow["eonium"] -= $fuel; - $result = mysql_query ("UPDATE planet SET eonium='$myrow[eonium]' ". - "WHERE id='$Planetid'", $db); + $result = mysqli_query ($db, "UPDATE planet SET eonium='$myrow[eonium]' ". + "WHERE id='$Planetid'" ); set_hostile($target_id,1); @@ -516,10 +516,13 @@ function send_missile ($num, $x, $y, $z) { $msg = ""; /* missiles are special */ -$result = mysql_query ("SELECT id from unit_class WHERE class=6", $db); -if ($result && mysql_num_rows($result) > 0) { - $row = mysql_fetch_row($result); +$result = mysqli_query ($db, "SELECT id from unit_class WHERE class=6" ); +if ($result && mysqli_num_rows($result) > 0) { + $row = mysqli_fetch_row($result); $missile_id = $row[0]; +} else { + $missile_id = 0; + // error } /* generate array of ships */ @@ -530,41 +533,41 @@ function send_missile ($num, $x, $y, $z) { "AND fleet.num<$number_of_fleets ". "GROUP BY units.unit_id"; -$result = mysql_query ($q, $db); +$result = mysqli_query ($db, $q ); -if ($result && mysql_num_rows($result) > 0) { - while ($row = mysql_fetch_row($result)) { +if ($result && mysqli_num_rows($result) > 0) { + while ($row = mysqli_fetch_row($result)) { $ships[$row[0]] = $row[1]; } } $ships[255] = "All Ships"; -if ($transfer) { - if ($ship_move_0) +if (ISSET($transfer)) { + if (ISSET($ship_move_0)) $msg .= transfer_ship ($ship_move_0, $ship_number_0, $ship_from_0, $ship_to_0); - if ($ship_move_1) + if (ISSET($ship_move_1)) $msg .= transfer_ship ($ship_move_1, $ship_number_1, $ship_from_1, $ship_to_1); - if ($ship_move_2) + if (ISSET($ship_move_2)) $msg .= transfer_ship ($ship_move_2, $ship_number_2, $ship_from_2, $ship_to_2); - if ($ship_move_3) + if (ISSET($ship_move_3)) $msg .= transfer_ship ($ship_move_3, $ship_number_3, $ship_from_3, $ship_to_3); } -if ($execute) { - if ($fleet_1) +if (ISSET($execute)) { + if (ISSET($fleet_1)) $msg .= send_fleet (1, $fleet_1, $fleet_1_x, $fleet_1_y ,$fleet_1_z); - if ($fleet_2) + if (ISSET($fleet_2)) $msg .= send_fleet (2, $fleet_2, $fleet_2_x, $fleet_2_y ,$fleet_2_z); - if ($fleet_3) + if (ISSET($fleet_3)) $msg .= send_fleet (3, $fleet_3, $fleet_3_x, $fleet_3_y ,$fleet_3_z); } -if ($launch) { +if (ISSET($launch)) { $msg .= send_missile ($miss_num, $miss_x, $miss_y, $miss_z); } @@ -610,9 +613,9 @@ function rtime () { "WHERE fleet.planet_id='$Planetid' AND fleet.fleet_id=units.id ". "GROUP BY units.unit_id,fleet.num"; -$res = mysql_query($q, $db); +$res = mysqli_query($db, $q ); // preselect first row -$row = mysql_fetch_row ($res); +$row = mysqli_fetch_row ($res); $ship_opt = ""; while (list ($num, $name) = each ($ships)) { @@ -638,7 +641,7 @@ function rtime () { } // fetch next - $row = mysql_fetch_row ($res); + $row = mysqli_fetch_row ($res); } else { echo " "; } @@ -692,7 +695,7 @@ function rtime () {
- +"> @@ -723,7 +726,7 @@ function rtime () {
Ship Movement
Ship Type
-
+"> @@ -735,9 +738,9 @@ function rtime () { +
Fleet Movement
Fleet
@@ -773,10 +776,10 @@ function rtime () { "WHERE units.id=fleet.fleet_id AND fleet.num=0 ". "AND units.unit_id=$missile_id AND fleet.planet_id=$Planetid"; - $res = mysql_query ($q, $db); + $res = mysqli_query ($db, $q ); - if ($res && mysql_num_rows($res) > 0) { - $row = mysql_fetch_row($res); + if ($res && mysqli_num_rows($res) > 0) { + $row = mysqli_fetch_row($res); $base_missile = $row[0]; if ($base_missile>0) { @@ -793,11 +796,11 @@ function rtime () { "FROM fleet WHERE planet_id=$Planetid ". "AND num=$number_of_fleets AND target_id!=0"; - $res = mysql_query ($q, $db); + $res = mysqli_query ($db, $q ); - if ($res && mysql_num_rows($res) > 0) { + if ($res && mysqli_num_rows($res) > 0) { - $row = mysql_fetch_row($res); + $row = mysqli_fetch_row($res); // find num units, target_xy_z $rowt = get_coord_name ($row[0]); diff --git a/online/motd.php b/online/motd.php index 98fe61d..e6eafaa 100644 --- a/online/motd.php +++ b/online/motd.php @@ -2,7 +2,7 @@ /* * MyPHPpa - * Copyright (C) 2003 Jens Beyer + * Copyright (C) 2003, 2007 Jens Beyer * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -22,9 +22,8 @@ ?>
-Please read the Announcement.
-

-Hope you had fun :-) +
+Have fun :-)


diff --git a/online/mpa.css b/online/mpa.css index 20a0a01..3a0e74d 100644 --- a/online/mpa.css +++ b/online/mpa.css @@ -1,6 +1,6 @@
Missile Attack
Group