mirror of
https://github.com/smarty-php/smarty.git
synced 2025-08-04 10:24:26 +02:00
changed _read_file parameter from $end to $lines
This commit is contained in:
@@ -1068,17 +1068,17 @@ function _run_insert_handler($args)
|
|||||||
|
|
||||||
/*======================================================================*\
|
/*======================================================================*\
|
||||||
Function: _read_file()
|
Function: _read_file()
|
||||||
Purpose: read in a file from line $start to line $end.
|
Purpose: read in a file from line $start for $lines.
|
||||||
read the entire file if $start and $end are null
|
read the entire file if $start and $lines are null.
|
||||||
\*======================================================================*/
|
\*======================================================================*/
|
||||||
function _read_file($filename,$start=null,$end=null)
|
function _read_file($filename,$start=null,$lines=null)
|
||||||
{
|
{
|
||||||
if (!($fd = @fopen($filename, 'r'))) {
|
if (!($fd = @fopen($filename, 'r'))) {
|
||||||
$this->_trigger_error_msg("problem reading '$filename.'");
|
$this->_trigger_error_msg("problem reading '$filename.'");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
flock($fd, LOCK_SH);
|
flock($fd, LOCK_SH);
|
||||||
if($start == null && $end == null) {
|
if($start == null && $lines == null) {
|
||||||
// read the entire file
|
// read the entire file
|
||||||
$contents = fread($fd, filesize($filename));
|
$contents = fread($fd, filesize($filename));
|
||||||
} else {
|
} else {
|
||||||
@@ -1088,14 +1088,14 @@ function _run_insert_handler($args)
|
|||||||
fgets($fd,65536);
|
fgets($fd,65536);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if( $end == null ) {
|
if( $lines == null ) {
|
||||||
// read the rest of the file
|
// read the rest of the file
|
||||||
while(!feof($fd)) {
|
while(!feof($fd)) {
|
||||||
$contents .= fgets($fd,65536);
|
$contents .= fgets($fd,65536);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// read up to $end lines
|
// read up to $lines lines
|
||||||
for ($loop=$start; $loop <= $end; $loop++) {
|
for ($loop=0; $loop < $lines; $loop++) {
|
||||||
$contents .= fgets($fd,65536);
|
$contents .= fgets($fd,65536);
|
||||||
if(feof($fd)) {
|
if(feof($fd)) {
|
||||||
break;
|
break;
|
||||||
|
@@ -1068,17 +1068,17 @@ function _run_insert_handler($args)
|
|||||||
|
|
||||||
/*======================================================================*\
|
/*======================================================================*\
|
||||||
Function: _read_file()
|
Function: _read_file()
|
||||||
Purpose: read in a file from line $start to line $end.
|
Purpose: read in a file from line $start for $lines.
|
||||||
read the entire file if $start and $end are null
|
read the entire file if $start and $lines are null.
|
||||||
\*======================================================================*/
|
\*======================================================================*/
|
||||||
function _read_file($filename,$start=null,$end=null)
|
function _read_file($filename,$start=null,$lines=null)
|
||||||
{
|
{
|
||||||
if (!($fd = @fopen($filename, 'r'))) {
|
if (!($fd = @fopen($filename, 'r'))) {
|
||||||
$this->_trigger_error_msg("problem reading '$filename.'");
|
$this->_trigger_error_msg("problem reading '$filename.'");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
flock($fd, LOCK_SH);
|
flock($fd, LOCK_SH);
|
||||||
if($start == null && $end == null) {
|
if($start == null && $lines == null) {
|
||||||
// read the entire file
|
// read the entire file
|
||||||
$contents = fread($fd, filesize($filename));
|
$contents = fread($fd, filesize($filename));
|
||||||
} else {
|
} else {
|
||||||
@@ -1088,14 +1088,14 @@ function _run_insert_handler($args)
|
|||||||
fgets($fd,65536);
|
fgets($fd,65536);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if( $end == null ) {
|
if( $lines == null ) {
|
||||||
// read the rest of the file
|
// read the rest of the file
|
||||||
while(!feof($fd)) {
|
while(!feof($fd)) {
|
||||||
$contents .= fgets($fd,65536);
|
$contents .= fgets($fd,65536);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// read up to $end lines
|
// read up to $lines lines
|
||||||
for ($loop=$start; $loop <= $end; $loop++) {
|
for ($loop=0; $loop < $lines; $loop++) {
|
||||||
$contents .= fgets($fd,65536);
|
$contents .= fgets($fd,65536);
|
||||||
if(feof($fd)) {
|
if(feof($fd)) {
|
||||||
break;
|
break;
|
||||||
|
Reference in New Issue
Block a user