34 lines
731 B
PHP
34 lines
731 B
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 {
|
|
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);
|
|
} |