T201704051343

This commit is contained in:
Leander
2017-04-05 13:43:49 +02:00
parent 9869c1c28a
commit 2b104e943d

View File

@@ -17,8 +17,7 @@ $chosen_answer = isset($_GET['answer']) ? $_GET['answer'] : '';
$chosen_answer = (($chosen_answer === '0') || ($chosen_answer && gettype(+$chosen_answer) == 'integer')) ? +$_GET['answer'] : -1;
function calculate_points($time) {
$points = $time < 2000 ? 100 : 141.1421 - 0.02842916 * $time + 0.000004132312 * pow($time, 2)
- 3.432331e-10 * pow($time, 3) + 1.391508e-14 * pow($time, 4) - 2.166078e-19 * pow($time, 5);
$points = $time < 2000 ? 100 : 205 - 1/2 * (205 + sqrt(-3975 + 2 * $time));
$points = $points < 10 ? 100 : intval($points * 10);
return $points;
}
@@ -51,7 +50,7 @@ if($uid == '') {
//set high score
if($db->query('SELECT EXISTS (SELECT 1 FROM "Highscores" WHERE "Users_ID" = $1 AND "Categories_ID" = $2)',
array($uid, $cid))['data'][0]['exists'] == 'f') {
$db->query('INSERT INTO "Highscores" ("Users_ID", "Categories_ID"), VALUES ($1, $2)', array($uid, $cid));
$db->query('INSERT INTO "Highscores" ("Users_ID", "Categories_ID") VALUES ($1, $2)', array($uid, $cid));
}
$old_hi_data = $db->query('SELECT "score", "answered_questions" FROM "Highscores" WHERE "Users_ID" = $1
AND "Categories_ID" = $2', array($uid, $cid))['data'][0];