summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDerek Jones <derek.jones@ellislab.com>2008-01-28 18:11:02 +0100
committerDerek Jones <derek.jones@ellislab.com>2008-01-28 18:11:02 +0100
commita25530f6594c7ba45b3faa9537fda9f807069759 (patch)
treedc47713436c3777dcb9eb22f2f08cee4186400f5
parent15130caa8d3f4650d383647050ce918de728bc53 (diff)
added is_really_writable() to Common.php, replaced is_writable() throughout application with is_really_writable()
-rw-r--r--system/codeigniter/Common.php38
-rw-r--r--system/database/DB_cache.php3
-rw-r--r--system/helpers/file_helper.php35
-rw-r--r--system/libraries/Log.php2
-rw-r--r--system/libraries/Output.php4
-rw-r--r--system/libraries/Upload.php2
-rw-r--r--system/plugins/captcha_pi.php2
-rw-r--r--user_guide/changelog.html2
8 files changed, 44 insertions, 44 deletions
diff --git a/system/codeigniter/Common.php b/system/codeigniter/Common.php
index b6f0a46e8..d9ddf80c7 100644
--- a/system/codeigniter/Common.php
+++ b/system/codeigniter/Common.php
@@ -30,6 +30,44 @@
// ------------------------------------------------------------------------
/**
+ * Tests for file writability
+ *
+ * is_writable() returns TRUE on Windows servers
+ * when you really can't write to the file
+ * as the OS reports to PHP as FALSE only if the
+ * read-only attribute is marked. Ugh?
+ *
+ * @access private
+ * @return void
+ */
+function is_really_writable($file)
+{
+ if (is_dir($file))
+ {
+ $file = rtrim($file, '/').'/'.md5(rand(1,100));
+
+ if (($fp = @fopen($file, 'ab')) === FALSE)
+ {
+ return FALSE;
+ }
+
+ fclose($fp);
+ @chmod($file, 0777);
+ @unlink($file);
+ return TRUE;
+ }
+ elseif (($fp = @fopen($file, 'ab')) === FALSE)
+ {
+ return FALSE;
+ }
+
+ fclose($fp);
+ return TRUE;
+}
+
+// ------------------------------------------------------------------------
+
+/**
* Class registry
*
* This function acts as a singleton. If the requested class does not
diff --git a/system/database/DB_cache.php b/system/database/DB_cache.php
index 44b8e815f..ad54fc315 100644
--- a/system/database/DB_cache.php
+++ b/system/database/DB_cache.php
@@ -63,9 +63,6 @@ class CI_DB_Cache {
// Add a trailing slash to the path if needed
$path = preg_replace("/(.+?)\/*$/", "\\1/", $path);
-
- // Load the file helper
- $this->CI->load->helper('file');
if ( ! is_dir($path) OR ! is_really_writable($path))
{
diff --git a/system/helpers/file_helper.php b/system/helpers/file_helper.php
index 5fb31cfaa..868561b5a 100644
--- a/system/helpers/file_helper.php
+++ b/system/helpers/file_helper.php
@@ -178,39 +178,4 @@ function get_filenames($source_dir, $include_path = FALSE)
// --------------------------------------------------------------------
-/**
- * Tests for file writability
- *
- * is_writable() returns TRUE on Windows servers
- * when you really can't write to the file
- * as the OS reports to PHP as FALSE only if the
- * read-only attribute is marked. Ugh?
- *
- * @access private
- * @return void
- */
-function is_really_writable($file)
-{
- if (is_dir($file))
- {
- $file = rtrim($file, '/').'/'.md5(rand(1,100));
-
- if (($fp = @fopen($file, 'ab')) === FALSE)
- {
- return FALSE;
- }
-
- fclose($fp);
- @chmod($file, 0777);
- @unlink($file);
- return TRUE;
- }
- elseif (($fp = @fopen($file, 'ab')) === FALSE)
- {
- return FALSE;
- }
-
- fclose($fp);
- return TRUE;
-}
?> \ No newline at end of file
diff --git a/system/libraries/Log.php b/system/libraries/Log.php
index 011bdbfd1..f9ca85a30 100644
--- a/system/libraries/Log.php
+++ b/system/libraries/Log.php
@@ -46,7 +46,7 @@ class CI_Log {
$this->log_path = ($config['log_path'] != '') ? $config['log_path'] : BASEPATH.'logs/';
- if ( ! is_dir($this->log_path) OR ! is_writable($this->log_path))
+ if ( ! is_dir($this->log_path) OR ! is_really_writable($this->log_path))
{
$this->_enabled = FALSE;
}
diff --git a/system/libraries/Output.php b/system/libraries/Output.php
index f98dab5e0..a4d8d34b8 100644
--- a/system/libraries/Output.php
+++ b/system/libraries/Output.php
@@ -285,7 +285,7 @@ class CI_Output {
$cache_path = ($path == '') ? BASEPATH.'cache/' : $path;
- if ( ! is_dir($cache_path) OR ! is_writable($cache_path))
+ if ( ! is_dir($cache_path) OR ! is_really_writable($cache_path))
{
return;
}
@@ -327,7 +327,7 @@ class CI_Output {
$cache_path = ($CFG->item('cache_path') == '') ? BASEPATH.'cache/' : $CFG->item('cache_path');
- if ( ! is_dir($cache_path) OR ! is_writable($cache_path))
+ if ( ! is_dir($cache_path) OR ! is_really_writable($cache_path))
{
return FALSE;
}
diff --git a/system/libraries/Upload.php b/system/libraries/Upload.php
index 39f1ed59b..dd7012211 100644
--- a/system/libraries/Upload.php
+++ b/system/libraries/Upload.php
@@ -641,7 +641,7 @@ class CI_Upload {
return FALSE;
}
- if ( ! is_writable($this->upload_path))
+ if ( ! is_really_writable($this->upload_path))
{
$this->set_error('upload_not_writable');
return FALSE;
diff --git a/system/plugins/captcha_pi.php b/system/plugins/captcha_pi.php
index 11d4564d3..693fd9117 100644
--- a/system/plugins/captcha_pi.php
+++ b/system/plugins/captcha_pi.php
@@ -180,7 +180,7 @@ function create_captcha($data = '', $img_path = '', $img_url = '', $font_path =
return FALSE;
}
- if ( ! is_writable($img_path))
+ if ( ! is_really_writable($img_path))
{
return FALSE;
}
diff --git a/user_guide/changelog.html b/user_guide/changelog.html
index c9d26844e..d8a67405e 100644
--- a/user_guide/changelog.html
+++ b/user_guide/changelog.html
@@ -105,6 +105,7 @@ Change Log
<li>Added Compat.php to allow function overrides for older versions of PHP or PHP environments missing certain extensions / libraries</li>
<li>Added memory usage, GET, URI string data, and individual query execution time to Profiler output.</li>
<li>Deprecated Scaffolding.</li>
+ <li>Added is_really_writable() to Common.php to provide a cross-platform reliable method of testing file/folder writability.</li>
</ul>
</li>
@@ -163,7 +164,6 @@ Change Log
<li>Fixed a bug (#3310) with sanitization of globals in the Input class that could unset CI's global variables.</li>
<li>Fixed a bug (#1890) in csv_from_result() where content that included the delimiter would break the file.</li>
<li>Fixed a bug (#3156) in Text Helper highlight_code() causing PHP tags to be handled incorrectly.</li>
- <li>Fixed a bug (#3289) in the File Helper where temp files in directories being tested with is_really_writable() were not being handled properly</li>
<li>Fixed a bug (#3279) where the Email class was sending the wrong Content-Transfer-Encoding for some character sets.</li>
<li>Fixed a bug (#3268) where the Router could leave '/' as the path.</li>
<li>Fixed a series of grammatical and spelling errors in the language files.</li>