-
Notifications
You must be signed in to change notification settings - Fork 0
/
Home.php
228 lines (218 loc) · 7.33 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
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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
<?php
include ("DBconnect.php");
include ("functions.php");
session_start();
if(!isset($_SESSION['id'])){
redirect('Login.php');
}
$current_user_id = $_SESSION['id'];
$current_username = $_SESSION['username'];
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></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="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
<style>
.navbar.navTop{
font-weight: lighter;
padding-top: 15px;
}
.navbar.navBottom{
font-weight: lighter;
padding-bottom: 2px;
}
.navBottom .navbar-nav{
width: 100%;
margin: 0 auto;
}
.navBottom .navbar-nav .nav-item{
width: 20%;
}
.navBottom .navbar-nav .nav-item .nav-link{
text-align: center;
}
.navbar-toggler{
float: right;
}
.navbar-brand{
float: left;
}
.container-fluid{
background-color: #f8f9fa !important;
min-height: 91vh;
padding-bottom: 56px;
}
.row{
background-color: #f8f9fa !important;
}
.card-deck{
margin: auto;
}
.card{
width: 100%;
margin: 10px auto;
box-shadow: 0px 0px 3px 1px rgba(0,0,0,0.15);
}
.card-header{
background-color: white;
}
.card-profile-pic{
width: 30px;
height: 30px;
border-radius: 15px;
margin-right: 10px;
float: left;
}
.authorname{
font-weight: bold;
float: left;
margin-top: 3px;
text-decoration: none;
color: black;
}
.card-img-top{
min-height: 100%;
min-width: 100%;
max-height: 100%;
min-width: 100%;
text-align: center;
display: inline-block;
}
.postImage{
width: auto;
height: auto;
max-width: 100%;
max-height: 100%;
vertical-align: middle;
margin: 0 auto;
}
.card-body a{
text-decoration: none;
color: #212529;
}
.likecount{
margin-right: 2px;
}
.caption{
margin-right: 30px;
line-height: 1.15;
font-size: 14px;
}
.dateText{
margin-bottom: 7px;
}
</style>
<title>Home</title>
<link rel="shortcut icon" href="assets/images/PicturesqueLogo.png" type="image/png">
</head>
<body>
<nav class="navbar navTop sticky-top navbar-expand-lg navbar-light bg-light">
<a class="navbar-brand" href="./Home.php">
<img src="assets/images/PicturesqueLogo.png" width="30" height="30" class="d-inline-block align-top" alt="">
Picturesque
</a>
<form class="form-inline my-lg-0" action="Logout.php">
<?php
if(!isset($_SESSION['username'])){
echo '<button class="btn btn-outline-success my-sm-0" type="submit" style="width: 100%>Login</button>';
}
else{
echo '<button class="btn btn-outline-info my-sm-0" type="submit" style="width: 100%">Logout</button>';
}
?>
</form>
</nav>
<div class="container-fluid">
<div class = "row">
<div class = "offset-xs-2 col-xs-8 offset-md-4 col-md-4 maincontainer">
<!-- Space for main content to be loaded -->
</div>
</div>
</div>
<nav class="navbar navBottom fixed-bottom navbar-dark bg-dark navbar-expand">
<ul class="navbar-nav">
<li class="nav-item">
<a class="nav-link" href="Home.php">
<i class="material-icons md-light">home</i>
</a>
</li>
<li class="nav-item">
<a class="nav-link" href="Search.php">
<i class="material-icons md-light">search</i>
</a>
</li>
<li class="nav-item">
<a class="nav-link" href="Upload.php">
<i class="material-icons md-light">add_box</i>
</a>
</li>
<li class="nav-item">
<a class="nav-link" href="Requests.php">
<i class="material-icons md-light">supervisor_account</i>
</a>
</li>
<li class="nav-item">
<a class="nav-link" href="Profile.php">
<i class="material-icons md-light">account_circle</i>
</a>
</li>
</ul>
</nav>
<script type="text/javascript">
var start = 0;
var limit = 5;
var reachedMax = false;
function getData() {
if (reachedMax)
return;
$.ajax({
url: 'HomeData.php',
method: 'POST',
data: {
getData: 1,
start: start,
limit: limit
},
success: function(response) {
if (response == "reachedMax")
reachedMax = true;
else {
start += limit;
$(".maincontainer").append(response);
}
}
});
}
$(window).scroll(function () {
if ($(window).scrollTop() == $(document).height() - $(window).height())
getData();
});
$(document).ready(function(){
getData();
setTimeout(function() {
$('.like').click(function(e){
var post_id = $(this).attr('id');
var url = "LikeKaro.php?post_id="+post_id;
$.getJSON(url, function(result) {
//Just inform the server about the like. No response handling required.
});
if($(this).hasClass('liked')){
$(this).attr('src', 'assets/images/PicturesqueLike.png').removeClass('liked');
$(this).next('.likecount').text((parseInt($(this).next('.likecount').text())-1));
}
else {
$(this).attr('src', 'assets/images/Liked.png').addClass('liked');
$(this).next('.likecount').text((parseInt($(this).next('.likecount').text())+1));
}
});
}, 200);
});
</script>
</body>
</html>