-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathrequest_node_info.php
63 lines (47 loc) · 1.67 KB
/
request_node_info.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
<?php
// have $_GET[nodeType/nodeID] from client request
require_once("db.php");
$con = openDB();
// get "xSnapshotURLRoot", "lSnapshotURLRoot"
$sql = "SELECT xSnapshotURLRoot, lSnapshotURLRoot FROM config";
$rows = doQuery($con, $sql);
$xSnapshotURLRoot = $rows[0]["xSnapshotURLRoot"];
$lSnapshotURLRoot = $rows[0]["lSnapshotURLRoot"];
// Case 1/2: "nodeType" = "X"
if ($_GET[nodeType] == "X") {
$sql = "SELECT name, subType, description, openPeriod,
url, snapshotURL, snapshotWidth, snapshotHeight
FROM location_node
WHERE nodeID = '$_GET[nodeID]'";
$rows = doQuery($con, $sql);
$arr["openPeriod"] = $rows[0]["openPeriod"];
$arr["url"] = $rows[0]["url"];
if ($rows[0]["snapshotURL"] == null) {
$arr["snapshotURL"] = null;
} else {
$arr["snapshotURL"] = $xSnapshotURLRoot.$rows[0]["snapshotURL"];
}
}
// Case 2/2: "nodeType" = "L"
if ($_GET[nodeType] == "L") {
$sql = "SELECT L.name, L.subType, L.description, L.operationPeriod,
LN.snapshotURL, LN.snapshotWidth, LN.snapshotHeight
FROM link AS L, link_node AS LN
WHERE LN.nodeID = '$_GET[nodeID]' AND L.linkID = LN.linkID";
$rows = doQuery($con, $sql);
$arr["operationPeriod"] = $rows[0]["operationPeriod"];
if ($rows[0]["snapshotURL"] == null) {
$arr["snapshotURL"] = null;
} else {
$arr["snapshotURL"] = $lSnapshotURLRoot.$rows[0]["snapshotURL"];
}
}
// Share parts:
$arr["name"] = $rows[0]["name"];
$arr["subType"] = $rows[0]["subType"];
$arr["description"] = $rows[0]["description"];
$arr["snapshotWidth"] = $rows[0]["snapshotWidth"];
$arr["snapshotHeight"] = $rows[0]["snapshotHeight"];
echo json_encode($arr);
mysql_close($con);
?>