Help with php visitor tracker!

It doesn't work and i need help getting it to work!

Page 1 of 1

0 Replies - 673 Views - Last Post: 11 October 2009 - 01:24 PM Rate Topic: -----

#1 Stephen304  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 40
  • Joined: 27-April 09

Help with php visitor tracker!

Post icon  Posted 11 October 2009 - 01:24 PM

Ive been trying to get a visitor tracker for my website, and i founf a good one, and it looks really useful but i cant get it to work, heres the code:

<!--Logger for website visitor tracking.This program is free software; you can redistribute it and/ormodify it under the terms of the GNU General Public Licenseas published by the Free Software Foundation; either version 2of the License, or (at your option) any later version.This program is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY; without even the implied warranty ofMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See theGNU General Public License for more details.http://www.gnu.org/licenses/gpl.html-->
<?php
// CUSTOMIZATION
$password="mypass"; // the password to view stats
$maxlines = 100; // the maximum number of lines to show
$fn = "log.txt"; // the name of the log file to create
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><html><head><title>Urgentclick.com - Website Visitor Tracker</title></head><body><font face="arial, helvetica, sans-serif">
<?php
// create new file
$fp = fopen ($fn, "r");if (!$fp) {   $fp = fopen ($fn, "w");   if ( $fp ) {   	  $os = "0\r\n";   	  $fw = fwrite($fp, $os);	  fclose($fp);   }} else {   fclose($fp);}
// read existing data
$fa = file($fn);$nl = count($fa);if (isset($page)) {$c = $fa[0] + 1; // inc hit
// write data to file
$fp = fopen ($fn, "w");$os = $c . "\r\n";$fr = fwrite($fp,$os);$ip = getenv("REMOTE_ADDR");$os = $page . "</td><td>" . date("D M jS g:ia") . "</td><td>" . $ip . "</td><td>" . $ref . "\r\n";$fr = fwrite($fp,$os);if ($nl > $maxlines) { $nl = $maxlines; }if ($nl > 1) {   for ($i = 1; $i < $nl; $i++)   	  $fr = fwrite($fp,$fa[$i]); }fclose($fp);} else {
// output results
if (!isset($pass) ) { $pass=""; }if ($pass != $password) {
// get password
echo "<form action=\"tracker.php\"><p>Enter password: <input name=\"pass\" type=\"password\" value=\"\"><input type=\"submit\"></p></form>\n";} else {echo "<h1>Visitor Traffic Report</h1><p><b>Total hits:</b> $fa[0]</p><table cellpadding=10><tr><td><b>Page</b></td><td><b>Date/Time</b></td><td><b>Visitor IP</b></td><td><b>Referring Page (blank if blocked or direct)</b></td></tr>\r\n";if ($nl > 1) {   for ($i = 1; $i < $nl; $i++)   	  echo "<tr><td>$fa[$i]</td></tr>\n"; }echo "</table>\n";}}?><hr><p>From <b>www.urgentclick.com</b> <a href="http://www.urgentclick.com">More Webmaster Resources</a></p></font></body></html>


First thing i had to do is recreate lost line breaks because the guy who put it on his website made most or all line breaks gone causing most of it to be commented out.

This file is supposed to be in /log/tracker.php
The next code is what is pasted on each page:

<script TYPE="text/javascript" LANGUAGE="javascript"><!--var trackerPath = "log/tracker.php";var pageRef = "pics";document.write("<iframe src=\""+trackerPath+"\?page="+ pageRef + "&ref="+document.referrer+"\" width=1 height=1 marginwidth=0 marginheight=0 frameborder=0 scrolling=\"no\"><\/iframe>")//--></SCRIPT>


I had to decapitalize some because XHTML 1.0 trans doesn't have capitalized stuff, and after also chmodding teh log folder to 755, it still doesn't work. Does anyone notice any obvious things that need to be corrected?

This post has been edited by Stephen304: 11 October 2009 - 01:36 PM


Is This A Good Question/Topic? 0
  • +

Page 1 of 1