aboutsummaryrefslogtreecommitdiff
path: root/loginform.inc.php
diff options
context:
space:
mode:
authorArno Richter <mail@arnorichter.de>2022-01-26 22:54:31 +0100
committerArno Richter <mail@arnorichter.de>2022-01-26 22:54:31 +0100
commit92c6aa46e73615d433bbef223f35921e5bf12e19 (patch)
treeecbc2d7ec79f67c539e6d3f78cf8019ae8b0425a /loginform.inc.php
parent8ed87afb6aa52e6398ade891ca07fdcc4b15525c (diff)
downloadmicroblog-92c6aa46e73615d433bbef223f35921e5bf12e19.tar.gz
microblog-92c6aa46e73615d433bbef223f35921e5bf12e19.tar.bz2
microblog-92c6aa46e73615d433bbef223f35921e5bf12e19.zip
Fix #3 by cleaning up a few localhost issues
Diffstat (limited to 'loginform.inc.php')
-rw-r--r--loginform.inc.php48
1 files changed, 48 insertions, 0 deletions
diff --git a/loginform.inc.php b/loginform.inc.php
new file mode 100644
index 0000000..8a6cad8
--- /dev/null
+++ b/loginform.inc.php
@@ -0,0 +1,48 @@
+<?php
+ if(!defined('ROOT')) die('Don\'t call this directly.');
+
+ // handle login
+ if(isset($_POST['user']) && isset($_POST['pass'])) {
+ if($_POST['user'] === $config['admin_user'] && $_POST['pass'] === $config['admin_pass']) {
+ $domain = ($_SERVER['HTTP_HOST'] != 'localhost') ? $_SERVER['HTTP_HOST'] : false;
+ setcookie('microblog_login', sha1($config['url'].$config['admin_pass']), NOW+$config['cookie_life'], '/', $domain, false);
+
+ header('Location: '.$config['url'].'/new');
+ die();
+ } else {
+ header('HTTP/1.0 401 Unauthorized');
+ $message = array(
+ 'status' => 'error',
+ 'message' => 'You entered wrong user credentials. Please try again.'
+ );
+ }
+ }
+
+ header('Content-Type: text/html; charset=utf-8');
+
+?><!DOCTYPE html>
+<html lang="<?= $config['language'] ?>" class="login">
+<head>
+ <title>micro.blog</title>
+ <link rel="stylesheet" href="<?= $config['url'] ?>/microblog.css" />
+</head>
+<body>
+ <div class="wrap">
+ <nav>
+ <ul>
+ <li><a href="<?= $config['url'] ?>/">Timeline</a></li>
+ <li><a href="<?= $config['url'] ?>/new">New Status</a></li>
+ </ul>
+ </nav>
+ <p>Please enter your login information.</p>
+ <?php if(isset($message['status']) && isset($message['message'])): ?>
+ <p class="message <?= $message['status'] ?>"><?= $message['message'] ?></p>
+ <?php endif; ?>
+ <form action="" method="post">
+ <input type="text" name="user" placeholder="username" /><br />
+ <input type="password" name="pass" placeholder="password" /><br />
+ <input type="submit" name="" value="Login" />
+ </form>
+ </div>
+</body>
+</html> \ No newline at end of file