summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--application/config/mimes.php10
-rw-r--r--system/core/Common.php4
-rw-r--r--system/core/Hooks.php5
-rw-r--r--system/core/Loader.php142
-rw-r--r--system/core/Log.php2
-rw-r--r--system/core/Router.php9
-rw-r--r--system/core/Security.php10
-rw-r--r--system/database/DB_query_builder.php2
-rw-r--r--system/database/drivers/mssql/mssql_result.php1
-rw-r--r--system/database/drivers/mysql/mysql_result.php1
-rw-r--r--system/database/drivers/mysqli/mysqli_result.php1
-rw-r--r--system/helpers/captcha_helper.php6
-rw-r--r--system/helpers/download_helper.php2
-rw-r--r--system/helpers/html_helper.php20
-rw-r--r--system/helpers/smiley_helper.php28
-rw-r--r--system/helpers/text_helper.php22
-rw-r--r--system/helpers/url_helper.php19
-rw-r--r--system/language/english/form_validation_lang.php1
-rw-r--r--system/libraries/Driver.php19
-rw-r--r--system/libraries/Form_validation.php13
-rw-r--r--system/libraries/Javascript.php2
-rw-r--r--system/libraries/Javascript/Jquery.php (renamed from system/libraries/javascript/Jquery.php)0
-rw-r--r--system/libraries/Javascript/index.html (renamed from system/libraries/javascript/index.html)0
-rw-r--r--system/libraries/Migration.php4
-rw-r--r--system/libraries/Session/drivers/Session_cookie.php2
-rw-r--r--system/libraries/Upload.php43
-rw-r--r--system/libraries/User_agent.php13
-rw-r--r--tests/codeigniter/core/Loader_test.php18
-rw-r--r--tests/codeigniter/helpers/url_helper_test.php11
-rw-r--r--tests/codeigniter/libraries/Upload_test.php6
-rw-r--r--user_guide_src/source/changelog.rst16
-rw-r--r--user_guide_src/source/general/routing.rst4
-rw-r--r--user_guide_src/source/installation/upgrade_300.rst34
-rw-r--r--user_guide_src/source/libraries/form_validation.rst4
-rw-r--r--user_guide_src/source/libraries/loader.rst146
-rw-r--r--user_guide_src/source/tutorial/news_section.rst4
36 files changed, 323 insertions, 301 deletions
diff --git a/application/config/mimes.php b/application/config/mimes.php
index dfa9f24e4..0129c3ca1 100644
--- a/application/config/mimes.php
+++ b/application/config/mimes.php
@@ -44,13 +44,13 @@ return array(
'lzh' => 'application/octet-stream',
'exe' => array('application/octet-stream', 'application/x-msdownload'),
'class' => 'application/octet-stream',
- 'psd' => 'application/x-photoshop',
+ 'psd' => array('application/x-photoshop', 'image/vnd.adobe.photoshop'),
'so' => 'application/octet-stream',
'sea' => 'application/octet-stream',
'dll' => 'application/octet-stream',
'oda' => 'application/oda',
'pdf' => array('application/pdf', 'application/x-download', 'binary/octet-stream'),
- 'ai' => 'application/postscript',
+ 'ai' => array('application/pdf', 'application/postscript'),
'eps' => 'application/postscript',
'ps' => 'application/postscript',
'smi' => 'application/smil',
@@ -123,7 +123,7 @@ return array(
'avi' => array('video/x-msvideo', 'video/msvideo', 'video/avi', 'application/x-troff-msvideo'),
'movie' => 'video/x-sgi-movie',
'doc' => array('application/msword', 'application/vnd.ms-office'),
- 'docx' => array('application/vnd.openxmlformats-officedocument.wordprocessingml.document', 'application/zip', 'application/msword'),
+ 'docx' => array('application/vnd.openxmlformats-officedocument.wordprocessingml.document', 'application/zip', 'application/msword', 'application/x-zip'),
'dot' => array('application/msword', 'application/vnd.ms-office'),
'dotx' => array('application/vnd.openxmlformats-officedocument.wordprocessingml.document', 'application/zip', 'application/msword'),
'xlsx' => array('application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', 'application/zip', 'application/vnd.ms-excel', 'application/msword'),
@@ -160,7 +160,7 @@ return array(
'm3u' => 'text/plain',
'xspf' => 'application/xspf+xml',
'vlc' => 'application/videolan',
- 'wmv' => 'video/x-ms-wmv',
+ 'wmv' => array('video/x-ms-wmv', 'video/x-ms-asf'),
'au' => 'audio/x-au',
'ac3' => 'audio/ac3',
'flac' => 'audio/x-flac',
@@ -176,4 +176,4 @@ return array(
);
/* End of file mimes.php */
-/* Location: ./application/config/mimes.php */ \ No newline at end of file
+/* Location: ./application/config/mimes.php */
diff --git a/system/core/Common.php b/system/core/Common.php
index 90cc5b3a4..258cd4967 100644
--- a/system/core/Common.php
+++ b/system/core/Common.php
@@ -316,11 +316,11 @@ if ( ! function_exists('get_mimes'))
{
static $_mimes = array();
- if (is_file(APPPATH.'config/'.ENVIRONMENT.'/mimes.php'))
+ if (file_exists(APPPATH.'config/'.ENVIRONMENT.'/mimes.php'))
{
$_mimes = include(APPPATH.'config/'.ENVIRONMENT.'/mimes.php');
}
- elseif (is_file(APPPATH.'config/mimes.php'))
+ elseif (file_exists(APPPATH.'config/mimes.php'))
{
$_mimes = include(APPPATH.'config/mimes.php');
}
diff --git a/system/core/Hooks.php b/system/core/Hooks.php
index 59759e02e..17f6a027e 100644
--- a/system/core/Hooks.php
+++ b/system/core/Hooks.php
@@ -81,11 +81,12 @@ class CI_Hooks {
}
// Grab the "hooks" definition file.
- if (is_file(APPPATH.'config/'.ENVIRONMENT.'/hooks.php'))
+ if (file_exists(APPPATH.'config/'.ENVIRONMENT.'/hooks.php'))
{
include(APPPATH.'config/'.ENVIRONMENT.'/hooks.php');
}
- elseif (is_file(APPPATH.'config/hooks.php'))
+
+ if (file_exists(APPPATH.'config/hooks.php'))
{
include(APPPATH.'config/hooks.php');
}
diff --git a/system/core/Loader.php b/system/core/Loader.php
index bbd7a84b6..00ca35199 100644
--- a/system/core/Loader.php
+++ b/system/core/Loader.php
@@ -97,13 +97,6 @@ class CI_Loader {
protected $_ci_classes = array();
/**
- * List of loaded files
- *
- * @var array
- */
- protected $_ci_loaded_files = array();
-
- /**
* List of loaded models
*
* @var array
@@ -943,7 +936,6 @@ class CI_Loader {
// Was the path included with the class name?
// We look for a slash to determine this
- $subdir = '';
if (($last_slash = strrpos($class, '/')) !== FALSE)
{
// Extract the path
@@ -952,108 +944,92 @@ class CI_Loader {
// Get the filename from the path
$class = substr($class, $last_slash);
}
+ else
+ {
+ $subdir = '';
+ }
+
+ $class = ucfirst($class);
+ $subclass = APPPATH.'libraries/'.$subdir.config_item('subclass_prefix').$class.'.php';
- // We'll test for both lowercase and capitalized versions of the file name
- foreach (array(ucfirst($class), strtolower($class)) as $class)
+ // Is this a class extension request?
+ if (file_exists($subclass))
{
- $subclass = APPPATH.'libraries/'.$subdir.config_item('subclass_prefix').$class.'.php';
+ $baseclass = BASEPATH.'libraries/'.$class.'.php';
- // Is this a class extension request?
- if (file_exists($subclass))
+ if ( ! file_exists($baseclass))
{
- $baseclass = BASEPATH.'libraries/'.ucfirst($class).'.php';
-
- if ( ! file_exists($baseclass))
- {
- log_message('error', 'Unable to load the requested class: '.$class);
- show_error('Unable to load the requested class: '.$class);
- }
+ log_message('error', 'Unable to load the requested class: '.$class);
+ show_error('Unable to load the requested class: '.$class);
+ }
- // Safety: Was the class already loaded by a previous call?
- if (in_array($subclass, $this->_ci_loaded_files))
+ // Safety: Was the class already loaded by a previous call?
+ if (class_exists(config_item('subclass_prefix').$class, FALSE))
+ {
+ // Before we deem this to be a duplicate request, let's see
+ // if a custom object name is being supplied. If so, we'll
+ // return a new instance of the object
+ if ($object_name !== NULL)
{
- // Before we deem this to be a duplicate request, let's see
- // if a custom object name is being supplied. If so, we'll
- // return a new instance of the object
- if ($object_name !== NULL)
+ $CI =& get_instance();
+ if ( ! isset($CI->$object_name))
{
- $CI =& get_instance();
- if ( ! isset($CI->$object_name))
- {
- return $this->_ci_init_class($class, config_item('subclass_prefix'), $params, $object_name);
- }
+ return $this->_ci_init_class($class, config_item('subclass_prefix'), $params, $object_name);
}
-
- $is_duplicate = TRUE;
- log_message('debug', $class.' class already loaded. Second attempt ignored.');
- return;
}
- include_once($baseclass);
- include_once($subclass);
- $this->_ci_loaded_files[] = $subclass;
-
- return $this->_ci_init_class($class, config_item('subclass_prefix'), $params, $object_name);
+ log_message('debug', $class.' class already loaded. Second attempt ignored.');
+ return;
}
- // Lets search for the requested library file and load it.
- $is_duplicate = FALSE;
- foreach ($this->_ci_library_paths as $path)
- {
- $filepath = $path.'libraries/'.$subdir.$class.'.php';
+ include_once($baseclass);
+ include_once($subclass);
- // Does the file exist? No? Bummer...
- if ( ! file_exists($filepath))
- {
- continue;
- }
+ return $this->_ci_init_class($class, config_item('subclass_prefix'), $params, $object_name);
+ }
+
+ // Lets search for the requested library file and load it.
+ foreach ($this->_ci_library_paths as $path)
+ {
+ $filepath = $path.'libraries/'.$subdir.$class.'.php';
- // Safety: Was the class already loaded by a previous call?
- if (in_array($filepath, $this->_ci_loaded_files))
+ // Safety: Was the class already loaded by a previous call?
+ if (class_exists($class, FALSE))
+ {
+ // Before we deem this to be a duplicate request, let's see
+ // if a custom object name is being supplied. If so, we'll
+ // return a new instance of the object
+ if ($object_name !== NULL)
{
- // Before we deem this to be a duplicate request, let's see
- // if a custom object name is being supplied. If so, we'll
- // return a new instance of the object
- if ($object_name !== NULL)
+ $CI =& get_instance();
+ if ( ! isset($CI->$object_name))
{
- $CI =& get_instance();
- if ( ! isset($CI->$object_name))
- {
- return $this->_ci_init_class($class, '', $params, $object_name);
- }
+ return $this->_ci_init_class($class, '', $params, $object_name);
}
-
- $is_duplicate = TRUE;
- log_message('debug', $class.' class already loaded. Second attempt ignored.');
- return;
}
- include_once($filepath);
- $this->_ci_loaded_files[] = $filepath;
- return $this->_ci_init_class($class, '', $params, $object_name);
+ log_message('debug', $class.' class already loaded. Second attempt ignored.');
+ return;
+ }
+ // Does the file exist? No? Bummer...
+ elseif ( ! file_exists($filepath))
+ {
+ continue;
}
- } // END FOREACH
+
+ include_once($filepath);
+ return $this->_ci_init_class($class, '', $params, $object_name);
+ }
// One last attempt. Maybe the library is in a subdirectory, but it wasn't specified?
if ($subdir === '')
{
- $path = strtolower($class).'/'.$class;
- return $this->_ci_load_class($path, $params, $object_name);
- }
- elseif (ucfirst($subdir) != $subdir)
- {
- // Lowercase subdir failed - retry capitalized
- $path = ucfirst($subdir).$class;
- return $this->_ci_load_class($path, $params, $object_name);
+ return $this->_ci_load_class($class.'/'.$class, $params, $object_name);
}
// If we got this far we were unable to find the requested class.
- // We do not issue errors if the load call failed due to a duplicate request
- if ($is_duplicate === FALSE)
- {
- log_message('error', 'Unable to load the requested class: '.$class);
- show_error('Unable to load the requested class: '.$class);
- }
+ log_message('error', 'Unable to load the requested class: '.$class);
+ show_error('Unable to load the requested class: '.$class);
}
// --------------------------------------------------------------------
diff --git a/system/core/Log.php b/system/core/Log.php
index cd3c17e1e..f5d091e14 100644
--- a/system/core/Log.php
+++ b/system/core/Log.php
@@ -179,4 +179,4 @@ class CI_Log {
}
/* End of file Log.php */
-/* Location: ./system/libraries/Log.php */ \ No newline at end of file
+/* Location: ./system/core/Log.php */ \ No newline at end of file
diff --git a/system/core/Router.php b/system/core/Router.php
index 4755b3712..bb0ce16bd 100644
--- a/system/core/Router.php
+++ b/system/core/Router.php
@@ -133,13 +133,14 @@ class CI_Router {
}
// Load the routes.php file.
- if (is_file(APPPATH.'config/'.ENVIRONMENT.'/routes.php'))
+ if (file_exists(APPPATH.'config/routes.php'))
{
- include(APPPATH.'config/'.ENVIRONMENT.'/routes.php');
+ include(APPPATH.'config/routes.php');
}
- elseif (is_file(APPPATH.'config/routes.php'))
+
+ if (file_exists(APPPATH.'config/'.ENVIRONMENT.'/routes.php'))
{
- include(APPPATH.'config/routes.php');
+ include(APPPATH.'config/'.ENVIRONMENT.'/routes.php');
}
$this->routes = (empty($route) OR ! is_array($route)) ? array() : $route;
diff --git a/system/core/Security.php b/system/core/Security.php
index a6cd14a5f..7aae54efc 100644
--- a/system/core/Security.php
+++ b/system/core/Security.php
@@ -576,7 +576,15 @@ class CI_Security {
}
$str = remove_invisible_characters($str, FALSE);
- return stripslashes(str_replace($bad, '', $str));
+
+ do
+ {
+ $old = $str;
+ $str = str_replace($bad, '', $str);
+ }
+ while ($old !== $str);
+
+ return stripslashes($str);
}
// ----------------------------------------------------------------
diff --git a/system/database/DB_query_builder.php b/system/database/DB_query_builder.php
index ac377d996..c7bc4a699 100644
--- a/system/database/DB_query_builder.php
+++ b/system/database/DB_query_builder.php
@@ -937,7 +937,7 @@ abstract class CI_DB_query_builder extends CI_DB_driver {
$this->qb_where[] = array('condition' => $like_statement, 'escape' => $escape);
if ($this->qb_caching === TRUE)
{
- $this->qb_cache_where[] = $like_statement;
+ $this->qb_cache_where[] = array('condition' => $like_statement, 'escape' => $escape);
$this->qb_cache_exists[] = 'where';
}
}
diff --git a/system/database/drivers/mssql/mssql_result.php b/system/database/drivers/mssql/mssql_result.php
index ea3f8e4d1..b6e5f2b17 100644
--- a/system/database/drivers/mssql/mssql_result.php
+++ b/system/database/drivers/mssql/mssql_result.php
@@ -74,6 +74,7 @@ class CI_DB_mssql_result extends CI_DB_result {
public function list_fields()
{
$field_names = array();
+ mssql_field_seek($this->result_id, 0);
while ($field = mssql_fetch_field($this->result_id))
{
$field_names[] = $field->name;
diff --git a/system/database/drivers/mysql/mysql_result.php b/system/database/drivers/mysql/mysql_result.php
index 1ed2759b6..a2affcb58 100644
--- a/system/database/drivers/mysql/mysql_result.php
+++ b/system/database/drivers/mysql/mysql_result.php
@@ -89,6 +89,7 @@ class CI_DB_mysql_result extends CI_DB_result {
public function list_fields()
{
$field_names = array();
+ mysql_field_seek($this->result_id, 0);
while ($field = mysql_fetch_field($this->result_id))
{
$field_names[] = $field->name;
diff --git a/system/database/drivers/mysqli/mysqli_result.php b/system/database/drivers/mysqli/mysqli_result.php
index 4105f99f6..3fe05f9c5 100644
--- a/system/database/drivers/mysqli/mysqli_result.php
+++ b/system/database/drivers/mysqli/mysqli_result.php
@@ -74,6 +74,7 @@ class CI_DB_mysqli_result extends CI_DB_result {
public function list_fields()
{
$field_names = array();
+ $this->result_id->field_seek(0);
while ($field = $this->result_id->fetch_field())
{
$field_names[] = $field->name;
diff --git a/system/helpers/captcha_helper.php b/system/helpers/captcha_helper.php
index 83783324b..78e255a15 100644
--- a/system/helpers/captcha_helper.php
+++ b/system/helpers/captcha_helper.php
@@ -93,7 +93,7 @@ if ( ! function_exists('create_captcha'))
// Do we have a "word" yet?
// -----------------------------------
- if ($word === '')
+ if (empty($word))
{
$pool = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
$word = '';
@@ -102,6 +102,10 @@ if ( ! function_exists('create_captcha'))
$word .= $pool[mt_rand(0, $mt_rand_max)];
}
}
+ elseif ( ! is_string($word))
+ {
+ $word = (string) $word;
+ }
// -----------------------------------
// Determine angle and position
diff --git a/system/helpers/download_helper.php b/system/helpers/download_helper.php
index 7294d50c5..4fe6a0e88 100644
--- a/system/helpers/download_helper.php
+++ b/system/helpers/download_helper.php
@@ -58,7 +58,7 @@ if ( ! function_exists('force_download'))
}
elseif ($data === NULL)
{
- if (@is_file($filename) && @file_exists($filename) && ($filesize = @filesize($filename)) !== FALSE)
+ if (@is_file($filename) && ($filesize = @filesize($filename)) !== FALSE)
{
$filepath = $filename;
$filename = explode('/', str_replace(DIRECTORY_SEPARATOR, '/', $filename));
diff --git a/system/helpers/html_helper.php b/system/helpers/html_helper.php
index 7a71eb82b..80a27876f 100644
--- a/system/helpers/html_helper.php
+++ b/system/helpers/html_helper.php
@@ -238,26 +238,30 @@ if ( ! function_exists('doctype'))
*/
function doctype($type = 'xhtml1-strict')
{
- global $_doctypes;
+ static $doctypes;
- if ( ! is_array($_doctypes))
+ if ( ! is_array($doctypes))
{
- if (is_file(APPPATH.'config/'.ENVIRONMENT.'/doctypes.php'))
+ if (file_exists(APPPATH.'config/doctypes.php'))
{
- include(APPPATH.'config/'.ENVIRONMENT.'/doctypes.php');
+ include(APPPATH.'config/doctypes.php');
}
- elseif (is_file(APPPATH.'config/doctypes.php'))
+
+ if (file_exists(APPPATH.'config/'.ENVIRONMENT.'/doctypes.php'))
{
- include(APPPATH.'config/doctypes.php');
+ include(APPPATH.'config/'.ENVIRONMENT.'/doctypes.php');
}
- if ( ! is_array($_doctypes))
+ if (empty($_doctypes) OR ! is_array($_doctypes))
{
+ $doctypes = array();
return FALSE;
}
+
+ $doctypes = $_doctypes;
}
- return isset($_doctypes[$type]) ? $_doctypes[$type] : FALSE;
+ return isset($doctypes[$type]) ? $doctypes[$type] : FALSE;
}
}
diff --git a/system/helpers/smiley_helper.php b/system/helpers/smiley_helper.php
index c2f50ec73..d9a693493 100644
--- a/system/helpers/smiley_helper.php
+++ b/system/helpers/smiley_helper.php
@@ -213,16 +213,30 @@ if ( ! function_exists('_get_smiley_array'))
*/
function _get_smiley_array()
{
- if (file_exists(APPPATH.'config/'.ENVIRONMENT.'/smileys.php'))
- {
- include(APPPATH.'config/'.ENVIRONMENT.'/smileys.php');
- }
- elseif (file_exists(APPPATH.'config/smileys.php'))
+ static $_smileys;
+
+ if ( ! is_array($smileys))
{
- include(APPPATH.'config/smileys.php');
+ if (file_exists(APPPATH.'config/smileys.php'))
+ {
+ include(APPPATH.'config/smileys.php');
+ }
+
+ if (file_exists(APPPATH.'config/'.ENVIRONMENT.'/smileys.php'))
+ {
+ include(APPPATH.'config/'.ENVIRONMENT.'/smileys.php');
+ }
+
+ if (empty($smileys) OR ! is_array($smileys))
+ {
+ $_smileys = array();
+ return FALSE;
+ }
+
+ $_smileys = $smileys;
}
- return (isset($smileys) && is_array($smileys)) ? $smileys : FALSE;
+ return $_smileys;
}
}
diff --git a/system/helpers/text_helper.php b/system/helpers/text_helper.php
index c255c15a8..54db14f94 100644
--- a/system/helpers/text_helper.php
+++ b/system/helpers/text_helper.php
@@ -358,31 +358,35 @@ if ( ! function_exists('convert_accented_characters'))
/**
* Convert Accented Foreign Characters to ASCII
*
- * @param string the text string
+ * @param string $str Input string
* @return string
*/
function convert_accented_characters($str)
{
- global $foreign_characters;
+ static $_foreign_characters;
- if ( ! isset($foreign_characters) OR ! is_array($foreign_characters))
+ if ( ! is_array($_foreign_characters))
{
- if (is_file(APPPATH.'config/'.ENVIRONMENT.'/foreign_chars.php'))
+ if (file_exists(APPPATH.'config/foreign_chars.php'))
{
- include(APPPATH.'config/'.ENVIRONMENT.'/foreign_chars.php');
+ include(APPPATH.'config/foreign_chars.php');
}
- elseif (is_file(APPPATH.'config/foreign_chars.php'))
+
+ if (file_exists(APPPATH.'config/'.ENVIRONMENT.'/foreign_chars.php'))
{
- include(APPPATH.'config/foreign_chars.php');
+ include(APPPATH.'config/'.ENVIRONMENT.'/foreign_chars.php');
}
- if ( ! isset($foreign_characters) OR ! is_array($foreign_characters))
+ if (empty($foreign_characters) OR ! is_array($foreign_characters))
{
+ $_foreign_characters = array();
return $str;
}
+
+ $_foreign_characters = $foreign_characters;
}
- return preg_replace(array_keys($foreign_characters), array_values($foreign_characters), $str);
+ return preg_replace(array_keys($_foreign_characters), array_values($_foreign_characters), $str);
}
}
diff --git a/system/helpers/url_helper.php b/system/helpers/url_helper.php
index a6536cf81..d0fab3fe0 100644
--- a/system/helpers/url_helper.php
+++ b/system/helpers/url_helper.php
@@ -384,22 +384,23 @@ if ( ! function_exists('auto_link'))
function auto_link($str, $type = 'both', $popup = FALSE)
{
// Find and replace any URLs.
- if ($type !== 'email' && preg_match_all('#\b(([\w-]+://?|www\.)[^\s()<>]+(?:\([\w\d]+\)|([^[:punct:]\s]|/)))#', $str, $matches, PREG_OFFSET_CAPTURE))
+ if ($type !== 'email' && preg_match_all('#(\w*://|www\.)[^\s()<>;]+\w#i', $str, $matches, PREG_OFFSET_CAPTURE | PREG_SET_ORDER))
{
// Set our target HTML if using popup links.
- $target = ($popup) ? 'target="_blank"' : '';
+ $target = ($popup) ? ' target="_blank"' : '';
// We process the links in reverse order (last -> first) so that
// the returned string offsets from preg_match_all() are not
// moved as we add more HTML.
- foreach (array_reverse($matches[0]) as $match)
+ foreach (array_reverse($matches) as $match)
{
- // $match is an array generated by the PREG_OFFSET_CAPTURE flag.
- // $match[0] is the matched string, $match[1] is the string offset.
-
- $anchor = anchor($match[0], '', $target);
-
- $str = substr_replace($str, $anchor, $match[1], strlen($match[0]));
+ // $match[0] is the matched string/link
+ // $match[1] is either a protocol prefix or 'www.'
+ //
+ // With PREG_OFFSET_CAPTURE, both of the above is an array,
+ // where the actual value is held in [0] and its offset at the [1] index.
+ $a = '<a href="'.(strpos($match[1][0], '/') ? '' : 'http://').$match[0][0].'"'.$target.'>'.$match[0][0].'</a>';
+ $str = substr_replace($str, $a, $match[0][1], strlen($match[0][0]));
}
}
diff --git a/system/language/english/form_validation_lang.php b/system/language/english/form_validation_lang.php
index 3fb007dd2..7c0277c25 100644
--- a/system/language/english/form_validation_lang.php
+++ b/system/language/english/form_validation_lang.php
@@ -37,6 +37,7 @@ $lang['form_validation_max_length'] = 'The {field} field cannot exceed {param}
$lang['form_validation_exact_length'] = 'The {field} field must be exactly {param} characters in length.';
$lang['form_validation_alpha'] = 'The {field} field may only contain alphabetical characters.';
$lang['form_validation_alpha_numeric'] = 'The {field} field may only contain alpha-numeric characters.';
+$lang['form_validation_alpha_numeric_spaces'] = 'The {field} field may only contain alpha-numeric characters and spaces.';
$lang['form_validation_alpha_dash'] = 'The {field} field may only contain alpha-numeric characters, underscores, and dashes.';
$lang['form_validation_numeric'] = 'The {field} field must contain only numbers.';
$lang['form_validation_is_numeric'] = 'The {field} field must contain only numeric characters.';
diff --git a/system/libraries/Driver.php b/system/libraries/Driver.php
index 4b35dce73..382420db0 100644
--- a/system/libraries/Driver.php
+++ b/system/libraries/Driver.php
@@ -80,8 +80,7 @@ class CI_Driver_Library {
public function load_driver($child)
{
// Get CodeIgniter instance and subclass prefix
- $CI = get_instance();
- $prefix = (string) $CI->config->item('subclass_prefix');
+ $prefix = config_item('subclass_prefix');
if ( ! isset($this->lib_name))
{
@@ -102,11 +101,12 @@ class CI_Driver_Library {
}
// Get package paths and filename case variations to search
+ $CI = get_instance();
$paths = $CI->load->get_package_paths(TRUE);
// Is there an extension?
$class_name = $prefix.$child_name;
- $found = class_exists($class_name);
+ $found = class_exists($class_name, FALSE);
if ( ! $found)
{
// Check for subclass file
@@ -126,8 +126,8 @@ class CI_Driver_Library {
}
// Include both sources and mark found
- include($basepath);
- include($file);
+ include_once($basepath);
+ include_once($file);
$found = TRUE;
break;
}
@@ -139,8 +139,7 @@ class CI_Driver_Library {
{
// Use standard class name
$class_name = 'CI_'.$child_name;
- $found = class_exists($class_name);
- if ( ! $found)
+ if ( ! class_exists($class_name, FALSE))
{
// Check package paths
foreach ($paths as $path)
@@ -150,7 +149,7 @@ class CI_Driver_Library {
if (file_exists($file))
{
// Include source
- include($file);
+ include_once($file);
break;
}
}
@@ -158,9 +157,9 @@ class CI_Driver_Library {
}
// Did we finally find the class?
- if ( ! class_exists($class_name))
+ if ( ! class_exists($class_name, FALSE))
{
- if (class_exists($child_name))
+ if (class_exists($child_name, FALSE))
{
$class_name = $child_name;
}
diff --git a/system/libraries/Form_validation.php b/system/libraries/Form_validation.php
index bbd0b523e..1511d9add 100644
--- a/system/libraries/Form_validation.php
+++ b/system/libraries/Form_validation.php
@@ -1232,6 +1232,19 @@ class CI_Form_validation {
// --------------------------------------------------------------------
/**
+ * Alpha-numeric w/ spaces
+ *
+ * @param string
+ * @return bool
+ */
+ public function alpha_numeric_spaces($str)
+ {
+ return (bool) preg_match('/^[A-Z0-9 ]+$/i', $str);
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
* Alpha-numeric with underscores and dashes
*
* @param string
diff --git a/system/libraries/Javascript.php b/system/libraries/Javascript.php
index 7f1d85511..773a58384 100644
--- a/system/libraries/Javascript.php
+++ b/system/libraries/Javascript.php
@@ -69,7 +69,7 @@ class CI_Javascript {
$this->CI =& get_instance();
// load the requested js library
- $this->CI->load->library('javascript/'.$js_library_driver, array('autoload' => $autoload));
+ $this->CI->load->library('Javascript/'.$js_library_driver, array('autoload' => $autoload));
// make js to refer to current library
$this->js =& $this->CI->$js_library_driver;
diff --git a/system/libraries/javascript/Jquery.php b/system/libraries/Javascript/Jquery.php
index b6e0434b2..b6e0434b2 100644
--- a/system/libraries/javascript/Jquery.php
+++ b/system/libraries/Javascript/Jquery.php
diff --git a/system/libraries/javascript/index.html b/system/libraries/Javascript/index.html
index c942a79ce..c942a79ce 100644
--- a/system/libraries/javascript/index.html
+++ b/system/libraries/Javascript/index.html
diff --git a/system/libraries/Migration.php b/system/libraries/Migration.php
index fd915c382..b673e9cb7 100644
--- a/system/libraries/Migration.php
+++ b/system/libraries/Migration.php
@@ -104,8 +104,8 @@ class CI_Migration {
*/
public function __construct($config = array())
{
- # Only run this constructor on main library load
- if (get_parent_class($this) !== FALSE)
+ // Only run this constructor on main library load
+ if ( ! in_array(get_class($this), array('CI_Migration', config_item('subclass_prefix').'Migration'), TRUE))
{
return;
}
diff --git a/system/libraries/Session/drivers/Session_cookie.php b/system/libraries/Session/drivers/Session_cookie.php
index 474641642..11bb32fe0 100644
--- a/system/libraries/Session/drivers/Session_cookie.php
+++ b/system/libraries/Session/drivers/Session_cookie.php
@@ -805,7 +805,7 @@ class CI_Session_cookie extends CI_Session_driver {
{
if (is_string($val))
{
- $val= str_replace('{{slash}}', '\\', $val);
+ $val = str_replace('{{slash}}', '\\', $val);
}
}
diff --git a/system/libraries/Upload.php b/system/libraries/Upload.php
index 96bb17edc..814ea68a4 100644
--- a/system/libraries/Upload.php
+++ b/system/libraries/Upload.php
@@ -463,7 +463,8 @@ class CI_Upload {
}
// Sanitize the file name for security
- $this->file_name = $this->clean_file_name($this->file_name);
+ $CI =& get_instance();
+ $this->file_name = $CI->security->sanitize_filename($this->file_name);
// Truncate the file name if it's too long
if ($this->max_filename > 0)
@@ -971,46 +972,6 @@ class CI_Upload {
// --------------------------------------------------------------------
/**
- * Clean the file name for security
- *
- * @param string $filename
- * @return string
- */
- public function clean_file_name($filename)
- {
- $bad = array(
- '<!--', '-->',
- "'", '"',
- '<', '>',
- '&', '$',
- '=',
- ';',
- '?',
- '/',
- '!',
- '#',
- '%20',
- '%22',
- '%3c', // <
- '%253c', // <
- '%3e', // >
- '%0e', // >
- '%28', // (
- '%29', // )
- '%2528', // (
- '%26', // &
- '%24', // $
- '%3f', // ?
- '%3b', // ;
- '%3d' // =
- );
-
- return stripslashes(str_replace($bad, '', $filename));
- }
-
- // --------------------------------------------------------------------
-
- /**
* Limit the File Name Length
*
* @param string $filename
diff --git a/system/libraries/User_agent.php b/system/libraries/User_agent.php
index 3fe2e0519..2f6f81909 100644
--- a/system/libraries/User_agent.php
+++ b/system/libraries/User_agent.php
@@ -175,15 +175,18 @@ class CI_User_agent {
*/
protected function _load_agent_file()
{
- if (is_file(APPPATH.'config/'.ENVIRONMENT.'/user_agents.php'))
+ if (($found = file_exists(APPPATH.'config/user_agents.php')))
{
- include(APPPATH.'config/'.ENVIRONMENT.'/user_agents.php');
+ include(APPPATH.'config/user_agents.php');
}
- elseif (is_file(APPPATH.'config/user_agents.php'))
+
+ if (file_exists(APPPATH.'config/'.ENVIRONMENT.'/user_agents.php'))
{
- include(APPPATH.'config/user_agents.php');
+ include(APPPATH.'config/'.ENVIRONMENT.'/user_agents.php');
+ $found = TRUE;
}
- else
+
+ if ($found !== TRUE)
{
return FALSE;
}
diff --git a/tests/codeigniter/core/Loader_test.php b/tests/codeigniter/core/Loader_test.php
index ecc5ca933..dea01a555 100644
--- a/tests/codeigniter/core/Loader_test.php
+++ b/tests/codeigniter/core/Loader_test.php
@@ -25,7 +25,7 @@ class Loader_test extends CI_TestCase {
// Create library in VFS
$lib = 'unit_test_lib';
$class = 'CI_'.ucfirst($lib);
- $this->ci_vfs_create($lib, '<?php class '.$class.' { }', $this->ci_base_root, 'libraries');
+ $this->ci_vfs_create(ucfirst($lib), '<?php class '.$class.' { }', $this->ci_base_root, 'libraries');
// Test is_loaded fail
$this->assertFalse($this->load->is_loaded($lib));
@@ -48,7 +48,7 @@ class Loader_test extends CI_TestCase {
// Test non-existent class
$this->setExpectedException(
'RuntimeException',
- 'CI Error: Non-existent class: '.$lib
+ 'CI Error: Unable to load the requested class: '.ucfirst($lib)
);
$this->assertNull($this->load->library($lib));
}
@@ -105,7 +105,7 @@ class Loader_test extends CI_TestCase {
$lib = 'unit_test_config_lib';
$class = 'CI_'.ucfirst($lib);
$content = '<?php class '.$class.' { public function __construct($params) { $this->config = $params; } }';
- $this->ci_vfs_create($lib, $content, $this->ci_base_root, 'libraries');
+ $this->ci_vfs_create(ucfirst($lib), $content, $this->ci_base_root, 'libraries');
// Create config file
$cfg = array(
@@ -133,7 +133,7 @@ class Loader_test extends CI_TestCase {
// Create library in VFS
$lib = 'super_test_library';
$class = ucfirst($lib);
- $this->ci_vfs_create($lib, '<?php class '.$class.' { }', $this->ci_app_root, 'libraries');
+ $this->ci_vfs_create(ucfirst($lib), '<?php class '.$class.' { }', $this->ci_app_root, 'libraries');
// Load library
$this->assertNull($this->load->library($lib));
@@ -152,7 +152,7 @@ class Loader_test extends CI_TestCase {
$dir = ucfirst($driver);
$class = 'CI_'.$dir;
$content = '<?php class '.$class.' { } ';
- $this->ci_vfs_create($driver, $content, $this->ci_base_root, 'libraries/'.$dir);
+ $this->ci_vfs_create(ucfirst($driver), $content, $this->ci_base_root, 'libraries/'.$dir);
// Test loading as an array.
$this->assertNull($this->load->driver(array($driver)));
@@ -410,7 +410,7 @@ class Loader_test extends CI_TestCase {
$dir = 'third-party';
$lib = 'unit_test_package';
$class = 'CI_'.ucfirst($lib);
- $this->ci_vfs_create($lib, '<?php class '.$class.' { }', $this->ci_app_root, array($dir, 'libraries'));
+ $this->ci_vfs_create(ucfirst($lib), '<?php class '.$class.' { }', $this->ci_app_root, array($dir, 'libraries'));
// Get paths
$paths = $this->load->get_package_paths(TRUE);
@@ -440,7 +440,7 @@ class Loader_test extends CI_TestCase {
// Test failed load without path
$this->setExpectedException(
'RuntimeException',
- 'CI Error: Unable to load the requested class: '.$lib
+ 'CI Error: Unable to load the requested class: '.ucfirst($lib)
);
$this->load->library($lib);
}
@@ -467,13 +467,13 @@ class Loader_test extends CI_TestCase {
// Create library in VFS
$lib = 'autolib';
$lib_class = 'CI_'.ucfirst($lib);
- $this->ci_vfs_create($lib, '<?php class '.$lib_class.' { }', $this->ci_base_root, 'libraries');
+ $this->ci_vfs_create(ucfirst($lib), '<?php class '.$lib_class.' { }', $this->ci_base_root, 'libraries');
// Create driver in VFS
$drv = 'autodrv';
$subdir = ucfirst($drv);
$drv_class = 'CI_'.$subdir;
- $this->ci_vfs_create($drv, '<?php class '.$drv_class.' { }', $this->ci_base_root, array('libraries', $subdir));
+ $this->ci_vfs_create(ucfirst($drv), '<?php class '.$drv_class.' { }', $this->ci_base_root, array('libraries', $subdir));
// Create model in VFS package path
$dir = 'testdir';
diff --git a/tests/codeigniter/helpers/url_helper_test.php b/tests/codeigniter/helpers/url_helper_test.php
index 5fc364238..24823a634 100644
--- a/tests/codeigniter/helpers/url_helper_test.php
+++ b/tests/codeigniter/helpers/url_helper_test.php
@@ -48,11 +48,12 @@ class Url_helper_test extends CI_TestCase {
public function test_auto_link_url()
{
$strings = array(
- 'www.codeigniter.com test' => '<a href="http://www.codeigniter.com">http://www.codeigniter.com</a> test',
+ 'www.codeigniter.com test' => '<a href="http://www.codeigniter.com">www.codeigniter.com</a> test',
'This is my noreply@codeigniter.com test' => 'This is my noreply@codeigniter.com test',
- '<br />www.google.com' => '<br /><a href="http://www.google.com">http://www.google.com</a>',
- 'Download CodeIgniter at www.codeigniter.com. Period test.' => 'Download CodeIgniter at <a href="http://www.codeigniter.com">http://www.codeigniter.com</a>. Period test.',
- 'Download CodeIgniter at www.codeigniter.com, comma test' => 'Download CodeIgniter at <a href="http://www.codeigniter.com">http://www.codeigniter.com</a>, comma test'
+ '<br />www.google.com' => '<br /><a href="http://www.google.com">www.google.com</a>',
+ 'Download CodeIgniter at www.codeigniter.com. Period test.' => 'Download CodeIgniter at <a href="http://www.codeigniter.com">www.codeigniter.com</a>. Period test.',
+ 'Download CodeIgniter at www.codeigniter.com, comma test' => 'Download CodeIgniter at <a href="http://www.codeigniter.com">www.codeigniter.com</a>, comma test',
+ 'This one: ://codeigniter.com must not break this one: http://codeigniter.com' => 'This one: <a href="://codeigniter.com">://codeigniter.com</a> must not break this one: <a href="http://codeigniter.com">http://codeigniter.com</a>'
);
foreach ($strings as $in => $out)
@@ -66,7 +67,7 @@ class Url_helper_test extends CI_TestCase {
public function test_pull_675()
{
$strings = array(
- '<br />www.google.com' => '<br /><a href="http://www.google.com">http://www.google.com</a>',
+ '<br />www.google.com' => '<br /><a href="http://www.google.com">www.google.com</a>',
);
foreach ($strings as $in => $out)
diff --git a/tests/codeigniter/libraries/Upload_test.php b/tests/codeigniter/libraries/Upload_test.php
index 1bd8f1430..4d9e4a46e 100644
--- a/tests/codeigniter/libraries/Upload_test.php
+++ b/tests/codeigniter/libraries/Upload_test.php
@@ -208,12 +208,6 @@ class Upload_test extends CI_TestCase {
$this->assertEquals('', $this->upload->get_extension('hello'));
}
- function test_clean_file_name()
- {
- $this->assertEquals('hello.txt', $this->upload->clean_file_name('hello.txt'));
- $this->assertEquals('hello.txt', $this->upload->clean_file_name('%253chell>o.txt'));
- }
-
function test_limit_filename_length()
{
$this->assertEquals('hello.txt', $this->upload->limit_filename_length('hello.txt', 10));
diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst
index 8b9ec2539..893c3db61 100644
--- a/user_guide_src/source/changelog.rst
+++ b/user_guide_src/source/changelog.rst
@@ -38,7 +38,6 @@ Release Date: Not Released
- Updated support for php files in mimes.php.
- Updated support for zip files in mimes.php.
- Updated support for csv files in mimes.php.
- - Added some more doctypes.
- Added Romanian, Greek, Vietnamese and Cyrilic characters in *application/config/foreign_characters.php*.
- Changed logger to only chmod when file is first created.
- Removed previously deprecated SHA1 Library.
@@ -74,7 +73,10 @@ Release Date: Not Released
- Added support (auto-detection) for HTTP/1.1 response code 303 in :php:func:`redirect()`.
- Changed :php:func:`redirect()` to only choose the **refresh** method only on IIS servers, instead of all servers on Windows (when **auto** is used).
- Changed :php:func:`anchor()`, :php:func:`anchor_popup()`, and :php:func:`redirect()` to support protocol-relative URLs (e.g. *//ellislab.com/codeigniter*).
- - Added XHTML Basic 1.1 doctype to :doc:`HTML Helper <helpers/html_helper>`.
+ - :doc:`HTML Helper <helpers/html_helper>` changes include:
+ - Added more doctypes.
+ - Changed application and environment config files to be loaded in a cascade-like manner.
+ - The doctypes array is now cached and loaded only once.
- :doc:`Inflector Helper <helpers/inflector_helper>` changes include:
- Changed :php:func:`humanize()` to allow passing an input separator as its second parameter.
- Refactored :php:func:`plural()` and :php:func:`singular()` to avoid double pluralization and support more words.
@@ -88,7 +90,10 @@ Release Date: Not Released
- :doc:`Security Helper <helpers/security_helper>` changes include:
- :php:func:`do_hash()` now uses PHP's native ``hash()`` function (supporting more algorithms) and is deprecated.
- :php:func:`strip_image_tags()` is now an alias for the same method in the :doc:`Security Library <libraries/security>`.
- - Removed previously deprecated helper function ``js_insert_smiley()`` from :doc:`Smiley Helper <helpers/smiley_helper>`.
+ - :doc:`Smiley Helper <helpers/smiley_helper>` changes include:
+ - Removed previously deprecated function ``js_insert_smiley()``.
+ - Changed application and environment config files to be loaded in a cascade-like manner.
+ - The smileys array is now cached and loaded only once.
- :doc:`File Helper <helpers/file_helper>` changes include:
- :php:func:`set_realpath()` can now also handle file paths as opposed to just directories.
- Added an optional paramater to :php:func:`delete_files()` to enable it to skip deleting files such as *.htaccess* and *index.html*.
@@ -210,6 +215,7 @@ Release Date: Not Released
- Added **max_filename_increment** config setting.
- Added an **index** parameter to the ``data()`` method.
- Added the **min_width** and **min_height** options for images.
+ - Removed method ``clean_file_name()`` and its usage in favor of :doc:`Security Library <libraries/security>`'s ``sanitize_filename()``.
- :doc:`Cart library <libraries/cart>` changes include:
- ``insert()`` now auto-increments quantity for an item when inserted twice instead of resetting it, this is the default behaviour of large e-commerce sites.
- *Product Name* strictness can be disabled by switching the ``$product_name_safe`` property to FALSE.
@@ -236,6 +242,7 @@ Release Date: Not Released
- Added rule **valid_url**.
- Added support for named parameters in error messages.
- :doc:`Language <libraries/language>` line keys must now be prefixed with **form_validation_**.
+ - Added rule **alpha_numeric_spaces**.
- Added support for setting :doc:`Table <libraries/table>` class defaults in a config file.
- :doc:`Caching Library <libraries/caching>` changes include:
- Added Wincache driver.
@@ -472,6 +479,9 @@ Bug fixes for 3.0
- Fixed a bug (#113) - :doc:`Form Validation Library <libraries/form_validation>` didn't properly handle empty fields that were specified as an array.
- Fixed a bug (#2061) - :doc:`Routing Class <general/routing>` didn't properly sanitize directory, controller and function triggers with **enable_query_strings** set to TRUE.
- Fixed a bug - SQLSRV didn't support ``escape_like_str()`` or escaping an array of values.
+- Fixed a bug - :doc:`DB result <database/results>` method ``list_fields()`` didn't reset its field pointer for the *mysql*, *mysqli* and *mssql* drivers.
+- Fixed a bug (#73) - :doc:`Security Library <libraries/security>` method ``sanitize_filename()`` could be tricked by an XSS attack.
+- Fixed a bug (#2211) - :doc:`Migration Library <libraries/migration>` extensions couldn't execute ``CI_Migration::__construct()``.
Version 2.1.3
=============
diff --git a/user_guide_src/source/general/routing.rst b/user_guide_src/source/general/routing.rst
index 2a0332088..ed21a6109 100644
--- a/user_guide_src/source/general/routing.rst
+++ b/user_guide_src/source/general/routing.rst
@@ -129,7 +129,7 @@ For those of you who don't know regular expressions and want to learn
more about them, `regular-expressions.info <http://www.regular-expressions.info/>`
might be a good starting point.
-..note:: You can also mix and match wildcards with regular expressions.
+.. note:: You can also mix and match wildcards with regular expressions.
Callbacks
=========
@@ -137,7 +137,7 @@ Callbacks
If you are using PHP >= 5.3 you can use callbacks in place of the normal
routing rules to process the back-references. Example::
- $route['products/([a-z]+)/edit/(\d+)'] = function ($product_type, $id)
+ $route['products/([a-zA-Z]+)/edit/(\d+)'] = function ($product_type, $id)
{
return 'catalog/product_edit/' . strtolower($product_type) . '/' . $id;
};
diff --git a/user_guide_src/source/installation/upgrade_300.rst b/user_guide_src/source/installation/upgrade_300.rst
index 94f6321be..2d125a71a 100644
--- a/user_guide_src/source/installation/upgrade_300.rst
+++ b/user_guide_src/source/installation/upgrade_300.rst
@@ -104,16 +104,40 @@ regular expression::
(.+) // matches ANYTHING
(:any) // matches any character, except for '/'
+*******************************************
+Step 9: Update your librararies' file names
+*******************************************
+
+CodeIgniter 3.0 only allows library file names to be named in a *ucfirst* manner
+(meaning that the first letter of the class name must be a capital). For example,
+if you have the following library file:
+
+ application/libraries/mylibrary.php
+
+... then you'll have to rename it to:
+
+ application/libraries/Mylibrary.php
+
+The same goes for driver libraries and extensions and/or overrides of CodeIgniter's
+own libraries and core classes.
+
+ application/libraries/MY_email.php
+ application/core/MY_log.php
+
+The above files should respectively be renamed to the following:
+
+ application/libraries/MY_Email.php
+ application/core/MY_Log.php
****************************************************************************
-Step 9: Check the calls to Array Helper's element() and elements() functions
+Step 10: Check the calls to Array Helper's element() and elements() functions
****************************************************************************
The default return value of these functions, when the required elements
don't exist, has been changed from FALSE to NULL.
*************************************************************
-Step 10: Update usage of Database Forge's drop_table() method
+Step 11: Update usage of Database Forge's drop_table() method
*************************************************************
Up until now, ``drop_table()`` added an IF EXISTS clause by default or it didn't work
@@ -135,7 +159,7 @@ If your application relies on IF EXISTS, you'll have to change its usage.
all drivers with the exception of ODBC.
***********************************************************
-Step 11: Change usage of Email library with multiple emails
+Step 12: Change usage of Email library with multiple emails
***********************************************************
The :doc:`Email Library <../libraries/email>` will automatically clear the
@@ -150,7 +174,7 @@ pass FALSE as the first parameter in the ``send()`` method:
}
***************************************************
-Step 12: Update your Form_validation language lines
+Step 13: Update your Form_validation language lines
***************************************************
Two improvements have been made to the :doc:`Form Validation Library
@@ -181,7 +205,7 @@ files and error messages format:
later.
****************************************************************
-Step 13: Remove usage of (previously) deprecated functionalities
+Step 14: Remove usage of (previously) deprecated functionalities
****************************************************************
In addition to the ``$autoload['core']`` configuration setting, there's a
diff --git a/user_guide_src/source/libraries/form_validation.rst b/user_guide_src/source/libraries/form_validation.rst
index ae7859aa3..8b35fdc75 100644
--- a/user_guide_src/source/libraries/form_validation.rst
+++ b/user_guide_src/source/libraries/form_validation.rst
@@ -877,7 +877,9 @@ Rule Parameter Description
**less_than_equal_to** Yes Returns FALSE if the form element is greater than the parameter value, less_than_equal_to[8]
or not numeric.
**alpha** No Returns FALSE if the form element contains anything other than alphabetical characters.
-**alpha_numeric** No Returns FALSE if the form element contains anything other than alpha-numeric characters.
+**alpha_numeric** No Returns FALSE if the form element contains anything other than alpha-numeric characters.
+**alpha_numeric_spaces** No Returns FALSE if the form element contains anything other than alpha-numeric characters
+ or spaces. Should be used after trim to avoid spaces at the beginning or end.
**alpha_dash** No Returns FALSE if the form element contains anything other than alpha-numeric characters,
underscores or dashes.
**numeric** No Returns FALSE if the form element contains anything other than numeric characters.
diff --git a/user_guide_src/source/libraries/loader.rst b/user_guide_src/source/libraries/loader.rst
index 615aba1c2..b048f4881 100644
--- a/user_guide_src/source/libraries/loader.rst
+++ b/user_guide_src/source/libraries/loader.rst
@@ -11,14 +11,15 @@ can be libraries (classes) :doc:`View files <../general/views>`,
.. note:: This class is initialized automatically by the system so there
is no need to do it manually.
-The following functions are available in this class:
+The following methods are available in this class:
$this->load->library('class_name', $config, 'object name')
-===========================================================
+==========================================================
-This function is used to load core classes. Where class_name is the
-name of the class you want to load. Note: We use the terms "class" and
-"library" interchangeably.
+This method is used to load core classes. Where class_name is the
+name of the class you want to load.
+
+.. note:: We use the terms "class" and "library" interchangeably.
For example, if you would like to send email with CodeIgniter, the first
step is to load the email class within your controller::
@@ -26,15 +27,15 @@ step is to load the email class within your controller::
$this->load->library('email');
Once loaded, the library will be ready for use, using
-$this->email->*some_function*().
+$this->email->*some_method*().
Library files can be stored in subdirectories within the main
-"libraries" folder, or within your personal application/libraries
-folder. To load a file located in a subdirectory, simply include the
-path, relative to the "libraries" folder. For example, if you have file
-located at::
+"libraries" directory, or within your personal application/libraries
+directory. To load a file located in a subdirectory, simply include the
+path, relative to the "libraries" directory. For example, if you have
+file located at::
- libraries/flavors/chocolate.php
+ libraries/flavors/Chocolate.php
You will load it using::
@@ -43,7 +44,7 @@ You will load it using::
You may nest the file in as many subdirectories as you want.
Additionally, multiple libraries can be loaded at the same time by
-passing an array of libraries to the load function.
+passing an array of libraries to the load method.
::
@@ -56,10 +57,10 @@ The second (optional) parameter allows you to optionally pass
configuration setting. You will typically pass these as an array::
$config = array (
- 'mailtype' => 'html',
- 'charset' => 'utf-8,
- 'priority' => '1'
- );
+ 'mailtype' => 'html',
+ 'charset' => 'utf-8,
+ 'priority' => '1'
+ );
$this->load->library('email', $config);
@@ -84,16 +85,15 @@ third parameter::
$this->load->library('calendar', '', 'my_calendar');
// Calendar class is now accessed using:
-
$this->my_calendar
Please take note, when multiple libraries are supplied in an array for
the first parameter, this parameter is discarded.
$this->load->driver('parent_name', $config, 'object name')
-===========================================================
+==========================================================
-This function is used to load driver libraries. Where parent_name is the
+This method is used to load driver libraries. Where parent_name is the
name of the parent class you want to load.
As an example, if you would like to use sessions with CodeIgniter, the first
@@ -102,15 +102,15 @@ step is to load the session driver within your controller::
$this->load->driver('session');
Once loaded, the library will be ready for use, using
-$this->session->*some_function*().
+$this->session->*some_method*().
Driver files must be stored in a subdirectory within the main
-"libraries" folder, or within your personal application/libraries
-folder. The subdirectory must match the parent class name. Read the
+"libraries" directory, or within your personal application/libraries
+directory. The subdirectory must match the parent class name. Read the
:doc:`Drivers <../general/drivers>` description for details.
Additionally, multiple driver libraries can be loaded at the same time by
-passing an array of drivers to the load function.
+passing an array of drivers to the load method.
::
@@ -122,11 +122,11 @@ Setting options
The second (optional) parameter allows you to optionally pass
configuration settings. You will typically pass these as an array::
- $config = array (
- 'sess_driver' => 'cookie',
- 'sess_encrypt_cookie' => true,
- 'encryption_key' => 'mysecretkey'
- );
+ $config = array(
+ 'sess_driver' => 'cookie',
+ 'sess_encrypt_cookie' => true,
+ 'encryption_key' => 'mysecretkey'
+ );
$this->load->driver('session', $config);
@@ -135,12 +135,12 @@ is explained in detail in its own page, so please read the information
regarding each one you would like to use.
Assigning a Driver to a different object name
-----------------------------------------------
+---------------------------------------------
If the third (optional) parameter is blank, the library will be assigned
to an object with the same name as the parent class. For example, if
the library is named Session, it will be assigned to a variable named
-$this->session.
+``$this->session``.
If you prefer to set your own class names you can pass its value to the
third parameter::
@@ -148,32 +148,33 @@ third parameter::
$this->load->library('session', '', 'my_session');
// Session class is now accessed using:
-
$this->my_session
-.. note:: Driver libraries may also be loaded with the library() method,
- but it is faster to use driver()
+.. note:: Driver libraries may also be loaded with the ``library()`` method,
+ but it is faster to use ``driver()``.
-$this->load->view('file_name', $data, true/false)
-==================================================
+$this->load->view('file_name', $data, TRUE/FALSE)
+=================================================
-This function is used to load your View files. If you haven't read the
+This method is used to load your View files. If you haven't read the
:doc:`Views <../general/views>` section of the user guide it is
-recommended that you do since it shows you how this function is
+recommended that you do since it shows you how this method is
typically used.
The first parameter is required. It is the name of the view file you
-would like to load. Note: The .php file extension does not need to be
-specified unless you use something other than .php.
+would like to load.
+
+.. note:: The .php file extension does not need to be specified unless
+ you use something other than .php.
The second **optional** parameter can take an associative array or an
object as input, which it runs through the PHP
-`extract <http://www.php.net/extract>`_ function to convert to variables
+`extract() <http://www.php.net/extract>`_ function to convert to variables
that can be used in your view files. Again, read the
:doc:`Views <../general/views>` page to learn how this might be useful.
The third **optional** parameter lets you change the behavior of the
-function so that it returns data as a string rather than sending it to
+method so that it returns data as a string rather than sending it to
your browser. This can be useful if you want to process the data in some
way. If you set the parameter to true (boolean) it will return data. The
default behavior is false, which sends it to your browser. Remember to
@@ -189,79 +190,76 @@ $this->load->model('model_name');
$this->load->model('model_name');
-If your model is located in a sub-folder, include the relative path from
-your models folder. For example, if you have a model located at
+If your model is located in a subdirectory, include the relative path
+from your models directory. For example, if you have a model located at
application/models/blog/queries.php you'll load it using::
$this->load->model('blog/queries');
-
If you would like your model assigned to a different object name you can
-specify it via the second parameter of the loading function::
+specify it via the second parameter of the loading method::
$this->load->model('model_name', 'fubar');
+ $this->fubar->method();
- $this->fubar->function();
-
-$this->load->database('options', true/false)
+$this->load->database('options', TRUE/FALSE)
============================================
-This function lets you load the database class. The two parameters are
+This method lets you load the database class. The two parameters are
**optional**. Please see the :doc:`database <../database/index>`
section for more info.
$this->load->vars($array)
=========================
-This function takes an associative array as input and generates
+This method takes an associative array as input and generates
variables using the PHP `extract <http://www.php.net/extract>`_
-function. This function produces the same result as using the second
-parameter of the $this->load->view() function above. The reason you
-might want to use this function independently is if you would like to
+method. This method produces the same result as using the second
+parameter of the ``$this->load->view()`` method above. The reason you
+might want to use this method independently is if you would like to
set some global variables in the constructor of your controller and have
-them become available in any view file loaded from any function. You can
-have multiple calls to this function. The data get cached and merged
+them become available in any view file loaded from any method. You can
+have multiple calls to this method. The data get cached and merged
into one array for conversion to variables.
$this->load->get_var($key)
-===========================
+==========================
-This function checks the associative array of variables available to
+This method checks the associative array of variables available to
your views. This is useful if for any reason a var is set in a library
-or another controller method using $this->load->vars().
+or another controller method using ``$this->load->vars()``.
$this->load->get_vars()
-===========================
+=======================
-This function retrieves all variables available to
-your views.
+This method retrieves all variables available to your views.
$this->load->helper('file_name')
-=================================
+================================
-This function loads helper files, where file_name is the name of the
+This method loads helper files, where file_name is the name of the
file, without the _helper.php extension.
-$this->load->file('filepath/filename', true/false)
+$this->load->file('filepath/filename', TRUE/FALSE)
==================================================
-This is a generic file loading function. Supply the filepath and name in
+This is a generic file loading method. Supply the filepath and name in
the first parameter and it will open and read the file. By default the
data is sent to your browser, just like a View file, but if you set the
second parameter to true (boolean) it will instead return the data as a
string.
$this->load->language('file_name')
-===================================
+==================================
-This function is an alias of the :doc:`language loading
-function <language>`: $this->lang->load()
+This method is an alias of the :doc:`language loading
+method <language>`: ``$this->lang->load()``
$this->load->config('file_name')
-=================================
+================================
-This function is an alias of the :doc:`config file loading
-function <config>`: $this->config->load()
+This method is an alias of the :doc:`config file loading
+method <config>`: ``$this->config->load()``
Application "Packages"
======================
@@ -269,7 +267,7 @@ Application "Packages"
An application package allows for the easy distribution of complete sets
of resources in a single directory, complete with its own libraries,
models, helpers, config, and language files. It is recommended that
-these packages be placed in the application/third_party folder. Below
+these packages be placed in the application/third_party directory. Below
is a sample map of an package directory
Sample Package "Foo Bar" Directory Map
@@ -311,7 +309,7 @@ $this->load->remove_package_path()
When your controller is finished using resources from an application
package, and particularly if you have other application packages you
want to work with, you may wish to remove the package path so the Loader
-no longer looks in that folder for resources. To remove the last path
+no longer looks in that directory for resources. To remove the last path
added, simply call the method with no parameters.
$this->load->remove_package_path()
@@ -346,4 +344,4 @@ calling add_package_path().
// Again without the second parameter:
$this->load->add_package_path(APPPATH.'my_app');
$this->load->view('my_app_index'); // Loads
- $this->load->view('welcome_message'); // Loads
+ $this->load->view('welcome_message'); // Loads \ No newline at end of file
diff --git a/user_guide_src/source/tutorial/news_section.rst b/user_guide_src/source/tutorial/news_section.rst
index b64ea2aae..833e34ead 100644
--- a/user_guide_src/source/tutorial/news_section.rst
+++ b/user_guide_src/source/tutorial/news_section.rst
@@ -68,7 +68,7 @@ following code to your model.
$query = $this->db->get('news');
return $query->result_array();
}
-
+
$query = $this->db->get_where('news', array('slug' => $slug));
return $query->row_array();
}
@@ -146,7 +146,7 @@ and add the next piece of code.
<?php foreach ($news as $news_item): ?>
<h2><?php echo $news_item['title'] ?></h2>
- <div id="main">
+ <div class="main">
<?php echo $news_item['text'] ?>
</div>
<p><a href="<?php echo $news_item['slug'] ?>">View article</a></p>