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! |
Learn field-tested SOA principles, methodology, technology and implementation from the global SOA market leader - in a new e-book by an IBM SOA expert. Written by IBM Certified SOA Solution Designer Bobby Woolf, "Exploring IBM SOA Technology & Practice" is the ultimate insider's guide to SOA - a PDF e-book packed cover to cover with IBM's specific advice on how to make your SOA implementation a success. FREE! Go There Now!
|
|
|
|
Building a software-as-a-service solution requires addressing a few key technical challenges. In this webcast, we'll focus on the role of IBM Tivoli Directory Server and WebSphere Portlet Factory in creating a Software as a Service solution. We will demonstrate how to use Tivoli Directory Server to prevent the user population of one tenant from accessing the virtual portal and portlet components of another tenant. We will also use the dynamic profile capability of WebSphere Portlet Factory to create multiple highly customized applications from one code base. FREE! Go There Now!
|
|
|
|
Download a free trial version of IBM DB2 9.5 for Linux, UNIX, and Windows. DB2 9 is the result of a five-year development project that transformed traditional (static) database technology into an interactive data server that merges the high performance and ease of use of DB2 with the self-describing benefits of XML. FREE! Go There Now!
|
|
|
|
Visit IBM developerWorks to download the latest trial version of IBM Data Studio V1.1 at no cost. IBM Data Studio is a comprehensive data management solution that helps you effectively design, develop, deploy and manage your data, databases, and database applications throughout the data management life cycle utilizing a consistent and integrated user interface. Unlike other client-side data management solutions that focus on only one aspect of the application lifecycle or database administration, Data Studio complements the Rational Software Delivery platform, providing unparalleled flexibility for a heterogeneous data server environment across platforms. FREE! Go There Now!
|
|
|
|
Download a free trial version of IBM Rational Software Analyzer Developer Edition V7.0 to identify bug defects earlier in the software development cycle. Rational Software Analyzer is an extensible software development solution that reduces the expense of bug-fixes by enabling static analysis code reviews and bug identification very early in the development cycle. 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!
|
|
|
|
Learn how Rational Build Forge can extend a simple compile and package build process by adding customization and deployment capability. Go from a manual method to automating: checking for code changes; getting the latest source; compiling and packaging; customizing; copying to and restarting a deployment server; and sending e-mail notification that a new version is available. FREE! Go There Now!
|
|
|
|
This Fall, IBM Rational talks to you directly through a special teleconference series giving you access to the best minds in IBM Rational - product experts and market thought leaders who will answer your questions during these pre-scheduled telephone conference calls. Register today! FREE! Go There Now!
|
|
|
|
The Eclipse community is constantly working to extend Eclipse's functionality. In this webcast, learn about some of the most important and feature-rich projects under development. From multi-language support to plug-in development, tune in to see what Eclipse is capable of now. FREE! Go There Now!
|
|
|
|
User communities play an important role in communication and collaboration around products, solutions and other areas of special interest to members. Successful communities are able to provide the right mix of content and services to deliver a value proposition that resonates with each audience. Join Tom Inman, VP of Marketing for Information and Platform Solutions as he introduces the new LeverageINFORMATION community. During this webcast, learn about the value provided by the community and how customers and partners derive value from the community in addressing their own technical and business challenges. FREE! Go There Now!
|
|
|
|
All FREE IBM® developerWorks Tools! |