-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgetData.php
More file actions
102 lines (86 loc) · 2.99 KB
/
getData.php
File metadata and controls
102 lines (86 loc) · 2.99 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
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
<?php
$res["status"] = "OK";
$res["data"] = array();
include './config.php';
if (isset($_REQUEST["id"])) {
$id = $_REQUEST["id"];
$sqli = "SELECT * FROM `cloud` WHERE id =" . $id;
$result = mysqli_query($con, $sqli);
if ($result) {
$row = mysqli_fetch_array($result);
foreach ($row as $key => $value) {
$row[$key] = utf8_encode($value);
}
array_push($res["data"], $row);
}
} elseif (isset($_REQUEST["SearchUp"])) {
//"loc=" + slct + "&cmpt=" + cmpt + "&os=" + ostrg + "&bs=" + bstrg + "&cdn=" + cdn + "&as=" + atosclng + "&sl=" + srvrls;
$loc = my_htmlentities($_REQUEST["loc"]);
$cmpt = $_REQUEST["cmpt"];
$os = $_REQUEST["os"];
$bs = $_REQUEST["bs"];
$cdn = $_REQUEST["cdn"];
$as = $_REQUEST["as"];
$sl = $_REQUEST["sl"];
$sql = "SELECT id,Company AS c,Region AS r, Location AS l,Lon AS lat, Lat AS lon FROM `cloud` WHERE Location = '$loc'";
if ($loc == -1) {
$sql = "SELECT id,Company AS c,Region AS r, Location AS l,Lon AS lat, Lat AS lon FROM `cloud` WHERE Location != ''";
}
if ($cmpt != 'false') {
$sql .= " AND Compute != ''";
}
if ($os != 'false') {
$sql .= " AND Object_Storage != ''";
}
if ($bs != 'false') {
$sql .= " AND Block_Storage != ''";
}
if ($cdn != 'false') {
$sql .= " AND CDN != ''";
}
if ($as != 'false') {
$sql .= " AND Auto_Scaling != ''";
}
if ($sl != 'false') {
$sql .= " AND Serverless_compute != ''";
}
$result = mysqli_query($con, $sql);
if ($result) {
while ($row = mysqli_fetch_array($result)) {
array_push($res["data"], array("id" => $row["id"], "com" => utf8_encode($row["c"]), "reg" => utf8_encode($row["r"]), "loc" => utf8_encode($row["l"]), "lat" => $row["lat"], "lon" => $row["lon"]));
}
}
} else {
$sql = "SELECT id,Company AS c,Region AS r, Location AS l,Lon AS lat, Lat AS lon FROM `cloud`";
$result = mysqli_query($con, $sql);
if ($result) {
while ($row = mysqli_fetch_array($result)) {
array_push($res["data"], array("id" => $row["id"], "com" => utf8_encode($row["c"]), "reg" => utf8_encode($row["r"]), "loc" => utf8_encode($row["l"]), "lat" => $row["lat"], "lon" => $row["lon"]));
}
}
}
//$retD = json_encode($res, JSON_PRETTY_PRINT);
mysqli_close($con);
echo json_encode($res);
//if (json_last_error() == 5) {
// $clean = utf8ize($res);
// echo json_encode($clean);
//} else {
// echo $retD;
//}
function my_htmlentities($input) {
$string = htmlentities($input, ENT_NOQUOTES, 'UTF-8');
$string = str_replace('€', chr(128), $string);
$string = html_entity_decode($string, ENT_NOQUOTES, 'ISO-8859-15');
return $string;
}
function utf8ize($mixed) {
if (is_array($mixed)) {
foreach ($mixed as $key => $value) {
$mixed[$key] = utf8ize($value);
}
} else if (is_string($mixed)) {
return utf8_encode($mixed);
}
return $mixed;
}