#!/usr/bin/perl # DISCUS 2.50/3.00 INTERACTIVE SETUP # CONGRATULATIONS! THIS STEP WORKED PROPERLY! # # Now, select "File | Save As..." from your browser's window. # This output should be saved as "ftpdiag.cgi" in any temporary # folder on your hard disk. When you have saved the file, use your # browser's back button to return to the instructions. # # This script is Copyright (c) 1998 by Kevin W. Paulisse and William # F. Polik. It is governed by the General Use license of the Discus # discussion board program. http://www.chem.hope.edu/discus # # # # # $| = 1; print "Content-type: text/html\n\n"; eval '$home = (getpwuid($<))[7];'; if (!-e "C:/") { $pwd = `pwd`; chop $pwd; } if (!eval 'use Cwd;') { eval '$cwd = cwd();'; } else { $cwd = ""; } $prog = $0; $prog =~ m|ftpdiag\.(\w+)|; $prog = "ftpdiag.$1"; $cgi_extension = $1; $b4 = $`; $b4 =~ s/\/$//; $b4 =~ s/\\$//; $docroot = $ENV{'DOCUMENT_ROOT'}; $docroot =~ s/\/$//; $docroot =~ s/\\$//; $filename = $ENV{'SCRIPT_FILENAME'}; $filename =~ s/\/$prog//; $filename =~ s/\\$prog//; $path = $ENV{'PATH_TRANSLATED'}; $path =~ s/\/$//; $path =~ s/\\$//; &check($pwd); &check($b4); &check($home); &check($docroot); &check($filename); &check($path); &check($cwd); if ($real eq "") { $real = &determine_cwd; } if ($real eq "") { print "Sorry...\n"; print "
Setup Complication\n\n";
   print "The setup script could not determine the current working directory\n";
   print "of the server.  This is very rare (only 1-2% of servers).  The environment\n";
   print "variables and other potentially helpful values are being printed here for\n";
   print "your reference:\n\n";
   print "PWD         $pwd\n";
   print "Server home $home\n";
   print "Doc. Root   $docroot\n";
   print "File name   $filename\n";
   print "Path        $path\n";
   print "CWD         $cwd\n\n";
   print "Here are the environment variables:\n\n";
   foreach $key (sort keys(%ENV)) {
       print "$key = [$ENV{$key}]\n";
   }
   print "\n\n";
   print "Due to this failure, you should probably use the above information\n";
   print "to use the Discus FTP detailed instructions.\n";
   print "
