Remember an hp's visitors IP on extra page?

Discussion about the creation of websites in general, HTML, PHP, Java.

Remember an hp's visitors IP on extra page?

Postby d0ppel-D on Thu Aug 17, 2006 12:47 pm

is it possible to create a website that "remembers" its visitors ip and stores it on an extra html page?

it should be like:

visitor (IP XXXXXXXXX) goes on site www.haha.com ... by opening the website his IP XXXXXXXXX is noticed and than put onto a page like www.haha.com/ip.html ...

would be a nice little tool for a page, to scare some of my friends^^

greetz
d0ppel-D
YOU ARE THE SHOGUN CUT THEM INTO PIECES
d0ppel-D
Contributer
Contributer
 
Posts: 31
Joined: Sat Jul 15, 2006 1:51 pm
Location: Germany

Re: Remember an hp's visitors IP on extra page?

Postby x86anonymous on Thu Aug 17, 2006 2:11 pm

It's easy.
You can use my code.Wink

Code: Select all
//on page index.php for example
//write where you want to show the ip of the visitor: Your ip is: <?php include("getip.php"); ?>

//(page: getip.php)
<?php
//by x86anonymous
$filename = "ip.html";
if(file_exists($filename)){
   $size = filesize($filename);
   if($size>0){
      $fd = fopen($filename, "r" );
         $information = fread($fd,$size);
      fclose($fd);
   }
}
$fd = fopen($filename, "w" );
   $time = gettimeofday();
   $information .= "<b>".$_SERVER['REMOTE_ADDR']." :: ".GetHostByAddr($_SERVER['REMOTE_ADDR'])."</b><br />";
   fwrite($fd,$information);
fclose($fd);

echo $_SERVER['REMOTE_ADDR'];
?>

ps: This code also write the hostname of the visitor in the external file.
x86anonymous
Contributer
Contributer
 
Posts: 22
Joined: Mon Aug 07, 2006 5:08 pm
Location: Portugal

Postby DjDarkman on Thu Aug 17, 2006 2:32 pm

Sure ,you need a php script for the job:

Code: Select all
<?php
if (! filesize('ip.html')==0)
{
$ipz=fread('ip.html',filesize('ip.html'));
}
if (! isset($ipz))
{
$ipz='<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><body></body></html>';
}
$ipz=substr($ipz,0,strlen($ipz)-14).$_SERVER['REMOTE_ADDR'].'<br></body></html>';
$wip=fopen('ip.html','w');
fwrite($wip,$ipz);
fclose($wip);
?>


This will do it.

