-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmod_ripe.php
42 lines (39 loc) · 1.53 KB
/
mod_ripe.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<?php
function ripe($args) {
if(!filter_var($args, FILTER_VALIDATE_IP) === false) {
$result = json_decode(file_get_contents("https://stat.ripe.net/data/whois/data.json?resource=".urlencode($args)."/32"),true);
if($result["status"]=!"ok") {
$returnstring = "[RIPE] Er is iets mis met de API...";
} elseif(count($result["data"]["records"])==0) {
$returnstring = "[RIPE] Geen resultaten";
} else {
$data = "IP-block: ";
foreach($result["data"]["records"][0] as $record) {
switch($record["key"]) {
case "inetnum":
case "netname":
case "descr":
case "country":
$data .= "[".$record["value"]."] ";
default:
}
}
foreach($result["data"]["irr_records"][0] as $record) {
switch($record["key"]) {
case "origin":
$data .= "| Network: AS".$record["value"]." |";
default:
}
}
$returnstring = "[RIPE] Info about ".$args.": ".$data." rDNS: ".gethostbyaddr($args);
}
} else {
$ip = gethostbyname($args);
if(!filter_var($ip, FILTER_VALIDATE_IP) === false) {
return ripe($ip);
} else {
$returnstring = "[RIPE] Voer een IP-adres in, of een hostname die resolved naar een IP-adres!";
}
}
return $returnstring;
}