Jump to content

Determine which .php files are in use by a site?


roopurt18

Recommended Posts

My current project is something I've inherited from other developers.  One of my ongoing goals is to clean up a lot of the old code and I've made pretty good progress on that front.  However, there are a large number of .php files just floating around that I'm not even sure are being used and others that I know are being used but would like to phase out.  To that end I'm looking for a solution to determine which files are still in use by the site.

I've thought about adding a small routine that I can call at the top of each file which would insert a record into a DB table with path information about the file, the name of the file, and the date it was accessed on.  If the record already exists for that file I'd just update the timestamp for the record; in other words, just one record per file.  I figure after a couple months of recorded data here I can go back and look at which files are good candidates to remove from the webhost.

Would this be the best way to go about doing this?  Or is there an easier method or reporting tool that I can use?  I have shell access to the web server, which is running FreeBSD 4.11.

Thanks in advance!
Link to comment
Share on other sites

[quote author=thorpe link=topic=114193.msg464563#msg464563 date=1162939794]
[quote]I have shell access to the web server, which is running FreeBSD 4.11.[/quote]

Check the logs.
[/quote]

Do you mean the web server logs?  If so, then 'include'd files don't appear, at least not in my logs with 1&1.  Or are you referring to some kind of filesystem-level access logs?  I imagine you could hack up a shell/PHP/whatever script to report on and analyse the 'last accessed' property of files in the project directory, maybe as a cron job?

I think the 'DB-access-log' idea is a great one, in the absence of a (to me at least) unknown shell tool that would do this.  I can't think of anything, which isn't to say it doesn't exist. 

I'd be very interested to hear how you get on with this. :)
Link to comment
Share on other sites

Thorpe, as bqallover mentioned most webserver logs don't include included files; so unless you are speaking of something else I'm not sure that'd help.

Also, I'm not sure how much outside my own personal directory on the server I can browse and look at as I've never really tried.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.