You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
61 lines
1.4 KiB
61 lines
1.4 KiB
<?php
|
|
|
|
/**
|
|
* Provides access to various HTTP request elements: GET, POST, FILE, etc paramaters.
|
|
|
|
* @license see /license.txt
|
|
* @deprecated
|
|
* @author Laurent Opprecht <laurent@opprecht.info> for the Univesity of Geneva
|
|
*/
|
|
class Request
|
|
{
|
|
|
|
public static function get($key, $default = null)
|
|
{
|
|
return isset($_REQUEST[$key]) ? $_REQUEST[$key] : $default;
|
|
}
|
|
|
|
public static function has($key) {
|
|
return isset($_REQUEST[$key]);
|
|
}
|
|
|
|
/**
|
|
* Returns true if the request is a GET request. False otherwise.
|
|
*
|
|
* @return bool
|
|
*/
|
|
public static function is_get()
|
|
{
|
|
$method = self::server()->request_method();
|
|
$method = strtoupper($method);
|
|
return $method == 'GET';
|
|
}
|
|
|
|
public static function post($key, $default = null)
|
|
{
|
|
return isset($_POST[$key]) ? $_POST[$key] : $default;
|
|
}
|
|
|
|
/**
|
|
* Returns true if the request is a POST request. False otherwise.
|
|
*
|
|
* @return bool
|
|
*/
|
|
public static function is_post()
|
|
{
|
|
$method = self::server()->request_method();
|
|
$method = strtoupper($method);
|
|
return $method == 'POST';
|
|
}
|
|
|
|
static function file($key, $default = null)
|
|
{
|
|
return isset($_FILES[$key]) ? $_FILES[$key] : $default;
|
|
}
|
|
|
|
static function environment($key, $default = null)
|
|
{
|
|
return isset($_ENV[$key]) ? $_ENV[$key] : $default;
|
|
}
|
|
|
|
}
|
|
|