r2072 + more changes to make compact URLs work
authorDenis Ovsienko <infrastation@yandex.ru>
Tue, 22 Jul 2008 17:13:06 +0000 (17:13 +0000)
committerDenis Ovsienko <infrastation@yandex.ru>
Tue, 22 Jul 2008 17:13:06 +0000 (17:13 +0000)
ChangeLog
inc/functions.php
inc/interface.php
inc/navigation.php
inc/ophandlers.php

index f3f4825faa36c9345e14341ee993d4622a224de5..dfd78f8524e2513dc4e996ff49bf8bc131dbf614 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -3,6 +3,7 @@
        new feature: cache RackCode parse tree for better performance
        bugfix: don't escape Greek letters to enable them in tag names
        bugfix: port manager messages were incorrect
+       bugfix: shorten URLs to enable longer message logs
        update: adjusted database for bigger texts
        update: better "origin" highlighting for browsing
        update: merged Petr Kohts' highlight patch
index 4e4cff3f4e7bdc0a919270b221d3cad294bf58ba..01fc9b41676b8b59fc02736d9b2ffda7e4d18586 100644 (file)
@@ -1584,24 +1584,19 @@ function buildWideRedirectURL ($log, $nextpage = NULL, $nexttab = NULL)
        return $url;
 }
 
-function buildRedirectURL_OK ($args = array(), $nextpage = NULL, $nexttab = NULL)
+function buildRedirectURL ($status, $args = array(), $nextpage = NULL, $nexttab = NULL)
 {
        global $msgcode, $pageno, $tabno, $op;
        if ($nextpage === NULL)
                $nextpage = $pageno;
        if ($nexttab === NULL)
                $nexttab = $tabno;
-       $code = $msgcode[$pageno][$tabno][$op]['OK'];
+       $code = $msgcode[$pageno][$tabno][$op][$status];
        $log = array ('v' => 2);
        $log['m'][] = count ($args) ? array ('c' => $code, 'a' => $args) : array ('c' => $code);
        return buildWideRedirectURL ($log, $nextpage, $nexttab);
 }
 
