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.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 
7 // Function: ws_display()
8 //
9 // Description:
10 // Displays a block map in the work_space div.
12 function ws_display($window_name, $form='') {
13  global $conf, $self, $onadb;
14  global $images, $color, $style;
15  $html = '';
16  $js = '';
17  $debug_val = 3; // used in the auth() calls to supress logging
18 
19  // If the user supplied an array in a string, build the array and store it in $form
20  $form = parse_options_string($form);
21 
22  // Load the host record
23  list($status, $rows, $record) = ona_get_block_record(array('id' => $form['block_id']));
24  if ($status or !$rows) {
25  array_pop($_SESSION['ona']['work_space']['history']);
26  $html .= "<br><center><font color=\"red\"><b>Block doesn't exist!</b></font></center>";
27  $response = new xajaxResponse();
28  $response->addAssign("work_space_content", "innerHTML", $html);
29  return($response->getXML());
30  }
31 
32  // Update History Title
33  $history = array_pop($_SESSION['ona']['work_space']['history']);
34  $js .= "xajax_window_submit('work_space', ' ', 'rewrite_history');";
35  if ($history['title'] == $window_name) {
36  $history['title'] = $record['name'];
37  array_push($_SESSION['ona']['work_space']['history'], $history);
38  }
39 
40  // Create some javascript to refresh the current page
41  $refresh = htmlentities(str_replace(array("'", '"'), array("\\'", '\\"'), $history['url']), ENT_QUOTES, $conf['php_charset']);
42  $refresh = "xajax_window_submit('work_space', '{$refresh}');";
43 
44  $record['ip_addr_start'] = ip_mangle($record['ip_addr_start'], 'dotted');
45  $record['ip_addr_end'] = ip_mangle($record['ip_addr_end'], 'dotted');
46 
47  $style['content_box'] = <<<EOL
48  margin: 10px 20px;
49  padding: 2px 4px;
50  background-color: #FFFFFF;
51  vertical-align: top;
52 EOL;
53 
54  $style['label_box'] = <<<EOL
55  font-weight: bold;
56  padding: 2px 4px;
57  border: solid 1px {$color['border']};
58  background-color: {$color['window_content_bg']};
59 EOL;
60 
61  // Escape data for display in html
62  foreach(array_keys($record) as $key) { $record[$key] = htmlentities($record[$key], ENT_QUOTES, $conf['php_charset']); }
63 
64  $html .= <<<EOL
65  <!-- FORMATTING TABLE -->
66  <div style="{$style['content_box']}">
67  <table cellspacing="0" border="0" cellpadding="0"><tr>
68 
69  <!-- START OF FIRST COLUMN OF SMALL BOXES -->
70  <td nowrap="true" valign="top" style="padding-right: 15px;">
71 EOL;
72 
73 
74  // BLOCK INFORMATION
75  $html .= <<<EOL
76  <table width=100% cellspacing="0" border="0" cellpadding="0" style="margin-bottom: 8px;">
77 
78  <tr><td colspan="99" nowrap="true" style="{$style['label_box']}">
79  <!-- LABEL -->
80  <form id="form_block_{$record['id']}"
81  ><input type="hidden" name="block_id" value="{$record['id']}"
82  ><input type="hidden" name="js" value="{$refresh}"
83  ></form>
84 EOL;
85  if (auth('advanced',$debug_val)) {
86  $html .= <<<EOL
87 
88  <a title="Edit block"
89  class="act"
90  onClick="xajax_window_submit('edit_block', xajax.getFormValues('form_block_{$record['id']}'), 'editor');"
91  ><img src="{$images}/silk/page_edit.png" border="0"></a>&nbsp;
92 
93  <a title="Delete block"
94  class="act"
95  onClick="var doit=confirm('Are you sure you want to delete this block?');
96  if (doit == true)
97  xajax_window_submit('edit_block', xajax.getFormValues('form_block_{$record['id']}'), 'delete');"
98  ><img src="{$images}/silk/delete.png" border="0"></a>&nbsp;
99 EOL;
100  }
101  $html .= <<<EOL
102  {$record['name']}
103 
104  &nbsp;&nbsp;<a href="?work_space={$window_name}&block_id={$record['id']}"><img title="Direct link to {$record['name']}" src="{$images}/silk/application_link.png" border="0"></a>
105  </td>
106  </tr>
107  <tr>
108  <td align="right" nowrap="true"><b>Name</b>&nbsp;</td>
109  <td class="padding" align="left">{$record['name']}&nbsp;</td>
110  </tr>
111 
112  <tr>
113  <td align="right" nowrap="true"><b>IP start</b>&nbsp;</td>
114  <td class="padding" align="left">
115  {$record['ip_addr_start']}
116  &nbsp;
117  </td>
118  </tr>
119  <tr>
120  <td align="right" nowrap="true"><b>IP end</b>&nbsp;</td>
121  <td class="padding" align="left">
122  {$record['ip_addr_end']}
123  &nbsp;
124  </td>
125  </tr>
126  <tr>
127  <td align="right" nowrap="true"><b>Notes</b>&nbsp;</td>
128  <td class="padding" align="left">
129  {$record['notes']}
130  &nbsp;
131  </td>
132  </tr>
133 
134 
135  </table>
136 EOL;
137  // END BLOCK INFORMATION
138 
139 
140  $html .= <<<EOL
141  <!-- END OF FIRST COLUMN OF SMALL BOXES -->
142  </td>
143 
144  <!-- START OF SECOND COLUMN OF SMALL BOXES -->
145  <td valign="top" style="padding-right: 15px;">
146 EOL;
147 
148  // SMALL SUBNET MAP
149 
150  // Get the numeric IP address of our subnet (we replace the last quad with a .0)
151 
152  $ip_subnet = ip_mangle($record['ip_addr_start'], 'numeric');
153  if (is_ipv4($ip_subnet)) {
154 
155  $end = '\.\d+$';
156  $replace_end_by = '.0';
157  $version=4;
158  }
159  else {
160  $end = ':[0-9A-F]{0,4}$';
161  // $replace_end_by = ':0000';
162  $replace_end_by = ':';
163  $version=6;
164  }
165  $ip = ip_mangle(preg_replace("/$end/", $replace_end_by, $record['ip_addr_start']), 'numeric');
166 
167  $html .= <<<EOL
168  <table width=100% cellspacing="0" border="0" cellpadding="0" style="margin-bottom: 8px;">
169  <tr><td colspan="99" nowrap="true">
170  <!-- LABEL -->
171  <div style="{$style['label_box']}">
172  <a title="Display full sized subnet map"
173  class="act"
174  onClick="xajax_window_submit('work_space', 'xajax_window_submit(\'display_block_map\', \'ip_block_start=>{$record['ip_addr_start']},ip_block_end=>{$record['ip_addr_end']},id=>{$record['id']}\', \'display\');');"
175  ><img src="{$images}/silk/shape_align_left.png" border="0"></a>&nbsp;
176  <a title="Highlight start of block"
177  class="act"
178  onClick="
179  var _el = el('{$ip_subnet}_row_label');
180  if (_el) {
181  if (_el.style.isHighlighted) {
182  _el.style.backgroundColor = '#000000';
183  _el.style.isHighlighted = false;
184  }
185  else {
186  _el.style.backgroundColor = '{$color['bgcolor_map_selected']}';
187  _el.style.isHighlighted = true;
188  }
189  }
190  "
191  ><img src="{$images}/silk/paintbrush.png" border="0"></a>&nbsp;
192  <b>Block Map</b>
193  </div>
194  </td></tr>
195 
196  <tr><td colspan="99" nowrap="true">
197  <input type="hidden" id="{$window_name}_zoom" name="zoom" value="7">
198  <div id="{$window_name}_portal" style="position: relative; height: 150px; width: 355px;">
199  <span id="{$window_name}_substrate"></span>
200  </div>
201  </td></tr>
202  </table>
203 EOL;
204 
205  // Get javascript to setup the map portal mouse handlers
206  // Force ip end to be less than ip start to prevent Block highlighting
207  $portal_js .= get_portal_js($window_name, $ip, $version);
208  //*** Send a fake mouseup event to draw the initial map view ***
209  $portal_js .= "el('{$window_name}_portal').myonmouseup('fake event');";
210 
211  // END SMALL SUBNET MAP
212 
213  $html .= <<<EOL
214  <!-- END OF SECOND COLUMN OF SMALL BOXES -->
215  </td>
216 
217  <!-- START OF THIRD COLUMN OF SMALL BOXES -->
218  <td valign="top" style="padding-right: 15px;">
219 EOL;
220 
221 
222  $html .= <<<EOL
223  </td>
224  <!-- END OF THIRD COLUMN OF SMALL BOXES -->
225  </tr></table>
226  </div>
227  <!-- END OF TOP SECTION -->
228 EOL;
229 
230 
231 
232 
233 
234 
235 
236 
237 
238 
239 
240  // SUBNET LIST
241  $tab = 'subnets';
242  $submit_window = "list_{$tab}";
243  $form_id = "{$submit_window}_filter_form";
244  $_SESSION['ona'][$form_id]['tab'] = $tab;
245  $content_id = "{$window_name}_{$submit_window}";
246  $html .= <<<EOL
247  <!-- SUBNET LIST -->
248  <div style="border: 1px solid {$color['border']}; margin: 10px 20px;">
249 
250  <!-- Tab & Quick Filter -->
251  <table id="{$form_id}_table" cellspacing="0" border="0" cellpadding="0">
252  <tr>
253  <td id="{$form_id}_subnets_tab" class="table-tab-active">
254  Associated {$tab} <span id="{$form_id}_{$tab}_count"></span>
255  </td>
256 
257  <td id="{$form_id}_quick_filter" class="padding" align="right" width="100%">
258  <form id="{$form_id}" onSubmit="return false;">
259  <input id="{$form_id}_page" name="page" value="1" type="hidden">
260  <input name="content_id" value="{$content_id}" type="hidden">
261  <input name="form_id" value="{$form_id}" type="hidden">
262  <input name="ip_subnet" value="{$record['ip_addr_start']}" type="hidden">
263  <input name="ip_subnet_thru" value="{$record['ip_addr_end']}" type="hidden">
264  <div id="{$form_id}_filter_overlay"
265  title="Filter"
266  style="position: relative;
267  display: inline;
268  color: #CACACA;
269  cursor: text;"
270  onClick="this.style.display = 'none'; el('{$form_id}_filter').focus();"
271  >Name</div>
272  <input
273  id="{$form_id}_filter"
274  name="filter"
275  class="filter"
276  type="text"
277  value=""
278  size="10"
279  maxlength="20"
280  alt="Quick Filter"
281  onFocus="el('{$form_id}_filter_overlay').style.display = 'none';"
282  onBlur="if (this.value == '') el('{$form_id}_filter_overlay').style.display = 'inline';"
283  onKeyUp="
284  if (typeof(timer) != 'undefined') clearTimeout(timer);
285  code = 'if ({$form_id}_last_search != el(\'{$form_id}_filter\').value) {' +
286  ' {$form_id}_last_search = el(\'{$form_id}_filter\').value;' +
287  ' document.getElementById(\'{$form_id}_page\').value = 1;' +
288  ' xajax_window_submit(\'{$submit_window}\', xajax.getFormValues(\'{$form_id}\'), \'display_list\');' +
289  '}';
290  timer = setTimeout(code, 700);"
291  >
292  </form>
293  </td>
294 
295  </tr>
296  </table>
297 
298  <div id='{$content_id}'>
299  {$conf['loading_icon']}
300  </div>
301 
302  </div>
303 EOL;
304  $js .= <<<EOL
305  /* Setup the quick filter */
306  el('{$form_id}_filter_overlay').style.left = (el('{$form_id}_filter_overlay').offsetWidth + 10) + 'px';
307  {$form_id}_last_search = '';
308 
309  /* Tell the browser to load/display the list */
310  xajax_window_submit('{$submit_window}', xajax.getFormValues('{$form_id}'), 'display_list');
311 EOL;
312 
313 
314 
315  // Insert the new html into the window
316  // Instantiate the xajaxResponse object
317  $response = new xajaxResponse();
318  // GDO need to use Big Int JS
319  $response->addIncludeScript('include/js/bignumber.js');
320  $response->addAssign("work_space_content", "innerHTML", $html);
321  if ($js) { $response->addScript($js . $portal_js); }
322  return($response->getXML());
323 }
324 
325 
326 
327 
328 
329 
330 
331 
332 
333 
334 
335 
336 
337 
338 
339 
340 
341 
342 ?>
Name
Full Name
Definition: app_user_info.inc.php:101
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
$record
$record['display_name']
Definition: app_advanced_search.inc.php:12
$status
$status
Definition: install.php:12
$onadb
global $onadb
Definition: 2-to-3.php:15
xajax
ona_get_block_record
ona_get_block_record($array='', $order='')
Definition: functions_db.inc.php:1118
$tab
$tab
Definition: app_config_type_list.inc.php:29
ws_display
ws_display($window_name, $form='')
Definition: display_block.inc.php:12
$replace_end_by
$replace_end_by
Definition: main.inc.php:21
$form_id
$form_id
Definition: app_config_type_list.inc.php:28
$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
$submit_window
$submit_window
Definition: app_config_type_list.inc.php:30
$_SESSION
$_SESSION['ona']['auth']
Definition: login.php:14
$conf
global $conf
Definition: 2-to-3.php:15
xajaxResponse
Definition: xajaxResponse.inc.php:68
$content_id
$content_id
Definition: app_config_type_list.inc.php:31
$style
$style['font-family']
Definition: config.inc.php:158
$ip
$ip
Definition: main.inc.php:24
nbsp
& nbsp
Definition: install.php:36
$self
global $self
Definition: 2-to-3.php:15
auth
auth($resource, $msg_level=1)
Definition: functions_general.inc.php:1330
$color
if($_SERVER['SERVER_PORT']==443) $color['bg']
Definition: config.inc.php:119
$ip_subnet
$ip_subnet
Definition: main.inc.php:12
$version
$version
Definition: main.inc.php:22
parse_options_string
parse_options_string($input)
Definition: xajax_setup.inc.php:88