ADD IP in email Excessive resource usage

20 views Asked by At

I have a system, where several people access it.

Yesterday I started receiving emails (lfd on server: Excessive resource usage).

Time: Tue Apr 6 03:00:08 2021 -0300
Account: xxxxx
Resource: Process Time
Exceeded: 31331 > 1800 (seconds)
Executable: /usr/local/bin/php-cgi
Command Line: /usr/local/bin/php-cgi/home/xxxx/public_html/painel/panel.php
PID: 23728 (Parent PID:14690)
Killed: No

But in the emails you don't have the person's IP.

It is possible to include the IP in this email I receive, or other data such as the Title of the page, as it has the name of the user logged in.

Thanks.

1

There are 1 answers

1
kayes Ibna Qayum On

$_SERVER['REMOTE_ADDR'] - It returns the IP address of the user currently visiting the webpage.

But sometimes the REMOTE_ADDR does not return the IP address of the client, and the main reason behind is the uses of the proxy. In such type of situation, we will try another way to get the real IP address of the user in PHP.

<?php  
    function getIPAddress() {  
    //whether ip is from the share internet  
     if(!emptyempty($_SERVER['HTTP_CLIENT_IP'])) {  
                $ip = $_SERVER['HTTP_CLIENT_IP'];  
        }  
    //whether ip is from the proxy  
    elseif (!emptyempty($_SERVER['HTTP_X_FORWARDED_FOR'])) {  
                $ip = $_SERVER['HTTP_X_FORWARDED_FOR'];  
     }  
//whether ip is from the remote address  
    else{  
             $ip = $_SERVER['REMOTE_ADDR'];  
     }  
     return $ip;  
}  
$ip = getIPAddress();  
echo 'User Real IP Address - '.$ip;  
?>