| 1 | <?php |
||
| 9 | class IdentificationRequest |
||
| 10 | { |
||
| 11 | public $url; |
||
| 12 | public $referrer; |
||
| 13 | public $ip; |
||
| 14 | public $user_agent; |
||
| 15 | |||
| 16 | /** |
||
| 17 | * This can be used to rapidly construct a request from superglobals simply by calling |
||
| 18 | * |
||
| 19 | * $req = class IdentificationRequest::fromArray($_SERVER); |
||
| 20 | * @param $vars |
||
| 21 | * @return IdentificationRequest |
||
| 22 | */ |
||
| 23 | 2 | public static function fromArray($vars) |
|
| 24 | { |
||
| 25 | 2 | $id = new IdentificationRequest; |
|
| 26 | 2 | if (isset($vars['REMOTE_ADDR'])) { |
|
| 27 | 2 | $id->ip = $vars['REMOTE_ADDR']; |
|
| 28 | } |
||
| 29 | 2 | if (isset($vars['HTTP_REFERER'])) { |
|
| 30 | 2 | $id->referrer = $vars['HTTP_REFERER']; |
|
| 31 | } |
||
| 32 | 2 | if (isset($vars['REQUEST_URI'])) { |
|
| 33 | 2 | $id->url = $vars['REQUEST_URI']; |
|
| 34 | } |
||
| 35 | 2 | if (isset($vars['HTTP_USER_AGENT'])) { |
|
| 36 | 2 | $id->user_agent = $vars['HTTP_USER_AGENT']; |
|
| 37 | } |
||
| 38 | 2 | return $id; |
|
| 39 | } |
||
| 40 | |||
| 41 | 10 | public function getRequestJSON() |
|
| 52 | } |
||
| 53 |