#!/usr/local/bin/perl require "/afs/cern.ch/project/cndoc/wwwasd/cgi-bin/asd.pl"; print "Content-type: text/html\n\n"; print "\n"; $report = $ENV{'PATH_INFO'}; $report =~ tr/\///; if ($report eq '') { &list_faqs } else { &print_faq } print "


"; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print "
"; print ""; print "Release Notes"; print "Known bugs"; print "FAQs"; print "Contributions"; print "Tutorial"; print "Reference manual"; print "Down load"; print "Miscellaneous
"; print "
$pawwm \n"; print "\n"; 1; sub list_faqs { print <<"EOM"; PAW Frequently Asked Questions

PAW Frequently Asked Questions


\n EOM # # print the 6th line of all files which reside in given directory # opendir (DIR, $pawfaqpath); local(@filenames) = readdir(DIR); closedir(DIR); if (@filenames > 2) { print "\n"; print "\n"; print "
\n"; print "
\n"; print "Search for a keyword: \n"; print "\n"; print "
\n"; print "

\n"; print "\n"; } $nb = 0; $icol = 1; for (@filenames) { next if $_ eq '.'; next if $_ eq '..'; next if $_ eq ''; next if $_ eq 'pics'; next if $_ eq 'log'; $cur_file = $_; $logentry = "0"; $nb++; open (FAQFILE, "$pawfaqpath/$nb") || print "Could not open $_\n"; if (!open (LOGFILE, "$pawfaqpath/log/$nb")) { print "Could not open log \n"; } else { # Read 10 bytes from the logentry (should be enough to cover usage # of a faq entry as an integer read (LOGFILE, $logentry, 10); } $logentry = 0 + $logentry; $first_time = 0; while () { last if $first_time eq 1; $first_time = 1; $text = substr ($_, index($_, "Question: ", 0)+10); if ( $icol == 1) { print "\n"; } if ( $icol == 2) { print "\n"; } if ( $icol == 3) { print "\n"; } print "\n"; $icol = $icol + 1; if ( $icol == 4) { $icol = 1; } $logp = $logentry; print "\n"; } close (FAQFILE); if ($logentry > 0) { close (LOGFILE); } } print "
$text
\n"; } # # Print a single FAQ # sub print_faq { open (FAQFILE, "$pawfaqpath$report") || print "Could not open $pawfaqpath/$report\n"; read (FAQFILE, $contents, 20480); $contents =~ s/\n\n/

/; $pos1 = index ($contents, "Question: ", 0); $pos2 = index ($contents, "Answer: ", $pos1); $question = substr ($contents, $pos1+10, $pos2-$pos1-10); $answer = substr ($contents, $pos2+8); close (FAQFILE); # Update the value in the access log if (!open (LOGFILE, "$pawfaqpath/log$report")) { $logentry = 1; } else { read (LOGFILE, $logentry, 10); close (LOGFILE); $logentry++; } print LOGFILE; open (LOGFILE, ">$pawfaqpath/log$report"); print (LOGFILE "$logentry\n"); close (LOGFILE); # Print the entry to the client printf (" %s

%s


%s ", $question, $question, $answer); }