ona  18.1.1
About: OpenNetAdmin provides a database managed inventory of your IP network (with Web and CLI interface).
  Fossies Dox: ona-18.1.1.tar.gz  ("inofficial" and yet experimental doxygen-generated source code documentation)  

list_hosts.inc.php
Go to the documentation of this file.
1 <?php
2 
3 
4 
6 // Function: ws_display_list()
7 //
8 // Description:
9 // Displays A list of hosts based on search criteria.
10 // Input: An array from xajaxGetFormValues() from a quick filter form.
12 function ws_display_list($window_name, $form='') {
13  global $conf, $self, $onadb;
14  global $images, $color, $style;
15  $html = '';
16  $js = '';
17 
18  // If the user supplied an array in a string, transform it into an array
19  $form = parse_options_string($form);
20 
21  // Find the "tab" we're on
22  $tab = $_SESSION['ona'][$form['form_id']]['tab'];
23 
24  // Build js to refresh this list
25  $refresh = "xajax_window_submit('{$window_name}', xajax.getFormValues('{$form['form_id']}'), 'display_list');";
26 
27  // If it's not a new query, load the previous query from the session
28  // into $form and save the current page and filter in the session.
29  // Also find/set the "page" we're viewing
30  $page = 1;
31  if ($form['page'] and is_numeric($form['page'])) {
32  $form = array_merge($form, (array)$_SESSION['ona'][$form['form_id']][$tab]['q']);
33  $_SESSION['ona'][$form['form_id']][$tab]['page'] = $page = $form['page'];
34  $_SESSION['ona'][$form['form_id']][$tab]['filter'] = $form['filter'];
35  }
36  printmsg("DEBUG => Displaying hosts list page: {$page}", 1);
37 
38  // Calculate the SQL query offset (based on the page being displayed)
39  $offset = ($conf['search_results_per_page'] * ($page - 1));
40  if ($offset == 0) { $offset = -1; }
41 
42  // Search results go in here
43  $results = array();
44  $count = 0;
45 
46 
47 
48  //
49  // *** ADVANCED HOST SEARCH ***
50  // FIND RESULT SET
51  //
52 
53  // Start building the "where" clause for the sql query to find the hosts to display
54  $where = "";
55  $and = "";
56  $orderby = "";
57  $from = 'hosts h';
58 
59  // enable or disable wildcards
60  $wildcard = '%';
61  if ($form['nowildcard']) $wildcard = '';
62 
63 
64  // DISPLAY ALL
65  // MP: I dont think this is used.. remove it if you can
66  if ($form['all_flag']) {
67  $where .= $and . "h.id > 0";
68  $and = " AND ";
69  }
70 
71  // HOST ID
72  if ($form['host_id']) {
73  $where .= $and . "h.id = " . $onadb->qstr($form['host_id']);
74  $and = " AND ";
75  }
76 
77  // DEVICE ID
78  if ($form['device_id']) {
79  $where .= $and . "h.device_id = " . $onadb->qstr($form['device_id']);
80  $and = " AND ";
81  }
82 
83 
84  // HOSTNAME
85  if ($form['hostname']) {
86  // Find the domain name piece of the hostname assuming it was passed in as an fqdn.
87  // FIXME: MP this was taken from the ona_find_domain function. make that function have the option
88  // to NOT return a default domain.
89 
90  // lets test out if it has a / in it to strip the view name portion
91  $view['id'] = 0;
92  if (strstr($form['hostname'],'/')) {
93  list($dnsview,$form['hostname']) = explode('/', $form['hostname']);
94  list($status, $viewrows, $view) = db_get_record($onadb, 'dns_views', array('name' => strtoupper($dnsview)));
95  if(!$viewrows) $view['id'] = 0;
96  }
97 
98  // Split it up on '.' and put it in an array backwards
99  $parts = array_reverse(explode('.', $form['hostname']));
100 
101  // Find the domain name that best matches
102  $name = '';
103  $domain = array();
104  foreach ($parts as $part) {
105  if (!$rows) {
106  if (!$name) $name = $part;
107  else $name = "{$part}.{$name}";
108  list($status, $rows, $record) = ona_get_domain_record(array('name' => $name));
109  if ($rows)
110  $domain = $record;
111  }
112  else {
113  list($status, $rows, $record) = ona_get_domain_record(array('name' => $part, 'parent_id' => $domain['id']));
114  if ($rows)
115  $domain = $record;
116  }
117  }
118 
119  $withdomain = '';
120  $hostname = $form['hostname'];
121  // If you found a domain in the query, add it to the search, and strip the domain from the host portion.
122  if (array_key_exists('id', $domain) and !$form['domain']) {
123  $withdomain = "AND b.domain_id = {$domain['id']}";
124  // Now find what the host part of $search is
125  $hostname = str_replace(".{$domain['fqdn']}", '', $form['hostname']);
126  }
127  // If we have a hostname and a domain name then use them both
128  if ($form['domain']) {
129  list($status, $rows, $record) = ona_find_domain($form['domain']);
130  if ($record['id']) {
131  $withdomain = "AND b.domain_id = {$record['id']}";
132  }
133  // Now find what the host part of $search is
134  $hostname = trim($form['hostname']);
135  }
136 
137 
138  // MP: Doing the many select IN statements was too slow.. I did this kludge:
139  // 1. get a list of all the interfaces
140  // 2. loop through the array and build a list of comma delimited host_ids to use in the final select
141  list($status, $rows, $tmp) = db_get_records($onadb, 'interfaces a, dns b', "a.id = b.interface_id and b.name LIKE '{$wildcard}{$hostname}{$wildcard}' {$withdomain}");
142  $commait = '';
143  $hostids = '';
144  foreach ($tmp as $item) {
145  $hostids .= $commait.$item['host_id'];
146  $commait = ',';
147  }
148 
149  // Just look for the host itself
150  list($status, $rows, $r) = ona_find_host($form['hostname']);
151  if ($rows) $hostids .= ','.$r['id'];
152 
153  // MP: this is the old, slow query for reference.
154  //
155  // TODO: MP this seems to be kinda slow (gee I wonder why).. look into speeding things up somehow.
156  // This also does not search for CNAME records etc. only things with interface_id.. how to fix that issue.......?
157  // $where .= $and . "id IN (select host_id from interfaces where id in (SELECT interface_id " .
158  // " FROM dns " .
159  // " WHERE name LIKE '%{$hostname}%' {$withdomain} ))";
160 
161  // Trim off extra commas
162  $hostids = trim($hostids, ",");
163  // If we got a list of hostids from interfaces then use them
164  if ($hostids) {
165  $idqry = "h.id IN ($hostids)";
166  }
167  // Otherwise assume we found nothing specific and should return all rows.
168  else {
169  $idqry = "";
170  }
171 
172  $where .= $and . $idqry;
173  $and = " AND ";
174 
175  }
176 
177 
178  // DOMAIN
179  if ($form['domain'] and !$form['hostname']) {
180  // FIXME: does this clause work correctly?
181  printmsg("FIXME: => Does \$form['domain'] work correctly in list_hosts.inc.php?", 2);
182  // Find the domain name piece of the hostname.
183  // FIXME: MP this was taken from the ona_find_domain function. make that function have the option
184  // to NOT return a default domain.
185 
186  // Split it up on '.' and put it in an array backwards
187  $parts = array_reverse(explode('.', $form['domain']));
188 
189  // Find the domain name that best matches
190  $name = '';
191  $domain = array();
192  foreach ($parts as $part) {
193  if (!$rows) {
194  if (!$name) $name = $part;
195  else $name = "{$part}.{$name}";
196  list($status, $rows, $record) = ona_get_domain_record(array('name' => $name));
197  if ($rows)
198  $domain = $record;
199  }
200  else {
201  list($status, $rows, $record) = ona_get_domain_record(array('name' => $part, 'parent_id' => $domain['id']));
202  if ($rows)
203  $domain = $record;
204  }
205  }
206 
207  if (array_key_exists('id', $domain)) {
208 
209  // Crappy way of writing the query but it makes it fast.
210  $from = "(
211 SELECT distinct a.*
212 from hosts as a, interfaces as i, dns as d
213 where a.id = i.host_id
214 and i.id = d.interface_id
215 and d.domain_id = ". $onadb->qstr($domain['id']). "
216 ) h";
217 
218  $and = " AND ";
219  }
220  }
221 
222  // DOMAIN ID
223  if ($form['domain_id'] and !$form['hostname']) {
224  $where .= $and . "h.primary_dns_id IN ( SELECT id " .
225  " FROM dns " .
226  " WHERE domain_id = " . $onadb->qstr($form['domain_id']) . " ) ";
227  $and = " AND ";
228  }
229 
230 
231 
232 
233  // MAC
234  if ($form['mac']) {
235  // Clean up the mac address
236  $form['mac'] = strtoupper($form['mac']);
237  $form['mac'] = preg_replace('/[^%0-9A-F]/', '', $form['mac']);
238 
239  // We do a sub-select to find interface id's that match
240  $where .= $and . "h.id IN ( SELECT host_id " .
241  " FROM interfaces " .
242  " WHERE mac_addr LIKE " . $onadb->qstr($wildcard.$form['mac'].$wildcard) . " ) ";
243  $and = " AND ";
244 
245  }
246 
247 
248  // IP ADDRESS
249  $ip = $ip_end = '';
250  if ($form['ip']) {
251  // Build $ip and $ip_end from $form['ip'] and $form['ip_thru']
252  $ip = ip_complete($form['ip'], '0');
253  if ($form['ip_thru']) { $ip_end = ip_complete($form['ip_thru'], '255'); }
254  else { $ip_end = ip_complete($form['ip'], '255'); }
255 
256  // Find out if $ip and $ip_end are valid
257  $ip = ip_mangle($ip, 'numeric');
258  $ip_end = ip_mangle($ip_end, 'numeric');
259  if ($ip != -1 and $ip_end != -1) {
260  // We do a sub-select to find interface id's between the specified ranges
261  $where .= $and . "h.id IN ( SELECT host_id " .
262  " FROM interfaces " .
263  " WHERE ip_addr >= " . $onadb->qstr($ip) . " AND ip_addr <= " . $onadb->qstr($ip_end) . " )";
264  $and = " AND ";
265  }
266  }
267 
268 
269  // NOTES
270  if ($form['notes']) {
271  $where .= $and . "h.notes LIKE " . $onadb->qstr($wildcard.$form['notes'].$wildcard);
272  $and = " AND ";
273  }
274 
275 
276 
277 
278  // DEVICE MODEL
279  if ($form['model_id']) {
280  $where .= $and . "h.device_id in (select id from devices where device_type_id in (select id from device_types where model_id = {$form['model_id']}))";
281  $and = " AND ";
282  }
283 
284  if ($form['model']) {
285  $where .= $and . "h.device_id in (select id from devices where device_type_id in (select id from device_types where model_id in (select id from models where name like '{$form['model']}')))";
286  $and = " AND ";
287  }
288 
289 
290 
291  // DEVICE TYPE
292  if ($form['role']) {
293  // Find model_id's that have a device_type_id of $form['role']
294  list($status, $rows, $records) =
296  'roles',
297  array('name' => $form['role'])
298  );
299  // If there were results, add each one to the $where clause
300  if ($rows > 0) {
301  $where .= $and . " ( ";
302  $and = " AND ";
303  $or = "";
304  foreach ($records as $record) {
305  // Yes this is one freakin nasty query but it works.
306  $where .= $or . "h.device_id in (select id from devices where device_type_id in (select id from device_types where role_id = " . $onadb->qstr($record['id']) ."))";
307  $or = " OR ";
308  }
309  $where .= " ) ";
310  }
311  }
312 
313 
314  // DEVICE MANUFACTURER
315  if ($form['manufacturer']) {
316  // Find model_id's that have a device_type_id of $form['manufacturer']
317  if (is_numeric($form['manufacturer'])) {
318  list($status, $rows, $records) = db_get_records($onadb, 'models', array('manufacturer_id' => $form['manufacturer']));
319  } else {
320  list($status, $rows, $manu) = db_get_record($onadb, 'manufacturers', array('name' => $form['manufacturer']));
321  list($status, $rows, $records) = db_get_records($onadb, 'models', array('manufacturer_id' => $manu['id']));
322  }
323 
324  // If there were results, add each one to the $where clause
325  if ($rows > 0) {
326  $where .= $and . " ( ";
327  $and = " AND ";
328  $or = "";
329  foreach ($records as $record) {
330  // Yes this is one freakin nasty query but it works.
331  $where .= $or . "h.device_id in (select id from devices where device_type_id in (select id from device_types where model_id = " . $onadb->qstr($record['id']) ."))";
332  $or = " OR ";
333  }
334  $where .= " ) ";
335  }
336  }
337 
338  // tag
339  if ($form['tag_host']) {
340  $where .= $and . "h.id in (select reference from tags where type like 'host' and name like " . $onadb->qstr($form['tag_host']) . ")";
341  $and = " AND ";
342 
343  }
344 
345  // custom attribute type
346  if ($form['custom_attribute_type']) {
347  $where .= $and . "h.id in (select table_id_ref from custom_attributes where table_name_ref like 'hosts' and custom_attribute_type_id = (SELECT id FROM custom_attribute_types WHERE name = " . $onadb->qstr($form['custom_attribute_type']) . "))";
348  $and = " AND ";
349  $cavaluetype = "and custom_attribute_type_id = (SELECT id FROM custom_attribute_types WHERE name = " . $onadb->qstr($form['custom_attribute_type']) . ")";
350 
351  }
352 
353  // custom attribute value
354  if ($form['ca_value']) {
355  $where .= $and . "h.id in (select table_id_ref from custom_attributes where table_name_ref like 'hosts' {$cavaluetype} and value like " . $onadb->qstr($wildcard.$form['ca_value'].$wildcard) . ")";
356  $and = " AND ";
357  }
358 
359  // LOCATION No.
360  if ($form['location']) {
361  list($status, $rows, $loc) = ona_find_location($form['location']);
362  $where .= $and . "h.device_id in (select id from devices where location_id = " . $onadb->qstr($loc['id']) . ")";
363  $and = " AND ";
364  }
365 
366  // subnet ID
367  if (is_numeric($form['subnet_id'])) {
368  // We do a sub-select to find interface id's that match
369  $from = "(
370 SELECT distinct a.*,b.ip_addr
371 from hosts as a, interfaces as b
372 where a.id = b.host_id
373 and b.subnet_id = ". $onadb->qstr($form['subnet_id']). "
374 order by b.ip_addr) h";
375 
376  $and = " AND ";
377  }
378 
379  // display a nice message when we dont find all the records
380  if ($where == '' and $form['content_id'] == 'search_results_list') {
381  $js .= "el('search_results_msg').innerHTML = 'Unable to find hosts matching your query, showing all records';";
382  }
383 
384  // Wild card .. if $while is still empty, add a 'ID > 0' to it so you see everything.
385  if ($where == '') {
386  $where = 'h.id > 0';
387  }
388 
389 
390  // Do the SQL Query
391  $filter = '';
392  if ($form['filter']) {
393 
394  // Host names should always be lower case
395  $form['filter'] = strtolower($form['filter']);
396  // FIXME (MP) for now this uses primary_dns_id, this will NOT find multiple A records or other record types. Find a better way some day
397  $filter = " AND h.primary_dns_id IN (SELECT id " .
398  " FROM dns " .
399  " WHERE name LIKE ". $onadb->qstr('%'.$form['filter'].'%') . " ) ";
400 
401  }
402  list ($status, $rows, $results) =
404  $onadb,
405  $from,
406  $where . $filter,
407  $orderby,
408  $conf['search_results_per_page'],
409  $offset
410  );
411 
412  // If we got less than serach_results_per_page, add the current offset to it
413  // so that if we're on the last page $rows still has the right number in it.
414  if ($rows > 0 and $rows < $conf['search_results_per_page']) {
415  $rows += ($conf['search_results_per_page'] * ($page - 1));
416  }
417 
418  // If there were more than $conf['search_results_per_page'] find out how many records there really are
419  else if ($rows >= $conf['search_results_per_page']) {
420  list ($status, $rows, $records) =
422  $onadb,
423  $from,
424  $where . $filter,
425  "",
426  0
427  );
428  }
429  $count = $rows;
430 
431 
432  //
433  // *** BUILD HTML LIST ***
434  //
435  $html .= <<<EOL
436  <!-- Host Results -->
437  <table id="{$form['form_id']}_host_list" class="list-box" cellspacing="0" border="0" cellpadding="0">
438 
439  <!-- Table Header -->
440  <tr>
441  <td class="list-header" align="center" style="{$style['borderR']};">Name</td>
442  <td class="list-header" align="center" style="{$style['borderR']};">Subnet</td>
443  <td class="list-header" align="center" style="{$style['borderR']};">Interface</td>
444  <td class="list-header" align="center" style="{$style['borderR']};">Device Type</td>
445  <td class="list-header" align="center" style="{$style['borderR']};">Location</td>
446  <td class="list-header" align="center" style="{$style['borderR']};">Notes</td>
447  <td class="list-header" align="center">&nbsp;</td>
448  </tr>
449 EOL;
450  // Loop and display each record
451  foreach($results as $record) {
452  // Get additional info about eash host record
453 
454 
455  // If a subnet_id was passed use it as part of the search. Used to display the IP of the subnet you searched
456  if (is_numeric($form['subnet_id'])) {
457  list($status, $interfaces, $interface) = ona_get_interface_record(array('host_id' => $record['id'], 'subnet_id' => $form['subnet_id']), '');
458 
459  // Count how many rows and assign it back to the interfaces variable
460  list($status, $rows, $records) = db_get_records($onadb,
461  'interfaces',
462  'host_id = '. $onadb->qstr($record['id']),
463  "ip_addr",
464  0);
465 
466  $interfaces = $rows;
467 
468  } else if (is_numeric($ip)) {
469  list($status, $interfaces, $interface) = db_get_record($onadb,
470  'interfaces',
471  'host_id = '. $onadb->qstr($record['id']) .
472  ' AND ip_addr >= ' . $onadb->qstr($ip) .
473  ' AND ip_addr <= ' . $onadb->qstr($ip_end),
474  "ip_addr",
475  0);
476 
477  // Count how many rows and assign it back to the interfaces variable
478  list($status, $rows, $records) = db_get_records($onadb,
479  'interfaces',
480  'host_id = '. $onadb->qstr($record['id']),
481  "ip_addr",
482  0);
483 
484  $interfaces = $rows;
485 
486  } else {
487  // Interface (and find out how many there are)
488  list($status, $interfaces, $interface) = ona_get_interface_record(array('host_id' => $record['id']), '');
489  }
490 
491  // bz: why did someone add this?? You especially want to show hosts with no interfaces so you can fix them!
492  // if (!$interfaces) {$count -1; continue;}
493 
494  // get interface cluster info
495  $clusterhtml = '';
496  list ($status, $intclusterrows, $intcluster) = db_get_records($onadb, 'interface_clusters', "interface_id = {$interface['id']}");
497  if ($intclusterrows>0) {
498  $clusterscript= "onMouseOver=\"wwTT(this, event,
499  'id', 'tt_interface_cluster_list_{$record['id']}',
500  'type', 'velcro',
501  'styleClass', 'wwTT_niceTitle',
502  'direction', 'south',
503  'javascript', 'xajax_window_submit(\'tooltips\', \'tooltip=>interface_cluster_list,id=>tt_interface_cluster_list_{$record['id']},interface_id=>{$interface['id']}\');'
504  );\"";
505  $clusterhtml .= <<<EOL
506  <img src="{$images}/silk/sitemap.png" {$clusterscript} />
507 EOL;
508  }
509 
510 
511  $record['ip_addr'] = ip_mangle($interface['ip_addr'], 'dotted');
512  $interface_style = '';
513  if ($interfaces > 1) $interface_style = 'font-weight: bold;';
514 
515  // DNS A record
516  list($status, $rows, $dns) = ona_get_dns_record(array('id' => $record['primary_dns_id']));
517  $record['name'] = $dns['name'];
518 
519  // Domain Name
520  list($status, $rows, $domain) = ona_get_domain_record(array('id' => $dns['domain_id']));
521  $record['domain'] = $domain['fqdn'];
522 
523  // Subnet description
524  list($status, $rows, $subnet) = ona_get_subnet_record(array('id' => $interface['subnet_id']));
525  $record['subnet'] = $subnet['name'];
526  $record['ip_mask'] = ip_mangle($subnet['ip_mask'], 'dotted');
527  $record['ip_mask_cidr'] = ip_mangle($subnet['ip_mask'], 'cidr');
528 
529 
530  // Device Description
531  list($status, $rows, $device) = ona_get_device_record(array('id' => $record['device_id']));
532  list($status, $rows, $device_type) = ona_get_device_type_record(array('id' => $device['device_type_id']));
533  list($status, $rows, $model) = ona_get_model_record(array('id' => $device_type['model_id']));
534  list($status, $rows, $role) = ona_get_role_record(array('id' => $device_type['role_id']));
535  list($status, $rows, $manufacturer) = ona_get_manufacturer_record(array('id' => $model['manufacturer_id']));
536  $record['devicefull'] = "{$manufacturer['name']}, {$model['name']} ({$role['name']})";
537  $record['device'] = str_replace('Unknown', '?', $record['devicefull']);
538 
539 
540  $record['notes_short'] = truncate($record['notes'], 40);
541 
542  // Get location_number from the location_id
543  list($status, $rows, $location) = ona_get_location_record(array('id' => $device['location_id']));
544 
545  // Escape data for display in html
546  foreach(array_keys($record) as $key) { $record[$key] = htmlentities($record[$key], ENT_QUOTES, $conf['php_charset']); }
547 
548  $primary_object_js = "xajax_window_submit('work_space', 'xajax_window_submit(\'display_host\', \'host_id=>{$record['id']}\', \'display\')');";
549  $html .= <<<EOL
550  <tr onMouseOver="this.className='row-highlight';" onMouseOut="this.className='row-normal';">
551 
552  <td class="list-row">
553  <a title="View host. ID: {$record['id']}"
554  class="nav"
555  onClick="{$primary_object_js}"
556  >{$record['name']}</a
557  >.<a title="View domain. ID: {$domain['id']}"
558  class="domain"
559  onClick="xajax_window_submit('work_space', 'xajax_window_submit(\'display_domain\', \'domain_id=>{$domain['id']}\', \'display\')');"
560  >{$record['domain']}</a>
561  </td>
562 
563  <td class="list-row">
564  <a title="View subnet. ID: {$subnet['id']}"
565  class="nav"
566  onClick="xajax_window_submit('work_space', 'xajax_window_submit(\'display_subnet\', \'subnet_id=>{$subnet['id']}\', \'display\')');"
567  >{$record['subnet']}</a>&nbsp;
568  </td>
569 
570  <td class="list-row" align="left">
571  <span style="{$interface_style}"
572 EOL;
573 
574 if ($interfaces > 1) {
575  $html .= <<<EOL
576  onMouseOver="wwTT(this, event,
577  'id', 'tt_host_interface_list_{$record['id']}',
578  'type', 'velcro',
579  'styleClass', 'wwTT_niceTitle',
580  'direction', 'south',
581  'javascript', 'xajax_window_submit(\'tooltips\', \'tooltip=>host_interface_list,id=>tt_host_interface_list_{$record['id']},host_id=>{$record['id']}\');'
582  );"
583 EOL;
584 }
585  $html .= <<<EOL
586  >{$record['ip_addr']}</span>&nbsp;
587  <span title="{$record['ip_mask']}">/{$record['ip_mask_cidr']}</span>
588  <span>{$clusterhtml}</span>
589  </td>
590 
591  <td class="list-row" title="{$record['devicefull']}">{$record['device']}&nbsp;</td>
592 
593  <td class="list-row" align="right">
594  <span onMouseOver="wwTT(this, event,
595  'id', 'tt_location_{$device['location_id']}',
596  'type', 'velcro',
597  'styleClass', 'wwTT_niceTitle',
598  'direction', 'south',
599  'javascript', 'xajax_window_submit(\'tooltips\', \'tooltip=>location,id=>tt_location_{$device['location_id']},location_id=>{$device['location_id']}\');'
600  );"
601  >{$location['reference']}</span>&nbsp;
602  </td>
603 
604  <td class="list-row">
605  <span title="{$record['notes']}">{$record['notes_short']}</span>&nbsp;
606  </td>
607 
608  <!-- ACTION ICONS -->
609  <td class="list-row" align="right">
610  <form id="{$form['form_id']}_list_host_{$record['id']}"
611  ><input type="hidden" name="host_id" value="{$record['id']}"
612  ><input type="hidden" name="js" value="{$refresh}"
613  ></form>&nbsp;
614 EOL;
615 
616  if (auth('host_modify')) {
617  $html .= <<<EOL
618 
619  <a title="Edit host"
620  class="act"
621  onClick="xajax_window_submit('edit_host', xajax.getFormValues('{$form['form_id']}_list_host_{$record['id']}'), 'editor');"
622  ><img src="{$images}/silk/page_edit.png" border="0"></a>&nbsp;
623 EOL;
624  }
625 
626  if (auth('host_del')) {
627  $html .= <<<EOL
628 
629  <a title="Delete host"
630  class="act"
631  onClick="xajax_window_submit('edit_host', xajax.getFormValues('{$form['form_id']}_list_host_{$record['id']}'), 'delete');"
632  ><img src="{$images}/silk/delete.png" border="0"></a>
633 EOL;
634  }
635  $html .= <<<EOL
636  &nbsp;
637  </td>
638 
639  </tr>
640 EOL;
641 
642  }
643 
644 
645 
646  if ($count == 0 and $form['subnet_id'] and !$form['filter']) {
647  $html .= <<<EOL
648  <tr><td colspan="99" align="center" style="color: red;">Please add the gateway host (router) to this subnet</td></tr>
649 EOL;
650  }
651 
652  $html .= <<<EOL
653  </table>
654 EOL;
655 
656  // Build page links if there are any
657  $html .= get_page_links($page, $conf['search_results_per_page'], $count, $window_name, $form['form_id']);
658 
659 
660  // If there was only 1 result, and we're about to display results in the "Search Results" window, display it.
661  if ($count == 1 and $form['content_id'] == 'search_results_list' and $form['filter'] == '')
662  $js .= $primary_object_js;
663 
664  // Insert the new html into the content div specified
665  // Instantiate the xajaxResponse object
666  $response = new xajaxResponse();
667  $response->addAssign("{$form['form_id']}_{$tab}_count", "innerHTML", "({$count})");
668  $response->addAssign($form['content_id'], "innerHTML", $html);
669  if ($js) { $response->addScript($js); }
670  return($response->getXML());
671 }
672 
673 
674 
675 
676 
677 
678 
679 ?>
ona_get_manufacturer_record
ona_get_manufacturer_record($array)
Definition: functions_db.inc.php:1210
ona_get_location_record
ona_get_location_record($array='', $order='')
Definition: functions_db.inc.php:1122
ws_display_list
ws_display_list($window_name, $form='')
Definition: list_hosts.inc.php:12
ona_find_domain
ona_find_domain($fqdn="", $returndefault=0)
Definition: functions_db.inc.php:1609
ona_get_device_record
ona_get_device_record($array)
Definition: functions_db.inc.php:1218
Name
Full Name
Definition: app_user_info.inc.php:101
ip_mangle
ip_mangle($ip="", $format="default")
Definition: functions_general.inc.php:308
ona_get_interface_record
ona_get_interface_record($array='', $order='')
Definition: functions_db.inc.php:1126
ona_find_host
ona_find_host($search="")
Definition: functions_db.inc.php:1490
$record
$record['display_name']
Definition: app_advanced_search.inc.php:12
db_get_records
db_get_records($dbh=0, $table="", $where="", $order="", $rows=-1, $offset=-1)
Definition: functions_db.inc.php:891
$status
$status
Definition: install.php:12
$onadb
global $onadb
Definition: 2-to-3.php:15
ona_get_role_record
ona_get_role_record($array)
Definition: functions_db.inc.php:1222
$tab
$tab
Definition: app_config_type_list.inc.php:29
ona_get_device_type_record
ona_get_device_type_record($array)
Definition: functions_db.inc.php:1214
ona_get_model_record
ona_get_model_record($array)
Definition: functions_db.inc.php:1197
printmsg
if(6<=$conf['debug']) printmsg($msg="", $debugLevel=0)
Definition: functions_general.inc.php:48
truncate
truncate($msg="", $length=0)
Definition: functions_general.inc.php:209
ona_find_location
ona_find_location($search="")
Definition: functions_db.inc.php:1810
ip_complete
ip_complete($ip='', $filler=0)
Definition: functions_general.inc.php:1044
$images
$images
Definition: config.inc.php:26
EOL
< a style="text-decoration: none;" href="/">< input class='edit' type="button" value="I don't like free stuff?" onclick=""/></a ></center ></div > EOL
Definition: install.php:40
$_SESSION
$_SESSION['ona']['auth']
Definition: login.php:14
$conf
global $conf
Definition: 2-to-3.php:15
xajaxResponse
Definition: xajaxResponse.inc.php:68
$style
$style['font-family']
Definition: config.inc.php:158
$ip
$ip
Definition: main.inc.php:24
nbsp
& nbsp
Definition: install.php:36
ona_get_domain_record
ona_get_domain_record($array='', $order='')
Definition: functions_db.inc.php:1134
get_page_links
get_page_links($page=1, $per_page=1, $total=1, $window_name='', $form_id='')
Definition: xajax_setup.inc.php:115
$self
global $self
Definition: 2-to-3.php:15
db_get_record
db_get_record($dbh=0, $table="", $where="", $order="")
Definition: functions_db.inc.php:708
auth
auth($resource, $msg_level=1)
Definition: functions_general.inc.php:1330
ona_get_subnet_record
ona_get_subnet_record($array)
Definition: functions_db.inc.php:1226
$color
if($_SERVER['SERVER_PORT']==443) $color['bg']
Definition: config.inc.php:119
parse_options_string
parse_options_string($input)
Definition: xajax_setup.inc.php:88
ona_get_dns_record
ona_get_dns_record($array='', $order='')
Definition: functions_db.inc.php:1142