ID:               28053
 Updated by:       [EMAIL PROTECTED]
 Reported By:      roberto at spadim dot com dot br
-Status:           Open
+Status:           Bogus
 Bug Type:         Feature/Change Request
 Operating System: ALL
 PHP Version:      Irrelevant
 New Comment:

Sorry, but your problem does not imply a bug in PHP itself.  For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system is not the
appropriate forum for asking support questions. 

Thank you for your interest in PHP.

.


Previous Comments:
------------------------------------------------------------------------

[2004-04-19 06:38:49] roberto at spadim dot com dot br

Description:
------------
<?
// get file size
function fget_filesize(& $fp){
        $old_point=ftell($fp);
        fseek($fp,0,SEEK_END);
        $size=ftell($fp);
        fseek($fp,$old_point,SEEK_SET);
        return($size);
}
// get number of rows
function fget_num_lines(& $fp,$length=1024,$debug = false){
        $old_point=ftell($fp);$buffer="";$pos=0;
        if ($debug)
                echo "BEGIN -- NUM LINES -- ftell->$old_point,
buffer_length=$length\n";
// not working yet.. :_(
// Linha UNIX => 10
// Linha WIN  => 10,13
// Linha MAC  => 13,10
        fseek($fp,0,SEEK_SET);
        $num=0;
        while (true){
                $num+=substr_count(fread($fp, $length),chr(10));
                if (feof($fp)){
                        if ($debug)
                                echo "***** End of File *****\n";
                        break;
                }
        }
        fseek($fp,$old_point,SEEK_SET);
        if ($debug)
                echo "*END* Num Lines: $num\n";
        return($num);
}
// get one line
function fget_line(& $fp,$length=1024,$debug = 0){
        $old_point=ftell($fp);$buffer="";$pos=0;
        if ($debug>0)
                echo "BEGIN -- GET LINE -- ftell->$old_point,
buffer_length=$length\n";
// Linha UNIX => 10
// Linha WIN  => 10,13
// Linha MAC  => 13,10

        while (true){
                $buffer.=fread ($fp, $length);
                $pos=strpos($buffer,chr(10));
                if ($pos>0){
                        if (substr($buffer,$pos-1,1)==chr(13)){ // linha WIN
                                if ($debug>1)
                                        echo "***** WIN Line *****\n";
                                $buffer=substr($buffer,0,$pos-1);$pos++;
                        }elseif (substr($buffer,$pos+1,1)==chr(10)){ // linha MAC
                                if ($debug>1)
                                        echo "***** MAC Line *****\n";
                                $buffer=substr($buffer,0,$pos);$pos+=2;
                        }else{
                                if ($debug>1)
                                        echo "***** UNIX Line *****\n";
                                $buffer=substr($buffer,0,$pos);$pos++;
                        }
                        break;
                }
                if (feof($fp)){
                        if ($debug>1)
                                echo "***** End of File *****\n";
                        $pos=-1;
                        break;
                }
                $pos=0;
        }
        if ($pos==-1)
                fseek($fp,0,SEEK_END);
        else
                fseek($fp,$old_point+$pos,SEEK_SET);
        $new_point=ftell($fp);
        
        if ($debug>2)
                echo "BUFFER length->".strlen($buffer)."\n$buffer\n";
        if ($debug>0)
                echo "*END* ftell->".ftell($fp)."\n";
        
        return($buffer);
}
?>



------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=28053&edit=1

Reply via email to