Happy New Year
[squirrelmail.git] / functions / files.php
index d8959b5fb17c7df83cc41791031202b3c8b6f15a..1d5fe669768ae505bbf4aa25195d872efebf249f 100644 (file)
@@ -6,9 +6,9 @@
  * This file includes various helper functions for working
  * with the server filesystem.
  *
  * This file includes various helper functions for working
  * with the server filesystem.
  *
- * @copyright © 2008-2008 The SquirrelMail Project Team
+ * @copyright 2008-2018 The SquirrelMail Project Team
  * @license http://opensource.org/licenses/gpl-license.php GNU Public License
  * @license http://opensource.org/licenses/gpl-license.php GNU Public License
- * @version $Id$
+ * @version $Id$
  * @package squirrelmail
  */
 
  * @package squirrelmail
  */
 
@@ -263,3 +263,33 @@ function list_files($directory_path, $extensions='', $return_filenames_only=TRUE
 }
 
 
 }
 
 
+/**
+ * Determine if there are lines in a file longer than a given length
+ *
+ * @param string $filename   The full file path of the file to inspect
+ * @param int    $max_length If any lines in the file are GREATER THAN
+ *                           this number, this function returns TRUE.
+ *
+ * @return boolean TRUE as explained above, otherwise, (no long lines
+ *                 found) FALSE is returned.
+ *
+ */
+function file_has_long_lines($filename, $max_length) {
+
+    $FILE = @fopen($filename, 'rb');
+
+    if ($FILE) {
+        while (!feof($FILE)) {
+            $buffer = fgets($FILE, 4096);
+            if (strlen($buffer) > $max_length) {
+                fclose($FILE);
+                return TRUE;
+            }
+        }
+        fclose($FILE);
+    }
+
+    return FALSE;
+}
+
+