Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- //ASSIGN VARIABLES TO USER INFO
- $time = date("M j G:i:s Y");
- $ip = getenv('REMOTE_ADDR');
- $userAgent = getenv('HTTP_USER_AGENT');
- $referrer = getenv('HTTP_REFERER');
- $query = getenv('QUERY_STRING');
- //COMBINE VARS INTO OUR LOG ENTRY
- $msg = "IP: " . $ip . " TIME: " . $time . " REFERRER: " . $referrer . " SEARCHSTRING: " . $query . " USERAGENT: " . $userAgent;
- //CALL OUR LOG FUNCTION
- writeToLogFile($msg);
- function writeToLogFile($msg) {
- $today = date("Y_m_d");
- $logfile = $today."_log.txt";
- $dir = 'logs';
- $saveLocation=$dir . '/' . $logfile;
- if (!$handle = @fopen($saveLocation, "a")) {
- exit;
- }
- else {
- if (@fwrite($handle,"$msg\r\n") === FALSE) {
- exit;
- }
- @fclose($handle);
- }
- }
- ?>
Add Comment
Please, Sign In to add comment