#!/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 "
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 =
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; }