forked from tectronics/ChristianFlatshare
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathajaxResponses.php
More file actions
68 lines (57 loc) · 2.2 KB
/
ajaxResponses.php
File metadata and controls
68 lines (57 loc) · 2.2 KB
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
<?php
use CFS\ChurchDirectory\CFSChurchDirectory;
use CFS\GeoEncoding\CFSGeoEncoding;
use CFS\Database\CFSDatabase;
header('Content-type: application/json');
// Autoloader
require_once 'web/global.php';
if (isset($_GET['target'])) {
switch($_GET['target']) {
case 'churchInfo':
if (isset($_GET['church_id'])) {
$CFSChurchDirectory = new CFSChurchDirectory();
$result = $CFSChurchDirectory->getChurchInfo($_GET['church_id']);
if ($result === FALSE) {
return FALSE;
}
else {
print json_encode($result);
}
}
else {
return FALSE;
}
break;
case 'geoEncode':
if (isset($_GET['lat']) && isset($_GET['lng'])) {
$geoEncoder = new CFSGeoEncoding();
print $geoEncoder->getReverseLookupJSON($_GET['lat'], $_GET['lng']);
}
else {
return TRUE;
}
break;
case 'saveDefault':
if ($currentUser) {
$CFSDatabase = new CFSDatabase();
$connection = $CFSDatabase->getConnection();
$defaults = $_SESSION['search_defaults'];
$defaults[$_GET['key']] = $_GET['value'];
$sql = "UPDATE cf_users SET search_defaults = :defaults WHERE user_id = :user";
$saveDefaults = $connection->prepare($sql);
$saveDefaults->bindValue('defaults', serialize($defaults));
$saveDefaults->bindValue('user', $currentUser['user_id']);
$saveDefaults->execute();
}
$_SESSION['search_defaults'][$_GET['key']] = $_GET['value'];
break;
case 'agePreview':
// CONVERT AGES
list($min, $max) = explode('-', $_GET['age']);
$min = ageConvert($min, 'min_age');
$max = ageConvert($max, 'max_age');
$age = cleanAge($min, $max, $_GET['type']);
print json_encode($age);
break;
}
}