summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Tänzer <neo@nhng.de>2014-12-05 01:11:53 +0100
committerMichael Tänzer <neo@nhng.de>2014-12-05 01:11:53 +0100
commit9e373f974a28e3573a419a069bfeb8ce2503f69d (patch)
tree1839642949e572469e8526a7bf519a5303da182e
parent86c04b83870dc547fdcef25f91b1bc3b1de53619 (diff)
parentb388a866c926be68aeb5a9e5bb28b364fa39ad86 (diff)
downloadcacert-devel-9e373f974a28e3573a419a069bfeb8ce2503f69d.tar.gz
cacert-devel-9e373f974a28e3573a419a069bfeb8ce2503f69d.tar.xz
cacert-devel-9e373f974a28e3573a419a069bfeb8ce2503f69d.zip
Merge remote-tracking branch 'origin/bug-1318' into release
-rw-r--r--includes/general.php39
1 files changed, 27 insertions, 12 deletions
diff --git a/includes/general.php b/includes/general.php
index b34b870..17b449b 100644
--- a/includes/general.php
+++ b/includes/general.php
@@ -538,20 +538,35 @@
if(preg_match("/^([a-zA-Z0-9])+([a-zA-Z0-9\+\._-])*@([a-zA-Z0-9_-])+([a-zA-Z0-9\._-]+)+$/" , $email))
{
list($username,$domain)=explode('@',$email,2);
- $dom = escapeshellarg($domain);
- $line = trim(shell_exec("dig +short MX $dom 2>&1"));
-#echo $email."-$dom-$line-\n";
-#echo shell_exec("dig +short mx heise.de 2>&1")."-<br>\n";
-
- $list = explode("\n", $line);
- foreach($list as $row) {
- if(!strstr($row, " ")) {
- continue;
+ $mxhostrr = array();
+ $mxweight = array();
+ if( !getmxrr($domain, $mxhostrr, $mxweight) ) {
+ $mxhostrr = array($domain);
+ $mxweight = array(0);
+ } else if ( empty($mxhostrr) ) {
+ $mxhostrr = array($domain);
+ $mxweight = array(0);
+ }
+
+ $mxhostprio = array();
+ for($i = 0; $i < count($mxhostrr); $i++) {
+ $mx_host = trim($mxhostrr[$i], '.');
+ $mx_prio = $mxweight[$i];
+ if(empty($mxhostprio[$mx_prio])) {
+ $mxhostprio[$mx_prio] = array();
+ }
+ $mxhostprio[$mx_prio][] = $mx_host;
+ }
+
+ array_walk($mxhostprio, function(&$mx) { shuffle($mx); } );
+ ksort($mxhostprio);
+
+ $mxhosts = array();
+ foreach($mxhostprio as $mx_prio => $mxhostnames) {
+ foreach($mxhostnames as $mx_host) {
+ $mxhosts[] = $mx_host;
}
- list($pri, $mxhosts[]) = explode(" ", trim($row), 2);
}
- $mxhosts[] = $domain;
- array_walk($mxhosts, function(&$mx) { $mx = trim($mx, '.'); } );
foreach($mxhosts as $key => $domain)
{