#!/usr/local/bin/perl -- -*-perl-*- # create a PICS rating header from a form created from the ratings file # copyright 1996 Andrew Daviel, Vancouver Webpaegs # you may freely use this script print "Content-type: text/html\n\n"; print "Vancouver Webpages PICS generator"; print "

PICS generator

\n"; $method = $ENV{'REQUEST_METHOD'} ; $query = $ENV{'QUERY_STRING'} ; $len = $ENV{'CONTENT_LENGTH'}; if (($method eq 'POST' && $len>0) || ($method eq 'GET' && $query =~ /=/)) { # Get the input if ($method eq 'POST' && $len>0) { read(STDIN, $buffer, $len) ; } else { $buffer = $query ; } # Split the name-value pairs @pairs = split(/&/, $buffer); foreach $pair (@pairs) { ($name, $value) = split(/=/, $pair); # print "$name $value
\n"; # Un-Webify plus signs and %-encoding $value =~ tr/+/ /; $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; $FORM{$name} = $value ; } } $_ = $FORM{'URL'} ; if ($_) { $err += !m%^http://%i ; $sfx += /\.\w+$/ ; $sl += m%://.+/.+$% ; if ($err) { print "ERROR - you must include a transport (\"http://\") in the URL.

\n"; } $scope = $FORM{'SCOPE'} ; if ($scope eq "Site" && $sl ){ print "ERROR - you specified a scope of Site but a URL for a file or directory.

\n"; } if ($scope eq "Directory" && !$sl) { print "ERROR - you specified a scope of Directory but a URL for a site.

\n"; } if ($scope eq "File" && !$sl) { print "ERROR - you specified a scope of File but a URL for a site.

\n"; } if ($scope eq "File" && !$sfx){ print "WARNING - you specified a scope of File but a URL with no suffix.

\n"; } $url = $_ ; } $version = $FORM{'VERSION'} ; $service = $FORM{'SERVICE'} ; $system = $FORM{'SYSTEM'} ; $icon = $FORM{'ICON'} ; $name = $FORM{'NAME'} ; $desc = $FORM{'DESC'} ; $by = $FORM{'BY'} ; if (!$version || !$service || !$system) { print "ERROR - a version, service URL and system URL must be supplied.

\n"; } $err = 0 ; $_ = $service ; $err += ( !m%^http://%i && !m%^ftp://%i ) ; $_ = $system ; $err += ( !m%^http://%i && !m%^ftp://%i ) ; if ($err) { print "ERROR - the service URL or system URL is incomplete.

\n"; } $date = `/bin/date +%Y.%m.%dT%H:%M` ; chop($date) ; $hr = `/bin/date +%k` ; $uhr = `/bin/date -u +%k` ; $tz = $hr - $uhr ; $tz = sprintf("%2.2d00",$tz) ; if ($url) { if ($scope eq "File") { print " You may include the following META tag in your HTML document $url " ; } elsif($scope eq "Site") { print " You may include the following META tag in your HTML homepage on server $url " ; } else { print " You may include the following META tag in your HTML documents in directory $url " ; } } else { print " You may include the following META tag in your HTML documents "; } print "(cut to buffer or save as TEXT). The META data should appear in the HTML document head (between the <HEAD> and </HEAD> tags):

<META http-equiv="PICS-Label" content='(PICS-$version
"$service" l ";
if ($scope ne "File") {
  print "gen true " ;
} else {
  print "gen false " ;
}
if ($name) { print "comment "$name" " ; }
if ($by)  { print "by "$by" " ; }
print "\n";
if ($date)  { print "on "$date$tz" "; }
if ($url) { print "for "$url"\n " ; }
print "r (" ;
while (($name,$value) = each (%FORM)) {
  $_ = $name ;
  if (!tr/a-z/a-z/) { next ; }
  print "$value ";
}
print "))'>\n
\n"; if ($url) { print "

Note: you may only include this META tag in documents using the specified URL and scope.\n"; } print "

You may include the following one-line header in HTTP headers on HTML documents, image files, etc. (using e.g. Apache .meta files, as-is documents or CGI scripts):

PICS-Label: (PICS-$version "$service" l ";
if ($scope ne "File") {
  print "gen true " ;
} else {
  print "gen false " ;
}
if ($name) { print "comment "$name" " ; }
if ($by)  { print "by "$by" " ; }
if ($date)  { print "on "$date$tz" "} ;
if ($url) { print "for "$url" " ; }
print "r (" ;
while (($name,$value) = each (%FORM)) {
  $_ = $name ;
  if (!tr/a-z/a-z/) { next ; }
  print "$value ";
}
print "))\n";

print "\n";