miniflux-legacy/vendor/PicoFarad/Request.php

57 lines
826 B
PHP
Raw Normal View History

2013-02-18 03:48:21 +01:00
<?php
namespace PicoFarad\Request;
2013-06-15 05:12:08 +02:00
function param($name, $default_value = null)
2013-02-18 03:48:21 +01:00
{
2013-06-15 05:12:08 +02:00
return isset($_GET[$name]) ? $_GET[$name] : $default_value;
2013-02-18 03:48:21 +01:00
}
2013-06-15 05:12:08 +02:00
function int_param($name, $default_value = 0)
2013-02-18 03:48:21 +01:00
{
2013-06-15 05:12:08 +02:00
return isset($_GET[$name]) && ctype_digit($_GET[$name]) ? (int) $_GET[$name] : $default_value;
}
function value($name)
{
$values = values();
return isset($values[$name]) ? $values[$name] : null;
2013-02-18 03:48:21 +01:00
}
function values()
{
if (! empty($_POST)) {
return $_POST;
}
$result = json_decode(body(), true);
if ($result) {
return $result;
}
return array();
}
function body()
{
return file_get_contents('php://input');
}
function file_content($name)
{
if (isset($_FILES[$name])) {
return file_get_contents($_FILES[$name]['tmp_name']);
}
return '';
}