summaryrefslogtreecommitdiffstats
path: root/user_guide_src/source/libraries
diff options
context:
space:
mode:
authorJonathon Hill <jhill@brandmovers.com>2012-11-12 14:51:41 +0100
committerJonathon Hill <jhill@brandmovers.com>2012-11-12 14:51:41 +0100
commit3978fc33d82dd7f778d1adbf30744f4dfac41c25 (patch)
treef32be1ae610f0cfeff65c35abecd14e8ea5cadc6 /user_guide_src/source/libraries
parent275cf274860c6ed181d50b398efd3a21d7ba9135 (diff)
parenta9ab46d7a031bda304eb9b6658ffaf693b8d9bcb (diff)
Merge remote-tracking branch 'upstream/develop' into develop
Conflicts: user_guide_src/source/changelog.rst Signed-off-by: Jonathon Hill <jhill@brandmovers.com>
Diffstat (limited to 'user_guide_src/source/libraries')
-rw-r--r--user_guide_src/source/libraries/form_validation.rst11
-rw-r--r--user_guide_src/source/libraries/input.rst93
-rw-r--r--user_guide_src/source/libraries/sessions.rst2
-rw-r--r--user_guide_src/source/libraries/unit_testing.rst2
4 files changed, 67 insertions, 41 deletions
diff --git a/user_guide_src/source/libraries/form_validation.rst b/user_guide_src/source/libraries/form_validation.rst
index 4d1940212..a3a35b499 100644
--- a/user_guide_src/source/libraries/form_validation.rst
+++ b/user_guide_src/source/libraries/form_validation.rst
@@ -288,8 +288,8 @@ CodeIgniter lets you pipe multiple rules together. Let's try it. Change
your rules in the third parameter of rule setting function, like this::
$this->form_validation->set_rules('username', 'Username', 'required|min_length[5]|max_length[12]|is_unique[users.username]');
- $this->form_validation->set_rules('password', 'Password', 'required|matches[passconf]');
- $this->form_validation->set_rules('passconf', 'Password Confirmation', 'required');
+ $this->form_validation->set_rules('password', 'Password', 'required');
+ $this->form_validation->set_rules('passconf', 'Password Confirmation', 'required|matches[password]');
$this->form_validation->set_rules('email', 'Email', 'required|valid_email|is_unique[users.email]');
The above code sets the following rules:
@@ -315,8 +315,8 @@ can also prep your data in various ways. For example, you can set up
rules like this::
$this->form_validation->set_rules('username', 'Username', 'trim|required|min_length[5]|max_length[12]|xss_clean');
- $this->form_validation->set_rules('password', 'Password', 'trim|required|matches[passconf]|md5');
- $this->form_validation->set_rules('passconf', 'Password Confirmation', 'trim|required');
+ $this->form_validation->set_rules('password', 'Password', 'trim|required|md5');
+ $this->form_validation->set_rules('passconf', 'Password Confirmation', 'trim|required|matches[password]');
$this->form_validation->set_rules('email', 'Email', 'trim|required|valid_email');
In the above example, we are "trimming" the fields, converting the
@@ -910,9 +910,6 @@ Rule Parameter Description
to two parameters, where at least one is required (to pass
the field data).
-.. note:: When using the **matches** rule, the form item specified
- to compare against must already be defined.
-
******************
Prepping Reference
******************
diff --git a/user_guide_src/source/libraries/input.rst b/user_guide_src/source/libraries/input.rst
index c0b9c6589..177f5cb64 100644
--- a/user_guide_src/source/libraries/input.rst
+++ b/user_guide_src/source/libraries/input.rst
@@ -5,8 +5,7 @@ Input Class
The Input Class serves two purposes:
#. It pre-processes global input data for security.
-#. It provides some helper functions for fetching input data and
- pre-processing it.
+#. It provides some helper methods for fetching input data and pre-processing it.
.. note:: This class is initialized automatically by the system so there
is no need to do it manually.
@@ -14,7 +13,7 @@ The Input Class serves two purposes:
Security Filtering
==================
-The security filtering function is called automatically when a new
+The security filtering method is called automatically when a new
:doc:`controller <../general/controllers>` is invoked. It does the
following:
@@ -47,7 +46,7 @@ Using POST, GET, COOKIE, or SERVER Data
CodeIgniter comes with four helper methods that let you fetch POST, GET,
COOKIE or SERVER items. The main advantage of using the provided
-functions rather than fetching an item directly ($_POST['something'])
+methods rather than fetching an item directly (``$_POST['something']``)
is that the methods will check to see if the item is set and return
NULL if not. This lets you conveniently use data without
having to test whether an item exists first. In other words, normally
@@ -55,7 +54,7 @@ you might do something like this::
$something = isset($_POST['something']) ? $_POST['something'] : NULL;
-With CodeIgniter's built in functions you can simply do this::
+With CodeIgniter's built in methods you can simply do this::
$something = $this->input->post('something');
@@ -74,7 +73,7 @@ looking for::
$this->input->post('some_data');
-The function returns NULL if the item you are attempting to retrieve
+The method returns NULL if the item you are attempting to retrieve
does not exist.
The second optional parameter lets you run the data through the XSS
@@ -89,7 +88,7 @@ To return an array of all POST items call without any parameters.
To return all POST items and pass them through the XSS filter set the
first parameter NULL while setting the second parameter to boolean;
-The function returns NULL if there are no items in the POST.
+The method returns NULL if there are no items in the POST.
::
@@ -99,8 +98,8 @@ The function returns NULL if there are no items in the POST.
$this->input->get()
===================
-This function is identical to the post function, only it fetches get
-data::
+This method is identical to the post method, only it fetches get data
+::
$this->input->get('some_data', TRUE);
@@ -109,7 +108,7 @@ To return an array of all GET items call without any parameters.
To return all GET items and pass them through the XSS filter set the
first parameter NULL while setting the second parameter to boolean;
-The function returns NULL if there are no items in the GET.
+The method returns NULL if there are no items in the GET.
::
@@ -118,9 +117,9 @@ The function returns NULL if there are no items in the GET.
$this->input->get_post()
-=========================
+========================
-This function will search through both the post and get streams for
+This method will search through both the post and get streams for
data, looking first in post, and then in get::
$this->input->get_post('some_data', TRUE);
@@ -128,8 +127,8 @@ data, looking first in post, and then in get::
$this->input->cookie()
======================
-This function is identical to the post function, only it fetches cookie
-data::
+This method is identical to the post method, only it fetches cookie data
+::
$this->input->cookie('some_cookie');
$this->input->cookie('some_cookie, TRUE); // with XSS filter
@@ -138,16 +137,43 @@ data::
$this->input->server()
======================
-This function is identical to the above functions, only it fetches
+This method is identical to the above methods, only it fetches server
server data::
$this->input->server('some_data');
+Using the php://input stream
+============================
+
+If you want to utilize the PUT, DELETE, PATCH or other exotic request
+methods, they can only be accessed via a special input stream, that
+can only be read once. This isn't as easy as just reading from e.g.
+the ``$_POST`` array, because it will always exist and you can try
+and access multiple variables without caring that you might only have
+one shot at all of the POST data.
+
+CodeIgniter will take care of that for you, and you can access data
+from the **php://input** stream at any time, just by calling the
+``input_stream()`` method::
+
+ $this->input->input_stream('key');
+
+Similar to the methods above, if the requested data is not found, it
+will return NULL and you can also decide whether to run the data
+through ``xss_clean()`` by passing a boolean value as the second
+parameter::
+
+ $this->input->input_stream('key', TRUE); // XSS Clean
+ $this->input->input_stream('key', FALSE); // No XSS filter
+
+.. note:: You can utilize method() in order to know if you're reading
+ PUT, DELETE or PATCH data.
+
$this->input->set_cookie()
-===========================
+==========================
Sets a cookie containing the values you specify. There are two ways to
-pass information to this function so that a cookie can be set: Array
+pass information to this method so that a cookie can be set: Array
Method, and Discrete Parameters:
Array Method
@@ -182,7 +208,7 @@ For site-wide cookies regardless of how your site is requested, add your
URL to the **domain** starting with a period, like this:
.your-domain.com
-The path is usually not needed since the function sets a root path.
+The path is usually not needed since the method sets a root path.
The prefix is only needed if you need to avoid name collisions with
other identically named cookies for your server.
@@ -198,22 +224,25 @@ parameters::
$this->input->set_cookie($name, $value, $expire, $domain, $path, $prefix, $secure);
+
$this->input->ip_address()
-===========================
+==========================
Returns the IP address for the current user. If the IP address is not
-valid, the function will return an IP of: 0.0.0.0
+valid, the method will return an IP of: 0.0.0.0
::
echo $this->input->ip_address();
$this->input->valid_ip($ip)
-============================
+===========================
Takes an IP address as input and returns TRUE or FALSE (boolean) if it
-is valid or not. Note: The $this->input->ip_address() function above
-validates the IP automatically.
+is valid or not.
+
+.. note:: The $this->input->ip_address() method above automatically
+ validates the IP address.
::
@@ -230,7 +259,7 @@ Accepts an optional second string parameter of 'ipv4' or 'ipv6' to specify
an IP format. The default checks for both formats.
$this->input->user_agent()
-===========================
+==========================
Returns the user agent (web browser) being used by the current user.
Returns FALSE if it's not available.
@@ -243,7 +272,7 @@ See the :doc:`User Agent Class <user_agent>` for methods which extract
information from the user agent string.
$this->input->request_headers()
-================================
+===============================
Useful if running in a non-Apache environment where
`apache_request_headers() <http://php.net/apache_request_headers>`_
@@ -253,8 +282,8 @@ will not be supported. Returns an array of headers.
$headers = $this->input->request_headers();
-$this->input->get_request_header();
-=====================================
+$this->input->get_request_header()
+==================================
Returns a single member of the request headers array.
@@ -263,13 +292,13 @@ Returns a single member of the request headers array.
$this->input->get_request_header('some-header', TRUE);
$this->input->is_ajax_request()
-=================================
+===============================
Checks to see if the HTTP_X_REQUESTED_WITH server header has been
set, and returns a boolean response.
$this->input->is_cli_request()
-================================
+==============================
Checks to see if the STDIN constant is set, which is a failsafe way to
see if PHP is being run on the command line.
@@ -278,8 +307,8 @@ see if PHP is being run on the command line.
$this->input->is_cli_request()
-$this->input->method();
-=====================================
+$this->input->method()
+======================
Returns the $_SERVER['REQUEST_METHOD'], optional set uppercase or lowercase (default lowercase).
@@ -287,4 +316,4 @@ Returns the $_SERVER['REQUEST_METHOD'], optional set uppercase or lowercase (def
echo $this->input->method(TRUE); // Outputs: POST
echo $this->input->method(FALSE); // Outputs: post
- echo $this->input->method(); // Outputs: post
+ echo $this->input->method(); // Outputs: post \ No newline at end of file
diff --git a/user_guide_src/source/libraries/sessions.rst b/user_guide_src/source/libraries/sessions.rst
index dd9e8cbb4..ee7fb0b1c 100644
--- a/user_guide_src/source/libraries/sessions.rst
+++ b/user_guide_src/source/libraries/sessions.rst
@@ -388,7 +388,7 @@ session class::
user_agent varchar(120) NOT NULL,
last_activity int(10) unsigned DEFAULT 0 NOT NULL,
user_data text NOT NULL,
- PRIMARY KEY (session_id),
+ PRIMARY KEY (session_id, ip_address, user_agent),
KEY `last_activity_idx` (`last_activity`)
);
diff --git a/user_guide_src/source/libraries/unit_testing.rst b/user_guide_src/source/libraries/unit_testing.rst
index 03819b27c..6bd91bf88 100644
--- a/user_guide_src/source/libraries/unit_testing.rst
+++ b/user_guide_src/source/libraries/unit_testing.rst
@@ -131,7 +131,7 @@ default:
- Any notes you entered for the test (notes)
You can customize which of these items get displayed by using
-$this->unit->set_items(). For example, if you only wanted the test name
+$this->unit->set_test_items(). For example, if you only wanted the test name
and the result displayed:
Customizing displayed tests