-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathIPClient.php
More file actions
91 lines (79 loc) · 1.37 KB
/
Copy pathIPClient.php
File metadata and controls
91 lines (79 loc) · 1.37 KB
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
<?php
/**
* Created by PhpStorm.
* User: colorrabbit
* Date: 2017/8/1
* Time: 14:49
*/
namespace ColorGallery;
class IPClient
{
const IP_URL = 'https://ipleak.net/json/';
/**
* @var
*/
private $ip;
/**
* @var mixed|string
*/
private $ipClient;
/**
* IPClient constructor.
*
* @param string $ip
*/
public function __construct($ip = '')
{
if ( ! empty($ip)) {
$this->setIp($ip);
}
}
/**
* @return mixed
*/
public function getIp()
{
return $this->ip;
}
/**
* @param mixed $ip
*/
public function setIp($ip)
{
$this->ip = $ip;
}
/**
* @return string
*/
private function getUrl()
{
return self::IP_URL . $this->ip;
}
/**
* Curl
*/
private function curlIpClient()
{
$curl = new Curl();
$curl->setUrl($this->getUrl());
try {
$this->ipClient = $curl->curl();
} catch (\Exception $e) {
echo $e->getMessage();
exit;
}
}
/**
* @param string $ip
*
* @return mixed|string
*/
public function getIpClient($ip = '')
{
if ( ! empty($ip)) {
$this->setIp($ip);
}
$this->curlIpClient();
return $this->ipClient;
}
}