-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathuniqueidranges.php
163 lines (147 loc) · 5.5 KB
/
uniqueidranges.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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
<?php
require_once('access.php');
require_once('dal.php');
require_once('utils.php');
require_once('email.php');
$filter = null;
$error = null;
$message = null;
$user = null;
$person = null;
$top = false;
$top_unique_ids = null;
$dal = new DAL($opts['hn'], $opts['db'], $opts['un'], $opts['pw']);
try {
$dal->beginTransaction();
$user = $dal->selectUser();
if (isset($_GET['pending'])) {
$filter = 'Pending';
$top_unique_ids = $dal->selectUnapprovedUniqueIds();
} else if (isset($_GET['person_id'])) {
$person = $dal->selectPersonById($_GET['person_id']);
if ($person === null) throw new UserException('Profile not found.');
$filter = formatPersonName($person);
$top_unique_ids = $dal->selectUniqueIdsByPerdonId($_GET['person_id']);
} else {
$top = true;
$top_unique_ids = $dal->selectTopUniqueIds();
}
$dal->commit();
} catch (UserException $e) {
$dal->rollback();
$error = $e->getMessage();
} catch (Exception $e) {
$dal->rollback();
throw $e;
}
if (empty($top_unique_ids)) $message = 'None found.';
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
<meta name="description" content="OpenLCB ID Registry"/>
<link rel="icon" href="../../favicon.ico"/>
<title>View OpenLCB Unique ID Ranges</title>
<!-- Bootstrap core CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css"/>
<!-- Custom styles for this template -->
<link href="theme.css" rel="stylesheet"/>
</head>
<body>
<?php
include('navbar.php');
?>
<div class="container-fluid">
<h2>View OpenLCB Unique ID Ranges</h2>
<?php
if ($filter !== null) {
?>
<h3><?php echo htmlspecialchars($filter); ?></h3>
<?php
}
if ($error !== null) {
?>
<div class="alert alert-danger">
<a href="" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></a>
<?php echo htmlspecialchars($error); ?>
</div>
<?php
} else if ($message !== null) {
?>
<div class="alert alert-info">
<a href="" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></a>
<?php echo htmlspecialchars($message); ?>
</div>
<?php
} else {
?>
<div class="alert alert-info" role="alert">
This page shows the ranges of OpenLCB Unique ID's that have been assigned to date.
The numbers below are in hexadecimal.<br/>
For more information on OpenLCB, please see the <a href="https://openlcb.org/openlcb-and-lcc-documents/layout-command-control-lcc/">documentation page</a>.
For more information on OpenLCB unique ID assignment, please see the current
<a href="https://openlcb.org/wp-content/uploads/2021/08/S-9.7.0.3-UniqueIdentifiers-2021-04-25.pdf">specification</a> and
<a href="https://openlcb.org/wp-content/uploads/2021/08/TN-9.7.0.3-UniqueIdentifiers-2021-04-25.pdf">technical note</a>.
This data is also available in <a href="uniqueidrangesxml">XML</a>, and <a href="uniqueidrangesjson">JSON</a>.<br/>
'*' means that any values are accepted in that byte.
</div>
<table class="table table-condensed">
<tbody>
<tr>
<th>Range</th>
<th>Delegating organization or person</th>
<th>URL</th>
<th>Comment</th>
</tr>
<?php
foreach ($top_unique_ids as $top_unique_id) {
?>
<tr>
<td style="font-family: monospace; white-space: pre;"><a href="uniqueidrange?uniqueid_id=<?php echo $top_unique_id['uniqueid_id']; ?>"><?php echo htmlspecialchars(formatUniqueIdHex($top_unique_id)); ?></a></td>
<td><?php echo htmlspecialchars(formatPersonName($top_unique_id)); ?></td>
<td><?php echo htmlspecialchars($top_unique_id['uniqueid_url']); ?></td>
<td><?php echo htmlspecialchars($top_unique_id['uniqueid_user_comment']); ?></td>
</tr>
<?php
}
if ($top) {
foreach ($top_unique_ids as $top_unique_id) {
$sub_unique_ids = $dal->selectSubUniqueIds($top_unique_id['uniqueid_byte0_value']);
if (count($sub_unique_ids) > 0) {
?>
<tr>
<td colspan="4"><h3><?php echo htmlspecialchars($top_unique_id['uniqueid_user_comment']); ?></h3></td>
</tr>
<tr>
<th>Range</th>
<th>Delegating organization or person</th>
<th>URL</th>
<th>Comment</th>
</tr>
<?php
foreach ($sub_unique_ids as $sub_unique_id) {
?>
<tr>
<td style="font-family: monospace; white-space: pre;"><a href="uniqueidrange?uniqueid_id=<?php echo $sub_unique_id['uniqueid_id']; ?>"><?php echo htmlspecialchars(formatUniqueIdHex($sub_unique_id)); ?></a></td>
<td><?php echo htmlspecialchars(formatPersonName($sub_unique_id)); ?></td>
<td><?php echo htmlspecialchars($sub_unique_id['uniqueid_url']); ?></td>
<td><?php echo htmlspecialchars($sub_unique_id['uniqueid_user_comment']); ?></td>
</tr>
<?php
}
}
}
}
?>
</tbody>
</table>
<?php
}
?>
</div>
</body>
</html>