mirror of
https://github.com/foin137/werwolfonline.eu.git
synced 2025-12-12 03:11:35 +00:00
Improved endpoint security (Fixes #35 )
This commit is contained in:
24
Werwolf.php
24
Werwolf.php
@@ -145,10 +145,8 @@ p#liste {
|
|||||||
//Schauen, ob wir uns bereits in einem Spiel befinden!
|
//Schauen, ob wir uns bereits in einem Spiel befinden!
|
||||||
if (isset($_COOKIE['SpielID']) && isset($_COOKIE['eigeneID']))
|
if (isset($_COOKIE['SpielID']) && isset($_COOKIE['eigeneID']))
|
||||||
{
|
{
|
||||||
$_COOKIE['SpielID'] = (int)$_COOKIE['SpielID'];
|
$spielID = (int)$_COOKIE['SpielID'];
|
||||||
$_COOKIE['eigeneID'] = (int)$_COOKIE['eigeneID'];
|
$eigeneID = (int)$_COOKIE['eigeneID'];
|
||||||
$spielID = $_COOKIE['SpielID'];
|
|
||||||
$eigeneID = $_COOKIE['eigeneID'];
|
|
||||||
if (isset($_POST['spielLoeschen']))
|
if (isset($_POST['spielLoeschen']))
|
||||||
{
|
{
|
||||||
//Will der Spieler das Spiel löschen?
|
//Will der Spieler das Spiel löschen?
|
||||||
@@ -1503,7 +1501,7 @@ p#liste {
|
|||||||
</form>";
|
</form>";
|
||||||
}
|
}
|
||||||
echo "<form name='gameLogForm' id='gameLogForm' style='display:none'><div id='gamelogdiv'></div></form>";
|
echo "<form name='gameLogForm' id='gameLogForm' style='display:none'><div id='gamelogdiv'></div></form>";
|
||||||
echo "<input type='submit' value='spiellog anzeigen' onClick='showGameLog($spielID);'";
|
echo "<input type='submit' value='spiellog anzeigen' onClick='showGameLog($spielID, $eigeneId);'";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1657,10 +1655,10 @@ p#liste {
|
|||||||
//Die eigene SpielID setzen
|
//Die eigene SpielID setzen
|
||||||
setcookie ("SpielID", $spielID, time()+172800); //Dauer 2 Tage, länger sollte ein Spiel nicht dauern ;)
|
setcookie ("SpielID", $spielID, time()+172800); //Dauer 2 Tage, länger sollte ein Spiel nicht dauern ;)
|
||||||
setcookie ("eigeneID",0, time()+172800);
|
setcookie ("eigeneID",0, time()+172800);
|
||||||
setcookie ("verifizierungsnr",$verifizierungsnr, time()+172800);
|
setcookie ("verifizierungsnr",$verifizierungsnr, time()+172800, secure: true, httponly: true);
|
||||||
$_COOKIE["SpielID"]=$spielID;
|
$_COOKIE["SpielID"]=$spielID;
|
||||||
$_COOKIE["eigeneID"] = 0;
|
$_COOKIE["eigeneID"] = 0;
|
||||||
$_COOKIE["verifizieren"] = $verifizierungsnr;
|
$_COOKIE["verifizierungsnr"] = $verifizierungsnr;
|
||||||
writeGameToLogSpielErstellen($mysqli,$spielID,$_POST['ihrName']);
|
writeGameToLogSpielErstellen($mysqli,$spielID,$_POST['ihrName']);
|
||||||
break; //die Schleife beenden
|
break; //die Schleife beenden
|
||||||
}
|
}
|
||||||
@@ -1937,7 +1935,7 @@ var sekBisTimerBeginn;
|
|||||||
xmlhttp2.send(null);
|
xmlhttp2.send(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
function gameLogRefresh(game)
|
function gameLogRefresh(game, id)
|
||||||
{
|
{
|
||||||
xmlhttp3.onreadystatechange=function()
|
xmlhttp3.onreadystatechange=function()
|
||||||
{
|
{
|
||||||
@@ -1961,17 +1959,17 @@ var sekBisTimerBeginn;
|
|||||||
para.appendChild(temp);
|
para.appendChild(temp);
|
||||||
if (refreshGameLog == 1)
|
if (refreshGameLog == 1)
|
||||||
{
|
{
|
||||||
setTimeout(gameLogRefresh,8000,game);
|
setTimeout(gameLogRefresh, 8000, game, id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
//Error
|
//Error
|
||||||
setTimeout(gameLogRefresh,2*8000,game);
|
setTimeout(gameLogRefresh, 2*8000, game, id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
xmlhttp3.open("GET","gamelogreload.php?game="+ game,true);
|
xmlhttp3.open("GET","gamelogreload.php?game=" + game + "&id=" + $id, true);
|
||||||
xmlhttp3.send();
|
xmlhttp3.send();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2010,7 +2008,7 @@ var sekBisTimerBeginn;
|
|||||||
setTimeout(listRefresh,3000,game,id);
|
setTimeout(listRefresh,3000,game,id);
|
||||||
}
|
}
|
||||||
|
|
||||||
function showGameLog(game)
|
function showGameLog(game, id)
|
||||||
{
|
{
|
||||||
var form = document.getElementById("gameLogForm");
|
var form = document.getElementById("gameLogForm");
|
||||||
if (form.style.display == "block")
|
if (form.style.display == "block")
|
||||||
@@ -2021,7 +2019,7 @@ var sekBisTimerBeginn;
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
form.style.display = "block";
|
form.style.display = "block";
|
||||||
gameLogRefresh(game);
|
gameLogRefresh(game, id);
|
||||||
refreshGameLog = 1;
|
refreshGameLog = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,7 +25,17 @@ werwolfonline, a php web game
|
|||||||
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
|
||||||
header('Pragma: no-cache');
|
header('Pragma: no-cache');
|
||||||
|
|
||||||
$spielID = (int)$_GET['game'];
|
$spielID = (int)$_GET['game'];
|
||||||
|
$id = (int)$_GET['id'];
|
||||||
|
$verifizierungsNr = (int)$_COOKIE['verifizierungsnr'];
|
||||||
|
|
||||||
|
// Verifizieren, dass es sich um einen spieler des spiels handelt
|
||||||
|
$meinSpieler = $mysqli->query("SELECT 1 FROM ".$spielID."_spieler WHERE id = $id AND verifizierungsnr = $verifizierungsNr");
|
||||||
|
if ($meinSpieler->num_rows != 1)
|
||||||
|
{
|
||||||
|
die("<p class='error'>Sie sind momentan nicht mit diesem Spiel verknüpft!</p>");
|
||||||
|
}
|
||||||
|
|
||||||
if ($Result = $mysqli->query("SELECT * FROM ".$spielID."_game"))
|
if ($Result = $mysqli->query("SELECT * FROM ".$spielID."_game"))
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -22,21 +22,28 @@ werwolfonline, a php web game
|
|||||||
|
|
||||||
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");
|
||||||
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
|
||||||
header('Pragma: no-cache');
|
header('Pragma: no-cache');
|
||||||
|
|
||||||
$spielID = (int)$_GET['game'];
|
$spielID = (int)$_GET['game'];
|
||||||
$id = (int)$_GET['id'];
|
$id = (int)$_GET['id'];
|
||||||
|
$verifizierungsNr = (int)$_COOKIE['verifizierungsnr'];
|
||||||
|
|
||||||
$trennzeichen = "$"; //Das Zeichen, auf das im Skript responded wird
|
$trennzeichen = "$"; //Das Zeichen, auf das im Skript responded wird
|
||||||
|
|
||||||
//Reloaded eine Liste, erfordert komplexeren Code als reload.php
|
$meinSpieler = $mysqli->Query("SELECT * FROM $spielID"."_spieler WHERE id = $id AND verifizierungsnr = $verifizierungsNr");
|
||||||
//Die Liste, die reloaded wird ist unterschiedlich, je nach Spielphase und eigenem Charakter
|
if ($meinSpieler->num_rows != 1)
|
||||||
//Wenn reload gesetzt ist, wird außerdem geschaut, ob ich reloaden muss!
|
{
|
||||||
$ichLebe = false;
|
die("<p class='error'>Sie sind momentan nicht mit diesem Spiel verknüpft!</p>");
|
||||||
$ichLebeQ = $mysqli->Query("SELECT * FROM $spielID"."_spieler WHERE id = $id");
|
}
|
||||||
$ichLebeQ = $ichLebeQ->fetch_assoc();
|
|
||||||
|
// Reloaded eine Liste, erfordert komplexeren Code als reload.php
|
||||||
|
// Die Liste, die reloaded wird ist unterschiedlich, je nach Spielphase und eigenem Charakter
|
||||||
|
// Wenn reload gesetzt ist, wird außerdem geschaut, ob ich reloaden muss!
|
||||||
|
$ichLebeQ = $meinSpieler->fetch_assoc();
|
||||||
if (isset($_GET['reload']))
|
if (isset($_GET['reload']))
|
||||||
{
|
{
|
||||||
if ($ichLebeQ['reload'] == 1 && $_GET['reload'] == 1)
|
if ($ichLebeQ['reload'] == 1 && $_GET['reload'] == 1)
|
||||||
@@ -49,10 +56,11 @@ werwolfonline, a php web game
|
|||||||
echo "0";
|
echo "0";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$ichLebe = false;
|
||||||
if ($ichLebeQ['lebt'] == 1)
|
if ($ichLebeQ['lebt'] == 1)
|
||||||
$ichLebe = true;
|
$ichLebe = true;
|
||||||
|
|
||||||
|
|
||||||
$spielRes = $mysqli->Query("SELECT * FROM $spielID"."_game");
|
$spielRes = $mysqli->Query("SELECT * FROM $spielID"."_game");
|
||||||
$spielAss = $spielRes->fetch_assoc();
|
$spielAss = $spielRes->fetch_assoc();
|
||||||
$phase = $spielAss['spielphase'];
|
$phase = $spielAss['spielphase'];
|
||||||
|
|||||||
@@ -18,19 +18,20 @@ werwolfonline, a php web game
|
|||||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
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("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
|
||||||
header('Pragma: no-cache');
|
header('Pragma: no-cache');
|
||||||
include "includes/includes.php";
|
|
||||||
$spielID = (int)$_GET['game'];
|
$spielID = (int)$_GET['game'];
|
||||||
$id = (int)$_GET['id'];
|
$id = (int)$_GET['id'];
|
||||||
if ($Result = $mysqli->query("SELECT * FROM ".$spielID."_spieler WHERE id = $id"))
|
$verifizierungsNr = (int)$_COOKIE['verifizierungsnr'];
|
||||||
|
|
||||||
|
if ($Result = $mysqli->query("SELECT * FROM ".$spielID."_spieler WHERE id = $id AND verifizierungsnr = $verifizierungsNr"))
|
||||||
{
|
{
|
||||||
$temp = $Result->fetch_assoc();
|
$temp = $Result->fetch_assoc();
|
||||||
echo $temp['reload'];
|
echo $temp['reload'];
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|||||||
Reference in New Issue
Block a user