This commit is contained in:
Trygve 2024-10-27 18:15:45 +01:00
parent 78c6f0e2dd
commit 35df188cf6
4 changed files with 78 additions and 66 deletions

BIN
QTOldGoudy.woff2 Normal file

Binary file not shown.

View File

@ -122,29 +122,24 @@ if (!isset($query)){
if ($query[0] == "registrering"){ if ($query[0] == "registrering"){
$matpost = $query[1]; $matpost = $query[1];
echo(" <tr> echo(" <thead><tr>
<th>#</th> <th>#</th>
<th>Startnummer</th>
<th>Navn</th> <th>Navn</th>
<th>1. matpost</th> <th>Tid</th>
<th>2. matpost</th> <th></th>
<th>Mål</th> </tr></thead>
</tr>"); <tbody>");
for ($i = 0; $i < count($runners); $i++) { for ($i = 0; $i < count($runners); $i++) {
$runner = $runners[$i]; $runner = $runners[$i];
$tid_1_mat = "";
if ($runner->splits[0] != false) { // Klokkeslett for denne posten
// https://www.php.net/manual/en/class.dateinterval.php if ($runner->splits[$matpost-1] != false) {
$tid_1_mat = $GLOBALS['start_time']->diff($runner->splits[0])->format('%H:%I:%S'); $tid_passering = $GLOBALS['start_time']->diff($runner->splits[$matpost-1])->format('%H:%I:%S');
} }
$tid_2_mat = ""; else {
if ($runner->splits[1] != false) { $tid_passering = "";
$tid_2_mat = $GLOBALS['start_time']->diff($runner->splits[1])->format('%H:%I:%S');
}
$tid_maal = "";
if ($runner->splits[2] != false) {
$tid_maal = $GLOBALS['start_time']->diff($runner->splits[2])->format('%H:%I:%S');
} }
if ($runner->get_control() == $matpost-1) { if ($runner->get_control() == $matpost-1) {
// Løperen har vært på denne matposten og vi farger raden grønn // Løperen har vært på denne matposten og vi farger raden grønn
$button = "<button onclick=\"register_runner($runner->id)\">✓</button>"; $button = "<button onclick=\"register_runner($runner->id)\">✓</button>";
@ -159,8 +154,9 @@ if ($query[0] == "registrering"){
$button = "<button onclick=\"register_runner($runner->id)\">✓</button>"; $button = "<button onclick=\"register_runner($runner->id)\">✓</button>";
$cssclass = ""; $cssclass = "";
} }
echo ("<tr $cssclass><td>". $i+1 .".</td><td>$runner->id</td><td>$runner->name</td><td>$tid_1_mat</td><td>$tid_2_mat</td><td>$tid_maal</td><td>$button</td></tr>\n"); echo ("<tr $cssclass><td>$runner->id</td><td>$runner->name</td><td>$tid_passering</td><td>$button</td></tr>\n");
} }
echo("</tbody>");
} }
elseif ($query[0] == "paameldte") { elseif ($query[0] == "paameldte") {
usort($runners, "cmp_course"); usort($runners, "cmp_course");
@ -177,7 +173,7 @@ elseif ($query[0] == "paameldte") {
} }
echo("<div class=\"flex space-evenly\"> echo("<div class=\"flex space-evenly\">
<div class=\"flash accent\">$kadaverløpere påmeldte i Kadaverløpet</div><div class=\"flash accent\">$minikadaverløpere påmeldte i Minikadaver'n</div> <div class=\"flash accent\">$kadaverløpere påmeldt Kadaverløpet</div><div class=\"flash accent\">$minikadaverløpere påmeldte i Minikadaver'n</div>
</div>"); </div>");
echo("<table><tbody> echo("<table><tbody>

View File

@ -7,8 +7,11 @@
<meta name="description" content="Elektronisk Kadaver Tidtakningssystem" /> <meta name="description" content="Elektronisk Kadaver Tidtakningssystem" />
<link rel="stylesheet" href="matcha.css"> <link rel="stylesheet" href="matcha.css">
<style> <style>
.passed { body {
background-color: #8ff0a4; padding: 0;
}
.settings {
padding: 0 1.5rem;
} }
fieldset { fieldset {
display: flex; display: flex;
@ -24,6 +27,9 @@
</style> </style>
</head> </head>
<body> <body>
<div class="settings">
<legend>Passord</legend>
<input type="password" name="passord" id="password">
<fieldset> <fieldset>
<legend>Velg post</legend> <legend>Velg post</legend>
<label> <label>
@ -40,20 +46,11 @@
</label> </label>
</fieldset> </fieldset>
<button onmousedown="update()">Oppdater</button> <button onmousedown="update()">Oppdater tabell</button>
<input id="search" type="number" class="form-control" onkeyup="filterTable()" placeholder="Søk"> <input id="search" type="number" class="form-control" onkeyup="filterTable()" placeholder="Søk">
<br> <br>
</div>
<table> <table id="runners"></table>
<tbody id="runners">
</tbody>
</table>
</body>
<?php
$action = isset($_SERVER['QUERY_STRING']) ? $_SERVER['QUERY_STRING'] : '';
print_r($action)
?>
<script> <script>
// Hvilken matpost vi er på: // Hvilken matpost vi er på:
var control = location.search[1]; var control = location.search[1];
@ -75,14 +72,21 @@ function register_runner(id) {
return 0; return 0;
} }
let formData = new FormData(); let formData = new FormData();
formData.append(name= 'password', value=document.getElementById('password').value)
formData.append(name= 'control', value=control); formData.append(name= 'control', value=control);
formData.append(name= 'id', value=id); formData.append(name= 'id', value=id);
time = new Date(Date.now()).toISOString().split('.')[0]+"Z" time = new Date(Date.now()).toISOString().split('.')[0]+"Z"
formData.append('time', time); formData.append('time', time);
fetch("upload.php", { response = fetch("post.php", {
method: "POST", method: "POST",
body: formData, body: formData,
}); })
.then(response => {
if (response.status == 401) {
alert("Feil passord!")
}
})
update() update()
//document.getElementById("search").focus() //document.getElementById("search").focus()
}; };
@ -98,17 +102,21 @@ function create_rows(csv) {
function filterTable() { function filterTable() {
var input, filter, table, tr, td, i, txtValue; var input, filter, table, tr, td, i, txtValue;
input = document.getElementById("search"); input = document.getElementById("search");
filter = input.value.toUpperCase(); filter = input.value;
table = document.getElementById("runners"); table = document.getElementById("runners").getElementsByTagName("tbody")[0];
tr = table.getElementsByTagName("tr"); tr = table.getElementsByTagName("tr");
if (filter == "") {
for (i = 0; i < tr.length; i++) {
tr[i].style.display = "";
}
}
else {
for (i = 0; i < tr.length; i++) { for (i = 0; i < tr.length; i++) {
td = tr[i].getElementsByTagName("td"); td = tr[i].getElementsByTagName("td");
for (var j = 0; j < td.length; j++) { txtValue = td[0].textContent;
txtValue = td[j].textContent || td[j].innerText; if (txtValue == filter) {
if (txtValue.toUpperCase().indexOf(filter) > -1) {
tr[i].style.display = ""; tr[i].style.display = "";
break;
} else { } else {
tr[i].style.display = "none"; tr[i].style.display = "none";
} }
@ -131,7 +139,6 @@ function update() {
table.innerHTML = text; table.innerHTML = text;
}); });
} }
update()
</script> </script>
<html> </body>
</html>

View File

@ -2,7 +2,16 @@
$control = $_POST['control']; $control = $_POST['control'];
$runner_id = $_POST['id']; $runner_id = $_POST['id'];
$time = $_POST['time']; $time = $_POST['time'];
$password = $_POST['password'];
$hash = file_get_contents("hash.txt");
if (!password_verify($password, $hash)) {
http_response_code(response_code: 401);
}
else {
$file = 'passering.csv'; $file = 'passering.csv';
$current = file_get_contents($file); $current = file_get_contents($file);
$current .= $control . "," . $runner_id . "," . $time . "\n"; $current .= $control . "," . $runner_id . "," . $time . "\n";
file_put_contents($file, $current); file_put_contents($file, $current);
}