simple tokenized loginsystem
This commit is contained in:
parent
8f2311df0b
commit
f5371aba5d
5 changed files with 124 additions and 10 deletions
39
index.php
39
index.php
|
@ -1,3 +1,10 @@
|
|||
<?php
|
||||
require_once "inc/database.php";
|
||||
$database = new DataBase();
|
||||
if(!$database) {
|
||||
die($database->lastErrorMsg());
|
||||
}
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
|
@ -9,6 +16,21 @@
|
|||
<body>
|
||||
<div id="centerbox">
|
||||
<div id="titlebox"><img src="favicon.ico" />Snuffler</div>
|
||||
|
||||
<?php
|
||||
if (!$database->getAuthedUserId()) {
|
||||
?>
|
||||
|
||||
<form id="loginform" method="post" action="login.php">
|
||||
<input type="text" name="name" placeholder="username" />
|
||||
<input type="password" name="pass" placeholder="password" />
|
||||
<input type="submit" name="submit" value="Log in" />
|
||||
</form>
|
||||
|
||||
<?php
|
||||
} else {
|
||||
?>
|
||||
<a href="logout.php">LOG OUT</a>
|
||||
<form id="postform">
|
||||
<textarea id="postformtextarea" name="text" rows="5" placeholder="Whatcha snuffin' about?"></textarea><br />
|
||||
<div id="postformactionrow">
|
||||
|
@ -20,15 +42,12 @@
|
|||
</div>
|
||||
</form>
|
||||
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
|
||||
|
||||
<?php
|
||||
require_once "inc/database.php";
|
||||
|
||||
$database = new DataBase();
|
||||
|
||||
if(!$database) {
|
||||
die($database->lastErrorMsg());
|
||||
}
|
||||
|
||||
//$database->addPost("Test post", 0);
|
||||
|
||||
|
@ -39,8 +58,8 @@ foreach($posts as $post) {
|
|||
echo '<strong>' . $post["user.name"] . '</strong>';
|
||||
echo '<br><small>@' . $post["user.handle"] . '</small>';
|
||||
echo '<p>' . $post["post.text"] . '</p>';
|
||||
echo '<hr><small>' . date("D j.n.Y \k\l\o G:i", $post["post.time"]) . '</small>';
|
||||
echo '<span class="postactions">5👍 0👎 2💬</span>';
|
||||
echo '<hr><small>' . date("D j.n.Y \@ G:i", $post["post.time"]) . '</small>';
|
||||
echo '<span class="postactions">👍5 👎0 💬2</span>';
|
||||
echo "</div>";
|
||||
|
||||
}
|
||||
|
@ -49,4 +68,4 @@ $database->close();
|
|||
?>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
</html>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue