• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

How do I 'intercept' all requests with PHP

lozina

Lifer
I want to run a PHP code snippet for every request to any resource under my Apache web server. Basically I want to record their visits to a table as a hit, plus other info.

Now, if this was Java which I am more familiar with, I would code a ServletFilter mapped to all paths and it would just be a class which could access their request data, gather what I want, and save to the database.

Using Apache w/ PHP I do not know how to do this without explicitly adding code to each page. I am hoping there is a way to do this automatically, like ServletFilters.

What are my options?
 
Ok, so it's been a while but I just started playing with this in the past few days.

It looks like this is not exactly working out for me. If I have this enabled to stuff like jpg files, for example, then the jpg files dont work anymore (because of the php code added to it).

what I really need is something that runs some snippet of php code for every request to any resource even if the resource does not exist.

Just like in Java, you can make a ServletFilter and map it to *.*, where no matter what the resource is you can run some Java code for each request.

I guess then PHP does not have anything equivalent to that?
 
You do not have access to the server logs, or they do not record something you are interested in?
 
Back
Top