From e1fec2836805a39352b0a0f7f700d8a5ee783ecf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mike=20Schw=C3=B6rer?= Date: Fri, 26 Jan 2018 23:52:55 +0100 Subject: [PATCH] /admin/ highscores --- www/data/css/styles.css | 68 ++++++++++++++++----- www/data/css/styles.min.css | 12 +++- www/data/css/styles_about.scss | 2 +- www/data/css/styles_admin.scss | 26 +++++++- www/data/css/styles_global.scss | 59 +++++++++++++----- www/internals/highscores.php | 90 ++++++++++++++++++++++++++++ www/pages/about.php | 10 ++-- www/pages/admin.php | 59 ++++++++++++++++-- www/pages/highscores_insert.php | 17 +----- www/pages/highscores_listentries.php | 11 +--- www/pages/highscores_listgames.php | 2 +- www/pages/highscores_newid.php | 5 +- www/pages/highscores_top50.php | 5 +- www/pages/highscores_update.php | 35 ++--------- 14 files changed, 295 insertions(+), 106 deletions(-) diff --git a/www/data/css/styles.css b/www/data/css/styles.css index 55d57cb..48e7d56 100644 --- a/www/data/css/styles.css +++ b/www/data/css/styles.css @@ -124,21 +124,40 @@ body { text-decoration: none; border: 1px solid #000; margin: 5px 0; } + .iconbutton:hover { + cursor: pointer; + background-color: #555; } + .iconbutton svg { + width: 14pt; + height: 14pt; + margin: 0 4px; + fill: #CCC; } + .iconbutton span { + flex-grow: 1; + text-align: center; + font-size: 14pt; } -.iconbutton:hover { - cursor: pointer; - background-color: #555; } - -.iconbutton svg { - width: 14pt; - height: 14pt; - margin: 0 4px; - fill: #CCC; } - -.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; } /* 400px */ #headerdiv { @@ -975,7 +994,7 @@ html, body { .about_circles a { margin: 5px 0; } -.about_circles .iconbutton span { +.about_circles .iconbutton_light span { text-align: left; } /* 400px */ @@ -997,6 +1016,25 @@ html, body { 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; } + /* 400px */ #loginform div { display: flex; diff --git a/www/data/css/styles.min.css b/www/data/css/styles.min.css index 7ed6495..800acf0 100644 --- a/www/data/css/styles.min.css +++ b/www/data/css/styles.min.css @@ -27,6 +27,10 @@ body{background-color:#EEE;color:#CCC;font-family:serif} .iconbutton:hover{cursor:pointer;background-color:#555} .iconbutton svg{width:14pt;height:14pt;margin:0 4px;fill:#CCC} .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 .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} @@ -240,10 +244,16 @@ html,body{margin:0;padding:0;height:100%} .egg_footer>a:hover{text-decoration:none;color:#22F} .about_circles{display:flex;flex-direction:column} .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 .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} +.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 button{margin:10px 0;padding:0} .loginerror{display:flex;background:#f44;font-weight:bold;padding:0 5px;margin:5px 0 20px 0} diff --git a/www/data/css/styles_about.scss b/www/data/css/styles_about.scss index f2d4d69..f5f5ad1 100644 --- a/www/data/css/styles_about.scss +++ b/www/data/css/styles_about.scss @@ -112,6 +112,6 @@ a { margin: 5px 0; } - .iconbutton span {text-align: left;} + .iconbutton_light span {text-align: left;} } \ No newline at end of file diff --git a/www/data/css/styles_admin.scss b/www/data/css/styles_admin.scss index 933ab02..a14f7a2 100644 --- a/www/data/css/styles_admin.scss +++ b/www/data/css/styles_admin.scss @@ -20,4 +20,28 @@ margin-right: auto; resize: none; height: 300px; -} \ No newline at end of file +} + +.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; } \ No newline at end of file diff --git a/www/data/css/styles_global.scss b/www/data/css/styles_global.scss index 1dfbfc0..c9ab290 100644 --- a/www/data/css/styles_global.scss +++ b/www/data/css/styles_global.scss @@ -132,24 +132,55 @@ body { border: 1px solid #000; margin: 5px 0; + + &:hover { + cursor: pointer; + background-color: #555; + } + svg { + width: 14pt; + height: 14pt; + margin: 0 4px; + + fill: $COL_TEXT_NORMAL; + } + span { + flex-grow: 1; + text-align: center; + + font-size: 14pt; + } + } -.iconbutton:hover { - cursor: pointer; - background-color: #555; -} +.iconbutton_light { + display: flex; + justify-content: center; + align-items: center; -.iconbutton svg { - width: 14pt; - height: 14pt; - margin: 0 4px; + background: #888; + color: $COL_TEXT_DARK_DARKER; + text-decoration: none; + border: 1px solid #000; - fill: $COL_TEXT_NORMAL; -} + margin: 5px 0; -.iconbutton span { - flex-grow: 1; - text-align: center; + &: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; + } - font-size: 14pt; } \ No newline at end of file diff --git a/www/internals/highscores.php b/www/internals/highscores.php index 47fec0c..3e1c07e 100644 --- a/www/internals/highscores.php +++ b/www/internals/highscores.php @@ -1,5 +1,7 @@ - + Github - + Goodreads - + Stackoverflow - + Reddit - + diff --git a/www/pages/admin.php b/www/pages/admin.php index a6de7da..707c7db 100644 --- a/www/pages/admin.php +++ b/www/pages/admin.php @@ -2,6 +2,11 @@ @@ -23,18 +28,22 @@ require_once (__DIR__ . '/../internals/base.php');

Admin


+ +
Version
-
-
Branch: 
-
Commit: 
-
Date: 
-
Message: 
+
+
Branch:
+
Commit:
+
Date:
+
Message:
+ +
ExtendedGitGraph
@@ -46,6 +55,46 @@ require_once (__DIR__ . '/../internals/base.php');
+
+ +
+
AlephNote
+ +
+ +
+ +
+
Highscores
+ +
+ + + +
+
+
+ +
+ + + +
+
diff --git a/www/pages/highscores_insert.php b/www/pages/highscores_insert.php index 39da527..a0eb4ad 100644 --- a/www/pages/highscores_insert.php +++ b/www/pages/highscores_insert.php @@ -16,24 +16,11 @@ if (! is_numeric($gameid)) 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', - [ - [ ':id', $OPTIONS['gameid'], PDO::PARAM_INT ], - ]); + $game = Highscores::getGameByID($gameid); if ($game == NULL) httpError(400, 'Invalid Request'); $checksum_generated = Highscores::generateChecksum($rand, $name, -1, $points, $game['SALT']); 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)', - [ - [':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], - ]); - + Highscores::insert($gameid, $points, $name, -1, $check, date("Y-m-d H:m:s", time()), $_SERVER['REMOTE_ADDR']); echo 'ok.'; \ No newline at end of file diff --git a/www/pages/highscores_listentries.php b/www/pages/highscores_listentries.php index 9ec4dac..51adbed 100644 --- a/www/pages/highscores_listentries.php +++ b/www/pages/highscores_listentries.php @@ -22,16 +22,9 @@ $highlight= intval(htmlspecialchars($_GET["highlight"])); } - $game = Database::sql_query_single_prep('SELECT * FROM ms4_highscoregames WHERE ID = :id', - [ - [ ':id', $OPTIONS['gameid'], PDO::PARAM_INT ] - ]); + $game = Highscores::getGameByID($OPTIONS['gameid']); - $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']); ?> diff --git a/www/pages/highscores_listgames.php b/www/pages/highscores_listgames.php index ddee8cf..959b38a 100644 --- a/www/pages/highscores_listgames.php +++ b/www/pages/highscores_listgames.php @@ -7,7 +7,7 @@ Database::connect(); - $games = Database::sql_query_assoc('SELECT * FROM ms4_highscoregames'); + $games = Highscores::getAllGames(); ?> diff --git a/www/pages/highscores_newid.php b/www/pages/highscores_newid.php index 632e051..4e903c4 100644 --- a/www/pages/highscores_newid.php +++ b/www/pages/highscores_newid.php @@ -7,10 +7,7 @@ Database::connect(); - $newid = Database::sql_query_num_prep('SELECT MAX(PLAYERID)+1 AS NID FROM ms4_highscoreentries WHERE GAME_ID = :gid', - [ - [ ':id', $OPTIONS['gameid'], PDO::PARAM_INT ] - ]); + $newid = Highscores::getNextPlayerID($OPTIONS['gameid']); if ($newid < 1024) $newid = 1024; diff --git a/www/pages/highscores_top50.php b/www/pages/highscores_top50.php index ffd6e18..ec2aa6c 100644 --- a/www/pages/highscores_top50.php +++ b/www/pages/highscores_top50.php @@ -7,10 +7,7 @@ Database::connect(); - $entries = Database::sql_query_single_prep('SELECT * FROM ms4_highscoreentries WHERE GAME_ID = :id ORDER BY POINTS DESC LIMIT 50', - [ - [ ':id', $OPTIONS['gameid'], PDO::PARAM_INT ] - ]); + $entries = Highscores::getOrderedEntriesFromGame($OPTIONS['gameid'], 50); for ($i = 0; $i < count($entries); $i++) { diff --git a/www/pages/highscores_update.php b/www/pages/highscores_update.php index 28dc0ab..62b4275 100644 --- a/www/pages/highscores_update.php +++ b/www/pages/highscores_update.php @@ -18,48 +18,21 @@ if (! is_numeric($nameid)) 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', - [ - [ ':id', $OPTIONS['gameid'], PDO::PARAM_INT ], - ]); + $game = Highscores::getGameByID($OPTIONS['gameid']); if ($game == NULL) httpError(400, 'Invalid Request'); $checksum_generated = Highscores::generateChecksum($rand, $name, $nameid, $points, $game['SALT']); if ($checksum_generated != $check) die('Nice try !'); - $old = Database::sql_query_single_prep('SELECT * FROM ms4_highscoreentries WHERE GAME_ID = :gid AND PLAYERID = :pid', - [ - [ ':gid', $OPTIONS['gameid'], PDO::PARAM_INT ], - [ ':pid', $OPTIONS['nameid'], PDO::PARAM_INT ], - ]); + $old = Highscores::getSpecificScore($gameid, $nameid); 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)', - [ - [':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], - ]); - + Highscores::insert($gameid, $points, $name, $nameid, $check, date("Y-m-d H:m:s", time()), $_SERVER['REMOTE_ADDR']); echo 'ok.'; } 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', - [ - [':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], - ]); - + Highscores::update($gameid, $points, $name, $nameid, $check, date("Y-m-d H:m:s", time()), $_SERVER['REMOTE_ADDR']); echo 'ok.'; }