$ifconfig = file_get_contents("https://ifconfig.co/");
$dom = new DomDocument('1.0', 'utf-8');
$dom->loadHTML($ifconfig);
- print_R($dom);exit;
+
$xpath = new DOMXPath($dom);
- $lists = $xpath->query("code[@class='ip]");
+ $element = $xpath->query("//code[@class='ip']");
+
+ if(!$element->length){
+ return;
+ }
+
+ $ip = $element->item(0)->nodeValue;
+
+ $cmd = "host {$ip}";
+
+ $e = `$cmd`;
- print_R($lists);exit;
+ $helo = array_pop(explode(' ', $e));
$error = array();