472,962 Members | 2,386 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,962 software developers and data experts.

problem with REMOTE_ADDR

I want to put a script on my site that shows how many users are online
on my site. I found one, and that is shown below. It also shows a
log with the IP-addresses of those visitors. Buuut... the counter
always stays on 1...
When I look at the log, every visitor seems to have the same
IP-address. When I look up that address, I see it is from the host of
my webspace.

Can someone offer me a solution?
Thanx,

Bart
<?php
################################################## ######################
# Copyright © 2001 Wanja Hemmerich
#
# First version published April 2001 - This version November 2001
#
################################################## ######################
# COPYRIGHT NOTICE
#
# Copyright 2001 Wanja Hemmerich. All rights reserved.
#
#
#
# This program may be used and modified, as long as this copyright
#
# notice stays intact.
#
#
#
# Wanja Hemmerich is not responsible for damage, which is possibly
#
# caused by his program.
#
#
#
# This program code may not be sold, nor auctioneered, nor be used in
#
# any other commercial way in order to make money.
#
#
#
# This Programm may not be distributed to download neither by
#
# Internet, nor by another medium.
#
################################################## ######################
# By using this programm, you agree with these conditions.
#
#
#
################################################## ######################
# The text above must be kept intact under all circumstances.
#
################################################## ######################
include ("./config.php3");

if (!$datei) $datei = dirname(__FILE__)."/$filename";
$time = @time();
$ip = getenv("REMOTE_ADDR");
$string = "$ip|$time\n";
$a = fopen("$filename", "a+");
fputs($a, $string);
fclose($a);

$timeout = time()-(60*$timer);

$all = "";
$i = 0;
$datei = file($filename);
for ($num = 0; $num < count($datei); $num++) {
$pieces = explode("|",$datei[$num]);

if ($pieces[1] > $timeout) {
$all .= $pieces[0];
$all .= ",";
}
$i++;
}

$all = substr($all,0,strlen($all)-1);
$arraypieces = explode(",",$all);
$useronline = count(array_flip(array_flip($arraypieces)));

// display how many people where activ within $timeout
echo $useronline;

// Delete
$dell = "";
for ($numm = 0; $numm < count($datei); $numm++) {
$tiles = explode("|",$datei[$numm]);
if ($tiles[1] > $timeout) {
$dell .= "$tiles[0]|$tiles[1]";
}
}

if (!$datei) $datei = dirname(__FILE__)."/$filename";
$time = @time();
$ip = getenv("REMOTE_ADDR");
$string = "$dell";
$a = fopen("$filename", "w+");
fputs($a, $string);
fclose($a);
?>
Jul 17 '05 #1
3 5699
Try

$_SERVER["REMOTE_ADDR"]

instead.
--
Bob
London, UK
echo Mail fefsensmrrjyaheeoceoq\! | tr "jefroq\!" "@obe.uk"
Jul 17 '05 #2
> Try

$_SERVER["REMOTE_ADDR"]

instead.


the problem remains :s ...
Some other scripts also take the IP from the users, and that works...
Jul 17 '05 #3
bawar wrote:
Try

$_SERVER["REMOTE_ADDR"]

instead.

the problem remains :s ...
Some other scripts also take the IP from the users, and that works...


$_SERVER["REMOTE_ADDR"] gives you your own IP address? That is weird.
Sounds like some funky-ass network configuration your web host is using.
(Like a bad proxy server which only reports its IP.) If so, I don't
think you'll be able to fix that. Web hosts are very stubborn about
fixing their network setups. I'm trying to persuade mine to get the
latest version of PHP 'cause a script I've written depends on a new
function.

Ah, to be able to run a server from home on a fat connection...
--
Bob
London, UK
echo Mail fefsensmrrjyaheeoceoq\! | tr "jefroq\!" "@obe.uk"
Jul 17 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: deko | last post by:
Why is $_SERVER returning multiple IP Addresses? Actually, I'm not sure if it's $_SERVER -- or which if/else statement -- that's the problem, but what I'm getting as a value for $visip looks...
4
by: CPD | last post by:
I can't parse $_SERVER when using the alphabetic key instead of the numeric index of the array. Below is some of the line-numbered code, followed by the corresponding output. For this posting, IP...
5
by: Sachin Singhal | last post by:
Hi All, I am in a bit of fix. In one of my setup, the server REMOTE_ADDR(url = Request.ServerVariables("REMOTE_ADDR")) does not work, itgives a IP address but the wrong one. It does not give the...
6
by: aabrahao | last post by:
Hi, In IIS 6, windows 2003 with php 4.3.11, the code REMOTE_ADDR does not show the IP, but the same page in apache2triad shows the IP. I tried <? $ip = getenv("REMOTE_ADDR"); print $ip; ?>...
3
by: hn | last post by:
I would like to get the visitor's ip address. Which one is the appropriate one to use: Request.ServerVariables("REMOTE_ADDR") or Request.UserHostAddress? Thanks in advance.
2
by: az538 | last post by:
Hello All, I am having a problem with my menu and submenu system. It works like a champ in IE6 and Firefox but IE7 renders the submenus in incorrect positions on the page. Also, the menu system...
3
by: Frank Moyles | last post by:
What is the equivalent for retrieving server side variables? For example in PHP, one such predefined variable is: $_SERVER
1
by: staticfire | last post by:
Hi i am in need of help with an ajax related problem on my site. I've coded an active users list which shows the members and guests online. I'm sure you've all seen active user lists before, like the...
2
by: Henry Stock | last post by:
I don't seem to understand how to use the value: Request.ServerVariables("remote_addr") I am trying to pass the ip address of a sending web client in the body of an email message. When I...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.