aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/includes/request/interface.php
diff options
context:
space:
mode:
authorIgor Wiedler <igor@wiedler.ch>2010-10-10 18:39:44 +0200
committerIgor Wiedler <igor@wiedler.ch>2010-10-10 18:39:44 +0200
commita885095897054c91ab68b753ce2a86ae74f2f666 (patch)
tree9adb9074112239838a1a69078702f08e0bcda9be /phpBB/includes/request/interface.php
parent9a39f55c24fee8fe817823097e8f596b92ab7049 (diff)
parentc2ffa78521a656b1a183d75c8de2f88624011967 (diff)
downloadforums-a885095897054c91ab68b753ce2a86ae74f2f666.tar
forums-a885095897054c91ab68b753ce2a86ae74f2f666.tar.gz
forums-a885095897054c91ab68b753ce2a86ae74f2f666.tar.bz2
forums-a885095897054c91ab68b753ce2a86ae74f2f666.tar.xz
forums-a885095897054c91ab68b753ce2a86ae74f2f666.zip
Merge branch 'feature/igorw/request-class' into develop
* feature/igorw/request-class: (21 commits) [feature/request-class] Fix mcp.php mode parameter [feature/request-class] Fix remember and session hide on login [feature/request-class] Fix missing include in database_update [feature/request-class] Make additional request test cases run [feature/request-class] Adjust some trailing newlines [feature/request-class] Remove tricky $_* is_array from acp_profile [feature/request-class] Convert any direct access to $_* to use $request [feature/request-class] Add $request to style.php, minor change [feature/request-class] Prevent recursive_set_var from applying htmlspecialchars twice [feature/request-class] Removal of direct access to some superglobals [feature/request-class] Refactor request classes to use autoloading [feature/request-class] Automatically normalize multibyte data in request_var [feature/request-class] Request class test now uses a type cast helper mock. [feature/request-class] Refactored request class and wrapper functions. [feature/request-class] Extracted type casting helpers from the request class. [feature/request-class] Replace direct use of GET/REQUEST with request_var. [feature/request-class] Use the request class in the installer & updater. [feature/request-class] request_var should return after setting the request object. [feature/request-class] Instantiate a global request class instance. [feature/request-class] New request class supports recursive arrays. ...
Diffstat (limited to 'phpBB/includes/request/interface.php')
-rw-r--r--phpBB/includes/request/interface.php103
1 files changed, 103 insertions, 0 deletions
diff --git a/phpBB/includes/request/interface.php b/phpBB/includes/request/interface.php
new file mode 100644
index 0000000000..7b5b600100
--- /dev/null
+++ b/phpBB/includes/request/interface.php
@@ -0,0 +1,103 @@
+<?php
+/**
+*
+* @package phpbb_request
+* @copyright (c) 2010 phpBB Group
+* @license http://opensource.org/licenses/gpl-license.php GNU Public License
+*
+*/
+
+/**
+* @ignore
+*/
+if (!defined('IN_PHPBB'))
+{
+ exit;
+}
+
+/**
+* An interface through which all application input can be accessed.
+*
+* @package phpbb_request
+*/
+interface phpbb_request_interface
+{
+ /**#@+
+ * Constant identifying the super global with the same name.
+ */
+ const POST = 0;
+ const GET = 1;
+ const REQUEST = 2;
+ const COOKIE = 3;
+ /**#@-*/
+
+ /**
+ * This function allows overwriting or setting a value in one of the super global arrays.
+ *
+ * Changes which are performed on the super globals directly will not have any effect on the results of
+ * other methods this class provides. Using this function should be avoided if possible! It will
+ * consume twice the the amount of memory of the value
+ *
+ * @param string $var_name The name of the variable that shall be overwritten
+ * @param mixed $value The value which the variable shall contain.
+ * If this is null the variable will be unset.
+ * @param phpbb_request_interface::POST|GET|REQUEST|COOKIE $super_global
+ * Specifies which super global shall be changed
+ */
+ public function overwrite($var_name, $value, $super_global = phpbb_request_interface::REQUEST);
+
+ /**
+ * Central type safe input handling function.
+ * All variables in GET or POST requests should be retrieved through this function to maximise security.
+ *
+ * @param string|array $var_name The form variable's name from which data shall be retrieved.
+ * If the value is an array this may be an array of indizes which will give
+ * direct access to a value at any depth. E.g. if the value of "var" is array(1 => "a")
+ * then specifying array("var", 1) as the name will return "a".
+ * @param mixed $default A default value that is returned if the variable was not set.
+ * This function will always return a value of the same type as the default.
+ * @param bool $multibyte If $default is a string this paramater has to be true if the variable may contain any UTF-8 characters
+ * Default is false, causing all bytes outside the ASCII range (0-127) to be replaced with question marks
+ * @param phpbb_request_interface::POST|GET|REQUEST|COOKIE $super_global
+ * Specifies which super global should be used
+ *
+ * @return mixed The value of $_REQUEST[$var_name] run through {@link set_var set_var} to ensure that the type is the
+ * the same as that of $default. If the variable is not set $default is returned.
+ */
+ public function variable($var_name, $default, $multibyte = false, $super_global = phpbb_request_interface::REQUEST);
+
+ /**
+ * Checks whether a certain variable was sent via POST.
+ * To make sure that a request was sent using POST you should call this function
+ * on at least one variable.
+ *
+ * @param string $name The name of the form variable which should have a
+ * _p suffix to indicate the check in the code that creates the form too.
+ *
+ * @return bool True if the variable was set in a POST request, false otherwise.
+ */
+ public function is_set_post($name);
+
+ /**
+ * Checks whether a certain variable is set in one of the super global
+ * arrays.
+ *
+ * @param string $var Name of the variable
+ * @param phpbb_request_interface::POST|GET|REQUEST|COOKIE $super_global
+ * Specifies the super global which shall be checked
+ *
+ * @return bool True if the variable was sent as input
+ */
+ public function is_set($var, $super_global = phpbb_request_interface::REQUEST);
+
+ /**
+ * Returns all variable names for a given super global
+ *
+ * @param phpbb_request_interface::POST|GET|REQUEST|COOKIE $super_global
+ * The super global from which names shall be taken
+ *
+ * @return array All variable names that are set for the super global.
+ * Pay attention when using these, they are unsanitised!
+ */
+ public function variable_names($super_global = phpbb_request_interface::REQUEST);
+}