Compare commits

...

6 Commits

Author SHA1 Message Date
foin137
d1c4b59a43 Better display settings 2023-11-05 16:23:51 +01:00
foin137
9ee2148d9a 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
2023-11-05 16:14:17 +01:00
foin137
a45bd3c642 Update version 2023-11-05 16:08:17 +01:00
foin137
30fea14c07 Include license statement 2023-11-05 16:07:41 +01:00
foin137
2bf710e215 Possibility to disable new games
Include possibility to disable new games by changing a constant in constants.php
2023-11-05 16:02:36 +01:00
foin137
93b38cfc47 Handle mysqli errors
- Handle mysql errors that are no longer silenced per default for new php versions
- Handled error when log file cannot be created
2023-11-05 15:44:24 +01:00
7 changed files with 377 additions and 174 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.9");
//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)
@@ -251,25 +278,25 @@ function spielRegeln($mysqli)
auswahl.werwoelfe.disabled = false;auswahl.werwolfbutton1.disabled=false; auswahl.werwolfbutton2.disabled=false;}'><label for='zufaelligauswaehlenID'> Die Charaktere verdeckt und zufällig auswählen </label></span>
<p class='normal' >Geben Sie dazu eine maximale Anzahl von Charakteren ein, die vorkommen sollen, bei Werwölfen müssen sie nichts eingeben<br>
Zusätzlich können Sie noch einen Wert eingeben, der die Verteilung bestimmt. Ein positiver Wert erleichtert das Spiel für die Dorfbewohner, ein negativer für die Werwölfe (nur bei der zufälligen Charakterverteilung)</p>";
echo "<span class='normal' ><label for='zufaelligeAuswahlBonusID'> Verteilung der zufälligen Charaktere </label><INPUT TYPE='number' NAME='zufaelligeAuswahlBonus' id='zufaelligeAuswahlBonusID' Size='2' value=$zufaelligeAuswahlBonus MIN=-15 MAX=15></span>";
echo "<span class='normal' ><label for='zufaelligeAuswahlBonusID'> Verteilung der zufälligen Charaktere </label><INPUT TYPE='number' NAME='zufaelligeAuswahlBonus' id='zufaelligeAuswahlBonusID' Size='4' value=$zufaelligeAuswahlBonus MIN=-15 MAX=15></span>";
echo "</div>";
echo "<div><h3 >Countdown-Einstellungen</h3>";
echo "<span class='normal' ><INPUT TYPE='button' VALUE='Countdowns zurücksetzen' OnClick='auswahl.werwolftimer1.value=60; auswahl.werwolfzusatz1.value=4; auswahl.werwolftimer2.value=50; auswahl.werwolfzusatz2.value=3; auswahl.dorftimer.value=550; auswahl.dorfzusatz.value=10; auswahl.dorfstichwahltimer.value=200; auswahl.dorfstichwahlzusatz.value=5'></span>";
echo "<span class='normal' ><label for='werwolftimer1ID'>Sekunden, bis die Werwölfe nicht mehr einstimmig wählen müssen: </label>
<INPUT TYPE='number' NAME='werwolftimer1' id='werwolftimer1ID' SIZE='2' VALUE=$werwolftimer1 MIN='20' MAX='500'><br>
<label for='werwolfzusatz1ID'>Zusätzliche Zeit pro Werwolf: </label><INPUT TYPE='number' NAME='werwolfzusatz1' id='werwolfzusatz1ID' SIZE='2' VALUE=$werwolfzusatz1 MIN='0' MAX='60'></span>";
<INPUT TYPE='number' NAME='werwolftimer1' id='werwolftimer1ID' SIZE='4' VALUE=$werwolftimer1 MIN='20' MAX='500'><br>
<label for='werwolfzusatz1ID'>Zusätzliche Zeit pro Werwolf: </label><INPUT TYPE='number' NAME='werwolfzusatz1' id='werwolfzusatz1ID' SIZE='4' VALUE=$werwolfzusatz1 MIN='0' MAX='60'></span>";
echo "<span class='normal' ><label for='werwolftimer2ID'>Sekunden, bis nach Ablaufen der Einstimmigkeit die Wahl der Werwölfe erfolglos ist: </label>
<INPUT TYPE='number' NAME='werwolftimer2' id='werwolftimer2ID' SIZE='2' VALUE=$werwolftimer2 MIN='10' MAX='500'><br>
<label for='werwolfzusatz2ID'>Zusätzliche Zeit pro Werwolf: </label><INPUT TYPE='number' NAME='werwolfzusatz2' id='werwolfzusatz2ID' SIZE='2' VALUE=$werwolfzusatz2 MIN='0' MAX='60'></span>";
<INPUT TYPE='number' NAME='werwolftimer2' id='werwolftimer2ID' SIZE='4' VALUE=$werwolftimer2 MIN='10' MAX='500'><br>
<label for='werwolfzusatz2ID'>Zusätzliche Zeit pro Werwolf: </label><INPUT TYPE='number' NAME='werwolfzusatz2' id='werwolfzusatz2ID' SIZE='4' VALUE=$werwolfzusatz2 MIN='0' MAX='60'></span>";
echo "<span class='normal' ><label for='dorftimerID'>Sekunden, bis die normale Abstimmung des Dorfes am Tag erfolglos ist: </label>
<INPUT TYPE='number' NAME='dorftimer' id='dorftimerID' SIZE='2' VALUE=$dorftimer MIN='60' MAX='7200'><br>
<label for='dorfzusatzID'>Zusätzliche Zeit pro Dorfbewohner: </label><INPUT TYPE='number' NAME='dorfzusatz' id='dorfzusatzID' SIZE='2' VALUE=$dorfzusatz MIN='0' MAX='300'></span>";
<INPUT TYPE='number' NAME='dorftimer' id='dorftimerID' SIZE='4' VALUE=$dorftimer MIN='60' MAX='7200'><br>
<label for='dorfzusatzID'>Zusätzliche Zeit pro Dorfbewohner: </label><INPUT TYPE='number' NAME='dorfzusatz' id='dorfzusatzID' SIZE='4' VALUE=$dorfzusatz MIN='0' MAX='300'></span>";
echo "<span class='normal' ><label for='dorfstichwahltimerID'>Sekunden, bis die Stichwahl am Tag erfolglos ist: </label>
<INPUT TYPE='number' NAME='dorfstichwahltimer' id='dorfstichwahltimerID' SIZE='2' VALUE=$dorfstichwahltimer MIN='30' MAX='3600'><br>
<label for='dorfstichwahlzusatzID'>Zusätzliche Zeit pro Dorfbewohner: </label><INPUT TYPE='number' NAME='dorfstichwahlzusatz' id='dorfstichwahlzusatzID' SIZE='2' VALUE=$dorfstichwahlzusatz MIN='0' MAX='300'></span>";
<INPUT TYPE='number' NAME='dorfstichwahltimer' id='dorfstichwahltimerID' SIZE='4' VALUE=$dorfstichwahltimer MIN='30' MAX='3600'><br>
<label for='dorfstichwahlzusatzID'>Zusätzliche Zeit pro Dorfbewohner: </label><INPUT TYPE='number' NAME='dorfstichwahlzusatz' id='dorfstichwahlzusatzID' SIZE='4' VALUE=$dorfstichwahlzusatz MIN='0' MAX='300'></span>";
echo "<span class='normal' ><label for='inaktivzeitID'>Sekunden, nach denen angezeigt wird, auf wen noch gewartet wird: </label>
<INPUT TYPE='number' NAME='inaktivzeit' id='inaktivzeitID' SIZE='2' VALUE=$inaktivzeit MIN='20' MAX='3600'><br>
<label for='inaktivzeitzusatzID'>Zusätzliche Zeit pro Spieler: </label><INPUT TYPE='number' NAME='inaktivzeitzusatz' id='inaktivzeitzusatzID' SIZE='2' VALUE=$inaktivzeitzusatz MIN='0' MAX='300'></span>";
<INPUT TYPE='number' NAME='inaktivzeit' id='inaktivzeitID' SIZE='4' VALUE=$inaktivzeit MIN='20' MAX='3600'><br>
<label for='inaktivzeitzusatzID'>Zusätzliche Zeit pro Spieler: </label><INPUT TYPE='number' NAME='inaktivzeitzusatz' id='inaktivzeitzusatzID' SIZE='4' VALUE=$inaktivzeitzusatz MIN='0' MAX='300'></span>";
echo "</div><span align = 'center'><input type='submit' value = 'Speichern'/></span>";
echo "</form>";
}
@@ -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