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 demonstration gives you an overview of IBM® Rational® Build Forge Express Edition, a global offering that provides a framework to automate and execute software processes. Rational Build Forge provides a software assembly line that can support all of your tools, technologies, and platforms so you can achieve a repeatable, reliable, and traceable build and release process. FREE! Go There Now!
|
|
|
|
Join this Rational Talks to You teleconference, featuring Paul Boustany and Mark Krasovich, to speak to the experts about becoming a Rational ClearCase power user. Get a chance to ask your questions and learn tips and tricks for using Rational ClearCase in Agile development FREE! Go There Now!
|
|
|
|
Visit IBM developerWorks to download IBM DB2 Express-C 9.5, a no-charge version of DB2 Express 9 database server. DB2 Express-C offers the same core data server base features as other DB2 Express editions and provides a solid base to build and deploy applications developed using C/C++, Java, .NET, PHP, and other programming languages. FREE! Go There Now!
|
|
|
|
Discover how IBM Rational AppScan Standard Edition can help you detext vulnerabilities in your web applications in the Web Application Security eKit. IBM Rational AppScan is a leading suite of automated web application security solutions that scan and test for common Web application vulnerabilities. The new Web Application Security eKit provides you with valuable resources, including white papers, demos, and additional information on the benefits of testing your Web applications. FREE! Go There Now!
|
|
|
|
Visit IBM developerWorks to download a free trial version of WebSphere Extended Deployment Compute Grid, which lets you schedule, execute, and monitor batch jobs. Because online transaction processing and batch jobs execute simultaneously on the same server resources, you can avoid costly duplication of resources. Compute Grid supports job types of Java transactional batch, compute-intensive and a new type called "native execution", which enables non-Java workloads to run on distributed end points. FREE! Go There Now!
|
|
|
|
This tutorial shows new users of IBM WebSphere Business Monitor Version 6.0.2 how to perform the "Hello World" equivalent for monitoring business process applications. It is intended to help you get familiar with the capabilities of the product. FREE! Go There Now!
|
|
|
|
Analysts, architects, and developers who have existing COBOL or PL/I skills and want to extend those skills to deploy new workloads on the mainframe can use the IBM Enterprise Modernization Sandbox for System z to find hands-on walkthroughs of common real world scenarios. The scenarios provide examples of how to rapidly design, create, assemble, test, and deploy high-quality Web, Web services, portal, and SOA applications for IBM CICS, IBM IMS, and IBM WebSphere Application Server. FREE! Go There Now!
|
|
|
|
Ken Krugler, co-founder of code search company Krugle, and Laura Merling, vice president of Marketing and Business Development for Krugle, join to talk about the ins and outs of code search and what it means as a new feature for developerWorks users. 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!
|
|
|
|
With IBM Rational Systems Development Solution, you can deliver products faster with higher quality. Within this kit, Read the “Model Driven Systems Development” white paper to see how to improve product quality and communication. Then check out the rest of the e-Kit to learn more about important topics that can affect the success of any software project through customer examples, tutorials, informative Webcasts, and best practices for designing, building and managing systems. From start to finish, at every stage in your projects, Rational Systems Development Solution can help your company reach its full potential. FREE! Go There Now!
|
|
|
|
All FREE IBM® developerWorks Tools! |