#!/usr/bin/perl # Constants $| = 1 ; $TRUE = 1 ; $FALSE = 0 ; # Settings $base_dir = ""; $root = $ENV{"DOCUMENT_ROOT"}."${base_dir}/"; $here = $ENV{"SCRIPT_FILENAME"}; $cgi = substr( $here, rindex( $here, "/" ) + 1 ); $style_file = "style.css"; $root_feature = "home"; $topbar_feature = "topbar"; $ad_feature = "ad"; $faq_feature = "faq"; $members_feature = "members"; $sitemap_feature = "sitemap"; # secondary_features == Features that are treated like txt/ files for # txt2html processing, and context-sensitive content. # insert between "" arguments $secondary_features = join( ',', "", $ad_feature, $topbar_feature, "" ); $menu_conf_separator_item = "SEPARATOR_ITEM"; $sawmill_option = "--sawmill"; $search_option = "--search"; $feedback_option = "--feedback"; $plain_option = "--plain"; if ( $ENV{"HTTP_USER_AGENT"} =~ /.*MSIE.*/ ) { $MSIE = $TRUE ; } else { $MSIE = $FALSE ; } $border = 0 ; ## DEBUG # $MSIE = $TRUE ; # $border = 1 ; $title = ""; $ref_URL = ""; $content = ""; $ad = ""; $menu_txt[0] = ""; $menu_URL[0] = ""; $menu_sub[0] = 0; $menu_path[0] = ""; $menu_desc[0] = ""; $menu_root[0] = $FALSE ; $menu_arrow[0] = $FALSE ; $menu_sel[0] = $FALSE ; $menu_file[0] = $FALSE ; $menu_max = 0 ; $menu_total_separators = 0 ; $label = $root_feature; $sawmill = $FALSE ; $sawmill_token = "[[[SAWMILL-STATISTICS]]]"; $search = $FALSE ; $search_token = "[[[SEARCH-PAGE]]]"; $feedback = $FALSE ; $feedback_token = "[[[FEEDBACK-PAGE]]]"; $plain = $FALSE ; $comment = "#OMP#"; $txt_dir = "txt/"; $txt_suf = ".txt"; $menu_conf = "menu.conf"; $menu_disimgsuf = "_d"; $menu_imgsuf = ".gif"; # Appearance $header_font = "Verdana,Arial,Helvetica"; $logo_color = "#007384"; $content_bg = "#FFFFFF"; $content_text = "#000000"; $banner_bg = "#CFCFCF"; $banner_text = "#000000"; $topbar_text = "#FFFFFF"; $backpage_bg = $logo_color ; $backpage_bg_0 = "#006971"; $backpage_bg_1 = "#00555D"; $backpage_bg_2 = "#00454D"; $backpage_width = 20 ; $backpage_height = 40 ; $backpage_text_size = "-2"; $backpage_text = "#FFFFFF"; $activate_backpage_menu = $FALSE ; $menu_images = $TRUE ; $menu_arrow_width = 7 ; $menu_arrow_open_height = 4 ; $menu_bg = "#CCFFCC"; $menu_bg_0 = "#B0E0B0"; $menu_bg_1 = "#99B599"; $menu_bg_2 = "#778A77"; $menu_text = "#000000"; $menu_text_size = "-1"; $menu_disabled = "#000000"; $menu_link = "#606060"; $menu_separator_bg = "#000000"; $menu_separator_width = 2 ; $menu_btn_width = 50; $menu_btn_height = 20 ; $menu_vert_pad = 6; $menu_width = 120; $menu_pad = 18; $side_pad = 13; $separator_bg = "#000000"; $separator_text = "#FFFFFF"; $vert_sep_width = 2 ; $horiz_sep_width = 2 ; # Parse Command Line while ( @ARGV ) { if ( $ARGV[0] eq $sawmill_option ) { # Create a context-correct framing page for Sawmill $sawmill = $TRUE ; $base_dir = "http://www.openmp.org"; $root = "/home/openmp/web/htdocs/"; $here = "/home/openmp/web/htdocs/members/index.cgi"; $cgi = substr( $here, rindex( $here, "/" ) + 1 ); $label = "sawmill"; $MSIE = $TRUE ; chdir "${root}/members" ; } elsif ( $ARGV[0] eq $search_option ) { # Create a context-correct framing page for Search $search = $TRUE ; $root = "/home/openmp/web/htdocs/"; $here = "/home/openmp/web/htdocs/members/archives/index.cgi"; $cgi = substr( $here, rindex( $here, "/" ) + 1 ); $label = "mjsearch"; $MSIE = $TRUE ; chdir "${root}/members/archives" ; } elsif ( $ARGV[0] eq $feedback_option ) { # Create a context-correct framing page for Feedback $feedback = $TRUE ; $root = "/home/openmp/web/htdocs/"; $here = "/home/openmp/web/htdocs/index.cgi"; $cgi = substr( $here, rindex( $here, "/" ) + 1 ); $label = "feedback_results"; $MSIE = $TRUE ; } elsif ( $ARGV[0] eq $plain_option ) { # For "]/_/g; $label =~ s/\.\.//g; $ref_URL =~ s/[\*\?\(\)\[\]\{\}\\\|;<>]/_/g; $ref_URL =~ s/\.\.//g; if ( !$sawmill && !$search && !$feedback ) { print "Content-type: text/html\n\n"; } # Read menu and ad contents # getMenu() modifies menu_*[] $menu_max = getMenu() - 1; if ( ( $menu_max == 0 ) && !defined( $menu_txt[0] ) ) { $menu_max = -1 ; } $topbar = getFiles( $topbar_feature, $FALSE, $FALSE ); $ad = getFiles( $ad_feature, $FALSE, $FALSE ); # Read in main title and contents # getContent() modifies $content, $title if ( $ref_URL eq "" ) { &getContent( $label ); } else { &getContent( $ref_URL ); } # We need a place-holder title for PLAIN files if ( $plain && ( $ref_URL ne "" ) ) { $title = "OpenMP: ".substr( $ref_URL, rindex( $ref_URL, "/" ) + 1 ); } # Generate HTML print "\n"; print "\n"; print "${title}\n"; print "\n"; print "\n"; # Load up the style sheet for this directory, if applicable, # else load root-level default if ( -f $style_file ) { print "\n"; } elsif ( -f "${root}${style_file}" ) { print "\n"; } print "\n"; print "\n"; print "\n"; # Top spacer print ""; # BANNER CELLS print ""; # Upper-left corner print ""; # Vertical separator stub print ""; # Image & title cell print ""; # BANNER GRADIENT SEPARATOR STUB print ""; # BANNER BACKPAGE STUB print ""; print "\n"; # TOP BAR TOP SPACER print ""; # TOP BAR print ""; # TOP BAR, MENU PART print ""; # TOP BAR, LEFT GRADIENT STUB print ""; # TOP BAR, CONTENT PART # COLSPAN: menu, sep*4, content, sep*4, (space) print ""; # TOP BAR, RIGHT GRADIENT STUB print ""; # TOP BAR, BACKPAGE STUB print ""; print "\n"; # TOP BAR BOTTOM SPACER print ""; # MENU CELL print ""; print "\n"; # VERTICAL GRADIENT SEPARATOR print ""; print ""; print ""; print ""; # CONTENT CELL print ""; # RIGHT SIDE VERTICAL GRADIENT SEPARATOR print ""; print ""; print ""; print ""; print ""; # END MENU/CONTENT ROW print "\n"; # COPYRIGHT NOTICE print ""; # BOTTOM HORIZONTAL GRADIENT SEPARATOR print ""; print ""; print ""; print ""; # BACKPAGE print ""; # Menu Stub # Separator Stub # Content Stub # Separator Stub # Backpage Stub # Bottom bar content print ""; print "\n"; # END BACKPAGE print "\n"; print "
"; print spacer( 1, $horiz_sep_width ); print "
"; print spacer( $menu_width, 1 ); print ""; print spacer( 1, 1 ); print ""; print "\n"; print ""; print ""; print ""; print "\n"; print "
"; print "\""; print spacer( ( $side_pad * 2 ), 1 ); print ""; $banner_title = $title ; $banner_title =~ s/^OpenMP: //i; print "${banner_title}"; print "
\n"; print "
"; print spacer( 1, 1 ); print ""; print spacer( $backpage_width, 1 ); print "
"; print spacer( 1, ( $horiz_sep_width / 2 ) ); print "
"; print ""; print spacer( 5, 1 ); print "www.openmp.org"; print ""; print spacer( 1, 1 ); print ""; print ""; print $topbar ; print ""; print ""; print spacer( 1, 1 ); print ""; print spacer( $backpage_width, 1 ); print "
"; print spacer( 1, ( $horiz_sep_width * 2 ) ); print "
"; # MENU TABLE-LET # HORIZ SPACING -- MENU TEXT/IMAGE -- HORIZ SPACING -- etc. print "\n"; # Side pads print ""; print ""; print ""; print ""; print "\n"; # End side pads for ( $c = 0 ; $c <= $menu_max ; $c++ ) { $sep = ( $menu_txt[$c] eq $menu_conf_separator_item ); $sep_next = ( $menu_txt[($c+1)] eq $menu_conf_separator_item ); # Menu items cell print ""; print ""; print "\n"; if ( !$sep && !$sep_next ) { if ( $c == $menu_max ) { $mult = 2 ; } else { $mult = 1 ; } print "\n"; } } # for ( $c <= $menu_max ) # MENU HORIZONTAL SEPARATOR if ( $ad ne "" ) { print "\n"; } # AD SECTION # Side pads print ""; print ""; print ""; # End side pads print "\n"; # Bottom spacer print ""; # END MENU TABLE-LET print "
"; print spacer( $side_pad, 1 ); print ""; print spacer( 1, $menu_vert_pad ); print ""; print spacer( $side_pad, 1 ); print "
"; if ( $sep ) { if ( $MSIE ) { $mult = 0.75 ; } else { $mult = 1.66 ; } print l_spacer( ( ( $menu_pad * $menu_sub[$c] ) + int( $menu_arrow_width * $mult ) ), 1 ); print "
"; } else { # Spacer if ( $menu_sub[$c] > 0 ) { print spacer( ( $menu_pad * $menu_sub[$c] ), 1 ); } # Arrow if ( $menu_root[$c] && $menu_arrow[$c] ) { # a bit redundant print ""; if ( $here =~ /${menu_URL[$c]}/ ) { print "\""; } else { print "\""; } print ""; } else { print spacer( $menu_arrow_width, 1 ); } print spacer( ( $menu_arrow_width / 2 ), 1 ); # Menu Item if ( $menu_sel[$c] ) { if ( -f "${txt_dir}${label}{$menu_disimgsuf}.gif" && $menu_images ) { print "\""; } else { print "".$menu_txt[$c]."" ; } } else { if ( $menu_root[$c] || $menu_file[$c] ) { print ""; } else { print ""; } if ( -f "${txt_dir}${label}.gif" && $menu_images ) { print "\""; } else { print "".$menu_txt[$c].""; } print ""; } } print "
"; print spacer( 1, ( $menu_vert_pad * $mult ) ); print "
"; print spacer( 1, $menu_separator_width ); print "
"; print spacer( $side_pad, 1 ); print ""; print spacer( 1, ( $menu_vert_pad * 2 ) ); print ""; print spacer( $side_pad, 1 ); print "
"; if ( $ad ne "" ) { print "
"; print $ad ; print "
\n"; } print "
"; print spacer( 1, ( $menu_vert_pad * 2 ) ); print "
\n"; # END MENU CELL print "
"; print spacer( $vert_sep_width, 1 ); print ""; print spacer( $vert_sep_width, 1 ); print ""; print spacer( $vert_sep_width, 1 ); print ""; print spacer( $vert_sep_width, 1 ); print "\n"; print "\n"; print "\n"; print "
"; if ( $plain ) { # If we got here via a "; } print $content; if ( $plain ) { # Close the PRE after content is finished print ""; } if ( $sawmill ) { # Within the content cell, tell Sawmill to start inserting # its statistics here. print "\n${sawmill_token}\n"; } elsif ( $search ) { print "\n${search_token}\n"; } elsif ( $feedback ) { print "\n${feedback_token}\n"; } print "
\n"; print "
"; print spacer( $vert_sep_width, 1 ); print ""; print spacer( $vert_sep_width, 1 ); print ""; print spacer( $vert_sep_width, 1 ); print ""; print spacer( $vert_sep_width, 1 ); print ""; print spacer( $backpage_width, 1 ); print "

Copyright © 1997-2003, OpenMP Architecture Review Board
"; print spacer( 1, ( $horiz_sep_width ) ); print "
"; print spacer( 1, ( $horiz_sep_width ) ); print "
"; print spacer( 1, ( $horiz_sep_width ) ); print "
"; print spacer( 1, ( $horiz_sep_width ) ); print "
"; if ( $activate_backpage_menu ) { print "\n"; print "\n"; print "
"; for ( $c = 0 ; $c <= $menu_max ; $c++ ) { if ( ( $menu_sub[$c] == 0 ) && ( $menu_txt[$c] ne $menu_conf_separator_item ) ) { if ( $c > 0 ) { print ""; print "|  "; print ""; } if ( $menu_root[$c] || $menu_file[$c] ) { print ""; } else { print ""; } $txt_tmp = $menu_txt[$c] ; $txt_tmp =~ s/ /\ \;/g ; print ""; print $txt_tmp ; print "   "; } } print "
\n"; } else { print spacer( 1, $backpage_height ); } print "
"; print spacer( 1, ( $horiz_sep_width * 2 ) ); print "
\n"; print "\n"; print "\n"; exit( 0 ); ### # Subroutines # getMenu(): Parses menu.conf files from a given point UP in the menu hierarchy # Modifies global menu_*[] arrays # $c is the menu_*[] subscript, maintained through recursion # $sub denotes the position in the hierarchy # $labeltree denotes the hierarchy above us that has already # been processed sub getMenu { my( $sub, $c, $labelTree ) = @_ ; my( $stage ) = ( 0 ); my( $myHere, $line ) = ( "", "" ); my( $menu_FP ) = ( "" ); # Where I am currently in the menu hierarchy $myHere = toPath( $here ); if ( defined( $sub ) && defined( $c ) && defined( $labelTree ) ) { # Find where I am ($myHere) by striping the higher part # of the hierarchy ($labeltree) $myHere = substr( $myHere, 0, length( $myHere ) - length( $labelTree ) ); } else { # First-time called, initialize $labelTree with current path $sub = 0 ; $c = 0 ; $labelTree = "" ; while ( $myHere ne $root ) { $labelTree = tailPath( $myHere )."/".${labelTree}; $myHere = headPath( $myHere ); if ( $myHere eq "/" ) { return $c ; } } } # Open and parse the menu_conf file # $stage == 1 -- found txt; 2 -- found url; if desc found at 2, reset to 0 $menu_FP = tailPath( $myHere ); if ( !open($menu_FP, "${myHere}${txt_dir}${menu_conf}") ) { # printf "Could not open \"${myHere}${txt_dir}${menu_conf}\"; punting."; # exit(0); return $c; } while ( <$menu_FP> ) { chomp;chomp; next if ( $_ =~ /^${comment}/ ); $line = $_ ; if ( $line eq "" ) { $stage = 0; } else { if ( $stage == 0 ) { if ( $line eq $menu_conf_separator_item ) { $menu_txt[$c] = $line ; $menu_sub[$c] = $sub ; $menu_total_separators++ ; $c++; } else { $stage++; $menu_txt[$c] = $line ; } } elsif ( $stage == 1 ) { $stage++; $menu_URL[$c] = $line ; if ( ( $menu_file[$c] = ( $line =~ /\./ ) ) ) { $look_label = substr( $menu_URL[$c], 0, index( $menu_URL[$c], '.' ) ); } else { $look_label = $menu_URL[$c] ; } $menu_sub[$c] = $sub ; $menu_path[$c] = substr( $myHere, length( $root ) ) ; # NASTY CODE TO DETERMINE WHETHER A MENU ITEM # IS THE CURRENTLY SELECTED ITEM... # print "here $here sub ".substr($myPath,length($myPath)-length($menu_path[$c]))." my $myHere label $label lt $labelTree mp $menu_path[$c] mU $menu_URL[$c]
"; $menu_sel[$c] = ( ( $menu_URL[$c] eq $labelTree ) && ( $label eq $root_feature ) && ( $ref_URL eq "" ) ) || ( ( $labelTree eq "" ) && ( $label eq $look_label ) && ( $ref_URL eq "" ) ) || ( ( $menu_URL[$c] eq $root_feature ) && ( $label eq $root_feature ) && ( $labelTree eq "" ) ); # print "check for $line root $root my $myHere mp ".substr( $myHere, length( $root ) )." lt $labelTree tp ".topPath( $labelTree )."
"; # Is the item a folder, and if so, does it have a menu.conf file? if ( substr( $line, length( $line )-1, 1 ) eq "/" ) { $menu_root[$c] = $TRUE ; $menu_arrow[$c] = ( -f $myHere.$menu_URL[$c].$txt_dir.$menu_conf ); $line = substr( $line, 0, rindex( $line, "/" ) ); } $c++; # GET HIGHER (ROOT) MENU ITEMS if ( $line eq topPath( $labelTree ) ) { $c = getMenu( $sub+1, $c, upPath( $labelTree ) ); } } elsif ( $stage == 2 ) { # Found final info line, reset stage $menu_desc[$c] = $line ; $stage = 0; } } } close( $menu_FP ); return $c ; } # getMenu() # toPath(): take off any filenames at the end of a path sub toPath { my( $thePath ) = @_ ; return substr( $thePath, 0, rindex( $thePath, "/" )+1 ); } # toPath() # tailPath(): extract the last directory entry in a path sub tailPath { my( $thePath ) = @_ ; my( $last, $nextLast ) = ( "", "" ); $last = rindex( $thePath, "/" ); $nextLast = rindex( $thePath, "/", $last-1 ); return substr( $thePath, $nextLast+1, $last-$nextLast-1 ); } # tailPath() # topPath(): extract the top level directory in a path sub topPath { my( $thePath ) = @_ ; return substr( $thePath, 0, index( $thePath, "/" ) ); } # topPath() # upPath(): inverse of topPath() -- remove top level dir sub upPath { my( $thePath ) = @_ ; return substr( $thePath, index( $thePath, "/" )+1 ); } # upPath() # headPath(): remove lowest level dir from path sub headPath { my( $thePath ) = @_ ; my( $last, $nextLast ) = ( "", "" ); $last = rindex( $thePath, "/" ); $nextLast = rindex( $thePath, "/", $last-1 ); return substr( $thePath, 0, $nextLast+1 ); } # headPath() # spacer(): Return a spacer HTML string sub spacer { my( $width, $height ) = @_ ; return if ( !defined( $width ) || !defined( $height ) ); $width = int( $width ); $height = int( $height ); if ( $MSIE ) { return "\""; } else { return ""; } } # spacer() # l_spacer(): Return an ALIGN=LEFT horizontal spacer HTML string sub l_spacer { my( $width, $height ) = @_ ; return if ( !defined( $width ) || !defined( $height ) ); $width = int( $width ); $height = int( $height ); if ( $MSIE ) { return "\""; } else { return ""; } } # l_spacer() # getContent(): Retrieve content, modify globals $title and $content # $type is the tag for our current menu hier. location # $link determines whether we're looking at a base txt # document, or an internal HTML page. sub getContent { my( $type ) = @_ ; my( $begin, $link, $line ) = ( $TRUE, $FALSE, "" ); return if ( !defined( $type ) ); if ( $type eq $sitemap_feature ) { $title = "OpenMP: Site Map"; $content = generateSiteMap(); return; } $link = ( $type =~ /\// && substr( $type, -1, 1 ) ne "/" ); if ( $link ) { if ( !open( CONTENT, "${type}" ) ) { $title = "Feature \"${type}\" not found - ${type}"; $content = "Sorry, the feature \"${type}\" could not be found.
\nPlease report this event to
webmaster\@openmp.org.
\n"; return; } } else { if ( !open( CONTENT, "${txt_dir}${type}${txt_suf}" ) ) { $title = "Feature \"${type}\" not found - ${txt_dir}${type}${txt_suf}"; $content = "Sorry, the feature \"${type}\" could not be found.
\nPlease report this event to webmaster\@openmp.org.

