Highscores
This commit is contained in:
parent
81e129effa
commit
85f107e8bd
@ -1,7 +1,11 @@
|
|||||||
<component name="InspectionProjectProfileManager">
|
<component name="InspectionProjectProfileManager">
|
||||||
<profile version="1.0" is_locked="false">
|
<profile version="1.0" is_locked="false">
|
||||||
<option name="myName" value="Project Default" />
|
<option name="myName" value="Project Default" />
|
||||||
<option name="myLocal" value="false" />
|
<inspection_tool class="DuplicatedCode" enabled="true" level="WEAK WARNING" enabled_by_default="true">
|
||||||
|
<Languages>
|
||||||
|
<language minSize="100" name="PHP" />
|
||||||
|
</Languages>
|
||||||
|
</inspection_tool>
|
||||||
<inspection_tool class="SpellCheckingInspection" enabled="false" level="TYPO" enabled_by_default="false">
|
<inspection_tool class="SpellCheckingInspection" enabled="false" level="TYPO" enabled_by_default="false">
|
||||||
<option name="processCode" value="true" />
|
<option name="processCode" value="true" />
|
||||||
<option name="processLiterals" value="true" />
|
<option name="processLiterals" value="true" />
|
||||||
|
@ -1,102 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
require_once (__DIR__ . '/../internals/database.php');
|
|
||||||
|
|
||||||
class Highscores
|
|
||||||
{
|
|
||||||
public static function generateChecksum($rand, $player, $playerid, $points, $gamesalt)
|
|
||||||
{
|
|
||||||
if ($playerid >= 0)
|
|
||||||
return md5($rand . $player . $playerid . $points . $gamesalt);
|
|
||||||
else
|
|
||||||
return md5($rand . $player . $points . $gamesalt);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function insert($gameid, $points, $name, $playerid, $check, $time, $ip)
|
|
||||||
{
|
|
||||||
return Database::sql_exec_prep('INSERT INTO highscoreentries (GAME_ID, POINTS, PLAYER, PLAYERID, CHECKSUM, TIMESTAMP, IP) VALUES (:gid, :p, :pn, :pid, :cs, :ts, :ip)',
|
|
||||||
[
|
|
||||||
[':gid', $gameid, PDO::PARAM_INT],
|
|
||||||
[':p', $points, PDO::PARAM_INT],
|
|
||||||
[':pn', $name, PDO::PARAM_STR],
|
|
||||||
[':pid', $playerid, PDO::PARAM_INT],
|
|
||||||
[':cs', $check, PDO::PARAM_STR],
|
|
||||||
[':ts', $time, PDO::PARAM_STR],
|
|
||||||
[':ip', $ip, PDO::PARAM_STR],
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function update($gameid, $points, $name, $playerid, $check, $time, $ip)
|
|
||||||
{
|
|
||||||
return Database::sql_exec_prep('UPDATE highscoreentries SET POINTS = :p, PLAYER = :pn, CHECKSUM = :cs, IP = :ip, TIMESTAMP = :ts WHERE GAME_ID = :gid AND PLAYERID = :pid',
|
|
||||||
[
|
|
||||||
[':gid', $gameid, PDO::PARAM_INT],
|
|
||||||
[':p', $points, PDO::PARAM_INT],
|
|
||||||
[':pn', $name, PDO::PARAM_STR],
|
|
||||||
[':pid', $playerid, PDO::PARAM_INT],
|
|
||||||
[':cs', $check, PDO::PARAM_STR],
|
|
||||||
[':ts', $time, PDO::PARAM_STR],
|
|
||||||
[':ip', $ip, PDO::PARAM_STR],
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function getGameByID($gameid)
|
|
||||||
{
|
|
||||||
return Database::sql_query_single_prep('SELECT * FROM highscoregames WHERE ID = :id',
|
|
||||||
[
|
|
||||||
[ ':id', $gameid, PDO::PARAM_INT ],
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function getOrderedEntriesFromGame($gameid, $limit = null)
|
|
||||||
{
|
|
||||||
$sql = 'SELECT * FROM highscoreentries WHERE GAME_ID = :id ORDER BY POINTS DESC';
|
|
||||||
if ($limit !== null) $sql .= " LIMIT $limit";
|
|
||||||
|
|
||||||
return Database::sql_query_assoc_prep($sql,
|
|
||||||
[
|
|
||||||
[ ':id', $gameid, PDO::PARAM_INT ]
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function getNewestEntriesFromGame($gameid, $limit = null)
|
|
||||||
{
|
|
||||||
$sql = 'SELECT * FROM highscoreentries WHERE GAME_ID = :id ORDER BY TIMESTAMP DESC';
|
|
||||||
if ($limit !== null) $sql .= " LIMIT $limit";
|
|
||||||
|
|
||||||
return Database::sql_query_assoc_prep($sql,
|
|
||||||
[
|
|
||||||
[ ':id', $gameid, PDO::PARAM_INT ]
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function getEntryCountFromGame($gameid)
|
|
||||||
{
|
|
||||||
return Database::sql_query_num_prep('SELECT COUNT(*) FROM highscoreentries WHERE GAME_ID = :id',
|
|
||||||
[
|
|
||||||
[ ':id', $gameid, PDO::PARAM_INT ]
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function getAllGames()
|
|
||||||
{
|
|
||||||
return Database::sql_query_assoc('SELECT * FROM highscoregames');
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function getNextPlayerID($gameid)
|
|
||||||
{
|
|
||||||
return Database::sql_query_num_prep('SELECT MAX(PLAYERID)+1 AS NID FROM highscoreentries WHERE GAME_ID = :gid',
|
|
||||||
[
|
|
||||||
[ ':id', $gameid, PDO::PARAM_INT ]
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function getSpecificScore($gameid, $playerid)
|
|
||||||
{
|
|
||||||
return Database::sql_query_single_prep('SELECT * FROM highscoreentries WHERE GAME_ID = :gid AND PLAYERID = :pid',
|
|
||||||
[
|
|
||||||
[ ':gid', $gameid, PDO::PARAM_INT ],
|
|
||||||
[ ':pid', $playerid, PDO::PARAM_INT ],
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
}
|
|
@ -14,6 +14,7 @@ class Modules
|
|||||||
/** @var UpdatesLog|null */ private $updateslog = null;
|
/** @var UpdatesLog|null */ private $updateslog = null;
|
||||||
/** @var WebApps|null */ private $webapps = null;
|
/** @var WebApps|null */ private $webapps = null;
|
||||||
/** @var MikescherGitGraph|null */ private $extendedgitgraph = null;
|
/** @var MikescherGitGraph|null */ private $extendedgitgraph = null;
|
||||||
|
/** @var Highscores|null */ private $highscores = null;
|
||||||
|
|
||||||
/** @var Website */
|
/** @var Website */
|
||||||
private $site;
|
private $site;
|
||||||
@ -83,4 +84,9 @@ class Modules
|
|||||||
return $this->extendedgitgraph;
|
return $this->extendedgitgraph;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function Highscores(): Highscores
|
||||||
|
{
|
||||||
|
if ($this->highscores === null) { require_once 'modules/highscores.php'; $this->highscores = new Highscores($this->site); }
|
||||||
|
return $this->highscores;
|
||||||
|
}
|
||||||
}
|
}
|
108
www/internals/modules/highscores.php
Normal file
108
www/internals/modules/highscores.php
Normal file
@ -0,0 +1,108 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
class Highscores
|
||||||
|
{
|
||||||
|
/** @var Website */
|
||||||
|
private $site;
|
||||||
|
|
||||||
|
public function __construct(Website $site)
|
||||||
|
{
|
||||||
|
$this->site = $site;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function generateChecksum($rand, $player, $playerid, $points, $gamesalt)
|
||||||
|
{
|
||||||
|
if ($playerid >= 0)
|
||||||
|
return md5($rand . $player . $playerid . $points . $gamesalt);
|
||||||
|
else
|
||||||
|
return md5($rand . $player . $points . $gamesalt);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function insert($gameid, $points, $name, $playerid, $check, $time, $ip)
|
||||||
|
{
|
||||||
|
return $this->site->modules->Database()->sql_exec_prep('INSERT INTO highscoreentries (GAME_ID, POINTS, PLAYER, PLAYERID, CHECKSUM, TIMESTAMP, IP) VALUES (:gid, :p, :pn, :pid, :cs, :ts, :ip)',
|
||||||
|
[
|
||||||
|
[':gid', $gameid, PDO::PARAM_INT],
|
||||||
|
[':p', $points, PDO::PARAM_INT],
|
||||||
|
[':pn', $name, PDO::PARAM_STR],
|
||||||
|
[':pid', $playerid, PDO::PARAM_INT],
|
||||||
|
[':cs', $check, PDO::PARAM_STR],
|
||||||
|
[':ts', $time, PDO::PARAM_STR],
|
||||||
|
[':ip', $ip, PDO::PARAM_STR],
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function update($gameid, $points, $name, $playerid, $check, $time, $ip)
|
||||||
|
{
|
||||||
|
return $this->site->modules->Database()->sql_exec_prep('UPDATE highscoreentries SET POINTS = :p, PLAYER = :pn, CHECKSUM = :cs, IP = :ip, TIMESTAMP = :ts WHERE GAME_ID = :gid AND PLAYERID = :pid',
|
||||||
|
[
|
||||||
|
[':gid', $gameid, PDO::PARAM_INT],
|
||||||
|
[':p', $points, PDO::PARAM_INT],
|
||||||
|
[':pn', $name, PDO::PARAM_STR],
|
||||||
|
[':pid', $playerid, PDO::PARAM_INT],
|
||||||
|
[':cs', $check, PDO::PARAM_STR],
|
||||||
|
[':ts', $time, PDO::PARAM_STR],
|
||||||
|
[':ip', $ip, PDO::PARAM_STR],
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getGameByID($gameid)
|
||||||
|
{
|
||||||
|
return $this->site->modules->Database()->sql_query_single_prep('SELECT * FROM highscoregames WHERE ID = :id',
|
||||||
|
[
|
||||||
|
[ ':id', $gameid, PDO::PARAM_INT ],
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getOrderedEntriesFromGame($gameid, $limit = null)
|
||||||
|
{
|
||||||
|
$sql = 'SELECT * FROM highscoreentries WHERE GAME_ID = :id ORDER BY POINTS DESC';
|
||||||
|
if ($limit !== null) $sql .= " LIMIT $limit";
|
||||||
|
|
||||||
|
return $this->site->modules->Database()->sql_query_assoc_prep($sql,
|
||||||
|
[
|
||||||
|
[ ':id', $gameid, PDO::PARAM_INT ]
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getNewestEntriesFromGame($gameid, $limit = null)
|
||||||
|
{
|
||||||
|
$sql = 'SELECT * FROM highscoreentries WHERE GAME_ID = :id ORDER BY TIMESTAMP DESC';
|
||||||
|
if ($limit !== null) $sql .= " LIMIT $limit";
|
||||||
|
|
||||||
|
return $this->site->modules->Database()->sql_query_assoc_prep($sql,
|
||||||
|
[
|
||||||
|
[ ':id', $gameid, PDO::PARAM_INT ]
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getEntryCountFromGame($gameid)
|
||||||
|
{
|
||||||
|
return $this->site->modules->Database()->sql_query_num_prep('SELECT COUNT(*) FROM highscoreentries WHERE GAME_ID = :id',
|
||||||
|
[
|
||||||
|
[ ':id', $gameid, PDO::PARAM_INT ]
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getAllGames()
|
||||||
|
{
|
||||||
|
return $this->site->modules->Database()->sql_query_assoc('SELECT * FROM highscoregames');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getNextPlayerID($gameid)
|
||||||
|
{
|
||||||
|
return $this->site->modules->Database()->sql_query_num_prep('SELECT MAX(PLAYERID)+1 AS NID FROM highscoreentries WHERE GAME_ID = :gid',
|
||||||
|
[
|
||||||
|
[ ':id', $gameid, PDO::PARAM_INT ]
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getSpecificScore($gameid, $playerid)
|
||||||
|
{
|
||||||
|
return $this->site->modules->Database()->sql_query_single_prep('SELECT * FROM highscoreentries WHERE GAME_ID = :gid AND PLAYERID = :pid',
|
||||||
|
[
|
||||||
|
[ ':gid', $gameid, PDO::PARAM_INT ],
|
||||||
|
[ ':pid', $playerid, PDO::PARAM_INT ],
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
@ -1,26 +1,30 @@
|
|||||||
<?php
|
<?php
|
||||||
global $OPTIONS;
|
require_once (__DIR__ . '/../internals/website.php');
|
||||||
|
|
||||||
require_once (__DIR__ . '/../internals/base.php');
|
/** @var PageFrameOptions $FRAME_OPTIONS */ global $FRAME_OPTIONS;
|
||||||
require_once (__DIR__ . '/../internals/database.php');
|
/** @var URLRoute $ROUTE */ global $ROUTE;
|
||||||
require_once (__DIR__ . '/../internals/highscores.php');
|
/** @var Website $SITE */ global $SITE;
|
||||||
|
|
||||||
Database::connect();
|
$FRAME_OPTIONS->title = null;
|
||||||
|
$FRAME_OPTIONS->canonical_url = null;
|
||||||
|
$FRAME_OPTIONS->activeHeader = null;
|
||||||
|
$FRAME_OPTIONS->frame = 'api_frame.php';
|
||||||
|
|
||||||
$gameid = $OPTIONS['gameid'];
|
|
||||||
$check = $OPTIONS['check'];
|
|
||||||
$name = $OPTIONS['name'];
|
|
||||||
$rand = $OPTIONS['rand'];
|
|
||||||
$points = $OPTIONS['points'];
|
|
||||||
|
|
||||||
if (! is_numeric($gameid)) httpError(400, 'Invalid Request');
|
$gameid = $ROUTE->parameter['gameid'];
|
||||||
if (! is_numeric($points)) httpError(400, 'Invalid Request');
|
$check = $ROUTE->parameter['check'];
|
||||||
|
$name = $ROUTE->parameter['name'];
|
||||||
|
$rand = $ROUTE->parameter['rand'];
|
||||||
|
$points = $ROUTE->parameter['points'];
|
||||||
|
|
||||||
$game = Highscores::getGameByID($gameid);
|
if (! is_numeric($gameid)) { $FRAME_OPTIONS->forceResult(400, 'Invalid Request'); return; }
|
||||||
if ($game == NULL) httpError(400, 'Invalid Request');
|
if (! is_numeric($points)) { $FRAME_OPTIONS->forceResult(400, 'Invalid Request'); return; }
|
||||||
|
|
||||||
$checksum_generated = Highscores::generateChecksum($rand, $name, -1, $points, $game['SALT']);
|
$game = $SITE->modules->Highscores()->getGameByID($gameid);
|
||||||
|
if ($game == NULL) { $FRAME_OPTIONS->forceResult(400, 'Invalid Request'); return; }
|
||||||
|
|
||||||
|
$checksum_generated = $SITE->modules->Highscores()->generateChecksum($rand, $name, -1, $points, $game['SALT']);
|
||||||
if ($checksum_generated != $check) die('Nice try !');
|
if ($checksum_generated != $check) die('Nice try !');
|
||||||
|
|
||||||
Highscores::insert($gameid, $points, $name, -1, $check, date("Y-m-d H:m:s", time()), $_SERVER['REMOTE_ADDR']);
|
$SITE->modules->Highscores()->insert($gameid, $points, $name, -1, $check, date("Y-m-d H:m:s", time()), $_SERVER['REMOTE_ADDR']);
|
||||||
echo 'ok.';
|
echo 'ok.';
|
@ -1,11 +1,16 @@
|
|||||||
<?php
|
<?php
|
||||||
global $OPTIONS;
|
require_once (__DIR__ . '/../internals/website.php');
|
||||||
|
|
||||||
|
/** @var PageFrameOptions $FRAME_OPTIONS */ global $FRAME_OPTIONS;
|
||||||
|
/** @var URLRoute $ROUTE */ global $ROUTE;
|
||||||
|
/** @var Website $SITE */ global $SITE;
|
||||||
|
|
||||||
|
$FRAME_OPTIONS->title = null;
|
||||||
|
$FRAME_OPTIONS->canonical_url = null;
|
||||||
|
$FRAME_OPTIONS->activeHeader = null;
|
||||||
|
$FRAME_OPTIONS->frame = 'api_frame.php';
|
||||||
|
|
||||||
require_once (__DIR__ . '/../internals/base.php');
|
|
||||||
require_once (__DIR__ . '/../internals/database.php');
|
|
||||||
require_once (__DIR__ . '/../internals/highscores.php');
|
|
||||||
|
|
||||||
Database::connect();
|
|
||||||
|
|
||||||
$pagesize = 20;
|
$pagesize = 20;
|
||||||
$start = 0;
|
$start = 0;
|
||||||
@ -22,9 +27,9 @@
|
|||||||
$highlight= intval(htmlspecialchars($_GET["highlight"]));
|
$highlight= intval(htmlspecialchars($_GET["highlight"]));
|
||||||
}
|
}
|
||||||
|
|
||||||
$game = Highscores::getGameByID($OPTIONS['gameid']);
|
$game = $SITE->modules->Highscores()->getGameByID($ROUTE->parameter['gameid']);
|
||||||
|
|
||||||
$entries = Highscores::getOrderedEntriesFromGame($OPTIONS['gameid']);
|
$entries = $SITE->modules->Highscores()->getOrderedEntriesFromGame($ROUTE->parameter['gameid']);
|
||||||
?>
|
?>
|
||||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
||||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||||
|
@ -1,14 +1,16 @@
|
|||||||
<?php
|
<?php
|
||||||
global $OPTIONS;
|
require_once (__DIR__ . '/../internals/website.php');
|
||||||
|
|
||||||
require_once (__DIR__ . '/../internals/base.php');
|
/** @var PageFrameOptions $FRAME_OPTIONS */ global $FRAME_OPTIONS;
|
||||||
require_once (__DIR__ . '/../internals/database.php');
|
/** @var URLRoute $ROUTE */ global $ROUTE;
|
||||||
require_once (__DIR__ . '/../internals/highscores.php');
|
/** @var Website $SITE */ global $SITE;
|
||||||
|
|
||||||
Database::connect();
|
$FRAME_OPTIONS->title = null;
|
||||||
|
$FRAME_OPTIONS->canonical_url = null;
|
||||||
$games = Highscores::getAllGames();
|
$FRAME_OPTIONS->activeHeader = null;
|
||||||
|
$FRAME_OPTIONS->frame = 'api_frame.php';
|
||||||
|
|
||||||
|
$games = $SITE->modules->Highscores()->getAllGames();
|
||||||
?>
|
?>
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
|
@ -1,13 +1,17 @@
|
|||||||
<?php
|
<?php
|
||||||
global $OPTIONS;
|
require_once (__DIR__ . '/../internals/website.php');
|
||||||
|
|
||||||
require_once (__DIR__ . '/../internals/base.php');
|
/** @var PageFrameOptions $FRAME_OPTIONS */ global $FRAME_OPTIONS;
|
||||||
require_once (__DIR__ . '/../internals/database.php');
|
/** @var URLRoute $ROUTE */ global $ROUTE;
|
||||||
require_once (__DIR__ . '/../internals/highscores.php');
|
/** @var Website $SITE */ global $SITE;
|
||||||
|
|
||||||
Database::connect();
|
$FRAME_OPTIONS->title = null;
|
||||||
|
$FRAME_OPTIONS->canonical_url = null;
|
||||||
|
$FRAME_OPTIONS->activeHeader = null;
|
||||||
|
$FRAME_OPTIONS->frame = 'api_frame.php';
|
||||||
|
|
||||||
$newid = Highscores::getNextPlayerID($OPTIONS['gameid']);
|
|
||||||
|
$newid = $SITE->modules->Highscores()->getNextPlayerID($ROUTE->parameter['gameid']);
|
||||||
|
|
||||||
if ($newid < 1024) $newid = 1024;
|
if ($newid < 1024) $newid = 1024;
|
||||||
|
|
||||||
|
@ -1,13 +1,17 @@
|
|||||||
<?php
|
<?php
|
||||||
global $OPTIONS;
|
require_once (__DIR__ . '/../internals/website.php');
|
||||||
|
|
||||||
require_once (__DIR__ . '/../internals/base.php');
|
/** @var PageFrameOptions $FRAME_OPTIONS */ global $FRAME_OPTIONS;
|
||||||
require_once (__DIR__ . '/../internals/database.php');
|
/** @var URLRoute $ROUTE */ global $ROUTE;
|
||||||
require_once (__DIR__ . '/../internals/highscores.php');
|
/** @var Website $SITE */ global $SITE;
|
||||||
|
|
||||||
Database::connect();
|
$FRAME_OPTIONS->title = null;
|
||||||
|
$FRAME_OPTIONS->canonical_url = null;
|
||||||
|
$FRAME_OPTIONS->activeHeader = null;
|
||||||
|
$FRAME_OPTIONS->frame = 'api_frame.php';
|
||||||
|
|
||||||
$entries = Highscores::getOrderedEntriesFromGame($OPTIONS['gameid'], 50);
|
|
||||||
|
$entries = $SITE->modules->Highscores()->getOrderedEntriesFromGame($ROUTE->parameter['gameid'], 50);
|
||||||
|
|
||||||
for ($i = 0; $i < count($entries); $i++)
|
for ($i = 0; $i < count($entries); $i++)
|
||||||
{
|
{
|
||||||
|
@ -1,38 +1,42 @@
|
|||||||
<?php
|
<?php
|
||||||
global $OPTIONS;
|
require_once (__DIR__ . '/../internals/website.php');
|
||||||
|
|
||||||
require_once (__DIR__ . '/../internals/base.php');
|
/** @var PageFrameOptions $FRAME_OPTIONS */ global $FRAME_OPTIONS;
|
||||||
require_once (__DIR__ . '/../internals/database.php');
|
/** @var URLRoute $ROUTE */ global $ROUTE;
|
||||||
require_once (__DIR__ . '/../internals/highscores.php');
|
/** @var Website $SITE */ global $SITE;
|
||||||
|
|
||||||
Database::connect();
|
$FRAME_OPTIONS->title = null;
|
||||||
|
$FRAME_OPTIONS->canonical_url = null;
|
||||||
|
$FRAME_OPTIONS->activeHeader = null;
|
||||||
|
$FRAME_OPTIONS->frame = 'api_frame.php';
|
||||||
|
|
||||||
$gameid = $OPTIONS['gameid'];
|
|
||||||
$check = $OPTIONS['check'];
|
|
||||||
$name = $OPTIONS['name'];
|
|
||||||
$nameid = $OPTIONS['nameid'];
|
|
||||||
$rand = $OPTIONS['rand'];
|
|
||||||
$points = $OPTIONS['points'];
|
|
||||||
|
|
||||||
if (! is_numeric($gameid)) httpError(400, 'Invalid Request');
|
$gameid = $ROUTE->parameter['gameid'];
|
||||||
if (! is_numeric($nameid)) httpError(400, 'Invalid Request');
|
$check = $ROUTE->parameter['check'];
|
||||||
if (! is_numeric($points)) httpError(400, 'Invalid Request');
|
$name = $ROUTE->parameter['name'];
|
||||||
|
$nameid = $ROUTE->parameter['nameid'];
|
||||||
|
$rand = $ROUTE->parameter['rand'];
|
||||||
|
$points = $ROUTE->parameter['points'];
|
||||||
|
|
||||||
$game = Highscores::getGameByID($OPTIONS['gameid']);
|
if (! is_numeric($gameid)) { $FRAME_OPTIONS->forceResult(400, 'Invalid Request'); return; }
|
||||||
if ($game == NULL) httpError(400, 'Invalid Request');
|
if (! is_numeric($nameid)) { $FRAME_OPTIONS->forceResult(400, 'Invalid Request'); return; }
|
||||||
|
if (! is_numeric($points)) { $FRAME_OPTIONS->forceResult(400, 'Invalid Request'); return; }
|
||||||
|
|
||||||
$checksum_generated = Highscores::generateChecksum($rand, $name, $nameid, $points, $game['SALT']);
|
$game = $SITE->modules->Highscores()->getGameByID($ROUTE->parameter['gameid']);
|
||||||
|
if ($game == NULL) { $FRAME_OPTIONS->forceResult(400, 'Invalid Request'); return; }
|
||||||
|
|
||||||
|
$checksum_generated = $SITE->modules->Highscores()->generateChecksum($rand, $name, $nameid, $points, $game['SALT']);
|
||||||
if ($checksum_generated != $check) die('Nice try !');
|
if ($checksum_generated != $check) die('Nice try !');
|
||||||
|
|
||||||
$old = Highscores::getSpecificScore($gameid, $nameid);
|
$old = $SITE->modules->Highscores()->getSpecificScore($gameid, $nameid);
|
||||||
|
|
||||||
if ($old == null)
|
if ($old == null)
|
||||||
{
|
{
|
||||||
Highscores::insert($gameid, $points, $name, $nameid, $check, date("Y-m-d H:m:s", time()), $_SERVER['REMOTE_ADDR']);
|
$SITE->modules->Highscores()->insert($gameid, $points, $name, $nameid, $check, date("Y-m-d H:m:s", time()), $_SERVER['REMOTE_ADDR']);
|
||||||
echo 'ok.';
|
echo 'ok.';
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Highscores::update($gameid, $points, $name, $nameid, $check, date("Y-m-d H:m:s", time()), $_SERVER['REMOTE_ADDR']);
|
$SITE->modules->Highscores()->update($gameid, $points, $name, $nameid, $check, date("Y-m-d H:m:s", time()), $_SERVER['REMOTE_ADDR']);
|
||||||
echo 'ok.';
|
echo 'ok.';
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user