Click to See Complete Forum and Search --> : ip address....


tanfwc
11-21-2003, 11:12 PM
i need a script that actually display the user ip address...it is best that i can use the code from my server...but i do not know how...

General server information:
Operating system Linux
Service Status Click to View
Kernel version 2.4.20-8
Apache version 1.3.29 (Unix)
PERL version 5.8.0
Path to PERL /usr/bin/perl
Path to sendmail /usr/sbin/sendmail
Installed Perl Modules Click to View
PHP version 4.3.3
MySQL version 4.0.15-standard
cPanel Build 8.5.3-STABLE 3
Theme cPanel X v2.2.5
Documentation Click to View

Sexay_Hamster
11-21-2003, 11:33 PM
<?

$IP = $_SERVER['REMOTE_ADDR'];

echo $IP

?>

tanfwc
11-21-2003, 11:37 PM
thanx for the code...erm...then how do i log each visitor ip address each visit to my web site? can i store it in a txt file and also show the time and date....?

tanfwc
11-22-2003, 12:27 AM
Originally posted by Sexay_Hamster
<?

$IP = $_SERVER['REMOTE_ADDR'];

echo $IP

?>

erm...it does not show the correct IP address as i see from my WAN configurations page...

Jupac
11-22-2003, 12:29 AM
this is the one i use for my site


<?
$log_file = "ip.txt";
$hourdiff = "-8";
$timeadjust = ($hourdiff * 60 * 60);
$date = date("l, d F Y \t h:i a",time() + $timeadjust);
$ie = getenv('HTTP_USER_AGENT');
$ip = getenv('REMOTE_ADDR');
$ia = $_SERVER["HTTP_REFERER"];
$fp = fopen("$log_file", "a");
fputs($fp, "$iprn");
flock($fp, 3);
fwrite($fp,$date);
fwrite($fp,"\t");
fwrite($fp,$ip);
fwrite($fp,"\t\t");
fwrite($fp,$ie);
fwrite($fp,"\t");
fwrite($fp,$ia);
fwrite($fp,"\n");
fclose($fp);
PRINT("Your Ip was logged $ip <br>");
?>

it could be better it gets ip,brownser,reffer,and time/date

tanfwc
11-22-2003, 12:36 AM
Originally posted by lakers01
this is the one i use for my site


<?
$log_file = "ip.txt";
$hourdiff = "-8";
$timeadjust = ($hourdiff * 60 * 60);
$date = date("l, d F Y \t h:i a",time() + $timeadjust);
$ie = getenv('HTTP_USER_AGENT');
$ip = getenv('REMOTE_ADDR');
$ia = $_SERVER["HTTP_REFERER"];
$fp = fopen("$log_file", "a");
fputs($fp, "$iprn");
flock($fp, 3);
fwrite($fp,$date);
fwrite($fp,"\t");
fwrite($fp,$ip);
fwrite($fp,"\t\t");
fwrite($fp,$ie);
fwrite($fp,"\t");
fwrite($fp,$ia);
fwrite($fp,"\n");
fclose($fp);
PRINT("Your Ip was logged $ip <br>");
?>

it could be better it gets ip,brownser,reffer,and time/date

thanx for the code...but the problem is that the ip address is wrong...it show 203.x.x.x but it is suppose to be 210.x.x.x

Jupac
11-22-2003, 12:37 AM
it because ur behide a proxey

tanfwc
11-22-2003, 12:40 AM
Originally posted by lakers01
it because ur behide a proxey

no...if it it behind proxy...it show pacnet123.xxxx erm....203 and 210 are two different ISP ip lease add...

Jupac
11-22-2003, 12:42 AM
hmm it works for me rite
wats your url

tanfwc
11-22-2003, 12:48 AM
Originally posted by lakers01
hmm it works for me rite
wats your url

erm...the site is http://www.tanfwc.com/ip.php ...later then u try...i am currently experiencing downtime on my server...

tanfwc
11-23-2003, 02:48 AM
Originally posted by tanfwc
erm...the site is http://www.tanfwc.com/ip.php ...later then u try...i am currently experiencing downtime on my server...

site is up...can help me try and feedback to me and see what happen...thanx...