Notes:
The page on wich you put this script must have the extension *.php or the webserver must be configured to allow php code in *.html files ,you can put the script anywhere on your page it doesn`t make any difference to it.

The file "ip.html" or the whole directory that contains it must be writable by the webserver ,this can be accomplished two ways:

-1)you create an empty(it must not contain a single character or the script won`t work properly) file called "ip.html" ,and make it writable by the webserver ,the most simple way to do that is type this command
Code: Select all
chmod 777 ip.html
in your favorite ftp client when you`re in the ftp directory of "ip.html"

-2)the same way as mentioned above you can type a command
Code: Select all
chmod 777 .
,didn`t test this ,but this should make the whole directory writable by the webserver and the script would create the file ,if you do this ,you don`t need to create the empty "ip.html" just type this command.
DjDarkman
Valued Member
Valued Member
 
Posts: 166
Joined: Wed May 24, 2006 9:14 pm

Postby d0ppel-D on Thu Aug 17, 2006 3:41 pm

thx for the damn fast answers

i tried darkmans solution, works quite good

is it possible to store every ip? at the moment, the ip is erased after a new ip connects to the page
YOU ARE THE SHOGUN CUT THEM INTO PIECES
d0ppel-D
Contributer
Contributer
 
Posts: 31
Joined: Sat Jul 15, 2006 1:51 pm
Location: Germany

Postby x86anonymous on Thu Aug 17, 2006 3:49 pm

d0ppel-D wrote:thx for the damn fast answers

i tried darkmans solution, works quite good

is it possible to store every ip? at the moment, the ip is erased after a new ip connects to the page


try my code, it stores every ip. Wink

or if you really like DjDarkman solution, tray it
Code: Select all
<?php
//by DjDarkman
if (!filesize('ip.html')==0)
{
$ipz=fread(fopen('ip.html','r'),filesize('ip.html'));// I think that it works better with fopen('ip.html','r') instead of 'ip.html'  ( line edited by x86anonymous)
}
if (!isset($ipz))
{
$ipz='<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><body></body></html>';
}
$ipz=substr($ipz,0,strlen($ipz)-14).$_SERVER['REMOTE_ADDR'].'<br></body></html>';
$wip=fopen('ip.html','w');
fwrite($wip,$ipz);
fclose($wip);
?>
x86anonymous
Contributer
Contributer
 
Posts: 22
Joined: Mon Aug 07, 2006 5:08 pm
Location: Portugal

Postby DjDarkman on Thu Aug 17, 2006 5:28 pm

x86anonymous was right ,I accidenlty forget the fopen part ,try his version of my code it should work fine.
DjDarkman
Valued Member
Valued Member
 
Posts: 166
Joined: Wed May 24, 2006 9:14 pm

Postby d0ppel-D on Thu Aug 17, 2006 5:33 pm

guys, you are create ^^

maybe you could tell my how to add an timer? so i can see when the ip was added to the page?

thx again

greetz
d0ppel-D
YOU ARE THE SHOGUN CUT THEM INTO PIECES
d0ppel-D
Contributer
Contributer
 
Posts: 31
Joined: Sat Jul 15, 2006 1:51 pm
Location: Germany

Postby d0ppel-D on Thu Aug 17, 2006 5:33 pm

guys, you are create ^^

maybe you could tell my how to add an timer? so i can see when the ip was added to the page?

thx again

greetz
d0ppel-D
YOU ARE THE SHOGUN CUT THEM INTO PIECES
d0ppel-D
Contributer
Contributer
 
Posts: 31
Joined: Sat Jul 15, 2006 1:51 pm
Location: Germany

Postby Samppa on Thu Aug 17, 2006 5:35 pm

There are some great tutorials on logging ips and time recorders if you bothered to open google.com, instead of having to ask all the time.
(\__/)
(='.'=) This is RomMaster's Bunny. Copy and paste bunny into your
(" )_(" ) signature to help him gain world domination.
Samppa
Phoenix Veteran
Phoenix Veteran
 
Posts: 744
Joined: Thu Feb 02, 2006 10:00 am
Location: Finland

Postby DjDarkman on Thu Aug 17, 2006 5:39 pm

Sure ,try this:
Code: Select all
<?php
//by DjDarkman
if (!filesize('ip.html')==0)
{
$ipz=fread(fopen('ip.html','r'),filesize('ip.html'));// I think that it works better with fopen('ip.html','r') instead of 'ip.html'  ( line edited by x86anonymous)
}
if (!isset($ipz))
{
$ipz='<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><body></body></html>';
}
$ipz=substr($ipz,0,strlen($ipz)-14).date('l dS \of F Y h:i:s A').$_SERVER['REMOTE_ADDR'].'<br></body></html>';
$wip=fopen('ip.html','w');
fwrite($wip,$ipz);
fclose($wip);
?>


or if you want something else read http://php.net/manual/en/function.date.php and chose what`s apropriate for you and replace the "date('l dS \of F Y h:i:s A')" part of the code.
DjDarkman
Valued Member
Valued Member
 
Posts: 166
Joined: Wed May 24, 2006 9:14 pm

Postby d0ppel-D on Fri Aug 18, 2006 8:42 am

Samppa wrote:There are some great tutorials on logging ips and time recorders if you bothered to open google.com, instead of having to ask all the time.


i know google, and i now how to use it. but not knowing anything about that (+ beeing from german not knowing the right expression (dictionnairy won't help, believe me ...)) searching for stuff like "ip logging" won't get you far ...


thx again darkman for the quick help

greetz d0ppel-D
YOU ARE THE SHOGUN CUT THEM INTO PIECES
d0ppel-D
Contributer
Contributer
 
Posts: 31
Joined: Sat Jul 15, 2006 1:51 pm
Location: Germany

Postby Samppa on Fri Aug 18, 2006 11:44 am

google.de? Very Happy
(\__/)
(='.'=) This is RomMaster's Bunny. Copy and paste bunny into your
(" )_(" ) signature to help him gain world domination.
Samppa
Phoenix Veteran
Phoenix Veteran
 
Posts: 744
Joined: Thu Feb 02, 2006 10:00 am
Location: Finland

Postby trick on Fri Aug 25, 2006 4:27 pm

BTW, just so you don't get too giddy. There's nothing secret about your IP. It's probably logged dozens of times a day on various webservers. Any time you go to a website you have to tell them you IP (otherwise they would have no way of sending the webpage back to you).
'The military don't start wars. Politicians start wars' - William Westmoreland
Image
trick
Contributer
Contributer
 
Posts: 74
Joined: Mon Aug 07, 2006 6:07 am

Postby DaysAreDone on Fri Aug 25, 2006 8:34 pm

Hence the invention of the proxy. With all the free proxies out there (you still have to be careful because the proxy may log your IP) it is rather quite easy to set one up.

For FireFox, simply find a proxy list and pick one close to you. Then go to Tools -> Options -> General Tab -> Connection Settings -> Manual Proxy Configuration and enter the HTTP Proxy IP and port. Then go to a site like http://www.whatismyip.com and test it.

Disclaimer: Yes, my post does relate to the main topic of this thread, because it shows how easy it is to hide your IP from websites. So you might not want to trust that list of IP's that you collect completely.
DaysAreDone
Contributer
Contributer
 
Posts: 47
Joined: Thu Aug 24, 2006 12:35 am
Location: Washington


Return to General Webmastering

Who is online

Users browsing this forum: No registered users and 1 guest

cron