-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathmain_dashbord.php
283 lines (250 loc) · 12.6 KB
/
main_dashbord.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
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
<?php require_once("includes/base.php") ?>
<?php require_once("includes/functions.php") ?>
<?php require_once("includes/connection.php") ?>
<?php require_once("backend/ifnotlogin.php") ?>
<?php
//This function will check whether the user is logged in or not. (Security function)
//session_start();
if (!(isset($_SESSION['currentuser']) && $_SESSION['currentuser'] != ''))
{
redirect_to("login.php");
}
?>
<?php
if (isset($_GET['user']))
{
$u = $_GET['user'];
}
if($u!=$username)
{
redirect_to("main_dashbord.php?user=$username");
}
?>
<link href="css/bootstrap.min.css" rel="stylesheet">
<link href="font-awesome/css/font-awesome.min.css" rel="stylesheet">
<link rel="stylesheet" type="text/css" href="http://fonts.googleapis.com/css?family=Tangerine">
<link rel="stylesheet" type="text/css" href="http://fonts.googleapis.com/css?family=Montserrat">
<!-- Page Content -->
<div class="container">
<!-- Introduction Row -->
<div class="row">
<div class="col-lg-12">
<h1 class="text-center"><font face="Montserrat">These events may interest you.</font></h1>
</div>
</div>
<div id="wrapper">
<!-- ************************ Recommended *********************************************** -->
<div class="row">
<div class="col-lg-12">
<h1 class="page-header"><span class="fa fa-compass"></span> <font face="Tangerine">Recommended for you</font></h1>
</div>
<?php
//$query="SELECT Ev_name, Ev_description,Sub_id FROM Event NATURAL JOIN Interested_in WHERE Count IN(SELECT MAX(Count) FROM Interested_in))";
//$query2="SELECT Ev_name, Ev_description,Sub_id FROM Event NATURAL JOIN Interested_in WHERE User_id=2 ORDER BY Count DESC";
$query2="SELECT User_id FROM User WHERE User_username='$username'";
$query_run2=mysql_query($query2);
$User_id=mysql_result($query_run2,0,'User_id');
$query="SELECT * FROM Event e,Interested_in i where e.Sub_id=i.Sub_id AND i.User_id=$User_id ORDER BY Count DESC";
$query_run=mysql_query($query);
$mini=min((mysql_num_rows($query_run)),4);
for ($i = 0; $i <$mini ; $i++)
{
$Ev_id = mysql_result($query_run, $i,'Ev_id');
$Ev_name=mysql_result($query_run, $i,'Ev_name');
$Ev_description=mysql_result($query_run, $i,'Ev_description');
$Sub_id=mysql_result($query_run, $i,'Sub_id');
$Ev_img=mysql_result($query_run,$i,'Ev_photo');
?>
<div class="col-lg-3 col-sm-6 text-center">
<?php
if(!is_null($Ev_img))
{
?>
<a href="event_page.php?user=<?php echo $username;?>&id=<?php echo $Ev_id;?>"><img class="img-responsive img-responsive img-center" src="<?php echo $Ev_img;?>" alt="" style="width:400px;height:200px;"></a>
<?php
}
else
{
?>
<a href="event_page.php?user=<?php echo $username;?>&id=<?php echo $Ev_id;?>"><img class="img-responsive img-responsive img-center" src="image/imagenotfound.jpg" alt="" style="width:400px;height:200px;"></a>
<?php
}
?>
<a href="event_page.php?user=<?php echo $username;?>&id=<?php echo $Ev_id;?>"><h3><font face="Montserrat"><?php echo $Ev_name ?></font></h3></a>
<p><font face="Montserrat"><?php echo $Ev_description ?></font></p>
</div>
<?php
}
?>
</div>
<!-- ************************ Popular *********************************************** -->
<div class="row">
<div class="col-lg-12">
<h1 class="page-header"><span class="fa fa-sort-amount-desc"><font face="Tangerine"> Most Popular</font></h1>
</div>
<?php
//$query="SELECT Ev_name, Ev_description,Sub_id FROM Event NATURAL JOIN Interested_in WHERE Count IN(SELECT MAX(Count) FROM Interested_in))";
//$query2="SELECT Ev_name, Ev_description,Sub_id FROM Event NATURAL JOIN Interested_in WHERE User_id=2 ORDER BY Count DESC";
$query2="SELECT User_id FROM User WHERE User_username='$username'";
$query_run2=mysql_query($query2);
$User_id=mysql_result($query_run2,0,'User_id');
$query="SELECT * FROM Event ORDER BY Ev_page_count DESC";
$query_run=mysql_query($query);
$mini=min((mysql_num_rows($query_run)),4);
for ($i = 0; $i <$mini ; $i++)
{
$Ev_id = mysql_result($query_run, $i,'Ev_id');
$Ev_name=mysql_result($query_run, $i,'Ev_name');
$Ev_description=mysql_result($query_run, $i,'Ev_description');
$Sub_id=mysql_result($query_run, $i,'Sub_id');
$Ev_img=mysql_result($query_run,$i,'Ev_photo');
?>
<div class="col-lg-3 col-sm-6 text-center">
<?php
if(!is_null($Ev_img))
{
?>
<a href="event_page.php?user=<?php echo $username;?>&id=<?php echo $Ev_id;?>"><img class="img-responsive img-responsive img-center" src="<?php echo $Ev_img;?>" alt="" style="width:400px;height:200px;"></a>
<?php
}
else
{
?>
<a href="event_page.php?user=<?php echo $username;?>&id=<?php echo $Ev_id;?>"><img class="img-responsive img-responsive img-center" src="image/imagenotfound.jpg" alt="" style="width:400px;height:200px;"></a>
<?php
}
?>
<a href="event_page.php?user=<?php echo $username;?>&id=<?php echo $Ev_id;?>"><h3><font face="Montserrat"><?php echo $Ev_name ?></font></h3></a>
<p><font face="Montserrat"><?php echo $Ev_description ?></font></p>
</div>
<?php
}
?>
</div>
<!-- ************************ Near You *********************************************** -->
<div class="row">
<div class="col-lg-12">
<h1 class="page-header"><span class="fa fa-signal"> <font face="Tangerine">Near You (Within 400 km radius)</font></h1>
</div>
<?php
$query2="SELECT User_address FROM User WHERE User_username = '$username'";
$query_run2=mysql_query($query2);
$from=mysql_result($query_run2,0,'User_address');
if(!empty($from))
{
$qr = "SELECT * FROM Event";
$qr2=mysql_query($qr);
$range=400000;
for ($i = 0; $i < 2/*mysql_num_rows($qr2)*/; $i++)
{
$to=mysql_result($qr2,$i,'Ev_location');
$from = urlencode($from);
$to = urlencode($to);
$data = file_get_contents("http://maps.googleapis.com/maps/api/distancematrix/json?origins=$from&destinations=$to&language=en-EN&sensor=false");
$data = json_decode($data);
$distance1 = 0;
foreach($data->rows[0]->elements as $road)
{
$distance1 += $road->distance->value;
}
if($distance1<=$range)
{
$Ev_id = mysql_result($qr2, $i,'Ev_id');
$Ev_name=mysql_result($qr2,$i,'Ev_name');
$Ev_description=mysql_result($qr2, $i,'Ev_description');
$Sub_id=mysql_result($qr2, $i,'Sub_id');
$Ev_img=mysql_result($query_run,$i,'Ev_photo');
if ($Ev_img == " ")
{
$Ev_img = "image/imagenotfound.jpg";
}
$distance1=$distance1/1000;
?>
<div class="col-lg-3 col-sm-6 text-center">
<?php
if(!is_null($Ev_img))
{
?>
<a href="/event_page.php?user=<?php echo $username;?>&id=<?php echo $Ev_id;?>"><img class="img-responsive img-responsive img-center" src="<?php echo $Ev_img;?>" alt="" style="width:400px;height:200px;"></a>
<?php
}
else
{
?>
<a href="/event_page.php?user=<?php echo $username;?>&id=<?php echo $Ev_id;?>"><img class="img-responsive img-responsive img-center" src="image/imagenotfound.jpg" alt="" style="width:400px;height:200px;"></a>
<?php
}
?>
<a href="/event_page.php?user=<?php echo $username;?>&id=<?php echo $Ev_id;?>"><h3><font face="Montserrat"><?php echo $Ev_name ?></font></h3></a>
<p><font face="Montserrat"><?php echo $Ev_description ?></font></p>
<p><font face="Montserrat"><?php echo "Distance: ".$distance1." km from you"; ?></font></p>
</div>
<?php
}
}
}
else
{
echo "Update Your profile to use this feature.";
}
?>
</div>
<!-- ************************ History *********************************************** -->
<div class="row">
<div class="col-lg-12">
<h1 class="page-header"><span class="fa fa-history"> <font face="Tangerine">Past Events</font></h1>
</div>
<?php
$query2=mysql_query("SELECT Ev_id FROM Past_Events WHERE User_id = '$User_id'");
if(!$query2)
{
echo mysql_error();
}
$numrows = mysql_num_rows($query2);
for ($i = 0; $i <$numrows ; $i++)
{
$row = mysql_fetch_array($query2);
$id = $row['Ev_id'];
$q = mysql_query("SELECT * FROM Event WHERE Ev_id = $id");
if(!$q)
{
echo mysql_error();
}
$row2 = mysql_fetch_array($q);
$Ev_name = $row2['Ev_name'];
$Ev_description = $row2['Ev_description'];
$Sub_id = $row2['Sub_id'];
$Ev_img=mysql_result($query_run,$i,'Ev_photo');
/*$Ev_name=mysql_result($query_run, $i,'Ev_name');
$Ev_description=mysql_result($query_run, $i,'Ev_description');
$Sub_id=mysql_result($query_run, $i,'Sub_id');*/
?>
<div class="col-lg-3 col-sm-6 text-center">
<?php
if(!is_null($Ev_img))
{
?>
<a href="/event_page.php?user=<?php echo $username;?>&id=<?php echo $Ev_id;?>"><img class="img-responsive img-responsive img-center" src="<?php echo $Ev_img;?>" alt="" style="width:400px;height:200px;"></a>
<?php
}
else
{
?>
<a href="/event_page.php?user=<?php echo $username;?>&id=<?php echo $Ev_id;?>"><img class="img-responsive img-responsive img-center" src="image/imagenotfound.jpg" alt="" style="width:400px;height:200px;"></a>
<?php
}
?>
<a href="/event_page.php?user=<?php echo $username;?>&id=<?php echo $id;?>"><h3><font face="Montserrat"><?php echo $Ev_name ?></font></h3></a>
<p><font face="Montserrat"><?php echo $Ev_description ?></font></p>
</div>
<?php
}
?>
</div>
<!--************************************************************************************************* -->
</div>
<!-- /$wrapper -->
</div>
<!-- /.container -->
<hr>
<?php require_once("includes/footer.php") ?>