1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Anax\Controller; |
4
|
|
|
|
5
|
|
|
use Anax\Commons\ContainerInjectableInterface; |
6
|
|
|
use Anax\Commons\ContainerInjectableTrait; |
7
|
|
|
|
8
|
|
|
// use Anax\Route\Exception\ForbiddenException; |
9
|
|
|
// use Anax\Route\Exception\NotFoundException; |
10
|
|
|
// use Anax\Route\Exception\InternalErrorException; |
11
|
|
|
|
12
|
|
|
/** |
13
|
|
|
* A sample controller to show how a controller class can be implemented. |
14
|
|
|
* The controller will be injected with $di if implementing the interface |
15
|
|
|
* ContainerInjectableInterface, like this sample class does. |
16
|
|
|
* The controller is mounted on a particular route and can then handle all |
17
|
|
|
* requests for that mount point. |
18
|
|
|
* |
19
|
|
|
* @SuppressWarnings(PHPMD.TooManyPublicMethods) |
20
|
|
|
*/ |
21
|
|
|
class ipController implements ContainerInjectableInterface |
22
|
|
|
{ |
23
|
|
|
use ContainerInjectableTrait; |
24
|
|
|
|
25
|
|
|
|
26
|
|
|
/** |
27
|
|
|
* This is the index method action, it handles: |
28
|
|
|
* ANY METHOD mountpoint |
29
|
|
|
* ANY METHOD mountpoint/ |
30
|
|
|
* ANY METHOD mountpoint/index |
31
|
|
|
* |
32
|
|
|
* @return string |
33
|
|
|
*/ |
34
|
1 |
|
public function indexAction() : object |
35
|
|
|
{ |
36
|
1 |
|
$page = $this->di->get("page"); |
37
|
|
|
|
38
|
1 |
|
$ip = $this->di->request->getServer("REMOTE_ADDR"); |
|
|
|
|
39
|
1 |
|
if (isset($_GET['submit'])) { |
40
|
|
|
$ip = $this->di->request->getGet("ip"); |
41
|
|
|
} |
42
|
1 |
|
$validator = new \Anax\Model\ipValidation; |
43
|
1 |
|
$res = $validator->toJson($ip); |
44
|
|
|
$data = [ |
45
|
1 |
|
"valid" => $res["valid"], |
46
|
1 |
|
"ip" => $ip, |
47
|
1 |
|
"domain" => $res["domain"], |
48
|
1 |
|
"ipv" => $res["ipv"], |
49
|
1 |
|
"lat" => $res["lat"], |
50
|
1 |
|
"lon" => $res["lon"], |
51
|
1 |
|
"country" => $res["country"], |
52
|
1 |
|
"city" => $res["city"] |
53
|
|
|
]; |
54
|
1 |
|
$page->add("ipVerification/ipJson", $data); |
55
|
|
|
|
56
|
1 |
|
return $page->render(); |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
} |
60
|
|
|
|