#!/bin/perl $IMAGE_DATA = "data/tracer.gif"; $MAIL_TO = "xxx\@xxx.example.com"; $LOG_FILE = "data/tracer.log"; $SENDMAIL_PATH="/lib/sendmail"; $MAIL_FROM = "xxx\@xxx.example.com"; print "Content-type: image/gif\n\n"; open(FILE, $IMAGE_DATA); print; close(FILE); use POSIX qw(strftime); $log_all = strftime "%a %b %e %H:%M:%S %Y", localtime; $log_select = strftime "%a %b %e %H:%M:%S %Y", localtime; $log_all .= "\n"; $addr = $ENV{'REMOTE_ADDR'}; $host = $ENV{'REMOTE_HOST'}; if (($host eq "") || ($host eq $addr)) { $ENV{'REMOTE_HOST'} = gethostbyaddr(pack("C4", split(/\./, $addr)), 2); } foreach $env (keys %ENV){ $log_all .= "$env = $ENV{$env}\n"; $log_select .= " $ENV{$env}" if ($env eq "HTTP_REFERER"); $log_select .= " $ENV{$env}" if ($env eq "HTTP_USER_AGENT"); } $log_all .= "\n"; $log_select .= "\n"; open(LOG, ">>$LOG_FILE"); print LOG $log_select; close(LOG); use Mail::Sendmail; $mail{'Sender'} = $MAIL_FROM; $mail{'To'} = $MAIL_TO; $mail{'Body'} = $log_all; sendmail(%mail);
リンクは歓迎です。断りなく、自由に行っていただいてかまいません。