Jupac
11-23-2003, 10:16 AM
umm 404eroor i think or somethnig bout hot link

tanfwc
11-23-2003, 06:47 PM
Originally posted by lakers01
umm 404eroor i think or somethnig bout hot link

erm...i delete the www.tanfwc.com/ip.php ...actually you will be redirected to the main page that i have put the ip logger there...anyway...the main page is www.tanfwc.com ...thank you...

tanfwc
11-23-2003, 07:29 PM
erm...i have notice that the time is difference...i change to +8 which is my time zone...and it is still wrong...why?

Jupac
11-23-2003, 08:47 PM
it not time zone it hours off the server time

Jupac
11-23-2003, 08:50 PM
umm the ip is right also

tanfwc
11-24-2003, 12:25 AM
Originally posted by lakers01
it not time zone it hours off the server time

i have tune the time alr...ty...

tanfwc
11-24-2003, 12:27 AM
Originally posted by lakers01
umm the ip is right also

i dun get the right ip...

tanfwc
11-25-2003, 06:09 AM
Originally posted by lakers01
it not time zone it hours off the server time

???

Jupac
11-25-2003, 08:22 PM
it is not time zone it is instead hours off the servers time

tanfwc
11-25-2003, 08:56 PM
Originally posted by lakers01
it is not time zone it is instead hours off the servers time

ty...erm...anyway...i manage to hours off the correct timing...ty...

tanfwc
12-07-2003, 08:37 PM
how to spilt the log file by date...which means one day one log file...

Jupac
12-07-2003, 08:39 PM
woo duno how ask pyro

tanfwc
12-07-2003, 08:41 PM
hmmm....pyro...please come in....

Sux0rZh@jc0rz
12-08-2003, 07:29 AM
sidenote:
why do you use tables for your site? it's a wretched mess of evil! use div's and CSS instead! makes your webpage much more accessible.

tanfwc
12-08-2003, 08:30 AM
Originally posted by Sux0rZh@jc0rz
sidenote:
why do you use tables for your site? it's a wretched mess of evil! use div's and CSS instead! makes your webpage much more accessible.

i will try...thank you...

DanUK
12-08-2003, 08:39 AM
Are you sure you're not seeing a proxy server's IP or suchlike which your ISP might make you use?
I know with NTL:Business a little while ago, we were forced to use a proxy server, so any "IP" tool I used in PHP would echo that proxy server's IP.

tanfwc
12-08-2003, 08:41 AM
Originally posted by skydan
Are you sure you're not seeing a proxy server's IP or suchlike which your ISP might make you use?
I know with NTL:Business a little while ago, we were forced to use a proxy server, so any "IP" tool I used in PHP would echo that proxy server's IP.

i change my server from US to Singapore. And i think the US server got problem. Now i am not having any problem logging people IP address..

pyro
12-08-2003, 09:51 AM
Do you still need help splitting the log file by date? If so, post a sample of how the log file looks, or perhaps a link to the actual file.

tanfwc
12-08-2003, 08:21 PM
Originally posted by pyro
Do you still need help splitting the log file by date? If so, post a sample of how the log file looks, or perhaps a link to the actual file.

i am using this script...

<?
$log_file = "ip.txt";
$hourdiff = "-8";
$timeadjust = ($hourdiff * 60 * 60);
$date = date("l, d F Y \t h:i a",time() + $timeadjust);
$ie = getenv('HTTP_USER_AGENT');
$ip = getenv('REMOTE_ADDR');
$ia = $_SERVER["HTTP_REFERER"];
$fp = fopen("$log_file", "a");
fputs($fp, "$iprn");
flock($fp, 3);
fwrite($fp,$date);
fwrite($fp,"\t");
fwrite($fp,$ip);
fwrite($fp,"\t\t");
fwrite($fp,$ie);
fwrite($fp,"\t");
fwrite($fp,$ia);
fwrite($fp,"\n");
fclose($fp);
PRINT("Your Ip was logged $ip <br>");
?>

Paul Jr
12-08-2003, 08:44 PM
This is kinda on the same subject. So...

Is there anyway to keep the same IP from being logged twice?

tanfwc
12-08-2003, 08:49 PM
Originally posted by Paul Jr
This is kinda on the same subject. So...

