home *** CD-ROM | disk | FTP | other *** search
/ SGI Hot Mix 12 / Silicon_Graphics_Developer_Magic_Soft_Dev_812-8101-012.iso / .all / httpd_ncsa / cgi-bin / AT-generate.cgi < prev    next >
Encoding:
Text File  |  1995-11-10  |  23.3 KB  |  694 lines

  1. #!/bin/sh
  2. perl=/usr/local/etc/architext/perl
  3. eval "exec $perl -x $0 $*"
  4. #!perl
  5.  
  6. ## Copyright Architext Software, 1994 (c)
  7. ##
  8. ## This CGI script allows users to generate an Architext database
  9. ## query page and result page. Naturally, there are plenty of security
  10. ## concerns associated with this scheme.
  11. ##
  12. ## This script appears as several different web pages, depending on
  13. ## its invocation. If invoked with a 'db=<database>' argument, the
  14. ## script prints out the configuration information for a particular
  15. ## database and then allows the user to input a description of the
  16. ## database for the pages it will generate. If
  17. ## invoked with 'Generate=Generate', 'dbname=<database>',
  18. ## 'describe=<description>', and 'unprefix=<unprefix>' 
  19. ## it will generate files for a database which has an existing database 
  20. ## configuration file. 
  21. ## Without any of these arguments, it displays a list of currently 
  22. ## existing database.conf files, and allows the user to choose a database 
  23. ## for which to generate pages.
  24. $| = 1;  ## don't buffer output
  25.  
  26. $root = "/usr/local/etc/architext";
  27.  
  28. die "Invalid root directory '$root'\n" unless -d $root;
  29.  
  30. unshift(@INC, "$root/perllib");
  31. require 'architext.pl';
  32. require 'architextConf.pl';
  33.  
  34. %form = &Architext'readFormArgs;
  35. $form{'db'} = $form{'dbname'} unless $form{'db'};
  36. %attr = &ArchitextConf'readConfig("$root/Architext.conf", $form{'db'});
  37.  
  38. if (&Architext'remoteMode($root)) {
  39.     $helppath = &Architext'helpPath();
  40. } else {
  41.     $helppath = $attr{'ArchitextURL'};
  42. }
  43.  
  44. $scriptname = "AT-generate.cgi";
  45.  
  46. ## check for password, if one is specified in Architext.conf
  47. ## if it doesn't appear as a form arg, present password page
  48. &Architext'password($attr{'ArchitextURL'},
  49.             $scriptname,
  50.             $attr{'Password'}, 
  51.             $form{'password'});
  52.  
  53. $attr{'Password'} =~ tr/a-zA-Z/n-za-mN-ZA-M/;
  54. $postpass = 
  55.     "<INPUT TYPE=\"hidden\" NAME=\"password\" VALUE=\"$attr{'Password'}\">" if
  56.     ($attr{'Password'});
  57. $getpass = "?password=$attr{'Password'}" if $postpass;
  58.  
  59. if ($form{'Dump'}) {
  60.     &Architext'printHeader($attr{'ArchitextURL'},
  61.                "View $form{'Type'} logfile");
  62.     if (! -e $form{'File'}) {
  63.     &Architext'exitError($attr{'ArchitextURL'},
  64.                  "Couldn't find '$form{'File'}'");
  65.     }
  66.     print "<hr><b>Collection Status</b><ul>\n";
  67.     &Architext'printStatus($form{'db'}, $root, $attr{'ConfigRoot'},
  68.                    $attr{'ArchitextURL'}, $attr{'CollectionRoot'});
  69.     print "</ul><hr>\n";
  70.     print "\n<pre>\n";
  71.     open(LOG, "$form{'File'}");
  72.     while (<LOG>) {
  73.     print;
  74.     }
  75.     close(LOG);
  76.     print "\n</pre>\n<hr>";
  77.     $filestub = $form{'File'};
  78.     $filestub =~ s|\.\w{3,4}$||;
  79.     print <<EOF;
  80. <b>Next steps:</b>
  81. <p><FORM ACTION="AT-generate.cgi" METHOD=POST>
  82. <INPUT TYPE="hidden" NAME="db" VALUE="$form{'db'}">
  83. <INPUT TYPE="submit" NAME="Reload" VALUE="Reload">
  84. Reload this page, in case the log file or status  has changed.
  85. <INPUT TYPE="hidden" NAME="Dump" VALUE="dummy">
  86. <INPUT TYPE="hidden" NAME="File" VALUE="$form{'File'}">
  87. <INPUT TYPE="hidden" NAME="Type" VALUE="$form{'Type'}">
  88. $postpass
  89. </FORM>
  90.  
  91. EOF
  92.     ;
  93.     if (! ($form{'Type'} eq 'progress')) {
  94.     print <<EOF;
  95. <p><FORM ACTION="AT-generate.cgi" METHOD=POST>
  96. <INPUT TYPE="hidden" NAME="db" VALUE="$form{'db'}">
  97. <INPUT TYPE="submit" NAME="Progress" VALUE="Progress">
  98. Show the contents of the progress log file.
  99. <INPUT TYPE="hidden" NAME="Dump" VALUE="dummy">
  100. <INPUT TYPE="hidden" NAME="File" VALUE="$filestub.prog">
  101. <INPUT TYPE="hidden" NAME="Type" VALUE="progress">
  102. $postpass
  103. </FORM>
  104.  
  105. EOF
  106.     ;
  107.     }
  108.     if (! ($form{'Type'} eq 'verbose')) {
  109.     print <<EOF;
  110. <p><FORM ACTION="AT-generate.cgi" METHOD=POST>
  111. <INPUT TYPE="hidden" NAME="db" VALUE="$form{'db'}">
  112. <INPUT TYPE="submit" NAME="Verbose Log" VALUE="Verbose Log">
  113. Show the contents of the verbose log file.
  114. <INPUT TYPE="hidden" NAME="Dump" VALUE="dummy">
  115. <INPUT TYPE="hidden" NAME="File" VALUE="$filestub.log">
  116. <INPUT TYPE="hidden" NAME="Type" VALUE="verbose">
  117. $postpass
  118. </FORM>
  119.  
  120.  
  121. EOF
  122.     ;
  123.     }
  124.     if (! ($form{'Type'} eq 'error')) {
  125.     print <<EOF;
  126. <p><FORM ACTION="AT-generate.cgi" METHOD=POST>
  127. <INPUT TYPE="hidden" NAME="db" VALUE="$form{'db'}">
  128. <INPUT TYPE="submit" NAME="Errors" VALUE="Errors">
  129. Show the contents of the error log file.
  130. <INPUT TYPE="hidden" NAME="Dump" VALUE="dummy">
  131. <INPUT TYPE="hidden" NAME="File" VALUE="$filestub.err">
  132. <INPUT TYPE="hidden" NAME="Type" VALUE="error">
  133. $postpass
  134. </FORM>
  135.  
  136.  
  137. EOF
  138.     ;
  139.     }
  140.     print <<EOF;
  141. <p><FORM ACTION="AT-admin.cgi" METHOD=POST>
  142. <INPUT TYPE="hidden" NAME="db" VALUE="$form{'db'}">
  143. <INPUT TYPE="submit" NAME="Admin" VALUE="Admin">
  144. Go back to the admin page for this collection.
  145. $postpass
  146. </FORM>
  147.  
  148. EOF
  149.     ;
  150.     &Architext'Copyright($attr{'ArchitextURL'});
  151.     exit(0);
  152. }
  153.  
  154. if ($form{'Status'}) {
  155.     &Architext'printHeader($attr{'ArchitextURL'}, 
  156.                    "View Indexing Logfiles: $form{'db'}");
  157.     print "<p> This page provides access to the three log files that the indexing process creates.  \n";
  158.     print "<hr><b>Collection Status</b><ul>\n";
  159.     &Architext'printStatus($form{'db'}, $root, $attr{'ConfigRoot'},
  160.                    $attr{'ArchitextURL'}, $attr{'CollectionRoot'});
  161.     print "</ul>\n";
  162.     $logname = "AT-$form{'db'}.log";
  163.     $progname = "AT-$form{'db'}.prog";
  164.     $errname = "AT-$form{'db'}.err";
  165.     $urlpath = "$root/collections";
  166.     
  167. print <<EOF;
  168. <p><hr>
  169. <b>Logfiles:</b>
  170. <p>
  171. <FORM ACTION="AT-generate.cgi" METHOD="POST">
  172. <INPUT TYPE="hidden" NAME="Dump" VALUE="dummy">
  173. <INPUT TYPE="hidden" NAME="db" VALUE="$form{'db'}">
  174. <INPUT TYPE="hidden" NAME="Type" VALUE="progress">
  175. <INPUT TYPE="hidden" NAME="File" VALUE="$urlpath/$progname">
  176. <INPUT TYPE="submit" VALUE="Progress"> Show the progress of the indexing 
  177. process.
  178. $postpass
  179. </FORM>
  180. <p>
  181. <FORM ACTION="AT-generate.cgi" METHOD="POST">
  182. <INPUT TYPE="hidden" NAME="Type" VALUE="verbose">
  183. <INPUT TYPE="hidden" NAME="db" VALUE="$form{'db'}">
  184. <INPUT TYPE="hidden" NAME="Dump" VALUE="dummy">
  185. <INPUT TYPE="hidden" NAME="File" VALUE="$urlpath/$logname">
  186. <INPUT TYPE="submit" VALUE="Verbose log"> Show a detailed log of
  187. the indexing process.
  188. $postpass
  189. </FORM>
  190. <p>
  191. <FORM ACTION="AT-generate.cgi" METHOD="POST">
  192. <INPUT TYPE="hidden" NAME="Type" VALUE="error">
  193. <INPUT TYPE="hidden" NAME="db" VALUE="$form{'db'}">
  194. <INPUT TYPE="hidden" NAME="Dump" VALUE="dummy">
  195. <INPUT TYPE="hidden" NAME="File" VALUE="$urlpath/$errname">
  196. <INPUT TYPE="submit" VALUE="Errors"> Show any errors that might
  197. have occured during indexing.
  198. $postpass
  199. </FORM>
  200. <hr>
  201. <b>Next steps:</b>
  202. <p>
  203. <FORM ACTION="AT-admin.cgi" METHOD=POST>
  204. <INPUT TYPE="hidden" NAME="db" VALUE="$form{'db'}">
  205. <INPUT TYPE="submit" NAME="Admin" VALUE="Admin">
  206. Go back to the admin page for this collection.
  207. $postpass
  208. </FORM>
  209. EOF
  210.     ;
  211.     &Architext'Copyright($attr{'ArchitextURL'});
  212.     exit(0);
  213. }
  214.  
  215. if ($form{'Generate'}) {
  216.     if ($form{'qpage'} && $form{'unprefix'}) {
  217.     ## Assuming all the relevant configuration options are specified
  218.     ## as form arguments, this mode generates the pages.
  219.     ## also checks for required elements 
  220.  
  221.     ## Header again
  222.     &Architext'printHeader($attr{'ArchitextURL'}, 
  223.                    "Search Page Generation: $form{'dbname'}");
  224.  
  225.     if (!$form{'dbname'}) { 
  226.         &Architext'exitError($attr{'ArchitextURL'},
  227.                  "Index specified with no dbname."); }
  228.  
  229.     ## Can we read the db.conf file?
  230.     $dbconfig = $root . "/collections/" . $form{'dbname'} . ".conf";
  231.     if (-e $dbconfig && ! -r $dbconfig) {
  232.         &Architext'exitFileError($attr{'ArchitextURL'},
  233.                      $dbconfig, 
  234.                      "does not exist or is not readable."); }
  235.     
  236.     ## create the default html pages here.
  237.     ## on the query.html page to produce the search.cgi script
  238.     &simpleQueryPage();
  239.     &simpleQueryScript();
  240.     &simpleGatherScript() if &Architext'asgMode();
  241.     
  242.     ## Let the user know the generation was successful.
  243.     print "<H2>Generation successful.</H2>\n";
  244.     print "<p>\n";
  245.     $simplepage = $form{'qpage'};
  246.     $simplepage .= ".html" unless $simplepage =~ /\.html$/;
  247.     
  248.     ## set up proper arguments for moving scripts to cgi-bin
  249.     $form{'qname'} = $simplepage;
  250.     $form{'qscript'} = "AT-$form{'dbname'}search.cgi";
  251.     $form{'gscript'} = "AT-$form{'dbname'}gather.cgi"
  252.              if &Architext'asgMode();
  253.         $files = "<b>$form{'qscript'}</b>";
  254.         $files .= " and <b>$form{'gscript'}</b>" 
  255.              if &Architext'asgMode();
  256.  
  257.     if ($form{'Move'}) {
  258.         $gatherscript = "$attr{'ConfigRoot'}/$form{'gscript'}"
  259.         if &Architext'asgMode();
  260.         $cmd = "cp $attr{'ConfigRoot'}/$form{'qscript'} $gatherscript $attr{'CgiBin'}";
  261.         $exit = system($cmd);
  262.         if (! $exit) {
  263.             unlink("$attr{'ConfigRoot'}/$form{'qscript'}");
  264.             unlink("$attr{'ConfigRoot'}/$gatherscript") 
  265.                  if &Architext'asgMode();
  266.         ## print "<h2> Moving successful. </h2>\n<p>";
  267.  
  268.         print <<EOF;
  269. Your <b>cgi</b> scripts ($files)
  270. have been generated and installed in your
  271. <b>cgi-bin</b> directory, <b>$attr{'CgiBin'}</b>.
  272. EOF
  273. ;
  274.  
  275. if (-e "$root/collections/$form{'dbname'}.last") {
  276. print <<EOF;
  277. <p>Since you have already created your indexes for this document collection, 
  278. you can now 
  279. <A HREF="$attr{'ArchitextURL'}$form{'qname'}">
  280. <b>Start Searching!</b></a>
  281. EOF
  282. ;
  283. }
  284. print <<EOF;
  285. <p> Once you have tested <b>$form{'qname'}</b> to your liking, 
  286. feel free to move it from the Architext administration directory
  287. (<b>$attr{'ConfigRoot'}</b>) into a directory better suited to 
  288. your needs.
  289. EOF
  290.     ;
  291. } else {
  292. print <<EOF;
  293. <h2>Problem moving '$files' from 
  294. $attr{'ConfigRoot'} to $attr{'CgiBin'} -- $!</h2>
  295.  
  296. <p>Your scripts have been generated, but they were not copied
  297. into your <b>cgi-bin</b> (<b>$attr{'CgiBin'}</b>) directory because
  298. an error was encountered (probably a permissions problem)
  299. while moving the files. Before you can do queries, 
  300. you will either need to move the scripts that
  301. were just generated ($files) 
  302. into <b>$attr{'CgiBin'}</b>, or
  303. you can try to <b>Generate</b> the scripts again after investigating
  304. the problem.
  305. EOF
  306.     ;
  307. }
  308. } else {
  309.     ## user's cgi-bin was not writeable, so we won't try to move 
  310.     ## the scripts there
  311.     print <<EOF;
  312.  
  313. <p> Your scripts have generated, but were not copied into your
  314. cgi-bin directory (<b>$attr{'CgiBin'}</b>), because it
  315. is not writeable by the userid your Web server is running under.
  316. <p><b> IMPORTANT: Before you can being making queries, you must copy the CGI
  317. scripts that were generated into your cgi-bin directory.</b>
  318.  
  319. <p> Copy $files from the directory
  320. <b>$attr{'ConfigRoot'}</b> to the cgi-bin directory, and you
  321. can begin making queries.
  322.  
  323. EOF
  324.     ;
  325. }
  326.  
  327. print <<EOF;
  328. <p> <b>SECURITY ISSUE:</b>  Remember that by making the query page available
  329. to users of your Web site, you are giving them easy access to all
  330. the pages on your site that have been indexed.  If you have sensitive
  331. information that you do not wish to be available to every user of
  332. your Web site, consider leaving those files out of your indexes, or
  333. consider making the search page secure in order to restrict access to it.
  334. <hr><b>Next steps:</b>
  335. EOF
  336.     ;
  337. if (! ((-e "$root/collections/$form{'dbname'}.last") ||
  338.        (-e "$root/collections/$form{'dbname'}.pid") ||
  339.        (-e "$root/collections/new/$form{'dbname'}.err")))
  340. {                   
  341.     print <<EOF;
  342. <p> <FORM ACTION="AT-index.cgi" METHOD=POST>
  343. <INPUT TYPE="submit" NAME="Indexing" VALUE="Index">
  344. Create an index for this collection.
  345. <INPUT TYPE="hidden" NAME="db" VALUE="$form{'dbname'}">
  346. $postpass
  347. </FORM>
  348. EOF
  349.     ;
  350. }
  351.  
  352. if ((-e "$root/collections/$form{'dbname'}.pid") 
  353.     || (-e "$root/collections/$form{'dbname'}.last")
  354.     || (-e "$root/collections/new/$form{'dbname'}.err" )) {
  355. print <<EOF;
  356. <p> <FORM ACTION="AT-generate.cgi" METHOD=POST>
  357. <INPUT TYPE="submit" NAME="Status" VALUE="Status">
  358. Check the status of indexing on this collection.
  359. <INPUT TYPE="hidden" NAME="db" VALUE="$form{'dbname'}">
  360. $postpass
  361. </FORM>
  362.  
  363. EOF
  364.     ;
  365. }
  366.     print <<EOF;
  367. <p> 
  368. <FORM ACTION="AT-admin.cgi" METHOD=POST>
  369. <INPUT TYPE="submit" NAME="Admin" VALUE="Admin">
  370. <INPUT TYPE="hidden" NAME="db" VALUE="$form{'dbname'}">
  371. Go back to the admin page for this collection.
  372. $postpass
  373. </FORM>
  374.  
  375. EOF
  376.     ;                
  377.     &Architext'Copyright($attr{'ArchitextURL'});
  378.     exit(0);
  379.     } else {
  380.     ## required elements were not passed in.
  381.     $message = "<b>You didn't enter a value for a required field.  Try again.</b>";
  382.     $form{'db'} = $form{'dbname'};
  383.     }
  384. if ($form{'db'}) {
  385.     ## Print out configuration options for an already-existing
  386.     ## database so the user knows what will happen upon page generation
  387.  
  388.     ## Dump our standard header
  389.     &Architext'printHeader($attr{'ArchitextURL'},
  390.                "Search Page Generation: $form{'db'}");
  391.  
  392.     ## Check for the desired database.conf file.
  393.     $dbconfig = $root . "/collections/" . $form{'db'} . ".conf";
  394.     if (! -r $dbconfig) { 
  395.     &Architext'exitFileError($attr{'ArchitextURL'},
  396.                  $dbconfig, "does not exist"); }
  397.  
  398.     ## Read all the configuration information.
  399.     ## %attr = &ArchitextConf'readConfig("$root/Architext.conf", $form{'db'});
  400.  
  401.     ## advise the user if required fields were not passed in
  402.     print $message if $message;
  403.  
  404.     print "<p> The collection you have chosen has ";
  405.     print "the following characteristics:\n";
  406.     ## Print the form.
  407.     ## This form is just a little list of the options.
  408.     &printForm($form{'db'});
  409.     if ($getpass) {
  410.     $getpass .= "&";
  411.     } else {
  412.     $getpass = "?";        
  413.     }
  414.     $getpass .= "db=$form{'db'}";
  415.     &Architext'Copyright($attr{'ArchitextURL'});
  416.     exit(0);
  417.  
  418. } else {
  419.     ## Print out the top-level screen: scan the root directory for
  420.     ## db.conf files, and allow the user to initialize a new db.conf
  421.     ## file.
  422.  
  423.     opendir(CONF, "$root/collections");
  424.     @dbconf = grep(/\.conf$/, readdir(CONF));
  425.  
  426.     &Architext'printHeader($attr{'ArchitextURL'},"Search Page Generation");
  427.     if ($#dbconf > -1) {
  428.     print <<EOF;
  429. <FORM ACTION="http:AT-generate.cgi" METHOD=POST>
  430. Choose a document collection for which to generate query and result pages.<P>
  431. <DL>
  432. <DT> 
  433. Existing <a href="${helppath}AT-helpdoc.html#Document Collections">document collections:</a> <DD>
  434. <SELECT NAME="db" SIZE=5>
  435. EOF
  436.     ;
  437.     for (@dbconf) {
  438.     s|\.conf$||;
  439.     next if $_ eq 'Architext';
  440.     print "<OPTION> $_\n";
  441.     }
  442.     print <<EOF;
  443. </SELECT>
  444. </DL>
  445. <INPUT TYPE="submit" NAME="select" VALUE="Select">
  446. $postpass
  447. </FORM>
  448. EOF
  449.     ;
  450. } else {
  451.     print <<EOF;
  452. <p> There are no document collections currently defined.  Please
  453. click on the configure button to go to the collection configuration
  454. screen.
  455. <FORM ACTION="http:AT-config.cgi" METHOD=POST>
  456. <INPUT TYPE="submit" VALUE="Configure">
  457. $postpass
  458. </FORM>
  459. EOF
  460.     ;
  461. }
  462.     &Architext'Copyright($attr{'ArchitextURL'});
  463. }
  464.  
  465. ## Prints an input line for a form.
  466. sub printLineItem {
  467.     local($name, $text) = @_;
  468.     local($val);
  469.     $text = $name unless $text;
  470.     $val = eval "\$attr{$name}";
  471.     print qq(<li> <a href="${helppath}AT-helpdoc.html#$text">$text:</a> $val\n);
  472. }
  473.  
  474. ## Prints out the Architext form. Uses dynamic scoping to ensure that
  475. ## the values in the %attr array are properly set.
  476. sub printForm {
  477.     local($db) = shift;
  478.     local ($size) = 30;
  479.     local($url) = $attr{'ArchitextURL'};
  480.     print "<UL>\n";
  481.     &Architext'printLineItem($url,'IndexExecutable',
  482.                  $attr{'IndexExecutable'}) 
  483.     if &Architext'debugMode();
  484.     &Architext'printLineItem($url,'SearchExecutable',
  485.                  $attr{'SearchExecutable'})
  486.     if &Architext'debugMode();
  487.     &Architext'printLineItem($url,'StemTable',$attr{'StemTable'})
  488.     if &Architext'debugMode();
  489.     &Architext'printLineItem($url,'StopTable',$attr{'StopTable'})
  490.     if &Architext'debugMode();
  491.     &Architext'printLineItem($url,'CollectionInfo', $attr{'CollectionInfo'})
  492.     if &Architext'debugMode(); 
  493.     &Architext'printLineItem($url,'CollectionIndex',
  494.                  $attr{'CollectionIndex'});
  495.     if ($attr{'CollectionContents'} =~ /^\+/) {
  496.     $attr{'CollectionContents'} =~ s/^\+//;
  497.     print <<EOF;
  498. <li> <a href="${helppath}AT-helpdoc.html#CollectionContents">
  499. CollectionContents:</a> Index the files listed in 
  500. '$attr{'CollectionContents'}'.
  501. EOF
  502.     ;
  503.     } else {
  504.     $files = join(", ", split(/[:,;\s]+/, $attr{'CollectionContents'}));
  505.     print <<EOF;
  506. <li> <a href="${helppath}AT-helpdoc.html#CollectionContents">
  507. CollectionContents:</a> Index the files '$files' using these rules:<ul>
  508. EOF
  509.     ;
  510.     &Architext'printLineItem($url,'IndexFilter',
  511.                  $attr{'IndexFilter'});
  512.     &Architext'printLineItem($url,'ExclusionRules',
  513.                  $attr{'ExclusionRules'});
  514.     print "</ul>";
  515.     }
  516.     &Architext'printLineItem($url,'AdminMail',
  517.                  $attr{'AdminMail'});
  518.     $size = (length($attr{'HtmlRoot'})+10) 
  519.     unless ((length($attr{'HtmlRoot'})+10) < 30);
  520.     $qlength = (length($attr{'ArchitextURL'}) + 
  521.         length("pictures/AT-Block-logo.gif") + 10);
  522.     print "</UL>\n";
  523.     print qq(<FORM ACTION="http:AT-generate.cgi" METHOD=POST>\n);
  524.     if (($attr{'CgiBin'}) && (-w "$attr{'CgiBin'}")) {
  525.     print qq(<INPUT TYPE="hidden" NAME="Move" VALUE="yes">\n);
  526.     }
  527.     print <<EOF;
  528. <p><b>Required Information</b><ul>
  529. <INPUT TYPE="hidden" NAME="qpage" VALUE="AT-$form{'db'}query.html">
  530. <p>Enter <a href="${helppath}AT-helpdoc.html#Path Prefix">path prefix</a>
  531.  to remove from result URLs: <INPUT NAME="unprefix" 
  532. VALUE="$attr{'HtmlRoot'}" SIZE=$size>
  533. </ul>
  534. <p> <b>Optional Information</b><ul>
  535. <p> Enter <a href="${helppath}AT-helpdoc.html#Banner Image">
  536. Banner Image </a> to appear at the top of query and result pages:
  537. <INPUT NAME="qimage" VALUE="$attr{'ArchitextURL'}pictures/AT-Block-logo.gif"
  538. SIZE=$qlength>
  539. <p>Enter a <a href="${helppath}AT-helpdoc.html#Brief Description">
  540. brief description</a>
  541.  of the contents of your database for use in 
  542. the query page.  The generated query page will appear in 
  543. <b>$attr{'ConfigRoot'}</b>. 
  544. <TEXTAREA NAME="describe" COLS=60 ROWS=4></TEXTAREA>
  545. </ul>
  546. <p><INPUT TYPE="submit" NAME="generate" VALUE="Generate">
  547. Generate the query pages and scripts need to perform queries.
  548. <INPUT TYPE="hidden" NAME="Generate" VALUE="Generate">
  549. <INPUT TYPE="hidden" NAME="dbname" VALUE="$db">
  550. $postpass
  551. </FORM>
  552. <p> 
  553. <FORM ACTION="AT-admin.cgi" METHOD=POST>
  554. <INPUT TYPE="hidden" NAME="db" VALUE="$db">
  555. <INPUT TYPE="submit" NAME="Admin" VALUE="Admin">
  556. Go back to the admin page for this collection.
  557. $postpass
  558. </FORM>
  559.  
  560. EOF
  561.     ;
  562. }
  563.  
  564. ## prints a default query page with a simple description
  565. sub simpleQueryPage {
  566.     local($simplepage);
  567.     local($exit);
  568.     local($cgi);
  569.     ## calculate location of cgi-bin directory
  570.     $cgi = $ENV{'SCRIPT_NAME'};
  571.     $cgi =~ s/\/?[^\/]+$//;
  572.     $simplepage = $form{'qpage'};
  573.     $simplepage .= ".html" unless $simplepage =~ /\.html$/;
  574.     $simplepage = $root . "/" . $simplepage;
  575.     open(SPAGE, ">$simplepage") ||
  576.     &Architext'exitFileError($attr{'ArchitextURL'},
  577.                  $simplepage, 
  578.                  "could not be opened for writing.");
  579.     print SPAGE "<html><head><title>Architext Querying</title></head>\n";
  580.     print SPAGE qq(<body><h1> <img src="$form{'qimage'}"> </h1>\n) 
  581.     if $form{'qimage'};
  582.     print SPAGE "<p><b>Database description:</b> $form{'describe'} \n<p>\n"
  583.     if ($form{'describe'} =~ /\w/);
  584.     print SPAGE "Enter a natural language query in the form below.\n";
  585.     print SPAGE qq(<p>\n<FORM ACTION="$cgi/AT-$form{'dbname'}search.cgi" METHOD="POST">\n);
  586.     print SPAGE qq(Search Type:\n);
  587.     print SPAGE qq(<INPUT TYPE="radio" NAME="mode" VALUE="concept" CHECKED> Concept\n);
  588.     print SPAGE qq(<INPUT TYPE="radio" NAME="mode" VALUE="simple"> Query words only\n);
  589.     print SPAGE qq(<br><TEXTAREA NAME="search" COLS=50 ROWS=4></TEXTAREA><br>\n);
  590.     print SPAGE qq(<INPUT TYPE="submit" VALUE="Search">\n);
  591.     print SPAGE qq(</FORM>);
  592.     print SPAGE qq(<p> Documentation about <a href="AT-queryhelp.html">making queries</a> is available.);
  593.     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.);
  594.  
  595.     close(SPAGE);
  596.     ## don't copy files if config root and architext root are the same
  597.     if ($root ne $attr{'ConfigRoot'}) {
  598.     $exit = system("cp $simplepage $attr{'ConfigRoot'}");
  599.     &Architext'exitError($attr{'ArchitextURL'},
  600.                  "Cannot copy $simplepage to $attr{'ConfigRoot'}") if $exit;
  601.     }
  602.     #$exit = system("cp $root/AT-Block-logo.gif $attr{'HtmlRoot'}");
  603.     #&Architext'exitError($attr{'ArchitextURL'},
  604. #                          "Cannot copy $root/AT-Block-logo.gif to $attr{'HtmlRoot'}") if $exit;
  605. }
  606.  
  607. ## prints a default query-result html and then creates the query script
  608. ## moves the old .cgi script out of the way to .cgi.old if it exists.
  609. sub simpleQueryScript {
  610.     local($simplepage);
  611.     local($cmd);
  612.     local($exit);
  613.     local($prefix);
  614.     ## add a trailing '/' to unprefix if it is not there
  615.     $prefix = $form{'unprefix'};
  616.     $prefix .= "/" unless ($prefix =~ /\/$/);    
  617.  
  618.     $simplepage = "AT-$form{'dbname'}search.html";
  619.     $simplepage = $root . "/" . $simplepage;
  620.     open (QPAGE, ">$simplepage") ||
  621.     &Architext'exitFileError($attr{'ArchitextURL'},
  622.                  $simplepage, 
  623.                  "could not be opened for writing.");
  624.  
  625.     print QPAGE qq(<html>\n<head>\n<title> Results From Your Architext Query</title>\n<body>\n);
  626.     print QPAGE qq(<h1> <img src="$form{'qimage'}"> </h1>\n) 
  627.     if $form{'qimage'};
  628.     print QPAGE qq(<ARCHITEXT-INDEX-CHECK ROOT="$attr{'CollectionRoot'}">\n);
  629.     print QPAGE qq(<ARCHITEXT-RESULT DB="$form{'dbname'}" UNPREFIX="$prefix" AHOME="$attr{'ArchitextURL'}">\n);
  630.  
  631.     ## check for advanced feature mode, add ASG if appropriate
  632.     if (&Architext'asgMode()) {
  633.     print QPAGE qq(<ARCHITEXT-MAKE-GATHER DB="$form{'dbname'}" UNPREFIX="$prefix" AHOME="$attr{'ArchitextURL'}">\n);
  634.     }
  635.     print QPAGE qq(<ARCHITEXT-LEGEND DB="$form{'dbname'}" AHOME="$attr{'ArchitextURL'}">\n);
  636.     print QPAGE qq(</body>\n</html>\n);
  637.     close(QPAGE);
  638.  
  639.     ## call architextify-html here to produce queryscript.cgi
  640.     $cmd = "$root/architextify-html -f $simplepage";
  641.     $exit = system($cmd);
  642.     &Architext'exitError($attr{'ArchitextURL'},
  643.              "Problem encountered generating AT-$form{'dbname'}search.cgi - $!") if $exit;
  644.     system("rm -f $simplepage");
  645.     ## don't copy files if config root and architext root are the same
  646.     if ($root ne $attr{'ConfigRoot'}) {
  647.     $exit = system("cp $root/AT-$form{'dbname'}search.cgi $attr{'ConfigRoot'}");
  648.     &Architext'exitError($attr{'ArchitextURL'},
  649.                  "Cannot copy $root/AT-$form{'dbname'}search.cgi to $attr{'ConfigRoot'}") if $exit;
  650.     }
  651. }
  652.  
  653. ## prints a default query-result html and then creates the query script
  654. ## moves the old .cgi script out of the way to .cgi.old if it exists.
  655. sub simpleGatherScript {
  656.     local($simplepage);
  657.     local($cmd);
  658.     local($exit);
  659.     local($prefix);
  660.     ## add a trailing '/' to unprefix if it is not there
  661.     $prefix = $form{'unprefix'};
  662.     $prefix .= "/" unless ($prefix =~ /\/$/);    
  663.  
  664.     $simplepage = "AT-$form{'dbname'}gather.html";
  665.     $simplepage = $root . "/" . $simplepage;
  666.     open (QPAGE, ">$simplepage") ||
  667.     &exitFileError($attr{'ArchitextURL'},
  668.                $simplepage, "could not be opened for writing.");
  669.  
  670.     print QPAGE qq(<html>\n<head>\n<title> Architext Automatic Subject Grouping</title>\n<body>\n);
  671.     print QPAGE qq(<h1> <img src="$form{'qimage'}"> </h1>\n)
  672.     if $form{'qimage'};
  673.     print QPAGE qq(\n<h1>Subject Grouping</h1>);
  674.     print QPAGE qq(<UL><ARCHITEXT-GATHER DB="$form{'dbname'}" UNPREFIX="$prefix" AHOME="$attr{'ArchitextURL'}"></UL>\n);
  675.     print QPAGE qq(<ARCHITEXT-LEGEND DB="$form{'dbname'}" AHOME="$attr{'ArchitextURL'}">\n);
  676.     print QPAGE qq(</body>\n</html>\n);
  677.     close(QPAGE);
  678.  
  679.     ## call architextify-html here to produce queryscript.cgi
  680.     $cmd = "$root/architextify-html -f $simplepage";
  681.     $exit = system($cmd);
  682.     &Architext'exitError($attr{'ArchitextURL'},
  683.              "Problem encountered generating $form{'dbname'}gather.cgi") if $exit;
  684.     system("rm -f $simplepage");
  685.     ## don't copy files if config root and architext root are the same
  686.     if ($root ne $attr{'ConfigRoot'}) {
  687.     $exit = system("cp $root/AT-$form{'dbname'}gather.cgi $attr{'ConfigRoot'}");
  688.     &Architext'exitError($attr{'ArchitextURL'},
  689.                  "Cannot copy $root/AT-$form{'dbname'}gather.cgi to $attr{'ConfigRoot'}") if $exit;
  690.     }
  691. }
  692.  
  693.