How to find out who made request in a certain PHP file?

0

I have a PHP file of a legacy system running perfectly on my server that does checks on this system and sends several emails with the found alerts. However, this file runs through Cron Jobs, Scheduled Tasks, etc.

The problem is that I have no idea where this Cron Job is calling the file. But I know where the file is and I can change it.

Is there any way to find out, through the archive, who the client is doing this request ?

    
asked by anonymous 13.03.2014 / 16:31

1 answer

3

You can look at the apache access log file. Generally in linux it is in /var/log/apache2/access.log:

$ grep nome_arquivo.php /var/log/apache2/access.log

Or put in your PHP file to display the IP address of the request source:

if (!empty($_SERVER["HTTP_CLIENT_IP"]))
{
 $ip = $_SERVER["HTTP_CLIENT_IP"];
}
elseif (!empty($_SERVER["HTTP_X_FORWARDED_FOR"]))
{
 $ip = $_SERVER["HTTP_X_FORWARDED_FOR"];
}
else
{
 $ip = $_SERVER["REMOTE_ADDR"];
}

echo $ip;
    
13.03.2014 / 23:28