Описание: разъясните |
Поиск в теме | Версия для печати |
тёркин василий |
Отправлено: 11 Сентября, 2004 - 10:28:11
|
SecurityAgent
Покинул форум
Сообщений всего: 1197
Дата рег-ции: Май 2004
Откуда: СПРИНГФИЛД
Карма 48
|
Анна,по твоей ссылке про навигацию на сайте,я нашёл интересный скрипт.Как там говорят,он отсылает к тебе на почт. ящик IP адрес,время и что-то ещё посетителя твоего сайта.Ниже я привожу его код.Кто знает куда там надо вписать адрес почты?И насколько это реально?
CODE:
#! /usr/local/bin/perl
# mail-log.cgi
#
# Version 2.03 -- 27 Jan 1997
# http://www.all-yours.net/scripts/
# Perl (release 4 or 5) script for Unix servers
# Written by Walter Soldierer of All-Yours Internet Solutions
# (hermes@all-yours.net), one of the authors of
#
# THE DIGITAL POSTCARD
#
# A FREE service to increase your web site's exposure!
# Need more hits?
# Check it out at http://www.all-yours.net/postcard/
# This script saves access date+time, the visitor's host name, their IP
# address and browser type, and the refering page (if any) to a log file
# on your server (default name = logfile.txt). This file will be automatically
# mailed to your mailbox. You can change the mailing interval according
# to your needs (default value is every 50 accesses to the page to be
# logged). The script will autocreate the logfile, if it does not exist.
# ----- BEGIN INSTALLATION INSTRUCTIONS -----
# - Save this script to a file mail-log.cgi
# - Cut installation instructions (optional)
# - Change the first script line, if your server's Perl executable
# is not located in /usr/local/bin/perl
# - Customize the settings below (*SETTINGS*)
# * Change e-mail address for $recipient
# * Set $log_page to 1 if you also want to log the page that
# called this script. Recommended in case you want to log accesses
# to more than one HTML page.
# * Set $max_entries to your needs, if you want to have more or less
# than 50 log entries mailed to your mailbox each time.
# * Change path/filename for log file, if necessary
# (default = logfile.txt in your cgi directory)
# * Change values for $check_host and $interval, if necessary
# * Change filename for host/time file, if necessary (default = hosttime.txt)
# - ASCII-upload mail-log.cgi to your cgi directory (cgi-bin, cgi-local...)
# Make it executable (chmod mail-log.cgi 755)
# - add the following line (Server Sde Include) to the page(s) to be logged
# (after the <body> tag):
# <!--#exec cgi="/your-cgi-directory/mail-log.cgi"-->
# HTML pages with Server Side Include tags often need to have the
# file extension ".shtml" !!!! (don't forget to update
# all links to this page(s) accordingly)
# (You should test the script with a test.shtml page first)
# - Load the logged page(s) with your browser.
# - View your new logfile
# It should look something like this:
#
# Time: 05/30/96 14:44:07 EDT
# Host: your.host.and.domain
# Addr: 123.45.67.89
# With: Mozilla/1.22 (compatible; MSIE 2.0; Windows 95)
# Page: test.shtml
# From: [no entry here, if you accessed your page directly (otherwise Yahoo etc.)]
#
# If the script doesn't work and you want to contact us, please check
# the following first:
# - did you upload the script in ASCII mode (*not* binary)?
# - did you chmod the script 755
# - does your server support the "exec cgi" Server Side Include?
# - did you rename the html file to .shtml
# - did you check the path to your server's Perl executable?
#
# If you still have a problem and you want us to help you, we need to know:
# - a detailed description of your problem
# - your script's settings section
# - html code and file name for the page to be logged
# - script related error messages from your server's error log file
# ----- END INSTALLATION INSTRUCTIONS -----
# -----------------------------------------------------------------------
# *SETTINGS* to customize this script:
# Your email address (within single quotes!):
$recipient = 'xxxx@yyyy.com';
# Do you want to log the .shtml page's file name?
# (recommended when more than one poage is logged)
# 1 = the .shtml page that called this script will be logged
# 0 = the .shtml page that called this script will not be logged
$log_page = 1;
# Do you want to log your visitor's IP number?
# The script attemps to call a domain name server in order to resolve
# IP addresses (such as 132.45.323.5) to a host name (such as yourdomain.com)
# However, resolving IP addressses doesn't work 100 per cent so you
# might also want to log rhe IP addresses.
# 1 = IP addresses will be logged
# 0 = IP addresses will be discarded
$log_IP = 1;
# Number of logged visits mailed to your mailbox at a time:
$max_entries = 50;
# Change logfile name if necessary:
$logfile = 'logfile.txt';
# server's sendmail directory:
$mailprogam = '/usr/lib/sendmail';
# If you set $check_host = "1" the script attempts not
# to log multiple page reloads.
# When a page was accessed from the same host by using the same
# browser, this visit will only be logged after the time
# interval specified in $interval.
# Example: You set $interval to 1800 (seconds). If there was no
# access from a different host in the meantime, a visitor from the
# same host who uses the same browser will only be logged when s/he
# accesses your page 30 minutes after visitor one.
# In other words: If someone reloads the page many times, in most cases
# s/he needs to wait 30 minutes after each reload to make your log file
# grow. When you set $check_host to 0 even the reloads will be logged.
$check_host = 1; # set to zero if you don't like this feature
# If you set the $check_host variable to 1, specify a time interval to
# ignore page reloads
$interval = 600; # seconds!
# If you set the $check_host variable to 1, change the name of the file
# that temporarily stores host and time information (if necessary)
$hostfile = 'hostfile.txt';
# don't change anything past this line unless you know what you are doing
# -----------------------------------------------------------------------
# create a date+time string
$shortdate = `date +"%D %T %Z"`;
chop ($shortdate);
# Some of Perl's network info functions required here
($part1,$part2,$part3,$part4)=split(/\./,$ENV{REMOTE_ADDR});
$IP_adr=pack("C4",$part1,$part2,$part3,$part4);
($host_name)=(gethostbyaddr("$IP_adr", 2));
print "Content-type: text/plain\n\n";
if ($check_host) {
# read host and time info from last visitor
if (-e "$hostfile") {
open(HOST,"$hostfile");
$hostline = <HOST>;
chop($hostline) if $hostline =~ /\n$/;
close(HOST);
($old_time,$old_number,$old_page,$old_browser) = split(/\|/,$hostline);
}
# save host and time info and check if this is a page reload
open(HOST,">$hostfile");
$seconds = time;
print HOST "$seconds\|$ENV{REMOTE_ADDR}\|$ENV{'DOCUMENT_URI'}\|$ENV{'HTTP_USER_AGENT'}";
close(HOST);
if (time - $old_time < $interval
&& $ENV{REMOTE_ADDR} eq $old_number
&& $ENV{'DOCUMENT_URI'} eq $old_page
&& $ENV{'HTTP_USER_AGENT'} eq $old_browser) {
exit; # probably same visitor, so exit
}
}
# open log file for output and append new log data
open (LOGFILE, ">>$logfile");
print LOGFILE "Time: $shortdate\n";
print LOGFILE "From: $ENV{'HTTP_REFERER'}\n";
print LOGFILE "IP : $ENV{REMOTE_ADDR}\n" if $log_IP;
print LOGFILE "Host: $host_name\n";
print LOGFILE "With: $ENV{'HTTP_USER_AGENT'}\n";
print LOGFILE "Page: $ENV{'DOCUMENT_URI'}\n" if $log_page;
print LOGFILE "\n";
close (LOGFILE);
# open log file for input and count log entries
open (LOGFILE, $logfile);
@entries = <LOGFILE>;
close (LOGFILE);
$log_rows = 7;
$log_rows-- unless $log_page;
$log_rows-- unless $log_IP;
$log_count = @entries/$log_rows;
# if number of logs >= max. number of logs, mail file and delete it
if ($log_count >= $max_entries) {
open (MAIL, "|$mailprogam $recipient") || die "Can't open $mailprogam!\n";
print MAIL "Subject: Mail-log File\n\n";
print MAIL "@entries\n";
close MAIL;
unlink $logfile;
}
# end of script
|
|
|
|
Поиск в теме | Версия для печати |
Страниц (3): [1] 2 3 » |
Сейчас эту тему просматривают: 3 (гостей: 3, зарегистрированных: 0, скрытых: 0) |
« PHP/Perl » |
Все гости форума могут просматривать этот раздел. Только администраторы и модераторы могут создавать новые темы в этом разделе. Только администраторы и модераторы могут отвечать на сообщения в этом разделе.
|
|
|