implemented fopen mode constants
diff --git a/system/codeigniter/Common.php b/system/codeigniter/Common.php
index 05720a4..b6a4ce4 100644
--- a/system/codeigniter/Common.php
+++ b/system/codeigniter/Common.php
@@ -46,7 +46,7 @@
{
$file = rtrim($file, '/').'/'.md5(rand(1,100));
- if (($fp = @fopen($file, 'ab')) === FALSE)
+ if (($fp = @fopen($file, FOPEN_WRITE_CREATE_EOF)) === FALSE)
{
return FALSE;
}
@@ -56,7 +56,7 @@
@unlink($file);
return TRUE;
}
- elseif (($fp = @fopen($file, 'ab')) === FALSE)
+ elseif (($fp = @fopen($file, FOPEN_WRITE_CREATE_EOF)) === FALSE)
{
return FALSE;
}
diff --git a/system/helpers/file_helper.php b/system/helpers/file_helper.php
index 1eb8348..2bcb98b 100644
--- a/system/helpers/file_helper.php
+++ b/system/helpers/file_helper.php
@@ -50,7 +50,7 @@
return file_get_contents($file);
}
- if (! $fp = @fopen($file, 'rb'))
+ if (! $fp = @fopen($file, FOPEN_READ_BOF))
{
return FALSE;
}
@@ -85,7 +85,7 @@
*/
if (! function_exists('write_file'))
{
- function write_file($path, $data, $mode = 'wb')
+ function write_file($path, $data, $mode = FOPEN_WRITE_CREATE_BOF)
{
if (! $fp = @fopen($path, $mode))
{
@@ -167,7 +167,7 @@
{
function get_filenames($source_dir, $include_path = FALSE, $_recursion = FALSE)
{
- $_filedata = array();
+ static $_filedata = array();
if ($fp = @opendir($source_dir))
{
diff --git a/system/libraries/Email.php b/system/libraries/Email.php
index 3b4dddd..d71f593 100644
--- a/system/libraries/Email.php
+++ b/system/libraries/Email.php
@@ -1070,7 +1070,7 @@
$attachment[$z++] = $h;
$file = filesize($filename) +1;
- if (! $fp = fopen($filename, 'r'))
+ if (! $fp = fopen($filename, FOPEN_READ_BOF))
{
$this->_set_error_message('email_attachment_unreadable', $filename);
return FALSE;
diff --git a/system/libraries/Log.php b/system/libraries/Log.php
index 247aee1..370ab79 100644
--- a/system/libraries/Log.php
+++ b/system/libraries/Log.php
@@ -97,7 +97,7 @@
$message .= "<"."?php if (!defined('BASEPATH')) exit('No direct script access allowed'); ?".">\n\n";
}
- if (! $fp = @fopen($filepath, "a"))
+ if (! $fp = @fopen($filepath, FOPEN_WRITE_CREATE_EOF))
{
return FALSE;
}
diff --git a/system/libraries/Upload.php b/system/libraries/Upload.php
index f139070..853c162 100644
--- a/system/libraries/Upload.php
+++ b/system/libraries/Upload.php
@@ -741,7 +741,7 @@
return FALSE;
}
- if (! $fp = @fopen($file, 'r+b'))
+ if (! $fp = @fopen($file, FOPEN_READ_WRITE_BOF))
{
return FALSE;
}
diff --git a/system/libraries/Zip.php b/system/libraries/Zip.php
index 4bdc925..6b59880 100644
--- a/system/libraries/Zip.php
+++ b/system/libraries/Zip.php
@@ -301,7 +301,7 @@
*/
function archive($filepath)
{
- if (! ($fp = @fopen($filepath, "wb")))
+ if (! ($fp = @fopen($filepath, FOPEN_WRITE_CREATE_BOF)))
{
return FALSE;
}
diff --git a/user_guide/changelog.html b/user_guide/changelog.html
index 9817d16..615d363 100644
--- a/user_guide/changelog.html
+++ b/user_guide/changelog.html
@@ -72,7 +72,7 @@
<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>
+ <li>Added new user-modifiable file constants.php containing file mode and fopen constants.</li>
<li>Added the ability to set CRLF settings via config in the <a href="libraries/email.html">Email</a> class.</li>
</ul>
</li>