diff --git a/README.md b/README.md index 7817f6a..f416e0d 100644 --- a/README.md +++ b/README.md @@ -212,6 +212,18 @@ Simply create a new `web.config` file in your projects `public` directory and pa ``` +#### Troubleshoting + +If you do not have a favicon.ico file in your project, you can get `404 Router::notFoundException()` constantly. +To add `favicon.ico` as exception, you can add this line to the `` group: +`````` + +You can also make one exception for files with some extensions: +`````` + +If you are using `$_SERVER['ORIG_PATH_INFO']`, you will get `\index.php\` as part of the returned value. By sample: +```/index.php/test/mypage.php``` + ### Configuration Create a new file, name it `routes.php` and place it in your library folder. This will be the file where you define all the routes for your project. diff --git a/src/Pecee/CsrfToken.php b/src/Pecee/CsrfToken.php index 3549243..0828279 100644 --- a/src/Pecee/CsrfToken.php +++ b/src/Pecee/CsrfToken.php @@ -15,7 +15,7 @@ class CsrfToken */ public static function generateToken() { - if (function_exists('random_bytes')) { + if (function_exists('random_bytes') === true) { return bin2hex(random_bytes(32)); } @@ -46,6 +46,7 @@ class CsrfToken /** * Set csrf token cookie + * Overwrite this method to save the token to another storage like session etc. * * @param $token */ diff --git a/src/Pecee/Http/Request.php b/src/Pecee/Http/Request.php index dedf144..5c124d0 100644 --- a/src/Pecee/Http/Request.php +++ b/src/Pecee/Http/Request.php @@ -1,4 +1,5 @@ headers = []; - $max = count($_SERVER) - 1; - $keys = array_keys($_SERVER); - - for ($i = $max; $i >= 0; $i--) { - $key = $keys[$i]; - $value = $_SERVER[$key]; - + foreach ($_SERVER as $key => $value) { $this->headers[strtolower($key)] = $value; $this->headers[strtolower(str_replace('_', '-', $key))] = $value; } @@ -167,24 +162,7 @@ class Request */ public function getHeader($name, $defaultValue = null) { - if (array_key_exists(strtolower($name), $this->headers) === true) { - return $this->headers[strtolower($name)]; - } - - $max = count($_SERVER) - 1; - $keys = array_keys($_SERVER); - - for ($i = $max; $i >= 0; $i--) { - - $key = $keys[$i]; - $name = $_SERVER[$key]; - - if ($key === $name) { - return $name; - } - } - - return $defaultValue; + return isset($this->headers[strtolower($name)]) ? $this->headers[strtolower($name)] : $defaultValue; } /**