Advertisement
Guest User

Untitled

a guest
Sep 28th, 2016
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.03 KB | None | 0 0
  1. class Request {
  2. public $get = array();
  3. public $post = array();
  4. public $cookie = array();
  5. public $files = array();
  6. public $server = array();
  7.  
  8. public function __construct() {
  9. $this->get = $this->clean($_GET);
  10. $this->post = $this->clean($_POST);
  11. $this->request = $this->clean($_REQUEST);
  12. $this->cookie = $this->clean($_COOKIE);
  13. $this->files = $this->clean($_FILES);
  14. $this->server = $this->clean($_SERVER);
  15. }
  16.  
  17. public function clean($data) {
  18. if (is_array($data)) {
  19. foreach ($data as $key => $value) {
  20. unset($data[$key]);
  21.  
  22. $data[$this->clean($key)] = $this->clean($value);
  23. }
  24. } else {
  25. $data = htmlspecialchars($data, ENT_COMPAT, 'UTF-8');
  26. }
  27.  
  28. return $data;
  29. }
  30. }
  31.  
  32. public function clean($data) {
  33. if (is_array($data)) {
  34. foreach ($data as $key => $value) {
  35. unset($data[$key]);
  36.  
  37. $data[$this->clean($key)] = $this->clean($value);
  38. }
  39. } else {
  40. $data = htmlspecialchars($data, ENT_COMPAT, 'UTF-8');
  41. }
  42.  
  43. return $data;
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement