Esempio n. 1
0
function dns_record_display($options = "")
{
    global $conf, $self, $onadb;
    // Version - UPDATE on every edit!
    $version = '1.00';
    printmsg("DEBUG => dns_record_display({$options}) called", 3);
    // Parse incoming options string to an array
    $options = parse_options($options);
    // Sanitize options[verbose] (default is yes)
    $options['verbose'] = sanitize_YN($options['verbose'], 'Y');
    // Return the usage summary if we need to
    if ($options['help'] or !$options['name']) {
        // NOTE: Help message lines should not exceed 80 characters for proper display on a console
        $self['error'] = 'ERROR => Insufficient parameters';
        return array(1, <<<EOM

dns_record_display-v{$version}
Displays a DNS record from the database

  Synopsis: dns_record_display [KEY=VALUE] ...

  Required:
    name=NAME[.DOMAIN] or ID      hostname or ID of the dns record to display

  Optional:
    verbose=[yes|no]              display additional info (yes)



EOM
);
    }
    // If the name we were passed has a leading . in it then remove the dot.
    $options['name'] = preg_replace("/^\\./", '', $options['name']);
    // Find the DNS record from $options['name']
    list($status, $rows, $record) = ona_find_dns_record($options['name']);
    printmsg("DEBUG => dns_record_del() DNS record: {$record['name']}", 3);
    if (!$record['id']) {
        printmsg("DEBUG => Unknown DNS record: {$options['name']}", 3);
        $self['error'] = "ERROR => Unknown DNS record: {$options['name']}";
        return array(2, $self['error'] . "\n");
    }
    // Build text to return
    $text = "DNS {$record['type']} RECORD ({$record['fqdn']})\n";
    $text .= format_array($record);
    // If 'verbose' is enabled, grab some additional info to display
    if ($options['verbose'] == 'Y') {
        // PTR record(s)
        $i = 0;
        do {
            list($status, $rows, $ptr) = ona_get_dns_record(array('dns_id' => $record['id'], 'type' => 'PTR'));
            if ($rows == 0) {
                break;
            }
            $i++;
            $text .= "\nASSOCIATED PTR RECORD ({$i} of {$rows})\n";
            $text .= format_array($ptr);
        } while ($i < $rows);
        // CNAME record(s)
        $i = 0;
        do {
            list($status, $rows, $cname) = ona_get_dns_record(array('dns_id' => $record['id'], 'type' => 'CNAME'));
            if ($rows == 0) {
                break;
            }
            $i++;
            $text .= "\nASSOCIATED CNAME RECORD ({$i} of {$rows})\n";
            $text .= format_array($cname);
        } while ($i < $rows);
        // FIXME: MP display other types of records like NS,MX,SRV etc etc, also support dns views better
    }
    // Return the success notice
    return array(0, $text);
}
Esempio n. 2
0
function rpt_output_text($form)
{
    global $onadb, $style, $images;
    // Provide a usage message here
    $usagemsg = <<<EOL
Report: nmap_scan
  Processes the XML output of an nmap scan and compares it to data in the database.

  Required:
    subnet=ID|IP|STRING   Subnet ID, IP, or name of existing subnet with a scan
      OR
    file=PATH             Local XML file will be sent to server for processing
      OR
    all                   Process ALL XML files on the server
      OR
    update_response       Update the last response field for all UP IPs to time in scan

  Output Formats:
    html
    text
    csv

NOTE: When running update_response, any entry that was updated will have a ~ indication
      at the beginning of the line.
      DNS names with a * preceeding them indicate there are more than one name available
      for this entry and it could have a more common name associated with it.

EOL;
    // Provide a usage message
    if ($form['rpt_usage']) {
        return array(0, $usagemsg);
    }
    if (!$form['totalhosts'] and !$form['all']) {
        return array(1, "\nERROR => No hosts found, check that the XML file is not empty, or that your subnet exists in the database.\n{$usagemsg}");
    }
    if (!$form['all']) {
        $text .= "NMAP scan of {$form['totalhosts']} hosts done on {$form['runtime']}. {$form['scansource']}\n\n";
    } else {
        $text .= "Displaying records for ALL nmap scans in the system.  It also only shows issues, not entries that are OK.\n\n";
    }
    //$text .= sprintf("%-50s %-8s %-8s\n",'NMAP SCAN','DATABASE','Actions');
    if ($form['csv_output']) {
        $text .= sprintf("%s,%s,%s,%s,%s,%s,%s,%s\n", 'STAT', 'NET IP', 'NET NAME', 'NET MAC', 'DB IP', 'DB NAME', 'DB MAC', 'ACTION');
    } else {
        $text .= sprintf("%-6s %-15s %-25s %-12s %-15s %-25s %-12s %s\n", 'STAT', 'NET IP', 'NET NAME', 'NET MAC', 'DB IP', 'DB NAME', 'DB MAC', 'ACTION');
    }
    // netip    netname     netmac      dbip    dbname  dbmac
    $poolhostcount = 0;
    // find out the broadcast IP for this subnet
    // TODO: fix this for ipv6 stuff!
    $num_hosts = 0xffffffff - ip_mangle($form['netcidr'], 'numeric');
    $broadcastip = ip_mangle(ip_mangle($form['netip'], 'numeric') + $num_hosts, 'dotted');
    foreach ((array) $form['ip'] as $record) {
        // scans with only one row in them may show up wrong, skip them
        if (!$record['netstatus'] and !$record['netip']) {
            continue;
        }
        $action = '';
        $upresp = ' ';
        // Check devices that are down
        if ($record['netstatus'] == "down") {
            // Skip over hosts that are not in network or database
            if ($record['dbip'] == "NOT FOUND") {
                continue;
            }
            // If it is only in the database then they should validate the ip or remove from database
            if ($record['netip'] == $record['dbip'] or $record['netdnsname'] != $record['dbdnsname']) {
                $action = "Ping to verify then delete as desired";
            }
        }
        // check devices that are up
        if ($record['netstatus'] == "up") {
            // If this is the subnet address or broadcast then skip it.  Sometimes nmap shows them as up
            if ($record['netip'] == $form['netip']) {
                continue;
            }
            if ($record['netip'] == $broadcastip) {
                continue;
            }
            // update the database last response field.
            if ($form['update_response'] and $record['dbip'] != "NOT FOUND") {
                //if (isset($options['dcm_output'])) { $text .=  "dcm.pl -r interface_modify interface={$record['ip']} set_last_response='{$runtime}'\n"; }
                list($updatestatus, $output) = run_module('interface_modify', array('interface' => $record['dbip'], 'set_last_response' => $form['runtime']));
                if ($updatestatus) {
                    $self['error'] = "ERROR => Failed to update response time for '{$record['dbip']}': " . $output;
                    printmsg($self['error'], 1);
                }
                $upresp = '~';
            }
            // Break out the host and domain parts of the name if we can
            if ($record['netdnsname']) {
                list($status, $rows, $domain) = ona_find_domain($record['netdnsname'], 0);
                // Now find what the host part of $search is
                $hostname = str_replace(".{$domain['fqdn']}", '', $record['netdnsname']);
            }
            // If we dont find it in the database
            if ($record['dbip'] == "NOT FOUND") {
                $action = "Add as host or Add as interface, check proper pool range";
            }
            // If it is in the database and network
            if ($record['netip'] == $record['dbip']) {
                $action = 'OK';
                // But if the names are not the same then action is partial
                if ($record['netdnsname'] != $record['dbdnsname']) {
                    $action = 'Update DNS';
                }
                if (strstr($record['dbdnsname'], '(')) {
                    $action = 'Update DNS PTR';
                }
            }
            // if the database name is empty, then provide a generic "name"
            if (!$record['dbdnsname'] and $record['dbip'] != 'NOT FOUND' and $record['netdnsname']) {
                $record['dbdnsname'] = 'NONE SET';
            }
            // if the names are different, offer an edit button for the DB
            if ($record['netdnsname'] and strtolower($record['netdnsname']) != $record['dbdnsname']) {
                // not a lot of testing here to make sure it will find the right name.
                list($status, $rows, $rptdnsrecord) = ona_find_dns_record($record['dbdnsname']);
            }
            // If the device is in a dhcp pool range, then count it and identify it.
            if ($record['inpool'] == 1) {
                $poolhostcount++;
                $record['dbip'] = 'DHCP Pooled';
                $action = 'DHCP Pooled device';
            }
        }
        // If we have more than 2 dns records, display info about them
        if ($record['dbdnsrows'] > 2) {
            $record['dbdnsname'] = '*' . $record['dbdnsname'];
        }
        /*
        TODO:
        * more testing of mac address stuff
        * display info about last response time.. add option to update last response form file.. flag if db has newer times than the scan
        */
        if ($form['csv_output']) {
            $txt = sprintf("%s,%s,%s,%s,%s,%s,%s,\"%s\"\n", $upresp . $record['netstatus'], $record['netip'], $record['netdnsname'], $record['netmacaddr'], $record['dbip'], $record['dbdnsname'] . ' ' . $record['dbdnsptrname'], $record['dbmacaddr'], $action);
        } else {
            $txt = sprintf("%-6s %-15s %-25s %-12s %-15s %-25s %-12s %s\n", $upresp . $record['netstatus'], $record['netip'], $record['netdnsname'], $record['netmacaddr'], $record['dbip'], $record['dbdnsname'] . ' ' . $record['dbdnsptrname'], $record['dbmacaddr'], $action);
        }
        // if we are in all mode, print only errors.. otherwise, print it all
        if ($form['all'] and $action == 'OK') {
            $txt = '';
        }
        // add the new line to the html output variable
        $text .= $txt;
    }
    if (!$form['all']) {
        $hostpoolinfo = "Hosts in DHCP pool range: {$poolhostcount}\n";
    }
    $text .= "\n{$hostpoolinfo}END OF REPORT";
    return array(0, $text);
}
Esempio n. 3
0
function domain_server_add($options = "")
{
    // The important globals
    global $conf, $self, $onadb;
    // Version - UPDATE on every edit!
    $version = '1.02';
    printmsg("DEBUG => domain_server_add({$options}) called", 3);
    // Parse incoming options string to an array
    $options = parse_options($options);
    // Return the usage summary if we need to
    if ($options['help'] or !($options['domain'] and $options['server'])) {
        // NOTE: Help message lines should not exceed 80 characters for proper display on a console
        $self['error'] = 'ERROR => Insufficient parameters';
        return array(1, <<<EOM

domain_server_add-v{$version}
Assigns an existing domain record to a DNS server

  Synopsis: domain_server_add [KEY=VALUE] ...

  Required:
    domain=NAME or ID               domain name or ID
    server=NAME[.DOMAIN] or ID      server name or ID
    role=master|slave|forward       role of this server for this domain

EOM
);
    }
    //     if (is_numeric($options['domain'])) {
    //         $domainsearch['id'] = $options['domain'];
    //     } else {
    //         $domainsearch['name'] = strtolower($options['domain']);
    //     }
    // Determine the entry itself exists
    list($status, $rows, $domain) = ona_find_domain($options['domain'], 0);
    // Test to see that we were able to find the specified record
    if (!$domain['id']) {
        printmsg("DEBUG => Unable to find the domain record using {$options['domain']}!", 3);
        $self['error'] = "ERROR => Unable to find the domain record using {$options['domain']}!";
        return array(4, $self['error'] . "\n");
    }
    printmsg("DEBUG => domain_server_add(): Found domain, {$domain['name']}", 3);
    // Determine the server is valid
    list($status, $rows, $ns_dns) = ona_find_dns_record($options['server']);
    list($status, $rows, $interface) = ona_find_interface($ns_dns['interface_id']);
    $host['id'] = $interface['host_id'];
    if (!$host['id']) {
        printmsg("DEBUG => The server ({$options['server']}) does not exist!", 3);
        $self['error'] = "ERROR => The server specified, {$options['server']}, does not exist!";
        return array(2, $self['error'] . "\n");
    }
    // what is the role for this server.
    switch (strtolower($options['role'])) {
        case "forward":
            $role = "forward";
            break;
        case "master":
            $role = "master";
            break;
        case "slave":
            $role = "slave";
            break;
        default:
            $role = "master";
    }
    // Check permissions
    if (!auth('advanced')) {
        $self['error'] = "Permission denied!";
        printmsg($self['error'], 0);
        return array(12, $self['error'] . "\n");
    }
    // Test that this domain isnt already assigned to the server
    list($status, $rows, $domainserver) = ona_get_dns_server_domain_record(array('host_id' => $host['id'], 'domain_id' => $domain['id']));
    if ($rows) {
        printmsg("DEBUG => Domain {$domain['name']} already assigned to {$options['server']}", 3);
        $self['error'] = "ERROR => Domain {$domain['name']} already assigned to {$options['server']}";
        return array(11, $self['error'] . "\n");
    }
    // Get the next ID
    $id = ona_get_next_id('dns_server_domains');
    if (!$id) {
        $self['error'] = "ERROR => The ona_get_next_id() call failed!";
        printmsg($self['error'], 0);
        return array(6, $add_to_error . $self['error'] . "\n");
    }
    printmsg("DEBUG => domain_server_add(): New DNS server domain ID: {$id}", 3);
    // Add new record to dns_server_domains
    list($status, $rows) = db_insert_record($onadb, 'dns_server_domains', array('id' => $id, 'host_id' => $host['id'], 'domain_id' => $domain['id'], 'role' => $role, 'rebuild_flag' => 1));
    if ($status or !$rows) {
        $self['error'] = "ERROR => domain_server_add() SQL Query failed:" . $self['error'];
        printmsg($self['error'], 0);
        return array(8, $add_to_error . $self['error'] . "\n");
    }
    // Test that there are no NS records for this pair already
    // ASSUMPTION: MP this will always be just one record??
    list($status, $dnsrows, $dnsrec) = db_get_record($onadb, 'dns', "domain_id = {$domain['id']} AND type = 'NS' AND interface_id in (select id from interfaces where host_id = {$host['id']})");
    // Auto add the NS record if there were none found already. the user can remove any NS records they dont want afterwards
    if (!$dnsrows) {
        printmsg("DEBUG => Auto adding a NS record for {$options['server']}.", 0);
        // Run dns_record_add as a NS type
        list($status, $output) = run_module('dns_record_add', array('name' => $domain['fqdn'], 'pointsto' => $options['server'], 'type' => 'NS'));
        if ($status) {
            return array($status, $output);
        }
        $add_to_error .= $output;
    } else {
        printmsg("DEBUG => Found existing NS record for {$options['server']}. Skipping the auto add.", 0);
    }
    // Return the success notice
    $self['error'] = "INFO => DNS Domain/Server Pair ADDED: {$domain['name']}/{$options['server']} ";
    printmsg($self['error'], 0);
    return array(0, $add_to_error . $self['error'] . "\n");
}
Esempio n. 4
0
function ws_display($window_name, $form = '')
{
    global $conf, $self, $onadb;
    global $images, $color, $style;
    $html = '';
    $js = '';
    //$debug_val = 3;  // used in the auth() calls to suppress logging
    // If the user supplied an array in a string, build the array and store it in $form
    $form = parse_options_string($form);
    // Load the domain record
    list($status, $rows, $record) = ona_get_domain_record(array('id' => $form['domain_id']));
    if ($status or !$rows) {
        array_pop($_SESSION['ona']['work_space']['history']);
        $html .= "<br><center><font color=\"red\"><b>Domain doesn't exist!</b></font></center>";
        $response = new xajaxResponse();
        $response->addAssign("work_space_content", "innerHTML", $html);
        return $response->getXML();
    }
    // Update History Title
    $history = array_pop($_SESSION['ona']['work_space']['history']);
    $js .= "xajax_window_submit('work_space', ' ', 'rewrite_history');";
    if ($history['title'] == $window_name) {
        $history['title'] = $record['fqdn'];
        array_push($_SESSION['ona']['work_space']['history'], $history);
    }
    // Create some javascript to refresh the current page
    $refresh = htmlentities(str_replace(array("'", '"'), array("\\'", '\\"'), $history['url']), ENT_QUOTES, $conf['php_charset']);
    $refresh = "xajax_window_submit('work_space', '{$refresh}');";
    // Get associated info
    if ($record['parent_id']) {
        list($status, $rows, $parent_domain) = ona_get_domain_record(array('id' => $record['parent_id']));
        $parent_domain['name'] = ona_build_domain_name($parent_domain['id']);
    } else {
        $parent_domain = "";
    }
    // Find the primary_master host to see if it is valid
    list($status, $rows, $primaster_host) = ona_find_dns_record($record['primary_master']);
    if ($primaster_host['id'] === 0) {
        $not_a_primaster = 1;
    }
    $style['content_box'] = <<<EOL
        margin: 10px 20px;
        padding: 2px 4px;
        background-color: #FFFFFF;
EOL;
    $style['label_box'] = <<<EOL
        font-weight: bold;
        padding: 2px 4px;
        border: solid 1px {$color['border']};
        background-color: {$color['window_content_bg']};
EOL;
    // Escape data for display in html
    foreach (array_keys($record) as $key) {
        $record[$key] = htmlentities($record[$key], ENT_QUOTES, $conf['php_charset']);
    }
    foreach (array_keys((array) $parent_domain) as $key) {
        $parent_domain[$key] = htmlentities($parent_domain[$key], ENT_QUOTES, $conf['php_charset']);
    }
    $html .= <<<EOL
    <!-- FORMATTING TABLE -->
    <div style="{$style['content_box']}">
    <table cellspacing="0" border="0" cellpadding="0"><tr>

        <!-- START OF FIRST COLUMN OF SMALL BOXES -->
        <td nowrap="true" valign="top" style="padding-right: 15px;">
EOL;
    // DOMAIN INFORMATION BOX
    $html .= <<<EOL
        <table width=100% cellspacing="0" border="0" cellpadding="0" style="margin-bottom: 8px;">
            <tr>
            <td colspan="99" nowrap="true">
                <!-- LABEL -->
                    <form id="form_domain_{$record['id']}"
                        ><input type="hidden" name="id" value="{$record['id']}"
                        ><input type="hidden" name="js" value="{$refresh}"
                    ></form>
                    <div style="{$style['label_box']}">

EOL;
    if (auth('advanced', $debug_val)) {
        $html .= <<<EOL
                            <a title="Edit domain. ID: {$record['id']}"
                               onClick="xajax_window_submit('edit_domain', xajax.getFormValues('form_domain_{$record['id']}'), 'editor');"
                            ><img src="{$images}/silk/page_edit.png" border="0"></a>
                            <a title="Delete domain. ID: {$record['id']}"
                               class="linkact"
                               onClick="var doit=confirm('Are you sure you want to delete this domain?');
                                        if (doit == true)
                                            xajax_window_submit('edit_domain', xajax.getFormValues('form_domain_{$record['id']}'), 'delete');"
                            ><img src="{$images}/silk/delete.png"></a>
EOL;
    }
    $html .= <<<EOL
                {$record['fqdn']}
                </div>
            </td>
            </tr>
EOL;
    if ($parent_domain['id']) {
        $html .= <<<EOL
            <tr>
                <td align="right" nowrap="true"><b>Parent Domain</b>&nbsp;</td>
                <td class="padding" align="left">
                    <a title="View domain. ID: {$parent_domain['id']}"
                       class="domain"
                       onClick="xajax_window_submit('work_space', 'xajax_window_submit(\\'display_domain\\', \\'domain_id=>{$parent_domain['id']}\\', \\'display\\')');"
                    >{$parent_domain['name']}</a>
                </td>
            </tr>
            <tr><td colspan="2" align="left" nowrap="true">&nbsp;</td></tr>
EOL;
    }
    $html .= <<<EOL
            <tr>
                <td colspan="2" align="left" nowrap="true"><b><u>Domain SOA Parameters</u></b>&nbsp;</td>
            </tr>

EOL;
    if ($record['primary_master']) {
        if ($not_a_primaster) {
            $record['primary_master'] = "<span style='background-color: #FFDDDD;' title='INFO: This FQDN is not defined in the database.'><img src='{$images}/silk/error.png' border='0'> {$record['primary_master']}</span>";
        }
        $html .= <<<EOL
            <tr>
                <td align="right" nowrap="true"><b>Primary Master</b>&nbsp;</td>
                <td class="padding" align="left" onClick="xajax_window_submit('edit_domain', xajax.getFormValues('form_domain_{$record['id']}'), 'editor');">
                    {$record['primary_master']}&nbsp;
                </td>
            </tr>
EOL;
    } else {
        $html .= <<<EOL
            <tr style="background-color: #FFDDDD;" title="There is no defined primary master server!">
                <td align="right" nowrap="true"><b>Primary Master</b>&nbsp;</td>
                <td nowrap="true">
                    <img src='{$images}/silk/error.png' border='0'> Please assign a Primary Master server!
                </td>
            </tr>
EOL;
    }
    $html .= <<<EOL
            <tr>
                <td align="right" nowrap="true"><b>Refresh</b>&nbsp;</td>
                <td class="padding" align="left">
                    {$record['refresh']}&nbsp;
                </td>
            </tr>

            <tr>
                <td align="right" nowrap="true"><b>Retry</b>&nbsp;</td>
                <td class="padding" align="left">
                    {$record['retry']}&nbsp;
                </td>
            </tr>

            <tr>
                <td align="right" nowrap="true"><b>Expiry</b>&nbsp;</td>
                <td class="padding" align="left">
                    {$record['expiry']}&nbsp;
                </td>
            </tr>

            <tr>
                <td align="right" nowrap="true"><b>Minimum</b>&nbsp;</td>
                <td class="padding" align="left">
                    {$record['minimum']}&nbsp;
                </td>
            </tr>

            <tr>
                <td align="right" nowrap="true"><b>Default TTL</b>&nbsp;</td>
                <td class="padding" align="left">
                    {$record['default_ttl']}&nbsp;
                </td>
            </tr>
        </table>
EOL;
    // END DOMAIN INFORMATION BOX
    $html .= <<<EOL
        <!-- END OF FIRST COLUMN OF SMALL BOXES -->
        </td>

        <!-- START OF SECOND COLUMN OF SMALL BOXES -->
        <td valign="top" style="padding-right: 15px;">
EOL;
    // DNS SERVERS BOX
    $html .= <<<EOL
        <table width=100% cellspacing="0" border="0" cellpadding="0" style="margin-bottom: 8px;">
            <tr>
                <td colspan="99" nowrap="true" style="{$style['label_box']}">DNS servers&nbsp;</td>
            </tr>

EOL;
    // Get a list of servers, and loop through them
    list($status, $rows, $domainservers) = db_get_records($onadb, 'dns_server_domains', array('domain_id' => $record['id']), 'role');
    if ($rows) {
        foreach ($domainservers as $domainserver) {
            $domainserver['role'] = strtoupper($domainserver['role']);
            list($status, $rows, $host) = ona_find_host($domainserver['host_id']);
            $host['fqdn'] = htmlentities($host['fqdn'], ENT_QUOTES, $conf['php_charset']);
            $html .= <<<EOL
                <tr onMouseOver="this.className='row-highlight';"
                    onMouseOut="this.className='row-normal';">

                    <td align="left" nowrap="true">
                        <a title="View server. ID: {$host['id']}"
                           class="nav"
                           onClick="xajax_window_submit('work_space', 'xajax_window_submit(\\'display_domain_server\\', \\'host_id=>{$host['id']}\\', \\'display\\')');"
                        >{$host['fqdn']}</a>&nbsp;
                     </td>
                     <td align="left" nowrap="true" style="border-left: 1px solid; border-left-color: #aaaaaa;padding-left: 3px;">
                            {$domainserver['role']}
                    </td>
                     <td align="right" nowrap="true">
                        <form id="{$form['form_id']}_domain_serv_{$domainserver['id']}"
                                ><input type="hidden" name="server" value="{$domainserver['host_id']}"
                                ><input type="hidden" name="domain" value="{$domainserver['domain_id']}"
                                ><input type="hidden" name="js" value="{$refresh}"
                        ></form>
EOL;
            if (auth('advanced', $debug_val)) {
                $html .= <<<EOL

                        &nbsp;<a title="Remove domain assignment"
                           class="linkact"
                           onClick="var doit=confirm('Are you sure you want to remove this domain from this DNS server?');
                           if (doit == true)
                                xajax_window_submit('edit_domain_server', xajax.getFormValues('{$form['form_id']}_domain_serv_{$domainserver['id']}'), 'delete');"
                        ><img src="{$images}/silk/page_delete.png"></a>
EOL;
            }
            $html .= <<<EOL
                   </td>

                </tr>
EOL;
        }
    } else {
        $html .= <<<EOL
            <tr style="background-color: #FFDDDD;" title="There are no defined servers for this domain!">
                <td colspan=10 nowrap="true">
                    <img src="{$images}/silk/error.png"> Please add a server for this domain!
                </td>
EOL;
    }
    if (auth('advanced', $debug_val)) {
        $html .= <<<EOL

                <tr>
                    <td colspan="3" align="left" valign="middle" nowrap="true" class="act-box">
                        <form id="form_domain_server_{$record['id']}"
                            ><input type="hidden" name="domain" value="{$record['name']}"
                            ><input type="hidden" name="js" value="{$refresh}"
                        ></form>

                        <a title="Assign server"
                           class="linkact"
                           onClick="xajax_window_submit('edit_domain_server', xajax.getFormValues('form_domain_server_{$record['id']}'), 'editor');"
                        ><img src="{$images}/silk/page_add.png">Assign to server</a>

                    </td>
                </tr>
EOL;
    }
    $html .= "          </table>";
    // END DNS SERVERS BOX
    $html .= <<<EOL
        <!-- END OF SECOND COLUMN OF SMALL BOXES -->
        </td>

        <!-- START OF THIRD COLUMN OF SMALL BOXES -->
        <td valign="top" style="padding-right: 15px;">
EOL;
    // extra stuff to pass to ws_plugins
    $extravars['refresh'] = $refresh;
    $extravars['window_name'] = $window_name;
    // Get all the plugin based worspace items
    $wspl_list = plugin_list('wspl_item');
    // Load all the dynamic plugins
    foreach ($wspl_list as $p) {
        $wspl = workspace_plugin_loader($p['path'], $record, $extravars);
        $html .= $wspl[0];
        $js .= $wspl[1];
    }
    $html .= <<<EOL
        </td>
        <!-- END OF THIRD COLUMN OF SMALL BOXES -->
    </tr></table>
    </div>
    <!-- END OF TOP SECTION -->
EOL;
    // HOST LIST
    $tab = 'records';
    $submit_window = "list_{$tab}";
    $form_id = "{$submit_window}_filter_form";
    $_SESSION['ona'][$form_id]['tab'] = $tab;
    $content_id = "{$window_name}_{$submit_window}";
    $html .= <<<EOL
    <!-- HOST LIST -->
    <div style="border: 1px solid {$color['border']}; margin: 10px 20px;">

        <!-- Tab & Quick Filter -->
        <table id="{$form_id}_table" cellspacing="0" border="0" cellpadding="0">
            <tr>
                <td id="{$form_id}_{$tab}_tab" class="table-tab-active">
                    Associated {$tab} <span id="{$form_id}_{$tab}_count"></span>
                </td>

                <td id="{$form_id}_quick_filter" class="padding" align="right" width="100%">
EOL;
    $html .= <<<EOL
                    <form id="{$form_id}" onSubmit="return false;">
                    <input id="{$form_id}_page" name="page" value="1" type="hidden">
                    <input name="content_id" value="{$content_id}" type="hidden">
                    <input name="form_id" value="{$form_id}" type="hidden">
                    <input name="domain_id" value="{$record['id']}" type="hidden">

                    <div id="{$form_id}_filter_overlay"
                         style="position: relative;
                                display: inline;
                                color: #CACACA;
                                cursor: text;"
                         onClick="this.style.display = 'none'; el('{$form_id}_filter').focus();"
                    >Filter</div>
                    <input
                        id="{$form_id}_filter"
                        name="filter"
                        class="filter"
                        type="text"
                        value=""
                        size="10"
                        maxlength="20"
                        alt="Quick Filter"
                        onFocus="el('{$form_id}_filter_overlay').style.display = 'none';"
                        onBlur="if (this.value == '') el('{$form_id}_filter_overlay').style.display = 'inline';"
                        onKeyUp="
                            if (typeof(timer) != 'undefined') clearTimeout(timer);
                            code = 'if ({$form_id}_last_search != el(\\'{$form_id}_filter\\').value) {' +
                                   '    {$form_id}_last_search = el(\\'{$form_id}_filter\\').value;' +
                                   '    document.getElementById(\\'{$form_id}_page\\').value = 1;' +
                                   '    xajax_window_submit(\\'{$submit_window}\\', xajax.getFormValues(\\'{$form_id}\\'), \\'display_list\\');' +
                                   '}';
                            timer = setTimeout(code, 700);"
                    >
                    </form>
                </td>

            </tr>
        </table>

        <div id='{$content_id}'>
            {$conf['loading_icon']}
        </div>
EOL;
    if (auth('dns_record_add', $debug_val)) {
        $html .= <<<EOL

        <!-- List by IP Address LINK -->
        <div class="act-box" style="padding: 2px 4px; border-top: 1px solid {$color['border']}">
            <form id="form_dns_add_{$record['id']}">
                <input type="hidden" name="js" value="{$refresh}">
                <input type="hidden" name="domain_id" value="{$record['id']}">
            </form>

            <a title="Add DNS Record"
               class="linkact"
               onClick="xajax_window_submit('edit_record', xajax.getFormValues('form_dns_add_{$record['id']}'), 'editor');"
            ><img src="{$images}/silk/page_add.png">Add a new DNS record</a>&nbsp;

        </div>
EOL;
    }
    $html .= <<<EOL
    </div>
EOL;
    // If we have a build type set, then display the output div
    if ($conf['build_dns_type'] && auth('dns_record_add', $debug_val)) {
        // Get a list of the views so we can build a select option
        if ($conf['dns_views']) {
            list($status, $rows, $recs) = db_get_records($onadb, 'dns_views', 'id >= 0', 'name');
            $dns_view_list = '';
            foreach ($recs as $rec) {
                $rec['name'] = htmlentities($rec['name']);
                $dns_view_list .= "<option value=\"{$rec['id']}\">{$rec['name']}</option>\n";
            }
            $html .= <<<EOL
    <div style="margin: 10px 20px;padding-left: 8px;">
        <form>
        Show config for DNS view: <select name="build_dns_view"
                id="build_dns_view"
                class="edit"
                onchange="xajax_window_submit('{$window_name}', 'fqdn=>{$record['fqdn']},view=>'+el('build_dns_view').value , 'display_config');"
        >
            {$dns_view_list}
        </select>
        </form>
    </div>
EOL;
        }
        $html .= <<<EOL
    <div id="confoutputdiv" style="border: 1px solid rgb(26, 26, 26); margin: 10px 20px;padding-left: 8px;overflow:hidden;width: 100px;"><pre style='font-family: monospace;overflow-y:auto;' id="confoutput"><center>Generating configuration...</center><br>{$conf['loading_icon']}</pre></div>
EOL;
        $js .= "xajax_window_submit('{$window_name}', 'fqdn=>{$record['fqdn']}', 'display_config');";
    }
    $js .= <<<EOL
        /* Setup the quick filter */
        el('{$form_id}_filter_overlay').style.left = (el('{$form_id}_filter_overlay').offsetWidth + 10) + 'px';
        {$form_id}_last_search = '';

        /* Tell the browser to load/display the list */
        xajax_window_submit('{$submit_window}', xajax.getFormValues('{$form_id}'), 'display_list');

        setTimeout('el(\\'confoutputdiv\\').style.width = el(\\'{$form_id}_table\\').offsetWidth-8+\\'px\\';',900);
EOL;
    // Insert the new html into the window
    // Instantiate the xajaxResponse object
    $response = new xajaxResponse();
    $response->addAssign("work_space_content", "innerHTML", $html);
    if ($js) {
        $response->addScript($js);
    }
    return $response->getXML();
}