HEX
Server: Apache
System: Linux hz.vslconceptsdomains.com 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64
User: dkfounda (3233)
PHP: 8.1.34
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //usr/src/installd-accountdnscheck/lib/accountdnscheck.class.php
<?


class accountdnscheck {

	private $error = false;

	private $errors = array();

	public function __construct() {}

	public function __destruct() {}

	public function accountdnscheck_error() {
		return $this->error;
	}

	public function getVersion() {
		if(is_file('/var/cpanel/addons/accountdnscheck/version') === false) {
			$this->error = '/var/cpanel/addons/accountdnscheck/version is missing, please reinstall plugin';
			return false;
		}
		
		$result = @file_get_contents('/var/cpanel/addons/accountdnscheck/version');
		if($result === false) {
			$this->error = 'Failed to get version from /var/cpanel/addons/accountdnscheck/version';
			return false;
		}
		
		return trim($result);
	}

	public function updateAvailable() {
		$latestVersion = @file_get_contents('http://download.ndchost.com/accountdnscheck/version.php');
		if($latestVersion === false) {
			$this->error = 'Failed to get latest version information from server';
			return false;
		}
		$currentVersion = $this->getVersion();
		if($currentVersion === false) return false;

		if(version_compare($currentVersion,$latestVersion) == -1 ) return true;
		
		return false;
	}

	public function showLicenseNag() {
		$curl = curl_init();
		curl_setopt($curl, CURLOPT_URL, 'http://verify.cpanel.net/verifyFeed.cgi');
		curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
		$result = curl_exec($curl);
		curl_close($curl);
		if($result === false) {
			$this->error = 'Failed to get license information from verify.cpanel.net';
			return false;
		}

		$licenseXML = simplexml_load_string($result);
		if($licenseXML->license->attributes['group'] != 'NDCHost') {
			if(preg_match('/external/i',$licenseXML->license->attributes['package'])) {
				return true;
			}
		}
		return false;
	}

	public function resolverCheck() {
		if(!is_file("/etc/resolv.conf")) {
			$this->error = '/etc/resolv.conf is missing or not accessible';
			return false;
		}
		
		$resolvConf = @file("/etc/resolv.conf");
		if($resolvConf === false) {
			$this->error = 'Failed to read contents of /etc/resolv.conf';
			return false;
		}

		$result = exec("/sbin/ifconfig | /bin/grep inet | /bin/cut -d: -f2 | /bin/awk '{print \$1 }'", $ifconfig_output, $ifconfig_exitstatus);
		if($ifconfig_exitstatus > 1) {
			$this->error = 'execution of /sbin/ifconfig failed';
			return false;
		}
		$interfaceIps = array();
		foreach($ifconfig_output as $line) $interfaceIps[$line] = $line;

		foreach($resolvConf as $line) {
			if(preg_match('/^nameserver (\d*).(\d*).(\d*).(\d*)$/i',$line, $matches)) {
				if($interfaceIps[$matches[1].".".$matches[2].".".$matches[3].".".$matches[4]]) {
					return false;
				}
			}
		}
		
		return true;
	}

	public function reports() {
		clearstatcache();

		if(!is_dir('/var/cpanel/addons/accountdnscheck/reports')) {
			$this->error = '/var/cpanel/addons/accountdnscheck/reports directory is not accessible or does not exist';
			return false;
		}
	
		$reports = array();
		if($dh = opendir('/var/cpanel/addons/accountdnscheck/reports')) {
			while(($file = readdir($dh)) !== false) {
				if(!is_file('/var/cpanel/addons/accountdnscheck/reports/' . $file)) continue;
				$tmpstat = stat('/var/cpanel/addons/accountdnscheck/reports/' . $file);
				$reports[] = array('filename' => $file, 'date' => $tmpstat['mtime'] );
			}
		}
		
		uasort($reports, function($a, $b) { if($a['date'] == $b['date']) return 0; return ($a['date'] < $b['date']) ? 1 : -1; });

		return $reports;
	}

}