X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=functions%2Ffiles.php;h=8318ff27129bff59dcd8bd4008a0b2e68052a8de;hb=30460a05016c7e066ad7b28df7788539e4054a99;hp=0a297eaaef5992c4599ece3143095e5273f03549;hpb=1856156617348e9bef0c1a596611b01b52848589;p=squirrelmail.git diff --git a/functions/files.php b/functions/files.php index 0a297eaa..8318ff27 100644 --- a/functions/files.php +++ b/functions/files.php @@ -6,7 +6,7 @@ * This file includes various helper functions for working * with the server filesystem. * - * @copyright © 2008-2008 The SquirrelMail Project Team + * @copyright 2008-2009 The SquirrelMail Project Team * @license http://opensource.org/licenses/gpl-license.php GNU Public License * @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; +} + +