#!/usr/local/bin/perl &DirInfo(); require $BinDir . 'setup.pl'; require $BinDir . 'g2lib.pl'; # require $BinDir . 'g2lib_upload.pl'; use CGI qw(:standard); $query = new CGI; $CategoryId = $query->param('category'); #---Look up the category desc. open(CATEGORY, $CategoryFile) or &g2WebAbort ("Unable to open " . $CategoryFile); while ($line=){ # Read until EOF chomp $line; ($id, $name) = split(/\t/, $line); # Split the input into fields if ($CategoryId eq $id) { $CatDesc = $name; } } close CATEGORY; #---Get the form template my $sForm = g2LoadFileScalar($TemplateShowArticle); dbmopen(%Catalog, $CatalogFile, 0666) or g2WebAbort("Unable to open $CatalogFile ($!)"); #---Read in the article catalog into a hash based on the article name foreach $FileName (keys %Catalog) { ($Id, $DocName, $DocDesc) = split(/\t/, $Catalog{$FileName}); if ($CategoryId eq $Id) { $articles{$DocName} = $FileName; } } #---Build article display list foreach $Doc (sort keys %articles) { ($Id, $DocName, $DocDesc) = split(/\t/, $Catalog{$articles{$Doc}}) or g2WebAbort("Split error ($!)"); $DocDesc =~ s/\\n/\r\n/g; $DocDesc =~ s/\\\"/\"/g; $ArticleList .= " \n"; $ArticleList .= " \n"; $ArticleList .= " \n"; $ArticleList .= " \n"; # $ArticleList .= " \n"; $ArticleList .= " \n"; $ArticleList .= " \n"; $ArticleList .= " \n"; $ArticleList .= " \n"; $ArticleList .= "
 

$DocName

$DocName

$DocDesc

\n"; } $sForm =~ s/\[CATEGORYDESC\]/$CatDesc/; $sForm =~ s/\[ARTICLELIST\]/$ArticleList/; g2HTMLStart(); print $sForm; dbmclose %Catalog; exit 0; #-------------------------------------------------------------------------------- sub DirInfo { if ($ENV{'OS'} eq 'Windows_NT') { $FullPath = $ENV{'PATH_TRANSLATED'}; } else { $FullPath = $ENV{'DOCUMENT_ROOT'} . $ENV{'SCRIPT_NAME'}; } my $sTemp = $ENV{'SCRIPT_NAME'}; $sTemp = $FullPath; $sTemp =~ tr/\\/\//; # replace all '\' with '/' my @dir = split(/\//, $sTemp); # split on '/' $This = @dir[scalar(@dir)-1]; $BinDir = ''; $BaseDir = ''; my $Levels = scalar(@dir); if ($Levels == 1) {$BinDir = './'; $BaseDir = '../';} else { $BinDir = substr($sTemp, 0, length($sTemp) - length($This)); if ($Levels == 2) {$BaseDir = '../';} else { $BaseDir = substr($sTemp, 0, length($sTemp) - length($This) - length(@dir[$Levels-2]) -1); } } } #--------------------------------------------------------------------------------