diff --git a/src/Pecee/CsrfToken.php b/src/Pecee/CsrfToken.php index 9193857..d161974 100644 --- a/src/Pecee/CsrfToken.php +++ b/src/Pecee/CsrfToken.php @@ -14,8 +14,8 @@ class CsrfToken */ public static function generateToken() { - if (function_exists('mcrypt_create_iv')) { - return bin2hex(mcrypt_create_iv(32, MCRYPT_DEV_URANDOM)); + if (function_exists('random_bytes')) { + return bin2hex(random_bytes(32)); } return bin2hex(openssl_random_pseudo_bytes(32)); diff --git a/src/Pecee/Http/Input/IInputItem.php b/src/Pecee/Http/Input/IInputItem.php index 0857453..36c4cb0 100644 --- a/src/Pecee/Http/Input/IInputItem.php +++ b/src/Pecee/Http/Input/IInputItem.php @@ -6,10 +6,16 @@ interface IInputItem public function getIndex(); + public function setIndex($index); + public function getName(); + public function setName($name); + public function getValue(); + public function setValue($value); + public function __toString(); } \ No newline at end of file diff --git a/src/Pecee/Http/Input/Input.php b/src/Pecee/Http/Input/Input.php index 614949c..0850a78 100644 --- a/src/Pecee/Http/Input/Input.php +++ b/src/Pecee/Http/Input/Input.php @@ -188,10 +188,6 @@ class Input */ public function all(array $filter = null) { - if ($this->invalidContentType === true) { - return []; - } - $output = $_POST; if ($this->request->getMethod() === 'post') { diff --git a/src/Pecee/Http/Input/InputFile.php b/src/Pecee/Http/Input/InputFile.php index 679b206..0d405f7 100644 --- a/src/Pecee/Http/Input/InputFile.php +++ b/src/Pecee/Http/Input/InputFile.php @@ -4,6 +4,7 @@ namespace Pecee\Http\Input; class InputFile implements IInputItem { public $index; + public $value; public $name; public $size; public $type; @@ -18,139 +19,6 @@ class InputFile implements IInputItem $this->name = ucfirst(str_replace('_', ' ', $this->index)); } - /** - * @return string - */ - public function getIndex() - { - return $this->index; - } - - /** - * @return string - */ - public function getName() - { - return $this->name; - } - - /** - * @return string - */ - public function getSize() - { - return $this->size; - } - - /** - * @return string - */ - public function getType() - { - return $this->type; - } - - /** - * @return string - */ - public function getError() - { - return $this->error; - } - - public function getMime() - { - return $this->getType(); - } - - /** - * @return string - */ - public function getTmpName() - { - return $this->tmpName; - } - - public function getExtension() - { - return pathinfo($this->getName(), PATHINFO_EXTENSION); - } - - public function move($destination) - { - return move_uploaded_file($this->tmpName, $destination); - } - - public function getContents() - { - return file_get_contents($this->tmpName); - } - - public function setName($name) - { - $this->name = $name; - - return $this; - } - - /** - * Set file temp. name - * @param string $name - * @return static $this - */ - public function setTmpName($name) - { - $this->tmpName = $name; - - return $this; - } - - /** - * Set file size - * @param int $size - * @return static $this - */ - public function setSize($size) - { - $this->size = $size; - - return $this; - } - - /** - * Set type - * @param string $type - * @return static $this - */ - public function setType($type) - { - $this->type = $type; - - return $this; - } - - /** - * Set error - * @param int $error - * @return static $this - */ - public function setError($error) - { - $this->error = (int)$error; - - return $this; - } - - public function getValue() - { - return $this->getTmpName(); - } - - public function hasError() - { - return ($this->getError() !== 0); - } - /** * Create from array * @param array $values @@ -172,6 +40,128 @@ class InputFile implements IInputItem return $input; } + /** + * @return string + */ + public function getIndex() + { + return $this->index; + } + + public function setIndex($index) + { + $this->index = $index; + + return $this; + } + + /** + * @return string + */ + public function getSize() + { + return $this->size; + } + + /** + * Set file size + * @param int $size + * @return static $this + */ + public function setSize($size) + { + $this->size = $size; + + return $this; + } + + public function getMime() + { + return $this->getType(); + } + + /** + * @return string + */ + public function getType() + { + return $this->type; + } + + /** + * Set type + * @param string $type + * @return static $this + */ + public function setType($type) + { + $this->type = $type; + + return $this; + } + + public function getExtension() + { + return pathinfo($this->getName(), PATHINFO_EXTENSION); + } + + /** + * @return string + */ + public function getName() + { + return $this->name; + } + + public function setName($name) + { + $this->name = $name; + + return $this; + } + + public function move($destination) + { + return move_uploaded_file($this->tmpName, $destination); + } + + public function getContents() + { + return file_get_contents($this->tmpName); + } + + public function setValue($value) + { + $this->value = $value; + + return $this; + } + + public function hasError() + { + return ($this->getError() !== 0); + } + + /** + * @return string + */ + public function getError() + { + return $this->error; + } + + /** + * Set error + * @param int $error + * @return static $this + */ + public function setError($error) + { + $this->error = (int)$error; + + return $this; + } + public function toArray() { return [ @@ -187,4 +177,29 @@ class InputFile implements IInputItem { return $this->getValue(); } + + public function getValue() + { + return $this->getTmpName(); + } + + /** + * @return string + */ + public function getTmpName() + { + return $this->tmpName; + } + + /** + * Set file temp. name + * @param string $name + * @return static $this + */ + public function setTmpName($name) + { + $this->tmpName = $name; + + return $this; + } } \ No newline at end of file diff --git a/src/Pecee/Http/Input/InputItem.php b/src/Pecee/Http/Input/InputItem.php index 32719a9..91dd56c 100644 --- a/src/Pecee/Http/Input/InputItem.php +++ b/src/Pecee/Http/Input/InputItem.php @@ -24,6 +24,13 @@ class InputItem implements IInputItem return $this->index; } + public function setIndex($index) + { + $this->index = $index; + + return $this; + } + /** * @return string */ @@ -32,14 +39,6 @@ class InputItem implements IInputItem return $this->name; } - /** - * @return string - */ - public function getValue() - { - return $this->value; - } - /** * Set input name * @param string $name @@ -52,6 +51,14 @@ class InputItem implements IInputItem return $this; } + /** + * @return string + */ + public function getValue() + { + return $this->value; + } + /** * Set input value * @param string $value @@ -68,5 +75,4 @@ class InputItem implements IInputItem { return (string)$this->value; } - } \ No newline at end of file diff --git a/src/Pecee/SimpleRouter/Route/Route.php b/src/Pecee/SimpleRouter/Route/Route.php index 1878b88..64464af 100644 --- a/src/Pecee/SimpleRouter/Route/Route.php +++ b/src/Pecee/SimpleRouter/Route/Route.php @@ -384,7 +384,10 @@ abstract class Route implements IRoute } if (count($this->parameters) > 0) { - $values['parameters'] = $this->parameters; + /* Ensure the right order + values */ + $parameters = ($values['parameters'] + $this->parameters); + $parameters = array_merge($parameters, $this->parameters); + $this->setParameters($parameters); } if (count($this->middlewares) > 0) {