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

30 lines
1.2 KiB
PHP
Raw Permalink Normal View History

2017-11-09 17:43:34 +01:00
<?php
2020-01-17 00:55:41 +01:00
require_once (__DIR__ . '/../internals/website.php');
2017-11-09 17:43:34 +01:00
2020-01-17 00:55:41 +01:00
/** @var PageFrameOptions $FRAME_OPTIONS */ global $FRAME_OPTIONS;
/** @var URLRoute $ROUTE */ global $ROUTE;
/** @var Website $SITE */ global $SITE;
2017-11-09 17:43:34 +01:00
2020-01-17 00:55:41 +01:00
$FRAME_OPTIONS->title = null;
$FRAME_OPTIONS->canonical_url = null;
$FRAME_OPTIONS->activeHeader = null;
$FRAME_OPTIONS->frame = 'api_frame.php';
2017-11-09 17:43:34 +01:00
2020-01-17 00:55:41 +01:00
$gameid = $ROUTE->parameter['gameid'];
$check = $ROUTE->parameter['check'];
$name = $ROUTE->parameter['name'];
$rand = $ROUTE->parameter['rand'];
$points = $ROUTE->parameter['points'];
2017-11-09 17:43:34 +01:00
2020-01-17 00:55:41 +01:00
if (! is_numeric($gameid)) { $FRAME_OPTIONS->forceResult(400, 'Invalid Request'); return; }
if (! is_numeric($points)) { $FRAME_OPTIONS->forceResult(400, 'Invalid Request'); return; }
2017-11-09 17:43:34 +01:00
2020-01-17 00:55:41 +01:00
$game = $SITE->modules->Highscores()->getGameByID($gameid);
if ($game == NULL) { $FRAME_OPTIONS->forceResult(400, 'Invalid Request'); return; }
2017-11-09 17:43:34 +01:00
2020-01-17 00:55:41 +01:00
$checksum_generated = $SITE->modules->Highscores()->generateChecksum($rand, $name, -1, $points, $game['SALT']);
if ($checksum_generated != $check) die('Nice try !');
$SITE->modules->Highscores()->insert($gameid, $points, $name, -1, $check, date("Y-m-d H:m:s", time()), $_SERVER['REMOTE_ADDR']);
echo 'ok.';