So, I'm new at this stuff, obviously, and I'm attempting to use this script that, when all is said and done, will log the computers IP address that loads the image.
I start with a folder on my FTP called "tracker"
Inside of tracker is another folder called "log"
Files inside of tracker:
moo.gif
track.php
login.htm
admin.php
track.php includes:
<?
$image = "moo.gif" ;
$id = $_GET['id'] ;
$logfile= "log/$id.htm";
$IP = $_SERVER['REMOTE_ADDR'];
$logdetails= date("F j, Y, g:i a") . ': ' . '<a href=http://dnsstuff.com/tools/city.ch?ip='.$_SERVER['REMOTE_ADDR'].'>'.$_SERVER['REMOTE_ADDR'].'</a>';
$imagedir = "" ;
if (isset($image) {
$imagepath = $imagedir.$image ;
$imageinfo = getimagesize( $imagepath );
header( "Content-type: image/jpg" );
@readfile( $imagepath );
if(isset ($_COOKIE['identifier'])){
$visitorid = $_COOKIE['identifier'];
$visitornumber = " Visitor ID: $visitorid";
}
else{
$r1 = rand (0, 9);
$r2 = rand (0, 9);
$r3 = rand (0, 9);
$r4 = rand (0, 9);
$r5 = rand (0, 9);
$r6 = rand (0, 9);
$r7 = rand (0, 9);
$r8 = rand (0, 9);
$r9 = rand (0, 9);
$rnumber = $r1.$r2.$r3.$r4.$r5.$r6.$r7.$r8.$r9;
setcookie("identifier", $rnumber, time()+155520000);
$visitornumber = " Visitor ID: $rnumber";
}
$fp = fopen($logfile, "a");
fwrite($fp, $logdetails.$visitornumber );
fwrite($fp, "<br>");
fclose($fp);
}
else {
header( "HTTP/1.0 404 Not Found" );
exit ;
}
?>
Login.htm:
<html>
<head>
<title>Tracker Login</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<form action="admin.php" method="get"><table width="575" border="0" align="center" cellpadding="5" cellspacing="5">
<!--DWLayoutTable-->
<tr>
<td height="31" colspan="6" valign="top"><div align="center"><strong><font face="Verdana, Arial, Helvetica, sans-serif">Login
Below </font></strong></div></td>
</tr>
<tr>
<td width="33" height="25"></td>
<td width="118"></td>
<td width="80"></td>
<td width="85"></td>
<td width="114"></td>
<td width="50"></td>
</tr>
<tr>
<td height="32"> </td>
<td colspan="2" valign="top"><font face="Verdana, Arial, Helvetica, sans-serif">Enter
your ID number</font></td>
<td colspan="2" valign="top"> <input size="35" name="id" type="text"> </td>
<td></td>
</tr>
<tr>
<td height="17"></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td height="34"></td>
<td></td>
<td colspan="2" align="center" valign="middle"><input type="submit" name="Submit" value="Submit" action="get"></td>
<td> </td>
<td> </td>
</tr>
<tr>
<td height="58"></td>
<td></td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
</table>
</form>
</body>
</html>
admin.php:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Visitor Detail</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<table align="center" width="855" border="0" cellpadding="0" cellspacing="0">
<!--DWLayoutTable-->
<tr>
<td align="center" width="855" height="245">
<?
$id = $_GET['id'] ;
$myFile = "log/$id.htm";
$fh = fopen($myFile, 'r');
$theData = fread($fh, filesize($myFile));
fclose($fh);
echo $theData;
?>
</td>
</tr>
</table>
</body>
</html>
Here is the site that I got the code from:
http://www.soggycowdesigns.com/tests/myspacetracker.htm
And www.theelemethian.com/tracker/info.php is my host info. I use Bluehost.
Here is what I get when I try to login:
Warning: fopen(log/13.htm) [function.fopen]: failed to open stream: No such file or directory in /home2/onethrt5/public_html/theelemethian/tracker/admin.php on line 17
Warning: filesize() [function.filesize]: stat failed for log/13.htm in /home2/onethrt5/public_html/theelemethian/tracker/admin.php on line 18
Warning: fread(): supplied argument is not a valid stream resource in /home2/onethrt5/public_html/theelemethian/tracker/admin.php on line 18
Warning: fclose(): supplied argument is not a valid stream resource in /home2/onethrt5/public_html/theelemethian/tracker/admin.php on line 19
I hope this is just a simple fix, but if it is, I'll feel dumber than I do.
I really appreciate any help that you guys can give.
Thanks!