07c1a819700e2e8ed294063e346b225bad63336d
4 * This file is a library of operation handlers for RackTables.
8 // This function assures that specified argument was passed
9 // and is a number greater than zero.
10 function assertUIntArg ($argname, $allow_zero = FALSE)
12 if (!isset ($_REQUEST[$argname]))
14 showError ("Parameter '${argname}' is missing.", __FUNCTION__
);
17 if (!is_numeric ($_REQUEST[$argname]))
19 showError ("Parameter '${argname}' is not a number.", __FUNCTION__
);
22 if ($_REQUEST[$argname] < 0)
24 showError ("Parameter '${argname}' is less than zero.", __FUNCTION__
);
27 if (!$allow_zero and $_REQUEST[$argname] == 0)
29 showError ("Parameter '${argname}' is equal to zero.", __FUNCTION__
);
34 // This function assures that specified argument was passed
35 // and is a non-empty string.
36 function assertStringArg ($argname, $ok_if_empty = FALSE)
38 if (!isset ($_REQUEST[$argname]))
40 showError ("Parameter '${argname}' is missing.", __FUNCTION__
);
43 if (!is_string ($_REQUEST[$argname]))
45 showError ("Parameter '${argname}' is not a string.", __FUNCTION__
);
48 if (!$ok_if_empty and empty ($_REQUEST[$argname]))
50 showError ("Parameter '${argname}' is an empty string.", __FUNCTION__
);
55 function assertBoolArg ($argname, $ok_if_empty = FALSE)
57 if (!isset ($_REQUEST[$argname]))
59 showError ("Parameter '${argname}' is missing.", __FUNCTION__
);
62 if (!is_string ($_REQUEST[$argname]) or $_REQUEST[$argname] != 'on')
64 showError ("Parameter '${argname}' is not a string.", __FUNCTION__
);
67 if (!$ok_if_empty and empty ($_REQUEST[$argname]))
69 showError ("Parameter '${argname}' is an empty string.", __FUNCTION__
);
74 function assertIPv4Arg ($argname, $ok_if_empty = FALSE)
76 assertStringArg ($argname, $ok_if_empty);
77 if (!empty ($_REQUEST[$argname]) and long2ip (ip2long ($_REQUEST[$argname])) !== $_REQUEST[$argname])
79 showError ("IPv4 address validation failed for value '" . $_REQUEST[$argname] . "'", __FUNCTION__
);
84 function addPortForwarding ()
86 global $root, $pageno, $tabno;
88 assertUIntArg ('object_id');
89 assertIPv4Arg ('localip');
90 assertIPv4Arg ('remoteip');
91 assertUIntArg ('localport');
92 assertUIntArg ('proto');
93 assertStringArg ('description', TRUE);
94 $object_id = $_REQUEST['object_id'];
95 $localip = $_REQUEST['localip'];
96 $remoteip = $_REQUEST['remoteip'];
97 $localport = $_REQUEST['localport'];
98 $remoteport = $_REQUEST['remoteport'];
99 $proto = $_REQUEST['proto'];
100 $description = $_REQUEST['description'];
101 if (empty ($remoteport))
102 $remoteport = $localport;
104 $retpage="${root}?page=${pageno}&tab=${tabno}&object_id=$object_id";
107 $error=newPortForwarding($object_id, $localip, $localport, $remoteip, $remoteport, $proto, $description);
110 return "${retpage}&message=".urlencode('Port forwarding successfully added.');
113 return "${retpage}&error=".urlencode($error);
118 function delPortForwarding ()
120 global $root, $pageno, $tabno;
122 $object_id = $_REQUEST['object_id'];
123 $localip = $_REQUEST['localip'];
124 $remoteip = $_REQUEST['remoteip'];
125 $localport = $_REQUEST['localport'];
126 $remoteport = $_REQUEST['remoteport'];
127 $proto = $_REQUEST['proto'];
129 $retpage="${root}?page=${pageno}&tab=${tabno}&object_id=$object_id";
131 $error=deletePortForwarding($object_id, $localip, $localport, $remoteip, $remoteport, $proto);
133 return "${retpage}&message=".urlencode('Port forwarding successfully deleted.');
136 return "${retpage}&error=".urlencode($error);
141 function updPortForwarding ()
143 global $root, $pageno, $tabno;
145 $object_id = $_REQUEST['object_id'];
146 $localip = $_REQUEST['localip'];
147 $remoteip = $_REQUEST['remoteip'];
148 $localport = $_REQUEST['localport'];
149 $remoteport = $_REQUEST['remoteport'];
150 $proto = $_REQUEST['proto'];
151 $description = $_REQUEST['description'];
153 $retpage="${root}?page=${pageno}&tab=${tabno}&object_id=$object_id";
155 $error=updatePortForwarding($object_id, $localip, $localport, $remoteip, $remoteport, $proto, $description);
157 return "${retpage}&message=".urlencode('Port forwarding successfully updated.');
160 return "${retpage}&error=".urlencode($error);
165 function addPortForObject ()
167 global $root, $pageno, $tabno;
169 $object_id = $_REQUEST['object_id'];
170 $port_name = $_REQUEST['port_name'];
171 $port_l2address = $_REQUEST['port_l2address'];
172 $port_label = $_REQUEST['port_label'];
173 $port_type_id = $_REQUEST['port_type_id'];
176 if ($port_name == '')
177 return "${root}?page=${pageno}&tab=${tabno}&object_id=${object_id}&error=".urlencode('Port name cannot be empty');
180 $error = commitAddPort ($object_id, $port_name, $port_type_id, $port_label, $port_l2address);
183 return "${root}?page=${pageno}&tab=${tabno}&object_id=${object_id}&error=".urlencode($error);
187 return "${root}?page=${pageno}&tab=${tabno}&object_id=${object_id}&message=".urlencode("Port $port_name added successfully");
193 function editPortForObject ()
195 global $root, $pageno, $tabno;
197 assertUIntArg ('port_id');
198 assertUIntArg ('object_id');
199 assertStringArg ('name');
200 $port_id = $_REQUEST['port_id'];
201 $object_id = $_REQUEST['object_id'];
202 $port_name = $_REQUEST['name'];
203 $port_l2address = $_REQUEST['l2address'];
204 $port_label = $_REQUEST['label'];
205 if (isset ($_REQUEST['reservation_comment']) and !empty ($_REQUEST['reservation_comment']))
206 $port_rc = '"' . $_REQUEST['reservation_comment'] . '"';
210 if ($port_name == '')
211 return "${root}?page=${pageno}&tab=${tabno}&object_id=${object_id}&error=".urlencode('Port name cannot be empty');
214 $error = commitUpdatePort ($port_id, $port_name, $port_label, $port_l2address, $port_rc);
217 return "${root}?page=${pageno}&tab=${tabno}&object_id=${object_id}&error=".urlencode($error);
221 return "${root}?page=${pageno}&tab=${tabno}&object_id=${object_id}&message=".urlencode("Port $port_name updated successfully");
227 function delPortFromObject ()
229 global $root, $pageno, $tabno;
231 $port_id = $_REQUEST['port_id'];
232 $port_name = $_REQUEST['port_name'];
233 $object_id = $_REQUEST['object_id'];
234 $error = delObjectPort($port_id);
238 return "${root}?page=${pageno}&tab=${tabno}&object_id=${object_id}&error=".urlencode($error);
242 return "${root}?page=${pageno}&tab=${tabno}&object_id=${object_id}&message=".urlencode("Port $port_name deleted successfully");
246 function linkPortForObject ()
248 global $root, $pageno, $tabno;
250 $port_id = $_REQUEST['port_id'];
251 $remote_port_id = $_REQUEST['remote_port_id'];
252 $object_id = $_REQUEST['object_id'];
253 $port_name = $_REQUEST['port_name'];
254 $remote_port_name = $_REQUEST['remote_port_name'];
255 $remote_object_name = $_REQUEST['remote_object_name'];
257 $error = linkPorts($port_id, $remote_port_id);
260 return "${root}?page=${pageno}&tab=${tabno}&object_id=${object_id}&error=".urlencode($error);
264 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");
268 function unlinkPortForObject ()
270 global $root, $pageno, $tabno;
272 $port_id = $_REQUEST['port_id'];
273 $object_id = $_REQUEST['object_id'];
274 $port_name = $_REQUEST['port_name'];
275 $remote_port_name = $_REQUEST['remote_port_name'];
276 $remote_object_name = $_REQUEST['remote_object_name'];
278 $error = unlinkPort($port_id);
281 return "${root}?page=${pageno}&tab=${tabno}&object_id=${object_id}&error=".urlencode($error);
285 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");
289 function addMultiPorts ()
291 global $root, $pageno, $tabno;
293 assertStringArg ('format');
294 assertStringArg ('input');
295 assertUIntArg ('port_type');
296 assertUIntArg ('object_id');
297 $format = $_REQUEST['format'];
298 $port_type = $_REQUEST['port_type'];
299 $object_id = $_REQUEST['object_id'];
300 // Input lines are escaped, so we have to explode and to chop by 2-char
301 // \n and \r respectively.
302 $lines1 = explode ('\n', $_REQUEST['input']);
303 foreach ($lines1 as $line)
305 $parts = explode ('\r', $line);
307 if (empty ($parts[0]))
310 $lines2[] = rtrim ($parts[0]);
313 foreach ($lines2 as $line)
318 $words = explode (' ', ereg_replace ('[[:space:]]+', ' ', $line));
319 list ($slot, $port) = explode ('/', $words[0]);
322 'name' => "e ${slot}/${port}",
323 'l2address' => $words[8],
324 'label' => "slot ${slot} port ${port}"
328 $words = explode (' ', ereg_replace ('[[:space:]]+', ' ', trim (substr ($line, 3))));
330 How Async Lines are Numbered in Cisco 3600 Series Routers
331 http://www.cisco.com/en/US/products/hw/routers/ps274/products_tech_note09186a00801ca70b.shtml
333 Understanding 16- and 32-Port Async Network Modules
334 http://www.cisco.com/en/US/products/hw/routers/ps274/products_tech_note09186a00800a93f0.shtml
337 $slot = floor (($async - 1) / 32);
338 $octalgroup = floor (($async - 1 - $slot * 32) / 8);
339 $cable = $async - $slot * 32 - $octalgroup * 8;
340 $og_label[0] = 'async 0-7';
341 $og_label[1] = 'async 8-15';
342 $og_label[2] = 'async 16-23';
343 $og_label[3] = 'async 24-31';
346 'name' => "async ${async}",
348 'label' => "slot ${slot} " . $og_label[$octalgroup] . " cable ${cable}"
352 $words = explode (' ', ereg_replace ('[[:space:]]+', ' ', $line));
353 $ifnumber = $words[0] * 1;
356 'name' => "e ${ifnumber}",
357 'l2address' => "${words[8]}",
358 'label' => "${ifnumber}"
362 $words = explode (' ', $line);
363 if (empty ($words[0]) or empty ($words[1]))
368 'l2address' => $words[1],
374 "${root}?page=${pageno}&tab=${tabno}&object_id=${object_id}&error=" .
375 urlencode('Cannot process submitted data: unknown format code.');
379 // Create ports, if they don't exist.
380 $added_count = $updated_count = $error_count = 0;
381 foreach ($ports as $port)
383 $port_id = getPortID ($object_id, $port['name']);
384 if ($port_id === NULL)
386 $result = commitAddPort ($object_id, $port['name'], $port_type, $port['label'], $port['l2address']);
394 $result = commitUpdatePort ($port_id, $port['name'], $port['label'], $port['l2address']);
402 "${root}?page=${pageno}&tab=${tabno}&object_id=${object_id}&message=" .
403 urlencode("Added ${added_count} ports, updated ${updated_count} ports, encountered ${error_count} errors.");
406 function editAddressFromObject ()
410 $ip = $_REQUEST['ip'];
411 $object_id = $_REQUEST['object_id'];
412 $name = $_REQUEST['bond_name'];
413 $type = $_REQUEST['bond_type'];
414 $error = updateBond($ip, $object_id, $name, $type);
417 return "${root}?page=object&tab=network&object_id=$object_id&error=".urlencode($error);
421 return "${root}?page=object&tab=network&object_id=$object_id&message=".urlencode("Interface successfully updated");
425 function delAddressFromObject ()
429 $ip = $_REQUEST['ip'];
430 $object_id = $_REQUEST['object_id'];
431 $error = unbindIpFromObject($ip, $object_id);
434 return "${root}?page=object&tab=network&object_id=$object_id&error=".urlencode($error);
438 return "${root}?page=object&tab=network&object_id=$object_id&message=".urlencode("Interface successfully deleted");
442 function delIpAssignment ()
446 $ip = $_REQUEST['ip'];
447 $object_id = $_REQUEST['object_id'];
448 $error = unbindIpFromObject($ip, $object_id);
451 return "${root}?page=ipaddress&tab=assignment&ip=$ip&error=".urlencode($error);
455 return "${root}?page=ipaddress&tab=assignment&ip=$ip&message=".urlencode("Interface successfully deleted");
459 function editIpAssignment ()
463 $ip = $_REQUEST['ip'];
464 $object_id = $_REQUEST['object_id'];
465 $name = $_REQUEST['bond_name'];
466 $type = $_REQUEST['bond_type'];
467 $error = updateBond($ip, $object_id, $name, $type);
471 return "${root}?page=ipaddress&tab=assignment&ip=$ip&error=".urlencode($error);
475 return "${root}?page=ipaddress&tab=assignment&ip=$ip&message=".urlencode("Interface successfully updated");
479 function addIpAssignment ()
483 $ip = $_REQUEST['ip'];
484 $object_id = $_REQUEST['object_id'];
485 $name = $_REQUEST['bond_name'];
486 $type = $_REQUEST['bond_type'];
487 $error = bindIpToObject($ip, $object_id, $name, $type);
490 return "${root}?page=ipaddress&tab=assignment&ip=$ip&error=".urlencode($error);
494 return "${root}?page=ipaddress&tab=assignment&ip=$ip&message=".urlencode("Interface successfully added");
498 function addNewRange ()
500 global $root, $pageno, $tabno;
501 assertStringArg ('range');
502 assertStringArg ('name');
504 $range = $_REQUEST['range'];
505 $name = $_REQUEST['name'];
506 $is_bcast = isset ($_REQUEST['is_bcast']) ?
$_REQUEST['is_bcast'] : 'off';
507 $taglist = isset ($_REQUEST['taglist']) ?
$_REQUEST['taglist'] : array();
508 $error = addRange($range, $name, $is_bcast == 'on', $taglist);
511 return "${root}?page=${pageno}&tab=${tabno}&error=".urlencode($error);
515 return "${root}?page=${pageno}&tab=${tabno}&message=".urlencode("Range successfully added");
519 function editRange ()
521 global $root, $pageno, $tabno;
523 $id = $_REQUEST['id'];
524 $name = $_REQUEST['name'];
525 $error = updateRange($id, $name);
528 return "${root}?page=${pageno}&tab=${tabno}&id=$id&error=".urlencode($error);
532 return "${root}?page=${pageno}&tab=${tabno}&id=$id&message=".urlencode("Range updated");
539 global $root, $pageno, $tabno;
541 $id = $_REQUEST['id'];
542 $error = commitDeleteRange ($id);
545 return "${root}?page=${pageno}&tab=${tabno}&error=".urlencode($error);
549 return "${root}?page=${pageno}&tab=${tabno}&message=".urlencode("Range deleted");
554 function editAddress ()
556 global $root, $pageno, $tabno;
558 $ip = $_REQUEST['ip'];
559 $name = $_REQUEST['name'];
560 if (isset ($_REQUEST['reserved']))
561 $reserved = $_REQUEST['reserved'];
564 $error = updateAddress($ip, $name, $reserved=='on'?
'yes':'no');
567 return "${root}?page=${pageno}&tab=${tabno}&ip=$ip&error=".urlencode($error);
571 return "${root}?page=${pageno}&tab=${tabno}&ip=$ip&message=".urlencode("Address updated");
576 function addAddressToObject ()
578 global $root, $pageno, $tabno;
580 assertStringArg ('ip');
581 assertUIntArg ('object_id');
582 assertStringArg ('name', TRUE);
583 assertStringArg ('type');
585 $ip = ereg_replace ('/[[:digit:]]+$', '', $_REQUEST['ip']);
586 $object_id = $_REQUEST['object_id'];
587 $error = bindIpToObject($ip, $object_id, $_REQUEST['name'], $_REQUEST['type']);
589 return "${root}?page=${pageno}&tab=${tabno}&object_id=${object_id}&error=".urlencode($error);
591 return "${root}?page=$pageno&tab=${tabno}&object_id=${object_id}&message=".
592 urlencode("Address ${ip} was added successfully.");
595 function createUserAccount ()
597 global $root, $pageno, $tabno;
598 assertStringArg ('username');
599 assertStringArg ('realname', TRUE);
600 assertStringArg ('password');
601 $username = $_REQUEST['username'];
602 $password = hash (PASSWORD_HASH
, $_REQUEST['password']);
603 $result = commitCreateUserAccount ($username, $_REQUEST['realname'], $password);
605 return "${root}?page=${pageno}&tab=${tabno}&message=" . urlencode ("User account ${username} created.");
607 return "${root}?page=${pageno}&tab=${tabno}&error=" . urlencode ("Error creating user account ${username}.");
610 function updateUserAccount ()
612 global $root, $pageno, $tabno;
613 assertUIntArg ('id');
614 assertStringArg ('username');
615 assertStringArg ('realname', TRUE);
616 assertStringArg ('password');
617 // We might be asked to change username, so use user ID only.
618 $id = $_REQUEST['id'];
619 $username = $_REQUEST['username'];
620 $new_password = $_REQUEST['password'];
621 $old_hash = getHashByID ($id);
622 if ($old_hash == NULL)
624 showError ('getHashByID() failed', __FUNCTION__
);
627 // Update user password only if provided password is not the same as current password hash.
628 if ($new_password != $old_hash)
629 $new_password = hash (PASSWORD_HASH
, $new_password);
630 $result = commitUpdateUserAccount ($_REQUEST['id'], $username, $_REQUEST['realname'], $new_password);
632 return "${root}?page=${pageno}&tab=${tabno}&message=" . urlencode ("User account ${username} updated.");
634 return "${root}?page=${pageno}&tab=${tabno}&error=" . urlencode ("Error updating user account ${username}.");
637 function enableUserAccount ()
639 global $root, $pageno, $tabno;
640 assertUIntArg ('id');
641 $id = $_REQUEST['id'];
642 $result = commitEnableUserAccount ($id, 'yes');
644 return "${root}?page=${pageno}&tab=${tabno}&message=" . urlencode ("User account enabled.");
646 return "${root}?page=${pageno}&tab=${tabno}&error=" . urlencode ("Error enabling user account.");
649 function disableUserAccount ()
651 global $root, $pageno, $tabno;
652 assertUIntArg ('id');
653 $id = $_REQUEST['id'];
657 $result = commitEnableUserAccount ($id, 'no');
659 return "${root}?page=${pageno}&tab=${tabno}&message=" . urlencode ("User account disabled.");
661 return "${root}?page=${pageno}&tab=${tabno}&error=" . urlencode ("Error disabling user account.");
664 function revokePermission ()
666 global $root, $pageno, $tabno;
667 assertUIntArg ('access_userid', TRUE);
668 assertStringArg ('access_page');
669 assertStringArg ('access_tab');
670 $result = commitRevokePermission
672 $_REQUEST['access_userid'],
673 $_REQUEST['access_page'],
674 $_REQUEST['access_tab']
677 return "${root}?page=${pageno}&tab=${tabno}&message=" . urlencode ("Revoke successfull.");
679 return "${root}?page=${pageno}&tab=${tabno}&error=" . urlencode ("Error revoking permission.");
682 function grantPermission ()
684 global $root, $pageno, $tabno;
685 assertUIntArg ('access_userid', TRUE);
686 assertStringArg ('access_page');
687 assertStringArg ('access_tab');
688 assertStringArg ('access_value');
689 $result = commitGrantPermission
691 $_REQUEST['access_userid'],
692 $_REQUEST['access_page'],
693 $_REQUEST['access_tab'],
694 $_REQUEST['access_value']
697 return "${root}?page=${pageno}&tab=${tabno}&message=" . urlencode ("Grant successfull.");
699 return "${root}?page=${pageno}&tab=${tabno}&error=" . urlencode ("Error granting permission.");
702 // This function find differences in users's submit and PortCompat table
703 // and modifies database accordingly.
704 function savePortMap ()
706 global $root, $pageno, $tabno;
707 $ptlist = getPortTypes();
708 $oldCompat = getPortCompat();
709 $newCompat = array();
710 foreach (array_keys ($ptlist) as $leftKey)
711 foreach (array_keys ($ptlist) as $rightKey)
712 if (isset ($_REQUEST["atom_${leftKey}_${rightKey}"]))
713 $newCompat[] = array ('type1' => $leftKey, 'type2' => $rightKey);
714 // Build the new matrix from user's submit and compare it to
715 // the old matrix. Those pairs which appear on
716 // new matrix only, have to be stored in PortCompat table. Those who appear
717 // on the old matrix only, should be removed from PortCompat table.
718 // Those present in both matrices should be skipped.
719 $oldCompatTable = buildPortCompatMatrixFromList ($ptlist, $oldCompat);
720 $newCompatTable = buildPortCompatMatrixFromList ($ptlist, $newCompat);
721 $error_count = $success_count = 0;
722 foreach (array_keys ($ptlist) as $type1)
723 foreach (array_keys ($ptlist) as $type2)
724 if ($oldCompatTable[$type1][$type2] != $newCompatTable[$type1][$type2])
725 switch ($oldCompatTable[$type1][$type2])
727 case TRUE: // new value is FALSE
728 if (removePortCompat ($type1, $type2) === TRUE)
733 case FALSE: // new value is TRUE
734 if (addPortCompat ($type1, $type2) === TRUE)
740 showError ('oldCompatTable is invalid', __FUNCTION__
);
744 "${root}?page=${pageno}&tab=${tabno}&" .
745 ($error_count == 0 ?
'message' : 'error') .
746 "=" . urlencode ("${error_count} failures and ${success_count} successfull changes.");
749 function deleteDictWord ()
751 global $root, $pageno, $tabno;
753 "${root}?page=${pageno}&tab=${tabno}&" .
754 "error=" . urlencode ('Dragon ate this word!');
757 function updateDictionary ()
759 global $root, $pageno, $tabno;
760 assertUIntArg ('chapter_no');
761 assertUIntArg ('dict_key');
762 assertStringArg ('dict_value');
763 if (commitUpdateDictionary ($_REQUEST['chapter_no'], $_REQUEST['dict_key'], $_REQUEST['dict_value']) === TRUE)
764 return "${root}?page=${pageno}&tab=${tabno}&message=" . urlencode ('Update succeeded.');
766 return "${root}?page=${pageno}&tab=${tabno}&error=" . urlencode ("Update failed!");
769 function supplementDictionary ()
771 global $root, $pageno, $tabno;
772 assertUIntArg ('chapter_no');
773 assertStringArg ('dict_value');
774 if (commitSupplementDictionary ($_REQUEST['chapter_no'], $_REQUEST['dict_value']) === TRUE)
775 return "${root}?page=${pageno}&tab=${tabno}&message=" . urlencode ('Supplement succeeded.');
777 return "${root}?page=${pageno}&tab=${tabno}&error=" . urlencode ("Supplement failed!");
780 function reduceDictionary ()
782 global $root, $pageno, $tabno;
783 assertUIntArg ('chapter_no');
784 assertUIntArg ('dict_key');
785 if (commitReduceDictionary ($_REQUEST['chapter_no'], $_REQUEST['dict_key']) === TRUE)
786 return "${root}?page=${pageno}&tab=${tabno}&message=" . urlencode ('Reduction succeeded.');
788 return "${root}?page=${pageno}&tab=${tabno}&error=" . urlencode ("Reduction failed!");
791 function addChapter ()
793 global $root, $pageno, $tabno;
794 assertStringArg ('chapter_name');
795 if (commitAddChapter ($_REQUEST['chapter_name']) === TRUE)
796 return "${root}?page=${pageno}&tab=${tabno}&message=" . urlencode ('Chapter was added.');
798 return "${root}?page=${pageno}&tab=${tabno}&error=" . urlencode ('Error adding chapter.');
801 function updateChapter ()
803 global $root, $pageno, $tabno;
804 assertUIntArg ('chapter_no');
805 assertStringArg ('chapter_name');
806 if (commitUpdateChapter ($_REQUEST['chapter_no'], $_REQUEST['chapter_name']) === TRUE)
807 return "${root}?page=${pageno}&tab=${tabno}&message=" . urlencode ('Chapter was updated.');
809 return "${root}?page=${pageno}&tab=${tabno}&error=" . urlencode ('Error updating chapter.');
812 function delChapter ()
814 global $root, $pageno, $tabno;
815 assertUIntArg ('chapter_no');
816 if (commitDeleteChapter ($_REQUEST['chapter_no']))
817 return "${root}?page=${pageno}&tab=${tabno}&message=" . urlencode ('Chapter was deleted.');
819 return "${root}?page=${pageno}&tab=${tabno}&error=" . urlencode ('Error deleting chapter.');
822 function changeAttribute ()
824 global $root, $pageno, $tabno;
825 assertUIntArg ('attr_id');
826 assertStringArg ('attr_name');
827 if (commitUpdateAttribute ($_REQUEST['attr_id'], $_REQUEST['attr_name']))
828 return "${root}?page=${pageno}&tab=${tabno}&message=" . urlencode ('Rename successful.');
830 return "${root}?page=${pageno}&tab=${tabno}&error=" . urlencode ('Error renaming attribute.');
833 function createAttribute ()
835 global $root, $pageno, $tabno;
836 assertStringArg ('attr_name');
837 assertStringArg ('attr_type');
838 if (commitAddAttribute ($_REQUEST['attr_name'], $_REQUEST['attr_type']))
839 return "${root}?page=${pageno}&tab=${tabno}&message=" . urlencode ("Attribute '${_REQUEST['attr_name']}' created.");
841 return "${root}?page=${pageno}&tab=${tabno}&error=" . urlencode ('Error creating attribute.');
844 function deleteAttribute ()
846 global $root, $pageno, $tabno;
847 assertUIntArg ('attr_id');
848 if (commitDeleteAttribute ($_REQUEST['attr_id']))
849 return "${root}?page=${pageno}&tab=${tabno}&message=" . urlencode ('Attribute was deleted.');
851 return "${root}?page=${pageno}&tab=${tabno}&error=" . urlencode ('Error deleting attribute.');
854 function supplementAttrMap ()
856 global $root, $pageno, $tabno;
857 assertUIntArg ('attr_id');
858 assertUIntArg ('objtype_id');
859 assertUIntArg ('chapter_no');
860 if (commitSupplementAttrMap ($_REQUEST['attr_id'], $_REQUEST['objtype_id'], $_REQUEST['chapter_no']) === TRUE)
861 return "${root}?page=${pageno}&tab=${tabno}&message=" . urlencode ('Supplement succeeded.');
863 return "${root}?page=${pageno}&tab=${tabno}&error=" . urlencode ("Supplement failed!");
866 function reduceAttrMap ()
868 global $root, $pageno, $tabno;
869 assertUIntArg ('attr_id');
870 assertUIntArg ('objtype_id');
871 if (commitReduceAttrMap ($_REQUEST['attr_id'], $_REQUEST['objtype_id']) === TRUE)
872 return "${root}?page=${pageno}&tab=${tabno}&message=" . urlencode ('Reduction succeeded.');
874 return "${root}?page=${pageno}&tab=${tabno}&error=" . urlencode ("Reduction failed!");
877 function resetAttrValue ()
879 global $root, $pageno, $tabno;
880 assertUIntArg ('attr_id');
881 assertUIntArg ('object_id');
882 $object_id = $_REQUEST['object_id'];
883 if (commitResetAttrValue ($object_id, $_REQUEST['attr_id']) === TRUE)
884 return "${root}?page=${pageno}&tab=${tabno}&object_id=${object_id}&message=" . urlencode ('Reset succeeded.');
886 return "${root}?page=${pageno}&tab=${tabno}&object_id=${object_id}&error=" . urlencode ("Reset failed!");
889 function updateAttrValues ()
891 global $root, $pageno, $tabno;
892 assertUIntArg ('object_id');
893 $object_id = $_REQUEST['object_id'];
894 $oldvalues = getAttrValues ($object_id);
896 assertUIntArg ('num_attrs');
897 $num_attrs = $_REQUEST['num_attrs'];
900 for ($i = 0; $i < $num_attrs; $i++
)
902 assertUIntArg ("${i}_attr_id");
903 $attr_id = $_REQUEST["${i}_attr_id"];
905 // Field is empty, delete attribute and move on.
906 if (empty($_REQUEST["${i}_value"]))
908 commitResetAttrValue ($object_id, $attr_id);
912 // The value could be uint/float, but we don't know ATM. Let SQL
913 // server check this and complain.
914 assertStringArg ("${i}_value");
915 $value = $_REQUEST["${i}_value"];
916 switch ($oldvalues[$attr_id]['type'])
921 $oldvalue = $oldvalues[$attr_id]['value'];
924 $oldvalue = $oldvalues[$attr_id]['key'];
927 showError ('Internal structure error', __FUNCTION__
);
930 if ($value == $oldvalue)
933 // Note if the queries succeed or not, it determines which page they see.
934 $result[] = commitUpdateAttrValue ($object_id, $attr_id, $value);
937 if (in_array(false, $result))
938 return "${root}?page=${pageno}&tab=${tabno}&object_id=${object_id}&error=" . urlencode ("Update failed!");
940 return "${root}?page=${pageno}&tab=${tabno}&object_id=${object_id}&message=" . urlencode ('Update succeeded.');
943 function useupPort ()
945 global $root, $pageno, $tabno;
946 assertUIntArg ('port_id');
947 assertUIntArg ('object_id');
948 $object_id = $_REQUEST['object_id'];
949 if (commitUseupPort ($_REQUEST['port_id']) === TRUE)
950 return "${root}?page=${pageno}&tab=${tabno}&object_id=${object_id}&message=" . urlencode ('Reservation removed.');
952 return "${root}?page=${pageno}&tab=${tabno}&object_id=${object_id}&error=" . urlencode ("Error removing reservation!");
957 global $root, $pageno, $tabno;
958 $oldvalues = loadConfigCache();
960 assertUIntArg ('num_vars');
961 $num_vars = $_REQUEST['num_vars'];
964 for ($i = 0; $i < $num_vars; $i++
)
966 assertStringArg ("${i}_varname");
967 assertStringArg ("${i}_varvalue", TRUE);
968 $varname = $_REQUEST["${i}_varname"];
969 $varvalue = $_REQUEST["${i}_varvalue"];
971 // If form value = value in DB, don't bother updating DB
972 if ($varvalue == getConfigVar ($varname))
975 // Note if the queries succeed or not, it determines which page they see.
976 $error = setConfigVar ($varname, $varvalue, TRUE);
982 return "${root}?page=${pageno}&tab=${tabno}&error=" . urlencode ("Update failed with error: " . $error);
984 return "${root}?page=${pageno}&tab=${tabno}&message=" . urlencode ("Update succeeded.");
987 function resetUIConfig()
989 global $root, $pageno, $tabno;
990 setConfigVar ('default_port_type','24');
991 setConfigVar ('MASSCOUNT','15');
992 setConfigVar ('MAXSELSIZE','30');
993 setConfigVar ('NAMEFUL_OBJTYPES','4,7,8');
994 setConfigVar ('ROW_SCALE','2');
995 setConfigVar ('PORTS_PER_ROW','12');
996 setConfigVar ('IPV4_ADDRS_PER_PAGE','256');
997 setConfigVar ('DEFAULT_RACK_HEIGHT','42');
998 setConfigVar ('REQUIRE_ASSET_TAG_FOR','4,7,8');
999 setConfigVar ('USER_AUTH_SRC','database');
1000 setConfigVar ('DEFAULT_SLB_VS_PORT','');
1001 setConfigVar ('DEFAULT_SLB_RS_PORT','');
1002 setConfigVar ('IPV4_PERFORMERS','1,4,7,8,12,14,445,447');
1003 setConfigVar ('NATV4_PERFORMERS','4,7,8');
1004 setConfigVar ('DETECT_URLS','no');
1005 setConfigVar ('RACK_PRESELECT_THRESHOLD','1');
1006 setConfigVar ('DEFAULT_IPV4_RS_INSERVICE','no');
1007 setConfigVar ('AUTOPORTS_CONFIG','4 = 1*33*kvm + 2*24*eth%u;15 = 1*446*kvm');
1008 setConfigVar ('SHOW_EXPLICIT_TAGS','yes');
1009 setConfigVar ('SHOW_IMPLICIT_TAGS','yes');
1010 setConfigVar ('SHOW_AUTOMATIC_TAGS','no');
1011 setConfigVar ('DEFAULT_OBJECT_TYPE','4');
1012 return "${root}?page=${pageno}&tab=default&message=" . urlencode ("Reset complete");
1015 // Add single record.
1016 function addRealServer ()
1018 global $root, $pageno, $tabno;
1020 assertUIntArg ('pool_id');
1021 assertIPv4Arg ('remoteip');
1022 assertUIntArg ('rsport');
1023 assertStringArg ('rsconfig', TRUE);
1024 $pool_id = $_REQUEST['pool_id'];
1025 if (!addRStoRSPool ($pool_id, $_REQUEST['remoteip'], $_REQUEST['rsport'], getConfigVar ('DEFAULT_IPV4_RS_INSERVICE'), $_REQUEST['rsconfig']))
1026 return "${root}?page=${pageno}&tab=${tabno}&pool_id=${pool_id}&error=" . urlencode ('addRStoRSPool() failed');
1028 return "${root}?page=${pageno}&tab=${tabno}&pool_id=${pool_id}&message=" . urlencode ("Real server was successfully added");
1031 // Parse textarea submitted and try adding a real server for each line.
1032 function addRealServers ()
1034 global $root, $pageno, $tabno;
1036 assertUIntArg ('id');
1037 assertStringArg ('format');
1038 assertStringArg ('rawtext');
1039 $pool_id = $_REQUEST['id'];
1040 $rawtext = str_replace ('\r', '', $_REQUEST['rawtext']);
1043 // Keep in mind, that the text will have HTML entities (namely '>') escaped.
1044 foreach (explode ('\n', $rawtext) as $line)
1049 switch ($_REQUEST['format'])
1051 case 'ipvs_2': // address and port only
1052 if (!preg_match ('/^ -> ([0-9\.]+):([0-9]+) /', $line, $match))
1054 if (addRStoRSPool ($pool_id, $match[1], $match[2], getConfigVar ('DEFAULT_IPV4_RS_INSERVICE'), ''))
1059 case 'ipvs_3': // address, port and weight
1060 if (!preg_match ('/^ -> ([0-9\.]+):([0-9]+) +[a-zA-Z]+ +([0-9]+) /', $line, $match))
1062 if (addRStoRSPool ($pool_id, $match[1], $match[2], getConfigVar ('DEFAULT_IPV4_RS_INSERVICE'), 'weight ' . $match[3]))
1067 case 'ssv_2': // IP address and port
1068 if (!preg_match ('/^([0-9\.]+) ([0-9]+)$/', $line, $match))
1070 if (addRStoRSPool ($pool_id, $match[1], $match[2], getConfigVar ('DEFAULT_IPV4_RS_INSERVICE'), ''))
1076 return "${root}?page=${pageno}&tab=${tabno}&id=${pool_id}&error=" . urlencode (__FUNCTION__
. ': invalid format requested');
1080 if ($nbad == 0 and $ngood > 0)
1081 return "${root}?page=${pageno}&tab=${tabno}&pool_id=${pool_id}&message=" . urlencode ("Successfully added ${ngood} real servers");
1083 return "${root}?page=${pageno}&tab=${tabno}&pool_id=${pool_id}&error=" . urlencode ("Added ${ngood} real servers and encountered ${nbad} errors");
1086 function addVService ()
1088 global $root, $pageno, $tabno;
1090 assertIPv4Arg ('vip');
1091 assertUIntArg ('vport');
1092 assertStringArg ('proto');
1093 $proto = $_REQUEST['proto'];
1094 if ($proto != 'TCP' and $proto != 'UDP')
1095 return "${root}?page=${pageno}&tab=${tabno}&error=" . urlencode (__FUNCTION__
. ': invalid protocol');
1096 assertStringArg ('name', TRUE);
1097 assertStringArg ('vsconfig', TRUE);
1098 assertStringArg ('rsconfig', TRUE);
1099 $pool_id = $_REQUEST['id'];
1100 if (!commitCreateVS ($_REQUEST['vip'], $_REQUEST['vport'], $proto, $_REQUEST['name'], $_REQUEST['vsconfig'], $_REQUEST['rsconfig']))
1101 return "${root}?page=${pageno}&tab=${tabno}&error=" . urlencode ('commitCreateVS() failed');
1103 return "${root}?page=${pageno}&tab=${tabno}&message=" . urlencode ("Virtual service was successfully created");
1106 function deleteRealServer ()
1108 global $root, $pageno, $tabno;
1110 assertUIntArg ('pool_id');
1111 assertUIntArg ('id');
1112 $pool_id = $_REQUEST['pool_id'];
1113 if (!commitDeleteRS ($_REQUEST['id']))
1114 return "${root}?page=${pageno}&tab=${tabno}&pool_id=${pool_id}&error=" . urlencode ('commitDeleteRS() failed');
1116 return "${root}?page=${pageno}&tab=${tabno}&pool_id=${pool_id}&message=" . urlencode ("Real server was successfully deleted");
1119 function deleteLoadBalancer ()
1121 global $root, $pageno, $tabno;
1123 assertUIntArg ('object_id');
1124 assertUIntArg ('pool_id');
1125 assertUIntArg ('vs_id');
1126 $pool_id = $_REQUEST['pool_id'];
1127 if (!commitDeleteLB ($_REQUEST['object_id'], $pool_id, $_REQUEST['vs_id']))
1128 return "${root}?page=${pageno}&tab=${tabno}&pool_id=${pool_id}&error=" . urlencode ('commitDeleteLB() failed');
1130 return "${root}?page=${pageno}&tab=${tabno}&pool_id=${pool_id}&message=" . urlencode ("Load balancer was successfully deleted");
1133 function deleteVService ()
1135 global $root, $pageno, $tabno;
1137 assertUIntArg ('id');
1138 if (!commitDeleteVS ($_REQUEST['id']))
1139 return "${root}?page=${pageno}&tab=${tabno}&error=" . urlencode ('commitDeleteVS() failed');
1141 return "${root}?page=${pageno}&tab=${tabno}&message=" . urlencode ("Virtual service was successfully deleted");
1144 function updateRealServer ()
1146 global $root, $pageno, $tabno;
1148 assertUIntArg ('id');
1149 assertUIntArg ('rs_id');
1150 assertIPv4Arg ('rsip');
1151 assertUIntArg ('rsport');
1152 assertStringArg ('rsconfig', TRUE);
1153 // only necessary for generating next URL
1154 $pool_id = $_REQUEST['id'];
1155 if (!commitUpdateRS ($_REQUEST['rs_id'], $_REQUEST['rsip'], $_REQUEST['rsport'], $_REQUEST['rsconfig']))
1156 return "${root}?page=${pageno}&tab=${tabno}&pool_id=${pool_id}&error=" . urlencode ('commitUpdateRS() failed');
1158 return "${root}?page=${pageno}&tab=${tabno}&pool_id=${pool_id}&message=" . urlencode ("Real server was successfully updated");
1161 function updateLoadBalancer ()
1163 global $root, $pageno, $tabno;
1165 assertUIntArg ('object_id');
1166 assertUIntArg ('pool_id');
1167 assertUIntArg ('vs_id');
1168 assertStringArg ('vsconfig', TRUE);
1169 assertStringArg ('rsconfig', TRUE);
1170 $pool_id = $_REQUEST['pool_id'];
1171 if (!commitUpdateLB ($_REQUEST['object_id'], $pool_id, $_REQUEST['vs_id'], $_REQUEST['vsconfig'], $_REQUEST['rsconfig']))
1172 return "${root}?page=${pageno}&tab=${tabno}&pool_id=${pool_id}&error=" . urlencode ('commitUpdateLB() failed');
1174 return "${root}?page=${pageno}&tab=${tabno}&pool_id=${pool_id}&message=" . urlencode ("Load balancer info was successfully updated");
1177 function updateVService ()
1179 global $root, $pageno, $tabno;
1181 assertUIntArg ('id');
1182 assertIPv4Arg ('vip');
1183 assertUIntArg ('vport');
1184 assertStringArg ('proto');
1185 assertStringArg ('name', TRUE);
1186 assertStringArg ('vsconfig', TRUE);
1187 assertStringArg ('rsconfig', TRUE);
1188 if (!commitUpdateVS ($_REQUEST['id'], $_REQUEST['vip'], $_REQUEST['vport'], $_REQUEST['proto'], $_REQUEST['name'], $_REQUEST['vsconfig'], $_REQUEST['rsconfig']))
1189 return "${root}?page=${pageno}&tab=${tabno}&error=" . urlencode ('commitUpdateVS() failed');
1191 return "${root}?page=${pageno}&tab=${tabno}&message=" . urlencode ("Virtual service was successfully updated");
1194 function addLoadBalancer ()
1196 global $root, $pageno, $tabno;
1198 assertUIntArg ('pool_id');
1199 assertUIntArg ('object_id');
1200 assertUIntArg ('vs_id');
1201 assertStringArg ('vsconfig', TRUE);
1202 assertStringArg ('rsconfig', TRUE);
1203 $pool_id = $_REQUEST['pool_id'];
1204 if (!addLBtoRSPool ($pool_id, $_REQUEST['object_id'], $_REQUEST['vs_id'], $_REQUEST['vsconfig'], $_REQUEST['rsconfig']))
1205 return "${root}?page=${pageno}&tab=${tabno}&pool_id=${pool_id}&error=" . urlencode ('addLBtoRSPool() failed');
1207 return "${root}?page=${pageno}&tab=${tabno}&pool_id=${pool_id}&message=" . urlencode ("Load balancer was successfully added");
1210 function addRSPool ()
1212 global $root, $pageno, $tabno;
1214 assertStringArg ('name', TRUE);
1215 assertStringArg ('vsconfig', TRUE);
1216 assertStringArg ('rsconfig', TRUE);
1217 if (!commitCreateRSPool ($_REQUEST['name'], $_REQUEST['vsconfig'], $_REQUEST['rsconfig']))
1218 return "${root}?page=${pageno}&tab=${tabno}&error=" . urlencode ('commitCreateRSPool() failed');
1220 return "${root}?page=${pageno}&tab=${tabno}&message=" . urlencode ("Real server pool was successfully created");
1223 function deleteRSPool ()
1225 global $root, $pageno, $tabno;
1227 assertUIntArg ('pool_id');
1228 if (!commitDeleteRSPool ($_REQUEST['pool_id']))
1229 return "${root}?page=${pageno}&tab=${tabno}&error=" . urlencode ('commitDeleteRSPool() failed');
1231 return "${root}?page=${pageno}&tab=${tabno}&message=" . urlencode ("Real server pool was successfully deleted");
1234 function updateRSPool ()
1236 global $root, $pageno, $tabno;
1238 assertUIntArg ('pool_id');
1239 assertStringArg ('name', TRUE);
1240 assertStringArg ('vsconfig', TRUE);
1241 assertStringArg ('rsconfig', TRUE);
1242 if (!commitUpdateRSPool ($_REQUEST['pool_id'], $_REQUEST['name'], $_REQUEST['vsconfig'], $_REQUEST['rsconfig']))
1243 return "${root}?page=${pageno}&tab=${tabno}&error=" . urlencode ('commitUpdateRSPool() failed');
1245 return "${root}?page=${pageno}&tab=${tabno}&message=" . urlencode ("Real server pool was successfully updated");
1248 function updateRSInService ()
1250 global $root, $pageno, $tabno;
1251 assertUIntArg ('pool_id');
1252 assertUIntArg ('rscount');
1253 $pool_id = $_REQUEST['pool_id'];
1254 $orig = getRSPoolInfo ($pool_id);
1256 for ($i = 1; $i <= $_REQUEST['rscount']; $i++
)
1258 $rs_id = $_REQUEST["rsid_${i}"];
1259 if (isset ($_REQUEST["inservice_${i}"]) and $_REQUEST["inservice_${i}"] == 'on')
1263 if ($newval != $orig['rslist'][$rs_id]['inservice'])
1265 if (commitSetInService ($rs_id, $newval))
1272 return "${root}?page=${pageno}&tab=${tabno}&pool_id=${pool_id}&message=" . urlencode ($ngood . " real server(s) were successfully (de)activated");
1274 return "${root}?page=${pageno}&tab=${tabno}&pool_id=${pool_id}&error=" . urlencode ("Encountered ${nbad} errors, (de)activated ${ngood} real servers");
1277 function importPTRData ()
1279 global $root, $pageno, $tabno;
1280 assertUIntArg ('id');
1281 assertUIntArg ('addrcount');
1283 $id = $_REQUEST['id'];
1284 for ($i = 0; $i < $_REQUEST['addrcount']; $i++
)
1286 $inputname = "import_${i}";
1287 if (!isset ($_REQUEST[$inputname]) or $_REQUEST[$inputname] != 'on')
1289 assertIPv4Arg ("addr_${i}");
1290 assertStringArg ("descr_${i}", TRUE);
1291 assertStringArg ("rsvd_${i}");
1292 // Non-existent addresses will not have this argument set in request.
1294 if ($_REQUEST["rsvd_${i}"] == 'yes')
1296 if (updateAddress ($_REQUEST["addr_${i}"], $_REQUEST["descr_${i}"], $rsvd) == '')
1302 return "${root}?page=${pageno}&tab=${tabno}&id=${id}&message=" . urlencode ($ngood . " IP address(es) were successfully updated");
1304 return "${root}?page=${pageno}&tab=${tabno}&id=${id}&error=" . urlencode ("Encountered ${nbad} errors, updated ${ngood} IP address(es)");
1307 function generateAutoPorts ()
1309 global $root, $pageno, $tabno;
1310 assertUIntArg ('object_id');
1311 $object_id = $_REQUEST['object_id'];
1312 $info = getObjectInfo ($object_id);
1313 // Navigate away in case of success, stay at the place otherwise.
1314 if (executeAutoPorts ($object_id, $info['objtype_id']))
1315 return "${root}?page=${pageno}&tab=ports&object_id=${object_id}&message=" . urlencode ('Generation complete');
1317 return "${root}?page=${pageno}&tab=${tabno}&object_id=${object_id}&error=" . urlencode ('executeAutoPorts() failed');
1320 // Filter out implicit tags before storing the new tag set.
1321 function saveEntityTags ($realm, $bypass)
1323 global $root, $pageno, $tabno, $explicit_tags, $implicit_tags;
1324 assertUIntArg ($bypass);
1325 $entity_id = $_REQUEST[$bypass];
1326 // Build a trail from the submitted data, minimize it,
1327 // then wipe existing records and store the new set instead.
1328 wipeTags ($realm, $entity_id);
1329 $newtrail = getExplicitTagsOnly (buildTrailFromIds ($_REQUEST['taglist']));
1330 $n_succeeds = $n_errors = 0;
1331 foreach ($newtrail as $taginfo)
1333 if (useInsertBlade ('TagStorage', array ('target_realm' => "'${realm}'", 'target_id' => $entity_id, 'tag_id' => $taginfo['id'])))
1339 return "${root}?page=${pageno}&tab=${tabno}&${bypass}=${entity_id}&error=" . urlencode ("Replaced trail with ${n_succeeds} tags, but experienced ${n_errors} errors.");
1341 return "${root}?page=${pageno}&tab=${tabno}&${bypass}=${entity_id}&message=" . urlencode ("New trail is ${n_succeeds} tags long");
1344 function saveObjectTags ()
1346 return saveEntityTags ('object', 'object_id');
1349 function saveIPv4PrefixTags ()
1351 return saveEntityTags ('ipv4net', 'id');
1354 function saveRackTags ()
1356 return saveEntityTags ('rack', 'rack_id');
1359 function saveIPv4VSTags ()
1361 return saveEntityTags ('ipv4vs', 'id');
1364 function saveIPv4RSPoolTags ()
1366 return saveEntityTags ('ipv4rspool', 'id');
1369 function destroyTag ()
1371 global $root, $pageno, $tabno;
1372 assertUIntArg ('id');
1373 if (($ret = commitDestroyTag ($_REQUEST['id'])) == '')
1374 return "${root}?page=${pageno}&tab=${tabno}&message=" . urlencode ("Successfully deleted tag.");
1376 return "${root}?page=${pageno}&tab=${tabno}&error=" . urlencode ("Error deleting tag: '${ret}'");
1379 function createTag ()
1381 global $root, $pageno, $tabno;
1382 assertStringArg ('tagname');
1383 assertUIntArg ('parent_id', TRUE);
1384 $tagname = trim ($_REQUEST['tagname']);
1385 if (($parent_id = $_REQUEST['parent_id']) <= 0)
1386 $parent_id = 'NULL';
1387 if (($ret = commitCreateTag ($tagname, $parent_id)) == '')
1388 return "${root}?page=${pageno}&tab=${tabno}&message=" . urlencode ("Created tag '${tagname}'.");
1390 return "${root}?page=${pageno}&tab=${tabno}&error=" . urlencode ("Could not create tag '${tagname}' because of error '${ret}'");