-added server files
This commit is contained in:
33
server/score-update.php
Normal file
33
server/score-update.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
ini_set('display_errors', 1);
|
||||
ini_set('display_startup_errors', 1);
|
||||
error_reporting(E_ALL);
|
||||
|
||||
class MiBD extends SQLite3
|
||||
{
|
||||
function __construct()
|
||||
{
|
||||
$this->open('../bd/jailgames.db');
|
||||
}
|
||||
}
|
||||
|
||||
$bd = new MiBD();
|
||||
|
||||
$game = "";
|
||||
if (isset($_GET['game'])) $game = $_GET['game'];
|
||||
$user = "";
|
||||
if (isset($_GET['user'])) $user = $_GET['user'];
|
||||
$points = "";
|
||||
if (isset($_GET['points'])) $points = $_GET['points'];
|
||||
|
||||
$query = "SELECT count(*) as count FROM scores WHERE game LIKE '".$game."' AND user LIKE '".$user."'";
|
||||
$resultado = $bd->query($query);
|
||||
if ($resultado->fetchArray(SQLITE3_ASSOC)['count'] > 0) {
|
||||
$query = "UPDATE scores SET points=".$points." WHERE game='".$game."' AND user='".$user."'";
|
||||
$bd->exec($query);
|
||||
} else {
|
||||
$query = "INSERT INTO scores (game, user, points) VALUES ('".$game."', '".$user."', ".$points.")";
|
||||
$bd->exec($query);
|
||||
}
|
||||
echo("OK");
|
||||
?>
|
||||
Reference in New Issue
Block a user