Is there anyway to keep the same IP from being logged twice?

hmmm....if you do not refresh....then it i will not log...anywhere logging same ip address means he visited twice lor..

Paul Jr
12-08-2003, 09:07 PM
Yes, yes I know. I only need someone's IP logged once, so I do not want the same IP logged more than once, even if the person visits the site more than one time.

tanfwc
12-08-2003, 09:13 PM
Originally posted by Paul Jr
Yes, yes I know. I only need someone's IP logged once, so I do not want the same IP logged more than once, even if the person visits the site more than one time.

ask pyro...

pyro
12-08-2003, 09:52 PM
tanfwc - I meant the ip.txt file.

Paul Jr. - Just rip through the ip.txt file and check if the current IP address is already entered.

tanfwc
12-08-2003, 10:49 PM
Originally posted by pyro
tanfwc - I meant the ip.txt file.

Paul Jr. - Just rip through the ip.txt file and check if the current IP address is already entered.

Saturday, 06 December 2003 03:05 pm 220.255.125.xxx Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.1.4322)

pyro
12-08-2003, 11:03 PM
$date = "Saturday, 06 December"; #date to find
foreach ($array_of_lines as $line) {
if (preg_match("/$date/", $line)) {
echo $str1."<br>";
}
}

tanfwc
12-09-2003, 07:44 PM
Originally posted by pyro
$date = "Saturday, 06 December"; #date to find
foreach ($array_of_lines as $line) {
if (preg_match("/$date/", $line)) {
echo $str1."<br>";
}
}

hmmm....i think this script only separate this day "Saturday, 06 December" only rite? i wan everyday, the script automatically generate a log file named 06 December 2003

Kyleva2204
12-09-2003, 08:41 PM
Ok so u want a log file for the day? ok easy man lemme rip it up fo u :)


<?php
////////////////////////////////////////////////
// Script Created By: Kyle Kirby //
// Email: kyleva2204@rctsilver.com //
// Email2: eviljester@rctsilver.com //
////////////////////////////////////////////////
$show_IP_warning = "1"; // 1 = show 0 = dont show //
$IPLogloc = ""; // Location to log. You can also include a begining part like 'logs/mylogs_' and it will put it in the dir logs and the file will be called mylogs_Tuesday, 09 December 2003.txt
$showip = "1"; // Show the IP address in the IP warning. 1 = Yes 0 = no
$Text1 = "Your IP has been logged! :: "; // If Show Warning is on, use this to disply the text before the IP address is show if show IP address is on.
$Text2 = " ::"; // The text after the IP addres
$hour_differance = "-8";
//////// Do not need to edit anymore /////////
$time = ($hourdiff * 60 * 60);
$date = date("l, d F Y \t h:i a",time() + $time);
$date2 = date("l, d F Y",time());
$IP = getenv('REMOTE_ADDR');
$all = "$IP :: $date
-----------------------------
";
$IP_Log = "$IPLogloc$date2.txt";
////
function createfile(){
$fpn = fopen($IP_Log, "w");
touch($fpn);
}
if (!file_exists($IP_Log)){
createfile();
}
else {
$fr = fopen($IP_Log, "r");
while (!feof($fr)) {
$IP_current = fread($fr, 1024);
$current_ips = $IP_current;
}
}
////

////
if (!strchr($current_ips, "$IP")){
$fp = fopen($IP_Log, "a");
flock($fp, 3);
fwrite($fp, $all);
fclose($fp);
}
if ($show_IP_warning == "1"){
print "$Text1";
if ($showip == "1"){
print "$IP";
}
print "$Text2";
}
?>

der u go :) just configure it and ur set!


Originally posted by tanfwc
hmmm....i think this script only separate this day "Saturday, 06 December" only rite? i wan everyday, the script automatically generate a log file named 06 December 2003

tanfwc
12-09-2003, 09:11 PM
can double check ur script? i got a error...i cannot seem to save in this directory...

/var/www/html/misc/log/

Kyleva2204
12-09-2003, 09:16 PM
did u create the directory log?Originally posted by tanfwc
can double check ur script? i got a error...i cannot seem to save in this directory...

/var/www/html/misc/log/

