-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgetData.php
More file actions
62 lines (44 loc) · 1.29 KB
/
getData.php
File metadata and controls
62 lines (44 loc) · 1.29 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
<?php
$all_actions = array("fetch");
$action = null;
$data = $_GET;
if (isset($data)) {
$action = $data['action'];
}
$params = null;
if (isset($data['params'])) {
$params = $data['params'];
}
header('Content-Type: application/json');
$response["error"] = false;
if (in_array($action, $all_actions) && is_json($params)){
require_once 'db_Functions.php';
$db = new DB_Functions();
if ($action =="fetch") {
$lat1 = $params["lat"];
$lat2 = $params["lat"];
$lng1 = $params["lng"];
$lng2 = $params["lng"];
$where = "(LONGITUDE >= $lat1 AND LONGITUDE <= $lat2) AND (LATITUDE >= $lng1 AND LATITUDE <= $lng2)";
$where = "1=1";
$getallLocations = $db->getRows("SELECT * FROM `GEO_DATA` WHERE ID in(14,11,6,16,15) order by LONGITUDE desc limit 5");
$response["data"] = $getallLocations;
}
} else {
$response["error"] = true;
$response["error_msg"] = "either action or params(json object) are not send.";
}
function is_json($str){
try {
if(!is_array($str))
{
$result = json_decode($str) ;
}
return true;
} catch (Exception $e) {
return false;
}
//return json_decode($str) != null;
}
echo json_encode($response);
?>