Here is statistic script, called from SSI. How to make this script works called from image tags?

#!/usr/bin/perl # This script saves access date+time, the visitor's host name, their I +P # address and browser type, and the refering page (if any) to a log fi +le # on your server (default name = logfile.txt). This file will be autom +atically # mailed to your mailbox. You can change the mailing interval accordin +g # 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 exis +t. # don't change anything past this line unless you know what you are do +ing # -------------------------------------------------------------------- +--- # 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(/\|/,$hos +tline); } # 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 $mailprog +am!\n"; print MAIL "Subject: Mail-log File\n\n"; print MAIL "@entries\n"; close MAIL; unlink $logfile; } # end of script

Janitored by Arunbear - added readmore tags, as per Monastery guidelines


In reply to Making script called from image tags by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.