home *** CD-ROM | disk | FTP | other *** search
- #!/bin/sh
- perl=/usr/local/etc/architext/perl
- eval "exec $perl -x $0 $*"
- #!perl
-
- ## Copyright Architext Software, 1994 (c)
- ##
- ## This CGI script allows users to generate an Architext database
- ## query page and result page. Naturally, there are plenty of security
- ## concerns associated with this scheme.
- ##
- ## This script appears as several different web pages, depending on
- ## its invocation. If invoked with a 'db=<database>' argument, the
- ## script prints out the configuration information for a particular
- ## database and then allows the user to input a description of the
- ## database for the pages it will generate. If
- ## invoked with 'Generate=Generate', 'dbname=<database>',
- ## 'describe=<description>', and 'unprefix=<unprefix>'
- ## it will generate files for a database which has an existing database
- ## configuration file.
- ## Without any of these arguments, it displays a list of currently
- ## existing database.conf files, and allows the user to choose a database
- ## for which to generate pages.
- $| = 1; ## don't buffer output
-
- $root = "/usr/local/etc/architext";
-
- die "Invalid root directory '$root'\n" unless -d $root;
-
- unshift(@INC, "$root/perllib");
- require 'architext.pl';
- require 'architextConf.pl';
-
- %form = &Architext'readFormArgs;
- $form{'db'} = $form{'dbname'} unless $form{'db'};
- %attr = &ArchitextConf'readConfig("$root/Architext.conf", $form{'db'});
-
- if (&Architext'remoteMode($root)) {
- $helppath = &Architext'helpPath();
- } else {
- $helppath = $attr{'ArchitextURL'};
- }
-
- $scriptname = "AT-generate.cgi";
-
- ## check for password, if one is specified in Architext.conf
- ## if it doesn't appear as a form arg, present password page
- &Architext'password($attr{'ArchitextURL'},
- $scriptname,
- $attr{'Password'},
- $form{'password'});
-
- $attr{'Password'} =~ tr/a-zA-Z/n-za-mN-ZA-M/;
- $postpass =
- "<INPUT TYPE=\"hidden\" NAME=\"password\" VALUE=\"$attr{'Password'}\">" if
- ($attr{'Password'});
- $getpass = "?password=$attr{'Password'}" if $postpass;
-
- if ($form{'Dump'}) {
- &Architext'printHeader($attr{'ArchitextURL'},
- "View $form{'Type'} logfile");
- if (! -e $form{'File'}) {
- &Architext'exitError($attr{'ArchitextURL'},
- "Couldn't find '$form{'File'}'");
- }
- print "<hr><b>Collection Status</b><ul>\n";
- &Architext'printStatus($form{'db'}, $root, $attr{'ConfigRoot'},
- $attr{'ArchitextURL'}, $attr{'CollectionRoot'});
- print "</ul><hr>\n";
- print "\n<pre>\n";
- open(LOG, "$form{'File'}");
- while (<LOG>) {
- print;
- }
- close(LOG);
- print "\n</pre>\n<hr>";
- $filestub = $form{'File'};
- $filestub =~ s|\.\w{3,4}$||;
- print <<EOF;
- <b>Next steps:</b>
- <p><FORM ACTION="AT-generate.cgi" METHOD=POST>
- <INPUT TYPE="hidden" NAME="db" VALUE="$form{'db'}">
- <INPUT TYPE="submit" NAME="Reload" VALUE="Reload">
- Reload this page, in case the log file or status has changed.
- <INPUT TYPE="hidden" NAME="Dump" VALUE="dummy">
- <INPUT TYPE="hidden" NAME="File" VALUE="$form{'File'}">
- <INPUT TYPE="hidden" NAME="Type" VALUE="$form{'Type'}">
- $postpass
- </FORM>
-
- EOF
- ;
- if (! ($form{'Type'} eq 'progress')) {
- print <<EOF;
- <p><FORM ACTION="AT-generate.cgi" METHOD=POST>
- <INPUT TYPE="hidden" NAME="db" VALUE="$form{'db'}">
- <INPUT TYPE="submit" NAME="Progress" VALUE="Progress">
- Show the contents of the progress log file.
- <INPUT TYPE="hidden" NAME="Dump" VALUE="dummy">
- <INPUT TYPE="hidden" NAME="File" VALUE="$filestub.prog">
- <INPUT TYPE="hidden" NAME="Type" VALUE="progress">
- $postpass
- </FORM>
-
- EOF
- ;
- }
- if (! ($form{'Type'} eq 'verbose')) {
- print <<EOF;
- <p><FORM ACTION="AT-generate.cgi" METHOD=POST>
- <INPUT TYPE="hidden" NAME="db" VALUE="$form{'db'}">
- <INPUT TYPE="submit" NAME="Verbose Log" VALUE="Verbose Log">
- Show the contents of the verbose log file.
- <INPUT TYPE="hidden" NAME="Dump" VALUE="dummy">
- <INPUT TYPE="hidden" NAME="File" VALUE="$filestub.log">
- <INPUT TYPE="hidden" NAME="Type" VALUE="verbose">
- $postpass
- </FORM>
-
-
- EOF
- ;
- }
- if (! ($form{'Type'} eq 'error')) {
- print <<EOF;
- <p><FORM ACTION="AT-generate.cgi" METHOD=POST>
- <INPUT TYPE="hidden" NAME="db" VALUE="$form{'db'}">
- <INPUT TYPE="submit" NAME="Errors" VALUE="Errors">
- Show the contents of the error log file.
- <INPUT TYPE="hidden" NAME="Dump" VALUE="dummy">
- <INPUT TYPE="hidden" NAME="File" VALUE="$filestub.err">
- <INPUT TYPE="hidden" NAME="Type" VALUE="error">
- $postpass
- </FORM>
-
-
- EOF
- ;
- }
- print <<EOF;
- <p><FORM ACTION="AT-admin.cgi" METHOD=POST>
- <INPUT TYPE="hidden" NAME="db" VALUE="$form{'db'}">
- <INPUT TYPE="submit" NAME="Admin" VALUE="Admin">
- Go back to the admin page for this collection.
- $postpass
- </FORM>
-
- EOF
- ;
- &Architext'Copyright($attr{'ArchitextURL'});
- exit(0);
- }
-
- if ($form{'Status'}) {
- &Architext'printHeader($attr{'ArchitextURL'},
- "View Indexing Logfiles: $form{'db'}");
- print "<p> This page provides access to the three log files that the indexing process creates. \n";
- print "<hr><b>Collection Status</b><ul>\n";
- &Architext'printStatus($form{'db'}, $root, $attr{'ConfigRoot'},
- $attr{'ArchitextURL'}, $attr{'CollectionRoot'});
- print "</ul>\n";
- $logname = "AT-$form{'db'}.log";
- $progname = "AT-$form{'db'}.prog";
- $errname = "AT-$form{'db'}.err";
- $urlpath = "$root/collections";
-
- print <<EOF;
- <p><hr>
- <b>Logfiles:</b>
- <p>
- <FORM ACTION="AT-generate.cgi" METHOD="POST">
- <INPUT TYPE="hidden" NAME="Dump" VALUE="dummy">
- <INPUT TYPE="hidden" NAME="db" VALUE="$form{'db'}">
- <INPUT TYPE="hidden" NAME="Type" VALUE="progress">
- <INPUT TYPE="hidden" NAME="File" VALUE="$urlpath/$progname">
- <INPUT TYPE="submit" VALUE="Progress"> Show the progress of the indexing
- process.
- $postpass
- </FORM>
- <p>
- <FORM ACTION="AT-generate.cgi" METHOD="POST">
- <INPUT TYPE="hidden" NAME="Type" VALUE="verbose">
- <INPUT TYPE="hidden" NAME="db" VALUE="$form{'db'}">
- <INPUT TYPE="hidden" NAME="Dump" VALUE="dummy">
- <INPUT TYPE="hidden" NAME="File" VALUE="$urlpath/$logname">
- <INPUT TYPE="submit" VALUE="Verbose log"> Show a detailed log of
- the indexing process.
- $postpass
- </FORM>
- <p>
- <FORM ACTION="AT-generate.cgi" METHOD="POST">
- <INPUT TYPE="hidden" NAME="Type" VALUE="error">
- <INPUT TYPE="hidden" NAME="db" VALUE="$form{'db'}">
- <INPUT TYPE="hidden" NAME="Dump" VALUE="dummy">
- <INPUT TYPE="hidden" NAME="File" VALUE="$urlpath/$errname">
- <INPUT TYPE="submit" VALUE="Errors"> Show any errors that might
- have occured during indexing.
- $postpass
- </FORM>
- <hr>
- <b>Next steps:</b>
- <p>
- <FORM ACTION="AT-admin.cgi" METHOD=POST>
- <INPUT TYPE="hidden" NAME="db" VALUE="$form{'db'}">
- <INPUT TYPE="submit" NAME="Admin" VALUE="Admin">
- Go back to the admin page for this collection.
- $postpass
- </FORM>
- EOF
- ;
- &Architext'Copyright($attr{'ArchitextURL'});
- exit(0);
- }
-
- if ($form{'Generate'}) {
- if ($form{'qpage'} && $form{'unprefix'}) {
- ## Assuming all the relevant configuration options are specified
- ## as form arguments, this mode generates the pages.
- ## also checks for required elements
-
- ## Header again
- &Architext'printHeader($attr{'ArchitextURL'},
- "Search Page Generation: $form{'dbname'}");
-
- if (!$form{'dbname'}) {
- &Architext'exitError($attr{'ArchitextURL'},
- "Index specified with no dbname."); }
-
- ## Can we read the db.conf file?
- $dbconfig = $root . "/collections/" . $form{'dbname'} . ".conf";
- if (-e $dbconfig && ! -r $dbconfig) {
- &Architext'exitFileError($attr{'ArchitextURL'},
- $dbconfig,
- "does not exist or is not readable."); }
-
- ## create the default html pages here.
- ## on the query.html page to produce the search.cgi script
- &simpleQueryPage();
- &simpleQueryScript();
- &simpleGatherScript() if &Architext'asgMode();
-
- ## Let the user know the generation was successful.
- print "<H2>Generation successful.</H2>\n";
- print "<p>\n";
- $simplepage = $form{'qpage'};
- $simplepage .= ".html" unless $simplepage =~ /\.html$/;
-
- ## set up proper arguments for moving scripts to cgi-bin
- $form{'qname'} = $simplepage;
- $form{'qscript'} = "AT-$form{'dbname'}search.cgi";
- $form{'gscript'} = "AT-$form{'dbname'}gather.cgi"
- if &Architext'asgMode();
- $files = "<b>$form{'qscript'}</b>";
- $files .= " and <b>$form{'gscript'}</b>"
- if &Architext'asgMode();
-
- if ($form{'Move'}) {
- $gatherscript = "$attr{'ConfigRoot'}/$form{'gscript'}"
- if &Architext'asgMode();
- $cmd = "cp $attr{'ConfigRoot'}/$form{'qscript'} $gatherscript $attr{'CgiBin'}";
- $exit = system($cmd);
- if (! $exit) {
- unlink("$attr{'ConfigRoot'}/$form{'qscript'}");
- unlink("$attr{'ConfigRoot'}/$gatherscript")
- if &Architext'asgMode();
- ## print "<h2> Moving successful. </h2>\n<p>";
-
- print <<EOF;
- Your <b>cgi</b> scripts ($files)
- have been generated and installed in your
- <b>cgi-bin</b> directory, <b>$attr{'CgiBin'}</b>.
- EOF
- ;
-
- if (-e "$root/collections/$form{'dbname'}.last") {
- print <<EOF;
- <p>Since you have already created your indexes for this document collection,
- you can now
- <A HREF="$attr{'ArchitextURL'}$form{'qname'}">
- <b>Start Searching!</b></a>
- EOF
- ;
- }
- print <<EOF;
- <p> Once you have tested <b>$form{'qname'}</b> to your liking,
- feel free to move it from the Architext administration directory
- (<b>$attr{'ConfigRoot'}</b>) into a directory better suited to
- your needs.
- EOF
- ;
- } else {
- print <<EOF;
- <h2>Problem moving '$files' from
- $attr{'ConfigRoot'} to $attr{'CgiBin'} -- $!</h2>
-
- <p>Your scripts have been generated, but they were not copied
- into your <b>cgi-bin</b> (<b>$attr{'CgiBin'}</b>) directory because
- an error was encountered (probably a permissions problem)
- while moving the files. Before you can do queries,
- you will either need to move the scripts that
- were just generated ($files)
- into <b>$attr{'CgiBin'}</b>, or
- you can try to <b>Generate</b> the scripts again after investigating
- the problem.
- EOF
- ;
- }
- } else {
- ## user's cgi-bin was not writeable, so we won't try to move
- ## the scripts there
- print <<EOF;
-
- <p> Your scripts have generated, but were not copied into your
- cgi-bin directory (<b>$attr{'CgiBin'}</b>), because it
- is not writeable by the userid your Web server is running under.
- <p><b> IMPORTANT: Before you can being making queries, you must copy the CGI
- scripts that were generated into your cgi-bin directory.</b>
-
- <p> Copy $files from the directory
- <b>$attr{'ConfigRoot'}</b> to the cgi-bin directory, and you
- can begin making queries.
-
- EOF
- ;
- }
-
- print <<EOF;
- <p> <b>SECURITY ISSUE:</b> Remember that by making the query page available
- to users of your Web site, you are giving them easy access to all
- the pages on your site that have been indexed. If you have sensitive
- information that you do not wish to be available to every user of
- your Web site, consider leaving those files out of your indexes, or
- consider making the search page secure in order to restrict access to it.
- <hr><b>Next steps:</b>
- EOF
- ;
- if (! ((-e "$root/collections/$form{'dbname'}.last") ||
- (-e "$root/collections/$form{'dbname'}.pid") ||
- (-e "$root/collections/new/$form{'dbname'}.err")))
- {
- print <<EOF;
- <p> <FORM ACTION="AT-index.cgi" METHOD=POST>
- <INPUT TYPE="submit" NAME="Indexing" VALUE="Index">
- Create an index for this collection.
- <INPUT TYPE="hidden" NAME="db" VALUE="$form{'dbname'}">
- $postpass
- </FORM>
- EOF
- ;
- }
-
- if ((-e "$root/collections/$form{'dbname'}.pid")
- || (-e "$root/collections/$form{'dbname'}.last")
- || (-e "$root/collections/new/$form{'dbname'}.err" )) {
- print <<EOF;
- <p> <FORM ACTION="AT-generate.cgi" METHOD=POST>
- <INPUT TYPE="submit" NAME="Status" VALUE="Status">
- Check the status of indexing on this collection.
- <INPUT TYPE="hidden" NAME="db" VALUE="$form{'dbname'}">
- $postpass
- </FORM>
-
- EOF
- ;
- }
- print <<EOF;
- <p>
- <FORM ACTION="AT-admin.cgi" METHOD=POST>
- <INPUT TYPE="submit" NAME="Admin" VALUE="Admin">
- <INPUT TYPE="hidden" NAME="db" VALUE="$form{'dbname'}">
- Go back to the admin page for this collection.
- $postpass
- </FORM>
-
- EOF
- ;
- &Architext'Copyright($attr{'ArchitextURL'});
- exit(0);
- } else {
- ## required elements were not passed in.
- $message = "<b>You didn't enter a value for a required field. Try again.</b>";
- $form{'db'} = $form{'dbname'};
- }
- }
- if ($form{'db'}) {
- ## Print out configuration options for an already-existing
- ## database so the user knows what will happen upon page generation
-
- ## Dump our standard header
- &Architext'printHeader($attr{'ArchitextURL'},
- "Search Page Generation: $form{'db'}");
-
- ## Check for the desired database.conf file.
- $dbconfig = $root . "/collections/" . $form{'db'} . ".conf";
- if (! -r $dbconfig) {
- &Architext'exitFileError($attr{'ArchitextURL'},
- $dbconfig, "does not exist"); }
-
- ## Read all the configuration information.
- ## %attr = &ArchitextConf'readConfig("$root/Architext.conf", $form{'db'});
-
- ## advise the user if required fields were not passed in
- print $message if $message;
-
- print "<p> The collection you have chosen has ";
- print "the following characteristics:\n";
- ## Print the form.
- ## This form is just a little list of the options.
- &printForm($form{'db'});
- if ($getpass) {
- $getpass .= "&";
- } else {
- $getpass = "?";
- }
- $getpass .= "db=$form{'db'}";
- &Architext'Copyright($attr{'ArchitextURL'});
- exit(0);
-
- } else {
- ## Print out the top-level screen: scan the root directory for
- ## db.conf files, and allow the user to initialize a new db.conf
- ## file.
-
- opendir(CONF, "$root/collections");
- @dbconf = grep(/\.conf$/, readdir(CONF));
-
- &Architext'printHeader($attr{'ArchitextURL'},"Search Page Generation");
- if ($#dbconf > -1) {
- print <<EOF;
- <FORM ACTION="http:AT-generate.cgi" METHOD=POST>
- Choose a document collection for which to generate query and result pages.<P>
- <DL>
- <DT>
- Existing <a href="${helppath}AT-helpdoc.html#Document Collections">document collections:</a> <DD>
- <SELECT NAME="db" SIZE=5>
- EOF
- ;
- for (@dbconf) {
- s|\.conf$||;
- next if $_ eq 'Architext';
- print "<OPTION> $_\n";
- }
- print <<EOF;
- </SELECT>
- </DL>
- <INPUT TYPE="submit" NAME="select" VALUE="Select">
- $postpass
- </FORM>
- EOF
- ;
- } else {
- print <<EOF;
- <p> There are no document collections currently defined. Please
- click on the configure button to go to the collection configuration
- screen.
- <FORM ACTION="http:AT-config.cgi" METHOD=POST>
- <INPUT TYPE="submit" VALUE="Configure">
- $postpass
- </FORM>
- EOF
- ;
- }
- &Architext'Copyright($attr{'ArchitextURL'});
- }
-
- ## Prints an input line for a form.
- sub printLineItem {
- local($name, $text) = @_;
- local($val);
- $text = $name unless $text;
- $val = eval "\$attr{$name}";
- print qq(<li> <a href="${helppath}AT-helpdoc.html#$text">$text:</a> $val\n);
- }
-
- ## Prints out the Architext form. Uses dynamic scoping to ensure that
- ## the values in the %attr array are properly set.
- sub printForm {
- local($db) = shift;
- local ($size) = 30;
- local($url) = $attr{'ArchitextURL'};
- print "<UL>\n";
- &Architext'printLineItem($url,'IndexExecutable',
- $attr{'IndexExecutable'})
- if &Architext'debugMode();
- &Architext'printLineItem($url,'SearchExecutable',
- $attr{'SearchExecutable'})
- if &Architext'debugMode();
- &Architext'printLineItem($url,'StemTable',$attr{'StemTable'})
- if &Architext'debugMode();
- &Architext'printLineItem($url,'StopTable',$attr{'StopTable'})
- if &Architext'debugMode();
- &Architext'printLineItem($url,'CollectionInfo', $attr{'CollectionInfo'})
- if &Architext'debugMode();
- &Architext'printLineItem($url,'CollectionIndex',
- $attr{'CollectionIndex'});
- if ($attr{'CollectionContents'} =~ /^\+/) {
- $attr{'CollectionContents'} =~ s/^\+//;
- print <<EOF;
- <li> <a href="${helppath}AT-helpdoc.html#CollectionContents">
- CollectionContents:</a> Index the files listed in
- '$attr{'CollectionContents'}'.
- EOF
- ;
- } else {
- $files = join(", ", split(/[:,;\s]+/, $attr{'CollectionContents'}));
- print <<EOF;
- <li> <a href="${helppath}AT-helpdoc.html#CollectionContents">
- CollectionContents:</a> Index the files '$files' using these rules:<ul>
- EOF
- ;
- &Architext'printLineItem($url,'IndexFilter',
- $attr{'IndexFilter'});
- &Architext'printLineItem($url,'ExclusionRules',
- $attr{'ExclusionRules'});
- print "</ul>";
- }
- &Architext'printLineItem($url,'AdminMail',
- $attr{'AdminMail'});
- $size = (length($attr{'HtmlRoot'})+10)
- unless ((length($attr{'HtmlRoot'})+10) < 30);
- $qlength = (length($attr{'ArchitextURL'}) +
- length("pictures/AT-Block-logo.gif") + 10);
- print "</UL>\n";
- print qq(<FORM ACTION="http:AT-generate.cgi" METHOD=POST>\n);
- if (($attr{'CgiBin'}) && (-w "$attr{'CgiBin'}")) {
- print qq(<INPUT TYPE="hidden" NAME="Move" VALUE="yes">\n);
- }
- print <<EOF;
- <p><b>Required Information</b><ul>
- <INPUT TYPE="hidden" NAME="qpage" VALUE="AT-$form{'db'}query.html">
- <p>Enter <a href="${helppath}AT-helpdoc.html#Path Prefix">path prefix</a>
- to remove from result URLs: <INPUT NAME="unprefix"
- VALUE="$attr{'HtmlRoot'}" SIZE=$size>
- </ul>
- <p> <b>Optional Information</b><ul>
- <p> Enter <a href="${helppath}AT-helpdoc.html#Banner Image">
- Banner Image </a> to appear at the top of query and result pages:
- <INPUT NAME="qimage" VALUE="$attr{'ArchitextURL'}pictures/AT-Block-logo.gif"
- SIZE=$qlength>
- <p>Enter a <a href="${helppath}AT-helpdoc.html#Brief Description">
- brief description</a>
- of the contents of your database for use in
- the query page. The generated query page will appear in
- <b>$attr{'ConfigRoot'}</b>.
- <TEXTAREA NAME="describe" COLS=60 ROWS=4></TEXTAREA>
- </ul>
- <p><INPUT TYPE="submit" NAME="generate" VALUE="Generate">
- Generate the query pages and scripts need to perform queries.
- <INPUT TYPE="hidden" NAME="Generate" VALUE="Generate">
- <INPUT TYPE="hidden" NAME="dbname" VALUE="$db">
- $postpass
- </FORM>
- <p>
- <FORM ACTION="AT-admin.cgi" METHOD=POST>
- <INPUT TYPE="hidden" NAME="db" VALUE="$db">
- <INPUT TYPE="submit" NAME="Admin" VALUE="Admin">
- Go back to the admin page for this collection.
- $postpass
- </FORM>
-
- EOF
- ;
- }
-
- ## prints a default query page with a simple description
- sub simpleQueryPage {
- local($simplepage);
- local($exit);
- local($cgi);
- ## calculate location of cgi-bin directory
- $cgi = $ENV{'SCRIPT_NAME'};
- $cgi =~ s/\/?[^\/]+$//;
- $simplepage = $form{'qpage'};
- $simplepage .= ".html" unless $simplepage =~ /\.html$/;
- $simplepage = $root . "/" . $simplepage;
- open(SPAGE, ">$simplepage") ||
- &Architext'exitFileError($attr{'ArchitextURL'},
- $simplepage,
- "could not be opened for writing.");
- print SPAGE "<html><head><title>Architext Querying</title></head>\n";
- print SPAGE qq(<body><h1> <img src="$form{'qimage'}"> </h1>\n)
- if $form{'qimage'};
- print SPAGE "<p><b>Database description:</b> $form{'describe'} \n<p>\n"
- if ($form{'describe'} =~ /\w/);
- print SPAGE "Enter a natural language query in the form below.\n";
- print SPAGE qq(<p>\n<FORM ACTION="$cgi/AT-$form{'dbname'}search.cgi" METHOD="POST">\n);
- print SPAGE qq(Search Type:\n);
- print SPAGE qq(<INPUT TYPE="radio" NAME="mode" VALUE="concept" CHECKED> Concept\n);
- print SPAGE qq(<INPUT TYPE="radio" NAME="mode" VALUE="simple"> Query words only\n);
- print SPAGE qq(<br><TEXTAREA NAME="search" COLS=50 ROWS=4></TEXTAREA><br>\n);
- print SPAGE qq(<INPUT TYPE="submit" VALUE="Search">\n);
- print SPAGE qq(</FORM>);
- print SPAGE qq(<p> Documentation about <a href="AT-queryhelp.html">making queries</a> is available.);
- print SPAGE qq(<p><p><b>TIP:</b> If you plan on making multiple queries, you might wish to make a bookmark for this page.);
-
- close(SPAGE);
- ## don't copy files if config root and architext root are the same
- if ($root ne $attr{'ConfigRoot'}) {
- $exit = system("cp $simplepage $attr{'ConfigRoot'}");
- &Architext'exitError($attr{'ArchitextURL'},
- "Cannot copy $simplepage to $attr{'ConfigRoot'}") if $exit;
- }
- #$exit = system("cp $root/AT-Block-logo.gif $attr{'HtmlRoot'}");
- #&Architext'exitError($attr{'ArchitextURL'},
- # "Cannot copy $root/AT-Block-logo.gif to $attr{'HtmlRoot'}") if $exit;
- }
-
- ## prints a default query-result html and then creates the query script
- ## moves the old .cgi script out of the way to .cgi.old if it exists.
- sub simpleQueryScript {
- local($simplepage);
- local($cmd);
- local($exit);
- local($prefix);
- ## add a trailing '/' to unprefix if it is not there
- $prefix = $form{'unprefix'};
- $prefix .= "/" unless ($prefix =~ /\/$/);
-
- $simplepage = "AT-$form{'dbname'}search.html";
- $simplepage = $root . "/" . $simplepage;
- open (QPAGE, ">$simplepage") ||
- &Architext'exitFileError($attr{'ArchitextURL'},
- $simplepage,
- "could not be opened for writing.");
-
- print QPAGE qq(<html>\n<head>\n<title> Results From Your Architext Query</title>\n<body>\n);
- print QPAGE qq(<h1> <img src="$form{'qimage'}"> </h1>\n)
- if $form{'qimage'};
- print QPAGE qq(<ARCHITEXT-INDEX-CHECK ROOT="$attr{'CollectionRoot'}">\n);
- print QPAGE qq(<ARCHITEXT-RESULT DB="$form{'dbname'}" UNPREFIX="$prefix" AHOME="$attr{'ArchitextURL'}">\n);
-
- ## check for advanced feature mode, add ASG if appropriate
- if (&Architext'asgMode()) {
- print QPAGE qq(<ARCHITEXT-MAKE-GATHER DB="$form{'dbname'}" UNPREFIX="$prefix" AHOME="$attr{'ArchitextURL'}">\n);
- }
- print QPAGE qq(<ARCHITEXT-LEGEND DB="$form{'dbname'}" AHOME="$attr{'ArchitextURL'}">\n);
- print QPAGE qq(</body>\n</html>\n);
- close(QPAGE);
-
- ## call architextify-html here to produce queryscript.cgi
- $cmd = "$root/architextify-html -f $simplepage";
- $exit = system($cmd);
- &Architext'exitError($attr{'ArchitextURL'},
- "Problem encountered generating AT-$form{'dbname'}search.cgi - $!") if $exit;
- system("rm -f $simplepage");
- ## don't copy files if config root and architext root are the same
- if ($root ne $attr{'ConfigRoot'}) {
- $exit = system("cp $root/AT-$form{'dbname'}search.cgi $attr{'ConfigRoot'}");
- &Architext'exitError($attr{'ArchitextURL'},
- "Cannot copy $root/AT-$form{'dbname'}search.cgi to $attr{'ConfigRoot'}") if $exit;
- }
- }
-
- ## prints a default query-result html and then creates the query script
- ## moves the old .cgi script out of the way to .cgi.old if it exists.
- sub simpleGatherScript {
- local($simplepage);
- local($cmd);
- local($exit);
- local($prefix);
- ## add a trailing '/' to unprefix if it is not there
- $prefix = $form{'unprefix'};
- $prefix .= "/" unless ($prefix =~ /\/$/);
-
- $simplepage = "AT-$form{'dbname'}gather.html";
- $simplepage = $root . "/" . $simplepage;
- open (QPAGE, ">$simplepage") ||
- &exitFileError($attr{'ArchitextURL'},
- $simplepage, "could not be opened for writing.");
-
- print QPAGE qq(<html>\n<head>\n<title> Architext Automatic Subject Grouping</title>\n<body>\n);
- print QPAGE qq(<h1> <img src="$form{'qimage'}"> </h1>\n)
- if $form{'qimage'};
- print QPAGE qq(\n<h1>Subject Grouping</h1>);
- print QPAGE qq(<UL><ARCHITEXT-GATHER DB="$form{'dbname'}" UNPREFIX="$prefix" AHOME="$attr{'ArchitextURL'}"></UL>\n);
- print QPAGE qq(<ARCHITEXT-LEGEND DB="$form{'dbname'}" AHOME="$attr{'ArchitextURL'}">\n);
- print QPAGE qq(</body>\n</html>\n);
- close(QPAGE);
-
- ## call architextify-html here to produce queryscript.cgi
- $cmd = "$root/architextify-html -f $simplepage";
- $exit = system($cmd);
- &Architext'exitError($attr{'ArchitextURL'},
- "Problem encountered generating $form{'dbname'}gather.cgi") if $exit;
- system("rm -f $simplepage");
- ## don't copy files if config root and architext root are the same
- if ($root ne $attr{'ConfigRoot'}) {
- $exit = system("cp $root/AT-$form{'dbname'}gather.cgi $attr{'ConfigRoot'}");
- &Architext'exitError($attr{'ArchitextURL'},
- "Cannot copy $root/AT-$form{'dbname'}gather.cgi to $attr{'ConfigRoot'}") if $exit;
- }
- }
-
-