#!/usr/bin/perl # rat2html.pl # Copyright 1996, Andrew Daviel, Vancouver-Webpages.com # you may freely use this program # Converts a very limited subset of PICS ratings files to an HTML form # Usage: rat2html.pl < service.rat > service.gen.html # # define CGI script to handle the generated form $action = "/cgi-bin/mk-PICS.pl" ; #$log = 1 ; $| = 1 ; #$debug = 1 ; while () { chop ; $line = $_ ; if ($debug) { print "$_\n"; } if (/\(\s*PICS-version/i) { s/.*PICS-version\s+//i ; s/\).*// ; $PICS_version = $_ ; if ($log) { print STDERR "Got PICS version $PICS_version\n"; } } if (/\(\s*rating-system\s+\"/i) { s/.*rating-system\s+\"//i ; s/\".*// ; $rating_system = $_ ; if ($log) { print STDERR "Got rating-system \"$rating_system\"\n"; } } if (/\(\s*rating-service\s+\"/i) { s/.*rating-service\s+\"//i ; s/\".*// ; $rating_service = $_ ; if ($log) { print STDERR "Got rating-service \"$rating_service\"\n"; } } if (/\(\s*category/) { &do_category ; } if (!$category) { if (/\(\s*name\s+\"/) { s/.*\(\s*name\s+\"// ; s/\".*// ; $rating_name = $_ ; if ($log) { print STDERR "Got rating name \"$rating_name\"\n"; } } if (/\(\s*description\s+\"/) { s/.*\(\s*description\s+\"// ; s/\".*// ; $rating_description = $_ ; if ($log) { print STDERR "Got rating description \"$rating_description\"\n"; } } if (/\(\s*icon\s+\"/) { s/.*\(\s*icon\s+\"// ; s/\".*// ; $rating_icon = $_ ; if ($log) { print STDERR "Got rating icon \"$rating_icon\"\n"; } } } else { # category $_ = $line ; if (/\(\s*label\s+/) { $label++ ; } if ($label) { $_ = $line ; if (/\(\s*name\s+\"/) { s/.*\(\s*name\s+\"// ; s/\".*// ; $name[$label]=$_ ; if ($log) { print STDERR "Got label name \"$_\"\n"; } } $_ = $line ; if (/\(\s*value\s+/) { s/.*\(\s*value\s+// ; s/\).*// ; $value[$label]=$_ ; if ($log) { print STDERR "Got label value \"$_\"\n"; } } $_ = $line ; if (/\(\s*description\s+\"/) { s/.*\(\s*description\s+\"// ; s/\".*// ; $description[$label]=$_ ; if ($log) { print STDERR "Got label description \"$_\"\n"; } } } else { # if label $_ = $line ; if (/\(\s*name\s+\"/) { s/.*\(\s*name\s+\"// ; s/\".*// ; $name = $_ ; if ($log) { print STDERR "Got category name \"$name\"\n"; } } $_ = $line ; if (/\(\s*description\s+\"/) { s/.*\(\s*description\s+\"// ; s/\".*// ; $description = $_ ; if ($log) { print STDERR "Got category description \"$description\"\n"; } } $_ = $line ; if (/\(\s*transmit-as\s+\"/) { s/.*\(\s*transmit-as\s+\"// ; s/\".*// ; $transmit_as= $_ ; if ($log) { print STDERR "Got transmit-as \"$transmit_as\"\n"; } } $_ = $line ; if (/\(\s*min\s+/) { s/.*\(\s*min\s+// ; s/\).*// ; $min = $_ ; if ($log) { print STDERR "Got min \"$min\"\n"; } } $_ = $line ; if (/\(\s*max\s+/) { s/.*\(\s*max\s+// ; s/\).*// ; $max = $_ ; if ($log) { print STDERR "Got max \"$max\"\n"; } } } # !label } # category } & do_category ; print < EOT exit ; sub do_category { if ($log) { print "Category\n"; } if ($category) { print <Category: $name EOT if (!$name) { print STDERR "ERROR - No category name\n"; } if (!$transmit_as) { print STDERR "ERROR - No transmit-as value\n"; } if ($description) { print "Description:
\n $description\n" ; } $minv = $value[1] ; $maxv = $value[1] ; print "
    \n"; for ($i =1 ; $i<=$label ; $i++) { #print "Name $name[$i] value $value[$i]\nDescription $description[$i]\n" ; #print "
  • $value[$i] $name[$i]: $description[$i]\n" ; print "
  • $name[$i]: $description[$i]\n" ; if ($value[$i] > $max) { print STDERR "Category $name value $value[$i] exceeds declared maximum $max\n"; } if ($value[$i] < $min) { print STDERR "Category $name value $value[$i] exceeds declared minimum $min\n"; } if ($value[$i] > $maxv) { $maxv = $value[$i] ; } if ($value[$i] < $minv) { $minv = $value[$i] ; } } if ($maxv != $max) { print STDERR "Category $name maximum $maxv != declared max. $max\n"; } if ($minv != $min) { print STDERR "Category $name minimum $minv != declared min. $min\n"; } print "
\n" ; print "Select Limit: \n"; $label = 0 ; undef(@name) ; undef(@description) ; undef(@value) ; $description = "" ; $transmit_as = "" ; $name = "" ; } else { # category not set, do header print <PICS Rating Generator: $rating_name

PICS Rating Generator

For more information on the PICS system of content rating, see This form was generated from a PICS rating file, which should be accessible under the Rating Service given below. Users must typically download this rating file and install it in their browser in order to use this service.

Rating Name: $rating_name

PICS Version: $PICS_version

Description: $rating_description

System: $rating_system

Service: $rating_service EOT if ($rating_icon) { $_ = $rating_service ; s%/$%% ; print "

Icon: $_/$rating_icon\n"; } print < For URL:
You may specify an entire site, a directory tree, or a single file. The rating tag must be applied to the correct URL or site, otherwise the pages will be inaccessible to all ratings users.
For a site, this should be the classification of the majority of pages. Pages which have a different rating must be given an explicit rating as a file.

By: (email or contact URL)
The person responsible for the rating, who may be contacted if the ratings are challenged.

Categories

Category values are presented most-desireable-first. Browsers will typically pass documents with one of the first N possible values, where the number N is set by a parent or password holder.

EOT } $category++ ; }