/
home.php
67 lines (61 loc) · 2.1 KB
/
home.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
<?php include("header.php");
if(!isset($_SESSION['id']))
{
header("Location: login.php");
exit();
}
?>
<div class="container piccontainer" id="book">
<h2 class="pictitle">Welcome.</h2>
<div class="picitem">
<h3>Home</h3>
<p>See every blog entry here.</p>
</div>
</div>
<div class="container contentdiv">
<div class="col-md-8">
<?php
$db = db();
$stmt = $db->prepare('SELECT * FROM post ORDER BY id DESC');
$result = $stmt->execute();
while($fetch = $result->fetchArray())
{
echo '<div class="row">';
echo '<div class="col-md-3 postuser">';
echo '<div class="nailthumb postuserpic"><a href="view-user.php?id=' . $fetch['user_id'] . '"><img src="pics/userpics/' . selectuser($fetch['user_id'])['pic'] . '.jpg"></a></div>';
echo '<h1>' . selectuser($fetch['user_id'])['username'] . '</h1>';
echo '</div>';
echo '<a href="view-post.php?id=' . $fetch['id'] . '"><div class="postspace col-md-9">';
echo '<h3>' . $fetch['tag'] . '</h3>';
echo '<h1>' . $fetch['title'] . '</h1>';
echo '<h4>' . $fetch['created_at'] . '</h4>';
?><h2><?php foreach(preg_split("/((\r?\n)|(\r\n?))/", $fetch['summary']) as $line)
{echo $line . '<br>';}?></h2><?php
echo '</div></a>';
echo '</div>';
}
if($result->fetchArray() === false)
{
echo "<h2>There aren't any blog entries here.</h2>";
}
?>
</div>
<div class="col-md-4">
<div class="userspace">
<h1><?php echo selectuser($_SESSION['id'])['username'];?></h1>
<div class="nailthumb userpic"><img src="pics/userpics/<?php echo selectuser($_SESSION['id'])['pic'];?>.jpg"></div>
<a href="view-user.php?id=<?php echo $_SESSION['id']; ?>"><button name="view-user">PROFILE</button></a><br>
<form method="post" action="lib/common.php">
<button name="logout">LOGOUT</button>
</form>
</div>
</div>
</div>
<script type="text/javascript" src="scripts/jquery.nailthumb.1.1.js"></script>
<script type="text/javascript">
jQuery(document).ready(function() {
jQuery('.nailthumb').nailthumb();
});
</script>
</body>
</html>