\n"; exit(0); } opendir(CURDIR, ".."); while ($q = readdir(CURDIR)) { push (@founddir, $q); } closedir(CURDIR); open (PROG, $prog); @prog = ; close (PROG); $perl = $prog[0]; $perl =~ s/^#!//; $real =~ s%\\%/%g; $real =~ s%//%/%g; if ($real =~ m|(.*)/(.+)|) { $base = $1; $cgi = $2; } else { $base = $real; $cgi = "cgi-bin"; } $admin_dir = "$base/discus_admin_"; $p = $$; $p =~ s/\D//g; $p .= substr(time, 0, -5); $admin_dir .= $p; $poss_html_dir = "public_html htdocs htdoc html www doc docs wwwdoc wwwdocs wwwroot httpd"; @poss = split(/\s/, $poss_html_dir); @founddir = grep(!/\./, @founddir); foreach $dir (@poss) { if (grep(/^$dir$/, @founddir)) { $html_dir = "$base/$dir/discus"; last; } } if ($html_dir eq "") { $html_dir = "$base/discus"; } $script_dir = "$real/discus"; $sn = ""; if ($ENV{'SCRIPT_URI'} ne "") { $sn = $ENV{'SCRIPT_URI'}; } elsif ($ENV{'SCRIPT_URL'} ne "") { $sn = $ENV{'SCRIPT_URL'}; } elsif ($ENV{'REQUEST_URI'}) { $sn = $ENV{'REQUEST_URI'}; } elsif ($ENV{'SCRIPT_NAME'} ne "") { $sn = $ENV{'SCRIPT_NAME'}; } if ($sn ne "") { if ($sn =~ m|^http://([^/]+)|) { $sn = $'; } if ($sn =~ m|/$prog|) { $sn = $`; } if ($sn ne "") { $script_url = "http://$ENV{'HTTP_HOST'}$sn/discus"; } } else { $script_url = "http://$ENV{'HTTP_HOST'}/$cgi/disdcus"; } if ($script_url =~ m|^http://([^/]+)/~([^/]+)/|) { $uinfo = "~" . $2 . "/"; } $html_url = "http://$ENV{'HTTP_HOST'}/$uinfo" . "discus"; # For NT users, convert / to \ to make it look more familiar $admin_dir =~ s%/%\\%g if $admin_dir =~ m|^(\w+):|; $html_dir =~ s%/%\\%g if $html_dir =~ m|^(\w+):|; $script_dir =~ s%/%\\%g if $script_dir =~ m|^(\w+):|; $bdcgi = "$base/$cgi"; $bdcgi =~ s%/%\\%g if $admin_dir =~ m|^(\w+):|; $admin_dir =~ s%\\\\%\\%g; $html_dir =~ s%\\\\%\\%g; $script_dir =~ s%\\\\%\\%g; $bdcgi =~ s%\\\\%\\%g; if (-e "C:/" || $^O eq "MSWin32") { $NTFLAG = ''; } if ($] < 5) { $perl4warn = "Perl Version Warning: The Perl path that\n"; $perl4warn .= "you selected, $perl, is running Perl version $].\n"; $perl4warn .= "Version 3.0 and 3.0 pro of Discus require Perl 5. In most cases,\n"; $perl4warn .= "there will not be any difficulties, but it is strongly\n"; $perl4warn .= "recommended that you consult your ISP's documents and determine\n"; $perl4warn .= "if you can select a different Perl path for Perl version 5.\n"; } print <<_END_; Discus Setup - Interactive Form
Discus Setup - Interactive Form

Introduction

This is important information that will help you when performing the setup of your board. Please read it carefully!

   If you are seeing this page, you were successful in accomplishing the first phase of Discus setup! What you are now looking at is the equivalent of the normal Discus FTP setup form, except that on this form, information gathered about your system has been used to fill in guesses for the appropriate form variables. You should review the changes, and fill in fields where appropriate (such as your board title).

IMPORTANT: The parameters filled in this form are our best guess about your server configuration. You may wish to change the directories or URLs to customize your board -- you may also need to change these. Don't just accept our guesses without reviewing them! This bears repeating.

Don't just accept our guesses without reviewing them (and changing them if necessary)!

   
Path to Perl

The Perl interpreter on your system interprets the Discus scripts and presents the results to you in your browser.

   $NTFLAG Enter the path to Perl for your system. Your test CGI script used $perl for the path to Perl, so this should also work on all of the rest of the Discus scripts. This Perl interpreter is running Perl version $].

$perl4warn

    Path to Perl:
   
CGI Extension

Your server needs to know what extension to use for CGI scripts on your server. On Windows NT servers, this often associates a particular extension directly with the Perl interpreter.

   The CGI extension is the extension that must be given to files for the server to treat them as CGI scripts. Usually this is ".cgi" or ".pl" and sometimes either will work. Consult your ISP's documentation if you don't know. Also keep in mind that this is probably case-sensitive (".cgi" and ".CGI" are not the same). You used $cgi_extension as the extension for the test script, so this should work for all of the Discus scripts.

    CGI Extension:
 
Administration Directory

The administration directory stores configuration files and password files for your Discus board. This directory should be "hidden" from the web server as described in this section.

   When specifying directories, it is necessary to use the full directory path that your server "sees" -- your server has reported seeing your test CGI script in $bdcgi. This may or may not correspond to what you see when you log in with your FTP program, as some web hosts limit your access to only your own area on the machine. In any case, it is what is "seen" by this setup program, and that is all that counts!

