r1873 + working on Protocols chapter decommission
authorDenis Ovsienko <infrastation@yandex.ru>
Sat, 12 Apr 2008 22:50:10 +0000 (22:50 +0000)
committerDenis Ovsienko <infrastation@yandex.ru>
Sat, 12 Apr 2008 22:50:10 +0000 (22:50 +0000)
inc/functions.php
inc/interface.php
inc/navigation.php
install/init-dictbase.sql
install/init-structure.sql
upgrade.php

index dff84292bf5e8481bbc79ce04c6e47d443f1fd9a..7c5c0e5093c5630520bc51cfec590fe8443ca4ec 100644 (file)
@@ -1083,17 +1083,14 @@ function updatePortForwarding($object_id, $localip, $localport, $remoteip, $remo
        return '';
 }
 
-function getObjectForwards($object_id)
+function getNATv4ForObject ($object_id)
 {
-       global $dbxlink;
-
        $ret = array();
        $ret['out'] = array();
        $ret['in'] = array();
        $query =
                "select ".
-               "dict_value as proto, ".
-               "proto as proto_bin, ".
+               "proto, ".
                "INET_NTOA(localip) as localip, ".
                "localport, ".
                "INET_NTOA(remoteip) as remoteip, ".
@@ -1101,25 +1098,25 @@ function getObjectForwards($object_id)
                "ipa1.name as local_addr_name, " .
                "ipa2.name as remote_addr_name, " .
                "description ".
-               "from PortForwarding inner join Dictionary on proto = dict_key natural join Chapter ".
+               "from PortForwarding ".
                "left join IPAddress as ipa1 on PortForwarding.localip = ipa1.ip " .
                "left join IPAddress as ipa2 on PortForwarding.remoteip = ipa2.ip " .
-               "where object_id='$object_id' and chapter_name = 'Protocols' ".
+               "where object_id='$object_id' ".
                "order by localip, localport, proto, remoteip, remoteport";
-       $result2 = $dbxlink->query ($query);
+       $result = useSelectBlade ($query);
        $count=0;
-       while ($row = $result2->fetch (PDO::FETCH_ASSOC))
+       while ($row = $result->fetch (PDO::FETCH_ASSOC))
        {
-               foreach (array ('proto', 'proto_bin', 'localport', 'localip', 'remoteport', 'remoteip', 'description', 'local_addr_name', 'remote_addr_name') as $cname)
+               foreach (array ('proto', 'localport', 'localip', 'remoteport', 'remoteip', 'description', 'local_addr_name', 'remote_addr_name') as $cname)
                        $ret['out'][$count][$cname] = $row[$cname];
                $count++;
        }
-       $result2->closeCursor();
+       $result->closeCursor();
+       unset ($result);
 
        $query =
                "select ".
-               "dict_value as proto, ".
-               "proto as proto_bin, ".
+               "proto, ".
                "INET_NTOA(localip) as localip, ".
                "localport, ".
                "INET_NTOA(remoteip) as remoteip, ".
@@ -1127,18 +1124,18 @@ function getObjectForwards($object_id)
                "PortForwarding.object_id as object_id, ".
                "RackObject.name as object_name, ".
                "description ".
-               "from ((PortForwarding join IPBonds on remoteip=IPBonds.ip) join RackObject on PortForwarding.object_id=RackObject.id) inner join Dictionary on proto = dict_key natural join Chapter ".
-               "where IPBonds.object_id='$object_id' and chapter_name = 'Protocols' ".
+               "from ((PortForwarding join IPBonds on remoteip=IPBonds.ip) join RackObject on PortForwarding.object_id=RackObject.id) ".
+               "where IPBonds.object_id='$object_id' ".
                "order by remoteip, remoteport, proto, localip, localport";
-       $result3 = $dbxlink->query ($query);
+       $result = useSelectBlade ($query);
        $count=0;
-       while ($row = $result3->fetch (PDO::FETCH_ASSOC))
+       while ($row = $result->fetch (PDO::FETCH_ASSOC))
        {
-               foreach (array ('proto', 'proto_bin', 'localport', 'localip', 'remoteport', 'remoteip', 'object_id', 'object_name', 'description') as $cname)
+               foreach (array ('proto', 'localport', 'localip', 'remoteport', 'remoteip', 'object_id', 'object_name', 'description') as $cname)
                        $ret['in'][$count][$cname] = $row[$cname];
                $count++;
        }
-       $result3->closeCursor();
+       $result->closeCursor();
 
        return $ret;
 }
