From 9383a15af699ede77142d040b65118e15754a2ca Mon Sep 17 00:00:00 2001 From: Frédéric Guillot Date: Sat, 25 Jan 2014 14:56:02 -0500 Subject: First commit --- lib/request.php | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 lib/request.php (limited to 'lib/request.php') diff --git a/lib/request.php b/lib/request.php new file mode 100644 index 00000000..8840e7a4 --- /dev/null +++ b/lib/request.php @@ -0,0 +1,44 @@ +getValues(); + return isset($values[$name]) ? $values[$name] : null; + } + + public function getValues() + { + if (! empty($_POST)) return $_POST; + + $result = json_decode($this->getBody(), true); + if ($result) return $result; + + return array(); + } + + public function getBody() + { + return file_get_contents('php://input'); + } + + public function getFileContent($name) + { + if (isset($_FILES[$name])) { + return file_get_contents($_FILES[$name]['tmp_name']); + } + + return ''; + } +} -- cgit v1.2.3