How do I 'intercept' all requests with PHP

lozina

Lifer
Sep 10, 2001
11,711
8
81
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?
 

lozina

Lifer
Sep 10, 2001
11,711
8
81
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?
 

Aluvus

Platinum Member
Apr 27, 2006
2,913
1
0
You do not have access to the server logs, or they do not record something you are interested in?