/
basicSearchOutput.php
383 lines (299 loc) · 9.29 KB
/
basicSearchOutput.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
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
<?php
session_start ();
require_once 'connection.php';
require_once 'foursquare.php';
$data_foursq = new Foursquare ();
?>
<!DOCTYPE html>
<head>
<script
src="http://maps.googleapis.com/maps/api/js?key=AIzaSyCqt0V2s8VlZHYEjC2k1k_rWhcSDVFxwfg">
</script>
<script>
var bounds = new google.maps.LatLngBounds();
function addMarkers(locations) {
var marker, i;
var myCenter =new google.maps.LatLng(40.73961668,-74.030238890);
var mapProp = {
center:myCenter,
zoom:6,
mapTypeId:google.maps.MapTypeId.ROADMAP
};
var map=new google.maps.Map(document.getElementById("googleMap"),mapProp);
// alert("myCenter " + locations[0].name);
for (i = 0; i < locations.length; i++) {
createMarker(locations[i],map);
}
}
function createMarker(location, map) {
var contentString = "<h3>" + location.name + "</h3> " +
"<p>" + location.address + ",</p>" +
"<p>" + location.city + ", " + location.state + ", " + location.zipcode + "</p> " +
"<p>" + location.phone + "</p>";
var marker = new google.maps.Marker({
position: new google.maps.LatLng(location.lat, location.lng),
map: map,
});
var infowindow = new google.maps.InfoWindow({
content:contentString
});
google.maps.event.addListener(marker, 'click', function() {
infowindow.open(map,marker);
});
bounds.extend(marker.position);
map.setCenter(bounds.getCenter());
map.fitBounds(bounds);
}
</script>
<meta charset="utf-8">
<title>Rendezvous - Search Output</title>
<link href='http://fonts.googleapis.com/css?family=Arizonia'
rel='stylesheet' type='text/css'>
<link rel="stylesheet"
href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
<style>
h2 {
font: 200 100px/1.0 'Arizonia', Helvetica, sans-serif;
color: #FFFFFF;
text-shadow: 4px 4px 0px rgba(0, 0, 0, 0.1);
}
body {
background-image: url("BackgroundCover.jpg");
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}
html {
width: 100%;
height: 100%;
margin: 0;
}
.panel-info {
opacity: 0.95;
margin-top: 30px;
width: 1300px;
margin: 30px auto;
}
#panel-body {
overflow: hidden;
}
#contents {
width: 750px;
min-height: 700px;
margin-left: 475px;
}
#forms {
width: 450px;
min-height: 700px;
float: left;
}
#googleMap {
width: 750px;
min-height: 400px;
}
#output {
margin-top: 25px;
width: 750px;
min-height: 300px;
overflow-y: scroll;
max-height: 300px;
}
.form-group {
width: 1000px;
padding-left: 60px;
}
.form-group label {
color: #428bca;
font-weight: bold;
padding: 4px;
font-size: 16px;
font-family: Georgia;
}
h4 {
font-style: italic;
}
h3 {
color: #428bca;
}
input, select {
font-weight: bold;
}
h1 {
color: #428bca;
font-style: italic;
font-family: "Lucida Sans Unicode", "Lucida Grande", sans-serif;
}
.btn-default {
position:absolute;
top:30px;
right:50px;
color: #428bca;
font-weight: bold;
}
.btn-success {
position:absolute;
top:30px;
right:150px;
color: #428bca;
font-weight: bold;
background: white;
border: white;
}
.btn-success:hover {
background: #E8E8E8;
color: black;
}
.btn-info {
position:absolute;
top:30px;
right:150px;
color: #428bca;
font-weight: bold;
background: white;
border: white;
}
.btn-info:hover {
background: #E8E8E8;
color: black;
}
</style>
</head>
<body>
<div id="header">
<h2> Rendezvous...</h2>
<h4>
<font color="white"> Meet your people at
your chosen places</font>
</h4>
</div>
<?php
if (isset ( $_SESSION ['login'] )) {
echo "<a href='logout.php' class='btn btn-default'>Logout</a>";
echo "<a href='basicsearch.php' class='btn btn-success'>Home</a>";
}
else
echo "<a href='homepage.php' class='btn btn-info'>Home</a>";
?>
<script type="text/javascript">
function vali(){
var venue = document.basicSearchForm.venue;
var city = document.basicSearchForm.city;
errmsg="";
if((venue.value == "") )
{
venue.style.background = 'Yellow';
errmsg += "Please enter a venue name.\n";
}
if((city.value == "") )
{
city.style.background = 'Yellow';
errmsg += "please enter a city.\n";
}
if(errmsg.length > 0){
alert("You must provide the following fields:\n" +errmsg);
return false;
}
return true;
}
</script>
<div class="panel panel-info" id="panel-info">
<h1 align="center">Search Results- Basic Search</h1>
<div class="panel-body" id="panel-body">
<div id="forms">
<div class="form-group" id="content">
<form method="POST" action="" name="basicSearchForm" id="basicSearchForm" class="form-horizontal" onsubmit="return vali()">
<label>Venue Name<font color="red">*</font> <br /> <input type="search" name="venue" id="venue" class="form-control" value="<?php if(isset($_POST['venue'])){ echo $_POST['venue'];} else {if(isset($_SESSION['venue'])){ echo $_SESSION['venue'];}}?>" /></label> <br /> <br />
<label>City<font color="red">*</font> <br /> <input type="search" name="city" id="city" class="form-control" value="<?php if(isset($_POST['city'])){ echo $_POST['city'];} else {if(isset($_SESSION['city'])){ echo $_SESSION['city'];}}?>"/></label> <br /> <br /><input type="submit" name="basicSearch" id="basicSearch" class="btn btn-primary" value="Search" />
<font size="3px" ><a href="advancedsearch.php">Advanced Search</a></font>
<br /> <br />
<?php
require_once 'rendezvousClass.php';
$data_rendezvous = new Rendezvous ();
$uid = $data_rendezvous->getUserId($_SESSION['username']);
$data_rendezvous->getSaveMeetSearch($uid);
?>
</form>
</div>
<?php
if(isset($_SESSION['login'])) {
require_once 'rendezvousClass.php';
$data_rendezvous = new Rendezvous ();
$uid = $data_rendezvous->getUserId($_SESSION['username']);
$basicResult = $data_rendezvous->getSavedBasicSearch($uid);
echo '<br/><br/><table class="table">';
echo "<h3>Last Searches</h3>";
for($i = 0; $i < sizeof($basicResult); $i++) {
$encryption = new Encryption();
$query = "venue=".$encryption->encode($basicResult[$i]['venueName']).
"&city=".$encryption->encode($basicResult[$i]['city']);
//$l_encrypted = $encryption->encode($query);
echo '<td> <a href="basicSearchOutput.php?' . $query . '">'. $basicResult [$i]['displayName'] . '</a></td></tr>';
}
echo '</table>';
}
?>
</div>
<div id="contents" >
<div id="googleMap"></div>
<div id="output">
<?php
function sendNameCity($data_foursq, $name, $city) {
$result = $data_foursq->NameCity ( $name, $city);
$js_result_array = json_encode($result);
if(is_array($result) == true) {
echo '<script type="text/javascript"> addMarkers('. $js_result_array .');</script>';
for($i = 0; $i < sizeof($result); $i++) {
echo "<h3>". $result[$i]['name']." </h3><br>";
echo $result[$i]['address'].", ";
echo $result[$i]['city'].", ".$result[$i]['state'].", ".$result[$i]['zipcode']." <br>";
echo $result[$i]['phone']." <br> <a href=".$result[$i]['url']."> ".$result[$i]['url'] ."</a> <br>";
echo "<label>Rating </label> ". $result[$i]['rating']."<br>";
echo "<hr>";
}
}
else {
echo "<h3>". $result." </h3><br>";
}
}
if (isset ( $_POST ['basicSearch'] )) {
if (($_POST ['city'] != "") && ($_POST ['venue'] != "")) {
if (isset ( $_POST ['venue'] ) && isset ( $_POST ['city'] )) {
$venue = strip_tags ( trim ( $_POST ['venue'] ) );
$city = strip_tags ( trim ( $_POST ['city'] ) );
$venue = preg_replace('/\s+/', ' ', $venue);
$city = preg_replace('/\s+/', ' ', $city);
$_SESSION['venue'] = $venue;
$_SESSION['city'] = $city;
//if(isset($_POST['login'])) {
$uid1 = $data_rendezvous->getUserId($_SESSION['username']);
$displayName = "$venue, $city";
$data_rendezvous->insertBasicSearch($uid1, $venue, $city, $displayName);
//}
}
}
}
if(isset($_GET['venue']) && isset($_GET['city']) ) {
$encryption = new Encryption();
$venue = $encryption->decode($_GET['venue']);
$city = $encryption->decode($_GET['city']);
unset( $_GET['venue']);
unset($_GET['city']);
sendNameCity($data_foursq, $venue, $city);
}
if (isset($_SESSION['venue']) && isset($_SESSION['city'])) {
$venue = ( trim ( $_SESSION['venue']));
$venue = strip_tags ( $venue );
$city = ( trim ( $_SESSION['city']));
$city = strip_tags ( $city );
$venue = preg_replace("/\s+/", " ", $venue);
$city = preg_replace("/\s+/", " ", $city);
unset( $_SESSION['venue']);
unset($_SESSION['city']);
sendNameCity($data_foursq, $venue, $city);
}
?>
</body>
</html>