SnakeGame/Web/index.php

52 lines
1.5 KiB
PHP
Raw Normal View History

2017-01-07 22:15:15 +00:00
<?php
if(!isset($_POST['client']) || $_POST['client']=="")
{
echo "Welcome!<br>
<a>Project home</a>";
die();
}
2017-01-07 22:18:03 +00:00
else
{
//echo "Client data";
$conn = mysqli_connect("mysql.hostinger.hu", "u821146919_games", "SLp7q9m60J", "u821146919_games");
if($_POST['client']=="cheesecrescent")
{ //GameList
$res=mysqli_query($conn, "SELECT * FROM games");
while($row=mysqli_fetch_array($res))
{
$namecount=count(explode(',', $row['playernames']));
if($namecount==0 || $row['startdate']<time()-60*60*1000)
{
mysqli_query($conn, "DELETE FROM games
WHERE name='".$row['name']."'
AND ownername='".$row['ownername']."'
AND maxplayers='".$row['maxplayers']."'
AND playernames='".$row['playernames']."'
AND startdate='".$row['startdate']."'
AND ip='".$row['ip']."'
") or die(mysqli_error($conn));
}
else
{
echo $row['name']."|".$row['ownername']."|".$row['maxplayers']."|".$namecount."|".$row['playernames']."|".$row['ip']."|";
}
}
}
else
{
2017-01-07 22:20:57 +00:00
if($_POST['name']=="" || $_POST['maxplayers']=="" || $_POST['client']=="" || $_POST['ip']=="")
2017-01-07 22:18:03 +00:00
die("A field is or more fields are empty!");
mysqli_query($conn, "INSERT INTO games
(
name, maxplayers, playernames, ownername, startdate, ip
) VALUES (
'".$_POST['name']."', '".$_POST['maxplayers']."', '".$_POST['client']."', '".$_POST['client']."', '".time()."', '".$_POST['ip']."'
)") or die(mysqli_error($conn));
echo "OK";
}
}
2017-01-07 22:15:15 +00:00
//WebPass: vhwfsQOv9E
2017-01-07 22:18:03 +00:00
//fötöpö: (...sznpadmin) VKiSh7i1og
2017-01-07 22:15:15 +00:00
?>