PEAR2_Net_RouterOS › PEAR2_Net_RouterOS-1.0.0b3/tests/bootstrap.php
- PEAR2_Net_RouterOS-1.0.0b3/
- docs/
- doxygen.ini
- phpdoc.dist.xml
- tutorials/
- PEAR2_Net_RouterOS/
- examples/
- src/
- PEAR2/
- Autoload.php
- Cache/
- Net/
- RouterOS/
- Transmitter/
- PEAR2/
- tests/
- docs/
- package.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<?php
namespace PEAR2\Net\RouterOS;
//require_once
// '../../PEAR2_Net_Transmitter.git/src/PEAR2/Net/Transmitter/Autoload.php';
//require_once '../src/PEAR2/Net/RouterOS/Autoload.php';
require_once 'PEAR2/Autoload.php';
\PEAR2\Autoload::initialize('../src');
\PEAR2\Autoload::initialize('../../PEAR2_Net_Transmitter.git/src');
\PEAR2\Autoload::initialize('../../PEAR2_Cache_SHM.git/src');
/**
* Resolves a hostname to an IP address.
*
* Resolves a hostname to an IP address. Used instead of gethostbyname() in
* order to enable resolutions to IPv6 hosts.
*
* @param string $hostname Hostname to resolve.
*
* @return string An IP (v4 or v6) for this hostname.
*/
function resolve($hostname)
{
$info = dns_get_record($hostname);
foreach ($info as $entry) {
switch($entry['type']) {
case 'A':
return $entry['ip'];
case 'AAAA':
case 'A6':
return $entry['ipv6'];
case 'CNAME':
if ($entry['host'] === $hostname) {
return resolve($entry['target']);
}
}
}
}
//Resolving HOSTNAME_* constants
$constants = array('HOSTNAME', 'HOSTNAME_INVALID', 'HOSTNAME_SILENT');
foreach ($constants as $constant) {
define(__NAMESPACE__ . '\\' . $constant, resolve(constant($constant)));
}EOF
