Commits

Steve Holsinger  committed 9339bc5 Merge

Merged branch with Tip from default branch.

  • Participants
  • Parent commits 4c03c0e, f95358c
  • Branches sholsinger-Form_validation

Comments (0)

Files changed (15)

File application/config/config.php

 |--------------------------------------------------------------------------
 |
 | Leave this BLANK unless you would like to set something other than the default
-| system/logs/ folder.  Use a full server path with trailing slash.
+| application/logs/ folder. Use a full server path with trailing slash.
 |
 */
 $config['log_path'] = '';
 | Enables a CSRF cookie token to be set. When set to TRUE, token will be
 | checked on a submitted form. If you are accepting user data, it is strongly
 | recommended CSRF protection be enabled.
+|
+| 'csrf_token_name' = The token name
+| 'csrf_cookie_name' = The cookie name
+| 'csrf_expire' = The number in seconds the token should expire.
 */
 $config['csrf_protection'] = FALSE;
-
+$config['csrf_token_name'] = 'csrf_test_name';
+$config['csrf_cookie_name'] = 'csrf_cookie_name';
+$config['csrf_expire'] = 7200;
 
 /*
 |--------------------------------------------------------------------------

File application/config/foreign_chars.php

 | conversion used by the Text helper
 |
 */
-$foreign_characters = array('223'	=>	"ss", // ß
-							'224'	=>	"a",
-							'225'	=>	"a",
-							'226'	=>	"a",
-							'229'	=>	"a",
-							'227'	=>	"ae",
-							'230'	=>	"ae",
-							'228'	=>	"ae",
-							'231'	=>	"c",
-							'232'	=>	"e",  // è
-							'233'	=>	"e",  // é
-							'234'	=>	"e",  // ê
-							'235'	=>	"e",  // ë
-							'236'	=>	"i",
-							'237'	=>	"i",
-							'238'	=>	"i",
-							'239'	=>	"i",
-							'241'	=>	"n",
-							'242'	=>	"o",
-							'243'	=>	"o",
-							'244'	=>	"o",
-							'245'	=>	"o",
-							'246'	=>	"oe", // ö
-							'249'	=>	"u",
-							'250'	=>	"u",
-							'251'	=>	"u",
-							'252'	=>	"ue", // ü
-							'255'	=>	"y",
-							'257'	=>	"aa",
-							'269'	=>	"ch",
-							'275'	=>	"ee",
-							'291'	=>	"gj",
-							'299'	=>	"ii",
-							'311'	=>	"kj",
-							'316'	=>	"lj",
-							'326'	=>	"nj",
-							'353'	=>	"sh",
-							'363'	=>	"uu",
-							'382'	=>	"zh",
-							'256'	=>	"aa",
-							'268'	=>	"ch",
-							'274'	=>	"ee",
-							'290'	=>	"gj",
-							'298'	=>	"ii",
-							'310'	=>	"kj",
-							'315'	=>	"lj",
-							'325'	=>	"nj",
-							'352'	=>	"sh",
-							'362'	=>	"uu",
-							'381'	=>	"zh",
-							);
-
+$foreign_characters = array(
+	'/ä|æ|ǽ/' => 'ae',
+	'/ö|œ/' => 'oe',
+	'/ü/' => 'ue',
+	'/Ä/' => 'Ae',
+	'/Ü/' => 'Ue',
+	'/Ö/' => 'Oe',
+	'/À|Á|Â|Ã|Ä|Å|Ǻ|Ā|Ă|Ą|Ǎ/' => 'A',
+	'/à|á|â|ã|å|ǻ|ā|ă|ą|ǎ|ª/' => 'a',
+	'/Ç|Ć|Ĉ|Ċ|Č/' => 'C',
+	'/ç|ć|ĉ|ċ|č/' => 'c',
+	'/Ð|Ď|Đ/' => 'D',
+	'/ð|ď|đ/' => 'd',
+	'/È|É|Ê|Ë|Ē|Ĕ|Ė|Ę|Ě/' => 'E',
+	'/è|é|ê|ë|ē|ĕ|ė|ę|ě/' => 'e',
+	'/Ĝ|Ğ|Ġ|Ģ/' => 'G',
+	'/ĝ|ğ|ġ|ģ/' => 'g',
+	'/Ĥ|Ħ/' => 'H',
+	'/ĥ|ħ/' => 'h',
+	'/Ì|Í|Î|Ï|Ĩ|Ī|Ĭ|Ǐ|Į|İ/' => 'I',
+	'/ì|í|î|ï|ĩ|ī|ĭ|ǐ|į|ı/' => 'i',
+	'/Ĵ/' => 'J',
+	'/ĵ/' => 'j',
+	'/Ķ/' => 'K',
+	'/ķ/' => 'k',
+	'/Ĺ|Ļ|Ľ|Ŀ|Ł/' => 'L',
+	'/ĺ|ļ|ľ|ŀ|ł/' => 'l',
+	'/Ñ|Ń|Ņ|Ň/' => 'N',
+	'/ñ|ń|ņ|ň|ʼn/' => 'n',
+	'/Ò|Ó|Ô|Õ|Ō|Ŏ|Ǒ|Ő|Ơ|Ø|Ǿ/' => 'O',
+	'/ò|ó|ô|õ|ō|ŏ|ǒ|ő|ơ|ø|ǿ|º/' => 'o',
+	'/Ŕ|Ŗ|Ř/' => 'R',
+	'/ŕ|ŗ|ř/' => 'r',
+	'/Ś|Ŝ|Ş|Š/' => 'S',
+	'/ś|ŝ|ş|š|ſ/' => 's',
+	'/Ţ|Ť|Ŧ/' => 'T',
+	'/ţ|ť|ŧ/' => 't',
+	'/Ù|Ú|Û|Ũ|Ū|Ŭ|Ů|Ű|Ų|Ư|Ǔ|Ǖ|Ǘ|Ǚ|Ǜ/' => 'U',
+	'/ù|ú|û|ũ|ū|ŭ|ů|ű|ų|ư|ǔ|ǖ|ǘ|ǚ|ǜ/' => 'u',
+	'/Ý|Ÿ|Ŷ/' => 'Y',
+	'/ý|ÿ|ŷ/' => 'y',
+	'/Ŵ/' => 'W',
+	'/ŵ/' => 'w',
+	'/Ź|Ż|Ž/' => 'Z',
+	'/ź|ż|ž/' => 'z',
+	'/Æ|Ǽ/' => 'AE',
+	'/ß/'=> 'ss',
+	'/IJ/' => 'IJ',
+	'/ij/' => 'ij',
+	'/Œ/' => 'OE',
+	'/ƒ/' => 'f'
+);
 
 /* End of file foreign_chars.php */
 /* Location: ./application/config/foreign_chars.php */

