A short script that logs visitors to your site by storing information such as IP, Referring URL and query string in a tab (or other character) delimited text file.
By : dinger
<?PHP
##################################################
#Chris Dingman's Hit Tracker
#Version 1.1
#Copyright Chris Dingman 2004 All Rights Reserved
#This script is distributed as shareware. If you use this script, please be sure to register your copy.
#To register, please send $10 check or money order, along with your name and email address to:
#
#Chris Dingman
#B20 Bayshore Drive
#South Amboy NJ 08879
#
#By registering you are signing up for notices regarding updates and new scripts and you help make this script possible.
#If you have any questions about installation, please email chrisdingman@yahoo.com.
#Hit tracking header file
#To use this script, simply include it at the top of all of your .php files on your site. It will create a log text file. Before you do, please be sure to modify the necessary variables below.
#For security purposes, it is recomennded that you store the log file in a non-web accessible directory. You may also wish to make this file non-web accessible as well, but it is not necessary.
#This script should never produce any output to the browser. It is intended solely to log hits to your site.
##################################################
#VARIABLES TO BE MODIFIED
#UNIX Path to Data file - should be non-web accessible if at all possible.
$pathToDataFile = "/usr/local/www/net-cabarett/data/hits.txt";
#Date format. If unsure of how to set it, don't touch it. For more info on how to set it, visit http://us2.php.net/manual/en/function.date.php
$todaysDate=date("D M j g:ia");
#Column separator. Recommended to be a tab or a space but can be anything you want. Leave as a tab to create a tab-delimited file.
$separator = "\t";
#END OF VARIABLES
#Start of script
#Opens log file for writing
$FilePointer=@fopen($pathToDataFile,"a");
#Creates record
$message = $_SERVER['REMOTE_ADDR'].$separator.$todaysDate.$separator.$_SERVER['PHP_SELF'].$separator.$_SERVER['HTTP_USER_AGENT'].$separator.$_SERVER['HTTP_REFERER'].$separator.$_SERVER['REMOTE_HOST'].$separator.$_SERVER['QUERY_STRING']."\n";
#writes record to log file
@fwrite($FilePointer,$message);
#closes log file
@fclose($FilePointer);
#END OF SCRIPT
?>u
| DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware. |
More Counters Code Articles
More By Codewalkers
developerWorks - FREE Tools! |
This whitepaper presents the benefits of successfully introducing static analysis into your organization using IBM Rational Software Analyzer. Additionally, it identifies some common pitfalls that can hinder the effective use of static analysis tooling as well as presents 10 simple strategies designed to help you quickly realize the value of static analysis using Rational Software Analyzer. FREE! Go There Now!
|
|
|
|
Build secure Web services with transport-level security using IBM Rational Application Developer V7 and IBM WebSphere Application Server V6.1. Follow this three-part series for step-by-step instructions about how to develop Web services and clients, configure HTTP basic authentication, and configure HTTP over SSL (HTTPS). This first part of the series walks you through building a Web service for a simple calculator application. You generate and test two different types of Web services clients: a Java Platform, Enterprise Edition (Java EE) client and a stand-alone Java client. You also handle user-defined exceptions in Web services. FREE! Go There Now!
|
|
|
|
Learn how to do more with your reusable assets with the free Rational Asset Manager eKit. The eKit includes demos on how Rational Asset Manager tracks and audits your assets in order to utilize them for reuse. Plus you’ll find white papers and a Webcast that discuss the challenges of a Service Oriented Architecture and how Rational Asset Manager can provide quick and effective solutions. FREE! Go There Now!
|
|
|
|
Rational Build Forge Express Edition is an automation framework that packages the latest enterprise-grade technologies into a reliable, flexible and robust configuration designed and priced specifically for small to midsize businesses. The new Rational Build Forge Express eKit provides you with valuable resources – including a case study, podcast, demo, and articles – to help you increase staff productivity, compress development cycles and deliver better software, fast. FREE! Go There Now!
|
|
|
|
Join this Rational Talks to You teleconference on December 6 at 1:00 pm ET to participate in an agile application development discussion and get your questions answered on using IBM Rational Method Composer in a distributed environment.Get your questions answered! FREE! Go There Now!
|
|
|
|
Learn the basics of the IBM Customer Information Control System (CICS). With a hands-on exercise, learn how to get your first CICS application up and running on your desktop using TXSeries V6.1 for Windows. The tutorial shows you how to download and install a free trial version of TXSeries V6.1. FREE! Go There Now!
|
|
|
|
This whitepaper provides areas to consider when evaluating any software configuration management solution. It addresses how the IBM solutions (Rational ClearCase and Rational ClearQuest) meet the needs and requirements of both project leaders and developers to provide successful Software Change and Configuration Management. FREE! Go There Now!
|
|
|
|
Get a free trial download of the latest version of IBM Rational Tester for SOA Quality V7.0.1, a functional and regression testing tool that enables the creation, comprehension, modification and execution of testing GUI-less Web services. FREE! Go There Now!
|
|
|
|
Join the IBM Watchfire team for an informative discussion on techniques and best practices to proactively manage Web application security and how to effectively build application security testing into the software development lifecycle (SDLC). In this Software Delivery Platform webcast you will learn: How to better understand potential web application security vulnerabilities, best practices and how to effectively integrate application security testing into the software development lifecycle, the importance of detecting and removing software vulnerabilities during application development. FREE! Go There Now!
|
|
|
|
The discipline of assembling and delivering software is maturing beyond standard developer-centric compile/test software builds. The end-to-end software development lifecycle is emerging as the new focus moves “Beyond the Build.” Join this on demand webcast to learn about methods for streamlining software delivery and key capabilities of the IBM Rational Build Forge framework for automating build and release management in environments of any size. FREE! Go There Now!
|
|
|
|
All FREE IBM® developerWorks Tools! |