r1640 + initial implementation of Live PTR updating code
authorDenis Ovsienko <infrastation@yandex.ru>
Thu, 31 Jan 2008 18:23:38 +0000 (18:23 +0000)
committerDenis Ovsienko <infrastation@yandex.ru>
Thu, 31 Jan 2008 18:23:38 +0000 (18:23 +0000)
ChangeLog
inc/interface.php
inc/navigation.php
inc/ophandlers.php

index 3ba14d10e95fd4185535a83a304236ef07831f98..ac437f436875cb674cf1b5a5daa5ae4d7bdf82b2 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,8 +1,9 @@
 0.14.10
-       new feature: LDAP authentication
        bugfix: avoid hitting GET limit on object and rack update
        bugfix: sticker reset icon did not work sometimes
+       new feature: LDAP authentication
        new feature: borrow URL detection from Mantis BTS (suggested by Joakim Kasimir)
+       new feature: Live PTR tab for DNS sync
 0.14.9 2008-01-30
        bugfix: upgrade to 0.14.8 broke IPv4 prefix creation
        bugfix: more DB cleanups
index bf0c0fb8353196b56d74cb277cafccbe090db78f..d0c19f5fa1df6a3fd26fad90fcac014b60bf8f5a 100644 (file)
@@ -4305,8 +4305,17 @@ function renderLivePTR ($id = 0)
                else
                        echo "<a href='${root}?page=${pageno}&tab=${tabno}&id=$id&pg=$i'>$i</a> ";
        echo "</center>";
+
+       echo "<form method=post action=${root}process.php>";
+       echo "<input type=hidden name=page value=${pageno}>\n";
+       echo "<input type=hidden name=tab value=${tabno}>\n";
+       echo "<input type=hidden name=op value=import>\n";
+       echo "<input type=hidden name=id value=${id}>\n";
+       echo '<input type=hidden name=addrcount value=' . ($endip - $startip + 1) . ">\n";
+
        echo "<table class='widetable' border=0 cellspacing=0 cellpadding=5 align='center'>\n";
-       echo "<tr><th>address</th><th>current name</th><th>DNS data</th></tr>\n";
+       echo "<tr><th>address</th><th>current name</th><th>DNS data</th><th>import</th></tr>\n";
+       $idx = 0;
        for ($ip = $startip; $ip <= $endip; $ip++)
        {
                $addr = $range['addrlist'][$ip];
@@ -4314,26 +4323,39 @@ function renderLivePTR ($id = 0)
                $ptrname = gethostbyaddr ($straddr);
                if ($ptrname == $straddr)
                        $ptrname = '';
+               echo "<input type=hidden name=addr_${idx} value=${straddr}>\n";
+               echo "<input type=hidden name=descr_${idx} value=${ptrname}>\n";
+               echo "<input type=hidden name=rsvd_${idx} value=${addr['reserved']}>\n";
                echo '<tr';
+               $print_cbox = FALSE;
                if (empty ($addr['name']))
                {
                        if (!empty ($ptrname))
                                echo ' class=trwarning';
+                               $print_cbox = TRUE;
                }
                else
                {
                        if ($addr['name'] != $ptrname)
+                       {
                                echo ' class=trerror';
+                               $print_cbox = TRUE;
+                       }
                        else
                                echo ' class=trok';
                }
                echo "><td><a href='${root}?page=ipaddress&ip=${straddr}'>${straddr}</a></td>";
                echo "<td>${addr['name']}</td><td>";
                echo ($straddr == $ptrname) ? '&nbsp;' : $ptrname;
+               echo "</td><td>";
+               if ($print_cbox)
+                       echo "<input type=checkbox name=import_${idx}>";
+               else
+                       echo '&nbsp;';
                echo "</td></tr>\n";
        }
        echo "</table>";
-
+       echo "</form>";
 }
 
 ?>
index 87939bb22e2889e2a3127387d0af5ecd46970399..6d3d3f87c512513c9da233d5a302574d50da6f97 100644 (file)
@@ -126,6 +126,7 @@ $tabhandler['iprange']['default'] = 'renderIPRange';
 $tabhandler['iprange']['properties'] = 'renderIPRangeProperties';
 $tabhandler['iprange']['liveptr'] = 'renderLivePTR';
 $ophandler['iprange']['properties']['editRange'] = 'editRange';
+$ophandler['iprange']['import'] = 'importPTRData';
 
 $page['ipaddress']['title_handler'] = 'dynamic_title_ipaddress';
 $page['ipaddress']['parent'] = 'iprange';
index aeecc8626f44a8beb9ef3351213eda447640df91..fdaa219488c6f1f7682807285f5d324ecf2b50ec 100644 (file)
@@ -1176,4 +1176,34 @@ function updateRSInService ()
                return "${root}?page=${pageno}&tab=${tabno}&id=${pool_id}&error=" . urlencode ("Encountered ${nbad} errors, (de)activated ${ngood} real servers");
 }
 
+function importPTRData ()
+{
+       global $root, $pageno, $tabno;
+       assertUIntArg ('id');
+       assertUIntArg ('addrcount');
+       $nbad = $ngood = 0;
+       $id = $_REQUEST['id'];
+       for ($i = 0; $i < $_REQUEST['addrcount']; $i++)
+       {
+               $inputname = "import_${idx}";
+               if (!isset ($_REQUEST[$inputname]) or $_REQUEST[$inputname] != 'on')
+                       continue;
+               assertIPv4Arg ("addr_${i}");
+               assertStringArg ("descr_${i}");
+               assertStringArg ("rsvd_${i}");
+               if ($_REQUEST["rsvd_${i}"] == 'yes')
+                       $rsvd = 'yes';
+               else
+                       $rsvd = 'no';
+               if (commitUpdateAddress ($_REQUEST["addr_${i}"], $_REQUEST["descr_${i}"], $rsvd) == '')
+                       $ngood++;
+               else
+                       $nbad++;
+       }
+       if (!$nbad)
+               return "${root}?page=${pageno}&tab=${tabno}&id=${id}&message=" . urlencode ($ngood . " IP addresse(s) were successfully updated");
+       else
+               return "${root}?page=${pageno}&tab=${tabno}&id=${id}&error=" . urlencode ("Encountered ${nbad} errors, updated ${ngood} IP addresses");
+}
+
 ?>