function win_getmxrr in Email Verify 7
Same name and namespace in other branches
- 8.2 windows_compat.inc \win_getmxrr()
- 6 windows_compat.inc \win_getmxrr()
- 7.2 windows_compat.inc \win_getmxrr()
getmxrr() support for Windows by HM2K <php [at] hm2k.org>.
http://www.php.net/manual/fr/function.getmxrr.php#88033
1 call to win_getmxrr()
- windows_compat.inc in ./
windows_compat.inc - Definitions for missing functions in Windows (bah) See: http://drupal.org/node/508004
File
- ./
windows_compat.inc, line 13 - Definitions for missing functions in Windows (bah) See: http://drupal.org/node/508004
Code
function win_getmxrr($hostname, &$mxhosts, &$mxweight = FALSE) {
if (empty($hostname)) {
return;
}
if (strtoupper(substr(PHP_OS, 0, 3)) != 'WIN') {
return;
}
if (!is_array($mxhosts)) {
$mxhosts = array();
}
$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;
}