summaryrefslogtreecommitdiff
path: root/code/admin/auth.php
diff options
context:
space:
mode:
Diffstat (limited to 'code/admin/auth.php')
-rw-r--r--code/admin/auth.php53
1 files changed, 53 insertions, 0 deletions
diff --git a/code/admin/auth.php b/code/admin/auth.php
new file mode 100644
index 0000000..f4afee0
--- /dev/null
+++ b/code/admin/auth.php
@@ -0,0 +1,53 @@
+<?php
+ // Edit secrets here
+ $configured_user = 'admin';
+ $configured_pass = 'admin';
+
+ // Auth validation
+ $auth_fail=FALSE;
+ if ( array_key_exists('u', $_POST) && array_key_exists('p', $_POST) ) {
+ if ( $_POST['u'] === $configured_user && $_POST['p'] === $configured_pass ) {
+ // Auth success
+ session_start();
+ $_SESSION['auth_user'] = TRUE;
+ // Auto-redirect to previous page
+ if ( array_key_exists('auth_return', $_SESSION) && (strlen($_SESSION['auth_return']) > 0) ) {
+ header('Location: ' . $_SESSION['auth_return']);
+ }
+ echo "Authenticated\n";
+ exit();
+ } else {
+ $auth_fail=TRUE;
+ }
+ }
+?>
+<!DOCTYPE html>
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+<title>Authentification</title>
+</head>
+<body>
+<form method="post">
+ <fieldset style="float:left">
+ <legend>Authentification</legend>
+ <table>
+ <tr>
+ <td><label>User</label></td>
+ <td><input type="text" name="u" value="admin"></td>
+ </tr>
+ <tr>
+ <td><label>Pass</label></td>
+ <td><input type="password" name="p" value="admin"></td>
+ </tr>
+ <tr>
+ <td colspan="2" align="right">
+ <span><?php if ($auth_fail) echo "Login failed";?></span>
+ <input type="submit" value="Login">
+ </td>
+ </tr>
+ </table>
+ </fieldset>
+</form>
+</body>
+</html>