#!/usr/bin/perl $exedir = 'cgi-bin/photoarch'; $data_dir = 'archdata'; ################################################################## # # Vandersall Photo Archive - Display Module # # Larry McP, 05/03/98. # # REVISION HISTORY: # # 06/03/98 (LEM): Modified program to run on NYNET; # Tidied-up the way it handles blank lines # between paragraphs; and implemented # a log file of all changes for backup # purposes. # ################################################################## ############################################################## # # display_error: Displays the Error screen. # # disp_err_text The text of the error to be displayed. # ############################################################## sub display_error { print "Content-type: text/html\n\n"; open(QK_ERR, "error.html"); while (!(eof(QK_ERR))) { $err_text = ; if ($err_text eq "ERROR_TEXT_HERE\n") {$err_text = $disp_err_text;} print ($err_text); } close (QK_ERR); die ("\n"); } ################################################################## # # BEGIN MAIN PROGRAM # ################################################################## $inbuf = $ENV{QUERY_STRING}; if ( ($inbuf =~ /^c\d\d$/ ) || ($inbuf =~ /^c\d\dd$/ ) || ($inbuf =~ /^c\d\dp\d\db$/ ) || ($inbuf =~ /^c\d\dp\d\dx$/ ) || ($inbuf =~ /^c\d\dp\d\dd1$/ ) ) { $twodig_chap_num = substr($inbuf,1,2); $chap_num = $twodig_chap_num - 1 + 1; if ($inbuf =~ /^c\d\dp/) {$req_page_type = "photo"; $template_file = "photo.html"; $twodig_photo_num = substr($inbuf,4,2); $photo_num = $twodig_photo_num - 1 + 1; $photo_code = substr($inbuf,6,1); if ($photo_code eq "d") {$photo_code = "d1";} } else {$req_page_type = "chapter"; $template_file = "chap.html"; if ($inbuf =~ /^c\d\dd$/ ) {$abs_req_type = "detailed"; $abs_font_size = 2;} else {$abs_req_type = "regular"; $abs_font_size = 3;} $tmp_fname = "$data_dir/c" . $twodig_chap_num . "ab1.txt"; open (QK_ABS, $tmp_fname); $tmp_var = ; close (QK_ABS); if (length ($tmp_var) > 5) {$abs1_present = 1;} else {$abs1_present = 0;} $tmp_fname = "$data_dir/c" . $twodig_chap_num . "ab2.txt"; open (QK_ABS, $tmp_fname); $tmp_var = ; close (QK_ABS); if (length ($tmp_var) > 5) {$abs2_present = 1;} else {$abs2_present = 0;} } # # Get Chapter Info. If not found, error. # open (QK_CHAP, "$data_dir/c$twodig_chap_num.txt"); $num_photos = ; $num_photos = $num_photos - 1 + 1; if ($num_photos < 1) { $disp_err_text = "Sorry, I cannot find a Chapter $chap_num.
 
Please press the BACK button and try again."; &display_error; } $chap_name = ; $chap_name = substr($chap_name,0,length($chap_name)-1); $detailed_photos = ; $detailed_photos = substr($detailed_photos,0,length($detailed_photos)-1); $detailed_photos = " " . $detailed_photos . " "; $detailed_photos =~ s/,/ /g; close (QK_CHAP); # # If requested a detailed history but there is none, error. # if ($abs_req_type eq "detailed" && $abs2_present == 0) { $disp_err_text = "Sorry, there is no detailed history for Chapter $chap_num.
 
Please press the BACK button and try again."; &display_error; } print "Content-type: text/html\n\n"; open(QK_HTML, $template_file); while (!(eof(QK_HTML))) { $line_of_text = ; if ($line_of_text eq "CHAP_LOOP_HERE\n") { for ($m_count=1; $m_count <= $num_photos; $m_count++) { $twodig_m_count = $m_count; if ($m_count < 10) {$twodig_m_count = "0" . "$m_count";} $tmp_fname = "$data_dir/c" . $twodig_chap_num . "p" . $twodig_m_count . ".txt"; $caption_exists = 1; open (QK_CAPT, $tmp_fname); $tmp_var = ; close (QK_CAPT); if (length ($tmp_var) < 5) {$caption_exists = 0;} open(LOOP_HTML, "chaploop.html"); while (!(eof(LOOP_HTML))) { $chap_loop_text = ; $chap_loop_text =~ s/TWODIG_CHAP_NUM_HERE/$twodig_chap_num/; $chap_loop_text =~ s/TWODIG_PHOTO_NUM_HERE/$twodig_m_count/; $chap_loop_text =~ s/PHOTO_NUM_HERE/$m_count/; $chap_loop_text =~ s/PGM_HEADER_HERE/http:\/\/$ip_addr\/$exedir\/display.cgi/; if ($caption_exists == 0) {$chap_loop_text =~ s/PHOTO_CAPTION_HERE/@nocap/;} if ($chap_loop_text !~ /PHOTO_CAPTION_HERE/) {print "$chap_loop_text";} else { open (QK_CAPT, $tmp_fname); while (!(eof(QK_CAPT))) { $cap_prt_line = ; if (length ($cap_prt_line) < 4) {$cap_prt_line = "
 
