summaryrefslogtreecommitdiffstats
path: root/system
diff options
context:
space:
mode:
authorAndrey Andreev <narf@devilix.net>2014-03-13 13:55:45 +0100
committerAndrey Andreev <narf@devilix.net>2014-03-13 13:55:45 +0100
commit7cf682abf46bcaa112b63c500a884ba25c0dd8b3 (patch)
treeec4283976055d986add2da7b0dad16c1e75dcba5 /system
parentd2e3a6fbf820b819bd7b2abc4794766f4c1d4e1a (diff)
Partially revert PR #2190
The core shouldn't depend on constants that are not defined by itself
Diffstat (limited to 'system')
-rw-r--r--system/core/Common.php25
-rw-r--r--system/core/Exceptions.php2
-rw-r--r--system/core/Input.php2
-rw-r--r--system/core/Log.php6
-rw-r--r--system/core/Output.php6
-rw-r--r--system/database/DB_cache.php6
-rw-r--r--system/database/DB_driver.php2
-rw-r--r--system/libraries/Driver.php2
-rw-r--r--system/libraries/Email.php2
-rw-r--r--system/libraries/Image_lib.php12
-rw-r--r--system/libraries/Zip.php2
11 files changed, 34 insertions, 33 deletions
diff --git a/system/core/Common.php b/system/core/Common.php
index 55f07a871..237bd4246 100644
--- a/system/core/Common.php
+++ b/system/core/Common.php
@@ -94,17 +94,17 @@ if ( ! function_exists('is_really_writable'))
if (is_dir($file))
{
$file = rtrim($file, '/').'/'.md5(mt_rand());
- if (($fp = @fopen($file, FOPEN_WRITE_CREATE)) === FALSE)
+ if (($fp = @fopen($file, 'ab')) === FALSE)
{
return FALSE;
}
fclose($fp);
- @chmod($file, DIR_WRITE_MODE);
+ @chmod($file, 0777);
@unlink($file);
return TRUE;
}
- elseif ( ! is_file($file) OR ($fp = @fopen($file, FOPEN_WRITE_CREATE)) === FALSE)
+ elseif ( ! is_file($file) OR ($fp = @fopen($file, 'ab')) === FALSE)
{
return FALSE;
}
@@ -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_UNKNOWN_CLASS);
+ exit(5); // EXIT_UNK_CLASS
}
// Keep track of what we just loaded
@@ -250,7 +250,7 @@ if ( ! function_exists('get_config'))
{
set_status_header(503);
echo 'The configuration file does not exist.';
- exit(EXIT_CONFIG);
+ exit(3); // EXIT_CONFIG
}
// Does the $config array exist in the file?
@@ -258,7 +258,7 @@ if ( ! function_exists('get_config'))
{
set_status_header(503);
echo 'Your config file does not appear to be formatted correctly.';
- exit(EXIT_CONFIG);
+ exit(3); // EXIT_CONFIG
}
// references cannot be directly assigned to static variables, so we use an array
@@ -397,16 +397,17 @@ if ( ! function_exists('show_error'))
$status_code = abs($status_code);
if ($status_code < 100)
{
- $exit_status = $status_code + EXIT__AUTO_MIN;
- if ($exit_status > EXIT__AUTO_MAX)
+ $exit_status = $status_code + 9; // 9 is EXIT__AUTO_MIN
+ if ($exit_status > 125) // 125 is EXIT__AUTO_MAX
{
- $exit_status = EXIT_ERROR;
+ $exit_status = 1; // EXIT_ERROR
}
+
$status_code = 500;
}
else
{
- $exit_status = EXIT_ERROR;
+ $exit_status = 1; // EXIT_ERROR
}
$_error =& load_class('Exceptions', 'core');
@@ -434,7 +435,7 @@ if ( ! function_exists('show_404'))
{
$_error =& load_class('Exceptions', 'core');
$_error->show_404($page, $log_error);
- exit(EXIT_UNKNOWN_FILE);
+ exit(4); // EXIT_UNKNOWN_FILE
}
}
@@ -612,7 +613,7 @@ if ( ! function_exists('_exception_handler'))
// default error handling. See http://www.php.net/manual/en/errorfunc.constants.php
if ($is_error)
{
- exit(EXIT_ERROR);
+ exit(1); // EXIT_ERROR
}
}
}
diff --git a/system/core/Exceptions.php b/system/core/Exceptions.php
index 54a5bc48b..041869641 100644
--- a/system/core/Exceptions.php
+++ b/system/core/Exceptions.php
@@ -125,7 +125,7 @@ class CI_Exceptions {
}
echo $this->show_error($heading, $message, 'error_404', 404);
- exit(EXIT_UNKNOWN_FILE);
+ exit(4); // EXIT_UNKNOWN_FILE
}
// --------------------------------------------------------------------
diff --git a/system/core/Input.php b/system/core/Input.php
index 1408da2cb..5ffe43d0e 100644
--- a/system/core/Input.php
+++ b/system/core/Input.php
@@ -754,7 +754,7 @@ class CI_Input {
{
set_status_header(503);
echo 'Disallowed Key Characters.';
- exit(EXIT_USER_INPUT);
+ exit(7); // EXIT_USER_INPUT
}
}
diff --git a/system/core/Log.php b/system/core/Log.php
index 707964ccc..a949c3f39 100644
--- a/system/core/Log.php
+++ b/system/core/Log.php
@@ -108,7 +108,7 @@ class CI_Log {
$this->_file_ext = (isset($config['log_file_extension']) && $config['log_file_extension'] !== '')
? ltrim($config['log_file_extension'], '.') : 'php';
- file_exists($this->_log_path) OR mkdir($this->_log_path, DIR_WRITE_MODE, TRUE);
+ file_exists($this->_log_path) OR mkdir($this->_log_path, 0777, TRUE);
if ( ! is_dir($this->_log_path) OR ! is_really_writable($this->_log_path))
{
@@ -170,7 +170,7 @@ class CI_Log {
}
}
- if ( ! $fp = @fopen($filepath, FOPEN_WRITE_CREATE))
+ if ( ! $fp = @fopen($filepath, 'ab'))
{
return FALSE;
}
@@ -192,7 +192,7 @@ class CI_Log {
if (isset($newfile) && $newfile === TRUE)
{
- @chmod($filepath, FILE_WRITE_MODE);
+ @chmod($filepath, 0666);
}
return is_int($result);
diff --git a/system/core/Output.php b/system/core/Output.php
index 7a35b02da..df9ef0778 100644
--- a/system/core/Output.php
+++ b/system/core/Output.php
@@ -555,7 +555,7 @@ class CI_Output {
$cache_path .= md5($uri);
- if ( ! $fp = @fopen($cache_path, FOPEN_WRITE_CREATE_DESTRUCTIVE))
+ if ( ! $fp = @fopen($cache_path, 'w+b'))
{
log_message('error', 'Unable to write cache file: '.$cache_path);
return;
@@ -606,7 +606,7 @@ class CI_Output {
if (is_int($result))
{
- @chmod($cache_path, FILE_WRITE_MODE);
+ @chmod($cache_path, 0666);
log_message('debug', 'Cache file written: '.$cache_path);
// Send HTTP cache-control headers to browser to match file cache settings.
@@ -639,7 +639,7 @@ class CI_Output {
$uri = $CFG->item('base_url').$CFG->item('index_page').$URI->uri_string;
$filepath = $cache_path.md5($uri);
- if ( ! file_exists($filepath) OR ! $fp = @fopen($filepath, FOPEN_READ))
+ if ( ! file_exists($filepath) OR ! $fp = @fopen($filepath, 'rb'))
{
return FALSE;
}
diff --git a/system/database/DB_cache.php b/system/database/DB_cache.php
index 0ab9c5d6b..b855ff24e 100644
--- a/system/database/DB_cache.php
+++ b/system/database/DB_cache.php
@@ -158,12 +158,12 @@ class CI_DB_Cache {
if ( ! is_dir($dir_path))
{
- if ( ! @mkdir($dir_path, DIR_WRITE_MODE))
+ if ( ! @mkdir($dir_path, 0777))
{
return FALSE;
}
- @chmod($dir_path, DIR_WRITE_MODE);
+ @chmod($dir_path, 0777);
}
if (write_file($dir_path.$filename, serialize($object)) === FALSE)
@@ -171,7 +171,7 @@ class CI_DB_Cache {
return FALSE;
}
- @chmod($dir_path.$filename, FILE_WRITE_MODE);
+ @chmod($dir_path.$filename, 0666);
return TRUE;
}
diff --git a/system/database/DB_driver.php b/system/database/DB_driver.php
index b004de355..fafce45c7 100644
--- a/system/database/DB_driver.php
+++ b/system/database/DB_driver.php
@@ -1676,7 +1676,7 @@ abstract class CI_DB_driver {
$error =& load_class('Exceptions', 'core');
echo $error->show_error($heading, $message, 'error_db');
- exit(EXIT_DATABASE);
+ exit(8); // EXIT_DATABASE
}
// --------------------------------------------------------------------
diff --git a/system/libraries/Driver.php b/system/libraries/Driver.php
index d2e41d6dd..d15d34fc3 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_UNKNOWN_METHOD);
+ exit(6); // EXIT_UNKNOWN_METHOD
}
// --------------------------------------------------------------------
diff --git a/system/libraries/Email.php b/system/libraries/Email.php
index fac8a49d5..1f2f6a991 100644
--- a/system/libraries/Email.php
+++ b/system/libraries/Email.php
@@ -732,7 +732,7 @@ class CI_Email {
return FALSE;
}
- if ( ! $fp = @fopen($file, FOPEN_READ))
+ if ( ! $fp = @fopen($file, 'rb'))
{
$this->_set_error_message('lang:email_attachment_unreadable', $file);
return FALSE;
diff --git a/system/libraries/Image_lib.php b/system/libraries/Image_lib.php
index ac3db416d..df0df3fec 100644
--- a/system/libraries/Image_lib.php
+++ b/system/libraries/Image_lib.php
@@ -734,7 +734,7 @@ class CI_Image_lib {
{
if ($this->source_image !== $this->new_image && @copy($this->full_src_path, $this->full_dst_path))
{
- @chmod($this->full_dst_path, FILE_WRITE_MODE);
+ @chmod($this->full_dst_path, 0666);
}
return TRUE;
@@ -811,7 +811,7 @@ class CI_Image_lib {
imagedestroy($src_img);
// Set the file to 666
- @chmod($this->full_dst_path, FILE_WRITE_MODE);
+ @chmod($this->full_dst_path, 0666);
return TRUE;
}
@@ -881,7 +881,7 @@ class CI_Image_lib {
}
// Set the file to 777
- @chmod($this->full_dst_path, FILE_WRITE_MODE);
+ @chmod($this->full_dst_path, 0666);
return TRUE;
}
@@ -969,7 +969,7 @@ class CI_Image_lib {
// we have to rename the temp file.
copy($this->dest_folder.'netpbm.tmp', $this->full_dst_path);
unlink($this->dest_folder.'netpbm.tmp');
- @chmod($this->full_dst_path, FILE_WRITE_MODE);
+ @chmod($this->full_dst_path, 0666);
return TRUE;
}
@@ -1014,7 +1014,7 @@ class CI_Image_lib {
imagedestroy($src_img);
// Set the file to 777
- @chmod($this->full_dst_path, FILE_WRITE_MODE);
+ @chmod($this->full_dst_path, 0666);
return TRUE;
}
@@ -1087,7 +1087,7 @@ class CI_Image_lib {
imagedestroy($src_img);
// Set the file to 777
- @chmod($this->full_dst_path, FILE_WRITE_MODE);
+ @chmod($this->full_dst_path, 0666);
return TRUE;
}
diff --git a/system/libraries/Zip.php b/system/libraries/Zip.php
index 43abfba42..c634b1133 100644
--- a/system/libraries/Zip.php
+++ b/system/libraries/Zip.php
@@ -398,7 +398,7 @@ class CI_Zip {
*/
public function archive($filepath)
{
- if ( ! ($fp = @fopen($filepath, FOPEN_WRITE_CREATE_DESTRUCTIVE)))
+ if ( ! ($fp = @fopen($filepath, 'w+b')))
{
return FALSE;
}