Merge pull request #34 from foin137/phpversionupdate

Ready for php 8.1, fix bug [#31]

Handle mysql errors [#33]
Include option to disable new game creation
Include license in every file
This commit is contained in:
foin137
2023-11-05 16:14:17 +01:00
committed by GitHub
7 changed files with 366 additions and 163 deletions

View File

@@ -1,3 +1,26 @@
<?php
/*
werwolfonline, a php web game
Copyright (C) 2023
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
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
?>
<!DOCTYPE html>
<HTML>
<head>
@@ -143,8 +166,14 @@ p#liste {
else
{
//Schauen, ob es auch einen Eintrag zu diesem Spiel in der Datenbank gibt...
$alleres = $mysqli->Query("SELECT * FROM $spielID"."_spieler");
if(isset($alleres->num_rows))
$spiel_existiert = True;
try{
$alleres = $mysqli->Query("SELECT * FROM $spielID"."_spieler");
}
catch (Exception $e) {
$spiel_existiert = False;
}
if($spiel_existiert && isset($alleres->num_rows))
{
//Schauen, ob es auch mich als Spieler gibt und meine verifizierungsnr stimmt
$spielerResult = $mysqli->Query("SELECT * FROM $spielID"."_spieler WHERE id = $eigeneID AND verifizierungsnr = ".(int)$_COOKIE['verifizierungsnr']);
@@ -1457,8 +1486,16 @@ p#liste {
if (isset($_POST['neuesSpiel']))
{
//Starten wir ein neues Spiel
$mysqli->Query("UPDATE $spielID"."_game SET spielphase = ".PHASESETUP);
$mysqli->Query("UPDATE $spielID"."_spieler SET reload = 1");
if (_NOGAMECREATIONERRORMESSAGE == "")
{
$mysqli->Query("UPDATE $spielID"."_game SET spielphase = ".PHASESETUP);
$mysqli->Query("UPDATE $spielID"."_spieler SET reload = 1");
}
else
{
//Spiel darf nicht erstellt werden, da _NOGAMECREATIONERRORMESSAGE existiert
echo "<p class='error' >Spiel darf nicht erstellt werden: ". _NOGAMECREATIONERRORMESSAGE ."</p>";
}
}
echo "<form action='Werwolf.php' method='post'>
<input type='hidden' name='neuesSpiel' value=1 />
@@ -1503,123 +1540,138 @@ p#liste {
if (rand(1,100)==50)
loescheAlteSpiele($mysqli);
//Wir erstellen ein neues Spiel
//Eine Schleife, die solange rennt, bis eine neue Zahl gefunden wurde
for ($i = 1; $i <= 100000; $i++)
if (_NOGAMECREATIONERRORMESSAGE == "") //Wir dürfen nur ein neues Spiel erstellen, falls diese message auf "" steht
{
if ($i == 1000)
//Eine Schleife, die solange rennt, bis eine neue Zahl gefunden wurde
for ($i = 1; $i <= 100000; $i++)
{
if ($i == 1000)
{
//Vielleicht gibt es alte Spiele, die Platz verbrauchen
loescheAlteSpiele($mysqli);
}
$spielID = rand(10000,99999);
//nachschauen, ob ein Spiel mit dieser Nummer bereits existiert
$existiert = False;
try {
$res = $mysqli->Query("SELECT * FROM $spielID"."_spieler");
}
catch (mysqli_sql_exception $e){
$existiert = True;
}
if(!$existiert && isset($res->num_rows)){
//Tabelle existiert
}else{
//Tabelle existiert noch nicht
//erstellen wir eine neue Tabelle
//BEIM HINZUFÜGEN: Auch die SetSpielerDefaultFunction ändern
$sql = "
CREATE TABLE `$spielID"."_spieler" ."` (
`id` INT( 10 ) NULL,
`name` VARCHAR( 150 ) NOT NULL ,
`spielleiter` INT( 5 ) NULL ,
`lebt` INT (2) NULL,
`wahlAuf` INT ( 5 ) DEFAULT -1 ,
`angeklagtVon` INT ( 5 ) DEFAULT -1 ,
`nachtIdentitaet` INT( 10 ) NULL,
`buergermeister` INT ( 2 ) DEFAULT 0,
`hexeHeiltraenke` INT( 10 ) NULL,
`hexeTodestraenke` INT( 5 ) NULL ,
`hexenOpfer` INT ( 5 ) DEFAULT -1 ,
`hexeHeilt` INT (2) DEFAULT 0,
`beschuetzerLetzteRundeBeschuetzt` INT( 5 ) DEFAULT -1 ,
`parErmEingesetzt` INT (2) DEFAULT 0 ,
`verliebtMit` INT ( 5 ) DEFAULT -1 ,
`jaegerDarfSchiessen` INT (2) DEFAULT 0 ,
`buergermeisterDarfWeitergeben` INT (2) DEFAULT 0 ,
`urwolf_anzahl_faehigkeiten` INT ( 5 ) DEFAULT 0,
`dieseNachtGestorben` INT (2) DEFAULT 0 ,
`countdownBis` INT (10) DEFAULT 0 ,
`countdownAb` INT (10) DEFAULT 0 ,
`playerlog` LONGTEXT ,
`popup_text` TEXT ,
`bereit` INT (2) NULL ,
`reload` INT (2) NULL ,
`verifizierungsnr` INT ( 5 ) DEFAULT 0
) ;
";
$mysqli->Query($sql);
//Wähle ein Verifizierungs-Passwort aus:
//Dieses dient dazu, um festzustellen, ob es tatsächlich der richtige Spieler ist, der eine Seite lädt
$verifizierungsnr = rand(2,100000);
$stmt = $mysqli->prepare("INSERT INTO $spielID"."_spieler"." (id, name , spielleiter, lebt, reload, verifizierungsnr) VALUES ( 0 , ?, 1 , 0 , 1, ?)");
$stmt->bind_param('si',$_POST['ihrName'],$verifizierungsnr);
$stmt->execute();
$stmt->close();
$sql2 = "
CREATE TABLE `$spielID"."_game` (
`spielphase` INT( 5 ) DEFAULT 0,
`charaktereAufdecken` INT ( 2 ) DEFAULT 0,
`buergermeisterWeitergeben` INT ( 2 ) DEFAULT 0,
`seherSiehtIdentitaet` INT ( 2 ) DEFAULT 1,
`werwolfzahl` INT ( 5 ) DEFAULT 0 ,
`hexenzahl` INT ( 5 ) DEFAULT 0 ,
`seherzahl` INT ( 5 ) DEFAULT 0 ,
`jaegerzahl` INT ( 5 ) DEFAULT 0 ,
`amorzahl` INT ( 2 ) DEFAULT 0 ,
`beschuetzerzahl` INT ( 5 ) DEFAULT 0 ,
`parErmZahl` INT (5) DEFAULT 0 ,
`lykantrophenzahl` INT ( 5 ) DEFAULT 0 ,
`spionezahl` INT ( 5 ) DEFAULT 0 ,
`idiotenzahl` INT ( 5 ) DEFAULT 0 ,
`pazifistenzahl` INT ( 5 ) DEFAULT 0 ,
`altenzahl` INT ( 5 ) DEFAULT 0 ,
`urwolfzahl` INT ( 5 ) DEFAULT 0 ,
`zufaelligeAuswahl` INT ( 2 ) DEFAULT 0 ,
`zufaelligeAuswahlBonus` INT ( 5 ) DEFAULT 0 ,
`werwolfeinstimmig` INT ( 2 ) DEFAULT 1 ,
`werwolfopfer` INT ( 5 ) DEFAULT -1 ,
`werwolftimer1` INT ( 10 ) DEFAULT 60 ,
`werwolfzusatz1` INT ( 10 ) DEFAULT 4 ,
`werwolftimer2` INT ( 10 ) DEFAULT 50 ,
`werwolfzusatz2` INT ( 10 ) DEFAULT 3 ,
`dorftimer` INT ( 10 ) DEFAULT 550 ,
`dorfzusatz` INT ( 10 ) DEFAULT 10 ,
`dorfstichwahltimer` INT ( 10 ) DEFAULT 200 ,
`dorfstichwahlzusatz` INT ( 10 ) DEFAULT 5 ,
`inaktivzeit` INT ( 10 ) DEFAULT 40 ,
`inaktivzeitzusatz` INT ( 10 ) DEFAULT 0 ,
`tagestext` TEXT ,
`nacht` INT ( 5 ) DEFAULT 1 ,
`log` LONGTEXT ,
`list_lebe` LONGTEXT,
`list_lebe_aktualisiert` BIGINT DEFAULT 0,
`list_tot` LONGTEXT,
`list_tot_aktualisiert` BIGINT DEFAULT 0,
`waiting_for_others_time` BIGINT,
`letzterAufruf` BIGINT
) ;";
$mysqli->Query($sql2);
$mysqli->Query("INSERT INTO $spielID"."_game (spielphase, letzterAufruf) VALUES (0 , ".time().")");
//Die SpielID groß mitteilen
echo "<BR><h1 align = 'center'>$spielID</h1><BR>Mit dieser Zahl können andere deinem Spiel beitreten!";
//Die eigene SpielID setzen
setcookie ("SpielID", $spielID, time()+172800); //Dauer 2 Tage, länger sollte ein Spiel nicht dauern ;)
setcookie ("eigeneID",0, time()+172800);
setcookie ("verifizierungsnr",$verifizierungsnr, time()+172800);
$_COOKIE["SpielID"]=$spielID;
$_COOKIE["eigeneID"] = 0;
$_COOKIE["verifizieren"] = $verifizierungsnr;
writeGameToLogSpielErstellen($mysqli,$spielID,$_POST['ihrName']);
break; //die Schleife beenden
}
}
$pageReload = true;
}
else
{
//Vielleicht gibt es alte Spiele, die Platz verbrauchen
loescheAlteSpiele($mysqli);
//Spiel darf nicht erstellt werden, da _NOGAMECREATIONERRORMESSAGE existiert
echo "<p class='error' >Spiel darf nicht erstellt werden: ". _NOGAMECREATIONERRORMESSAGE ."</p>";
}
$spielID = rand(10000,99999);
//nachschauen, ob ein Spiel mit dieser Nummer bereits existiert
$res = $mysqli->Query("SELECT * FROM $spielID"."_spieler");
if(isset($res->num_rows)){
//Tabelle existiert
}else{
//Tabelle existiert noch nicht
//erstellen wir eine neue Tabelle
//BEIM HINZUFÜGEN: Auch die SetSpielerDefaultFunction ändern
$sql = "
CREATE TABLE `$spielID"."_spieler" ."` (
`id` INT( 10 ) NULL,
`name` VARCHAR( 150 ) NOT NULL ,
`spielleiter` INT( 5 ) NULL ,
`lebt` INT (2) NULL,
`wahlAuf` INT ( 5 ) DEFAULT -1 ,
`angeklagtVon` INT ( 5 ) DEFAULT -1 ,
`nachtIdentitaet` INT( 10 ) NULL,
`buergermeister` INT ( 2 ) DEFAULT 0,
`hexeHeiltraenke` INT( 10 ) NULL,
`hexeTodestraenke` INT( 5 ) NULL ,
`hexenOpfer` INT ( 5 ) DEFAULT -1 ,
`hexeHeilt` INT (2) DEFAULT 0,
`beschuetzerLetzteRundeBeschuetzt` INT( 5 ) DEFAULT -1 ,
`parErmEingesetzt` INT (2) DEFAULT 0 ,
`verliebtMit` INT ( 5 ) DEFAULT -1 ,
`jaegerDarfSchiessen` INT (2) DEFAULT 0 ,
`buergermeisterDarfWeitergeben` INT (2) DEFAULT 0 ,
`urwolf_anzahl_faehigkeiten` INT ( 5 ) DEFAULT 0,
`dieseNachtGestorben` INT (2) DEFAULT 0 ,
`countdownBis` INT (10) DEFAULT 0 ,
`countdownAb` INT (10) DEFAULT 0 ,
`playerlog` LONGTEXT ,
`popup_text` TEXT ,
`bereit` INT (2) NULL ,
`reload` INT (2) NULL ,
`verifizierungsnr` INT ( 5 ) DEFAULT 0
) ;
";
$mysqli->Query($sql);
//Wähle ein Verifizierungs-Passwort aus:
//Dieses dient dazu, um festzustellen, ob es tatsächlich der richtige Spieler ist, der eine Seite lädt
$verifizierungsnr = rand(2,100000);
$stmt = $mysqli->prepare("INSERT INTO $spielID"."_spieler"." (id, name , spielleiter, lebt, reload, verifizierungsnr) VALUES ( 0 , ?, 1 , 0 , 1, ?)");
$stmt->bind_param('si',$_POST['ihrName'],$verifizierungsnr);
$stmt->execute();
$stmt->close();
$sql2 = "
CREATE TABLE `$spielID"."_game` (
`spielphase` INT( 5 ) DEFAULT 0,
`charaktereAufdecken` INT ( 2 ) DEFAULT 0,
`buergermeisterWeitergeben` INT ( 2 ) DEFAULT 0,
`seherSiehtIdentitaet` INT ( 2 ) DEFAULT 1,
`werwolfzahl` INT ( 5 ) DEFAULT 0 ,
`hexenzahl` INT ( 5 ) DEFAULT 0 ,
`seherzahl` INT ( 5 ) DEFAULT 0 ,
`jaegerzahl` INT ( 5 ) DEFAULT 0 ,
`amorzahl` INT ( 2 ) DEFAULT 0 ,
`beschuetzerzahl` INT ( 5 ) DEFAULT 0 ,
`parErmZahl` INT (5) DEFAULT 0 ,
`lykantrophenzahl` INT ( 5 ) DEFAULT 0 ,
`spionezahl` INT ( 5 ) DEFAULT 0 ,
`idiotenzahl` INT ( 5 ) DEFAULT 0 ,
`pazifistenzahl` INT ( 5 ) DEFAULT 0 ,
`altenzahl` INT ( 5 ) DEFAULT 0 ,
`urwolfzahl` INT ( 5 ) DEFAULT 0 ,
`zufaelligeAuswahl` INT ( 2 ) DEFAULT 0 ,
`zufaelligeAuswahlBonus` INT ( 5 ) DEFAULT 0 ,
`werwolfeinstimmig` INT ( 2 ) DEFAULT 1 ,
`werwolfopfer` INT ( 5 ) DEFAULT -1 ,
`werwolftimer1` INT ( 10 ) DEFAULT 60 ,
`werwolfzusatz1` INT ( 10 ) DEFAULT 4 ,
`werwolftimer2` INT ( 10 ) DEFAULT 50 ,
`werwolfzusatz2` INT ( 10 ) DEFAULT 3 ,
`dorftimer` INT ( 10 ) DEFAULT 550 ,
`dorfzusatz` INT ( 10 ) DEFAULT 10 ,
`dorfstichwahltimer` INT ( 10 ) DEFAULT 200 ,
`dorfstichwahlzusatz` INT ( 10 ) DEFAULT 5 ,
`inaktivzeit` INT ( 10 ) DEFAULT 40 ,
`inaktivzeitzusatz` INT ( 10 ) DEFAULT 0 ,
`tagestext` TEXT ,
`nacht` INT ( 5 ) DEFAULT 1 ,
`log` LONGTEXT ,
`list_lebe` LONGTEXT,
`list_lebe_aktualisiert` BIGINT DEFAULT 0,
`list_tot` LONGTEXT,
`list_tot_aktualisiert` BIGINT DEFAULT 0,
`waiting_for_others_time` BIGINT,
`letzterAufruf` BIGINT
) ;";
$mysqli->Query($sql2);
$mysqli->Query("INSERT INTO $spielID"."_game (spielphase, letzterAufruf) VALUES (0 , ".time().")");
//Die SpielID groß mitteilen
echo "<BR><h1 align = 'center'>$spielID</h1><BR>Mit dieser Zahl können andere deinem Spiel beitreten!";
//Die eigene SpielID setzen
setcookie ("SpielID", $spielID, time()+172800); //Dauer 2 Tage, länger sollte ein Spiel nicht dauern ;)
setcookie ("eigeneID",0, time()+172800);
setcookie ("verifizierungsnr",$verifizierungsnr, time()+172800);
$_COOKIE["SpielID"]=$spielID;
$_COOKIE["eigeneID"] = 0;
$_COOKIE["verifizieren"] = $verifizierungsnr;
writeGameToLogSpielErstellen($mysqli,$spielID,$_POST['ihrName']);
break; //die Schleife beenden
}
}
$pageReload = true;
}
else
{
@@ -1635,8 +1687,14 @@ p#liste {
if ($_POST['ihrName'] != "" && strpos($_POST['ihrName'],"$")===false && strpos($_POST['ihrName'],";")===false && strpos($_POST['ihrName'],'"')===false && strpos($_POST['ihrName'],"'")===false && strpos($_POST['ihrName'],"=")===false)
{
//Name wurde eingegeben. Existiert auch ein Spiel dieser Nummer?
$res = $mysqli->Query("SELECT * FROM $spielID"."_spieler");
if(isset($res->num_rows))
$existiert = False;
try{
$res = $mysqli->Query("SELECT * FROM $spielID"."_spieler");
}
catch(mysqli_sql_exception $e){
$existiert = True;
}
if(!$existiert && isset($res->num_rows))
{
//Ein Spiel dieser Nummer existiert!
$verboteneNamen = array("niemanden","niemand","keinen","keiner","dorfbewohner","werwolf","seher","seherin","hexe","hexer","jäger","amor","beschützer","paranormaler ermittler","lykantroph","lykantrophin","spion","spionin","mordlustiger","mordlustige","pazifist","pazifistin","alter mann","alter","alte","alte frau","die alten","alten");
@@ -1645,6 +1703,7 @@ p#liste {
$stmt->bind_param('s',$_POST['ihrName']);
$stmt->execute();
$nameRes = $stmt->get_result();
$stmt->close();
if ($nameRes->num_rows <= 0 && !in_array(strtolower($_POST['ihrName']),$verboteneNamen))
{
//Name gültig
@@ -1696,7 +1755,6 @@ p#liste {
{
echo "<p class='error' >Der angegebene Name ist bereits vorhanden oder ungültig</p>";
}
$stmt->close();
}
else
{

View File

@@ -1,5 +1,25 @@
<?php
/*
werwolfonline, a php web game
Copyright (C) 2023
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
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
include "includes/includes.php";
header("Content-Type: text/html; charset=utf-8");
header('Cache-Control: no-cache, no-store, max-age=0, must-revalidate');

View File

@@ -1,9 +1,37 @@
<?php
//Constants
define("_VERSION","v1.2.7");
/*
werwolfonline, a php web game
Copyright (C) 2023
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
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
//Settings:
define ("_NOGAMECREATIONERRORMESSAGE", ""); //Falls nicht "": Kein Spiel kann erstellt werden, stattdessen wird der string angezeigt.
//define ("_NOGAMECREATIONERRORMESSAGE", "Wartungsarbeiten bis ..."); //Falls nicht "": Kein Spiel kann erstellt werden, stattdessen wird der string angezeigt.
define("_LISTMAXRELOADTIME",3000);
define("_MAXPLAYERS",50);
///////////////////////////////////
// Constants, do not change!
///////////////////////////////////
define("_VERSION","v1.2.8");
//Phasen
define ("PHASESETUP",0);
define ("PHASESPIELSETUP",1);

View File

@@ -1,4 +1,25 @@
<?php
/*
werwolfonline, a php web game
Copyright (C) 2023
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
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
function start()
{
//Diese Funktion zeigt das Startformular an, bei dem der Nutzer aufgefordert wird, ein Spiel zu erstellen, oder eine ID einzugeben
@@ -30,8 +51,14 @@ function loescheAlteSpiele($mysqli)
for ($i = 10000; $i<= 99999; $i++)
{
$alleres = $mysqli ->Query("SELECT * FROM $i"."_game");
if(isset($alleres->num_rows))
$existiert = True;
try{
$alleres = $mysqli ->Query("SELECT * FROM $i"."_game");
}
catch (mysqli_sql_exception $e){
$existiert = False;
}
if($existiert && isset($alleres->num_rows))
{
$temp = $alleres->fetch_assoc();
if ($temp['letzterAufruf'] < $zeitpunkt)
@@ -1658,41 +1685,45 @@ function writeGameToLog($mysqli)
$spielID = $_COOKIE['SpielID'];
$fileName = "log/Werwolf_log_".date("Y_m").".log";
$myfile = fopen($fileName, "a");
fwrite($myfile,"\n--- SPIEL BEENDET --- \n");
fwrite($myfile,"SpielID: $spielID \n");
fwrite($myfile,"SpielEnde: ".date("d.m.Y, H:i:s")."\n");
//Alle Spieler hineinschreiben:
fwrite($myfile,"Spieler:\n");
$playerQ = $mysqli->Query("SELECT * FROM $spielID"."_spieler");
while ($temp = $playerQ->fetch_assoc())
{
fwrite($myfile,$temp['name']."\n");
}
fwrite($myfile,"Spielverlauf:\n");
$gameAssoc = gameAssoc($mysqli);
$mitUmbruch = str_replace("<br>","\n",$gameAssoc['log']);
fwrite($myfile,$mitUmbruch);
if ($myfile){
fwrite($myfile,"\n--- SPIEL BEENDET --- \n");
fwrite($myfile,"SpielID: $spielID \n");
fwrite($myfile,"SpielEnde: ".date("d.m.Y, H:i:s")."\n");
//Alle Spieler hineinschreiben:
fwrite($myfile,"Spieler:\n");
$playerQ = $mysqli->Query("SELECT * FROM $spielID"."_spieler");
while ($temp = $playerQ->fetch_assoc())
{
fwrite($myfile,$temp['name']."\n");
}
fwrite($myfile,"Spielverlauf:\n");
$gameAssoc = gameAssoc($mysqli);
$mitUmbruch = str_replace("<br>","\n",$gameAssoc['log']);
fwrite($myfile,$mitUmbruch);
//Schreibe noch die Überlebenden
fwrite($myfile,"Die Überlebenden:\n");
$lebendQuery = $mysqli->Query("SELECT * FROM $spielID"."_spieler WHERE lebt = 1");
while ($temp = $lebendQuery->fetch_assoc())
{
fwrite($myfile,$temp['name']."(".nachtidentitaetAlsString($temp['nachtIdentitaet'],$mysqli).")\n");
//Schreibe noch die Überlebenden
fwrite($myfile,"Die Überlebenden:\n");
$lebendQuery = $mysqli->Query("SELECT * FROM $spielID"."_spieler WHERE lebt = 1");
while ($temp = $lebendQuery->fetch_assoc())
{
fwrite($myfile,$temp['name']."(".nachtidentitaetAlsString($temp['nachtIdentitaet'],$mysqli).")\n");
}
fwrite($myfile,"--- ENDE DES SPIELLOGS ---\n");
fclose($myfile);
}
fwrite($myfile,"--- ENDE DES SPIELLOGS ---\n");
fclose($myfile);
}
function writeGameToLogSpielErstellen($mysqli, $spielID, $name)
{
$fileName = "log/Werwolf_log_".date("Y_m").".log";
$myfile = fopen($fileName, "a");
fwrite($myfile,"\n--- NEUES SPIEL ERSTELLT --- \n");
fwrite($myfile,"SpielID: $spielID \n");
fwrite($myfile,"Zeit: ".date("d.m.Y, H:i:s")."\n");
fwrite($myfile,"Name des Erstellers: $name \n");
fclose($myfile);
if ($myfile){
fwrite($myfile,"\n--- NEUES SPIEL ERSTELLT --- \n");
fwrite($myfile,"SpielID: $spielID \n");
fwrite($myfile,"Zeit: ".date("d.m.Y, H:i:s")."\n");
fwrite($myfile,"Name des Erstellers: $name \n");
fclose($myfile);
}
}
function checkeSiegbedingungen($mysqli)
@@ -1813,11 +1844,13 @@ function setBereit($mysqli,$spielerID,$bereit)
function gameAssoc($mysqli)
{
$spielID = $_COOKIE['SpielID'];
if ($gameRes = $mysqli->Query("SELECT * FROM $spielID"."_game"))
{
$gameA = $gameRes->fetch_assoc();
return $gameA;
}
try{
if ($gameRes = $mysqli->Query("SELECT * FROM $spielID"."_game"))
{
$gameA = $gameRes->fetch_assoc();
return $gameA;
}
}catch(mysqli_sql_exception $e) {}
return false;
}
@@ -1835,11 +1868,13 @@ function getName($mysqli, $spielerID)
//Gibt den Namen des Spielers mit der $spielerID zurück
$spielID = $_COOKIE['SpielID'];
$spielerID = (int)$spielerID;
if ($res = $mysqli->Query("SELECT * FROM $spielID"."_spieler WHERE id = $spielerID"))
{
$temp = $res->fetch_assoc();
return $temp['name'];
}
try{
if ($res = $mysqli->Query("SELECT * FROM $spielID"."_spieler WHERE id = $spielerID"))
{
$temp = $res->fetch_assoc();
return $temp['name'];
}
} catch(mysqli_sql_exception $e) {}
return "Unknown";
}

View File

@@ -1,5 +1,26 @@
<?php
$id = "id"; // Ihre ID zum MySQL Server
/*
werwolfonline, a php web game
Copyright (C) 2023
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
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
$id = "id"; // Ihre ID (username) zum MySQL Server
$pw = "pw"; // Passwort zum MySQL Server
$host = "localhost"; // Host ("localhost" oder "IP-Adresse")
$db = "werwolf"; // Name Ihrer Datenbank

View File

@@ -1,5 +1,25 @@
<?php
/*
werwolfonline, a php web game
Copyright (C) 2023
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
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
include "includes/includes.php";
include "includes/constants.php";
header("Content-Type: text/html; charset=utf-8");

View File

@@ -1,4 +1,25 @@
<?php
/*
werwolfonline, a php web game
Copyright (C) 2023
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
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
header("Content-Type: text/html; charset=utf-8");
header('Cache-Control: no-cache, no-store, max-age=0, must-revalidate');
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); // Date in the past