r1640 + initial implementation of Live PTR updating code
[racktables] / inc / ophandlers.php
CommitLineData
b325120a 1<?php
e673ee24
DO
2/*
3*
4* This file is a library of operation handlers for RackTables.
5*
6*/
7
8function addPortForwarding ()
9{
10 global $root, $pageno, $tabno;
11
12 $object_id = $_REQUEST['object_id'];
13 $localip = $_REQUEST['localip'];
14 $remoteip = $_REQUEST['remoteip'];
15 $localport = $_REQUEST['localport'];
16 $remoteport = $_REQUEST['remoteport'];
17 $proto = $_REQUEST['proto'];
18 $mode = $_REQUEST['mode'];
19 $description = $_REQUEST['description'];
31fc4157
DO
20 if (empty ($remoteport))
21 $remoteport = $localport;
e673ee24
DO
22
23 $retpage="${root}?page=${pageno}&tab=${tabno}&object_id=$object_id";
24
25
26 $error=newPortForwarding($object_id, $localip, $localport, $remoteip, $remoteport, $proto, $description);
27
28 if ($error == '')
29 return "${retpage}&message=".urlencode('Port forwarding successfully added.');
30 else
31 {
32 return "${retpage}&error=".urlencode($error);
33 }
34
35}
36
37function delPortForwarding ()
38{
39 global $root, $pageno, $tabno;
40
41 $object_id = $_REQUEST['object_id'];
42 $localip = $_REQUEST['localip'];
43 $remoteip = $_REQUEST['remoteip'];
44 $localport = $_REQUEST['localport'];
45 $remoteport = $_REQUEST['remoteport'];
46 $proto = $_REQUEST['proto'];
47 $mode = $_REQUEST['mode'];
48
49 $retpage="${root}?page=${pageno}&tab=${tabno}&object_id=$object_id";
50
51 $error=deletePortForwarding($object_id, $localip, $localport, $remoteip, $remoteport, $proto);
52 if ($error == '')
53 return "${retpage}&message=".urlencode('Port forwarding successfully deleted.');
54 else
55 {
56 return "${retpage}&error=".urlencode($error);
57 }
58
59}
60
61function updPortForwarding ()
62{
63 global $root, $pageno, $tabno;
64
65 $object_id = $_REQUEST['object_id'];
66 $localip = $_REQUEST['localip'];
67 $remoteip = $_REQUEST['remoteip'];
68 $localport = $_REQUEST['localport'];
69 $remoteport = $_REQUEST['remoteport'];
70 $proto = $_REQUEST['proto'];
71 $description = $_REQUEST['description'];
72
73 $retpage="${root}?page=${pageno}&tab=${tabno}&object_id=$object_id";
74
75 $error=updatePortForwarding($object_id, $localip, $localport, $remoteip, $remoteport, $proto, $description);
76 if ($error == '')
77 return "${retpage}&message=".urlencode('Port forwarding successfully updated.');
78 else
79 {
80 return "${retpage}&error=".urlencode($error);
81 }
82
83}
84
e673ee24
DO
85function addPortForObject ()
86{
87 global $root, $pageno, $tabno;
88
89 $object_id = $_REQUEST['object_id'];
90 $port_name = $_REQUEST['port_name'];
91 $port_l2address = $_REQUEST['port_l2address'];
92 $port_label = $_REQUEST['port_label'];
93 $port_type_id = $_REQUEST['port_type_id'];
94
95
96 if ($port_name == '')
97 return "${root}?page=${pageno}&tab=${tabno}&object_id=${object_id}&error=".urlencode('Port name cannot be empty');
98 else
99 {
100 $error = commitAddPort ($object_id, $port_name, $port_type_id, $port_label, $port_l2address);
101 if ($error != '')
102 {
103 return "${root}?page=${pageno}&tab=${tabno}&object_id=${object_id}&error=".urlencode($error);
104 }
105 else
106 {
107 return "${root}?page=${pageno}&tab=${tabno}&object_id=${object_id}&message=".urlencode("Port $port_name added successfully");
108 }
109 }
110
111}
112
113function editPortForObject ()
114{
115 global $root, $pageno, $tabno;
116
117 assertUIntArg ('port_id');
118 assertUIntArg ('object_id');
119 assertStringArg ('name');
120 $port_id = $_REQUEST['port_id'];
121 $object_id = $_REQUEST['object_id'];
122 $port_name = $_REQUEST['name'];
123 $port_l2address = $_REQUEST['l2address'];
124 $port_label = $_REQUEST['label'];
125 if (isset ($_REQUEST['reservation_comment']) and !empty ($_REQUEST['reservation_comment']))
126 $port_rc = '"' . $_REQUEST['reservation_comment'] . '"';
127 else
128 $port_rc = 'NULL';
129
130 if ($port_name == '')
131 return "${root}?page=${pageno}&tab=${tabno}&object_id=${object_id}&error=".urlencode('Port name cannot be empty');
132 else
133 {
134 $error = commitUpdatePort ($port_id, $port_name, $port_label, $port_l2address, $port_rc);
135 if ($error != '')
136 {
137 return "${root}?page=${pageno}&tab=${tabno}&object_id=${object_id}&error=".urlencode($error);
138 }
139 else
140 {
141 return "${root}?page=${pageno}&tab=${tabno}&object_id=${object_id}&message=".urlencode("Port $port_name updated successfully");
142 }
143 }
144
145}
146
147function delPortFromObject ()
148{
149 global $root, $pageno, $tabno;
150
151 $port_id = $_REQUEST['port_id'];
152 $port_name = $_REQUEST['port_name'];
153 $object_id = $_REQUEST['object_id'];
154 $error = delObjectPort($port_id);
155
156 if ($error != '')
157 {
158 return "${root}?page=${pageno}&tab=${tabno}&object_id=${object_id}&error=".urlencode($error);
159 }
160 else
161 {
162 return "${root}?page=${pageno}&tab=${tabno}&object_id=${object_id}&message=".urlencode("Port $port_name deleted successfully");
163 }
164}
165
166function linkPortForObject ()
167{
168 global $root, $pageno, $tabno;
169
170 $port_id = $_REQUEST['port_id'];
171 $remote_port_id = $_REQUEST['remote_port_id'];
172 $object_id = $_REQUEST['object_id'];
173 $port_name = $_REQUEST['port_name'];
174 $remote_port_name = $_REQUEST['remote_port_name'];
175 $remote_object_name = $_REQUEST['remote_object_name'];
176
177 $error = linkPorts($port_id, $remote_port_id);
178 if ($error != '')
179 {
180 return "${root}?page=${pageno}&tab=${tabno}&object_id=${object_id}&error=".urlencode($error);
181 }
182 else
183 {
184 return "${root}?page=${pageno}&tab=${tabno}&object_id=${object_id}&message=".urlencode("Port $port_name successfully linked with port $remote_port_name at object $remote_object_name");
185 }
186}
187
188function unlinkPortForObject ()
189{
190 global $root, $pageno, $tabno;
191
192 $port_id = $_REQUEST['port_id'];
193 $object_id = $_REQUEST['object_id'];
194 $port_name = $_REQUEST['port_name'];
195 $remote_port_name = $_REQUEST['remote_port_name'];
196 $remote_object_name = $_REQUEST['remote_object_name'];
197
198 $error = unlinkPort($port_id);
199 if ($error != '')
200 {
201 return "${root}?page=${pageno}&tab=${tabno}&object_id=${object_id}&error=".urlencode($error);
202 }
203 else
204 {
205 return "${root}?page=${pageno}&tab=${tabno}&object_id=${object_id}&message=".urlencode("Port $port_name successfully unlinked from port $remote_port_name at object $remote_object_name");
206 }
207}
208
209function addMultiPorts ()
210{
211 global $root, $pageno, $tabno;
212 // Parse data.
213 assertStringArg ('format');
214 assertStringArg ('input');
215 assertUIntArg ('port_type');
216 assertUIntArg ('object_id');
217 $format = $_REQUEST['format'];
218 $port_type = $_REQUEST['port_type'];
219 $object_id = $_REQUEST['object_id'];
220 // Input lines are escaped, so we have to explode and to chop by 2-char
221 // \n and \r respectively.
222 $lines1 = explode ('\n', $_REQUEST['input']);
223 foreach ($lines1 as $line)
224 {
225 $parts = explode ('\r', $line);
226 reset ($parts);
227 if (empty ($parts[0]))
228 continue;
229 else
230 $lines2[] = rtrim ($parts[0]);
231 }
232 $ports = array();
233 foreach ($lines2 as $line)
234 {
235 switch ($format)
236 {
237 case 'fisxii':
238 $words = explode (' ', ereg_replace ('[[:space:]]+', ' ', $line));
239 list ($slot, $port) = explode ('/', $words[0]);
240 $ports[] = array
241 (
242 'name' => "e ${slot}/${port}",
243 'l2address' => $words[8],
244 'label' => "slot ${slot} port ${port}"
245 );
246 break;
247 case 'c3600asy':
248 $words = explode (' ', ereg_replace ('[[:space:]]+', ' ', trim (substr ($line, 3))));
249/*
250How Async Lines are Numbered in Cisco 3600 Series Routers
251http://www.cisco.com/en/US/products/hw/routers/ps274/products_tech_note09186a00801ca70b.shtml
252
253Understanding 16- and 32-Port Async Network Modules
254http://www.cisco.com/en/US/products/hw/routers/ps274/products_tech_note09186a00800a93f0.shtml
255*/
256 $async = $words[0];
257 $slot = floor (($async - 1) / 32);
258 $octalgroup = floor (($async - 1 - $slot * 32) / 8);
259 $cable = $async - $slot * 32 - $octalgroup * 8;
260 $og_label[0] = 'async 0-7';
261 $og_label[1] = 'async 8-15';
262 $og_label[2] = 'async 16-23';
263 $og_label[3] = 'async 24-31';
264 $ports[] = array
265 (
266 'name' => "async ${async}",
267 'l2address' => '',
268 'label' => "slot ${slot} " . $og_label[$octalgroup] . " cable ${cable}"
269 );
270 break;
271 case 'fiwg':
272 $words = explode (' ', ereg_replace ('[[:space:]]+', ' ', $line));
273 $ifnumber = $words[0] * 1;
274 $ports[] = array
275 (
276 'name' => "e ${ifnumber}",
277 'l2address' => "${words[8]}",
278 'label' => "${ifnumber}"
279 );
280 break;
351d4dbf 281 case 'ssv1':
5b585342 282 $words = explode (' ', $line);
351d4dbf
DO
283 if (empty ($words[0]) or empty ($words[1]))
284 continue;
285 $ports[] = array
286 (
287 'name' => $words[0],
288 'l2address' => $words[1],
289 'label' => ''
290 );
291 break;
e673ee24
DO
292 default:
293 return
294 "${root}?page=${pageno}&tab=${tabno}&object_id=${object_id}&error=" .
295 urlencode('Cannot process submitted data: unknown format code.');
296 break;
297 }
298 }
299 // Create ports, if they don't exist.
300 $added_count = $updated_count = $error_count = 0;
301 foreach ($ports as $port)
302 {
303 $port_id = getPortID ($object_id, $port['name']);
304 if ($port_id === NULL)
305 {
306 $result = commitAddPort ($object_id, $port['name'], $port_type, $port['label'], $port['l2address']);
307 if ($result == '')
308 $added_count++;
309 else
310 $error_count++;
311 }
312 else
313 {
314 $result = commitUpdatePort ($port_id, $port['name'], $port['label'], $port['l2address']);
315 if ($result == '')
316 $updated_count++;
317 else
318 $error_count++;
319 }
320 }
321 return
322 "${root}?page=${pageno}&tab=${tabno}&object_id=${object_id}&message=" .
323 urlencode("Added ${added_count} ports, updated ${updated_count} ports, encountered ${error_count} errors.");
324}
325
326function editAddressFromObject ()
327{
328 global $root;
329
330 $ip = $_REQUEST['ip'];
331 $object_id = $_REQUEST['object_id'];
332 $name = $_REQUEST['bond_name'];
333 $type = $_REQUEST['bond_type'];
334 $error = updateBond($ip, $object_id, $name, $type);
335 if ($error != '')
336 {
337 return "${root}?page=object&tab=network&object_id=$object_id&error=".urlencode($error);
338 }
339 else
340 {
341 return "${root}?page=object&tab=network&object_id=$object_id&message=".urlencode("Interface successfully updated");
342 }
343}
344
345function delAddressFromObject ()
346{
347 global $root;
348
349 $ip = $_REQUEST['ip'];
350 $object_id = $_REQUEST['object_id'];
351 $error = unbindIpFromObject($ip, $object_id);
352 if ($error != '')
353 {
354 return "${root}?page=object&tab=network&object_id=$object_id&error=".urlencode($error);
355 }
356 else
357 {
358 return "${root}?page=object&tab=network&object_id=$object_id&message=".urlencode("Interface successfully deleted");
359 }
360}
361
362function delIpAssignment ()
363{
364 global $root;
365
366 $ip = $_REQUEST['ip'];
367 $object_id = $_REQUEST['object_id'];
368 $error = unbindIpFromObject($ip, $object_id);
369 if ($error != '')
370 {
371 return "${root}?page=ipaddress&tab=assignment&ip=$ip&error=".urlencode($error);
372 }
373 else
374 {
375 return "${root}?page=ipaddress&tab=assignment&ip=$ip&message=".urlencode("Interface successfully deleted");
376 }
377}
378
379function editIpAssignment ()
380{
381 global $root;
382
383 $ip = $_REQUEST['ip'];
384 $object_id = $_REQUEST['object_id'];
385 $name = $_REQUEST['bond_name'];
386 $type = $_REQUEST['bond_type'];
387 $error = updateBond($ip, $object_id, $name, $type);
388
389 if ($error != '')
390 {
391 return "${root}?page=ipaddress&tab=assignment&ip=$ip&error=".urlencode($error);
392 }
393 else
394 {
395 return "${root}?page=ipaddress&tab=assignment&ip=$ip&message=".urlencode("Interface successfully updated");
396 }
397}
398
399function addIpAssignment ()
400{
401 global $root;
402
403 $ip = $_REQUEST['ip'];
404 $object_id = $_REQUEST['object_id'];
405 $name = $_REQUEST['bond_name'];
406 $type = $_REQUEST['bond_type'];
407 $error = bindIpToObject($ip, $object_id, $name, $type);
408 if ($error != '')
409 {
410 return "${root}?page=ipaddress&tab=assignment&ip=$ip&error=".urlencode($error);
411 }
412 else
413 {
414 return "${root}?page=ipaddress&tab=assignment&ip=$ip&message=".urlencode("Interface successfully added");
415 }
416}
417
418function addNewRange ()
419{
420 global $root, $pageno, $tabno;
421
2a201216 422 $range = $_REQUEST['range'];
e673ee24 423 $name = $_REQUEST['name'];
2dee289e
DO
424 $is_bcast = $_REQUEST['is_bcast'];
425 $error = addRange($range, $name, $is_bcast == 'on');
e673ee24
DO
426 if ($error != '')
427 {
428 return "${root}?page=${pageno}&tab=${tabno}&error=".urlencode($error);
429 }
430 else
431 {
432 return "${root}?page=${pageno}&tab=${tabno}&message=".urlencode("Range successfully added");
433 }
434}
435
436function editRange ()
437{
438 global $root, $pageno, $tabno;
439
440 $id = $_REQUEST['id'];
441 $name = $_REQUEST['name'];
442 $error = updateRange($id, $name);
443 if ($error != '')
444 {
445 return "${root}?page=${pageno}&tab=${tabno}&id=$id&error=".urlencode($error);
446 }
447 else
448 {
449 return "${root}?page=${pageno}&tab=${tabno}&id=$id&message=".urlencode("Range updated");
450 }
451
452}
453
454function delRange ()
455{
456 global $root, $pageno, $tabno;
457
458 $id = $_REQUEST['id'];
459 $error = commitDeleteRange ($id);
460 if ($error != '')
461 {
462 return "${root}?page=${pageno}&tab=${tabno}&error=".urlencode($error);
463 }
464 else
465 {
466 return "${root}?page=${pageno}&tab=${tabno}&message=".urlencode("Range deleted");
467 }
468
469}
470
471function editAddress ()
472{
473 global $root, $pageno, $tabno;
474
475 $ip = $_REQUEST['ip'];
476 $name = $_REQUEST['name'];
477 if (isset ($_REQUEST['reserved']))
478 $reserved = $_REQUEST['reserved'];
479 else
480 $reserved = 'off';
481 $error = updateAddress($ip, $name, $reserved=='on'?'yes':'no');
482 if ($error != '')
483 {
484 return "${root}?page=${pageno}&tab=${tabno}&ip=$ip&error=".urlencode($error);
485 }
486 else
487 {
488 return "${root}?page=${pageno}&tab=${tabno}&ip=$ip&message=".urlencode("Address updated");
489 }
490
491}
492
493function addAddressToObject ()
494{
495 global $root, $pageno, $tabno;
496
497 $ip = $_REQUEST['ip'];
498 $object_id = $_REQUEST['object_id'];
499 $name = $_REQUEST['name'];
500 $type = $_REQUEST['type'];
501 $error = bindIpToObject($ip, $object_id, $name, $type);
502 if ($error != '')
503 {
504 return "${root}?page=${pageno}&tab=${tabno}&object_id=$object_id&error=".urlencode($error);
505 }
506 else
507 {
508 return "${root}?page=$pageno&tab=${tabno}&object_id=$object_id&message=".urlencode("Interface successfully added");
509 }
510}
511
512function createUserAccount ()
513{
514 global $root, $pageno, $tabno;
515 assertStringArg ('username');
516 assertStringArg ('realname', TRUE);
517 assertStringArg ('password');
518 $username = $_REQUEST['username'];
519 $password = hash (PASSWORD_HASH, $_REQUEST['password']);
520 $result = commitCreateUserAccount ($username, $_REQUEST['realname'], $password);
521 if ($result == TRUE)
522 return "${root}?page=${pageno}&tab=${tabno}&message=" . urlencode ("User account ${username} created.");
523 else
524 return "${root}?page=${pageno}&tab=${tabno}&error=" . urlencode ("Error creating user account ${username}.");
525}
526
527function updateUserAccount ()
528{
529 global $root, $pageno, $tabno;
530 assertUIntArg ('id');
531 assertStringArg ('username');
532 assertStringArg ('realname', TRUE);
533 assertStringArg ('password');
534 // We might be asked to change username, so use user ID only.
535 $id = $_REQUEST['id'];
536 $username = $_REQUEST['username'];
537 $new_password = $_REQUEST['password'];
538 $old_hash = getHashByID ($id);
539 if ($old_hash == NULL)
540 {
61e269b5 541 showError ('getHashByID() failed', __FUNCTION__);
e673ee24
DO
542 return;
543 }
544 // Update user password only if provided password is not the same as current password hash.
545 if ($new_password != $old_hash)
546 $new_password = hash (PASSWORD_HASH, $new_password);
547 $result = commitUpdateUserAccount ($_REQUEST['id'], $username, $_REQUEST['realname'], $new_password);
548 if ($result == TRUE)
549 return "${root}?page=${pageno}&tab=${tabno}&message=" . urlencode ("User account ${username} updated.");
550 else
551 return "${root}?page=${pageno}&tab=${tabno}&error=" . urlencode ("Error updating user account ${username}.");
552}
553
554function enableUserAccount ()
555{
556 global $root, $pageno, $tabno;
557 assertUIntArg ('id');
558 $id = $_REQUEST['id'];
559 $result = commitEnableUserAccount ($id, 'yes');
560 if ($result == TRUE)
561 return "${root}?page=${pageno}&tab=${tabno}&message=" . urlencode ("User account enabled.");
562 else
563 return "${root}?page=${pageno}&tab=${tabno}&error=" . urlencode ("Error enabling user account.");
564}
565
566function disableUserAccount ()
567{
568 global $root, $pageno, $tabno;
569 assertUIntArg ('id');
570 $id = $_REQUEST['id'];
571 if ($id == 1)
572 $result = FALSE;
573 else
574 $result = commitEnableUserAccount ($id, 'no');
575 if ($result == TRUE)
576 return "${root}?page=${pageno}&tab=${tabno}&message=" . urlencode ("User account disabled.");
577 else
578 return "${root}?page=${pageno}&tab=${tabno}&error=" . urlencode ("Error disabling user account.");
579}
580
581function revokePermission ()
582{
583 global $root, $pageno, $tabno;
584 assertUIntArg ('access_userid', TRUE);
585 assertStringArg ('access_page');
586 assertStringArg ('access_tab');
587 $result = commitRevokePermission
588 (
589 $_REQUEST['access_userid'],
590 $_REQUEST['access_page'],
591 $_REQUEST['access_tab']
592 );
593 if ($result == TRUE)
594 return "${root}?page=${pageno}&tab=${tabno}&message=" . urlencode ("Revoke successfull.");
595 else
596 return "${root}?page=${pageno}&tab=${tabno}&error=" . urlencode ("Error revoking permission.");
597}
598
599function grantPermission ()
600{
601 global $root, $pageno, $tabno;
602 assertUIntArg ('access_userid', TRUE);
603 assertStringArg ('access_page');
604 assertStringArg ('access_tab');
605 assertStringArg ('access_value');
606 $result = commitGrantPermission
607 (
608 $_REQUEST['access_userid'],
609 $_REQUEST['access_page'],
610 $_REQUEST['access_tab'],
611 $_REQUEST['access_value']
612 );
613 if ($result == TRUE)
614 return "${root}?page=${pageno}&tab=${tabno}&message=" . urlencode ("Grant successfull.");
615 else
616 return "${root}?page=${pageno}&tab=${tabno}&error=" . urlencode ("Error granting permission.");
617}
618
619// This function find differences in users's submit and PortCompat table
620// and modifies database accordingly.
621function savePortMap ()
622{
623 global $root, $pageno, $tabno;
624 $ptlist = getPortTypes();
625 $oldCompat = getPortCompat();
626 $newCompat = array();
627 foreach (array_keys ($ptlist) as $leftKey)
628 foreach (array_keys ($ptlist) as $rightKey)
629 if (isset ($_REQUEST["atom_${leftKey}_${rightKey}"]))
630 $newCompat[] = array ('type1' => $leftKey, 'type2' => $rightKey);
631 // Build the new matrix from user's submit and compare it to
632 // the old matrix. Those pairs which appear on
633 // new matrix only, have to be stored in PortCompat table. Those who appear
634 // on the old matrix only, should be removed from PortCompat table.
635 // Those present in both matrices should be skipped.
636 $oldCompatTable = buildPortCompatMatrixFromList ($ptlist, $oldCompat);
637 $newCompatTable = buildPortCompatMatrixFromList ($ptlist, $newCompat);
638 $error_count = $success_count = 0;
639 foreach (array_keys ($ptlist) as $type1)
640 foreach (array_keys ($ptlist) as $type2)
641 if ($oldCompatTable[$type1][$type2] != $newCompatTable[$type1][$type2])
642 switch ($oldCompatTable[$type1][$type2])
643 {
644 case TRUE: // new value is FALSE
645 if (removePortCompat ($type1, $type2) === TRUE)
646 $success_count++;
647 else
648 $error_count++;
649 break;
650 case FALSE: // new value is TRUE
651 if (addPortCompat ($type1, $type2) === TRUE)
652 $success_count++;
653 else
654 $error_count++;
655 break;
656 default:
61e269b5 657 showError ('oldCompatTable is invalid', __FUNCTION__);
e673ee24
DO
658 break;
659 }
660 return
661 "${root}?page=${pageno}&tab=${tabno}&" .
662 ($error_count == 0 ? 'message' : 'error') .
663 "=" . urlencode ("${error_count} failures and ${success_count} successfull changes.");
664}
665
666function deleteDictWord ()
667{
668 global $root, $pageno, $tabno;
669 return
670 "${root}?page=${pageno}&tab=${tabno}&" .
671 "error=" . urlencode ('Dragon ate this word!');
672}
673
674function updateDictionary ()
675{
676 global $root, $pageno, $tabno;
677 assertUIntArg ('chapter_no');
678 assertUIntArg ('dict_key');
679 assertStringArg ('dict_value');
680 if (commitUpdateDictionary ($_REQUEST['chapter_no'], $_REQUEST['dict_key'], $_REQUEST['dict_value']) === TRUE)
681 return "${root}?page=${pageno}&tab=${tabno}&message=" . urlencode ('Update succeeded.');
682 else
683 return "${root}?page=${pageno}&tab=${tabno}&error=" . urlencode ("Update failed!");
684}
685
686function supplementDictionary ()
687{
688 global $root, $pageno, $tabno;
689 assertUIntArg ('chapter_no');
690 assertStringArg ('dict_value');
691 if (commitSupplementDictionary ($_REQUEST['chapter_no'], $_REQUEST['dict_value']) === TRUE)
692 return "${root}?page=${pageno}&tab=${tabno}&message=" . urlencode ('Supplement succeeded.');
693 else
694 return "${root}?page=${pageno}&tab=${tabno}&error=" . urlencode ("Supplement failed!");
695}
696
697function reduceDictionary ()
698{
699 global $root, $pageno, $tabno;
700 assertUIntArg ('chapter_no');
701 assertUIntArg ('dict_key');
702 if (commitReduceDictionary ($_REQUEST['chapter_no'], $_REQUEST['dict_key']) === TRUE)
703 return "${root}?page=${pageno}&tab=${tabno}&message=" . urlencode ('Reduction succeeded.');
704 else
705 return "${root}?page=${pageno}&tab=${tabno}&error=" . urlencode ("Reduction failed!");
706}
707
708function addChapter ()
709{
710 global $root, $pageno, $tabno;
711 assertStringArg ('chapter_name');
712 if (commitAddChapter ($_REQUEST['chapter_name']) === TRUE)
713 return "${root}?page=${pageno}&tab=${tabno}&message=" . urlencode ('Chapter was added.');
714 else
715 return "${root}?page=${pageno}&tab=${tabno}&error=" . urlencode ('Error adding chapter.');
716}
717
718function updateChapter ()
719{
720 global $root, $pageno, $tabno;
721 assertUIntArg ('chapter_no');
722 assertStringArg ('chapter_name');
723 if (commitUpdateChapter ($_REQUEST['chapter_no'], $_REQUEST['chapter_name']) === TRUE)
724 return "${root}?page=${pageno}&tab=${tabno}&message=" . urlencode ('Chapter was updated.');
725 else
726 return "${root}?page=${pageno}&tab=${tabno}&error=" . urlencode ('Error updating chapter.');
727}
728
729function delChapter ()
730{
731 global $root, $pageno, $tabno;
732 assertUIntArg ('chapter_no');
733 if (commitDeleteChapter ($_REQUEST['chapter_no']))
734 return "${root}?page=${pageno}&tab=${tabno}&message=" . urlencode ('Chapter was deleted.');
735 else
736 return "${root}?page=${pageno}&tab=${tabno}&error=" . urlencode ('Error deleting chapter.');
737}
738
739function changeAttribute ()
740{
741 global $root, $pageno, $tabno;
742 assertUIntArg ('attr_id');
743 assertStringArg ('attr_name');
744 if (commitUpdateAttribute ($_REQUEST['attr_id'], $_REQUEST['attr_name']))
745 return "${root}?page=${pageno}&tab=${tabno}&message=" . urlencode ('Rename successful.');
746 else
747 return "${root}?page=${pageno}&tab=${tabno}&error=" . urlencode ('Error renaming attribute.');
748}
749
750function createAttribute ()
751{
752 global $root, $pageno, $tabno;
753 assertStringArg ('attr_name');
754 assertStringArg ('attr_type');
755 if (commitAddAttribute ($_REQUEST['attr_name'], $_REQUEST['attr_type']))
756 return "${root}?page=${pageno}&tab=${tabno}&message=" . urlencode ("Attribute '${_REQUEST['attr_name']}' created.");
757 else
758 return "${root}?page=${pageno}&tab=${tabno}&error=" . urlencode ('Error creating attribute.');
759}
760
761function deleteAttribute ()
762{
763 global $root, $pageno, $tabno;
764 assertUIntArg ('attr_id');
765 if (commitDeleteAttribute ($_REQUEST['attr_id']))
766 return "${root}?page=${pageno}&tab=${tabno}&message=" . urlencode ('Attribute was deleted.');
767 else
768 return "${root}?page=${pageno}&tab=${tabno}&error=" . urlencode ('Error deleting attribute.');
769}
770
771function supplementAttrMap ()
772{
773 global $root, $pageno, $tabno;
774 assertUIntArg ('attr_id');
775 assertUIntArg ('objtype_id');
776 assertUIntArg ('chapter_no');
777 if (commitSupplementAttrMap ($_REQUEST['attr_id'], $_REQUEST['objtype_id'], $_REQUEST['chapter_no']) === TRUE)
778 return "${root}?page=${pageno}&tab=${tabno}&message=" . urlencode ('Supplement succeeded.');
779 else
780 return "${root}?page=${pageno}&tab=${tabno}&error=" . urlencode ("Supplement failed!");
781}
782
783function reduceAttrMap ()
784{
785 global $root, $pageno, $tabno;
786 assertUIntArg ('attr_id');
787 assertUIntArg ('objtype_id');
788 if (commitReduceAttrMap ($_REQUEST['attr_id'], $_REQUEST['objtype_id']) === TRUE)
789 return "${root}?page=${pageno}&tab=${tabno}&message=" . urlencode ('Reduction succeeded.');
790 else
791 return "${root}?page=${pageno}&tab=${tabno}&error=" . urlencode ("Reduction failed!");
792}
793
794function resetAttrValue ()
795{
796 global $root, $pageno, $tabno;
797 assertUIntArg ('attr_id');
798 assertUIntArg ('object_id');
799 $object_id = $_REQUEST['object_id'];
800 if (commitResetAttrValue ($object_id, $_REQUEST['attr_id']) === TRUE)
801 return "${root}?page=${pageno}&tab=${tabno}&object_id=${object_id}&message=" . urlencode ('Reset succeeded.');
802 else
803 return "${root}?page=${pageno}&tab=${tabno}&object_id=${object_id}&error=" . urlencode ("Reset failed!");
804}
805
0dfb8a2a 806function updateAttrValues ()
e673ee24
DO
807{
808 global $root, $pageno, $tabno;
e673ee24 809 assertUIntArg ('object_id');
e673ee24 810 $object_id = $_REQUEST['object_id'];
0dfb8a2a
DO
811 $oldvalues = getAttrValues ($object_id);
812
813 assertUIntArg ('num_attrs');
814 $num_attrs = $_REQUEST['num_attrs'];
815 $result = array();
816
817 for ($i = 0; $i < $num_attrs; $i++)
818 {
819 assertUIntArg ("${i}_attr_id");
820 $attr_id = $_REQUEST["${i}_attr_id"];
821
822 // Field is empty, delete attribute and move on.
823 if (empty($_REQUEST["${i}_value"]))
824 {
825 commitResetAttrValue ($object_id, $attr_id);
826 continue;
827 }
828
829 // The value could be uint/float, but we don't know ATM. Let SQL
830 // server check this and complain.
831 assertStringArg ("${i}_value");
832 $value = $_REQUEST["${i}_value"];
833 switch ($oldvalues[$attr_id]['type'])
834 {
835 case 'uint':
836 case 'float':
837 case 'string':
838 $oldvalue = $oldvalues[$attr_id]['value'];
839 break;
840 case 'dict':
841 $oldvalue = $oldvalues[$attr_id]['key'];
842 break;
843 default:
61e269b5 844 showError ('Internal structure error', __FUNCTION__);
0dfb8a2a
DO
845 die;
846 }
847 if ($value == $oldvalue)
848 continue;
849
850 // Note if the queries succeed or not, it determines which page they see.
851 $result[] = commitUpdateAttrValue ($object_id, $attr_id, $value);
852 }
853
854 if (in_array(false, $result))
e673ee24 855 return "${root}?page=${pageno}&tab=${tabno}&object_id=${object_id}&error=" . urlencode ("Update failed!");
0dfb8a2a
DO
856
857 return "${root}?page=${pageno}&tab=${tabno}&object_id=${object_id}&message=" . urlencode ('Update succeeded.');
e673ee24
DO
858}
859
860function useupPort ()
861{
862 global $root, $pageno, $tabno;
863 assertUIntArg ('port_id');
864 assertUIntArg ('object_id');
865 $object_id = $_REQUEST['object_id'];
866 if (commitUseupPort ($_REQUEST['port_id']) === TRUE)
867 return "${root}?page=${pageno}&tab=${tabno}&object_id=${object_id}&message=" . urlencode ('Reservation removed.');
868 else
869 return "${root}?page=${pageno}&tab=${tabno}&object_id=${object_id}&error=" . urlencode ("Error removing reservation!");
870}
871
4fe32e78
DY
872function updateUI ()
873{
c461c579 874 global $root, $pageno, $tabno;
4fe32e78
DY
875 $oldvalues = loadConfigCache();
876
877 assertUIntArg ('num_vars');
878 $num_vars = $_REQUEST['num_vars'];
c461c579 879 $error = '';
4fe32e78
DY
880
881 for ($i = 0; $i < $num_vars; $i++)
882 {
883 assertStringArg ("${i}_varname");
1f464cff 884 assertStringArg ("${i}_varvalue", TRUE);
4fe32e78 885 $varname = $_REQUEST["${i}_varname"];
4fe32e78 886 $varvalue = $_REQUEST["${i}_varvalue"];
4fe32e78 887
c461c579
DO
888 // If form value = value in DB, don't bother updating DB
889 if ($varvalue == getConfigVar ($varname))
4fe32e78
DY
890 continue;
891
892 // Note if the queries succeed or not, it determines which page they see.
c461c579
DO
893 $error = setConfigVar ($varname, $varvalue, TRUE);
894 if (!empty ($error))
895 break;
4fe32e78
DY
896 }
897
c461c579
DO
898 if ($error != '')
899 return "${root}?page=${pageno}&tab=${tabno}&error=" . urlencode ("Update failed with error: " . $error);
4fe32e78 900
c461c579 901 return "${root}?page=${pageno}&tab=${tabno}&message=" . urlencode ("Update succeeded.");
4fe32e78
DY
902}
903
b07f617c
DO
904function resetUIConfig()
905{
6c12ef9b 906 global $root, $pageno, $tabno;
1f86e996 907 setConfigVar ('default_port_type','24');
b07f617c
DO
908 setConfigVar ('MASSCOUNT','15');
909 setConfigVar ('MAXSELSIZE','30');
910 setConfigVar ('NAMEFUL_OBJTYPES','4,7,8');
911 setConfigVar ('ROW_SCALE','2');
912 setConfigVar ('PORTS_PER_ROW','12');
913 setConfigVar ('IPV4_ADDRS_PER_PAGE','256');
914 setConfigVar ('DEFAULT_RACK_HEIGHT','42');
a6305acc 915 setConfigVar ('REQUIRE_ASSET_TAG_FOR','4,7,8');
b5ce46aa
DO
916 setConfigVar ('USER_AUTH_SRC','database');
917 setConfigVar ('DEFAULT_SLB_VS_PORT','');
918 setConfigVar ('DEFAULT_SLB_RS_PORT','');
919 setConfigVar ('IPV4_PERFORMERS','1,4,7,8,12,14');
920 setConfigVar ('NATV4_PERFORMERS','4,7,8');
72281138 921 setConfigVar ('DETECT_URLS','no');
6c12ef9b 922 return "${root}?page=${pageno}&tab=default&message=" . urlencode ("Reset complete");
b07f617c
DO
923}
924
732e4578 925// Add single record.
ca461127
DO
926function addRealServer ()
927{
928 global $root, $pageno, $tabno;
929
930 assertUIntArg ('id');
d6517a21 931 assertIPv4Arg ('rsip');
ca461127
DO
932 assertUIntArg ('rsport');
933 assertStringArg ('rsconfig', TRUE);
934 $pool_id = $_REQUEST['id'];
d6517a21
DO
935 if (!addRStoRSPool ($pool_id, $_REQUEST['rsip'], $_REQUEST['rsport'], $_REQUEST['rsconfig']))
936 return "${root}?page=${pageno}&tab=${tabno}&id=${pool_id}&error=" . urlencode ('addRStoRSPool() failed');
937 else
938 return "${root}?page=${pageno}&tab=${tabno}&id=${pool_id}&message=" . urlencode ("Real server was successfully added");
939}
940
732e4578
DO
941// Parse textarea submitted and try adding a real server for each line.
942function addRealServers ()
943{
944 global $root, $pageno, $tabno;
945
946 assertUIntArg ('id');
947 assertStringArg ('format');
948 assertStringArg ('rawtext');
949 $pool_id = $_REQUEST['id'];
950 $rawtext = str_replace ('\r', '', $_REQUEST['rawtext']);
951 $ngood = $nbad = 0;
952 $rsconfig = '';
953 // Keep in mind, that the text will have HTML entities (namely '>') escaped.
954 foreach (explode ('\n', $rawtext) as $line)
955 {
956 if (empty ($line))
957 continue;
958 $match = array ();
959 switch ($_REQUEST['format'])
960 {
961 case 'ipvs_2': // address and port only
962 if (!preg_match ('/^ -&gt; ([0-9\.]+):([0-9]+) /', $line, $match))
963 continue;
964 if (addRStoRSPool ($pool_id, $match[1], $match[2], ''))
965 $ngood++;
966 else
967 $nbad++;
968 break;
969 case 'ipvs_3': // address, port and weight
970 if (!preg_match ('/^ -&gt; ([0-9\.]+):([0-9]+) +[a-zA-Z]+ +([0-9]+) /', $line, $match))
971 continue;
972 if (addRStoRSPool ($pool_id, $match[1], $match[2], 'weight ' . $match[3]))
973 $ngood++;
974 else
975 $nbad++;
976 break;
977 default:
978 return "${root}?page=${pageno}&tab=${tabno}&id=${pool_id}&error=" . urlencode (__FUNCTION__ . ': invalid format requested');
979 break;
980 }
981 }
982 if ($nbad == 0 and $ngood > 0)
983 return "${root}?page=${pageno}&tab=${tabno}&id=${pool_id}&message=" . urlencode ("Successfully added ${ngood} real servers");
984 else
985 return "${root}?page=${pageno}&tab=${tabno}&id=${pool_id}&error=" . urlencode ("Added ${ngood} real servers and encountered ${nbad} errors");
986}
987
d6517a21
DO
988function addVService ()
989{
990 global $root, $pageno, $tabno;
991
992 assertIPv4Arg ('vip');
993 assertUIntArg ('vport');
994 assertStringArg ('proto');
995 $proto = $_REQUEST['proto'];
996 if ($proto != 'TCP' and $proto != 'UDP')
997 return "${root}?page=${pageno}&tab=${tabno}&error=" . urlencode (__FUNCTION__ . ': invalid protocol');
998 assertStringArg ('name', TRUE);
999 assertStringArg ('vsconfig', TRUE);
1000 assertStringArg ('rsconfig', TRUE);
1001 $pool_id = $_REQUEST['id'];
1002 if (!commitCreateVS ($_REQUEST['vip'], $_REQUEST['vport'], $proto, $_REQUEST['name'], $_REQUEST['vsconfig'], $_REQUEST['rsconfig']))
1003 return "${root}?page=${pageno}&tab=${tabno}&error=" . urlencode ('commitCreateVS() failed');
ca461127 1004 else
d6517a21 1005 return "${root}?page=${pageno}&tab=${tabno}&message=" . urlencode ("Virtual service was successfully created");
fb1c4a54
DO
1006}
1007
1008function deleteRealServer ()
1009{
1010 global $root, $pageno, $tabno;
1011
1012 assertUIntArg ('pool_id');
1013 assertUIntArg ('id');
fb1c4a54 1014 $pool_id = $_REQUEST['pool_id'];
d6517a21
DO
1015 if (!commitDeleteRS ($_REQUEST['id']))
1016 return "${root}?page=${pageno}&tab=${tabno}&id=${pool_id}&error=" . urlencode ('commitDeleteRS() failed');
fb1c4a54 1017 else
d6517a21 1018 return "${root}?page=${pageno}&tab=${tabno}&id=${pool_id}&message=" . urlencode ("Real server was successfully deleted");
fb1c4a54
DO
1019}
1020
3241551e
DO
1021function deleteLoadBalancer ()
1022{
1023 global $root, $pageno, $tabno;
1024
1025 assertUIntArg ('object_id');
1026 assertUIntArg ('pool_id');
c4d85fd1 1027 assertUIntArg ('vs_id');
3241551e 1028 $pool_id = $_REQUEST['pool_id'];
c4d85fd1 1029 if (!commitDeleteLB ($_REQUEST['object_id'], $pool_id, $_REQUEST['vs_id']))
d6517a21
DO
1030 return "${root}?page=${pageno}&tab=${tabno}&id=${pool_id}&error=" . urlencode ('commitDeleteLB() failed');
1031 else
1032 return "${root}?page=${pageno}&tab=${tabno}&id=${pool_id}&message=" . urlencode ("Load balancer was successfully deleted");
1033}
1034
1035function deleteVService ()
1036{
1037 global $root, $pageno, $tabno;
1038
1039 assertUIntArg ('id');
1040 if (!commitDeleteVS ($_REQUEST['id']))
1041 return "${root}?page=${pageno}&tab=${tabno}&error=" . urlencode ('commitDeleteVS() failed');
3241551e 1042 else
d6517a21 1043 return "${root}?page=${pageno}&tab=${tabno}&message=" . urlencode ("Virtual service was successfully deleted");
3241551e
DO
1044}
1045
fb1c4a54
DO
1046function updateRealServer ()
1047{
1048 global $root, $pageno, $tabno;
1049
1050 assertUIntArg ('id');
732e4578 1051 assertUIntArg ('rs_id');
d6517a21 1052 assertIPv4Arg ('rsip');
fb1c4a54
DO
1053 assertUIntArg ('rsport');
1054 assertStringArg ('rsconfig', TRUE);
3241551e 1055 // only necessary for generating next URL
732e4578
DO
1056 $pool_id = $_REQUEST['id'];
1057 if (!commitUpdateRS ($_REQUEST['rs_id'], $_REQUEST['rsip'], $_REQUEST['rsport'], $_REQUEST['rsconfig']))
d6517a21 1058 return "${root}?page=${pageno}&tab=${tabno}&id=${pool_id}&error=" . urlencode ('commitUpdateRS() failed');
fb1c4a54 1059 else
d6517a21 1060 return "${root}?page=${pageno}&tab=${tabno}&id=${pool_id}&message=" . urlencode ("Real server was successfully updated");
ca461127
DO
1061}
1062
c1ca768c 1063function updateLoadBalancer ()
3241551e
DO
1064{
1065 global $root, $pageno, $tabno;
1066
1067 assertUIntArg ('object_id');
1068 assertUIntArg ('pool_id');
c1ca768c 1069 assertUIntArg ('vs_id');
3241551e
DO
1070 assertStringArg ('vsconfig', TRUE);
1071 assertStringArg ('rsconfig', TRUE);
1072 $pool_id = $_REQUEST['pool_id'];
c1ca768c 1073 if (!commitUpdateLB ($_REQUEST['object_id'], $pool_id, $_REQUEST['vs_id'], $_REQUEST['vsconfig'], $_REQUEST['rsconfig']))
d6517a21
DO
1074 return "${root}?page=${pageno}&tab=${tabno}&id=${pool_id}&error=" . urlencode ('commitUpdateLB() failed');
1075 else
28928596 1076 return "${root}?page=${pageno}&tab=${tabno}&id=${pool_id}&message=" . urlencode ("Load balancer info was successfully updated");
d6517a21
DO
1077}
1078
1079function updateVService ()
1080{
1081 global $root, $pageno, $tabno;
1082
1083 assertUIntArg ('id');
1084 assertIPv4Arg ('vip');
1085 assertUIntArg ('vport');
1086 assertStringArg ('proto');
1087 assertStringArg ('name', TRUE);
1088 assertStringArg ('vsconfig', TRUE);
1089 assertStringArg ('rsconfig', TRUE);
1090 if (!commitUpdateVS ($_REQUEST['id'], $_REQUEST['vip'], $_REQUEST['vport'], $_REQUEST['proto'], $_REQUEST['name'], $_REQUEST['vsconfig'], $_REQUEST['rsconfig']))
1091 return "${root}?page=${pageno}&tab=${tabno}&error=" . urlencode ('commitUpdateVS() failed');
3241551e 1092 else
d6517a21 1093 return "${root}?page=${pageno}&tab=${tabno}&message=" . urlencode ("Virtual service was successfully updated");
3241551e
DO
1094}
1095
1096function addLoadBalancer ()
1097{
1098 global $root, $pageno, $tabno;
1099
1100 assertUIntArg ('pool_id');
1101 assertUIntArg ('object_id');
c1ca768c 1102 assertUIntArg ('vs_id');
3241551e
DO
1103 assertStringArg ('vsconfig', TRUE);
1104 assertStringArg ('rsconfig', TRUE);
1105 $pool_id = $_REQUEST['pool_id'];
c1ca768c 1106 if (!addLBtoRSPool ($pool_id, $_REQUEST['object_id'], $_REQUEST['vs_id'], $_REQUEST['vsconfig'], $_REQUEST['rsconfig']))
d6517a21 1107 return "${root}?page=${pageno}&tab=${tabno}&id=${pool_id}&error=" . urlencode ('addLBtoRSPool() failed');
3241551e 1108 else
d6517a21 1109 return "${root}?page=${pageno}&tab=${tabno}&id=${pool_id}&message=" . urlencode ("Load balancer was successfully added");
3241551e
DO
1110}
1111
5ad76f01
DO
1112function addRSPool ()
1113{
1114 global $root, $pageno, $tabno;
1115
5ad76f01
DO
1116 assertStringArg ('name', TRUE);
1117 assertStringArg ('vsconfig', TRUE);
1118 assertStringArg ('rsconfig', TRUE);
70c24883 1119 if (!commitCreateRSPool ($_REQUEST['name'], $_REQUEST['vsconfig'], $_REQUEST['rsconfig']))
5ad76f01
DO
1120 return "${root}?page=${pageno}&tab=${tabno}&error=" . urlencode ('commitCreateRSPool() failed');
1121 else
1122 return "${root}?page=${pageno}&tab=${tabno}&message=" . urlencode ("Real server pool was successfully created");
1123}
1124
1125function deleteRSPool ()
1126{
1127 global $root, $pageno, $tabno;
1128
1129 assertUIntArg ('id');
1130 if (!commitDeleteRSPool ($_REQUEST['id']))
1131 return "${root}?page=${pageno}&tab=${tabno}&error=" . urlencode ('commitDeleteRSPool() failed');
1132 else
1133 return "${root}?page=${pageno}&tab=${tabno}&message=" . urlencode ("Real server pool was successfully deleted");
1134}
1135
1136function updateRSPool ()
1137{
1138 global $root, $pageno, $tabno;
1139
1140 assertUIntArg ('id');
1141 assertStringArg ('name', TRUE);
1142 assertStringArg ('vsconfig', TRUE);
1143 assertStringArg ('rsconfig', TRUE);
1144 if (!commitUpdateRSPool ($_REQUEST['id'], $_REQUEST['name'], $_REQUEST['vsconfig'], $_REQUEST['rsconfig']))
1145 return "${root}?page=${pageno}&tab=${tabno}&error=" . urlencode ('commitUpdateRSPool() failed');
1146 else
1147 return "${root}?page=${pageno}&tab=${tabno}&message=" . urlencode ("Real server pool was successfully updated");
1148}
1149
1f7d18fa
DO
1150function updateRSInService ()
1151{
1152 global $root, $pageno, $tabno;
1153 assertUIntArg ('id');
1154 assertUIntArg ('rscount');
1155 $pool_id = $_REQUEST['id'];
1156 $orig = getRSPoolInfo ($pool_id);
1157 $nbad = $ngood = 0;
1158 for ($i = 1; $i <= $_REQUEST['rscount']; $i++)
1159 {
1160 $rs_id = $_REQUEST["rsid_${i}"];
1161 if (isset ($_REQUEST["inservice_${i}"]) and $_REQUEST["inservice_${i}"] == 'on')
1162 $newval = 'yes';
1163 else
1164 $newval = 'no';
1165 if ($newval != $orig['rslist'][$rs_id]['inservice'])
1166 {
1167 if (commitSetInService ($rs_id, $newval))
1168 $ngood++;
1169 else
1170 $nbad++;
1171 }
1172 }
1173 if (!$nbad)
1174 return "${root}?page=${pageno}&tab=${tabno}&id=${pool_id}&message=" . urlencode ($ngood . " real server(s) were successfully (de)activated");
1175 else
1176 return "${root}?page=${pageno}&tab=${tabno}&id=${pool_id}&error=" . urlencode ("Encountered ${nbad} errors, (de)activated ${ngood} real servers");
1177}
1178
03eb5209
DO
1179function importPTRData ()
1180{
1181 global $root, $pageno, $tabno;
1182 assertUIntArg ('id');
1183 assertUIntArg ('addrcount');
1184 $nbad = $ngood = 0;
1185 $id = $_REQUEST['id'];
1186 for ($i = 0; $i < $_REQUEST['addrcount']; $i++)
1187 {
1188 $inputname = "import_${idx}";
1189 if (!isset ($_REQUEST[$inputname]) or $_REQUEST[$inputname] != 'on')
1190 continue;
1191 assertIPv4Arg ("addr_${i}");
1192 assertStringArg ("descr_${i}");
1193 assertStringArg ("rsvd_${i}");
1194 if ($_REQUEST["rsvd_${i}"] == 'yes')
1195 $rsvd = 'yes';
1196 else
1197 $rsvd = 'no';
1198 if (commitUpdateAddress ($_REQUEST["addr_${i}"], $_REQUEST["descr_${i}"], $rsvd) == '')
1199 $ngood++;
1200 else
1201 $nbad++;
1202 }
1203 if (!$nbad)
1204 return "${root}?page=${pageno}&tab=${tabno}&id=${id}&message=" . urlencode ($ngood . " IP addresse(s) were successfully updated");
1205 else
1206 return "${root}?page=${pageno}&tab=${tabno}&id=${id}&error=" . urlencode ("Encountered ${nbad} errors, updated ${ngood} IP addresses");
1207}
1208
e673ee24 1209?>