From 353f9834adf3f44c6c7a0f924089bb2b43360404 Mon Sep 17 00:00:00 2001 From: Daniel Hunsaker Date: Thu, 24 Jan 2013 17:09:10 -0700 Subject: Updated all cases of exit() to return a valid code Specific codes are as follows, but can easily be changed if a different order/breakdown makes more sense: - 0: Success; everything executed as planned - 1: Configuration Error; something is wrong with/in the configuration file(s) - 2: Class Not Found; what it says - 3: Driver Method Unsupported; the method you're trying to use on a Driver doesn't exist - 4: File Not Found; 404 error - 5: Database Error; something is broken in the database somewhere - 6: Invalid Input; the user attempted to submit a request with invlaid characters in 1+ key names 7 through 26 are reserved for future use - 27: Generic Error; generated by show_error() when the status code is >= 100 28 through 127 are errors generated by user applications, normally by using show_error() with a status code below 100 128 through 254 should not be used by applications, as they are reserved by system-level functions - 255: PHP Fatal Error; automatically generated by PHP for fatal errors, and therefore not allowed for our use Status codes below 100 are shifted up by 28 to place them in the user error range. It may make more sense to have these codes left alone and instead shift the CI errors into the 101 through 127 space, but that's not what I opted for here. It would probably also be a good idea to replace the hard-coded numbers with constants or some such, but I was in a bit of a hurry when I made these changes, so I didn't look around for the best place to do this. With proper guidance, I could easily amend this commit with another that uses such constant values. Signed-off-by: Daniel Hunsaker --- system/core/CodeIgniter.php | 2 +- system/core/Common.php | 29 ++++++++++++++++++++++------- system/core/Exceptions.php | 2 +- system/core/Input.php | 3 ++- system/core/Output.php | 2 +- system/database/DB_driver.php | 2 +- system/helpers/download_helper.php | 5 +++-- system/helpers/url_helper.php | 2 +- system/libraries/Driver.php | 2 +- system/libraries/Trackback.php | 4 ++-- system/libraries/Xmlrpcs.php | 3 ++- 11 files changed, 37 insertions(+), 19 deletions(-) (limited to 'system') diff --git a/system/core/CodeIgniter.php b/system/core/CodeIgniter.php index 8affde64d..13826c328 100644 --- a/system/core/CodeIgniter.php +++ b/system/core/CodeIgniter.php @@ -188,7 +188,7 @@ defined('BASEPATH') OR exit('No direct script access allowed'); if ($EXT->call_hook('cache_override') === FALSE && $OUT->_display_cache($CFG, $URI) === TRUE) { - exit; + exit(0); } /* diff --git a/system/core/Common.php b/system/core/Common.php index d494caf80..d6387209b 100644 --- a/system/core/Common.php +++ b/system/core/Common.php @@ -1,3 +1,4 @@ + show_error($heading, $message, 'error_general', $status_code); - exit; + exit($exit_status); } } @@ -392,7 +407,7 @@ if ( ! function_exists('show_404')) { $_error =& load_class('Exceptions', 'core'); $_error->show_404($page, $log_error); - exit; + exit(4); } } @@ -514,11 +529,11 @@ if ( ! function_exists('set_status_header')) if (strpos(php_sapi_name(), 'cgi') === 0) { - header('Status: '.$code.' '.$text, TRUE); + if (!headers_sent()) header('Status: '.$code.' '.$text, TRUE); } else { - header(($server_protocol ? $server_protocol : 'HTTP/1.1').' '.$code.' '.$text, TRUE, $code); + if (!headers_sent()) header(($server_protocol ? $server_protocol : 'HTTP/1.1').' '.$code.' '.$text, TRUE, $code); } } } diff --git a/system/core/Exceptions.php b/system/core/Exceptions.php index e6023e73b..f799d6027 100644 --- a/system/core/Exceptions.php +++ b/system/core/Exceptions.php @@ -117,7 +117,7 @@ class CI_Exceptions { } echo $this->show_error($heading, $message, 'error_404', 404); - exit; + exit(4); } // -------------------------------------------------------------------- diff --git a/system/core/Input.php b/system/core/Input.php index 82e22dd49..8f37e4464 100644 --- a/system/core/Input.php +++ b/system/core/Input.php @@ -745,7 +745,8 @@ class CI_Input { if ( ! preg_match('/^[a-z0-9:_\/|-]+$/i', $str)) { set_status_header(503); - exit('Disallowed Key Characters.'); + echo 'Disallowed Key Characters.'; + exit(6); } // Clean UTF-8 if supported diff --git a/system/core/Output.php b/system/core/Output.php index a20841463..7898d1972 100644 --- a/system/core/Output.php +++ b/system/core/Output.php @@ -696,7 +696,7 @@ class CI_Output { if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) && $last_modified <= strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE'])) { $this->set_status_header(304); - exit; + exit(0); } else { diff --git a/system/database/DB_driver.php b/system/database/DB_driver.php index 35ac8e870..cb2ef4ac8 100644 --- a/system/database/DB_driver.php +++ b/system/database/DB_driver.php @@ -1658,7 +1658,7 @@ abstract class CI_DB_driver { $error =& load_class('Exceptions', 'core'); echo $error->show_error($heading, $message, 'error_db'); - exit; + exit(5); } // -------------------------------------------------------------------- diff --git a/system/helpers/download_helper.php b/system/helpers/download_helper.php index 7294d50c5..d7691cb61 100644 --- a/system/helpers/download_helper.php +++ b/system/helpers/download_helper.php @@ -141,7 +141,8 @@ if ( ! function_exists('force_download')) // If we have raw data - just dump it if ($data !== NULL) { - exit($data); + echo $data; + exit(0); } // Flush 1MB chunks of data @@ -151,7 +152,7 @@ if ( ! function_exists('force_download')) } fclose($fp); - exit; + exit(0); } } diff --git a/system/helpers/url_helper.php b/system/helpers/url_helper.php index a6536cf81..9a0153542 100644 --- a/system/helpers/url_helper.php +++ b/system/helpers/url_helper.php @@ -549,7 +549,7 @@ if ( ! function_exists('redirect')) header('Location: '.$uri, TRUE, $code); break; } - exit; + exit(0); } } diff --git a/system/libraries/Driver.php b/system/libraries/Driver.php index 4b35dce73..bb7318991 100644 --- a/system/libraries/Driver.php +++ b/system/libraries/Driver.php @@ -291,7 +291,7 @@ class CI_Driver { $trace = debug_backtrace(); _exception_handler(E_ERROR, "No such method '{$method}'", $trace[1]['file'], $trace[1]['line']); - exit; + exit(3); } // -------------------------------------------------------------------- diff --git a/system/libraries/Trackback.php b/system/libraries/Trackback.php index ecc7129e3..cc93b2e30 100644 --- a/system/libraries/Trackback.php +++ b/system/libraries/Trackback.php @@ -212,7 +212,7 @@ class CI_Trackback { public function send_error($message = 'Incomplete Information') { echo '\n\n1\n".$message."\n"; - exit; + exit(0); } // -------------------------------------------------------------------- @@ -228,7 +228,7 @@ class CI_Trackback { public function send_success() { echo '\n\n0\n"; - exit; + exit(0); } // -------------------------------------------------------------------- diff --git a/system/libraries/Xmlrpcs.php b/system/libraries/Xmlrpcs.php index d4524d230..465a1967b 100644 --- a/system/libraries/Xmlrpcs.php +++ b/system/libraries/Xmlrpcs.php @@ -170,7 +170,8 @@ class CI_Xmlrpcs extends CI_Xmlrpc { header('Content-Type: text/xml'); header('Content-Length: '.strlen($payload)); - exit($payload); + echo $payload; + exit(0); } // -------------------------------------------------------------------- -- cgit v1.2.3-24-g4f1b From 3b5b7f48848d098c6190781f8790a1b0dcb0217c Mon Sep 17 00:00:00 2001 From: Daniel Hunsaker Date: Fri, 22 Feb 2013 19:17:56 -0700 Subject: Updated exit codes as constant values Re-allocated exit status codes according to three references, which follow: BSD sysexits.h:http://www.gsp.com/cgi-bin/man.cgi?section=3&topic=sysexits GNU recomendations:http://www.gnu.org/software/libc/manual/html_node/Exit-Status.html Bash scripting:http://tldp.org/LDP/abs/html/exitcodes.html The GNU recommendations stem from and expand upon the standard C/C++ library (stdlibc) definitions, while also suggesting some best-practice conventions which happen to prevent exit status code collisions with bash, and probably other shells. The re-allocated codes are now mapped to constant values, set in *application/config/constants.php*, and used throughout the CodeIgniter core. They would additionally be used in *index.php*, but the constants file hasn't been loaded at that point, so the integer values are used instead, and a comment follows each such use with amplifying information on why that particular value was selected. Finally, the errors documentation has been updated accordingly. Signed-off-by: Daniel Hunsaker --- system/core/CodeIgniter.php | 2 +- system/core/Common.php | 16 ++++++++++------ system/core/Exceptions.php | 2 +- system/core/Input.php | 2 +- system/core/Output.php | 2 +- system/database/DB_driver.php | 2 +- system/helpers/download_helper.php | 4 ++-- system/helpers/url_helper.php | 2 +- system/libraries/Driver.php | 2 +- system/libraries/Trackback.php | 4 ++-- system/libraries/Xmlrpcs.php | 2 +- 11 files changed, 22 insertions(+), 18 deletions(-) (limited to 'system') diff --git a/system/core/CodeIgniter.php b/system/core/CodeIgniter.php index 5a872ef21..8f5271add 100644 --- a/system/core/CodeIgniter.php +++ b/system/core/CodeIgniter.php @@ -188,7 +188,7 @@ defined('BASEPATH') OR exit('No direct script access allowed'); if ($EXT->call_hook('cache_override') === FALSE && $OUT->_display_cache($CFG, $URI) === TRUE) { - exit(0); + exit(EXIT_SUCCESS); } /* diff --git a/system/core/Common.php b/system/core/Common.php index 3cd97dc2e..479f0da7f 100644 --- a/system/core/Common.php +++ b/system/core/Common.php @@ -177,7 +177,7 @@ if ( ! function_exists('load_class')) // self-referencing loop with the Exceptions class set_status_header(503); echo 'Unable to locate the specified class: '.$class.'.php'; - exit(2); + exit(EXIT_UNK_CLASS); } // Keep track of what we just loaded @@ -251,7 +251,7 @@ if ( ! function_exists('get_config')) { set_status_header(503); echo 'The configuration file does not exist.'; - exit(1); + exit(EXIT_CONFIG); } // Does the $config array exist in the file? @@ -259,7 +259,7 @@ if ( ! function_exists('get_config')) { set_status_header(503); echo 'Your config file does not appear to be formatted correctly.'; - exit(1); + exit(EXIT_CONFIG); } // Are any values being dynamically replaced? @@ -374,12 +374,16 @@ if ( ! function_exists('show_error')) $status_code = abs($status_code); if ($status_code < 100) { - $exit_status = $status_code + 28; + $exit_status = $status_code + EXIT__AUTO_MIN; + if ($exit_status > EXIT__AUTO_MAX) + { + $exit_status = EXIT_FAILURE; + } $status_code = 500; } else { - $exit_status = 27; + $exit_status = EXIT_FAILURE; } $_error =& load_class('Exceptions', 'core'); @@ -407,7 +411,7 @@ if ( ! function_exists('show_404')) { $_error =& load_class('Exceptions', 'core'); $_error->show_404($page, $log_error); - exit(4); + exit(EXIT_UNK_FILE); } } diff --git a/system/core/Exceptions.php b/system/core/Exceptions.php index f799d6027..423387ff9 100644 --- a/system/core/Exceptions.php +++ b/system/core/Exceptions.php @@ -117,7 +117,7 @@ class CI_Exceptions { } echo $this->show_error($heading, $message, 'error_404', 404); - exit(4); + exit(EXIT_UNK_FILE); } // -------------------------------------------------------------------- diff --git a/system/core/Input.php b/system/core/Input.php index 904f4d6e9..8d491e055 100644 --- a/system/core/Input.php +++ b/system/core/Input.php @@ -746,7 +746,7 @@ class CI_Input { { set_status_header(503); echo 'Disallowed Key Characters.'; - exit(6); + exit(EXIT_USER_INPUT); } // Clean UTF-8 if supported diff --git a/system/core/Output.php b/system/core/Output.php index d4abe871d..1025703dc 100644 --- a/system/core/Output.php +++ b/system/core/Output.php @@ -696,7 +696,7 @@ class CI_Output { if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) && $last_modified <= strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE'])) { $this->set_status_header(304); - exit(0); + exit(EXIT_SUCCESS); } else { diff --git a/system/database/DB_driver.php b/system/database/DB_driver.php index 6ae1d524d..18dbbc76e 100644 --- a/system/database/DB_driver.php +++ b/system/database/DB_driver.php @@ -1658,7 +1658,7 @@ abstract class CI_DB_driver { $error =& load_class('Exceptions', 'core'); echo $error->show_error($heading, $message, 'error_db'); - exit(5); + exit(EXIT_DATABASE); } // -------------------------------------------------------------------- diff --git a/system/helpers/download_helper.php b/system/helpers/download_helper.php index daf59f51b..25863eaa4 100644 --- a/system/helpers/download_helper.php +++ b/system/helpers/download_helper.php @@ -142,7 +142,7 @@ if ( ! function_exists('force_download')) if ($data !== NULL) { echo $data; - exit(0); + exit(EXIT_SUCCESS); } // Flush 1MB chunks of data @@ -152,7 +152,7 @@ if ( ! function_exists('force_download')) } fclose($fp); - exit(0); + exit(EXIT_SUCCESS); } } diff --git a/system/helpers/url_helper.php b/system/helpers/url_helper.php index d6bf7e2c9..7d5ccff35 100644 --- a/system/helpers/url_helper.php +++ b/system/helpers/url_helper.php @@ -550,7 +550,7 @@ if ( ! function_exists('redirect')) header('Location: '.$uri, TRUE, $code); break; } - exit(0); + exit(EXIT_SUCCESS); } } diff --git a/system/libraries/Driver.php b/system/libraries/Driver.php index ba15f81df..9a56013ab 100644 --- a/system/libraries/Driver.php +++ b/system/libraries/Driver.php @@ -290,7 +290,7 @@ class CI_Driver { $trace = debug_backtrace(); _exception_handler(E_ERROR, "No such method '{$method}'", $trace[1]['file'], $trace[1]['line']); - exit(3); + exit(EXIT_UNK_MEMBER); } // -------------------------------------------------------------------- diff --git a/system/libraries/Trackback.php b/system/libraries/Trackback.php index cc93b2e30..ea8017efd 100644 --- a/system/libraries/Trackback.php +++ b/system/libraries/Trackback.php @@ -212,7 +212,7 @@ class CI_Trackback { public function send_error($message = 'Incomplete Information') { echo '\n\n1\n".$message."\n"; - exit(0); + exit(EXIT_SUCCESS); } // -------------------------------------------------------------------- @@ -228,7 +228,7 @@ class CI_Trackback { public function send_success() { echo '\n\n0\n"; - exit(0); + exit(EXIT_SUCCESS); } // -------------------------------------------------------------------- diff --git a/system/libraries/Xmlrpcs.php b/system/libraries/Xmlrpcs.php index 2d2e7f13b..e150c13b7 100644 --- a/system/libraries/Xmlrpcs.php +++ b/system/libraries/Xmlrpcs.php @@ -171,7 +171,7 @@ class CI_Xmlrpcs extends CI_Xmlrpc { header('Content-Type: text/xml'); header('Content-Length: '.strlen($payload)); echo $payload; - exit(0); + exit(EXIT_SUCCESS); } // -------------------------------------------------------------------- -- cgit v1.2.3-24-g4f1b From 50dfe0175df02fe4aa243757bdf1b42fb9fc3169 Mon Sep 17 00:00:00 2001 From: Daniel Hunsaker Date: Mon, 4 Mar 2013 02:05:20 -0700 Subject: Updated in accordance with feedback from @narfbg - Removed commented lists of constants from the three reference conventions, replacing each with the URLs at which more information can be found. - Renamed a few constants to more closely reflect CodeIgniter conventions. - Modified a couple of lines which were in violation of the CI Style Guide. Signed-off-by: Daniel Hunsaker --- system/core/Common.php | 23 +++++++++++++---------- system/core/Exceptions.php | 2 +- system/helpers/download_helper.php | 4 ++-- system/libraries/Driver.php | 2 +- system/libraries/Xmlrpcs.php | 2 +- 5 files changed, 18 insertions(+), 15 deletions(-) (limited to 'system') diff --git a/system/core/Common.php b/system/core/Common.php index 479f0da7f..e11668d5f 100644 --- a/system/core/Common.php +++ b/system/core/Common.php @@ -177,7 +177,7 @@ if ( ! function_exists('load_class')) // self-referencing loop with the Exceptions class set_status_header(503); echo 'Unable to locate the specified class: '.$class.'.php'; - exit(EXIT_UNK_CLASS); + exit(EXIT_UNKNOWN_CLASS); } // Keep track of what we just loaded @@ -377,13 +377,13 @@ if ( ! function_exists('show_error')) $exit_status = $status_code + EXIT__AUTO_MIN; if ($exit_status > EXIT__AUTO_MAX) { - $exit_status = EXIT_FAILURE; + $exit_status = EXIT_ERROR; } $status_code = 500; } else { - $exit_status = EXIT_FAILURE; + $exit_status = EXIT_ERROR; } $_error =& load_class('Exceptions', 'core'); @@ -411,7 +411,7 @@ if ( ! function_exists('show_404')) { $_error =& load_class('Exceptions', 'core'); $_error->show_404($page, $log_error); - exit(EXIT_UNK_FILE); + exit(EXIT_UNKNOWN_FILE); } } @@ -531,13 +531,16 @@ if ( ! function_exists('set_status_header')) $server_protocol = isset($_SERVER['SERVER_PROTOCOL']) ? $_SERVER['SERVER_PROTOCOL'] : FALSE; - if (strpos(php_sapi_name(), 'cgi') === 0) + if ( ! headers_sent()) { - if (!headers_sent()) header('Status: '.$code.' '.$text, TRUE); - } - else - { - if (!headers_sent()) header(($server_protocol ? $server_protocol : 'HTTP/1.1').' '.$code.' '.$text, TRUE, $code); + if (strpos(php_sapi_name(), 'cgi') === 0) + { + header('Status: '.$code.' '.$text, TRUE); + } + else + { + header(($server_protocol ? $server_protocol : 'HTTP/1.1').' '.$code.' '.$text, TRUE, $code); + } } } } diff --git a/system/core/Exceptions.php b/system/core/Exceptions.php index 423387ff9..9c68d06a5 100644 --- a/system/core/Exceptions.php +++ b/system/core/Exceptions.php @@ -117,7 +117,7 @@ class CI_Exceptions { } echo $this->show_error($heading, $message, 'error_404', 404); - exit(EXIT_UNK_FILE); + exit(EXIT_UNKNOWN_FILE); } // -------------------------------------------------------------------- diff --git a/system/helpers/download_helper.php b/system/helpers/download_helper.php index 25863eaa4..bd3296574 100644 --- a/system/helpers/download_helper.php +++ b/system/helpers/download_helper.php @@ -142,7 +142,7 @@ if ( ! function_exists('force_download')) if ($data !== NULL) { echo $data; - exit(EXIT_SUCCESS); + exit; } // Flush 1MB chunks of data @@ -152,7 +152,7 @@ if ( ! function_exists('force_download')) } fclose($fp); - exit(EXIT_SUCCESS); + exit; } } diff --git a/system/libraries/Driver.php b/system/libraries/Driver.php index 9a56013ab..1bc365cbc 100644 --- a/system/libraries/Driver.php +++ b/system/libraries/Driver.php @@ -290,7 +290,7 @@ class CI_Driver { $trace = debug_backtrace(); _exception_handler(E_ERROR, "No such method '{$method}'", $trace[1]['file'], $trace[1]['line']); - exit(EXIT_UNK_MEMBER); + exit(EXIT_UNKNOWN_METHOD); } // -------------------------------------------------------------------- diff --git a/system/libraries/Xmlrpcs.php b/system/libraries/Xmlrpcs.php index e150c13b7..a6048cb9f 100644 --- a/system/libraries/Xmlrpcs.php +++ b/system/libraries/Xmlrpcs.php @@ -171,7 +171,7 @@ class CI_Xmlrpcs extends CI_Xmlrpc { header('Content-Type: text/xml'); header('Content-Length: '.strlen($payload)); echo $payload; - exit(EXIT_SUCCESS); + exit; } // -------------------------------------------------------------------- -- cgit v1.2.3-24-g4f1b From b2ac67a3a766ac18f5041eff7a5cbeef7437a184 Mon Sep 17 00:00:00 2001 From: Daniel Hunsaker Date: Mon, 4 Mar 2013 02:31:26 -0700 Subject: Oops, missed a few places where EXIT_SUCCESS was being used. Signed-off-by: Daniel Hunsaker --- system/core/CodeIgniter.php | 2 +- system/core/Output.php | 2 +- system/helpers/url_helper.php | 2 +- system/libraries/Trackback.php | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) (limited to 'system') diff --git a/system/core/CodeIgniter.php b/system/core/CodeIgniter.php index 8f5271add..7f76977b5 100644 --- a/system/core/CodeIgniter.php +++ b/system/core/CodeIgniter.php @@ -188,7 +188,7 @@ defined('BASEPATH') OR exit('No direct script access allowed'); if ($EXT->call_hook('cache_override') === FALSE && $OUT->_display_cache($CFG, $URI) === TRUE) { - exit(EXIT_SUCCESS); + exit; } /* diff --git a/system/core/Output.php b/system/core/Output.php index 1025703dc..25ecd496c 100644 --- a/system/core/Output.php +++ b/system/core/Output.php @@ -696,7 +696,7 @@ class CI_Output { if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) && $last_modified <= strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE'])) { $this->set_status_header(304); - exit(EXIT_SUCCESS); + exit; } else { diff --git a/system/helpers/url_helper.php b/system/helpers/url_helper.php index 7d5ccff35..d0fab3fe0 100644 --- a/system/helpers/url_helper.php +++ b/system/helpers/url_helper.php @@ -550,7 +550,7 @@ if ( ! function_exists('redirect')) header('Location: '.$uri, TRUE, $code); break; } - exit(EXIT_SUCCESS); + exit; } } diff --git a/system/libraries/Trackback.php b/system/libraries/Trackback.php index ea8017efd..ecc7129e3 100644 --- a/system/libraries/Trackback.php +++ b/system/libraries/Trackback.php @@ -212,7 +212,7 @@ class CI_Trackback { public function send_error($message = 'Incomplete Information') { echo '\n\n1\n".$message."\n"; - exit(EXIT_SUCCESS); + exit; } // -------------------------------------------------------------------- @@ -228,7 +228,7 @@ class CI_Trackback { public function send_success() { echo '\n\n0\n"; - exit(EXIT_SUCCESS); + exit; } // -------------------------------------------------------------------- -- cgit v1.2.3-24-g4f1b From 8626e93d5b4362c86a58933dda9206ac8810476d Mon Sep 17 00:00:00 2001 From: Daniel Hunsaker Date: Mon, 4 Mar 2013 05:14:22 -0700 Subject: Reverting changes to functions that have no business being used in CLI apps to begin with Signed-off-by: Daniel Hunsaker --- system/core/Common.php | 15 ++++++--------- system/helpers/download_helper.php | 3 +-- system/libraries/Trackback.php | 6 ++---- system/libraries/Xmlrpcs.php | 3 +-- 4 files changed, 10 insertions(+), 17 deletions(-) (limited to 'system') diff --git a/system/core/Common.php b/system/core/Common.php index e11668d5f..9baf5e315 100644 --- a/system/core/Common.php +++ b/system/core/Common.php @@ -531,16 +531,13 @@ if ( ! function_exists('set_status_header')) $server_protocol = isset($_SERVER['SERVER_PROTOCOL']) ? $_SERVER['SERVER_PROTOCOL'] : FALSE; - if ( ! headers_sent()) + if (strpos(php_sapi_name(), 'cgi') === 0) { - if (strpos(php_sapi_name(), 'cgi') === 0) - { - header('Status: '.$code.' '.$text, TRUE); - } - else - { - header(($server_protocol ? $server_protocol : 'HTTP/1.1').' '.$code.' '.$text, TRUE, $code); - } + header('Status: '.$code.' '.$text, TRUE); + } + else + { + header(($server_protocol ? $server_protocol : 'HTTP/1.1').' '.$code.' '.$text, TRUE, $code); } } } diff --git a/system/helpers/download_helper.php b/system/helpers/download_helper.php index bd3296574..4fe6a0e88 100644 --- a/system/helpers/download_helper.php +++ b/system/helpers/download_helper.php @@ -141,8 +141,7 @@ if ( ! function_exists('force_download')) // If we have raw data - just dump it if ($data !== NULL) { - echo $data; - exit; + exit($data); } // Flush 1MB chunks of data diff --git a/system/libraries/Trackback.php b/system/libraries/Trackback.php index ecc7129e3..5a45be8dd 100644 --- a/system/libraries/Trackback.php +++ b/system/libraries/Trackback.php @@ -211,8 +211,7 @@ class CI_Trackback { */ public function send_error($message = 'Incomplete Information') { - echo '\n\n1\n".$message."\n"; - exit; + exit('\n\n1\n".$message."\n"); } // -------------------------------------------------------------------- @@ -227,8 +226,7 @@ class CI_Trackback { */ public function send_success() { - echo '\n\n0\n"; - exit; + exit('\n\n0\n"); } // -------------------------------------------------------------------- diff --git a/system/libraries/Xmlrpcs.php b/system/libraries/Xmlrpcs.php index a6048cb9f..d263d789d 100644 --- a/system/libraries/Xmlrpcs.php +++ b/system/libraries/Xmlrpcs.php @@ -170,8 +170,7 @@ class CI_Xmlrpcs extends CI_Xmlrpc { header('Content-Type: text/xml'); header('Content-Length: '.strlen($payload)); - echo $payload; - exit; + exit($payload); } // -------------------------------------------------------------------- -- cgit v1.2.3-24-g4f1b From fa01ae4b3a2ed51a93590527c04295eb8cba4e40 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Mon, 4 Mar 2013 14:40:18 +0200 Subject: [ci skip] Fix #2289 --- system/libraries/Email.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'system') diff --git a/system/libraries/Email.php b/system/libraries/Email.php index daa38484b..756a38a10 100644 --- a/system/libraries/Email.php +++ b/system/libraries/Email.php @@ -2017,12 +2017,11 @@ class CI_Email { $reply = $this->_get_smtp_data(); - if (strpos($reply, '503') !== 0) // Already authenticated + if (strpos($reply, '503') === 0) // Already authenticated { return TRUE; } - - if (strpos($reply, '334') !== 0) + elseif (strpos($reply, '334') !== 0) { $this->_set_error_message('lang:email_failed_smtp_login', $reply); return FALSE; -- cgit v1.2.3-24-g4f1b From 83c344efcae85ef3f07453bda70292a6bb628178 Mon Sep 17 00:00:00 2001 From: vlakoff Date: Mon, 4 Mar 2013 14:30:08 +0100 Subject: Cache file driver: clean() now preserves .htaccess and index files --- system/libraries/Cache/drivers/Cache_file.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system') diff --git a/system/libraries/Cache/drivers/Cache_file.php b/system/libraries/Cache/drivers/Cache_file.php index f1f1a30be..769bd5a26 100644 --- a/system/libraries/Cache/drivers/Cache_file.php +++ b/system/libraries/Cache/drivers/Cache_file.php @@ -133,7 +133,7 @@ class CI_Cache_file extends CI_Driver { */ public function clean() { - return delete_files($this->_cache_path); + return delete_files($this->_cache_path, FALSE, TRUE); } // ------------------------------------------------------------------------ -- cgit v1.2.3-24-g4f1b From 5a6814e2c832186e61d15e2032c4ad41932c4f49 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Mon, 4 Mar 2013 15:44:12 +0200 Subject: Fix #2301 --- system/core/Common.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'system') diff --git a/system/core/Common.php b/system/core/Common.php index 9baf5e315..10c22375e 100644 --- a/system/core/Common.php +++ b/system/core/Common.php @@ -1,4 +1,3 @@ - show_error($heading, $message, 'error_general', $status_code); exit($exit_status); -- cgit v1.2.3-24-g4f1b From 89b67b49616b19e9c9f0bee8f49cb1bfc93b7436 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Tue, 12 Mar 2013 19:34:23 +0200 Subject: Fix #2320 --- system/libraries/Email.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'system') diff --git a/system/libraries/Email.php b/system/libraries/Email.php index 756a38a10..a745d331d 100644 --- a/system/libraries/Email.php +++ b/system/libraries/Email.php @@ -105,9 +105,9 @@ class CI_Email { /** * SMTP Encryption * - * @var string NULL, 'tls' or 'ssl' + * @var string empty, 'tls' or 'ssl' */ - public $smtp_crypto = NULL; + public $smtp_crypto = ''; /** * Whether to apply word-wrapping to the message body. @@ -1875,7 +1875,7 @@ class CI_Email { return TRUE; } - $ssl = ($this->smtp_crypto === 'ssl') ? 'ssl://' : NULL; + $ssl = ($this->smtp_crypto === 'ssl') ? 'ssl://' : ''; $this->_smtp_connect = fsockopen($ssl.$this->smtp_host, $this->smtp_port, -- cgit v1.2.3-24-g4f1b From 219565d05f6b223c28e24422b9d244b201890699 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Tue, 12 Mar 2013 20:00:08 +0200 Subject: Add a (default) CI_DB_query_builder::_update_batch() method An improved version of PR #2324, which only targets ODBC. --- system/database/DB_query_builder.php | 41 ++++++++++++++++++++++ system/database/drivers/cubrid/cubrid_driver.php | 41 ---------------------- system/database/drivers/mysql/mysql_driver.php | 41 ---------------------- system/database/drivers/mysqli/mysqli_driver.php | 41 ---------------------- .../drivers/pdo/subdrivers/pdo_mysql_driver.php | 41 ---------------------- 5 files changed, 41 insertions(+), 164 deletions(-) (limited to 'system') diff --git a/system/database/DB_query_builder.php b/system/database/DB_query_builder.php index 85a233b50..292621b66 100644 --- a/system/database/DB_query_builder.php +++ b/system/database/DB_query_builder.php @@ -1854,6 +1854,47 @@ abstract class CI_DB_query_builder extends CI_DB_driver { // -------------------------------------------------------------------- + /** + * Update_Batch statement + * + * Generates a platform-specific batch update string from the supplied data + * + * @param string $table Table name + * @param array $values Update data + * @param string $index WHERE key + * @return string + */ + protected function _update_batch($table, $values, $index) + { + $ids = array(); + foreach ($values as $key => $val) + { + $ids[] = $val[$index]; + + foreach (array_keys($val) as $field) + { + if ($field !== $index) + { + $final[$field][] = 'WHEN '.$index.' = '.$val[$index].' THEN '.$val[$field]; + } + } + } + + $cases = ''; + foreach ($final as $k => $v) + { + $cases .= $k." = CASE \n" + .implode("\n", $v)."\n" + .'ELSE '.$k.' END, '; + } + + $this->where($index.' IN('.implode(',', $ids).')', NULL, FALSE); + + return 'UPDATE '.$table.' SET '.substr($cases, 0, -2).$this->_compile_wh('qb_where'); + } + + // -------------------------------------------------------------------- + /** * The "set_update_batch" function. Allows key/value pairs to be set for batch updating * diff --git a/system/database/drivers/cubrid/cubrid_driver.php b/system/database/drivers/cubrid/cubrid_driver.php index 6663868bd..51bbbdb47 100644 --- a/system/database/drivers/cubrid/cubrid_driver.php +++ b/system/database/drivers/cubrid/cubrid_driver.php @@ -429,47 +429,6 @@ class CI_DB_cubrid_driver extends CI_DB { // -------------------------------------------------------------------- - /** - * Update_Batch statement - * - * Generates a platform-specific batch update string from the supplied data - * - * @param string $table Table name - * @param array $values Update data - * @param string $index WHERE key - * @return string - */ - protected function _update_batch($table, $values, $index) - { - $ids = array(); - foreach ($values as $key => $val) - { - $ids[] = $val[$index]; - - foreach (array_keys($val) as $field) - { - if ($field !== $index) - { - $final[$field][] = 'WHEN '.$index.' = '.$val[$index].' THEN '.$val[$field]; - } - } - } - - $cases = ''; - foreach ($final as $k => $v) - { - $cases .= $k." = CASE \n" - .implode("\n", $v) - .'ELSE '.$k.' END, '; - } - - $this->where($index.' IN('.implode(',', $ids).')', NULL, FALSE); - - return 'UPDATE '.$table.' SET '.substr($cases, 0, -2).$this->_compile_wh('qb_where'); - } - - // -------------------------------------------------------------------- - /** * FROM tables * diff --git a/system/database/drivers/mysql/mysql_driver.php b/system/database/drivers/mysql/mysql_driver.php index 95003f648..b94642b35 100644 --- a/system/database/drivers/mysql/mysql_driver.php +++ b/system/database/drivers/mysql/mysql_driver.php @@ -455,47 +455,6 @@ class CI_DB_mysql_driver extends CI_DB { // -------------------------------------------------------------------- - /** - * Update_Batch statement - * - * Generates a platform-specific batch update string from the supplied data - * - * @param string $table Table name - * @param array $values Update data - * @param string $index WHERE key - * @return string - */ - protected function _update_batch($table, $values, $index) - { - $ids = array(); - foreach ($values as $key => $val) - { - $ids[] = $val[$index]; - - foreach (array_keys($val) as $field) - { - if ($field !== $index) - { - $final[$field][] = 'WHEN '.$index.' = '.$val[$index].' THEN '.$val[$field]; - } - } - } - - $cases = ''; - foreach ($final as $k => $v) - { - $cases .= $k." = CASE \n" - .implode("\n", $v)."\n" - .'ELSE '.$k.' END, '; - } - - $this->where($index.' IN('.implode(',', $ids).')', NULL, FALSE); - - return 'UPDATE '.$table.' SET '.substr($cases, 0, -2).$this->_compile_wh('qb_where'); - } - - // -------------------------------------------------------------------- - /** * FROM tables * diff --git a/system/database/drivers/mysqli/mysqli_driver.php b/system/database/drivers/mysqli/mysqli_driver.php index b64a7a2e8..ef2cb8a8d 100644 --- a/system/database/drivers/mysqli/mysqli_driver.php +++ b/system/database/drivers/mysqli/mysqli_driver.php @@ -426,47 +426,6 @@ class CI_DB_mysqli_driver extends CI_DB { // -------------------------------------------------------------------- - /** - * Update_Batch statement - * - * Generates a platform-specific batch update string from the supplied data - * - * @param string $table Table name - * @param array $values Update data - * @param string $index WHERE key - * @return string - */ - protected function _update_batch($table, $values, $index) - { - $ids = array(); - foreach ($values as $key => $val) - { - $ids[] = $val[$index]; - - foreach (array_keys($val) as $field) - { - if ($field !== $index) - { - $final[$field][] = 'WHEN '.$index.' = '.$val[$index].' THEN '.$val[$field]; - } - } - } - - $cases = ''; - foreach ($final as $k => $v) - { - $cases .= $k.' = CASE '."\n" - .implode("\n", $v)."\n" - .'ELSE '.$k.' END, '; - } - - $this->where($index.' IN('.implode(',', $ids).')', NULL, FALSE); - - return 'UPDATE '.$table.' SET '.substr($cases, 0, -2).$this->_compile_wh('qb_where'); - } - - // -------------------------------------------------------------------- - /** * FROM tables * diff --git a/system/database/drivers/pdo/subdrivers/pdo_mysql_driver.php b/system/database/drivers/pdo/subdrivers/pdo_mysql_driver.php index 315f6f53b..ff486fc5a 100644 --- a/system/database/drivers/pdo/subdrivers/pdo_mysql_driver.php +++ b/system/database/drivers/pdo/subdrivers/pdo_mysql_driver.php @@ -200,47 +200,6 @@ class CI_DB_pdo_mysql_driver extends CI_DB_pdo_driver { // -------------------------------------------------------------------- - /** - * Update_Batch statement - * - * Generates a platform-specific batch update string from the supplied data - * - * @param string $table Table name - * @param array $values Update data - * @param string $index UPDATE key - * @return string - */ - protected function _update_batch($table, $values, $index) - { - $ids = array(); - foreach ($values as $key => $val) - { - $ids[] = $val[$index]; - - foreach (array_keys($val) as $field) - { - if ($field !== $index) - { - $final[$field][] = 'WHEN '.$index.' = '.$val[$index].' THEN '.$val[$field]; - } - } - } - - $cases = ''; - foreach ($final as $k => $v) - { - $cases .= $k." = CASE \n" - .implode("\n", $v)."\n" - .'ELSE '.$k.' END), '; - } - - $this->where($index.' IN('.implode(',', $ids).')', NULL, FALSE); - - return 'UPDATE '.$table.' SET '.substr($cases, 0, -2).$this->_compile_wh('qb_where'); - } - - // -------------------------------------------------------------------- - /** * Truncate statement * -- cgit v1.2.3-24-g4f1b From 7b90325ceb8aa6fdb4680afe959927fc000bf548 Mon Sep 17 00:00:00 2001 From: bayssmekanique Date: Tue, 12 Mar 2013 13:25:24 -0700 Subject: Output Class Minify Function Change Added 2 additional MIME types to match against for JavaScript detection. --- system/core/Output.php | 2 ++ 1 file changed, 2 insertions(+) (limited to 'system') diff --git a/system/core/Output.php b/system/core/Output.php index 25ecd496c..3320ae154 100644 --- a/system/core/Output.php +++ b/system/core/Output.php @@ -793,6 +793,8 @@ class CI_Output { case 'text/css': case 'text/javascript': + case 'application/javascript': + case 'application/x-javascript': $output = $this->_minify_script_style($output); -- cgit v1.2.3-24-g4f1b From 5cb5c0a4354518ac1a8c5b71971d7a7232c33480 Mon Sep 17 00:00:00 2001 From: Sam Doidge Date: Wed, 13 Mar 2013 01:28:06 +0000 Subject: adding thumb_marker to image_lib->clear() --- system/libraries/Image_lib.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'system') diff --git a/system/libraries/Image_lib.php b/system/libraries/Image_lib.php index 0cec43fc4..7f01ac028 100644 --- a/system/libraries/Image_lib.php +++ b/system/libraries/Image_lib.php @@ -388,7 +388,7 @@ class CI_Image_lib { */ public function clear() { - $props = array('library_path', 'source_image', 'new_image', 'width', 'height', 'rotation_angle', 'x_axis', 'y_axis', 'wm_text', 'wm_overlay_path', 'wm_font_path', 'wm_shadow_color', 'source_folder', 'dest_folder', 'mime_type', 'orig_width', 'orig_height', 'image_type', 'size_str', 'full_src_path', 'full_dst_path'); + $props = array('thumb_marker', 'library_path', 'source_image', 'new_image', 'width', 'height', 'rotation_angle', 'x_axis', 'y_axis', 'wm_text', 'wm_overlay_path', 'wm_font_path', 'wm_shadow_color', 'source_folder', 'dest_folder', 'mime_type', 'orig_width', 'orig_height', 'image_type', 'size_str', 'full_src_path', 'full_dst_path'); foreach ($props as $val) { @@ -1767,4 +1767,4 @@ class CI_Image_lib { } /* End of file Image_lib.php */ -/* Location: ./system/libraries/Image_lib.php */ \ No newline at end of file +/* Location: ./system/libraries/Image_lib.php */ -- cgit v1.2.3-24-g4f1b From 7ee2034cabf965c68861b68093f126befbf26727 Mon Sep 17 00:00:00 2001 From: Sam Doidge Date: Wed, 13 Mar 2013 04:43:55 +0000 Subject: removing linebreak --- system/libraries/Image_lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system') diff --git a/system/libraries/Image_lib.php b/system/libraries/Image_lib.php index 7f01ac028..b6a11a3a5 100644 --- a/system/libraries/Image_lib.php +++ b/system/libraries/Image_lib.php @@ -1767,4 +1767,4 @@ class CI_Image_lib { } /* End of file Image_lib.php */ -/* Location: ./system/libraries/Image_lib.php */ +/* Location: ./system/libraries/Image_lib.php */ \ No newline at end of file -- cgit v1.2.3-24-g4f1b From 13f6eabafa655828a8c09b4ae0a58a2e3776c269 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Fri, 15 Mar 2013 10:56:55 +0200 Subject: Fix MSSQL ALTER TABLE ADD statement An improved version of PR #2329 --- system/database/DB_forge.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'system') diff --git a/system/database/DB_forge.php b/system/database/DB_forge.php index 53cdd53b6..d52029ecd 100644 --- a/system/database/DB_forge.php +++ b/system/database/DB_forge.php @@ -680,8 +680,12 @@ abstract class CI_DB_forge { return $sql.'DROP COLUMN '.$this->db->escape_identifiers($field); } + $sql .= ($alter_type === 'ADD') + ? 'ADD ' + : $alter_type.' COLUMN '; + $sqls = array(); - for ($i = 0, $c = count($field), $sql .= $alter_type.' COLUMN '; $i < $c; $i++) + for ($i = 0, $c = count($field); $i < $c; $i++) { $sqls[] = $sql .($field[$i]['_literal'] !== FALSE ? $field[$i]['_literal'] : $this->_process_column($field[$i])); -- cgit v1.2.3-24-g4f1b