diff --git a/NEWS b/NEWS index 6640a6ca..c512c26f 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,4 @@ + - removed unused functionality to load a subset of lines from a file (messju) - fix is_secure() should only check if a file is_readable, not if the directory where it is in is readable (sagi, messju) - fix problem displaying debug console when $default_resource_type diff --git a/libs/Config_File.class.php b/libs/Config_File.class.php index 8e0e9efd..2a6c9604 100644 --- a/libs/Config_File.class.php +++ b/libs/Config_File.class.php @@ -240,7 +240,7 @@ class Config_File { return false; } - $contents = fread($fp, filesize($config_file)); + $contents = ($size = filesize($config_file)) ? fread($fp, $size) : ''; fclose($fp); $this->_config_data[$config_file] = $this->parse_contents($contents); diff --git a/libs/Smarty.class.php b/libs/Smarty.class.php index a9a049ca..37203326 100644 --- a/libs/Smarty.class.php +++ b/libs/Smarty.class.php @@ -1702,39 +1702,15 @@ class Smarty * @param integer $lines * @return string */ - function _read_file($filename, $start=null, $lines=null) + function _read_file($filename) { - if (!($fd = @fopen($filename, 'r'))) { + if ($fd = @fopen($filename, 'rb')) { + $contents = ($size = filesize($filename)) ? fread($fd, $size) : ''; + fclose($fd); + return $contents; + } else { return false; } - flock($fd, LOCK_SH); - if ($start == null && $lines == null) { - // read the entire file - $contents = fread($fd, filesize($filename)); - } else { - if ( $start > 1 ) { - // skip the first lines before $start - for ($loop=1; $loop < $start; $loop++) { - fgets($fd, 65536); - } - } - if ( $lines == null ) { - // read the rest of the file - while (!feof($fd)) { - $contents .= fgets($fd, 65536); - } - } else { - // read up to $lines lines - for ($loop=0; $loop < $lines; $loop++) { - $contents .= fgets($fd, 65536); - if (feof($fd)) { - break; - } - } - } - } - fclose($fd); - return $contents; } /**