summaryrefslogtreecommitdiffstats
path: root/lib/general.lib.php
diff options
context:
space:
mode:
authormomo-i <momo-i@ampache>2009-02-03 07:18:00 +0000
committermomo-i <momo-i@ampache>2009-02-03 07:18:00 +0000
commit1b3ef2951f4e72b612a11f9244b6cf791c1c4dc1 (patch)
treed2d464fab4da2d026e82f91161de23ef73a4b53b /lib/general.lib.php
parent00effbf55451016e5863e27de93344dfb4a50216 (diff)
downloadampache-1b3ef2951f4e72b612a11f9244b6cf791c1c4dc1.tar.gz
ampache-1b3ef2951f4e72b612a11f9244b6cf791c1c4dc1.tar.bz2
ampache-1b3ef2951f4e72b612a11f9244b6cf791c1c4dc1.zip
Added: checkdnsrr and getmxrr function for Win
Diffstat (limited to 'lib/general.lib.php')
-rw-r--r--lib/general.lib.php50
1 files changed, 50 insertions, 0 deletions
diff --git a/lib/general.lib.php b/lib/general.lib.php
index 11002f66..60a38819 100644
--- a/lib/general.lib.php
+++ b/lib/general.lib.php
@@ -457,4 +457,54 @@ function __autoload($class) {
} // __autoload
+function win_checkdnsrr($host, $type='MX') {
+ if (strtoupper(substr(PHP_OS, 0, 3)) != 'WIN') { return; }
+ if (empty($host)) { return; }
+ $types=array('A', 'MX', 'NS', 'SOA', 'PTR', 'CNAME', 'AAAA', 'A6', 'SRV', 'NAPTR', 'TXT', 'ANY');
+ if (!in_array($type,$types)) {
+ user_error("checkdnsrr() Type '$type' not supported", E_USER_WARNING);
+ return;
+ }
+ @exec('nslookup -type='.$type.' '.escapeshellcmd($host), $output);
+ foreach($output as $line){
+ if (preg_match('/^'.$host.'/',$line)) { return true; }
+ }
+}
+
+// Define
+if (!function_exists('checkdnsrr')) {
+ function checkdnsrr($host, $type='MX') {
+ return win_checkdnsrr($host, $type);
+ }
+}
+
+function win_getmxrr($hostname, &$mxhosts, &$mxweight=false) {
+ if (strtoupper(substr(PHP_OS, 0, 3)) != 'WIN') return;
+ if (!is_array ($mxhosts) ) $mxhosts = array();
+ if (empty($hostname)) return;
+ $exec='nslookup -type=MX '.escapeshellarg($hostname);
+ @exec($exec, $output);
+ if (empty($output)) return;
+ $i=-1;
+ foreach ($output as $line) {
+ $i++;
+ if (preg_match("/^$hostname\tMX preference = ([0-9]+), mail exchanger = (.+)$/i", $line, $parts)) {
+ $mxweight[$i] = trim($parts[1]);
+ $mxhosts[$i] = trim($parts[2]);
+ }
+ if (preg_match('/responsible mail addr = (.+)$/i', $line, $parts)) {
+ $mxweight[$i] = $i;
+ $mxhosts[$i] = trim($parts[1]);
+ }
+ }
+ return ($i!=-1);
+}
+
+// Define
+if (!function_exists('getmxrr')) {
+ function getmxrr($hostname, &$mxhosts, &$mxweight=false) {
+ return win_getmxrr($hostname, $mxhosts, $mxweight);
+ }
+}
+
?>