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.
69 lines
1.5 KiB
69 lines
1.5 KiB
![]()
14 years ago
|
<?php
|
||
|
|
||
|
/**
|
||
![]()
14 years ago
|
* Provides access to various HTTP request elements: GET, POST, FILE, etc paramaters.
|
||
|
|
||
|
* @license see /license.txt
|
||
|
* @author Laurent Opprecht <laurent@opprecht.info> for the Univesity of Geneva
|
||
![]()
14 years ago
|
*/
|
||
|
class Request
|
||
|
{
|
||
|
|
||
|
public static function get($key, $default = null)
|
||
|
{
|
||
![]()
13 years ago
|
return isset($_REQUEST[$key]) ? $_REQUEST[$key] : $default;
|
||
|
}
|
||
|
|
||
|
public static function has($key){
|
||
|
return isset($_REQUEST[$key]);
|
||
![]()
14 years ago
|
}
|
||
|
|
||
![]()
14 years ago
|
/**
|
||
|
* 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';
|
||
|
}
|
||
|
|
||
![]()
14 years ago
|
public static function post($key, $default = null)
|
||
|
{
|
||
![]()
14 years ago
|
return isset($_POST[$key]) ? $_POST[$key] : $default;
|
||
![]()
14 years ago
|
}
|
||
![]()
14 years ago
|
|
||
|
/**
|
||
|
* 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';
|
||
|
}
|
||
![]()
14 years ago
|
|
||
![]()
14 years ago
|
/**
|
||
|
*
|
||
|
* @return RequestServer
|
||
|
*/
|
||
|
static function server()
|
||
![]()
14 years ago
|
{
|
||
![]()
14 years ago
|
return RequestServer::instance();
|
||
![]()
14 years ago
|
}
|
||
|
|
||
|
static function file($key, $default = null)
|
||
|
{
|
||
![]()
14 years ago
|
return isset($_FILES[$key]) ? $_FILES[$key] : $default;
|
||
![]()
14 years ago
|
}
|
||
|
|
||
|
static function environment($key, $default = null)
|
||
|
{
|
||
![]()
14 years ago
|
return isset($_ENV[$key]) ? $_ENV[$key] : $default;
|
||
![]()
14 years ago
|
}
|
||
|
|
||
|
}
|