D
D
Dmitry Kalinin2016-11-22 19:12:16
linux
Dmitry Kalinin, 2016-11-22 19:12:16

How to track/log requests to php files from the server side?

How to create a log in which one could see which php files were accessed by Apache.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
Mouvdy, 2016-11-22
@Mouvdy

It is also possible through the file system list time file access
stat filename

4
4X_Pro, 2017-07-09
@XXXXPro

If you have VDS, then Apache logs are most likely enabled by default and are located somewhere in /var/log/apache2 or /var/log/httpd. If it's a regular hosting, then most likely it's in the /logs directory at the root.
But on them you can see only the php file that was launched directly, and those connected via include / require will not appear there. If you need to track them too, then use the get_included_files() function, and add a code to the end of each of the called scripts that will write a list of included files to the log.
The code is something like this:

$files = join(',',get_included_files())."\n";
$fh = fopen('php.log','a');
if ($fh) fputs($fh,$files);
fclose($fh);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question