-function buildRedirectURL_ERR ($text, $nextpage = NULL, $nexttab = NULL)
-{
-       return buildWideRedirectURL (array (array ('code' => 'error', 'message' => $text)), $nextpage, $nexttab);
-}
-
 function validTagName ($s, $allow_autotag = FALSE)
 {
        if (1 == mb_ereg (TAGNAME_REGEXP, $s))
index b6d989c3f8899b89bc8dc7d744f8c482813a9744..e3bc1a6bd80879f564d0b5ec3fb54776f6d54f85 100644 (file)
@@ -1253,13 +1253,15 @@ function printLog ($log)
        switch (TRUE)
        {
                case !isset ($log['v']):
+               case $log['v'] == 1:
                        foreach ($log as $key => $record)
-                               if ($key != 'v')
+                               if ($key !== 'v')
                                        echo "<div class=msg_${record['code']}>${record['message']}</div>";
                        break;
                case $log['v'] == 2:
                        $msginfo = array
                        (
+                               0 => array ('code' => 'success', 'format' => 'Success: %s'),
                                1 => array ('code' => 'success', 'format' => '%u new records done, %u already existed'),
                                2 => array ('code' => 'success', 'format' => 'NATv4 rule was successfully added.'),
                                3 => array ('code' => 'success', 'format' => 'NATv4 rule was successfully deleted.'),
@@ -1320,7 +1322,64 @@ function printLog ($log)
                                58 => array ('code' => 'success', 'format' => "Successfully deleted tag ."),
                                59 => array ('code' => 'success', 'format' => "Created tag '%s'."),
                                60 => array ('code' => 'success', 'format' => "Updated tag '%s'."),
-                               61 => array ('code' => 'success', 'format' => 'Password changed successfully.')
+                               61 => array ('code' => 'success', 'format' => 'Password changed successfully.'),
+                               100 => array ('code' => 'error', 'format' => 'Generic error: %s'),
+                               101 => array ('code' => 'error', 'format' => 'Port name cannot be empty'),
+                               102 => array ('code' => 'error', 'format' => "Error creating user account '%s'"),
+                               103 => array ('code' => 'error', 'format' => 'getHashByID() failed'),
+                               104 => array ('code' => 'error', 'format' => "Error updating user account '%s'"),
+                               105 => array ('code' => 'error', 'format' => 'Error enabling user account.'),
+                               106 => array ('code' => 'error', 'format' => 'Error disabling user account.'),
+                               107 => array ('code' => 'error', 'format' => 'Admin account cannot be disabled'),
+                               108 => array ('code' => 'error', 'format' => '%u failures and %u successfull changes.'),
+                               109 => array ('code' => 'error', 'format' => 'Update failed!'),
+                               110 => array ('code' => 'error', 'format' => 'Supplement failed!'),
+                               111 => array ('code' => 'error', 'format' => 'Reduction failed!'),
+                               112 => array ('code' => 'error', 'format' => 'Error adding chapter.'),
+                               113 => array ('code' => 'error', 'format' => 'Error updating chapter.'),
+                               114 => array ('code' => 'error', 'format' => 'Error deleting chapter.'),
+                               115 => array ('code' => 'error', 'format' => 'Error renaming attribute.'),
+                               116 => array ('code' => 'error', 'format' => 'Error creating attribute.'),
+                               117 => array ('code' => 'error', 'format' => 'Error deleting attribute.'),
+                               118 => array ('code' => 'error', 'format' => 'Supplement failed!'),
+                               119 => array ('code' => 'error', 'format' => 'Reduction failed!'),
+                               120 => array ('code' => 'error', 'format' => 'Reset failed!'),
+                               121 => array ('code' => 'error', 'format' => 'commitUpdateObject() failed'),
+                               122 => array ('code' => 'error', 'format' => 'One or more update(s) failed!'),
+                               123 => array ('code' => 'error', 'format' => 'Cannot process submitted data: unknown format code.'),
+                               124 => array ('code' => 'error', 'format' => 'Error removing reservation!'),
+                               125 => array ('code' => 'error', 'format' => "Update failed with error: '%s'"),
+                               126 => array ('code' => 'error', 'format' => 'addRStoRSPool() failed'),
+                               127 => array ('code' => 'error', 'format' => 'Added %u real servers and encountered %u errors'),
+                               128 => array ('code' => 'error', 'format' => 'commitDeleteRS() failed'),
+                               129 => array ('code' => 'error', 'format' => 'commitDeleteLB() failed'),
+                               130 => array ('code' => 'error', 'format' => 'commitDeleteVS() failed'),
+                               131 => array ('code' => 'error', 'format' => 'invalid format requested'),
+                               132 => array ('code' => 'error', 'format' => 'invalid protocol'),
+                               133 => array ('code' => 'error', 'format' => 'commitUpdateRS() failed'),
+                               134 => array ('code' => 'error', 'format' => 'commitUpdateLB() failed'),
+                               135 => array ('code' => 'error', 'format' => 'commitUpdateVS() failed'),
+                               136 => array ('code' => 'error', 'format' => 'addLBtoRSPool() failed'),
+                               137 => array ('code' => 'error', 'format' => 'addLBtoRSPool() failed'),
+                               138 => array ('code' => 'error', 'format' => 'commitDeleteRSPool() failed'),
+                               139 => array ('code' => 'error', 'format' => 'commitUpdateRSPool() failed'),
+                               140 => array ('code' => 'error', 'format' => 'Encountered %u errors, (de)activated %u real servers'),
+                               141 => array ('code' => 'error', 'format' => 'Encountered %u errors, updated %u IP address(es)'),
+                               142 => array ('code' => 'error', 'format' => 'executeAutoPorts() failed'),
+                               143 => array ('code' => 'error', 'format' => 'Tried chaining %u tags, but experienced %u errors.'),
+                               144 => array ('code' => 'error', 'format' => "Error deleting tag: '%s'"),
+                               145 => array ('code' => 'error', 'format' => "Invalid tag name '%s'"),
+                               146 => array ('code' => 'error', 'format' => "Tag '%s' (or similar name) already exists"),
+                               147 => array ('code' => 'error', 'format' => "Could not create tag '%s' because of error '%s'"),
+                               148 => array ('code' => 'error', 'format' => "Could not update tag '%s' because of error '%s'"),
+                               149 => array ('code' => 'error', 'format' => 'Turing test failed'),
+                               150 => array ('code' => 'error', 'format' => 'Can only change password under DB authentication.'),
+                               151 => array ('code' => 'error', 'format' => 'Old password doesn\'t match.'),
+                               152 => array ('code' => 'error', 'format' => 'New passwords don\'t match.'),
+                               153 => array ('code' => 'error', 'format' => 'Password change failed.'),
+                               154 => array ('code' => 'error', 'format' => "Verification error: %s"),
+                               155 => array ('code' => 'error', 'format' => 'Save failed.'),
+                               156 => array ('code' => 'error', 'format' => 'getSwitchVLANs() failed'),
                        );
                        // Handle the arguments. Is there any better way to do it?
                        foreach ($log['m'] as $record)
index da60f4aa1b84e21b1e1a25439999aef743fce2e0..86990287091e3fdbc31f501ecd36ebb3d6e0b073 100644 (file)
@@ -47,6 +47,7 @@ $tabhandler['row']['newrack'] = 'renderNewRackForm';
 $tabhandler['row']['tagroller'] = 'renderTagRollerForRow';
 $ophandler['row']['tagroller']['rollTags'] = 'rollTags';
 $msgcode['row']['tagroller']['rollTags']['OK'] = 1;
+$msgcode['row']['tagroller']['rollTags']['ERR'] = 149;
 
 $page['rack']['title_handler'] = 'dynamic_title_rack';
 $page['rack']['bypass'] = 'rack_id';
@@ -66,6 +67,7 @@ $tabhandler['rack']['problems'] = 'renderRackProblems';
 $tabhandler['rack']['tags'] = 'renderRackTags';
 $trigger['rack']['tags'] = 'trigger_tags';
 $ophandler['rack']['tags']['saveTags'] = 'saveRackTags';
+$msgcode['rack']['tags']['saveTags'] = $msgcode['object']['tags']['saveTags'];
 
 $page['objgroup']['title_handler'] = 'dynamic_title_objgroup';
 $page['objgroup']['handler'] = 'renderObjectGroup';
@@ -137,26 +139,50 @@ $ophandler['object']['editrspvs']['delLB'] = 'deleteLoadBalancer';
 $ophandler['object']['editrspvs']['updLB'] = 'updateLoadBalancer';
 $delayauth['object']['livevlans']['setPortVLAN'] = TRUE;
 $msgcode['object']['nat4']['addNATv4Rule']['OK'] = 2;
+$msgcode['object']['nat4']['addNATv4Rule']['ERR'] = 100;
 $msgcode['object']['nat4']['delNATv4Rule']['OK'] = 3;
+$msgcode['object']['nat4']['delNATv4Rule']['ERR'] = 100;
 $msgcode['object']['nat4']['updNATv4Rule']['OK'] = 4;
+$msgcode['object']['nat4']['updNATv4Rule']['ERR'] = 100;
 $msgcode['object']['ports']['addPort']['OK'] = 5;
+$msgcode['object']['ports']['addPort']['ERR1'] = 101;
+$msgcode['object']['ports']['addPort']['ERR2'] = 100;
 $msgcode['object']['ports']['editPort']['OK'] = 6;
+$msgcode['object']['ports']['editPort']['ERR1'] = 101;
+$msgcode['object']['ports']['editPort']['ERR2'] = 100;
 $msgcode['object']['ports']['delPort']['OK'] = 7;
+$msgcode['object']['ports']['delPort']['ERR'] = 100;
 $msgcode['object']['ports']['linkPort']['OK'] = 8;
+$msgcode['object']['ports']['linkPort']['ERR'] = 100;
 $msgcode['object']['ports']['unlinkPort']['OK'] = 9;
+$msgcode['object']['ports']['unlinkPort']['ERR'] = 100;
 $msgcode['object']['ports']['addMultiPorts']['OK'] = 10;
+$msgcode['object']['ports']['addMultiPorts']['ERR'] = 123;
 $msgcode['object']['ports']['useup']['OK'] = 11;
+$msgcode['object']['ports']['useup']['ERR'] = 124;
 $msgcode['object']['ipv4']['updIPv4Allocation']['OK'] = 12;
+$msgcode['object']['ipv4']['updIPv4Allocation']['ERR'] = 100;
 $msgcode['object']['ipv4']['addIPv4Allocation']['OK'] = 13;
+$msgcode['object']['ipv4']['addIPv4Allocation']['ERR'] = 100;
 $msgcode['object']['ipv4']['delIPv4Allocation']['OK'] = 14;
+$msgcode['object']['ipv4']['delIPv4Allocation']['ERR'] = 100;
 $msgcode['object']['edit']['clearSticker']['OK'] = 15;
+$msgcode['object']['edit']['clearSticker']['ERR'] = 120;
 $msgcode['object']['edit']['update']['OK'] = 16;
+$msgcode['object']['edit']['update']['ERR'] = 121;
 $msgcode['object']['edit']['updateStickers']['OK'] = 17;
+$msgcode['object']['edit']['updateStickers']['ERR'] = 122;
 $msgcode['object']['editrspvs']['addLB']['OK'] = 18;
+$msgcode['object']['editrspvs']['addLB']['ERR'] = 137;
 $msgcode['object']['editrspvs']['delLB']['OK'] = 19;
+$msgcode['object']['editrspvs']['delLB']['ERR'] = 129;
 $msgcode['object']['editrspvs']['updLB']['OK'] = 20;
+$msgcode['object']['editrspvs']['updLB']['ERR'] = 134;
 $msgcode['object']['autoports']['generate']['OK'] = 21;
+$msgcode['object']['autoports']['generate']['ERR'] = 142;
 $msgcode['object']['tags']['saveTags']['OK'] = 22;
+$msgcode['object']['tags']['saveTags']['ERR'] = 143;
+$msgcode['object']['livevlans']['setPortVLAN']['ERR1'] = 156;
 
 $page['ipv4space']['title'] = 'IPv4 space';
 $page['ipv4space']['parent'] = 'index';
@@ -167,7 +193,9 @@ $tabhandler['ipv4space']['newrange'] = 'renderAddNewRange';
 $ophandler['ipv4space']['newrange']['addIPv4Prefix'] = 'addIPv4Prefix';
 $ophandler['ipv4space']['newrange']['delIPv4Prefix'] = 'delIPv4Prefix';
 $msgcode['ipv4space']['newrange']['addIPv4Prefix']['OK'] = 23;
+$msgcode['ipv4space']['newrange']['addIPv4Prefix']['ERR'] = 100;
 $msgcode['ipv4space']['newrange']['delIPv4Prefix']['OK'] = 24;
+$msgcode['ipv4space']['newrange']['delIPv4Prefix']['ERR'] = 100;
 
 $page['iprange']['title_handler'] = 'dynamic_title_iprange';
 $page['iprange']['parent'] = 'ipv4space';
@@ -188,7 +216,10 @@ $ophandler['iprange']['properties']['editRange'] = 'editRange';
 $ophandler['iprange']['liveptr']['importPTRData'] = 'importPTRData';
 $ophandler['iprange']['tags']['saveTags'] = 'saveIPv4PrefixTags';
 $msgcode['iprange']['properties']['editRange']['OK'] = 25;
+$msgcode['iprange']['properties']['editRange']['ERR'] = 100;
 $msgcode['iprange']['liveptr']['importPTRData']['OK'] = 26;
+$msgcode['iprange']['liveptr']['importPTRData']['ERR'] = 141;
+$msgcode['iprange']['tags']['saveTags'] = $msgcode['object']['tags']['saveTags'];
 
 $page['ipaddress']['title_handler'] = 'dynamic_title_ipaddress';
 $page['ipaddress']['parent'] = 'iprange';
@@ -208,6 +239,7 @@ $ophandler['ipaddress']['assignment']['delIPv4Allocation'] = 'delIPv4Allocation'
 $ophandler['ipaddress']['assignment']['updIPv4Allocation'] = 'updIPv4Allocation';
 $ophandler['ipaddress']['assignment']['addIPv4Allocation'] = 'addIPv4Allocation';
 $msgcode['ipaddress']['properties']['editAddress']['OK'] = 27;
+$msgcode['ipaddress']['properties']['editAddress']['ERR'] = 100;
 
 $page['ipv4slb']['title'] = 'IPv4 SLB';
 $page['ipv4slb']['parent'] = 'index';
@@ -223,8 +255,12 @@ $ophandler['ipv4vslist']['edit']['add'] = 'addVService';
 $ophandler['ipv4vslist']['edit']['del'] = 'deleteVService';
 $ophandler['ipv4vslist']['edit']['upd'] = 'updateVService';
 $msgcode['ipv4vslist']['edit']['add']['OK'] = 28;
+$msgcode['ipv4vslist']['edit']['add']['ERR1'] = 132;
+$msgcode['ipv4vslist']['edit']['add']['ERR2'] = 100;
 $msgcode['ipv4vslist']['edit']['del']['OK'] = 29;
+$msgcode['ipv4vslist']['edit']['del']['ERR'] = 130;
 $msgcode['ipv4vslist']['edit']['upd']['OK'] = 30;
+$msgcode['ipv4vslist']['edit']['upd']['ERR'] = 135;
 
 $page['ipv4vs']['title_handler'] = 'dynamic_title_vservice';
 $page['ipv4vs']['parent'] = 'ipv4vslist';
@@ -247,6 +283,7 @@ $ophandler['ipv4vs']['editlblist']['delLB'] = 'deleteLoadBalancer';
 $ophandler['ipv4vs']['editlblist']['updLB'] = 'updateLoadBalancer';
 $trigger['ipv4vs']['tags'] = 'trigger_tags';
 $msgcode['ipv4vs']['editlblist'] = $msgcode['object']['editrspvs'];
+$msgcode['ipv4vs']['tags']['saveTags'] = $msgcode['object']['tags']['saveTags'];
 
 $page['ipv4rsplist']['title'] = 'RS pools';
 $page['ipv4rsplist']['parent'] = 'ipv4slb';
@@ -258,8 +295,11 @@ $ophandler['ipv4rsplist']['edit']['add'] = 'addRSPool';
 $ophandler['ipv4rsplist']['edit']['del'] = 'deleteRSPool';
 $ophandler['ipv4rsplist']['edit']['upd'] = 'updateRSPool';
 $msgcode['ipv4rsplist']['edit']['add']['OK'] = 31;
+$msgcode['ipv4rsplist']['edit']['add']['ERR'] = 100;
 $msgcode['ipv4rsplist']['edit']['del']['OK'] = 32;
+$msgcode['ipv4rsplist']['edit']['del']['ERR'] = 138;
 $msgcode['ipv4rsplist']['edit']['upd']['OK'] = 33;
+$msgcode['ipv4rsplist']['edit']['upd']['ERR'] = 139;
 
 $page['ipv4rsp']['title_handler'] = 'dynamic_title_rspool';
 $page['ipv4rsp']['parent'] = 'ipv4rsplist';
@@ -292,11 +332,19 @@ $ophandler['ipv4rsp']['rsinservice']['upd'] = 'updateRSInService';
 $ophandler['ipv4rsp']['tags']['saveTags'] = 'saveIPv4RSPoolTags';
 $ophandler['ipv4rsp']['edit']['updIPv4RSP'] = 'updateRSPool';
 $msgcode['ipv4rsp']['editrslist']['addRS']['OK'] = 34;
+$msgcode['ipv4rsp']['editrslist']['addRS']['ERR'] = 126;
 $msgcode['ipv4rsp']['editrslist']['delRS']['OK'] = 35;
+$msgcode['ipv4rsp']['editrslist']['delRS']['ERR'] = 128;
 $msgcode['ipv4rsp']['editrslist']['updRS']['OK'] = 36;
+$msgcode['ipv4rsp']['editrslist']['updRS']['ERR'] = 133;
 $msgcode['ipv4rsp']['editrslist']['addMany']['OK'] = 37;
+$msgcode['ipv4rsp']['editrslist']['addMany']['ERR1'] = 131;
+$msgcode['ipv4rsp']['editrslist']['addMany']['ERR2'] = 127;
 $msgcode['ipv4rsp']['editlblist'] = $msgcode['object']['editrspvs'];
+$msgcode['ipv4rsp']['edit']['updIPv4RSP'] = $msgcode['ipv4rsplist']['edit']['upd'];
 $msgcode['ipv4rsp']['rsinservice']['upd']['OK'] = 38;
+$msgcode['ipv4rsp']['rsinservice']['upd']['ERR'] = 140;
+$msgcode['ipv4rsp']['tags']['saveTags'] = $msgcode['object']['tags']['saveTags'];
 
 $page['rservers']['title'] = 'Real servers';
 $page['rservers']['parent'] = 'ipv4slb';
@@ -326,9 +374,15 @@ $ophandler['userlist']['edit']['createUser'] = 'createUser';
 $ophandler['userlist']['edit']['disableUser'] = 'disableUser';
 $ophandler['userlist']['edit']['enableUser'] = 'enableUser';
 $msgcode['userlist']['edit']['updateUser']['OK'] = 39;
+$msgcode['userlist']['edit']['updateUser']['ERR1'] = 103;
+$msgcode['userlist']['edit']['updateUser']['ERR1'] = 104;
 $msgcode['userlist']['edit']['createUser']['OK'] = 40;
+$msgcode['userlist']['edit']['createUser']['ERR'] = 102;
 $msgcode['userlist']['edit']['disableUser']['OK'] = 41;
+$msgcode['userlist']['edit']['disableUser']['ERR1'] = 107;
+$msgcode['userlist']['edit']['disableUser']['ERR2'] = 106;
 $msgcode['userlist']['edit']['enableUser']['OK'] = 42;
+$msgcode['userlist']['edit']['enableUser']['ERR'] = 105;
 
 $page['user']['title_handler'] = 'dynamic_title_user';
 $page['user']['parent'] = 'userlist';
@@ -341,6 +395,7 @@ $tab['user']['tags'] = 'Tags';
 $tabhandler['user']['default'] = 'renderUser';
 $tabhandler['user']['tags'] = 'renderUserTags';
 $ophandler['user']['tags']['saveTags'] = 'saveUserTags';
+$msgcode['user']['tags']['saveTags'] = $msgcode['object']['tags']['saveTags'];
 
 $page['perms']['title'] = 'Permissions';
 $page['perms']['parent'] = 'config';
@@ -350,6 +405,8 @@ $tabhandler['perms']['default'] = 'renderRackCodeViewer';
 $tabhandler['perms']['edit'] = 'renderRackCodeEditor';
 $ophandler['perms']['edit']['saveRackCode'] = 'saveRackCode';
 $msgcode['perms']['edit']['saveRackCode']['OK'] = 43;
+$msgcode['perms']['edit']['saveRackCode']['ERR1'] = 154;
+$msgcode['perms']['edit']['saveRackCode']['ERR2'] = 155;
 
 $page['portmap']['title'] = 'Port compatibility map';
 $page['portmap']['parent'] = 'config';
@@ -359,6 +416,7 @@ $tabhandler['portmap']['default'] = 'renderPortMapViewer';
 $tabhandler['portmap']['edit'] = 'renderPortMapEditor';
 $ophandler['portmap']['edit']['save'] = 'savePortMap';
 $msgcode['portmap']['edit']['save']['OK'] = 44;
+$msgcode['portmap']['edit']['save']['ERR'] = 108;
 
 $page['attrs']['title'] = 'Attributes';
 $page['attrs']['parent'] = 'config';
@@ -374,10 +432,15 @@ $ophandler['attrs']['editattrs']['del'] = 'deleteAttribute';
 $ophandler['attrs']['editmap']['add'] = 'supplementAttrMap';
 $ophandler['attrs']['editmap']['del'] = 'reduceAttrMap';
 $msgcode['attrs']['editattrs']['add']['OK'] = 45;
+$msgcode['attrs']['editattrs']['add']['ERR'] = 116;
 $msgcode['attrs']['editattrs']['upd']['OK'] = 46;
+$msgcode['attrs']['editattrs']['upd']['ERR'] = 115;
 $msgcode['attrs']['editattrs']['del']['OK'] = 47;
+$msgcode['attrs']['editattrs']['del']['ERR'] = 117;
 $msgcode['attrs']['editmap']['add']['OK'] = 48;
+$msgcode['attrs']['editmap']['add']['ERR'] = 118;
 $msgcode['attrs']['editmap']['del']['OK'] = 49;
+$msgcode['attrs']['editmap']['del']['ERR'] = 119;
 
 $page['dict']['title'] = 'Dictionary';
 $page['dict']['parent'] = 'config';
@@ -394,11 +457,17 @@ $ophandler['dict']['chapters']['del'] = 'delChapter';
 $ophandler['dict']['chapters']['upd'] = 'updateChapter';
 $ophandler['dict']['chapters']['add'] = 'addChapter';
 $msgcode['dict']['edit']['del']['OK'] = 50;
+$msgcode['dict']['edit']['del']['ERR'] = 111;
 $msgcode['dict']['edit']['upd']['OK'] = 51;
+$msgcode['dict']['edit']['upd']['ERR'] = 109;
 $msgcode['dict']['edit']['add']['OK'] = 52;
+$msgcode['dict']['edit']['add']['ERR'] = 110;
 $msgcode['dict']['chapters']['del']['OK'] = 53;
+$msgcode['dict']['chapters']['del']['ERR'] = 114;
 $msgcode['dict']['chapters']['upd']['OK'] = 54;
+$msgcode['dict']['chapters']['upd']['ERR'] = 113;
 $msgcode['dict']['chapters']['add']['OK'] = 55;
+$msgcode['dict']['chapters']['add']['ERR'] = 112;
 
 $page['ui']['title'] = 'User interface';
 $page['ui']['parent'] = 'config';
@@ -411,6 +480,7 @@ $tabhandler['ui']['reset'] = 'renderUIResetForm';
 $ophandler['ui']['edit']['upd'] = 'updateUI';
 $ophandler['ui']['reset']['go'] = 'resetUIConfig';
 $msgcode['ui']['edit']['upd']['OK'] = 56;
+$msgcode['ui']['edit']['upd']['ERR'] = 125;
 $msgcode['ui']['reset']['go']['OK'] = 57;
 
 $page['tagtree']['title'] = 'Tag tree';
@@ -423,8 +493,14 @@ $ophandler['tagtree']['edit']['destroyTag'] = 'destroyTag';
 $ophandler['tagtree']['edit']['createTag'] = 'createTag';
 $ophandler['tagtree']['edit']['updateTag'] = 'updateTag';
 $msgcode['tagtree']['edit']['destroyTag']['OK'] = 58;
+$msgcode['tagtree']['edit']['destroyTag']['ERR'] = 144;
 $msgcode['tagtree']['edit']['createTag']['OK'] = 59;
+$msgcode['tagtree']['edit']['createTag']['ERR1'] = 145;
+$msgcode['tagtree']['edit']['createTag']['ERR2'] = 146;
+$msgcode['tagtree']['edit']['createTag']['ERR3'] = 147;
 $msgcode['tagtree']['edit']['updateTag']['OK'] = 60;
+$msgcode['tagtree']['edit']['updateTag']['ERR1'] = 145;
+$msgcode['tagtree']['edit']['updateTag']['ERR2'] = 148;
 
 $page['myaccount']['title'] = 'My account';
 $page['myaccount']['parent'] = 'config';
@@ -437,6 +513,10 @@ $tabhandler['myaccount']['mypassword'] = 'renderMyPasswordEditor';
 $tabhandler['myaccount']['myrealname'] = 'dragon';
 $ophandler['myaccount']['mypassword']['changeMyPassword'] = 'changeMyPassword';
 $msgcode['myaccount']['mypassword']['changeMyPassword']['OK'] = 61;
+$msgcode['myaccount']['mypassword']['changeMyPassword']['ERR1'] = 150;
+$msgcode['myaccount']['mypassword']['changeMyPassword']['ERR2'] = 151;
+$msgcode['myaccount']['mypassword']['changeMyPassword']['ERR3'] = 152;
+$msgcode['myaccount']['mypassword']['changeMyPassword']['ERR4'] = 153;
 
 $page['reports']['title'] = 'Reports';
 $page['reports']['parent'] = 'index';
index edabbcb47f2a60d355d363d4d8a3eaf6e72069a3..8a103c5504b7ed027b3ff998ac035f1eb803f9dd 100644 (file)
@@ -105,9 +105,9 @@ function addPortForwarding ()
        );
 
        if ($error == '')
-               return buildRedirectURL_OK();
+               return buildRedirectURL ('OK');
        else
-               return buildRedirectURL_ERR ($error);
+               return buildRedirectURL ('ERR', array ($error));
 }
 
 function delPortForwarding ()
