X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=functions%2Ffiles.php;h=ddcbc88621c480ef827e7519ebf32efa09b4da38;hb=ad2f0b546afcb978ee67ef25332cf4f12c363892;hp=0a297eaaef5992c4599ece3143095e5273f03549;hpb=67c826cef3c0dcbf930606b13b6eadbedabba82c;p=squirrelmail.git diff --git a/functions/files.php b/functions/files.php index 0a297eaa..ddcbc886 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-2012 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; +} + +