[FEATURE] Csrf token

- Added functionality to CsrfToken class.
- Added header support to Request class.
- Added option to set BaseCsrfVerifier class in RouterBase and
  SimpleRouter.
This commit is contained in:
Simon Sessingø
2015-10-21 18:12:53 +02:00
parent c221381c02
commit 1ba05b923c
7 changed files with 118 additions and 21 deletions
+19
View File
@@ -6,11 +6,13 @@ class Request {
protected $uri;
protected $host;
protected $method;
protected $headers;
public function __construct() {
$this->host = $_SERVER['HTTP_HOST'];
$this->uri = rtrim($_SERVER['REQUEST_URI'], '/') . '/';
$this->method = (isset($_POST['_method'])) ? strtolower($_POST['_method']) : strtolower($_SERVER['REQUEST_METHOD']);
$this->headers = getallheaders();
}
/**
@@ -50,4 +52,21 @@ class Request {
return (isset($_SERVER['PHP_AUTH_PW'])) ? $_SERVER['PHP_AUTH_PW']: null;
}
/**
* Get headers
* @return array
*/
public function getHeaders() {
return $this->headers;
}
/**
* Get header value by name
* @param string $name
* @return string|null
*/
public function getHeader($name) {
return (isset($this->headers[$name])) ? $this->headers[$name] : null;
}
}