This commit is contained in:
2024-01-11 09:27:03 +01:00
parent e584aeb36a
commit 59f399c866
12 changed files with 295 additions and 11 deletions

56
pages/global/login.php Normal file
View File

@@ -0,0 +1,56 @@
<?php
ob_start();
$template_dir = "templates/";
if($_SERVER["REQUEST_METHOD"] == "POST"){
if(!empty($_POST["email"]) && !empty($_POST["password"])){
$email = $_POST["email"];
$pass = $_POST["password"];
/* prepare statement */
$stmt = $mysqli->prepare("SELECT ID, PSWD, IGN, ISADMIN FROM Users where EMAIL = ?");
$stmt->bind_param("s", $email);
$stmt->execute();
/* bind variables to prepared statement */
$stmt->bind_result($idcko, $hash, $ign, $isadmin);
$found = false;
/* fetch values */
while ($stmt->fetch()) {
if (password_verify($pass, $hash)){
$_SESSION["ID"] = $idcko;
$_SESSION["email"] = $email;
$_SESSION["ign"] = $ign;
$_SESSION["isadmin"] = $isadmin;
$found = true;
break;
}
else{
$_SESSION["ID"] = 0;
$_SESSION["email"] = "";
$_SESSION["ign"] = "";
$_SESSION["isadmin"] = 0;
$found = false;
}
break;
}
if($found){
echo "Login successful";
}
else{
echo "Login failed";
}
}
}
if ($_SESSION["ID"] > 0){
$account_template = file_get_contents($template_dir . "account.html");
echo $account_template;
}
else{
$login_template = file_get_contents($template_dir . "login.html");
echo $login_template;
}
return ob_get_clean();
?>

5
pages/home/domov.html Normal file
View File

@@ -0,0 +1,5 @@
<header>
<h1 class="title">Adlerka Memes</h1>
<p>Skoro ako <a href="https://reddit.com/r/adlerka" target="_blank">r/adlerka</a> - ale lepšie.</p>
<hr>
</header>

1
pages/home/info.html Normal file
View File

@@ -0,0 +1 @@
<h1>Vitaj na oficiálnej stránke Memeov o AdlerkaSMP</h1>