@@ -129,9 +129,9 @@ function delPortForwarding ()
                $_REQUEST['proto']
        );
        if ($error == '')
-               return buildRedirectURL_OK();
+               return buildRedirectURL ('OK');
        else
-               return buildRedirectURL_ERR ($error);
+               return buildRedirectURL ('ERR', array ($error));
 }
 
 function updPortForwarding ()
@@ -155,9 +155,9 @@ function updPortForwarding ()
                $_REQUEST['description']
        );
        if ($error == '')
-               return buildRedirectURL_OK();
+               return buildRedirectURL ('OK');
        else
-               return buildRedirectURL_ERR ($error);
+               return buildRedirectURL ('ERR', array ($error));
 }
 
 function addPortForObject ()
@@ -165,12 +165,12 @@ function addPortForObject ()
        assertUIntArg ('object_id', __FUNCTION__);
        assertStringArg ('port_name', __FUNCTION__, TRUE);
        if (empty ($_REQUEST['port_name']))
-               return buildRedirectURL_ERR ('Port name cannot be empty');
+               return buildRedirectURL ('ERR1');
        $error = commitAddPort ($_REQUEST['object_id'], $_REQUEST['port_name'], $_REQUEST['port_type_id'], $_REQUEST['port_label'], $_REQUEST['port_l2address']);
        if ($error != '')
