Compare commits

...

2 Commits

2 changed files with 28 additions and 22 deletions

View File

@ -1,3 +1,22 @@
<?php
if (null !== $_POST['set_pwd']) {
$pwd = $_POST['set_pwd'];
file_put_contents('data/admin_pwd', password_hash($pwd, PASSWORD_DEFAULT));
setcookie('owe_admin', base64_encode($pwd), ['httponly' => true]);
header('location: admin.php');
} elseif (null !== $_POST['pwd']) {
$pwd = $_POST['pwd'];
if (password_verify($pwd, file_get_contents('data/admin_pwd'))) {
setcookie('owe_admin', base64_encode($pwd), ['httponly' => true]);
header('location: admin.php');
print("DER KEKS MÜSSTE GESETZT SEIN");
} else {
print("Nope, falsch");
}
}
?>
<!DOCTYPE html>
<?php
@ -47,13 +66,6 @@ $config_data = json_decode($raw_json_config, false);
<?php
if (null !== $_POST['set_pwd']) {
$pwd = $_POST['set_pwd'];
file_put_contents('data/admin_pwd', password_hash($pwd, PASSWORD_DEFAULT));
setcookie('owe_admin', base64_encode($pwd), ['httponly' => true]);
header('location: admin.php');
}
endif;
if ($login):
@ -96,17 +108,8 @@ $config_data = json_decode($raw_json_config, false);
</form>
<?php
if (null !== $_POST['pwd']) {
$pwd = $_POST['pwd'];
if (password_verify($pwd, file_get_contents('data/admin_pwd'))) {
setcookie('owe_admin', base64_encode($pwd), ['httponly' => true]);
header('location: admin.php');
} else {
print("Nope, falsch");
}
}
endif; ?>
endif;
?>
</p>
<script>

11
owe.js
View File

@ -31,11 +31,14 @@ function loadSentences(alertIfNew = false, increaseUnread = true) {
// color
var spans = document.querySelector(".sentences").getElementsByTagName("span");
// we expect this to be from the user who's turn it is now
var histurnspan = spans[spans.length - config_data.users.length];
//console.log(histurnspan.getAttribute("style"));
document.getElementById("wordinput").setAttribute("style", histurnspan.getAttribute("style"));
if (spans.length >= config_data.users.length) {
var histurnspan = spans[spans.length - config_data.users.length];
//console.log(histurnspan.getAttribute("style"));
document.getElementById("wordinput").setAttribute("style", histurnspan.getAttribute("style"));
} else {
console.error('Not enough spans available for users.');
}
initializeLoginArea();
});
});