summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.travis.yml14
-rw-r--r--application/config/autoload.php6
-rw-r--r--application/config/config.php8
-rw-r--r--application/config/constants.php10
-rw-r--r--application/config/database.php6
-rw-r--r--application/config/doctypes.php34
-rw-r--r--application/config/foreign_chars.php6
-rw-r--r--application/config/hooks.php7
-rw-r--r--application/config/migration.php6
-rw-r--r--application/config/mimes.php5
-rw-r--r--application/config/profiler.php7
-rw-r--r--application/config/routes.php7
-rw-r--r--application/config/smileys.php6
-rw-r--r--application/config/user_agents.php4
-rw-r--r--application/controllers/welcome.php10
-rw-r--r--application/errors/error_404.php10
-rw-r--r--application/errors/error_db.php10
-rw-r--r--application/errors/error_general.php10
-rw-r--r--application/errors/error_php.php14
-rw-r--r--application/views/welcome_message.php14
-rw-r--r--license.rst245
-rwxr-xr-xsystem/core/CodeIgniter.php14
-rw-r--r--system/core/Common.php190
-rwxr-xr-xsystem/core/Config.php2
-rwxr-xr-xsystem/core/Exceptions.php6
-rwxr-xr-xsystem/core/Hooks.php32
-rwxr-xr-xsystem/core/Input.php13
-rw-r--r--system/core/Loader.php61
-rwxr-xr-xsystem/core/Output.php20
-rwxr-xr-xsystem/core/Router.php32
-rwxr-xr-xsystem/core/Security.php10
-rwxr-xr-xsystem/core/URI.php18
-rwxr-xr-xsystem/database/DB.php24
-rw-r--r--system/database/DB_active_rec.php65
-rw-r--r--system/database/DB_cache.php2
-rw-r--r--system/database/DB_driver.php302
-rw-r--r--system/database/DB_forge.php4
-rw-r--r--system/database/DB_result.php23
-rw-r--r--system/database/DB_utility.php4
-rw-r--r--system/database/drivers/cubrid/cubrid_driver.php230
-rw-r--r--system/database/drivers/cubrid/cubrid_forge.php37
-rw-r--r--system/database/drivers/cubrid/cubrid_result.php38
-rw-r--r--system/database/drivers/cubrid/cubrid_utility.php24
-rw-r--r--system/database/drivers/interbase/interbase_driver.php191
-rw-r--r--system/database/drivers/interbase/interbase_result.php85
-rw-r--r--system/database/drivers/mssql/mssql_driver.php175
-rw-r--r--system/database/drivers/mssql/mssql_forge.php45
-rw-r--r--system/database/drivers/mssql/mssql_result.php38
-rw-r--r--system/database/drivers/mssql/mssql_utility.php26
-rw-r--r--system/database/drivers/mysql/mysql_driver.php2
-rw-r--r--system/database/drivers/mysql/mysql_forge.php4
-rw-r--r--system/database/drivers/mysql/mysql_result.php2
-rw-r--r--system/database/drivers/mysql/mysql_utility.php2
-rw-r--r--system/database/drivers/mysqli/mysqli_driver.php32
-rw-r--r--system/database/drivers/mysqli/mysqli_forge.php4
-rw-r--r--system/database/drivers/mysqli/mysqli_result.php18
-rw-r--r--system/database/drivers/mysqli/mysqli_utility.php2
-rw-r--r--system/database/drivers/oci8/oci8_driver.php274
-rw-r--r--system/database/drivers/oci8/oci8_forge.php29
-rw-r--r--system/database/drivers/oci8/oci8_result.php36
-rw-r--r--system/database/drivers/oci8/oci8_utility.php25
-rw-r--r--system/database/drivers/odbc/odbc_driver.php165
-rw-r--r--system/database/drivers/odbc/odbc_forge.php36
-rw-r--r--system/database/drivers/odbc/odbc_result.php55
-rw-r--r--system/database/drivers/odbc/odbc_utility.php24
-rw-r--r--system/database/drivers/pdo/pdo_driver.php238
-rw-r--r--system/database/drivers/pdo/pdo_forge.php34
-rw-r--r--system/database/drivers/pdo/pdo_result.php99
-rw-r--r--system/database/drivers/pdo/pdo_utility.php24
-rw-r--r--system/database/drivers/postgre/postgre_driver.php207
-rw-r--r--system/database/drivers/postgre/postgre_forge.php41
-rw-r--r--system/database/drivers/postgre/postgre_result.php58
-rw-r--r--system/database/drivers/postgre/postgre_utility.php4
-rw-r--r--system/database/drivers/sqlite/sqlite_driver.php159
-rw-r--r--system/database/drivers/sqlite/sqlite_forge.php37
-rw-r--r--system/database/drivers/sqlite/sqlite_result.php82
-rw-r--r--system/database/drivers/sqlite/sqlite_utility.php2
-rw-r--r--system/database/drivers/sqlsrv/sqlsrv_driver.php247
-rw-r--r--system/database/drivers/sqlsrv/sqlsrv_forge.php38
-rw-r--r--system/database/drivers/sqlsrv/sqlsrv_result.php56
-rw-r--r--system/database/drivers/sqlsrv/sqlsrv_utility.php30
-rw-r--r--system/helpers/array_helper.php2
-rw-r--r--system/helpers/captcha_helper.php143
-rw-r--r--system/helpers/cookie_helper.php10
-rw-r--r--system/helpers/date_helper.php114
-rw-r--r--system/helpers/directory_helper.php2
-rw-r--r--system/helpers/download_helper.php3
-rw-r--r--system/helpers/email_helper.php10
-rw-r--r--system/helpers/file_helper.php19
-rw-r--r--system/helpers/form_helper.php162
-rw-r--r--system/helpers/html_helper.php66
-rw-r--r--system/helpers/inflector_helper.php22
-rw-r--r--system/helpers/language_helper.php7
-rw-r--r--system/helpers/number_helper.php5
-rw-r--r--system/helpers/path_helper.php21
-rw-r--r--system/helpers/security_helper.php18
-rw-r--r--system/helpers/smiley_helper.php20
-rw-r--r--system/helpers/string_helper.php51
-rw-r--r--system/helpers/text_helper.php37
-rw-r--r--system/helpers/typography_helper.php8
-rw-r--r--system/helpers/url_helper.php59
-rw-r--r--system/helpers/xml_helper.php14
-rw-r--r--system/language/english/upload_lang.php2
-rw-r--r--system/libraries/Cache/Cache.php109
-rw-r--r--system/libraries/Cache/drivers/Cache_apc.php43
-rw-r--r--system/libraries/Cache/drivers/Cache_dummy.php37
-rw-r--r--system/libraries/Cache/drivers/Cache_file.php42
-rw-r--r--system/libraries/Cache/drivers/Cache_memcached.php57
-rw-r--r--system/libraries/Cache/drivers/Cache_wincache.php7
-rw-r--r--system/libraries/Calendar.php61
-rw-r--r--system/libraries/Cart.php48
-rw-r--r--system/libraries/Driver.php52
-rw-r--r--system/libraries/Email.php13
-rw-r--r--system/libraries/Form_validation.php2
-rw-r--r--system/libraries/Ftp.php109
-rw-r--r--system/libraries/Migration.php26
-rw-r--r--system/libraries/Pagination.php44
-rw-r--r--system/libraries/Parser.php47
-rw-r--r--system/libraries/Session.php41
-rw-r--r--system/libraries/Table.php4
-rw-r--r--system/libraries/Typography.php53
-rw-r--r--system/libraries/Upload.php328
-rw-r--r--system/libraries/Xmlrpc.php57
-rw-r--r--system/libraries/Xmlrpcs.php64
-rw-r--r--system/libraries/Zip.php162
-rw-r--r--tests/Bootstrap.php21
-rw-r--r--tests/README.md164
-rw-r--r--tests/codeigniter/Setup_test.php13
-rw-r--r--tests/codeigniter/core/Common_test.php13
-rw-r--r--tests/codeigniter/core/Config_test.php93
-rw-r--r--tests/codeigniter/core/Lang_test.php31
-rw-r--r--tests/codeigniter/core/Loader_test.php235
-rw-r--r--tests/codeigniter/core/URI_test.php313
-rw-r--r--tests/codeigniter/database/.gitkeep0
-rw-r--r--tests/codeigniter/helpers/array_helper_test.php47
-rw-r--r--tests/codeigniter/helpers/date_helper_test.php288
-rw-r--r--tests/codeigniter/helpers/directory_helper_test.php41
-rw-r--r--tests/codeigniter/helpers/email_helper_test.php18
-rw-r--r--tests/codeigniter/helpers/file_helper_test.php156
-rw-r--r--tests/codeigniter/helpers/html_helper_test.php80
-rw-r--r--tests/codeigniter/helpers/inflector_helper_test.php95
-rw-r--r--tests/codeigniter/helpers/number_helper_test.php77
-rw-r--r--tests/codeigniter/helpers/path_helper_test.php32
-rw-r--r--tests/codeigniter/helpers/string_helper_test.php147
-rw-r--r--tests/codeigniter/helpers/text_helper_test.php159
-rw-r--r--tests/codeigniter/helpers/url_helper_test.php75
-rw-r--r--tests/codeigniter/helpers/xml_helper_test.php15
-rw-r--r--tests/codeigniter/libraries/Parser_test.php110
-rw-r--r--tests/codeigniter/libraries/Table_test.php296
-rw-r--r--tests/codeigniter/libraries/Typography_test.php188
-rw-r--r--tests/codeigniter/libraries/Useragent_test.php87
-rw-r--r--tests/mocks/autoloader.php79
-rw-r--r--tests/mocks/ci_testcase.php196
-rw-r--r--tests/mocks/core/common.php132
-rw-r--r--tests/mocks/core/loader.php30
-rw-r--r--tests/mocks/core/uri.php25
-rw-r--r--tests/mocks/database/.gitkeep0
-rw-r--r--tests/mocks/libraries/parser.php3
-rw-r--r--tests/mocks/libraries/table.php15
-rw-r--r--tests/mocks/libraries/typography.php3
-rw-r--r--tests/mocks/libraries/useragent.php3
-rw-r--r--tests/phpunit.xml37
-rw-r--r--user_guide_src/source/changelog.rst28
-rw-r--r--user_guide_src/source/database/active_record.rst10
-rw-r--r--user_guide_src/source/database/utilities.rst2
-rw-r--r--user_guide_src/source/general/styleguide.rst3
-rw-r--r--user_guide_src/source/general/views.rst22
-rw-r--r--user_guide_src/source/helpers/date_helper.rst13
-rw-r--r--user_guide_src/source/helpers/form_helper.rst4
-rw-r--r--user_guide_src/source/helpers/html_helper.rst62
-rw-r--r--user_guide_src/source/helpers/path_helper.rst20
-rw-r--r--user_guide_src/source/helpers/security_helper.rst7
-rw-r--r--user_guide_src/source/helpers/string_helper.rst30
-rw-r--r--user_guide_src/source/libraries/email.rst1
-rw-r--r--user_guide_src/source/libraries/file_uploading.rst16
-rw-r--r--user_guide_src/source/libraries/form_validation.rst4
-rw-r--r--user_guide_src/source/libraries/sessions.rst4
-rw-r--r--user_guide_src/source/libraries/xmlrpc.rst28
178 files changed, 6048 insertions, 3940 deletions
diff --git a/.travis.yml b/.travis.yml
index 7f290e6be..29111bcf5 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,11 +1,17 @@
language: php
-phps:
- - 5.2
+php:
- 5.3
- 5.4
+before_script:
+ - pyrus channel-discover pear.php-tools.net
+ - pyrus install http://pear.php-tools.net/get/vfsStream-0.11.2.tgz
+ - phpenv rehash
+
+script: phpunit --configuration tests/phpunit.xml
+
branches:
- except:
+ only:
- develop
- - master
+ - master \ No newline at end of file
diff --git a/application/config/autoload.php b/application/config/autoload.php
index e8c999334..b3e63cbf6 100644
--- a/application/config/autoload.php
+++ b/application/config/autoload.php
@@ -1,13 +1,13 @@
-<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
* An open source application development framework for PHP 5.2.4 or newer
*
* NOTICE OF LICENSE
- *
+ *
* Licensed under the Academic Free License version 3.0
- *
+ *
* This source file is subject to the Academic Free License (AFL 3.0) that is
* bundled with this package in the files license_afl.txt / license_afl.rst.
* It is also available through the world wide web at this URL:
diff --git a/application/config/config.php b/application/config/config.php
index 4ad9d1d6a..2628885f0 100644
--- a/application/config/config.php
+++ b/application/config/config.php
@@ -1,13 +1,13 @@
-<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
* An open source application development framework for PHP 5.2.4 or newer
*
* NOTICE OF LICENSE
- *
+ *
* Licensed under the Academic Free License version 3.0
- *
+ *
* This source file is subject to the Academic Free License (AFL 3.0) that is
* bundled with this package in the files license_afl.txt / license_afl.rst.
* It is also available through the world wide web at this URL:
@@ -297,12 +297,14 @@ $config['sess_time_to_update'] = 300;
| 'cookie_domain' = Set to .your-domain.com for site-wide cookies
| 'cookie_path' = Typically will be a forward slash
| 'cookie_secure' = Cookies will only be set if a secure HTTPS connection exists.
+| 'cookie_httponly' = Cookie will only be accessible via HTTP(S) (no javascript)
|
*/
$config['cookie_prefix'] = "";
$config['cookie_domain'] = "";
$config['cookie_path'] = "/";
$config['cookie_secure'] = FALSE;
+$config['cookie_httponly'] = FALSE;
/*
|--------------------------------------------------------------------------
diff --git a/application/config/constants.php b/application/config/constants.php
index fce101320..d22d2963e 100644
--- a/application/config/constants.php
+++ b/application/config/constants.php
@@ -1,13 +1,13 @@
-<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
* An open source application development framework for PHP 5.2.4 or newer
*
* NOTICE OF LICENSE
- *
+ *
* Licensed under the Academic Free License version 3.0
- *
+ *
* This source file is subject to the Academic Free License (AFL 3.0) that is
* bundled with this package in the files license_afl.txt / license_afl.rst.
* It is also available through the world wide web at this URL:
@@ -66,8 +66,8 @@ define('FOPEN_READ_WRITE_CREATE_STRICT', 'x+b');
| Display Debug backtrace
|--------------------------------------------------------------------------
|
-| If set to TRUE, a backtrace will be displayed along with php errors. If
-| error_reporting is disabled, the backtrace will not display, regardless
+| If set to TRUE, a backtrace will be displayed along with php errors. If
+| error_reporting is disabled, the backtrace will not display, regardless
| of this setting
|
*/
diff --git a/application/config/database.php b/application/config/database.php
index 154638d1f..744de0392 100644
--- a/application/config/database.php
+++ b/application/config/database.php
@@ -1,13 +1,13 @@
-<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
* An open source application development framework for PHP 5.2.4 or newer
*
* NOTICE OF LICENSE
- *
+ *
* Licensed under the Academic Free License version 3.0
- *
+ *
* This source file is subject to the Academic Free License (AFL 3.0) that is
* bundled with this package in the files license_afl.txt / license_afl.rst.
* It is also available through the world wide web at this URL:
diff --git a/application/config/doctypes.php b/application/config/doctypes.php
index e5e70daf6..c7f5b55c2 100644
--- a/application/config/doctypes.php
+++ b/application/config/doctypes.php
@@ -1,13 +1,13 @@
-<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
* An open source application development framework for PHP 5.2.4 or newer
*
* NOTICE OF LICENSE
- *
+ *
* Licensed under the Academic Free License version 3.0
- *
+ *
* This source file is subject to the Academic Free License (AFL 3.0) that is
* bundled with this package in the files license_afl.txt / license_afl.rst.
* It is also available through the world wide web at this URL:
@@ -26,15 +26,25 @@
*/
$_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">',
- 'xhtml-basic11' => '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML Basic 1.1//EN" "http://www.w3.org/TR/xhtml-basic/xhtml-basic11.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">'
+ '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">',
+ 'xhtml-basic11' => '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML Basic 1.1//EN" "http://www.w3.org/TR/xhtml-basic/xhtml-basic11.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">',
+ 'mathml1' => '<!DOCTYPE math SYSTEM "http://www.w3.org/Math/DTD/mathml1/mathml.dtd">',
+ 'mathml2' => '<!DOCTYPE math PUBLIC "-//W3C//DTD MathML 2.0//EN" "http://www.w3.org/Math/DTD/mathml2/mathml2.dtd">',
+ 'svg10' => '<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.0//EN" "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">',
+ 'svg11' => '<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">',
+ 'svg11-basic' => '<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1 Basic//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11-basic.dtd">',
+ 'svg11-tiny' => '<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1 Tiny//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11-tiny.dtd">',
+ 'xhtml-math-svg-xh' => '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1 plus MathML 2.0 plus SVG 1.1//EN" "http://www.w3.org/2002/04/xhtml-math-svg/xhtml-math-svg.dtd">',
+ 'xhtml-math-svg-sh' => '<!DOCTYPE svg:svg PUBLIC "-//W3C//DTD XHTML 1.1 plus MathML 2.0 plus SVG 1.1//EN" "http://www.w3.org/2002/04/xhtml-math-svg/xhtml-math-svg.dtd">',
+ 'xhtml-rdfa-1' => '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML+RDFa 1.0//EN" "http://www.w3.org/MarkUp/DTD/xhtml-rdfa-1.dtd">',
+ 'xhtml-rdfa-2' => '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML+RDFa 1.1//EN" "http://www.w3.org/MarkUp/DTD/xhtml-rdfa-2.dtd">'
);
/* End of file doctypes.php */
diff --git a/application/config/foreign_chars.php b/application/config/foreign_chars.php
index d3713fe98..e2d3f236e 100644
--- a/application/config/foreign_chars.php
+++ b/application/config/foreign_chars.php
@@ -1,13 +1,13 @@
-<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
* An open source application development framework for PHP 5.2.4 or newer
*
* NOTICE OF LICENSE
- *
+ *
* Licensed under the Academic Free License version 3.0
- *
+ *
* This source file is subject to the Academic Free License (AFL 3.0) that is
* bundled with this package in the files license_afl.txt / license_afl.rst.
* It is also available through the world wide web at this URL:
diff --git a/application/config/hooks.php b/application/config/hooks.php
index 1b10fc27d..350050370 100644
--- a/application/config/hooks.php
+++ b/application/config/hooks.php
@@ -1,13 +1,13 @@
-<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
* An open source application development framework for PHP 5.2.4 or newer
*
* NOTICE OF LICENSE
- *
+ *
* Licensed under the Academic Free License version 3.0
- *
+ *
* This source file is subject to the Academic Free License (AFL 3.0) that is
* bundled with this package in the files license_afl.txt / license_afl.rst.
* It is also available through the world wide web at this URL:
@@ -37,6 +37,5 @@
*/
-
/* End of file hooks.php */
/* Location: ./application/config/hooks.php */ \ No newline at end of file
diff --git a/application/config/migration.php b/application/config/migration.php
index e1ce1ae6f..88e398243 100644
--- a/application/config/migration.php
+++ b/application/config/migration.php
@@ -1,4 +1,4 @@
-<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
@@ -89,5 +89,5 @@ $config['migration_version'] = 0;
*/
$config['migration_path'] = APPPATH . 'migrations/';
-
-/* End of file migration.php */ \ No newline at end of file
+/* End of file migration.php */
+/* Location: ./application/config/migration.php */ \ No newline at end of file
diff --git a/application/config/mimes.php b/application/config/mimes.php
index 7ec782b60..02e12c011 100644
--- a/application/config/mimes.php
+++ b/application/config/mimes.php
@@ -34,7 +34,8 @@
|
*/
-$mimes = array('hqx' => array('application/mac-binhex40', 'application/mac-binhex', 'application/x-binhex40', 'application/x-mac-binhex40'),
+$mimes = array(
+ 'hqx' => array('application/mac-binhex40', 'application/mac-binhex', 'application/x-binhex40', 'application/x-mac-binhex40'),
'cpt' => 'application/mac-compactpro',
'csv' => array('text/x-comma-separated-values', 'text/comma-separated-values', 'application/octet-stream', 'application/vnd.ms-excel', 'application/x-csv', 'text/x-csv', 'text/csv', 'application/csv', 'application/excel', 'application/vnd.msexcel'),
'bin' => array('application/macbinary', 'application/mac-binary', 'application/octet-stream', 'application/x-binary', 'application/x-macbinary'),
@@ -165,4 +166,4 @@ $mimes = array('hqx' => array('application/mac-binhex40', 'application/mac-binhe
);
/* End of file mimes.php */
-/* Location: ./application/config/mimes.php */
+/* Location: ./application/config/mimes.php */ \ No newline at end of file
diff --git a/application/config/profiler.php b/application/config/profiler.php
index 53391892d..c161a4d59 100644
--- a/application/config/profiler.php
+++ b/application/config/profiler.php
@@ -1,13 +1,13 @@
-<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
* An open source application development framework for PHP 5.2.4 or newer
*
* NOTICE OF LICENSE
- *
+ *
* Licensed under the Academic Free License version 3.0
- *
+ *
* This source file is subject to the Academic Free License (AFL 3.0) that is
* bundled with this package in the files license_afl.txt / license_afl.rst.
* It is also available through the world wide web at this URL:
@@ -38,6 +38,5 @@
*/
-
/* End of file profiler.php */
/* Location: ./application/config/profiler.php */ \ No newline at end of file
diff --git a/application/config/routes.php b/application/config/routes.php
index 686573deb..474bda969 100644
--- a/application/config/routes.php
+++ b/application/config/routes.php
@@ -1,13 +1,13 @@
-<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
* An open source application development framework for PHP 5.2.4 or newer
*
* NOTICE OF LICENSE
- *
+ *
* Licensed under the Academic Free License version 3.0
- *
+ *
* This source file is subject to the Academic Free License (AFL 3.0) that is
* bundled with this package in the files license_afl.txt / license_afl.rst.
* It is also available through the world wide web at this URL:
@@ -67,6 +67,5 @@
$route['default_controller'] = "welcome";
$route['404_override'] = '';
-
/* End of file routes.php */
/* Location: ./application/config/routes.php */ \ No newline at end of file
diff --git a/application/config/smileys.php b/application/config/smileys.php
index 8e3844a89..baefe5380 100644
--- a/application/config/smileys.php
+++ b/application/config/smileys.php
@@ -1,13 +1,13 @@
-<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
* An open source application development framework for PHP 5.2.4 or newer
*
* NOTICE OF LICENSE
- *
+ *
* Licensed under the Academic Free License version 3.0
- *
+ *
* This source file is subject to the Academic Free License (AFL 3.0) that is
* bundled with this package in the files license_afl.txt / license_afl.rst.
* It is also available through the world wide web at this URL:
diff --git a/application/config/user_agents.php b/application/config/user_agents.php
index 0baa25220..60f256e01 100644
--- a/application/config/user_agents.php
+++ b/application/config/user_agents.php
@@ -1,4 +1,4 @@
-<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
@@ -211,4 +211,4 @@ $robots = array(
);
/* End of file user_agents.php */
-/* Location: ./application/config/user_agents.php */
+/* Location: ./application/config/user_agents.php */ \ No newline at end of file
diff --git a/application/controllers/welcome.php b/application/controllers/welcome.php
index 2451d9776..1ed82d2a7 100644
--- a/application/controllers/welcome.php
+++ b/application/controllers/welcome.php
@@ -1,13 +1,13 @@
-<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
* An open source application development framework for PHP 5.2.4 or newer
*
* NOTICE OF LICENSE
- *
+ *
* Licensed under the Academic Free License version 3.0
- *
+ *
* This source file is subject to the Academic Free License (AFL 3.0) that is
* bundled with this package in the files license_afl.txt / license_afl.rst.
* It is also available through the world wide web at this URL:
@@ -32,10 +32,10 @@ class Welcome extends CI_Controller {
*
* Maps to the following URL
* http://example.com/index.php/welcome
- * - or -
+ * - or -
* http://example.com/index.php/welcome/index
* - or -
- * Since this controller is set as the default controller in
+ * Since this controller is set as the default controller in
* config/routes.php, it's displayed at http://example.com/
*
* So any other public methods not prefixed with an underscore will
diff --git a/application/errors/error_404.php b/application/errors/error_404.php
index 9af9e39de..746032956 100644
--- a/application/errors/error_404.php
+++ b/application/errors/error_404.php
@@ -1,13 +1,13 @@
-<?php
+<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
* An open source application development framework for PHP 5.2.4 or newer
*
* NOTICE OF LICENSE
- *
+ *
* Licensed under the Academic Free License version 3.0
- *
+ *
* This source file is subject to the Academic Free License (AFL 3.0) that is
* bundled with this package in the files license_afl.txt / license_afl.rst.
* It is also available through the world wide web at this URL:
@@ -24,9 +24,7 @@
* @since Version 1.0
* @filesource
*/
-?>
-
-<!DOCTYPE html>
+?><!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
diff --git a/application/errors/error_db.php b/application/errors/error_db.php
index 81ff02adb..eb3a75260 100644
--- a/application/errors/error_db.php
+++ b/application/errors/error_db.php
@@ -1,13 +1,13 @@
-<?php
+<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
* An open source application development framework for PHP 5.2.4 or newer
*
* NOTICE OF LICENSE
- *
+ *
* Licensed under the Academic Free License version 3.0
- *
+ *
* This source file is subject to the Academic Free License (AFL 3.0) that is
* bundled with this package in the files license_afl.txt / license_afl.rst.
* It is also available through the world wide web at this URL:
@@ -24,9 +24,7 @@
* @since Version 1.0
* @filesource
*/
-?>
-
-<!DOCTYPE html>
+?><!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
diff --git a/application/errors/error_general.php b/application/errors/error_general.php
index 8efcfd991..59896e1ea 100644
--- a/application/errors/error_general.php
+++ b/application/errors/error_general.php
@@ -1,13 +1,13 @@
-<?php
+<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
* An open source application development framework for PHP 5.2.4 or newer
*
* NOTICE OF LICENSE
- *
+ *
* Licensed under the Academic Free License version 3.0
- *
+ *
* This source file is subject to the Academic Free License (AFL 3.0) that is
* bundled with this package in the files license_afl.txt / license_afl.rst.
* It is also available through the world wide web at this URL:
@@ -24,9 +24,7 @@
* @since Version 1.0
* @filesource
*/
-?>
-
-<!DOCTYPE html>
+?><!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
diff --git a/application/errors/error_php.php b/application/errors/error_php.php
index 42e5f5a28..3855720de 100644
--- a/application/errors/error_php.php
+++ b/application/errors/error_php.php
@@ -1,13 +1,13 @@
-<?php
+<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
* An open source application development framework for PHP 5.2.4 or newer
*
* NOTICE OF LICENSE
- *
+ *
* Licensed under the Academic Free License version 3.0
- *
+ *
* This source file is subject to the Academic Free License (AFL 3.0) that is
* bundled with this package in the files license_afl.txt / license_afl.rst.
* It is also available through the world wide web at this URL:
@@ -35,11 +35,11 @@
<p>Filename: <?php echo $filepath; ?></p>
<p>Line Number: <?php echo $line; ?></p>
-<?php if(defined('SHOW_DEBUG_BACKTRACE') && SHOW_DEBUG_BACKTRACE === TRUE): ?>
-
+<?php if (defined('SHOW_DEBUG_BACKTRACE') && SHOW_DEBUG_BACKTRACE === TRUE): ?>
+
<p>Backtrace: </p>
<?php foreach(debug_backtrace() as $error): ?>
-
+
<?php if(isset($error['file']) && ! stristr($error['file'], SYSDIR)): ?>
<p style="margin-left:10px">
File: <?php echo $error['file'] ?><br />
@@ -47,7 +47,7 @@
Function: <?php echo $error['function'] ?>
</p>
<?php endif ?>
-
+
<?php endforeach ?></p>
<?php endif ?>
diff --git a/application/views/welcome_message.php b/application/views/welcome_message.php
index 0dd892441..45360da60 100644
--- a/application/views/welcome_message.php
+++ b/application/views/welcome_message.php
@@ -1,13 +1,13 @@
-<?php
+<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
* An open source application development framework for PHP 5.2.4 or newer
*
* NOTICE OF LICENSE
- *
+ *
* Licensed under the Academic Free License version 3.0
- *
+ *
* This source file is subject to the Academic Free License (AFL 3.0) that is
* bundled with this package in the files license_afl.txt / license_afl.rst.
* It is also available through the world wide web at this URL:
@@ -24,9 +24,7 @@
* @since Version 1.0
* @filesource
*/
-?>
-
-<!DOCTYPE html>
+?><!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
@@ -75,7 +73,7 @@
#body{
margin: 0 15px 0 15px;
}
-
+
p.footer{
text-align: right;
font-size: 11px;
@@ -84,7 +82,7 @@
padding: 0 10px 0 10px;
margin: 20px 0 0 0;
}
-
+
#container{
margin: 10px;
border: 1px solid #D0D0D0;
diff --git a/license.rst b/license.rst
deleted file mode 100644
index 17179a95c..000000000
--- a/license.rst
+++ /dev/null
@@ -1,245 +0,0 @@
-###################################
-Open Software License ("OSL") v 3.0
-###################################
-
-This Open Software License (the "License") applies to any original work of
-authorship (the "Original Work") whose owner (the "Licensor") has placed the
-following licensing notice adjacent to the copyright notice for the Original
-Work:
-
-*Licensed under the Open Software License version 3.0*
-
-
-*****************************
-1) Grant of Copyright License
-*****************************
-
-Licensor grants You a worldwide, royalty-free, non-exclusive, sublicensable
-license, for the duration of the copyright, to do the following:
-
- *a)* to reproduce the Original Work in copies, either alone or as part of
- a collective work;
-
- *b)* to translate, adapt, alter, transform, modify, or arrange the
- Original Work, thereby creating derivative works ("Derivative Works")
- based upon the Original Work;
-
- *c)* to distribute or communicate copies of the Original Work and
- Derivative Works to the public, *with the proviso that copies of Original
- Work or Derivative Works that You distribute or communicate shall be
- licensed under this Open Software License*;
-
- *d)* to perform the Original Work publicly; and
-
- *e)* to display the Original Work publicly.
-
-
-**************************
-2) Grant of Patent License
-**************************
-
-Licensor grants You a worldwide, royalty-free, non-exclusive, sublicensable
-license, under patent claims owned or controlled by the Licensor that are
-embodied in the Original Work as furnished by the Licensor, for the duration
-of the patents, to make, use, sell, offer for sale, have made, and import the
-Original Work and Derivative Works.
-
-
-*******************************
-3) Grant of Source Code License
-*******************************
-
-The term "Source Code" means the preferred form of the Original Work for
-making modifications to it and all available documentation describing how to
-modify the Original Work. Licensor agrees to provide a machine-readable copy
-of the Source Code of the Original Work along with each copy of the Original
-Work that Licensor distributes. Licensor reserves the right to satisfy this
-obligation by placing a machine-readable copy of the Source Code in an
-information repository reasonably calculated to permit inexpensive and
-convenient access by You for as long as Licensor continues to distribute the
-Original Work.
-
-
-********************************
-4) Exclusions From License Grant
-********************************
-
-Neither the names of Licensor, nor the names of any contributors to the
-Original Work, nor any of their trademarks or service marks, may be used to
-endorse or promote products derived from this Original Work without express
-prior permission of the Licensor. Except as expressly stated herein, nothing
-in this License grants any license to Licensor's trademarks, copyrights,
-patents, trade secrets or any other intellectual property. No patent license
-is granted to make, use, sell, offer for sale, have made, or import
-embodiments of any patent claims other than the licensed claims defined in
-Section 2) No license is granted to the trademarks of Licensor even if such
-marks are included in the Original Work. Nothing in this License shall be
-interpreted to prohibit Licensor from licensing under terms different from
-this License any Original Work that Licensor otherwise would have a right to
-license.
-
-
-**********************
-5) External Deployment
-**********************
-
-The term "External Deployment" means the use, distribution, or communication
-of the Original Work or Derivative Works in any way such that the Original
-Work or Derivative Works may be used by anyone other than You, whether those
-works are distributed or communicated to those persons or made available as an
-application intended for use over a network. As an express condition for the
-grants of license hereunder, You must treat any External Deployment by You of
-the Original Work or a Derivative Work as a distribution under section 1(c).
-
-
-*********************
-6) Attribution Rights
-*********************
-
-You must retain, in the Source Code of any Derivative Works that You create,
-all copyright, patent, or trademark notices from the Source Code of the
-Original Work, as well as any notices of licensing and any descriptive text
-identified therein as an "Attribution Notice." You must cause the Source Code
-for any Derivative Works that You create to carry a prominent Attribution
-Notice reasonably calculated to inform recipients that You have modified the
-Original Work.
-
-
-****************************************************
-7) Warranty of Provenance and Disclaimer of Warranty
-****************************************************
-
-Licensor warrants that the copyright in and to the Original Work and the
-patent rights granted herein by Licensor are owned by the Licensor or are
-sublicensed to You under the terms of this License with the permission of the
-contributor(s) of those copyrights and patent rights. Except as expressly
-stated in the immediately preceding sentence, the Original Work is provided
-under this License on an "AS IS" BASIS and WITHOUT WARRANTY, either express or
-implied, including, without limitation, the warranties of non-infringement,
-merchantability or fitness for a particular purpose. THE ENTIRE RISK AS TO THE
-QUALITY OF THE ORIGINAL WORK IS WITH YOU. This DISCLAIMER OF WARRANTY
-constitutes an essential part of this License. No license to the Original Work
-is granted by this License except under this disclaimer.
-
-
-**************************
-8) Limitation of Liability
-**************************
-
-Under no circumstances and under no legal theory, whether in tort (including
-negligence), contract, or otherwise, shall the Licensor be liable to anyone
-for any indirect, special, incidental, or consequential damages of any
-character arising as a result of this License or the use of the Original Work
-including, without limitation, damages for loss of goodwill, work stoppage,
-computer failure or malfunction, or any and all other commercial damages or
-losses. This limitation of liability shall not apply to the extent applicable
-law prohibits such limitation.
-
-
-*****************************
-9) Acceptance and Termination
-*****************************
-
-If, at any time, You expressly assented to this License, that assent indicates
-your clear and irrevocable acceptance of this License and all of its terms and
-conditions. If You distribute or communicate copies of the Original Work or a
-Derivative Work, You must make a reasonable effort under the circumstances to
-obtain the express assent of recipients to the terms of this License. This
-License conditions your rights to undertake the activities listed in Section
-1, including your right to create Derivative Works based upon the Original
-Work, and doing so without honoring these terms and conditions is prohibited
-by copyright law and international treaty. Nothing in this License is intended
-to affect copyright exceptions and limitations (including "fair use" or "fair
-dealing"). This License shall terminate immediately and You may no longer
-exercise any of the rights granted to You by this License upon your failure to
-honor the conditions in Section 1(c).
-
-
-*********************************
-10) Termination for Patent Action
-*********************************
-
-This License shall terminate automatically and You may no longer exercise any
-of the rights granted to You by this License as of the date You commence an
-action, including a cross-claim or counterclaim, against Licensor or any
-licensee alleging that the Original Work infringes a patent. This termination
-provision shall not apply for an action alleging patent infringement by
-combinations of the Original Work with other software or hardware.
-
-
-*****************************************
-11) Jurisdiction, Venue and Governing Law
-*****************************************
-
-Any action or suit relating to this License may be brought only in the courts
-of a jurisdiction wherein the Licensor resides or in which Licensor conducts
-its primary business, and under the laws of that jurisdiction excluding its
-conflict-of-law provisions. The application of the United Nations Convention
-on Contracts for the International Sale of Goods is expressly excluded. Any
-use of the Original Work outside the scope of this License or after its
-termination shall be subject to the requirements and penalties of copyright or
-patent law in the appropriate jurisdiction. This section shall survive the
-termination of this License.
-
-
-*******************
-12) Attorneys' Fees
-*******************
-
-In any action to enforce the terms of this License or seeking damages relating
-thereto, the prevailing party shall be entitled to recover its costs and
-expenses, including, without limitation, reasonable attorneys' fees and costs
-incurred in connection with such action, including any appeal of such action.
-This section shall survive the termination of this License.
-
-
-*****************
-13) Miscellaneous
-*****************
-
-If any provision of this License is held to be unenforceable, such provision
-shall be reformed only to the extent necessary to make it enforceable.
-
-
-***************************************
-14) Definition of "You" in This License
-***************************************
-
-"You" throughout this License, whether in upper or lower case, means an
-individual or a legal entity exercising rights under, and complying with all
-of the terms of, this License. For legal entities, "You" includes any entity
-that controls, is controlled by, or is under common control with you. For
-purposes of this definition, "control" means (i) the power, direct or
-indirect, to cause the direction or management of such entity, whether by
-contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the
-outstanding shares, or (iii) beneficial ownership of such entity.
-
-
-****************
-15) Right to Use
-****************
-
-You may use the Original Work in all ways not otherwise restricted or
-conditioned by this License or by law, and Licensor promises not to interfere
-with or be responsible for such uses by You.
-
-
-********************************
-16) Modification of This License
-********************************
-
-This License is Copyright © 2005 Lawrence Rosen. Permission is granted to
-copy, distribute, or communicate this License without modification. Nothing in
-this License permits You to modify this License as applied to the Original
-Work or to Derivative Works. However, You may modify the text of this License
-and copy, distribute or communicate your modified version (the "Modified
-License") and apply it to other original works of authorship subject to the
-following conditions: (i) You may not indicate in any way that your Modified
-License is the "Open Software License" or "OSL" and you may not use those
-names in the name of your Modified License; (ii) You must replace the notice
-specified in the first paragraph above with the notice "Licensed under <insert
-your license name here>" or with a notice of your own that is not confusingly
-similar to the notice in this License; and (iii) You may not claim that your
-original works are open source software unless your Modified License has been
-approved by Open Source Initiative (OSI) and You comply with its license
-review and certification process. \ No newline at end of file
diff --git a/system/core/CodeIgniter.php b/system/core/CodeIgniter.php
index a79a69590..4885f310c 100755
--- a/system/core/CodeIgniter.php
+++ b/system/core/CodeIgniter.php
@@ -133,7 +133,7 @@
* Is there a "pre_system" hook?
* ------------------------------------------------------
*/
- $EXT->_call_hook('pre_system');
+ $EXT->call_hook('pre_system');
/*
* ------------------------------------------------------
@@ -194,7 +194,7 @@
* Is there a valid cache file? If so, we're done...
* ------------------------------------------------------
*/
- if ($EXT->_call_hook('cache_override') === FALSE
+ if ($EXT->call_hook('cache_override') === FALSE
&& $OUT->_display_cache($CFG, $URI) == TRUE)
{
exit;
@@ -297,7 +297,7 @@
* Is there a "pre_controller" hook?
* ------------------------------------------------------
*/
- $EXT->_call_hook('pre_controller');
+ $EXT->call_hook('pre_controller');
/*
* ------------------------------------------------------
@@ -314,7 +314,7 @@
* Is there a "post_controller_constructor" hook?
* ------------------------------------------------------
*/
- $EXT->_call_hook('post_controller_constructor');
+ $EXT->call_hook('post_controller_constructor');
/*
* ------------------------------------------------------
@@ -369,14 +369,14 @@
* Is there a "post_controller" hook?
* ------------------------------------------------------
*/
- $EXT->_call_hook('post_controller');
+ $EXT->call_hook('post_controller');
/*
* ------------------------------------------------------
* Send the final rendered output to the browser
* ------------------------------------------------------
*/
- if ($EXT->_call_hook('display_override') === FALSE)
+ if ($EXT->call_hook('display_override') === FALSE)
{
$OUT->_display();
}
@@ -386,7 +386,7 @@
* Is there a "post_system" hook?
* ------------------------------------------------------
*/
- $EXT->_call_hook('post_system');
+ $EXT->call_hook('post_system');
/*
* ------------------------------------------------------
diff --git a/system/core/Common.php b/system/core/Common.php
index f20acafd4..aeb784bbe 100644
--- a/system/core/Common.php
+++ b/system/core/Common.php
@@ -25,8 +25,6 @@
* @filesource
*/
-// ------------------------------------------------------------------------
-
/**
* Common Functions
*
@@ -42,15 +40,14 @@
// ------------------------------------------------------------------------
/**
-* Determines if the current version of PHP is greater then the supplied value
-*
-* Since there are a few places where we conditionally test for PHP > 5
-* we'll set a static variable.
-*
-* @access public
-* @param string
-* @return bool TRUE if the current version is $version or higher
-*/
+ * Determines if the current version of PHP is greater then the supplied value
+ *
+ * Since there are a few places where we conditionally test for PHP > 5
+ * we'll set a static variable.
+ *
+ * @param string
+ * @return bool TRUE if the current version is $version or higher
+ */
if ( ! function_exists('is_php'))
{
function is_php($version = '5.0.0')
@@ -76,7 +73,7 @@ if ( ! function_exists('is_php'))
* the file, based on the read-only attribute. is_writable() is also unreliable
* on Unix servers if safe_mode is on.
*
- * @access public
+ * @param string
* @return void
*/
if ( ! function_exists('is_really_writable'))
@@ -118,18 +115,17 @@ if ( ! function_exists('is_really_writable'))
// ------------------------------------------------------------------------
/**
-* Class registry
-*
-* This function acts as a singleton. If the requested class does not
-* exist it is instantiated and set to a static variable. If it has
-* previously been instantiated the variable is returned.
-*
-* @access public
-* @param string the class name being requested
-* @param string the directory where the class should be found
-* @param string the class name prefix
-* @return object
-*/
+ * Class registry
+ *
+ * This function acts as a singleton. If the requested class does not
+ * exist it is instantiated and set to a static variable. If it has
+ * previously been instantiated the variable is returned.
+ *
+ * @param string the class name being requested
+ * @param string the directory where the class should be found
+ * @param string the class name prefix
+ * @return object
+ */
if ( ! function_exists('load_class'))
{
function &load_class($class, $directory = 'libraries', $prefix = 'CI_')
@@ -192,12 +188,12 @@ if ( ! function_exists('load_class'))
// --------------------------------------------------------------------
/**
-* Keeps track of which libraries have been loaded. This function is
-* called by the load_class() function above
-*
-* @access public
-* @return array
-*/
+ * Keeps track of which libraries have been loaded. This function is
+ * called by the load_class() function above
+ *
+ * @param string
+ * @return array
+ */
if ( ! function_exists('is_loaded'))
{
function &is_loaded($class = '')
@@ -216,14 +212,14 @@ if ( ! function_exists('is_loaded'))
// ------------------------------------------------------------------------
/**
-* Loads the main config.php file
-*
-* This function lets us grab the config file even if the Config class
-* hasn't been instantiated yet
-*
-* @access private
-* @return array
-*/
+ * Loads the main config.php file
+ *
+ * This function lets us grab the config file even if the Config class
+ * hasn't been instantiated yet
+ *
+ * @param array
+ * @return array
+ */
if ( ! function_exists('get_config'))
{
function &get_config($replace = array())
@@ -276,11 +272,11 @@ if ( ! function_exists('get_config'))
// ------------------------------------------------------------------------
/**
-* Returns the specified config item
-*
-* @access public
-* @return mixed
-*/
+ * Returns the specified config item
+ *
+ * @param string
+ * @return mixed
+ */
if ( ! function_exists('config_item'))
{
function config_item($item)
@@ -305,17 +301,19 @@ if ( ! function_exists('config_item'))
// ------------------------------------------------------------------------
/**
-* Error Handler
-*
-* This function lets us invoke the exception class and
-* display errors using the standard error template located
-* in application/errors/errors.php
-* This function will send the error page directly to the
-* browser and exit.
-*
-* @access public
-* @return void
-*/
+ * Error Handler
+ *
+ * This function lets us invoke the exception class and
+ * display errors using the standard error template located
+ * in application/errors/errors.php
+ * This function will send the error page directly to the
+ * browser and exit.
+ *
+ * @param string
+ * @param int
+ * @param string
+ * @return void
+ */
if ( ! function_exists('show_error'))
{
function show_error($message, $status_code = 500, $heading = 'An Error Was Encountered')
@@ -329,15 +327,16 @@ if ( ! function_exists('show_error'))
// ------------------------------------------------------------------------
/**
-* 404 Page Handler
-*
-* This function is similar to the show_error() function above
-* However, instead of the standard error template it displays
-* 404 errors.
-*
-* @access public
-* @return void
-*/
+ * 404 Page Handler
+ *
+ * This function is similar to the show_error() function above
+ * However, instead of the standard error template it displays
+ * 404 errors.
+ *
+ * @param string
+ * @param bool
+ * @return void
+ */
if ( ! function_exists('show_404'))
{
function show_404($page = '', $log_error = TRUE)
@@ -351,14 +350,16 @@ if ( ! function_exists('show_404'))
// ------------------------------------------------------------------------
/**
-* Error Logging Interface
-*
-* We use this as a simple mechanism to access the logging
-* class and send messages to be logged.
-*
-* @access public
-* @return void
-*/
+ * Error Logging Interface
+ *
+ * We use this as a simple mechanism to access the logging
+ * class and send messages to be logged.
+ *
+ * @param string
+ * @param string
+ * @param bool
+ * @return void
+ */
if ( ! function_exists('log_message'))
{
function log_message($level = 'error', $message, $php_error = FALSE)
@@ -380,8 +381,7 @@ if ( ! function_exists('log_message'))
/**
* Set HTTP Status Header
*
- * @access public
- * @param int the status code
+ * @param int the status code
* @param string
* @return void
*/
@@ -467,19 +467,22 @@ if ( ! function_exists('set_status_header'))
// --------------------------------------------------------------------
/**
-* Exception Handler
-*
-* This is the custom exception handler that is declaired at the top
-* of Codeigniter.php. The main reason we use this is to permit
-* PHP errors to be logged in our own log files since the user may
-* not have access to server logs. Since this function
-* effectively intercepts PHP errors, however, we also need
-* to display errors based on the current error_reporting level.
-* We do that with the use of a PHP error template.
-*
-* @access private
-* @return void
-*/
+ * Exception Handler
+ *
+ * This is the custom exception handler that is declaired at the top
+ * of Codeigniter.php. The main reason we use this is to permit
+ * PHP errors to be logged in our own log files since the user may
+ * not have access to server logs. Since this function
+ * effectively intercepts PHP errors, however, we also need
+ * to display errors based on the current error_reporting level.
+ * We do that with the use of a PHP error template.
+ *
+ * @param int
+ * @param string
+ * @param string
+ * @param int
+ * @return void
+ */
if ( ! function_exists('_exception_handler'))
{
function _exception_handler($severity, $message, $filepath, $line)
@@ -521,8 +524,8 @@ if ( ! function_exists('_exception_handler'))
* This prevents sandwiching null characters
* between ascii characters, like Java\0script.
*
- * @access public
* @param string
+ * @param bool
* @return string
*/
if ( ! function_exists('remove_invisible_characters'))
@@ -554,12 +557,11 @@ if ( ! function_exists('remove_invisible_characters'))
// ------------------------------------------------------------------------
/**
-* Returns HTML escaped variable
-*
-* @access public
-* @param mixed
-* @return mixed
-*/
+ * Returns HTML escaped variable
+ *
+ * @param mixed
+ * @return mixed
+ */
if ( ! function_exists('html_escape'))
{
function html_escape($var)
@@ -571,4 +573,4 @@ if ( ! function_exists('html_escape'))
}
/* End of file Common.php */
-/* Location: ./system/core/Common.php */
+/* Location: ./system/core/Common.php */ \ No newline at end of file
diff --git a/system/core/Config.php b/system/core/Config.php
index 1e149d005..91826bd41 100755
--- a/system/core/Config.php
+++ b/system/core/Config.php
@@ -76,7 +76,7 @@ class CI_Config {
log_message('debug', 'Config Class Initialized');
// Set the base_url automatically if none was provided
- if ($this->config['base_url'] == '')
+ if (empty($this->config['base_url']))
{
if (isset($_SERVER['HTTP_HOST']))
{
diff --git a/system/core/Exceptions.php b/system/core/Exceptions.php
index d7282b1f3..f36b31598 100755
--- a/system/core/Exceptions.php
+++ b/system/core/Exceptions.php
@@ -25,8 +25,6 @@
* @filesource
*/
-// ------------------------------------------------------------------------
-
/**
* Exceptions Class
*
@@ -163,7 +161,7 @@ class CI_Exceptions {
* @param string the error line number
* @return string
*/
- function show_php_error($severity, $message, $filepath, $line)
+ public function show_php_error($severity, $message, $filepath, $line)
{
$severity = ( ! isset($this->levels[$severity])) ? $severity : $this->levels[$severity];
$filepath = str_replace('\\', '/', $filepath);
@@ -189,4 +187,4 @@ class CI_Exceptions {
}
/* End of file Exceptions.php */
-/* Location: ./system/core/Exceptions.php */
+/* Location: ./system/core/Exceptions.php */ \ No newline at end of file
diff --git a/system/core/Hooks.php b/system/core/Hooks.php
index 493822f36..68e30ef0f 100755
--- a/system/core/Hooks.php
+++ b/system/core/Hooks.php
@@ -25,8 +25,6 @@
* @filesource
*/
-// ------------------------------------------------------------------------
-
/**
* CodeIgniter Hooks Class
*
@@ -51,7 +49,7 @@ class CI_Hooks {
*
* @var array
*/
- public $hooks = array();
+ public $hooks = array();
/**
* Determines wether hook is in progress, used to prevent infinte loops
*
@@ -59,23 +57,17 @@ class CI_Hooks {
*/
public $in_progress = FALSE;
- public function __construct()
- {
- $this->_initialize();
- log_message('debug', 'Hooks Class Initialized');
- }
-
- // --------------------------------------------------------------------
-
/**
* Initialize the Hooks Preferences
*
* @return void
*/
- private function _initialize()
+ public function __construct()
{
$CFG =& load_class('Config', 'core');
+ log_message('debug', 'Hooks Class Initialized');
+
// If hooks are not enabled in the config file
// there is nothing else to do
if ($CFG->item('enable_hooks') == FALSE)
@@ -84,7 +76,7 @@ class CI_Hooks {
}
// Grab the "hooks" definition file.
- if (defined('ENVIRONMENT') AND is_file(APPPATH.'config/'.ENVIRONMENT.'/hooks.php'))
+ if (defined('ENVIRONMENT') && is_file(APPPATH.'config/'.ENVIRONMENT.'/hooks.php'))
{
include(APPPATH.'config/'.ENVIRONMENT.'/hooks.php');
}
@@ -113,14 +105,14 @@ class CI_Hooks {
* @param string the hook name
* @return mixed
*/
- public function _call_hook($which = '')
+ public 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]))
+ if (isset($this->hooks[$which][0]) && is_array($this->hooks[$which][0]))
{
foreach ($this->hooks[$which] as $val)
{
@@ -167,7 +159,7 @@ class CI_Hooks {
// Set file path
// -----------------------------------
- if ( ! isset($data['filepath']) OR ! isset($data['filename']))
+ if ( ! isset($data['filepath'], $data['filename']))
{
return FALSE;
}
@@ -187,12 +179,12 @@ class CI_Hooks {
$function = FALSE;
$params = '';
- if (isset($data['class']) AND $data['class'] != '')
+ if ( ! empty($data['class']))
{
$class = $data['class'];
}
- if (isset($data['function']))
+ if ( ! empty($data['function']))
{
$function = $data['function'];
}
@@ -202,7 +194,7 @@ class CI_Hooks {
$params = $data['params'];
}
- if ($class === FALSE AND $function === FALSE)
+ if ($class === FALSE && $function === FALSE)
{
return FALSE;
}
@@ -244,4 +236,4 @@ class CI_Hooks {
}
/* End of file Hooks.php */
-/* Location: ./system/core/Hooks.php */
+/* Location: ./system/core/Hooks.php */ \ No newline at end of file
diff --git a/system/core/Input.php b/system/core/Input.php
index 901b4147e..6e6885992 100755
--- a/system/core/Input.php
+++ b/system/core/Input.php
@@ -228,7 +228,7 @@ class CI_Input {
/**
* Set cookie
*
- * Accepts six parameter, or you can submit an associative
+ * Accepts seven parameters, or you can submit an associative
* array in the first parameter containing all the values.
*
* @param mixed
@@ -238,14 +238,15 @@ class CI_Input {
* @param string the cookie path
* @param string the cookie prefix
* @param bool true makes the cookie secure
+ * @param bool true makes the cookie accessible via http(s) only (no javascript)
* @return void
*/
- public function set_cookie($name = '', $value = '', $expire = '', $domain = '', $path = '/', $prefix = '', $secure = FALSE)
+ public function set_cookie($name = '', $value = '', $expire = '', $domain = '', $path = '/', $prefix = '', $secure = FALSE, $httponly = FALSE)
{
if (is_array($name))
{
// always leave 'name' in last place, as the loop will break otherwise, due to $$item
- foreach (array('value', 'expire', 'domain', 'path', 'prefix', 'secure', 'name') as $item)
+ foreach (array('value', 'expire', 'domain', 'path', 'prefix', 'secure', 'httponly', 'name') as $item)
{
if (isset($name[$item]))
{
@@ -270,6 +271,10 @@ class CI_Input {
{
$secure = config_item('cookie_secure');
}
+ if ($httponly == FALSE && config_item('cookie_httponly') != FALSE)
+ {
+ $httponly = config_item('cookie_httponly');
+ }
if ( ! is_numeric($expire))
{
@@ -280,7 +285,7 @@ class CI_Input {
$expire = ($expire > 0) ? time() + $expire : 0;
}
- setcookie($prefix.$name, $value, $expire, $path, $domain, $secure);
+ setcookie($prefix.$name, $value, $expire, $path, $domain, $secure, $httponly);
}
// --------------------------------------------------------------------
diff --git a/system/core/Loader.php b/system/core/Loader.php
index 9b9cc2fef..027ed20e5 100644
--- a/system/core/Loader.php
+++ b/system/core/Loader.php
@@ -25,8 +25,6 @@
* @filesource
*/
-// ------------------------------------------------------------------------
-
/**
* Loader Class
*
@@ -281,7 +279,7 @@ class CI_Loader {
continue;
}
- if ($db_conn !== FALSE AND ! class_exists('CI_DB'))
+ if ($db_conn !== FALSE && ! class_exists('CI_DB'))
{
if ($db_conn === TRUE)
{
@@ -324,7 +322,7 @@ class CI_Loader {
$CI =& get_instance();
// Do we even need to load the database class?
- if (class_exists('CI_DB') AND $return == FALSE AND $active_record == NULL AND isset($CI->db) AND is_object($CI->db))
+ if (class_exists('CI_DB') && $return == FALSE && $active_record == NULL && isset($CI->db) && is_object($CI->db))
{
return FALSE;
}
@@ -399,13 +397,13 @@ class CI_Loader {
/**
* Load View
*
- * This function is used to load a "view" file. It has three parameters:
+ * This function is used to load a "view" file. It has three parameters:
*
* 1. The name of the "view" file to be included.
* 2. An associative array of data to be extracted for use in the view.
- * 3. TRUE/FALSE - whether to return the data or load it. In
- * some cases it's advantageous to be able to return data so that
- * a developer can process it in some way.
+ * 3. TRUE/FALSE - whether to return the data or load it. In
+ * some cases it's advantageous to be able to return data so that
+ * a developer can process it in some way.
*
* @param string
* @param array
@@ -447,14 +445,14 @@ class CI_Loader {
*/
public function vars($vars = array(), $val = '')
{
- if ($val != '' AND is_string($vars))
+ if ($val != '' && is_string($vars))
{
$vars = array($vars => $val);
}
$vars = $this->_ci_object_to_array($vars);
- if (is_array($vars) AND count($vars) > 0)
+ if (is_array($vars) && count($vars) > 0)
{
foreach ($vars as $key => $val)
{
@@ -660,7 +658,7 @@ class CI_Loader {
* Prepends a parent path to the library, model, helper, and config path arrays
*
* @param string
- * @param boolean
+ * @param bool
* @return void
*/
public function add_package_path($path, $view_cascade=TRUE)
@@ -701,9 +699,9 @@ class CI_Loader {
* Remove a path from the library, model, and helper path arrays if it exists
* If no path is provided, the most recently added path is removed.
*
- * @param type
+ * @param string
* @param bool
- * @return type
+ * @return void
*/
public function remove_package_path($path = '', $remove_config_path = TRUE)
{
@@ -764,7 +762,7 @@ class CI_Loader {
// Set the default data variables
foreach (array('_ci_view', '_ci_vars', '_ci_path', '_ci_return') as $_ci_val)
{
- $$_ci_val = ( ! isset($_ci_data[$_ci_val])) ? FALSE : $_ci_data[$_ci_val];
+ $$_ci_val = isset($_ci_data[$_ci_val]) ? $_ci_data[$_ci_val] : FALSE;
}
$file_exists = FALSE;
@@ -1019,11 +1017,11 @@ class CI_Loader {
* @param string
* @param bool
* @param string an optional object name
- * @return null
+ * @return void
*/
protected function _ci_init_class($class, $prefix = '', $config = FALSE, $object_name = NULL)
{
- // Is there an associated config file for this class? Note: these should always be lowercase
+ // Is there an associated config file for this class? Note: these should always be lowercase
if ($config === NULL)
{
// Fetch the config paths containing any package paths
@@ -1038,24 +1036,24 @@ class CI_Loader {
// We test for both uppercase and lowercase, for servers that
// are case-sensitive with regard to file names. Check for environment
// first, global next
- if (defined('ENVIRONMENT') AND file_exists($path .'config/'.ENVIRONMENT.'/'.strtolower($class).'.php'))
+ if (defined('ENVIRONMENT') && file_exists($path.'config/'.ENVIRONMENT.'/'.strtolower($class).'.php'))
{
- include($path .'config/'.ENVIRONMENT.'/'.strtolower($class).'.php');
+ include($path.'config/'.ENVIRONMENT.'/'.strtolower($class).'.php');
break;
}
- elseif (defined('ENVIRONMENT') AND file_exists($path .'config/'.ENVIRONMENT.'/'.ucfirst(strtolower($class)).'.php'))
+ elseif (defined('ENVIRONMENT') && file_exists($path.'config/'.ENVIRONMENT.'/'.ucfirst(strtolower($class)).'.php'))
{
- include($path .'config/'.ENVIRONMENT.'/'.ucfirst(strtolower($class)).'.php');
+ include($path.'config/'.ENVIRONMENT.'/'.ucfirst(strtolower($class)).'.php');
break;
}
- elseif (file_exists($path .'config/'.strtolower($class).'.php'))
+ elseif (file_exists($path.'config/'.strtolower($class).'.php'))
{
- include($path .'config/'.strtolower($class).'.php');
+ include($path.'config/'.strtolower($class).'.php');
break;
}
- elseif (file_exists($path .'config/'.ucfirst(strtolower($class)).'.php'))
+ elseif (file_exists($path.'config/'.ucfirst(strtolower($class)).'.php'))
{
- include($path .'config/'.ucfirst(strtolower($class)).'.php');
+ include($path.'config/'.ucfirst(strtolower($class)).'.php');
break;
}
}
@@ -1095,7 +1093,7 @@ class CI_Loader {
if (is_null($object_name))
{
- $classvar = ( ! isset($this->_ci_varmap[$class])) ? $class : $this->_ci_varmap[$class];
+ $classvar = isset($this->_ci_varmap[$class]) ? $this->_ci_varmap[$class] : $class;
}
else
{
@@ -1113,7 +1111,7 @@ class CI_Loader {
}
else
{
- $CI->$classvar = new $name;
+ $CI->$classvar = new $name();
}
}
@@ -1130,7 +1128,7 @@ class CI_Loader {
*/
protected function _ci_autoloader()
{
- if (defined('ENVIRONMENT') AND file_exists(APPPATH.'config/'.ENVIRONMENT.'/autoload.php'))
+ if (defined('ENVIRONMENT') && file_exists(APPPATH.'config/'.ENVIRONMENT.'/autoload.php'))
{
include(APPPATH.'config/'.ENVIRONMENT.'/autoload.php');
}
@@ -1166,14 +1164,14 @@ class CI_Loader {
// Autoload helpers and languages
foreach (array('helper', 'language') as $type)
{
- if (isset($autoload[$type]) AND count($autoload[$type]) > 0)
+ if (isset($autoload[$type]) && count($autoload[$type]) > 0)
{
$this->$type($autoload[$type]);
}
}
// Load libraries
- if (isset($autoload['libraries']) AND count($autoload['libraries']) > 0)
+ if (isset($autoload['libraries']) && count($autoload['libraries']) > 0)
{
// Load the database driver.
if (in_array('database', $autoload['libraries']))
@@ -1208,7 +1206,7 @@ class CI_Loader {
*/
protected function _ci_object_to_array($object)
{
- return (is_object($object)) ? get_object_vars($object) : $object;
+ return is_object($object) ? get_object_vars($object) : $object;
}
// --------------------------------------------------------------------
@@ -1252,7 +1250,8 @@ class CI_Loader {
return $filename;
}
}
+
}
/* End of file Loader.php */
-/* Location: ./system/core/Loader.php */
+/* Location: ./system/core/Loader.php */ \ No newline at end of file
diff --git a/system/core/Output.php b/system/core/Output.php
index faebbbe72..9bf818e88 100755
--- a/system/core/Output.php
+++ b/system/core/Output.php
@@ -25,8 +25,6 @@
* @filesource
*/
-// ------------------------------------------------------------------------
-
/**
* Output Class
*
@@ -94,7 +92,7 @@ class CI_Output {
$this->_zlib_oc = @ini_get('zlib.output_compression');
// Get mime types for later
- if (defined('ENVIRONMENT') AND file_exists(APPPATH.'config/'.ENVIRONMENT.'/mimes.php'))
+ if (defined('ENVIRONMENT') && file_exists(APPPATH.'config/'.ENVIRONMENT.'/mimes.php'))
{
include APPPATH.'config/'.ENVIRONMENT.'/mimes.php';
}
@@ -229,7 +227,7 @@ class CI_Output {
* Set HTTP Status Header
* moved to Common procedural functions in 1.7.2
*
- * @param int the status code
+ * @param int the status code
* @param string
* @return void
*/
@@ -249,7 +247,7 @@ class CI_Output {
*/
public function enable_profiler($val = TRUE)
{
- $this->enable_profiler = (is_bool($val)) ? $val : TRUE;
+ $this->enable_profiler = is_bool($val) ? $val : TRUE;
return $this;
}
@@ -267,7 +265,7 @@ class CI_Output {
{
foreach ($sections as $section => $enable)
{
- $this->_profiler_sections[$section] = ($enable !== FALSE) ? TRUE : FALSE;
+ $this->_profiler_sections[$section] = ($enable !== FALSE);
}
return $this;
@@ -278,12 +276,12 @@ class CI_Output {
/**
* Set Cache
*
- * @param integer
+ * @param int
* @return void
*/
public function cache($time)
{
- $this->cache_expiration = ( ! is_numeric($time)) ? 0 : $time;
+ $this->cache_expiration = is_numeric($time) ? $time : 0;
return $this;
}
@@ -297,7 +295,7 @@ class CI_Output {
* $this->final_output
*
* This function sends the finalized output data to the browser along
- * with any server headers and profile data. It also stops the
+ * with any server headers and profile data. It also stops the
* benchmark timer so the page rendering speed and memory usage can be shown.
*
* @param string
@@ -343,7 +341,7 @@ class CI_Output {
if ($this->parse_exec_vars === TRUE)
{
- $memory = ( ! function_exists('memory_get_usage')) ? '0' : round(memory_get_usage()/1024/1024, 2).'MB';
+ $memory = function_exists('memory_get_usage') ? round(memory_get_usage()/1024/1024, 2).'MB' : '0';
$output = str_replace(array('{elapsed_time}', '{memory_usage}'), array($elapsed, $memory), $output);
}
@@ -520,4 +518,4 @@ class CI_Output {
}
/* End of file Output.php */
-/* Location: ./system/core/Output.php */
+/* Location: ./system/core/Output.php */ \ No newline at end of file
diff --git a/system/core/Router.php b/system/core/Router.php
index b251abb4b..5477fed5d 100755
--- a/system/core/Router.php
+++ b/system/core/Router.php
@@ -25,8 +25,6 @@
* @filesource
*/
-// ------------------------------------------------------------------------
-
/**
* Router Class
*
@@ -111,7 +109,7 @@ class CI_Router {
// since URI segments are more search-engine friendly, but they can optionally be used.
// If this feature is enabled, we will gather the directory/class/method a little differently
$segments = array();
- if ($this->config->item('enable_query_strings') === TRUE AND isset($_GET[$this->config->item('controller_trigger')]))
+ if ($this->config->item('enable_query_strings') === TRUE && isset($_GET[$this->config->item('controller_trigger')]))
{
if (isset($_GET[$this->config->item('directory_trigger')]))
{
@@ -133,7 +131,7 @@ class CI_Router {
}
// Load the routes.php file.
- if (defined('ENVIRONMENT') AND is_file(APPPATH.'config/'.ENVIRONMENT.'/routes.php'))
+ if (defined('ENVIRONMENT') && is_file(APPPATH.'config/'.ENVIRONMENT.'/routes.php'))
{
include(APPPATH.'config/'.ENVIRONMENT.'/routes.php');
}
@@ -147,7 +145,7 @@ class CI_Router {
// Set the default controller so we can display it in the event
// the URI doesn't correlated to a valid controller.
- $this->default_controller = ( ! isset($this->routes['default_controller']) OR $this->routes['default_controller'] == '') ? FALSE : strtolower($this->routes['default_controller']);
+ $this->default_controller = empty($this->routes['default_controller']) ? FALSE : strtolower($this->routes['default_controller']);
// Were there any query string segments? If so, we'll validate them and bail out since we're done.
if (count($segments) > 0)
@@ -248,8 +246,8 @@ class CI_Router {
// --------------------------------------------------------------------
/**
- * Validates the supplied segments. Attempts to determine the path to
- * the controller.
+ * Validates the supplied segments.
+ * Attempts to determine the path to the controller.
*
* @param array
* @return array
@@ -340,7 +338,7 @@ class CI_Router {
// --------------------------------------------------------------------
/**
- * Parse Routes
+ * Parse Routes
*
* This function matches any routes that may exist in
* the config/routes.php file against the URI to
@@ -369,7 +367,7 @@ class CI_Router {
if (preg_match('#^'.$key.'$#', $uri))
{
// Do we have a back-reference?
- if (strpos($val, '$') !== FALSE AND strpos($key, '(') !== FALSE)
+ if (strpos($val, '$') !== FALSE && strpos($key, '(') !== FALSE)
{
$val = preg_replace('#^'.$key.'$#', $val, $uri);
}
@@ -411,7 +409,7 @@ class CI_Router {
// --------------------------------------------------------------------
/**
- * Set the method name
+ * Set the method name
*
* @param string
* @return void
@@ -424,7 +422,7 @@ class CI_Router {
// --------------------------------------------------------------------
/**
- * Fetch the current method
+ * Fetch the current method
*
* @return string
*/
@@ -441,7 +439,7 @@ class CI_Router {
// --------------------------------------------------------------------
/**
- * Set the directory name
+ * Set the directory name
*
* @param string
* @return void
@@ -454,7 +452,7 @@ class CI_Router {
// --------------------------------------------------------------------
/**
- * Fetch the sub-directory (if any) that contains the requested controller class
+ * Fetch the sub-directory (if any) that contains the requested controller class
*
* @return string
*/
@@ -466,10 +464,10 @@ class CI_Router {
// --------------------------------------------------------------------
/**
- * Set the controller overrides
+ * Set the controller overrides
*
* @param array
- * @return null
+ * @return void
*/
public function _set_overrides($routing)
{
@@ -483,7 +481,7 @@ class CI_Router {
$this->set_directory($routing['directory']);
}
- if (isset($routing['controller']) AND $routing['controller'] != '')
+ if (isset($routing['controller']) && $routing['controller'] != '')
{
$this->set_class($routing['controller']);
}
@@ -498,4 +496,4 @@ class CI_Router {
}
/* End of file Router.php */
-/* Location: ./system/core/Router.php */
+/* Location: ./system/core/Router.php */ \ No newline at end of file
diff --git a/system/core/Security.php b/system/core/Security.php
index cd8a61028..ac39ce97b 100755
--- a/system/core/Security.php
+++ b/system/core/Security.php
@@ -196,7 +196,15 @@ class CI_Security {
return FALSE;
}
- setcookie($this->_csrf_cookie_name, $this->_csrf_hash, $expire, config_item('cookie_path'), config_item('cookie_domain'), $secure_cookie);
+ setcookie(
+ $this->_csrf_cookie_name,
+ $this->_csrf_hash,
+ $expire,
+ config_item('cookie_path'),
+ config_item('cookie_domain'),
+ $secure_cookie,
+ config_item('cookie_httponly')
+ );
log_message('debug', 'CRSF cookie Set');
return $this;
diff --git a/system/core/URI.php b/system/core/URI.php
index 4a2e87c2a..48bb7ae3c 100755
--- a/system/core/URI.php
+++ b/system/core/URI.php
@@ -22,7 +22,6 @@
* @license http://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
* @link http://codeigniter.com
* @since Version 1.0
- * @filesource
*/
// ------------------------------------------------------------------------
@@ -93,7 +92,7 @@ class CI_URI {
if (strtoupper($this->config->item('uri_protocol')) === 'AUTO')
{
// Is the request coming from the command line?
- if (php_sapi_name() === 'cli' OR defined('STDIN'))
+ if ($this->_is_cli_request())
{
$this->_set_uri_string($this->_parse_cli_args());
return;
@@ -227,6 +226,21 @@ class CI_URI {
}
// --------------------------------------------------------------------
+
+ /**
+ * Is cli Request?
+ *
+ * Duplicate of function from the Input class to test to see if a request was made from the command line
+ *
+ * @return boolean
+ */
+ protected function _is_cli_request()
+ {
+ return (php_sapi_name() == 'cli') OR defined('STDIN');
+ }
+
+
+ // --------------------------------------------------------------------
/**
* Parse cli arguments
diff --git a/system/database/DB.php b/system/database/DB.php
index 116116bf4..96e495515 100755
--- a/system/database/DB.php
+++ b/system/database/DB.php
@@ -37,11 +37,11 @@
function &DB($params = '', $active_record_override = NULL)
{
// Load the DB config file if a DSN string wasn't passed
- if (is_string($params) AND strpos($params, '://') === FALSE)
+ if (is_string($params) && strpos($params, '://') === FALSE)
{
// Is the config file in the environment folder?
if (( ! defined('ENVIRONMENT') OR ! file_exists($file_path = APPPATH.'config/'.ENVIRONMENT.'/database.php'))
- AND ! file_exists($file_path = APPPATH.'config/database.php'))
+ && ! file_exists($file_path = APPPATH.'config/database.php'))
{
show_error('The configuration file database.php does not exist.');
}
@@ -74,24 +74,24 @@ function &DB($params = '', $active_record_override = NULL)
* parameter. DSNs must have this prototype:
* $dsn = 'driver://username:password@hostname/database';
*/
- if (($dns = @parse_url($params)) === FALSE)
+ if (($dsn = @parse_url($params)) === FALSE)
{
show_error('Invalid DB Connection String');
}
$params = array(
- 'dbdriver' => $dns['scheme'],
- 'hostname' => (isset($dns['host'])) ? rawurldecode($dns['host']) : '',
- 'port' => (isset($dns['port'])) ? rawurldecode($dns['port']) : '',
- 'username' => (isset($dns['user'])) ? rawurldecode($dns['user']) : '',
- 'password' => (isset($dns['pass'])) ? rawurldecode($dns['pass']) : '',
- 'database' => (isset($dns['path'])) ? rawurldecode(substr($dns['path'], 1)) : ''
+ 'dbdriver' => $dsn['scheme'],
+ 'hostname' => isset($dsn['host']) ? rawurldecode($dsn['host']) : '',
+ 'port' => isset($dsn['port']) ? rawurldecode($dsn['port']) : '',
+ 'username' => isset($dsn['user']) ? rawurldecode($dsn['user']) : '',
+ 'password' => isset($dsn['pass']) ? rawurldecode($dsn['pass']) : '',
+ 'database' => isset($dsn['path']) ? rawurldecode(substr($dsn['path'], 1)) : ''
);
// were additional config items set?
- if (isset($dns['query']))
+ if (isset($dsn['query']))
{
- parse_str($dns['query'], $extra);
+ parse_str($dsn['query'], $extra);
foreach ($extra as $key => $val)
{
// booleans please
@@ -158,4 +158,4 @@ function &DB($params = '', $active_record_override = NULL)
}
/* End of file DB.php */
-/* Location: ./system/database/DB.php */
+/* Location: ./system/database/DB.php */ \ No newline at end of file
diff --git a/system/database/DB_active_rec.php b/system/database/DB_active_rec.php
index 756709698..b324226ab 100644
--- a/system/database/DB_active_rec.php
+++ b/system/database/DB_active_rec.php
@@ -25,8 +25,6 @@
* @filesource
*/
-// ------------------------------------------------------------------------
-
/**
* Active Record Class
*
@@ -38,7 +36,7 @@
* @author EllisLab Dev Team
* @link http://codeigniter.com/user_guide/database/
*/
-class CI_DB_active_record extends CI_DB_driver {
+abstract class CI_DB_active_record extends CI_DB_driver {
protected $return_delete_sql = FALSE;
protected $reset_delete_data = FALSE;
@@ -214,6 +212,7 @@ class CI_DB_active_record extends CI_DB_driver {
$sql = $this->protect_identifiers($type.'('.trim($select).')').' AS '.$this->protect_identifiers(trim($alias));
$this->ar_select[] = $sql;
+ $this->ar_no_escape[] = NULL;
if ($this->ar_caching === TRUE)
{
@@ -421,7 +420,7 @@ class CI_DB_active_record extends CI_DB_driver {
foreach ($key as $k => $v)
{
- $prefix = (count($this->ar_where) === 0 AND count($this->ar_cache_where) === 0) ? '' : $type;
+ $prefix = (count($this->ar_where) === 0 && count($this->ar_cache_where) === 0) ? '' : $type;
if (is_null($v) && ! $this->_has_operator($k))
{
@@ -536,7 +535,7 @@ class CI_DB_active_record extends CI_DB_driver {
*
* @param string The field to search
* @param array The values searched on
- * @param boolean If the statement would be IN or NOT IN
+ * @param bool If the statement would be IN or NOT IN
* @param string
* @return object
*/
@@ -718,7 +717,7 @@ class CI_DB_active_record extends CI_DB_driver {
{
$type = $this->_group_get_type($type);
$this->ar_where_group_started = TRUE;
- $prefix = (count($this->ar_where) === 0 AND count($this->ar_cache_where) === 0) ? '' : $type;
+ $prefix = (count($this->ar_where) === 0 && count($this->ar_cache_where) === 0) ? '' : $type;
$this->ar_where[] = $value = $prefix.$not.str_repeat(' ', ++$this->ar_where_group_count).' (';
if ($this->ar_caching)
@@ -983,8 +982,8 @@ class CI_DB_active_record extends CI_DB_driver {
/**
* Sets the LIMIT value
*
- * @param integer the limit value
- * @param integer the offset value
+ * @param int the limit value
+ * @param int the offset value
* @return object
*/
public function limit($value, $offset = NULL)
@@ -1004,7 +1003,7 @@ class CI_DB_active_record extends CI_DB_driver {
/**
* Sets the OFFSET value
*
- * @param integer the offset value
+ * @param int the offset value
* @return object
*/
public function offset($offset)
@@ -1020,7 +1019,7 @@ class CI_DB_active_record extends CI_DB_driver {
*
* @param mixed
* @param string
- * @param boolean
+ * @param bool
* @return object
*/
public function set($key, $value = '', $escape = TRUE)
@@ -1054,9 +1053,8 @@ class CI_DB_active_record extends CI_DB_driver {
*
* Compiles a SELECT query string and returns the sql.
*
- * @access public
* @param string the table name to select from (optional)
- * @param boolean TRUE: resets AR values; FALSE: leave AR vaules alone
+ * @param bool TRUE: resets AR values; FALSE: leave AR vaules alone
* @return string
*/
public function get_compiled_select($table = '', $reset = TRUE)
@@ -1225,7 +1223,7 @@ class CI_DB_active_record extends CI_DB_driver {
*
* @param mixed
* @param string
- * @param boolean
+ * @param bool
* @return object
*/
public function set_insert_batch($key, $value = '', $escape = TRUE)
@@ -1282,9 +1280,8 @@ class CI_DB_active_record extends CI_DB_driver {
*
* Compiles an insert query and returns the sql
*
- * @access public
* @param string the table to insert into
- * @param boolean TRUE: reset AR values; FALSE: leave AR values alone
+ * @param bool TRUE: reset AR values; FALSE: leave AR values alone
* @return string
*/
public function get_compiled_insert($table = '', $reset = TRUE)
@@ -1315,7 +1312,6 @@ class CI_DB_active_record extends CI_DB_driver {
*
* Compiles an insert string and runs the query
*
- * @access public
* @param string the table to insert data into
* @param array an associative array of insert values
* @return object
@@ -1351,7 +1347,6 @@ class CI_DB_active_record extends CI_DB_driver {
* validate that the there data is actually being set and that table
* has been chosen to be inserted into.
*
- * @access public
* @param string the table to insert data into
* @return string
*/
@@ -1422,9 +1417,8 @@ class CI_DB_active_record extends CI_DB_driver {
*
* Compiles an update query and returns the sql
*
- * @access public
* @param string the table to update
- * @param boolean TRUE: reset AR values; FALSE: leave AR values alone
+ * @param bool TRUE: reset AR values; FALSE: leave AR values alone
* @return string
*/
public function get_compiled_update($table = '', $reset = TRUE)
@@ -1498,7 +1492,6 @@ class CI_DB_active_record extends CI_DB_driver {
* validate that data is actually being set and that a table has been
* chosen to be update.
*
- * @access public
* @param string the table to update data on
* @return bool
*/
@@ -1583,7 +1576,7 @@ class CI_DB_active_record extends CI_DB_driver {
*
* @param array
* @param string
- * @param boolean
+ * @param bool
* @return object
*/
public function set_update_batch($key, $index = '', $escape = TRUE)
@@ -1695,9 +1688,8 @@ class CI_DB_active_record extends CI_DB_driver {
*
* Compiles a delete query string and returns the sql
*
- * @access public
* @param string the table to delete from
- * @param boolean TRUE: reset AR values; FALSE: leave AR values alone
+ * @param bool TRUE: reset AR values; FALSE: leave AR values alone
* @return string
*/
public function get_compiled_delete($table = '', $reset = TRUE)
@@ -1718,7 +1710,7 @@ class CI_DB_active_record extends CI_DB_driver {
* @param mixed the table(s) to delete from. String or array
* @param mixed the where clause
* @param mixed the limit clause
- * @param boolean
+ * @param bool
* @return object
*/
public function delete($table = '', $where = '', $limit = NULL, $reset_data = TRUE)
@@ -2061,7 +2053,6 @@ class CI_DB_active_record extends CI_DB_driver {
*
* Empties the AR cache
*
- * @access public
* @return void
*/
public function flush_cache()
@@ -2113,7 +2104,7 @@ class CI_DB_active_record extends CI_DB_driver {
// If we are "protecting identifiers" we need to examine the "from"
// portion of the query to determine if there are any aliases
- if ($this->_protect_identifiers === TRUE AND count($this->ar_cache_from) > 0)
+ if ($this->_protect_identifiers === TRUE && count($this->ar_cache_from) > 0)
{
$this->_track_aliases($this->ar_from);
}
@@ -2196,19 +2187,19 @@ class CI_DB_active_record extends CI_DB_driver {
protected function _reset_write()
{
$this->_reset_run(array(
- 'ar_set' => array(),
- 'ar_from' => array(),
- 'ar_where' => array(),
- 'ar_like' => array(),
- 'ar_orderby' => array(),
- 'ar_keys' => array(),
- 'ar_limit' => FALSE,
- 'ar_order' => FALSE
- )
- );
+ 'ar_set' => array(),
+ 'ar_from' => array(),
+ 'ar_where' => array(),
+ 'ar_like' => array(),
+ 'ar_orderby' => array(),
+ 'ar_keys' => array(),
+ 'ar_limit' => FALSE,
+ 'ar_order' => FALSE
+ )
+ );
}
}
/* End of file DB_active_rec.php */
-/* Location: ./system/database/DB_active_rec.php */
+/* Location: ./system/database/DB_active_rec.php */ \ No newline at end of file
diff --git a/system/database/DB_cache.php b/system/database/DB_cache.php
index fb0cfa89a..58e6968c0 100644
--- a/system/database/DB_cache.php
+++ b/system/database/DB_cache.php
@@ -183,4 +183,4 @@ class CI_DB_Cache {
}
/* End of file DB_cache.php */
-/* Location: ./system/database/DB_cache.php */
+/* Location: ./system/database/DB_cache.php */ \ No newline at end of file
diff --git a/system/database/DB_driver.php b/system/database/DB_driver.php
index bcff43392..45f17e8ec 100644
--- a/system/database/DB_driver.php
+++ b/system/database/DB_driver.php
@@ -38,7 +38,7 @@
* @author EllisLab Dev Team
* @link http://codeigniter.com/user_guide/database/
*/
-class CI_DB_driver {
+abstract class CI_DB_driver {
public $dsn;
public $username;
@@ -99,9 +99,13 @@ class CI_DB_driver {
*/
public function initialize()
{
- // If an existing connection resource is available
- // there is no need to connect and select the database
- if (is_resource($this->conn_id) OR is_object($this->conn_id))
+ /* If an established connection is available, then there's
+ * no need to connect and select the database.
+ *
+ * Depending on the database driver, conn_id can be either
+ * boolean TRUE, a resource or an object.
+ */
+ if ($this->conn_id)
{
return TRUE;
}
@@ -171,10 +175,41 @@ class CI_DB_driver {
// --------------------------------------------------------------------
/**
+ * Reconnect
+ *
+ * Keep / reestablish the db connection if no queries have been
+ * sent for a length of time exceeding the server's idle timeout.
+ *
+ * This is just a dummy method to allow drivers without such
+ * functionality to not declare it, while others will override it.
+ *
+ * @return void
+ */
+ public function reconnect()
+ {
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Select database
+ *
+ * This is just a dummy method to allow drivers without such
+ * functionality to not declare it, while others will override it.
+ *
+ * @return bool
+ */
+ public function db_select()
+ {
+ return TRUE;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
* Set client character set
*
* @param string
- * @param string
* @return bool
*/
public function db_set_charset($charset)
@@ -266,17 +301,13 @@ class CI_DB_driver {
{
log_message('error', 'Invalid query: '.$sql);
- if ($this->db_debug)
- {
- return $this->display_error('db_invalid_query');
- }
- return FALSE;
+ return ($this->db_debug) ? $this->display_error('db_invalid_query') : FALSE;
}
// Verify table prefix and replace if necessary
- if ( ($this->dbprefix != '' AND $this->swap_pre != '') AND ($this->dbprefix != $this->swap_pre) )
+ if ($this->dbprefix != '' && $this->swap_pre != '' && $this->dbprefix != $this->swap_pre)
{
- $sql = preg_replace("/(\W)".$this->swap_pre."(\S+?)/", "\\1".$this->dbprefix."\\2", $sql);
+ $sql = preg_replace('/(\W)'.$this->swap_pre.'(\S+?)/', '\\1'.$this->dbprefix.'\\2', $sql);
}
// Compile binds if needed
@@ -288,15 +319,12 @@ class CI_DB_driver {
// Is query caching enabled? If the query is a "read type"
// we will load the caching class and return the previously
// cached query if it exists
- if ($this->cache_on == TRUE AND stristr($sql, 'SELECT'))
+ if ($this->cache_on == TRUE && stripos($sql, 'SELECT') !== FALSE && $this->_cache_init())
{
- if ($this->_cache_init())
+ $this->load_rdriver();
+ if (FALSE !== ($cache = $this->CACHE->read($sql)))
{
- $this->load_rdriver();
- if (FALSE !== ($cache = $this->CACHE->read($sql)))
- {
- return $cache;
- }
+ return $cache;
}
}
@@ -335,13 +363,7 @@ class CI_DB_driver {
$this->trans_complete();
// Display errors
- return $this->display_error(
- array(
- 'Error Number: '.$error['code'],
- $error['message'],
- $sql
- )
- );
+ return $this->display_error(array('Error Number: '.$error['code'], $error['message'], $sql));
}
return FALSE;
@@ -365,7 +387,7 @@ class CI_DB_driver {
{
// If caching is enabled we'll auto-cleanup any
// existing files related to this particular URI
- if ($this->cache_on == TRUE AND $this->cache_autodel == TRUE AND $this->_cache_init())
+ if ($this->cache_on == TRUE && $this->cache_autodel == TRUE && $this->_cache_init())
{
$this->CACHE->delete();
}
@@ -387,9 +409,9 @@ class CI_DB_driver {
$RES->num_rows = $RES->num_rows();
- // Is query caching enabled? If so, we'll serialize the
+ // Is query caching enabled? If so, we'll serialize the
// result object and save it to a cache file.
- if ($this->cache_on == TRUE AND $this->_cache_init())
+ if ($this->cache_on == TRUE && $this->_cache_init())
{
// We'll create a new instance of the result object
// only without the platform specific driver since
@@ -398,9 +420,9 @@ class CI_DB_driver {
// result object, so we'll have to compile the data
// and save it)
$CR = new CI_DB_result();
- $CR->num_rows = $RES->num_rows();
$CR->result_object = $RES->result_object();
$CR->result_array = $RES->result_array();
+ $CR->num_rows = $RES->num_rows();
// Reset these since cached objects can not utilize resource IDs.
$CR->conn_id = NULL;
@@ -591,7 +613,8 @@ class CI_DB_driver {
// The count of bind should be 1 less then the count of segments
// If there are more bind arguments trim it down
- if (count($binds) >= count($segments)) {
+ if (count($binds) >= count($segments))
+ {
$binds = array_slice($binds, 0, count($segments)-1);
}
@@ -600,8 +623,7 @@ class CI_DB_driver {
$i = 0;
foreach ($binds as $bind)
{
- $result .= $this->escape($bind);
- $result .= $segments[++$i];
+ $result .= $this->escape($bind).$segments[++$i];
}
return $result;
@@ -672,15 +694,15 @@ class CI_DB_driver {
{
if (is_string($str) OR method_exists($str, '__toString'))
{
- $str = "'".$this->escape_str($str)."'";
+ return "'".$this->escape_str($str)."'";
}
elseif (is_bool($str))
{
- $str = ($str === FALSE) ? 0 : 1;
+ return ($str === FALSE) ? 0 : 1;
}
elseif (is_null($str))
{
- $str = 'NULL';
+ return 'NULL';
}
return $str;
@@ -716,13 +738,7 @@ class CI_DB_driver {
public function primary($table = '')
{
$fields = $this->list_fields($table);
-
- if ( ! is_array($fields))
- {
- return FALSE;
- }
-
- return current($fields);
+ return is_array($fields) ? current($fields) : FALSE;
}
// --------------------------------------------------------------------
@@ -742,35 +758,40 @@ class CI_DB_driver {
if (FALSE === ($sql = $this->_list_tables($constrain_by_prefix)))
{
- if ($this->db_debug)
- {
- return $this->display_error('db_unsupported_function');
- }
- return FALSE;
+ return ($this->db_debug) ? $this->display_error('db_unsupported_function') : FALSE;
}
- $retval = array();
+ $this->data_cache['table_names'] = array();
$query = $this->query($sql);
- if ($query->num_rows() > 0)
+ foreach ($query->result_array() as $row)
{
- $table = FALSE;
- $rows = $query->result_array();
- $key = (($row = current($rows)) && in_array('table_name', array_map('strtolower', array_keys($row))));
-
- if ($key)
+ // Do we know from which column to get the table name?
+ if ( ! isset($key))
{
- $table = array_key_exists('TABLE_NAME', $row) ? 'TABLE_NAME' : 'table_name';
+ if (isset($row['table_name']))
+ {
+ $key = 'table_name';
+ }
+ elseif (isset($row['TABLE_NAME']))
+ {
+ $key = 'TABLE_NAME';
+ }
+ else
+ {
+ /* We have no other choice but to just get the first element's key.
+ * Due to array_shift() accepting it's argument by reference, if
+ * E_STRICT is on, this would trigger a warning. So we'll have to
+ * assign it first.
+ */
+ $key = array_keys($row);
+ $key = array_shift($key);
+ }
}
- foreach ($rows as $row)
- {
- $retval[] = ( ! $table) ? current($row) : $row[$table];
- }
+ $this->data_cache['table_names'][] = $row[$key];
}
- $this->data_cache['table_names'] = $retval;
-
return $this->data_cache['table_names'];
}
@@ -804,38 +825,45 @@ class CI_DB_driver {
if ($table == '')
{
- if ($this->db_debug)
- {
- return $this->display_error('db_field_param_missing');
- }
- return FALSE;
+ return ($this->db_debug) ? $this->display_error('db_field_param_missing') : FALSE;
}
if (FALSE === ($sql = $this->_list_columns($table)))
{
- if ($this->db_debug)
- {
- return $this->display_error('db_unsupported_function');
- }
- return FALSE;
+ return ($this->db_debug) ? $this->display_error('db_unsupported_function') : FALSE;
}
$query = $this->query($sql);
+ $this->data_cache['field_names'][$table] = array();
- $retval = array();
foreach ($query->result_array() as $row)
{
- if (isset($row['COLUMN_NAME']))
- {
- $retval[] = $row['COLUMN_NAME'];
- }
- else
+ // Do we know from where to get the column's name?
+ if ( ! isset($key))
{
- $retval[] = current($row);
+ if (isset($row['column_name']))
+ {
+ $key = 'column_name';
+ }
+ elseif (isset($row['COLUMN_NAME']))
+ {
+ $key = 'COLUMN_NAME';
+ }
+ else
+ {
+ /* We have no other choice but to just get the first element's key.
+ * Due to array_shift() accepting it's argument by reference, if
+ * E_STRICT is on, this would trigger a warning. So we'll have to
+ * assign it first.
+ */
+ $key = array_keys($row);
+ $key = array_shift($key);
+ }
}
+
+ $this->data_cache['field_names'][$table][] = $row[$key];
}
- $this->data_cache['field_names'][$table] = $retval;
return $this->data_cache['field_names'][$table];
}
@@ -850,7 +878,7 @@ class CI_DB_driver {
*/
public function field_exists($field_name, $table_name)
{
- return ( ! in_array($field_name, $this->list_fields($table_name))) ? FALSE : TRUE;
+ return in_array($field_name, $this->list_fields($table_name));
}
// --------------------------------------------------------------------
@@ -865,15 +893,10 @@ class CI_DB_driver {
{
if ($table == '')
{
- if ($this->db_debug)
- {
- return $this->display_error('db_field_param_missing');
- }
- return FALSE;
+ return ($this->db_debug) ? $this->display_error('db_field_param_missing') : FALSE;
}
$query = $this->query($this->_field_data($this->protect_identifiers($table, TRUE, NULL, FALSE)));
-
return $query->field_data();
}
@@ -888,8 +911,7 @@ class CI_DB_driver {
*/
public function insert_string($table, $data)
{
- $fields = array();
- $values = array();
+ $fields = $values = array();
foreach ($data as $key => $val)
{
@@ -962,13 +984,7 @@ class CI_DB_driver {
*/
protected function _has_operator($str)
{
- $str = trim($str);
- if ( ! preg_match("/(\s|<|>|!|=|is null|is not null)/i", $str))
- {
- return FALSE;
- }
-
- return TRUE;
+ return (bool) preg_match('/(\s|<|>|!|=|IS NULL|IS NOT NULL)/i', trim($str));
}
// --------------------------------------------------------------------
@@ -991,25 +1007,12 @@ class CI_DB_driver {
if ( ! function_exists($function))
{
- if ($this->db_debug)
- {
- return $this->display_error('db_unsupported_function');
- }
- return FALSE;
+ return ($this->db_debug) ? $this->display_error('db_unsupported_function') : FALSE;
}
- else
- {
- $args = (func_num_args() > 1) ? array_splice(func_get_args(), 1) : null;
- if (is_null($args))
- {
- return call_user_func($function);
- }
- else
- {
- return call_user_func_array($function, $args);
- }
- }
+ return (func_num_args() > 1)
+ ? call_user_func_array($function, array_splice(func_get_args(), 1))
+ : call_user_func($function);
}
// --------------------------------------------------------------------
@@ -1034,8 +1037,7 @@ class CI_DB_driver {
*/
public function cache_on()
{
- $this->cache_on = TRUE;
- return TRUE;
+ return $this->cache_on = TRUE;
}
// --------------------------------------------------------------------
@@ -1047,8 +1049,7 @@ class CI_DB_driver {
*/
public function cache_off()
{
- $this->cache_on = FALSE;
- return FALSE;
+ return $this->cache_on = FALSE;
}
@@ -1061,11 +1062,9 @@ class CI_DB_driver {
*/
public function cache_delete($segment_one = '', $segment_two = '')
{
- if ( ! $this->_cache_init())
- {
- return FALSE;
- }
- return $this->CACHE->delete($segment_one, $segment_two);
+ return ($this->_cache_init())
+ ? $this->CACHE->delete($segment_one, $segment_two)
+ : FALSE;
}
// --------------------------------------------------------------------
@@ -1077,12 +1076,9 @@ class CI_DB_driver {
*/
public function cache_delete_all()
{
- if ( ! $this->_cache_init())
- {
- return FALSE;
- }
-
- return $this->CACHE->delete_all();
+ return ($this->_cache_init())
+ ? $this->CACHE->delete_all()
+ : FALSE;
}
// --------------------------------------------------------------------
@@ -1094,18 +1090,17 @@ class CI_DB_driver {
*/
protected function _cache_init()
{
- if (is_object($this->CACHE) AND class_exists('CI_DB_Cache'))
+ if (class_exists('CI_DB_Cache'))
{
- return TRUE;
- }
-
- if ( ! class_exists('CI_DB_Cache'))
- {
- if ( ! @include(BASEPATH.'database/DB_cache.php'))
+ if (is_object($this->CACHE))
{
- return $this->cache_off();
+ return TRUE;
}
}
+ elseif ( ! @include_once(BASEPATH.'database/DB_cache.php'))
+ {
+ return $this->cache_off();
+ }
$this->CACHE = new CI_DB_Cache($this); // pass db object to support multiple db connections and returned db objects
return TRUE;
@@ -1120,11 +1115,11 @@ class CI_DB_driver {
*/
public function close()
{
- if (is_resource($this->conn_id) OR is_object($this->conn_id))
+ if ($this->conn_id)
{
$this->_close($this->conn_id);
+ $this->conn_id = FALSE;
}
- $this->conn_id = FALSE;
}
// --------------------------------------------------------------------
@@ -1156,9 +1151,7 @@ class CI_DB_driver {
// Find the most likely culprit of the error by going through
// the backtrace until the source file is no longer in the
// database folder.
-
$trace = debug_backtrace();
-
foreach ($trace as $call)
{
if (isset($call['file']) && strpos($call['file'], BASEPATH.'database') === FALSE)
@@ -1166,7 +1159,6 @@ class CI_DB_driver {
// Found it - use a relative path for safety
$message[] = 'Filename: '.str_replace(array(BASEPATH, APPPATH), '', $call['file']);
$message[] = 'Line Number: '.$call['line'];
-
break;
}
}
@@ -1184,7 +1176,7 @@ class CI_DB_driver {
* This function is used extensively by the Active Record class, and by
* a couple functions in this class.
* It takes a column or table name (optionally with an alias) and inserts
- * the table prefix onto it. Some logic is necessary in order to deal with
+ * the table prefix onto it. Some logic is necessary in order to deal with
* column names that include the path. Consider a query like this:
*
* SELECT * FROM hostname.database.table.column AS c FROM hostname.database.table
@@ -1227,12 +1219,15 @@ class CI_DB_driver {
// If the item has an alias declaration we remove it and set it aside.
// Basically we remove everything to the right of the first space
- $alias = '';
if (strpos($item, ' ') !== FALSE)
{
- $alias = strstr($item, " ");
+ $alias = strstr($item, ' ');
$item = substr($item, 0, - strlen($alias));
}
+ else
+ {
+ $alias = '';
+ }
// This is basically a bug fix for queries that use MAX, MIN, etc.
// If a parenthesis is found we know that we do not need to
@@ -1267,6 +1262,7 @@ class CI_DB_driver {
$item = implode('.', $parts);
}
+
return $item.$alias;
}
@@ -1301,13 +1297,12 @@ class CI_DB_driver {
}
// Verify table prefix and replace if necessary
- if ($this->swap_pre != '' && strncmp($parts[$i], $this->swap_pre, strlen($this->swap_pre)) === 0)
+ if ($this->swap_pre != '' && strpos($parts[$i], $this->swap_pre) === 0)
{
- $parts[$i] = preg_replace("/^".$this->swap_pre."(\S+?)/", $this->dbprefix."\\1", $parts[$i]);
+ $parts[$i] = preg_replace('/^'.$this->swap_pre.'(\S+?)/', $this->dbprefix.'\\1', $parts[$i]);
}
-
// We only add the table prefix if it does not already exist
- if (substr($parts[$i], 0, strlen($this->dbprefix)) != $this->dbprefix)
+ elseif (strpos($parts[$i], $this->dbprefix) !== 0)
{
$parts[$i] = $this->dbprefix.$parts[$i];
}
@@ -1328,19 +1323,18 @@ class CI_DB_driver {
if ($this->dbprefix != '')
{
// Verify table prefix and replace if necessary
- if ($this->swap_pre != '' && strncmp($item, $this->swap_pre, strlen($this->swap_pre)) === 0)
+ if ($this->swap_pre != '' && strpos($item, $this->swap_pre) === 0)
{
- $item = preg_replace("/^".$this->swap_pre."(\S+?)/", $this->dbprefix."\\1", $item);
+ $item = preg_replace('/^'.$this->swap_pre.'(\S+?)/', $this->dbprefix.'\\1', $item);
}
-
// Do we prefix an item with no segments?
- if ($prefix_single == TRUE AND substr($item, 0, strlen($this->dbprefix)) != $this->dbprefix)
+ elseif ($prefix_single == TRUE && strpos($item, $this->dbprefix) !== 0)
{
$item = $this->dbprefix.$item;
}
}
- if ($protect_identifiers === TRUE AND ! in_array($item, $this->_reserved_identifiers))
+ if ($protect_identifiers === TRUE && ! in_array($item, $this->_reserved_identifiers))
{
$item = $this->_escape_identifiers($item);
}
@@ -1364,4 +1358,4 @@ class CI_DB_driver {
}
/* End of file DB_driver.php */
-/* Location: ./system/database/DB_driver.php */
+/* Location: ./system/database/DB_driver.php */ \ No newline at end of file
diff --git a/system/database/DB_forge.php b/system/database/DB_forge.php
index fe2a67728..34c502a99 100644
--- a/system/database/DB_forge.php
+++ b/system/database/DB_forge.php
@@ -34,7 +34,7 @@
* @author EllisLab Dev Team
* @link http://codeigniter.com/user_guide/database/
*/
-class CI_DB_forge {
+abstract class CI_DB_forge {
public $fields = array();
public $keys = array();
@@ -346,4 +346,4 @@ class CI_DB_forge {
}
/* End of file DB_forge.php */
-/* Location: ./system/database/DB_forge.php */
+/* Location: ./system/database/DB_forge.php */ \ No newline at end of file
diff --git a/system/database/DB_result.php b/system/database/DB_result.php
index c3cdd24ff..bb09c014c 100644
--- a/system/database/DB_result.php
+++ b/system/database/DB_result.php
@@ -57,7 +57,7 @@ class CI_DB_result {
* Query result. Acts as a wrapper function for the following functions.
*
* @param string can be "object" or "array"
- * @return mixed either a result object or array
+ * @return object
*/
public function result($type = 'object')
{
@@ -108,9 +108,9 @@ class CI_DB_result {
// --------------------------------------------------------------------
/**
- * Query result. "object" version.
+ * Query result. "object" version.
*
- * @return object
+ * @return array
*/
public function result_object()
{
@@ -224,7 +224,7 @@ class CI_DB_result {
return;
}
- if ($key != '' AND ! is_null($value))
+ if ($key != '' && ! is_null($value))
{
$this->row_data[$key] = $value;
}
@@ -245,7 +245,7 @@ class CI_DB_result {
return $result;
}
- if ($n != $this->current_row AND isset($result[$n]))
+ if ($n != $this->current_row && isset($result[$n]))
{
$this->current_row = $n;
}
@@ -266,7 +266,7 @@ class CI_DB_result {
return $result;
}
- if ($n != $this->current_row AND isset($result[$n]))
+ if ($n != $this->current_row && isset($result[$n]))
{
$this->current_row = $n;
}
@@ -289,7 +289,7 @@ class CI_DB_result {
return $result;
}
- if ($n != $this->current_row AND isset($result[$n]))
+ if ($n != $this->current_row && isset($result[$n]))
{
$this->current_row = $n;
}
@@ -297,7 +297,6 @@ class CI_DB_result {
return $result[$this->current_row];
}
-
// --------------------------------------------------------------------
/**
@@ -374,9 +373,9 @@ class CI_DB_result {
/**
* The following functions are normally overloaded by the identically named
* methods in the platform-specific driver -- except when query caching
- * is used. When caching is enabled we do not load the other driver.
+ * is used. When caching is enabled we do not load the other driver.
* These functions are primarily here to prevent undefined function errors
- * when a cached result object is in use. They are not otherwise fully
+ * when a cached result object is in use. They are not otherwise fully
* operational due to the unavailability of the database resource IDs with
* cached results.
*/
@@ -384,7 +383,7 @@ class CI_DB_result {
public function num_fields() { return 0; }
public function list_fields() { return array(); }
public function field_data() { return array(); }
- public function free_result() { return TRUE; }
+ public function free_result() { $this->result_id = FALSE; }
protected function _data_seek() { return TRUE; }
protected function _fetch_assoc() { return array(); }
protected function _fetch_object() { return array(); }
@@ -392,4 +391,4 @@ class CI_DB_result {
}
/* End of file DB_result.php */
-/* Location: ./system/database/DB_result.php */
+/* Location: ./system/database/DB_result.php */ \ No newline at end of file
diff --git a/system/database/DB_utility.php b/system/database/DB_utility.php
index c94f93e5e..642a004bd 100644
--- a/system/database/DB_utility.php
+++ b/system/database/DB_utility.php
@@ -32,7 +32,7 @@
* @author EllisLab Dev Team
* @link http://codeigniter.com/user_guide/database/
*/
-class CI_DB_utility extends CI_DB_forge {
+abstract class CI_DB_utility extends CI_DB_forge {
public $db;
public $data_cache = array();
@@ -384,4 +384,4 @@ class CI_DB_utility extends CI_DB_forge {
}
/* End of file DB_utility.php */
-/* Location: ./system/database/DB_utility.php */
+/* Location: ./system/database/DB_utility.php */ \ No newline at end of file
diff --git a/system/database/drivers/cubrid/cubrid_driver.php b/system/database/drivers/cubrid/cubrid_driver.php
index 244707395..0f9c427e6 100644
--- a/system/database/drivers/cubrid/cubrid_driver.php
+++ b/system/database/drivers/cubrid/cubrid_driver.php
@@ -1,13 +1,13 @@
-<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
* An open source application development framework for PHP 5.2.4 or newer
*
* NOTICE OF LICENSE
- *
+ *
* Licensed under the Open Software License version 3.0
- *
+ *
* This source file is subject to the Open Software License (OSL 3.0) that is
* bundled with this package in the files license.txt / license.rst. It is
* also available through the world wide web at this URL:
@@ -25,8 +25,6 @@
* @filesource
*/
-// ------------------------------------------------------------------------
-
/**
* CUBRID Database Adapter Class
*
@@ -42,115 +40,120 @@
*/
class CI_DB_cubrid_driver extends CI_DB {
- // Default CUBRID Broker port. Will be used unless user
- // explicitly specifies another one.
- const DEFAULT_PORT = 33000;
-
- var $dbdriver = 'cubrid';
+ public $dbdriver = 'cubrid';
// The character used for escaping - no need in CUBRID
- var $_escape_char = '';
+ protected $_escape_char = '';
// clause and character used for LIKE escape sequences - not used in CUBRID
- var $_like_escape_str = '';
- var $_like_escape_chr = '';
+ protected $_like_escape_str = '';
+ protected $_like_escape_chr = '';
/**
* The syntax to count rows is slightly different across different
* database engines, so this string appears in each driver and is
* used for the count_all() and count_all_results() functions.
*/
- var $_count_string = 'SELECT COUNT(*) AS ';
- var $_random_keyword = ' RAND()'; // database specific random keyword
+ protected $_count_string = 'SELECT COUNT(*) AS ';
+ protected $_random_keyword = ' RAND()'; // database specific random keyword
- /**
- * Non-persistent database connection
- *
- * @access private called by the base class
- * @return resource
- */
- function db_connect()
- {
- // If no port is defined by the user, use the default value
- if ($this->port == '')
- {
- $this->port = self::DEFAULT_PORT;
- }
+ // CUBRID-specific properties
+ public $auto_commit = TRUE;
- $conn = cubrid_connect($this->hostname, $this->port, $this->database, $this->username, $this->password);
+ public function __construct($params)
+ {
+ parent::__construct($params);
- if ($conn)
+ if (preg_match('/^CUBRID:[^:]+(:[0-9][1-9]{0,4})?:[^:]+:[^:]*:[^:]*:(\?.+)?$/', $this->dsn, $matches))
{
- // Check if a user wants to run queries in dry, i.e. run the
- // queries but not commit them.
- if (isset($this->auto_commit) && ! $this->auto_commit)
+ if (stripos($matches[2], 'autocommit=off') !== FALSE)
{
- cubrid_set_autocommit($conn, CUBRID_AUTOCOMMIT_FALSE);
- }
- else
- {
- cubrid_set_autocommit($conn, CUBRID_AUTOCOMMIT_TRUE);
- $this->auto_commit = TRUE;
+ $this->auto_commit = FALSE;
}
}
+ else
+ {
+ // If no port is defined by the user, use the default value
+ $this->port == '' OR $this->port = 33000;
+ }
+ }
- return $conn;
+ /**
+ * Non-persistent database connection
+ *
+ * @return resource
+ */
+ public function db_connect()
+ {
+ return $this->_cubrid_connect();
}
// --------------------------------------------------------------------
/**
* Persistent database connection
+ *
* In CUBRID persistent DB connection is supported natively in CUBRID
* engine which can be configured in the CUBRID Broker configuration
* file by setting the CCI_PCONNECT parameter to ON. In that case, all
* connections established between the client application and the
- * server will become persistent. This is calling the same
- * @cubrid_connect function will establish persisten connection
- * considering that the CCI_PCONNECT is ON.
+ * server will become persistent.
*
- * @access private called by the base class
* @return resource
*/
- function db_pconnect()
+ public function db_pconnect()
{
- return $this->db_connect();
+ return $this->_cubrid_connect(TRUE);
}
// --------------------------------------------------------------------
/**
- * Reconnect
+ * CUBRID connection
*
- * Keep / reestablish the db connection if no queries have been
- * sent for a length of time exceeding the server's idle timeout
+ * A CUBRID-specific method to create a connection to the database.
+ * Except for determining if a persistent connection should be used,
+ * the rest of the logic is the same for db_connect() and db_pconnect().
*
- * @access public
- * @return void
+ * @param bool
+ * @return resource
*/
- function reconnect()
+ protected function _cubrid_connect($persistent = FALSE)
{
- if (cubrid_ping($this->conn_id) === FALSE)
+ if (preg_match('/^CUBRID:[^:]+(:[0-9][1-9]{0,4})?:[^:]+:([^:]*):([^:]*):(\?.+)?$/', $this->dsn, $matches))
{
- $this->conn_id = FALSE;
+ $_temp = ($persistent !== TRUE) ? 'cubrid_connect_with_url' : 'cubrid_pconnect_with_url';
+ $conn_id = ($matches[2] === '' && $matches[3] === '' && $this->username !== '' && $this->password !== '')
+ ? $_temp($this->dsn, $this->username, $this->password)
+ : $_temp($this->dsn);
}
+ else
+ {
+ $_temp = ($persistent !== TRUE) ? 'cubrid_connect' : 'cubrid_pconnect';
+ $conn_id = ($this->username !== '')
+ ? $_temp($this->hostname, $this->port, $this->database, $this->username, $this->password)
+ : $_temp($this->hostname, $this->port, $this->database);
+ }
+
+ return $conn_id;
}
// --------------------------------------------------------------------
/**
- * Select the database
+ * Reconnect
*
- * @access private called by the base class
- * @return resource
+ * Keep / reestablish the db connection if no queries have been
+ * sent for a length of time exceeding the server's idle timeout
+ *
+ * @return void
*/
- function db_select()
+ public function reconnect()
{
- // In CUBRID there is no need to select a database as the database
- // is chosen at the connection time.
- // So, to determine if the database is "selected", all we have to
- // do is ping the server and return that value.
- return cubrid_ping($this->conn_id);
+ if (cubrid_ping($this->conn_id) === FALSE)
+ {
+ $this->conn_id = FALSE;
+ }
}
// --------------------------------------------------------------------
@@ -172,42 +175,22 @@ class CI_DB_cubrid_driver extends CI_DB {
/**
* Execute the query
*
- * @access private called by the base class
* @param string an SQL query
* @return resource
*/
- function _execute($sql)
+ protected function _execute($sql)
{
- $sql = $this->_prep_query($sql);
return @cubrid_query($sql, $this->conn_id);
}
// --------------------------------------------------------------------
/**
- * Prep the query
- *
- * If needed, each database adapter can prep the query string
- *
- * @access private called by execute()
- * @param string an SQL query
- * @return string
- */
- function _prep_query($sql)
- {
- // No need to prepare
- return $sql;
- }
-
- // --------------------------------------------------------------------
-
- /**
* Begin Transaction
*
- * @access public
* @return bool
*/
- function trans_begin($test_mode = FALSE)
+ public function trans_begin($test_mode = FALSE)
{
if ( ! $this->trans_enabled)
{
@@ -238,10 +221,9 @@ class CI_DB_cubrid_driver extends CI_DB {
/**
* Commit Transaction
*
- * @access public
* @return bool
*/
- function trans_commit()
+ public function trans_commit()
{
if ( ! $this->trans_enabled)
{
@@ -269,10 +251,9 @@ class CI_DB_cubrid_driver extends CI_DB {
/**
* Rollback Transaction
*
- * @access public
* @return bool
*/
- function trans_rollback()
+ public function trans_rollback()
{
if ( ! $this->trans_enabled)
{
@@ -300,12 +281,11 @@ class CI_DB_cubrid_driver extends CI_DB {
/**
* Escape String
*
- * @access public
* @param string
* @param bool whether or not the string will be used in a LIKE condition
* @return string
*/
- function escape_str($str, $like = FALSE)
+ public function escape_str($str, $like = FALSE)
{
if (is_array($str))
{
@@ -352,10 +332,9 @@ class CI_DB_cubrid_driver extends CI_DB {
/**
* Insert ID
*
- * @access public
- * @return integer
+ * @return int
*/
- function insert_id()
+ public function insert_id()
{
return @cubrid_insert_id($this->conn_id);
}
@@ -368,11 +347,10 @@ class CI_DB_cubrid_driver extends CI_DB {
* Generates a platform-specific query string that counts all records in
* the specified table
*
- * @access public
* @param string
- * @return string
+ * @return int
*/
- function count_all($table = '')
+ public function count_all($table = '')
{
if ($table == '')
{
@@ -397,11 +375,10 @@ class CI_DB_cubrid_driver extends CI_DB {
*
* Generates a platform-specific query string so that the table names can be fetched
*
- * @access private
- * @param boolean
+ * @param bool
* @return string
*/
- function _list_tables($prefix_limit = FALSE)
+ protected function _list_tables($prefix_limit = FALSE)
{
$sql = "SHOW TABLES";
@@ -420,11 +397,10 @@ class CI_DB_cubrid_driver extends CI_DB {
*
* Generates a platform-specific query string so that the column names can be fetched
*
- * @access public
* @param string the table name
* @return string
*/
- function _list_columns($table = '')
+ protected function _list_columns($table = '')
{
return 'SHOW COLUMNS FROM '.$this->protect_identifiers($table, TRUE, NULL, FALSE);
}
@@ -436,11 +412,10 @@ class CI_DB_cubrid_driver extends CI_DB {
*
* Generates a platform-specific query so that the column data can be retrieved
*
- * @access public
* @param string the table name
- * @return object
+ * @return string
*/
- function _field_data($table)
+ protected function _field_data($table)
{
return "SELECT * FROM ".$table." LIMIT 1";
}
@@ -465,11 +440,10 @@ class CI_DB_cubrid_driver extends CI_DB {
*
* This function escapes column and table names
*
- * @access private
* @param string
* @return string
*/
- function _escape_identifiers($item)
+ public function _escape_identifiers($item)
{
if ($this->_escape_char == '')
{
@@ -508,11 +482,10 @@ class CI_DB_cubrid_driver extends CI_DB {
* This function implicitly groups FROM tables so there is no confusion
* about operator precedence in harmony with SQL standards
*
- * @access public
- * @param type
- * @return type
+ * @param array
+ * @return string
*/
- function _from_tables($tables)
+ protected function _from_tables($tables)
{
if ( ! is_array($tables))
{
@@ -529,13 +502,12 @@ class CI_DB_cubrid_driver extends CI_DB {
*
* Generates a platform-specific insert string from the supplied data
*
- * @access public
* @param string the table name
* @param array the insert keys
* @param array the insert values
* @return string
*/
- function _insert($table, $keys, $values)
+ protected function _insert($table, $keys, $values)
{
return "INSERT INTO ".$table." (\"".implode('", "', $keys)."\") VALUES (".implode(', ', $values).")";
}
@@ -548,13 +520,12 @@ class CI_DB_cubrid_driver extends CI_DB {
*
* Generates a platform-specific replace string from the supplied data
*
- * @access public
* @param string the table name
* @param array the insert keys
* @param array the insert values
* @return string
*/
- function _replace($table, $keys, $values)
+ protected function _replace($table, $keys, $values)
{
return "REPLACE INTO ".$table." (\"".implode('", "', $keys)."\") VALUES (".implode(', ', $values).")";
}
@@ -566,13 +537,12 @@ class CI_DB_cubrid_driver extends CI_DB {
*
* Generates a platform-specific insert string from the supplied data
*
- * @access public
* @param string the table name
* @param array the insert keys
* @param array the insert values
* @return string
*/
- function _insert_batch($table, $keys, $values)
+ protected function _insert_batch($table, $keys, $values)
{
return "INSERT INTO ".$table." (\"".implode('", "', $keys)."\") VALUES ".implode(', ', $values);
}
@@ -585,7 +555,6 @@ class CI_DB_cubrid_driver extends CI_DB {
*
* Generates a platform-specific update string from the supplied data
*
- * @access public
* @param string the table name
* @param array the update data
* @param array the where clause
@@ -593,7 +562,7 @@ class CI_DB_cubrid_driver extends CI_DB {
* @param array the limit clause
* @return string
*/
- function _update($table, $values, $where, $orderby = array(), $limit = FALSE)
+ protected function _update($table, $values, $where, $orderby = array(), $limit = FALSE)
{
foreach ($values as $key => $val)
{
@@ -621,13 +590,12 @@ class CI_DB_cubrid_driver extends CI_DB {
*
* Generates a platform-specific batch update string from the supplied data
*
- * @access public
* @param string the table name
* @param array the update data
* @param array the where clause
* @return string
*/
- function _update_batch($table, $values, $index, $where = NULL)
+ protected function _update_batch($table, $values, $index, $where = NULL)
{
$ids = array();
$where = ($where != '' AND count($where) >=1) ? implode(" ", $where).' AND ' : '';
@@ -668,7 +636,6 @@ class CI_DB_cubrid_driver extends CI_DB {
// --------------------------------------------------------------------
-
/**
* Truncate statement
*
@@ -676,11 +643,10 @@ class CI_DB_cubrid_driver extends CI_DB {
* If the database does not support the truncate() command
* This function maps to "DELETE FROM table"
*
- * @access public
* @param string the table name
* @return string
*/
- function _truncate($table)
+ protected function _truncate($table)
{
return "TRUNCATE ".$table;
}
@@ -692,13 +658,12 @@ class CI_DB_cubrid_driver extends CI_DB {
*
* Generates a platform-specific delete string from the supplied data
*
- * @access public
* @param string the table name
* @param array the where clause
* @param string the limit clause
* @return string
*/
- function _delete($table, $where = array(), $like = array(), $limit = FALSE)
+ protected function _delete($table, $where = array(), $like = array(), $limit = FALSE)
{
$conditions = '';
@@ -726,13 +691,12 @@ class CI_DB_cubrid_driver extends CI_DB {
*
* Generates a platform-specific LIMIT clause
*
- * @access public
* @param string the sql query string
- * @param integer the number of rows to limit the query to
- * @param integer the offset value
+ * @param int the number of rows to limit the query to
+ * @param int the offset value
* @return string
*/
- function _limit($sql, $limit, $offset)
+ protected function _limit($sql, $limit, $offset)
{
if ($offset == 0)
{
@@ -751,17 +715,15 @@ class CI_DB_cubrid_driver extends CI_DB {
/**
* Close DB Connection
*
- * @access public
* @param resource
* @return void
*/
- function _close($conn_id)
+ protected function _close($conn_id)
{
@cubrid_close($conn_id);
}
}
-
/* End of file cubrid_driver.php */
-/* Location: ./system/database/drivers/cubrid/cubrid_driver.php */
+/* Location: ./system/database/drivers/cubrid/cubrid_driver.php */ \ No newline at end of file
diff --git a/system/database/drivers/cubrid/cubrid_forge.php b/system/database/drivers/cubrid/cubrid_forge.php
index 7d606ea36..bbda484c4 100644
--- a/system/database/drivers/cubrid/cubrid_forge.php
+++ b/system/database/drivers/cubrid/cubrid_forge.php
@@ -1,13 +1,13 @@
-<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
* An open source application development framework for PHP 5.2.4 or newer
*
* NOTICE OF LICENSE
- *
+ *
* Licensed under the Open Software License version 3.0
- *
+ *
* This source file is subject to the Open Software License (OSL 3.0) that is
* bundled with this package in the files license.txt / license.rst. It is
* also available through the world wide web at this URL:
@@ -25,8 +25,6 @@
* @filesource
*/
-// ------------------------------------------------------------------------
-
/**
* CUBRID Forge Class
*
@@ -39,11 +37,10 @@ class CI_DB_cubrid_forge extends CI_DB_forge {
/**
* Create database
*
- * @access private
* @param string the database name
* @return bool
*/
- function _create_database($name)
+ public function _create_database($name)
{
// CUBRID does not allow to create a database in SQL. The GUI tools
// have to be used for this purpose.
@@ -55,11 +52,10 @@ class CI_DB_cubrid_forge extends CI_DB_forge {
/**
* Drop database
*
- * @access private
* @param string the database name
* @return bool
*/
- function _drop_database($name)
+ public function _drop_database($name)
{
// CUBRID does not allow to drop a database in SQL. The GUI tools
// have to be used for this purpose.
@@ -71,16 +67,15 @@ class CI_DB_cubrid_forge extends CI_DB_forge {
/**
* Process Fields
*
- * @access private
* @param mixed the fields
* @return string
*/
- function _process_fields($fields)
+ protected function _process_fields($fields)
{
$current_field_count = 0;
$sql = '';
- foreach ($fields as $field=>$attributes)
+ foreach ($fields as $field => $attributes)
{
// Numeric field names aren't allowed in databases, so if the key is
// numeric, we know it was assigned by PHP and the developer manually
@@ -172,15 +167,14 @@ class CI_DB_cubrid_forge extends CI_DB_forge {
/**
* Create Table
*
- * @access private
* @param string the table name
* @param mixed the fields
* @param mixed primary key(s)
* @param mixed key(s)
- * @param boolean should 'IF NOT EXISTS' be added to the SQL
+ * @param bool should 'IF NOT EXISTS' be added to the SQL
* @return bool
*/
- function _create_table($table, $fields, $primary_keys, $keys, $if_not_exists)
+ public function _create_table($table, $fields, $primary_keys, $keys, $if_not_exists)
{
$sql = 'CREATE TABLE ';
@@ -232,10 +226,9 @@ class CI_DB_cubrid_forge extends CI_DB_forge {
/**
* Drop Table
*
- * @access private
* @return string
*/
- function _drop_table($table)
+ public function _drop_table($table)
{
return "DROP TABLE IF EXISTS ".$this->db->_escape_identifiers($table);
}
@@ -248,14 +241,13 @@ class CI_DB_cubrid_forge extends CI_DB_forge {
* Generates a platform-specific query so that a table can be altered
* Called by add_column(), drop_column(), and column_alter(),
*
- * @access private
* @param string the ALTER type (ADD, DROP, CHANGE)
* @param string the column name
* @param array fields
* @param string the field after which we should add the new field
- * @return object
+ * @return string
*/
- function _alter_table($alter_type, $table, $fields, $after_field = '')
+ public function _alter_table($alter_type, $table, $fields, $after_field = '')
{
$sql = 'ALTER TABLE '.$this->db->protect_identifiers($table).' '.$alter_type.' ';
@@ -282,12 +274,11 @@ class CI_DB_cubrid_forge extends CI_DB_forge {
*
* Generates a platform-specific query so that a table can be renamed
*
- * @access private
* @param string the old table name
* @param string the new table name
* @return string
*/
- function _rename_table($table_name, $new_table_name)
+ public function _rename_table($table_name, $new_table_name)
{
return 'RENAME TABLE '.$this->db->protect_identifiers($table_name).' AS '.$this->db->protect_identifiers($new_table_name);
}
@@ -295,4 +286,4 @@ class CI_DB_cubrid_forge extends CI_DB_forge {
}
/* End of file cubrid_forge.php */
-/* Location: ./system/database/drivers/cubrid/cubrid_forge.php */
+/* Location: ./system/database/drivers/cubrid/cubrid_forge.php */ \ No newline at end of file
diff --git a/system/database/drivers/cubrid/cubrid_result.php b/system/database/drivers/cubrid/cubrid_result.php
index a7eeb8a39..6a61a213d 100644
--- a/system/database/drivers/cubrid/cubrid_result.php
+++ b/system/database/drivers/cubrid/cubrid_result.php
@@ -1,13 +1,13 @@
-<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
* An open source application development framework for PHP 5.2.4 or newer
*
* NOTICE OF LICENSE
- *
+ *
* Licensed under the Open Software License version 3.0
- *
+ *
* This source file is subject to the Open Software License (OSL 3.0) that is
* bundled with this package in the files license.txt / license.rst. It is
* also available through the world wide web at this URL:
@@ -25,8 +25,6 @@
* @filesource
*/
-// --------------------------------------------------------------------
-
/**
* CUBRID Result Class
*
@@ -41,10 +39,9 @@ class CI_DB_cubrid_result extends CI_DB_result {
/**
* Number of rows in the result set
*
- * @access public
- * @return integer
+ * @return int
*/
- function num_rows()
+ public function num_rows()
{
return @cubrid_num_rows($this->result_id);
}
@@ -54,10 +51,9 @@ class CI_DB_cubrid_result extends CI_DB_result {
/**
* Number of fields in the result set
*
- * @access public
- * @return integer
+ * @return int
*/
- function num_fields()
+ public function num_fields()
{
return @cubrid_num_fields($this->result_id);
}
@@ -69,10 +65,9 @@ class CI_DB_cubrid_result extends CI_DB_result {
*
* Generates an array of column names
*
- * @access public
* @return array
*/
- function list_fields()
+ public function list_fields()
{
return cubrid_column_names($this->result_id);
}
@@ -84,10 +79,9 @@ class CI_DB_cubrid_result extends CI_DB_result {
*
* Generates an array of objects containing field meta-data
*
- * @access public
* @return array
*/
- function field_data()
+ public function field_data()
{
$retval = array();
@@ -147,9 +141,9 @@ class CI_DB_cubrid_result extends CI_DB_result {
/**
* Free the result
*
- * @return null
+ * @return void
*/
- function free_result()
+ public function free_result()
{
if(is_resource($this->result_id) ||
get_resource_type($this->result_id) == "Unknown" &&
@@ -169,10 +163,9 @@ class CI_DB_cubrid_result extends CI_DB_result {
* this internally before fetching results to make sure the
* result set starts at zero
*
- * @access private
* @return array
*/
- function _data_seek($n = 0)
+ protected function _data_seek($n = 0)
{
return cubrid_data_seek($this->result_id, $n);
}
@@ -184,10 +177,9 @@ class CI_DB_cubrid_result extends CI_DB_result {
*
* Returns the result set as an array
*
- * @access private
* @return array
*/
- function _fetch_assoc()
+ protected function _fetch_assoc()
{
return cubrid_fetch_assoc($this->result_id);
}
@@ -199,16 +191,14 @@ class CI_DB_cubrid_result extends CI_DB_result {
*
* Returns the result set as an object
*
- * @access private
* @return object
*/
- function _fetch_object()
+ protected function _fetch_object()
{
return cubrid_fetch_object($this->result_id);
}
}
-
/* End of file cubrid_result.php */
/* Location: ./system/database/drivers/cubrid/cubrid_result.php */ \ No newline at end of file
diff --git a/system/database/drivers/cubrid/cubrid_utility.php b/system/database/drivers/cubrid/cubrid_utility.php
index a13c0a5e4..dafd66146 100644
--- a/system/database/drivers/cubrid/cubrid_utility.php
+++ b/system/database/drivers/cubrid/cubrid_utility.php
@@ -1,13 +1,13 @@
-<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
* An open source application development framework for PHP 5.2.4 or newer
*
* NOTICE OF LICENSE
- *
+ *
* Licensed under the Open Software License version 3.0
- *
+ *
* This source file is subject to the Open Software License (OSL 3.0) that is
* bundled with this package in the files license.txt / license.rst. It is
* also available through the world wide web at this URL:
@@ -25,8 +25,6 @@
* @filesource
*/
-// ------------------------------------------------------------------------
-
/**
* CUBRID Utility Class
*
@@ -39,10 +37,9 @@ class CI_DB_cubrid_utility extends CI_DB_utility {
/**
* List databases
*
- * @access private
* @return array
*/
- function _list_databases()
+ public function _list_databases()
{
// CUBRID does not allow to see the list of all databases on the
// server. It is the way its architecture is designed. Every
@@ -66,12 +63,11 @@ class CI_DB_cubrid_utility extends CI_DB_utility {
*
* Generates a platform-specific query so that a table can be optimized
*
- * @access private
* @param string the table name
- * @return object
+ * @return bool
* @link http://www.cubrid.org/manual/840/en/Optimize%20Database
*/
- function _optimize_table($table)
+ public function _optimize_table($table)
{
// No SQL based support in CUBRID as of version 8.4.0. Database or
// table optimization can be performed using CUBRID Manager
@@ -86,12 +82,11 @@ class CI_DB_cubrid_utility extends CI_DB_utility {
*
* Generates a platform-specific query so that a table can be repaired
*
- * @access private
* @param string the table name
- * @return object
+ * @return bool
* @link http://www.cubrid.org/manual/840/en/Checking%20Database%20Consistency
*/
- function _repair_table($table)
+ public function _repair_table($table)
{
// Not supported in CUBRID as of version 8.4.0. Database or
// table consistency can be checked using CUBRID Manager
@@ -103,11 +98,10 @@ class CI_DB_cubrid_utility extends CI_DB_utility {
/**
* CUBRID Export
*
- * @access private
* @param array Preferences
* @return mixed
*/
- function _backup($params = array())
+ public function _backup($params = array())
{
// No SQL based support in CUBRID as of version 8.4.0. Database or
// table backup can be performed using CUBRID Manager
diff --git a/system/database/drivers/interbase/interbase_driver.php b/system/database/drivers/interbase/interbase_driver.php
index a9a647202..6d3346292 100644
--- a/system/database/drivers/interbase/interbase_driver.php
+++ b/system/database/drivers/interbase/interbase_driver.php
@@ -25,8 +25,6 @@
* @filesource
*/
-// ------------------------------------------------------------------------
-
/**
* Firebird/Interbase Database Adapter Class
*
@@ -56,8 +54,8 @@ class CI_DB_interbase_driver extends CI_DB {
* database engines, so this string appears in each driver and is
* used for the count_all() and count_all_results() functions.
*/
- protected $_count_string = "SELECT COUNT(*) AS ";
- protected $_random_keyword = ' Random()'; // database specific random keyword
+ protected $_count_string = 'SELECT COUNT(*) AS ';
+ protected $_random_keyword = ' Random()'; // database specific random keyword
// Keeps track of the resource for the current transaction
protected $trans;
@@ -87,34 +85,6 @@ class CI_DB_interbase_driver extends CI_DB {
// --------------------------------------------------------------------
/**
- * Reconnect
- *
- * Keep / reestablish the db connection if no queries have been
- * sent for a length of time exceeding the server's idle timeout
- *
- * @return void
- */
- public function reconnect()
- {
- // not implemented in Interbase/Firebird
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Select the database
- *
- * @return bool
- */
- public function db_select()
- {
- // Connection selects the database
- return TRUE;
- }
-
- // --------------------------------------------------------------------
-
- /**
* Database version number
*
* @return string
@@ -148,41 +118,20 @@ class CI_DB_interbase_driver extends CI_DB {
*/
protected function _execute($sql)
{
- $sql = $this->_prep_query($sql);
return @ibase_query($this->conn_id, $sql);
}
// --------------------------------------------------------------------
/**
- * Prep the query
- *
- * If needed, each database adapter can prep the query string
- *
- * @param string an SQL query
- * @return string
- */
- protected function _prep_query($sql)
- {
- return $sql;
- }
-
- // --------------------------------------------------------------------
-
- /**
* Begin Transaction
*
* @return bool
*/
public function trans_begin($test_mode = FALSE)
{
- if ( ! $this->trans_enabled)
- {
- return TRUE;
- }
-
// When transactions are nested we only begin/commit/rollback the outermost ones
- if ($this->_trans_depth > 0)
+ if ( ! $this->trans_enabled OR $this->_trans_depth > 0)
{
return TRUE;
}
@@ -190,7 +139,7 @@ class CI_DB_interbase_driver extends CI_DB {
// Reset the transaction failure flag.
// If the $test_mode flag is set to TRUE transactions will be rolled back
// even if the queries produce a successful result.
- $this->_trans_failure = ($test_mode === TRUE) ? TRUE : FALSE;
+ $this->_trans_failure = ($test_mode === TRUE);
$this->trans = @ibase_trans($this->conn_id);
@@ -206,13 +155,8 @@ class CI_DB_interbase_driver extends CI_DB {
*/
public function trans_commit()
{
- if ( ! $this->trans_enabled)
- {
- return TRUE;
- }
-
// When transactions are nested we only begin/commit/rollback the outermost ones
- if ($this->_trans_depth > 0)
+ if ( ! $this->trans_enabled OR $this->_trans->depth > 0)
{
return TRUE;
}
@@ -229,13 +173,8 @@ class CI_DB_interbase_driver extends CI_DB {
*/
public function trans_rollback()
{
- if ( ! $this->trans_enabled)
- {
- return TRUE;
- }
-
// When transactions are nested we only begin/commit/rollback the outermost ones
- if ($this->_trans_depth > 0)
+ if ( ! $this->trans_enabled OR $this->_trans_depth > 0)
{
return TRUE;
}
@@ -267,9 +206,9 @@ class CI_DB_interbase_driver extends CI_DB {
// escape LIKE condition wildcards
if ($like === TRUE)
{
- $str = str_replace( array('%', '_', $this->_like_escape_chr),
- array($this->_like_escape_chr.'%', $this->_like_escape_chr.'_', $this->_like_escape_chr.$this->_like_escape_chr),
- $str);
+ return str_replace(array($this->_like_escape_chr, '%', '_'),
+ array($this->_like_escape_chr.$this->_like_escape_chr, $this->_like_escape_chr.'%', $this->_like_escape_chr.'_'),
+ $str);
}
return $str;
@@ -280,7 +219,7 @@ class CI_DB_interbase_driver extends CI_DB {
/**
* Affected Rows
*
- * @return integer
+ * @return int
*/
public function affected_rows()
{
@@ -292,9 +231,9 @@ class CI_DB_interbase_driver extends CI_DB {
/**
* Insert ID
*
- * @param string $generator_name
- * @param integer $inc_by
- * @return integer
+ * @param string $generator_name
+ * @param int $inc_by
+ * @return int
*/
public function insert_id($generator_name, $inc_by=0)
{
@@ -326,9 +265,9 @@ class CI_DB_interbase_driver extends CI_DB {
return 0;
}
- $row = $query->row();
+ $query = $query->row();
$this->_reset_select();
- return (int) $row->numrows;
+ return (int) $query->numrows;
}
// --------------------------------------------------------------------
@@ -338,21 +277,18 @@ class CI_DB_interbase_driver extends CI_DB {
*
* Generates a platform-specific query string so that the table names can be fetched
*
- * @param boolean
+ * @param bool
* @return string
*/
protected function _list_tables($prefix_limit = FALSE)
{
- $sql = <<<SQL
- SELECT "RDB\$RELATION_NAME" FROM "RDB\$RELATIONS"
- WHERE "RDB\$RELATION_NAME" NOT LIKE 'RDB$%'
- AND "RDB\$RELATION_NAME" NOT LIKE 'MON$%'
-SQL;
+ $sql = 'SELECT "RDB$RELATION_NAME" FROM "RDB$RELATIONS" WHERE "RDB$RELATION_NAME" NOT LIKE \'RDB$%\' AND "RDB$RELATION_NAME" NOT LIKE \'MON$%\'';
- if ($prefix_limit !== FALSE AND $this->dbprefix != '')
+ if ($prefix_limit !== FALSE && $this->dbprefix != '')
{
- $sql .= ' AND "RDB$RELATION_NAME" LIKE \''.$this->escape_like_str($this->dbprefix)."%' ".sprintf($this->_like_escape_str, $this->_like_escape_chr);
+ return $sql.' AND "RDB$RELATION_NAME" LIKE \''.$this->escape_like_str($this->dbprefix)."%' ".sprintf($this->_like_escape_str, $this->_like_escape_chr);
}
+
return $sql;
}
@@ -368,10 +304,7 @@ SQL;
*/
protected function _list_columns($table = '')
{
- return <<<SQL
- SELECT "RDB\$FIELD_NAME" FROM "RDB\$RELATION_FIELDS"
- WHERE "RDB\$RELATION_NAME"='{$table}';
-SQL;
+ return 'SELECT "RDB$FIELD_NAME" FROM "RDB$RELATION_FIELDS" WHERE "RDB$RELATION_NAME" = \''.$this->escape_str($table)."'";
}
// --------------------------------------------------------------------
@@ -382,14 +315,14 @@ SQL;
* Generates a platform-specific query so that the column data can be retrieved
*
* @param string the table name
- * @return object
+ * @return string
*/
protected function _field_data($table)
{
// Need to find a more efficient way to do this
// but Interbase/Firebird seems to lack the
// limit clause
- return "SELECT * FROM {$table}";
+ return 'SELECT * FROM '.$table;
}
// --------------------------------------------------------------------
@@ -423,24 +356,20 @@ SQL;
{
if (strpos($item, '.'.$id) !== FALSE)
{
- $str = $this->_escape_char. str_replace('.', $this->_escape_char.'.', $item);
+ $item = str_replace('.', $this->_escape_char.'.', $item);
// remove duplicates if the user already included the escape
- return preg_replace('/['.$this->_escape_char.']+/', $this->_escape_char, $str);
+ return preg_replace('/['.$this->_escape_char.']+/', $this->_escape_char, $this->_escape_char.$item);
}
}
if (strpos($item, '.') !== FALSE)
{
- $str = $this->_escape_char.str_replace('.', $this->_escape_char.'.'.$this->_escape_char, $item).$this->_escape_char;
- }
- else
- {
- $str = $this->_escape_char.$item.$this->_escape_char;
+ $item = str_replace('.', $this->_escape_char.'.'.$this->_escape_char, $item);
}
// remove duplicates if the user already included the escape
- return preg_replace('/['.$this->_escape_char.']+/', $this->_escape_char, $str);
+ return preg_replace('/['.$this->_escape_char.']+/', $this->_escape_char, $this->_escape_char.$item.$this->_escape_char);
}
// --------------------------------------------------------------------
@@ -451,8 +380,8 @@ SQL;
* This public function implicitly groups FROM tables so there is no confusion
* about operator precedence in harmony with SQL standards
*
- * @param type
- * @return type
+ * @param array
+ * @return string
*/
protected function _from_tables($tables)
{
@@ -479,7 +408,7 @@ SQL;
*/
protected function _insert($table, $keys, $values)
{
- return "INSERT INTO {$table} (".implode(', ', $keys).') VALUES ('.implode(', ', $values).')';
+ return 'INSERT INTO '.$table.' ('.implode(', ', $keys).') VALUES ('.implode(', ', $values).')';
}
// --------------------------------------------------------------------
@@ -500,20 +429,14 @@ SQL;
{
foreach ($values as $key => $val)
{
- $valstr[] = $key." = ".$val;
+ $valstr[] = $key.' = '.$val;
}
//$limit = ( ! $limit) ? '' : ' LIMIT '.$limit;
- $orderby = (count($orderby) >= 1)?' ORDER BY '.implode(", ", $orderby):'';
-
- $sql = "UPDATE {$table} SET ".implode(', ', $valstr);
-
- $sql .= ($where != '' AND count($where) >=1) ? ' WHERE '.implode(' ', $where) : '';
-
- $sql .= $orderby;
-
- return $sql;
+ return 'UPDATE '.$table.' SET '.implode(', ', $valstr)
+ .(($where != '' && count($where) > 0) ? ' WHERE '.implode(' ', $where) : '')
+ .(count($orderby) > 0 ? ' ORDER BY '.implode(', ', $orderby) : '');
}
@@ -548,23 +471,20 @@ SQL;
*/
protected function _delete($table, $where = array(), $like = array(), $limit = FALSE)
{
- $conditions = '';
-
if (count($where) > 0 OR count($like) > 0)
{
- $conditions = "\nWHERE ";
- $conditions .= implode("\n", $this->ar_where);
-
- if (count($where) > 0 && count($like) > 0)
- {
- $conditions .= ' AND ';
- }
- $conditions .= implode("\n", $like);
+ $conditions = "\nWHERE ".implode("\n", $where)
+ .((count($where) > 0 && count($like) > 0) ? ' AND ' : '')
+ .implode("\n", $like);
+ }
+ else
+ {
+ $conditions = '';
}
//$limit = ( ! $limit) ? '' : ' LIMIT '.$limit;
- return "DELETE FROM {$table}{$conditions}";
+ return 'DELETE FROM '.$table.' '.$conditions;
}
// --------------------------------------------------------------------
@@ -575,36 +495,25 @@ SQL;
* Generates a platform-specific LIMIT clause
*
* @param string the sql query string
- * @param integer the number of rows to limit the query to
- * @param integer the offset value
+ * @param int the number of rows to limit the query to
+ * @param int the offset value
* @return string
*/
protected function _limit($sql, $limit, $offset)
{
- // Keep the current sql string safe for a moment
- $orig_sql = $sql;
-
// Limit clause depends on if Interbase or Firebird
if (stripos($this->version(), 'firebird') !== FALSE)
{
- $sql = 'FIRST '. (int) $limit;
-
- if ($offset > 0)
- {
- $sql .= ' SKIP '. (int) $offset;
- }
+ $select = 'FIRST '. (int) $limit
+ .($offset > 0 ? ' SKIP '. (int) $offset : '');
}
else
{
- $sql = 'ROWS ' . (int) $limit;
-
- if ($offset > 0)
- {
- $sql = 'ROWS '. (int) $offset . ' TO ' . ($limit + $offset);
- }
+ $select = 'ROWS '
+ .($offset > 0 ? (int) $offset.' TO '.($limit + $offset) : (int) $limit);
}
- return preg_replace('`SELECT`i', "SELECT {$sql}", $orig_sql);
+ return preg_replace('`SELECT`i', 'SELECT '.$select, $sql);
}
// --------------------------------------------------------------------
@@ -623,4 +532,4 @@ SQL;
}
/* End of file interbase_driver.php */
-/* Location: ./system/database/drivers/interbase/interbase_driver.php */
+/* Location: ./system/database/drivers/interbase/interbase_driver.php */ \ No newline at end of file
diff --git a/system/database/drivers/interbase/interbase_result.php b/system/database/drivers/interbase/interbase_result.php
index 5bf0c902d..fd4178dec 100644
--- a/system/database/drivers/interbase/interbase_result.php
+++ b/system/database/drivers/interbase/interbase_result.php
@@ -25,8 +25,6 @@
* @filesource
*/
-// ------------------------------------------------------------------------
-
/**
* Interbase/Firebird Result Class
*
@@ -43,18 +41,18 @@ class CI_DB_interbase_result extends CI_DB_result {
/**
* Number of rows in the result set
*
- * @return integer
+ * @return int
*/
public function num_rows()
{
- if( ! is_null($this->num_rows))
+ if (is_int($this->num_rows))
{
return $this->num_rows;
}
-
- //Get the results so that you can get an accurate rowcount
+
+ // Get the results so that you can get an accurate rowcount
$this->result();
-
+
return $this->num_rows;
}
@@ -63,7 +61,7 @@ class CI_DB_interbase_result extends CI_DB_result {
/**
* Number of fields in the result set
*
- * @return integer
+ * @return int
*/
public function num_fields()
{
@@ -102,20 +100,17 @@ class CI_DB_interbase_result extends CI_DB_result {
*/
public function field_data()
{
-
$retval = array();
- for ($i = 0, $num_fields = $this->num_fields(); $i < $num_fields; $i++)
+ for ($i = 0, $c = $this->num_fields(); $i < $c; $i++)
{
$info = ibase_field_info($this->result_id, $i);
-
- $F = new stdClass();
- $F->name = $info['name'];
- $F->type = $info['type'];
- $F->max_length = $info['length'];
- $F->primary_key = 0;
- $F->default = '';
-
- $retval[] = $F;
+
+ $retval[$i] = new stdClass();
+ $retval[$i]->name = $info['name'];
+ $retval[$i]->type = $info['type'];
+ $retval[$i]->max_length = $info['length'];
+ $retval[$i]->primary_key = 0;
+ $retval[$i]->default = '';
}
return $retval;
@@ -126,7 +121,7 @@ class CI_DB_interbase_result extends CI_DB_result {
/**
* Free the result
*
- * @return null
+ * @return void
*/
public function free_result()
{
@@ -138,7 +133,7 @@ class CI_DB_interbase_result extends CI_DB_result {
/**
* Data Seek
*
- * Moves the internal pointer to the desired offset. We call
+ * Moves the internal pointer to the desired offset. We call
* this internally before fetching results to make sure the
* result set starts at zero
*
@@ -146,11 +141,8 @@ class CI_DB_interbase_result extends CI_DB_result {
*/
protected function _data_seek($n = 0)
{
- //Set the row count to 0
- $this->num_rows = 0;
-
- //Interbase driver doesn't implement a suitable function
- return FALSE;
+ // Interbase driver doesn't implement a suitable function
+ return FALSE;
}
// --------------------------------------------------------------------
@@ -169,7 +161,7 @@ class CI_DB_interbase_result extends CI_DB_result {
//Increment row count
$this->num_rows++;
}
-
+
return $row;
}
@@ -189,10 +181,10 @@ class CI_DB_interbase_result extends CI_DB_result {
//Increment row count
$this->num_rows++;
}
-
+
return $row;
}
-
+
// --------------------------------------------------------------------
/**
@@ -202,29 +194,20 @@ class CI_DB_interbase_result extends CI_DB_result {
*/
public function result_object()
{
- if (count($this->result_object) > 0)
+ if (count($this->result_object) === $this->num_rows)
{
return $this->result_object;
}
-
- // Convert result array to object so that
+
+ // Convert result array to object so that
// We don't have to get the result again
- if (count($this->result_array) > 0)
+ if (($c = count($this->result_array)) > 0)
{
- $i = 0;
-
- foreach ($this->result_array as $array)
+ for ($i = 0; $i < $c; $i++)
{
- $this->result_object[$i] = new StdClass();
-
- foreach ($array as $key => $val)
- {
- $this->result_object[$i]->{$key} = $val;
- }
-
- ++$i;
+ $this->result_object[$i] = (object) $this->result_array[$i];
}
-
+
return $this->result_object;
}
@@ -254,20 +237,20 @@ class CI_DB_interbase_result extends CI_DB_result {
*/
public function result_array()
{
- if (count($this->result_array) > 0)
+ if (count($this->result_array) === $this->num_rows)
{
return $this->result_array;
}
-
+
// Since the object and array are really similar, just case
// the result object to an array if need be
- if (count($this->result_object) > 0)
+ if (($c = count($this->result_object)) > 0)
{
- foreach ($this->result_object as $obj)
+ for ($i = 0; $i < $c; $i++)
{
- $this->result_array[] = (array) $obj;
+ $this->result_array[$i] = (array) $this->result_object[$i];
}
-
+
return $this->result_array;
}
diff --git a/system/database/drivers/mssql/mssql_driver.php b/system/database/drivers/mssql/mssql_driver.php
index b6b64cc44..81af6cd72 100644
--- a/system/database/drivers/mssql/mssql_driver.php
+++ b/system/database/drivers/mssql/mssql_driver.php
@@ -1,13 +1,13 @@
-<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
* An open source application development framework for PHP 5.2.4 or newer
*
* NOTICE OF LICENSE
- *
+ *
* Licensed under the Open Software License version 3.0
- *
+ *
* This source file is subject to the Open Software License (OSL 3.0) that is
* bundled with this package in the files license.txt / license.rst. It is
* also available through the world wide web at this URL:
@@ -25,8 +25,6 @@
* @filesource
*/
-// ------------------------------------------------------------------------
-
/**
* MS SQL Database Adapter Class
*
@@ -42,30 +40,29 @@
*/
class CI_DB_mssql_driver extends CI_DB {
- var $dbdriver = 'mssql';
+ public $dbdriver = 'mssql';
// The character used for escaping
- var $_escape_char = '';
+ protected $_escape_char = '';
// clause and character used for LIKE escape sequences
- var $_like_escape_str = " ESCAPE '%s' ";
- var $_like_escape_chr = '!';
+ protected $_like_escape_str = " ESCAPE '%s' ";
+ protected $_like_escape_chr = '!';
/**
* The syntax to count rows is slightly different across different
* database engines, so this string appears in each driver and is
- * used for the count_all() and count_all_results() functions.
+ * used for the count_all() and count_all_results() methods.
*/
- var $_count_string = "SELECT COUNT(*) AS ";
- var $_random_keyword = ' ASC'; // not currently supported
+ protected $_count_string = 'SELECT COUNT(*) AS ';
+ protected $_random_keyword = ' NEWID()';
/**
* Non-persistent database connection
*
- * @access private called by the base class
* @return resource
*/
- function db_connect()
+ public function db_connect()
{
if ($this->port != '')
{
@@ -80,10 +77,9 @@ class CI_DB_mssql_driver extends CI_DB {
/**
* Persistent database connection
*
- * @access private called by the base class
* @return resource
*/
- function db_pconnect()
+ public function db_pconnect()
{
if ($this->port != '')
{
@@ -96,22 +92,6 @@ class CI_DB_mssql_driver extends CI_DB {
// --------------------------------------------------------------------
/**
- * Reconnect
- *
- * Keep / reestablish the db connection if no queries have been
- * sent for a length of time exceeding the server's idle timeout
- *
- * @access public
- * @return void
- */
- function reconnect()
- {
- // not implemented in MSSQL
- }
-
- // --------------------------------------------------------------------
-
- /**
* Select the database
*
* @param string database name
@@ -140,41 +120,22 @@ class CI_DB_mssql_driver extends CI_DB {
/**
* Execute the query
*
- * @access private called by the base class
* @param string an SQL query
* @return resource
*/
- function _execute($sql)
+ protected function _execute($sql)
{
- $sql = $this->_prep_query($sql);
return @mssql_query($sql, $this->conn_id);
}
// --------------------------------------------------------------------
/**
- * Prep the query
- *
- * If needed, each database adapter can prep the query string
- *
- * @access private called by execute()
- * @param string an SQL query
- * @return string
- */
- function _prep_query($sql)
- {
- return $sql;
- }
-
- // --------------------------------------------------------------------
-
- /**
* Begin Transaction
*
- * @access public
* @return bool
*/
- function trans_begin($test_mode = FALSE)
+ public function trans_begin($test_mode = FALSE)
{
if ( ! $this->trans_enabled)
{
@@ -201,10 +162,9 @@ class CI_DB_mssql_driver extends CI_DB {
/**
* Commit Transaction
*
- * @access public
* @return bool
*/
- function trans_commit()
+ public function trans_commit()
{
if ( ! $this->trans_enabled)
{
@@ -226,10 +186,9 @@ class CI_DB_mssql_driver extends CI_DB {
/**
* Rollback Transaction
*
- * @access public
* @return bool
*/
- function trans_rollback()
+ public function trans_rollback()
{
if ( ! $this->trans_enabled)
{
@@ -251,12 +210,11 @@ class CI_DB_mssql_driver extends CI_DB {
/**
* Escape String
*
- * @access public
* @param string
* @param bool whether or not the string will be used in a LIKE condition
* @return string
*/
- function escape_str($str, $like = FALSE)
+ public function escape_str($str, $like = FALSE)
{
if (is_array($str))
{
@@ -289,10 +247,9 @@ class CI_DB_mssql_driver extends CI_DB {
/**
* Affected Rows
*
- * @access public
- * @return integer
+ * @return int
*/
- function affected_rows()
+ public function affected_rows()
{
return @mssql_rows_affected($this->conn_id);
}
@@ -300,14 +257,13 @@ class CI_DB_mssql_driver extends CI_DB {
// --------------------------------------------------------------------
/**
- * Insert ID
- *
- * Returns the last id created in the Identity column.
- *
- * @access public
- * @return integer
- */
- function insert_id()
+ * Insert ID
+ *
+ * Returns the last id created in the Identity column.
+ *
+ * @return string
+ */
+ public function insert_id()
{
$ver = self::_parse_major_version($this->version());
$sql = ($ver >= 8 ? "SELECT SCOPE_IDENTITY() AS last_id" : "SELECT @@IDENTITY AS last_id");
@@ -319,16 +275,15 @@ class CI_DB_mssql_driver extends CI_DB {
// --------------------------------------------------------------------
/**
- * Parse major version
- *
- * Grabs the major version number from the
- * database server version string passed in.
- *
- * @access private
- * @param string $version
- * @return int16 major version number
- */
- function _parse_major_version($version)
+ * Parse major version
+ *
+ * Grabs the major version number from the
+ * database server version string passed in.
+ *
+ * @param string $version
+ * @return int major version number
+ */
+ protected function _parse_major_version($version)
{
preg_match('/([0-9]+)\.([0-9]+)\.([0-9]+)/', $version, $ver_info);
return $ver_info[1]; // return the major version b/c that's all we're interested in.
@@ -337,10 +292,10 @@ class CI_DB_mssql_driver extends CI_DB {
// --------------------------------------------------------------------
/**
- * Version number query string
- *
- * @return string
- */
+ * Version number query string
+ *
+ * @return string
+ */
protected function _version()
{
return 'SELECT @@VERSION AS ver';
@@ -354,11 +309,10 @@ class CI_DB_mssql_driver extends CI_DB {
* Generates a platform-specific query string that counts all records in
* the specified database
*
- * @access public
* @param string
* @return string
*/
- function count_all($table = '')
+ public function count_all($table = '')
{
if ($table == '')
{
@@ -383,11 +337,10 @@ class CI_DB_mssql_driver extends CI_DB {
*
* Generates a platform-specific query string so that the table names can be fetched
*
- * @access private
- * @param boolean
+ * @param bool
* @return string
*/
- function _list_tables($prefix_limit = FALSE)
+ protected function _list_tables($prefix_limit = FALSE)
{
$sql = "SELECT name FROM sysobjects WHERE type = 'U' ORDER BY name";
@@ -408,11 +361,10 @@ class CI_DB_mssql_driver extends CI_DB {
*
* Generates a platform-specific query string so that the column names can be fetched
*
- * @access private
* @param string the table name
* @return string
*/
- function _list_columns($table = '')
+ protected function _list_columns($table = '')
{
return "SELECT * FROM INFORMATION_SCHEMA.Columns WHERE TABLE_NAME = '".$table."'";
}
@@ -424,11 +376,10 @@ class CI_DB_mssql_driver extends CI_DB {
*
* Generates a platform-specific query so that the column data can be retrieved
*
- * @access public
* @param string the table name
- * @return object
+ * @return string
*/
- function _field_data($table)
+ protected function _field_data($table)
{
return "SELECT TOP 1 * FROM ".$table;
}
@@ -457,11 +408,10 @@ class CI_DB_mssql_driver extends CI_DB {
*
* This function escapes column and table names
*
- * @access private
* @param string
* @return string
*/
- function _escape_identifiers($item)
+ public function _escape_identifiers($item)
{
if ($this->_escape_char == '')
{
@@ -500,11 +450,10 @@ class CI_DB_mssql_driver extends CI_DB {
* This function implicitly groups FROM tables so there is no confusion
* about operator precedence in harmony with SQL standards
*
- * @access public
- * @param type
- * @return type
+ * @param array
+ * @return string
*/
- function _from_tables($tables)
+ protected function _from_tables($tables)
{
if ( ! is_array($tables))
{
@@ -521,13 +470,12 @@ class CI_DB_mssql_driver extends CI_DB {
*
* Generates a platform-specific insert string from the supplied data
*
- * @access public
* @param string the table name
* @param array the insert keys
* @param array the insert values
* @return string
*/
- function _insert($table, $keys, $values)
+ protected function _insert($table, $keys, $values)
{
return "INSERT INTO ".$table." (".implode(', ', $keys).") VALUES (".implode(', ', $values).")";
}
@@ -539,7 +487,6 @@ class CI_DB_mssql_driver extends CI_DB {
*
* Generates a platform-specific update string from the supplied data
*
- * @access public
* @param string the table name
* @param array the update data
* @param array the where clause
@@ -547,7 +494,7 @@ class CI_DB_mssql_driver extends CI_DB {
* @param array the limit clause
* @return string
*/
- function _update($table, $values, $where, $orderby = array(), $limit = FALSE)
+ protected function _update($table, $values, $where, $orderby = array(), $limit = FALSE)
{
foreach ($values as $key => $val)
{
@@ -577,11 +524,10 @@ class CI_DB_mssql_driver extends CI_DB {
* If the database does not support the truncate() command
* This function maps to "DELETE FROM table"
*
- * @access public
* @param string the table name
* @return string
*/
- function _truncate($table)
+ protected function _truncate($table)
{
return "TRUNCATE ".$table;
}
@@ -593,13 +539,12 @@ class CI_DB_mssql_driver extends CI_DB {
*
* Generates a platform-specific delete string from the supplied data
*
- * @access public
* @param string the table name
* @param array the where clause
* @param string the limit clause
* @return string
*/
- function _delete($table, $where = array(), $like = array(), $limit = FALSE)
+ protected function _delete($table, $where = array(), $like = array(), $limit = FALSE)
{
$conditions = '';
@@ -627,13 +572,12 @@ class CI_DB_mssql_driver extends CI_DB {
*
* Generates a platform-specific LIMIT clause
*
- * @access public
* @param string the sql query string
- * @param integer the number of rows to limit the query to
- * @param integer the offset value
+ * @param int the number of rows to limit the query to
+ * @param int the offset value
* @return string
*/
- function _limit($sql, $limit, $offset)
+ protected function _limit($sql, $limit, $offset)
{
$i = $limit + $offset;
@@ -645,18 +589,15 @@ class CI_DB_mssql_driver extends CI_DB {
/**
* Close DB Connection
*
- * @access public
* @param resource
* @return void
*/
- function _close($conn_id)
+ protected function _close($conn_id)
{
@mssql_close($conn_id);
}
}
-
-
/* End of file mssql_driver.php */
-/* Location: ./system/database/drivers/mssql/mssql_driver.php */
+/* Location: ./system/database/drivers/mssql/mssql_driver.php */ \ No newline at end of file
diff --git a/system/database/drivers/mssql/mssql_forge.php b/system/database/drivers/mssql/mssql_forge.php
index 4a8089bb1..2e3e314ed 100644
--- a/system/database/drivers/mssql/mssql_forge.php
+++ b/system/database/drivers/mssql/mssql_forge.php
@@ -1,13 +1,13 @@
-<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
* An open source application development framework for PHP 5.2.4 or newer
*
* NOTICE OF LICENSE
- *
+ *
* Licensed under the Open Software License version 3.0
- *
+ *
* This source file is subject to the Open Software License (OSL 3.0) that is
* bundled with this package in the files license.txt / license.rst. It is
* also available through the world wide web at this URL:
@@ -25,8 +25,6 @@
* @filesource
*/
-// ------------------------------------------------------------------------
-
/**
* MS SQL Forge Class
*
@@ -39,11 +37,10 @@ class CI_DB_mssql_forge extends CI_DB_forge {
/**
* Create database
*
- * @access private
* @param string the database name
- * @return bool
+ * @return string
*/
- function _create_database($name)
+ public function _create_database($name)
{
return "CREATE DATABASE ".$name;
}
@@ -53,11 +50,10 @@ class CI_DB_mssql_forge extends CI_DB_forge {
/**
* Drop database
*
- * @access private
* @param string the database name
- * @return bool
+ * @return string
*/
- function _drop_database($name)
+ public function _drop_database($name)
{
return "DROP DATABASE ".$name;
}
@@ -67,10 +63,10 @@ class CI_DB_mssql_forge extends CI_DB_forge {
/**
* Drop Table
*
- * @access private
- * @return bool
+ * @param string table name
+ * @return string
*/
- function _drop_table($table)
+ public function _drop_table($table)
{
return "DROP TABLE ".$this->db->_escape_identifiers($table);
}
@@ -80,15 +76,14 @@ class CI_DB_mssql_forge extends CI_DB_forge {
/**
* Create Table
*
- * @access private
* @param string the table name
* @param array the fields
* @param mixed primary key(s)
* @param mixed key(s)
- * @param boolean should 'IF NOT EXISTS' be added to the SQL
- * @return bool
+ * @param bool should 'IF NOT EXISTS' be added to the SQL
+ * @return string
*/
- function _create_table($table, $fields, $primary_keys, $keys, $if_not_exists)
+ public function _create_table($table, $fields, $primary_keys, $keys, $if_not_exists)
{
$sql = 'CREATE TABLE ';
@@ -100,7 +95,7 @@ class CI_DB_mssql_forge extends CI_DB_forge {
$sql .= $this->db->_escape_identifiers($table)." (";
$current_field_count = 0;
- foreach ($fields as $field=>$attributes)
+ foreach ($fields as $field => $attributes)
{
// Numeric field names aren't allowed in databases, so if the key is
// numeric, we know it was assigned by PHP and the developer manually
@@ -190,17 +185,16 @@ class CI_DB_mssql_forge extends CI_DB_forge {
* Generates a platform-specific query so that a table can be altered
* Called by add_column(), drop_column(), and column_alter(),
*
- * @access private
* @param string the ALTER type (ADD, DROP, CHANGE)
* @param string the column name
* @param string the table name
* @param string the column definition
* @param string the default value
- * @param boolean should 'NOT NULL' be added
+ * @param bool should 'NOT NULL' be added
* @param string the field after which we should add the new field
- * @return object
+ * @return string
*/
- function _alter_table($alter_type, $table, $column_name, $column_definition = '', $default_value = '', $null = '', $after_field = '')
+ public function _alter_table($alter_type, $table, $column_name, $column_definition = '', $default_value = '', $null = '', $after_field = '')
{
$sql = 'ALTER TABLE '.$this->db->protect_identifiers($table).' '.$alter_type.' '.$this->db->protect_identifiers($column_name);
@@ -242,12 +236,11 @@ class CI_DB_mssql_forge extends CI_DB_forge {
*
* Generates a platform-specific query so that a table can be renamed
*
- * @access private
* @param string the old table name
* @param string the new table name
* @return string
*/
- function _rename_table($table_name, $new_table_name)
+ public function _rename_table($table_name, $new_table_name)
{
// I think this syntax will work, but can find little documentation on renaming tables in MSSQL
return 'ALTER TABLE '.$this->db->protect_identifiers($table_name).' RENAME TO '.$this->db->protect_identifiers($new_table_name);
@@ -256,4 +249,4 @@ class CI_DB_mssql_forge extends CI_DB_forge {
}
/* End of file mssql_forge.php */
-/* Location: ./system/database/drivers/mssql/mssql_forge.php */
+/* Location: ./system/database/drivers/mssql/mssql_forge.php */ \ No newline at end of file
diff --git a/system/database/drivers/mssql/mssql_result.php b/system/database/drivers/mssql/mssql_result.php
index b205ce2d1..2723f4614 100644
--- a/system/database/drivers/mssql/mssql_result.php
+++ b/system/database/drivers/mssql/mssql_result.php
@@ -1,13 +1,13 @@
-<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
* An open source application development framework for PHP 5.2.4 or newer
*
* NOTICE OF LICENSE
- *
+ *
* Licensed under the Open Software License version 3.0
- *
+ *
* This source file is subject to the Open Software License (OSL 3.0) that is
* bundled with this package in the files license.txt / license.rst. It is
* also available through the world wide web at this URL:
@@ -25,8 +25,6 @@
* @filesource
*/
-// ------------------------------------------------------------------------
-
/**
* MS SQL Result Class
*
@@ -41,10 +39,9 @@ class CI_DB_mssql_result extends CI_DB_result {
/**
* Number of rows in the result set
*
- * @access public
- * @return integer
+ * @return int
*/
- function num_rows()
+ public function num_rows()
{
return @mssql_num_rows($this->result_id);
}
@@ -54,10 +51,9 @@ class CI_DB_mssql_result extends CI_DB_result {
/**
* Number of fields in the result set
*
- * @access public
- * @return integer
+ * @return int
*/
- function num_fields()
+ public function num_fields()
{
return @mssql_num_fields($this->result_id);
}
@@ -69,10 +65,9 @@ class CI_DB_mssql_result extends CI_DB_result {
*
* Generates an array of column names
*
- * @access public
* @return array
*/
- function list_fields()
+ public function list_fields()
{
$field_names = array();
while ($field = mssql_fetch_field($this->result_id))
@@ -90,10 +85,9 @@ class CI_DB_mssql_result extends CI_DB_result {
*
* Generates an array of objects containing field meta-data
*
- * @access public
* @return array
*/
- function field_data()
+ public function field_data()
{
$retval = array();
while ($field = mssql_fetch_field($this->result_id))
@@ -116,9 +110,9 @@ class CI_DB_mssql_result extends CI_DB_result {
/**
* Free the result
*
- * @return null
+ * @return void
*/
- function free_result()
+ public function free_result()
{
if (is_resource($this->result_id))
{
@@ -136,10 +130,9 @@ class CI_DB_mssql_result extends CI_DB_result {
* this internally before fetching results to make sure the
* result set starts at zero
*
- * @access private
* @return array
*/
- function _data_seek($n = 0)
+ protected function _data_seek($n = 0)
{
return mssql_data_seek($this->result_id, $n);
}
@@ -151,10 +144,9 @@ class CI_DB_mssql_result extends CI_DB_result {
*
* Returns the result set as an array
*
- * @access private
* @return array
*/
- function _fetch_assoc()
+ protected function _fetch_assoc()
{
return mssql_fetch_assoc($this->result_id);
}
@@ -166,16 +158,14 @@ class CI_DB_mssql_result extends CI_DB_result {
*
* Returns the result set as an object
*
- * @access private
* @return object
*/
- function _fetch_object()
+ protected function _fetch_object()
{
return mssql_fetch_object($this->result_id);
}
}
-
/* End of file mssql_result.php */
/* Location: ./system/database/drivers/mssql/mssql_result.php */ \ No newline at end of file
diff --git a/system/database/drivers/mssql/mssql_utility.php b/system/database/drivers/mssql/mssql_utility.php
index 28f34b999..5c144330d 100644
--- a/system/database/drivers/mssql/mssql_utility.php
+++ b/system/database/drivers/mssql/mssql_utility.php
@@ -1,13 +1,13 @@
-<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
* An open source application development framework for PHP 5.2.4 or newer
*
* NOTICE OF LICENSE
- *
+ *
* Licensed under the Open Software License version 3.0
- *
+ *
* This source file is subject to the Open Software License (OSL 3.0) that is
* bundled with this package in the files license.txt / license.rst. It is
* also available through the world wide web at this URL:
@@ -25,8 +25,6 @@
* @filesource
*/
-// ------------------------------------------------------------------------
-
/**
* MS SQL Utility Class
*
@@ -39,10 +37,9 @@ class CI_DB_mssql_utility extends CI_DB_utility {
/**
* List databases
*
- * @access private
- * @return bool
+ * @return string
*/
- function _list_databases()
+ public function _list_databases()
{
return "EXEC sp_helpdb"; // Can also be: EXEC sp_databases
}
@@ -54,11 +51,10 @@ class CI_DB_mssql_utility extends CI_DB_utility {
*
* Generates a platform-specific query so that a table can be optimized
*
- * @access private
* @param string the table name
- * @return object
+ * @return bool
*/
- function _optimize_table($table)
+ public function _optimize_table($table)
{
return FALSE; // Is this supported in MS SQL?
}
@@ -70,11 +66,10 @@ class CI_DB_mssql_utility extends CI_DB_utility {
*
* Generates a platform-specific query so that a table can be repaired
*
- * @access private
* @param string the table name
- * @return object
+ * @return bool
*/
- function _repair_table($table)
+ public function _repair_table($table)
{
return FALSE; // Is this supported in MS SQL?
}
@@ -84,11 +79,10 @@ class CI_DB_mssql_utility extends CI_DB_utility {
/**
* MSSQL Export
*
- * @access private
* @param array Preferences
* @return mixed
*/
- function _backup($params = array())
+ public function _backup($params = array())
{
// Currently unsupported
return $this->db->display_error('db_unsuported_feature');
diff --git a/system/database/drivers/mysql/mysql_driver.php b/system/database/drivers/mysql/mysql_driver.php
index ba646d226..bef4111c3 100644
--- a/system/database/drivers/mysql/mysql_driver.php
+++ b/system/database/drivers/mysql/mysql_driver.php
@@ -701,4 +701,4 @@ class CI_DB_mysql_driver extends CI_DB {
}
/* End of file mysql_driver.php */
-/* Location: ./system/database/drivers/mysql/mysql_driver.php */
+/* Location: ./system/database/drivers/mysql/mysql_driver.php */ \ No newline at end of file
diff --git a/system/database/drivers/mysql/mysql_forge.php b/system/database/drivers/mysql/mysql_forge.php
index 004a5a103..11172b41b 100644
--- a/system/database/drivers/mysql/mysql_forge.php
+++ b/system/database/drivers/mysql/mysql_forge.php
@@ -66,7 +66,7 @@ class CI_DB_mysql_forge extends CI_DB_forge {
* @param mixed the fields
* @return string
*/
- private function _process_fields($fields)
+ protected function _process_fields($fields)
{
$current_field_count = 0;
$sql = '';
@@ -237,4 +237,4 @@ class CI_DB_mysql_forge extends CI_DB_forge {
}
/* End of file mysql_forge.php */
-/* Location: ./system/database/drivers/mysql/mysql_forge.php */
+/* Location: ./system/database/drivers/mysql/mysql_forge.php */ \ No newline at end of file
diff --git a/system/database/drivers/mysql/mysql_result.php b/system/database/drivers/mysql/mysql_result.php
index cec28dc2d..f76076f4c 100644
--- a/system/database/drivers/mysql/mysql_result.php
+++ b/system/database/drivers/mysql/mysql_result.php
@@ -166,4 +166,4 @@ class CI_DB_mysql_result extends CI_DB_result {
}
/* End of file mysql_result.php */
-/* Location: ./system/database/drivers/mysql/mysql_result.php */
+/* Location: ./system/database/drivers/mysql/mysql_result.php */ \ No newline at end of file
diff --git a/system/database/drivers/mysql/mysql_utility.php b/system/database/drivers/mysql/mysql_utility.php
index d716b004a..2d89cb9cb 100644
--- a/system/database/drivers/mysql/mysql_utility.php
+++ b/system/database/drivers/mysql/mysql_utility.php
@@ -204,4 +204,4 @@ class CI_DB_mysql_utility extends CI_DB_utility {
}
/* End of file mysql_utility.php */
-/* Location: ./system/database/drivers/mysql/mysql_utility.php */
+/* Location: ./system/database/drivers/mysql/mysql_utility.php */ \ No newline at end of file
diff --git a/system/database/drivers/mysqli/mysqli_driver.php b/system/database/drivers/mysqli/mysqli_driver.php
index f38b94c13..47b0449d6 100644
--- a/system/database/drivers/mysqli/mysqli_driver.php
+++ b/system/database/drivers/mysqli/mysqli_driver.php
@@ -72,8 +72,8 @@ class CI_DB_mysqli_driver extends CI_DB {
public function db_connect()
{
return ($this->port != '')
- ? @mysqli_connect($this->hostname, $this->username, $this->password, $this->database, $this->port)
- : @mysqli_connect($this->hostname, $this->username, $this->password, $this->database);
+ ? @new mysqli($this->hostname, $this->username, $this->password, $this->database, $this->port)
+ : @new mysqli($this->hostname, $this->username, $this->password, $this->database);
}
// --------------------------------------------------------------------
@@ -92,8 +92,8 @@ class CI_DB_mysqli_driver extends CI_DB {
}
return ($this->port != '')
- ? @mysqli_connect('p:'.$this->hostname, $this->username, $this->password, $this->database, $this->port)
- : @mysqli_connect('p:'.$this->hostname, $this->username, $this->password, $this->database);
+ ? @new mysqli('p:'.$this->hostname, $this->username, $this->password, $this->database, $this->port)
+ : @new mysqli('p:'.$this->hostname, $this->username, $this->password, $this->database);
}
// --------------------------------------------------------------------
@@ -108,7 +108,7 @@ class CI_DB_mysqli_driver extends CI_DB {
*/
public function reconnect()
{
- if (mysqli_ping($this->conn_id) === FALSE)
+ if ($this->conn_id !== FALSE && $this->conn_id->ping() === FALSE)
{
$this->conn_id = FALSE;
}
@@ -129,7 +129,7 @@ class CI_DB_mysqli_driver extends CI_DB {
$database = $this->database;
}
- if (@mysqli_select_db($this->conn_id, $database))
+ if (@$this->conn_id->select_db($database))
{
$this->database = $database;
return TRUE;
@@ -148,7 +148,7 @@ class CI_DB_mysqli_driver extends CI_DB {
*/
protected function _db_set_charset($charset)
{
- return @mysqli_set_charset($this->conn_id, $charset);
+ return @$this->conn_id->set_charset($charset);
}
// --------------------------------------------------------------------
@@ -162,7 +162,7 @@ class CI_DB_mysqli_driver extends CI_DB {
{
return isset($this->data_cache['version'])
? $this->data_cache['version']
- : $this->data_cache['version'] = @mysqli_get_server_info($this->conn_id);
+ : $this->data_cache['version'] = $this->conn_id->server_info;
}
// --------------------------------------------------------------------
@@ -175,7 +175,7 @@ class CI_DB_mysqli_driver extends CI_DB {
*/
protected function _execute($sql)
{
- return @mysqli_query($this->conn_id, $this->_prep_query($sql));
+ return @$this->conn_id->query($this->_prep_query($sql));
}
// --------------------------------------------------------------------
@@ -286,7 +286,7 @@ class CI_DB_mysqli_driver extends CI_DB {
return $str;
}
- $str = is_object($this->conn_id) ? mysqli_real_escape_string($this->conn_id, $str) : addslashes($str);
+ $str = is_object($this->conn_id) ? $this->conn_id->real_escape_string($str) : addslashes($str);
// escape LIKE condition wildcards
if ($like === TRUE)
@@ -306,7 +306,7 @@ class CI_DB_mysqli_driver extends CI_DB {
*/
public function affected_rows()
{
- return @mysqli_affected_rows($this->conn_id);
+ return $this->conn_id->affected_rows;
}
// --------------------------------------------------------------------
@@ -318,7 +318,7 @@ class CI_DB_mysqli_driver extends CI_DB {
*/
public function insert_id()
{
- return @mysqli_insert_id($this->conn_id);
+ return $this->conn_id->insert_id;
}
// --------------------------------------------------------------------
@@ -357,7 +357,6 @@ class CI_DB_mysqli_driver extends CI_DB {
*
* Generates a platform-specific query string so that the table names can be fetched
*
- * @access private
* @param bool
* @return string
*/
@@ -434,7 +433,7 @@ class CI_DB_mysqli_driver extends CI_DB {
*/
public function error()
{
- return array('code' => mysqli_errno($this->conn_id), 'message' => mysqli_error($this->conn_id));
+ return array('code' => $this->conn_id->errno, 'message' => $this->conn_id->error);
}
// --------------------------------------------------------------------
@@ -691,10 +690,11 @@ class CI_DB_mysqli_driver extends CI_DB {
*/
protected function _close($conn_id)
{
- @mysqli_close($conn_id);
+ $this->conn_id->close();
+ $this->conn_id = FALSE;
}
}
/* End of file mysqli_driver.php */
-/* Location: ./system/database/drivers/mysqli/mysqli_driver.php */
+/* Location: ./system/database/drivers/mysqli/mysqli_driver.php */ \ No newline at end of file
diff --git a/system/database/drivers/mysqli/mysqli_forge.php b/system/database/drivers/mysqli/mysqli_forge.php
index 9cb1a0c70..8cf0ae1fd 100644
--- a/system/database/drivers/mysqli/mysqli_forge.php
+++ b/system/database/drivers/mysqli/mysqli_forge.php
@@ -66,7 +66,7 @@ class CI_DB_mysqli_forge extends CI_DB_forge {
* @param mixed the fields
* @return string
*/
- public function _process_fields($fields)
+ protected function _process_fields($fields)
{
$current_field_count = 0;
$sql = '';
@@ -237,4 +237,4 @@ class CI_DB_mysqli_forge extends CI_DB_forge {
}
/* End of file mysqli_forge.php */
-/* Location: ./system/database/drivers/mysqli/mysqli_forge.php */
+/* Location: ./system/database/drivers/mysqli/mysqli_forge.php */ \ No newline at end of file
diff --git a/system/database/drivers/mysqli/mysqli_result.php b/system/database/drivers/mysqli/mysqli_result.php
index f135f4d46..cf0362217 100644
--- a/system/database/drivers/mysqli/mysqli_result.php
+++ b/system/database/drivers/mysqli/mysqli_result.php
@@ -43,7 +43,7 @@ class CI_DB_mysqli_result extends CI_DB_result {
*/
public function num_rows()
{
- return @mysqli_num_rows($this->result_id);
+ return $this->result_id->num_rows;
}
// --------------------------------------------------------------------
@@ -55,7 +55,7 @@ class CI_DB_mysqli_result extends CI_DB_result {
*/
public function num_fields()
{
- return @mysqli_num_fields($this->result_id);
+ return $this->result_id->field_count;
}
// --------------------------------------------------------------------
@@ -70,7 +70,7 @@ class CI_DB_mysqli_result extends CI_DB_result {
public function list_fields()
{
$field_names = array();
- while ($field = mysqli_fetch_field($this->result_id))
+ while ($field = $this->result_id->fetch_field())
{
$field_names[] = $field->name;
}
@@ -90,7 +90,7 @@ class CI_DB_mysqli_result extends CI_DB_result {
public function field_data()
{
$retval = array();
- $field_data = mysqli_fetch_fields($this->result_id);
+ $field_data = $this->result_id->fetch_fields();
for ($i = 0, $c = count($field_data); $i < $c; $i++)
{
$retval[$i] = new stdClass();
@@ -115,7 +115,7 @@ class CI_DB_mysqli_result extends CI_DB_result {
{
if (is_object($this->result_id))
{
- mysqli_free_result($this->result_id);
+ $this->result_id->free();
$this->result_id = FALSE;
}
}
@@ -133,7 +133,7 @@ class CI_DB_mysqli_result extends CI_DB_result {
*/
protected function _data_seek($n = 0)
{
- return mysqli_data_seek($this->result_id, $n);
+ return $this->result_id->data_seek($n);
}
// --------------------------------------------------------------------
@@ -147,7 +147,7 @@ class CI_DB_mysqli_result extends CI_DB_result {
*/
protected function _fetch_assoc()
{
- return mysqli_fetch_assoc($this->result_id);
+ return $this->result_id->fetch_assoc();
}
// --------------------------------------------------------------------
@@ -161,10 +161,10 @@ class CI_DB_mysqli_result extends CI_DB_result {
*/
protected function _fetch_object()
{
- return mysqli_fetch_object($this->result_id);
+ return $this->result_id->fetch_object();
}
}
/* End of file mysqli_result.php */
-/* Location: ./system/database/drivers/mysqli/mysqli_result.php */
+/* Location: ./system/database/drivers/mysqli/mysqli_result.php */ \ No newline at end of file
diff --git a/system/database/drivers/mysqli/mysqli_utility.php b/system/database/drivers/mysqli/mysqli_utility.php
index 650ddfd18..4d7002e78 100644
--- a/system/database/drivers/mysqli/mysqli_utility.php
+++ b/system/database/drivers/mysqli/mysqli_utility.php
@@ -90,4 +90,4 @@ class CI_DB_mysqli_utility extends CI_DB_utility {
}
/* End of file mysqli_utility.php */
-/* Location: ./system/database/drivers/mysqli/mysqli_utility.php */
+/* Location: ./system/database/drivers/mysqli/mysqli_utility.php */ \ No newline at end of file
diff --git a/system/database/drivers/oci8/oci8_driver.php b/system/database/drivers/oci8/oci8_driver.php
index 070d58a34..45b0198eb 100644
--- a/system/database/drivers/oci8/oci8_driver.php
+++ b/system/database/drivers/oci8/oci8_driver.php
@@ -1,13 +1,13 @@
-<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
* An open source application development framework for PHP 5.2.4 or newer
*
* NOTICE OF LICENSE
- *
+ *
* Licensed under the Open Software License version 3.0
- *
+ *
* This source file is subject to the Open Software License (OSL 3.0) that is
* bundled with this package in the files license.txt / license.rst. It is
* also available through the world wide web at this URL:
@@ -25,8 +25,6 @@
* @filesource
*/
-// ------------------------------------------------------------------------
-
/**
* oci8 Database Adapter Class
*
@@ -50,90 +48,139 @@
* @author Kelly McArdle
*
*/
-
class CI_DB_oci8_driver extends CI_DB {
- var $dbdriver = 'oci8';
+ public $dbdriver = 'oci8';
// The character used for excaping
- var $_escape_char = '"';
+ protected $_escape_char = '"';
// clause and character used for LIKE escape sequences
- var $_like_escape_str = " escape '%s' ";
- var $_like_escape_chr = '!';
+ protected $_like_escape_str = " ESCAPE '%s' ";
+ protected $_like_escape_chr = '!';
/**
* The syntax to count rows is slightly different across different
* database engines, so this string appears in each driver and is
* used for the count_all() and count_all_results() functions.
*/
- var $_count_string = "SELECT COUNT(1) AS ";
- var $_random_keyword = ' ASC'; // not currently supported
+ protected $_count_string = 'SELECT COUNT(1) AS ';
+ protected $_random_keyword = ' ASC'; // not currently supported
// Set "auto commit" by default
- var $_commit = OCI_COMMIT_ON_SUCCESS;
+ protected $_commit = OCI_COMMIT_ON_SUCCESS;
// need to track statement id and cursor id
- var $stmt_id;
- var $curs_id;
+ public $stmt_id;
+ public $curs_id;
// if we use a limit, we will add a field that will
// throw off num_fields later
- var $limit_used;
+ public $limit_used;
- /**
- * Non-persistent database connection
- *
- * @access private called by the base class
- * @return resource
- */
- public function db_connect()
+ public function __construct($params)
{
- return @oci_connect($this->username, $this->password, $this->hostname, $this->char_set);
- }
+ parent::__construct($params);
- // --------------------------------------------------------------------
+ $valid_dsns = array(
+ 'tns' => '/^\(DESCRIPTION=(\(.+\)){2,}\)$/', // TNS
+ // Easy Connect string (Oracle 10g+)
+ 'ec' => '/^(\/\/)?[a-z0-9.:_-]+(:[1-9][0-9]{0,4})?(\/[a-z0-9$_]+)?(:[^\/])?(\/[a-z0-9$_]+)?$/i',
+ 'in' => '/^[a-z0-9$_]+$/i' // Instance name (defined in tnsnames.ora)
+ );
- /**
- * Persistent database connection
- *
- * @access private called by the base class
- * @return resource
- */
- public function db_pconnect()
- {
- return @oci_pconnect($this->username, $this->password, $this->hostname, $this->char_set);
- }
+ /* Space characters don't have any effect when actually
+ * connecting, but can be a hassle while validating the DSN.
+ */
+ $this->dsn = str_replace(array("\n", "\r", "\t", ' '), '', $this->dsn);
- // --------------------------------------------------------------------
+ if ($this->dsn !== '')
+ {
+ foreach ($valid_dsns as $regexp)
+ {
+ if (preg_match($regexp, $this->dsn))
+ {
+ return;
+ }
+ }
+ }
+
+ // Legacy support for TNS in the hostname configuration field
+ $this->hostname = str_replace(array("\n", "\r", "\t", ' '), '', $this->hostname);
+ if (preg_match($valid_dsns['tns'], $this->hostname))
+ {
+ $this->dsn = $this->hostname;
+ return;
+ }
+ elseif ($this->hostname !== '' && strpos($this->hostname, '/') === FALSE && strpos($this->hostname, ':') === FALSE
+ && (( ! empty($this->port) && ctype_digit($this->port)) OR $this->database !== ''))
+ {
+ /* If the hostname field isn't empty, doesn't contain
+ * ':' and/or '/' and if port and/or database aren't
+ * empty, then the hostname field is most likely indeed
+ * just a hostname. Therefore we'll try and build an
+ * Easy Connect string from these 3 settings, assuming
+ * that the database field is a service name.
+ */
+ $this->dsn = $this->hostname
+ .(( ! empty($this->port) && ctype_digit($this->port)) ? ':'.$this->port : '')
+ .($this->database !== '' ? '/'.ltrim($this->database, '/') : '');
+
+ if (preg_match($valid_dsns['ec'], $this->dsn))
+ {
+ return;
+ }
+ }
+
+ /* At this point, we can only try and validate the hostname and
+ * database fields separately as DSNs.
+ */
+ if (preg_match($valid_dsns['ec'], $this->hostname) OR preg_match($valid_dsns['in'], $this->hostname))
+ {
+ $this->dsn = $this->hostname;
+ return;
+ }
+
+ $this->database = str_replace(array("\n", "\r", "\t", ' '), '', $this->database);
+ foreach ($valid_dsns as $regexp)
+ {
+ if (preg_match($regexp, $this->database))
+ {
+ return;
+ }
+ }
+
+ /* Well - OK, an empty string should work as well.
+ * PHP will try to use environment variables to
+ * determine which Oracle instance to connect to.
+ */
+ $this->dsn = '';
+ }
/**
- * Reconnect
- *
- * Keep / reestablish the db connection if no queries have been
- * sent for a length of time exceeding the server's idle timeout
+ * Non-persistent database connection
*
- * @access public
- * @return void
+ * @return resource
*/
- public function reconnect()
+ public function db_connect()
{
- // not implemented in oracle
- return;
+ return ( ! empty($this->char_set))
+ ? @oci_connect($this->username, $this->password, $this->dsn, $this->char_set)
+ : @oci_connect($this->username, $this->password, $this->dsn);
}
// --------------------------------------------------------------------
/**
- * Select the database
+ * Persistent database connection
*
- * @access private called by the base class
- * @return resource
+ * @return resource
*/
- public function db_select()
+ public function db_pconnect()
{
- // Not in Oracle - schemas are actually usernames
- return TRUE;
+ return ( ! empty($this->char_set))
+ ? @oci_pconnect($this->username, $this->password, $this->dsn, $this->char_set)
+ : @oci_pconnect($this->username, $this->password, $this->dsn);
}
// --------------------------------------------------------------------
@@ -155,9 +202,8 @@ class CI_DB_oci8_driver extends CI_DB {
/**
* Execute the query
*
- * @access protected called by the base class
- * @param string an SQL query
- * @return resource
+ * @param string an SQL query
+ * @return resource
*/
protected function _execute($sql)
{
@@ -172,41 +218,23 @@ class CI_DB_oci8_driver extends CI_DB {
/**
* Generate a statement ID
*
- * @access private
- * @param string an SQL query
- * @return none
+ * @param string an SQL query
+ * @return void
*/
- private function _set_stmt_id($sql)
+ protected function _set_stmt_id($sql)
{
if ( ! is_resource($this->stmt_id))
{
- $this->stmt_id = oci_parse($this->conn_id, $this->_prep_query($sql));
+ $this->stmt_id = oci_parse($this->conn_id, $sql);
}
}
// --------------------------------------------------------------------
/**
- * Prep the query
+ * Get cursor. Returns a cursor from the database
*
- * If needed, each database adapter can prep the query string
- *
- * @access private called by execute()
- * @param string an SQL query
- * @return string
- */
- private function _prep_query($sql)
- {
- return $sql;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * getCursor. Returns a cursor from the datbase
- *
- * @access public
- * @return cursor id
+ * @return cursor id
*/
public function get_cursor()
{
@@ -219,11 +247,10 @@ class CI_DB_oci8_driver extends CI_DB {
/**
* Stored Procedure. Executes a stored procedure
*
- * @access public
- * @param package package stored procedure is in
- * @param procedure stored procedure to execute
- * @param params array of parameters
- * @return array
+ * @param string package stored procedure is in
+ * @param string stored procedure to execute
+ * @param array parameters
+ * @return object
*
* params array keys
*
@@ -272,10 +299,9 @@ class CI_DB_oci8_driver extends CI_DB {
/**
* Bind parameters
*
- * @access private
- * @return none
+ * @return void
*/
- private function _bind_params($params)
+ protected function _bind_params($params)
{
if ( ! is_array($params) OR ! is_resource($this->stmt_id))
{
@@ -301,7 +327,6 @@ class CI_DB_oci8_driver extends CI_DB {
/**
* Begin Transaction
*
- * @access public
* @return bool
*/
public function trans_begin($test_mode = FALSE)
@@ -331,7 +356,6 @@ class CI_DB_oci8_driver extends CI_DB {
/**
* Commit Transaction
*
- * @access public
* @return bool
*/
public function trans_commit()
@@ -357,7 +381,6 @@ class CI_DB_oci8_driver extends CI_DB {
/**
* Rollback Transaction
*
- * @access public
* @return bool
*/
public function trans_rollback()
@@ -417,8 +440,7 @@ class CI_DB_oci8_driver extends CI_DB {
/**
* Affected Rows
*
- * @access public
- * @return integer
+ * @return int
*/
public function affected_rows()
{
@@ -430,8 +452,7 @@ class CI_DB_oci8_driver extends CI_DB {
/**
* Insert ID
*
- * @access public
- * @return integer
+ * @return int
*/
public function insert_id()
{
@@ -447,9 +468,8 @@ class CI_DB_oci8_driver extends CI_DB {
* Generates a platform-specific query string that counts all records in
* the specified database
*
- * @access public
- * @param string
- * @return string
+ * @param string
+ * @return string
*/
public function count_all($table = '')
{
@@ -476,8 +496,7 @@ class CI_DB_oci8_driver extends CI_DB {
*
* Generates a platform-specific query string so that the table names can be fetched
*
- * @access protected
- * @param boolean
+ * @param bool
* @return string
*/
protected function _list_tables($prefix_limit = FALSE)
@@ -499,9 +518,8 @@ class CI_DB_oci8_driver extends CI_DB {
*
* Generates a platform-specific query string so that the column names can be fetched
*
- * @access protected
- * @param string the table name
- * @return string
+ * @param string the table name
+ * @return string
*/
protected function _list_columns($table = '')
{
@@ -515,9 +533,8 @@ class CI_DB_oci8_driver extends CI_DB {
*
* Generates a platform-specific query so that the column data can be retrieved
*
- * @access public
- * @param string the table name
- * @return object
+ * @param string the table name
+ * @return string
*/
protected function _field_data($table)
{
@@ -562,11 +579,10 @@ class CI_DB_oci8_driver extends CI_DB {
*
* This function escapes column and table names
*
- * @access protected
* @param string
* @return string
*/
- protected function _escape_identifiers($item)
+ public function _escape_identifiers($item)
{
if ($this->_escape_char == '')
{
@@ -605,9 +621,8 @@ class CI_DB_oci8_driver extends CI_DB {
* This function implicitly groups FROM tables so there is no confusion
* about operator precedence in harmony with SQL standards
*
- * @access protected
- * @param type
- * @return type
+ * @param array
+ * @return string
*/
protected function _from_tables($tables)
{
@@ -626,11 +641,10 @@ class CI_DB_oci8_driver extends CI_DB {
*
* Generates a platform-specific insert string from the supplied data
*
- * @access public
- * @param string the table name
- * @param array the insert keys
- * @param array the insert values
- * @return string
+ * @param string the table name
+ * @param array the insert keys
+ * @param array the insert values
+ * @return string
*/
protected function _insert($table, $keys, $values)
{
@@ -644,10 +658,10 @@ class CI_DB_oci8_driver extends CI_DB {
*
* Generates a platform-specific insert string from the supplied data
*
- * @param string the table name
- * @param array the insert keys
- * @param array the insert values
- * @return string
+ * @param string the table name
+ * @param array the insert keys
+ * @param array the insert values
+ * @return string
*/
protected function _insert_batch($table, $keys, $values)
{
@@ -671,7 +685,6 @@ class CI_DB_oci8_driver extends CI_DB {
*
* Generates a platform-specific update string from the supplied data
*
- * @access protected
* @param string the table name
* @param array the update data
* @param array the where clause
@@ -708,7 +721,6 @@ class CI_DB_oci8_driver extends CI_DB {
* If the database does not support the truncate() command
* This function maps to "DELETE FROM table"
*
- * @access protected
* @param string the table name
* @return string
*/
@@ -724,7 +736,6 @@ class CI_DB_oci8_driver extends CI_DB {
*
* Generates a platform-specific delete string from the supplied data
*
- * @access protected
* @param string the table name
* @param array the where clause
* @param string the limit clause
@@ -758,11 +769,10 @@ class CI_DB_oci8_driver extends CI_DB {
*
* Generates a platform-specific LIMIT clause
*
- * @access protected
- * @param string the sql query string
- * @param integer the number of rows to limit the query to
- * @param integer the offset value
- * @return string
+ * @param string the sql query string
+ * @param int the number of rows to limit the query to
+ * @param int the offset value
+ * @return string
*/
protected function _limit($sql, $limit, $offset)
{
@@ -785,19 +795,15 @@ class CI_DB_oci8_driver extends CI_DB {
/**
* Close DB Connection
*
- * @access protected
- * @param resource
- * @return void
+ * @param resource
+ * @return void
*/
protected function _close($conn_id)
{
@oci_close($conn_id);
}
-
}
-
-
/* End of file oci8_driver.php */
-/* Location: ./system/database/drivers/oci8/oci8_driver.php */
+/* Location: ./system/database/drivers/oci8/oci8_driver.php */ \ No newline at end of file
diff --git a/system/database/drivers/oci8/oci8_forge.php b/system/database/drivers/oci8/oci8_forge.php
index 7fcc8094d..8285a29d2 100644
--- a/system/database/drivers/oci8/oci8_forge.php
+++ b/system/database/drivers/oci8/oci8_forge.php
@@ -1,13 +1,13 @@
-<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
* An open source application development framework for PHP 5.2.4 or newer
*
* NOTICE OF LICENSE
- *
+ *
* Licensed under the Open Software License version 3.0
- *
+ *
* This source file is subject to the Open Software License (OSL 3.0) that is
* bundled with this package in the files license.txt / license.rst. It is
* also available through the world wide web at this URL:
@@ -25,8 +25,6 @@
* @filesource
*/
-// ------------------------------------------------------------------------
-
/**
* Oracle Forge Class
*
@@ -39,11 +37,10 @@ class CI_DB_oci8_forge extends CI_DB_forge {
/**
* Create database
*
- * @access public
* @param string the database name
* @return bool
*/
- function _create_database($name)
+ public function _create_database($name)
{
return FALSE;
}
@@ -53,11 +50,10 @@ class CI_DB_oci8_forge extends CI_DB_forge {
/**
* Drop database
*
- * @access private
* @param string the database name
* @return bool
*/
- function _drop_database($name)
+ public function _drop_database($name)
{
return FALSE;
}
@@ -144,10 +140,9 @@ class CI_DB_oci8_forge extends CI_DB_forge {
/**
* Drop Table
*
- * @access private
* @return bool
*/
- function _drop_table($table)
+ public function _drop_table($table)
{
return FALSE;
}
@@ -160,17 +155,16 @@ class CI_DB_oci8_forge extends CI_DB_forge {
* Generates a platform-specific query so that a table can be altered
* Called by add_column(), drop_column(), and column_alter(),
*
- * @access private
* @param string the ALTER type (ADD, DROP, CHANGE)
* @param string the column name
* @param string the table name
* @param string the column definition
* @param string the default value
- * @param boolean should 'NOT NULL' be added
+ * @param bool should 'NOT NULL' be added
* @param string the field after which we should add the new field
- * @return object
+ * @return string
*/
- function _alter_table($alter_type, $table, $column_name, $column_definition = '', $default_value = '', $null = '', $after_field = '')
+ public function _alter_table($alter_type, $table, $column_name, $column_definition = '', $default_value = '', $null = '', $after_field = '')
{
$sql = 'ALTER TABLE '.$this->db->protect_identifiers($table).' '.$alter_type.' '.$this->db->protect_identifiers($column_name);
@@ -212,12 +206,11 @@ class CI_DB_oci8_forge extends CI_DB_forge {
*
* Generates a platform-specific query so that a table can be renamed
*
- * @access private
* @param string the old table name
* @param string the new table name
* @return string
*/
- function _rename_table($table_name, $new_table_name)
+ public function _rename_table($table_name, $new_table_name)
{
return 'ALTER TABLE '.$this->db->protect_identifiers($table_name).' RENAME TO '.$this->db->protect_identifiers($new_table_name);
}
@@ -225,4 +218,4 @@ class CI_DB_oci8_forge extends CI_DB_forge {
}
/* End of file oci8_forge.php */
-/* Location: ./system/database/drivers/oci8/oci8_forge.php */
+/* Location: ./system/database/drivers/oci8/oci8_forge.php */ \ No newline at end of file
diff --git a/system/database/drivers/oci8/oci8_result.php b/system/database/drivers/oci8/oci8_result.php
index 6f1b8b4c1..c3f775730 100644
--- a/system/database/drivers/oci8/oci8_result.php
+++ b/system/database/drivers/oci8/oci8_result.php
@@ -1,13 +1,13 @@
-<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
* An open source application development framework for PHP 5.2.4 or newer
*
* NOTICE OF LICENSE
- *
+ *
* Licensed under the Open Software License version 3.0
- *
+ *
* This source file is subject to the Open Software License (OSL 3.0) that is
* bundled with this package in the files license.txt / license.rst. It is
* also available through the world wide web at this URL:
@@ -25,8 +25,6 @@
* @filesource
*/
-// ------------------------------------------------------------------------
-
/**
* oci8 Result Class
*
@@ -57,9 +55,7 @@ class CI_DB_oci8_result extends CI_DB_result {
* Oracle doesn't have a graceful way to retun the number of rows
* so we have to use what amounts to a hack.
*
- *
- * @access public
- * @return integer
+ * @return int
*/
public function num_rows()
{
@@ -82,8 +78,7 @@ class CI_DB_oci8_result extends CI_DB_result {
/**
* Number of fields in the result set
*
- * @access public
- * @return integer
+ * @return int
*/
public function num_fields()
{
@@ -105,7 +100,6 @@ class CI_DB_oci8_result extends CI_DB_result {
*
* Generates an array of column names
*
- * @access public
* @return array
*/
public function list_fields()
@@ -125,8 +119,7 @@ class CI_DB_oci8_result extends CI_DB_result {
*
* Generates an array of objects containing field meta-data
*
- * @access public
- * @return array
+ * @return array
*/
public function field_data()
{
@@ -149,7 +142,7 @@ class CI_DB_oci8_result extends CI_DB_result {
/**
* Free the result
*
- * @return null
+ * @return void
*/
public function free_result()
{
@@ -167,8 +160,7 @@ class CI_DB_oci8_result extends CI_DB_result {
*
* Returns the result set as an array
*
- * @access protected
- * @return array
+ * @return array
*/
protected function _fetch_assoc()
{
@@ -183,8 +175,7 @@ class CI_DB_oci8_result extends CI_DB_result {
*
* Returns the result set as an object
*
- * @access protected
- * @return object
+ * @return object
*/
protected function _fetch_object()
{
@@ -197,8 +188,7 @@ class CI_DB_oci8_result extends CI_DB_result {
/**
* Query result. "array" version.
*
- * @access public
- * @return array
+ * @return array
*/
public function result_array()
{
@@ -221,11 +211,10 @@ class CI_DB_oci8_result extends CI_DB_result {
/**
* Data Seek
*
- * Moves the internal pointer to the desired offset. We call
+ * Moves the internal pointer to the desired offset. We call
* this internally before fetching results to make sure the
* result set starts at zero
*
- * @access protected
* @return array
*/
protected function _data_seek($n = 0)
@@ -235,6 +224,5 @@ class CI_DB_oci8_result extends CI_DB_result {
}
-
/* End of file oci8_result.php */
-/* Location: ./system/database/drivers/oci8/oci8_result.php */
+/* Location: ./system/database/drivers/oci8/oci8_result.php */ \ No newline at end of file
diff --git a/system/database/drivers/oci8/oci8_utility.php b/system/database/drivers/oci8/oci8_utility.php
index 62dfb2f3c..e303fb6cb 100644
--- a/system/database/drivers/oci8/oci8_utility.php
+++ b/system/database/drivers/oci8/oci8_utility.php
@@ -1,13 +1,13 @@
-<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
* An open source application development framework for PHP 5.2.4 or newer
*
* NOTICE OF LICENSE
- *
+ *
* Licensed under the Open Software License version 3.0
- *
+ *
* This source file is subject to the Open Software License (OSL 3.0) that is
* bundled with this package in the files license.txt / license.rst. It is
* also available through the world wide web at this URL:
@@ -25,8 +25,6 @@
* @filesource
*/
-// ------------------------------------------------------------------------
-
/**
* Oracle Utility Class
*
@@ -39,10 +37,9 @@ class CI_DB_oci8_utility extends CI_DB_utility {
/**
* List databases
*
- * @access private
* @return bool
*/
- function _list_databases()
+ public function _list_databases()
{
return FALSE;
}
@@ -54,11 +51,10 @@ class CI_DB_oci8_utility extends CI_DB_utility {
*
* Generates a platform-specific query so that a table can be optimized
*
- * @access private
* @param string the table name
- * @return object
+ * @return bool
*/
- function _optimize_table($table)
+ public function _optimize_table($table)
{
return FALSE; // Is this supported in Oracle?
}
@@ -70,11 +66,10 @@ class CI_DB_oci8_utility extends CI_DB_utility {
*
* Generates a platform-specific query so that a table can be repaired
*
- * @access private
* @param string the table name
- * @return object
+ * @return bool
*/
- function _repair_table($table)
+ public function _repair_table($table)
{
return FALSE; // Is this supported in Oracle?
}
@@ -84,15 +79,15 @@ class CI_DB_oci8_utility extends CI_DB_utility {
/**
* Oracle Export
*
- * @access private
* @param array Preferences
* @return mixed
*/
- function _backup($params = array())
+ public function _backup($params = array())
{
// Currently unsupported
return $this->db->display_error('db_unsuported_feature');
}
+
}
/* End of file oci8_utility.php */
diff --git a/system/database/drivers/odbc/odbc_driver.php b/system/database/drivers/odbc/odbc_driver.php
index acc2838e3..ed901bd81 100644
--- a/system/database/drivers/odbc/odbc_driver.php
+++ b/system/database/drivers/odbc/odbc_driver.php
@@ -1,13 +1,13 @@
-<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
* An open source application development framework for PHP 5.2.4 or newer
*
* NOTICE OF LICENSE
- *
+ *
* Licensed under the Open Software License version 3.0
- *
+ *
* This source file is subject to the Open Software License (OSL 3.0) that is
* bundled with this package in the files license.txt / license.rst. It is
* also available through the world wide web at this URL:
@@ -25,8 +25,6 @@
* @filesource
*/
-// ------------------------------------------------------------------------
-
/**
* ODBC Database Adapter Class
*
@@ -42,40 +40,44 @@
*/
class CI_DB_odbc_driver extends CI_DB {
- var $dbdriver = 'odbc';
+ public $dbdriver = 'odbc';
// the character used to excape - not necessary for ODBC
- var $_escape_char = '';
+ protected $_escape_char = '';
// clause and character used for LIKE escape sequences
- var $_like_escape_str = " {escape '%s'} ";
- var $_like_escape_chr = '!';
+ protected $_like_escape_str = " {escape '%s'} ";
+ protected $_like_escape_chr = '!';
/**
* The syntax to count rows is slightly different across different
* database engines, so this string appears in each driver and is
* used for the count_all() and count_all_results() functions.
*/
- var $_count_string = "SELECT COUNT(*) AS ";
- var $_random_keyword;
+ protected $_count_string = 'SELECT COUNT(*) AS ';
+ protected $_random_keyword;
-
- function __construct($params)
+ public function __construct($params)
{
parent::__construct($params);
$this->_random_keyword = ' RND('.time().')'; // database specific random keyword
+
+ // Legacy support for DSN in the hostname field
+ if ($this->dsn == '')
+ {
+ $this->dsn = $this->hostname;
+ }
}
/**
* Non-persistent database connection
*
- * @access private called by the base class
* @return resource
*/
- function db_connect()
+ public function db_connect()
{
- return @odbc_connect($this->hostname, $this->username, $this->password);
+ return @odbc_connect($this->dsn, $this->username, $this->password);
}
// --------------------------------------------------------------------
@@ -83,42 +85,11 @@ class CI_DB_odbc_driver extends CI_DB {
/**
* Persistent database connection
*
- * @access private called by the base class
* @return resource
*/
- function db_pconnect()
- {
- return @odbc_pconnect($this->hostname, $this->username, $this->password);
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Reconnect
- *
- * Keep / reestablish the db connection if no queries have been
- * sent for a length of time exceeding the server's idle timeout
- *
- * @access public
- * @return void
- */
- function reconnect()
+ public function db_pconnect()
{
- // not implemented in odbc
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Select the database
- *
- * @access private called by the base class
- * @return resource
- */
- function db_select()
- {
- // Not needed for ODBC
- return TRUE;
+ return @odbc_pconnect($this->dsn, $this->username, $this->password);
}
// --------------------------------------------------------------------
@@ -126,41 +97,22 @@ class CI_DB_odbc_driver extends CI_DB {
/**
* Execute the query
*
- * @access private called by the base class
* @param string an SQL query
* @return resource
*/
- function _execute($sql)
+ protected function _execute($sql)
{
- $sql = $this->_prep_query($sql);
return @odbc_exec($this->conn_id, $sql);
}
// --------------------------------------------------------------------
/**
- * Prep the query
- *
- * If needed, each database adapter can prep the query string
- *
- * @access private called by execute()
- * @param string an SQL query
- * @return string
- */
- function _prep_query($sql)
- {
- return $sql;
- }
-
- // --------------------------------------------------------------------
-
- /**
* Begin Transaction
*
- * @access public
* @return bool
*/
- function trans_begin($test_mode = FALSE)
+ public function trans_begin($test_mode = FALSE)
{
if ( ! $this->trans_enabled)
{
@@ -186,10 +138,9 @@ class CI_DB_odbc_driver extends CI_DB {
/**
* Commit Transaction
*
- * @access public
* @return bool
*/
- function trans_commit()
+ public function trans_commit()
{
if ( ! $this->trans_enabled)
{
@@ -212,10 +163,9 @@ class CI_DB_odbc_driver extends CI_DB {
/**
* Rollback Transaction
*
- * @access public
* @return bool
*/
- function trans_rollback()
+ public function trans_rollback()
{
if ( ! $this->trans_enabled)
{
@@ -238,12 +188,11 @@ class CI_DB_odbc_driver extends CI_DB {
/**
* Escape String
*
- * @access public
* @param string
* @param bool whether or not the string will be used in a LIKE condition
* @return string
*/
- function escape_str($str, $like = FALSE)
+ public function escape_str($str, $like = FALSE)
{
if (is_array($str))
{
@@ -261,9 +210,9 @@ class CI_DB_odbc_driver extends CI_DB {
// escape LIKE condition wildcards
if ($like === TRUE)
{
- $str = str_replace( array('%', '_', $this->_like_escape_chr),
- array($this->_like_escape_chr.'%', $this->_like_escape_chr.'_', $this->_like_escape_chr.$this->_like_escape_chr),
- $str);
+ return str_replace(array($this->_like_escape_chr, '%', '_'),
+ array($this->_like_escape_chr.$this->_like_escape_chr, $this->_like_escape_chr.'%', $this->_like_escape_chr.'_'),
+ $str);
}
return $str;
@@ -274,10 +223,9 @@ class CI_DB_odbc_driver extends CI_DB {
/**
* Affected Rows
*
- * @access public
- * @return integer
+ * @return int
*/
- function affected_rows()
+ public function affected_rows()
{
return @odbc_num_rows($this->conn_id);
}
@@ -302,11 +250,10 @@ class CI_DB_odbc_driver extends CI_DB {
* Generates a platform-specific query string that counts all records in
* the specified database
*
- * @access public
* @param string
* @return string
*/
- function count_all($table = '')
+ public function count_all($table = '')
{
if ($table == '')
{
@@ -332,11 +279,10 @@ class CI_DB_odbc_driver extends CI_DB {
*
* Generates a platform-specific query string so that the table names can be fetched
*
- * @access private
- * @param boolean
+ * @param bool
* @return string
*/
- function _list_tables($prefix_limit = FALSE)
+ protected function _list_tables($prefix_limit = FALSE)
{
$sql = "SHOW TABLES FROM `".$this->database."`";
@@ -356,11 +302,10 @@ class CI_DB_odbc_driver extends CI_DB {
*
* Generates a platform-specific query string so that the column names can be fetched
*
- * @access public
* @param string the table name
* @return string
*/
- function _list_columns($table = '')
+ protected function _list_columns($table = '')
{
return "SHOW COLUMNS FROM ".$table;
}
@@ -372,11 +317,10 @@ class CI_DB_odbc_driver extends CI_DB {
*
* Generates a platform-specific query so that the column data can be retrieved
*
- * @access public
* @param string the table name
- * @return object
+ * @return string
*/
- function _field_data($table)
+ protected function _field_data($table)
{
return "SELECT TOP 1 FROM ".$table;
}
@@ -403,11 +347,10 @@ class CI_DB_odbc_driver extends CI_DB {
*
* This function escapes column and table names
*
- * @access private
* @param string
* @return string
*/
- function _escape_identifiers($item)
+ public function _escape_identifiers($item)
{
if ($this->_escape_char == '')
{
@@ -446,11 +389,10 @@ class CI_DB_odbc_driver extends CI_DB {
* This function implicitly groups FROM tables so there is no confusion
* about operator precedence in harmony with SQL standards
*
- * @access public
- * @param type
- * @return type
+ * @param array
+ * @return string
*/
- function _from_tables($tables)
+ protected function _from_tables($tables)
{
if ( ! is_array($tables))
{
@@ -467,13 +409,12 @@ class CI_DB_odbc_driver extends CI_DB {
*
* Generates a platform-specific insert string from the supplied data
*
- * @access public
* @param string the table name
* @param array the insert keys
* @param array the insert values
* @return string
*/
- function _insert($table, $keys, $values)
+ protected function _insert($table, $keys, $values)
{
return "INSERT INTO ".$table." (".implode(', ', $keys).") VALUES (".implode(', ', $values).")";
}
@@ -485,7 +426,6 @@ class CI_DB_odbc_driver extends CI_DB {
*
* Generates a platform-specific update string from the supplied data
*
- * @access public
* @param string the table name
* @param array the update data
* @param array the where clause
@@ -493,7 +433,7 @@ class CI_DB_odbc_driver extends CI_DB {
* @param array the limit clause
* @return string
*/
- function _update($table, $values, $where, $orderby = array(), $limit = FALSE)
+ protected function _update($table, $values, $where, $orderby = array(), $limit = FALSE)
{
foreach ($values as $key => $val)
{
@@ -523,11 +463,10 @@ class CI_DB_odbc_driver extends CI_DB {
* If the database does not support the truncate() command
* This function maps to "DELETE FROM table"
*
- * @access public
* @param string the table name
* @return string
*/
- function _truncate($table)
+ protected function _truncate($table)
{
return $this->_delete($table);
}
@@ -539,13 +478,12 @@ class CI_DB_odbc_driver extends CI_DB {
*
* Generates a platform-specific delete string from the supplied data
*
- * @access public
* @param string the table name
* @param array the where clause
* @param string the limit clause
* @return string
*/
- function _delete($table, $where = array(), $like = array(), $limit = FALSE)
+ protected function _delete($table, $where = array(), $like = array(), $limit = FALSE)
{
$conditions = '';
@@ -573,13 +511,12 @@ class CI_DB_odbc_driver extends CI_DB {
*
* Generates a platform-specific LIMIT clause
*
- * @access public
* @param string the sql query string
- * @param integer the number of rows to limit the query to
- * @param integer the offset value
+ * @param int the number of rows to limit the query to
+ * @param int the offset value
* @return string
*/
- function _limit($sql, $limit, $offset)
+ protected function _limit($sql, $limit, $offset)
{
// Does ODBC doesn't use the LIMIT clause?
return $sql;
@@ -590,19 +527,15 @@ class CI_DB_odbc_driver extends CI_DB {
/**
* Close DB Connection
*
- * @access public
* @param resource
* @return void
*/
- function _close($conn_id)
+ protected function _close($conn_id)
{
@odbc_close($conn_id);
}
-
}
-
-
/* End of file odbc_driver.php */
-/* Location: ./system/database/drivers/odbc/odbc_driver.php */
+/* Location: ./system/database/drivers/odbc/odbc_driver.php */ \ No newline at end of file
diff --git a/system/database/drivers/odbc/odbc_forge.php b/system/database/drivers/odbc/odbc_forge.php
index acc2cadee..486a8dd7f 100644
--- a/system/database/drivers/odbc/odbc_forge.php
+++ b/system/database/drivers/odbc/odbc_forge.php
@@ -1,13 +1,13 @@
-<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
* An open source application development framework for PHP 5.2.4 or newer
*
* NOTICE OF LICENSE
- *
+ *
* Licensed under the Open Software License version 3.0
- *
+ *
* This source file is subject to the Open Software License (OSL 3.0) that is
* bundled with this package in the files license.txt / license.rst. It is
* also available through the world wide web at this URL:
@@ -25,8 +25,6 @@
* @filesource
*/
-// ------------------------------------------------------------------------
-
/**
* ODBC Forge Class
*
@@ -39,11 +37,10 @@ class CI_DB_odbc_forge extends CI_DB_forge {
/**
* Create database
*
- * @access private
* @param string the database name
* @return bool
*/
- function _create_database()
+ public function _create_database()
{
// ODBC has no "create database" command since it's
// designed to connect to an existing database
@@ -59,11 +56,10 @@ class CI_DB_odbc_forge extends CI_DB_forge {
/**
* Drop database
*
- * @access private
* @param string the database name
* @return bool
*/
- function _drop_database($name)
+ public function _drop_database($name)
{
// ODBC has no "drop database" command since it's
// designed to connect to an existing database
@@ -79,15 +75,14 @@ class CI_DB_odbc_forge extends CI_DB_forge {
/**
* Create Table
*
- * @access private
* @param string the table name
* @param array the fields
* @param mixed primary key(s)
* @param mixed key(s)
- * @param boolean should 'IF NOT EXISTS' be added to the SQL
+ * @param bool should 'IF NOT EXISTS' be added to the SQL
* @return bool
*/
- function _create_table($table, $fields, $primary_keys, $keys, $if_not_exists)
+ public function _create_table($table, $fields, $primary_keys, $keys, $if_not_exists)
{
$sql = 'CREATE TABLE ';
@@ -99,7 +94,7 @@ class CI_DB_odbc_forge extends CI_DB_forge {
$sql .= $this->db->_escape_identifiers($table)." (";
$current_field_count = 0;
- foreach ($fields as $field=>$attributes)
+ foreach ($fields as $field => $attributes)
{
// Numeric field names aren't allowed in databases, so if the key is
// numeric, we know it was assigned by PHP and the developer manually
@@ -186,10 +181,9 @@ class CI_DB_odbc_forge extends CI_DB_forge {
/**
* Drop Table
*
- * @access private
* @return bool
*/
- function _drop_table($table)
+ public function _drop_table($table)
{
// Not a supported ODBC feature
if ($this->db->db_debug)
@@ -207,17 +201,16 @@ class CI_DB_odbc_forge extends CI_DB_forge {
* Generates a platform-specific query so that a table can be altered
* Called by add_column(), drop_column(), and column_alter(),
*
- * @access private
* @param string the ALTER type (ADD, DROP, CHANGE)
* @param string the column name
* @param string the table name
* @param string the column definition
* @param string the default value
- * @param boolean should 'NOT NULL' be added
+ * @param bool should 'NOT NULL' be added
* @param string the field after which we should add the new field
- * @return object
+ * @return string
*/
- function _alter_table($alter_type, $table, $column_name, $column_definition = '', $default_value = '', $null = '', $after_field = '')
+ public function _alter_table($alter_type, $table, $column_name, $column_definition = '', $default_value = '', $null = '', $after_field = '')
{
$sql = 'ALTER TABLE '.$this->db->protect_identifiers($table).' '.$alter_type.' '.$this->db->protect_identifiers($column_name);
@@ -260,12 +253,11 @@ class CI_DB_odbc_forge extends CI_DB_forge {
*
* Generates a platform-specific query so that a table can be renamed
*
- * @access private
* @param string the old table name
* @param string the new table name
* @return string
*/
- function _rename_table($table_name, $new_table_name)
+ public function _rename_table($table_name, $new_table_name)
{
return 'ALTER TABLE '.$this->db->protect_identifiers($table_name).' RENAME TO '.$this->db->protect_identifiers($new_table_name);
}
@@ -273,4 +265,4 @@ class CI_DB_odbc_forge extends CI_DB_forge {
}
/* End of file odbc_forge.php */
-/* Location: ./system/database/drivers/odbc/odbc_forge.php */
+/* Location: ./system/database/drivers/odbc/odbc_forge.php */ \ No newline at end of file
diff --git a/system/database/drivers/odbc/odbc_result.php b/system/database/drivers/odbc/odbc_result.php
index d19fa247e..30cc979ce 100644
--- a/system/database/drivers/odbc/odbc_result.php
+++ b/system/database/drivers/odbc/odbc_result.php
@@ -1,13 +1,13 @@
-<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
* An open source application development framework for PHP 5.2.4 or newer
*
* NOTICE OF LICENSE
- *
+ *
* Licensed under the Open Software License version 3.0
- *
+ *
* This source file is subject to the Open Software License (OSL 3.0) that is
* bundled with this package in the files license.txt / license.rst. It is
* also available through the world wide web at this URL:
@@ -25,8 +25,6 @@
* @filesource
*/
-// ------------------------------------------------------------------------
-
/**
* ODBC Result Class
*
@@ -128,9 +126,9 @@ class CI_DB_odbc_result extends CI_DB_result {
/**
* Free the result
*
- * @return null
+ * @return void
*/
- function free_result()
+ public function free_result()
{
if (is_resource($this->result_id))
{
@@ -148,10 +146,9 @@ class CI_DB_odbc_result extends CI_DB_result {
* this internally before fetching results to make sure the
* result set starts at zero
*
- * @access private
- * @return array
+ * @return bool
*/
- function _data_seek($n = 0)
+ protected function _data_seek($n = 0)
{
return FALSE;
}
@@ -163,12 +160,11 @@ class CI_DB_odbc_result extends CI_DB_result {
*
* Returns the result set as an array
*
- * @access private
* @return array
*/
- function _fetch_assoc()
+ protected function _fetch_assoc()
{
- if (function_exists('odbc_fetch_object'))
+ if (function_exists('odbc_fetch_array'))
{
return odbc_fetch_array($this->result_id);
}
@@ -185,10 +181,9 @@ class CI_DB_odbc_result extends CI_DB_result {
*
* Returns the result set as an object
*
- * @access private
* @return object
*/
- function _fetch_object()
+ protected function _fetch_object()
{
if (function_exists('odbc_fetch_object'))
{
@@ -200,6 +195,7 @@ class CI_DB_odbc_result extends CI_DB_result {
}
}
+ // --------------------------------------------------------------------
/**
* Result - object
@@ -207,21 +203,24 @@ class CI_DB_odbc_result extends CI_DB_result {
* subsititutes the odbc_fetch_object function when
* not available (odbc_fetch_object requires unixODBC)
*
- * @access private
* @return object
*/
- function _odbc_fetch_object(& $odbc_result) {
+ protected function _odbc_fetch_object(& $odbc_result)
+ {
$rs = array();
$rs_obj = FALSE;
- if (odbc_fetch_into($odbc_result, $rs)) {
- foreach ($rs as $k=>$v) {
- $field_name= odbc_field_name($odbc_result, $k+1);
+ if (odbc_fetch_into($odbc_result, $rs))
+ {
+ foreach ($rs as $k => $v)
+ {
+ $field_name = odbc_field_name($odbc_result, $k+1);
$rs_obj->$field_name = $v;
}
}
return $rs_obj;
}
+ // --------------------------------------------------------------------
/**
* Result - array
@@ -229,16 +228,18 @@ class CI_DB_odbc_result extends CI_DB_result {
* subsititutes the odbc_fetch_array function when
* not available (odbc_fetch_array requires unixODBC)
*
- * @access private
* @return array
*/
- function _odbc_fetch_array(& $odbc_result) {
+ protected function _odbc_fetch_array(& $odbc_result)
+ {
$rs = array();
$rs_assoc = FALSE;
- if (odbc_fetch_into($odbc_result, $rs)) {
- $rs_assoc=array();
- foreach ($rs as $k=>$v) {
- $field_name= odbc_field_name($odbc_result, $k+1);
+ if (odbc_fetch_into($odbc_result, $rs))
+ {
+ $rs_assoc = array();
+ foreach ($rs as $k => $v)
+ {
+ $field_name = odbc_field_name($odbc_result, $k+1);
$rs_assoc[$field_name] = $v;
}
}
@@ -318,4 +319,4 @@ class CI_DB_odbc_result extends CI_DB_result {
}
/* End of file odbc_result.php */
-/* Location: ./system/database/drivers/odbc/odbc_result.php */
+/* Location: ./system/database/drivers/odbc/odbc_result.php */ \ No newline at end of file
diff --git a/system/database/drivers/odbc/odbc_utility.php b/system/database/drivers/odbc/odbc_utility.php
index c146c1785..65445e96c 100644
--- a/system/database/drivers/odbc/odbc_utility.php
+++ b/system/database/drivers/odbc/odbc_utility.php
@@ -1,13 +1,13 @@
-<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
* An open source application development framework for PHP 5.2.4 or newer
*
* NOTICE OF LICENSE
- *
+ *
* Licensed under the Open Software License version 3.0
- *
+ *
* This source file is subject to the Open Software License (OSL 3.0) that is
* bundled with this package in the files license.txt / license.rst. It is
* also available through the world wide web at this URL:
@@ -25,8 +25,6 @@
* @filesource
*/
-// ------------------------------------------------------------------------
-
/**
* ODBC Utility Class
*
@@ -39,10 +37,9 @@ class CI_DB_odbc_utility extends CI_DB_utility {
/**
* List databases
*
- * @access private
* @return bool
*/
- function _list_databases()
+ public function _list_databases()
{
// Not sure if ODBC lets you list all databases...
if ($this->db->db_debug)
@@ -59,11 +56,10 @@ class CI_DB_odbc_utility extends CI_DB_utility {
*
* Generates a platform-specific query so that a table can be optimized
*
- * @access private
* @param string the table name
- * @return object
+ * @return bool
*/
- function _optimize_table($table)
+ public function _optimize_table($table)
{
// Not a supported ODBC feature
if ($this->db->db_debug)
@@ -80,11 +76,10 @@ class CI_DB_odbc_utility extends CI_DB_utility {
*
* Generates a platform-specific query so that a table can be repaired
*
- * @access private
* @param string the table name
- * @return object
+ * @return bool
*/
- function _repair_table($table)
+ public function _repair_table($table)
{
// Not a supported ODBC feature
if ($this->db->db_debug)
@@ -99,11 +94,10 @@ class CI_DB_odbc_utility extends CI_DB_utility {
/**
* ODBC Export
*
- * @access private
* @param array Preferences
* @return mixed
*/
- function _backup($params = array())
+ public function _backup($params = array())
{
// Currently unsupported
return $this->db->display_error('db_unsuported_feature');
diff --git a/system/database/drivers/pdo/pdo_driver.php b/system/database/drivers/pdo/pdo_driver.php
index 09764779a..a9bed367e 100644
--- a/system/database/drivers/pdo/pdo_driver.php
+++ b/system/database/drivers/pdo/pdo_driver.php
@@ -1,13 +1,13 @@
-<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
* An open source application development framework for PHP 5.2.4 or newer
*
* NOTICE OF LICENSE
- *
+ *
* Licensed under the Open Software License version 3.0
- *
+ *
* This source file is subject to the Open Software License (OSL 3.0) that is
* bundled with this package in the files license.txt / license.rst. It is
* also available through the world wide web at this URL:
@@ -25,8 +25,6 @@
* @filesource
*/
-// ------------------------------------------------------------------------
-
/**
* PDO Database Adapter Class
*
@@ -42,28 +40,28 @@
*/
class CI_DB_pdo_driver extends CI_DB {
- var $dbdriver = 'pdo';
+ public $dbdriver = 'pdo';
// the character used to excape - not necessary for PDO
- var $_escape_char = '';
+ protected $_escape_char = '';
// clause and character used for LIKE escape sequences
- var $_like_escape_str;
- var $_like_escape_chr;
+ protected $_like_escape_str;
+ protected $_like_escape_chr;
/**
* The syntax to count rows is slightly different across different
* database engines, so this string appears in each driver and is
* used for the count_all() and count_all_results() functions.
*/
- var $_count_string = "SELECT COUNT(*) AS ";
- var $_random_keyword;
+ protected $_count_string = 'SELECT COUNT(*) AS ';
+ protected $_random_keyword;
// need to track the pdo driver and options
- var $pdodriver;
- var $options = array();
+ public $pdodriver;
+ public $options = array();
- function __construct($params)
+ public function __construct($params)
{
parent::__construct($params);
@@ -96,19 +94,18 @@ class CI_DB_pdo_driver extends CI_DB {
$this->_like_escape_str = " ESCAPE '%s' ";
$this->_like_escape_chr = '!';
}
-
- $this->trans_enabled = FALSE;
+
+ $this->trans_enabled = FALSE;
$this->_random_keyword = ' RND('.time().')'; // database specific random keyword
}
/**
* Connection String
*
- * @access private
* @param array
* @return void
*/
- function _connect_string($params)
+ protected function _connect_string($params)
{
if (strpos($this->hostname, ':'))
{
@@ -138,7 +135,7 @@ class CI_DB_pdo_driver extends CI_DB {
$this->dsn = $this->pdodriver.':';
// Add hostname to the DSN for databases that need it
- if ( ! empty($this->hostname)
+ if ( ! empty($this->hostname)
&& strpos($this->hostname, ':') === FALSE
&& in_array($this->pdodriver, array('informix', 'mysql', 'pgsql', 'sybase', 'mssql', 'dblib', 'cubrid')))
{
@@ -153,7 +150,7 @@ class CI_DB_pdo_driver extends CI_DB {
}
// Add the database name to the DSN, if needed
- if (stripos($this->dsn, 'dbname') === FALSE
+ if (stripos($this->dsn, 'dbname') === FALSE
&& in_array($this->pdodriver, array('4D', 'pgsql', 'mysql', 'firebird', 'sybase', 'mssql', 'dblib', 'cubrid')))
{
$this->dsn .= 'dbname='.$this->database.';';
@@ -190,10 +187,9 @@ class CI_DB_pdo_driver extends CI_DB {
/**
* Non-persistent database connection
*
- * @access private called by the base class
- * @return resource
+ * @return object
*/
- function db_connect()
+ public function db_connect()
{
$this->options[PDO::ATTR_ERRMODE] = PDO::ERRMODE_SILENT;
@@ -205,14 +201,13 @@ class CI_DB_pdo_driver extends CI_DB {
/**
* Persistent database connection
*
- * @access private called by the base class
- * @return resource
+ * @return object
*/
- function db_pconnect()
+ public function db_pconnect()
{
- $this->options[PDO::ATTR_ERRMODE] = PDO::ERRMODE_SILENT;
+ $this->options[PDO::ATTR_ERRMODE] = PDO::ERRMODE_SILENT;
$this->options[PDO::ATTR_PERSISTENT] = TRUE;
-
+
return $this->pdo_connect();
}
@@ -221,23 +216,22 @@ class CI_DB_pdo_driver extends CI_DB {
/**
* PDO connection
*
- * @access private called by the PDO driver class
- * @return resource
+ * @return object
*/
- function pdo_connect()
+ public function pdo_connect()
{
// Refer : http://php.net/manual/en/ref.pdo-mysql.connection.php
- if ($this->pdodriver == 'mysql' && is_php('5.3.6'))
+ if ($this->pdodriver === 'mysql' && ! is_php('5.3.6'))
{
$this->options[PDO::MYSQL_ATTR_INIT_COMMAND] = "SET NAMES $this->char_set COLLATE '$this->dbcollat'";
}
// Connecting...
- try
+ try
{
$db = new PDO($this->dsn, $this->username, $this->password, $this->options);
- }
- catch (PDOException $e)
+ }
+ catch (PDOException $e)
{
if ($this->db_debug && empty($this->failover))
{
@@ -253,41 +247,6 @@ class CI_DB_pdo_driver extends CI_DB {
// --------------------------------------------------------------------
/**
- * Reconnect
- *
- * Keep / reestablish the db connection if no queries have been
- * sent for a length of time exceeding the server's idle timeout
- *
- * @access public
- * @return void
- */
- function reconnect()
- {
- if ($this->db->db_debug)
- {
- return $this->db->display_error('db_unsuported_feature');
- }
-
- return FALSE;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Select the database
- *
- * @access private called by the base class
- * @return resource
- */
- function db_select()
- {
- // Not needed for PDO
- return TRUE;
- }
-
- // --------------------------------------------------------------------
-
- /**
* Database version number
*
* @return string
@@ -304,16 +263,15 @@ class CI_DB_pdo_driver extends CI_DB {
/**
* Execute the query
*
- * @access private called by the base class
* @param string an SQL query
- * @return object
+ * @return mixed
*/
- function _execute($sql)
+ protected function _execute($sql)
{
$sql = $this->_prep_query($sql);
$result_id = $this->conn_id->query($sql);
-
+
if (is_object($result_id))
{
$this->affect_rows = $result_id->rowCount();
@@ -322,7 +280,7 @@ class CI_DB_pdo_driver extends CI_DB {
{
$this->affect_rows = 0;
}
-
+
return $result_id;
}
@@ -333,11 +291,10 @@ class CI_DB_pdo_driver extends CI_DB {
*
* If needed, each database adapter can prep the query string
*
- * @access private called by execute()
* @param string an SQL query
* @return string
*/
- function _prep_query($sql)
+ protected function _prep_query($sql)
{
if ($this->pdodriver === 'pgsql')
{
@@ -358,10 +315,9 @@ class CI_DB_pdo_driver extends CI_DB {
/**
* Begin Transaction
*
- * @access public
* @return bool
*/
- function trans_begin($test_mode = FALSE)
+ public function trans_begin($test_mode = FALSE)
{
if ( ! $this->trans_enabled)
{
@@ -387,10 +343,9 @@ class CI_DB_pdo_driver extends CI_DB {
/**
* Commit Transaction
*
- * @access public
* @return bool
*/
- function trans_commit()
+ public function trans_commit()
{
if ( ! $this->trans_enabled)
{
@@ -404,7 +359,7 @@ class CI_DB_pdo_driver extends CI_DB {
}
$ret = $this->conn->commit();
-
+
return $ret;
}
@@ -413,10 +368,9 @@ class CI_DB_pdo_driver extends CI_DB {
/**
* Rollback Transaction
*
- * @access public
* @return bool
*/
- function trans_rollback()
+ public function trans_rollback()
{
if ( ! $this->trans_enabled)
{
@@ -439,12 +393,11 @@ class CI_DB_pdo_driver extends CI_DB {
/**
* Escape String
*
- * @access public
* @param string
* @param bool whether or not the string will be used in a LIKE condition
* @return string
*/
- function escape_str($str, $like = FALSE)
+ public function escape_str($str, $like = FALSE)
{
if (is_array($str))
{
@@ -455,24 +408,22 @@ class CI_DB_pdo_driver extends CI_DB {
return $str;
}
-
+
//Escape the string
$str = $this->conn_id->quote($str);
-
+
//If there are duplicated quotes, trim them away
if (strpos($str, "'") === 0)
{
$str = substr($str, 1, -1);
}
-
+
// escape LIKE condition wildcards
if ($like === TRUE)
{
- $str = str_replace( array('%', '_', $this->_like_escape_chr),
- array($this->_like_escape_chr.'%',
- $this->_like_escape_chr.'_',
- $this->_like_escape_chr.$this->_like_escape_chr),
- $str);
+ return str_replace(array($this->_like_escape_chr, '%', '_'),
+ array($this->_like_escape_chr.$this->_like_escape_chr, $this->_like_escape_chr.'%', $this->_like_escape_chr.'_'),
+ $str);
}
return $str;
@@ -483,10 +434,9 @@ class CI_DB_pdo_driver extends CI_DB {
/**
* Affected Rows
*
- * @access public
- * @return integer
+ * @return int
*/
- function affected_rows()
+ public function affected_rows()
{
return $this->affect_rows;
}
@@ -518,11 +468,10 @@ class CI_DB_pdo_driver extends CI_DB {
* Generates a platform-specific query string that counts all records in
* the specified database
*
- * @access public
* @param string
* @return string
*/
- function count_all($table = '')
+ public function count_all($table = '')
{
if ($table == '')
{
@@ -550,17 +499,21 @@ class CI_DB_pdo_driver extends CI_DB {
*
* Generates a platform-specific query string so that the table names can be fetched
*
- * @access private
- * @param boolean
+ * @param bool
* @return string
*/
- function _list_tables($prefix_limit = FALSE)
+ protected function _list_tables($prefix_limit = FALSE)
{
if ($this->pdodriver == 'pgsql')
{
// Analog function to show all tables in postgre
$sql = "SELECT * FROM information_schema.tables WHERE table_schema = 'public'";
}
+ elseif ($this->pdodriver == 'sqlite')
+ {
+ // Analog function to show all tables in sqlite
+ $sql = "SELECT name FROM sqlite_master WHERE type='table' AND name NOT LIKE 'sqlite_%'";
+ }
else
{
$sql = "SHOW TABLES FROM `".$this->database."`";
@@ -568,7 +521,7 @@ class CI_DB_pdo_driver extends CI_DB {
if ($prefix_limit !== FALSE AND $this->dbprefix != '')
{
- return FALSE;
+ return FALSE;
}
return $sql;
@@ -581,11 +534,10 @@ class CI_DB_pdo_driver extends CI_DB {
*
* Generates a platform-specific query string so that the column names can be fetched
*
- * @access public
* @param string the table name
* @return string
*/
- function _list_columns($table = '')
+ protected function _list_columns($table = '')
{
return 'SHOW COLUMNS FROM '.$this->_from_tables($table);
}
@@ -597,12 +549,27 @@ class CI_DB_pdo_driver extends CI_DB {
*
* Generates a platform-specific query so that the column data can be retrieved
*
- * @access public
* @param string the table name
- * @return object
+ * @return string
*/
- function _field_data($table)
+ protected function _field_data($table)
{
+ if ($this->pdodriver == 'mysql' or $this->pdodriver == 'pgsql')
+ {
+ // Analog function for mysql and postgre
+ return 'SELECT * FROM '.$this->_from_tables($table).' LIMIT 1';
+ }
+ elseif ($this->pdodriver == 'oci')
+ {
+ // Analog function for oci
+ return 'SELECT * FROM '.$this->_from_tables($table).' WHERE ROWNUM <= 1';
+ }
+ elseif ($this->pdodriver == 'sqlite')
+ {
+ // Analog function for sqlite
+ return 'PRAGMA table_info('.$this->_from_tables($table).')';
+ }
+
return 'SELECT TOP 1 FROM '.$this->_from_tables($table);
}
@@ -642,11 +609,10 @@ class CI_DB_pdo_driver extends CI_DB {
*
* This function escapes column and table names
*
- * @access private
* @param string
* @return string
*/
- function _escape_identifiers($item)
+ public function _escape_identifiers($item)
{
if ($this->_escape_char == '')
{
@@ -686,11 +652,10 @@ class CI_DB_pdo_driver extends CI_DB {
* This function implicitly groups FROM tables so there is no confusion
* about operator precedence in harmony with SQL standards
*
- * @access public
- * @param type
- * @return type
+ * @param array
+ * @return string
*/
- function _from_tables($tables)
+ protected function _from_tables($tables)
{
if ( ! is_array($tables))
{
@@ -707,17 +672,16 @@ class CI_DB_pdo_driver extends CI_DB {
*
* Generates a platform-specific insert string from the supplied data
*
- * @access public
* @param string the table name
* @param array the insert keys
* @param array the insert values
* @return string
*/
- function _insert($table, $keys, $values)
+ protected function _insert($table, $keys, $values)
{
return 'INSERT INTO '.$this->_from_tables($table).' ('.implode(', ', $keys).') VALUES ('.implode(', ', $values).')';
}
-
+
// --------------------------------------------------------------------
/**
@@ -725,13 +689,12 @@ class CI_DB_pdo_driver extends CI_DB {
*
* Generates a platform-specific insert string from the supplied data
*
- * @access public
- * @param string the table name
- * @param array the insert keys
- * @param array the insert values
- * @return string
+ * @param string the table name
+ * @param array the insert keys
+ * @param array the insert values
+ * @return string
*/
- function _insert_batch($table, $keys, $values)
+ protected function _insert_batch($table, $keys, $values)
{
return 'INSERT INTO '.$this->_from_tables($table).' ('.implode(', ', $keys).') VALUES '.implode(', ', $values);
}
@@ -743,7 +706,6 @@ class CI_DB_pdo_driver extends CI_DB {
*
* Generates a platform-specific update string from the supplied data
*
- * @access public
* @param string the table name
* @param array the update data
* @param array the where clause
@@ -751,7 +713,7 @@ class CI_DB_pdo_driver extends CI_DB {
* @param array the limit clause
* @return string
*/
- function _update($table, $values, $where, $orderby = array(), $limit = FALSE)
+ protected function _update($table, $values, $where, $orderby = array(), $limit = FALSE)
{
foreach ($values as $key => $val)
{
@@ -767,7 +729,7 @@ class CI_DB_pdo_driver extends CI_DB {
return $sql;
}
-
+
// --------------------------------------------------------------------
/**
@@ -775,13 +737,12 @@ class CI_DB_pdo_driver extends CI_DB {
*
* Generates a platform-specific batch update string from the supplied data
*
- * @access public
* @param string the table name
* @param array the update data
* @param array the where clause
* @return string
*/
- function _update_batch($table, $values, $index, $where = NULL)
+ protected function _update_batch($table, $values, $index, $where = NULL)
{
$ids = array();
$where = ($where != '' && count($where) >=1) ? implode(" ", $where).' AND ' : '';
@@ -820,7 +781,6 @@ class CI_DB_pdo_driver extends CI_DB {
return $sql;
}
-
// --------------------------------------------------------------------
/**
@@ -830,11 +790,10 @@ class CI_DB_pdo_driver extends CI_DB {
* If the database does not support the truncate() command
* This function maps to "DELETE FROM table"
*
- * @access public
* @param string the table name
* @return string
*/
- function _truncate($table)
+ protected function _truncate($table)
{
return $this->_delete($table);
}
@@ -846,13 +805,12 @@ class CI_DB_pdo_driver extends CI_DB {
*
* Generates a platform-specific delete string from the supplied data
*
- * @access public
* @param string the table name
* @param array the where clause
* @param string the limit clause
* @return string
*/
- function _delete($table, $where = array(), $like = array(), $limit = FALSE)
+ protected function _delete($table, $where = array(), $like = array(), $limit = FALSE)
{
$conditions = '';
@@ -881,13 +839,12 @@ class CI_DB_pdo_driver extends CI_DB {
*
* Generates a platform-specific LIMIT clause
*
- * @access public
* @param string the sql query string
- * @param integer the number of rows to limit the query to
- * @param integer the offset value
+ * @param int the number of rows to limit the query to
+ * @param int the offset value
* @return string
*/
- function _limit($sql, $limit, $offset)
+ protected function _limit($sql, $limit, $offset)
{
if ($this->pdodriver == 'cubrid' OR $this->pdodriver == 'sqlite')
{
@@ -899,7 +856,7 @@ class CI_DB_pdo_driver extends CI_DB {
{
$sql .= 'LIMIT '.$limit;
$sql .= ($offset > 0) ? ' OFFSET '.$offset : '';
-
+
return $sql;
}
}
@@ -909,11 +866,10 @@ class CI_DB_pdo_driver extends CI_DB {
/**
* Close DB Connection
*
- * @access public
* @param resource
* @return void
*/
- function _close($conn_id)
+ protected function _close($conn_id)
{
$this->conn_id = null;
}
@@ -921,4 +877,4 @@ class CI_DB_pdo_driver extends CI_DB {
}
/* End of file pdo_driver.php */
-/* Location: ./system/database/drivers/pdo/pdo_driver.php */
+/* Location: ./system/database/drivers/pdo/pdo_driver.php */ \ No newline at end of file
diff --git a/system/database/drivers/pdo/pdo_forge.php b/system/database/drivers/pdo/pdo_forge.php
index 87b638570..6bff3542f 100644
--- a/system/database/drivers/pdo/pdo_forge.php
+++ b/system/database/drivers/pdo/pdo_forge.php
@@ -1,13 +1,13 @@
-<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
* An open source application development framework for PHP 5.2.4 or newer
*
* NOTICE OF LICENSE
- *
+ *
* Licensed under the Open Software License version 3.0
- *
+ *
* This source file is subject to the Open Software License (OSL 3.0) that is
* bundled with this package in the files license.txt / license.rst. It is
* also available through the world wide web at this URL:
@@ -25,8 +25,6 @@
* @filesource
*/
-// ------------------------------------------------------------------------
-
/**
* PDO Forge Class
*
@@ -39,11 +37,10 @@ class CI_DB_pdo_forge extends CI_DB_forge {
/**
* Create database
*
- * @access private
* @param string the database name
* @return bool
*/
- function _create_database()
+ public function _create_database()
{
// PDO has no "create database" command since it's
// designed to connect to an existing database
@@ -59,11 +56,10 @@ class CI_DB_pdo_forge extends CI_DB_forge {
/**
* Drop database
*
- * @access private
* @param string the database name
* @return bool
*/
- function _drop_database($name)
+ public function _drop_database($name)
{
// PDO has no "drop database" command since it's
// designed to connect to an existing database
@@ -79,15 +75,14 @@ class CI_DB_pdo_forge extends CI_DB_forge {
/**
* Create Table
*
- * @access private
* @param string the table name
* @param array the fields
* @param mixed primary key(s)
* @param mixed key(s)
- * @param boolean should 'IF NOT EXISTS' be added to the SQL
+ * @param bool should 'IF NOT EXISTS' be added to the SQL
* @return bool
*/
- function _create_table($table, $fields, $primary_keys, $keys, $if_not_exists)
+ public function _create_table($table, $fields, $primary_keys, $keys, $if_not_exists)
{
$sql = 'CREATE TABLE ';
@@ -191,10 +186,9 @@ class CI_DB_pdo_forge extends CI_DB_forge {
/**
* Drop Table
*
- * @access private
* @return bool
*/
- function _drop_table($table)
+ public function _drop_table($table)
{
// Not a supported PDO feature
if ($this->db->db_debug)
@@ -212,17 +206,16 @@ class CI_DB_pdo_forge extends CI_DB_forge {
* Generates a platform-specific query so that a table can be altered
* Called by add_column(), drop_column(), and column_alter(),
*
- * @access private
* @param string the ALTER type (ADD, DROP, CHANGE)
* @param string the column name
* @param string the table name
* @param string the column definition
* @param string the default value
- * @param boolean should 'NOT NULL' be added
+ * @param bool should 'NOT NULL' be added
* @param string the field after which we should add the new field
- * @return object
+ * @return string
*/
- function _alter_table($alter_type, $table, $column_name, $column_definition = '', $default_value = '', $null = '', $after_field = '')
+ public function _alter_table($alter_type, $table, $column_name, $column_definition = '', $default_value = '', $null = '', $after_field = '')
{
$sql = 'ALTER TABLE `'.$this->db->protect_identifiers($table).'` '.$alter_type.' '.$this->db->protect_identifiers($column_name);
@@ -265,12 +258,11 @@ class CI_DB_pdo_forge extends CI_DB_forge {
*
* Generates a platform-specific query so that a table can be renamed
*
- * @access private
* @param string the old table name
* @param string the new table name
* @return string
*/
- function _rename_table($table_name, $new_table_name)
+ public function _rename_table($table_name, $new_table_name)
{
return 'ALTER TABLE '.$this->db->protect_identifiers($table_name).' RENAME TO '.$this->db->protect_identifiers($new_table_name);
}
@@ -278,4 +270,4 @@ class CI_DB_pdo_forge extends CI_DB_forge {
}
/* End of file pdo_forge.php */
-/* Location: ./system/database/drivers/pdo/pdo_forge.php */
+/* Location: ./system/database/drivers/pdo/pdo_forge.php */ \ No newline at end of file
diff --git a/system/database/drivers/pdo/pdo_result.php b/system/database/drivers/pdo/pdo_result.php
index 309f1947d..5bbd85d75 100644
--- a/system/database/drivers/pdo/pdo_result.php
+++ b/system/database/drivers/pdo/pdo_result.php
@@ -1,13 +1,13 @@
-<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
* An open source application development framework for PHP 5.2.4 or newer
*
* NOTICE OF LICENSE
- *
+ *
* Licensed under the Open Software License version 3.0
- *
+ *
* This source file is subject to the Open Software License (OSL 3.0) that is
* bundled with this package in the files license.txt / license.rst. It is
* also available through the world wide web at this URL:
@@ -25,8 +25,6 @@
* @filesource
*/
-// ------------------------------------------------------------------------
-
/**
* PDO Result Class
*
@@ -51,10 +49,9 @@ class CI_DB_pdo_result extends CI_DB_result {
/**
* Number of rows in the result set
*
- * @access public
- * @return integer
+ * @return int
*/
- function num_rows()
+ public function num_rows()
{
if (empty($this->result_id) OR ! is_object($this->result_id))
{
@@ -74,10 +71,9 @@ class CI_DB_pdo_result extends CI_DB_result {
/**
* Fetch the result handler
*
- * @access public
* @return mixed
*/
- function result_assoc()
+ public function result_assoc()
{
// If the result already fetched before, use that one
if (count($this->result_array) > 0 OR $this->is_fetched)
@@ -94,7 +90,7 @@ class CI_DB_pdo_result extends CI_DB_result {
// Define the method and handler
$res_method = '_fetch_'.$type;
$res_handler = 'result_'.$type;
-
+
$this->$res_handler = array();
$this->_data_seek(0);
@@ -116,10 +112,9 @@ class CI_DB_pdo_result extends CI_DB_result {
/**
* Number of fields in the result set
*
- * @access public
- * @return integer
+ * @return int
*/
- function num_fields()
+ public function num_fields()
{
return $this->result_id->columnCount();
}
@@ -131,16 +126,15 @@ class CI_DB_pdo_result extends CI_DB_result {
*
* Generates an array of column names
*
- * @access public
- * @return array
+ * @return bool
*/
- function list_fields()
+ public function list_fields()
{
if ($this->db->db_debug)
{
return $this->db->display_error('db_unsuported_feature');
}
-
+
return FALSE;
}
@@ -151,20 +145,58 @@ class CI_DB_pdo_result extends CI_DB_result {
*
* Generates an array of objects containing field meta-data
*
- * @access public
* @return array
*/
- function field_data()
+ public function field_data()
{
$data = array();
-
+
try
{
- for($i = 0; $i < $this->num_fields(); $i++)
+ if (strpos($this->result_id->queryString, 'PRAGMA') !== FALSE)
{
- $data[] = $this->result_id->getColumnMeta($i);
+ foreach ($this->result_array() as $field)
+ {
+ preg_match('/([a-zA-Z]+)(\(\d+\))?/', $field['type'], $matches);
+
+ $F = new stdClass();
+ $F->name = $field['name'];
+ $F->type = ( ! empty($matches[1])) ? $matches[1] : NULL;
+ $F->default = NULL;
+ $F->max_length = ( ! empty($matches[2])) ? preg_replace('/[^\d]/', '', $matches[2]) : NULL;
+ $F->primary_key = (int) $field['pk'];
+ $F->pdo_type = NULL;
+
+ $data[] = $F;
+ }
}
-
+ else
+ {
+ for($i = 0, $max = $this->num_fields(); $i < $max; $i++)
+ {
+ $field = $this->result_id->getColumnMeta($i);
+
+ $F = new stdClass();
+ $F->name = $field['name'];
+ $F->type = $field['native_type'];
+ $F->default = NULL;
+ $F->pdo_type = $field['pdo_type'];
+
+ if ($field['precision'] < 0)
+ {
+ $F->max_length = NULL;
+ $F->primary_key = 0;
+ }
+ else
+ {
+ $F->max_length = ($field['len'] > 255) ? 0 : $field['len'];
+ $F->primary_key = (int) ( ! empty($field['flags']) && in_array('primary_key', $field['flags']));
+ }
+
+ $data[] = $F;
+ }
+ }
+
return $data;
}
catch (Exception $e)
@@ -183,9 +215,9 @@ class CI_DB_pdo_result extends CI_DB_result {
/**
* Free the result
*
- * @return null
+ * @return void
*/
- function free_result()
+ public function free_result()
{
if (is_object($this->result_id))
{
@@ -198,14 +230,13 @@ class CI_DB_pdo_result extends CI_DB_result {
/**
* Data Seek
*
- * Moves the internal pointer to the desired offset. We call
+ * Moves the internal pointer to the desired offset. We call
* this internally before fetching results to make sure the
* result set starts at zero
*
- * @access private
- * @return array
+ * @return bool
*/
- function _data_seek($n = 0)
+ protected function _data_seek($n = 0)
{
return FALSE;
}
@@ -217,10 +248,9 @@ class CI_DB_pdo_result extends CI_DB_result {
*
* Returns the result set as an array
*
- * @access private
* @return array
*/
- function _fetch_assoc()
+ protected function _fetch_assoc()
{
return $this->result_id->fetch(PDO::FETCH_ASSOC);
}
@@ -232,11 +262,10 @@ class CI_DB_pdo_result extends CI_DB_result {
*
* Returns the result set as an object
*
- * @access private
* @return object
*/
- function _fetch_object()
- {
+ protected function _fetch_object()
+ {
return $this->result_id->fetchObject();
}
diff --git a/system/database/drivers/pdo/pdo_utility.php b/system/database/drivers/pdo/pdo_utility.php
index c278c5172..86c798397 100644
--- a/system/database/drivers/pdo/pdo_utility.php
+++ b/system/database/drivers/pdo/pdo_utility.php
@@ -1,13 +1,13 @@
-<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
* An open source application development framework for PHP 5.2.4 or newer
*
* NOTICE OF LICENSE
- *
+ *
* Licensed under the Open Software License version 3.0
- *
+ *
* This source file is subject to the Open Software License (OSL 3.0) that is
* bundled with this package in the files license.txt / license.rst. It is
* also available through the world wide web at this URL:
@@ -25,8 +25,6 @@
* @filesource
*/
-// ------------------------------------------------------------------------
-
/**
* PDO Utility Class
*
@@ -39,10 +37,9 @@ class CI_DB_pdo_utility extends CI_DB_utility {
/**
* List databases
*
- * @access private
* @return bool
*/
- function _list_databases()
+ public function _list_databases()
{
// Not sure if PDO lets you list all databases...
if ($this->db->db_debug)
@@ -59,11 +56,10 @@ class CI_DB_pdo_utility extends CI_DB_utility {
*
* Generates a platform-specific query so that a table can be optimized
*
- * @access private
* @param string the table name
- * @return object
+ * @return bool
*/
- function _optimize_table($table)
+ public function _optimize_table($table)
{
// Not a supported PDO feature
if ($this->db->db_debug)
@@ -80,11 +76,10 @@ class CI_DB_pdo_utility extends CI_DB_utility {
*
* Generates a platform-specific query so that a table can be repaired
*
- * @access private
* @param string the table name
- * @return object
+ * @return bool
*/
- function _repair_table($table)
+ public function _repair_table($table)
{
// Not a supported PDO feature
if ($this->db->db_debug)
@@ -99,11 +94,10 @@ class CI_DB_pdo_utility extends CI_DB_utility {
/**
* PDO Export
*
- * @access private
* @param array Preferences
* @return mixed
*/
- function _backup($params = array())
+ public function _backup($params = array())
{
// Currently unsupported
return $this->db->display_error('db_unsuported_feature');
diff --git a/system/database/drivers/postgre/postgre_driver.php b/system/database/drivers/postgre/postgre_driver.php
index 5d22af2e6..a033d74f3 100644
--- a/system/database/drivers/postgre/postgre_driver.php
+++ b/system/database/drivers/postgre/postgre_driver.php
@@ -1,13 +1,13 @@
-<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
* An open source application development framework for PHP 5.2.4 or newer
*
* NOTICE OF LICENSE
- *
+ *
* Licensed under the Open Software License version 3.0
- *
+ *
* This source file is subject to the Open Software License (OSL 3.0) that is
* bundled with this package in the files license.txt / license.rst. It is
* also available through the world wide web at this URL:
@@ -25,8 +25,6 @@
* @filesource
*/
-// ------------------------------------------------------------------------
-
/**
* Postgre Database Adapter Class
*
@@ -42,47 +40,81 @@
*/
class CI_DB_postgre_driver extends CI_DB {
- var $dbdriver = 'postgre';
+ public $dbdriver = 'postgre';
- var $_escape_char = '"';
+ protected $_escape_char = '"';
// clause and character used for LIKE escape sequences
- var $_like_escape_str = " ESCAPE '%s' ";
- var $_like_escape_chr = '!';
+ protected $_like_escape_str = " ESCAPE '%s' ";
+ protected $_like_escape_chr = '!';
/**
* The syntax to count rows is slightly different across different
* database engines, so this string appears in each driver and is
* used for the count_all() and count_all_results() functions.
*/
- var $_count_string = "SELECT COUNT(*) AS ";
- var $_random_keyword = ' RANDOM()'; // database specific random keyword
+ protected $_count_string = 'SELECT COUNT(*) AS ';
+ protected $_random_keyword = ' RANDOM()'; // database specific random keyword
/**
- * Connection String
+ * Constructor
*
- * @access private
- * @return string
+ * Creates a DSN string to be used for db_connect() and db_pconnect()
+ *
+ * @return void
*/
- function _connect_string()
+ public function __construct($params)
{
- $components = array(
- 'hostname' => 'host',
- 'port' => 'port',
- 'database' => 'dbname',
- 'username' => 'user',
- 'password' => 'password'
- );
-
- $connect_string = "";
- foreach ($components as $key => $val)
+ parent::__construct($params);
+
+ if ( ! empty($this->dsn))
{
- if (isset($this->$key) && $this->$key != '')
+ return;
+ }
+
+ $this->dsn === '' OR $this->dsn = '';
+
+ if (strpos($this->hostname, '/') !== FALSE)
+ {
+ // If UNIX sockets are used, we shouldn't set a port
+ $this->port = '';
+ }
+
+ $this->hostname === '' OR $this->dsn = 'host='.$this->hostname;
+
+ if ( ! empty($this->port) && ctype_digit($this->port))
+ {
+ $this->dsn .= 'host='.$this->port.' ';
+ }
+
+ if ($this->username !== '')
+ {
+ $this->dsn .= 'username='.$this->username.' ';
+
+ /* An empty password is valid!
+ *
+ * $db['password'] = NULL must be done in order to ignore it.
+ */
+ $this->password === NULL OR $this->dsn .= "password='".$this->password."' ";
+ }
+
+ $this->database === '' OR $this->dsn .= 'dbname='.$this->database.' ';
+
+ /* We don't have these options as elements in our standard configuration
+ * array, but they might be set by parse_url() if the configuration was
+ * provided via string. Example:
+ *
+ * postgre://username:password@localhost:5432/database?connect_timeout=5&sslmode=1
+ */
+ foreach (array('connect_timeout', 'options', 'sslmode', 'service') as $key)
+ {
+ if (isset($this->$key) && is_string($this->key) && $this->key !== '')
{
- $connect_string .= " $val=".$this->$key;
+ $this->dsn .= $key."='".$this->key."' ";
}
}
- return trim($connect_string);
+
+ $this->dsn = rtrim($this->dsn);
}
// --------------------------------------------------------------------
@@ -90,12 +122,11 @@ class CI_DB_postgre_driver extends CI_DB {
/**
* Non-persistent database connection
*
- * @access private called by the base class
* @return resource
*/
- function db_connect()
+ public function db_connect()
{
- return @pg_connect($this->_connect_string());
+ return @pg_connect($this->dsn);
}
// --------------------------------------------------------------------
@@ -103,12 +134,11 @@ class CI_DB_postgre_driver extends CI_DB {
/**
* Persistent database connection
*
- * @access private called by the base class
* @return resource
*/
- function db_pconnect()
+ public function db_pconnect()
{
- return @pg_pconnect($this->_connect_string());
+ return @pg_pconnect($this->dsn);
}
// --------------------------------------------------------------------
@@ -119,10 +149,9 @@ class CI_DB_postgre_driver extends CI_DB {
* Keep / reestablish the db connection if no queries have been
* sent for a length of time exceeding the server's idle timeout
*
- * @access public
* @return void
*/
- function reconnect()
+ public function reconnect()
{
if (pg_ping($this->conn_id) === FALSE)
{
@@ -133,20 +162,6 @@ class CI_DB_postgre_driver extends CI_DB {
// --------------------------------------------------------------------
/**
- * Select the database
- *
- * @access private called by the base class
- * @return resource
- */
- function db_select()
- {
- // Not needed for Postgre so we'll return TRUE
- return TRUE;
- }
-
- // --------------------------------------------------------------------
-
- /**
* Set client character set
*
* @param string
@@ -191,35 +206,17 @@ class CI_DB_postgre_driver extends CI_DB {
/**
* Execute the query
*
- * @access private called by the base class
* @param string an SQL query
* @return resource
*/
- function _execute($sql)
+ protected function _execute($sql)
{
- $sql = $this->_prep_query($sql);
return @pg_query($this->conn_id, $sql);
}
// --------------------------------------------------------------------
/**
- * Prep the query
- *
- * If needed, each database adapter can prep the query string
- *
- * @access private called by execute()
- * @param string an SQL query
- * @return string
- */
- function _prep_query($sql)
- {
- return $sql;
- }
-
- // --------------------------------------------------------------------
-
- /**
* Begin Transaction
*
* @return bool
@@ -281,12 +278,11 @@ class CI_DB_postgre_driver extends CI_DB {
/**
* Escape String
*
- * @access public
* @param string
* @param bool whether or not the string will be used in a LIKE condition
* @return string
*/
- function escape_str($str, $like = FALSE)
+ public function escape_str($str, $like = FALSE)
{
if (is_array($str))
{
@@ -303,9 +299,9 @@ class CI_DB_postgre_driver extends CI_DB {
// escape LIKE condition wildcards
if ($like === TRUE)
{
- $str = str_replace( array('%', '_', $this->_like_escape_chr),
- array($this->_like_escape_chr.'%', $this->_like_escape_chr.'_', $this->_like_escape_chr.$this->_like_escape_chr),
- $str);
+ return str_replace(array($this->_like_escape_chr, '%', '_'),
+ array($this->_like_escape_chr.$this->_like_escape_chr, $this->_like_escape_chr.'%', $this->_like_escape_chr.'_'),
+ $str);
}
return $str;
@@ -316,10 +312,9 @@ class CI_DB_postgre_driver extends CI_DB {
/**
* Affected Rows
*
- * @access public
- * @return integer
+ * @return int
*/
- function affected_rows()
+ public function affected_rows()
{
return @pg_affected_rows($this->result_id);
}
@@ -329,10 +324,9 @@ class CI_DB_postgre_driver extends CI_DB {
/**
* Insert ID
*
- * @access public
- * @return integer
+ * @return string
*/
- function insert_id()
+ public function insert_id()
{
$v = $this->version();
@@ -372,11 +366,10 @@ class CI_DB_postgre_driver extends CI_DB {
* Generates a platform-specific query string that counts all records in
* the specified database
*
- * @access public
* @param string
* @return string
*/
- function count_all($table = '')
+ public function count_all($table = '')
{
if ($table == '')
{
@@ -401,11 +394,10 @@ class CI_DB_postgre_driver extends CI_DB {
*
* Generates a platform-specific query string so that the table names can be fetched
*
- * @access private
- * @param boolean
+ * @param bool
* @return string
*/
- function _list_tables($prefix_limit = FALSE)
+ protected function _list_tables($prefix_limit = FALSE)
{
$sql = "SELECT table_name FROM information_schema.tables WHERE table_schema = 'public'";
@@ -424,11 +416,10 @@ class CI_DB_postgre_driver extends CI_DB {
*
* Generates a platform-specific query string so that the column names can be fetched
*
- * @access public
* @param string the table name
* @return string
*/
- function _list_columns($table = '')
+ protected function _list_columns($table = '')
{
return "SELECT column_name FROM information_schema.columns WHERE table_name ='".$table."'";
}
@@ -440,11 +431,10 @@ class CI_DB_postgre_driver extends CI_DB {
*
* Generates a platform-specific query so that the column data can be retrieved
*
- * @access public
* @param string the table name
* @return object
*/
- function _field_data($table)
+ protected function _field_data($table)
{
return "SELECT * FROM ".$table." LIMIT 1";
}
@@ -471,11 +461,10 @@ class CI_DB_postgre_driver extends CI_DB {
*
* This function escapes column and table names
*
- * @access private
* @param string
* @return string
*/
- function _escape_identifiers($item)
+ public function _escape_identifiers($item)
{
if ($this->_escape_char == '')
{
@@ -514,11 +503,10 @@ class CI_DB_postgre_driver extends CI_DB {
* This function implicitly groups FROM tables so there is no confusion
* about operator precedence in harmony with SQL standards
*
- * @access public
- * @param type
- * @return type
+ * @param array
+ * @return string
*/
- function _from_tables($tables)
+ protected function _from_tables($tables)
{
if ( ! is_array($tables))
{
@@ -535,13 +523,12 @@ class CI_DB_postgre_driver extends CI_DB {
*
* Generates a platform-specific insert string from the supplied data
*
- * @access public
* @param string the table name
* @param array the insert keys
* @param array the insert values
* @return string
*/
- function _insert($table, $keys, $values)
+ protected function _insert($table, $keys, $values)
{
return "INSERT INTO ".$table." (".implode(', ', $keys).") VALUES (".implode(', ', $values).")";
}
@@ -553,13 +540,12 @@ class CI_DB_postgre_driver extends CI_DB {
*
* Generates a platform-specific insert string from the supplied data
*
- * @access public
* @param string the table name
* @param array the insert keys
* @param array the insert values
* @return string
*/
- function _insert_batch($table, $keys, $values)
+ protected function _insert_batch($table, $keys, $values)
{
return "INSERT INTO ".$table." (".implode(', ', $keys).") VALUES ".implode(', ', $values);
}
@@ -571,7 +557,6 @@ class CI_DB_postgre_driver extends CI_DB {
*
* Generates a platform-specific update string from the supplied data
*
- * @access public
* @param string the table name
* @param array the update data
* @param array the where clause
@@ -579,7 +564,7 @@ class CI_DB_postgre_driver extends CI_DB {
* @param array the limit clause
* @return string
*/
- function _update($table, $values, $where, $orderby = array(), $limit = FALSE)
+ protected function _update($table, $values, $where, $orderby = array(), $limit = FALSE)
{
foreach ($values as $key => $val)
{
@@ -602,11 +587,10 @@ class CI_DB_postgre_driver extends CI_DB {
* If the database does not support the truncate() command
* This function maps to "DELETE FROM table"
*
- * @access public
* @param string the table name
* @return string
*/
- function _truncate($table)
+ protected function _truncate($table)
{
return "TRUNCATE ".$table;
}
@@ -618,13 +602,12 @@ class CI_DB_postgre_driver extends CI_DB {
*
* Generates a platform-specific delete string from the supplied data
*
- * @access public
* @param string the table name
* @param array the where clause
* @param string the limit clause
* @return string
*/
- function _delete($table, $where = array(), $like = array(), $limit = FALSE)
+ protected function _delete($table, $where = array(), $like = array(), $limit = FALSE)
{
$conditions = '';
@@ -649,13 +632,12 @@ class CI_DB_postgre_driver extends CI_DB {
*
* Generates a platform-specific LIMIT clause
*
- * @access public
* @param string the sql query string
- * @param integer the number of rows to limit the query to
- * @param integer the offset value
+ * @param int the number of rows to limit the query to
+ * @param int the offset value
* @return string
*/
- function _limit($sql, $limit, $offset)
+ protected function _limit($sql, $limit, $offset)
{
$sql .= "LIMIT ".$limit;
@@ -672,18 +654,15 @@ class CI_DB_postgre_driver extends CI_DB {
/**
* Close DB Connection
*
- * @access public
* @param resource
* @return void
*/
- function _close($conn_id)
+ protected function _close($conn_id)
{
@pg_close($conn_id);
}
-
}
-
/* End of file postgre_driver.php */
-/* Location: ./system/database/drivers/postgre/postgre_driver.php */
+/* Location: ./system/database/drivers/postgre/postgre_driver.php */ \ No newline at end of file
diff --git a/system/database/drivers/postgre/postgre_forge.php b/system/database/drivers/postgre/postgre_forge.php
index 577100544..a72449820 100644
--- a/system/database/drivers/postgre/postgre_forge.php
+++ b/system/database/drivers/postgre/postgre_forge.php
@@ -1,13 +1,13 @@
-<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
* An open source application development framework for PHP 5.2.4 or newer
*
* NOTICE OF LICENSE
- *
+ *
* Licensed under the Open Software License version 3.0
- *
+ *
* This source file is subject to the Open Software License (OSL 3.0) that is
* bundled with this package in the files license.txt / license.rst. It is
* also available through the world wide web at this URL:
@@ -25,8 +25,6 @@
* @filesource
*/
-// ------------------------------------------------------------------------
-
/**
* Postgre Forge Class
*
@@ -39,11 +37,10 @@ class CI_DB_postgre_forge extends CI_DB_forge {
/**
* Create database
*
- * @access private
* @param string the database name
* @return bool
*/
- function _create_database($name)
+ public function _create_database($name)
{
return "CREATE DATABASE ".$name;
}
@@ -53,29 +50,28 @@ class CI_DB_postgre_forge extends CI_DB_forge {
/**
* Drop database
*
- * @access private
* @param string the database name
* @return bool
*/
- function _drop_database($name)
+ public function _drop_database($name)
{
return "DROP DATABASE ".$name;
}
// --------------------------------------------------------------------
-
+
/**
* Process Fields
*
* @param mixed the fields
* @return string
*/
- function _process_fields($fields, $primary_keys=array())
+ protected function _process_fields($fields, $primary_keys=array())
{
$sql = '';
$current_field_count = 0;
- foreach ($fields as $field=>$attributes)
+ foreach ($fields as $field => $attributes)
{
// Numeric field names aren't allowed in databases, so if the key is
// numeric, we know it was assigned by PHP and the developer manually
@@ -168,7 +164,7 @@ class CI_DB_postgre_forge extends CI_DB_forge {
$sql .= ',';
}
}
-
+
return $sql;
}
@@ -177,15 +173,14 @@ class CI_DB_postgre_forge extends CI_DB_forge {
/**
* Create Table
*
- * @access private
* @param string the table name
* @param array the fields
* @param mixed primary key(s)
* @param mixed key(s)
- * @param boolean should 'IF NOT EXISTS' be added to the SQL
+ * @param bool should 'IF NOT EXISTS' be added to the SQL
* @return bool
*/
- function _create_table($table, $fields, $primary_keys, $keys, $if_not_exists)
+ public function _create_table($table, $fields, $primary_keys, $keys, $if_not_exists)
{
$sql = 'CREATE TABLE ';
@@ -241,8 +236,10 @@ class CI_DB_postgre_forge extends CI_DB_forge {
/**
* Drop Table
+ *
+ * @return string
*/
- function _drop_table($table)
+ public function _drop_table($table)
{
return "DROP TABLE IF EXISTS ".$this->db->_escape_identifiers($table)." CASCADE";
}
@@ -255,7 +252,6 @@ class CI_DB_postgre_forge extends CI_DB_forge {
* Generates a platform-specific query so that a table can be altered
* Called by add_column(), drop_column(), and column_alter(),
*
- * @access private
* @param string the ALTER type (ADD, DROP, CHANGE)
* @param string the column name
* @param string the table name
@@ -263,9 +259,9 @@ class CI_DB_postgre_forge extends CI_DB_forge {
* @param string the default value
* @param boolean should 'NOT NULL' be added
* @param string the field after which we should add the new field
- * @return object
+ * @return string
*/
- function _alter_table($alter_type, $table, $fields, $after_field = '')
+ public function _alter_table($alter_type, $table, $fields, $after_field = '')
{
$sql = 'ALTER TABLE '.$this->db->protect_identifiers($table).' '.$alter_type.' ';
@@ -292,16 +288,15 @@ class CI_DB_postgre_forge extends CI_DB_forge {
*
* Generates a platform-specific query so that a table can be renamed
*
- * @access private
* @param string the old table name
* @param string the new table name
* @return string
*/
- function _rename_table($table_name, $new_table_name)
+ public function _rename_table($table_name, $new_table_name)
{
return 'ALTER TABLE '.$this->db->protect_identifiers($table_name).' RENAME TO '.$this->db->protect_identifiers($new_table_name);
}
}
/* End of file postgre_forge.php */
-/* Location: ./system/database/drivers/postgre/postgre_forge.php */
+/* Location: ./system/database/drivers/postgre/postgre_forge.php */ \ No newline at end of file
diff --git a/system/database/drivers/postgre/postgre_result.php b/system/database/drivers/postgre/postgre_result.php
index 12d7547c5..394b8b6fd 100644
--- a/system/database/drivers/postgre/postgre_result.php
+++ b/system/database/drivers/postgre/postgre_result.php
@@ -1,13 +1,13 @@
-<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
* An open source application development framework for PHP 5.2.4 or newer
*
* NOTICE OF LICENSE
- *
+ *
* Licensed under the Open Software License version 3.0
- *
+ *
* This source file is subject to the Open Software License (OSL 3.0) that is
* bundled with this package in the files license.txt / license.rst. It is
* also available through the world wide web at this URL:
@@ -25,8 +25,6 @@
* @filesource
*/
-// ------------------------------------------------------------------------
-
/**
* Postgres Result Class
*
@@ -41,10 +39,9 @@ class CI_DB_postgre_result extends CI_DB_result {
/**
* Number of rows in the result set
*
- * @access public
- * @return integer
+ * @return int
*/
- function num_rows()
+ public function num_rows()
{
return @pg_num_rows($this->result_id);
}
@@ -54,10 +51,9 @@ class CI_DB_postgre_result extends CI_DB_result {
/**
* Number of fields in the result set
*
- * @access public
- * @return integer
+ * @return int
*/
- function num_fields()
+ public function num_fields()
{
return @pg_num_fields($this->result_id);
}
@@ -69,13 +65,12 @@ class CI_DB_postgre_result extends CI_DB_result {
*
* Generates an array of column names
*
- * @access public
* @return array
*/
- function list_fields()
+ public function list_fields()
{
$field_names = array();
- for ($i = 0; $i < $this->num_fields(); $i++)
+ for ($i = 0, $c = $this->num_fields(); $i < $c; $i++)
{
$field_names[] = pg_field_name($this->result_id, $i);
}
@@ -90,22 +85,19 @@ class CI_DB_postgre_result extends CI_DB_result {
*
* Generates an array of objects containing field meta-data
*
- * @access public
* @return array
*/
- function field_data()
+ public function field_data()
{
$retval = array();
- for ($i = 0; $i < $this->num_fields(); $i++)
+ for ($i = 0, $c = $this->num_fields(); $i < $c; $i++)
{
- $F = new stdClass();
- $F->name = pg_field_name($this->result_id, $i);
- $F->type = pg_field_type($this->result_id, $i);
- $F->max_length = pg_field_size($this->result_id, $i);
- $F->primary_key = 0;
- $F->default = '';
-
- $retval[] = $F;
+ $retval[$i] = new stdClass();
+ $retval[$i]->name = pg_field_name($this->result_id, $i);
+ $retval[$i]->type = pg_field_type($this->result_id, $i);
+ $retval[$i]->max_length = pg_field_size($this->result_id, $i);
+ $retval[$i]->primary_key = 0;
+ $retval[$i]->default = '';
}
return $retval;
@@ -116,9 +108,9 @@ class CI_DB_postgre_result extends CI_DB_result {
/**
* Free the result
*
- * @return null
+ * @return void
*/
- function free_result()
+ public function free_result()
{
if (is_resource($this->result_id))
{
@@ -132,14 +124,13 @@ class CI_DB_postgre_result extends CI_DB_result {
/**
* Data Seek
*
- * Moves the internal pointer to the desired offset. We call
+ * Moves the internal pointer to the desired offset. We call
* this internally before fetching results to make sure the
* result set starts at zero
*
- * @access private
* @return array
*/
- function _data_seek($n = 0)
+ protected function _data_seek($n = 0)
{
return pg_result_seek($this->result_id, $n);
}
@@ -151,10 +142,9 @@ class CI_DB_postgre_result extends CI_DB_result {
*
* Returns the result set as an array
*
- * @access private
* @return array
*/
- function _fetch_assoc()
+ protected function _fetch_assoc()
{
return pg_fetch_assoc($this->result_id);
}
@@ -166,16 +156,14 @@ class CI_DB_postgre_result extends CI_DB_result {
*
* Returns the result set as an object
*
- * @access private
* @return object
*/
- function _fetch_object()
+ protected function _fetch_object()
{
return pg_fetch_object($this->result_id);
}
}
-
/* End of file postgre_result.php */
/* Location: ./system/database/drivers/postgre/postgre_result.php */ \ No newline at end of file
diff --git a/system/database/drivers/postgre/postgre_utility.php b/system/database/drivers/postgre/postgre_utility.php
index e31a6db8f..cf29201ff 100644
--- a/system/database/drivers/postgre/postgre_utility.php
+++ b/system/database/drivers/postgre/postgre_utility.php
@@ -78,7 +78,7 @@ class CI_DB_postgre_utility extends CI_DB_utility {
* @param array Preferences
* @return mixed
*/
- function _backup($params = array())
+ public function _backup($params = array())
{
// Currently unsupported
return $this->db->display_error('db_unsuported_feature');
@@ -86,4 +86,4 @@ class CI_DB_postgre_utility extends CI_DB_utility {
}
/* End of file postgre_utility.php */
-/* Location: ./system/database/drivers/postgre/postgre_utility.php */
+/* Location: ./system/database/drivers/postgre/postgre_utility.php */ \ No newline at end of file
diff --git a/system/database/drivers/sqlite/sqlite_driver.php b/system/database/drivers/sqlite/sqlite_driver.php
index 55d9bfdb8..ef543c9b5 100644
--- a/system/database/drivers/sqlite/sqlite_driver.php
+++ b/system/database/drivers/sqlite/sqlite_driver.php
@@ -1,13 +1,13 @@
-<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
* An open source application development framework for PHP 5.2.4 or newer
*
* NOTICE OF LICENSE
- *
+ *
* Licensed under the Open Software License version 3.0
- *
+ *
* This source file is subject to the Open Software License (OSL 3.0) that is
* bundled with this package in the files license.txt / license.rst. It is
* also available through the world wide web at this URL:
@@ -25,10 +25,6 @@
* @filesource
*/
-// ------------------------------------------------------------------------
-
-
-
/**
* SQLite Database Adapter Class
*
@@ -44,30 +40,29 @@
*/
class CI_DB_sqlite_driver extends CI_DB {
- var $dbdriver = 'sqlite';
+ public $dbdriver = 'sqlite';
// The character used to escape with - not needed for SQLite
- var $_escape_char = '';
+ protected $_escape_char = '';
// clause and character used for LIKE escape sequences
- var $_like_escape_str = " ESCAPE '%s' ";
- var $_like_escape_chr = '!';
+ protected $_like_escape_str = " ESCAPE '%s' ";
+ protected $_like_escape_chr = '!';
/**
* The syntax to count rows is slightly different across different
* database engines, so this string appears in each driver and is
* used for the count_all() and count_all_results() functions.
*/
- var $_count_string = "SELECT COUNT(*) AS ";
- var $_random_keyword = ' Random()'; // database specific random keyword
+ protected $_count_string = 'SELECT COUNT(*) AS ';
+ protected $_random_keyword = ' Random()'; // database specific random keyword
/**
* Non-persistent database connection
*
- * @access private called by the base class
* @return resource
*/
- function db_connect()
+ public function db_connect()
{
if ( ! $conn_id = @sqlite_open($this->database, FILE_WRITE_MODE, $error))
{
@@ -89,10 +84,9 @@ class CI_DB_sqlite_driver extends CI_DB {
/**
* Persistent database connection
*
- * @access private called by the base class
* @return resource
*/
- function db_pconnect()
+ public function db_pconnect()
{
if ( ! $conn_id = @sqlite_popen($this->database, FILE_WRITE_MODE, $error))
{
@@ -112,35 +106,6 @@ class CI_DB_sqlite_driver extends CI_DB {
// --------------------------------------------------------------------
/**
- * Reconnect
- *
- * Keep / reestablish the db connection if no queries have been
- * sent for a length of time exceeding the server's idle timeout
- *
- * @access public
- * @return void
- */
- function reconnect()
- {
- // not implemented in SQLite
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Select the database
- *
- * @access private called by the base class
- * @return resource
- */
- function db_select()
- {
- return TRUE;
- }
-
- // --------------------------------------------------------------------
-
- /**
* Database version number
*
* @return string
@@ -157,41 +122,22 @@ class CI_DB_sqlite_driver extends CI_DB {
/**
* Execute the query
*
- * @access private called by the base class
* @param string an SQL query
* @return resource
*/
- function _execute($sql)
+ protected function _execute($sql)
{
- $sql = $this->_prep_query($sql);
return @sqlite_query($this->conn_id, $sql);
}
// --------------------------------------------------------------------
/**
- * Prep the query
- *
- * If needed, each database adapter can prep the query string
- *
- * @access private called by execute()
- * @param string an SQL query
- * @return string
- */
- function _prep_query($sql)
- {
- return $sql;
- }
-
- // --------------------------------------------------------------------
-
- /**
* Begin Transaction
*
- * @access public
* @return bool
*/
- function trans_begin($test_mode = FALSE)
+ public function trans_begin($test_mode = FALSE)
{
if ( ! $this->trans_enabled)
{
@@ -218,10 +164,9 @@ class CI_DB_sqlite_driver extends CI_DB {
/**
* Commit Transaction
*
- * @access public
* @return bool
*/
- function trans_commit()
+ public function trans_commit()
{
if ( ! $this->trans_enabled)
{
@@ -243,10 +188,9 @@ class CI_DB_sqlite_driver extends CI_DB {
/**
* Rollback Transaction
*
- * @access public
* @return bool
*/
- function trans_rollback()
+ public function trans_rollback()
{
if ( ! $this->trans_enabled)
{
@@ -268,12 +212,11 @@ class CI_DB_sqlite_driver extends CI_DB {
/**
* Escape String
*
- * @access public
* @param string
* @param bool whether or not the string will be used in a LIKE condition
* @return string
*/
- function escape_str($str, $like = FALSE)
+ public function escape_str($str, $like = FALSE)
{
if (is_array($str))
{
@@ -290,9 +233,9 @@ class CI_DB_sqlite_driver extends CI_DB {
// escape LIKE condition wildcards
if ($like === TRUE)
{
- $str = str_replace( array('%', '_', $this->_like_escape_chr),
- array($this->_like_escape_chr.'%', $this->_like_escape_chr.'_', $this->_like_escape_chr.$this->_like_escape_chr),
- $str);
+ return str_replace(array($this->_like_escape_chr, '%', '_'),
+ array($this->_like_escape_chr.$this->_like_escape_chr, $this->_like_escape_chr.'%', $this->_like_escape_chr.'_'),
+ $str);
}
return $str;
@@ -303,10 +246,9 @@ class CI_DB_sqlite_driver extends CI_DB {
/**
* Affected Rows
*
- * @access public
- * @return integer
+ * @return int
*/
- function affected_rows()
+ public function affected_rows()
{
return sqlite_changes($this->conn_id);
}
@@ -316,10 +258,9 @@ class CI_DB_sqlite_driver extends CI_DB {
/**
* Insert ID
*
- * @access public
- * @return integer
+ * @return int
*/
- function insert_id()
+ public function insert_id()
{
return @sqlite_last_insert_rowid($this->conn_id);
}
@@ -332,11 +273,10 @@ class CI_DB_sqlite_driver extends CI_DB {
* Generates a platform-specific query string that counts all records in
* the specified database
*
- * @access public
* @param string
* @return string
*/
- function count_all($table = '')
+ public function count_all($table = '')
{
if ($table == '')
{
@@ -361,11 +301,10 @@ class CI_DB_sqlite_driver extends CI_DB {
*
* Generates a platform-specific query string so that the table names can be fetched
*
- * @access private
- * @param boolean
+ * @param bool
* @return string
*/
- function _list_tables($prefix_limit = FALSE)
+ protected function _list_tables($prefix_limit = FALSE)
{
$sql = "SELECT name from sqlite_master WHERE type='table'";
@@ -383,11 +322,10 @@ class CI_DB_sqlite_driver extends CI_DB {
*
* Generates a platform-specific query string so that the column names can be fetched
*
- * @access public
* @param string the table name
- * @return string
+ * @return bool
*/
- function _list_columns($table = '')
+ protected function _list_columns($table = '')
{
// Not supported
return FALSE;
@@ -400,11 +338,10 @@ class CI_DB_sqlite_driver extends CI_DB {
*
* Generates a platform-specific query so that the column data can be retrieved
*
- * @access public
* @param string the table name
- * @return object
+ * @return string
*/
- function _field_data($table)
+ protected function _field_data($table)
{
return "SELECT * FROM ".$table." LIMIT 1";
}
@@ -433,11 +370,10 @@ class CI_DB_sqlite_driver extends CI_DB {
*
* This function escapes column and table names
*
- * @access private
* @param string
* @return string
*/
- function _escape_identifiers($item)
+ public function _escape_identifiers($item)
{
if ($this->_escape_char == '')
{
@@ -476,11 +412,10 @@ class CI_DB_sqlite_driver extends CI_DB {
* This function implicitly groups FROM tables so there is no confusion
* about operator precedence in harmony with SQL standards
*
- * @access public
- * @param type
- * @return type
+ * @param array
+ * @return string
*/
- function _from_tables($tables)
+ protected function _from_tables($tables)
{
if ( ! is_array($tables))
{
@@ -497,13 +432,12 @@ class CI_DB_sqlite_driver extends CI_DB {
*
* Generates a platform-specific insert string from the supplied data
*
- * @access public
* @param string the table name
* @param array the insert keys
* @param array the insert values
* @return string
*/
- function _insert($table, $keys, $values)
+ protected function _insert($table, $keys, $values)
{
return "INSERT INTO ".$table." (".implode(', ', $keys).") VALUES (".implode(', ', $values).")";
}
@@ -515,7 +449,6 @@ class CI_DB_sqlite_driver extends CI_DB {
*
* Generates a platform-specific update string from the supplied data
*
- * @access public
* @param string the table name
* @param array the update data
* @param array the where clause
@@ -523,7 +456,7 @@ class CI_DB_sqlite_driver extends CI_DB {
* @param array the limit clause
* @return string
*/
- function _update($table, $values, $where, $orderby = array(), $limit = FALSE)
+ protected function _update($table, $values, $where, $orderby = array(), $limit = FALSE)
{
foreach ($values as $key => $val)
{
@@ -553,11 +486,10 @@ class CI_DB_sqlite_driver extends CI_DB {
* If the database does not support the truncate() command
* This function maps to "DELETE FROM table"
*
- * @access public
* @param string the table name
* @return string
*/
- function _truncate($table)
+ protected function _truncate($table)
{
return $this->_delete($table);
}
@@ -569,13 +501,12 @@ class CI_DB_sqlite_driver extends CI_DB {
*
* Generates a platform-specific delete string from the supplied data
*
- * @access public
* @param string the table name
* @param array the where clause
* @param string the limit clause
* @return string
*/
- function _delete($table, $where = array(), $like = array(), $limit = FALSE)
+ protected function _delete($table, $where = array(), $like = array(), $limit = FALSE)
{
$conditions = '';
@@ -603,13 +534,12 @@ class CI_DB_sqlite_driver extends CI_DB {
*
* Generates a platform-specific LIMIT clause
*
- * @access public
* @param string the sql query string
- * @param integer the number of rows to limit the query to
- * @param integer the offset value
+ * @param int the number of rows to limit the query to
+ * @param int the offset value
* @return string
*/
- function _limit($sql, $limit, $offset)
+ protected function _limit($sql, $limit, $offset)
{
if ($offset == 0)
{
@@ -628,18 +558,15 @@ class CI_DB_sqlite_driver extends CI_DB {
/**
* Close DB Connection
*
- * @access public
* @param resource
* @return void
*/
- function _close($conn_id)
+ protected function _close($conn_id)
{
@sqlite_close($conn_id);
}
-
}
-
/* End of file sqlite_driver.php */
-/* Location: ./system/database/drivers/sqlite/sqlite_driver.php */
+/* Location: ./system/database/drivers/sqlite/sqlite_driver.php */ \ No newline at end of file
diff --git a/system/database/drivers/sqlite/sqlite_forge.php b/system/database/drivers/sqlite/sqlite_forge.php
index 7fc531463..068a556ed 100644
--- a/system/database/drivers/sqlite/sqlite_forge.php
+++ b/system/database/drivers/sqlite/sqlite_forge.php
@@ -1,13 +1,13 @@
-<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
* An open source application development framework for PHP 5.2.4 or newer
*
* NOTICE OF LICENSE
- *
+ *
* Licensed under the Open Software License version 3.0
- *
+ *
* This source file is subject to the Open Software License (OSL 3.0) that is
* bundled with this package in the files license.txt / license.rst. It is
* also available through the world wide web at this URL:
@@ -25,8 +25,6 @@
* @filesource
*/
-// ------------------------------------------------------------------------
-
/**
* SQLite Forge Class
*
@@ -39,11 +37,10 @@ class CI_DB_sqlite_forge extends CI_DB_forge {
/**
* Create database
*
- * @access public
* @param string the database name
* @return bool
*/
- function _create_database()
+ public function _create_database()
{
// In SQLite, a database is created when you connect to the database.
// We'll return TRUE so that an error isn't generated
@@ -55,11 +52,10 @@ class CI_DB_sqlite_forge extends CI_DB_forge {
/**
* Drop database
*
- * @access private
* @param string the database name
* @return bool
*/
- function _drop_database($name)
+ public function _drop_database($name)
{
if ( ! @file_exists($this->db->database) OR ! @unlink($this->db->database))
{
@@ -71,20 +67,20 @@ class CI_DB_sqlite_forge extends CI_DB_forge {
}
return TRUE;
}
+
// --------------------------------------------------------------------
/**
* Create Table
*
- * @access private
* @param string the table name
* @param array the fields
* @param mixed primary key(s)
* @param mixed key(s)
- * @param boolean should 'IF NOT EXISTS' be added to the SQL
+ * @param bool should 'IF NOT EXISTS' be added to the SQL
* @return bool
*/
- function _create_table($table, $fields, $primary_keys, $keys, $if_not_exists)
+ public function _create_table($table, $fields, $primary_keys, $keys, $if_not_exists)
{
$sql = 'CREATE TABLE ';
@@ -184,12 +180,9 @@ class CI_DB_sqlite_forge extends CI_DB_forge {
/**
* Drop Table
*
- * Unsupported feature in SQLite
- *
- * @access private
* @return bool
*/
- function _drop_table($table)
+ public function _drop_table($table)
{
if ($this->db->db_debug)
{
@@ -206,17 +199,16 @@ class CI_DB_sqlite_forge extends CI_DB_forge {
* Generates a platform-specific query so that a table can be altered
* Called by add_column(), drop_column(), and column_alter(),
*
- * @access private
* @param string the ALTER type (ADD, DROP, CHANGE)
* @param string the column name
* @param string the table name
* @param string the column definition
* @param string the default value
- * @param boolean should 'NOT NULL' be added
+ * @param bool should 'NOT NULL' be added
* @param string the field after which we should add the new field
- * @return object
+ * @return string
*/
- function _alter_table($alter_type, $table, $column_name, $column_definition = '', $default_value = '', $null = '', $after_field = '')
+ public function _alter_table($alter_type, $table, $column_name, $column_definition = '', $default_value = '', $null = '', $after_field = '')
{
$sql = 'ALTER TABLE '.$this->db->protect_identifiers($table).' '.$alter_type.' '.$this->db->protect_identifiers($column_name);
@@ -261,12 +253,11 @@ class CI_DB_sqlite_forge extends CI_DB_forge {
*
* Generates a platform-specific query so that a table can be renamed
*
- * @access private
* @param string the old table name
* @param string the new table name
* @return string
*/
- function _rename_table($table_name, $new_table_name)
+ public function _rename_table($table_name, $new_table_name)
{
return 'ALTER TABLE '.$this->db->protect_identifiers($table_name).' RENAME TO '.$this->db->protect_identifiers($new_table_name);
}
@@ -274,4 +265,4 @@ class CI_DB_sqlite_forge extends CI_DB_forge {
}
/* End of file sqlite_forge.php */
-/* Location: ./system/database/drivers/sqlite/sqlite_forge.php */
+/* Location: ./system/database/drivers/sqlite/sqlite_forge.php */ \ No newline at end of file
diff --git a/system/database/drivers/sqlite/sqlite_result.php b/system/database/drivers/sqlite/sqlite_result.php
index ac2235cbc..4af80abf7 100644
--- a/system/database/drivers/sqlite/sqlite_result.php
+++ b/system/database/drivers/sqlite/sqlite_result.php
@@ -1,13 +1,13 @@
-<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
* An open source application development framework for PHP 5.2.4 or newer
*
* NOTICE OF LICENSE
- *
+ *
* Licensed under the Open Software License version 3.0
- *
+ *
* This source file is subject to the Open Software License (OSL 3.0) that is
* bundled with this package in the files license.txt / license.rst. It is
* also available through the world wide web at this URL:
@@ -25,8 +25,6 @@
* @filesource
*/
-// ------------------------------------------------------------------------
-
/**
* SQLite Result Class
*
@@ -41,10 +39,9 @@ class CI_DB_sqlite_result extends CI_DB_result {
/**
* Number of rows in the result set
*
- * @access public
- * @return integer
+ * @return int
*/
- function num_rows()
+ public function num_rows()
{
return @sqlite_num_rows($this->result_id);
}
@@ -54,10 +51,9 @@ class CI_DB_sqlite_result extends CI_DB_result {
/**
* Number of fields in the result set
*
- * @access public
- * @return integer
+ * @return int
*/
- function num_fields()
+ public function num_fields()
{
return @sqlite_num_fields($this->result_id);
}
@@ -69,15 +65,14 @@ class CI_DB_sqlite_result extends CI_DB_result {
*
* Generates an array of column names
*
- * @access public
* @return array
*/
- function list_fields()
+ public function list_fields()
{
$field_names = array();
- for ($i = 0; $i < $this->num_fields(); $i++)
+ for ($i = 0, $c = $this->num_fields(); $i < $c; $i++)
{
- $field_names[] = sqlite_field_name($this->result_id, $i);
+ $field_names[$i] = sqlite_field_name($this->result_id, $i);
}
return $field_names;
@@ -90,22 +85,19 @@ class CI_DB_sqlite_result extends CI_DB_result {
*
* Generates an array of objects containing field meta-data
*
- * @access public
* @return array
*/
- function field_data()
+ public function field_data()
{
$retval = array();
- for ($i = 0; $i < $this->num_fields(); $i++)
+ for ($i = 0, $c = $this->num_fields(); $i < $c; $i++)
{
- $F = new stdClass();
- $F->name = sqlite_field_name($this->result_id, $i);
- $F->type = 'varchar';
- $F->max_length = 0;
- $F->primary_key = 0;
- $F->default = '';
-
- $retval[] = $F;
+ $retval[$i] = new stdClass();
+ $retval[$i]->name = sqlite_field_name($this->result_id, $i);
+ $retval[$i]->type = 'varchar';
+ $retval[$i]->max_length = 0;
+ $retval[$i]->primary_key = 0;
+ $retval[$i]->default = '';
}
return $retval;
@@ -114,28 +106,15 @@ class CI_DB_sqlite_result extends CI_DB_result {
// --------------------------------------------------------------------
/**
- * Free the result
- *
- * @return null
- */
- function free_result()
- {
- // Not implemented in SQLite
- }
-
- // --------------------------------------------------------------------
-
- /**
* Data Seek
*
- * Moves the internal pointer to the desired offset. We call
+ * Moves the internal pointer to the desired offset. We call
* this internally before fetching results to make sure the
* result set starts at zero
*
- * @access private
* @return array
*/
- function _data_seek($n = 0)
+ protected function _data_seek($n = 0)
{
return sqlite_seek($this->result_id, $n);
}
@@ -147,10 +126,9 @@ class CI_DB_sqlite_result extends CI_DB_result {
*
* Returns the result set as an array
*
- * @access private
* @return array
*/
- function _fetch_assoc()
+ protected function _fetch_assoc()
{
return sqlite_fetch_array($this->result_id);
}
@@ -162,30 +140,20 @@ class CI_DB_sqlite_result extends CI_DB_result {
*
* Returns the result set as an object
*
- * @access private
* @return object
*/
- function _fetch_object()
+ protected function _fetch_object()
{
if (function_exists('sqlite_fetch_object'))
{
return sqlite_fetch_object($this->result_id);
}
- else
- {
- $arr = sqlite_fetch_array($this->result_id, SQLITE_ASSOC);
- if (is_array($arr))
- {
- $obj = (object) $arr;
- return $obj;
- } else {
- return NULL;
- }
- }
+
+ $arr = sqlite_fetch_array($this->result_id, SQLITE_ASSOC);
+ return is_array($arr) ? (object) $arr : FALSE;
}
}
-
/* End of file sqlite_result.php */
/* Location: ./system/database/drivers/sqlite/sqlite_result.php */ \ No newline at end of file
diff --git a/system/database/drivers/sqlite/sqlite_utility.php b/system/database/drivers/sqlite/sqlite_utility.php
index 9f9ddca44..c07004c54 100644
--- a/system/database/drivers/sqlite/sqlite_utility.php
+++ b/system/database/drivers/sqlite/sqlite_utility.php
@@ -94,4 +94,4 @@ class CI_DB_sqlite_utility extends CI_DB_utility {
}
/* End of file sqlite_utility.php */
-/* Location: ./system/database/drivers/sqlite/sqlite_utility.php */
+/* Location: ./system/database/drivers/sqlite/sqlite_utility.php */ \ No newline at end of file
diff --git a/system/database/drivers/sqlsrv/sqlsrv_driver.php b/system/database/drivers/sqlsrv/sqlsrv_driver.php
index 5e920cbe8..bb4f009bc 100644
--- a/system/database/drivers/sqlsrv/sqlsrv_driver.php
+++ b/system/database/drivers/sqlsrv/sqlsrv_driver.php
@@ -1,13 +1,13 @@
-<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
* An open source application development framework for PHP 5.2.4 or newer
*
* NOTICE OF LICENSE
- *
+ *
* Licensed under the Open Software License version 3.0
- *
+ *
* This source file is subject to the Open Software License (OSL 3.0) that is
* bundled with this package in the files license.txt / license.rst. It is
* also available through the world wide web at this URL:
@@ -25,8 +25,6 @@
* @filesource
*/
-// ------------------------------------------------------------------------
-
/**
* SQLSRV Database Adapter Class
*
@@ -42,46 +40,46 @@
*/
class CI_DB_sqlsrv_driver extends CI_DB {
- var $dbdriver = 'sqlsrv';
+ public $dbdriver = 'sqlsrv';
// The character used for escaping
- var $_escape_char = '';
+ protected $_escape_char = '';
// clause and character used for LIKE escape sequences
- var $_like_escape_str = " ESCAPE '%s' ";
- var $_like_escape_chr = '!';
+ protected $_like_escape_str = " ESCAPE '%s' ";
+ protected $_like_escape_chr = '!';
/**
* The syntax to count rows is slightly different across different
* database engines, so this string appears in each driver and is
* used for the count_all() and count_all_results() functions.
*/
- var $_count_string = "SELECT COUNT(*) AS ";
- var $_random_keyword = ' ASC'; // not currently supported
+ protected $_count_string = 'SELECT COUNT(*) AS ';
+ protected $_random_keyword = ' NEWID()'; // not currently supported
/**
* Non-persistent database connection
*
- * @access private called by the base class
* @return resource
*/
- function db_connect($pooling = false)
+ public function db_connect($pooling = FALSE)
{
// Check for a UTF-8 charset being passed as CI's default 'utf8'.
$character_set = (0 === strcasecmp('utf8', $this->char_set)) ? 'UTF-8' : $this->char_set;
$connection = array(
- 'UID' => empty($this->username) ? '' : $this->username,
- 'PWD' => empty($this->password) ? '' : $this->password,
- 'Database' => $this->database,
- 'ConnectionPooling' => $pooling ? 1 : 0,
+ 'UID' => empty($this->username) ? '' : $this->username,
+ 'PWD' => empty($this->password) ? '' : $this->password,
+ 'Database' => $this->database,
+ 'ConnectionPooling' => $pooling ? 1 : 0,
'CharacterSet' => $character_set,
- 'ReturnDatesAsStrings' => 1
+ 'ReturnDatesAsStrings' => 1
);
-
- // If the username and password are both empty, assume this is a
+
+ // If the username and password are both empty, assume this is a
// 'Windows Authentication Mode' connection.
- if(empty($connection['UID']) && empty($connection['PWD'])) {
+ if (empty($connection['UID']) && empty($connection['PWD']))
+ {
unset($connection['UID'], $connection['PWD']);
}
@@ -93,10 +91,9 @@ class CI_DB_sqlsrv_driver extends CI_DB {
/**
* Persistent database connection
*
- * @access private called by the base class
* @return resource
*/
- function db_pconnect()
+ public function db_pconnect()
{
return $this->db_connect(TRUE);
}
@@ -104,22 +101,6 @@ class CI_DB_sqlsrv_driver extends CI_DB {
// --------------------------------------------------------------------
/**
- * Reconnect
- *
- * Keep / reestablish the db connection if no queries have been
- * sent for a length of time exceeding the server's idle timeout
- *
- * @access public
- * @return void
- */
- function reconnect()
- {
- // not implemented in MSSQL
- }
-
- // --------------------------------------------------------------------
-
- /**
* Select the database
*
* @param string database name
@@ -146,33 +127,16 @@ class CI_DB_sqlsrv_driver extends CI_DB {
/**
* Execute the query
*
- * @access private called by the base class
* @param string an SQL query
* @return resource
*/
- function _execute($sql)
+ protected function _execute($sql)
{
- $sql = $this->_prep_query($sql);
- return sqlsrv_query($this->conn_id, $sql, null, array(
- 'Scrollable' => SQLSRV_CURSOR_STATIC,
- 'SendStreamParamsAtExec' => true
- ));
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Prep the query
- *
- * If needed, each database adapter can prep the query string
- *
- * @access private called by execute()
- * @param string an SQL query
- * @return string
- */
- function _prep_query($sql)
- {
- return $sql;
+ return sqlsrv_query($this->conn_id,
+ $sql,
+ NULL,
+ array('Scrollable'=> SQLSRV_CURSOR_STATIC, 'SendStreamParamsAtExec' => TRUE)
+ );
}
// --------------------------------------------------------------------
@@ -180,10 +144,9 @@ class CI_DB_sqlsrv_driver extends CI_DB {
/**
* Begin Transaction
*
- * @access public
* @return bool
*/
- function trans_begin($test_mode = FALSE)
+ public function trans_begin($test_mode = FALSE)
{
if ( ! $this->trans_enabled)
{
@@ -209,10 +172,9 @@ class CI_DB_sqlsrv_driver extends CI_DB {
/**
* Commit Transaction
*
- * @access public
* @return bool
*/
- function trans_commit()
+ public function trans_commit()
{
if ( ! $this->trans_enabled)
{
@@ -233,10 +195,9 @@ class CI_DB_sqlsrv_driver extends CI_DB {
/**
* Rollback Transaction
*
- * @access public
* @return bool
*/
- function trans_rollback()
+ public function trans_rollback()
{
if ( ! $this->trans_enabled)
{
@@ -257,12 +218,11 @@ class CI_DB_sqlsrv_driver extends CI_DB {
/**
* Escape String
*
- * @access public
* @param string
* @param bool whether or not the string will be used in a LIKE condition
* @return string
*/
- function escape_str($str, $like = FALSE)
+ public function escape_str($str, $like = FALSE)
{
// Escape single quotes
return str_replace("'", "''", $str);
@@ -273,10 +233,9 @@ class CI_DB_sqlsrv_driver extends CI_DB {
/**
* Affected Rows
*
- * @access public
- * @return integer
+ * @return int
*/
- function affected_rows()
+ public function affected_rows()
{
return @sqlrv_rows_affected($this->conn_id);
}
@@ -284,34 +243,17 @@ class CI_DB_sqlsrv_driver extends CI_DB {
// --------------------------------------------------------------------
/**
- * Insert ID
- *
- * Returns the last id created in the Identity column.
- *
- * @access public
- * @return integer
- */
- function insert_id()
- {
- return $this->query('select @@IDENTITY as insert_id')->row('insert_id');
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Parse major version
- *
- * Grabs the major version number from the
- * database server version string passed in.
- *
- * @access private
- * @param string $version
- * @return int16 major version number
- */
- function _parse_major_version($version)
+ * Insert ID
+ *
+ * Returns the last id created in the Identity column.
+ *
+ * @return string
+ */
+ public function insert_id()
{
- preg_match('/([0-9]+)\.([0-9]+)\.([0-9]+)/', $version, $ver_info);
- return $ver_info[1]; // return the major version b/c that's all we're interested in.
+ $query = $this->query('SELECT @@IDENTITY AS insert_id');
+ $query = $query->row();
+ return $query->insert_id;
}
// --------------------------------------------------------------------
@@ -344,23 +286,25 @@ class CI_DB_sqlsrv_driver extends CI_DB {
* Generates a platform-specific query string that counts all records in
* the specified database
*
- * @access public
* @param string
- * @return string
+ * @return int
*/
- function count_all($table = '')
+ public function count_all($table = '')
{
if ($table == '')
- return '0';
-
+ {
+ return 0;
+ }
+
$query = $this->query("SELECT COUNT(*) AS numrows FROM " . $this->dbprefix . $table);
-
if ($query->num_rows() == 0)
- return '0';
+ {
+ return 0;
+ }
$row = $query->row();
$this->_reset_select();
- return $row->numrows;
+ return (int) $row->numrows;
}
// --------------------------------------------------------------------
@@ -370,11 +314,10 @@ class CI_DB_sqlsrv_driver extends CI_DB {
*
* Generates a platform-specific query string so that the table names can be fetched
*
- * @access private
- * @param boolean
+ * @param bool
* @return string
*/
- function _list_tables($prefix_limit = FALSE)
+ protected function _list_tables($prefix_limit = FALSE)
{
return "SELECT name FROM sysobjects WHERE type = 'U' ORDER BY name";
}
@@ -386,13 +329,12 @@ class CI_DB_sqlsrv_driver extends CI_DB {
*
* Generates a platform-specific query string so that the column names can be fetched
*
- * @access private
* @param string the table name
* @return string
*/
- function _list_columns($table = '')
+ protected function _list_columns($table = '')
{
- return "SELECT * FROM INFORMATION_SCHEMA.Columns WHERE TABLE_NAME = '".$this->_escape_table($table)."'";
+ return "SELECT * FROM INFORMATION_SCHEMA.Columns WHERE TABLE_NAME = '".$table."'";
}
// --------------------------------------------------------------------
@@ -402,13 +344,12 @@ class CI_DB_sqlsrv_driver extends CI_DB {
*
* Generates a platform-specific query so that the column data can be retrieved
*
- * @access public
* @param string the table name
- * @return object
+ * @return string
*/
- function _field_data($table)
+ protected function _field_data($table)
{
- return "SELECT TOP 1 * FROM " . $this->_escape_table($table);
+ return 'SELECT TOP 1 * FROM '.$table;
}
// --------------------------------------------------------------------
@@ -452,31 +393,14 @@ class CI_DB_sqlsrv_driver extends CI_DB {
// --------------------------------------------------------------------
/**
- * Escape Table Name
- *
- * This function adds backticks if the table name has a period
- * in it. Some DBs will get cranky unless periods are escaped
- *
- * @access private
- * @param string the table name
- * @return string
- */
- function _escape_table($table)
- {
- return $table;
- }
-
-
- /**
* Escape the SQL Identifiers
*
* This function escapes column and table names
*
- * @access private
* @param string
* @return string
*/
- function _escape_identifiers($item)
+ public function _escape_identifiers($item)
{
return $item;
}
@@ -489,11 +413,10 @@ class CI_DB_sqlsrv_driver extends CI_DB {
* This function implicitly groups FROM tables so there is no confusion
* about operator precedence in harmony with SQL standards
*
- * @access public
- * @param type
- * @return type
+ * @param array
+ * @return string
*/
- function _from_tables($tables)
+ protected function _from_tables($tables)
{
if ( ! is_array($tables))
{
@@ -510,15 +433,14 @@ class CI_DB_sqlsrv_driver extends CI_DB {
*
* Generates a platform-specific insert string from the supplied data
*
- * @access public
* @param string the table name
* @param array the insert keys
* @param array the insert values
* @return string
*/
- function _insert($table, $keys, $values)
- {
- return "INSERT INTO ".$this->_escape_table($table)." (".implode(', ', $keys).") VALUES (".implode(', ', $values).")";
+ protected function _insert($table, $keys, $values)
+ {
+ return 'INSERT INTO '.$table.' ('.implode(', ', $keys).') VALUES ('.implode(', ', $values).')';
}
// --------------------------------------------------------------------
@@ -528,7 +450,6 @@ class CI_DB_sqlsrv_driver extends CI_DB {
*
* Generates a platform-specific update string from the supplied data
*
- * @access public
* @param string the table name
* @param array the update data
* @param array the where clause
@@ -536,16 +457,16 @@ class CI_DB_sqlsrv_driver extends CI_DB {
* @param array the limit clause
* @return string
*/
- function _update($table, $values, $where)
+ protected function _update($table, $values, $where)
{
foreach($values as $key => $val)
{
$valstr[] = $key." = ".$val;
}
-
- return "UPDATE ".$this->_escape_table($table)." SET ".implode(', ', $valstr)." WHERE ".implode(" ", $where);
+
+ return 'UPDATE '.$table.' SET '.implode(', ', $valstr).' WHERE '.implode(' ', $where);
}
-
+
// --------------------------------------------------------------------
/**
@@ -555,11 +476,10 @@ class CI_DB_sqlsrv_driver extends CI_DB {
* If the database does not support the truncate() command
* This function maps to "DELETE FROM table"
*
- * @access public
* @param string the table name
* @return string
*/
- function _truncate($table)
+ protected function _truncate($table)
{
return "TRUNCATE ".$table;
}
@@ -571,15 +491,14 @@ class CI_DB_sqlsrv_driver extends CI_DB {
*
* Generates a platform-specific delete string from the supplied data
*
- * @access public
* @param string the table name
* @param array the where clause
* @param string the limit clause
* @return string
*/
- function _delete($table, $where)
+ protected function _delete($table, $where)
{
- return "DELETE FROM ".$this->_escape_table($table)." WHERE ".implode(" ", $where);
+ return 'DELETE FROM '.$table.' WHERE '.implode(' ', $where);
}
// --------------------------------------------------------------------
@@ -589,17 +508,14 @@ class CI_DB_sqlsrv_driver extends CI_DB {
*
* Generates a platform-specific LIMIT clause
*
- * @access public
* @param string the sql query string
- * @param integer the number of rows to limit the query to
- * @param integer the offset value
+ * @param int the number of rows to limit the query to
+ * @param int the offset value
* @return string
*/
- function _limit($sql, $limit, $offset)
+ protected function _limit($sql, $limit, $offset)
{
- $i = $limit + $offset;
-
- return preg_replace('/(^\SELECT (DISTINCT)?)/i','\\1 TOP '.$i.' ', $sql);
+ return preg_replace('/(^\SELECT (DISTINCT)?)/i','\\1 TOP '.($limit + $offset).' ', $sql);
}
// --------------------------------------------------------------------
@@ -607,18 +523,15 @@ class CI_DB_sqlsrv_driver extends CI_DB {
/**
* Close DB Connection
*
- * @access public
* @param resource
* @return void
*/
- function _close($conn_id)
+ protected function _close($conn_id)
{
@sqlsrv_close($conn_id);
}
}
-
-
-/* End of file mssql_driver.php */
-/* Location: ./system/database/drivers/mssql/mssql_driver.php */
+/* End of file sqlsrv_driver.php */
+/* Location: ./system/database/drivers/sqlsrv/sqlsrv_driver.php */ \ No newline at end of file
diff --git a/system/database/drivers/sqlsrv/sqlsrv_forge.php b/system/database/drivers/sqlsrv/sqlsrv_forge.php
index cd061dd23..0dc7b5242 100644
--- a/system/database/drivers/sqlsrv/sqlsrv_forge.php
+++ b/system/database/drivers/sqlsrv/sqlsrv_forge.php
@@ -1,13 +1,13 @@
-<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
* An open source application development framework for PHP 5.2.4 or newer
*
* NOTICE OF LICENSE
- *
+ *
* Licensed under the Open Software License version 3.0
- *
+ *
* This source file is subject to the Open Software License (OSL 3.0) that is
* bundled with this package in the files license.txt / license.rst. It is
* also available through the world wide web at this URL:
@@ -25,8 +25,6 @@
* @filesource
*/
-// ------------------------------------------------------------------------
-
/**
* SQLSRV Forge Class
*
@@ -39,11 +37,10 @@ class CI_DB_sqlsrv_forge extends CI_DB_forge {
/**
* Create database
*
- * @access private
* @param string the database name
- * @return bool
+ * @return string
*/
- function _create_database($name)
+ public function _create_database($name)
{
return "CREATE DATABASE ".$name;
}
@@ -53,11 +50,10 @@ class CI_DB_sqlsrv_forge extends CI_DB_forge {
/**
* Drop database
*
- * @access private
* @param string the database name
* @return bool
*/
- function _drop_database($name)
+ public function _drop_database($name)
{
return "DROP DATABASE ".$name;
}
@@ -67,10 +63,9 @@ class CI_DB_sqlsrv_forge extends CI_DB_forge {
/**
* Drop Table
*
- * @access private
* @return bool
*/
- function _drop_table($table)
+ public function _drop_table($table)
{
return "DROP TABLE ".$this->db->_escape_identifiers($table);
}
@@ -80,15 +75,14 @@ class CI_DB_sqlsrv_forge extends CI_DB_forge {
/**
* Create Table
*
- * @access private
* @param string the table name
* @param array the fields
* @param mixed primary key(s)
* @param mixed key(s)
- * @param boolean should 'IF NOT EXISTS' be added to the SQL
+ * @param bool should 'IF NOT EXISTS' be added to the SQL
* @return bool
*/
- function _create_table($table, $fields, $primary_keys, $keys, $if_not_exists)
+ public function _create_table($table, $fields, $primary_keys, $keys, $if_not_exists)
{
$sql = 'CREATE TABLE ';
@@ -100,7 +94,7 @@ class CI_DB_sqlsrv_forge extends CI_DB_forge {
$sql .= $this->db->_escape_identifiers($table)." (";
$current_field_count = 0;
- foreach ($fields as $field=>$attributes)
+ foreach ($fields as $field => $attributes)
{
// Numeric field names aren't allowed in databases, so if the key is
// numeric, we know it was assigned by PHP and the developer manually
@@ -190,17 +184,16 @@ class CI_DB_sqlsrv_forge extends CI_DB_forge {
* Generates a platform-specific query so that a table can be altered
* Called by add_column(), drop_column(), and column_alter(),
*
- * @access private
* @param string the ALTER type (ADD, DROP, CHANGE)
* @param string the column name
* @param string the table name
* @param string the column definition
* @param string the default value
- * @param boolean should 'NOT NULL' be added
+ * @param bool should 'NOT NULL' be added
* @param string the field after which we should add the new field
- * @return object
+ * @return string
*/
- function _alter_table($alter_type, $table, $column_name, $column_definition = '', $default_value = '', $null = '', $after_field = '')
+ public function _alter_table($alter_type, $table, $column_name, $column_definition = '', $default_value = '', $null = '', $after_field = '')
{
$sql = 'ALTER TABLE '.$this->db->protect_identifiers($table).' '.$alter_type.' '.$this->db->protect_identifiers($column_name);
@@ -242,12 +235,11 @@ class CI_DB_sqlsrv_forge extends CI_DB_forge {
*
* Generates a platform-specific query so that a table can be renamed
*
- * @access private
* @param string the old table name
* @param string the new table name
* @return string
*/
- function _rename_table($table_name, $new_table_name)
+ public function _rename_table($table_name, $new_table_name)
{
// I think this syntax will work, but can find little documentation on renaming tables in MSSQL
return 'ALTER TABLE '.$this->db->protect_identifiers($table_name).' RENAME TO '.$this->db->protect_identifiers($new_table_name);
@@ -256,4 +248,4 @@ class CI_DB_sqlsrv_forge extends CI_DB_forge {
}
/* End of file sqlsrv_forge.php */
-/* Location: ./system/database/drivers/sqlsrv/sqlsrv_forge.php */
+/* Location: ./system/database/drivers/sqlsrv/sqlsrv_forge.php */ \ No newline at end of file
diff --git a/system/database/drivers/sqlsrv/sqlsrv_result.php b/system/database/drivers/sqlsrv/sqlsrv_result.php
index 52d338a30..10d790e4b 100644
--- a/system/database/drivers/sqlsrv/sqlsrv_result.php
+++ b/system/database/drivers/sqlsrv/sqlsrv_result.php
@@ -1,13 +1,13 @@
-<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
* An open source application development framework for PHP 5.2.4 or newer
*
* NOTICE OF LICENSE
- *
+ *
* Licensed under the Open Software License version 3.0
- *
+ *
* This source file is subject to the Open Software License (OSL 3.0) that is
* bundled with this package in the files license.txt / license.rst. It is
* also available through the world wide web at this URL:
@@ -25,8 +25,6 @@
* @filesource
*/
-// ------------------------------------------------------------------------
-
/**
* SQLSRV Result Class
*
@@ -41,10 +39,9 @@ class CI_DB_sqlsrv_result extends CI_DB_result {
/**
* Number of rows in the result set
*
- * @access public
- * @return integer
+ * @return int
*/
- function num_rows()
+ public function num_rows()
{
return @sqlsrv_num_rows($this->result_id);
}
@@ -54,10 +51,9 @@ class CI_DB_sqlsrv_result extends CI_DB_result {
/**
* Number of fields in the result set
*
- * @access public
- * @return integer
+ * @return int
*/
- function num_fields()
+ public function num_fields()
{
return @sqlsrv_num_fields($this->result_id);
}
@@ -69,17 +65,16 @@ class CI_DB_sqlsrv_result extends CI_DB_result {
*
* Generates an array of column names
*
- * @access public
* @return array
*/
- function list_fields()
+ public function list_fields()
{
$field_names = array();
- foreach(sqlsrv_field_metadata($this->result_id) as $offset => $field)
+ foreach (sqlsrv_field_metadata($this->result_id) as $offset => $field)
{
$field_names[] = $field['Name'];
}
-
+
return $field_names;
}
@@ -90,13 +85,12 @@ class CI_DB_sqlsrv_result extends CI_DB_result {
*
* Generates an array of objects containing field meta-data
*
- * @access public
* @return array
*/
- function field_data()
+ public function field_data()
{
$retval = array();
- foreach(sqlsrv_field_metadata($this->result_id) as $offset => $field)
+ foreach (sqlsrv_field_metadata($this->result_id) as $offset => $field)
{
$F = new stdClass();
$F->name = $field['Name'];
@@ -104,10 +98,10 @@ class CI_DB_sqlsrv_result extends CI_DB_result {
$F->max_length = $field['Size'];
$F->primary_key = 0;
$F->default = '';
-
+
$retval[] = $F;
}
-
+
return $retval;
}
@@ -116,9 +110,9 @@ class CI_DB_sqlsrv_result extends CI_DB_result {
/**
* Free the result
*
- * @return null
+ * @return void
*/
- function free_result()
+ public function free_result()
{
if (is_resource($this->result_id))
{
@@ -132,14 +126,13 @@ class CI_DB_sqlsrv_result extends CI_DB_result {
/**
* Data Seek
*
- * Moves the internal pointer to the desired offset. We call
+ * Moves the internal pointer to the desired offset. We call
* this internally before fetching results to make sure the
* result set starts at zero
*
- * @access private
- * @return array
+ * @return void
*/
- function _data_seek($n = 0)
+ protected function _data_seek($n = 0)
{
// Not implemented
}
@@ -151,10 +144,9 @@ class CI_DB_sqlsrv_result extends CI_DB_result {
*
* Returns the result set as an array
*
- * @access private
* @return array
*/
- function _fetch_assoc()
+ protected function _fetch_assoc()
{
return sqlsrv_fetch_array($this->result_id, SQLSRV_FETCH_ASSOC);
}
@@ -166,16 +158,14 @@ class CI_DB_sqlsrv_result extends CI_DB_result {
*
* Returns the result set as an object
*
- * @access private
* @return object
*/
- function _fetch_object()
+ protected function _fetch_object()
{
return sqlsrv_fetch_object($this->result_id);
}
}
-
-/* End of file mssql_result.php */
-/* Location: ./system/database/drivers/mssql/mssql_result.php */ \ No newline at end of file
+/* End of file sqlsrv_result.php */
+/* Location: ./system/database/drivers/sqlsrv/sqlsrv_result.php */ \ No newline at end of file
diff --git a/system/database/drivers/sqlsrv/sqlsrv_utility.php b/system/database/drivers/sqlsrv/sqlsrv_utility.php
index 44e6fafeb..5830c62de 100644
--- a/system/database/drivers/sqlsrv/sqlsrv_utility.php
+++ b/system/database/drivers/sqlsrv/sqlsrv_utility.php
@@ -1,13 +1,13 @@
-<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
* An open source application development framework for PHP 5.2.4 or newer
*
* NOTICE OF LICENSE
- *
+ *
* Licensed under the Open Software License version 3.0
- *
+ *
* This source file is subject to the Open Software License (OSL 3.0) that is
* bundled with this package in the files license.txt / license.rst. It is
* also available through the world wide web at this URL:
@@ -25,8 +25,6 @@
* @filesource
*/
-// ------------------------------------------------------------------------
-
/**
* SQLSRV Utility Class
*
@@ -39,10 +37,9 @@ class CI_DB_sqlsrv_utility extends CI_DB_utility {
/**
* List databases
*
- * @access private
- * @return bool
+ * @return string
*/
- function _list_databases()
+ public function _list_databases()
{
return "EXEC sp_helpdb"; // Can also be: EXEC sp_databases
}
@@ -54,11 +51,10 @@ class CI_DB_sqlsrv_utility extends CI_DB_utility {
*
* Generates a platform-specific query so that a table can be optimized
*
- * @access private
* @param string the table name
- * @return object
+ * @return bool
*/
- function _optimize_table($table)
+ public function _optimize_table($table)
{
return FALSE; // Is this supported in MS SQL?
}
@@ -70,11 +66,10 @@ class CI_DB_sqlsrv_utility extends CI_DB_utility {
*
* Generates a platform-specific query so that a table can be repaired
*
- * @access private
* @param string the table name
- * @return object
+ * @return bool
*/
- function _repair_table($table)
+ public function _repair_table($table)
{
return FALSE; // Is this supported in MS SQL?
}
@@ -84,11 +79,10 @@ class CI_DB_sqlsrv_utility extends CI_DB_utility {
/**
* MSSQL Export
*
- * @access private
* @param array Preferences
* @return mixed
*/
- function _backup($params = array())
+ public function _backup($params = array())
{
// Currently unsupported
return $this->db->display_error('db_unsuported_feature');
@@ -96,5 +90,5 @@ class CI_DB_sqlsrv_utility extends CI_DB_utility {
}
-/* End of file mssql_utility.php */
-/* Location: ./system/database/drivers/mssql/mssql_utility.php */ \ No newline at end of file
+/* End of file sqlsrv_utility.php */
+/* Location: ./system/database/drivers/sqlsrv/sqlsrv_utility.php */ \ No newline at end of file
diff --git a/system/helpers/array_helper.php b/system/helpers/array_helper.php
index 464d1d112..6f56d9db9 100644
--- a/system/helpers/array_helper.php
+++ b/system/helpers/array_helper.php
@@ -103,4 +103,4 @@ if ( ! function_exists('elements'))
}
/* End of file array_helper.php */
-/* Location: ./system/helpers/array_helper.php */
+/* Location: ./system/helpers/array_helper.php */ \ No newline at end of file
diff --git a/system/helpers/captcha_helper.php b/system/helpers/captcha_helper.php
index 578796573..bdbc62097 100644
--- a/system/helpers/captcha_helper.php
+++ b/system/helpers/captcha_helper.php
@@ -1,4 +1,4 @@
-<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
@@ -25,8 +25,6 @@
* @filesource
*/
-// ------------------------------------------------------------------------
-
/**
* CodeIgniter CAPTCHA Helper
*
@@ -42,7 +40,6 @@
/**
* Create CAPTCHA
*
- * @access public
* @param array array of data for the CAPTCHA
* @param string path to create the image in
* @param string URL to the CAPTCHA image folder
@@ -57,35 +54,19 @@ if ( ! function_exists('create_captcha'))
foreach ($defaults as $key => $val)
{
- if ( ! is_array($data))
+ if ( ! is_array($data) && empty($$key))
{
- if ( ! isset($$key) OR $$key == '')
- {
- $$key = $val;
- }
+ $$key = $val;
}
else
{
- $$key = ( ! isset($data[$key])) ? $val : $data[$key];
+ $$key = isset($data[$key]) ? $data[$key] : $val;
}
}
- if ($img_path == '' OR $img_url == '')
- {
- return FALSE;
- }
-
- if ( ! @is_dir($img_path))
- {
- return FALSE;
- }
-
- if ( ! is_writable($img_path))
- {
- return FALSE;
- }
-
- if ( ! extension_loaded('gd'))
+ if ($img_path == '' OR $img_url == ''
+ OR ! @is_dir($img_path) OR ! is_writeable($img_path)
+ OR ! extension_loaded('gd'))
{
return FALSE;
}
@@ -97,17 +78,12 @@ if ( ! function_exists('create_captcha'))
$now = microtime(TRUE);
$current_dir = @opendir($img_path);
-
while ($filename = @readdir($current_dir))
{
- if ($filename != '.' && $filename != '..' && $filename != 'index.html')
+ if ($filename !== '.' && $filename !== '..' && $filename !== 'index.html'
+ && (str_replace('.jpg', '', $filename) + $expiration) < $now)
{
- $name = str_replace('.jpg', '', $filename);
-
- if (($name + $expiration) < $now)
- {
- @unlink($img_path.$filename);
- }
+ @unlink($img_path.$filename);
}
}
@@ -117,141 +93,114 @@ if ( ! function_exists('create_captcha'))
// Do we have a "word" yet?
// -----------------------------------
- if ($word == '')
- {
+ if ($word == '')
+ {
$pool = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
-
- $str = '';
- for ($i = 0; $i < 8; $i++)
+ $word = '';
+ for ($i = 0, $mt_rand_max = strlen($pool) - 1; $i < 8; $i++)
{
- $str .= substr($pool, mt_rand(0, strlen($pool) -1), 1);
+ $word .= $pool[mt_rand(0, $mt_rand_max)];
}
-
- $word = $str;
- }
+ }
// -----------------------------------
// Determine angle and position
// -----------------------------------
-
$length = strlen($word);
$angle = ($length >= 6) ? rand(-($length-6), ($length-6)) : 0;
$x_axis = rand(6, (360/$length)-16);
- $y_axis = ($angle >= 0 ) ? rand($img_height, $img_width) : rand(6, $img_height);
+ $y_axis = ($angle >= 0) ? rand($img_height, $img_width) : rand(6, $img_height);
- // -----------------------------------
// Create image
- // -----------------------------------
-
// PHP.net recommends imagecreatetruecolor(), but it isn't always available
- if (function_exists('imagecreatetruecolor'))
- {
- $im = imagecreatetruecolor($img_width, $img_height);
- }
- else
- {
- $im = imagecreate($img_width, $img_height);
- }
+ $im = function_exists('imagecreatetruecolor')
+ ? imagecreatetruecolor($img_width, $img_height)
+ : imagecreate($img_width, $img_height);
// -----------------------------------
// Assign colors
// -----------------------------------
-
- $bg_color = imagecolorallocate ($im, 255, 255, 255);
- $border_color = imagecolorallocate ($im, 153, 102, 102);
- $text_color = imagecolorallocate ($im, 204, 153, 153);
- $grid_color = imagecolorallocate($im, 255, 182, 182);
+ $bg_color = imagecolorallocate($im, 255, 255, 255);
+ $border_color = imagecolorallocate($im, 153, 102, 102);
+ $text_color = imagecolorallocate($im, 204, 153, 153);
+ $grid_color = imagecolorallocate($im, 255, 182, 182);
$shadow_color = imagecolorallocate($im, 255, 240, 240);
- // -----------------------------------
// Create the rectangle
- // -----------------------------------
-
ImageFilledRectangle($im, 0, 0, $img_width, $img_height, $bg_color);
// -----------------------------------
// Create the spiral pattern
// -----------------------------------
-
$theta = 1;
$thetac = 7;
$radius = 16;
$circles = 20;
$points = 32;
- for ($i = 0; $i < ($circles * $points) - 1; $i++)
+ for ($i = 0, $cp = ($circles * $points) - 1; $i < $cp; $i++)
{
- $theta = $theta + $thetac;
- $rad = $radius * ($i / $points );
+ $theta += $thetac;
+ $rad = $radius * ($i / $points);
$x = ($rad * cos($theta)) + $x_axis;
$y = ($rad * sin($theta)) + $y_axis;
- $theta = $theta + $thetac;
+ $theta += $thetac;
$rad1 = $radius * (($i + 1) / $points);
$x1 = ($rad1 * cos($theta)) + $x_axis;
- $y1 = ($rad1 * sin($theta )) + $y_axis;
+ $y1 = ($rad1 * sin($theta)) + $y_axis;
imageline($im, $x, $y, $x1, $y1, $grid_color);
- $theta = $theta - $thetac;
+ $theta -= $thetac;
}
// -----------------------------------
// Write the text
// -----------------------------------
- $use_font = ($font_path != '' && file_exists($font_path) && function_exists('imagettftext')) ? TRUE : FALSE;
-
- if ($use_font == FALSE)
+ $use_font = ($font_path != '' && file_exists($font_path) && function_exists('imagettftext'));
+ if ($use_font === FALSE)
{
$font_size = 5;
- $x = rand(0, $img_width/($length/3));
+ $x = rand(0, $img_width / ($length / 3));
$y = 0;
}
else
{
- $font_size = 16;
- $x = rand(0, $img_width/($length/1.5));
- $y = $font_size+2;
+ $font_size = 16;
+ $x = rand(0, $img_width / ($length / 1.5));
+ $y = $font_size + 2;
}
- for ($i = 0; $i < strlen($word); $i++)
+ for ($i = 0; $i < $length; $i++)
{
- if ($use_font == FALSE)
+ if ($use_font === FALSE)
{
- $y = rand(0 , $img_height/2);
- imagestring($im, $font_size, $x, $y, substr($word, $i, 1), $text_color);
- $x += ($font_size*2);
+ $y = rand(0 , $img_height / 2);
+ imagestring($im, $font_size, $x, $y, $word[$i], $text_color);
+ $x += ($font_size * 2);
}
else
{
- $y = rand($img_height/2, $img_height-3);
- imagettftext($im, $font_size, $angle, $x, $y, $text_color, $font_path, substr($word, $i, 1));
+ $y = rand($img_height / 2, $img_height - 3);
+ imagettftext($im, $font_size, $angle, $x, $y, $text_color, $font_path, $word[$i]);
$x += $font_size;
}
}
- // -----------------------------------
- // Create the border
- // -----------------------------------
-
- imagerectangle($im, 0, 0, $img_width-1, $img_height-1, $border_color);
+ // Create the border
+ imagerectangle($im, 0, 0, $img_width - 1, $img_height - 1, $border_color);
// -----------------------------------
// Generate the image
// -----------------------------------
-
$img_name = $now.'.jpg';
-
ImageJPEG($im, $img_path.$img_name);
-
- $img = "<img src=\"$img_url$img_name\" width=\"$img_width\" height=\"$img_height\" style=\"border:0;\" alt=\" \" />";
-
+ $img = '<img src="'.$img_url.$img_name.'" style="width: '.$img_width.'; height: '.$img_height .'; border: 0;" alt=" " />';
ImageDestroy($im);
return array('word' => $word, 'time' => $now, 'image' => $img);
}
}
-// ------------------------------------------------------------------------
-
/* End of file captcha_helper.php */
/* Location: ./system/helpers/captcha_helper.php */ \ No newline at end of file
diff --git a/system/helpers/cookie_helper.php b/system/helpers/cookie_helper.php
index 38a2f78fc..06560e723 100644
--- a/system/helpers/cookie_helper.php
+++ b/system/helpers/cookie_helper.php
@@ -40,7 +40,7 @@
/**
* Set cookie
*
- * Accepts six parameter, or you can submit an associative
+ * Accepts seven parameters, or you can submit an associative
* array in the first parameter containing all the values.
*
* @param mixed
@@ -49,15 +49,17 @@
* @param string the cookie domain. Usually: .yourdomain.com
* @param string the cookie path
* @param string the cookie prefix
+ * @param bool true makes the cookie secure
+ * @param bool true makes the cookie accessible via http(s) only (no javascript)
* @return void
*/
if ( ! function_exists('set_cookie'))
{
- function set_cookie($name = '', $value = '', $expire = '', $domain = '', $path = '/', $prefix = '', $secure = FALSE)
+ function set_cookie($name = '', $value = '', $expire = '', $domain = '', $path = '/', $prefix = '', $secure = FALSE, $httponly = FALSE)
{
// Set the config file options
$CI =& get_instance();
- $CI->input->set_cookie($name, $value, $expire, $domain, $path, $prefix, $secure);
+ $CI->input->set_cookie($name, $value, $expire, $domain, $path, $prefix, $secure, $httponly);
}
}
@@ -100,4 +102,4 @@ if ( ! function_exists('delete_cookie'))
}
/* End of file cookie_helper.php */
-/* Location: ./system/helpers/cookie_helper.php */
+/* Location: ./system/helpers/cookie_helper.php */ \ No newline at end of file
diff --git a/system/helpers/date_helper.php b/system/helpers/date_helper.php
index 2a34cf93e..f1ba364f5 100644
--- a/system/helpers/date_helper.php
+++ b/system/helpers/date_helper.php
@@ -1,4 +1,4 @@
-<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
@@ -25,8 +25,6 @@
* @filesource
*/
-// ------------------------------------------------------------------------
-
/**
* CodeIgniter Date Helpers
*
@@ -44,8 +42,7 @@
*
* Returns time() or its GMT equivalent based on the config file preference
*
- * @access public
- * @return integer
+ * @return int
*/
if ( ! function_exists('now'))
{
@@ -85,10 +82,9 @@ if ( ! function_exists('now'))
* have to worry about escaping your text letters that
* match the date codes.
*
- * @access public
* @param string
- * @param integer
- * @return integer
+ * @param int
+ * @return int
*/
if ( ! function_exists('mdate'))
{
@@ -118,9 +114,8 @@ if ( ! function_exists('mdate'))
*
* Returns a date formatted according to the submitted standard.
*
- * @access public
* @param string the chosen format
- * @param integer Unix timestamp
+ * @param int Unix timestamp
* @return string
*/
if ( ! function_exists('standard_date'))
@@ -128,15 +123,16 @@ if ( ! function_exists('standard_date'))
function standard_date($fmt = 'DATE_RFC822', $time = '')
{
$formats = array(
- 'DATE_ATOM' => '%Y-%m-%dT%H:%i:%s%Q',
+ 'DATE_ATOM' => '%Y-%m-%dT%H:%i:%s%O',
'DATE_COOKIE' => '%l, %d-%M-%y %H:%i:%s UTC',
- 'DATE_ISO8601' => '%Y-%m-%dT%H:%i:%s%Q',
+ 'DATE_ISO8601' => '%Y-%m-%dT%H:%i:%s%O',
'DATE_RFC822' => '%D, %d %M %y %H:%i:%s %O',
'DATE_RFC850' => '%l, %d-%M-%y %H:%i:%s UTC',
'DATE_RFC1036' => '%D, %d %M %y %H:%i:%s %O',
'DATE_RFC1123' => '%D, %d %M %Y %H:%i:%s %O',
+ 'DATE_RFC2822' => '%D, %d %M %Y %H:%i:%s %O',
'DATE_RSS' => '%D, %d %M %Y %H:%i:%s %O',
- 'DATE_W3C' => '%Y-%m-%dT%H:%i:%s%Q'
+ 'DATE_W3C' => '%Y-%m-%dT%H:%i:%s%O'
);
if ( ! isset($formats[$fmt]))
@@ -156,14 +152,14 @@ if ( ! function_exists('standard_date'))
* Returns a span of seconds in this format:
* 10 days 14 hours 36 minutes 47 seconds
*
- * @access public
- * @param integer a number of seconds
- * @param integer Unix timestamp
- * @return integer
+ * @param int a number of seconds
+ * @param int Unix timestamp
+ * @param int a number of display units
+ * @return string
*/
if ( ! function_exists('timespan'))
{
- function timespan($seconds = 1, $time = '')
+ function timespan($seconds = 1, $time = '', $units = 7)
{
$CI =& get_instance();
$CI->lang->load('date');
@@ -178,24 +174,29 @@ if ( ! function_exists('timespan'))
$time = time();
}
+ if ( ! is_numeric($units))
+ {
+ $units = 7;
+ }
+
$seconds = ($time <= $seconds) ? 1 : $time - $seconds;
- $str = '';
+ $str = array();
$years = floor($seconds / 31557600);
if ($years > 0)
{
- $str .= $years.' '.$CI->lang->line((($years > 1) ? 'date_years' : 'date_year')).', ';
+ $str[] = $years.' '.$CI->lang->line((($years > 1) ? 'date_years' : 'date_year'));
}
$seconds -= $years * 31557600;
$months = floor($seconds / 2629743);
- if ($years > 0 OR $months > 0)
+ if (count($str) < $units && ($years > 0 OR $months > 0))
{
if ($months > 0)
{
- $str .= $months.' '.$CI->lang->line((($months > 1) ? 'date_months' : 'date_month')).', ';
+ $str[] = $months.' '.$CI->lang->line((($months > 1) ? 'date_months' : 'date_month'));
}
$seconds -= $months * 2629743;
@@ -203,11 +204,11 @@ if ( ! function_exists('timespan'))
$weeks = floor($seconds / 604800);
- if ($years > 0 OR $months > 0 OR $weeks > 0)
+ if (count($str) < $units && ($years > 0 OR $months > 0 OR $weeks > 0))
{
if ($weeks > 0)
{
- $str .= $weeks.' '.$CI->lang->line((($weeks > 1) ? 'date_weeks' : 'date_week')).', ';
+ $str[] = $weeks.' '.$CI->lang->line((($weeks > 1) ? 'date_weeks' : 'date_week'));
}
$seconds -= $weeks * 604800;
@@ -215,11 +216,11 @@ if ( ! function_exists('timespan'))
$days = floor($seconds / 86400);
- if ($months > 0 OR $weeks > 0 OR $days > 0)
+ if (count($str) < $units && ($months > 0 OR $weeks > 0 OR $days > 0))
{
if ($days > 0)
{
- $str .= $days.' '.$CI->lang->line((($days > 1) ? 'date_days' : 'date_day')).', ';
+ $str[] = $days.' '.$CI->lang->line((($days > 1) ? 'date_days' : 'date_day'));
}
$seconds -= $days * 86400;
@@ -227,11 +228,11 @@ if ( ! function_exists('timespan'))
$hours = floor($seconds / 3600);
- if ($days > 0 OR $hours > 0)
+ if (count($str) < $units && ($days > 0 OR $hours > 0))
{
if ($hours > 0)
{
- $str .= $hours.' '.$CI->lang->line((($hours > 1) ? 'date_hours' : 'date_hour')).', ';
+ $str[] = $hours.' '.$CI->lang->line((($hours > 1) ? 'date_hours' : 'date_hour'));
}
$seconds -= $hours * 3600;
@@ -239,22 +240,22 @@ if ( ! function_exists('timespan'))
$minutes = floor($seconds / 60);
- if ($days > 0 OR $hours > 0 OR $minutes > 0)
+ if (count($str) < $units && ($days > 0 OR $hours > 0 OR $minutes > 0))
{
if ($minutes > 0)
{
- $str .= $minutes.' '.$CI->lang->line((($minutes > 1) ? 'date_minutes' : 'date_minute')).', ';
+ $str[] = $minutes.' '.$CI->lang->line((($minutes > 1) ? 'date_minutes' : 'date_minute'));
}
$seconds -= $minutes * 60;
}
- if ($str == '')
+ if (count($str) === 0)
{
- $str .= $seconds.' '.$CI->lang->line((($seconds > 1) ? 'date_seconds' : 'date_second')).', ';
+ $str[] = $seconds.' '.$CI->lang->line((($seconds > 1) ? 'date_seconds' : 'date_second'));
}
- return substr(trim($str), 0, -1);
+ return implode(', ', $str);
}
}
@@ -266,10 +267,9 @@ if ( ! function_exists('timespan'))
* Takes a month/year as input and returns the number of days
* for the given month/year. Takes leap years into consideration.
*
- * @access public
- * @param integer a numeric month
- * @param integer a numeric year
- * @return integer
+ * @param int a numeric month
+ * @param int a numeric year
+ * @return int
*/
if ( ! function_exists('days_in_month'))
{
@@ -287,7 +287,7 @@ if ( ! function_exists('days_in_month'))
if ($month == 2)
{
- if ($year % 400 == 0 OR ($year % 4 == 0 AND $year % 100 != 0))
+ if ($year % 400 == 0 OR ($year % 4 == 0 && $year % 100 != 0))
{
return 29;
}
@@ -303,9 +303,8 @@ if ( ! function_exists('days_in_month'))
/**
* Converts a local Unix timestamp to GMT
*
- * @access public
- * @param integer Unix timestamp
- * @return integer
+ * @param int Unix timestamp
+ * @return int
*/
if ( ! function_exists('local_to_gmt'))
{
@@ -336,11 +335,10 @@ if ( ! function_exists('local_to_gmt'))
* at the local value based on the timezone and DST setting
* submitted
*
- * @access public
- * @param integer Unix timestamp
+ * @param int Unix timestamp
* @param string timezone
* @param bool whether DST is active
- * @return integer
+ * @return int
*/
if ( ! function_exists('gmt_to_local'))
{
@@ -367,9 +365,8 @@ if ( ! function_exists('gmt_to_local'))
/**
* Converts a MySQL Timestamp to Unix
*
- * @access public
- * @param integer Unix timestamp
- * @return integer
+ * @param int Unix timestamp
+ * @return int
*/
if ( ! function_exists('mysql_to_unix'))
{
@@ -402,8 +399,7 @@ if ( ! function_exists('mysql_to_unix'))
*
* Formats Unix timestamp to the following prototype: 2006-08-21 11:35 PM
*
- * @access public
- * @param integer Unix timestamp
+ * @param int Unix timestamp
* @param bool whether to show seconds
* @param string format: us or euro
* @return string
@@ -444,9 +440,8 @@ if ( ! function_exists('unix_to_human'))
*
* Reverses the above process
*
- * @access public
* @param string format: us or euro
- * @return integer
+ * @return int
*/
if ( ! function_exists('human_to_unix'))
{
@@ -492,12 +487,12 @@ if ( ! function_exists('human_to_unix'))
{
$ampm = strtolower($split['2']);
- if (substr($ampm, 0, 1) == 'p' AND $hour < 12)
+ if (substr($ampm, 0, 1) === 'p' && $hour < 12)
{
$hour = $hour + 12;
}
- if (substr($ampm, 0, 1) == 'a' AND $hour == 12)
+ if (substr($ampm, 0, 1) === 'a' && $hour == 12)
{
$hour = '00';
}
@@ -518,10 +513,9 @@ if ( ! function_exists('human_to_unix'))
* Turns many "reasonably-date-like" strings into something
* that is actually useful. This only works for dates after unix epoch.
*
- * @access public
- * @param string The terribly formatted date-like string
- * @param string Date format to return (same as php date function)
- * @return string
+ * @param string The terribly formatted date-like string
+ * @param string Date format to return (same as php date function)
+ * @return string
*/
if ( ! function_exists('nice_date'))
{
@@ -586,7 +580,6 @@ if ( ! function_exists('nice_date'))
*
* Generates a drop-down menu of timezones.
*
- * @access public
* @param string timezone
* @param string classname
* @param string menu name
@@ -627,10 +620,9 @@ if ( ! function_exists('timezone_menu'))
/**
* Timezones
*
- * Returns an array of timezones. This is a helper function
+ * Returns an array of timezones. This is a helper function
* for various other ones in this library
*
- * @access public
* @param string timezone
* @return string
*/
@@ -691,7 +683,7 @@ if ( ! function_exists('timezones'))
$tz = ($tz == 'GMT') ? 'UTC' : $tz;
- return ( ! isset($zones[$tz])) ? 0 : $zones[$tz];
+ return isset($zones[$tz]) ? $zones[$tz] : 0;
}
}
diff --git a/system/helpers/directory_helper.php b/system/helpers/directory_helper.php
index d7ca13e85..4044ace11 100644
--- a/system/helpers/directory_helper.php
+++ b/system/helpers/directory_helper.php
@@ -85,4 +85,4 @@ if ( ! function_exists('directory_map'))
}
/* End of file directory_helper.php */
-/* Location: ./system/helpers/directory_helper.php */
+/* Location: ./system/helpers/directory_helper.php */ \ No newline at end of file
diff --git a/system/helpers/download_helper.php b/system/helpers/download_helper.php
index 96ff29dec..19192a147 100644
--- a/system/helpers/download_helper.php
+++ b/system/helpers/download_helper.php
@@ -42,7 +42,6 @@
*
* Generates headers that force a download to happen
*
- * @access public
* @param string filename
* @param mixed the data to be downloaded
* @param bool wether to try and send the actual file MIME type
@@ -125,4 +124,4 @@ if ( ! function_exists('force_download'))
}
/* End of file download_helper.php */
-/* Location: ./system/helpers/download_helper.php */
+/* Location: ./system/helpers/download_helper.php */ \ No newline at end of file
diff --git a/system/helpers/email_helper.php b/system/helpers/email_helper.php
index b87bce674..497625c10 100644
--- a/system/helpers/email_helper.php
+++ b/system/helpers/email_helper.php
@@ -25,8 +25,6 @@
* @filesource
*/
-// ------------------------------------------------------------------------
-
/**
* CodeIgniter Email Helpers
*
@@ -42,7 +40,7 @@
/**
* Validate email address
*
- * @access public
+ * @param string
* @return bool
*/
if ( ! function_exists('valid_email'))
@@ -58,7 +56,9 @@ if ( ! function_exists('valid_email'))
/**
* Send an email
*
- * @access public
+ * @param string
+ * @param string
+ * @param string
* @return bool
*/
if ( ! function_exists('send_email'))
@@ -70,4 +70,4 @@ if ( ! function_exists('send_email'))
}
/* End of file email_helper.php */
-/* Location: ./system/helpers/email_helper.php */
+/* Location: ./system/helpers/email_helper.php */ \ No newline at end of file
diff --git a/system/helpers/file_helper.php b/system/helpers/file_helper.php
index 3fd6b82e1..6e8a4ded1 100644
--- a/system/helpers/file_helper.php
+++ b/system/helpers/file_helper.php
@@ -25,8 +25,6 @@
* @filesource
*/
-// ------------------------------------------------------------------------
-
/**
* CodeIgniter File Helpers
*
@@ -44,7 +42,6 @@
*
* Opens the file specfied in the path and returns it as a string.
*
- * @access public
* @param string path to file
* @return string
*/
@@ -90,7 +87,6 @@ if ( ! function_exists('read_file'))
* Writes data to the file specified in the path.
* Creates a new file if non-existent.
*
- * @access public
* @param string path to file
* @param string file data
* @return bool
@@ -123,7 +119,6 @@ if ( ! function_exists('write_file'))
* If the second parameter is set to TRUE, any directories contained
* within the supplied base directory will be nuked as well.
*
- * @access public
* @param string path to file
* @param bool whether to delete any directories found in the path
* @return bool
@@ -142,7 +137,7 @@ if ( ! function_exists('delete_files'))
while (FALSE !== ($filename = @readdir($current_dir)))
{
- if ($filename !== '.' and $filename !== '..')
+ if ($filename !== '.' && $filename !== '..')
{
if (is_dir($path.DIRECTORY_SEPARATOR.$filename) && $filename[0] !== '.')
{
@@ -150,13 +145,13 @@ if ( ! function_exists('delete_files'))
}
else
{
- unlink($path.DIRECTORY_SEPARATOR.$filename);
+ @unlink($path.DIRECTORY_SEPARATOR.$filename);
}
}
}
@closedir($current_dir);
- if ($del_dir == TRUE AND $level > 0)
+ if ($del_dir == TRUE && $level > 0)
{
return @rmdir($path);
}
@@ -173,7 +168,6 @@ if ( ! function_exists('delete_files'))
* Reads the specified directory and builds an array containing the filenames.
* Any sub-folders contained within the specified path are read as well.
*
- * @access public
* @param string path to source
* @param bool whether to include the path as part of the filename
* @param bool internal variable to determine recursion status - do not use in calls
@@ -224,7 +218,6 @@ if ( ! function_exists('get_filenames'))
*
* Any sub-folders contained within the specified path are read as well.
*
- * @access public
* @param string path to source
* @param bool Look only at the top level directory specified?
* @param bool internal variable to determine recursion status - do not use in calls
@@ -278,7 +271,6 @@ if ( ! function_exists('get_dir_file_info'))
* Options are: name, server_path, size, date, readable, writable, executable, fileperms
* Returns FALSE if the file cannot be found.
*
-* @access public
* @param string path to file
* @param mixed array or comma separated string of information returned
* @return array
@@ -345,7 +337,6 @@ if ( ! function_exists('get_file_info'))
* Note: this is NOT an accurate way of determining file mime types, and is here strictly as a convenience
* It should NOT be trusted, and should certainly NOT be used for security
*
- * @access public
* @param string path to file
* @return mixed
*/
@@ -399,7 +390,6 @@ if ( ! function_exists('get_mime_by_extension'))
* Takes a numeric value representing a file's permissions and returns
* standard symbolic notation representing that value
*
- * @access public
* @param int
* @return string
*/
@@ -467,7 +457,6 @@ if ( ! function_exists('symbolic_permissions'))
* Takes a numeric value representing a file's permissions and returns
* a three character string representing the file's octal permissions
*
- * @access public
* @param int
* @return string
*/
@@ -480,4 +469,4 @@ if ( ! function_exists('octal_permissions'))
}
/* End of file file_helper.php */
-/* Location: ./system/helpers/file_helper.php */
+/* Location: ./system/helpers/file_helper.php */ \ No newline at end of file
diff --git a/system/helpers/form_helper.php b/system/helpers/form_helper.php
index 37337d975..e5b487608 100644
--- a/system/helpers/form_helper.php
+++ b/system/helpers/form_helper.php
@@ -24,8 +24,6 @@
* @since Version 1.0
*/
-// ------------------------------------------------------------------------
-
/**
* CodeIgniter Form Helpers
*
@@ -43,7 +41,6 @@
*
* Creates the opening portion of the form.
*
- * @access public
* @param string the URI segments of the form destination
* @param array a key/value pair of attributes
* @param array a key/value pair hidden data
@@ -71,15 +68,15 @@ if ( ! function_exists('form_open'))
$form = '<form action="'.$action.'"'._attributes_to_string($attributes, TRUE).">\n";
- // Add CSRF field if enabled, but leave it out for GET requests and requests to external websites
- if ($CI->config->item('csrf_protection') === TRUE AND ! (strpos($action, $CI->config->base_url()) === FALSE OR strpos($form, 'method="get"')))
+ // Add CSRF field if enabled, but leave it out for GET requests and requests to external websites
+ if ($CI->config->item('csrf_protection') === TRUE && ! (strpos($action, $CI->config->base_url()) === FALSE OR strpos($form, 'method="get"')))
{
$hidden[$CI->security->get_csrf_token_name()] = $CI->security->get_csrf_hash();
}
- if (is_array($hidden) AND count($hidden) > 0)
+ if (is_array($hidden) && count($hidden) > 0)
{
- $form .= sprintf("<div style=\"display:none\">%s</div>", form_hidden($hidden));
+ $form .= sprintf('<div style="display:none;">%s</div>', form_hidden($hidden));
}
return $form;
@@ -93,7 +90,6 @@ if ( ! function_exists('form_open'))
*
* Creates the opening portion of the form, but with "multipart/form-data".
*
- * @access public
* @param string the URI segments of the form destination
* @param array a key/value pair of attributes
* @param array a key/value pair hidden data
@@ -121,10 +117,9 @@ if ( ! function_exists('form_open_multipart'))
/**
* Hidden Input Field
*
- * Generates hidden fields. You can pass a simple key/value string or an associative
- * array with multiple values.
+ * Generates hidden fields. You can pass a simple key/value string or
+ * an associative array with multiple values.
*
- * @access public
* @param mixed
* @param string
* @return string
@@ -157,7 +152,7 @@ if ( ! function_exists('form_hidden'))
{
foreach ($value as $k => $v)
{
- $k = (is_int($k)) ? '' : $k;
+ $k = is_int($k) ? '' : $k;
form_hidden($name.'['.$k.']', $v, TRUE);
}
}
@@ -171,7 +166,6 @@ if ( ! function_exists('form_hidden'))
/**
* Text Input Field
*
- * @access public
* @param mixed
* @param string
* @param string
@@ -181,7 +175,7 @@ if ( ! function_exists('form_input'))
{
function form_input($data = '', $value = '', $extra = '')
{
- $defaults = array('type' => 'text', 'name' => (( ! is_array($data)) ? $data : ''), 'value' => $value);
+ $defaults = array('type' => 'text', 'name' => ( ! is_array($data) ? $data : ''), 'value' => $value);
return '<input '._parse_form_attributes($data, $defaults).$extra." />\n";
}
@@ -194,7 +188,6 @@ if ( ! function_exists('form_input'))
*
* Identical to the input function but adds the "password" type
*
- * @access public
* @param mixed
* @param string
* @param string
@@ -221,7 +214,6 @@ if ( ! function_exists('form_password'))
*
* Identical to the input function but adds the "file" type
*
- * @access public
* @param mixed
* @param string
* @param string
@@ -246,7 +238,6 @@ if ( ! function_exists('form_upload'))
/**
* Textarea field
*
- * @access public
* @param mixed
* @param string
* @param string
@@ -256,7 +247,7 @@ if ( ! function_exists('form_textarea'))
{
function form_textarea($data = '', $value = '', $extra = '')
{
- $defaults = array('name' => (( ! is_array($data)) ? $data : ''), 'cols' => '40', 'rows' => '10');
+ $defaults = array('name' => ( ! is_array($data) ? $data : ''), 'cols' => '40', 'rows' => '10');
if ( ! is_array($data) OR ! isset($data['value']))
{
@@ -268,7 +259,7 @@ if ( ! function_exists('form_textarea'))
unset($data['value']); // textareas don't use the value attribute
}
- $name = (is_array($data)) ? $data['name'] : $data;
+ $name = is_array($data) ? $data['name'] : $data;
return '<textarea '._parse_form_attributes($data, $defaults).$extra.'>'.form_prep($val, $name)."</textarea>\n";
}
}
@@ -278,12 +269,11 @@ if ( ! function_exists('form_textarea'))
/**
* Multi-select menu
*
- * @access public
* @param string
* @param array
* @param mixed
* @param string
- * @return type
+ * @return string
*/
if ( ! function_exists('form_multiselect'))
{
@@ -303,7 +293,6 @@ if ( ! function_exists('form_multiselect'))
/**
* Drop-down Menu
*
- * @access public
* @param string
* @param array
* @param string
@@ -314,28 +303,16 @@ if ( ! function_exists('form_dropdown'))
{
function form_dropdown($name = '', $options = array(), $selected = array(), $extra = '')
{
- // If name is really an array then we'll call the function again using the array
- if (is_array($name) && isset($name['name']))
- {
-
- if ( ! isset($name['options']))
- {
- $name['options'] = array();
- }
-
- if ( ! isset($name['selected']))
- {
- $name['selected'] = array();
- }
-
- if ( ! isset($name['extra']))
- {
- $name['extra'] = '';
- }
-
- return form_dropdown($name['name'], $name['options'], $name['selected'], $name['extra']);
- }
-
+ // If name is really an array then we'll call the function again using the array
+ if (is_array($name) && isset($name['name']))
+ {
+ isset($name['options']) OR $name['options'] = array();
+ isset($name['selected']) OR $name['selected'] = array();
+ isset($name['extra']) OR $name['extra'] = array();
+
+ return form_dropdown($name['name'], $name['options'], $name['selected'], $name['extra']);
+ }
+
if ( ! is_array($selected))
{
$selected = array($selected);
@@ -363,11 +340,11 @@ if ( ! function_exists('form_dropdown'))
foreach ($val as $optgroup_key => $optgroup_val)
{
- $sel = (in_array($optgroup_key, $selected)) ? ' selected="selected"' : '';
+ $sel = in_array($optgroup_key, $selected) ? ' selected="selected"' : '';
$form .= '<option value="'.$optgroup_key.'"'.$sel.'>'.(string) $optgroup_val."</option>\n";
}
- $form .= '</optgroup>'."\n";
+ $form .= "</optgroup>\n";
}
else
{
@@ -375,9 +352,7 @@ if ( ! function_exists('form_dropdown'))
}
}
- $form .= "</select>\n";
-
- return $form;
+ return $form."</select>\n";
}
}
@@ -386,7 +361,6 @@ if ( ! function_exists('form_dropdown'))
/**
* Checkbox Field
*
- * @access public
* @param mixed
* @param string
* @param bool
@@ -397,9 +371,9 @@ if ( ! function_exists('form_checkbox'))
{
function form_checkbox($data = '', $value = '', $checked = FALSE, $extra = '')
{
- $defaults = array('type' => 'checkbox', 'name' => (( ! is_array($data)) ? $data : ''), 'value' => $value);
+ $defaults = array('type' => 'checkbox', 'name' => ( ! is_array($data) ? $data : ''), 'value' => $value);
- if (is_array($data) AND array_key_exists('checked', $data))
+ if (is_array($data) && array_key_exists('checked', $data))
{
$checked = $data['checked'];
@@ -431,7 +405,6 @@ if ( ! function_exists('form_checkbox'))
/**
* Radio Button
*
- * @access public
* @param mixed
* @param string
* @param bool
@@ -457,7 +430,6 @@ if ( ! function_exists('form_radio'))
/**
* Submit Button
*
- * @access public
* @param mixed
* @param string
* @param string
@@ -467,7 +439,7 @@ if ( ! function_exists('form_submit'))
{
function form_submit($data = '', $value = '', $extra = '')
{
- $defaults = array('type' => 'submit', 'name' => (( ! is_array($data)) ? $data : ''), 'value' => $value);
+ $defaults = array('type' => 'submit', 'name' => ( ! is_array($data) ? $data : ''), 'value' => $value);
return '<input '._parse_form_attributes($data, $defaults).$extra." />\n";
}
}
@@ -477,7 +449,6 @@ if ( ! function_exists('form_submit'))
/**
* Reset Button
*
- * @access public
* @param mixed
* @param string
* @param string
@@ -487,7 +458,7 @@ if ( ! function_exists('form_reset'))
{
function form_reset($data = '', $value = '', $extra = '')
{
- $defaults = array('type' => 'reset', 'name' => (( ! is_array($data)) ? $data : ''), 'value' => $value);
+ $defaults = array('type' => 'reset', 'name' => ( ! is_array($data) ? $data : ''), 'value' => $value);
return '<input '._parse_form_attributes($data, $defaults).$extra." />\n";
}
}
@@ -497,7 +468,6 @@ if ( ! function_exists('form_reset'))
/**
* Form Button
*
- * @access public
* @param mixed
* @param string
* @param string
@@ -507,8 +477,8 @@ if ( ! function_exists('form_button'))
{
function form_button($data = '', $content = '', $extra = '')
{
- $defaults = array('name' => (( ! is_array($data)) ? $data : ''), 'type' => 'button');
- if ( is_array($data) AND isset($data['content']))
+ $defaults = array('name' => ( ! is_array($data) ? $data : ''), 'type' => 'button');
+ if (is_array($data) && isset($data['content']))
{
$content = $data['content'];
unset($data['content']); // content is not an attribute
@@ -523,7 +493,6 @@ if ( ! function_exists('form_button'))
/**
* Form Label Tag
*
- * @access public
* @param string The text to appear onscreen
* @param string The id the label applies to
* @param string Additional attributes
@@ -538,10 +507,10 @@ if ( ! function_exists('form_label'))
if ($id != '')
{
- $label .= " for=\"$id\"";
+ $label .= ' for="'.$id.'"';
}
- if (is_array($attributes) AND count($attributes) > 0)
+ if (is_array($attributes) && count($attributes) > 0)
{
foreach ($attributes as $key => $val)
{
@@ -549,7 +518,7 @@ if ( ! function_exists('form_label'))
}
}
- return $label .= ">$label_text</label>";
+ return $label.'>'.$label_text.'</label>';
}
}
@@ -560,7 +529,6 @@ if ( ! function_exists('form_label'))
* Used to produce <fieldset><legend>text</legend>. To close fieldset
* use form_fieldset_close()
*
- * @access public
* @param string The legend text
* @param string Additional attributes
* @return string
@@ -572,7 +540,7 @@ if ( ! function_exists('form_fieldset'))
$fieldset = '<fieldset'._attributes_to_string($attributes, FALSE).">\n";
if ($legend_text != '')
{
- $fieldset .= "<legend>$legend_text</legend>\n";
+ return $fieldset.'<legend>'.$legend_text."</legend>\n";
}
return $fieldset;
@@ -584,7 +552,6 @@ if ( ! function_exists('form_fieldset'))
/**
* Fieldset Close Tag
*
- * @access public
* @param string
* @return string
*/
@@ -592,7 +559,7 @@ if ( ! function_exists('form_fieldset_close'))
{
function form_fieldset_close($extra = '')
{
- return "</fieldset>".$extra;
+ return '</fieldset>'.$extra;
}
}
@@ -601,7 +568,6 @@ if ( ! function_exists('form_fieldset_close'))
/**
* Form Close Tag
*
- * @access public
* @param string
* @return string
*/
@@ -609,7 +575,7 @@ if ( ! function_exists('form_close'))
{
function form_close($extra = '')
{
- return "</form>".$extra;
+ return '</form>'.$extra;
}
}
@@ -620,7 +586,6 @@ if ( ! function_exists('form_close'))
*
* Formats text so that it can be safely placed in a form field in the event it has HTML tags.
*
- * @access public
* @param string
* @return string
*/
@@ -670,10 +635,9 @@ if ( ! function_exists('form_prep'))
* Form Value
*
* Grabs a value from the POST array for the specified field so you can
- * re-populate an input field or textarea. If Form Validation
+ * re-populate an input field or textarea. If Form Validation
* is active it retrieves the info from the validation class
*
- * @access public
* @param string
* @return mixed
*/
@@ -703,7 +667,6 @@ if ( ! function_exists('set_value'))
* Let's you set the selected value of a <select> menu via data in the POST array.
* If Form Validation is active it retrieves the info from the validation class
*
- * @access public
* @param string
* @param string
* @param bool
@@ -719,7 +682,7 @@ if ( ! function_exists('set_select'))
{
if ( ! isset($_POST[$field]))
{
- if (count($_POST) === 0 AND $default == TRUE)
+ if (count($_POST) === 0 && $default == TRUE)
{
return ' selected="selected"';
}
@@ -735,12 +698,9 @@ if ( ! function_exists('set_select'))
return '';
}
}
- else
+ elseif (($field == '' OR $value == '') OR ($field != $value))
{
- if (($field == '' OR $value == '') OR ($field != $value))
- {
- return '';
- }
+ return '';
}
return ' selected="selected"';
@@ -758,7 +718,6 @@ if ( ! function_exists('set_select'))
* Let's you set the selected value of a checkbox via the value in the POST array.
* If Form Validation is active it retrieves the info from the validation class
*
- * @access public
* @param string
* @param string
* @param bool
@@ -774,7 +733,7 @@ if ( ! function_exists('set_checkbox'))
{
if ( ! isset($_POST[$field]))
{
- if (count($_POST) === 0 AND $default == TRUE)
+ if (count($_POST) === 0 && $default == TRUE)
{
return ' checked="checked"';
}
@@ -790,12 +749,9 @@ if ( ! function_exists('set_checkbox'))
return '';
}
}
- else
+ elseif (($field == '' OR $value == '') OR ($field != $value))
{
- if (($field == '' OR $value == '') OR ($field != $value))
- {
- return '';
- }
+ return '';
}
return ' checked="checked"';
@@ -813,7 +769,6 @@ if ( ! function_exists('set_checkbox'))
* Let's you set the selected value of a radio field via info in the POST array.
* If Form Validation is active it retrieves the info from the validation class
*
- * @access public
* @param string
* @param string
* @param bool
@@ -829,7 +784,7 @@ if ( ! function_exists('set_radio'))
{
if ( ! isset($_POST[$field]))
{
- if (count($_POST) === 0 AND $default == TRUE)
+ if (count($_POST) === 0 && $default == TRUE)
{
return ' checked="checked"';
}
@@ -865,10 +820,9 @@ if ( ! function_exists('set_radio'))
/**
* Form Error
*
- * Returns the error for a specific form field. This is a helper for the
+ * Returns the error for a specific form field. This is a helper for the
* form validation class.
*
- * @access public
* @param string
* @param string
* @param string
@@ -892,10 +846,9 @@ if ( ! function_exists('form_error'))
/**
* Validation Error String
*
- * Returns all the errors associated with a form submission. This is a helper
+ * Returns all the errors associated with a form submission. This is a helper
* function for the form validation class.
*
- * @access public
* @param string
* @param string
* @return string
@@ -920,7 +873,6 @@ if ( ! function_exists('validation_errors'))
*
* Helper function used by some of the form helpers
*
- * @access private
* @param array
* @param array
* @return string
@@ -955,7 +907,7 @@ if ( ! function_exists('_parse_form_attributes'))
$val = form_prep($val, $default['name']);
}
- $att .= $key . '="' . $val . '" ';
+ $att .= $key.'="'.$val.'" ';
}
return $att;
@@ -969,7 +921,6 @@ if ( ! function_exists('_parse_form_attributes'))
*
* Helper function used by some of the form helpers
*
- * @access private
* @param mixed
* @param bool
* @return string
@@ -978,14 +929,14 @@ if ( ! function_exists('_attributes_to_string'))
{
function _attributes_to_string($attributes, $formtag = FALSE)
{
- if (is_string($attributes) AND strlen($attributes) > 0)
+ if (is_string($attributes) && strlen($attributes) > 0)
{
- if ($formtag == TRUE AND strpos($attributes, 'method=') === FALSE)
+ if ($formtag == TRUE && strpos($attributes, 'method=') === FALSE)
{
$attributes .= ' method="post"';
}
- if ($formtag == TRUE AND strpos($attributes, 'accept-charset=') === FALSE)
+ if ($formtag == TRUE && strpos($attributes, 'accept-charset=') === FALSE)
{
$attributes .= ' accept-charset="'.strtolower(config_item('charset')).'"';
}
@@ -993,21 +944,21 @@ if ( ! function_exists('_attributes_to_string'))
return ' '.$attributes;
}
- if (is_object($attributes) AND count($attributes) > 0)
+ if (is_object($attributes) && count($attributes) > 0)
{
- $attributes = (array)$attributes;
+ $attributes = (array) $attributes;
}
- if (is_array($attributes) AND ($formtag === TRUE OR count($attributes) > 0))
+ if (is_array($attributes) && ($formtag === TRUE OR count($attributes) > 0))
{
$atts = '';
- if ( ! isset($attributes['method']) AND $formtag === TRUE)
+ if ( ! isset($attributes['method']) && $formtag === TRUE)
{
$atts .= ' method="post"';
}
- if ( ! isset($attributes['accept-charset']) AND $formtag === TRUE)
+ if ( ! isset($attributes['accept-charset']) && $formtag === TRUE)
{
$atts .= ' accept-charset="'.strtolower(config_item('charset')).'"';
}
@@ -1030,7 +981,6 @@ if ( ! function_exists('_attributes_to_string'))
* Determines what the form validation class was instantiated as, fetches
* the object and returns it.
*
- * @access private
* @return mixed
*/
if ( ! function_exists('_get_validation_object'))
@@ -1057,4 +1007,4 @@ if ( ! function_exists('_get_validation_object'))
}
/* End of file form_helper.php */
-/* Location: ./system/helpers/form_helper.php */
+/* Location: ./system/helpers/form_helper.php */ \ No newline at end of file
diff --git a/system/helpers/html_helper.php b/system/helpers/html_helper.php
index b8c4f36f6..0417bd253 100644
--- a/system/helpers/html_helper.php
+++ b/system/helpers/html_helper.php
@@ -25,8 +25,6 @@
* @filesource
*/
-// ------------------------------------------------------------------------
-
/**
* CodeIgniter HTML Helpers
*
@@ -42,12 +40,10 @@
/**
* Heading
*
- * Generates an HTML heading tag. First param is the data.
- * Second param is the size of the heading tag.
+ * Generates an HTML heading tag.
*
- * @access public
- * @param string
- * @param integer
+ * @param string content
+ * @param int heading level
* @return string
*/
if ( ! function_exists('heading'))
@@ -65,7 +61,6 @@ if ( ! function_exists('heading'))
*
* Generates an HTML unordered list from an single or multi-dimensional array.
*
- * @access public
* @param array
* @param mixed
* @return string
@@ -85,7 +80,6 @@ if ( ! function_exists('ul'))
*
* Generates an HTML ordered list from an single or multi-dimensional array.
*
- * @access public
* @param array
* @param mixed
* @return string
@@ -105,11 +99,10 @@ if ( ! function_exists('ol'))
*
* Generates an HTML ordered list from an single or multi-dimensional array.
*
- * @access private
* @param string
* @param mixed
* @param mixed
- * @param integer
+ * @param int
* @return string
*/
if ( ! function_exists('_list'))
@@ -131,13 +124,13 @@ if ( ! function_exists('_list'))
$atts = '';
foreach ($attributes as $key => $val)
{
- $atts .= ' ' . $key . '="' . $val . '"';
+ $atts .= ' '.$key.'="'.$val.'"';
}
$attributes = $atts;
}
- elseif (is_string($attributes) AND strlen($attributes) > 0)
+ elseif (is_string($attributes) && strlen($attributes) > 0)
{
- $attributes = ' '. $attributes;
+ $attributes = ' '.$attributes;
}
// Write the opening list tag
@@ -175,8 +168,7 @@ if ( ! function_exists('_list'))
/**
* Generates HTML BR tags based on number supplied
*
- * @access public
- * @param integer
+ * @param int
* @return string
*/
if ( ! function_exists('br'))
@@ -194,8 +186,8 @@ if ( ! function_exists('br'))
*
* Generates an <img /> element
*
- * @access public
* @param mixed
+ * @param bool
* @return string
*/
if ( ! function_exists('img'))
@@ -217,7 +209,7 @@ if ( ! function_exists('img'))
foreach ($src as $k => $v)
{
- if ($k === 'src' AND strpos($v, '://') === FALSE)
+ if ($k === 'src' && strpos($v, '://') === FALSE)
{
$CI =& get_instance();
@@ -232,7 +224,7 @@ if ( ! function_exists('img'))
}
else
{
- $img .= " $k=\"$v\"";
+ $img .= ' '.$k.'="'.$v.'"';
}
}
@@ -248,10 +240,9 @@ if ( ! function_exists('img'))
* 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
+ * 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
*/
@@ -263,7 +254,7 @@ if ( ! function_exists('doctype'))
if ( ! is_array($_doctypes))
{
- if (defined('ENVIRONMENT') AND is_file(APPPATH.'config/'.ENVIRONMENT.'/doctypes.php'))
+ if (defined('ENVIRONMENT') && is_file(APPPATH.'config/'.ENVIRONMENT.'/doctypes.php'))
{
include(APPPATH.'config/'.ENVIRONMENT.'/doctypes.php');
}
@@ -278,7 +269,7 @@ if ( ! function_exists('doctype'))
}
}
- return (isset($_doctypes[$type])) ? $_doctypes[$type] : FALSE;
+ return isset($_doctypes[$type]) ? $_doctypes[$type] : FALSE;
}
}
@@ -289,13 +280,12 @@ if ( ! function_exists('doctype'))
*
* 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
+ * @param bool should index_page be added to the css path
* @return string
*/
if ( ! function_exists('link_tag'))
@@ -309,7 +299,7 @@ if ( ! function_exists('link_tag'))
{
foreach ($href as $k => $v)
{
- if ($k === 'href' AND strpos($v, '://') === FALSE)
+ if ($k === 'href' && strpos($v, '://') === FALSE)
{
if ($index_page === TRUE)
{
@@ -322,11 +312,9 @@ if ( ! function_exists('link_tag'))
}
else
{
- $link .= "$k=\"$v\" ";
+ $link .= $k.'="'.$v.'" ';
}
}
-
- $link .= '/>';
}
else
{
@@ -354,11 +342,9 @@ if ( ! function_exists('link_tag'))
{
$link .= 'title="'.$title.'" ';
}
-
- $link .= '/>';
}
- return $link."\n";
+ return $link."/>\n";
}
}
@@ -367,8 +353,10 @@ if ( ! function_exists('link_tag'))
/**
* Generates meta tags from an array of key/values
*
- * @access public
* @param array
+ * @param string
+ * @param string
+ * @param string
* @return string
*/
if ( ! function_exists('meta'))
@@ -381,13 +369,10 @@ if ( ! function_exists('meta'))
{
$name = array(array('name' => $name, 'content' => $content, 'type' => $type, 'newline' => $newline));
}
- else
+ elseif (isset($name['name']))
{
// Turn single array into multidimensional
- if (isset($name['name']))
- {
- $name = array($name);
- }
+ $name = array($name);
}
$str = '';
@@ -410,8 +395,7 @@ if ( ! function_exists('meta'))
/**
* Generates non-breaking space entities based on number supplied
*
- * @access public
- * @param integer
+ * @param int
* @return string
*/
if ( ! function_exists('nbs'))
@@ -423,4 +407,4 @@ if ( ! function_exists('nbs'))
}
/* End of file html_helper.php */
-/* Location: ./system/helpers/html_helper.php */
+/* Location: ./system/helpers/html_helper.php */ \ No newline at end of file
diff --git a/system/helpers/inflector_helper.php b/system/helpers/inflector_helper.php
index 9cf015d2b..feeaf57d7 100644
--- a/system/helpers/inflector_helper.php
+++ b/system/helpers/inflector_helper.php
@@ -170,7 +170,7 @@ if ( ! function_exists('camelize'))
{
function camelize($str)
{
- return str_replace(' ', '', ucwords(preg_replace('/[\s_]+/', ' ', strtolower($str))));
+ return strtolower($str[0]).substr(str_replace(' ', '', ucwords(preg_replace('/[\s_]+/', ' ', $str))), 1);
}
}
@@ -199,8 +199,8 @@ if ( ! function_exists('underscore'))
*
* Takes multiple words separated by the separator and changes them to spaces
*
- * @param string $str
- * @param string $separator
+ * @param string $str
+ * @param string $separator
* @return str
*/
if ( ! function_exists('humanize'))
@@ -214,19 +214,21 @@ if ( ! function_exists('humanize'))
/**
* Checks if the given word has a plural version.
*
- * @param string the word to check
- * @return bool if the word is countable
+ * @param string the word to check
+ * @return bool if the word is countable
*/
if ( ! function_exists('is_countable'))
{
function is_countable($word)
{
- return ! (in_array(strtolower(strval($word)), array(
- 'equipment', 'information', 'rice', 'money',
- 'species', 'series', 'fish', 'meta'
- )));
+ return ! in_array(strtolower(strval($word)),
+ array(
+ 'equipment', 'information', 'rice', 'money',
+ 'species', 'series', 'fish', 'meta'
+ )
+ );
}
}
/* End of file inflector_helper.php */
-/* Location: ./system/helpers/inflector_helper.php */
+/* Location: ./system/helpers/inflector_helper.php */ \ No newline at end of file
diff --git a/system/helpers/language_helper.php b/system/helpers/language_helper.php
index 1d66df59f..b31c97107 100644
--- a/system/helpers/language_helper.php
+++ b/system/helpers/language_helper.php
@@ -25,8 +25,6 @@
* @filesource
*/
-// ------------------------------------------------------------------------
-
/**
* CodeIgniter Language Helpers
*
@@ -44,7 +42,6 @@
*
* 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
@@ -58,7 +55,7 @@ if ( ! function_exists('lang'))
if ($id != '')
{
- $line = '<label for="'.$id.'">'.$line."</label>";
+ $line = '<label for="'.$id.'">'.$line.'</label>';
}
return $line;
@@ -66,4 +63,4 @@ if ( ! function_exists('lang'))
}
/* End of file language_helper.php */
-/* Location: ./system/helpers/language_helper.php */
+/* Location: ./system/helpers/language_helper.php */ \ No newline at end of file
diff --git a/system/helpers/number_helper.php b/system/helpers/number_helper.php
index b6c823d8b..40da6e7bf 100644
--- a/system/helpers/number_helper.php
+++ b/system/helpers/number_helper.php
@@ -25,8 +25,6 @@
* @filesource
*/
-// ------------------------------------------------------------------------
-
/**
* CodeIgniter Number Helpers
*
@@ -42,7 +40,6 @@
/**
* Formats a numbers as bytes, based on size, and adds the appropriate suffix
*
- * @access public
* @param mixed // will be cast as int
* @return string
*/
@@ -84,4 +81,4 @@ if ( ! function_exists('byte_format'))
}
/* End of file number_helper.php */
-/* Location: ./system/helpers/number_helper.php */
+/* Location: ./system/helpers/number_helper.php */ \ No newline at end of file
diff --git a/system/helpers/path_helper.php b/system/helpers/path_helper.php
index 2eb85fefa..6ee99072c 100644
--- a/system/helpers/path_helper.php
+++ b/system/helpers/path_helper.php
@@ -25,8 +25,6 @@
* @filesource
*/
-// ------------------------------------------------------------------------
-
/**
* CodeIgniter Path Helpers
*
@@ -42,7 +40,6 @@
/**
* Set Realpath
*
- * @access public
* @param string
* @param bool checks to see if the path exists
* @return string
@@ -51,30 +48,26 @@ if ( ! function_exists('set_realpath'))
{
function set_realpath($path, $check_existance = FALSE)
{
- // Security check to make sure the path is NOT a URL. No remote file inclusion!
- if (preg_match("#^(http:\/\/|https:\/\/|www\.|ftp|[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3})#i", $path))
+ // Security check to make sure the path is NOT a URL. No remote file inclusion!
+ if (preg_match('#^(http:\/\/|https:\/\/|www\.|ftp|[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3})#i', $path))
{
show_error('The path you submitted must be a local server path, not a URL');
}
// Resolve the path
- if (function_exists('realpath') AND @realpath($path) !== FALSE)
+ if (function_exists('realpath') && @realpath($path) !== FALSE)
{
$path = realpath($path);
}
-
- // Add a trailing slash
- $path = rtrim($path, DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR;
-
- // Make sure the path exists
- if ($check_existance == TRUE && ! is_dir($path))
+ elseif ($check_existance && ! is_dir($path) && ! is_file($path))
{
show_error('Not a valid path: '.$path);
}
- return $path;
+ // Add a trailing slash, if this is a directory
+ return is_dir($path) ? rtrim($path, DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR : $path;
}
}
/* End of file path_helper.php */
-/* Location: ./system/helpers/path_helper.php */
+/* Location: ./system/helpers/path_helper.php */ \ No newline at end of file
diff --git a/system/helpers/security_helper.php b/system/helpers/security_helper.php
index e05e947a5..d6f134c9f 100644
--- a/system/helpers/security_helper.php
+++ b/system/helpers/security_helper.php
@@ -25,8 +25,6 @@
* @filesource
*/
-// ------------------------------------------------------------------------
-
/**
* CodeIgniter Security Helpers
*
@@ -42,7 +40,6 @@
/**
* XSS Filtering
*
- * @access public
* @param string
* @param bool whether or not the content is an image file
* @return string
@@ -61,7 +58,6 @@ if ( ! function_exists('xss_clean'))
/**
* Sanitize Filename
*
- * @access public
* @param string
* @return string
*/
@@ -79,7 +75,6 @@ if ( ! function_exists('sanitize_filename'))
/**
* Hash encode a string
*
- * @access public
* @param string
* @return string
*/
@@ -87,7 +82,12 @@ if ( ! function_exists('do_hash'))
{
function do_hash($str, $type = 'sha1')
{
- return ($type === 'sha1') ? sha1($str) : md5($str);
+ if ( ! in_array(strtolower($type), hash_algos()))
+ {
+ $type = 'md5';
+ }
+
+ return hash($type, $str);
}
}
@@ -96,7 +96,6 @@ if ( ! function_exists('do_hash'))
/**
* Strip Image Tags
*
- * @access public
* @param string
* @return string
*/
@@ -104,7 +103,7 @@ if ( ! function_exists('strip_image_tags'))
{
function strip_image_tags($str)
{
- return preg_replace(array("#<img\s+.*?src\s*=\s*[\"'](.+?)[\"'].*?\>#", "#<img\s+.*?src\s*=\s*(.+?).*?\>#"), "\\1", $str);
+ return preg_replace(array('#<img\s+.*?src\s*=\s*["\'](.+?)["\'].*?\>#', '#<img\s+.*?src\s*=\s*(.+?).*?\>#'), '\\1', $str);
}
}
@@ -113,7 +112,6 @@ if ( ! function_exists('strip_image_tags'))
/**
* Convert PHP tags to entities
*
- * @access public
* @param string
* @return string
*/
@@ -126,4 +124,4 @@ if ( ! function_exists('encode_php_tags'))
}
/* End of file security_helper.php */
-/* Location: ./system/helpers/security_helper.php */
+/* Location: ./system/helpers/security_helper.php */ \ No newline at end of file
diff --git a/system/helpers/smiley_helper.php b/system/helpers/smiley_helper.php
index cc903bc1c..8dba74e73 100644
--- a/system/helpers/smiley_helper.php
+++ b/system/helpers/smiley_helper.php
@@ -1,13 +1,13 @@
-<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
* An open source application development framework for PHP 5.2.4 or newer
*
* NOTICE OF LICENSE
- *
+ *
* Licensed under the Open Software License version 3.0
- *
+ *
* This source file is subject to the Open Software License (OSL 3.0) that is
* bundled with this package in the files license.txt / license.rst. It is
* also available through the world wide web at this URL:
@@ -25,8 +25,6 @@
* @filesource
*/
-// ------------------------------------------------------------------------
-
/**
* CodeIgniter Smiley Helpers
*
@@ -45,7 +43,6 @@
* Returns the javascript required for the smiley insertion. Optionally takes
* an array of aliases to loosely couple the smiley array to the view.
*
- * @access public
* @param mixed alias name or array of alias->field_id pairs
* @param string field_id if alias name was passed in
* @return array
@@ -139,7 +136,6 @@ EOF;
* Returns an array of image tag links that can be clicked to be inserted
* into a form field.
*
- * @access public
* @param string the URL to the folder containing the smiley images
* @return array
*/
@@ -193,7 +189,6 @@ if ( ! function_exists('get_clickable_smileys'))
*
* Takes a string as input and swaps any contained smileys for the actual image
*
- * @access public
* @param string the text to be parsed
* @param string the URL to the folder containing the smiley images
* @return string
@@ -234,14 +229,13 @@ if ( ! function_exists('parse_smileys'))
*
* Fetches the config/smiley.php file
*
- * @access private
* @return mixed
*/
if ( ! function_exists('_get_smiley_array'))
{
function _get_smiley_array()
{
- if (defined('ENVIRONMENT') AND file_exists(APPPATH.'config/'.ENVIRONMENT.'/smileys.php'))
+ if (defined('ENVIRONMENT') && file_exists(APPPATH.'config/'.ENVIRONMENT.'/smileys.php'))
{
include(APPPATH.'config/'.ENVIRONMENT.'/smileys.php');
}
@@ -249,8 +243,8 @@ if ( ! function_exists('_get_smiley_array'))
{
include(APPPATH.'config/smileys.php');
}
-
- if (isset($smileys) AND is_array($smileys))
+
+ if (isset($smileys) && is_array($smileys))
{
return $smileys;
}
@@ -268,7 +262,6 @@ if ( ! function_exists('_get_smiley_array'))
*
* DEPRECATED as of version 1.7.2, use smiley_js instead
*
- * @access public
* @param string form name
* @param string field name
* @return string
@@ -288,6 +281,5 @@ EOF;
}
}
-
/* End of file smiley_helper.php */
/* Location: ./system/helpers/smiley_helper.php */ \ No newline at end of file
diff --git a/system/helpers/string_helper.php b/system/helpers/string_helper.php
index 607a12bcb..aed35c157 100644
--- a/system/helpers/string_helper.php
+++ b/system/helpers/string_helper.php
@@ -1,13 +1,13 @@
-<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
* An open source application development framework for PHP 5.2.4 or newer
*
* NOTICE OF LICENSE
- *
+ *
* Licensed under the Open Software License version 3.0
- *
+ *
* This source file is subject to the Open Software License (OSL 3.0) that is
* bundled with this package in the files license.txt / license.rst. It is
* also available through the world wide web at this URL:
@@ -25,8 +25,6 @@
* @filesource
*/
-// ------------------------------------------------------------------------
-
/**
* CodeIgniter String Helpers
*
@@ -50,7 +48,6 @@
*
* this/that/theother
*
- * @access public
* @param string
* @return string
*/
@@ -69,7 +66,6 @@ if ( ! function_exists('trim_slashes'))
*
* Removes slashes contained in a string or in an array
*
- * @access public
* @param mixed string or array
* @return mixed string or array
*/
@@ -100,7 +96,6 @@ if ( ! function_exists('strip_slashes'))
*
* Removes single and double quotes from a string
*
- * @access public
* @param string
* @return string
*/
@@ -119,7 +114,6 @@ if ( ! function_exists('strip_quotes'))
*
* Converts single and double quotes to entities
*
- * @access public
* @param string
* @return string
*/
@@ -145,7 +139,6 @@ if ( ! function_exists('quotes_to_entities'))
*
* http://www.some-site.com/index.php
*
- * @access public
* @param string
* @return string
*/
@@ -153,7 +146,7 @@ if ( ! function_exists('reduce_double_slashes'))
{
function reduce_double_slashes($str)
{
- return preg_replace("#(^|[^:])//+#", "\\1/", $str);
+ return preg_replace('#(^|[^:])//+#', '\\1/', $str);
}
}
@@ -170,7 +163,6 @@ if ( ! function_exists('reduce_double_slashes'))
*
* Fred, Bill, Joe, Jimmy
*
- * @access public
* @param string
* @param string the character you wish to reduce
* @param bool TRUE/FALSE - whether to trim the character from the beginning/end
@@ -184,7 +176,7 @@ if ( ! function_exists('reduce_multiples'))
if ($trim === TRUE)
{
- $str = trim($str, $character);
+ return trim($str, $character);
}
return $str;
@@ -198,9 +190,8 @@ if ( ! function_exists('reduce_multiples'))
*
* Useful for generating passwords or hashes.
*
- * @access public
* @param string type of random string. basic, alpha, alunum, numeric, nozero, unique, md5, encrypt and sha1
- * @param integer number of characters
+ * @param int number of characters
* @return string
*/
if ( ! function_exists('random_string'))
@@ -227,9 +218,9 @@ if ( ! function_exists('random_string'))
case 'nozero' : $pool = '123456789';
break;
}
-
+
$str = substr(str_shuffle(str_repeat($pool, ceil($len/strlen($pool)))),0,$len);
-
+
return $str;
break;
case 'unique' :
@@ -254,16 +245,19 @@ if ( ! function_exists('random_string'))
/**
* Add's _1 to a string or increment the ending number to allow _2, _3, etc
*
- * @param string $str required
- * @param string $separator What should the duplicate number be appended with
- * @param string $first Which number should be used for the first dupe increment
- * @return string
+ * @param string required
+ * @param string What should the duplicate number be appended with
+ * @param string Which number should be used for the first dupe increment
+ * @return string
*/
-function increment_string($str, $separator = '_', $first = 1)
+if ( ! function_exists('increment_string'))
{
- preg_match('/(.+)'.$separator.'([0-9]+)$/', $str, $match);
+ function increment_string($str, $separator = '_', $first = 1)
+ {
+ preg_match('/(.+)'.$separator.'([0-9]+)$/', $str, $match);
- return isset($match[2]) ? $match[1].$separator.($match[2] + 1) : $str.$separator.$first;
+ return isset($match[2]) ? $match[1].$separator.($match[2] + 1) : $str.$separator.$first;
+ }
}
// ------------------------------------------------------------------------
@@ -271,9 +265,8 @@ function increment_string($str, $separator = '_', $first = 1)
/**
* Alternator
*
- * Allows strings to be alternated. See docs...
+ * Allows strings to be alternated. See docs...
*
- * @access public
* @param string (as many parameters as needed)
* @return string
*/
@@ -298,19 +291,17 @@ if ( ! function_exists('alternator'))
/**
* Repeater function
*
- * @access public
* @param string
- * @param integer number of repeats
+ * @param int number of repeats
* @return string
*/
if ( ! function_exists('repeater'))
{
function repeater($data, $num = 1)
{
- return (($num > 0) ? str_repeat($data, $num) : '');
+ return ($num > 0) ? str_repeat($data, $num) : '';
}
}
-
/* End of file string_helper.php */
/* Location: ./system/helpers/string_helper.php */ \ No newline at end of file
diff --git a/system/helpers/text_helper.php b/system/helpers/text_helper.php
index 7591bac5f..cc501c334 100644
--- a/system/helpers/text_helper.php
+++ b/system/helpers/text_helper.php
@@ -1,13 +1,13 @@
-<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
* An open source application development framework for PHP 5.2.4 or newer
*
* NOTICE OF LICENSE
- *
+ *
* Licensed under the Open Software License version 3.0
- *
+ *
* This source file is subject to the Open Software License (OSL 3.0) that is
* bundled with this package in the files license.txt / license.rst. It is
* also available through the world wide web at this URL:
@@ -25,8 +25,6 @@
* @filesource
*/
-// ------------------------------------------------------------------------
-
/**
* CodeIgniter Text Helpers
*
@@ -44,9 +42,8 @@
*
* Limits a string to X number of words.
*
- * @access public
* @param string
- * @param integer
+ * @param int
* @param string the end character. Usually an ellipsis
* @return string
*/
@@ -78,9 +75,8 @@ if ( ! function_exists('word_limiter'))
* Limits the string based on the character count. Preserves complete words
* so the character count may not be exactly as specified.
*
- * @access public
* @param string
- * @param integer
+ * @param int
* @param string the end character. Usually an ellipsis
* @return string
*/
@@ -121,7 +117,6 @@ if ( ! function_exists('character_limiter'))
*
* Converts High ascii text and MS Word special characters to character entities
*
- * @access public
* @param string
* @return string
*/
@@ -182,7 +177,6 @@ if ( ! function_exists('ascii_to_entities'))
*
* Converts character entities back to ASCII
*
- * @access public
* @param string
* @param bool
* @return string
@@ -240,7 +234,6 @@ if ( ! function_exists('entities_to_ascii'))
* matched words will be converted to #### or to the replacement
* word you've submitted.
*
- * @access public
* @param string the text string
* @param string the array of censoered words
* @param string the optional replacement value
@@ -286,7 +279,6 @@ if ( ! function_exists('word_censor'))
*
* Colorizes code strings
*
- * @access public
* @param string the text string
* @return string
*/
@@ -330,7 +322,6 @@ if ( ! function_exists('highlight_code'))
*
* Highlights a phrase within a text string
*
- * @access public
* @param string the text string
* @param string the phrase you'd like to highlight
* @param string the openging tag to precede the phrase with
@@ -360,7 +351,6 @@ if ( ! function_exists('highlight_phrase'))
/**
* Convert Accented Foreign Characters to ASCII
*
- * @access public
* @param string the text string
* @return string
*/
@@ -368,7 +358,7 @@ if ( ! function_exists('convert_accented_characters'))
{
function convert_accented_characters($str)
{
- if (defined('ENVIRONMENT') AND is_file(APPPATH.'config/'.ENVIRONMENT.'/foreign_chars.php'))
+ if (defined('ENVIRONMENT') && is_file(APPPATH.'config/'.ENVIRONMENT.'/foreign_chars.php'))
{
include(APPPATH.'config/'.ENVIRONMENT.'/foreign_chars.php');
}
@@ -395,9 +385,8 @@ if ( ! function_exists('convert_accented_characters'))
* Anything placed between {unwrap}{/unwrap} will not be word wrapped, nor
* will URLs.
*
- * @access public
* @param string the text string
- * @param integer the number of characters to wrap at
+ * @param int the number of characters to wrap at
* @return string
*/
if ( ! function_exists('word_wrap'))
@@ -497,11 +486,11 @@ if ( ! function_exists('word_wrap'))
*
* This function will strip tags from a string, split it at its max_length and ellipsize
*
- * @param string string to ellipsize
- * @param integer max length of string
- * @param mixed int (1|0) or float, .5, .2, etc for position to split
- * @param string ellipsis ; Default '...'
- * @return string ellipsized string
+ * @param string string to ellipsize
+ * @param int max length of string
+ * @param mixed int (1|0) or float, .5, .2, etc for position to split
+ * @param string ellipsis ; Default '...'
+ * @return string ellipsized string
*/
if ( ! function_exists('ellipsize'))
{
@@ -534,4 +523,4 @@ if ( ! function_exists('ellipsize'))
}
/* End of file text_helper.php */
-/* Location: ./system/helpers/text_helper.php */
+/* Location: ./system/helpers/text_helper.php */ \ No newline at end of file
diff --git a/system/helpers/typography_helper.php b/system/helpers/typography_helper.php
index 9b19c7c2d..7a3db5d6b 100644
--- a/system/helpers/typography_helper.php
+++ b/system/helpers/typography_helper.php
@@ -25,8 +25,6 @@
* @filesource
*/
-// ------------------------------------------------------------------------
-
/**
* CodeIgniter Typography Helpers
*
@@ -42,7 +40,6 @@
/**
* Convert newlines to HTML line breaks except within PRE tags
*
- * @access public
* @param string
* @return string
*/
@@ -61,8 +58,6 @@ if ( ! function_exists('nl2br_except_pre'))
/**
* Auto Typography Wrapper Function
*
- *
- * @access public
* @param string
* @param bool whether to allow javascript event handlers
* @param bool whether to reduce multiple instances of double newlines to two
@@ -86,7 +81,6 @@ if ( ! function_exists('auto_typography'))
*
* This function is a replacement for html_entity_decode()
*
- * @access public
* @param string
* @param string
* @return string
@@ -101,4 +95,4 @@ if ( ! function_exists('entity_decode'))
}
/* End of file typography_helper.php */
-/* Location: ./system/helpers/typography_helper.php */
+/* Location: ./system/helpers/typography_helper.php */ \ No newline at end of file
diff --git a/system/helpers/url_helper.php b/system/helpers/url_helper.php
index 2ae1fd37b..5576c2748 100644
--- a/system/helpers/url_helper.php
+++ b/system/helpers/url_helper.php
@@ -25,8 +25,6 @@
* @filesource
*/
-// ------------------------------------------------------------------------
-
/**
* CodeIgniter URL Helpers
*
@@ -45,7 +43,6 @@
* Create a local URL based on your basepath. Segments can be passed via the
* first parameter either as a string or an array.
*
- * @access public
* @param string
* @return string
*/
@@ -67,8 +64,7 @@ if ( ! function_exists('site_url'))
* Segments can be passed in as a string or an array, same as site_url
* or a URL to a file can be passed in, e.g. to an image file.
*
- * @access public
- * @param string
+ * @param string
* @return string
*/
if ( ! function_exists('base_url'))
@@ -88,7 +84,6 @@ if ( ! function_exists('base_url'))
* Returns the full URL (including segments) of the page where this
* function is placed
*
- * @access public
* @return string
*/
if ( ! function_exists('current_url'))
@@ -106,7 +101,6 @@ if ( ! function_exists('current_url'))
*
* Returns the URI segments.
*
- * @access public
* @return string
*/
if ( ! function_exists('uri_string'))
@@ -125,7 +119,6 @@ if ( ! function_exists('uri_string'))
*
* Returns the "index_page" from your config file
*
- * @access public
* @return string
*/
if ( ! function_exists('index_page'))
@@ -144,7 +137,6 @@ if ( ! function_exists('index_page'))
*
* Creates an anchor based on the local URL.
*
- * @access public
* @param string the URL
* @param string the link title
* @param mixed any attributes
@@ -158,7 +150,7 @@ if ( ! function_exists('anchor'))
if ( ! is_array($uri))
{
- $site_url = ( ! preg_match('!^\w+://! i', $uri)) ? site_url($uri) : $uri;
+ $site_url = preg_match('!^\w+://! i', $uri) ? $uri : site_url($uri);
}
else
{
@@ -187,7 +179,6 @@ if ( ! function_exists('anchor'))
* Creates an anchor based on the local URL. The link
* opens a new window based on the attributes specified.
*
- * @access public
* @param string the URL
* @param string the link title
* @param mixed any attributes
@@ -198,7 +189,7 @@ if ( ! function_exists('anchor_popup'))
function anchor_popup($uri = '', $title = '', $attributes = FALSE)
{
$title = (string) $title;
- $site_url = ( ! preg_match('!^\w+://! i', $uri)) ? site_url($uri) : $uri;
+ $site_url = preg_match('!^\w+://! i', $uri) ? $uri : site_url($uri);
if ($title == '')
{
@@ -207,7 +198,7 @@ if ( ! function_exists('anchor_popup'))
if ($attributes === FALSE)
{
- return "<a href='javascript:void(0);' onclick=\"window.open('".$site_url."', '_blank');\">".$title."</a>";
+ return "<a href='javascript:void(0);' onclick=\"window.open('".$site_url."', '_blank');\">".$title.'</a>';
}
if ( ! is_array($attributes))
@@ -217,7 +208,7 @@ if ( ! function_exists('anchor_popup'))
foreach (array('width' => '800', 'height' => '600', 'scrollbars' => 'yes', 'status' => 'yes', 'resizable' => 'yes', 'screenx' => '0', 'screeny' => '0', ) as $key => $val)
{
- $atts[$key] = ( ! isset($attributes[$key])) ? $val : $attributes[$key];
+ $atts[$key] = isset($attributes[$key]) ? $attributes[$key] : $val;
unset($attributes[$key]);
}
@@ -226,7 +217,7 @@ if ( ! function_exists('anchor_popup'))
$attributes = _parse_attributes($attributes);
}
- return "<a href='javascript:void(0);' onclick=\"window.open('".$site_url."', '_blank', '"._parse_attributes($atts, TRUE)."');\"$attributes>".$title."</a>";
+ return "<a href='javascript:void(0);' onclick=\"window.open('".$site_url."', '_blank', '"._parse_attributes($atts, TRUE)."');\"".$attributes.'>'.$title.'</a>';
}
}
@@ -235,7 +226,6 @@ if ( ! function_exists('anchor_popup'))
/**
* Mailto Link
*
- * @access public
* @param string the email address
* @param string the link title
* @param mixed any attributes
@@ -263,7 +253,6 @@ if ( ! function_exists('mailto'))
*
* Create a spam-protected mailto link written in Javascript
*
- * @access public
* @param string the email address
* @param string the link title
* @param mixed any attributes
@@ -373,10 +362,9 @@ if ( ! function_exists('safe_mailto'))
*
* Automatically links URL and Email addresses.
* Note: There's a bit of extra code here to deal with
- * URLs or emails that end in a period. We'll strip these
+ * URLs or emails that end in a period. We'll strip these
* off and add them after the link.
*
- * @access public
* @param string the string
* @param string the type: email, url, or both
* @param bool whether to create pop-up links
@@ -440,7 +428,6 @@ if ( ! function_exists('auto_link'))
*
* Simply adds the http:// part if no scheme is included
*
- * @access public
* @param string the URL
* @return string
*/
@@ -470,12 +457,12 @@ if ( ! function_exists('prep_url'))
* Create URL Title
*
* Takes a "title" string as input and creates a
- * human-friendly URL string with a "separator" string
+ * human-friendly URL string with a "separator" string
* as the word separator.
*
- * @access public
* @param string the string
* @param string the separator
+ * @param bool
* @return string
*/
if ( ! function_exists('url_title'))
@@ -484,21 +471,21 @@ if ( ! function_exists('url_title'))
{
if ($separator === 'dash')
{
- $separator = '-';
+ $separator = '-';
}
- else if ($separator == 'underscore')
+ elseif ($separator === 'underscore')
{
- $separator = '_';
+ $separator = '_';
}
-
+
$q_separator = preg_quote($separator);
$trans = array(
- '&.+?;' => '',
- '[^a-z0-9 _-]' => '',
- '\s+' => $separator,
- '('.$q_separator.')+' => $separator
- );
+ '&.+?;' => '',
+ '[^a-z0-9 _-]' => '',
+ '\s+' => $separator,
+ '('.$q_separator.')+' => $separator
+ );
$str = strip_tags($str);
foreach ($trans as $key => $val)
@@ -524,7 +511,6 @@ if ( ! function_exists('url_title'))
* For very fine grained control over headers, you could use the Output
* Library's set_header() function.
*
- * @access public
* @param string the URL
* @param string the method: location or refresh
* @return string
@@ -564,7 +550,6 @@ if ( ! function_exists('redirect'))
*
* Some of the functions use this
*
- * @access private
* @param array
* @param bool
* @return string
@@ -583,15 +568,15 @@ if ( ! function_exists('_parse_attributes'))
{
if ($javascript == TRUE)
{
- $att .= $key . '=' . $val . ',';
+ $att .= $key.'='.$val.',';
}
else
{
- $att .= ' ' . $key . '="' . $val . '"';
+ $att .= ' '.$key.'="'.$val.'"';
}
}
- if ($javascript == TRUE AND $att != '')
+ if ($javascript == TRUE && $att != '')
{
return substr($att, 0, -1);
}
@@ -601,4 +586,4 @@ if ( ! function_exists('_parse_attributes'))
}
/* End of file url_helper.php */
-/* Location: ./system/helpers/url_helper.php */
+/* Location: ./system/helpers/url_helper.php */ \ No newline at end of file
diff --git a/system/helpers/xml_helper.php b/system/helpers/xml_helper.php
index f3ff5764c..67fd34b97 100644
--- a/system/helpers/xml_helper.php
+++ b/system/helpers/xml_helper.php
@@ -25,8 +25,6 @@
* @filesource
*/
-// ------------------------------------------------------------------------
-
/**
* CodeIgniter XML Helpers
*
@@ -42,8 +40,8 @@
/**
* Convert Reserved XML characters to Entities
*
- * @access public
* @param string
+ * @param bool
* @return string
*/
if ( ! function_exists('xml_convert'))
@@ -54,11 +52,11 @@ if ( ! function_exists('xml_convert'))
// Replace entities to temporary markers so that
// ampersands won't get messed up
- $str = preg_replace("/&#(\d+);/", "$temp\\1;", $str);
+ $str = preg_replace('/&#(\d+);/', $temp.'\\1;', $str);
if ($protect_all == TRUE)
{
- $str = preg_replace('/&(\w+);/', "$temp\\1;", $str);
+ $str = preg_replace('/&(\w+);/', $temp.'\\1;', $str);
}
$str = str_replace(array('&', '<', '>', '"', "'", '-'),
@@ -66,11 +64,11 @@ if ( ! function_exists('xml_convert'))
$str);
// Decode the temp markers back to entities
- $str = preg_replace('/$temp(\d+);/', '&#\\1;', $str);
+ $str = preg_replace('/'.$temp.'(\d+);/', '&#\\1;', $str);
if ($protect_all == TRUE)
{
- return preg_replace("/$temp(\w+);/", '&\\1;', $str);
+ return preg_replace('/'.$temp.'(\w+);/', '&\\1;', $str);
}
return $str;
@@ -78,4 +76,4 @@ if ( ! function_exists('xml_convert'))
}
/* End of file xml_helper.php */
-/* Location: ./system/helpers/xml_helper.php */
+/* Location: ./system/helpers/xml_helper.php */ \ No newline at end of file
diff --git a/system/language/english/upload_lang.php b/system/language/english/upload_lang.php
index ec5de1e6b..4fa8394ec 100644
--- a/system/language/english/upload_lang.php
+++ b/system/language/english/upload_lang.php
@@ -35,7 +35,7 @@ $lang['upload_stopped_by_extension'] = "The file upload was stopped by extension
$lang['upload_no_file_selected'] = "You did not select a file to upload.";
$lang['upload_invalid_filetype'] = "The filetype you are attempting to upload is not allowed.";
$lang['upload_invalid_filesize'] = "The file you are attempting to upload is larger than the permitted size.";
-$lang['upload_invalid_dimensions'] = "The image you are attempting to upload exceedes the maximum height or width.";
+$lang['upload_invalid_dimensions'] = "The image you are attempting to upload exceeds the maximum height or width.";
$lang['upload_destination_error'] = "A problem was encountered while attempting to move the uploaded file to the final destination.";
$lang['upload_no_filepath'] = "The upload path does not appear to be valid.";
$lang['upload_no_file_types'] = "You have not specified any allowed file types.";
diff --git a/system/libraries/Cache/Cache.php b/system/libraries/Cache/Cache.php
index 7642a5270..f98241617 100644
--- a/system/libraries/Cache/Cache.php
+++ b/system/libraries/Cache/Cache.php
@@ -25,8 +25,6 @@
* @filesource
*/
-// ------------------------------------------------------------------------
-
/**
* CodeIgniter Caching Class
*
@@ -50,11 +48,37 @@ class CI_Cache extends CI_Driver_Library {
protected $_adapter = 'dummy';
protected $_backup_driver;
+ /**
+ * Constructor
+ *
+ * Initialize class properties based on the configuration array.
+ *
+ * @param array
+ * @return void
+ */
public function __construct($config = array())
{
- if ( ! empty($config))
+ $default_config = array(
+ 'adapter',
+ 'memcached'
+ );
+
+ foreach ($default_config as $key)
{
- $this->_initialize($config);
+ if (isset($config[$key]))
+ {
+ $param = '_'.$key;
+
+ $this->{$param} = $config[$key];
+ }
+ }
+
+ if (isset($config['backup']))
+ {
+ if (in_array('cache_'.$config['backup'], $this->valid_drivers))
+ {
+ $this->_backup_driver = $config['backup'];
+ }
}
}
@@ -63,11 +87,11 @@ class CI_Cache extends CI_Driver_Library {
/**
* Get
*
- * Look for a value in the cache. If it exists, return the data
+ * Look for a value in the cache. If it exists, return the data
* if not, return FALSE
*
- * @param string
- * @return mixed value that is stored/FALSE on failure
+ * @param string
+ * @return mixed value that is stored/FALSE on failure
*/
public function get($id)
{
@@ -79,11 +103,10 @@ class CI_Cache extends CI_Driver_Library {
/**
* Cache Save
*
- * @param string Unique Key
- * @param mixed Data to store
- * @param int Length of time (in seconds) to cache the data
- *
- * @return boolean true on success/false on failure
+ * @param string Unique Key
+ * @param mixed Data to store
+ * @param int Length of time (in seconds) to cache the data
+ * @return bool true on success/false on failure
*/
public function save($id, $data, $ttl = 60)
{
@@ -95,8 +118,8 @@ class CI_Cache extends CI_Driver_Library {
/**
* Delete from Cache
*
- * @param mixed unique identifier of the item in the cache
- * @return boolean true on success/false on failure
+ * @param mixed unique identifier of the item in the cache
+ * @return bool true on success/false on failure
*/
public function delete($id)
{
@@ -108,7 +131,7 @@ class CI_Cache extends CI_Driver_Library {
/**
* Clean the cache
*
- * @return boolean false on failure/true on success
+ * @return bool false on failure/true on success
*/
public function clean()
{
@@ -120,8 +143,8 @@ class CI_Cache extends CI_Driver_Library {
/**
* Cache Info
*
- * @param string user/filehits
- * @return mixed array on success, false on failure
+ * @param string user/filehits
+ * @return mixed array on success, false on failure
*/
public function cache_info($type = 'user')
{
@@ -133,8 +156,8 @@ class CI_Cache extends CI_Driver_Library {
/**
* Get Cache Metadata
*
- * @param mixed key to get cache metadata on
- * @return mixed return value from child method
+ * @param mixed key to get cache metadata on
+ * @return mixed return value from child method
*/
public function get_metadata($id)
{
@@ -144,46 +167,10 @@ class CI_Cache extends CI_Driver_Library {
// ------------------------------------------------------------------------
/**
- * Initialize
- *
- * Initialize class properties based on the configuration array.
- *
- * @param array
- * @return void
- */
- private function _initialize($config)
- {
- $default_config = array(
- 'adapter',
- 'memcached'
- );
-
- foreach ($default_config as $key)
- {
- if (isset($config[$key]))
- {
- $param = '_'.$key;
-
- $this->{$param} = $config[$key];
- }
- }
-
- if (isset($config['backup']))
- {
- if (in_array('cache_'.$config['backup'], $this->valid_drivers))
- {
- $this->_backup_driver = $config['backup'];
- }
- }
- }
-
- // ------------------------------------------------------------------------
-
- /**
* Is the requested driver supported in this environment?
*
- * @param string The driver to test.
- * @return array
+ * @param string The driver to test.
+ * @return array
*/
public function is_supported($driver)
{
@@ -202,8 +189,8 @@ class CI_Cache extends CI_Driver_Library {
/**
* __get()
*
- * @param child
- * @return object
+ * @param child
+ * @return object
*/
public function __get($child)
{
@@ -217,9 +204,7 @@ class CI_Cache extends CI_Driver_Library {
return $obj;
}
- // ------------------------------------------------------------------------
}
-// End Class
/* End of file Cache.php */
-/* Location: ./system/libraries/Cache/Cache.php */
+/* Location: ./system/libraries/Cache/Cache.php */ \ No newline at end of file
diff --git a/system/libraries/Cache/drivers/Cache_apc.php b/system/libraries/Cache/drivers/Cache_apc.php
index c387a30fc..59ab67533 100644
--- a/system/libraries/Cache/drivers/Cache_apc.php
+++ b/system/libraries/Cache/drivers/Cache_apc.php
@@ -25,8 +25,6 @@
* @filesource
*/
-// ------------------------------------------------------------------------
-
/**
* CodeIgniter APC Caching Class
*
@@ -36,23 +34,22 @@
* @author EllisLab Dev Team
* @link
*/
-
class CI_Cache_apc extends CI_Driver {
/**
* Get
*
- * Look for a value in the cache. If it exists, return the data
+ * Look for a value in the cache. If it exists, return the data
* if not, return FALSE
*
- * @param string
- * @return mixed value that is stored/FALSE on failure
+ * @param string
+ * @return mixed value that is stored/FALSE on failure
*/
public function get($id)
{
$data = apc_fetch($id);
- return (is_array($data)) ? $data[0] : FALSE;
+ return is_array($data) ? $data[0] : FALSE;
}
// ------------------------------------------------------------------------
@@ -60,11 +57,11 @@ class CI_Cache_apc extends CI_Driver {
/**
* Cache Save
*
- * @param string Unique Key
- * @param mixed Data to store
- * @param int Length of time (in seconds) to cache the data
+ * @param string Unique Key
+ * @param mixed Data to store
+ * @param int Length of time (in seconds) to cache the data
*
- * @return boolean true on success/false on failure
+ * @return bool true on success/false on failure
*/
public function save($id, $data, $ttl = 60)
{
@@ -77,8 +74,8 @@ class CI_Cache_apc extends CI_Driver {
/**
* Delete from Cache
*
- * @param mixed unique identifier of the item in the cache
- * @param boolean true on success/false on failure
+ * @param mixed unique identifier of the item in the cache
+ * @param bool true on success/false on failure
*/
public function delete($id)
{
@@ -90,7 +87,7 @@ class CI_Cache_apc extends CI_Driver {
/**
* Clean the cache
*
- * @return boolean false on failure/true on success
+ * @return bool false on failure/true on success
*/
public function clean()
{
@@ -102,8 +99,8 @@ class CI_Cache_apc extends CI_Driver {
/**
* Cache Info
*
- * @param string user/filehits
- * @return mixed array on success, false on failure
+ * @param string user/filehits
+ * @return mixed array on success, false on failure
*/
public function cache_info($type = NULL)
{
@@ -115,8 +112,8 @@ class CI_Cache_apc extends CI_Driver {
/**
* Get Cache Metadata
*
- * @param mixed key to get cache metadata on
- * @return mixed array on success/false on failure
+ * @param mixed key to get cache metadata on
+ * @return mixed array on success/false on failure
*/
public function get_metadata($id)
{
@@ -142,10 +139,12 @@ class CI_Cache_apc extends CI_Driver {
* is_supported()
*
* Check to see if APC is available on this system, bail if it isn't.
+ *
+ * @return bool
*/
public function is_supported()
{
- if ( ! extension_loaded('apc') OR ini_get('apc.enabled') != "1")
+ if ( ! extension_loaded('apc') OR ! (bool) @ini_get('apc.enabled'))
{
log_message('error', 'The APC PHP extension must be loaded to use APC Cache.');
return FALSE;
@@ -154,11 +153,7 @@ class CI_Cache_apc extends CI_Driver {
return TRUE;
}
- // ------------------------------------------------------------------------
-
-
}
-// End Class
/* End of file Cache_apc.php */
-/* Location: ./system/libraries/Cache/drivers/Cache_apc.php */
+/* Location: ./system/libraries/Cache/drivers/Cache_apc.php */ \ No newline at end of file
diff --git a/system/libraries/Cache/drivers/Cache_dummy.php b/system/libraries/Cache/drivers/Cache_dummy.php
index c9767e401..e8b791c5b 100644
--- a/system/libraries/Cache/drivers/Cache_dummy.php
+++ b/system/libraries/Cache/drivers/Cache_dummy.php
@@ -25,8 +25,6 @@
* @filesource
*/
-// ------------------------------------------------------------------------
-
/**
* CodeIgniter Dummy Caching Class
*
@@ -36,7 +34,6 @@
* @author EllisLab Dev Team
* @link
*/
-
class CI_Cache_dummy extends CI_Driver {
/**
@@ -44,8 +41,8 @@ class CI_Cache_dummy extends CI_Driver {
*
* Since this is the dummy class, it's always going to return FALSE.
*
- * @param string
- * @return Boolean FALSE
+ * @param string
+ * @return bool FALSE
*/
public function get($id)
{
@@ -57,11 +54,10 @@ class CI_Cache_dummy extends CI_Driver {
/**
* Cache Save
*
- * @param string Unique Key
- * @param mixed Data to store
- * @param int Length of time (in seconds) to cache the data
- *
- * @return boolean TRUE, Simulating success
+ * @param string Unique Key
+ * @param mixed Data to store
+ * @param int Length of time (in seconds) to cache the data
+ * @return bool TRUE, Simulating success
*/
public function save($id, $data, $ttl = 60)
{
@@ -73,8 +69,8 @@ class CI_Cache_dummy extends CI_Driver {
/**
* Delete from Cache
*
- * @param mixed unique identifier of the item in the cache
- * @param boolean TRUE, simulating success
+ * @param mixed unique identifier of the item in the cache
+ * @param bool TRUE, simulating success
*/
public function delete($id)
{
@@ -86,7 +82,7 @@ class CI_Cache_dummy extends CI_Driver {
/**
* Clean the cache
*
- * @return boolean TRUE, simulating success
+ * @return bool TRUE, simulating success
*/
public function clean()
{
@@ -98,8 +94,8 @@ class CI_Cache_dummy extends CI_Driver {
/**
* Cache Info
*
- * @param string user/filehits
- * @return boolean FALSE
+ * @param string user/filehits
+ * @return bool FALSE
*/
public function cache_info($type = NULL)
{
@@ -111,8 +107,8 @@ class CI_Cache_dummy extends CI_Driver {
/**
* Get Cache Metadata
*
- * @param mixed key to get cache metadata on
- * @return boolean FALSE
+ * @param mixed key to get cache metadata on
+ * @return bool FALSE
*/
public function get_metadata($id)
{
@@ -125,17 +121,14 @@ class CI_Cache_dummy extends CI_Driver {
* Is this caching driver supported on the system?
* Of course this one is.
*
- * @return TRUE;
+ * @return bool TRUE
*/
public function is_supported()
{
return TRUE;
}
- // ------------------------------------------------------------------------
-
}
-// End Class
/* End of file Cache_dummy.php */
-/* Location: ./system/libraries/Cache/drivers/Cache_dummy.php */
+/* Location: ./system/libraries/Cache/drivers/Cache_dummy.php */ \ No newline at end of file
diff --git a/system/libraries/Cache/drivers/Cache_file.php b/system/libraries/Cache/drivers/Cache_file.php
index c0be0def4..dd27aa90e 100644
--- a/system/libraries/Cache/drivers/Cache_file.php
+++ b/system/libraries/Cache/drivers/Cache_file.php
@@ -25,8 +25,6 @@
* @filesource
*/
-// ------------------------------------------------------------------------
-
/**
* CodeIgniter Memcached Caching Class
*
@@ -36,14 +34,10 @@
* @author EllisLab Dev Team
* @link
*/
-
class CI_Cache_file extends CI_Driver {
protected $_cache_path;
- /**
- * Constructor
- */
public function __construct()
{
$CI =& get_instance();
@@ -57,8 +51,8 @@ class CI_Cache_file extends CI_Driver {
/**
* Fetch from cache
*
- * @param mixed unique key id
- * @return mixed data on success/false on failure
+ * @param mixed unique key id
+ * @return mixed data on success/false on failure
*/
public function get($id)
{
@@ -83,11 +77,11 @@ class CI_Cache_file extends CI_Driver {
/**
* Save into cache
*
- * @param string unique key
- * @param mixed data to store
- * @param int length of time (in seconds) the cache is valid
- * - Default is 60 seconds
- * @return boolean true on success/false on failure
+ * @param string unique key
+ * @param mixed data to store
+ * @param int length of time (in seconds) the cache is valid
+ * - Default is 60 seconds
+ * @return bool true on success/false on failure
*/
public function save($id, $data, $ttl = 60)
{
@@ -111,12 +105,12 @@ class CI_Cache_file extends CI_Driver {
/**
* Delete from Cache
*
- * @param mixed unique identifier of item in cache
- * @return boolean true on success/false on failure
+ * @param mixed unique identifier of item in cache
+ * @return bool true on success/false on failure
*/
public function delete($id)
{
- return (file_exists($this->_cache_path.$id)) ? unlink($this->_cache_path.$id) : FALSE;
+ return file_exists($this->_cache_path.$id) ? unlink($this->_cache_path.$id) : FALSE;
}
// ------------------------------------------------------------------------
@@ -124,7 +118,7 @@ class CI_Cache_file extends CI_Driver {
/**
* Clean the Cache
*
- * @return boolean false on failure/true on success
+ * @return bool false on failure/true on success
*/
public function clean()
{
@@ -138,8 +132,8 @@ class CI_Cache_file extends CI_Driver {
*
* Not supported by file-based caching
*
- * @param string user/filehits
- * @return mixed FALSE
+ * @param string user/filehits
+ * @return mixed FALSE
*/
public function cache_info($type = NULL)
{
@@ -151,8 +145,8 @@ class CI_Cache_file extends CI_Driver {
/**
* Get Cache Metadata
*
- * @param mixed key to get cache metadata on
- * @return mixed FALSE on failure, array on success.
+ * @param mixed key to get cache metadata on
+ * @return mixed FALSE on failure, array on success.
*/
public function get_metadata($id)
{
@@ -188,16 +182,14 @@ class CI_Cache_file extends CI_Driver {
*
* In the file driver, check to see that the cache directory is indeed writable
*
- * @return boolean
+ * @return bool
*/
public function is_supported()
{
return is_really_writable($this->_cache_path);
}
- // ------------------------------------------------------------------------
}
-// End Class
/* End of file Cache_file.php */
-/* Location: ./system/libraries/Cache/drivers/Cache_file.php */
+/* Location: ./system/libraries/Cache/drivers/Cache_file.php */ \ No newline at end of file
diff --git a/system/libraries/Cache/drivers/Cache_memcached.php b/system/libraries/Cache/drivers/Cache_memcached.php
index b8f2d7e4c..1028c8fd5 100644
--- a/system/libraries/Cache/drivers/Cache_memcached.php
+++ b/system/libraries/Cache/drivers/Cache_memcached.php
@@ -25,8 +25,6 @@
* @filesource
*/
-// ------------------------------------------------------------------------
-
/**
* CodeIgniter Memcached Caching Class
*
@@ -36,12 +34,11 @@
* @author EllisLab Dev Team
* @link
*/
-
class CI_Cache_memcached extends CI_Driver {
- private $_memcached; // Holds the memcached object
+ protected $_memcached; // Holds the memcached object
- protected $_memcache_conf = array(
+ protected $_memcache_conf = array(
'default' => array(
'default_host' => '127.0.0.1',
'default_port' => 11211,
@@ -49,19 +46,17 @@ class CI_Cache_memcached extends CI_Driver {
)
);
- // ------------------------------------------------------------------------
-
/**
* Fetch from cache
*
- * @param mixed unique key id
- * @return mixed data on success/false on failure
+ * @param mixed unique key id
+ * @return mixed data on success/false on failure
*/
public function get($id)
{
$data = $this->_memcached->get($id);
- return (is_array($data)) ? $data[0] : FALSE;
+ return is_array($data) ? $data[0] : FALSE;
}
// ------------------------------------------------------------------------
@@ -69,18 +64,18 @@ class CI_Cache_memcached extends CI_Driver {
/**
* Save
*
- * @param string unique identifier
- * @param mixed data being cached
- * @param int time to live
- * @return boolean true on success, false on failure
+ * @param string unique identifier
+ * @param mixed data being cached
+ * @param int time to live
+ * @return bool true on success, false on failure
*/
public function save($id, $data, $ttl = 60)
{
- if (get_class($this->_memcached) == 'Memcached')
+ if (get_class($this->_memcached) === 'Memcached')
{
return $this->_memcached->set($id, array($data, time(), $ttl), $ttl);
}
- else if (get_class($this->_memcached) == 'Memcache')
+ elseif (get_class($this->_memcached) === 'Memcache')
{
return $this->_memcached->set($id, array($data, time(), $ttl), 0, $ttl);
}
@@ -93,8 +88,8 @@ class CI_Cache_memcached extends CI_Driver {
/**
* Delete from Cache
*
- * @param mixed key to be deleted.
- * @return boolean true on success, false on failure
+ * @param mixed key to be deleted.
+ * @return bool true on success, false on failure
*/
public function delete($id)
{
@@ -106,7 +101,7 @@ class CI_Cache_memcached extends CI_Driver {
/**
* Clean the Cache
*
- * @return boolean false on failure/true on success
+ * @return bool false on failure/true on success
*/
public function clean()
{
@@ -118,10 +113,9 @@ class CI_Cache_memcached extends CI_Driver {
/**
* Cache Info
*
- * @param null type not supported in memcached
- * @return mixed array on success, false on failure
+ * @return mixed array on success, false on failure
*/
- public function cache_info($type = NULL)
+ public function cache_info()
{
return $this->_memcached->getStats();
}
@@ -131,8 +125,8 @@ class CI_Cache_memcached extends CI_Driver {
/**
* Get Cache Metadata
*
- * @param mixed key to get cache metadata on
- * @return mixed FALSE on failure, array on success.
+ * @param mixed key to get cache metadata on
+ * @return mixed FALSE on failure, array on success.
*/
public function get_metadata($id)
{
@@ -156,8 +150,10 @@ class CI_Cache_memcached extends CI_Driver {
/**
* Setup memcached.
+ *
+ * @return bool
*/
- private function _setup_memcached()
+ protected function _setup_memcached()
{
// Try to load memcached server info from the config file.
$CI =& get_instance();
@@ -179,14 +175,13 @@ class CI_Cache_memcached extends CI_Driver {
{
$this->_memcached = new Memcached();
}
- else if (class_exists('Memcache'))
+ elseif (class_exists('Memcache'))
{
$this->_memcached = new Memcache();
}
else
{
log_message('error', 'Failed to create object for Memcached Cache; extension not loaded?');
-
return FALSE;
}
@@ -237,23 +232,21 @@ class CI_Cache_memcached extends CI_Driver {
*
* Returns FALSE if memcached is not supported on the system.
* If it is, we setup the memcached object & return TRUE
+ *
+ * @return bool
*/
public function is_supported()
{
if ( ! extension_loaded('memcached') && ! extension_loaded('memcache'))
{
log_message('error', 'The Memcached Extension must be loaded to use Memcached Cache.');
-
return FALSE;
}
return $this->_setup_memcached();
}
- // ------------------------------------------------------------------------
-
}
-// End Class
/* End of file Cache_memcached.php */
-/* Location: ./system/libraries/Cache/drivers/Cache_memcached.php */
+/* Location: ./system/libraries/Cache/drivers/Cache_memcached.php */ \ No newline at end of file
diff --git a/system/libraries/Cache/drivers/Cache_wincache.php b/system/libraries/Cache/drivers/Cache_wincache.php
index df619d4e6..b32e66a46 100644
--- a/system/libraries/Cache/drivers/Cache_wincache.php
+++ b/system/libraries/Cache/drivers/Cache_wincache.php
@@ -25,8 +25,6 @@
* @filesource
*/
-// ------------------------------------------------------------------------
-
/**
* CodeIgniter Wincache Caching Class
*
@@ -39,7 +37,6 @@
* @author Mike Murkovic
* @link
*/
-
class CI_Cache_wincache extends CI_Driver {
/**
@@ -68,7 +65,7 @@ class CI_Cache_wincache extends CI_Driver {
* @param string Unique Key
* @param mixed Data to store
* @param int Length of time (in seconds) to cache the data
- * @return bool true on success/false on failure
+ * @return bool true on success/false on failure
*/
public function save($id, $data, $ttl = 60)
{
@@ -162,4 +159,4 @@ class CI_Cache_wincache extends CI_Driver {
}
/* End of file Cache_wincache.php */
-/* Location: ./system/libraries/Cache/drivers/Cache_wincache.php */
+/* Location: ./system/libraries/Cache/drivers/Cache_wincache.php */ \ No newline at end of file
diff --git a/system/libraries/Calendar.php b/system/libraries/Calendar.php
index 6c04de8a2..b6f145d95 100644
--- a/system/libraries/Calendar.php
+++ b/system/libraries/Calendar.php
@@ -25,8 +25,6 @@
* @filesource
*/
-// ------------------------------------------------------------------------
-
/**
* CodeIgniter Calendar Class
*
@@ -40,7 +38,7 @@
*/
class CI_Calendar {
- private $CI;
+ protected $CI;
public $lang;
public $local_time;
public $template = '';
@@ -54,6 +52,9 @@ class CI_Calendar {
* Constructor
*
* Loads the calendar language file and sets the default time reference
+ *
+ * @param array
+ * @return void
*/
public function __construct($config = array())
{
@@ -71,7 +72,7 @@ class CI_Calendar {
$this->initialize($config);
}
- log_message('debug', "Calendar Class Initialized");
+ log_message('debug', 'Calendar Class Initialized');
}
// --------------------------------------------------------------------
@@ -81,7 +82,6 @@ class CI_Calendar {
*
* Accepts an associative array as input, containing display preferences
*
- * @access public
* @param array config preferences
* @return void
*/
@@ -101,9 +101,8 @@ class CI_Calendar {
/**
* Generate the calendar
*
- * @access public
- * @param integer the year
- * @param integer the month
+ * @param int the year
+ * @param int the month
* @param array the data to be shown in the calendar cells
* @return string
*/
@@ -147,7 +146,7 @@ class CI_Calendar {
// Set the starting day number
$local_date = mktime(12, 0, 0, $month, 1, $year);
$date = getdate($local_date);
- $day = $start_day + 1 - $date["wday"];
+ $day = $start_day + 1 - $date['wday'];
while ($day > 1)
{
@@ -160,7 +159,7 @@ class CI_Calendar {
$cur_month = date('m', $this->local_time);
$cur_day = date('j', $this->local_time);
- $is_current_month = ($cur_year == $year AND $cur_month == $month) ? TRUE : FALSE;
+ $is_current_month = ($cur_year == $year && $cur_month == $month);
// Generate the template data array
$this->parse_template();
@@ -172,7 +171,7 @@ class CI_Calendar {
if ($this->show_next_prev == TRUE)
{
// Add a trailing slash to the URL if needed
- $this->next_prev_url = preg_replace("/(.+?)\/*$/", "\\1/", $this->next_prev_url);
+ $this->next_prev_url = preg_replace('/(.+?)\/*$/', '\\1/', $this->next_prev_url);
$adjusted_date = $this->adjust_date($month - 1, $year);
$out .= str_replace('{previous_url}', $this->next_prev_url.$adjusted_date['year'].'/'.$adjusted_date['month'], $this->temp['heading_previous_cell'])."\n";
@@ -213,21 +212,21 @@ class CI_Calendar {
for ($i = 0; $i < 7; $i++)
{
- $out .= ($is_current_month === TRUE AND $day == $cur_day) ? $this->temp['cal_cell_start_today'] : $this->temp['cal_cell_start'];
+ $out .= ($is_current_month === TRUE && $day == $cur_day) ? $this->temp['cal_cell_start_today'] : $this->temp['cal_cell_start'];
- if ($day > 0 AND $day <= $total_days)
+ if ($day > 0 && $day <= $total_days)
{
if (isset($data[$day]))
{
// Cells with content
- $temp = ($is_current_month === TRUE AND $day == $cur_day) ?
+ $temp = ($is_current_month === TRUE && $day == $cur_day) ?
$this->temp['cal_cell_content_today'] : $this->temp['cal_cell_content'];
$out .= str_replace(array('{content}', '{day}'), array($data[$day], $day), $temp);
}
else
{
// Cells with no content
- $temp = ($is_current_month === TRUE AND $day == $cur_day) ?
+ $temp = ($is_current_month === TRUE && $day == $cur_day) ?
$this->temp['cal_cell_no_content_today'] : $this->temp['cal_cell_no_content'];
$out .= str_replace('{day}', $day, $temp);
}
@@ -238,7 +237,7 @@ class CI_Calendar {
$out .= $this->temp['cal_cell_blank'];
}
- $out .= ($is_current_month === TRUE AND $day == $cur_day) ? $this->temp['cal_cell_end_today'] : $this->temp['cal_cell_end'];
+ $out .= ($is_current_month === TRUE && $day == $cur_day) ? $this->temp['cal_cell_end_today'] : $this->temp['cal_cell_end'];
$day++;
}
@@ -258,8 +257,7 @@ class CI_Calendar {
* Generates a textual month name based on the numeric
* month provided.
*
- * @access public
- * @param integer the month
+ * @param int the month
* @return string
*/
public function get_month_name($month)
@@ -289,9 +287,8 @@ class CI_Calendar {
* Get Day Names
*
* Returns an array of day names (Sunday, Monday, etc.) based
- * on the type. Options: long, short, abrev
+ * on the type. Options: long, short, abrev
*
- * @access public
* @param string
* @return array
*/
@@ -333,9 +330,8 @@ class CI_Calendar {
* For example, if you submit 13 as the month, the year will
* increment and the month will become January.
*
- * @access public
- * @param integer the month
- * @param integer the year
+ * @param int the month
+ * @param int the year
* @return array
*/
public function adjust_date($month, $year)
@@ -370,10 +366,9 @@ class CI_Calendar {
/**
* Total days in a given month
*
- * @access public
- * @param integer the month
- * @param integer the year
- * @return integer
+ * @param int the month
+ * @param int the year
+ * @return int
*/
public function get_total_days($month, $year)
{
@@ -387,7 +382,7 @@ class CI_Calendar {
// Is the year a leap year?
if ($month == 2)
{
- if ($year % 400 == 0 OR ($year % 4 == 0 AND $year % 100 != 0))
+ if ($year % 400 == 0 OR ($year % 4 == 0 && $year % 100 != 0))
{
return 29;
}
@@ -403,8 +398,7 @@ class CI_Calendar {
*
* This is used in the event that the user has not created their own template
*
- * @access public
- * @return array
+ * @return array
*/
public function default_template()
{
@@ -441,7 +435,6 @@ class CI_Calendar {
* Harvests the data within the template {pseudo-variables}
* used to display the calendar
*
- * @access public
* @return void
*/
public function parse_template()
@@ -457,7 +450,7 @@ class CI_Calendar {
foreach (array('table_open', 'table_close', 'heading_row_start', 'heading_previous_cell', 'heading_title_cell', 'heading_next_cell', 'heading_row_end', 'week_row_start', 'week_day_cell', 'week_row_end', 'cal_row_start', 'cal_cell_start', 'cal_cell_content', 'cal_cell_no_content', 'cal_cell_blank', 'cal_cell_end', 'cal_row_end', 'cal_cell_start_today', 'cal_cell_content_today', 'cal_cell_no_content_today', 'cal_cell_end_today') as $val)
{
- if (preg_match("/\{".$val."\}(.*?)\{\/".$val."\}/si", $this->template, $match))
+ if (preg_match('/\{'.$val.'\}(.*?)\{\/'.$val.'\}/si', $this->template, $match))
{
$this->temp[$val] = $match[1];
}
@@ -470,7 +463,5 @@ class CI_Calendar {
}
-// END CI_Calendar class
-
/* End of file Calendar.php */
-/* Location: ./system/libraries/Calendar.php */
+/* Location: ./system/libraries/Calendar.php */ \ No newline at end of file
diff --git a/system/libraries/Cart.php b/system/libraries/Cart.php
index 60a1e52fe..ca7be555e 100644
--- a/system/libraries/Cart.php
+++ b/system/libraries/Cart.php
@@ -25,8 +25,6 @@
* @filesource
*/
-// ------------------------------------------------------------------------
-
/**
* Shopping Cart Class
*
@@ -41,12 +39,11 @@ class CI_Cart {
// These are the regular expression rules that we use to validate the product ID and product name
public $product_id_rules = '\.a-z0-9_-'; // alpha-numeric, dashes, underscores, or periods
public $product_name_rules = '\.\:\-_ a-z0-9'; // alpha-numeric, dashes, underscores, colons or periods
- public $product_name_safe = true; // only allow safe product names
-
- // Private variables. Do not change!
- private $CI;
- private $_cart_contents = array();
+ public $product_name_safe = TRUE; // only allow safe product names
+ // Protected variables. Do not change!
+ protected $CI;
+ protected $_cart_contents = array();
/**
* Shopping Class Constructor
@@ -72,7 +69,7 @@ class CI_Cart {
$this->_cart_contents = array('cart_total' => 0, 'total_items' => 0);
}
- log_message('debug', "Cart Class Initialized");
+ log_message('debug', 'Cart Class Initialized');
}
// --------------------------------------------------------------------
@@ -80,7 +77,6 @@ class CI_Cart {
/**
* Insert items into the cart and save it to the session table
*
- * @access public
* @param array
* @return bool
*/
@@ -110,7 +106,7 @@ class CI_Cart {
{
foreach ($items as $val)
{
- if (is_array($val) AND isset($val['id']))
+ if (is_array($val) && isset($val['id']))
{
if ($this->_insert($val))
{
@@ -135,11 +131,10 @@ class CI_Cart {
/**
* Insert
*
- * @access private
* @param array
* @return bool
*/
- private function _insert($items = array())
+ protected function _insert($items = array())
{
// Was any cart data passed? No? Bah...
if ( ! is_array($items) OR count($items) === 0)
@@ -213,7 +208,7 @@ class CI_Cart {
// Internally, we need to treat identical submissions, but with different options, as a unique product.
// Our solution is to convert the options array to a string and MD5 it along with the product ID.
// This becomes the unique "row ID"
- if (isset($items['options']) AND count($items['options']) > 0)
+ if (isset($items['options']) && count($items['options']) > 0)
{
$rowid = md5($items['id'].implode('', $items['options']));
}
@@ -249,7 +244,6 @@ class CI_Cart {
* changes to the quantity before checkout. That array must contain the
* product ID and quantity for each item.
*
- * @access public
* @param array
* @param string
* @return bool
@@ -308,11 +302,10 @@ class CI_Cart {
* changes to the quantity before checkout. That array must contain the
* product ID and quantity for each item.
*
- * @access private
* @param array
* @return bool
*/
- private function _update($items = array())
+ protected function _update($items = array())
{
// Without these array indexes there is nothing we can do
if ( ! isset($items['qty']) OR ! isset($items['rowid']) OR ! isset($this->_cart_contents[$items['rowid']]))
@@ -348,10 +341,9 @@ class CI_Cart {
/**
* Save the cart array to the session DB
*
- * @access private
* @return bool
*/
- private function _save_cart()
+ protected function _save_cart()
{
// Lets add up the individual prices and set the cart sub-total
$this->_cart_contents['total_items'] = $this->_cart_contents['cart_total'] = 0;
@@ -390,8 +382,7 @@ class CI_Cart {
/**
* Cart Total
*
- * @access public
- * @return integer
+ * @return int
*/
public function total()
{
@@ -405,8 +396,7 @@ class CI_Cart {
*
* Removes an item from the cart
*
- * @access public
- * @return boolean
+ * @return bool
*/
public function remove($rowid)
{
@@ -423,8 +413,7 @@ class CI_Cart {
*
* Returns the total item count
*
- * @access public
- * @return integer
+ * @return int
*/
public function total_items()
{
@@ -438,7 +427,6 @@ class CI_Cart {
*
* Returns the entire cart array
*
- * @access public
* @return array
*/
public function contents($newest_first = FALSE)
@@ -461,7 +449,6 @@ class CI_Cart {
* Returns TRUE if the rowid passed to this function correlates to an item
* that has options associated with it.
*
- * @access public
* @return bool
*/
public function has_options($rowid = '')
@@ -476,7 +463,7 @@ class CI_Cart {
*
* Returns the an array of options, for a particular product row ID
*
- * @access public
+ * @param int
* @return array
*/
public function product_options($rowid = '')
@@ -491,7 +478,7 @@ class CI_Cart {
*
* Returns the supplied number with commas and a decimal point.
*
- * @access public
+ * @param float
* @return string
*/
public function format_number($n = '')
@@ -514,7 +501,6 @@ class CI_Cart {
*
* Empties the cart and kills the session
*
- * @access public
* @return void
*/
public function destroy()
@@ -523,9 +509,7 @@ class CI_Cart {
$this->CI->session->unset_userdata('cart_contents');
}
-
}
-// END Cart Class
/* End of file Cart.php */
-/* Location: ./system/libraries/Cart.php */
+/* Location: ./system/libraries/Cart.php */ \ No newline at end of file
diff --git a/system/libraries/Driver.php b/system/libraries/Driver.php
index 9a073b336..f409f47d4 100644
--- a/system/libraries/Driver.php
+++ b/system/libraries/Driver.php
@@ -25,8 +25,6 @@
* @filesource
*/
-// ------------------------------------------------------------------------
-
/**
* CodeIgniter Driver Library Class
*
@@ -84,8 +82,8 @@ class CI_Driver_Library {
// it's a valid driver, but the file simply can't be found
if ( ! class_exists($child_class))
{
- log_message('error', "Unable to load the requested driver: ".$child_class);
- show_error("Unable to load the requested driver: ".$child_class);
+ log_message('error', 'Unable to load the requested driver: '.$child_class);
+ show_error('Unable to load the requested driver: '.$child_class);
}
}
@@ -96,15 +94,11 @@ class CI_Driver_Library {
}
// The requested driver isn't valid!
- log_message('error', "Invalid driver requested: ".$child_class);
- show_error("Invalid driver requested: ".$child_class);
+ log_message('error', 'Invalid driver requested: '.$child_class);
+ show_error('Invalid driver requested: '.$child_class);
}
- // --------------------------------------------------------------------
-
}
-// END CI_Driver_Library CLASS
-
/**
* CodeIgniter Driver Class
@@ -120,12 +114,12 @@ class CI_Driver_Library {
*/
class CI_Driver {
- protected $parent;
+ protected $_parent;
- private $methods = array();
- private $properties = array();
+ protected $_methods = array();
+ protected $_properties = array();
- private static $reflections = array();
+ protected static $_reflections = array();
/**
* Decorate
@@ -137,14 +131,14 @@ class CI_Driver {
*/
public function decorate($parent)
{
- $this->parent = $parent;
+ $this->_parent = $parent;
// Lock down attributes to what is defined in the class
// and speed up references in magic methods
$class_name = get_class($parent);
- if ( ! isset(self::$reflections[$class_name]))
+ if ( ! isset(self::$_reflections[$class_name]))
{
$r = new ReflectionObject($parent);
@@ -152,7 +146,7 @@ class CI_Driver {
{
if ($method->isPublic())
{
- $this->methods[] = $method->getName();
+ $this->_methods[] = $method->getName();
}
}
@@ -160,15 +154,15 @@ class CI_Driver {
{
if ($prop->isPublic())
{
- $this->properties[] = $prop->getName();
+ $this->_properties[] = $prop->getName();
}
}
- self::$reflections[$class_name] = array($this->methods, $this->properties);
+ self::$_reflections[$class_name] = array($this->_methods, $this->_properties);
}
else
{
- list($this->methods, $this->properties) = self::$reflections[$class_name];
+ list($this->_methods, $this->_properties) = self::$_reflections[$class_name];
}
}
@@ -179,16 +173,15 @@ class CI_Driver {
*
* Handles access to the parent driver library's methods
*
- * @access public
* @param string
* @param array
* @return mixed
*/
public function __call($method, $args = array())
{
- if (in_array($method, $this->methods))
+ if (in_array($method, $this->_methods))
{
- return call_user_func_array(array($this->parent, $method), $args);
+ return call_user_func_array(array($this->_parent, $method), $args);
}
$trace = debug_backtrace();
@@ -208,9 +201,9 @@ class CI_Driver {
*/
public function __get($var)
{
- if (in_array($var, $this->properties))
+ if (in_array($var, $this->_properties))
{
- return $this->parent->$var;
+ return $this->_parent->$var;
}
}
@@ -227,16 +220,13 @@ class CI_Driver {
*/
public function __set($var, $val)
{
- if (in_array($var, $this->properties))
+ if (in_array($var, $this->_properties))
{
- $this->parent->$var = $val;
+ $this->_parent->$var = $val;
}
}
- // --------------------------------------------------------------------
-
}
-// END CI_Driver CLASS
/* End of file Driver.php */
-/* Location: ./system/libraries/Driver.php */
+/* Location: ./system/libraries/Driver.php */ \ No newline at end of file
diff --git a/system/libraries/Email.php b/system/libraries/Email.php
index 7429035f8..48c3bf3ab 100644
--- a/system/libraries/Email.php
+++ b/system/libraries/Email.php
@@ -59,6 +59,7 @@ class CI_Email {
public $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.
+ public $dsn = FALSE; // Delivery Status Notification
public $send_multipart = TRUE; // TRUE/FALSE - Yahoo does not like multipart alternative, so this is an override. Set to FALSE for Yahoo.
public $bcc_batch_mode = FALSE; // TRUE/FALSE - Turns on/off Bcc batch feature
public $bcc_batch_size = 200; // If bcc_batch_mode = TRUE, sets max number of Bccs in each batch
@@ -1577,9 +1578,15 @@ class CI_Email {
$resp = 250;
break;
case 'to' :
-
- $this->_send_data('RCPT TO:<'.$data.'>');
-
+
+ if ($this->dsn)
+ {
+ $this->_send_data('RCPT TO:<'.$data.'> NOTIFY=SUCCESS,DELAY,FAILURE ORCPT=rfc822;'.$data);
+ }
+ else
+ {
+ $this->_send_data('RCPT TO:<'.$data.'>');
+ }
$resp = 250;
break;
case 'data' :
diff --git a/system/libraries/Form_validation.php b/system/libraries/Form_validation.php
index 9491f354c..3e0c72e84 100644
--- a/system/libraries/Form_validation.php
+++ b/system/libraries/Form_validation.php
@@ -101,7 +101,7 @@ class CI_Form_validation {
return $this;
}
- // If an array was passed via the first parameter instead of indidual string
+ // If an array was passed via the first parameter instead of individual string
// values we cycle through it and recursively call this function.
if (is_array($field))
{
diff --git a/system/libraries/Ftp.php b/system/libraries/Ftp.php
index 4d96c00cc..8aa1650d2 100644
--- a/system/libraries/Ftp.php
+++ b/system/libraries/Ftp.php
@@ -25,8 +25,6 @@
* @filesource
*/
-// ------------------------------------------------------------------------
-
/**
* FTP Class
*
@@ -42,16 +40,11 @@ class CI_FTP {
public $username = '';
public $password = '';
public $port = 21;
- public $passive = TRUE;
+ public $passive = TRUE;
public $debug = FALSE;
- public $conn_id = FALSE;
+ public $conn_id = FALSE;
- /**
- * Constructor - Sets Preferences
- *
- * The constructor can be passed an array of config values
- */
public function __construct($config = array())
{
if (count($config) > 0)
@@ -59,7 +52,7 @@ class CI_FTP {
$this->initialize($config);
}
- log_message('debug', "FTP Class Initialized");
+ log_message('debug', 'FTP Class Initialized');
}
// --------------------------------------------------------------------
@@ -67,7 +60,6 @@ class CI_FTP {
/**
* Initialize preferences
*
- * @access public
* @param array
* @return void
*/
@@ -90,7 +82,6 @@ class CI_FTP {
/**
* FTP Connect
*
- * @access public
* @param array the connection values
* @return bool
*/
@@ -133,10 +124,9 @@ class CI_FTP {
/**
* FTP Login
*
- * @access private
* @return bool
*/
- private function _login()
+ protected function _login()
{
return @ftp_login($this->conn_id, $this->username, $this->password);
}
@@ -146,10 +136,9 @@ class CI_FTP {
/**
* Validates the connection ID
*
- * @access private
* @return bool
*/
- private function _is_conn()
+ protected function _is_conn()
{
if ( ! is_resource($this->conn_id))
{
@@ -164,17 +153,15 @@ class CI_FTP {
// --------------------------------------------------------------------
-
/**
* Change directory
*
* The second parameter lets us momentarily turn off debugging so that
* this function can be used to test for the existence of a folder
- * without throwing an error. There's no FTP equivalent to is_dir()
+ * 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 parameter is only used by the "mirror" function below.
*
- * @access public
* @param string
* @param bool
* @return bool
@@ -190,7 +177,7 @@ class CI_FTP {
if ($result === FALSE)
{
- if ($this->debug == TRUE AND $supress_debug == FALSE)
+ if ($this->debug == TRUE && $supress_debug == FALSE)
{
$this->_error('ftp_unable_to_changedir');
}
@@ -205,8 +192,8 @@ class CI_FTP {
/**
* Create a directory
*
- * @access public
* @param string
+ * @param int
* @return bool
*/
public function mkdir($path = '', $permissions = NULL)
@@ -230,7 +217,7 @@ class CI_FTP {
// Set file permissions if needed
if ( ! is_null($permissions))
{
- $this->chmod($path, (int)$permissions);
+ $this->chmod($path, (int) $permissions);
}
return TRUE;
@@ -241,10 +228,10 @@ class CI_FTP {
/**
* Upload a file to the server
*
- * @access public
* @param string
* @param string
* @param string
+ * @param int
* @return bool
*/
public function upload($locpath, $rempath, $mode = 'auto', $permissions = NULL)
@@ -284,7 +271,7 @@ class CI_FTP {
// Set file permissions if needed
if ( ! is_null($permissions))
{
- $this->chmod($rempath, (int)$permissions);
+ $this->chmod($rempath, (int) $permissions);
}
return TRUE;
@@ -295,7 +282,6 @@ class CI_FTP {
/**
* Download a file from a remote server to the local server
*
- * @access public
* @param string
* @param string
* @param string
@@ -337,7 +323,6 @@ class CI_FTP {
/**
* Rename (or move) a file
*
- * @access public
* @param string
* @param string
* @param bool
@@ -369,7 +354,6 @@ class CI_FTP {
/**
* Move a file
*
- * @access public
* @param string
* @param string
* @return bool
@@ -384,7 +368,6 @@ class CI_FTP {
/**
* Rename (or move) a file
*
- * @access public
* @param string
* @return bool
*/
@@ -415,7 +398,6 @@ class CI_FTP {
* Delete a folder and recursively delete everything (including sub-folders)
* containted within it.
*
- * @access public
* @param string
* @return bool
*/
@@ -427,11 +409,11 @@ class CI_FTP {
}
// Add a trailing slash to the file path if needed
- $filepath = preg_replace("/(.+?)\/*$/", "\\1/", $filepath);
+ $filepath = preg_replace('/(.+?)\/*$/', '\\1/', $filepath);
$list = $this->list_files($filepath);
- if ($list !== FALSE AND count($list) > 0)
+ if ($list !== FALSE && count($list) > 0)
{
foreach ($list as $item)
{
@@ -463,7 +445,6 @@ class CI_FTP {
/**
* Set file permissions
*
- * @access public
* @param string the file path
* @param string the permissions
* @return bool
@@ -494,7 +475,6 @@ class CI_FTP {
/**
* FTP List files in the specified directory
*
- * @access public
* @return array
*/
public function list_files($path = '.')
@@ -512,11 +492,11 @@ class CI_FTP {
/**
* 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.
+ * 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
@@ -532,7 +512,7 @@ class CI_FTP {
if ($fp = @opendir($locpath))
{
// Attempt to open the remote file path and try to create it, if it doesn't exist
- if ( ! $this->changedir($rempath, TRUE) AND ( ! $this->mkdir($rempath) OR ! $this->changedir($rempath)))
+ if ( ! $this->changedir($rempath, TRUE) && ( ! $this->mkdir($rempath) OR ! $this->changedir($rempath)))
{
return FALSE;
}
@@ -542,9 +522,9 @@ class CI_FTP {
{
if (@is_dir($locpath.$file) && $file[0] !== '.')
{
- $this->mirror($locpath.$file."/", $rempath.$file."/");
+ $this->mirror($locpath.$file.'/', $rempath.$file.'/');
}
- elseif ($file[0] !== ".")
+ elseif ($file[0] !== '.')
{
// Get the file extension so we can se the upload type
$ext = $this->_getext($file);
@@ -565,11 +545,10 @@ class CI_FTP {
/**
* Extract the file extension
*
- * @access private
* @param string
* @return string
*/
- private function _getext($filename)
+ protected function _getext($filename)
{
if (FALSE === strpos($filename, '.'))
{
@@ -580,36 +559,34 @@ class CI_FTP {
return end($x);
}
-
// --------------------------------------------------------------------
/**
* Set the upload type
*
- * @access private
* @param string
* @return string
*/
- private function _settype($ext)
+ protected 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';
+ 'txt',
+ 'text',
+ 'php',
+ 'phps',
+ 'php4',
+ 'js',
+ 'css',
+ 'htm',
+ 'html',
+ 'phtml',
+ 'shtml',
+ 'log',
+ 'xml'
+ );
+
+
+ return in_array($ext, $text_types) ? 'ascii' : 'binary';
}
// ------------------------------------------------------------------------
@@ -617,7 +594,6 @@ class CI_FTP {
/**
* Close the connection
*
- * @access public
* @return bool
*/
public function close()
@@ -635,20 +611,17 @@ class CI_FTP {
/**
* Display error message
*
- * @access private
* @param string
* @return void
*/
- private function _error($line)
+ protected 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 */
+/* Location: ./system/libraries/Ftp.php */ \ No newline at end of file
diff --git a/system/libraries/Migration.php b/system/libraries/Migration.php
index c045ac0e2..a18fcb9f1 100644
--- a/system/libraries/Migration.php
+++ b/system/libraries/Migration.php
@@ -25,8 +25,6 @@
* @filesource
*/
-// ------------------------------------------------------------------------
-
/**
* Migration Class
*
@@ -71,7 +69,7 @@ class CI_Migration {
}
// If not set, set it
- $this->_migration_path == '' AND $this->_migration_path = APPPATH.'migrations/';
+ $this->_migration_path != '' OR $this->_migration_path = APPPATH.'migrations/';
// Add trailing slash if not set
$this->_migration_path = rtrim($this->_migration_path, '/').'/';
@@ -101,7 +99,7 @@ class CI_Migration {
}
// Do we auto migrate to the latest migration?
- if ($this->_migration_auto_latest === TRUE AND ! $this->latest())
+ if ($this->_migration_auto_latest === TRUE && ! $this->latest())
{
show_error($this->error_string());
}
@@ -115,8 +113,7 @@ class CI_Migration {
* Calls each migration step required to get to the schema version of
* choice
*
- * @access public
- * @param $version integer Target schema version
+ * @param int Target schema version
* @return mixed TRUE if already latest, FALSE if failed, int if upgraded
*/
public function version($target_version)
@@ -241,7 +238,6 @@ class CI_Migration {
/**
* Set's the schema to the latest migration
*
- * @access public
* @return mixed true if already latest, false if failed, int if upgraded
*/
public function latest()
@@ -264,7 +260,6 @@ class CI_Migration {
/**
* Set's the schema to the migration version set in config
*
- * @access public
* @return mixed true if already current, false if failed, int if upgraded
*/
public function current()
@@ -277,7 +272,6 @@ class CI_Migration {
/**
* Error string
*
- * @access public
* @return string Error message returned as a string
*/
public function error_string()
@@ -290,7 +284,6 @@ class CI_Migration {
/**
* Set's the schema to the latest migration
*
- * @access protected
* @return mixed true if already latest, false if failed, int if upgraded
*/
protected function find_migrations()
@@ -317,8 +310,7 @@ class CI_Migration {
/**
* Retrieves current schema version
*
- * @access protected
- * @return integer Current Migration
+ * @return int Current Migration
*/
protected function _get_version()
{
@@ -331,9 +323,8 @@ class CI_Migration {
/**
* Stores the current schema version
*
- * @access protected
- * @param $migrations integer Migration reached
- * @return void Outputs a report of the migration
+ * @param int Migration reached
+ * @return void Outputs a report of the migration
*/
protected function _update_version($migrations)
{
@@ -347,8 +338,7 @@ class CI_Migration {
/**
* Enable the use of CI super-global
*
- * @access public
- * @param $var
+ * @param $var
* @return mixed
*/
public function __get($var)
@@ -358,4 +348,4 @@ class CI_Migration {
}
/* End of file Migration.php */
-/* Location: ./system/libraries/Migration.php */
+/* Location: ./system/libraries/Migration.php */ \ No newline at end of file
diff --git a/system/libraries/Pagination.php b/system/libraries/Pagination.php
index 86b8d79fa..0fe73d69f 100644
--- a/system/libraries/Pagination.php
+++ b/system/libraries/Pagination.php
@@ -25,8 +25,6 @@
* @filesource
*/
-// ------------------------------------------------------------------------
-
/**
* Pagination Class
*
@@ -74,13 +72,12 @@ class CI_Pagination {
/**
* Constructor
*
- * @access public
* @param array initialization parameters
*/
public function __construct($params = array())
{
$this->initialize($params);
- log_message('debug', "Pagination Class Initialized");
+ log_message('debug', 'Pagination Class Initialized');
}
// --------------------------------------------------------------------
@@ -88,7 +85,6 @@ class CI_Pagination {
/**
* Initialize Preferences
*
- * @access public
* @param array initialization parameters
* @return void
*/
@@ -116,7 +112,6 @@ class CI_Pagination {
/**
* Generate the pagination links
*
- * @access public
* @return string
*/
public function create_links()
@@ -155,13 +150,13 @@ class CI_Pagination {
$this->cur_page = (int) $CI->input->get($this->query_string_segment);
}
}
- elseif ( ! $this->cur_page AND $CI->uri->segment($this->uri_segment) != $base_page)
+ elseif ( ! $this->cur_page && $CI->uri->segment($this->uri_segment) != $base_page)
{
$this->cur_page = (int) $CI->uri->segment($this->uri_segment);
}
// Set current page to 1 if it's not valid or if using page numbers instead of offset
- if ( ! is_numeric($this->cur_page) OR ($this->use_page_numbers AND $this->cur_page == 0))
+ if ( ! is_numeric($this->cur_page) OR ($this->use_page_numbers && $this->cur_page == 0))
{
$this->cur_page = $base_page;
}
@@ -182,12 +177,9 @@ class CI_Pagination {
$this->cur_page = $num_pages;
}
}
- else
+ elseif ($this->cur_page > $this->total_rows)
{
- if ($this->cur_page > $this->total_rows)
- {
- $this->cur_page = ($num_pages - 1) * $this->per_page;
- }
+ $this->cur_page = ($num_pages - 1) * $this->per_page;
}
$uri_page_number = $this->cur_page;
@@ -199,10 +191,10 @@ class CI_Pagination {
// Calculate the start and end numbers. These determine
// which number to start and end the digit links with
- $start = (($this->cur_page - $this->num_links) > 0) ? $this->cur_page - ($this->num_links - 1) : 1;
- $end = (($this->cur_page + $this->num_links) < $num_pages) ? $this->cur_page + $this->num_links : $num_pages;
+ $start = (($this->cur_page - $this->num_links) > 0) ? $this->cur_page - ($this->num_links - 1) : 1;
+ $end = (($this->cur_page + $this->num_links) < $num_pages) ? $this->cur_page + $this->num_links : $num_pages;
- // Is pagination being used over GET or POST? If get, add a per_page query
+ // Is pagination being used over GET or POST? If get, add a per_page query
// string. If post, add a trailing slash to the base URL if needed
if ($CI->config->item('enable_query_strings') === TRUE OR $this->page_query_string === TRUE)
{
@@ -217,18 +209,18 @@ class CI_Pagination {
$output = '';
// Render the "First" link
- if ($this->first_link !== FALSE AND $this->cur_page > ($this->num_links + 1))
+ if ($this->first_link !== FALSE && $this->cur_page > ($this->num_links + 1))
{
$first_url = ($this->first_url == '') ? $this->base_url : $this->first_url;
$output .= $this->first_tag_open.'<a '.$this->anchor_class.'href="'.$first_url.'">'.$this->first_link.'</a>'.$this->first_tag_close;
}
// Render the "previous" link
- if ($this->prev_link !== FALSE AND $this->cur_page != 1)
+ if ($this->prev_link !== FALSE && $this->cur_page != 1)
{
$i = ($this->use_page_numbers) ? $uri_page_number - 1 : $uri_page_number - $this->per_page;
- if ($i == $base_page AND $this->first_url != '')
+ if ($i == $base_page && $this->first_url != '')
{
$output .= $this->prev_tag_open.'<a '.$this->anchor_class.'href="'.$this->first_url.'">'.$this->prev_link.'</a>'.$this->prev_tag_close;
}
@@ -274,7 +266,7 @@ class CI_Pagination {
}
// Render the "next" link
- if ($this->next_link !== FALSE AND $this->cur_page < $num_pages)
+ if ($this->next_link !== FALSE && $this->cur_page < $num_pages)
{
$i = ($this->use_page_numbers) ? $this->cur_page + 1 : $this->cur_page * $this->per_page;
@@ -282,7 +274,7 @@ class CI_Pagination {
}
// Render the "Last" link
- if ($this->last_link !== FALSE AND ($this->cur_page + $this->num_links) < $num_pages)
+ if ($this->last_link !== FALSE && ($this->cur_page + $this->num_links) < $num_pages)
{
$i = ($this->use_page_numbers) ? $num_pages : ($num_pages * $this->per_page) - $this->per_page;
@@ -291,15 +283,13 @@ class CI_Pagination {
// Kill double slashes. Note: Sometimes we can end up with a double slash
// in the penultimate link so we'll kill all double slashes.
- $output = preg_replace("#([^:])//+#", "\\1/", $output);
+ $output = preg_replace('#([^:])//+#', '\\1/', $output);
// Add the wrapper HTML if exists
- $output = $this->full_tag_open.$output.$this->full_tag_close;
-
- return $output;
+ return $this->full_tag_open.$output.$this->full_tag_close;
}
+
}
-// END Pagination Class
/* End of file Pagination.php */
-/* Location: ./system/libraries/Pagination.php */
+/* Location: ./system/libraries/Pagination.php */ \ No newline at end of file
diff --git a/system/libraries/Parser.php b/system/libraries/Parser.php
index 290e17fc0..d1b5b764b 100644
--- a/system/libraries/Parser.php
+++ b/system/libraries/Parser.php
@@ -25,8 +25,6 @@
* @filesource
*/
-// ------------------------------------------------------------------------
-
/**
* Parser Class
*
@@ -41,15 +39,14 @@ class CI_Parser {
public $l_delim = '{';
public $r_delim = '}';
public $object;
- private $CI;
+ protected $CI;
/**
- * Parse a template
+ * Parse a template
*
* Parses pseudo-variables contained in the specified template view,
* replacing them with the data in the second param
*
- * @access public
* @param string
* @param array
* @param bool
@@ -66,12 +63,11 @@ class CI_Parser {
// --------------------------------------------------------------------
/**
- * Parse a String
+ * Parse a String
*
* Parses pseudo-variables contained in the specified string,
* replacing them with the data in the second param
*
- * @access public
* @param string
* @param array
* @param bool
@@ -85,18 +81,17 @@ class CI_Parser {
// --------------------------------------------------------------------
/**
- * Parse a template
+ * Parse a template
*
* Parses pseudo-variables contained in the specified template,
* replacing them with the data in the second param
*
- * @access private
* @param string
* @param array
* @param bool
* @return string
*/
- private function _parse($template, $data, $return = FALSE)
+ protected function _parse($template, $data, $return = FALSE)
{
if ($template == '')
{
@@ -126,9 +121,8 @@ class CI_Parser {
// --------------------------------------------------------------------
/**
- * Set the left/right variable delimiters
+ * Set the left/right variable delimiters
*
- * @access public
* @param string
* @param string
* @return void
@@ -142,15 +136,14 @@ class CI_Parser {
// --------------------------------------------------------------------
/**
- * Parse a single key/value
+ * Parse a single key/value
*
- * @access private
* @param string
* @param string
* @param string
* @return string
*/
- private function _parse_single($key, $val, $string)
+ protected function _parse_single($key, $val, $string)
{
return str_replace($this->l_delim.$key.$this->r_delim, (string) $val, $string);
}
@@ -158,17 +151,16 @@ class CI_Parser {
// --------------------------------------------------------------------
/**
- * Parse a tag pair
+ * Parse a tag pair
*
- * Parses tag pairs: {some_tag} string... {/some_tag}
+ * Parses tag pairs: {some_tag} string... {/some_tag}
*
- * @access private
* @param string
* @param array
* @param string
* @return string
*/
- private function _parse_pair($variable, $data, $string)
+ protected function _parse_pair($variable, $data, $string)
{
if (FALSE === ($match = $this->_match_pair($string, $variable)))
{
@@ -200,25 +192,20 @@ class CI_Parser {
// --------------------------------------------------------------------
/**
- * Matches a variable pair
+ * Matches a variable pair
*
- * @access private
* @param string
* @param string
* @return mixed
*/
- private function _match_pair($string, $variable)
+ protected function _match_pair($string, $variable)
{
- if ( ! preg_match("|" . preg_quote($this->l_delim) . $variable . preg_quote($this->r_delim) . "(.+?)". preg_quote($this->l_delim) . '/' . $variable . preg_quote($this->r_delim) . "|s", $string, $match))
- {
- return FALSE;
- }
-
- return $match;
+ return preg_match('|'.preg_quote($this->l_delim).$variable.preg_quote($this->r_delim).'(.+?)'.preg_quote($this->l_delim).'/'.$variable.preg_quote($this->r_delim).'|s',
+ $string, $match)
+ ? $match : FALSE;
}
}
-// END Parser Class
/* End of file Parser.php */
-/* Location: ./system/libraries/Parser.php */
+/* Location: ./system/libraries/Parser.php */ \ No newline at end of file
diff --git a/system/libraries/Session.php b/system/libraries/Session.php
index 0b9d45b2a..3a80c1626 100644
--- a/system/libraries/Session.php
+++ b/system/libraries/Session.php
@@ -48,6 +48,7 @@ class CI_Session {
public $cookie_path = '';
public $cookie_domain = '';
public $cookie_secure = FALSE;
+ public $cookie_httponly = FALSE;
public $sess_time_to_update = 300;
public $encryption_key = '';
public $flashdata_key = 'flash';
@@ -72,7 +73,7 @@ class CI_Session {
// 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_expire_on_close', 'sess_match_ip', 'sess_match_useragent', 'sess_cookie_name', 'cookie_path', 'cookie_domain', 'cookie_secure', 'sess_time_to_update', 'time_reference', 'cookie_prefix', 'encryption_key') as $key)
+ foreach (array('sess_encrypt_cookie', 'sess_use_database', 'sess_table_name', 'sess_expiration', 'sess_expire_on_close', 'sess_match_ip', 'sess_match_useragent', 'sess_cookie_name', 'cookie_path', 'cookie_domain', 'cookie_secure', 'cookie_httponly', 'sess_time_to_update', 'time_reference', 'cookie_prefix', 'encryption_key') as $key)
{
$this->$key = (isset($params[$key])) ? $params[$key] : $this->CI->config->item($key);
}
@@ -468,6 +469,29 @@ class CI_Session {
{
return $this->userdata;
}
+
+ // --------------------------------------------------------------------------
+
+ /**
+ * Fetch all flashdata
+ *
+ * @return array
+ */
+ public function all_flashdata()
+ {
+ $out = array();
+
+ // loop through all userdata
+ foreach ($this->all_userdata() as $key => $val)
+ {
+ // if it contains flashdata, add it
+ if (strpos($key, 'flash:old:') !== FALSE)
+ {
+ $out[$key] = $val;
+ }
+ }
+ return $out;
+ }
// --------------------------------------------------------------------
@@ -666,13 +690,14 @@ class CI_Session {
// Set the cookie
setcookie(
- $this->sess_cookie_name,
- $cookie_data,
- $expire,
- $this->cookie_path,
- $this->cookie_domain,
- $this->cookie_secure
- );
+ $this->sess_cookie_name,
+ $cookie_data,
+ $expire,
+ $this->cookie_path,
+ $this->cookie_domain,
+ $this->cookie_secure,
+ $this->cookie_httponly
+ );
}
// --------------------------------------------------------------------
diff --git a/system/libraries/Table.php b/system/libraries/Table.php
index 99d001ce5..11a4858a9 100644
--- a/system/libraries/Table.php
+++ b/system/libraries/Table.php
@@ -112,7 +112,7 @@ class CI_Table {
*/
public function make_columns($array = array(), $col_limit = 0)
{
- if ( ! is_array($array) OR count($array) === 0)
+ if ( ! is_array($array) OR count($array) === 0 OR ! is_int($col_limit))
{
return FALSE;
}
@@ -405,7 +405,7 @@ class CI_Table {
// First generate the headings from the table column names
if (count($this->heading) === 0)
{
- if ( ! method_exists($query, 'list_fields'))
+ if ( ! is_callable(array($query, 'list_fields')))
{
return FALSE;
}
diff --git a/system/libraries/Typography.php b/system/libraries/Typography.php
index 65e30b089..21bbad038 100644
--- a/system/libraries/Typography.php
+++ b/system/libraries/Typography.php
@@ -25,13 +25,11 @@
* @filesource
*/
-// ------------------------------------------------------------------------
-
/**
* Typography Class
*
- *
- * @access protected
+ * @package CodeIgniter
+ * @subpackage Libraries
* @category Helpers
* @author EllisLab Dev Team
* @link http://codeigniter.com/user_guide/libraries/typography.html
@@ -67,7 +65,6 @@ class CI_Typography {
* - 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
@@ -94,15 +91,12 @@ class CI_Typography {
// HTML comment tags don't conform to patterns of normal tags, so pull them out separately, only if needed
$html_comments = array();
- if (strpos($str, '<!--') !== FALSE)
+ if (strpos($str, '<!--') !== FALSE && preg_match_all('#(<!\-\-.*?\-\->)#s', $str, $matches))
{
- if (preg_match_all("#(<!\-\-.*?\-\->)#s", $str, $matches))
+ for ($i = 0, $total = count($matches[0]); $i < $total; $i++)
{
- for ($i = 0, $total = count($matches[0]); $i < $total; $i++)
- {
- $html_comments[] = $matches[0][$i];
- $str = str_replace($matches[0][$i], '{@HC'.$i.'}', $str);
- }
+ $html_comments[] = $matches[0][$i];
+ $str = str_replace($matches[0][$i], '{@HC'.$i.'}', $str);
}
}
@@ -110,22 +104,22 @@ class CI_Typography {
// not contain <pre> tags, and it keeps the PCRE patterns below simpler and faster
if (strpos($str, '<pre') !== FALSE)
{
- $str = preg_replace_callback("#<pre.*?>.*?</pre>#si", array($this, '_protect_characters'), $str);
+ $str = preg_replace_callback('#<pre.*?>.*?</pre>#si', array($this, '_protect_characters'), $str);
}
// Convert quotes within tags to temporary markers.
- $str = preg_replace_callback("#<.+?>#si", array($this, '_protect_characters'), $str);
+ $str = preg_replace_callback('#<.+?>#si', array($this, '_protect_characters'), $str);
// Do the same with braces if necessary
if ($this->protect_braced_quotes === TRUE)
{
- $str = preg_replace_callback("#\{.+?\}#si", array($this, '_protect_characters'), $str);
+ $str = preg_replace_callback('#\{.+?\}#si', array($this, '_protect_characters'), $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);
+ $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:
*
@@ -148,9 +142,9 @@ class CI_Typography {
{
// 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.").*?>#", $chunks[$i], $match))
+ if (preg_match('#<(/*)('.$this->block_elements.').*?>#', $chunks[$i], $match))
{
- if (preg_match("#".$this->skip_elements."#", $match[2]))
+ if (preg_match('#'.$this->skip_elements.'#', $match[2]))
{
$process = ($match[1] === '/');
}
@@ -180,10 +174,10 @@ class CI_Typography {
$str .= $this->_format_newlines($chunks[$i]);
}
- // No opening block level tag? Add it if needed.
- if ( ! preg_match("/^\s*<(?:".$this->block_elements.")/i", $str))
+ // No opening block level tag? Add it if needed.
+ if ( ! preg_match('/^\s*<(?:'.$this->block_elements.')/i', $str))
{
- $str = preg_replace("/^(.*?)<(".$this->block_elements.")/i", '<p>$1</p><$2', $str);
+ $str = preg_replace('/^(.*?)<('.$this->block_elements.')/i', '<p>$1</p><$2', $str);
}
// Convert quotes, elipsis, em-dashes, non-breaking spaces, and ampersands
@@ -230,7 +224,7 @@ class CI_Typography {
// Similarly, there might be cases where a closing </block> will follow
// a closing </p> tag, so we'll correct it by adding a newline in between
- "#</p></#" => "</p>\n</"
+ '#</p></#' => "</p>\n</"
);
// Do we need to reduce empty lines?
@@ -258,7 +252,6 @@ class CI_Typography {
* to curly entities, but it also converts em-dashes,
* double spaces, and ampersands
*
- * @access public
* @param string
* @return string
*/
@@ -322,13 +315,12 @@ class CI_Typography {
*
* Converts newline characters into either <p> tags or <br />
*
- * @access protected
* @param string
* @return string
*/
protected function _format_newlines($str)
{
- if ($str == '' OR (strpos($str, "\n") === FALSE AND ! in_array($this->last_block_element, $this->inner_block_required)))
+ if ($str == '' OR (strpos($str, "\n") === FALSE && ! in_array($this->last_block_element, $this->inner_block_required)))
{
return $str;
}
@@ -337,7 +329,7 @@ class CI_Typography {
$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);
+ $str = preg_replace("/([^\n])(\n)([^\n])/", '\\1<br />\\2\\3', $str);
// Wrap the whole enchilada in enclosing paragraphs
if ($str != "\n")
@@ -350,9 +342,7 @@ class CI_Typography {
// 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;
+ return preg_replace('/<p><\/p>(.*)/', '\\1', $str, 1);
}
// ------------------------------------------------------------------------
@@ -365,7 +355,6 @@ class CI_Typography {
* 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
*
- * @access protected
* @param array
* @return string
*/
@@ -379,7 +368,6 @@ class CI_Typography {
/**
* Convert newlines to HTML line breaks except within PRE tags
*
- * @access public
* @param string
* @return string
*/
@@ -399,7 +387,6 @@ class CI_Typography {
}
}
-// END Typography Class
/* End of file Typography.php */
-/* Location: ./system/libraries/Typography.php */
+/* Location: ./system/libraries/Typography.php */ \ No newline at end of file
diff --git a/system/libraries/Upload.php b/system/libraries/Upload.php
index 42664a587..8ad67050d 100644
--- a/system/libraries/Upload.php
+++ b/system/libraries/Upload.php
@@ -25,8 +25,6 @@
* @filesource
*/
-// ------------------------------------------------------------------------
-
/**
* File Uploading Class
*
@@ -38,39 +36,40 @@
*/
class CI_Upload {
- public $max_size = 0;
- public $max_width = 0;
- public $max_height = 0;
- public $max_filename = 0;
+ public $max_size = 0;
+ public $max_width = 0;
+ public $max_height = 0;
+ public $max_filename = 0;
public $max_filename_increment = 100;
- public $allowed_types = "";
- public $file_temp = "";
- public $file_name = "";
- public $orig_name = "";
- public $file_type = "";
- public $file_size = "";
- public $file_ext = "";
- public $upload_path = "";
- public $overwrite = FALSE;
- public $encrypt_name = FALSE;
- public $is_image = FALSE;
- public $image_width = '';
- public $image_height = '';
- public $image_type = '';
- public $image_size_str = '';
- public $error_msg = array();
- public $mimes = array();
- public $remove_spaces = TRUE;
- public $xss_clean = FALSE;
- public $temp_prefix = "temp_file_";
- public $client_name = '';
+ public $allowed_types = '';
+ public $file_temp = '';
+ public $file_name = '';
+ public $orig_name = '';
+ public $file_type = '';
+ public $file_size = '';
+ public $file_ext = '';
+ public $upload_path = '';
+ public $overwrite = FALSE;
+ public $encrypt_name = FALSE;
+ public $is_image = FALSE;
+ public $image_width = '';
+ public $image_height = '';
+ public $image_type = '';
+ public $image_size_str = '';
+ public $error_msg = array();
+ public $mimes = array();
+ public $remove_spaces = TRUE;
+ public $xss_clean = FALSE;
+ public $temp_prefix = 'temp_file_';
+ public $client_name = '';
protected $_file_name_override = '';
/**
* Constructor
*
- * @access public
+ * @param array
+ * @return void
*/
public function __construct($props = array())
{
@@ -79,7 +78,7 @@ class CI_Upload {
$this->initialize($props);
}
- log_message('debug', "Upload Class Initialized");
+ log_message('debug', 'Upload Class Initialized');
}
// --------------------------------------------------------------------
@@ -93,33 +92,33 @@ class CI_Upload {
public function initialize($config = array())
{
$defaults = array(
- 'max_size' => 0,
- 'max_width' => 0,
- 'max_height' => 0,
- 'max_filename' => 0,
- 'max_filename_increment' => 100,
- 'allowed_types' => "",
- 'file_temp' => "",
- 'file_name' => "",
- 'orig_name' => "",
- 'file_type' => "",
- 'file_size' => "",
- 'file_ext' => "",
- 'upload_path' => "",
- 'overwrite' => FALSE,
- 'encrypt_name' => FALSE,
- 'is_image' => FALSE,
- 'image_width' => '',
- 'image_height' => '',
- 'image_type' => '',
- 'image_size_str' => '',
- 'error_msg' => array(),
- 'mimes' => array(),
- 'remove_spaces' => TRUE,
- 'xss_clean' => FALSE,
- 'temp_prefix' => "temp_file_",
- 'client_name' => ''
- );
+ 'max_size' => 0,
+ 'max_width' => 0,
+ 'max_height' => 0,
+ 'max_filename' => 0,
+ 'max_filename_increment' => 100,
+ 'allowed_types' => '',
+ 'file_temp' => '',
+ 'file_name' => '',
+ 'orig_name' => '',
+ 'file_type' => '',
+ 'file_size' => '',
+ 'file_ext' => '',
+ 'upload_path' => '',
+ 'overwrite' => FALSE,
+ 'encrypt_name' => FALSE,
+ 'is_image' => FALSE,
+ 'image_width' => '',
+ 'image_height' => '',
+ 'image_type' => '',
+ 'image_size_str' => '',
+ 'error_msg' => array(),
+ 'mimes' => array(),
+ 'remove_spaces' => TRUE,
+ 'xss_clean' => FALSE,
+ 'temp_prefix' => 'temp_file_',
+ 'client_name' => ''
+ );
foreach ($defaults as $key => $val)
@@ -156,8 +155,7 @@ class CI_Upload {
*/
public function do_upload($field = 'userfile')
{
-
- // Is $_FILES[$field] set? If not, no reason to continue.
+ // Is $_FILES[$field] set? If not, no reason to continue.
if ( ! isset($_FILES[$field]))
{
$this->set_error('upload_no_file_selected');
@@ -176,7 +174,7 @@ class CI_Upload {
{
$error = ( ! isset($_FILES[$field]['error'])) ? 4 : $_FILES[$field]['error'];
- switch($error)
+ switch ($error)
{
case 1: // UPLOAD_ERR_INI_SIZE
$this->set_error('upload_file_exceeds_limit');
@@ -199,19 +197,19 @@ class CI_Upload {
case 8: // UPLOAD_ERR_EXTENSION
$this->set_error('upload_stopped_by_extension');
break;
- default : $this->set_error('upload_no_file_selected');
+ default:
+ $this->set_error('upload_no_file_selected');
break;
}
return FALSE;
}
-
// Set the uploaded data as class variables
$this->file_temp = $_FILES[$field]['tmp_name'];
$this->file_size = $_FILES[$field]['size'];
$this->_file_mime_type($_FILES[$field]);
- $this->file_type = preg_replace("/^(.+?);.*$/", "\\1", $this->file_type);
+ $this->file_type = preg_replace('/^(.+?);.*$/', '\\1', $this->file_type);
$this->file_type = strtolower(trim(stripslashes($this->file_type), '"'));
$this->file_name = $this->_prep_filename($_FILES[$field]['name']);
$this->file_ext = $this->get_extension($this->file_name);
@@ -234,11 +232,10 @@ class CI_Upload {
{
$this->file_name .= $this->file_ext;
}
-
- // An extension was provided, lets have it!
else
{
- $this->file_ext = $this->get_extension($this->_file_name_override);
+ // An extension was provided, lets have it!
+ $this->file_ext = $this->get_extension($this->_file_name_override);
}
if ( ! $this->is_allowed_filetype(TRUE))
@@ -281,7 +278,7 @@ class CI_Upload {
// Remove white spaces in the name
if ($this->remove_spaces == TRUE)
{
- $this->file_name = preg_replace("/\s+/", "_", $this->file_name);
+ $this->file_name = preg_replace('/\s+/', '_', $this->file_name);
}
/*
@@ -305,23 +302,20 @@ class CI_Upload {
/*
* Run the file through the XSS hacking filter
* This helps prevent malicious code from being
- * embedded within a file. Scripts can easily
+ * embedded within a file. Scripts can easily
* be disguised as images or other file types.
*/
- if ($this->xss_clean)
+ if ($this->xss_clean && $this->do_xss_clean() === FALSE)
{
- if ($this->do_xss_clean() === FALSE)
- {
- $this->set_error('upload_unable_to_write_file');
- return FALSE;
- }
+ $this->set_error('upload_unable_to_write_file');
+ return FALSE;
}
/*
* Move the file to the final destination
* To deal with different server configurations
- * we'll attempt to use copy() first. If that fails
- * we'll use move_uploaded_file(). One of the two should
+ * we'll attempt to use copy() first. If that fails
+ * we'll use move_uploaded_file(). One of the two should
* reliably work in most environments
*/
if ( ! @copy($this->file_temp, $this->upload_path.$this->file_name))
@@ -336,7 +330,7 @@ class CI_Upload {
/*
* Set the finalized image dimensions
* This sets the image width/height (assuming the
- * file was an image). We use this information
+ * file was an image). We use this information
* in the "data" function.
*/
$this->set_image_properties($this->upload_path.$this->file_name);
@@ -356,22 +350,22 @@ class CI_Upload {
*/
public function data()
{
- return array (
- 'file_name' => $this->file_name,
- 'file_type' => $this->file_type,
- 'file_path' => $this->upload_path,
- 'full_path' => $this->upload_path.$this->file_name,
- 'raw_name' => str_replace($this->file_ext, '', $this->file_name),
- 'orig_name' => $this->orig_name,
- 'client_name' => $this->client_name,
- 'file_ext' => $this->file_ext,
- 'file_size' => $this->file_size,
- 'is_image' => $this->is_image(),
- 'image_width' => $this->image_width,
- 'image_height' => $this->image_height,
- 'image_type' => $this->image_type,
- 'image_size_str' => $this->image_size_str,
- );
+ return array(
+ 'file_name' => $this->file_name,
+ 'file_type' => $this->file_type,
+ 'file_path' => $this->upload_path,
+ 'full_path' => $this->upload_path.$this->file_name,
+ 'raw_name' => str_replace($this->file_ext, '', $this->file_name),
+ 'orig_name' => $this->orig_name,
+ 'client_name' => $this->client_name,
+ 'file_ext' => $this->file_ext,
+ 'file_size' => $this->file_size,
+ 'is_image' => $this->is_image(),
+ 'image_width' => $this->image_width,
+ 'image_height' => $this->image_height,
+ 'image_type' => $this->image_type,
+ 'image_size_str' => $this->image_size_str,
+ );
}
// --------------------------------------------------------------------
@@ -442,12 +436,12 @@ class CI_Upload {
/**
* Set Maximum File Size
*
- * @param integer
+ * @param int
* @return void
*/
public function set_max_filesize($n)
{
- $this->max_size = ((int) $n < 0) ? 0: (int) $n;
+ $this->max_size = ((int) $n < 0) ? 0 : (int) $n;
}
// --------------------------------------------------------------------
@@ -455,12 +449,12 @@ class CI_Upload {
/**
* Set Maximum File Name Length
*
- * @param integer
+ * @param int
* @return void
*/
public function set_max_filename($n)
{
- $this->max_filename = ((int) $n < 0) ? 0: (int) $n;
+ $this->max_filename = ((int) $n < 0) ? 0 : (int) $n;
}
// --------------------------------------------------------------------
@@ -468,12 +462,12 @@ class CI_Upload {
/**
* Set Maximum Image Width
*
- * @param integer
+ * @param int
* @return void
*/
public function set_max_width($n)
{
- $this->max_width = ((int) $n < 0) ? 0: (int) $n;
+ $this->max_width = ((int) $n < 0) ? 0 : (int) $n;
}
// --------------------------------------------------------------------
@@ -481,12 +475,12 @@ class CI_Upload {
/**
* Set Maximum Image Height
*
- * @param integer
+ * @param int
* @return void
*/
public function set_max_height($n)
{
- $this->max_height = ((int) $n < 0) ? 0: (int) $n;
+ $this->max_height = ((int) $n < 0) ? 0 : (int) $n;
}
// --------------------------------------------------------------------
@@ -499,7 +493,7 @@ class CI_Upload {
*/
public function set_allowed_types($types)
{
- if ( ! is_array($types) && $types == '*')
+ if ( ! is_array($types) && $types === '*')
{
$this->allowed_types = '*';
return;
@@ -530,10 +524,10 @@ class CI_Upload {
{
$types = array(1 => 'gif', 2 => 'jpeg', 3 => 'png');
- $this->image_width = $D['0'];
- $this->image_height = $D['1'];
- $this->image_type = ( ! isset($types[$D['2']])) ? 'unknown' : $types[$D['2']];
- $this->image_size_str = $D['3']; // string containing height and width
+ $this->image_width = $D[0];
+ $this->image_height = $D[1];
+ $this->image_type = isset($types[$D[2]]) ? $types[$D[2]] : 'unknown';
+ $this->image_size_str = $D[3]; // string containing height and width
}
}
}
@@ -551,7 +545,7 @@ class CI_Upload {
*/
public function set_xss_clean($flag = FALSE)
{
- $this->xss_clean = ($flag == TRUE) ? TRUE : FALSE;
+ $this->xss_clean = ($flag == TRUE);
}
// --------------------------------------------------------------------
@@ -573,19 +567,14 @@ class CI_Upload {
{
$this->file_type = 'image/png';
}
-
- if (in_array($this->file_type, $jpeg_mimes))
+ elseif (in_array($this->file_type, $jpeg_mimes))
{
$this->file_type = 'image/jpeg';
}
- $img_mimes = array(
- 'image/gif',
- 'image/jpeg',
- 'image/png',
- );
+ $img_mimes = array('image/gif', 'image/jpeg', 'image/png');
- return (in_array($this->file_type, $img_mimes, TRUE)) ? TRUE : FALSE;
+ return in_array($this->file_type, $img_mimes, TRUE);
}
// --------------------------------------------------------------------
@@ -631,16 +620,13 @@ class CI_Upload {
$mime = $this->mimes_types($ext);
- if (is_array($mime))
+ if (is_array($mime) && in_array($this->file_type, $mime, TRUE))
{
- if (in_array($this->file_type, $mime, TRUE))
- {
- return TRUE;
- }
+ return TRUE;
}
elseif ($mime === $this->file_type)
{
- return TRUE;
+ return TRUE;
}
return FALSE;
@@ -655,14 +641,7 @@ class CI_Upload {
*/
public function is_allowed_filesize()
{
- if ($this->max_size != 0 AND $this->file_size > $this->max_size)
- {
- return FALSE;
- }
- else
- {
- return TRUE;
- }
+ return ($this->max_size == 0 OR $this->max_size > $this->file_size);
}
// --------------------------------------------------------------------
@@ -683,17 +662,15 @@ class CI_Upload {
{
$D = @getimagesize($this->file_temp);
- if ($this->max_width > 0 AND $D['0'] > $this->max_width)
+ if ($this->max_width > 0 && $D[0] > $this->max_width)
{
return FALSE;
}
- if ($this->max_height > 0 AND $D['1'] > $this->max_height)
+ if ($this->max_height > 0 && $D[1] > $this->max_height)
{
return FALSE;
}
-
- return TRUE;
}
return TRUE;
@@ -706,7 +683,6 @@ class CI_Upload {
*
* Verifies that it is a valid upload path with proper permissions.
*
- *
* @return bool
*/
public function validate_upload_path()
@@ -717,9 +693,9 @@ class CI_Upload {
return FALSE;
}
- if (function_exists('realpath') AND @realpath($this->upload_path) !== FALSE)
+ if (function_exists('realpath') && @realpath($this->upload_path) !== FALSE)
{
- $this->upload_path = str_replace("\\", "/", realpath($this->upload_path));
+ $this->upload_path = str_replace('\\', '/', realpath($this->upload_path));
}
if ( ! @is_dir($this->upload_path))
@@ -734,7 +710,7 @@ class CI_Upload {
return FALSE;
}
- $this->upload_path = preg_replace("/(.+?)\/*$/", "\\1/", $this->upload_path);
+ $this->upload_path = preg_replace('/(.+?)\/*$/', '\\1/', $this->upload_path);
return TRUE;
}
@@ -763,37 +739,31 @@ class CI_Upload {
public function clean_file_name($filename)
{
$bad = array(
- "<!--",
- "-->",
- "'",
- "<",
- ">",
- '"',
- '&',
- '$',
- '=',
- ';',
- '?',
- '/',
- "%20",
- "%22",
- "%3c", // <
- "%253c", // <
- "%3e", // >
- "%0e", // >
- "%28", // (
- "%29", // )
- "%2528", // (
- "%26", // &
- "%24", // $
- "%3f", // ?
- "%3b", // ;
- "%3d" // =
- );
-
- $filename = str_replace($bad, '', $filename);
-
- return stripslashes($filename);
+ '<!--', '-->',
+ "'", '"',
+ '<', '>',
+ '&', '$',
+ '=',
+ ';',
+ '?',
+ '/',
+ '%20',
+ '%22',
+ '%3c', // <
+ '%253c', // <
+ '%3e', // >
+ '%0e', // >
+ '%28', // (
+ '%29', // )
+ '%2528', // (
+ '%26', // &
+ '%24', // $
+ '%3f', // ?
+ '%3b', // ;
+ '%3d' // =
+ );
+
+ return stripslashes(str_replace($bad, '', $filename));
}
// --------------------------------------------------------------------
@@ -847,7 +817,7 @@ class CI_Upload {
$current = ini_get('memory_limit') * 1024 * 1024;
// There was a bug/behavioural change in PHP 5.2, where numbers over one million get output
- // into scientific notation. number_format() ensures this number is an integer
+ // into scientific notation. number_format() ensures this number is an integer
// http://bugs.php.net/bug.php?id=43053
$new_memory = number_format(ceil(filesize($file) + $current), 0, '.', '');
@@ -857,8 +827,8 @@ class CI_Upload {
// If the file being uploaded is an image, then we should have no problem with XSS attacks (in theory), but
// IE can be fooled into mime-type detecting a malformed image as an html file, thus executing an XSS attack on anyone
- // using IE who looks at the image. It does this by inspecting the first 255 bytes of an image. To get around this
- // CI will itself look at the first 255 bytes of an image to determine its relative safety. This can save a lot of
+ // using IE who looks at the image. It does this by inspecting the first 255 bytes of an image. To get around this
+ // CI will itself look at the first 255 bytes of an image to determine its relative safety. This can save a lot of
// processor power and time if it is actually a clean image, as it will be in nearly all instances _except_ an
// attempted XSS attack.
@@ -932,7 +902,7 @@ class CI_Upload {
*/
public function display_errors($open = '<p>', $close = '</p>')
{
- return (count($this->error_msg) > 0) ? $open . implode($close . $open, $this->error_msg) . $close : '';
+ return (count($this->error_msg) > 0) ? $open.implode($close.$open, $this->error_msg).$close : '';
}
// --------------------------------------------------------------------
@@ -940,7 +910,7 @@ class CI_Upload {
/**
* List of Mime Types
*
- * This is a list of mime types. We use it to validate
+ * This is a list of mime types. We use it to validate
* the "allowed types" set by the developer
*
* @param string
@@ -952,7 +922,7 @@ class CI_Upload {
if (count($this->mimes) == 0)
{
- if (defined('ENVIRONMENT') AND is_file(APPPATH.'config/'.ENVIRONMENT.'/mimes.php'))
+ if (defined('ENVIRONMENT') && is_file(APPPATH.'config/'.ENVIRONMENT.'/mimes.php'))
{
include(APPPATH.'config/'.ENVIRONMENT.'/mimes.php');
}
@@ -966,10 +936,9 @@ class CI_Upload {
}
$this->mimes = $mimes;
- unset($mimes);
}
- return ( ! isset($this->mimes[$mime])) ? FALSE : $this->mimes[$mime];
+ return isset($this->mimes[$mime]) ? $this->mimes[$mime] : FALSE;
}
// --------------------------------------------------------------------
@@ -1006,9 +975,7 @@ class CI_Upload {
}
}
- $filename .= '.'.$ext;
-
- return $filename;
+ return $filename.'.'.$ext;
}
// --------------------------------------------------------------------
@@ -1129,10 +1096,7 @@ class CI_Upload {
$this->file_type = $file['type'];
}
- // --------------------------------------------------------------------
-
}
-// END Upload Class
/* End of file Upload.php */
-/* Location: ./system/libraries/Upload.php */
+/* Location: ./system/libraries/Upload.php */ \ No newline at end of file
diff --git a/system/libraries/Xmlrpc.php b/system/libraries/Xmlrpc.php
index 32e2e523b..b6e6c810d 100644
--- a/system/libraries/Xmlrpc.php
+++ b/system/libraries/Xmlrpc.php
@@ -136,10 +136,9 @@ class CI_Xmlrpc {
$this->initialize($config);
- log_message('debug', "XML-RPC Class Initialized");
+ log_message('debug', 'XML-RPC Class Initialized');
}
-
//-------------------------------------
// Initialize Prefs
//-------------------------------------
@@ -163,7 +162,7 @@ class CI_Xmlrpc {
// Take URL and parse it
//-------------------------------------
- public function server($url, $port=80)
+ public function server($url, $port = 80)
{
if (strpos($url, 'http') !== 0)
{
@@ -172,9 +171,9 @@ class CI_Xmlrpc {
$parts = parse_url($url);
- $path = ( ! isset($parts['path'])) ? '/' : $parts['path'];
+ $path = isset($parts['path']) ? $parts['path'] : '/';
- if (isset($parts['query']) && $parts['query'] != '')
+ if ( ! empty($parts['query']))
{
$path .= '?'.$parts['query'];
}
@@ -244,7 +243,7 @@ class CI_Xmlrpc {
{
if (is_array($value) && array_key_exists(0, $value))
{
- if ( ! isset($value[1]) OR ( ! isset($this->xmlrpcTypes[$value[1]])))
+ if ( ! isset($value[1], $this->xmlrpcTypes[$value[1]]))
{
$temp = new XML_RPC_Values($value[0], (is_array($value[0]) ? 'array' : 'string'));
}
@@ -337,7 +336,6 @@ class CI_Xmlrpc {
} // END XML_RPC Class
-
/**
* XML-RPC Client class
*
@@ -355,7 +353,7 @@ class XML_RPC_Client extends CI_Xmlrpc
public $timeout = 5;
public $no_multicall = FALSE;
- public function __construct($path, $server, $port=80)
+ public function __construct($path, $server, $port = 80)
{
parent::__construct();
@@ -383,7 +381,7 @@ class XML_RPC_Client extends CI_Xmlrpc
if ( ! is_resource($fp))
{
error_log($this->xmlrpcstr['http_error']);
- $r = new XML_RPC_Response(0, $this->xmlrpcerr['http_error'],$this->xmlrpcstr['http_error']);
+ $r = new XML_RPC_Response(0, $this->xmlrpcerr['http_error'], $this->xmlrpcstr['http_error']);
return $r;
}
@@ -394,12 +392,12 @@ class XML_RPC_Client extends CI_Xmlrpc
}
$r = "\r\n";
- $op = "POST {$this->path} HTTP/1.0$r"
- . "Host: {$this->server}$r"
- . "Content-Type: text/xml$r"
- . "User-Agent: {$this->xmlrpcName}$r"
- . "Content-Length: ".strlen($msg->payload)."$r$r"
- . $msg->payload;
+ $op = 'POST '.$this->path.' HTTP/1.0'.$r
+ .'Host: '.$this->server.$r
+ .'Content-Type: text/xml'.$r
+ .'User-Agent: '.$this->xmlrpcName.$r
+ .'Content-Length: '.strlen($msg->payload).$r.$r
+ .$msg->payload;
if ( ! fputs($fp, $op, strlen($op)))
@@ -446,10 +444,10 @@ class XML_RPC_Response
$this->errstr = htmlspecialchars($fstr, ENT_XML1 | ENT_NOQUOTES, 'UTF-8');
}
}
- else if ( ! is_object($val))
+ elseif ( ! is_object($val))
{
// programmer error, not an object
- error_log("Invalid type '" . gettype($val) . "' (value: $val) passed to XML_RPC_Response. Defaulting to empty value.");
+ error_log("Invalid type '".gettype($val)."' (value: ".$val.') passed to XML_RPC_Response. Defaulting to empty value.');
$this->val = new XML_RPC_Values();
}
else
@@ -532,8 +530,6 @@ class XML_RPC_Response
return $result;
}
-
-
//-------------------------------------
// XML-RPC Object to PHP Types
//-------------------------------------
@@ -571,7 +567,6 @@ class XML_RPC_Response
}
}
-
//-------------------------------------
// ISO-8601 time to server or UTC time
//-------------------------------------
@@ -605,7 +600,7 @@ class XML_RPC_Message extends CI_Xmlrpc
public $params = array();
public $xh = array();
- public function __construct($method, $pars=0)
+ public function __construct($method, $pars = 0)
{
parent::__construct();
@@ -681,7 +676,7 @@ class XML_RPC_Message extends CI_Xmlrpc
if (strncmp($data, 'HTTP', 4) === 0 && ! preg_match('/^HTTP\/[0-9\.]+ 200 /', $data))
{
$errstr= substr($data, 0, strpos($data, "\n")-1);
- $r = new XML_RPC_Response(0, $this->xmlrpcerr['http_error'], $this->xmlrpcstr['http_error']. ' (' . $errstr . ')');
+ $r = new XML_RPC_Response(0, $this->xmlrpcerr['http_error'], $this->xmlrpcstr['http_error'].' (' . $errstr . ')');
return $r;
}
@@ -706,7 +701,6 @@ class XML_RPC_Message extends CI_Xmlrpc
xml_set_character_data_handler($parser, 'character_data');
//xml_set_default_handler($parser, 'default_handler');
-
//-------------------------------------
// GET HEADERS
//-------------------------------------
@@ -765,14 +759,14 @@ class XML_RPC_Message extends CI_Xmlrpc
if ($this->debug === TRUE)
{
- echo "<pre>";
+ echo '<pre>';
if (count($this->xh[$parser]['headers'] > 0))
{
echo "---HEADERS---\n";
foreach ($this->xh[$parser]['headers'] as $header)
{
- echo "$header\n";
+ echo $header."\n";
}
echo "---END HEADERS---\n\n";
}
@@ -850,7 +844,7 @@ class XML_RPC_Message extends CI_Xmlrpc
if ( ! in_array($this->xh[$the_parser]['stack'][0], $this->valid_parents[$name], TRUE))
{
$this->xh[$the_parser]['isf'] = 2;
- $this->xh[$the_parser]['isf_reason'] = "XML-RPC element $name cannot be child of ".$this->xh[$the_parser]['stack'][0];
+ $this->xh[$the_parser]['isf_reason'] = 'XML-RPC element $name cannot be child of '.$this->xh[$the_parser]['stack'][0];
return;
}
}
@@ -861,8 +855,7 @@ class XML_RPC_Message extends CI_Xmlrpc
case 'ARRAY':
// Creates array for child elements
- $cur_val = array('value' => array(),
- 'type' => $name);
+ $cur_val = array('value' => array(), 'type' => $name);
array_unshift($this->xh[$the_parser]['valuestack'], $cur_val);
break;
@@ -925,7 +918,6 @@ class XML_RPC_Message extends CI_Xmlrpc
}
// END
-
//-------------------------------------
// End Element Handler
//-------------------------------------
@@ -996,7 +988,7 @@ class XML_RPC_Message extends CI_Xmlrpc
}
else
{
- $this->xh[$the_parser]['value'] = (double)$this->xh[$the_parser]['ac'];
+ $this->xh[$the_parser]['value'] = (float) $this->xh[$the_parser]['ac'];
}
}
else
@@ -1145,7 +1137,6 @@ class XML_RPC_Message extends CI_Xmlrpc
return $parameters;
}
-
public function decode_message($param)
{
$kind = $param->kindOf();
@@ -1237,7 +1228,7 @@ class XML_RPC_Values extends CI_Xmlrpc
if ($type == $this->xmlrpcBoolean)
{
- $val = (strcasecmp($val,'true') === 0 OR $val == 1 OR ($val == true && strcasecmp($val, 'false'))) ? 1 : 0;
+ $val = (strcasecmp($val,'true') === 0 OR $val == 1 OR ($val == TRUE && strcasecmp($val, 'false'))) ? 1 : 0;
}
if ($this->mytype == 2)
@@ -1383,4 +1374,4 @@ class XML_RPC_Values extends CI_Xmlrpc
// END XML_RPC_Values Class
/* End of file Xmlrpc.php */
-/* Location: ./system/libraries/Xmlrpc.php */
+/* Location: ./system/libraries/Xmlrpc.php */ \ No newline at end of file
diff --git a/system/libraries/Xmlrpcs.php b/system/libraries/Xmlrpcs.php
index fc41444bc..6d270c2ea 100644
--- a/system/libraries/Xmlrpcs.php
+++ b/system/libraries/Xmlrpcs.php
@@ -54,10 +54,7 @@ class CI_Xmlrpcs extends CI_Xmlrpc
public $controller_obj;
public $object = FALSE;
- /**
- * Constructor
- */
- public function __construct($config=array())
+ public function __construct($config = array())
{
parent::__construct();
$this->set_system_methods();
@@ -67,7 +64,7 @@ class CI_Xmlrpcs extends CI_Xmlrpc
$this->methods = array_merge($this->methods, $config['functions']);
}
- log_message('debug', "XML-RPC Server Class Initialized");
+ log_message('debug', 'XML-RPC Server Class Initialized');
}
// --------------------------------------------------------------------
@@ -75,7 +72,6 @@ class CI_Xmlrpcs extends CI_Xmlrpc
/**
* Initialize Prefs and Serve
*
- * @access public
* @param mixed
* @return void
*/
@@ -107,7 +103,6 @@ class CI_Xmlrpcs extends CI_Xmlrpc
/**
* Setting of System Methods
*
- * @access public
* @return void
*/
public function set_system_methods()
@@ -137,7 +132,6 @@ class CI_Xmlrpcs extends CI_Xmlrpc
/**
* Main Server Function
*
- * @access public
* @return void
*/
public function serve()
@@ -145,8 +139,8 @@ class CI_Xmlrpcs extends CI_Xmlrpc
$r = $this->parseRequest();
$payload = '<?xml version="1.0" encoding="'.$this->xmlrpc_defencoding.'"?'.'>'."\n".$this->debug_msg.$r->prepare_response();
- header("Content-Type: text/xml");
- header("Content-Length: ".strlen($payload));
+ header('Content-Type: text/xml');
+ header('Content-Length: '.strlen($payload));
exit($payload);
}
@@ -155,7 +149,6 @@ class CI_Xmlrpcs extends CI_Xmlrpc
/**
* Add Method to Class
*
- * @access public
* @param string method name
* @param string function
* @param string signature
@@ -176,7 +169,6 @@ class CI_Xmlrpcs extends CI_Xmlrpc
/**
* Parse Server Request
*
- * @access public
* @param string data
* @return object xmlrpc response
*/
@@ -198,7 +190,7 @@ class CI_Xmlrpcs extends CI_Xmlrpc
//-------------------------------------
$parser = xml_parser_create($this->xmlrpc_defencoding);
- $parser_object = new XML_RPC_Message("filler");
+ $parser_object = new XML_RPC_Message('filler');
$parser_object->xh[$parser] = array(
'isf' => 0,
@@ -215,7 +207,6 @@ class CI_Xmlrpcs extends CI_Xmlrpc
xml_set_character_data_handler($parser, 'character_data');
//xml_set_default_handler($parser, 'default_handler');
-
//-------------------------------------
// PARSE + PROCESS XML DATA
//-------------------------------------
@@ -245,7 +236,7 @@ class CI_Xmlrpcs extends CI_Xmlrpc
{
if ($this->debug === TRUE)
{
- $plist .= "$i - " . print_r(get_object_vars($parser_object->xh[$parser]['params'][$i]), TRUE). ";\n";
+ $plist .= $i.' - '.print_r(get_object_vars($parser_object->xh[$parser]['params'][$i]), TRUE).";\n";
}
$m->addParam($parser_object->xh[$parser]['params'][$i]);
@@ -276,7 +267,6 @@ class CI_Xmlrpcs extends CI_Xmlrpc
/**
* Executes the Method
*
- * @access protected
* @param object
* @return mixed
*/
@@ -305,7 +295,7 @@ class CI_Xmlrpcs extends CI_Xmlrpc
// Check for Method (and Object)
//-------------------------------------
- $method_parts = explode(".", $this->methods[$methName]['function']);
+ $method_parts = explode('.', $this->methods[$methName]['function']);
$objectCall = (isset($method_parts[1]) && $method_parts[1] != '');
if ($system_call === TRUE)
@@ -315,14 +305,11 @@ class CI_Xmlrpcs extends CI_Xmlrpc
return new XML_RPC_Response(0, $this->xmlrpcerr['unknown_method'], $this->xmlrpcstr['unknown_method']);
}
}
- else
+ elseif (($objectCall && ! is_callable(array($method_parts[0], $method_parts[1])))
+ OR ( ! $objectCall && ! is_callable($this->methods[$methName]['function']))
+ )
{
- if (($objectCall AND ! is_callable(array($method_parts[0], $method_parts[1])))
- OR ( ! $objectCall AND ! is_callable($this->methods[$methName]['function']))
- )
- {
- return new XML_RPC_Response(0, $this->xmlrpcerr['unknown_method'], $this->xmlrpcstr['unknown_method']);
- }
+ return new XML_RPC_Response(0, $this->xmlrpcerr['unknown_method'], $this->xmlrpcstr['unknown_method']);
}
//-------------------------------------
@@ -351,7 +338,7 @@ class CI_Xmlrpcs extends CI_Xmlrpc
return new XML_RPC_Response(0,
$this->xmlrpcerr['incorrect_params'],
$this->xmlrpcstr['incorrect_params'] .
- ": Wanted {$wanted}, got {$pt} at param {$pno})");
+ ': Wanted '.$wanted.', got '.$pt.' at param '.$pno.')');
}
}
}
@@ -393,7 +380,6 @@ class CI_Xmlrpcs extends CI_Xmlrpc
/**
* Server Function: List Methods
*
- * @access public
* @param mixed
* @return object
*/
@@ -409,7 +395,7 @@ class CI_Xmlrpcs extends CI_Xmlrpc
foreach ($this->system_methods as $key => $value)
{
- $output[]= new XML_RPC_Values($key, 'string');
+ $output[] = new XML_RPC_Values($key, 'string');
}
$v->addArray($output);
@@ -421,7 +407,6 @@ class CI_Xmlrpcs extends CI_Xmlrpc
/**
* Server Function: Return Signature for Method
*
- * @access public
* @param mixed
* @return object
*/
@@ -447,18 +432,14 @@ class CI_Xmlrpcs extends CI_Xmlrpc
}
$sigs[] = new XML_RPC_Values($cursig, 'array');
}
- $r = new XML_RPC_Response(new XML_RPC_Values($sigs, 'array'));
- }
- else
- {
- $r = new XML_RPC_Response(new XML_RPC_Values('undef', 'string'));
+
+ return new XML_RPC_Response(new XML_RPC_Values($sigs, 'array'));
}
+
+ return new XML_RPC_Response(new XML_RPC_Values('undef', 'string'));
}
- else
- {
- $r = new XML_RPC_Response(0,$this->xmlrpcerr['introspect_unknown'], $this->xmlrpcstr['introspect_unknown']);
- }
- return $r;
+
+ return new XML_RPC_Response(0,$this->xmlrpcerr['introspect_unknown'], $this->xmlrpcstr['introspect_unknown']);
}
// --------------------------------------------------------------------
@@ -466,7 +447,6 @@ class CI_Xmlrpcs extends CI_Xmlrpc
/**
* Server Function: Doc String for Method
*
- * @access public
* @param mixed
* @return object
*/
@@ -492,7 +472,6 @@ class CI_Xmlrpcs extends CI_Xmlrpc
/**
* Server Function: Multi-call
*
- * @access public
* @param mixed
* @return object
*/
@@ -536,7 +515,6 @@ class CI_Xmlrpcs extends CI_Xmlrpc
/**
* Multi-call Function: Error Handling
*
- * @access public
* @param mixed
* @return object
*/
@@ -556,7 +534,6 @@ class CI_Xmlrpcs extends CI_Xmlrpc
/**
* Multi-call Function: Processes method
*
- * @access public
* @param mixed
* @return object
*/
@@ -610,7 +587,6 @@ class CI_Xmlrpcs extends CI_Xmlrpc
}
}
-// END XML_RPC_Server class
/* End of file Xmlrpcs.php */
-/* Location: ./system/libraries/Xmlrpcs.php */
+/* Location: ./system/libraries/Xmlrpcs.php */ \ No newline at end of file
diff --git a/system/libraries/Zip.php b/system/libraries/Zip.php
index e33eb4e5a..e91e2a2ff 100644
--- a/system/libraries/Zip.php
+++ b/system/libraries/Zip.php
@@ -1,13 +1,13 @@
-<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
* An open source application development framework for PHP 5.2.4 or newer
*
* NOTICE OF LICENSE
- *
+ *
* Licensed under the Open Software License version 3.0
- *
+ *
* This source file is subject to the Open Software License (OSL 3.0) that is
* bundled with this package in the files license.txt / license.rst. It is
* also available through the world wide web at this URL:
@@ -25,8 +25,6 @@
* @filesource
*/
-// ------------------------------------------------------------------------
-
/**
* Zip Compression Class
*
@@ -44,21 +42,17 @@
*/
class CI_Zip {
- var $zipdata = '';
- var $directory = '';
- var $entries = 0;
- var $file_num = 0;
- var $offset = 0;
- var $now;
+ public $zipdata = '';
+ public $directory = '';
+ public $entries = 0;
+ public $file_num = 0;
+ public $offset = 0;
+ public $now;
- /**
- * Constructor
- */
public function __construct()
{
- log_message('debug', "Zip Compression Class Initialized");
-
$this->now = time();
+ log_message('debug', 'Zip Compression Class Initialized');
}
// --------------------------------------------------------------------
@@ -68,21 +62,19 @@ class CI_Zip {
*
* Lets you add a virtual directory into which you can place files.
*
- * @access public
* @param mixed the directory name. Can be string or array
* @return void
*/
- function add_dir($directory)
+ public function add_dir($directory)
{
- foreach ((array)$directory as $dir)
+ foreach ( (array) $directory as $dir)
{
- if ( ! preg_match("|.+/$|", $dir))
+ if ( ! preg_match('|.+/$|', $dir))
{
$dir .= '/';
}
$dir_time = $this->_get_mod_time($dir);
-
$this->_add_dir($dir, $dir_time['file_mtime'], $dir_time['file_mdate']);
}
}
@@ -90,22 +82,22 @@ class CI_Zip {
// --------------------------------------------------------------------
/**
- * Get file/directory modification time
+ * Get file/directory modification time
*
- * If this is a newly created file/dir, we will set the time to 'now'
+ * If this is a newly created file/dir, we will set the time to 'now'
*
- * @param string path to file
- * @return array filemtime/filemdate
+ * @param string path to file
+ * @return array filemtime/filemdate
*/
- function _get_mod_time($dir)
+ protected function _get_mod_time($dir)
{
// filemtime() may return false, but raises an error for non-existing files
- $date = (file_exists($dir)) ? filemtime($dir): getdate($this->now);
-
- $time['file_mtime'] = ($date['hours'] << 11) + ($date['minutes'] << 5) + $date['seconds'] / 2;
- $time['file_mdate'] = (($date['year'] - 1980) << 9) + ($date['mon'] << 5) + $date['mday'];
+ $date = file_exists($dir) ? filemtime($dir) : getdate($this->now);
- return $time;
+ return array(
+ 'file_mtime' => ($date['hours'] << 11) + ($date['minutes'] << 5) + $date['seconds'] / 2,
+ 'file_mdate' => (($date['year'] - 1980) << 9) + ($date['mon'] << 5) + $date['mday']
+ );
}
// --------------------------------------------------------------------
@@ -113,13 +105,14 @@ class CI_Zip {
/**
* Add Directory
*
- * @access private
* @param string the directory name
+ * @param int
+ * @param int
* @return void
*/
- function _add_dir($dir, $file_mtime, $file_mdate)
+ protected function _add_dir($dir, $file_mtime, $file_mdate)
{
- $dir = str_replace("\\", "/", $dir);
+ $dir = str_replace('\\', '/', $dir);
$this->zipdata .=
"\x50\x4b\x03\x04\x0a\x00\x00\x00\x00\x00"
@@ -162,29 +155,26 @@ class CI_Zip {
* Add Data to Zip
*
* Lets you add files to the archive. If the path is included
- * in the filename it will be placed within a directory. Make
+ * in the filename it will be placed within a directory. Make
* sure you use add_dir() first to create the folder.
*
- * @access public
* @param mixed
* @param string
* @return void
*/
- function add_data($filepath, $data = NULL)
+ public function add_data($filepath, $data = NULL)
{
if (is_array($filepath))
{
foreach ($filepath as $path => $data)
{
$file_data = $this->_get_mod_time($path);
-
$this->_add_data($path, $data, $file_data['file_mtime'], $file_data['file_mdate']);
}
}
else
{
$file_data = $this->_get_mod_time($filepath);
-
$this->_add_data($filepath, $data, $file_data['file_mtime'], $file_data['file_mdate']);
}
}
@@ -194,20 +184,19 @@ class CI_Zip {
/**
* Add Data to Zip
*
- * @access private
* @param string the file name/path
* @param string the data to be encoded
+ * @param int
+ * @param int
* @return void
*/
- function _add_data($filepath, $data, $file_mtime, $file_mdate)
+ protected function _add_data($filepath, $data, $file_mtime, $file_mdate)
{
- $filepath = str_replace("\\", "/", $filepath);
+ $filepath = str_replace('\\', '/', $filepath);
$uncompressed_size = strlen($data);
$crc32 = crc32($data);
-
- $gzdata = gzcompress($data);
- $gzdata = substr($gzdata, 2, -4);
+ $gzdata = substr(gzcompress($data), 2, -4);
$compressed_size = strlen($gzdata);
$this->zipdata .=
@@ -248,10 +237,11 @@ class CI_Zip {
/**
* Read the contents of a file and add it to the zip
*
- * @access public
+ * @param string
+ * @param bool
* @return bool
*/
- function read_file($path, $preserve_filepath = FALSE)
+ public function read_file($path, $preserve_filepath = FALSE)
{
if ( ! file_exists($path))
{
@@ -260,16 +250,16 @@ class CI_Zip {
if (FALSE !== ($data = file_get_contents($path)))
{
- $name = str_replace("\\", "/", $path);
-
+ $name = str_replace('\\', '/', $path);
if ($preserve_filepath === FALSE)
{
- $name = preg_replace("|.*/(.+)|", "\\1", $name);
+ $name = preg_replace('|.*/(.+)|', '\\1', $name);
}
$this->add_data($name, $data);
return TRUE;
}
+
return FALSE;
}
@@ -279,15 +269,17 @@ class CI_Zip {
* Read a directory and add it to the zip.
*
* This function recursively reads a folder and everything it contains (including
- * sub-folders) and creates a zip based on it. Whatever directory structure
+ * sub-folders) and creates a zip based on it. Whatever directory structure
* is in the original file path will be recreated in the zip file.
*
- * @access public
* @param string path to source
+ * @param bool
+ * @param bool
* @return bool
*/
- function read_dir($path, $preserve_filepath = TRUE, $root_path = NULL)
+ public function read_dir($path, $preserve_filepath = TRUE, $root_path = NULL)
{
+ $path = rtrim($path, '/\\').'/';
if ( ! $fp = @opendir($path))
{
return FALSE;
@@ -301,31 +293,27 @@ class CI_Zip {
while (FALSE !== ($file = readdir($fp)))
{
- if (substr($file, 0, 1) == '.')
+ if ($file[0] === '.')
{
continue;
}
if (@is_dir($path.$file))
{
- $this->read_dir($path.$file."/", $preserve_filepath, $root_path);
+ $this->read_dir($path.$file.'/', $preserve_filepath, $root_path);
}
- else
+ elseif (FALSE !== ($data = file_get_contents($path.$file)))
{
- if (FALSE !== ($data = file_get_contents($path.$file)))
+ $name = str_replace('\\', '/', $path);
+ if ($preserve_filepath === FALSE)
{
- $name = str_replace("\\", "/", $path);
-
- if ($preserve_filepath === FALSE)
- {
- $name = str_replace($root_path, '', $name);
- }
-
- $this->add_data($name.$file, $data);
+ $name = str_replace($root_path, '', $name);
}
+ $this->add_data($name.$file, $data);
}
}
+ closedir($fp);
return TRUE;
}
@@ -334,26 +322,23 @@ class CI_Zip {
/**
* Get the Zip file
*
- * @access public
- * @return binary string
+ * @return string (binary encoded)
*/
- function get_zip()
+ public function get_zip()
{
// Is there any data to return?
- if ($this->entries == 0)
+ if ($this->entries === 0)
{
return FALSE;
}
- $zip_data = $this->zipdata;
- $zip_data .= $this->directory."\x50\x4b\x05\x06\x00\x00\x00\x00";
- $zip_data .= pack('v', $this->entries); // total # of entries "on this disk"
- $zip_data .= pack('v', $this->entries); // total # of entries overall
- $zip_data .= pack('V', strlen($this->directory)); // size of central dir
- $zip_data .= pack('V', strlen($this->zipdata)); // offset to start of central dir
- $zip_data .= "\x00\x00"; // .zip file comment length
-
- return $zip_data;
+ return $this->zipdata
+ .$this->directory."\x50\x4b\x05\x06\x00\x00\x00\x00"
+ .pack('v', $this->entries) // total # of entries "on this disk"
+ .pack('v', $this->entries) // total # of entries overall
+ .pack('V', strlen($this->directory)) // size of central dir
+ .pack('V', strlen($this->zipdata)) // offset to start of central dir
+ ."\x00\x00"; // .zip file comment length
}
// --------------------------------------------------------------------
@@ -363,11 +348,10 @@ class CI_Zip {
*
* Lets you write a file
*
- * @access public
* @param string the file name
* @return bool
*/
- function archive($filepath)
+ public function archive($filepath)
{
if ( ! ($fp = @fopen($filepath, FOPEN_WRITE_CREATE_DESTRUCTIVE)))
{
@@ -387,23 +371,19 @@ class CI_Zip {
/**
* Download
*
- * @access public
* @param string the file name
- * @param string the data to be encoded
- * @return bool
+ * @return void
*/
- function download($filename = 'backup.zip')
+ public function download($filename = 'backup.zip')
{
- if ( ! preg_match("|.+?\.zip$|", $filename))
+ if ( ! preg_match('|.+?\.zip$|', $filename))
{
$filename .= '.zip';
}
$CI =& get_instance();
$CI->load->helper('download');
-
$get_zip = $this->get_zip();
-
$zip_content =& $get_zip;
force_download($filename, $zip_content);
@@ -414,19 +394,19 @@ class CI_Zip {
/**
* Initialize Data
*
- * Lets you clear current zip data. Useful if you need to create
+ * Lets you clear current zip data. Useful if you need to create
* multiple zips with different data.
*
- * @access public
- * @return void
+ * @return object
*/
- function clear_data()
+ public function clear_data()
{
$this->zipdata = '';
$this->directory = '';
$this->entries = 0;
$this->file_num = 0;
$this->offset = 0;
+ return $this;
}
}
diff --git a/tests/Bootstrap.php b/tests/Bootstrap.php
new file mode 100644
index 000000000..9f89d1be8
--- /dev/null
+++ b/tests/Bootstrap.php
@@ -0,0 +1,21 @@
+<?php
+
+// Errors on full!
+ini_set('display_errors', 1);
+error_reporting(E_ALL | E_STRICT);
+
+$dir = realpath(dirname(__FILE__));
+
+// Path constants
+define('PROJECT_BASE', realpath($dir.'/../').'/');
+define('BASEPATH', PROJECT_BASE.'system/');
+define('APPPATH', PROJECT_BASE.'application/');
+define('VIEWPATH', PROJECT_BASE.'');
+
+// Prep our test environment
+require_once 'vfsStream/vfsStream.php';
+include_once $dir.'/mocks/core/common.php';
+include_once $dir.'/mocks/autoloader.php';
+spl_autoload_register('autoload');
+
+unset($dir); \ No newline at end of file
diff --git a/tests/README.md b/tests/README.md
new file mode 100644
index 000000000..6d83c34d8
--- /dev/null
+++ b/tests/README.md
@@ -0,0 +1,164 @@
+# CodeIgniter Unit Tests #
+
+Status : [![Build Status](https://secure.travis-ci.org/EllisLab/CodeIgniter.png?branch=feature/unit-tests)](http://travis-ci.org/EllisLab/CodeIgniter)
+
+*Do not merge to default until these issues have been addressed*
+
+- Clean up naming conventions
+- Figure out config stuff
+- Figure out database testing
+
+### Introduction:
+
+This is the preliminary CodeIgniter testing documentation. It
+will cover both internal as well as external APIs and the reasoning
+behind their implemenation, where appropriate. As with all CodeIgniter
+documentation, this file should maintain a mostly human readable
+format to facilitate clean api design. [see http://arrenbrecht.ch/testing/]
+
+*First public draft: everything is subject to change*
+
+### Requirements
+
+PHP Unit >= 3.5.6
+
+ pear channel-discover pear.phpunit.de
+ pear install phpunit/PHPUnit
+
+vfsStream
+
+ pear channel-discover pear.php-tools.net
+ pear install pat/vfsStream-alpha
+
+#### Installation of PEAR and PHPUnit on Ubuntu
+
+ Installation on Ubuntu requires a few steps. Depending on your setup you may
+ need to use 'sudo' to install these. Mileage may vary but these steps are a
+ good start.
+
+ # Install the PEAR package
+ sudo apt-get install php-pear
+
+ # Add a few sources to PEAR
+ pear channel-discover pear.phpunit.de
+ pear channel-discover pear.symfony-project.com
+ pear channel-discover components.ez.no
+ pear channel-discover pear.php-tools.net
+
+ # Finally install PHPUnit and vfsStream (including dependencies)
+ pear install --alldeps phpunit/PHPUnit
+ pear install --alldeps pat/vfsStream-alpha
+
+ # Finally, run 'phpunit' from within the ./tests directory
+ # and you should be on your way!
+
+## Test Suites:
+
+CodeIgniter bootstraps a request very directly, with very flat class
+hierarchy. As a result, there is no main CodeIgniter class until the
+controller is instantiated.
+
+This has forced the core classes to be relatively decoupled, which is
+a good thing. However, it makes that portion of code relatively hard
+to test.
+
+Right now that means we'll probably have two core test suites, along
+with a base for application and package tests. That gives us:
+
+1. Bootstrap Test - test common.php and sanity check codeigniter.php [in planning]
+2. System Test - test core components in relative isolation [in development]
+3. Application Test - bootstrapping for application/tests [not started]
+4. Package Test - bootstrapping for <package>/tests [not started]
+
+### CI_TestCase Documentation
+
+Test cases should extend CI_TestCase. This internally extends
+PHPUnit\_Framework\_TestCase, so you have access to all of your
+usual PHPUnit methods.
+
+We need to provide a simple way to modify the globals and the
+common function output. We also need to be able to mock up
+the super object as we please.
+
+Current API is *not stable*. Names and implementations will change.
+
+ $this->ci_set_config($key, $val)
+
+Set the global config variables. If key is an array, it will
+replace the entire config array. They are _not_ merged.
+
+ $this->ci_instance($obj)
+
+Set the object to use as the "super object", in a lot
+of cases this will be a simple stdClass with the attributes
+you need it to have. If no parameter, will return the instance.
+
+ $this->ci_instance_var($name, $val)
+
+Add an attribute to the super object. This is useful if you
+set up a simple instance in setUp and then need to add different
+class mockups to your super object.
+
+ $this->ci_core_class($name)
+
+Get the _class name_ of a core class, so that you can instantiate
+it. The variable is returned by reference and is tied to the correct
+$GLOBALS key. For example:
+
+ $cfg =& $this->ci_core_class('cfg'); // returns 'CI_Config'
+ $cfg = new $cfg; // instantiates config and overwrites the CFG global
+
+ $this->ci_set_core_class($name, $obj)
+
+An alternative way to set one of the core globals.
+
+ $this->ci_get_config() __internal__
+
+Returns the global config array. Internal as you shouldn't need to
+call this (you're setting it, after all). Used internally to make
+CI's get_config() work.
+
+ CI_TestCase::instance() __internal__
+
+Returns an instance of the current test case. We force phpunit to
+run with backup-globals enabled, so this will always be the instance
+of the currently running test class.
+
+### Going forward
+
+#### 1. Bootstrap Test
+
+Testing common.php should be pretty simple. Include the file, and test the
+functions. May require some tweaking so that we can grab the statics from all
+methods (see is_loaded()). Testing the actual CodeIgniter.php file will most
+likely be an output test for the default view, with some object checking after
+the file runs. Needs consideration.
+
+#### 2. System Test
+
+Testing the core system relies on being able to isolate the core components
+as much as possible. A few of them access other core classes as globals. These
+should be mocked up and easy to manipulate.
+
+All functions in common.php should be a minimal implementation, or and mapped
+to a method in the test's parent class to gives us full control of their output.
+
+#### 3. Application Test:
+
+Not sure yet, needs to handle:
+
+- Libraries
+- Helpers
+- Models
+- MY_* files
+- Controllers (uh...?)
+- Views? (watir, selenium, cucumber?)
+- Database Testing
+
+#### 4. Package Test:
+
+I don't have a clue how this will work.
+
+Needs to be able to handle packages
+that are used multiple times within the application (i.e. EE/Pyro modules)
+as well as packages that are used by multiple applications (library distributions)
diff --git a/tests/codeigniter/Setup_test.php b/tests/codeigniter/Setup_test.php
new file mode 100644
index 000000000..550245f2f
--- /dev/null
+++ b/tests/codeigniter/Setup_test.php
@@ -0,0 +1,13 @@
+<?php
+
+class Setup_test extends PHPUnit_Framework_TestCase {
+
+ function test_nonsense()
+ {
+ $this->markTestIncomplete('not implemented');
+ // ensure that our bootstrapped test environment
+ // is a good representation of an isolated CI install
+ //die('here');
+ }
+
+} \ No newline at end of file
diff --git a/tests/codeigniter/core/Common_test.php b/tests/codeigniter/core/Common_test.php
new file mode 100644
index 000000000..dded2e824
--- /dev/null
+++ b/tests/codeigniter/core/Common_test.php
@@ -0,0 +1,13 @@
+<?php
+
+class Common_test extends CI_TestCase {
+
+ // ------------------------------------------------------------------------
+
+ public function test_is_php()
+ {
+ $this->assertEquals(TRUE, is_php('1.2.0'));
+ $this->assertEquals(FALSE, is_php('9999.9.9'));
+ }
+
+} \ No newline at end of file
diff --git a/tests/codeigniter/core/Config_test.php b/tests/codeigniter/core/Config_test.php
new file mode 100644
index 000000000..30f0cc61d
--- /dev/null
+++ b/tests/codeigniter/core/Config_test.php
@@ -0,0 +1,93 @@
+<?php
+
+class Config_test extends CI_TestCase {
+
+ public function set_up()
+ {
+ $cls =& $this->ci_core_class('cfg');
+
+ // set predictable config values
+ $this->ci_set_config(array(
+ 'index_page' => 'index.php',
+ 'base_url' => 'http://example.com/',
+ 'subclass_prefix' => 'MY_'
+ ));
+
+ $this->config = new $cls;
+ }
+
+ // --------------------------------------------------------------------
+
+ public function test_item()
+ {
+ $this->assertEquals('http://example.com/', $this->config->item('base_url'));
+
+ // Bad Config value
+ $this->assertFalse($this->config->item('no_good_item'));
+
+ // Index
+ $this->assertFalse($this->config->item('no_good_item', 'bad_index'));
+ $this->assertFalse($this->config->item('no_good_item', 'default'));
+ }
+
+ // --------------------------------------------------------------------
+
+ public function test_set_item()
+ {
+ $this->assertFalse($this->config->item('not_yet_set'));
+
+ $this->config->set_item('not_yet_set', 'is set');
+
+ $this->assertEquals('is set', $this->config->item('not_yet_set'));
+ }
+
+ // --------------------------------------------------------------------
+
+ public function test_slash_item()
+ {
+ // Bad Config value
+ $this->assertFalse($this->config->slash_item('no_good_item'));
+
+ $this->assertEquals('http://example.com/', $this->config->slash_item('base_url'));
+
+ $this->assertEquals('MY_/', $this->config->slash_item('subclass_prefix'));
+ }
+
+ // --------------------------------------------------------------------
+
+ public function test_site_url()
+ {
+ $this->assertEquals('http://example.com/index.php', $this->config->site_url());
+
+ $base_url = $this->config->item('base_url');
+
+ $this->config->set_item('base_url', '');
+
+ $q_string = $this->config->item('enable_query_strings');
+
+ $this->config->set_item('enable_query_strings', FALSE);
+
+ $this->assertEquals('index.php/test', $this->config->site_url('test'));
+ $this->assertEquals('index.php/test/1', $this->config->site_url(array('test', '1')));
+
+ $this->config->set_item('enable_query_strings', TRUE);
+
+ $this->assertEquals('index.php?test', $this->config->site_url('test'));
+ $this->assertEquals('index.php?0=test&1=1', $this->config->site_url(array('test', '1')));
+
+ $this->config->set_item('base_url', $base_url);
+
+ $this->assertEquals('http://example.com/index.php?test', $this->config->site_url('test'));
+
+ // back to home base
+ $this->config->set_item('enable_query_strings', $q_string);
+ }
+
+ // --------------------------------------------------------------------
+
+ public function test_system_url()
+ {
+ $this->assertEquals('http://example.com/system/', $this->config->system_url());
+ }
+
+} \ No newline at end of file
diff --git a/tests/codeigniter/core/Lang_test.php b/tests/codeigniter/core/Lang_test.php
new file mode 100644
index 000000000..a414f0ace
--- /dev/null
+++ b/tests/codeigniter/core/Lang_test.php
@@ -0,0 +1,31 @@
+<?php
+
+class Lang_test extends CI_TestCase {
+
+ protected $lang;
+
+ public function set_up()
+ {
+ $loader_cls = $this->ci_core_class('load');
+ $this->ci_instance_var('load', new $loader_cls);
+
+ $cls = $this->ci_core_class('lang');
+ $this->lang = new $cls;
+ }
+
+ // --------------------------------------------------------------------
+
+ public function test_load()
+ {
+ $this->assertTrue($this->lang->load('profiler', 'english'));
+ }
+
+ // --------------------------------------------------------------------
+
+ public function test_line()
+ {
+ $this->assertTrue($this->lang->load('profiler', 'english'));
+ $this->assertEquals('URI STRING', $this->lang->line('profiler_uri_string'));
+ }
+
+} \ No newline at end of file
diff --git a/tests/codeigniter/core/Loader_test.php b/tests/codeigniter/core/Loader_test.php
new file mode 100644
index 000000000..43008651e
--- /dev/null
+++ b/tests/codeigniter/core/Loader_test.php
@@ -0,0 +1,235 @@
+<?php
+
+class Loader_test extends CI_TestCase {
+
+ private $ci_obj;
+
+ public function set_up()
+ {
+ // Instantiate a new loader
+ $this->load = new Mock_Core_Loader();
+
+ // mock up a ci instance
+ $this->ci_obj = new StdClass;
+
+ // Fix get_instance()
+ $this->ci_instance($this->ci_obj);
+ }
+
+ // --------------------------------------------------------------------
+
+ public function test_library()
+ {
+ $this->_setup_config_mock();
+
+ // Test loading as an array.
+ $this->assertNull($this->load->library(array('table')));
+ $this->assertTrue(class_exists('CI_Table'), 'Table class exists');
+ $this->assertAttributeInstanceOf('CI_Table', 'table', $this->ci_obj);
+
+ // Test no lib given
+ $this->assertEquals(FALSE, $this->load->library());
+
+ // Test a string given to params
+ $this->assertEquals(NULL, $this->load->library('table', ' '));
+ }
+
+ // --------------------------------------------------------------------
+
+ public function test_load_library_in_application_dir()
+ {
+ $this->_setup_config_mock();
+
+ $content = '<?php class Super_test_library {} ';
+
+ $model = vfsStream::newFile('Super_test_library.php')->withContent($content)
+ ->at($this->load->libs_dir);
+
+ $this->assertNull($this->load->library('super_test_library'));
+
+ // Was the model class instantiated.
+ $this->assertTrue(class_exists('Super_test_library'));
+ }
+
+ // --------------------------------------------------------------------
+
+ private function _setup_config_mock()
+ {
+ // Mock up a config object until we
+ // figure out how to test the library configs
+ $config = $this->getMock('CI_Config', NULL, array(), '', FALSE);
+ $config->expects($this->any())
+ ->method('load')
+ ->will($this->returnValue(TRUE));
+
+ // Add the mock to our stdClass
+ $this->ci_instance_var('config', $config);
+ }
+
+ // --------------------------------------------------------------------
+
+ public function test_non_existent_model()
+ {
+ $this->setExpectedException(
+ 'RuntimeException',
+ 'CI Error: Unable to locate the model you have specified: ci_test_nonexistent_model.php'
+ );
+
+ $this->load->model('ci_test_nonexistent_model.php');
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * @coverts CI_Loader::model
+ */
+ public function test_models()
+ {
+ $this->ci_set_core_class('model', 'CI_Model');
+
+ $content = '<?php class Unit_test_model extends CI_Model {} ';
+
+ $model = vfsStream::newFile('unit_test_model.php')->withContent($content)
+ ->at($this->load->models_dir);
+
+ $this->assertNull($this->load->model('unit_test_model'));
+
+ // Was the model class instantiated.
+ $this->assertTrue(class_exists('Unit_test_model'));
+
+ // Test no model given
+ $this->assertNull($this->load->model(''));
+ }
+
+ // --------------------------------------------------------------------
+
+ // public function testDatabase()
+ // {
+ // $this->assertEquals(NULL, $this->load->database());
+ // $this->assertEquals(NULL, $this->load->dbutil());
+ // }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * @coverts CI_Loader::view
+ */
+ public function test_load_view()
+ {
+ $this->ci_set_core_class('output', 'CI_Output');
+
+ $content = 'This is my test page. <?php echo $hello; ?>';
+ $view = vfsStream::newFile('unit_test_view.php')->withContent($content)
+ ->at($this->load->views_dir);
+
+ // Use the optional return parameter in this test, so the view is not
+ // run through the output class.
+ $this->assertEquals('This is my test page. World!',
+ $this->load->view('unit_test_view', array('hello' => "World!"), TRUE));
+
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * @coverts CI_Loader::view
+ */
+ public function test_non_existent_view()
+ {
+ $this->setExpectedException(
+ 'RuntimeException',
+ 'CI Error: Unable to load the requested file: ci_test_nonexistent_view.php'
+ );
+
+ $this->load->view('ci_test_nonexistent_view', array('foo' => 'bar'));
+ }
+
+ // --------------------------------------------------------------------
+
+ public function test_file()
+ {
+ $content = 'Here is a test file, which we will load now.';
+ $file = vfsStream::newFile('ci_test_mock_file.php')->withContent($content)
+ ->at($this->load->views_dir);
+
+ // Just like load->view(), take the output class out of the mix here.
+ $load = $this->load->file(vfsStream::url('application').'/views/ci_test_mock_file.php',
+ TRUE);
+
+ $this->assertEquals($content, $load);
+
+ $this->setExpectedException(
+ 'RuntimeException',
+ 'CI Error: Unable to load the requested file: ci_test_file_not_exists'
+ );
+
+ $this->load->file('ci_test_file_not_exists', TRUE);
+
+ }
+
+ // --------------------------------------------------------------------
+
+ public function test_vars()
+ {
+ $vars = array(
+ 'foo' => 'bar'
+ );
+
+ $this->assertNull($this->load->vars($vars));
+ $this->assertNull($this->load->vars('foo', 'bar'));
+ }
+
+ // --------------------------------------------------------------------
+
+ public function test_helper()
+ {
+ $this->assertEquals(NULL, $this->load->helper('array'));
+
+ $this->setExpectedException(
+ 'RuntimeException',
+ 'CI Error: Unable to load the requested file: helpers/bad_helper.php'
+ );
+
+ $this->load->helper('bad');
+ }
+
+ // --------------------------------------------------------------------
+
+ public function test_loading_multiple_helpers()
+ {
+ $this->assertEquals(NULL, $this->load->helpers(array('file', 'array', 'string')));
+ }
+
+ // --------------------------------------------------------------------
+
+ // public function testLanguage()
+ // {
+ // $this->assertEquals(NULL, $this->load->language('test'));
+ // }
+
+ // --------------------------------------------------------------------
+
+ public function test_load_config()
+ {
+ $this->_setup_config_mock();
+
+ $this->assertNull($this->load->config('config', FALSE));
+ }
+
+ // --------------------------------------------------------------------
+
+ public function test_load_bad_config()
+ {
+ $this->_setup_config_mock();
+
+ $this->setExpectedException(
+ 'RuntimeException',
+ 'CI Error: The configuration file foobar.php does not exist.'
+ );
+
+ $this->load->config('foobar', FALSE);
+ }
+
+ // --------------------------------------------------------------------
+
+}
diff --git a/tests/codeigniter/core/URI_test.php b/tests/codeigniter/core/URI_test.php
new file mode 100644
index 000000000..e340ddf73
--- /dev/null
+++ b/tests/codeigniter/core/URI_test.php
@@ -0,0 +1,313 @@
+<?php
+
+class URI_test extends CI_TestCase {
+
+ public function set_up()
+ {
+ $this->uri = new Mock_Core_URI();
+ }
+
+ // --------------------------------------------------------------------
+
+ public function test_set_uri_string()
+ {
+ // Slashes get killed
+ $this->uri->_set_uri_string('/');
+
+ $a = '';
+ $b =& $this->uri->uri_string;
+
+ $this->assertEquals($a, $b);
+
+ $this->uri->_set_uri_string('nice/uri');
+
+ $a = 'nice/uri';
+
+ $this->assertEquals($a, $b);
+ }
+
+ // --------------------------------------------------------------------
+
+ public function test_fetch_uri_string()
+ {
+ define('SELF', 'index.php');
+
+ // uri_protocol: AUTO
+ $this->uri->config->set_item('uri_protocol', 'AUTO');
+
+ // Test a variety of request uris
+ $requests = array(
+ '/index.php/controller/method' => 'controller/method',
+ '/index.php?/controller/method' => 'controller/method',
+ '/index.php?/controller/method/?var=foo' => 'controller/method'
+ );
+
+ foreach($requests as $request => $expected)
+ {
+ $_SERVER['SCRIPT_NAME'] = '/index.php';
+ $_SERVER['REQUEST_URI'] = $request;
+
+ $this->uri->_fetch_uri_string();
+ $this->assertEquals($expected, $this->uri->uri_string );
+ }
+
+ // Test a subfolder
+ $_SERVER['SCRIPT_NAME'] = '/subfolder/index.php';
+ $_SERVER['REQUEST_URI'] = '/subfolder/index.php/controller/method';
+
+ $this->uri->_fetch_uri_string();
+
+ $a = 'controller/method';
+ $b = $this->uri->uri_string;
+
+ $this->assertEquals($a, $b);
+
+ // death to request uri
+ unset($_SERVER['REQUEST_URI']);
+
+ // life to path info
+ $_SERVER['PATH_INFO'] = '/controller/method/';
+
+ $this->uri->_fetch_uri_string();
+
+ $a = '/controller/method/';
+ $b =& $this->uri->uri_string;
+
+ $this->assertEquals($a, $b);
+
+ // death to path info
+ // At this point your server must be seriously drunk
+ unset($_SERVER['PATH_INFO']);
+
+ $_SERVER['QUERY_STRING'] = '/controller/method/';
+
+ $this->uri->_fetch_uri_string();
+
+ $a = '/controller/method/';
+ $b = $this->uri->uri_string;
+
+ $this->assertEquals($a, $b);
+
+ // At this point your server is a labotomy victim
+
+ unset($_SERVER['QUERY_STRING']);
+
+ $_GET['/controller/method/'] = '';
+
+ $this->uri->_fetch_uri_string();
+ $this->assertEquals($a, $b);
+
+ // Test coverage implies that these will work
+ // uri_protocol: REQUEST_URI
+ // uri_protocol: CLI
+
+ }
+
+ // --------------------------------------------------------------------
+
+ public function test_explode_segments()
+ {
+ // Lets test the function's ability to clean up this mess
+ $uris = array(
+ 'test/uri' => array('test', 'uri'),
+ '/test2/uri2' => array('test2', 'uri2'),
+ '//test3/test3///' => array('test3', 'test3')
+ );
+
+ foreach($uris as $uri => $a)
+ {
+ $this->uri->segments = array();
+ $this->uri->uri_string = $uri;
+ $this->uri->_explode_segments();
+
+ $b = $this->uri->segments;
+
+ $this->assertEquals($a, $b);
+ }
+
+ }
+
+ // --------------------------------------------------------------------
+
+ public function test_filter_uri()
+ {
+ $this->uri->config->set_item('enable_query_strings', FALSE);
+ $this->uri->config->set_item('permitted_uri_chars', 'a-z 0-9~%.:_\-');
+
+ $str_in = 'abc01239~%.:_-';
+ $str = $this->uri->_filter_uri($str_in);
+
+ $this->assertEquals($str, $str_in);
+ }
+
+ // --------------------------------------------------------------------
+
+ public function test_filter_uri_escaping()
+ {
+ // ensure escaping even if dodgey characters are permitted
+
+ $this->uri->config->set_item('enable_query_strings', FALSE);
+ $this->uri->config->set_item('permitted_uri_chars', 'a-z 0-9~%.:_\-()$');
+
+ $str = $this->uri->_filter_uri('$destroy_app(foo)');
+
+ $this->assertEquals($str, '&#36;destroy_app&#40;foo&#41;');
+ }
+
+ // --------------------------------------------------------------------
+
+ public function test_filter_uri_throws_error()
+ {
+ $this->setExpectedException('RuntimeException');
+
+ $this->uri->config->set_item('enable_query_strings', FALSE);
+ $this->uri->config->set_item('permitted_uri_chars', 'a-z 0-9~%.:_\-');
+ $this->uri->_filter_uri('$this()');
+ }
+
+ // --------------------------------------------------------------------
+
+ public function test_remove_url_suffix()
+ {
+ $this->uri->config->set_item('url_suffix', '.html');
+
+ $this->uri->uri_string = 'controller/method/index.html';
+ $this->uri->_remove_url_suffix();
+
+ $this->assertEquals($this->uri->uri_string, 'controller/method/index');
+
+ $this->uri->uri_string = 'controller/method/index.htmlify.html';
+ $this->uri->_remove_url_suffix();
+
+ $this->assertEquals($this->uri->uri_string, 'controller/method/index.htmlify');
+ }
+
+ // --------------------------------------------------------------------
+
+ public function test_segment()
+ {
+ $this->uri->segments = array(1 => 'controller');
+ $this->assertEquals($this->uri->segment(1), 'controller');
+ $this->assertEquals($this->uri->segment(2, 'default'), 'default');
+ }
+
+ // --------------------------------------------------------------------
+
+ public function test_rsegment()
+ {
+ $this->uri->rsegments = array(1 => 'method');
+ $this->assertEquals($this->uri->rsegment(1), 'method');
+ $this->assertEquals($this->uri->rsegment(2, 'default'), 'default');
+ }
+
+ // --------------------------------------------------------------------
+
+ public function test_uri_to_assoc()
+ {
+ $this->uri->segments = array('a', '1', 'b', '2', 'c', '3');
+
+ $a = array('a' => '1', 'b' => '2', 'c' => '3');
+ $b = $this->uri->uri_to_assoc(1);
+ $this->assertEquals($a, $b);
+
+ $a = array('b' => '2', 'c' => '3');
+ $b = $this->uri->uri_to_assoc(3);
+ $this->assertEquals($a, $b);
+
+
+ $this->uri->keyval = array(); // reset cache
+
+ $this->uri->segments = array('a', '1', 'b', '2', 'c');
+
+ $a = array('a' => '1', 'b' => '2', 'c' => FALSE);
+ $b = $this->uri->uri_to_assoc(1);
+ $this->assertEquals($a, $b);
+
+ $this->uri->keyval = array(); // reset cache
+
+ $this->uri->segments = array('a', '1');
+
+ // test default
+ $a = array('a' => '1', 'b' => FALSE);
+ $b = $this->uri->uri_to_assoc(1, array('a', 'b'));
+ $this->assertEquals($a, $b);
+ }
+
+ // --------------------------------------------------------------------
+
+ public function test_ruri_to_assoc()
+ {
+ $this->uri->rsegments = array('x', '1', 'y', '2', 'z', '3');
+
+ $a = array('x' => '1', 'y' => '2', 'z' => '3');
+ $b = $this->uri->ruri_to_assoc(1);
+ $this->assertEquals($a, $b);
+
+ $a = array('y' => '2', 'z' => '3');
+ $b = $this->uri->ruri_to_assoc(3);
+ $this->assertEquals($a, $b);
+
+
+ $this->uri->keyval = array(); // reset cache
+
+ $this->uri->rsegments = array('x', '1', 'y', '2', 'z');
+
+ $a = array('x' => '1', 'y' => '2', 'z' => FALSE);
+ $b = $this->uri->ruri_to_assoc(1);
+ $this->assertEquals($a, $b);
+
+ $this->uri->keyval = array(); // reset cache
+
+ $this->uri->rsegments = array('x', '1');
+
+ // test default
+ $a = array('x' => '1', 'y' => FALSE);
+ $b = $this->uri->ruri_to_assoc(1, array('x', 'y'));
+ $this->assertEquals($a, $b);
+
+ }
+
+ // --------------------------------------------------------------------
+
+ public function test_assoc_to_uri()
+ {
+ $this->uri->config->set_item('uri_string_slashes', 'none');
+
+ $arr = array('a' => 1, 'b' => 2);
+ $a = 'a/1/b/2';
+ $b = $this->uri->assoc_to_uri($arr);
+ $this->assertEquals($a, $b);
+ }
+
+ // --------------------------------------------------------------------
+
+ public function test_slash_segment()
+ {
+ $this->uri->segments[1] = 'segment';
+ $this->uri->rsegments[1] = 'segment';
+
+ $a = '/segment/';
+ $b = $this->uri->slash_segment(1, 'both');
+ $this->assertEquals($a, $b);
+ $b = $this->uri->slash_rsegment(1, 'both');
+ $this->assertEquals($a, $b);
+
+ $a = '/segment';
+ $b = $this->uri->slash_segment(1, 'leading');
+ $this->assertEquals($a, $b);
+ $b = $this->uri->slash_rsegment(1, 'leading');
+ $this->assertEquals($a, $b);
+
+ $a = 'segment/';
+ $b = $this->uri->slash_segment(1, 'trailing');
+ $this->assertEquals($a, $b);
+ $b = $this->uri->slash_rsegment(1, 'trailing');
+ $this->assertEquals($a, $b);
+ }
+
+
+}
+// END URI_test Class
+
+/* End of file URI_test.php */
+/* Location: ./tests/core/URI_test.php */
diff --git a/tests/codeigniter/database/.gitkeep b/tests/codeigniter/database/.gitkeep
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/tests/codeigniter/database/.gitkeep
diff --git a/tests/codeigniter/helpers/array_helper_test.php b/tests/codeigniter/helpers/array_helper_test.php
new file mode 100644
index 000000000..9cd15960f
--- /dev/null
+++ b/tests/codeigniter/helpers/array_helper_test.php
@@ -0,0 +1,47 @@
+<?php
+
+class Array_helper_test extends CI_TestCase {
+
+ public function set_up()
+ {
+ $this->helper('array');
+
+ $this->my_array = array(
+ 'foo' => 'bar',
+ 'sally' => 'jim',
+ 'maggie' => 'bessie',
+ 'herb' => 'cook'
+ );
+ }
+
+ // ------------------------------------------------------------------------
+
+ public function test_element_with_existing_item()
+ {
+ $this->assertEquals(FALSE, element('testing', $this->my_array));
+
+ $this->assertEquals('not set', element('testing', $this->my_array, 'not set'));
+
+ $this->assertEquals('bar', element('foo', $this->my_array));
+ }
+
+ // ------------------------------------------------------------------------
+
+ public function test_random_element()
+ {
+ // Send a string, not an array to random_element
+ $this->assertEquals('my string', random_element('my string'));
+
+ // Test sending an array
+ $this->assertEquals(TRUE, in_array(random_element($this->my_array), $this->my_array));
+ }
+
+ // ------------------------------------------------------------------------
+
+ public function test_elements()
+ {
+ $this->assertEquals(TRUE, is_array(elements('test', $this->my_array)));
+ $this->assertEquals(TRUE, is_array(elements('foo', $this->my_array)));
+ }
+
+} \ No newline at end of file
diff --git a/tests/codeigniter/helpers/date_helper_test.php b/tests/codeigniter/helpers/date_helper_test.php
new file mode 100644
index 000000000..17d1ef21e
--- /dev/null
+++ b/tests/codeigniter/helpers/date_helper_test.php
@@ -0,0 +1,288 @@
+<?php
+
+class Date_helper_test extends CI_TestCase {
+
+ public function set_up()
+ {
+ $this->helper('date');
+ }
+
+ // ------------------------------------------------------------------------
+
+ public function test_now_local()
+ {
+ // This stub job, is simply to cater $config['time_reference']
+ $config = $this->getMock('CI_Config');
+ $config->expects($this->any())
+ ->method('item')
+ ->will($this->returnValue('local'));
+
+ // Add the stub to our test instance
+ $this->ci_instance_var('config', $config);
+
+ $expected = time();
+ $test = now();
+ $this->assertEquals($expected, $test);
+ }
+
+ // ------------------------------------------------------------------------
+
+ public function test_now_gmt()
+ {
+ // This stub job, is simply to cater $config['time_reference']
+ $config = $this->getMock('CI_Config');
+ $config->expects($this->any())
+ ->method('item')
+ ->will($this->returnValue('gmt'));
+
+ // Add the stub to our stdClass
+ $this->ci_instance_var('config', $config);
+
+ $t = time();
+ $expected = mktime(gmdate("H", $t), gmdate("i", $t), gmdate("s", $t), gmdate("m", $t), gmdate("d", $t), gmdate("Y", $t));
+ $test = now();
+ $this->assertEquals($expected, $test);
+ }
+
+ // ------------------------------------------------------------------------
+
+ public function test_mdate()
+ {
+ $time = time();
+ $expected = date("Y-m-d - h:i a", $time);
+ $test = mdate("%Y-%m-%d - %h:%i %a", $time);
+ $this->assertEquals($expected, $test);
+ }
+
+ // ------------------------------------------------------------------------
+
+ public function test_standard_date_rfc822()
+ {
+ $time = time();
+ $format = 'DATE_RFC822';
+ $expected = date("D, d M y H:i:s O", $time);
+ $this->assertEquals($expected, standard_date($format, $time));
+ }
+
+ // ------------------------------------------------------------------------
+
+ public function test_standard_date_atom()
+ {
+ $time = time();
+ $format = 'DATE_ATOM';
+ $expected = date("Y-m-d\TH:i:sO", $time);
+ $this->assertEquals($expected, standard_date($format, $time));
+ }
+
+ // ------------------------------------------------------------------------
+
+ public function test_standard_date_cookie()
+ {
+ $time = time();
+ $format = 'DATE_COOKIE';
+ $expected = date("l, d-M-y H:i:s \U\T\C", $time);
+ $this->assertEquals($expected, standard_date($format, $time));
+ }
+
+ // ------------------------------------------------------------------------
+
+ public function test_standard_date_iso8601()
+ {
+ $time = time();
+ $format = 'DATE_ISO8601';
+ $expected = date("Y-m-d\TH:i:sO", $time);
+ $this->assertEquals($expected, standard_date($format, $time));
+ }
+
+ // ------------------------------------------------------------------------
+
+ public function test_standard_date_rfc850()
+ {
+ $time = time();
+ $format = 'DATE_RFC850';
+ $expected = date("l, d-M-y H:i:s \U\T\C", $time);
+ $this->assertEquals($expected, standard_date($format, $time));
+ }
+
+ // ------------------------------------------------------------------------
+
+ public function test_standard_date_rfc1036()
+ {
+ $time = time();
+ $format = 'DATE_RFC1036';
+ $expected = date("D, d M y H:i:s O", $time);
+ $this->assertEquals($expected, standard_date($format, $time));
+ }
+
+ // ------------------------------------------------------------------------
+
+ public function test_standard_date_rfc1123()
+ {
+ $time = time();
+ $format = 'DATE_RFC1123';
+ $expected = date("D, d M Y H:i:s O", $time);
+ $this->assertEquals($expected, standard_date($format, $time));
+ }
+
+ // ------------------------------------------------------------------------
+
+ public function test_standard_date_rfc2822()
+ {
+ $time = time();
+ $format = 'DATE_RFC2822';
+ $expected = date("D, d M Y H:i:s O", $time);
+ $this->assertEquals($expected, standard_date($format, $time));
+ }
+
+ // ------------------------------------------------------------------------
+
+ public function test_standard_date_rss()
+ {
+ $time = time();
+ $format = 'DATE_RSS';
+ $expected = date("D, d M Y H:i:s O", $time);
+ $this->assertEquals($expected, standard_date($format, $time));
+ }
+
+ // ------------------------------------------------------------------------
+
+ public function test_standard_date_w3c()
+ {
+ $time = time();
+ $format = 'DATE_W3C';
+ $expected = date("Y-m-d\TH:i:sO", $time);
+ $this->assertEquals($expected, standard_date($format, $time));
+ }
+
+ // ------------------------------------------------------------------------
+
+ public function test_timespan()
+ {
+ $loader_cls = $this->ci_core_class('load');
+ $this->ci_instance_var('load', new $loader_cls);
+
+ $lang_cls = $this->ci_core_class('lang');
+ $this->ci_instance_var('lang', new $lang_cls);
+
+ $this->assertEquals('1 Second', timespan(time(), time()+1));
+ $this->assertEquals('1 Minute', timespan(time(), time()+60));
+ $this->assertEquals('1 Hour', timespan(time(), time()+3600));
+ $this->assertEquals('2 Hours', timespan(time(), time()+7200));
+ }
+
+ // ------------------------------------------------------------------------
+
+ public function test_days_in_month()
+ {
+ $this->assertEquals(30, days_in_month(06, 2005));
+ $this->assertEquals(28, days_in_month(02, 2011));
+ $this->assertEquals(29, days_in_month(02, 2012));
+ }
+
+ // ------------------------------------------------------------------------
+
+ public function test_local_to_gmt()
+ {
+ $t = time();
+ $expected = mktime(gmdate("H", $t), gmdate("i", $t), gmdate("s", $t), gmdate("m", $t), gmdate("d", $t), gmdate("Y", $t));
+ $this->assertEquals($expected, local_to_gmt($t));
+ }
+
+ // ------------------------------------------------------------------------
+
+ public function test_gmt_to_local()
+ {
+ $timestamp = '1140153693';
+ $timezone = 'UM8';
+ $daylight_saving = TRUE;
+
+ $this->assertEquals(1140128493, gmt_to_local($timestamp, $timezone, $daylight_saving));
+ }
+
+ // ------------------------------------------------------------------------
+
+ public function test_mysql_to_unix()
+ {
+ $time = time();
+ $this->assertEquals($time,
+ mysql_to_unix(date("Y-m-d H:i:s", $time)));
+ }
+
+ // ------------------------------------------------------------------------
+
+ public function test_unix_to_human()
+ {
+ $time = time();
+ $this->assertEquals(date("Y-m-d h:i A", $time), unix_to_human($time));
+ $this->assertEquals(date("Y-m-d h:i:s A", $time), unix_to_human($time, TRUE, 'us'));
+ $this->assertEquals(date("Y-m-d H:i:s", $time), unix_to_human($time, TRUE, 'eu'));
+ }
+
+ // ------------------------------------------------------------------------
+
+ public function test_human_to_unix()
+ {
+ $date = '2000-12-31 10:00:00 PM';
+ $expected = strtotime($date);
+ $this->assertEquals($expected, human_to_unix($date));
+ $this->assertFalse(human_to_unix());
+ }
+
+ // ------------------------------------------------------------------------
+
+ public function test_timezones()
+ {
+ $zones = array(
+ 'UM12' => -12,
+ 'UM11' => -11,
+ 'UM10' => -10,
+ 'UM95' => -9.5,
+ 'UM9' => -9,
+ 'UM8' => -8,
+ 'UM7' => -7,
+ 'UM6' => -6,
+ 'UM5' => -5,
+ 'UM45' => -4.5,
+ 'UM4' => -4,
+ 'UM35' => -3.5,
+ 'UM3' => -3,
+ 'UM2' => -2,
+ 'UM1' => -1,
+ 'UTC' => 0,
+ 'UP1' => +1,
+ 'UP2' => +2,
+ 'UP3' => +3,
+ 'UP35' => +3.5,
+ 'UP4' => +4,
+ 'UP45' => +4.5,
+ 'UP5' => +5,
+ 'UP55' => +5.5,
+ 'UP575' => +5.75,
+ 'UP6' => +6,
+ 'UP65' => +6.5,
+ 'UP7' => +7,
+ 'UP8' => +8,
+ 'UP875' => +8.75,
+ 'UP9' => +9,
+ 'UP95' => +9.5,
+ 'UP10' => +10,
+ 'UP105' => +10.5,
+ 'UP11' => +11,
+ 'UP115' => +11.5,
+ 'UP12' => +12,
+ 'UP1275' => +12.75,
+ 'UP13' => +13,
+ 'UP14' => +14
+ );
+
+ foreach ($zones AS $test => $expected)
+ {
+ $this->assertEquals($expected, timezones($test));
+ }
+
+ $this->assertArrayHasKey('UP3', timezones());
+ $this->assertEquals(0, timezones('non_existant'));
+ }
+}
+
+/* End of file date_helper_test.php */ \ No newline at end of file
diff --git a/tests/codeigniter/helpers/directory_helper_test.php b/tests/codeigniter/helpers/directory_helper_test.php
new file mode 100644
index 000000000..3937d2913
--- /dev/null
+++ b/tests/codeigniter/helpers/directory_helper_test.php
@@ -0,0 +1,41 @@
+<?php
+
+class Directory_helper_test extends CI_TestCase {
+
+ public function set_up()
+ {
+ $this->helper('directory');
+
+ vfsStreamWrapper::register();
+ vfsStreamWrapper::setRoot(new vfsStreamDirectory('testDir'));
+
+ $this->_test_dir = vfsStreamWrapper::getRoot();
+ }
+
+ public function test_directory_map()
+ {
+ $structure = array('libraries' => array('benchmark.html' => '', 'database' =>
+ array('active_record.html' => '', 'binds.html' => ''), 'email.html' => '', '.hiddenfile.txt' => ''));
+
+ vfsStream::create($structure, $this->_test_dir);
+
+ // test default recursive behavior
+ $expected = array('libraries' => array('benchmark.html', 'database' =>
+ array('active_record.html', 'binds.html'), 'email.html'));
+
+ $this->assertEquals($expected, directory_map(vfsStream::url('testDir')));
+
+ // test recursion depth behavior
+ $expected = array('libraries');
+
+ $this->assertEquals($expected, directory_map(vfsStream::url('testDir'), 1));
+
+ // test detection of hidden files
+ $expected = array('libraries' => array('benchmark.html', 'database' =>
+ array('active_record.html', 'binds.html'), 'email.html', '.hiddenfile.txt'));
+
+ $this->assertEquals($expected, directory_map(vfsStream::url('testDir'), FALSE, TRUE));
+ }
+}
+
+/* End of file directory_helper_test.php */ \ No newline at end of file
diff --git a/tests/codeigniter/helpers/email_helper_test.php b/tests/codeigniter/helpers/email_helper_test.php
new file mode 100644
index 000000000..a01f3d5af
--- /dev/null
+++ b/tests/codeigniter/helpers/email_helper_test.php
@@ -0,0 +1,18 @@
+<?php
+
+class Email_helper_test extends CI_TestCase {
+
+ public function set_up()
+ {
+ $this->helper('email');
+ }
+
+ public function test_valid_email()
+ {
+ $this->assertEquals(FALSE, valid_email('test'));
+ $this->assertEquals(FALSE, valid_email('test@test@test.com'));
+ $this->assertEquals(TRUE, valid_email('test@test.com'));
+ $this->assertEquals(TRUE, valid_email('my.test@test.com'));
+ }
+
+} \ No newline at end of file
diff --git a/tests/codeigniter/helpers/file_helper_test.php b/tests/codeigniter/helpers/file_helper_test.php
new file mode 100644
index 000000000..4b9c29485
--- /dev/null
+++ b/tests/codeigniter/helpers/file_helper_test.php
@@ -0,0 +1,156 @@
+<?php
+
+class File_helper_Test extends CI_TestCase {
+
+ public function set_up()
+ {
+ $this->helper('file');
+
+ vfsStreamWrapper::register();
+ vfsStreamWrapper::setRoot(new vfsStreamDirectory('testDir'));
+
+ $this->_test_dir = vfsStreamWrapper::getRoot();
+ }
+
+ // --------------------------------------------------------------------
+
+ public function test_read_file()
+ {
+ $this->assertFalse(read_file('does_not_exist'));
+
+ $content = 'Jack and Jill went up the mountain to fight a billy goat.';
+
+ $file = vfsStream::newFile('my_file.txt')->withContent($content)
+ ->at($this->_test_dir);
+
+ $this->assertEquals($content, read_file(vfsStream::url('my_file.txt')));
+ }
+
+ // --------------------------------------------------------------------
+
+ public function test_octal_permissions()
+ {
+ $content = 'Jack and Jill went up the mountain to fight a billy goat.';
+
+ $file = vfsStream::newFile('my_file.txt', 0777)->withContent($content)
+ ->lastModified(time() - 86400)
+ ->at($this->_test_dir);
+
+ $this->assertEquals('777', octal_permissions($file->getPermissions()));
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * More tests should happen here, since I'm not hitting the whole function.
+ */
+ public function test_symbolic_permissions()
+ {
+ $content = 'Jack and Jill went up the mountain to fight a billy goat.';
+
+ $file = vfsStream::newFile('my_file.txt', 0777)->withContent($content)
+ ->lastModified(time() - 86400)
+ ->at($this->_test_dir);
+
+ $this->assertEquals('urwxrwxrwx', symbolic_permissions($file->getPermissions()));
+ }
+
+ // --------------------------------------------------------------------
+
+ public function test_get_mime_by_extension()
+ {
+ $content = 'Jack and Jill went up the mountain to fight a billy goat.';
+
+ $file = vfsStream::newFile('my_file.txt', 0777)->withContent($content)
+ ->lastModified(time() - 86400)
+ ->at($this->_test_dir);
+
+ $this->assertEquals('text/plain',
+ get_mime_by_extension(vfsStream::url('my_file.txt')));
+
+ // Test a mime with an array, such as png
+ $file = vfsStream::newFile('foo.png')->at($this->_test_dir);
+
+ $this->assertEquals('image/png', get_mime_by_extension(vfsStream::url('foo.png')));
+
+ // Test a file not in the mimes array
+ $file = vfsStream::newFile('foo.blarfengar')->at($this->_test_dir);
+
+ $this->assertFalse(get_mime_by_extension(vfsStream::url('foo.blarfengar')));
+ }
+
+ // --------------------------------------------------------------------
+
+ public function test_get_file_info()
+ {
+ // Test Bad File
+ $this->assertFalse(get_file_info('i_am_bad_boo'));
+
+ // Test the rest
+
+ // First pass in an array
+ $vals = array(
+ 'name', 'server_path', 'size', 'date',
+ 'readable', 'writable', 'executable', 'fileperms'
+ );
+
+ $this->_test_get_file_info($vals);
+
+ // Test passing in vals as a string.
+ $vals = 'name, server_path, size, date, readable, writable, executable, fileperms';
+ $this->_test_get_file_info($vals);
+ }
+
+ private function _test_get_file_info($vals)
+ {
+ $content = 'Jack and Jill went up the mountain to fight a billy goat.';
+ $last_modified = time() - 86400;
+
+ $file = vfsStream::newFile('my_file.txt', 0777)->withContent($content)
+ ->lastModified($last_modified)
+ ->at($this->_test_dir);
+
+ $ret_values = array(
+ 'name' => 'my_file.txt',
+ 'server_path' => 'vfs://my_file.txt',
+ 'size' => 57,
+ 'date' => $last_modified,
+ 'readable' => TRUE,
+ 'writable' => TRUE,
+ 'executable' => TRUE,
+ 'fileperms' => 33279
+ );
+
+ $info = get_file_info(vfsStream::url('my_file.txt'), $vals);
+
+ foreach ($info as $k => $v)
+ {
+ $this->assertEquals($ret_values[$k], $v);
+ }
+ }
+
+ // --------------------------------------------------------------------
+
+ // Skipping for now, as it's not implemented in vfsStreamWrapper
+ // flock(): vfsStreamWrapper::stream_lock is not implemented!
+
+ // public function test_write_file()
+ // {
+ // if ( ! defined('FOPEN_WRITE_CREATE_DESTRUCTIVE'))
+ // {
+ // define('FOPEN_WRITE_CREATE_DESTRUCTIVE', 'wb');
+ // }
+ //
+ // $content = 'Jack and Jill went up the mountain to fight a billy goat.';
+ //
+ // $file = vfsStream::newFile('write.txt', 0777)->withContent('')
+ // ->lastModified(time() - 86400)
+ // ->at($this->_test_dir);
+ //
+ // $this->assertTrue(write_file(vfsStream::url('write.txt'), $content));
+ //
+ // }
+
+ // --------------------------------------------------------------------
+
+} \ No newline at end of file
diff --git a/tests/codeigniter/helpers/html_helper_test.php b/tests/codeigniter/helpers/html_helper_test.php
new file mode 100644
index 000000000..28974b0f8
--- /dev/null
+++ b/tests/codeigniter/helpers/html_helper_test.php
@@ -0,0 +1,80 @@
+<?php
+
+class Html_helper_test extends CI_TestCase {
+
+ public function set_up()
+ {
+ $this->helper('html');
+ }
+
+ // ------------------------------------------------------------------------
+
+ public function test_br()
+ {
+ $this->assertEquals('<br /><br />', br(2));
+ }
+
+ // ------------------------------------------------------------------------
+
+ public function test_heading()
+ {
+ $this->assertEquals('<h1>foobar</h1>', heading('foobar'));
+ $this->assertEquals('<h2 class="bar">foobar</h2>', heading('foobar', 2, 'class="bar"'));
+ }
+
+ // ------------------------------------------------------------------------
+
+ public function test_Ul()
+ {
+ $expect = <<<EOH
+<ul>
+ <li>foo</li>
+ <li>bar</li>
+</ul>
+
+EOH;
+
+ $expect = ltrim($expect);
+
+ $list = array('foo', 'bar');
+
+ $this->assertEquals($expect, ul($list));
+
+
+ $expect = <<<EOH
+<ul class="test">
+ <li>foo</li>
+ <li>bar</li>
+</ul>
+
+EOH;
+
+ $expect = ltrim($expect);
+
+ $list = array('foo', 'bar');
+
+ $this->assertEquals($expect, ul($list, 'class="test"'));
+
+ $this->assertEquals($expect, ul($list, array('class' => 'test')));
+ }
+
+ // ------------------------------------------------------------------------
+
+ public function test_NBS()
+ {
+ $this->assertEquals('&nbsp;&nbsp;&nbsp;', nbs(3));
+ }
+
+ // ------------------------------------------------------------------------
+
+ public function test_meta()
+ {
+ $this->assertEquals("<meta name=\"test\" content=\"foo\" />\n", meta('test', 'foo'));
+
+ $expect = "<meta name=\"foo\" content=\"\" />\n";
+
+ $this->assertEquals($expect, meta(array('name' => 'foo')));
+
+ }
+
+} \ No newline at end of file
diff --git a/tests/codeigniter/helpers/inflector_helper_test.php b/tests/codeigniter/helpers/inflector_helper_test.php
new file mode 100644
index 000000000..9e9478711
--- /dev/null
+++ b/tests/codeigniter/helpers/inflector_helper_test.php
@@ -0,0 +1,95 @@
+<?php
+
+class Inflector_helper_test extends CI_TestCase {
+
+ public function set_up()
+ {
+ $this->helper('inflector');
+ }
+
+ public function test_singular()
+ {
+ $strs = array(
+ 'tellies' => 'telly',
+ 'smellies' => 'smelly',
+ 'abjectnesses' => 'abjectness',
+ 'smells' => 'smell',
+ 'equipment' => 'equipment'
+ );
+
+ foreach ($strs as $str => $expect)
+ {
+ $this->assertEquals($expect, singular($str));
+ }
+ }
+
+ // --------------------------------------------------------------------
+
+ public function test_plural()
+ {
+ $strs = array(
+ 'telly' => 'tellies',
+ 'smelly' => 'smellies',
+ 'abjectness' => 'abjectnesses', // ref : http://en.wiktionary.org/wiki/abjectnesses
+ 'smell' => 'smells',
+ 'witch' => 'witches',
+ 'equipment' => 'equipment'
+ );
+
+ foreach ($strs as $str => $expect)
+ {
+ $this->assertEquals($expect, plural($str));
+ }
+ }
+
+ // --------------------------------------------------------------------
+
+ public function test_camelize()
+ {
+ $strs = array(
+ 'this is the string' => 'thisIsTheString',
+ 'this is another one' => 'thisIsAnotherOne',
+ 'i-am-playing-a-trick' => 'i-am-playing-a-trick',
+ 'what_do_you_think-yo?' => 'whatDoYouThink-yo?',
+ );
+
+ foreach ($strs as $str => $expect)
+ {
+ $this->assertEquals($expect, camelize($str));
+ }
+ }
+
+ // --------------------------------------------------------------------
+
+ public function test_underscore()
+ {
+ $strs = array(
+ 'this is the string' => 'this_is_the_string',
+ 'this is another one' => 'this_is_another_one',
+ 'i-am-playing-a-trick' => 'i-am-playing-a-trick',
+ 'what_do_you_think-yo?' => 'what_do_you_think-yo?',
+ );
+
+ foreach ($strs as $str => $expect)
+ {
+ $this->assertEquals($expect, underscore($str));
+ }
+ }
+
+ // --------------------------------------------------------------------
+
+ public function test_humanize()
+ {
+ $strs = array(
+ 'this_is_the_string' => 'This Is The String',
+ 'this_is_another_one' => 'This Is Another One',
+ 'i-am-playing-a-trick' => 'I-am-playing-a-trick',
+ 'what_do_you_think-yo?' => 'What Do You Think-yo?',
+ );
+
+ foreach ($strs as $str => $expect)
+ {
+ $this->assertEquals($expect, humanize($str));
+ }
+ }
+} \ No newline at end of file
diff --git a/tests/codeigniter/helpers/number_helper_test.php b/tests/codeigniter/helpers/number_helper_test.php
new file mode 100644
index 000000000..4bb9a918a
--- /dev/null
+++ b/tests/codeigniter/helpers/number_helper_test.php
@@ -0,0 +1,77 @@
+<?php
+
+class Number_helper_test extends CI_TestCase {
+
+ public function set_up()
+ {
+ $this->helper('number');
+
+ // Grab the core lang class
+ $lang_cls = $this->ci_core_class('lang');
+
+ // Mock away load, too much going on in there,
+ // we'll just check for the expected parameter
+
+ $lang = $this->getMock($lang_cls, array('load'));
+ $lang->expects($this->once())
+ ->method('load')
+ ->with($this->equalTo('number'));
+
+ // Assign the proper language array
+
+ $lang->language = $this->_get_lang('number');
+
+ // We don't have a controller, so just create
+ // a cheap class to act as our super object.
+ // Make sure it has a lang attribute.
+
+ $obj = new StdClass;
+ $obj->lang = $lang;
+ $this->ci_instance($obj);
+ }
+
+ // Quick helper to actually grab the language
+ // file. Consider moving this to ci_testcase?
+ public function _get_lang($name)
+ {
+ require BASEPATH.'language/english/'.$name.'_lang.php';
+ return $lang;
+ }
+
+ public function test_byte_format()
+ {
+ $this->assertEquals('456 Bytes', byte_format(456));
+ }
+
+ public function test_kb_format()
+ {
+ $this->assertEquals('4.5 KB', byte_format(4567));
+ }
+
+ public function test_kb_format_medium()
+ {
+ $this->assertEquals('44.6 KB', byte_format(45678));
+ }
+
+ public function test_kb_format_large()
+ {
+ $this->assertEquals('446.1 KB', byte_format(456789));
+ }
+
+ public function test_mb_format()
+ {
+ $this->assertEquals('3.3 MB', byte_format(3456789));
+ }
+
+ public function test_gb_format()
+ {
+ $this->assertEquals('1.8 GB', byte_format(1932735283.2));
+ }
+
+ public function test_tb_format()
+ {
+ $this->assertEquals('112,283.3 TB', byte_format(123456789123456789));
+ }
+}
+
+// EOF \ No newline at end of file
diff --git a/tests/codeigniter/helpers/path_helper_test.php b/tests/codeigniter/helpers/path_helper_test.php
new file mode 100644
index 000000000..632f57501
--- /dev/null
+++ b/tests/codeigniter/helpers/path_helper_test.php
@@ -0,0 +1,32 @@
+<?php
+
+class Path_helper_test extends CI_TestCase {
+
+ public function set_up()
+ {
+ $this->helper('path');
+ }
+
+ public function test_set_realpath()
+ {
+ $expected = getcwd() . DIRECTORY_SEPARATOR;
+ $this->assertEquals($expected, set_realpath(getcwd()));
+ }
+
+ public function test_set_realpath_nonexistent_directory()
+ {
+ $expected = '/path/to/nowhere';
+ $this->assertEquals($expected, set_realpath('/path/to/nowhere', FALSE));
+ }
+
+ public function test_set_realpath_error_trigger()
+ {
+ $this->setExpectedException(
+ 'RuntimeException', 'CI Error: Not a valid path: /path/to/nowhere'
+ );
+
+ set_realpath('/path/to/nowhere', TRUE);
+ }
+}
+
+/* End of file path_helper_test.php */ \ No newline at end of file
diff --git a/tests/codeigniter/helpers/string_helper_test.php b/tests/codeigniter/helpers/string_helper_test.php
new file mode 100644
index 000000000..29c3d6594
--- /dev/null
+++ b/tests/codeigniter/helpers/string_helper_test.php
@@ -0,0 +1,147 @@
+<?php
+
+class String_helper_test extends CI_TestCase {
+
+ public function set_up()
+ {
+ $this->helper('string');
+ }
+
+ public function test_strip_slashes()
+ {
+ $expected = array(
+ "Is your name O'reilly?",
+ "No, my name is O'connor."
+ );
+
+ $str = array(
+ "Is your name O\'reilly?",
+ "No, my name is O\'connor."
+ );
+
+ $this->assertEquals($expected, strip_slashes($str));
+ }
+
+ public function test_trim_slashes()
+ {
+ $strs = array(
+ '//Slashes//\/' => 'Slashes//\\',
+ '/var/www/html/' => 'var/www/html'
+ );
+
+ foreach ($strs as $str => $expect)
+ {
+ $this->assertEquals($expect, trim_slashes($str));
+ }
+ }
+
+ // --------------------------------------------------------------------
+
+ public function test_strip_quotes()
+ {
+ $strs = array(
+ '"me oh my!"' => 'me oh my!',
+ "it's a winner!" => 'its a winner!',
+ );
+
+ foreach ($strs as $str => $expect)
+ {
+ $this->assertEquals($expect, strip_quotes($str));
+ }
+ }
+
+ // --------------------------------------------------------------------
+
+ public function test_quotes_to_entities()
+ {
+ $strs = array(
+ '"me oh my!"' => '&quot;me oh my!&quot;',
+ "it's a winner!" => 'it&#39;s a winner!',
+ );
+
+ foreach ($strs as $str => $expect)
+ {
+ $this->assertEquals($expect, quotes_to_entities($str));
+ }
+ }
+
+ // --------------------------------------------------------------------
+
+ public function test_reduce_double_slashes()
+ {
+ $strs = array(
+ 'http://codeigniter.com' => 'http://codeigniter.com',
+ '//var/www/html/example.com/' => '/var/www/html/example.com/',
+ '/var/www/html//index.php' => '/var/www/html/index.php'
+ );
+
+ foreach ($strs as $str => $expect)
+ {
+ $this->assertEquals($expect, reduce_double_slashes($str));
+ }
+ }
+
+ // --------------------------------------------------------------------
+
+ public function test_reduce_multiples()
+ {
+ $strs = array(
+ 'Fred, Bill,, Joe, Jimmy' => 'Fred, Bill, Joe, Jimmy',
+ 'Ringo, John, Paul,,' => 'Ringo, John, Paul,'
+ );
+
+ foreach ($strs as $str => $expect)
+ {
+ $this->assertEquals($expect, reduce_multiples($str));
+ }
+
+ $strs = array(
+ 'Fred, Bill,, Joe, Jimmy' => 'Fred, Bill, Joe, Jimmy',
+ 'Ringo, John, Paul,,' => 'Ringo, John, Paul'
+ );
+
+ foreach ($strs as $str => $expect)
+ {
+ $this->assertEquals($expect, reduce_multiples($str, ',', TRUE));
+ }
+ }
+
+ // --------------------------------------------------------------------
+
+ public function test_repeater()
+ {
+ $strs = array(
+ 'a' => 'aaaaaaaaaa',
+ '&nbsp;' => '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;',
+ '<br>' => '<br><br><br><br><br><br><br><br><br><br>'
+
+ );
+
+ foreach ($strs as $str => $expect)
+ {
+ $this->assertEquals($expect, repeater($str, 10));
+ }
+ }
+
+ // --------------------------------------------------------------------
+
+ public function test_random_string()
+ {
+ $this->assertEquals(16, strlen(random_string('alnum', 16)));
+ $this->assertEquals(32, strlen(random_string('unique', 16)));
+ $this->assertInternalType('string', random_string('numeric', 16));
+ }
+
+ // --------------------------------------------------------------------
+
+ public function test_increment_string()
+ {
+ $this->assertEquals('my-test_1', increment_string('my-test'));
+ $this->assertEquals('my-test-1', increment_string('my-test', '-'));
+ $this->assertEquals('file_5', increment_string('file_4'));
+ $this->assertEquals('file-5', increment_string('file-4', '-'));
+ $this->assertEquals('file-5', increment_string('file-4', '-'));
+ $this->assertEquals('file-1', increment_string('file', '-', '1'));
+ $this->assertEquals(124, increment_string('123', ''));
+ }
+} \ No newline at end of file
diff --git a/tests/codeigniter/helpers/text_helper_test.php b/tests/codeigniter/helpers/text_helper_test.php
new file mode 100644
index 000000000..584066b0c
--- /dev/null
+++ b/tests/codeigniter/helpers/text_helper_test.php
@@ -0,0 +1,159 @@
+<?php
+
+class Text_helper_test extends CI_TestCase {
+
+ private $_long_string;
+
+ public function set_up()
+ {
+ $this->helper('text');
+
+ $this->_long_string = 'Once upon a time, a framework had no tests. It sad. So some nice people began to write tests. The more time that went on, the happier it became. Everyone was happy.';
+ }
+
+ // ------------------------------------------------------------------------
+
+ public function test_word_limiter()
+ {
+ $this->assertEquals('Once upon a time,&#8230;', word_limiter($this->_long_string, 4));
+ $this->assertEquals('Once upon a time,&hellip;', word_limiter($this->_long_string, 4, '&hellip;'));
+ $this->assertEquals('', word_limiter('', 4));
+ }
+
+ // ------------------------------------------------------------------------
+
+ public function test_character_limiter()
+ {
+ $this->assertEquals('Once upon a time, a&#8230;', character_limiter($this->_long_string, 20));
+ $this->assertEquals('Once upon a time, a&hellip;', character_limiter($this->_long_string, 20, '&hellip;'));
+ $this->assertEquals('Short', character_limiter('Short', 20));
+ $this->assertEquals('Short', character_limiter('Short', 5));
+ }
+
+ // ------------------------------------------------------------------------
+
+ public function test_ascii_to_entities()
+ {
+ $strs = array(
+ '“‘ “test”' => '&#8220;&#8216; &#8220;test&#8221;',
+ '†¥¨ˆøåß∂ƒ©˙∆˚¬' => '&#8224;&#165;&#168;&#710;&#248;&#229;&#223;&#8706;&#402;&#169;&#729;&#8710;&#730;&#172;'
+ );
+
+ foreach ($strs as $str => $expect)
+ {
+ $this->assertEquals($expect, ascii_to_entities($str));
+ }
+ }
+
+ // ------------------------------------------------------------------------
+
+ public function test_entities_to_ascii()
+ {
+ $strs = array(
+ '&#8220;&#8216; &#8220;test&#8221;' => '“‘ “test”',
+ '&#8224;&#165;&#168;&#710;&#248;&#229;&#223;&#8706;&#402;&#169;&#729;&#8710;&#730;&#172;' => '†¥¨ˆøåß∂ƒ©˙∆˚¬'
+ );
+
+ foreach ($strs as $str => $expect)
+ {
+ $this->assertEquals($expect, entities_to_ascii($str));
+ }
+ }
+
+ // ------------------------------------------------------------------------
+
+ function test_convert_accented_characters()
+ {
+ $this->assertEquals('AAAeEEEIIOOEUUUeY', convert_accented_characters('ÀÂÄÈÊËÎÏÔŒÙÛÜŸ'));
+ $this->assertEquals('a e i o u n ue', convert_accented_characters('á é í ó ú ñ ü'));
+ }
+
+ // ------------------------------------------------------------------------
+
+ public function test_censored_words()
+ {
+ $censored = array('boob', 'nerd', 'ass', 'fart');
+
+ $strs = array(
+ 'Ted bobbled the ball' => 'Ted bobbled the ball',
+ 'Jake is a nerdo' => 'Jake is a nerdo',
+ 'The borg will assimilate you' => 'The borg will assimilate you',
+ 'Did Mary Fart?' => 'Did Mary $*#?',
+ 'Jake is really a boob' => 'Jake is really a $*#'
+ );
+
+
+ foreach ($strs as $str => $expect)
+ {
+ $this->assertEquals($expect, word_censor($str, $censored, '$*#'));
+ }
+
+ // test censored words being sent as a string
+ $this->assertEquals('test', word_censor('test', 'test'));
+ }
+
+ // ------------------------------------------------------------------------
+
+ public function test_highlight_code()
+ {
+ $code = '<?php var_dump($this); ?>';
+ $expect = "<code><span style=\"color: #000000\">\n<span style=\"color: #0000BB\">&lt;?php&nbsp;var_dump</span><span style=\"color: #007700\">(</span><span style=\"color: #0000BB\">\$this</span><span style=\"color: #007700\">);&nbsp;</span><span style=\"color: #0000BB\">?&gt;&nbsp;</span>\n</span>\n</code>";
+
+ $this->assertEquals($expect, highlight_code($code));
+ }
+
+ // ------------------------------------------------------------------------
+
+ public function test_highlight_phrase()
+ {
+ $strs = array(
+ 'this is a phrase' => '<strong>this is</strong> a phrase',
+ 'this is another' => '<strong>this is</strong> another',
+ 'Gimme a test, Sally' => 'Gimme a test, Sally',
+ 'Or tell me what this is' => 'Or tell me what <strong>this is</strong>',
+ '' => ''
+ );
+
+ foreach ($strs as $str => $expect)
+ {
+ $this->assertEquals($expect, highlight_phrase($str, 'this is'));
+ }
+ }
+
+ // ------------------------------------------------------------------------
+
+ public function test_ellipsizing()
+ {
+ $strs = array(
+ '0' => array(
+ 'this is my string' => '&hellip; my string',
+ "here's another one" => '&hellip;nother one',
+ 'this one is just a bit longer' => '&hellip;bit longer',
+ 'short' => 'short'
+ ),
+ '.5' => array(
+ 'this is my string' => 'this &hellip;tring',
+ "here's another one" => "here'&hellip;r one",
+ 'this one is just a bit longer' => 'this &hellip;onger',
+ 'short' => 'short'
+ ),
+ '1' => array(
+ 'this is my string' => 'this is my&hellip;',
+ "here's another one" => "here's ano&hellip;",
+ 'this one is just a bit longer' => 'this one i&hellip;',
+ 'short' => 'short'
+ ),
+ );
+
+ foreach ($strs as $pos => $s)
+ {
+ foreach ($s as $str => $expect)
+ {
+ $this->assertEquals($expect, ellipsize($str, 10, $pos));
+ }
+ }
+ }
+
+ // ------------------------------------------------------------------------
+
+} \ No newline at end of file
diff --git a/tests/codeigniter/helpers/url_helper_test.php b/tests/codeigniter/helpers/url_helper_test.php
new file mode 100644
index 000000000..c561809ce
--- /dev/null
+++ b/tests/codeigniter/helpers/url_helper_test.php
@@ -0,0 +1,75 @@
+<?php
+
+class Url_helper_test extends CI_TestCase {
+
+ public function set_up()
+ {
+ $this->helper('url');
+ }
+
+ public function test_url_title()
+ {
+ $words = array(
+ 'foo bar /' => 'foo-bar',
+ '\ testing 12' => 'testing-12'
+ );
+
+ foreach ($words as $in => $out)
+ {
+ $this->assertEquals($out, url_title($in, 'dash', TRUE));
+ }
+ }
+
+ // --------------------------------------------------------------------
+
+ public function test_url_title_extra_dashes()
+ {
+ $words = array(
+ '_foo bar_' => 'foo_bar',
+ '_What\'s wrong with CSS?_' => 'Whats_wrong_with_CSS'
+ );
+
+ foreach ($words as $in => $out)
+ {
+ $this->assertEquals($out, url_title($in, 'underscore'));
+ }
+ }
+
+ // --------------------------------------------------------------------
+
+ public function test_prep_url()
+ {
+ $this->assertEquals('http://codeigniter.com', prep_url('codeigniter.com'));
+ $this->assertEquals('http://www.codeigniter.com', prep_url('www.codeigniter.com'));
+ }
+
+ // --------------------------------------------------------------------
+
+ public function test_auto_link_url()
+ {
+ $strings = array(
+ 'www.codeigniter.com test' => '<a href="http://www.codeigniter.com">http://www.codeigniter.com</a> test',
+ 'This is my noreply@codeigniter.com test' => 'This is my noreply@codeigniter.com test',
+ '<br />www.google.com' => '<br /><a href="http://www.google.com">http://www.google.com</a>',
+ );
+
+ foreach ($strings as $in => $out)
+ {
+ $this->assertEquals($out, auto_link($in, 'url'));
+ }
+ }
+
+ // --------------------------------------------------------------------
+
+ public function test_pull_675()
+ {
+ $strings = array(
+ '<br />www.google.com' => '<br /><a href="http://www.google.com">http://www.google.com</a>',
+ );
+
+ foreach ($strings as $in => $out)
+ {
+ $this->assertEquals($out, auto_link($in, 'url'));
+ }
+ }
+} \ No newline at end of file
diff --git a/tests/codeigniter/helpers/xml_helper_test.php b/tests/codeigniter/helpers/xml_helper_test.php
new file mode 100644
index 000000000..a83fef91e
--- /dev/null
+++ b/tests/codeigniter/helpers/xml_helper_test.php
@@ -0,0 +1,15 @@
+<?php
+
+class Xml_helper_test extends CI_TestCase {
+
+ public function set_up()
+ {
+ $this->helper('xml');
+ }
+
+ public function test_xml_convert()
+ {
+ $this->assertEquals('&lt;tag&gt;my &amp; test &#45; &lt;/tag&gt;', xml_convert('<tag>my & test - </tag>'));
+ }
+
+} \ No newline at end of file
diff --git a/tests/codeigniter/libraries/Parser_test.php b/tests/codeigniter/libraries/Parser_test.php
new file mode 100644
index 000000000..c3d88fa85
--- /dev/null
+++ b/tests/codeigniter/libraries/Parser_test.php
@@ -0,0 +1,110 @@
+<?php
+
+class Parser_test extends CI_TestCase {
+
+ public function set_up()
+ {
+ $obj = new StdClass;
+ $obj->parser = new Mock_Libraries_Parser();
+
+ $this->ci_instance($obj);
+
+ $this->parser = $obj->parser;
+ }
+ // --------------------------------------------------------------------
+
+ public function test_set_delimiters()
+ {
+ // Make sure default delimiters are there
+ $this->assertEquals('{', $this->parser->l_delim);
+ $this->assertEquals('}', $this->parser->r_delim);
+
+ // Change them to square brackets
+ $this->parser->set_delimiters('[', ']');
+
+ // Make sure they changed
+ $this->assertEquals('[', $this->parser->l_delim);
+ $this->assertEquals(']', $this->parser->r_delim);
+
+ // Reset them
+ $this->parser->set_delimiters();
+
+ // Make sure default delimiters are there
+ $this->assertEquals('{', $this->parser->l_delim);
+ $this->assertEquals('}', $this->parser->r_delim);
+ }
+
+ // --------------------------------------------------------------------
+
+ public function test_parse_simple_string()
+ {
+ $data = array(
+ 'title' => 'Page Title',
+ 'body' => 'Lorem ipsum dolor sit amet.'
+ );
+
+ $template = "{title}\n{body}";
+
+ $result = implode("\n", $data);
+
+ $this->assertEquals($result, $this->parser->parse_string($template, $data, TRUE));
+ }
+
+ // --------------------------------------------------------------------
+
+ public function test_parse()
+ {
+ $this->_parse_no_template();
+ $this->_parse_var_pair();
+ $this->_mismatched_var_pair();
+ }
+
+ // --------------------------------------------------------------------
+
+ private function _parse_no_template()
+ {
+ $this->assertFalse($this->parser->parse_string('', '', TRUE));
+ }
+
+ // --------------------------------------------------------------------
+
+ private function _parse_var_pair()
+ {
+ $data = array(
+ 'title' => 'Super Heroes',
+ 'powers' => array(
+ array(
+ 'invisibility' => 'yes',
+ 'flying' => 'no'),
+ )
+ );
+
+ $template = "{title}\n{powers}{invisibility}\n{flying}{/powers}";
+
+ $result = "Super Heroes\nyes\nno";
+
+ $this->assertEquals($result, $this->parser->parse_string($template, $data, TRUE));
+ }
+
+ // --------------------------------------------------------------------
+
+ private function _mismatched_var_pair()
+ {
+ $data = array(
+ 'title' => 'Super Heroes',
+ 'powers' => array(
+ array(
+ 'invisibility' => 'yes',
+ 'flying' => 'no'),
+ )
+ );
+
+ $template = "{title}\n{powers}{invisibility}\n{flying}";
+
+ $result = "Super Heroes\n{powers}{invisibility}\n{flying}";
+
+ $this->assertEquals($result, $this->parser->parse_string($template, $data, TRUE));
+ }
+
+ // --------------------------------------------------------------------
+} \ No newline at end of file
diff --git a/tests/codeigniter/libraries/Table_test.php b/tests/codeigniter/libraries/Table_test.php
new file mode 100644
index 000000000..13f338c6b
--- /dev/null
+++ b/tests/codeigniter/libraries/Table_test.php
@@ -0,0 +1,296 @@
+<?php
+
+class Table_test extends CI_TestCase {
+
+ public function set_up()
+ {
+ $obj = new StdClass;
+ $obj->table = new Mock_Libraries_Table();
+
+ $this->ci_instance($obj);
+
+ $this->table = $obj->table;
+ }
+
+
+ // Setter Methods
+ // --------------------------------------------------------------------
+
+ public function test_set_template()
+ {
+ $this->assertFalse($this->table->set_template('not an array'));
+
+ $template = array(
+ 'a' => 'b'
+ );
+
+ $this->table->set_template($template);
+ $this->assertEquals($template, $this->table->template);
+ }
+
+ public function test_set_empty()
+ {
+ $this->table->set_empty('nada');
+ $this->assertEquals('nada', $this->table->empty_cells);
+ }
+
+ public function test_set_caption()
+ {
+ $this->table->set_caption('awesome cap');
+ $this->assertEquals('awesome cap', $this->table->caption);
+ }
+
+
+ /*
+ * @depends testPrepArgs
+ */
+ public function test_set_heading()
+ {
+ // uses _prep_args internally, so we'll just do a quick
+ // check to verify that func_get_args and prep_args are
+ // being called.
+
+ $this->table->set_heading('name', 'color', 'size');
+
+ $this->assertEquals(
+ array(
+ array('data' => 'name'),
+ array('data' => 'color'),
+ array('data' => 'size')
+ ),
+ $this->table->heading
+ );
+ }
+
+
+ /*
+ * @depends testPrepArgs
+ */
+ public function test_add_row()
+ {
+ // uses _prep_args internally, so we'll just do a quick
+ // check to verify that func_get_args and prep_args are
+ // being called.
+
+ $this->table->add_row('my', 'pony', 'sings');
+ $this->table->add_row('your', 'pony', 'stinks');
+ $this->table->add_row('my pony', '>', 'your pony');
+
+ $this->assertEquals(count($this->table->rows), 3);
+
+ $this->assertEquals(
+ array(
+ array('data' => 'your'),
+ array('data' => 'pony'),
+ array('data' => 'stinks')
+ ),
+ $this->table->rows[1]
+ );
+ }
+
+
+ // Uility Methods
+ // --------------------------------------------------------------------
+
+ public function test_prep_args()
+ {
+ $expected = array(
+ array('data' => 'name'),
+ array('data' => 'color'),
+ array('data' => 'size')
+ );
+
+ $this->assertEquals(
+ $expected,
+ $this->table->prep_args(array('name', 'color', 'size'))
+ );
+
+ // with cell attributes
+ // need to add that new argument row to our expected outcome
+ $expected[] = array('data' => 'weight', 'class' => 'awesome');
+
+ $this->assertEquals(
+ $expected,
+ $this->table->prep_args(array('name', 'color', 'size', array('data' => 'weight', 'class' => 'awesome')))
+ );
+ }
+
+ public function test_default_template_keys()
+ {
+ $keys = array(
+ 'table_open',
+ 'thead_open', 'thead_close',
+ 'heading_row_start', 'heading_row_end', 'heading_cell_start', 'heading_cell_end',
+ 'tbody_open', 'tbody_close',
+ 'row_start', 'row_end', 'cell_start', 'cell_end',
+ 'row_alt_start', 'row_alt_end', 'cell_alt_start', 'cell_alt_end',
+ 'table_close'
+ );
+
+ foreach ($keys as $key)
+ {
+ $this->assertArrayHasKey($key, $this->table->default_template());
+ }
+ }
+
+ public function test_compile_template()
+ {
+ $this->assertFalse($this->table->set_template('invalid_junk'));
+
+ // non default key
+ $this->table->set_template(array('nonsense' => 'foo'));
+ $this->table->compile_template();
+
+ $this->assertArrayHasKey('nonsense', $this->table->template);
+ $this->assertEquals('foo', $this->table->template['nonsense']);
+
+ // override default
+ $this->table->set_template(array('table_close' => '</table junk>'));
+ $this->table->compile_template();
+
+ $this->assertArrayHasKey('table_close', $this->table->template);
+ $this->assertEquals('</table junk>', $this->table->template['table_close']);
+ }
+
+ public function test_make_columns()
+ {
+ // Test bogus parameters
+ $this->assertFalse($this->table->make_columns('invalid_junk'));
+ $this->assertFalse($this->table->make_columns(array()));
+ $this->assertFalse($this->table->make_columns(array('one', 'two'), '2.5'));
+
+
+ // Now on to the actual column creation
+
+ $five_values = array(
+ 'Laura', 'Red', '15',
+ 'Katie', 'Blue'
+ );
+
+ // No column count - no changes to the array
+ $this->assertEquals(
+ $five_values,
+ $this->table->make_columns($five_values)
+ );
+
+ // Column count of 3 leaves us with one &nbsp;
+ $this->assertEquals(
+ array(
+ array('Laura', 'Red', '15'),
+ array('Katie', 'Blue', '&nbsp;')
+ ),
+ $this->table->make_columns($five_values, 3)
+ );
+ }
+
+ public function test_clear()
+ {
+ $this->table->set_heading('Name', 'Color', 'Size');
+
+ // Make columns changes auto_heading
+ $rows = $this->table->make_columns(array(
+ 'Laura', 'Red', '15',
+ 'Katie', 'Blue'
+ ), 3);
+
+ foreach ($rows as $row)
+ {
+ $this->table->add_row($row);
+ }
+
+ $this->assertFalse($this->table->auto_heading);
+ $this->assertEquals(count($this->table->heading), 3);
+ $this->assertEquals(count($this->table->rows), 2);
+
+ $this->table->clear();
+
+ $this->assertTrue($this->table->auto_heading);
+ $this->assertEmpty($this->table->heading);
+ $this->assertEmpty($this->table->rows);
+ }
+
+
+ public function test_set_from_array()
+ {
+ $this->assertFalse($this->table->set_from_array('bogus'));
+ $this->assertFalse($this->table->set_from_array(NULL));
+
+ $data = array(
+ array('name', 'color', 'number'),
+ array('Laura', 'Red', '22'),
+ array('Katie', 'Blue')
+ );
+
+ $this->table->set_from_array($data, FALSE);
+ $this->assertEmpty($this->table->heading);
+
+ $this->table->clear();
+
+ $expected_heading = array(
+ array('data' => 'name'),
+ array('data' => 'color'),
+ array('data' => 'number')
+ );
+
+ $expected_second = array(
+ array('data' => 'Katie'),
+ array('data' => 'Blue'),
+ );
+
+ $this->table->set_from_array($data);
+ $this->assertEquals(count($this->table->rows), 2);
+
+ $this->assertEquals(
+ $expected_heading,
+ $this->table->heading
+ );
+
+ $this->assertEquals(
+ $expected_second,
+ $this->table->rows[1]
+ );
+ }
+
+ function test_set_from_object()
+ {
+ // Make a stub of query instance
+ $query = new CI_TestCase();
+ $query->list_fields = function(){
+ return array('name', 'email');
+ };
+ $query->result_array = function(){
+ return array(
+ array('name' => 'John Doe', 'email' => 'john@doe.com'),
+ array('name' => 'Foo Bar', 'email' => 'foo@bar.com'),
+ );
+ };
+ $query->num_rows = function(){
+ return 2;
+ };
+
+ $expected_heading = array(
+ array('data' => 'name'),
+ array('data' => 'email')
+ );
+
+ $expected_second = array(
+ 'name' => array('data' => 'Foo Bar'),
+ 'email' => array('data' => 'foo@bar.com'),
+ );
+
+ $this->table->set_from_object($query);
+
+ $this->assertEquals(
+ $expected_heading,
+ $this->table->heading
+ );
+
+ $this->assertEquals(
+ $expected_second,
+ $this->table->rows[1]
+ );
+ }
+
+ // Test main generate method
+ // --------------------------------------------------------------------
+} \ No newline at end of file
diff --git a/tests/codeigniter/libraries/Typography_test.php b/tests/codeigniter/libraries/Typography_test.php
new file mode 100644
index 000000000..250aefb24
--- /dev/null
+++ b/tests/codeigniter/libraries/Typography_test.php
@@ -0,0 +1,188 @@
+<?php
+
+class Typography_test extends CI_TestCase {
+
+ public function set_up()
+ {
+ $obj = new StdClass;
+ $obj->type = new Mock_Libraries_Typography();
+
+ $this->ci_instance($obj);
+
+ $this->type = $obj->type;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Tests the format_characters() function.
+ *
+ * this can and should grow.
+ */
+ public function test_format_characters()
+ {
+ $strs = array(
+ '"double quotes"' => '&#8220;double quotes&#8221;',
+ '"testing" in "theory" that is' => '&#8220;testing&#8221; in &#8220;theory&#8221; that is',
+ "Here's what I'm" => 'Here&#8217;s what I&#8217;m',
+ '&' => '&amp;',
+ '&amp;' => '&amp;',
+ '&nbsp;' => '&nbsp;',
+ '--' => '&#8212;',
+ 'foo...' => 'foo&#8230;',
+ 'foo..' => 'foo..',
+ 'foo...bar.' => 'foo&#8230;bar.',
+ 'test. new' => 'test.&nbsp; new',
+ );
+
+ foreach ($strs as $str => $expected)
+ {
+ $this->assertEquals($expected, $this->type->format_characters($str));
+ }
+ }
+
+ // --------------------------------------------------------------------
+
+ public function test_nl2br_except_pre()
+ {
+ $str = <<<EOH
+Hello, I'm a happy string with some new lines.
+
+I like to skip.
+
+Jump
+
+and sing.
+
+<pre>
+I am inside a pre tag. Please don't mess with me.
+
+k?
+</pre>
+
+That's my story and I'm sticking to it.
+
+The End.
+EOH;
+
+ $expected = <<<EOH
+Hello, I'm a happy string with some new lines. <br />
+<br />
+I like to skip.<br />
+<br />
+Jump<br />
+<br />
+and sing.<br />
+<br />
+<pre>
+I am inside a pre tag. Please don't mess with me.
+
+k?
+</pre><br />
+<br />
+That's my story and I'm sticking to it.<br />
+<br />
+The End.
+EOH;
+
+ $this->assertEquals($expected,
+ $this->type->nl2br_except_pre($str));
+ }
+
+ // --------------------------------------------------------------------
+
+ public function test_auto_typography()
+ {
+ $this->_blank_string();
+ $this->_standardize_new_lines();
+ $this->_reduce_linebreaks();
+ $this->_remove_comments();
+ $this->_protect_pre();
+ $this->_no_opening_block();
+ $this->_protect_braced_quotes();
+ }
+
+ // --------------------------------------------------------------------
+
+ private function _blank_string()
+ {
+ // Test blank string
+ $this->assertEquals('', $this->type->auto_typography(''));
+ }
+
+ // --------------------------------------------------------------------
+
+ private function _standardize_new_lines()
+ {
+ $strs = array(
+ "My string\rhas return characters" => "<p>My string<br />\nhas return characters</p>",
+ 'This one does not!' => '<p>This one does not!</p>'
+ );
+
+ foreach ($strs as $str => $expect)
+ {
+ $this->assertEquals($expect, $this->type->auto_typography($str));
+ }
+ }
+
+ // --------------------------------------------------------------------
+
+ private function _reduce_linebreaks()
+ {
+ $str = "This has way too many linebreaks.\n\n\n\nSee?";
+ $expect = "<p>This has way too many linebreaks.</p>\n\n<p>See?</p>";
+
+ $this->assertEquals($expect, $this->type->auto_typography($str, TRUE));
+ }
+
+ // --------------------------------------------------------------------
+
+ private function _remove_comments()
+ {
+ $str = '<!-- I can haz comments? --> But no!';
+ $expect = '<p><!-- I can haz comments? -->&nbsp; But no!</p>';
+
+ $this->assertEquals($expect, $this->type->auto_typography($str));
+ }
+
+ // --------------------------------------------------------------------
+
+ private function _protect_pre()
+ {
+ $str = '<p>My Sentence</p><pre>var_dump($this);</pre>';
+ $expect = '<p>My Sentence</p><pre>var_dump($this);</pre>';
+
+ $this->assertEquals($expect, $this->type->auto_typography($str));
+ }
+
+ // --------------------------------------------------------------------
+
+ private function _no_opening_block()
+ {
+ $str = 'My Sentence<pre>var_dump($this);</pre>';
+ $expect = '<p>My Sentence</p><pre>var_dump($this);</pre>';
+
+ $this->assertEquals($expect, $this->type->auto_typography($str));
+ }
+
+ // --------------------------------------------------------------------
+
+ public function _protect_braced_quotes()
+ {
+ $this->type->protect_braced_quotes = TRUE;
+
+ $str = 'Test {parse="foobar"}';
+ $expect = '<p>Test {parse="foobar"}</p>';
+
+ $this->assertEquals($expect, $this->type->auto_typography($str));
+
+ $this->type->protect_braced_quotes = FALSE;
+
+ $str = 'Test {parse="foobar"}';
+ $expect = '<p>Test {parse=&#8220;foobar&#8221;}</p>';
+
+ $this->assertEquals($expect, $this->type->auto_typography($str));
+
+
+ }
+} \ No newline at end of file
diff --git a/tests/codeigniter/libraries/Useragent_test.php b/tests/codeigniter/libraries/Useragent_test.php
new file mode 100644
index 000000000..7dad7ac54
--- /dev/null
+++ b/tests/codeigniter/libraries/Useragent_test.php
@@ -0,0 +1,87 @@
+<?php
+
+class UserAgent_test extends CI_TestCase {
+
+ protected $_user_agent = 'Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_7; en-us) AppleWebKit/533.20.25 (KHTML, like Gecko) Version/5.0.4 Safari/533.20.27';
+ protected $_mobile_ua = 'Mozilla/5.0 (iPhone; U; CPU iPhone OS 4_1 like Mac OS X; en-us) AppleWebKit/532.9 (KHTML, like Gecko) Version/4.0.5 Mobile/8B117 Safari/6531.22.7';
+
+ public function set_up()
+ {
+ // set a baseline user agent
+ $_SERVER['HTTP_USER_AGENT'] = $this->_user_agent;
+
+ $obj = new StdClass;
+ $obj->agent = new Mock_Libraries_UserAgent();
+
+ $this->ci_instance($obj);
+
+ $this->agent = $obj->agent;
+ }
+
+ // --------------------------------------------------------------------
+
+ public function test_accept_lang()
+ {
+ $_SERVER['HTTP_ACCEPT_LANGUAGE'] = 'en';
+ $this->assertTrue($this->agent->accept_lang());
+ unset($_SERVER['HTTP_ACCEPT_LANGUAGE']);
+ $this->assertTrue($this->agent->accept_lang('en'));
+ $this->assertFalse($this->agent->accept_lang('fr'));
+ }
+
+ // --------------------------------------------------------------------
+
+ public function test_mobile()
+ {
+ // Mobile Not Set
+ $_SERVER['HTTP_USER_AGENT'] = $this->_mobile_ua;
+ $this->assertEquals('', $this->agent->mobile());
+ unset($_SERVER['HTTP_USER_AGENT']);
+ }
+
+ // --------------------------------------------------------------------
+
+ public function test_util_is_functions()
+ {
+ $this->assertTrue($this->agent->is_browser());
+ $this->assertFalse($this->agent->is_robot());
+ $this->assertFalse($this->agent->is_mobile());
+ $this->assertFalse($this->agent->is_referral());
+ }
+
+ // --------------------------------------------------------------------
+
+ public function test_agent_string()
+ {
+ $this->assertEquals($this->_user_agent, $this->agent->agent_string());
+ }
+
+ // --------------------------------------------------------------------
+
+ public function test_browser_info()
+ {
+ $this->assertEquals('Mac OS X', $this->agent->platform());
+ $this->assertEquals('Safari', $this->agent->browser());
+ $this->assertEquals('533.20.27', $this->agent->version());
+ $this->assertEquals('', $this->agent->robot());
+ $this->assertEquals('', $this->agent->referrer());
+ }
+
+ // --------------------------------------------------------------------
+
+ public function test_charsets()
+ {
+ $_SERVER['HTTP_ACCEPT_CHARSET'] = 'utf8';
+
+ $charsets = $this->agent->charsets();
+
+ $this->assertEquals('utf8', $charsets[0]);
+
+ unset($_SERVER['HTTP_ACCEPT_CHARSET']);
+
+ $this->assertFalse($this->agent->accept_charset());
+ }
+
+ // --------------------------------------------------------------------
+
+} \ No newline at end of file
diff --git a/tests/mocks/autoloader.php b/tests/mocks/autoloader.php
new file mode 100644
index 000000000..dd5929206
--- /dev/null
+++ b/tests/mocks/autoloader.php
@@ -0,0 +1,79 @@
+<?php
+
+// This autoloader provide convinient way to working with mock object
+// make the test looks natural. This autoloader support cascade file loading as well
+// within mocks directory.
+//
+// Prototype :
+//
+// include_once('Mock_Core_Loader') // Will load ./mocks/core/loader.php
+// $mock_table = new Mock_Libraries_Table(); // Will load ./mocks/libraries/table.php
+// $mock_database_driver = new Mock_Database_Driver(); // Will load ./mocks/database/driver.php
+// and so on...
+function autoload($class)
+{
+ $dir = realpath(dirname(__FILE__)).DIRECTORY_SEPARATOR;
+
+ $ci_core = array(
+ 'Benchmark', 'Config', 'Controller',
+ 'Exceptions', 'Hooks', 'Input',
+ 'Lang', 'Loader', 'Model',
+ 'Output', 'Router', 'Security',
+ 'URI', 'Utf8',
+ );
+
+ $ci_libraries = array(
+ 'Calendar', 'Cart', 'Driver',
+ 'Email', 'Encrypt', 'Form_validation',
+ 'Ftp', 'Image_lib', 'Javascript',
+ 'Log', 'Migration', 'Pagination',
+ 'Parser', 'Profiler', 'Session',
+ 'Table', 'Trackback', 'Typography',
+ 'Unit_test', 'Upload', 'User_agent',
+ 'Xmlrpc', 'Zip',
+ );
+
+ if (strpos($class, 'Mock_') === 0)
+ {
+ $class = str_replace(array('Mock_', '_'), array('', DIRECTORY_SEPARATOR), $class);
+ $class = strtolower($class);
+ }
+ elseif (strpos($class, 'CI_') === 0)
+ {
+ $fragments = explode('_', $class, 2);
+ $subclass = next($fragments);
+
+ if (in_array($subclass, $ci_core))
+ {
+ $dir = BASEPATH.'core'.DIRECTORY_SEPARATOR;
+ $class = $subclass;
+ }
+ elseif (in_array($subclass, $ci_libraries))
+ {
+ $dir = BASEPATH.'libraries'.DIRECTORY_SEPARATOR;
+ $class = $subclass;
+ }
+ else
+ {
+ $class = strtolower($class);
+ }
+ }
+
+ $file = $dir.$class.'.php';
+
+ if ( ! file_exists($file))
+ {
+ $trace = debug_backtrace();
+
+ // If the autoload call came from `class_exists` or `file_exists`,
+ // we skipped and return FALSE
+ if ($trace[2]['function'] == 'class_exists' OR $trace[2]['function'] == 'file_exists')
+ {
+ return FALSE;
+ }
+
+ throw new InvalidArgumentException("Unable to load $class.");
+ }
+
+ include_once($file);
+} \ No newline at end of file
diff --git a/tests/mocks/ci_testcase.php b/tests/mocks/ci_testcase.php
new file mode 100644
index 000000000..f327e6b07
--- /dev/null
+++ b/tests/mocks/ci_testcase.php
@@ -0,0 +1,196 @@
+<?php
+
+class CI_TestCase extends PHPUnit_Framework_TestCase {
+
+ protected $ci_config;
+ protected $ci_instance;
+ protected static $ci_test_instance;
+
+ private $global_map = array(
+ 'benchmark' => 'bm',
+ 'config' => 'cfg',
+ 'hooks' => 'ext',
+ 'utf8' => 'uni',
+ 'router' => 'rtr',
+ 'output' => 'out',
+ 'security' => 'sec',
+ 'input' => 'in',
+ 'lang' => 'lang',
+ 'loader' => 'load',
+ 'model' => 'model'
+ );
+
+ // --------------------------------------------------------------------
+
+ public function __construct()
+ {
+ parent::__construct();
+
+ $this->ci_config = array();
+ }
+
+ // --------------------------------------------------------------------
+
+ public function setUp()
+ {
+ if (method_exists($this, 'set_up'))
+ {
+ $this->set_up();
+ }
+ }
+
+ // --------------------------------------------------------------------
+
+ public function tearDown()
+ {
+ if (method_exists($this, 'tear_down'))
+ {
+ $this->tear_down();
+ }
+ }
+
+ // --------------------------------------------------------------------
+
+ public static function instance()
+ {
+ return self::$ci_test_instance;
+ }
+
+ // --------------------------------------------------------------------
+
+ function ci_set_config($key, $val = '')
+ {
+ if (is_array($key))
+ {
+ $this->ci_config = $key;
+ }
+ else
+ {
+ $this->ci_config[$key] = $val;
+ }
+ }
+
+ // --------------------------------------------------------------------
+
+ function ci_get_config()
+ {
+ return $this->ci_config;
+ }
+
+ // --------------------------------------------------------------------
+
+ function ci_instance($obj = FALSE)
+ {
+ if ( ! is_object($obj))
+ {
+ return $this->ci_instance;
+ }
+
+ $this->ci_instance = $obj;
+ }
+
+ // --------------------------------------------------------------------
+
+ function ci_instance_var($name, $obj = FALSE)
+ {
+ if ( ! is_object($obj))
+ {
+ return $this->ci_instance->$name;
+ }
+
+ $this->ci_instance->$name =& $obj;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Grab a core class
+ *
+ * Loads the correct core class without extensions
+ * and returns a reference to the class name in the
+ * globals array with the correct key. This way the
+ * test can modify the variable it assigns to and
+ * still maintain the global.
+ */
+ function &ci_core_class($name)
+ {
+ $name = strtolower($name);
+
+ if (isset($this->global_map[$name]))
+ {
+ $class_name = ucfirst($name);
+ $global_name = $this->global_map[$name];
+ }
+ elseif (in_array($name, $this->global_map))
+ {
+ $class_name = ucfirst(array_search($name, $this->global_map));
+ $global_name = $name;
+ }
+ else
+ {
+ throw new Exception('Not a valid core class.');
+ }
+
+ if ( ! class_exists('CI_'.$class_name))
+ {
+ require_once BASEPATH.'core/'.$class_name.'.php';
+ }
+
+ $GLOBALS[strtoupper($global_name)] = 'CI_'.$class_name;
+ return $GLOBALS[strtoupper($global_name)];
+ }
+
+ // --------------------------------------------------------------------
+
+ // convenience function for global mocks
+ function ci_set_core_class($name, $obj)
+ {
+ $orig =& $this->ci_core_class($name);
+ $orig = $obj;
+ }
+
+ // --------------------------------------------------------------------
+ // Internals
+ // --------------------------------------------------------------------
+
+ /**
+ * Overwrite runBare
+ *
+ * PHPUnit instantiates the test classes before
+ * running them individually. So right before a test
+ * runs we set our instance. Normally this step would
+ * happen in setUp, but someone is bound to forget to
+ * call the parent method and debugging this is no fun.
+ */
+ public function runBare()
+ {
+ self::$ci_test_instance = $this;
+ parent::runBare();
+ }
+
+ // --------------------------------------------------------------------
+
+ function helper($name)
+ {
+ require_once(BASEPATH.'helpers/'.$name.'_helper.php');
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * This overload is useful to create a stub, that need to have a specific method.
+ */
+ function __call($method, $args)
+ {
+ if ($this->{$method} instanceof Closure)
+ {
+ return call_user_func_array($this->{$method},$args);
+ }
+ else
+ {
+ return parent::__call($method, $args);
+ }
+ }
+}
+
+// EOF \ No newline at end of file
diff --git a/tests/mocks/core/common.php b/tests/mocks/core/common.php
new file mode 100644
index 000000000..fc94d7fff
--- /dev/null
+++ b/tests/mocks/core/common.php
@@ -0,0 +1,132 @@
+<?php
+
+// Set up the global CI functions in their most minimal core representation
+
+function &get_instance()
+{
+ $test = CI_TestCase::instance();
+ $instance = $test->ci_instance();
+ return $instance;
+}
+
+// --------------------------------------------------------------------
+
+function &get_config() {
+ $test = CI_TestCase::instance();
+ $config = $test->ci_get_config();
+
+ return $config;
+}
+
+function config_item($item)
+{
+ $config =& get_config();
+
+ if ( ! isset($config[$item]))
+ {
+ return FALSE;
+ }
+
+ return $config[$item];
+}
+
+// --------------------------------------------------------------------
+
+function load_class($class, $directory = 'libraries', $prefix = 'CI_')
+{
+ if ($directory != 'core' OR $prefix != 'CI_')
+ {
+ throw new Exception('Not Implemented: Non-core load_class()');
+ }
+
+ $test = CI_TestCase::instance();
+
+ $obj =& $test->ci_core_class($class);
+
+ if (is_string($obj))
+ {
+ throw new Exception('Bad Isolation: Use ci_set_core_class to set '.$class.'');
+ }
+
+ return $obj;
+}
+
+// This is sort of meh. Should probably be mocked up with
+// controllable output, so that we can test some of our
+// security code. The function itself will be tested in the
+// bootstrap testsuite.
+// --------------------------------------------------------------------
+
+function remove_invisible_characters($str, $url_encoded = TRUE)
+{
+ $non_displayables = array();
+
+ // every control character except newline (dec 10)
+ // carriage return (dec 13), and horizontal tab (dec 09)
+
+ if ($url_encoded)
+ {
+ $non_displayables[] = '/%0[0-8bcef]/'; // url encoded 00-08, 11, 12, 14, 15
+ $non_displayables[] = '/%1[0-9a-f]/'; // url encoded 16-31
+ }
+
+ $non_displayables[] = '/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F]+/S'; // 00-08, 11, 12, 14-31, 127
+
+ do
+ {
+ $str = preg_replace($non_displayables, '', $str, -1, $count);
+ }
+ while ($count);
+
+ return $str;
+}
+
+
+// Clean up error messages
+// --------------------------------------------------------------------
+
+function show_error($message, $status_code = 500, $heading = 'An Error Was Encountered')
+{
+ throw new RuntimeException('CI Error: '.$message);
+}
+
+function show_404($page = '', $log_error = TRUE)
+{
+ throw new RuntimeException('CI Error: 404');
+}
+
+function _exception_handler($severity, $message, $filepath, $line)
+{
+ throw new RuntimeException('CI Exception: '.$message.' | '.$filepath.' | '.$line);
+}
+
+
+// We assume a few things about our environment ...
+// --------------------------------------------------------------------
+
+function is_php($version = '5.0.0')
+{
+ return ! (version_compare(PHP_VERSION, $version) < 0);
+}
+
+function is_really_writable($file)
+{
+ return is_writable($file);
+}
+
+function is_loaded()
+{
+ throw new Exception('Bad Isolation: mock up environment');
+}
+
+function log_message($level = 'error', $message, $php_error = FALSE)
+{
+ return TRUE;
+}
+
+function set_status_header($code = 200, $text = '')
+{
+ return TRUE;
+}
+
+// EOF \ No newline at end of file
diff --git a/tests/mocks/core/loader.php b/tests/mocks/core/loader.php
new file mode 100644
index 000000000..d4b29bb3d
--- /dev/null
+++ b/tests/mocks/core/loader.php
@@ -0,0 +1,30 @@
+<?php
+
+class Mock_Core_Loader extends CI_Loader {
+
+ /**
+ * Since we use paths to load up models, views, etc, we need the ability to
+ * mock up the file system so when core tests are run, we aren't mucking
+ * in the application directory. this will give finer grained control over
+ * these tests. So yeah, while this looks odd, I need to overwrite protected
+ * class vars in the loader. So here we go...
+ *
+ * @covers CI_Loader::__construct()
+ */
+ public function __construct()
+ {
+ vfsStreamWrapper::register();
+ vfsStreamWrapper::setRoot(new vfsStreamDirectory('application'));
+
+ $this->models_dir = vfsStream::newDirectory('models')->at(vfsStreamWrapper::getRoot());
+ $this->libs_dir = vfsStream::newDirectory('libraries')->at(vfsStreamWrapper::getRoot());
+ $this->helpers_dir = vfsStream::newDirectory('helpers')->at(vfsStreamWrapper::getRoot());
+ $this->views_dir = vfsStream::newDirectory('views')->at(vfsStreamWrapper::getRoot());
+
+ $this->_ci_ob_level = ob_get_level();
+ $this->_ci_library_paths = array(vfsStream::url('application').'/', BASEPATH);
+ $this->_ci_helper_paths = array(vfsStream::url('application').'/', BASEPATH);
+ $this->_ci_model_paths = array(vfsStream::url('application').'/');
+ $this->_ci_view_paths = array(vfsStream::url('application').'/views/' => TRUE);
+ }
+} \ No newline at end of file
diff --git a/tests/mocks/core/uri.php b/tests/mocks/core/uri.php
new file mode 100644
index 000000000..b6946091e
--- /dev/null
+++ b/tests/mocks/core/uri.php
@@ -0,0 +1,25 @@
+<?php
+
+class Mock_Core_URI extends CI_URI {
+
+ public function __construct()
+ {
+ $test = CI_TestCase::instance();
+ $cls =& $test->ci_core_class('cfg');
+
+ // set predictable config values
+ $test->ci_set_config(array(
+ 'index_page' => 'index.php',
+ 'base_url' => 'http://example.com/',
+ 'subclass_prefix' => 'MY_'
+ ));
+
+ $this->config = new $cls;
+
+ }
+
+ protected function _is_cli_request()
+ {
+ return FALSE;
+ }
+} \ No newline at end of file
diff --git a/tests/mocks/database/.gitkeep b/tests/mocks/database/.gitkeep
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/tests/mocks/database/.gitkeep
diff --git a/tests/mocks/libraries/parser.php b/tests/mocks/libraries/parser.php
new file mode 100644
index 000000000..81dcfb37e
--- /dev/null
+++ b/tests/mocks/libraries/parser.php
@@ -0,0 +1,3 @@
+<?php
+
+class Mock_Libraries_Parser extends CI_Parser {} \ No newline at end of file
diff --git a/tests/mocks/libraries/table.php b/tests/mocks/libraries/table.php
new file mode 100644
index 000000000..1a6ff8d35
--- /dev/null
+++ b/tests/mocks/libraries/table.php
@@ -0,0 +1,15 @@
+<?php
+
+class Mock_Libraries_Table extends CI_Table {
+
+ // Overide inaccesible private or protected method
+ public function __call($method, $params)
+ {
+ if (is_callable(array($this, '_'.$method)))
+ {
+ return call_user_func_array(array($this, '_'.$method), $params);
+ }
+
+ throw new BadMethodCallException('Method '.$method.' was not found');
+ }
+} \ No newline at end of file
diff --git a/tests/mocks/libraries/typography.php b/tests/mocks/libraries/typography.php
new file mode 100644
index 000000000..0f76c5745
--- /dev/null
+++ b/tests/mocks/libraries/typography.php
@@ -0,0 +1,3 @@
+<?php
+
+class Mock_Libraries_Typography extends CI_Typography {} \ No newline at end of file
diff --git a/tests/mocks/libraries/useragent.php b/tests/mocks/libraries/useragent.php
new file mode 100644
index 000000000..c957cde5b
--- /dev/null
+++ b/tests/mocks/libraries/useragent.php
@@ -0,0 +1,3 @@
+<?php
+
+class Mock_Libraries_UserAgent extends CI_User_agent {} \ No newline at end of file
diff --git a/tests/phpunit.xml b/tests/phpunit.xml
new file mode 100644
index 000000000..dfeecd19f
--- /dev/null
+++ b/tests/phpunit.xml
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<phpunit
+ bootstrap="Bootstrap.php"
+ colors="true"
+ convertNoticesToExceptions="true"
+ convertWarningsToExceptions="true"
+ stopOnError="false"
+ stopOnFailure="false"
+ stopOnIncomplete="false"
+ stopOnSkipped="false">
+ <testsuites>
+ <testsuite name="CodeIgniter Core Test Suite">
+ <file>./codeigniter/Setup_test.php</file>
+ <directory suffix="test.php">codeigniter/core</directory>
+ <directory suffix="test.php">codeigniter/helpers</directory>
+ <directory suffix="test.php">codeigniter/libraries</directory>
+ <!-- We'll worry about these later ...
+ <directory suffix="test.php">codeigniter/libraries</directory>
+ <directory suffix="test.php">codeigniter/helpers</directory>
+ -->
+ </testsuite>
+ </testsuites>
+ <filters>
+ <blacklist>
+ <directory suffix=".php">PEAR_INSTALL_DIR</directory>
+ <directory suffix=".php">PHP_LIBDIR</directory>
+ <directory suffix=".php">PROJECT_BASE.'tests'</directory>
+ <directory suffix=".php">'../system/core/CodeIgniter.php'</directory>
+ </blacklist>
+ <whitelist>
+ <!--
+ <directory suffix=".php">'../system/core'</directory>
+ -->
+ </whitelist>
+ </filters>
+</phpunit> \ No newline at end of file
diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst
index 3dd5fca2a..52cd51603 100644
--- a/user_guide_src/source/changelog.rst
+++ b/user_guide_src/source/changelog.rst
@@ -35,6 +35,8 @@ Release Date: Not Released
- Removed previously deprecated SHA1 Library.
- Removed previously deprecated use of ``$autoload['core']`` in application/config/autoload.php.
Only entries in ``$autoload['libraries']`` are auto-loaded now.
+ - Added some more doctypes.
+ - Updated all classes to be written in PHP 5 style, with visibility declarations and no ``var`` usage for properties.
- Helpers
@@ -43,8 +45,11 @@ Release Date: Not Released
- Changed humanize to include a second param for the separator.
- Refactored ``plural()`` and ``singular()`` to avoid double pluralization and support more words.
- Added an optional third parameter to ``force_download()`` that enables/disables sending the actual file MIME type in the Content-Type header (disabled by default).
+ - Added an optional third parameter to ``timespan()`` that constrains the number of time units displayed.
- Added a work-around in force_download() for a bug Android <= 2.1, where the filename extension needs to be in uppercase.
- form_dropdown() will now also take an array for unity with other form helpers.
+ - set_realpath() can now also handle file paths as opposed to just directories.
+ - do_hash() now uses PHP's native hash() function, supporting more algorithms.
- Database
@@ -53,9 +58,11 @@ Release Date: Not Released
get_compiled_insert(), get_compiled_update(), get_compiled_delete().
- Taking care of LIKE condition when used with MySQL UPDATE statement.
- Adding $escape parameter to the order_by function, this enables ordering by custom fields.
- - MySQLi driver now uses mysqli_get_server_info() for server version checking.
- - MySQLi driver now supports persistent connections when running on PHP >= 5.3.
- - Added dsn if the group connections in the config use PDO or any driver which need DSN.
+ - Improved support for the MySQLi driver, including:
+ - OOP style of the PHP extension is now used, instead of the procedural aliases.
+ - Server version checking is now done via ``mysqli::$server_info`` instead of running an SQL query.
+ - Added persistent connections support for PHP >= 5.3.
+ - Added 'dsn' configuration setting for drivers that support DSN strings (PDO, PostgreSQL, Oracle, ODBC, CUBRID).
- Improved PDO database support.
- Added Interbase/Firebird database support via the "interbase" driver
- Added an optional database name parameter to db_select().
@@ -70,6 +77,11 @@ Release Date: Not Released
- Removed protect_identifiers() and renamed _protect_identifiers() to it instead - it was just an alias.
- MySQL and MySQLi drivers now require at least MySQL version 5.1.
- db_set_charset() now only requires one parameter (collation was only needed due to legacy support for MySQL versions prior to 5.1).
+ - Added DSN string support for CUBRID.
+ - Added persistent connections support for CUBRID.
+ - Added DSN string support (Easy Connect and TNS) for Oracle.
+ - Added random ordering support for MSSQL.
+ - Added random ordering support for SQLSRV.
- Libraries
@@ -90,6 +102,7 @@ Release Date: Not Released
- Minor speed optimizations and method & property visibility declarations in the Calendar Library.
- Removed SHA1 function in the :doc:`Encryption Library <libraries/encryption>`.
- Added $config['csrf_regeneration'] to the CSRF protection in the :doc:`Security library <libraries/security>`, which makes token regeneration optional.
+ - Added all_flashdata() method to session class. Returns an associative array of only flashdata.
- Allowed for setting table class defaults in a config file.
- Form Validation library now allows setting of error delimiters in the config file via $config['error_prefix'] and $config['error_suffix'].
- Added function error_array() to return all error messages as an array in the Form_validation class.
@@ -97,6 +110,7 @@ Release Date: Not Released
- Added function reset_validation() to form validation library, which resets internal validation variables in case of multiple validation routines.
- Changed the Session library to select only one row when using database sessions.
- Added a Wincache driver to the `Caching Library <libraries/caching>`.
+ - Added dsn (delivery status notification) option to the :doc:`Email Library <libraries/email>`.
- Core
@@ -107,6 +121,8 @@ Release Date: Not Released
- $config['rewrite_short_tags'] now has no effect when using PHP 5.4 as *<?=* will always be available.
- Added method() to CI_Input to retrieve $_SERVER['REQUEST_METHOD'].
- Modified valid_ip() to use PHP's filter_var() in the :doc:`Input Library <libraries/input>`.
+ - Added support for HTTP-Only cookies with new config option ``cookie_httponly`` (default FALSE).
+ - Renamed method _call_hook() to call_hook() in the :doc:`Hooks Library <general/hooks.html>`.
Bug fixes for 3.0
------------------
@@ -158,6 +174,8 @@ Bug fixes for 3.0
- Fixed a bug in the :doc:`Session Library <libraries/sessions>` where a PHP E_NOTICE error was triggered by _unserialize() due to results from databases such as MSSQL and Oracle being space-padded on the right.
- Fixed a bug (#501) - set_rules() to check if the request method is not 'POST' before aborting, instead of depending on count($_POST) in the :doc:`Form Validation Library <libraries/form_validation>`.
- Fixed a bug (#940) - csrf_verify() used to set the CSRF cookie while processing a POST request with no actual POST data, which resulted in validating a request that should be considered invalid.
+- Fixed a bug in PostgreSQL's escape_str() where it didn't properly escape LIKE wild characters.
+- Fixed a bug in the library loader where some PHP versions wouldn't execute the class constructor.
Version 2.1.1
=============
@@ -243,11 +261,9 @@ Release Date: November 14, 2011
override them.
- Removed CI_CORE boolean constant from CodeIgniter.php (no longer Reactor and Core versions).
-
Bug fixes for 2.1.0
-------------------
-
- Fixed #378 Robots identified as regular browsers by the User Agent
class.
- If a config class was loaded first then a library with the same name
@@ -1246,7 +1262,7 @@ Bug fixes for 1.6.3
- Added a language key for valid_emails in validation_lang.php.
- Amended fixes for bug (#3419) with parsing DSN database connections.
-- Moved the _has_operators() function (#4535) into DB_driver from
+- Moved the _has_operator() function (#4535) into DB_driver from
DB_active_rec.
- Fixed a syntax error in upload_lang.php.
- Fixed a bug (#4542) with a regular expression in the Image library.
diff --git a/user_guide_src/source/database/active_record.rst b/user_guide_src/source/database/active_record.rst
index c04e67d2a..e328c11e2 100644
--- a/user_guide_src/source/database/active_record.rst
+++ b/user_guide_src/source/database/active_record.rst
@@ -68,7 +68,7 @@ Example::
// Produces string: SELECT * FROM mytable
The second parameter enables you to set whether or not the active record query
-will be reset (by default it will be&mdash;just like `$this->db->get()`)::
+will be reset (by default it will be just like `$this->db->get()`)::
echo $this->db->limit(10,20)->get_compiled_select('mytable', FALSE);
// Produces string: SELECT * FROM mytable LIMIT 20, 10
@@ -533,7 +533,7 @@ Query grouping
**************
Query grouping allows you to create groups of WHERE clauses by enclosing them in parentheses. This will allow
-you to create queries with complex WHERE clauses. Nested groups are supported. Example:
+you to create queries with complex WHERE clauses. Nested groups are supported. Example::
$this->db->select('*')->from('my_table')
->group_start()
@@ -921,9 +921,9 @@ Method chaining allows you to simplify your syntax by connecting
multiple functions. Consider this example::
$query = $this->db->select('title')
- ->where('id', $id)
- ->limit(10, 20)
- ->get('mytable');
+ ->where('id', $id)
+ ->limit(10, 20)
+ ->get('mytable');
.. _ar-caching:
diff --git a/user_guide_src/source/database/utilities.rst b/user_guide_src/source/database/utilities.rst
index 3805ffb87..4e83929b2 100644
--- a/user_guide_src/source/database/utilities.rst
+++ b/user_guide_src/source/database/utilities.rst
@@ -117,7 +117,7 @@ query. Example::
echo $this->dbutil->csv_from_result($query);
The second, third, and fourth parameters allow you to set the delimiter
-newline, and enclosure characters respectively. By default tabs are
+newline, and enclosure characters respectively. By default commas are
used as the delimiter, "\n" is used as a new line, and a double-quote
is used as the enclosure. Example::
diff --git a/user_guide_src/source/general/styleguide.rst b/user_guide_src/source/general/styleguide.rst
index d8bdd0531..2b91d1cc0 100644
--- a/user_guide_src/source/general/styleguide.rst
+++ b/user_guide_src/source/general/styleguide.rst
@@ -94,7 +94,7 @@ overly long and verbose names.
class Super_class {
- function __construct()
+ public function __construct()
{
}
@@ -168,7 +168,6 @@ picked up by IDEs::
/**
* Encodes string for use in XML
*
- * @access public
* @param string
* @return string
*/
diff --git a/user_guide_src/source/general/views.rst b/user_guide_src/source/general/views.rst
index dc65f6c4f..9b7c9daaa 100644
--- a/user_guide_src/source/general/views.rst
+++ b/user_guide_src/source/general/views.rst
@@ -49,7 +49,7 @@ replace the echo statement with the view loading function::
<?php
class Blog extends CI_Controller {
- function index()
+ public function index()
{
$this->load->view('blogview');
}
@@ -74,14 +74,14 @@ might look something like this::
class Page extends CI_Controller {
- function index()
- {
- $data['page_title'] = 'Your title';
- $this->load->view('header');
- $this->load->view('menu');
- $this->load->view('content', $data);
- $this->load->view('footer');
- }
+ public function index()
+ {
+ $data['page_title'] = 'Your title';
+ $this->load->view('header');
+ $this->load->view('menu');
+ $this->load->view('content', $data);
+ $this->load->view('footer');
+ }
}
?>
@@ -126,7 +126,7 @@ Let's try it with your controller file. Open it add this code::
<?php
class Blog extends CI_Controller {
- function index()
+ public function index()
{
$data['title'] = "My Real Title";
$data['heading'] = "My Real Heading";
@@ -164,7 +164,7 @@ Here's a simple example. Add this to your controller::
<?php
class Blog extends CI_Controller {
- function index()
+ public function index()
{
$data['todo_list'] = array('Clean House', 'Call Mom', 'Run Errands');
diff --git a/user_guide_src/source/helpers/date_helper.rst b/user_guide_src/source/helpers/date_helper.rst
index ad06dd628..b21d147bd 100644
--- a/user_guide_src/source/helpers/date_helper.rst
+++ b/user_guide_src/source/helpers/date_helper.rst
@@ -255,14 +255,16 @@ Formats a unix timestamp so that is appears similar to this
The first parameter must contain a Unix timestamp. The second parameter
must contain a timestamp that is greater that the first timestamp. If
-the second parameter empty, the current time will be used. The most
-common purpose for this function is to show how much time has elapsed
-from some point in time in the past to now.
+the second parameter empty, the current time will be used. The third
+parameter is optional and limits the number of time units to display.
+The most common purpose for this function is to show how much time has
+elapsed from some point in time in the past to now.
-.. php:method:: timespan($seconds = 1, $time = '')
+.. php:method:: timespan($seconds = 1, $time = '', $units = '')
:param integer $seconds: a number of seconds
:param string $time: Unix timestamp
+ :param integer $units: a number of time units to display
:returns: string
Example
@@ -271,7 +273,8 @@ Example
$post_date = '1079621429';
$now = time();
- echo timespan($post_date, $now);
+ $units = 2;
+ echo timespan($post_date, $now, $units);
.. note:: The text generated by this function is found in the following language
file: language/<your_lang>/date_lang.php
diff --git a/user_guide_src/source/helpers/form_helper.rst b/user_guide_src/source/helpers/form_helper.rst
index 4cb0cfd38..a110f3c14 100644
--- a/user_guide_src/source/helpers/form_helper.rst
+++ b/user_guide_src/source/helpers/form_helper.rst
@@ -177,7 +177,7 @@ form to contain
/*
Would produce:
- <input type="text" name="username" id="username" value="johndoe" maxlength="100" size="50" style="width:50%" />
+ <input type="text" name="username" value="johndoe" id="username" maxlength="100" size="50" style="width:50%" />
*/
If you would like your form to contain some additional data, like
@@ -325,7 +325,7 @@ the tag. For example
$string = "</div></div>";
echo form_fieldset_close($string);
- // Would produce: </fieldset> </div></div>
+ // Would produce: </fieldset></div></div>
form_checkbox()
===============
diff --git a/user_guide_src/source/helpers/html_helper.rst b/user_guide_src/source/helpers/html_helper.rst
index 2e217898e..17c28cd2a 100644
--- a/user_guide_src/source/helpers/html_helper.rst
+++ b/user_guide_src/source/helpers/html_helper.rst
@@ -325,24 +325,44 @@ Strict is used by default, but many doctypes are available.
The following is a list of doctype choices. These are configurable, and
pulled from application/config/doctypes.php
-+------------------------+--------------------------+---------------------------------------------------------------------------------------------------------------------------+
-| Doctype | Option | Result |
-+========================+==========================+===========================================================================================================================+
-| XHTML 1.1 | doctype('xhtml11') | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> |
-+------------------------+--------------------------+---------------------------------------------------------------------------------------------------------------------------+
-| XHTML 1.0 Strict | doctype('xhtml1-strict') | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> |
-+------------------------+--------------------------+---------------------------------------------------------------------------------------------------------------------------+
-| XHTML 1.0 Transitional | doctype('xhtml1-trans') | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
-+------------------------+--------------------------+---------------------------------------------------------------------------------------------------------------------------+
-| XHTML 1.0 Frameset | doctype('xhtml1-frame') | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd"> |
-+------------------------+--------------------------+---------------------------------------------------------------------------------------------------------------------------+
-| XHTML Basic 1.1 | doctype('xhtml-basic11') | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML Basic 1.1//EN" "http://www.w3.org/TR/xhtml-basic/xhtml-basic11.dtd"> |
-+------------------------+--------------------------+---------------------------------------------------------------------------------------------------------------------------+
-| HTML 5 | doctype('html5') | <!DOCTYPE html> |
-+------------------------+--------------------------+---------------------------------------------------------------------------------------------------------------------------+
-| HTML 4 Strict | doctype('html4-strict') | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> |
-+------------------------+--------------------------+---------------------------------------------------------------------------------------------------------------------------+
-| HTML 4 Transitional | doctype('html4-trans') | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> |
-+------------------------+--------------------------+---------------------------------------------------------------------------------------------------------------------------+
-| HTML 4 Frameset | doctype('html4-frame') | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd"> |
-+------------------------+--------------------------+---------------------------------------------------------------------------------------------------------------------------+
++-------------------------------+------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------+
+| Doctype | Option | Result |
++===============================+==============================+==================================================================================================================================================+
+| XHTML 1.1 | doctype('xhtml11') | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> |
++-------------------------------+------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------+
+| XHTML 1.0 Strict | doctype('xhtml1-strict') | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> |
++-------------------------------+------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------+
+| XHTML 1.0 Transitional | doctype('xhtml1-trans') | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
++-------------------------------+------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------+
+| XHTML 1.0 Frameset | doctype('xhtml1-frame') | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd"> |
++-------------------------------+------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------+
+| XHTML Basic 1.1 | doctype('xhtml-basic11') | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML Basic 1.1//EN" "http://www.w3.org/TR/xhtml-basic/xhtml-basic11.dtd"> |
++-------------------------------+------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------+
+| HTML 5 | doctype('html5') | <!DOCTYPE html> |
++-------------------------------+------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------+
+| HTML 4 Strict | doctype('html4-strict') | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> |
++-------------------------------+------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------+
+| HTML 4 Transitional | doctype('html4-trans') | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> |
++-------------------------------+------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------+
+| HTML 4 Frameset | doctype('html4-frame') | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd"> |
++-------------------------------+------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------+
+| MathML 1.01 | doctype('mathml1') | <!DOCTYPE math SYSTEM "http://www.w3.org/Math/DTD/mathml1/mathml.dtd"> |
++-------------------------------+------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------+
+| MathML 2.0 | doctype('mathml2') | <!DOCTYPE math PUBLIC "-//W3C//DTD MathML 2.0//EN" "http://www.w3.org/Math/DTD/mathml2/mathml2.dtd"> |
++-------------------------------+------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------+
+| SVG 1.0 | doctype('svg10') | <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.0//EN" "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd"> |
++-------------------------------+------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------+
+| SVG 1.1 Full | doctype('svg11') | <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"> |
++-------------------------------+------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------+
+| SVG 1.1 Basic | doctype('svg11-basic') | <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1 Basic//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11-basic.dtd"> |
++-------------------------------+------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------+
+| SVG 1.1 Tiny | doctype('svg11-tiny') | <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1 Tiny//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11-tiny.dtd"> |
++-------------------------------+------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------+
+| XHTML+MathML+SVG (XHTML host) | doctype('xhtml-math-svg-xh') | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1 plus MathML 2.0 plus SVG 1.1//EN" "http://www.w3.org/2002/04/xhtml-math-svg/xhtml-math-svg.dtd"> |
++-------------------------------+------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------+
+| XHTML+MathML+SVG (SVG host) | doctype('xhtml-math-svg-sh') | <!DOCTYPE svg:svg PUBLIC "-//W3C//DTD XHTML 1.1 plus MathML 2.0 plus SVG 1.1//EN" "http://www.w3.org/2002/04/xhtml-math-svg/xhtml-math-svg.dtd"> |
++-------------------------------+------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------+
+| XHTML+RDFa 1.0 | doctype('xhtml-rdfa-1') | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML+RDFa 1.0//EN" "http://www.w3.org/MarkUp/DTD/xhtml-rdfa-1.dtd"> |
++-------------------------------+------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------+
+| XHTML+RDFa 1.1 | doctype('xhtml-rdfa-2') | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML+RDFa 1.1//EN" "http://www.w3.org/MarkUp/DTD/xhtml-rdfa-2.dtd"> |
++-------------------------------+------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------+ \ No newline at end of file
diff --git a/user_guide_src/source/helpers/path_helper.rst b/user_guide_src/source/helpers/path_helper.rst
index 1a70af458..847f5a08b 100644
--- a/user_guide_src/source/helpers/path_helper.rst
+++ b/user_guide_src/source/helpers/path_helper.rst
@@ -28,10 +28,16 @@ cannot be resolved.
::
- $directory = '/etc/passwd';
- echo set_realpath($directory); // returns "/etc/passwd"
- $non_existent_directory = '/path/to/nowhere';
- echo set_realpath($non_existent_directory, TRUE); // returns an error, as the path could not be resolved
- echo set_realpath($non_existent_directory, FALSE); // returns "/path/to/nowhere"
-
-
+ $file = '/etc/php5/apache2/php.ini';
+ echo set_realpath($file); // returns "/etc/php5/apache2/php.ini"
+
+ $non_existent_file = '/path/to/non-exist-file.txt';
+ echo set_realpath($non_existent_file, TRUE); // shows an error, as the path cannot be resolved
+ echo set_realpath($non_existent_file, FALSE); // returns "/path/to/non-exist-file.txt"
+
+ $directory = '/etc/php5';
+ echo set_realpath($directory); // returns "/etc/php5/"
+
+ $non_existent_directory = '/path/to/nowhere';
+ echo set_realpath($non_existent_directory, TRUE); // shows an error, as the path cannot be resolved
+ echo set_realpath($non_existent_directory, FALSE); // returns "/path/to/nowhere"
diff --git a/user_guide_src/source/helpers/security_helper.rst b/user_guide_src/source/helpers/security_helper.rst
index 01018c61a..b1bcf2b4a 100644
--- a/user_guide_src/source/helpers/security_helper.rst
+++ b/user_guide_src/source/helpers/security_helper.rst
@@ -34,8 +34,9 @@ More info can be found there.
do_hash()
=========
-Permits you to create SHA1 or MD5 one way hashes suitable for encrypting
-passwords. Will create SHA1 by default. Examples
+Permits you to create one way hashes suitable for encrypting
+passwords. Will create SHA1 by default. See `hash_algos() <http://php.net/function.hash_algos>`_
+for a full list of supported algorithms.
::
@@ -43,7 +44,7 @@ passwords. Will create SHA1 by default. Examples
$str = do_hash($str, 'md5'); // MD5
.. note:: This function was formerly named dohash(), which has been
- deprecated in favor of `do_hash()`.
+ removed in favor of `do_hash()`.
strip_image_tags()
==================
diff --git a/user_guide_src/source/helpers/string_helper.rst b/user_guide_src/source/helpers/string_helper.rst
index dc70e461a..2d23fb00c 100644
--- a/user_guide_src/source/helpers/string_helper.rst
+++ b/user_guide_src/source/helpers/string_helper.rst
@@ -108,6 +108,36 @@ found in http://. Example
$string = "http://example.com//index.php";
echo reduce_double_slashes($string); // results in "http://example.com/index.php"
+strip_slashes()
+===============
+
+Removes any slashes from a string. Example
+
+::
+
+ $str = "Is your name O\'reilly?";
+ echo strip_slashes($str); // results in Is your name O'reilly?
+
+You can also use an array. Example
+
+::
+
+ $str = array(
+ 'question'  => 'Is your name O\'reilly?',
+ 'answer' => 'No, my name is O\'connor.'
+ );
+
+ $str = strip_slashes($str);
+
+The above will return the following array:
+
+::
+
+ array(
+ 'question'  => "Is your name O'reilly?",
+ 'answer' => "No, my name is O'connor."
+ );
+
trim_slashes()
==============
diff --git a/user_guide_src/source/libraries/email.rst b/user_guide_src/source/libraries/email.rst
index 19c2706d9..daf000907 100644
--- a/user_guide_src/source/libraries/email.rst
+++ b/user_guide_src/source/libraries/email.rst
@@ -104,6 +104,7 @@ Preference Default Value Options Descript
**newline** \\n "\\r\\n" or "\\n" or "\\r" Newline character. (Use "\\r\\n" to comply with RFC 822).
**bcc_batch_mode** FALSE TRUE or FALSE (boolean) Enable BCC Batch Mode.
**bcc_batch_size** 200 None Number of emails in each BCC batch.
+**dsn** FALSE TRUE or FALSE (boolean) Enable notify message from server
=================== ====================== ============================ =======================================================================
Email Function Reference
diff --git a/user_guide_src/source/libraries/file_uploading.rst b/user_guide_src/source/libraries/file_uploading.rst
index 90efca95d..d573fc770 100644
--- a/user_guide_src/source/libraries/file_uploading.rst
+++ b/user_guide_src/source/libraries/file_uploading.rst
@@ -90,24 +90,24 @@ this code and save it to your applications/controllers/ folder::
class Upload extends CI_Controller {
- function __construct()
+ public function __construct()
{
parent::__construct();
$this->load->helper(array('form', 'url'));
}
- function index()
+ public function index()
{
$this->load->view('upload_form', array('error' => ' ' ));
}
- function do_upload()
+ public function do_upload()
{
- $config['upload_path'] = './uploads/';
- $config['allowed_types'] = 'gif|jpg|png';
- $config['max_size'] = '100';
- $config['max_width'] = '1024';
- $config['max_height'] = '768';
+ $config['upload_path'] = './uploads/';
+ $config['allowed_types'] = 'gif|jpg|png';
+ $config['max_size'] = 100;
+ $config['max_width'] = 1024;
+ $config['max_height'] = 768;
$this->load->library('upload', $config);
diff --git a/user_guide_src/source/libraries/form_validation.rst b/user_guide_src/source/libraries/form_validation.rst
index 5d7368ccb..3e8855f60 100644
--- a/user_guide_src/source/libraries/form_validation.rst
+++ b/user_guide_src/source/libraries/form_validation.rst
@@ -123,7 +123,7 @@ this code and save it to your applications/controllers/ folder::
class Form extends CI_Controller {
- function index()
+ public function index()
{
$this->load->helper(array('form', 'url'));
@@ -219,7 +219,7 @@ Your controller should now look like this::
class Form extends CI_Controller {
- function index()
+ public function index()
{
$this->load->helper(array('form', 'url'));
diff --git a/user_guide_src/source/libraries/sessions.rst b/user_guide_src/source/libraries/sessions.rst
index ef32f5d71..e8332ee97 100644
--- a/user_guide_src/source/libraries/sessions.rst
+++ b/user_guide_src/source/libraries/sessions.rst
@@ -209,6 +209,10 @@ set_userdata().
To read a flashdata variable::
$this->session->flashdata('item');
+
+An array of all flashdata can be retrieved as follows::
+
+ $this->session->all_flashdata();
If you find that you need to preserve a flashdata variable through an
diff --git a/user_guide_src/source/libraries/xmlrpc.rst b/user_guide_src/source/libraries/xmlrpc.rst
index 3b945769f..dfb88114e 100644
--- a/user_guide_src/source/libraries/xmlrpc.rst
+++ b/user_guide_src/source/libraries/xmlrpc.rst
@@ -184,10 +184,10 @@ server will expect a class to exist with this prototype::
class My_blog extends CI_Controller {
- function new_post($request)
- {
+ public function new_post($request)
+ {
- }
+ }
}
The $request variable is an object compiled by the Server, which
@@ -304,7 +304,7 @@ folder::
class Xmlrpc_client extends CI_Controller {
- function index()
+ public function index()
{
$this->load->helper('url');
$server_url = site_url('xmlrpc_server');
@@ -345,7 +345,7 @@ folder::
class Xmlrpc_server extends CI_Controller {
- function index()
+ public function index()
{
$this->load->library('xmlrpc');
$this->load->library('xmlrpcs');
@@ -357,15 +357,17 @@ folder::
}
- function process($request)
+ public function process($request)
{
$parameters = $request->output_parameters();
$response = array(
- array(
- 'you_said' => $parameters['0'],
- 'i_respond' => 'Not bad at all.'),
- 'struct');
+ array(
+ 'you_said' => $parameters[0],
+ 'i_respond' => 'Not bad at all.'
+ ),
+ 'struct'
+ );
return $this->xmlrpc->send_response($response);
}
@@ -419,9 +421,9 @@ the Server.
::
$parameters = $request->output_parameters();
- $name = $parameters['0']['name'];
- $size = $parameters['1']['size'];
- $size = $parameters['1']['shape'];
+ $name = $parameters[0]['name'];
+ $size = $parameters[1]['size'];
+ $size = $parameters[1]['shape'];
**************************
XML-RPC Function Reference