mirror of
https://github.com/foin137/werwolfonline.eu.git
synced 2025-12-28 19:21:22 +00:00
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:
300
Werwolf.php
300
Werwolf.php
@@ -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>
|
<!DOCTYPE html>
|
||||||
<HTML>
|
<HTML>
|
||||||
<head>
|
<head>
|
||||||
@@ -143,8 +166,14 @@ p#liste {
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
//Schauen, ob es auch einen Eintrag zu diesem Spiel in der Datenbank gibt...
|
//Schauen, ob es auch einen Eintrag zu diesem Spiel in der Datenbank gibt...
|
||||||
$alleres = $mysqli->Query("SELECT * FROM $spielID"."_spieler");
|
$spiel_existiert = True;
|
||||||
if(isset($alleres->num_rows))
|
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
|
//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']);
|
$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']))
|
if (isset($_POST['neuesSpiel']))
|
||||||
{
|
{
|
||||||
//Starten wir ein neues Spiel
|
//Starten wir ein neues Spiel
|
||||||
$mysqli->Query("UPDATE $spielID"."_game SET spielphase = ".PHASESETUP);
|
if (_NOGAMECREATIONERRORMESSAGE == "")
|
||||||
$mysqli->Query("UPDATE $spielID"."_spieler SET reload = 1");
|
{
|
||||||
|
$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'>
|
echo "<form action='Werwolf.php' method='post'>
|
||||||
<input type='hidden' name='neuesSpiel' value=1 />
|
<input type='hidden' name='neuesSpiel' value=1 />
|
||||||
@@ -1503,123 +1540,138 @@ p#liste {
|
|||||||
if (rand(1,100)==50)
|
if (rand(1,100)==50)
|
||||||
loescheAlteSpiele($mysqli);
|
loescheAlteSpiele($mysqli);
|
||||||
//Wir erstellen ein neues Spiel
|
//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
|
//Spiel darf nicht erstellt werden, da _NOGAMECREATIONERRORMESSAGE existiert
|
||||||
loescheAlteSpiele($mysqli);
|
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
|
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)
|
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?
|
//Name wurde eingegeben. Existiert auch ein Spiel dieser Nummer?
|
||||||
$res = $mysqli->Query("SELECT * FROM $spielID"."_spieler");
|
$existiert = False;
|
||||||
if(isset($res->num_rows))
|
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!
|
//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");
|
$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->bind_param('s',$_POST['ihrName']);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
$nameRes = $stmt->get_result();
|
$nameRes = $stmt->get_result();
|
||||||
|
$stmt->close();
|
||||||
if ($nameRes->num_rows <= 0 && !in_array(strtolower($_POST['ihrName']),$verboteneNamen))
|
if ($nameRes->num_rows <= 0 && !in_array(strtolower($_POST['ihrName']),$verboteneNamen))
|
||||||
{
|
{
|
||||||
//Name gültig
|
//Name gültig
|
||||||
@@ -1696,7 +1755,6 @@ p#liste {
|
|||||||
{
|
{
|
||||||
echo "<p class='error' >Der angegebene Name ist bereits vorhanden oder ungültig</p>";
|
echo "<p class='error' >Der angegebene Name ist bereits vorhanden oder ungültig</p>";
|
||||||
}
|
}
|
||||||
$stmt->close();
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,5 +1,25 @@
|
|||||||
<?php
|
<?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/includes.php";
|
||||||
header("Content-Type: text/html; charset=utf-8");
|
header("Content-Type: text/html; charset=utf-8");
|
||||||
header('Cache-Control: no-cache, no-store, max-age=0, must-revalidate');
|
header('Cache-Control: no-cache, no-store, max-age=0, must-revalidate');
|
||||||
|
|||||||
@@ -1,9 +1,37 @@
|
|||||||
<?php
|
<?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("_LISTMAXRELOADTIME",3000);
|
||||||
define("_MAXPLAYERS",50);
|
define("_MAXPLAYERS",50);
|
||||||
|
|
||||||
|
|
||||||
|
///////////////////////////////////
|
||||||
|
// Constants, do not change!
|
||||||
|
///////////////////////////////////
|
||||||
|
define("_VERSION","v1.2.8");
|
||||||
|
|
||||||
//Phasen
|
//Phasen
|
||||||
define ("PHASESETUP",0);
|
define ("PHASESETUP",0);
|
||||||
define ("PHASESPIELSETUP",1);
|
define ("PHASESPIELSETUP",1);
|
||||||
|
|||||||
@@ -1,4 +1,25 @@
|
|||||||
<?php
|
<?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()
|
function start()
|
||||||
{
|
{
|
||||||
//Diese Funktion zeigt das Startformular an, bei dem der Nutzer aufgefordert wird, ein Spiel zu erstellen, oder eine ID einzugeben
|
//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++)
|
for ($i = 10000; $i<= 99999; $i++)
|
||||||
{
|
{
|
||||||
$alleres = $mysqli ->Query("SELECT * FROM $i"."_game");
|
$existiert = True;
|
||||||
if(isset($alleres->num_rows))
|
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();
|
$temp = $alleres->fetch_assoc();
|
||||||
if ($temp['letzterAufruf'] < $zeitpunkt)
|
if ($temp['letzterAufruf'] < $zeitpunkt)
|
||||||
@@ -1658,41 +1685,45 @@ function writeGameToLog($mysqli)
|
|||||||
$spielID = $_COOKIE['SpielID'];
|
$spielID = $_COOKIE['SpielID'];
|
||||||
$fileName = "log/Werwolf_log_".date("Y_m").".log";
|
$fileName = "log/Werwolf_log_".date("Y_m").".log";
|
||||||
$myfile = fopen($fileName, "a");
|
$myfile = fopen($fileName, "a");
|
||||||
fwrite($myfile,"\n--- SPIEL BEENDET --- \n");
|
if ($myfile){
|
||||||
fwrite($myfile,"SpielID: $spielID \n");
|
fwrite($myfile,"\n--- SPIEL BEENDET --- \n");
|
||||||
fwrite($myfile,"SpielEnde: ".date("d.m.Y, H:i:s")."\n");
|
fwrite($myfile,"SpielID: $spielID \n");
|
||||||
//Alle Spieler hineinschreiben:
|
fwrite($myfile,"SpielEnde: ".date("d.m.Y, H:i:s")."\n");
|
||||||
fwrite($myfile,"Spieler:\n");
|
//Alle Spieler hineinschreiben:
|
||||||
$playerQ = $mysqli->Query("SELECT * FROM $spielID"."_spieler");
|
fwrite($myfile,"Spieler:\n");
|
||||||
while ($temp = $playerQ->fetch_assoc())
|
$playerQ = $mysqli->Query("SELECT * FROM $spielID"."_spieler");
|
||||||
{
|
while ($temp = $playerQ->fetch_assoc())
|
||||||
fwrite($myfile,$temp['name']."\n");
|
{
|
||||||
}
|
fwrite($myfile,$temp['name']."\n");
|
||||||
fwrite($myfile,"Spielverlauf:\n");
|
}
|
||||||
$gameAssoc = gameAssoc($mysqli);
|
fwrite($myfile,"Spielverlauf:\n");
|
||||||
$mitUmbruch = str_replace("<br>","\n",$gameAssoc['log']);
|
$gameAssoc = gameAssoc($mysqli);
|
||||||
fwrite($myfile,$mitUmbruch);
|
$mitUmbruch = str_replace("<br>","\n",$gameAssoc['log']);
|
||||||
|
fwrite($myfile,$mitUmbruch);
|
||||||
|
|
||||||
//Schreibe noch die Überlebenden
|
//Schreibe noch die Überlebenden
|
||||||
fwrite($myfile,"Die Überlebenden:\n");
|
fwrite($myfile,"Die Überlebenden:\n");
|
||||||
$lebendQuery = $mysqli->Query("SELECT * FROM $spielID"."_spieler WHERE lebt = 1");
|
$lebendQuery = $mysqli->Query("SELECT * FROM $spielID"."_spieler WHERE lebt = 1");
|
||||||
while ($temp = $lebendQuery->fetch_assoc())
|
while ($temp = $lebendQuery->fetch_assoc())
|
||||||
{
|
{
|
||||||
fwrite($myfile,$temp['name']."(".nachtidentitaetAlsString($temp['nachtIdentitaet'],$mysqli).")\n");
|
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)
|
function writeGameToLogSpielErstellen($mysqli, $spielID, $name)
|
||||||
{
|
{
|
||||||
$fileName = "log/Werwolf_log_".date("Y_m").".log";
|
$fileName = "log/Werwolf_log_".date("Y_m").".log";
|
||||||
$myfile = fopen($fileName, "a");
|
$myfile = fopen($fileName, "a");
|
||||||
fwrite($myfile,"\n--- NEUES SPIEL ERSTELLT --- \n");
|
if ($myfile){
|
||||||
fwrite($myfile,"SpielID: $spielID \n");
|
fwrite($myfile,"\n--- NEUES SPIEL ERSTELLT --- \n");
|
||||||
fwrite($myfile,"Zeit: ".date("d.m.Y, H:i:s")."\n");
|
fwrite($myfile,"SpielID: $spielID \n");
|
||||||
fwrite($myfile,"Name des Erstellers: $name \n");
|
fwrite($myfile,"Zeit: ".date("d.m.Y, H:i:s")."\n");
|
||||||
fclose($myfile);
|
fwrite($myfile,"Name des Erstellers: $name \n");
|
||||||
|
fclose($myfile);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function checkeSiegbedingungen($mysqli)
|
function checkeSiegbedingungen($mysqli)
|
||||||
@@ -1813,11 +1844,13 @@ function setBereit($mysqli,$spielerID,$bereit)
|
|||||||
function gameAssoc($mysqli)
|
function gameAssoc($mysqli)
|
||||||
{
|
{
|
||||||
$spielID = $_COOKIE['SpielID'];
|
$spielID = $_COOKIE['SpielID'];
|
||||||
if ($gameRes = $mysqli->Query("SELECT * FROM $spielID"."_game"))
|
try{
|
||||||
{
|
if ($gameRes = $mysqli->Query("SELECT * FROM $spielID"."_game"))
|
||||||
$gameA = $gameRes->fetch_assoc();
|
{
|
||||||
return $gameA;
|
$gameA = $gameRes->fetch_assoc();
|
||||||
}
|
return $gameA;
|
||||||
|
}
|
||||||
|
}catch(mysqli_sql_exception $e) {}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1835,11 +1868,13 @@ function getName($mysqli, $spielerID)
|
|||||||
//Gibt den Namen des Spielers mit der $spielerID zurück
|
//Gibt den Namen des Spielers mit der $spielerID zurück
|
||||||
$spielID = $_COOKIE['SpielID'];
|
$spielID = $_COOKIE['SpielID'];
|
||||||
$spielerID = (int)$spielerID;
|
$spielerID = (int)$spielerID;
|
||||||
if ($res = $mysqli->Query("SELECT * FROM $spielID"."_spieler WHERE id = $spielerID"))
|
try{
|
||||||
{
|
if ($res = $mysqli->Query("SELECT * FROM $spielID"."_spieler WHERE id = $spielerID"))
|
||||||
$temp = $res->fetch_assoc();
|
{
|
||||||
return $temp['name'];
|
$temp = $res->fetch_assoc();
|
||||||
}
|
return $temp['name'];
|
||||||
|
}
|
||||||
|
} catch(mysqli_sql_exception $e) {}
|
||||||
return "Unknown";
|
return "Unknown";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,26 @@
|
|||||||
<?php
|
<?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
|
$pw = "pw"; // Passwort zum MySQL Server
|
||||||
$host = "localhost"; // Host ("localhost" oder "IP-Adresse")
|
$host = "localhost"; // Host ("localhost" oder "IP-Adresse")
|
||||||
$db = "werwolf"; // Name Ihrer Datenbank
|
$db = "werwolf"; // Name Ihrer Datenbank
|
||||||
|
|||||||
@@ -1,5 +1,25 @@
|
|||||||
<?php
|
<?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/includes.php";
|
||||||
include "includes/constants.php";
|
include "includes/constants.php";
|
||||||
header("Content-Type: text/html; charset=utf-8");
|
header("Content-Type: text/html; charset=utf-8");
|
||||||
|
|||||||
21
reload.php
21
reload.php
@@ -1,4 +1,25 @@
|
|||||||
<?php
|
<?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("Content-Type: text/html; charset=utf-8");
|
||||||
header('Cache-Control: no-cache, no-store, max-age=0, must-revalidate');
|
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
|
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); // Date in the past
|
||||||
|
|||||||
Reference in New Issue
Block a user