1
0
www.mikescher.com/www/pages/highscores_insert.php

26 lines
867 B
PHP
Raw Normal View History

2017-11-09 17:43:34 +01:00
<?php
global $OPTIONS;
require_once (__DIR__ . '/../internals/base.php');
require_once (__DIR__ . '/../internals/database.php');
require_once (__DIR__ . '/../internals/highscores.php');
Database::connect();
$gameid = $OPTIONS['gameid'];
$check = $OPTIONS['check'];
$name = $OPTIONS['name'];
$rand = $OPTIONS['rand'];
$points = $OPTIONS['points'];
if (! is_numeric($gameid)) httpError(400, 'Invalid Request');
if (! is_numeric($points)) httpError(400, 'Invalid Request');
2018-01-26 23:52:55 +01:00
$game = Highscores::getGameByID($gameid);
2017-11-09 17:43:34 +01:00
if ($game == NULL) httpError(400, 'Invalid Request');
$checksum_generated = Highscores::generateChecksum($rand, $name, -1, $points, $game['SALT']);
if ($checksum_generated != $check) die('Nice try !');
2018-01-26 23:52:55 +01:00
Highscores::insert($gameid, $points, $name, -1, $check, date("Y-m-d H:m:s", time()), $_SERVER['REMOTE_ADDR']);
2017-11-09 17:43:34 +01:00
echo 'ok.';