function subnet_conf($subnet = array(), $indent = 0)
{
    printmsg("DEBUG => subnet_conf(\$subnet, {$indent}) called", 5);
    // global $dhcp_entry_options;
    global $self;
    $exit = 0;
    // Validate input
    if (!(is_array($subnet) and count($subnet) > 0)) {
        return array(1, "");
    }
    // set the indent info if required
    $dent = '';
    if ($indent != 0) {
        $dent = '    ';
    }
    $text = "\n{$dent}# {$subnet['name']}\n";
    // Determine if this is a IPv6 address
    if ($subnet['ip_addr'] > '4294967295') {
        $text .= "{$dent}subnet6 " . ip_mangle($subnet['ip_addr'], 'ipv6') . "/" . ip_mangle($subnet['ip_mask'], 'cidr') . " {\n";
        // v6 does not allow a gateway defined, it uses the RA to do it.
        $hasgatewayoption = 1;
        $v6option = 'dhcp6.';
    } else {
        $text .= "{$dent}subnet " . long2ip($subnet['ip_addr']) . " netmask " . long2ip($subnet['ip_mask']) . " {\n";
        $hasgatewayoption = 0;
        $v6option = '';
    }
    // Loop through all of the dhcp entries and print them
    $i = 0;
    do {
        list($status, $rows, $dhcp_entry) = ona_get_dhcp_option_entry_record(array('subnet_id' => $subnet['id']));
        printmsg("DEBUG => subnet_conf(): Processing option {$dhcp_entry['display_name']}", 3);
        if (!$rows) {
            break;
        }
        if ($status) {
            $exit++;
            break;
        }
        // if the current dhcp entry is the "Default Gateway" option then set hasgatewayoption to 1
        if (strpos($dhcp_entry['name'], 'router') !== false) {
            printmsg("DEBUG => subnet_conf(\$subnet, {$indent}): --------.", 5);
            $hasgatewayoption = 1;
        }
        $i++;
        // format the tag appropriatly
        list($status, $formatted_entry) = format_tag($dhcp_entry);
        if ($formatted_entry) {
            $text .= "{$dent}    option {$v6option}{$dhcp_entry['name']} {$formatted_entry};\n";
        } else {
            $exit++;
            break;
        }
    } while ($i < $rows);
    // Loop through all of the dhcp pools and print them
    $i = 0;
    do {
        list($status, $poolrows, $pool) = ona_get_dhcp_pool_record(array('subnet_id' => $subnet['id']));
        if (!$rows) {
            break;
        }
        if ($status) {
            $exit++;
            break;
        }
        $i++;
        list($status, $srows, $server_subnet) = ona_get_dhcp_server_subnet_record(array('subnet_id' => $pool['subnet_id']));
        // if there is no failover group assignment and this pool is related to your server, print it
        if ($server_subnet['host_id'] == $self['serverid'] && $pool['dhcp_failover_group_id'] == 0) {
            printmsg("DEBUG => subnet_conf(\$subnet, {$indent}): Found pool with no failovergroup.", 5);
            list($status, $pool_entry) = process_dhcp_pool($pool, $indent);
            $text .= $pool_entry;
        }
        // if there is a failover group assignment, print the pool
        if ($pool['dhcp_failover_group_id'] != 0) {
            printmsg("DEBUG => subnet_conf(\$subnet, {$indent}): Found pool with a failovergroup", 5);
            list($status, $pool_entry) = process_dhcp_pool($pool, $indent);
            $text .= $pool_entry;
        }
    } while ($i < $poolrows);
    // Close the subnet block
    $text .= "{$dent}}\n";
    // Return the subnet block if there is a gateway option defined.
    if ($hasgatewayoption == 1) {
        return array($exit, $text);
    } else {
        printmsg("ERROR => subnet_conf({$subnet['name']}): Not enabling subnet, no gateway option defined. ", 0);
        $text = "\n{$dent}# WARNING => Subnet {$subnet['name']} has no default gateway opiton defined, skipping...\n";
        return array($exit, $text);
    }
}
Beispiel #2
0
function dhcp_server_del($options = "")
{
    // The important globals
    global $conf, $self, $onadb;
    // Version - UPDATE on every edit!
    $version = '1.03';
    printmsg("DEBUG => dhcp_server_del({$options}) called", 3);
    // Parse incoming options string to an array
    $options = parse_options($options);
    // Sanitize options[commit] (default is yes)
    $options['commit'] = sanitize_YN($options['commit'], 'N');
    // Return the usage summary if we need to
    if ($options['help'] or !($options['subnet'] 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

dhcp_server_del-v{$version}
Removes a subnet record from a DHCP server

  Synopsis: dhcp_server_del [KEY=VALUE] ...

  Required:
    subnet=NAME or ID               subnet name or ID
    server=NAME[.DOMAIN] or ID      server name or ID

  Optional:
    commit=[Y|N]                    commit db transaction (no)

  Notes:
    DOMAIN will default to {$conf['dns_defaultdomain']} if not specified


EOM
);
    }
    // Determine the entry itself exists
    list($status, $rows, $subnet) = ona_find_subnet($options['subnet']);
    // Test to see that we were able to find the specified record
    if (!$subnet['id']) {
        printmsg("DEBUG => Unable to find the subnet record using {$options['subnet']}!", 3);
        $self['error'] = "ERROR => Unable to find the subnet record using {$options['subnet']}!";
        return array(4, $self['error'] . "\n");
    }
    printmsg("DEBUG => dhcp_server_del(): Found subnet, {$subnet['name']}", 3);
    if ($options['server']) {
        // Determine the server is valid
        list($status, $rows, $host) = ona_find_host($options['server']);
        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");
        }
    }
    //printmsg("DEBUG => dhcp_server_del(): Found server, {$host['FQDN']}", 3);
    // Test that this subnet is even assigned to the server
    list($status, $rows, $dhcpserver) = ona_get_dhcp_server_subnet_record(array('host_id' => $host['id'], 'subnet_id' => $subnet['id']));
    if (!$rows) {
        printmsg("DEBUG => Unable to find {$subnet['name']} on server {$host['fqdn']}", 3);
        $self['error'] = "ERROR => Unable to find {$subnet['name']} on server {$host['fqdn']}";
        return array(11, $self['error'] . "\n");
    }
    // If "commit" is yes, delete the record
    if ($options['commit'] == 'Y') {
        // Check permissions
        if (!auth('advanced') or !authlvl($host['LVL']) or !authlvl($subnet['LVL'])) {
            $self['error'] = "Permission denied!";
            printmsg($self['error'], 0);
            return array(10, $self['error'] . "\n");
        }
        // check if allowed to remove subnet from server
        // check for pool assigned to the server itself
        list($status, $rows, $pools) = db_get_records($onadb, 'dhcp_pools', array('subnet_id' => $subnet['id']));
        foreach ($pools as $pool) {
            if ($pool['dhcp_failover_group_id']) {
                $foundfg = 0;
                list($status, $rows, $primary) = ona_get_dhcp_failover_group_record(array('id' => $pool['dhcp_failover_group_id'], 'primary_server_id' => $host['id']));
                if ($rows) {
                    $foundfg++;
                }
                list($status, $rows, $secondary) = ona_get_dhcp_failover_group_record(array('id' => $pool['dhcp_failover_group_id'], 'secondary_server_id' => $host['id']));
                if ($rows) {
                    $foundfg++;
                }
                // if a subnet/server pair is found in dhcp pools, don't allow removal
                if ($foundfg > 0) {
                    printmsg("DEBUG => Subnet ({$subnet['name']}) has a pool assigned to this Server ({$host['fqdn']}), which is part of a failover group.  The server must be removed from the failover group first.", 3);
                    $self['error'] = "ERROR => Subnet ({$subnet['name']}) has a pool assigned to this Server ({$host['fqdn']}), which is part of a failover group.  The server must be removed from the failover group first.";
                    return array(12, $self['error'] . "\n");
                }
            }
        }
        // MP: remove this after testing.  dhcp options should not stop us from dis-associating a subnet from a server
        //     Not really sure why I have this.. probably left over cruft from old thoughts
        //         // check if there are any DHCP parameters assigned to the subnet
        //         list($status, $rows, $tmp) = ona_get_dhcp_option_entry_record(array('subnet_id' => $subnet['id']));
        //
        //         // if so, check that this is not the last DHCP server that services this subnet
        //         if ($rows > 0) {
        //             list($status, $rows, $tmp) = ona_get_dhcp_server_subnet_record(array('subnet_id' => $subnet['id']));
        //
        //             // If this is the last DHCP server that services this subnet, don't allow removal until DHCP parameters are removed
        //             if($rows <= 1){
        //                 printmsg("DEBUG => Subnet ({$subnet['name']}) has DHCP parameters assigned which need to be removed first",3);
        //                 $self['error'] = "ERROR => Subnet ({$subnet['name']}) has DHCP parameters assigned which need to be removed first";
        //                 return(array(12, $self['error'] . "\n"));
        //             }
        //         }
        // delete record from dhcp_server_subnets
        list($status, $rows) = db_delete_records($onadb, 'dhcp_server_subnets', array('id' => $dhcpserver['id']));
        if ($status) {
            $self['error'] = "ERROR => dhcp_server_del() SQL Query failed:" . $self['error'];
            printmsg($self['error'], 0);
            return array(9, $self['error'] . "\n");
        }
        // Return the success notice
        $self['error'] = "INFO => DHCP Subnet/Server Pair DELETED: {$subnet['name']}/{$host['fqdn']} ";
        printmsg($self['error'], 0);
        return array(0, $self['error'] . "\n");
    }
    // Otherwise display the record that would have been deleted
    $text = <<<EOL
    Record(s) NOT DELETED (see "commit" option)
    Displaying record(s) that would have been removed:

    {$subnet['name']} from: {$host['fqdn']}

