Counters Code
  Home arrow Counters Code arrow Adv. Log file generator
Codewalker Forums 
  Tutorials  
Database Articles  
Miscellaneous  
Navigation Usability  
PEAR Articles  
Programming Basics  
Server Administration  
XML Tutorials  
  Reviews  
Database Book Reviews  
Linux Book Reviews  
Miscellaneous Reviews  
PHP Book Reviews  
PHP Software Reviews  
Server Admin Reviews  
SQL Tool Reviews  
  Code Gallery  
Content Management Code  
Contest Code  
Counters Code  
Database Code  
Date Time Code  
Discussion Board Code  
Email Code  
File Manipulation Code  
GUI Code  
Link Farm Code  
Miscellaneous Code  
Search Code  
Site Navigation Code  
User Management Code  
Forums Sitemap 
Download TestComplete 
JMSL Numerical Library 
IBM® developerWorks
Weekly Newsletter 
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
COUNTERS CODE

Adv. Log file generator
By: Codewalkers
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 1
    2003-04-14

    Table of Contents:

    Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    Set as your index.php and then change the $goto variable to your main entrance page. You can view the log either by downloading the Comma Seperated File it creates or you can type index?view and it will show you a nice little table generated from the Comma Seperated File.

    By : Rock

    <?php
    /*/-----------------------------------------\
    |Original Name : reflog.php |
    | Author : Neil |
    | Function : Generate a log of IP No.s |
    | and Exact Referring pages and the user |
    | agent after checking the HTTP_REFERER |
    | for a small expresstion. (Useful for |
    | checking the for a domain name in the |
    | HTTP_REFERER and then geting the entire|
    | path) |
    | You could run case or elseif's to run |
    | the check from multiple domains or |
    | expressions. You could get an exact |
    | log of refering pages if you were |
    | advertising, like in the original |
    | script, at Yell.co.uk. |
    \-----------------------------------------/

    Definition of variables
    Logstring is the string to insert in to the
    logfile
    The log file name is specified by filename
    regexp is the expression to search for in the
    URL
    */
    $date = gmdate("d/m/Y - H:i:s T"); //change to preffered format.
    $logstring = $date.",".$HTTP_SERVER_VARS['REMOTE_ADDR'].",".$HTTP_SERVER_VARS['HTTP_REFERER'].",".$HTTP_SERVER_VARS['HTTP_USER_AGENT']."\r";
    $regexp = strtoupper("yell.co.uk"); //String to filter for.
    $filename = "./reflog.csv";

    /*
    No cache!!
    */
    $goto = "http://www.yoursite.com/main.html";
    header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past
    header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
    // always modified
    header("Cache-Control: no-store, no-cache, must-revalidate"); // HTTP/1.1
    header("Cache-Control: post-check=0, pre-check=0", false);
    header("Pragma: no-cache"); // HTTP/1.0
    /*
    End of No cache
    */


    function viewlog($filename) {
    $fp = fopen($filename,"r");
    $file = fread($fp,65535);
    $replaced = eregi_replace(",", "<td>", $file);
    $replaced2 = eregi_replace("\n", "<tr><td>", $replaced);
    $replaced3 = eregi_replace("\r", "<tr><td>", $replaced2);
    fclose($fp);

    return $replaced3;
    }
    if(isset($view)) {
    echo "<html><head><base href=\"./\"><title>Referer Log</title></head><body bgcolor=silver>";
    echo "<table border=0 bordercolor=black cellspacing=0 cellpadding=5 width=100% style='font-size:10pt'><tr><td><b>Date & Time</b><td><b>IP No.</b><td><b>Referring page</b><td><b>user agent</b><tr><td>";
    echo viewlog($filename);
    echo "</table></body></html>";
    exit;
    }
    else if (ereg($regexp, strtoupper($HTTP_SERVER_VARS['HTTP_REFERER']))) {
    $fp=fopen($filename, "a");
    if(!$fp) die ("Error opening file");

    fwrite($fp, $logstring);
    fclose($fp);
    }

    header("Location: $goto");
    ?>
    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

     

    IBM® developerWorks developerWorks - FREE Tools!


    NEW! Best practices for software analysis: An introduction to the IBM Rational Software Analyzer application

    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!


    NEW! Discovering the value of WebSphere Process Server

    WebSphere Process Server delivers a unique integration framework that simplifies existing IT resources. Often, as IT assets grow to support business demand, so too does their complexity and manageability. In this webcast, we’ll discuss how WebSphere Process Server helps deliver an SOA infrastructure that provides a common model to orchestrate, mediate, connect, map, and execute the underlying IT functions. Discover how WebSphere Process Server simplifies integration of business processes by leveraging existing IT assets as reusable services without the complexities of traditional integration methodologies.
    FREE! Go There Now!


    NEW! Evaluate WebSphere Extended Deployment Compute Grid V6.1

    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!


    NEW! Hello World: WebSphere Service Registry and Repository

    Manage, govern, and share services across your organization by using WebSphere Service Registry and Repository. Follow the hands-on exercises to learn how to navigate the Web interface to publish, find, reuse, and update services.
    FREE! Go There Now!


    NEW! IBM Enterprise Modernization Sandbox for System z

    IBM Enterprise Modernization solutions help organizations evolve core IT systems towards modern architectures and technologies—reducing the burden of maintenance and freeing up resources to develop new business requirements and capabilities. With the IBM Enterprise Modernization Sandbox for System z you can evaluate IBM Enterprise Modernization solutions focused on five key areas: Assets, Architectures, Skills, Processes and Infrastructures, and Investment. Each solution is based upon real customer experiences and offers a proven path to get you started with your modernization projects.
    FREE! Go There Now!


    NEW! IBM Rational ClearCase Innovator's Series

    Learn from the best! Find out how developers use Rational ClearCase to be more flexible, innovative and deliver higher quality code in the Rational ClearCase Power Users eKit. This complimentary eKit provides a collection of materials, like articles, whitepapers, and demos that can help you become a power user of Rational ClearCase.
    FREE! Go There Now!


    NEW! Krugle, developerWorks, and code search

    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!


    NEW! Project and Portfolio Management Executive Resource Kit

    Portfolio Management is about effectively managing portfolio value by aligning portfolio investments with business goals. This complimentary e-kit provides a collection of materials that can help you understand how IBM Rational enables and automates best practices for improved governance and clear visibility into portfolio and project performance across the entire IT project lifecycle.
    FREE! Go There Now!


    NEW! Try the IBM SOA Sandbox for Connectivity

    Visit IBM developerWorks to try the IBM SOA Sandbox for connectivity. The SOA Sandbox for connectivity provides a trial environment with the tooling and components to help you explore how to effectively connect your infrastructure and integrate all of the people, processes and information in your company. Use the hosted sandbox to explore SOA techniques that streamline connecting existing IT assets together, as well as learn how to connect them to new business logic.
    FREE! Go There Now!


    NEW! Webcast: Calling All Testers! Find Application Vulnerabilities Early in the Development Process Where they are Easier to Fix and Less Risky to your Business

    In this webcast, IBM Rational will discuss the importance of Web application security and will share techniques and best practices to introduce application security testing into current QA processes including: understanding common security vulnerabilities and techniques to integrate security testing with defect tracking and remediation systems in an effort to safeguard sensitive online information.
    FREE! Go There Now!



    All FREE IBM® developerWorks Tools!

    COUNTERS CODE ARTICLES

    - TG Who's Online
    - Text Based Counter that formats output
    - Counter & visitor statistics
    - Server Uptime Statistics
    - Chris Dingman's Hit Tracker Script
    - Graph Maker Function
    - Simple userOnline class
    - Adv. Log file generator
    - Logwriter
    - time_left()
    - Basic Statistics
    - Easy Counter
    - countCodeLines
    - MySQL Counter
    - bandwidthmeter





    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway
    Stay green...Green IT