diff options
author | admin <devnull@localhost> | 2006-09-21 07:36:15 +0200 |
---|---|---|
committer | admin <devnull@localhost> | 2006-09-21 07:36:15 +0200 |
commit | 885b0343036695ad673fc24ba7682fc155c54036 (patch) | |
tree | 648e3d80b6082c905cc291e0bb1d033f57bf06ba | |
parent | cfc1fb38f0d7cd49c735730a603f7ca5a98a664d (diff) |
-rw-r--r-- | system/drivers/DB_active_record.php | 2 | ||||
-rw-r--r-- | system/helpers/cookie_helper.php | 49 | ||||
-rw-r--r-- | system/libraries/Validation.php | 2 | ||||
-rw-r--r-- | user_guide/general/changelog.html | 3 | ||||
-rw-r--r-- | user_guide/helpers/cookie_helper.html | 26 | ||||
-rw-r--r-- | user_guide/libraries/database/active_record.html | 2 |
6 files changed, 80 insertions, 4 deletions
diff --git a/system/drivers/DB_active_record.php b/system/drivers/DB_active_record.php index c7e4f096c..af12d9d27 100644 --- a/system/drivers/DB_active_record.php +++ b/system/drivers/DB_active_record.php @@ -390,7 +390,7 @@ class CI_DB_active_record extends CI_DB_driver { { if (trim($direction) != '') { - $direction = (in_array(strtoupper(trim($direction)), array('ASC', 'DESC'))) ? ' '.$direction : ' ASC'; + $direction = (in_array(strtoupper(trim($direction)), array('ASC', 'DESC', 'RAND()'))) ? ' '.$direction : ' ASC'; } $this->ar_orderby[] = $orderby.$direction; diff --git a/system/helpers/cookie_helper.php b/system/helpers/cookie_helper.php index 24e243ddd..fc5920f25 100644 --- a/system/helpers/cookie_helper.php +++ b/system/helpers/cookie_helper.php @@ -55,6 +55,22 @@ function set_cookie($name = '', $value = '', $expire = '', $domain = '', $path = } } + // Set the config file options + $obj =& get_instance(); + + if ($prefix == '' AND $obj->config->item('cookie_prefix') != '') + { + $obj->config->item('cookie_prefix'); + } + if ($domain == '' AND $obj->config->item('cookie_domain') != '') + { + $obj->config->item('cookie_domain'); + } + if ($prefix == '/' AND $obj->config->item('cookie_path') != '/') + { + $obj->config->item('cookie_path'); + } + if ( ! is_numeric($expire)) { $expire = time() - 86500; @@ -73,5 +89,38 @@ function set_cookie($name = '', $value = '', $expire = '', $domain = '', $path = setcookie($prefix.$name, $value, $expire, $path, $domain, 0); } + +// -------------------------------------------------------------------- + +/** + * Fetch an item from the COOKIE array + * + * @access public + * @param string + * @param bool + * @return mixed + */ +function get_cookie($index = '', $xss_clean = FALSE) +{ + $obj =& get_instance(); + return $obj->input->cookie($index, $xss_clean); +} + +// -------------------------------------------------------------------- + +/** + * Delete a COOKIE + * + * @param mixed + * @param string the cookie domain. Usually: .yourdomain.com + * @param string the cookie path + * @param string the cookie prefix + * @return void + */ +function delete_cookie($name = '', $domain = '', $path = '/', $prefix = '') +{ + set_cookie($name, '', '', $domain, $path, $prefix); +} + ?>
\ No newline at end of file diff --git a/system/libraries/Validation.php b/system/libraries/Validation.php index 065e7a2d5..f9b51d778 100644 --- a/system/libraries/Validation.php +++ b/system/libraries/Validation.php @@ -524,7 +524,7 @@ class CI_Validation { */ function numeric($str) { - return ( ! is_numeric($str)) ? FALSE : TRUE; + return ( ! ereg("^[0-9]+$", $str)) ? FALSE : TRUE; } // -------------------------------------------------------------------- diff --git a/user_guide/general/changelog.html b/user_guide/general/changelog.html index ca04b140c..80ffe7a4e 100644 --- a/user_guide/general/changelog.html +++ b/user_guide/general/changelog.html @@ -71,10 +71,13 @@ Change Log <li>Added <a href="../helpers/inflector_helper.html">Inflector helper</a>.</li>
<li>Added element() function in the <a href="../helpers/array_helper.html">array helper</a>.</li>
<li>Added <a href="../libraries/output.html">$this->output->set_header()</a> function, which allows you to set server headers.</li>
+<li>Added RAND() to active record orderby() function.</li>
+<li>Added <dfn>delete_cookie()</dfn> and <dfn>get_cookie()</dfn> to <a href="../helpers/cookie_helper.html">Cookie helper</a>, even though the input class has a cookie fetching function.</li>
<li>Removed the is_numeric test from the db->escape() function.</li>
<li>Fixed a MySQLi bug that was causing error messages not to contain proper errror data.</li>
<li>Fixed a bug in the email class which was causing it to ignore explicitly set alternative headers.</li>
<li>Fixed a bug that was causing a PHP error when the Exceptions class was called within the _get_config() function.</li>
+<li>Fixed an oversight in the cookie helper in which the config file cookie settings were not being honored.</li>
<li>Added some code to allow email attachments to be reset when sending batches of email.</li>
<li>Deprecated the following database functions: $this->db->smart_escape_str() and $this->db->fields().</li>
</ul>
diff --git a/user_guide/helpers/cookie_helper.html b/user_guide/helpers/cookie_helper.html index 3e89df74d..9c17cdd5c 100644 --- a/user_guide/helpers/cookie_helper.html +++ b/user_guide/helpers/cookie_helper.html @@ -76,7 +76,7 @@ Cookie Helper <h2>set_cookie()</h2>
<p>Sets a cookie containing the values you specify. There are two ways to pass information this function so that a cookie can be set:
-Arrray Method, and Discreet Parameters:</p>
+Array Method, and Discreet Parameters:</p>
<h4>Array Method</h4>
@@ -112,6 +112,30 @@ zero the cookie will only last as long as the browser is open.</p> <code>set_cookie($name, $value, $expire, $domain, $path, $prefix);</code>
+<h2>get_cookie()</h2>
+
+<p>Lets you fetch a cookie. The first parameter will contain the name of the cookie you are looking for:</p>
+
+<code>get_cookie('some_cookie');</code>
+
+<p>The function returns FALSE (boolean) if the item you are attempting to retrieve does not exist.</p>
+
+<p>The second optional parameter lets you run the data through the XSS filter. It's enabled by setting the second parameter to boolean TRUE;</p>
+
+<code>get_cookie('some_cookie', TRUE);</code>
+
+
+
+<h2>delete_cookie()</h2>
+
+<p>Lets you delete a cookie. Unless you've set a custom path or other values, only the name of the cookie is needed:</p>
+
+<code>delete_cookie("name");</code>
+
+<p>This function is otherwise identical to <dfn>set_cookie()</dfn>, except that it does not have the value and expiration parameters. You can submit an array
+of values in the first parameter or you can set discreet parameters.</p>
+
+<code>delete_cookie($name, $domain, $path, $prefix)</code>
</div>
diff --git a/user_guide/libraries/database/active_record.html b/user_guide/libraries/database/active_record.html index 793f41f1e..b45c5d14e 100644 --- a/user_guide/libraries/database/active_record.html +++ b/user_guide/libraries/database/active_record.html @@ -354,7 +354,7 @@ $this->db->orlike('body', $match); <h2>$this->db->orderby();</h2>
<p>Lets you set an ORDER BY clause. The first parameter contains the name of the column you would like to order by.
-The second parameter lets you set the direction of the result. Options are <kbd>asc</kbd> or <kbd>desc</kbd></p>
+The second parameter lets you set the direction of the result. Options are <kbd>asc</kbd> or <kbd>desc</kbd> or <kbd>RAND()</kbd></p>
<code>$this->db->orderby("title", "desc");
<br /><br />// Produces: ORDER BY title DESC
|