La til epost knapp
This commit is contained in:
parent
4cc7ff821c
commit
fdddbbb0ef
@ -46,6 +46,13 @@
|
||||
<button type="submit">Søk</button>
|
||||
</form>
|
||||
<div id="runner_info" class="profile-card"></div>
|
||||
|
||||
<button hx-get="/api/email.php" hx-target="#emails" hx-headers='js:{"password": localStorage.getItem("passord")}'>hent alle eposter</button>
|
||||
<button hx-get="/api/email.php?course=Kadaverløpet" hx-target="#emails" hx-headers='js:{"password": localStorage.getItem("passord")}'>Hent bare eposter for fullkadavern</button>
|
||||
<button hx-get="/api/email.php?course=Minikadaver'n" hx-target="#emails" hx-headers='js:{"password": localStorage.getItem("passord")}'>Hent bare eposter for minikadaver'n</button>
|
||||
<div class="flash default">
|
||||
<output id="emails"></output>
|
||||
</div>
|
||||
<h1>Løpende resultater</h1>
|
||||
<?php
|
||||
include("api/table.php");
|
||||
@ -83,6 +90,6 @@ liveresult_table($runners);
|
||||
}
|
||||
|
||||
</script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/htmx.org@2.0.8/dist/htmx.min.js" integrity="sha384-/TgkGk7p307TH7EXJDuUlgG3Ce1UVolAOFopFekQkkXihi5u/6OCvVKyz1W+idaz" crossorigin="anonymous"></script>
|
||||
<script src="/lib/htmx.min.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
@ -13,7 +13,7 @@ function write_ini_file($assoc_array, $path) {
|
||||
}
|
||||
$content .= "\n";
|
||||
}
|
||||
file_put_contents($path, $content);
|
||||
file_put_contents($path, data: $content);
|
||||
}
|
||||
|
||||
$config = parse_ini_file("$documentRoot/data/config.ini");
|
||||
@ -31,7 +31,8 @@ if ($method == "POST") {
|
||||
$file = "$documentRoot/data/config.ini";
|
||||
$config["start_date"] = $start_time . "+01";
|
||||
write_ini_file($config, $file);
|
||||
header("Location: $documentRoot/config_editor.html");
|
||||
header("HX-Replace-Url: false");
|
||||
echo("Starttida er oppdatert til: $start_time");
|
||||
}
|
||||
}
|
||||
elseif ($method == "GET"){
|
||||
|
||||
25
api/email.php
Normal file
25
api/email.php
Normal file
@ -0,0 +1,25 @@
|
||||
<?php
|
||||
$documentRoot = $_SERVER['DOCUMENT_ROOT'];
|
||||
include("$documentRoot/import_runners.php");
|
||||
$hash = file_get_contents("$documentRoot/data/hash.txt");
|
||||
$method = $_SERVER['REQUEST_METHOD'];
|
||||
if ($method == "GET") {
|
||||
parse_str($_SERVER['QUERY_STRING'], $query);
|
||||
$course = $query['course'];
|
||||
$password = getallheaders()['password'];
|
||||
if (!password_verify($password, $hash)) {
|
||||
http_response_code(response_code: 401);
|
||||
}
|
||||
$runners = read_runners_from_csv();
|
||||
$emails = "";
|
||||
for ($i = 0; $i < count($runners); $i++) {
|
||||
$email = $runners[$i]->email;
|
||||
if (!isset($query['course'])){
|
||||
$emails .= "$email, ";
|
||||
}
|
||||
elseif ($course == $runners[$i]->course) {
|
||||
$emails .= "$email, ";
|
||||
}
|
||||
}
|
||||
echo($emails);
|
||||
}
|
||||
@ -23,6 +23,8 @@ if ($method == "POST") {
|
||||
else {
|
||||
$file = "$documentRoot/data/db.csv";
|
||||
file_put_contents($file, $line, FILE_APPEND);
|
||||
header("HX-Replace-Url: false");
|
||||
echo("Løper lagt til: $line");
|
||||
}
|
||||
}
|
||||
if ($method == "GET") {
|
||||
|
||||
@ -24,7 +24,7 @@
|
||||
</nav>
|
||||
|
||||
<h2>Sett dato og tid startskuddet gikk:</h2>
|
||||
<form action="/api/config.php" method="POST">
|
||||
<form action="/api/config.php" method="POST" hx-boost="true" hx-target="#updated" hx-swap="show:none">
|
||||
<input style="display: none;" type="text" id="password" name="password" required>
|
||||
<label>
|
||||
Dato og tid
|
||||
@ -32,7 +32,7 @@
|
||||
</label>
|
||||
<button type="submit">Oppdater</button>
|
||||
</form>
|
||||
|
||||
<div id="updated"></div>
|
||||
</div>
|
||||
<script>
|
||||
function log_out(){
|
||||
@ -57,5 +57,6 @@
|
||||
console.log(xmlHttpReq.response)
|
||||
|
||||
</script>
|
||||
<script src="/lib/htmx.min.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
@ -23,7 +23,7 @@
|
||||
</menu>
|
||||
</nav>
|
||||
<h2>Legg til løper</h2>
|
||||
<form action="/api/runner.php" method="POST">
|
||||
<form action="/api/runner.php" method="POST" hx-boost="true" hx-target="#updated" hx-swap="show:none">
|
||||
<input style="display: none;" type="text" id="password" name="password" required>
|
||||
|
||||
<label for="id">Startnummer:
|
||||
@ -51,6 +51,7 @@
|
||||
</form>
|
||||
|
||||
</div>
|
||||
<div id="updated"></div>
|
||||
<script>
|
||||
function log_out(){
|
||||
localStorage.removeItem("navn");
|
||||
@ -69,5 +70,6 @@
|
||||
document.getElementById('password').value = localStorage.getItem("passord");
|
||||
|
||||
</script>
|
||||
<script src="/lib/htmx.min.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
1
lib/htmx.min.js
vendored
Normal file
1
lib/htmx.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
@ -19,7 +19,7 @@
|
||||
<figure><img src="img/kadaver.png" alt="" width="100px" class="invert"></figure>
|
||||
<h1>Påmeldte Kadaverløpet 2025</h1>
|
||||
</div>
|
||||
<h2>Oppdatert 24.10.25</h2>
|
||||
<h2>Oppdatert 28.10.25</h2>
|
||||
<div class="flash attention">Startnummer blir tildelt nærmere arrangementet. Prøver å oppdatere lista jevnlig. TBN</div>
|
||||
<?php
|
||||
$query = ["type"=>"paameldte"];
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user