tanfwc
12-09-2003, 09:20 PM
Originally posted by Kyleva2204
did u create the directory log?

yes...

tanfwc
12-09-2003, 09:22 PM
test the script at www.tanfwc.com/test.php

Kyleva2204
12-09-2003, 09:22 PM
ok yea didnt think u were that stupid. but is it chmod to 777?Originally posted by tanfwc
yes...

Kyleva2204
12-09-2003, 09:23 PM
no sry 755 :POriginally posted by tanfwc
test the script at www.tanfwc.com/test.php

tanfwc
12-09-2003, 09:25 PM
it is chmod 755

Kyleva2204
12-09-2003, 09:27 PM
HMM WTF it should work. it works fine for me: http://rctsilver.com/ip2.php and it saves it to the dir: http://rctsilver.com/logs/
I really have no clue... Lemme look at ur test page agian.

Originally posted by tanfwc
it is chmod 755

tanfwc
12-09-2003, 09:31 PM
i also dunno what is happening...

Kyleva2204
12-09-2003, 09:32 PM
have you changed anything in the script like the dir or sumtin? if so try deleteing the data in the varable: $IPLogloc just leave it blank, and see what happens.Originally posted by tanfwc
i also dunno what is happening...

Kyleva2204
12-09-2003, 09:35 PM
hmmmm thiz could be Warning: fopen(var/www/html/misc/log/Wednesday, 10 December 2003.txt): failed to open stream: No such file or directory in /var/www/html/test.php on line 41.

Now just checking is it suppsed to be pointing to misc/log??

tanfwc
12-09-2003, 09:37 PM
now if u go to www.tanfwc.com/test.php ...u should not see any problem....but under the directory, it is not logged to /var/www/html/misc/log ...it is logged to /var/www/html/ ...

Kyleva2204
12-09-2003, 09:39 PM
hmm weird... just create a directory called logs and point it to 'logs/' and see what happens.Originally posted by tanfwc
now if u go to www.tanfwc.com/test.php ...u should not see any problem....but under the directory, it is not logged to /var/www/html/misc/log ...it is logged to /var/www/html/ ...

tanfwc
12-09-2003, 09:41 PM
if the folder is empty,

this error message appear..


Warning: touch(): Unable to create file because No such file or directory in /var/www/html/test.php on line 25

after do a refresh...thing look fine...

Kyleva2204
12-09-2003, 09:46 PM
ok does it create a file? if no then try chmoding the dir to 755 because some servers have different properties.. I thinkOriginally posted by tanfwc
if the folder is empty,

this error message appear..


Warning: touch(): Unable to create file because No such file or directory in /var/www/html/test.php on line 25

after do a refresh...thing look fine...

tanfwc
12-09-2003, 09:48 PM
Originally posted by Kyleva2204
ok does it create a file? if no then try chmoding the dir to 755 because some servers have different properties.. I think

it create a file after the second refresh...hmm...

Kyleva2204
12-09-2003, 09:54 PM
weird i dont understand it. Anyway I have to go, do you have an AIM,MSN,ICQ,Yahoo addy? if so e-mail it to me: eviljester@rctsilver.com and I'll help ya tomarrow if no one else does but they prb will..Originally posted by tanfwc
it create a file after the second refresh...hmm...

Kyleva2204
12-09-2003, 11:52 PM
Ok im not quite sure if this is the soultion but U can try it..

<?php
////////////////////////////////////////////////
// Script Created By: Kyle Kirby //
// Email: kyleva2204@rctsilver.com //
// Email2: eviljester@rctsilver.com //
////////////////////////////////////////////////
$show_IP_warning = "1"; // 1 = show 0 = dont show //
$IPLogloc = ""; // Location to log. You can also include a begining part like 'logs/mylogs_' and it will put it in the dir logs and the file will be called mylogs_Tuesday, 09 December 2003.txt
$showip = "1"; // Show the IP address in the IP warning. 1 = Yes 0 = no
$Text1 = "Your IP has been logged! :: "; // If Show Warning is on, use this to disply the text before the IP address is show if show IP address is on.
$Text2 = " ::"; // The text after the IP addres
$hour_differance = "-8";
//////// Do not need to edit anymore /////////
$time = ($hourdiff * 60 * 60);
$date = date("l, d F Y \t h:i a",time() + $time);
$date2 = date("l, d F Y",time());
$IP = getenv('REMOTE_ADDR');
$all = "$IP :: $date
-----------------------------
";
$IP_Log = "$IPLogloc$date2.txt";
////
function createfile(){
$fpn = fopen($IP_Log, "w");
touch($IP_Log);
fclose($fpn);
}
if (!file_exists($IP_Log)){
createfile();
}
else {
$fr = fopen($IP_Log, "r");
while (!feof($fr)) {
$IP_current = fread($fr, 1024);
$current_ips = $IP_current;
}
}
////

