X-Git-Url: https://vcs.fsf.org/?p=squirrelmail.git;a=blobdiff_plain;f=functions%2Ffiles.php;h=1d5fe669768ae505bbf4aa25195d872efebf249f;hp=13bfe5264d1e3f910935abd223163d67a5da1d40;hb=353d074afac6827c90f4bb03e846c5e453d3b5b1;hpb=591494f42a8e4dc26cdcf9ba75fd2eadc0827d7e;ds=sidebyside diff --git a/functions/files.php b/functions/files.php index 13bfe526..1d5fe669 100644 --- a/functions/files.php +++ b/functions/files.php @@ -6,9 +6,9 @@ * 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 - * @version $Id:$ + * @version $Id$ * @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; +} + +