index 8f028d3d246dafa33298cc1d794fb6086c497c93..00f4df88d108336db5e4d92a53ae54422968c814 100644 (file)
@@ -856,7 +856,7 @@ function renderRackObject ($object_id = 0)
                finishPortlet();
        }
 
-       $forwards = getObjectForwards ($object_id);
+       $forwards = getNATv4ForObject ($object_id);
        if (count($forwards['in']) or count($forwards['out']))
        {
                startPortlet('NATv4');
@@ -2407,12 +2407,12 @@ function renderIPAddressAssignment ()
 
 }
 
-function renderIPAddressPortForwarding ($object_id=0)
+function renderNATv4ForObject ($object_id = 0)
 {
        global $pageno, $tabno, $root;
        
        $info = getObjectInfo ($object_id);
-       $forwards = getObjectForwards ($object_id);
+       $forwards = getNATv4ForObject ($object_id);
        $addresses = getObjectAddresses ($object_id);
        showMessageOrError();
        echo "<center><h2>locally performed NAT</h2></center>";
@@ -2433,7 +2433,7 @@ function renderIPAddressPortForwarding ($object_id=0)
                        }
 
                echo "<tr class='$class'>";
-               echo "<td><a href='process.php?op=delPortForwarding&localip=${pf['localip']}&localport=${pf['localport']}&remoteip=${pf['remoteip']}&remoteport=${pf['remoteport']}&proto=${pf['proto_bin']}&object_id=$object_id&page=${pageno}&tab=${tabno}'>";
+               echo "<td><a href='process.php?op=delPortForwarding&localip=${pf['localip']}&localport=${pf['localport']}&remoteip=${pf['remoteip']}&remoteport=${pf['remoteport']}&proto=${pf['proto']}&object_id=$object_id&page=${pageno}&tab=${tabno}'>";
                printImageHREF ('delete', 'Delete NAT rule');
                echo "</a></td>";
                echo "<td>${pf['proto']}/${name}: <a href='${root}?page=ipaddress&tab=default&ip=${pf['localip']}'>${pf['localip']}</a>:${pf['localport']}";
@@ -2450,7 +2450,12 @@ function renderIPAddressPortForwarding ($object_id=0)
                                echo "<a href='${root}?page=object&tab=default&object_id=${bond['object_id']}'>${bond['object_name']}(${bond['name']})</a> ";
                elseif (!empty ($pf['remote_addr_name']))
                        echo '(' . $pf['remote_addr_name'] . ')';
-               echo "</td><form action='process.php'><input type='hidden' name='op' value='updPortForwarding'><input type=hidden name=page value='${pageno}'><input type=hidden name=tab value='${tabno}'><input type='hidden' name='object_id' value='$object_id'><input type='hidden' name='localip' value='${pf['localip']}'><input type='hidden' name='localport' value='${pf['localport']}'><input type='hidden' name='remoteip' value='${pf['remoteip']}'><input type='hidden' name='remoteport' value='${pf['remoteport']}'><input type='hidden' name='proto' value='${pf['proto_bin']}'><td class='description'><input type='text' name='description' value='${pf['description']}'> <input type='submit' value='OK'></td></form>";
+               echo "</td><form action='process.php'><input type='hidden' name='op' value='updPortForwarding'><input type=hidden name=page value='${pageno}'>";
+               echo "<input type=hidden name=tab value='${tabno}'><input type='hidden' name='object_id' value='$object_id'>";
+               echo "<input type='hidden' name='localip' value='${pf['localip']}'><input type='hidden' name='localport' value='${pf['localport']}'>";
+               echo "<input type='hidden' name='remoteip' value='${pf['remoteip']}'><input type='hidden' name='remoteport' value='${pf['remoteport']}'>";
+               echo "<input type='hidden' name='proto' value='${pf['proto']}'><td class='description'>";
+               echo "<input type='text' name='description' value='${pf['description']}'> <input type='submit' value='OK'></td></form>";
                echo "</tr>";
        }
        echo "<form action='process.php'><input type='hidden' name='op' value='forwardPorts'>";
@@ -2458,7 +2463,7 @@ function renderIPAddressPortForwarding ($object_id=0)
        echo "<input type=hidden name=page value='${pageno}'>\n";
        echo "<input type=hidden name=tab value='${tabno}'>\n";
        echo "<tr align='center'><td colspan=2>";
