cedric813
10-24-2008, 12:23 PM
I think I posted this in the wrong category before so I am reposting it here.
Hi all,
I have this script below that will log the ip address of a user that visits my site to a file called log.php.
<?php putenv("TZ=America/Los_Angeles"); ?>
<?php
define("DATE_FORMAT","d-m-Y H:i:s");
define("LOG_FILE","../administrators/log/log.php");
$logfileHeader='
<html>
<head>
<title></title>
</head>
<body>
<table width="1000" border="0" align="center" cellpadding="0" cellspacing="1" class="ts4">
<tr><th>Username</th><th>Date/Time (PST)</th><th>IP Address</th><th>Hostname</th><th>Track</th></tr>'."\n";
$userIp = $_SERVER['REMOTE_ADDR'];
$hostName = gethostbyaddr($userIp);
$actualTime = date(DATE_FORMAT);
$username = $_REQUEST[uid];
$logEntry = " <tr><td width=150>$username</td><td width=200>$actualTime</td><td width=125>$userIp</td><td>$hostName</td><td width=125><a href=http://www.dnsstuff.com/tools/ipall.ch?domain=$userIp>$userIp</a></td></tr>\n";
if (!file_exists(LOG_FILE)) {
$logFile = fopen(LOG_FILE,"w");
fwrite($logFile, $logfileHeader);
}
else {
$logFile = fopen(LOG_FILE,"a");
}
fwrite($logFile,$logEntry);
fclose($logFile);
?>
The code: $_SERVER['REMOTE_ADDR']; no longer records the user's ip address. Instead the address of a yahoo server is recorded (my website provider). I found a new code that will record the user's ip address, which is located below:
<script language="Javascript" src="http://gd.geobytes.com/gd?after=-1&variables=GeobytesIpAddress"></script>
<script language="Javascript"> document.write(sGeobytesIpAddress);
</script>
How would i go about replacing the $_SERVER['REMOTE_ADDR']; code with the code above. I have tried many things but nothing works. Thank you for any help you can provide,
cedric
Hi all,
I have this script below that will log the ip address of a user that visits my site to a file called log.php.
<?php putenv("TZ=America/Los_Angeles"); ?>
<?php
define("DATE_FORMAT","d-m-Y H:i:s");
define("LOG_FILE","../administrators/log/log.php");
$logfileHeader='
<html>
<head>
<title></title>
</head>
<body>
<table width="1000" border="0" align="center" cellpadding="0" cellspacing="1" class="ts4">
<tr><th>Username</th><th>Date/Time (PST)</th><th>IP Address</th><th>Hostname</th><th>Track</th></tr>'."\n";
$userIp = $_SERVER['REMOTE_ADDR'];
$hostName = gethostbyaddr($userIp);
$actualTime = date(DATE_FORMAT);
$username = $_REQUEST[uid];
$logEntry = " <tr><td width=150>$username</td><td width=200>$actualTime</td><td width=125>$userIp</td><td>$hostName</td><td width=125><a href=http://www.dnsstuff.com/tools/ipall.ch?domain=$userIp>$userIp</a></td></tr>\n";
if (!file_exists(LOG_FILE)) {
$logFile = fopen(LOG_FILE,"w");
fwrite($logFile, $logfileHeader);
}
else {
$logFile = fopen(LOG_FILE,"a");
}
fwrite($logFile,$logEntry);
fclose($logFile);
?>
The code: $_SERVER['REMOTE_ADDR']; no longer records the user's ip address. Instead the address of a yahoo server is recorded (my website provider). I found a new code that will record the user's ip address, which is located below:
<script language="Javascript" src="http://gd.geobytes.com/gd?after=-1&variables=GeobytesIpAddress"></script>
<script language="Javascript"> document.write(sGeobytesIpAddress);
</script>
How would i go about replacing the $_SERVER['REMOTE_ADDR']; code with the code above. I have tried many things but nothing works. Thank you for any help you can provide,
cedric