added constants.php file and implemented constants for file system modes
diff --git a/system/application/config/constants.php b/system/application/config/constants.php
new file mode 100644
index 0000000..ace3f8b
--- /dev/null
+++ b/system/application/config/constants.php
@@ -0,0 +1,21 @@
+<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
+
+/*
+|--------------------------------------------------------------------------
+| File and Directory Modes
+|--------------------------------------------------------------------------
+|
+| These prefs are used when checking and setting modes when working
+| with the file system. The defaults are fine on servers with proper
+| security, but you may wish (or even need) to change the values in
+| certain environments (Apache running a separate process for each
+| user, PHP under CGI with Apache suEXEC, etc.). Octal values should
+| always be used to set the mode correctly.
+|
+*/
+define('FILE_READ_MODE', 0644);
+define('FILE_WRITE_MODE', 0666);
+define('DIR_READ_MODE', 0755);
+define('DIR_WRITE_MODE', 0777);
+
+?>
\ No newline at end of file
diff --git a/system/codeigniter/CodeIgniter.php b/system/codeigniter/CodeIgniter.php
index 866be35..04936b9 100644
--- a/system/codeigniter/CodeIgniter.php
+++ b/system/codeigniter/CodeIgniter.php
@@ -43,7 +43,14 @@
* ------------------------------------------------------
*/
require(BASEPATH.'codeigniter/Compat'.EXT);
-
+
+/*
+ * ------------------------------------------------------
+ * Load the compatibility override functions
+ * ------------------------------------------------------
+ */
+require(APPPATH.'config/constants'.EXT);
+
/*
* ------------------------------------------------------
* Define a custom error handler so we can log PHP errors
diff --git a/system/codeigniter/Common.php b/system/codeigniter/Common.php
index d9ddf80..4554a71 100644
--- a/system/codeigniter/Common.php
+++ b/system/codeigniter/Common.php
@@ -52,7 +52,7 @@
}
fclose($fp);
- @chmod($file, 0777);
+ @chmod($file, DIR_WRITE_MODE);
@unlink($file);
return TRUE;
}
diff --git a/system/database/DB_cache.php b/system/database/DB_cache.php
index ad54fc3..08394da 100644
--- a/system/database/DB_cache.php
+++ b/system/database/DB_cache.php
@@ -129,12 +129,12 @@
if ( ! @is_dir($dir_path))
{
- if ( ! @mkdir($dir_path, 0777))
+ if ( ! @mkdir($dir_path, DIR_WRITE_MODE))
{
return FALSE;
}
- @chmod($dir_path, 0777);
+ @chmod($dir_path, DIR_WRITE_MODE);
}
if (write_file($dir_path.$filename, serialize($object)) === FALSE)
@@ -142,7 +142,7 @@
return FALSE;
}
- @chmod($dir_path.$filename, 0777);
+ @chmod($dir_path.$filename, DIR_WRITE_MODE);
return TRUE;
}
diff --git a/system/database/drivers/sqlite/sqlite_driver.php b/system/database/drivers/sqlite/sqlite_driver.php
index c859dea..16a8308 100644
--- a/system/database/drivers/sqlite/sqlite_driver.php
+++ b/system/database/drivers/sqlite/sqlite_driver.php
@@ -48,7 +48,7 @@
*/
function db_connect()
{
- if ( ! $conn_id = @sqlite_open($this->database, 0666, $error))
+ if ( ! $conn_id = @sqlite_open($this->database, FILE_WRITE_MODE, $error))
{
log_message('error', $error);
@@ -73,7 +73,7 @@
*/
function db_pconnect()
{
- if ( ! $conn_id = @sqlite_popen($this->database, 0666, $error))
+ if ( ! $conn_id = @sqlite_popen($this->database, FILE_WRITE_MODE, $error))
{
log_message('error', $error);
diff --git a/system/libraries/Image_lib.php b/system/libraries/Image_lib.php
index 3957420..85435f6 100644
--- a/system/libraries/Image_lib.php
+++ b/system/libraries/Image_lib.php
@@ -484,7 +484,7 @@
return FALSE;
}
- @chmod($this->full_dst_path, 0777);
+ @chmod($this->full_dst_path, DIR_WRITE_MODE);
return TRUE;
}
@@ -539,7 +539,7 @@
imagedestroy($src_img);
// Set the file to 777
- @chmod($this->full_dst_path, 0777);
+ @chmod($this->full_dst_path, DIR_WRITE_MODE);
return TRUE;
}
@@ -609,7 +609,7 @@
}
// Set the file to 777
- @chmod($this->full_dst_path, 0777);
+ @chmod($this->full_dst_path, DIR_WRITE_MODE);
return TRUE;
}
@@ -695,7 +695,7 @@
// we have to rename the temp file.
copy ($this->dest_folder.'netpbm.tmp', $this->full_dst_path);
unlink ($this->dest_folder.'netpbm.tmp');
- @chmod($dst_image, 0777);
+ @chmod($dst_image, DIR_WRITE_MODE);
return TRUE;
}
@@ -754,7 +754,7 @@
// Set the file to 777
- @chmod($this->full_dst_path, 0777);
+ @chmod($this->full_dst_path, DIR_WRITE_MODE);
return true;
}
@@ -838,7 +838,7 @@
imagedestroy($src_img);
// Set the file to 777
- @chmod($this->full_dst_path, 0777);
+ @chmod($this->full_dst_path, DIR_WRITE_MODE);
return TRUE;
}
diff --git a/system/libraries/Log.php b/system/libraries/Log.php
index f9ca85a..1aa8bd0 100644
--- a/system/libraries/Log.php
+++ b/system/libraries/Log.php
@@ -109,7 +109,7 @@
flock($fp, LOCK_UN);
fclose($fp);
- @chmod($filepath, 0666);
+ @chmod($filepath, FILE_WRITE_MODE);
return TRUE;
}
diff --git a/system/libraries/Output.php b/system/libraries/Output.php
index a4d8d34..07990eb 100644
--- a/system/libraries/Output.php
+++ b/system/libraries/Output.php
@@ -308,7 +308,7 @@
fwrite($fp, $expire.'TS--->'.$output);
flock($fp, LOCK_UN);
fclose($fp);
- @chmod($cache_path, 0777);
+ @chmod($cache_path, DIR_WRITE_MODE);
log_message('debug', "Cache file written: ".$cache_path);
}