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)  

ipcalc.inc.php
Go to the documentation of this file.
1 <?php
2 // DON'T put whitespace at the beginning or end of this file!!!
3 
4 
5 
6 
8 // Function: ipcalc (string $options='')
9 //
10 // Input Options:
11 // $options = key=value pairs of options for this function.
12 // multiple sets of key=value pairs should be separated
13 // by an "&" symbol.
14 //
15 // Output:
16 // Returns a two part list:
17 // 1. The exit status of the function. 0 on success, non-zero on
18 // error. All errors messages are stored in $self['error'].
19 // 2. A textual message for display on the console or web interface.
20 //
21 // Example: list($status, $result) = ipcalc('ip=address,mask=address');
23 function ipcalc($options) {
24  global $conf, $self;
25  printmsg('DEBUG => ipcalc('.$options.') called', 3);
26 
27  // Version - UPDATE on every edit!
28  $version = '1.00';
29 
30  // Parse incoming options string to an array
31  $options = parse_options($options);
32 
33  // Return the usage summary if we need to
34  if ($options['help'] or !$options['ip']) {
35  $self['error'] = 'ERROR => Insufficient parameters';
36  // NOTE: Help message lines should not exceed 80 characters for proper display on a console
37  return(array(1,
38 <<<EOM
39 
41 Displays various IP representations and basic subnet calculations
42 
43  Synopsis: ipcalc(OPTIONS)
44 
45  Required:
46  ip=STRING 32 or 128-bit Internet address
47  mask=STRING the mask you want to use
48 \n
49 EOM
50 
51  ));
52  }
53 
54 // FIXME MP: fix the fact that I"m not testing for the GMP module.. it will fail for ipv6 stuff
55 
56 // MP: I could also provide a more parsable output as well.. maybe even XML wonderfulness
57 
58  $text = '';
59  $ipinfo = ipcalc_info($options['ip'],$options['mask']);
60 
61 // MP: I removed the following as they are tooooo large
62 //bin128: {$ipinfo['ip_bin128']}
63 //bin128: {$ipinfo['mask_bin128']}
64 
65 
66 
67  $text .= <<<EOL
68 
69 Input: IP={$ipinfo['in_ip']} MASK={$ipinfo['in_mask']}
70 
71 IP={$ipinfo['in_ip']}
72  Dotted: {$ipinfo['ip_dotted']}
73  Numeric: {$ipinfo['ip_numeric']}
74  binary: {$ipinfo['ip_binary']}
75  ipv6: {$ipinfo['ip_ipv6']}
76  ipv6gz: {$ipinfo['ip_ipv6gz']}
77  flip: {$ipinfo['ip_flip']}
78 
79 MASK={$ipinfo['mask_dotted']}
80  Dotted: {$ipinfo['mask_dotted']}
81  Numeric: {$ipinfo['mask_numeric']}
82  Cidr: {$ipinfo['mask_cidr']}
83  binary: {$ipinfo['mask_binary']}
84  bin invert: {$ipinfo['mask_bin_invert']}
85  ipv6: {$ipinfo['mask_ipv6']}
86  ipv6gz: {$ipinfo['mask_ipv6gz']}
87  flip: {$ipinfo['mask_flip']}
88  IP invert: {$ipinfo['mask_dotted_invert']}
89 
90 The subnet your IP falls in is: {$ipinfo['truenet']}/{$ipinfo['mask_cidr']} ({$ipinfo['mask_dotted']})
91 
92 Total addresses using this mask: {$ipinfo['ip_total']}
93 Usable addresses using this mask: {$ipinfo['ip_usable']}
94 Last address using this mask: {$ipinfo['ip_last']}
95 
96 
97 EOL;
98 
99  return(array(0, $text));
100 }
101 
102 
103 ?>
ipcalc
ipcalc($options)
Definition: ipcalc.inc.php:23
printmsg
if(6<=$conf['debug']) printmsg($msg="", $debugLevel=0)
Definition: functions_general.inc.php:48
ipcalc_info
ipcalc_info($ip='', $mask='')
Definition: functions_general.inc.php:748
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
$conf
global $conf
Definition: 2-to-3.php:15
$text
$text
Definition: install.php:11
$self
global $self
Definition: 2-to-3.php:15
parse_options
parse_options($options="")
Definition: functions_general.inc.php:1579
$version
$version
Definition: main.inc.php:22