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

 

Category: PHP Codes Library >> Analytics & Counters >> Access logs


Code Snippet </> Info


Snippet Name: Access logs

Description: Keep accurate logs of a web page or folder section.

Note: Be sure to create a blank log.txt file for the access logs to be stored.

Author: SnapBuilder <snippets@snapbuilder.com>

Last Modified: 2015-08-26 23:47:33

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

<? // Begin Access Log // == This Script Free To Use Providing This Notice Remains == // == This Script Has Been Found In The http://snapbuilder.com 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


[ Snippet Options ]

 

© 2002 -  Snap Builder Public Codes Library