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)  

mangle.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: mangle_ip (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) = mangle_ip('ip=address,format=string');
23 function mangle_ip($options) {
24  global $conf, $self;
25  printmsg('DEBUG => mangle_ip('.$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 Converts between various IP address representations
42 
43  Synopsis: mangle_ip(OPTIONS)
44 
45  Required:
46  ip=<inet_addr> 32 or 128-bit Internet address
47 
48  Optional:
49  format=<specifier> Desired output format, specified as a string
50  numeric : return ip as an integer
51  dotted : return ip as an IPv4 address
52  cidr : return ip as a CIDR netmask
53  binary : return ip as a 32-bit binary string
54  bin128 : return ip as a 128-bit binary string
55  ipv6 : return ip as an IPv6 address
56  ipv6gz : return ip as a compressed IPv6 address
57 
58 \n
59 EOM
60 
61  ));
62  }
63 
64  // Now what? We need to call ip_mangle() with our options
65  if (!$options['format'])
66  $options['format'] = 'default';
67  $retval = ip_mangle($options['ip'], $options['format']) . "\n";
68 
69  if ($self['error'] != '')
70  return (array(1, $self['error'] . "\n"));
71  else
72  return (array(0, $retval));
73 }
74 
75 
76 ?>
ip_mangle
ip_mangle($ip="", $format="default")
Definition: functions_general.inc.php:308
printmsg
if(6<=$conf['debug']) printmsg($msg="", $debugLevel=0)
Definition: functions_general.inc.php:48
mangle_ip
mangle_ip($options)
Definition: mangle.inc.php:23
$conf
global $conf
Definition: 2-to-3.php:15
$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