summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenny Baumann <BenBE@geshi.org>2014-11-29 13:56:25 +0100
committerBenny Baumann <BenBE@geshi.org>2014-11-29 13:56:25 +0100
commit055903f98e575d31da9e2189d0a83724c9f11322 (patch)
tree501337a17be6860fddec0adcfdb9582706113479
parentdd9d8f84843eef8c5e5d744c91116a0d532f655a (diff)
parentb9e5bc9e1fbcb4ec8be3b361894ab8715e42d630 (diff)
downloadcacert-devel-055903f98e575d31da9e2189d0a83724c9f11322.tar.gz
cacert-devel-055903f98e575d31da9e2189d0a83724c9f11322.tar.xz
cacert-devel-055903f98e575d31da9e2189d0a83724c9f11322.zip
Merge branch 'bug-1318' into testserver-stable
-rw-r--r--includes/general.php38
1 files changed, 26 insertions, 12 deletions
diff --git a/includes/general.php b/includes/general.php
index 6bb3d72..e1cd72c 100644
--- a/includes/general.php
+++ b/includes/general.php
@@ -576,20 +576,34 @@
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;
+ $mxhosts = array();
+ $mxweight = array();
+ if( !getmxrr($domain, $mxhosts) ) {
+ $mxhostrr = array($domain);
+ $mxweight = array(0);
+ } else if ( !empty($mxhosts) ) {
+ $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();
}
- list($pri, $mxhosts[]) = explode(" ", trim($row), 2);
+ $mxhostprio[$mx_prio][] = $mx_host;
+ }
+
+ array_walk($mxhostprio, function(&$mx) { shuffle($mx); } );
+
+ $mxhosts = array();
+ foreach($mxhostprio as $mx_prio => $mxhostnames) {
+ foreach($mxhostnames as $mx_host) {
+ $mxhosts[] = $mx_host;
+ ]
}
- $mxhosts[] = $domain;
- array_walk($mxhosts, function(&$mx) { $mx = trim($mx, '.'); } );
foreach($mxhosts as $key => $domain)
{