This directory should not be accessible at http://your.server.com/something. If you cannot "hide" this directory from your server, at least give it a non-standard name (if you call it "discus_admin" anyone at all can find it easily). Otherwise, anyone from the WWW will be able to view privileged information for your Discus implementation, such as the log of all posts, all of your board configuration settings, and your password files! The directory must be a directory and not a URL -- it should not start with http://!

Example: To specify the Discus administration directory, we suggest choosing a directory with a nonstandard name so it cannot be easily guessed. Perhaps $admin_dir would be a good choice.

    Administration Files Directory:
 
HTML Directory

The HTML directory stores HTML files that are used by Discus, such as the documentation and message files. This directory does not go under your cgi-bin.

   The HTML files that come with Discus, such as the instructions, main menu, and administration program framesetting document are placed in the "HTML Files Directory." In addition, your message files (topics and messages), clipart, and icons are all stored in subdirectories of the HTML Files Directory. This should not go under your server's CGI directory (i.e., don't put it under your cgi-bin). The directory must be a directory and not a URL -- it should not start with http://!

Example: $html_dir.

    HTML Files Directory:

You also need to give the URL that corresponds to the HTML Files Directory that you specified above. This must start with http://.

Example: $html_url

    HTML Files URL:
 
Script Directory

The script directory stores the Perl CGI scripts that power the Discus program. This directory normally needs to go under your cgi-bin.

   The script (CGI) files that come with Discus, such as the board administration script and the new message search, go into the Script Files Directory. (These are the Perl scripts that actually power Discus by writing to the message files.)

You need to be able to have your CGI scripts be executed by the server when they are in this directory (which may require you to put this script under your server's cgi-bin or cgi-local directory). The directory must be a directory and not a URL -- it should not start with http://!

Example: $script_dir

    Script Files Directory:

You also need to give the URL that corresponds to the Script Files Directory that you specified above. This must start with http://.

Example: $script_url

    Script Files URL:
 
Board Title

You can specify the title of your board.

   This is, quite simply, the title of your discussion board.

Example: John's Forum

    Board Title:
 
Board Contact

This is where you type your name and e-mail address.

   This is the name and e-mail address of the person who is to be contacted if there is a problem with the board. (When users receive error messages, they are told to contact this person.)

Example: John Smith is the contact person, and smith\@johnsmith.com is the e-mail.

    Board Contact Person:

    Board Contact E-mail Address:
 
Submit the form

After double checking your parameters, click the button to generate your individualized distribution of Discus!

   When you have filled in all of the blanks above, click the button to generate your individual custom Discus distribution. Please note that processing could take several seconds, so please click the button only one time, and be patient.

Copyright © 1998, Kevin W. Paulisse and William F. Polik, all rights reserved. _END_ exit(0); sub check { local ($dr) = @_; return 0 if $dr eq ""; if (-e "$dr/$prog") { $real = $dr; return 1; } } exit(0); sub determine_cwd { $filename = $0; if ($filename =~ m|(.*)/(.*)|) { $filename = $2; } undef @parent; $ctr = 100; $dots = ""; O: while ($ctr > 0) { $ctr -= 1; $dots .= "/" if $dots ne ""; $dots .= ".."; if (opendir(DIR, $dots)) { I: while ($dir = readdir(DIR)) { next if $dir =~ m|^\.+$|; next if !-d "$dots/$dir"; if (scalar(@parent)) { $parent = "/" . join("/", reverse(@parent)); } else { $parent = ""; } if (-e "$dots/$dir$parent/$filename") { push (@parent, $dir); last I; } } closedir(DIR); } else { last O; } $parent = "/" . join("/", reverse(@parent)); if (-e "$parent/$filename") { last O; } } $parent = "/" . join("/", reverse(@parent)); if ($^O eq "MSWin32") { foreach $dr ('c' .. 'z') { if (-e "$dr:$parent/$filename") { return "$dr:$parent"; } } } return $parent; }