<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">#!/usr/bin/perl -w
# vim: set sw=4 ts=4 si et:
# Copyright: GPL, Written by: Guido Socher 
my $ver="0.1";
my %mon2digit=('January'=&gt;1,'February'=&gt;2,'March'=&gt;3,'April'=&gt;4,
    'May'=&gt;5,'June'=&gt;6,'July'=&gt;7,'August'=&gt;8,'September'=&gt;9,
    'October'=&gt;10,'November'=&gt;11,'December'=&gt;12);
#
# This program is executed from a serverside include to insert automatically
# links to a pdf version of the article
#
my ($anum,$yn,$mn,$month,$file,$ldir);
#
if ($ENV{'DOCUMENT_URI'}){
    print "&lt;!-- addedByLfPdf ver $ver --&gt;\n";
    # DOCUMENT_URI is somthing like: /English/July2001/article207.shtml
    my @pcomp=split(/\//,$ENV{'DOCUMENT_URI'});
    exit 0 if ($#pcomp &lt; 2);
    $file= $pcomp[$#pcomp];
    $month=$pcomp[$#pcomp-1];
    if ($month=~/^([A-Z][a-z]+)(\d\d\d\d)/){
        $mn=$1;
        $yn=$2;
        if ($mon2digit{$mn}){
            $mn=$mon2digit{$mn};
        }else{
            exit(0);
        }
    }else{
        exit(0);
    }
    $ldir=$pcomp[$#pcomp-2];
    if ($file=~/^article(\d+)/){
        $anum=$1;
    }else{
        exit(0);
    }
    my $pdffile=sprintf("lf-%04d_%02d-%04d.pdf",$yn,$mn,$anum);
    if (-r "$ldir/Archives/$pdffile"){
        print qq|&lt;TABLE style="border-style:outset; border-width:1px" align="right" bgcolor="#ff9616" cellspacing="1"&gt;&lt;TR&gt;&lt;TD bgcolor="#ff9616"&gt;
        &lt;a href="../Archives/$pdffile"&gt;&lt;small&gt;PDF&lt;/small&gt;&lt;/a&gt;
        &lt;/TD&gt;&lt;/TR&gt;&lt;/TABLE&gt;
        |;
    }
}else{
    print "&lt;!-- LfPdf error: DOCUMENT_URI not defined --&gt;\n";
}
__END__ 

</pre></body></html>