45 lines
1.0 KiB
PHP
45 lines
1.0 KiB
PHP
<?php
|
|
|
|
include("database_queries.php");
|
|
|
|
function check_login($con) {
|
|
|
|
if(isset($_SESSION['user_id'])) {
|
|
|
|
$id = $_SESSION['user_id'];
|
|
if(check_user_id($con, $id)) {
|
|
return get_user_data_id($con, $id);
|
|
} else {
|
|
unset($_SESSION['user_id']);
|
|
header("Location: login.php");
|
|
die;
|
|
}
|
|
} else {
|
|
header("Location: login.php");
|
|
die;
|
|
}
|
|
}
|
|
|
|
function generate_salt() {
|
|
return substr(bin2hex(random_bytes(128)), 0, 128);
|
|
}
|
|
|
|
function generate_user_id($username, $salt) {
|
|
$uname = $username . $salt;
|
|
return hash('sha3-512', $uname);
|
|
}
|
|
|
|
function generate_password_hash($password, $salt) {
|
|
$pword = $password . $salt;
|
|
return hash('sha3-512', $pword);
|
|
}
|
|
|
|
function load_stations_table($con) {
|
|
$stmt = get_stations($con);
|
|
foreach($stmt->fetchAll() as $row) {
|
|
echo "<tr>";
|
|
echo "<td>" . $row['name'] . "</td>";
|
|
echo "<td>" . $row['standort'] . "</td>";
|
|
echo "</tr>";
|
|
}
|
|
} |