Snap Builder Public Codes Library
Snap | Generators | Login | Browse | Search | Enter Code | Export Snap Builder Public Codes Library


Category: PHP Codes Library >> Miscellaneous >> Access Log

Code Snippet </> Info

Snippet Name: Access Log

Description: Keeps track of any page, just add the code to the bottom of the page.

Note: There needs to be the log.txt file present for access logs to be stored.

Author: SnapBuilder <>

Last Modified: 2015-08-27 00:02:01

Language: php

Highlight Mode: phphtml

Copy Codes: Use Free Notepad ++
Bookmark and Share

Snap HTML Code Editor:
Paste the source code, make changes and instantly see it in live preview.
Snap HTML Code Editor

  About Copying
Copied To Clipboard!

<? // Begin Access Log // == This Script Free To Use Providing This Notice Remains == // == This Script Has Been Found In The Free Public Codes Library == // == NOTICE: Though This Material May Have Been In A Public Depository, Certain Author Copyright Restrictions May Apply == // Place code at bottom of the page. $ip = getenv("REMOTE_ADDR"); $date = date("D, M n, h:ia"); $txtlog = "./log.txt"; // be sure to create a blank log.txt file $page = $_SERVER[PHP_SELF]; $fp = @fopen($txtlog, "r+") or die("Error occured while opening file."); $filedata = fread($fp, filesize($txtlog)); $mystr = "$ip - $date - $page $filedata" ; rewind($fp); fwrite($fp, $mystr); fclose($fp); ?> // NOTE: // Be sure to create a blank log.txt file for the access logs to be stored // You can create different log.txt files for pages... just rename $txtlog = "./log.txt"; // to log1.txt... etc.

[ Snippet Options ]


© 2002 -  Snap Builder Public Codes Library