Приглашаем посетить
Easy Log
#!/usr/bin/perl
# EasyLog version 1.2 beta
# Written by Dave Palmer <dave@upstatepress.com>
# http://www.upstatepress.com/dave/perl.html
##################################################################
# EasyLog writes to an HTML file each time someone visits one #
# of your pages. EasyLog can be used on any or all pages, just #
# as long as you have the required: <!--#exec cgi="/..."--> in #
# your html file (and named with a: .shtml extension). EasyLog #
# can also be customized to notify you which page specifically #
# has been accessed by making copies of EasyLog, and adjusting #
# the message in "print FILE" statements and making adjustments #
# in the: <!--#exec cgi="/..."--> to reflect each variation of #
# the EasyLog copies (i.e. have: easylog1.cgi, easylog2.cgi etc. #
# to correspond with what ever page is using a given easylog #
# file.) Consult the README file for installation instructions! #
##################################################################
#required changes:
$mailprog = '/usr/sbin/sendmail';
$my_name = 'Dave Palmer';
$my_email = 'upstate@pair.com';
$date = '/bin/date';
$logfile = "/usr/home/upstate/public_html/easylog/easylog.html";
############### That's it! You'll all set to go! #################
#print the header
print "Content-type: text/html\n\n";
#get the date
&get_date;
open(FILE, "$logfile") || die "I can't open $linkpage\n";
@lines = <FILE>;
close(FILE);
$sizelines = @lines;
open (FILE, ">$logfile") || die "I can't open that now\n";
for ($a = 0; $a <= $sizelines; $a++) {
$_ = $lines[$a];
if (/<!--begin-->/) {
print FILE "<!--begin-->\n";
print FILE "EasyLog reports that someone visited one<br>\n";
print FILE "of your pages on $date<br>\n";
print FILE "Here are some ENV variables that may be\n";
print FILE "of some interest to you:<br>\n";
print FILE "<tt>They came from:\n";
print FILE "<a href=\"$ENV{'HTTP_REFERER'}\">$ENV{'HTTP_REFERER'}</a><br>\n";
print FILE "Your server name: $ENV{'SERVER_NAME'}<br>\n";
print FILE "The browser they are using: $ENV{'HTTP_USER_AGENT'}<br></tt>\n";
print FILE "<hr width=75%>";
print FILE "\n";
} else {
print FILE $_;
}
}
close(FILE);
#send mail
&sendmail;
sub get_date {
@days = ('Sunday','Monday','Tuesday','Wednesday','Thursday',
'Friday','Saturday');
@months = ('January','February','March','April','May','June',
'July','August','September','October','November',
'December');
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);
if ($hour < 10) { $hour = "0$hour"; }
if ($min < 10) { $min = "0$min"; }
if ($sec < 10) { $sec = "0$sec"; }
$date = "$days[$wday], $months[$mon] $mday, 19$year at $hour\:$min\:$sec";
}
sub sendmail {
open(MAIL, "| $mailprog -t") || die "I can't send mail\n";
print MAIL "To: $my_name <$my_email>\n";
print MAIL "From: EasyLog <$my_email>\n";
print MAIL "Subject: EasyLog report\n";
print MAIL "--------------------------------------\n";
print MAIL "Someone visited one of your pages\n";
print MAIL "on: $date\n";
print MAIL "EasyLog has appended your log file at:\n";
print MAIL "$logfile\n";
print MAIL "thanks for using EasyLog!\n";
print MAIL "----------------------------------------\n";
close(MAIL);
}