home *** CD-ROM | disk | FTP | other *** search
/ CD Actual 49 / cda49.iso / VNULabs / BrownOrifice / BOHTTPD-0.2 / BOHTTPD.cgi < prev    next >
Encoding:
Text File  |  2000-08-10  |  2.2 KB  |  101 lines

  1. #!/usr/bin/perl
  2.  
  3. use CGI;
  4. use BOHTTPD;
  5.  
  6. my $cgi = new CGI;
  7.  
  8. sub show_applet {
  9.   my $path = $cgi->param('path') ||
  10.     (is_ms ? '/c:/Program Files' : '/usr/local');
  11.   $path =~ s/^\/+//;
  12.   $path =~ s/\/+$//;
  13.  
  14.   my $host = $ENV{REMOTE_HOST} || $ENV{REMOTE_ADDR};
  15.   my $port = $cgi->param('port') || 8080;
  16.   my $url ="http://${host}:${port}/${path}/";
  17.   my ($HOST, $PATH, $PORT, $URL) = map html_escape($_), $host, $path, $port, $url;
  18.  
  19.   if (is_ie) {
  20.     print qq<
  21.       <p>
  22.         BOHTTPD does not yet work with Internet Explorer.
  23.         Get the latest version of Netscape Communicator in order to
  24.         convert your browser into a Web Server!
  25.       </p>
  26.     >
  27.   } else {
  28.     print qq<
  29.       <h3>Congratulations!</h3>
  30.       <p>You are now running BOHTTPD on port $port!</p>
  31.       <p>Click the link below to access your browser's web server:</p>
  32.       <ul>
  33.         <li><code><a href="$URL">$URL</a></code>
  34.       </ul>
  35.       <applet trustproxy=1 code="BOHTTPD.class" name="BOHTTPD" width=0 height=0>
  36.         <param name="host" value="$HOST">
  37.         <param name="port" value="$PORT">
  38.         <param name="path" value="$PATH">
  39.       </applet>
  40.     >
  41.   }
  42. }
  43.  
  44. sub show_form {
  45.   my $path = $cgi->param('path') ||
  46.     (is_ms ? '/C:/Program Files/' : '/usr/local/');
  47.   $path =~ s/^\/\/+/\//;
  48.   $path =~ s/\/\/+$/\//;
  49.  
  50.   my $port = $cgi->param('port') || 8080;
  51.   my ($PATH, $PORT) = map html_escape($_), $path, $port;
  52.  
  53.   show_info;
  54.  
  55.   print qq<
  56.     <form action="BOHTTPD.cgi" method=post>
  57.       <h3>Run BOHTTPD in Netscape</h3>
  58.       <ul>
  59.   >;
  60.  
  61.   show_warning;
  62.  
  63.   print qq<
  64.       <table>
  65.         <tr>
  66.           <td>Path</td>
  67.           <td><input type=text name=path value="$PATH"></td>
  68.         </tr>
  69.         <tr>
  70.           <td>Port</td>
  71.           <td><input type=text name=port value="$PORT"></td>
  72.         </tr>
  73.         <tr>
  74.           <td colspan=2>
  75.             <input type=hidden name=do value=applet>
  76.             <input type=submit value="Start BOHTTPD">
  77.           </td>
  78.         </tr>
  79.       </table>
  80.       </ul>
  81.     </form>
  82.   >
  83. }
  84.  
  85. sub show {
  86.   show_header;
  87.  
  88.   if ($cgi->param('do') eq 'applet') {
  89.     show_applet;
  90.   } else {
  91.     show_form;
  92.   }
  93.  
  94.   show_footer;
  95. }
  96.  
  97. print "Content-type: text/html\n\n";
  98. &show;
  99.  
  100. 1
  101.