Skip to content

Commit 5dbeca6

Browse files
committed
Using autoload functions to include php files
1 parent 131cfa2 commit 5dbeca6

File tree

4 files changed

+31
-24
lines changed

4 files changed

+31
-24
lines changed

DNS/dnsData/dnsIncludes.php

-17
This file was deleted.

DNS/dnsProtocol.php

+27-4
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,32 @@
11
<?php
2-
include_once('dnsData/dnsIncludes.php');
3-
include_once('dnsResponses/dnsIncludes.php');
2+
spl_autoload_register('autoload');
3+
4+
function autoload($className) {
5+
loadfile($className,'dnsData');
6+
loadfile($className,'dnsResponses');
7+
}
8+
9+
function loadfile($className, $directory) {
10+
if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
11+
$delimiter = '\\';
12+
} else {
13+
$delimiter = '/';
14+
}
15+
if (strlen($directory)>0) {
16+
$directory .= $delimiter;
17+
}
18+
$fileName = __DIR__ . $delimiter . $directory . $className . '.php';
19+
//echo "Test autoload $fileName\n";
20+
if (is_readable($fileName)) {
21+
//echo "Autoloaded $fileName\n";
22+
require($fileName);
23+
}
24+
}
425

526
class dnsProtocol
627
{
28+
private $header;
29+
private $rawheader;
730
private $rawbuffer;
831
/**
932
*
@@ -22,7 +45,7 @@ class dnsProtocol
2245
protected $server;
2346
/**
2447
*
25-
* @var short $port=53
48+
* @var int $port=53
2649
*/
2750
protected $port;
2851
/**
@@ -408,7 +431,7 @@ function nsec3hash($qname, $salt=null, $iterations='-')
408431
$iterations--;
409432
}
410433
while ($iterations >= 0);
411-
return base32encode($toHash);
434+
return $this->base32encode($toHash);
412435
}
413436

414437

DNS/dnsResponses/dnsIncludes.php

-3
This file was deleted.

validate.php

+4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
<?php
2+
/**
3+
* This function makes use of dnsProtocol class, which is able to retrieve DNS records from nameservers
4+
* With this information the function validateDomain is able to check if the DNSSEC information on a domain name is valid
5+
*/
26
include_once(dirname(__FILE__).'/DNS/dnsProtocol.php');
37

48

0 commit comments

Comments
 (0)