: 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
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?
More posts by @Nimeshi995
3 Comments
Sorted by latest first Latest Oldest Best
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.
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
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.
Terms of Use Create Support ticket Your support tickets Stock Market News! © vmapp.org2024 All Rights reserved.