home *** CD-ROM | disk | FTP | other *** search
- #!/bin/sh
- perl=/usr/local/etc/architext/perl
- eval "exec $perl -x $0 $*"
- #!perl
- ## Copyright Arhitext Software, 1995 (c)
- ##
- ## This CGI script is intended as a first stop for
- ## administrators of Architext's web site search engine.
- ##
- ## This script will appear a several different web pages,
- ## and will check to make sure that the user has
- ## registered with Architext before providing access
- ## to the full range of functionality.
- $| = 1;
-
- $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;
- %attr = &ArchitextConf'readConfig("$root/Architext.conf", $form{'db'});
-
- if (&Architext'remoteMode($root)) {
- $helppath = &Architext'helpPath();
- } else {
- $helppath = $attr{'ArchitextURL'};
- }
-
- $news_url = &Architext'newsURL();
- $scriptname = "AT-admin.cgi";
-
- if ($form{'register'} eq 'yes') {
- ## given the presence of the register attribute
- ## we can assume that the user has registered with
- ## architext and is visiting this page for the
- ## first time, so we need to update Architext.conf
- ## to mark the user as registered.
- $cmd = "echo register yes >> $attr{'ArchitextRoot'}/Architext.conf";
- $exit = system($cmd) unless ($attr{'register'} eq 'yes');
- &Architext'exitError($attr{'ArchitextURL'},
- "Unable to update configuration file with registation information. $!") if $exit;
- if ($form{'remote'} eq 'yes') {
- $cmd = "touch $attr{'ArchitextRoot'}/.remote";
- $exit = system($cmd) unless (-e "$attr{'ArchitextRoot'}/.remote");
- &Architext'exitError($attr{'ArchitextURL'},
- "Unable to create .remote file - $!")
- if $exit;
- }
- if ($form{'at_email'}) {
- $cmd = "echo AdminMail $form{'at_email'} >> $attr{'ArchitextRoot'}/Architext.conf";
- $exit = system($cmd) unless ($attr{'AdminMail'});
- &Architext'exitError($attr{'ArchitextURL'},
- "Unable to update configuration file with admin mail address. $!") if $exit;
- }
- ## create index.html file with some interesting stuff in it
- %attr = &ArchitextConf'readConfig("$root/Architext.conf");
- &createIndex($attr{'ConfigRoot'});
- }
-
- ## check for password, if one is specified in Architext.conf
- ## if it doesn't appear as a form arg, present password page
-
- if ($attr{'register'} eq 'yes') {
- ## they are registered, so present them with the options
- ## and check for an admin password
- &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{'db'}) {
- ## db specific admin page
- &Architext'printHeader($attr{'ArchitextURL'},
- "Collection Administration: $form{'db'}");
- print "<hr><b>Collection Status</b><ul>";
- &Architext'printStatus($form{'db'}, $root, $attr{'ConfigRoot'},
- $attr{'ArchitextURL'}, $attr{'CollectionRoot'});
- print <<EOF;
- <p><FORM ACTION="AT-admin.cgi" METHOD=POST>
- <INPUT TYPE="submit" VALUE="Update Status">
- Check status information again, in case it has changed.
- <INPUT TYPE="hidden" NAME="db" VALUE="$form{'db'}">
- $postpass
- </FORM>
- EOF
- ;
- print "</ul><hr>";
- print <<EOF;
- <b>Possible Actions</b><ul>
-
- <FORM ACTION="AT-config.cgi" METHOD="POST">
- <INPUT TYPE="submit" VALUE="Configure">
- <INPUT TYPE="hidden" NAME="db" VALUE="$form{'db'}">
- Configure the characteristics of this document collection.
- $postpass
- </FORM>
- EOF
- ;
- ## show index or stop index button appropriately
- if (-e "$root/collections/$form{'db'}.pid") {
- print <<EOF;
- <FORM ACTION="AT-index.cgi" METHOD=POST>
- <INPUT TYPE="submit" NAME="Stop" VALUE="Stop Indexing">
- Stop the indexing process that is currently running on this collection.
- <INPUT TYPE="hidden" NAME="db" VALUE="$form{'db'}">
- $postpass
- </FORM>
- EOF
- ;
- } else {
- print <<EOF;
- <FORM ACTION="AT-index.cgi" METHOD="POST">
- <INPUT TYPE="hidden" NAME="db" VALUE="$form{'db'}">
- <INPUT TYPE="submit" VALUE="Index">
- Create an index for this collection.
- $postpass
- </FORM>
- EOF
- ;
- }
-
- print <<EOF;
-
- <FORM ACTION="AT-generate.cgi" METHOD="POST">
- <INPUT TYPE="hidden" NAME="db" VALUE="$form{'db'}">
- <INPUT TYPE="submit" VALUE="Generate"> Generate the pages
- needed to search on this collection.
- $postpass
- </FORM>
- EOF
- ;
- if (-e "$attr{'ConfigRoot'}/AT-$form{'db'}query.html") {
- print <<EOF;
- <FORM ACTION="$attr{'ArchitextURL'}AT-$form{'db'}query.html" METHOD="GET">
- <INPUT TYPE="submit" VALUE="Search">
- Make a query on this collection.
- </FORM>
-
- EOF
- ;
- }
- if ((-e "$root/collections/$form{'db'}.pid") ||
- (-e "$root/collections/$form{'db'}.last") ||
- (-e "$root/collections/new/$form{'db'}.err")) {
- print <<EOF;
- <p> <FORM ACTION="AT-generate.cgi" METHOD=POST>
- <INPUT TYPE="submit" NAME="Status" VALUE="View Logs">
- View the log files from the most recent indexing process.
- <INPUT TYPE="hidden" NAME="db" VALUE="$form{'db'}">
- $postpass
- </FORM>
- EOF
- ;
-
- }
- print <<EOF;
- <FORM ACTION="AT-admin.cgi" METHOD="POST">
- <INPUT TYPE="hidden" NAME="dbname" VALUE="$form{'db'}">
- <INPUT TYPE="hidden" NAME="Remove" VALUE="Remove">
- <INPUT TYPE="submit" VALUE="Remove">
- Remove this collection and all files associated with it.
- $postpass
- </FORM>
-
- <FORM ACTION="AT-admin.cgi" METHOD="POST">
- <INPUT TYPE="submit" VALUE="Main Admin Page">
- Go back to the main administration page.
- $postpass
- </FORM>
-
- EOF
- ;
- print "</ul>";
- print "<hr><b>Collection Characteristics</b>\n";
- &printForm($form{'db'});
- } elsif ($form{'Support'}) {
- ## send support information to Architext
- open(STDERR, ">/dev/null");
- @commands = ('ls -ld HTML', 'ls -l HTML',
- 'ls -ld ROOT', 'ls -ld ROOT/collections',
- 'ls -ld ROOT/collections/new',
- 'ls -lR ROOT', 'cat ROOT/Architext.conf',
- 'cat ROOT/collections/*.conf');
-
- opendir(LOGS, "$attr{'ConfigRoot'}");
- @outfiles = grep(/\.log|err|prog$/, readdir(LOGS));
- for (@outfiles) {
- push(@commands, "tail HTML/$_");
- }
-
- &Architext'printHeader($attr{'ArchitextURL'},
- "Create Support Information");
-
-
- open(SUPPORT, ">$root/support.out");
- open(MAIL, "| mail support@atext.com") if $form{'email'};
- print MAIL "To: support@atext.com\n" if $form{'email'};
- print MAIL "Subject: Architext Support Information\n" if $form{'email'};
- for (@commands) {
- $_ =~ s/ROOT/$root/;
- $_ =~ s/HTML/$attr{'ConfigRoot'}/;
- print SUPPORT "$_\n";
- print MAIL "$_\n" if $form{'email'};
- print SUPPORT `$_`;
- print MAIL `$_` if $form{'email'};
- print MAIL "\n" if $form{'email'};
- print SUPPORT "\n";
-
- }
-
- close(MAIL) if $form{'email'};
- close(SUPPORT);
-
- if ($form{'email'}) {
- $email =
- ", and has been sent via email to <b>support@atext.com</b>,";
- } else {
- $email = ".";
- }
-
- print <<EOF;
-
- <p> Your support information has been recorded in the file
- <b>$root/support.out</b>$email If your system is not configured to send email
- to outside locations, please send the contents of the above file
- to support@atext.com. Thank you.
- <p>
- <FORM ACTION="AT-admin.cgi" METHOD=POST>
- $postpass
- <INPUT TYPE="submit" NAME="GoBack" VALUE="Back To Main Admin Page">
- </FORM>
- EOF
- ;
- &Architext'Copyright($attr{'ArchitextURL'});
- exit 0;
- } elsif ($form{'Remove'}) {
- ## remove collection verb
- &Architext'printHeader($attr{'ArchitextURL'},
- "Remove Collection: $form{'dbname'}");
- if ($form{'verify'}) {
- if (-e "$root/collections/$form{'dbname'}.pid") {
- print "<p><b>Sorry, you cannot remove a collection while an index process is running for that collection</b>";
- } else {
- ## no index process is running, so it is safe to
- ## remove the collection and all associated files
- %attr = &ArchitextConf'readConfig("$root/Architext.conf",
- $form{'dbname'});
- open(STDERR, ">/dev/null");
- push(@commands,
- "rm -f $root/collections/new/$form{'dbname'}*");
- push(@commands,
- "rm -f $root/collections/$form{'dbname'}*");
- push(@commands, "rm -f $attr{'CollectionRoot'}*");
- push(@commands,
- "rm -f $attr{'ConfigRoot'}/AT-$form{'dbname'}query.html");
- push(@commands,
- "rm -f $attr{'ConfigRoot'}/AT-$form{'dbname'}.log");
- push(@commands,
- "rm -f $attr{'ConfigRoot'}/AT-$form{'dbname'}.prog");
- push(@commands,
- "rm -f $attr{'ConfigRoot'}/AT-$form{'dbname'}.err");
- push(@commands,
- "rm -f $attr{'CgiBin'}AT-$form{'dbname'}search.cgi");
- push(@commands,
- "rm -f $attr{'CgiBin'}AT-$form{'dbname'}gather.cgi");
- push(@commands,
- "rm -f $attr{'ConfigRoot'}/AT-$form{'dbname'}search.cgi");
- push(@commands,
- "rm -f $attr{'ConfigRoot'}/AT-$form{'dbname'}gather.cgi");
- for (@commands) {
- system($_);
- }
- print "<p><b>The collection '$form{'dbname'}' has been removed</b>.";
- }
- print <<EOF;
- <p>
- <FORM ACTION="AT-admin.cgi" METHOD=POST>
- $postpass
- <INPUT TYPE="submit" VALUE="Admin">
- Go back to the main administration page.
- </FORM>
- EOF
- ;
-
- } else {
- print <<EOF;
- Do you really want to remove the configure files, index files, and
- query scripts associated with this collection?
- <p>
- <FORM ACTION="AT-admin.cgi" METHOD=POST>
- <INPUT TYPE="hidden" NAME="verify" VALUE="yes">
- <INPUT TYPE="hidden" NAME="Remove" VALUE="Remove">
- <INPUT TYPE="hidden" NAME="dbname" VALUE="$form{'dbname'}">
- $postpass
- <INPUT TYPE="submit" VALUE="Remove">
- Remove all files associated with this collection.
- </FORM>
-
- <p>
- <FORM ACTION="AT-admin.cgi" METHOD=POST>
- <INPUT TYPE="hidden" NAME="db" VALUE="$form{'dbname'}">
- $postpass
- <INPUT TYPE="submit" VALUE="Admin">
- Don't remove files, go back to the administration page for this collection.
- </FORM>
- EOF
- ;
-
- }
- &Architext'Copyright($attr{'ArchitextURL'});
- exit(0);
- } else {
- ## main admin page
- &Architext'printHeader($attr{'ArchitextURL'},
- "On Target Administration");
- opendir(CONF, "$root/collections");
- @dbconf = grep(/\.conf$/, readdir(CONF));
- print "<hr><b>Exisiting Collections</b><ul>";
-
- if ($#dbconf > -1) {
- for (@dbconf) {
- s|\.conf$||;
- if ($getpass) {
- $getdb = "&db=$_";
- } else {
- $getdb = "?db=$_";
- }
- print qq(<br> <a href="AT-admin.cgi$getpass$getdb">$_</a>\n);
- $status = &Architext'getStatusString($root, $_,
- $attr{'ConfigRoot'},
- $attr{'ArchitextURL'});
- print " -- $status\n";
- }
- } else {
- print "<p>(No document collections found)<p>\n";
- }
-
- print "</ul><hr>";
-
- print "<b> New Collection</b><ul>";
- print <<EOF;
- <p><FORM ACTION="AT-config.cgi" METHOD=POST>
- Enter a name for a new collection:
- <INPUT NAME="new" SIZE=20><br>
- <INPUT TYPE="submit" NAME="NewCollection" VALUE="Create New Collection">
- $postpass
- </FORM>
- EOF
- ;
-
- print "</ul><hr>";
-
- print "<b> Support Information</b>";
- print "<ul>";
- print <<EOF;
- <p><FORM ACTION="AT-admin.cgi" METHOD=POST>
- $postpass
- <INPUT TYPE="checkbox" NAME="email" VALUE="email" CHECKED>
- Send support information to <b>support@atext.com</b>. If you do not
- want the information automatically emailed to Architext, uncheck this
- box, and a file containing the support information will be created, but
- not emailed.<br>
- <INPUT TYPE="submit" NAME="Support" VALUE="Support">
- EOF
- ;
-
- print "</ul>";
- print <<EOF;
- <hr>
- <a href="$news_url">
- News</a> Check here for up-to-the-minute information about OnTarget.
- <hr>
- <a href="$attr{'ArchitextURL'}AT-admininfo.html">
- Admin Info Page.</a> This page is simply
- a list of the options you chose at install time; you
- can check here to find out where certain files are located in
- case you have forgotten.
- EOF
- ;
- &Architext'Copyright($attr{'ArchitextURL'});
- exit 0;
- }
-
-
-
- } else {
- ## not yet registered, so print out screen to send user
- ## back to AT-starthere.html to get them registered and
- ## happy before they start using the admin tools
- &Architext'printHeader($attr{'ArchitextURL'}, "Architext Administration");
- print <<EOF;
- <p><h1> Not yet registered. </h1>
- <p> Apparently, you have not yet registered your copy of
- this software with Architext. To do this, please go to the
- <a href="AT-start.cgi">getting started</a>
- page and follow the instructions presented there. <br>
- Thanks!<br>
- EOF
- ;
- }
-
- &Architext'Copyright($attr{'ArchitextURL'});
-
-
- ## show the attributes for a particular collection
- sub printForm {
- local($db) = shift;
- 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'});
- print "</UL>\n";
-
- }
-
- sub createIndex {
- local($location) = @_;
- open(INDEX, ">$location/index.html");
- print INDEX qq(<html><head><title>On Target Administration</title></head>);
- print INDEX qq(<body><h1><img src="pictures/AT-Block-logo.gif">);
- print INDEX qq(<p>Architext On Target</h1>);
- print INDEX qq(<p> Welcome to the OnTarget administration directory.\n);
- print INDEX qq(From here, you can:);
- print INDEX qq(<p> Go to the <a href="$ENV{'SCRIPT_NAME'}"> main\n);
- print INDEX qq(administration page</a>.<br>\n);
- print INDEX qq(Go to <a href="http://www.atext.com">Architext Software's);
- print INDEX qq(</a> home page);
- print INDEX qq(<p><p><b>TIP:</b> Make a bookmark for this page, so you can easily get back to the administration page.);
- close(INDEX);
- }
-