-       printSelect (readChapter ('Protocols'), 'proto');
+       printSelect (array ('TCP' => 'TCP', 'UDP' => 'UDP'), 'proto');
        echo "<select name='localip' tabindex=1>";
 
        foreach ($addresses as $addr)
@@ -2476,16 +2481,13 @@ function renderIPAddressPortForwarding ($object_id=0)
 
        echo "</table><br><br>";
 
-
        echo "<center><h2>arriving NAT connections</h2></center>";
        echo "<table class='widetable' cesspadding=5 cellspacing=0 border=0 align='center'>\n";
        echo "<tr><th></th><th>Source</th><th>Source objects</th><th>Target</th><th>Description</th></tr>\n";
 
        foreach ($forwards['in'] as $pf)
        {
-               echo "<tr>";
-
-               echo "<td><a href='process.php?op=delPortForwarding&localip=${pf['localip']}&localport=${pf['localport']}&remoteip=${pf['remoteip']}&remoteport=${pf['remoteport']}&proto=${pf['proto_bin']}&object_id=${pf['object_id']}&page=${pageno}&tab=${tabno}'>";
+               echo "<tr><td><a href='process.php?op=delPortForwarding&localip=${pf['localip']}&localport=${pf['localport']}&remoteip=${pf['remoteip']}&remoteport=${pf['remoteport']}&proto=${pf['proto']}&object_id=${pf['object_id']}&page=${pageno}&tab=${tabno}'>";
                printImageHREF ('delete', 'Delete NAT rule');
                echo "</a></td>";
                echo "<td>${pf['proto']}/<a href='${root}?page=ipaddress&tab=default&ip=${pf['localip']}'>${pf['localip']}</a>:${pf['localport']}</td>";
@@ -2494,19 +2496,7 @@ function renderIPAddressPortForwarding ($object_id=0)
                echo "<td class='description'>${pf['description']}</td></tr>";
        }
 
-//     echo "<form action='process.php'><input type='hidden' name='op' value='forwardPorts'>";
-//     echo "<input type='hidden' name='object_id' value='$object_id'>";
-//     echo "<input type=hidden name=page value='${pageno}'>\n";
-//     echo "<input type=hidden name=tab value='${tabno}'>\n";
-//     echo "<tr align='center'><td colspan=2><select name='proto'><option value='1'>TCP</option><option value='2'>UDP</option><input type='text' name='localip' size='10'>:<input type='text' name='localport' size='4'></td><td><select name='localip'>";
-//     foreach ($addresses as $addr)
-//             echo "<option value='${addr['ip']}'>${addr['ip']}</option>";
-//
-//     echo "</select>:<input type='text' name='remoteport' size='4'></td><td><input type='text' name='description' size='20'></td><td><input type='submit' value='Create Forwarding'></td></tr>";
-//     echo "</form>";
        echo "</table><br><br>";
-
-
 }
 
 
index d4232a3abb46be3a5ebfec1c2e61930ce6ec5bb5..28287588946a9045306f88d0a2abf468d5514ac2 100644 (file)
@@ -93,7 +93,7 @@ $tabhandler['object']['edit'] = 'renderEditObjectForm';
 $tabhandler['object']['rackspace'] = 'renderRackSpaceForObject';
 $tabhandler['object']['ports'] = 'renderPortsForObject';
 $tabhandler['object']['network'] = 'renderNetworkForObject';
-$tabhandler['object']['portfwrd'] = 'renderIPAddressPortForwarding';
+$tabhandler['object']['portfwrd'] = 'renderNATv4ForObject';
 $tabhandler['object']['switchvlans'] = 'renderVLANMembership';
 $tabhandler['object']['snmpportfinder'] = 'renderSNMPPortFinder';
 $tabhandler['object']['lvsconfig'] = 'renderLVSConfig';