EOL;
    return array(6, $text);
}
Beispiel #3
0
function dhcp_entry_add($options = "")
{
    // The important globals
    global $conf, $self, $onadb;
    // Version - UPDATE on every edit!
    $version = '1.03';
    printmsg("DEBUG => dhcp_entry_add({$options}) called", 3);
    // Parse incoming options string to an array
    $options = parse_options($options);
    // if global is set to N then get rid of it entirely from the options array
    $options['global'] = sanitize_YN($options['global'], 'N');
    if ($options['global'] == 'N') {
        unset($options['global']);
    }
    // Return the usage summary if we need to
    if ($options['help'] or !($options['option'] and array_key_exists('value', $options) and ($options['server'] and !($options['host'] or $options['subnet'] or $options['global']) or $options['host'] and !($options['server'] or $options['subnet'] or $options['global']) or $options['subnet'] and !($options['host'] or $options['server'] or $options['global']) or array_key_exists('global', $options) and !($options['host'] or $options['server'] or $options['subnet'])))) {
        // NOTE: Help message lines should not exceed 80 characters for proper display on a console
        $self['error'] = 'ERROR => Insufficient parameters';
        return array(1, <<<EOM

dhcp_entry_add-v{$version}
Adds a dhcp entry into the database pointing to the specified identifier

  Synopsis: dhcp_entry_add [KEY=VALUE] ...

  Identifier (pick one):
    host=HOSTNAME[.DOMAIN] or ID            host identifier to add to
    subnet=NAME or ID                       subnet identifier to add to
    server=NAME[.DOMAIN] or ID              server identifier to add to
    global                                  global entry for all subnets/hosts etc

  Options (both required):
    option=DHCP option name                 DHCP option name (as identified in ONA)
    value=STRING                            string value for the DHCP type



EOM
);
    }
    // trim leading and trailing whitespace from 'value' and check that a value exists
    $dhcp_option_value = trim($options['value']);
    if (strlen($dhcp_option_value) == 0) {
        printmsg("DEBUG => The DHCP value was blank", 3);
        $self['error'] = "ERROR => DHCP value was blank";
        return array(2, $self['error'] . "\n");
    }
    if ($options['global'] == 'Y') {
        $anchor = 'global';
        $desc = 'Global DHCP option';
        $lvl = 0;
        $subnet['id'] = 0;
        $server['host_id'] = 0;
        $host['id'] = 0;
    } elseif ($options['host']) {
        // Determine the host is valid
        list($status, $rows, $host) = ona_find_host($options['host']);
        if (!$host['id']) {
            printmsg("DEBUG => The host specified, {$options['host']}, does not exist!", 3);
            $self['error'] = "ERROR => The host specified, {$options['host']}, does not exist!";
            return array(2, $self['error'] . "\n");
        }
        $anchor = 'host';
        $desc = $host['fqdn'];
        $lvl = $host['lvl'];
        $subnet['id'] = 0;
        $server['host_id'] = 0;
    } elseif ($options['subnet']) {
        // Determine the subnet is valid
        list($status, $rows, $subnet) = ona_find_subnet($options['subnet']);
        if (!$subnet['id']) {
            printmsg("DEBUG => The subnet specified, {$options['subnet']}, does not exist!", 3);
            $self['error'] = "ERROR => The subnet specified, {$options['subnet']}, does not exist!";
            return array(3, $self['error'] . "\n");
        }
        $anchor = 'subnet';
        $desc = "{$subnet['name']} (" . ip_mangle($subnet['ip_addr']) . ")";
        $lvl = $subnet['lvl'];
        $host['id'] = 0;
        $server['host_id'] = 0;
    } elseif ($options['server']) {
        // Determine the server is valid
        list($status, $rows, $host) = ona_find_host($options['server']);
        if (!$host['id']) {
            printmsg("DEBUG => The server specified, {$options['server']}, does not exist!", 3);
            $self['error'] = "ERROR => The server specified, {$options['server']}, does not exist!";
            return array(4, $self['error'] . "\n");
        }
        // Determine the host that was found is actually a server
        list($status, $rows, $server) = ona_get_dhcp_server_subnet_record(array('host_id' => $host['id']));
        if (!$rows) {
            printmsg("DEBUG => The host specified, {$host['fqdn']}, is not a DHCP server!", 3);
            $self['error'] = "ERROR => The host specified, {$host['fqdn']}, is not a DHCP server!";
            return array(5, $self['error'] . "\n");
        }
        $anchor = 'server';
        $desc = $host['fqdn'];
        $lvl = $host['lvl'];
        $host['id'] = 0;
        $subnet['id'] = 0;
    }
    // Determine the type is valid
    list($status, $rows, $type) = ona_find_dhcp_option($options['option']);
    if (!$type['id']) {
        printmsg("DEBUG => The DHCP parameter type specified, {$options['option']}, does not exist!", 3);
        $self['error'] = "ERROR => The DHCP parameter type specified, {$options['option']}, does not exist!";
        return array(8, $self['error'] . "\n");
    }
    printmsg("DEBUG => dhcp_entry_add(): Found DHCP option {$type['display_name']}", 3);
    // Make sure this isn't a duplicate
    $search = array('dhcp_option_id' => $type['id'], 'host_id' => 0, 'subnet_id' => 0);
    if ($host['id']) {
        $search['host_id'] = $host['id'];
    }
    if ($subnet['id']) {
        $search['subnet_id'] = $subnet['id'];
    }
    if ($server['id']) {
        $search['server_id'] = $server['id'];
    }
    list($status, $rows, $record) = ona_get_dhcp_option_entry_record($search);
    if ($status or $rows) {
        printmsg("DEBUG => That DHCP option, {$type['display_name']}, is already defined!", 3);
        $self['error'] = "ERROR => That DHCP option ({$type['display_name']}) is already defined!";
        return array(11, $self['error'] . "\n");
    }
    // Check permissions
    if (!auth('advanced') or !authlvl($lvl)) {
        $self['error'] = "Permission denied!";
        printmsg($self['error'], 0);
        return array(10, $self['error'] . "\n");
    }
    // Get the next id
    $id = ona_get_next_id('dhcp_option_entries');
    if (!$id) {
        $self['error'] = "ERROR => The ona_get_next_id() call failed!";
        printmsg($self['error'], 0);
        return array(6, $self['error'] . "\n");
    }
    printmsg("DEBUG => dhcp_entry_add(): New ID: {$id}", 3);
    // Add the record
    list($status, $rows) = db_insert_record($onadb, 'dhcp_option_entries', array('id' => $id, 'dhcp_option_id' => $type['id'], 'value' => $dhcp_option_value, 'host_id' => $host['id'], 'server_id' => $server['host_id'], 'subnet_id' => $subnet['id']));
    if ($status or !$rows) {
        $self['error'] = "ERROR => dhcp_entry_add() SQL Query failed: " . $self['error'];
        printmsg($self['error'], 0);
        return array(7, $self['error'] . "\n");
    }
    // Return the success notice
    $self['error'] = "INFO => DHCP entry ADDED: {$type['display_name']}={$dhcp_option_value} on {$desc} ";
    printmsg($self['error'], 0);
    return array(0, $self['error'] . "\n");
}
Beispiel #4
0
function ws_display_list($window_name, $form = '')
{
    global $conf, $self, $onadb;
    global $images, $color, $style;
    $html = '';
    $js = '';
    $debug_val = 3;
    // used in the auth() calls to supress logging
    // If the user supplied an array in a string, build the array and store it in $form
    $form = parse_options_string($form);
    // Find the "tab" we're on
    $tab = $_SESSION['ona'][$form['form_id']]['tab'];
    // Build js to refresh this list
    $refresh = "xajax_window_submit('{$window_name}', xajax.getFormValues('{$form['form_id']}'), 'display_list');";
    // If it's not a new query, load the previous query from the session
    // into $form and save the current page and filter in the session.
    // Also find/set the "page" we're viewing
    $page = 1;
    if ($form['page'] and is_numeric($form['page'])) {
        $form = array_merge($form, (array) $_SESSION['ona'][$form['form_id']][$tab]['q']);
        $_SESSION['ona'][$form['form_id']][$tab]['page'] = $page = $form['page'];
        $_SESSION['ona'][$form['form_id']][$tab]['filter'] = $form['filter'];
    }
    // Calculate the SQL query offset (based on the page being displayed)
    $offset = $conf['search_results_per_page'] * ($page - 1);
    if ($offset == 0) {
        $offset = -1;
    }
    // Search results go in here
    $results = array();
    $count = 0;
    //
    //       FIND RESULT SET
    //
    // Start building the "where" clause for the sql query to find the subnets to display
    $where = "";
    $and = "";
    // SERVER ID
    if ($form['server_id']) {
        $where .= $and . 'id IN (SELECT subnet_id
                                FROM   dhcp_server_subnets
                                WHERE  host_id = ' . $onadb->qstr($form['server_id']) . '
                                UNION
                                SELECT subnet_id
                                FROM dhcp_pools
                                WHERE dhcp_failover_group_id IN (SELECT id
                                                                FROM dhcp_failover_groups
                                                                WHERE primary_server_id = ' . $onadb->qstr($form['server_id']) . '
                                                                OR secondary_server_id = ' . $onadb->qstr($form['server_id']) . '))';
        $and = " AND ";
    }
    // Do the SQL Query
    $filter = '';
    if ($form['filter']) {
        // Subnet descriptions are always upper case
        $form['filter'] = strtoupper($form['filter']);
        $filter = $and . ' name LIKE ' . $onadb->qstr('%' . $form['filter'] . '%');
    }
    list($status, $rows, $results) = db_get_records($onadb, 'subnets', $where . $filter, 'ip_addr', $conf['search_results_per_page'], $offset);
    // If we got less than serach_results_per_page, add the current offset to it
    // so that if we're on the last page $rows still has the right number in it.
    if ($rows > 0 and $rows < $conf['search_results_per_page']) {
        $rows += $conf['search_results_per_page'] * ($page - 1);
    } else {
        if ($rows >= $conf['search_results_per_page']) {
            list($status, $rows, $records) = db_get_records($onadb, 'subnets', $where . $filter, "", 0);
        }
    }
    $count = $rows;
    //
    // *** BUILD HTML LIST ***
    //
    $html .= <<<EOL
    <!-- Subnet Results -->
    <table id="{$form['form_id']}_dhcp_server_list" class="list-box" cellspacing="0" border="0" cellpadding="0">

        <!-- Table Header -->
        <tr>
            <td class="list-header" align="center" style="{$style['borderR']};">Name</td>
            <td class="list-header" align="center" style="{$style['borderR']};">Subnet</td>
            <td class="list-header" align="center" style="{$style['borderR']};">Usage</td>
            <td class="list-header" align="center" style="{$style['borderR']};">Type</td>
            <td class="list-header" align="center">&nbsp;</td>
        </tr>
