Lagde config fil og side for å endre starttidspunkt
This commit is contained in:
parent
cfd95bea41
commit
88dda157b5
@ -13,6 +13,7 @@
|
|||||||
<li class="selected"><a href="/admin.php">📊 Dashbord</a></li>
|
<li class="selected"><a href="/admin.php">📊 Dashbord</a></li>
|
||||||
<li class="disabled"><a href="/registrering.php">⏱️ Registrer passering på matpost/mål</a></li>
|
<li class="disabled"><a href="/registrering.php">⏱️ Registrer passering på matpost/mål</a></li>
|
||||||
<li class="disabled"><a href="/db_editor.html">👥 Endre løperbase</a></li>
|
<li class="disabled"><a href="/db_editor.html">👥 Endre løperbase</a></li>
|
||||||
|
<li class="disabled"><a href="/config_editor.html">⚙️ Konfigurasjon</a></li>
|
||||||
</menu>
|
</menu>
|
||||||
</nav>
|
</nav>
|
||||||
<button class="danger" onclick="log_out()">Logg ut</button>
|
<button class="danger" onclick="log_out()">Logg ut</button>
|
||||||
|
|||||||
41
config.php
Normal file
41
config.php
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
function write_ini_file($assoc_array, $path) {
|
||||||
|
$content = "";
|
||||||
|
foreach ($assoc_array as $section => $values) {
|
||||||
|
if (is_array($values)) {
|
||||||
|
$content .= "[$section]\n";
|
||||||
|
foreach ($values as $key => $val) {
|
||||||
|
$content .= "$key = \"$val\"\n";
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$content .= "$section = \"$values\"\n";
|
||||||
|
}
|
||||||
|
$content .= "\n";
|
||||||
|
}
|
||||||
|
file_put_contents($path, $content);
|
||||||
|
}
|
||||||
|
|
||||||
|
$config = parse_ini_file("data/config.ini");
|
||||||
|
|
||||||
|
$hash = file_get_contents("data/hash.txt");
|
||||||
|
$method = $_SERVER['REQUEST_METHOD'];
|
||||||
|
if ($method == "POST") {
|
||||||
|
$start_time = $_POST['start_time'];
|
||||||
|
|
||||||
|
$password = $_POST['password'];
|
||||||
|
if (!password_verify($password, $hash)) {
|
||||||
|
http_response_code(response_code: 401);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$file = 'data/config.ini';
|
||||||
|
$config["start_date"] = $start_time . "+01";
|
||||||
|
write_ini_file($config, $file);
|
||||||
|
header('Location: config_editor.html');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
elseif ($method == "GET"){
|
||||||
|
print($config["start_date"]);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
55
config_editor.html
Normal file
55
config_editor.html
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="no">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8" />
|
||||||
|
<title>EKT</title>
|
||||||
|
<meta name="viewport" content="width=device-width,initial-scale=1" />
|
||||||
|
<meta name="description" content="Elektronisk Kadaver Tidtakningssystem" />
|
||||||
|
<link rel="stylesheet" href="matcha.css">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<nav>
|
||||||
|
<menu>
|
||||||
|
<li class="disabled"><a href="/admin.php">📊 Dashbord</a></li>
|
||||||
|
<li class="disabled"><a href="/registrering.php">⏱️ Registrer passering på matpost/mål</a></li>
|
||||||
|
<li class="disabled"><a href="/db_editor.html">👥 Endre løperbase</a></li>
|
||||||
|
<li class="selected"><a href="/config_editor.html">⚙️ Konfigurasjon</a></li>
|
||||||
|
</menu>
|
||||||
|
</nav>
|
||||||
|
|
||||||
|
<h2>Sett dato og tid startskuddet gikk:</h2>
|
||||||
|
<form action="/config.php" method="POST">
|
||||||
|
<input style="display: none;" type="text" id="password" name="password" required>
|
||||||
|
<label>
|
||||||
|
Dato og tid
|
||||||
|
<input type="datetime-local" id="start_time" name="start_time" step="1">
|
||||||
|
</label>
|
||||||
|
<button type="submit">Oppdater</button>
|
||||||
|
</form>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<script>
|
||||||
|
function log_out(){
|
||||||
|
localStorage.removeItem("navn");
|
||||||
|
localStorage.removeItem("passord");
|
||||||
|
window.location.href = "/login.html";
|
||||||
|
}
|
||||||
|
|
||||||
|
// Sjekk om brukeren er logga inn. hvis ikke hiv de ut til innloggingskjermen
|
||||||
|
let xmlHttpReq = new XMLHttpRequest();
|
||||||
|
xmlHttpReq.open("POST", "/is_authorized.php", false);
|
||||||
|
xmlHttpReq.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;charset=UTF-8")
|
||||||
|
xmlHttpReq.send("username=" + localStorage.getItem("navn")+"&"+"password=" + localStorage.getItem("passord"));
|
||||||
|
if (xmlHttpReq.status != 200){
|
||||||
|
window.location.href = "/login.html";
|
||||||
|
}
|
||||||
|
document.getElementById('password').value = localStorage.getItem("passord");
|
||||||
|
|
||||||
|
xmlHttpReq.open("GET", "/config.php", false);
|
||||||
|
xmlHttpReq.send();
|
||||||
|
document.getElementById('start_time').value = xmlHttpReq.response.split('+')[0]
|
||||||
|
console.log(xmlHttpReq.response)
|
||||||
|
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@ -13,11 +13,11 @@
|
|||||||
<li class="disabled"><a href="/admin.php">📊 Dashbord</a></li>
|
<li class="disabled"><a href="/admin.php">📊 Dashbord</a></li>
|
||||||
<li class="disabled"><a href="/registrering.php">⏱️ Registrer passering på matpost/mål</a></li>
|
<li class="disabled"><a href="/registrering.php">⏱️ Registrer passering på matpost/mål</a></li>
|
||||||
<li class="selected"><a href="/db_editor.html">👥 Endre løperbase</a></li>
|
<li class="selected"><a href="/db_editor.html">👥 Endre løperbase</a></li>
|
||||||
|
<li class="disabled"><a href="/config_editor.html">⚙️ Konfigurasjon</a></li>
|
||||||
</menu>
|
</menu>
|
||||||
</nav>
|
</nav>
|
||||||
<h2>Legg til løper</h2>
|
<h2>Legg til løper</h2>
|
||||||
<form action="/runner.php" method="POST">
|
<form action="/runner.php" method="POST">
|
||||||
|
|
||||||
<input style="display: none;" type="text" id="password" name="password" required>
|
<input style="display: none;" type="text" id="password" name="password" required>
|
||||||
|
|
||||||
<label for="id">Startnummer:
|
<label for="id">Startnummer:
|
||||||
@ -41,7 +41,7 @@
|
|||||||
</label>
|
</label>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
|
|
||||||
<button type="submit">Submit</button>
|
<button type="submit">Legg til løper</button>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
$hash = file_get_contents("hash.txt");
|
$hash = file_get_contents("data/hash.txt");
|
||||||
$method = $_SERVER['REQUEST_METHOD'];
|
$method = $_SERVER['REQUEST_METHOD'];
|
||||||
if ($method == "POST") {
|
if ($method == "POST") {
|
||||||
$password = $_POST['password'];
|
$password = $_POST['password'];
|
||||||
|
|||||||
@ -4,13 +4,13 @@ $runner_id = $_POST['id'];
|
|||||||
$time = $_POST['time'];
|
$time = $_POST['time'];
|
||||||
$password = $_POST['password'];
|
$password = $_POST['password'];
|
||||||
|
|
||||||
$hash = file_get_contents("hash.txt");
|
$hash = file_get_contents("data/hash.txt");
|
||||||
|
|
||||||
if (!password_verify($password, $hash)) {
|
if (!password_verify($password, $hash)) {
|
||||||
http_response_code(response_code: 401);
|
http_response_code(response_code: 401);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$file = 'passering.csv';
|
$file = 'data/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);
|
||||||
|
|||||||
@ -43,6 +43,7 @@
|
|||||||
<li class="disabled"><a href="/admin.php">📊 Dashbord</a></li>
|
<li class="disabled"><a href="/admin.php">📊 Dashbord</a></li>
|
||||||
<li class="selected"><a href="/registrering.php">⏱️ Registrer passering på matpost/mål</a></li>
|
<li class="selected"><a href="/registrering.php">⏱️ Registrer passering på matpost/mål</a></li>
|
||||||
<li class="disabled"><a href="/db_editor.html">👥 Endre løperbase</a></li>
|
<li class="disabled"><a href="/db_editor.html">👥 Endre løperbase</a></li>
|
||||||
|
<li class="disabled"><a href="/config_editor.html">⚙️ Konfigurasjon</a></li>
|
||||||
</menu>
|
</menu>
|
||||||
</nav>
|
</nav>
|
||||||
<fieldset>
|
<fieldset>
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
$hash = file_get_contents("hash.txt");
|
$hash = file_get_contents("data/hash.txt");
|
||||||
$method = $_SERVER['REQUEST_METHOD'];
|
$method = $_SERVER['REQUEST_METHOD'];
|
||||||
print_r($_POST);
|
print_r($_POST);
|
||||||
if ($method == "POST") {
|
if ($method == "POST") {
|
||||||
@ -18,7 +18,7 @@ if ($method == "POST") {
|
|||||||
http_response_code(response_code: 400);
|
http_response_code(response_code: 400);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$file = 'db.csv';
|
$file = 'data/db.csv';
|
||||||
file_put_contents($file, $line, FILE_APPEND);
|
file_put_contents($file, $line, FILE_APPEND);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
11
table.php
11
table.php
@ -1,11 +1,12 @@
|
|||||||
<?php
|
<?php
|
||||||
|
$config = parse_ini_file("data/config.ini");
|
||||||
date_default_timezone_set('UTC');
|
date_default_timezone_set('UTC');
|
||||||
$GLOBALS['start_time'] = DateTime::createFromFormat(DateTime::ISO8601, "2026-10-26T08:53:00+01");
|
$GLOBALS['start_time'] = DateTime::createFromFormat(DateTime::ISO8601, $config["start_date"]);
|
||||||
$GLOBALS['number_of_controls'] = 3;
|
$GLOBALS['number_of_controls'] = 3;
|
||||||
/*
|
/*
|
||||||
// Caching
|
// Caching
|
||||||
header("Last-Modified: " . date("F d Y H:i:s.", filemtime("passering.csv")));
|
header("Last-Modified: " . date("F d Y H:i:s.", filemtime("data/passering.csv")));
|
||||||
$etag = '"' . md5_file("passering.csv"). '"';
|
$etag = '"' . md5_file("data/passering.csv"). '"';
|
||||||
header(header: 'ETag: ' . $etag );
|
header(header: 'ETag: ' . $etag );
|
||||||
|
|
||||||
if(isset($_SERVER['HTTP_IF_NONE_MATCH'])) {
|
if(isset($_SERVER['HTTP_IF_NONE_MATCH'])) {
|
||||||
@ -108,7 +109,7 @@ function time_diff(DateTime $date_1, DateTime $date_2) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
$runners = [];
|
$runners = [];
|
||||||
$csv_runners = file_get_contents("db.csv");
|
$csv_runners = file_get_contents("data/db.csv");
|
||||||
$csv_runners = str_getcsv($csv_runners, "\n");
|
$csv_runners = str_getcsv($csv_runners, "\n");
|
||||||
for ($i = 1; $i < count($csv_runners); $i++) {
|
for ($i = 1; $i < count($csv_runners); $i++) {
|
||||||
$line = str_getcsv($csv_runners[$i], ";");
|
$line = str_getcsv($csv_runners[$i], ";");
|
||||||
@ -116,7 +117,7 @@ for ($i = 1; $i < count($csv_runners); $i++) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$timings = file_get_contents("passering.csv");
|
$timings = file_get_contents("data/passering.csv");
|
||||||
$timings = str_getcsv($timings, "\n");
|
$timings = str_getcsv($timings, "\n");
|
||||||
for ($i = 0; $i < count($timings); $i++) {
|
for ($i = 0; $i < count($timings); $i++) {
|
||||||
$line = str_getcsv($timings[$i]);
|
$line = str_getcsv($timings[$i]);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user