[Solved] Programmatically identify PHP and ASP include dependencies [closed]

[ad_1]

Many thanks to @Progrock for pointing me to checking last accessed time for files in target folder. This is what I had to do.

Ensure capturing last accessed time is being set by Windows (see Directory.GetFiles keeping the last access time)

Process.Start("fsutil", "behavior set disablelastaccess 0").WaitForExit();

Also need to restart IIS to stop any cached in memory files

Process.Start("IISRESET").WaitForExit();

A refresh on FileInfo needs to be performed to ensure you get the correct last accessed time (see How can System.IO.FileSystemInfo.Refresh be used).

This resulted in the following code …

var start = DateTime.UtcNow;
Process.Start("fsutil", "behavior set disablelastaccess 0").WaitForExit();
Process.Start("IISRESET").WaitForExit();
//do work that will access folder. i.e. access IIS web pages
var files = Directory.GetFiles(iisPath, "*.*", SearchOption.AllDirectories).ToList();
files = files.Where(x =>
{
  var fileInfo = new FileInfo(x);
  fileInfo.Refresh();
  return fileInfo.LastAccessTimeUtc >= start;
}).ToList();   

I can use this list of files to identify all .ASP and .PHP and any other files that were accessed via the IIS server on page requests.

[ad_2]

solved Programmatically identify PHP and ASP include dependencies [closed]