Esempio n. 1
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&first={$first}&second={$second}&" . "search={$search}&when={$when}&fromdate={$fromdate}&" . "todate={$todate}&page=1&";
    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';
}
$result = build_search_sql($sku_fields, $_GET['sku_id'], $_GET['sku_id_from'], $_GET['sku_id_to']);
if ($result) {
    $criteria[] = $result;
}
$amt_fields = array('m.total_amount', 'i.debit_amount', 'i.credit_amount');
$result = build_search_sql($amt_fields, $_GET['amount_id'], $_GET['amount_id_from'], $_GET['amount_id_to']);
if ($result) {
    $criteria[] = $result;
}
$gl_acct_fields = array('m.gl_acct_id', 'i.gl_account');
$result = build_search_sql($gl_acct_fields, $_GET['gl_acct_id'], $_GET['gl_acct_id_from'], $_GET['gl_acct_id_to']);
if ($result) {
    $criteria[] = $result;
}
$main_fields = array('m.id');
$result = build_search_sql($main_fields, $_GET['main_id'], $_GET['main_id_from'], $_GET['main_id_to']);
if ($result) {
    $criteria[] = $result;
}
$date_prefs = array('fieldname' => 'm.post_date', 'params' => $_GET['date_id'] . ':' . $_GET['date_from'] . ':' . $_GET['date_to']);
$temp = gen_build_sql_date($date_prefs['params'], $date_prefs['fieldname']);
if ($temp['sql']) {
    $criteria[] = '(' . $temp['sql'] . ')';
}
$crit = $criteria ? " where " . implode(' and ', $criteria) : '';
$query_raw = "select distinct m.id, m.journal_id, m.post_date, m.description, m.total_amount, \r\n\tm.purchase_invoice_id, m.bill_primary_name, m.bill_acct_id   \r\n\tfrom " . TABLE_JOURNAL_MAIN . " m inner join " . TABLE_JOURNAL_ITEM . " i \r\n\ton m.id = i.ref_id " . $crit . " order by {$disp_order}";
$query_result = $db->Execute($query_raw);
$query_split = new splitPageResults($_GET['page'], MAX_DISPLAY_SEARCH_RESULTS, $query_raw, $query_numrows);
$query_result = $db->Execute($query_raw);
$include_template = 'template_main.php';
// include display template (required)
$req_cfg = config_get('req_cfg');
$tcase_cfg = config_get('testcase_cfg');
$charset = config_get('charset');
$commandMgr = new reqCommands($db);
$gui = $commandMgr->initGuiBean();
$gui->main_descr = lang_get('caption_search_form_req');
$gui->warning_msg = '';
$gui->path_info = null;
$gui->resultSet = null;
$gui->tableSet = null;
$map = null;
$args = init_args($date_format_cfg);
$gui->tcasePrefix = $tproject_mgr->getTestCasePrefix($args->tprojectID);
$gui->tcasePrefix .= $tcase_cfg->glue_character;
if ($args->tprojectID) {
    $sql = build_search_sql($db, $args, $gui);
    // key: req id (db id)
    // value: array of versions and revisions
    //
    $map = $db->fetchRowsIntoMap($sql, 'id', database::CUMULATIVE);
    // dont show requirements from different testprojects than the selected one
    if (count($map)) {
        $reqIDSet = array_keys($map);
        foreach ($reqIDSet as $item) {
            $pid = $tproject_mgr->tree_manager->getTreeRoot($item);
            if ($pid != $args->tprojectID) {
                unset($map[$item]);
            }
        }
    }
}
Esempio n. 4
0
$result = build_search_sql($sku_fields, $_SESSION['search_sku_id'], $_SESSION['search_sku_from'], $_SESSION['search_sku_to']);
if ($result) {
    $criteria[] = $result;
}
$amt_fields = array('m.total_amount', 'i.debit_amount', 'i.credit_amount');
$result = build_search_sql($amt_fields, $_SESSION['search_amount_id'], $_SESSION['search_amount_from'], $_SESSION['search_amount_to']);
if ($result) {
    $criteria[] = $result;
}
$gl_acct_fields = array('m.gl_acct_id', 'i.gl_account');
$result = build_search_sql($gl_acct_fields, $_SESSION['search_gl_acct_id'], $_SESSION['search_gl_acct_from'], $_SESSION['search_gl_acct_to']);
if ($result) {
    $criteria[] = $result;
}
$main_fields = array('m.id');
$result = build_search_sql($main_fields, $_SESSION['search_main_id'], $_SESSION['search_main_from'], $_SESSION['search_main_to']);
if ($result) {
    $criteria[] = $result;
}
$date_prefs = array('fieldname' => 'm.post_date', 'params' => $_SESSION['search_date_id'] . ':' . $_SESSION['search_date_from'] . ':' . $_SESSION['search_date_to']);
$temp = gen_build_sql_date($date_prefs['params'], $date_prefs['fieldname']);
if ($temp['sql']) {
    $criteria[] = '(' . $temp['sql'] . ')';
}
$crit = $criteria ? " where " . implode(' and ', $criteria) : '';
$query_raw = "select SQL_CALC_FOUND_ROWS distinct m.id, m.journal_id, m.post_date, m.description, m.total_amount, \n\tm.purchase_invoice_id, m.bill_primary_name, m.bill_acct_id   \n\tfrom " . TABLE_JOURNAL_MAIN . " m inner join " . TABLE_JOURNAL_ITEM . " i \n\ton m.id = i.ref_id " . $crit . " order by {$disp_order}";
//echo 'sql = '; print_r($query_raw); echo '<br>';
$query_result = $db->Execute($query_raw, MAX_DISPLAY_SEARCH_RESULTS * ($_REQUEST['list'] - 1) . ", " . MAX_DISPLAY_SEARCH_RESULTS);
$query_split = new splitPageResults($_REQUEST['list'], '');
if ($query_split->current_page_number != $_REQUEST['list']) {
    // if here, go last was selected, now we know # pages, requery to get results