index 13c84f977c99145ae7064323b9af369388e93df8..b76d0b40d2ac53c6e128842fda8c63dca6b66ccb 100644 (file)
@@ -88,7 +88,6 @@ INSERT INTO `Chapter` (`chapter_no`, `sticky`, `chapter_name`) VALUES (16,'no','
 INSERT INTO `Chapter` (`chapter_no`, `sticky`, `chapter_name`) VALUES (17,'no','router models');
 INSERT INTO `Chapter` (`chapter_no`, `sticky`, `chapter_name`) VALUES (18,'no','disk array models');
 INSERT INTO `Chapter` (`chapter_no`, `sticky`, `chapter_name`) VALUES (19,'no','tape library models');
-INSERT INTO `Chapter` (`chapter_no`, `sticky`, `chapter_name`) VALUES (20,'yes','Protocols');
 INSERT INTO `Chapter` (`chapter_no`, `sticky`, `chapter_name`) VALUES (21,'no','KVM switch models');
 INSERT INTO `Chapter` (`chapter_no`, `sticky`, `chapter_name`) VALUES (22,'no','multiplexer models');
 INSERT INTO `Chapter` (`chapter_no`, `sticky`, `chapter_name`) VALUES (23, 'no', 'console models');
@@ -213,8 +212,6 @@ INSERT INTO `Dictionary` (`chapter_no`, `dict_key`, `dict_value`) VALUES (2,38,'
 INSERT INTO `Dictionary` (`chapter_no`, `dict_key`, `dict_value`) VALUES (2,39,'10GBase-LX4');
 INSERT INTO `Dictionary` (`chapter_no`, `dict_key`, `dict_value`) VALUES (2,40,'10GBase-CX4');
 INSERT INTO `Dictionary` (`chapter_no`, `dict_key`, `dict_value`) VALUES (2,41,'10GBase-Kx');
-INSERT INTO `Dictionary` (`chapter_no`, `dict_key`, `dict_value`) VALUES (20,336,'TCP');
-INSERT INTO `Dictionary` (`chapter_no`, `dict_key`, `dict_value`) VALUES (20,337,'UDP');
 INSERT INTO `Dictionary` (`chapter_no`, `dict_key`, `dict_value`) VALUES (2,439,'dry contact');
 INSERT INTO `Dictionary` (`chapter_no`, `dict_key`, `dict_value`) VALUES (2,440,'unknown');
 INSERT INTO `Dictionary` (`chapter_no`, `dict_key`, `dict_value`) VALUES (1,445,'KVM switch');
index 99eb39d00713fb9648c7490fe27e458d772a255d..e39c7aa5e25e253f32e9610a1c65f06469e91d56 100644 (file)
@@ -158,7 +158,7 @@ CREATE TABLE `PortCompat` (
 
 CREATE TABLE `PortForwarding` (
   `object_id` int(10) unsigned NOT NULL,
-  `proto` int(11) NOT NULL,
+  `proto` enum('TCP','UDP') not null default 'TCP',
   `localip` int(10) unsigned NOT NULL,
   `localport` smallint(5) unsigned NOT NULL,
   `remoteip` int(10) unsigned NOT NULL,
index 58c9e0ae3811d5b397bf693b5f04fb6151f8c68b..4b2c91e8516acb8e6a1bd2f1a019c9ad1389ca78 100644 (file)
@@ -1252,6 +1252,16 @@ CREATE TABLE `TagTree` (
                        $query[] = "INSERT INTO `Config` (varname, varvalue, vartype, emptyok, is_hidden, description) VALUES ('SHOW_EXPLICIT_TAGS','yes','string','no','no','Show explicit tags')";
                        $query[] = "INSERT INTO `Config` (varname, varvalue, vartype, emptyok, is_hidden, description) VALUES ('SHOW_IMPLICIT_TAGS','yes','string','no','no','Show implicit tags')";
                        $query[] = "INSERT INTO `Config` (varname, varvalue, vartype, emptyok, is_hidden, description) VALUES ('SHOW_AUTOMATIC_TAGS','no','string','no','no','Show automatic tags')";
+                       // Decommission the Protocols dictionary chapter.
+                       $query[] = "alter table PortForwarding add column proto_new enum('TCP','UDP') not null default 'TCP' after proto";
+                       $query[] = "update PortForwarding set proto_new = 'TCP' where proto = 336";
+                       $query[] = "update PortForwarding set proto_new = 'UDP' where proto = 337";
+                       $query[] = "alter table PortForwarding drop primary key";
+                       $query[] = "alter table PortForwarding drop column proto";
+                       $query[] = "alter table PortForwarding change column proto_new proto enum('TCP','UDP') not null default 'TCP'";
+                       $query[] = "alter table PortForwarding add primary key (`object_id`,`proto`,`localip`,`localport`,`remoteip`,`remoteport`)";
+                       $query[] = "delete from Dictionary where chapter_no = 20";
+                       $query[] = "delete from Chapter where chapter_no = 20";
                        $query[] = "update Config set varvalue = '0.14.13' where varname = 'DB_VERSION'";
                        break; // --------------------------------------------
 #              case '0.14.14':