Extension talk:DNSlookup

From MediaWiki.org
Jump to navigation Jump to search

How can change this extension for resolve more one IP? example: {{ #dnslookup: 127.0.0.1 127.0.0.2 }}

it's possible?

I fix this issue. For this i change efDNSlookup_wrapper function:

function efDNSlookup_wrapper( $lookup1 = '' ) {
	$tmp_lookup = preg_split('/\s/s', $lookup1,-1,PREG_SPLIT_NO_EMPTY);
	foreach ($tmp_lookup as $name => $lookup){
		if ( ! preg_match("/[.]/", $lookup)){
			$tmp_output .= $lookup." ";
			continue ;
		}
		if (($binIp = ip2long($lookup)) === false) {
          # we were given something that isn't a valid IP address-- try it as a hostname.
          $output = gethostbyname($lookup);
          # gethostbyname returns waht it was given if it doesn't resolve.
          # so, if the paramter is the same as the return, we complain that
          # it doesn't resolve.
          if ( $lookup == $output ) {
               $output = "<span style=\"color: red\">".
                               "Invalid DNS lookup: ".$lookup."</span>";
            }
        } else {
          # we were given what looks like a valid IP address, so let's find the reverse.
          $output = gethostbyaddr($lookup);
          # gethostbyaddr will return the address if it doesn't find a reverse for it.
          # since we may be building a URL around this, we go ahead and return
          # the address even if it doesn't resolve.
        }
		$tmp_output .= $output."\r\n";
	}

    return $tmp_output;

}