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/libraries/Driver.php | 2 +- system/libraries/Trackback.php | 4 ++-- system/libraries/Xmlrpcs.php | 3 ++- 3 files changed, 5 insertions(+), 4 deletions(-) (limited to 'system/libraries') 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/libraries/Driver.php | 2 +- system/libraries/Trackback.php | 4 ++-- system/libraries/Xmlrpcs.php | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) (limited to 'system/libraries') 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/libraries/Driver.php | 2 +- system/libraries/Xmlrpcs.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'system/libraries') 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/libraries/Trackback.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'system/libraries') 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/libraries/Trackback.php | 6 ++---- system/libraries/Xmlrpcs.php | 3 +-- 2 files changed, 3 insertions(+), 6 deletions(-) (limited to 'system/libraries') 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/libraries') 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/libraries') 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 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/libraries') 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 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/libraries') 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/libraries') 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