-               return buildRedirectURL_ERR ($error);
+               return buildRedirectURL ('ERR2', array ($error));
        else
-               return buildRedirectURL_OK (array ($_REQUEST['port_name']));
+               return buildRedirectURL ('OK', array ($_REQUEST['port_name']));
 }
 
 function editPortForObject ()
@@ -179,7 +179,7 @@ function editPortForObject ()
        // tolerate empty value now to produce custom informative message later
        assertStringArg ('name', __FUNCTION__, TRUE);
        if (empty ($_REQUEST['name']))
-               return buildRedirectURL_ERR ('Port name cannot be empty');
+               return buildRedirectURL ('ERR1');
 
        if (isset ($_REQUEST['reservation_comment']) and !empty ($_REQUEST['reservation_comment']))
                $port_rc = '"' . $_REQUEST['reservation_comment'] . '"';
@@ -187,9 +187,9 @@ function editPortForObject ()
                $port_rc = 'NULL';
        $error = commitUpdatePort ($_REQUEST['port_id'], $_REQUEST['name'], $_REQUEST['label'], $_REQUEST['l2address'], $port_rc);
        if ($error != '')
-               return buildRedirectURL_ERR ($error);
+               return buildRedirectURL ('ERR2', array ($error));
        else
-               return buildRedirectURL_OK (array ($_REQUEST['name']));
+               return buildRedirectURL ('OK', array ($_REQUEST['name']));
 }
 
 function delPortFromObject ()
