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)  

display_block_map.inc.php
Go to the documentation of this file.
1 <?php
2 // Include map portal functions
3 include('include/functions_network_map.inc.php');
4 
5 
6 
7 
9 // Function: ws_display()
10 //
11 // Description:
12 // Displays a block record and all associated info in the work_space div.
14 function ws_display($window_name, $form='') {
15  global $conf, $self, $ona;
16  global $images, $color, $style;
17  $html = '';
18  $js = '';
19 
20  // If the user supplied an array in a string, build the array and store it in $form
21  $form = parse_options_string($form);
22 
23  // Build $ip from $form['ip_block_start']
24  $form['ip_block_start'] = ip_complete($form['ip_block_start'], '0');
25 
26  // Since we currently only display /24 (C) class networks, the
27  //GD Need to call ip_mangle() so we can use is_ipv4()
28  // last quad needs to be a .0.
29 
30  $ip = ip_mangle($form['ip_block_start'],'numeric');
31  if (is_ipv4($ip)) {
32 
33  $end = '\.\d+$';
34  $replace_end_by = '.0';
35  $version=4;
36  }
37  else {
38  $end = ':[0-9A-F]{0,4}$';
39  // $replace_end_by = ':0000';
40  $replace_end_by = ':';
41  $version=6;
42  }
43 
44  $ip = $form['ip_block_start'] = preg_replace("/$end/", $replace_end_by, $form['ip_block_start']);
45 
46  // Find out if $ip is valid
47  $ip = ip_mangle($ip, 'numeric');
48  if ($ip == -1) {
49  $js .= "alert('The IP address specified is invalid!');";
50  }
51 
52  // Update History Title
53  $history = array_pop($_SESSION['ona']['work_space']['history']);
54  $js .= "xajax_window_submit('work_space', ' ', 'rewrite_history');";
55  if ($history['title'] == $window_name) {
56  $history['title'] = 'Map: ' . ip_mangle($ip, 'dotted');
57  array_push($_SESSION['ona']['work_space']['history'], $history);
58  }
59 
60  // Create some javascript to refresh the current page
61  $refresh = htmlentities(str_replace(array("'", '"'), array("\\'", '\\"'), $history['url']), ENT_QUOTES, $conf['php_charset']);
62  $refresh = "xajax_window_submit('work_space', '{$refresh}');";
63 
64  // Define the window's inner html
65  $html .= <<<EOL
66  <div id="{$window_name}_content" style="padding: 2px 4px;">
67  <form id="block_search_form" onsubmit="el('zoom_block_button').onclick(); return false;">
68  <div id="{$window_name}_tools">
69  <b>IP Address</b>
70  <input type="hidden" id="{$window_name}_zoom" name="zoom" value="8">
71  <input id="{$window_name}_ip_block_start" name="{$window_name}_ip_block_start" value="{$form['ip_block_start']}" class="edit" type="text" size="15" />
72  <a id="zoom_block_button" title="Zoom block"
73  class="act"
74  onClick="xajax_window_submit('work_space', 'xajax_window_submit(\'{$window_name}\', \'ip_block_start=>' + el('{$window_name}_ip_block_start').value + ',zoom=>' + el('{$window_name}_zoom').value + '\', \'display\');');"
75  ><img src="{$images}/silk/bullet_go.png" border="0"></a>&nbsp;
76  <br><br>
77  </div>
78  </form>
79 
80  <div id="{$window_name}_portal">
81  <span id="{$window_name}_substrate"></span>
82  </div>
83 
84  </div>
85 EOL;
86 
87  // Position/size the portal ourselves
88  $js .=<<<EOL
89  var _el = el('{$window_name}_portal');
90 
91  /* Now calculate where we will sit */
92  var my_height = el('work_space_content').offsetHeight - el('{$window_name}_tools').offsetHeight - 40;
93  var my_width = el('{$window_name}_tools').offsetWidth - 10;
94 
95  /* Finally reposition/resize the window */
96  _el.style.position = 'relative';
97  _el.style.height = my_height + 'px';
98 
99 EOL;
100 
101  // Get javascript to setup the map portal
102  $js .= get_portal_js($window_name, $ip,$version);
103  //*** Send a fake mouseup event to draw the initial map view ***
104  $js .= "el('{$window_name}_portal').myonmouseup('fake event');";
105 
106 
107  // Insert the new html into the window
108  // Instantiate the xajaxResponse object
109  $response = new xajaxResponse();
110  // GDO need to use Big Int JS
111  $response->addIncludeScript('include/js/bignumber.js');
112  $response->addAssign("work_space_content", "innerHTML", $html);
113  if ($js) { $response->addScript($js); }
114  return($response->getXML());
115 }
116 
117 
118 
119 
120 
121 
122 
123 ?>
get_portal_js
get_portal_js($window_name, $ip, $version=4)
Definition: functions_network_map.inc.php:7
ip_mangle
ip_mangle($ip="", $format="default")
Definition: functions_general.inc.php:308
$replace_end_by
$replace_end_by
Definition: main.inc.php:21
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
ws_display
ws_display($window_name, $form='')
Definition: display_block_map.inc.php:14
$self
global $self
Definition: 2-to-3.php:15
$color
if($_SERVER['SERVER_PORT']==443) $color['bg']
Definition: config.inc.php:119
$version
$version
Definition: main.inc.php:22
parse_options_string
parse_options_string($input)
Definition: xajax_setup.inc.php:88