Do a live count while processing logfiles.
Posted: Fri Jul 11, 2003 2:01 pm
Hi.
Im not quite sure where to post this, but i think it should go here.
I´m developing a IIS FTP log analyzer application in php & am wondering about something.
I would like to add a live counter which shows the user how much in procent is done per processing logfile.
My guess is that this has to be done clientside wise. I just don´t know how.
Code for the logfile processing:
Im not quite sure where to post this, but i think it should go here.
I´m developing a IIS FTP log analyzer application in php & am wondering about something.
I would like to add a live counter which shows the user how much in procent is done per processing logfile.
My guess is that this has to be done clientside wise. I just don´t know how.
Code for the logfile processing:
Code: Select all
<?php
// Count Db rows
// Notice to my self. ---> I should use COUNT( id ) below instead.
$fetch_all = mysql_query( "SELECT id FROM `". mysqlTable ."`" ) or die ( mysql_error( ) );
$db_rows = mysql_num_rows( $fetch_all );
$i = '0'; //---> Total Valid Rows in Logfile
$i_1 = '0'; //---> Valid rows after filtering out useless commands.
$i_2 = '0'; //---> Rows Uploaded to database after dupe check
$i_3 = '0'; //---> Total number of files processed
if ( $entry = opendir( "$log_path" ) )
{
echo "<strong>Log Files Path:</strong> ".stripslashes( $log_path )."<br><br>";
while ( false !== ( $file = readdir( $entry ) ) )
{
if ( ( $file != '.' )&&( $file != '..' ) )
{
$rows = file( $log_path.$file ); //---> Full path to current logfile
count( $i_3++ ); //---> Do a file count for each logfile passing through
$e = ( $db_rows - $i_2 );
if( $e < 1 )
{
$e = '0';
}
while( list( $arr ) = each( $rows ) )
{
$valid_lines = substr( $rows[$arr], 0, 1 );
if ( ( $arr != "" )&&( $valid_lines != '#' )&&( $valid_lines != ' ' ) )
{
$v[] = $arr;
count( $i++ );
//Determine Logfile type( W3C or IIS standrad )
if( strpos( $rows[$arr],',',0 ) )
{
IIS_Parse( );
}
else
{
W3C_Parse( );
}
}
}
echo"<br><strong>Filename:</strong>". $file ."<br>
<strong>Total rows in file:</Strong><font color=#990000>". $i ."</font><br>
<strong>Valid rows for processing:</Strong><font color=#990000>". $i_1 ."</font><br>";
}
}
closedir( $entry );
}
?>