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"){
$matpost = $query[1];
echo(" <tr>
echo(" <thead><tr>
<th>#</th>
<th>Startnummer</th>
<th>Navn</th>
<th>1. matpost</th>
<th>2. matpost</th>
<th>Mål</th>
</tr>");
<th>Tid</th>
<th></th>
</tr></thead>
<tbody>");
for ($i = 0; $i < count($runners); $i++) {
$runner = $runners[$i];
$tid_1_mat = "";
if ($runner->splits[0] != false) {
// https://www.php.net/manual/en/class.dateinterval.php
$tid_1_mat = $GLOBALS['start_time']->diff($runner->splits[0])->format('%H:%I:%S');
// Klokkeslett for denne posten
if ($runner->splits[$matpost-1] != false) {
$tid_passering = $GLOBALS['start_time']->diff($runner->splits[$matpost-1])->format('%H:%I:%S');
}
$tid_2_mat = "";
if ($runner->splits[1] != false) {
$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');
else {
$tid_passering = "";
}
if ($runner->get_control() == $matpost-1) {
// Løperen har vært på denne matposten og vi farger raden grønn
$button = "<button onclick=\"register_runner($runner->id)\">✓</button>";
@ -159,8 +154,9 @@ if ($query[0] == "registrering"){
$button = "<button onclick=\"register_runner($runner->id)\">✓</button>";
$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") {
usort($runners, "cmp_course");
@ -177,7 +173,7 @@ elseif ($query[0] == "paameldte") {
}
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>");
echo("<table><tbody>

View File

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

View File

@ -2,7 +2,16 @@
$control = $_POST['control'];
$runner_id = $_POST['id'];
$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';
$current = file_get_contents($file);
$current .= $control . "," . $runner_id . "," . $time . "\n";
file_put_contents($file, $current);
}