";} $cap_prt_line =~ s/\n//g; $cap_prt_line =~ s/\f//g; $cap_prt_line =~ s/\r//g; $cap_prt_line = $cap_prt_line . " "; $cap_prt_line =~ s/\. /.  /g; $cap_prt_line =~ s/\. /.  /g; $cap_prt_line =~ s/\? /?  /g; $cap_prt_line =~ s/\? /?  /g; $cap_prt_line =~ s/\! /!  /g; $cap_prt_line =~ s/\! /!  /g; $cap_prt_line = $cap_prt_line . "\n"; print "$cap_prt_line"; } close (QK_CAPT); } } close (LOOP_HTML); } } $detail_for_this_photo = 0; if ( $detailed_photos =~ / $photo_num / || $detailed_photos =~ / $twodig_photo_num /) {$detail_for_this_photo = 1;} $do_we_display = 1; if ( ($line_of_text =~ s/^ABS_2_LINK// && ($abs2_present != 1 || $abs_req_type ne "regular")) || ($line_of_text =~ s/^REGULAR_LINK// && $photo_code eq "b") || ($line_of_text =~ s/^MAXWIDTH_LINK// && $photo_code eq "x") || ($line_of_text =~ s/^REGULAR_NOLINK// && $photo_code ne "b") || ($line_of_text =~ s/^MAXWIDTH_NOLINK// && $photo_code ne "x") || ($line_of_text =~ s/^DETZOOM_LINK// && ($photo_code eq "d1" || $detail_for_this_photo == 0)) || ($line_of_text =~ s/^DETZOOM_NOLINK// && ($photo_code ne "d1" || $detail_for_this_photo == 0)) || ($line_of_text =~ s/CHAP_LOOP_HERE// ) ) {$do_we_display = 0;} if ($req_page_type eq "photo") {$chap_name =~ s/-5/- 5/g;} $line_of_text =~ s/TWODIG_CHAP_NUM_HERE/$twodig_chap_num/; $line_of_text =~ s/CHAP_NUM_HERE/$chap_num/; $line_of_text =~ s/TWODIG_PHOTO_NUM_HERE/$twodig_photo_num/; $line_of_text =~ s/PHOTO_NUM_HERE/$photo_num/; $line_of_text =~ s/PHOTO_CODE_HERE/$photo_code/; $line_of_text =~ s/CHAP_NAME_HERE/$chap_name/; $line_of_text =~ s/PGM_HEADER_HERE/http:\/\/www.vandersall.com\/$exedir\/display.cgi/; $line_of_text =~ s/ABS_FONT_SIZE_HERE/$abs_font_size/; if ($abs1_present != 1) {$line_of_text =~ s/ABS_HERE/@noabs/;} if ($line_of_text eq "ABS_HERE\n") { $do_we_display = 0; $tmp_fname = "$data_dir/c" . $twodig_chap_num . "ab1.txt"; if ($abs_req_type eq "detailed") {$tmp_fname = "$data_dir/c" . $twodig_chap_num . "ab2.txt";} open (QK_ABS, $tmp_fname); while (!(eof(QK_ABS))) { $abs_prt_line = ; if (length ($abs_prt_line) < 4) {$abs_prt_line = "
 
";} $abs_prt_line =~ s/\n//g; $abs_prt_line =~ s/\f//g; $abs_prt_line =~ s/\r//g; $abs_prt_line = $abs_prt_line . " "; $abs_prt_line =~ s/\. /.  /g; $abs_prt_line =~ s/\. /.  /g; $abs_prt_line =~ s/\? /?  /g; $abs_prt_line =~ s/\? /?  /g; $abs_prt_line =~ s/\! /!  /g; $abs_prt_line =~ s/\! /!  /g; $abs_prt_line = $abs_prt_line . "\n"; print "$abs_prt_line"; } close (QK_ABS); } if ($do_we_display == 1) {print ($line_of_text);} } close (QK_HTML); die ("\n"); } # # If invalid request. # $disp_err_text = "Sorry, I received an invalid request.
 
Please press the BACK button and try again."; &display_error; die ("\n");