diff options
author | Derek Jones <derek.jones@ellislab.com> | 2008-01-28 18:11:02 +0100 |
---|---|---|
committer | Derek Jones <derek.jones@ellislab.com> | 2008-01-28 18:11:02 +0100 |
commit | a25530f6594c7ba45b3faa9537fda9f807069759 (patch) | |
tree | dc47713436c3777dcb9eb22f2f08cee4186400f5 /system/codeigniter | |
parent | 15130caa8d3f4650d383647050ce918de728bc53 (diff) |
added is_really_writable() to Common.php, replaced is_writable() throughout application with is_really_writable()
Diffstat (limited to 'system/codeigniter')
-rw-r--r-- | system/codeigniter/Common.php | 38 |
1 files changed, 38 insertions, 0 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
|