summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDerek Jones <derek.jones@ellislab.com>2008-04-04 20:56:04 +0200
committerDerek Jones <derek.jones@ellislab.com>2008-04-04 20:56:04 +0200
commit3ad8efe07deb3ec27a205815dc9097c20c728e9b (patch)
treed2d699b7173505ef6ce317cd0856fa5b03e6aae1
parent1ea127ae8a8026af7679526af06ff297d5104104 (diff)
added constants.php file and implemented constants for file system modes
-rw-r--r--system/application/config/constants.php21
-rw-r--r--system/codeigniter/CodeIgniter.php9
-rw-r--r--system/codeigniter/Common.php2
-rw-r--r--system/database/DB_cache.php6
-rw-r--r--system/database/drivers/sqlite/sqlite_driver.php4
-rw-r--r--system/libraries/Image_lib.php12
-rw-r--r--system/libraries/Log.php2
-rw-r--r--system/libraries/Output.php2
-rw-r--r--user_guide/changelog.html1
-rw-r--r--user_guide/installation/upgrade_162.html6
-rw-r--r--user_guide/libraries/ftp.html4
11 files changed, 50 insertions, 19 deletions
diff --git a/system/application/config/constants.php b/system/application/config/constants.php
new file mode 100644
index 000000000..ace3f8b9d
--- /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 866be35cc..04936b956 100644
--- a/system/codeigniter/CodeIgniter.php
+++ b/system/codeigniter/CodeIgniter.php
@@ -43,7 +43,14 @@ require(BASEPATH.'codeigniter/Common'.EXT);
* ------------------------------------------------------
*/
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 d9ddf80c7..4554a712b 100644
--- a/system/codeigniter/Common.php
+++ b/system/codeigniter/Common.php
@@ -52,7 +52,7 @@ function is_really_writable($file)
}
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 ad54fc315..08394da29 100644
--- a/system/database/DB_cache.php
+++ b/system/database/DB_cache.php
@@ -129,12 +129,12 @@ class CI_DB_Cache {
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 @@ class CI_DB_Cache {
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 c859dea6e..16a8308c1 100644
--- a/system/database/drivers/sqlite/sqlite_driver.php
+++ b/system/database/drivers/sqlite/sqlite_driver.php
@@ -48,7 +48,7 @@ class CI_DB_sqlite_driver extends CI_DB {
*/
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 @@ class CI_DB_sqlite_driver extends CI_DB {
*/
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 395742092..85435f6c9 100644
--- a/system/libraries/Image_lib.php
+++ b/system/libraries/Image_lib.php
@@ -484,7 +484,7 @@ class CI_Image_lib {
return FALSE;
}
- @chmod($this->full_dst_path, 0777);
+ @chmod($this->full_dst_path, DIR_WRITE_MODE);
return TRUE;
}
@@ -539,7 +539,7 @@ class CI_Image_lib {
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 @@ class CI_Image_lib {
}
// 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 @@ 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($dst_image, 0777);
+ @chmod($dst_image, DIR_WRITE_MODE);
return TRUE;
}
@@ -754,7 +754,7 @@ class CI_Image_lib {
// 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 @@ class CI_Image_lib {
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 f9ca85a30..1aa8bd0f4 100644
--- a/system/libraries/Log.php
+++ b/system/libraries/Log.php
@@ -109,7 +109,7 @@ class CI_Log {
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 a4d8d34b8..07990eb16 100644
--- a/system/libraries/Output.php
+++ b/system/libraries/Output.php
@@ -308,7 +308,7 @@ class CI_Output {
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);
}
diff --git a/user_guide/changelog.html b/user_guide/changelog.html
index 4e3ca7ced..af51c0e24 100644
--- a/user_guide/changelog.html
+++ b/user_guide/changelog.html
@@ -64,6 +64,7 @@ Change Log
<ul>
<li>Added 'application/vnd.ms-powerpoint' to list of mime types.</li>
<li>Added 'audio/mpg' to list of mime types.</li>
+ <li>Added new user-modifiable file constants.php containing file mode constants</li>
</ul>
</li>
<li>Libraries
diff --git a/user_guide/installation/upgrade_162.html b/user_guide/installation/upgrade_162.html
index 7fd01ea44..66c498b0f 100644
--- a/user_guide/installation/upgrade_162.html
+++ b/user_guide/installation/upgrade_162.html
@@ -42,7 +42,7 @@
<td id="breadcrumb">
<a href="http://codeigniter.com/">CodeIgniter Home</a> &nbsp;&#8250;&nbsp;
<a href="../index.html">User Guide Home</a> &nbsp;&#8250;&nbsp;
-Upgrading from 1.6.0 to 1.6.1
+Upgrading from 1.6.1 to 1.6.2
</td>
<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide&nbsp; <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" />&nbsp;<input type="submit" class="submit" name="sa" value="Go" /></form></td>
</tr>
@@ -80,8 +80,10 @@ Upgrading from 1.6.0 to 1.6.1
<h2>Step 2: Encryption Key</h2>
<p>If you are using sessions, open up system/application/config.php and verify you've set an encryption key.</p>
+<h2>Step 3: Constants File</h2>
+<p>Copy /system/application/config/constants.php to your installation, and modify if necessary.</p>
-<h2>Step 3: Update your user guide</h2>
+<h2>Step 4: Update your user guide</h2>
<p>Please also replace your local copy of the user guide with the new version.</p>
</div>
diff --git a/user_guide/libraries/ftp.html b/user_guide/libraries/ftp.html
index 9e4af8b5d..0e577e9d0 100644
--- a/user_guide/libraries/ftp.html
+++ b/user_guide/libraries/ftp.html
@@ -258,7 +258,7 @@ Permissions can be set by passed an <kbd>octal</kbd> value in the second paramet
<code>
// Creates a folder named "bar"<br />
-$this->ftp->mkdir('/public_html/foo/bar/', 0777);
+$this->ftp->mkdir('/public_html/foo/bar/', DIR_WRITE_MODE);
</code>
@@ -268,7 +268,7 @@ $this->ftp->mkdir('/public_html/foo/bar/', 0777);
<code>
// Chmod "bar" to 777<br />
-$this->ftp->chmod('/public_html/foo/bar/', 0777);
+$this->ftp->chmod('/public_html/foo/bar/', DIR_WRITE_MODE);
</code>