forked from nickwhynot/whynotv5
-
Notifications
You must be signed in to change notification settings - Fork 0
/
model.php
100 lines (79 loc) · 2.04 KB
/
model.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
<?php
$dir = sys_get_temp_dir();
session_save_path($dir);
session_start();
include('getyelp.php');
include('getuser.php');
include('sanitise.php');
include('rank.php');
include('parse.php');
include('sort.php');
include('lastfm.php');
include('getdist.php');
include('foursqid.php');
include('foursquare.php');
include('geocode.php');
$user = $_SESSION['user'];
$lat = $_SESSION['lat'];
$long = $_SESSION['long'];
$cat = $_SESSION['cat'];
$place = $_SESSION['place'];
$radius = 2000;
$refresh = $_SESSION['refresh'];
if ($cat == 'gigs') {
if ($refresh=='true') {
$places = getlastfm($lat,$long,3);
$places = parselastfm($places);
$_SESSION['refresh'] = 'false';
} else {
$places = $_SESSION['places'];
}
} else {
//GET YELP DATA
if ($refresh=='true') {
$places = getyelpall($lat,$long,$cat,$radius);
$places = parseyelp($places);
$_SESSION['refresh'] = 'false';
} else {
$places = $_SESSION['places'];
}
}
print_r($_SESSION);
//users history
$userevents = getevents($user);
//sanitise data
//yelp
$places = sanitise($places,$userevents);
// get user tags
$usertags = gettags($user);
// weight yelp
for ($i=0 ; $i<count($places) ; $i++) {
$places[$i] = weight($places[$i],$usertags);
}
//sort yelp
$places = sortevents($places);
$places = array_values($places);
$_SESSION['places'] = $places;
$userlat = $_SESSION['userlat'];
$userlong = $_SESSION['userlong'];
//display top
$suggestion = $places[0];
$postcode = $suggestion['postcode'];
//enrich with foursquare
//geocode to get lat long
$latlong = geocodepost($postcode);
$suggestion['latlong'] = $latlong;
//get foursquare id
$foursqid = getfoursqid($latlong[0],$latlong[1],$suggestion['name']);
$suggestion['foursqid'] = $foursqid;
//get foursquare data
$foursqdata = getfoursqbus($foursqid);
//parse foursquare
$foursq = parsefoursq($foursqdata);
$suggestion = array_merge($foursq,$suggestion);
$dist = getdist($latlong[0],$latlong[1],$userlat,$userlong);
$suggestion['dist'] = $dist;
$suggestion['cat'] = $cat;
$_SESSION['suggestion'] = $suggestion;
print_r(json_encode($suggestion));
?>