Location: PHPKode > scripts > SimpleSiteAudit > display_log.php
<?php
/*
  _, _ _, _ __, _,  __,    _, _ ___ __,    _, _,_ __, _ ___  
 (_  | |\/| |_) |   |_    (_  |  |  |_    / \ | | | \ |  |   
 , ) | |  | |   | , |     , ) |  |  |     |~| | | | / |  |   
  ~  ~ ~  ~ ~   ~~~ ~~~    ~  ~  ~  ~~~   ~ ~ `~' ~~  ~  ~   MULTISITE v1.0
 
 */

if( !ini_get('safe_mode') ){
     set_time_limit(60); // 60 secs should cover most sites
}  

$directory_to_monitor = "/htdocs";
$ftp_server = "terryheffernan.net"; 
$ftp_user   = "hide@address.com"; 
$ftp_pw     = "lcwhad123"; 
$route_dir = 'htdocs/';
$logs_dir = 'logs/';
$previous_list = 'previous_list.txt';
$last_run = 'last_run.txt';
$FTPsettings = $logs_dir.$ftp_server.'/FTPsettings.txt';

    // make your FTP connection
$conn_id    = ftp_connect($ftp_server) OR die("<br>unable to establish an FTP connection");
ftp_login($conn_id, $ftp_user, $ftp_pw) OR die("<br>ftp-login failed - User name or password not correct");
    
    $contents = ftp_rawlist($conn_id,$directory_to_monitor,true);   
    $file_list = parse_rawlist( $contents,$route_dir );

ftp_close($conn_id);  
    echo '<link href="css/simplesiteaudit.css" rel="stylesheet" type="text/css">';
    echo '<TABLE class="tab0">';
    echo '<th colspan="7">Web site: '.$ftp_server.'<br /></th>';
    echo '<tr class="logheader"><td>File URL</td><td>File name</td><td>Size</td>
          <td>Day</td><td>Month</td><td>Year</td><td>Time</td></tr>';
    
if(!file_exists($logs_dir.'/'.$ftp_server)){
   mkdir($logs_dir.'/'.$ftp_server,0777,TRUE);
}

$lastrun = fopen($logs_dir.'/'.$ftp_server.'/'.$last_run, 'w');
$d = date('hide@address.com:i:s');
fwrite($lastrun, $d);
fclose($lastrun);

$FTPfile = fopen($FTPsettings, 'w');
$ftp_setts = $ftp_server."\r\n".$ftp_user."\r\n".$ftp_pw."\r\n".$directory_to_monitor."\r\n".$logs_dir."\r\n".$route_dir;
fwrite($FTPfile, $ftp_setts);
fclose($FTPfile);

$prev_list = fopen($logs_dir.'/'.$ftp_server.'/'.$previous_list, 'w');
  
    foreach ($file_list as $value) {

        if($value['file_name'] != "" && $value['file_name'] != '.' && $value['file_name'] != '..'){
            $path = $value['path'];
            $path = str_replace(":", "/", $path);
            $path = str_replace("/htdocs", $ftp_server, $path);
            if(strpos($value[year], ':')){
            $year = date("Y");
            }
            if(strpos($value[file_name], '.')){
            echo '<TR>';
            print "<TD><font color=\"blue\">$path</font></TD>"; // name of file
            print "<TD>$value[file_name]</TD>";
            print "<TD>$value[size]</TD>";
            print "<TD>$value[day]</TD>";
            print "<TD>$value[month]</TD>";
                        
            if(!strpos($value[year], ':')){
              print "<TD>$value[year]</TD>";
              print "<TD></TD>";
              fwrite($prev_list, $path.$value[file_name].'|'.$value[size].'|'.$value[day].'|'.$value[month].'|'.$value[year]."\r\n");
            }else{              
              print "<TD>$year</TD>";
              print "<TD>$value[year]</TD>";
              fwrite($prev_list, $path.$value[file_name].'|'.$value[size].'|'.$value[day].'|'.$value[month].'|'.$value[year]."\r\n");
            }
            echo '</TR>';
            
            }
        } // end if
    
    } // end foreach loop
    fclose($prev_list);
    echo '</TABLE>';


 
 function parse_rawlist( $array,$route_dir ) 
{ 
    $i=0; 
    foreach($array as $curraw) 
    { 
      

        $struc = array(); 
        $current = preg_split("/[\s]+/",$curraw,9); 
        foreach($current as $val){
           if(strpos($val, $route_dir)){
              $path = $val;
              
           }            
        }
     if($path == ""){
         $path = '/'.$route_dir;
     }
        
        //$struc['perms']      =     $current[0]; 
        //$struc['number']     =     $current[1]; 
        //$struc['owner']     =     $current[2]; 
        $struc['path']      =     $path; 
        $struc['size']         =     $current[4]; 
        $struc['month']      =     $current[5]; 
        $struc['day']        =     $current[6];
        $struc['year']        =     $current[7];
        $struc['file_name']      =     $current[8];
        //$struc['unixtime']      =     $current[10];
        
     $structure[$i]      =     $struc; 
    $i++; 
    //}
    }
   return $structure; 

}
?>
Return current item: SimpleSiteAudit