EOL;
    // Loop and display each record
    foreach ($results as $record) {
        // Get additional info about eash subnet record //
        // Convert IP and Netmask to a presentable format
        $record['ip_addr'] = ip_mangle($record['ip_addr'], 'dotted');
        $record['ip_mask'] = ip_mangle($record['ip_mask'], 'dotted');
        $record['ip_mask_cidr'] = ip_mangle($record['ip_mask'], 'cidr');
        list($status, $rows, $type) = ona_get_subnet_type_record(array('id' => $record['subnet_type_id']));
        $record['type'] = $type['display_name'];
        // Calculate the percentage of the subnet that's used (total size - allocated hosts - dhcp pool size)
        $usage_html = get_subnet_usage_html($record['id']);
        // Escape data for display in html
        foreach (array_keys($record) as $key) {
            $record[$key] = htmlentities($record[$key], ENT_QUOTES, $conf['php_charset']);
        }
        $primary_object_js = "xajax_window_submit('work_space', 'xajax_window_submit(\\'display_subnet\\', \\'subnet_id=>{$record['id']}\\', \\'display\\')');";
        $html .= <<<EOL
        <tr onMouseOver="this.className='row-highlight'" onMouseOut="this.className='row-normal'">

            <td class="list-row">
                <a title="View subnet. ID: {$record['id']}"
                   class="nav"
                   onClick="{$primary_object_js}"
                >{$record['name']}</a>
            </td>

            <td class="list-row" align="left">
                {$record['ip_addr']} <span title="{$record['ip_mask']}">/{$record['ip_mask_cidr']}</span>&nbsp;
            </td>

            <td class="list-row" align="center" style="vertical-align: middle;">
                {$usage_html}
            </td>

            <td class="list-row" align="right">
                {$record['type']}&nbsp;
            </td>

            <td class="list-row" align="right">
                <form id="{$form['form_id']}_list_dhcp_server_{$record['id']}"
                    ><input type="hidden" name="subnet_id" value="{$record['id']}"
                    ><input type="hidden" name="server_id" value="{$form['server_id']}"
                    ><input type="hidden" name="js" value="{$refresh}"
                ></form>

                <a title="Display subnet map"
                   class="act"
                   onClick="xajax_window_submit('work_space', 'xajax_window_submit(\\'display_block_map\\', \\'ip_block_start=>{$record['ip_addr']}\\', \\'display\\');');"
                ><img src="{$images}/silk/shape_align_left.png" border="0"></a>&nbsp;
EOL;
        if (auth('subnet_modify', $debug_val)) {
            $html .= <<<EOL

                <a title="Edit subnet"
                   class="act"
                   onClick="xajax_window_submit('edit_subnet', xajax.getFormValues('{$form['form_id']}_list_dhcp_server_{$record['id']}'), 'editor');"
                ><img src="{$images}/silk/page_edit.png" border="0"></a>&nbsp;
EOL;
        }
        // check if the subnet listed is from a failover group or an actual dhcp server subnet assignment
        list($dhcpsubnetstatus, $dhcpsubnetrows, $dhcpserver) = ona_get_dhcp_server_subnet_record(array('subnet_id' => $record['id'], 'host_id' => $form['server_id']));
        if (auth('subnet_del', $debug_val) && $dhcpsubnetrows == 1) {
            $html .= <<<EOL

                <a title="Remove subnet association with server."
                   class="act"
                   onClick="var doit=confirm('Are you sure you want to remove this subnet from this DHCP server?');
                        if (doit == true)
                            xajax_window_submit('edit_dhcp_server', xajax.getFormValues('{$form['form_id']}_list_dhcp_server_{$record['id']}'), 'delete');"
                ><img src="{$images}/silk/page_delete.png" border="0"></a>&nbsp;
EOL;
        } else {
            $html .= <<<EOL
                <span title="You must change the failover group assignment on the pool to remove this entry."><img src="{$images}/silk/comment.png" border="0"></span>&nbsp;
EOL;
        }
        $html .= <<<EOL

            </td>

        </tr>
EOL;
    }
    $html .= <<<EOL
    </table>