\n"; return; } } while ( ) { chomp;chomp; $line = $_ ; # Ignore blank lines until non-blank found # Ignore commented-out lines next if ( ( $_ eq "" && $begin ) || $_ =~ /^${comment}/ ); if ( $begin && !$plain ) { $begin = $FALSE ; if ( !( $line =~ /^ don't run the txt2html translator on these files # @sources -- use these paths to look for ads (global/local ads) sub getFiles { my( $type, $skipFirst, $noTranslate ) = @_ ; my( $stuff, $src_dir ) = ( "", "" ); my( $c, $d ) = ( 0, 0 ); my( $found ) = ( $FALSE ); my( @sources ) = ( "${txt_dir}${label}_", "${txt_dir}" ); return "" if ( !defined($type) ); if ( ( $secondary_features =~ /,${type},/ ) && ( toPath( $here ) ne $root ) ) { push( @sources, "${root}${txt_dir}" ); } for ( $d = 0 ; $d <= $#sources ; $d++ ) { $src_dir = $sources[$d] ; # print "SRC $src_dir or ${src_dir}${type}${txt_suf}
\n"; if ( -f "${src_dir}${type}${txt_suf}" && (!$skipFirst) ) { if ( $found ) { $stuff .= "
\n"; } $found = $TRUE ; $stuff .= catFile( "${src_dir}${type}${txt_suf}" ); } $c = 0; while ( -f "${src_dir}${type}${c}${txt_suf}" ) { if ( $found || $skipFirst ) { $stuff .= "
\n"; } $found = $TRUE ; $stuff .= catFile( "${src_dir}${type}${c}${txt_suf}" ); $c++ ; } } if ( $found ) { if ( $noTranslate ) { return $stuff ; } else { return txt2html( $type, $stuff ); } } else { return ""; } } # getFiles() # catFile(): literally cat a file into a variable. sub catFile { my( $filename ) = @_ ; my( $stuff ) = ""; return "" if ( (!defined($filename)) || (! -f $filename) ); open( IN, "<${filename}" ) || return "Could not open file \"${filename}\" for reading!
\n"; while ( ) { next if ( $_ =~ /^${comment}/ ); $stuff .= $_ ; } close( IN ); return $stuff ; } # catFile() # txt2html(): Make basic txt->html translations, link translation, etc. # Read in $txtBuffer, translate it and return the new string # Use $type to enable FAQ or other additional/different translations sub txt2html { my( $type, $txtBuffer ) = @_ ; my( $i, $b, $c, $in, $indent, $stage ) = ( 0, 0, 0, 0, 0, 0 ); my( $newBuffer, $buf, $relPath ) = ( "", "", "" ); return "" if ( !defined( $type ) || $type eq "" || !defined( $txtBuffer ) || $txtBuffer eq "" ); if ( ( $type eq $faq_feature ) || ( $type =~ /_${faq_feature}$/ ) ) { return faq2html( $txtBuffer ); } $relPath = toPath( $type ); if ( ( $relPath eq "" ) || ( $relPath eq $txt_dir ) || ( $secondary_features =~ /,${type},/ ) ) { # Handle $txt_dir features $txtBuffer =~ s/\s+HREF=\"\// FIXED HREF=\"\//gi; $txtBuffer =~ s/\s+INT\s+HREF=\"(?!HTTP)/ INT HREF=\"${cgi}\?${label}+/gi; $txtBuffer =~ s/\s+FIXED\s+HREF=\"\// HREF=\"\//gi; } else { # Handle arbitrary HTML $txtBuffer =~ /\([\s\S]*)\<\/TITLE\>/i; if ( defined( $1 ) && $title eq "" ) { $title = $1 ; } $txtBuffer =~ s/\[\s\w\n\m]*\<\/TITLE\>\n//gi; $txtBuffer =~ s/\[\s\w\n\m]*\<\/TITLE\>//gi; $txtBuffer =~ s/\\n//gi; $txtBuffer =~ s/\<\/HTML\>//gi; $txtBuffer =~ s/\\n//gi; $txtBuffer =~ s/\<\/HEAD\>//gi; $txtBuffer =~ s/\\n//gi; $txtBuffer =~ s/\<\/BODY\>//gi; $txtBuffer =~ s/\ with
  • ) # Quite nasty. while ( ( ( $i = index( $txtBuffer, "\n", $b ) ) >= 0 ) && !$plain ) { # print "AT ".substr( $txtBuffer, $b, $i-$b )." TA $stage
    "; $buf = substr( $txtBuffer, $b, $i-$b ); $char = substr( $buf, 0, 1 ); if ( $buf eq "" ) { if ( $stage == 0 ) { $stage = 1; } elsif ( $stage == 2 ) { for ( $c = 0 ; $c < $indent ; $c++ ) { $newBuffer .= "\n"; } $indent = 0 ; $stage = 1 ; $b = $i + 1 ; next; } } elsif ( $char eq "\t" ) { $in = 0; while ( substr( $txtBuffer, $b+$in, 1 ) eq "\t" ) { $in++; } if ( $in > $indent ) { for ( $c = 0 ; $c < ($in-$indent) ; $c++ ) { $newBuffer .= "
      "; } } elsif ( $indent > $in ) { for ( $c = 0 ; $c < ($indent-$in) ; $c++ ) { $newBuffer .= "
    "; } } $indent = $in; if ( $stage == 1 ) { $stage = 2; $newBuffer .= "
  • "; } elsif ( $stage == 2 ) { $newBuffer .= "
  • "; } } else { if ( $stage == 0 || $stage == 1 ) { if ( ( substr( $txtBuffer, $i+1, 1 ) eq "\n" ) && ( substr( $buf, 0, 1 ) ne "<" ) ) { $newBuffer .= "${buf}

    \n"; $b = $i + 1 ; next; } } if ( $stage == 1 ) { $stage = 0; } elsif ( $stage == 2 ) { for ( $c = 0 ; $c < $indent ; $c++ ) { $newBuffer .= "\n"; } $stage = 0 ; } } $newBuffer .= $buf."\n"; $b = $i + 1 ; } $buf = substr( $txtBuffer, $b ); if ( $buf ne "" ) { $newBuffer .= $buf ; } return $newBuffer; } # txt2html() # faq2html(): convert a FAQ-formatted txt file into header links and content sub faq2html { my( $txtBuffer ) = @_ ; my( $stage, $i, $b, $c ) = ( 0, 0, 0, 0 ); my( $indexBuffer, $fullBuffer, $newBuffer, $buf ) = ( "", "", "", "" ); my( @q, @a ); while ( ( $i = index( $txtBuffer, "\n", $b ) ) >= 0 ) { $buf = substr( $txtBuffer, $b, $i-$b ); if ( $buf =~ /^\s*Q[0-9]+:([\s\S]+)/ ) { $stage = 1 ; $q[$#q+1] = $1 ; } elsif ( $buf =~ /^\s*A[0-9]+:([\s\S]+)/ ) { $stage = 2 ; $a[$#a+1] = $1 ; } else { if ( $stage == 0 ) { $newBuffer .= $buf."\n"; } elsif ( $stage == 1 ) { $q[$#q] .= $buf ; } elsif ( $stage == 2 ) { $a[$#a] .= $buf ; } } $b = $i + 1 ; } $indexBuffer .= "\n"; $fullBuffer .= "
    \n"; for ( $c = 0 ; $c <= $#q ; $c++ ) { $i = $c + 1 ; if ( defined( $a[$c] ) && ( $a[$c] ne "" ) ) { $indexBuffer .= "\n"; $fullBuffer .= "\n"; $fullBuffer .= "\n"; if ( $c != $#q ) { $fullBuffer .= "\n"; } } } $indexBuffer .= "
    Q${i}:".$q[$c]."
    Q${i}:".$q[$c]."
    A${i}:".$a[$c]."

    \n"; $fullBuffer .= "\n"; $newBuffer .= $indexBuffer."


    \n".$fullBuffer ; return $newBuffer ; } # faq2html() $gSMlineCount = 0; # generateSiteMap(): recurse through all menu_conf files from site root # This could theoretically be an option of getMenu(), but that function is hard # enough to follow already, methinks. sub generateSiteMap { my( $myRoot, $c ) = @_ ; my( $menu_txt, $menu_URL, $menu_desc ) = ( "", "", "", "" ); my( $menu_root, $menu_arrow, $start ) = ( $FALSE, $FALSE ); my( $stage, $t ) = ( 0, 0 ); my( $stuff ) = ( "" ); if ( !defined( $myRoot ) ) { $myRoot = $root ; } if ( !defined( $c ) ) { $c = 0 ; $start = $TRUE ; $gSMlineCount = 0 ; $stuff .= "
    \n"; $stuff .= "\n"; } my( $menu_FP ) = ( $myRoot ); if ( ( $here !~ /\/${members_feature}\// ) && ( tailPath( $myRoot ) eq $members_feature ) ) { return ""; } if ( !open($menu_FP, "${myRoot}${txt_dir}${menu_conf}") ) { # printf "Could not open \"${myRoot}${txt_dir}${menu_conf}\"; punting."; # exit(0); return ""; } while ( <$menu_FP> ) { chomp;chomp; next if ( $_ =~ /^${comment}/ ); $line = $_ ; if ( $line eq "" ) { $stage = 0; $menu_root = $FALSE ; $menu_arrow = $FALSE ; } else { if ( $stage == 0 ) { $stage++; $menu_txt = $line ; } elsif ( $stage == 1 ) { $stage++; $menu_URL = $line ; # IS THE ITEM A FOLDER/SUBMENU? if ( substr( $line, length( $line )-1, 1 ) eq "/" ) { $menu_root = $TRUE ; } if ( -f $myRoot.$menu_URL.$txt_dir.$menu_conf ) { $menu_arrow = $TRUE ; } } elsif ( $stage == 2 ) { $menu_desc = $line ; $stuff .= ""; $gSMlineCount++ ; if ( $gSMlineCount % 2 ) { $stuff .= ""; if ( $gSMlineCount % 2 ) { $stuff .= ""; $stuff .= "\n"; $stuff .= generateSiteMap( ${myRoot}.${menu_URL}, $c+1 ); $stage = 0; $menu_root = $FALSE ; $menu_arrow = $FALSE ; } } } close( $menu_FP ); if ( $start ) { $stuff .= "
    "; } else { $stuff .= ""; } for ( $t=0 ; $t < $c ; $t++ ) { $stuff .= spacer( $menu_pad, 1 ); } if ( $menu_arrow ) { $stuff .= "\""; $stuff .= spacer( ( $menu_arrow_width / 2 ), 1 ); } else { $stuff .= spacer( ( $menu_arrow_width * 1.5 ), 1 ); } if ( $menu_root ) { $stuff .= "${menu_txt}"; } else { $stuff .= "${menu_txt}"; } $stuff .= ""; } else { $stuff .= ""; } $stuff .= $menu_desc ; $stuff .= "
    \n"; $stuff .= "
    \n"; } return $stuff; } # generateSiteMap()