////
if (!strchr($current_ips, "$IP")){
$fp = fopen($IP_Log, "a");
flock($fp, 3);
fwrite($fp, $all);
fclose($fp);
}
if ($show_IP_warning == "1"){
print "$Text1";
if ($showip == "1"){
print "$IP";
}
print "$Text2";
}
?>

tanfwc
12-09-2003, 11:53 PM
can u kindly include the path also?

this is the path

/var/www/html/misc/log

tanfwc
12-09-2003, 11:55 PM
can contact me in MSN? easily like that...

Kyleva2204
12-09-2003, 11:57 PM
ok as far as I know this one is the best.. I did a little editing and made it faster...

<?php
////////////////////////////////////////////////
// Script Created By: Kyle Kirby //
// Email: kyleva2204@rctsilver.com //
// Email2: eviljester@rctsilver.com //
////////////////////////////////////////////////
$show_IP_warning = "1"; // 1 = show 0 = dont show //
$IPLogloc = ""; // Location to log. You can also include a begining part like 'logs/mylogs_' and it will put it in the dir logs and the file will be called mylogs_Tuesday, 09 December 2003.txt
$showip = "1"; // Show the IP address in the IP warning. 1 = Yes 0 = no
$Text1 = "Your IP has been logged! :: "; // If Show Warning is on, use this to disply the text before the IP address is show if show IP address is on.
$Text2 = " ::"; // The text after the IP addres
$hour_differance = "-8";
//////// Do not need to edit anymore /////////
$time = ($hourdiff * 60 * 60);
$date = date("l, d F Y \t h:i a",time() + $time);
$date2 = date("l, d F Y",time());
$IP = getenv('REMOTE_ADDR');
$all = "$IP :: $date
-----------------------------
";
$IP_Log = "$IPLogloc$date2.txt";
////
function createfile(){
$fpn = fopen($IP_Log, "w");
touch($IP_Log);
fclose($fpn);
}
if (!file_exists($IP_Log)){
createfile();
}
else {
$fr = fopen($IP_Log, "r");
while (!feof($fr)) {
$IP_current = fread($fr, 1024);
$current_ips = $IP_current;
}
}
////

////
if (!strchr($current_ips, "$IP")){
$fp = fopen($IP_Log, "a");
flock($fp, 3);
fwrite($fp, $all);
fclose($fp);
}
if ($show_IP_warning == "1"){
print "$Text1";
if ($showip == "1"){
print "$IP";
}
print "$Text2";
}
?>

tanfwc
12-09-2003, 11:59 PM
Originally posted by Kyleva2204
ok as far as I know this one is the best.. I did a little editing and made it faster...

<?php
////////////////////////////////////////////////
// Script Created By: Kyle Kirby //
// Email: kyleva2204@rctsilver.com //
// Email2: eviljester@rctsilver.com //
////////////////////////////////////////////////
$show_IP_warning = "1"; // 1 = show 0 = dont show //
$IPLogloc = ""; // Location to log. You can also include a begining part like 'logs/mylogs_' and it will put it in the dir logs and the file will be called mylogs_Tuesday, 09 December 2003.txt
$showip = "1"; // Show the IP address in the IP warning. 1 = Yes 0 = no
$Text1 = "Your IP has been logged! :: "; // If Show Warning is on, use this to disply the text before the IP address is show if show IP address is on.
$Text2 = " ::"; // The text after the IP addres
$hour_differance = "-8";
//////// Do not need to edit anymore /////////
$time = ($hourdiff * 60 * 60);
$date = date("l, d F Y \t h:i a",time() + $time);
$date2 = date("l, d F Y",time());
$IP = getenv('REMOTE_ADDR');
$all = "$IP :: $date
-----------------------------
";
$IP_Log = "$IPLogloc$date2.txt";
////
function createfile(){
$fpn = fopen($IP_Log, "w");
touch($IP_Log);
fclose($fpn);
}
if (!file_exists($IP_Log)){
createfile();
}
else {
$fr = fopen($IP_Log, "r");
while (!feof($fr)) {
$IP_current = fread($fr, 1024);
$current_ips = $IP_current;
}
}
////

