home *** CD-ROM | disk | FTP | other *** search
/ rtsi.com / 2014.01.www.rtsi.com.tar / www.rtsi.com / OS9 / FAQ / cgi-bin / discus4_00 / dconfig.cgi < prev    next >
Text File  |  2009-11-06  |  25KB  |  735 lines

  1. #!/usr/bin/perl
  2. #
  3. # <!--
  4. # ------------------------------------------------------------------
  5. #  DISCUS CONFIGURATION ASSISTANT SCRIPT
  6. #
  7. #  Congratulations, if you are seeing this page, generation of this
  8. #  script was successful!
  9. #
  10. #  Now, select "File | Save As..." from your browser's window.
  11. #  This output should be saved as "dconfig.cgi" in any temporary
  12. #  folder on your hard disk.  When you have saved the file, use your
  13. #  browser's back button to return to the instructions.  This file
  14. #  should be saved as plain text, NOT as HTML.
  15. #
  16. #  This script is Copyright (c) 2001 by DiscusWare, LLC, all rights
  17. #  reserved.  It may be used under the same terms as Discus itself,
  18. #  detailed in http://www.discusware.com/discus/license
  19. #
  20. # ------------------------------------------------------------------
  21. #
  22. # This code checks for the script being displayed as HTML
  23.  
  24. if (1 == 0) {
  25.     print <<EOF;
  26. -->
  27. <HTML><HEAD><TITLE>Setup Assistant Error</TITLE></HEAD>
  28. <BODY BGCOLOR=#ffffff TEXT=#000000>
  29. <H1>Setup Assistant Error</H1>
  30. If you are seeing this error message, the Setup setup assistant is not
  31. being properly executed as a CGI script, but is rather being shown as
  32. an ordinary HTML file.  You must consult your server administrator to
  33. have them turn on CGI permissions in this directory.
  34. </BODY></HTML>
  35. <!--
  36. EOF
  37. }
  38.  
  39. if ($ENV{QUERY_STRING} =~ /title/) {
  40.     my $discus_conf_generate_dir = '/home/ftp/OS9/FAQ/cgi-bin/discus4_00';
  41.     my $FORM = {};
  42.     my $query_string = $ENV{QUERY_STRING};
  43.     $query_string =~ s/#(.*)$//;
  44.     if ($query_string ne "") {
  45.         my @query_pairs = split(/&/, $query_string);
  46.         foreach my $qpair (@query_pairs) {
  47.             my ($qname, $qvalue) = split(/=/, $qpair);
  48.             $qvalue =~ tr/+/ /;
  49.             $qvalue =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
  50.             $qvalue =~ s/<!--#(\w*)(\s*)(\w*)(\s*)=(\s*)"([^"]*)"(.*)-->//g;
  51.             $FORM->{$qname} .= ",$qvalue" if $FORM->{$qname} ne "";
  52.             $FORM->{$qname} = $qvalue if $FORM->{$qname} eq "";
  53.         }
  54.     }
  55.     my $discus_conf = "";
  56.     foreach my $field ('admin_dir', 'html_dir', 'script_dir', 'html_url', 'script_url', 'language', 'title', 'cgi_extension') {
  57.         $discus_conf .= "$field=$FORM->{$field}\n";
  58.     }
  59.     $discus_conf .= "superuser=admin\n";
  60.     $discus_conf .= "pro=$FORM->{get_pro}\n";
  61.     $discus_conf .= "ext=html\n";
  62.     $discus_conf .= "pro_license=$FORM->{pro_license}\n" if $FORM->{pro_license};
  63.     $discus_conf .= "version=4.00\n";
  64.     $discus_conf .= "platform=NT\n" if $^O eq "MSWin32";
  65.     $discus_conf .= "contact=<a href=\"mailto:$FORM->{contact_email}\">$FORM->{contact_name}</a>\n";
  66.     my $discus_conf_written = 0;
  67.     if ($discus_conf_generate_dir ne "" && -e "$discus_conf_generate_dir/discus.conf" && -s "$discus_conf_generate_dir/discus.conf" == 0) {
  68.         if (open (DISCUS_CONF, "> $discus_conf_generate_dir/discus.conf")) {
  69.             print DISCUS_CONF $discus_conf;
  70.             close (DISCUS_CONF);
  71.             $discus_conf_written = 1;
  72.         }
  73.     }
  74.     header();
  75.     print <<End_Top;
  76. <HTML><HEAD><TITLE>Telnet/Console Setup Assistant</TITLE></HEAD>
  77. <style>
  78. <!--
  79. body {font: 9pt Verdana,Arial,Helvetica; }
  80. p {width: 600;}
  81. .mainheader {width: 600; font: 14pt Verdana,Arial,Helvetica; border-bottom: thin #aa0000 solid; }
  82. .miniheader {width: 600; font: 11pt Verdana,Arial,Helvetica; font-weight: bold; border-bottom: thin #ff0000 solid; }
  83. -->
  84. </style>
  85. </head>
  86. <body bgcolor=#ffffff text=#000000 link=#0000ff vlink=#800080 background="http://www.discusware.com/discus/ftp/background.jpg">
  87.  
  88. <p class="mainheader">Discus Setup - Configuration is Complete</p>
  89. <p>
  90. Congratulations!  You have successfully configured your Discus installation for your server.
  91. Now, all that remains is one simple step of actually copying the files to the appropriate
  92. locations on your server.  These instructions will guide you through this process.
  93. </p>
  94.  
  95. End_Top
  96.  
  97.     if ($discus_conf_written) {
  98.         print <<End_Top;
  99. <p class="miniheader">1. Return to 1st_install.pl script</p>
  100. <p>
  101. Your discus.conf file has been automatically copied to the directory where you ran the
  102. 1st_install.pl script.  All you need to do is return to the 1st_install.pl script, and
  103. when asked whether to use the discus.conf file in the directory, answer yes.  The setup
  104. of your Discus installation will then proceed automatically.
  105. </p>
  106.  
  107. <p class="miniheader">2. Access your board</p>
  108.  
  109. End_Top
  110.  
  111.     } else {
  112.         print <<End_Top;
  113. <p class="miniheader">1. Obtain your discus.conf file</p>
  114. <p>
  115. Your discus.conf file is contained in the following box.  Click your mouse in the box,
  116. and select all of the text.  Select Edit | Copy from the browser's menu.
  117. </p>
  118. <ul>
  119.     <form>
  120.     <textarea rows=8 cols=50 wrap=off>$discus_conf</textarea>
  121.     </form>
  122. </ul>
  123. <p class="miniheader">2. Run 1st_install.pl again</p>
  124. <p>
  125. Back in your telnet/console window, run the 1st_install.pl script again by typing
  126. <tt>perl 1st_install.pl</tt>, or in Windows, double-clicking on the 1st_install.pl
  127. script in the explorer list.
  128. </p>
  129. <p>
  130. The script will ask you if you just recently generated a discus.conf file -- answer
  131. yes.
  132. </p>
  133.  
  134. <p class="miniheader">3. Paste in discus.conf</p>
  135. <p>
  136. The 1st_install.pl script will tell you to paste in your discus.conf file.  Using
  137. the paste function of your telnet client or console window, paste in the discus.conf
  138. file you copied from above.  Generally there is a paste button to accomplish this
  139. feature.
  140. </p>
  141.  
  142. <p class="miniheader">4. Access your board</p>
  143.  
  144. End_Top
  145.  
  146.     }
  147.     print <<End_Top;
  148. <p>
  149. Your board is now ready for use at:
  150. </p>
  151. <ul>
  152.     <a href="$FORM->{script_url}/discus.$FORM->{cgi_extension}">$FORM->{script_url}/discus.$FORM->{cgi_extension}</a>
  153. </ul>
  154. <p>
  155. The first thing you should do is to set up your administration password.  To do this, click
  156. on the "Administration" link.  Enter "admin" as your username and leave the password blank.
  157. You will be prompted to set up your password and to register Discus.
  158. </p>
  159. <p>
  160. Thank you for choosing Discus for your discussion needs!
  161. </p>
  162. </body>
  163. </html>
  164.     
  165. End_Top
  166.     exit(0);
  167. }
  168.  
  169. #
  170. # Check for compliance of Perl interpreter
  171. #
  172.  
  173. if ($] < 5) {
  174.     &header("Setup Setup Error");
  175.     print "Your Perl interpreter is not Perl 5 or better.\n";
  176.     &perl_sysreq();
  177. }
  178.  
  179. eval 'use strict;';
  180. if ($@) {
  181.     &header("Setup Setup Error");
  182.     print "Your Perl interpreter does not support 'use strict'.\n";
  183.     &perl_sysreq();
  184. }
  185.  
  186. my $rv = eval 'my $x = returns_one(); $x;';
  187. if ($rv != 1 || $@) {
  188.     &header("Setup Setup Error");
  189.     print "Your Perl interpreter does not properly handle subroutine definitions.\n";
  190.     &perl_sysreq();
  191. }
  192.     
  193. my $c = eval 'crypt("test", "na");';
  194. if ($c ne "nagdheJ4NyCzY") {
  195.     &header("Setup Setup Error");
  196.     print "Your Perl interpreter does not properly support the 'crypt' function.\n";
  197.     if ($^O eq "MSWin32") {
  198.         print "Note: On Windows, you need <a href='http://www.activestate.com'>ActivePerl</a>!\n";
  199.     }
  200.     &perl_sysreq();
  201. }        
  202.  
  203. #
  204. # Figure out what this script is running as
  205. #
  206.  
  207. header();    
  208.  
  209. my $prog = $0;
  210. my $cgi_extension = "";
  211. my $b4 = "";
  212.  
  213. if ($prog =~ m|dconfig\.(\w+)|i) {
  214.     $prog = $&;
  215.     $cgi_extension = $1;
  216.     $b4 = $`; $b4 =~ s/\/$//; $b4 =~ s/\\$//;   
  217. } else {
  218.    print "<HTML><HEAD><TITLE>Sorry...</TITLE></HEAD>\n";
  219.    print "<BODY><B>Setup Error</B>\n\n";
  220.    if ($prog eq "") {
  221.       print "<P>This version of Perl is malfunctioning, as it did not\n";
  222.       print "set the <B>\$0</B> variable.  Please contact your server\n";
  223.       print "administrator and inform them that this Perl installation\n";
  224.       print "is not functioning properly.<P>\n";
  225.    } else {
  226.      print "<P>It appears that this script is not named "dconfig.***"\n";
  227.      print "as required by the setup.  If necessary, rename this file.  Currently\n";
  228.      print "this file is titled <B>$prog</B><P>\n";
  229.    }
  230.    print "</BODY></HTML>\n";
  231.    exit(0);
  232. }
  233.  
  234. #
  235. # Find your home directory
  236. #
  237.  
  238. my ($script_uid, $hdsees, $elim, $sees, $sees_warn);
  239. if ($^O ne "MSWin32") {
  240.     ($script_uid, $hdsees, $elim, $sees) = eval {
  241.         my ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,$blksize,$blocks) = stat $0;
  242.         my $hd = (getpwuid($uid))[7];
  243.         if ($hd =~ m|/\./|) {
  244.             ( $uid, $hd, $`, "$'" );
  245.         } else {
  246.             ( $uid, $hd, "", "" );
  247.         }
  248.     };
  249.     if ($elim || $sees) {
  250.         $sees_warn = "
  251.             <p>
  252.             <ul>
  253.             <table bgcolor=#ffcccc><tr><td>
  254.             <font face='Verdana,Arial,Helvetica' size=2>
  255.             <p>
  256.             <b>Directory Information:</b>  It appears that when you log in by Setup, you are
  257.             restricted by your web host to a certain portion of your server.  This is OK, but
  258.             it will require you to mentally adjust directory paths when you complete the
  259.             setup of this software.
  260.             </p>
  261.             <p>
  262.             It appears that when you log in by Setup, the name of the directory you first see in
  263.             your Setup program is <b>/$sees</b>.  The actual, full path to this directory is
  264.             <b>$elim/$sees</b>.
  265.             </p>
  266.             <p>
  267.             It is very important in this setup that you leave the <b>$elim</b> part at the
  268.             beginning of the directory paths, even though you don't see this when you log in
  269.             by Setup.  However, in the final setup instructions, you may be asked for example
  270.             to create the directory $elim/$sees/discus.  In your Setup program, it would appear
  271.             that you are creating the directory    /$sees/discus.
  272.             </p>
  273.             <p>
  274.             For more information regarding this situation, please read our Knowledge Center
  275.             document on <a href='http://support.discusware.com/center/resources/tips/adjust.html' target=_blank>Adjusting Directory Paths</a>.
  276.             </p>
  277.             </font></td></tr></table></ul>
  278.             </p>
  279.             <input type=hidden name='sees' value='/$sees'>
  280.             <input type=hidden name='elim' value='$elim'>
  281.             <input type=hidden name='own_uid' value='$script_uid'>
  282.             <input type=hidden name='run_uid' value='$<'>
  283.         ";
  284.     }    
  285. }
  286.  
  287. my $homedir = {};
  288. if ($^O ne "MSWin32") {
  289.     eval '$homedir->{home} = (getpwuid($<))[7];';
  290.     $homedir->{pwd} = `pwd`; chomp $homedir->{pwd};
  291. }
  292. if (!eval 'use Cwd;') {
  293.     eval '$homedir->{cwd} = cwd();';
  294. }
  295. $homedir->{docroot} = $ENV{'DOCUMENT_ROOT'};
  296. $homedir->{filename} = $ENV{'SCRIPT_FILENAME'};
  297. $homedir->{filename} =~ s/\/$prog//;
  298. $homedir->{filename} =~ s/\\$prog//;
  299. $homedir->{path} = $ENV{'PATH_TRANSLATED'};
  300. $homedir->{b4} = $b4;
  301. my $real = check($homedir, [ 'pwd', 'filename', 'path', 'cwd', 'b4', 'docroot' ], $prog);
  302. $real =~ s%\\%/%g; $real =~ s%//%/%g;
  303.  
  304. if ($real eq "") {
  305.    print "<HTML><HEAD><TITLE>Sorry...</TITLE></HEAD>\n";
  306.    print "<BODY><PRE><B>Setup Complication</B>\n\n";
  307.    print "The setup script could not determine the current working directory\n";
  308.    print "of the server.  This is very rare (only 1-2% of servers).  The environment\n";
  309.    print "variables and other potentially helpful values are being printed here for\n";
  310.    print "your reference:\n\n";
  311.    print "<B>PWD</B>         $homedir->{pwd}\n";
  312.    print "<B>Doc. Root</B>   $homedir->{docroot}\n";
  313.    print "<B>File name</B>   $homedir->{filename}\n";
  314.    print "<B>Path</B>        $homedir->{path}\n";
  315.    print "<B>CWD</B>         $homedir->{cwd}\n";
  316.    print "<B>'b4'</B>        $homedir->{b4}\n";
  317.    print "Here are the environment variables:\n\n";
  318.    foreach my $key (sort keys(%ENV)) {
  319.        print "<B>$key</B> = [$ENV{$key}]\n";
  320.    }
  321.    print "\n\n";
  322.    print "</PRE></BODY></HTML>\n";
  323.    exit(0);
  324. }
  325.  
  326. my @founddir = ();
  327. opendir(CURDIR, "..");
  328. while (my $q = readdir(CURDIR)) {
  329.     push (@founddir, $q);
  330. }
  331. closedir(CURDIR);
  332. @founddir = grep(!/\./, @founddir);
  333.  
  334. my $discusware_url = "dconfig.cgi";
  335.  
  336. ### SETUP PARAMETERS ###
  337. my $version = '4_00';
  338. my $get_discus_pro = 0;
  339. my $pro_license = '';
  340. ### END SETUP PARAMETERS ###
  341.  
  342. ### LANGUAGES ###
  343. my $language_list = "";
  344. ### END LANGUAGES ###
  345.  
  346. ### SUGGESTION PARAMETERS ###
  347. my $discus_dir_name = 'discus';
  348. my $board_title = '';
  349. my $contact_name = '';
  350. my $contact_email = '';
  351. ### END SUGGESTION PARAMETERS ###
  352.  
  353. #
  354. # On some unix platforms, figure out altered directory paths
  355. #
  356.  
  357. my $adjustment = "";
  358. if ($^O ne "MSWin32") {
  359.     my $s = '
  360.         my $u = (stat "$0")[4];
  361.         my $hd = (getpwuid($u))[7];
  362.         if ($hd =~ m|/\./|) {
  363.             $`;
  364.         }
  365.     ';
  366.     $adjustment = eval $s;
  367. }
  368.  
  369. #
  370. # Guess your setup parameters
  371. #
  372.  
  373. open (PROG, $prog);
  374. my @prog = <PROG>;
  375. close (PROG);
  376.  
  377. my $perl = $prog[0]; $perl =~ s/^#!//; $perl =~ s/\s+$//;
  378. $perl = "/usr/bin/perl" if $perl eq "";
  379. my $base = ""; my $cgi = "";
  380. if ($real =~ m|(.*)/(.+)|) {
  381.     $base = $1; $cgi = $2;
  382. } else {
  383.     $base = $real; $cgi = "cgi-bin";
  384. }
  385. my $admin_dir = "$base/$discus_dir_name" . "_admin_"; my $p = $$; $p =~ s/\D//g; $p .= substr(time, 0, -5); $admin_dir .= $p;
  386. my $html_prefix = 'public_html htdocs www htdoc html docs doc';
  387. my $html_dir = $base;
  388. foreach my $i (split(/\s+/, $html_prefix)) {
  389.     if (-e "$base/$i/index.html" || -e "$base/$i/default.htm" || -e "$base/$i/index.htm") {
  390.         $html_dir .= "/$i";
  391.         last;
  392.     }
  393. }
  394. $html_dir .= "/$discus_dir_name";
  395. my $script_dir = "$real/$discus_dir_name";
  396.  
  397. my $sn = "";
  398. my $script_url = "";
  399.  
  400. if ($ENV{'SCRIPT_URI'} ne "") {
  401.     $sn = $ENV{'SCRIPT_URI'};
  402. } elsif ($ENV{'SCRIPT_URL'} ne "") {
  403.     $sn = $ENV{'SCRIPT_URL'};
  404. } elsif ($ENV{'REQUEST_URI'}) {
  405.     $sn = $ENV{'REQUEST_URI'};
  406. } elsif ($ENV{'SCRIPT_NAME'} ne "") {
  407.     $sn = $ENV{'SCRIPT_NAME'};
  408. }
  409.  
  410. if ($sn ne "") {
  411.     if ($sn =~ m|^http://([^/]+)|) {
  412.         $sn = $';
  413.     }
  414.     if ($sn =~ m|/$prog|i) {
  415.         $sn = $`;
  416.     }
  417.     if ($sn ne "") {
  418.         $script_url = "http://$ENV{'HTTP_HOST'}$sn/$discus_dir_name";
  419.     }
  420. } else {
  421.     $script_url = "http://$ENV{'HTTP_HOST'}/$cgi/$discus_dir_name";
  422. }
  423.  
  424. my $uinfo = "";
  425. if ($script_url =~ m|^http://([^/]+)/~([^/]+)/|) {
  426.     $uinfo = "~" . $2 . "/";
  427. }
  428. my $html_url = "http://$ENV{'HTTP_HOST'}/$uinfo$discus_dir_name";
  429. my $bdcgi = "$base/$cgi";
  430.  
  431. #
  432. # For NT users, convert / to \ to make it look more familiar
  433. #
  434.  
  435. $admin_dir =~ s%/%\\%g if $admin_dir =~ m|^(\w+):|;
  436. $html_dir =~ s%/%\\%g if $html_dir =~ m|^(\w+):|;
  437. $script_dir =~ s%/%\\%g if $script_dir =~ m|^(\w+):|;
  438. $admin_dir =~ s%\\\\%\\%g;
  439. $html_dir =~ s%\\\\%\\%g;
  440. $script_dir =~ s%\\\\%\\%g;
  441. $bdcgi =~ s%/%\\%g if $admin_dir =~ m|^(\w+):|;
  442. $bdcgi =~ s%\\\\%\\%g;
  443.  
  444. my $NTFLAG = '';
  445. my $slash = "/";
  446. if (-e 'c:/' || $^O eq "MSWin32") {
  447.     $NTFLAG = '<input type=hidden name=OS value="NT">';
  448.     $slash = "\\";
  449. }
  450.  
  451. my $path_warning = "";
  452. if ($cgi =~ m|/| || $sn =~ m|^.+/|) {
  453.     $path_warning = "
  454.         <p>
  455.         <font color=#ff0000><b>Warning:</b></font>
  456.         <b>
  457.         It has been detected that you might have created a separate directory
  458.         for this script (e.g., cgi-bin/discus).  If you did this, THIS IS BAD and the
  459.         suggestions will not be accurate.  To ensure the most accurate suggestions,
  460.         this script should be placed, if possible, into the server's main cgi directory.
  461.         </b></p>
  462.     ";
  463.     $path_warning = "" if $cgi !~ m|discus| && $sn !~ m|discus|;
  464. }
  465.  
  466. #
  467. # Discus Setup Form
  468. #
  469.  
  470. print <<_END_;
  471. <html>
  472. <head>
  473. <title>Welcome to Discus Setup</title>
  474. <style>
  475. <!--
  476. body {font: 9pt Verdana,Arial,Helvetica; }
  477. p {width: 600;}
  478. .mainheader {width: 600; font: 14pt Verdana,Arial,Helvetica; border-bottom: thin #aa0000 solid; }
  479. .miniheader {width: 600; font: 11pt Verdana,Arial,Helvetica; font-weight: bold; border-bottom: thin #ff0000 solid; }
  480.  
  481. -->
  482. </style>
  483. </head>
  484. <body bgcolor=#ffffff text=#000000 link=#0000ff vlink=#800080 background="http://www.discusware.com/discus/ftp/background.jpg">
  485.  
  486. <p class="mainheader">Discus Setup - Interactive Form</p>
  487. <form action="$discusware_url" method=GET>
  488. <input type=hidden name=adjustment value="$adjustment">
  489. <p>
  490. Congratulations!  You have successfully uploaded the Setup setup assistant to your server, and it is now being properly executed by your web server.  In addition, it appears that your web server meets our system requirements for basic installation and operation of Discus. 
  491. </p>
  492. $path_warning
  493. <p>
  494. 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.  <b><font color=#ff0000>Don't just accept our guesses without reviewing them (and changing them if necessary)!</font></b>
  495. </p>
  496. <p>
  497. When specifying directories, it is necessary to use the full directory path that your server "sees".  This may or may not correspond to what you see when you log in with your Setup program (many web hosts seek to restrict you to only certain parts of the server to avoid interrupting their other customers).  The suggestions are generally accurate or very close to being accurate.  If you find yourself substantially changing the suggestions, you might be doing something wrong. </p>
  498. <p>
  499. Your server reports seeing this script as:
  500. <br>
  501.     <b>$bdcgi$slash$prog</b>
  502. </p>
  503. $sees_warn
  504. <p class="miniheader">Path to Perl, CGI Extension, License Information</p>
  505.  
  506. <p>
  507. Setup has automatically selected the following parameters:
  508. </p>
  509. <p>
  510.     Path to Perl: <b>$perl</b><br>
  511.     CGI Extension: <b>$cgi_extension</b><br>
  512.     Discus Version: <b>Discus
  513. _END_
  514.  
  515. my $v = $version; $v =~ s/_/\./g;
  516. if ($get_discus_pro) {
  517.     print "Pro $v</b><br>    License Number: <b>$pro_license";
  518. } else {
  519.     print "Freeware $v";
  520. }
  521.  
  522. print <<_END_;
  523. </b>
  524. </p>
  525. <p>
  526. The path to Perl, Discus version, and Discus Pro license information (if any) were configured when you downloaded this file from DiscusWare's web server.  The CGI extension is chosen to match the extension on this file.  If any of these parameters is incorrect, you should download another copy of this script from DiscusWare.
  527. </p>
  528. <input type=hidden name=version_requested value="$version">
  529. <input type=hidden name=get_pro value="$get_discus_pro">
  530. <input type=hidden name=pro_license value="$pro_license">
  531. <input type=hidden name=pathperl value="$perl">
  532. <input type=hidden name=cgi_extension value="$cgi_extension">
  533. $NTFLAG
  534.  
  535. <p class="miniheader">Administration Directory</p>
  536.  
  537. <p>
  538. The administration directory stores configuration files and password files for your Discus board.  This directory is never accessed by a web browser.  For your security, this directory should be "hidden" from the web server (out of the server's web space) if possible.  In other words, the administration directory should <b>not</b> be accessible at <I>http://your.server.com/something</I>.
  539. </p>
  540. <p>
  541. If you must put this directory in a place where it's accessible via the web, we suggest a long string of numbers (or something else random) after the directory name to make it more difficult for an attacker to guess the directory name.  Note that if you don't hide this directory from your web server and someone finds it and accesses it via the web, they can look at your password files and other privileged information!  Finally, this setting must be a <I>directory</I> and not a URL -- it should <B>not</B> start with <B>http://</B>.</p>
  542. <p>
  543. Our suggestions for this parameter are over 95% accurate!
  544. </p>
  545.  
  546. <p>
  547. Administration Directory:
  548. <br>
  549.     <Input TYPE=text SIZE=50 NAME=admin_dir VALUE="$admin_dir"></p>
  550.  
  551. <p class="miniheader">HTML Directory and URL</p>
  552.  
  553. <p>
  554. The HTML files that come with Discus, such as the instructions and main menu, are placed in the HTML Directory.  In addition, your message files (topics and messages), clipart, and icons are all stored in subdirectories of the HTML Directory.  This should <b>not</b> 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 <B>http://</B>!
  555. </p>
  556. <p>
  557. Our suggestions for this parameter are generally quite accurate (unless you choose to rename "discus" to something else).  The most common mistake in the suggestion is if the suggestion forgets to put in the directory immediately above "discus" -- sometimes named public_html, www, htdocs, docs, and so on.  Or, sometimes the suggestion contains one of these directory names when it shouldn't.
  558. </p>
  559.  
  560. <p>
  561. HTML Directory:<br>
  562.     <Input TYPE=text SIZE=50 NAME=html_dir VALUE="$html_dir"></p>
  563.  
  564. <p>
  565. You also need to give the URL that corresponds to the HTML Directory that you specified above.  This <B>must</B> start with <B>http://</B>.  If you changed "discus" to something else when setting up the HTML Directory, be sure to change it here too.
  566. </p>
  567. <p>
  568. HTML URL:<br>
  569.     <Input TYPE=text SIZE=50 NAME=html_url VALUE="$html_url"></p>
  570.  
  571. <p class="miniheader">Script Directory and URL</p>
  572.  
  573. <p>
  574. The script (CGI) files that come with Discus, such as the board administration script and the new message search script, go into the Script Directory.  (These are the Perl scripts that actually power Discus by writing to the message files.)
  575. </p>
  576. <p>
  577. The suggestion for this parameter is over 99% accurate.  You may change the "discus" part at the end if you want to, but don't change anything else unless you really know what you're doing.
  578. </p>
  579.  
  580. <p>
  581. Script Directory:<br>
  582.     <Input TYPE=text SIZE=50 NAME=script_dir VALUE="$script_dir"></p>
  583.  
  584. <p>
  585. You also need to give the URL that corresponds to the Script Directory that you specified above.  This suggestion for this parameter has proven to be over 99% accurate.  If you changed the "discus" part in the Script Directory, be sure to change it here as well.  Don't change anything else unless you really know what you're doing.
  586. </p>
  587.  
  588. <p>
  589. Script URL:<br>
  590.     <Input TYPE=text SIZE=50 NAME=script_url VALUE="$script_url"></p>
  591.  
  592. <p class="miniheader">Title and Contact Information</p>
  593.  
  594. <p>
  595. Here is where you specify the title of your discussion board.  Choose any title you wish.  Since it is fairly difficult to change this later, please be sure to double-check your spelling!
  596. </p>
  597. <p>
  598. Board Title:<br>
  599.     <Input TYPE=text SIZE=50 NAME=title></p>
  600.  
  601. <p>
  602. Enter 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.  Generally you will enter your own name and e-mail address here.  This is very easy to change later.</p>
  603.  
  604. <p>
  605. Board Contact Person:<br>
  606.     <Input TYPE=text SIZE=50 NAME=contact_name>
  607. </p>
  608.  
  609. <p>
  610. Board Contact E-mail Address:<br>
  611.     <Input TYPE=text SIZE=50 NAME=contact_email>
  612. </p>
  613.  
  614. <p class="miniheader">User Interface Options</p>
  615.  
  616. <p>
  617. Available translations of the Discus User Interface are indicated on the list below.  Choose the desired language for your User Interface from this list.
  618. </P>
  619. <p>
  620. User Interface Language:<br>
  621.     <SELECT NAME=language SIZE=1>
  622. <OPTION VALUE=english SELECTED>English
  623. $language_list
  624. </SELECT>
  625. </p>
  626.  
  627. <p class="miniheader">Submit the Form</p>
  628.  
  629. <p>
  630. When you have filled in all of the blanks above, click the button to generate your individual customized Discus distribution.  Please note that <B>processing could take several seconds</B>, so please click the button only one time, and be patient.</p>
  631. <p>
  632. <input type=submit value="Submit Form">
  633. </p>
  634. </body></html>
  635. _END_
  636. exit(0);
  637.  
  638. sub check {
  639.     my ($hr, $arr, $prog) = @_;
  640.     foreach my $l (@{ $arr }) {
  641.         my $dr = $hr->{$l};
  642.         next if $dr eq "";
  643.         $dr =~ s%\\%/%g;
  644.         $dr =~ s%/$%%g;
  645.         next if $dr eq "";
  646.         if (-e "$dr/$prog") {
  647.             return $dr;
  648.         }
  649.     }
  650.     my $c = determine_cwd();
  651.     return $c if $c ne "";
  652.     
  653. }
  654.  
  655. sub determine_cwd {
  656.     my $filename = $0;
  657.     if ($filename =~ m|(.*)/(.*)|) {
  658.         $filename = $2;
  659.     }
  660.     undef my @parent;
  661.     my $ctr = 100;
  662.     my $dots = "";
  663.     my $parent = "";
  664. O:    while ($ctr > 0) {
  665.         $ctr -= 1;
  666.         $dots .= "/" if $dots ne "";
  667.         $dots .= "..";
  668.         if (opendir(DIR, $dots)) {
  669. I:            while (my $dir = readdir(DIR)) {
  670.                 next if $dir =~ m|^\.+$|;
  671.                 next if !-d "$dots/$dir";
  672.                 if (scalar(@parent)) {
  673.                     $parent = "/" . join("/", reverse(@parent));
  674.                 } else {
  675.                     $parent = "";
  676.                 }
  677.                 if (-e "$dots/$dir$parent/$filename") {
  678.                     push (@parent, $dir);
  679.                     last I;
  680.                 }
  681.             }
  682.             closedir(DIR);
  683.         } else {
  684.             last O;
  685.         }
  686.         $parent = "/" . join("/", reverse(@parent));
  687.         if (-e "$parent/$filename") {
  688.             last O;
  689.         }
  690.     }
  691.     $parent = "/" . join("/", reverse(@parent));
  692.     if ($^O eq "MSWin32") {
  693.         foreach my $dr ('c' .. 'z') {
  694.             if (-e "$dr:$parent/$filename") {
  695.                 return "$dr:$parent";
  696.             }
  697.         }
  698.     }
  699.     return $parent;
  700. }
  701.  
  702. sub returns_one {
  703.     return 1;
  704. }
  705.  
  706. sub header {
  707.     my ($x) = @_;
  708.     $| = 1;
  709.     print "Content-type: text/html\n\n";
  710.     return undef if $x eq "";
  711.     print "<html><head><title>$x</title></head>\n";
  712.     print "<body><h1>$x</h1><hr>\n";
  713.     print "<pre>\n";
  714.     return undef;
  715. }
  716.  
  717. sub perl_sysreq {
  718.     print "\n";
  719.     print "Discus will not run on this system, as your Perl interpreter\n";
  720.     print "does not meet the system requirements.  You should upgrade your\n";
  721.     print "Perl interpreter at <a href='http://www.cpan.org'>CPAN</a> (for unix) or at ";
  722.     print "<a href='http://www.activestate.com'>ActiveState</a> (for\nWindows) to be able ";
  723.     print "to run Discus and other CGI scripts like it.\n\n";
  724.     print "Your Perl version is: $]\n";
  725.     print "Your OS is reported as: $^O\n";
  726.     print "The exact error was: $@\n" if ($@ ne "");
  727.     print "\n";
  728.     print "This is not a malfunction in Discus.  We regret that DiscusWare\n";
  729.     print "Support cannot assist you with this problem.\n";
  730.     print "</pre></body></html>\n";
  731.     exit(0);
  732. }
  733.  
  734. # -->
  735.