Create a very basic login system
This commit is contained in:
parent
51d68584f7
commit
7739b27105
10
base.php
10
base.php
|
@ -1 +1,11 @@
|
|||
<?php
|
||||
|
||||
if (!isset($_COOKIE['_session']) || !file_exists('/tmp/apcontrol-sessions')) {
|
||||
header('Location: login.php'); die;
|
||||
}
|
||||
|
||||
$session = trim($_COOKIE['_session']);
|
||||
$sessions = explode("\n", trim(file_get_contents('/tmp/apcontrol-sessions')));
|
||||
if (!in_array($session, $sessions)) {
|
||||
header('Location: login.php'); die;
|
||||
}
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
<?php require 'base.php' ?>
|
||||
<html>
|
||||
<head>
|
||||
<title>ActivityPub Control Panel</title>
|
||||
|
|
|
@ -0,0 +1,42 @@
|
|||
<?php
|
||||
|
||||
if (isset($_POST['username']) && isset($_POST['password'])) {
|
||||
$username = trim($_POST['username']);
|
||||
$password = trim($_POST['password']);
|
||||
// TODO: implement a way to check user passwords
|
||||
$session = sha1(strval(microtime(true)));
|
||||
setcookie('_session', $session);
|
||||
file_put_contents('/tmp/apcontrol-sessions', $session."\n", FILE_APPEND);
|
||||
header('Location: ..');
|
||||
die;
|
||||
}
|
||||
?>
|
||||
<html>
|
||||
<head>
|
||||
<title>APub Control - Login</title>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<link rel="stylesheet" href="fonts/forkawesome/css/fork-awesome.min.css">
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<?php require 'css/base.php' ?>
|
||||
|
||||
<main style="display:flex">
|
||||
<form style="margin:auto" action="login.php" method="POST">
|
||||
<input type="text" name="username" placeholder="Username"/>
|
||||
<br>
|
||||
<input type="password" name="password" placeholder="Password"/>
|
||||
<br>
|
||||
<input type="submit" value="Log in"/>
|
||||
</form>
|
||||
hola
|
||||
</main>
|
||||
|
||||
<?php require 'js/base.php' ?>
|
||||
|
||||
<script>
|
||||
window.onload = function(e) {
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
Loading…
Reference in New Issue