Ejemplo n.º 1
0
function list_subnets()
{
    global $COLLATE;
    global $dbo;
    $block_id = isset($_GET['block_id']) && is_numeric($_GET['block_id']) ? $_GET['block_id'] : '';
    if (!isset($_GET['block_id']) || empty($_GET['block_id'])) {
        $notice = "invalidrequest";
        header("Location: blocks.php?notice={$notice}");
        exit;
    }
    $block_id = $_GET['block_id'];
    $sort = !isset($_GET['sort']) ? '' : $_GET['sort'];
    if ($sort == 'network') {
        $sort = 'start_ip';
    } else {
        $sort = 'name';
    }
    $sql = "SELECT `name` FROM `blocks` WHERE `id` = '{$block_id}'";
    $result = $dbo->query($sql);
    if ($result->rowCount() !== 1) {
        $notice = "invalidrequest";
        header("Location: blocks.php?notice={$notice}");
        exit;
    }
    require_once './include/header.php';
    $block_name = $result->fetchColumn();
    $blocknamesubnets = str_replace("%block_name%", $block_name, $COLLATE['languages']['selected']['BlockSubnets']);
    echo "<h1>{$blocknamesubnets}</h1>\n" . "<div style=\"float: left; width: 70%;\">";
    $sql = "SELECT `id`, `name`, `start_ip`, `end_ip`, `mask`, `note` FROM `subnets` \r\n      WHERE `block_id` = '{$block_id}' ORDER BY `{$sort}` ASC";
    $hiddenformvars = "<input type=\"hidden\" name=\"block_id\" value=\"{$block_id}\" />" . "<input type=\"hidden\" name=\"sort\" value=\"{$sort}\" />";
    # page selector here
    $updatedsql = pageselector($sql, $hiddenformvars);
    $row = $dbo->query($updatedsql);
    $rows = $row->rowCount();
    echo "</div>\n" . "<a href=\"subnets.php?op=add&amp;block_id={$block_id}\">\n" . "<div style=\"float: left; width: 25%; text-align:right; padding:5px;\">" . "<img src=\"./images/add.gif\" alt=\"\" /> " . $COLLATE['languages']['selected']['AllocateaSubnet'] . " </a></div><p style=\"clear: left; display: done;\">\n";
    echo "<table style=\"width: 100%\">\n" . "<tr><th style=\"text-align: left\"><a href=\"subnets.php?block_id={$block_id}&amp;sort=name\">" . $COLLATE['languages']['selected']['SubnetName'] . "</a></th>" . "<th style=\"text-align: left\"><a href=\"subnets.php?block_id={$block_id}&amp;sort=network\">" . $COLLATE['languages']['selected']['NetworkAddress'] . "</a></th>" . "<th style=\"text-align: left\">" . $COLLATE['languages']['selected']['SubnetMask'] . "</th>" . "<th style=\"text-align: left\">" . $COLLATE['languages']['selected']['StaticsUsed'] . "</th><th></th></tr>\n" . "<tr><td colspan=\"5\"><hr class=\"head\" /></td></tr>\n";
    $javascript = '';
    # This gets concatenated to below.
    while (list($subnet_id, $name, $long_start_ip, $long_end_ip, $long_mask, $note) = $row->fetch(PDO::FETCH_NUM)) {
        $start_ip = long2ip($long_start_ip);
        $mask = long2ip($long_mask);
        $subnet_size = $long_end_ip - $long_start_ip;
        $in_color = true;
        if ($subnet_size > 4) {
            # only calculate usage if larger than a /30
            $percent_subnet_used = get_formatted_subnet_util($subnet_id, $subnet_size, $in_color);
        } else {
            $percent_subnet_used = '<td style=\\"color:green"></td>';
        }
        echo "<tr id=\"subnet_" . $subnet_id . "_row_1\">\r\n         <td><a href=\"statics.php?subnet_id={$subnet_id}\"><img src=\"images/subnet.png\" alt=\"\"></a> &nbsp; \r\n\t\t <b><span id=\"edit_name_" . $subnet_id . "\">{$name}</span></b></td><td><a href=\"statics.php?subnet_id={$subnet_id}\">{$start_ip}</a></td>\r\n         <td>{$mask}</td>{$percent_subnet_used}\r\n         <td style=\"text-align: right;\">";
        if ($COLLATE['user']['accesslevel'] >= '3' || $COLLATE['settings']['perms'] > '3') {
            echo "<a href=\"subnets.php?op=modify&amp;subnet_id={$subnet_id}\"><img alt=\"modify subnet\" title=\"" . $COLLATE['languages']['selected']['modifysubnet'] . "\" src=\"images/modify.gif\" /></a> &nbsp; " . "<a href=\"#\" onclick=\"\r\n           if (confirm('" . $COLLATE['languages']['selected']['confirmdelete'] . "')) { \r\n             new Element.update('subnet_" . $subnet_id . "_notice', ''); \r\n             new Ajax.Updater('subnet_" . $subnet_id . "_notice', '_subnets.php?op=delete&subnet_id={$subnet_id}', {onSuccess:function(){ \r\n               new Effect.Parallel( [\r\n                 new Effect.Fade('subnet_" . $subnet_id . "_row_1'), \r\n                 new Effect.Fade('subnet_" . $subnet_id . "_row_2'), \r\n                 new Effect.Fade('subnet_" . $subnet_id . "_row_3'), \r\n                 new Effect.Fade('subnet_" . $subnet_id . "_row_4')\r\n               ]); \r\n             }}); \r\n           };\r\n           return false;\"><img src=\"./images/remove.gif\" alt=\"X\" title=\"" . $COLLATE['languages']['selected']['deletesubnet'] . "\" /></a>";
        }
        echo "</td>\r\n         </tr>\n";
        echo "<tr id=\"subnet_" . $subnet_id . "_row_2\"><td colspan=\"4\"><span id=\"edit_note_" . $subnet_id . "\">{$note}</span></td><td></td></tr>\n";
        echo "<tr id=\"subnet_" . $subnet_id . "_row_3\"><td colspan=\"5\"><span id=\"subnet_" . $subnet_id . "_notice\" class=\"tip\"></span></td></tr>\n";
        echo "<tr id=\"subnet_" . $subnet_id . "_row_4\"><td colspan=\"5\"><hr class=\"division\" /></td></tr>\n";
        if ($COLLATE['user']['accesslevel'] >= '3' || $COLLATE['settings']['perms'] > '3') {
            $javascript .= "<script type=\"text/javascript\"><!--\n" . "  new Ajax.InPlaceEditorWithEmptyText('edit_name_" . $subnet_id . "', '_subnets.php?op=edit&subnet_id={$subnet_id}&edit=name',\r\n              {\r\n               clickToEditText: '" . $COLLATE['languages']['selected']['ClicktoEdit'] . "',\r\n               highlightcolor: '#a5ddf8', \r\n               callback:\r\n                function(form) {\r\n                  new Element.update('subnet_" . $subnet_id . "_notice', '');\r\n                  return Form.serialize(form);\r\n                },\r\n               onFailure: \r\n                function(transport, ipe) {\r\n                  new Element.update('subnet_" . $subnet_id . "_notice', ipe.responseText.stripTags());\r\n                }\r\n              }\r\n              );\n" . "  new Ajax.InPlaceEditorWithEmptyText('edit_note_" . $subnet_id . "', '_subnets.php?op=edit&subnet_id={$subnet_id}&edit=note',\r\n              {\r\n               clickToEditText: '" . $COLLATE['languages']['selected']['ClicktoEdit'] . "',\r\n               highlightcolor: '#a5ddf8',  \r\n               callback:\r\n                function(form) {\r\n                  new Element.update('subnet_" . $subnet_id . "_notice', '');\r\n                  return Form.serialize(form);\r\n                },\r\n               onFailure: \r\n                function(transport, ipe) {\r\n                  new Element.update('subnet_" . $subnet_id . "_notice', ipe.responseText.stripTags());\r\n                }\r\n              }\r\n              );\n" . "--></script>\n";
        }
    }
    echo "</table>";
    pageselector($sql, $hiddenformvars);
    echo $javascript;
    require_once "include/footer.php";
    exit;
}
Ejemplo n.º 2
0
function search()
{
    global $COLLATE;
    global $dbo;
    $export = !isset($_GET['export']) ? 'off' : $_GET['export'];
    # set these for hidden forms. They'll be reset by return data from build_search_sql()
    $first = isset($_GET['first']) ? $_GET['first'] : '';
    $second = isset($_GET['second']) ? $_GET['second'] : '';
    $search = isset($_GET['search']) ? $_GET['search'] : '';
    $fromdate = isset($_GET['fromdate']) ? $_GET['fromdate'] : '';
    $todate = isset($_GET['todate']) ? $_GET['todate'] : '';
    $when = $fromdate == $todate ? 'all' : 'dates';
    $sort = isset($_GET['sort']) ? $_GET['sort'] : '';
    if ($export == "on") {
        // The download function is a separate page
        $uri = $_SERVER['REQUEST_URI'];
        $uri = str_replace("op=search", "op=download", $uri);
        header("Location: {$uri}");
        exit;
    }
    $tmparray = build_search_sql();
    $sql = $tmparray["sql"];
    $unsortedrequesturl = "search.php?op=search&amp;first={$first}&amp;second={$second}&amp;" . "search={$search}&amp;when={$when}&amp;fromdate={$fromdate}&amp;" . "todate={$todate}&amp;page=1&amp;";
    require_once 'include/header.php';
    $hiddenformvars = "<input type=\"hidden\" name=\"op\" value=\"search\" />\r\n\t                 <input type=\"hidden\" name=\"first\" value=\"{$first}\" />\r\n\t                 <input type=\"hidden\" name=\"second\" value=\"{$second}\" />\r\n\t\t             <input type=\"hidden\" name=\"search\" value=\"{$search}\" />\r\n\t\t             <input type=\"hidden\" name=\"when\" value=\"{$when}\" />\r\n\t\t             <input type=\"hidden\" name=\"fromdate\" value=\"{$fromdate}\" />\r\n\t\t             <input type=\"hidden\" name=\"todate\" value=\"{$todate}\" />\r\n\t\t\t\t\t <input type=\"hidden\" name=\"sort\" value=\"{$sort}\" />";
    $updatedsql = pageselector($sql, $hiddenformvars);
    $row = $dbo->query($updatedsql);
    $rows = $row->rowCount();
    $searchdescription = $tmparray["searchdescription"];
    $first = $tmparray["first"];
    $First = $tmparray["First"];
    $second = $tmparray["second"];
    $Second = $tmparray["Second"];
    $search = $tmparray["search"];
    $when = $tmparray["when"];
    $todate = $tmparray["todate"];
    $fromdate = $tmparray["fromdate"];
    $sort = $tmparray["sort"];
    echo $COLLATE['languages']['selected']['SearchResults'];
    if ($second == 'failed_scans') {
        $SearchResultsText = str_replace("%search%", "{$search}", $COLLATE['languages']['selected']['failedscansearch']);
    } else {
        $SearchResultsText = str_replace("%first%", "{$first}", $COLLATE['languages']['selected']['generalsearchterm']);
        $SearchResultsText = str_replace("%second%", "{$second}", $SearchResultsText);
        $SearchResultsText = str_replace("%search%", "{$search}", $SearchResultsText);
        $SearchResultsText = str_replace("%searchdescription%", "{$searchdescription}", $SearchResultsText);
    }
    echo "{$SearchResultsText}</p>\n<hr class=\"head\" />\n";
    if ($rows == 0) {
        if ($first == 'static IPs' && $second == 'ip') {
            header("Location: search.php?op=search&first=1&second=ip&search={$search}&notice=nostaticsfound-notice");
            exit;
        } else {
            echo "<p><b>" . $COLLATE['languages']['selected']['nosearchresults'] . "</b></p>";
            require_once './include/footer.php';
            exit;
        }
    }
    if ($first == "blocks") {
        echo "<table style=\"width: 100%\">\n" . "<tr><th style=\"text-align: left\"><a href=\"" . $unsortedrequesturl . "sort=name\">" . $COLLATE['languages']['selected']['BlockName'] . "</a></th>" . "<th style=\"text-align: left\"><a href=\"" . $unsortedrequesturl . "sort=network\">" . $COLLATE['languages']['selected']['StartingIP'] . "</a></th>" . "<th style=\"text-align: left\">" . $COLLATE['languages']['selected']['EndIP'] . "</th>" . "</tr>\n" . "<tr><td colspan=\"4\"><hr class=\"head\" /></td></tr>\n";
        $javascript = '';
        # this gets concatenated to below
        while (list($block_id, $name, $long_start_ip, $long_end_ip, $note, $block_type) = $row->fetch(PDO::FETCH_NUM)) {
            $link_target = $block_type == 'container' ? "blocks.php?block_id={$block_id}" : "subnets.php?block_id={$block_id}";
            if (empty($long_start_ip)) {
                $start_ip = $COLLATE['languages']['selected']['Browse'];
                $end_ip = '';
            } else {
                $start_ip = long2ip($long_start_ip);
                $end_ip = long2ip($long_end_ip);
            }
            echo "<tr id=\"block_" . $block_id . "_row_1\"><td><a href=\"{$link_target}\">";
            echo $block_type == 'container' ? "<img src=\"images/container_block.png\" alt=\"\">" : "<img src=\"images/ip_block.png\" alt=\"\">";
            echo "</a> &nbsp; <b><span id=\"edit_name_" . $block_id . "\">{$name}</span></b></td>\r\n            <td><a href=\"{$link_target}\">{$start_ip}</a></td>\r\n            <td>{$end_ip}</td>\r\n            <td style=\"text-align: right;\">";
            if ($COLLATE['user']['accesslevel'] >= '4' || $COLLATE['settings']['perms'] > '4') {
                echo "<a href=\"blocks.php?op=modify&amp;block_id={$block_id}\"><img alt=\"modify block\" title=\"" . $COLLATE['languages']['selected']['modifyblock'] . "\" src=\"images/modify.gif\" /></a> &nbsp; " . " <a href=\"#\" onclick=\"\r\n               if (confirm('" . $COLLATE['languages']['selected']['confirmdelete'] . "')) { \r\n      \t\t   new Element.update('block_" . $block_id . "_notice', ''); \r\n      \t\t   new Ajax.Updater('block_" . $block_id . "_notice', '_blocks.php?op=delete&amp;block_id={$block_id}', {onSuccess:function(){ \r\n      \t\t     new Effect.Parallel( [new Effect.Fade('block_" . $block_id . "_row_1'), \r\n      \t\t\t new Effect.Fade('block_" . $block_id . "_row_2'), \r\n      \t\t\t new Effect.Fade('block_" . $block_id . "_row_3'), \r\n      \t\t\t new Effect.Fade('block_" . $block_id . "_row_4')]); \r\n                   }}); \r\n      \t\t };\r\n      \t\t return false;\">\r\n      \t\t <img src=\"./images/remove.gif\" alt=\"X\" /></a>";
            }
            echo "</td>\r\n            </tr>\n";
            echo "<tr id=\"block_" . $block_id . "_row_2\"><td colspan=\"2\"><span id=\"edit_note_" . $block_id . "\">{$note}</span></td></tr>\n";
            echo "<tr id=\"block_" . $block_id . "_row_3\"><td colspan=\"3\"><span id=\"block_" . $block_id . "_notice\" class=\"tip\"></span></td></tr>\n";
            echo "<tr id=\"block_" . $block_id . "_row_4\"><td colspan=\"4\"><hr class=\"division\" /></td></tr>\n";
            if ($COLLATE['user']['accesslevel'] >= '4' || $COLLATE['settings']['perms'] > '4') {
                $javascript .= "<script type=\"text/javascript\"><!--\n" . "  new Ajax.InPlaceEditorWithEmptyText('edit_name_" . $block_id . "', '_blocks.php?op=edit&block_id={$block_id}&edit=name',\r\n      \t      {\r\n      \t\t   clickToEditText: '" . $COLLATE['languages']['selected']['ClicktoEdit'] . "',\r\n      \t\t   highlightcolor: '#a5ddf8', \r\n      \t\t   callback:\r\n      \t\t    function(form) {\r\n      \t\t      new Element.update('block_" . $block_id . "_notice', '');\r\n      \t\t\t  return Form.serialize(form);\r\n      \t\t    },\r\n      \t\t   onFailure: \r\n      \t\t    function(transport, ipe) {\r\n      \t\t      new Element.update('block_" . $block_id . "_notice', ipe.responseText.stripTags());\r\n      \t\t    }\r\n      \t\t  }\r\n      \t\t  );\n" . "  new Ajax.InPlaceEditorWithEmptyText('edit_note_" . $block_id . "', '_blocks.php?op=edit&block_id={$block_id}&edit=note',\r\n      \t      {\r\n      \t\t   clickToEditText: '" . $COLLATE['languages']['selected']['ClicktoEdit'] . "',\r\n      \t\t   highlightcolor: '#a5ddf8',  \r\n      \t\t   callback:\r\n      \t\t    function(form) {\r\n      \t\t      new Element.update('block_" . $block_id . "_notice', '');\r\n      \t\t\t  return Form.serialize(form);\r\n      \t\t    },\r\n      \t\t   onFailure: \r\n      \t\t    function(transport, ipe) {\r\n      \t\t      new Element.update('block_" . $block_id . "_notice', ipe.responseText.stripTags());\r\n      \t\t    }\r\n      \t\t  }\r\n      \t\t  );\n" . "--></script>\n";
            }
        }
        echo "</table>";
    } elseif ($first == "subnets") {
        echo "<table style=\"width: 100%\">\n" . "<tr><th style=\"text-align: left\"><a href=\"" . $unsortedrequesturl . "sort=name\">" . $COLLATE['languages']['selected']['SubnetName'] . "</th>" . "<th style=\"text-align: left\">" . $COLLATE['languages']['selected']['Block'] . "</th>" . "<th style=\"text-align: left\"><a href=\"" . $unsortedrequesturl . "sort=network\">" . $COLLATE['languages']['selected']['NetworkAddress'] . "</th>" . "<th style=\"text-align: left\">" . $COLLATE['languages']['selected']['SubnetMask'] . "</th>" . "<th style=\"text-align: left\">" . $COLLATE['languages']['selected']['StaticsUsed'] . "</th></tr>\n" . "<tr><td colspan=\"6\"><hr class=\"head\" /></td></tr>\n";
        $javascript = '';
        # this gets appended to in the following while loop
        while (list($subnet_id, $name, $long_start_ip, $long_end_ip, $long_mask, $note, $block_id) = $row->fetch(PDO::FETCH_NUM)) {
            $start_ip = long2ip($long_start_ip);
            $mask = long2ip($long_mask);
            if (!isset($block_name[$block_id])) {
                // Only look up the block name if we haven't seen the block_id yet on this page
                $blocknamesql = "SELECT `name` FROM `blocks` WHERE `id` = '{$block_id}'";
                $result = $dbo->query($blocknamesql);
                $block_name[$block_id] = $result->fetchColumn();
            }
            $subnet_size = $long_end_ip - $long_start_ip;
            $in_color = true;
            $percent_subnet_used = get_formatted_subnet_util($subnet_id, $subnet_size, $in_color);
            echo "<tr id=\"subnet_" . $subnet_id . "_row_1\">\r\n           <td><a href=\"statics.php?subnet_id={$subnet_id}\"><img src=\"images/subnet.png\" alt=\"\"></a> &nbsp;\r\n\t\t   <b><span id=\"edit_name_" . $subnet_id . "\">{$name}</span></b></td><td><a href=\"subnets.php?block_id={$block_id}\">" . $block_name[$block_id] . "</a>" . "</td><td><a href=\"statics.php?subnet_id={$subnet_id}\">{$start_ip}</a></td>\r\n           <td>{$mask}</td>{$percent_subnet_used}\r\n           <td>";
            if ($COLLATE['user']['accesslevel'] >= '3' || $COLLATE['settings']['perms'] > '3') {
                echo "<a href=\"subnets.php?op=modify&amp;subnet_id={$subnet_id}\"><img title=\"" . $COLLATE['languages']['selected']['modifysubnet'] . "\"" . "src=\"images/modify.gif\" /></a> &nbsp; " . "<a href=\"#\" onclick=\"\r\n\t\t\t if (confirm('" . $COLLATE['languages']['selected']['confirmdelete'] . "')) {\r\n               new Element.update('subnet_" . $subnet_id . "_notice', ''); \r\n\t\t\t   new Ajax.Updater('subnet_" . $subnet_id . "_notice', '_subnets.php?op=delete&amp;subnet_id={$subnet_id}', \r\n\t\t\t   {onSuccess:function(){ \r\n\t\t\t     new Effect.Parallel( [\r\n\t\t\t\t   new Effect.Fade('subnet_" . $subnet_id . "_row_1'), \r\n\t\t\t\t   new Effect.Fade('subnet_" . $subnet_id . "_row_2'), \r\n\t\t\t\t   new Effect.Fade('subnet_" . $subnet_id . "_row_3'), \r\n                   new Effect.Fade('subnet_" . $subnet_id . "_row_4')]);\r\n               }}); \r\n\t\t\t }; return false;\"><img src=\"./images/remove.gif\" alt=\"X\" title=\"" . $COLLATE['languages']['selected']['deletesubnet'] . "\" /></a>";
            }
            echo "</td></tr>\n";
            echo "<tr id=\"subnet_" . $subnet_id . "_row_2\"><td colspan=\"5\"><span id=\"edit_note_" . $subnet_id . "\">{$note}</span></td></tr>\n";
            echo "<tr id=\"subnet_" . $subnet_id . "_row_3\"><td colspan=\"6\"><span id=\"subnet_" . $subnet_id . "_notice\" class=\"tip\"></span></td></tr>\n";
            echo "<tr id=\"subnet_" . $subnet_id . "_row_4\"><td colspan=\"6\"><hr class=\"division\" /></td></tr>\n";
            if ($COLLATE['user']['accesslevel'] >= '3' || $COLLATE['settings']['perms'] > '3') {
                $javascript .= "<script type=\"text/javascript\"><!--\n" . "  new Ajax.InPlaceEditorWithEmptyText('edit_name_" . $subnet_id . "', '_subnets.php?op=edit&subnet_id={$subnet_id}&edit=name',\r\n              {\r\n\t\t\t  clickToEditText: '" . $COLLATE['languages']['selected']['ClicktoEdit'] . "',\r\n\t\t\t  highlightcolor: '#a5ddf8', \r\n              callback:\r\n               function(form) {\r\n                 new Element.update('subnet_" . $subnet_id . "_notice', '');\r\n                 return Form.serialize(form);\r\n               },\r\n              onFailure: \r\n               function(transport, ipe) {\r\n                 new Element.update('subnet_" . $subnet_id . "_notice', ipe.responseText.stripTags());\r\n               }\r\n            }\r\n            );\n" . "  new Ajax.InPlaceEditorWithEmptyText('edit_note_" . $subnet_id . "', '_subnets.php?op=edit&subnet_id={$subnet_id}&edit=note',\r\n              {\r\n\t\t\t  clickToEditText: '" . $COLLATE['languages']['selected']['ClicktoEdit'] . "',\r\n\t\t\t  highlightcolor: '#a5ddf8',  \r\n              callback:\r\n               function(form) {\r\n                 new Element.update('subnet_" . $subnet_id . "_notice', '');\r\n                 return Form.serialize(form);\r\n               },\r\n              onFailure: \r\n               function(transport, ipe) {\r\n                 new Element.update('subnet_" . $subnet_id . "_notice', ipe.responseText.stripTags());\r\n               }\r\n            }\r\n            );\n" . "--></script>\n";
            }
        }
        echo "</table>\n";
    } elseif ($first == "static IPs") {
        echo "<table style=\"width: 100%\"><tr>" . "<th><a href=\"" . $unsortedrequesturl . "sort=ip\">" . $COLLATE['languages']['selected']['IPAddress'] . "</a></th>" . "<th>" . $COLLATE['languages']['selected']['Path'] . "</th>" . "<th><a href=\"" . $unsortedrequesturl . "sort=name\">" . $COLLATE['languages']['selected']['Name'] . "</a></th>" . "<th><a href=\"" . $unsortedrequesturl . "\">" . $COLLATE['languages']['selected']['Contact'] . "</a></th>" . "<th><a href=\"" . $unsortedrequesturl . "sort=failed_scans\">" . $COLLATE['languages']['selected']['FailedScans'] . "</a></th>" . "</tr><tr><td colspan=\"6\"><hr class=\"head\" /></td></tr>\n";
        $javascript = '';
        # this gets appended to in the following while loop
        while (list($static_id, $ip, $name, $contact, $note, $subnet_id, $failed_scans) = $row->fetch(PDO::FETCH_NUM)) {
            # Build path information for IP - use an array to avoid accessive db calls
            if (!isset($path[$subnet_id])) {
                $pathsql = "SELECT blocks.name, blocks.parent_id, subnets.name, subnets.block_id, subnets.stalescan_enabled FROM blocks, subnets \r\n                        WHERE subnets.id ='{$subnet_id}' AND subnets.block_id = blocks.id";
                $result = $dbo->query($pathsql);
                if ($result->rowCount() == '1') {
                    list($block_name, $block_parent, $subnet_name, $block_id, $stalescan_enabled) = $result->fetch(PDO::FETCH_NUM);
                    if ($block_parent === null) {
                        $path[$subnet_id] = "<a href=\"blocks.php\">[root]</a> / <a href=\"subnets.php?block_id={$block_id}\">{$block_name}</a> / \r\n\t\t\t\t   <a href=\"statics.php?subnet_id={$subnet_id}\">{$subnet_name}</a>";
                    } else {
                        $path[$subnet_id] = "<a href=\"blocks.php\">[root]</a> / ... / <a href=\"subnets.php?block_id={$block_id}\">{$block_name}</a> / \r\n\t\t\t\t   <a href=\"statics.php?subnet_id={$subnet_id}\">{$subnet_name}</a>";
                    }
                }
            }
            $ip = long2ip($ip);
            echo "<tr id=\"static_" . $static_id . "_row_1\">" . "<td><img src=\"images/static.png\" alt=\"\" /> &nbsp; {$ip}</td><td>" . $path[$subnet_id] . " </td><td><span id=\"edit_name_" . $static_id . "\">{$name}</span></td>" . "<td><span id=\"edit_contact_" . $static_id . "\">{$contact}</span></td>" . "<td>{$failed_scans}</td>" . "<td>";
            if ($COLLATE['user']['accesslevel'] >= '2' || $COLLATE['settings']['perms'] > '2') {
                echo " <a href=\"#\" onclick=\"\r\n\t\t      if (confirm('" . $COLLATE['languages']['selected']['confirmdelete'] . "')) { \r\n\t\t\t    new Element.update('static_" . $static_id . "_notice', ''); \r\n\t\t\t\tnew Ajax.Updater('static_" . $static_id . "_notice', '_statics.php?op=delete&amp;static_ip={$ip}', {onSuccess:function(){ \r\n\t\t\t\t  new Effect.Parallel( [\r\n\t\t\t\t    new Effect.Fade('static_" . $static_id . "_row_1'), \r\n\t\t\t\t    new Effect.Fade('static_" . $static_id . "_row_2'), \r\n\t\t\t\t    new Effect.Fade('static_" . $static_id . "_row_3'), \r\n\t\t\t\t\tnew Effect.Fade('static_" . $static_id . "_row_4')]); \r\n\t\t\t\t}}); \r\n               }; return false;\"><img src=\"./images/remove.gif\" alt=\"X\" title=\"" . $COLLATE['languages']['selected']['deletestatic'] . "\" /></a>";
            }
            echo "</td></tr>\n";
            echo "<tr id=\"static_" . $static_id . "_row_2\">" . "  <td colspan=\"4\"><span id=\"edit_note_" . $static_id . "\">{$note}</span></td>" . "  <td>";
            if ($stalescan_enabled == false) {
                # disabled at the subnet level
                echo "<img src=\"./images/skipping_disabled.png\" alt=\"\" title=\"" . $COLLATE['languages']['selected']['StaleScandisabled'] . "\" /></td>";
            } elseif ($failed_scans == '-1') {
                # disabled at the static ip level
                if ($COLLATE['user']['accesslevel'] >= '2' || $COLLATE['settings']['perms'] > '2') {
                    echo "<a href=\"#\" onclick=\"new Ajax.Updater('stalescan_status_icon" . $static_id . "', '_statics.php?op=toggle_stale-scan&amp;static_ip={$ip}')\">";
                    echo "<span id=\"stalescan_status_icon" . $static_id . "\">";
                }
                echo "<img src=\"./images/skipping.png\" alt=\"\" title=\"" . $COLLATE['languages']['selected']['enablestalescan'] . "\" />";
                if ($COLLATE['user']['accesslevel'] >= '2' || $COLLATE['settings']['perms'] > '2') {
                    echo "</span></a>";
                }
            } else {
                # currently enabled
                if ($COLLATE['user']['accesslevel'] >= '2' || $COLLATE['settings']['perms'] > '2') {
                    echo "<a href=\"#\" onclick=\"new Ajax.Updater('stalescan_status_icon" . $static_id . "', '_statics.php?op=toggle_stale-scan&amp;static_ip={$ip}')\">";
                    echo "<span id=\"stalescan_status_icon" . $static_id . "\">";
                }
                echo "<img src=\"./images/scanning.png\" alt=\"\" title=\"" . $COLLATE['languages']['selected']['disablestalescan'] . "\" />";
                if ($COLLATE['user']['accesslevel'] >= '2' || $COLLATE['settings']['perms'] > '2') {
                    echo "</span></a>";
                }
            }
            echo "</td></tr>\n";
            echo "<tr id=\"static_" . $static_id . "_row_3\"><td colspan=\"6\"><span id=\"static_" . $static_id . "_notice\" class=\"tip\"></span></td>\n";
            echo "<tr id=\"static_" . $static_id . "_row_4\"><td colspan=\"6\"><hr class=\"division\" /></td></tr>\n";
            if ($COLLATE['user']['accesslevel'] >= '2' || $COLLATE['settings']['perms'] > '2') {
                $javascript .= "<script type=\"text/javascript\"><!--\n" . "  new Ajax.InPlaceEditorWithEmptyText('edit_name_" . $static_id . "', '_statics.php?op=edit&static_id={$static_id}&edit=name',\r\n              {\r\n\t\t\t  clickToEditText: '" . $COLLATE['languages']['selected']['ClicktoEdit'] . "',\r\n\t\t\t  highlightcolor: '#a5ddf8', \r\n              callback:\r\n               function(form) {\r\n                 new Element.update('static_" . $static_id . "_notice', '');\r\n                 return Form.serialize(form);\r\n               },\r\n              onFailure: \r\n               function(transport, ipe) {\r\n                 new Element.update('static_" . $static_id . "_notice', ipe.responseText.stripTags());\r\n               }\r\n            }\r\n            );\n" . "  new Ajax.InPlaceEditorWithEmptyText('edit_contact_" . $static_id . "', '_statics.php?op=edit&static_id={$static_id}&edit=contact',\r\n              {\r\n\t\t\t  clickToEditText: '" . $COLLATE['languages']['selected']['ClicktoEdit'] . "',\r\n\t\t\t  highlightcolor: '#a5ddf8',  \r\n              callback:\r\n               function(form) {\r\n                 new Element.update('static_" . $static_id . "_notice', '');\r\n                 return Form.serialize(form);\r\n               },\r\n              onFailure: \r\n               function(transport, ipe) {\r\n                 new Element.update('static_" . $static_id . "_notice', ipe.responseText.stripTags());\r\n               }\r\n            }\r\n            );\n" . "  new Ajax.InPlaceEditorWithEmptyText('edit_note_" . $static_id . "', '_statics.php?op=edit&static_id={$static_id}&edit=note',\r\n              {\r\n\t\t\t  clickToEditText: '" . $COLLATE['languages']['selected']['ClicktoEdit'] . "',\r\n\t\t\t  highlightcolor: '#a5ddf8',  \r\n              callback:\r\n               function(form) {\r\n                 new Element.update('static_" . $static_id . "_notice', '');\r\n                 return Form.serialize(form);\r\n               },\r\n              onFailure: \r\n               function(transport, ipe) {\r\n                 new Element.update('static_" . $static_id . "_notice', ipe.responseText.stripTags());\r\n               }\r\n            }\r\n            );\n" . "--></script>\n";
            }
        }
        echo "</table>\n";
    } elseif ($first == "logs") {
        echo "<table style=\"width: 100%\">" . "<tr><th>" . $COLLATE['languages']['selected']['Timestamp'] . "</th>" . "<th>" . $COLLATE['languages']['selected']['Username'] . "</th>" . "<th>" . $COLLATE['languages']['selected']['IPAddress'] . "</th>" . "<th>" . $COLLATE['languages']['selected']['Severity'] . "</th>" . "<th>" . $COLLATE['languages']['selected']['Message'] . "</th></tr>\n" . "<tr><td colspan=\"5\"><hr class=\"head\" /></td></tr>\n";
        while (list($occuredat, $username, $ipaddress, $level, $message) = $row->fetch(PDO::FETCH_NUM)) {
            if ($level == "high") {
                $level = "<b>{$level}</b>";
            }
            echo "<tr><td>{$occuredat}</td><td>{$username}</td><td>{$ipaddress}</td><td>{$level}</td><td>{$message}</td></tr>\n" . "<tr><td colspan=\"5\"><hr class=\"division\" /></td></tr>\n";
        }
        echo "</table>\n";
    }
    pageselector($sql, $hiddenformvars);
    $javascript = !isset($javascript) ? '' : $javascript;
    echo $javascript;
    require_once './include/footer.php';
}