-
Notifications
You must be signed in to change notification settings - Fork 0
/
browse.php
98 lines (90 loc) · 3.87 KB
/
browse.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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
<?php include("functions.php"); ?>
<?php include("core/json.php");
$_SESSION['success'] = null;
if (isset($_POST['applyskin_btn']))
{
applyskin();
}
?>
<html>
<head>
<link rel="stylesheet" href="css/bootstrap.min.css">
<link rel="stylesheet" href="css/style.css">
<title><?php echo $name; ?> - Browse</title>
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
<script src="js/bootstrap.min.js"></script>
<style>
.center {
margin: auto;
width: 50%;
padding: 10px;
}
</style>
<?php include("core/menu.php"); ?>
</head>
<body>
<div class="jumbotron">
<h1 style="text-align: center;">Browse</h1>
<div class="row">
<?php
$conn = mysqli_connect($dbhost, $usernamedb, $password, $db);
// Check connection
if (!$conn) {
$conerror = mysqli_connect_error();
echo '<div style="margin: auto;" class="alert alert-danger" role="alert">
Connection error $conerror
</div>';
exit();
}
$sql = "SELECT * FROM posts";
$result = mysqli_query($conn, $sql);
if (mysqli_num_rows($result) > 0) {
// output data of each row
while($row = mysqli_fetch_assoc($result)) {
if($row['type'] == "music"){
echo '<div class="col-sm-3">
<div style="border: 1px solid grey; ">
<a class="center" href="view.php?id='. $row["id"] .'"><img style="width: 20%" class="card-img-top" src="img/music-icon.png" alt="'. $row["title"] .'"></a>
<div class="card-body">
<h5 class="card-title">'. strip_tags(stripslashes($row["title"])) .'</h5>
<p class="card-text">'. strip_tags(stripslashes($row["description"])) .'</p>
<p class="card-text"><p class="text-muted">posted on: '. gmdate("Y-m-d\TH:i:s\Z", $row["posttimestamp"]) .'</p>
<p class="card-text"><p class="text-muted">author: <a href="profile.php?u='. $row["author"] .'">'. $row["author"] .'</a></p></div></div></div>
';
}elseif($row['type'] == "other"){
echo '<div class="col-sm-3">
<div style="border: 1px solid grey; ">
<a class="center" href="view.php?id='. $row["id"] .'"><img style="width: 20%" class="card-img-top" src="img/other.png" alt="'. $row["title"] .'"></a>
<div class="card-body">
<h5 class="card-title">'. strip_tags(stripslashes($row["title"])) .'</h5>
<p class="card-text">'. strip_tags(stripslashes($row["description"])) .'</p>
<p class="card-text"><p class="text-muted">posted on: '. gmdate("Y-m-d\TH:i:s\Z", $row["posttimestamp"]) .'</p>
<p class="card-text"><p class="text-muted">author: <a href="profile.php?u='. $row["author"] .'">'. $row["author"] .'</a></p></div></div></div>
';
}else{
echo '<div class="col-sm-3">
<div style="border: 1px solid grey; ">
<a class="center" href="view.php?id='. $row["id"] .'"><img style="width: 20%" class="card-img-top" src="posts/'. $row["id"] .'/'. $row["id"].'.png" alt="'. $row["title"] .'"></a>
<div class="card-body">
<h5 class="card-title">'. strip_tags(stripslashes($row["title"])) .'</h5>
<p class="card-text">'. strip_tags(stripslashes($row["description"])) .'</p>
<p class="card-text"><p class="text-muted">posted on: '. gmdate("Y-m-d\TH:i:s\Z", $row["posttimestamp"]) .'</p>
<p class="card-text"><p class="text-muted">author: <a href="profile.php?u='. $row["author"] .'">'. $row["author"] .'</a></p></div></div></div>';
}
}
} else {
echo '<div style="margin: auto;" class="alert alert-info" role="alert">
No posts have been uploaded to this image board currently.
</div>';
}
?>
</div>
</div>
</body>
<footer>
<div style="border: 10px">
<center>© <?php print($copyright); ?></center>
</div>
</footer>
</html>