2024-09-28 08:21:52 +03:00
|
|
|
<?php
|
|
|
|
require_once "inc/database.php";
|
2024-09-28 23:01:23 +03:00
|
|
|
function getRandomIcon() {
|
|
|
|
$files = glob('./snuffmoji/*.png');
|
|
|
|
$random_file_num = array_rand($files);
|
|
|
|
return $files[$random_file_num];;
|
|
|
|
}
|
|
|
|
$randomicon = getRandomIcon();
|
2024-09-28 08:21:52 +03:00
|
|
|
$database = new DataBase();
|
|
|
|
if(!$database) {
|
|
|
|
die($database->lastErrorMsg());
|
|
|
|
}
|
|
|
|
?>
|
2024-09-27 05:47:54 +03:00
|
|
|
<!DOCTYPE html>
|
|
|
|
<html>
|
|
|
|
<head>
|
2024-09-28 01:01:51 +03:00
|
|
|
<meta charset="UTF-8" />
|
|
|
|
<link rel="stylesheet" href="style.css" />
|
2024-09-28 23:01:23 +03:00
|
|
|
<link rel="icon" type="image/x-icon" href="<?php echo $randomicon; ?>">
|
2024-09-28 01:13:20 +03:00
|
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
2024-09-27 05:47:54 +03:00
|
|
|
<title>Snuffler</title>
|
|
|
|
</head>
|
|
|
|
<body>
|
2024-09-28 19:42:37 +03:00
|
|
|
<div id="flexout">
|
|
|
|
|
|
|
|
<div id="lpanel" class="flexpanel">
|
|
|
|
<ul>
|
|
|
|
<li>Kotisivu</li>
|
|
|
|
<li>Viestit</li>
|
|
|
|
<li>Kalavaleet</li>
|
|
|
|
<li>Takasivu</li>
|
|
|
|
</ul>
|
|
|
|
</div>
|
|
|
|
<div id="rpanel" class="flexpanel">
|
|
|
|
<ul>
|
|
|
|
<li>Mikko Mällikäs<br /><small>@mmallikas</small></li>
|
|
|
|
<li>Jarkko Toivanen<br /><small>@jt</small></li>
|
|
|
|
</ul>
|
|
|
|
</div>
|
|
|
|
|
2024-09-28 01:01:51 +03:00
|
|
|
<div id="centerbox">
|
2024-09-28 23:01:23 +03:00
|
|
|
<div id="titlebox"><img src="<?php echo $randomicon; ?>" alt="" />Snuffler</div>
|
2024-09-28 08:21:52 +03:00
|
|
|
|
|
|
|
<?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>
|
2024-09-28 01:01:51 +03:00
|
|
|
<form id="postform">
|
|
|
|
<textarea id="postformtextarea" name="text" rows="5" placeholder="Whatcha snuffin' about?"></textarea><br />
|
|
|
|
<div id="postformactionrow">
|
|
|
|
<select id="user" name="user">
|
|
|
|
<option value=0>SYSTEM</option>
|
|
|
|
<option value=1>User</option>
|
|
|
|
</select>
|
|
|
|
<input type="submit" id="submit" name="submit" value="Snuff!" />
|
|
|
|
</div>
|
|
|
|
</form>
|
2024-09-27 05:47:54 +03:00
|
|
|
|
2024-09-28 08:21:52 +03:00
|
|
|
<?php
|
|
|
|
}
|
|
|
|
?>
|
2024-09-27 05:47:54 +03:00
|
|
|
|
|
|
|
|
2024-09-28 08:21:52 +03:00
|
|
|
<?php
|
2024-09-28 01:01:51 +03:00
|
|
|
|
|
|
|
//$database->addPost("Test post", 0);
|
|
|
|
|
2024-09-28 01:27:52 +03:00
|
|
|
$posts = array_reverse($database->getPosts());
|
2024-09-28 01:01:51 +03:00
|
|
|
//var_dump($posts);
|
|
|
|
foreach($posts as $post) {
|
|
|
|
echo '<div class="post">';
|
|
|
|
echo '<strong>' . $post["user.name"] . '</strong>';
|
|
|
|
echo '<br><small>@' . $post["user.handle"] . '</small>';
|
|
|
|
echo '<p>' . $post["post.text"] . '</p>';
|
2024-09-28 08:21:52 +03:00
|
|
|
echo '<hr><small>' . date("D j.n.Y \@ G:i", $post["post.time"]) . '</small>';
|
2024-09-28 23:01:23 +03:00
|
|
|
echo '
|
|
|
|
<span class="postactions">
|
|
|
|
<img class="reactionaction" src="snuffmoji/thumbs_up.png" />
|
|
|
|
<img class="reactionaction" src="snuffmoji/thumbs_down.png" />
|
|
|
|
<img class="reactionaction" src="snuffmoji/joy.png" />
|
|
|
|
<img class="reactionaction" src="snuffmoji/sob.png" />
|
|
|
|
<img class="reactionaction" src="snuffmoji/heart_eyes.png" />
|
|
|
|
</span>';
|
2024-09-28 01:01:51 +03:00
|
|
|
echo "</div>";
|
|
|
|
|
|
|
|
}
|
2024-09-27 05:47:54 +03:00
|
|
|
$database->close();
|
|
|
|
|
2024-09-28 01:01:51 +03:00
|
|
|
?>
|
|
|
|
</div>
|
2024-09-28 19:42:37 +03:00
|
|
|
</div>
|
2024-09-28 01:01:51 +03:00
|
|
|
</body>
|
2024-09-28 08:21:52 +03:00
|
|
|
</html>
|