stories/app/admin/login.php

64 lines
2.1 KiB
PHP
Executable File

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Feed - Login</title>
<link rel="stylesheet" href="assets/css/login.css">
</head>
<?php
include_once("includes/config.php");
if(isset($_POST["submit"])) {
// declare functions
function generateRandomString($length = 64) {
$characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
$charactersLength = strlen($characters);
$randomString = '';
for ($i = 0; $i < $length; $i++) {
$randomString .= $characters[rand(0, $charactersLength - 1)];
}
return $randomString;
}
$randomString = generateRandomString();
if ($_SERVER["REQUEST_METHOD"] == "POST") {
// declare some variables
$username = htmlspecialchars(strip_tags($_POST["username"]));
$password = htmlspecialchars(strip_tags($_POST["password"]));
if(!$username && !$password) {
die("No Username was entered");
} else if ($username == "administrator" && $password == "5fxDTjgUykN8X374Wduu7AGZGNBhccMD4jCQ2W7694rAEV4KemB9Q4kY2tWKjUye") {
$_SESSION["username"] = $randomString;
header("Location: index.php");
} else {
header("Location: login.php");
}
}
}
?>
<body>
<div class="content">
<div id="main" class="center">
<h1>Win's Panel</h1>
<form action="login.php" method="post" enctype="multipart/form-data">
Username: <input type="text" name="username" placeholder="Username...">
<br><br>
Password: <input type="password" name="password" placeholder="Password...">
<br><br>
<button id="submit" type="submit" name="submit">Submit</button>
</form>
</div>
</div>
</body>
</html>