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)  

functions_gui.inc.php
Go to the documentation of this file.
1 <?php
2 
3 //
4 // GUI Specific Functions
5 // Not included for DCM modules
6 //
7 
8 // FIXME: This should be done where all the other user's prefs are loaded
9 // The other half of this is in search_results.inc.php
10 // if (is_numeric($_SESSION['search_results_per_page'])) $conf['search_results_per_page'] = $_SESSION['search_results_per_page'];
11 
13 // Returns HTML containing menu items based on the inbound array $menuarray
14 //
16 function build_workspace_menu($menuarray=array()){
17  global $base, $baseURL;
18 
19  foreach ($menuarray as $plmenu) {
20  if ($plmenu) {
21  foreach ($plmenu as $menuitem) {
22  // Use a default image if we cant find the one specified.
23  if (!file_exists($base.$menuitem['image']) or !$menuitem['image']){
24  $menuitem['image'] = '/images/silk/plugin.png';
25  }
26 
27  if (!$menuitem['tooltip']){
28  $menuitem['tooltip'] = $menuitem['menutitle'];
29  }
30 
31  // Check the authorization and print the menuitem if the are authorized
32  if (auth($menuitem['authname'],3) || !$menuitem['authname']) {
33  $wsmenuhtml .= <<<EOL
34 
35 <div class="row"
36  onMouseOver="this.className='hovered';"
37  onMouseOut="this.className='row';"
38  onClick="ona_menu_closedown(); {$menuitem['commandjs']};"
39  title="{$menuitem['tooltip']}"
40  ><img style="vertical-align: middle;" src="{$baseURL}{$menuitem['image']}" border="0"
41  />&nbsp;{$menuitem['menutitle']}</div>
42 
43 EOL;
44  }
45  }
46  }
47  }
48 
49  return $wsmenuhtml;
50 }
51 
53 // Returns a list of available local plugins of given type
54 //
55 // Patterned from dokuwiki by Andreas Gohr <andi@splitbrain.org>
56 //
57 // Not currently utilizing the "type" stuff as I could be
58 //
59 // returns an array of plugin names that have a specific type available.
60 //
62 function plugin_list($type=''){
63  global $base;
64  $plugins = array();
65  $i=0;
66  // check local plugins, then builtin plugins
67  $plugin_paths = array($base."/local/plugins/",$base."/plugins/");
68  foreach ($plugin_paths as $plugin_path) {
69  if ($dh = @opendir($plugin_path)) {
70  while (false !== ($plugin = readdir($dh))) {
71  if ($plugin == '.' || $plugin == '..' || $plugin == 'tmp' || $plugin == '.svn'|| substr($plugin, -7) == '.tar.gz') continue;
72  if (is_file($plugin_path.$plugin)) continue;
73 
74  if ($type=='' || @file_exists($plugin_path."$plugin/$type.inc.php") and @!file_exists($plugin_path."$plugin/plugin_disabled")){
75  $plugins[$i]['name'] = $plugin;
76  //if we did not specify a type.. just get the path for the plugin
77  if($type=='')
78  $plugins[$i]['path'] = $plugin_path."$plugin";
79  else
80  $plugins[$i]['path'] = $plugin_path."$plugin/$type.inc.php";
81  $i++;
82  }
83  }
84  closedir($dh);
85  }
86  }
87  return $plugins;
88 }
89 
91 // Loads the given local plugin and creates an object of it
92 //
93 // Patterned from dokuwiki by Andreas Gohr <andi@splitbrain.org>
94 //
95 // @param $type string type of plugin to load
96 // @param $name string name of the plugin to load
97 // @return objectreference the plugin object or null on failure
98 //
99 // Currently not doing any classes.
100 //
102 function &plugin_load($type,$name){
103  //we keep all loaded plugins available in global scope for reuse
104  global $ONA_PLUGINS, $base;
105 
106 
107  //plugin already loaded?
108  if($ONA_PLUGINS[$type][$name] != null){
109  return $ONA_PLUGINS[$type][$name];
110  }
111  // check local plugins, then builtin plugins
112  $plugin_paths = array($base."/local/plugins/",$base."/plugins/");
113  foreach ($plugin_paths as $plugin_path) {
114  //try to load the wanted plugin file if it is not disabled
115  if (!file_exists($plugin_path."$name/plugin_disabled")){
116  if (file_exists($plugin_path."$name/$type.inc.php")){
117  include_once($plugin_path."$name/$type.inc.php");
118  break;
119  }
120  }
121  }
122 
123  //construct class and instanciate
124  $class = $type.'_plugin_'.$name;
125  if (!class_exists($class)) return null;
126 
127  $ONA_PLUGINS[$type][$name] = new $class;
128  return $ONA_PLUGINS[$type][$name];
129 }
130 
131 
132 
133 /*
134 // Used in display_ pages to load a workspace plugin module and wrap it
135 // in a common looking div.
136 //
137 // Returns the html to render the ws plugin
138 //
139 */
140 function workspace_plugin_loader($modulename, $record=array(), $extravars=array()) {
141  global $conf, $self, $base, $images, $color, $style, $onadb;
142  $modhtml = '';
143  $modjs = '';
144  $modwsmenu = '';
145  $modbodyhtml = '';
146  $ws_plugin_dir = "{$base}/workspace_plugins";
147 
148  $max_img = "{$images}/silk/bullet_arrow_down.png";
149  $min_img = "{$images}/silk/bullet_arrow_up.png";
150 
151  //Default the module title
152  $title_left_html = $modulename;
153  $title_right_html = '';
154 
155  // Load the modules contents from the modules directory.
156  // Check for an installed module first. if not then use a builtin one
157  // First check the module name as a direct path to the workspace plugin.
158  if (is_file($modulename)) { require($modulename); }
159  else if (is_dir("{$ws_plugin_dir}/{$modulename}")) {
160  $mod_conf="{$ws_plugin_dir}/{$modulename}/config.inc.php";
161  if (file_exists($mod_conf)) { require($mod_conf); }
162  $mod_main="{$ws_plugin_dir}/{$modulename}/main.inc.php";
163  if (file_exists($mod_main)) { require($mod_main); }
164  }
165  else if (is_dir("{$ws_plugin_dir}/builtin/{$modulename}")) {
166  $mod_conf="{$ws_plugin_dir}/builtin/{$modulename}/config.inc.php";
167  if (file_exists($mod_conf)) { require($mod_conf); }
168  $mod_main="{$ws_plugin_dir}/builtin/{$modulename}/main.inc.php";
169  if (file_exists($mod_main)) { require($mod_main); }
170  }
171  else {
172  $mod_main="{$base}/include/unknown_module_msg.inc.php";
173  if (file_exists($mod_main)) { require($mod_main); }
174  }
175 
176 
177 /* one way to do the div containter..
178  <span id="mod_title_{$modulename}" style="float: left;">{$titlehtml}</span>
179  <span id="mod_buttons_{$modulename}" style="float: right;">
180  {$confightml}
181  <img src="{$min_img}"
182  id="{$modulename}_dropdown"
183  title="Min/Max"
184  onclick="if (el('{$modulename}_content').style.display=='none') { el('{$modulename}_content').style.display=''; el('{$modulename}_dropdown').src='{$min_img}'; }
185  else { el('{$modulename}_content').style.display='none'; el('{$modulename}_dropdown').src='{$max_img}';}"
186 
187  /></span>&nbsp;
188 */
189 
190 
191 
192 
193 
194 
195  // Create a standard div container for the module
196  $modhtml .= <<<EOL
197  <!-- {$modulename} start -->
198  <div id="{$modulename}_container" class="ws_plugin_content">
199  <table cellspacing="0" border="0" cellpadding="0" style="margin-bottom: 8px;">
200  <tr>
201  <td class="ws_plugin_title_right" title="{$title_description}">{$title_left_html}</td>
202  <td class="ws_plugin_title_left">
204  <img src="{$min_img}"
205  id="{$modulename}_dropdown"
206  title="Min/Max"
207  onclick="if (el('{$modulename}_content').style.display=='none') { el('{$modulename}_content').style.display=''; el('{$modulename}_dropdown').src='{$min_img}'; }
208  else { el('{$modulename}_content').style.display='none'; el('{$modulename}_dropdown').src='{$max_img}';}"
209 
210  /></td>
211  </tr>
212  <tr><td colspan="99" id="{$modulename}_content">
213 EOL;
214 
215  // FIXME: MP put some sort of loading icon here.
216 
217  // Dislay the modules contents from the modules directory.
218  $modhtml .= $modbodyhtml;
219 
220  // Close out the modules div container
221  $modhtml .= <<<EOL
222  </td></tr>
223  </table>
224  </div>
225  <!-- {$modulename} end -->
226 EOL;
227 
228  // If the module returns no body, then lets blank out what we have
229  // and assume that the module determined it should not display itself
230  // But if it gives us some menu items, display those still
231  if (!$modbodyhtml) {
232  $modhtml = '';
233  $modjs = '';
234  }
235 
236  return(array($modhtml,$modjs,$modwsmenu));
237 }
238 
239 
240 
241 
242 
243 
244 
245 
246 
247 
248 
249 
250 
251 
252 
253 
254 
256 // Calculates the percentage of a subnet that is in "use".
257 // Returns a three part list:
258 // list($percentage_used, $number_used, $number_total)
260 function get_subnet_usage($subnet_id) {
261  global $conf, $self, $onadb;
262 
263  list($status, $rows, $subnet) = db_get_record($onadb, 'subnets', array('id' => $subnet_id));
264  if ($status or !$rows) { return(0); }
265  if (strlen($subnet['ip_addr']) > 11) {
266  $sub = gmp_sub("340282366920938463463374607431768211455", $subnet['ip_mask']);
267  $subnet['size'] = gmp_strval(gmp_sub($sub,1));
268  } else {
269  $subnet['size'] = (0xffffffff - ip_mangle($subnet['ip_mask'], 'numeric')) - 1;
270  if ($subnet['ip_mask'] == 4294967295) $subnet['size'] = 1;
271  if ($subnet['ip_mask'] == 4294967294) $subnet['size'] = 2;
272  }
273 
274  // Calculate the percentage used (total size - allocated hosts - dhcp pool size)
275  list($status, $hosts, $tmp) = db_get_records($onadb, 'interfaces', array('subnet_id' => $subnet['id']), "", 0);
276  list($status, $rows, $pools) = db_get_records($onadb, 'dhcp_pools', array('subnet_id' => $subnet['id']));
277  $pool_size = 0;
278  foreach ($pools as $pool) {
279  $pool_size += ($pool['ip_addr_end'] - $pool['ip_addr_start'] + 1);
280  }
281  $total_used = $hosts + $pool_size;
282  $percentage = 100;
283  if ($subnet['size']) $percentage = sprintf('%d', ($total_used / $subnet['size']) * 100);
284  return(array($percentage, $total_used, $subnet['size']));
285 }
286 
287 
288 
289 
290 
292 // Returns the html for a "percentage of subnet used" bar graph
294 function get_subnet_usage_html($subnet_id, $width=30, $height=8) {
295  global $conf, $self, $mysql, $onadb;
296  list($usage, $used, $total) = get_subnet_usage($subnet_id);
297  $css='';
298  if (strpos($_SERVER['HTTP_USER_AGENT'],'MSIE') != false)
299  $css = "font-size: " . ($height - 2) . "px;";
300  return(<<<EOL
301  <div style="white-space: nowrap; width: 100%; text-align: left; padding-top: 2px; padding-bottom: 2px; vertical-align: middle; font-size: 8px;">
302  <div title="{$usage}% used" style="{$css} float: left; width: {$width}px; height: {$height}px; text-align: left; vertical-align: middle; background-color: #ABFFBC; border: 1px solid #000;">
303  <div style="{$css} width: {$usage}%; height: {$height}px; vertical-align: middle; background-color: #FF3939;"></div>
304  </div>
305  <span style="font-size: 8px;">&nbsp;{$used} / {$total}</span>
306  </div>
307 EOL
308 );
309 }
310 
311 
312 
313 
314 
315 
316 function get_host_suggestions($q, $max_results=10) {
317  global $self, $conf, $onadb;
318  $results = array();
319 
320  // If we are not using views, limit to the default
321  if (!$conf['dns_views']) $limit_to_view = 'dns_view_id = 0 AND ';
322 
323  // wildcard the query before searching
324  $q = $q . '%';
325 
326  $table = 'dns';
327  $field = 'name';
328  $where = "{$limit_to_view} {$field} LIKE " . $onadb->qstr($q);
329  $order = "{$field} ASC";
330 
331  // Search the db for results
332  list ($status, $rows, $records) = db_get_records(
333  $onadb,
334  $table,
335  $where,
336  $order,
337  $max_results
338  );
339 
340  // If the query didn't work return the error message
341  if ($status) { $results[] = "Internal Error: {$self['error']}"; }
342 
343  foreach ($records as $record) {
344  // NS records dont need to show their domain.
345  if ($record['type'] == 'NS') {
346  $results[] = $record[$field];
347  } else {
348  list($status, $rows, $domain) = db_get_record($onadb, 'domains', array('id' => $record['domain_id']));
349  if ($conf['dns_views']) {
350  list($status, $rows, $view) = db_get_record($onadb, 'dns_views', array('id' => $record['dns_view_id']));
351  $viewname = $view['name'].'/';
352  }
353  $results[] = $viewname.$record[$field].".".$domain['name'];
354  }
355  }
356 
357  // Return the records
358  return($results);
359 }
360 
361 function get_a_record_suggestions($q, $max_results=10) {
362  global $self, $conf, $onadb;
363  $results = array();
364 
365  // If we are not using views, limit to the default
366  if (!$conf['dns_views']) $limit_to_view = 'dns_view_id = 0 AND ';
367 
368  // wildcard the query before searching
369  $q = $q . '%';
370 
371  $table = 'dns';
372  $field = 'name';
373  $where = "{$limit_to_view} type LIKE 'A' and {$field} LIKE " . $onadb->qstr($q);
374  $order = "{$field} ASC";
375 
376  // Search the db for results
377  list ($status, $rows, $records) = db_get_records(
378  $onadb,
379  $table,
380  $where,
381  $order,
382  $max_results
383  );
384 
385  // If the query didn't work return the error message
386  if ($status) { $results[] = "Internal Error: {$self['error']}"; }
387 
388  foreach ($records as $record) {
389  list($status, $rows, $domain) = db_get_record($onadb, 'domains', array('id' => $record['domain_id']));
390  $results[] = $record[$field].".".$domain['name'];
391  }
392 
393  // Return the records
394  return($results);
395 }
396 
397 
398 function get_host_notes_suggestions($q, $max_results=10) {
399  return(get_text_suggestions($q . '%', 'hosts', 'notes', $max_results));
400 }
401 
402 function get_domain_suggestions($q, $max_results=10) {
403  global $self, $conf, $onadb;
404  $results = array();
405 
406  // wildcard the query before searching
407  $q = $q . '%';
408 
409  $table = 'domains';
410  $field = 'name';
411  $where = "{$field} LIKE " . $onadb->qstr($q);
412  $order = "{$field} ASC";
413 
414  // Search the db for results
415  list ($status, $rows, $records) = db_get_records(
416  $onadb,
417  $table,
418  $where,
419  $order,
420  $max_results
421  );
422 
423  // If the query didn't work return the error message
424  if ($status) { $results[] = "Internal Error: {$self['error']}"; }
425 
426  foreach ($records as $record) {
427  if ($record['parent_id']) {
428  list($status, $rows, $domain) = db_get_record($onadb, 'domains', array('id' => $record['parent_id']));
429  $results[] = $record[$field].".".ona_build_domain_name($domain['id']);
430  } else {
431  $results[] = $record[$field];
432  // Also check if this record is a parent of others
433  list ($status, $rows, $precords) = db_get_records($onadb, $table, "{$record['id']} = parent_id", $order, $max_results);
434  foreach ($precords as $precord) {
435  $results[] = $precord[$field].".".ona_build_domain_name($record['id']);
436  }
437  }
438  }
439 
440  // Return the records
441  return($results);
442 }
443 
444 function get_vlan_campus_suggestions($q, $max_results=10) {
445  $q = strtoupper($q);
446  return(get_text_suggestions($q . '%', 'vlan_campuses', 'name', $max_results));
447 }
448 
449 function get_block_suggestions($q, $max_results=10) {
450  $q = strtoupper($q);
451  return(get_text_suggestions($q . '%', 'blocks', 'name', $max_results));
452 }
453 
454 function get_subnet_suggestions($q, $max_results=10) {
455  $q = strtoupper($q);
456  return(get_text_suggestions($q . '%', 'subnets', 'name', $max_results));
457 }
458 
459 function get_location_suggestions($q, $max_results=10) {
460  return(get_text_suggestions($q . '%', 'locations', 'reference', $max_results));
461 }
462 
463 function get_mac_suggestions($q, $max_results=10) {
464  $formatted = $results = array();
465 
466  $q = strtoupper($q);
467  //if (preg_match('/[^\%\:\.\-0-9A-F]/', $q)) return(array()); // It's not a mac address ;)
468  // MP: I added the %3A line because some searches were coming through with the : replaced.
469  $q = preg_replace('/\%3A/', '', $q); // Discard characters that aren't stored in the db
470  $q = preg_replace('/[\:\.\-]/', '', $q); // Discard characters that aren't stored in the db
471 
472  $results = get_text_suggestions($q . '%', 'interfaces', 'mac_addr', $max_results);
473  foreach($results as $result) $formatted[] = mac_mangle($result, 2);
474  return($formatted);
475 }
476 
477 
478 
479 function get_ip_suggestions($q, $max_results=10) {
480  global $onadb;
481  $formatted = $results = array();
482 
483  // Complete the (potentially incomplete) ip address
484  $ip = ip_complete($q, '0');
485  $ip_end = ip_complete($q, '255');
486 
487  // Find out if $ip and $ip_end are valid
488  $ip = ip_mangle($ip, 'numeric');
489  $ip_end = ip_mangle($ip_end, 'numeric');
490  if ($ip == -1 or $ip_end == -1) { return(array()); } // It's not valid ip addresses
491 
492  // Now use SQL to look for subnet ip records that match
493  $table = 'subnets';
494  $field = 'ip_addr';
495  $where = "{$field} >= " . $onadb->qstr($ip) . " AND {$field} <= " . $onadb->qstr($ip_end);
496  $order = "{$field} ASC";
497 
498  // Search the db for results and put results into $results
499  list ($status, $rows, $records) = db_get_records($onadb, $table, $where, $order, $max_results);
500  foreach ($records as $record) { $results[] = $record[$field]; }
501 
502  // If we need more suggestions, look in the host_subnets table
503  $max_results -= count($results);
504  if ($max_results) {
505  $table = 'interfaces';
506  list ($status, $rows, $records) = db_get_records($onadb, $table, $where, $order, $max_results);
507  foreach ($records as $record) { $results[] = $record[$field]; }
508  }
509 
510 
511  // Format the ip's in dotted format
512  sort($results);
513  foreach($results as $result) {
514  // format ipv6 or regular
515  $format = ( is_ipv4($result) ? 'dotted' : 'ipv6' );
516  $formatted[] = ip_mangle($result, $format);
517  }
518 
519  unset($results, $result, $records, $record);
520  return($formatted);
521 }
522 
523 function get_model_suggestions($q, $max_results=10) {
524 // global $self, $conf, $onadb;
525 // $results = array();
526 //
527 // // wildcard the query before searching
528 // $q = $q . '%';
529 //
530 // $table = 'models';
531 // $field = 'name';
532 // $where = "{$field} LIKE " . $onadb->qstr($q);
533 // $order = "{$field} ASC";
534 //
535 // // Search the db for results
536 // list ($status, $rows, $records) = db_get_records(
537 // $onadb,
538 // $table,
539 // $where,
540 // $order,
541 // $max_results
542 // );
543 //
544 // // If the query didn't work return the error message
545 // if ($status) { $results[] = "Internal Error: {$self['error']}"; }
546 //
547 // foreach ($records as $record) {
548 // list($status, $rows, $manu) = db_get_record($onadb, 'manufacturers', array('id' => $record['manufacturer_id']));
549 // $results[] = $manu['name'].", ".$record[$field];
550 // }
551 // sort($results);
552 // // Return the records
553 // return($results);
554 
555 
556  return(get_text_suggestions($q . '%', 'models', 'name', $max_results));
557 }
558 
559 function get_custom_attribute_type_suggestions($q, $max_results=10) {
560  return(get_text_suggestions($q . '%', 'custom_attribute_types', 'name', $max_results));
561 }
562 
563 function get_role_suggestions($q, $max_results=10) {
564  return(get_text_suggestions($q . '%', 'roles', 'name', $max_results));
565 }
566 
567 function get_manufacturer_suggestions($q, $max_results=10) {
568  return(get_text_suggestions($q . '%', 'manufacturers', 'name', $max_results));
569 }
570 
571 // This could get slow as more tags are addded, there is no ability to do
572 // a distinct or group by operation here..
573 function get_tag_suggestions($q, $max_results=10) {
574  return(get_text_suggestions($q . '%', 'tags', 'name', $max_results));
575 }
576 
578 // xajax server for suggest_qsearch()
579 // This function is called by the suggest() function.
581 function suggest_qsearch($q, $el_input, $el_suggest) {
582  global $conf, $images;
583  $results = array();
584 
585  // Instantiate the xajaxResponse object
586  $response = new xajaxResponse();
587  if (!$q or !$el_input or !$el_suggest) { return($response->getXML()); }
588  $js = "";
589 
590  // Command intrepreter
591  if (strpos($q, '/') === 0) {
592  $js .= "suggestions = Array('Enter a command...');";
593  $js .= "suggest_display('{$el_input}', '{$el_suggest}');";
594  $response->addScript($js);
595  return($response->getXML());
596  }
597 
598  // Search the DB for ip addressees
599  if (count($results) < $conf['suggest_max_results']) {
600  $array = get_ip_suggestions($q, $conf['suggest_max_results'] - count($results));
601  foreach($array as $suggestion) { $results[] = $suggestion; }
602  $results = array_unique($results);
603  }
604 
605  // Search the DB for hosts
606  if (count($results) < $conf['suggest_max_results']) {
607  $array = get_host_suggestions($q, $conf['suggest_max_results'] - count($results));
608  foreach($array as $suggestion) { $results[] = $suggestion; }
609  $results = array_unique($results);
610  }
611 
612  // Search the DB for subnets
613  if (count($results) < $conf['suggest_max_results']) {
614  $array = get_subnet_suggestions($q, $conf['suggest_max_results'] - count($results));
615  foreach($array as $suggestion) { $results[] = $suggestion; }
616  $results = array_unique($results);
617  }
618 
619  // Search the DB for hosts (*)
620  if (count($results) < $conf['suggest_max_results']) {
621  $array = get_host_suggestions('%' . $q, $conf['suggest_max_results'] - count($results));
622  foreach($array as $suggestion) { $results[] = $suggestion; }
623  $results = array_unique($results);
624  }
625 
626  // Search the DB for subnets (*)
627  if (count($results) < $conf['suggest_max_results']) {
628  $array = get_subnet_suggestions('%' . $q, $conf['suggest_max_results'] - count($results));
629  foreach($array as $suggestion) { $results[] = $suggestion; }
630  $results = array_unique($results);
631  }
632 
633 // FIXM: MP this does not come out correctly in the resulting record matches.. disabled for now.
634 // // Search the DB for domains
635 // if (count($results) < $conf['suggest_max_results']) {
636 // $array = get_domain_suggestions($q, $conf['suggest_max_results'] - count($results));
637 // foreach($array as $suggestion) { $results[] = $suggestion; }
638 // $results = array_unique($results);
639 // }
640 
641  // Search the DB for mac addressees
642  if (count($results) < $conf['suggest_max_results']) {
643  $array = get_mac_suggestions($q, $conf['suggest_max_results'] - count($results));
644  foreach($array as $suggestion) { $results[] = $suggestion; }
645  $results = array_unique($results);
646  }
647 
648  // Search the DB for mac addressees (*)
649  if (count($results) < $conf['suggest_max_results']) {
650  $array = get_mac_suggestions('%' . $q, $conf['suggest_max_results'] - count($results));
651  foreach($array as $suggestion) { $results[] = $suggestion; }
652  $results = array_unique($results);
653  }
654 
655 
656  // Build the javascript to return
657  $js .= "suggestions = Array(";
658  $comma = "";
659  foreach ($results as $suggestion) {
660  $suggestion = str_replace("'", "\\'", $suggestion);
661  $js .= $comma . "'{$suggestion}'";
662  if (!$comma) { $comma = ", "; }
663  }
664  $js .= ");";
665 
666  // Tell the browser to execute the javascript in $js by sending an XML response
667  $js .= "suggest_display('{$el_input}', '{$el_suggest}');";
668  $response->addScript($js);
669  return($response->getXML());
670 }
671 
672 
674 // xajax server
675 // This function is called by the suggest() function.
677 function suggest_a_record($q, $el_input, $el_suggest) {
678  global $conf;
679 
680  // Instantiate the xajaxResponse object
681  $response = new xajaxResponse();
682  if (!$q or !$el_input or !$el_suggest) { return($response->getXML()); }
683  $js = "";
684 
685  // Search the DB
686  $results = get_a_record_suggestions($q);
687  $results = array_merge($results, get_a_record_suggestions('%'.$q, $conf['suggest_max_results'] - count($results)));
688  $results = array_unique($results);
689 
690  // Build the javascript to return
691  $js .= "suggestions = Array(";
692  $comma = "";
693  foreach ($results as $suggestion) {
694  $suggestion = str_replace("'", "\\'", $suggestion);
695  $js .= $comma . "'{$suggestion}'";
696  if (!$comma) { $comma = ", "; }
697  }
698  $js .= ");";
699 
700  // Tell the browser to execute the javascript in $js by sending an XML response
701  $js .= "suggest_display('{$el_input}', '{$el_suggest}');";
702  $response->addScript($js);
703  return($response->getXML());
704 }
705 function suggest_set_a_record_edit_record($q, $el_input, $el_suggest) {
706  return(suggest_a_record($q, $el_input, $el_suggest));
707 }
708 
709 
711 // xajax server
712 // This function is called by the suggest() function.
714 function suggest_hostname($q, $el_input, $el_suggest) {
715  global $conf;
716 
717  // Instantiate the xajaxResponse object
718  $response = new xajaxResponse();
719  if (!$q or !$el_input or !$el_suggest) { return($response->getXML()); }
720  $js = "";
721 
722  // Search the DB
723  $results = get_host_suggestions($q);
724  $results = array_merge($results, get_host_suggestions('%'.$q, $conf['suggest_max_results'] - count($results)));
725  $results = array_unique($results);
726 
727  // Build the javascript to return
728  $js .= "suggestions = Array(";
729  $comma = "";
730  foreach ($results as $suggestion) {
731  $suggestion = str_replace("'", "\\'", $suggestion);
732  $js .= $comma . "'{$suggestion}'";
733  if (!$comma) { $comma = ", "; }
734  }
735  $js .= ");";
736 
737  // Tell the browser to execute the javascript in $js by sending an XML response
738  $js .= "suggest_display('{$el_input}', '{$el_suggest}');";
739  $response->addScript($js);
740  return($response->getXML());
741 }
742 function suggest_move_hostname($q, $el_input, $el_suggest) {
743  return(suggest_hostname($q, $el_input, $el_suggest));
744 }
745 function suggest_share_hostname($q, $el_input, $el_suggest) {
746  return(suggest_hostname($q, $el_input, $el_suggest));
747 }
748 function suggest_int_hostname($q, $el_input, $el_suggest) {
749  return(suggest_hostname($q, $el_input, $el_suggest));
750 }
751 function suggest_device($q, $el_input, $el_suggest) {
752  return(suggest_hostname($q, $el_input, $el_suggest));
753 }
754 
756 // xajax server
757 // This function is called by the suggest() function.
759 //FIXME: (PK) this function is redundant. Can we replace it with a call directly
760 // to suggest_hostname()?
761 function suggest_failover_pri_hostname($q, $el_input, $el_suggest) {
762  return(suggest_hostname($q, $el_input, $el_suggest));
763 }
764 
766 // xajax server
767 // This function is called by the suggest() function.
769 //FIXME: (PK) this function is redundant. Can we replace it with a call directly
770 // to suggest_hostname()?
771 function suggest_failover_sec_hostname($q, $el_input, $el_suggest) {
772  return(suggest_hostname($q, $el_input, $el_suggest));
773 }
774 
776 // xajax server
777 // This function is called by the suggest() function.
779 function suggest_server($q, $el_input, $el_suggest) {
780  global $conf;
781 
782  // Instantiate the xajaxResponse object
783  $response = new xajaxResponse();
784  if (!$q or !$el_input or !$el_suggest) { return($response->getXML()); }
785  $js = "";
786 
787  // Search the DB
788  $results = get_host_suggestions($q);
789  $results = array_merge($results, get_host_suggestions('%'.$q, $conf['suggest_max_results'] - count($results)));
790  $results = array_unique($results);
791 
792  //TODO: potentialy add a search for get_domain_suggestions here
793 
794  // Build the javascript to return
795  $js .= "suggestions = Array(";
796  $comma = "";
797  foreach ($results as $suggestion) {
798  $suggestion = str_replace("'", "\\'", $suggestion);
799  $js .= $comma . "'{$suggestion}'";
800  if (!$comma) { $comma = ", "; }
801  }
802  $js .= ");";
803 
804  // Tell the browser to execute the javascript in $js by sending an XML response
805  $js .= "suggest_display('{$el_input}', '{$el_suggest}');";
806  $response->addScript($js);
807  return($response->getXML());
808 }
809 
810 // FIXME: (PK) do we still use these functions anywhere? Check & remove, if not.
811 // MP: I'm keeping them for now.. I've changed the function to just use host_suggestions.. server_suggestions could be removed??
812 function suggest_pool_server_qf($q, $el_input, $el_suggest) {
813  return(suggest_server($q, $el_input, $el_suggest));
814 }
815 function suggest_domain_server_name($q, $el_input, $el_suggest) {
816  return(suggest_server($q, $el_input, $el_suggest));
817 }
818 function suggest_dhcp_server_name($q, $el_input, $el_suggest) {
819  return(suggest_server($q, $el_input, $el_suggest));
820 }
821 
822 
823 
825 // xajax server
826 // This function is called by the suggest() function.
828 function suggest_domain($q, $el_input, $el_suggest) {
829  global $conf;
830 
831  // Instantiate the xajaxResponse object
832  $response = new xajaxResponse();
833  if (!$q or !$el_input or !$el_suggest) { return($response->getXML()); }
834  $js = "";
835 
836  // Search the DB
837  $results = get_domain_suggestions($q);
838  $results = array_merge($results, get_domain_suggestions('%'.$q, $conf['suggest_max_results'] - count($results)));
839  $results = array_unique($results);
840 
841  // Build the javascript to return
842  $js .= "suggestions = Array(";
843  $comma = "";
844  foreach ($results as $suggestion) {
845  $suggestion = str_replace("'", "\\'", $suggestion);
846  $js .= $comma . "'{$suggestion}'";
847  if (!$comma) { $comma = ", "; }
848  }
849  $js .= ");";
850 
851  // Tell the browser to execute the javascript in $js by sending an XML response
852  $js .= "suggest_display('{$el_input}', '{$el_suggest}');";
853  $response->addScript($js);
854  return($response->getXML());
855 }
856 function suggest_domain_alias_edit($q, $el_input, $el_suggest) {
857  return(suggest_domain($q, $el_input, $el_suggest));
858 }
859 function suggest_domain_edit($q, $el_input, $el_suggest) {
860  return(suggest_domain($q, $el_input, $el_suggest));
861 }
862 function suggest_set_domain_edit_host($q, $el_input, $el_suggest) {
863  return(suggest_domain($q, $el_input, $el_suggest));
864 }
865 function suggest_domain_server_edit($q, $el_input, $el_suggest) {
866  return(suggest_domain($q, $el_input, $el_suggest));
867 }
868 function suggest_set_domain_edit_record($q, $el_input, $el_suggest) {
869  return(suggest_domain($q, $el_input, $el_suggest));
870 }
871 function suggest_dns_domain($q, $el_input, $el_suggest) {
872  return(suggest_domain($q, $el_input, $el_suggest));
873 }
874 
875 
876 
878 // xajax server
879 // This function is called by the suggest() function.
881 function suggest_notes($q, $el_input, $el_suggest) {
882  global $conf;
883 
884  // Instantiate the xajaxResponse object
885  $response = new xajaxResponse();
886  if (!$q or !$el_input or !$el_suggest) { return($response->getXML()); }
887  $js = "";
888 
889  // Search the DB
890  $results = get_host_notes_suggestions($q, $conf['suggest_max_results']);
891  $results = array_merge($results, get_host_notes_suggestions('%'.$q, $conf['suggest_max_results'] - count($results)));
892  $results = array_unique($results);
893 
894  // Build the javascript to return
895  $js .= "suggestions = Array(";
896  $comma = "";
897  foreach ($results as $suggestion) {
898  $suggestion = str_replace("'", "\\'", $suggestion);
899  $js .= $comma . "'{$suggestion}'";
900  if (!$comma) { $comma = ", "; }
901  }
902  $js .= ");";
903 
904  // Tell the browser to execute the javascript in $js by sending an XML response
905  $js .= "suggest_display('{$el_input}', '{$el_suggest}');";
906  $response->addScript($js);
907  return($response->getXML());
908 }
909 
910 
911 
912 
913 
914 
916 // xajax server
917 // This function is called by the suggest() function.
919 function suggest_mac($q, $el_input, $el_suggest) {
920  global $conf;
921 
922  // Instantiate the xajaxResponse object
923  $response = new xajaxResponse();
924  if (!$q or !$el_input or !$el_suggest) { return($response->getXML()); }
925  $js = "";
926 
927  // Search the DB
928  $results = get_mac_suggestions($q);
929  $results = array_merge($results, get_mac_suggestions('%'.$q, $conf['suggest_max_results'] - count($results)));
930  $results = array_unique($results);
931 
932  // Build the javascript to return
933  $js .= "suggestions = Array(";
934  $comma = "";
935  foreach ($results as $suggestion) {
936  $suggestion = str_replace("'", "\\'", $suggestion);
937  $js .= $comma . "'{$suggestion}'";
938  if (!$comma) { $comma = ", "; }
939  }
940  $js .= ");";
941 
942  // Tell the browser to execute the javascript in $js by sending an XML response
943  $js .= "suggest_display('{$el_input}', '{$el_suggest}');";
944  $response->addScript($js);
945  return($response->getXML());
946 }
947 
948 
949 
950 
951 
952 
953 
954 
956 // xajax server
957 // This function is called by the suggest() function that is part of the
958 // xajax_suggest module.
960 function suggest_ip($q, $el_input, $el_suggest) {
961  global $conf;
962 
963  // Instantiate the xajaxResponse object
964  $response = new xajaxResponse();
965  if (!$q or !$el_input or !$el_suggest) { return($response->getXML()); }
966  $js = "";
967 
968  // Search the DB
969  $results = get_ip_suggestions($q);
970 
971  // Build the javascript to return
972  $js .= "suggestions = Array(";
973  $comma = "";
974  foreach ($results as $suggestion) {
975  $suggestion = str_replace("'", "\\'", $suggestion);
976  $js .= $comma . "'{$suggestion}'";
977  if (!$comma) { $comma = ", "; }
978  }
979  $js .= ");";
980 
981  // Tell the browser to execute the javascript in $js by sending an XML response
982  $js .= "suggest_display('{$el_input}', '{$el_suggest}');";
983  $response->addScript($js);
984  return($response->getXML());
985 }
986 // The following are just wrappers around suggest_ip();
987 function suggest_ip_thru($q, $el_input, $el_suggest) {
988  return(suggest_ip($q, $el_input, $el_suggest));
989 }
990 function suggest_ip_subnet($q, $el_input, $el_suggest) {
991  return(suggest_ip($q, $el_input, $el_suggest));
992 }
993 function suggest_ip_subnet_thru($q, $el_input, $el_suggest) {
994  return(suggest_ip($q, $el_input, $el_suggest));
995 }
996 function suggest_ip_subnet_qf($q, $el_input, $el_suggest) {
997  return(suggest_ip($q, $el_input, $el_suggest));
998 }
999 function suggest_ip_subnet_thru_qf($q, $el_input, $el_suggest) {
1000  return(suggest_ip($q, $el_input, $el_suggest));
1001 }
1002 function suggest_block_ip_subnet($q, $el_input, $el_suggest) {
1003  return(suggest_ip($q, $el_input, $el_suggest));
1004 }
1005 function suggest_block_ip_subnet_thru($q, $el_input, $el_suggest) {
1006  return(suggest_ip($q, $el_input, $el_suggest));
1007 }
1008 function suggest_set_ip_edit_interface($q, $el_input, $el_suggest) {
1009  return(suggest_ip($q, $el_input, $el_suggest));
1010 }
1011 function suggest_natip_qf($q, $el_input, $el_suggest) {
1012  return(suggest_ip($q, $el_input, $el_suggest));
1013 }
1014 function suggest_dns_ip($q, $el_input, $el_suggest) {
1015  return(suggest_ip($q, $el_input, $el_suggest));
1016 }
1017 
1018 
1020 // xajax server
1021 // This function is called by the suggest() function.
1023 function suggest_vlan_campus($q, $el_input, $el_suggest) {
1024  global $conf;
1025 
1026  // Instantiate the xajaxResponse object
1027  $response = new xajaxResponse();
1028  if (!$q or !$el_input or !$el_suggest) { return($response->getXML()); }
1029  $js = "";
1030 
1031  // Search the DB
1032  $results = get_vlan_campus_suggestions($q);
1033  $results = array_merge($results, get_vlan_campus_suggestions('%'.$q, $conf['suggest_max_results'] - count($results)));
1034  $results = array_unique($results);
1035 
1036  // Build the javascript to return
1037  $js .= "suggestions = Array(";
1038  $comma = "";
1039  foreach ($results as $suggestion) {
1040  $suggestion = str_replace("'", "\\'", $suggestion);
1041  $js .= $comma . "'{$suggestion}'";
1042  if (!$comma) { $comma = ", "; }
1043  }
1044  $js .= ");";
1045 
1046  // Tell the browser to execute the javascript in $js by sending an XML response
1047  $js .= "suggest_display('{$el_input}', '{$el_suggest}');";
1048  $response->addScript($js);
1049  return($response->getXML());
1050 }
1051 function suggest_vlan_edit($q, $el_input, $el_suggest) {
1052  return(suggest_vlan_campus($q, $el_input, $el_suggest));
1053 }
1054 function suggest_vlan_campus_qf($q, $el_input, $el_suggest) {
1055  return(suggest_vlan_campus($q, $el_input, $el_suggest));
1056 }
1057 
1058 
1060 // xajax server
1061 // This function is called by the suggest() function.
1063 function suggest_custom_attribute_type($q, $el_input, $el_suggest) {
1064  global $conf;
1065 
1066  // Instantiate the xajaxResponse object
1067  $response = new xajaxResponse();
1068  if (!$q or !$el_input or !$el_suggest) { return($response->getXML()); }
1069  $js = "";
1070 
1071  // Search the DB
1073  $results = array_merge($results, get_custom_attribute_type_suggestions('%'.$q, $conf['suggest_max_results'] - count($results)));
1074  $results = array_unique($results);
1075 
1076  // Build the javascript to return
1077  $js .= "suggestions = Array(";
1078  $comma = "";
1079  foreach ($results as $suggestion) {
1080  $suggestion = str_replace("'", "\\'", $suggestion);
1081  $js .= $comma . "'{$suggestion}'";
1082  if (!$comma) { $comma = ", "; }
1083  }
1084  $js .= ");";
1085 
1086  // Tell the browser to execute the javascript in $js by sending an XML response
1087  $js .= "suggest_display('{$el_input}', '{$el_suggest}');";
1088  $response->addScript($js);
1089  return($response->getXML());
1090 }
1091 
1092 function suggest_custom_attribute_type_net($q, $el_input, $el_suggest) {
1093  return(suggest_custom_attribute_type($q, $el_input, $el_suggest));
1094 }
1095 
1097 // xajax server
1098 // This function is called by the suggest() function.
1100 function suggest_manufacturer($q, $el_input, $el_suggest) {
1101  global $conf;
1102 
1103  // Instantiate the xajaxResponse object
1104  $response = new xajaxResponse();
1105  if (!$q or !$el_input or !$el_suggest) { return($response->getXML()); }
1106  $js = "";
1107 
1108  // Search the DB
1109  $results = get_manufacturer_suggestions($q);
1110  $results = array_merge($results, get_manufacturer_suggestions('%'.$q, $conf['suggest_max_results'] - count($results)));
1111  $results = array_unique($results);
1112 
1113  // Build the javascript to return
1114  $js .= "suggestions = Array(";
1115  $comma = "";
1116  foreach ($results as $suggestion) {
1117  $suggestion = str_replace("'", "\\'", $suggestion);
1118  $js .= $comma . "'{$suggestion}'";
1119  if (!$comma) { $comma = ", "; }
1120  }
1121  $js .= ");";
1122 
1123  // Tell the browser to execute the javascript in $js by sending an XML response
1124  $js .= "suggest_display('{$el_input}', '{$el_suggest}');";
1125  $response->addScript($js);
1126  return($response->getXML());
1127 }
1128 
1129 
1131 // xajax server
1132 // This function is called by the suggest() function.
1134 function suggest_model($q, $el_input, $el_suggest) {
1135  global $conf;
1136 
1137  // Instantiate the xajaxResponse object
1138  $response = new xajaxResponse();
1139  if (!$q or !$el_input or !$el_suggest) { return($response->getXML()); }
1140  $js = "";
1141 
1142  // Search the DB
1143  $results = get_model_suggestions($q);
1144  $results = array_merge($results, get_model_suggestions('%'.$q, $conf['suggest_max_results'] - count($results)));
1145  $results = array_unique($results);
1146 
1147  // Build the javascript to return
1148  $js .= "suggestions = Array(";
1149  $comma = "";
1150  foreach ($results as $suggestion) {
1151  $suggestion = str_replace("'", "\\'", $suggestion);
1152  $js .= $comma . "'{$suggestion}'";
1153  if (!$comma) { $comma = ", "; }
1154  }
1155  $js .= ");";
1156 
1157  // Tell the browser to execute the javascript in $js by sending an XML response
1158  $js .= "suggest_display('{$el_input}', '{$el_suggest}');";
1159  $response->addScript($js);
1160  return($response->getXML());
1161 }
1162 
1163 
1165 // xajax server
1166 // This function is called by the suggest() function.
1168 function suggest_tag($q, $el_input, $el_suggest) {
1169  global $conf;
1170 
1171  // Instantiate the xajaxResponse object
1172  $response = new xajaxResponse();
1173  if (!$q or !$el_input or !$el_suggest) { return($response->getXML()); }
1174  $js = "";
1175 
1176  // Search the DB
1177  $results = get_tag_suggestions($q);
1178  $results = array_merge($results, get_tag_suggestions('%'.$q, $conf['suggest_max_results'] - count($results)));
1179  $results = array_unique($results);
1180 
1181  // Build the javascript to return
1182  $js .= "suggestions = Array(";
1183  $comma = "";
1184  foreach ($results as $suggestion) {
1185  $suggestion = str_replace("'", "\\'", $suggestion);
1186  $js .= $comma . "'{$suggestion}'";
1187  if (!$comma) { $comma = ", "; }
1188  }
1189  $js .= ");";
1190 
1191  // Tell the browser to execute the javascript in $js by sending an XML response
1192  $js .= "suggest_display('{$el_input}', '{$el_suggest}');";
1193  $response->addScript($js);
1194  return($response->getXML());
1195 }
1196 function suggest_tag_qf($q, $el_input, $el_suggest) {
1197  return(suggest_tag($q, $el_input, $el_suggest));
1198 }
1199 function suggest_tag_host($q, $el_input, $el_suggest) {
1200  return(suggest_tag($q, $el_input, $el_suggest));
1201 }
1202 function suggest_tag_net($q, $el_input, $el_suggest) {
1203  return(suggest_tag($q, $el_input, $el_suggest));
1204 }
1205 
1206 
1208 // xajax server
1209 // This function is called by the suggest() function.
1211 function suggest_role($q, $el_input, $el_suggest) {
1212  global $conf;
1213 
1214  // Instantiate the xajaxResponse object
1215  $response = new xajaxResponse();
1216  if (!$q or !$el_input or !$el_suggest) { return($response->getXML()); }
1217  $js = "";
1218 
1219  // Search the DB
1220  $results = get_role_suggestions($q);
1221  $results = array_merge($results, get_role_suggestions('%'.$q, $conf['suggest_max_results'] - count($results)));
1222  $results = array_unique($results);
1223 
1224  // Build the javascript to return
1225  $js .= "suggestions = Array(";
1226  $comma = "";
1227  foreach ($results as $suggestion) {
1228  $suggestion = str_replace("'", "\\'", $suggestion);
1229  $js .= $comma . "'{$suggestion}'";
1230  if (!$comma) { $comma = ", "; }
1231  }
1232  $js .= ");";
1233 
1234  // Tell the browser to execute the javascript in $js by sending an XML response
1235  $js .= "suggest_display('{$el_input}', '{$el_suggest}');";
1236  $response->addScript($js);
1237  return($response->getXML());
1238 }
1239 
1240 
1242 // xajax server
1243 // This function is called by the suggest() function.
1245 function suggest_block($q, $el_input, $el_suggest) {
1246  global $conf;
1247 
1248  // Instantiate the xajaxResponse object
1249  $response = new xajaxResponse();
1250  if (!$q or !$el_input or !$el_suggest) { return($response->getXML()); }
1251  $js = "";
1252 
1253  // Search the DB
1254  $results = get_block_suggestions($q);
1255  $results = array_merge($results, get_block_suggestions('%'.$q, $conf['suggest_max_results'] - count($results)));
1256  $results = array_unique($results);
1257 
1258  // Build the javascript to return
1259  $js .= "suggestions = Array(";
1260  $comma = "";
1261  foreach ($results as $suggestion) {
1262  $suggestion = str_replace("'", "\\'", $suggestion);
1263  $js .= $comma . "'{$suggestion}'";
1264  if (!$comma) { $comma = ", "; }
1265  }
1266  $js .= ");";
1267 
1268  // Tell the browser to execute the javascript in $js by sending an XML response
1269  $js .= "suggest_display('{$el_input}', '{$el_suggest}');";
1270  $response->addScript($js);
1271  return($response->getXML());
1272 }
1273 
1274 
1275 
1276 
1277 
1278 
1279 
1281 // xajax server
1282 // This function is called by the suggest() function.
1284 function suggest_subnet($q, $el_input, $el_suggest) {
1285  global $conf;
1286 
1287  // Instantiate the xajaxResponse object
1288  $response = new xajaxResponse();
1289  if (!$q or !$el_input or !$el_suggest) { return($response->getXML()); }
1290  $js = "";
1291 
1292  // Search the DB
1293  $results = get_subnet_suggestions($q);
1294  $results = array_merge($results, get_subnet_suggestions('%'.$q, $conf['suggest_max_results'] - count($results)));
1295  $results = array_unique($results);
1296 
1297  // Build the javascript to return
1298  $js .= "suggestions = Array(";
1299  $comma = "";
1300  foreach ($results as $suggestion) {
1301  $suggestion = str_replace("'", "\\'", $suggestion);
1302  $js .= $comma . "'{$suggestion}'";
1303  if (!$comma) { $comma = ", "; }
1304  }
1305  $js .= ");";
1306 
1307  // Tell the browser to execute the javascript in $js by sending an XML response
1308  $js .= "suggest_display('{$el_input}', '{$el_suggest}');";
1309  $response->addScript($js);
1310  return($response->getXML());
1311 }
1312 function suggest_set_subnet_edit_interface($q, $el_input, $el_suggest) {
1313  return(suggest_subnet($q, $el_input, $el_suggest));
1314 }
1315 function suggest_set_subnet_edit_host($q, $el_input, $el_suggest) {
1316  return(suggest_subnet($q, $el_input, $el_suggest));
1317 }
1318 function suggest_subnet_qf($q, $el_input, $el_suggest) {
1319  return(suggest_subnet($q, $el_input, $el_suggest));
1320 }
1321 function suggest_dhcp_subnet_name($q, $el_input, $el_suggest) {
1322  return(suggest_subnet($q, $el_input, $el_suggest));
1323 }
1324 
1325 
1326 
1327 
1329 // xajax server
1330 // This function is called by the suggest() function.
1332 function suggest_masks_edit_subnet($q, $el_input, $el_suggest) {
1333  global $conf;
1334 
1335  // Instantiate the xajaxResponse object
1336  $response = new xajaxResponse();
1337  if (!$q or !$el_input or !$el_suggest) { return($response->getXML()); }
1338  $js = "";
1339 
1340  $q = trim($q);
1341 
1342  // Build the array of dotted masks or cidr masks if there is a /
1343  $hasslash = strpos($q,'/');
1344  if ($hasslash === FALSE) {
1345  $results = array(
1346  '255.255.255.255',
1347  '255.255.255.254',
1348  '255.255.255.252',
1349  '255.255.255.248',
1350  '255.255.255.240',
1351  '255.255.255.224',
1352  '255.255.255.192',
1353  '255.255.255.128',
1354  '255.255.255.0',
1355  '255.255.254.0',
1356  '255.255.252.0',
1357  '255.255.248.0',
1358  '255.255.240.0',
1359  '255.255.224.0',
1360  '255.255.192.0',
1361  '255.255.128.0',
1362  '255.255.0.0',
1363  '255.254.0.0',
1364  '255.252.0.0',
1365  '255.248.0.0',
1366  '255.240.0.0',
1367  '255.224.0.0',
1368  '255.192.0.0',
1369  '255.128.0.0',
1370  '255.0.0.0',
1371  '254.0.0.0',
1372  '252.0.0.0',
1373  '248.0.0.0',
1374  '240.0.0.0',
1375  '224.0.0.0',
1376  '192.0.0.0',
1377  '128.0.0.0',
1378  );
1379  }
1380  else {
1381  $results = array(
1382  '/66',
1383  '/65',
1384  '/64',
1385  '/48',
1386  '/32',
1387  '/31',
1388  '/30',
1389  '/29',
1390  '/28',
1391  '/27',
1392  '/26',
1393  '/25',
1394  '/24',
1395  '/23',
1396  '/22',
1397  '/21',
1398  '/20',
1399  '/19',
1400  '/18',
1401  '/17',
1402  '/16',
1403  '/15',
1404  '/14',
1405  '/13',
1406  '/12',
1407  '/11',
1408  '/10',
1409  '/9',
1410  '/8',
1411  '/7',
1412  '/6',
1413  '/5',
1414  '/4',
1415  '/3',
1416  '/2',
1417  '/1',
1418  );
1419  }
1420 
1421  // grep for the query to slim down the array
1422  $results = preg_grep("%{$q}%",$results);
1423 
1424  // Build the javascript to return
1425  $js .= "suggestions = Array(";
1426  $comma = "";
1427  foreach ($results as $suggestion) {
1428  $suggestion = str_replace("'", "\\'", $suggestion);
1429  $js .= $comma . "'{$suggestion}'";
1430  if (!$comma) { $comma = ", "; }
1431  }
1432  $js .= ");";
1433 
1434  // Tell the browser to execute the javascript in $js by sending an XML response
1435  $js .= "suggest_display('{$el_input}', '{$el_suggest}');";
1436  $response->addScript($js);
1437  return($response->getXML());
1438 }
1439 
1440 
1441 
1442 
1444 // xajax server
1445 // This function is called by the suggest() function.
1447 function suggest_location($q, $el_input, $el_suggest) {
1448  global $conf;
1449 
1450  // Instantiate the xajaxResponse object
1451  $response = new xajaxResponse();
1452  if (!$q or !$el_input or !$el_suggest) { return($response->getXML()); }
1453  $js = "";
1454 
1455  // Search the DB
1456  $results = get_location_suggestions($q);
1457  $results = array_merge($results, get_location_suggestions('%'.$q, $conf['suggest_max_results'] - count($results)));
1458  $results = array_unique($results);
1459 
1460  // Build the javascript to return
1461  $js .= "suggestions = Array(";
1462  $comma = "";
1463  foreach ($results as $suggestion) {
1464  $suggestion = str_replace("'", "\\'", $suggestion);
1465  $js .= $comma . "'{$suggestion}'";
1466  if (!$comma) { $comma = ", "; }
1467  }
1468  $js .= ");";
1469 
1470  // Tell the browser to execute the javascript in $js by sending an XML response
1471  $js .= "suggest_display('{$el_input}', '{$el_suggest}');";
1472  $response->addScript($js);
1473  return($response->getXML());
1474 }
1475 // Used in all QF (tool-tip based) search boxes
1476 function suggest_location_qf($q, $el_input, $el_suggest) {
1477  return(suggest_location($q, $el_input, $el_suggest));
1478 }
1479 // Advanced search subnet tab
1480 function suggest_location_number_subnet($q, $el_input, $el_suggest) {
1481  return(suggest_location($q, $el_input, $el_suggest));
1482 }
1483 // Used in all QF (tool-tip based) search boxes
1484 function suggest_set_location_edit_host($q, $el_input, $el_suggest) {
1485  return(suggest_location($q, $el_input, $el_suggest));
1486 }
1487 
1488 
1489 
1490 
1491 ?>
suggest_role
suggest_role($q, $el_input, $el_suggest)
Definition: functions_gui.inc.php:1211
suggest_int_hostname
suggest_int_hostname($q, $el_input, $el_suggest)
Definition: functions_gui.inc.php:748
workspace_plugin_loader
workspace_plugin_loader($modulename, $record=array(), $extravars=array())
Definition: functions_gui.inc.php:140
suggest_failover_pri_hostname
suggest_failover_pri_hostname($q, $el_input, $el_suggest)
Definition: functions_gui.inc.php:761
suggest_location_number_subnet
suggest_location_number_subnet($q, $el_input, $el_suggest)
Definition: functions_gui.inc.php:1480
plugin_load
& plugin_load($type, $name)
Definition: functions_gui.inc.php:102
suggest_ip_subnet
suggest_ip_subnet($q, $el_input, $el_suggest)
Definition: functions_gui.inc.php:990
suggest_manufacturer
suggest_manufacturer($q, $el_input, $el_suggest)
Definition: functions_gui.inc.php:1100
onclick
_button onclick
Definition: app_advanced_search.inc.php:50
suggest_ip_subnet_qf
suggest_ip_subnet_qf($q, $el_input, $el_suggest)
Definition: functions_gui.inc.php:996
get_manufacturer_suggestions
get_manufacturer_suggestions($q, $max_results=10)
Definition: functions_gui.inc.php:567
get_host_suggestions
get_host_suggestions($q, $max_results=10)
Definition: functions_gui.inc.php:316
get_subnet_suggestions
get_subnet_suggestions($q, $max_results=10)
Definition: functions_gui.inc.php:454
suggest_block_ip_subnet
suggest_block_ip_subnet($q, $el_input, $el_suggest)
Definition: functions_gui.inc.php:1002
suggest_custom_attribute_type_net
suggest_custom_attribute_type_net($q, $el_input, $el_suggest)
Definition: functions_gui.inc.php:1092
ip_mangle
ip_mangle($ip="", $format="default")
Definition: functions_general.inc.php:308
suggest_failover_sec_hostname
suggest_failover_sec_hostname($q, $el_input, $el_suggest)
Definition: functions_gui.inc.php:771
get_custom_attribute_type_suggestions
get_custom_attribute_type_suggestions($q, $max_results=10)
Definition: functions_gui.inc.php:559
suggest_server
suggest_server($q, $el_input, $el_suggest)
Definition: functions_gui.inc.php:779
suggest_vlan_campus
suggest_vlan_campus($q, $el_input, $el_suggest)
Definition: functions_gui.inc.php:1023
$record
$record['display_name']
Definition: app_advanced_search.inc.php:12
suggest_model
suggest_model($q, $el_input, $el_suggest)
Definition: functions_gui.inc.php:1134
build_workspace_menu
build_workspace_menu($menuarray=array())
Definition: functions_gui.inc.php:16
suggest_mac
suggest_mac($q, $el_input, $el_suggest)
Definition: functions_gui.inc.php:919
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
mac_mangle
mac_mangle($input="", $format="default")
Definition: functions_general.inc.php:964
suggest_masks_edit_subnet
suggest_masks_edit_subnet($q, $el_input, $el_suggest)
Definition: functions_gui.inc.php:1332
$modjs
$modjs
Definition: main.inc.php:41
$title_right_html
$title_right_html
Definition: main.inc.php:3
suggest_set_subnet_edit_host
suggest_set_subnet_edit_host($q, $el_input, $el_suggest)
Definition: functions_gui.inc.php:1315
get_ip_suggestions
get_ip_suggestions($q, $max_results=10)
Definition: functions_gui.inc.php:479
get_tag_suggestions
get_tag_suggestions($q, $max_results=10)
Definition: functions_gui.inc.php:573
suggest_domain_server_edit
suggest_domain_server_edit($q, $el_input, $el_suggest)
Definition: functions_gui.inc.php:865
suggest_vlan_campus_qf
suggest_vlan_campus_qf($q, $el_input, $el_suggest)
Definition: functions_gui.inc.php:1054
$modwsmenu
$modwsmenu[0]['menutitle']
Definition: main.inc.php:24
suggest_move_hostname
suggest_move_hostname($q, $el_input, $el_suggest)
Definition: functions_gui.inc.php:742
suggest_set_a_record_edit_record
suggest_set_a_record_edit_record($q, $el_input, $el_suggest)
Definition: functions_gui.inc.php:705
suggest_location_qf
suggest_location_qf($q, $el_input, $el_suggest)
Definition: functions_gui.inc.php:1476
suggest_location
suggest_location($q, $el_input, $el_suggest)
Definition: functions_gui.inc.php:1447
get_subnet_usage
get_subnet_usage($subnet_id)
Definition: functions_gui.inc.php:260
suggest_set_subnet_edit_interface
suggest_set_subnet_edit_interface($q, $el_input, $el_suggest)
Definition: functions_gui.inc.php:1312
suggest_block
suggest_block($q, $el_input, $el_suggest)
Definition: functions_gui.inc.php:1245
suggest_natip_qf
suggest_natip_qf($q, $el_input, $el_suggest)
Definition: functions_gui.inc.php:1011
$baseURL
$baseURL
Definition: config.inc.php:25
suggest_custom_attribute_type
suggest_custom_attribute_type($q, $el_input, $el_suggest)
Definition: functions_gui.inc.php:1063
suggest_device
suggest_device($q, $el_input, $el_suggest)
Definition: functions_gui.inc.php:751
suggest_set_ip_edit_interface
suggest_set_ip_edit_interface($q, $el_input, $el_suggest)
Definition: functions_gui.inc.php:1008
$type
$type
Definition: dcm.php:17
suggest_pool_server_qf
suggest_pool_server_qf($q, $el_input, $el_suggest)
Definition: functions_gui.inc.php:812
get_vlan_campus_suggestions
get_vlan_campus_suggestions($q, $max_results=10)
Definition: functions_gui.inc.php:444
suggest_set_location_edit_host
suggest_set_location_edit_host($q, $el_input, $el_suggest)
Definition: functions_gui.inc.php:1484
suggest_dns_domain
suggest_dns_domain($q, $el_input, $el_suggest)
Definition: functions_gui.inc.php:871
$mod_conf
$mod_conf
Definition: main.inc.php:9
suggest_dns_ip
suggest_dns_ip($q, $el_input, $el_suggest)
Definition: functions_gui.inc.php:1014
ip_complete
ip_complete($ip='', $filler=0)
Definition: functions_general.inc.php:1044
suggest_hostname
suggest_hostname($q, $el_input, $el_suggest)
Definition: functions_gui.inc.php:714
get_domain_suggestions
get_domain_suggestions($q, $max_results=10)
Definition: functions_gui.inc.php:402
get_subnet_usage_html
get_subnet_usage_html($subnet_id, $width=30, $height=8)
Definition: functions_gui.inc.php:294
suggest_dhcp_subnet_name
suggest_dhcp_subnet_name($q, $el_input, $el_suggest)
Definition: functions_gui.inc.php:1321
$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
suggest_domain_edit
suggest_domain_edit($q, $el_input, $el_suggest)
Definition: functions_gui.inc.php:859
suggest_subnet
suggest_subnet($q, $el_input, $el_suggest)
Definition: functions_gui.inc.php:1284
suggest_ip_subnet_thru_qf
suggest_ip_subnet_thru_qf($q, $el_input, $el_suggest)
Definition: functions_gui.inc.php:999
suggest_domain_alias_edit
suggest_domain_alias_edit($q, $el_input, $el_suggest)
Definition: functions_gui.inc.php:856
$conf
global $conf
Definition: 2-to-3.php:15
xajaxResponse
Definition: xajaxResponse.inc.php:68
get_location_suggestions
get_location_suggestions($q, $max_results=10)
Definition: functions_gui.inc.php:459
suggest_ip
suggest_ip($q, $el_input, $el_suggest)
Definition: functions_gui.inc.php:960
get_host_notes_suggestions
get_host_notes_suggestions($q, $max_results=10)
Definition: functions_gui.inc.php:398
$style
$style['font-family']
Definition: config.inc.php:158
suggest_ip_subnet_thru
suggest_ip_subnet_thru($q, $el_input, $el_suggest)
Definition: functions_gui.inc.php:993
suggest_tag
suggest_tag($q, $el_input, $el_suggest)
Definition: functions_gui.inc.php:1168
$ip
$ip
Definition: main.inc.php:24
suggest_dhcp_server_name
suggest_dhcp_server_name($q, $el_input, $el_suggest)
Definition: functions_gui.inc.php:818
nbsp
& nbsp
Definition: install.php:36
get_role_suggestions
get_role_suggestions($q, $max_results=10)
Definition: functions_gui.inc.php:563
get_block_suggestions
get_block_suggestions($q, $max_results=10)
Definition: functions_gui.inc.php:449
suggest_tag_host
suggest_tag_host($q, $el_input, $el_suggest)
Definition: functions_gui.inc.php:1199
$modbodyhtml
$modbodyhtml
Definition: unknown_module_msg.inc.php:2
suggest_set_domain_edit_record
suggest_set_domain_edit_record($q, $el_input, $el_suggest)
Definition: functions_gui.inc.php:868
get_mac_suggestions
get_mac_suggestions($q, $max_results=10)
Definition: functions_gui.inc.php:463
suggest_notes
suggest_notes($q, $el_input, $el_suggest)
Definition: functions_gui.inc.php:881
$self
global $self
Definition: 2-to-3.php:15
suggest_ip_thru
suggest_ip_thru($q, $el_input, $el_suggest)
Definition: functions_gui.inc.php:987
suggest_share_hostname
suggest_share_hostname($q, $el_input, $el_suggest)
Definition: functions_gui.inc.php:745
db_get_record
db_get_record($dbh=0, $table="", $where="", $order="")
Definition: functions_db.inc.php:708
get_model_suggestions
get_model_suggestions($q, $max_results=10)
Definition: functions_gui.inc.php:523
suggest_block_ip_subnet_thru
suggest_block_ip_subnet_thru($q, $el_input, $el_suggest)
Definition: functions_gui.inc.php:1005
suggest_tag_net
suggest_tag_net($q, $el_input, $el_suggest)
Definition: functions_gui.inc.php:1202
suggest_set_domain_edit_host
suggest_set_domain_edit_host($q, $el_input, $el_suggest)
Definition: functions_gui.inc.php:862
auth
auth($resource, $msg_level=1)
Definition: functions_general.inc.php:1330
$base
$base
Definition: 2-to-3.php:8
get_a_record_suggestions
get_a_record_suggestions($q, $max_results=10)
Definition: functions_gui.inc.php:361
suggest_tag_qf
suggest_tag_qf($q, $el_input, $el_suggest)
Definition: functions_gui.inc.php:1196
$color
if($_SERVER['SERVER_PORT']==443) $color['bg']
Definition: config.inc.php:119
plugin_list
plugin_list($type='')
Definition: functions_gui.inc.php:62
suggest_vlan_edit
suggest_vlan_edit($q, $el_input, $el_suggest)
Definition: functions_gui.inc.php:1051
get_text_suggestions
get_text_suggestions($q="", $table="", $field="", $max_results=10)
Definition: xajax_setup.inc.php:238
suggest_a_record
suggest_a_record($q, $el_input, $el_suggest)
Definition: functions_gui.inc.php:677
suggest_subnet_qf
suggest_subnet_qf($q, $el_input, $el_suggest)
Definition: functions_gui.inc.php:1318
suggest_qsearch
suggest_qsearch($q, $el_input, $el_suggest)
Definition: functions_gui.inc.php:581
$title_left_html
$title_left_html
Definition: main.inc.php:3
ona_build_domain_name
ona_build_domain_name($search='')
Definition: functions_db.inc.php:1433
suggest_domain_server_name
suggest_domain_server_name($q, $el_input, $el_suggest)
Definition: functions_gui.inc.php:815
suggest_domain
suggest_domain($q, $el_input, $el_suggest)
Definition: functions_gui.inc.php:828