|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace KW\KWcontroller; |
|
4
|
|
|
|
|
5
|
|
|
use Anax\Commons\ContainerInjectableInterface; |
|
6
|
|
|
use Anax\Commons\ContainerInjectableTrait; |
|
7
|
|
|
|
|
8
|
|
|
class IpWebController implements ContainerInjectableInterface |
|
9
|
|
|
{ |
|
10
|
|
|
use ContainerInjectableTrait; |
|
11
|
|
|
|
|
12
|
|
|
|
|
13
|
|
|
/** |
|
14
|
|
|
* This is the index method action, it handles: |
|
15
|
|
|
* GET METHOD mountpoint |
|
16
|
|
|
* GET METHOD mountpoint/ |
|
17
|
|
|
* GET METHOD mountpoint/index |
|
18
|
|
|
* |
|
19
|
|
|
* @return object |
|
20
|
|
|
*/ |
|
21
|
|
|
public function indexActionGet() |
|
22
|
|
|
{ |
|
23
|
|
|
$page = $this->di->get("page"); |
|
24
|
|
|
$page->add("anax/v2/ipweb/default"); |
|
25
|
|
|
|
|
26
|
|
|
//echo($this->di->get("apikeys")["config"]["darkSky"]); |
|
27
|
|
|
//die; |
|
28
|
|
|
|
|
29
|
|
|
return $page->render([ |
|
30
|
|
|
"title"=>"Mata in ipnummer" |
|
31
|
|
|
]); |
|
32
|
|
|
} |
|
33
|
|
|
|
|
34
|
|
|
/** |
|
35
|
|
|
* Return status of given ip-number |
|
36
|
|
|
* |
|
37
|
|
|
* @return object |
|
38
|
|
|
*/ |
|
39
|
|
|
public function ipnummerActionGet() |
|
40
|
|
|
{ |
|
41
|
|
|
//$ipn = $this->di->request->getGet("ipnummer"); |
|
42
|
|
|
$ipn = $this->di->get("request")->getGet("ipnummer"); |
|
43
|
|
|
if (!filter_var($ipn, FILTER_VALIDATE_IP)) { |
|
44
|
|
|
$res = [ |
|
45
|
|
|
"ip-number" => $ipn, |
|
46
|
|
|
"message" => "Not a valid ip-number" |
|
47
|
|
|
]; |
|
48
|
|
|
} else { |
|
49
|
|
|
$type = (filter_var($ipn, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4) ? "ipv4" : "ipv6" ); |
|
50
|
|
|
$domainname = gethostbyaddr($ipn); |
|
51
|
|
|
|
|
52
|
|
|
$domainname = ($domainname == $ipn ? "none" : $domainname); |
|
53
|
|
|
|
|
54
|
|
|
$res = [ |
|
55
|
|
|
"ipnumber" => $ipn, |
|
56
|
|
|
"message" => "Valid ip-number", |
|
57
|
|
|
"type" => $type, |
|
58
|
|
|
"domain name" => $domainname |
|
59
|
|
|
]; |
|
60
|
|
|
} |
|
61
|
|
|
$page = $this->di->get("page"); |
|
62
|
|
|
$page->add("anax/v2/ipweb/result", [ |
|
63
|
|
|
"res" => $res |
|
64
|
|
|
]); |
|
65
|
|
|
|
|
66
|
|
|
return $page->render([ |
|
67
|
|
|
"title" => "Resultat" |
|
68
|
|
|
]); |
|
69
|
|
|
} |
|
70
|
|
|
} |
|
71
|
|
|
|