////
if (!strchr($current_ips, "$IP")){
$fp = fopen($IP_Log, "a");
flock($fp, 3);
fwrite($fp, $all);
fclose($fp);
}
if ($show_IP_warning == "1"){
print "$Text1";
if ($showip == "1"){
print "$IP";
}
print "$Text2";
}
?>


thanx...

Kyleva2204
12-09-2003, 11:59 PM
><
___

It didnt copy OMG! Oh well I'll double check to make sure its the right code. :P mah bad.


<?php
////////////////////////////////////////////////
// Script Created By: Kyle Kirby //
// Email: kyleva2204@rctsilver.com //
// Email2: eviljester@rctsilver.com //
////////////////////////////////////////////////
$show_IP_warning = "1"; // 1 = show 0 = dont show //
$IPLogloc = ""; // Location to log. You can also include a begining part like 'logs/mylogs_' and it will put it in the dir logs and the file will be called mylogs_Tuesday, 09 December 2003.txt
$showip = "1"; // Show the IP address in the IP warning. 1 = Yes 0 = no
$Text1 = "Your IP has been logged! :: "; // If Show Warning is on, use this to disply the text before the IP address is show if show IP address is on.
$Text2 = " ::"; // The text after the IP addres
$hour_differance = "-8";
//////// Do not need to edit anymore /////////
$time = ($hourdiff * 60 * 60);
$date = date("l, d F Y \t h:i a",time() + $time);
$date2 = date("l, d F Y",time());
$IP = getenv('REMOTE_ADDR');
$all = "$IP :: $date
-----------------------------
";
$IP_Log = "$IPLogloc$date2.txt";
////
function createfile(){
$fpn = fopen($IP_Log, "w");
touch($IP_Log);
fclose($fpn);
}
if (!file_exists($IP_Log)){
createfile();
}
else {
$fr = fopen($IP_Log, "r");
while (!feof($fr)) {
$IP_current = fread($fr, 1024);
$current_ips = $IP_current;
}
fclose($fr);
}
////

////
if (!strchr($current_ips, "$IP")){
$fp = fopen($IP_Log, "a");
flock($fp, 3);
fwrite($fp, $all);
fclose($fp);
}
if ($show_IP_warning == "1"){
print "$Text1";
if ($showip == "1"){
print "$IP";
}
print "$Text2";
}
?>


Ok yea use this one.

tanfwc
12-10-2003, 12:02 AM
same problem...

Kyleva2204
12-10-2003, 12:08 AM
arhhhhhOriginally posted by tanfwc
same problem...

tanfwc
12-10-2003, 12:09 AM
Originally posted by Kyleva2204
arhhhhh

sorry...

BWWebDesigns
04-09-2007, 04:35 PM
Just curious to know the method you used to get your ip info page that shows city state country and long lat etc

Im in need of something similar with similar maping use and i wondered how you did yours

Thanks

Kyleva2204
04-09-2007, 04:47 PM
Just curious to know the method you used to get your ip info page that shows city state country and long lat etc

Im in need of something similar with similar maping use and i wondered how you did yours

Thanks
Who are you asking? "How you did yours"

BWWebDesigns
04-09-2007, 04:50 PM
Check the subject of my post To tanfwc how did you get ip info like location

tanfwc
04-10-2007, 12:49 AM
Check the subject of my post

check this out

http://www.maxmind.com/app/ip-location

BWWebDesigns
04-10-2007, 02:13 AM
thanks

mvleandro
04-10-2007, 08:52 AM
Conheça o meu blog: http://www.prosadigital.com

Conteúdo javascript!

Espero que eu possa contribuir com todos!
Não deixe de assinar o feed!