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)  

main.inc.php
Go to the documentation of this file.
1 <?php
2 
3 // This module will display a small dragable subnet map. It is required that you place the following statement
4 // at the top of your display page that calls this function:
5 //
6 // include('include/functions_network_map.inc.php');
7 
9 
10 
11 // Get the numeric IP address of our subnet (we replace the last quad with a .0)
12 $ip_subnet = ip_mangle($record['ip_addr'], 'numeric');
13 if ($ip_subnet < 4294967295) {
14  $end = '\.\d+$';
15  $replace_end_by = '.0';
16  $version=4;
17 }
18 else {
19  $end = ':[0-9A-F]{0,4}$';
20  // $replace_end_by = ':0000';
23 }
24 $ip = ip_mangle(preg_replace("/$end/", $replace_end_by, $record['ip_addr']), 'numeric');
25 
26 $ip_netmask = ip_mangle($record['ip_mask'], 'numeric');
27 
28 if ($version==4) {
29  $net_end = ((4294967295 - $ip_netmask) + $ip_subnet);
30 }
31 else {
32  $net_end = gmp_strval(gmp_add(gmp_sub(gmp_init("0xfffffffffffffffffffffffffffffffe"),$ip_netmask),$ip_subnet));
33 }
34 
35 
37  <a title="Display full sized subnet map"
38  class="act"
39  onClick="xajax_window_submit('work_space', 'xajax_window_submit(\'display_block_map\', \'ip_block_start=>{$record['ip_addr']}\', \'display\');');"
40  ><img src="{$images}/silk/shape_align_left.png" border="0"></a>
41  <a title="Highlight current subnet"
42  class="act"
43  onClick="
44  var _el = el('{$ip_subnet}_block');
45  if (_el) {
46  if (_el.style.isHighlighted) {
47  _el.style.backgroundColor = '{$color['bgcolor_map_subnet']}';
48  _el.style.isHighlighted = false;
49  }
50  else {
51  _el.style.backgroundColor = '{$color['bgcolor_map_selected']}';
52  _el.style.isHighlighted = true;
53  }
54  }
55  "
56  ><img src="{$images}/silk/paintbrush.png" border="0"></a>&nbsp;&nbsp;Subnet Allocation Map
58 
59 
61 
62 
63 
64 
65 
66 
68  <table width=100% cellspacing="0" border="0" cellpadding="0" style="margin-bottom: 8px;">
69 
70  <tr><td colspan="99" nowrap="true" align="center">
71  <input type="hidden" id="{$extravars['window_name']}_zoom" name="zoom" value="7">
72  <div id="{$extravars['window_name']}_portal" onclick="el('dragmessage').style.display='';el('{$extravars['window_name']}_portal').style.color = '#FFFFFF';el('{$extravars['window_name']}_portal').style.height = '150px';el('{$extravars['window_name']}_portal').myonmouseup('fake event');" style="text-align: center;color: #999999;position: relative; height: 19px; width: 355px;">
73  Click here to show map
74  <span id="{$extravars['window_name']}_substrate"></span>
75 
76  </div>
77  <span id="dragmessage" style="display: none;font-size:10px;float: right;margin-top: -150px;padding-right: 12px;">&uarr;<br><br>D<br>R<br>A<br>G<br><br>&darr;<br></span>
78  </td>
79  </tr>
80  </table>
81 EOL;
82 
83 // Get a list of blocks that touches this subnet
84 list($status, $rows, $blocks) = db_get_records($onadb, 'blocks', "{$ip_subnet} BETWEEN ip_addr_start AND ip_addr_end OR {$net_end} BETWEEN ip_addr_start AND ip_addr_end OR ip_addr_start BETWEEN {$ip_subnet} and {$net_end}");
85 if ($rows) {
86  $modbodyhtml .= <<<EOL
87  <div style="border: 1px solid; border-bottom: none">
88  <div class="list-header">This subnet is related to following block(s):</div>
89 EOL;
90 
91  foreach($blocks as $block) {
92  $block['ip_addr_start_text'] = ip_mangle($block['ip_addr_start'], 'dotted');
93  $block['ip_addr_end_text'] = ip_mangle($block['ip_addr_end'], 'dotted');
94  $modbodyhtml .= <<<EOL
95  <div class="list-row"><a title="View block. ID: {$block['id']}"
96  class="nav"
97  onClick="xajax_window_submit('work_space', 'xajax_window_submit(\'display_block\', \'block_id=>{$block['id']}\', \'display\')');"
98  >{$block['name']}</a> ({$block['ip_addr_start_text']} - {$block['ip_addr_end_text']})</div>
99 EOL;
100  }
101  $modbodyhtml .= <<<EOL
102  </div>
103 EOL;
104 }
105 
106 // Get javascript to setup the map portal mouse handlers
107 // Force ip end to be less than ip start to prevent Block highlighting
108 $modjs .= get_portal_js($extravars['window_name'], $ip, $version);
109 
110 
111 ?>
onclick
_button onclick
Definition: app_advanced_search.inc.php:50
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
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
$modjs
$modjs
Definition: main.inc.php:41
$title_right_html
$title_right_html
Definition: main.inc.php:3
nbsp
</td >< td class="padding" align="left"></td ></tr >< tr >< td align="right" nowrap="true">< b > Netmask</b > & nbsp
Definition: main.inc.php:121
$replace_end_by
$replace_end_by
Definition: main.inc.php:21
$ip_netmask
$ip_netmask
Definition: main.inc.php:26
$modbodyhtml
$modbodyhtml
Definition: main.inc.php:5
darr
< br >< br > D< br > R< br > A< br > G< br >< br > & darr
Definition: main.inc.php:77
EOL
EOL
Definition: main.inc.php:43
$ip
$ip
Definition: main.inc.php:24
$ip_subnet
$ip_subnet
Definition: main.inc.php:12
$version
$version
Definition: main.inc.php:22
$title_left_html
$title_left_html
Definition: main.inc.php:3