@@ -198,9 +198,9 @@ function delPortFromObject ()
        $error = delObjectPort ($_REQUEST['port_id']);
 
        if ($error != '')
-               return buildRedirectURL_ERR ($error);
+               return buildRedirectURL ('ERR', array ($error));
        else
-               return buildRedirectURL_OK (array ($_REQUEST['port_name']));
+               return buildRedirectURL ('OK', array ($_REQUEST['port_name']));
 }
 
 function linkPortForObject ()
@@ -213,9 +213,9 @@ function linkPortForObject ()
 
        $error = linkPorts ($_REQUEST['port_id'], $_REQUEST['remote_port_id']);
        if ($error != '')
-               return buildRedirectURL_ERR ($error);
+               return buildRedirectURL ('ERR', array ($error));
        else
-               return buildRedirectURL_OK (array ($_REQUEST['port_name'], $_REQUEST['remote_port_name'], $_REQUEST['remote_object_name']));
+               return buildRedirectURL ('OK', array ($_REQUEST['port_name'], $_REQUEST['remote_port_name'], $_REQUEST['remote_object_name']));
 }
 
 function unlinkPortForObject ()
@@ -227,9 +227,9 @@ function unlinkPortForObject ()
 
        $error = unlinkPort ($_REQUEST['port_id']);
        if ($error != '')
-               return buildRedirectURL_ERR ($error);
+               return buildRedirectURL ('ERR', array ($error));
        else
-               return buildRedirectURL_OK (array ($_REQUEST['port_name'], $_REQUEST['remote_port_name'], $_REQUEST['remote_object_name']));
+               return buildRedirectURL ('OK', array ($_REQUEST['port_name'], $_REQUEST['remote_port_name'], $_REQUEST['remote_object_name']));
 }
 
 function addMultiPorts ()
@@ -314,7 +314,7 @@ http://www.cisco.com/en/US/products/hw/routers/ps274/products_tech_note09186a008
                                );
                                break;
                        default:
-                               return buildRedirectURL_ERR ('Cannot process submitted data: unknown format code.');
+                               return buildRedirectURL ('ERR');
                                break;
                }
        }
@@ -340,7 +340,7 @@ http://www.cisco.com/en/US/products/hw/routers/ps274/products_tech_note09186a008
                                $error_count++;
                }
        }
-       return buildRedirectURL_OK (array ($added_count, $updated_count, $error_count));
+       return buildRedirectURL ('OK', array ($added_count, $updated_count, $error_count));
 }
 
 function updIPv4Allocation ()
@@ -352,9 +352,9 @@ function updIPv4Allocation ()
 
        $error = updateBond ($_REQUEST['ip'], $_REQUEST['object_id'], $_REQUEST['bond_name'], $_REQUEST['bond_type']);
        if ($error != '')
-               return buildRedirectURL_ERR ($error);
+               return buildRedirectURL ('ERR', array ($error));
        else
-               return buildRedirectURL_OK();
+               return buildRedirectURL ('OK');
 }
 
 function delIPv4Allocation ()
@@ -364,9 +364,9 @@ function delIPv4Allocation ()
 
        $error = unbindIpFromObject ($_REQUEST['ip'], $_REQUEST['object_id']);
        if ($error != '')
-               return buildRedirectURL_ERR ($error);
+               return buildRedirectURL ('ERR', array ($error));
        else
-               return buildRedirectURL_OK();
+               return buildRedirectURL ('OK');
 }
 
 function addIPv4Allocation ()
@@ -390,9 +390,9 @@ function addIPv4Allocation ()
                updateAddress ($ip, $address['name'], $address['reserved']);
        }
        if ($error != '')
-               return buildRedirectURL_ERR ($error);
+               return buildRedirectURL ('ERR', array ($error));
        else
-               return buildRedirectURL_OK();
+               return buildRedirectURL ('OK');
 }
 
 function addIPv4Prefix ()
@@ -404,9 +404,9 @@ function addIPv4Prefix ()
        $taglist = isset ($_REQUEST['taglist']) ? $_REQUEST['taglist'] : array();
        $error = createIPv4Prefix ($_REQUEST['range'], $_REQUEST['name'], $is_bcast == 'on', $taglist);
        if ($error != '')
-               return buildRedirectURL_ERR ($error);
+               return buildRedirectURL ('ERR', $error);
        else
-               return buildRedirectURL_OK();
+               return buildRedirectURL ('OK');
 }
 
 function delIPv4Prefix ()
@@ -414,9 +414,9 @@ function delIPv4Prefix ()
        assertUIntArg ('id', __FUNCTION__);
        $error = destroyIPv4Prefix ($_REQUEST['id']);
        if ($error != '')
-               return buildRedirectURL_ERR ($error);
+               return buildRedirectURL ('ERR', $error);
        else
-               return buildRedirectURL_OK();
+               return buildRedirectURL ('OK');
 }
 
 function editRange ()
@@ -426,9 +426,9 @@ function editRange ()
 
        $error = updateRange ($_REQUEST['id'], $_REQUEST['name']);
        if ($error != '')
-               return buildRedirectURL_ERR ($error);
+               return buildRedirectURL ('ERR', array ($error));
        else
-               return buildRedirectURL_OK();
+               return buildRedirectURL ('OK');
 }
 
 function editAddress ()
@@ -442,9 +442,9 @@ function editAddress ()
                $reserved = 'off';
        $error = updateAddress ($_REQUEST['ip'], $_REQUEST['name'], $reserved == 'on' ? 'yes' : 'no');
        if ($error != '')
-               return buildRedirectURL_ERR ($error);
+               return buildRedirectURL ('ERR', array ($error));
        else
-               return buildRedirectURL_OK();
+               return buildRedirectURL ('OK');
 }
 
 function createUser ()
@@ -456,9 +456,9 @@ function createUser ()
        $password = hash (PASSWORD_HASH, $_REQUEST['password']);
        $result = commitCreateUserAccount ($username, $_REQUEST['realname'], $password);
        if ($result == TRUE)
-               return buildRedirectURL_OK (array ($username));
+               return buildRedirectURL ('OK', array ($username));
        else
-               return buildRedirectURL_ERR ("Error creating user account ${username}.");
+               return buildRedirectURL ('ERR', array ($username));
 }
 
 function updateUser ()
@@ -471,37 +471,35 @@ function updateUser ()
        $new_password = $_REQUEST['password'];
        $old_hash = getHashByID ($_REQUEST['user_id']);
        if ($old_hash == NULL)
-               return buildRedirectURL_ERR ('getHashByID() failed');
+               return buildRedirectURL ('ERR1');
        // Update user password only if provided password is not the same as current password hash.
        if ($new_password != $old_hash)
                $new_password = hash (PASSWORD_HASH, $new_password);
        $result = commitUpdateUserAccount ($_REQUEST['user_id'], $username, $_REQUEST['realname'], $new_password);
        if ($result == TRUE)
-               return buildRedirectURL_OK (array ($username));
+               return buildRedirectURL ('OK', array ($username));
        else
-               return buildRedirectURL_ERR ("Error updating user account ${username}.");
+               return buildRedirectURL ('ERR2', array ($username));
 }
 
 function enableUser ()
 {
        assertUIntArg ('user_id', __FUNCTION__);
        if (commitEnableUserAccount ($_REQUEST['user_id'], 'yes') == TRUE)
-               return buildRedirectURL_OK();
+               return buildRedirectURL ('OK');
        else
-               return buildRedirectURL_ERR ('Error enabling user account.');
+               return buildRedirectURL ('ERR');
 }
 
 function disableUser ()
 {
        assertUIntArg ('user_id', __FUNCTION__);
        if ($_REQUEST['user_id'] == 1)
-               $result = FALSE;
+               return buildRedirectURL ('ERR1');
+       if (commitEnableUserAccount ($_REQUEST['user_id'], 'no'))
+               return buildRedirectURL ('OK');
        else
-               $result = commitEnableUserAccount ($_REQUEST['user_id'], 'no');
-       if ($result == TRUE)
-               return buildRedirectURL_OK();
-       else
-               return buildRedirectURL_ERR ('Error disabling user account.');
+               return buildRedirectURL ('ERR2');
 }
 
 // This function find differences in users's submit and PortCompat table
