| 1 |
<?php defined('ABSPATH') or die("Protected By WT!"); |
| 2 |
|
| 3 |
|
| 4 |
class WTSEC_LIBRARY_Request |
| 5 |
{ |
| 6 |
|
| 7 |
public $request; |
| 8 |
|
| 9 |
public $method; |
| 10 |
|
| 11 |
public function __construct() |
| 12 |
{ |
| 13 |
$this->request = []; |
| 14 |
$this->request += $this->clean($_GET); |
| 15 |
$this->request += $this->clean($_POST); |
| 16 |
$this->request = (object)$this->request; |
| 17 |
$this->method = $this->clean($_SERVER['REQUEST_METHOD']); |
| 18 |
} |
| 19 |
|
| 20 |
public function clean($data) |
| 21 |
{ |
| 22 |
if (is_array($data)) { |
| 23 |
foreach ($data as $key => $value) { |
| 24 |
unset($data[$key]); |
| 25 |
$data[$this->clean($key)] = $this->clean($value); |
| 26 |
} |
| 27 |
} else { |
| 28 |
$data = htmlspecialchars(strip_tags($data), ENT_COMPAT, 'UTF-8'); |
| 29 |
} |
| 30 |
return $data; |
| 31 |
} |
| 32 |
|
| 33 |
public function __get($name) |
| 34 |
{ |
| 35 |
if (!is_null($this->request) && property_exists($this->request, $name)) { |
| 36 |
return $this->request->$name; |
| 37 |
} |
| 38 |
if (isset($this->$name)) { |
| 39 |
return $this->$name; |
| 40 |
} |
| 41 |
return ""; |
| 42 |
} |
| 43 |
} |