Mobile app version of vmapp.org
Login or Join
Nimeshi995

: How to determine which files are used by website I recently became responsible for a PHP / HTML / MySQL website. The document structure is full of duplicate files and folders making the site

@Nimeshi995

Posted in: #Html #Php #WebDevelopment

I recently became responsible for a PHP / HTML / MySQL website.

The document structure is full of duplicate files and folders making the site appear more complex than it is.

Is there any tool I can use to process the files and find out which files are used and which are not so that I can purge all the redundant code from the file structure?

Also, can a tool identify if there are any missing files?

10.03% popularity Vote Up Vote Down


Login to follow query

More posts by @Nimeshi995

3 Comments

Sorted by latest first Latest Oldest Best

 

@Karen161

If you want to see the files on a page-by-page basis, use a browser like Chrome that shows the files transferred. In Chrome, right-click on a page and select the "Inspect element" menu item. A new window pane will open in the lower half of the page with tabs named "Elements", "Resource", "Network", etc.

Click on the Network tab and then reload the page. All files transferred over the network will appear in the Name column. At the bottom of the pane are other tabs to group the files by type: Documents, Stylesheets, Images, etc.

If a file is missing, you will see a red 404 in the Status column.

10% popularity Vote Up Vote Down


 

@Steve110

Another possibility is to import all the code into a IDE, and use the refactoring functions; if you try to delete a file they can track if it is included somewere and warn you before deleting it

10% popularity Vote Up Vote Down


 

@Miguel251

There is no way to programmatically analyze the files you have to see which are used. One of the PHP scripts could do something as simple as <a href="<?= $filename ?>.html"> to reference an arbitrary file, and you'd have no way of detecting that that target file was in use.

However, an alternative is to poll the website access logs. If you have logs going back for a sufficient time, you could simply parse out the name of every file that has been served, and assume that any files that have never been served aren't used. I'd recommend moving the "unused" files to a safe place just in case you need to bring one of them back.

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme