Page 1 of 1

saving data to a log file

Posted: Tue Jul 02, 2013 12:44 am
by Vegan
I was wondering how easy or hard to open a log file and write results, such as page viewed etc

i have code to find the IP address of the client

Code: Select all

<?php 
echo ' Client IP address: '; 
if ( isset($_SERVER["REMOTE_ADDR"]) )    { 
    echo '' . $_SERVER["REMOTE_ADDR"] . ' '; 
} else if ( isset($_SERVER["HTTP_X_FORWARDED_FOR"]) )    { 
    echo '' . $_SERVER["HTTP_X_FORWARDED_FOR"] . ' '; 
} else if ( isset($_SERVER["HTTP_CLIENT_IP"]) )    { 
    echo '' . $_SERVER["HTTP_CLIENT_IP"] . ' '; 
} 
?>

Re: saving data to a log file

Posted: Tue Jul 02, 2013 3:03 pm
by Christopher
Maybe use an existing class like Analog https://github.com/jbroadway/analog/

Re: saving data to a log file

Posted: Tue Jul 02, 2013 5:34 pm
by Vegan
seems to be overkill, i was thinking opening in the docroot a csv file and write to that

Re: saving data to a log file

Posted: Tue Jul 02, 2013 10:12 pm
by Christopher
Then do that!