@@ -541,13 +539,13 @@ function savePortMap ()
                                                        $error_count++;
                                                break;
                                        default:
-                                               showError ('oldCompatTable is invalid', __FUNCTION__);
+                                               showError ('Internal error: oldCompatTable is invalid', __FUNCTION__);
                                                break;
                                }
        if ($error_count == 0)
-               return buildRedirectURL_OK (array ($error_count, $success_count));
+               return buildRedirectURL ('OK', array ($error_count, $success_count));
        else
-               return buildRedirectURL_ERR ("${error_count} failures and ${success_count} successfull changes.");
+               return buildRedirectURL ('ERR', array ($error_count, $success_count));
 }
 
 function updateDictionary ()
@@ -556,9 +554,9 @@ function updateDictionary ()
        assertUIntArg ('dict_key', __FUNCTION__);
        assertStringArg ('dict_value', __FUNCTION__);
        if (commitUpdateDictionary ($_REQUEST['chapter_no'], $_REQUEST['dict_key'], $_REQUEST['dict_value']) === TRUE)
-               return buildRedirectURL_OK();
+               return buildRedirectURL ('OK');
        else
-               return buildRedirectURL_ERR ('Update failed!');
+               return buildRedirectURL ('ERR');
 }
 
 function supplementDictionary ()
@@ -566,9 +564,9 @@ function supplementDictionary ()
        assertUIntArg ('chapter_no', __FUNCTION__);
        assertStringArg ('dict_value', __FUNCTION__);
        if (commitSupplementDictionary ($_REQUEST['chapter_no'], $_REQUEST['dict_value']) === TRUE)
-               return buildRedirectURL_OK();
+               return buildRedirectURL ('OK');
        else
-               return buildRedirectURL_ERR ('Supplement failed!');
+               return buildRedirectURL ('ERR');
 }
 
 function reduceDictionary ()
@@ -576,18 +574,18 @@ function reduceDictionary ()
        assertUIntArg ('chapter_no', __FUNCTION__);
        assertUIntArg ('dict_key', __FUNCTION__);
        if (commitReduceDictionary ($_REQUEST['chapter_no'], $_REQUEST['dict_key']) === TRUE)
-               return buildRedirectURL_OK();
+               return buildRedirectURL ('OK');
        else
-               return buildRedirectURL_ERR ('Reduction failed!');
+               return buildRedirectURL ('ERR');
 }
 
 function addChapter ()
 {
        assertStringArg ('chapter_name', __FUNCTION__);
        if (commitAddChapter ($_REQUEST['chapter_name']) === TRUE)
-               return buildRedirectURL_OK();
+               return buildRedirectURL ('OK');
        else
-               return buildRedirectURL_ERR ('Error adding chapter.');
+               return buildRedirectURL ('ERR');
 }
 
 function updateChapter ()
@@ -595,18 +593,18 @@ function updateChapter ()
        assertUIntArg ('chapter_no', __FUNCTION__);
        assertStringArg ('chapter_name', __FUNCTION__);
        if (commitUpdateChapter ($_REQUEST['chapter_no'], $_REQUEST['chapter_name']) === TRUE)
-               return buildRedirectURL_OK();
+               return buildRedirectURL ('OK');
        else
-               return buildRedirectURL_ERR ('Error updating chapter.');
+               return buildRedirectURL ('ERR');
 }
 
 function delChapter ()
 {
        assertUIntArg ('chapter_no', __FUNCTION__);
        if (commitDeleteChapter ($_REQUEST['chapter_no']))
-               return buildRedirectURL_OK();
+               return buildRedirectURL ('OK');
        else
-               return buildRedirectURL_ERR ('Error deleting chapter.');
+               return buildRedirectURL ('ERR');
 }
 
 function changeAttribute ()
@@ -614,9 +612,9 @@ function changeAttribute ()
        assertUIntArg ('attr_id', __FUNCTION__);
        assertStringArg ('attr_name', __FUNCTION__);
        if (commitUpdateAttribute ($_REQUEST['attr_id'], $_REQUEST['attr_name']))
-               return buildRedirectURL_OK();
+               return buildRedirectURL ('OK');
        else
-               return buildRedirectURL_ERR ('Error renaming attribute.');
+               return buildRedirectURL ('ERR');
 }
 
 function createAttribute ()
@@ -624,18 +622,18 @@ function createAttribute ()
        assertStringArg ('attr_name', __FUNCTION__);
        assertStringArg ('attr_type', __FUNCTION__);
        if (commitAddAttribute ($_REQUEST['attr_name'], $_REQUEST['attr_type']))
-               return buildRedirectURL_OK (array ($_REQUEST['attr_name']));
+               return buildRedirectURL ('OK', array ($_REQUEST['attr_name']));
        else
-               return buildRedirectURL_ERR ('Error creating attribute.');
+               return buildRedirectURL ('ERR');
 }
 
 function deleteAttribute ()
 {
        assertUIntArg ('attr_id', __FUNCTION__);
        if (commitDeleteAttribute ($_REQUEST['attr_id']))
-               return buildRedirectURL_OK();
+               return buildRedirectURL ('OK');
        else
-               return buildRedirectURL_ERR ('Error deleting attribute.');
+               return buildRedirectURL ('ERR');
 }
 
 function supplementAttrMap ()
@@ -644,9 +642,9 @@ function supplementAttrMap ()
        assertUIntArg ('objtype_id', __FUNCTION__);
        assertUIntArg ('chapter_no', __FUNCTION__);
        if (commitSupplementAttrMap ($_REQUEST['attr_id'], $_REQUEST['objtype_id'], $_REQUEST['chapter_no']) === TRUE)
-               return buildRedirectURL_OK();
+               return buildRedirectURL ('OK');
        else
-               return buildRedirectURL_ERR ('Supplement failed!');
+               return buildRedirectURL ('ERR');
 }
 
 function reduceAttrMap ()
@@ -654,9 +652,9 @@ function reduceAttrMap ()
        assertUIntArg ('attr_id', __FUNCTION__);
        assertUIntArg ('objtype_id', __FUNCTION__);
        if (commitReduceAttrMap ($_REQUEST['attr_id'], $_REQUEST['objtype_id']) === TRUE)
-               return buildRedirectURL_OK();
+               return buildRedirectURL ('OK');
        else
-               return buildRedirectURL_ERR ("Reduction failed!");
+               return buildRedirectURL ('ERR');
 }
 
 function clearSticker ()
@@ -664,9 +662,9 @@ function clearSticker ()
        assertUIntArg ('attr_id', __FUNCTION__);
        assertUIntArg ('object_id', __FUNCTION__);
        if (commitResetAttrValue ($_REQUEST['object_id'], $_REQUEST['attr_id']) === TRUE)
-               return buildRedirectURL_OK();
+               return buildRedirectURL ('OK');
        else
-               return buildRedirectURL_ERR ('Reset failed!');
+               return buildRedirectURL ('ERR');
 }
 
 function updateObject ()
@@ -692,11 +690,11 @@ function updateObject ()
                $_REQUEST['object_asset_no'],
                $_REQUEST['object_comment']
        ) !== TRUE)
-               return buildRedirectURL_ERR ('commitUpdateObject() failed');
+               return buildRedirectURL ('ERR');
        // Invalidate thumb cache of all racks objects could occupy.
        foreach (getResidentRacksData ($_REQUEST['object_id'], FALSE) as $rack_id)
                resetThumbCache ($rack_id);
-       return buildRedirectURL_OK();
+       return buildRedirectURL ('OK');
 }
 
 function updateStickers ()
@@ -744,18 +742,18 @@ function updateStickers ()
        }
 
        if (in_array (FALSE, $result))
-               return buildRedirectURL_ERR ('One or more update(s) failed!');
+               return buildRedirectURL ('ERR');
 
