From: Alan Knowles Date: Thu, 14 Jul 2016 05:30:11 +0000 (+0800) Subject: Merge branch 'master' of http://git.roojs.com:8081/Pman.Core X-Git-Url: http://git.roojs.org/?a=commitdiff_plain;h=da2f97b10b334d3bc63508947239b70810273e97;hp=04409b93bd547a943ec213e99426baaf6592d0a6;p=Pman.Core Merge branch 'master' of git.roojs.com:8081/Pman.Core --- diff --git a/NotifySmtpCheck.php b/NotifySmtpCheck.php index ca0eb39c..695649b0 100644 --- a/NotifySmtpCheck.php +++ b/NotifySmtpCheck.php @@ -27,25 +27,7 @@ class Pman_Core_NotifySmtpCheck extends Pman return; } - $ifconfig = file_get_contents("https://ifconfig.co/"); - $dom = new DomDocument('1.0', 'utf-8'); - $dom->loadHTML($ifconfig); - - $xpath = new DOMXPath($dom); - - $element = $xpath->query("//code[@class='ip']"); - - if(!$element->length){ - return; - } - - $ip = $element->item(0)->nodeValue; - - $cmd = "host {$ip}"; - - $e = `$cmd`; - - $helo = substr(array_pop(explode(' ', $e)), 0, -2); + $helo = $this->getHelo(); $error = array(); @@ -88,4 +70,29 @@ class Pman_Core_NotifySmtpCheck extends Pman } } + function getHelo() + { + $ifconfig = file_get_contents("https://ifconfig.co/"); + $dom = new DomDocument('1.0', 'utf-8'); + $dom->loadHTML($ifconfig); + + $xpath = new DOMXPath($dom); + + $element = $xpath->query("//code[@class='ip']"); + + if(!$element->length){ + return; + } + + $ip = $element->item(0)->nodeValue; + + $cmd = "host {$ip}"; + + $e = `$cmd`; + + $helo = substr(array_pop(explode(' ', $e)), 0, -2); + + return $helo; + } + } \ No newline at end of file