Jump to content


Photo
- - - - -

VISITOR


  • Please log in to reply
5 replies to this topic

#1 fgd46tgh7ddd

fgd46tgh7ddd

    Young Padawan

  • Members
  • Pip
  • 26 posts
  • Gender:Female

Posted 16 September 2005 - 05:45 AM

Hi

If you have a website and you want to know when a visitor visits your website or if you want to know who is your website visitor or if you want to know your website visitor’s IP address, and more information about visitors, follow this tutorial

1 - If (main page is PHP) {
// add the code below into the php page

<?php
 $browser = $_SERVER['HTTP_USER_AGENT']; // visitor’s browser
 $ip = $_SERVER['REMOTE_ADDR']; // visitor’s IP Address
 $date = date("Y / m / d"); // date of visit
 $time = date("H : i : s"); // time of visit
 $subject = "I’m a Visitor"; // mail subject
 $email = "NRG@PRO "; // it’s not necessary to be a correct address
 $message = " browser = $browser \n ip      = $ip \n date    = $date \n time    = $time";
 mail( "Your Email address Here", "$subject", "$message", "From: $email" );
 ?>

2 - } Else if (main page is not PHP) {
// add the code below into the main page

<p><?php
$browser = $_SERVER['HTTP_USER_AGENT']; // visitor’s browser
 $ip = $_SERVER['REMOTE_ADDR']; // visitor’s IP Address
 $date = date("Y / m / d"); // date of visit
 $time = date("H : i : s"); // time of visit
 $subject = "I’m a Visitor"; // mail subject
 $email = "NRG@PRO "; // it’s not necessary to be a correct address
 $message = " browser = $browser \n ip      = $ip \n date    = $date \n time    = $time";
 mail( "Your Email address Here", "$subject", "$message", "From: $email" );
?></p>

}

Comment it and tell me you problems.

Have fun

Edited by Donna, 16 September 2005 - 08:06 PM.


#2 _*Speed_*

_*Speed_*
  • Guests

Posted 12 February 2006 - 01:05 AM

This is cool but I have a question.

Using this script, will you be sent an email every time someone visits your site? What if the same user visits the same 10 times a day; will 10 emails be sent?

And isnt there a possibility that someone could launch a DoS attack to your site, and if it does send emails per visitor, wont that spam your inbox?

Sorry if I sounded rude but I wanted to know before I use this script.

#3 DanWilliamson

DanWilliamson

    P2L Jedi

  • Members
  • PipPipPip
  • 651 posts

Posted 12 February 2006 - 08:18 AM

Hey,

I think your correct therfore this script isn't much good really I'm sure you could do this through Mint.

- Dan

This is cool but I have a question.

Using this script, will you be sent an email every time someone visits your site? What if the same user visits the same 10 times a day; will 10 emails be sent?

And isnt there a possibility that someone could launch a DoS attack to your site, and if it does send emails per visitor, wont that spam your inbox?

Sorry if I sounded rude but I wanted to know before I use this script.



#4 Arutha

Arutha

    Young Padawan

  • Members
  • Pip
  • 144 posts
  • Gender:Male
  • Location:Southampton, England

Posted 21 February 2006 - 02:38 PM

if you use shared hosting this script would prob get your account locked, depending on how many emails it sends out an hour because most shared hosts will prevent your account from using over a certain percentage off the CPU.

And some explination into what you've actually coded would be good rather than just posting code snippets

Arutha

#5 Joeydabomb

Joeydabomb

    Young Padawan

  • Members
  • Pip
  • 10 posts

Posted 25 February 2006 - 07:20 AM

You could also use:

<?php
$agent = $_SERVER['HTTP_USER_AGENT'];
$uri = $_SERVER['REQUEST_URI'];
$ip = $_SERVER['REMOTE_ADDR'];
$ref = $_SERVER['HTTP_REFERER'];
$host = gethostbyaddr($ip);
$dtime = date('F jS Y, h:iA');

if($agent == ""){
$agent = "None";
}
if($uri == ""){
$uri = "None";
}
if($ip == ""){
$ip = "None";
}
if($host == ""){
$host = "None";
}
if($ref == ""){
$ref = "None";
}
if($dtime == ""){
$dtime = "None";
}


$entry_line = "
[Date] $dtime
[IP] $ip
[Host] $host
[Browser] $agent
[URL] $uri
[Referrer] $ref
---------------------------------------------------
";
$fp = fopen("users.txt", "a");
fputs($fp, $entry_line);
fclose($fp);
?>

This will log every user with the details you want and will save it to a .txt file.

Remember to CHMOD to 777

Edited by Joeydabomb, 25 February 2006 - 07:21 AM.


#6 liveman

liveman

    Young Padawan

  • Members
  • Pip
  • 246 posts
  • Location:New Jersey

Posted 02 March 2006 - 10:40 AM

Actually wouldn't it be easier just to make it put it into a db each time, and then login to an admin panel ...and view it :)




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users