-       return buildRedirectURL_OK();
+       return buildRedirectURL ('OK');
 }
 
 function useupPort ()
 {
        assertUIntArg ('port_id', __FUNCTION__);
        if (commitUseupPort ($_REQUEST['port_id']) === TRUE)
-               return buildRedirectURL_OK();
+               return buildRedirectURL ('OK');
        else
-               return buildRedirectURL_ERR ('Error removing reservation!');
+               return buildRedirectURL ('ERR');
 }
 
 function updateUI ()
@@ -781,9 +779,9 @@ function updateUI ()
        }
 
        if ($error != '')
-               return buildRedirectURL_ERR ('Update failed with error: ' . $error);
+               return buildRedirectURL ('ERR', array ($error));
 
-       return buildRedirectURL_OK();
+       return buildRedirectURL ('OK');
 }
 
 function resetUIConfig()
@@ -811,7 +809,7 @@ function resetUIConfig()
        setConfigVar ('SHOW_AUTOMATIC_TAGS','no');
        setConfigVar ('DEFAULT_OBJECT_TYPE','4');
        setConfigVar ('IPV4_AUTO_RELEASE','1');
-       return buildRedirectURL_OK();
+       return buildRedirectURL ('OK');
 }
 
 // Add single record.
@@ -828,9 +826,9 @@ function addRealServer ()
                getConfigVar ('DEFAULT_IPV4_RS_INSERVICE'),
                $_REQUEST['rsconfig']
        ))
-               return buildRedirectURL_ERR ('addRStoRSPool() failed');
+               return buildRedirectURL ('ERR');
        else
-               return buildRedirectURL_OK();
+               return buildRedirectURL ('OK');
 }
 
 // Parse textarea submitted and try adding a real server for each line.
@@ -875,14 +873,14 @@ function addRealServers ()
                                        $nbad++;
                                break;
                        default:
-                               return buildRedirectURL_ERR (__FUNCTION__ . ': invalid format requested');
+                               return buildRedirectURL ('ERR1');
                                break;
                }
        }
        if ($nbad == 0 and $ngood > 0)
-               return buildRedirectURL_OK (array ($ngood));
+               return buildRedirectURL ('OK', array ($ngood));
        else
-               return buildRedirectURL_ERR ("Added ${ngood} real servers and encountered ${nbad} errors");
+               return buildRedirectURL ('ERR2', array ($ngood, $nbad));
 }
 
 function addVService ()
@@ -891,7 +889,7 @@ function addVService ()
        assertUIntArg ('vport', __FUNCTION__);
        assertStringArg ('proto', __FUNCTION__);
        if ($_REQUEST['proto'] != 'TCP' and $_REQUEST['proto'] != 'UDP')
-               return buildRedirectURL_ERR (__FUNCTION__ . ': invalid protocol');
+               return buildRedirectURL ('ERR1');
        assertStringArg ('name', __FUNCTION__, TRUE);
        assertStringArg ('vsconfig', __FUNCTION__, TRUE);
        assertStringArg ('rsconfig', __FUNCTION__, TRUE);
@@ -906,18 +904,18 @@ function addVService ()
                isset ($_REQUEST['taglist']) ? $_REQUEST['taglist'] : array()
        );
        if ($error != '')
-               return buildRedirectURL_ERR ($error);
+               return buildRedirectURL ('ERR2', array ($error));
        else
-               return buildRedirectURL_OK();
+               return buildRedirectURL ('OK');
 }
 
 function deleteRealServer ()
 {
        assertUIntArg ('id', __FUNCTION__);
        if (!commitDeleteRS ($_REQUEST['id']))
-               return buildRedirectURL_ERR ('commitDeleteRS() failed');
+               return buildRedirectURL ('ERR');
        else
-               return buildRedirectURL_OK();
+               return buildRedirectURL ('OK');
 }
 
 function deleteLoadBalancer ()
@@ -930,18 +928,18 @@ function deleteLoadBalancer ()
                $_REQUEST['pool_id'],
                $_REQUEST['vs_id']
        ))
-               return buildRedirectURL_ERR ('commitDeleteLB() failed');
+               return buildRedirectURL ('ERR');
        else
-               return buildRedirectURL_OK();
+               return buildRedirectURL ('OK');
 }
 
 function deleteVService ()
 {
        assertUIntArg ('vs_id', __FUNCTION__);
        if (!commitDeleteVS ($_REQUEST['vs_id']))
-               return buildRedirectURL_ERR ('commitDeleteVS() failed');
+               return buildRedirectURL ('ERR');
        else
-               return buildRedirectURL_OK();
+               return buildRedirectURL ('OK');
 }
 
 function updateRealServer ()
@@ -956,9 +954,9 @@ function updateRealServer ()
                $_REQUEST['rsport'],
                $_REQUEST['rsconfig']
        ))
-               return buildRedirectURL_ERR ('commitUpdateRS() failed');
+               return buildRedirectURL ('ERR');
        else
-               return buildRedirectURL_OK();
+               return buildRedirectURL ('OK');
 }
 
 function updateLoadBalancer ()
@@ -975,9 +973,9 @@ function updateLoadBalancer ()
                $_REQUEST['vsconfig'],
                $_REQUEST['rsconfig']
        ))
-               return buildRedirectURL_ERR ('commitUpdateLB() failed');
+               return buildRedirectURL ('ERR');
        else
-               return buildRedirectURL_OK();
+               return buildRedirectURL ('OK');
 }
 
 function updateVService ()
@@ -998,9 +996,9 @@ function updateVService ()
                $_REQUEST['vsconfig'],
                $_REQUEST['rsconfig']
        ))
-               return buildRedirectURL_ERR ('commitUpdateVS() failed');
+               return buildRedirectURL ('ERR');
        else
-               return buildRedirectURL_OK();
+               return buildRedirectURL ('OK');
 }
 
 function addLoadBalancer ()
@@ -1017,9 +1015,9 @@ function addLoadBalancer ()
                $_REQUEST['vsconfig'],
                $_REQUEST['rsconfig']
        ))
-               return buildRedirectURL_ERR ('addLBtoRSPool() failed');
+               return buildRedirectURL ('ERR');
        else
-               return buildRedirectURL_OK();
+               return buildRedirectURL ('OK');
 }
 
 function addRSPool ()
@@ -1035,18 +1033,18 @@ function addRSPool ()
                isset ($_REQUEST['taglist']) ? $_REQUEST['taglist'] : array()
        );
        if ($error != '')
-               return buildRedirectURL_ERR ($error);
+               return buildRedirectURL ('ERR', array ($error));
        else
-               return buildRedirectURL_OK();
+               return buildRedirectURL ('OK');
 }
 
 function deleteRSPool ()
 {
        assertUIntArg ('pool_id', __FUNCTION__);
        if (!commitDeleteRSPool ($_REQUEST['pool_id']))
-               return buildRedirectURL_ERR ('commitDeleteRSPool() failed');
+               return buildRedirectURL ('ERR');
        else
-               return buildRedirectURL_OK();
+               return buildRedirectURL ('OK');
 }
 
 function updateRSPool ()
@@ -1056,9 +1054,9 @@ function updateRSPool ()
        assertStringArg ('vsconfig', __FUNCTION__, TRUE);
        assertStringArg ('rsconfig', __FUNCTION__, TRUE);
        if (!commitUpdateRSPool ($_REQUEST['pool_id'], $_REQUEST['name'], $_REQUEST['vsconfig'], $_REQUEST['rsconfig']))
-               return buildRedirectURL_ERR ('commitUpdateRSPool() failed');
+               return buildRedirectURL ('ERR');
        else
-               return buildRedirectURL_OK();
+               return buildRedirectURL ('OK');
 }
 
 function updateRSInService ()
@@ -1083,9 +1081,9 @@ function updateRSInService ()
                }
        }
        if (!$nbad)
-               return buildRedirectURL_OK (array ($ngood));
+               return buildRedirectURL ('OK', array ($ngood));
        else
-               return buildRedirectURL_ERR ("Encountered ${nbad} errors, (de)activated ${ngood} real servers");
+               return buildRedirectURL ('ERR', array ($nbad, $ngood));
 }
 
 function importPTRData ()
