Improve email, file & form helpers
diff --git a/system/helpers/file_helper.php b/system/helpers/file_helper.php
index cc9dea2..9b39b8c 100644
--- a/system/helpers/file_helper.php
+++ b/system/helpers/file_helper.php
@@ -1,13 +1,13 @@
-<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
 /**
  * CodeIgniter
  *
  * An open source application development framework for PHP 5.1.6 or newer
  *
  * NOTICE OF LICENSE
- * 
+ *
  * Licensed under the Open Software License version 3.0
- * 
+ *
  * This source file is subject to the Open Software License (OSL 3.0) that is
  * bundled with this package in the files license.txt / license.rst.  It is
  * also available through the world wide web at this URL:
@@ -142,15 +142,11 @@
 
 		while (FALSE !== ($filename = @readdir($current_dir)))
 		{
-			if ($filename != "." and $filename != "..")
+			if ($filename !== '.' and $filename !== '..')
 			{
-				if (is_dir($path.DIRECTORY_SEPARATOR.$filename))
+				if (is_dir($path.DIRECTORY_SEPARATOR.$filename) && $filename[0] !== '.')
 				{
-					// Ignore empty folders
-					if (substr($filename, 0, 1) != '.')
-					{
-						delete_files($path.DIRECTORY_SEPARATOR.$filename, $del_dir, $level + 1);
-					}
+					delete_files($path.DIRECTORY_SEPARATOR.$filename, $del_dir, $level + 1);
 				}
 				else
 				{
@@ -209,12 +205,12 @@
 					$_filedata[] = ($include_path == TRUE) ? $source_dir.$file : $file;
 				}
 			}
+			closedir($source_dir);
+
 			return $_filedata;
 		}
-		else
-		{
-			return FALSE;
-		}
+
+		return FALSE;
 	}
 }
 
@@ -263,13 +259,12 @@
 					$_filedata[$file]['relative_path'] = $relative_path;
 				}
 			}
+			closedir($source_dir);
 
 			return $_filedata;
 		}
-		else
-		{
-			return FALSE;
-		}
+
+		return FALSE;
 	}
 }
 
@@ -391,10 +386,8 @@
 				return $mimes[$extension];
 			}
 		}
-		else
-		{
-			return FALSE;
-		}
+
+		return FALSE;
 	}
 }
 
@@ -414,31 +407,31 @@
 {
 	function symbolic_permissions($perms)
 	{
-		if (($perms & 0xC000) == 0xC000)
+		if (($perms & 0xC000) === 0xC000)
 		{
 			$symbolic = 's'; // Socket
 		}
-		elseif (($perms & 0xA000) == 0xA000)
+		elseif (($perms & 0xA000) === 0xA000)
 		{
 			$symbolic = 'l'; // Symbolic Link
 		}
-		elseif (($perms & 0x8000) == 0x8000)
+		elseif (($perms & 0x8000) === 0x8000)
 		{
 			$symbolic = '-'; // Regular
 		}
-		elseif (($perms & 0x6000) == 0x6000)
+		elseif (($perms & 0x6000) === 0x6000)
 		{
 			$symbolic = 'b'; // Block special
 		}
-		elseif (($perms & 0x4000) == 0x4000)
+		elseif (($perms & 0x4000) === 0x4000)
 		{
 			$symbolic = 'd'; // Directory
 		}
-		elseif (($perms & 0x2000) == 0x2000)
+		elseif (($perms & 0x2000) === 0x2000)
 		{
 			$symbolic = 'c'; // Character special
 		}
-		elseif (($perms & 0x1000) == 0x1000)
+		elseif (($perms & 0x1000) === 0x1000)
 		{
 			$symbolic = 'p'; // FIFO pipe
 		}
@@ -448,19 +441,19 @@
 		}
 
 		// Owner
-		$symbolic .= (($perms & 0x0100) ? 'r' : '-');
-		$symbolic .= (($perms & 0x0080) ? 'w' : '-');
-		$symbolic .= (($perms & 0x0040) ? (($perms & 0x0800) ? 's' : 'x' ) : (($perms & 0x0800) ? 'S' : '-'));
+		$symbolic .= (($perms & 0x0100) ? 'r' : '-')
+			. (($perms & 0x0080) ? 'w' : '-')
+			. (($perms & 0x0040) ? (($perms & 0x0800) ? 's' : 'x' ) : (($perms & 0x0800) ? 'S' : '-'));
 
 		// Group
-		$symbolic .= (($perms & 0x0020) ? 'r' : '-');
-		$symbolic .= (($perms & 0x0010) ? 'w' : '-');
-		$symbolic .= (($perms & 0x0008) ? (($perms & 0x0400) ? 's' : 'x' ) : (($perms & 0x0400) ? 'S' : '-'));
+		$symbolic .= (($perms & 0x0020) ? 'r' : '-')
+			. (($perms & 0x0010) ? 'w' : '-')
+			. (($perms & 0x0008) ? (($perms & 0x0400) ? 's' : 'x' ) : (($perms & 0x0400) ? 'S' : '-'));
 
 		// World
-		$symbolic .= (($perms & 0x0004) ? 'r' : '-');
-		$symbolic .= (($perms & 0x0002) ? 'w' : '-');
-		$symbolic .= (($perms & 0x0001) ? (($perms & 0x0200) ? 't' : 'x' ) : (($perms & 0x0200) ? 'T' : '-'));
+		$symbolic .= (($perms & 0x0004) ? 'r' : '-')
+			. (($perms & 0x0002) ? 'w' : '-')
+			. (($perms & 0x0001) ? (($perms & 0x0200) ? 't' : 'x' ) : (($perms & 0x0200) ? 'T' : '-'));
 
 		return $symbolic;
 	}
@@ -486,6 +479,5 @@
 	}
 }
 
-
 /* End of file file_helper.php */
-/* Location: ./system/helpers/file_helper.php */
\ No newline at end of file
+/* Location: ./system/helpers/file_helper.php */