diff options
author | Simon Rettberg | 2014-05-15 18:28:24 +0200 |
---|---|---|
committer | Simon Rettberg | 2014-05-15 18:28:24 +0200 |
commit | 63c0cf521f8097b0dadaf1228176dc38c7d897f6 (patch) | |
tree | 83f5da6dc130ac7db575b0eee41ed6c7a2f994fb /inc/request.inc.php | |
parent | Fix handle leak in downloading, better error reporting on failed downloads, a... (diff) | |
download | slx-admin-63c0cf521f8097b0dadaf1228176dc38c7d897f6.tar.gz slx-admin-63c0cf521f8097b0dadaf1228176dc38c7d897f6.tar.xz slx-admin-63c0cf521f8097b0dadaf1228176dc38c7d897f6.zip |
Working on config.tgz composition through config modules
Diffstat (limited to 'inc/request.inc.php')
-rw-r--r-- | inc/request.inc.php | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/inc/request.inc.php b/inc/request.inc.php new file mode 100644 index 00000000..bb212dfd --- /dev/null +++ b/inc/request.inc.php @@ -0,0 +1,45 @@ +<?php + +/** + * Wrapper for getting fields from the request (GET, POST, ...) + */ +class Request +{ + + /** + * + * @param string $key Key of field to get from $_GET + * @param string $default Value to return if $_GET does not contain $key + * @return mixed Field from $_GET, or $default if not set + */ + public static function get($key, $default = false) + { + if (!isset($_GET[$key])) return $default; + return $_GET[$key]; + } + + /** + * + * @param string $key Key of field to get from $_POST + * @param string $default Value to return if $_POST does not contain $key + * @return mixed Field from $_POST, or $default if not set + */ + public static function post($key, $default = false) + { + if (!isset($_POST[$key])) return $default; + return $_POST[$key]; + } + + /** + * + * @param string $key Key of field to get from $_REQUEST + * @param string $default Value to return if $_REQUEST does not contain $key + * @return mixed Field from $_REQUEST, or $default if not set + */ + public static function any($key, $default = false) + { + if (!isset($_REQUEST[$key])) return $default; + return $_REQUEST[$key]; + } + +} |