File system/core/CodeIgniter.php

 
 /*
  * ------------------------------------------------------
- *  Instantiate the Unicode class
+ *  Instantiate the UTF-8 class
  * ------------------------------------------------------
  *
- * Note: Order here is rather important as the Unicode
+ * Note: Order here is rather important as the UTF-8
  * class needs to be used very early on, but it cannot
  * properly determine if UTf-8 can be supported until
  * after the Config class is instantiated.
  *
  */
 
-	$UNI =& load_class('Unicode', 'core');
+	$UNI =& load_class('Utf8', 'core');
 
 /*
  * ------------------------------------------------------

File system/core/Config.php

 				$uri = implode('/', $uri);
 			}
 
+			$index = $this->item('index_page') == '' ? '' : $this->slash_item('index_page');
 			$suffix = ($this->item('url_suffix') == FALSE) ? '' : $this->item('url_suffix');
-			return $this->slash_item('base_url').$this->slash_item('index_page').trim($uri, '/').$suffix;
+			return $this->slash_item('base_url').$index.trim($uri, '/').$suffix;
 		}
 		else
 		{

File system/core/Input.php

 			$this->security =& load_class('Security');
 		}
 
-		// Do we need the Unicode class?
+		// Do we need the UTF-8 class?
 		if (UTF8_ENABLED === TRUE)
 		{
 			global $UNI;
 	}
 
 	// --------------------------------------------------------------------
-	
+
 	/**
 	 * Is ajax Request?
 	 *
 	 * Test to see if a request contains the HTTP_X_REQUESTED_WITH header
 	 *
-	 * @return 	boolean 	
+	 * @return 	boolean
 	 */
 	public function is_ajax_request()
 	{
 		return ($this->server('HTTP_X_REQUESTED_WITH') === 'XMLHttpRequest');
 	}
 
+	// --------------------------------------------------------------------
+
+	/**
+	 * Is cli Request?
+	 *
+	 * Test to see if a request was made from the command line
+	 *
+	 * @return 	boolean
+	 */
+	public function is_cli_request()
+	{
+		return (bool) defined('STDIN');
+	}
+
 }
 // END Input class
 

