Commit | Line | Data |
---|---|---|
b325120a | 1 | <?php |
e673ee24 DO |
2 | /* |
3 | * | |
4 | * This file contains frontend functions for RackTables. | |
5 | * | |
6 | */ | |
7 | ||
9c0b0016 DO |
8 | // Interface function's special. |
9 | $nextorder['odd'] = 'even'; | |
10 | $nextorder['even'] = 'odd'; | |
11 | ||
52c836b1 DO |
12 | // address allocation type |
13 | $aat = array | |
14 | ( | |
15 | 'regular' => 'Connected', | |
16 | 'virtual' => 'Loopback', | |
17 | 'shared' => 'Shared', | |
18 | 'router' => 'Router', | |
19 | ); | |
beb9e88a | 20 | // address allocation code, IPv4 addresses and objects view |
52c836b1 DO |
21 | $aac = array |
22 | ( | |
23 | 'regular' => '', | |
24 | 'virtual' => '<strong>L</strong>', | |
25 | 'shared' => '<strong>S</strong>', | |
26 | 'router' => '<strong>R</strong>', | |
27 | ); | |
beb9e88a DO |
28 | // address allocation code, IPv4 networks view |
29 | $aac2 = array | |
30 | ( | |
31 | 'regular' => '', | |
32 | 'virtual' => '<strong>L:</strong>', | |
29025f8e | 33 | 'shared' => '<strong>S:</strong>', |
beb9e88a DO |
34 | 'router' => '<strong>R:</strong>', |
35 | ); | |
52c836b1 | 36 | |
7056988c DO |
37 | // Let's have it here, so extensions can add their own images. |
38 | $image = array(); | |
39 | $image['error']['path'] = 'pix/error.png'; | |
40 | $image['error']['width'] = 76; | |
41 | $image['error']['height'] = 17; | |
42 | $image['logo']['path'] = 'pix/defaultlogo.png'; | |
43 | $image['logo']['width'] = 210; | |
44 | $image['logo']['height'] = 40; | |
45 | $image['rackspace']['path'] = 'pix/racks.png'; | |
46 | $image['rackspace']['width'] = 218; | |
47 | $image['rackspace']['height'] = 200; | |
48 | $image['objects']['path'] = 'pix/server.png'; | |
49 | $image['objects']['width'] = 218; | |
50 | $image['objects']['height'] = 200; | |
e1ae3fb4 AD |
51 | $image['files']['path'] = 'pix/files.png'; |
52 | $image['files']['width'] = 218; | |
53 | $image['files']['height'] = 200; | |
7056988c DO |
54 | $image['ipv4space']['path'] = 'pix/addressspace.png'; |
55 | $image['ipv4space']['width'] = 218; | |
56 | $image['ipv4space']['height'] = 200; | |
57 | $image['ipv4slb']['path'] = 'pix/slb.png'; | |
58 | $image['ipv4slb']['width'] = 218; | |
59 | $image['ipv4slb']['height'] = 200; | |
60 | $image['config']['path'] = 'pix/configuration.png'; | |
61 | $image['config']['width'] = 218; | |
62 | $image['config']['height'] = 200; | |
63 | $image['reports']['path'] = 'pix/report.png'; | |
64 | $image['reports']['width'] = 218; | |
65 | $image['reports']['height'] = 200; | |
e1ae3fb4 AD |
66 | $image['download']['path'] = 'pix/download.png'; |
67 | $image['download']['width'] = 16; | |
68 | $image['download']['height'] = 16; | |
08cd1902 AD |
69 | $image['DOWNLOAD']['path'] = 'pix/download-big.png'; |
70 | $image['DOWNLOAD']['width'] = 32; | |
71 | $image['DOWNLOAD']['height'] = 32; | |
5ccd99a0 DO |
72 | $image['plug']['path'] = 'pix/tango-network-wired.png'; |
73 | $image['plug']['width'] = 16; | |
74 | $image['plug']['height'] = 16; | |
75 | $image['cut']['path'] = 'pix/tango-edit-cut-16x16.png'; | |
76 | $image['cut']['width'] = 16; | |
77 | $image['cut']['height'] = 16; | |
78 | $image['CUT']['path'] = 'pix/tango-edit-cut-32x32.png'; | |
79 | $image['CUT']['width'] = 32; | |
80 | $image['CUT']['height'] = 32; | |
7056988c DO |
81 | $image['add']['path'] = 'pix/tango-list-add.png'; |
82 | $image['add']['width'] = 16; | |
83 | $image['add']['height'] = 16; | |
a685a26a DO |
84 | $image['ADD']['path'] = 'pix/tango-list-add-big.png'; |
85 | $image['ADD']['width'] = 32; | |
86 | $image['ADD']['height'] = 32; | |
7056988c DO |
87 | $image['delete']['path'] = 'pix/tango-list-remove.png'; |
88 | $image['delete']['width'] = 16; | |
89 | $image['delete']['height'] = 16; | |
d3c27c5c | 90 | $image['destroy']['path'] = 'pix/tango-user-trash-16x16.png'; |
1bdc2bfc DO |
91 | $image['destroy']['width'] = 16; |
92 | $image['destroy']['height'] = 16; | |
d3c27c5c | 93 | $image['nodestroy']['path'] = 'pix/tango-user-trash-16x16-gray.png'; |
1bdc2bfc DO |
94 | $image['nodestroy']['width'] = 16; |
95 | $image['nodestroy']['height'] = 16; | |
8bc5d1e4 DO |
96 | $image['NODESTROY']['path'] = 'pix/tango-user-trash-32x32-gray.png'; |
97 | $image['NODESTROY']['width'] = 32; | |
98 | $image['NODESTROY']['height'] = 32; | |
d3c27c5c | 99 | $image['DESTROY']['path'] = 'pix/tango-user-trash-32x32.png'; |
97b1f33b DO |
100 | $image['DESTROY']['width'] = 32; |
101 | $image['DESTROY']['height'] = 32; | |
7056988c DO |
102 | $image['nodelete']['path'] = 'pix/tango-list-remove-shadow.png'; |
103 | $image['nodelete']['width'] = 16; | |
104 | $image['nodelete']['height'] = 16; | |
7056988c DO |
105 | $image['inservice']['path'] = 'pix/tango-emblem-system.png'; |
106 | $image['inservice']['width'] = 16; | |
107 | $image['inservice']['height'] = 16; | |
108 | $image['notinservice']['path'] = 'pix/tango-dialog-error.png'; | |
109 | $image['notinservice']['width'] = 16; | |
110 | $image['notinservice']['height'] = 16; | |
7056988c DO |
111 | $image['find']['path'] = 'pix/tango-system-search.png'; |
112 | $image['find']['width'] = 16; | |
113 | $image['find']['height'] = 16; | |
7056988c DO |
114 | $image['next']['path'] = 'pix/tango-go-next.png'; |
115 | $image['next']['width'] = 32; | |
116 | $image['next']['height'] = 32; | |
117 | $image['prev']['path'] = 'pix/tango-go-previous.png'; | |
118 | $image['prev']['width'] = 32; | |
119 | $image['prev']['height'] = 32; | |
120 | $image['clear']['path'] = 'pix/tango-edit-clear.png'; | |
121 | $image['clear']['width'] = 16; | |
122 | $image['clear']['height'] = 16; | |
61a61189 DO |
123 | $image['CLEAR']['path'] = 'pix/tango-edit-clear-big.png'; |
124 | $image['CLEAR']['width'] = 32; | |
125 | $image['CLEAR']['height'] = 32; | |
f3d274bf DO |
126 | $image['CLEAR gray']['path'] = 'pix/tango-edit-clear-gray-32x32.png'; |
127 | $image['CLEAR gray']['width'] = 32; | |
128 | $image['CLEAR gray']['height'] = 32; | |
7056988c DO |
129 | $image['save']['path'] = 'pix/tango-document-save.png'; |
130 | $image['save']['width'] = 16; | |
131 | $image['save']['height'] = 16; | |
132 | $image['SAVE']['path'] = 'pix/tango-document-save-big.png'; | |
133 | $image['SAVE']['width'] = 32; | |
134 | $image['SAVE']['height'] = 32; | |
135 | $image['create']['path'] = 'pix/tango-document-new.png'; | |
136 | $image['create']['width'] = 16; | |
137 | $image['create']['height'] = 16; | |
138 | $image['CREATE']['path'] = 'pix/tango-document-new-big.png'; | |
139 | $image['CREATE']['width'] = 32; | |
140 | $image['CREATE']['height'] = 32; | |
141 | $image['DENIED']['path'] = 'pix/tango-dialog-error-big.png'; | |
142 | $image['DENIED']['width'] = 32; | |
143 | $image['DENIED']['height'] = 32; | |
d28d7f4d DO |
144 | $image['apply']['path'] = 'pix/tango-emblem-system.png'; |
145 | $image['apply']['width'] = 16; | |
146 | $image['apply']['height'] = 16; | |
737a3f72 DO |
147 | $image['node-collapsed']['path'] = 'pix/node-collapsed.png'; |
148 | $image['node-collapsed']['width'] = 16; | |
149 | $image['node-collapsed']['height'] = 16; | |
150 | $image['node-expanded']['path'] = 'pix/node-expanded.png'; | |
151 | $image['node-expanded']['width'] = 16; | |
152 | $image['node-expanded']['height'] = 16; | |
fec0c8da DO |
153 | $image['node-expanded-static']['path'] = 'pix/node-expanded-static.png'; |
154 | $image['node-expanded-static']['width'] = 16; | |
155 | $image['node-expanded-static']['height'] = 16; | |
09620506 DO |
156 | $image['dragons']['path'] = 'pix/mitsudragon.png'; |
157 | $image['dragons']['width'] = 125; | |
158 | $image['dragons']['height'] = 21; | |
b1a970c7 DO |
159 | $image['LB']['path'] = 'pix/loadbalancer.png'; |
160 | $image['LB']['width'] = 32; | |
161 | $image['LB']['height'] = 32; | |
162 | $image['RS pool']['path'] = 'pix/serverpool.png'; | |
163 | $image['RS pool']['width'] = 48; | |
164 | $image['RS pool']['height'] = 16; | |
165 | $image['VS']['path'] = 'pix/servicesign.png'; | |
166 | $image['VS']['width'] = 39; | |
167 | $image['VS']['height'] = 62; | |
8b3874a5 DO |
168 | $image['router']['path'] = 'pix/router.png'; |
169 | $image['router']['width'] = 32; | |
170 | $image['router']['height'] = 32; | |
0b9c98d7 DO |
171 | $image['ATTACH']['path'] = 'pix/crystal-attach-32x32.png'; |
172 | $image['ATTACH']['width'] = 32; | |
173 | $image['ATTACH']['height'] = 32; | |
7a0f5847 DO |
174 | $image['favorite']['path'] = 'pix/tango-emblem-favorite.png'; |
175 | $image['favorite']['width'] = 16; | |
176 | $image['favorite']['height'] = 16; | |
4f12d88f DO |
177 | $image['computer']['path'] = 'pix/tango-computer.png'; |
178 | $image['computer']['width'] = 16; | |
179 | $image['computer']['height'] = 16; | |
0b9c98d7 DO |
180 | $image['empty file']['path'] = 'pix/crystal-file-empty-32x32.png'; |
181 | $image['empty file']['width'] = 32; | |
182 | $image['empty file']['height'] = 32; | |
183 | $image['text file']['path'] = 'pix/crystal-file-text-32x32.png'; | |
184 | $image['text file']['width'] = 32; | |
185 | $image['text file']['height'] = 32; | |
186 | $image['image file']['path'] = 'pix/crystal-file-image-32x32.png'; | |
187 | $image['image file']['width'] = 32; | |
188 | $image['image file']['height'] = 32; | |
189 | $image['NET']['path'] = 'pix/crystal-network-32x32.png'; | |
190 | $image['NET']['width'] = 32; | |
191 | $image['NET']['height'] = 32; | |
19dac9c3 DO |
192 | $image['USER']['path'] = 'pix/crystal-edit-user-32x32.png'; |
193 | $image['USER']['width'] = 32; | |
194 | $image['USER']['height'] = 32; | |
7056988c | 195 | |
e5c4506d DO |
196 | // This may be populated later onsite, report rendering function will use it. |
197 | // See the $systemreport for structure. | |
198 | $localreports = array(); | |
9db67d95 DO |
199 | $CodePressMap = array |
200 | ( | |
201 | 'sql' => 'sql', | |
202 | 'php' => 'php', | |
203 | 'html' => 'html', | |
204 | 'css' => 'css', | |
205 | 'js' => 'javascript', | |
206 | ); | |
e5c4506d | 207 | |
8d4f7d18 DO |
208 | $attrtypes = array |
209 | ( | |
210 | 'uint' => '[U] unsigned integer', | |
211 | 'float' => '[F] floating point', | |
212 | 'string' => '[S] string', | |
213 | 'dict' => '[D] dictionary record' | |
214 | ); | |
215 | ||
529eac25 DO |
216 | // Rack thumbnail image width summands: "front", "interior" and "rear" elements w/o surrounding border. |
217 | $rtwidth = array | |
218 | ( | |
219 | 0 => 9, | |
220 | 1 => 21, | |
221 | 2 => 9 | |
222 | ); | |
223 | ||
e673ee24 DO |
224 | // Main menu. |
225 | function renderIndex () | |
226 | { | |
e673ee24 DO |
227 | ?> |
228 | <table border=0 cellpadding=0 cellspacing=0 width='100%'> | |
229 | <tr> | |
230 | <td> | |
231 | <div style='text-align: center; margin: 10px; '> | |
232 | <table width='100%' cellspacing=0 cellpadding=30 class=mainmenu border=0> | |
233 | <tr> | |
234 | <td> | |
4fbb5a00 | 235 | <h1><a href='<?php echo makeHref(array('page'=>'rackspace')) ?>'>Rackspace<br> |
b325120a | 236 | <?php printImageHREF ('rackspace'); ?></a></h1> |
e673ee24 DO |
237 | </td> |
238 | <td> | |
341fd895 | 239 | <h1><a href='<?php echo makeHref(array('page'=>'depot')) ?>'>Objects<br> |
b325120a | 240 | <?php printImageHREF ('objects'); ?></a></h1> |
e673ee24 | 241 | </td> |
e673ee24 | 242 | <td> |
4fbb5a00 | 243 | <h1><a href='<?php echo makeHref(array('page'=>'ipv4space')) ?>'>IPv4 space<br> |
e1ae3fb4 | 244 | <?php printImageHREF ('ipv4space'); ?></a></h1> |
e673ee24 DO |
245 | </td> |
246 | <td> | |
4fbb5a00 | 247 | <h1><a href='<?php echo makeHref(array('page'=>'files')) ?>'>Files<br> |
e1ae3fb4 | 248 | <?php printImageHREF ('files'); ?></a></h1> |
e673ee24 | 249 | </td> |
e1ae3fb4 | 250 | </tr> |
e1ae3fb4 | 251 | <tr> |
ae545907 | 252 | <td> |
4fbb5a00 | 253 | <h1><a href='<?php echo makeHref(array('page'=>'config')) ?>'>Configuration<br> |
f4d879a9 | 254 | <?php printImageHREF ('config'); ?></a></h1> |
ae545907 | 255 | </td> |
e1ae3fb4 | 256 | <td> |
4fbb5a00 | 257 | <h1><a href='<?php echo makeHref(array('page'=>'reports')) ?>'>Reports<br> |
f4d879a9 | 258 | <?php printImageHREF ('reports'); ?></a></h1> |
e1ae3fb4 AD |
259 | </td> |
260 | <td> | |
4fbb5a00 | 261 | <h1><a href='<?php echo makeHref(array('page'=>'ipv4slb')) ?>'>IPv4 SLB<br> |
f4d879a9 | 262 | <?php printImageHREF ('ipv4slb'); ?></a></h1> |
e1ae3fb4 | 263 | </td> |
f4d879a9 | 264 | <td> </td> |
e673ee24 DO |
265 | </tr> |
266 | </table> | |
267 | </div> | |
268 | </td> | |
269 | </tr> | |
270 | </table> | |
b325120a | 271 | <?php |
e673ee24 DO |
272 | } |
273 | ||
274 | function renderRackspace () | |
275 | { | |
489a7502 | 276 | echo "<table class=objview border=0 width='100%'><tr><td class=pcleft>"; |
a8efc03e DO |
277 | $cellfilter = getCellFilter(); |
278 | renderCellFilterPortlet ($cellfilter, 'rack'); | |
489a7502 DO |
279 | echo '</td><td class=pcright>'; |
280 | echo '<table border=0 cellpadding=10 cellpadding=1>'; | |
e673ee24 | 281 | // generate thumb gallery |
4fbb5a00 | 282 | global $nextorder; |
d5157018 | 283 | $rackwidth = getRackImageWidth(); |
f5883ec1 DO |
284 | // Zero value effectively disables the limit. |
285 | $maxPerRow = getConfigVar ('RACKS_PER_ROW'); | |
e673ee24 | 286 | $order = 'odd'; |
6c18dd08 | 287 | foreach (getRackRows() as $row_id => $row_name) |
e673ee24 | 288 | { |
a8efc03e DO |
289 | $rackList = filterCellList (listCells ('rack', $row_id), $cellfilter['expression']); |
290 | if (!count ($rackList) and count ($cellfilter['expression'])) | |
6c18dd08 | 291 | continue; |
f5883ec1 | 292 | $rackListIdx = 0; |
48325652 | 293 | echo "<tr class=row_${order}><th class=tdleft>"; |
a8efc03e | 294 | echo "<a href='".makeHref(array('page'=>'row', 'row_id'=>$row_id))."${cellfilter['urlextra']}'>"; |
48325652 DO |
295 | echo "${row_name}</a></th><td><table border=0 cellspacing=5><tr>"; |
296 | if (!count ($rackList)) | |
297 | echo "<td>(empty row)</td>"; | |
298 | else | |
299 | foreach ($rackList as $rack) | |
f5883ec1 | 300 | { |
48325652 DO |
301 | if ($rackListIdx > 0 and $maxPerRow > 0 and $rackListIdx % $maxPerRow == 0) |
302 | { | |
f5883ec1 | 303 | echo '</tr></table></tr>'; |
48325652 DO |
304 | echo "<tr class=row_${order}><th class=tdleft>${row_name} (continued)"; |
305 | echo "</th><td><table border=0 cellspacing=5><tr>"; | |
48325652 DO |
306 | } |
307 | echo "<td align=center><a href='".makeHref(array('page'=>'rack', 'rack_id'=>$rack['id']))."'>"; | |
308 | echo "<img border=0 width=${rackwidth} height="; | |
309 | echo getRackImageHeight ($rack['height']); | |
310 | echo " title='${rack['height']} units'"; | |
311 | echo "src='render_image.php?img=minirack&rack_id=${rack['id']}'>"; | |
312 | echo "<br>${rack['name']}</a></td>"; | |
313 | $rackListIdx++; | |
f5883ec1 | 314 | } |
a395fdad | 315 | $order = $nextorder[$order]; |
e673ee24 | 316 | echo "</tr></table></tr>\n"; |
e673ee24 DO |
317 | } |
318 | echo "</table>\n"; | |
489a7502 | 319 | echo "</td></tr></table>\n"; |
e673ee24 DO |
320 | } |
321 | ||
345fd640 AD |
322 | function renderRackspaceRowEditor () |
323 | { | |
324 | function printNewItemTR () | |
325 | { | |
326 | printOpFormIntro ('addRow'); | |
7be51fea DO |
327 | echo "<tr><td>"; |
328 | printImageHREF ('create', 'Add new row', TRUE); | |
329 | echo "</td><td><input type=text name=name tabindex=100></td><td>"; | |
345fd640 | 330 | printImageHREF ('create', 'Add new row', TRUE, 101); |
7be51fea | 331 | echo "</td></tr></form>"; |
345fd640 | 332 | } |
d732e47e | 333 | startPortlet ('Rows'); |
345fd640 | 334 | echo "<table border=0 cellspacing=0 cellpadding=5 align=center class=widetable>\n"; |
7be51fea | 335 | echo "<tr><th> </th><th>Name</th><th> </th></tr>\n"; |
345fd640 AD |
336 | if (getConfigVar ('ADDNEW_AT_TOP') == 'yes') |
337 | printNewItemTR(); | |
c40666f5 | 338 | foreach (getRackRows() as $row_id => $row_name) |
345fd640 | 339 | { |
7be51fea | 340 | echo "<tr><td>"; |
a8efc03e | 341 | if ($rc = count (listCells ('rack', $row_id))) |
6c18dd08 | 342 | printImageHREF ('nodestroy', "${rc} rack(s) here"); |
7be51fea | 343 | else |
5af82683 | 344 | { |
c40666f5 | 345 | echo "<a href=\"".makeHrefProcess(array('op'=>'delete', 'row_id'=>$row_id))."\">"; |
7be51fea | 346 | printImageHREF ('destroy', 'Delete row'); |
5af82683 DY |
347 | echo "</a>"; |
348 | } | |
c40666f5 DO |
349 | printOpFormIntro ('updateRow', array ('row_id' => $row_id)); |
350 | echo "</td><td><input type=text name=name value='${row_name}'></td><td>"; | |
7be51fea DO |
351 | printImageHREF ('save', 'Save changes', TRUE); |
352 | echo "</form></td></tr>\n"; | |
345fd640 AD |
353 | } |
354 | if (getConfigVar ('ADDNEW_AT_TOP') != 'yes') | |
355 | printNewItemTR(); | |
356 | echo "</table><br>\n"; | |
357 | finishPortlet(); | |
358 | } | |
359 | ||
7e1db771 | 360 | function renderRow ($row_id) |
e673ee24 | 361 | { |
e673ee24 DO |
362 | if (($rowInfo = getRackRowInfo ($row_id)) == NULL) |
363 | { | |
39a6338a | 364 | showError ('getRackRowInfo() failed', __FUNCTION__); |
e673ee24 DO |
365 | return; |
366 | } | |
a8efc03e DO |
367 | $cellfilter = getCellFilter(); |
368 | $rackList = filterCellList (listCells ('rack', $row_id), $cellfilter['expression']); | |
e673ee24 DO |
369 | // Main layout starts. |
370 | echo "<table border=0 class=objectview cellspacing=0 cellpadding=0>"; | |
371 | ||
372 | // Left portlet with row information. | |
373 | echo "<tr><td class=pcleft>"; | |
a8ce7234 | 374 | startPortlet ($rowInfo['name']); |
e673ee24 | 375 | echo "<table border=0 cellspacing=0 cellpadding=3 width='100%'>\n"; |
5af82683 DY |
376 | echo "<tr><th width='50%' class=tdright>Racks:</th><td class=tdleft>${rowInfo['count']}</td></tr>\n"; |
377 | echo "<tr><th width='50%' class=tdright>Units:</th><td class=tdleft>${rowInfo['sum']}</td></tr>\n"; | |
04d619d0 | 378 | echo "<tr><th width='50%' class=tdright>%% used:</th><td class=tdleft>"; |
114e50af DO |
379 | renderProgressBar (getRSUforRackRow ($rackList)); |
380 | echo "</td></tr>\n"; | |
e673ee24 DO |
381 | echo "</table><br>\n"; |
382 | finishPortlet(); | |
a8efc03e | 383 | renderCellFilterPortlet ($cellfilter, 'rack', 'row_id', $row_id); |
e673ee24 | 384 | |
48325652 | 385 | echo "</td><td class=pcright>"; |
e673ee24 | 386 | |
4fbb5a00 | 387 | global $nextorder; |
d5157018 | 388 | $rackwidth = getRackImageWidth() * getConfigVar ('ROW_SCALE'); |
f5883ec1 DO |
389 | // Maximum number of racks per row is proportionally less, but at least 1. |
390 | $maxPerRow = max (floor (getConfigVar ('RACKS_PER_ROW') / getConfigVar ('ROW_SCALE')), 1); | |
391 | $rackListIdx = 0; | |
e673ee24 DO |
392 | $order = 'odd'; |
393 | startPortlet ('Racks'); | |
394 | echo "<table border=0 cellspacing=5 align='center'><tr>"; | |
64b95774 | 395 | foreach ($rackList as $rack) |
e673ee24 | 396 | { |
f5883ec1 DO |
397 | if ($rackListIdx % $maxPerRow == 0) |
398 | { | |
399 | if ($rackListIdx > 0) | |
400 | echo '</tr>'; | |
401 | echo '<tr>'; | |
402 | } | |
4fbb5a00 | 403 | echo "<td align=center class=row_${order}><a href='".makeHref(array('page'=>'rack', 'rack_id'=>$rack['id']))."'>"; |
d5157018 | 404 | echo "<img border=0 width=${rackwidth} height=" . (getRackImageHeight ($rack['height']) * getConfigVar ('ROW_SCALE')); |
e673ee24 | 405 | echo " title='${rack['height']} units'"; |
d2ec5490 | 406 | echo "src='render_image.php?img=minirack&rack_id=${rack['id']}'>"; |
e673ee24 DO |
407 | echo "<br>${rack['name']}</a></td>"; |
408 | $order = $nextorder[$order]; | |
f5883ec1 | 409 | $rackListIdx++; |
e673ee24 DO |
410 | } |
411 | echo "</tr></table>\n"; | |
412 | finishPortlet(); | |
e673ee24 DO |
413 | echo "</td></tr></table>"; |
414 | } | |
415 | ||
04f110a0 | 416 | function showError ($info = '', $location = 'N/A') |
e673ee24 | 417 | { |
04f110a0 DO |
418 | if (preg_match ('/\.php$/', $location)) |
419 | $location = basename ($location); | |
420 | elseif ($location != 'N/A') | |
421 | $location = $location . '()'; | |
422 | echo "<div class=msg_error>An error has occured in [${location}]. "; | |
59a83bd8 | 423 | if (!strlen ($info)) |
e673ee24 DO |
424 | echo 'No additional information is available.'; |
425 | else | |
426 | echo "Additional information:<br><p>\n<pre>\n${info}\n</pre></p>"; | |
4fbb5a00 | 427 | echo "Go back or try starting from <a href='".makeHref()."'>index page</a>.<br></div>\n"; |
e673ee24 DO |
428 | } |
429 | ||
b6a7d936 DO |
430 | // This function assures that specified argument was passed |
431 | // and is a number greater than zero. | |
432 | function assertUIntArg ($argname, $caller = 'N/A', $allow_zero = FALSE) | |
433 | { | |
434 | if (!isset ($_REQUEST[$argname])) | |
435 | { | |
436 | showError ("Parameter '${argname}' is missing (calling function is [${caller}]).", __FUNCTION__); | |
437 | die(); | |
438 | } | |
439 | if (!is_numeric ($_REQUEST[$argname])) | |
440 | { | |
441 | showError ("Parameter '${argname}' is not a number (calling function is [${caller}]).", __FUNCTION__); | |
442 | die(); | |
443 | } | |
444 | if ($_REQUEST[$argname] < 0) | |
445 | { | |
446 | showError ("Parameter '${argname}' is less than zero (calling function is [${caller}]).", __FUNCTION__); | |
447 | die(); | |
448 | } | |
59a83bd8 | 449 | if (!$allow_zero and $_REQUEST[$argname] === 0) |
b6a7d936 DO |
450 | { |
451 | showError ("Parameter '${argname}' is equal to zero (calling function is [${caller}]).", __FUNCTION__); | |
452 | die(); | |
453 | } | |
454 | } | |
455 | ||
456 | // This function assures that specified argument was passed | |
457 | // and is a non-empty string. | |
458 | function assertStringArg ($argname, $caller = 'N/A', $ok_if_empty = FALSE) | |
459 | { | |
460 | if (!isset ($_REQUEST[$argname])) | |
461 | { | |
462 | showError ("Parameter '${argname}' is missing (calling function is [${caller}]).", __FUNCTION__); | |
463 | die(); | |
464 | } | |
465 | if (!is_string ($_REQUEST[$argname])) | |
466 | { | |
467 | showError ("Parameter '${argname}' is not a string (calling function is [${caller}]).", __FUNCTION__); | |
468 | die(); | |
469 | } | |
59a83bd8 | 470 | if (!$ok_if_empty and !strlen ($_REQUEST[$argname])) |
b6a7d936 DO |
471 | { |
472 | showError ("Parameter '${argname}' is an empty string (calling function is [${caller}]).", __FUNCTION__); | |
473 | die(); | |
474 | } | |
475 | } | |
476 | ||
477 | function assertBoolArg ($argname, $caller = 'N/A', $ok_if_empty = FALSE) | |
478 | { | |
479 | if (!isset ($_REQUEST[$argname])) | |
480 | { | |
481 | showError ("Parameter '${argname}' is missing (calling function is [${caller}]).", __FUNCTION__); | |
482 | die(); | |
483 | } | |
484 | if (!is_string ($_REQUEST[$argname]) or $_REQUEST[$argname] != 'on') | |
485 | { | |
486 | showError ("Parameter '${argname}' is not a string (calling function is [${caller}]).", __FUNCTION__); | |
487 | die(); | |
488 | } | |
59a83bd8 | 489 | if (!$ok_if_empty and !strlen ($_REQUEST[$argname])) |
b6a7d936 DO |
490 | { |
491 | showError ("Parameter '${argname}' is an empty string (calling function is [${caller}]).", __FUNCTION__); | |
492 | die(); | |
493 | } | |
494 | } | |
495 | ||
496 | function assertIPv4Arg ($argname, $caller = 'N/A', $ok_if_empty = FALSE) | |
497 | { | |
498 | assertStringArg ($argname, $caller, $ok_if_empty); | |
59a83bd8 | 499 | if (strlen ($_REQUEST[$argname]) and long2ip (ip2long ($_REQUEST[$argname])) !== $_REQUEST[$argname]) |
b6a7d936 DO |
500 | { |
501 | showError ("IPv4 address validation failed for value '" . $_REQUEST[$argname] . "' (calling function is [${caller}]).", __FUNCTION__); | |
502 | die(); | |
503 | } | |
504 | } | |
505 | ||
e673ee24 | 506 | // This function renders rack as HTML table. |
7e1db771 | 507 | function renderRack ($rack_id, $hl_obj_id = 0) |
e673ee24 | 508 | { |
61a1d996 DO |
509 | $rackData = spotEntity ('rack', $rack_id); |
510 | amplifyCell ($rackData); | |
e673ee24 DO |
511 | markAllSpans ($rackData); |
512 | if ($hl_obj_id > 0) | |
513 | highlightObject ($rackData, $hl_obj_id); | |
514 | markupObjectProblems ($rackData); | |
515 | $prev_id = getPrevIDforRack ($rackData['row_id'], $rack_id); | |
516 | $next_id = getNextIDforRack ($rackData['row_id'], $rack_id); | |
d48d8820 | 517 | echo "<center><table border=0><tr valign=middle>"; |
4fbb5a00 | 518 | echo "<td><h2><a href='".makeHref(array('page'=>'row', 'row_id'=>$rackData['row_id']))."'>${rackData['row_name']}</a> :</h2></td>"; |
e673ee24 DO |
519 | // FIXME: use 'bypass'? |
520 | if ($prev_id != NULL) | |
9803c56c | 521 | { |
4fbb5a00 | 522 | echo "<td><a href='".makeHref(array('page'=>'rack', 'rack_id'=>$prev_id))."'>"; |
9803c56c | 523 | printImageHREF ('prev', 'previous rack'); |
d48d8820 | 524 | echo "</a></td>"; |
9803c56c | 525 | } |
4fbb5a00 | 526 | echo "<td><h2><a href='".makeHref(array('page'=>'rack', 'rack_id'=>$rackData['id']))."'>${rackData['name']}</a></h2></td>"; |
e673ee24 | 527 | if ($next_id != NULL) |
9803c56c | 528 | { |
4fbb5a00 | 529 | echo "<td><a href='".makeHref(array('page'=>'rack', 'rack_id'=>$next_id))."'>"; |
f444c095 | 530 | printImageHREF ('next', 'next rack'); |
d48d8820 | 531 | echo "</a></td>"; |
9803c56c | 532 | } |
d48d8820 | 533 | echo "</h2></td></tr></table>\n"; |
e673ee24 | 534 | echo "<table class=rack border=0 cellspacing=0 cellpadding=1>\n"; |
d08147d6 DO |
535 | echo "<tr><th width='10%'> </th><th width='20%'>Front</th>"; |
536 | echo "<th width='50%'>Interior</th><th width='20%'>Back</th></tr>\n"; | |
e673ee24 DO |
537 | for ($i = $rackData['height']; $i > 0; $i--) |
538 | { | |
d08147d6 | 539 | echo "<tr><th>${i}</th>"; |
e673ee24 DO |
540 | for ($locidx = 0; $locidx < 3; $locidx++) |
541 | { | |
542 | if (isset ($rackData[$i][$locidx]['skipped'])) | |
543 | continue; | |
544 | $state = $rackData[$i][$locidx]['state']; | |
545 | echo "<td class=state_${state}"; | |
546 | if (isset ($rackData[$i][$locidx]['hl'])) | |
547 | echo $rackData[$i][$locidx]['hl']; | |
548 | if (isset ($rackData[$i][$locidx]['colspan'])) | |
549 | echo ' colspan=' . $rackData[$i][$locidx]['colspan']; | |
550 | if (isset ($rackData[$i][$locidx]['rowspan'])) | |
551 | echo ' rowspan=' . $rackData[$i][$locidx]['rowspan']; | |
552 | echo ">"; | |
553 | switch ($state) | |
554 | { | |
555 | case 'T': | |
fb6e2f57 | 556 | $objectData = spotEntity ('object', $rackData[$i][$locidx]['object_id']); |
59a83bd8 | 557 | if (strlen ($objectData['asset_no'])) |
e673ee24 DO |
558 | $prefix = "<div title='${objectData['asset_no']}"; |
559 | else | |
560 | $prefix = "<div title='no asset tag"; | |
561 | // Don't tell about label, if it matches common name. | |
59a83bd8 | 562 | if ($objectData['name'] != $objectData['label'] and strlen ($objectData['label'])) |
e673ee24 DO |
563 | $suffix = ", visible label is \"${objectData['label']}\"'>"; |
564 | else | |
565 | $suffix = "'>"; | |
566 | echo $prefix . $suffix; | |
4fbb5a00 | 567 | echo "<a href='".makeHref(array('page'=>'object', 'object_id'=>$objectData['id']))."'>${objectData['dname']}</a></div>"; |
e673ee24 DO |
568 | break; |
569 | case 'A': | |
570 | echo '<div title="This rackspace does not exist"> </div>'; | |
571 | break; | |
572 | case 'F': | |
573 | echo '<div title="Free rackspace"> </div>'; | |
574 | break; | |
575 | case 'U': | |
576 | echo '<div title="Problematic rackspace, you CAN\'T mount here"> </div>'; | |
577 | break; | |
578 | default: | |
579 | echo '<div title="No data"> </div>'; | |
580 | break; | |
581 | } | |
582 | echo '</td>'; | |
583 | } | |
584 | echo "</tr>\n"; | |
585 | } | |
586 | echo "</table></center>\n"; | |
587 | } | |
588 | ||
e673ee24 DO |
589 | function renderNewRackForm ($row_id) |
590 | { | |
50b4ba85 | 591 | startPortlet ('Add one'); |
f19c75d6 | 592 | printOpFormIntro ('addRack', array ('got_data' => 'TRUE')); |
e673ee24 | 593 | echo '<table border=0 align=center>'; |
b901bf1f DO |
594 | $defh = getConfigVar ('DEFAULT_RACK_HEIGHT'); |
595 | if ($defh == 0) | |
596 | $defh = ''; | |
72d52730 DO |
597 | echo "<tr><th class=tdright>Rack name (*):</th><td class=tdleft><input type=text name=rack_name tabindex=1></td>"; |
598 | echo "<td rowspan=4>Assign tags:<br>"; | |
25186565 | 599 | renderNewEntityTags(); |
72d52730 | 600 | echo "</td></tr>\n"; |
b8094ae4 | 601 | echo "<tr><th class=tdright>Height in units (*):</th><td class=tdleft><input type=text name=rack_height1 tabindex=2 value='${defh}'></td></tr>\n"; |
4134b5c0 | 602 | echo "<tr><th class=tdright>Comment:</th><td class=tdleft><input type=text name=rack_comment tabindex=3></td></tr>\n"; |
f19c75d6 DO |
603 | echo "<tr><td class=submit colspan=2>"; |
604 | printImageHREF ('CREATE', 'Add', TRUE); | |
605 | echo "</td></tr></table></form>"; | |
406b54bd | 606 | finishPortlet(); |
406b54bd | 607 | |
50b4ba85 | 608 | startPortlet ('Add many'); |
f19c75d6 | 609 | printOpFormIntro ('addRack', array ('got_mdata' => 'TRUE')); |
50b4ba85 DO |
610 | echo '<table border=0 align=center>'; |
611 | $defh = getConfigVar ('DEFAULT_RACK_HEIGHT'); | |
612 | if ($defh == 0) | |
613 | $defh = ''; | |
72d52730 DO |
614 | echo "<tr><th class=tdright>Height in units (*):</th><td class=tdleft><input type=text name=rack_height2 value='${defh}'></td>"; |
615 | echo "<td rowspan=3 valign=top>Assign tags:<br>"; | |
25186565 | 616 | renderNewEntityTags(); |
72d52730 | 617 | echo "</td></tr>\n"; |
50b4ba85 | 618 | echo "<tr><th class=tdright>Rack names (*):</th><td class=tdleft><textarea name=rack_names cols=40 rows=25></textarea></td></tr>\n"; |
f19c75d6 DO |
619 | echo "<tr><td class=submit colspan=2>"; |
620 | printImageHREF ('CREATE', 'Add', TRUE); | |
e673ee24 DO |
621 | echo '</form></table>'; |
622 | finishPortlet(); | |
623 | } | |
624 | ||
625 | function renderEditObjectForm ($object_id) | |
626 | { | |
e10f583a | 627 | global $pageno; |
fb6e2f57 | 628 | $object = spotEntity ('object', $object_id); |
e673ee24 DO |
629 | if ($object == NULL) |
630 | { | |
fb6e2f57 | 631 | showError ('Error retrieving data', __FUNCTION__); |
e673ee24 DO |
632 | return; |
633 | } | |
cdd3efe9 | 634 | startPortlet (); |
43fb6eaf | 635 | printOpFormIntro ('update'); |
cdd3efe9 AD |
636 | |
637 | // static attributes | |
e10f583a DO |
638 | echo '<table border=0 cellspacing=0 cellpadding=3 align=center>'; |
639 | echo "<tr><td> </td><th colspan=2><h2>Attributes</h2></th></tr>"; | |
640 | echo "<tr><td> </td><th class=tdright>Type:</th><td class=tdleft>"; | |
e673ee24 DO |
641 | printSelect (getObjectTypeList(), 'object_type_id', $object['objtype_id']); |
642 | echo "</td></tr>\n"; | |
22bb04da | 643 | // baseline info |
e10f583a DO |
644 | echo "<tr><td> </td><th class=tdright>Common name:</th><td class=tdleft><input type=text name=object_name value='${object['name']}'></td></tr>\n"; |
645 | echo "<tr><td> </td><th class=tdright>Visible label:</th><td class=tdleft><input type=text name=object_label value='${object['label']}'></td></tr>\n"; | |
646 | echo "<tr><td> </td><th class=tdright>Asset tag:</th><td class=tdleft><input type=text name=object_asset_no value='${object['asset_no']}'></td></tr>\n"; | |
647 | echo "<tr><td> </td><th class=tdright>Barcode:</th><td class=tdleft><input type=text name=object_barcode value='${object['barcode']}'></td></tr>\n"; | |
cdd3efe9 | 648 | // optional attributes |
e673ee24 | 649 | $values = getAttrValues ($object_id); |
0f63538a | 650 | echo '<input type=hidden name=num_attrs value=' . count($values) . ">\n"; |
2b98d5a2 | 651 | if (count($values) > 0) |
e673ee24 | 652 | { |
2b98d5a2 AD |
653 | $i = 0; |
654 | foreach ($values as $record) | |
e673ee24 | 655 | { |
2b98d5a2 AD |
656 | echo "<input type=hidden name=${i}_attr_id value=${record['id']}>"; |
657 | echo '<tr><td>'; | |
59a83bd8 | 658 | if (strlen ($record['value'])) |
2b98d5a2 | 659 | { |
4fbb5a00 | 660 | echo "<a href='".makeHrefProcess(array('op'=>'clearSticker', 'object_id'=>$object_id, 'attr_id'=>$record['id']))."'>"; |
2b98d5a2 AD |
661 | printImageHREF ('clear', 'Clear value'); |
662 | echo '</a>'; | |
663 | } | |
664 | else | |
665 | echo ' '; | |
666 | echo '</td>'; | |
e10f583a | 667 | echo "<th class=sticker>${record['name']}:</th><td class=tdleft>"; |
2b98d5a2 AD |
668 | switch ($record['type']) |
669 | { | |
670 | case 'uint': | |
671 | case 'float': | |
672 | case 'string': | |
673 | echo "<input type=text name=${i}_value value='${record['value']}'>"; | |
674 | break; | |
675 | case 'dict': | |
676 | $chapter = readChapter ($record['chapter_name']); | |
677 | $chapter[0] = '-- NOT SET --'; | |
f3d274bf DO |
678 | $chapter = cookOptgroups ($chapter, $object['objtype_id'], $record['key']); |
679 | printNiftySelect ($chapter, "${i}_value", $record['key']); | |
2b98d5a2 AD |
680 | break; |
681 | } | |
682 | echo "</td></tr>\n"; | |
683 | $i++; | |
e673ee24 | 684 | } |
e673ee24 | 685 | } |
e10f583a DO |
686 | echo "<tr><td> </td><th class=tdright>Has problems:</th><td class=tdleft><input type=checkbox name=object_has_problems"; |
687 | if ($object['has_problems'] == 'yes') | |
688 | echo ' checked'; | |
689 | echo "></td></tr>\n"; | |
690 | echo "<tr><td> </td><th class=tdright>Actions:</th><td class=tdleft><a href='". | |
c78a40ec | 691 | makeHrefProcess(array('op'=>'deleteObject', 'page'=>'depot', 'tab'=>'default', 'object_id'=>$object_id)). |
e10f583a DO |
692 | "' onclick=\"javascript:return confirm('Are you sure you want to delete the object?')\">Delete object</a></td></tr>\n"; |
693 | echo "<tr><td colspan=3><b>Comment:</b><br><textarea name=object_comment rows=10 cols=80>${object['comment']}</textarea></td></tr>"; | |
cdd3efe9 | 694 | |
e10f583a | 695 | echo "<tr><th class=submit colspan=3>"; |
5bbbeaa2 | 696 | printImageHREF ('SAVE', 'Save changes', TRUE); |
cdd3efe9 | 697 | echo "</form></th></tr></table>\n"; |
e673ee24 | 698 | finishPortlet(); |
e673ee24 | 699 | |
cdd3efe9 | 700 | echo '<table border=0 width=100%><tr><td>'; |
e673ee24 DO |
701 | startPortlet ('history'); |
702 | renderHistory ($pageno, $object_id); | |
703 | finishPortlet(); | |
cdd3efe9 | 704 | echo '</td></tr></table>'; |
e673ee24 DO |
705 | } |
706 | ||
707 | // This is a clone of renderEditObjectForm(). | |
708 | function renderEditRackForm ($rack_id) | |
709 | { | |
0c2b7c4a | 710 | global $pageno; |
61a1d996 DO |
711 | $rack = spotEntity ('rack', $rack_id); |
712 | amplifyCell ($rack); | |
e673ee24 | 713 | |
e673ee24 | 714 | startPortlet ('Rack attributes'); |
7056988c | 715 | printOpFormIntro ('updateRack'); |
e673ee24 DO |
716 | echo '<table border=0 align=center>'; |
717 | echo "<tr><th class=tdright>Rack row:</th><td class=tdleft>"; | |
4fbb5a00 | 718 | printSelect (getRackRows(), 'rack_row_id', $rack['row_id']); |
e673ee24 DO |
719 | echo "</td></tr>\n"; |
720 | echo "<tr><th class=tdright>Name (required):</th><td class=tdleft><input type=text name=rack_name value='${rack['name']}'></td></tr>\n"; | |
721 | echo "<tr><th class=tdright>Height (required):</th><td class=tdleft><input type=text name=rack_height value='${rack['height']}'></td></tr>\n"; | |
722 | echo "<tr><th class=tdright>Comment:</th><td class=tdleft><input type=text name=rack_comment value='${rack['comment']}'></td></tr>\n"; | |
c8187437 DY |
723 | if (count ($rack['mountedObjects']) == 0) |
724 | { | |
725 | echo "<tr><th class=tdright>Actions:</th><td class=tdleft><a href='". | |
726 | makeHrefProcess(array('op'=>'deleteRack', 'rack_id'=>$rack_id)). | |
727 | "' onclick=\"javascript:return confirm('Are you sure you want to delete the rack?')\">Delete rack</a></td></tr>\n"; | |
728 | } | |
7056988c DO |
729 | echo "<tr><td class=submit colspan=2>"; |
730 | printImageHREF ('SAVE', 'Save changes', TRUE); | |
731 | echo "</td></tr>\n"; | |
e673ee24 DO |
732 | echo '</form></table><br>'; |
733 | finishPortlet(); | |
734 | ||
735 | startPortlet ('History'); | |
736 | renderHistory ($pageno, $rack_id); | |
737 | finishPortlet(); | |
738 | } | |
739 | ||
740 | // This is a helper for creators and editors. | |
f3d274bf DO |
741 | // Input array keys are OPTION VALUEs and input array values are OPTION text. |
742 | function printSelect ($optionList, $select_name, $selected_id = NULL, $tabindex = NULL) | |
e673ee24 | 743 | { |
f3d274bf DO |
744 | echo "<select name=${select_name}" . ($tabindex ? " tabindex=${tabindex}" : '') . '>'; |
745 | foreach ($optionList as $dict_key => $dict_value) | |
ca0cc77e | 746 | echo "<option value='${dict_key}'" . ($dict_key == $selected_id ? ' selected' : '') . ">${dict_value}</option>"; |
f3d274bf DO |
747 | echo "</select>"; |
748 | } | |
749 | ||
750 | // Input is a cooked list of OPTGROUPs, each with own sub-list of OPTIONs in the same | |
751 | // format as printSelect() expects. | |
752 | function printNiftySelect ($groupList, $select_name, $selected_id = NULL, $tabindex = NULL) | |
753 | { | |
754 | // special treatment for ungrouped data | |
755 | if (count ($groupList) == 1 and isset ($groupList['other'])) | |
e673ee24 | 756 | { |
f3d274bf DO |
757 | printSelect ($groupList['other'], $select_name, $selected_id, $tabindex); |
758 | return; | |
9e7f32a7 | 759 | } |
a65f9f54 | 760 | echo "<select name=${select_name}" . ($tabindex ? " tabindex=${tabindex}" : '') . '>'; |
f3d274bf | 761 | foreach ($groupList as $groupname => $groupdata) |
9e7f32a7 | 762 | { |
f3d274bf DO |
763 | echo "<optgroup label='${groupname}'>"; |
764 | foreach ($groupdata as $dict_key => $dict_value) | |
ca0cc77e | 765 | echo "<option value='${dict_key}'" . ($dict_key == $selected_id ? ' selected' : '') . ">${dict_value}</option>"; |
f3d274bf | 766 | echo "</optgroup>\n"; |
e673ee24 DO |
767 | } |
768 | echo "</select>"; | |
769 | } | |
770 | ||
254673dd DO |
771 | // used by renderGridForm() and renderRackPage() |
772 | function renderRackInfoPortlet ($rackData) | |
773 | { | |
774 | startPortlet ('summary'); | |
775 | echo "<table border=0 cellspacing=0 cellpadding=3 width='100%'>\n"; | |
776 | echo "<tr><th width='50%' class=tdright>Rack row:</th><td class=tdleft>${rackData['row_name']}</td></tr>\n"; | |
777 | echo "<tr><th width='50%' class=tdright>Name:</th><td class=tdleft>${rackData['name']}</td></tr>\n"; | |
778 | echo "<tr><th width='50%' class=tdright>Height:</th><td class=tdleft>${rackData['height']}</td></tr>\n"; | |
04d619d0 | 779 | echo "<tr><th width='50%' class=tdright>%% used:</th><td class=tdleft>"; |
254673dd DO |
780 | renderProgressBar (getRSUforRack ($rackData)); |
781 | echo "</td></tr>\n"; | |
782 | echo "<tr><th width='50%' class=tdright>Objects:</th><td class=tdleft>"; | |
61a1d996 | 783 | echo count ($rackData['mountedObjects']); |
254673dd | 784 | echo "</td></tr>\n"; |
9b57f793 | 785 | printTagTRs ($rackData, makeHref(array('page'=>'rackspace', 'tab'=>'default'))."&"); |
59a83bd8 | 786 | if (strlen ($rackData['comment'])) |
254673dd DO |
787 | echo "<tr><th width='50%' class=tdright>Comment:</th><td class=tdleft>${rackData['comment']}</td></tr>\n"; |
788 | echo '</table>'; | |
789 | finishPortlet(); | |
790 | } | |
791 | ||
e673ee24 | 792 | // This is a universal editor of rack design/waste. |
7056988c | 793 | // FIXME: switch to using printOpFormIntro() |
7e1db771 | 794 | function renderGridForm ($rack_id, $filter, $header, $submit, $state1, $state2) |
e673ee24 | 795 | { |
61a1d996 DO |
796 | $rackData = spotEntity ('rack', $rack_id); |
797 | amplifyCell ($rackData); | |
254673dd | 798 | $filter ($rackData); |
e673ee24 DO |
799 | markupObjectProblems ($rackData); |
800 | ||
e673ee24 DO |
801 | // Render the result whatever it is. |
802 | // Main layout. | |
803 | echo "<table border=0 class=objectview cellspacing=0 cellpadding=0>"; | |
804 | echo "<tr><td colspan=2 align=center><h1>${rackData['name']}</h1></td></tr>\n"; | |
805 | ||
806 | // Left column with information portlet. | |
807 | echo "<tr><td class=pcleft height='1%' width='50%'>"; | |
254673dd | 808 | renderRackInfoPortlet ($rackData); |
e673ee24 | 809 | echo "</td>\n"; |
bb09cca0 | 810 | echo "<td class=pcright>"; |
e673ee24 DO |
811 | |
812 | // Grid form. | |
813 | startPortlet ($header); | |
814 | echo "<center>\n"; | |
815 | echo "<table class=rack border=0 cellspacing=0 cellpadding=1>\n"; | |
57c69e9c AD |
816 | echo "<tr><th width='10%'> </th>"; |
817 | echo "<th width='20%'><a href='javascript:;' onclick=\"toggleColumnOfAtoms('${rack_id}', '0', ${rackData['height']})\">Front</a></th>"; | |
818 | echo "<th width='50%'><a href='javascript:;' onclick=\"toggleColumnOfAtoms('${rack_id}', '1', ${rackData['height']})\">Interior</a></th>"; | |
819 | echo "<th width='20%'><a href='javascript:;' onclick=\"toggleColumnOfAtoms('${rack_id}', '2', ${rackData['height']})\">Back</a></th></tr>\n"; | |
4fbb5a00 | 820 | printOpFormIntro ('updateRack'); |
e673ee24 DO |
821 | markupAtomGrid ($rackData, $state2); |
822 | renderAtomGrid ($rackData); | |
823 | echo "</table></center>\n"; | |
824 | echo "<br><input type=submit name=do_update value='${submit}'></form><br><br>\n"; | |
825 | finishPortlet(); | |
bb09cca0 | 826 | echo "</td></tr></table>\n"; |
e673ee24 DO |
827 | } |
828 | ||
829 | function renderRackDesign ($rack_id) | |
830 | { | |
bb09cca0 | 831 | renderGridForm ($rack_id, 'applyRackDesignMask', 'Rack design', 'Set rack design', 'A', 'F'); |
e673ee24 DO |
832 | } |
833 | ||
7e1db771 | 834 | function renderRackProblems ($rack_id) |
e673ee24 | 835 | { |
bb09cca0 | 836 | renderGridForm ($rack_id, 'applyRackProblemMask', 'Rack problems', 'Mark unusable atoms', 'F', 'U'); |
e673ee24 DO |
837 | } |
838 | ||
839 | function startPortlet ($title = '') | |
840 | { | |
841 | echo "<div class=portlet><h2>${title}</h2>"; | |
842 | } | |
843 | ||
844 | function finishPortlet () | |
845 | { | |
846 | echo "</div>\n"; | |
847 | } | |
848 | ||
7e1db771 | 849 | function renderRackObject ($object_id) |
e673ee24 | 850 | { |
4fbb5a00 | 851 | global $nextorder, $aac; |
fb6e2f57 DO |
852 | $info = spotEntity ('object', $object_id); |
853 | // FIXME: employ amplifyCell() instead of calling loader functions directly | |
94fe6370 | 854 | amplifyCell ($info); |
e673ee24 DO |
855 | if ($info == NULL) |
856 | { | |
fb6e2f57 | 857 | showError ('Error loading data', __FUNCTION__); |
e673ee24 DO |
858 | return; |
859 | } | |
860 | // Main layout starts. | |
861 | echo "<table border=0 class=objectview cellspacing=0 cellpadding=0>"; | |
862 | echo "<tr><td colspan=2 align=center><h1>${info['dname']}</h1></td></tr>\n"; | |
863 | // left column with uknown number of portlets | |
864 | echo "<tr><td class=pcleft>"; | |
0ab782bc | 865 | startPortlet ('summary'); |
e673ee24 | 866 | echo "<table border=0 cellspacing=0 cellpadding=3 width='100%'>\n"; |
59a83bd8 | 867 | if (strlen ($info['name'])) |
e673ee24 | 868 | echo "<tr><th width='50%' class=tdright>Common name:</th><td class=tdleft>${info['name']}</td></tr>\n"; |
212c9d8a | 869 | // FIXME: don't call spotEntity() each time, do it once in the beginning. |
94fe6370 | 870 | elseif (considerConfiguredConstraint ($info, 'NAMEWARN_LISTSRC')) |
a0ec6295 | 871 | echo "<tr><td colspan=2 class=msg_error>Common name is missing.</td></tr>\n"; |
341fd895 DO |
872 | echo "<tr><th width='50%' class=tdright>Object type:</th><td class=tdleft><a href='"; |
873 | echo makeHref (array ( | |
874 | 'page' => 'depot', | |
875 | 'tab' => 'default', | |
876 | 'cfe' => '{$typeid_' . $info['objtype_id'] . '}' | |
877 | )); | |
878 | echo "'>${info['objtype_name']}</a></td></tr>\n"; | |
59a83bd8 | 879 | if (strlen ($info['asset_no'])) |
e673ee24 | 880 | echo "<tr><th width='50%' class=tdright>Asset tag:</th><td class=tdleft>${info['asset_no']}</td></tr>\n"; |
212c9d8a | 881 | // FIXME: ditto |
94fe6370 | 882 | elseif (considerConfiguredConstraint (info, 'ASSETWARN_LISTSRC')) |
a0ec6295 | 883 | echo "<tr><td colspan=2 class=msg_error>Asset tag is missing.</td></tr>\n"; |
59a83bd8 | 884 | if (strlen ($info['label'])) |
e673ee24 | 885 | echo "<tr><th width='50%' class=tdright>Visible label:</th><td class=tdleft>${info['label']}</td></tr>\n"; |
59a83bd8 | 886 | if (strlen ($info['barcode'])) |
e673ee24 DO |
887 | echo "<tr><th width='50%' class=tdright>Barcode:</th><td class=tdleft>${info['barcode']}</td></tr>\n"; |
888 | if ($info['has_problems'] == 'yes') | |
889 | echo "<tr><td colspan=2 class=msg_error>Has problems</td></tr>\n"; | |
24cbe8af | 890 | foreach (getAttrValues ($object_id, TRUE) as $record) |
59a83bd8 | 891 | if (strlen ($record['value'])) |
57777e4a | 892 | echo "<tr><th width='50%' class=sticker>${record['name']}:</th><td class=sticker>${record['a_value']}</td></tr>\n"; |
341fd895 DO |
893 | printTagTRs |
894 | ( | |
9b57f793 | 895 | $info, |
341fd895 DO |
896 | makeHref |
897 | ( | |
898 | array | |
899 | ( | |
900 | 'page'=>'depot', | |
901 | 'tab'=>'default', | |
902 | 'andor' => 'and', | |
a8efc03e | 903 | 'cfe' => '{$typeid_' . $info['objtype_id'] . '}', |
341fd895 DO |
904 | ) |
905 | )."&" | |
906 | ); | |
e673ee24 DO |
907 | echo "</table><br>\n"; |
908 | finishPortlet(); | |
909 | ||
59a83bd8 | 910 | if (strlen ($info['comment'])) |
e673ee24 DO |
911 | { |
912 | startPortlet ('Comment'); | |
6cc5d6cd | 913 | echo '<div class=commentblock>' . string_insert_hrefs ($info['comment']) . '</div>'; |
e673ee24 DO |
914 | finishPortlet (); |
915 | } | |
916 | ||
e1ae3fb4 AD |
917 | renderFilesPortlet ('object', $object_id); |
918 | ||
94fe6370 | 919 | $ports = $info['ports']; |
e673ee24 DO |
920 | if (count ($ports)) |
921 | { | |
0ab782bc | 922 | startPortlet ('ports and links'); |
e673ee24 DO |
923 | usort($ports, 'sortByName'); |
924 | if ($ports) | |
925 | { | |
926 | $hl_port_id = 0; | |
927 | if (isset ($_REQUEST['hl_port_id'])) | |
928 | { | |
2c6c7645 | 929 | assertUIntArg ('hl_port_id', __FUNCTION__); |
e673ee24 DO |
930 | $hl_port_id = $_REQUEST['hl_port_id']; |
931 | } | |
932 | echo "<table cellspacing=0 cellpadding='5' align='center' class='widetable'>\n"; | |
933 | echo "<tr><th>Local name</th><th>Visible label</th><th>Port type</th><th>L2 address</th>"; | |
934 | echo "<th>Rem. Object</th><th>Rem. port</th></tr>\n"; | |
935 | foreach ($ports as $port) | |
936 | { | |
937 | echo '<tr'; | |
938 | if ($hl_port_id == $port['id']) | |
939 | echo ' class=port_highlight'; | |
940 | echo "><td>${port['name']}</td><td>${port['label']}</td><td>${port['type']}</td>"; | |
941 | echo "<td>${port['l2address']}</td>"; | |
942 | if ($port['remote_object_id']) | |
943 | { | |
4fbb5a00 | 944 | echo "<td><a href='".makeHref(array('page'=>'object', 'object_id'=>$port['remote_object_id'], 'hl_port_id'=>$port['remote_id']))."'>${port['remote_object_name']}</a></td>"; |
e673ee24 DO |
945 | echo "<td>${port['remote_name']}</td>"; |
946 | } | |
59a83bd8 | 947 | elseif (strlen ($port['reservation_comment'])) |
e673ee24 DO |
948 | { |
949 | echo "<td><b>Reserved;</b></td>"; | |
950 | echo "<td>${port['reservation_comment']}</td>"; | |
951 | } | |
952 | else | |
953 | echo '<td> </td><td> </td>'; | |
954 | echo "</tr>\n"; | |
955 | } | |
956 | echo "</table><br>\n"; | |
957 | } | |
958 | finishPortlet(); | |
959 | } | |
85970da2 | 960 | |
94fe6370 | 961 | $alloclist = $info['ipv4']; |
0ab782bc | 962 | if (count ($alloclist)) |
e673ee24 | 963 | { |
f28fbe8b | 964 | startPortlet ('IPv4 addresses'); |
e673ee24 | 965 | echo "<table cellspacing=0 cellpadding='5' align='center' class='widetable'>\n"; |
f0ed1181 | 966 | if (getConfigVar ('EXT_IPV4_VIEW') == 'yes') |
0b9c98d7 | 967 | echo "<tr><th>OS interface</th><th>IP address</th><th>network</th><th>routed by</th><th>peers</th></tr>\n"; |
83fdf85f DO |
968 | else |
969 | echo "<tr><th>OS interface</th><th>IP address</th><th>peers</th></tr>\n"; | |
fc0e3978 DO |
970 | $hl_ipv4_addr = ''; |
971 | if (isset ($_REQUEST['hl_ipv4_addr'])) | |
972 | { | |
973 | assertIPv4Arg ('hl_ipv4_addr', __FUNCTION__); | |
974 | $hl_ipv4_addr = $_REQUEST['hl_ipv4_addr']; | |
975 | } | |
85970da2 | 976 | foreach ($alloclist as $dottedquad => $alloc) |
e673ee24 | 977 | { |
0ab782bc DO |
978 | $address_name = niftyString ($alloc['addrinfo']['name']); |
979 | $class = $alloc['addrinfo']['class']; | |
85970da2 | 980 | $secondclass = ($hl_ipv4_addr == $dottedquad) ? 'tdleft port_highlight' : 'tdleft'; |
83fdf85f | 981 | $netid = getIPv4AddressNetworkId ($dottedquad); |
d7a8186d | 982 | if (NULL !== $netid) |
83fdf85f | 983 | { |
d724d290 | 984 | $netinfo = spotEntity ('ipv4net', $netid); |
d7a8186d | 985 | loadIPv4AddrList ($netinfo); |
83fdf85f | 986 | } |
d7a8186d DO |
987 | echo "<tr class='${class}' valign=top><td class=tdleft>${alloc['osif']}</td><td class='${secondclass}'>"; |
988 | if (NULL !== $netid) | |
4fbb5a00 | 989 | echo "<a href='".makeHref(array('page'=>'ipaddress', 'ip'=>$dottedquad, 'hl_object_id'=>$object_id))."'>${dottedquad}</a>"; |
d7a8186d DO |
990 | else |
991 | echo $dottedquad; | |
992 | if (getConfigVar ('EXT_IPV4_VIEW') != 'yes') | |
993 | echo '<small>/' . (NULL === $netid ? '??' : $netinfo['mask']) . '</small>'; | |
351b1f45 | 994 | echo ' ' . $aac[$alloc['type']]; |
59a83bd8 | 995 | if (strlen ($alloc['addrinfo']['name'])) |
28a664e7 | 996 | echo ' (' . niftyString ($alloc['addrinfo']['name']) . ')'; |
83fdf85f | 997 | echo '</td>'; |
f0ed1181 | 998 | if (getConfigVar ('EXT_IPV4_VIEW') == 'yes') |
b90c3907 | 999 | { |
83fdf85f | 1000 | if (NULL === $netid) |
0b9c98d7 | 1001 | echo '<td class=sparenetwork>N/A</td><td class=sparenetwork>N/A</td>'; |
83fdf85f | 1002 | else |
83fdf85f | 1003 | { |
0b9c98d7 | 1004 | echo "<td class='${secondclass}'>"; |
6df2025d | 1005 | renderCell ($netinfo); |
0b9c98d7 | 1006 | echo "</td>"; |
8b3874a5 DO |
1007 | // filter out self-allocation |
1008 | $other_routers = array(); | |
d7a8186d | 1009 | foreach (findRouters ($netinfo['addrlist']) as $router) |
8b3874a5 DO |
1010 | if ($router['id'] != $object_id) |
1011 | $other_routers[] = $router; | |
0b9c98d7 DO |
1012 | if (count ($other_routers)) |
1013 | printRoutersTD ($other_routers); | |
1014 | else | |
1015 | echo "<td class='${secondclass}'> </td>"; | |
83fdf85f | 1016 | } |
b90c3907 | 1017 | } |
83fdf85f | 1018 | // peers |
0ab782bc | 1019 | echo "<td class='${secondclass}'>\n"; |
0ab782bc | 1020 | $prefix = ''; |
2c817354 | 1021 | if ($alloc['addrinfo']['reserved'] == 'yes') |
e673ee24 | 1022 | { |
85970da2 | 1023 | echo $prefix . '<strong>RESERVED</strong>'; |
0ab782bc DO |
1024 | $prefix = '; '; |
1025 | } | |
1026 | foreach ($alloc['addrinfo']['allocs'] as $allocpeer) | |
1027 | { | |
1028 | if ($allocpeer['object_id'] == $object_id) | |
1029 | continue; | |
4fbb5a00 | 1030 | echo $prefix . "<a href='".makeHref(array('page'=>'object', 'object_id'=>$allocpeer['object_id']))."'>"; |
43eb71f1 | 1031 | if (isset ($allocpeer['osif']) and strlen ($allocpeer['osif'])) |
0ab782bc DO |
1032 | echo $allocpeer['osif'] . '@'; |
1033 | echo $allocpeer['object_name'] . '</a>'; | |
0ab782bc | 1034 | $prefix = '; '; |
e673ee24 | 1035 | } |
e673ee24 DO |
1036 | echo "</td></tr>\n"; |
1037 | } | |
1038 | echo "</table><br>\n"; | |
1039 | finishPortlet(); | |
1040 | } | |
1041 | ||
94fe6370 | 1042 | $forwards = $info['nat4']; |
e673ee24 DO |
1043 | if (count($forwards['in']) or count($forwards['out'])) |
1044 | { | |
f28fbe8b | 1045 | startPortlet('NATv4'); |
e673ee24 DO |
1046 | |
1047 | if (count($forwards['out'])) | |
1048 | { | |
1049 | ||
f28fbe8b | 1050 | echo "<h3>locally performed NAT</h3>"; |
e673ee24 | 1051 | |
105a3bc8 | 1052 | echo "<table class='widetable' cellpadding=5 cellspacing=0 border=0 align='center'>\n"; |
f28fbe8b | 1053 | echo "<tr><th>Proto</th><th>Match endpoint</th><th>Translate to</th><th>Target object</th><th>Rule comment</th></tr>\n"; |
e673ee24 DO |
1054 | |
1055 | foreach ($forwards['out'] as $pf) | |
1056 | { | |
2c817354 DO |
1057 | $class = 'trerror'; |
1058 | $osif = ''; | |
1059 | if (isset ($alloclist [$pf['localip']])) | |
1060 | { | |
1061 | $class = $alloclist [$pf['localip']]['addrinfo']['class']; | |
1062 | $osif = $alloclist [$pf['localip']]['osif'] . ': '; | |
1063 | } | |
e673ee24 | 1064 | echo "<tr class='$class'>"; |
4fbb5a00 DY |
1065 | echo "<td>${pf['proto']}</td><td class=tdleft>${osif}<a href='".makeHref(array('page'=>'ipaddress', 'tab'=>'default', 'ip'=>$pf['localip']))."'>${pf['localip']}</a>:${pf['localport']}</td>"; |
1066 | echo "<td class=tdleft><a href='".makeHref(array('page'=>'ipaddress', 'tab'=>'default', 'ip'=>$pf['remoteip']))."'>${pf['remoteip']}</a>:${pf['remoteport']}</td>"; | |
53ef3908 | 1067 | $address = getIPv4Address ($pf['remoteip']); |
e673ee24 | 1068 | echo "<td class='description'>"; |
53ef3908 DO |
1069 | if (count ($address['allocs'])) |
1070 | foreach($address['allocs'] as $bond) | |
4fbb5a00 | 1071 | echo "<a href='".makeHref(array('page'=>'object', 'tab'=>'default', 'object_id'=>$bond['object_id']))."'>${bond['object_name']}(${bond['name']})</a> "; |
59a83bd8 | 1072 | elseif (strlen ($pf['remote_addr_name'])) |
f28fbe8b | 1073 | echo '(' . $pf['remote_addr_name'] . ')'; |
53ef3908 | 1074 | echo "</td><td class='description'>${pf['description']}</td></tr>"; |
e673ee24 DO |
1075 | } |
1076 | echo "</table><br><br>"; | |
1077 | } | |
1078 | if (count($forwards['in'])) | |
1079 | { | |
f28fbe8b | 1080 | echo "<h3>arriving NAT connections</h3>"; |
105a3bc8 | 1081 | echo "<table class='widetable' cellpadding=5 cellspacing=0 border=0 align='center'>\n"; |
f28fbe8b | 1082 | echo "<tr><th>Matched endpoint</th><th>Source object</th><th>Translated to</th><th>Rule comment</th></tr>\n"; |
e673ee24 DO |
1083 | foreach ($forwards['in'] as $pf) |
1084 | { | |
1085 | echo "<tr>"; | |
4fbb5a00 DY |
1086 | echo "<td>${pf['proto']}/<a href='".makeHref(array('page'=>'ipaddress', 'tab'=>'default', 'ip'=>$pf['localip']))."'>${pf['localip']}</a>:${pf['localport']}</td>"; |
1087 | echo "<td class='description'><a href='".makeHref(array('page'=>'object', 'tab'=>'default', 'object_id'=>$pf['object_id']))."'>${pf['object_name']}</a>"; | |
1088 | echo "</td><td><a href='".makeHref(array('page'=>'ipaddress', 'tab'=>'default', 'ip'=>$pf['remoteip']))."'>${pf['remoteip']}</a>:${pf['remoteport']}</td>"; | |
e673ee24 DO |
1089 | echo "<td class='description'>${pf['description']}</td></tr>"; |
1090 | } | |
e673ee24 DO |
1091 | echo "</table><br><br>"; |
1092 | } | |
1093 | finishPortlet(); | |
1094 | } | |
1095 | ||
94fe6370 | 1096 | $pools = $info['ipv4rspools']; |
78e7b769 DO |
1097 | if (count ($pools)) |
1098 | { | |
300826cb | 1099 | $order = 'odd'; |
8128c257 | 1100 | startPortlet ('Real server pools (' . count ($pools) . ')'); |
78e7b769 | 1101 | echo "<table cellspacing=0 cellpadding=5 align=center class=widetable>\n"; |
732e4578 | 1102 | echo "<tr><th>VS</th><th>RS pool</th><th>RS</th><th>VS config</th><th>RS config</th></tr>\n"; |
748805bf | 1103 | foreach ($pools as $vs_id => $info) |
78e7b769 | 1104 | { |
b1a970c7 | 1105 | echo "<tr valign=top class=row_${order}><td class=tdleft>"; |
6df2025d | 1106 | renderCell (spotEntity ('ipv4vs', $vs_id)); |
b1a970c7 | 1107 | echo "</td><td class=tdleft>"; |
6cd32e3c | 1108 | renderCell (spotEntity ('ipv4rspool', $info['pool_id'])); |
b1a970c7 DO |
1109 | echo '</td><td class=tdleft>' . $info['rscount'] . '</td>'; |
1110 | echo "<td class=slbconf>${info['vsconfig']}</td>"; | |
1111 | echo "<td class=slbconf>${info['rsconfig']}</td>"; | |
78e7b769 | 1112 | echo "</tr>\n"; |
300826cb | 1113 | $order = $nextorder[$order]; |
78e7b769 DO |
1114 | } |
1115 | echo "</table>\n"; | |
1116 | finishPortlet(); | |
1117 | } | |
e673ee24 DO |
1118 | echo "</td>\n"; |
1119 | ||
7056988c | 1120 | // After left column we have (surprise!) right column with rackspace portlet only. |
e673ee24 DO |
1121 | echo "<td class=pcright>"; |
1122 | // rackspace portlet | |
0ab782bc | 1123 | startPortlet ('rackspace allocation'); |
932e8cc2 DO |
1124 | foreach (getResidentRacksData ($object_id, FALSE) as $rack_id) |
1125 | renderRack ($rack_id, $object_id); | |
e673ee24 DO |
1126 | echo '<br>'; |
1127 | finishPortlet(); | |
1128 | echo "</td></tr>"; | |
1129 | echo "</table>\n"; | |
1130 | } | |
1131 | ||
1132 | function renderRackMultiSelect ($sname, $racks, $selected) | |
1133 | { | |
04571888 DO |
1134 | // Transform the given flat list into a list of groups, each representing a rack row. |
1135 | $rdata = array(); | |
e673ee24 | 1136 | foreach ($racks as $rack) |
04571888 DO |
1137 | if (!isset ($rdata[$rack['row_name']])) |
1138 | $rdata[$rack['row_name']] = array ($rack['id'] => $rack['name']); | |
1139 | else | |
1140 | $rdata[$rack['row_name']][$rack['id']] = $rack['name']; | |
4fbb5a00 | 1141 | echo "<select name=${sname} multiple size=" . getConfigVar ('MAXSELSIZE') . " onchange='getElementsByName(\"updateObjectAllocation\")[0].submit()'>\n"; |
04571888 | 1142 | foreach ($rdata as $optgroup => $racklist) |
e673ee24 | 1143 | { |
04571888 DO |
1144 | echo "<optgroup label='${optgroup}'>"; |
1145 | foreach ($racklist as $rack_id => $rack_name) | |
1146 | { | |
1147 | echo "<option value=${rack_id}"; | |
1148 | if (!(array_search ($rack_id, $selected) === FALSE)) | |
1149 | echo ' selected'; | |
1150 | echo">${rack_name}</option>\n"; | |
1151 | } | |
e673ee24 DO |
1152 | } |
1153 | echo "</select>\n"; | |
1154 | } | |
1155 | ||
e673ee24 | 1156 | // This function renders a form for port edition. |
7e1db771 | 1157 | function renderPortsForObject ($object_id) |
e673ee24 | 1158 | { |
39b4abd0 DO |
1159 | function printNewItemTR () |
1160 | { | |
1161 | printOpFormIntro ('addPort'); | |
1162 | echo "<tr><td>"; | |
f5ff50f5 | 1163 | printImageHREF ('add', 'add a port', TRUE); |
39b4abd0 | 1164 | echo "</td><td><input type=text size=8 name=port_name tabindex=100></td>\n"; |
3decd141 DO |
1165 | echo "<td><input type=text size=24 name=port_label tabindex=101></td><td>"; |
1166 | printSelect (getPortTypes(), 'port_type_id', getConfigVar ('default_port_type'), 102); | |
39b4abd0 | 1167 | echo "<td><input type=text name=port_l2address tabindex=103></td>\n"; |
9318d2ef DO |
1168 | echo "<td colspan=3> </td><td>"; |
1169 | printImageHREF ('add', 'add a port', TRUE, 104); | |
1170 | echo "</td></tr></form>"; | |
39b4abd0 | 1171 | } |
e673ee24 DO |
1172 | startPortlet ('Ports and interfaces'); |
1173 | $ports = getObjectPortsAndLinks ($object_id); | |
1174 | usort($ports, 'sortByName'); | |
1175 | echo "<table cellspacing=0 cellpadding='5' align='center' class='widetable'>\n"; | |
1176 | echo "<tr><th> </th><th>Local name</th><th>Visible label</th><th>Port type</th><th>L2 address</th>"; | |
1177 | echo "<th>Rem. object</th><th>Rem. port</th><th>(Un)link or (un)reserve</th><th> </th></tr>\n"; | |
39b4abd0 DO |
1178 | if (getConfigVar ('ADDNEW_AT_TOP') == 'yes') |
1179 | printNewItemTR(); | |
e673ee24 DO |
1180 | foreach ($ports as $port) |
1181 | { | |
7056988c | 1182 | printOpFormIntro ('editPort', array ('port_id' => $port['id'])); |
b7f0eaec | 1183 | echo "<tr><td><a href='".makeHrefProcess(array('op'=>'delPort', 'port_id'=>$port['id'], 'object_id'=>$object_id, 'port_name'=>$port['name']))."'>"; |
e673ee24 DO |
1184 | printImageHREF ('delete', 'Unlink and Delete this port'); |
1185 | echo "</a></td>\n"; | |
1186 | echo "<td><input type=text name=name value='${port['name']}' size=8></td>"; | |
1187 | echo "<td><input type=text name=label value='${port['label']}' size=24></td>"; | |
611170af AD |
1188 | if (!$port['remote_object_id']) |
1189 | { | |
1190 | echo "<td>"; | |
1191 | printSelect (getPortTypes(), 'port_type_id', $port['type_id']); | |
1192 | echo "</td>"; | |
1193 | } | |
1194 | else | |
1195 | { | |
1196 | echo "<input type=hidden name=port_type_id value='${port['type_id']}'>"; | |
f7a3c94a | 1197 | echo "<td class=tdleft>${port['type']}</td>\n"; |
611170af | 1198 | } |
e673ee24 DO |
1199 | echo "<td><input type=text name=l2address value='${port['l2address']}'></td>\n"; |
1200 | if ($port['remote_object_id']) | |
1201 | { | |
4fbb5a00 | 1202 | echo "<td><a href='".makeHref(array('page'=>'object', 'object_id'=>$port['remote_object_id']))."'>${port['remote_object_name']}</a></td>"; |
e673ee24 | 1203 | echo "<td>${port['remote_name']}</td>"; |
4fbb5a00 DY |
1204 | echo "<td><a href='". |
1205 | makeHrefProcess(array( | |
1206 | 'op'=>'unlinkPort', | |
1207 | 'port_id'=>$port['id'], | |
1208 | 'object_id'=>$object_id, | |
1209 | 'port_name'=>$port['name'], | |
1210 | 'remote_port_name'=>$port['remote_name'], | |
1211 | 'remote_object_name'=>$port['remote_object_name'])). | |
1212 | "'>"; | |
5ccd99a0 | 1213 | printImageHREF ('cut', 'Unlink this port'); |
e673ee24 DO |
1214 | echo "</a></td>"; |
1215 | } | |
59a83bd8 | 1216 | elseif (strlen ($port['reservation_comment'])) |
e673ee24 DO |
1217 | { |
1218 | echo "<td><b>Reserved;</b></td>"; | |
1219 | echo "<td><input type=text name=reservation_comment value='${port['reservation_comment']}'></td>"; | |
4fbb5a00 DY |
1220 | echo "<td><a href='". |
1221 | makeHrefProcess(array( | |
1222 | 'op'=>'useup', | |
1223 | 'port_id'=>$port['id'], | |
1224 | 'object_id'=>$object_id)). | |
1225 | "'>"; | |
39be655e | 1226 | printImageHREF ('clear', 'Use up this port'); |
e673ee24 DO |
1227 | echo "</a></td>"; |
1228 | } | |
1229 | else | |
1230 | { | |
1231 | echo "<td> </td><td> </td>"; | |
1232 | echo "<td>"; | |
39106006 | 1233 | echo "<a href='javascript:;' onclick='window.open(\"".makeHrefForHelper('portlist', array('port'=>$port['id'], 'type'=>$port['type_id'], 'object_id'=>$object_id, 'port_name'=>$port['name']))."\",\"findlink\",\"height=700, width=400, location=no, menubar=no, resizable=yes, scrollbars=no, status=no, titlebar=no, toolbar=no\");'>"; |
5ccd99a0 | 1234 | printImageHREF ('plug', 'Link this port'); |
e673ee24 DO |
1235 | echo "</a> <input type=text name=reservation_comment>"; |
1236 | echo "</td>\n"; | |
1237 | } | |
5bbbeaa2 DO |
1238 | echo "<td>"; |
1239 | printImageHREF ('save', 'Save changes', TRUE); | |
1240 | echo "</td></form></tr>\n"; | |
e673ee24 | 1241 | } |
39b4abd0 DO |
1242 | if (getConfigVar ('ADDNEW_AT_TOP') != 'yes') |
1243 | printNewItemTR(); | |
e673ee24 DO |
1244 | echo "</table><br>\n"; |
1245 | finishPortlet(); | |
1246 | ||
1247 | startPortlet ('Add/update multiple ports'); | |
7056988c | 1248 | printOpFormIntro ('addMultiPorts'); |
f7a3c94a | 1249 | echo 'Format: <select name=format tabindex=201>'; |
e673ee24 DO |
1250 | echo '<option value=c3600asy>Cisco 3600 async: sh line | inc TTY</option>'; |
1251 | echo '<option value=fiwg selected>Foundry ServerIron/FastIron WorkGroup/Edge: sh int br</option>'; | |
e673ee24 | 1252 | echo '<option value=fisxii>Foundry FastIron SuperX/II4000: sh int br</option>'; |
351d4dbf | 1253 | echo '<option value=ssv1>SSV:<interface name> <MAC address></option>'; |
e673ee24 DO |
1254 | echo "</select>"; |
1255 | echo 'Default port type: '; | |
f7a3c94a DO |
1256 | printSelect (getPortTypes(), 'port_type', getConfigVar ('default_port_type'), 202); |
1257 | echo "<input type=submit value='Parse output' tabindex=204><br>\n"; | |
1258 | echo "<textarea name=input cols=100 rows=50 tabindex=203></textarea><br>\n"; | |
e673ee24 DO |
1259 | echo '</form>'; |
1260 | finishPortlet(); | |
1261 | } | |
1262 | ||
7e1db771 | 1263 | function renderIPv4ForObject ($object_id) |
e673ee24 | 1264 | { |
39b4abd0 DO |
1265 | function printNewItemTR () |
1266 | { | |
1267 | global $aat; | |
1268 | printOpFormIntro ('addIPv4Allocation'); | |
1269 | echo "<tr><td>"; | |
f5ff50f5 | 1270 | printImageHREF ('add', 'allocate', TRUE); |
39b4abd0 DO |
1271 | echo "</td>"; |
1272 | echo "<td class=tdleft><input type='text' size='10' name='bond_name' tabindex=100></td>\n"; | |
1273 | echo "<td class=tdleft><input type=text name='ip' tabindex=101></td>\n"; | |
0b9c98d7 | 1274 | echo "<td colspan=2> </td><td>"; |
f5ff50f5 | 1275 | printSelect ($aat, 'bond_type', NULL, 102); |
9318d2ef | 1276 | echo "</td><td> </td><td>"; |
f5ff50f5 | 1277 | printImageHREF ('add', 'allocate', TRUE, 103); |
9318d2ef | 1278 | echo "</td></tr></form>"; |
39b4abd0 | 1279 | } |
94fe6370 DO |
1280 | $focus = spotEntity ('object', $object_id); |
1281 | amplifyCell ($focus); | |
b82cce3f | 1282 | global $aat; |
72d8ced3 | 1283 | startPortlet ('Allocations'); |
e673ee24 | 1284 | echo "<table cellspacing=0 cellpadding='5' align='center' class='widetable'>\n"; |
79e45b4c DO |
1285 | echo '<tr><th> </th><th>OS interface</th><th>IP address</th>'; |
1286 | if (getConfigVar ('EXT_IPV4_VIEW') == 'yes') | |
0b9c98d7 | 1287 | echo '<th>network</th><th>routed by</th>'; |
79e45b4c | 1288 | echo '<th>type</th><th>misc</th><th> </th></tr>'; |
09620506 | 1289 | |
39b4abd0 DO |
1290 | if (getConfigVar ('ADDNEW_AT_TOP') == 'yes') |
1291 | printNewItemTR(); | |
94fe6370 | 1292 | foreach ($focus['ipv4'] as $dottedquad => $alloc) |
e673ee24 | 1293 | { |
85970da2 | 1294 | $class = $alloc['addrinfo']['class']; |
79e45b4c | 1295 | $netid = getIPv4AddressNetworkId ($dottedquad); |
d7a8186d DO |
1296 | if (NULL !== $netid) |
1297 | { | |
d724d290 | 1298 | $netinfo = spotEntity ('ipv4net', $netid); |
d7a8186d DO |
1299 | loadIPv4AddrList ($netinfo); |
1300 | } | |
85970da2 | 1301 | printOpFormIntro ('updIPv4Allocation', array ('ip' => $dottedquad)); |
4fbb5a00 | 1302 | echo "<tr class='$class' valign=top><td><a href='".makeHrefProcess(array('op'=>'delIPv4Allocation', 'ip'=>$dottedquad, 'object_id'=>$object_id))."'>"; |
e673ee24 DO |
1303 | printImageHREF ('delete', 'Delete this IPv4 address'); |
1304 | echo "</a></td>"; | |
d7a8186d DO |
1305 | echo "<td class=tdleft><input type='text' name='bond_name' value='${alloc['osif']}' size=10></td><td class=tdleft>"; |
1306 | if (NULL !== $netid) | |
4fbb5a00 | 1307 | echo "<a href='".makeHref(array('page'=>'ipaddress', 'ip'=>$dottedquad))."'>${dottedquad}</a>"; |
d7a8186d DO |
1308 | else |
1309 | echo $dottedquad; | |
79e45b4c | 1310 | if (getConfigVar ('EXT_IPV4_VIEW') != 'yes') |
d7a8186d | 1311 | echo '<small>/' . (NULL === $netid ? '??' : $netinfo['mask']) . '</small>'; |
59a83bd8 | 1312 | if (strlen ($alloc['addrinfo']['name'])) |
28a664e7 | 1313 | echo ' (' . niftyString ($alloc['addrinfo']['name']) . ')'; |
79e45b4c DO |
1314 | echo '</td>'; |
1315 | // FIXME: this a copy-and-paste from renderRackObject() | |
1316 | if (getConfigVar ('EXT_IPV4_VIEW') == 'yes') | |
1317 | { | |
1318 | if (NULL === $netid) | |
0b9c98d7 | 1319 | echo '<td class=sparenetwork>N/A</td><td class=sparenetwork>N/A</td>'; |
79e45b4c | 1320 | else |
79e45b4c | 1321 | { |
0b9c98d7 | 1322 | echo '<td>'; |
6df2025d | 1323 | renderCell ($netinfo); |
d7a8186d | 1324 | echo '</td>'; |
0b9c98d7 DO |
1325 | // filter out self-allocation |
1326 | $other_routers = array(); | |
1327 | foreach (findRouters ($netinfo['addrlist']) as $router) | |
1328 | if ($router['id'] != $object_id) | |
1329 | $other_routers[] = $router; | |
1330 | if (count ($other_routers)) | |
1331 | printRoutersTD ($other_routers); | |
1332 | else | |
1333 | echo "<td> </td>"; | |
79e45b4c | 1334 | } |
79e45b4c DO |
1335 | } |
1336 | echo '<td>'; | |
85970da2 | 1337 | printSelect ($aat, 'bond_type', $alloc['type']); |
e673ee24 | 1338 | echo "</td><td>"; |
85970da2 | 1339 | $prefix = ''; |
4940e4d5 | 1340 | if ($alloc['addrinfo']['reserved'] == 'yes') |
e673ee24 | 1341 | { |
85970da2 DO |
1342 | echo $prefix . '<strong>RESERVED</strong>'; |
1343 | $prefix = '; '; | |
e673ee24 | 1344 | } |
85970da2 | 1345 | foreach ($alloc['addrinfo']['allocs'] as $allocpeer) |
e673ee24 | 1346 | { |
85970da2 DO |
1347 | if ($allocpeer['object_id'] == $object_id) |
1348 | continue; | |
4fbb5a00 | 1349 | echo $prefix . "<a href='".makeHref(array('page'=>'object', 'object_id'=>$allocpeer['object_id']))."'>"; |
43eb71f1 | 1350 | if (isset ($allocpeer['osif']) and strlen ($allocpeer['osif'])) |
85970da2 DO |
1351 | echo $allocpeer['osif'] . '@'; |
1352 | echo $allocpeer['object_name'] . '</a>'; | |
1353 | $prefix = '; '; | |
e673ee24 | 1354 | } |
d54b9495 DO |
1355 | echo "</td><td>"; |
1356 | printImageHREF ('save', 'Save changes', TRUE); | |
1357 | echo "</td></form></tr>\n"; | |
e673ee24 | 1358 | } |
39b4abd0 DO |
1359 | if (getConfigVar ('ADDNEW_AT_TOP') != 'yes') |
1360 | printNewItemTR(); | |
e673ee24 | 1361 | |
09620506 | 1362 | echo "</table><br>\n"; |
e673ee24 DO |
1363 | finishPortlet(); |
1364 | ||
1365 | } | |
1366 | ||
baf37d01 DO |
1367 | // Log structure versions: |
1368 | // 1: the whole structure is a list of code-message pairs | |
1369 | // 2 and later: there's a "v" field set, which indicates the version | |
1370 | // 2: there's a "m" list set to hold message code and optional arguments | |
1cb6adf5 | 1371 | function showMessageOrError () |
e673ee24 | 1372 | { |
1cb6adf5 DO |
1373 | if (!isset ($_SESSION['log'])) |
1374 | return; | |
1375 | $log = $_SESSION['log']; | |
baf37d01 DO |
1376 | switch (TRUE) |
1377 | { | |
1378 | case !isset ($log['v']): | |
ebb5441d | 1379 | case $log['v'] == 1: |
baf37d01 | 1380 | foreach ($log as $key => $record) |
ebb5441d | 1381 | if ($key !== 'v') |
baf37d01 DO |
1382 | echo "<div class=msg_${record['code']}>${record['message']}</div>"; |
1383 | break; | |
1384 | case $log['v'] == 2: | |
1385 | $msginfo = array | |
1386 | ( | |
8628ae44 | 1387 | // records 0~99 with success messages |
950a1887 | 1388 | 0 => array ('code' => 'success', 'format' => '%s'), |
baf37d01 DO |
1389 | 1 => array ('code' => 'success', 'format' => '%u new records done, %u already existed'), |
1390 | 2 => array ('code' => 'success', 'format' => 'NATv4 rule was successfully added.'), | |
1391 | 3 => array ('code' => 'success', 'format' => 'NATv4 rule was successfully deleted.'), | |
1392 | 4 => array ('code' => 'success', 'format' => 'NATv4 rule was successfully updated'), | |
1393 | 5 => array ('code' => 'success', 'format' => 'Port %s was added successfully'), | |
1394 | 6 => array ('code' => 'success', 'format' => 'Port %s was updated successfully'), | |
1395 | 7 => array ('code' => 'success', 'format' => 'Port %s was deleted successfully'), | |
1396 | 8 => array ('code' => 'success', 'format' => 'Port %s successfully linked with port %s at object %s'), | |
1397 | 9 => array ('code' => 'success', 'format' => 'Port %s was successfully unlinked from %s@%s'), | |
1398 | 10 => array ('code' => 'success', 'format' => 'Added %u ports, updated %u ports, encountered %u errors.'), | |
1399 | 11 => array ('code' => 'success', 'format' => 'Reservation removed.'), | |
1400 | 12 => array ('code' => 'success', 'format' => 'allocation updated'), | |
1401 | 13 => array ('code' => 'success', 'format' => 'allocated'), | |
1402 | 14 => array ('code' => 'success', 'format' => 'deallocated'), | |
1403 | 15 => array ('code' => 'success', 'format' => 'Reset succeeded.'), | |
1404 | 16 => array ('code' => 'success', 'format' => 'Update done'), | |
1405 | 17 => array ('code' => 'success', 'format' => 'Update(s) succeeded.'), | |
1406 | 18 => array ('code' => 'success', 'format' => 'Load balancer was successfully added'), | |
1407 | 19 => array ('code' => 'success', 'format' => 'Load balancer was successfully deleted'), | |
1408 | 20 => array ('code' => 'success', 'format' => 'Load balancer info was successfully updated'), | |
1409 | 21 => array ('code' => 'success', 'format' => 'Generation complete'), | |
1410 | 22 => array ('code' => 'success', 'format' => 'Chained %u tags'), | |
1411 | 23 => array ('code' => 'success', 'format' => 'IPv4 prefix successfully added'), | |
1412 | 24 => array ('code' => 'success', 'format' => 'IPv4 prefix deleted'), | |
1413 | 25 => array ('code' => 'success', 'format' => 'IPv4 prefix updated'), | |
1414 | 26 => array ('code' => 'success', 'format' => '%u IP address(es) were successfully updated'), | |
1415 | 27 => array ('code' => 'success', 'format' => 'IPv4 address updated'), | |
1416 | 28 => array ('code' => 'success', 'format' => 'Virtual service was successfully created'), | |
1417 | 29 => array ('code' => 'success', 'format' => 'Virtual service was successfully deleted'), | |
1418 | 30 => array ('code' => 'success', 'format' => 'Virtual service was successfully updated'), | |
1419 | 31 => array ('code' => 'success', 'format' => 'RS pool was successfully created'), | |
1420 | 32 => array ('code' => 'success', 'format' => 'RS pool was successfully deleted'), | |
1421 | 33 => array ('code' => 'success', 'format' => 'RS pool was successfully updated'), | |
1422 | 34 => array ('code' => 'success', 'format' => 'Real server was successfully added'), | |
1423 | 35 => array ('code' => 'success', 'format' => 'Real server was successfully deleted'), | |
1424 | 36 => array ('code' => 'success', 'format' => 'Real server was successfully updated'), | |
1425 | 37 => array ('code' => 'success', 'format' => 'Successfully added %u real servers'), | |
1426 | 38 => array ('code' => 'success', 'format' => '%u real server(s) were successfully (de)activated'), | |
1427 | 39 => array ('code' => 'success', 'format' => 'User account %s updated.'), | |
1428 | 40 => array ('code' => 'success', 'format' => 'User account %s created.'), | |
79b8ad1e DO |
1429 | // ... |
1430 | // ... | |
baf37d01 DO |
1431 | 43 => array ('code' => 'success', 'format' => 'Saved successfully.'), |
1432 | 44 => array ('code' => 'success', 'format' => '%s failures and %s successfull changes.'), | |
1433 | 45 => array ('code' => 'success', 'format' => "Attribute '%s' created."), | |
1434 | 46 => array ('code' => 'success', 'format' => 'Rename successful.'), | |
1435 | 47 => array ('code' => 'success', 'format' => 'Attribute was deleted.'), | |
1436 | 48 => array ('code' => 'success', 'format' => 'Supplement succeeded.'), | |
1437 | 49 => array ('code' => 'success', 'format' => 'Reduction succeeded.'), | |
1438 | 50 => array ('code' => 'success', 'format' => 'Reduction succeeded.'), | |
1439 | 51 => array ('code' => 'success', 'format' => 'Update succeeded.'), | |
1440 | 52 => array ('code' => 'success', 'format' => 'Supplement succeeded.'), | |
1441 | 53 => array ('code' => 'success', 'format' => 'Chapter was deleted.'), | |
1442 | 54 => array ('code' => 'success', 'format' => 'Chapter was updated.'), | |
1443 | 55 => array ('code' => 'success', 'format' => 'Chapter was added.'), | |
1444 | 56 => array ('code' => 'success', 'format' => 'Update succeeded.'), | |
1445 | 57 => array ('code' => 'success', 'format' => 'Reset complete'), | |
c615a655 | 1446 | 58 => array ('code' => 'success', 'format' => "Deleted tag '%s'."), |
baf37d01 DO |
1447 | 59 => array ('code' => 'success', 'format' => "Created tag '%s'."), |
1448 | 60 => array ('code' => 'success', 'format' => "Updated tag '%s'."), | |
ebb5441d | 1449 | 61 => array ('code' => 'success', 'format' => 'Password changed successfully.'), |
24dcb9d8 | 1450 | 62 => array ('code' => 'success', 'format' => 'gw: %s'), |
f0ff4930 DO |
1451 | 63 => array ('code' => 'success', 'format' => '%u change request(s) have been processed'), |
1452 | 64 => array ('code' => 'success', 'format' => 'Port %s@%s has been assigned to VLAN %u'), | |
f19c75d6 | 1453 | 65 => array ('code' => 'success', 'format' => "Added new rack '%s'"), |
03e6ef01 | 1454 | 66 => array ('code' => 'success', 'format' => "File sent Ok via handler '%s'"), |
abef7149 | 1455 | 67 => array ('code' => 'success', 'format' => "Tag rolling done, %u objects involved"), |
0c2b7c4a | 1456 | 68 => array ('code' => 'success', 'format' => "Updated rack '%s'"), |
7be51fea DO |
1457 | 69 => array ('code' => 'success', 'format' => 'File "%s" was added successfully'), |
1458 | 70 => array ('code' => 'success', 'format' => 'File "%s" was updated successfully'), | |
1459 | 71 => array ('code' => 'success', 'format' => 'File "%s" was linked successfully'), | |
8bc5d1e4 | 1460 | 72 => array ('code' => 'success', 'format' => 'File was unlinked successfully'), |
7be51fea DO |
1461 | 73 => array ('code' => 'success', 'format' => 'File "%s" was deleted successfully'), |
1462 | 74 => array ('code' => 'success', 'format' => 'Row "%s" was added successfully'), | |
1463 | 75 => array ('code' => 'success', 'format' => 'Row "%s" was updated successfully'), | |
1464 | 76 => array ('code' => 'success', 'format' => 'Object "%s" was deleted successfully'), | |
1465 | 77 => array ('code' => 'success', 'format' => 'Row "%s" was deleted successfully'), | |
1466 | 78 => array ('code' => 'success', 'format' => 'File "%s" saved Ok'), | |
1467 | 79 => array ('code' => 'success', 'format' => 'Rack "%s" was deleted successfully'), | |
57777e4a | 1468 | 80 => array ('code' => 'success', 'format' => "Added new object '%s'"), |
f0ff4930 | 1469 | |
8628ae44 | 1470 | // records 100~199 with fatal error messages |
950a1887 | 1471 | 100 => array ('code' => 'error', 'format' => '%s'), |
ebb5441d DO |
1472 | 101 => array ('code' => 'error', 'format' => 'Port name cannot be empty'), |
1473 | 102 => array ('code' => 'error', 'format' => "Error creating user account '%s'"), | |
b82cce3f | 1474 | 103 => array ('code' => 'error', 'format' => 'User not found!'), |
ebb5441d | 1475 | 104 => array ('code' => 'error', 'format' => "Error updating user account '%s'"), |
79b8ad1e DO |
1476 | // ... |
1477 | // ... | |
1478 | // ... | |
ebb5441d DO |
1479 | 108 => array ('code' => 'error', 'format' => '%u failures and %u successfull changes.'), |
1480 | 109 => array ('code' => 'error', 'format' => 'Update failed!'), | |
1481 | 110 => array ('code' => 'error', 'format' => 'Supplement failed!'), | |
1482 | 111 => array ('code' => 'error', 'format' => 'Reduction failed!'), | |
1483 | 112 => array ('code' => 'error', 'format' => 'Error adding chapter.'), | |
1484 | 113 => array ('code' => 'error', 'format' => 'Error updating chapter.'), | |
1485 | 114 => array ('code' => 'error', 'format' => 'Error deleting chapter.'), | |
1486 | 115 => array ('code' => 'error', 'format' => 'Error renaming attribute.'), | |
1487 | 116 => array ('code' => 'error', 'format' => 'Error creating attribute.'), | |
1488 | 117 => array ('code' => 'error', 'format' => 'Error deleting attribute.'), | |
1489 | 118 => array ('code' => 'error', 'format' => 'Supplement failed!'), | |
1490 | 119 => array ('code' => 'error', 'format' => 'Reduction failed!'), | |
1491 | 120 => array ('code' => 'error', 'format' => 'Reset failed!'), | |
1492 | 121 => array ('code' => 'error', 'format' => 'commitUpdateObject() failed'), | |
1493 | 122 => array ('code' => 'error', 'format' => 'One or more update(s) failed!'), | |
1494 | 123 => array ('code' => 'error', 'format' => 'Cannot process submitted data: unknown format code.'), | |
1495 | 124 => array ('code' => 'error', 'format' => 'Error removing reservation!'), | |
1496 | 125 => array ('code' => 'error', 'format' => "Update failed with error: '%s'"), | |
1497 | 126 => array ('code' => 'error', 'format' => 'addRStoRSPool() failed'), | |
1498 | 127 => array ('code' => 'error', 'format' => 'Added %u real servers and encountered %u errors'), | |
1499 | 128 => array ('code' => 'error', 'format' => 'commitDeleteRS() failed'), | |
1500 | 129 => array ('code' => 'error', 'format' => 'commitDeleteLB() failed'), | |
1501 | 130 => array ('code' => 'error', 'format' => 'commitDeleteVS() failed'), | |
1502 | 131 => array ('code' => 'error', 'format' => 'invalid format requested'), | |
1503 | 132 => array ('code' => 'error', 'format' => 'invalid protocol'), | |
1504 | 133 => array ('code' => 'error', 'format' => 'commitUpdateRS() failed'), | |
1505 | 134 => array ('code' => 'error', 'format' => 'commitUpdateLB() failed'), | |
1506 | 135 => array ('code' => 'error', 'format' => 'commitUpdateVS() failed'), | |
1507 | 136 => array ('code' => 'error', 'format' => 'addLBtoRSPool() failed'), | |
1508 | 137 => array ('code' => 'error', 'format' => 'addLBtoRSPool() failed'), | |
1509 | 138 => array ('code' => 'error', 'format' => 'commitDeleteRSPool() failed'), | |
1510 | 139 => array ('code' => 'error', 'format' => 'commitUpdateRSPool() failed'), | |
1511 | 140 => array ('code' => 'error', 'format' => 'Encountered %u errors, (de)activated %u real servers'), | |
1512 | 141 => array ('code' => 'error', 'format' => 'Encountered %u errors, updated %u IP address(es)'), | |
1513 | 142 => array ('code' => 'error', 'format' => 'executeAutoPorts() failed'), | |
1514 | 143 => array ('code' => 'error', 'format' => 'Tried chaining %u tags, but experienced %u errors.'), | |
1515 | 144 => array ('code' => 'error', 'format' => "Error deleting tag: '%s'"), | |
1516 | 145 => array ('code' => 'error', 'format' => "Invalid tag name '%s'"), | |
590e1281 DO |
1517 | // ... |
1518 | 147 => array ('code' => 'error', 'format' => "Could not create tag '%s': %s"), | |
1519 | 148 => array ('code' => 'error', 'format' => "Could not update tag '%s': %s"), | |
ebb5441d DO |
1520 | 149 => array ('code' => 'error', 'format' => 'Turing test failed'), |
1521 | 150 => array ('code' => 'error', 'format' => 'Can only change password under DB authentication.'), | |
1522 | 151 => array ('code' => 'error', 'format' => 'Old password doesn\'t match.'), | |
1523 | 152 => array ('code' => 'error', 'format' => 'New passwords don\'t match.'), | |
1524 | 153 => array ('code' => 'error', 'format' => 'Password change failed.'), | |
1525 | 154 => array ('code' => 'error', 'format' => "Verification error: %s"), | |
1526 | 155 => array ('code' => 'error', 'format' => 'Save failed.'), | |
1527 | 156 => array ('code' => 'error', 'format' => 'getSwitchVLANs() failed'), | |
e81fb764 | 1528 | 157 => array ('code' => 'error', 'format' => 'operation not permitted'), |
24dcb9d8 DO |
1529 | 158 => array ('code' => 'error', 'format' => 'Ignoring malformed record #%u in form submit'), |
1530 | 159 => array ('code' => 'error', 'format' => 'Permission denied moving port %s from VLAN%u to VLAN%u'), | |
1531 | 160 => array ('code' => 'error', 'format' => 'Invalid arguments'), | |
1532 | 161 => array ('code' => 'error', 'format' => 'Endpoint not found. Please either set FQDN attribute or assign an IP address to the object.'), | |
1533 | 162 => array ('code' => 'error', 'format' => 'More than one IP address is assigned to this object, please configure FQDN attribute.'), | |
1534 | 163 => array ('code' => 'error', 'format' => 'Failed to get any response from queryGateway() or the gateway died'), | |
c030232f | 1535 | 164 => array ('code' => 'error', 'format' => 'Gateway failure: %s.'), |
24dcb9d8 DO |
1536 | 165 => array ('code' => 'error', 'format' => 'Gateway failure: malformed reply.'), |
1537 | 166 => array ('code' => 'error', 'format' => 'gw: %s'), | |
f0ff4930 DO |
1538 | 167 => array ('code' => 'error', 'format' => 'Could not find port %s'), |
1539 | 168 => array ('code' => 'error', 'format' => 'Port %s is a trunk'), | |
1540 | 169 => array ('code' => 'error', 'format' => 'Failed to configure %s, connector returned code %u'), | |
5222f192 | 1541 | 170 => array ('code' => 'error', 'format' => 'There is no network for IP address "%s"'), |
f19c75d6 DO |
1542 | 171 => array ('code' => 'error', 'format' => "Failed creating rack '%s'. Already exists in this row?"), |
1543 | 172 => array ('code' => 'error', 'format' => 'Malformed request'), | |
e5c4506d DO |
1544 | 173 => array ('code' => 'error', 'format' => "Invalid IPv4 prefix '%s'"), |
1545 | 174 => array ('code' => 'error', 'format' => 'Bad IPv4 address'), | |
1546 | 175 => array ('code' => 'error', 'format' => 'Invalid netmask'), | |
1547 | 176 => array ('code' => 'error', 'format' => 'This network already exists'), | |
0c2b7c4a | 1548 | 177 => array ('code' => 'error', 'format' => 'commitUpdateRack() failed'), |
121496b6 | 1549 | 178 => array ('code' => 'error', 'format' => 'file not found'), |
70cb9b56 DO |
1550 | 179 => array ('code' => 'error', 'format' => 'Declining outdated text. Re-edit the file for consistency.'), |
1551 | 180 => array ('code' => 'error', 'format' => 'Error saving file, all changes lost!'), | |
db55cf54 DO |
1552 | 181 => array ('code' => 'error', 'format' => "file uploads not allowed, change 'file_uploads' parameter in php.ini"), |
1553 | 182 => array ('code' => 'error', 'format' => 'SQL query failed: %s'), | |
c615a655 | 1554 | 183 => array ('code' => 'error', 'format' => "Tag id '%s' does not exist."), |
57777e4a DO |
1555 | 184 => array ('code' => 'error', 'format' => 'Submitted form is invalid at line %u'), |
1556 | 185 => array ('code' => 'error', 'format' => "Failed to add object '%s'"), | |
1557 | 186 => array ('code' => 'error', 'format' => 'Incomplete form has been ignored. Cheers.'), | |
9a61c175 | 1558 | 187 => array ('code' => 'error', 'format' => "Internal error in function '%s'"), |
f0ff4930 | 1559 | |
8628ae44 | 1560 | // records 200~299 with warnings |
950a1887 | 1561 | 200 => array ('code' => 'warning', 'format' => '%s'), |
24dcb9d8 DO |
1562 | 201 => array ('code' => 'warning', 'format' => 'nothing happened...'), |
1563 | 202 => array ('code' => 'warning', 'format' => 'gw: %s'), | |
f0ff4930 DO |
1564 | 203 => array ('code' => 'warning', 'format' => 'Port %s seems to be the first in VLAN %u at this switch.'), |
1565 | 204 => array ('code' => 'warning', 'format' => 'Check uplink/downlink configuration for proper operation.'), | |
1566 | 205 => array ('code' => 'warning', 'format' => '%u change request(s) have been ignored'), | |
c8187437 | 1567 | 206 => array ('code' => 'warning', 'format' => 'Rack is not empty'), |
db55cf54 | 1568 | 207 => array ('code' => 'warning', 'format' => 'Ignored empty request'), |
57777e4a | 1569 | |
baf37d01 DO |
1570 | ); |
1571 | // Handle the arguments. Is there any better way to do it? | |
1572 | foreach ($log['m'] as $record) | |
1573 | { | |
5222f192 DO |
1574 | if (!isset ($record['c']) or !isset ($msginfo[$record['c']])) |
1575 | { | |
1576 | echo '<div class=msg_neutral>(this message was lost)</div>'; | |
1577 | continue; | |
1578 | } | |
baf37d01 DO |
1579 | if (isset ($record['a'])) |
1580 | switch (count ($record['a'])) | |
1581 | { | |
1582 | case 1: | |
1583 | $msgtext = sprintf | |
1584 | ( | |
1585 | $msginfo[$record['c']]['format'], | |
1586 | $record['a'][0] | |
1587 | ); | |
1588 | break; | |
1589 | case 2: | |
1590 | $msgtext = sprintf | |
1591 | ( | |
1592 | $msginfo[$record['c']]['format'], | |
1593 | $record['a'][0], | |
1594 | $record['a'][1] | |
1595 | ); | |
1596 | break; | |
1597 | case 3: | |
1598 | $msgtext = sprintf | |
1599 | ( | |
1600 | $msginfo[$record['c']]['format'], | |
1601 | $record['a'][0], | |
1602 | $record['a'][1], | |
1603 | $record['a'][2] | |
1604 | ); | |
1605 | break; | |
1606 | case 4: | |
1607 | default: | |
1608 | $msgtext = sprintf | |
1609 | ( | |
1610 | $msginfo[$record['c']]['format'], | |
1611 | $record['a'][0], | |
1612 | $record['a'][1], | |
1613 | $record['a'][2], | |
1614 | $record['a'][3] | |
1615 | ); | |
1616 | break; | |
1617 | } | |
1618 | else | |
1619 | $msgtext = $msginfo[$record['c']]['format']; | |
1620 | echo '<div class=msg_' . $msginfo[$record['c']]['code'] . ">${msgtext}</div>"; | |
1621 | } | |
1622 | break; | |
1623 | default: | |
1624 | echo '<div class=msg_error>' . __FUNCTION__ . ': internal error</div>'; | |
1625 | break; | |
1626 | } | |
1cb6adf5 | 1627 | unset($_SESSION['log']); |
e673ee24 DO |
1628 | } |
1629 | ||
1630 | /* | |
1631 | The following conditions must be followed: | |
1632 | 1. We can mount onto free atoms only. This means: if any record for an atom | |
1633 | already exists in RackSpace, it can't be used for mounting. | |
1634 | 2. We can't unmount from 'W' atoms. Operator should review appropriate comments | |
1635 | and either delete them before unmounting or refuse to unmount the object. | |
1636 | */ | |
1637 | ||
1638 | // We extensively use $_REQUEST in the function. | |
7e1db771 | 1639 | function renderRackSpaceForObject ($object_id) |
e673ee24 | 1640 | { |
e673ee24 | 1641 | $is_update = isset ($_REQUEST['rackmulti'][0]); |
fb6e2f57 | 1642 | $info = spotEntity ('object', $object_id); |
e673ee24 DO |
1643 | if ($info == NULL) |
1644 | { | |
fb6e2f57 | 1645 | showError ('Error loading data', __FUNCTION__); |
e673ee24 DO |
1646 | return; |
1647 | } | |
1648 | // Always process occupied racks plus racks chosen by user. First get racks with | |
1649 | // already allocated rackspace... | |
f0e2c99f DO |
1650 | if (NULL === ($workingRacksData = getResidentRacksData ($object_id))) |
1651 | die; // some error already shown | |
e673ee24 DO |
1652 | |
1653 | // ...and then add those chosen by user (if any). | |
2135fd83 | 1654 | if (isset($_REQUEST['rackmulti'])) |
e673ee24 DO |
1655 | foreach ($_REQUEST['rackmulti'] as $cand_id) |
1656 | { | |
1657 | if (!isset ($workingRacksData[$cand_id])) | |
1658 | { | |
61a1d996 | 1659 | if (NULL == ($rackData = spotEntity ('rack', $cand_id))) |
e673ee24 | 1660 | { |
61a1d996 | 1661 | showError ('Rack not found', __FUNCTION__); |
e673ee24 DO |
1662 | return NULL; |
1663 | } | |
61a1d996 | 1664 | amplifyCell ($rackData); |
e673ee24 DO |
1665 | $workingRacksData[$cand_id] = $rackData; |
1666 | } | |
1667 | } | |
1668 | ||
2135fd83 DY |
1669 | printOpFormIntro ('updateObjectAllocation'); |
1670 | ||
e673ee24 | 1671 | // Do it only once... |
2135fd83 DY |
1672 | foreach ($workingRacksData as $rackId => &$rackData) |
1673 | { | |
e673ee24 | 1674 | applyObjectMountMask ($rackData, $object_id); |
2135fd83 DY |
1675 | echo "<input type=\"hidden\" name=\"rackmulti[]\" value=\"$rackId\">"; |
1676 | } | |
e673ee24 DO |
1677 | // Now we workaround an old caveat: http://bugs.php.net/bug.php?id=37410 |
1678 | unset ($rackData); | |
1679 | ||
e673ee24 | 1680 | // This is the time for rendering. |
51690ad4 | 1681 | |
e673ee24 DO |
1682 | // Main layout starts. |
1683 | echo "<table border=0 class=objectview cellspacing=0 cellpadding=0><tr>"; | |
1684 | ||
1685 | // Left portlet with rack list. | |
1686 | echo "<td class=pcleft height='1%'>"; | |
1687 | startPortlet ('Racks'); | |
a8efc03e | 1688 | $allRacksData = listCells ('rack'); |
4b8d413e DO |
1689 | if (count ($allRacksData) <= getConfigVar ('RACK_PRESELECT_THRESHOLD')) |
1690 | { | |
61a1d996 | 1691 | foreach ($allRacksData as $rack) |
4b8d413e | 1692 | { |
61a1d996 DO |
1693 | amplifyCell ($rack); |
1694 | $workingRacksData[$rack_id] = $rack; | |
4b8d413e DO |
1695 | } |
1696 | foreach ($workingRacksData as &$rackData) | |
1697 | applyObjectMountMask ($rackData, $object_id); | |
1698 | unset ($rackData); | |
1699 | } | |
1700 | renderRackMultiSelect ('rackmulti[]', $allRacksData, array_keys ($workingRacksData)); | |
e673ee24 DO |
1701 | echo "<br>"; |
1702 | echo "<br>"; | |
1703 | finishPortlet(); | |
1704 | echo "</td>"; | |
1705 | ||
1706 | // Middle portlet with comment and submit. | |
1707 | echo "<td class=pcleft>"; | |
1708 | startPortlet ('Comment'); | |
1709 | echo "<textarea name=comment rows=10 cols=40></textarea><br>\n"; | |
1710 | echo "<input type=submit value='Save' name=got_atoms>\n"; | |
1711 | echo "<br>"; | |
1712 | echo "<br>"; | |
1713 | finishPortlet(); | |
1714 | echo "</td>"; | |
1715 | ||
1716 | // Right portlet with rendered racks. If this form submit is not final, we have to | |
1717 | // reflect the former state of the grid in current form. | |
1718 | echo "<td class=pcright rowspan=2 height='1%'>"; | |
1719 | startPortlet ('Working copy'); | |
1720 | echo '<table border=0 cellspacing=10 align=center><tr>'; | |
1721 | foreach ($workingRacksData as $rack_id => $rackData) | |
1722 | { | |
1723 | // Order is important here: only original allocation is highlighted. | |
1724 | highlightObject ($rackData, $object_id); | |
1725 | markupAtomGrid ($rackData, 'T'); | |
1726 | // If we have a form processed, discard user input and show new database | |
1727 | // contents. | |
f0e2c99f | 1728 | if ($is_update) |
e673ee24 DO |
1729 | mergeGridFormToRack ($rackData); |
1730 | echo "<td valign=top>"; | |
1731 | echo "<center>\n<h2>${rackData['name']}</h2>\n"; | |
1732 | echo "<table class=rack border=0 cellspacing=0 cellpadding=1>\n"; | |
57c69e9c AD |
1733 | echo "<tr><th width='10%'> </th>"; |
1734 | echo "<th width='20%'><a href='javascript:;' onclick=\"toggleColumnOfAtoms('${rack_id}', '0', ${rackData['height']})\">Front</a></th>"; | |
1735 | echo "<th width='50%'><a href='javascript:;' onclick=\"toggleColumnOfAtoms('${rack_id}', '1', ${rackData['height']})\">Interior</a></th>"; | |
1736 | echo "<th width='20%'><a href='javascript:;' onclick=\"toggleColumnOfAtoms('${rack_id}', '2', ${rackData['height']})\">Back</a></th></tr>\n"; | |
e673ee24 | 1737 | renderAtomGrid ($rackData); |
57c69e9c AD |
1738 | echo "<tr><th width='10%'> </th>"; |
1739 | echo "<th width='20%'><a href='javascript:;' onclick=\"toggleColumnOfAtoms('${rack_id}', '0', ${rackData['height']})\">Front</a></th>"; | |
1740 | echo "<th width='50%'><a href='javascript:;' onclick=\"toggleColumnOfAtoms('${rack_id}', '1', ${rackData['height']})\">Interior</a></th>"; | |
1741 | echo "<th width='20%'><a href='javascript:;' onclick=\"toggleColumnOfAtoms('${rack_id}', '2', ${rackData['height']})\">Back</a></th></tr>\n"; | |
e673ee24 DO |
1742 | echo "</table></center>\n"; |
1743 | echo '</td>'; | |
1744 | } | |
1745 | echo "</tr></table>"; | |
1746 | finishPortlet(); | |
1747 | echo "</td>\n"; | |
1748 | ||
2135fd83 | 1749 | |
e673ee24 DO |
1750 | echo "</form>\n"; |
1751 | echo "</tr></table>\n"; | |
1752 | } | |
1753 | ||
1754 | function renderMolecule ($mdata, $object_id) | |
1755 | { | |
1756 | // sort data out | |
1757 | $rackpack = array(); | |
1758 | global $loclist; | |
64b95774 | 1759 | foreach ($mdata as $rua) |
e673ee24 DO |
1760 | { |
1761 | $rack_id = $rua['rack_id']; | |
1762 | $unit_no = $rua['unit_no']; | |
1763 | $atom = $rua['atom']; | |
1764 | if (!isset ($rackpack[$rack_id])) | |
1765 | { | |
61a1d996 DO |
1766 | $rackData = spotEntity ('rack', $rack_id); |
1767 | amplifyCell ($rackData); | |
e673ee24 DO |
1768 | for ($i = $rackData['height']; $i > 0; $i--) |
1769 | for ($locidx = 0; $locidx < 3; $locidx++) | |
1770 | $rackData[$i][$locidx]['state'] = 'F'; | |
1771 | $rackpack[$rack_id] = $rackData; | |
1772 | } | |
1773 | $rackpack[$rack_id][$unit_no][$loclist[$atom]]['state'] = 'T'; | |
1774 | $rackpack[$rack_id][$unit_no][$loclist[$atom]]['object_id'] = $object_id; | |
1775 | } | |
1776 | // now we have some racks to render | |
64b95774 | 1777 | foreach ($rackpack as $rackData) |
e673ee24 DO |
1778 | { |
1779 | markAllSpans ($rackData); | |
1780 | echo "<table class=molecule cellspacing=0>\n"; | |
1781 | echo "<caption>${rackData['name']}</caption>\n"; | |
1782 | echo "<tr><th width='10%'> </th><th width='20%'>Front</th><th width='50%'>Interior</th><th width='20%'>Back</th></tr>\n"; | |
1783 | for ($i = $rackData['height']; $i > 0; $i--) | |
1784 | { | |
1785 | echo "<tr><th>$i</th>"; | |
1786 | for ($locidx = 0; $locidx < 3; $locidx++) | |
1787 | { | |
1788 | $state = $rackData[$i][$locidx]['state']; | |
1789 | echo "<td class=state_${state}> </td>\n"; | |
1790 | } | |
1791 | echo "</tr>\n"; | |
1792 | } | |
1793 | echo "</table>\n"; | |
1794 | } | |
1795 | } | |
1796 | ||
e673ee24 DO |
1797 | function renderEmptyPortsSelect ($port_id, $type_id) |
1798 | { | |
1799 | $ports = getEmptyPortsOfType($type_id); | |
1800 | usort($ports, 'sortEmptyPorts'); | |
1801 | foreach ($ports as $port) | |
1802 | { | |
1803 | if ($port_id == $port['Port_id']) | |
1804 | continue; | |
1805 | echo "<option value='${port['Port_id']}' onclick='getElementById(\"remote_port_name\").value=\"${port['Port_name']}\"; getElementById(\"remote_object_name\").value=\"${port['Object_name']}\";'>${port['Object_name']} ${port['Port_name']}</option>\n"; | |
1806 | } | |
1807 | } | |
1808 | ||
23cdc7e9 | 1809 | function renderDepot () |
e673ee24 | 1810 | { |
23cdc7e9 | 1811 | global $pageno, $nextorder; |
23cdc7e9 DO |
1812 | $cellfilter = getCellFilter(); |
1813 | $objects = filterCellList (listCells ('object'), $cellfilter['expression']); | |
1814 | ||
1815 | echo "<table border=0 class=objectview>\n"; | |
1816 | echo "<tr><td class=pcleft>"; | |
1817 | ||
1818 | startPortlet ('Objects (' . count ($objects) . ')'); | |
1819 | if ($objects === NULL) | |
1820 | { | |
17112e81 | 1821 | showError ('Fatal error retrieving object list', __FUNCTION__); |
23cdc7e9 DO |
1822 | return; |
1823 | } | |
1824 | echo '<br><br><table border=0 cellpadding=5 cellspacing=0 align=center class=cooltable>'; | |
1825 | echo '<tr><th>Common name</th><th>Visible label</th><th>Asset tag</th><th>Barcode</th><th>Row/Rack</th></tr>'; | |
1826 | $order = 'odd'; | |
1827 | foreach ($objects as $obj) | |
e673ee24 | 1828 | { |
23cdc7e9 DO |
1829 | if (isset ($_REQUEST['hl_object_id']) and $_REQUEST['hl_object_id'] == $obj['id']) |
1830 | $secondclass = 'tdleft port_highlight'; | |
1831 | else | |
1832 | $secondclass = 'tdleft'; | |
23cdc7e9 | 1833 | echo "<tr class=row_${order} valign=top><td class='${secondclass}'><a href='".makeHref(array('page'=>'object', 'object_id'=>$obj['id']))."'><strong>${obj['dname']}</strong></a>"; |
c6064c9d DO |
1834 | if (count ($obj['etags'])) |
1835 | echo '<br><small>' . serializeTags ($obj['etags'], makeHref(array('page'=>$pageno, 'tab'=>'default')) . '&') . '</small>'; | |
23cdc7e9 DO |
1836 | echo "</td><td class='${secondclass}'>${obj['label']}</td>"; |
1837 | echo "<td class='${secondclass}'>${obj['asset_no']}</td>"; | |
1838 | echo "<td class='${secondclass}'>${obj['barcode']}</td>"; | |
1839 | if ($obj['rack_id']) | |
1840 | echo "<td class='${secondclass}'><a href='".makeHref(array('page'=>'row', 'row_id'=>$obj['row_id']))."'>${obj['Row_name']}</a>/<a href='".makeHref(array('page'=>'rack', 'rack_id'=>$obj['rack_id']))."'>${obj['Rack_name']}</a></td>"; | |
1841 | else | |
1842 | echo "<td class='${secondclass}'>Unmounted</td>"; | |
1843 | echo '</tr>'; | |
1844 | $order = $nextorder[$order]; | |
e673ee24 | 1845 | } |
23cdc7e9 DO |
1846 | echo '</table>'; |
1847 | finishPortlet(); | |
1848 | ||
1849 | echo "</td><td class=pcright width='25%'>"; | |
1850 | ||
1851 | renderCellFilterPortlet ($cellfilter, 'object'); | |
1852 | echo "</td></tr></table>\n"; | |
e673ee24 DO |
1853 | } |
1854 | ||
1855 | // History viewer for history-enabled simple dictionaries. | |
1856 | function renderHistory ($object_type, $object_id) | |
1857 | { | |
1858 | switch ($object_type) | |
1859 | { | |
1860 | case 'row': | |
aa9a0fb4 DO |
1861 | $query = "select ctime, user_name, name, comment from RackRowHistory where id = ${object_id} order by ctime"; |
1862 | $header = '<tr><th>change time</th><th>author</th><th>rack row name</th><th>rack row comment</th></tr>'; | |
1863 | $extra = 3; | |
e673ee24 DO |
1864 | break; |
1865 | case 'rack': | |
1866 | $query = | |
aa9a0fb4 | 1867 | "select ctime, user_name, rh.name, rr.name as name, rh.height, rh.comment " . |
51690ad4 DY |
1868 | "from RackHistory as rh left join RackRow as rr on rh.row_id = rr.id " . |
1869 | "where rh.id = ${object_id} order by ctime"; | |
aa9a0fb4 DO |
1870 | $header = '<tr><th>change time</th><th>author</th><th>rack name</th><th>rack row name</th><th>rack height</th><th>rack comment</th></tr>'; |
1871 | $extra = 5; | |
e673ee24 DO |
1872 | break; |
1873 | case 'object': | |
1874 | $query = | |
aa9a0fb4 | 1875 | "select ctime, user_name, RackObjectHistory.name as name, label, barcode, asset_no, has_problems, dict_value, comment " . |
00f6f1e4 DY |
1876 | "from RackObjectHistory inner join Dictionary on objtype_id = dict_key join Chapter on Dictionary.chapter_id = Chapter.id " . |
1877 | "where Chapter.name = 'RackObjectType' and RackObjectHistory.id=${object_id} order by ctime"; | |
aa9a0fb4 DO |
1878 | $header = '<tr><th>change time</th><th>author</th><th>common name</th><th>visible label</th><th>barcode</th><th>asset no</th><th>has problems?</th><th>object type</th><th>comment</th></tr>'; |
1879 | $extra = 8; | |
e673ee24 DO |
1880 | break; |
1881 | default: | |
591ff2c4 | 1882 | showError ("Uknown object type '${object_type}'", __FUNCTION__); |
e673ee24 DO |
1883 | return; |
1884 | } | |
1885 | global $dbxlink; | |
1886 | $result = $dbxlink->query ($query); | |
1887 | if ($result == NULL) | |
1888 | { | |
591ff2c4 | 1889 | showError ('SQL query failed', __FUNCTION__); |
e673ee24 DO |
1890 | return; |
1891 | } | |
1892 | echo '<table border=0 cellpadding=5 cellspacing=0 align=center class=cooltable>'; | |
1893 | $order = 'odd'; | |
1894 | global $nextorder; | |
1895 | echo $header; | |
1896 | while ($row = $result->fetch (PDO::FETCH_NUM)) | |
1897 | { | |
1898 | echo "<tr class=row_${order}><td>${row[0]}</td>"; | |
1899 | for ($i = 1; $i <= $extra; $i++) | |
1900 | echo "<td>" . $row[$i] . "</td>"; | |
1901 | echo "</tr>\n"; | |
1902 | $order = $nextorder[$order]; | |
1903 | } | |
1904 | echo "</table><br>\n"; | |
1905 | } | |
1906 | ||
1907 | function renderRackspaceHistory () | |
1908 | { | |
4fbb5a00 | 1909 | global $nextorder, $pageno, $tabno; |
e673ee24 DO |
1910 | $order = 'odd'; |
1911 | $history = getRackspaceHistory(); | |
1912 | // Show the last operation by default. | |
1913 | if (isset ($_REQUEST['op_id'])) | |
1914 | $op_id = $_REQUEST['op_id']; | |
1915 | elseif (isset ($history[0]['mo_id'])) | |
1916 | $op_id = $history[0]['mo_id']; | |
1917 | else $op_id = NULL; | |
1918 | ||
1919 | $omid = NULL; | |
1920 | $nmid = NULL; | |
1921 | $object_id = 1; | |
1922 | if ($op_id) | |
1923 | list ($omid, $nmid) = getOperationMolecules ($op_id); | |
1924 | ||
1925 | // Main layout starts. | |
1926 | echo "<table border=0 class=objectview cellspacing=0 cellpadding=0>"; | |
1927 | ||
1928 | // Left top portlet with old allocation. | |
1929 | echo "<tr><td class=pcleft>"; | |
1930 | startPortlet ('Old allocation'); | |
1931 | if ($omid) | |
1932 | { | |
1933 | $oldMolecule = getMolecule ($omid); | |
1934 | renderMolecule ($oldMolecule, $object_id); | |
1935 | } | |
1936 | else | |
1937 | echo "nothing"; | |
1938 | finishPortlet(); | |
1939 | ||
1940 | echo '</td><td class=pcright>'; | |
1941 | ||
1942 | // Right top portlet with new allocation | |
1943 | startPortlet ('New allocation'); | |
1944 | if ($nmid) | |
1945 | { | |
1946 | $newMolecule = getMolecule ($nmid); | |
1947 | renderMolecule ($newMolecule, $object_id); | |
1948 | } | |
1949 | else | |
1950 | echo "nothing"; | |
1951 | finishPortlet(); | |
737a3f72 | 1952 | |
e673ee24 | 1953 | echo '</td></tr><tr><td colspan=2>'; |
737a3f72 | 1954 | |
e673ee24 DO |
1955 | // Bottom portlet with list |
1956 | ||
1957 | startPortlet ('Rackspace allocation history'); | |
1958 | echo "<table border=0 cellpadding=5 cellspacing=0 align=center class=cooltable>\n"; | |
1959 | echo "<tr><th>timestamp</th><th>author</th><th>rack object ID</th><th>rack object type</th><th>rack object name</th><th>comment</th></tr>\n"; | |
1960 | foreach ($history as $row) | |
1961 | { | |
1962 | if ($row['mo_id'] == $op_id) | |
1963 | $class = 'hl'; | |
1964 | else | |
1965 | $class = "row_${order}"; | |
4fbb5a00 | 1966 | echo "<tr class=${class}><td><a href='".makeHref(array('page'=>$pageno, 'tab'=>$tabno, 'op_id'=>$row['mo_id']))."'>${row['ctime']}</a></td>"; |
e673ee24 DO |
1967 | echo "<td>${row['user_name']}</td>"; |
1968 | echo "<td>${row['ro_id']}</td><td>${row['objtype_name']}</td><td>${row['name']}</td><td>${row['comment']}</td>\n"; | |
1969 | echo "</tr>\n"; | |
1970 | $order = $nextorder[$order]; | |
1971 | } | |
1972 | echo "</table>\n"; | |
1973 | finishPortlet(); | |
737a3f72 | 1974 | |
e673ee24 | 1975 | echo '</td></tr></table>'; |
e673ee24 DO |
1976 | } |
1977 | ||
d9f8a37a | 1978 | function renderIPv4SpaceRecords ($tree, &$tagcache, $baseurl, $target = 0, $level = 1) |
d65353ad DO |
1979 | { |
1980 | $self = __FUNCTION__; | |
1981 | foreach ($tree as $item) | |
1982 | { | |
737a3f72 | 1983 | $total = $item['addrt']; |
64347dcf DO |
1984 | if (getConfigVar ('IPV4_TREE_SHOW_USAGE') == 'yes') |
1985 | { | |
1986 | loadIPv4AddrList ($item); // necessary to compute router list and address counter | |
1987 | $used = $item['addrc']; | |
1988 | } | |
1989 | else | |
1990 | { | |
1991 | $item['addrlist'] = array(); | |
1992 | $item['addrc'] = 0; | |
1993 | } | |
0137d53c DO |
1994 | if (isset ($item['id'])) |
1995 | { | |
fec0c8da | 1996 | if ($item['symbol'] == 'node-collapsed') |
d9f8a37a | 1997 | $expandurl = "${baseurl}&eid=" . $item['id'] . "#netid" . $item['id']; |
fec0c8da | 1998 | elseif ($item['symbol'] == 'node-expanded') |
d9f8a37a | 1999 | $expandurl = $baseurl . ($item['parent_id'] ? "&eid=${item['parent_id']}#netid${item['parent_id']}" : ''); |
fec0c8da DO |
2000 | else |
2001 | $expandurl = ''; | |
0137d53c | 2002 | echo "<tr valign=top>"; |
fec0c8da | 2003 | printIPv4NetInfoTDs ($item, 'tdleft', $level, $item['symbol'], $expandurl); |
0137d53c | 2004 | echo "<td class=tdcenter>"; |
d9f8a37a DO |
2005 | if ($target == $item['id']) |
2006 | echo "<a name=netid${target}></a>"; | |
64347dcf DO |
2007 | if (getConfigVar ('IPV4_TREE_SHOW_USAGE') == 'yes') |
2008 | { | |
2009 | renderProgressBar ($total ? $used/$total : 0); | |
2010 | echo "<br><small>${used}/${total}</small>"; | |
2011 | } | |
2012 | else | |
2013 | echo "<small>${total}</small>"; | |
2014 | echo "</td>"; | |
0137d53c | 2015 | if (getConfigVar ('EXT_IPV4_VIEW') == 'yes') |
b6b87070 | 2016 | printRoutersTD (findRouters ($item['addrlist']), $tagcache); |
0137d53c | 2017 | echo "</tr>"; |
fec0c8da | 2018 | if ($item['symbol'] == 'node-expanded' or $item['symbol'] == 'node-expanded-static') |
d9f8a37a | 2019 | $self ($item['kids'], $tagcache, $baseurl, $target, $level + 1); |
0137d53c DO |
2020 | } |
2021 | else | |
2022 | { | |
0137d53c | 2023 | echo "<tr valign=top>"; |
fec0c8da | 2024 | printIPv4NetInfoTDs ($item, 'tdleft sparenetwork', $level, $item['symbol']); |
0137d53c | 2025 | echo "<td class=tdcenter>"; |
64347dcf DO |
2026 | if (getConfigVar ('IPV4_TREE_SHOW_USAGE') == 'yes') |
2027 | { | |
2028 | renderProgressBar ($used/$total, 'sparenetwork'); | |
2029 | echo "<br><small>${used}/${total}</small>"; | |
2030 | } | |
2031 | else | |
2032 | echo "<small>${total}</small>"; | |
2033 | echo "</td><td> </td></tr>"; | |
0137d53c | 2034 | } |
d65353ad DO |
2035 | } |
2036 | } | |
2037 | ||
04d619d0 | 2038 | function renderIPv4Space () |
e673ee24 | 2039 | { |
4fbb5a00 | 2040 | global $pageno, $tabno; |
31c941ec DO |
2041 | $cellfilter = getCellFilter(); |
2042 | $netlist = filterCellList (listCells ('ipv4net'), $cellfilter['expression']); | |
573214e0 | 2043 | array_walk ($netlist, 'amplifyCell'); |
4fbb5a00 | 2044 | |
94a40058 | 2045 | $netcount = count ($netlist); |
5388794d DO |
2046 | // expand request can take either natural values or "ALL". Zero means no expanding. |
2047 | $eid = isset ($_REQUEST['eid']) ? $_REQUEST['eid'] : 0; | |
2048 | $tree = prepareIPv4Tree ($netlist, $eid); | |
3630d1fb DO |
2049 | |
2050 | echo "<table border=0 class=objectview>\n"; | |
2051 | echo "<tr><td class=pcleft>"; | |
94a40058 | 2052 | startPortlet ("networks (${netcount})"); |
5388794d DO |
2053 | echo '<h4>'; |
2054 | if ($eid === 0) | |
65085888 DO |
2055 | echo 'auto-collapsing at threshold ' . getConfigVar ('TREE_THRESHOLD') . |
2056 | " (<a href='".makeHref(array('page'=>$pageno, 'tab'=>$tabno, 'eid'=>'ALL')) . | |
2057 | $cellfilter['urlextra'] . "'>expand all</a>)"; | |
5388794d | 2058 | elseif ($eid === 'ALL') |
65085888 DO |
2059 | echo "expanding all (<a href='".makeHref(array('page'=>$pageno, 'tab'=>$tabno)) . |
2060 | $cellfilter['urlextra'] . "'>auto-collapse</a>)"; | |
5388794d DO |
2061 | else |
2062 | { | |
d724d290 | 2063 | $netinfo = spotEntity ('ipv4net', $eid); |
4fbb5a00 | 2064 | echo "expanding ${netinfo['ip']}/${netinfo['mask']} (<a href='".makeHref(array('page'=>$pageno, 'tab'=>$tabno))."'>auto-collapse</a> / <a href='".makeHref(array('page'=>$pageno, 'tab'=>$tabno, 'eid'=>'ALL'))."'>expand all</a>)"; |
5388794d DO |
2065 | } |
2066 | echo "</h4><table class='widetable' border=0 cellpadding=5 cellspacing=0 align='center'>\n"; | |
64347dcf | 2067 | echo "<tr><th>prefix</th><th>name/tags</th><th>capacity</th>"; |
f0ed1181 | 2068 | if (getConfigVar ('EXT_IPV4_VIEW') == 'yes') |
57dece2f DO |
2069 | echo "<th>routed by</th>"; |
2070 | echo "</tr>\n"; | |
fec0c8da | 2071 | $tagcache = array(); |
a8efc03e | 2072 | $baseurl = makeHref(array('page'=>$pageno, 'tab'=>$tabno)) . $cellfilter['urlextra']; |
5388794d | 2073 | renderIPv4SpaceRecords ($tree, $tagcache, $baseurl, $eid); |
e673ee24 | 2074 | echo "</table>\n"; |
a7fe7729 | 2075 | finishPortlet(); |
74ccacff | 2076 | echo '</td><td class=pcright>'; |
3d670bba | 2077 | renderCellFilterPortlet ($cellfilter, 'ipv4net'); |
74ccacff | 2078 | echo "</td></tr></table>\n"; |
f973f491 | 2079 | } |
a7fe7729 | 2080 | |
f973f491 DO |
2081 | function renderIPv4SLB () |
2082 | { | |
4fbb5a00 | 2083 | global $page, $nextorder; |
a7fe7729 | 2084 | |
6fec9f39 | 2085 | startPortlet ('SLB configuration'); |
b3c50e6c | 2086 | echo "<table border=0 width='100%'><tr>"; |
ee437dab | 2087 | foreach (array ('ipv4vslist', 'ipv4rsplist', 'rservers', 'lbs') as $pno) |
4fbb5a00 | 2088 | echo "<td><h3><a href='".makeHref(array('page'=>$pno))."'>" . $page[$pno]['title'] . "</a></h3></td>"; |
b3c50e6c DO |
2089 | echo '</tr></table>'; |
2090 | finishPortlet(); | |
2091 | ||
c3bdc503 | 2092 | $summary = getSLBSummary(); |
6fec9f39 | 2093 | startPortlet ('SLB tactical overview'); |
4cadac8f DO |
2094 | // A single id-keyed array isn't used here to preserve existing |
2095 | // order of LBs returned by getSLBSummary() | |
c3bdc503 DO |
2096 | $lblist = array(); |
2097 | $lbdname = array(); | |
4cadac8f | 2098 | foreach ($summary as $vipdata) |
da04825a | 2099 | foreach (array_keys ($vipdata['lblist']) as $lb_object_id) |
c3bdc503 DO |
2100 | if (!in_array ($lb_object_id, $lblist)) |
2101 | { | |
fb6e2f57 | 2102 | $oi = spotEntity ('object', $lb_object_id); |
c3bdc503 DO |
2103 | $lbdname[$lb_object_id] = $oi['dname']; |
2104 | $lblist[] = $lb_object_id; | |
2105 | } | |
2106 | if (!count ($summary)) | |
2107 | echo 'none configured'; | |
2108 | else | |
2109 | { | |
80e85ea1 | 2110 | $order = 'odd'; |
c3bdc503 | 2111 | echo "<table class='widetable' border=0 cellpadding=5 cellspacing=0 align='center'>\n"; |
b1a970c7 | 2112 | echo "<tr valign=top><td> </td>"; |
c3bdc503 | 2113 | foreach ($lblist as $lb_object_id) |
b1a970c7 | 2114 | { |
4fbb5a00 | 2115 | #echo "<th><a href='".makeHref(array('page'=>'object', 'tab'=>'default', 'object_id'=>$lb_object_id))."'>" . $lbdname[$lb_object_id] . "</a></th>"; |
b1a970c7 DO |
2116 | echo '<td>'; |
2117 | renderLBCell ($lb_object_id); | |
2118 | echo '</td>'; | |
2119 | } | |
c3bdc503 | 2120 | echo "</tr>\n"; |
4cadac8f DO |
2121 | foreach ($summary as $vsid => $vsdata) |
2122 | { | |
b1a970c7 | 2123 | echo "<tr class=row_${order}><td class=tdleft>"; |
6df2025d | 2124 | renderCell (spotEntity ('ipv4vs', $vsid)); |
6fec9f39 | 2125 | echo "</td>"; |
4cadac8f | 2126 | foreach ($lblist as $lb_object_id) |
da04825a | 2127 | { |
60fbcece | 2128 | echo '<td class=tdleft>'; |
2b4eee17 | 2129 | if (!isset ($vsdata['lblist'][$lb_object_id])) |
da04825a DO |
2130 | echo ' '; |
2131 | else | |
6fec9f39 DO |
2132 | { |
2133 | echo $vsdata['lblist'][$lb_object_id]['size']; | |
4fbb5a00 | 2134 | // echo " (<a href='".makeHref(array('page'=>'ipv4rspool', 'pool_id'=>$vsdata['lblist'][$lb_object_id]['id'])). "'>"; |
79a9edb4 | 2135 | // echo $vsdata['lblist'][$lb_object_id]['name'] . '</a>)'; |
6fec9f39 | 2136 | } |
da04825a DO |
2137 | echo '</td>'; |
2138 | } | |
2139 | echo "</tr>\n"; | |
80e85ea1 | 2140 | $order = $nextorder[$order]; |
4cadac8f | 2141 | } |
c3bdc503 DO |
2142 | echo "</table>\n"; |
2143 | } | |
a7fe7729 | 2144 | finishPortlet (); |
e673ee24 DO |
2145 | } |
2146 | ||
04d619d0 | 2147 | function renderIPv4SpaceEditor () |
e673ee24 | 2148 | { |
a262e150 DO |
2149 | // IPv4 validator |
2150 | ?> | |
2151 | <script type="text/javascript"> | |
2152 | function init() { | |
2153 | document.add_new_range.range.setAttribute('match', "^\\d\\d?\\d?\\.\\d\\d?\\d?\\.\\d\\d?\\d?\\.\\d\\d?\\d?\\/\\d\\d?$"); | |
2154 | ||
2155 | Validate.init(); | |
2156 | } | |
2157 | window.onload=init; | |
2158 | </script> | |
2159 | <?php | |
2160 | ||
4c0653e2 | 2161 | startPortlet ("Add new"); |
04d619d0 | 2162 | echo '<table border=0 cellpadding=10 align=center>'; |
7056988c DO |
2163 | // This form requires a name, so JavaScript validator can find it. |
2164 | // No printOpFormIntro() hence | |
4fbb5a00 | 2165 | echo "<form method=post name='add_new_range' action='".makeHrefProcess()."'>\n"; |
42023f03 | 2166 | echo "<input type=hidden name=op value=addIPv4Prefix>\n"; |
04d619d0 DO |
2167 | // tags column |
2168 | echo '<tr><td rowspan=4><h3>assign tags</h3>'; | |
25186565 | 2169 | renderNewEntityTags(); |
04d619d0 DO |
2170 | echo '</td>'; |
2171 | // inputs column | |
2172 | echo "<th class=tdright>prefix</th><td class=tdleft><input type=text name='range' size=18 class='live-validate' tabindex=1></td>"; | |
2173 | echo "<tr><th class=tdright>name</th><td class=tdleft><input type=text name='name' size='20' tabindex=2></td></tr>"; | |
0c16ef0c | 2174 | echo "<tr><th class=tdright>connected network</th><td class=tdleft><input type=checkbox name='is_bcast' tabindex=3></td></tr>"; |
04d619d0 | 2175 | echo "<tr><td colspan=2>"; |
4c0653e2 | 2176 | printImageHREF ('CREATE', 'Add a new network', TRUE, 4); |
04d619d0 | 2177 | echo '</td></tr>'; |
2a201216 | 2178 | echo "</form></table><br><br>\n"; |
5c0bb421 | 2179 | finishPortlet(); |
2a201216 | 2180 | |
573214e0 DO |
2181 | $addrspaceList = listCells ('ipv4net'); |
2182 | array_walk ($addrspaceList, 'amplifyCell'); | |
e43a2de4 | 2183 | if (count ($addrspaceList)) |
e673ee24 | 2184 | { |
e43a2de4 | 2185 | startPortlet ('Manage existing (' . count ($addrspaceList) . ')'); |
04d619d0 DO |
2186 | echo "<table class='widetable' border=0 cellpadding=5 cellspacing=0 align='center'>\n"; |
2187 | echo "<tr><th> </th><th>prefix</th><th>name</th><th> </th></tr>"; | |
0c16ef0c | 2188 | foreach ($addrspaceList as $netinfo) |
e673ee24 | 2189 | { |
0b9c98d7 | 2190 | echo "<form method=post action='".makeHrefProcess(array('op'=>'updIPv4Prefix', 'id'=>$netinfo['id']))."'>"; |
e43a2de4 DO |
2191 | echo "<tr valign=top><td>"; |
2192 | if (getConfigVar ('IPV4_JAYWALK') == 'yes') | |
2193 | { | |
2194 | echo "<a href='".makeHrefProcess(array('op'=>'delIPv4Prefix', 'id'=>$netinfo['id']))."'>"; | |
2195 | printImageHREF ('destroy', 'Delete this prefix'); | |
2196 | echo "</a>"; | |
2197 | } | |
2198 | else // only render clickable image for empty networks | |
2199 | { | |
d724d290 | 2200 | $netdata = spotEntity ('ipv4net', $netinfo['id']); |
e43a2de4 DO |
2201 | loadIPv4AddrList ($netdata); |
2202 | if (count ($netdata['addrlist'])) | |
2203 | printImageHREF ('nodestroy', 'There are ' . count ($netdata['addrlist']) . ' allocations inside'); | |
2204 | else | |
2205 | { | |
2206 | echo "<a href='".makeHrefProcess(array('op'=>'delIPv4Prefix', 'id'=>$netinfo['id']))."'>"; | |
2207 | printImageHREF ('destroy', 'Delete this prefix'); | |
2208 | echo "</a>"; | |
2209 | } | |
2210 | ||
2211 | } | |
2212 | echo "</td>\n<td class=tdleft>${netinfo['ip']}/${netinfo['mask']}</td>"; | |
0c16ef0c | 2213 | echo "<td><input type=text name=name size=40 value='${netinfo['name']}'>"; |
04d619d0 DO |
2214 | echo "</td><td>"; |
2215 | printImageHREF ('save', 'Save changes', TRUE); | |
2216 | echo "</td></tr></form>\n"; | |
e673ee24 | 2217 | } |
04d619d0 DO |
2218 | echo "</table>"; |
2219 | finishPortlet(); | |
e673ee24 | 2220 | } |
e673ee24 DO |
2221 | } |
2222 | ||
beb9e88a | 2223 | function renderIPv4Network ($id) |
e673ee24 | 2224 | { |
4fbb5a00 | 2225 | global $pageno, $tabno, $aac2; |
545478d0 DO |
2226 | $netmaskbylen = array |
2227 | ( | |
2228 | 32 => '255.255.255.255', | |
2229 | 31 => '255.255.255.254', | |
2230 | 30 => '255.255.255.252', | |
2231 | 29 => '255.255.255.248', | |
2232 | 28 => '255.255.255.240', | |
2233 | 27 => '255.255.255.224', | |
2234 | 26 => '255.255.255.192', | |
2235 | 25 => '255.255.255.128', | |
2236 | 24 => '255.255.255.0', | |
2237 | 23 => '255.255.254.0', | |
2238 | 22 => '255.255.252.0', | |
2239 | 21 => '255.255.248.0', | |
2240 | 20 => '255.255.240.0', | |
2241 | 19 => '255.255.224.0', | |
2242 | 18 => '255.255.192.0', | |
2243 | 17 => '255.255.128.0', | |
2244 | 16 => '255.255.0.0', | |
2245 | 15 => '255.254.0.0', | |
2246 | 14 => '255.252.0.0', | |
2247 | 13 => '255.248.0.0', | |
2248 | 12 => '255.240.0.0', | |
2249 | 11 => '255.224.0.0', | |
2250 | 10 => '255.192.0.0', | |
2251 | 9 => '255.128.0.0', | |
2252 | 8 => '255.0.0.0', | |
2253 | 7 => '254.0.0.0', | |
2254 | 6 => '252.0.0.0', | |
2255 | 5 => '248.0.0.0', | |
2256 | 4 => '240.0.0.0', | |
2257 | 3 => '224.0.0.0', | |
2258 | 2 => '192.0.0.0', | |
2259 | 1 => '128.0.0.0' | |
2260 | ); | |
2261 | $wildcardbylen = array | |
2262 | ( | |
2263 | 32 => '0.0.0.0', | |
2264 | 31 => '0.0.0.1', | |
2265 | 30 => '0.0.0.3', | |
2266 | 29 => '0.0.0.7', | |
2267 | 28 => '0.0.0.15', | |
2268 | 27 => '0.0.0.31', | |
2269 | 26 => '0.0.0.63', | |
2270 | 25 => '0.0.0.127', | |
2271 | 24 => '0.0.0.255', | |
2272 | 23 => '0.0.1.255', | |
2273 | 22 => '0.0.3.255', | |
2274 | 21 => '0.0.7.255', | |
2275 | 20 => '0.0.15.255', | |
2276 | 19 => '0.0.31.255', | |
2277 | 18 => '0.0.63.255', | |
2278 | 17 => '0.0.127.255', | |
2279 | 16 => '0.0.255.25', | |
2280 | 15 => '0.1.255.255', | |
2281 | 14 => '0.3.255.255', | |
2282 | 13 => '0.7.255.255', | |
2283 | 12 => '0.15.255.255', | |
2284 | 11 => '0.31.255.255', | |
2285 | 10 => '0.63.255.255', | |
2286 | 9 => '0.127.255.255', | |
2287 | 8 => '0.255.255.255', | |
2288 | 7 => '1.255.255.255', | |
2289 | 6 => '3.255.255.255', | |
2290 | 5 => '7.255.255.255', | |
2291 | 4 => '15.255.255.255', | |
2292 | 3 => '31.255.255.255', | |
2293 | 2 => '63.255.255.255', | |
2294 | 1 => '127.255.255.255' | |
2295 | ); | |
b901bf1f | 2296 | $maxperpage = getConfigVar ('IPV4_ADDRS_PER_PAGE'); |
e673ee24 DO |
2297 | if (isset($_REQUEST['pg'])) |
2298 | $page = $_REQUEST['pg']; | |
2299 | else | |
2300 | $page=0; | |
2301 | ||
d724d290 | 2302 | $range = spotEntity ('ipv4net', $id); |
b6b87070 | 2303 | loadIPv4AddrList ($range); |
2034d968 DO |
2304 | echo "<table border=0 class=objectview cellspacing=0 cellpadding=0>"; |
2305 | echo "<tr><td colspan=2 align=center><h1>${range['ip']}/${range['mask']}</h1><h2>${range['name']}</h2></td></tr>\n"; | |
2306 | ||
2307 | echo "<tr><td class=pcleft width='50%'>"; | |
2308 | startPortlet ('summary'); | |
2309 | $total = ($range['ip_bin'] | $range['mask_bin_inv']) - ($range['ip_bin'] & $range['mask_bin']) + 1; | |
2310 | $used = count ($range['addrlist']); | |
2311 | echo "<table border=0 cellspacing=0 cellpadding=3 width='100%'>\n"; | |
04d619d0 DO |
2312 | |
2313 | echo "<tr><th width='50%' class=tdright>%% used:</th><td class=tdleft>"; | |
2034d968 DO |
2314 | renderProgressBar ($used/$total); |
2315 | echo " ${used}/${total}</td></tr>\n"; | |
04d619d0 | 2316 | |
001e61fa DO |
2317 | if (getConfigVar ('EXT_IPV4_VIEW') == 'yes') |
2318 | { | |
3444ecf2 DO |
2319 | // Build a backtrace from all parent networks. |
2320 | $clen = $range['mask']; | |
2321 | $backtrace = array(); | |
2322 | while (NULL !== ($upperid = getIPv4AddressNetworkId ($range['ip'], $clen))) | |
2323 | { | |
d724d290 | 2324 | $upperinfo = spotEntity ('ipv4net', $upperid); |
3444ecf2 | 2325 | $clen = $upperinfo['mask']; |
d724d290 | 2326 | $backtrace[] = $upperinfo; |
3444ecf2 DO |
2327 | } |
2328 | $arrows = count ($backtrace); | |
d724d290 | 2329 | foreach (array_reverse ($backtrace) as $ainfo) |
001e61fa | 2330 | { |
3444ecf2 DO |
2331 | echo "<tr><th width='50%' class=tdright>"; |
2332 | for ($i = 0; $i < $arrows; $i++) | |
2333 | echo '↑'; | |
2334 | $arrows--; | |
5d3dcb8d | 2335 | echo "</th><td class=tdleft>"; |
6df2025d | 2336 | renderCell ($ainfo); |
5d3dcb8d | 2337 | echo "</td></tr>"; |
001e61fa | 2338 | } |
3444ecf2 | 2339 | echo "<tr><th width='50%' class=tdright>→</th>"; |
5d3dcb8d | 2340 | echo "<td class=tdleft>"; |
6df2025d | 2341 | renderCell ($range); |
5d3dcb8d | 2342 | echo "</td></tr>"; |
001e61fa DO |
2343 | // FIXME: get and display nested networks |
2344 | // $theitem = pickLeaf ($ipv4tree, $id); | |
2345 | } | |
2346 | ||
545478d0 DO |
2347 | echo "<tr><th width='50%' class=tdright>Netmask:</th><td class=tdleft>"; |
2348 | echo $netmaskbylen[$range['mask']]; | |
2349 | echo "</td></tr>\n"; | |
04d619d0 | 2350 | |
c607ab55 DO |
2351 | echo "<tr><th width='50%' class=tdright>Netmask:</th><td class=tdleft>"; |
2352 | printf ('0x%08X', binMaskFromDec ($range['mask'])); | |
2353 | echo "</td></tr>\n"; | |
2354 | ||
545478d0 DO |
2355 | echo "<tr><th width='50%' class=tdright>Wildcard bits:</th><td class=tdleft>"; |
2356 | echo $wildcardbylen[$range['mask']]; | |
2357 | echo "</td></tr>\n"; | |
04d619d0 | 2358 | |
f3d0cb20 | 2359 | $routers = findRouters ($range['addrlist']); |
f0ed1181 | 2360 | if (getConfigVar ('EXT_IPV4_VIEW') == 'yes' and count ($routers)) |
04d619d0 | 2361 | { |
57dece2f | 2362 | echo "<tr><th width='50%' class=tdright>Routed by:</th>"; |
f3d0cb20 | 2363 | printRoutersTD ($routers); |
57dece2f | 2364 | echo "</tr>\n"; |
04d619d0 DO |
2365 | } |
2366 | ||
9b57f793 | 2367 | printTagTRs ($range, makeHref(array('page'=>'ipv4space', 'tab'=>'default'))."&"); |
2034d968 DO |
2368 | echo "</table><br>\n"; |
2369 | finishPortlet(); | |
e1ae3fb4 AD |
2370 | |
2371 | renderFilesPortlet ('ipv4net', $id); | |
2034d968 | 2372 | echo "</td>\n"; |
e673ee24 | 2373 | |
2034d968 DO |
2374 | echo "<td class=pcright>"; |
2375 | startPortlet ('details'); | |
e673ee24 DO |
2376 | $startip = $range['ip_bin'] & $range['mask_bin']; |
2377 | $endip = $range['ip_bin'] | $range['mask_bin_inv']; | |
2378 | $realstartip = $startip; | |
2379 | $realendip = $endip; | |
2380 | $numpages = 0; | |
2381 | if($endip - $startip > $maxperpage) | |
2382 | { | |
e673ee24 DO |
2383 | $numpages = ($endip - $startip)/$maxperpage; |
2384 | $startip = $startip + $page * $maxperpage; | |
2385 | $endip = $startip + $maxperpage-1; | |
2386 | } | |
2387 | echo "<center>"; | |
b901bf1f DO |
2388 | if ($numpages) |
2389 | echo '<h3>' . long2ip ($startip) . ' ~ ' . long2ip ($endip) . '</h3>'; | |
e673ee24 DO |
2390 | for ($i=0; $i<$numpages; $i++) |
2391 | { | |
2392 | if ($i == $page) | |
2393 | echo "<b>$i</b> "; | |
2394 | else | |
4fbb5a00 | 2395 | echo "<a href='".makeHref(array('page'=>$pageno, 'tab'=>$tabno, 'id'=>$id, 'pg'=>$i))."'>$i</a> "; |
e673ee24 DO |
2396 | } |
2397 | echo "</center>"; | |
2398 | ||
beb9e88a | 2399 | echo "<table class='widetable' border=0 cellspacing=0 cellpadding=5 align='center' width='100%'>\n"; |
e673ee24 DO |
2400 | echo "<tr><th>Address</th><th>Name</th><th>Allocation</th></tr>\n"; |
2401 | ||
2402 | ||
b2035dca DO |
2403 | for ($ip = $startip; $ip <= $endip; $ip++) : |
2404 | if (isset ($_REQUEST['hl_ipv4_addr']) and ip2long ($_REQUEST['hl_ipv4_addr']) == $ip) | |
2405 | $secondstyle = 'tdleft port_highlight'; | |
2727c7df | 2406 | else |
b2035dca DO |
2407 | $secondstyle = 'tdleft'; |
2408 | if (!isset ($range['addrlist'][$ip])) | |
e673ee24 | 2409 | { |
4fbb5a00 | 2410 | echo "<tr><td class=tdleft><a href='".makeHref(array('page'=>'ipaddress', 'ip'=>ip_long2quad($ip)))."'>" . ip_long2quad($ip); |
b2035dca DO |
2411 | echo "</a></td><td class='${secondstyle}'> </td><td class='${secondstyle}'> </td></tr>\n"; |
2412 | continue; | |
2413 | } | |
b2035dca | 2414 | $addr = $range['addrlist'][$ip]; |
2d318652 | 2415 | echo "<tr class='${addr['class']}'>"; |
e673ee24 | 2416 | |
4fbb5a00 | 2417 | echo "<td class=tdleft><a href='".makeHref(array('page'=>'ipaddress', 'ip'=>$addr['ip']))."'>${addr['ip']}</a></td>"; |
b2035dca DO |
2418 | echo "<td class='${secondstyle}'>${addr['name']}</td><td class='${secondstyle}'>"; |
2419 | $delim = ''; | |
2420 | $prologue = ''; | |
2421 | if ( $addr['reserved'] == 'yes') | |
2422 | { | |
2d318652 | 2423 | echo "<strong>RESERVED</strong> "; |
b2035dca DO |
2424 | $delim = '; '; |
2425 | } | |
2d318652 | 2426 | foreach ($range['addrlist'][$ip]['allocs'] as $ref) |
b2035dca | 2427 | { |
beb9e88a | 2428 | echo $delim . $aac2[$ref['type']]; |
4fbb5a00 | 2429 | echo "<a href='".makeHref(array('page'=>'object', 'object_id'=>$ref['object_id'], 'hl_ipv4_addr'=>$addr['ip']))."'>"; |
59a83bd8 | 2430 | echo $ref['name'] . (!strlen ($ref['name']) ? '' : '@'); |
b2035dca DO |
2431 | echo "${ref['object_name']}</a>"; |
2432 | $delim = '; '; | |
2433 | } | |
2434 | if ($delim != '') | |
2435 | { | |
6131056c | 2436 | $delim = ''; |
b2035dca DO |
2437 | $prologue = '<br>'; |
2438 | } | |
2d318652 | 2439 | foreach ($range['addrlist'][$ip]['lblist'] as $ref) |
b2035dca DO |
2440 | { |
2441 | echo $prologue; | |
602663f4 | 2442 | $prologue = ''; |
4fbb5a00 DY |
2443 | echo "${delim}<a href='".makeHref(array('page'=>'object', 'object_id'=>$ref['object_id']))."'>"; |
2444 | echo "${ref['object_name']}</a>:<a href='".makeHref(array('page'=>'ipv4vs', 'vs_id'=>$ref['vs_id']))."'>"; | |
b2035dca DO |
2445 | echo "${ref['vport']}/${ref['proto']}</a>→"; |
2446 | $delim = '; '; | |
2447 | } | |
2448 | if ($delim != '') | |
2449 | { | |
2450 | $delim = ''; | |
2451 | $prologue = '<br>'; | |
e673ee24 | 2452 | } |
2d318652 | 2453 | foreach ($range['addrlist'][$ip]['rslist'] as $ref) |
b2035dca DO |
2454 | { |
2455 | echo $prologue; | |
2456 | $prologue = ''; | |
4fbb5a00 | 2457 | echo "${delim}→${ref['rsport']}@<a href='".makeHref(array('page'=>'ipv4rspool', 'pool_id'=>$ref['rspool_id']))."'>"; |
b2035dca DO |
2458 | echo "${ref['rspool_name']}</a>"; |
2459 | $delim = '; '; | |
2460 | } | |
2461 | echo "</td></tr>\n"; | |
2462 | endfor; | |
2727c7df | 2463 | // end of iteration |
e673ee24 DO |
2464 | |
2465 | echo "</table>"; | |
2034d968 DO |
2466 | finishPortlet(); |
2467 | echo "</td></tr></table>\n"; | |
e673ee24 DO |
2468 | } |
2469 | ||
53ef3908 | 2470 | function renderIPv4NetworkProperties ($id) |
e673ee24 | 2471 | { |
d724d290 | 2472 | $netdata = spotEntity ('ipv4net', $id); |
53ef3908 | 2473 | echo "<center><h1>${netdata['ip']}/${netdata['mask']}</h1></center>\n"; |
e673ee24 | 2474 | echo "<table border=0 cellpadding=10 cellpadding=1 align='center'>\n"; |
7056988c | 2475 | printOpFormIntro ('editRange'); |
53ef3908 DO |
2476 | echo "<tr><td class='tdright'>Name:</td><td class='tdleft'><input type=text name=name size=20 value='${netdata['name']}'></tr>"; |
2477 | echo "<tr><td colspan=2 class=tdcenter>"; | |
2478 | printImageHREF ('SAVE', 'Save changes', TRUE); | |
2479 | echo "</td></form></tr></table>\n"; | |
e673ee24 DO |
2480 | } |
2481 | ||
2d318652 | 2482 | function renderIPv4Address ($dottedquad) |
e673ee24 | 2483 | { |
4fbb5a00 | 2484 | global $aat; |
2d318652 | 2485 | $address = getIPv4Address ($dottedquad); |
68225375 | 2486 | echo "<table border=0 class=objectview cellspacing=0 cellpadding=0>"; |
2d318652 | 2487 | echo "<tr><td colspan=2 align=center><h1>${dottedquad}</h1></td></tr>\n"; |
59a83bd8 | 2488 | if (strlen ($address['name'])) |
68225375 | 2489 | echo "<tr><td colspan=2 align=center><h2>${address['name']}</h2></td></tr>\n"; |
e673ee24 | 2490 | |
68225375 DO |
2491 | echo "<tr><td class=pcleft>"; |
2492 | startPortlet ('summary'); | |
2493 | echo "<table border=0 cellspacing=0 cellpadding=3 width='100%'>\n"; | |
04d619d0 | 2494 | echo "<tr><th width='50%' class=tdright>Allocations:</th><td class=tdleft>" . count ($address['allocs']) . "</td></tr>\n"; |
68225375 DO |
2495 | echo "<tr><th width='50%' class=tdright>Originated NAT connections:</th><td class=tdleft>" . count ($address['outpf']) . "</td></tr>\n"; |
2496 | echo "<tr><th width='50%' class=tdright>Arriving NAT connections:</th><td class=tdleft>" . count ($address['inpf']) . "</td></tr>\n"; | |
04d619d0 | 2497 | echo "<tr><th width='50%' class=tdright>SLB virtual services:</th><td class=tdleft>" . count ($address['lblist']) . "</td></tr>\n"; |
68225375 | 2498 | echo "<tr><th width='50%' class=tdright>SLB real servers:</th><td class=tdleft>" . count ($address['rslist']) . "</td></tr>\n"; |
68225375 DO |
2499 | echo "</table><br>\n"; |
2500 | finishPortlet(); | |
2501 | echo "</td>\n"; | |
e673ee24 | 2502 | |
68225375 | 2503 | echo "<td class=pcright>"; |
e673ee24 | 2504 | |
f74d96c6 | 2505 | if (isset ($address['class'])) |
59bebe2b | 2506 | { |
8e700dd1 | 2507 | startPortlet ('allocations'); |
2d318652 DO |
2508 | echo "<table class='widetable' cellpadding=5 cellspacing=0 border=0 align='center' width='100%'>\n"; |
2509 | echo "<tr><th>object</th><th>OS interface</th><th>allocation type</th></tr>\n"; | |
2510 | $class = $address['class']; | |
2511 | // render all allocation records for this address the same way | |
59bebe2b | 2512 | if ($address['reserved'] == 'yes') |
2d318652 DO |
2513 | echo "<tr class='${class}'><td colspan=2> </td><td class=tdleft><strong>RESERVED</strong></td></tr>"; |
2514 | foreach ($address['allocs'] as $bond) | |
59bebe2b | 2515 | { |
8e700dd1 DO |
2516 | if (isset ($_REQUEST['hl_object_id']) and $_REQUEST['hl_object_id'] == $bond['object_id']) |
2517 | $secondclass = 'tdleft port_highlight'; | |
2518 | else | |
2519 | $secondclass = 'tdleft'; | |
4fbb5a00 | 2520 | echo "<tr class='$class'><td class=tdleft><a href='".makeHref(array('page'=>'object', 'object_id'=>$bond['object_id'], 'hl_ipv4_addr'=>$dottedquad))."'>${bond['object_name']}</td><td class='${secondclass}'>${bond['name']}</td><td class='${secondclass}'><strong>"; |
52c836b1 DO |
2521 | echo $aat[$bond['type']]; |
2522 | echo "</strong></td></tr>\n"; | |
59bebe2b DO |
2523 | } |
2524 | echo "</table><br><br>"; | |
2525 | finishPortlet(); | |
2526 | } | |
e673ee24 | 2527 | |
f3d0cb20 DO |
2528 | // FIXME: The returned list is structured differently, than we expect it to be. One of the sides |
2529 | // must be fixed. | |
2d318652 | 2530 | if (count ($address['lblist'])) |
e673ee24 | 2531 | { |
2d318652 DO |
2532 | startPortlet ('Virtual services (' . count ($address['lblist']) . ')'); |
2533 | echo "<table class='widetable' cellpadding=5 cellspacing=0 border=0 align='center' width='100%'>\n"; | |
59bebe2b | 2534 | echo "<tr><th>VS</th><th>name</th></tr>\n"; |
2d318652 | 2535 | foreach ($address['lblist'] as $vsinfo) |
e673ee24 | 2536 | { |
4fbb5a00 | 2537 | echo "<tr><td class=tdleft><a href='".makeHref(array('page'=>'ipv4vs', 'vs_id'=>$vsinfo['vs_id']))."'>"; |
59bebe2b | 2538 | echo buildVServiceName ($vsinfo) . "</a></td><td class=tdleft>"; |
5fe1ed76 | 2539 | echo $vsinfo['name'] . "</td></tr>\n"; |
e673ee24 | 2540 | } |
59bebe2b DO |
2541 | echo "</table><br><br>"; |
2542 | finishPortlet(); | |
e673ee24 | 2543 | } |
5fe1ed76 DO |
2544 | |
2545 | if (count ($address['rslist'])) | |
2546 | { | |
2547 | startPortlet ('Real servers (' . count ($address['rslist']) . ')'); | |
2d318652 | 2548 | echo "<table class='widetable' cellpadding=5 cellspacing=0 border=0 align='center' width='100%'>\n"; |
53f4b619 | 2549 | echo "<tr><th> </th><th>port</th><th>RS pool</th></tr>\n"; |
5fe1ed76 DO |
2550 | foreach ($address['rslist'] as $rsinfo) |
2551 | { | |
2552 | echo "<tr><td>"; | |
2553 | if ($rsinfo['inservice'] == 'yes') | |
2554 | printImageHREF ('inservice', 'in service'); | |
2555 | else | |
2556 | printImageHREF ('notinservice', 'NOT in service'); | |
4fbb5a00 | 2557 | echo "</td><td class=tdleft>${rsinfo['rsport']}</td><td class=tdleft><a href='".makeHref(array('page'=>'ipv4rspool', 'pool_id'=>$rsinfo['rspool_id']))."'>"; |
2d318652 | 2558 | echo $rsinfo['rspool_name'] . "</a></td></tr>\n"; |
5fe1ed76 DO |
2559 | } |
2560 | echo "</table><br><br>"; | |
2561 | finishPortlet(); | |
2562 | } | |
2563 | ||
68225375 DO |
2564 | if (count ($address['outpf'])) |
2565 | { | |
105a3bc8 | 2566 | startPortlet ('departing NAT rules'); |
2d318652 | 2567 | echo "<table class='widetable' cellpadding=5 cellspacing=0 border=0 align='center' width='100%'>\n"; |
105a3bc8 DO |
2568 | echo "<tr><th>proto</th><th>from</th><th>to</th><th>comment</th></tr>\n"; |
2569 | foreach ($address['outpf'] as $rule) | |
b62ff880 | 2570 | echo "<tr><td>${rule['proto']}</td><td>${rule['localip']}:${rule['localport']}</td><td>${rule['remoteip']}:${rule['remoteport']}</td><td>${rule['description']}</td></tr>"; |
105a3bc8 | 2571 | echo "</table>"; |
68225375 DO |
2572 | finishPortlet(); |
2573 | } | |
105a3bc8 DO |
2574 | |
2575 | if (count ($address['inpf'])) | |
2576 | { | |
2577 | startPortlet ('arriving NAT rules'); | |
2d318652 | 2578 | echo "<table class='widetable' cellpadding=5 cellspacing=0 border=0 align='center' width='100%'>\n"; |
105a3bc8 DO |
2579 | echo "<tr><th>proto</th><th>from</th><th>to</th><th>comment</th></tr>\n"; |
2580 | foreach ($address['inpf'] as $rule) | |
b62ff880 | 2581 | echo "<tr><td>${rule['proto']}</td><td>${rule['localip']}:${rule['localport']}</td><td>${rule['remoteip']}:${rule['remoteport']}</td><td>${rule['description']}</td></tr>"; |
105a3bc8 DO |
2582 | echo "</table>"; |
2583 | finishPortlet(); | |
2584 | } | |
2585 | ||
68225375 DO |
2586 | echo "</td></tr>"; |
2587 | echo "</table>\n"; | |
e673ee24 DO |
2588 | } |
2589 | ||
2d318652 | 2590 | function renderIPv4AddressProperties ($dottedquad) |
e673ee24 | 2591 | { |
2d318652 DO |
2592 | $address = getIPv4Address ($dottedquad); |
2593 | echo "<center><h1>$dottedquad</h1></center>\n"; | |
7056988c | 2594 | |
1fbc9fd6 | 2595 | startPortlet ('update'); |
e673ee24 | 2596 | echo "<table border=0 cellpadding=10 cellpadding=1 align='center'>\n"; |
7056988c | 2597 | printOpFormIntro ('editAddress'); |
2d318652 DO |
2598 | echo "<tr><td class='tdright'>Name:</td><td class='tdleft'><input type=text name=name size=20 value='${address['name']}'></tr>"; |
2599 | echo "<td class='tdright'>Reserved:</td><td class='tdleft'><input type=checkbox name=reserved size=20 "; | |
2600 | echo ($address['reserved']=='yes') ? 'checked' : ''; | |
f3d274bf | 2601 | echo "></tr><tr><td class=tdleft>"; |
53ef3908 | 2602 | printImageHREF ('SAVE', 'Save changes', TRUE); |
f3d274bf | 2603 | echo "</td></form><td class=tdright>"; |
59a83bd8 | 2604 | if (!strlen ($address['name']) and $address['reserved'] == 'no') |
f3d274bf DO |
2605 | printImageHREF ('CLEAR gray'); |
2606 | else | |
2607 | { | |
2608 | printOpFormIntro ('editAddress', array ('name' => '', 'reserved' => '')); | |
2609 | printImageHREF ('CLEAR', 'Release', TRUE); | |
2610 | echo "</form>"; | |
2611 | } | |
2612 | echo "</td></tr></table>\n"; | |
1fbc9fd6 | 2613 | finishPortlet(); |
e673ee24 DO |
2614 | } |
2615 | ||
2d318652 | 2616 | function renderIPv4AddressAllocations ($dottedquad) |
e673ee24 | 2617 | { |
39b4abd0 DO |
2618 | function printNewItemTR () |
2619 | { | |
2620 | global $aat; | |
2621 | printOpFormIntro ('addIPv4Allocation'); | |
2622 | echo "<tr><td>"; | |
9318d2ef | 2623 | printImageHREF ('add', 'allocate', TRUE); |
8d4f7d18 | 2624 | echo "</td><td>"; |
c6bc0ac5 | 2625 | printSelect (getNarrowObjectList ('IPV4OBJ_LISTSRC'), 'object_id', NULL, 100); |
8d4f7d18 | 2626 | echo "</td><td><input type=text tabindex=101 name=bond_name size=10></td><td>"; |
f5ff50f5 | 2627 | printSelect ($aat, 'bond_type', NULL, 102); |
9318d2ef | 2628 | echo "</td><td>"; |
f5ff50f5 | 2629 | printImageHREF ('add', 'allocate', TRUE, 103); |
9318d2ef | 2630 | echo "</td></form></tr>"; |
39b4abd0 | 2631 | } |
b82cce3f | 2632 | global $aat; |
e673ee24 | 2633 | |
2d318652 | 2634 | $address = getIPv4Address ($dottedquad); |
f74d96c6 | 2635 | |
2d318652 | 2636 | echo "<center><h1>${dottedquad}</h1></center>\n"; |
105a3bc8 | 2637 | echo "<table class='widetable' cellpadding=5 cellspacing=0 border=0 align='center'>\n"; |
2d318652 | 2638 | echo "<tr><th> </th><th>object</th><th>OS interface</th><th>allocation type</th><th> </th></tr>\n"; |
e673ee24 | 2639 | |
39b4abd0 DO |
2640 | if (getConfigVar ('ADDNEW_AT_TOP') == 'yes') |
2641 | printNewItemTR(); | |
f74d96c6 | 2642 | if (isset ($address['class'])) |
e673ee24 | 2643 | { |
f74d96c6 DO |
2644 | $class = $address['class']; |
2645 | if ($address['reserved'] == 'yes') | |
2646 | echo "<tr class='${class}'><td colspan=3> </td><td class=tdleft><strong>RESERVED</strong></td><td> </td></tr>"; | |
2647 | foreach ($address['allocs'] as $bond) | |
2648 | { | |
2649 | echo "<tr class='$class'>"; | |
2650 | printOpFormIntro ('updIPv4Allocation', array ('object_id' => $bond['object_id'])); | |
4fbb5a00 | 2651 | echo "<td><a href='".makeHrefProcess(array('op'=>'delIPv4Allocation', 'ip'=>$dottedquad, 'object_id'=>$bond['object_id']))."'>"; |
f74d96c6 DO |
2652 | printImageHREF ('delete', 'Unallocate address'); |
2653 | echo "</a></td>"; | |
4fbb5a00 | 2654 | echo "<td><a href='".makeHref(array('page'=>'object', 'object_id'=>$bond['object_id'], 'hl_ipv4_addr'=>$dottedquad))."'>${bond['object_name']}</td>"; |
f74d96c6 DO |
2655 | echo "<td><input type='text' name='bond_name' value='${bond['name']}' size=10></td><td>"; |
2656 | printSelect ($aat, 'bond_type', $bond['type']); | |
2657 | echo "</td><td>"; | |
2658 | printImageHREF ('save', 'Save changes', TRUE); | |
2659 | echo "</td></form></tr>\n"; | |
2660 | } | |
e673ee24 | 2661 | } |
39b4abd0 DO |
2662 | if (getConfigVar ('ADDNEW_AT_TOP') != 'yes') |
2663 | printNewItemTR(); | |
e673ee24 | 2664 | echo "</table><br><br>"; |
e673ee24 DO |
2665 | } |
2666 | ||
7e1db771 | 2667 | function renderNATv4ForObject ($object_id) |
e673ee24 | 2668 | { |
9318d2ef DO |
2669 | function printNewItemTR ($alloclist) |
2670 | { | |
9318d2ef DO |
2671 | printOpFormIntro ('addNATv4Rule'); |
2672 | echo "<tr align='center'><td>"; | |
2673 | printImageHREF ('add', 'Add new NAT rule', TRUE); | |
2674 | echo '</td><td>'; | |
2675 | printSelect (array ('TCP' => 'TCP', 'UDP' => 'UDP'), 'proto'); | |
2676 | echo "<select name='localip' tabindex=1>"; | |
2677 | ||
2678 | foreach ($alloclist as $dottedquad => $alloc) | |
2679 | { | |
43eb71f1 DO |
2680 | $name = (!isset ($alloc['addrinfo']['name']) or !strlen ($alloc['addrinfo']['name'])) ? '' : (' (' . niftyString ($alloc['addrinfo']['name']) . ')'); |
2681 | $osif = (!isset ($alloc['osif']) or !strlen ($alloc['osif'])) ? '' : ($alloc['osif'] . ': '); | |
9318d2ef DO |
2682 | echo "<option value='${dottedquad}'>${osif}${dottedquad}${name}</option>"; |
2683 | } | |
2684 | ||
2685 | echo "</select>:<input type='text' name='localport' size='4' tabindex=2></td>"; | |
2686 | echo "<td><input type='text' name='remoteip' id='remoteip' size='10' tabindex=3>"; | |
39106006 DO |
2687 | echo "<a href='javascript:;' onclick='window.open(\"" . makeHrefForHelper ('inet4list'); |
2688 | echo "\", \"findobjectip\", \"height=700, width=400, location=no, menubar=no, resizable=yes, scrollbars=no, status=no, titlebar=no, toolbar=no\");'>"; | |
9318d2ef DO |
2689 | printImageHREF ('find', 'Find object'); |
2690 | echo "</a>"; | |
2691 | echo ":<input type='text' name='remoteport' size='4' tabindex=4></td><td></td>"; | |
2692 | echo "<td colspan=1><input type='text' name='description' size='20' tabindex=5></td><td>"; | |
f5ff50f5 | 2693 | printImageHREF ('add', 'Add new NAT rule', TRUE, 6); |
9318d2ef DO |
2694 | echo "</td></tr></form>"; |
2695 | } | |
e673ee24 | 2696 | |
94fe6370 DO |
2697 | $focus = spotEntity ('object', $object_id); |
2698 | amplifyCell ($focus); | |
f28fbe8b | 2699 | echo "<center><h2>locally performed NAT</h2></center>"; |
e673ee24 | 2700 | |
105a3bc8 | 2701 | echo "<table class='widetable' cellpadding=5 cellspacing=0 border=0 align='center'>\n"; |
d54b9495 | 2702 | echo "<tr><th></th><th>Match endpoint</th><th>Translate to</th><th>Target object</th><th>Comment</th><th> </th></tr>\n"; |
e673ee24 | 2703 | |
9318d2ef | 2704 | if (getConfigVar ('ADDNEW_AT_TOP') == 'yes') |
94fe6370 DO |
2705 | printNewItemTR ($focus['ipv4']); |
2706 | foreach ($focus['nat4']['out'] as $pf) | |
e673ee24 | 2707 | { |
2c817354 DO |
2708 | $class = 'trerror'; |
2709 | $osif = ''; | |
94fe6370 | 2710 | if (isset ($focus['ipv4'][$pf['localip']])) |
2c817354 | 2711 | { |
94fe6370 DO |
2712 | $class = $focus['ipv4'][$pf['localip']]['addrinfo']['class']; |
2713 | $osif = $focus['ipv4'][$pf['localip']]['osif'] . ': '; | |
2c817354 | 2714 | } |
e673ee24 DO |
2715 | |
2716 | echo "<tr class='$class'>"; | |
4fbb5a00 DY |
2717 | echo "<td><a href='". |
2718 | makeHrefProcess(array( | |
2719 | 'op'=>'delNATv4Rule', | |
2720 | 'localip'=>$pf['localip'], | |
2721 | 'localport'=>$pf['localport'], | |
2722 | 'remoteip'=>$pf['remoteip'], | |
2723 | 'remoteport'=>$pf['remoteport'], | |
2724 | 'proto'=>$pf['proto'], | |
2725 | 'object_id'=>$object_id)). | |
2726 | "'>"; | |
4de22e7e DO |
2727 | printImageHREF ('delete', 'Delete NAT rule'); |
2728 | echo "</a></td>"; | |
4fbb5a00 | 2729 | echo "<td>${pf['proto']}/${osif}<a href='".makeHref(array('page'=>'ipaddress', 'tab'=>'default', 'ip'=>$pf['localip']))."'>${pf['localip']}</a>:${pf['localport']}"; |
59a83bd8 | 2730 | if (strlen ($pf['local_addr_name'])) |
f28fbe8b DO |
2731 | echo ' (' . $pf['local_addr_name'] . ')'; |
2732 | echo "</td>"; | |
4fbb5a00 | 2733 | echo "<td><a href='".makeHref(array('page'=>'ipaddress', 'tab'=>'default', 'ip'=>$pf['remoteip']))."'>${pf['remoteip']}</a>:${pf['remoteport']}</td>"; |
e673ee24 | 2734 | |
53ef3908 | 2735 | $address = getIPv4Address ($pf['remoteip']); |
e673ee24 DO |
2736 | |
2737 | echo "<td class='description'>"; | |
53ef3908 DO |
2738 | if (count ($address['allocs'])) |
2739 | foreach ($address['allocs'] as $bond) | |
4fbb5a00 | 2740 | echo "<a href='".makeHref(array('page'=>'object', 'tab'=>'default', 'object_id'=>$bond['object_id']))."'>${bond['object_name']}(${bond['name']})</a> "; |
59a83bd8 | 2741 | elseif (strlen ($pf['remote_addr_name'])) |
f28fbe8b | 2742 | echo '(' . $pf['remote_addr_name'] . ')'; |
7056988c DO |
2743 | printOpFormIntro |
2744 | ( | |
2745 | 'updNATv4Rule', | |
2746 | array | |
2747 | ( | |
2748 | 'localip' => $pf['localip'], | |
2749 | 'localport' => $pf['localport'], | |
2750 | 'remoteip' => $pf['remoteip'], | |
2751 | 'remoteport' => $pf['remoteport'], | |
2752 | 'proto' => $pf['proto'] | |
2753 | ) | |
2754 | ); | |
2755 | echo "</td><td class='description'>"; | |
d54b9495 DO |
2756 | echo "<input type='text' name='description' value='${pf['description']}'></td><td>"; |
2757 | printImageHREF ('save', 'Save changes', TRUE); | |
2758 | echo "</td></form></tr>"; | |
e673ee24 | 2759 | } |
9318d2ef | 2760 | if (getConfigVar ('ADDNEW_AT_TOP') != 'yes') |
94fe6370 | 2761 | printNewItemTR ($focus['ipv4']); |
e673ee24 DO |
2762 | |
2763 | echo "</table><br><br>"; | |
94fe6370 DO |
2764 | if (!count ($focus['nat4'])) |
2765 | return; | |
e673ee24 | 2766 | |
f28fbe8b | 2767 | echo "<center><h2>arriving NAT connections</h2></center>"; |
105a3bc8 | 2768 | echo "<table class='widetable' cellpadding=5 cellspacing=0 border=0 align='center'>\n"; |
e673ee24 DO |
2769 | echo "<tr><th></th><th>Source</th><th>Source objects</th><th>Target</th><th>Description</th></tr>\n"; |
2770 | ||
94fe6370 | 2771 | foreach ($focus['nat4']['in'] as $pf) |
e673ee24 | 2772 | { |
4fbb5a00 DY |
2773 | echo "<tr><td><a href='". |
2774 | makeHrefProcess(array( | |
2775 | 'op'=>'delNATv4Rule', | |
2776 | 'localip'=>$pf['localip'], | |
2777 | 'localport'=>$pf['localport'], | |
2778 | 'remoteip'=>$pf['remoteip'], | |
2779 | 'remoteport'=>$pf['remoteport'], | |
2780 | 'proto'=>$pf['proto'], | |
2781 | 'object_id'=>$pf['object_id'] | |
2782 | )). | |
2783 | "'>"; | |
4de22e7e DO |
2784 | printImageHREF ('delete', 'Delete NAT rule'); |
2785 | echo "</a></td>"; | |
4fbb5a00 DY |
2786 | echo "<td>${pf['proto']}/<a href='".makeHref(array('page'=>'ipaddress', 'tab'=>'default', 'ip'=>$pf['localip']))."'>${pf['localip']}</a>:${pf['localport']}</td>"; |
2787 | echo "<td class='description'><a href='".makeHref(array('page'=>'object', 'tab'=>'default', 'object_id'=>$pf['object_id']))."'>${pf['object_name']}</a>"; | |
2788 | echo "</td><td><a href='".makeHref(array('page'=>'ipaddress', 'tab'=>'default', 'ip'=>$pf['remoteip']))."'>${pf['remoteip']}</a>:${pf['remoteport']}</td>"; | |
e673ee24 DO |
2789 | echo "<td class='description'>${pf['description']}</td></tr>"; |
2790 | } | |
2791 | ||
e673ee24 | 2792 | echo "</table><br><br>"; |
e673ee24 DO |
2793 | } |
2794 | ||
e673ee24 DO |
2795 | function renderAddMultipleObjectsForm () |
2796 | { | |
e673ee24 | 2797 | $typelist = getObjectTypeList(); |
4c330a14 | 2798 | $typelist[0] = 'select type...'; |
a1886a78 DO |
2799 | $max = getConfigVar ('MASSCOUNT'); |
2800 | $tabindex = 100; | |
7f791d1d | 2801 | |
f60bb422 | 2802 | startPortlet ('Distinct types, same tags'); |
42d73cbf | 2803 | printOpFormIntro ('addObjects'); |
e673ee24 | 2804 | echo '<table border=0 align=center>'; |
f60bb422 DO |
2805 | echo "<tr><th>Object type</th><th>Common name</th><th>Visible label</th>"; |
2806 | echo "<th>Asset tag</th><th>Barcode</th><th>Tags</th></tr>\n"; | |
9c0b0016 | 2807 | for ($i = 0; $i < $max; $i++) |
e673ee24 | 2808 | { |
7f791d1d | 2809 | echo '<tr><td>'; |
e7ade6bf | 2810 | // Don't employ DEFAULT_OBJECT_TYPE to avoid creating ghost records for pre-selected empty rows. |
a1886a78 | 2811 | printSelect ($typelist, "${i}_object_type_id", 0, $tabindex); |
e673ee24 | 2812 | echo '</td>'; |
a1886a78 DO |
2813 | echo "<td><input type=text size=30 name=${i}_object_name tabindex=${tabindex}></td>"; |
2814 | echo "<td><input type=text size=30 name=${i}_object_label tabindex=${tabindex}></td>"; | |
2815 | echo "<td><input type=text size=20 name=${i}_object_asset_no tabindex=${tabindex}></td>"; | |
2816 | echo "<td><input type=text size=10 name=${i}_object_barcode tabindex=${tabindex}></td>"; | |
f60bb422 DO |
2817 | if ($i == 0) |
2818 | { | |
2819 | echo "<td valign=top rowspan=${max}>"; | |
25186565 | 2820 | renderNewEntityTags(); |
f60bb422 DO |
2821 | echo "</td>\n"; |
2822 | } | |
e673ee24 | 2823 | echo "</tr>\n"; |
a1886a78 | 2824 | $tabindex++; |
e673ee24 | 2825 | } |
216c84bb | 2826 | echo "<tr><td class=submit colspan=5><input type=submit name=got_fast_data value='Go!'></td></tr>\n"; |
e673ee24 DO |
2827 | echo "</form></table>\n"; |
2828 | finishPortlet(); | |
7f791d1d | 2829 | |
f60bb422 | 2830 | startPortlet ('Same type, same tags'); |
42d73cbf | 2831 | printOpFormIntro ('addLotOfObjects'); |
f60bb422 DO |
2832 | echo "<table border=0 align=center><tr><th>names</th><th>type</th></tr>"; |
2833 | echo "<tr><td rowspan=3><textarea name=namelist cols=40 rows=25>\n"; | |
f60bb422 DO |
2834 | echo "</textarea></td><td valign=top>"; |
2835 | printSelect ($typelist, "global_type_id", getConfigVar ('DEFAULT_OBJECT_TYPE')); | |
2836 | echo "</td></tr>"; | |
2837 | echo "<tr><th>Tags</th></tr>"; | |
2838 | echo "<tr><td valign=top>"; | |
25186565 | 2839 | renderNewEntityTags(); |
f60bb422 DO |
2840 | echo "</td></tr>"; |
2841 | echo "<tr><td colspan=2><input type=submit name=got_very_fast_data value='Go!'></td></tr></table>\n"; | |
2842 | echo "</form>\n"; | |
7f791d1d | 2843 | finishPortlet(); |
e673ee24 DO |
2844 | } |
2845 | ||
2846 | function printGreeting () | |
2847 | { | |
d6d79c36 DO |
2848 | global $root, $remote_username, $remote_displayname; |
2849 | echo "Hello, <a href='${root}?page=myaccount&tab=default'>${remote_displayname}</a>. This is RackTables " . | |
2850 | CODE_VERSION . | |
2851 | ". Click <a href='${root}?logout'>here</a> to logout."; | |
e673ee24 DO |
2852 | } |
2853 | ||
2854 | function renderSearchResults () | |
2855 | { | |
0b9c98d7 | 2856 | global $root; |
e673ee24 | 2857 | $terms = trim ($_REQUEST['q']); |
59a83bd8 | 2858 | if (!strlen ($terms)) |
e673ee24 | 2859 | { |
591ff2c4 | 2860 | showError ('Search string cannot be empty.', __FUNCTION__); |
e673ee24 DO |
2861 | return; |
2862 | } | |
c78a40ec | 2863 | if (!permitted ('depot', 'default')) |
e673ee24 | 2864 | { |
591ff2c4 | 2865 | showError ('You are not authorized for viewing information about objects.', __FUNCTION__); |
e673ee24 DO |
2866 | return; |
2867 | } | |
ea5fc465 | 2868 | $nhits = 0; |
e673ee24 DO |
2869 | // If we search for L2 address, we can either find one or find none. |
2870 | if | |
2871 | ( | |
05771508 DO |
2872 | preg_match (RE_L2_IFCFG, $terms) or |
2873 | preg_match (RE_L2_SOLID, $terms) or | |
2874 | preg_match (RE_L2_CISCO, $terms) or | |
1930dc7f | 2875 | preg_match (RE_L2_IPCFG, $terms) or |
05771508 DO |
2876 | // Foundry STP bridge ID: bridge priotity + port MAC address. Cut off first 4 chars and look for MAC address. |
2877 | preg_match (RE_L2_FDRYSTP, $terms) | |
e673ee24 DO |
2878 | ) |
2879 | // Search for L2 address. | |
2880 | { | |
3ec29bf4 DO |
2881 | $terms = str_replace ('.', '', $terms); |
2882 | $terms = str_replace (':', '', $terms); | |
1930dc7f | 2883 | $terms = str_replace ('-', '', $terms); |
ea5fc465 | 2884 | $terms = substr ($terms, -12); |
e673ee24 DO |
2885 | $result = searchByl2address ($terms); |
2886 | if ($result !== NULL) | |
2887 | { | |
ea5fc465 DO |
2888 | $nhits++; |
2889 | $lasthit = 'port'; | |
2890 | $summary['port'][] = $result; | |
e673ee24 | 2891 | } |
e673ee24 | 2892 | } |
05771508 | 2893 | elseif (preg_match (RE_IP4_ADDR, $terms)) |
64347dcf | 2894 | // Search for IPv4 address. |
e673ee24 | 2895 | { |
bb0a44e9 | 2896 | if (NULL !== getIPv4AddressNetworkId ($terms)) |
e673ee24 | 2897 | { |
ea5fc465 | 2898 | $nhits++; |
f3d0cb20 DO |
2899 | $lasthit = 'ipv4addressbydq'; |
2900 | $summary['ipv4addressbydq'][] = $terms; | |
e673ee24 | 2901 | } |
e673ee24 | 2902 | } |
05771508 | 2903 | elseif (preg_match (RE_IP4_NET, $terms)) |
64347dcf DO |
2904 | // Search for IPv4 network |
2905 | { | |
2906 | list ($base, $len) = explode ('/', $terms); | |
2907 | if (NULL !== ($tmp = getIPv4AddressNetworkId ($base, $len + 1))) | |
2908 | { | |
2909 | $nhits++; | |
2910 | $lasthit = 'ipv4network'; | |
d724d290 | 2911 | $summary['ipv4network'][] = spotEntity ('ipv4net', $tmp); |
64347dcf DO |
2912 | } |
2913 | } | |
e673ee24 | 2914 | else |
ea5fc465 | 2915 | // Search for objects, addresses, networks, virtual services and RS pools by their description. |
e673ee24 | 2916 | { |
ea5fc465 DO |
2917 | $tmp = getObjectSearchResults ($terms); |
2918 | if (count ($tmp)) | |
e673ee24 | 2919 | { |
ea5fc465 DO |
2920 | $nhits += count ($tmp); |
2921 | $lasthit = 'object'; | |
2922 | $summary['object'] = $tmp; | |
e673ee24 | 2923 | } |
ea5fc465 DO |
2924 | $tmp = getIPv4AddressSearchResult ($terms); |
2925 | if (count ($tmp)) | |
e673ee24 | 2926 | { |
ea5fc465 | 2927 | $nhits += count ($tmp); |
f3d0cb20 DO |
2928 | $lasthit = 'ipv4addressbydescr'; |
2929 | $summary['ipv4addressbydescr'] = $tmp; | |
ea5fc465 DO |
2930 | } |
2931 | $tmp = getIPv4PrefixSearchResult ($terms); | |
2932 | if (count ($tmp)) | |
2933 | { | |
2934 | $nhits += count ($tmp); | |
2935 | $lasthit = 'ipv4network'; | |
2936 | $summary['ipv4network'] = $tmp; | |
2937 | } | |
05411ccd DO |
2938 | $tmp = getIPv4RSPoolSearchResult ($terms); |
2939 | if (count ($tmp)) | |
2940 | { | |
2941 | $nhits += count ($tmp); | |
2942 | $lasthit = 'ipv4rspool'; | |
2943 | $summary['ipv4rspool'] = $tmp; | |
2944 | } | |
2945 | $tmp = getIPv4VServiceSearchResult ($terms); | |
2946 | if (count ($tmp)) | |
2947 | { | |
2948 | $nhits += count ($tmp); | |
2949 | $lasthit = 'ipv4vs'; | |
2950 | $summary['ipv4vs'] = $tmp; | |
2951 | } | |
6a88e734 DO |
2952 | $tmp = getAccountSearchResult ($terms); |
2953 | if (count ($tmp)) | |
2954 | { | |
2955 | $nhits += count ($tmp); | |
2956 | $lasthit = 'user'; | |
2957 | $summary['user'] = $tmp; | |
2958 | } | |
e1ae3fb4 AD |
2959 | $tmp = getFileSearchResult ($terms); |
2960 | if (count ($tmp)) | |
2961 | { | |
2962 | $nhits += count ($tmp); | |
2963 | $lasthit = 'file'; | |
2964 | $summary['file'] = $tmp; | |
2965 | } | |
e531b4d6 DO |
2966 | $tmp = getRackSearchResult ($terms); |
2967 | if (count ($tmp)) | |
2968 | { | |
2969 | $nhits += count ($tmp); | |
2970 | $lasthit = 'rack'; | |
2971 | $summary['rack'] = $tmp; | |
2972 | } | |
ea5fc465 DO |
2973 | } |
2974 | if ($nhits == 0) | |
2975 | echo "<center><h2>Nothing found for '${terms}'</h2></center>"; | |
2976 | elseif ($nhits == 1) | |
2977 | { | |
2978 | $record = current ($summary[$lasthit]); | |
2979 | switch ($lasthit) | |
2980 | { | |
2981 | case 'port': | |
2982 | echo "<script language='Javascript'>document.location='${root}?page=object"; | |
2983 | echo "&hl_port_id=" . $record['port_id']; | |
2984 | echo "&object_id=" . $record['object_id'] . "';//</script>"; | |
2985 | break; | |
f3d0cb20 DO |
2986 | case 'ipv4addressbydq': |
2987 | $parentnet = getIPv4AddressNetworkId ($record); | |
2988 | if ($parentnet !== NULL) | |
e1ae3fb4 | 2989 | echo "<script language='Javascript'>document.location='${root}?page=ipv4net&tab=default&id=${parentnet}&hl_ipv4_addr=${record}';//</script>"; |
f3d0cb20 DO |
2990 | else |
2991 | echo "<script language='Javascript'>document.location='${root}?page=ipaddress&ip=${record}';//</script>"; | |
ea5fc465 | 2992 | break; |
f3d0cb20 DO |
2993 | case 'ipv4addressbydescr': |
2994 | $parentnet = getIPv4AddressNetworkId ($record['ip']); | |
2995 | if ($parentnet !== NULL) | |
e1ae3fb4 | 2996 | echo "<script language='Javascript'>document.location='${root}?page=ipv4net&tab=default&id=${parentnet}&hl_ipv4_addr=${record['ip']}';//</script>"; |
f3d0cb20 DO |
2997 | else |
2998 | echo "<script language='Javascript'>document.location='${root}?page=ipaddress&ip=${record['ip']}';//</script>"; | |
ea5fc465 DO |
2999 | break; |
3000 | case 'ipv4network': | |
e1ae3fb4 | 3001 | echo "<script language='Javascript'>document.location='${root}?page=ipv4net"; |
ea5fc465 DO |
3002 | echo "&id=${record['id']}"; |
3003 | echo "';//</script>"; | |
3004 | break; | |
3005 | case 'object': | |
3006 | echo "<script language='Javascript'>document.location='${root}?page=object&object_id=${record['id']}';//</script>"; | |
3007 | break; | |
05411ccd | 3008 | case 'ipv4rspool': |
e1ae3fb4 | 3009 | echo "<script language='Javascript'>document.location='${root}?page=ipv4rspool&pool_id=${record['pool_id']}';//</script>"; |
05411ccd DO |
3010 | break; |
3011 | case 'ipv4vs': | |
49fb2686 | 3012 | echo "<script language='Javascript'>document.location='${root}?page=ipv4vs&vs_id=${record['id']}';//</script>"; |
05411ccd | 3013 | break; |
6a88e734 DO |
3014 | case 'user': |
3015 | echo "<script language='Javascript'>document.location='${root}?page=user&user_id=${record['user_id']}';//</script>"; | |
3016 | break; | |
e1ae3fb4 AD |
3017 | case 'file': |
3018 | echo "<script language='Javascript'>document.location='${root}?page=file&file_id=${record['id']}';//</script>"; | |
3019 | break; | |
e531b4d6 DO |
3020 | case 'rack': |
3021 | echo "<script language='Javascript'>document.location='${root}?page=rack&rack_id=${record['id']}';//</script>"; | |
3022 | break; | |
ea5fc465 DO |
3023 | } |
3024 | return; | |
3025 | } | |
3026 | else | |
3027 | { | |
3028 | global $nextorder; | |
3029 | $order = 'odd'; | |
3030 | echo "<center><h2>${nhits} result(s) found for '${terms}'</h2></center>"; | |
3031 | foreach ($summary as $where => $what) | |
3032 | switch ($where) | |
e673ee24 | 3033 | { |
ea5fc465 | 3034 | case 'object': |
c78a40ec | 3035 | startPortlet ("<a href='${root}?page=depot'>Objects</a>"); |
ea5fc465 | 3036 | echo '<table border=0 cellpadding=5 cellspacing=0 align=center class=cooltable>'; |
e1ae3fb4 | 3037 | echo '<tr><th>Common name</th><th>Visible label</th><th>Asset tag</th><th>Barcode</th></tr>'; |
ea5fc465 DO |
3038 | foreach ($what as $obj) |
3039 | { | |
2c21a10c | 3040 | $tags = loadEntityTags ('object', $obj['id']); |
2b3d64c5 DO |
3041 | echo "<tr class=row_${order} valign=top><td class=tdleft><a href=\"${root}?page=object&object_id=${obj['id']}\">${obj['dname']}</a>"; |
3042 | if (count ($tags)) | |
3043 | echo '<br><small>' . serializeTags ($tags) . '</small>'; | |
3044 | echo "</td><td>${obj['label']}</td>"; | |
ea5fc465 DO |
3045 | echo "<td>${obj['asset_no']}</td>"; |
3046 | echo "<td>${obj['barcode']}</td></tr>"; | |
3047 | $order = $nextorder[$order]; | |
3048 | } | |
3049 | echo '</table>'; | |
3050 | finishPortlet(); | |
3051 | break; | |
3052 | case 'ipv4network': | |
06adfe89 | 3053 | startPortlet ("<a href='${root}?page=ipv4space'>IPv4 networks</a>"); |
ea5fc465 | 3054 | echo '<table border=0 cellpadding=5 cellspacing=0 align=center class=cooltable>'; |
6df2025d | 3055 | foreach ($what as $cell) |
ea5fc465 | 3056 | { |
0b9c98d7 | 3057 | echo "<tr class=row_${order} valign=top><td>"; |
6df2025d | 3058 | renderCell ($cell); |
0b9c98d7 | 3059 | echo "</td></tr>\n"; |
ea5fc465 DO |
3060 | $order = $nextorder[$order]; |
3061 | } | |
3062 | echo '</table>'; | |
3063 | finishPortlet(); | |
3064 | break; | |
f3d0cb20 | 3065 | case 'ipv4addressbydescr': |
ea5fc465 DO |
3066 | startPortlet ('IPv4 addresses'); |
3067 | echo '<table border=0 cellpadding=5 cellspacing=0 align=center class=cooltable>'; | |
f3d0cb20 | 3068 | // FIXME: address, parent network, routers (if extended view is enabled) |
e1ae3fb4 | 3069 | echo '<tr><th>Address</th><th>Description</th></tr>'; |
ea5fc465 DO |
3070 | foreach ($what as $addr) |
3071 | { | |
f3d0cb20 DO |
3072 | echo "<tr class=row_${order}><td class=tdleft>"; |
3073 | $parentnet = getIPv4AddressNetworkId ($addr['ip']); | |
3074 | if ($parentnet !== NULL) | |
e1ae3fb4 | 3075 | echo "<a href='${root}?page=ipv4net&tab=default&id=${parentnet}&hl_ipv4_addr=${addr['ip']}'>${addr['ip']}</a></td>"; |
f3d0cb20 DO |
3076 | else |
3077 | echo "<a href='${root}?page=ipaddress&ip=${addr['ip']}'>${addr['ip']}</a></td>"; | |
ea5fc465 DO |
3078 | echo "<td class=tdleft>${addr['name']}</td></tr>"; |
3079 | $order = $nextorder[$order]; | |
3080 | } | |
3081 | echo '</table>'; | |
3082 | finishPortlet(); | |
3083 | break; | |
05411ccd | 3084 | case 'ipv4rspool': |
ee437dab | 3085 | startPortlet ("<a href='${root}?page=ipv4rsplist'>RS pools</a>"); |
05411ccd | 3086 | echo '<table border=0 cellpadding=5 cellspacing=0 align=center class=cooltable>'; |
6cd32e3c | 3087 | foreach ($what as $cell) |
05411ccd | 3088 | { |
216136d2 | 3089 | echo "<tr class=row_${order}><td class=tdleft>"; |
6cd32e3c | 3090 | renderCell ($cell); |
216136d2 | 3091 | echo "</td></tr>"; |
05411ccd DO |
3092 | $order = $nextorder[$order]; |
3093 | } | |
3094 | echo '</table>'; | |
3095 | finishPortlet(); | |
3096 | break; | |
3097 | case 'ipv4vs': | |
a239e016 | 3098 | startPortlet ("<a href='${root}?page=ipv4vslist'>Virtual services</a>"); |
05411ccd | 3099 | echo '<table border=0 cellpadding=5 cellspacing=0 align=center class=cooltable>'; |
6df2025d | 3100 | foreach ($what as $cell) |
05411ccd | 3101 | { |
8128c257 | 3102 | echo "<tr class=row_${order}><td class=tdleft>"; |
6df2025d | 3103 | renderCell ($cell); |
8128c257 | 3104 | echo "</td></tr>"; |
6a88e734 DO |
3105 | $order = $nextorder[$order]; |
3106 | } | |
3107 | echo '</table>'; | |
3108 | finishPortlet(); | |
3109 | break; | |
3110 | case 'user': | |
3111 | startPortlet ("<a href='${root}?page=userlist'>Users</a>"); | |
3112 | echo '<table border=0 cellpadding=5 cellspacing=0 align=center class=cooltable>'; | |
6a88e734 DO |
3113 | foreach ($what as $item) |
3114 | { | |
19dac9c3 | 3115 | echo "<tr class=row_${order}><td class=tdleft>"; |
573214e0 | 3116 | renderCell ($item); |
19dac9c3 | 3117 | echo "</td></tr>"; |
05411ccd DO |
3118 | $order = $nextorder[$order]; |
3119 | } | |
3120 | echo '</table>'; | |
3121 | finishPortlet(); | |
3122 | break; | |
e1ae3fb4 AD |
3123 | case 'file': |
3124 | startPortlet ("<a href='${root}?page=files'>Files</a>"); | |
3125 | echo '<table border=0 cellpadding=5 cellspacing=0 align=center class=cooltable>'; | |
6df2025d | 3126 | foreach ($what as $cell) |
e1ae3fb4 | 3127 | { |
35d10b16 | 3128 | echo "<tr class=row_${order}><td class=tdleft>"; |
6df2025d | 3129 | renderCell ($cell); |
35d10b16 | 3130 | echo "</td></tr>"; |
e1ae3fb4 AD |
3131 | $order = $nextorder[$order]; |
3132 | } | |
3133 | echo '</table>'; | |
3134 | finishPortlet(); | |
3135 | break; | |
e531b4d6 DO |
3136 | case 'rack': |
3137 | startPortlet ("<a href='${root}?page=rackspace'>Racks</a>"); | |
3138 | echo '<table border=0 cellpadding=5 cellspacing=0 align=center class=cooltable>'; | |
3139 | foreach ($what as $cell) | |
3140 | { | |
3141 | echo "<tr class=row_${order}><td class=tdleft>"; | |
3142 | renderCell ($cell); | |
3143 | echo "</td></tr>"; | |
3144 | $order = $nextorder[$order]; | |
3145 | } | |
3146 | echo '</table>'; | |
3147 | finishPortlet(); | |
3148 | break; | |
e673ee24 | 3149 | } |
e673ee24 DO |
3150 | } |
3151 | } | |
3152 | ||
3153 | // This function prints a table of checkboxes to aid the user in toggling mount atoms | |
3154 | // from one state to another. The first argument is rack data as | |
61a1d996 | 3155 | // produced by amplifyCell(), the second is the value used for the 'unckecked' state |
e673ee24 DO |
3156 | // and the third is the value used for 'checked' state. |
3157 | // Usage contexts: | |
3158 | // for mounting an object: printAtomGrid ($data, 'F', 'T') | |
3159 | // for changing rack design: printAtomGrid ($data, 'A', 'F') | |
3160 | // for adding rack problem: printAtomGrid ($data, 'F', 'U') | |
3161 | // for adding object problem: printAtomGrid ($data, 'T', 'W') | |
3162 | ||
3163 | function renderAtomGrid ($data) | |
3164 | { | |
3165 | $rack_id = $data['id']; | |
3166 | for ($unit_no = $data['height']; $unit_no > 0; $unit_no--) | |
3167 | { | |
57c69e9c | 3168 | echo "<tr><th><a href='javascript:;' onclick=\"toggleRowOfAtoms('${rack_id}','${unit_no}')\">${unit_no}</a></th>"; |
e673ee24 DO |
3169 | for ($locidx = 0; $locidx < 3; $locidx++) |
3170 | { | |
57c69e9c |