summaryrefslogtreecommitdiffstats
path: root/system/helpers/file_helper.php
diff options
context:
space:
mode:
authorEric Roberts <eric@cryode.com>2012-04-15 00:49:21 +0200
committerEric Roberts <eric@cryode.com>2012-04-15 00:49:21 +0200
commit8cefb3ff51de4f023753c0146eb16950f48601a9 (patch)
treeed868ec7a795fcf1fe97efc5642d26dc1d1faefe /system/helpers/file_helper.php
parent0760a48d431fb9ab85f2a0ca9af63aa131e29520 (diff)
parent0f2211711deceb74157d6811116acc0376d3157d (diff)
Merge branch 'develop' of https://github.com/EllisLab/CodeIgniter into feature/form_error_msgs
Conflicts: system/language/english/form_validation_lang.php
Diffstat (limited to 'system/helpers/file_helper.php')
-rw-r--r--system/helpers/file_helper.php29
1 files changed, 10 insertions, 19 deletions
diff --git a/system/helpers/file_helper.php b/system/helpers/file_helper.php
index 2d4b10e37..3a373efd3 100644
--- a/system/helpers/file_helper.php
+++ b/system/helpers/file_helper.php
@@ -2,7 +2,7 @@
/**
* CodeIgniter
*
- * An open source application development framework for PHP 5.1.6 or newer
+ * An open source application development framework for PHP 5.2.4 or newer
*
* NOTICE OF LICENSE
*
@@ -25,8 +25,6 @@
* @filesource
*/
-// ------------------------------------------------------------------------
-
/**
* CodeIgniter File Helpers
*
@@ -44,7 +42,6 @@
*
* Opens the file specfied in the path and returns it as a string.
*
- * @access public
* @param string path to file
* @return string
*/
@@ -90,7 +87,6 @@ if ( ! function_exists('read_file'))
* Writes data to the file specified in the path.
* Creates a new file if non-existent.
*
- * @access public
* @param string path to file
* @param string file data
* @return bool
@@ -123,14 +119,15 @@ if ( ! function_exists('write_file'))
* If the second parameter is set to TRUE, any directories contained
* within the supplied base directory will be nuked as well.
*
- * @access public
* @param string path to file
* @param bool whether to delete any directories found in the path
+ * @param int
+ * @param bool whether to skip deleting .htaccess and index page files
* @return bool
*/
if ( ! function_exists('delete_files'))
{
- function delete_files($path, $del_dir = FALSE, $level = 0)
+ function delete_files($path, $del_dir = FALSE, $level = 0, $htdocs = FALSE)
{
// Trim the trailing slash
$path = rtrim($path, DIRECTORY_SEPARATOR);
@@ -142,21 +139,21 @@ if ( ! function_exists('delete_files'))
while (FALSE !== ($filename = @readdir($current_dir)))
{
- if ($filename !== '.' and $filename !== '..')
+ if ($filename !== '.' && $filename !== '..')
{
if (is_dir($path.DIRECTORY_SEPARATOR.$filename) && $filename[0] !== '.')
{
- delete_files($path.DIRECTORY_SEPARATOR.$filename, $del_dir, $level + 1);
+ delete_files($path.DIRECTORY_SEPARATOR.$filename, $del_dir, $level + 1, $htdocs);
}
- else
+ elseif ($htdocs === TRUE && ! preg_match('/^(\.htaccess|index\.(html|htm|php))$/', $filename))
{
- unlink($path.DIRECTORY_SEPARATOR.$filename);
+ @unlink($path.DIRECTORY_SEPARATOR.$filename);
}
}
}
@closedir($current_dir);
- if ($del_dir == TRUE AND $level > 0)
+ if ($del_dir == TRUE && $level > 0)
{
return @rmdir($path);
}
@@ -173,7 +170,6 @@ if ( ! function_exists('delete_files'))
* Reads the specified directory and builds an array containing the filenames.
* Any sub-folders contained within the specified path are read as well.
*
- * @access public
* @param string path to source
* @param bool whether to include the path as part of the filename
* @param bool internal variable to determine recursion status - do not use in calls
@@ -224,7 +220,6 @@ if ( ! function_exists('get_filenames'))
*
* Any sub-folders contained within the specified path are read as well.
*
- * @access public
* @param string path to source
* @param bool Look only at the top level directory specified?
* @param bool internal variable to determine recursion status - do not use in calls
@@ -278,7 +273,6 @@ if ( ! function_exists('get_dir_file_info'))
* Options are: name, server_path, size, date, readable, writable, executable, fileperms
* Returns FALSE if the file cannot be found.
*
-* @access public
* @param string path to file
* @param mixed array or comma separated string of information returned
* @return array
@@ -345,7 +339,6 @@ if ( ! function_exists('get_file_info'))
* Note: this is NOT an accurate way of determining file mime types, and is here strictly as a convenience
* It should NOT be trusted, and should certainly NOT be used for security
*
- * @access public
* @param string path to file
* @return mixed
*/
@@ -399,7 +392,6 @@ if ( ! function_exists('get_mime_by_extension'))
* Takes a numeric value representing a file's permissions and returns
* standard symbolic notation representing that value
*
- * @access public
* @param int
* @return string
*/
@@ -467,7 +459,6 @@ if ( ! function_exists('symbolic_permissions'))
* Takes a numeric value representing a file's permissions and returns
* a three character string representing the file's octal permissions
*
- * @access public
* @param int
* @return string
*/
@@ -480,4 +471,4 @@ if ( ! function_exists('octal_permissions'))
}
/* End of file file_helper.php */
-/* Location: ./system/helpers/file_helper.php */
+/* Location: ./system/helpers/file_helper.php */ \ No newline at end of file