1
0

/admin/ highscores

This commit is contained in:
Mike Schwörer 2018-01-26 23:52:55 +01:00
parent 82bb16be57
commit e1fec28368
Signed by: Mikescher
GPG Key ID: D3C7172E0A70F8CF
14 changed files with 295 additions and 106 deletions

View File

@ -124,22 +124,41 @@ body {
text-decoration: none; text-decoration: none;
border: 1px solid #000; border: 1px solid #000;
margin: 5px 0; } margin: 5px 0; }
.iconbutton:hover { .iconbutton:hover {
cursor: pointer; cursor: pointer;
background-color: #555; } background-color: #555; }
.iconbutton svg { .iconbutton svg {
width: 14pt; width: 14pt;
height: 14pt; height: 14pt;
margin: 0 4px; margin: 0 4px;
fill: #CCC; } fill: #CCC; }
.iconbutton span { .iconbutton span {
flex-grow: 1; flex-grow: 1;
text-align: center; text-align: center;
font-size: 14pt; } font-size: 14pt; }
.iconbutton_light {
display: flex;
justify-content: center;
align-items: center;
background: #888;
color: #222;
text-decoration: none;
border: 1px solid #000;
margin: 5px 0; }
.iconbutton_light:hover {
cursor: pointer;
background-color: #555; }
.iconbutton_light svg {
width: 14pt;
height: 14pt;
margin: 0 4px;
fill: #000; }
.iconbutton_light span {
flex-grow: 1;
text-align: center;
font-size: 14pt; }
/* 400px */ /* 400px */
#headerdiv { #headerdiv {
z-index: 999; z-index: 999;
@ -975,7 +994,7 @@ html, body {
.about_circles a { .about_circles a {
margin: 5px 0; } margin: 5px 0; }
.about_circles .iconbutton span { .about_circles .iconbutton_light span {
text-align: left; } text-align: left; }
/* 400px */ /* 400px */
@ -997,6 +1016,25 @@ html, body {
resize: none; resize: none;
height: 300px; } height: 300px; }
.keyvaluelist {
display: flex;
flex-direction: column; }
.keyvaluelist div {
display: flex;
flex-direction: row; }
.keyvaluelist div span:first-child {
font-weight: bold;
min-width: 500px; }
.kvl_100 div span:first-child {
min-width: 100px; }
.kvl_200 div span:first-child {
min-width: 200px; }
.kvl_300 div span:first-child {
min-width: 300px; }
/* 400px */ /* 400px */
#loginform div { #loginform div {
display: flex; display: flex;

View File

@ -27,6 +27,10 @@ body{background-color:#EEE;color:#CCC;font-family:serif}
.iconbutton:hover{cursor:pointer;background-color:#555} .iconbutton:hover{cursor:pointer;background-color:#555}
.iconbutton svg{width:14pt;height:14pt;margin:0 4px;fill:#CCC} .iconbutton svg{width:14pt;height:14pt;margin:0 4px;fill:#CCC}
.iconbutton span{flex-grow:1;text-align:center;font-size:14pt} .iconbutton span{flex-grow:1;text-align:center;font-size:14pt}
.iconbutton_light{display:flex;justify-content:center;align-items:center;background:#888;color:#222;text-decoration:none;border:1px solid #000;margin:5px 0}
.iconbutton_light:hover{cursor:pointer;background-color:#555}
.iconbutton_light svg{width:14pt;height:14pt;margin:0 4px;fill:#000}
.iconbutton_light span{flex-grow:1;text-align:center;font-size:14pt}
#headerdiv{z-index:999;background-color:#333;display:flex;border-bottom:1px solid #111;box-shadow:0 0 8px #000;position:fixed;width:100%} #headerdiv{z-index:999;background-color:#333;display:flex;border-bottom:1px solid #111;box-shadow:0 0 8px #000;position:fixed;width:100%}
#headerdiv .logowrapper{flex:initial;margin:0;padding:0;height:42px} #headerdiv .logowrapper{flex:initial;margin:0;padding:0;height:42px}
#headerdiv .logowrapper .logo{min-width:197.5px;height:30px;margin:4px 0 8px 6px;flex:initial} #headerdiv .logowrapper .logo{min-width:197.5px;height:30px;margin:4px 0 8px 6px;flex:initial}
@ -240,10 +244,16 @@ html,body{margin:0;padding:0;height:100%}
.egg_footer>a:hover{text-decoration:none;color:#22F} .egg_footer>a:hover{text-decoration:none;color:#22F}
.about_circles{display:flex;flex-direction:column} .about_circles{display:flex;flex-direction:column}
.about_circles a{margin:5px 0} .about_circles a{margin:5px 0}
.about_circles .iconbutton span{text-align:left} .about_circles .iconbutton_light span{text-align:left}
.admincontent{display:block;width:100%} .admincontent{display:block;width:100%}
.admincontent .boxedcontent{margin-bottom:20px} .admincontent .boxedcontent{margin-bottom:20px}
.egh_ajaxOutput{display:flex;box-sizing:border-box;width:100%;align-self:center;justify-self:center;margin-left:auto;margin-right:auto;resize:none;height:300px} .egh_ajaxOutput{display:flex;box-sizing:border-box;width:100%;align-self:center;justify-self:center;margin-left:auto;margin-right:auto;resize:none;height:300px}
.keyvaluelist{display:flex;flex-direction:column}
.keyvaluelist div{display:flex;flex-direction:row}
.keyvaluelist div span:first-child{font-weight:bold;min-width:500px}
.kvl_100 div span:first-child{min-width:100px}
.kvl_200 div span:first-child{min-width:200px}
.kvl_300 div span:first-child{min-width:300px}
#loginform div{display:flex;flex-direction:column} #loginform div{display:flex;flex-direction:column}
#loginform div button{margin:10px 0;padding:0} #loginform div button{margin:10px 0;padding:0}
.loginerror{display:flex;background:#f44;font-weight:bold;padding:0 5px;margin:5px 0 20px 0} .loginerror{display:flex;background:#f44;font-weight:bold;padding:0 5px;margin:5px 0 20px 0}

View File

@ -112,6 +112,6 @@
a { margin: 5px 0; } a { margin: 5px 0; }
.iconbutton span {text-align: left;} .iconbutton_light span {text-align: left;}
} }

View File

@ -21,3 +21,27 @@
resize: none; resize: none;
height: 300px; height: 300px;
} }
.keyvaluelist {
display: flex;
flex-direction: column;
div {
display: flex;
flex-direction: row;
span:first-child {
font-weight: bold;
min-width: 500px;
}
span:last-child {
}
}
}
.kvl_100 div span:first-child { min-width: 100px; }
.kvl_200 div span:first-child { min-width: 200px; }
.kvl_300 div span:first-child { min-width: 300px; }

View File

@ -132,24 +132,55 @@ body {
border: 1px solid #000; border: 1px solid #000;
margin: 5px 0; margin: 5px 0;
}
.iconbutton:hover { &:hover {
cursor: pointer; cursor: pointer;
background-color: #555; background-color: #555;
} }
svg {
.iconbutton svg {
width: 14pt; width: 14pt;
height: 14pt; height: 14pt;
margin: 0 4px; margin: 0 4px;
fill: $COL_TEXT_NORMAL; fill: $COL_TEXT_NORMAL;
} }
span {
.iconbutton span {
flex-grow: 1; flex-grow: 1;
text-align: center; text-align: center;
font-size: 14pt; font-size: 14pt;
} }
}
.iconbutton_light {
display: flex;
justify-content: center;
align-items: center;
background: #888;
color: $COL_TEXT_DARK_DARKER;
text-decoration: none;
border: 1px solid #000;
margin: 5px 0;
&:hover {
cursor: pointer;
background-color: #555;
}
svg {
width: 14pt;
height: 14pt;
margin: 0 4px;
fill: #000;
}
span {
flex-grow: 1;
text-align: center;
font-size: 14pt;
}
}

View File

@ -1,5 +1,7 @@
<?php if(count(get_included_files()) ==1) exit("Direct access not permitted."); <?php if(count(get_included_files()) ==1) exit("Direct access not permitted.");
require_once (__DIR__ . '/../internals/database.php');
class Highscores class Highscores
{ {
public static function generateChecksum($rand, $player, $playerid, $points, $gamesalt) public static function generateChecksum($rand, $player, $playerid, $points, $gamesalt)
@ -9,4 +11,92 @@ class Highscores
else else
return md5($rand . $player . $points . $gamesalt); return md5($rand . $player . $points . $gamesalt);
} }
public static function insert($gameid, $points, $name, $playerid, $check, $time, $ip)
{
return Database::sql_exec_prep('INSERT INTO ms4_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 ms4_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 ms4_highscoregames WHERE ID = :id',
[
[ ':id', $gameid, PDO::PARAM_INT ],
]);
}
public static function getOrderedEntriesFromGame($gameid, $limit = null)
{
$sql = 'SELECT * FROM ms4_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 ms4_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 ms4_highscoreentries WHERE GAME_ID = :id',
[
[ ':id', $gameid, PDO::PARAM_INT ]
]);
}
public static function getAllGames()
{
return Database::sql_query_assoc('SELECT * FROM ms4_highscoregames');
}
public static function getNextPlayerID($gameid)
{
return Database::sql_query_num_prep('SELECT MAX(PLAYERID)+1 AS NID FROM ms4_highscoreentries WHERE GAME_ID = :gid',
[
[ ':id', $gameid, PDO::PARAM_INT ]
]);
}
public static function getSpecificScore($gameid, $playerid)
{
return Database::sql_query_single_prep('SELECT * FROM ms4_highscoreentries WHERE GAME_ID = :gid AND PLAYERID = :pid',
[
[ ':gid', $gameid, PDO::PARAM_INT ],
[ ':pid', $playerid, PDO::PARAM_INT ],
]);
}
} }

View File

@ -59,31 +59,31 @@ global $OPTIONS;
<div class="bc_data about_circles"> <div class="bc_data about_circles">
<a class="iconbutton" href="https://github.com/Mikescher"> <a class="iconbutton_light" href="https://github.com/Mikescher">
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 24 24"> <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 24 24">
<use xlink:href="/data/images/icons.svg#github"></use> <use xlink:href="/data/images/icons.svg#github"></use>
</svg> </svg>
<span>Github</span> <span>Github</span>
</a> </a>
<a class="iconbutton" href="https://www.goodreads.com/C4terpillar"> <a class="iconbutton_light" href="https://www.goodreads.com/C4terpillar">
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 24 24"> <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 24 24">
<use xlink:href="/data/images/icons.svg#goodreads"></use> <use xlink:href="/data/images/icons.svg#goodreads"></use>
</svg> </svg>
<span>Goodreads</span> <span>Goodreads</span>
</a> </a>
<a class="iconbutton" href="https://stackoverflow.com/users/1761622/mikescher"> <a class="iconbutton_light" href="https://stackoverflow.com/users/1761622/mikescher">
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 24 24"> <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 24 24">
<use xlink:href="/data/images/icons.svg#stackoverflow"></use> <use xlink:href="/data/images/icons.svg#stackoverflow"></use>
</svg> </svg>
<span>Stackoverflow</span> <span>Stackoverflow</span>
</a> </a>
<a class="iconbutton" href="https://www.reddit.com/user/M1kescher/"> <a class="iconbutton_light" href="https://www.reddit.com/user/M1kescher/">
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 24 24"> <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 24 24">
<use xlink:href="/data/images/icons.svg#reddit"></use> <use xlink:href="/data/images/icons.svg#reddit"></use>
</svg> </svg>
<span>Reddit</span> <span>Reddit</span>
</a> </a>
<a class="iconbutton" href="http://www.delphipraxis.net/members/46235-mikescher.html"> <a class="iconbutton_light" href="http://www.delphipraxis.net/members/46235-mikescher.html">
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 24 24"> <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 24 24">
<use xlink:href="/data/images/icons.svg#delphipraxis"></use> <use xlink:href="/data/images/icons.svg#delphipraxis"></use>
</svg> </svg>

View File

@ -2,6 +2,11 @@
<html lang="en"> <html lang="en">
<?php <?php
require_once (__DIR__ . '/../internals/base.php'); require_once (__DIR__ . '/../internals/base.php');
require_once (__DIR__ . '/../internals/highscores.php');
require_once (__DIR__ . '/../internals/alephnoteStatistics.php');
Database::connect();
?> ?>
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
@ -23,18 +28,22 @@ require_once (__DIR__ . '/../internals/base.php');
<div class="contentheader"><h1>Admin</h1><hr/></div> <div class="contentheader"><h1>Admin</h1><hr/></div>
<!------------------------------------------>
<div class="boxedcontent"> <div class="boxedcontent">
<div class="bc_header">Version</div> <div class="bc_header">Version</div>
<div class="bc_data"> <div class="bc_data keyvaluelist kvl_100">
<div><b style="display:inline-block; min-width: 100px">Branch:&nbsp;</b><span><?php echo exec('git rev-parse --abbrev-ref HEAD'); ?></span></div> <div><span>Branch:</span> <span><?php echo exec('git rev-parse --abbrev-ref HEAD'); ?></span></div>
<div><b style="display:inline-block; min-width: 100px">Commit:&nbsp;</b><span><?php echo exec('git rev-parse HEAD'); ?></span></div> <div><span>Commit:</span> <span><?php echo exec('git rev-parse HEAD'); ?></span></div>
<div><b style="display:inline-block; min-width: 100px">Date:&nbsp;</b><span><?php echo exec('git log -1 --format=%cd'); ?></span></div> <div><span>Date:</span> <span><?php echo exec('git log -1 --format=%cd'); ?></span></div>
<div><b style="display:inline-block; min-width: 100px">Message:&nbsp;</b><span><?php echo nl2br(exec('git log -1')); ?></span></div> <div><span>Message:</span><span><?php echo nl2br(trim(exec('git log -1'))); ?></span></div>
</div> </div>
</div> </div>
<!------------------------------------------>
<div class="boxedcontent"> <div class="boxedcontent">
<div class="bc_header">ExtendedGitGraph</div> <div class="bc_header">ExtendedGitGraph</div>
@ -46,6 +55,46 @@ require_once (__DIR__ . '/../internals/base.php');
</div> </div>
</div>
<div class="boxedcontent">
<div class="bc_header">AlephNote</div>
<div class="bc_data">
<div class="keyvaluelist kvl_200">
<div><span>Total users:</span> <span><?php echo 0; ?></span></div>
<div><span>Users on latest version:</span> <span><?php echo 0; ?></span></div>
<div><span>Active users:</span> <span><?php echo 0; ?></span></div>
</div>
<div id="an_ajax_target"></div>
<a class="button" href="javascript:showAlephNoteData('<?php echo $CONFIG['ajax_secret'] ?>')">Show</a>
</div>
</div>
<div class="boxedcontent">
<div class="bc_header">Highscores</div>
<div class="bc_data keyvaluelist kvl_300">
<?php foreach (Highscores::getAllGames() as $game): ?>
<div><span><?php echo '[' . $game['NAME'] . '] Entries:' ?></span> <span><a href="/Highscores/list?gameid=<?php echo $game['ID']; ?>"><?php echo Highscores::getEntryCountFromGame($game['ID']); ?></a></span></div>
<div><span><?php echo '[' . $game['NAME'] . '] Highscore:' ?></span> <span><?php
$hs = Highscores::getOrderedEntriesFromGame($game['ID'], 1)[0];
echo $hs['POINTS'] . ' (' . $hs['PLAYER'] . ') @ ' . $hs['TIMESTAMP'];
?></span></div>
<div><span><?php echo '[' . $game['NAME'] . '] Last Update:' ?></span> <span><?php echo Highscores::getNewestEntriesFromGame($game['ID'], 1)[0]['TIMESTAMP']; ?></span></div>
<hr />
<?php endforeach; ?>
</div>
</div> </div>
</div> </div>

View File

@ -16,24 +16,11 @@
if (! is_numeric($gameid)) httpError(400, 'Invalid Request'); if (! is_numeric($gameid)) httpError(400, 'Invalid Request');
if (! is_numeric($points)) httpError(400, 'Invalid Request'); if (! is_numeric($points)) httpError(400, 'Invalid Request');
$game = Database::sql_query_single_prep('SELECT * FROM ms4_highscoregames WHERE ID = :id', $game = Highscores::getGameByID($gameid);
[
[ ':id', $OPTIONS['gameid'], PDO::PARAM_INT ],
]);
if ($game == NULL) httpError(400, 'Invalid Request'); if ($game == NULL) httpError(400, 'Invalid Request');
$checksum_generated = Highscores::generateChecksum($rand, $name, -1, $points, $game['SALT']); $checksum_generated = Highscores::generateChecksum($rand, $name, -1, $points, $game['SALT']);
if ($checksum_generated != $check) die('Nice try !'); if ($checksum_generated != $check) die('Nice try !');
Database::sql_exec_prep('INSERT INTO ms4_highscoreentries (GAME_ID, POINTS, PLAYER, PLAYERID, CHECKSUM, TIMESTAMP, IP) VALUES (:gid, :p, :pn, :pid, :cs, :ts, :ip)', Highscores::insert($gameid, $points, $name, -1, $check, date("Y-m-d H:m:s", time()), $_SERVER['REMOTE_ADDR']);
[
[':gid', $gameid, PDO::PARAM_INT],
[':p', $points, PDO::PARAM_INT],
[':pn', $name, PDO::PARAM_STR],
[':pid', -1, PDO::PARAM_INT],
[':cs', $check, PDO::PARAM_STR],
[':ts', time(), PDO::PARAM_STR],
[':ip', $_SERVER['REMOTE_ADDR'], PDO::PARAM_STR],
]);
echo 'ok.'; echo 'ok.';

View File

@ -22,16 +22,9 @@
$highlight= intval(htmlspecialchars($_GET["highlight"])); $highlight= intval(htmlspecialchars($_GET["highlight"]));
} }
$game = Database::sql_query_single_prep('SELECT * FROM ms4_highscoregames WHERE ID = :id', $game = Highscores::getGameByID($OPTIONS['gameid']);
[
[ ':id', $OPTIONS['gameid'], PDO::PARAM_INT ]
]);
$entries = Database::sql_query_assoc_prep('SELECT * FROM ms4_highscoreentries WHERE GAME_ID = :id ORDER BY POINTS DESC',
[
[ ':id', $OPTIONS['gameid'], PDO::PARAM_INT ]
]);
$entries = Highscores::getOrderedEntriesFromGame($OPTIONS['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">

View File

@ -7,7 +7,7 @@
Database::connect(); Database::connect();
$games = Database::sql_query_assoc('SELECT * FROM ms4_highscoregames'); $games = Highscores::getAllGames();
?> ?>
<html> <html>

View File

@ -7,10 +7,7 @@
Database::connect(); Database::connect();
$newid = Database::sql_query_num_prep('SELECT MAX(PLAYERID)+1 AS NID FROM ms4_highscoreentries WHERE GAME_ID = :gid', $newid = Highscores::getNextPlayerID($OPTIONS['gameid']);
[
[ ':id', $OPTIONS['gameid'], PDO::PARAM_INT ]
]);
if ($newid < 1024) $newid = 1024; if ($newid < 1024) $newid = 1024;

View File

@ -7,10 +7,7 @@
Database::connect(); Database::connect();
$entries = Database::sql_query_single_prep('SELECT * FROM ms4_highscoreentries WHERE GAME_ID = :id ORDER BY POINTS DESC LIMIT 50', $entries = Highscores::getOrderedEntriesFromGame($OPTIONS['gameid'], 50);
[
[ ':id', $OPTIONS['gameid'], PDO::PARAM_INT ]
]);
for ($i = 0; $i < count($entries); $i++) for ($i = 0; $i < count($entries); $i++)
{ {

View File

@ -18,48 +18,21 @@
if (! is_numeric($nameid)) httpError(400, 'Invalid Request'); if (! is_numeric($nameid)) httpError(400, 'Invalid Request');
if (! is_numeric($points)) httpError(400, 'Invalid Request'); if (! is_numeric($points)) httpError(400, 'Invalid Request');
$game = Database::sql_query_single_prep('SELECT * FROM ms4_highscoregames WHERE ID = :id', $game = Highscores::getGameByID($OPTIONS['gameid']);
[
[ ':id', $OPTIONS['gameid'], PDO::PARAM_INT ],
]);
if ($game == NULL) httpError(400, 'Invalid Request'); if ($game == NULL) httpError(400, 'Invalid Request');
$checksum_generated = Highscores::generateChecksum($rand, $name, $nameid, $points, $game['SALT']); $checksum_generated = Highscores::generateChecksum($rand, $name, $nameid, $points, $game['SALT']);
if ($checksum_generated != $check) die('Nice try !'); if ($checksum_generated != $check) die('Nice try !');
$old = Database::sql_query_single_prep('SELECT * FROM ms4_highscoreentries WHERE GAME_ID = :gid AND PLAYERID = :pid', $old = Highscores::getSpecificScore($gameid, $nameid);
[
[ ':gid', $OPTIONS['gameid'], PDO::PARAM_INT ],
[ ':pid', $OPTIONS['nameid'], PDO::PARAM_INT ],
]);
if ($old == null) if ($old == null)
{ {
Database::sql_exec_prep('INSERT INTO ms4_highscoreentries (GAME_ID, POINTS, PLAYER, PLAYERID, CHECKSUM, TIMESTAMP, IP) VALUES (:gid, :p, :pn, :pid, :cs, :ts, :ip)', Highscores::insert($gameid, $points, $name, $nameid, $check, date("Y-m-d H:m:s", time()), $_SERVER['REMOTE_ADDR']);
[
[':gid', $gameid, PDO::PARAM_INT],
[':p', $points, PDO::PARAM_INT],
[':pn', $name, PDO::PARAM_STR],
[':pid', $nameid, PDO::PARAM_INT],
[':cs', $check, PDO::PARAM_STR],
[':ts', time(), PDO::PARAM_STR],
[':ip', $_SERVER['REMOTE_ADDR'], PDO::PARAM_STR],
]);
echo 'ok.'; echo 'ok.';
} }
else else
{ {
Database::sql_exec_prep('UPDATE ms4_highscoreentries SET POINTS = :p, PLAYER = :pn, CHECKSUM = :cs, IP = :ip, TIMESTAMP = :ts WHERE GAME_ID = :gid AND PLAYERID = :pid', Highscores::update($gameid, $points, $name, $nameid, $check, date("Y-m-d H:m:s", time()), $_SERVER['REMOTE_ADDR']);
[
[':gid', $gameid, PDO::PARAM_INT],
[':p', $points, PDO::PARAM_INT],
[':pn', $name, PDO::PARAM_STR],
[':pid', $nameid, PDO::PARAM_INT],
[':cs', $check], PDO::PARAM_STR,
[':ts', time(), PDO::PARAM_STR],
[':ip', $_SERVER['REMOTE_ADDR'], PDO::PARAM_STR],
]);
echo 'ok.'; echo 'ok.';
} }