Make your own free website on
#!/usr/bin/perl #<!-- # ------------------------------------------------------------------ # DISCUS 2.50-3.10 FTP SETUP ASSISTANT SCRIPT # [Revision 3.10.1/b38] # # Congratulations, if you are seeing this page, generation of this # script was successful! # # 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 file # should be saved as plain text, NOT as HTML. # # This script is Copyright (c) 2000 by DiscusWare, LLC, all rights # reserved. It may be used under the same terms as Discus itself, # detailed in # # ------------------------------------------------------------------ # This code checks for the script being displayed as HTML if (1 == 0) { print <<EOF; --> <HTML><HEAD><TITLE>FTP Assistant Error</TITLE></HEAD> <BODY BGCOLOR=#ffffff TEXT=#000000> <H1>FTP Assistant Error</H1> If you are seeing this error message, the FTP setup assistant is not being properly executed as a CGI script, but is rather being shown as an ordinary HTML file. You must consult your server administrator to have them turn on CGI permissions in this directory. </body></HTML> <!-- EOF } $| = 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; if ($prog =~ m|ftpdiag\.(\w+)|) { $prog = "ftpdiag.$1"; $cgi_extension = $1; } else { print "<HTML><HEAD><TITLE>Sorry...</TITLE></HEAD>\n"; print "<BODY><B>Setup Error</b>\n\n"; if ($prog eq "") { print "<P>This version of Perl is malfunctioning, as it did not\n"; print "set the <B>\$0</b> variable. Please contact your server\n"; print "administrator and inform them that this Perl installation\n"; print "is not functioning properly.<P>\n"; } else { print "<P>It appears that this script is not named &quot;ftpdiag.***&quot;\n"; print "as required by the setup. If necessary, rename this file. Currently\n"; print "this file is titled <B>$prog</b><P>\n"; } print "</body></HTML>\n"; exit(0); } $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 "<HTML><HEAD><TITLE>Sorry...</TITLE></HEAD>\n"; print "<BODY><PRE><B>Setup Complication</b>\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 "<B>PWD</b> $pwd\n"; print "<B>Server home</b> $home\n"; print "<B>Doc. Root</b> $docroot\n"; print "<B>File name</b> $filename\n"; print "<B>Path</b> $path\n"; print "<B>CWD</b> $cwd\n\n"; print "Here are the environment variables:\n\n"; foreach $key (sort keys(%ENV)) { print "<B>$key</b> = [$ENV{$key}]\n"; } print "\n\n"; print "</PRE></body></HTML>\n"; exit(0); } opendir(CURDIR, ".."); while ($q = readdir(CURDIR)) { push (@founddir, $q); } closedir(CURDIR); open (PROG, $prog); @prog = <PROG>; close (PROG); $perl = $prog[0]; $perl =~ s/^#!//; $perl =~ s/\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"; $unsure_html_dir = "htdoc html www wwwdoc wwwdocs wwwroot httpd doc docs"; @poss = split(/\s/, $poss_html_dir); @founddir = grep(!/\./, @founddir); $flag = 0; foreach $dir (@poss) { if (grep(/^$dir$/, @founddir)) { $html_dir = "$base/$dir/discus"; $flag = 1; last; } } if ($flag == 0) { @poss = split(/\s/, $unsure_html_dir); foreach $dir (@poss) { if (grep(/^$dir$/, @founddir)) { if (-e "$base/$dir/index.html" || -e "$base/$dir/index.htm") { $html_dir = "$base/$dir/discus"; if (-e "$base/index.html" || -e "$base/index.htm") { $flag = 2; $dir_me = $dir; last; } else { $flag = 1; last; } } else { if (!-e "$base/index.html" && !-e "$base/index.htm") { $html_dir = "$base/$dir/discus"; $flag = 2; $dir_me = $dir; last; } else { $flag = 1; last; } } } } } if ($flag == 2) { $warn_dir = "<P><B><FONT COLOR=#ff0000>NOTE!</FONT> I'm not entirely sure about the &quot;$dir_me&quot;\n"; $warn_dir .= " part of this directory. Make sure you double check this suggestion.</b>\n"; } 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/discus"; } 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 = '<INPUT TYPE=HIDDEN NAME=OS VALUE=NT>'; } if ($] < 5) { $perl4warn = "<FONT COLOR=#ff0000><B>Perl Version Warning</b>: The Perl path that\n"; $perl4warn .= "you selected, <B>$perl</b>, 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 <U>strongly</U>\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.</FONT>\n"; } if (eval '$test = crypt("Foo", "Foo");') { $cryptwarn = ""; } else { $cryptwarn = "<FONT COLOR=#ff0000><B>Perl Version Warning</b>: The Perl interpreter\n"; $cryptwarn .= "that you selected, <B>$perl</b>, does not support the &quot;crypt&quot;\n"; $cryptwarn .= "function, which is required to encrypt user and moderator passwords.\n"; $cryptwarn .= "If you are on a Windows system, you must be using the ActiveState\n"; $cryptwarn .= "port of Perl, as it supports the &quot;crypt&quot; function.</FONT>\n"; } print <<_END_; <HTML><HEAD><TITLE>Discus Setup - Interactive Form</TITLE></HEAD> <BODY BGCOLOR=#ffffff TEXT=#000000 LINK=#0000ff VLINK=#800080 BACKGROUND=""> <BASEFONT SIZE=2> <FONT FACE="Verdana, Arial, Helvetica" SIZE=2> <FONT SIZE=4><CENTER><B>Discus Setup - Interactive Form</b></CENTER></FONT> <HR SIZE=0><P> <FORM ACTION="" METHOD=POST> <TABLE WIDTH=100% BORDER=0 CELLPADDING=0 CELLSPACING=0> <TR> <TD VALIGN=TOP BGCOLOR=#ccccff WIDTH=200><FONT FACE="Verdana,Arial,Helvetica" SIZE=2><CENTER><B>Introduction</b></CENTER><P><FONT SIZE=1> This is important information that will help you when performing the setup of your board. Please read it carefully!</FONT></FONT></TD> <TD>&nbsp;&nbsp;</TD> <TD VALIGN=TOP> <FONT FACE="Verdana,Arial,Helvetica" SIZE=2> Congratulations! You have successfully uploaded the FTP setup assistant to your server, and it is now being executed as a CGI script by your web server using your Perl interpreter. On this page, you will be able to enter the parameters for your Discus board after reviewing the instructions and suggestions that have been provided for you. <P> <B>IMPORTANT:</b> 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 <I>need</I> to change these. <B><FONT COLOR=#ff0000>Don't just accept our guesses without reviewing them (and changing them if necessary)!</FONT></b> </TD></TR> <TR><TD>&nbsp;</TD><TD>&nbsp;</TD><TD>&nbsp;</TD></TR> <TR> <TD VALIGN=TOP BGCOLOR=#ffccff WIDTH=200><FONT FACE="Verdana,Arial,Helvetica" SIZE=2><CENTER><B>Path to Perl</b></CENTER><P><FONT SIZE=1> The Perl interpreter on your system interprets the Discus scripts and presents the results to you in your browser.</FONT></FONT></TD> <TD>&nbsp;&nbsp;</TD> <TD VALIGN=TOP> <FONT FACE="Verdana,Arial,Helvetica" SIZE=2> <INPUT TYPE=HIDDEN NAME=version_requested VALUE="3_10-"> $NTFLAG Enter the path to Perl for your system. Your test CGI script used <B>$perl</b> for the path to Perl, so this should also work on all of the rest of the Discus scripts. Do not change this setting unless you have a good reason to do so. This Perl interpreter is running Perl version <B>$]</b>. <P> $perl4warn <P> $cryptwarn <P> <UL> Path to Perl: <TABLE><TR><TD><Input TYPE=text SIZE=40 NAME=pathperl VALUE="$perl"></TD></TR></TABLE> </UL></FONT> </TD></TR> <TR><TD>&nbsp;</TD><TD>&nbsp;</TD><TD>&nbsp;</TD></TR> <TR> <TD VALIGN=TOP BGCOLOR=#ffccff WIDTH=200><FONT FACE="Verdana,Arial,Helvetica" SIZE=2><CENTER><B>CGI Extension</b></CENTER><P><FONT SIZE=1> 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.</FONT></FONT></TD> <TD>&nbsp;&nbsp;</TD> <TD VALIGN=TOP> <FONT FACE="Verdana,Arial,Helvetica" SIZE=2> The CGI extension is the extension that must be given to files for the server to treat them as CGI scripts. Usually this is &quot;.cgi&quot; or &quot;.pl&quot; 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 (&quot;.cgi&quot; and &quot;.CGI&quot; are <I>not</I> the same). You used <B>$cgi_extension</b> as the extension for the test script, so this should work for all of the Discus scripts. Do not change this setting uless you have a good reason to do so. <P> <UL> CGI Extension: <TABLE><TR><TD><Input TYPE=text SIZE=5 NAME=cgi_extension VALUE="$cgi_extension"></TD></TR></TABLE> </UL></FONT> </TD></TR> <TR><TD>&nbsp;</TD></TR> <TR> <TD VALIGN=TOP BGCOLOR=#ffcccc WIDTH=200><FONT FACE="Verdana,Arial,Helvetica" SIZE=2><CENTER><B>Administration Directory</b></CENTER><P><FONT SIZE=1> The administration directory stores configuration files and password files for your Discus board. This directory is never accessed by a web browser. <P> For your security, this directory should be &quot;hidden&quot; from the web server (out of the server's web space) if possible.</FONT></FONT></TD> <TD>&nbsp;&nbsp;</TD> <TD VALIGN=TOP> <FONT FACE="Verdana,Arial,Helvetica" SIZE=2> 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 <B>$bdcgi</b>. 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! <P> The <B>administration directory</b> should not be accessible at <I></I>. If you cannot &quot;hide&quot; this directory from your server, at least give it a non-standard name (if you call it &quot;discus_admin&quot; anyone at all can find it easily and look at your password files). 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 <I>directory</I> and not a URL -- it should <B>not</b> start with <TT><B>http://</b></TT>! <P> <FONT COLOR=#aa0000><B>Example:</b> To specify the Discus administration directory, we suggest choosing a directory with a nonstandard name so it cannot be easily guessed. Perhaps <B>$admin_dir</b> would be a good choice.</FONT> <P> <UL> Administration Files Directory: <TABLE><TR><TD><Input TYPE=text SIZE=50 NAME=admin_dir VALUE="$admin_dir"></TD></TR></TABLE> </UL></FONT> </TD></TR> <TR><TD>&nbsp;</TD></TR> <TR> <TD VALIGN=TOP BGCOLOR=#ffcccc WIDTH=200><FONT FACE="Verdana,Arial,Helvetica" SIZE=2><CENTER><B>HTML Directory</b></CENTER><P><FONT SIZE=1> 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.</FONT></FONT></TD> <TD>&nbsp;&nbsp;</TD> <TD VALIGN=TOP> <FONT FACE="Verdana,Arial,Helvetica" SIZE=2> The HTML files that come with Discus, such as the instructions, main menu, and administration program framesetting document are placed in the &quot;HTML Files Directory.&quot; 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 <I>directory</I> and not a URL -- it should <B>not</b> start with <TT><B>http://</b></TT>! $warn_dir <P> <FONT COLOR=#aa0000><B>Example:</b> <TT><B>$html_dir</b></TT></FONT>. <P> <UL> HTML Files Directory: <TABLE><TR><TD><Input TYPE=text SIZE=50 NAME=html_dir VALUE="$html_dir"></TD></TR></TABLE> </UL> <P> You also need to give the URL that corresponds to the HTML Files Directory that you specified above. This <B>must</b> start with <TT><B>http://</b></TT>. <P> <FONT COLOR=#aa0000><B>Example:</b> <TT><B>$html_url</b></TT></FONT> <P> <UL> HTML Files URL: <TABLE><TR><TD><Input TYPE=text SIZE=50 NAME=html_url VALUE="$html_url"></TD></TR></TABLE> </UL> </FONT> </TD></TR> <TR><TD>&nbsp;</TD></TR> <TR> <TD VALIGN=TOP BGCOLOR=#ffcccc WIDTH=200><FONT FACE="Verdana,Arial,Helvetica" SIZE=2><CENTER><B>Script Directory</b></CENTER><P><FONT SIZE=1> The script directory stores the Perl CGI scripts that power the Discus program. This directory normally needs to go under your cgi-bin. <P> Because this script is working properly, if you placed it in your cgi-bin without creating a special directory for it, these suggestions should work.</FONT></FONT></TD> <TD>&nbsp;&nbsp;</TD> <TD VALIGN=TOP> <FONT FACE="Verdana,Arial,Helvetica" SIZE=2> 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.) <P> 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 <I>directory</I> and not a URL -- it should <B>not</b> start with <TT><B>http://</b></TT>! <P> <FONT COLOR=#aa0000><B>Example:</b> <TT><B>$script_dir</b></TT></FONT> <P> <UL> Script Files Directory: <TABLE><TR><TD><Input TYPE=text SIZE=50 NAME=script_dir VALUE="$script_dir"></TD></TR></TABLE> </UL> <P> You also need to give the URL that corresponds to the Script Files Directory that you specified above. This <B>must</b> start with <TT><B>http://</b></TT>. <P> <FONT COLOR=#aa0000><B>Example:</b> <TT><B>$script_url</b></TT></FONT> <P> <UL> Script Files URL: <TABLE><TR><TD><Input TYPE=text SIZE=50 NAME=script_url VALUE="$script_url"></TD></TR></TABLE> </UL> </FONT> </TD></TR> <TR><TD>&nbsp;</TD></TR> <TR> <TD VALIGN=TOP BGCOLOR=#ccffcc WIDTH=200><FONT FACE="Verdana,Arial,Helvetica" SIZE=2><CENTER><B>Board Title</b></CENTER><P><FONT SIZE=1> You can specify the title of your board.</FONT></FONT></TD> <TD>&nbsp;&nbsp;</TD> <TD VALIGN=TOP> <FONT FACE="Verdana,Arial,Helvetica" SIZE=2> Choose any title you wish by typing the title into the box below. <P> <FONT COLOR=#aa0000><B>Example:</b> <TT><B>John's Forum</b></TT></FONT> <P> <UL> Board Title: <TABLE><TR><TD><Input TYPE=text SIZE=50 NAME=title></TD></TR></TABLE> </UL></FONT> </TD></TR> <TR><TD>&nbsp;</TD></TR> <TR> <TD VALIGN=TOP BGCOLOR=#ccffcc WIDTH=200><FONT FACE="Verdana,Arial,Helvetica" SIZE=2><CENTER><B>Board Contact</b></CENTER><P><FONT SIZE=1> This is where you type your name and e-mail address.</FONT></FONT></TD> <TD>&nbsp;&nbsp;</TD> <TD VALIGN=TOP> <FONT FACE="Verdana,Arial,Helvetica" SIZE=2> 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.) <P> <FONT COLOR=#aa0000><B>Example:</b> <TT><B>John Smith</b></TT> is the contact person, and <TT><B>smith\</b></TT> is the e-mail.</FONT> <P> <UL> Board Contact Person: <TABLE><TR><TD><Input TYPE=text SIZE=50 NAME=contact_name></TD></TR></TABLE> </UL> <P> <UL> Board Contact E-mail Address: <TABLE><TR><TD><Input TYPE=text SIZE=50 NAME=contact_email></TD></TR></TABLE> </UL> </FONT> </TD></TR> <TR><TD>&nbsp;</TD></TR> <TR><TD>&nbsp;</TD></TR> <TR> <TD VALIGN=TOP BGCOLOR=#ccffcc WIDTH=200><FONT FACE="Verdana,Arial,Helvetica" SIZE=2> <CENTER><B>Language</b></CENTER><P><FONT SIZE=1> You can choose the language for the User Interface of your board.</FONT></FONT></TD> <TD>&nbsp;&nbsp;</TD> <TD VALIGN=TOP> <FONT FACE="Verdana,Arial,Helvetica" SIZE=2> Available translations of the Discus User Interface for this version are indicated on the list below. Choose the desired language for the User Interface from this list. <P> <UL> Language: <TABLE><TR><TD><SELECT NAME=language SIZE=1> <OPTION VALUE=english SELECTED>English <OPTION VALUE=danish>Danish <OPTION VALUE=french>French <OPTION VALUE=dutch>Dutch <OPTION VALUE=finnish>Finnish <OPTION VALUE=german>German <OPTION VALUE=italian>Italian <OPTION VALUE=korean>Korean <OPTION VALUE=malaysian>Malaysian <OPTION VALUE=norwegian>Norwegian <OPTION VALUE=portuguese>Portuguese <OPTION VALUE=slovenian>Slovenian <OPTION VALUE=spanish>Spanish <OPTION VALUE=swedish>Swedish <OPTION VALUE=turkish>Turkish </SELECT> </TD></TR></TABLE> </UL></FONT> </TD></TR> <TR><TD>&nbsp;</TD></TR> <TR> <TD VALIGN=TOP BGCOLOR=#00aa00 WIDTH=200><FONT FACE="Verdana,Arial,Helvetica" SIZE=2><CENTER><B>Submit the form</b></CENTER><P><FONT SIZE=1> After double checking your parameters, click the button to generate your individualized distribution of Discus!</FONT></FONT></TD> <TD>&nbsp;&nbsp;</TD> <TD VALIGN=TOP> <FONT FACE="Verdana,Arial,Helvetica" SIZE=2> When you have filled in all of the blanks above, click the button to generate your individual custom Discus distribution. Please note that <B>processing could take several seconds</b>, so please click the button only one time, and be patient. <P> <CENTER> <INPUT TYPE=SUBMIT VALUE="Submit Form"> </CENTER> <P> </FONT></TD></TR></TABLE> </FORM> <P> <FONT SIZE=1 FACE="Arial,Helvetica">Copyright &copy; 2000, <A HREF="">DiscusWare, LLC</A>, all rights reserved.</FONT> </body></HTML> _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; } # -->