#!/usr/bin/perl -T # # Tag file based rfc cgi scripts # # John Lines (john@paladin.demon.co.uk) # use CGI qw(:standard); # This file is where site specific information for the rfc cgi perl # script is kept. You will probably have to edit this for your site. # # location of the tag binary executables $tagbindir="/usr/local/bin"; # location of your local rfc directory (and of rfc-index.tag) $rfc_dir="/usr2/local/rfc"; # URL to be prepended to local rfcs (only used for the rfc-report at present) $localurl="/rfc"; $cat="/bin/cat"; # end of site modifications - If you alter anything beyond here please # mail your improvements to john@paladin.demon.co.uk $rfc_file="${rfc_dir}/rfc-index.tag"; $version="1.3"; # Set the path to nothing - we should not be executing anything without an # explicit path - helps us pass the taint checks $ENV{PATH}=''; $|=1; print header; print start_html('RFC Index','john@paladin.demon.co.uk'), h1('RFC Index'); print start_form; print checkbox(-name=>'Hide_Obsoleted', -checked=>'checked', -label=>'Hide Obsoleted'); print checkbox(-name=>'localonly', label=>'Show Local RFCs only'); print "Local RFC report" if -e "${rfc_dir}/rfc-report.html"; print br; # find the keywords in the header open RFC,$rfc_file or die "Cant open $rfc_file: $!\n"; while () { next unless /Keywords:/; last if (/^Keywords: ([\w,]*)$/) && ($keys=$1); } # the slightly obscure bit above is because $1 does not survive outside the while block close (RFC); @keywords=split(/,/,$keys); @keywords=('',@keywords); print "Select by",br,"keyword ",popup_menu('select_keywords',\@keywords,''); print "keyword ",popup_menu('select_keywords2',\@keywords,''); print "status ",popup_menu('select_status',['','Informational','Experimental','Historic', 'Best_Current_Practice','Draft_Standard','Proposed_Standard','Standard'],''),br; print "RFC title contains ",textfield(-name=>'title_search',-default=>'',-size=>20)," case sensitive",br; print "Display as ",radio_group(-name=>'DisplayAs',-values=>[List,Table,Raw],-default=>'List'); print " - URLs in table mode are ",radio_group(-name=>'TableURL',-values=>[Local,Global],-default=>'Local'); print p,submit,end_form,p,"This rfc indexing cgi script (version $version) was written by John.Lines", "Documentation and the latest version can be found at http://www.paladin.demon.co.uk/tag-types/rfc/",p,hr,p; if (param) { # untaint localonly $p_localonly=param('localonly'); $p_localonly =~ /^([\w]*)$/; $p_localonly=$1; $selectlocal=""; $selectlocal="| $tagbindir/tagextract -m X-local-url -exists " if ($p_localonly eq "on"); $p_obs=param('Hide_Obsoleted'); $p_obs =~ /^([\w]*)$/; $p_obs=$1; $hide_obsoleted=""; $hide_obsoleted="| $tagbindir/tagextract -v -m Obsoleted-by -exists " if ($p_obs eq "on" ); $selectkeywd=""; $keyword=param('select_keywords'); # # security - keyword must be a single word (at present) - for taint checks # - note that this may need to be revised for more complex patterns if ( $keyword =~ /^([\w]*)$/ ) { $keyword = $1; } else { die "Bad data in keyword $keyword!\n"; } $selectkeywd="| $tagbindir/tagextract -m Keywords -contains $keyword" if ($keyword ne ""); $selectkeywd2=""; $keyword=param('select_keywords2'); if ( $keyword =~ /^([\w]*)$/ ) { $keyword = $1; } else { die "Bad data in keyword $keyword!\n"; } $selectkeywd2="| $tagbindir/tagextract -m Keywords -contains $keyword" if ($keyword ne ""); $p_sts=param('select_status'); $p_sts =~ /^([\w]*)$/; $p_sts=$1; $selectsts=""; $selectsts="| $tagbindir/tagextract -m Status -eq $p_sts " if ($p_sts ne ""); $p_titlesearch=param('title_search'); $p_titlesearch =~ /^([\w ]*)$/; $p_titlesearch=$1; $searchtitle=""; $searchtitle="| $tagbindir/tagextract -m Title -contains '$p_titlesearch'" if ($p_titlesearch ne ""); $p_urlmode=param('TableURL'); $p_urlmode =~ /^([\w]*)$/; $p_urlmode=$1; $urlfield="Url"; $urlfield="X-local-url" if ($p_urlmode eq "Local"); $p_disp=param('DisplayAs'); $p_disp =~ /^([\w]*)$/; $p_disp=$1; if ($p_disp eq "Table") { $display_cmd="| $tagbindir/tag2html -o border -t Rfc Title -u $urlfield"; } elsif ($p_disp eq "List") { $display_cmd="| $tagbindir/tag2html -u Url -u X-local-url"; } elsif ($p_disp eq "Raw") { # for the moment we will just write it out as preformatted text, would like # to do something more useful here - such as switch mime types print "
\n";
$display_cmd="";
}



system("$cat $rfc_file $hide_obsoleted  $selectlocal $selectkeywd $selectkeywd2 $selectsts $searchtitle $display_cmd");

print "
\n" if ($p_disp eq "Raw"); } print end_html; exit;