本文整理汇总了PHP中db_get_records函数的典型用法代码示例。如果您正苦于以下问题:PHP db_get_records函数的具体用法?PHP db_get_records怎么用?PHP db_get_records使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了db_get_records函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get_module_list
function get_module_list($options = "type=string")
{
global $conf, $self, $onadb;
printmsg('DEBUG => get_module_list(' . $options . ') called', 3);
// Version - UPDATE on every edit!
$version = '1.01';
// Parse incoming options string to an array
$options = parse_options($options);
// Return the usage summary if we need to
if ($options['help'] or !$options['type']) {
$self['error'] = 'ERROR => Insufficient parameters';
// NOTE: Help message lines should not exceed 80 characters for proper display on a console
return array(1, <<<EOM
get_module_list-v{$version}
Returns a list of available DCM modules
Synopsis: get_module_list(OPTIONS)
Options:
type=<string|perl|array> format module list in the specified format
string = human readable for console
perl = hash for perl parsing
array = php array
EOM
);
}
// $pad_length is the amount of padding to put after each NAME.
$pad_length = 25;
$modules_string = str_pad('NAME', $pad_length) . " :: DESCRIPTION\n";
$modules_perl = "";
$modules_array = array();
// Get a list of the valid "modules" and their descriptions.
// FIXME: move this to the db later!
list($status, $rows, $modules) = db_get_records($onadb, 'dcm_module_list', '1', 'name');
printmsg("DEBUG => get_module_list() found {$rows} modules in db", 4);
foreach ($modules as $module) {
if ($module['name'] != 'get_module_list') {
$modules_string .= str_pad($module['name'], $pad_length) . " :: {$module['description']}\n";
}
$modules_array[$module['name']] = $module['description'];
$modules_perl .= "\$modules{'{$module['name']}'} = \"{$module['description']}\";\n";
}
// Return the list of modules as a string or array.
if ($options['type'] == 'string') {
return array(0, "\n" . $modules_string . "\n");
} else {
if ($options['type'] == 'array') {
return array(0, $modules_array);
} else {
if ($options['type'] == 'perl') {
return array(0, $modules_perl);
} else {
return array(3, "ERROR => get_module_list() Invalid \"type\" specified!");
}
}
}
}
示例2: ws_display_list
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);
// Override system default for lists.. we want logs to show more
$conf['search_results_per_page'] = 20;
// 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;
// Start building the "where" clause for the sql query to find the vlans to display
$where = "";
$and = "";
// DISPLAY ALL VLAN CAMPUSES
if ($form['all_flag']) {
$where .= $and . "id > 0";
$and = " AND ";
}
// CAMPUS ID
if ($form['id']) {
$where .= $and . "id = " . $onadb->qstr($form['id']);
$and = " AND ";
}
// CAMPUS NAME
if ($form['username']) {
$where .= $and . " username LIKE " . $onadb->qstr('%' . $form['username'] . '%');
$and = " AND ";
}
// Wild card .. if $while is still empty, add a 'ID > 0' to it so you see everything.
if ($where == '') {
$where = 'id > 0';
}
// Do the SQL Query
$filter = '';
if ($form['filter']) {
$filter = ' AND username LIKE ' . $onadb->qstr('%' . $form['filter'] . '%');
}
list($status, $rows, $results) = db_get_records($onadb, 'ona_logs', $where . $filter, "timestamp DESC", $conf['search_results_per_page'], $offset);
// If we got less than search_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, 'ona_logs', $where . $filter, "", 0);
}
}
$count = $rows;
$html .= <<<EOL
<!-- List -->
<table id="{$form['form_id']}_ona_db_logs_list" class="list-box" cellspacing="0" border="0" cellpadding="0">
<!-- Table Header -->
<tr>
<td class="list-header" align="center" style="{$style['borderR']};">Timestamp</td>
<td class="list-header" align="center" style="{$style['borderR']};">Username</td>
<td class="list-header" align="center" style="{$style['borderR']};">Remote location</td>
<td class="list-header" align="center" style="{$style['borderR']};">Context</td>
<td class="list-header" align="center">Message</td>
</tr>
EOL;
// Loop and display each record
foreach ($results as $record) {
// Escape data for display in html
foreach (array_keys($record) as $key) {
$record[$key] = htmlentities($record[$key], ENT_QUOTES, $conf['php_charset']);
}
$html .= <<<EOL
<tr onMouseOver="this.className='row-highlight'" onMouseOut="this.className='row-normal'">
<td class="list-row">
{$record['timestamp']}
</td>
<td class="list-row" align="left">
{$record['username']}
</td>
//.........这里部分代码省略.........
示例3: list
<td colspan="5" align="left" valign="middle" nowrap="true" class="act-box">
<form id="form_dhcp_entry_add_{$kind}_{$record['id']}"
><input type="hidden" name="{$kind}_id" value="{$record['id']}"
><input type="hidden" name="js" value="{$extravars['refresh']}"
></form>
<a title="Add DHCP Entry"
class="act"
onClick="xajax_window_submit('edit_dhcp_option_entry', xajax.getFormValues('form_dhcp_entry_add_{$kind}_{$record['id']}'), 'editor');"
><img src="{$images}/silk/page_add.png" border="0"></a>
<a title="Add DHCP Entry"
class="act"
onClick="xajax_window_submit('edit_dhcp_option_entry', xajax.getFormValues('form_dhcp_entry_add_{$kind}_{$record['id']}'), 'editor');"
>Add DHCP Entry</a>
</td>
</tr>
EOL;
}
$modbodyhtml .= "</table>";
}
// Show a menu warning about gateway missing
if ($kind == 'subnet' and $hasgateway == 0) {
list($status, $rows, $dhcp_servers) = db_get_records($onadb, 'dhcp_server_subnets', array('subnet_id' => $record['id']));
if ($rows or $poolrows) {
$modwsmenu[0]['menutitle'] = "Add DHCP Entry <span style='background-color: #FFDDDD;'>(<img src='{$images}/silk/error.png' border='0'>Gateway)</span>";
}
}
// END DHCP ENTRIES LIST
unset($rec_content);
示例4: elseif
<?php
$title_left_html = 'Custom Attributes';
// Determine if this is a host, a subnet or a vlan we are dealing with
if (is_numeric($record['subnet_type_id'])) {
$kind = 'subnet';
} elseif (is_numeric($record['device_id'])) {
$kind = 'host';
} else {
$kind = 'vlan';
}
// This adds an "s" at the end of the table name. assumes all tables are plural
list($status, $rows, $attributes) = db_get_records($onadb, 'custom_attributes', array('table_id_ref' => $record['id'], 'table_name_ref' => $kind . 's'), '');
// create workspace menu items
// This is where you list an array of menu items to display for this workspace
$modwsmenu[0]['menutitle'] = 'Add Custom Attribute';
$modwsmenu[0]['tooltip'] = "Add Custom Attribute to this {$kind}";
$modwsmenu[0]['authname'] = 'custom_attribute_add';
$modwsmenu[0]['commandjs'] = "xajax_window_submit('edit_custom_attribute', xajax.getFormValues('form_{$kind}_{$record['id']}'), 'editor');";
$modwsmenu[0]['image'] = '/images/silk/tag_blue.png';
// CUSTOM ATTRIBUTES LIST
if ($rows) {
$modbodyhtml .= <<<EOL
<!-- CUSTOM ATTRIBUTES -->
<table width=100% cellspacing="0" border="0" cellpadding="0" style="margin-bottom: 8px; margin-top: 0px;">
EOL;
foreach ($attributes as $entry) {
list($status, $rows, $ca_type) = ona_get_custom_attribute_record(array('id' => $entry['id']));
$modbodyhtml .= <<<EOL
<tr onMouseOver="this.className='row-highlight';"
onMouseOut="this.className='row-normal';">
示例5: config_diff
function config_diff($options = "")
{
// The important globals
global $conf;
global $self;
global $onadb;
// Version - UPDATE on every edit!
$version = '1.03';
printmsg('DEBUG => config_diff(' . $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['host'] or !$options['type']) and (!$options['ida'] or !$options['idb'])) {
// NOTE: Help message lines should not exceed 80 characters for proper display on a console
return array(1, <<<EOM
config_diff-v{$version}
Displays the difference between selected archive entries
Synopsis: config_diff [KEY=VALUE] ...
Required:
host=ID or NAME[.DOMAIN] display most recent config for specified host
type=TYPE type of config to display -
usually "IOS_VERSION" or "IOS_CONFIG"
OR
ida=ID First config ID to compare against idb
idb=ID Second config ID to compare against ida
Note:
If you don't pass any IDs you will get the two most recent configs
related to the host/type you provide.
EOM
);
}
$text = "";
// Compare arbitrary configs based on config IDs
// If we have ids, lets use those instead
if ($options['ida'] and $options['idb']) {
// get the two configs from the db
list($status, $rows, $configs) = db_get_records($onadb, 'configurations', "id in ({$options['ida']},{$options['idb']})", 'ctime DESC', '2', '');
} else {
// Get a config record if there is one
$self['error'] = "";
list($status, $rows, $config) = ona_find_config($options);
list($status, $rows, $configs) = db_get_records($onadb, 'configurations', array('host_id' => $config['host_id'], 'configuration_type_id' => $config['configuration_type_id']), 'ctime DESC', '2', '');
}
// Error if an error was returned
if ($status or $rows != 2) {
if ($self['error']) {
$text = $self['error'] . "\n";
}
$text .= "ERROR => One or more config text entries not found!\n";
return array(2, $text);
}
// Get a unified text diff output
$text .= text_diff($configs[1]['config_body'], $configs[0]['config_body']);
// Return the success notice
return array(0, $text);
}
示例6: ws_interface_move_save
function ws_interface_move_save($window_name, $form = '')
{
global $base, $include, $conf, $self, $onadb;
// Check permissions
if (!auth('advanced')) {
$response = new xajaxResponse();
$response->addScript("alert('Permission denied!');");
return $response->getXML();
}
// Instantiate the xajaxResponse object
$response = new xajaxResponse();
$js = '';
$refresh = "xajax_window_submit('list_interfaces', xajax.getFormValues('list_interfaces_filter_form'), 'display_list');";
// Validate input
if (!$form['host'] and !$form['ip']) {
$response->addScript("alert('Please complete all fields to continue!');");
return $response->getXML();
}
list($status, $total_interfaces, $ints) = db_get_records($onadb, 'interfaces', array('host_id' => $form['orig_host']), '', 0);
// Decide if we're editing or adding
$module = 'interface_move_host';
// Run the module
list($status, $output) = run_module($module, $form);
// If the module returned an error code display a popup warning
if ($status) {
$js .= "alert('Save failed. " . preg_replace('/[\\s\']+/', ' ', $self['error']) . "');";
} else {
// Check if this is the last interface, if it is, delete the host too.
if ($total_interfaces == 0) {
// Run the host del module
list($status, $output) = run_module('host_del', array('host' => $form['orig_host'], 'commit' => 'y'));
if ($status) {
// If the host del failed, move the interface back to the original host to clean things up
list($status, $output) = run_module('interface_move_host', array('host' => $form['orig_host'], 'ip' => $form['ip']));
$js .= "alert('Host delete failed. " . preg_replace('/[\\s\']+/', ' ', $self['error']) . "');";
} else {
$js .= "removeElement('{$window_name}');{$refresh}";
if ($form['js']) {
$js .= $form['js'];
}
}
} else {
$js .= "removeElement('{$window_name}');{$refresh}";
if ($form['js']) {
$js .= $form['js'];
}
}
}
// Insert the new table into the window
$response->addScript($js);
return $response->getXML();
}
示例7: dns_record_del
function dns_record_del($options = "")
{
global $conf, $self, $onadb;
printmsg("DEBUG => dns_record_del({$options}) called", 3);
// Version - UPDATE on every edit!
$version = '1.03';
// Parse incoming options string to an array
$options = parse_options($options);
// Sanitize options[commit] (default is no)
$options['commit'] = sanitize_YN($options['commit'], 'N');
// 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_del-v{$version}
Deletes a DNS record from the database
Synopsis: dns_record_del [KEY=VALUE] ...
Required:
name=NAME[.DOMAIN] or ID hostname or ID of the record to delete
type=TYPE record type (A,CNAME,PTR...)
Optional:
ip=ADDRESS ip address (numeric or dotted)
commit=[yes|no] commit db transaction (no)
EOM
);
}
/*
thoughts on the flow of things:
A records:
remove any CNAMES using this A record
remove any PTR records using this A record
test that it is not a primary_dns_id, if it is, it must be reassigned
should make a find_dns_record(s) function. a find by host option would be good.
need to do a better delete of DNS records when deleting a host.. currently its a problem.
MP: TODO: this delete will not handle DNS views unless you use the ID of the record to delete. add a view option at some point.
*/
// If the name we were passed has a leading . in it then remove the dot.
$options['name'] = preg_replace("/^\\./", '', $options['name']);
// FIXME: MP Fix this to use a find_dns_record function ID only for now
// Find the DNS record from $options['name']
list($status, $rows, $dns) = ona_find_dns_record($options['name'], $options['type']);
printmsg("DEBUG => dns_record_del() DNS record: {$options['name']}", 3);
if (!$dns['id']) {
printmsg("DEBUG => Unknown DNS record: {$options['name']} ({$options['type']})", 3);
$self['error'] = "ERROR => Unknown DNS record: {$options['name']} ({$options['type']})";
return array(2, $self['error'] . "\n");
}
// Check permissions
if (!auth('host_del') or !authlvl($host['LVL'])) {
$self['error'] = "Permission denied!";
printmsg($self['error'], 0);
return array(10, $self['error'] . "\n");
}
// If "commit" is yes, delete the host
if ($options['commit'] == 'Y') {
$text = "";
$add_to_error = "";
// SUMMARY:
// Display any associated PTR records for an A record
// Display any associated CNAMEs for an A record
// Test if it is used as a primary_dns_id unless it is the host_del module calling
if (!isset($options['delete_by_module'])) {
list($status, $rows, $srecord) = db_get_record($onadb, 'hosts', array('primary_dns_id' => $dns['id']));
if ($rows) {
$self['error'] = "ERROR => dns_record_del() The DNS record, {$dns['name']}.{$dns['domain_fqdn']}[{$dns['id']}], is a primary A record for a host! You can not delete it until you associate a new primary record, or delete the host.";
printmsg($self['error'], 0);
return array(5, $self['error'] . "\n");
}
}
// Delete related Points to records
// get list for logging
list($status, $rows, $records) = db_get_records($onadb, 'dns', array('dns_id' => $dns['id']));
// do the delete
list($status, $rows) = db_delete_records($onadb, 'dns', array('dns_id' => $dns['id']));
if ($status) {
$self['error'] = "ERROR => dns_record_del() Child record delete SQL Query failed: {$self['error']}";
printmsg($self['error'], 0);
return array(5, $self['error'] . "\n");
}
if ($rows) {
// log deletions
// FIXME: do better logging here
printmsg("INFO => {$rows} child DNS record(s) DELETED from {$dns['fqdn']}", 0);
$add_to_error .= "INFO => {$rows} child record(s) DELETED from {$dns['fqdn']}\n";
}
// TRIGGER: flag the domains for rebuild
foreach ($records as $record) {
list($status, $rows) = db_update_record($onadb, 'dns_server_domains', array('domain_id' => $record['domain_id']), array('rebuild_flag' => 1));
if ($status) {
$self['error'] = "ERROR => dns_record_del() Unable to update rebuild flags for domain.: {$self['error']}";
printmsg($self['error'], 0);
return array(7, $self['error'] . "\n");
//.........这里部分代码省略.........
示例8: build_dhcpd_conf
function build_dhcpd_conf($options = "")
{
global $self;
global $conf;
global $onadb;
// Version - UPDATE on every edit!
$version = '1.10';
// Exit status of the function
$exit = 0;
printmsg('DEBUG => build_dhcpd_conf(' . $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['server']) {
// NOTE: Help message lines should not exceed 80 characters for proper display on a console
return array(1, <<<EOM
build_dhcpd_conf-v{$version}
Builds configuration for dhcpcd from the database
Synopsis: build_dhcpd_conf [KEY=VALUE] ...
Required:
server=NAME[.DOMAIN] or ID Build conf by hostname or HOST_ID
Optional:
header_path=PATH Path to the server local header to include
Notes:
* Specified host must be a valid DHCP server
* header_path is a file on the DHCP server. It will be defined at
the very top of your configuration using the DHCP "include" directive.
EOM
);
}
// TODO: ipv6 need to pass in if we want v4 or v6.. default to v4 for now.
// looks like you cant have a mixed config
// Debugging
printmsg("DEBUG => Building DHCP config for: {$options['server']}", 3);
// Validate that there is already a host named $options['server'].
list($status, $rows, $host) = ona_find_host($options['server']);
if (!$host['id']) {
return array(2, "ERROR => No such host: {$options['server']}\n");
}
// Now determine if that host is a valid server
list($status, $dhcp_rows, $dhcp_server) = db_get_records($onadb, 'dhcp_server_subnets', array('host_id' => $host['id']), '');
list($status, $dhcpf_rows, $dhcpf_server) = db_get_records($onadb, 'dhcp_failover_groups', "primary_server_id = {$host['id']} or secondary_server_id = {$host['id']}", '');
if ($dhcp_rows == 0 and $dhcpf_rows == 0) {
return array(3, "ERROR => Specified host is not a DHCP server: {$options['server']}\n");
}
// Throw the host id into a self variable for later use
$self['serverid'] = $host['id'];
// Start an output variable with build timestamp
$text .= "###### DO NOT EDIT THIS FILE ###### \n";
$text .= "# dhcpd.conf file for {$host['fqdn']} built on " . date($conf['date_format']) . "\n#\n";
$text .= "# This file is built by an automated script. Any change to this \n";
$text .= "# file will be lost at the next build.\n\n";
// setup standard include path
// TODO: MP possibly put this into a configuration option like header so the user can easily change where this is.
if (isset($options['header_path'])) {
$text .= "include \"{$options['header_path']}\";\n";
}
/////////////////////////////// Build global options //////////////////////////////////////////
list($status, $globals) = build_global($host['id']);
$text .= $globals;
/////////////////////////////// Failover groups //////////////////////////////////////////
// build list of failover group statements for provided server
list($status, $failovergroup) = ona_dhcp_build_failover_group($host['id']);
$text .= $failovergroup;
/////////////////////////////// shared subnets //////////////////////////////////////////
// setup a variable to keep track of which vlan we are on
$vlananchor = '';
// Loop through all of the vlan subnets and print them
printmsg("DEBUG => Processing all Shared (VLAN) Subnets", 1);
$i = 0;
do {
list($status, $rows, $vlan_subnet) = ona_get_record('vlan_id != 0 AND
id IN (SELECT subnet_id
FROM dhcp_server_subnets
WHERE host_id = ' . $host['id'] . '
UNION
SELECT subnet_id
FROM dhcp_pools
WHERE dhcp_failover_group_id IN (SELECT id
FROM dhcp_failover_groups
WHERE primary_server_id = ' . $host['id'] . '
OR secondary_server_id = ' . $host['id'] . '))', 'subnets', 'vlan_id ASC');
if ($status) {
printmsg($self['error'], 0);
$exit += $status;
}
if ($rows == 0) {
printmsg("DEBUG => build_dhcpd_conf(): Found no shared subnets.", 3);
break;
} else {
if ($i == 0) {
$text .= "# --------SHARED SUBNETS (count={$rows})--------\n\n";
}
//.........这里部分代码省略.........
示例9: rpt_get_data
function rpt_get_data($form)
{
global $base, $onadb;
// If they want to perform a scan on an existing file
if ($form['subnet']) {
$rptdata['scansource'] = "Based on an existing scan file for '{$form['subnet']}'";
//$xml = shell_exec("{$nmapcommand} -sP -R -oX - {$form['subnet']}");
list($status, $rows, $subnet) = ona_find_subnet($form['subnet']);
if ($rows) {
$netip = ip_mangle($subnet['ip_addr'], 'dotted');
$netcidr = ip_mangle($subnet['ip_mask'], 'cidr');
$nmapxmlfile = "{$base}/local/nmap_scans/subnets/{$netip}-{$netcidr}.xml";
if (file_exists($nmapxmlfile)) {
$xml[0] = xml2ary(file_get_contents($nmapxmlfile));
} else {
$self['error'] = "ERROR => The subnet '{$form['subnet']}' does not have an nmap scan XML file on this server. {$nmapxmlfile}";
return array(2, $self['error'] . "\n");
}
} else {
$self['error'] = "ERROR => The subnet '{$form['subnet']}' does not exist.";
return array(2, $self['error'] . "\n");
}
}
// If they want to build a report on ALL the nmap data
if ($form['all']) {
$rptdata['scansource'] = "Showing all scan data";
$nmapdir = "{$base}/local/nmap_scans/subnets";
$dh = @opendir($nmapdir);
$c = 0;
while (false !== ($filename = @readdir($dh))) {
if (strpos($filename, 'xml')) {
$xml[$c] = xml2ary(file_get_contents($nmapdir . '/' . $filename));
}
$c++;
}
}
// If they pass a file from the remote host via CLI
if ($form['file']) {
$rptdata['scansource'] = "Based on an uploaded XML file";
$nmapxmlfile = $form['file'];
// clean up escaped characters
$nmapxmlfile = preg_replace('/\\\\"/', '"', $nmapxmlfile);
$nmapxmlfile = preg_replace('/\\\\=/', '=', $nmapxmlfile);
$nmapxmlfile = preg_replace('/\\\\&/', '&', $nmapxmlfile);
$xml[0] = xml2ary($nmapxmlfile);
}
// loop through all the xml arrays that have been built.
for ($z = 0; $z < count($xml); $z++) {
// Find out how many total hosts we have in the array
$rptdata['totalhosts'] = $xml[$z]['nmaprun']['_c']['runstats']['_c']['hosts']['_a']['total'];
$rptdata['runtime'] = $xml[$z]['nmaprun']['_c']['runstats']['_c']['finished']['_a']['timestr'];
// pull args to find subnet/cidr
$rptdata['args'] = $xml[$z]['nmaprun']['_a']['args'];
// process args
list($subnetaddr, $netcidr) = explode('/', preg_replace("/.* (.*)\\/(\\d+)\$/", "\\1/\\2", $rptdata['args']));
$netip = ip_mangle($subnetaddr, 'dotted');
$netcidr = ip_mangle($netcidr, 'cidr');
// Process the array for the total amount of hosts reported
for ($i = 0; $i < $rptdata['totalhosts']; $i++) {
// Clear MAC each itteration of the loop
$macaddr = '';
// Gather some info from the nmap XML file
$netstatus = $xml[$z]['nmaprun']['_c']['host'][$i]['_c']['status']['_a']['state'];
$ipaddr = $xml[$z]['nmaprun']['_c']['host'][$i]['_c']['address']['_a']['addr'];
//$macaddr = $xml['nmaprun']['_c']['host'][$i]['_c']['address']['_a']['addr'];
$dnsname = $xml[$z]['nmaprun']['_c']['host'][$i]['_c']['hostnames']['_c']['hostname']['_a']['name'];
$dnsrows = 0;
$dns = array();
// Try the older nmap format if no IP found.. not sure of what differences there are in the XSL used?
if (!$ipaddr) {
$ipaddr = $xml[$z]['nmaprun']['_c']['host'][$i]['_c']['address']['0']['_a']['addr'];
$macaddr = $xml[$z]['nmaprun']['_c']['host'][$i]['_c']['address']['1']['_a']['addr'];
}
// Lookup the IP address in the database
if ($ipaddr) {
list($status, $introws, $interface) = ona_find_interface($ipaddr);
if (!$introws) {
$interface['ip_addr_text'] = 'NOT FOUND';
list($status, $introws, $tmp) = ona_find_subnet($ipaddr);
$interface['subnet_id'] = $tmp['id'];
} else {
// Lookup the DNS name in the database
list($status, $dnsrows, $dnscount) = db_get_records($onadb, 'dns', "interface_id = {$interface['id']}", "", 0);
list($status, $dnsptrrows, $dnsptr) = ona_get_dns_record(array('interface_id' => $interface['id'], 'type' => 'PTR'));
list($status, $dnsprows, $dns) = ona_get_dns_record(array('id' => $dnsptr['dns_id']));
}
}
// Find out if this IP falls inside of a pool
$inpool = 0;
$ip = ip_mangle($ipaddr, 'numeric');
if ($ip > 0) {
list($status, $poolrows, $pool) = ona_get_dhcp_pool_record("ip_addr_start <= '{$ip}' AND ip_addr_end >= '{$ip}'");
}
if ($poolrows) {
$inpool = 1;
}
// some base logic
// if host is up in nmap but no db ip then put in $nodb
// if host is up and is in db then put in $noissue
// if host is down and not in db then skip
//.........这里部分代码省略.........
示例10: dhcp_server_del
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']));
//.........这里部分代码省略.........
示例11: ws_editor
function ws_editor($window_name, $form = '')
{
global $conf, $self, $onadb;
global $font_family, $color, $style, $images;
$window = array();
// Check permissions
if (!auth('advanced')) {
$response = new xajaxResponse();
$response->addScript("alert('Permission denied!');");
return $response->getXML();
}
// If an array in a string was provided, build the array and store it in $form
$form = parse_options_string($form);
// If $form is a number, it's an dhcp entry record id- so we transform $form into an array
if ($form['id']) {
list($status, $rows, $dhcp_entry) = ona_get_dhcp_option_entry_record(array('id' => $form['id']));
$window['title'] = "Edit DHCP Entry";
} else {
$window['title'] = "Add DHCP Entry";
}
// If they are adding a global option
$global_id = 'N';
if (is_numeric($form['global_id'])) {
// Setup a title description for this edit type
$window['edit_type'] = "Global";
$window['edit_type_value'] = 'This will be a Global DHCP option';
$global_id = 'Y';
}
// Load the subnet record and associated info.
if (is_numeric($form['subnet_id'])) {
list($status, $rows, $subnet) = ona_get_subnet_record(array('id' => $form['subnet_id']));
// Setup a title description for this edit type
$window['edit_type'] = "Subnet";
$window['edit_type_value'] = "{$subnet['name']}";
}
// If they are adding a new DHCP entry they will usually pass a host_id in
if (is_numeric($form['host_id'])) {
list($status, $rows, $host) = ona_find_host($form['host_id']);
// Setup a title description for this edit type
$window['edit_type'] = "Host";
$window['edit_type_value'] = $host['fqdn'];
}
// If they are adding a new server level DHCP entry they will usually pass a server_id in
if (is_numeric($form['server_id'])) {
list($status, $rows, $server) = ona_find_host($form['server_id']);
// Setup a title description for this edit type
$window['edit_type'] = "Server";
$window['edit_type_value'] = $server['fqdn'];
}
// Escape data for display in html
foreach (array_keys((array) $subnet) as $key) {
$subnet[$key] = htmlentities($subnet[$key], ENT_QUOTES, $conf['php_charset']);
}
foreach (array_keys((array) $zone) as $key) {
$zone[$key] = htmlentities($zone[$key], ENT_QUOTES, $conf['php_charset']);
}
foreach (array_keys((array) $host) as $key) {
$host[$key] = htmlentities($host[$key], ENT_QUOTES, $conf['php_charset']);
}
foreach (array_keys((array) $server) as $key) {
$server[$key] = htmlentities($server[$key], ENT_QUOTES, $conf['php_charset']);
}
// Build dhcp option list
list($status, $rows, $dhcpoptions) = db_get_records($onadb, 'dhcp_options', 'id >= 1', 'display_name');
$dhcp_option_list = '<option value=""> </option>\\n';
$dhcpoptions['dhcp_options'] = htmlentities($dhcpoptions['display_name']);
foreach ($dhcpoptions as $record) {
$selected = "";
if ($record['id'] == $dhcp_entry['dhcp_option_id']) {
$selected = "SELECTED=\"selected\"";
}
if ($record['id']) {
$dhcp_option_list .= "<option {$selected} value=\"{$record['id']}\">{$record['display_name']} ({$record['number']})</option>\n";
}
}
// Javascript to run after the window is built
$window['js'] = <<<EOL
/* Put a minimize icon in the title bar */
el('{$window_name}_title_r').innerHTML =
' <a onClick="toggle_window(\\'{$window_name}\\');" title="Minimize window" style="cursor: pointer;"><img src="{$images}/icon_minimize.gif" border="0" /></a>' +
el('{$window_name}_title_r').innerHTML;
/* Put a help icon in the title bar */
el('{$window_name}_title_r').innerHTML =
' <a href="{$_ENV['help_url']}{$window_name}" target="null" title="Help" style="cursor: pointer;"><img src="{$images}/silk/help.png" border="0" /></a>' +
el('{$window_name}_title_r').innerHTML;
el('{$window_name}_form').onsubmit = function() { return false; };
EOL;
// Define the window's inner html
$window['html'] = <<<EOL
<!-- DHCP entry Edit Form -->
<form id="{$window_name}_form" onSubmit="return false;">
<input type="hidden" name="host" value="{$host['id']}">
<input type="hidden" name="subnet" value="{$subnet['id']}">
<input type="hidden" name="server" value="{$server['id']}">
<input type="hidden" name="global" value="{$global_id}">
<input type="hidden" name="id" value="{$dhcp_entry['id']}">
<input type="hidden" name="js" value="{$form['js']}">
//.........这里部分代码省略.........
示例12: custom_attribute_display
function custom_attribute_display($options = "")
{
// The important globals
global $conf, $self, $onadb;
$text_array = array();
// Version - UPDATE on every edit!
$version = '1.02';
printmsg("DEBUG => custom_attribute_display({$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['host'] and !$options['id'] and !$options['subnet'] and !$options['vlan']) {
// NOTE: Help message lines should not exceed 80 characters for proper display on a console
$self['error'] = 'ERROR => Insufficient parameters';
return array(1, <<<EOM
custom_attribute_display-v{$version}
Display the custom attribute specified or attributes for a host
Synopsis: custom_attribute_display
Where:
id=ID custom attribute ID
OR
host=ID or NAME[.DOMAIN] display custom attributes for specified host
OR
subnet=ID or NAME display custom attributes for specified subnet
OR
vlan=NAME display custom attributes for specified VLAN
Optional:
type=ID or NAME If you specify a type and a host or subnet you
will only get back a 1 or a 0 indicating that
that type is set or not set for the host or subnet
EOM
);
}
// if a type was set, check if it is associated with the host or subnet and return 1 or 0
if ($options['type']) {
$field = is_numeric($options['type']) ? 'id' : 'name';
list($status, $rows, $catype) = ona_get_custom_attribute_type_record(array($field => $options['type']));
// error if we cant find the type specified
if (!$catype['id']) {
$self['error'] = "ERROR => The custom attribute type specified, {$options['type']}, does not exist!";
return array(5, $self['error']);
}
$where['custom_attribute_type_id'] = $catype['id'];
}
// Search for the host first
if ($options['host']) {
list($status, $rows, $host) = ona_find_host($options['host']);
// Error if the host doesn't exist
if (!$host['id']) {
$self['error'] = "ERROR => The host specified, {$options['host']}, does not exist!";
return array(2, $self['error']);
} else {
$where['table_id_ref'] = $host['id'];
$where['table_name_ref'] = 'hosts';
list($status, $rows, $cas) = db_get_records($onadb, 'custom_attributes', $where);
}
$anchor = 'host';
$desc = $host['fqdn'];
}
// Search for subnet
if ($options['subnet']) {
list($status, $rows, $subnet) = ona_find_subnet($options['subnet']);
// Error if the record doesn't exist
if (!$subnet['id']) {
$self['error'] = "ERROR => The subnet specified, {$options['subnet']}, does not exist!";
return array(3, $self['error']);
} else {
$where['table_id_ref'] = $subnet['id'];
$where['table_name_ref'] = 'subnets';
list($status, $rows, $cas) = db_get_records($onadb, 'custom_attributes', $where);
}
$anchor = 'subnet';
$desc = $subnet['description'];
}
// Search for vlan
if ($options['vlan']) {
list($status, $rows, $vlan) = ona_find_vlan($options['vlan']);
// Error if the record doesn't exist
if (!$vlan['id']) {
$self['error'] = "ERROR => The VLAN specified, {$options['vlan']}, does not exist!";
return array(3, $self['error']);
} else {
$where['table_id_ref'] = $vlan['id'];
$where['table_name_ref'] = 'vlans';
list($status, $rows, $cas) = db_get_records($onadb, 'custom_attributes', $where);
}
$anchor = 'vlan';
$desc = $vlan['description'];
}
// Now find the ID of the record, returns a specific record only
if ($options['id']) {
list($status, $rows, $ca) = ona_get_custom_attribute_record(array('id' => $options['id']));
if (!$ca['id']) {
$self['error'] = "ERROR => The custom attribute specified, {$options['id']}, is invalid!";
return array(4, $self['error']);
//.........这里部分代码省略.........
示例13: ws_editor
function ws_editor($window_name, $form = '')
{
global $conf, $self, $onadb;
global $font_family, $color, $style, $images;
$window = array();
// Check permissions
if (!(auth('subnet_modify') and auth('subnet_add'))) {
$response = new xajaxResponse();
$response->addScript("alert('Permission denied!');");
return $response->getXML();
}
// If the user supplied an array in a string, build the array and store it in $form
$form = parse_options_string($form);
// If $form is a number, it's an record ID- so we transform $form into an array
if (is_numeric($form)) {
$form = array('subnet_id' => $form);
}
$subnet = array();
// Load an existing record (and associated info) if $form is an id
if (is_numeric($form['subnet_id'])) {
list($status, $rows, $subnet) = ona_get_subnet_record(array('id' => $form['subnet_id']));
if ($rows) {
if (strlen($subnet['ip_addr']) > 11) {
$subnet['ip_mask'] = '/' . ip_mangle($subnet['ip_mask'], 'cidr');
} else {
$subnet['ip_mask'] = ip_mangle($subnet['ip_mask'], 'dotted');
}
$subnet['ip_addr'] = ip_mangle($subnet['ip_addr'], 'dotted');
// Vlan Record
list($status, $rows, $vlan) = ona_get_vlan_record(array('id' => $subnet['vlan_id']));
$subnet['vlan_desc'] = $vlan['vlan_campus_name'] . ' / ' . $vlan['name'];
}
} else {
if (strlen($form['ip_addr']) > 1) {
$subnet['ip_addr'] = ip_mangle($form['ip_addr'], 'dotted');
}
if (strlen($form['ip_mask']) > 1) {
$subnet['ip_mask'] = ip_mangle($form['ip_mask'], 'dotted');
}
if (strlen($form['name']) > 1) {
$subnet['name'] = $form['name'];
}
}
if (!$subnet['vlan_id']) {
$subnet['vlan_desc'] = 'None';
}
// Escape data for display in html
foreach (array_keys((array) $subnet) as $key) {
$subnet[$key] = htmlentities($subnet[$key], ENT_QUOTES, $conf['php_charset']);
}
// Set the window title:
$window['title'] = "Add Subnet";
if ($subnet['id']) {
$window['title'] = "Edit Subnet";
}
// Build subnet type list
list($status, $rows, $subnettypes) = db_get_records($onadb, 'subnet_types', 'id > 0', 'display_name');
$subnet_type_list = '<option value=""> </option>\\n';
$subnettypes['subnet_type_name'] = htmlentities($subnettypes['display_name']);
foreach ($subnettypes as $record) {
$selected = "";
if ($record['id'] == $subnet['subnet_type_id']) {
$selected = "SELECTED=\"selected\"";
}
if ($record['id']) {
$subnet_type_list .= "<option {$selected} value=\"{$record['id']}\">{$record['display_name']}</option>\n";
}
}
// Javascript to run after the window is built
$window['js'] = <<<EOL
/* Put a minimize icon in the title bar */
el('{$window_name}_title_r').innerHTML =
' <a onClick="toggle_window(\\'{$window_name}\\');" title="Minimize window" style="cursor: pointer;"><img src="{$images}/icon_minimize.gif" border="0" /></a>' +
el('{$window_name}_title_r').innerHTML;
/* Put a help icon in the title bar */
el('{$window_name}_title_r').innerHTML =
' <a href="{$_ENV['help_url']}{$window_name}" target="null" title="Help" style="cursor: pointer;"><img src="{$images}/silk/help.png" border="0" /></a>' +
el('{$window_name}_title_r').innerHTML;
el('{$window_name}_edit_form').onsubmit = function() { return false; };
/* Setup the Quick Find VLAN icon */
var _button = el('qf_vlan_{$window_name}');
_button.style.cursor = 'pointer';
_button.onclick =
function(ev) {
if (!ev) ev = event;
/* Create the popup div */
wwTT(this, ev,
'id', 'tt_qf_vlan_{$window_name}',
'type', 'static',
'direction', 'south',
'delay', 0,
'styleClass', 'wwTT_qf',
'javascript',
"xajax_window_submit('tooltips', '" +
"tooltip=>qf_vlan," +
"id=>tt_qf_vlan_{$window_name}," +
//.........这里部分代码省略.........
示例14: ws_display
//.........这里部分代码省略.........
'}';
timer = setTimeout(code, 700);"
>
</form>
</td>
</tr>
</table>
<div id='{$content_id}'>
{$conf['loading_icon']}
</div>
EOL;
if (auth('advanced', $debug_val)) {
$html .= <<<EOL
<div class="act-box" style="padding: 2px 4px; border-top: 1px solid {$color['border']}">
<form id="{$form['form_id']}_domain_server_{$record['id']}"
><input type="hidden" name="server" value="{$record['id']}"
><input type="hidden" name="js" value="{$refresh}"
></form>
<!-- ADD DOMAIN LINK -->
<a title="Assign domain"
class="act"
onClick="xajax_window_submit('edit_domain_server', xajax.getFormValues('{$form['form_id']}_domain_server_{$record['id']}'), 'editor');"
><img src="{$images}/silk/page_add.png" border="0"></a>
<a title="Assign domain"
class="act"
onClick="xajax_window_submit('edit_domain_server', xajax.getFormValues('{$form['form_id']}_domain_server_{$record['id']}'), 'editor');"
>Assign existing domain</a>
<!-- ADD DOMAIN LINK -->
<a title="New DNS domain"
class="act"
onClick="xajax_window_submit('edit_domain', xajax.getFormValues('{$form['form_id']}_domain_server_{$record['id']}'), 'editor');"
><img src="{$images}/silk/page_add.png" border="0"></a>
<a title="New DNS domain"
class="act"
onClick="xajax_window_submit('edit_domain', xajax.getFormValues('{$form['form_id']}_domain_server_{$record['id']}'), 'editor');"
>Add DNS domain</a>
</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();
}
示例15: ws_display_list
//.........这里部分代码省略.........
}
}
// tag
if ($form['tag_net']) {
$where .= $and . "id in (select reference from tags where type like 'subnet' and name like " . $onadb->qstr($form['tag_net']) . ")";
$and = " AND ";
}
// custom attribute type
if ($form['custom_attribute_type_net']) {
$where .= $and . "id in (select table_id_ref from custom_attributes where table_name_ref like 'subnets' and custom_attribute_type_id = (SELECT id FROM custom_attribute_types WHERE name = " . $onadb->qstr($form['custom_attribute_type_net']) . "))";
$and = " AND ";
$cavaluetype = "and custom_attribute_type_id = (SELECT id FROM custom_attribute_types WHERE name = " . $onadb->qstr($form['custom_attribute_type_net']) . ")";
}
// custom attribute value
if ($form['ca_value_net']) {
$where .= $and . "id in (select table_id_ref from custom_attributes where table_name_ref like 'subnets' {$cavaluetype} and value like " . $onadb->qstr($wildcard . $form['ca_value_net'] . $wildcard) . ")";
$and = " AND ";
}
// display a nice message when we dont find all the records
if ($where == '' and $form['content_id'] == 'search_results_list') {
$js .= "el('search_results_msg').innerHTML = 'Unable to find subnets matching your query, showing all records';";
}
// Wild card .. if $where is still empty, add a 'ID > 0' to it so you see everything.
if ($where == '') {
$where = 'id > 0';
}
// Do the SQL Query
$filter = '';
if ($form['filter']) {
// Subnet namess 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 search_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']}_subnet_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"> </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');