EOL;
    // Build page links if there are any
    $html .= get_page_links($page, $conf['search_results_per_page'], $count, $window_name, $form['form_id']);
    // If there was only 1 result, and we're about to display results in the "Search Results" window, display it.
    if ($count == 1 and $form['content_id'] == 'search_results_list' and $form['filter'] == '') {
        $js .= $primary_object_js;
    }
    // Insert the new html into the content div specified
    // Instantiate the xajaxResponse object
    $response = new xajaxResponse();
    $response->addAssign("{$form['form_id']}_{$tab}_count", "innerHTML", "({$count})");
    $response->addAssign($form['content_id'], "innerHTML", $html);
    if ($js) {
        $response->addScript($js);
    }
    return $response->getXML();
}
Beispiel #5
0
                                                                WHERE id IN (SELECT dhcp_failover_group_id
                                                                                                FROM dhcp_pools
                                                                                                WHERE subnet_id = ' . $record['id'] . ')
                                                                UNION
                                                                SELECT secondary_server_id
                                                                FROM  dhcp_failover_groups
                                                                WHERE id IN (SELECT dhcp_failover_group_id
                                                                                                FROM dhcp_pools
                                                                                                WHERE subnet_id = ' . $record['id'] . '))');
if ($rows) {
    $modbodyhtml .= <<<EOL
        <table width=100% cellspacing="0" border="0" cellpadding="0" style="margin-bottom: 8px;">
EOL;
    foreach ($dhcpservers as $dhcphost) {
        list($status, $rows, $host) = ona_find_host($dhcphost['id']);
        list($dhcpsubnetstatus, $dhcpsubnetrows, $dhcpserver) = ona_get_dhcp_server_subnet_record(array('subnet_id' => $record['id'], 'host_id' => $host['id']));
        $host['fqdn'] = htmlentities($host['fqdn'], ENT_QUOTES);
        $modbodyhtml .= <<<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_dhcp_server\\', \\'host_id=>{$host['id']}\\', \\'display\\')');"
                    >{$host['fqdn']}</a>&nbsp;
                </td>
                    <td align="right" nowrap="true">
EOL;
        if (auth('advanced', $debug_val) && $dhcpsubnetrows == 1) {
            $modbodyhtml .= <<<EOL
                    <form id="form_dhcp_serv_{$dhcpserver['id']}"