File system/core/URI.php

 	{
 		if (strtoupper($this->config->item('uri_protocol')) == 'AUTO')
 		{
-			// Let's try the REQUEST_URI first, this will work in most situations
-			if ($uri = $this->_get_request_uri())
-			{
-				$this->uri_string = $this->_parse_request_uri($uri);
-				return;
-			}
-
 			// Arguments exist, it must be a command line request
 			if ( ! empty($_SERVER['argv']))
 			{
 				return;
 			}
 
+			// Let's try the REQUEST_URI first, this will work in most situations
+			if ($uri = $this->_detect_uri())
+			{
+				$this->uri_string = $uri;
+				return;
+			}
+
 			// Is there a PATH_INFO variable?
 			// Note: some servers seem to have trouble with getenv() so we'll test it two ways
 			$path = (isset($_SERVER['PATH_INFO'])) ? $_SERVER['PATH_INFO'] : @getenv('PATH_INFO');
 
 			if ($uri == 'REQUEST_URI')
 			{
-				$this->uri_string = $this->_parse_request_uri($this->_get_request_uri());
+				$this->uri_string = $this->_detect_uri();
 				return;
 			}
 			elseif ($uri == 'CLI')
 	// --------------------------------------------------------------------
 
 	/**
-	 * Get REQUEST_URI
+	 * Detects the URI
 	 *
-	 * Retrieves the REQUEST_URI, or equivelent for IIS.
+	 * This function will detect the URI automatically and fix the query string
+	 * if necessary.
 	 *
 	 * @access	private
 	 * @return	string
 	 */
-	function _get_request_uri()
+	private function _detect_uri()
 	{
-		$uri = FALSE;
-
-		// Let's check for standard servers first
-		if (isset($_SERVER['REQUEST_URI']))
+		if ( ! isset($_SERVER['REQUEST_URI']))
 		{
-			$uri = $_SERVER['REQUEST_URI'];
-			if (strpos($uri, $_SERVER['SERVER_NAME']) !== FALSE)
-			{
-				$uri = preg_replace('/^\w+:\/\/[^\/]+/', '', $uri);
-			}
+			return '';
 		}
 
-		// Now lets check for IIS
-		elseif (isset($_SERVER['HTTP_X_REWRITE_URL']))
+		$uri = $_SERVER['REQUEST_URI'];
+		if (strpos($uri, $_SERVER['SCRIPT_NAME']) === 0)
 		{
-			$uri = $_SERVER['HTTP_X_REWRITE_URL'];
+			$uri = substr($uri, strlen($_SERVER['SCRIPT_NAME']));
+		}
+		elseif (strpos($uri, dirname($_SERVER['SCRIPT_NAME'])) === 0)
+		{
+			$uri = substr($uri, strlen(dirname($_SERVER['SCRIPT_NAME'])));
 		}
 
-		// Last ditch effort (for older CGI servers, like IIS 5)
-		elseif (isset($_SERVER['ORIG_PATH_INFO']))
+		// This section ensures that even on servers that require the URI to be in the query string (Nginx) a correct
+		// URI is found, and also fixes the QUERY_STRING server var and $_GET array.
+		if (strncmp($uri, '?/', 2) === 0)
 		{
-			$uri = $_SERVER['ORIG_PATH_INFO'];
-			if ( ! empty($_SERVER['QUERY_STRING']))
-			{
-				$uri .= '?' . $_SERVER['QUERY_STRING'];
-			}
+			$uri = substr($uri, 2);
 		}
+		$parts = preg_split('#\?#i', $uri, 2);
+		$uri = $parts[0];
+		if (isset($parts[1]))
+		{
+			$_SERVER['QUERY_STRING'] = $parts[1];
+			parse_str($_SERVER['QUERY_STRING'], $_GET);
+		}
+		else
+		{
+			$_SERVER['QUERY_STRING'] = '';
+			$_GET = array();
+		}
+		$uri = parse_url($uri, PHP_URL_PATH);
 
-		return $uri;
-	}
-
-	// --------------------------------------------------------------------
-
-	/**
-	 * Parse REQUEST_URI
-	 *
-	 * Due to the way REQUEST_URI works it usually contains path info
-	 * that makes it unusable as URI data.  We'll trim off the unnecessary
-	 * data, hopefully arriving at a valid URI that we can use.
-	 *
-	 * @access	private
-	 * @param	string
-	 * @return	string
-	 */
-	private function _parse_request_uri($uri)
-	{
-		// Some server's require URL's like index.php?/whatever If that is the case,
-		// then we need to add that to our parsing.
-		$fc_path = ltrim(FCPATH . SELF, '/');
-		if (strpos($uri, SELF . '?') !== FALSE)
-		{
-			$fc_path .= '?';
-		}
-
-		$parsed_uri = explode('/', ltrim($uri, '/'));
-
-		$i = 0;
-		foreach (explode("/", $fc_path) as $segment)
-		{
-			if (isset($parsed_uri[$i]) && $segment == $parsed_uri[$i])
-			{
-				$i++;
-			}
-		}
-
-		$uri = implode("/", array_slice($parsed_uri, $i));
-
-		// Let's take off any query string and re-assign $_SERVER['QUERY_STRING'] and $_GET.
-		// This is only needed on some servers.  However, we are forced to use it to accomodate
-		// them.
-		if (($qs_pos = strpos($uri, '?')) !== FALSE)
-		{
-			$_SERVER['QUERY_STRING'] = substr($uri, $qs_pos + 1);
-			parse_str($_SERVER['QUERY_STRING'], $_GET);
-			$uri = substr($uri, 0, $qs_pos);
-		}
-
-		// If it is just a / or index.php then just empty it.
-		if ($uri == '/' OR $uri == SELF)
-		{
-			$uri = '';
-		}
-
-		return $uri;
+		// Do some final cleaning of the URI and return it
+		return str_replace(array('//', '../'), '/', trim($uri, '/'));
 	}
 
 	// --------------------------------------------------------------------
 	 */
 	function ruri_string()
 	{
-		return '/'.implode('/', $this->rsegment_array()).'/';
+		return '/'.implode('/', $this->rsegment_array());
 	}
 
 }

File system/core/Unicode.php

-<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
-/**
- * CodeIgniter
- *
- * An open source application development framework for PHP 5.1.6 or newer
- *
- * @package		CodeIgniter
- * @author		ExpressionEngine Dev Team
- * @copyright	Copyright (c) 2008 - 2010, EllisLab, Inc.
- * @license		http://codeigniter.com/user_guide/license.html
- * @link		http://codeigniter.com
- * @since		Version 2.0
- * @filesource
- */
-
-// ------------------------------------------------------------------------
-
-/**
- * Unicode Class
- *
- * Provides unicode support for UTF-8 environments
- *
- * @package		CodeIgniter
- * @subpackage	Libraries
- * @category	Unicode
- * @author		ExpressionEngine Dev Team
- * @link		http://codeigniter.com/user_guide/libraries/unicode.html
- */
-class CI_Unicode {
-
-	/**
-	 * Constructor
-	 *
-	 * Determines if UTF-8 support is to be enabled
-	 *
-	 */
-	function __construct()
-	{
-		log_message('debug', "Unicode Class Initialized");
-
-		global $CFG;
-
-		if (
-			preg_match('/./u', 'é') === 1					// PCRE must support UTF-8
-			AND function_exists('iconv')					// iconv must be installed
-			AND ini_get('mbstring.func_overload') != 1		// Multibyte string function overloading cannot be enabled
-			AND $CFG->item('charset') == 'UTF-8'			// Application charset must be UTF-8
-			)
-		{
-			log_message('debug', "Unicode Class - UTF-8 Support Enabled");
-
-			define('UTF8_ENABLED', TRUE);
-
-			// set internal encoding for multibyte string functions if necessary
-			// and set a flag so we don't have to repeatedly use extension_loaded()
-			// or function_exists()
-			if (extension_loaded('mbstring'))
-			{
-				define('MB_ENABLED', TRUE);
-				mb_internal_encoding('UTF-8');
-			}
-			else
-			{
-				define('MB_ENABLED', FALSE);
-			}
-		}
-		else
-		{
-			log_message('debug', "Unicode Class - UTF-8 Support Disabled");
-			define('UTF8_ENABLED', FALSE);
-		}
-	}
-
-	// --------------------------------------------------------------------
-
-	/**
-	 * Clean UTF-8 strings
-	 *
-	 * Ensures strings are UTF-8
-	 *
-	 * @access	public
-	 * @param	string
-	 * @return	string
-	 */
-	function clean_string($str)
-	{
-		if ($this->_is_ascii($str) === FALSE)
-		{
-			$str = @iconv('UTF-8', 'UTF-8//IGNORE', $str);
-		}
-
-		return $str;
-	}
-
-	// --------------------------------------------------------------------
-
-	/**
-	 * Remove ASCII control characters
-	 *
-	 * Removes all ASCII control characters except horizontal tabs,
-	 * line feeds, and carriage returns, as all others can cause
-	 * problems in XML
-	 *
-	 * @access	public
-	 * @param	string
-	 * @return	string
-	 */
-	function safe_ascii_for_xml($str)
-	{
-		return preg_replace('/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F]+/S', '', $str);
-	}
-
-	// --------------------------------------------------------------------
-
-	/**
-	 * Convert to UTF-8
-	 *
-	 * Attempts to convert a string to UTF-8
-	 *
-	 * @access	public
-	 * @param	string
-	 * @param	string	- input encoding
-	 * @return	string
-	 */
-	function convert_to_utf8($str, $encoding)
-	{
-		if (function_exists('iconv'))
-		{
-			$str = @iconv($encoding, 'UTF-8', $str);
-		}
-		elseif (function_exists('mb_convert_encoding'))
-		{
-			$str = @mb_convert_encoding($str, 'UTF-8', $encoding);
-		}
-		else
-		{
-			return FALSE;
-		}
-
-		return $str;
-	}
-
-	// --------------------------------------------------------------------
-
-	/**
-	 * Is ASCII?
-	 *
-	 * Tests if a string is standard 7-bit ASCII or not
-	 *
-	 * @access	public
-	 * @param	string
-	 * @return	bool
-	 */
-	function _is_ascii($str)
-	{
-		return (preg_match('/[^\x00-\x7F]/S', $str) == 0);
-	}
-
-	// --------------------------------------------------------------------
-
-}
-// End Unicode Class
-
-/* End of file Unicode.php */
-/* Location: ./system/core/Unicode.php */

File system/core/Utf8.php

+<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+/**
+ * CodeIgniter
+ *
+ * An open source application development framework for PHP 5.1.6 or newer
+ *
+ * @package		CodeIgniter
+ * @author		ExpressionEngine Dev Team
+ * @copyright	Copyright (c) 2008 - 2010, EllisLab, Inc.
+ * @license		http://codeigniter.com/user_guide/license.html
+ * @link		http://codeigniter.com
+ * @since		Version 2.0
+ * @filesource
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+ * Utf8 Class
+ *
+ * Provides support for UTF-8 environments
+ *
+ * @package		CodeIgniter
+ * @subpackage	Libraries
+ * @category	UTF-8
+ * @author		ExpressionEngine Dev Team
+ * @link		http://codeigniter.com/user_guide/libraries/utf8.html
+ */
+class CI_Utf8 {
+
+	/**
+	 * Constructor
+	 *
+	 * Determines if UTF-8 support is to be enabled
+	 *
+	 */
+	function __construct()
+	{
+		log_message('debug', "Utf8 Class Initialized");
+
+		global $CFG;
+
+		if (
+			preg_match('/./u', 'é') === 1					// PCRE must support UTF-8
+			AND function_exists('iconv')					// iconv must be installed
+			AND ini_get('mbstring.func_overload') != 1		// Multibyte string function overloading cannot be enabled
+			AND $CFG->item('charset') == 'UTF-8'			// Application charset must be UTF-8
+			)
+		{
+			log_message('debug', "UTF-8 Support Enabled");
+
+			define('UTF8_ENABLED', TRUE);
+
+			// set internal encoding for multibyte string functions if necessary
+			// and set a flag so we don't have to repeatedly use extension_loaded()
+			// or function_exists()
+			if (extension_loaded('mbstring'))
+			{
+				define('MB_ENABLED', TRUE);
+				mb_internal_encoding('UTF-8');
+			}
+			else
+			{
+				define('MB_ENABLED', FALSE);
+			}
+		}
+		else
+		{
+			log_message('debug', "UTF-8 Support Disabled");
+			define('UTF8_ENABLED', FALSE);
+		}
+	}
+
+	// --------------------------------------------------------------------
+
+	/**
+	 * Clean UTF-8 strings
+	 *
+	 * Ensures strings are UTF-8
+	 *
+	 * @access	public
+	 * @param	string
+	 * @return	string
+	 */
+	function clean_string($str)
+	{
+		if ($this->_is_ascii($str) === FALSE)
+		{
+			$str = @iconv('UTF-8', 'UTF-8//IGNORE', $str);
+		}
+
+		return $str;
+	}
+
+	// --------------------------------------------------------------------
+
+	/**
+	 * Remove ASCII control characters
+	 *
+	 * Removes all ASCII control characters except horizontal tabs,
+	 * line feeds, and carriage returns, as all others can cause
+	 * problems in XML
+	 *
+	 * @access	public
+	 * @param	string
+	 * @return	string
+	 */
+	function safe_ascii_for_xml($str)
+	{
+		return preg_replace('/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F]+/S', '', $str);
+	}
+
+	// --------------------------------------------------------------------
+
+	/**
+	 * Convert to UTF-8
+	 *
+	 * Attempts to convert a string to UTF-8
+	 *
+	 * @access	public
+	 * @param	string
+	 * @param	string	- input encoding
+	 * @return	string
+	 */
+	function convert_to_utf8($str, $encoding)
+	{
+		if (function_exists('iconv'))
+		{
+			$str = @iconv($encoding, 'UTF-8', $str);
+		}
+		elseif (function_exists('mb_convert_encoding'))
+		{
+			$str = @mb_convert_encoding($str, 'UTF-8', $encoding);
+		}
+		else
+		{
+			return FALSE;
+		}
+
+		return $str;
+	}
+
+	// --------------------------------------------------------------------
+
+	/**
+	 * Is ASCII?
+	 *
+	 * Tests if a string is standard 7-bit ASCII or not
+	 *
+	 * @access	public
+	 * @param	string
+	 * @return	bool
+	 */
+	function _is_ascii($str)
+	{
+		return (preg_match('/[^\x00-\x7F]/S', $str) == 0);
+	}
+
+	// --------------------------------------------------------------------
+
+}
+// End Utf8 Class
+
+/* End of file Utf8.php */
+/* Location: ./system/core/Utf8.php */

File system/database/DB_result.php

  */
 class CI_DB_result {
 
-	var $conn_id		= NULL;
-	var $result_id		= NULL;
-	var $result_array	= array();
-	var $result_object	= array();
-	var $current_row	= 0;
-	var $num_rows		= 0;
-	var $row_data		= NULL;
+	var $conn_id		      = NULL;
+	var $result_id		      = NULL;
+	var $result_array	      = array();
+	var $result_object	      = array();
+    var $custom_result_object = array();
+	var $current_row	      = 0;
+	var $num_rows		      = 0;
+	var $row_data		      = NULL;
 
 
 	/**
 	 */
 	function result($type = 'object')
 	{
-		return ($type == 'object') ? $this->result_object() : $this->result_array();
+        if ($type == 'array') return $this->result_array();
+        else if ($type == 'object') return $this->result_object();
+        else return $this->custom_result_object($type);
 	}
 
 	// --------------------------------------------------------------------
 
+    /**
+     * Custom query result.
+     *
+     * @param  class_name  A string that represents the type of object you want back
+     * @return array of objects
+     */
+    function custom_result_object($class_name)
+    {
+        if (array_key_exists($class_name, $this->custom_result_object))
+        {
+            return $this->custom_result_object[$class_name];
+        }
+        
+        if ($this->result_id === FALSE OR $this->num_rows() == 0)
+        {
+            return array();
+        }
+
+        // add the data to the object
+        $this->_data_seek(0);
+        $result_object = array();
+		while ($row = $this->_fetch_object())
+        {
+            $object = new $class_name();
+            foreach($row as $key => $value)
+            {
+                $object->$key = $value;
+            }
+			$result_object[] = $object;
+		}
+
+        // return the array
+        return $this->custom_result_object[$class_name] = $result_object;
+    }
+
 	/**
 	 * Query result.  "object" version.
 	 *
 			$n = 0;
 		}
 
-		return ($type == 'object') ? $this->row_object($n) : $this->row_array($n);
+        if ($type == 'object') return $this->row_object($n);
+        else if ($type == 'array') return $this->row_array($n);
+        else return $this->custom_row_object($n, $type);
 	}
 
 	// --------------------------------------------------------------------
 
 	// --------------------------------------------------------------------
 
-	/**
+    /**
+	 * Returns a single result row - custom object version
+	 *
+	 * @access	public
+	 * @return	object
+	 */
+	function custom_row_object($n, $type)
+	{
+		$result = $this->custom_result_object($type);
+
+		if (count($result) == 0)
+		{
+			return $result;
+		}
+
+		if ($n != $this->current_row AND isset($result[$n]))
+		{
+			$this->current_row = $n;
+		}
+
+		return $result[$this->current_row];
+	}
+
+    /**
 	 * Returns a single result row - object version
 	 *
 	 * @access	public
 // END DB_result class
 
 /* End of file DB_result.php */
-/* Location: ./system/database/DB_result.php */
+/* Location: ./system/database/DB_result.php */

File system/helpers/text_helper.php

  */
 if ( ! function_exists('convert_accented_characters'))
 {
-	function convert_accented_characters($match)
+	function convert_accented_characters($str)
 	{
 		if ( ! file_exists(APPPATH.'config/foreign_chars'.EXT))
 		{
-			return $match;
+			return $str;
 		}
 
 		include APPPATH.'config/foreign_chars'.EXT;
 
 		if ( ! isset($foreign_characters))
 		{
-			return $match;
+			return $str;
 		}
 
-		$ord = ord($match['1']);
-
-		if (isset($foreign_characters[$ord]))
-		{
-			return $foreign_characters[$ord];
-		}
-		else
-		{
-			return $match['1'];
-		}
+		return preg_replace(array_keys($foreign_characters), array_values($foreign_characters), $str);
 	}
 }
 

File system/libraries/Email.php

 	 *
 	 * The constructor can be passed an array of config values
 	 */
-	function __construct($config = array())
+	public function __construct($config = array())
 	{
 		if (count($config) > 0)
 		{
 	 * @param	array
 	 * @return	void
 	 */
-	function initialize($config = array())
+	public function initialize($config = array())
 	{
 		foreach ($config as $key => $val)
 		{
 
 		$this->_smtp_auth = ($this->smtp_user == '' AND $this->smtp_pass == '') ? FALSE : TRUE;
 		$this->_safe_mode = ((boolean)@ini_get("safe_mode") === FALSE) ? FALSE : TRUE;
+
+		return $this;
 	}
 
 	// --------------------------------------------------------------------
 	 * @access	public
 	 * @return	void
 	 */
-	function clear($clear_attachments = FALSE)
+	public function clear($clear_attachments = FALSE)
 	{
 		$this->_subject		= "";
 		$this->_body		= "";
 	 * @param	string
 	 * @return	void
 	 */
-	function from($from, $name = '')
+	public function from($from, $name = '')
 	{
 		if (preg_match( '/\<(.*)\>/', $from, $match))
 		{
 	 * @param	string
 	 * @return	void
 	 */
-	function reply_to($replyto, $name = '')
+	public function reply_to($replyto, $name = '')
 	{
 		if (preg_match( '/\<(.*)\>/', $replyto, $match))
 		{
 	 * @param	string
 	 * @return	void
 	 */
-	function to($to)
+	public function to($to)
 	{
 		$to = $this->_str_to_array($to);
 		$to = $this->clean_email($to);
 
 		switch ($this->_get_protocol())
 		{
-			case 'smtp'		: $this->_recipients = $to;
+			case 'smtp'		:
+				$this->_recipients = $to;
 			break;
-			case 'sendmail'	: $this->_recipients = implode(", ", $to);
-			break;
-			case 'mail'		: $this->_recipients = implode(", ", $to);
+			case 'sendmail'	:
+			case 'mail'		:
+				$this->_recipients = implode(", ", $to);
 			break;
 		}
 
 	 * @param	string
 	 * @return	void
 	 */
-	function cc($cc)
+	public function cc($cc)
 	{
 		$cc = $this->_str_to_array($cc);
 		$cc = $this->clean_email($cc);
 	 * @param	string
 	 * @return	void
 	 */
-	function bcc($bcc, $limit = '')
+	public function bcc($bcc, $limit = '')
 	{
 		if ($limit != '' && is_numeric($limit))
 		{
 	 * @param	string
 	 * @return	void
 	 */
-	function subject($subject)
+	public function subject($subject)
 	{
 		$subject = $this->_prep_q_encoding($subject);
 		$this->_set_header('Subject', $subject);
 	 * @param	string
 	 * @return	void
 	 */
-	function message($body)
+	public function message($body)
 	{
 		$this->_body = stripslashes(rtrim(str_replace("\r", "", $body)));
 		return $this;
 	 * @param	string
 	 * @return	void
 	 */
-	function attach($filename, $disposition = 'attachment')
+	public function attach($filename, $disposition = 'attachment')
 	{
 		$this->_attach_name[] = $filename;
 		$this->_attach_type[] = $this->_mime_types(next(explode('.', basename($filename))));
 	 * @param	string
 	 * @return	void
 	 */
-	function _set_header($header, $value)
+	private function _set_header($header, $value)
 	{
 		$this->_headers[$header] = $value;
 	}
 	 * @param	string
 	 * @return	array
 	 */
-	function _str_to_array($email)
+	private function _str_to_array($email)
 	{
 		if ( ! is_array($email))
 		{
 	 * @param	string
 	 * @return	void
 	 */
-	function set_alt_message($str = '')
+	public function set_alt_message($str = '')
 	{
 		$this->alt_message = ($str == '') ? '' : $str;
 		return $this;
 	 * @param	string
 	 * @return	void
 	 */
-	function set_mailtype($type = 'text')
+	public function set_mailtype($type = 'text')
 	{
 		$this->mailtype = ($type == 'html') ? 'html' : 'text';
 		return $this;
 	 * @param	string
 	 * @return	void
 	 */
-	function set_wordwrap($wordwrap = TRUE)
+	public function set_wordwrap($wordwrap = TRUE)
 	{
 		$this->wordwrap = ($wordwrap === FALSE) ? FALSE : TRUE;
 		return $this;
 	 * @param	string
 	 * @return	void
 	 */
-	function set_protocol($protocol = 'mail')
+	public function set_protocol($protocol = 'mail')
 	{
 		$this->protocol = ( ! in_array($protocol, $this->_protocols, TRUE)) ? 'mail' : strtolower($protocol);
 		return $this;
 	 * @param	integer
 	 * @return	void
 	 */
-	function set_priority($n = 3)
+	public function set_priority($n = 3)
 	{
 		if ( ! is_numeric($n))
 		{
 	 * @param	string
 	 * @return	void
 	 */
-	function set_newline($newline = "\n")
+	public function set_newline($newline = "\n")
 	{
 		if ($newline != "\n" AND $newline != "\r\n" AND $newline != "\r")
 		{
 	 * @param	string
 	 * @return	void
 	 */
-	function set_crlf($crlf = "\n")
+	public function set_crlf($crlf = "\n")
 	{
 		if ($crlf != "\n" AND $crlf != "\r\n" AND $crlf != "\r")
 		{
 	 * @access	private
 	 * @return	void
 	 */
-	function _set_boundaries()
+	private function _set_boundaries()
 	{
 		$this->_alt_boundary = "B_ALT_".uniqid(''); // multipart/alternative
 		$this->_atc_boundary = "B_ATC_".uniqid(''); // attachment boundary
 	 * @access	private
 	 * @return	string
 	 */
-	function _get_message_id()
+	private function _get_message_id()
 	{
 		$from = $this->_headers['Return-Path'];
 		$from = str_replace(">", "", $from);
 	 * @param	bool
 	 * @return	string
 	 */
-	function _get_protocol($return = TRUE)
+	private function _get_protocol($return = TRUE)
 	{
 		$this->protocol = strtolower($this->protocol);
 		$this->protocol = ( ! in_array($this->protocol, $this->_protocols, TRUE)) ? 'mail' : $this->protocol;
 	 * @param	bool
 	 * @return	string
 	 */
-	function _get_encoding($return = TRUE)
+	private function _get_encoding($return = TRUE)
 	{
 		$this->_encoding = ( ! in_array($this->_encoding, $this->_bit_depths)) ? '8bit' : $this->_encoding;
 
 	 * @access	private
 	 * @return	string
 	 */
-	function _get_content_type()
+	private function _get_content_type()
 	{
 		if	($this->mailtype == 'html' &&  count($this->_attach_name) == 0)
 		{
 	 * @access	private
 	 * @return	string
 	 */
-	function _set_date()
+	private function _set_date()
 	{
 		$timezone = date("Z");
 		$operator = (strncmp($timezone, '-', 1) == 0) ? '-' : '+';
 	 * @access	private
 	 * @return	string
 	 */
-	function _get_mime_message()
+	private function _get_mime_message()
 	{
 		return "This is a multi-part message in MIME format.".$this->newline."Your email application may not support this format.";
 	}
 	 * @param	string
 	 * @return	bool
 	 */
-	function validate_email($email)
+	public function validate_email($email)
 	{
 		if ( ! is_array($email))
 		{
 	 * @param	string
 	 * @return	bool
 	 */
-	function valid_email($address)
+	public function valid_email($address)
 	{
 		return ( ! preg_match("/^([a-z0-9\+_\-]+)(\.[a-z0-9\+_\-]+)*@([a-z0-9\-]+\.)+[a-z]{2,6}$/ix", $address)) ? FALSE : TRUE;
 	}
 	 * @param	string
 	 * @return	string
 	 */
-	function clean_email($email)
+	public function clean_email($email)
 	{
 		if ( ! is_array($email))
 		{
 	/**
 	 * Build alternative plain text message
 	 *
-	 * This function provides the raw message for use
+	 * This public function provides the raw message for use
 	 * in plain-text headers of HTML-formatted emails.
 	 * If the user hasn't specified his own alternative message
 	 * it creates one by stripping the HTML
 	 * @access	private
 	 * @return	string
 	 */
-	function _get_alt_message()
+	private function _get_alt_message()
 	{
 		if ($this->alt_message != "")
 		{
 	 * @param	integer
 	 * @return	string
 	 */
-	function word_wrap($str, $charlim = '')
+	public function word_wrap($str, $charlim = '')
 	{
 		// Se the character limit
 		if ($charlim == '')
 			}
 		}
 
-		// Use PHP's native function to do the initial wordwrap.
+		// Use PHP's native public function to do the initial wordwrap.
 		// We set the cut flag to FALSE so that any individual words that are
 		// too long get left alone.  In the next step we'll deal with them.
 		$str = wordwrap($str, $charlim, "\n", FALSE);
 	 * @param	string
 	 * @return	string
 	 */
-	function _build_headers()
+	private function _build_headers()
 	{
 		$this->_set_header('X-Sender', $this->clean_email($this->_headers['From']));
 		$this->_set_header('X-Mailer', $this->useragent);
 	 * @access	private
 	 * @return	void
 	 */
-	function _write_headers()
+	private function _write_headers()
 	{
 		if ($this->protocol == 'mail')
 		{
 	 * @access	private
 	 * @return	void
 	 */
-	function _build_message()
+	private function _build_message()
 	{
 		if ($this->wordwrap === TRUE  AND  $this->mailtype != 'html')
 		{
 	 * @param	integer
 	 * @return	string
 	 */
-	function _prep_quoted_printable($str, $charlim = '')
+	private function _prep_quoted_printable($str, $charlim = '')
 	{
 		// Set the character limit
 		// Don't allow over 76, as that will make servers and MUAs barf
 	 * @param	bool	// set to TRUE for processing From: headers
 	 * @return	str
 	 */
-	function _prep_q_encoding($str, $from = FALSE)
+	private function _prep_q_encoding($str, $from = FALSE)
 	{
 		$str = str_replace(array("\r", "\n"), array('', ''), $str);
 
 	 * @access	public
 	 * @return	bool
 	 */
-	function send()
+	public function send()
 	{
 		if ($this->_replyto_flag == FALSE)
 		{
 	 * @access	public
 	 * @return	bool
 	 */
-	function batch_bcc_send()
+	public function batch_bcc_send()
 	{
 		$float = $this->bcc_batch_size -1;
 
 	 * @access	private
 	 * @return	void
 	 */
-	function _unwrap_specials()
+	private function _unwrap_specials()
 	{
 		$this->_finalbody = preg_replace_callback("/\{unwrap\}(.*?)\{\/unwrap\}/si", array($this, '_remove_nl_callback'), $this->_finalbody);
 	}
 	 * @access	private
 	 * @return	string
 	 */
-	function _remove_nl_callback($matches)
+	private function _remove_nl_callback($matches)
 	{
 		if (strpos($matches[1], "\r") !== FALSE OR strpos($matches[1], "\n") !== FALSE)
 		{
 	 * @access	private
 	 * @return	bool
 	 */
-	function _spool_email()
+	private function _spool_email()
 	{
 		$this->_unwrap_specials();
 
 	 * @access	private
 	 * @return	bool
 	 */
-	function _send_with_mail()
+	private function _send_with_mail()
 	{
 		if ($this->_safe_mode == TRUE)
 		{
 	 * @access	private
 	 * @return	bool
 	 */
-	function _send_with_sendmail()
+	private function _send_with_sendmail()
 	{
 		$fp = @popen($this->mailpath . " -oi -f ".$this->clean_email($this->_headers['From'])." -t", 'w');
 
 	 * @access	private
 	 * @return	bool
 	 */
-	function _send_with_smtp()
+	private function _send_with_smtp()
 	{
 		if ($this->smtp_host == '')
 		{
 	 * @param	string
 	 * @return	string
 	 */
-	function _smtp_connect()
+	private function _smtp_connect()
 	{
 		$this->_smtp_connect = fsockopen($this->smtp_host,
 										$this->smtp_port,
 	 * @param	string
 	 * @return	string
 	 */
-	function _send_command($cmd, $data = '')
+	private function _send_command($cmd, $data = '')
 	{
 		switch ($cmd)
 		{
 	 * @access	private
 	 * @return	bool
 	 */
-	function _smtp_authenticate()
+	private function _smtp_authenticate()
 	{
 		if ( ! $this->_smtp_auth)
 		{
 	 * @access	private
 	 * @return	bool
 	 */
-	function _send_data($data)
+	private function _send_data($data)
 	{
 		if ( ! fwrite($this->_smtp_connect, $data . $this->newline))
 		{
 	 * @access	private
 	 * @return	string
 	 */
-	function _get_smtp_data()
+	private function _get_smtp_data()
 	{
 		$data = "";
 
 	 * @access	private
 	 * @return	string
 	 */
-	function _get_hostname()
+	private function _get_hostname()
 	{
 		return (isset($_SERVER['SERVER_NAME'])) ? $_SERVER['SERVER_NAME'] : 'localhost.localdomain';
 	}
 	 * @access	private
 	 * @return	string
 	 */
-	function _get_ip()
+	private function _get_ip()
 	{
 		if ($this->_IP !== FALSE)
 		{
 	 * @access	public
 	 * @return	string
 	 */
-	function print_debugger()
+	public function print_debugger()
 	{
 		$msg = '';
 
 	 * @param	string
 	 * @return	string
 	 */
-	function _set_error_message($msg, $val = '')
+	private function _set_error_message($msg, $val = '')
 	{
 		$CI =& get_instance();
 		$CI->lang->load('email');
 	 * @param	string
 	 * @return	string
 	 */
-	function _mime_types($ext = "")
+	private function _mime_types($ext = "")
 	{
 		$mimes = array(	'hqx'	=>	'application/mac-binhex40',
 						'cpt'	=>	'application/mac-compactpro',

File system/libraries/Form_validation.php

 		}
 
 		$this->_error_messages = array_merge($this->_error_messages, $lang);
-		
+
 		return $this;
 	}
 
 	{
 		$this->_error_prefix = $prefix;
 		$this->_error_suffix = $suffix;
-		
+
 		return $this;
 	}
 
 				}
 			}
 
-			preg_match_all('/([a-zA-Z_-]*(\[.*\])?)\|?/i', $row['rules'], $matches);
-
-			$rules = $matches[1];
-			array_pop($rules);
-			unset($matches);
-
-			$this->_execute($row, $rules, $this->_field_data[$field]['postdata']);
+			$this->_execute($row, explode('|', $row['rules']), $this->_field_data[$field]['postdata']);
 		}
 
 		// Did we end up with any errors?
 		{
 			return array_shift($this->_field_data[$field]['postdata']);
 		}
-		
+
 		return $this->_field_data[$field]['postdata'];
 	}
 

File system/libraries/Security.php

  * @link		http://codeigniter.com/user_guide/libraries/sessions.html
  */
 class CI_Security {
-	var $xss_hash			= '';
-	var $csrf_hash			= '';
-	var $csrf_expire		= 7200;  // Two hours (in seconds)
-	var $csrf_token_name	= 'ci_csrf_token';
-	var $csrf_cookie_name	= 'ci_csrf_token';
+
+	public $xss_hash			= '';
+	public $csrf_hash			= '';
+	public $csrf_expire			= 7200;  // Two hours (in seconds)
+	public $csrf_token_name		= 'ci_csrf_token';
+	public $csrf_cookie_name	= 'ci_csrf_token';
 
 	/* never allowed, string replacement */
-	var $never_allowed_str = array(
+	public $never_allowed_str = array(
 									'document.cookie'	=> '[removed]',
 									'document.write'	=> '[removed]',
 									'.parentNode'		=> '[removed]',
 									'<![CDATA['			=> '&lt;![CDATA['
 									);
 	/* never allowed, regex replacement */
-	var $never_allowed_regex = array(
+	public $never_allowed_regex = array(
 										"javascript\s*:"			=> '[removed]',
 										"expression\s*(\(|&\#40;)"	=> '[removed]', // CSS and IE
 										"vbscript\s*:"				=> '[removed]', // IE, surprise!
 
 	public function __construct()
 	{
+		$this->csrf_token_name = (config_item('csrf_token_name')) ? config_item('csrf_token_name') : 'csrf_token_name';
+		$this->csrf_cookie_name = (config_item('csrf_cookie_name')) ? config_item('csrf_cookie_name') : 'csrf_cookie_name';
+		$this->csrf_expire = (config_item('csrf_expire')) ? config_item('csrf_expire') : 7200;
+
 		// Append application specific cookie prefix to token name
 		$this->csrf_cookie_name = (config_item('cookie_prefix')) ? config_item('cookie_prefix').$this->csrf_token_name : $this->csrf_token_name;
 
 	 * @access	public
 	 * @return	null
 	 */
-	function csrf_verify()
+	public function csrf_verify()
 	{
 		// If no POST data exists we will set the CSRF cookie
 		if (count($_POST) == 0)
 	 * @access	public
 	 * @return	null
 	 */
-	function csrf_set_cookie()
+	public function csrf_set_cookie()
 	{
 		$expire = time() + $this->csrf_expire;
 
 	/**
 	 * Set Cross Site Request Forgery Protection Cookie
 	 *
-	 * @access	public
+	 * @access	private
 	 * @return	null
 	 */
-	function _csrf_set_hash()
+	private function _csrf_set_hash()
 	{
 		if ($this->csrf_hash == '')
 		{
 	 * @access	public
 	 * @return	null
 	 */
-	function csrf_show_error()
+	public function csrf_show_error()
 	{
 		show_error('The action you have requested is not allowed.');
 	}
 	 * @param	mixed	string or array
 	 * @return	string
 	 */
-	function xss_clean($str, $is_image = FALSE)
+	public function xss_clean($str, $is_image = FALSE)
 	{
 		/*
 		 * Is the string an array?
 		/*
 		 * Protect GET variables in URLs
 		 */
-		
+
 		 // 901119URL5918AMP18930PROTECT8198
-		
+
 		$str = preg_replace('|\&([a-z\_0-9\-]+)\=([a-z\_0-9\-]+)|i', $this->xss_hash()."\\1=\\2", $str);
 
 		/*
 		 */
 
 		$str = preg_replace_callback("/[a-z]+=([\'\"]).*?\\1/si", array($this, '_convert_attribute'), $str);
-	
+
 		$str = preg_replace_callback("/<\w+.*?(?=>|<|$)/si", array($this, '_decode_entity'), $str);
 
 		/*
 	 * @access	public
 	 * @return	string
 	 */
-	function xss_hash()
+	public function xss_hash()
 	{
 		if ($this->xss_hash == '')
 		{
 	 * Callback function for xss_clean() to remove whitespace from
 	 * things like j a v a s c r i p t
 	 *
-	 * @access	public
+	 * @access	private
 	 * @param	type
 	 * @return	type
 	 */
-	function _compact_exploded_words($matches)
+	private function _compact_exploded_words($matches)
 	{
 		return preg_replace('/\s+/s', '', $matches[1]).$matches[2];
 	}
 	 * @param	array
 	 * @return	string
 	 */
-	function _sanitize_naughty_html($matches)
+	private function _sanitize_naughty_html($matches)
 	{
 		// encode opening brace
 		$str = '&lt;'.$matches[1].$matches[2].$matches[3];
 	 * @param	array
 	 * @return	string
 	 */
-	function _js_link_removal($match)
+	private function _js_link_removal($match)
 	{
 		$attributes = $this->_filter_attributes(str_replace(array('<', '>'), '', $match[1]));
 		return str_replace($match[1], preg_replace("#href=.*?(alert\(|alert&\#40;|javascript\:|charset\=|window\.|document\.|\.cookie|<script|<xss|base64\s*,)#si", "", $attributes), $match[0]);
 	 * @param	array
 	 * @return	string
 	 */
-	function _js_img_removal($match)
+	private function _js_img_removal($match)
 	{
 		$attributes = $this->_filter_attributes(str_replace(array('<', '>'), '', $match[1]));
 		return str_replace($match[1], preg_replace("#src=.*?(alert\(|alert&\#40;|javascript\:|charset\=|window\.|document\.|\.cookie|<script|<xss|base64\s*,)#si", "", $attributes), $match[0]);
 	 *
 	 * Used as a callback for XSS Clean
 	 *
-	 * @access	public
+	 * @access	private
 	 * @param	array
 	 * @return	string
 	 */
-	function _convert_attribute($match)
+	private function _convert_attribute($match)
 	{
 		return str_replace(array('>', '<', '\\'), array('&gt;', '&lt;', '\\\\'), $match[0]);
 	}
 	 *
 	 * Filters tag attributes for consistency and safety
 	 *
-	 * @access	public
+	 * @access	private
 	 * @param	string
 	 * @return	string
 	 */
-	function _filter_attributes($str)
+	private function _filter_attributes($str)
 	{
 		$out = '';
 
 	 *
 	 * Used as a callback for XSS Clean
 	 *
-	 * @access	public
+	 * @access	private
 	 * @param	array
 	 * @return	string
 	 */
-	function _decode_entity($match)
+	private function _decode_entity($match)
 	{
 		return $this->entity_decode($match[0], strtoupper(config_item('charset')));
 	}
 	 * @param	string
 	 * @return	string
 	 */
-	function entity_decode($str, $charset='UTF-8')
+	public function entity_decode($str, $charset='UTF-8')
 	{
 		if (stristr($str, '&') === FALSE) return $str;
 
 	 * @param	string
 	 * @return	string
 	 */
-	function sanitize_filename($str, $relative_path = FALSE)
+	public function sanitize_filename($str, $relative_path = FALSE)
 	{
 		$bad = array(
 						"../",
 						"%3b",		// ;
 						"%3d"		// =
 					);
-		
+
 		if ( ! $relative_path)
 		{
 			$bad[] = './';

File user_guide/database/active_record.html

 <br />
 //Generates:  SELECT `field2` FROM (`tablename`)</code></p>
 
-<p class="important"> <strong>Note:</strong> The following statements can be cached: select, from, join, where, like, groupby, having, orderby, set</p>
+<p class="important"> <strong>Note:</strong> The following statements can be cached: select, from, join, where, like, group_by, having, order_by, set</p>
 <p>&nbsp;</p>
 </div>
 <!-- END CONTENT -->

File user_guide/general/core_classes.html

 <li>Log</li>
 <li>Output</li>
 <li>Router</li>
-<li>Unicode</li>
 <li>URI</li>
+<li>Utf8</li>
 </ul>
 
 <h2>Replacing Core Classes</h2>