@@ -1110,9 +1108,9 @@ function importPTRData ()
                        $nbad++;
        }
        if (!$nbad)
-               return buildRedirectURL_OK (array ($ngood));
+               return buildRedirectURL ('OK', array ($ngood));
        else
-               return buildRedirectURL_ERR ("Encountered ${nbad} errors, updated ${ngood} IP address(es)");
+               return buildRedirectURL ('ERR', array ($nbad, $ngood));
 }
 
 function generateAutoPorts ()
@@ -1122,9 +1120,9 @@ function generateAutoPorts ()
        $info = getObjectInfo ($_REQUEST['object_id']);
        // Navigate away in case of success, stay at the place otherwise.
        if (executeAutoPorts ($_REQUEST['object_id'], $info['objtype_id']))
-               return buildRedirectURL_OK (array(), $pageno, 'ports');
+               return buildRedirectURL ('OK', array(), $pageno, 'ports');
        else
-               return buildRedirectURL_ERR ('executeAutoPorts() failed');
+               return buildRedirectURL ('ERR');
 }
 
 // Filter out implicit tags before storing the new tag set.
@@ -1145,9 +1143,9 @@ function saveEntityTags ($realm, $bypass)
                else
                        $n_errors++;
        if ($n_errors)
-               return buildRedirectURL_ERR ("Tried chaining ${n_succeeds} tags, but experienced ${n_errors} errors.");
+               return buildRedirectURL ('ERR', array ($n_succeeds, $n_errors));
        else
-               return buildRedirectURL_OK (array ($n_succeeds));
+               return buildRedirectURL ('OK', array ($n_succeeds));
 }
 
 function saveObjectTags ()
@@ -1184,9 +1182,9 @@ function destroyTag ()
 {
        assertUIntArg ('tag_id', __FUNCTION__);
        if (($ret = commitDestroyTag ($_REQUEST['tag_id'])) == '')
-               return buildRedirectURL_OK();
+               return buildRedirectURL ('OK');
        else
-               return buildRedirectURL_ERR ("Error deleting tag: '${ret}'");
+               return buildRedirectURL ('ERR');
 }
 
 function createTag ()
@@ -1195,15 +1193,15 @@ function createTag ()
        assertUIntArg ('parent_id', __FUNCTION__, TRUE);
        $tagname = trim ($_REQUEST['tag_name']);
        if (!validTagName ($tagname))
-               return buildRedirectURL_ERR ("Invalid tag name '${tagname}'");
+               return buildRedirectURL ('ERR1', array ($tagname));
        if (tagExistsInDatabase ($tagname))
-               return buildRedirectURL_ERR ("Tag '${tagname}' (or similar name) already exists");
+               return buildRedirectURL ('ERR2', array ($tagname));
        if (($parent_id = $_REQUEST['parent_id']) <= 0)
                $parent_id = 'NULL';
        if (($ret = commitCreateTag ($tagname, $parent_id)) == '')
-               return buildRedirectURL_OK (array ($tagname));
+               return buildRedirectURL ('OK', array ($tagname));
        else
-               return buildRedirectURL_ERR ("Could not create tag '${tagname}' because of error '${ret}'");
+               return buildRedirectURL ('ERR', array ($tagname, $ret));
 }
 
 function updateTag ()
@@ -1213,13 +1211,13 @@ function updateTag ()
        assertStringArg ('tag_name', __FUNCTION__);
        $tagname = trim ($_REQUEST['tag_name']);
        if (!validTagName ($tagname))
-               return buildRedirectURL_ERR ("Invalid tag name '${tagname}'");
+               return buildRedirectURL ('ERR');
        if (($parent_id = $_REQUEST['parent_id']) <= 0)
                $parent_id = 'NULL';
        if (($ret = commitUpdateTag ($_REQUEST['tag_id'], $tagname, $parent_id)) == '')
-               return buildRedirectURL_OK (array ($tagname));
+               return buildRedirectURL ('OK', array ($tagname));
        else
-               return buildRedirectURL_ERR ("Could not update tag '${tagname}' because of error '${ret}'");
+               return buildRedirectURL ('ERR', array ($tagname, $ret));
 }
 
 function rollTags ()
@@ -1229,7 +1227,7 @@ function rollTags ()
        assertUIntArg ('realsum', __FUNCTION__);
        $row_id = $_REQUEST['row_id'];
        if ($_REQUEST['sum'] != $_REQUEST['realsum'])
-               return buildRedirectURL_ERR ('Turing test failed');
+               return buildRedirectURL ('ERR');
        $racks = getRacksForRow ($row_id);
        // Each time addTagForEntity() fails we assume it was just because of already existing record in its way.
        $newtags = isset ($_REQUEST['taglist']) ? $_REQUEST['taglist'] : array();
@@ -1244,25 +1242,25 @@ function rollTags ()
                                $ndupes++;
                        // FIXME: do something likewise for all object inside current rack
                }
-       return buildRedirectURL_OK();
+       return buildRedirectURL ('OK');
 }
 
 function changeMyPassword ()
 {
        global $accounts, $remote_username;
        if (getConfigVar ('USER_AUTH_SRC') != 'database')
-               return buildRedirectURL_ERR ('Can only change password under DB authentication.');
+               return buildRedirectURL ('ERR1');
        assertStringArg ('oldpassword', __FUNCTION__);
        assertStringArg ('newpassword1', __FUNCTION__);
        assertStringArg ('newpassword2', __FUNCTION__);
        if ($accounts[$remote_username]['user_password_hash'] != hash (PASSWORD_HASH, $_REQUEST['oldpassword']))
-               return buildRedirectURL_ERR ('Old password doesn\'t match.');
+               return buildRedirectURL ('ERR2');
        if ($_REQUEST['newpassword1'] != $_REQUEST['newpassword2'])
-               return buildRedirectURL_ERR ('New passwords don\'t match.');
+               return buildRedirectURL ('ERR3');
        if (commitUpdateUserAccount ($accounts[$remote_username]['user_id'], $accounts[$remote_username]['user_name'], $accounts[$remote_username]['user_realname'], hash (PASSWORD_HASH, $_REQUEST['newpassword1'])))
-               return buildRedirectURL_OK();
+               return buildRedirectURL ('OK');
        else
-               return buildRedirectURL_ERR ('Password change failed.');
+               return buildRedirectURL ('ERR4');
 }
 
 function saveRackCode ()
@@ -1272,12 +1270,12 @@ function saveRackCode ()
        $newcode = str_replace ('\r', '', str_replace ('\n', "\n", $_REQUEST['rackcode']));
        $parseTree = getRackCode ($newcode);
        if ($parseTree['result'] != 'ACK')
-               return buildRedirectURL_ERR ('Verification failed: ' . $parseTree['load']);
+               return buildRedirectURL ('ERR1', array ($parseTree['load']));
        saveScript ('RackCodeCache', '');
        if (saveScript ('RackCode', $newcode))
-               return buildRedirectURL_OK();
+               return buildRedirectURL ('OK');
        else
-               return buildRedirectURL_ERR ('Save failed.');
+               return buildRedirectURL ('ERR2');
 }
 
 // This handler's context is pre-built, but not authorized. It is assumed, that the
@@ -1288,7 +1286,7 @@ function setPortVLAN ()
        assertUIntArg ('portcount', __FUNCTION__);
        $data = getSwitchVLANs ($_REQUEST['object_id']);
        if ($data === NULL)
-               return buildRedirectURL_ERR ('getSwitchVLANs() failed');
+               return buildRedirectURL ('ERR1');
        list ($vlanlist, $portlist) = $data;
        // Here we just build up 1 set command for the gateway with all of the ports
        // included. The gateway is expected to filter unnecessary changes silently
@@ -1296,7 +1294,7 @@ function setPortVLAN ()
        // for each of the rest.
        $nports = $_REQUEST['portcount'];
        $prefix = 'set ';
-       $log = array();
+       $log = array ('v' => 1);
        $setcmd = '';
        for ($i = 0; $i < $nports; $i++)
                if