summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--index.php234
-rw-r--r--system/application/config/doctypes.php28
-rw-r--r--system/application/config/hooks.php30
-rw-r--r--system/application/config/smileys.php130
-rw-r--r--system/application/config/user_agents.php348
-rw-r--r--system/application/errors/error_404.php68
-rw-r--r--system/application/errors/error_db.php66
-rw-r--r--system/application/errors/error_general.php66
-rw-r--r--system/application/errors/error_php.php18
-rw-r--r--system/helpers/compatibility_helper.php994
-rw-r--r--system/helpers/html_helper.php830
-rw-r--r--system/helpers/language_helper.php114
-rw-r--r--system/language/english/profiler_lang.php36
-rw-r--r--system/language/english/scaffolding_lang.php32
-rw-r--r--system/libraries/Email.php3908
-rw-r--r--system/libraries/Ftp.php1234
-rw-r--r--system/libraries/Hooks.php450
-rw-r--r--system/libraries/Image_lib.php3094
-rw-r--r--system/libraries/Input.php2116
-rw-r--r--system/libraries/Language.php244
-rw-r--r--system/libraries/Session.php1514
-rw-r--r--system/libraries/Typography.php769
-rw-r--r--system/libraries/URI.php1168
-rw-r--r--system/scaffolding/views/add.php64
-rw-r--r--system/scaffolding/views/delete.php18
-rw-r--r--system/scaffolding/views/edit.php64
-rw-r--r--system/scaffolding/views/header.php56
-rw-r--r--system/scaffolding/views/no_data.php14
-rw-r--r--system/scaffolding/views/view.php52
-rw-r--r--user_guide/changelog.html1912
-rw-r--r--user_guide/general/styleguide.html1296
-rw-r--r--user_guide/helpers/html_helper.html734
-rw-r--r--user_guide/helpers/language_helper.html194
-rw-r--r--user_guide/nav/hacks.txt16
-rwxr-xr-xuser_guide/nav/prototype.lite.js252
35 files changed, 11081 insertions, 11082 deletions
diff --git a/index.php b/index.php
index 39aeda5c9..de5fdef13 100644
--- a/index.php
+++ b/index.php
@@ -1,118 +1,118 @@
-<?php
-/*
-|---------------------------------------------------------------
-| PHP ERROR REPORTING LEVEL
-|---------------------------------------------------------------
-|
-| By default CI runs with error reporting set to ALL. For security
-| reasons you are encouraged to change this when your site goes live.
-| For more info visit: http://www.php.net/error_reporting
-|
-*/
- error_reporting(E_ALL);
-
-/*
-|---------------------------------------------------------------
-| SYSTEM FOLDER NAME
-|---------------------------------------------------------------
-|
-| This variable must contain the name of your "system" folder.
-| Include the path if the folder is not in the same directory
-| as this file.
-|
-| NO TRAILING SLASH!
-|
-*/
- $system_folder = "system";
-
-/*
-|---------------------------------------------------------------
-| APPLICATION FOLDER NAME
-|---------------------------------------------------------------
-|
-| If you want this front controller to use a different "application"
-| folder then the default one you can set its name here. The folder
-| can also be renamed or relocated anywhere on your server.
-| For more info please see the user guide:
-| http://codeigniter.com/user_guide/general/managing_apps.html
-|
-|
-| NO TRAILING SLASH!
-|
-*/
- $application_folder = "application";
-
-/*
-|===============================================================
-| END OF USER CONFIGURABLE SETTINGS
-|===============================================================
-*/
-
-
-/*
-|---------------------------------------------------------------
-| SET THE SERVER PATH
-|---------------------------------------------------------------
-|
-| Let's attempt to determine the full-server path to the "system"
-| folder in order to reduce the possibility of path problems.
-| Note: We only attempt this if the user hasn't specified a
-| full server path.
-|
-*/
-if (strpos($system_folder, '/') === FALSE)
-{
- if (function_exists('realpath') AND @realpath(dirname(__FILE__)) !== FALSE)
- {
- $system_folder = realpath(dirname(__FILE__)).'/'.$system_folder;
- }
-}
-else
-{
- // Swap directory separators to Unix style for consistency
- $system_folder = str_replace("\\", "/", $system_folder);
-}
-
-/*
-|---------------------------------------------------------------
-| DEFINE APPLICATION CONSTANTS
-|---------------------------------------------------------------
-|
-| EXT - The file extension. Typically ".php"
-| FCPATH - The full server path to THIS file
-| SELF - The name of THIS file (typically "index.php")
-| BASEPATH - The full server path to the "system" folder
-| APPPATH - The full server path to the "application" folder
-|
-*/
-define('EXT', '.'.pathinfo(__FILE__, PATHINFO_EXTENSION));
-define('FCPATH', __FILE__);
-define('SELF', pathinfo(__FILE__, PATHINFO_BASENAME));
-define('BASEPATH', $system_folder.'/');
-
-if (is_dir($application_folder))
-{
- define('APPPATH', $application_folder.'/');
-}
-else
-{
- if ($application_folder == '')
- {
- $application_folder = 'application';
- }
-
- define('APPPATH', BASEPATH.$application_folder.'/');
-}
-
-/*
-|---------------------------------------------------------------
-| LOAD THE FRONT CONTROLLER
-|---------------------------------------------------------------
-|
-| And away we go...
-|
-*/
-require_once BASEPATH.'codeigniter/CodeIgniter'.EXT;
-
-/* End of file index.php */
+<?php
+/*
+|---------------------------------------------------------------
+| PHP ERROR REPORTING LEVEL
+|---------------------------------------------------------------
+|
+| By default CI runs with error reporting set to ALL. For security
+| reasons you are encouraged to change this when your site goes live.
+| For more info visit: http://www.php.net/error_reporting
+|
+*/
+ error_reporting(E_ALL);
+
+/*
+|---------------------------------------------------------------
+| SYSTEM FOLDER NAME
+|---------------------------------------------------------------
+|
+| This variable must contain the name of your "system" folder.
+| Include the path if the folder is not in the same directory
+| as this file.
+|
+| NO TRAILING SLASH!
+|
+*/
+ $system_folder = "system";
+
+/*
+|---------------------------------------------------------------
+| APPLICATION FOLDER NAME
+|---------------------------------------------------------------
+|
+| If you want this front controller to use a different "application"
+| folder then the default one you can set its name here. The folder
+| can also be renamed or relocated anywhere on your server.
+| For more info please see the user guide:
+| http://codeigniter.com/user_guide/general/managing_apps.html
+|
+|
+| NO TRAILING SLASH!
+|
+*/
+ $application_folder = "application";
+
+/*
+|===============================================================
+| END OF USER CONFIGURABLE SETTINGS
+|===============================================================
+*/
+
+
+/*
+|---------------------------------------------------------------
+| SET THE SERVER PATH
+|---------------------------------------------------------------
+|
+| Let's attempt to determine the full-server path to the "system"
+| folder in order to reduce the possibility of path problems.
+| Note: We only attempt this if the user hasn't specified a
+| full server path.
+|
+*/
+if (strpos($system_folder, '/') === FALSE)
+{
+ if (function_exists('realpath') AND @realpath(dirname(__FILE__)) !== FALSE)
+ {
+ $system_folder = realpath(dirname(__FILE__)).'/'.$system_folder;
+ }
+}
+else
+{
+ // Swap directory separators to Unix style for consistency
+ $system_folder = str_replace("\\", "/", $system_folder);
+}
+
+/*
+|---------------------------------------------------------------
+| DEFINE APPLICATION CONSTANTS
+|---------------------------------------------------------------
+|
+| EXT - The file extension. Typically ".php"
+| FCPATH - The full server path to THIS file
+| SELF - The name of THIS file (typically "index.php")
+| BASEPATH - The full server path to the "system" folder
+| APPPATH - The full server path to the "application" folder
+|
+*/
+define('EXT', '.'.pathinfo(__FILE__, PATHINFO_EXTENSION));
+define('FCPATH', __FILE__);
+define('SELF', pathinfo(__FILE__, PATHINFO_BASENAME));
+define('BASEPATH', $system_folder.'/');
+
+if (is_dir($application_folder))
+{
+ define('APPPATH', $application_folder.'/');
+}
+else
+{
+ if ($application_folder == '')
+ {
+ $application_folder = 'application';
+ }
+
+ define('APPPATH', BASEPATH.$application_folder.'/');
+}
+
+/*
+|---------------------------------------------------------------
+| LOAD THE FRONT CONTROLLER
+|---------------------------------------------------------------
+|
+| And away we go...
+|
+*/
+require_once BASEPATH.'codeigniter/CodeIgniter'.EXT;
+
+/* End of file index.php */
/* Location: ./index.php */ \ No newline at end of file
diff --git a/system/application/config/doctypes.php b/system/application/config/doctypes.php
index 9d510abca..2e6ac7d07 100644
--- a/system/application/config/doctypes.php
+++ b/system/application/config/doctypes.php
@@ -1,15 +1,15 @@
-<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
-
-$_doctypes = array(
- 'xhtml11' => '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">',
- 'xhtml1-strict' => '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">',
- 'xhtml1-trans' => '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">',
- 'xhtml1-frame' => '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">',
- 'html5' => '<!DOCTYPE html>',
- 'html4-strict' => '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">',
- 'html4-trans' => '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">',
- 'html4-frame' => '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">'
- );
-
-/* End of file doctypes.php */
+<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+
+$_doctypes = array(
+ 'xhtml11' => '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">',
+ 'xhtml1-strict' => '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">',
+ 'xhtml1-trans' => '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">',
+ 'xhtml1-frame' => '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">',
+ 'html5' => '<!DOCTYPE html>',
+ 'html4-strict' => '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">',
+ 'html4-trans' => '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">',
+ 'html4-frame' => '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">'
+ );
+
+/* End of file doctypes.php */
/* Location: application/config/doctypes.php */ \ No newline at end of file
diff --git a/system/application/config/hooks.php b/system/application/config/hooks.php
index 5e98a9b46..b94edb973 100644
--- a/system/application/config/hooks.php
+++ b/system/application/config/hooks.php
@@ -1,16 +1,16 @@
-<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
-/*
-| -------------------------------------------------------------------------
-| Hooks
-| -------------------------------------------------------------------------
-| This file lets you define "hooks" to extend CI without hacking the core
-| files. Please see the user guide for info:
-|
-| http://codeigniter.com/user_guide/general/hooks.html
-|
-*/
-
-
-
-/* End of file hooks.php */
+<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+/*
+| -------------------------------------------------------------------------
+| Hooks
+| -------------------------------------------------------------------------
+| This file lets you define "hooks" to extend CI without hacking the core
+| files. Please see the user guide for info:
+|
+| http://codeigniter.com/user_guide/general/hooks.html
+|
+*/
+
+
+
+/* End of file hooks.php */
/* Location: ./system/application/config/hooks.php */ \ No newline at end of file
diff --git a/system/application/config/smileys.php b/system/application/config/smileys.php
index 7f3aba550..8ef424fcf 100644
--- a/system/application/config/smileys.php
+++ b/system/application/config/smileys.php
@@ -1,66 +1,66 @@
-<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
-/*
-| -------------------------------------------------------------------
-| SMILEYS
-| -------------------------------------------------------------------
-| This file contains an array of smileys for use with the emoticon helper.
-| Individual images can be used to replace multiple simileys. For example:
-| :-) and :) use the same image replacement.
-|
-| Please see user guide for more info:
-| http://codeigniter.com/user_guide/helpers/smiley_helper.html
-|
-*/
-
-$smileys = array(
-
-// smiley image name width height alt
-
- ':-)' => array('grin.gif', '19', '19', 'grin'),
- ':lol:' => array('lol.gif', '19', '19', 'LOL'),
- ':cheese:' => array('cheese.gif', '19', '19', 'cheese'),
- ':)' => array('smile.gif', '19', '19', 'smile'),
- ';-)' => array('wink.gif', '19', '19', 'wink'),
- ';)' => array('wink.gif', '19', '19', 'wink'),
- ':smirk:' => array('smirk.gif', '19', '19', 'smirk'),
- ':roll:' => array('rolleyes.gif', '19', '19', 'rolleyes'),
- ':-S' => array('confused.gif', '19', '19', 'confused'),
- ':wow:' => array('surprise.gif', '19', '19', 'surprised'),
- ':bug:' => array('bigsurprise.gif', '19', '19', 'big surprise'),
- ':-P' => array('tongue_laugh.gif', '19', '19', 'tongue laugh'),
- '%-P' => array('tongue_rolleye.gif', '19', '19', 'tongue rolleye'),
- ';-P' => array('tongue_wink.gif', '19', '19', 'tongue wink'),
- ':P' => array('raspberry.gif', '19', '19', 'raspberry'),
- ':blank:' => array('blank.gif', '19', '19', 'blank stare'),
- ':long:' => array('longface.gif', '19', '19', 'long face'),
- ':ohh:' => array('ohh.gif', '19', '19', 'ohh'),
- ':grrr:' => array('grrr.gif', '19', '19', 'grrr'),
- ':gulp:' => array('gulp.gif', '19', '19', 'gulp'),
- '8-/' => array('ohoh.gif', '19', '19', 'oh oh'),
- ':down:' => array('downer.gif', '19', '19', 'downer'),
- ':red:' => array('embarrassed.gif', '19', '19', 'red face'),
- ':sick:' => array('sick.gif', '19', '19', 'sick'),
- ':shut:' => array('shuteye.gif', '19', '19', 'shut eye'),
- ':-/' => array('hmm.gif', '19', '19', 'hmmm'),
- '>:(' => array('mad.gif', '19', '19', 'mad'),
- ':mad:' => array('mad.gif', '19', '19', 'mad'),
- '>:-(' => array('angry.gif', '19', '19', 'angry'),
- ':angry:' => array('angry.gif', '19', '19', 'angry'),
- ':zip:' => array('zip.gif', '19', '19', 'zipper'),
- ':kiss:' => array('kiss.gif', '19', '19', 'kiss'),
- ':ahhh:' => array('shock.gif', '19', '19', 'shock'),
- ':coolsmile:' => array('shade_smile.gif', '19', '19', 'cool smile'),
- ':coolsmirk:' => array('shade_smirk.gif', '19', '19', 'cool smirk'),
- ':coolgrin:' => array('shade_grin.gif', '19', '19', 'cool grin'),
- ':coolhmm:' => array('shade_hmm.gif', '19', '19', 'cool hmm'),
- ':coolmad:' => array('shade_mad.gif', '19', '19', 'cool mad'),
- ':coolcheese:' => array('shade_cheese.gif', '19', '19', 'cool cheese'),
- ':vampire:' => array('vampire.gif', '19', '19', 'vampire'),
- ':snake:' => array('snake.gif', '19', '19', 'snake'),
- ':exclaim:' => array('exclaim.gif', '19', '19', 'excaim'),
- ':question:' => array('question.gif', '19', '19', 'question') // no comma after last item
-
- );
-
-/* End of file smileys.php */
+<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+/*
+| -------------------------------------------------------------------
+| SMILEYS
+| -------------------------------------------------------------------
+| This file contains an array of smileys for use with the emoticon helper.
+| Individual images can be used to replace multiple simileys. For example:
+| :-) and :) use the same image replacement.
+|
+| Please see user guide for more info:
+| http://codeigniter.com/user_guide/helpers/smiley_helper.html
+|
+*/
+
+$smileys = array(
+
+// smiley image name width height alt
+
+ ':-)' => array('grin.gif', '19', '19', 'grin'),
+ ':lol:' => array('lol.gif', '19', '19', 'LOL'),
+ ':cheese:' => array('cheese.gif', '19', '19', 'cheese'),
+ ':)' => array('smile.gif', '19', '19', 'smile'),
+ ';-)' => array('wink.gif', '19', '19', 'wink'),
+ ';)' => array('wink.gif', '19', '19', 'wink'),
+ ':smirk:' => array('smirk.gif', '19', '19', 'smirk'),
+ ':roll:' => array('rolleyes.gif', '19', '19', 'rolleyes'),
+ ':-S' => array('confused.gif', '19', '19', 'confused'),
+ ':wow:' => array('surprise.gif', '19', '19', 'surprised'),
+ ':bug:' => array('bigsurprise.gif', '19', '19', 'big surprise'),
+ ':-P' => array('tongue_laugh.gif', '19', '19', 'tongue laugh'),
+ '%-P' => array('tongue_rolleye.gif', '19', '19', 'tongue rolleye'),
+ ';-P' => array('tongue_wink.gif', '19', '19', 'tongue wink'),
+ ':P' => array('raspberry.gif', '19', '19', 'raspberry'),
+ ':blank:' => array('blank.gif', '19', '19', 'blank stare'),
+ ':long:' => array('longface.gif', '19', '19', 'long face'),
+ ':ohh:' => array('ohh.gif', '19', '19', 'ohh'),
+ ':grrr:' => array('grrr.gif', '19', '19', 'grrr'),
+ ':gulp:' => array('gulp.gif', '19', '19', 'gulp'),
+ '8-/' => array('ohoh.gif', '19', '19', 'oh oh'),
+ ':down:' => array('downer.gif', '19', '19', 'downer'),
+ ':red:' => array('embarrassed.gif', '19', '19', 'red face'),
+ ':sick:' => array('sick.gif', '19', '19', 'sick'),
+ ':shut:' => array('shuteye.gif', '19', '19', 'shut eye'),
+ ':-/' => array('hmm.gif', '19', '19', 'hmmm'),
+ '>:(' => array('mad.gif', '19', '19', 'mad'),
+ ':mad:' => array('mad.gif', '19', '19', 'mad'),
+ '>:-(' => array('angry.gif', '19', '19', 'angry'),
+ ':angry:' => array('angry.gif', '19', '19', 'angry'),
+ ':zip:' => array('zip.gif', '19', '19', 'zipper'),
+ ':kiss:' => array('kiss.gif', '19', '19', 'kiss'),
+ ':ahhh:' => array('shock.gif', '19', '19', 'shock'),
+ ':coolsmile:' => array('shade_smile.gif', '19', '19', 'cool smile'),
+ ':coolsmirk:' => array('shade_smirk.gif', '19', '19', 'cool smirk'),
+ ':coolgrin:' => array('shade_grin.gif', '19', '19', 'cool grin'),
+ ':coolhmm:' => array('shade_hmm.gif', '19', '19', 'cool hmm'),
+ ':coolmad:' => array('shade_mad.gif', '19', '19', 'cool mad'),
+ ':coolcheese:' => array('shade_cheese.gif', '19', '19', 'cool cheese'),
+ ':vampire:' => array('vampire.gif', '19', '19', 'vampire'),
+ ':snake:' => array('snake.gif', '19', '19', 'snake'),
+ ':exclaim:' => array('exclaim.gif', '19', '19', 'excaim'),
+ ':question:' => array('question.gif', '19', '19', 'question') // no comma after last item
+
+ );
+
+/* End of file smileys.php */
/* Location: ./system/application/config/smileys.php */ \ No newline at end of file
diff --git a/system/application/config/user_agents.php b/system/application/config/user_agents.php
index c01b2767d..eabd762f2 100644
--- a/system/application/config/user_agents.php
+++ b/system/application/config/user_agents.php
@@ -1,175 +1,175 @@
-<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
-/*
-| -------------------------------------------------------------------
-| USER AGENT TYPES
-| -------------------------------------------------------------------
-| This file contains four arrays of user agent data. It is used by the
-| User Agent Class to help identify browser, platform, robot, and
-| mobile device data. The array keys are used to identify the device
-| and the array values are used to set the actual name of the item.
-|
-*/
-
-$platforms = array (
- 'windows nt 6.0' => 'Windows Longhorn',
- 'windows nt 5.2' => 'Windows 2003',
- 'windows nt 5.0' => 'Windows 2000',
- 'windows nt 5.1' => 'Windows XP',
- 'windows nt 4.0' => 'Windows NT 4.0',
- 'winnt4.0' => 'Windows NT 4.0',
- 'winnt 4.0' => 'Windows NT',
- 'winnt' => 'Windows NT',
- 'windows 98' => 'Windows 98',
- 'win98' => 'Windows 98',
- 'windows 95' => 'Windows 95',
- 'win95' => 'Windows 95',
- 'windows' => 'Unknown Windows OS',
- 'os x' => 'Mac OS X',
- 'ppc mac' => 'Power PC Mac',
- 'freebsd' => 'FreeBSD',
- 'ppc' => 'Macintosh',
- 'linux' => 'Linux',
- 'debian' => 'Debian',
- 'sunos' => 'Sun Solaris',
- 'beos' => 'BeOS',
- 'apachebench' => 'ApacheBench',
- 'aix' => 'AIX',
- 'irix' => 'Irix',
- 'osf' => 'DEC OSF',
- 'hp-ux' => 'HP-UX',
- 'netbsd' => 'NetBSD',
- 'bsdi' => 'BSDi',
- 'openbsd' => 'OpenBSD',
- 'gnu' => 'GNU/Linux',
- 'unix' => 'Unknown Unix OS'
- );
-
-
-// The order of this array should NOT be changed. Many browsers return
-// multiple browser types so we want to identify the sub-type first.
-$browsers = array(
- 'Opera' => 'Opera',
- 'MSIE' => 'Internet Explorer',
- 'Internet Explorer' => 'Internet Explorer',
- 'Shiira' => 'Shiira',
- 'Firefox' => 'Firefox',
- 'Chimera' => 'Chimera',
- 'Phoenix' => 'Phoenix',
- 'Firebird' => 'Firebird',
- 'Camino' => 'Camino',
- 'Netscape' => 'Netscape',
- 'OmniWeb' => 'OmniWeb',
- 'Mozilla' => 'Mozilla',
- 'Safari' => 'Safari',
- 'Konqueror' => 'Konqueror',
- 'icab' => 'iCab',
- 'Lynx' => 'Lynx',
- 'Links' => 'Links',
- 'hotjava' => 'HotJava',
- 'amaya' => 'Amaya',
- 'IBrowse' => 'IBrowse'
- );
-
-$mobiles = array(
- // legacy array, old values commented out
- 'mobileexplorer' => 'Mobile Explorer',
-// 'openwave' => 'Open Wave',
-// 'opera mini' => 'Opera Mini',
-// 'operamini' => 'Opera Mini',
-// 'elaine' => 'Palm',
- 'palmsource' => 'Palm',
-// 'digital paths' => 'Palm',
-// 'avantgo' => 'Avantgo',
-// 'xiino' => 'Xiino',
- 'palmscape' => 'Palmscape',
-// 'nokia' => 'Nokia',
-// 'ericsson' => 'Ericsson',
-// 'blackberry' => 'BlackBerry',
-// 'motorola' => 'Motorola'
-
- // Phones and Manufacturers
- 'motorola' => "Motorola",
- 'nokia' => "Nokia",
- 'palm' => "Palm",
- 'iphone' => "Apple iPhone",
- 'ipod' => "Apple iPod Touch",
- 'sony' => "Sony Ericsson",
- 'ericsson' => "Sony Ericsson",
- 'blackberry' => "BlackBerry",
- 'cocoon' => "O2 Cocoon",
- 'blazer' => "Treo",
- 'lg' => "LG",
- 'amoi' => "Amoi",
- 'xda' => "XDA",
- 'mda' => "MDA",
- 'vario' => "Vario",
- 'htc' => "HTC",
- 'samsung' => "Samsung",
- 'sharp' => "Sharp",
- 'sie-' => "Siemens",
- 'alcatel' => "Alcatel",
- 'benq' => "BenQ",
- 'ipaq' => "HP iPaq",
- 'mot-' => "Motorola",
- 'playstation portable' => "PlayStation Portable",
- 'hiptop' => "Danger Hiptop",
- 'nec-' => "NEC",
- 'panasonic' => "Panasonic",
- 'philips' => "Philips",
- 'sagem' => "Sagem",
- 'sanyo' => "Sanyo",
- 'spv' => "SPV",
- 'zte' => "ZTE",
- 'sendo' => "Sendo",
-
- // Operating Systems
- 'symbian' => "Symbian",
- 'SymbianOS' => "SymbianOS",
- 'elaine' => "Palm",
- 'palm' => "Palm",
- 'series60' => "Symbian S60",
- 'windows ce' => "Windows CE",
-
- // Browsers
- 'obigo' => "Obigo",
- 'netfront' => "Netfront Browser",
- 'openwave' => "Openwave Browser",
- 'mobilexplorer' => "Mobile Explorer",
- 'operamini' => "Opera Mini",
- 'opera mini' => "Opera Mini",
-
- // Other
- 'digital paths' => "Digital Paths",
- 'avantgo' => "AvantGo",
- 'xiino' => "Xiino",
- 'novarra' => "Novarra Transcoder",
- 'vodafone' => "Vodafone",
- 'docomo' => "NTT DoCoMo",
- 'o2' => "O2",
-
- // Fallback
- 'mobile' => "Generic Mobile",
- 'wireless' => "Generic Mobile",
- 'j2me' => "Generic Mobile",
- 'midp' => "Generic Mobile",
- 'cldc' => "Generic Mobile",
- 'up.link' => "Generic Mobile",
- 'up.browser' => "Generic Mobile",
- 'smartphone' => "Generic Mobile",
- 'cellphone' => "Generic Mobile"
- );
-
-// There are hundreds of bots but these are the most common.
-$robots = array(
- 'googlebot' => 'Googlebot',
- 'msnbot' => 'MSNBot',
- 'slurp' => 'Inktomi Slurp',
- 'yahoo' => 'Yahoo',
- 'askjeeves' => 'AskJeeves',
- 'fastcrawler' => 'FastCrawler',
- 'infoseek' => 'InfoSeek Robot 1.0',
- 'lycos' => 'Lycos'
- );
-
-/* End of file user_agents.php */
+<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+/*
+| -------------------------------------------------------------------
+| USER AGENT TYPES
+| -------------------------------------------------------------------
+| This file contains four arrays of user agent data. It is used by the
+| User Agent Class to help identify browser, platform, robot, and
+| mobile device data. The array keys are used to identify the device
+| and the array values are used to set the actual name of the item.
+|
+*/
+
+$platforms = array (
+ 'windows nt 6.0' => 'Windows Longhorn',
+ 'windows nt 5.2' => 'Windows 2003',
+ 'windows nt 5.0' => 'Windows 2000',
+ 'windows nt 5.1' => 'Windows XP',
+ 'windows nt 4.0' => 'Windows NT 4.0',
+ 'winnt4.0' => 'Windows NT 4.0',
+ 'winnt 4.0' => 'Windows NT',
+ 'winnt' => 'Windows NT',
+ 'windows 98' => 'Windows 98',
+ 'win98' => 'Windows 98',
+ 'windows 95' => 'Windows 95',
+ 'win95' => 'Windows 95',
+ 'windows' => 'Unknown Windows OS',
+ 'os x' => 'Mac OS X',
+ 'ppc mac' => 'Power PC Mac',
+ 'freebsd' => 'FreeBSD',
+ 'ppc' => 'Macintosh',
+ 'linux' => 'Linux',
+ 'debian' => 'Debian',
+ 'sunos' => 'Sun Solaris',
+ 'beos' => 'BeOS',
+ 'apachebench' => 'ApacheBench',
+ 'aix' => 'AIX',
+ 'irix' => 'Irix',
+ 'osf' => 'DEC OSF',
+ 'hp-ux' => 'HP-UX',
+ 'netbsd' => 'NetBSD',
+ 'bsdi' => 'BSDi',
+ 'openbsd' => 'OpenBSD',
+ 'gnu' => 'GNU/Linux',
+ 'unix' => 'Unknown Unix OS'
+ );
+
+
+// The order of this array should NOT be changed. Many browsers return
+// multiple browser types so we want to identify the sub-type first.
+$browsers = array(
+ 'Opera' => 'Opera',
+ 'MSIE' => 'Internet Explorer',
+ 'Internet Explorer' => 'Internet Explorer',
+ 'Shiira' => 'Shiira',
+ 'Firefox' => 'Firefox',
+ 'Chimera' => 'Chimera',
+ 'Phoenix' => 'Phoenix',
+ 'Firebird' => 'Firebird',
+ 'Camino' => 'Camino',
+ 'Netscape' => 'Netscape',
+ 'OmniWeb' => 'OmniWeb',
+ 'Mozilla' => 'Mozilla',
+ 'Safari' => 'Safari',
+ 'Konqueror' => 'Konqueror',
+ 'icab' => 'iCab',
+ 'Lynx' => 'Lynx',
+ 'Links' => 'Links',
+ 'hotjava' => 'HotJava',
+ 'amaya' => 'Amaya',
+ 'IBrowse' => 'IBrowse'
+ );
+
+$mobiles = array(
+ // legacy array, old values commented out
+ 'mobileexplorer' => 'Mobile Explorer',
+// 'openwave' => 'Open Wave',
+// 'opera mini' => 'Opera Mini',
+// 'operamini' => 'Opera Mini',
+// 'elaine' => 'Palm',
+ 'palmsource' => 'Palm',
+// 'digital paths' => 'Palm',
+// 'avantgo' => 'Avantgo',
+// 'xiino' => 'Xiino',
+ 'palmscape' => 'Palmscape',
+// 'nokia' => 'Nokia',
+// 'ericsson' => 'Ericsson',
+// 'blackberry' => 'BlackBerry',
+// 'motorola' => 'Motorola'
+
+ // Phones and Manufacturers
+ 'motorola' => "Motorola",
+ 'nokia' => "Nokia",
+ 'palm' => "Palm",
+ 'iphone' => "Apple iPhone",
+ 'ipod' => "Apple iPod Touch",
+ 'sony' => "Sony Ericsson",
+ 'ericsson' => "Sony Ericsson",
+ 'blackberry' => "BlackBerry",
+ 'cocoon' => "O2 Cocoon",
+ 'blazer' => "Treo",
+ 'lg' => "LG",
+ 'amoi' => "Amoi",
+ 'xda' => "XDA",
+ 'mda' => "MDA",
+ 'vario' => "Vario",
+ 'htc' => "HTC",
+ 'samsung' => "Samsung",
+ 'sharp' => "Sharp",
+ 'sie-' => "Siemens",
+ 'alcatel' => "Alcatel",
+ 'benq' => "BenQ",
+ 'ipaq' => "HP iPaq",
+ 'mot-' => "Motorola",
+ 'playstation portable' => "PlayStation Portable",
+ 'hiptop' => "Danger Hiptop",
+ 'nec-' => "NEC",
+ 'panasonic' => "Panasonic",
+ 'philips' => "Philips",
+ 'sagem' => "Sagem",
+ 'sanyo' => "Sanyo",
+ 'spv' => "SPV",
+ 'zte' => "ZTE",
+ 'sendo' => "Sendo",
+
+ // Operating Systems
+ 'symbian' => "Symbian",
+ 'SymbianOS' => "SymbianOS",
+ 'elaine' => "Palm",
+ 'palm' => "Palm",
+ 'series60' => "Symbian S60",
+ 'windows ce' => "Windows CE",
+
+ // Browsers
+ 'obigo' => "Obigo",
+ 'netfront' => "Netfront Browser",
+ 'openwave' => "Openwave Browser",
+ 'mobilexplorer' => "Mobile Explorer",
+ 'operamini' => "Opera Mini",
+ 'opera mini' => "Opera Mini",
+
+ // Other
+ 'digital paths' => "Digital Paths",
+ 'avantgo' => "AvantGo",
+ 'xiino' => "Xiino",
+ 'novarra' => "Novarra Transcoder",
+ 'vodafone' => "Vodafone",
+ 'docomo' => "NTT DoCoMo",
+ 'o2' => "O2",
+
+ // Fallback
+ 'mobile' => "Generic Mobile",
+ 'wireless' => "Generic Mobile",
+ 'j2me' => "Generic Mobile",
+ 'midp' => "Generic Mobile",
+ 'cldc' => "Generic Mobile",
+ 'up.link' => "Generic Mobile",
+ 'up.browser' => "Generic Mobile",
+ 'smartphone' => "Generic Mobile",
+ 'cellphone' => "Generic Mobile"
+ );
+
+// There are hundreds of bots but these are the most common.
+$robots = array(
+ 'googlebot' => 'Googlebot',
+ 'msnbot' => 'MSNBot',
+ 'slurp' => 'Inktomi Slurp',
+ 'yahoo' => 'Yahoo',
+ 'askjeeves' => 'AskJeeves',
+ 'fastcrawler' => 'FastCrawler',
+ 'infoseek' => 'InfoSeek Robot 1.0',
+ 'lycos' => 'Lycos'
+ );
+
+/* End of file user_agents.php */
/* Location: ./system/application/config/user_agents.php */ \ No newline at end of file
diff --git a/system/application/errors/error_404.php b/system/application/errors/error_404.php
index bfe9444b2..cad737596 100644
--- a/system/application/errors/error_404.php
+++ b/system/application/errors/error_404.php
@@ -1,35 +1,35 @@
-<?php header("HTTP/1.1 404 Not Found"); ?>
-<html>
-<head>
-<title>404 Page Not Found</title>
-<style type="text/css">
-
-body {
-background-color: #fff;
-margin: 40px;
-font-family: Lucida Grande, Verdana, Sans-serif;
-font-size: 12px;
-color: #000;
-}
-
-#content {
-border: #999 1px solid;
-background-color: #fff;
-padding: 20px 20px 12px 20px;
-}
-
-h1 {
-font-weight: normal;
-font-size: 14px;
-color: #990000;
-margin: 0 0 4px 0;
-}
-</style>
-</head>
-<body>
- <div id="content">
- <h1><?php echo $heading; ?></h1>
- <?php echo $message; ?>
- </div>
-</body>
+<?php header("HTTP/1.1 404 Not Found"); ?>
+<html>
+<head>
+<title>404 Page Not Found</title>
+<style type="text/css">
+
+body {
+background-color: #fff;
+margin: 40px;
+font-family: Lucida Grande, Verdana, Sans-serif;
+font-size: 12px;
+color: #000;
+}
+
+#content {
+border: #999 1px solid;
+background-color: #fff;
+padding: 20px 20px 12px 20px;
+}
+
+h1 {
+font-weight: normal;
+font-size: 14px;
+color: #990000;
+margin: 0 0 4px 0;
+}
+</style>
+</head>
+<body>
+ <div id="content">
+ <h1><?php echo $heading; ?></h1>
+ <?php echo $message; ?>
+ </div>
+</body>
</html> \ No newline at end of file
diff --git a/system/application/errors/error_db.php b/system/application/errors/error_db.php
index 1ce52dfc9..71a4b98d8 100644
--- a/system/application/errors/error_db.php
+++ b/system/application/errors/error_db.php
@@ -1,34 +1,34 @@
-<html>
-<head>
-<title>Database Error</title>
-<style type="text/css">
-
-body {
-background-color: #fff;
-margin: 40px;
-font-family: Lucida Grande, Verdana, Sans-serif;
-font-size: 12px;
-color: #000;
-}
-
-#content {
-border: #999 1px solid;
-background-color: #fff;
-padding: 20px 20px 12px 20px;
-}
-
-h1 {
-font-weight: normal;
-font-size: 14px;
-color: #990000;
-margin: 0 0 4px 0;
-}
-</style>
-</head>
-<body>
- <div id="content">
- <h1><?php echo $heading; ?></h1>
- <?php echo $message; ?>
- </div>
-</body>
+<html>
+<head>
+<title>Database Error</title>
+<style type="text/css">
+
+body {
+background-color: #fff;
+margin: 40px;
+font-family: Lucida Grande, Verdana, Sans-serif;
+font-size: 12px;
+color: #000;
+}
+
+#content {
+border: #999 1px solid;
+background-color: #fff;
+padding: 20px 20px 12px 20px;
+}
+
+h1 {
+font-weight: normal;
+font-size: 14px;
+color: #990000;
+margin: 0 0 4px 0;
+}
+</style>
+</head>
+<body>
+ <div id="content">
+ <h1><?php echo $heading; ?></h1>
+ <?php echo $message; ?>
+ </div>
+</body>
</html> \ No newline at end of file
diff --git a/system/application/errors/error_general.php b/system/application/errors/error_general.php
index d8610702b..8545286f9 100644
--- a/system/application/errors/error_general.php
+++ b/system/application/errors/error_general.php
@@ -1,34 +1,34 @@
-<html>
-<head>
-<title>Error</title>
-<style type="text/css">
-
-body {
-background-color: #fff;
-margin: 40px;
-font-family: Lucida Grande, Verdana, Sans-serif;
-font-size: 12px;
-color: #000;
-}
-
-#content {
-border: #999 1px solid;
-background-color: #fff;
-padding: 20px 20px 12px 20px;
-}
-
-h1 {
-font-weight: normal;
-font-size: 14px;
-color: #990000;
-margin: 0 0 4px 0;
-}
-</style>
-</head>
-<body>
- <div id="content">
- <h1><?php echo $heading; ?></h1>
- <?php echo $message; ?>
- </div>
-</body>
+<html>
+<head>
+<title>Error</title>
+<style type="text/css">
+
+body {
+background-color: #fff;
+margin: 40px;
+font-family: Lucida Grande, Verdana, Sans-serif;
+font-size: 12px;
+color: #000;
+}
+
+#content {
+border: #999 1px solid;
+background-color: #fff;
+padding: 20px 20px 12px 20px;
+}
+
+h1 {
+font-weight: normal;
+font-size: 14px;
+color: #990000;
+margin: 0 0 4px 0;
+}
+</style>
+</head>
+<body>
+ <div id="content">
+ <h1><?php echo $heading; ?></h1>
+ <?php echo $message; ?>
+ </div>
+</body>
</html> \ No newline at end of file
diff --git a/system/application/errors/error_php.php b/system/application/errors/error_php.php
index f085c2037..f5941c96f 100644
--- a/system/application/errors/error_php.php
+++ b/system/application/errors/error_php.php
@@ -1,10 +1,10 @@
-<div style="border:1px solid #990000;padding-left:20px;margin:0 0 10px 0;">
-
-<h4>A PHP Error was encountered</h4>
-
-<p>Severity: <?php echo $severity; ?></p>
-<p>Message: <?php echo $message; ?></p>
-<p>Filename: <?php echo $filepath; ?></p>
-<p>Line Number: <?php echo $line; ?></p>
-
+<div style="border:1px solid #990000;padding-left:20px;margin:0 0 10px 0;">
+
+<h4>A PHP Error was encountered</h4>
+
+<p>Severity: <?php echo $severity; ?></p>
+<p>Message: <?php echo $message; ?></p>
+<p>Filename: <?php echo $filepath; ?></p>
+<p>Line Number: <?php echo $line; ?></p>
+
</div> \ No newline at end of file
diff --git a/system/helpers/compatibility_helper.php b/system/helpers/compatibility_helper.php
index 3b37cea02..996a6d7ea 100644
--- a/system/helpers/compatibility_helper.php
+++ b/system/helpers/compatibility_helper.php
@@ -1,498 +1,498 @@
-<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
-/**
- * CodeIgniter
- *
- * An open source application development framework for PHP 4.3.2 or newer
- *
- * @package CodeIgniter
- * @author ExpressionEngine Dev Team
- * @copyright Copyright (c) 2008, EllisLab, Inc.
- * @license http://codeigniter.com/user_guide/license.html
- * @link http://codeigniter.com
- * @since Version 1.0
- * @filesource
- */
-
-// ------------------------------------------------------------------------
-
-/**
- * CodeIgniter Compatibility Helpers
- *
- * This helper contains some functions based on the PEAR PHP_Compat library
- * http://pear.php.net/package/PHP_Compat
- *
- * The PEAR compat library is a little bloated and the code doesn't harmonize
- * well with CodeIgniter, so those functions have been refactored.
- * We cheat a little and use CI's _exception_handler() to output our own PHP errors
- * so that the behavior fully mimicks the PHP 5 counterparts. -- Derek Jones
- *
- * @package CodeIgniter
- * @subpackage Helpers
- * @category Helpers
- * @author ExpressionEngine Dev Team
- * @link http://codeigniter.com/user_guide/helpers/compatibility_helper.html
- */
-
-// ------------------------------------------------------------------------
-
-if ( ! defined('PHP_EOL'))
-{
- define('PHP_EOL', (DIRECTORY_SEPARATOR == '/') ? "\n" : "\r\n");
-}
-
-// ------------------------------------------------------------------------
-
-/**
- * file_put_contents()
- *
- * Writes a string to a file
- * http://us.php.net/manual/en/function.file_put_contents.php
- * argument 4, $context, not supported
- *
- * @access public
- * @param string file name
- * @param mixed data to be written
- * @param int flags
- * @return int length of written string
- */
-if ( ! function_exists('file_put_contents'))
-{
- function file_put_contents($filename, $data, $flags = NULL)
- {
- if (is_scalar($data))
- {
- settype($data, 'STRING');
- }
-
- if ( ! is_string($data) && ! is_array($data) && ! is_resource($data))
- {
- $backtrace = debug_backtrace();
- _exception_handler(E_USER_WARNING, 'file_put_contents(): the 2nd parameter should be either a string or an array', $backtrace[0]['file'], $backtrace[0]['line']);
- return FALSE;
- }
-
- // read stream if given a stream resource
- if (is_resource($data))
- {
- if (get_resource_type($data) !== 'stream')
- {
- $backtrace = debug_backtrace();
- _exception_handler(E_USER_WARNING, 'file_put_contents(): supplied resource is not a valid stream resource', $backtrace[0]['file'], $backtrace[0]['line']);
- return FALSE;
- }
-
- $text = '';
-
- while ( ! feof($data))
- {
- $text .= fread($data, 4096);
- }
-
- $data = $text;
- unset($text);
- }
-
- // strings only please!
- if (is_array($data))
- {
- $data = implode('', $data);
- }
-
- // Set the appropriate mode
- if (($flags & 8) > 0) // 8 = FILE_APPEND flag
- {
- $mode = FOPEN_WRITE_CREATE;
- }
- else
- {
- $mode = FOPEN_WRITE_CREATE_DESTRUCTIVE;
- }
-
- // Check if we're using the include path
- if (($flags & 1) > 0) // 1 = FILE_USE_INCLUDE_PATH flag
- {
- $use_include_path = TRUE;
- }
- else
- {
- $use_include_path = FALSE;
- }
-
- $fp = @fopen($filename, $mode, $use_include_path);
-
- if ($fp === FALSE)
- {
- $backtrace = debug_backtrace();
- _exception_handler(E_USER_WARNING, 'file_put_contents('.htmlentities($filename).') failed to open stream', $backtrace[0]['file'], $backtrace[0]['line']);
- return FALSE;
- }
-
- if (($flags & LOCK_EX) > 0)
- {
- if ( ! flock($fp, LOCK_EX))
- {
- $backtrace = debug_backtrace();
- _exception_handler(E_USER_WARNING, 'file_put_contents('.htmlentities($filename).') unable to acquire an exclusive lock on file', $backtrace[0]['file'], $backtrace[0]['line']);
- return FALSE;
- }
- }
-
- // write it
- if (($written = @fwrite($fp, $data)) === FALSE)
- {
- $backtrace = debug_backtrace();
- _exception_handler(E_USER_WARNING, 'file_put_contents('.htmlentities($filename).') failed to write to '.htmlentities($filename), $backtrace[0]['file'], $backtrace[0]['line']);
- }
-
- // Close the handle
- @fclose($fp);
-
- // Return length
- return $written;
- }
-}
-
-// ------------------------------------------------------------------------
-
-/**
- * fputcsv()
- *
- * Format line as CSV and write to file pointer
- * http://us.php.net/manual/en/function.fputcsv.php
- *
- * @access public
- * @param resource file pointer
- * @param array data to be written
- * @param string delimiter
- * @param string enclosure
- * @return int length of written string
- */
-if ( ! function_exists('fputcsv'))
-{
- function fputcsv($handle, $fields, $delimiter = ',', $enclosure = '"')
- {
- // Checking for a handle resource
- if ( ! is_resource($handle))
- {
- $backtrace = debug_backtrace();
- _exception_handler(E_USER_WARNING, 'fputcsv() expects parameter 1 to be stream resource, '.gettype($handle).' given', $backtrace[0]['file'], $backtrace[0]['line']);
- return FALSE;
- }
-
- // OK, it is a resource, but is it a stream?
- if (get_resource_type($handle) !== 'stream')
- {
- $backtrace = debug_backtrace();
- _exception_handler(E_USER_WARNING, 'fputcsv() expects parameter 1 to be stream resource, '.get_resource_type($handle).' given', $backtrace[0]['file'], $backtrace[0]['line']);
- return FALSE;
- }
-
- // Checking for an array of fields
- if ( ! is_array($fields))
- {
- $backtrace = debug_backtrace();
- _exception_handler(E_USER_WARNING, 'fputcsv() expects parameter 2 to be array, '.gettype($fields).' given', $backtrace[0]['file'], $backtrace[0]['line']);
- return FALSE;
- }
-
- // validate delimiter
- if (strlen($delimiter) > 1)
- {
- $delimiter = substr($delimiter, 0, 1);
- $backtrace = debug_backtrace();
- _exception_handler(E_NOTICE, 'fputcsv() delimiter must be one character long, "'.htmlentities($delimiter).'" used', $backtrace[0]['file'], $backtrace[0]['line']);
- }
-
- // validate enclosure
- if (strlen($enclosure) > 1)
- {
- $enclosure = substr($enclosure, 0, 1);
- $backtrace = debug_backtrace();
- _exception_handler(E_NOTICE, 'fputcsv() enclosure must be one character long, "'.htmlentities($enclosure).'" used', $backtrace[0]['file'], $backtrace[0]['line']);
-
- }
-
- $out = '';
-
- foreach ($fields as $cell)
- {
- $cell = str_replace($enclosure, $enclosure.$enclosure, $cell);
-
- if (strpos($cell, $delimiter) !== FALSE OR strpos($cell, $enclosure) !== FALSE OR strpos($cell, "\n") !== FALSE)
- {
- $out .= $enclosure.$cell.$enclosure.$delimiter;
- }
- else
- {
- $out .= $cell.$delimiter;
- }
- }
-
- $length = @fwrite($handle, substr($out, 0, -1)."\n");
-
- return $length;
- }
-}
-
-// ------------------------------------------------------------------------
-
-/**
- * stripos()
- *
- * Find position of first occurrence of a case-insensitive string
- * http://us.php.net/manual/en/function.stripos.php
- *
- * @access public
- * @param string haystack
- * @param string needle
- * @param int offset
- * @return int numeric position of the first occurrence of needle in the haystack
- */
-if ( ! function_exists('stripos'))
-{
- function stripos($haystack, $needle, $offset = NULL)
- {
- // Cast non string scalar values
- if (is_scalar($haystack))
- {
- settype($haystack, 'STRING');
- }
-
- if ( ! is_string($haystack))
- {
- $backtrace = debug_backtrace();
- _exception_handler(E_USER_WARNING, 'stripos() expects parameter 1 to be string, '.gettype($haystack).' given', $backtrace[0]['file'], $backtrace[0]['line']);
- return FALSE;
- }
-
- if ( ! is_scalar($needle))
- {
- $backtrace = debug_backtrace();
- _exception_handler(E_USER_WARNING, 'stripos() needle is not a string or an integer in '.$backtrace[0]['file'], $backtrace[0]['line']);
- return FALSE;
- }
-
- if (is_float($offset))
- {
- $offset = (int)$offset;
- }
-
- if ( ! is_int($offset) && ! is_bool($offset) && ! is_null($offset))
- {
- $backtrace = debug_backtrace();
- _exception_handler(E_USER_WARNING, 'stripos() expects parameter 3 to be long, '.gettype($offset).' given', $backtrace[0]['file'], $backtrace[0]['line']);
- return NULL;
- }
-
- return strpos(strtolower($haystack), strtolower($needle), $offset);
- }
-}
-
-// ------------------------------------------------------------------------
-
-/**
- * str_ireplace()
- *
- * Find position of first occurrence of a case-insensitive string
- * http://us.php.net/manual/en/function.str-ireplace.php
- * (parameter 4, $count, is not supported as to do so in PHP 4 would make
- * it a required parameter)
- *
- * @access public
- * @param mixed search
- * @param mixed replace
- * @param mixed subject
- * @return int numeric position of the first occurrence of needle in the haystack
- */
-if ( ! function_exists('str_ireplace'))
-{
- function str_ireplace($search, $replace, $subject)
- {
- // Nothing to do here
- if ($search === NULL OR $subject === NULL)
- {
- return $subject;
- }
-
- // Crazy arguments
- if (is_scalar($search) && is_array($replace))
- {
- $backtrace = debug_backtrace();
-
- if (is_object($replace))
- {
- show_error('Object of class '.get_class($replace).' could not be converted to string in '.$backtrace[0]['file'].' on line '.$backtrace[0]['line']);
- }
- else
- {
- _exception_handler(E_USER_NOTICE, 'Array to string conversion in '.$backtrace[0]['file'], $backtrace[0]['line']);
- }
- }
-
- // Searching for an array
- if (is_array($search))
- {
- // Replacing with an array
- if (is_array($replace))
- {
- $search = array_values($search);
- $replace = array_values($replace);
-
- if (count($search) >= count($replace))
- {
- $replace = array_pad($replace, count($search), '');
- }
- else
- {
- $replace = array_slice($replace, 0, count($search));
- }
- }
- else
- {
- // Replacing with a string all positions
- $replace = array_fill(0, count($search), $replace);
- }
- }
- else
- {
- //Searching for a string and replacing with a string.
- $search = array((string)$search);
- $replace = array((string)$replace);
- }
-
- // Prepare the search array
- foreach ($search as $search_key => $search_value)
- {
- $search[$search_key] = '/'.preg_quote($search_value, '/').'/i';
- }
-
- // Prepare the replace array (escape backreferences)
- foreach ($replace as $k => $v)
- {
- $replace[$k] = str_replace(array(chr(92), '$'), array(chr(92).chr(92), '\$'), $v);
- }
-
- // do the replacement
- $result = preg_replace($search, $replace, (array)$subject);
-
- // Check if subject was initially a string and return it as a string
- if ( ! is_array($subject))
- {
- return current($result);
- }
-
- // Otherwise, just return the array
- return $result;
- }
-}
-
-// ------------------------------------------------------------------------
-
-/**
- * http_build_query()
- *
- * Generate URL-encoded query string
- * http://us.php.net/manual/en/function.http-build-query.php
- *
- * @access public
- * @param array form data
- * @param string numeric prefix
- * @param string argument separator
- * @return string URL-encoded string
- */
-if ( ! function_exists('http_build_query'))
-{
- function http_build_query($formdata, $numeric_prefix = NULL, $separator = NULL)
- {
- // Check the data
- if ( ! is_array($formdata) && ! is_object($formdata))
- {
- $backtrace = debug_backtrace();
- _exception_handler(E_USER_WARNING, 'http_build_query() Parameter 1 expected to be Array or Object. Incorrect value given', $backtrace[0]['file'], $backtrace[0]['line']);
- return FALSE;
- }
-
- // Cast it as array
- if (is_object($formdata))
- {
- $formdata = get_object_vars($formdata);
- }
-
- // If the array is empty, return NULL
- if (empty($formdata))
- {
- return NULL;
- }
-
- // Argument separator
- if ($separator === NULL)
- {
- $separator = ini_get('arg_separator.output');
-
- if (strlen($separator) == 0)
- {
- $separator = '&';
- }
- }
-
- // Start building the query
- $tmp = array();
-
- foreach ($formdata as $key => $val)
- {
- if ($val === NULL)
- {
- continue;
- }
-
- if (is_integer($key) && $numeric_prefix != NULL)
- {
- $key = $numeric_prefix.$key;
- }
-
- if (is_resource($val))
- {
- return NULL;
- }
-
- // hand it off to a recursive parser
- $tmp[] = _http_build_query_helper($key, $val, $separator);
- }
-
- return implode($separator, $tmp);
- }
-
-
- // Helper helper. Remind anyone of college?
- // Required to handle recursion in nested arrays.
- //
- // You could shave fractions of fractions of a second by moving where
- // the urlencoding takes place, but it's much less intuitive, and if
- // your application has 10,000 form fields, well, you have other problems ;)
- function _http_build_query_helper($key, $val, $separator = '&')
- {
- if (is_scalar($val))
- {
- return urlencode($key).'='.urlencode($val);
- }
- else
- {
- // arrays please
- if (is_object($val))
- {
- $val = get_object_vars($val);
- }
-
- foreach ($val as $k => $v)
- {
- $tmp[] = _http_build_query_helper($key.'['.$k.']', $v, $separator);
- }
- }
-
- return implode($separator, $tmp);
- }
-}
-
-
-/* End of file compatibility_helper.php */
+<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+/**
+ * CodeIgniter
+ *
+ * An open source application development framework for PHP 4.3.2 or newer
+ *
+ * @package CodeIgniter
+ * @author ExpressionEngine Dev Team
+ * @copyright Copyright (c) 2008, EllisLab, Inc.
+ * @license http://codeigniter.com/user_guide/license.html
+ * @link http://codeigniter.com
+ * @since Version 1.0
+ * @filesource
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+ * CodeIgniter Compatibility Helpers
+ *
+ * This helper contains some functions based on the PEAR PHP_Compat library
+ * http://pear.php.net/package/PHP_Compat
+ *
+ * The PEAR compat library is a little bloated and the code doesn't harmonize
+ * well with CodeIgniter, so those functions have been refactored.
+ * We cheat a little and use CI's _exception_handler() to output our own PHP errors
+ * so that the behavior fully mimicks the PHP 5 counterparts. -- Derek Jones
+ *
+ * @package CodeIgniter
+ * @subpackage Helpers
+ * @category Helpers
+ * @author ExpressionEngine Dev Team
+ * @link http://codeigniter.com/user_guide/helpers/compatibility_helper.html
+ */
+
+// ------------------------------------------------------------------------
+
+if ( ! defined('PHP_EOL'))
+{
+ define('PHP_EOL', (DIRECTORY_SEPARATOR == '/') ? "\n" : "\r\n");
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * file_put_contents()
+ *
+ * Writes a string to a file
+ * http://us.php.net/manual/en/function.file_put_contents.php
+ * argument 4, $context, not supported
+ *
+ * @access public
+ * @param string file name
+ * @param mixed data to be written
+ * @param int flags
+ * @return int length of written string
+ */
+if ( ! function_exists('file_put_contents'))
+{
+ function file_put_contents($filename, $data, $flags = NULL)
+ {
+ if (is_scalar($data))
+ {
+ settype($data, 'STRING');
+ }
+
+ if ( ! is_string($data) && ! is_array($data) && ! is_resource($data))
+ {
+ $backtrace = debug_backtrace();
+ _exception_handler(E_USER_WARNING, 'file_put_contents(): the 2nd parameter should be either a string or an array', $backtrace[0]['file'], $backtrace[0]['line']);
+ return FALSE;
+ }
+
+ // read stream if given a stream resource
+ if (is_resource($data))
+ {
+ if (get_resource_type($data) !== 'stream')
+ {
+ $backtrace = debug_backtrace();
+ _exception_handler(E_USER_WARNING, 'file_put_contents(): supplied resource is not a valid stream resource', $backtrace[0]['file'], $backtrace[0]['line']);
+ return FALSE;
+ }
+
+ $text = '';
+
+ while ( ! feof($data))
+ {
+ $text .= fread($data, 4096);
+ }
+
+ $data = $text;
+ unset($text);
+ }
+
+ // strings only please!
+ if (is_array($data))
+ {
+ $data = implode('', $data);
+ }
+
+ // Set the appropriate mode
+ if (($flags & 8) > 0) // 8 = FILE_APPEND flag
+ {
+ $mode = FOPEN_WRITE_CREATE;
+ }
+ else
+ {
+ $mode = FOPEN_WRITE_CREATE_DESTRUCTIVE;
+ }
+
+ // Check if we're using the include path
+ if (($flags & 1) > 0) // 1 = FILE_USE_INCLUDE_PATH flag
+ {
+ $use_include_path = TRUE;
+ }
+ else
+ {
+ $use_include_path = FALSE;
+ }
+
+ $fp = @fopen($filename, $mode, $use_include_path);
+
+ if ($fp === FALSE)
+ {
+ $backtrace = debug_backtrace();
+ _exception_handler(E_USER_WARNING, 'file_put_contents('.htmlentities($filename).') failed to open stream', $backtrace[0]['file'], $backtrace[0]['line']);
+ return FALSE;
+ }
+
+ if (($flags & LOCK_EX) > 0)
+ {
+ if ( ! flock($fp, LOCK_EX))
+ {
+ $backtrace = debug_backtrace();
+ _exception_handler(E_USER_WARNING, 'file_put_contents('.htmlentities($filename).') unable to acquire an exclusive lock on file', $backtrace[0]['file'], $backtrace[0]['line']);
+ return FALSE;
+ }
+ }
+
+ // write it
+ if (($written = @fwrite($fp, $data)) === FALSE)
+ {
+ $backtrace = debug_backtrace();
+ _exception_handler(E_USER_WARNING, 'file_put_contents('.htmlentities($filename).') failed to write to '.htmlentities($filename), $backtrace[0]['file'], $backtrace[0]['line']);
+ }
+
+ // Close the handle
+ @fclose($fp);
+
+ // Return length
+ return $written;
+ }
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * fputcsv()
+ *
+ * Format line as CSV and write to file pointer
+ * http://us.php.net/manual/en/function.fputcsv.php
+ *
+ * @access public
+ * @param resource file pointer
+ * @param array data to be written
+ * @param string delimiter
+ * @param string enclosure
+ * @return int length of written string
+ */
+if ( ! function_exists('fputcsv'))
+{
+ function fputcsv($handle, $fields, $delimiter = ',', $enclosure = '"')
+ {
+ // Checking for a handle resource
+ if ( ! is_resource($handle))
+ {
+ $backtrace = debug_backtrace();
+ _exception_handler(E_USER_WARNING, 'fputcsv() expects parameter 1 to be stream resource, '.gettype($handle).' given', $backtrace[0]['file'], $backtrace[0]['line']);
+ return FALSE;
+ }
+
+ // OK, it is a resource, but is it a stream?
+ if (get_resource_type($handle) !== 'stream')
+ {
+ $backtrace = debug_backtrace();
+ _exception_handler(E_USER_WARNING, 'fputcsv() expects parameter 1 to be stream resource, '.get_resource_type($handle).' given', $backtrace[0]['file'], $backtrace[0]['line']);
+ return FALSE;
+ }
+
+ // Checking for an array of fields
+ if ( ! is_array($fields))
+ {
+ $backtrace = debug_backtrace();
+ _exception_handler(E_USER_WARNING, 'fputcsv() expects parameter 2 to be array, '.gettype($fields).' given', $backtrace[0]['file'], $backtrace[0]['line']);
+ return FALSE;
+ }
+
+ // validate delimiter
+ if (strlen($delimiter) > 1)
+ {
+ $delimiter = substr($delimiter, 0, 1);
+ $backtrace = debug_backtrace();
+ _exception_handler(E_NOTICE, 'fputcsv() delimiter must be one character long, "'.htmlentities($delimiter).'" used', $backtrace[0]['file'], $backtrace[0]['line']);
+ }
+
+ // validate enclosure
+ if (strlen($enclosure) > 1)
+ {
+ $enclosure = substr($enclosure, 0, 1);
+ $backtrace = debug_backtrace();
+ _exception_handler(E_NOTICE, 'fputcsv() enclosure must be one character long, "'.htmlentities($enclosure).'" used', $backtrace[0]['file'], $backtrace[0]['line']);
+
+ }
+
+ $out = '';
+
+ foreach ($fields as $cell)
+ {
+ $cell = str_replace($enclosure, $enclosure.$enclosure, $cell);
+
+ if (strpos($cell, $delimiter) !== FALSE OR strpos($cell, $enclosure) !== FALSE OR strpos($cell, "\n") !== FALSE)
+ {
+ $out .= $enclosure.$cell.$enclosure.$delimiter;
+ }
+ else
+ {
+ $out .= $cell.$delimiter;
+ }
+ }
+
+ $length = @fwrite($handle, substr($out, 0, -1)."\n");
+
+ return $length;
+ }
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * stripos()
+ *
+ * Find position of first occurrence of a case-insensitive string
+ * http://us.php.net/manual/en/function.stripos.php
+ *
+ * @access public
+ * @param string haystack
+ * @param string needle
+ * @param int offset
+ * @return int numeric position of the first occurrence of needle in the haystack
+ */
+if ( ! function_exists('stripos'))
+{
+ function stripos($haystack, $needle, $offset = NULL)
+ {
+ // Cast non string scalar values
+ if (is_scalar($haystack))
+ {
+ settype($haystack, 'STRING');
+ }
+
+ if ( ! is_string($haystack))
+ {
+ $backtrace = debug_backtrace();
+ _exception_handler(E_USER_WARNING, 'stripos() expects parameter 1 to be string, '.gettype($haystack).' given', $backtrace[0]['file'], $backtrace[0]['line']);
+ return FALSE;
+ }
+
+ if ( ! is_scalar($needle))
+ {
+ $backtrace = debug_backtrace();
+ _exception_handler(E_USER_WARNING, 'stripos() needle is not a string or an integer in '.$backtrace[0]['file'], $backtrace[0]['line']);
+ return FALSE;
+ }
+
+ if (is_float($offset))
+ {
+ $offset = (int)$offset;
+ }
+
+ if ( ! is_int($offset) && ! is_bool($offset) && ! is_null($offset))
+ {
+ $backtrace = debug_backtrace();
+ _exception_handler(E_USER_WARNING, 'stripos() expects parameter 3 to be long, '.gettype($offset).' given', $backtrace[0]['file'], $backtrace[0]['line']);
+ return NULL;
+ }
+
+ return strpos(strtolower($haystack), strtolower($needle), $offset);
+ }
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * str_ireplace()
+ *
+ * Find position of first occurrence of a case-insensitive string
+ * http://us.php.net/manual/en/function.str-ireplace.php
+ * (parameter 4, $count, is not supported as to do so in PHP 4 would make
+ * it a required parameter)
+ *
+ * @access public
+ * @param mixed search
+ * @param mixed replace
+ * @param mixed subject
+ * @return int numeric position of the first occurrence of needle in the haystack
+ */
+if ( ! function_exists('str_ireplace'))
+{
+ function str_ireplace($search, $replace, $subject)
+ {
+ // Nothing to do here
+ if ($search === NULL OR $subject === NULL)
+ {
+ return $subject;
+ }
+
+ // Crazy arguments
+ if (is_scalar($search) && is_array($replace))
+ {
+ $backtrace = debug_backtrace();
+
+ if (is_object($replace))
+ {
+ show_error('Object of class '.get_class($replace).' could not be converted to string in '.$backtrace[0]['file'].' on line '.$backtrace[0]['line']);
+ }
+ else
+ {
+ _exception_handler(E_USER_NOTICE, 'Array to string conversion in '.$backtrace[0]['file'], $backtrace[0]['line']);
+ }
+ }
+
+ // Searching for an array
+ if (is_array($search))
+ {
+ // Replacing with an array
+ if (is_array($replace))
+ {
+ $search = array_values($search);
+ $replace = array_values($replace);
+
+ if (count($search) >= count($replace))
+ {
+ $replace = array_pad($replace, count($search), '');
+ }
+ else
+ {
+ $replace = array_slice($replace, 0, count($search));
+ }
+ }
+ else
+ {
+ // Replacing with a string all positions
+ $replace = array_fill(0, count($search), $replace);
+ }
+ }
+ else
+ {
+ //Searching for a string and replacing with a string.
+ $search = array((string)$search);
+ $replace = array((string)$replace);
+ }
+
+ // Prepare the search array
+ foreach ($search as $search_key => $search_value)
+ {
+ $search[$search_key] = '/'.preg_quote($search_value, '/').'/i';
+ }
+
+ // Prepare the replace array (escape backreferences)
+ foreach ($replace as $k => $v)
+ {
+ $replace[$k] = str_replace(array(chr(92), '$'), array(chr(92).chr(92), '\$'), $v);
+ }
+
+ // do the replacement
+ $result = preg_replace($search, $replace, (array)$subject);
+
+ // Check if subject was initially a string and return it as a string
+ if ( ! is_array($subject))
+ {
+ return current($result);
+ }
+
+ // Otherwise, just return the array
+ return $result;
+ }
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * http_build_query()
+ *
+ * Generate URL-encoded query string
+ * http://us.php.net/manual/en/function.http-build-query.php
+ *
+ * @access public
+ * @param array form data
+ * @param string numeric prefix
+ * @param string argument separator
+ * @return string URL-encoded string
+ */
+if ( ! function_exists('http_build_query'))
+{
+ function http_build_query($formdata, $numeric_prefix = NULL, $separator = NULL)
+ {
+ // Check the data
+ if ( ! is_array($formdata) && ! is_object($formdata))
+ {
+ $backtrace = debug_backtrace();
+ _exception_handler(E_USER_WARNING, 'http_build_query() Parameter 1 expected to be Array or Object. Incorrect value given', $backtrace[0]['file'], $backtrace[0]['line']);
+ return FALSE;
+ }
+
+ // Cast it as array
+ if (is_object($formdata))
+ {
+ $formdata = get_object_vars($formdata);
+ }
+
+ // If the array is empty, return NULL
+ if (empty($formdata))
+ {
+ return NULL;
+ }
+
+ // Argument separator
+ if ($separator === NULL)
+ {
+ $separator = ini_get('arg_separator.output');
+
+ if (strlen($separator) == 0)
+ {
+ $separator = '&';
+ }
+ }
+
+ // Start building the query
+ $tmp = array();
+
+ foreach ($formdata as $key => $val)
+ {
+ if ($val === NULL)
+ {
+ continue;
+ }
+
+ if (is_integer($key) && $numeric_prefix != NULL)
+ {
+ $key = $numeric_prefix.$key;
+ }
+
+ if (is_resource($val))
+ {
+ return NULL;
+ }
+
+ // hand it off to a recursive parser
+ $tmp[] = _http_build_query_helper($key, $val, $separator);
+ }
+
+ return implode($separator, $tmp);
+ }
+
+
+ // Helper helper. Remind anyone of college?
+ // Required to handle recursion in nested arrays.
+ //
+ // You could shave fractions of fractions of a second by moving where
+ // the urlencoding takes place, but it's much less intuitive, and if
+ // your application has 10,000 form fields, well, you have other problems ;)
+ function _http_build_query_helper($key, $val, $separator = '&')
+ {
+ if (is_scalar($val))
+ {
+ return urlencode($key).'='.urlencode($val);
+ }
+ else
+ {
+ // arrays please
+ if (is_object($val))
+ {
+ $val = get_object_vars($val);
+ }
+
+ foreach ($val as $k => $v)
+ {
+ $tmp[] = _http_build_query_helper($key.'['.$k.']', $v, $separator);
+ }
+ }
+
+ return implode($separator, $tmp);
+ }
+}
+
+
+/* End of file compatibility_helper.php */
/* Location: ./system/helpers/compatibility_helper.php */ \ No newline at end of file
diff --git a/system/helpers/html_helper.php b/system/helpers/html_helper.php
index e552b86b4..cc34b6530 100644
--- a/system/helpers/html_helper.php
+++ b/system/helpers/html_helper.php
@@ -1,416 +1,416 @@
-<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
-/**
- * CodeIgniter
- *
- * An open source application development framework for PHP 4.3.2 or newer
- *
- * @package CodeIgniter
- * @author ExpressionEngine Dev Team
- * @copyright Copyright (c) 2008, EllisLab, Inc.
- * @license http://codeigniter.com/user_guide/license.html
- * @link http://codeigniter.com
- * @since Version 1.0
- * @filesource
- */
-
-// ------------------------------------------------------------------------
-
-/**
- * CodeIgniter HTML Helpers
- *
- * @package CodeIgniter
- * @subpackage Helpers
- * @category Helpers
- * @author ExpressionEngine Dev Team
- * @link http://codeigniter.com/user_guide/helpers/html_helper.html
- */
-
-// ------------------------------------------------------------------------
-
-/**
- * Heading
- *
- * Generates an HTML heading tag. First param is the data.
- * Second param is the size of the heading tag.
- *
- * @access public
- * @param string
- * @param integer
- * @return string
- */
-if ( ! function_exists('heading'))
-{
- function heading($data = '', $h = '1')
- {
- return "<h".$h.">".$data."</h".$h.">";
- }
-}
-
-// ------------------------------------------------------------------------
-
-/**
- * Unordered List
- *
- * Generates an HTML unordered list from an single or multi-dimensional array.
- *
- * @access public
- * @param array
- * @param mixed
- * @return string
- */
-if ( ! function_exists('ul'))
-{
- function ul($list, $attributes = '')
- {
- return _list('ul', $list, $attributes);
- }
-}
-
-// ------------------------------------------------------------------------
-
-/**
- * Ordered List
- *
- * Generates an HTML ordered list from an single or multi-dimensional array.
- *
- * @access public
- * @param array
- * @param mixed
- * @return string
- */
-if ( ! function_exists('ol'))
-{
- function ol($list, $attributes = '')
- {
- return _list('ol', $list, $attributes);
- }
-}
-
-// ------------------------------------------------------------------------
-
-/**
- * Generates the list
- *
- * Generates an HTML ordered list from an single or multi-dimensional array.
- *
- * @access private
- * @param string
- * @param mixed
- * @param mixed
- * @param intiger
- * @return string
- */
-if ( ! function_exists('_list'))
-{
- function _list($type = 'ul', $list, $attributes = '', $depth = 0)
- {
- // If an array wasn't submitted there's nothing to do...
- if ( ! is_array($list))
- {
- return $list;
- }
-
- // Set the indentation based on the depth
- $out = str_repeat(" ", $depth);
-
- // Were any attributes submitted? If so generate a string
- if (is_array($attributes))
- {
- $atts = '';
- foreach ($attributes as $key => $val)
- {
- $atts .= ' ' . $key . '="' . $val . '"';
- }
- $attributes = $atts;
- }
-
- // Write the opening list tag
- $out .= "<".$type.$attributes.">\n";
-
- // Cycle through the list elements. If an array is
- // encountered we will recursively call _list()
-
- static $_last_list_item = '';
- foreach ($list as $key => $val)
- {
- $_last_list_item = $key;
-
- $out .= str_repeat(" ", $depth + 2);
- $out .= "<li>";
-
- if ( ! is_array($val))
- {
- $out .= $val;
- }
- else
- {
- $out .= $_last_list_item."\n";
- $out .= _list($type, $val, '', $depth + 4);
- $out .= str_repeat(" ", $depth + 2);
- }
-
- $out .= "</li>\n";
- }
-
- // Set the indentation for the closing tag
- $out .= str_repeat(" ", $depth);
-
- // Write the closing list tag
- $out .= "</".$type.">\n";
-
- return $out;
- }
-}
-
-// ------------------------------------------------------------------------
-
-/**
- * Generates HTML BR tags based on number supplied
- *
- * @access public
- * @param integer
- * @return string
- */
-if ( ! function_exists('br'))
-{
- function br($num = 1)
- {
- return str_repeat("<br />", $num);
- }
-}
-
-// ------------------------------------------------------------------------
-
-/**
- * Image
- *
- * Generates an <img /> element
- *
- * @access public
- * @param mixed
- * @return string
- */
-if ( ! function_exists('img'))
-{
- function img($src = '', $index_page = FALSE)
- {
- if ( ! is_array($src) )
- {
- $src = array('src' => $src);
- }
-
- $img = '<img';
-
- foreach ($src as $k=>$v)
- {
-
- if ($k == 'src' AND strpos($v, '://') === FALSE)
- {
- $CI =& get_instance();
-
- if ($index_page === TRUE)
- {
- $img .= ' src="'.$CI->config->site_url($v).'" ';
- }
- else
- {
- $img .= ' src="'.$CI->config->slash_item('base_url').$v.'" ';
- }
- }
- else
- {
- $img .= " $k=\"$v\" ";
- }
- }
-
- $img .= '/>';
-
- return $img;
- }
-}
-
-// ------------------------------------------------------------------------
-
-/**
- * Doctype
- *
- * Generates a page document type declaration
- *
- * Valid options are xhtml-11, xhtml-strict, xhtml-trans, xhtml-frame,
- * html4-strict, html4-trans, and html4-frame. Values are saved in the
- * doctypes config file.
- *
- * @access public
- * @param string type The doctype to be generated
- * @return string
- */
-if ( ! function_exists('doctype'))
-{
- function doctype($type = 'xhtml-strict')
- {
- global $_doctypes;
-
- if ( ! is_array($_doctypes))
- {
- if ( ! require_once(APPPATH.'config/doctypes.php'))
- {
- return FALSE;
- }
- }
-
- if (isset($_doctypes[$type]))
- {
- return $_doctypes[$type];
- }
- else
- {
- return FALSE;
- }
- }
-}
-
-// ------------------------------------------------------------------------
-
-/**
- * Link
- *
- * Generates link to a CSS file
- *
- * @access public
- * @param mixed stylesheet hrefs or an array
- * @param string rel
- * @param string type
- * @param string title
- * @param string media
- * @param boolean should index_page be added to the css path
- * @return string
- */
-if ( ! function_exists('link_tag'))
-{
- function link_tag($href = '', $rel = 'stylesheet', $type = 'text/css', $title = '', $media = '', $index_page = FALSE)
- {
- $CI =& get_instance();
-
- $link = '<link ';
-
- if (is_array($href))
- {
- foreach ($href as $k=>$v)
- {
- if ($k == 'href' AND strpos($v, '://') === FALSE)
- {
- if ($index_page === TRUE)
- {
- $link .= ' href="'.$CI->config->site_url($v).'" ';
- }
- else
- {
- $link .= ' href="'.$CI->config->slash_item('base_url').$v.'" ';
- }
- }
- else
- {
- $link .= "$k=\"$v\" ";
- }
- }
-
- $link .= "/>";
- }
- else
- {
- if ( strpos($href, '://') !== FALSE)
- {
- $link .= ' href="'.$href.'" ';
- }
- elseif ($index_page === TRUE)
- {
- $link .= ' href="'.$CI->config->site_url($href).'" ';
- }
- else
- {
- $link .= ' href="'.$CI->config->slash_item('base_url').$href.'" ';
- }
-
- $link .= 'rel="'.$rel.'" type="'.$type.'" ';
-
- if ($media != '')
- {
- $link .= 'media="'.$media.'" ';
- }
-
- if ($title != '')
- {
- $link .= 'title="'.$title.'" ';
- }
-
- $link .= '/>';
- }
-
-
- return $link;
- }
-}
-
-// ------------------------------------------------------------------------
-
-/**
- * Generates meta tags from an array of key/values
- *
- * @access public
- * @param array
- * @return string
- */
-if ( ! function_exists('meta'))
-{
- function meta($name = '', $content = '', $type = 'name', $newline = "\n")
- {
- // Since we allow the data to be passes as a string, a simple array
- // or a multidimensional one, we need to do a little prepping.
- if ( ! is_array($name))
- {
- $name = array(array('name' => $name, 'content' => $content, 'type' => $type, 'newline' => $newline));
- }
- else
- {
- // Turn single array into multidimensional
- if (isset($name['name']))
- {
- $name = array($name);
- }
- }
-
- $str = '';
- foreach ($name as $meta)
- {
- $type = ( ! isset($meta['type']) OR $meta['type'] == 'name') ? 'name' : 'http-equiv';
- $name = ( ! isset($meta['name'])) ? '' : $meta['name'];
- $content = ( ! isset($meta['content'])) ? '' : $meta['content'];
- $newline = ( ! isset($meta['newline'])) ? "\n" : $meta['newline'];
-
- $str .= '<meta '.$type.'="'.$name.'" content="'.$content.'" />'.$newline;
- }
-
- return $str;
- }
-}
-
-// ------------------------------------------------------------------------
-
-/**
- * Generates non-breaking space entities based on number supplied
- *
- * @access public
- * @param integer
- * @return string
- */
-if ( ! function_exists('nbs'))
-{
- function nbs($num = 1)
- {
- return str_repeat("&nbsp;", $num);
- }
-}
-
-
-/* End of file html_helper.php */
+<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+/**
+ * CodeIgniter
+ *
+ * An open source application development framework for PHP 4.3.2 or newer
+ *
+ * @package CodeIgniter
+ * @author ExpressionEngine Dev Team
+ * @copyright Copyright (c) 2008, EllisLab, Inc.
+ * @license http://codeigniter.com/user_guide/license.html
+ * @link http://codeigniter.com
+ * @since Version 1.0
+ * @filesource
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+ * CodeIgniter HTML Helpers
+ *
+ * @package CodeIgniter
+ * @subpackage Helpers
+ * @category Helpers
+ * @author ExpressionEngine Dev Team
+ * @link http://codeigniter.com/user_guide/helpers/html_helper.html
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+ * Heading
+ *
+ * Generates an HTML heading tag. First param is the data.
+ * Second param is the size of the heading tag.
+ *
+ * @access public
+ * @param string
+ * @param integer
+ * @return string
+ */
+if ( ! function_exists('heading'))
+{
+ function heading($data = '', $h = '1')
+ {
+ return "<h".$h.">".$data."</h".$h.">";
+ }
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * Unordered List
+ *
+ * Generates an HTML unordered list from an single or multi-dimensional array.
+ *
+ * @access public
+ * @param array
+ * @param mixed
+ * @return string
+ */
+if ( ! function_exists('ul'))
+{
+ function ul($list, $attributes = '')
+ {
+ return _list('ul', $list, $attributes);
+ }
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * Ordered List
+ *
+ * Generates an HTML ordered list from an single or multi-dimensional array.
+ *
+ * @access public
+ * @param array
+ * @param mixed
+ * @return string
+ */
+if ( ! function_exists('ol'))
+{
+ function ol($list, $attributes = '')
+ {
+ return _list('ol', $list, $attributes);
+ }
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * Generates the list
+ *
+ * Generates an HTML ordered list from an single or multi-dimensional array.
+ *
+ * @access private
+ * @param string
+ * @param mixed
+ * @param mixed
+ * @param intiger
+ * @return string
+ */
+if ( ! function_exists('_list'))
+{
+ function _list($type = 'ul', $list, $attributes = '', $depth = 0)
+ {
+ // If an array wasn't submitted there's nothing to do...
+ if ( ! is_array($list))
+ {
+ return $list;
+ }
+
+ // Set the indentation based on the depth
+ $out = str_repeat(" ", $depth);
+
+ // Were any attributes submitted? If so generate a string
+ if (is_array($attributes))
+ {
+ $atts = '';
+ foreach ($attributes as $key => $val)
+ {
+ $atts .= ' ' . $key . '="' . $val . '"';
+ }
+ $attributes = $atts;
+ }
+
+ // Write the opening list tag
+ $out .= "<".$type.$attributes.">\n";
+
+ // Cycle through the list elements. If an array is
+ // encountered we will recursively call _list()
+
+ static $_last_list_item = '';
+ foreach ($list as $key => $val)
+ {
+ $_last_list_item = $key;
+
+ $out .= str_repeat(" ", $depth + 2);
+ $out .= "<li>";
+
+ if ( ! is_array($val))
+ {
+ $out .= $val;
+ }
+ else
+ {
+ $out .= $_last_list_item."\n";
+ $out .= _list($type, $val, '', $depth + 4);
+ $out .= str_repeat(" ", $depth + 2);
+ }
+
+ $out .= "</li>\n";
+ }
+
+ // Set the indentation for the closing tag
+ $out .= str_repeat(" ", $depth);
+
+ // Write the closing list tag
+ $out .= "</".$type.">\n";
+
+ return $out;
+ }
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * Generates HTML BR tags based on number supplied
+ *
+ * @access public
+ * @param integer
+ * @return string
+ */
+if ( ! function_exists('br'))
+{
+ function br($num = 1)
+ {
+ return str_repeat("<br />", $num);
+ }
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * Image
+ *
+ * Generates an <img /> element
+ *
+ * @access public
+ * @param mixed
+ * @return string
+ */
+if ( ! function_exists('img'))
+{
+ function img($src = '', $index_page = FALSE)
+ {
+ if ( ! is_array($src) )
+ {
+ $src = array('src' => $src);
+ }
+
+ $img = '<img';
+
+ foreach ($src as $k=>$v)
+ {
+
+ if ($k == 'src' AND strpos($v, '://') === FALSE)
+ {
+ $CI =& get_instance();
+
+ if ($index_page === TRUE)
+ {
+ $img .= ' src="'.$CI->config->site_url($v).'" ';
+ }
+ else
+ {
+ $img .= ' src="'.$CI->config->slash_item('base_url').$v.'" ';
+ }
+ }
+ else
+ {
+ $img .= " $k=\"$v\" ";
+ }
+ }
+
+ $img .= '/>';
+
+ return $img;
+ }
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * Doctype
+ *
+ * Generates a page document type declaration
+ *
+ * Valid options are xhtml-11, xhtml-strict, xhtml-trans, xhtml-frame,
+ * html4-strict, html4-trans, and html4-frame. Values are saved in the
+ * doctypes config file.
+ *
+ * @access public
+ * @param string type The doctype to be generated
+ * @return string
+ */
+if ( ! function_exists('doctype'))
+{
+ function doctype($type = 'xhtml-strict')
+ {
+ global $_doctypes;
+
+ if ( ! is_array($_doctypes))
+ {
+ if ( ! require_once(APPPATH.'config/doctypes.php'))
+ {
+ return FALSE;
+ }
+ }
+
+ if (isset($_doctypes[$type]))
+ {
+ return $_doctypes[$type];
+ }
+ else
+ {
+ return FALSE;
+ }
+ }
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * Link
+ *
+ * Generates link to a CSS file
+ *
+ * @access public
+ * @param mixed stylesheet hrefs or an array
+ * @param string rel
+ * @param string type
+ * @param string title
+ * @param string media
+ * @param boolean should index_page be added to the css path
+ * @return string
+ */
+if ( ! function_exists('link_tag'))
+{
+ function link_tag($href = '', $rel = 'stylesheet', $type = 'text/css', $title = '', $media = '', $index_page = FALSE)
+ {
+ $CI =& get_instance();
+
+ $link = '<link ';
+
+ if (is_array($href))
+ {
+ foreach ($href as $k=>$v)
+ {
+ if ($k == 'href' AND strpos($v, '://') === FALSE)
+ {
+ if ($index_page === TRUE)
+ {
+ $link .= ' href="'.$CI->config->site_url($v).'" ';
+ }
+ else
+ {
+ $link .= ' href="'.$CI->config->slash_item('base_url').$v.'" ';
+ }
+ }
+ else
+ {
+ $link .= "$k=\"$v\" ";
+ }
+ }
+
+ $link .= "/>";
+ }
+ else
+ {
+ if ( strpos($href, '://') !== FALSE)
+ {
+ $link .= ' href="'.$href.'" ';
+ }
+ elseif ($index_page === TRUE)
+ {
+ $link .= ' href="'.$CI->config->site_url($href).'" ';
+ }
+ else
+ {
+ $link .= ' href="'.$CI->config->slash_item('base_url').$href.'" ';
+ }
+
+ $link .= 'rel="'.$rel.'" type="'.$type.'" ';
+
+ if ($media != '')
+ {
+ $link .= 'media="'.$media.'" ';
+ }
+
+ if ($title != '')
+ {
+ $link .= 'title="'.$title.'" ';
+ }
+
+ $link .= '/>';
+ }
+
+
+ return $link;
+ }
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * Generates meta tags from an array of key/values
+ *
+ * @access public
+ * @param array
+ * @return string
+ */
+if ( ! function_exists('meta'))
+{
+ function meta($name = '', $content = '', $type = 'name', $newline = "\n")
+ {
+ // Since we allow the data to be passes as a string, a simple array
+ // or a multidimensional one, we need to do a little prepping.
+ if ( ! is_array($name))
+ {
+ $name = array(array('name' => $name, 'content' => $content, 'type' => $type, 'newline' => $newline));
+ }
+ else
+ {
+ // Turn single array into multidimensional
+ if (isset($name['name']))
+ {
+ $name = array($name);
+ }
+ }
+
+ $str = '';
+ foreach ($name as $meta)
+ {
+ $type = ( ! isset($meta['type']) OR $meta['type'] == 'name') ? 'name' : 'http-equiv';
+ $name = ( ! isset($meta['name'])) ? '' : $meta['name'];
+ $content = ( ! isset($meta['content'])) ? '' : $meta['content'];
+ $newline = ( ! isset($meta['newline'])) ? "\n" : $meta['newline'];
+
+ $str .= '<meta '.$type.'="'.$name.'" content="'.$content.'" />'.$newline;
+ }
+
+ return $str;
+ }
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * Generates non-breaking space entities based on number supplied
+ *
+ * @access public
+ * @param integer
+ * @return string
+ */
+if ( ! function_exists('nbs'))
+{
+ function nbs($num = 1)
+ {
+ return str_repeat("&nbsp;", $num);
+ }
+}
+
+
+/* End of file html_helper.php */
/* Location: ./system/helpers/html_helper.php */ \ No newline at end of file
diff --git a/system/helpers/language_helper.php b/system/helpers/language_helper.php
index 2091fd41d..d90fe3195 100644
--- a/system/helpers/language_helper.php
+++ b/system/helpers/language_helper.php
@@ -1,58 +1,58 @@
-<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
-/**
- * CodeIgniter
- *
- * An open source application development framework for PHP 4.3.2 or newer
- *
- * @package CodeIgniter
- * @author ExpressionEngine Dev Team
- * @copyright Copyright (c) 2008, EllisLab, Inc.
- * @license http://codeigniter.com/user_guide/license.html
- * @link http://codeigniter.com
- * @since Version 1.0
- * @filesource
- */
-
-// ------------------------------------------------------------------------
-
-/**
- * CodeIgniter Language Helpers
- *
- * @package CodeIgniter
- * @subpackage Helpers
- * @category Helpers
- * @author ExpressionEngine Dev Team
- * @link http://codeigniter.com/user_guide/helpers/language_helper.html
- */
-
-// ------------------------------------------------------------------------
-
-/**
- * Lang
- *
- * Fetches a language variable and optionally outputs a form label
- *
- * @access public
- * @param string the language line
- * @param string the id of the form element
- * @return string
- */
-if ( ! function_exists('lang'))
-{
- function lang($line, $id = '')
- {
- $CI =& get_instance();
- $line = $CI->lang->line($line);
-
- if ($id != '')
- {
- $line = '<label for="'.$id.'">'.$line."</label>";
- }
-
- return $line;
- }
-}
-
-// ------------------------------------------------------------------------
-/* End of file language_helper.php */
+<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
+/**
+ * CodeIgniter
+ *
+ * An open source application development framework for PHP 4.3.2 or newer
+ *
+ * @package CodeIgniter
+ * @author ExpressionEngine Dev Team
+ * @copyright Copyright (c) 2008, EllisLab, Inc.
+ * @license http://codeigniter.com/user_guide/license.html
+ * @link http://codeigniter.com
+ * @since Version 1.0
+ * @filesource
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+ * CodeIgniter Language Helpers
+ *
+ * @package CodeIgniter
+ * @subpackage Helpers
+ * @category Helpers
+ * @author ExpressionEngine Dev Team
+ * @link http://codeigniter.com/user_guide/helpers/language_helper.html
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+ * Lang
+ *
+ * Fetches a language variable and optionally outputs a form label
+ *
+ * @access public
+ * @param string the language line
+ * @param string the id of the form element
+ * @return string
+ */
+if ( ! function_exists('lang'))
+{
+ function lang($line, $id = '')
+ {
+ $CI =& get_instance();
+ $line = $CI->lang->line($line);
+
+ if ($id != '')
+ {
+ $line = '<label for="'.$id.'">'.$line."</label>";
+ }
+
+ return $line;
+ }
+}
+
+// ------------------------------------------------------------------------
+/* End of file language_helper.php */
/* Location: ./system/helpers/language_helper.php */ \ No newline at end of file
diff --git a/system/language/english/profiler_lang.php b/system/language/english/profiler_lang.php
index 7c40e3f3e..4db55117c 100644
--- a/system/language/english/profiler_lang.php
+++ b/system/language/english/profiler_lang.php
@@ -1,19 +1,19 @@
-<?php
-
-$lang['profiler_database'] = 'DATABASE';
-$lang['profiler_controller_info'] = 'CLASS/METHOD';
-$lang['profiler_benchmarks'] = 'BENCHMARKS';
-$lang['profiler_queries'] = 'QUERIES';
-$lang['profiler_get_data'] = 'GET DATA';
-$lang['profiler_post_data'] = 'POST DATA';
-$lang['profiler_uri_string'] = 'URI STRING';
-$lang['profiler_memory_usage'] = 'MEMORY USAGE';
-$lang['profiler_no_db'] = 'Database driver is not currently loaded';
-$lang['profiler_no_queries'] = 'No queries were run';
-$lang['profiler_no_post'] = 'No POST data exists';
-$lang['profiler_no_get'] = 'No GET data exists';
-$lang['profiler_no_uri'] = 'No URI data exists';
-$lang['profiler_no_memory'] = 'Memory Usage Unavailable';
-
-/* End of file profiler_lang.php */
+<?php
+
+$lang['profiler_database'] = 'DATABASE';
+$lang['profiler_controller_info'] = 'CLASS/METHOD';
+$lang['profiler_benchmarks'] = 'BENCHMARKS';
+$lang['profiler_queries'] = 'QUERIES';
+$lang['profiler_get_data'] = 'GET DATA';
+$lang['profiler_post_data'] = 'POST DATA';
+$lang['profiler_uri_string'] = 'URI STRING';
+$lang['profiler_memory_usage'] = 'MEMORY USAGE';
+$lang['profiler_no_db'] = 'Database driver is not currently loaded';
+$lang['profiler_no_queries'] = 'No queries were run';
+$lang['profiler_no_post'] = 'No POST data exists';
+$lang['profiler_no_get'] = 'No GET data exists';
+$lang['profiler_no_uri'] = 'No URI data exists';
+$lang['profiler_no_memory'] = 'Memory Usage Unavailable';
+
+/* End of file profiler_lang.php */
/* Location: ./system/language/english/profiler_lang.php */ \ No newline at end of file
diff --git a/system/language/english/scaffolding_lang.php b/system/language/english/scaffolding_lang.php
index c4d54d5c6..7df297057 100644
--- a/system/language/english/scaffolding_lang.php
+++ b/system/language/english/scaffolding_lang.php
@@ -1,17 +1,17 @@
-<?php
-
-$lang['scaff_view_records'] = 'View Records';
-$lang['scaff_create_record'] = 'Create New Record';
-$lang['scaff_add'] = 'Add Data';
-$lang['scaff_view'] = 'View Data';
-$lang['scaff_edit'] = 'Edit';
-$lang['scaff_delete'] = 'Delete';
-$lang['scaff_view_all'] = 'View All';
-$lang['scaff_yes'] = 'Yes';
-$lang['scaff_no'] = 'No';
-$lang['scaff_no_data'] = 'No data exists for this table yet.';
-$lang['scaff_del_confirm'] = 'Are you sure you want to delete the following row:';
-
-
-/* End of file scaffolding_lang.php */
+<?php
+
+$lang['scaff_view_records'] = 'View Records';
+$lang['scaff_create_record'] = 'Create New Record';
+$lang['scaff_add'] = 'Add Data';
+$lang['scaff_view'] = 'View Data';
+$lang['scaff_edit'] = 'Edit';
+$lang['scaff_delete'] = 'Delete';
+$lang['scaff_view_all'] = 'View All';
+$lang['scaff_yes'] = 'Yes';
+$lang['scaff_no'] = 'No';
+$lang['scaff_no_data'] = 'No data exists for this table yet.';
+$lang['scaff_del_confirm'] = 'Are you sure you want to delete the following row:';
+
+
+/* End of file scaffolding_lang.php */
/* Location: ./system/language/english/scaffolding_lang.php */ \ No newline at end of file
diff --git a/system/libraries/Email.php b/system/libraries/Email.php
index ac9688247..e414d84ed 100644
--- a/system/libraries/Email.php
+++ b/system/libraries/Email.php
@@ -1,1955 +1,1955 @@
-<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
-/**
- * CodeIgniter
- *
- * An open source application development framework for PHP 4.3.2 or newer
- *
- * @package CodeIgniter
- * @author ExpressionEngine Dev Team
- * @copyright Copyright (c) 2008, EllisLab, Inc.
- * @license http://codeigniter.com/user_guide/license.html
- * @link http://codeigniter.com
- * @since Version 1.0
- * @filesource
- */
-
-// ------------------------------------------------------------------------
-
-/**
- * CodeIgniter Email Class
- *
- * Permits email to be sent using Mail, Sendmail, or SMTP.
- *
- * @package CodeIgniter
- * @subpackage Libraries
- * @category Libraries
- * @author ExpressionEngine Dev Team
- * @link http://codeigniter.com/user_guide/libraries/email.html
- */
-class CI_Email {
-
- var $useragent = "CodeIgniter";
- var $mailpath = "/usr/sbin/sendmail"; // Sendmail path
- var $protocol = "mail"; // mail/sendmail/smtp
- var $smtp_host = ""; // SMTP Server. Example: mail.earthlink.net
- var $smtp_user = ""; // SMTP Username
- var $smtp_pass = ""; // SMTP Password
- var $smtp_port = "25"; // SMTP Port
- var $smtp_timeout = 5; // SMTP Timeout in seconds
- var $wordwrap = TRUE; // TRUE/FALSE Turns word-wrap on/off
- var $wrapchars = "76"; // Number of characters to wrap at.
- var $mailtype = "text"; // text/html Defines email formatting
- var $charset = "utf-8"; // Default char set: iso-8859-1 or us-ascii
- var $multipart = "mixed"; // "mixed" (in the body) or "related" (separate)
- var $alt_message = ''; // Alternative message for HTML emails
- var $validate = FALSE; // TRUE/FALSE. Enables email validation
- var $priority = "3"; // Default priority (1 - 5)
- var $newline = "\n"; // Default newline. "\r\n" or "\n" (Use "\r\n" to comply with RFC 822)
- var $crlf = "\n"; // The RFC 2045 compliant CRLF for quoted-printable is "\r\n". Apparently some servers,
- // even on the receiving end think they need to muck with CRLFs, so using "\n", while
- // distasteful, is the only thing that seems to work for all environments.
- var $send_multipart = TRUE; // TRUE/FALSE - Yahoo does not like multipart alternative, so this is an override. Set to FALSE for Yahoo.
- var $bcc_batch_mode = FALSE; // TRUE/FALSE Turns on/off Bcc batch feature
- var $bcc_batch_size = 200; // If bcc_batch_mode = TRUE, sets max number of Bccs in each batch
- var $_safe_mode = FALSE;
- var $_subject = "";
- var $_body = "";
- var $_finalbody = "";
- var $_alt_boundary = "";
- var $_atc_boundary = "";
- var $_header_str = "";
- var $_smtp_connect = "";
- var $_encoding = "8bit";
- var $_IP = FALSE;
- var $_smtp_auth = FALSE;
- var $_replyto_flag = FALSE;
- var $_debug_msg = array();
- var $_recipients = array();
- var $_cc_array = array();
- var $_bcc_array = array();
- var $_headers = array();
- var $_attach_name = array();
- var $_attach_type = array();
- var $_attach_disp = array();
- var $_protocols = array('mail', 'sendmail', 'smtp');
- var $_base_charsets = array('us-ascii', 'iso-2022-'); // 7-bit charsets (excluding language suffix)
- var $_bit_depths = array('7bit', '8bit');
- var $_priorities = array('1 (Highest)', '2 (High)', '3 (Normal)', '4 (Low)', '5 (Lowest)');
-
-
- /**
- * Constructor - Sets Email Preferences
- *
- * The constructor can be passed an array of config values
- */
- function CI_Email($config = array())
- {
- if (count($config) > 0)
- {
- $this->initialize($config);
- }
- else
- {
- $this->_smtp_auth = ($this->smtp_user == '' AND $this->smtp_pass == '') ? FALSE : TRUE;
- $this->_safe_mode = ((boolean)@ini_get("safe_mode") === FALSE) ? FALSE : TRUE;
- }
-
- log_message('debug', "Email Class Initialized");
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Initialize preferences
- *
- * @access public
- * @param array
- * @return void
- */
- function initialize($config = array())
- {
- $this->clear();
- foreach ($config as $key => $val)
- {
- if (isset($this->$key))
- {
- $method = 'set_'.$key;
-
- if (method_exists($this, $method))
- {
- $this->$method($val);
- }
- else
- {
- $this->$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;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Initialize the Email Data
- *
- * @access public
- * @return void
- */
- function clear($clear_attachments = FALSE)
- {
- $this->_subject = "";
- $this->_body = "";
- $this->_finalbody = "";
- $this->_header_str = "";
- $this->_replyto_flag = FALSE;
- $this->_recipients = array();
- $this->_headers = array();
- $this->_debug_msg = array();
-
- $this->_set_header('User-Agent', $this->useragent);
- $this->_set_header('Date', $this->_set_date());
-
- if ($clear_attachments !== FALSE)
- {
- $this->_attach_name = array();
- $this->_attach_type = array();
- $this->_attach_disp = array();
- }
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Set FROM
- *
- * @access public
- * @param string
- * @param string
- * @return void
- */
- function from($from, $name = '')
- {
- if (preg_match( '/\<(.*)\>/', $from, $match))
- {
- $from = $match['1'];
- }
-
- if ($this->validate)
- {
- $this->validate_email($this->_str_to_array($from));
- }
-
- if ($name != '' && strncmp($name, '"', 1) != 0)
- {
- $name = '"'.$name.'"';
- }
-
- $this->_set_header('From', $name.' <'.$from.'>');
- $this->_set_header('Return-Path', '<'.$from.'>');
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Set Reply-to
- *
- * @access public
- * @param string
- * @param string
- * @return void
- */
- function reply_to($replyto, $name = '')
- {
- if (preg_match( '/\<(.*)\>/', $replyto, $match))
- {
- $replyto = $match['1'];
- }
-
- if ($this->validate)
- {
- $this->validate_email($this->_str_to_array($replyto));
- }
-
- if ($name == '')
- {
- $name = $replyto;
- }
-
- if (strncmp($name, '"', 1) != 0)
- {
- $name = '"'.$name.'"';
- }
-
- $this->_set_header('Reply-To', $name.' <'.$replyto.'>');
- $this->_replyto_flag = TRUE;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Set Recipients
- *
- * @access public
- * @param string
- * @return void
- */
- function to($to)
- {
- $to = $this->_str_to_array($to);
- $to = $this->clean_email($to);
-
- if ($this->validate)
- {
- $this->validate_email($to);
- }
-
- if ($this->_get_protocol() != 'mail')
- {
- $this->_set_header('To', implode(", ", $to));
- }
-
- switch ($this->_get_protocol())
- {
- case 'smtp' : $this->_recipients = $to;
- break;
- case 'sendmail' : $this->_recipients = implode(", ", $to);
- break;
- case 'mail' : $this->_recipients = implode(", ", $to);
- break;
- }
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Set CC
- *
- * @access public
- * @param string
- * @return void
- */
- function cc($cc)
- {
- $cc = $this->_str_to_array($cc);
- $cc = $this->clean_email($cc);
-
- if ($this->validate)
- {
- $this->validate_email($cc);
- }
-
- $this->_set_header('Cc', implode(", ", $cc));
-
- if ($this->_get_protocol() == "smtp")
- {
- $this->_cc_array = $cc;
- }
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Set BCC
- *
- * @access public
- * @param string
- * @param string
- * @return void
- */
- function bcc($bcc, $limit = '')
- {
- if ($limit != '' && is_numeric($limit))
- {
- $this->bcc_batch_mode = TRUE;
- $this->bcc_batch_size = $limit;
- }
-
- $bcc = $this->_str_to_array($bcc);
- $bcc = $this->clean_email($bcc);
-
- if ($this->validate)
- {
- $this->validate_email($bcc);
- }
-
- if (($this->_get_protocol() == "smtp") OR ($this->bcc_batch_mode && count($bcc) > $this->bcc_batch_size))
- {
- $this->_bcc_array = $bcc;
- }
- else
- {
- $this->_set_header('Bcc', implode(", ", $bcc));
- }
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Set Email Subject
- *
- * @access public
- * @param string
- * @return void
- */
- function subject($subject)
- {
- if (strpos($subject, "\r") !== FALSE OR strpos($subject, "\n") !== FALSE)
- {
- $subject = str_replace(array("\r\n", "\r", "\n"), '', $subject);
- }
-
- if (strpos($subject, "\t"))
- {
- $subject = str_replace("\t", ' ', $subject);
- }
-
- $this->_set_header('Subject', trim($subject));
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Set Body
- *
- * @access public
- * @param string
- * @return void
- */
- function message($body)
- {
- $this->_body = stripslashes(rtrim(str_replace("\r", "", $body)));
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Assign file attachments
- *
- * @access public
- * @param string
- * @return void
- */
- function attach($filename, $disposition = 'attachment')
- {
- $this->_attach_name[] = $filename;
- $this->_attach_type[] = $this->_mime_types(next(explode('.', basename($filename))));
- $this->_attach_disp[] = $disposition; // Can also be 'inline' Not sure if it matters
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Add a Header Item
- *
- * @access private
- * @param string
- * @param string
- * @return void
- */
- function _set_header($header, $value)
- {
- $this->_headers[$header] = $value;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Convert a String to an Array
- *
- * @access private
- * @param string
- * @return array
- */
- function _str_to_array($email)
- {
- if ( ! is_array($email))
- {
- if (strpos($email, ',') !== FALSE)
- {
- $email = preg_split('/[\s,]/', $email, -1, PREG_SPLIT_NO_EMPTY);
- }
- else
- {
- $email = trim($email);
- settype($email, "array");
- }
- }
- return $email;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Set Multipart Value
- *
- * @access public
- * @param string
- * @return void
- */
- function set_alt_message($str = '')
- {
- $this->alt_message = ($str == '') ? '' : $str;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Set Mailtype
- *
- * @access public
- * @param string
- * @return void
- */
- function set_mailtype($type = 'text')
- {
- $this->mailtype = ($type == 'html') ? 'html' : 'text';
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Set Wordwrap
- *
- * @access public
- * @param string
- * @return void
- */
- function set_wordwrap($wordwrap = TRUE)
- {
- $this->wordwrap = ($wordwrap === FALSE) ? FALSE : TRUE;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Set Protocol
- *
- * @access public
- * @param string
- * @return void
- */
- function set_protocol($protocol = 'mail')
- {
- $this->protocol = ( ! in_array($protocol, $this->_protocols, TRUE)) ? 'mail' : strtolower($protocol);
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Set Priority
- *
- * @access public
- * @param integer
- * @return void
- */
- function set_priority($n = 3)
- {
- if ( ! is_numeric($n))
- {
- $this->priority = 3;
- return;
- }
-
- if ($n < 1 OR $n > 5)
- {
- $this->priority = 3;
- return;
- }
-
- $this->priority = $n;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Set Newline Character
- *
- * @access public
- * @param string
- * @return void
- */
- function set_newline($newline = "\n")
- {
- if ($newline != "\n" AND $newline != "\r\n" AND $newline != "\r")
- {
- $this->newline = "\n";
- return;
- }
-
- $this->newline = $newline;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Set CRLF
- *
- * @access public
- * @param string
- * @return void
- */
- function set_crlf($crlf = "\n")
- {
- if ($crlf != "\n" AND $crlf != "\r\n" AND $crlf != "\r")
- {
- $this->crlf = "\n";
- return;
- }
-
- $this->crlf = $crlf;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Set Message Boundary
- *
- * @access private
- * @return void
- */
- function _set_boundaries()
- {
- $this->_alt_boundary = "B_ALT_".uniqid(''); // multipart/alternative
- $this->_atc_boundary = "B_ATC_".uniqid(''); // attachment boundary
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Get the Message ID
- *
- * @access private
- * @return string
- */
- function _get_message_id()
- {
- $from = $this->_headers['Return-Path'];
- $from = str_replace(">", "", $from);
- $from = str_replace("<", "", $from);
-
- return "<".uniqid('').strstr($from, '@').">";
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Get Mail Protocol
- *
- * @access private
- * @param bool
- * @return string
- */
- function _get_protocol($return = TRUE)
- {
- $this->protocol = strtolower($this->protocol);
- $this->protocol = ( ! in_array($this->protocol, $this->_protocols, TRUE)) ? 'mail' : $this->protocol;
-
- if ($return == TRUE)
- {
- return $this->protocol;
- }
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Get Mail Encoding
- *
- * @access private
- * @param bool
- * @return string
- */
- function _get_encoding($return = TRUE)
- {
- $this->_encoding = ( ! in_array($this->_encoding, $this->_bit_depths)) ? '8bit' : $this->_encoding;
-
- foreach ($this->_base_charsets as $charset)
- {
- if (strncmp($charset, $this->charset, strlen($charset)) == 0)
- {
- $this->_encoding = '7bit';
- }
- }
-
- if ($return == TRUE)
- {
- return $this->_encoding;
- }
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Get content type (text/html/attachment)
- *
- * @access private
- * @return string
- */
- function _get_content_type()
- {
- if ($this->mailtype == 'html' && count($this->_attach_name) == 0)
- {
- return 'html';
- }
- elseif ($this->mailtype == 'html' && count($this->_attach_name) > 0)
- {
- return 'html-attach';
- }
- elseif ($this->mailtype == 'text' && count($this->_attach_name) > 0)
- {
- return 'plain-attach';
- }
- else
- {
- return 'plain';
- }
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Set RFC 822 Date
- *
- * @access private
- * @return string
- */
- function _set_date()
- {
- $timezone = date("Z");
- $operator = (strncmp($timezone, '-', 1) == 0) ? '-' : '+';
- $timezone = abs($timezone);
- $timezone = floor($timezone/3600) * 100 + ($timezone % 3600 ) / 60;
-
- return sprintf("%s %s%04d", date("D, j M Y H:i:s"), $operator, $timezone);
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Mime message
- *
- * @access private
- * @return string
- */
- function _get_mime_message()
- {
- return "This is a multi-part message in MIME format.".$this->newline."Your email application may not support this format.";
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Validate Email Address
- *
- * @access public
- * @param string
- * @return bool
- */
- function validate_email($email)
- {
- if ( ! is_array($email))
- {
- $this->_set_error_message('email_must_be_array');
- return FALSE;
- }
-
- foreach ($email as $val)
- {
- if ( ! $this->valid_email($val))
- {
- $this->_set_error_message('email_invalid_address', $val);
- return FALSE;
- }
- }
-
- return TRUE;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Email Validation
- *
- * @access public
- * @param string
- * @return bool
- */
- function valid_email($address)
- {
- return ( ! preg_match("/^([a-z0-9\+_\-]+)(\.[a-z0-9\+_\-]+)*@([a-z0-9\-]+\.)+[a-z]{2,6}$/ix", $address)) ? FALSE : TRUE;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Clean Extended Email Address: Joe Smith <joe@smith.com>
- *
- * @access public
- * @param string
- * @return string
- */
- function clean_email($email)
- {
- if ( ! is_array($email))
- {
- if (preg_match('/\<(.*)\>/', $email, $match))
- {
- return $match['1'];
- }
- else
- {
- return $email;
- }
- }
-
- $clean_email = array();
-
- foreach ($email as $addy)
- {
- if (preg_match( '/\<(.*)\>/', $addy, $match))
- {
- $clean_email[] = $match['1'];
- }
- else
- {
- $clean_email[] = $addy;
- }
- }
-
- return $clean_email;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Build alternative plain text message
- *
- * This 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()
- {
- if ($this->alt_message != "")
- {
- return $this->word_wrap($this->alt_message, '76');
- }
-
- if (preg_match('/\<body.*?\>(.*)\<\/body\>/si', $this->_body, $match))
- {
- $body = $match['1'];
- }
- else
- {
- $body = $this->_body;
- }
-
- $body = trim(strip_tags($body));
- $body = preg_replace( '#<!--(.*)--\>#', "", $body);
- $body = str_replace("\t", "", $body);
-
- for ($i = 20; $i >= 3; $i--)
- {
- $n = "";
-
- for ($x = 1; $x <= $i; $x ++)
- {
- $n .= "\n";
- }
-
- $body = str_replace($n, "\n\n", $body);
- }
-
- return $this->word_wrap($body, '76');
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Word Wrap
- *
- * @access public
- * @param string
- * @param integer
- * @return string
- */
- function word_wrap($str, $charlim = '')
- {
- // Se the character limit
- if ($charlim == '')
- {
- $charlim = ($this->wrapchars == "") ? "76" : $this->wrapchars;
- }
-
- // Reduce multiple spaces
- $str = preg_replace("| +|", " ", $str);
-
- // Standardize newlines
- if (strpos($str, "\r") !== FALSE)
- {
- $str = str_replace(array("\r\n", "\r"), "\n", $str);
- }
-
- // If the current word is surrounded by {unwrap} tags we'll
- // strip the entire chunk and replace it with a marker.
- $unwrap = array();
- if (preg_match_all("|(\{unwrap\}.+?\{/unwrap\})|s", $str, $matches))
- {
- for ($i = 0; $i < count($matches['0']); $i++)
- {
- $unwrap[] = $matches['1'][$i];
- $str = str_replace($matches['1'][$i], "{{unwrapped".$i."}}", $str);
- }
- }
-
- // Use PHP's native 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);
-
- // Split the string into individual lines of text and cycle through them
- $output = "";
- foreach (explode("\n", $str) as $line)
- {
- // Is the line within the allowed character count?
- // If so we'll join it to the output and continue
- if (strlen($line) <= $charlim)
- {
- $output .= $line.$this->newline;
- continue;
- }
-
- $temp = '';
- while((strlen($line)) > $charlim)
- {
- // If the over-length word is a URL we won't wrap it
- if (preg_match("!\[url.+\]|://|wwww.!", $line))
- {
- break;
- }
-
- // Trim the word down
- $temp .= substr($line, 0, $charlim-1);
- $line = substr($line, $charlim-1);
- }
-
- // If $temp contains data it means we had to split up an over-length
- // word into smaller chunks so we'll add it back to our current line
- if ($temp != '')
- {
- $output .= $temp.$this->newline.$line;
- }
- else
- {
- $output .= $line;
- }
-
- $output .= $this->newline;
- }
-
- // Put our markers back
- if (count($unwrap) > 0)
- {
- foreach ($unwrap as $key => $val)
- {
- $output = str_replace("{{unwrapped".$key."}}", $val, $output);
- }
- }
-
- return $output;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Build final headers
- *
- * @access private
- * @param string
- * @return string
- */
- function _build_headers()
- {
- $this->_set_header('X-Sender', $this->clean_email($this->_headers['From']));
- $this->_set_header('X-Mailer', $this->useragent);
- $this->_set_header('X-Priority', $this->_priorities[$this->priority - 1]);
- $this->_set_header('Message-ID', $this->_get_message_id());
- $this->_set_header('Mime-Version', '1.0');
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Write Headers as a string
- *
- * @access private
- * @return void
- */
- function _write_headers()
- {
- if ($this->protocol == 'mail')
- {
- $this->_subject = $this->_headers['Subject'];
- unset($this->_headers['Subject']);
- }
-
- reset($this->_headers);
- $this->_header_str = "";
-
- foreach($this->_headers as $key => $val)
- {
- $val = trim($val);
-
- if ($val != "")
- {
- $this->_header_str .= $key.": ".$val.$this->newline;
- }
- }
-
- if ($this->_get_protocol() == 'mail')
- {
- $this->_header_str = substr($this->_header_str, 0, -1);
- }
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Build Final Body and attachments
- *
- * @access private
- * @return void
- */
- function _build_message()
- {
- if ($this->wordwrap === TRUE AND $this->mailtype != 'html')
- {
- $this->_body = $this->word_wrap($this->_body);
- }
-
- $this->_set_boundaries();
- $this->_write_headers();
-
- $hdr = ($this->_get_protocol() == 'mail') ? $this->newline : '';
-
- switch ($this->_get_content_type())
- {
- case 'plain' :
-
- $hdr .= "Content-Type: text/plain; charset=" . $this->charset . $this->newline;
- $hdr .= "Content-Transfer-Encoding: " . $this->_get_encoding();
-
- if ($this->_get_protocol() == 'mail')
- {
- $this->_header_str .= $hdr;
- $this->_finalbody = $this->_body;
-
- return;
- }
-
- $hdr .= $this->newline . $this->newline . $this->_body;
-
- $this->_finalbody = $hdr;
- return;
-
- break;
- case 'html' :
-
- if ($this->send_multipart === FALSE)
- {
- $hdr .= "Content-Type: text/html; charset=" . $this->charset . $this->newline;
- $hdr .= "Content-Transfer-Encoding: quoted-printable";
- }
- else
- {
- $hdr .= "Content-Type: multipart/alternative; boundary=\"" . $this->_alt_boundary . "\"" . $this->newline;
- $hdr .= $this->_get_mime_message() . $this->newline . $this->newline;
- $hdr .= "--" . $this->_alt_boundary . $this->newline;
-
- $hdr .= "Content-Type: text/plain; charset=" . $this->charset . $this->newline;
- $hdr .= "Content-Transfer-Encoding: " . $this->_get_encoding() . $this->newline . $this->newline;
- $hdr .= $this->_get_alt_message() . $this->newline . $this->newline . "--" . $this->_alt_boundary . $this->newline;
-
- $hdr .= "Content-Type: text/html; charset=" . $this->charset . $this->newline;
- $hdr .= "Content-Transfer-Encoding: quoted-printable";
- }
-
- $this->_body = $this->_prep_quoted_printable($this->_body);
-
- if ($this->_get_protocol() == 'mail')
- {
- $this->_header_str .= $hdr;
- $this->_finalbody = $this->_body . $this->newline . $this->newline;
-
- if ($this->send_multipart !== FALSE)
- {
- $this->_finalbody .= "--" . $this->_alt_boundary . "--";
- }
-
- return;
- }
-
- $hdr .= $this->newline . $this->newline;
- $hdr .= $this->_body . $this->newline . $this->newline;
-
- if ($this->send_multipart !== FALSE)
- {
- $hdr .= "--" . $this->_alt_boundary . "--";
- }
-
- $this->_finalbody = $hdr;
- return;
-
- break;
- case 'plain-attach' :
-
- $hdr .= "Content-Type: multipart/".$this->multipart."; boundary=\"" . $this->_atc_boundary."\"" . $this->newline;
- $hdr .= $this->_get_mime_message() . $this->newline . $this->newline;
- $hdr .= "--" . $this->_atc_boundary . $this->newline;
-
- $hdr .= "Content-Type: text/plain; charset=" . $this->charset . $this->newline;
- $hdr .= "Content-Transfer-Encoding: " . $this->_get_encoding();
-
- if ($this->_get_protocol() == 'mail')
- {
- $this->_header_str .= $hdr;
-
- $body = $this->_body . $this->newline . $this->newline;
- }
-
- $hdr .= $this->newline . $this->newline;
- $hdr .= $this->_body . $this->newline . $this->newline;
-
- break;
- case 'html-attach' :
-
- $hdr .= "Content-Type: multipart/".$this->multipart."; boundary=\"" . $this->_atc_boundary."\"" . $this->newline;
- $hdr .= $this->_get_mime_message() . $this->newline . $this->newline;
- $hdr .= "--" . $this->_atc_boundary . $this->newline;
-
- $hdr .= "Content-Type: multipart/alternative; boundary=\"" . $this->_alt_boundary . "\"" . $this->newline .$this->newline;
- $hdr .= "--" . $this->_alt_boundary . $this->newline;
-
- $hdr .= "Content-Type: text/plain; charset=" . $this->charset . $this->newline;
- $hdr .= "Content-Transfer-Encoding: " . $this->_get_encoding() . $this->newline . $this->newline;
- $hdr .= $this->_get_alt_message() . $this->newline . $this->newline . "--" . $this->_alt_boundary . $this->newline;
-
- $hdr .= "Content-Type: text/html; charset=" . $this->charset . $this->newline;
- $hdr .= "Content-Transfer-Encoding: quoted-printable";
-
- $this->_body = $this->_prep_quoted_printable($this->_body);
-
- if ($this->_get_protocol() == 'mail')
- {
- $this->_header_str .= $hdr;
-
- $body = $this->_body . $this->newline . $this->newline;
- $body .= "--" . $this->_alt_boundary . "--" . $this->newline . $this->newline;
- }
-
- $hdr .= $this->newline . $this->newline;
- $hdr .= $this->_body . $this->newline . $this->newline;
- $hdr .= "--" . $this->_alt_boundary . "--" . $this->newline . $this->newline;
-
- break;
- }
-
- $attachment = array();
-
- $z = 0;
-
- for ($i=0; $i < count($this->_attach_name); $i++)
- {
- $filename = $this->_attach_name[$i];
- $basename = basename($filename);
- $ctype = $this->_attach_type[$i];
-
- if ( ! file_exists($filename))
- {
- $this->_set_error_message('email_attachment_missing', $filename);
- return FALSE;
- }
-
- $h = "--".$this->_atc_boundary.$this->newline;
- $h .= "Content-type: ".$ctype."; ";
- $h .= "name=\"".$basename."\"".$this->newline;
- $h .= "Content-Disposition: ".$this->_attach_disp[$i].";".$this->newline;
- $h .= "Content-Transfer-Encoding: base64".$this->newline;
-
- $attachment[$z++] = $h;
- $file = filesize($filename) +1;
-
- if ( ! $fp = fopen($filename, FOPEN_READ))
- {
- $this->_set_error_message('email_attachment_unreadable', $filename);
- return FALSE;
- }
-
- $attachment[$z++] = chunk_split(base64_encode(fread($fp, $file)));
- fclose($fp);
- }
-
- if ($this->_get_protocol() == 'mail')
- {
- $this->_finalbody = $body . implode($this->newline, $attachment).$this->newline."--".$this->_atc_boundary."--";
-
- return;
- }
-
- $this->_finalbody = $hdr.implode($this->newline, $attachment).$this->newline."--".$this->_atc_boundary."--";
-
- return;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Prep Quoted Printable
- *
- * Prepares string for Quoted-Printable Content-Transfer-Encoding
- * Refer to RFC 2045 http://www.ietf.org/rfc/rfc2045.txt
- *
- * @access private
- * @param string
- * @param integer
- * @return string
- */
- function _prep_quoted_printable($str, $charlim = '')
- {
- // Set the character limit
- // Don't allow over 76, as that will make servers and MUAs barf
- // all over quoted-printable data
- if ($charlim == '' OR $charlim > '76')
- {
- $charlim = '76';
- }
-
- // Reduce multiple spaces
- $str = preg_replace("| +|", " ", $str);
-
- // kill nulls
- $str = preg_replace('/\x00+/', '', $str);
-
- // Standardize newlines
- if (strpos($str, "\r") !== FALSE)
- {
- $str = str_replace(array("\r\n", "\r"), "\n", $str);
- }
-
- // We are intentionally wrapping so mail servers will encode characters
- // properly and MUAs will behave, so {unwrap} must go!
- $str = str_replace(array('{unwrap}', '{/unwrap}'), '', $str);
-
- // Break into an array of lines
- $lines = explode("\n", $str);
-
- $escape = '=';
- $output = '';
-
- foreach ($lines as $line)
- {
- $length = strlen($line);
- $temp = '';
-
- // Loop through each character in the line to add soft-wrap
- // characters at the end of a line " =\r\n" and add the newly
- // processed line(s) to the output (see comment on $crlf class property)
- for ($i = 0; $i < $length; $i++)
- {
- // Grab the next character
- $char = substr($line, $i, 1);
- $ascii = ord($char);
-
- // Convert spaces and tabs but only if it's the end of the line
- if ($i == ($length - 1))
- {
- $char = ($ascii == '32' OR $ascii == '9') ? $escape.sprintf('%02s', dechex($ascii)) : $char;
- }
-
- // encode = signs
- if ($ascii == '61')
- {
- $char = $escape.strtoupper(sprintf('%02s', dechex($ascii))); // =3D
- }
-
- // If we're at the character limit, add the line to the output,
- // reset our temp variable, and keep on chuggin'
- if ((strlen($temp) + strlen($char)) >= $charlim)
- {
- $output .= $temp.$escape.$this->crlf;
- $temp = '';
- }
-
- // Add the character to our temporary line
- $temp .= $char;
- }
-
- // Add our completed line to the output
- $output .= $temp.$this->crlf;
- }
-
- // get rid of extra CRLF tacked onto the end
- $output = substr($output, 0, strlen($this->crlf) * -1);
-
- return $output;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Send Email
- *
- * @access public
- * @return bool
- */
- function send()
- {
- if ($this->_replyto_flag == FALSE)
- {
- $this->reply_to($this->_headers['From']);
- }
-
- if (( ! isset($this->_recipients) AND ! isset($this->_headers['To'])) AND
- ( ! isset($this->_bcc_array) AND ! isset($this->_headers['Bcc'])) AND
- ( ! isset($this->_headers['Cc'])))
- {
- $this->_set_error_message('email_no_recipients');
- return FALSE;
- }
-
- $this->_build_headers();
-
- if ($this->bcc_batch_mode AND count($this->_bcc_array) > 0)
- {
- if (count($this->_bcc_array) > $this->bcc_batch_size)
- return $this->batch_bcc_send();
- }
-
- $this->_build_message();
-
- if ( ! $this->_spool_email())
- {
- return FALSE;
- }
- else
- {
- return TRUE;
- }
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Batch Bcc Send. Sends groups of BCCs in batches
- *
- * @access public
- * @return bool
- */
- function batch_bcc_send()
- {
- $float = $this->bcc_batch_size -1;
-
- $set = "";
-
- $chunk = array();
-
- for ($i = 0; $i < count($this->_bcc_array); $i++)
- {
- if (isset($this->_bcc_array[$i]))
- {
- $set .= ", ".$this->_bcc_array[$i];
- }
-
- if ($i == $float)
- {
- $chunk[] = substr($set, 1);
- $float = $float + $this->bcc_batch_size;
- $set = "";
- }
-
- if ($i == count($this->_bcc_array)-1)
- {
- $chunk[] = substr($set, 1);
- }
- }
-
- for ($i = 0; $i < count($chunk); $i++)
- {
- unset($this->_headers['Bcc']);
- unset($bcc);
-
- $bcc = $this->_str_to_array($chunk[$i]);
- $bcc = $this->clean_email($bcc);
-
- if ($this->protocol != 'smtp')
- {
- $this->_set_header('Bcc', implode(", ", $bcc));
- }
- else
- {
- $this->_bcc_array = $bcc;
- }
-
- $this->_build_message();
- $this->_spool_email();
- }
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Unwrap special elements
- *
- * @access private
- * @return void
- */
- function _unwrap_specials()
- {
- $this->_finalbody = preg_replace_callback("/\{unwrap\}(.*?)\{\/unwrap\}/si", array($this, '_remove_nl_callback'), $this->_finalbody);
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Strip line-breaks via callback
- *
- * @access private
- * @return string
- */
- function _remove_nl_callback($matches)
- {
- if (strpos($matches[1], "\r") !== FALSE OR strpos($matches[1], "\n") !== FALSE)
- {
- $matches[1] = str_replace(array("\r\n", "\r", "\n"), '', $matches[1]);
- }
-
- return $matches[1];
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Spool mail to the mail server
- *
- * @access private
- * @return bool
- */
- function _spool_email()
- {
- $this->_unwrap_specials();
-
- switch ($this->_get_protocol())
- {
- case 'mail' :
-
- if ( ! $this->_send_with_mail())
- {
- $this->_set_error_message('email_send_failure_phpmail');
- return FALSE;
- }
- break;
- case 'sendmail' :
-
- if ( ! $this->_send_with_sendmail())
- {
- $this->_set_error_message('email_send_failure_sendmail');
- return FALSE;
- }
- break;
- case 'smtp' :
-
- if ( ! $this->_send_with_smtp())
- {
- $this->_set_error_message('email_send_failure_smtp');
- return FALSE;
- }
- break;
-
- }
-
- $this->_set_error_message('email_sent', $this->_get_protocol());
- return TRUE;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Send using mail()
- *
- * @access private
- * @return bool
- */
- function _send_with_mail()
- {
- if ($this->_safe_mode == TRUE)
- {
- if ( ! mail($this->_recipients, $this->_subject, $this->_finalbody, $this->_header_str))
- {
- return FALSE;
- }
- else
- {
- return TRUE;
- }
- }
- else
- {
- // most documentation of sendmail using the "-f" flag lacks a space after it, however
- // we've encountered servers that seem to require it to be in place.
- if ( ! mail($this->_recipients, $this->_subject, $this->_finalbody, $this->_header_str, "-f ".$this->clean_email($this->_headers['From'])))
- {
- return FALSE;
- }
- else
- {
- return TRUE;
- }
- }
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Send using Sendmail
- *
- * @access private
- * @return bool
- */
- function _send_with_sendmail()
- {
- $fp = @popen($this->mailpath . " -oi -f ".$this->clean_email($this->_headers['From'])." -t", 'w');
-
- if ( ! is_resource($fp))
- {
- $this->_set_error_message('email_no_socket');
- return FALSE;
- }
-
- fputs($fp, $this->_header_str);
- fputs($fp, $this->_finalbody);
- pclose($fp) >> 8 & 0xFF;
-
- return TRUE;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Send using SMTP
- *
- * @access private
- * @return bool
- */
- function _send_with_smtp()
- {
- if ($this->smtp_host == '')
- {
- $this->_set_error_message('email_no_hostname');
- return FALSE;
- }
-
- $this->_smtp_connect();
- $this->_smtp_authenticate();
-
- $this->_send_command('from', $this->clean_email($this->_headers['From']));
-
- foreach($this->_recipients as $val)
- {
- $this->_send_command('to', $val);
- }
-
- if (count($this->_cc_array) > 0)
- {
- foreach($this->_cc_array as $val)
- {
- if ($val != "")
- {
- $this->_send_command('to', $val);
- }
- }
- }
-
- if (count($this->_bcc_array) > 0)
- {
- foreach($this->_bcc_array as $val)
- {
- if ($val != "")
- {
- $this->_send_command('to', $val);
- }
- }
- }
-
- $this->_send_command('data');
-
- // perform dot transformation on any lines that begin with a dot
- $this->_send_data($this->_header_str . preg_replace('/^\./m', '..$1', $this->_finalbody));
-
- $this->_send_data('.');
-
- $reply = $this->_get_smtp_data();
-
- $this->_set_error_message($reply);
-
- if (strncmp($reply, '250', 3) != 0)
- {
- $this->_set_error_message('email_smtp_error', $reply);
- return FALSE;
- }
-
- $this->_send_command('quit');
- return TRUE;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * SMTP Connect
- *
- * @access private
- * @param string
- * @return string
- */
- function _smtp_connect()
- {
- $this->_smtp_connect = fsockopen($this->smtp_host,
- $this->smtp_port,
- $errno,
- $errstr,
- $this->smtp_timeout);
-
- if( ! is_resource($this->_smtp_connect))
- {
- $this->_set_error_message('email_smtp_error', $errno." ".$errstr);
- return FALSE;
- }
-
- $this->_set_error_message($this->_get_smtp_data());
- return $this->_send_command('hello');
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Send SMTP command
- *
- * @access private
- * @param string
- * @param string
- * @return string
- */
- function _send_command($cmd, $data = '')
- {
- switch ($cmd)
- {
- case 'hello' :
-
- if ($this->_smtp_auth OR $this->_get_encoding() == '8bit')
- $this->_send_data('EHLO '.$this->_get_hostname());
- else
- $this->_send_data('HELO '.$this->_get_hostname());
-
- $resp = 250;
- break;
- case 'from' :
-
- $this->_send_data('MAIL FROM:<'.$data.'>');
-
- $resp = 250;
- break;
- case 'to' :
-
- $this->_send_data('RCPT TO:<'.$data.'>');
-
- $resp = 250;
- break;
- case 'data' :
-
- $this->_send_data('DATA');
-
- $resp = 354;
- break;
- case 'quit' :
-
- $this->_send_data('QUIT');
-
- $resp = 221;
- break;
- }
-
- $reply = $this->_get_smtp_data();
-
- $this->_debug_msg[] = "<pre>".$cmd.": ".$reply."</pre>";
-
- if (substr($reply, 0, 3) != $resp)
- {
- $this->_set_error_message('email_smtp_error', $reply);
- return FALSE;
- }
-
- if ($cmd == 'quit')
- {
- fclose($this->_smtp_connect);
- }
-
- return TRUE;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * SMTP Authenticate
- *
- * @access private
- * @return bool
- */
- function _smtp_authenticate()
- {
- if ( ! $this->_smtp_auth)
- {
- return TRUE;
- }
-
- if ($this->smtp_user == "" AND $this->smtp_pass == "")
- {
- $this->_set_error_message('email_no_smtp_unpw');
- return FALSE;
- }
-
- $this->_send_data('AUTH LOGIN');
-
- $reply = $this->_get_smtp_data();
-
- if (strncmp($reply, '334', 3) != 0)
- {
- $this->_set_error_message('email_failed_smtp_login', $reply);
- return FALSE;
- }
-
- $this->_send_data(base64_encode($this->smtp_user));
-
- $reply = $this->_get_smtp_data();
-
- if (strncmp($reply, '334', 3) != 0)
- {
- $this->_set_error_message('email_smtp_auth_un', $reply);
- return FALSE;
- }
-
- $this->_send_data(base64_encode($this->smtp_pass));
-
- $reply = $this->_get_smtp_data();
-
- if (strncmp($reply, '235', 3) != 0)
- {
- $this->_set_error_message('email_smtp_auth_pw', $reply);
- return FALSE;
- }
-
- return TRUE;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Send SMTP data
- *
- * @access private
- * @return bool
- */
- function _send_data($data)
- {
- if ( ! fwrite($this->_smtp_connect, $data . $this->newline))
- {
- $this->_set_error_message('email_smtp_data_failure', $data);
- return FALSE;
- }
- else
- {
- return TRUE;
- }
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Get SMTP data
- *
- * @access private
- * @return string
- */
- function _get_smtp_data()
- {
- $data = "";
-
- while ($str = fgets($this->_smtp_connect, 512))
- {
- $data .= $str;
-
- if (substr($str, 3, 1) == " ")
- {
- break;
- }
- }
-
- return $data;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Get Hostname
- *
- * @access private
- * @return string
- */
- function _get_hostname()
- {
- return (isset($_SERVER['SERVER_NAME'])) ? $_SERVER['SERVER_NAME'] : 'localhost.localdomain';
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Get IP
- *
- * @access private
- * @return string
- */
- function _get_ip()
- {
- if ($this->_IP !== FALSE)
- {
- return $this->_IP;
- }
-
- $cip = (isset($_SERVER['HTTP_CLIENT_IP']) AND $_SERVER['HTTP_CLIENT_IP'] != "") ? $_SERVER['HTTP_CLIENT_IP'] : FALSE;
- $rip = (isset($_SERVER['REMOTE_ADDR']) AND $_SERVER['REMOTE_ADDR'] != "") ? $_SERVER['REMOTE_ADDR'] : FALSE;
- $fip = (isset($_SERVER['HTTP_X_FORWARDED_FOR']) AND $_SERVER['HTTP_X_FORWARDED_FOR'] != "") ? $_SERVER['HTTP_X_FORWARDED_FOR'] : FALSE;
-
- if ($cip && $rip) $this->_IP = $cip;
- elseif ($rip) $this->_IP = $rip;
- elseif ($cip) $this->_IP = $cip;
- elseif ($fip) $this->_IP = $fip;
-
- if (strstr($this->_IP, ','))
- {
- $x = explode(',', $this->_IP);
- $this->_IP = end($x);
- }
-
- if ( ! preg_match( "/^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$/", $this->_IP))
- {
- $this->_IP = '0.0.0.0';
- }
-
- unset($cip);
- unset($rip);
- unset($fip);
-
- return $this->_IP;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Get Debug Message
- *
- * @access public
- * @return string
- */
- function print_debugger()
- {
- $msg = '';
-
- if (count($this->_debug_msg) > 0)
- {
- foreach ($this->_debug_msg as $val)
- {
- $msg .= $val;
- }
- }
-
- $msg .= "<pre>".$this->_header_str."\n".htmlspecialchars($this->_subject)."\n".htmlspecialchars($this->_finalbody).'</pre>';
- return $msg;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Set Message
- *
- * @access private
- * @param string
- * @return string
- */
- function _set_error_message($msg, $val = '')
- {
- $CI =& get_instance();
- $CI->lang->load('email');
-
- if (FALSE === ($line = $CI->lang->line($msg)))
- {
- $this->_debug_msg[] = str_replace('%s', $val, $msg)."<br />";
- }
- else
- {
- $this->_debug_msg[] = str_replace('%s', $val, $line)."<br />";
- }
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Mime Types
- *
- * @access private
- * @param string
- * @return string
- */
- function _mime_types($ext = "")
- {
- $mimes = array( 'hqx' => 'application/mac-binhex40',
- 'cpt' => 'application/mac-compactpro',
- 'doc' => 'application/msword',
- 'bin' => 'application/macbinary',
- 'dms' => 'application/octet-stream',
- 'lha' => 'application/octet-stream',
- 'lzh' => 'application/octet-stream',
- 'exe' => 'application/octet-stream',
- 'class' => 'application/octet-stream',
- 'psd' => 'application/octet-stream',
- 'so' => 'application/octet-stream',
- 'sea' => 'application/octet-stream',
- 'dll' => 'application/octet-stream',
- 'oda' => 'application/oda',
- 'pdf' => 'application/pdf',
- 'ai' => 'application/postscript',
- 'eps' => 'application/postscript',
- 'ps' => 'application/postscript',
- 'smi' => 'application/smil',
- 'smil' => 'application/smil',
- 'mif' => 'application/vnd.mif',
- 'xls' => 'application/vnd.ms-excel',
- 'ppt' => 'application/vnd.ms-powerpoint',
- 'wbxml' => 'application/vnd.wap.wbxml',
- 'wmlc' => 'application/vnd.wap.wmlc',
- 'dcr' => 'application/x-director',
- 'dir' => 'application/x-director',
- 'dxr' => 'application/x-director',
- 'dvi' => 'application/x-dvi',
- 'gtar' => 'application/x-gtar',
- 'php' => 'application/x-httpd-php',
- 'php4' => 'application/x-httpd-php',
- 'php3' => 'application/x-httpd-php',
- 'phtml' => 'application/x-httpd-php',
- 'phps' => 'application/x-httpd-php-source',
- 'js' => 'application/x-javascript',
- 'swf' => 'application/x-shockwave-flash',
- 'sit' => 'application/x-stuffit',
- 'tar' => 'application/x-tar',
- 'tgz' => 'application/x-tar',
- 'xhtml' => 'application/xhtml+xml',
- 'xht' => 'application/xhtml+xml',
- 'zip' => 'application/zip',
- 'mid' => 'audio/midi',
- 'midi' => 'audio/midi',
- 'mpga' => 'audio/mpeg',
- 'mp2' => 'audio/mpeg',
- 'mp3' => 'audio/mpeg',
- 'aif' => 'audio/x-aiff',
- 'aiff' => 'audio/x-aiff',
- 'aifc' => 'audio/x-aiff',
- 'ram' => 'audio/x-pn-realaudio',
- 'rm' => 'audio/x-pn-realaudio',
- 'rpm' => 'audio/x-pn-realaudio-plugin',
- 'ra' => 'audio/x-realaudio',
- 'rv' => 'video/vnd.rn-realvideo',
- 'wav' => 'audio/x-wav',
- 'bmp' => 'image/bmp',
- 'gif' => 'image/gif',
- 'jpeg' => 'image/jpeg',
- 'jpg' => 'image/jpeg',
- 'jpe' => 'image/jpeg',
- 'png' => 'image/png',
- 'tiff' => 'image/tiff',
- 'tif' => 'image/tiff',
- 'css' => 'text/css',
- 'html' => 'text/html',
- 'htm' => 'text/html',
- 'shtml' => 'text/html',
- 'txt' => 'text/plain',
- 'text' => 'text/plain',
- 'log' => 'text/plain',
- 'rtx' => 'text/richtext',
- 'rtf' => 'text/rtf',
- 'xml' => 'text/xml',
- 'xsl' => 'text/xml',
- 'mpeg' => 'video/mpeg',
- 'mpg' => 'video/mpeg',
- 'mpe' => 'video/mpeg',
- 'qt' => 'video/quicktime',
- 'mov' => 'video/quicktime',
- 'avi' => 'video/x-msvideo',
- 'movie' => 'video/x-sgi-movie',
- 'doc' => 'application/msword',
- 'word' => 'application/msword',
- 'xl' => 'application/excel',
- 'eml' => 'message/rfc822'
- );
-
- return ( ! isset($mimes[strtolower($ext)])) ? "application/x-unknown-content-type" : $mimes[strtolower($ext)];
- }
-
-}
-// END CI_Email class
-
-/* End of file Email.php */
+<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+/**
+ * CodeIgniter
+ *
+ * An open source application development framework for PHP 4.3.2 or newer
+ *
+ * @package CodeIgniter
+ * @author ExpressionEngine Dev Team
+ * @copyright Copyright (c) 2008, EllisLab, Inc.
+ * @license http://codeigniter.com/user_guide/license.html
+ * @link http://codeigniter.com
+ * @since Version 1.0
+ * @filesource
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+ * CodeIgniter Email Class
+ *
+ * Permits email to be sent using Mail, Sendmail, or SMTP.
+ *
+ * @package CodeIgniter
+ * @subpackage Libraries
+ * @category Libraries
+ * @author ExpressionEngine Dev Team
+ * @link http://codeigniter.com/user_guide/libraries/email.html
+ */
+class CI_Email {
+
+ var $useragent = "CodeIgniter";
+ var $mailpath = "/usr/sbin/sendmail"; // Sendmail path
+ var $protocol = "mail"; // mail/sendmail/smtp
+ var $smtp_host = ""; // SMTP Server. Example: mail.earthlink.net
+ var $smtp_user = ""; // SMTP Username
+ var $smtp_pass = ""; // SMTP Password
+ var $smtp_port = "25"; // SMTP Port
+ var $smtp_timeout = 5; // SMTP Timeout in seconds
+ var $wordwrap = TRUE; // TRUE/FALSE Turns word-wrap on/off
+ var $wrapchars = "76"; // Number of characters to wrap at.
+ var $mailtype = "text"; // text/html Defines email formatting
+ var $charset = "utf-8"; // Default char set: iso-8859-1 or us-ascii
+ var $multipart = "mixed"; // "mixed" (in the body) or "related" (separate)
+ var $alt_message = ''; // Alternative message for HTML emails
+ var $validate = FALSE; // TRUE/FALSE. Enables email validation
+ var $priority = "3"; // Default priority (1 - 5)
+ var $newline = "\n"; // Default newline. "\r\n" or "\n" (Use "\r\n" to comply with RFC 822)
+ var $crlf = "\n"; // The RFC 2045 compliant CRLF for quoted-printable is "\r\n". Apparently some servers,
+ // even on the receiving end think they need to muck with CRLFs, so using "\n", while
+ // distasteful, is the only thing that seems to work for all environments.
+ var $send_multipart = TRUE; // TRUE/FALSE - Yahoo does not like multipart alternative, so this is an override. Set to FALSE for Yahoo.
+ var $bcc_batch_mode = FALSE; // TRUE/FALSE Turns on/off Bcc batch feature
+ var $bcc_batch_size = 200; // If bcc_batch_mode = TRUE, sets max number of Bccs in each batch
+ var $_safe_mode = FALSE;
+ var $_subject = "";
+ var $_body = "";
+ var $_finalbody = "";
+ var $_alt_boundary = "";
+ var $_atc_boundary = "";
+ var $_header_str = "";
+ var $_smtp_connect = "";
+ var $_encoding = "8bit";
+ var $_IP = FALSE;
+ var $_smtp_auth = FALSE;
+ var $_replyto_flag = FALSE;
+ var $_debug_msg = array();
+ var $_recipients = array();
+ var $_cc_array = array();
+ var $_bcc_array = array();
+ var $_headers = array();
+ var $_attach_name = array();
+ var $_attach_type = array();
+ var $_attach_disp = array();
+ var $_protocols = array('mail', 'sendmail', 'smtp');
+ var $_base_charsets = array('us-ascii', 'iso-2022-'); // 7-bit charsets (excluding language suffix)
+ var $_bit_depths = array('7bit', '8bit');
+ var $_priorities = array('1 (Highest)', '2 (High)', '3 (Normal)', '4 (Low)', '5 (Lowest)');
+
+
+ /**
+ * Constructor - Sets Email Preferences
+ *
+ * The constructor can be passed an array of config values
+ */
+ function CI_Email($config = array())
+ {
+ if (count($config) > 0)
+ {
+ $this->initialize($config);
+ }
+ else
+ {
+ $this->_smtp_auth = ($this->smtp_user == '' AND $this->smtp_pass == '') ? FALSE : TRUE;
+ $this->_safe_mode = ((boolean)@ini_get("safe_mode") === FALSE) ? FALSE : TRUE;
+ }
+
+ log_message('debug', "Email Class Initialized");
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Initialize preferences
+ *
+ * @access public
+ * @param array
+ * @return void
+ */
+ function initialize($config = array())
+ {
+ $this->clear();
+ foreach ($config as $key => $val)
+ {
+ if (isset($this->$key))
+ {
+ $method = 'set_'.$key;
+
+ if (method_exists($this, $method))
+ {
+ $this->$method($val);
+ }
+ else
+ {
+ $this->$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;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Initialize the Email Data
+ *
+ * @access public
+ * @return void
+ */
+ function clear($clear_attachments = FALSE)
+ {
+ $this->_subject = "";
+ $this->_body = "";
+ $this->_finalbody = "";
+ $this->_header_str = "";
+ $this->_replyto_flag = FALSE;
+ $this->_recipients = array();
+ $this->_headers = array();
+ $this->_debug_msg = array();
+
+ $this->_set_header('User-Agent', $this->useragent);
+ $this->_set_header('Date', $this->_set_date());
+
+ if ($clear_attachments !== FALSE)
+ {
+ $this->_attach_name = array();
+ $this->_attach_type = array();
+ $this->_attach_disp = array();
+ }
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Set FROM
+ *
+ * @access public
+ * @param string
+ * @param string
+ * @return void
+ */
+ function from($from, $name = '')
+ {
+ if (preg_match( '/\<(.*)\>/', $from, $match))
+ {
+ $from = $match['1'];
+ }
+
+ if ($this->validate)
+ {
+ $this->validate_email($this->_str_to_array($from));
+ }
+
+ if ($name != '' && strncmp($name, '"', 1) != 0)
+ {
+ $name = '"'.$name.'"';
+ }
+
+ $this->_set_header('From', $name.' <'.$from.'>');
+ $this->_set_header('Return-Path', '<'.$from.'>');
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Set Reply-to
+ *
+ * @access public
+ * @param string
+ * @param string
+ * @return void
+ */
+ function reply_to($replyto, $name = '')
+ {
+ if (preg_match( '/\<(.*)\>/', $replyto, $match))
+ {
+ $replyto = $match['1'];
+ }
+
+ if ($this->validate)
+ {
+ $this->validate_email($this->_str_to_array($replyto));
+ }
+
+ if ($name == '')
+ {
+ $name = $replyto;
+ }
+
+ if (strncmp($name, '"', 1) != 0)
+ {
+ $name = '"'.$name.'"';
+ }
+
+ $this->_set_header('Reply-To', $name.' <'.$replyto.'>');
+ $this->_replyto_flag = TRUE;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Set Recipients
+ *
+ * @access public
+ * @param string
+ * @return void
+ */
+ function to($to)
+ {
+ $to = $this->_str_to_array($to);
+ $to = $this->clean_email($to);
+
+ if ($this->validate)
+ {
+ $this->validate_email($to);
+ }
+
+ if ($this->_get_protocol() != 'mail')
+ {
+ $this->_set_header('To', implode(", ", $to));
+ }
+
+ switch ($this->_get_protocol())
+ {
+ case 'smtp' : $this->_recipients = $to;
+ break;
+ case 'sendmail' : $this->_recipients = implode(", ", $to);
+ break;
+ case 'mail' : $this->_recipients = implode(", ", $to);
+ break;
+ }
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Set CC
+ *
+ * @access public
+ * @param string
+ * @return void
+ */
+ function cc($cc)
+ {
+ $cc = $this->_str_to_array($cc);
+ $cc = $this->clean_email($cc);
+
+ if ($this->validate)
+ {
+ $this->validate_email($cc);
+ }
+
+ $this->_set_header('Cc', implode(", ", $cc));
+
+ if ($this->_get_protocol() == "smtp")
+ {
+ $this->_cc_array = $cc;
+ }
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Set BCC
+ *
+ * @access public
+ * @param string
+ * @param string
+ * @return void
+ */
+ function bcc($bcc, $limit = '')
+ {
+ if ($limit != '' && is_numeric($limit))
+ {
+ $this->bcc_batch_mode = TRUE;
+ $this->bcc_batch_size = $limit;
+ }
+
+ $bcc = $this->_str_to_array($bcc);
+ $bcc = $this->clean_email($bcc);
+
+ if ($this->validate)
+ {
+ $this->validate_email($bcc);
+ }
+
+ if (($this->_get_protocol() == "smtp") OR ($this->bcc_batch_mode && count($bcc) > $this->bcc_batch_size))
+ {
+ $this->_bcc_array = $bcc;
+ }
+ else
+ {
+ $this->_set_header('Bcc', implode(", ", $bcc));
+ }
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Set Email Subject
+ *
+ * @access public
+ * @param string
+ * @return void
+ */
+ function subject($subject)
+ {
+ if (strpos($subject, "\r") !== FALSE OR strpos($subject, "\n") !== FALSE)
+ {
+ $subject = str_replace(array("\r\n", "\r", "\n"), '', $subject);
+ }
+
+ if (strpos($subject, "\t"))
+ {
+ $subject = str_replace("\t", ' ', $subject);
+ }
+
+ $this->_set_header('Subject', trim($subject));
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Set Body
+ *
+ * @access public
+ * @param string
+ * @return void
+ */
+ function message($body)
+ {
+ $this->_body = stripslashes(rtrim(str_replace("\r", "", $body)));
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Assign file attachments
+ *
+ * @access public
+ * @param string
+ * @return void
+ */
+ function attach($filename, $disposition = 'attachment')
+ {
+ $this->_attach_name[] = $filename;
+ $this->_attach_type[] = $this->_mime_types(next(explode('.', basename($filename))));
+ $this->_attach_disp[] = $disposition; // Can also be 'inline' Not sure if it matters
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Add a Header Item
+ *
+ * @access private
+ * @param string
+ * @param string
+ * @return void
+ */
+ function _set_header($header, $value)
+ {
+ $this->_headers[$header] = $value;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Convert a String to an Array
+ *
+ * @access private
+ * @param string
+ * @return array
+ */
+ function _str_to_array($email)
+ {
+ if ( ! is_array($email))
+ {
+ if (strpos($email, ',') !== FALSE)
+ {
+ $email = preg_split('/[\s,]/', $email, -1, PREG_SPLIT_NO_EMPTY);
+ }
+ else
+ {
+ $email = trim($email);
+ settype($email, "array");
+ }
+ }
+ return $email;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Set Multipart Value
+ *
+ * @access public
+ * @param string
+ * @return void
+ */
+ function set_alt_message($str = '')
+ {
+ $this->alt_message = ($str == '') ? '' : $str;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Set Mailtype
+ *
+ * @access public
+ * @param string
+ * @return void
+ */
+ function set_mailtype($type = 'text')
+ {
+ $this->mailtype = ($type == 'html') ? 'html' : 'text';
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Set Wordwrap
+ *
+ * @access public
+ * @param string
+ * @return void
+ */
+ function set_wordwrap($wordwrap = TRUE)
+ {
+ $this->wordwrap = ($wordwrap === FALSE) ? FALSE : TRUE;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Set Protocol
+ *
+ * @access public
+ * @param string
+ * @return void
+ */
+ function set_protocol($protocol = 'mail')
+ {
+ $this->protocol = ( ! in_array($protocol, $this->_protocols, TRUE)) ? 'mail' : strtolower($protocol);
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Set Priority
+ *
+ * @access public
+ * @param integer
+ * @return void
+ */
+ function set_priority($n = 3)
+ {
+ if ( ! is_numeric($n))
+ {
+ $this->priority = 3;
+ return;
+ }
+
+ if ($n < 1 OR $n > 5)
+ {
+ $this->priority = 3;
+ return;
+ }
+
+ $this->priority = $n;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Set Newline Character
+ *
+ * @access public
+ * @param string
+ * @return void
+ */
+ function set_newline($newline = "\n")
+ {
+ if ($newline != "\n" AND $newline != "\r\n" AND $newline != "\r")
+ {
+ $this->newline = "\n";
+ return;
+ }
+
+ $this->newline = $newline;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Set CRLF
+ *
+ * @access public
+ * @param string
+ * @return void
+ */
+ function set_crlf($crlf = "\n")
+ {
+ if ($crlf != "\n" AND $crlf != "\r\n" AND $crlf != "\r")
+ {
+ $this->crlf = "\n";
+ return;
+ }
+
+ $this->crlf = $crlf;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Set Message Boundary
+ *
+ * @access private
+ * @return void
+ */
+ function _set_boundaries()
+ {
+ $this->_alt_boundary = "B_ALT_".uniqid(''); // multipart/alternative
+ $this->_atc_boundary = "B_ATC_".uniqid(''); // attachment boundary
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Get the Message ID
+ *
+ * @access private
+ * @return string
+ */
+ function _get_message_id()
+ {
+ $from = $this->_headers['Return-Path'];
+ $from = str_replace(">", "", $from);
+ $from = str_replace("<", "", $from);
+
+ return "<".uniqid('').strstr($from, '@').">";
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Get Mail Protocol
+ *
+ * @access private
+ * @param bool
+ * @return string
+ */
+ function _get_protocol($return = TRUE)
+ {
+ $this->protocol = strtolower($this->protocol);
+ $this->protocol = ( ! in_array($this->protocol, $this->_protocols, TRUE)) ? 'mail' : $this->protocol;
+
+ if ($return == TRUE)
+ {
+ return $this->protocol;
+ }
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Get Mail Encoding
+ *
+ * @access private
+ * @param bool
+ * @return string
+ */
+ function _get_encoding($return = TRUE)
+ {
+ $this->_encoding = ( ! in_array($this->_encoding, $this->_bit_depths)) ? '8bit' : $this->_encoding;
+
+ foreach ($this->_base_charsets as $charset)
+ {
+ if (strncmp($charset, $this->charset, strlen($charset)) == 0)
+ {
+ $this->_encoding = '7bit';
+ }
+ }
+
+ if ($return == TRUE)
+ {
+ return $this->_encoding;
+ }
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Get content type (text/html/attachment)
+ *
+ * @access private
+ * @return string
+ */
+ function _get_content_type()
+ {
+ if ($this->mailtype == 'html' && count($this->_attach_name) == 0)
+ {
+ return 'html';
+ }
+ elseif ($this->mailtype == 'html' && count($this->_attach_name) > 0)
+ {
+ return 'html-attach';
+ }
+ elseif ($this->mailtype == 'text' && count($this->_attach_name) > 0)
+ {
+ return 'plain-attach';
+ }
+ else
+ {
+ return 'plain';
+ }
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Set RFC 822 Date
+ *
+ * @access private
+ * @return string
+ */
+ function _set_date()
+ {
+ $timezone = date("Z");
+ $operator = (strncmp($timezone, '-', 1) == 0) ? '-' : '+';
+ $timezone = abs($timezone);
+ $timezone = floor($timezone/3600) * 100 + ($timezone % 3600 ) / 60;
+
+ return sprintf("%s %s%04d", date("D, j M Y H:i:s"), $operator, $timezone);
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Mime message
+ *
+ * @access private
+ * @return string
+ */
+ function _get_mime_message()
+ {
+ return "This is a multi-part message in MIME format.".$this->newline."Your email application may not support this format.";
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Validate Email Address
+ *
+ * @access public
+ * @param string
+ * @return bool
+ */
+ function validate_email($email)
+ {
+ if ( ! is_array($email))
+ {
+ $this->_set_error_message('email_must_be_array');
+ return FALSE;
+ }
+
+ foreach ($email as $val)
+ {
+ if ( ! $this->valid_email($val))
+ {
+ $this->_set_error_message('email_invalid_address', $val);
+ return FALSE;
+ }
+ }
+
+ return TRUE;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Email Validation
+ *
+ * @access public
+ * @param string
+ * @return bool
+ */
+ function valid_email($address)
+ {
+ return ( ! preg_match("/^([a-z0-9\+_\-]+)(\.[a-z0-9\+_\-]+)*@([a-z0-9\-]+\.)+[a-z]{2,6}$/ix", $address)) ? FALSE : TRUE;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Clean Extended Email Address: Joe Smith <joe@smith.com>
+ *
+ * @access public
+ * @param string
+ * @return string
+ */
+ function clean_email($email)
+ {
+ if ( ! is_array($email))
+ {
+ if (preg_match('/\<(.*)\>/', $email, $match))
+ {
+ return $match['1'];
+ }
+ else
+ {
+ return $email;
+ }
+ }
+
+ $clean_email = array();
+
+ foreach ($email as $addy)
+ {
+ if (preg_match( '/\<(.*)\>/', $addy, $match))
+ {
+ $clean_email[] = $match['1'];
+ }
+ else
+ {
+ $clean_email[] = $addy;
+ }
+ }
+
+ return $clean_email;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Build alternative plain text message
+ *
+ * This 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()
+ {
+ if ($this->alt_message != "")
+ {
+ return $this->word_wrap($this->alt_message, '76');
+ }
+
+ if (preg_match('/\<body.*?\>(.*)\<\/body\>/si', $this->_body, $match))
+ {
+ $body = $match['1'];
+ }
+ else
+ {
+ $body = $this->_body;
+ }
+
+ $body = trim(strip_tags($body));
+ $body = preg_replace( '#<!--(.*)--\>#', "", $body);
+ $body = str_replace("\t", "", $body);
+
+ for ($i = 20; $i >= 3; $i--)
+ {
+ $n = "";
+
+ for ($x = 1; $x <= $i; $x ++)
+ {
+ $n .= "\n";
+ }
+
+ $body = str_replace($n, "\n\n", $body);
+ }
+
+ return $this->word_wrap($body, '76');
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Word Wrap
+ *
+ * @access public
+ * @param string
+ * @param integer
+ * @return string
+ */
+ function word_wrap($str, $charlim = '')
+ {
+ // Se the character limit
+ if ($charlim == '')
+ {
+ $charlim = ($this->wrapchars == "") ? "76" : $this->wrapchars;
+ }
+
+ // Reduce multiple spaces
+ $str = preg_replace("| +|", " ", $str);
+
+ // Standardize newlines
+ if (strpos($str, "\r") !== FALSE)
+ {
+ $str = str_replace(array("\r\n", "\r"), "\n", $str);
+ }
+
+ // If the current word is surrounded by {unwrap} tags we'll
+ // strip the entire chunk and replace it with a marker.
+ $unwrap = array();
+ if (preg_match_all("|(\{unwrap\}.+?\{/unwrap\})|s", $str, $matches))
+ {
+ for ($i = 0; $i < count($matches['0']); $i++)
+ {
+ $unwrap[] = $matches['1'][$i];
+ $str = str_replace($matches['1'][$i], "{{unwrapped".$i."}}", $str);
+ }
+ }
+
+ // Use PHP's native 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);
+
+ // Split the string into individual lines of text and cycle through them
+ $output = "";
+ foreach (explode("\n", $str) as $line)
+ {
+ // Is the line within the allowed character count?
+ // If so we'll join it to the output and continue
+ if (strlen($line) <= $charlim)
+ {
+ $output .= $line.$this->newline;
+ continue;
+ }
+
+ $temp = '';
+ while((strlen($line)) > $charlim)
+ {
+ // If the over-length word is a URL we won't wrap it
+ if (preg_match("!\[url.+\]|://|wwww.!", $line))
+ {
+ break;
+ }
+
+ // Trim the word down
+ $temp .= substr($line, 0, $charlim-1);
+ $line = substr($line, $charlim-1);
+ }
+
+ // If $temp contains data it means we had to split up an over-length
+ // word into smaller chunks so we'll add it back to our current line
+ if ($temp != '')
+ {
+ $output .= $temp.$this->newline.$line;
+ }
+ else
+ {
+ $output .= $line;
+ }
+
+ $output .= $this->newline;
+ }
+
+ // Put our markers back
+ if (count($unwrap) > 0)
+ {
+ foreach ($unwrap as $key => $val)
+ {
+ $output = str_replace("{{unwrapped".$key."}}", $val, $output);
+ }
+ }
+
+ return $output;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Build final headers
+ *
+ * @access private
+ * @param string
+ * @return string
+ */
+ function _build_headers()
+ {
+ $this->_set_header('X-Sender', $this->clean_email($this->_headers['From']));
+ $this->_set_header('X-Mailer', $this->useragent);
+ $this->_set_header('X-Priority', $this->_priorities[$this->priority - 1]);
+ $this->_set_header('Message-ID', $this->_get_message_id());
+ $this->_set_header('Mime-Version', '1.0');
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Write Headers as a string
+ *
+ * @access private
+ * @return void
+ */
+ function _write_headers()
+ {
+ if ($this->protocol == 'mail')
+ {
+ $this->_subject = $this->_headers['Subject'];
+ unset($this->_headers['Subject']);
+ }
+
+ reset($this->_headers);
+ $this->_header_str = "";
+
+ foreach($this->_headers as $key => $val)
+ {
+ $val = trim($val);
+
+ if ($val != "")
+ {
+ $this->_header_str .= $key.": ".$val.$this->newline;
+ }
+ }
+
+ if ($this->_get_protocol() == 'mail')
+ {
+ $this->_header_str = substr($this->_header_str, 0, -1);
+ }
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Build Final Body and attachments
+ *
+ * @access private
+ * @return void
+ */
+ function _build_message()
+ {
+ if ($this->wordwrap === TRUE AND $this->mailtype != 'html')
+ {
+ $this->_body = $this->word_wrap($this->_body);
+ }
+
+ $this->_set_boundaries();
+ $this->_write_headers();
+
+ $hdr = ($this->_get_protocol() == 'mail') ? $this->newline : '';
+
+ switch ($this->_get_content_type())
+ {
+ case 'plain' :
+
+ $hdr .= "Content-Type: text/plain; charset=" . $this->charset . $this->newline;
+ $hdr .= "Content-Transfer-Encoding: " . $this->_get_encoding();
+
+ if ($this->_get_protocol() == 'mail')
+ {
+ $this->_header_str .= $hdr;
+ $this->_finalbody = $this->_body;
+
+ return;
+ }
+
+ $hdr .= $this->newline . $this->newline . $this->_body;
+
+ $this->_finalbody = $hdr;
+ return;
+
+ break;
+ case 'html' :
+
+ if ($this->send_multipart === FALSE)
+ {
+ $hdr .= "Content-Type: text/html; charset=" . $this->charset . $this->newline;
+ $hdr .= "Content-Transfer-Encoding: quoted-printable";
+ }
+ else
+ {
+ $hdr .= "Content-Type: multipart/alternative; boundary=\"" . $this->_alt_boundary . "\"" . $this->newline;
+ $hdr .= $this->_get_mime_message() . $this->newline . $this->newline;
+ $hdr .= "--" . $this->_alt_boundary . $this->newline;
+
+ $hdr .= "Content-Type: text/plain; charset=" . $this->charset . $this->newline;
+ $hdr .= "Content-Transfer-Encoding: " . $this->_get_encoding() . $this->newline . $this->newline;
+ $hdr .= $this->_get_alt_message() . $this->newline . $this->newline . "--" . $this->_alt_boundary . $this->newline;
+
+ $hdr .= "Content-Type: text/html; charset=" . $this->charset . $this->newline;
+ $hdr .= "Content-Transfer-Encoding: quoted-printable";
+ }
+
+ $this->_body = $this->_prep_quoted_printable($this->_body);
+
+ if ($this->_get_protocol() == 'mail')
+ {
+ $this->_header_str .= $hdr;
+ $this->_finalbody = $this->_body . $this->newline . $this->newline;
+
+ if ($this->send_multipart !== FALSE)
+ {
+ $this->_finalbody .= "--" . $this->_alt_boundary . "--";
+ }
+
+ return;
+ }
+
+ $hdr .= $this->newline . $this->newline;
+ $hdr .= $this->_body . $this->newline . $this->newline;
+
+ if ($this->send_multipart !== FALSE)
+ {
+ $hdr .= "--" . $this->_alt_boundary . "--";
+ }
+
+ $this->_finalbody = $hdr;
+ return;
+
+ break;
+ case 'plain-attach' :
+
+ $hdr .= "Content-Type: multipart/".$this->multipart."; boundary=\"" . $this->_atc_boundary."\"" . $this->newline;
+ $hdr .= $this->_get_mime_message() . $this->newline . $this->newline;
+ $hdr .= "--" . $this->_atc_boundary . $this->newline;
+
+ $hdr .= "Content-Type: text/plain; charset=" . $this->charset . $this->newline;
+ $hdr .= "Content-Transfer-Encoding: " . $this->_get_encoding();
+
+ if ($this->_get_protocol() == 'mail')
+ {
+ $this->_header_str .= $hdr;
+
+ $body = $this->_body . $this->newline . $this->newline;
+ }
+
+ $hdr .= $this->newline . $this->newline;
+ $hdr .= $this->_body . $this->newline . $this->newline;
+
+ break;
+ case 'html-attach' :
+
+ $hdr .= "Content-Type: multipart/".$this->multipart."; boundary=\"" . $this->_atc_boundary."\"" . $this->newline;
+ $hdr .= $this->_get_mime_message() . $this->newline . $this->newline;
+ $hdr .= "--" . $this->_atc_boundary . $this->newline;
+
+ $hdr .= "Content-Type: multipart/alternative; boundary=\"" . $this->_alt_boundary . "\"" . $this->newline .$this->newline;
+ $hdr .= "--" . $this->_alt_boundary . $this->newline;
+
+ $hdr .= "Content-Type: text/plain; charset=" . $this->charset . $this->newline;
+ $hdr .= "Content-Transfer-Encoding: " . $this->_get_encoding() . $this->newline . $this->newline;
+ $hdr .= $this->_get_alt_message() . $this->newline . $this->newline . "--" . $this->_alt_boundary . $this->newline;
+
+ $hdr .= "Content-Type: text/html; charset=" . $this->charset . $this->newline;
+ $hdr .= "Content-Transfer-Encoding: quoted-printable";
+
+ $this->_body = $this->_prep_quoted_printable($this->_body);
+
+ if ($this->_get_protocol() == 'mail')
+ {
+ $this->_header_str .= $hdr;
+
+ $body = $this->_body . $this->newline . $this->newline;
+ $body .= "--" . $this->_alt_boundary . "--" . $this->newline . $this->newline;
+ }
+
+ $hdr .= $this->newline . $this->newline;
+ $hdr .= $this->_body . $this->newline . $this->newline;
+ $hdr .= "--" . $this->_alt_boundary . "--" . $this->newline . $this->newline;
+
+ break;
+ }
+
+ $attachment = array();
+
+ $z = 0;
+
+ for ($i=0; $i < count($this->_attach_name); $i++)
+ {
+ $filename = $this->_attach_name[$i];
+ $basename = basename($filename);
+ $ctype = $this->_attach_type[$i];
+
+ if ( ! file_exists($filename))
+ {
+ $this->_set_error_message('email_attachment_missing', $filename);
+ return FALSE;
+ }
+
+ $h = "--".$this->_atc_boundary.$this->newline;
+ $h .= "Content-type: ".$ctype."; ";
+ $h .= "name=\"".$basename."\"".$this->newline;
+ $h .= "Content-Disposition: ".$this->_attach_disp[$i].";".$this->newline;
+ $h .= "Content-Transfer-Encoding: base64".$this->newline;
+
+ $attachment[$z++] = $h;
+ $file = filesize($filename) +1;
+
+ if ( ! $fp = fopen($filename, FOPEN_READ))
+ {
+ $this->_set_error_message('email_attachment_unreadable', $filename);
+ return FALSE;
+ }
+
+ $attachment[$z++] = chunk_split(base64_encode(fread($fp, $file)));
+ fclose($fp);
+ }
+
+ if ($this->_get_protocol() == 'mail')
+ {
+ $this->_finalbody = $body . implode($this->newline, $attachment).$this->newline."--".$this->_atc_boundary."--";
+
+ return;
+ }
+
+ $this->_finalbody = $hdr.implode($this->newline, $attachment).$this->newline."--".$this->_atc_boundary."--";
+
+ return;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Prep Quoted Printable
+ *
+ * Prepares string for Quoted-Printable Content-Transfer-Encoding
+ * Refer to RFC 2045 http://www.ietf.org/rfc/rfc2045.txt
+ *
+ * @access private
+ * @param string
+ * @param integer
+ * @return string
+ */
+ function _prep_quoted_printable($str, $charlim = '')
+ {
+ // Set the character limit
+ // Don't allow over 76, as that will make servers and MUAs barf
+ // all over quoted-printable data
+ if ($charlim == '' OR $charlim > '76')
+ {
+ $charlim = '76';
+ }
+
+ // Reduce multiple spaces
+ $str = preg_replace("| +|", " ", $str);
+
+ // kill nulls
+ $str = preg_replace('/\x00+/', '', $str);
+
+ // Standardize newlines
+ if (strpos($str, "\r") !== FALSE)
+ {
+ $str = str_replace(array("\r\n", "\r"), "\n", $str);
+ }
+
+ // We are intentionally wrapping so mail servers will encode characters
+ // properly and MUAs will behave, so {unwrap} must go!
+ $str = str_replace(array('{unwrap}', '{/unwrap}'), '', $str);
+
+ // Break into an array of lines
+ $lines = explode("\n", $str);
+
+ $escape = '=';
+ $output = '';
+
+ foreach ($lines as $line)
+ {
+ $length = strlen($line);
+ $temp = '';
+
+ // Loop through each character in the line to add soft-wrap
+ // characters at the end of a line " =\r\n" and add the newly
+ // processed line(s) to the output (see comment on $crlf class property)
+ for ($i = 0; $i < $length; $i++)
+ {
+ // Grab the next character
+ $char = substr($line, $i, 1);
+ $ascii = ord($char);
+
+ // Convert spaces and tabs but only if it's the end of the line
+ if ($i == ($length - 1))
+ {
+ $char = ($ascii == '32' OR $ascii == '9') ? $escape.sprintf('%02s', dechex($ascii)) : $char;
+ }
+
+ // encode = signs
+ if ($ascii == '61')
+ {
+ $char = $escape.strtoupper(sprintf('%02s', dechex($ascii))); // =3D
+ }
+
+ // If we're at the character limit, add the line to the output,
+ // reset our temp variable, and keep on chuggin'
+ if ((strlen($temp) + strlen($char)) >= $charlim)
+ {
+ $output .= $temp.$escape.$this->crlf;
+ $temp = '';
+ }
+
+ // Add the character to our temporary line
+ $temp .= $char;
+ }
+
+ // Add our completed line to the output
+ $output .= $temp.$this->crlf;
+ }
+
+ // get rid of extra CRLF tacked onto the end
+ $output = substr($output, 0, strlen($this->crlf) * -1);
+
+ return $output;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Send Email
+ *
+ * @access public
+ * @return bool
+ */
+ function send()
+ {
+ if ($this->_replyto_flag == FALSE)
+ {
+ $this->reply_to($this->_headers['From']);
+ }
+
+ if (( ! isset($this->_recipients) AND ! isset($this->_headers['To'])) AND
+ ( ! isset($this->_bcc_array) AND ! isset($this->_headers['Bcc'])) AND
+ ( ! isset($this->_headers['Cc'])))
+ {
+ $this->_set_error_message('email_no_recipients');
+ return FALSE;
+ }
+
+ $this->_build_headers();
+
+ if ($this->bcc_batch_mode AND count($this->_bcc_array) > 0)
+ {
+ if (count($this->_bcc_array) > $this->bcc_batch_size)
+ return $this->batch_bcc_send();
+ }
+
+ $this->_build_message();
+
+ if ( ! $this->_spool_email())
+ {
+ return FALSE;
+ }
+ else
+ {
+ return TRUE;
+ }
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Batch Bcc Send. Sends groups of BCCs in batches
+ *
+ * @access public
+ * @return bool
+ */
+ function batch_bcc_send()
+ {
+ $float = $this->bcc_batch_size -1;
+
+ $set = "";
+
+ $chunk = array();
+
+ for ($i = 0; $i < count($this->_bcc_array); $i++)
+ {
+ if (isset($this->_bcc_array[$i]))
+ {
+ $set .= ", ".$this->_bcc_array[$i];
+ }
+
+ if ($i == $float)
+ {
+ $chunk[] = substr($set, 1);
+ $float = $float + $this->bcc_batch_size;
+ $set = "";
+ }
+
+ if ($i == count($this->_bcc_array)-1)
+ {
+ $chunk[] = substr($set, 1);
+ }
+ }
+
+ for ($i = 0; $i < count($chunk); $i++)
+ {
+ unset($this->_headers['Bcc']);
+ unset($bcc);
+
+ $bcc = $this->_str_to_array($chunk[$i]);
+ $bcc = $this->clean_email($bcc);
+
+ if ($this->protocol != 'smtp')
+ {
+ $this->_set_header('Bcc', implode(", ", $bcc));
+ }
+ else
+ {
+ $this->_bcc_array = $bcc;
+ }
+
+ $this->_build_message();
+ $this->_spool_email();
+ }
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Unwrap special elements
+ *
+ * @access private
+ * @return void
+ */
+ function _unwrap_specials()
+ {
+ $this->_finalbody = preg_replace_callback("/\{unwrap\}(.*?)\{\/unwrap\}/si", array($this, '_remove_nl_callback'), $this->_finalbody);
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Strip line-breaks via callback
+ *
+ * @access private
+ * @return string
+ */
+ function _remove_nl_callback($matches)
+ {
+ if (strpos($matches[1], "\r") !== FALSE OR strpos($matches[1], "\n") !== FALSE)
+ {
+ $matches[1] = str_replace(array("\r\n", "\r", "\n"), '', $matches[1]);
+ }
+
+ return $matches[1];
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Spool mail to the mail server
+ *
+ * @access private
+ * @return bool
+ */
+ function _spool_email()
+ {
+ $this->_unwrap_specials();
+
+ switch ($this->_get_protocol())
+ {
+ case 'mail' :
+
+ if ( ! $this->_send_with_mail())
+ {
+ $this->_set_error_message('email_send_failure_phpmail');
+ return FALSE;
+ }
+ break;
+ case 'sendmail' :
+
+ if ( ! $this->_send_with_sendmail())
+ {
+ $this->_set_error_message('email_send_failure_sendmail');
+ return FALSE;
+ }
+ break;
+ case 'smtp' :
+
+ if ( ! $this->_send_with_smtp())
+ {
+ $this->_set_error_message('email_send_failure_smtp');
+ return FALSE;
+ }
+ break;
+
+ }
+
+ $this->_set_error_message('email_sent', $this->_get_protocol());
+ return TRUE;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Send using mail()
+ *
+ * @access private
+ * @return bool
+ */
+ function _send_with_mail()
+ {
+ if ($this->_safe_mode == TRUE)
+ {
+ if ( ! mail($this->_recipients, $this->_subject, $this->_finalbody, $this->_header_str))
+ {
+ return FALSE;
+ }
+ else
+ {
+ return TRUE;
+ }
+ }
+ else
+ {
+ // most documentation of sendmail using the "-f" flag lacks a space after it, however
+ // we've encountered servers that seem to require it to be in place.
+ if ( ! mail($this->_recipients, $this->_subject, $this->_finalbody, $this->_header_str, "-f ".$this->clean_email($this->_headers['From'])))
+ {
+ return FALSE;
+ }
+ else
+ {
+ return TRUE;
+ }
+ }
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Send using Sendmail
+ *
+ * @access private
+ * @return bool
+ */
+ function _send_with_sendmail()
+ {
+ $fp = @popen($this->mailpath . " -oi -f ".$this->clean_email($this->_headers['From'])." -t", 'w');
+
+ if ( ! is_resource($fp))
+ {
+ $this->_set_error_message('email_no_socket');
+ return FALSE;
+ }
+
+ fputs($fp, $this->_header_str);
+ fputs($fp, $this->_finalbody);
+ pclose($fp) >> 8 & 0xFF;
+
+ return TRUE;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Send using SMTP
+ *
+ * @access private
+ * @return bool
+ */
+ function _send_with_smtp()
+ {
+ if ($this->smtp_host == '')
+ {
+ $this->_set_error_message('email_no_hostname');
+ return FALSE;
+ }
+
+ $this->_smtp_connect();
+ $this->_smtp_authenticate();
+
+ $this->_send_command('from', $this->clean_email($this->_headers['From']));
+
+ foreach($this->_recipients as $val)
+ {
+ $this->_send_command('to', $val);
+ }
+
+ if (count($this->_cc_array) > 0)
+ {
+ foreach($this->_cc_array as $val)
+ {
+ if ($val != "")
+ {
+ $this->_send_command('to', $val);
+ }
+ }
+ }
+
+ if (count($this->_bcc_array) > 0)
+ {
+ foreach($this->_bcc_array as $val)
+ {
+ if ($val != "")
+ {
+ $this->_send_command('to', $val);
+ }
+ }
+ }
+
+ $this->_send_command('data');
+
+ // perform dot transformation on any lines that begin with a dot
+ $this->_send_data($this->_header_str . preg_replace('/^\./m', '..$1', $this->_finalbody));
+
+ $this->_send_data('.');
+
+ $reply = $this->_get_smtp_data();
+
+ $this->_set_error_message($reply);
+
+ if (strncmp($reply, '250', 3) != 0)
+ {
+ $this->_set_error_message('email_smtp_error', $reply);
+ return FALSE;
+ }
+
+ $this->_send_command('quit');
+ return TRUE;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * SMTP Connect
+ *
+ * @access private
+ * @param string
+ * @return string
+ */
+ function _smtp_connect()
+ {
+ $this->_smtp_connect = fsockopen($this->smtp_host,
+ $this->smtp_port,
+ $errno,
+ $errstr,
+ $this->smtp_timeout);
+
+ if( ! is_resource($this->_smtp_connect))
+ {
+ $this->_set_error_message('email_smtp_error', $errno." ".$errstr);
+ return FALSE;
+ }
+
+ $this->_set_error_message($this->_get_smtp_data());
+ return $this->_send_command('hello');
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Send SMTP command
+ *
+ * @access private
+ * @param string
+ * @param string
+ * @return string
+ */
+ function _send_command($cmd, $data = '')
+ {
+ switch ($cmd)
+ {
+ case 'hello' :
+
+ if ($this->_smtp_auth OR $this->_get_encoding() == '8bit')
+ $this->_send_data('EHLO '.$this->_get_hostname());
+ else
+ $this->_send_data('HELO '.$this->_get_hostname());
+
+ $resp = 250;
+ break;
+ case 'from' :
+
+ $this->_send_data('MAIL FROM:<'.$data.'>');
+
+ $resp = 250;
+ break;
+ case 'to' :
+
+ $this->_send_data('RCPT TO:<'.$data.'>');
+
+ $resp = 250;
+ break;
+ case 'data' :
+
+ $this->_send_data('DATA');
+
+ $resp = 354;
+ break;
+ case 'quit' :
+
+ $this->_send_data('QUIT');
+
+ $resp = 221;
+ break;
+ }
+
+ $reply = $this->_get_smtp_data();
+
+ $this->_debug_msg[] = "<pre>".$cmd.": ".$reply."</pre>";
+
+ if (substr($reply, 0, 3) != $resp)
+ {
+ $this->_set_error_message('email_smtp_error', $reply);
+ return FALSE;
+ }
+
+ if ($cmd == 'quit')
+ {
+ fclose($this->_smtp_connect);
+ }
+
+ return TRUE;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * SMTP Authenticate
+ *
+ * @access private
+ * @return bool
+ */
+ function _smtp_authenticate()
+ {
+ if ( ! $this->_smtp_auth)
+ {
+ return TRUE;
+ }
+
+ if ($this->smtp_user == "" AND $this->smtp_pass == "")
+ {
+ $this->_set_error_message('email_no_smtp_unpw');
+ return FALSE;
+ }
+
+ $this->_send_data('AUTH LOGIN');
+
+ $reply = $this->_get_smtp_data();
+
+ if (strncmp($reply, '334', 3) != 0)
+ {
+ $this->_set_error_message('email_failed_smtp_login', $reply);
+ return FALSE;
+ }
+
+ $this->_send_data(base64_encode($this->smtp_user));
+
+ $reply = $this->_get_smtp_data();
+
+ if (strncmp($reply, '334', 3) != 0)
+ {
+ $this->_set_error_message('email_smtp_auth_un', $reply);
+ return FALSE;
+ }
+
+ $this->_send_data(base64_encode($this->smtp_pass));
+
+ $reply = $this->_get_smtp_data();
+
+ if (strncmp($reply, '235', 3) != 0)
+ {
+ $this->_set_error_message('email_smtp_auth_pw', $reply);
+ return FALSE;
+ }
+
+ return TRUE;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Send SMTP data
+ *
+ * @access private
+ * @return bool
+ */
+ function _send_data($data)
+ {
+ if ( ! fwrite($this->_smtp_connect, $data . $this->newline))
+ {
+ $this->_set_error_message('email_smtp_data_failure', $data);
+ return FALSE;
+ }
+ else
+ {
+ return TRUE;
+ }
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Get SMTP data
+ *
+ * @access private
+ * @return string
+ */
+ function _get_smtp_data()
+ {
+ $data = "";
+
+ while ($str = fgets($this->_smtp_connect, 512))
+ {
+ $data .= $str;
+
+ if (substr($str, 3, 1) == " ")
+ {
+ break;
+ }
+ }
+
+ return $data;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Get Hostname
+ *
+ * @access private
+ * @return string
+ */
+ function _get_hostname()
+ {
+ return (isset($_SERVER['SERVER_NAME'])) ? $_SERVER['SERVER_NAME'] : 'localhost.localdomain';
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Get IP
+ *
+ * @access private
+ * @return string
+ */
+ function _get_ip()
+ {
+ if ($this->_IP !== FALSE)
+ {
+ return $this->_IP;
+ }
+
+ $cip = (isset($_SERVER['HTTP_CLIENT_IP']) AND $_SERVER['HTTP_CLIENT_IP'] != "") ? $_SERVER['HTTP_CLIENT_IP'] : FALSE;
+ $rip = (isset($_SERVER['REMOTE_ADDR']) AND $_SERVER['REMOTE_ADDR'] != "") ? $_SERVER['REMOTE_ADDR'] : FALSE;
+ $fip = (isset($_SERVER['HTTP_X_FORWARDED_FOR']) AND $_SERVER['HTTP_X_FORWARDED_FOR'] != "") ? $_SERVER['HTTP_X_FORWARDED_FOR'] : FALSE;
+
+ if ($cip && $rip) $this->_IP = $cip;
+ elseif ($rip) $this->_IP = $rip;
+ elseif ($cip) $this->_IP = $cip;
+ elseif ($fip) $this->_IP = $fip;
+
+ if (strstr($this->_IP, ','))
+ {
+ $x = explode(',', $this->_IP);
+ $this->_IP = end($x);
+ }
+
+ if ( ! preg_match( "/^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$/", $this->_IP))
+ {
+ $this->_IP = '0.0.0.0';
+ }
+
+ unset($cip);
+ unset($rip);
+ unset($fip);
+
+ return $this->_IP;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Get Debug Message
+ *
+ * @access public
+ * @return string
+ */
+ function print_debugger()
+ {
+ $msg = '';
+
+ if (count($this->_debug_msg) > 0)
+ {
+ foreach ($this->_debug_msg as $val)
+ {
+ $msg .= $val;
+ }
+ }
+
+ $msg .= "<pre>".$this->_header_str."\n".htmlspecialchars($this->_subject)."\n".htmlspecialchars($this->_finalbody).'</pre>';
+ return $msg;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Set Message
+ *
+ * @access private
+ * @param string
+ * @return string
+ */
+ function _set_error_message($msg, $val = '')
+ {
+ $CI =& get_instance();
+ $CI->lang->load('email');
+
+ if (FALSE === ($line = $CI->lang->line($msg)))
+ {
+ $this->_debug_msg[] = str_replace('%s', $val, $msg)."<br />";
+ }
+ else
+ {
+ $this->_debug_msg[] = str_replace('%s', $val, $line)."<br />";
+ }
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Mime Types
+ *
+ * @access private
+ * @param string
+ * @return string
+ */
+ function _mime_types($ext = "")
+ {
+ $mimes = array( 'hqx' => 'application/mac-binhex40',
+ 'cpt' => 'application/mac-compactpro',
+ 'doc' => 'application/msword',
+ 'bin' => 'application/macbinary',
+ 'dms' => 'application/octet-stream',
+ 'lha' => 'application/octet-stream',
+ 'lzh' => 'application/octet-stream',
+ 'exe' => 'application/octet-stream',
+ 'class' => 'application/octet-stream',
+ 'psd' => 'application/octet-stream',
+ 'so' => 'application/octet-stream',
+ 'sea' => 'application/octet-stream',
+ 'dll' => 'application/octet-stream',
+ 'oda' => 'application/oda',
+ 'pdf' => 'application/pdf',
+ 'ai' => 'application/postscript',
+ 'eps' => 'application/postscript',
+ 'ps' => 'application/postscript',
+ 'smi' => 'application/smil',
+ 'smil' => 'application/smil',
+ 'mif' => 'application/vnd.mif',
+ 'xls' => 'application/vnd.ms-excel',
+ 'ppt' => 'application/vnd.ms-powerpoint',
+ 'wbxml' => 'application/vnd.wap.wbxml',
+ 'wmlc' => 'application/vnd.wap.wmlc',
+ 'dcr' => 'application/x-director',
+ 'dir' => 'application/x-director',
+ 'dxr' => 'application/x-director',
+ 'dvi' => 'application/x-dvi',
+ 'gtar' => 'application/x-gtar',
+ 'php' => 'application/x-httpd-php',
+ 'php4' => 'application/x-httpd-php',
+ 'php3' => 'application/x-httpd-php',
+ 'phtml' => 'application/x-httpd-php',
+ 'phps' => 'application/x-httpd-php-source',
+ 'js' => 'application/x-javascript',
+ 'swf' => 'application/x-shockwave-flash',
+ 'sit' => 'application/x-stuffit',
+ 'tar' => 'application/x-tar',
+ 'tgz' => 'application/x-tar',
+ 'xhtml' => 'application/xhtml+xml',
+ 'xht' => 'application/xhtml+xml',
+ 'zip' => 'application/zip',
+ 'mid' => 'audio/midi',
+ 'midi' => 'audio/midi',
+ 'mpga' => 'audio/mpeg',
+ 'mp2' => 'audio/mpeg',
+ 'mp3' => 'audio/mpeg',
+ 'aif' => 'audio/x-aiff',
+ 'aiff' => 'audio/x-aiff',
+ 'aifc' => 'audio/x-aiff',
+ 'ram' => 'audio/x-pn-realaudio',
+ 'rm' => 'audio/x-pn-realaudio',
+ 'rpm' => 'audio/x-pn-realaudio-plugin',
+ 'ra' => 'audio/x-realaudio',
+ 'rv' => 'video/vnd.rn-realvideo',
+ 'wav' => 'audio/x-wav',
+ 'bmp' => 'image/bmp',
+ 'gif' => 'image/gif',
+ 'jpeg' => 'image/jpeg',
+ 'jpg' => 'image/jpeg',
+ 'jpe' => 'image/jpeg',
+ 'png' => 'image/png',
+ 'tiff' => 'image/tiff',
+ 'tif' => 'image/tiff',
+ 'css' => 'text/css',
+ 'html' => 'text/html',
+ 'htm' => 'text/html',
+ 'shtml' => 'text/html',
+ 'txt' => 'text/plain',
+ 'text' => 'text/plain',
+ 'log' => 'text/plain',
+ 'rtx' => 'text/richtext',
+ 'rtf' => 'text/rtf',
+ 'xml' => 'text/xml',
+ 'xsl' => 'text/xml',
+ 'mpeg' => 'video/mpeg',
+ 'mpg' => 'video/mpeg',
+ 'mpe' => 'video/mpeg',
+ 'qt' => 'video/quicktime',
+ 'mov' => 'video/quicktime',
+ 'avi' => 'video/x-msvideo',
+ 'movie' => 'video/x-sgi-movie',
+ 'doc' => 'application/msword',
+ 'word' => 'application/msword',
+ 'xl' => 'application/excel',
+ 'eml' => 'message/rfc822'
+ );
+
+ return ( ! isset($mimes[strtolower($ext)])) ? "application/x-unknown-content-type" : $mimes[strtolower($ext)];
+ }
+
+}
+// END CI_Email class
+
+/* End of file Email.php */
/* Location: ./system/libraries/Email.php */ \ No newline at end of file
diff --git a/system/libraries/Ftp.php b/system/libraries/Ftp.php
index ec84eb0a7..1a3ab184c 100644
--- a/system/libraries/Ftp.php
+++ b/system/libraries/Ftp.php
@@ -1,618 +1,618 @@
-<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
-/**
- * CodeIgniter
- *
- * An open source application development framework for PHP 4.3.2 or newer
- *
- * @package CodeIgniter
- * @author ExpressionEngine Dev Team
- * @copyright Copyright (c) 2008, EllisLab, Inc.
- * @license http://codeigniter.com/user_guide/license.html
- * @link http://codeigniter.com
- * @since Version 1.0
- * @filesource
- */
-
-// ------------------------------------------------------------------------
-
-/**
- * FTP Class
- *
- * @package CodeIgniter
- * @subpackage Libraries
- * @category Libraries
- * @author ExpressionEngine Dev Team
- * @link http://codeigniter.com/user_guide/libraries/ftp.html
- */
-class CI_FTP {
-
- var $hostname = '';
- var $username = '';
- var $password = '';
- var $port = 21;
- var $passive = TRUE;
- var $debug = FALSE;
- var $conn_id = FALSE;
-
-
- /**
- * Constructor - Sets Preferences
- *
- * The constructor can be passed an array of config values
- */
- function CI_FTP($config = array())
- {
- if (count($config) > 0)
- {
- $this->initialize($config);
- }
-
- log_message('debug', "FTP Class Initialized");
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Initialize preferences
- *
- * @access public
- * @param array
- * @return void
- */
- function initialize($config = array())
- {
- foreach ($config as $key => $val)
- {
- if (isset($this->$key))
- {
- $this->$key = $val;
- }
- }
-
- // Prep the hostname
- $this->hostname = preg_replace('|.+?://|', '', $this->hostname);
- }
-
- // --------------------------------------------------------------------
-
- /**
- * FTP Connect
- *
- * @access public
- * @param array the connection values
- * @return bool
- */
- function connect($config = array())
- {
- if (count($config) > 0)
- {
- $this->initialize($config);
- }
-
- if (FALSE === ($this->conn_id = @ftp_connect($this->hostname, $this->port)))
- {
- if ($this->debug == TRUE)
- {
- $this->_error('ftp_unable_to_connect');
- }
- return FALSE;
- }
-
- if ( ! $this->_login())
- {
- if ($this->debug == TRUE)
- {
- $this->_error('ftp_unable_to_login');
- }
- return FALSE;
- }
-
- // Set passive mode if needed
- if ($this->passive == TRUE)
- {
- ftp_pasv($this->conn_id, TRUE);
- }
-
- return TRUE;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * FTP Login
- *
- * @access private
- * @return bool
- */
- function _login()
- {
- return @ftp_login($this->conn_id, $this->username, $this->password);
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Validates the connection ID
- *
- * @access private
- * @return bool
- */
- function _is_conn()
- {
- if ( ! is_resource($this->conn_id))
- {
- if ($this->debug == TRUE)
- {
- $this->_error('ftp_no_connection');
- }
- return FALSE;
- }
- return TRUE;
- }
-
- // --------------------------------------------------------------------
-
-
- /**
- * Change direcotry
- *
- * The second parameter lets us momentarily turn off debugging so that
- * this function can be used to test for the existance of a folder
- * without throwing an error. There's no FTP equivalent to is_dir()
- * so we do it by trying to change to a particular directory.
- * Internally, this paramter is only used by the "mirror" function below.
- *
- * @access public
- * @param string
- * @param bool
- * @return bool
- */
- function changedir($path = '', $supress_debug = FALSE)
- {
- if ($path == '' OR ! $this->_is_conn())
- {
- return FALSE;
- }
-
- $result = @ftp_chdir($this->conn_id, $path);
-
- if ($result === FALSE)
- {
- if ($this->debug == TRUE AND $supress_debug == FALSE)
- {
- $this->_error('ftp_unable_to_changedir');
- }
- return FALSE;
- }
-
- return TRUE;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Create a directory
- *
- * @access public
- * @param string
- * @return bool
- */
- function mkdir($path = '', $permissions = NULL)
- {
- if ($path == '' OR ! $this->_is_conn())
- {
- return FALSE;
- }
-
- $result = @ftp_mkdir($this->conn_id, $path);
-
- if ($result === FALSE)
- {
- if ($this->debug == TRUE)
- {
- $this->_error('ftp_unable_to_makdir');
- }
- return FALSE;
- }
-
- // Set file permissions if needed
- if ( ! is_null($permissions))
- {
- $this->chmod($path, (int)$permissions);
- }
-
- return TRUE;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Upload a file to the server
- *
- * @access public
- * @param string
- * @param string
- * @param string
- * @return bool
- */
- function upload($locpath, $rempath, $mode = 'auto', $permissions = NULL)
- {
- if ( ! $this->_is_conn())
- {
- return FALSE;
- }
-
- if ( ! file_exists($locpath))
- {
- $this->_error('ftp_no_source_file');
- return FALSE;
- }
-
- // Set the mode if not specified
- if ($mode == 'auto')
- {
- // Get the file extension so we can set the upload type
- $ext = $this->_getext($locpath);
- $mode = $this->_settype($ext);
- }
-
- $mode = ($mode == 'ascii') ? FTP_ASCII : FTP_BINARY;
-
- $result = @ftp_put($this->conn_id, $rempath, $locpath, $mode);
-
- if ($result === FALSE)
- {
- if ($this->debug == TRUE)
- {
- $this->_error('ftp_unable_to_upload');
- }
- return FALSE;
- }
-
- // Set file permissions if needed
- if ( ! is_null($permissions))
- {
- $this->chmod($rempath, (int)$permissions);
- }
-
- return TRUE;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Rename (or move) a file
- *
- * @access public
- * @param string
- * @param string
- * @param bool
- * @return bool
- */
- function rename($old_file, $new_file, $move = FALSE)
- {
- if ( ! $this->_is_conn())
- {
- return FALSE;
- }
-
- $result = @ftp_rename($this->conn_id, $old_file, $new_file);
-
- if ($result === FALSE)
- {
- if ($this->debug == TRUE)
- {
- $msg = ($move == FALSE) ? 'ftp_unable_to_rename' : 'ftp_unable_to_move';
-
- $this->_error($msg);
- }
- return FALSE;
- }
-
- return TRUE;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Move a file
- *
- * @access public
- * @param string
- * @param string
- * @return bool
- */
- function move($old_file, $new_file)
- {
- return $this->rename($old_file, $new_file, TRUE);
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Rename (or move) a file
- *
- * @access public
- * @param string
- * @return bool
- */
- function delete_file($filepath)
- {
- if ( ! $this->_is_conn())
- {
- return FALSE;
- }
-
- $result = @ftp_delete($this->conn_id, $filepath);
-
- if ($result === FALSE)
- {
- if ($this->debug == TRUE)
- {
- $this->_error('ftp_unable_to_delete');
- }
- return FALSE;
- }
-
- return TRUE;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Delete a folder and recursively delete everything (including sub-folders)
- * containted within it.
- *
- * @access public
- * @param string
- * @return bool
- */
- function delete_dir($filepath)
- {
- if ( ! $this->_is_conn())
- {
- return FALSE;
- }
-
- // Add a trailing slash to the file path if needed
- $filepath = preg_replace("/(.+?)\/*$/", "\\1/", $filepath);
-
- $list = $this->list_files($filepath);
-
- if ($list !== FALSE AND count($list) > 0)
- {
- foreach ($list as $item)
- {
- // If we can't delete the item it's probaly a folder so
- // we'll recursively call delete_dir()
- if ( ! @ftp_delete($this->conn_id, $item))
- {
- $this->delete_dir($item);
- }
- }
- }
-
- $result = @ftp_rmdir($this->conn_id, $filepath);
-
- if ($result === FALSE)
- {
- if ($this->debug == TRUE)
- {
- $this->_error('ftp_unable_to_delete');
- }
- return FALSE;
- }
-
- return TRUE;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Set file permissions
- *
- * @access public
- * @param string the file path
- * @param string the permissions
- * @return bool
- */
- function chmod($path, $perm)
- {
- if ( ! $this->_is_conn())
- {
- return FALSE;
- }
-
- // Permissions can only be set when running PHP 5
- if ( ! function_exists('ftp_chmod'))
- {
- if ($this->debug == TRUE)
- {
- $this->_error('ftp_unable_to_chmod');
- }
- return FALSE;
- }
-
- $result = @ftp_chmod($this->conn_id, $perm, $path);
-
- if ($result === FALSE)
- {
- if ($this->debug == TRUE)
- {
- $this->_error('ftp_unable_to_chmod');
- }
- return FALSE;
- }
-
- return TRUE;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * FTP List files in the specified directory
- *
- * @access public
- * @return array
- */
- function list_files($path = '.')
- {
- if ( ! $this->_is_conn())
- {
- return FALSE;
- }
-
- return ftp_nlist($this->conn_id, $path);
- }
-
- // ------------------------------------------------------------------------
-
- /**
- * Read a directory and recreate it remotely
- *
- * This function recursively reads a folder and everything it contains (including
- * sub-folders) and creates a mirror via FTP based on it. Whatever the directory structure
- * of the original file path will be recreated on the server.
- *
- * @access public
- * @param string path to source with trailing slash
- * @param string path to destination - include the base folder with trailing slash
- * @return bool
- */
- function mirror($locpath, $rempath)
- {
- if ( ! $this->_is_conn())
- {
- return FALSE;
- }
-
- // Open the local file path
- if ($fp = @opendir($locpath))
- {
- // Attempt to open the remote file path.
- if ( ! $this->changedir($rempath, TRUE))
- {
- // If it doesn't exist we'll attempt to create the direcotory
- if ( ! $this->mkdir($rempath) OR ! $this->changedir($rempath))
- {
- return FALSE;
- }
- }
-
- // Recursively read the local directory
- while (FALSE !== ($file = readdir($fp)))
- {
- if (@is_dir($locpath.$file) && substr($file, 0, 1) != '.')
- {
- $this->mirror($locpath.$file."/", $rempath.$file."/");
- }
- elseif (substr($file, 0, 1) != ".")
- {
- // Get the file extension so we can se the upload type
- $ext = $this->_getext($file);
- $mode = $this->_settype($ext);
-
- $this->upload($locpath.$file, $rempath.$file, $mode);
- }
- }
- return TRUE;
- }
-
- return FALSE;
- }
-
-
- // --------------------------------------------------------------------
-
- /**
- * Extract the file extension
- *
- * @access private
- * @param string
- * @return string
- */
- function _getext($filename)
- {
- if (FALSE === strpos($filename, '.'))
- {
- return 'txt';
- }
-
- $x = explode('.', $filename);
- return end($x);
- }
-
-
- // --------------------------------------------------------------------
-
- /**
- * Set the upload type
- *
- * @access private
- * @param string
- * @return string
- */
- function _settype($ext)
- {
- $text_types = array(
- 'txt',
- 'text',
- 'php',
- 'phps',
- 'php4',
- 'js',
- 'css',
- 'htm',
- 'html',
- 'phtml',
- 'shtml',
- 'log',
- 'xml'
- );
-
-
- return (in_array($ext, $text_types)) ? 'ascii' : 'binary';
- }
-
- // ------------------------------------------------------------------------
-
- /**
- * Close the connection
- *
- * @access public
- * @param string path to source
- * @param string path to destination
- * @return bool
- */
- function close()
- {
- if ( ! $this->_is_conn())
- {
- return FALSE;
- }
-
- @ftp_close($this->conn_id);
- }
-
- // ------------------------------------------------------------------------
-
- /**
- * Display error message
- *
- * @access private
- * @param string
- * @return bool
- */
- function _error($line)
- {
- $CI =& get_instance();
- $CI->lang->load('ftp');
- show_error($CI->lang->line($line));
- }
-
-
-}
-// END FTP Class
-
-/* End of file Ftp.php */
+<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+/**
+ * CodeIgniter
+ *
+ * An open source application development framework for PHP 4.3.2 or newer
+ *
+ * @package CodeIgniter
+ * @author ExpressionEngine Dev Team
+ * @copyright Copyright (c) 2008, EllisLab, Inc.
+ * @license http://codeigniter.com/user_guide/license.html
+ * @link http://codeigniter.com
+ * @since Version 1.0
+ * @filesource
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+ * FTP Class
+ *
+ * @package CodeIgniter
+ * @subpackage Libraries
+ * @category Libraries
+ * @author ExpressionEngine Dev Team
+ * @link http://codeigniter.com/user_guide/libraries/ftp.html
+ */
+class CI_FTP {
+
+ var $hostname = '';
+ var $username = '';
+ var $password = '';
+ var $port = 21;
+ var $passive = TRUE;
+ var $debug = FALSE;
+ var $conn_id = FALSE;
+
+
+ /**
+ * Constructor - Sets Preferences
+ *
+ * The constructor can be passed an array of config values
+ */
+ function CI_FTP($config = array())
+ {
+ if (count($config) > 0)
+ {
+ $this->initialize($config);
+ }
+
+ log_message('debug', "FTP Class Initialized");
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Initialize preferences
+ *
+ * @access public
+ * @param array
+ * @return void
+ */
+ function initialize($config = array())
+ {
+ foreach ($config as $key => $val)
+ {
+ if (isset($this->$key))
+ {
+ $this->$key = $val;
+ }
+ }
+
+ // Prep the hostname
+ $this->hostname = preg_replace('|.+?://|', '', $this->hostname);
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * FTP Connect
+ *
+ * @access public
+ * @param array the connection values
+ * @return bool
+ */
+ function connect($config = array())
+ {
+ if (count($config) > 0)
+ {
+ $this->initialize($config);
+ }
+
+ if (FALSE === ($this->conn_id = @ftp_connect($this->hostname, $this->port)))
+ {
+ if ($this->debug == TRUE)
+ {
+ $this->_error('ftp_unable_to_connect');
+ }
+ return FALSE;
+ }
+
+ if ( ! $this->_login())
+ {
+ if ($this->debug == TRUE)
+ {
+ $this->_error('ftp_unable_to_login');
+ }
+ return FALSE;
+ }
+
+ // Set passive mode if needed
+ if ($this->passive == TRUE)
+ {
+ ftp_pasv($this->conn_id, TRUE);
+ }
+
+ return TRUE;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * FTP Login
+ *
+ * @access private
+ * @return bool
+ */
+ function _login()
+ {
+ return @ftp_login($this->conn_id, $this->username, $this->password);
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Validates the connection ID
+ *
+ * @access private
+ * @return bool
+ */
+ function _is_conn()
+ {
+ if ( ! is_resource($this->conn_id))
+ {
+ if ($this->debug == TRUE)
+ {
+ $this->_error('ftp_no_connection');
+ }
+ return FALSE;
+ }
+ return TRUE;
+ }
+
+ // --------------------------------------------------------------------
+
+
+ /**
+ * Change direcotry
+ *
+ * The second parameter lets us momentarily turn off debugging so that
+ * this function can be used to test for the existance of a folder
+ * without throwing an error. There's no FTP equivalent to is_dir()
+ * so we do it by trying to change to a particular directory.
+ * Internally, this paramter is only used by the "mirror" function below.
+ *
+ * @access public
+ * @param string
+ * @param bool
+ * @return bool
+ */
+ function changedir($path = '', $supress_debug = FALSE)
+ {
+ if ($path == '' OR ! $this->_is_conn())
+ {
+ return FALSE;
+ }
+
+ $result = @ftp_chdir($this->conn_id, $path);
+
+ if ($result === FALSE)
+ {
+ if ($this->debug == TRUE AND $supress_debug == FALSE)
+ {
+ $this->_error('ftp_unable_to_changedir');
+ }
+ return FALSE;
+ }
+
+ return TRUE;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Create a directory
+ *
+ * @access public
+ * @param string
+ * @return bool
+ */
+ function mkdir($path = '', $permissions = NULL)
+ {
+ if ($path == '' OR ! $this->_is_conn())
+ {
+ return FALSE;
+ }
+
+ $result = @ftp_mkdir($this->conn_id, $path);
+
+ if ($result === FALSE)
+ {
+ if ($this->debug == TRUE)
+ {
+ $this->_error('ftp_unable_to_makdir');
+ }
+ return FALSE;
+ }
+
+ // Set file permissions if needed
+ if ( ! is_null($permissions))
+ {
+ $this->chmod($path, (int)$permissions);
+ }
+
+ return TRUE;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Upload a file to the server
+ *
+ * @access public
+ * @param string
+ * @param string
+ * @param string
+ * @return bool
+ */
+ function upload($locpath, $rempath, $mode = 'auto', $permissions = NULL)
+ {
+ if ( ! $this->_is_conn())
+ {
+ return FALSE;
+ }
+
+ if ( ! file_exists($locpath))
+ {
+ $this->_error('ftp_no_source_file');
+ return FALSE;
+ }
+
+ // Set the mode if not specified
+ if ($mode == 'auto')
+ {
+ // Get the file extension so we can set the upload type
+ $ext = $this->_getext($locpath);
+ $mode = $this->_settype($ext);
+ }
+
+ $mode = ($mode == 'ascii') ? FTP_ASCII : FTP_BINARY;
+
+ $result = @ftp_put($this->conn_id, $rempath, $locpath, $mode);
+
+ if ($result === FALSE)
+ {
+ if ($this->debug == TRUE)
+ {
+ $this->_error('ftp_unable_to_upload');
+ }
+ return FALSE;
+ }
+
+ // Set file permissions if needed
+ if ( ! is_null($permissions))
+ {
+ $this->chmod($rempath, (int)$permissions);
+ }
+
+ return TRUE;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Rename (or move) a file
+ *
+ * @access public
+ * @param string
+ * @param string
+ * @param bool
+ * @return bool
+ */
+ function rename($old_file, $new_file, $move = FALSE)
+ {
+ if ( ! $this->_is_conn())
+ {
+ return FALSE;
+ }
+
+ $result = @ftp_rename($this->conn_id, $old_file, $new_file);
+
+ if ($result === FALSE)
+ {
+ if ($this->debug == TRUE)
+ {
+ $msg = ($move == FALSE) ? 'ftp_unable_to_rename' : 'ftp_unable_to_move';
+
+ $this->_error($msg);
+ }
+ return FALSE;
+ }
+
+ return TRUE;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Move a file
+ *
+ * @access public
+ * @param string
+ * @param string
+ * @return bool
+ */
+ function move($old_file, $new_file)
+ {
+ return $this->rename($old_file, $new_file, TRUE);
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Rename (or move) a file
+ *
+ * @access public
+ * @param string
+ * @return bool
+ */
+ function delete_file($filepath)
+ {
+ if ( ! $this->_is_conn())
+ {
+ return FALSE;
+ }
+
+ $result = @ftp_delete($this->conn_id, $filepath);
+
+ if ($result === FALSE)
+ {
+ if ($this->debug == TRUE)
+ {
+ $this->_error('ftp_unable_to_delete');
+ }
+ return FALSE;
+ }
+
+ return TRUE;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Delete a folder and recursively delete everything (including sub-folders)
+ * containted within it.
+ *
+ * @access public
+ * @param string
+ * @return bool
+ */
+ function delete_dir($filepath)
+ {
+ if ( ! $this->_is_conn())
+ {
+ return FALSE;
+ }
+
+ // Add a trailing slash to the file path if needed
+ $filepath = preg_replace("/(.+?)\/*$/", "\\1/", $filepath);
+
+ $list = $this->list_files($filepath);
+
+ if ($list !== FALSE AND count($list) > 0)
+ {
+ foreach ($list as $item)
+ {
+ // If we can't delete the item it's probaly a folder so
+ // we'll recursively call delete_dir()
+ if ( ! @ftp_delete($this->conn_id, $item))
+ {
+ $this->delete_dir($item);
+ }
+ }
+ }
+
+ $result = @ftp_rmdir($this->conn_id, $filepath);
+
+ if ($result === FALSE)
+ {
+ if ($this->debug == TRUE)
+ {
+ $this->_error('ftp_unable_to_delete');
+ }
+ return FALSE;
+ }
+
+ return TRUE;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Set file permissions
+ *
+ * @access public
+ * @param string the file path
+ * @param string the permissions
+ * @return bool
+ */
+ function chmod($path, $perm)
+ {
+ if ( ! $this->_is_conn())
+ {
+ return FALSE;
+ }
+
+ // Permissions can only be set when running PHP 5
+ if ( ! function_exists('ftp_chmod'))
+ {
+ if ($this->debug == TRUE)
+ {
+ $this->_error('ftp_unable_to_chmod');
+ }
+ return FALSE;
+ }
+
+ $result = @ftp_chmod($this->conn_id, $perm, $path);
+
+ if ($result === FALSE)
+ {
+ if ($this->debug == TRUE)
+ {
+ $this->_error('ftp_unable_to_chmod');
+ }
+ return FALSE;
+ }
+
+ return TRUE;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * FTP List files in the specified directory
+ *
+ * @access public
+ * @return array
+ */
+ function list_files($path = '.')
+ {
+ if ( ! $this->_is_conn())
+ {
+ return FALSE;
+ }
+
+ return ftp_nlist($this->conn_id, $path);
+ }
+
+ // ------------------------------------------------------------------------
+
+ /**
+ * Read a directory and recreate it remotely
+ *
+ * This function recursively reads a folder and everything it contains (including
+ * sub-folders) and creates a mirror via FTP based on it. Whatever the directory structure
+ * of the original file path will be recreated on the server.
+ *
+ * @access public
+ * @param string path to source with trailing slash
+ * @param string path to destination - include the base folder with trailing slash
+ * @return bool
+ */
+ function mirror($locpath, $rempath)
+ {
+ if ( ! $this->_is_conn())
+ {
+ return FALSE;
+ }
+
+ // Open the local file path
+ if ($fp = @opendir($locpath))
+ {
+ // Attempt to open the remote file path.
+ if ( ! $this->changedir($rempath, TRUE))
+ {
+ // If it doesn't exist we'll attempt to create the direcotory
+ if ( ! $this->mkdir($rempath) OR ! $this->changedir($rempath))
+ {
+ return FALSE;
+ }
+ }
+
+ // Recursively read the local directory
+ while (FALSE !== ($file = readdir($fp)))
+ {
+ if (@is_dir($locpath.$file) && substr($file, 0, 1) != '.')
+ {
+ $this->mirror($locpath.$file."/", $rempath.$file."/");
+ }
+ elseif (substr($file, 0, 1) != ".")
+ {
+ // Get the file extension so we can se the upload type
+ $ext = $this->_getext($file);
+ $mode = $this->_settype($ext);
+
+ $this->upload($locpath.$file, $rempath.$file, $mode);
+ }
+ }
+ return TRUE;
+ }
+
+ return FALSE;
+ }
+
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Extract the file extension
+ *
+ * @access private
+ * @param string
+ * @return string
+ */
+ function _getext($filename)
+ {
+ if (FALSE === strpos($filename, '.'))
+ {
+ return 'txt';
+ }
+
+ $x = explode('.', $filename);
+ return end($x);
+ }
+
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Set the upload type
+ *
+ * @access private
+ * @param string
+ * @return string
+ */
+ function _settype($ext)
+ {
+ $text_types = array(
+ 'txt',
+ 'text',
+ 'php',
+ 'phps',
+ 'php4',
+ 'js',
+ 'css',
+ 'htm',
+ 'html',
+ 'phtml',
+ 'shtml',
+ 'log',
+ 'xml'
+ );
+
+
+ return (in_array($ext, $text_types)) ? 'ascii' : 'binary';
+ }
+
+ // ------------------------------------------------------------------------
+
+ /**
+ * Close the connection
+ *
+ * @access public
+ * @param string path to source
+ * @param string path to destination
+ * @return bool
+ */
+ function close()
+ {
+ if ( ! $this->_is_conn())
+ {
+ return FALSE;
+ }
+
+ @ftp_close($this->conn_id);
+ }
+
+ // ------------------------------------------------------------------------
+
+ /**
+ * Display error message
+ *
+ * @access private
+ * @param string
+ * @return bool
+ */
+ function _error($line)
+ {
+ $CI =& get_instance();
+ $CI->lang->load('ftp');
+ show_error($CI->lang->line($line));
+ }
+
+
+}
+// END FTP Class
+
+/* End of file Ftp.php */
/* Location: ./system/libraries/Ftp.php */ \ No newline at end of file
diff --git a/system/libraries/Hooks.php b/system/libraries/Hooks.php
index 46f3ac478..55019e486 100644
--- a/system/libraries/Hooks.php
+++ b/system/libraries/Hooks.php
@@ -1,226 +1,226 @@
-<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
-/**
- * CodeIgniter
- *
- * An open source application development framework for PHP 4.3.2 or newer
- *
- * @package CodeIgniter
- * @author ExpressionEngine Dev Team
- * @copyright Copyright (c) 2008, EllisLab, Inc.
- * @license http://codeigniter.com/user_guide/license.html
- * @link http://codeigniter.com
- * @since Version 1.0
- * @filesource
- */
-
-// ------------------------------------------------------------------------
-
-/**
- * CodeIgniter Hooks Class
- *
- * Provides a mechanism to extend the base system without hacking. Most of
- * this class is borrowed from Paul's Extension class in ExpressionEngine.
- *
- * @package CodeIgniter
- * @subpackage Libraries
- * @category Libraries
- * @author ExpressionEngine Dev Team
- * @link http://codeigniter.com/user_guide/libraries/encryption.html
- */
-class CI_Hooks {
-
- var $enabled = FALSE;
- var $hooks = array();
- var $in_progress = FALSE;
-
- /**
- * Constructor
- *
- */
- function CI_Hooks()
- {
- $this->_initialize();
- log_message('debug', "Hooks Class Initialized");
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Initialize the Hooks Preferences
- *
- * @access private
- * @return void
- */
- function _initialize()
- {
- $CFG =& load_class('Config');
-
- // If hooks are not enabled in the config file
- // there is nothing else to do
-
- if ($CFG->item('enable_hooks') == FALSE)
- {
- return;
- }
-
- // Grab the "hooks" definition file.
- // If there are no hooks, we're done.
-
- @include(APPPATH.'config/hooks'.EXT);
-
- if ( ! isset($hook) OR ! is_array($hook))
- {
- return;
- }
-
- $this->hooks =& $hook;
- $this->enabled = TRUE;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Call Hook
- *
- * Calls a particular hook
- *
- * @access private
- * @param string the hook name
- * @return mixed
- */
- function _call_hook($which = '')
- {
- if ( ! $this->enabled OR ! isset($this->hooks[$which]))
- {
- return FALSE;
- }
-
- if (isset($this->hooks[$which][0]) AND is_array($this->hooks[$which][0]))
- {
- foreach ($this->hooks[$which] as $val)
- {
- $this->_run_hook($val);
- }
- }
- else
- {
- $this->_run_hook($this->hooks[$which]);
- }
-
- return TRUE;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Run Hook
- *
- * Runs a particular hook
- *
- * @access private
- * @param array the hook details
- * @return bool
- */
- function _run_hook($data)
- {
- if ( ! is_array($data))
- {
- return FALSE;
- }
-
- // -----------------------------------
- // Safety - Prevents run-away loops
- // -----------------------------------
-
- // If the script being called happens to have the same
- // hook call within it a loop can happen
-
- if ($this->in_progress == TRUE)
- {
- return;
- }
-
- // -----------------------------------
- // Set file path
- // -----------------------------------
-
- if ( ! isset($data['filepath']) OR ! isset($data['filename']))
- {
- return FALSE;
- }
-
- $filepath = APPPATH.$data['filepath'].'/'.$data['filename'];
-
- if ( ! file_exists($filepath))
- {
- return FALSE;
- }
-
- // -----------------------------------
- // Set class/function name
- // -----------------------------------
-
- $class = FALSE;
- $function = FALSE;
- $params = '';
-
- if (isset($data['class']) AND $data['class'] != '')
- {
- $class = $data['class'];
- }
-
- if (isset($data['function']))
- {
- $function = $data['function'];
- }
-
- if (isset($data['params']))
- {
- $params = $data['params'];
- }
-
- if ($class === FALSE AND $function === FALSE)
- {
- return FALSE;
- }
-
- // -----------------------------------
- // Set the in_progress flag
- // -----------------------------------
-
- $this->in_progress = TRUE;
-
- // -----------------------------------
- // Call the requested class and/or function
- // -----------------------------------
-
- if ($class !== FALSE)
- {
- if ( ! class_exists($class))
- {
- require($filepath);
- }
-
- $HOOK = new $class;
- $HOOK->$function($params);
- }
- else
- {
- if ( ! function_exists($function))
- {
- require($filepath);
- }
-
- $function($params);
- }
-
- $this->in_progress = FALSE;
- return TRUE;
- }
-
-}
-
-// END CI_Hooks class
-
-/* End of file Hooks.php */
+<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+/**
+ * CodeIgniter
+ *
+ * An open source application development framework for PHP 4.3.2 or newer
+ *
+ * @package CodeIgniter
+ * @author ExpressionEngine Dev Team
+ * @copyright Copyright (c) 2008, EllisLab, Inc.
+ * @license http://codeigniter.com/user_guide/license.html
+ * @link http://codeigniter.com
+ * @since Version 1.0
+ * @filesource
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+ * CodeIgniter Hooks Class
+ *
+ * Provides a mechanism to extend the base system without hacking. Most of
+ * this class is borrowed from Paul's Extension class in ExpressionEngine.
+ *
+ * @package CodeIgniter
+ * @subpackage Libraries
+ * @category Libraries
+ * @author ExpressionEngine Dev Team
+ * @link http://codeigniter.com/user_guide/libraries/encryption.html
+ */
+class CI_Hooks {
+
+ var $enabled = FALSE;
+ var $hooks = array();
+ var $in_progress = FALSE;
+
+ /**
+ * Constructor
+ *
+ */
+ function CI_Hooks()
+ {
+ $this->_initialize();
+ log_message('debug', "Hooks Class Initialized");
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Initialize the Hooks Preferences
+ *
+ * @access private
+ * @return void
+ */
+ function _initialize()
+ {
+ $CFG =& load_class('Config');
+
+ // If hooks are not enabled in the config file
+ // there is nothing else to do
+
+ if ($CFG->item('enable_hooks') == FALSE)
+ {
+ return;
+ }
+
+ // Grab the "hooks" definition file.
+ // If there are no hooks, we're done.
+
+ @include(APPPATH.'config/hooks'.EXT);
+
+ if ( ! isset($hook) OR ! is_array($hook))
+ {
+ return;
+ }
+
+ $this->hooks =& $hook;
+ $this->enabled = TRUE;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Call Hook
+ *
+ * Calls a particular hook
+ *
+ * @access private
+ * @param string the hook name
+ * @return mixed
+ */
+ function _call_hook($which = '')
+ {
+ if ( ! $this->enabled OR ! isset($this->hooks[$which]))
+ {
+ return FALSE;
+ }
+
+ if (isset($this->hooks[$which][0]) AND is_array($this->hooks[$which][0]))
+ {
+ foreach ($this->hooks[$which] as $val)
+ {
+ $this->_run_hook($val);
+ }
+ }
+ else
+ {
+ $this->_run_hook($this->hooks[$which]);
+ }
+
+ return TRUE;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Run Hook
+ *
+ * Runs a particular hook
+ *
+ * @access private
+ * @param array the hook details
+ * @return bool
+ */
+ function _run_hook($data)
+ {
+ if ( ! is_array($data))
+ {
+ return FALSE;
+ }
+
+ // -----------------------------------
+ // Safety - Prevents run-away loops
+ // -----------------------------------
+
+ // If the script being called happens to have the same
+ // hook call within it a loop can happen
+
+ if ($this->in_progress == TRUE)
+ {
+ return;
+ }
+
+ // -----------------------------------
+ // Set file path
+ // -----------------------------------
+
+ if ( ! isset($data['filepath']) OR ! isset($data['filename']))
+ {
+ return FALSE;
+ }
+
+ $filepath = APPPATH.$data['filepath'].'/'.$data['filename'];
+
+ if ( ! file_exists($filepath))
+ {
+ return FALSE;
+ }
+
+ // -----------------------------------
+ // Set class/function name
+ // -----------------------------------
+
+ $class = FALSE;
+ $function = FALSE;
+ $params = '';
+
+ if (isset($data['class']) AND $data['class'] != '')
+ {
+ $class = $data['class'];
+ }
+
+ if (isset($data['function']))
+ {
+ $function = $data['function'];
+ }
+
+ if (isset($data['params']))
+ {
+ $params = $data['params'];
+ }
+
+ if ($class === FALSE AND $function === FALSE)
+ {
+ return FALSE;
+ }
+
+ // -----------------------------------
+ // Set the in_progress flag
+ // -----------------------------------
+
+ $this->in_progress = TRUE;
+
+ // -----------------------------------
+ // Call the requested class and/or function
+ // -----------------------------------
+
+ if ($class !== FALSE)
+ {
+ if ( ! class_exists($class))
+ {
+ require($filepath);
+ }
+
+ $HOOK = new $class;
+ $HOOK->$function($params);
+ }
+ else
+ {
+ if ( ! function_exists($function))
+ {
+ require($filepath);
+ }
+
+ $function($params);
+ }
+
+ $this->in_progress = FALSE;
+ return TRUE;
+ }
+
+}
+
+// END CI_Hooks class
+
+/* End of file Hooks.php */
/* Location: ./system/libraries/Hooks.php */ \ No newline at end of file
diff --git a/system/libraries/Image_lib.php b/system/libraries/Image_lib.php
index 16201ee9e..f260e7627 100644
--- a/system/libraries/Image_lib.php
+++ b/system/libraries/Image_lib.php
@@ -1,1548 +1,1548 @@
-<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
-/**
- * CodeIgniter
- *
- * An open source application development framework for PHP 4.3.2 or newer
- *
- * @package CodeIgniter
- * @author ExpressionEngine Dev Team
- * @copyright Copyright (c) 2008, EllisLab, Inc.
- * @license http://codeigniter.com/user_guide/license.html
- * @link http://codeigniter.com
- * @since Version 1.0
- * @filesource
- */
-
-// ------------------------------------------------------------------------
-
-/**
- * Image Manipulation class
- *
- * @package CodeIgniter
- * @subpackage Libraries
- * @category Image_lib
- * @author ExpressionEngine Dev Team
- * @link http://codeigniter.com/user_guide/libraries/image_lib.html
- */
-class CI_Image_lib {
-
- var $image_library = 'gd2'; // Can be: imagemagick, netpbm, gd, gd2
- var $library_path = '';
- var $dynamic_output = FALSE; // Whether to send to browser or write to disk
- var $source_image = '';
- var $new_image = '';
- var $width = '';
- var $height = '';
- var $quality = '90';
- var $create_thumb = FALSE;
- var $thumb_marker = '_thumb';
- var $maintain_ratio = TRUE; // Whether to maintain aspect ratio when resizing or use hard values
- var $master_dim = 'auto'; // auto, height, or width. Determines what to use as the master dimension
- var $rotation_angle = '';
- var $x_axis = '';
- var $y_axis = '';
-
- // Watermark Vars
- var $wm_text = ''; // Watermark text if graphic is not used
- var $wm_type = 'text'; // Type of watermarking. Options: text/overlay
- var $wm_x_transp = 4;
- var $wm_y_transp = 4;
- var $wm_overlay_path = ''; // Watermark image path
- var $wm_font_path = ''; // TT font
- var $wm_font_size = 17; // Font size (different versions of GD will either use points or pixels)
- var $wm_vrt_alignment = 'B'; // Vertical alignment: T M B
- var $wm_hor_alignment = 'C'; // Horizontal alignment: L R C
- var $wm_padding = 0; // Padding around text
- var $wm_hor_offset = 0; // Lets you push text to the right
- var $wm_vrt_offset = 0; // Lets you push text down
- var $wm_font_color = '#ffffff'; // Text color
- var $wm_shadow_color = ''; // Dropshadow color
- var $wm_shadow_distance = 2; // Dropshadow distance
- var $wm_opacity = 50; // Image opacity: 1 - 100 Only works with image
-
- // Private Vars
- var $source_folder = '';
- var $dest_folder = '';
- var $mime_type = '';
- var $orig_width = '';
- var $orig_height = '';
- var $image_type = '';
- var $size_str = '';
- var $full_src_path = '';
- var $full_dst_path = '';
- var $create_fnc = 'imagecreatetruecolor';
- var $copy_fnc = 'imagecopyresampled';
- var $error_msg = array();
- var $wm_use_drop_shadow = FALSE;
- var $wm_use_truetype = FALSE;
-
- /**
- * Constructor
- *
- * @access public
- * @param string
- * @return void
- */
- function CI_Image_lib($props = array())
- {
- if (count($props) > 0)
- {
- $this->initialize($props);
- }
-
- log_message('debug', "Image Lib Class Initialized");
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Initialize image properties
- *
- * Resets values in case this class is used in a loop
- *
- * @access public
- * @return void
- */
- function clear()
- {
- $props = array('source_folder', 'dest_folder', 'source_image', 'full_src_path', 'full_dst_path', 'new_image', 'image_type', 'size_str', 'quality', 'orig_width', 'orig_height', 'rotation_angle', 'x_axis', 'y_axis', 'create_fnc', 'copy_fnc', 'wm_overlay_path', 'wm_use_truetype', 'dynamic_output', 'wm_font_size', 'wm_text', 'wm_vrt_alignment', 'wm_hor_alignment', 'wm_padding', 'wm_hor_offset', 'wm_vrt_offset', 'wm_font_color', 'wm_use_drop_shadow', 'wm_shadow_color', 'wm_shadow_distance', 'wm_opacity');
-
- foreach ($props as $val)
- {
- $this->$val = '';
- }
-
- // special consideration for master_dim
- $this->master_dim = 'auto';
- }
-
- // --------------------------------------------------------------------
-
- /**
- * initialize image preferences
- *
- * @access public
- * @param array
- * @return bool
- */
- function initialize($props = array())
- {
- /*
- * Convert array elements into class variables
- */
- if (count($props) > 0)
- {
- foreach ($props as $key => $val)
- {
- $this->$key = $val;
- }
- }
-
- /*
- * Is there a source image?
- *
- * If not, there's no reason to continue
- *
- */
- if ($this->source_image == '')
- {
- $this->set_error('imglib_source_image_required');
- return FALSE;
- }
-
- /*
- * Is getimagesize() Available?
- *
- * We use it to determine the image properties (width/height).
- * Note: We need to figure out how to determine image
- * properties using ImageMagick and NetPBM
- *
- */
- if ( ! function_exists('getimagesize'))
- {
- $this->set_error('imglib_gd_required_for_props');
- return FALSE;
- }
-
- $this->image_library = strtolower($this->image_library);
-
- /*
- * Set the full server path
- *
- * The source image may or may not contain a path.
- * Either way, we'll try use realpath to generate the
- * full server path in order to more reliably read it.
- *
- */
- if (function_exists('realpath') AND @realpath($this->source_image) !== FALSE)
- {
- $full_source_path = str_replace("\\", "/", realpath($this->source_image));
- }
- else
- {
- $full_source_path = $this->source_image;
- }
-
- $x = explode('/', $full_source_path);
- $this->source_image = end($x);
- $this->source_folder = str_replace($this->source_image, '', $full_source_path);
-
- // Set the Image Properties
- if ( ! $this->get_image_properties($this->source_folder.$this->source_image))
- {
- return FALSE;
- }
-
- /*
- * Assign the "new" image name/path
- *
- * If the user has set a "new_image" name it means
- * we are making a copy of the source image. If not
- * it means we are altering the original. We'll
- * set the destination filename and path accordingly.
- *
- */
- if ($this->new_image == '')
- {
- $this->dest_image = $this->source_image;
- $this->dest_folder = $this->source_folder;
- }
- else
- {
- if (strpos($this->new_image, '/') === FALSE)
- {
- $this->dest_folder = $this->source_folder;
- $this->dest_image = $this->new_image;
- }
- else
- {
- if (function_exists('realpath') AND @realpath($this->new_image) !== FALSE)
- {
- $full_dest_path = str_replace("\\", "/", realpath($this->new_image));
- }
- else
- {
- $full_dest_path = $this->new_image;
- }
-
- // Is there a file name?
- if ( ! preg_match("#\.(jpg|jpeg|gif|png)$#i", $full_dest_path))
- {
- $this->dest_folder = $full_dest_path.'/';
- $this->dest_image = $this->source_image;
- }
- else
- {
- $x = explode('/', $full_dest_path);
- $this->dest_image = end($x);
- $this->dest_folder = str_replace($this->dest_image, '', $full_dest_path);
- }
- }
- }
-
- /*
- * Compile the finalized filenames/paths
- *
- * We'll create two master strings containing the
- * full server path to the source image and the
- * full server path to the destination image.
- * We'll also split the destination image name
- * so we can insert the thumbnail marker if needed.
- *
- */
- if ($this->create_thumb === FALSE OR $this->thumb_marker == '')
- {
- $this->thumb_marker = '';
- }
-
- $xp = $this->explode_name($this->dest_image);
-
- $filename = $xp['name'];
- $file_ext = $xp['ext'];
-
- $this->full_src_path = $this->source_folder.$this->source_image;
- $this->full_dst_path = $this->dest_folder.$filename.$this->thumb_marker.$file_ext;
-
- /*
- * Should we maintain image proportions?
- *
- * When creating thumbs or copies, the target width/height
- * might not be in correct proportion with the source
- * image's width/height. We'll recalculate it here.
- *
- */
- if ($this->maintain_ratio === TRUE && ($this->width != '' AND $this->height != ''))
- {
- $this->image_reproportion();
- }
-
- /*
- * Was a width and height specified?
- *
- * If the destination width/height was
- * not submitted we will use the values
- * from the actual file
- *
- */
- if ($this->width == '')
- $this->width = $this->orig_width;
-
- if ($this->height == '')
- $this->height = $this->orig_height;
-
- // Set the quality
- $this->quality = trim(str_replace("%", "", $this->quality));
-
- if ($this->quality == '' OR $this->quality == 0 OR ! is_numeric($this->quality))
- $this->quality = 90;
-
- // Set the x/y coordinates
- $this->x_axis = ($this->x_axis == '' OR ! is_numeric($this->x_axis)) ? 0 : $this->x_axis;
- $this->y_axis = ($this->y_axis == '' OR ! is_numeric($this->y_axis)) ? 0 : $this->y_axis;
-
- // Watermark-related Stuff...
- if ($this->wm_font_color != '')
- {
- if (strlen($this->wm_font_color) == 6)
- {
- $this->wm_font_color = '#'.$this->wm_font_color;
- }
- }
-
- if ($this->wm_shadow_color != '')
- {
- if (strlen($this->wm_shadow_color) == 6)
- {
- $this->wm_shadow_color = '#'.$this->wm_shadow_color;
- }
- }
-
- if ($this->wm_overlay_path != '')
- {
- $this->wm_overlay_path = str_replace("\\", "/", realpath($this->wm_overlay_path));
- }
-
- if ($this->wm_shadow_color != '')
- {
- $this->wm_use_drop_shadow = TRUE;
- }
-
- if ($this->wm_font_path != '')
- {
- $this->wm_use_truetype = TRUE;
- }
-
- return TRUE;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Image Resize
- *
- * This is a wrapper function that chooses the proper
- * resize function based on the protocol specified
- *
- * @access public
- * @return bool
- */
- function resize()
- {
- $protocol = 'image_process_'.$this->image_library;
-
- if (eregi("gd2$", $protocol))
- {
- $protocol = 'image_process_gd';
- }
-
- return $this->$protocol('resize');
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Image Crop
- *
- * This is a wrapper function that chooses the proper
- * cropping function based on the protocol specified
- *
- * @access public
- * @return bool
- */
- function crop()
- {
- $protocol = 'image_process_'.$this->image_library;
-
- if (eregi("gd2$", $protocol))
- {
- $protocol = 'image_process_gd';
- }
-
- return $this->$protocol('crop');
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Image Rotate
- *
- * This is a wrapper function that chooses the proper
- * rotation function based on the protocol specified
- *
- * @access public
- * @return bool
- */
- function rotate()
- {
- // Allowed rotation values
- $degs = array(90, 180, 270, 'vrt', 'hor');
-
- if ($this->rotation_angle == '' OR ! in_array($this->rotation_angle, $degs, TRUE))
- {
- $this->set_error('imglib_rotation_angle_required');
- return FALSE;
- }
-
- // Reassign the width and height
- if ($this->rotation_angle == 90 OR $this->rotation_angle == 270)
- {
- $this->width = $this->orig_height;
- $this->height = $this->orig_width;
- }
- else
- {
- $this->width = $this->orig_width;
- $this->height = $this->orig_height;
- }
-
-
- // Choose resizing function
- if ($this->image_library == 'imagemagick' OR $this->image_library == 'netpbm')
- {
- $protocol = 'image_process_'.$this->image_library;
-
- return $this->$protocol('rotate');
- }
-
- if ($this->rotation_angle == 'hor' OR $this->rotation_angle == 'vrt')
- {
- return $this->image_mirror_gd();
- }
- else
- {
- return $this->image_rotate_gd();
- }
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Image Process Using GD/GD2
- *
- * This function will resize or crop
- *
- * @access public
- * @param string
- * @return bool
- */
- function image_process_gd($action = 'resize')
- {
- $v2_override = FALSE;
-
- // If the target width/height match the source, AND if the new file name is not equal to the old file name
- // we'll simply make a copy of the original with the new name... assuming dynamic rendering is off.
- if ($this->dynamic_output === FALSE)
- {
- if ($this->orig_width == $this->width AND $this->orig_height == $this->height)
- {
- if ($this->source_image != $this->new_image)
- {
- if (@copy($this->full_src_path, $this->full_dst_path))
- {
- @chmod($this->full_dst_path, DIR_WRITE_MODE);
- }
- }
-
- return TRUE;
- }
- }
-
- // Let's set up our values based on the action
- if ($action == 'crop')
- {
- // Reassign the source width/height if cropping
- $this->orig_width = $this->width;
- $this->orig_height = $this->height;
-
- // GD 2.0 has a cropping bug so we'll test for it
- if ($this->gd_version() !== FALSE)
- {
- $gd_version = str_replace('0', '', $this->gd_version());
- $v2_override = ($gd_version == 2) ? TRUE : FALSE;
- }
- }
- else
- {
- // If resizing the x/y axis must be zero
- $this->x_axis = 0;
- $this->y_axis = 0;
- }
-
- // Create the image handle
- if ( ! ($src_img = $this->image_create_gd()))
- {
- return FALSE;
- }
-
- // Create The Image
- //
- // old conditional which users report cause problems with shared GD libs who report themselves as "2.0 or greater"
- // it appears that this is no longer the issue that it was in 2004, so we've removed it, retaining it in the comment
- // below should that ever prove inaccurate.
- //
- // if ($this->image_library == 'gd2' AND function_exists('imagecreatetruecolor') AND $v2_override == FALSE)
- if ($this->image_library == 'gd2' AND function_exists('imagecreatetruecolor'))
- {
- $create = 'imagecreatetruecolor';
- $copy = 'imagecopyresampled';
- }
- else
- {
- $create = 'imagecreate';
- $copy = 'imagecopyresized';
- }
-
- $dst_img = $create($this->width, $this->height);
- $copy($dst_img, $src_img, 0, 0, $this->x_axis, $this->y_axis, $this->width, $this->height, $this->orig_width, $this->orig_height);
-
- // Show the image
- if ($this->dynamic_output == TRUE)
- {
- $this->image_display_gd($dst_img);
- }
- else
- {
- // Or save it
- if ( ! $this->image_save_gd($dst_img))
- {
- return FALSE;
- }
- }
-
- // Kill the file handles
- imagedestroy($dst_img);
- imagedestroy($src_img);
-
- // Set the file to 777
- @chmod($this->full_dst_path, DIR_WRITE_MODE);
-
- return TRUE;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Image Process Using ImageMagick
- *
- * This function will resize, crop or rotate
- *
- * @access public
- * @param string
- * @return bool
- */
- function image_process_imagemagick($action = 'resize')
- {
- // Do we have a vaild library path?
- if ($this->library_path == '')
- {
- $this->set_error('imglib_libpath_invalid');
- return FALSE;
- }
-
- if ( ! eregi("convert$", $this->library_path))
- {
- if ( ! eregi("/$", $this->library_path)) $this->library_path .= "/";
-
- $this->library_path .= 'convert';
- }
-
- // Execute the command
- $cmd = $this->library_path." -quality ".$this->quality;
-
- if ($action == 'crop')
- {
- $cmd .= " -crop ".$this->width."x".$this->height."+".$this->x_axis."+".$this->y_axis." \"$this->full_src_path\" \"$this->full_dst_path\" 2>&1";
- }
- elseif ($action == 'rotate')
- {
- switch ($this->rotation_angle)
- {
- case 'hor' : $angle = '-flop';
- break;
- case 'vrt' : $angle = '-flip';
- break;
- default : $angle = '-rotate '.$this->rotation_angle;
- break;
- }
-
- $cmd .= " ".$angle." \"$this->full_src_path\" \"$this->full_dst_path\" 2>&1";
- }
- else // Resize
- {
- $cmd .= " -resize ".$this->width."x".$this->height." \"$this->full_src_path\" \"$this->full_dst_path\" 2>&1";
- }
-
- $retval = 1;
-
- @exec($cmd, $output, $retval);
-
- // Did it work?
- if ($retval > 0)
- {
- $this->set_error('imglib_image_process_failed');
- return FALSE;
- }
-
- // Set the file to 777
- @chmod($this->full_dst_path, DIR_WRITE_MODE);
-
- return TRUE;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Image Process Using NetPBM
- *
- * This function will resize, crop or rotate
- *
- * @access public
- * @param string
- * @return bool
- */
- function image_process_netpbm($action = 'resize')
- {
- if ($this->library_path == '')
- {
- $this->set_error('imglib_libpath_invalid');
- return FALSE;
- }
-
- // Build the resizing command
- switch ($this->image_type)
- {
- case 1 :
- $cmd_in = 'giftopnm';
- $cmd_out = 'ppmtogif';
- break;
- case 2 :
- $cmd_in = 'jpegtopnm';
- $cmd_out = 'ppmtojpeg';
- break;
- case 3 :
- $cmd_in = 'pngtopnm';
- $cmd_out = 'ppmtopng';
- break;
- }
-
- if ($action == 'crop')
- {
- $cmd_inner = 'pnmcut -left '.$this->x_axis.' -top '.$this->y_axis.' -width '.$this->width.' -height '.$this->height;
- }
- elseif ($action == 'rotate')
- {
- switch ($this->rotation_angle)
- {
- case 90 : $angle = 'r270';
- break;
- case 180 : $angle = 'r180';
- break;
- case 270 : $angle = 'r90';
- break;
- case 'vrt' : $angle = 'tb';
- break;
- case 'hor' : $angle = 'lr';
- break;
- }
-
- $cmd_inner = 'pnmflip -'.$angle.' ';
- }
- else // Resize
- {
- $cmd_inner = 'pnmscale -xysize '.$this->width.' '.$this->height;
- }
-
- $cmd = $this->library_path.$cmd_in.' '.$this->full_src_path.' | '.$cmd_inner.' | '.$cmd_out.' > '.$this->dest_folder.'netpbm.tmp';
-
- $retval = 1;
-
- @exec($cmd, $output, $retval);
-
- // Did it work?
- if ($retval > 0)
- {
- $this->set_error('imglib_image_process_failed');
- return FALSE;
- }
-
- // With NetPBM we have to create a temporary image.
- // If you try manipulating the original it fails so
- // we have to rename the temp file.
- copy ($this->dest_folder.'netpbm.tmp', $this->full_dst_path);
- unlink ($this->dest_folder.'netpbm.tmp');
- @chmod($this->full_dst_path, DIR_WRITE_MODE);
-
- return TRUE;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Image Rotate Using GD
- *
- * @access public
- * @return bool
- */
- function image_rotate_gd()
- {
- // Is Image Rotation Supported?
- // this function is only supported as of PHP 4.3
- if ( ! function_exists('imagerotate'))
- {
- $this->set_error('imglib_rotate_unsupported');
- return FALSE;
- }
-
- // Create the image handle
- if ( ! ($src_img = $this->image_create_gd()))
- {
- return FALSE;
- }
-
- // Set the background color
- // This won't work with transparent PNG files so we are
- // going to have to figure out how to determine the color
- // of the alpha channel in a future release.
-
- $white = imagecolorallocate($src_img, 255, 255, 255);
-
- // Rotate it!
- $dst_img = imagerotate($src_img, $this->rotation_angle, $white);
-
- // Save the Image
- if ($this->dynamic_output == TRUE)
- {
- $this->image_display_gd($dst_img);
- }
- else
- {
- // Or save it
- if ( ! $this->image_save_gd($dst_img))
- {
- return FALSE;
- }
- }
-
- // Kill the file handles
- imagedestroy($dst_img);
- imagedestroy($src_img);
-
- // Set the file to 777
-
- @chmod($this->full_dst_path, DIR_WRITE_MODE);
-
- return true;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Create Mirror Image using GD
- *
- * This function will flip horizontal or vertical
- *
- * @access public
- * @return bool
- */
- function image_mirror_gd()
- {
- if ( ! $src_img = $this->image_create_gd())
- {
- return FALSE;
- }
-
- $width = $this->orig_width;
- $height = $this->orig_height;
-
- if ($this->rotation_angle == 'hor')
- {
- for ($i = 0; $i < $height; $i++)
- {
- $left = 0;
- $right = $width-1;
-
- while ($left < $right)
- {
- $cl = imagecolorat($src_img, $left, $i);
- $cr = imagecolorat($src_img, $right, $i);
-
- imagesetpixel($src_img, $left, $i, $cr);
- imagesetpixel($src_img, $right, $i, $cl);
-
- $left++;
- $right--;
- }
- }
- }
- else
- {
- for ($i = 0; $i < $width; $i++)
- {
- $top = 0;
- $bot = $height-1;
-
- while ($top < $bot)
- {
- $ct = imagecolorat($src_img, $i, $top);
- $cb = imagecolorat($src_img, $i, $bot);
-
- imagesetpixel($src_img, $i, $top, $cb);
- imagesetpixel($src_img, $i, $bot, $ct);
-
- $top++;
- $bot--;
- }
- }
- }
-
- // Show the image
- if ($this->dynamic_output == TRUE)
- {
- $this->image_display_gd($src_img);
- }
- else
- {
- // Or save it
- if ( ! $this->image_save_gd($src_img))
- {
- return FALSE;
- }
- }
-
- // Kill the file handles
- imagedestroy($src_img);
-
- // Set the file to 777
- @chmod($this->full_dst_path, DIR_WRITE_MODE);
-
- return TRUE;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Image Watermark
- *
- * This is a wrapper function that chooses the type
- * of watermarking based on the specified preference.
- *
- * @access public
- * @param string
- * @return bool
- */
- function watermark()
- {
- if ($this->wm_type == 'overlay')
- {
- return $this->overlay_watermark();
- }
- else
- {
- return $this->text_watermark();
- }
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Watermark - Graphic Version
- *
- * @access public
- * @return bool
- */
- function overlay_watermark()
- {
- if ( ! function_exists('imagecolortransparent'))
- {
- $this->set_error('imglib_gd_required');
- return FALSE;
- }
-
- // Fetch source image properties
- $this->get_image_properties();
-
- // Fetch watermark image properties
- $props = $this->get_image_properties($this->wm_overlay_path, TRUE);
- $wm_img_type = $props['image_type'];
- $wm_width = $props['width'];
- $wm_height = $props['height'];
-
- // Create two image resources
- $wm_img = $this->image_create_gd($this->wm_overlay_path, $wm_img_type);
- $src_img = $this->image_create_gd($this->full_src_path);
-
- // Reverse the offset if necessary
- // When the image is positioned at the bottom
- // we don't want the vertical offset to push it
- // further down. We want the reverse, so we'll
- // invert the offset. Same with the horizontal
- // offset when the image is at the right
-
- $this->wm_vrt_alignment = strtoupper(substr($this->wm_vrt_alignment, 0, 1));
- $this->wm_hor_alignment = strtoupper(substr($this->wm_hor_alignment, 0, 1));
-
- if ($this->wm_vrt_alignment == 'B')
- $this->wm_vrt_offset = $this->wm_vrt_offset * -1;
-
- if ($this->wm_hor_alignment == 'R')
- $this->wm_hor_offset = $this->wm_hor_offset * -1;
-
- // Set the base x and y axis values
- $x_axis = $this->wm_hor_offset + $this->wm_padding;
- $y_axis = $this->wm_vrt_offset + $this->wm_padding;
-
- // Set the vertical position
- switch ($this->wm_vrt_alignment)
- {
- case 'T':
- break;
- case 'M': $y_axis += ($this->orig_height / 2) - ($wm_height / 2);
- break;
- case 'B': $y_axis += $this->orig_height - $wm_height;
- break;
- }
-
- // Set the horizontal position
- switch ($this->wm_hor_alignment)
- {
- case 'L':
- break;
- case 'C': $x_axis += ($this->orig_width / 2) - ($wm_width / 2);
- break;
- case 'R': $x_axis += $this->orig_width - $wm_width;
- break;
- }
-
- // Build the finalized image
- if ($wm_img_type == 3 AND function_exists('imagealphablending'))
- {
- @imagealphablending($src_img, TRUE);
- }
-
- // Set RGB values for text and shadow
- $rgba = imagecolorat($wm_img, $this->wm_x_transp, $this->wm_y_transp);
- $alpha = ($rgba & 0x7F000000) >> 24;
-
- // make a best guess as to whether we're dealing with an image with alpha transparency or no/binary transparency
- if ($alpha > 0)
- {
- // copy the image directly, the image's alpha transparency being the sole determinant of blending
- imagecopy($src_img, $wm_img, $x_axis, $y_axis, 0, 0, $wm_width, $wm_height);
- }
- else
- {
- // set our RGB value from above to be transparent and merge the images with the specified opacity
- imagecolortransparent($wm_img, imagecolorat($wm_img, $this->wm_x_transp, $this->wm_y_transp));
- imagecopymerge($src_img, $wm_img, $x_axis, $y_axis, 0, 0, $wm_width, $wm_height, $this->wm_opacity);
- }
-
- // Output the image
- if ($this->dynamic_output == TRUE)
- {
- $this->image_display_gd($src_img);
- }
- else
- {
- if ( ! $this->image_save_gd($src_img))
- {
- return FALSE;
- }
- }
-
- imagedestroy($src_img);
- imagedestroy($wm_img);
-
- return TRUE;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Watermark - Text Version
- *
- * @access public
- * @return bool
- */
- function text_watermark()
- {
- if ( ! ($src_img = $this->image_create_gd()))
- {
- return FALSE;
- }
-
- if ($this->wm_use_truetype == TRUE AND ! file_exists($this->wm_font_path))
- {
- $this->set_error('imglib_missing_font');
- return FALSE;
- }
-
- // Fetch source image properties
- $this->get_image_properties();
-
- // Set RGB values for text and shadow
- $this->wm_font_color = str_replace('#', '', $this->wm_font_color);
- $this->wm_shadow_color = str_replace('#', '', $this->wm_shadow_color);
-
- $R1 = hexdec(substr($this->wm_font_color, 0, 2));
- $G1 = hexdec(substr($this->wm_font_color, 2, 2));
- $B1 = hexdec(substr($this->wm_font_color, 4, 2));
-
- $R2 = hexdec(substr($this->wm_shadow_color, 0, 2));
- $G2 = hexdec(substr($this->wm_shadow_color, 2, 2));
- $B2 = hexdec(substr($this->wm_shadow_color, 4, 2));
-
- $txt_color = imagecolorclosest($src_img, $R1, $G1, $B1);
- $drp_color = imagecolorclosest($src_img, $R2, $G2, $B2);
-
- // Reverse the vertical offset
- // When the image is positioned at the bottom
- // we don't want the vertical offset to push it
- // further down. We want the reverse, so we'll
- // invert the offset. Note: The horizontal
- // offset flips itself automatically
-
- if ($this->wm_vrt_alignment == 'B')
- $this->wm_vrt_offset = $this->wm_vrt_offset * -1;
-
- if ($this->wm_hor_alignment == 'R')
- $this->wm_hor_offset = $this->wm_hor_offset * -1;
-
- // Set font width and height
- // These are calculated differently depending on
- // whether we are using the true type font or not
- if ($this->wm_use_truetype == TRUE)
- {
- if ($this->wm_font_size == '')
- $this->wm_font_size = '17';
-
- $fontwidth = $this->wm_font_size-($this->wm_font_size/4);
- $fontheight = $this->wm_font_size;
- $this->wm_vrt_offset += $this->wm_font_size;
- }
- else
- {
- $fontwidth = imagefontwidth($this->wm_font_size);
- $fontheight = imagefontheight($this->wm_font_size);
- }
-
- // Set base X and Y axis values
- $x_axis = $this->wm_hor_offset + $this->wm_padding;
- $y_axis = $this->wm_vrt_offset + $this->wm_padding;
-
- // Set verticle alignment
- if ($this->wm_use_drop_shadow == FALSE)
- $this->wm_shadow_distance = 0;
-
- $this->wm_vrt_alignment = strtoupper(substr($this->wm_vrt_alignment, 0, 1));
- $this->wm_hor_alignment = strtoupper(substr($this->wm_hor_alignment, 0, 1));
-
- switch ($this->wm_vrt_alignment)
- {
- case "T" :
- break;
- case "M": $y_axis += ($this->orig_height/2)+($fontheight/2);
- break;
- case "B": $y_axis += ($this->orig_height - $fontheight - $this->wm_shadow_distance - ($fontheight/2));
- break;
- }
-
- $x_shad = $x_axis + $this->wm_shadow_distance;
- $y_shad = $y_axis + $this->wm_shadow_distance;
-
- // Set horizontal alignment
- switch ($this->wm_hor_alignment)
- {
- case "L":
- break;
- case "R":
- if ($this->wm_use_drop_shadow)
- $x_shad += ($this->orig_width - $fontwidth*strlen($this->wm_text));
- $x_axis += ($this->orig_width - $fontwidth*strlen($this->wm_text));
- break;
- case "C":
- if ($this->wm_use_drop_shadow)
- $x_shad += floor(($this->orig_width - $fontwidth*strlen($this->wm_text))/2);
- $x_axis += floor(($this->orig_width -$fontwidth*strlen($this->wm_text))/2);
- break;
- }
-
- // Add the text to the source image
- if ($this->wm_use_truetype)
- {
- if ($this->wm_use_drop_shadow)
- imagettftext($src_img, $this->wm_font_size, 0, $x_shad, $y_shad, $drp_color, $this->wm_font_path, $this->wm_text);
- imagettftext($src_img, $this->wm_font_size, 0, $x_axis, $y_axis, $txt_color, $this->wm_font_path, $this->wm_text);
- }
- else
- {
- if ($this->wm_use_drop_shadow)
- imagestring($src_img, $this->wm_font_size, $x_shad, $y_shad, $this->wm_text, $drp_color);
- imagestring($src_img, $this->wm_font_size, $x_axis, $y_axis, $this->wm_text, $txt_color);
- }
-
- // Output the final image
- if ($this->dynamic_output == TRUE)
- {
- $this->image_display_gd($src_img);
- }
- else
- {
- $this->image_save_gd($src_img);
- }
-
- imagedestroy($src_img);
-
- return TRUE;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Create Image - GD
- *
- * This simply creates an image resource handle
- * based on the type of image being processed
- *
- * @access public
- * @param string
- * @return resource
- */
- function image_create_gd($path = '', $image_type = '')
- {
- if ($path == '')
- $path = $this->full_src_path;
-
- if ($image_type == '')
- $image_type = $this->image_type;
-
-
- switch ($image_type)
- {
- case 1 :
- if ( ! function_exists('imagecreatefromgif'))
- {
- $this->set_error(array('imglib_unsupported_imagecreate', 'imglib_gif_not_supported'));
- return FALSE;
- }
-
- return imagecreatefromgif($path);
- break;
- case 2 :
- if ( ! function_exists('imagecreatefromjpeg'))
- {
- $this->set_error(array('imglib_unsupported_imagecreate', 'imglib_jpg_not_supported'));
- return FALSE;
- }
-
- return imagecreatefromjpeg($path);
- break;
- case 3 :
- if ( ! function_exists('imagecreatefrompng'))
- {
- $this->set_error(array('imglib_unsupported_imagecreate', 'imglib_png_not_supported'));
- return FALSE;
- }
-
- return imagecreatefrompng($path);
- break;
-
- }
-
- $this->set_error(array('imglib_unsupported_imagecreate'));
- return FALSE;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Write image file to disk - GD
- *
- * Takes an image resource as input and writes the file
- * to the specified destination
- *
- * @access public
- * @param resource
- * @return bool
- */
- function image_save_gd($resource)
- {
- switch ($this->image_type)
- {
- case 1 :
- if ( ! function_exists('imagegif'))
- {
- $this->set_error(array('imglib_unsupported_imagecreate', 'imglib_gif_not_supported'));
- return FALSE;
- }
-
- @imagegif($resource, $this->full_dst_path);
- break;
- case 2 :
- if ( ! function_exists('imagejpeg'))
- {
- $this->set_error(array('imglib_unsupported_imagecreate', 'imglib_jpg_not_supported'));
- return FALSE;
- }
-
- if (phpversion() == '4.4.1')
- {
- @touch($this->full_dst_path); // PHP 4.4.1 bug #35060 - workaround
- }
-
- @imagejpeg($resource, $this->full_dst_path, $this->quality);
- break;
- case 3 :
- if ( ! function_exists('imagepng'))
- {
- $this->set_error(array('imglib_unsupported_imagecreate', 'imglib_png_not_supported'));
- return FALSE;
- }
-
- @imagepng($resource, $this->full_dst_path);
- break;
- default :
- $this->set_error(array('imglib_unsupported_imagecreate'));
- return FALSE;
- break;
- }
-
- return TRUE;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Dynamically outputs an image
- *
- * @access public
- * @param resource
- * @return void
- */
- function image_display_gd($resource)
- {
- header("Content-Disposition: filename={$this->source_image};");
- header("Content-Type: {$this->mime_type}");
- header('Content-Transfer-Encoding: binary');
- header('Last-Modified: '.gmdate('D, d M Y H:i:s', time()).' GMT');
-
- switch ($this->image_type)
- {
- case 1 : imagegif($resource);
- break;
- case 2 : imagejpeg($resource, '', $this->quality);
- break;
- case 3 : imagepng($resource);
- break;
- default : echo 'Unable to display the image';
- break;
- }
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Re-proportion Image Width/Height
- *
- * When creating thumbs, the desired width/height
- * can end up warping the image due to an incorrect
- * ratio between the full-sized image and the thumb.
- *
- * This function lets us re-proportion the width/height
- * if users choose to maintain the aspect ratio when resizing.
- *
- * @access public
- * @return void
- */
- function image_reproportion()
- {
- if ( ! is_numeric($this->width) OR ! is_numeric($this->height) OR $this->width == 0 OR $this->height == 0)
- return;
-
- if ( ! is_numeric($this->orig_width) OR ! is_numeric($this->orig_height) OR $this->orig_width == 0 OR $this->orig_height == 0)
- return;
-
- $new_width = ceil($this->orig_width*$this->height/$this->orig_height);
- $new_height = ceil($this->width*$this->orig_height/$this->orig_width);
-
- $ratio = (($this->orig_height/$this->orig_width) - ($this->height/$this->width));
-
- if ($this->master_dim != 'width' AND $this->master_dim != 'height')
- {
- $this->master_dim = ($ratio < 0) ? 'width' : 'height';
- }
-
- if (($this->width != $new_width) AND ($this->height != $new_height))
- {
- if ($this->master_dim == 'height')
- {
- $this->width = $new_width;
- }
- else
- {
- $this->height = $new_height;
- }
- }
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Get image properties
- *
- * A helper function that gets info about the file
- *
- * @access public
- * @param string
- * @return mixed
- */
- function get_image_properties($path = '', $return = FALSE)
- {
- // For now we require GD but we should
- // find a way to determine this using IM or NetPBM
-
- if ($path == '')
- $path = $this->full_src_path;
-
- if ( ! file_exists($path))
- {
- $this->set_error('imglib_invalid_path');
- return FALSE;
- }
-
- $vals = @getimagesize($path);
-
- $types = array(1 => 'gif', 2 => 'jpeg', 3 => 'png');
-
- $mime = (isset($types[$vals['2']])) ? 'image/'.$types[$vals['2']] : 'image/jpg';
-
- if ($return == TRUE)
- {
- $v['width'] = $vals['0'];
- $v['height'] = $vals['1'];
- $v['image_type'] = $vals['2'];
- $v['size_str'] = $vals['3'];
- $v['mime_type'] = $mime;
-
- return $v;
- }
-
- $this->orig_width = $vals['0'];
- $this->orig_height = $vals['1'];
- $this->image_type = $vals['2'];
- $this->size_str = $vals['3'];
- $this->mime_type = $mime;
-
- return TRUE;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Size calculator
- *
- * This function takes a known width x height and
- * recalculates it to a new size. Only one
- * new variable needs to be known
- *
- * $props = array(
- * 'width' => $width,
- * 'height' => $height,
- * 'new_width' => 40,
- * 'new_height' => ''
- * );
- *
- * @access public
- * @param array
- * @return array
- */
- function size_calculator($vals)
- {
- if ( ! is_array($vals))
- {
- return;
- }
-
- $allowed = array('new_width', 'new_height', 'width', 'height');
-
- foreach ($allowed as $item)
- {
- if ( ! isset($vals[$item]) OR $vals[$item] == '')
- $vals[$item] = 0;
- }
-
- if ($vals['width'] == 0 OR $vals['height'] == 0)
- {
- return $vals;
- }
-
- if ($vals['new_width'] == 0)
- {
- $vals['new_width'] = ceil($vals['width']*$vals['new_height']/$vals['height']);
- }
- elseif ($vals['new_height'] == 0)
- {
- $vals['new_height'] = ceil($vals['new_width']*$vals['height']/$vals['width']);
- }
-
- return $vals;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Explode source_image
- *
- * This is a helper function that extracts the extension
- * from the source_image. This function lets us deal with
- * source_images with multiple periods, like: my.cool.jpg
- * It returns an associative array with two elements:
- * $array['ext'] = '.jpg';
- * $array['name'] = 'my.cool';
- *
- * @access public
- * @param array
- * @return array
- */
- function explode_name($source_image)
- {
- $x = explode('.', $source_image);
- $ret['ext'] = '.'.end($x);
-
- $name = '';
-
- $ct = count($x)-1;
-
- for ($i = 0; $i < $ct; $i++)
- {
- $name .= $x[$i];
-
- if ($i < ($ct - 1))
- {
- $name .= '.';
- }
- }
-
- $ret['name'] = $name;
-
- return $ret;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Is GD Installed?
- *
- * @access public
- * @return bool
- */
- function gd_loaded()
- {
- if ( ! extension_loaded('gd'))
- {
- if ( ! dl('gd.so'))
- {
- return FALSE;
- }
- }
-
- return TRUE;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Get GD version
- *
- * @access public
- * @return mixed
- */
- function gd_version()
- {
- if (function_exists('gd_info'))
- {
- $gd_version = @gd_info();
- $gd_version = preg_replace("/\D/", "", $gd_version['GD Version']);
-
- return $gd_version;
- }
-
- return FALSE;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Set error message
- *
- * @access public
- * @param string
- * @return void
- */
- function set_error($msg)
- {
- $CI =& get_instance();
- $CI->lang->load('imglib');
-
- if (is_array($msg))
- {
- foreach ($msg as $val)
- {
-
- $msg = ($CI->lang->line($val) == FALSE) ? $val : $CI->lang->line($val);
- $this->error_msg[] = $msg;
- log_message('error', $msg);
- }
- }
- else
- {
- $msg = ($CI->lang->line($msg) == FALSE) ? $msg : $CI->lang->line($msg);
- $this->error_msg[] = $msg;
- log_message('error', $msg);
- }
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Show error messages
- *
- * @access public
- * @param string
- * @return string
- */
- function display_errors($open = '<p>', $close = '</p>')
- {
- $str = '';
- foreach ($this->error_msg as $val)
- {
- $str .= $open.$val.$close;
- }
-
- return $str;
- }
-
-}
-// END Image_lib Class
-
-/* End of file Image_lib.php */
+<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+/**
+ * CodeIgniter
+ *
+ * An open source application development framework for PHP 4.3.2 or newer
+ *
+ * @package CodeIgniter
+ * @author ExpressionEngine Dev Team
+ * @copyright Copyright (c) 2008, EllisLab, Inc.
+ * @license http://codeigniter.com/user_guide/license.html
+ * @link http://codeigniter.com
+ * @since Version 1.0
+ * @filesource
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+ * Image Manipulation class
+ *
+ * @package CodeIgniter
+ * @subpackage Libraries
+ * @category Image_lib
+ * @author ExpressionEngine Dev Team
+ * @link http://codeigniter.com/user_guide/libraries/image_lib.html
+ */
+class CI_Image_lib {
+
+ var $image_library = 'gd2'; // Can be: imagemagick, netpbm, gd, gd2
+ var $library_path = '';
+ var $dynamic_output = FALSE; // Whether to send to browser or write to disk
+ var $source_image = '';
+ var $new_image = '';
+ var $width = '';
+ var $height = '';
+ var $quality = '90';
+ var $create_thumb = FALSE;
+ var $thumb_marker = '_thumb';
+ var $maintain_ratio = TRUE; // Whether to maintain aspect ratio when resizing or use hard values
+ var $master_dim = 'auto'; // auto, height, or width. Determines what to use as the master dimension
+ var $rotation_angle = '';
+ var $x_axis = '';
+ var $y_axis = '';
+
+ // Watermark Vars
+ var $wm_text = ''; // Watermark text if graphic is not used
+ var $wm_type = 'text'; // Type of watermarking. Options: text/overlay
+ var $wm_x_transp = 4;
+ var $wm_y_transp = 4;
+ var $wm_overlay_path = ''; // Watermark image path
+ var $wm_font_path = ''; // TT font
+ var $wm_font_size = 17; // Font size (different versions of GD will either use points or pixels)
+ var $wm_vrt_alignment = 'B'; // Vertical alignment: T M B
+ var $wm_hor_alignment = 'C'; // Horizontal alignment: L R C
+ var $wm_padding = 0; // Padding around text
+ var $wm_hor_offset = 0; // Lets you push text to the right
+ var $wm_vrt_offset = 0; // Lets you push text down
+ var $wm_font_color = '#ffffff'; // Text color
+ var $wm_shadow_color = ''; // Dropshadow color
+ var $wm_shadow_distance = 2; // Dropshadow distance
+ var $wm_opacity = 50; // Image opacity: 1 - 100 Only works with image
+
+ // Private Vars
+ var $source_folder = '';
+ var $dest_folder = '';
+ var $mime_type = '';
+ var $orig_width = '';
+ var $orig_height = '';
+ var $image_type = '';
+ var $size_str = '';
+ var $full_src_path = '';
+ var $full_dst_path = '';
+ var $create_fnc = 'imagecreatetruecolor';
+ var $copy_fnc = 'imagecopyresampled';
+ var $error_msg = array();
+ var $wm_use_drop_shadow = FALSE;
+ var $wm_use_truetype = FALSE;
+
+ /**
+ * Constructor
+ *
+ * @access public
+ * @param string
+ * @return void
+ */
+ function CI_Image_lib($props = array())
+ {
+ if (count($props) > 0)
+ {
+ $this->initialize($props);
+ }
+
+ log_message('debug', "Image Lib Class Initialized");
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Initialize image properties
+ *
+ * Resets values in case this class is used in a loop
+ *
+ * @access public
+ * @return void
+ */
+ function clear()
+ {
+ $props = array('source_folder', 'dest_folder', 'source_image', 'full_src_path', 'full_dst_path', 'new_image', 'image_type', 'size_str', 'quality', 'orig_width', 'orig_height', 'rotation_angle', 'x_axis', 'y_axis', 'create_fnc', 'copy_fnc', 'wm_overlay_path', 'wm_use_truetype', 'dynamic_output', 'wm_font_size', 'wm_text', 'wm_vrt_alignment', 'wm_hor_alignment', 'wm_padding', 'wm_hor_offset', 'wm_vrt_offset', 'wm_font_color', 'wm_use_drop_shadow', 'wm_shadow_color', 'wm_shadow_distance', 'wm_opacity');
+
+ foreach ($props as $val)
+ {
+ $this->$val = '';
+ }
+
+ // special consideration for master_dim
+ $this->master_dim = 'auto';
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * initialize image preferences
+ *
+ * @access public
+ * @param array
+ * @return bool
+ */
+ function initialize($props = array())
+ {
+ /*
+ * Convert array elements into class variables
+ */
+ if (count($props) > 0)
+ {
+ foreach ($props as $key => $val)
+ {
+ $this->$key = $val;
+ }
+ }
+
+ /*
+ * Is there a source image?
+ *
+ * If not, there's no reason to continue
+ *
+ */
+ if ($this->source_image == '')
+ {
+ $this->set_error('imglib_source_image_required');
+ return FALSE;
+ }
+
+ /*
+ * Is getimagesize() Available?
+ *
+ * We use it to determine the image properties (width/height).
+ * Note: We need to figure out how to determine image
+ * properties using ImageMagick and NetPBM
+ *
+ */
+ if ( ! function_exists('getimagesize'))
+ {
+ $this->set_error('imglib_gd_required_for_props');
+ return FALSE;
+ }
+
+ $this->image_library = strtolower($this->image_library);
+
+ /*
+ * Set the full server path
+ *
+ * The source image may or may not contain a path.
+ * Either way, we'll try use realpath to generate the
+ * full server path in order to more reliably read it.
+ *
+ */
+ if (function_exists('realpath') AND @realpath($this->source_image) !== FALSE)
+ {
+ $full_source_path = str_replace("\\", "/", realpath($this->source_image));
+ }
+ else
+ {
+ $full_source_path = $this->source_image;
+ }
+
+ $x = explode('/', $full_source_path);
+ $this->source_image = end($x);
+ $this->source_folder = str_replace($this->source_image, '', $full_source_path);
+
+ // Set the Image Properties
+ if ( ! $this->get_image_properties($this->source_folder.$this->source_image))
+ {
+ return FALSE;
+ }
+
+ /*
+ * Assign the "new" image name/path
+ *
+ * If the user has set a "new_image" name it means
+ * we are making a copy of the source image. If not
+ * it means we are altering the original. We'll
+ * set the destination filename and path accordingly.
+ *
+ */
+ if ($this->new_image == '')
+ {
+ $this->dest_image = $this->source_image;
+ $this->dest_folder = $this->source_folder;
+ }
+ else
+ {
+ if (strpos($this->new_image, '/') === FALSE)
+ {
+ $this->dest_folder = $this->source_folder;
+ $this->dest_image = $this->new_image;
+ }
+ else
+ {
+ if (function_exists('realpath') AND @realpath($this->new_image) !== FALSE)
+ {
+ $full_dest_path = str_replace("\\", "/", realpath($this->new_image));
+ }
+ else
+ {
+ $full_dest_path = $this->new_image;
+ }
+
+ // Is there a file name?
+ if ( ! preg_match("#\.(jpg|jpeg|gif|png)$#i", $full_dest_path))
+ {
+ $this->dest_folder = $full_dest_path.'/';
+ $this->dest_image = $this->source_image;
+ }
+ else
+ {
+ $x = explode('/', $full_dest_path);
+ $this->dest_image = end($x);
+ $this->dest_folder = str_replace($this->dest_image, '', $full_dest_path);
+ }
+ }
+ }
+
+ /*
+ * Compile the finalized filenames/paths
+ *
+ * We'll create two master strings containing the
+ * full server path to the source image and the
+ * full server path to the destination image.
+ * We'll also split the destination image name
+ * so we can insert the thumbnail marker if needed.
+ *
+ */
+ if ($this->create_thumb === FALSE OR $this->thumb_marker == '')
+ {
+ $this->thumb_marker = '';
+ }
+
+ $xp = $this->explode_name($this->dest_image);
+
+ $filename = $xp['name'];
+ $file_ext = $xp['ext'];
+
+ $this->full_src_path = $this->source_folder.$this->source_image;
+ $this->full_dst_path = $this->dest_folder.$filename.$this->thumb_marker.$file_ext;
+
+ /*
+ * Should we maintain image proportions?
+ *
+ * When creating thumbs or copies, the target width/height
+ * might not be in correct proportion with the source
+ * image's width/height. We'll recalculate it here.
+ *
+ */
+ if ($this->maintain_ratio === TRUE && ($this->width != '' AND $this->height != ''))
+ {
+ $this->image_reproportion();
+ }
+
+ /*
+ * Was a width and height specified?
+ *
+ * If the destination width/height was
+ * not submitted we will use the values
+ * from the actual file
+ *
+ */
+ if ($this->width == '')
+ $this->width = $this->orig_width;
+
+ if ($this->height == '')
+ $this->height = $this->orig_height;
+
+ // Set the quality
+ $this->quality = trim(str_replace("%", "", $this->quality));
+
+ if ($this->quality == '' OR $this->quality == 0 OR ! is_numeric($this->quality))
+ $this->quality = 90;
+
+ // Set the x/y coordinates
+ $this->x_axis = ($this->x_axis == '' OR ! is_numeric($this->x_axis)) ? 0 : $this->x_axis;
+ $this->y_axis = ($this->y_axis == '' OR ! is_numeric($this->y_axis)) ? 0 : $this->y_axis;
+
+ // Watermark-related Stuff...
+ if ($this->wm_font_color != '')
+ {
+ if (strlen($this->wm_font_color) == 6)
+ {
+ $this->wm_font_color = '#'.$this->wm_font_color;
+ }
+ }
+
+ if ($this->wm_shadow_color != '')
+ {
+ if (strlen($this->wm_shadow_color) == 6)
+ {
+ $this->wm_shadow_color = '#'.$this->wm_shadow_color;
+ }
+ }
+
+ if ($this->wm_overlay_path != '')
+ {
+ $this->wm_overlay_path = str_replace("\\", "/", realpath($this->wm_overlay_path));
+ }
+
+ if ($this->wm_shadow_color != '')
+ {
+ $this->wm_use_drop_shadow = TRUE;
+ }
+
+ if ($this->wm_font_path != '')
+ {
+ $this->wm_use_truetype = TRUE;
+ }
+
+ return TRUE;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Image Resize
+ *
+ * This is a wrapper function that chooses the proper
+ * resize function based on the protocol specified
+ *
+ * @access public
+ * @return bool
+ */
+ function resize()
+ {
+ $protocol = 'image_process_'.$this->image_library;
+
+ if (eregi("gd2$", $protocol))
+ {
+ $protocol = 'image_process_gd';
+ }
+
+ return $this->$protocol('resize');
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Image Crop
+ *
+ * This is a wrapper function that chooses the proper
+ * cropping function based on the protocol specified
+ *
+ * @access public
+ * @return bool
+ */
+ function crop()
+ {
+ $protocol = 'image_process_'.$this->image_library;
+
+ if (eregi("gd2$", $protocol))
+ {
+ $protocol = 'image_process_gd';
+ }
+
+ return $this->$protocol('crop');
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Image Rotate
+ *
+ * This is a wrapper function that chooses the proper
+ * rotation function based on the protocol specified
+ *
+ * @access public
+ * @return bool
+ */
+ function rotate()
+ {
+ // Allowed rotation values
+ $degs = array(90, 180, 270, 'vrt', 'hor');
+
+ if ($this->rotation_angle == '' OR ! in_array($this->rotation_angle, $degs, TRUE))
+ {
+ $this->set_error('imglib_rotation_angle_required');
+ return FALSE;
+ }
+
+ // Reassign the width and height
+ if ($this->rotation_angle == 90 OR $this->rotation_angle == 270)
+ {
+ $this->width = $this->orig_height;
+ $this->height = $this->orig_width;
+ }
+ else
+ {
+ $this->width = $this->orig_width;
+ $this->height = $this->orig_height;
+ }
+
+
+ // Choose resizing function
+ if ($this->image_library == 'imagemagick' OR $this->image_library == 'netpbm')
+ {
+ $protocol = 'image_process_'.$this->image_library;
+
+ return $this->$protocol('rotate');
+ }
+
+ if ($this->rotation_angle == 'hor' OR $this->rotation_angle == 'vrt')
+ {
+ return $this->image_mirror_gd();
+ }
+ else
+ {
+ return $this->image_rotate_gd();
+ }
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Image Process Using GD/GD2
+ *
+ * This function will resize or crop
+ *
+ * @access public
+ * @param string
+ * @return bool
+ */
+ function image_process_gd($action = 'resize')
+ {
+ $v2_override = FALSE;
+
+ // If the target width/height match the source, AND if the new file name is not equal to the old file name
+ // we'll simply make a copy of the original with the new name... assuming dynamic rendering is off.
+ if ($this->dynamic_output === FALSE)
+ {
+ if ($this->orig_width == $this->width AND $this->orig_height == $this->height)
+ {
+ if ($this->source_image != $this->new_image)
+ {
+ if (@copy($this->full_src_path, $this->full_dst_path))
+ {
+ @chmod($this->full_dst_path, DIR_WRITE_MODE);
+ }
+ }
+
+ return TRUE;
+ }
+ }
+
+ // Let's set up our values based on the action
+ if ($action == 'crop')
+ {
+ // Reassign the source width/height if cropping
+ $this->orig_width = $this->width;
+ $this->orig_height = $this->height;
+
+ // GD 2.0 has a cropping bug so we'll test for it
+ if ($this->gd_version() !== FALSE)
+ {
+ $gd_version = str_replace('0', '', $this->gd_version());
+ $v2_override = ($gd_version == 2) ? TRUE : FALSE;
+ }
+ }
+ else
+ {
+ // If resizing the x/y axis must be zero
+ $this->x_axis = 0;
+ $this->y_axis = 0;
+ }
+
+ // Create the image handle
+ if ( ! ($src_img = $this->image_create_gd()))
+ {
+ return FALSE;
+ }
+
+ // Create The Image
+ //
+ // old conditional which users report cause problems with shared GD libs who report themselves as "2.0 or greater"
+ // it appears that this is no longer the issue that it was in 2004, so we've removed it, retaining it in the comment
+ // below should that ever prove inaccurate.
+ //
+ // if ($this->image_library == 'gd2' AND function_exists('imagecreatetruecolor') AND $v2_override == FALSE)
+ if ($this->image_library == 'gd2' AND function_exists('imagecreatetruecolor'))
+ {
+ $create = 'imagecreatetruecolor';
+ $copy = 'imagecopyresampled';
+ }
+ else
+ {
+ $create = 'imagecreate';
+ $copy = 'imagecopyresized';
+ }
+
+ $dst_img = $create($this->width, $this->height);
+ $copy($dst_img, $src_img, 0, 0, $this->x_axis, $this->y_axis, $this->width, $this->height, $this->orig_width, $this->orig_height);
+
+ // Show the image
+ if ($this->dynamic_output == TRUE)
+ {
+ $this->image_display_gd($dst_img);
+ }
+ else
+ {
+ // Or save it
+ if ( ! $this->image_save_gd($dst_img))
+ {
+ return FALSE;
+ }
+ }
+
+ // Kill the file handles
+ imagedestroy($dst_img);
+ imagedestroy($src_img);
+
+ // Set the file to 777
+ @chmod($this->full_dst_path, DIR_WRITE_MODE);
+
+ return TRUE;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Image Process Using ImageMagick
+ *
+ * This function will resize, crop or rotate
+ *
+ * @access public
+ * @param string
+ * @return bool
+ */
+ function image_process_imagemagick($action = 'resize')
+ {
+ // Do we have a vaild library path?
+ if ($this->library_path == '')
+ {
+ $this->set_error('imglib_libpath_invalid');
+ return FALSE;
+ }
+
+ if ( ! eregi("convert$", $this->library_path))
+ {
+ if ( ! eregi("/$", $this->library_path)) $this->library_path .= "/";
+
+ $this->library_path .= 'convert';
+ }
+
+ // Execute the command
+ $cmd = $this->library_path." -quality ".$this->quality;
+
+ if ($action == 'crop')
+ {
+ $cmd .= " -crop ".$this->width."x".$this->height."+".$this->x_axis."+".$this->y_axis." \"$this->full_src_path\" \"$this->full_dst_path\" 2>&1";
+ }
+ elseif ($action == 'rotate')
+ {
+ switch ($this->rotation_angle)
+ {
+ case 'hor' : $angle = '-flop';
+ break;
+ case 'vrt' : $angle = '-flip';
+ break;
+ default : $angle = '-rotate '.$this->rotation_angle;
+ break;
+ }
+
+ $cmd .= " ".$angle." \"$this->full_src_path\" \"$this->full_dst_path\" 2>&1";
+ }
+ else // Resize
+ {
+ $cmd .= " -resize ".$this->width."x".$this->height." \"$this->full_src_path\" \"$this->full_dst_path\" 2>&1";
+ }
+
+ $retval = 1;
+
+ @exec($cmd, $output, $retval);
+
+ // Did it work?
+ if ($retval > 0)
+ {
+ $this->set_error('imglib_image_process_failed');
+ return FALSE;
+ }
+
+ // Set the file to 777
+ @chmod($this->full_dst_path, DIR_WRITE_MODE);
+
+ return TRUE;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Image Process Using NetPBM
+ *
+ * This function will resize, crop or rotate
+ *
+ * @access public
+ * @param string
+ * @return bool
+ */
+ function image_process_netpbm($action = 'resize')
+ {
+ if ($this->library_path == '')
+ {
+ $this->set_error('imglib_libpath_invalid');
+ return FALSE;
+ }
+
+ // Build the resizing command
+ switch ($this->image_type)
+ {
+ case 1 :
+ $cmd_in = 'giftopnm';
+ $cmd_out = 'ppmtogif';
+ break;
+ case 2 :
+ $cmd_in = 'jpegtopnm';
+ $cmd_out = 'ppmtojpeg';
+ break;
+ case 3 :
+ $cmd_in = 'pngtopnm';
+ $cmd_out = 'ppmtopng';
+ break;
+ }
+
+ if ($action == 'crop')
+ {
+ $cmd_inner = 'pnmcut -left '.$this->x_axis.' -top '.$this->y_axis.' -width '.$this->width.' -height '.$this->height;
+ }
+ elseif ($action == 'rotate')
+ {
+ switch ($this->rotation_angle)
+ {
+ case 90 : $angle = 'r270';
+ break;
+ case 180 : $angle = 'r180';
+ break;
+ case 270 : $angle = 'r90';
+ break;
+ case 'vrt' : $angle = 'tb';
+ break;
+ case 'hor' : $angle = 'lr';
+ break;
+ }
+
+ $cmd_inner = 'pnmflip -'.$angle.' ';
+ }
+ else // Resize
+ {
+ $cmd_inner = 'pnmscale -xysize '.$this->width.' '.$this->height;
+ }
+
+ $cmd = $this->library_path.$cmd_in.' '.$this->full_src_path.' | '.$cmd_inner.' | '.$cmd_out.' > '.$this->dest_folder.'netpbm.tmp';
+
+ $retval = 1;
+
+ @exec($cmd, $output, $retval);
+
+ // Did it work?
+ if ($retval > 0)
+ {
+ $this->set_error('imglib_image_process_failed');
+ return FALSE;
+ }
+
+ // With NetPBM we have to create a temporary image.
+ // If you try manipulating the original it fails so
+ // we have to rename the temp file.
+ copy ($this->dest_folder.'netpbm.tmp', $this->full_dst_path);
+ unlink ($this->dest_folder.'netpbm.tmp');
+ @chmod($this->full_dst_path, DIR_WRITE_MODE);
+
+ return TRUE;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Image Rotate Using GD
+ *
+ * @access public
+ * @return bool
+ */
+ function image_rotate_gd()
+ {
+ // Is Image Rotation Supported?
+ // this function is only supported as of PHP 4.3
+ if ( ! function_exists('imagerotate'))
+ {
+ $this->set_error('imglib_rotate_unsupported');
+ return FALSE;
+ }
+
+ // Create the image handle
+ if ( ! ($src_img = $this->image_create_gd()))
+ {
+ return FALSE;
+ }
+
+ // Set the background color
+ // This won't work with transparent PNG files so we are
+ // going to have to figure out how to determine the color
+ // of the alpha channel in a future release.
+
+ $white = imagecolorallocate($src_img, 255, 255, 255);
+
+ // Rotate it!
+ $dst_img = imagerotate($src_img, $this->rotation_angle, $white);
+
+ // Save the Image
+ if ($this->dynamic_output == TRUE)
+ {
+ $this->image_display_gd($dst_img);
+ }
+ else
+ {
+ // Or save it
+ if ( ! $this->image_save_gd($dst_img))
+ {
+ return FALSE;
+ }
+ }
+
+ // Kill the file handles
+ imagedestroy($dst_img);
+ imagedestroy($src_img);
+
+ // Set the file to 777
+
+ @chmod($this->full_dst_path, DIR_WRITE_MODE);
+
+ return true;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Create Mirror Image using GD
+ *
+ * This function will flip horizontal or vertical
+ *
+ * @access public
+ * @return bool
+ */
+ function image_mirror_gd()
+ {
+ if ( ! $src_img = $this->image_create_gd())
+ {
+ return FALSE;
+ }
+
+ $width = $this->orig_width;
+ $height = $this->orig_height;
+
+ if ($this->rotation_angle == 'hor')
+ {
+ for ($i = 0; $i < $height; $i++)
+ {
+ $left = 0;
+ $right = $width-1;
+
+ while ($left < $right)
+ {
+ $cl = imagecolorat($src_img, $left, $i);
+ $cr = imagecolorat($src_img, $right, $i);
+
+ imagesetpixel($src_img, $left, $i, $cr);
+ imagesetpixel($src_img, $right, $i, $cl);
+
+ $left++;
+ $right--;
+ }
+ }
+ }
+ else
+ {
+ for ($i = 0; $i < $width; $i++)
+ {
+ $top = 0;
+ $bot = $height-1;
+
+ while ($top < $bot)
+ {
+ $ct = imagecolorat($src_img, $i, $top);
+ $cb = imagecolorat($src_img, $i, $bot);
+
+ imagesetpixel($src_img, $i, $top, $cb);
+ imagesetpixel($src_img, $i, $bot, $ct);
+
+ $top++;
+ $bot--;
+ }
+ }
+ }
+
+ // Show the image
+ if ($this->dynamic_output == TRUE)
+ {
+ $this->image_display_gd($src_img);
+ }
+ else
+ {
+ // Or save it
+ if ( ! $this->image_save_gd($src_img))
+ {
+ return FALSE;
+ }
+ }
+
+ // Kill the file handles
+ imagedestroy($src_img);
+
+ // Set the file to 777
+ @chmod($this->full_dst_path, DIR_WRITE_MODE);
+
+ return TRUE;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Image Watermark
+ *
+ * This is a wrapper function that chooses the type
+ * of watermarking based on the specified preference.
+ *
+ * @access public
+ * @param string
+ * @return bool
+ */
+ function watermark()
+ {
+ if ($this->wm_type == 'overlay')
+ {
+ return $this->overlay_watermark();
+ }
+ else
+ {
+ return $this->text_watermark();
+ }
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Watermark - Graphic Version
+ *
+ * @access public
+ * @return bool
+ */
+ function overlay_watermark()
+ {
+ if ( ! function_exists('imagecolortransparent'))
+ {
+ $this->set_error('imglib_gd_required');
+ return FALSE;
+ }
+
+ // Fetch source image properties
+ $this->get_image_properties();
+
+ // Fetch watermark image properties
+ $props = $this->get_image_properties($this->wm_overlay_path, TRUE);
+ $wm_img_type = $props['image_type'];
+ $wm_width = $props['width'];
+ $wm_height = $props['height'];
+
+ // Create two image resources
+ $wm_img = $this->image_create_gd($this->wm_overlay_path, $wm_img_type);
+ $src_img = $this->image_create_gd($this->full_src_path);
+
+ // Reverse the offset if necessary
+ // When the image is positioned at the bottom
+ // we don't want the vertical offset to push it
+ // further down. We want the reverse, so we'll
+ // invert the offset. Same with the horizontal
+ // offset when the image is at the right
+
+ $this->wm_vrt_alignment = strtoupper(substr($this->wm_vrt_alignment, 0, 1));
+ $this->wm_hor_alignment = strtoupper(substr($this->wm_hor_alignment, 0, 1));
+
+ if ($this->wm_vrt_alignment == 'B')
+ $this->wm_vrt_offset = $this->wm_vrt_offset * -1;
+
+ if ($this->wm_hor_alignment == 'R')
+ $this->wm_hor_offset = $this->wm_hor_offset * -1;
+
+ // Set the base x and y axis values
+ $x_axis = $this->wm_hor_offset + $this->wm_padding;
+ $y_axis = $this->wm_vrt_offset + $this->wm_padding;
+
+ // Set the vertical position
+ switch ($this->wm_vrt_alignment)
+ {
+ case 'T':
+ break;
+ case 'M': $y_axis += ($this->orig_height / 2) - ($wm_height / 2);
+ break;
+ case 'B': $y_axis += $this->orig_height - $wm_height;
+ break;
+ }
+
+ // Set the horizontal position
+ switch ($this->wm_hor_alignment)
+ {
+ case 'L':
+ break;
+ case 'C': $x_axis += ($this->orig_width / 2) - ($wm_width / 2);
+ break;
+ case 'R': $x_axis += $this->orig_width - $wm_width;
+ break;
+ }
+
+ // Build the finalized image
+ if ($wm_img_type == 3 AND function_exists('imagealphablending'))
+ {
+ @imagealphablending($src_img, TRUE);
+ }
+
+ // Set RGB values for text and shadow
+ $rgba = imagecolorat($wm_img, $this->wm_x_transp, $this->wm_y_transp);
+ $alpha = ($rgba & 0x7F000000) >> 24;
+
+ // make a best guess as to whether we're dealing with an image with alpha transparency or no/binary transparency
+ if ($alpha > 0)
+ {
+ // copy the image directly, the image's alpha transparency being the sole determinant of blending
+ imagecopy($src_img, $wm_img, $x_axis, $y_axis, 0, 0, $wm_width, $wm_height);
+ }
+ else
+ {
+ // set our RGB value from above to be transparent and merge the images with the specified opacity
+ imagecolortransparent($wm_img, imagecolorat($wm_img, $this->wm_x_transp, $this->wm_y_transp));
+ imagecopymerge($src_img, $wm_img, $x_axis, $y_axis, 0, 0, $wm_width, $wm_height, $this->wm_opacity);
+ }
+
+ // Output the image
+ if ($this->dynamic_output == TRUE)
+ {
+ $this->image_display_gd($src_img);
+ }
+ else
+ {
+ if ( ! $this->image_save_gd($src_img))
+ {
+ return FALSE;
+ }
+ }
+
+ imagedestroy($src_img);
+ imagedestroy($wm_img);
+
+ return TRUE;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Watermark - Text Version
+ *
+ * @access public
+ * @return bool
+ */
+ function text_watermark()
+ {
+ if ( ! ($src_img = $this->image_create_gd()))
+ {
+ return FALSE;
+ }
+
+ if ($this->wm_use_truetype == TRUE AND ! file_exists($this->wm_font_path))
+ {
+ $this->set_error('imglib_missing_font');
+ return FALSE;
+ }
+
+ // Fetch source image properties
+ $this->get_image_properties();
+
+ // Set RGB values for text and shadow
+ $this->wm_font_color = str_replace('#', '', $this->wm_font_color);
+ $this->wm_shadow_color = str_replace('#', '', $this->wm_shadow_color);
+
+ $R1 = hexdec(substr($this->wm_font_color, 0, 2));
+ $G1 = hexdec(substr($this->wm_font_color, 2, 2));
+ $B1 = hexdec(substr($this->wm_font_color, 4, 2));
+
+ $R2 = hexdec(substr($this->wm_shadow_color, 0, 2));
+ $G2 = hexdec(substr($this->wm_shadow_color, 2, 2));
+ $B2 = hexdec(substr($this->wm_shadow_color, 4, 2));
+
+ $txt_color = imagecolorclosest($src_img, $R1, $G1, $B1);
+ $drp_color = imagecolorclosest($src_img, $R2, $G2, $B2);
+
+ // Reverse the vertical offset
+ // When the image is positioned at the bottom
+ // we don't want the vertical offset to push it
+ // further down. We want the reverse, so we'll
+ // invert the offset. Note: The horizontal
+ // offset flips itself automatically
+
+ if ($this->wm_vrt_alignment == 'B')
+ $this->wm_vrt_offset = $this->wm_vrt_offset * -1;
+
+ if ($this->wm_hor_alignment == 'R')
+ $this->wm_hor_offset = $this->wm_hor_offset * -1;
+
+ // Set font width and height
+ // These are calculated differently depending on
+ // whether we are using the true type font or not
+ if ($this->wm_use_truetype == TRUE)
+ {
+ if ($this->wm_font_size == '')
+ $this->wm_font_size = '17';
+
+ $fontwidth = $this->wm_font_size-($this->wm_font_size/4);
+ $fontheight = $this->wm_font_size;
+ $this->wm_vrt_offset += $this->wm_font_size;
+ }
+ else
+ {
+ $fontwidth = imagefontwidth($this->wm_font_size);
+ $fontheight = imagefontheight($this->wm_font_size);
+ }
+
+ // Set base X and Y axis values
+ $x_axis = $this->wm_hor_offset + $this->wm_padding;
+ $y_axis = $this->wm_vrt_offset + $this->wm_padding;
+
+ // Set verticle alignment
+ if ($this->wm_use_drop_shadow == FALSE)
+ $this->wm_shadow_distance = 0;
+
+ $this->wm_vrt_alignment = strtoupper(substr($this->wm_vrt_alignment, 0, 1));
+ $this->wm_hor_alignment = strtoupper(substr($this->wm_hor_alignment, 0, 1));
+
+ switch ($this->wm_vrt_alignment)
+ {
+ case "T" :
+ break;
+ case "M": $y_axis += ($this->orig_height/2)+($fontheight/2);
+ break;
+ case "B": $y_axis += ($this->orig_height - $fontheight - $this->wm_shadow_distance - ($fontheight/2));
+ break;
+ }
+
+ $x_shad = $x_axis + $this->wm_shadow_distance;
+ $y_shad = $y_axis + $this->wm_shadow_distance;
+
+ // Set horizontal alignment
+ switch ($this->wm_hor_alignment)
+ {
+ case "L":
+ break;
+ case "R":
+ if ($this->wm_use_drop_shadow)
+ $x_shad += ($this->orig_width - $fontwidth*strlen($this->wm_text));
+ $x_axis += ($this->orig_width - $fontwidth*strlen($this->wm_text));
+ break;
+ case "C":
+ if ($this->wm_use_drop_shadow)
+ $x_shad += floor(($this->orig_width - $fontwidth*strlen($this->wm_text))/2);
+ $x_axis += floor(($this->orig_width -$fontwidth*strlen($this->wm_text))/2);
+ break;
+ }
+
+ // Add the text to the source image
+ if ($this->wm_use_truetype)
+ {
+ if ($this->wm_use_drop_shadow)
+ imagettftext($src_img, $this->wm_font_size, 0, $x_shad, $y_shad, $drp_color, $this->wm_font_path, $this->wm_text);
+ imagettftext($src_img, $this->wm_font_size, 0, $x_axis, $y_axis, $txt_color, $this->wm_font_path, $this->wm_text);
+ }
+ else
+ {
+ if ($this->wm_use_drop_shadow)
+ imagestring($src_img, $this->wm_font_size, $x_shad, $y_shad, $this->wm_text, $drp_color);
+ imagestring($src_img, $this->wm_font_size, $x_axis, $y_axis, $this->wm_text, $txt_color);
+ }
+
+ // Output the final image
+ if ($this->dynamic_output == TRUE)
+ {
+ $this->image_display_gd($src_img);
+ }
+ else
+ {
+ $this->image_save_gd($src_img);
+ }
+
+ imagedestroy($src_img);
+
+ return TRUE;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Create Image - GD
+ *
+ * This simply creates an image resource handle
+ * based on the type of image being processed
+ *
+ * @access public
+ * @param string
+ * @return resource
+ */
+ function image_create_gd($path = '', $image_type = '')
+ {
+ if ($path == '')
+ $path = $this->full_src_path;
+
+ if ($image_type == '')
+ $image_type = $this->image_type;
+
+
+ switch ($image_type)
+ {
+ case 1 :
+ if ( ! function_exists('imagecreatefromgif'))
+ {
+ $this->set_error(array('imglib_unsupported_imagecreate', 'imglib_gif_not_supported'));
+ return FALSE;
+ }
+
+ return imagecreatefromgif($path);
+ break;
+ case 2 :
+ if ( ! function_exists('imagecreatefromjpeg'))
+ {
+ $this->set_error(array('imglib_unsupported_imagecreate', 'imglib_jpg_not_supported'));
+ return FALSE;
+ }
+
+ return imagecreatefromjpeg($path);
+ break;
+ case 3 :
+ if ( ! function_exists('imagecreatefrompng'))
+ {
+ $this->set_error(array('imglib_unsupported_imagecreate', 'imglib_png_not_supported'));
+ return FALSE;
+ }
+
+ return imagecreatefrompng($path);
+ break;
+
+ }
+
+ $this->set_error(array('imglib_unsupported_imagecreate'));
+ return FALSE;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Write image file to disk - GD
+ *
+ * Takes an image resource as input and writes the file
+ * to the specified destination
+ *
+ * @access public
+ * @param resource
+ * @return bool
+ */
+ function image_save_gd($resource)
+ {
+ switch ($this->image_type)
+ {
+ case 1 :
+ if ( ! function_exists('imagegif'))
+ {
+ $this->set_error(array('imglib_unsupported_imagecreate', 'imglib_gif_not_supported'));
+ return FALSE;
+ }
+
+ @imagegif($resource, $this->full_dst_path);
+ break;
+ case 2 :
+ if ( ! function_exists('imagejpeg'))
+ {
+ $this->set_error(array('imglib_unsupported_imagecreate', 'imglib_jpg_not_supported'));
+ return FALSE;
+ }
+
+ if (phpversion() == '4.4.1')
+ {
+ @touch($this->full_dst_path); // PHP 4.4.1 bug #35060 - workaround
+ }
+
+ @imagejpeg($resource, $this->full_dst_path, $this->quality);
+ break;
+ case 3 :
+ if ( ! function_exists('imagepng'))
+ {
+ $this->set_error(array('imglib_unsupported_imagecreate', 'imglib_png_not_supported'));
+ return FALSE;
+ }
+
+ @imagepng($resource, $this->full_dst_path);
+ break;
+ default :
+ $this->set_error(array('imglib_unsupported_imagecreate'));
+ return FALSE;
+ break;
+ }
+
+ return TRUE;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Dynamically outputs an image
+ *
+ * @access public
+ * @param resource
+ * @return void
+ */
+ function image_display_gd($resource)
+ {
+ header("Content-Disposition: filename={$this->source_image};");
+ header("Content-Type: {$this->mime_type}");
+ header('Content-Transfer-Encoding: binary');
+ header('Last-Modified: '.gmdate('D, d M Y H:i:s', time()).' GMT');
+
+ switch ($this->image_type)
+ {
+ case 1 : imagegif($resource);
+ break;
+ case 2 : imagejpeg($resource, '', $this->quality);
+ break;
+ case 3 : imagepng($resource);
+ break;
+ default : echo 'Unable to display the image';
+ break;
+ }
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Re-proportion Image Width/Height
+ *
+ * When creating thumbs, the desired width/height
+ * can end up warping the image due to an incorrect
+ * ratio between the full-sized image and the thumb.
+ *
+ * This function lets us re-proportion the width/height
+ * if users choose to maintain the aspect ratio when resizing.
+ *
+ * @access public
+ * @return void
+ */
+ function image_reproportion()
+ {
+ if ( ! is_numeric($this->width) OR ! is_numeric($this->height) OR $this->width == 0 OR $this->height == 0)
+ return;
+
+ if ( ! is_numeric($this->orig_width) OR ! is_numeric($this->orig_height) OR $this->orig_width == 0 OR $this->orig_height == 0)
+ return;
+
+ $new_width = ceil($this->orig_width*$this->height/$this->orig_height);
+ $new_height = ceil($this->width*$this->orig_height/$this->orig_width);
+
+ $ratio = (($this->orig_height/$this->orig_width) - ($this->height/$this->width));
+
+ if ($this->master_dim != 'width' AND $this->master_dim != 'height')
+ {
+ $this->master_dim = ($ratio < 0) ? 'width' : 'height';
+ }
+
+ if (($this->width != $new_width) AND ($this->height != $new_height))
+ {
+ if ($this->master_dim == 'height')
+ {
+ $this->width = $new_width;
+ }
+ else
+ {
+ $this->height = $new_height;
+ }
+ }
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Get image properties
+ *
+ * A helper function that gets info about the file
+ *
+ * @access public
+ * @param string
+ * @return mixed
+ */
+ function get_image_properties($path = '', $return = FALSE)
+ {
+ // For now we require GD but we should
+ // find a way to determine this using IM or NetPBM
+
+ if ($path == '')
+ $path = $this->full_src_path;
+
+ if ( ! file_exists($path))
+ {
+ $this->set_error('imglib_invalid_path');
+ return FALSE;
+ }
+
+ $vals = @getimagesize($path);
+
+ $types = array(1 => 'gif', 2 => 'jpeg', 3 => 'png');
+
+ $mime = (isset($types[$vals['2']])) ? 'image/'.$types[$vals['2']] : 'image/jpg';
+
+ if ($return == TRUE)
+ {
+ $v['width'] = $vals['0'];
+ $v['height'] = $vals['1'];
+ $v['image_type'] = $vals['2'];
+ $v['size_str'] = $vals['3'];
+ $v['mime_type'] = $mime;
+
+ return $v;
+ }
+
+ $this->orig_width = $vals['0'];
+ $this->orig_height = $vals['1'];
+ $this->image_type = $vals['2'];
+ $this->size_str = $vals['3'];
+ $this->mime_type = $mime;
+
+ return TRUE;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Size calculator
+ *
+ * This function takes a known width x height and
+ * recalculates it to a new size. Only one
+ * new variable needs to be known
+ *
+ * $props = array(
+ * 'width' => $width,
+ * 'height' => $height,
+ * 'new_width' => 40,
+ * 'new_height' => ''
+ * );
+ *
+ * @access public
+ * @param array
+ * @return array
+ */
+ function size_calculator($vals)
+ {
+ if ( ! is_array($vals))
+ {
+ return;
+ }
+
+ $allowed = array('new_width', 'new_height', 'width', 'height');
+
+ foreach ($allowed as $item)
+ {
+ if ( ! isset($vals[$item]) OR $vals[$item] == '')
+ $vals[$item] = 0;
+ }
+
+ if ($vals['width'] == 0 OR $vals['height'] == 0)
+ {
+ return $vals;
+ }
+
+ if ($vals['new_width'] == 0)
+ {
+ $vals['new_width'] = ceil($vals['width']*$vals['new_height']/$vals['height']);
+ }
+ elseif ($vals['new_height'] == 0)
+ {
+ $vals['new_height'] = ceil($vals['new_width']*$vals['height']/$vals['width']);
+ }
+
+ return $vals;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Explode source_image
+ *
+ * This is a helper function that extracts the extension
+ * from the source_image. This function lets us deal with
+ * source_images with multiple periods, like: my.cool.jpg
+ * It returns an associative array with two elements:
+ * $array['ext'] = '.jpg';
+ * $array['name'] = 'my.cool';
+ *
+ * @access public
+ * @param array
+ * @return array
+ */
+ function explode_name($source_image)
+ {
+ $x = explode('.', $source_image);
+ $ret['ext'] = '.'.end($x);
+
+ $name = '';
+
+ $ct = count($x)-1;
+
+ for ($i = 0; $i < $ct; $i++)
+ {
+ $name .= $x[$i];
+
+ if ($i < ($ct - 1))
+ {
+ $name .= '.';
+ }
+ }
+
+ $ret['name'] = $name;
+
+ return $ret;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Is GD Installed?
+ *
+ * @access public
+ * @return bool
+ */
+ function gd_loaded()
+ {
+ if ( ! extension_loaded('gd'))
+ {
+ if ( ! dl('gd.so'))
+ {
+ return FALSE;
+ }
+ }
+
+ return TRUE;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Get GD version
+ *
+ * @access public
+ * @return mixed
+ */
+ function gd_version()
+ {
+ if (function_exists('gd_info'))
+ {
+ $gd_version = @gd_info();
+ $gd_version = preg_replace("/\D/", "", $gd_version['GD Version']);
+
+ return $gd_version;
+ }
+
+ return FALSE;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Set error message
+ *
+ * @access public
+ * @param string
+ * @return void
+ */
+ function set_error($msg)
+ {
+ $CI =& get_instance();
+ $CI->lang->load('imglib');
+
+ if (is_array($msg))
+ {
+ foreach ($msg as $val)
+ {
+
+ $msg = ($CI->lang->line($val) == FALSE) ? $val : $CI->lang->line($val);
+ $this->error_msg[] = $msg;
+ log_message('error', $msg);
+ }
+ }
+ else
+ {
+ $msg = ($CI->lang->line($msg) == FALSE) ? $msg : $CI->lang->line($msg);
+ $this->error_msg[] = $msg;
+ log_message('error', $msg);
+ }
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Show error messages
+ *
+ * @access public
+ * @param string
+ * @return string
+ */
+ function display_errors($open = '<p>', $close = '</p>')
+ {
+ $str = '';
+ foreach ($this->error_msg as $val)
+ {
+ $str .= $open.$val.$close;
+ }
+
+ return $str;
+ }
+
+}
+// END Image_lib Class
+
+/* End of file Image_lib.php */
/* Location: ./system/libraries/Image_lib.php */ \ No newline at end of file
diff --git a/system/libraries/Input.php b/system/libraries/Input.php
index f26df7552..fe76559fe 100644
--- a/system/libraries/Input.php
+++ b/system/libraries/Input.php
@@ -1,1059 +1,1059 @@
-<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
-/**
- * CodeIgniter
- *
- * An open source application development framework for PHP 4.3.2 or newer
- *
- * @package CodeIgniter
- * @author ExpressionEngine Dev Team
- * @copyright Copyright (c) 2008, EllisLab, Inc.
- * @license http://codeigniter.com/user_guide/license.html
- * @link http://codeigniter.com
- * @since Version 1.0
- * @filesource
- */
-
-// ------------------------------------------------------------------------
-
-/**
- * Input Class
- *
- * Pre-processes global input data for security
- *
- * @package CodeIgniter
- * @subpackage Libraries
- * @category Input
- * @author ExpressionEngine Dev Team
- * @link http://codeigniter.com/user_guide/libraries/input.html
- */
-class CI_Input {
- var $use_xss_clean = FALSE;
- var $xss_hash = '';
- var $ip_address = FALSE;
- var $user_agent = FALSE;
- var $allow_get_array = FALSE;
-
- /* never allowed, string replacement */
- var $never_allowed_str = array(
- 'document.cookie' => '[removed]',
- 'document.write' => '[removed]',
- '.parentNode' => '[removed]',
- '.innerHTML' => '[removed]',
- 'window.location' => '[removed]',
- '-moz-binding' => '[removed]',
- '<!--' => '&lt;!--',
- '-->' => '--&gt;',
- '<![CDATA[' => '&lt;![CDATA['
- );
- /* never allowed, regex replacement */
- var $never_allowed_regex = array(
- "javascript\s*:" => '[removed]',
- "expression\s*\(" => '[removed]', // CSS and IE
- "Redirect\s+302" => '[removed]'
- );
-
- /**
- * Constructor
- *
- * Sets whether to globally enable the XSS processing
- * and whether to allow the $_GET array
- *
- * @access public
- */
- function CI_Input()
- {
- log_message('debug', "Input Class Initialized");
-
- $CFG =& load_class('Config');
- $this->use_xss_clean = ($CFG->item('global_xss_filtering') === TRUE) ? TRUE : FALSE;
- $this->allow_get_array = ($CFG->item('enable_query_strings') === TRUE) ? TRUE : FALSE;
- $this->_sanitize_globals();
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Sanitize Globals
- *
- * This function does the following:
- *
- * Unsets $_GET data (if query strings are not enabled)
- *
- * Unsets all globals if register_globals is enabled
- *
- * Standardizes newline characters to \n
- *
- * @access private
- * @return void
- */
- function _sanitize_globals()
- {
- // Would kind of be "wrong" to unset any of these GLOBALS
- $protected = array('_SERVER', '_GET', '_POST', '_FILES', '_REQUEST', '_SESSION', '_ENV', 'GLOBALS', 'HTTP_RAW_POST_DATA',
- 'system_folder', 'application_folder', 'BM', 'EXT', 'CFG', 'URI', 'RTR', 'OUT', 'IN');
-
- // Unset globals for security.
- // This is effectively the same as register_globals = off
- foreach (array($_GET, $_POST, $_COOKIE, $_SERVER, $_FILES, $_ENV, (isset($_SESSION) && is_array($_SESSION)) ? $_SESSION : array()) as $global)
- {
- if ( ! is_array($global))
- {
- if ( ! in_array($global, $protected))
- {
- unset($GLOBALS[$global]);
- }
- }
- else
- {
- foreach ($global as $key => $val)
- {
- if ( ! in_array($key, $protected))
- {
- unset($GLOBALS[$key]);
- }
-
- if (is_array($val))
- {
- foreach($val as $k => $v)
- {
- if ( ! in_array($k, $protected))
- {
- unset($GLOBALS[$k]);
- }
- }
- }
- }
- }
- }
-
- // Is $_GET data allowed? If not we'll set the $_GET to an empty array
- if ($this->allow_get_array == FALSE)
- {
- $_GET = array();
- }
- else
- {
- $_GET = $this->_clean_input_data($_GET);
- }
-
- // Clean $_POST Data
- $_POST = $this->_clean_input_data($_POST);
-
- // Clean $_COOKIE Data
- // Also get rid of specially treated cookies that might be set by a server
- // or silly application, that are of no use to a CI application anyway
- // but that when present will trip our 'Disallowed Key Characters' alarm
- // http://www.ietf.org/rfc/rfc2109.txt
- // note that the key names below are single quoted strings, and are not PHP variables
- unset($_COOKIE['$Version']);
- unset($_COOKIE['$Path']);
- unset($_COOKIE['$Domain']);
- $_COOKIE = $this->_clean_input_data($_COOKIE);
-
- log_message('debug', "Global POST and COOKIE data sanitized");
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Clean Input Data
- *
- * This is a helper function. It escapes data and
- * standardizes newline characters to \n
- *
- * @access private
- * @param string
- * @return string
- */
- function _clean_input_data($str)
- {
- if (is_array($str))
- {
- $new_array = array();
- foreach ($str as $key => $val)
- {
- $new_array[$this->_clean_input_keys($key)] = $this->_clean_input_data($val);
- }
- return $new_array;
- }
-
- // We strip slashes if magic quotes is on to keep things consistent
- if (get_magic_quotes_gpc())
- {
- $str = stripslashes($str);
- }
-
- // Should we filter the input data?
- if ($this->use_xss_clean === TRUE)
- {
- $str = $this->xss_clean($str);
- }
-
- // Standardize newlines
- if (strpos($str, "\r") !== FALSE)
- {
- $str = str_replace(array("\r\n", "\r"), "\n", $str);
- }
-
- return $str;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Clean Keys
- *
- * This is a helper function. To prevent malicious users
- * from trying to exploit keys we make sure that keys are
- * only named with alpha-numeric text and a few other items.
- *
- * @access private
- * @param string
- * @return string
- */
- function _clean_input_keys($str)
- {
- if ( ! preg_match("/^[a-z0-9:_\/-]+$/i", $str))
- {
- exit('Disallowed Key Characters.');
- }
-
- return $str;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Fetch from array
- *
- * This is a helper function to retrieve values from global arrays
- *
- * @access private
- * @param array
- * @param string
- * @param bool
- * @return string
- */
- function _fetch_from_array(&$array, $index = '', $xss_clean = FALSE)
- {
- if ( ! isset($array[$index]))
- {
- return FALSE;
- }
-
- if ($xss_clean === TRUE)
- {
- return $this->xss_clean($array[$index]);
- }
-
- return $array[$index];
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Fetch an item from the GET array
- *
- * @access public
- * @param string
- * @param bool
- * @return string
- */
- function get($index = '', $xss_clean = FALSE)
- {
- return $this->_fetch_from_array($_GET, $index, $xss_clean);
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Fetch an item from the POST array
- *
- * @access public
- * @param string
- * @param bool
- * @return string
- */
- function post($index = '', $xss_clean = FALSE)
- {
- return $this->_fetch_from_array($_POST, $index, $xss_clean);
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Fetch an item from either the GET array or the POST
- *
- * @access public
- * @param string The index key
- * @param bool XSS cleaning
- * @return string
- */
- function get_post($index = '', $xss_clean = FALSE)
- {
- if ( ! isset($_POST[$index]) )
- {
- return $this->get($index, $xss_clean);
- }
- else
- {
- return $this->post($index, $xss_clean);
- }
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Fetch an item from the COOKIE array
- *
- * @access public
- * @param string
- * @param bool
- * @return string
- */
- function cookie($index = '', $xss_clean = FALSE)
- {
- return $this->_fetch_from_array($_COOKIE, $index, $xss_clean);
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Fetch an item from the SERVER array
- *
- * @access public
- * @param string
- * @param bool
- * @return string
- */
- function server($index = '', $xss_clean = FALSE)
- {
- return $this->_fetch_from_array($_SERVER, $index, $xss_clean);
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Fetch the IP Address
- *
- * @access public
- * @return string
- */
- function ip_address()
- {
- if ($this->ip_address !== FALSE)
- {
- return $this->ip_address;
- }
-
- if ($this->server('REMOTE_ADDR') AND $this->server('HTTP_CLIENT_IP'))
- {
- $this->ip_address = $_SERVER['HTTP_CLIENT_IP'];
- }
- elseif ($this->server('REMOTE_ADDR'))
- {
- $this->ip_address = $_SERVER['REMOTE_ADDR'];
- }
- elseif ($this->server('HTTP_CLIENT_IP'))
- {
- $this->ip_address = $_SERVER['HTTP_CLIENT_IP'];
- }
- elseif ($this->server('HTTP_X_FORWARDED_FOR'))
- {
- $this->ip_address = $_SERVER['HTTP_X_FORWARDED_FOR'];
- }
-
- if ($this->ip_address === FALSE)
- {
- $this->ip_address = '0.0.0.0';
- return $this->ip_address;
- }
-
- if (strstr($this->ip_address, ','))
- {
- $x = explode(',', $this->ip_address);
- $this->ip_address = end($x);
- }
-
- if ( ! $this->valid_ip($this->ip_address))
- {
- $this->ip_address = '0.0.0.0';
- }
-
- return $this->ip_address;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Validate IP Address
- *
- * Updated version suggested by Geert De Deckere
- *
- * @access public
- * @param string
- * @return string
- */
- function valid_ip($ip)
- {
- $ip_segments = explode('.', $ip);
-
- // Always 4 segments needed
- if (count($ip_segments) != 4)
- {
- return FALSE;
- }
- // IP can not start with 0
- if ($ip_segments[0][0] == '0')
- {
- return FALSE;
- }
- // Check each segment
- foreach ($ip_segments as $segment)
- {
- // IP segments must be digits and can not be
- // longer than 3 digits or greater then 255
- if ($segment == '' OR preg_match("/[^0-9]/", $segment) OR $segment > 255 OR strlen($segment) > 3)
- {
- return FALSE;
- }
- }
-
- return TRUE;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * User Agent
- *
- * @access public
- * @return string
- */
- function user_agent()
- {
- if ($this->user_agent !== FALSE)
- {
- return $this->user_agent;
- }
-
- $this->user_agent = ( ! isset($_SERVER['HTTP_USER_AGENT'])) ? FALSE : $_SERVER['HTTP_USER_AGENT'];
-
- return $this->user_agent;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Filename Security
- *
- * @access public
- * @param string
- * @return string
- */
- function filename_security($str)
- {
- $bad = array(
- "../",
- "./",
- "<!--",
- "-->",
- "<",
- ">",
- "'",
- '"',
- '&',
- '$',
- '#',
- '{',
- '}',
- '[',
- ']',
- '=',
- ';',
- '?',
- "%20",
- "%22",
- "%3c", // <
- "%253c", // <
- "%3e", // >
- "%0e", // >
- "%28", // (
- "%29", // )
- "%2528", // (
- "%26", // &
- "%24", // $
- "%3f", // ?
- "%3b", // ;
- "%3d" // =
- );
-
- return stripslashes(str_replace($bad, '', $str));
- }
-
- // --------------------------------------------------------------------
-
- /**
- * XSS Clean
- *
- * Sanitizes data so that Cross Site Scripting Hacks can be
- * prevented. This function does a fair amount of work but
- * it is extremely thorough, designed to prevent even the
- * most obscure XSS attempts. Nothing is ever 100% foolproof,
- * of course, but I haven't been able to get anything passed
- * the filter.
- *
- * Note: This function should only be used to deal with data
- * upon submission. It's not something that should
- * be used for general runtime processing.
- *
- * This function was based in part on some code and ideas I
- * got from Bitflux: http://blog.bitflux.ch/wiki/XSS_Prevention
- *
- * To help develop this script I used this great list of
- * vulnerabilities along with a few other hacks I've
- * harvested from examining vulnerabilities in other programs:
- * http://ha.ckers.org/xss.html
- *
- * @access public
- * @param string
- * @return string
- */
- function xss_clean($str, $is_image = FALSE)
- {
- /*
- * Is the string an array?
- *
- */
- if (is_array($str))
- {
- while (list($key) = each($str))
- {
- $str[$key] = $this->xss_clean($str[$key]);
- }
-
- return $str;
- }
-
- /*
- * Remove Invisible Characters
- */
- $str = $this->_remove_invisible_characters($str);
-
- /*
- * Protect GET variables in URLs
- */
-
- // 901119URL5918AMP18930PROTECT8198
-
- $str = preg_replace('|\&([a-z\_0-9]+)\=([a-z\_0-9]+)|i', $this->xss_hash()."\\1=\\2", $str);
-
- /*
- * Validate standard character entities
- *
- * Add a semicolon if missing. We do this to enable
- * the conversion of entities to ASCII later.
- *
- */
- $str = preg_replace('#(&\#?[0-9a-z]{2,})[\x00-\x20]*;?#i', "\\1;", $str);
-
- /*
- * Validate UTF16 two byte encoding (x00)
- *
- * Just as above, adds a semicolon if missing.
- *
- */
- $str = preg_replace('#(&\#x?)([0-9A-F]+);?#i',"\\1\\2;",$str);
-
- /*
- * Un-Protect GET variables in URLs
- */
- $str = str_replace($this->xss_hash(), '&', $str);
-
- /*
- * URL Decode
- *
- * Just in case stuff like this is submitted:
- *
- * <a href="http://%77%77%77%2E%67%6F%6F%67%6C%65%2E%63%6F%6D">Google</a>
- *
- * Note: Use rawurldecode() so it does not remove plus signs
- *
- */
- $str = rawurldecode($str);
-
- /*
- * Convert character entities to ASCII
- *
- * This permits our tests below to work reliably.
- * We only convert entities that are within tags since
- * these are the ones that will pose security problems.
- *
- */
-
- $str = preg_replace_callback("/[a-z]+=([\'\"]).*?\\1/si", array($this, '_convert_attribute'), $str);
-
- $str = preg_replace_callback("/<\w+.*?(?=>|<|$)/si", array($this, '_html_entity_decode_callback'), $str);
-
- /*
- * Remove Invisible Characters Again!
- */
- $str = $this->_remove_invisible_characters($str);
-
- /*
- * Convert all tabs to spaces
- *
- * This prevents strings like this: ja vascript
- * NOTE: we deal with spaces between characters later.
- * NOTE: preg_replace was found to be amazingly slow here on large blocks of data,
- * so we use str_replace.
- *
- */
-
- if (strpos($str, "\t") !== FALSE)
- {
- $str = str_replace("\t", ' ', $str);
- }
-
- /*
- * Capture converted string for later comparison
- */
- $converted_string = $str;
-
- /*
- * Not Allowed Under Any Conditions
- */
-
- foreach ($this->never_allowed_str as $key => $val)
- {
- $str = str_replace($key, $val, $str);
- }
-
- foreach ($this->never_allowed_regex as $key => $val)
- {
- $str = preg_replace("#".$key."#i", $val, $str);
- }
-
- /*
- * Makes PHP tags safe
- *
- * Note: XML tags are inadvertently replaced too:
- *
- * <?xml
- *
- * But it doesn't seem to pose a problem.
- *
- */
- if ($is_image === TRUE)
- {
- // Images have a tendency to have the PHP short opening and closing tags every so often
- // so we skip those and only do the long opening tags.
- $str = str_replace(array('<?php', '<?PHP'), array('&lt;?php', '&lt;?PHP'), $str);
- }
- else
- {
- $str = str_replace(array('<?php', '<?PHP', '<?', '?'.'>'), array('&lt;?php', '&lt;?PHP', '&lt;?', '?&gt;'), $str);
- }
-
- /*
- * Compact any exploded words
- *
- * This corrects words like: j a v a s c r i p t
- * These words are compacted back to their correct state.
- *
- */
- $words = array('javascript', 'expression', 'vbscript', 'script', 'applet', 'alert', 'document', 'write', 'cookie', 'window');
- foreach ($words as $word)
- {
- $temp = '';
-
- for ($i = 0, $wordlen = strlen($word); $i < $wordlen; $i++)
- {
- $temp .= substr($word, $i, 1)."\s*";
- }
-
- // We only want to do this when it is followed by a non-word character
- // That way valid stuff like "dealer to" does not become "dealerto"
- $str = preg_replace_callback('#('.substr($temp, 0, -3).')(\W)#is', array($this, '_compact_exploded_words'), $str);
- }
-
- /*
- * Remove disallowed Javascript in links or img tags
- * We used to do some version comparisons and use of stripos for PHP5, but it is dog slow compared
- * to these simplified non-capturing preg_match(), especially if the pattern exists in the string
- */
- do
- {
- $original = $str;
-
- if (preg_match("/<a/i", $str))
- {
- $str = preg_replace_callback("#<a\s+([^>]*?)(>|$)#si", array($this, '_js_link_removal'), $str);
- }
-
- if (preg_match("/<img/i", $str))
- {
- $str = preg_replace_callback("#<img\s+([^>]*?)(\s?/?>|$)#si", array($this, '_js_img_removal'), $str);
- }
-
- if (preg_match("/script/i", $str) OR preg_match("/xss/i", $str))
- {
- $str = preg_replace("#<(/*)(script|xss)(.*?)\>#si", '[removed]', $str);
- }
- }
- while($original != $str);
-
- unset($original);
-
- /*
- * Remove JavaScript Event Handlers
- *
- * Note: This code is a little blunt. It removes
- * the event handler and anything up to the closing >,
- * but it's unlikely to be a problem.
- *
- */
- $event_handlers = array('[^a-z_\-]on\w*','xmlns');
-
- if ($is_image === TRUE)
- {
- /*
- * Adobe Photoshop puts XML metadata into JFIF images, including namespacing,
- * so we have to allow this for images. -Paul
- */
- unset($event_handlers[array_search('xmlns', $event_handlers)]);
- }
-
- $str = preg_replace("#<([^><]+?)(".implode('|', $event_handlers).")(\s*=\s*[^><]*)([><]*)#i", "<\\1\\4", $str);
-
- /*
- * Sanitize naughty HTML elements
- *
- * If a tag containing any of the words in the list
- * below is found, the tag gets converted to entities.
- *
- * So this: <blink>
- * Becomes: &lt;blink&gt;
- *
- */
- $naughty = 'alert|applet|audio|basefont|base|behavior|bgsound|blink|body|embed|expression|form|frameset|frame|head|html|ilayer|iframe|input|isindex|layer|link|meta|object|plaintext|style|script|textarea|title|video|xml|xss';
- $str = preg_replace_callback('#<(/*\s*)('.$naughty.')([^><]*)([><]*)#is', array($this, '_sanitize_naughty_html'), $str);
-
- /*
- * Sanitize naughty scripting elements
- *
- * Similar to above, only instead of looking for
- * tags it looks for PHP and JavaScript commands
- * that are disallowed. Rather than removing the
- * code, it simply converts the parenthesis to entities
- * rendering the code un-executable.
- *
- * For example: eval('some code')
- * Becomes: eval&#40;'some code'&#41;
- *
- */
- $str = preg_replace('#(alert|cmd|passthru|eval|exec|expression|system|fopen|fsockopen|file|file_get_contents|readfile|unlink)(\s*)\((.*?)\)#si', "\\1\\2&#40;\\3&#41;", $str);
-
- /*
- * Final clean up
- *
- * This adds a bit of extra precaution in case
- * something got through the above filters
- *
- */
- foreach ($this->never_allowed_str as $key => $val)
- {
- $str = str_replace($key, $val, $str);
- }
-
- foreach ($this->never_allowed_regex as $key => $val)
- {
- $str = preg_replace("#".$key."#i", $val, $str);
- }
-
- /*
- * Images are Handled in a Special Way
- * - Essentially, we want to know that after all of the character conversion is done whether
- * any unwanted, likely XSS, code was found. If not, we return TRUE, as the image is clean.
- * However, if the string post-conversion does not matched the string post-removal of XSS,
- * then it fails, as there was unwanted XSS code found and removed/changed during processing.
- */
-
- if ($is_image === TRUE)
- {
- if ($str == $converted_string)
- {
- return TRUE;
- }
- else
- {
- return FALSE;
- }
- }
-
- log_message('debug', "XSS Filtering completed");
- return $str;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Random Hash for protecting URLs
- *
- * @access public
- * @return string
- */
- function xss_hash()
- {
- if ($this->xss_hash == '')
- {
- if (phpversion() >= 4.2)
- mt_srand();
- else
- mt_srand(hexdec(substr(md5(microtime()), -8)) & 0x7fffffff);
-
- $this->xss_hash = md5(time() + mt_rand(0, 1999999999));
- }
-
- return $this->xss_hash;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Remove Invisible Characters
- *
- * This prevents sandwiching null characters
- * between ascii characters, like Java\0script.
- *
- * @access public
- * @param string
- * @return string
- */
- function _remove_invisible_characters($str)
- {
- static $non_displayables;
-
- if ( ! isset($non_displayables))
- {
- // every control character except newline (dec 10), carriage return (dec 13), and horizontal tab (dec 09),
- $non_displayables = array(
- '/%0[0-8bcef]/', // url encoded 00-08, 11, 12, 14, 15
- '/%1[0-9a-f]/', // url encoded 16-31
- '/[\x00-\x08]/', // 00-08
- '/\x0b/', '/\x0c/', // 11, 12
- '/[\x0e-\x1f]/' // 14-31
- );
- }
-
- do
- {
- $cleaned = $str;
- $str = preg_replace($non_displayables, '', $str);
- }
- while ($cleaned != $str);
-
- return $str;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Compact Exploded Words
- *
- * Callback function for xss_clean() to remove whitespace from
- * things like j a v a s c r i p t
- *
- * @access public
- * @param type
- * @return type
- */
- function _compact_exploded_words($matches)
- {
- return preg_replace('/\s+/s', '', $matches[1]).$matches[2];
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Sanitize Naughty HTML
- *
- * Callback function for xss_clean() to remove naughty HTML elements
- *
- * @access private
- * @param array
- * @return string
- */
- function _sanitize_naughty_html($matches)
- {
- // encode opening brace
- $str = '&lt;'.$matches[1].$matches[2].$matches[3];
-
- // encode captured opening or closing brace to prevent recursive vectors
- $str .= str_replace(array('>', '<'), array('&gt;', '&lt;'), $matches[4]);
-
- return $str;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * JS Link Removal
- *
- * Callback function for xss_clean() to sanitize links
- * This limits the PCRE backtracks, making it more performance friendly
- * and prevents PREG_BACKTRACK_LIMIT_ERROR from being triggered in
- * PHP 5.2+ on link-heavy strings
- *
- * @access private
- * @param array
- * @return string
- */
- 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]);
- }
-
- /**
- * JS Image Removal
- *
- * Callback function for xss_clean() to sanitize image tags
- * This limits the PCRE backtracks, making it more performance friendly
- * and prevents PREG_BACKTRACK_LIMIT_ERROR from being triggered in
- * PHP 5.2+ on image tag heavy strings
- *
- * @access private
- * @param array
- * @return string
- */
- 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]);
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Attribute Conversion
- *
- * Used as a callback for XSS Clean
- *
- * @access public
- * @param array
- * @return string
- */
- function _convert_attribute($match)
- {
- return str_replace(array('>', '<'), array('&gt;', '&lt;'), $match[0]);
- }
-
- // --------------------------------------------------------------------
-
- /**
- * HTML Entity Decode Callback
- *
- * Used as a callback for XSS Clean
- *
- * @access public
- * @param array
- * @return string
- */
- function _html_entity_decode_callback($match)
- {
- $CFG =& load_class('Config');
- $charset = $CFG->item('charset');
-
- return $this->_html_entity_decode($match[0], strtoupper($charset));
- }
-
- // --------------------------------------------------------------------
-
- /**
- * HTML Entities Decode
- *
- * This function is a replacement for html_entity_decode()
- *
- * In some versions of PHP the native function does not work
- * when UTF-8 is the specified character set, so this gives us
- * a work-around. More info here:
- * http://bugs.php.net/bug.php?id=25670
- *
- * @access private
- * @param string
- * @param string
- * @return string
- */
- /* -------------------------------------------------
- /* Replacement for html_entity_decode()
- /* -------------------------------------------------*/
-
- /*
- NOTE: html_entity_decode() has a bug in some PHP versions when UTF-8 is the
- character set, and the PHP developers said they were not back porting the
- fix to versions other than PHP 5.x.
- */
- function _html_entity_decode($str, $charset='UTF-8')
- {
- if (stristr($str, '&') === FALSE) return $str;
-
- // The reason we are not using html_entity_decode() by itself is because
- // while it is not technically correct to leave out the semicolon
- // at the end of an entity most browsers will still interpret the entity
- // correctly. html_entity_decode() does not convert entities without
- // semicolons, so we are left with our own little solution here. Bummer.
-
- if (function_exists('html_entity_decode') && (strtolower($charset) != 'utf-8' OR version_compare(phpversion(), '5.0.0', '>=')))
- {
- $str = html_entity_decode($str, ENT_COMPAT, $charset);
- $str = preg_replace('~&#x(0*[0-9a-f]{2,5})~ei', 'chr(hexdec("\\1"))', $str);
- return preg_replace('~&#([0-9]{2,4})~e', 'chr(\\1)', $str);
- }
-
- // Numeric Entities
- $str = preg_replace('~&#x(0*[0-9a-f]{2,5});{0,1}~ei', 'chr(hexdec("\\1"))', $str);
- $str = preg_replace('~&#([0-9]{2,4});{0,1}~e', 'chr(\\1)', $str);
-
- // Literal Entities - Slightly slow so we do another check
- if (stristr($str, '&') === FALSE)
- {
- $str = strtr($str, array_flip(get_html_translation_table(HTML_ENTITIES)));
- }
-
- return $str;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Filter Attributes
- *
- * Filters tag attributes for consistency and safety
- *
- * @access public
- * @param string
- * @return string
- */
- function _filter_attributes($str)
- {
- $out = '';
-
- if (preg_match_all('#\s*[a-z\-]+\s*=\s*(\042|\047)([^\\1]*?)\\1#is', $str, $matches))
- {
- foreach ($matches[0] as $match)
- {
- $out .= "{$match}";
- }
- }
-
- return $out;
- }
-
- // --------------------------------------------------------------------
-
-}
-// END Input class
-
-/* End of file Input.php */
+<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+/**
+ * CodeIgniter
+ *
+ * An open source application development framework for PHP 4.3.2 or newer
+ *
+ * @package CodeIgniter
+ * @author ExpressionEngine Dev Team
+ * @copyright Copyright (c) 2008, EllisLab, Inc.
+ * @license http://codeigniter.com/user_guide/license.html
+ * @link http://codeigniter.com
+ * @since Version 1.0
+ * @filesource
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+ * Input Class
+ *
+ * Pre-processes global input data for security
+ *
+ * @package CodeIgniter
+ * @subpackage Libraries
+ * @category Input
+ * @author ExpressionEngine Dev Team
+ * @link http://codeigniter.com/user_guide/libraries/input.html
+ */
+class CI_Input {
+ var $use_xss_clean = FALSE;
+ var $xss_hash = '';
+ var $ip_address = FALSE;
+ var $user_agent = FALSE;
+ var $allow_get_array = FALSE;
+
+ /* never allowed, string replacement */
+ var $never_allowed_str = array(
+ 'document.cookie' => '[removed]',
+ 'document.write' => '[removed]',
+ '.parentNode' => '[removed]',
+ '.innerHTML' => '[removed]',
+ 'window.location' => '[removed]',
+ '-moz-binding' => '[removed]',
+ '<!--' => '&lt;!--',
+ '-->' => '--&gt;',
+ '<![CDATA[' => '&lt;![CDATA['
+ );
+ /* never allowed, regex replacement */
+ var $never_allowed_regex = array(
+ "javascript\s*:" => '[removed]',
+ "expression\s*\(" => '[removed]', // CSS and IE
+ "Redirect\s+302" => '[removed]'
+ );
+
+ /**
+ * Constructor
+ *
+ * Sets whether to globally enable the XSS processing
+ * and whether to allow the $_GET array
+ *
+ * @access public
+ */
+ function CI_Input()
+ {
+ log_message('debug', "Input Class Initialized");
+
+ $CFG =& load_class('Config');
+ $this->use_xss_clean = ($CFG->item('global_xss_filtering') === TRUE) ? TRUE : FALSE;
+ $this->allow_get_array = ($CFG->item('enable_query_strings') === TRUE) ? TRUE : FALSE;
+ $this->_sanitize_globals();
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Sanitize Globals
+ *
+ * This function does the following:
+ *
+ * Unsets $_GET data (if query strings are not enabled)
+ *
+ * Unsets all globals if register_globals is enabled
+ *
+ * Standardizes newline characters to \n
+ *
+ * @access private
+ * @return void
+ */
+ function _sanitize_globals()
+ {
+ // Would kind of be "wrong" to unset any of these GLOBALS
+ $protected = array('_SERVER', '_GET', '_POST', '_FILES', '_REQUEST', '_SESSION', '_ENV', 'GLOBALS', 'HTTP_RAW_POST_DATA',
+ 'system_folder', 'application_folder', 'BM', 'EXT', 'CFG', 'URI', 'RTR', 'OUT', 'IN');
+
+ // Unset globals for security.
+ // This is effectively the same as register_globals = off
+ foreach (array($_GET, $_POST, $_COOKIE, $_SERVER, $_FILES, $_ENV, (isset($_SESSION) && is_array($_SESSION)) ? $_SESSION : array()) as $global)
+ {
+ if ( ! is_array($global))
+ {
+ if ( ! in_array($global, $protected))
+ {
+ unset($GLOBALS[$global]);
+ }
+ }
+ else
+ {
+ foreach ($global as $key => $val)
+ {
+ if ( ! in_array($key, $protected))
+ {
+ unset($GLOBALS[$key]);
+ }
+
+ if (is_array($val))
+ {
+ foreach($val as $k => $v)
+ {
+ if ( ! in_array($k, $protected))
+ {
+ unset($GLOBALS[$k]);
+ }
+ }
+ }
+ }
+ }
+ }
+
+ // Is $_GET data allowed? If not we'll set the $_GET to an empty array
+ if ($this->allow_get_array == FALSE)
+ {
+ $_GET = array();
+ }
+ else
+ {
+ $_GET = $this->_clean_input_data($_GET);
+ }
+
+ // Clean $_POST Data
+ $_POST = $this->_clean_input_data($_POST);
+
+ // Clean $_COOKIE Data
+ // Also get rid of specially treated cookies that might be set by a server
+ // or silly application, that are of no use to a CI application anyway
+ // but that when present will trip our 'Disallowed Key Characters' alarm
+ // http://www.ietf.org/rfc/rfc2109.txt
+ // note that the key names below are single quoted strings, and are not PHP variables
+ unset($_COOKIE['$Version']);
+ unset($_COOKIE['$Path']);
+ unset($_COOKIE['$Domain']);
+ $_COOKIE = $this->_clean_input_data($_COOKIE);
+
+ log_message('debug', "Global POST and COOKIE data sanitized");
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Clean Input Data
+ *
+ * This is a helper function. It escapes data and
+ * standardizes newline characters to \n
+ *
+ * @access private
+ * @param string
+ * @return string
+ */
+ function _clean_input_data($str)
+ {
+ if (is_array($str))
+ {
+ $new_array = array();
+ foreach ($str as $key => $val)
+ {
+ $new_array[$this->_clean_input_keys($key)] = $this->_clean_input_data($val);
+ }
+ return $new_array;
+ }
+
+ // We strip slashes if magic quotes is on to keep things consistent
+ if (get_magic_quotes_gpc())
+ {
+ $str = stripslashes($str);
+ }
+
+ // Should we filter the input data?
+ if ($this->use_xss_clean === TRUE)
+ {
+ $str = $this->xss_clean($str);
+ }
+
+ // Standardize newlines
+ if (strpos($str, "\r") !== FALSE)
+ {
+ $str = str_replace(array("\r\n", "\r"), "\n", $str);
+ }
+
+ return $str;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Clean Keys
+ *
+ * This is a helper function. To prevent malicious users
+ * from trying to exploit keys we make sure that keys are
+ * only named with alpha-numeric text and a few other items.
+ *
+ * @access private
+ * @param string
+ * @return string
+ */
+ function _clean_input_keys($str)
+ {
+ if ( ! preg_match("/^[a-z0-9:_\/-]+$/i", $str))
+ {
+ exit('Disallowed Key Characters.');
+ }
+
+ return $str;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Fetch from array
+ *
+ * This is a helper function to retrieve values from global arrays
+ *
+ * @access private
+ * @param array
+ * @param string
+ * @param bool
+ * @return string
+ */
+ function _fetch_from_array(&$array, $index = '', $xss_clean = FALSE)
+ {
+ if ( ! isset($array[$index]))
+ {
+ return FALSE;
+ }
+
+ if ($xss_clean === TRUE)
+ {
+ return $this->xss_clean($array[$index]);
+ }
+
+ return $array[$index];
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Fetch an item from the GET array
+ *
+ * @access public
+ * @param string
+ * @param bool
+ * @return string
+ */
+ function get($index = '', $xss_clean = FALSE)
+ {
+ return $this->_fetch_from_array($_GET, $index, $xss_clean);
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Fetch an item from the POST array
+ *
+ * @access public
+ * @param string
+ * @param bool
+ * @return string
+ */
+ function post($index = '', $xss_clean = FALSE)
+ {
+ return $this->_fetch_from_array($_POST, $index, $xss_clean);
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Fetch an item from either the GET array or the POST
+ *
+ * @access public
+ * @param string The index key
+ * @param bool XSS cleaning
+ * @return string
+ */
+ function get_post($index = '', $xss_clean = FALSE)
+ {
+ if ( ! isset($_POST[$index]) )
+ {
+ return $this->get($index, $xss_clean);
+ }
+ else
+ {
+ return $this->post($index, $xss_clean);
+ }
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Fetch an item from the COOKIE array
+ *
+ * @access public
+ * @param string
+ * @param bool
+ * @return string
+ */
+ function cookie($index = '', $xss_clean = FALSE)
+ {
+ return $this->_fetch_from_array($_COOKIE, $index, $xss_clean);
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Fetch an item from the SERVER array
+ *
+ * @access public
+ * @param string
+ * @param bool
+ * @return string
+ */
+ function server($index = '', $xss_clean = FALSE)
+ {
+ return $this->_fetch_from_array($_SERVER, $index, $xss_clean);
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Fetch the IP Address
+ *
+ * @access public
+ * @return string
+ */
+ function ip_address()
+ {
+ if ($this->ip_address !== FALSE)
+ {
+ return $this->ip_address;
+ }
+
+ if ($this->server('REMOTE_ADDR') AND $this->server('HTTP_CLIENT_IP'))
+ {
+ $this->ip_address = $_SERVER['HTTP_CLIENT_IP'];
+ }
+ elseif ($this->server('REMOTE_ADDR'))
+ {
+ $this->ip_address = $_SERVER['REMOTE_ADDR'];
+ }
+ elseif ($this->server('HTTP_CLIENT_IP'))
+ {
+ $this->ip_address = $_SERVER['HTTP_CLIENT_IP'];
+ }
+ elseif ($this->server('HTTP_X_FORWARDED_FOR'))
+ {
+ $this->ip_address = $_SERVER['HTTP_X_FORWARDED_FOR'];
+ }
+
+ if ($this->ip_address === FALSE)
+ {
+ $this->ip_address = '0.0.0.0';
+ return $this->ip_address;
+ }
+
+ if (strstr($this->ip_address, ','))
+ {
+ $x = explode(',', $this->ip_address);
+ $this->ip_address = end($x);
+ }
+
+ if ( ! $this->valid_ip($this->ip_address))
+ {
+ $this->ip_address = '0.0.0.0';
+ }
+
+ return $this->ip_address;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Validate IP Address
+ *
+ * Updated version suggested by Geert De Deckere
+ *
+ * @access public
+ * @param string
+ * @return string
+ */
+ function valid_ip($ip)
+ {
+ $ip_segments = explode('.', $ip);
+
+ // Always 4 segments needed
+ if (count($ip_segments) != 4)
+ {
+ return FALSE;
+ }
+ // IP can not start with 0
+ if ($ip_segments[0][0] == '0')
+ {
+ return FALSE;
+ }
+ // Check each segment
+ foreach ($ip_segments as $segment)
+ {
+ // IP segments must be digits and can not be
+ // longer than 3 digits or greater then 255
+ if ($segment == '' OR preg_match("/[^0-9]/", $segment) OR $segment > 255 OR strlen($segment) > 3)
+ {
+ return FALSE;
+ }
+ }
+
+ return TRUE;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * User Agent
+ *
+ * @access public
+ * @return string
+ */
+ function user_agent()
+ {
+ if ($this->user_agent !== FALSE)
+ {
+ return $this->user_agent;
+ }
+
+ $this->user_agent = ( ! isset($_SERVER['HTTP_USER_AGENT'])) ? FALSE : $_SERVER['HTTP_USER_AGENT'];
+
+ return $this->user_agent;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Filename Security
+ *
+ * @access public
+ * @param string
+ * @return string
+ */
+ function filename_security($str)
+ {
+ $bad = array(
+ "../",
+ "./",
+ "<!--",
+ "-->",
+ "<",
+ ">",
+ "'",
+ '"',
+ '&',
+ '$',
+ '#',
+ '{',
+ '}',
+ '[',
+ ']',
+ '=',
+ ';',
+ '?',
+ "%20",
+ "%22",
+ "%3c", // <
+ "%253c", // <
+ "%3e", // >
+ "%0e", // >
+ "%28", // (
+ "%29", // )
+ "%2528", // (
+ "%26", // &
+ "%24", // $
+ "%3f", // ?
+ "%3b", // ;
+ "%3d" // =
+ );
+
+ return stripslashes(str_replace($bad, '', $str));
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * XSS Clean
+ *
+ * Sanitizes data so that Cross Site Scripting Hacks can be
+ * prevented. This function does a fair amount of work but
+ * it is extremely thorough, designed to prevent even the
+ * most obscure XSS attempts. Nothing is ever 100% foolproof,
+ * of course, but I haven't been able to get anything passed
+ * the filter.
+ *
+ * Note: This function should only be used to deal with data
+ * upon submission. It's not something that should
+ * be used for general runtime processing.
+ *
+ * This function was based in part on some code and ideas I
+ * got from Bitflux: http://blog.bitflux.ch/wiki/XSS_Prevention
+ *
+ * To help develop this script I used this great list of
+ * vulnerabilities along with a few other hacks I've
+ * harvested from examining vulnerabilities in other programs:
+ * http://ha.ckers.org/xss.html
+ *
+ * @access public
+ * @param string
+ * @return string
+ */
+ function xss_clean($str, $is_image = FALSE)
+ {
+ /*
+ * Is the string an array?
+ *
+ */
+ if (is_array($str))
+ {
+ while (list($key) = each($str))
+ {
+ $str[$key] = $this->xss_clean($str[$key]);
+ }
+
+ return $str;
+ }
+
+ /*
+ * Remove Invisible Characters
+ */
+ $str = $this->_remove_invisible_characters($str);
+
+ /*
+ * Protect GET variables in URLs
+ */
+
+ // 901119URL5918AMP18930PROTECT8198
+
+ $str = preg_replace('|\&([a-z\_0-9]+)\=([a-z\_0-9]+)|i', $this->xss_hash()."\\1=\\2", $str);
+
+ /*
+ * Validate standard character entities
+ *
+ * Add a semicolon if missing. We do this to enable
+ * the conversion of entities to ASCII later.
+ *
+ */
+ $str = preg_replace('#(&\#?[0-9a-z]{2,})[\x00-\x20]*;?#i', "\\1;", $str);
+
+ /*
+ * Validate UTF16 two byte encoding (x00)
+ *
+ * Just as above, adds a semicolon if missing.
+ *
+ */
+ $str = preg_replace('#(&\#x?)([0-9A-F]+);?#i',"\\1\\2;",$str);
+
+ /*
+ * Un-Protect GET variables in URLs
+ */
+ $str = str_replace($this->xss_hash(), '&', $str);
+
+ /*
+ * URL Decode
+ *
+ * Just in case stuff like this is submitted:
+ *
+ * <a href="http://%77%77%77%2E%67%6F%6F%67%6C%65%2E%63%6F%6D">Google</a>
+ *
+ * Note: Use rawurldecode() so it does not remove plus signs
+ *
+ */
+ $str = rawurldecode($str);
+
+ /*
+ * Convert character entities to ASCII
+ *
+ * This permits our tests below to work reliably.
+ * We only convert entities that are within tags since
+ * these are the ones that will pose security problems.
+ *
+ */
+
+ $str = preg_replace_callback("/[a-z]+=([\'\"]).*?\\1/si", array($this, '_convert_attribute'), $str);
+
+ $str = preg_replace_callback("/<\w+.*?(?=>|<|$)/si", array($this, '_html_entity_decode_callback'), $str);
+
+ /*
+ * Remove Invisible Characters Again!
+ */
+ $str = $this->_remove_invisible_characters($str);
+
+ /*
+ * Convert all tabs to spaces
+ *
+ * This prevents strings like this: ja vascript
+ * NOTE: we deal with spaces between characters later.
+ * NOTE: preg_replace was found to be amazingly slow here on large blocks of data,
+ * so we use str_replace.
+ *
+ */
+
+ if (strpos($str, "\t") !== FALSE)
+ {
+ $str = str_replace("\t", ' ', $str);
+ }
+
+ /*
+ * Capture converted string for later comparison
+ */
+ $converted_string = $str;
+
+ /*
+ * Not Allowed Under Any Conditions
+ */
+
+ foreach ($this->never_allowed_str as $key => $val)
+ {
+ $str = str_replace($key, $val, $str);
+ }
+
+ foreach ($this->never_allowed_regex as $key => $val)
+ {
+ $str = preg_replace("#".$key."#i", $val, $str);
+ }
+
+ /*
+ * Makes PHP tags safe
+ *
+ * Note: XML tags are inadvertently replaced too:
+ *
+ * <?xml
+ *
+ * But it doesn't seem to pose a problem.
+ *
+ */
+ if ($is_image === TRUE)
+ {
+ // Images have a tendency to have the PHP short opening and closing tags every so often
+ // so we skip those and only do the long opening tags.
+ $str = str_replace(array('<?php', '<?PHP'), array('&lt;?php', '&lt;?PHP'), $str);
+ }
+ else
+ {
+ $str = str_replace(array('<?php', '<?PHP', '<?', '?'.'>'), array('&lt;?php', '&lt;?PHP', '&lt;?', '?&gt;'), $str);
+ }
+
+ /*
+ * Compact any exploded words
+ *
+ * This corrects words like: j a v a s c r i p t
+ * These words are compacted back to their correct state.
+ *
+ */
+ $words = array('javascript', 'expression', 'vbscript', 'script', 'applet', 'alert', 'document', 'write', 'cookie', 'window');
+ foreach ($words as $word)
+ {
+ $temp = '';
+
+ for ($i = 0, $wordlen = strlen($word); $i < $wordlen; $i++)
+ {
+ $temp .= substr($word, $i, 1)."\s*";
+ }
+
+ // We only want to do this when it is followed by a non-word character
+ // That way valid stuff like "dealer to" does not become "dealerto"
+ $str = preg_replace_callback('#('.substr($temp, 0, -3).')(\W)#is', array($this, '_compact_exploded_words'), $str);
+ }
+
+ /*
+ * Remove disallowed Javascript in links or img tags
+ * We used to do some version comparisons and use of stripos for PHP5, but it is dog slow compared
+ * to these simplified non-capturing preg_match(), especially if the pattern exists in the string
+ */
+ do
+ {
+ $original = $str;
+
+ if (preg_match("/<a/i", $str))
+ {
+ $str = preg_replace_callback("#<a\s+([^>]*?)(>|$)#si", array($this, '_js_link_removal'), $str);
+ }
+
+ if (preg_match("/<img/i", $str))
+ {
+ $str = preg_replace_callback("#<img\s+([^>]*?)(\s?/?>|$)#si", array($this, '_js_img_removal'), $str);
+ }
+
+ if (preg_match("/script/i", $str) OR preg_match("/xss/i", $str))
+ {
+ $str = preg_replace("#<(/*)(script|xss)(.*?)\>#si", '[removed]', $str);
+ }
+ }
+ while($original != $str);
+
+ unset($original);
+
+ /*
+ * Remove JavaScript Event Handlers
+ *
+ * Note: This code is a little blunt. It removes
+ * the event handler and anything up to the closing >,
+ * but it's unlikely to be a problem.
+ *
+ */
+ $event_handlers = array('[^a-z_\-]on\w*','xmlns');
+
+ if ($is_image === TRUE)
+ {
+ /*
+ * Adobe Photoshop puts XML metadata into JFIF images, including namespacing,
+ * so we have to allow this for images. -Paul
+ */
+ unset($event_handlers[array_search('xmlns', $event_handlers)]);
+ }
+
+ $str = preg_replace("#<([^><]+?)(".implode('|', $event_handlers).")(\s*=\s*[^><]*)([><]*)#i", "<\\1\\4", $str);
+
+ /*
+ * Sanitize naughty HTML elements
+ *
+ * If a tag containing any of the words in the list
+ * below is found, the tag gets converted to entities.
+ *
+ * So this: <blink>
+ * Becomes: &lt;blink&gt;
+ *
+ */
+ $naughty = 'alert|applet|audio|basefont|base|behavior|bgsound|blink|body|embed|expression|form|frameset|frame|head|html|ilayer|iframe|input|isindex|layer|link|meta|object|plaintext|style|script|textarea|title|video|xml|xss';
+ $str = preg_replace_callback('#<(/*\s*)('.$naughty.')([^><]*)([><]*)#is', array($this, '_sanitize_naughty_html'), $str);
+
+ /*
+ * Sanitize naughty scripting elements
+ *
+ * Similar to above, only instead of looking for
+ * tags it looks for PHP and JavaScript commands
+ * that are disallowed. Rather than removing the
+ * code, it simply converts the parenthesis to entities
+ * rendering the code un-executable.
+ *
+ * For example: eval('some code')
+ * Becomes: eval&#40;'some code'&#41;
+ *
+ */
+ $str = preg_replace('#(alert|cmd|passthru|eval|exec|expression|system|fopen|fsockopen|file|file_get_contents|readfile|unlink)(\s*)\((.*?)\)#si', "\\1\\2&#40;\\3&#41;", $str);
+
+ /*
+ * Final clean up
+ *
+ * This adds a bit of extra precaution in case
+ * something got through the above filters
+ *
+ */
+ foreach ($this->never_allowed_str as $key => $val)
+ {
+ $str = str_replace($key, $val, $str);
+ }
+
+ foreach ($this->never_allowed_regex as $key => $val)
+ {
+ $str = preg_replace("#".$key."#i", $val, $str);
+ }
+
+ /*
+ * Images are Handled in a Special Way
+ * - Essentially, we want to know that after all of the character conversion is done whether
+ * any unwanted, likely XSS, code was found. If not, we return TRUE, as the image is clean.
+ * However, if the string post-conversion does not matched the string post-removal of XSS,
+ * then it fails, as there was unwanted XSS code found and removed/changed during processing.
+ */
+
+ if ($is_image === TRUE)
+ {
+ if ($str == $converted_string)
+ {
+ return TRUE;
+ }
+ else
+ {
+ return FALSE;
+ }
+ }
+
+ log_message('debug', "XSS Filtering completed");
+ return $str;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Random Hash for protecting URLs
+ *
+ * @access public
+ * @return string
+ */
+ function xss_hash()
+ {
+ if ($this->xss_hash == '')
+ {
+ if (phpversion() >= 4.2)
+ mt_srand();
+ else
+ mt_srand(hexdec(substr(md5(microtime()), -8)) & 0x7fffffff);
+
+ $this->xss_hash = md5(time() + mt_rand(0, 1999999999));
+ }
+
+ return $this->xss_hash;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Remove Invisible Characters
+ *
+ * This prevents sandwiching null characters
+ * between ascii characters, like Java\0script.
+ *
+ * @access public
+ * @param string
+ * @return string
+ */
+ function _remove_invisible_characters($str)
+ {
+ static $non_displayables;
+
+ if ( ! isset($non_displayables))
+ {
+ // every control character except newline (dec 10), carriage return (dec 13), and horizontal tab (dec 09),
+ $non_displayables = array(
+ '/%0[0-8bcef]/', // url encoded 00-08, 11, 12, 14, 15
+ '/%1[0-9a-f]/', // url encoded 16-31
+ '/[\x00-\x08]/', // 00-08
+ '/\x0b/', '/\x0c/', // 11, 12
+ '/[\x0e-\x1f]/' // 14-31
+ );
+ }
+
+ do
+ {
+ $cleaned = $str;
+ $str = preg_replace($non_displayables, '', $str);
+ }
+ while ($cleaned != $str);
+
+ return $str;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Compact Exploded Words
+ *
+ * Callback function for xss_clean() to remove whitespace from
+ * things like j a v a s c r i p t
+ *
+ * @access public
+ * @param type
+ * @return type
+ */
+ function _compact_exploded_words($matches)
+ {
+ return preg_replace('/\s+/s', '', $matches[1]).$matches[2];
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Sanitize Naughty HTML
+ *
+ * Callback function for xss_clean() to remove naughty HTML elements
+ *
+ * @access private
+ * @param array
+ * @return string
+ */
+ function _sanitize_naughty_html($matches)
+ {
+ // encode opening brace
+ $str = '&lt;'.$matches[1].$matches[2].$matches[3];
+
+ // encode captured opening or closing brace to prevent recursive vectors
+ $str .= str_replace(array('>', '<'), array('&gt;', '&lt;'), $matches[4]);
+
+ return $str;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * JS Link Removal
+ *
+ * Callback function for xss_clean() to sanitize links
+ * This limits the PCRE backtracks, making it more performance friendly
+ * and prevents PREG_BACKTRACK_LIMIT_ERROR from being triggered in
+ * PHP 5.2+ on link-heavy strings
+ *
+ * @access private
+ * @param array
+ * @return string
+ */
+ 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]);
+ }
+
+ /**
+ * JS Image Removal
+ *
+ * Callback function for xss_clean() to sanitize image tags
+ * This limits the PCRE backtracks, making it more performance friendly
+ * and prevents PREG_BACKTRACK_LIMIT_ERROR from being triggered in
+ * PHP 5.2+ on image tag heavy strings
+ *
+ * @access private
+ * @param array
+ * @return string
+ */
+ 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]);
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Attribute Conversion
+ *
+ * Used as a callback for XSS Clean
+ *
+ * @access public
+ * @param array
+ * @return string
+ */
+ function _convert_attribute($match)
+ {
+ return str_replace(array('>', '<'), array('&gt;', '&lt;'), $match[0]);
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * HTML Entity Decode Callback
+ *
+ * Used as a callback for XSS Clean
+ *
+ * @access public
+ * @param array
+ * @return string
+ */
+ function _html_entity_decode_callback($match)
+ {
+ $CFG =& load_class('Config');
+ $charset = $CFG->item('charset');
+
+ return $this->_html_entity_decode($match[0], strtoupper($charset));
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * HTML Entities Decode
+ *
+ * This function is a replacement for html_entity_decode()
+ *
+ * In some versions of PHP the native function does not work
+ * when UTF-8 is the specified character set, so this gives us
+ * a work-around. More info here:
+ * http://bugs.php.net/bug.php?id=25670
+ *
+ * @access private
+ * @param string
+ * @param string
+ * @return string
+ */
+ /* -------------------------------------------------
+ /* Replacement for html_entity_decode()
+ /* -------------------------------------------------*/
+
+ /*
+ NOTE: html_entity_decode() has a bug in some PHP versions when UTF-8 is the
+ character set, and the PHP developers said they were not back porting the
+ fix to versions other than PHP 5.x.
+ */
+ function _html_entity_decode($str, $charset='UTF-8')
+ {
+ if (stristr($str, '&') === FALSE) return $str;
+
+ // The reason we are not using html_entity_decode() by itself is because
+ // while it is not technically correct to leave out the semicolon
+ // at the end of an entity most browsers will still interpret the entity
+ // correctly. html_entity_decode() does not convert entities without
+ // semicolons, so we are left with our own little solution here. Bummer.
+
+ if (function_exists('html_entity_decode') && (strtolower($charset) != 'utf-8' OR version_compare(phpversion(), '5.0.0', '>=')))
+ {
+ $str = html_entity_decode($str, ENT_COMPAT, $charset);
+ $str = preg_replace('~&#x(0*[0-9a-f]{2,5})~ei', 'chr(hexdec("\\1"))', $str);
+ return preg_replace('~&#([0-9]{2,4})~e', 'chr(\\1)', $str);
+ }
+
+ // Numeric Entities
+ $str = preg_replace('~&#x(0*[0-9a-f]{2,5});{0,1}~ei', 'chr(hexdec("\\1"))', $str);
+ $str = preg_replace('~&#([0-9]{2,4});{0,1}~e', 'chr(\\1)', $str);
+
+ // Literal Entities - Slightly slow so we do another check
+ if (stristr($str, '&') === FALSE)
+ {
+ $str = strtr($str, array_flip(get_html_translation_table(HTML_ENTITIES)));
+ }
+
+ return $str;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Filter Attributes
+ *
+ * Filters tag attributes for consistency and safety
+ *
+ * @access public
+ * @param string
+ * @return string
+ */
+ function _filter_attributes($str)
+ {
+ $out = '';
+
+ if (preg_match_all('#\s*[a-z\-]+\s*=\s*(\042|\047)([^\\1]*?)\\1#is', $str, $matches))
+ {
+ foreach ($matches[0] as $match)
+ {
+ $out .= "{$match}";
+ }
+ }
+
+ return $out;
+ }
+
+ // --------------------------------------------------------------------
+
+}
+// END Input class
+
+/* End of file Input.php */
/* Location: ./system/libraries/Input.php */ \ No newline at end of file
diff --git a/system/libraries/Language.php b/system/libraries/Language.php
index 78f4143af..bc237e756 100644
--- a/system/libraries/Language.php
+++ b/system/libraries/Language.php
@@ -1,123 +1,123 @@
-<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
-/**
- * CodeIgniter
- *
- * An open source application development framework for PHP 4.3.2 or newer
- *
- * @package CodeIgniter
- * @author ExpressionEngine Dev Team
- * @copyright Copyright (c) 2008, EllisLab, Inc.
- * @license http://codeigniter.com/user_guide/license.html
- * @link http://codeigniter.com
- * @since Version 1.0
- * @filesource
- */
-
-// ------------------------------------------------------------------------
-
-/**
- * Language Class
- *
- * @package CodeIgniter
- * @subpackage Libraries
- * @category Language
- * @author ExpressionEngine Dev Team
- * @link http://codeigniter.com/user_guide/libraries/language.html
- */
-class CI_Language {
-
- var $language = array();
- var $is_loaded = array();
-
- /**
- * Constructor
- *
- * @access public
- */
- function CI_Language()
- {
- log_message('debug', "Language Class Initialized");
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Load a language file
- *
- * @access public
- * @param mixed the name of the language file to be loaded. Can be an array
- * @param string the language (english, etc.)
- * @return mixed
- */
- function load($langfile = '', $idiom = '', $return = FALSE)
- {
- $langfile = str_replace(EXT, '', str_replace('_lang.', '', $langfile)).'_lang'.EXT;
-
- if (in_array($langfile, $this->is_loaded, TRUE))
- {
- return;
- }
-
- if ($idiom == '')
- {
- $CI =& get_instance();
- $deft_lang = $CI->config->item('language');
- $idiom = ($deft_lang == '') ? 'english' : $deft_lang;
- }
-
- // Determine where the language file is and load it
- if (file_exists(APPPATH.'language/'.$idiom.'/'.$langfile))
- {
- include(APPPATH.'language/'.$idiom.'/'.$langfile);
- }
- else
- {
- if (file_exists(BASEPATH.'language/'.$idiom.'/'.$langfile))
- {
- include(BASEPATH.'language/'.$idiom.'/'.$langfile);
- }
- else
- {
- show_error('Unable to load the requested language file: language/'.$langfile);
- }
- }
-
- if ( ! isset($lang))
- {
- log_message('error', 'Language file contains no data: language/'.$idiom.'/'.$langfile);
- return;
- }
-
- if ($return == TRUE)
- {
- return $lang;
- }
-
- $this->is_loaded[] = $langfile;
- $this->language = array_merge($this->language, $lang);
- unset($lang);
-
- log_message('debug', 'Language file loaded: language/'.$idiom.'/'.$langfile);
- return TRUE;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Fetch a single line of text from the language array
- *
- * @access public
- * @param string $line the language line
- * @return string
- */
- function line($line = '')
- {
- $line = ($line == '' OR ! isset($this->language[$line])) ? FALSE : $this->language[$line];
- return $line;
- }
-
-}
-// END Language Class
-
-/* End of file Language.php */
+<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+/**
+ * CodeIgniter
+ *
+ * An open source application development framework for PHP 4.3.2 or newer
+ *
+ * @package CodeIgniter
+ * @author ExpressionEngine Dev Team
+ * @copyright Copyright (c) 2008, EllisLab, Inc.
+ * @license http://codeigniter.com/user_guide/license.html
+ * @link http://codeigniter.com
+ * @since Version 1.0
+ * @filesource
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+ * Language Class
+ *
+ * @package CodeIgniter
+ * @subpackage Libraries
+ * @category Language
+ * @author ExpressionEngine Dev Team
+ * @link http://codeigniter.com/user_guide/libraries/language.html
+ */
+class CI_Language {
+
+ var $language = array();
+ var $is_loaded = array();
+
+ /**
+ * Constructor
+ *
+ * @access public
+ */
+ function CI_Language()
+ {
+ log_message('debug', "Language Class Initialized");
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Load a language file
+ *
+ * @access public
+ * @param mixed the name of the language file to be loaded. Can be an array
+ * @param string the language (english, etc.)
+ * @return mixed
+ */
+ function load($langfile = '', $idiom = '', $return = FALSE)
+ {
+ $langfile = str_replace(EXT, '', str_replace('_lang.', '', $langfile)).'_lang'.EXT;
+
+ if (in_array($langfile, $this->is_loaded, TRUE))
+ {
+ return;
+ }
+
+ if ($idiom == '')
+ {
+ $CI =& get_instance();
+ $deft_lang = $CI->config->item('language');
+ $idiom = ($deft_lang == '') ? 'english' : $deft_lang;
+ }
+
+ // Determine where the language file is and load it
+ if (file_exists(APPPATH.'language/'.$idiom.'/'.$langfile))
+ {
+ include(APPPATH.'language/'.$idiom.'/'.$langfile);
+ }
+ else
+ {
+ if (file_exists(BASEPATH.'language/'.$idiom.'/'.$langfile))
+ {
+ include(BASEPATH.'language/'.$idiom.'/'.$langfile);
+ }
+ else
+ {
+ show_error('Unable to load the requested language file: language/'.$langfile);
+ }
+ }
+
+ if ( ! isset($lang))
+ {
+ log_message('error', 'Language file contains no data: language/'.$idiom.'/'.$langfile);
+ return;
+ }
+
+ if ($return == TRUE)
+ {
+ return $lang;
+ }
+
+ $this->is_loaded[] = $langfile;
+ $this->language = array_merge($this->language, $lang);
+ unset($lang);
+
+ log_message('debug', 'Language file loaded: language/'.$idiom.'/'.$langfile);
+ return TRUE;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Fetch a single line of text from the language array
+ *
+ * @access public
+ * @param string $line the language line
+ * @return string
+ */
+ function line($line = '')
+ {
+ $line = ($line == '' OR ! isset($this->language[$line])) ? FALSE : $this->language[$line];
+ return $line;
+ }
+
+}
+// END Language Class
+
+/* End of file Language.php */
/* Location: ./system/libraries/Language.php */ \ No newline at end of file
diff --git a/system/libraries/Session.php b/system/libraries/Session.php
index 660ce8f16..25bf21fb1 100644
--- a/system/libraries/Session.php
+++ b/system/libraries/Session.php
@@ -1,758 +1,758 @@
-<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
-/**
- * CodeIgniter
- *
- * An open source application development framework for PHP 4.3.2 or newer
- *
- * @package CodeIgniter
- * @author ExpressionEngine Dev Team
- * @copyright Copyright (c) 2008, EllisLab, Inc.
- * @license http://codeigniter.com/user_guide/license.html
- * @link http://codeigniter.com
- * @since Version 1.0
- * @filesource
- */
-
-// ------------------------------------------------------------------------
-
-/**
- * Session Class
- *
- * @package CodeIgniter
- * @subpackage Libraries
- * @category Sessions
- * @author ExpressionEngine Dev Team
- * @link http://codeigniter.com/user_guide/libraries/sessions.html
- */
-class CI_Session {
-
- var $sess_encrypt_cookie = FALSE;
- var $sess_use_database = FALSE;
- var $sess_table_name = '';
- var $sess_expiration = 7200;
- var $sess_match_ip = FALSE;
- var $sess_match_useragent = TRUE;
- var $sess_cookie_name = 'ci_session';
- var $cookie_prefix = '';
- var $cookie_path = '';
- var $cookie_domain = '';
- var $sess_time_to_update = 300;
- var $encryption_key = '';
- var $flashdata_key = 'flash';
- var $time_reference = 'time';
- var $gc_probability = 5;
- var $userdata = array();
- var $CI;
- var $now;
-
- /**
- * Session Constructor
- *
- * The constructor runs the session routines automatically
- * whenever the class is instantiated.
- */
- function CI_Session($params = array())
- {
- log_message('debug', "Session Class Initialized");
-
- // Set the super object to a local variable for use throughout the class
- $this->CI =& get_instance();
-
- // Set all the session preferences, which can either be set
- // manually via the $params array above or via the config file
- foreach (array('sess_encrypt_cookie', 'sess_use_database', 'sess_table_name', 'sess_expiration', 'sess_match_ip', 'sess_match_useragent', 'sess_cookie_name', 'cookie_path', 'cookie_domain', 'sess_time_to_update', 'time_reference', 'cookie_prefix', 'encryption_key') as $key)
- {
- $this->$key = (isset($params[$key])) ? $params[$key] : $this->CI->config->item($key);
- }
-
- // Load the string helper so we can use the strip_slashes() function
- $this->CI->load->helper('string');
-
- // Do we need encryption? If so, load the encryption class
- if ($this->sess_encrypt_cookie == TRUE)
- {
- $this->CI->load->library('encrypt');
- }
-
- // Are we using a database? If so, load it
- if ($this->sess_use_database === TRUE AND $this->sess_table_name != '')
- {
- $this->CI->load->database();
- }
-
- // Set the "now" time. Can either be GMT or server time, based on the
- // config prefs. We use this to set the "last activity" time
- $this->now = $this->_get_time();
-
- // Set the session length. If the session expiration is
- // set to zero we'll set the expiration two years from now.
- if ($this->sess_expiration == 0)
- {
- $this->sess_expiration = (60*60*24*365*2);
- }
-
- // Set the cookie name
- $this->sess_cookie_name = $this->cookie_prefix.$this->sess_cookie_name;
-
- // Run the Session routine. If a session doesn't exist we'll
- // create a new one. If it does, we'll update it.
- if ( ! $this->sess_read())
- {
- $this->sess_create();
- }
- else
- {
- $this->sess_update();
- }
-
- // Delete 'old' flashdata (from last request)
- $this->_flashdata_sweep();
-
- // Mark all new flashdata as old (data will be deleted before next request)
- $this->_flashdata_mark();
-
- // Delete expired sessions if necessary
- $this->_sess_gc();
-
- log_message('debug', "Session routines successfully run");
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Fetch the current session data if it exists
- *
- * @access public
- * @return bool
- */
- function sess_read()
- {
- // Fetch the cookie
- $session = $this->CI->input->cookie($this->sess_cookie_name);
-
- // No cookie? Goodbye cruel world!...
- if ($session === FALSE)
- {
- log_message('debug', 'A session cookie was not found.');
- return FALSE;
- }
-
- // Decrypt the cookie data
- if ($this->sess_encrypt_cookie == TRUE)
- {
- $session = $this->CI->encrypt->decode($session);
- }
- else
- {
- // encryption was not used, so we need to check the md5 hash
- $hash = substr($session, strlen($session)-32); // get last 32 chars
- $session = substr($session, 0, strlen($session)-32);
-
- // Does the md5 hash match? This is to prevent manipulation of session data in userspace
- if ($hash !== md5($session.$this->encryption_key))
- {
- log_message('error', 'The session cookie data did not match what was expected. This could be a possible hacking attempt.');
- $this->sess_destroy();
- return FALSE;
- }
- }
-
- // Unserialize the session array
- $session = $this->_unserialize($session);
-
- // Is the session data we unserialized an array with the correct format?
- if ( ! is_array($session) OR ! isset($session['session_id']) OR ! isset($session['ip_address']) OR ! isset($session['user_agent']) OR ! isset($session['last_activity']))
- {
- $this->sess_destroy();
- return FALSE;
- }
-
- // Is the session current?
- if (($session['last_activity'] + $this->sess_expiration) < $this->now)
- {
- $this->sess_destroy();
- return FALSE;
- }
-
- // Does the IP Match?
- if ($this->sess_match_ip == TRUE AND $session['ip_address'] != $this->CI->input->ip_address())
- {
- $this->sess_destroy();
- return FALSE;
- }
-
- // Does the User Agent Match?
- if ($this->sess_match_useragent == TRUE AND trim($session['user_agent']) != trim(substr($this->CI->input->user_agent(), 0, 50)))
- {
- $this->sess_destroy();
- return FALSE;
- }
-
- // Is there a corresponding session in the DB?
- if ($this->sess_use_database === TRUE)
- {
- $this->CI->db->where('session_id', $session['session_id']);
-
- if ($this->sess_match_ip == TRUE)
- {
- $this->CI->db->where('ip_address', $session['ip_address']);
- }
-
- if ($this->sess_match_useragent == TRUE)
- {
- $this->CI->db->where('user_agent', $session['user_agent']);
- }
-
- $query = $this->CI->db->get($this->sess_table_name);
-
- // No result? Kill it!
- if ($query->num_rows() == 0)
- {
- $this->sess_destroy();
- return FALSE;
- }
-
- // Is there custom data? If so, add it to the main session array
- $row = $query->row();
- if (isset($row->user_data) AND $row->user_data != '')
- {
- $custom_data = $this->_unserialize($row->user_data);
-
- if (is_array($custom_data))
- {
- foreach ($custom_data as $key => $val)
- {
- $session[$key] = $val;
- }
- }
- }
- }
-
- // Session is valid!
- $this->userdata = $session;
- unset($session);
-
- return TRUE;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Write the session data
- *
- * @access public
- * @return void
- */
- function sess_write()
- {
- // Are we saving custom data to the DB? If not, all we do is update the cookie
- if ($this->sess_use_database === FALSE)
- {
- $this->_set_cookie();
- return;
- }
-
- // set the custom userdata, the session data we will set in a second
- $custom_userdata = $this->userdata;
- $cookie_userdata = array();
-
- // Before continuing, we need to determine if there is any custom data to deal with.
- // Let's determine this by removing the default indexes to see if there's anything left in the array
- // and set the session data while we're at it
- foreach (array('session_id','ip_address','user_agent','last_activity') as $val)
- {
- unset($custom_userdata[$val]);
- $cookie_userdata[$val] = $this->userdata[$val];
- }
-
- // Did we find any custom data? If not, we turn the empty array into a string
- // since there's no reason to serialize and store an empty array in the DB
- if (count($custom_userdata) === 0)
- {
- $custom_userdata = '';
- }
- else
- {
- // Serialize the custom data array so we can store it
- $custom_userdata = $this->_serialize($custom_userdata);
- }
-
- // Run the update query
- $this->CI->db->where('session_id', $this->userdata['session_id']);
- $this->CI->db->update($this->sess_table_name, array('last_activity' => $this->userdata['last_activity'], 'user_data' => $custom_userdata));
-
- // Write the cookie. Notice that we manually pass the cookie data array to the
- // _set_cookie() function. Normally that function will store $this->userdata, but
- // in this case that array contains custom data, which we do not want in the cookie.
- $this->_set_cookie($cookie_userdata);
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Create a new session
- *
- * @access public
- * @return void
- */
- function sess_create()
- {
- $sessid = '';
- while (strlen($sessid) < 32)
- {
- $sessid .= mt_rand(0, mt_getrandmax());
- }
-
- // To make the session ID even more secure we'll combine it with the user's IP
- $sessid .= $this->CI->input->ip_address();
-
- $this->userdata = array(
- 'session_id' => md5(uniqid($sessid, TRUE)),
- 'ip_address' => $this->CI->input->ip_address(),
- 'user_agent' => substr($this->CI->input->user_agent(), 0, 50),
- 'last_activity' => $this->now
- );
-
-
- // Save the data to the DB if needed
- if ($this->sess_use_database === TRUE)
- {
- $this->CI->db->query($this->CI->db->insert_string($this->sess_table_name, $this->userdata));
- }
-
- // Write the cookie
- $this->_set_cookie();
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Update an existing session
- *
- * @access public
- * @return void
- */
- function sess_update()
- {
- // We only update the session every five minutes by default
- if (($this->userdata['last_activity'] + $this->sess_time_to_update) >= $this->now)
- {
- return;
- }
-
- // Save the old session id so we know which record to
- // update in the database if we need it
- $old_sessid = $this->userdata['session_id'];
- $new_sessid = '';
- while (strlen($new_sessid) < 32)
- {
- $new_sessid .= mt_rand(0, mt_getrandmax());
- }
-
- // To make the session ID even more secure we'll combine it with the user's IP
- $new_sessid .= $this->CI->input->ip_address();
-
- // Turn it into a hash
- $new_sessid = md5(uniqid($new_sessid, TRUE));
-
- // Update the session data in the session data array
- $this->userdata['session_id'] = $new_sessid;
- $this->userdata['last_activity'] = $this->now;
-
- // _set_cookie() will handle this for us if we aren't using database sessions
- // by pushing all userdata to the cookie.
- $cookie_data = NULL;
-
- // Update the session ID and last_activity field in the DB if needed
- if ($this->sess_use_database === TRUE)
- {
- // set cookie explicitly to only have our session data
- $cookie_data = array();
- foreach (array('session_id','ip_address','user_agent','last_activity') as $val)
- {
- $cookie_data[$val] = $this->userdata[$val];
- }
-
- $this->CI->db->query($this->CI->db->update_string($this->sess_table_name, array('last_activity' => $this->now, 'session_id' => $new_sessid), array('session_id' => $old_sessid)));
- }
-
- // Write the cookie
- $this->_set_cookie($cookie_data);
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Destroy the current session
- *
- * @access public
- * @return void
- */
- function sess_destroy()
- {
- // Kill the session DB row
- if ($this->sess_use_database === TRUE AND isset($this->userdata['session_id']))
- {
- $this->CI->db->where('session_id', $this->userdata['session_id']);
- $this->CI->db->delete($this->sess_table_name);
- }
-
- // Kill the cookie
- setcookie(
- $this->sess_cookie_name,
- addslashes(serialize(array())),
- ($this->now - 31500000),
- $this->cookie_path,
- $this->cookie_domain,
- 0
- );
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Fetch a specific item from the session array
- *
- * @access public
- * @param string
- * @return string
- */
- function userdata($item)
- {
- return ( ! isset($this->userdata[$item])) ? FALSE : $this->userdata[$item];
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Fetch all session data
- *
- * @access public
- * @return mixed
- */
- function all_userdata()
- {
- return ( ! isset($this->userdata)) ? FALSE : $this->userdata;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Add or change data in the "userdata" array
- *
- * @access public
- * @param mixed
- * @param string
- * @return void
- */
- function set_userdata($newdata = array(), $newval = '')
- {
- if (is_string($newdata))
- {
- $newdata = array($newdata => $newval);
- }
-
- if (count($newdata) > 0)
- {
- foreach ($newdata as $key => $val)
- {
- $this->userdata[$key] = $val;
- }
- }
-
- $this->sess_write();
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Delete a session variable from the "userdata" array
- *
- * @access array
- * @return void
- */
- function unset_userdata($newdata = array())
- {
- if (is_string($newdata))
- {
- $newdata = array($newdata => '');
- }
-
- if (count($newdata) > 0)
- {
- foreach ($newdata as $key => $val)
- {
- unset($this->userdata[$key]);
- }
- }
-
- $this->sess_write();
- }
-
- // ------------------------------------------------------------------------
-
- /**
- * Add or change flashdata, only available
- * until the next request
- *
- * @access public
- * @param mixed
- * @param string
- * @return void
- */
- function set_flashdata($newdata = array(), $newval = '')
- {
- if (is_string($newdata))
- {
- $newdata = array($newdata => $newval);
- }
-
- if (count($newdata) > 0)
- {
- foreach ($newdata as $key => $val)
- {
- $flashdata_key = $this->flashdata_key.':new:'.$key;
- $this->set_userdata($flashdata_key, $val);
- }
- }
- }
-
- // ------------------------------------------------------------------------
-
- /**
- * Keeps existing flashdata available to next request.
- *
- * @access public
- * @param string
- * @return void
- */
- function keep_flashdata($key)
- {
- // 'old' flashdata gets removed. Here we mark all
- // flashdata as 'new' to preserve it from _flashdata_sweep()
- // Note the function will return FALSE if the $key
- // provided cannot be found
- $old_flashdata_key = $this->flashdata_key.':old:'.$key;
- $value = $this->userdata($old_flashdata_key);
-
- $new_flashdata_key = $this->flashdata_key.':new:'.$key;
- $this->set_userdata($new_flashdata_key, $value);
- }
-
- // ------------------------------------------------------------------------
-
- /**
- * Fetch a specific flashdata item from the session array
- *
- * @access public
- * @param string
- * @return string
- */
- function flashdata($key)
- {
- $flashdata_key = $this->flashdata_key.':old:'.$key;
- return $this->userdata($flashdata_key);
- }
-
- // ------------------------------------------------------------------------
-
- /**
- * Identifies flashdata as 'old' for removal
- * when _flashdata_sweep() runs.
- *
- * @access private
- * @return void
- */
- function _flashdata_mark()
- {
- $userdata = $this->all_userdata();
- foreach ($userdata as $name => $value)
- {
- $parts = explode(':new:', $name);
- if (is_array($parts) && count($parts) === 2)
- {
- $new_name = $this->flashdata_key.':old:'.$parts[1];
- $this->set_userdata($new_name, $value);
- $this->unset_userdata($name);
- }
- }
- }
-
- // ------------------------------------------------------------------------
-
- /**
- * Removes all flashdata marked as 'old'
- *
- * @access private
- * @return void
- */
-
- function _flashdata_sweep()
- {
- $userdata = $this->all_userdata();
- foreach ($userdata as $key => $value)
- {
- if (strpos($key, ':old:'))
- {
- $this->unset_userdata($key);
- }
- }
-
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Get the "now" time
- *
- * @access private
- * @return string
- */
- function _get_time()
- {
- if (strtolower($this->time_reference) == 'gmt')
- {
- $now = time();
- $time = mktime(gmdate("H", $now), gmdate("i", $now), gmdate("s", $now), gmdate("m", $now), gmdate("d", $now), gmdate("Y", $now));
- }
- else
- {
- $time = time();
- }
-
- return $time;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Write the session cookie
- *
- * @access public
- * @return void
- */
- function _set_cookie($cookie_data = NULL)
- {
- if (is_null($cookie_data))
- {
- $cookie_data = $this->userdata;
- }
-
- // Serialize the userdata for the cookie
- $cookie_data = $this->_serialize($cookie_data);
-
- if ($this->sess_encrypt_cookie == TRUE)
- {
- $cookie_data = $this->CI->encrypt->encode($cookie_data);
- }
- else
- {
- // if encryption is not used, we provide an md5 hash to prevent userside tampering
- $cookie_data = $cookie_data.md5($cookie_data.$this->encryption_key);
- }
-
- // Set the cookie
- setcookie(
- $this->sess_cookie_name,
- $cookie_data,
- $this->sess_expiration + time(),
- $this->cookie_path,
- $this->cookie_domain,
- 0
- );
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Serialize an array
- *
- * This function first converts any slashes found in the array to a temporary
- * marker, so when it gets unserialized the slashes will be preserved
- *
- * @access private
- * @param array
- * @return string
- */
- function _serialize($data)
- {
- if (is_array($data))
- {
- foreach ($data as $key => $val)
- {
- $data[$key] = str_replace('\\', '{{slash}}', $val);
- }
- }
- else
- {
- $data = str_replace('\\', '{{slash}}', $data);
- }
-
- return serialize($data);
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Unserialize
- *
- * This function unserializes a data string, then converts any
- * temporary slash markers back to actual slashes
- *
- * @access private
- * @param array
- * @return string
- */
- function _unserialize($data)
- {
- $data = @unserialize(strip_slashes($data));
-
- if (is_array($data))
- {
- foreach ($data as $key => $val)
- {
- $data[$key] = str_replace('{{slash}}', '\\', $val);
- }
-
- return $data;
- }
-
- return str_replace('{{slash}}', '\\', $data);
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Garbage collection
- *
- * This deletes expired session rows from database
- * if the probability percentage is met
- *
- * @access public
- * @return void
- */
- function _sess_gc()
- {
- if ($this->sess_use_database != TRUE)
- {
- return;
- }
-
- srand(time());
- if ((rand() % 100) < $this->gc_probability)
- {
- $expire = $this->now - $this->sess_expiration;
-
- $this->CI->db->where("last_activity < {$expire}");
- $this->CI->db->delete($this->sess_table_name);
-
- log_message('debug', 'Session garbage collection performed.');
- }
- }
-
-
-}
-// END Session Class
-
-/* End of file Session.php */
+<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+/**
+ * CodeIgniter
+ *
+ * An open source application development framework for PHP 4.3.2 or newer
+ *
+ * @package CodeIgniter
+ * @author ExpressionEngine Dev Team
+ * @copyright Copyright (c) 2008, EllisLab, Inc.
+ * @license http://codeigniter.com/user_guide/license.html
+ * @link http://codeigniter.com
+ * @since Version 1.0
+ * @filesource
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+ * Session Class
+ *
+ * @package CodeIgniter
+ * @subpackage Libraries
+ * @category Sessions
+ * @author ExpressionEngine Dev Team
+ * @link http://codeigniter.com/user_guide/libraries/sessions.html
+ */
+class CI_Session {
+
+ var $sess_encrypt_cookie = FALSE;
+ var $sess_use_database = FALSE;
+ var $sess_table_name = '';
+ var $sess_expiration = 7200;
+ var $sess_match_ip = FALSE;
+ var $sess_match_useragent = TRUE;
+ var $sess_cookie_name = 'ci_session';
+ var $cookie_prefix = '';
+ var $cookie_path = '';
+ var $cookie_domain = '';
+ var $sess_time_to_update = 300;
+ var $encryption_key = '';
+ var $flashdata_key = 'flash';
+ var $time_reference = 'time';
+ var $gc_probability = 5;
+ var $userdata = array();
+ var $CI;
+ var $now;
+
+ /**
+ * Session Constructor
+ *
+ * The constructor runs the session routines automatically
+ * whenever the class is instantiated.
+ */
+ function CI_Session($params = array())
+ {
+ log_message('debug', "Session Class Initialized");
+
+ // Set the super object to a local variable for use throughout the class
+ $this->CI =& get_instance();
+
+ // Set all the session preferences, which can either be set
+ // manually via the $params array above or via the config file
+ foreach (array('sess_encrypt_cookie', 'sess_use_database', 'sess_table_name', 'sess_expiration', 'sess_match_ip', 'sess_match_useragent', 'sess_cookie_name', 'cookie_path', 'cookie_domain', 'sess_time_to_update', 'time_reference', 'cookie_prefix', 'encryption_key') as $key)
+ {
+ $this->$key = (isset($params[$key])) ? $params[$key] : $this->CI->config->item($key);
+ }
+
+ // Load the string helper so we can use the strip_slashes() function
+ $this->CI->load->helper('string');
+
+ // Do we need encryption? If so, load the encryption class
+ if ($this->sess_encrypt_cookie == TRUE)
+ {
+ $this->CI->load->library('encrypt');
+ }
+
+ // Are we using a database? If so, load it
+ if ($this->sess_use_database === TRUE AND $this->sess_table_name != '')
+ {
+ $this->CI->load->database();
+ }
+
+ // Set the "now" time. Can either be GMT or server time, based on the
+ // config prefs. We use this to set the "last activity" time
+ $this->now = $this->_get_time();
+
+ // Set the session length. If the session expiration is
+ // set to zero we'll set the expiration two years from now.
+ if ($this->sess_expiration == 0)
+ {
+ $this->sess_expiration = (60*60*24*365*2);
+ }
+
+ // Set the cookie name
+ $this->sess_cookie_name = $this->cookie_prefix.$this->sess_cookie_name;
+
+ // Run the Session routine. If a session doesn't exist we'll
+ // create a new one. If it does, we'll update it.
+ if ( ! $this->sess_read())
+ {
+ $this->sess_create();
+ }
+ else
+ {
+ $this->sess_update();
+ }
+
+ // Delete 'old' flashdata (from last request)
+ $this->_flashdata_sweep();
+
+ // Mark all new flashdata as old (data will be deleted before next request)
+ $this->_flashdata_mark();
+
+ // Delete expired sessions if necessary
+ $this->_sess_gc();
+
+ log_message('debug', "Session routines successfully run");
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Fetch the current session data if it exists
+ *
+ * @access public
+ * @return bool
+ */
+ function sess_read()
+ {
+ // Fetch the cookie
+ $session = $this->CI->input->cookie($this->sess_cookie_name);
+
+ // No cookie? Goodbye cruel world!...
+ if ($session === FALSE)
+ {
+ log_message('debug', 'A session cookie was not found.');
+ return FALSE;
+ }
+
+ // Decrypt the cookie data
+ if ($this->sess_encrypt_cookie == TRUE)
+ {
+ $session = $this->CI->encrypt->decode($session);
+ }
+ else
+ {
+ // encryption was not used, so we need to check the md5 hash
+ $hash = substr($session, strlen($session)-32); // get last 32 chars
+ $session = substr($session, 0, strlen($session)-32);
+
+ // Does the md5 hash match? This is to prevent manipulation of session data in userspace
+ if ($hash !== md5($session.$this->encryption_key))
+ {
+ log_message('error', 'The session cookie data did not match what was expected. This could be a possible hacking attempt.');
+ $this->sess_destroy();
+ return FALSE;
+ }
+ }
+
+ // Unserialize the session array
+ $session = $this->_unserialize($session);
+
+ // Is the session data we unserialized an array with the correct format?
+ if ( ! is_array($session) OR ! isset($session['session_id']) OR ! isset($session['ip_address']) OR ! isset($session['user_agent']) OR ! isset($session['last_activity']))
+ {
+ $this->sess_destroy();
+ return FALSE;
+ }
+
+ // Is the session current?
+ if (($session['last_activity'] + $this->sess_expiration) < $this->now)
+ {
+ $this->sess_destroy();
+ return FALSE;
+ }
+
+ // Does the IP Match?
+ if ($this->sess_match_ip == TRUE AND $session['ip_address'] != $this->CI->input->ip_address())
+ {
+ $this->sess_destroy();
+ return FALSE;
+ }
+
+ // Does the User Agent Match?
+ if ($this->sess_match_useragent == TRUE AND trim($session['user_agent']) != trim(substr($this->CI->input->user_agent(), 0, 50)))
+ {
+ $this->sess_destroy();
+ return FALSE;
+ }
+
+ // Is there a corresponding session in the DB?
+ if ($this->sess_use_database === TRUE)
+ {
+ $this->CI->db->where('session_id', $session['session_id']);
+
+ if ($this->sess_match_ip == TRUE)
+ {
+ $this->CI->db->where('ip_address', $session['ip_address']);
+ }
+
+ if ($this->sess_match_useragent == TRUE)
+ {
+ $this->CI->db->where('user_agent', $session['user_agent']);
+ }
+
+ $query = $this->CI->db->get($this->sess_table_name);
+
+ // No result? Kill it!
+ if ($query->num_rows() == 0)
+ {
+ $this->sess_destroy();
+ return FALSE;
+ }
+
+ // Is there custom data? If so, add it to the main session array
+ $row = $query->row();
+ if (isset($row->user_data) AND $row->user_data != '')
+ {
+ $custom_data = $this->_unserialize($row->user_data);
+
+ if (is_array($custom_data))
+ {
+ foreach ($custom_data as $key => $val)
+ {
+ $session[$key] = $val;
+ }
+ }
+ }
+ }
+
+ // Session is valid!
+ $this->userdata = $session;
+ unset($session);
+
+ return TRUE;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Write the session data
+ *
+ * @access public
+ * @return void
+ */
+ function sess_write()
+ {
+ // Are we saving custom data to the DB? If not, all we do is update the cookie
+ if ($this->sess_use_database === FALSE)
+ {
+ $this->_set_cookie();
+ return;
+ }
+
+ // set the custom userdata, the session data we will set in a second
+ $custom_userdata = $this->userdata;
+ $cookie_userdata = array();
+
+ // Before continuing, we need to determine if there is any custom data to deal with.
+ // Let's determine this by removing the default indexes to see if there's anything left in the array
+ // and set the session data while we're at it
+ foreach (array('session_id','ip_address','user_agent','last_activity') as $val)
+ {
+ unset($custom_userdata[$val]);
+ $cookie_userdata[$val] = $this->userdata[$val];
+ }
+
+ // Did we find any custom data? If not, we turn the empty array into a string
+ // since there's no reason to serialize and store an empty array in the DB
+ if (count($custom_userdata) === 0)
+ {
+ $custom_userdata = '';
+ }
+ else
+ {
+ // Serialize the custom data array so we can store it
+ $custom_userdata = $this->_serialize($custom_userdata);
+ }
+
+ // Run the update query
+ $this->CI->db->where('session_id', $this->userdata['session_id']);
+ $this->CI->db->update($this->sess_table_name, array('last_activity' => $this->userdata['last_activity'], 'user_data' => $custom_userdata));
+
+ // Write the cookie. Notice that we manually pass the cookie data array to the
+ // _set_cookie() function. Normally that function will store $this->userdata, but
+ // in this case that array contains custom data, which we do not want in the cookie.
+ $this->_set_cookie($cookie_userdata);
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Create a new session
+ *
+ * @access public
+ * @return void
+ */
+ function sess_create()
+ {
+ $sessid = '';
+ while (strlen($sessid) < 32)
+ {
+ $sessid .= mt_rand(0, mt_getrandmax());
+ }
+
+ // To make the session ID even more secure we'll combine it with the user's IP
+ $sessid .= $this->CI->input->ip_address();
+
+ $this->userdata = array(
+ 'session_id' => md5(uniqid($sessid, TRUE)),
+ 'ip_address' => $this->CI->input->ip_address(),
+ 'user_agent' => substr($this->CI->input->user_agent(), 0, 50),
+ 'last_activity' => $this->now
+ );
+
+
+ // Save the data to the DB if needed
+ if ($this->sess_use_database === TRUE)
+ {
+ $this->CI->db->query($this->CI->db->insert_string($this->sess_table_name, $this->userdata));
+ }
+
+ // Write the cookie
+ $this->_set_cookie();
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Update an existing session
+ *
+ * @access public
+ * @return void
+ */
+ function sess_update()
+ {
+ // We only update the session every five minutes by default
+ if (($this->userdata['last_activity'] + $this->sess_time_to_update) >= $this->now)
+ {
+ return;
+ }
+
+ // Save the old session id so we know which record to
+ // update in the database if we need it
+ $old_sessid = $this->userdata['session_id'];
+ $new_sessid = '';
+ while (strlen($new_sessid) < 32)
+ {
+ $new_sessid .= mt_rand(0, mt_getrandmax());
+ }
+
+ // To make the session ID even more secure we'll combine it with the user's IP
+ $new_sessid .= $this->CI->input->ip_address();
+
+ // Turn it into a hash
+ $new_sessid = md5(uniqid($new_sessid, TRUE));
+
+ // Update the session data in the session data array
+ $this->userdata['session_id'] = $new_sessid;
+ $this->userdata['last_activity'] = $this->now;
+
+ // _set_cookie() will handle this for us if we aren't using database sessions
+ // by pushing all userdata to the cookie.
+ $cookie_data = NULL;
+
+ // Update the session ID and last_activity field in the DB if needed
+ if ($this->sess_use_database === TRUE)
+ {
+ // set cookie explicitly to only have our session data
+ $cookie_data = array();
+ foreach (array('session_id','ip_address','user_agent','last_activity') as $val)
+ {
+ $cookie_data[$val] = $this->userdata[$val];
+ }
+
+ $this->CI->db->query($this->CI->db->update_string($this->sess_table_name, array('last_activity' => $this->now, 'session_id' => $new_sessid), array('session_id' => $old_sessid)));
+ }
+
+ // Write the cookie
+ $this->_set_cookie($cookie_data);
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Destroy the current session
+ *
+ * @access public
+ * @return void
+ */
+ function sess_destroy()
+ {
+ // Kill the session DB row
+ if ($this->sess_use_database === TRUE AND isset($this->userdata['session_id']))
+ {
+ $this->CI->db->where('session_id', $this->userdata['session_id']);
+ $this->CI->db->delete($this->sess_table_name);
+ }
+
+ // Kill the cookie
+ setcookie(
+ $this->sess_cookie_name,
+ addslashes(serialize(array())),
+ ($this->now - 31500000),
+ $this->cookie_path,
+ $this->cookie_domain,
+ 0
+ );
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Fetch a specific item from the session array
+ *
+ * @access public
+ * @param string
+ * @return string
+ */
+ function userdata($item)
+ {
+ return ( ! isset($this->userdata[$item])) ? FALSE : $this->userdata[$item];
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Fetch all session data
+ *
+ * @access public
+ * @return mixed
+ */
+ function all_userdata()
+ {
+ return ( ! isset($this->userdata)) ? FALSE : $this->userdata;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Add or change data in the "userdata" array
+ *
+ * @access public
+ * @param mixed
+ * @param string
+ * @return void
+ */
+ function set_userdata($newdata = array(), $newval = '')
+ {
+ if (is_string($newdata))
+ {
+ $newdata = array($newdata => $newval);
+ }
+
+ if (count($newdata) > 0)
+ {
+ foreach ($newdata as $key => $val)
+ {
+ $this->userdata[$key] = $val;
+ }
+ }
+
+ $this->sess_write();
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Delete a session variable from the "userdata" array
+ *
+ * @access array
+ * @return void
+ */
+ function unset_userdata($newdata = array())
+ {
+ if (is_string($newdata))
+ {
+ $newdata = array($newdata => '');
+ }
+
+ if (count($newdata) > 0)
+ {
+ foreach ($newdata as $key => $val)
+ {
+ unset($this->userdata[$key]);
+ }
+ }
+
+ $this->sess_write();
+ }
+
+ // ------------------------------------------------------------------------
+
+ /**
+ * Add or change flashdata, only available
+ * until the next request
+ *
+ * @access public
+ * @param mixed
+ * @param string
+ * @return void
+ */
+ function set_flashdata($newdata = array(), $newval = '')
+ {
+ if (is_string($newdata))
+ {
+ $newdata = array($newdata => $newval);
+ }
+
+ if (count($newdata) > 0)
+ {
+ foreach ($newdata as $key => $val)
+ {
+ $flashdata_key = $this->flashdata_key.':new:'.$key;
+ $this->set_userdata($flashdata_key, $val);
+ }
+ }
+ }
+
+ // ------------------------------------------------------------------------
+
+ /**
+ * Keeps existing flashdata available to next request.
+ *
+ * @access public
+ * @param string
+ * @return void
+ */
+ function keep_flashdata($key)
+ {
+ // 'old' flashdata gets removed. Here we mark all
+ // flashdata as 'new' to preserve it from _flashdata_sweep()
+ // Note the function will return FALSE if the $key
+ // provided cannot be found
+ $old_flashdata_key = $this->flashdata_key.':old:'.$key;
+ $value = $this->userdata($old_flashdata_key);
+
+ $new_flashdata_key = $this->flashdata_key.':new:'.$key;
+ $this->set_userdata($new_flashdata_key, $value);
+ }
+
+ // ------------------------------------------------------------------------
+
+ /**
+ * Fetch a specific flashdata item from the session array
+ *
+ * @access public
+ * @param string
+ * @return string
+ */
+ function flashdata($key)
+ {
+ $flashdata_key = $this->flashdata_key.':old:'.$key;
+ return $this->userdata($flashdata_key);
+ }
+
+ // ------------------------------------------------------------------------
+
+ /**
+ * Identifies flashdata as 'old' for removal
+ * when _flashdata_sweep() runs.
+ *
+ * @access private
+ * @return void
+ */
+ function _flashdata_mark()
+ {
+ $userdata = $this->all_userdata();
+ foreach ($userdata as $name => $value)
+ {
+ $parts = explode(':new:', $name);
+ if (is_array($parts) && count($parts) === 2)
+ {
+ $new_name = $this->flashdata_key.':old:'.$parts[1];
+ $this->set_userdata($new_name, $value);
+ $this->unset_userdata($name);
+ }
+ }
+ }
+
+ // ------------------------------------------------------------------------
+
+ /**
+ * Removes all flashdata marked as 'old'
+ *
+ * @access private
+ * @return void
+ */
+
+ function _flashdata_sweep()
+ {
+ $userdata = $this->all_userdata();
+ foreach ($userdata as $key => $value)
+ {
+ if (strpos($key, ':old:'))
+ {
+ $this->unset_userdata($key);
+ }
+ }
+
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Get the "now" time
+ *
+ * @access private
+ * @return string
+ */
+ function _get_time()
+ {
+ if (strtolower($this->time_reference) == 'gmt')
+ {
+ $now = time();
+ $time = mktime(gmdate("H", $now), gmdate("i", $now), gmdate("s", $now), gmdate("m", $now), gmdate("d", $now), gmdate("Y", $now));
+ }
+ else
+ {
+ $time = time();
+ }
+
+ return $time;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Write the session cookie
+ *
+ * @access public
+ * @return void
+ */
+ function _set_cookie($cookie_data = NULL)
+ {
+ if (is_null($cookie_data))
+ {
+ $cookie_data = $this->userdata;
+ }
+
+ // Serialize the userdata for the cookie
+ $cookie_data = $this->_serialize($cookie_data);
+
+ if ($this->sess_encrypt_cookie == TRUE)
+ {
+ $cookie_data = $this->CI->encrypt->encode($cookie_data);
+ }
+ else
+ {
+ // if encryption is not used, we provide an md5 hash to prevent userside tampering
+ $cookie_data = $cookie_data.md5($cookie_data.$this->encryption_key);
+ }
+
+ // Set the cookie
+ setcookie(
+ $this->sess_cookie_name,
+ $cookie_data,
+ $this->sess_expiration + time(),
+ $this->cookie_path,
+ $this->cookie_domain,
+ 0
+ );
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Serialize an array
+ *
+ * This function first converts any slashes found in the array to a temporary
+ * marker, so when it gets unserialized the slashes will be preserved
+ *
+ * @access private
+ * @param array
+ * @return string
+ */
+ function _serialize($data)
+ {
+ if (is_array($data))
+ {
+ foreach ($data as $key => $val)
+ {
+ $data[$key] = str_replace('\\', '{{slash}}', $val);
+ }
+ }
+ else
+ {
+ $data = str_replace('\\', '{{slash}}', $data);
+ }
+
+ return serialize($data);
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Unserialize
+ *
+ * This function unserializes a data string, then converts any
+ * temporary slash markers back to actual slashes
+ *
+ * @access private
+ * @param array
+ * @return string
+ */
+ function _unserialize($data)
+ {
+ $data = @unserialize(strip_slashes($data));
+
+ if (is_array($data))
+ {
+ foreach ($data as $key => $val)
+ {
+ $data[$key] = str_replace('{{slash}}', '\\', $val);
+ }
+
+ return $data;
+ }
+
+ return str_replace('{{slash}}', '\\', $data);
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Garbage collection
+ *
+ * This deletes expired session rows from database
+ * if the probability percentage is met
+ *
+ * @access public
+ * @return void
+ */
+ function _sess_gc()
+ {
+ if ($this->sess_use_database != TRUE)
+ {
+ return;
+ }
+
+ srand(time());
+ if ((rand() % 100) < $this->gc_probability)
+ {
+ $expire = $this->now - $this->sess_expiration;
+
+ $this->CI->db->where("last_activity < {$expire}");
+ $this->CI->db->delete($this->sess_table_name);
+
+ log_message('debug', 'Session garbage collection performed.');
+ }
+ }
+
+
+}
+// END Session Class
+
+/* End of file Session.php */
/* Location: ./system/libraries/Session.php */ \ No newline at end of file
diff --git a/system/libraries/Typography.php b/system/libraries/Typography.php
index 6a0f2ec33..3ff0d2f58 100644
--- a/system/libraries/Typography.php
+++ b/system/libraries/Typography.php
@@ -1,386 +1,385 @@
-<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
-/**
- * CodeIgniter
- *
- * An open source application development framework for PHP 4.3.2 or newer
- *
- * @package CodeIgniter
- * @author ExpressionEngine Dev Team
- * @copyright Copyright (c) 2008, EllisLab, Inc.
- * @license http://codeigniter.com/user_guide/license.html
- * @link http://codeigniter.com
- * @since Version 1.0
- * @filesource
- */
-
-// ------------------------------------------------------------------------
-
-/**
- * Typography Class
- *
- *
- * @access private
- * @category Helpers
- * @author ExpressionEngine Dev Team
- * @link http://codeigniter.com/user_guide/helpers/
- */
-class CI_Typography {
-
- // Block level elements that should not be wrapped inside <p> tags
- var $block_elements = 'address|blockquote|div|dl|fieldset|form|h\d|hr|noscript|object|ol|p|pre|script|table|ul';
-
- // Elements that should not have <p> and <br /> tags within them.
- var $skip_elements = 'p|pre|ol|ul|dl|object|table';
-
- // Tags we want the parser to completely ignore when splitting the string.
- var $inline_elements = 'a|abbr|acronym|b|bdo|big|br|button|cite|code|del|dfn|em|i|img|ins|input|label|map|kbd|q|samp|select|small|span|strong|sub|sup|textarea|tt|var';
-
- // whether or not to protect quotes within { curly braces }
- var $protect_braced_quotes = FALSE;
-
- /**
- * Nothing to do here...
- *
- */
- function CI_Typography()
- {
- }
-
- /**
- * Auto Typography
- *
- * This function converts text, making it typographically correct:
- * - Converts double spaces into paragraphs.
- * - Converts single line breaks into <br /> tags
- * - Converts single and double quotes into correctly facing curly quote entities.
- * - Converts three dots into ellipsis.
- * - Converts double dashes into em-dashes.
- * - Converts two spaces into entities
- *
- * @access public
- * @param string
- * @param bool whether to reduce more then two consecutive newlines to two
- * @return string
- */
- function auto_typography($str, $reduce_linebreaks = FALSE)
- {
- if ($str == '')
- {
- return '';
- }
-
- // Standardize Newlines to make matching easier
- if (strpos($str, "\r") !== FALSE)
- {
- $str = str_replace(array("\r\n", "\r"), "\n", $str);
- }
-
- // Reduce line breaks. If there are more than two consecutive linebreaks
- // we'll compress them down to a maximum of two since there's no benefit to more.
- if ($reduce_linebreaks === TRUE)
- {
- $str = preg_replace("/\n\n+/", "\n\n", $str);
- }
-
- // Convert quotes within tags to temporary markers. We don't want quotes converted
- // within tags so we'll temporarily convert them to {@DQ} and {@SQ}
- // and we don't want double dashes converted to emdash entities, so they are marked with {@DD}
- // likewise double spaces are converted to {@NBS} to prevent entity conversion
- if (preg_match_all("#\<.+?>#si", $str, $matches))
- {
- for ($i = 0, $total = count($matches[0]); $i < $total; $i++)
- {
- $str = str_replace($matches[0][$i],
- str_replace(array("'",'"','--',' '), array('{@SQ}', '{@DQ}', '{@DD}', '{@NBS}'), $matches[0][$i]),
- $str);
- }
- }
-
- if ($this->protect_braced_quotes === TRUE)
- {
- if (preg_match_all("#\{.+?}#si", $str, $matches))
- {
- for ($i = 0, $total = count($matches[0]); $i < $total; $i++)
- {
- $str = str_replace($matches[0][$i],
- str_replace(array("'",'"'), array('{@SQ}', '{@DQ}'), $matches[0][$i]),
- $str);
- }
- }
- }
-
- // Convert "ignore" tags to temporary marker. The parser splits out the string at every tag
- // it encounters. Certain inline tags, like image tags, links, span tags, etc. will be
- // adversely affected if they are split out so we'll convert the opening bracket < temporarily to: {@TAG}
- $str = preg_replace("#<(/*)(".$this->inline_elements.")([ >])#i", "{@TAG}\\1\\2\\3", $str);
-
- // Split the string at every tag. This expression creates an array with this prototype:
- //
- // [array]
- // {
- // [0] = <opening tag>
- // [1] = Content...
- // [2] = <closing tag>
- // Etc...
- // }
- $chunks = preg_split('/(<(?:[^<>]+(?:"[^"]*"|\'[^\']*\')?)+>)/', $str, -1, PREG_SPLIT_DELIM_CAPTURE|PREG_SPLIT_NO_EMPTY);
-
- // Build our finalized string. We cycle through the array, skipping tags, and processing the contained text
- $str = '';
- $process = TRUE;
- $paragraph = FALSE;
- foreach ($chunks as $chunk)
- {
- // Are we dealing with a tag? If so, we'll skip the processing for this cycle.
- // Well also set the "process" flag which allows us to skip <pre> tags and a few other things.
- if (preg_match("#<(/*)(".$this->block_elements.").*?\>#", $chunk, $match))
- {
- if (preg_match("#".$this->skip_elements."#", $match[2]))
- {
- $process = ($match[1] == '/') ? TRUE : FALSE;
- }
-
- $str .= $chunk;
- continue;
- }
- elseif (preg_match('/<(\/?)([a-z]*).*?>/s', $chunk, $tagmatch))
- {
- if ($tagmatch[1] == '/' && $tagmatch[2] == $this->last_tag)
- {
- $process = FALSE;
- }
- else
- {
- $process = TRUE;
- $this->last_tag = $tagmatch[2];
- }
- }
-
- if ($process == FALSE)
- {
- $str .= $chunk;
- continue;
- }
-
- // Convert Newlines into <p> and <br /> tags
- $str .= $this->format_characters($this->_format_newlines($chunk));
- }
-
- // is the whole of the content inside a block level element?
- if ( ! preg_match("/^<(?:".$this->block_elements.")/i", $str, $match))
- {
- $str = "<p>{$str}</p>";
- }
-
-
- // some special linebreak cleanup
- $str = preg_replace_callback('#<(?!/|'.$this->block_elements.')([^>]*)><p>(.*?)</p><(\w*)#si', array($this, '_linebreak_cleanup'), $str);
-
- // and cleanup empty paragraph tags sitting between two closing tags
- $str = preg_replace('#(</\w+>)<p>(\s*)</p>(</\w+>)#si', '$1$2$3', $str);
-
- // Final clean up
- $table = array(
-
- // If the user submitted their own paragraph tags within the text
- // we will retain them instead of using our tags.
- '/(<p[^>*?]>)<p>/' => '$1', // <?php BBEdit syntax coloring bug fix
-
- // Reduce multiple instances of opening/closing paragraph tags to a single one
- '#(</p>)+#' => '</p>',
- '/(<p><p>)+/' => '<p>',
- '/(<p>\W+<p>)+/' => '<p>',
-
- // Clean up stray paragraph tags that appear before block level elements
- '#<p></p><('.$this->block_elements.')#' => '<$1',
-
- // Clean up open paragraph tags that appear before block level elements
- '#<p>(\W)<('.$this->block_elements.')#' => '<p></p>$1<$2',
-
- // Clean up stray non-breaking spaces preceeding block elements
- '#[&nbsp; ]+<('.$this->block_elements.')#' => ' <$1',
-
- // Replace the temporary markers we added earlier
- '/\{@TAG\}/' => '<',
- '/\{@DQ\}/' => '"',
- '/\{@SQ\}/' => "'",
- '/\{@DD\}/' => '--',
- '/\{@NBS\}/' => ' '
-
- );
-
- // Do we need to reduce empty lines?
- if ($reduce_linebreaks === TRUE)
- {
- $table['#<p>\n*</p>#'] = '';
- }
- else
- {
- // If we have empty paragraph tags we add a non-breaking space
- // otherwise most browsers won't treat them as true paragraphs
- $table['#<p></p>#'] = '<p>&nbsp;</p>';
- }
-
- return preg_replace(array_keys($table), $table, $str);
-
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Linebreak Cleanup
- *
- * Removes paragraph and line break tags inserted inbetween
- * inline content and a new opening block level element
- *
- * @access private
- * @param array
- * @return string
- */
- function _linebreak_cleanup($match)
- {
- if (in_array($match[3], explode('|', $this->block_elements)))
- {
- return "<{$match[1]}>".str_replace('<br />', '', $match[2])."<{$match[3]}";
- }
- else
- {
- return $match[0];
- }
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Format Characters
- *
- * This function mainly converts double and single quotes
- * to curly entities, but it also converts em-dashes,
- * double spaces, and ampersands
- *
- * @access public
- * @param string
- * @return string
- */
- function format_characters($str)
- {
- static $table;
-
- if ( ! isset($table))
- {
- $table = array(
- // nested smart quotes, opening and closing
- // note that rules for grammar (English) allow only for two levels deep
- // and that single quotes are _supposed_ to always be on the outside
- // but we'll accommodate both
- '/(^|\W|\s)\'"/' => '$1&#8216;&#8220;',
- '/\'"(\s|\W|$)/' => '&#8217;&#8221;$1',
- '/(^|\W|\s)"\'/' => '$1&#8220;&#8216;',
- '/"\'(\s|\W|$)/' => '&#8221;&#8217;$1',
-
- // single quote smart quotes
- '/\'(\s|\W|$)/' => '&#8217;$1',
- '/(^|\W|\s)\'/' => '$1&#8216;',
-
- // double quote smart quotes
- '/"(\s|\W|$)/' => '&#8221;$1',
- '/(^|\W|\s)"/' => '$1&#8220;',
-
- // apostrophes
- "/(\w)'(\w)/" => '$1&#8217;$2',
-
- // Em dash and ellipses dots
- '/\s?\-\-\s?/' => '&#8212;',
- '/(\w)\.{3}/' => '$1&#8230;',
-
- // double space after sentences
- '/(\W) /' => '$1&nbsp; ',
-
- // ampersands, if not a character entity
- '/&(?!#?[a-zA-Z0-9]{2,};)/' => '&amp;'
- );
- }
-
- return preg_replace(array_keys($table), $table, $str);
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Format Newlines
- *
- * Converts newline characters into either <p> tags or <br />
- *
- * @access public
- * @param string
- * @return string
- */
- function _format_newlines($str)
- {
- if ($str == '')
- {
- return $str;
- }
-
- if (strpos($str, "\n") === FALSE)
- {
- return $str;
- }
-
- // Convert two consecutive newlines to paragraphs
- $str = str_replace("\n\n", "</p>\n\n<p>", $str);
-
- // Convert single spaces to <br /> tags
- $str = preg_replace("/([^\n])(\n)([^\n])/", "\\1<br />\\2\\3", $str);
-
- // Wrap the whole enchilada in enclosing paragraphs
- if ($str != "\n")
- {
- $str = '<p>'.$str.'</p>';
- }
-
- // Remove empty paragraphs if they are on the first line, as this
- // is a potential unintended consequence of the previous code
- $str = preg_replace("/<p><\/p>(.*)/", "\\1", $str, 1);
-
- return $str;
- }
-
- // ------------------------------------------------------------------------
-
- /**
- * Convert newlines to HTML line breaks except within PRE tags
- *
- * @access public
- * @param string
- * @return string
- */
- function nl2br_except_pre($str)
- {
- $ex = explode("pre>",$str);
- $ct = count($ex);
-
- $newstr = "";
- for ($i = 0; $i < $ct; $i++)
- {
- if (($i % 2) == 0)
- {
- $newstr .= nl2br($ex[$i]);
- }
- else
- {
- $newstr .= $ex[$i];
- }
-
- if ($ct - 1 != $i)
- $newstr .= "pre>";
- }
-
- return $newstr;
- }
-
-}
-// END Typography Class
-
-/* End of file Typography.php */
+<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+/**
+ * CodeIgniter
+ *
+ * An open source application development framework for PHP 4.3.2 or newer
+ *
+ * @package CodeIgniter
+ * @author ExpressionEngine Dev Team
+ * @copyright Copyright (c) 2008, EllisLab, Inc.
+ * @license http://codeigniter.com/user_guide/license.html
+ * @link http://codeigniter.com
+ * @since Version 1.0
+ * @filesource
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+ * Typography Class
+ *
+ *
+ * @access private
+ * @category Helpers
+ * @author ExpressionEngine Dev Team
+ * @link http://codeigniter.com/user_guide/helpers/
+ */
+class CI_Typography {
+
+ // Block level elements that should not be wrapped inside <p> tags
+ var $block_elements = 'address|blockquote|div|dl|fieldset|form|h\d|hr|noscript|object|ol|p|pre|script|table|ul';
+
+ // Elements that should not have <p> and <br /> tags within them.
+ var $skip_elements = 'p|pre|ol|ul|dl|object|table';
+
+ // Tags we want the parser to completely ignore when splitting the string.
+ var $inline_elements = 'a|abbr|acronym|b|bdo|big|br|button|cite|code|del|dfn|em|i|img|ins|input|label|map|kbd|q|samp|select|small|span|strong|sub|sup|textarea|tt|var';
+
+ // whether or not to protect quotes within { curly braces }
+ var $protect_braced_quotes = FALSE;
+
+ /**
+ * Nothing to do here...
+ *
+ */
+ function CI_Typography()
+ {
+ }
+
+ /**
+ * Auto Typography
+ *
+ * This function converts text, making it typographically correct:
+ * - Converts double spaces into paragraphs.
+ * - Converts single line breaks into <br /> tags
+ * - Converts single and double quotes into correctly facing curly quote entities.
+ * - Converts three dots into ellipsis.
+ * - Converts double dashes into em-dashes.
+ * - Converts two spaces into entities
+ *
+ * @access public
+ * @param string
+ * @param bool whether to reduce more then two consecutive newlines to two
+ * @return string
+ */
+ function auto_typography($str, $reduce_linebreaks = FALSE)
+ {
+ if ($str == '')
+ {
+ return '';
+ }
+
+ // Standardize Newlines to make matching easier
+ if (strpos($str, "\r") !== FALSE)
+ {
+ $str = str_replace(array("\r\n", "\r"), "\n", $str);
+ }
+
+ // Reduce line breaks. If there are more than two consecutive linebreaks
+ // we'll compress them down to a maximum of two since there's no benefit to more.
+ if ($reduce_linebreaks === TRUE)
+ {
+ $str = preg_replace("/\n\n+/", "\n\n", $str);
+ }
+
+ // Convert quotes within tags to temporary markers. We don't want quotes converted
+ // within tags so we'll temporarily convert them to {@DQ} and {@SQ}
+ // and we don't want double dashes converted to emdash entities, so they are marked with {@DD}
+ // likewise double spaces are converted to {@NBS} to prevent entity conversion
+ if (preg_match_all("#\<.+?>#si", $str, $matches))
+ {
+ for ($i = 0, $total = count($matches[0]); $i < $total; $i++)
+ {
+ $str = str_replace($matches[0][$i],
+ str_replace(array("'",'"','--',' '), array('{@SQ}', '{@DQ}', '{@DD}', '{@NBS}'), $matches[0][$i]),
+ $str);
+ }
+ }
+
+ if ($this->protect_braced_quotes === TRUE)
+ {
+ if (preg_match_all("#\{.+?}#si", $str, $matches))
+ {
+ for ($i = 0, $total = count($matches[0]); $i < $total; $i++)
+ {
+ $str = str_replace($matches[0][$i],
+ str_replace(array("'",'"'), array('{@SQ}', '{@DQ}'), $matches[0][$i]),
+ $str);
+ }
+ }
+ }
+
+ // Convert "ignore" tags to temporary marker. The parser splits out the string at every tag
+ // it encounters. Certain inline tags, like image tags, links, span tags, etc. will be
+ // adversely affected if they are split out so we'll convert the opening bracket < temporarily to: {@TAG}
+ $str = preg_replace("#<(/*)(".$this->inline_elements.")([ >])#i", "{@TAG}\\1\\2\\3", $str);
+
+ // Split the string at every tag. This expression creates an array with this prototype:
+ //
+ // [array]
+ // {
+ // [0] = <opening tag>
+ // [1] = Content...
+ // [2] = <closing tag>
+ // Etc...
+ // }
+ $chunks = preg_split('/(<(?:[^<>]+(?:"[^"]*"|\'[^\']*\')?)+>)/', $str, -1, PREG_SPLIT_DELIM_CAPTURE|PREG_SPLIT_NO_EMPTY);
+
+ // Build our finalized string. We cycle through the array, skipping tags, and processing the contained text
+ $str = '';
+ $process = TRUE;
+ $paragraph = FALSE;
+ foreach ($chunks as $chunk)
+ {
+ // Are we dealing with a tag? If so, we'll skip the processing for this cycle.
+ // Well also set the "process" flag which allows us to skip <pre> tags and a few other things.
+ if (preg_match("#<(/*)(".$this->block_elements.").*?>#", $chunk, $match))
+ {
+ if (preg_match("#".$this->skip_elements."#", $match[2]))
+ {
+ $process = ($match[1] == '/') ? TRUE : FALSE;
+ }
+
+ $str .= $chunk;
+ continue;
+ }
+ elseif (preg_match('/<(\/?)([a-z]*).*?>/s', $chunk, $tagmatch))
+ {
+ if ($tagmatch[1] == '/' && $tagmatch[2] == $this->last_tag)
+ {
+ $process = FALSE;
+ }
+ else
+ {
+ $process = TRUE;
+ $this->last_tag = $tagmatch[2];
+ }
+ }
+
+ if ($process == FALSE)
+ {
+ $str .= $chunk;
+ continue;
+ }
+
+ // Convert Newlines into <p> and <br /> tags
+ $str .= $this->format_characters($this->_format_newlines($chunk));
+ }
+
+ // is the whole of the content inside a block level element?
+ if ( ! preg_match("/^<(?:".$this->block_elements.")/i", $str, $match))
+ {
+ $str = "<p>{$str}</p>";
+ }
+
+
+ // some special linebreak cleanup
+ $str = preg_replace_callback('#<(?!/|'.$this->block_elements.')([^>]*)><p>(.*?)</p><(\w*)#si', array($this, '_linebreak_cleanup'), $str);
+
+ // and cleanup empty paragraph tags sitting between two closing tags
+ $str = preg_replace('#(</\w+>)<p>(\s*)</p>(</\w+>)#si', '$1$2$3', $str);
+
+ // Final clean up
+ $table = array(
+
+ // If the user submitted their own paragraph tags within the text
+ // we will retain them instead of using our tags.
+ '/(<p[^>*?]>)<p>/' => '$1', // <?php BBEdit syntax coloring bug fix
+
+ // Reduce multiple instances of opening/closing paragraph tags to a single one
+ '#(</p>)+#' => '</p>',
+ '/(<p>\W*<p>)+/' => '<p>',
+
+ // Clean up stray paragraph tags that appear before block level elements
+ '#<p></p><('.$this->block_elements.')#' => '<$1',
+
+ // Clean up open paragraph tags that appear before block level elements
+ '#<p>(\W)<('.$this->block_elements.')#' => '<p></p>$1<$2',
+
+ // Clean up stray non-breaking spaces preceeding block elements
+ '#[&nbsp; ]+<('.$this->block_elements.')#' => ' <$1',
+
+ // Replace the temporary markers we added earlier
+ '/\{@TAG\}/' => '<',
+ '/\{@DQ\}/' => '"',
+ '/\{@SQ\}/' => "'",
+ '/\{@DD\}/' => '--',
+ '/\{@NBS\}/' => ' '
+
+ );
+
+ // Do we need to reduce empty lines?
+ if ($reduce_linebreaks === TRUE)
+ {
+ $table['#<p>\n*</p>#'] = '';
+ }
+ else
+ {
+ // If we have empty paragraph tags we add a non-breaking space
+ // otherwise most browsers won't treat them as true paragraphs
+ $table['#<p></p>#'] = '<p>&nbsp;</p>';
+ }
+
+ return preg_replace(array_keys($table), $table, $str);
+
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Linebreak Cleanup
+ *
+ * Removes paragraph and line break tags inserted inbetween
+ * inline content and a new opening block level element
+ *
+ * @access private
+ * @param array
+ * @return string
+ */
+ function _linebreak_cleanup($match)
+ {
+ if (in_array($match[3], explode('|', $this->block_elements)))
+ {
+ return "<{$match[1]}>".str_replace('<br />', '', $match[2])."<{$match[3]}";
+ }
+ else
+ {
+ return $match[0];
+ }
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Format Characters
+ *
+ * This function mainly converts double and single quotes
+ * to curly entities, but it also converts em-dashes,
+ * double spaces, and ampersands
+ *
+ * @access public
+ * @param string
+ * @return string
+ */
+ function format_characters($str)
+ {
+ static $table;
+
+ if ( ! isset($table))
+ {
+ $table = array(
+ // nested smart quotes, opening and closing
+ // note that rules for grammar (English) allow only for two levels deep
+ // and that single quotes are _supposed_ to always be on the outside
+ // but we'll accommodate both
+ '/(^|\W|\s)\'"/' => '$1&#8216;&#8220;',
+ '/\'"(\s|\W|$)/' => '&#8217;&#8221;$1',
+ '/(^|\W|\s)"\'/' => '$1&#8220;&#8216;',
+ '/"\'(\s|\W|$)/' => '&#8221;&#8217;$1',
+
+ // single quote smart quotes
+ '/\'(\s|\W|$)/' => '&#8217;$1',
+ '/(^|\W|\s)\'/' => '$1&#8216;',
+
+ // double quote smart quotes
+ '/"(\s|\W|$)/' => '&#8221;$1',
+ '/(^|\W|\s)"/' => '$1&#8220;',
+
+ // apostrophes
+ "/(\w)'(\w)/" => '$1&#8217;$2',
+
+ // Em dash and ellipses dots
+ '/\s?\-\-\s?/' => '&#8212;',
+ '/(\w)\.{3}/' => '$1&#8230;',
+
+ // double space after sentences
+ '/(\W) /' => '$1&nbsp; ',
+
+ // ampersands, if not a character entity
+ '/&(?!#?[a-zA-Z0-9]{2,};)/' => '&amp;'
+ );
+ }
+
+ return preg_replace(array_keys($table), $table, $str);
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Format Newlines
+ *
+ * Converts newline characters into either <p> tags or <br />
+ *
+ * @access public
+ * @param string
+ * @return string
+ */
+ function _format_newlines($str)
+ {
+ if ($str == '')
+ {
+ return $str;
+ }
+
+ if (strpos($str, "\n") === FALSE)
+ {
+ return $str;
+ }
+
+ // Convert two consecutive newlines to paragraphs
+ $str = str_replace("\n\n", "</p>\n\n<p>", $str);
+
+ // Convert single spaces to <br /> tags
+ $str = preg_replace("/([^\n])(\n)([^\n])/", "\\1<br />\\2\\3", $str);
+
+ // Wrap the whole enchilada in enclosing paragraphs
+ if ($str != "\n")
+ {
+ $str = '<p>'.$str.'</p>';
+ }
+
+ // Remove empty paragraphs if they are on the first line, as this
+ // is a potential unintended consequence of the previous code
+ $str = preg_replace("/<p><\/p>(.*)/", "\\1", $str, 1);
+
+ return $str;
+ }
+
+ // ------------------------------------------------------------------------
+
+ /**
+ * Convert newlines to HTML line breaks except within PRE tags
+ *
+ * @access public
+ * @param string
+ * @return string
+ */
+ function nl2br_except_pre($str)
+ {
+ $ex = explode("pre>",$str);
+ $ct = count($ex);
+
+ $newstr = "";
+ for ($i = 0; $i < $ct; $i++)
+ {
+ if (($i % 2) == 0)
+ {
+ $newstr .= nl2br($ex[$i]);
+ }
+ else
+ {
+ $newstr .= $ex[$i];
+ }
+
+ if ($ct - 1 != $i)
+ $newstr .= "pre>";
+ }
+
+ return $newstr;
+ }
+
+}
+// END Typography Class
+
+/* End of file Typography.php */
/* Location: ./system/libraries/Typography.php */ \ No newline at end of file
diff --git a/system/libraries/URI.php b/system/libraries/URI.php
index aa2d71e87..b27dfa3cc 100644
--- a/system/libraries/URI.php
+++ b/system/libraries/URI.php
@@ -1,585 +1,585 @@
-<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
-/**
- * CodeIgniter
- *
- * An open source application development framework for PHP 4.3.2 or newer
- *
- * @package CodeIgniter
- * @author ExpressionEngine Dev Team
- * @copyright Copyright (c) 2008, EllisLab, Inc.
- * @license http://codeigniter.com/user_guide/license.html
- * @link http://codeigniter.com
- * @since Version 1.0
- * @filesource
- */
-
-// ------------------------------------------------------------------------
-
-/**
- * URI Class
- *
- * Parses URIs and determines routing
- *
- * @package CodeIgniter
- * @subpackage Libraries
- * @category URI
- * @author ExpressionEngine Dev Team
- * @link http://codeigniter.com/user_guide/libraries/uri.html
- */
-class CI_URI {
-
- var $keyval = array();
- var $uri_string;
- var $segments = array();
- var $rsegments = array();
-
- /**
- * Constructor
- *
- * Simply globalizes the $RTR object. The front
- * loads the Router class early on so it's not available
- * normally as other classes are.
- *
- * @access public
- */
- function CI_URI()
- {
- $this->config =& load_class('Config');
- log_message('debug', "URI Class Initialized");
- }
-
-
- // --------------------------------------------------------------------
-
- /**
- * Get the URI String
- *
- * @access private
- * @return string
- */
- function _fetch_uri_string()
- {
- if (strtoupper($this->config->item('uri_protocol')) == 'AUTO')
- {
- // If the URL has a question mark then it's simplest to just
- // build the URI string from the zero index of the $_GET array.
- // This avoids having to deal with $_SERVER variables, which
- // can be unreliable in some environments
- if (is_array($_GET) && count($_GET) == 1 && trim(key($_GET), '/') != '')
- {
- $this->uri_string = key($_GET);
- 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 (trim($path, '/') != '' && $path != "/".SELF)
- {
- $this->uri_string = $path;
- return;
- }
-
- // No PATH_INFO?... What about QUERY_STRING?
- $path = (isset($_SERVER['QUERY_STRING'])) ? $_SERVER['QUERY_STRING'] : @getenv('QUERY_STRING');
- if (trim($path, '/') != '')
- {
- $this->uri_string = $path;
- return;
- }
-
- // No QUERY_STRING?... Maybe the ORIG_PATH_INFO variable exists?
- $path = (isset($_SERVER['ORIG_PATH_INFO'])) ? $_SERVER['ORIG_PATH_INFO'] : @getenv('ORIG_PATH_INFO');
- if (trim($path, '/') != '' && $path != "/".SELF)
- {
- // remove path and script information so we have good URI data
- $this->uri_string = str_replace($_SERVER['SCRIPT_NAME'], '', $path);
- return;
- }
-
- // We've exhausted all our options...
- $this->uri_string = '';
- }
- else
- {
- $uri = strtoupper($this->config->item('uri_protocol'));
-
- if ($uri == 'REQUEST_URI')
- {
- $this->uri_string = $this->_parse_request_uri();
- return;
- }
-
- $this->uri_string = (isset($_SERVER[$uri])) ? $_SERVER[$uri] : @getenv($uri);
- }
-
- // If the URI contains only a slash we'll kill it
- if ($this->uri_string == '/')
- {
- $this->uri_string = '';
- }
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Parse the 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
- * @return string
- */
- function _parse_request_uri()
- {
- if ( ! isset($_SERVER['REQUEST_URI']) OR $_SERVER['REQUEST_URI'] == '')
- {
- return '';
- }
-
- $request_uri = preg_replace("|/(.*)|", "\\1", str_replace("\\", "/", $_SERVER['REQUEST_URI']));
-
- if ($request_uri == '' OR $request_uri == SELF)
- {
- return '';
- }
-
- $fc_path = FCPATH;
- if (strpos($request_uri, '?') !== FALSE)
- {
- $fc_path .= '?';
- }
-
- $parsed_uri = explode("/", $request_uri);
-
- $i = 0;
- foreach(explode("/", $fc_path) as $segment)
- {
- if (isset($parsed_uri[$i]) && $segment == $parsed_uri[$i])
- {
- $i++;
- }
- }
-
- $parsed_uri = implode("/", array_slice($parsed_uri, $i));
-
- if ($parsed_uri != '')
- {
- $parsed_uri = '/'.$parsed_uri;
- }
-
- return $parsed_uri;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Filter segments for malicious characters
- *
- * @access private
- * @param string
- * @return string
- */
- function _filter_uri($str)
- {
- if ($str != '' && $this->config->item('permitted_uri_chars') != '' && $this->config->item('enable_query_strings') == FALSE)
- {
- if ( ! preg_match("|^[".preg_quote($this->config->item('permitted_uri_chars'))."]+$|i", $str))
- {
- header('HTTP/1.1 400 Bad Request');
- exit('The URI you submitted has disallowed characters.');
- }
- }
-
- // Convert programatic characters to entities
- $bad = array('$', '(', ')', '%28', '%29');
- $good = array('&#36;', '&#40;', '&#41;', '&#40;', '&#41;');
-
- return str_replace($bad, $good, $str);
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Remove the suffix from the URL if needed
- *
- * @access private
- * @return void
- */
- function _remove_url_suffix()
- {
- if ($this->config->item('url_suffix') != "")
- {
- $this->uri_string = preg_replace("|".preg_quote($this->config->item('url_suffix'))."$|", "", $this->uri_string);
- }
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Explode the URI Segments. The individual segments will
- * be stored in the $this->segments array.
- *
- * @access private
- * @return void
- */
- function _explode_segments()
- {
- foreach(explode("/", preg_replace("|/*(.+?)/*$|", "\\1", $this->uri_string)) as $val)
- {
- // Filter segments for security
- $val = trim($this->_filter_uri($val));
-
- if ($val != '')
- {
- $this->segments[] = $val;
- }
- }
- }
-
- // --------------------------------------------------------------------
- /**
- * Re-index Segments
- *
- * This function re-indexes the $this->segment array so that it
- * starts at 1 rather than 0. Doing so makes it simpler to
- * use functions like $this->uri->segment(n) since there is
- * a 1:1 relationship between the segment array and the actual segments.
- *
- * @access private
- * @return void
- */
- function _reindex_segments()
- {
- array_unshift($this->segments, NULL);
- array_unshift($this->rsegments, NULL);
- unset($this->segments[0]);
- unset($this->rsegments[0]);
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Fetch a URI Segment
- *
- * This function returns the URI segment based on the number provided.
- *
- * @access public
- * @param integer
- * @param bool
- * @return string
- */
- function segment($n, $no_result = FALSE)
- {
- return ( ! isset($this->segments[$n])) ? $no_result : $this->segments[$n];
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Fetch a URI "routed" Segment
- *
- * This function returns the re-routed URI segment (assuming routing rules are used)
- * based on the number provided. If there is no routing this function returns the
- * same result as $this->segment()
- *
- * @access public
- * @param integer
- * @param bool
- * @return string
- */
- function rsegment($n, $no_result = FALSE)
- {
- return ( ! isset($this->rsegments[$n])) ? $no_result : $this->rsegments[$n];
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Generate a key value pair from the URI string
- *
- * This function generates and associative array of URI data starting
- * at the supplied segment. For example, if this is your URI:
- *
- * example.com/user/search/name/joe/location/UK/gender/male
- *
- * You can use this function to generate an array with this prototype:
- *
- * array (
- * name => joe
- * location => UK
- * gender => male
- * )
- *
- * @access public
- * @param integer the starting segment number
- * @param array an array of default values
- * @return array
- */
- function uri_to_assoc($n = 3, $default = array())
- {
- return $this->_uri_to_assoc($n, $default, 'segment');
- }
- /**
- * Identical to above only it uses the re-routed segment array
- *
- */
- function ruri_to_assoc($n = 3, $default = array())
- {
- return $this->_uri_to_assoc($n, $default, 'rsegment');
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Generate a key value pair from the URI string or Re-routed URI string
- *
- * @access private
- * @param integer the starting segment number
- * @param array an array of default values
- * @param string which array we should use
- * @return array
- */
- function _uri_to_assoc($n = 3, $default = array(), $which = 'segment')
- {
- if ($which == 'segment')
- {
- $total_segments = 'total_segments';
- $segment_array = 'segment_array';
- }
- else
- {
- $total_segments = 'total_rsegments';
- $segment_array = 'rsegment_array';
- }
-
- if ( ! is_numeric($n))
- {
- return $default;
- }
-
- if (isset($this->keyval[$n]))
- {
- return $this->keyval[$n];
- }
-
- if ($this->$total_segments() < $n)
- {
- if (count($default) == 0)
- {
- return array();
- }
-
- $retval = array();
- foreach ($default as $val)
- {
- $retval[$val] = FALSE;
- }
- return $retval;
- }
-
- $segments = array_slice($this->$segment_array(), ($n - 1));
-
- $i = 0;
- $lastval = '';
- $retval = array();
- foreach ($segments as $seg)
- {
- if ($i % 2)
- {
- $retval[$lastval] = $seg;
- }
- else
- {
- $retval[$seg] = FALSE;
- $lastval = $seg;
- }
-
- $i++;
- }
-
- if (count($default) > 0)
- {
- foreach ($default as $val)
- {
- if ( ! array_key_exists($val, $retval))
- {
- $retval[$val] = FALSE;
- }
- }
- }
-
- // Cache the array for reuse
- $this->keyval[$n] = $retval;
- return $retval;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Generate a URI string from an associative array
- *
- *
- * @access public
- * @param array an associative array of key/values
- * @return array
- */
- function assoc_to_uri($array)
- {
- $temp = array();
- foreach ((array)$array as $key => $val)
- {
- $temp[] = $key;
- $temp[] = $val;
- }
-
- return implode('/', $temp);
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Fetch a URI Segment and add a trailing slash
- *
- * @access public
- * @param integer
- * @param string
- * @return string
- */
- function slash_segment($n, $where = 'trailing')
- {
- return $this->_slash_segment($n, $where, 'segment');
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Fetch a URI Segment and add a trailing slash
- *
- * @access public
- * @param integer
- * @param string
- * @return string
- */
- function slash_rsegment($n, $where = 'trailing')
- {
- return $this->_slash_segment($n, $where, 'rsegment');
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Fetch a URI Segment and add a trailing slash - helper function
- *
- * @access private
- * @param integer
- * @param string
- * @param string
- * @return string
- */
- function _slash_segment($n, $where = 'trailing', $which = 'segment')
- {
- if ($where == 'trailing')
- {
- $trailing = '/';
- $leading = '';
- }
- elseif ($where == 'leading')
- {
- $leading = '/';
- $trailing = '';
- }
- else
- {
- $leading = '/';
- $trailing = '/';
- }
- return $leading.$this->$which($n).$trailing;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Segment Array
- *
- * @access public
- * @return array
- */
- function segment_array()
- {
- return $this->segments;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Routed Segment Array
- *
- * @access public
- * @return array
- */
- function rsegment_array()
- {
- return $this->rsegments;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Total number of segments
- *
- * @access public
- * @return integer
- */
- function total_segments()
- {
- return count($this->segments);
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Total number of routed segments
- *
- * @access public
- * @return integer
- */
- function total_rsegments()
- {
- return count($this->rsegments);
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Fetch the entire URI string
- *
- * @access public
- * @return string
- */
- function uri_string()
- {
- return $this->uri_string;
- }
-
-
- // --------------------------------------------------------------------
-
- /**
- * Fetch the entire Re-routed URI string
- *
- * @access public
- * @return string
- */
- function ruri_string()
- {
- return '/'.implode('/', $this->rsegment_array()).'/';
- }
-
-}
-// END URI Class
-
-/* End of file URI.php */
+<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+/**
+ * CodeIgniter
+ *
+ * An open source application development framework for PHP 4.3.2 or newer
+ *
+ * @package CodeIgniter
+ * @author ExpressionEngine Dev Team
+ * @copyright Copyright (c) 2008, EllisLab, Inc.
+ * @license http://codeigniter.com/user_guide/license.html
+ * @link http://codeigniter.com
+ * @since Version 1.0
+ * @filesource
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+ * URI Class
+ *
+ * Parses URIs and determines routing
+ *
+ * @package CodeIgniter
+ * @subpackage Libraries
+ * @category URI
+ * @author ExpressionEngine Dev Team
+ * @link http://codeigniter.com/user_guide/libraries/uri.html
+ */
+class CI_URI {
+
+ var $keyval = array();
+ var $uri_string;
+ var $segments = array();
+ var $rsegments = array();
+
+ /**
+ * Constructor
+ *
+ * Simply globalizes the $RTR object. The front
+ * loads the Router class early on so it's not available
+ * normally as other classes are.
+ *
+ * @access public
+ */
+ function CI_URI()
+ {
+ $this->config =& load_class('Config');
+ log_message('debug', "URI Class Initialized");
+ }
+
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Get the URI String
+ *
+ * @access private
+ * @return string
+ */
+ function _fetch_uri_string()
+ {
+ if (strtoupper($this->config->item('uri_protocol')) == 'AUTO')
+ {
+ // If the URL has a question mark then it's simplest to just
+ // build the URI string from the zero index of the $_GET array.
+ // This avoids having to deal with $_SERVER variables, which
+ // can be unreliable in some environments
+ if (is_array($_GET) && count($_GET) == 1 && trim(key($_GET), '/') != '')
+ {
+ $this->uri_string = key($_GET);
+ 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 (trim($path, '/') != '' && $path != "/".SELF)
+ {
+ $this->uri_string = $path;
+ return;
+ }
+
+ // No PATH_INFO?... What about QUERY_STRING?
+ $path = (isset($_SERVER['QUERY_STRING'])) ? $_SERVER['QUERY_STRING'] : @getenv('QUERY_STRING');
+ if (trim($path, '/') != '')
+ {
+ $this->uri_string = $path;
+ return;
+ }
+
+ // No QUERY_STRING?... Maybe the ORIG_PATH_INFO variable exists?
+ $path = (isset($_SERVER['ORIG_PATH_INFO'])) ? $_SERVER['ORIG_PATH_INFO'] : @getenv('ORIG_PATH_INFO');
+ if (trim($path, '/') != '' && $path != "/".SELF)
+ {
+ // remove path and script information so we have good URI data
+ $this->uri_string = str_replace($_SERVER['SCRIPT_NAME'], '', $path);
+ return;
+ }
+
+ // We've exhausted all our options...
+ $this->uri_string = '';
+ }
+ else
+ {
+ $uri = strtoupper($this->config->item('uri_protocol'));
+
+ if ($uri == 'REQUEST_URI')
+ {
+ $this->uri_string = $this->_parse_request_uri();
+ return;
+ }
+
+ $this->uri_string = (isset($_SERVER[$uri])) ? $_SERVER[$uri] : @getenv($uri);
+ }
+
+ // If the URI contains only a slash we'll kill it
+ if ($this->uri_string == '/')
+ {
+ $this->uri_string = '';
+ }
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Parse the 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
+ * @return string
+ */
+ function _parse_request_uri()
+ {
+ if ( ! isset($_SERVER['REQUEST_URI']) OR $_SERVER['REQUEST_URI'] == '')
+ {
+ return '';
+ }
+
+ $request_uri = preg_replace("|/(.*)|", "\\1", str_replace("\\", "/", $_SERVER['REQUEST_URI']));
+
+ if ($request_uri == '' OR $request_uri == SELF)
+ {
+ return '';
+ }
+
+ $fc_path = FCPATH;
+ if (strpos($request_uri, '?') !== FALSE)
+ {
+ $fc_path .= '?';
+ }
+
+ $parsed_uri = explode("/", $request_uri);
+
+ $i = 0;
+ foreach(explode("/", $fc_path) as $segment)
+ {
+ if (isset($parsed_uri[$i]) && $segment == $parsed_uri[$i])
+ {
+ $i++;
+ }
+ }
+
+ $parsed_uri = implode("/", array_slice($parsed_uri, $i));
+
+ if ($parsed_uri != '')
+ {
+ $parsed_uri = '/'.$parsed_uri;
+ }
+
+ return $parsed_uri;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Filter segments for malicious characters
+ *
+ * @access private
+ * @param string
+ * @return string
+ */
+ function _filter_uri($str)
+ {
+ if ($str != '' && $this->config->item('permitted_uri_chars') != '' && $this->config->item('enable_query_strings') == FALSE)
+ {
+ if ( ! preg_match("|^[".preg_quote($this->config->item('permitted_uri_chars'))."]+$|i", $str))
+ {
+ header('HTTP/1.1 400 Bad Request');
+ exit('The URI you submitted has disallowed characters.');
+ }
+ }
+
+ // Convert programatic characters to entities
+ $bad = array('$', '(', ')', '%28', '%29');
+ $good = array('&#36;', '&#40;', '&#41;', '&#40;', '&#41;');
+
+ return str_replace($bad, $good, $str);
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Remove the suffix from the URL if needed
+ *
+ * @access private
+ * @return void
+ */
+ function _remove_url_suffix()
+ {
+ if ($this->config->item('url_suffix') != "")
+ {
+ $this->uri_string = preg_replace("|".preg_quote($this->config->item('url_suffix'))."$|", "", $this->uri_string);
+ }
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Explode the URI Segments. The individual segments will
+ * be stored in the $this->segments array.
+ *
+ * @access private
+ * @return void
+ */
+ function _explode_segments()
+ {
+ foreach(explode("/", preg_replace("|/*(.+?)/*$|", "\\1", $this->uri_string)) as $val)
+ {
+ // Filter segments for security
+ $val = trim($this->_filter_uri($val));
+
+ if ($val != '')
+ {
+ $this->segments[] = $val;
+ }
+ }
+ }
+
+ // --------------------------------------------------------------------
+ /**
+ * Re-index Segments
+ *
+ * This function re-indexes the $this->segment array so that it
+ * starts at 1 rather than 0. Doing so makes it simpler to
+ * use functions like $this->uri->segment(n) since there is
+ * a 1:1 relationship between the segment array and the actual segments.
+ *
+ * @access private
+ * @return void
+ */
+ function _reindex_segments()
+ {
+ array_unshift($this->segments, NULL);
+ array_unshift($this->rsegments, NULL);
+ unset($this->segments[0]);
+ unset($this->rsegments[0]);
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Fetch a URI Segment
+ *
+ * This function returns the URI segment based on the number provided.
+ *
+ * @access public
+ * @param integer
+ * @param bool
+ * @return string
+ */
+ function segment($n, $no_result = FALSE)
+ {
+ return ( ! isset($this->segments[$n])) ? $no_result : $this->segments[$n];
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Fetch a URI "routed" Segment
+ *
+ * This function returns the re-routed URI segment (assuming routing rules are used)
+ * based on the number provided. If there is no routing this function returns the
+ * same result as $this->segment()
+ *
+ * @access public
+ * @param integer
+ * @param bool
+ * @return string
+ */
+ function rsegment($n, $no_result = FALSE)
+ {
+ return ( ! isset($this->rsegments[$n])) ? $no_result : $this->rsegments[$n];
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Generate a key value pair from the URI string
+ *
+ * This function generates and associative array of URI data starting
+ * at the supplied segment. For example, if this is your URI:
+ *
+ * example.com/user/search/name/joe/location/UK/gender/male
+ *
+ * You can use this function to generate an array with this prototype:
+ *
+ * array (
+ * name => joe
+ * location => UK
+ * gender => male
+ * )
+ *
+ * @access public
+ * @param integer the starting segment number
+ * @param array an array of default values
+ * @return array
+ */
+ function uri_to_assoc($n = 3, $default = array())
+ {
+ return $this->_uri_to_assoc($n, $default, 'segment');
+ }
+ /**
+ * Identical to above only it uses the re-routed segment array
+ *
+ */
+ function ruri_to_assoc($n = 3, $default = array())
+ {
+ return $this->_uri_to_assoc($n, $default, 'rsegment');
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Generate a key value pair from the URI string or Re-routed URI string
+ *
+ * @access private
+ * @param integer the starting segment number
+ * @param array an array of default values
+ * @param string which array we should use
+ * @return array
+ */
+ function _uri_to_assoc($n = 3, $default = array(), $which = 'segment')
+ {
+ if ($which == 'segment')
+ {
+ $total_segments = 'total_segments';
+ $segment_array = 'segment_array';
+ }
+ else
+ {
+ $total_segments = 'total_rsegments';
+ $segment_array = 'rsegment_array';
+ }
+
+ if ( ! is_numeric($n))
+ {
+ return $default;
+ }
+
+ if (isset($this->keyval[$n]))
+ {
+ return $this->keyval[$n];
+ }
+
+ if ($this->$total_segments() < $n)
+ {
+ if (count($default) == 0)
+ {
+ return array();
+ }
+
+ $retval = array();
+ foreach ($default as $val)
+ {
+ $retval[$val] = FALSE;
+ }
+ return $retval;
+ }
+
+ $segments = array_slice($this->$segment_array(), ($n - 1));
+
+ $i = 0;
+ $lastval = '';
+ $retval = array();
+ foreach ($segments as $seg)
+ {
+ if ($i % 2)
+ {
+ $retval[$lastval] = $seg;
+ }
+ else
+ {
+ $retval[$seg] = FALSE;
+ $lastval = $seg;
+ }
+
+ $i++;
+ }
+
+ if (count($default) > 0)
+ {
+ foreach ($default as $val)
+ {
+ if ( ! array_key_exists($val, $retval))
+ {
+ $retval[$val] = FALSE;
+ }
+ }
+ }
+
+ // Cache the array for reuse
+ $this->keyval[$n] = $retval;
+ return $retval;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Generate a URI string from an associative array
+ *
+ *
+ * @access public
+ * @param array an associative array of key/values
+ * @return array
+ */
+ function assoc_to_uri($array)
+ {
+ $temp = array();
+ foreach ((array)$array as $key => $val)
+ {
+ $temp[] = $key;
+ $temp[] = $val;
+ }
+
+ return implode('/', $temp);
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Fetch a URI Segment and add a trailing slash
+ *
+ * @access public
+ * @param integer
+ * @param string
+ * @return string
+ */
+ function slash_segment($n, $where = 'trailing')
+ {
+ return $this->_slash_segment($n, $where, 'segment');
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Fetch a URI Segment and add a trailing slash
+ *
+ * @access public
+ * @param integer
+ * @param string
+ * @return string
+ */
+ function slash_rsegment($n, $where = 'trailing')
+ {
+ return $this->_slash_segment($n, $where, 'rsegment');
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Fetch a URI Segment and add a trailing slash - helper function
+ *
+ * @access private
+ * @param integer
+ * @param string
+ * @param string
+ * @return string
+ */
+ function _slash_segment($n, $where = 'trailing', $which = 'segment')
+ {
+ if ($where == 'trailing')
+ {
+ $trailing = '/';
+ $leading = '';
+ }
+ elseif ($where == 'leading')
+ {
+ $leading = '/';
+ $trailing = '';
+ }
+ else
+ {
+ $leading = '/';
+ $trailing = '/';
+ }
+ return $leading.$this->$which($n).$trailing;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Segment Array
+ *
+ * @access public
+ * @return array
+ */
+ function segment_array()
+ {
+ return $this->segments;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Routed Segment Array
+ *
+ * @access public
+ * @return array
+ */
+ function rsegment_array()
+ {
+ return $this->rsegments;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Total number of segments
+ *
+ * @access public
+ * @return integer
+ */
+ function total_segments()
+ {
+ return count($this->segments);
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Total number of routed segments
+ *
+ * @access public
+ * @return integer
+ */
+ function total_rsegments()
+ {
+ return count($this->rsegments);
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Fetch the entire URI string
+ *
+ * @access public
+ * @return string
+ */
+ function uri_string()
+ {
+ return $this->uri_string;
+ }
+
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Fetch the entire Re-routed URI string
+ *
+ * @access public
+ * @return string
+ */
+ function ruri_string()
+ {
+ return '/'.implode('/', $this->rsegment_array()).'/';
+ }
+
+}
+// END URI Class
+
+/* End of file URI.php */
/* Location: ./system/libraries/URI.php */ \ No newline at end of file
diff --git a/system/scaffolding/views/add.php b/system/scaffolding/views/add.php
index cbb12f6fb..cac255acf 100644
--- a/system/scaffolding/views/add.php
+++ b/system/scaffolding/views/add.php
@@ -1,32 +1,32 @@
-<?php $this->load->view('header'); ?>
-
-<p><?php echo anchor(array($base_uri, 'view'), '&lt; '.$scaff_view_all); ?></p>
-
-
-<?php echo form_open($action); ?>
-
-<table border="0" cellpadding="3" cellspacing="1">
-<?php foreach($fields as $field): ?>
-
-<?php if ($field->primary_key == 1) continue; ?>
-
-<tr>
- <td><?php echo $field->name; echo ' '.$field->default; ?></td>
-
- <?php if ($field->type == 'blob'): ?>
- <td><textarea class="textarea" name="<?php echo $field->name; ?>" cols="60" rows="10" ><?php echo form_prep($field->default); ?></textarea></td>
- <?php else : ?>
- <td><input class="input" name="<?php echo $field->name; ?>" value="<?php echo form_prep($field->default); ?>" size="60" /></td>
- <?php endif; ?>
-
-</tr>
-<?php endforeach; ?>
-</table>
-
-<input type="submit" class="submit" value="Insert" />
-
-</form>
-
-<?php $this->load->view('footer');
-/* End of file add.php */
-/* Location: ./system/scaffolding/views/add.php */
+<?php $this->load->view('header'); ?>
+
+<p><?php echo anchor(array($base_uri, 'view'), '&lt; '.$scaff_view_all); ?></p>
+
+
+<?php echo form_open($action); ?>
+
+<table border="0" cellpadding="3" cellspacing="1">
+<?php foreach($fields as $field): ?>
+
+<?php if ($field->primary_key == 1) continue; ?>
+
+<tr>
+ <td><?php echo $field->name; echo ' '.$field->default; ?></td>
+
+ <?php if ($field->type == 'blob'): ?>
+ <td><textarea class="textarea" name="<?php echo $field->name; ?>" cols="60" rows="10" ><?php echo form_prep($field->default); ?></textarea></td>
+ <?php else : ?>
+ <td><input class="input" name="<?php echo $field->name; ?>" value="<?php echo form_prep($field->default); ?>" size="60" /></td>
+ <?php endif; ?>
+
+</tr>
+<?php endforeach; ?>
+</table>
+
+<input type="submit" class="submit" value="Insert" />
+
+</form>
+
+<?php $this->load->view('footer');
+/* End of file add.php */
+/* Location: ./system/scaffolding/views/add.php */
diff --git a/system/scaffolding/views/delete.php b/system/scaffolding/views/delete.php
index d19542195..87b59bef9 100644
--- a/system/scaffolding/views/delete.php
+++ b/system/scaffolding/views/delete.php
@@ -1,9 +1,9 @@
-<?php $this->load->view('header'); ?>
-
-<p><?php echo $message; ?></p>
-
-<p><?php echo $no; ?>&nbsp;&nbsp;|&nbsp;&nbsp;<?php echo $yes; ?>
-
-<?php $this->load->view('footer');
-/* End of file delete.php */
-/* Location: ./system/scaffolding/views/delete.php */
+<?php $this->load->view('header'); ?>
+
+<p><?php echo $message; ?></p>
+
+<p><?php echo $no; ?>&nbsp;&nbsp;|&nbsp;&nbsp;<?php echo $yes; ?>
+
+<?php $this->load->view('footer');
+/* End of file delete.php */
+/* Location: ./system/scaffolding/views/delete.php */
diff --git a/system/scaffolding/views/edit.php b/system/scaffolding/views/edit.php
index fe553e591..c66259d90 100644
--- a/system/scaffolding/views/edit.php
+++ b/system/scaffolding/views/edit.php
@@ -1,33 +1,33 @@
-<?php $this->load->view('header'); ?>
-
-
-<p><?php echo anchor(array($base_uri, 'view'), '&lt; '.$scaff_view_all);?></p>
-
-
-<?php echo form_open($action); ?>
-
-<table border="0" cellpadding="3" cellspacing="1">
-<?php foreach($fields as $field): ?>
-
-<?php if ($field->primary_key == 1) continue; ?>
-
-<tr>
- <td><?php echo $field->name; ?></td>
-
- <?php if ($field->type == 'blob'): ?>
- <td><textarea class="textarea" name="<?php echo $field->name;?>" cols="60" rows="10" ><?php $f = $field->name; echo form_prep($query->$f); ?></textarea></td>
- <?php else : ?>
- <td><input class="input" value="<?php $f = $field->name; echo form_prep($query->$f); ?>" name="<?php echo $field->name; ?>" size="60" /></td>
- <?php endif; ?>
-
-</tr>
-<?php endforeach; ?>
-</table>
-
-<input type="submit" class="submit" value="Update" />
-
-</form>
-
-<?php $this->load->view('footer');
-/* End of file edit.php */
+<?php $this->load->view('header'); ?>
+
+
+<p><?php echo anchor(array($base_uri, 'view'), '&lt; '.$scaff_view_all);?></p>
+
+
+<?php echo form_open($action); ?>
+
+<table border="0" cellpadding="3" cellspacing="1">
+<?php foreach($fields as $field): ?>
+
+<?php if ($field->primary_key == 1) continue; ?>
+
+<tr>
+ <td><?php echo $field->name; ?></td>
+
+ <?php if ($field->type == 'blob'): ?>
+ <td><textarea class="textarea" name="<?php echo $field->name;?>" cols="60" rows="10" ><?php $f = $field->name; echo form_prep($query->$f); ?></textarea></td>
+ <?php else : ?>
+ <td><input class="input" value="<?php $f = $field->name; echo form_prep($query->$f); ?>" name="<?php echo $field->name; ?>" size="60" /></td>
+ <?php endif; ?>
+
+</tr>
+<?php endforeach; ?>
+</table>
+
+<input type="submit" class="submit" value="Update" />
+
+</form>
+
+<?php $this->load->view('footer');
+/* End of file edit.php */
/* Location: ./system/scaffolding/views/edit.php */ \ No newline at end of file
diff --git a/system/scaffolding/views/header.php b/system/scaffolding/views/header.php
index 50f234a49..a1621ff3c 100644
--- a/system/scaffolding/views/header.php
+++ b/system/scaffolding/views/header.php
@@ -1,29 +1,29 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html>
-<head>
-
-<title><?php echo $title; ?></title>
-
-<style type='text/css'>
-<?php $this->file(BASEPATH.'scaffolding/views/stylesheet.css'); ?>
-</style>
-
-<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
-<meta http-equiv='expires' content='-1' />
-<meta http-equiv= 'pragma' content='no-cache' />
-
-</head>
-<body>
-
-<div id="header">
-<div id="header_left">
-<h3>Scaffolding:&nbsp; <?php echo $title; ?></h3>
-</div>
-<div id="header_right">
-<?php echo anchor(array($base_uri, 'view'), $scaff_view_records); ?> &nbsp;&nbsp;|&nbsp;&nbsp;
-<?php echo anchor(array($base_uri, 'add'), $scaff_create_record); ?>
-</div>
-</div>
-
-<br clear="all">
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html>
+<head>
+
+<title><?php echo $title; ?></title>
+
+<style type='text/css'>
+<?php $this->file(BASEPATH.'scaffolding/views/stylesheet.css'); ?>
+</style>
+
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+<meta http-equiv='expires' content='-1' />
+<meta http-equiv= 'pragma' content='no-cache' />
+
+</head>
+<body>
+
+<div id="header">
+<div id="header_left">
+<h3>Scaffolding:&nbsp; <?php echo $title; ?></h3>
+</div>
+<div id="header_right">
+<?php echo anchor(array($base_uri, 'view'), $scaff_view_records); ?> &nbsp;&nbsp;|&nbsp;&nbsp;
+<?php echo anchor(array($base_uri, 'add'), $scaff_create_record); ?>
+</div>
+</div>
+
+<br clear="all">
<div id="outer"> \ No newline at end of file
diff --git a/system/scaffolding/views/no_data.php b/system/scaffolding/views/no_data.php
index bc81e7480..963341b70 100644
--- a/system/scaffolding/views/no_data.php
+++ b/system/scaffolding/views/no_data.php
@@ -1,8 +1,8 @@
-<?php $this->load->view('header'); ?>
-
-<p><?php echo $scaff_no_data; ?></p>
-<p><?php echo anchor(array($base_uri, 'add'), $scaff_create_record); ?></p>
-
-<?php $this->load->view('footer');
-/* End of file no_data.php */
+<?php $this->load->view('header'); ?>
+
+<p><?php echo $scaff_no_data; ?></p>
+<p><?php echo anchor(array($base_uri, 'add'), $scaff_create_record); ?></p>
+
+<?php $this->load->view('footer');
+/* End of file no_data.php */
/* Location: ./system/scaffolding/views/no_data.php */ \ No newline at end of file
diff --git a/system/scaffolding/views/view.php b/system/scaffolding/views/view.php
index a81241d39..69c1f45d8 100644
--- a/system/scaffolding/views/view.php
+++ b/system/scaffolding/views/view.php
@@ -1,27 +1,27 @@
-<?php $this->load->view('header'); ?>
-
-<table border="0" cellpadding="0" cellspacing="1" style="width:100%">
- <tr>
- <th>Edit</th>
- <th>Delete</th>
- <?php foreach($fields as $field): ?>
- <th><?php echo $field; ?></th>
- <?php endforeach; ?>
-</tr>
-
-<?php foreach($query->result() as $row): ?>
- <tr>
- <td>&nbsp;<?php echo anchor(array($base_uri, 'edit', $row->$primary), $scaff_edit); ?>&nbsp;</td>
- <td><?php echo anchor(array($base_uri, 'delete', $row->$primary), $scaff_delete); ?></td>
- <?php foreach($fields as $field): ?>
- <td><?php echo form_prep($row->$field);?></td>
- <?php endforeach; ?>
- </tr>
-<?php endforeach; ?>
-</table>
-
-<?php echo $paginate; ?>
-
-<?php $this->load->view('footer');
-/* End of file view.php */
+<?php $this->load->view('header'); ?>
+
+<table border="0" cellpadding="0" cellspacing="1" style="width:100%">
+ <tr>
+ <th>Edit</th>
+ <th>Delete</th>
+ <?php foreach($fields as $field): ?>
+ <th><?php echo $field; ?></th>
+ <?php endforeach; ?>
+</tr>
+
+<?php foreach($query->result() as $row): ?>
+ <tr>
+ <td>&nbsp;<?php echo anchor(array($base_uri, 'edit', $row->$primary), $scaff_edit); ?>&nbsp;</td>
+ <td><?php echo anchor(array($base_uri, 'delete', $row->$primary), $scaff_delete); ?></td>
+ <?php foreach($fields as $field): ?>
+ <td><?php echo form_prep($row->$field);?></td>
+ <?php endforeach; ?>
+ </tr>
+<?php endforeach; ?>
+</table>
+
+<?php echo $paginate; ?>
+
+<?php $this->load->view('footer');
+/* End of file view.php */
/* Location: ./system/scaffolding/views/view.php */ \ No newline at end of file
diff --git a/user_guide/changelog.html b/user_guide/changelog.html
index cde5f436c..89ec0ac5f 100644
--- a/user_guide/changelog.html
+++ b/user_guide/changelog.html
@@ -1,956 +1,956 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
-<head>
-
-<style type='text/css' media='all'>@import url('userguide.css');</style>
-<link rel='stylesheet' type='text/css' media='all' href='userguide.css' />
-
-<script type="text/javascript" src="./nav/nav.js"></script>
-<script type="text/javascript" src="./nav/prototype.lite.js"></script>
-<script type="text/javascript" src="./nav/moo.fx.js"></script>
-<script type="text/javascript" src="./nav/user_guide_menu.js"></script>
-
-<meta http-equiv='expires' content='-1' />
-<meta http-equiv= 'pragma' content='no-cache' />
-<meta name='robots' content='all' />
-<meta name='author' content='ExpressionEngine Dev Team' />
-<meta name='description' content='CodeIgniter User Guide' />
-
-<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
-<title>Change Log : CodeIgniter User Guide</title>
-
-</head>
-<body>
-
-<!-- START NAVIGATION -->
-<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('./');</script></div></div>
-<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="./images/nav_toggle_darker.jpg" width="154" height="43" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
-<div id="masthead">
-<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
-<tr>
-<td><h1>CodeIgniter User Guide Version 1.7</h1></td>
-<td id="breadcrumb_right"><a href="./toc.html">Table of Contents Page</a></td>
-</tr>
-</table>
-</div>
-<!-- END NAVIGATION -->
-
-
-<!-- START BREADCRUMB -->
-<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
-<tr>
-<td id="breadcrumb">
-<a href="http://codeigniter.com/">CodeIgniter Home</a> &nbsp;&#8250;&nbsp;
-<a href="index.html">User Guide Home</a> &nbsp;&#8250;&nbsp;
-Change Log
-</td>
-<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide&nbsp; <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" />&nbsp;<input type="submit" class="submit" name="sa" value="Go" /></form></td>
-</tr>
-</table>
-<!-- END BREADCRUMB -->
-
-<br clear="all" />
-
-
-<!-- START CONTENT -->
-<div id="content">
-
-<h1>Change Log</h1>
-
-<h2>Version 1.7.1</h2>
-<p>Release Date: not yet released<br />
-SVN Revision: </p>
-
-<ul>
- <li>Libraries
- <ul>
- <li>Changed default current page indicator in the Pagination library to use &lt;strong&gt; instead of &lt;b&gt;</li>
- <li>A "HTTP/1.1 400 Bad Request" header is now sent when disallowed characters are encountered.</li>
- <li>Added &lt;big&gt;, &lt;small&gt;, &lt;q&gt;, and &lt;tt&gt; to the Typography parser's inline elements.</li>
- </ul>
- </li>
- <li>Helpers
- <ul>
- <li>Added a doctype() function to the <a href="helpers/html_helper.html">HTML helper</a>.</li>
- </ul>
- </li>
-</ul>
-
-<h3>Bug fixes for 1.7.1</h3>
-<ul>
- <li>Fixed a bug in the MySQLi driver when no port is specified</li>
- <li>Fixed a bug (#5702), in which the field label was not being fetched properly, when "matching" one field to another.</li>
- <li>Fixed a bug in which identifers were not being escaped properly when reserved characters were used.</li>
- <li>Fixed a bug with the regular expression used to protect submitted paragraph tags in auto typography.</li>
- <li>Fixed a bug where double dashes within tag attributes were being converted to em dash entities.</li>
- <li>Fixed a bug where double spaces within tag attributes were being converted to non-breaking space entities.</li>
- <li>Changed a few docblock comments to reflect actual return values.</li>
-</ul>
-
-
-<h2>Version 1.7</h2>
-<p>Release Date: October 23, 2008<br />
-SVN Revision: 1541</p>
-
-<ul>
- <li>Libraries
- <ul>
- <li>Added a new <a href="libraries/form_validation.html">Form Validation Class</a>. It simplifies setting rules and field names, supports arrays as field names, allows groups of validation rules to be saved in a config file, and adds some helper functions for use in view files. <strong>Please note that the old Validation class is now deprecated</strong>. We will leave it in the library folder for some time so that existing applications that use it will not break, but you are encouraged to migrate to the new version.</li>
- <li>Updated the <a href="libraries/sessions.html">Sessions class</a> so that any custom data being saved gets stored to a database rather than the session cookie (assuming you are using a database to store session data), permitting much more data to be saved.</li>
- <li>Added the ability to store libraries in subdirectories within either the main "libraries" or the local application "libraries" folder. Please see the <a href="libraries/loader.html">Loader class</a> for more info.</li>
- <li>Added the ability to assign library objects to your own variable names when you use <kbd>$this->load->library()</kbd>. Please see the <a href="libraries/loader.html">Loader class</a> for more info.</li>
- <li>Added controller class/method info to <a href="general/profiling.html">Profiler class</a> and support for multiple database connections.</li>
- <li>Improved the "auto typography" feature and moved it out of the helper into its own <a href="libraries/typography.html">Typography Class</a>.</li>
- <li>Improved performance and accuracy of <kbd>xss_clean()</kbd>, including reduction of false positives on image/file tests.</li>
- <li>Improved <a href="./libraries/parser.html">Parser class</a> to allow multiple calls to the parse() function. The output of each is appended in the output.</li>
- <li>Added <dfn>max_filename</dfn> option to set a file name length limit in the <a href="libraries/file_uploading.html">File Upload Class</a>.</li>
- <li>Added <dfn>set_status_header()</dfn> function to <a href="libraries/output.html">Output class</a>.</li>
- <li>Modified <a href="libraries/pagination.html">Pagination</a> class to only output the "First" link when the link for page one would not be shown.</li>
- <li>Added support for mb_strlen in the <a href="libraries/form_validation.html">Form Validation</a> class so that multi-byte languages will calculate string lengths properly.</li>
- </ul>
- </li>
- <li>Database
- <ul>
- <li>Improved Active Record class to allow full path column and table names: hostname.database.table.column. Also improved the alias handling.</li>
- <li>Improved how table and column names are escaped and prefixed. It now honors full path names when adding prefixes and escaping.</li>
- <li>Added Active Record caching feature to "update" and "delete" functions.</li>
- <li>Added removal of non-printing control characters in <kbd>escape_str()</kbd> of DB drivers that do not have native PHP escaping mechanisms (mssql, oci8, odbc), to avoid potential SQL errors, and possible sources of SQL injection.</li>
- <li>Added port support to MySQL, MySQLi, and MS SQL database drivers.</li>
- <li>Added driver name variable in each DB driver, based on bug report #4436.</li>
- </ul>
- </li>
- <li>Helpers
- <ul>
- <li>Added several new "setting" functions to the <a href="helpers/form_helper.html">Form helper</a> that allow POST data to be retrieved and set into forms. These are intended to be used on their own, or with the new <a href="libraries/form_validation.html">Form Validation Class</a>.</li>
- <li>Added <kbd>current_url()</kbd> and uri_segments() to <a href="helpers/url_helper.html">URL helper</a>.</li>
- <li>Altered <kbd>auto_link()</kbd> in the <a href="helpers/url_helper.html">URL helper</a> so that email addresses with "+" included will be linked.</li>
- <li>Added <kbd>meta()</kbd> function to <a href="helpers/html_helper.html">HTML helper</a>.</li>
- <li>Improved accuracy of calculations in <a href="helpers/number_helper.html">Number helper</a>.</li>
- <li>Removed added newlines ("\n") from most form and html helper functions.</li>
- <li>Tightened up validation in the <a href="helpers/date_helper.html">Date helper</a> function <kbd>human_to_unix()</kbd>, and eliminated the POSIX regex.</li>
- <li>Updated <a href="helpers/date_helper.html">Date helper</a> to match the world's current time zones and offsets.</li>
- <li>Modified url_title() in the <a href="helpers/url_helper.html">URL helper</a> to remove characters and digits that are part of
- character entities, to allow dashes, underscores, and periods regardless of the $separator, and to allow uppercase characters.</li>
- <li>Added support for arbitrary attributes in anchor_popup() of the <a href="helpers/url_helper.html">URL helper</a>.</li>
- </ul>
- </li>
- <li>Other Changes
- <ul>
- <li>Added <a href="./general/styleguide.html">PHP Style Guide</a> to docs.</li>
- <li>Added sanitization in <kbd>xss_clean()</kbd> for a deprecated HTML tag that could be abused in user input in Internet Explorer.</li>
- <li>Added a few openxml document mime types, and an additional mobile agent to mimes.php and user_agents.php respectively.</li>
- <li>Added a file lock check during caching, before trying to write to the file.</li>
- <li>Modified Cookie key cleaning to unset a few troublesome key names that can be present in certain environments, preventing CI from halting execution.</li>
- <li>Changed the output of the profiler to use style attribute rather than clear, and added the id "codeigniter_profiler" to the container div.</li>
- </ul>
- </li>
-</ul>
-
-<h3>Bug fixes for 1.7.0</h3>
-<ul>
- <li>Fixed bug in <kbd>xss_clean()</kbd> that could remove some desirable tag attributes.</li>
- <li>Fixed assorted user guide typos or examples (#4807, #4812, #4840, #4862, #4864, #4899, #4930, #5006, #5071, #5158, #5229, #5254, #5351).</li>
- <li>Fixed an edit from 1.6.3 that made the $robots array in user_agents.php go poof.</li>
- <li>Fixed a bug in the <a href="libraries/email.html">Email library</a> with quoted-printable encoding improperly encoding space and tab characters.</li>
- <li>Modified XSS sanitization to no longer add semicolons after &amp;[single letter], such as in M&amp;M's, B&amp;B, etc.</li>
- <li>Modified XSS sanitization to no longer strip XHTML image tags of closing slashes.</li>
- <li>Fixed a bug in the Session class when database sessions are used where upon session update all userdata would be errantly written to the session cookie.</li>
- <li>Fixed a bug (#4536) in backups with the MySQL driver where some legacy code was causing certain characters to be double escaped.</li>
- <li>Fixed a routing bug (#4661) that occurred when the default route pointed to a subfolder.</li>
- <li>Fixed the spelling of "Dhaka" in the <kbd>timezone_menu()</kbd> function of the <a href="helpers/date_helper.html">Date helper.</a></li>
- <li>Fixed the spelling of "raspberry" in config/smileys.php.</li>
- <li>Fixed incorrect parenthesis in <kbd>form_open()</kbd> function (#5135).</li>
- <li>Fixed a bug that was ignoring case when comparing controller methods (#4560).</li>
- <li>Fixed a bug (#4615) that was not setting SMTP authorization settings when using the initialize function.</li>
- <li>Fixed a bug in <kbd>highlight_code()</kbd> in the <a href="helpers/text_helper.html">Text helper</a> that would leave a stray &lt;/span&gt; in certain cases.</li>
- <li>Fixed Oracle bug (#3306) that was preventing multiple queries in one action.</li>
- <li>Fixed ODBC bug that was ignoring connection params due to its use of a constructor.</li>
- <li>Fixed a DB driver bug with num_rows() that would cause an error with the Oracle driver.</li>
- <li>Fixed MS SQL bug (#4915). Added brackets around database name in MS SQL driver when selecting the database, in the event that reserved characters are used in the name.</li>
- <li>Fixed a DB caching bug (4718) in which the path was incorrect when no URI segments were present.</li>
- <li>Fixed Image_lib class bug #4562. A path was not defined for NetPBM.</li>
- <li>Fixed Image_lib class bug #4532. When cropping an image with identical height/width settings on output, a copy is made.</li>
- <li>Fixed DB_driver bug (4900), in which a database error was not being logged correctly.</li>
- <li>Fixed DB backup bug in which field names were not being escaped.</li>
- <li>Fixed a DB Active Record caching bug in which multiple calls to cached data were not being honored.</li>
- <li>Fixed a bug in the Session class that was disallowing slashes in the serialized array.</li>
- <li>Fixed a Form Validation bug in which the "isset" error message was being trigged by the "required" rule.</li>
- <li>Fixed a spelling error in a Loader error message.</li>
- <li>Fixed a bug (5050) with IP validation with empty segments.</li>
- <li>Fixed a bug in which the parser was being greedy if multiple identical sets of tags were enountered.</li>
-</ul>
-
-<h2>Version 1.6.3</h2>
-<p>Release Date: June 26, 2008<br />
-SVN Revision: 1238</p>
-<p>Version 1.6.3 is a security and maintenance release and is recommended for all users.</p>
-<ul>
- <li>Database
- <ul>
- <li>Modified MySQL/MySQLi Forge class to give explicit names to keys</li>
- <li>Added ability to set multiple column non-primary keys to the <a href="database/forge.html">Forge class</a></li>
- <li>Added ability to set additional database config values in <a href="database/connecting.html">DSN connections</a> via the query string.</li>
- </ul>
- </li>
- <li>Libraries
- <ul>
- <li>Set the mime type check in the <a href="libraries/file_uploading.html">Upload class</a> to reference the global mimes variable.</li>
- <li>Added support for query strings to the <a href="libraries/pagination.html">Pagination class</a>, automatically detected or explicitly declared.</li>
- <li>Added <kbd>get_post()</kbd> to the <a href="libraries/input.html">Input class</a>.</li>
- <li>Documented <kbd>get()</kbd> in the <a href="libraries/input.html">Input class</a>.</li>
- <li>Added the ability to automatically output language items as form labels in the <a href="libraries/language.html">Language class</a>.</li>
- </ul>
- </li>
- <li>Helpers
- <ul>
- <li>Added a <a href="helpers/language_helper.html">Language helper</a>.</li>
- <li>Added a <a href="helpers/number_helper.html">Number helper</a>.</li>
- <li><a href="helpers/form_helper.html">Form helper</a> refactored to allow <kbd>form_open()</kbd> and <kbd>form_fieldset()</kbd> to accept arrays or strings as arguments.</li>
- </ul>
- </li>
- <li>Other changes
- <ul>
- <li>Improved security in <kbd>xss_clean()</kbd>.</li>
- <li>Removed an unused Router reference in <kbd>_display_cache()</kbd>.</li>
- <li>Added ability to <a href="libraries/input.html">use xss_clean() to test images</a> for XSS, useful for upload security.</li>
- <li>Considerably expanded list of mobile user-agents in config/user_agents.php.</li>
- <li>Charset information in the userguide has been moved above title for internationalization purposes (#4614).</li>
- <li>Added &quot;Using Associative Arrays In a Request Parameter&quot; example to the <a href="libraries/xmlrpc.html">XMLRPC userguide page</a>.</li>
- <li>Removed maxlength and size as automatically added attributes of form_input() in the <a href="helpers/form_helper.html">form helper</a>.</li>
- <li>Documented the language file use of <kbd>byte_format()</kbd> in the <a href="helpers/number_helper.html">number helper</a>.</li>
- </ul>
- </li>
-</ul>
-
-
-<h3>Bug fixes for 1.6.3</h3>
-
-<ul>
- <li>Added a language key for valid_emails in validation_lang.php.</li>
- <li>Amended fixes for bug (#3419) with parsing DSN database connections.</li>
- <li>Moved the <kbd>_has_operators()</kbd> function (#4535) into DB_driver from DB_active_rec.</li>
- <li>Fixed a syntax error in upload_lang.php.</li>
- <li>Fixed a bug (#4542) with a regular expression in the Image library.</li>
- <li>Fixed a bug (#4561) where <kbd>orhaving()</kbd> wasn't properly passing values.</li>
- <li>Removed some unused variables from the code (#4563).</li>
- <li>Fixed a bug where <kbd>having()</kbd> was not adding an = into the statement (#4568).</li>
- <li>Fixed assorted user guide typos or examples (#4574, #4706).</li>
- <li>Added quoted-printable headers to Email class when the multi-part override is used.</li>
- <li>Fixed a double opening &lt;p&gt; tag in the index pages of each system directory.</li>
-</ul>
-
-<h2>Version 1.6.2</h2>
-<p>Release Date: May 13, 2008<br />
-SVN Revision: 1155</p>
-<ul>
- <li>Active Record
- <ul>
- <li>Added the ability to prevent escaping in <kbd>having()</kbd> clauses.</li>
- <li>Added <kbd>rename_table()</kbd> into <a href="./database/forge.html">DBForge</a>.</li>
- <li>Fixed a bug that wasn't allowing escaping to be turned off if the value of a query was NULL.</li>
- <li>DB Forge is now assigned to any models that exist after loading (#3457).</li>
- </ul>
- </li>
- <li>Database
- <ul>
- <li>Added <a href="./database/transactions.html">Strict Mode</a> to database transactions.</li>
- <li>Escape behaviour in where() clauses has changed; values in those with the &quot;FALSE&quot; argument are no longer escaped (ie: quoted).</li>
- </ul>
- </li>
- <li>Config
- <ul>
- <li>Added 'application/vnd.ms-powerpoint' to list of mime types.</li>
- <li>Added 'audio/mpg' to list of mime types.</li>
- <li>Added new user-modifiable file constants.php containing file mode and fopen constants.</li>
- <li>Added the ability to set CRLF settings via config in the <a href="libraries/email.html">Email</a> class.</li>
- </ul>
- </li>
- <li>Libraries
- <ul>
- <li>Added increased security for filename handling in the Upload library.</li>
- <li>Added increased security for sessions for client-side data tampering.</li>
- <li>The MySQLi forge class is now in sync with MySQL forge. </li>
- <li>Added the ability to set CRLF settings via config in the <a href="libraries/email.html">Email</a> class.</li>
- <li><a href="libraries/unit_testing.html">Unit Testing</a> results are now colour coded, and a change was made to the default template of results.</li>
- <li>Added a valid_emails rule to the <a href="libraries/validation.html">Validation</a> class.</li>
- <li>The <a href="libraries/zip.html">Zip class</a> now exits within <kbd>download()</kbd>.</li>
- <li>The <a href="libraries/zip.html">Zip class</a> has undergone a substantial re-write for speed and clarity (thanks stanleyxu for the hard work and code contribution in bug report #3425!)</li>
- </ul>
- </li>
- <li>Helpers
- <ul>
- <li>Added a <a href="helpers/compatibility_helper.html">Compatibility Helper</a> for using some common PHP 5 functions safely in applications that might run on PHP 4 servers (thanks Seppo for the hard work and code contribution!)</li>
- <li>Added <kbd>form_button()</kbd> in the <a href="helpers/form_helper.html">Form helper</a>.</li>
- <li>Changed the <kbd>radio()</kbd> and <kbd>checkbox()</kbd> functions to default to not checked by default.</li>
- <li>Added the ability to include an optional HTTP Response Code in the <kbd>redirect()</kbd> function of the <a href="helpers/url_helper.html">URL Helper</a>.</li>
- <li>Modified <kbd>img()</kbd> in the <a href="helpers/html_helper.html">HTML Helper</a> to remove an unneeded space (#4208).</li>
- <li>Modified <kbd>anchor()</kbd> in the <a href="helpers/url_helper.html">URL helper</a> to no longer add a default title= attribute (#4209).</li>
- <li>The <a href="helpers/download_helper.html">Download helper</a> now exits within <kbd>force_download()</kbd>.</li>
- <li>Added <kbd>get_dir_file_info()</kbd>, <kbd>get_file_info()</kbd>, and <kbd>get_mime_by_extension()</kbd> to the <a href="helpers/file_helper.html">File Helper</a>.</li>
- <li>Added <kbd>symbolic_permissions()</kbd> and <kbd>octal_permissions()</kbd> to the <a href='helpers/file_helper.html'>File helper</a>.</li>
- </ul>
- </li>
- <li>Plugins
- <ul>
- <li>Modified captcha generation to first look for the function imagecreatetruecolor, and fallback to imagecreate if it isn't available (#4226).</li>
- </ul>
- </li>
- <li>Other
- Changes
- <ul>
- <li>Added ability for <a href="libraries/input.html">xss_clean()</a> to accept arrays.</li>
- <li>Removed closing PHP tags from all PHP files to avoid accidental output and potential 'cannot modify headers' errors.</li>
- <li>Removed &quot;scripts&quot; from the auto-load search path. Scripts were deprecated
- in Version 1.4.1 (September 21, 2006). If you still need to use them for legacy reasons, they must now be manually loaded in each Controller.</li>
- <li>Added a <a href="general/reserved_names.html">Reserved Names</a> page to the userguide, and migrated reserved controller names into it.</li>
- <li>Added a <a href="general/common_functions.html">Common Functions</a> page to the userguide for globally available functions.</li>
- <li>Improved security and performance of xss_clean().</li>
- </ul>
- </li>
- </ul>
-
-<h3>Bugfixes for 1.6.2</h3>
-<ul>
- <li>Fixed a bug where SET queries were not being handled as "write" queries.</li>
- <li>Fixed a bug (#3191) with ORIG_PATH_INFO URI parsing.</li>
- <li>Fixed a bug in DB Forge, when inserting an id field (#3456).</li>
- <li>Fixed a bug in the table library that could cause identically constructed rows to be dropped (#3459).</li>
- <li>Fixed DB Driver and MySQLi result driver checking for resources instead of objects (#3461).</li>
- <li>Fixed an AR_caching error where it wasn't tracking table aliases (#3463).</li>
- <li>Fixed a bug in AR compiling, where select statements with arguments got incorrectly escaped (#3478).</li>
- <li>Fixed an incorrect documentation of $this-&gt;load-&gt;language (#3520).</li>
- <li>Fixed bugs (#3523, #4350) in get_filenames() with recursion and problems with Windows when $include_path is used.</li>
- <li>Fixed a bug (#4153) in the XML-RPC class preventing dateTime.iso8601 from being used.</li>
- <li>Fixed an AR bug with or_where_not_in() (#4171).</li>
- <li>Fixed a bug with <a href="libraries/input.html">xss_clean()</a> that would add semicolons to GET URI variable strings.</li>
- <li>Fixed a bug (#4206) in the Directory Helper where the directory resource was not being closed, and minor improvements.</li>
- <li>Fixed a bug in the FTP library where delete_dir() was not working recursively (#4215).</li>
- <li>Fixed a Validation bug when set_rules() is used with a non-array field name and rule (#4220).</li>
- <li>Fixed a bug (#4223) where DB caching would not work for returned DB objects or multiple DB connections.</li>
- <li>Fixed a bug in the Upload library that might output the same error twice (#4390).</li>
- <li>Fixed an AR bug when joining with a table alias and table prefix (#4400).</li>
- <li>Fixed a bug in the DB class testing the $params argument.</li>
- <li>Fixed a bug in the Table library where the integer 0 in cell data would be displayed as a blank cell.</li>
- <li>Fixed a bug in <kbd>link_tag()</kbd> of the <a href="helpers/url_helper.html">URL helper</a> where a key was passed instead of a value.</li>
- <li>Fixed a bug in DB_result::row() that prevented it from returning individual fields with MySQL NULL values.</li>
- <li>Fixed a bug where SMTP emails were not having dot transformation performed on lines that begin with a dot.</li>
- <li>Fixed a bug in display_error() in the DB driver that was instantiating new Language and Exception objects, and not using the error heading.</li>
- <li>Fixed a bug (#4413) where a URI containing slashes only e.g. 'http://example.com/index.php?//' would result in PHP errors</li>
- <li>Fixed an array to string conversion error in the Validation library (#4425)</li>
- <li>Fixed bug (#4451, #4299, #4339) where failed transactions will not rollback when debug mode is enabled.</li>
- <li>Fixed a bug (#4506) with overlay_watermark() in the Image library preventing support for PNG-24s with alpha transparency</li>
- <li>Fixed assorted user guide typos (#3453, #4364, #4379, #4399, #4408, #4412, #4448, #4488).</li>
- </ul>
-
-<h2>Version 1.6.1</h2>
-<p>Release Date: February 12, 2008<br />
- SVN Revision: 984</p>
-<ul>
- <li>Active Record
- <ul>
- <li>Added <a href="./database/active_record.html#caching">Active Record Caching</a>.</li>
- <li>Made Active Record fully database-prefix aware.</li>
- </ul>
- </li>
- <li>Database drivers
- <ul>
- <li>Added support for setting client character set and collation for MySQLi.</li>
- </ul>
- </li>
- <li>Core Changes
- <ul>
- <li>Modified <kbd>xss_clean()</kbd> to be more intelligent with its handling of URL encoded strings.</li>
- <li>Added $_SERVER, $_FILES, $_ENV, and $_SESSION to sanitization of globals.</li>
- <li>Added a <a href="./helpers/path_helper.html">Path Helper</a>.</li>
- <li>Simplified <kbd>_reindex_segments()</kbd> in the URI class.</li>
- <li>Escaped the '-' in the default 'permitted_uri_chars' config item, to prevent errors if developers just try to add additional characters to the end of the default expression.</li>
- <li>Modified method calling to controllers to show a 404 when a private or protected method is accessed via a URL.</li>
- <li>Modified framework initiated 404s to log the controller and method for invalid requests.</li>
- </ul>
- </li>
- <li>Helpers
- <ul>
- <li>Modified <kbd>get_filenames()</kbd> in the File Helper to return FALSE if the $source_dir is not readable.</li>
- </ul>
- </li>
-</ul>
-
-
-<h3>Bugfixes for 1.6.1</h3>
-<ul>
- <li>Deprecated is_numeric as a validation rule. Use of numeric and integer are preferred.</li>
- <li>Fixed bug (#3379) in DBForge with SQLite for table creation.</li>
- <li>Made Active Record fully database prefix aware (#3384).</li>
- <li>Fixed a bug where DBForge was outputting invalid SQL in Postgres by adding brackets around the tables in FROM.</li>
- <li>Changed the behaviour of Active Record's update() to make the WHERE clause optional (#3395).</li>
- <li>Fixed a bug (#3396) where certain POST variables would cause a PHP warning.</li>
- <li>Fixed a bug in query binding (#3402).</li>
- <li>Changed order of SQL keywords in the Profiler $highlight array so OR would not be highlighted before ORDER BY.</li>
- <li>Fixed a bug (#3404) where the MySQLi driver was testing if $this->conn_id was a resource instead of an object.</li>
- <li>Fixed a bug (#3419) connecting to a database via a DSN string.</li>
- <li>Fixed a bug (#3445) where the routed segment array was not re-indexed to begin with 1 when the default controller is used.</li>
- <li>Fixed assorted user guide typos.</li>
-</ul>
-
-
-
-<h2>Version 1.6.0</h2>
-<p>Release Date: January 30, 2008 </p>
-<ul>
- <li>DBForge
- <ul>
- <li>Added <a href="./database/forge.html">DBForge</a> to the database tools.</li>
- <li>Moved <kbd>create_database()</kbd> and <kbd>drop_database()</kbd> into <a href="./database/forge.html">DBForge</a>.</li>
- <li>Added <kbd>add_field()</kbd>, <kbd>add_key()</kbd>, <kbd>create_table()</kbd>, <kbd>drop_table()</kbd>, <kbd>add_column()</kbd>, <kbd>drop_column()</kbd>, <kbd>modify_column()</kbd> into <a href="./database/forge.html">DBForge</a>.</li>
- </ul>
- </li>
-
- <li>Active Record
- <ul>
- <li>Added <kbd>protect_identifiers()</kbd> in <a href="./database/active_record.html">Active Record</a>.</li>
- <li>All AR queries are backticked if appropriate to the database.</li>
- <li>Added <kbd>where_in()</kbd>, <kbd>or_where_in()</kbd>, <kbd>where_not_in()</kbd>, <kbd>or_where_not_in()</kbd>, <kbd>not_like()</kbd> and <kbd>or_not_like()</kbd> to <a href="./database/active_record.html">Active Record</a>.</li>
- <li>Added support for <kbd>limit()</kbd> into <kbd>update()</kbd> and <kbd>delete()</kbd> statements in <a href="./database/active_record.html">Active Record</a>.</li>
- <li>Added <kbd>empty_table()</kbd> and <kbd>truncate_table()</kbd> to <a href="./database/active_record.html">Active Record</a>.</li>
- <li>Added the ability to pass an array of tables to the <kbd>delete()</kbd> statement in <a href="./database/active_record.html">Active Record</a>.</li>
- <li>Added <kbd>count_all_results()</kbd> function to <a href="./database/active_record.html">Active Record</a>.</li>
- <li>Added <kbd>select_max()</kbd>, <kbd>select_min()</kbd>, <kbd>select_avg()</kbd> and <kbd>select_sum()</kbd> to <a href="./database/active_record.html">Active Record</a>.</li>
- <li>Added the ability to use aliases with joins in <a href="./database/active_record.html">Active Record</a>.</li>
- <li>Added a third parameter to Active Record's <kbd>like()</kbd> clause to control where the wildcard goes. </li>
- <li>Added a third parameter to <kbd>set()</kbd> in <a href="./database/active_record.html">Active Record</a> that withholds escaping data.</li>
- <li>Changed the behaviour of variables submitted to the where() clause with no values to auto set &quot;IS NULL&quot;</li>
- </ul>
- </li>
-
- <li>Other Database Related
- <ul>
- <li>MySQL driver now requires MySQL 4.1+</li>
- <li>Added $this->DB->save_queries variable to DB driver, enabling queries to get saved or not. Previously they were always saved.</li>
- <li>Added $this->db->dbprefix() to manually add database prefixes.</li>
- <li>Added 'random' as an <kbd>order_by()</kbd> option , and removed &quot;rand()&quot; as a listed option as it was MySQL only.</li>
- <li>Added a check for NULL fields in the MySQL database backup utility.</li>
- <li>Added &quot;constrain_by_prefix&quot; parameter to db-&gt;list_table() function. If set to TRUE it will limit the result to only table names with the current prefix.</li>
- <li>Deprecated from Active Record; <kbd>getwhere()</kbd> for <kbd>get_where()</kbd>; <kbd>groupby()</kbd> for <kbd>group_by()</kbd>; <kbd>havingor()</kbd> for <kbd>having_or()</kbd>; <kbd>orderby()</kbd> for <kbd>order_by</kbd>; <kbd>orwhere()</kbd> for <kbd>or_where()</kbd>; and <kbd>orlike()</kbd> for <kbd>or_like()</kbd>.</li>
- <li>Modified <kbd>csv_from_result()</kbd> to output CSV data more in the spirit of basic rules of RFC 4180.</li>
- <li>Added 'char_set' and 'dbcollat' database configuration settings, to explicitly set the client communication properly.</li>
- <li>Removed 'active_r' configuration setting and replaced with a global $active_record setting, which is more
- in harmony with the global nature of the behavior (#1834).</li>
- </ul>
- </li>
-
- <li>Core changes
- <ul>
- <li>Added ability to load multiple views, whose content will be appended to the output in the order loaded.</li>
- <li>Added the ability to <a href="./general/autoloader.html">auto-load</a> <a href="./general/models.html">Models</a>.</li>
- <li>Reorganized the URI and Routes classes for better clarity.</li>
- <li>Added Compat.php to allow function overrides for older versions of PHP or PHP environments missing certain extensions / libraries</li>
- <li>Added memory usage, GET, URI string data, and individual query execution time to Profiler output.</li>
- <li>Deprecated Scaffolding.</li>
- <li>Added is_really_writable() to Common.php to provide a cross-platform reliable method of testing file/folder writability.</li>
- </ul>
- </li>
-
- <li>Libraries
- <ul>
- <li>Changed the load protocol of Models to allow for extension.</li>
- <li>Strengthened the Encryption library to help protect against man in the middle attacks when MCRYPT_MODE_CBC mode is used.</li>
- <li>Added Flashdata variables, session_id regeneration and configurable session update times to the <a href="./libraries/sessions.html">Session class.</a></li>
- <li>Removed 'last_visit' from the Session class.</li>
- <li>Added a language entry for valid_ip validation error.</li>
- <li>Modified prep_for_form() in the Validation class to accept arrays, adding support for POST array validation (via callbacks only)</li>
- <li>Added an &quot;integer&quot; rule into the <a href="./libraries/validation.html">Validation</a> library.</li>
- <li>Added valid_base64() to the <a href="./libraries/validation.html">Validation</a> library.</li>
- <li>Documented clear() in the <a href="../libraries/image_lib.html">Image Processing</a> library.</li>
- <li>Changed the behaviour of custom callbacks so that they no longer trigger the &quot;required&quot; rule. </li>
- <li>Modified Upload class $_FILES error messages to be more precise.</li>
- <li>Moved the safe mode and auth checks for the Email library into the constructor. </li>
- <li>Modified variable names in _ci_load() method of Loader class to avoid conflicts with view variables.</li>
- <li>Added a few additional mime type variations for CSV.</li>
- <li>Enabled the 'system' methods for the XML-RPC Server library, except for 'system.multicall' which is still disabled.</li>
- </ul>
- </li>
-
- <li>Helpers &amp; Plugins
- <ul>
- <li>Added link_tag() to the <a href="./helpers/html_helper.html">HTML helper.</a></li>
- <li>Added img() to the <a href="./helpers/html_helper.html">HTML helper.</a></li>
- <li>Added ability to <a href="./general/helpers.html">"extend" Helpers</a>.</li>
- <li>Added an <a href="./helpers/email_helper.html">email helper</a> into core helpers.</li>
- <li>Added <kbd>strip_quotes()</kbd> function to <a href="./helpers/string_helper.html">string helper</a>.</li>
- <li>Added <kbd>reduce_multiples()</kbd> function to <a href="./helpers/string_helper.html">string helper</a>.</li>
- <li>Added <kbd>quotes_to_entities()</kbd> function to <a href="./helpers/string_helper.html">string helper</a>.</li>
- <li>Added <kbd>form_fieldset()</kbd>, <kbd>form_fieldset_close()</kbd>, <kbd>form_label()</kbd>, and <kbd>form_reset()</kbd> function to <a href="./helpers/form_helper.html">form helper</a>.</li>
- <li>Added support for external urls in <kbd>form_open()</kbd>.</li>
- <li>Removed support for db_backup in MySQLi due to incompatible functions.</li>
- <li>Javascript Calendar plugin now uses the months and days from the calendar language file, instead of hard-coded values, internationalizing it.</li>
- </ul>
- </li>
-
-
- <li>Documentation Changes
- <ul>
- <li>Added <a href="./doc_style/index.html">Writing Documentation</a> section for the community to use in writing their own documentation.</li>
- <li>Added titles to all user manual pages.</li>
- <li>Added attributes into &lt;html&gt; of userguide for valid html.</li>
- <li>Added <a href="http://codeigniter.com/user_guide/libraries/zip.html">Zip Encoding Class</a> to the table of contents of the userguide.</li>
- <li>Moved part of the userguide menu javascript to an external file.</li>
- <li>Documented <kbd>distinct()</kbd> in <a href="./database/active_record.html">Active Record</a>. </li>
- <li>Documented the <kbd>timezones()</kbd> function in the <a href="./helpers/date_helper.html">Date Helper</a>.</li>
- <li>Documented unset_userdata in the <a href="./libraries/sessions.html">Session class</a>.</li>
- <li>Documented 2 config options to the <a href="./database/configuration.html">Database configuration</a> page.</li>
- </ul>
- </li>
-</ul>
-
-<h3>Bug fixes for Version 1.6.0</h3>
-
-<ul>
- <li>Fixed a bug (#1813) preventing using $CI->db in the same application with returned database objects.</li>
- <li>Fixed a bug (#1842) where the $this->uri->rsegments array would not include the 'index' method if routed to the controller without an implicit method.</li>
- <li>Fixed a bug (#1872) where word_limiter() was not retaining whitespace.</li>
- <li>Fixed a bug (#1890) in csv_from_result() where content that included the delimiter would break the file.</li>
- <li>Fixed a bug (#2542)in the clean_email() method of the Email class to allow for non-numeric / non-sequential array keys.</li>
- <li>Fixed a bug (#2545) in <kbd>_html_entity_decode_callback()</kbd> when 'global_xss_filtering' is enabled.</li>
- <li>Fixed a bug (#2668) in the <a href="./libraries/parser.html">parser class</a> where numeric data was ignored.</li>
- <li>Fixed a bug (#2679) where the &quot;previous&quot; pagination link would get drawn on the first page.</li>
- <li>Fixed a bug (#2702) in _object_to_array that broke some types of inserts and updates.</li>
- <li>Fixed a bug (#2732) in the SQLite driver for PHP 4.</li>
- <li>Fixed a bug (#2754) in Pagination to scan for non-positive num_links.</li>
- <li>Fixed a bug (#2762) in the <a href="./libraries/sessions.html">Session library</a> where user agent matching would fail on user agents ending with a space. </li>
- <li>Fixed a bug (#2784) $field_names[] vs $Ffield_names[] in postgres and sqlite drivers.</li>
- <li>Fixed a bug (#2810) in the typography helper causing extraneous paragraph tags when string contains tags.</li>
- <li>Fixed a bug (#2849) where arguments passed to a subfolder controller method would be incorrectly shifted, dropping the 3rd segment value.</li>
- <li>Fixed a bug (#2858) which referenced a wrong variable in the Image class.</li>
- <li>Fixed a bug (#2875)when loading plugin files as _plugin. and not _pi.</li>
- <li>Fixed a bug (#2912) in <kbd>get_filenames()</kbd> in the <a href="./helpers/file_helper.html">File Helper </a>where the array wasn't cleared after each call.</li>
- <li>Fixed a bug (#2974) in <kbd>highlight_phrase()</kbd> that caused an error with slashes.</li>
- <li>Fixed a bug (#3003) in the Encryption Library to support modes other than MCRYPT_MODE_ECB</li>
- <li>Fixed a bug (#3015) in the <a href="./libraries/user_agent.html">User Agent library</a> where more then 2 languages where not reported with languages().</li>
- <li>Fixed a bug (#3017) in the <a href="./libraries/email.html">Email</a> library where some timezones were calculated incorrectly. </li>
- <li>Fixed a bug (#3024) in which master_dim wasn't getting reset by clear() in the Image library.</li>
- <li>Fixed a bug (#3156) in Text Helper highlight_code() causing PHP tags to be handled incorrectly.</li>
- <li>Fixed a bug (#3166) that prevented num_rows from working in Oracle.</li>
- <li>Fixed a bug (#3175) preventing certain libraries from working properly when autoloaded in PHP 4.</li>
- <li>Fixed a bug (#3267) in the Typography Helper where unordered list was listed &quot;un.</li>
- <li>Fixed a bug (#3268) where the Router could leave '/' as the path.</li>
- <li>Fixed a bug (#3279) where the Email class was sending the wrong Content-Transfer-Encoding for some character sets.</li>
- <li>Fixed a bug (#3284) where the rsegment array would not be set properly if the requested URI contained more segments than the routed URI.</li>
- <li>Removed extraneous load of $CFG in _display_cache() of the Output class (#3285).</li>
- <li>Removed an extraneous call to loading models (#3286).</li>
- <li>Fixed a bug (#3310) with sanitization of globals in the Input class that could unset CI's global variables.</li>
- <li>Fixed a bug (#3314) which would cause the top level path to be deleted in delete_files() of the File helper.</li>
- <li>Fixed a bug (#3328) where the smiley helper might return an undefined variable.</li>
- <li>Fixed a bug (#3330) in the FTP class where a comparison wasn't getting made.</li>
- <li>Removed an unused parameter from Profiler (#3332).</li>
- <li>Fixed a bug in database driver where num_rows property wasn't getting updated.</li>
- <li>Fixed a bug in the <a href="./libraries/file_uploading.html">upload library</a> when allowed_files wasn't defined.</li>
- <li>Fixed a bug in <kbd>word_wrap()</kbd> of the Text Helper that incorrectly referenced an object. </li>
- <li>Fixed a bug in <a href="./libraries/validation.html">Validation</a> where <kbd>valid_ip()</kbd> wasn't called properly.</li>
- <li>Fixed a bug in <a href="./libraries/validation.html">Validation</a> where individual error messages for checkboxes wasn't supported.</li>
- <li>Fixed a bug in captcha calling an invalid PHP function.</li>
- <li>Fixed a bug in the cookie helper "set_cookie" function. It was not honoring the config settings.</li>
- <li>Fixed a bug that was making validation callbacks required even when not set as such.</li>
- <li>Fixed a bug in the XML-RPC library so if a type is specified, a more intelligent decision is made as to the default type.</li>
- <li>Fixed an example of comma-separated emails in the email library documentation.</li>
- <li>Fixed an example in the Calendar library for Showing Next/Previous Month Links.</li>
- <li>Fixed a typo in the database language file.</li>
- <li>Fixed a typo in the image language file &quot;suppor&quot; to &quot;support&quot;.</li>
- <li>Fixed an example for XML RPC.</li>
- <li>Fixed an example of <kbd>accept_charset()</kbd> in the <a href="./libraries/user_agent.html">User Agent Library</a>.</li>
- <li>Fixed a typo in the docblock comments that had CodeIgniter spelled CodeIgnitor.</li>
- <li>Fixed a typo in the <a href="./helpers/string_helper.html">String Helper</a> (uniquid changed to uniqid).</li>
- <li>Fixed typos in the email Language class (email_attachment_unredable, email_filed_smtp_login), and FTP Class (ftp_unable_to_remame).</li>
- <li>Added a stripslashes() into the Upload Library.</li>
- <li>Fixed a series of grammatical and spelling errors in the language files.</li>
- <li>Fixed assorted user guide typos.</li>
-</ul>
-<h2>Version 1.5.4</h2>
-<p>Release Date: July 12, 2007 </p>
-<ul>
- <li>Added <a href="./libraries/language.html">custom Language files</a> to the <a href="./general/autoloader.html">autoload</a> options. </li>
- <li>Added stripslashes() to the _clean_input_data() function in the <a href="./libraries/input.html">Input class</a> when magic quotes is on so that data will always be un-slashed within the framework.</li>
- <li>Added array to string into the <a href="general/profiling.html">profiler</a>.</li>
- <li>Added some additional mime types in application/config/mimes.php.</li>
- <li>Added filename_security() method to <a href="./libraries/input.html">Input library</a>.</li>
- <li>Added some additional arguments to the <a href="./helpers/inflector_helper.html">Inflection helper</a> singular() to compensate for words ending in "s". Also added a force parameter to pluralize().</li>
- <li>Added $config['charset'] to the config file. Default value is 'UTF-8', used in some string handling functions.</li>
- <li>Fixed MSSQL insert_id().</li>
- <li>Fixed a logic error in the DB trans_status() function. It was incorrectly returning TRUE on failure and FALSE on success.</li>
- <li>Fixed a bug that was allowing multiple load attempts on extended classes.</li>
- <li>Fixed a bug in the bootstrap file that was incorrectly attempting to discern the full server path even when it was explicity set by the user.</li>
- <li>Fixed a bug in the escape_str() function in the MySQL driver.</li>
- <li>Fixed a typo in the <a href="./libraries/calendar.html">Calendar library </a> </li>
- <li>Fixed a typo in rpcs.php library</li>
- <li>Fixed a bug in the <a href="./libraries/zip.html">Zip library</a>, providing PC Zip file compatibility with Mac OS X</li>
- <li>Fixed a bug in router that was ignoring the scaffolding route for optimization </li>
- <li>Fixed an IP validation bug.</li>
- <li>Fixed a bug in display of POST keys in the <a href="./general/profiling.html">Profiler</a> output</li>
- <li>Fixed a bug in display of queries with characters that would be interpreted as HTML in the <a href="./general/profiling.html">Profiler</a> output</li>
- <li>Fixed a bug in display of Email class print debugger with characters that would be interpreted as HTML in the debugging output</li>
- <li>Fixed a bug in the Content-Transfer-Encoding of HTML emails with the quoted-printable MIME type</li>
- <li>Fixed a bug where one could unset certain PHP superglobals by setting them via GET or POST data</li>
- <li>Fixed an undefined function error in the insert_id() function of the PostgreSQL driver</li>
- <li>Fixed various doc typos. </li>
- <li>Documented two functions from the <a href="./helpers/string_helper.html">String helper </a> that were missing from the user guide: trim_slashes() and reduce_double_slashes().</li>
- <li>Docs now validate to XHTML 1 transitional</li>
- <li>Updated the XSS Filtering to take into account the IE expression() ability and improved certain deletions to prevent possible exploits</li>
- <li>Modified the Router so that when Query Strings are Enabled, the controller trigger and function trigger values are sanitized for filename include security.</li>
- <li>Modified the is_image() method in the Upload library to take into account Windows IE 6/7 eccentricities when dealing with MIMEs</li>
- <li>Modified XSS Cleaning routine to be more performance friendly and compatible with PHP 5.2's new PCRE backtrack and recursion limits.</li>
- <li>Modified the <a href="./helpers/url_helper.html">URL Helper</a> to type cast the $title as a string in case a numeric value is supplied</li>
- <li>Modified Form Helper form_dropdown() to type cast the keys and values of the options array as strings, allowing numeric values to be properly set as 'selected'</li>
- <li>Deprecated the use if <kbd>is_numeric()</kbd> in various places since it allows periods. Due to compatibility problems with <kbd>ctype_digit()</kbd>, making it unreliable in some installations, the following regular expression was used instead: <kbd>preg_match("/[^0-9]/", $n)</kbd></li>
- <li>Deprecated: APPVER has been deprecated and replaced with CI_VERSION for clarity. </li>
-</ul>
-<h2>Version 1.5.3</h2>
-<p>Release Date: April 15, 2007 </p>
-<ul>
- <li>Added array to string into the profiler </li>
- <li>Code Igniter references updated to CodeIgniter </li>
- <li>pMachine references updated to EllisLab </li>
- <li>Fixed a bug in the repeater function of <a href="./helpers/string_helper.html">string helper</a>. </li>
- <li>Fixed a bug in ODBC driver </li>
- <li>Fixed a bug in result_array() that was returning an empty array when no result is produced.</li>
- <li>Fixed a bug in the redirect function of the <a href="./helpers/url_helper.html">url helper</a>. </li>
- <li>Fixed an undefined variable in Loader </li>
- <li>Fixed a version bug in the Postgres driver </li>
- <li>Fixed a bug in the textarea function of the form helper for use with strings</li>
- <li>Fixed doc typos. </li>
-</ul>
-<h2>Version 1.5.2</h2>
-<p>Release Date: February 13, 2007 </p>
-<ul>
- <li>Added <a href="./installation/downloads.html#svn">subversion information</a> to the <a href="./installation/downloads.html">downloads</a> page. </li>
- <li>Added support for captions in the <a href="./libraries/table.html">Table Library</a> </li>
- <li>Fixed a bug in the <a href="./helpers/download_helper.html">download_helper</a> that was causing Internet Explorer to load rather than download </li>
- <li>Fixed a bug in the Active Record Join function that was not taking table prefixes into consideration.</li>
- <li>Removed unescaped variables in error messages of Input and Router classes</li>
- <li>Fixed a bug in the Loader that was causing errors on Libraries loaded twice. A debug message is now silently made in the log. </li>
- <li>Fixed a bug in the <a href="./helpers/form_helper.html">form helper</a> that gave textarea a value attribute </li>
- <li>Fixed a bug in the <a href="./libraries/image_lib.php">Image Library</a> that was ignoring resizing the same size image </li>
- <li>Fixed some doc typos.</li>
-</ul>
-
-
-<h2>Version 1.5.1</h2>
-<p>Release Date: November 23, 2006</p>
-<ul>
- <li>Added support for submitting arrays of libraries in the $this-&gt;load-&gt;library function.</li>
- <li>Added support for naming custom library files in lower or uppercase.</li>
- <li>Fixed a bug related to output buffering.</li>
- <li>Fixed a bug in the active record class that was not resetting query data after a completed query.</li>
- <li>Fixed a bug that was suppressing errors in controllers.</li>
- <li>Fixed a problem that can cause a loop to occur when the config file is missing.</li>
- <li>Fixed a bug that occurred when multiple models were loaded with the third parameter set to TRUE.</li>
- <li>Fixed an oversight that was not unsetting globals properly in the input sanitize function.</li>
- <li>Fixed some bugs in the Oracle DB driver.</li>
- <li>Fixed an incorrectly named variable in the MySQLi result driver.</li>
- <li>Fixed some doc typos.</li>
-</ul>
-<h2>Version 1.5.0.1</h2>
-<p>Release Date: October 31, 2006</p>
-<ul>
-<li>Fixed a problem in which duplicate attempts to load helpers and classes were not being stopped.</li>
-<li>Fixed a bug in the word_wrap() helper function.</li>
-<li>Fixed an invalid color Hex number in the Profiler class.</li>
-<li>Fixed a corrupted image in the user guide.</li>
-</ul>
-
-
-
-<h2>Version 1.5.0</h2>
-<p>Release Date: October 30, 2006</p>
-
-<ul>
-<li>Added <a href="./database/utilities.html">DB utility class</a>, permitting DB backups, CVS or XML files from DB results, and various other functions.</li>
-<li>Added <a href="./database/caching.html">Database Caching Class</a>.</li>
-<li>Added <a href="./database/transactions.html">transaction support</a> to the database classes.</li>
-<li>Added <a href="./general/profiling.html">Profiler Class</a> which generates a report of Benchmark execution times, queries, and POST data at the bottom of your pages.</li>
-<li>Added <a href="./libraries/user_agent.html">User Agent Library</a> which allows browsers, robots, and mobile devises to be identified.</li>
-<li>Added <a href="./libraries/table.html">HTML Table Class</a> , enabling tables to be generated from arrays or database results.</li>
-<li>Added <a href="./libraries/zip.html">Zip Encoding Library</a>.</li>
-<li>Added <a href="./libraries/ftp.html">FTP Library</a>.</li>
-<li>Added the ability to <a href="./general/creating_libraries.html">extend libraries</a> and <a href="./general/core_classes.html">extend core classes</a>, in addition to being able to replace them.</li>
-<li>Added support for storing <a href="./general/models.html">models within sub-folders</a>.</li>
-<li>Added <a href="./helpers/download_helper.html">Download Helper</a>.</li>
-<li>Added <a href="./database/queries.html">simple_query()</a> function to the database classes</li>
-<li>Added <a href="./helpers/date_helper.html">standard_date()</a> function to the Date Helper.</li>
-<li>Added <a href="./database/results.html">$query->free_result()</a> to database class.</li>
-<li>Added <a href="./database/fields.html">$query->list_fields()</a> function to database class</li>
-<li>Added <a href="./database/helpers.html">$this->db->platform()</a> function</li>
-<li>Added new <a href="./helpers/file_helper.html">File Helper</a>: get_filenames()</li>
-<li>Added new helper: <a href="./helpers/smiley_helper.html">Smiley Helper</a></li>
-<li>Added support for &lt;ul> and &lt;ol> lists in the <a href="./helpers/html_helper.html">HTML Helper</a></li>
-<li>Added the ability to rewrite <a href="./general/alternative_php.html">short tags</a> on-the-fly, converting them to standard PHP statements, for those servers that do not support short tags. This allows the cleaner syntax to be used regardless of whether it's supported by the server.</li>
-<li>Added the ability to <a href="./general/managing_apps.html">rename or relocate the "application" folder</a>.</li>
-<li>Added more thorough initialization in the upload class so that all class variables are reset.</li>
-<li>Added "is_numeric" to validation, which uses the native PHP is_numeric function.</li>
-<li>Improved the URI handler to make it more reliable when the $config['uri_protocol'] item is set to AUTO.</li>
-<li>Moved most of the functions in the Controller class into the Loader class, allowing fewer reserved function names for controllers when running under PHP 5.</li>
-<li>Updated the DB Result class to return an empty array when $query->result() doesn't produce a result.</li>
-<li>Updated the <dfn>input->cookie()</dfn> and <dfn>input->post()</dfn> functions in <a href="./libraries/input.html">Input Class</a> to permit arrays contained cookies that are arrays to be run through the XSS filter.</li>
-<li>Documented three functions from the <a href="./libraries/validation.html">Validation class</a> that were missing from the user guide: set_select(), set_radio(), and set_checkbox().</li>
-<li>Fixed a bug in the Email class related to SMTP Helo data.</li>
-<li>Fixed a bug in the word wrapping helper and function in the email class.</li>
-<li>Fixed a bug in the validation class.</li>
-<li>Fixed a bug in the typography helper that was incorrectly wrapping block level elements in paragraph tags.</li>
-<li>Fixed a problem in the form_prep() function that was double encoding entities.</li>
-<li>Fixed a bug that affects some versions of PHP when output buffering is nested.</li>
-<li>Fixed a bug that caused CI to stop working when the PHP magic __get() or __set() functions were used within models or controllers.</li>
-<li>Fixed a pagination bug that was permitting negative values in the URL.</li>
-<li>Fixed an oversight in which the Loader class was not allowed to be exteneded.</li>
-<li>Changed <dfn>_get_config()</dfn> to <dfn>get_config()</dfn> since the function is not a private one.</li>
-<li><strong>Deprecated "init" folder</strong>. Initialization happens automatically now. <a href="./general/creating_libraries.html">Please see documentation</a>.</li>
-<li><strong>Deprecated</strong> $this->db->field_names() USE $this->db->list_fields()</li>
-<li><strong>Deprecated</strong> the <dfn>$config['log_errors']</dfn> item from the config.php file. Instead, <dfn>$config['log_threshold']</dfn> can be set to "0" to turn it off.</li>
-</ul>
-
-
-
-
-<h2>Version 1.4.1</h2>
-<p>Release Date: September 21, 2006</p>
-
-<ul>
-<li>Added a new feature that passes URI segments directly to your function calls as parameters. See the <a href="controllers.html">Controllers</a> page for more info.</li>
-<li>Added support for a function named <dfn>_output()</dfn>, which when used in your controllers will received the final rendered output from the output class. More info in the <a href="controllers.html">Controllers</a> page.</li>
-<li>Added several new functions in the <a href="./libraries/uri.html">URI Class</a> to let you retrieve and manipulate URI segments that have been re-routed using the <a href="routing.html">URI Routing</a> feature. Previously, the URI class did not permit you to access any re-routed URI segments, but now it does.</li>
-<li>Added <a href="./libraries/output.html">$this->output->set_header()</a> function, which allows you to set server headers.</li>
-<li>Updated plugins, helpers, and language classes to allow your <dfn>application</dfn> folder to contain its own plugins, helpers, and language folders. Previously they were always treated as global for your entire installation. If your application folder contains any of these resources they will be used <em>instead</em> the global ones.</li>
-<li>Added <a href="./helpers/inflector_helper.html">Inflector helper</a>.</li>
-<li>Added <dfn>element()</dfn> function in the <a href="./helpers/array_helper.html">array helper</a>.</li>
-<li>Added <dfn>RAND()</dfn> to active record <dfn>orderby()</dfn> function.</li>
-<li>Added <dfn>delete_cookie()</dfn> and <dfn>get_cookie()</dfn> to <a href="./helpers/cookie_helper.html">Cookie helper</a>, even though the input class has a cookie fetching function.</li>
-<li>Added Oracle database driver (still undergoing testing so it might have some bugs).</li>
-<li>Added the ability to combine pseudo-variables and php variables in the template parser class.</li>
-<li>Added output compression option to the config file.</li>
-<li>Removed the is_numeric test from the db->escape() function.</li>
-<li>Fixed a MySQLi bug that was causing error messages not to contain proper error data.</li>
-<li>Fixed a bug in the email class which was causing it to ignore explicitly set alternative headers.</li>
-<li>Fixed a bug that was causing a PHP error when the Exceptions class was called within the get_config() function since it was causing problems.</li>
-<li>Fixed an oversight in the cookie helper in which the config file cookie settings were not being honored.</li>
-<li>Fixed an oversight in the upload class. An item mentioned in the 1.4 changelog was missing.</li>
-<li>Added some code to allow email attachments to be reset when sending batches of email.</li>
-<li>Deprecated the <dfn>application/scripts</dfn> folder. It will continue to work for legacy users, but it is recommended that you create your own
-<a href="./general/libraries.html">libraries</a> or <a href="./general/models.html">models</a> instead. It was originally added before CI had user libraries or models, but it's not needed anymore.</li>
-<li>Deprecated the <dfn>$autoload['core']</dfn> item from the <kbd>autoload.php</kbd> file. Instead, please now use: <kbd>$autoload['libraries']</kbd></li>
-<li>Deprecated the following database functions: $this->db->smart_escape_str() and $this->db->fields().</li>
-</ul>
-
-
-
-<h2>Version 1.4.0</h2>
-<p>Release Date: September 17, 2006</p>
-
-<ul>
-<li>Added <a href="hooks.html">Hooks</a> feature, enabling you to tap into and modify the inner workings of the framework without hacking the core files.</li>
-<li>Added the ability to organize controller files <a href="controllers.html">into sub-folders</a>. Kudos to Marco for <a href="http://codeigniter.com/forums/viewthread/627/">suggesting</a> this (and the next two) feature.</li>
-<li>Added regular expressions support for <a href="routing.html">routing rules</a>.</li>
-<li>Added the ability to <a href="controllers.html">remap function calls</a> within your controllers.</li>
-<li>Added the ability to <a href="core_classes.html">replace core system classes</a> with your own classes.</li>
-<li>Added support for % character in URL.</li>
-<li>Added the ability to supply full URLs using the <a href="./helpers/url_helper.html">anchor()</a> helper function.</li>
-<li>Added mode parameter to <a href="./helpers/file_helper.html">file_write()</a> helper.</li>
-<li>Added support for changing the port number in the <a href="./database/configuration.html">Postgres driver</a>.</li>
-<li>Moved the list of "allowed URI characters" out of the Router class and into the config file.</li>
-<li>Moved the MIME type array out of the Upload class and into its own file in the applications/config/ folder.</li>
-<li>Updated the Upload class to allow the upload field name to be set when calling <a href="./libraries/file_uploading.html">do_upload()</a>.</li>
-<li>Updated the <a href="./libraries/config.html">Config Library</a> to be able to load config files silently, and to be able to assign config files to their own index (to avoid collisions if you use multiple config files).</li>
-<li>Updated the URI Protocol code to allow more options so that URLs will work more reliably in different environments.</li>
-<li>Updated the <dfn>form_open()</dfn> helper to allow the GET method to be used.</li>
-<li>Updated the MySQLi <dfn>execute()</dfn> function with some code to help prevent lost connection errors.</li>
-<li>Updated the SQLite Driver to check for object support before attempting to return results as objects. If unsupported it returns an array.</li>
-<li>Updated the Models loader function to allow multiple loads of the same model.</li>
-<li>Updated the MS SQL driver so that single quotes are escaped.</li>
-<li>Updated the Postgres and ODBC drivers for better compatibility.</li>
-<li>Removed a strtolower() call that was changing URL segments to lower case.</li>
-<li>Removed some references that were interfering with PHP 4.4.1 compatibility.</li>
-<li>Removed backticks from Postgres class since these are not needed.</li>
-<li>Renamed <dfn>display()</dfn> to <dfn>_display()</dfn> in the Output class to make it clear that it's a private function.</li>
-<li>Deprecated the hash() function due to a naming conflict with a native PHP function with the same name. Please use <kbd>dohash()</kbd> instead.</li>
-<li>Fixed an bug that was preventing the input class from unsetting GET variables.</li>
-<li>Fixed a router bug that was making it too greedy when matching end segments.</li>
-<li>Fixed a bug that was preventing multiple discrete database calls.</li>
-<li>Fixed a bug in which loading a language file was producing a "file contains no data" message.</li>
-<li>Fixed a session bug caused by the XSS Filtering feature inadvertently changing the case of certain words.</li>
-<li>Fixed some missing prefixes when using the database prefix feature.</li>
-<li>Fixed a typo in the Calendar class (cal_november).</li>
-<li>Fixed a bug in the <dfn>form_checkbox()</dfn> helper.</li>
-<li>Fixed a bug that was allowing the second segment of the URI to be identical to the class name.</li>
-<li>Fixed an evaluation bug in the database initialization function.</li>
-<li>Fixed a minor bug in one of the error messages in the language class.</li>
-<li>Fixed a bug in the date helper <dfn>timespan</dfn> function.</li>
-<li>Fixed an undefined variable in the DB Driver class.</li>
-<li>Fixed a bug in which dollar signs used as binding replacement values in the DB class would be treated as RegEx back-references.</li>
-<li>Fixed a bug in the <dfn>set_hash()</dfn> function which was preventing MD5 from being used.</li>
-<li>Fixed a couple bugs in the Unit Testing class.</li>
-<li>Fixed an incorrectly named variable in the Validation class.</li>
-<li>Fixed an incorrectly named variable in the URI class.</li>
-<li>Fixed a bug in the config class that was preventing the base URL from being called properly.</li>
-<li>Fixed a bug in the validation class that was not permitting callbacks if the form field was empty.</li>
-<li>Fixed a problem that was preventing scaffolding from working properly with MySQLi.</li>
-<li>Fixed some MS SQL bugs.</li>
-<li>Fixed some doc typos.</li>
-</ul>
-
-
-
-<h2>Version 1.3.3</h2>
-<p>Release Date: June 1, 2006</p>
-
-<ul>
-
-<li>Models do <strong>not</strong> connect automatically to the database as of this version. <a href="./general/models.html">More info here</a>.</li>
-<li>Updated the Sessions class to utilize the active record class when running session related queries. Previously the queries assumed MySQL syntax.</li>
-<li>Updated alternator() function to re-initialize when called with no arguments, allowing multiple calls.</li>
-<li>Fixed a bug in the active record "having" function.</li>
-<li>Fixed a problem in the validation class which was making checkboxes be ignored when required.</li>
-<li>Fixed a bug in the word_limiter() helper function. It was cutting off the fist word.</li>
-<li>Fixed a bug in the xss_clean function due to a PHP bug that affects some versions of html_entity_decode.</li>
-<li>Fixed a validation bug that was preventing rules from being set twice in one controller.</li>
-<li>Fixed a calendar bug that was not letting it use dynamically loaded languages.</li>
-<li>Fixed a bug in the active record class when using WHERE clauses with LIKE</li>
-<li>Fixed a bug in the hash() security helper.</li>
-<li>Fixed some typos.</li>
-</ul>
-
-
-
-
-<h2>Version 1.3.2</h2>
-<p>Release Date: April 17, 2006</p>
-
-<ul>
-<li>Changed the behavior of the validation class such that if a "required" rule is NOT explicitly stated for a field then all other tests get ignored.</li>
-<li>Fixed a bug in the Controller class that was causing it to look in the local "init" folder instead of the main system one.</li>
-<li>Fixed a bug in the init_pagination file. The $config item was not being set correctly.</li>
-<li>Fixed a bug in the auto typography helper that was causing inconsistent behavior.</li>
-<li>Fixed a couple bugs in the Model class.</li>
-<li>Fixed some documentation typos and errata.</li>
-</ul>
-
-
-
-<h2>Version 1.3.1</h2>
-<p>Release Date: April 11, 2006</p>
-
-<ul>
-<li>Added a <a href="./libraries/unit_testing.html">Unit Testing Library</a>.</li>
-<li>Added the ability to pass objects to the <strong>insert()</strong> and <strong>update()</strong> database functions.
-This feature enables you to (among other things) use your <a href="./general/models.html">Model class</a> variables to run queries with. See the Models page for details.</li>
-<li>Added the ability to pass objects to the <a href="./general/views.html">view loading function</a>: $this->load->view('my_view', <var>$object</var>);</li>
-<li>Added <kbd>getwhere</kbd> function to <a href="./database/active_record.html">Active Record class</a>.</li>
-<li>Added <kbd>count_all</kbd> function to <a href="./database/active_record.html">Active Record class</a>.</li>
-<li>Added language file for scaffolding and fixed a scaffolding bug that occurs when there are no rows in the specified table.</li>
-<li>Added <a href="./database/queries.html">$this->db->last_query()</a>, which allows you to view your last query that was run.</li>
-<li>Added a new mime type to the upload class for better compatibility.</li>
-<li>Changed how cache files are read to prevent PHP errors if the cache file contains an XML tag, which PHP wants to interpret as a short tag.</li>
-<li>Fixed a bug in a couple of the active record functions (where and orderby).</li>
-<li>Fixed a bug in the image library when realpath() returns false.</li>
-<li>Fixed a bug in the Models that was preventing libraries from being used within them.</li>
-<li>Fixed a bug in the "exact_length" function of the validation class.</li>
-<li>Fixed some typos in the user guide</li>
-</ul>
-
-
-<h2>Version 1.3</h2>
-<p>Release Date: April 3, 2006</p>
-
-<ul>
-<li>Added support for <a href="models.html">Models</a>.</li>
-<li>Redesigned the database libraries to support additional RDBMs (Postgres, MySQLi, etc.).</li>
-<li>Redesigned the <a href="./database/active_record.html">Active Record class</a> to enable more varied types of queries with simpler syntax, and advanced features like JOINs.</li>
-<li>Added a feature to the database class that lets you run <a href="./database/call_function.html">custom function calls</a>.</li>
-<li>Added support for <a href="controllers.html">private functions</a> in your controllers. Any controller function name that starts with an underscore will not be served by a URI request.</li>
-<li>Added the ability to pass your own initialization parameters to your <a href="creating_libraries.html">custom core libraries</a> when using $this->load->library()</li>
-<li>Added support for running standard <a href="urls.html">query string URLs</a>. These can be optionally enabled in your config file.</li>
-<li>Added the ability to <a href="urls.html">specify a "suffix"</a>, which will be appended to your URLs. For example, you could add .html to your URLs, making them appear static. This feature is enabled in your config file.</li>
-<li>Added a new error template for use with native PHP errors.</li>
-<li>Added "alternator" function in the <a href="./helpers/string_helper.html">string helpers</a>.</li>
-<li>Removed slashing from the input class. After much debate we decided to kill this feature.</li>
-<li>Change the commenting style in the scripts to the PEAR standard so that IDEs and tools like phpDocumenter can harvest the comments.</li>
-<li>Added better class and function name-spacing to avoid collisions with user developed classes. All CodeIgniter classes are now prefixed with <dfn>CI_</dfn> and
-all controller methods are prefixed with <dfn>_ci</dfn> to avoid controller collisions. A list of reserved function names can be <a href="controllers.html">found here</a>.</li>
-<li>Redesigned how the "CI" super object is referenced, depending on whether PHP 4 or 5 is being run, since PHP 5 allows a more graceful way to manage objects that utilizes a bit less resources.</li>
-<li>Deprecated: <var>$this->db->use_table()</var> has been deprecated. Please read the <a href="./database/active_record.html">Active Record</a> page for information.</li>
-<li>Deprecated: <var>$this->db->smart_escape_str()</var> has been deprecated. Please use this instead: <var>$this->db->escape()</var></li>
-<li>Fixed a bug in the exception handler which was preventing some PHP errors from showing up.</li>
-<li>Fixed a typo in the URI class. $this->total_segment() should be plural: $this->total_segments()</li>
-<li>Fixed some typos in the default calendar template</li>
-<li>Fixed some typos in the user guide</li>
-</ul>
-
-
-
-
-
-
-
-
-<h2>Version 1.2</h2>
-<p>Release Date: March 21, 2006</p>
-
-<ul>
-<li>Redesigned some internal aspects of the framework to resolve scoping problems that surfaced during the beta tests. The problem was most notable when instantiating classes in your constructors, particularly if those classes in turn did work in their constructors.</li>
-<li>Added a global function named <a href="ancillary_classes.html">get_instance()</a> allowing the main CodeIgniter object to be accessible throughout your own classes.</li>
-<li>Added new <a href="./helpers/file_helper.html">File Helper</a>: delete_files()</li>
-<li>Added new <a href="./helpers/url_helper.html">URL Helpers</a>: base_url(), index_page()</li>
-<li>Added the ability to create your own <a href="creating_libraries.html">core libraries</a> and store them in your local application directory.</li>
-<li>Added an <kbd>overwrite</kbd> option to the <a href="./libraries/file_uploading.html">Upload class</a>, enabling files to be overwritten rather than having the file name appended.</li>
-<li>Added Javascript Calendar plugin.</li>
-<li>Added search feature to user guide. Note: This is done using Google, which at the time of this writing has not crawled all the pages of the docs.</li>
-<li>Updated the parser class so that it allows tag pars within other tag pairs.</li>
-<li>Fixed a bug in the DB "where" function.</li>
-<li>Fixed a bug that was preventing custom config files to be auto-loaded.</li>
-<li>Fixed a bug in the mysql class bind feature that prevented question marks in the replacement data.</li>
-<li>Fixed some bugs in the xss_clean function</li>
-</ul>
-
-
-
-
-
-<h2>Version Beta 1.1</h2>
-<p>Release Date: March 10, 2006</p>
-
-<ul>
-<li>Added a <a href="./libraries/calendar.html">Calendaring class</a>.</li>
-<li>Added support for running <a href="managing_apps.html">multiple applications</a> that share a common CodeIgniter backend.</li>
-<li>Moved the "uri protocol" variable from the index.php file into the config.php file</li>
-<li>Fixed a problem that was preventing certain function calls from working within constructors.</li>
-<li>Fixed a problem that was preventing the $this->load->library function from working in constructors.</li>
-<li>Fixed a bug that occurred when the session class was loaded using the auto-load routine.</li>
-<li>Fixed a bug that can happen with PHP versions that do not support the E_STRICT constant</li>
-<li>Fixed a data type error in the form_radio function (form helper)</li>
-<li>Fixed a bug that was preventing the xss_clean function from being called from the validation class.</li>
-<li>Fixed the cookie related config names, which were incorrectly specified as $conf rather than $config</li>
-<li>Fixed a pagination problem in the scaffolding.</li>
-<li>Fixed a bug in the mysql class "where" function.</li>
-<li>Fixed a regex problem in some code that trimmed duplicate slashes.</li>
-<li>Fixed a bug in the br() function in the HTML helper</li>
-<li>Fixed a syntax mistake in the form_dropdown function in the Form Helper.</li>
-<li>Removed the "style" attributes form the form helpers.</li>
-<li>Updated the documentation. Added "next/previous" links to each page and fixed various typos.</li>
-</ul>
-
-<h2>Version Beta 1.0 </h2>
-<p>Release Date: February 28, 2006</p>
-<p>First publicly released version.</p>
-
-</div>
-<!-- END CONTENT -->
-
-
-<div id="footer">
-<p>
-Previous Topic:&nbsp;&nbsp;<a href="license.html">License Agreement</a>
-&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
-<a href="#top">Top of Page</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
-<a href="index.html">User Guide Home</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
-Next Topic:&nbsp;&nbsp;<a href="./general/credits.html">Credits</a>
-</p>
-<p><a href="http://codeigniter.com">CodeIgniter</a> &nbsp;&middot;&nbsp; Copyright &#169; 2006-2008 &nbsp;&middot;&nbsp; <a href="http://ellislab.com/">Ellislab, Inc.</a></p>
-</div>
-
-</body>
-</html>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+
+<style type='text/css' media='all'>@import url('userguide.css');</style>
+<link rel='stylesheet' type='text/css' media='all' href='userguide.css' />
+
+<script type="text/javascript" src="./nav/nav.js"></script>
+<script type="text/javascript" src="./nav/prototype.lite.js"></script>
+<script type="text/javascript" src="./nav/moo.fx.js"></script>
+<script type="text/javascript" src="./nav/user_guide_menu.js"></script>
+
+<meta http-equiv='expires' content='-1' />
+<meta http-equiv= 'pragma' content='no-cache' />
+<meta name='robots' content='all' />
+<meta name='author' content='ExpressionEngine Dev Team' />
+<meta name='description' content='CodeIgniter User Guide' />
+
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+<title>Change Log : CodeIgniter User Guide</title>
+
+</head>
+<body>
+
+<!-- START NAVIGATION -->
+<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('./');</script></div></div>
+<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="./images/nav_toggle_darker.jpg" width="154" height="43" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
+<div id="masthead">
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td><h1>CodeIgniter User Guide Version 1.7</h1></td>
+<td id="breadcrumb_right"><a href="./toc.html">Table of Contents Page</a></td>
+</tr>
+</table>
+</div>
+<!-- END NAVIGATION -->
+
+
+<!-- START BREADCRUMB -->
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td id="breadcrumb">
+<a href="http://codeigniter.com/">CodeIgniter Home</a> &nbsp;&#8250;&nbsp;
+<a href="index.html">User Guide Home</a> &nbsp;&#8250;&nbsp;
+Change Log
+</td>
+<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide&nbsp; <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" />&nbsp;<input type="submit" class="submit" name="sa" value="Go" /></form></td>
+</tr>
+</table>
+<!-- END BREADCRUMB -->
+
+<br clear="all" />
+
+
+<!-- START CONTENT -->
+<div id="content">
+
+<h1>Change Log</h1>
+
+<h2>Version 1.7.1</h2>
+<p>Release Date: not yet released<br />
+SVN Revision: </p>
+
+<ul>
+ <li>Libraries
+ <ul>
+ <li>Changed default current page indicator in the Pagination library to use &lt;strong&gt; instead of &lt;b&gt;</li>
+ <li>A "HTTP/1.1 400 Bad Request" header is now sent when disallowed characters are encountered.</li>
+ <li>Added &lt;big&gt;, &lt;small&gt;, &lt;q&gt;, and &lt;tt&gt; to the Typography parser's inline elements.</li>
+ </ul>
+ </li>
+ <li>Helpers
+ <ul>
+ <li>Added a doctype() function to the <a href="helpers/html_helper.html">HTML helper</a>.</li>
+ </ul>
+ </li>
+</ul>
+
+<h3>Bug fixes for 1.7.1</h3>
+<ul>
+ <li>Fixed a bug in the MySQLi driver when no port is specified</li>
+ <li>Fixed a bug (#5702), in which the field label was not being fetched properly, when "matching" one field to another.</li>
+ <li>Fixed a bug in which identifers were not being escaped properly when reserved characters were used.</li>
+ <li>Fixed a bug with the regular expression used to protect submitted paragraph tags in auto typography.</li>
+ <li>Fixed a bug where double dashes within tag attributes were being converted to em dash entities.</li>
+ <li>Fixed a bug where double spaces within tag attributes were being converted to non-breaking space entities.</li>
+ <li>Changed a few docblock comments to reflect actual return values.</li>
+</ul>
+
+
+<h2>Version 1.7</h2>
+<p>Release Date: October 23, 2008<br />
+SVN Revision: 1541</p>
+
+<ul>
+ <li>Libraries
+ <ul>
+ <li>Added a new <a href="libraries/form_validation.html">Form Validation Class</a>. It simplifies setting rules and field names, supports arrays as field names, allows groups of validation rules to be saved in a config file, and adds some helper functions for use in view files. <strong>Please note that the old Validation class is now deprecated</strong>. We will leave it in the library folder for some time so that existing applications that use it will not break, but you are encouraged to migrate to the new version.</li>
+ <li>Updated the <a href="libraries/sessions.html">Sessions class</a> so that any custom data being saved gets stored to a database rather than the session cookie (assuming you are using a database to store session data), permitting much more data to be saved.</li>
+ <li>Added the ability to store libraries in subdirectories within either the main "libraries" or the local application "libraries" folder. Please see the <a href="libraries/loader.html">Loader class</a> for more info.</li>
+ <li>Added the ability to assign library objects to your own variable names when you use <kbd>$this->load->library()</kbd>. Please see the <a href="libraries/loader.html">Loader class</a> for more info.</li>
+ <li>Added controller class/method info to <a href="general/profiling.html">Profiler class</a> and support for multiple database connections.</li>
+ <li>Improved the "auto typography" feature and moved it out of the helper into its own <a href="libraries/typography.html">Typography Class</a>.</li>
+ <li>Improved performance and accuracy of <kbd>xss_clean()</kbd>, including reduction of false positives on image/file tests.</li>
+ <li>Improved <a href="./libraries/parser.html">Parser class</a> to allow multiple calls to the parse() function. The output of each is appended in the output.</li>
+ <li>Added <dfn>max_filename</dfn> option to set a file name length limit in the <a href="libraries/file_uploading.html">File Upload Class</a>.</li>
+ <li>Added <dfn>set_status_header()</dfn> function to <a href="libraries/output.html">Output class</a>.</li>
+ <li>Modified <a href="libraries/pagination.html">Pagination</a> class to only output the "First" link when the link for page one would not be shown.</li>
+ <li>Added support for mb_strlen in the <a href="libraries/form_validation.html">Form Validation</a> class so that multi-byte languages will calculate string lengths properly.</li>
+ </ul>
+ </li>
+ <li>Database
+ <ul>
+ <li>Improved Active Record class to allow full path column and table names: hostname.database.table.column. Also improved the alias handling.</li>
+ <li>Improved how table and column names are escaped and prefixed. It now honors full path names when adding prefixes and escaping.</li>
+ <li>Added Active Record caching feature to "update" and "delete" functions.</li>
+ <li>Added removal of non-printing control characters in <kbd>escape_str()</kbd> of DB drivers that do not have native PHP escaping mechanisms (mssql, oci8, odbc), to avoid potential SQL errors, and possible sources of SQL injection.</li>
+ <li>Added port support to MySQL, MySQLi, and MS SQL database drivers.</li>
+ <li>Added driver name variable in each DB driver, based on bug report #4436.</li>
+ </ul>
+ </li>
+ <li>Helpers
+ <ul>
+ <li>Added several new "setting" functions to the <a href="helpers/form_helper.html">Form helper</a> that allow POST data to be retrieved and set into forms. These are intended to be used on their own, or with the new <a href="libraries/form_validation.html">Form Validation Class</a>.</li>
+ <li>Added <kbd>current_url()</kbd> and uri_segments() to <a href="helpers/url_helper.html">URL helper</a>.</li>
+ <li>Altered <kbd>auto_link()</kbd> in the <a href="helpers/url_helper.html">URL helper</a> so that email addresses with "+" included will be linked.</li>
+ <li>Added <kbd>meta()</kbd> function to <a href="helpers/html_helper.html">HTML helper</a>.</li>
+ <li>Improved accuracy of calculations in <a href="helpers/number_helper.html">Number helper</a>.</li>
+ <li>Removed added newlines ("\n") from most form and html helper functions.</li>
+ <li>Tightened up validation in the <a href="helpers/date_helper.html">Date helper</a> function <kbd>human_to_unix()</kbd>, and eliminated the POSIX regex.</li>
+ <li>Updated <a href="helpers/date_helper.html">Date helper</a> to match the world's current time zones and offsets.</li>
+ <li>Modified url_title() in the <a href="helpers/url_helper.html">URL helper</a> to remove characters and digits that are part of
+ character entities, to allow dashes, underscores, and periods regardless of the $separator, and to allow uppercase characters.</li>
+ <li>Added support for arbitrary attributes in anchor_popup() of the <a href="helpers/url_helper.html">URL helper</a>.</li>
+ </ul>
+ </li>
+ <li>Other Changes
+ <ul>
+ <li>Added <a href="./general/styleguide.html">PHP Style Guide</a> to docs.</li>
+ <li>Added sanitization in <kbd>xss_clean()</kbd> for a deprecated HTML tag that could be abused in user input in Internet Explorer.</li>
+ <li>Added a few openxml document mime types, and an additional mobile agent to mimes.php and user_agents.php respectively.</li>
+ <li>Added a file lock check during caching, before trying to write to the file.</li>
+ <li>Modified Cookie key cleaning to unset a few troublesome key names that can be present in certain environments, preventing CI from halting execution.</li>
+ <li>Changed the output of the profiler to use style attribute rather than clear, and added the id "codeigniter_profiler" to the container div.</li>
+ </ul>
+ </li>
+</ul>
+
+<h3>Bug fixes for 1.7.0</h3>
+<ul>
+ <li>Fixed bug in <kbd>xss_clean()</kbd> that could remove some desirable tag attributes.</li>
+ <li>Fixed assorted user guide typos or examples (#4807, #4812, #4840, #4862, #4864, #4899, #4930, #5006, #5071, #5158, #5229, #5254, #5351).</li>
+ <li>Fixed an edit from 1.6.3 that made the $robots array in user_agents.php go poof.</li>
+ <li>Fixed a bug in the <a href="libraries/email.html">Email library</a> with quoted-printable encoding improperly encoding space and tab characters.</li>
+ <li>Modified XSS sanitization to no longer add semicolons after &amp;[single letter], such as in M&amp;M's, B&amp;B, etc.</li>
+ <li>Modified XSS sanitization to no longer strip XHTML image tags of closing slashes.</li>
+ <li>Fixed a bug in the Session class when database sessions are used where upon session update all userdata would be errantly written to the session cookie.</li>
+ <li>Fixed a bug (#4536) in backups with the MySQL driver where some legacy code was causing certain characters to be double escaped.</li>
+ <li>Fixed a routing bug (#4661) that occurred when the default route pointed to a subfolder.</li>
+ <li>Fixed the spelling of "Dhaka" in the <kbd>timezone_menu()</kbd> function of the <a href="helpers/date_helper.html">Date helper.</a></li>
+ <li>Fixed the spelling of "raspberry" in config/smileys.php.</li>
+ <li>Fixed incorrect parenthesis in <kbd>form_open()</kbd> function (#5135).</li>
+ <li>Fixed a bug that was ignoring case when comparing controller methods (#4560).</li>
+ <li>Fixed a bug (#4615) that was not setting SMTP authorization settings when using the initialize function.</li>
+ <li>Fixed a bug in <kbd>highlight_code()</kbd> in the <a href="helpers/text_helper.html">Text helper</a> that would leave a stray &lt;/span&gt; in certain cases.</li>
+ <li>Fixed Oracle bug (#3306) that was preventing multiple queries in one action.</li>
+ <li>Fixed ODBC bug that was ignoring connection params due to its use of a constructor.</li>
+ <li>Fixed a DB driver bug with num_rows() that would cause an error with the Oracle driver.</li>
+ <li>Fixed MS SQL bug (#4915). Added brackets around database name in MS SQL driver when selecting the database, in the event that reserved characters are used in the name.</li>
+ <li>Fixed a DB caching bug (4718) in which the path was incorrect when no URI segments were present.</li>
+ <li>Fixed Image_lib class bug #4562. A path was not defined for NetPBM.</li>
+ <li>Fixed Image_lib class bug #4532. When cropping an image with identical height/width settings on output, a copy is made.</li>
+ <li>Fixed DB_driver bug (4900), in which a database error was not being logged correctly.</li>
+ <li>Fixed DB backup bug in which field names were not being escaped.</li>
+ <li>Fixed a DB Active Record caching bug in which multiple calls to cached data were not being honored.</li>
+ <li>Fixed a bug in the Session class that was disallowing slashes in the serialized array.</li>
+ <li>Fixed a Form Validation bug in which the "isset" error message was being trigged by the "required" rule.</li>
+ <li>Fixed a spelling error in a Loader error message.</li>
+ <li>Fixed a bug (5050) with IP validation with empty segments.</li>
+ <li>Fixed a bug in which the parser was being greedy if multiple identical sets of tags were enountered.</li>
+</ul>
+
+<h2>Version 1.6.3</h2>
+<p>Release Date: June 26, 2008<br />
+SVN Revision: 1238</p>
+<p>Version 1.6.3 is a security and maintenance release and is recommended for all users.</p>
+<ul>
+ <li>Database
+ <ul>
+ <li>Modified MySQL/MySQLi Forge class to give explicit names to keys</li>
+ <li>Added ability to set multiple column non-primary keys to the <a href="database/forge.html">Forge class</a></li>
+ <li>Added ability to set additional database config values in <a href="database/connecting.html">DSN connections</a> via the query string.</li>
+ </ul>
+ </li>
+ <li>Libraries
+ <ul>
+ <li>Set the mime type check in the <a href="libraries/file_uploading.html">Upload class</a> to reference the global mimes variable.</li>
+ <li>Added support for query strings to the <a href="libraries/pagination.html">Pagination class</a>, automatically detected or explicitly declared.</li>
+ <li>Added <kbd>get_post()</kbd> to the <a href="libraries/input.html">Input class</a>.</li>
+ <li>Documented <kbd>get()</kbd> in the <a href="libraries/input.html">Input class</a>.</li>
+ <li>Added the ability to automatically output language items as form labels in the <a href="libraries/language.html">Language class</a>.</li>
+ </ul>
+ </li>
+ <li>Helpers
+ <ul>
+ <li>Added a <a href="helpers/language_helper.html">Language helper</a>.</li>
+ <li>Added a <a href="helpers/number_helper.html">Number helper</a>.</li>
+ <li><a href="helpers/form_helper.html">Form helper</a> refactored to allow <kbd>form_open()</kbd> and <kbd>form_fieldset()</kbd> to accept arrays or strings as arguments.</li>
+ </ul>
+ </li>
+ <li>Other changes
+ <ul>
+ <li>Improved security in <kbd>xss_clean()</kbd>.</li>
+ <li>Removed an unused Router reference in <kbd>_display_cache()</kbd>.</li>
+ <li>Added ability to <a href="libraries/input.html">use xss_clean() to test images</a> for XSS, useful for upload security.</li>
+ <li>Considerably expanded list of mobile user-agents in config/user_agents.php.</li>
+ <li>Charset information in the userguide has been moved above title for internationalization purposes (#4614).</li>
+ <li>Added &quot;Using Associative Arrays In a Request Parameter&quot; example to the <a href="libraries/xmlrpc.html">XMLRPC userguide page</a>.</li>
+ <li>Removed maxlength and size as automatically added attributes of form_input() in the <a href="helpers/form_helper.html">form helper</a>.</li>
+ <li>Documented the language file use of <kbd>byte_format()</kbd> in the <a href="helpers/number_helper.html">number helper</a>.</li>
+ </ul>
+ </li>
+</ul>
+
+
+<h3>Bug fixes for 1.6.3</h3>
+
+<ul>
+ <li>Added a language key for valid_emails in validation_lang.php.</li>
+ <li>Amended fixes for bug (#3419) with parsing DSN database connections.</li>
+ <li>Moved the <kbd>_has_operators()</kbd> function (#4535) into DB_driver from DB_active_rec.</li>
+ <li>Fixed a syntax error in upload_lang.php.</li>
+ <li>Fixed a bug (#4542) with a regular expression in the Image library.</li>
+ <li>Fixed a bug (#4561) where <kbd>orhaving()</kbd> wasn't properly passing values.</li>
+ <li>Removed some unused variables from the code (#4563).</li>
+ <li>Fixed a bug where <kbd>having()</kbd> was not adding an = into the statement (#4568).</li>
+ <li>Fixed assorted user guide typos or examples (#4574, #4706).</li>
+ <li>Added quoted-printable headers to Email class when the multi-part override is used.</li>
+ <li>Fixed a double opening &lt;p&gt; tag in the index pages of each system directory.</li>
+</ul>
+
+<h2>Version 1.6.2</h2>
+<p>Release Date: May 13, 2008<br />
+SVN Revision: 1155</p>
+<ul>
+ <li>Active Record
+ <ul>
+ <li>Added the ability to prevent escaping in <kbd>having()</kbd> clauses.</li>
+ <li>Added <kbd>rename_table()</kbd> into <a href="./database/forge.html">DBForge</a>.</li>
+ <li>Fixed a bug that wasn't allowing escaping to be turned off if the value of a query was NULL.</li>
+ <li>DB Forge is now assigned to any models that exist after loading (#3457).</li>
+ </ul>
+ </li>
+ <li>Database
+ <ul>
+ <li>Added <a href="./database/transactions.html">Strict Mode</a> to database transactions.</li>
+ <li>Escape behaviour in where() clauses has changed; values in those with the &quot;FALSE&quot; argument are no longer escaped (ie: quoted).</li>
+ </ul>
+ </li>
+ <li>Config
+ <ul>
+ <li>Added 'application/vnd.ms-powerpoint' to list of mime types.</li>
+ <li>Added 'audio/mpg' to list of mime types.</li>
+ <li>Added new user-modifiable file constants.php containing file mode and fopen constants.</li>
+ <li>Added the ability to set CRLF settings via config in the <a href="libraries/email.html">Email</a> class.</li>
+ </ul>
+ </li>
+ <li>Libraries
+ <ul>
+ <li>Added increased security for filename handling in the Upload library.</li>
+ <li>Added increased security for sessions for client-side data tampering.</li>
+ <li>The MySQLi forge class is now in sync with MySQL forge. </li>
+ <li>Added the ability to set CRLF settings via config in the <a href="libraries/email.html">Email</a> class.</li>
+ <li><a href="libraries/unit_testing.html">Unit Testing</a> results are now colour coded, and a change was made to the default template of results.</li>
+ <li>Added a valid_emails rule to the <a href="libraries/validation.html">Validation</a> class.</li>
+ <li>The <a href="libraries/zip.html">Zip class</a> now exits within <kbd>download()</kbd>.</li>
+ <li>The <a href="libraries/zip.html">Zip class</a> has undergone a substantial re-write for speed and clarity (thanks stanleyxu for the hard work and code contribution in bug report #3425!)</li>
+ </ul>
+ </li>
+ <li>Helpers
+ <ul>
+ <li>Added a <a href="helpers/compatibility_helper.html">Compatibility Helper</a> for using some common PHP 5 functions safely in applications that might run on PHP 4 servers (thanks Seppo for the hard work and code contribution!)</li>
+ <li>Added <kbd>form_button()</kbd> in the <a href="helpers/form_helper.html">Form helper</a>.</li>
+ <li>Changed the <kbd>radio()</kbd> and <kbd>checkbox()</kbd> functions to default to not checked by default.</li>
+ <li>Added the ability to include an optional HTTP Response Code in the <kbd>redirect()</kbd> function of the <a href="helpers/url_helper.html">URL Helper</a>.</li>
+ <li>Modified <kbd>img()</kbd> in the <a href="helpers/html_helper.html">HTML Helper</a> to remove an unneeded space (#4208).</li>
+ <li>Modified <kbd>anchor()</kbd> in the <a href="helpers/url_helper.html">URL helper</a> to no longer add a default title= attribute (#4209).</li>
+ <li>The <a href="helpers/download_helper.html">Download helper</a> now exits within <kbd>force_download()</kbd>.</li>
+ <li>Added <kbd>get_dir_file_info()</kbd>, <kbd>get_file_info()</kbd>, and <kbd>get_mime_by_extension()</kbd> to the <a href="helpers/file_helper.html">File Helper</a>.</li>
+ <li>Added <kbd>symbolic_permissions()</kbd> and <kbd>octal_permissions()</kbd> to the <a href='helpers/file_helper.html'>File helper</a>.</li>
+ </ul>
+ </li>
+ <li>Plugins
+ <ul>
+ <li>Modified captcha generation to first look for the function imagecreatetruecolor, and fallback to imagecreate if it isn't available (#4226).</li>
+ </ul>
+ </li>
+ <li>Other
+ Changes
+ <ul>
+ <li>Added ability for <a href="libraries/input.html">xss_clean()</a> to accept arrays.</li>
+ <li>Removed closing PHP tags from all PHP files to avoid accidental output and potential 'cannot modify headers' errors.</li>
+ <li>Removed &quot;scripts&quot; from the auto-load search path. Scripts were deprecated
+ in Version 1.4.1 (September 21, 2006). If you still need to use them for legacy reasons, they must now be manually loaded in each Controller.</li>
+ <li>Added a <a href="general/reserved_names.html">Reserved Names</a> page to the userguide, and migrated reserved controller names into it.</li>
+ <li>Added a <a href="general/common_functions.html">Common Functions</a> page to the userguide for globally available functions.</li>
+ <li>Improved security and performance of xss_clean().</li>
+ </ul>
+ </li>
+ </ul>
+
+<h3>Bugfixes for 1.6.2</h3>
+<ul>
+ <li>Fixed a bug where SET queries were not being handled as "write" queries.</li>
+ <li>Fixed a bug (#3191) with ORIG_PATH_INFO URI parsing.</li>
+ <li>Fixed a bug in DB Forge, when inserting an id field (#3456).</li>
+ <li>Fixed a bug in the table library that could cause identically constructed rows to be dropped (#3459).</li>
+ <li>Fixed DB Driver and MySQLi result driver checking for resources instead of objects (#3461).</li>
+ <li>Fixed an AR_caching error where it wasn't tracking table aliases (#3463).</li>
+ <li>Fixed a bug in AR compiling, where select statements with arguments got incorrectly escaped (#3478).</li>
+ <li>Fixed an incorrect documentation of $this-&gt;load-&gt;language (#3520).</li>
+ <li>Fixed bugs (#3523, #4350) in get_filenames() with recursion and problems with Windows when $include_path is used.</li>
+ <li>Fixed a bug (#4153) in the XML-RPC class preventing dateTime.iso8601 from being used.</li>
+ <li>Fixed an AR bug with or_where_not_in() (#4171).</li>
+ <li>Fixed a bug with <a href="libraries/input.html">xss_clean()</a> that would add semicolons to GET URI variable strings.</li>
+ <li>Fixed a bug (#4206) in the Directory Helper where the directory resource was not being closed, and minor improvements.</li>
+ <li>Fixed a bug in the FTP library where delete_dir() was not working recursively (#4215).</li>
+ <li>Fixed a Validation bug when set_rules() is used with a non-array field name and rule (#4220).</li>
+ <li>Fixed a bug (#4223) where DB caching would not work for returned DB objects or multiple DB connections.</li>
+ <li>Fixed a bug in the Upload library that might output the same error twice (#4390).</li>
+ <li>Fixed an AR bug when joining with a table alias and table prefix (#4400).</li>
+ <li>Fixed a bug in the DB class testing the $params argument.</li>
+ <li>Fixed a bug in the Table library where the integer 0 in cell data would be displayed as a blank cell.</li>
+ <li>Fixed a bug in <kbd>link_tag()</kbd> of the <a href="helpers/url_helper.html">URL helper</a> where a key was passed instead of a value.</li>
+ <li>Fixed a bug in DB_result::row() that prevented it from returning individual fields with MySQL NULL values.</li>
+ <li>Fixed a bug where SMTP emails were not having dot transformation performed on lines that begin with a dot.</li>
+ <li>Fixed a bug in display_error() in the DB driver that was instantiating new Language and Exception objects, and not using the error heading.</li>
+ <li>Fixed a bug (#4413) where a URI containing slashes only e.g. 'http://example.com/index.php?//' would result in PHP errors</li>
+ <li>Fixed an array to string conversion error in the Validation library (#4425)</li>
+ <li>Fixed bug (#4451, #4299, #4339) where failed transactions will not rollback when debug mode is enabled.</li>
+ <li>Fixed a bug (#4506) with overlay_watermark() in the Image library preventing support for PNG-24s with alpha transparency</li>
+ <li>Fixed assorted user guide typos (#3453, #4364, #4379, #4399, #4408, #4412, #4448, #4488).</li>
+ </ul>
+
+<h2>Version 1.6.1</h2>
+<p>Release Date: February 12, 2008<br />
+ SVN Revision: 984</p>
+<ul>
+ <li>Active Record
+ <ul>
+ <li>Added <a href="./database/active_record.html#caching">Active Record Caching</a>.</li>
+ <li>Made Active Record fully database-prefix aware.</li>
+ </ul>
+ </li>
+ <li>Database drivers
+ <ul>
+ <li>Added support for setting client character set and collation for MySQLi.</li>
+ </ul>
+ </li>
+ <li>Core Changes
+ <ul>
+ <li>Modified <kbd>xss_clean()</kbd> to be more intelligent with its handling of URL encoded strings.</li>
+ <li>Added $_SERVER, $_FILES, $_ENV, and $_SESSION to sanitization of globals.</li>
+ <li>Added a <a href="./helpers/path_helper.html">Path Helper</a>.</li>
+ <li>Simplified <kbd>_reindex_segments()</kbd> in the URI class.</li>
+ <li>Escaped the '-' in the default 'permitted_uri_chars' config item, to prevent errors if developers just try to add additional characters to the end of the default expression.</li>
+ <li>Modified method calling to controllers to show a 404 when a private or protected method is accessed via a URL.</li>
+ <li>Modified framework initiated 404s to log the controller and method for invalid requests.</li>
+ </ul>
+ </li>
+ <li>Helpers
+ <ul>
+ <li>Modified <kbd>get_filenames()</kbd> in the File Helper to return FALSE if the $source_dir is not readable.</li>
+ </ul>
+ </li>
+</ul>
+
+
+<h3>Bugfixes for 1.6.1</h3>
+<ul>
+ <li>Deprecated is_numeric as a validation rule. Use of numeric and integer are preferred.</li>
+ <li>Fixed bug (#3379) in DBForge with SQLite for table creation.</li>
+ <li>Made Active Record fully database prefix aware (#3384).</li>
+ <li>Fixed a bug where DBForge was outputting invalid SQL in Postgres by adding brackets around the tables in FROM.</li>
+ <li>Changed the behaviour of Active Record's update() to make the WHERE clause optional (#3395).</li>
+ <li>Fixed a bug (#3396) where certain POST variables would cause a PHP warning.</li>
+ <li>Fixed a bug in query binding (#3402).</li>
+ <li>Changed order of SQL keywords in the Profiler $highlight array so OR would not be highlighted before ORDER BY.</li>
+ <li>Fixed a bug (#3404) where the MySQLi driver was testing if $this->conn_id was a resource instead of an object.</li>
+ <li>Fixed a bug (#3419) connecting to a database via a DSN string.</li>
+ <li>Fixed a bug (#3445) where the routed segment array was not re-indexed to begin with 1 when the default controller is used.</li>
+ <li>Fixed assorted user guide typos.</li>
+</ul>
+
+
+
+<h2>Version 1.6.0</h2>
+<p>Release Date: January 30, 2008 </p>
+<ul>
+ <li>DBForge
+ <ul>
+ <li>Added <a href="./database/forge.html">DBForge</a> to the database tools.</li>
+ <li>Moved <kbd>create_database()</kbd> and <kbd>drop_database()</kbd> into <a href="./database/forge.html">DBForge</a>.</li>
+ <li>Added <kbd>add_field()</kbd>, <kbd>add_key()</kbd>, <kbd>create_table()</kbd>, <kbd>drop_table()</kbd>, <kbd>add_column()</kbd>, <kbd>drop_column()</kbd>, <kbd>modify_column()</kbd> into <a href="./database/forge.html">DBForge</a>.</li>
+ </ul>
+ </li>
+
+ <li>Active Record
+ <ul>
+ <li>Added <kbd>protect_identifiers()</kbd> in <a href="./database/active_record.html">Active Record</a>.</li>
+ <li>All AR queries are backticked if appropriate to the database.</li>
+ <li>Added <kbd>where_in()</kbd>, <kbd>or_where_in()</kbd>, <kbd>where_not_in()</kbd>, <kbd>or_where_not_in()</kbd>, <kbd>not_like()</kbd> and <kbd>or_not_like()</kbd> to <a href="./database/active_record.html">Active Record</a>.</li>
+ <li>Added support for <kbd>limit()</kbd> into <kbd>update()</kbd> and <kbd>delete()</kbd> statements in <a href="./database/active_record.html">Active Record</a>.</li>
+ <li>Added <kbd>empty_table()</kbd> and <kbd>truncate_table()</kbd> to <a href="./database/active_record.html">Active Record</a>.</li>
+ <li>Added the ability to pass an array of tables to the <kbd>delete()</kbd> statement in <a href="./database/active_record.html">Active Record</a>.</li>
+ <li>Added <kbd>count_all_results()</kbd> function to <a href="./database/active_record.html">Active Record</a>.</li>
+ <li>Added <kbd>select_max()</kbd>, <kbd>select_min()</kbd>, <kbd>select_avg()</kbd> and <kbd>select_sum()</kbd> to <a href="./database/active_record.html">Active Record</a>.</li>
+ <li>Added the ability to use aliases with joins in <a href="./database/active_record.html">Active Record</a>.</li>
+ <li>Added a third parameter to Active Record's <kbd>like()</kbd> clause to control where the wildcard goes. </li>
+ <li>Added a third parameter to <kbd>set()</kbd> in <a href="./database/active_record.html">Active Record</a> that withholds escaping data.</li>
+ <li>Changed the behaviour of variables submitted to the where() clause with no values to auto set &quot;IS NULL&quot;</li>
+ </ul>
+ </li>
+
+ <li>Other Database Related
+ <ul>
+ <li>MySQL driver now requires MySQL 4.1+</li>
+ <li>Added $this->DB->save_queries variable to DB driver, enabling queries to get saved or not. Previously they were always saved.</li>
+ <li>Added $this->db->dbprefix() to manually add database prefixes.</li>
+ <li>Added 'random' as an <kbd>order_by()</kbd> option , and removed &quot;rand()&quot; as a listed option as it was MySQL only.</li>
+ <li>Added a check for NULL fields in the MySQL database backup utility.</li>
+ <li>Added &quot;constrain_by_prefix&quot; parameter to db-&gt;list_table() function. If set to TRUE it will limit the result to only table names with the current prefix.</li>
+ <li>Deprecated from Active Record; <kbd>getwhere()</kbd> for <kbd>get_where()</kbd>; <kbd>groupby()</kbd> for <kbd>group_by()</kbd>; <kbd>havingor()</kbd> for <kbd>having_or()</kbd>; <kbd>orderby()</kbd> for <kbd>order_by</kbd>; <kbd>orwhere()</kbd> for <kbd>or_where()</kbd>; and <kbd>orlike()</kbd> for <kbd>or_like()</kbd>.</li>
+ <li>Modified <kbd>csv_from_result()</kbd> to output CSV data more in the spirit of basic rules of RFC 4180.</li>
+ <li>Added 'char_set' and 'dbcollat' database configuration settings, to explicitly set the client communication properly.</li>
+ <li>Removed 'active_r' configuration setting and replaced with a global $active_record setting, which is more
+ in harmony with the global nature of the behavior (#1834).</li>
+ </ul>
+ </li>
+
+ <li>Core changes
+ <ul>
+ <li>Added ability to load multiple views, whose content will be appended to the output in the order loaded.</li>
+ <li>Added the ability to <a href="./general/autoloader.html">auto-load</a> <a href="./general/models.html">Models</a>.</li>
+ <li>Reorganized the URI and Routes classes for better clarity.</li>
+ <li>Added Compat.php to allow function overrides for older versions of PHP or PHP environments missing certain extensions / libraries</li>
+ <li>Added memory usage, GET, URI string data, and individual query execution time to Profiler output.</li>
+ <li>Deprecated Scaffolding.</li>
+ <li>Added is_really_writable() to Common.php to provide a cross-platform reliable method of testing file/folder writability.</li>
+ </ul>
+ </li>
+
+ <li>Libraries
+ <ul>
+ <li>Changed the load protocol of Models to allow for extension.</li>
+ <li>Strengthened the Encryption library to help protect against man in the middle attacks when MCRYPT_MODE_CBC mode is used.</li>
+ <li>Added Flashdata variables, session_id regeneration and configurable session update times to the <a href="./libraries/sessions.html">Session class.</a></li>
+ <li>Removed 'last_visit' from the Session class.</li>
+ <li>Added a language entry for valid_ip validation error.</li>
+ <li>Modified prep_for_form() in the Validation class to accept arrays, adding support for POST array validation (via callbacks only)</li>
+ <li>Added an &quot;integer&quot; rule into the <a href="./libraries/validation.html">Validation</a> library.</li>
+ <li>Added valid_base64() to the <a href="./libraries/validation.html">Validation</a> library.</li>
+ <li>Documented clear() in the <a href="../libraries/image_lib.html">Image Processing</a> library.</li>
+ <li>Changed the behaviour of custom callbacks so that they no longer trigger the &quot;required&quot; rule. </li>
+ <li>Modified Upload class $_FILES error messages to be more precise.</li>
+ <li>Moved the safe mode and auth checks for the Email library into the constructor. </li>
+ <li>Modified variable names in _ci_load() method of Loader class to avoid conflicts with view variables.</li>
+ <li>Added a few additional mime type variations for CSV.</li>
+ <li>Enabled the 'system' methods for the XML-RPC Server library, except for 'system.multicall' which is still disabled.</li>
+ </ul>
+ </li>
+
+ <li>Helpers &amp; Plugins
+ <ul>
+ <li>Added link_tag() to the <a href="./helpers/html_helper.html">HTML helper.</a></li>
+ <li>Added img() to the <a href="./helpers/html_helper.html">HTML helper.</a></li>
+ <li>Added ability to <a href="./general/helpers.html">"extend" Helpers</a>.</li>
+ <li>Added an <a href="./helpers/email_helper.html">email helper</a> into core helpers.</li>
+ <li>Added <kbd>strip_quotes()</kbd> function to <a href="./helpers/string_helper.html">string helper</a>.</li>
+ <li>Added <kbd>reduce_multiples()</kbd> function to <a href="./helpers/string_helper.html">string helper</a>.</li>
+ <li>Added <kbd>quotes_to_entities()</kbd> function to <a href="./helpers/string_helper.html">string helper</a>.</li>
+ <li>Added <kbd>form_fieldset()</kbd>, <kbd>form_fieldset_close()</kbd>, <kbd>form_label()</kbd>, and <kbd>form_reset()</kbd> function to <a href="./helpers/form_helper.html">form helper</a>.</li>
+ <li>Added support for external urls in <kbd>form_open()</kbd>.</li>
+ <li>Removed support for db_backup in MySQLi due to incompatible functions.</li>
+ <li>Javascript Calendar plugin now uses the months and days from the calendar language file, instead of hard-coded values, internationalizing it.</li>
+ </ul>
+ </li>
+
+
+ <li>Documentation Changes
+ <ul>
+ <li>Added <a href="./doc_style/index.html">Writing Documentation</a> section for the community to use in writing their own documentation.</li>
+ <li>Added titles to all user manual pages.</li>
+ <li>Added attributes into &lt;html&gt; of userguide for valid html.</li>
+ <li>Added <a href="http://codeigniter.com/user_guide/libraries/zip.html">Zip Encoding Class</a> to the table of contents of the userguide.</li>
+ <li>Moved part of the userguide menu javascript to an external file.</li>
+ <li>Documented <kbd>distinct()</kbd> in <a href="./database/active_record.html">Active Record</a>. </li>
+ <li>Documented the <kbd>timezones()</kbd> function in the <a href="./helpers/date_helper.html">Date Helper</a>.</li>
+ <li>Documented unset_userdata in the <a href="./libraries/sessions.html">Session class</a>.</li>
+ <li>Documented 2 config options to the <a href="./database/configuration.html">Database configuration</a> page.</li>
+ </ul>
+ </li>
+</ul>
+
+<h3>Bug fixes for Version 1.6.0</h3>
+
+<ul>
+ <li>Fixed a bug (#1813) preventing using $CI->db in the same application with returned database objects.</li>
+ <li>Fixed a bug (#1842) where the $this->uri->rsegments array would not include the 'index' method if routed to the controller without an implicit method.</li>
+ <li>Fixed a bug (#1872) where word_limiter() was not retaining whitespace.</li>
+ <li>Fixed a bug (#1890) in csv_from_result() where content that included the delimiter would break the file.</li>
+ <li>Fixed a bug (#2542)in the clean_email() method of the Email class to allow for non-numeric / non-sequential array keys.</li>
+ <li>Fixed a bug (#2545) in <kbd>_html_entity_decode_callback()</kbd> when 'global_xss_filtering' is enabled.</li>
+ <li>Fixed a bug (#2668) in the <a href="./libraries/parser.html">parser class</a> where numeric data was ignored.</li>
+ <li>Fixed a bug (#2679) where the &quot;previous&quot; pagination link would get drawn on the first page.</li>
+ <li>Fixed a bug (#2702) in _object_to_array that broke some types of inserts and updates.</li>
+ <li>Fixed a bug (#2732) in the SQLite driver for PHP 4.</li>
+ <li>Fixed a bug (#2754) in Pagination to scan for non-positive num_links.</li>
+ <li>Fixed a bug (#2762) in the <a href="./libraries/sessions.html">Session library</a> where user agent matching would fail on user agents ending with a space. </li>
+ <li>Fixed a bug (#2784) $field_names[] vs $Ffield_names[] in postgres and sqlite drivers.</li>
+ <li>Fixed a bug (#2810) in the typography helper causing extraneous paragraph tags when string contains tags.</li>
+ <li>Fixed a bug (#2849) where arguments passed to a subfolder controller method would be incorrectly shifted, dropping the 3rd segment value.</li>
+ <li>Fixed a bug (#2858) which referenced a wrong variable in the Image class.</li>
+ <li>Fixed a bug (#2875)when loading plugin files as _plugin. and not _pi.</li>
+ <li>Fixed a bug (#2912) in <kbd>get_filenames()</kbd> in the <a href="./helpers/file_helper.html">File Helper </a>where the array wasn't cleared after each call.</li>
+ <li>Fixed a bug (#2974) in <kbd>highlight_phrase()</kbd> that caused an error with slashes.</li>
+ <li>Fixed a bug (#3003) in the Encryption Library to support modes other than MCRYPT_MODE_ECB</li>
+ <li>Fixed a bug (#3015) in the <a href="./libraries/user_agent.html">User Agent library</a> where more then 2 languages where not reported with languages().</li>
+ <li>Fixed a bug (#3017) in the <a href="./libraries/email.html">Email</a> library where some timezones were calculated incorrectly. </li>
+ <li>Fixed a bug (#3024) in which master_dim wasn't getting reset by clear() in the Image library.</li>
+ <li>Fixed a bug (#3156) in Text Helper highlight_code() causing PHP tags to be handled incorrectly.</li>
+ <li>Fixed a bug (#3166) that prevented num_rows from working in Oracle.</li>
+ <li>Fixed a bug (#3175) preventing certain libraries from working properly when autoloaded in PHP 4.</li>
+ <li>Fixed a bug (#3267) in the Typography Helper where unordered list was listed &quot;un.</li>
+ <li>Fixed a bug (#3268) where the Router could leave '/' as the path.</li>
+ <li>Fixed a bug (#3279) where the Email class was sending the wrong Content-Transfer-Encoding for some character sets.</li>
+ <li>Fixed a bug (#3284) where the rsegment array would not be set properly if the requested URI contained more segments than the routed URI.</li>
+ <li>Removed extraneous load of $CFG in _display_cache() of the Output class (#3285).</li>
+ <li>Removed an extraneous call to loading models (#3286).</li>
+ <li>Fixed a bug (#3310) with sanitization of globals in the Input class that could unset CI's global variables.</li>
+ <li>Fixed a bug (#3314) which would cause the top level path to be deleted in delete_files() of the File helper.</li>
+ <li>Fixed a bug (#3328) where the smiley helper might return an undefined variable.</li>
+ <li>Fixed a bug (#3330) in the FTP class where a comparison wasn't getting made.</li>
+ <li>Removed an unused parameter from Profiler (#3332).</li>
+ <li>Fixed a bug in database driver where num_rows property wasn't getting updated.</li>
+ <li>Fixed a bug in the <a href="./libraries/file_uploading.html">upload library</a> when allowed_files wasn't defined.</li>
+ <li>Fixed a bug in <kbd>word_wrap()</kbd> of the Text Helper that incorrectly referenced an object. </li>
+ <li>Fixed a bug in <a href="./libraries/validation.html">Validation</a> where <kbd>valid_ip()</kbd> wasn't called properly.</li>
+ <li>Fixed a bug in <a href="./libraries/validation.html">Validation</a> where individual error messages for checkboxes wasn't supported.</li>
+ <li>Fixed a bug in captcha calling an invalid PHP function.</li>
+ <li>Fixed a bug in the cookie helper "set_cookie" function. It was not honoring the config settings.</li>
+ <li>Fixed a bug that was making validation callbacks required even when not set as such.</li>
+ <li>Fixed a bug in the XML-RPC library so if a type is specified, a more intelligent decision is made as to the default type.</li>
+ <li>Fixed an example of comma-separated emails in the email library documentation.</li>
+ <li>Fixed an example in the Calendar library for Showing Next/Previous Month Links.</li>
+ <li>Fixed a typo in the database language file.</li>
+ <li>Fixed a typo in the image language file &quot;suppor&quot; to &quot;support&quot;.</li>
+ <li>Fixed an example for XML RPC.</li>
+ <li>Fixed an example of <kbd>accept_charset()</kbd> in the <a href="./libraries/user_agent.html">User Agent Library</a>.</li>
+ <li>Fixed a typo in the docblock comments that had CodeIgniter spelled CodeIgnitor.</li>
+ <li>Fixed a typo in the <a href="./helpers/string_helper.html">String Helper</a> (uniquid changed to uniqid).</li>
+ <li>Fixed typos in the email Language class (email_attachment_unredable, email_filed_smtp_login), and FTP Class (ftp_unable_to_remame).</li>
+ <li>Added a stripslashes() into the Upload Library.</li>
+ <li>Fixed a series of grammatical and spelling errors in the language files.</li>
+ <li>Fixed assorted user guide typos.</li>
+</ul>
+<h2>Version 1.5.4</h2>
+<p>Release Date: July 12, 2007 </p>
+<ul>
+ <li>Added <a href="./libraries/language.html">custom Language files</a> to the <a href="./general/autoloader.html">autoload</a> options. </li>
+ <li>Added stripslashes() to the _clean_input_data() function in the <a href="./libraries/input.html">Input class</a> when magic quotes is on so that data will always be un-slashed within the framework.</li>
+ <li>Added array to string into the <a href="general/profiling.html">profiler</a>.</li>
+ <li>Added some additional mime types in application/config/mimes.php.</li>
+ <li>Added filename_security() method to <a href="./libraries/input.html">Input library</a>.</li>
+ <li>Added some additional arguments to the <a href="./helpers/inflector_helper.html">Inflection helper</a> singular() to compensate for words ending in "s". Also added a force parameter to pluralize().</li>
+ <li>Added $config['charset'] to the config file. Default value is 'UTF-8', used in some string handling functions.</li>
+ <li>Fixed MSSQL insert_id().</li>
+ <li>Fixed a logic error in the DB trans_status() function. It was incorrectly returning TRUE on failure and FALSE on success.</li>
+ <li>Fixed a bug that was allowing multiple load attempts on extended classes.</li>
+ <li>Fixed a bug in the bootstrap file that was incorrectly attempting to discern the full server path even when it was explicity set by the user.</li>
+ <li>Fixed a bug in the escape_str() function in the MySQL driver.</li>
+ <li>Fixed a typo in the <a href="./libraries/calendar.html">Calendar library </a> </li>
+ <li>Fixed a typo in rpcs.php library</li>
+ <li>Fixed a bug in the <a href="./libraries/zip.html">Zip library</a>, providing PC Zip file compatibility with Mac OS X</li>
+ <li>Fixed a bug in router that was ignoring the scaffolding route for optimization </li>
+ <li>Fixed an IP validation bug.</li>
+ <li>Fixed a bug in display of POST keys in the <a href="./general/profiling.html">Profiler</a> output</li>
+ <li>Fixed a bug in display of queries with characters that would be interpreted as HTML in the <a href="./general/profiling.html">Profiler</a> output</li>
+ <li>Fixed a bug in display of Email class print debugger with characters that would be interpreted as HTML in the debugging output</li>
+ <li>Fixed a bug in the Content-Transfer-Encoding of HTML emails with the quoted-printable MIME type</li>
+ <li>Fixed a bug where one could unset certain PHP superglobals by setting them via GET or POST data</li>
+ <li>Fixed an undefined function error in the insert_id() function of the PostgreSQL driver</li>
+ <li>Fixed various doc typos. </li>
+ <li>Documented two functions from the <a href="./helpers/string_helper.html">String helper </a> that were missing from the user guide: trim_slashes() and reduce_double_slashes().</li>
+ <li>Docs now validate to XHTML 1 transitional</li>
+ <li>Updated the XSS Filtering to take into account the IE expression() ability and improved certain deletions to prevent possible exploits</li>
+ <li>Modified the Router so that when Query Strings are Enabled, the controller trigger and function trigger values are sanitized for filename include security.</li>
+ <li>Modified the is_image() method in the Upload library to take into account Windows IE 6/7 eccentricities when dealing with MIMEs</li>
+ <li>Modified XSS Cleaning routine to be more performance friendly and compatible with PHP 5.2's new PCRE backtrack and recursion limits.</li>
+ <li>Modified the <a href="./helpers/url_helper.html">URL Helper</a> to type cast the $title as a string in case a numeric value is supplied</li>
+ <li>Modified Form Helper form_dropdown() to type cast the keys and values of the options array as strings, allowing numeric values to be properly set as 'selected'</li>
+ <li>Deprecated the use if <kbd>is_numeric()</kbd> in various places since it allows periods. Due to compatibility problems with <kbd>ctype_digit()</kbd>, making it unreliable in some installations, the following regular expression was used instead: <kbd>preg_match("/[^0-9]/", $n)</kbd></li>
+ <li>Deprecated: APPVER has been deprecated and replaced with CI_VERSION for clarity. </li>
+</ul>
+<h2>Version 1.5.3</h2>
+<p>Release Date: April 15, 2007 </p>
+<ul>
+ <li>Added array to string into the profiler </li>
+ <li>Code Igniter references updated to CodeIgniter </li>
+ <li>pMachine references updated to EllisLab </li>
+ <li>Fixed a bug in the repeater function of <a href="./helpers/string_helper.html">string helper</a>. </li>
+ <li>Fixed a bug in ODBC driver </li>
+ <li>Fixed a bug in result_array() that was returning an empty array when no result is produced.</li>
+ <li>Fixed a bug in the redirect function of the <a href="./helpers/url_helper.html">url helper</a>. </li>
+ <li>Fixed an undefined variable in Loader </li>
+ <li>Fixed a version bug in the Postgres driver </li>
+ <li>Fixed a bug in the textarea function of the form helper for use with strings</li>
+ <li>Fixed doc typos. </li>
+</ul>
+<h2>Version 1.5.2</h2>
+<p>Release Date: February 13, 2007 </p>
+<ul>
+ <li>Added <a href="./installation/downloads.html#svn">subversion information</a> to the <a href="./installation/downloads.html">downloads</a> page. </li>
+ <li>Added support for captions in the <a href="./libraries/table.html">Table Library</a> </li>
+ <li>Fixed a bug in the <a href="./helpers/download_helper.html">download_helper</a> that was causing Internet Explorer to load rather than download </li>
+ <li>Fixed a bug in the Active Record Join function that was not taking table prefixes into consideration.</li>
+ <li>Removed unescaped variables in error messages of Input and Router classes</li>
+ <li>Fixed a bug in the Loader that was causing errors on Libraries loaded twice. A debug message is now silently made in the log. </li>
+ <li>Fixed a bug in the <a href="./helpers/form_helper.html">form helper</a> that gave textarea a value attribute </li>
+ <li>Fixed a bug in the <a href="./libraries/image_lib.php">Image Library</a> that was ignoring resizing the same size image </li>
+ <li>Fixed some doc typos.</li>
+</ul>
+
+
+<h2>Version 1.5.1</h2>
+<p>Release Date: November 23, 2006</p>
+<ul>
+ <li>Added support for submitting arrays of libraries in the $this-&gt;load-&gt;library function.</li>
+ <li>Added support for naming custom library files in lower or uppercase.</li>
+ <li>Fixed a bug related to output buffering.</li>
+ <li>Fixed a bug in the active record class that was not resetting query data after a completed query.</li>
+ <li>Fixed a bug that was suppressing errors in controllers.</li>
+ <li>Fixed a problem that can cause a loop to occur when the config file is missing.</li>
+ <li>Fixed a bug that occurred when multiple models were loaded with the third parameter set to TRUE.</li>
+ <li>Fixed an oversight that was not unsetting globals properly in the input sanitize function.</li>
+ <li>Fixed some bugs in the Oracle DB driver.</li>
+ <li>Fixed an incorrectly named variable in the MySQLi result driver.</li>
+ <li>Fixed some doc typos.</li>
+</ul>
+<h2>Version 1.5.0.1</h2>
+<p>Release Date: October 31, 2006</p>
+<ul>
+<li>Fixed a problem in which duplicate attempts to load helpers and classes were not being stopped.</li>
+<li>Fixed a bug in the word_wrap() helper function.</li>
+<li>Fixed an invalid color Hex number in the Profiler class.</li>
+<li>Fixed a corrupted image in the user guide.</li>
+</ul>
+
+
+
+<h2>Version 1.5.0</h2>
+<p>Release Date: October 30, 2006</p>
+
+<ul>
+<li>Added <a href="./database/utilities.html">DB utility class</a>, permitting DB backups, CVS or XML files from DB results, and various other functions.</li>
+<li>Added <a href="./database/caching.html">Database Caching Class</a>.</li>
+<li>Added <a href="./database/transactions.html">transaction support</a> to the database classes.</li>
+<li>Added <a href="./general/profiling.html">Profiler Class</a> which generates a report of Benchmark execution times, queries, and POST data at the bottom of your pages.</li>
+<li>Added <a href="./libraries/user_agent.html">User Agent Library</a> which allows browsers, robots, and mobile devises to be identified.</li>
+<li>Added <a href="./libraries/table.html">HTML Table Class</a> , enabling tables to be generated from arrays or database results.</li>
+<li>Added <a href="./libraries/zip.html">Zip Encoding Library</a>.</li>
+<li>Added <a href="./libraries/ftp.html">FTP Library</a>.</li>
+<li>Added the ability to <a href="./general/creating_libraries.html">extend libraries</a> and <a href="./general/core_classes.html">extend core classes</a>, in addition to being able to replace them.</li>
+<li>Added support for storing <a href="./general/models.html">models within sub-folders</a>.</li>
+<li>Added <a href="./helpers/download_helper.html">Download Helper</a>.</li>
+<li>Added <a href="./database/queries.html">simple_query()</a> function to the database classes</li>
+<li>Added <a href="./helpers/date_helper.html">standard_date()</a> function to the Date Helper.</li>
+<li>Added <a href="./database/results.html">$query->free_result()</a> to database class.</li>
+<li>Added <a href="./database/fields.html">$query->list_fields()</a> function to database class</li>
+<li>Added <a href="./database/helpers.html">$this->db->platform()</a> function</li>
+<li>Added new <a href="./helpers/file_helper.html">File Helper</a>: get_filenames()</li>
+<li>Added new helper: <a href="./helpers/smiley_helper.html">Smiley Helper</a></li>
+<li>Added support for &lt;ul> and &lt;ol> lists in the <a href="./helpers/html_helper.html">HTML Helper</a></li>
+<li>Added the ability to rewrite <a href="./general/alternative_php.html">short tags</a> on-the-fly, converting them to standard PHP statements, for those servers that do not support short tags. This allows the cleaner syntax to be used regardless of whether it's supported by the server.</li>
+<li>Added the ability to <a href="./general/managing_apps.html">rename or relocate the "application" folder</a>.</li>
+<li>Added more thorough initialization in the upload class so that all class variables are reset.</li>
+<li>Added "is_numeric" to validation, which uses the native PHP is_numeric function.</li>
+<li>Improved the URI handler to make it more reliable when the $config['uri_protocol'] item is set to AUTO.</li>
+<li>Moved most of the functions in the Controller class into the Loader class, allowing fewer reserved function names for controllers when running under PHP 5.</li>
+<li>Updated the DB Result class to return an empty array when $query->result() doesn't produce a result.</li>
+<li>Updated the <dfn>input->cookie()</dfn> and <dfn>input->post()</dfn> functions in <a href="./libraries/input.html">Input Class</a> to permit arrays contained cookies that are arrays to be run through the XSS filter.</li>
+<li>Documented three functions from the <a href="./libraries/validation.html">Validation class</a> that were missing from the user guide: set_select(), set_radio(), and set_checkbox().</li>
+<li>Fixed a bug in the Email class related to SMTP Helo data.</li>
+<li>Fixed a bug in the word wrapping helper and function in the email class.</li>
+<li>Fixed a bug in the validation class.</li>
+<li>Fixed a bug in the typography helper that was incorrectly wrapping block level elements in paragraph tags.</li>
+<li>Fixed a problem in the form_prep() function that was double encoding entities.</li>
+<li>Fixed a bug that affects some versions of PHP when output buffering is nested.</li>
+<li>Fixed a bug that caused CI to stop working when the PHP magic __get() or __set() functions were used within models or controllers.</li>
+<li>Fixed a pagination bug that was permitting negative values in the URL.</li>
+<li>Fixed an oversight in which the Loader class was not allowed to be exteneded.</li>
+<li>Changed <dfn>_get_config()</dfn> to <dfn>get_config()</dfn> since the function is not a private one.</li>
+<li><strong>Deprecated "init" folder</strong>. Initialization happens automatically now. <a href="./general/creating_libraries.html">Please see documentation</a>.</li>
+<li><strong>Deprecated</strong> $this->db->field_names() USE $this->db->list_fields()</li>
+<li><strong>Deprecated</strong> the <dfn>$config['log_errors']</dfn> item from the config.php file. Instead, <dfn>$config['log_threshold']</dfn> can be set to "0" to turn it off.</li>
+</ul>
+
+
+
+
+<h2>Version 1.4.1</h2>
+<p>Release Date: September 21, 2006</p>
+
+<ul>
+<li>Added a new feature that passes URI segments directly to your function calls as parameters. See the <a href="controllers.html">Controllers</a> page for more info.</li>
+<li>Added support for a function named <dfn>_output()</dfn>, which when used in your controllers will received the final rendered output from the output class. More info in the <a href="controllers.html">Controllers</a> page.</li>
+<li>Added several new functions in the <a href="./libraries/uri.html">URI Class</a> to let you retrieve and manipulate URI segments that have been re-routed using the <a href="routing.html">URI Routing</a> feature. Previously, the URI class did not permit you to access any re-routed URI segments, but now it does.</li>
+<li>Added <a href="./libraries/output.html">$this->output->set_header()</a> function, which allows you to set server headers.</li>
+<li>Updated plugins, helpers, and language classes to allow your <dfn>application</dfn> folder to contain its own plugins, helpers, and language folders. Previously they were always treated as global for your entire installation. If your application folder contains any of these resources they will be used <em>instead</em> the global ones.</li>
+<li>Added <a href="./helpers/inflector_helper.html">Inflector helper</a>.</li>
+<li>Added <dfn>element()</dfn> function in the <a href="./helpers/array_helper.html">array helper</a>.</li>
+<li>Added <dfn>RAND()</dfn> to active record <dfn>orderby()</dfn> function.</li>
+<li>Added <dfn>delete_cookie()</dfn> and <dfn>get_cookie()</dfn> to <a href="./helpers/cookie_helper.html">Cookie helper</a>, even though the input class has a cookie fetching function.</li>
+<li>Added Oracle database driver (still undergoing testing so it might have some bugs).</li>
+<li>Added the ability to combine pseudo-variables and php variables in the template parser class.</li>
+<li>Added output compression option to the config file.</li>
+<li>Removed the is_numeric test from the db->escape() function.</li>
+<li>Fixed a MySQLi bug that was causing error messages not to contain proper error data.</li>
+<li>Fixed a bug in the email class which was causing it to ignore explicitly set alternative headers.</li>
+<li>Fixed a bug that was causing a PHP error when the Exceptions class was called within the get_config() function since it was causing problems.</li>
+<li>Fixed an oversight in the cookie helper in which the config file cookie settings were not being honored.</li>
+<li>Fixed an oversight in the upload class. An item mentioned in the 1.4 changelog was missing.</li>
+<li>Added some code to allow email attachments to be reset when sending batches of email.</li>
+<li>Deprecated the <dfn>application/scripts</dfn> folder. It will continue to work for legacy users, but it is recommended that you create your own
+<a href="./general/libraries.html">libraries</a> or <a href="./general/models.html">models</a> instead. It was originally added before CI had user libraries or models, but it's not needed anymore.</li>
+<li>Deprecated the <dfn>$autoload['core']</dfn> item from the <kbd>autoload.php</kbd> file. Instead, please now use: <kbd>$autoload['libraries']</kbd></li>
+<li>Deprecated the following database functions: $this->db->smart_escape_str() and $this->db->fields().</li>
+</ul>
+
+
+
+<h2>Version 1.4.0</h2>
+<p>Release Date: September 17, 2006</p>
+
+<ul>
+<li>Added <a href="hooks.html">Hooks</a> feature, enabling you to tap into and modify the inner workings of the framework without hacking the core files.</li>
+<li>Added the ability to organize controller files <a href="controllers.html">into sub-folders</a>. Kudos to Marco for <a href="http://codeigniter.com/forums/viewthread/627/">suggesting</a> this (and the next two) feature.</li>
+<li>Added regular expressions support for <a href="routing.html">routing rules</a>.</li>
+<li>Added the ability to <a href="controllers.html">remap function calls</a> within your controllers.</li>
+<li>Added the ability to <a href="core_classes.html">replace core system classes</a> with your own classes.</li>
+<li>Added support for % character in URL.</li>
+<li>Added the ability to supply full URLs using the <a href="./helpers/url_helper.html">anchor()</a> helper function.</li>
+<li>Added mode parameter to <a href="./helpers/file_helper.html">file_write()</a> helper.</li>
+<li>Added support for changing the port number in the <a href="./database/configuration.html">Postgres driver</a>.</li>
+<li>Moved the list of "allowed URI characters" out of the Router class and into the config file.</li>
+<li>Moved the MIME type array out of the Upload class and into its own file in the applications/config/ folder.</li>
+<li>Updated the Upload class to allow the upload field name to be set when calling <a href="./libraries/file_uploading.html">do_upload()</a>.</li>
+<li>Updated the <a href="./libraries/config.html">Config Library</a> to be able to load config files silently, and to be able to assign config files to their own index (to avoid collisions if you use multiple config files).</li>
+<li>Updated the URI Protocol code to allow more options so that URLs will work more reliably in different environments.</li>
+<li>Updated the <dfn>form_open()</dfn> helper to allow the GET method to be used.</li>
+<li>Updated the MySQLi <dfn>execute()</dfn> function with some code to help prevent lost connection errors.</li>
+<li>Updated the SQLite Driver to check for object support before attempting to return results as objects. If unsupported it returns an array.</li>
+<li>Updated the Models loader function to allow multiple loads of the same model.</li>
+<li>Updated the MS SQL driver so that single quotes are escaped.</li>
+<li>Updated the Postgres and ODBC drivers for better compatibility.</li>
+<li>Removed a strtolower() call that was changing URL segments to lower case.</li>
+<li>Removed some references that were interfering with PHP 4.4.1 compatibility.</li>
+<li>Removed backticks from Postgres class since these are not needed.</li>
+<li>Renamed <dfn>display()</dfn> to <dfn>_display()</dfn> in the Output class to make it clear that it's a private function.</li>
+<li>Deprecated the hash() function due to a naming conflict with a native PHP function with the same name. Please use <kbd>dohash()</kbd> instead.</li>
+<li>Fixed an bug that was preventing the input class from unsetting GET variables.</li>
+<li>Fixed a router bug that was making it too greedy when matching end segments.</li>
+<li>Fixed a bug that was preventing multiple discrete database calls.</li>
+<li>Fixed a bug in which loading a language file was producing a "file contains no data" message.</li>
+<li>Fixed a session bug caused by the XSS Filtering feature inadvertently changing the case of certain words.</li>
+<li>Fixed some missing prefixes when using the database prefix feature.</li>
+<li>Fixed a typo in the Calendar class (cal_november).</li>
+<li>Fixed a bug in the <dfn>form_checkbox()</dfn> helper.</li>
+<li>Fixed a bug that was allowing the second segment of the URI to be identical to the class name.</li>
+<li>Fixed an evaluation bug in the database initialization function.</li>
+<li>Fixed a minor bug in one of the error messages in the language class.</li>
+<li>Fixed a bug in the date helper <dfn>timespan</dfn> function.</li>
+<li>Fixed an undefined variable in the DB Driver class.</li>
+<li>Fixed a bug in which dollar signs used as binding replacement values in the DB class would be treated as RegEx back-references.</li>
+<li>Fixed a bug in the <dfn>set_hash()</dfn> function which was preventing MD5 from being used.</li>
+<li>Fixed a couple bugs in the Unit Testing class.</li>
+<li>Fixed an incorrectly named variable in the Validation class.</li>
+<li>Fixed an incorrectly named variable in the URI class.</li>
+<li>Fixed a bug in the config class that was preventing the base URL from being called properly.</li>
+<li>Fixed a bug in the validation class that was not permitting callbacks if the form field was empty.</li>
+<li>Fixed a problem that was preventing scaffolding from working properly with MySQLi.</li>
+<li>Fixed some MS SQL bugs.</li>
+<li>Fixed some doc typos.</li>
+</ul>
+
+
+
+<h2>Version 1.3.3</h2>
+<p>Release Date: June 1, 2006</p>
+
+<ul>
+
+<li>Models do <strong>not</strong> connect automatically to the database as of this version. <a href="./general/models.html">More info here</a>.</li>
+<li>Updated the Sessions class to utilize the active record class when running session related queries. Previously the queries assumed MySQL syntax.</li>
+<li>Updated alternator() function to re-initialize when called with no arguments, allowing multiple calls.</li>
+<li>Fixed a bug in the active record "having" function.</li>
+<li>Fixed a problem in the validation class which was making checkboxes be ignored when required.</li>
+<li>Fixed a bug in the word_limiter() helper function. It was cutting off the fist word.</li>
+<li>Fixed a bug in the xss_clean function due to a PHP bug that affects some versions of html_entity_decode.</li>
+<li>Fixed a validation bug that was preventing rules from being set twice in one controller.</li>
+<li>Fixed a calendar bug that was not letting it use dynamically loaded languages.</li>
+<li>Fixed a bug in the active record class when using WHERE clauses with LIKE</li>
+<li>Fixed a bug in the hash() security helper.</li>
+<li>Fixed some typos.</li>
+</ul>
+
+
+
+
+<h2>Version 1.3.2</h2>
+<p>Release Date: April 17, 2006</p>
+
+<ul>
+<li>Changed the behavior of the validation class such that if a "required" rule is NOT explicitly stated for a field then all other tests get ignored.</li>
+<li>Fixed a bug in the Controller class that was causing it to look in the local "init" folder instead of the main system one.</li>
+<li>Fixed a bug in the init_pagination file. The $config item was not being set correctly.</li>
+<li>Fixed a bug in the auto typography helper that was causing inconsistent behavior.</li>
+<li>Fixed a couple bugs in the Model class.</li>
+<li>Fixed some documentation typos and errata.</li>
+</ul>
+
+
+
+<h2>Version 1.3.1</h2>
+<p>Release Date: April 11, 2006</p>
+
+<ul>
+<li>Added a <a href="./libraries/unit_testing.html">Unit Testing Library</a>.</li>
+<li>Added the ability to pass objects to the <strong>insert()</strong> and <strong>update()</strong> database functions.
+This feature enables you to (among other things) use your <a href="./general/models.html">Model class</a> variables to run queries with. See the Models page for details.</li>
+<li>Added the ability to pass objects to the <a href="./general/views.html">view loading function</a>: $this->load->view('my_view', <var>$object</var>);</li>
+<li>Added <kbd>getwhere</kbd> function to <a href="./database/active_record.html">Active Record class</a>.</li>
+<li>Added <kbd>count_all</kbd> function to <a href="./database/active_record.html">Active Record class</a>.</li>
+<li>Added language file for scaffolding and fixed a scaffolding bug that occurs when there are no rows in the specified table.</li>
+<li>Added <a href="./database/queries.html">$this->db->last_query()</a>, which allows you to view your last query that was run.</li>
+<li>Added a new mime type to the upload class for better compatibility.</li>
+<li>Changed how cache files are read to prevent PHP errors if the cache file contains an XML tag, which PHP wants to interpret as a short tag.</li>
+<li>Fixed a bug in a couple of the active record functions (where and orderby).</li>
+<li>Fixed a bug in the image library when realpath() returns false.</li>
+<li>Fixed a bug in the Models that was preventing libraries from being used within them.</li>
+<li>Fixed a bug in the "exact_length" function of the validation class.</li>
+<li>Fixed some typos in the user guide</li>
+</ul>
+
+
+<h2>Version 1.3</h2>
+<p>Release Date: April 3, 2006</p>
+
+<ul>
+<li>Added support for <a href="models.html">Models</a>.</li>
+<li>Redesigned the database libraries to support additional RDBMs (Postgres, MySQLi, etc.).</li>
+<li>Redesigned the <a href="./database/active_record.html">Active Record class</a> to enable more varied types of queries with simpler syntax, and advanced features like JOINs.</li>
+<li>Added a feature to the database class that lets you run <a href="./database/call_function.html">custom function calls</a>.</li>
+<li>Added support for <a href="controllers.html">private functions</a> in your controllers. Any controller function name that starts with an underscore will not be served by a URI request.</li>
+<li>Added the ability to pass your own initialization parameters to your <a href="creating_libraries.html">custom core libraries</a> when using $this->load->library()</li>
+<li>Added support for running standard <a href="urls.html">query string URLs</a>. These can be optionally enabled in your config file.</li>
+<li>Added the ability to <a href="urls.html">specify a "suffix"</a>, which will be appended to your URLs. For example, you could add .html to your URLs, making them appear static. This feature is enabled in your config file.</li>
+<li>Added a new error template for use with native PHP errors.</li>
+<li>Added "alternator" function in the <a href="./helpers/string_helper.html">string helpers</a>.</li>
+<li>Removed slashing from the input class. After much debate we decided to kill this feature.</li>
+<li>Change the commenting style in the scripts to the PEAR standard so that IDEs and tools like phpDocumenter can harvest the comments.</li>
+<li>Added better class and function name-spacing to avoid collisions with user developed classes. All CodeIgniter classes are now prefixed with <dfn>CI_</dfn> and
+all controller methods are prefixed with <dfn>_ci</dfn> to avoid controller collisions. A list of reserved function names can be <a href="controllers.html">found here</a>.</li>
+<li>Redesigned how the "CI" super object is referenced, depending on whether PHP 4 or 5 is being run, since PHP 5 allows a more graceful way to manage objects that utilizes a bit less resources.</li>
+<li>Deprecated: <var>$this->db->use_table()</var> has been deprecated. Please read the <a href="./database/active_record.html">Active Record</a> page for information.</li>
+<li>Deprecated: <var>$this->db->smart_escape_str()</var> has been deprecated. Please use this instead: <var>$this->db->escape()</var></li>
+<li>Fixed a bug in the exception handler which was preventing some PHP errors from showing up.</li>
+<li>Fixed a typo in the URI class. $this->total_segment() should be plural: $this->total_segments()</li>
+<li>Fixed some typos in the default calendar template</li>
+<li>Fixed some typos in the user guide</li>
+</ul>
+
+
+
+
+
+
+
+
+<h2>Version 1.2</h2>
+<p>Release Date: March 21, 2006</p>
+
+<ul>
+<li>Redesigned some internal aspects of the framework to resolve scoping problems that surfaced during the beta tests. The problem was most notable when instantiating classes in your constructors, particularly if those classes in turn did work in their constructors.</li>
+<li>Added a global function named <a href="ancillary_classes.html">get_instance()</a> allowing the main CodeIgniter object to be accessible throughout your own classes.</li>
+<li>Added new <a href="./helpers/file_helper.html">File Helper</a>: delete_files()</li>
+<li>Added new <a href="./helpers/url_helper.html">URL Helpers</a>: base_url(), index_page()</li>
+<li>Added the ability to create your own <a href="creating_libraries.html">core libraries</a> and store them in your local application directory.</li>
+<li>Added an <kbd>overwrite</kbd> option to the <a href="./libraries/file_uploading.html">Upload class</a>, enabling files to be overwritten rather than having the file name appended.</li>
+<li>Added Javascript Calendar plugin.</li>
+<li>Added search feature to user guide. Note: This is done using Google, which at the time of this writing has not crawled all the pages of the docs.</li>
+<li>Updated the parser class so that it allows tag pars within other tag pairs.</li>
+<li>Fixed a bug in the DB "where" function.</li>
+<li>Fixed a bug that was preventing custom config files to be auto-loaded.</li>
+<li>Fixed a bug in the mysql class bind feature that prevented question marks in the replacement data.</li>
+<li>Fixed some bugs in the xss_clean function</li>
+</ul>
+
+
+
+
+
+<h2>Version Beta 1.1</h2>
+<p>Release Date: March 10, 2006</p>
+
+<ul>
+<li>Added a <a href="./libraries/calendar.html">Calendaring class</a>.</li>
+<li>Added support for running <a href="managing_apps.html">multiple applications</a> that share a common CodeIgniter backend.</li>
+<li>Moved the "uri protocol" variable from the index.php file into the config.php file</li>
+<li>Fixed a problem that was preventing certain function calls from working within constructors.</li>
+<li>Fixed a problem that was preventing the $this->load->library function from working in constructors.</li>
+<li>Fixed a bug that occurred when the session class was loaded using the auto-load routine.</li>
+<li>Fixed a bug that can happen with PHP versions that do not support the E_STRICT constant</li>
+<li>Fixed a data type error in the form_radio function (form helper)</li>
+<li>Fixed a bug that was preventing the xss_clean function from being called from the validation class.</li>
+<li>Fixed the cookie related config names, which were incorrectly specified as $conf rather than $config</li>
+<li>Fixed a pagination problem in the scaffolding.</li>
+<li>Fixed a bug in the mysql class "where" function.</li>
+<li>Fixed a regex problem in some code that trimmed duplicate slashes.</li>
+<li>Fixed a bug in the br() function in the HTML helper</li>
+<li>Fixed a syntax mistake in the form_dropdown function in the Form Helper.</li>
+<li>Removed the "style" attributes form the form helpers.</li>
+<li>Updated the documentation. Added "next/previous" links to each page and fixed various typos.</li>
+</ul>
+
+<h2>Version Beta 1.0 </h2>
+<p>Release Date: February 28, 2006</p>
+<p>First publicly released version.</p>
+
+</div>
+<!-- END CONTENT -->
+
+
+<div id="footer">
+<p>
+Previous Topic:&nbsp;&nbsp;<a href="license.html">License Agreement</a>
+&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="#top">Top of Page</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="index.html">User Guide Home</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+Next Topic:&nbsp;&nbsp;<a href="./general/credits.html">Credits</a>
+</p>
+<p><a href="http://codeigniter.com">CodeIgniter</a> &nbsp;&middot;&nbsp; Copyright &#169; 2006-2008 &nbsp;&middot;&nbsp; <a href="http://ellislab.com/">Ellislab, Inc.</a></p>
+</div>
+
+</body>
+</html>
diff --git a/user_guide/general/styleguide.html b/user_guide/general/styleguide.html
index 43385d064..faa1a8ff1 100644
--- a/user_guide/general/styleguide.html
+++ b/user_guide/general/styleguide.html
@@ -1,649 +1,649 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
-<head>
-
-<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
-<title>Style Guide : CodeIgniter User Guide</title>
-
-<style type='text/css' media='all'>@import url('../userguide.css');</style>
-<link rel='stylesheet' type='text/css' media='all' href='../userguide.css' />
-
-<style type="text/css" media="screen">
- code {
- white-space: pre;
- }
-</style>
-
-<script type="text/javascript" src="../nav/nav.js"></script>
-<script type="text/javascript" src="../nav/prototype.lite.js"></script>
-<script type="text/javascript" src="../nav/moo.fx.js"></script>
-<script type="text/javascript" src="../nav/user_guide_menu.js"></script>
-
-<meta http-equiv='expires' content='-1' />
-<meta http-equiv= 'pragma' content='no-cache' />
-<meta name='robots' content='all' />
-<meta name='author' content='ExpressionEngine Dev Team' />
-<meta name='description' content='CodeIgniter User Guide' />
-
-</head>
-<body>
-
-<!-- START NAVIGATION -->
-<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div>
-<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle_darker.jpg" width="154" height="43" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
-<div id="masthead">
-<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
-<tr>
-<td><h1>CodeIgniter User Guide Version 1.7</h1></td>
-<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
-</tr>
-</table>
-</div>
-<!-- END NAVIGATION -->
-
-
-<!-- START BREADCRUMB -->
-<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
-<tr>
-<td id="breadcrumb">
-<a href="http://codeigniter.com/">CodeIgniter Home</a> &nbsp;&#8250;&nbsp;
-<a href="../index.html">User Guide Home</a> &nbsp;&#8250;&nbsp;
-Style Guide
-</td>
-<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide&nbsp; <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" />&nbsp;<input type="submit" class="submit" name="sa" value="Go" /></form></td>
-</tr>
-</table>
-<!-- END BREADCRUMB -->
-
-<br clear="all" />
-
-
-<!-- START CONTENT -->
-<div id="content">
-
-
-<h1>General Style and Syntax</h1>
-
-<p>The following page describes the coding rules use adhere to when developing CodeIgniter.</p>
-
-
-<h2>Table of Contents</h2>
-<ul class="minitoc">
- <li><a href="#php_closing_tag">PHP Closing Tag</a></li>
- <li><a href="#class_and_method_naming">Class and Method Naming</a></li>
- <li><a href="#variable_names">Variable Names</a></li>
- <li><a href="#commenting">Commenting</a></li>
- <li><a href="#constants">Constants</a></li>
- <li><a href="#true_false_and_null">TRUE, FALSE, and NULL</a></li>
- <li><a href="#logical_operators">Logical Operators</a></li>
- <li><a href="#comparing_return_values_and_typecasting">Comparing Return Values and Typecasting</a></li>
- <li><a href="#debugging_code">Debugging Code</a></li>
- <li><a href="#whitespace_in_files">Whitespace in Files</a></li>
- <li><a href="#compatibility">Compatibility</a></li>
- <li><a href="#class_and_file_names_using_common_words">Class and File Names using Common Words</a></li>
- <li><a href="#database_table_names">Database Table Names</a></li>
- <li><a href="#one_file_per_class">One File per Class</a></li>
- <li><a href="#whitespace">Whitespace</a></li>
- <li><a href="#line_breaks">Line Breaks</a></li>
- <li><a href="#code_indenting">Code Indenting</a></li>
- <li><a href="#bracket_spacing">Bracket and Parenthetic Spacing</li>
- <li><a href="#localized_text_in_control_panel">Localized Text in Control Panel</a></li>
- <li><a href="#private_methods_and_variables">Private Methods and Variables</a></li>
- <li><a href="#php_errors">PHP Errors</a></li>
- <li><a href="#short_open_tags">Short Open Tags</a></li>
- <li><a href="#one_statement_per_line">One Statement Per Line</a></li>
- <li><a href="#strings">Strings</a></li>
- <li><a href="#sql_queries">SQL Queries</a></li>
- <li><a href="#default_function_arguments">Default Function Arguments</a></li>
- <li><a href="#overlapping_tag_parameters">Overlapping Tag Parameters</a></li>
-</ul>
-
- <h2><a name="php_closing_tag"></a>PHP Closing Tag</h2>
- <div class="guidelineDetails">
- <p>The PHP closing tag on a PHP document <strong>?&gt;</strong> is optional to the PHP parser. However, if used, any whitespace following the closing tag, whether introduced
- by the developer, user, or an FTP application, can cause unwanted output, PHP errors, or if the latter are suppressed, blank pages. For this reason, all PHP files should
- <strong>OMIT</strong> the closing PHP tag, and instead use a comment block to mark the end of file and it's location relative to the application root.
- This allows you to still identify a file as being complete and not truncated.</p>
-<code><strong>INCORRECT</strong>:
-&lt;?php
-
-echo "Here's my code!";
-
-?&gt;
-
-<strong>CORRECT</strong>:
-&lt;?php
-
-echo "Here's my code!";
-
-/* End of file myfile.php */
-/* Location: ./system/modules/mymodule/myfile.php */
-</code>
- </div>
-
-
- <h2><a name="class_and_method_naming"></a>Class and Method Naming</h2>
- <div class="guidelineDetails">
- <p>Class names should always have their first letter uppercase, and the constructor method should match identically. Multiple words should be separated with an underscore, and not CamelCased. All other class methods should be entirely lowercased and named to clearly indicate their function, preferably including a verb. Try to avoid overly long and verbose names.</p>
-
- <code><strong>INCORRECT</strong>:
-class superclass
-class SuperClass
-
-<strong>CORRECT</strong>:
-class Super_class</code>
-
- <p>Notice that the Class and constructor methods are identically named and cased:</p>
-
- <code>class Super_class {
-
- function Super_class()
- {
-
- }
-}</code>
-
- <p>Examples of improper and proper method naming:</p>
-
- <code><strong>INCORRECT</strong>:
-function fileproperties() // not descriptive and needs underscore separator
-function fileProperties() // not descriptive and uses CamelCase
-function getfileproperties() // Better! But still missing underscore separator
-function getFileProperties() // uses CamelCase
-function get_the_file_properties_from_the_file() // wordy
-
-<strong>CORRECT</strong>:
-function get_file_properties() // descriptive, underscore separator, and all lowercase letters</code>
-
- </div>
-
-
- <h2><a name="variable_names"></a>Variable Names</h2>
- <div class="guidelineDetails">
- <p>The guidelines for variable naming is very similar to that used for class methods. Namely, variables should contain only lowercase letters, use underscore separators, and be reasonably named to indicate their purpose and contents. Very short, non-word variables should only be used as iterators in for() loops.</p>
-<code><strong>INCORRECT</strong>:
-$j = &apos;foo&apos;; // single letter variables should only be used in for() loops
-$Str // contains uppercase letters
-$bufferedText // uses CamelCasing, and could be shortened without losing semantic meaning
-$groupid // multiple words, needs underscore separator
-$name_of_last_city_used // too long
-
-<strong>CORRECT</strong>:
-for ($j = 0; $j &lt; 10; $j++)
-$str
-$buffer
-$group_id
-$last_city
-</code>
- </div>
-
-
- <h2><a name="commenting"></a>Commenting</h2>
- <div class="guidelineDetails">
- <p>In general, code should be commented prolifically. It not only helps describe the flow and intent of the code for less experienced programmers, but can prove invaluable when returning to your own code months down the line. There is not a required format for comments, but the following are recommended.</p>
-
- <p><a href="http://manual.phpdoc.org/HTMLSmartyConverter/HandS/phpDocumentor/tutorial_phpDocumentor.howto.pkg.html#basics.docblock">DocBlock</a> style comments preceding class and method declarations so they can be picked up by IDEs:</p>
-
-<code>/**
- * Super Class
- *
- * @package Package Name
- * @subpackage Subpackage
- * @category Category
- * @author Author Name
- * @link http://example.com
- */
-class Super_class {</code>
-
-<code>/**
- * Encodes string for use in XML
- *
- * @access public
- * @param string
- * @return string
- */
-function xml_encode($str)</code>
-
- <p>Use single line comments within code, leaving a blank line between large comment blocks and code.</p>
-
-<code>// break up the string by newlines
-$parts = explode("\n", $str);
-
-// A longer comment that needs to give greater detail on what is
-// occurring and why can use multiple single-line comments. Try to
-// keep the width reasonable, around 70 characters is the easiest to
-// read. Don't hesitate to link to permanent external resources
-// that may provide greater detail:
-//
-// http://example.com/information_about_something/in_particular/
-
-$parts = $this->foo($parts);
-</code>
- </div>
-
-
- <h2><a name="constants"></a>Constants</h2>
- <div class="guidelineDetails">
- <p>Constants follow the same guidelines as do variables, except constants should always be fully uppercase. <em>Always use ExpressionEngine constants when appropriate, i.e. SLASH, LD, RD, PATH_CACHE, etc.</em></p>
-<code><strong>INCORRECT</strong>:
-myConstant // missing underscore separator and not fully uppercase
-N // no single-letter constants
-S_C_VER // not descriptive
-$str = str_replace('{foo}', 'bar', $str); // should use LD and RD constants
-
-<strong>CORRECT</strong>:
-MY_CONSTANT
-NEWLINE
-SUPER_CLASS_VERSION
-$str = str_replace(LD.'foo'.RD, 'bar', $str);
-</code>
- </div>
-
-
- <h2><a name="true_false_and_null"></a>TRUE, FALSE, and NULL</h2>
- <div class="guidelineDetails">
- <p><strong>TRUE</strong>, <strong>FALSE</strong>, and <strong>NULL</strong> keywords should always be fully uppercase.</p>
-<code><strong>INCORRECT</strong>:
-if ($foo == true)
-$bar = false;
-function foo($bar = null)
-
-<strong>CORRECT</strong>:
-if ($foo == TRUE)
-$bar = FALSE;
-function foo($bar = NULL)</code>
- </div>
-
-
-
- <h2><a name="logical_operators"></a>Logical Operators</h2>
- <div class="guidelineDetails">
- <p>Use of <strong>||</strong> is discouraged as its clarity on some output devices is low (looking like the number 11 for instance).
- <strong>&amp;&amp;</strong> is preferred over <strong>AND</strong> but either are acceptable, and a space should always precede and follow <strong>!</strong>.</p>
-<code><strong>INCORRECT</strong>:
-if ($foo || $bar)
-if ($foo AND $bar) // okay but not recommended for common syntax highlighting applications
-if (!$foo)
-if (! is_array($foo))
-
-<strong>CORRECT</strong>:
-if ($foo OR $bar)
-if ($foo && $bar) // recommended
-if ( ! $foo)
-if ( ! is_array($foo))
-</code>
- </div>
-
-
-
- <h2><a name="comparing_return_values_and_typecasting"></a>Comparing Return Values and Typecasting</h2>
- <div class="guidelineDetails">
- <p>Some PHP functions return FALSE on failure, but may also have a valid return value of "" or 0, which would evaluate to FALSE in loose comparisons. Be explicit by comparing the variable type when using these return values in conditionals to ensure the return value is indeed what you expect, and not a value that has an equivalent loose-type evaluation.</p>
- <p>Use the same stringency in returning and checking your own variables. Use <strong>===</strong> and <strong>!==</strong> as necessary.
-
-<code><strong>INCORRECT</strong>:
-// If 'foo' is at the beginning of the string, strpos will return a 0,
-// resulting in this conditional evaluating as TRUE
-if (strpos($str, 'foo') == FALSE)
-
-<strong>CORRECT</strong>:
-if (strpos($str, 'foo') === FALSE)
-</code>
-
-<code><strong>INCORRECT</strong>:
-function build_string($str = "")
-{
- if ($str == "") // uh-oh! What if FALSE or the integer 0 is passed as an argument?
- {
-
- }
-}
-
-<strong>CORRECT</strong>:
-function build_string($str = "")
-{
- if ($str === "")
- {
-
- }
-}</code>
-
- <p>See also information regarding <a href="http://us3.php.net/manual/en/language.types.type-juggling.php#language.types.typecasting">typecasting</a>, which can be quite useful. Typecasting has a slightly different effect which may be desirable. When casting a variable as a string, for instance, NULL and boolean FALSE variables become empty strings, 0 (and other numbers) become strings of digits, and boolean TRUE becomes "1":</p>
-
-<code>$str = (string) $str; // cast $str as a string</code>
-
- </div>
-
-
- <h2><a name="debugging_code"></a>Debugging Code</h2>
- <div class="guidelineDetails">
- <p>No debugging code can be left in place for submitted add-ons unless it is commented out, i.e. no var_dump(), print_r(), die(), and exit() calls that were used while creating the add-on, unless they are commented out.</p>
-
-<code>// print_r($foo);</code>
- </div>
-
-
-
- <h2><a name="whitespace_in_files"></a>Whitespace in Files</h2>
- <div class="guidelineDetails">
- <p>No whitespace can precede the opening PHP tag or follow the closing PHP tag. ExpressionEngine output is buffered, so whitespace in your files can cause output to begin before ExpressionEngine outputs its content, leading to errors and an inability for ExpressionEngine to send proper headers. In the examples below, select the text with your mouse to reveal the incorrect whitespace.</p>
-
- <p><strong>INCORRECT</strong>:</p>
-<code>
-&lt;?php
- // ...there is whitespace and a linebreak above the opening PHP tag
- // as well as whitespace after the closing PHP tag
-?&gt;
-</code>
- <p><strong>CORRECT</strong>:</p>
-<code>&lt;?php
- // this sample has no whitespace before or after the opening and closing PHP tags
-?&gt;</code>
-
- </div>
-
-
- <h2><a name="compatibility"></a>Compatibility</h2>
- <div class="guidelineDetails">
- <p>Unless specifically mentioned in your add-on's documentation, all code must be compatible with PHP version 4.3+. Additionally, do not use PHP functions that require non-default libraries to be installed unless your code contains an alternative method when the function is not available, or you implicitly document that your add-on requires said PHP libraries.</p>
- </div>
-
-
-
- <h2><a name="class_and_file_names_using_common_words"></a>Class and File Names using Common Words</h2>
- <div class="guidelineDetails">
- <p>When your class or filename is a common word, or might quite likely be identically named in another PHP script, provide a unique prefix to help prevent collision. Always realize that your end users may be running other add-ons or third party PHP scripts. Choose a prefix that is unique to your identity as a developer or company.</p>
-
-<code><strong>INCORRECT</strong>:
-class Email pi.email.php
-class Xml ext.xml.php
-class Import mod.import.php
-
-<strong>CORRECT</strong>:
-class Pre_email pi.pre_email.php
-class Pre_xml ext.pre_xml.php
-class Pre_import mod.pre_import.php
-</code>
- </div>
-
-
- <h2><a name="database_table_names"></a>Database Table Names</h2>
- <div class="guidelineDetails">
- <p>Any tables that your add-on might use must use the 'exp_' prefix, followed by a prefix uniquely identifying you as the developer or company, and then a short descriptive table name. You do not need to be concerned about the database prefix being used on the user's installation, as ExpressionEngine's database class will automatically convert 'exp_' to what is actually being used.</p>
-
-<code><strong>INCORRECT</strong>:
-email_addresses // missing both prefixes
-pre_email_addresses // missing exp_ prefix
-exp_email_addresses // missing unique prefix
-
-<strong>CORRECT</strong>:
-exp_pre_email_addresses
-</code>
-
- <p class="important"><strong>NOTE:</strong> Be mindful that MySQL has a limit of 64 characters for table names. This should not be an issue as table names that would exceed this would likely have unreasonable names. For instance, the following table name exceeds this limitation by one character. Silly, no? <strong>exp_pre_email_addresses_of_registered_users_in_seattle_washington</strong>
- </div>
-
-
-
- <h2><a name="one_file_per_class"></a>One File per Class</h2>
- <div class="guidelineDetails">
- <p>Use separate files for each class your add-on uses, unless the classes are <em>closely related</em>. An example of ExpressionEngine files that contains multiple classes is the Database class file, which contains both the DB class and the DB_Cache class, and the Magpie plugin, which contains both the Magpie and Snoopy classes.</p>
- </div>
-
-
-
- <h2><a name="whitespace"></a>Whitespace</h2>
- <div class="guidelineDetails">
- <p>Use tabs for whitespace in your code, not spaces. This may seem like a small thing, but using tabs instead of whitespace allows the developer looking at your code to have indentation at levels that they prefer and customize in whatever application they use. And as a side benefit, it results in (slightly) more compact files, storing one tab character versus, say, four space characters.</p>
- </div>
-
-
-
- <h2><a name="line_breaks"></a>Line Breaks</h2>
- <div class="guidelineDetails">
- <p>Files must be saved with Unix line breaks. This is more of an issue for developers who work in Windows, but in any case ensure that your text editor is setup to save files with Unix line breaks.</p>
- </div>
-
-
-
- <h2><a name="code_indenting"></a>Code Indenting</h2>
- <div class="guidelineDetails">
- <p>Use Allman style indenting. With the exception of Class declarations, braces are always placed on a line by themselves, and indented at the same level as the control statement that "owns" them.</p>
-
-<code><strong>INCORRECT</strong>:
-function foo($bar) {
- // ...
-}
-
-foreach ($arr as $key => $val) {
- // ...
-}
-
-if ($foo == $bar) {
- // ...
-} else {
- // ...
-}
-
-for ($i = 0; $i &lt; 10; $i++)
- {
- for ($j = 0; $j &lt; 10; $j++)
- {
- // ...
- }
- }
-
-<strong>CORRECT</strong>:
-function foo($bar)
-{
- // ...
-}
-
-foreach ($arr as $key => $val)
-{
- // ...
-}
-
-if ($foo == $bar)
-{
- // ...
-}
-else
-{
- // ...
-}
-
-for ($i = 0; $i &lt; 10; $i++)
-{
- for ($j = 0; $j &lt; 10; $j++)
- {
- // ...
- }
-}</code>
- </div>
-
-
- <h2><a name="bracket_spacing"></a>Bracket and Parenthetic Spacing</h2>
- <div class="guidelineDetails">
- <p>In general, parenthesis and brackets should not use any additional spaces. The exception is that a space should always follow PHP control structures that accept arguments with parenthesis (declare, do-while, elseif, for, foreach, if, switch, while), to help distinguish them from functions and increase readability.</p>
-
-<code>INCORRECT:
-$arr[ $foo ] = 'foo';
-
-CORRECT:
-$arr[$foo] = 'foo'; // no spaces around array keys
-
-
-INCORRECT:
-function foo ( $bar )
-{
-
-}
-
-CORRECT:
-function foo($bar) // no spaces around parenthesis in function declarations
-{
-
-}
-
-
-INCORRECT:
-foreach( $query->result() as $row )
-
-CORRECT:
-foreach ($query->result() as $row) // single space following PHP control structures, but not in interior parenthesis
-</code>
- </div>
-
-
-
- <h2><a name="localized_text_in_control_panel"></a>Localized Text in Control Panel</h2>
- <div class="guidelineDetails">
- <p>Any text that is output in the control panel should use language variables in your module's lang file to allow localization.</p>
-
-<code>INCORRECT:
-return "Invalid Selection";
-
-CORRECT:
-return $LANG->line('invalid_selection');</code>
- </div>
-
-
-
- <h2><a name="private_methods_and_variables"></a>Private Methods and Variables</h2>
- <div class="guidelineDetails">
- <p>Methods and variables that are only accessed internally by your class, such as utility and helper functions that your public methods use for code abstraction, should be prefixed with an underscore.</p>
-
-<code>convert_text() // public method
-_convert_text() // private method</code>
- </div>
-
-
-
- <h2><a name="php_errors"></a>PHP Errors</h2>
- <div class="guidelineDetails">
- <p>Code must run error free and not rely on warnings and notices to be hidden to meet this requirement. For instance, never access a variable that you did not set yourself (such as $_POST array keys) without first checking to see that it isset().</p>
-
- <p>Make sure that while developing your add-on, error reporting is enabled for ALL users, and that display_errors is enabled in the PHP environment. You can check this setting with:</p>
-
-<code>if (ini_get('display_errors') == 1)
-{
- exit "Enabled";
-}</code>
-
- <p>On some servers where display_errors is disabled, and you do not have the ability to change this in the php.ini, you can often enable it with:</p>
-
-<code>ini_set('display_errors', 1);</code>
-
- <p class="important"><strong>NOTE:</strong> Setting the <a href="http://us.php.net/manual/en/ref.errorfunc.php#ini.display-errors">display_errors</a> setting with ini_set() at runtime is not identical to having it enabled in the PHP environment. Namely, it will not have any effect if the script has fatal errors</p>
- </div>
-
-
-
- <h2><a name="short_open_tags"></a>Short Open Tags</h2>
- <div class="guidelineDetails">
- <p>Always use full PHP opening tags, in case a server does not have short_open_tag enabled.</p>
-
-<code><strong>INCORRECT</strong>:
-&lt;? echo $foo; ?&gt;
-
-&lt;?=$foo?&gt;
-
-<strong>CORRECT</strong>:
-&lt;?php echo $foo; ?&gt;</code>
- </div>
-
-
-
- <h2><a name="one_statement_per_line"></a>One Statement Per Line</h2>
- <div class="guidelineDetails">
- <p>Never combine statements on one line.</p>
-
-<code><strong>INCORRECT</strong>:
-$foo = 'this'; $bar = 'that'; $bat = str_replace($foo, $bar, $bag);
-
-<strong>CORRECT</strong>:
-$foo = 'this';
-$bar = 'that';
-$bat = str_replace($foo, $bar, $bag);
-</code>
- </div>
-
-
-
- <h2><a name="strings"></a>Strings</h2>
- <div class="guidelineDetails">
- <p>Always use single quoted strings unless you need variables parsed, and in cases where you do need variables parsed, use braces to prevent greedy token parsing. You may also use double-quoted strings if the string contains single quotes, so you do not have to use escape characters.</p>
-
-<code><strong>INCORRECT</strong>:
-"My String" // no variable parsing, so no use for double quotes
-"My string $foo" // needs braces
-'SELECT foo FROM bar WHERE baz = \'bag\'' // ugly
-
-<strong>CORRECT</strong>:
-'My String'
-"My string {$foo}"
-"SELECT foo FROM bar WHERE baz = 'bag'"</code>
- </div>
-
-
-
- <h2><a name="sql_queries"></a>SQL Queries</h2>
- <div class="guidelineDetails">
- <p>MySQL keywords are always capitalized: SELECT, INSERT, UPDATE, WHERE, AS, JOIN, ON, IN, etc.</p>
-
- <p>Break up long queries into multiple lines for legibility, preferably breaking for each clause.</p>
-
-<code><strong>INCORRECT</strong>:
-// keywords are lowercase and query is too long for
-// a single line (... indicates continuation of line)
-$query = $this->db->query("select foo, bar, baz, foofoo, foobar as raboof, foobaz from exp_pre_email_addresses
-...where foo != 'oof' and baz != 'zab' order by foobaz limit 5, 100");
-
-<strong>CORRECT</strong>:
-$query = $this->db->query("SELECT foo, bar, baz, foofoo, foobar AS raboof, foobaz
- FROM exp_pre_email_addresses
- WHERE foo != 'oof'
- AND baz != 'zab'
- ORDER BY foobaz
- LIMIT 5, 100");</code>
- </div>
-
-
-
- <h2><a name="default_function_arguments"></a>Default Function Arguments</h2>
- <div class="guidelineDetails">
- <p>Whenever appropriate, provide function argument defaults, which helps prevent PHP errors with mistaken calls and provides common fallback values which can save a few lines of code. Example:</p>
-
-<code>function foo($bar = '', $baz = FALSE)</code>
- </div>
-
-
-
- <h2><a name="overlapping_tag_parameters"></a>Overlapping Tag Parameters</h2>
- <div class="guidelineDetails">
- <p>Avoid multiple tag parameters that have effect on the same thing. For instance, instead of <strong>include=</strong> and <strong>exclude=</strong>, perhaps allow <strong>include=</strong> to handle the parameter alone, with the addition of "not", e.g. <strong>include="not bar"</strong>. This will prevent problems of parameters overlapping or having to worry about which parameter has priority over another.</p>
- </div>
-
-
-</div>
-
-
-
-</div>
-<!-- END CONTENT -->
-
-
-<div id="footer">
-<p>
-Previous Topic:&nbsp;&nbsp;<a href="security.html">Security</a>
-&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
-<a href="#top">Top of Page</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
-<a href="../index.html">User Guide Home</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
-Next Topic:&nbsp;&nbsp;<a href="../doc_style/index.html">Writing Documentation</a>
-</p>
-<p><a href="http://codeigniter.com">CodeIgniter</a> &nbsp;&middot;&nbsp; Copyright &#169; 2006-2008 &nbsp;&middot;&nbsp; <a href="http://ellislab.com/">Ellislab, Inc.</a></p>
-</div>
-
-</body>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+<title>Style Guide : CodeIgniter User Guide</title>
+
+<style type='text/css' media='all'>@import url('../userguide.css');</style>
+<link rel='stylesheet' type='text/css' media='all' href='../userguide.css' />
+
+<style type="text/css" media="screen">
+ code {
+ white-space: pre;
+ }
+</style>
+
+<script type="text/javascript" src="../nav/nav.js"></script>
+<script type="text/javascript" src="../nav/prototype.lite.js"></script>
+<script type="text/javascript" src="../nav/moo.fx.js"></script>
+<script type="text/javascript" src="../nav/user_guide_menu.js"></script>
+
+<meta http-equiv='expires' content='-1' />
+<meta http-equiv= 'pragma' content='no-cache' />
+<meta name='robots' content='all' />
+<meta name='author' content='ExpressionEngine Dev Team' />
+<meta name='description' content='CodeIgniter User Guide' />
+
+</head>
+<body>
+
+<!-- START NAVIGATION -->
+<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div>
+<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle_darker.jpg" width="154" height="43" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
+<div id="masthead">
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td><h1>CodeIgniter User Guide Version 1.7</h1></td>
+<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
+</tr>
+</table>
+</div>
+<!-- END NAVIGATION -->
+
+
+<!-- START BREADCRUMB -->
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td id="breadcrumb">
+<a href="http://codeigniter.com/">CodeIgniter Home</a> &nbsp;&#8250;&nbsp;
+<a href="../index.html">User Guide Home</a> &nbsp;&#8250;&nbsp;
+Style Guide
+</td>
+<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide&nbsp; <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" />&nbsp;<input type="submit" class="submit" name="sa" value="Go" /></form></td>
+</tr>
+</table>
+<!-- END BREADCRUMB -->
+
+<br clear="all" />
+
+
+<!-- START CONTENT -->
+<div id="content">
+
+
+<h1>General Style and Syntax</h1>
+
+<p>The following page describes the coding rules use adhere to when developing CodeIgniter.</p>
+
+
+<h2>Table of Contents</h2>
+<ul class="minitoc">
+ <li><a href="#php_closing_tag">PHP Closing Tag</a></li>
+ <li><a href="#class_and_method_naming">Class and Method Naming</a></li>
+ <li><a href="#variable_names">Variable Names</a></li>
+ <li><a href="#commenting">Commenting</a></li>
+ <li><a href="#constants">Constants</a></li>
+ <li><a href="#true_false_and_null">TRUE, FALSE, and NULL</a></li>
+ <li><a href="#logical_operators">Logical Operators</a></li>
+ <li><a href="#comparing_return_values_and_typecasting">Comparing Return Values and Typecasting</a></li>
+ <li><a href="#debugging_code">Debugging Code</a></li>
+ <li><a href="#whitespace_in_files">Whitespace in Files</a></li>
+ <li><a href="#compatibility">Compatibility</a></li>
+ <li><a href="#class_and_file_names_using_common_words">Class and File Names using Common Words</a></li>
+ <li><a href="#database_table_names">Database Table Names</a></li>
+ <li><a href="#one_file_per_class">One File per Class</a></li>
+ <li><a href="#whitespace">Whitespace</a></li>
+ <li><a href="#line_breaks">Line Breaks</a></li>
+ <li><a href="#code_indenting">Code Indenting</a></li>
+ <li><a href="#bracket_spacing">Bracket and Parenthetic Spacing</li>
+ <li><a href="#localized_text_in_control_panel">Localized Text in Control Panel</a></li>
+ <li><a href="#private_methods_and_variables">Private Methods and Variables</a></li>
+ <li><a href="#php_errors">PHP Errors</a></li>
+ <li><a href="#short_open_tags">Short Open Tags</a></li>
+ <li><a href="#one_statement_per_line">One Statement Per Line</a></li>
+ <li><a href="#strings">Strings</a></li>
+ <li><a href="#sql_queries">SQL Queries</a></li>
+ <li><a href="#default_function_arguments">Default Function Arguments</a></li>
+ <li><a href="#overlapping_tag_parameters">Overlapping Tag Parameters</a></li>
+</ul>
+
+ <h2><a name="php_closing_tag"></a>PHP Closing Tag</h2>
+ <div class="guidelineDetails">
+ <p>The PHP closing tag on a PHP document <strong>?&gt;</strong> is optional to the PHP parser. However, if used, any whitespace following the closing tag, whether introduced
+ by the developer, user, or an FTP application, can cause unwanted output, PHP errors, or if the latter are suppressed, blank pages. For this reason, all PHP files should
+ <strong>OMIT</strong> the closing PHP tag, and instead use a comment block to mark the end of file and it's location relative to the application root.
+ This allows you to still identify a file as being complete and not truncated.</p>
+<code><strong>INCORRECT</strong>:
+&lt;?php
+
+echo "Here's my code!";
+
+?&gt;
+
+<strong>CORRECT</strong>:
+&lt;?php
+
+echo "Here's my code!";
+
+/* End of file myfile.php */
+/* Location: ./system/modules/mymodule/myfile.php */
+</code>
+ </div>
+
+
+ <h2><a name="class_and_method_naming"></a>Class and Method Naming</h2>
+ <div class="guidelineDetails">
+ <p>Class names should always have their first letter uppercase, and the constructor method should match identically. Multiple words should be separated with an underscore, and not CamelCased. All other class methods should be entirely lowercased and named to clearly indicate their function, preferably including a verb. Try to avoid overly long and verbose names.</p>
+
+ <code><strong>INCORRECT</strong>:
+class superclass
+class SuperClass
+
+<strong>CORRECT</strong>:
+class Super_class</code>
+
+ <p>Notice that the Class and constructor methods are identically named and cased:</p>
+
+ <code>class Super_class {
+
+ function Super_class()
+ {
+
+ }
+}</code>
+
+ <p>Examples of improper and proper method naming:</p>
+
+ <code><strong>INCORRECT</strong>:
+function fileproperties() // not descriptive and needs underscore separator
+function fileProperties() // not descriptive and uses CamelCase
+function getfileproperties() // Better! But still missing underscore separator
+function getFileProperties() // uses CamelCase
+function get_the_file_properties_from_the_file() // wordy
+
+<strong>CORRECT</strong>:
+function get_file_properties() // descriptive, underscore separator, and all lowercase letters</code>
+
+ </div>
+
+
+ <h2><a name="variable_names"></a>Variable Names</h2>
+ <div class="guidelineDetails">
+ <p>The guidelines for variable naming is very similar to that used for class methods. Namely, variables should contain only lowercase letters, use underscore separators, and be reasonably named to indicate their purpose and contents. Very short, non-word variables should only be used as iterators in for() loops.</p>
+<code><strong>INCORRECT</strong>:
+$j = &apos;foo&apos;; // single letter variables should only be used in for() loops
+$Str // contains uppercase letters
+$bufferedText // uses CamelCasing, and could be shortened without losing semantic meaning
+$groupid // multiple words, needs underscore separator
+$name_of_last_city_used // too long
+
+<strong>CORRECT</strong>:
+for ($j = 0; $j &lt; 10; $j++)
+$str
+$buffer
+$group_id
+$last_city
+</code>
+ </div>
+
+
+ <h2><a name="commenting"></a>Commenting</h2>
+ <div class="guidelineDetails">
+ <p>In general, code should be commented prolifically. It not only helps describe the flow and intent of the code for less experienced programmers, but can prove invaluable when returning to your own code months down the line. There is not a required format for comments, but the following are recommended.</p>
+
+ <p><a href="http://manual.phpdoc.org/HTMLSmartyConverter/HandS/phpDocumentor/tutorial_phpDocumentor.howto.pkg.html#basics.docblock">DocBlock</a> style comments preceding class and method declarations so they can be picked up by IDEs:</p>
+
+<code>/**
+ * Super Class
+ *
+ * @package Package Name
+ * @subpackage Subpackage
+ * @category Category
+ * @author Author Name
+ * @link http://example.com
+ */
+class Super_class {</code>
+
+<code>/**
+ * Encodes string for use in XML
+ *
+ * @access public
+ * @param string
+ * @return string
+ */
+function xml_encode($str)</code>
+
+ <p>Use single line comments within code, leaving a blank line between large comment blocks and code.</p>
+
+<code>// break up the string by newlines
+$parts = explode("\n", $str);
+
+// A longer comment that needs to give greater detail on what is
+// occurring and why can use multiple single-line comments. Try to
+// keep the width reasonable, around 70 characters is the easiest to
+// read. Don't hesitate to link to permanent external resources
+// that may provide greater detail:
+//
+// http://example.com/information_about_something/in_particular/
+
+$parts = $this->foo($parts);
+</code>
+ </div>
+
+
+ <h2><a name="constants"></a>Constants</h2>
+ <div class="guidelineDetails">
+ <p>Constants follow the same guidelines as do variables, except constants should always be fully uppercase. <em>Always use ExpressionEngine constants when appropriate, i.e. SLASH, LD, RD, PATH_CACHE, etc.</em></p>
+<code><strong>INCORRECT</strong>:
+myConstant // missing underscore separator and not fully uppercase
+N // no single-letter constants
+S_C_VER // not descriptive
+$str = str_replace('{foo}', 'bar', $str); // should use LD and RD constants
+
+<strong>CORRECT</strong>:
+MY_CONSTANT
+NEWLINE
+SUPER_CLASS_VERSION
+$str = str_replace(LD.'foo'.RD, 'bar', $str);
+</code>
+ </div>
+
+
+ <h2><a name="true_false_and_null"></a>TRUE, FALSE, and NULL</h2>
+ <div class="guidelineDetails">
+ <p><strong>TRUE</strong>, <strong>FALSE</strong>, and <strong>NULL</strong> keywords should always be fully uppercase.</p>
+<code><strong>INCORRECT</strong>:
+if ($foo == true)
+$bar = false;
+function foo($bar = null)
+
+<strong>CORRECT</strong>:
+if ($foo == TRUE)
+$bar = FALSE;
+function foo($bar = NULL)</code>
+ </div>
+
+
+
+ <h2><a name="logical_operators"></a>Logical Operators</h2>
+ <div class="guidelineDetails">
+ <p>Use of <strong>||</strong> is discouraged as its clarity on some output devices is low (looking like the number 11 for instance).
+ <strong>&amp;&amp;</strong> is preferred over <strong>AND</strong> but either are acceptable, and a space should always precede and follow <strong>!</strong>.</p>
+<code><strong>INCORRECT</strong>:
+if ($foo || $bar)
+if ($foo AND $bar) // okay but not recommended for common syntax highlighting applications
+if (!$foo)
+if (! is_array($foo))
+
+<strong>CORRECT</strong>:
+if ($foo OR $bar)
+if ($foo && $bar) // recommended
+if ( ! $foo)
+if ( ! is_array($foo))
+</code>
+ </div>
+
+
+
+ <h2><a name="comparing_return_values_and_typecasting"></a>Comparing Return Values and Typecasting</h2>
+ <div class="guidelineDetails">
+ <p>Some PHP functions return FALSE on failure, but may also have a valid return value of "" or 0, which would evaluate to FALSE in loose comparisons. Be explicit by comparing the variable type when using these return values in conditionals to ensure the return value is indeed what you expect, and not a value that has an equivalent loose-type evaluation.</p>
+ <p>Use the same stringency in returning and checking your own variables. Use <strong>===</strong> and <strong>!==</strong> as necessary.
+
+<code><strong>INCORRECT</strong>:
+// If 'foo' is at the beginning of the string, strpos will return a 0,
+// resulting in this conditional evaluating as TRUE
+if (strpos($str, 'foo') == FALSE)
+
+<strong>CORRECT</strong>:
+if (strpos($str, 'foo') === FALSE)
+</code>
+
+<code><strong>INCORRECT</strong>:
+function build_string($str = "")
+{
+ if ($str == "") // uh-oh! What if FALSE or the integer 0 is passed as an argument?
+ {
+
+ }
+}
+
+<strong>CORRECT</strong>:
+function build_string($str = "")
+{
+ if ($str === "")
+ {
+
+ }
+}</code>
+
+ <p>See also information regarding <a href="http://us3.php.net/manual/en/language.types.type-juggling.php#language.types.typecasting">typecasting</a>, which can be quite useful. Typecasting has a slightly different effect which may be desirable. When casting a variable as a string, for instance, NULL and boolean FALSE variables become empty strings, 0 (and other numbers) become strings of digits, and boolean TRUE becomes "1":</p>
+
+<code>$str = (string) $str; // cast $str as a string</code>
+
+ </div>
+
+
+ <h2><a name="debugging_code"></a>Debugging Code</h2>
+ <div class="guidelineDetails">
+ <p>No debugging code can be left in place for submitted add-ons unless it is commented out, i.e. no var_dump(), print_r(), die(), and exit() calls that were used while creating the add-on, unless they are commented out.</p>
+
+<code>// print_r($foo);</code>
+ </div>
+
+
+
+ <h2><a name="whitespace_in_files"></a>Whitespace in Files</h2>
+ <div class="guidelineDetails">
+ <p>No whitespace can precede the opening PHP tag or follow the closing PHP tag. ExpressionEngine output is buffered, so whitespace in your files can cause output to begin before ExpressionEngine outputs its content, leading to errors and an inability for ExpressionEngine to send proper headers. In the examples below, select the text with your mouse to reveal the incorrect whitespace.</p>
+
+ <p><strong>INCORRECT</strong>:</p>
+<code>
+&lt;?php
+ // ...there is whitespace and a linebreak above the opening PHP tag
+ // as well as whitespace after the closing PHP tag
+?&gt;
+</code>
+ <p><strong>CORRECT</strong>:</p>
+<code>&lt;?php
+ // this sample has no whitespace before or after the opening and closing PHP tags
+?&gt;</code>
+
+ </div>
+
+
+ <h2><a name="compatibility"></a>Compatibility</h2>
+ <div class="guidelineDetails">
+ <p>Unless specifically mentioned in your add-on's documentation, all code must be compatible with PHP version 4.3+. Additionally, do not use PHP functions that require non-default libraries to be installed unless your code contains an alternative method when the function is not available, or you implicitly document that your add-on requires said PHP libraries.</p>
+ </div>
+
+
+
+ <h2><a name="class_and_file_names_using_common_words"></a>Class and File Names using Common Words</h2>
+ <div class="guidelineDetails">
+ <p>When your class or filename is a common word, or might quite likely be identically named in another PHP script, provide a unique prefix to help prevent collision. Always realize that your end users may be running other add-ons or third party PHP scripts. Choose a prefix that is unique to your identity as a developer or company.</p>
+
+<code><strong>INCORRECT</strong>:
+class Email pi.email.php
+class Xml ext.xml.php
+class Import mod.import.php
+
+<strong>CORRECT</strong>:
+class Pre_email pi.pre_email.php
+class Pre_xml ext.pre_xml.php
+class Pre_import mod.pre_import.php
+</code>
+ </div>
+
+
+ <h2><a name="database_table_names"></a>Database Table Names</h2>
+ <div class="guidelineDetails">
+ <p>Any tables that your add-on might use must use the 'exp_' prefix, followed by a prefix uniquely identifying you as the developer or company, and then a short descriptive table name. You do not need to be concerned about the database prefix being used on the user's installation, as ExpressionEngine's database class will automatically convert 'exp_' to what is actually being used.</p>
+
+<code><strong>INCORRECT</strong>:
+email_addresses // missing both prefixes
+pre_email_addresses // missing exp_ prefix
+exp_email_addresses // missing unique prefix
+
+<strong>CORRECT</strong>:
+exp_pre_email_addresses
+</code>
+
+ <p class="important"><strong>NOTE:</strong> Be mindful that MySQL has a limit of 64 characters for table names. This should not be an issue as table names that would exceed this would likely have unreasonable names. For instance, the following table name exceeds this limitation by one character. Silly, no? <strong>exp_pre_email_addresses_of_registered_users_in_seattle_washington</strong>
+ </div>
+
+
+
+ <h2><a name="one_file_per_class"></a>One File per Class</h2>
+ <div class="guidelineDetails">
+ <p>Use separate files for each class your add-on uses, unless the classes are <em>closely related</em>. An example of ExpressionEngine files that contains multiple classes is the Database class file, which contains both the DB class and the DB_Cache class, and the Magpie plugin, which contains both the Magpie and Snoopy classes.</p>
+ </div>
+
+
+
+ <h2><a name="whitespace"></a>Whitespace</h2>
+ <div class="guidelineDetails">
+ <p>Use tabs for whitespace in your code, not spaces. This may seem like a small thing, but using tabs instead of whitespace allows the developer looking at your code to have indentation at levels that they prefer and customize in whatever application they use. And as a side benefit, it results in (slightly) more compact files, storing one tab character versus, say, four space characters.</p>
+ </div>
+
+
+
+ <h2><a name="line_breaks"></a>Line Breaks</h2>
+ <div class="guidelineDetails">
+ <p>Files must be saved with Unix line breaks. This is more of an issue for developers who work in Windows, but in any case ensure that your text editor is setup to save files with Unix line breaks.</p>
+ </div>
+
+
+
+ <h2><a name="code_indenting"></a>Code Indenting</h2>
+ <div class="guidelineDetails">
+ <p>Use Allman style indenting. With the exception of Class declarations, braces are always placed on a line by themselves, and indented at the same level as the control statement that "owns" them.</p>
+
+<code><strong>INCORRECT</strong>:
+function foo($bar) {
+ // ...
+}
+
+foreach ($arr as $key => $val) {
+ // ...
+}
+
+if ($foo == $bar) {
+ // ...
+} else {
+ // ...
+}
+
+for ($i = 0; $i &lt; 10; $i++)
+ {
+ for ($j = 0; $j &lt; 10; $j++)
+ {
+ // ...
+ }
+ }
+
+<strong>CORRECT</strong>:
+function foo($bar)
+{
+ // ...
+}
+
+foreach ($arr as $key => $val)
+{
+ // ...
+}
+
+if ($foo == $bar)
+{
+ // ...
+}
+else
+{
+ // ...
+}
+
+for ($i = 0; $i &lt; 10; $i++)
+{
+ for ($j = 0; $j &lt; 10; $j++)
+ {
+ // ...
+ }
+}</code>
+ </div>
+
+
+ <h2><a name="bracket_spacing"></a>Bracket and Parenthetic Spacing</h2>
+ <div class="guidelineDetails">
+ <p>In general, parenthesis and brackets should not use any additional spaces. The exception is that a space should always follow PHP control structures that accept arguments with parenthesis (declare, do-while, elseif, for, foreach, if, switch, while), to help distinguish them from functions and increase readability.</p>
+
+<code>INCORRECT:
+$arr[ $foo ] = 'foo';
+
+CORRECT:
+$arr[$foo] = 'foo'; // no spaces around array keys
+
+
+INCORRECT:
+function foo ( $bar )
+{
+
+}
+
+CORRECT:
+function foo($bar) // no spaces around parenthesis in function declarations
+{
+
+}
+
+
+INCORRECT:
+foreach( $query->result() as $row )
+
+CORRECT:
+foreach ($query->result() as $row) // single space following PHP control structures, but not in interior parenthesis
+</code>
+ </div>
+
+
+
+ <h2><a name="localized_text_in_control_panel"></a>Localized Text in Control Panel</h2>
+ <div class="guidelineDetails">
+ <p>Any text that is output in the control panel should use language variables in your module's lang file to allow localization.</p>
+
+<code>INCORRECT:
+return "Invalid Selection";
+
+CORRECT:
+return $LANG->line('invalid_selection');</code>
+ </div>
+
+
+
+ <h2><a name="private_methods_and_variables"></a>Private Methods and Variables</h2>
+ <div class="guidelineDetails">
+ <p>Methods and variables that are only accessed internally by your class, such as utility and helper functions that your public methods use for code abstraction, should be prefixed with an underscore.</p>
+
+<code>convert_text() // public method
+_convert_text() // private method</code>
+ </div>
+
+
+
+ <h2><a name="php_errors"></a>PHP Errors</h2>
+ <div class="guidelineDetails">
+ <p>Code must run error free and not rely on warnings and notices to be hidden to meet this requirement. For instance, never access a variable that you did not set yourself (such as $_POST array keys) without first checking to see that it isset().</p>
+
+ <p>Make sure that while developing your add-on, error reporting is enabled for ALL users, and that display_errors is enabled in the PHP environment. You can check this setting with:</p>
+
+<code>if (ini_get('display_errors') == 1)
+{
+ exit "Enabled";
+}</code>
+
+ <p>On some servers where display_errors is disabled, and you do not have the ability to change this in the php.ini, you can often enable it with:</p>
+
+<code>ini_set('display_errors', 1);</code>
+
+ <p class="important"><strong>NOTE:</strong> Setting the <a href="http://us.php.net/manual/en/ref.errorfunc.php#ini.display-errors">display_errors</a> setting with ini_set() at runtime is not identical to having it enabled in the PHP environment. Namely, it will not have any effect if the script has fatal errors</p>
+ </div>
+
+
+
+ <h2><a name="short_open_tags"></a>Short Open Tags</h2>
+ <div class="guidelineDetails">
+ <p>Always use full PHP opening tags, in case a server does not have short_open_tag enabled.</p>
+
+<code><strong>INCORRECT</strong>:
+&lt;? echo $foo; ?&gt;
+
+&lt;?=$foo?&gt;
+
+<strong>CORRECT</strong>:
+&lt;?php echo $foo; ?&gt;</code>
+ </div>
+
+
+
+ <h2><a name="one_statement_per_line"></a>One Statement Per Line</h2>
+ <div class="guidelineDetails">
+ <p>Never combine statements on one line.</p>
+
+<code><strong>INCORRECT</strong>:
+$foo = 'this'; $bar = 'that'; $bat = str_replace($foo, $bar, $bag);
+
+<strong>CORRECT</strong>:
+$foo = 'this';
+$bar = 'that';
+$bat = str_replace($foo, $bar, $bag);
+</code>
+ </div>
+
+
+
+ <h2><a name="strings"></a>Strings</h2>
+ <div class="guidelineDetails">
+ <p>Always use single quoted strings unless you need variables parsed, and in cases where you do need variables parsed, use braces to prevent greedy token parsing. You may also use double-quoted strings if the string contains single quotes, so you do not have to use escape characters.</p>
+
+<code><strong>INCORRECT</strong>:
+"My String" // no variable parsing, so no use for double quotes
+"My string $foo" // needs braces
+'SELECT foo FROM bar WHERE baz = \'bag\'' // ugly
+
+<strong>CORRECT</strong>:
+'My String'
+"My string {$foo}"
+"SELECT foo FROM bar WHERE baz = 'bag'"</code>
+ </div>
+
+
+
+ <h2><a name="sql_queries"></a>SQL Queries</h2>
+ <div class="guidelineDetails">
+ <p>MySQL keywords are always capitalized: SELECT, INSERT, UPDATE, WHERE, AS, JOIN, ON, IN, etc.</p>
+
+ <p>Break up long queries into multiple lines for legibility, preferably breaking for each clause.</p>
+
+<code><strong>INCORRECT</strong>:
+// keywords are lowercase and query is too long for
+// a single line (... indicates continuation of line)
+$query = $this->db->query("select foo, bar, baz, foofoo, foobar as raboof, foobaz from exp_pre_email_addresses
+...where foo != 'oof' and baz != 'zab' order by foobaz limit 5, 100");
+
+<strong>CORRECT</strong>:
+$query = $this->db->query("SELECT foo, bar, baz, foofoo, foobar AS raboof, foobaz
+ FROM exp_pre_email_addresses
+ WHERE foo != 'oof'
+ AND baz != 'zab'
+ ORDER BY foobaz
+ LIMIT 5, 100");</code>
+ </div>
+
+
+
+ <h2><a name="default_function_arguments"></a>Default Function Arguments</h2>
+ <div class="guidelineDetails">
+ <p>Whenever appropriate, provide function argument defaults, which helps prevent PHP errors with mistaken calls and provides common fallback values which can save a few lines of code. Example:</p>
+
+<code>function foo($bar = '', $baz = FALSE)</code>
+ </div>
+
+
+
+ <h2><a name="overlapping_tag_parameters"></a>Overlapping Tag Parameters</h2>
+ <div class="guidelineDetails">
+ <p>Avoid multiple tag parameters that have effect on the same thing. For instance, instead of <strong>include=</strong> and <strong>exclude=</strong>, perhaps allow <strong>include=</strong> to handle the parameter alone, with the addition of "not", e.g. <strong>include="not bar"</strong>. This will prevent problems of parameters overlapping or having to worry about which parameter has priority over another.</p>
+ </div>
+
+
+</div>
+
+
+
+</div>
+<!-- END CONTENT -->
+
+
+<div id="footer">
+<p>
+Previous Topic:&nbsp;&nbsp;<a href="security.html">Security</a>
+&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="#top">Top of Page</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="../index.html">User Guide Home</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+Next Topic:&nbsp;&nbsp;<a href="../doc_style/index.html">Writing Documentation</a>
+</p>
+<p><a href="http://codeigniter.com">CodeIgniter</a> &nbsp;&middot;&nbsp; Copyright &#169; 2006-2008 &nbsp;&middot;&nbsp; <a href="http://ellislab.com/">Ellislab, Inc.</a></p>
+</div>
+
+</body>
</html> \ No newline at end of file
diff --git a/user_guide/helpers/html_helper.html b/user_guide/helpers/html_helper.html
index 3b4ffb132..98b2c2559 100644
--- a/user_guide/helpers/html_helper.html
+++ b/user_guide/helpers/html_helper.html
@@ -1,368 +1,368 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
-<head>
-
-<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
-<title>HTML Helper : CodeIgniter User Guide</title>
-
-<style type='text/css' media='all'>@import url('../userguide.css');</style>
-<link rel='stylesheet' type='text/css' media='all' href='../userguide.css' />
-
-<script type="text/javascript" src="../nav/nav.js"></script>
-<script type="text/javascript" src="../nav/prototype.lite.js"></script>
-<script type="text/javascript" src="../nav/moo.fx.js"></script>
-<script type="text/javascript" src="../nav/user_guide_menu.js"></script>
-
-<meta http-equiv='expires' content='-1' />
-<meta http-equiv= 'pragma' content='no-cache' />
-<meta name='robots' content='all' />
-<meta name='author' content='ExpressionEngine Dev Team' />
-<meta name='description' content='CodeIgniter User Guide' />
-
-</head>
-<body>
-
-<!-- START NAVIGATION -->
-<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div>
-<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle_darker.jpg" width="154" height="43" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
-<div id="masthead">
-<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
-<tr>
-<td><h1>CodeIgniter User Guide Version 1.7</h1></td>
-<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
-</tr>
-</table>
-</div>
-<!-- END NAVIGATION -->
-
-
-<!-- START BREADCRUMB -->
-<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
-<tr>
-<td id="breadcrumb">
-<a href="http://codeigniter.com/">CodeIgniter Home</a> &nbsp;&#8250;&nbsp;
-<a href="../index.html">User Guide Home</a> &nbsp;&#8250;&nbsp;
-HTML Helper
-</td>
-<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide&nbsp; <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" />&nbsp;<input type="submit" class="submit" name="sa" value="Go" /></form></td>
-</tr>
-</table>
-<!-- END BREADCRUMB -->
-
-<br clear="all" />
-
-
-<!-- START CONTENT -->
-<div id="content">
-
-
-<h1>HTML Helper</h1>
-
-<p>The HTML Helper file contains functions that assist in working with HTML.</p>
-
-
-<h2>Loading this Helper</h2>
-
-<p>This helper is loaded using the following code:</p>
-<code>$this->load->helper('html');</code>
-
-<p>The following functions are available:</p>
-
-<h2>br()</h2>
-<p>Generates line break tags (&lt;br />) based on the number you submit. Example:</p>
-<code>echo br(3);</code>
-<p>The above would produce: &lt;br />&lt;br />&lt;br /></p>
-
-<h2>heading()</h2>
-<p>Lets you create HTML &lt;h1> tags. The first parameter will contain the data, the
-second the size of the heading. Example:</p>
-<code>echo heading('Welcome!', 3);</code>
-<p>The above would produce: &lt;h3>Welcome!&lt;/h3></p>
-<h2>img()</h2>
-<p>Lets you create HTML &lt;img /&gt; tags. The first parameter contains the image source. Example:</p>
-<code>echo img('images/picture.jpg');<br />
-// gives &lt;img src=&quot;http://site.com/images/picture.jpg&quot; /&gt;</code>
-<p>There is an optional second parameter that is a TRUE/FALSE value that specifics if the src should have the page specified by $config['index_page'] added to the address it creates. Presumably, this would be if you were using a media controller.</p>
-<p><code>echo img('images/picture.jpg', TRUE);<br />
-// gives &lt;img src=&quot;http://site.com/index.php/images/picture.jpg&quot; /&gt;</code></p>
-<p>Additionally, an associative array can be passed to the img() function for complete control over all attributes and values.</p>
-<p><code> $image_properties = array(<br />
- &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'src' =&gt; 'images/picture.jpg',<br />
- &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'alt' =&gt; 'Me, demonstrating how to eat 4 slices of pizza at one time',<br />
- &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'class' =&gt; 'post_images',<br />
- &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'width' =&gt; '200',<br />
- &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'height' =&gt; '200',<br />
- &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'title' =&gt; 'That was quite a night',<br />
- &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'rel' =&gt; 'lightbox',<br />
- );<br />
- <br />
- img($image_properties);<br />
- // &lt;img src=&quot;http://site.com/index.php/images/picture.jpg&quot; alt=&quot;Me, demonstrating how to eat 4 slices of pizza at one time&quot; class=&quot;post_images&quot; width=&quot;200&quot; height=&quot;200&quot; title=&quot;That was quite a night&quot; rel=&quot;lightbox&quot; /&gt;</code></p>
-<h2>link_tag()</h2>
-<p>Lets you create HTML &lt;link /> tags. This is useful for stylesheet links, as well as other links. The parameters are href, with optional rel, type, title, media and index_page. index_page is a TRUE/FALSE value that specifics if the href should have the page specified by $config['index_page'] added to the address it creates.<code>
-echo link_tag('css/mystyles.css');<br />
-// gives &lt;link href=&quot;http://site.com/css/mystyles.css&quot; rel=&quot;stylesheet&quot; type=&quot;text/css&quot; /&gt;</code></p>
-<p>Further examples:</p>
-
-<code>
- echo link_tag('favicon.ico', 'shortcut icon', 'image/ico');<br />
- // &lt;link href=&quot;http://site.com/favicon.ico&quot; rel=&quot;shortcut icon&quot; type=&quot;image/ico&quot; /&gt;
- <br />
- <br />
- echo link('feed', 'alternate', 'application/rss+xml', 'My RSS Feed');<br />
- // &lt;link href=&quot;http://site.com/feed&quot; rel=&quot;alternate&quot; type=&quot;application/rss+xml&quot; title=&quot;My RSS Feed&quot; /&gt; </code>
-<p>Additionally, an associative array can be passed to the link() function for complete control over all attributes and values.</p>
-<p><code>
- $link = array(<br />
- &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'href' =&gt; 'css/printer.css',<br />
- &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'rel' =&gt; 'stylesheet',<br />
- &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'type' =&gt; 'text/css',<br />
- &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'media' =&gt; 'print'<br />
- );<br />
- <br />
- echo link_tag($link);<br />
- // &lt;link href=&quot;http://site.com/css/printer.css&quot; rel=&quot;stylesheet&quot; type=&quot;text/css&quot; media=&quot;print&quot; /&gt;</code></p>
-
-<h2>nbs()</h2>
-<p>Generates non-breaking spaces (&amp;nbsp;) based on the number you submit. Example:</p>
-<code>echo nbs(3);</code>
-<p>The above would produce: &amp;nbsp;&amp;nbsp;&amp;nbsp;</p>
-
-<h2>ol()&nbsp; and&nbsp; ul()</h2>
-
-<p>Permits you to generate ordered or unordered HTML lists from simple or multi-dimensional arrays. Example:</p>
-
-<code>
-$this->load->helper('html');<br />
-<br />
-$list = array(<br />
-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'red', <br />
-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'blue', <br />
-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'green',<br />
-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'yellow'<br />
-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;);<br />
-<br />
-$attributes = array(<br />
-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'class' => 'boldlist',<br />
-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'id'&nbsp;&nbsp;&nbsp;&nbsp;=> 'mylist'<br />
-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;);<br />
-<br />
-echo ul($list, $attributes);<br />
-</code>
-
-<p>The above code will produce this:</p>
-
-<code>
-&lt;ul&nbsp;class="boldlist"&nbsp;id="mylist"><br />
-&nbsp;&nbsp;&lt;li>red&lt;/li><br />
-&nbsp;&nbsp;&lt;li>blue&lt;/li><br />
-&nbsp;&nbsp;&lt;li>green&lt;/li><br />
-&nbsp;&nbsp;&lt;li>yellow&lt;/li><br />
-&lt;/ul>
-</code>
-
-<p>Here is a more complex example, using a multi-dimensional array:</p>
-
-<code>
-$this->load->helper('html');<br />
-<br />
-$list = array(<br />
-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'colors' => array(<br />
-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'red',<br />
-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'blue',<br />
-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'green'<br />
-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;),<br />
-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'shapes' => array(<br />
-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'round', <br />
-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'square',<br />
-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'circles' => array(<br />
-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'ellipse', <br />
-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'oval', <br />
-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'sphere'<br />
-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;)<br />
-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;),<br />
-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'moods'&nbsp;&nbsp;&nbsp;&nbsp;=> array(<br />
-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'happy', <br />
-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'upset' => array(<br />
-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'defeated' => array(<br />
-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'dejected',<br />
-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'disheartened',<br />
-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'depressed'<br />
-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;),<br />
-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'annoyed',<br />
-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'cross',<br />
-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'angry'<br />
-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;)<br />
-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;)<br />
-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;);<br />
-<br />
-<br />
-echo ul($list);</code>
-
-<p>The above code will produce this:</p>
-
-<code>
-&lt;ul&nbsp;class="boldlist"&nbsp;id="mylist"&gt;<br />
-&nbsp;&nbsp;&lt;li&gt;colors<br />
-&nbsp;&nbsp;&nbsp;&nbsp;&lt;ul&gt;<br />
-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;li&gt;red&lt;/li&gt;<br />
-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;li&gt;blue&lt;/li&gt;<br />
-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;li&gt;green&lt;/li&gt;<br />
-&nbsp;&nbsp;&nbsp;&nbsp;&lt;/ul&gt;<br />
-&nbsp;&nbsp;&lt;/li&gt;<br />
-&nbsp;&nbsp;&lt;li&gt;shapes<br />
-&nbsp;&nbsp;&nbsp;&nbsp;&lt;ul&gt;<br />
-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;li&gt;round&lt;/li&gt;<br />
-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;li&gt;suare&lt;/li&gt;<br />
-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;li&gt;circles<br />
-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;ul&gt;<br />
-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;li&gt;elipse&lt;/li&gt;<br />
-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;li&gt;oval&lt;/li&gt;<br />
-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;li&gt;sphere&lt;/li&gt;<br />
-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;/ul&gt;<br />
-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;/li&gt;<br />
-&nbsp;&nbsp;&nbsp;&nbsp;&lt;/ul&gt;<br />
-&nbsp;&nbsp;&lt;/li&gt;<br />
-&nbsp;&nbsp;&lt;li&gt;moods<br />
-&nbsp;&nbsp;&nbsp;&nbsp;&lt;ul&gt;<br />
-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;li&gt;happy&lt;/li&gt;<br />
-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;li&gt;upset<br />
-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;ul&gt;<br />
-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;li&gt;defeated<br />
-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;ul&gt;<br />
-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;li&gt;dejected&lt;/li&gt;<br />
-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;li&gt;disheartened&lt;/li&gt;<br />
-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;li&gt;depressed&lt;/li&gt;<br />
-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;/ul&gt;<br />
-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;/li&gt;<br />
-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;li&gt;annoyed&lt;/li&gt;<br />
-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;li&gt;cross&lt;/li&gt;<br />
-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;li&gt;angry&lt;/li&gt;<br />
-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;/ul&gt;<br />
-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;/li&gt;<br />
-&nbsp;&nbsp;&nbsp;&nbsp;&lt;/ul&gt;<br />
-&nbsp;&nbsp;&lt;/li&gt;<br />
-&lt;/ul&gt;
-</code>
-
-
-
-<h2>meta()</h2>
-
-<p>Helps you generate meta tags. You can pass strings to the function, or simple arrays, or multidimensional ones. Examples:</p>
-
-<code>
-echo meta('description', 'My Great site');<br />
-// Generates: &lt;meta name="description" content="My Great Site" /><br />
-<br /><br />
-
-echo meta('Content-type', 'text/html; charset=utf-8', 'equiv'); // Note the third parameter. Can be "equiv" or "name"<br />
-// Generates: &lt;meta http-equiv="Content-type" content="text/html; charset=utf-8" /><br />
-
-<br /><br />
-
-echo meta(array('name' => 'robots', 'content' => 'no-cache'));<br />
-// Generates: &lt;meta name="robots" content="no-cache" /><br />
-
-<br /><br />
-
-$meta = array(<br />
-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;array('name' => 'robots', 'content' => 'no-cache'),<br />
-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;array('name' => 'description', 'content' => 'My Great Site'),<br />
-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;array('name' => 'keywords', 'content' => 'love, passion, intrigue, deception'),<br />
-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;array('name' => 'robots', 'content' => 'no-cache'),<br />
-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;array('name' => 'Content-type', 'content' => 'text/html; charset=utf-8', 'type' => 'equiv')<br />
-&nbsp;&nbsp;&nbsp;&nbsp;);<br />
-<br />
-echo meta($meta);
-<br />
-// Generates: <br />
-// &lt;meta name="robots" content="no-cache" /><br />
-// &lt;meta name="description" content="My Great Site" /><br />
-// &lt;meta name="keywords" content="love, passion, intrigue, deception" /><br />
-// &lt;meta name="robots" content="no-cache" /><br />
-// &lt;meta http-equiv="Content-type" content="text/html; charset=utf-8" />
-</code>
-
-
-<h2>doctype()</h2>
-
-<p>Helps you generate document type declarations, or DTD's. XHTML 1.0 Strict is used by default, but many doctypes are available.</p>
-
-<code>
-echo docytype();<br />
-// &lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"&gt;<br />
-<br />
-echo doctype('html4-trans');<br />
-// &lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"&gt;
-</code>
-
-<p>The following is a list of doctype choices. These are configurable, and pulled from <samp>application/config/doctypes.php</samp></p>
-
-<table cellpadding="0" cellspacing="1" border="0" style="width:100%" class="tableborder">
- <tr>
- <th>Doctype</th>
- <th>Option</th>
- <th>Result</th>
- </tr>
- <tr>
- <td class="td">XHTML 1.1</td>
- <td class="td">doctype('xhtml11')</td>
- <td class="td">&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"&gt;</td>
- </tr>
- <tr>
- <td class="td">XHTML 1.0 Strict</td>
- <td class="td">doctype('xhtml1-strict')</td>
- <td class="td">&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"&gt;</td>
- </tr>
- <tr>
- <td class="td">XHTML 1.0 Transitional</td>
- <td class="td">doctype('xhtml1-trans')</td>
- <td class="td">&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;</td>
- </tr>
- <tr>
- <td class="td">XHTML 1.0 Frameset</td>
- <td class="td">doctype('xhtml1-frame')</td>
- <td class="td">&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd"&gt;</td>
- </tr>
- <tr>
- <td class="td">HTML 5</td>
- <td class="td">doctype('html5')</td>
- <td class="td">&lt;!DOCTYPE html&gt;</td>
- </tr>
- <tr>
- <td class="td">HTML 4 Strict</td>
- <td class="td">doctype('html4-strict')</td>
- <td class="td">&lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"&gt;</td>
- </tr>
- <tr>
- <td class="td">HTML 4 Transitional</td>
- <td class="td">doctype('html4-trans')</td>
- <td class="td">&lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"&gt;</td>
- </tr>
- <tr>
- <td class="td">HTML 4 Frameset</td>
- <td class="td">doctype('html4-frame')</td>
- <td class="td">&lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd"&gt;</td>
- </tr>
-</table>
-
-
-
-
-</div>
-<!-- END CONTENT -->
-
-
-<div id="footer">
-<p>
-Previous Topic:&nbsp;&nbsp;<a href="form_helper.html">Form Helper</a>
-&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
-<a href="#top">Top of Page</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
-<a href="../index.html">User Guide Home</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
-Next Topic:&nbsp;&nbsp;<a href="path_helper.html"> Path Helper</a></p>
-<p><a href="http://codeigniter.com">CodeIgniter</a> &nbsp;&middot;&nbsp; Copyright &#169; 2006-2008 &nbsp;&middot;&nbsp; <a href="http://ellislab.com/">Ellislab, Inc.</a></p>
-</div>
-
-</body>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+<title>HTML Helper : CodeIgniter User Guide</title>
+
+<style type='text/css' media='all'>@import url('../userguide.css');</style>
+<link rel='stylesheet' type='text/css' media='all' href='../userguide.css' />
+
+<script type="text/javascript" src="../nav/nav.js"></script>
+<script type="text/javascript" src="../nav/prototype.lite.js"></script>
+<script type="text/javascript" src="../nav/moo.fx.js"></script>
+<script type="text/javascript" src="../nav/user_guide_menu.js"></script>
+
+<meta http-equiv='expires' content='-1' />
+<meta http-equiv= 'pragma' content='no-cache' />
+<meta name='robots' content='all' />
+<meta name='author' content='ExpressionEngine Dev Team' />
+<meta name='description' content='CodeIgniter User Guide' />
+
+</head>
+<body>
+
+<!-- START NAVIGATION -->
+<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div>
+<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle_darker.jpg" width="154" height="43" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
+<div id="masthead">
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td><h1>CodeIgniter User Guide Version 1.7</h1></td>
+<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
+</tr>
+</table>
+</div>
+<!-- END NAVIGATION -->
+
+
+<!-- START BREADCRUMB -->
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td id="breadcrumb">
+<a href="http://codeigniter.com/">CodeIgniter Home</a> &nbsp;&#8250;&nbsp;
+<a href="../index.html">User Guide Home</a> &nbsp;&#8250;&nbsp;
+HTML Helper
+</td>
+<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide&nbsp; <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" />&nbsp;<input type="submit" class="submit" name="sa" value="Go" /></form></td>
+</tr>
+</table>
+<!-- END BREADCRUMB -->
+
+<br clear="all" />
+
+
+<!-- START CONTENT -->
+<div id="content">
+
+
+<h1>HTML Helper</h1>
+
+<p>The HTML Helper file contains functions that assist in working with HTML.</p>
+
+
+<h2>Loading this Helper</h2>
+
+<p>This helper is loaded using the following code:</p>
+<code>$this->load->helper('html');</code>
+
+<p>The following functions are available:</p>
+
+<h2>br()</h2>
+<p>Generates line break tags (&lt;br />) based on the number you submit. Example:</p>
+<code>echo br(3);</code>
+<p>The above would produce: &lt;br />&lt;br />&lt;br /></p>
+
+<h2>heading()</h2>
+<p>Lets you create HTML &lt;h1> tags. The first parameter will contain the data, the
+second the size of the heading. Example:</p>
+<code>echo heading('Welcome!', 3);</code>
+<p>The above would produce: &lt;h3>Welcome!&lt;/h3></p>
+<h2>img()</h2>
+<p>Lets you create HTML &lt;img /&gt; tags. The first parameter contains the image source. Example:</p>
+<code>echo img('images/picture.jpg');<br />
+// gives &lt;img src=&quot;http://site.com/images/picture.jpg&quot; /&gt;</code>
+<p>There is an optional second parameter that is a TRUE/FALSE value that specifics if the src should have the page specified by $config['index_page'] added to the address it creates. Presumably, this would be if you were using a media controller.</p>
+<p><code>echo img('images/picture.jpg', TRUE);<br />
+// gives &lt;img src=&quot;http://site.com/index.php/images/picture.jpg&quot; /&gt;</code></p>
+<p>Additionally, an associative array can be passed to the img() function for complete control over all attributes and values.</p>
+<p><code> $image_properties = array(<br />
+ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'src' =&gt; 'images/picture.jpg',<br />
+ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'alt' =&gt; 'Me, demonstrating how to eat 4 slices of pizza at one time',<br />
+ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'class' =&gt; 'post_images',<br />
+ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'width' =&gt; '200',<br />
+ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'height' =&gt; '200',<br />
+ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'title' =&gt; 'That was quite a night',<br />
+ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'rel' =&gt; 'lightbox',<br />
+ );<br />
+ <br />
+ img($image_properties);<br />
+ // &lt;img src=&quot;http://site.com/index.php/images/picture.jpg&quot; alt=&quot;Me, demonstrating how to eat 4 slices of pizza at one time&quot; class=&quot;post_images&quot; width=&quot;200&quot; height=&quot;200&quot; title=&quot;That was quite a night&quot; rel=&quot;lightbox&quot; /&gt;</code></p>
+<h2>link_tag()</h2>
+<p>Lets you create HTML &lt;link /> tags. This is useful for stylesheet links, as well as other links. The parameters are href, with optional rel, type, title, media and index_page. index_page is a TRUE/FALSE value that specifics if the href should have the page specified by $config['index_page'] added to the address it creates.<code>
+echo link_tag('css/mystyles.css');<br />
+// gives &lt;link href=&quot;http://site.com/css/mystyles.css&quot; rel=&quot;stylesheet&quot; type=&quot;text/css&quot; /&gt;</code></p>
+<p>Further examples:</p>
+
+<code>
+ echo link_tag('favicon.ico', 'shortcut icon', 'image/ico');<br />
+ // &lt;link href=&quot;http://site.com/favicon.ico&quot; rel=&quot;shortcut icon&quot; type=&quot;image/ico&quot; /&gt;
+ <br />
+ <br />
+ echo link('feed', 'alternate', 'application/rss+xml', 'My RSS Feed');<br />
+ // &lt;link href=&quot;http://site.com/feed&quot; rel=&quot;alternate&quot; type=&quot;application/rss+xml&quot; title=&quot;My RSS Feed&quot; /&gt; </code>
+<p>Additionally, an associative array can be passed to the link() function for complete control over all attributes and values.</p>
+<p><code>
+ $link = array(<br />
+ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'href' =&gt; 'css/printer.css',<br />
+ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'rel' =&gt; 'stylesheet',<br />
+ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'type' =&gt; 'text/css',<br />
+ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'media' =&gt; 'print'<br />
+ );<br />
+ <br />
+ echo link_tag($link);<br />
+ // &lt;link href=&quot;http://site.com/css/printer.css&quot; rel=&quot;stylesheet&quot; type=&quot;text/css&quot; media=&quot;print&quot; /&gt;</code></p>
+
+<h2>nbs()</h2>
+<p>Generates non-breaking spaces (&amp;nbsp;) based on the number you submit. Example:</p>
+<code>echo nbs(3);</code>
+<p>The above would produce: &amp;nbsp;&amp;nbsp;&amp;nbsp;</p>
+
+<h2>ol()&nbsp; and&nbsp; ul()</h2>
+
+<p>Permits you to generate ordered or unordered HTML lists from simple or multi-dimensional arrays. Example:</p>
+
+<code>
+$this->load->helper('html');<br />
+<br />
+$list = array(<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'red', <br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'blue', <br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'green',<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'yellow'<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;);<br />
+<br />
+$attributes = array(<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'class' => 'boldlist',<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'id'&nbsp;&nbsp;&nbsp;&nbsp;=> 'mylist'<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;);<br />
+<br />
+echo ul($list, $attributes);<br />
+</code>
+
+<p>The above code will produce this:</p>
+
+<code>
+&lt;ul&nbsp;class="boldlist"&nbsp;id="mylist"><br />
+&nbsp;&nbsp;&lt;li>red&lt;/li><br />
+&nbsp;&nbsp;&lt;li>blue&lt;/li><br />
+&nbsp;&nbsp;&lt;li>green&lt;/li><br />
+&nbsp;&nbsp;&lt;li>yellow&lt;/li><br />
+&lt;/ul>
+</code>
+
+<p>Here is a more complex example, using a multi-dimensional array:</p>
+
+<code>
+$this->load->helper('html');<br />
+<br />
+$list = array(<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'colors' => array(<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'red',<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'blue',<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'green'<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;),<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'shapes' => array(<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'round', <br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'square',<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'circles' => array(<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'ellipse', <br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'oval', <br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'sphere'<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;)<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;),<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'moods'&nbsp;&nbsp;&nbsp;&nbsp;=> array(<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'happy', <br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'upset' => array(<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'defeated' => array(<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'dejected',<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'disheartened',<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'depressed'<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;),<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'annoyed',<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'cross',<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'angry'<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;)<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;)<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;);<br />
+<br />
+<br />
+echo ul($list);</code>
+
+<p>The above code will produce this:</p>
+
+<code>
+&lt;ul&nbsp;class="boldlist"&nbsp;id="mylist"&gt;<br />
+&nbsp;&nbsp;&lt;li&gt;colors<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&lt;ul&gt;<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;li&gt;red&lt;/li&gt;<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;li&gt;blue&lt;/li&gt;<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;li&gt;green&lt;/li&gt;<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&lt;/ul&gt;<br />
+&nbsp;&nbsp;&lt;/li&gt;<br />
+&nbsp;&nbsp;&lt;li&gt;shapes<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&lt;ul&gt;<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;li&gt;round&lt;/li&gt;<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;li&gt;suare&lt;/li&gt;<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;li&gt;circles<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;ul&gt;<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;li&gt;elipse&lt;/li&gt;<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;li&gt;oval&lt;/li&gt;<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;li&gt;sphere&lt;/li&gt;<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;/ul&gt;<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;/li&gt;<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&lt;/ul&gt;<br />
+&nbsp;&nbsp;&lt;/li&gt;<br />
+&nbsp;&nbsp;&lt;li&gt;moods<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&lt;ul&gt;<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;li&gt;happy&lt;/li&gt;<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;li&gt;upset<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;ul&gt;<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;li&gt;defeated<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;ul&gt;<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;li&gt;dejected&lt;/li&gt;<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;li&gt;disheartened&lt;/li&gt;<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;li&gt;depressed&lt;/li&gt;<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;/ul&gt;<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;/li&gt;<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;li&gt;annoyed&lt;/li&gt;<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;li&gt;cross&lt;/li&gt;<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;li&gt;angry&lt;/li&gt;<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;/ul&gt;<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;/li&gt;<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&lt;/ul&gt;<br />
+&nbsp;&nbsp;&lt;/li&gt;<br />
+&lt;/ul&gt;
+</code>
+
+
+
+<h2>meta()</h2>
+
+<p>Helps you generate meta tags. You can pass strings to the function, or simple arrays, or multidimensional ones. Examples:</p>
+
+<code>
+echo meta('description', 'My Great site');<br />
+// Generates: &lt;meta name="description" content="My Great Site" /><br />
+<br /><br />
+
+echo meta('Content-type', 'text/html; charset=utf-8', 'equiv'); // Note the third parameter. Can be "equiv" or "name"<br />
+// Generates: &lt;meta http-equiv="Content-type" content="text/html; charset=utf-8" /><br />
+
+<br /><br />
+
+echo meta(array('name' => 'robots', 'content' => 'no-cache'));<br />
+// Generates: &lt;meta name="robots" content="no-cache" /><br />
+
+<br /><br />
+
+$meta = array(<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;array('name' => 'robots', 'content' => 'no-cache'),<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;array('name' => 'description', 'content' => 'My Great Site'),<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;array('name' => 'keywords', 'content' => 'love, passion, intrigue, deception'),<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;array('name' => 'robots', 'content' => 'no-cache'),<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;array('name' => 'Content-type', 'content' => 'text/html; charset=utf-8', 'type' => 'equiv')<br />
+&nbsp;&nbsp;&nbsp;&nbsp;);<br />
+<br />
+echo meta($meta);
+<br />
+// Generates: <br />
+// &lt;meta name="robots" content="no-cache" /><br />
+// &lt;meta name="description" content="My Great Site" /><br />
+// &lt;meta name="keywords" content="love, passion, intrigue, deception" /><br />
+// &lt;meta name="robots" content="no-cache" /><br />
+// &lt;meta http-equiv="Content-type" content="text/html; charset=utf-8" />
+</code>
+
+
+<h2>doctype()</h2>
+
+<p>Helps you generate document type declarations, or DTD's. XHTML 1.0 Strict is used by default, but many doctypes are available.</p>
+
+<code>
+echo docytype();<br />
+// &lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"&gt;<br />
+<br />
+echo doctype('html4-trans');<br />
+// &lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"&gt;
+</code>
+
+<p>The following is a list of doctype choices. These are configurable, and pulled from <samp>application/config/doctypes.php</samp></p>
+
+<table cellpadding="0" cellspacing="1" border="0" style="width:100%" class="tableborder">
+ <tr>
+ <th>Doctype</th>
+ <th>Option</th>
+ <th>Result</th>
+ </tr>
+ <tr>
+ <td class="td">XHTML 1.1</td>
+ <td class="td">doctype('xhtml11')</td>
+ <td class="td">&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"&gt;</td>
+ </tr>
+ <tr>
+ <td class="td">XHTML 1.0 Strict</td>
+ <td class="td">doctype('xhtml1-strict')</td>
+ <td class="td">&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"&gt;</td>
+ </tr>
+ <tr>
+ <td class="td">XHTML 1.0 Transitional</td>
+ <td class="td">doctype('xhtml1-trans')</td>
+ <td class="td">&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;</td>
+ </tr>
+ <tr>
+ <td class="td">XHTML 1.0 Frameset</td>
+ <td class="td">doctype('xhtml1-frame')</td>
+ <td class="td">&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd"&gt;</td>
+ </tr>
+ <tr>
+ <td class="td">HTML 5</td>
+ <td class="td">doctype('html5')</td>
+ <td class="td">&lt;!DOCTYPE html&gt;</td>
+ </tr>
+ <tr>
+ <td class="td">HTML 4 Strict</td>
+ <td class="td">doctype('html4-strict')</td>
+ <td class="td">&lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"&gt;</td>
+ </tr>
+ <tr>
+ <td class="td">HTML 4 Transitional</td>
+ <td class="td">doctype('html4-trans')</td>
+ <td class="td">&lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"&gt;</td>
+ </tr>
+ <tr>
+ <td class="td">HTML 4 Frameset</td>
+ <td class="td">doctype('html4-frame')</td>
+ <td class="td">&lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd"&gt;</td>
+ </tr>
+</table>
+
+
+
+
+</div>
+<!-- END CONTENT -->
+
+
+<div id="footer">
+<p>
+Previous Topic:&nbsp;&nbsp;<a href="form_helper.html">Form Helper</a>
+&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="#top">Top of Page</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="../index.html">User Guide Home</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+Next Topic:&nbsp;&nbsp;<a href="path_helper.html"> Path Helper</a></p>
+<p><a href="http://codeigniter.com">CodeIgniter</a> &nbsp;&middot;&nbsp; Copyright &#169; 2006-2008 &nbsp;&middot;&nbsp; <a href="http://ellislab.com/">Ellislab, Inc.</a></p>
+</div>
+
+</body>
</html> \ No newline at end of file
diff --git a/user_guide/helpers/language_helper.html b/user_guide/helpers/language_helper.html
index 9c60759dc..cad1ef491 100644
--- a/user_guide/helpers/language_helper.html
+++ b/user_guide/helpers/language_helper.html
@@ -1,98 +1,98 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
-<head>
-
-<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
-<title>Language Helper : CodeIgniter User Guide</title>
-
-<style type='text/css' media='all'>@import url('../userguide.css');</style>
-<link rel='stylesheet' type='text/css' media='all' href='../userguide.css' />
-
-<script type="text/javascript" src="../nav/nav.js"></script>
-<script type="text/javascript" src="../nav/prototype.lite.js"></script>
-<script type="text/javascript" src="../nav/moo.fx.js"></script>
-<script type="text/javascript" src="../nav/user_guide_menu.js"></script>
-
-<meta http-equiv='expires' content='-1' />
-<meta http-equiv= 'pragma' content='no-cache' />
-<meta name='robots' content='all' />
-<meta name='author' content='ExpressionEngine Dev Team' />
-<meta name='description' content='CodeIgniter User Guide' />
-
-</head>
-<body>
-
-<!-- START NAVIGATION -->
-<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div>
-<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle_darker.jpg" width="154" height="43" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
-<div id="masthead">
-<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
-<tr>
-<td><h1>CodeIgniter User Guide Version 1.7</h1></td>
-<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
-</tr>
-</table>
-</div>
-<!-- END NAVIGATION -->
-
-
-<!-- START BREADCRUMB -->
-
-<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
-<tr>
-<td id="breadcrumb">
-<a href="http://codeigniter.com/">CodeIgniter Home</a> &nbsp;&#8250;&nbsp;
-<a href="../index.html">User Guide Home</a> &nbsp;&#8250;&nbsp;
-Language Helper
-</td>
-<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide&nbsp; <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" />&nbsp;<input type="submit" class="submit" name="sa" value="Go" /></form></td>
-</tr>
-</table>
-<!-- END BREADCRUMB -->
-
-<br clear="all" />
-
-
-<!-- START CONTENT -->
-<div id="content">
-
-
-<h1>Language Helper</h1>
-
-<p>The Language Helper file contains functions that assist in working with language files.</p>
-
-
-<h2>Loading this Helper</h2>
-
-<p>This helper is loaded using the following code:</p>
-<code>$this->load->helper('language');</code>
-
-<p>The following functions are available:</p>
-
-<h2>lang('<var>language line</var>', '<var>element id</var>')</h2>
-
-<p>This function returns a line of text from a loaded language file with simplified syntax
- that may be more desirable for view files than calling <kbd>$this-&gt;lang-&gt;line()</kbd>.
- The optional second parameter will also output a form label for you. Example:</p>
-
-<code>echo lang('<samp>language_key</samp>', '<samp>form_item_id</samp>');<br />
-// becomes &lt;label for="form_item_id"&gt;language_key&lt;/label&gt;</code>
-
-
-</div>
-<!-- END CONTENT -->
-
-
-<div id="footer">
-<p>
-Previous Topic:&nbsp;&nbsp;<a href="date_helper.html">Date Helper</a>
-&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
-<a href="#top">Top of Page</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
-<a href="../index.html">User Guide Home</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
-Next Topic:&nbsp;&nbsp;<a href="download_helper.html">Download Helper</a>
-</p>
-<p><a href="http://codeigniter.com">CodeIgniter</a> &nbsp;&middot;&nbsp; Copyright &#169; 2006-2008 &nbsp;&middot;&nbsp; <a href="http://ellislab.com/">Ellislab, Inc.</a></p>
-</div>
-
-</body>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+<title>Language Helper : CodeIgniter User Guide</title>
+
+<style type='text/css' media='all'>@import url('../userguide.css');</style>
+<link rel='stylesheet' type='text/css' media='all' href='../userguide.css' />
+
+<script type="text/javascript" src="../nav/nav.js"></script>
+<script type="text/javascript" src="../nav/prototype.lite.js"></script>
+<script type="text/javascript" src="../nav/moo.fx.js"></script>
+<script type="text/javascript" src="../nav/user_guide_menu.js"></script>
+
+<meta http-equiv='expires' content='-1' />
+<meta http-equiv= 'pragma' content='no-cache' />
+<meta name='robots' content='all' />
+<meta name='author' content='ExpressionEngine Dev Team' />
+<meta name='description' content='CodeIgniter User Guide' />
+
+</head>
+<body>
+
+<!-- START NAVIGATION -->
+<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div>
+<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle_darker.jpg" width="154" height="43" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
+<div id="masthead">
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td><h1>CodeIgniter User Guide Version 1.7</h1></td>
+<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
+</tr>
+</table>
+</div>
+<!-- END NAVIGATION -->
+
+
+<!-- START BREADCRUMB -->
+
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td id="breadcrumb">
+<a href="http://codeigniter.com/">CodeIgniter Home</a> &nbsp;&#8250;&nbsp;
+<a href="../index.html">User Guide Home</a> &nbsp;&#8250;&nbsp;
+Language Helper
+</td>
+<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide&nbsp; <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" />&nbsp;<input type="submit" class="submit" name="sa" value="Go" /></form></td>
+</tr>
+</table>
+<!-- END BREADCRUMB -->
+
+<br clear="all" />
+
+
+<!-- START CONTENT -->
+<div id="content">
+
+
+<h1>Language Helper</h1>
+
+<p>The Language Helper file contains functions that assist in working with language files.</p>
+
+
+<h2>Loading this Helper</h2>
+
+<p>This helper is loaded using the following code:</p>
+<code>$this->load->helper('language');</code>
+
+<p>The following functions are available:</p>
+
+<h2>lang('<var>language line</var>', '<var>element id</var>')</h2>
+
+<p>This function returns a line of text from a loaded language file with simplified syntax
+ that may be more desirable for view files than calling <kbd>$this-&gt;lang-&gt;line()</kbd>.
+ The optional second parameter will also output a form label for you. Example:</p>
+
+<code>echo lang('<samp>language_key</samp>', '<samp>form_item_id</samp>');<br />
+// becomes &lt;label for="form_item_id"&gt;language_key&lt;/label&gt;</code>
+
+
+</div>
+<!-- END CONTENT -->
+
+
+<div id="footer">
+<p>
+Previous Topic:&nbsp;&nbsp;<a href="date_helper.html">Date Helper</a>
+&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="#top">Top of Page</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="../index.html">User Guide Home</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+Next Topic:&nbsp;&nbsp;<a href="download_helper.html">Download Helper</a>
+</p>
+<p><a href="http://codeigniter.com">CodeIgniter</a> &nbsp;&middot;&nbsp; Copyright &#169; 2006-2008 &nbsp;&middot;&nbsp; <a href="http://ellislab.com/">Ellislab, Inc.</a></p>
+</div>
+
+</body>
</html> \ No newline at end of file
diff --git a/user_guide/nav/hacks.txt b/user_guide/nav/hacks.txt
index f29e5a77a..081eecef3 100644
--- a/user_guide/nav/hacks.txt
+++ b/user_guide/nav/hacks.txt
@@ -1,9 +1,9 @@
-I did the following hack in moo.fx.js:
-
-At line 79 in the toggle: function() function, I added:
-
-document.getElementById('nav').style.display = 'block';
-
-
-
+I did the following hack in moo.fx.js:
+
+At line 79 in the toggle: function() function, I added:
+
+document.getElementById('nav').style.display = 'block';
+
+
+
-- Rick Ellis \ No newline at end of file
diff --git a/user_guide/nav/prototype.lite.js b/user_guide/nav/prototype.lite.js
index e6c362279..d294fd7f6 100755
--- a/user_guide/nav/prototype.lite.js
+++ b/user_guide/nav/prototype.lite.js
@@ -1,127 +1,127 @@
-/* Prototype JavaScript framework
- * (c) 2005 Sam Stephenson <sam@conio.net>
- *
- * Prototype is freely distributable under the terms of an MIT-style license.
- *
- * For details, see the Prototype web site: http://prototype.conio.net/
- *
-/*--------------------------------------------------------------------------*/
-
-
-//note: this is a stripped down version of prototype, to be used with moo.fx by mad4milk (http://moofx.mad4milk.net).
-
-var Class = {
- create: function() {
- return function() {
- this.initialize.apply(this, arguments);
- }
- }
-}
-
-Object.extend = function(destination, source) {
- for (property in source) {
- destination[property] = source[property];
- }
- return destination;
-}
-
-Function.prototype.bind = function(object) {
- var __method = this;
- return function() {
- return __method.apply(object, arguments);
- }
-}
-
-function $() {
- var elements = new Array();
-
- for (var i = 0; i < arguments.length; i++) {
- var element = arguments[i];
- if (typeof element == 'string')
- element = document.getElementById(element);
-
- if (arguments.length == 1)
- return element;
-
- elements.push(element);
- }
-
- return elements;
-}
-
-//-------------------------
-
-document.getElementsByClassName = function(className) {
- var children = document.getElementsByTagName('*') || document.all;
- var elements = new Array();
-
- for (var i = 0; i < children.length; i++) {
- var child = children[i];
- var classNames = child.className.split(' ');
- for (var j = 0; j < classNames.length; j++) {
- if (classNames[j] == className) {
- elements.push(child);
- break;
- }
- }
- }
-
- return elements;
-}
-
-//-------------------------
-
-if (!window.Element) {
- var Element = new Object();
-}
-
-Object.extend(Element, {
- remove: function(element) {
- element = $(element);
- element.parentNode.removeChild(element);
- },
-
- hasClassName: function(element, className) {
- element = $(element);
- if (!element)
- return;
- var a = element.className.split(' ');
- for (var i = 0; i < a.length; i++) {
- if (a[i] == className)
- return true;
- }
- return false;
- },
-
- addClassName: function(element, className) {
- element = $(element);
- Element.removeClassName(element, className);
- element.className += ' ' + className;
- },
-
- removeClassName: function(element, className) {
- element = $(element);
- if (!element)
- return;
- var newClassName = '';
- var a = element.className.split(' ');
- for (var i = 0; i < a.length; i++) {
- if (a[i] != className) {
- if (i > 0)
- newClassName += ' ';
- newClassName += a[i];
- }
- }
- element.className = newClassName;
- },
-
- // removes whitespace-only text node children
- cleanWhitespace: function(element) {
- element = $(element);
- for (var i = 0; i < element.childNodes.length; i++) {
- var node = element.childNodes[i];
- if (node.nodeType == 3 && !/\S/.test(node.nodeValue))
- Element.remove(node);
- }
- }
+/* Prototype JavaScript framework
+ * (c) 2005 Sam Stephenson <sam@conio.net>
+ *
+ * Prototype is freely distributable under the terms of an MIT-style license.
+ *
+ * For details, see the Prototype web site: http://prototype.conio.net/
+ *
+/*--------------------------------------------------------------------------*/
+
+
+//note: this is a stripped down version of prototype, to be used with moo.fx by mad4milk (http://moofx.mad4milk.net).
+
+var Class = {
+ create: function() {
+ return function() {
+ this.initialize.apply(this, arguments);
+ }
+ }
+}
+
+Object.extend = function(destination, source) {
+ for (property in source) {
+ destination[property] = source[property];
+ }
+ return destination;
+}
+
+Function.prototype.bind = function(object) {
+ var __method = this;
+ return function() {
+ return __method.apply(object, arguments);
+ }
+}
+
+function $() {
+ var elements = new Array();
+
+ for (var i = 0; i < arguments.length; i++) {
+ var element = arguments[i];
+ if (typeof element == 'string')
+ element = document.getElementById(element);
+
+ if (arguments.length == 1)
+ return element;
+
+ elements.push(element);
+ }
+
+ return elements;
+}
+
+//-------------------------
+
+document.getElementsByClassName = function(className) {
+ var children = document.getElementsByTagName('*') || document.all;
+ var elements = new Array();
+
+ for (var i = 0; i < children.length; i++) {
+ var child = children[i];
+ var classNames = child.className.split(' ');
+ for (var j = 0; j < classNames.length; j++) {
+ if (classNames[j] == className) {
+ elements.push(child);
+ break;
+ }
+ }
+ }
+
+ return elements;
+}
+
+//-------------------------
+
+if (!window.Element) {
+ var Element = new Object();
+}
+
+Object.extend(Element, {
+ remove: function(element) {
+ element = $(element);
+ element.parentNode.removeChild(element);
+ },
+
+ hasClassName: function(element, className) {
+ element = $(element);
+ if (!element)
+ return;
+ var a = element.className.split(' ');
+ for (var i = 0; i < a.length; i++) {
+ if (a[i] == className)
+ return true;
+ }
+ return false;
+ },
+
+ addClassName: function(element, className) {
+ element = $(element);
+ Element.removeClassName(element, className);
+ element.className += ' ' + className;
+ },
+
+ removeClassName: function(element, className) {
+ element = $(element);
+ if (!element)
+ return;
+ var newClassName = '';
+ var a = element.className.split(' ');
+ for (var i = 0; i < a.length; i++) {
+ if (a[i] != className) {
+ if (i > 0)
+ newClassName += ' ';
+ newClassName += a[i];
+ }
+ }
+ element.className = newClassName;
+ },
+
+ // removes whitespace-only text node children
+ cleanWhitespace: function(element) {
+ element = $(element);
+ for (var i = 0; i < element.childNodes.length; i++) {
+ var node = element.childNodes[i];
+ if (node.nodeType == 3 && !/\S/.test(node.nodeValue))
+ Element.remove(node);
+ }
+ }
}); \ No newline at end of file