home *** CD-ROM | disk | FTP | other *** search
/ IRIX 6.4 Applications 1997 August / SGI IRIX 6.4 Applications 1997 August.iso / dist / gateway.idb / usr / WebFace / Tasks / Tasks.connect-start.cgi.z / Tasks.connect-start.cgi
Encoding:
Text File  |  1997-07-30  |  7.2 KB  |  223 lines

  1. #!/usr/bin/perl5
  2. #
  3. # Tasks.connect-start.cgi
  4. #
  5. # Copyright 1988-1996 Silicon Graphics, Inc.
  6. # All rights reserved.
  7. #
  8. # This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, Inc.;
  9. # the contents of this file may not be disclosed to third parties, copied or
  10. # duplicated in any form, in whole or in part, without the prior written
  11. # permission of Silicon Graphics, Inc.
  12. #
  13. # RESTRICTED RIGHTS LEGEND:
  14. # Use, duplication or disclosure by the Government is subject to restrictions
  15. # as set forth in subdivision (c)(1)(ii) of the Rights in Technical Data
  16. # and Computer Software clause at DFARS 252.227-7013, and/or in similar or
  17. # successor clauses in the FAR, DOD or NASA FAR Supplement. Unpublished -
  18. # rights reserved under the Copyright Laws of the United States.
  19. #
  20. # $Id: Tasks.connect-start.cgi,v 1.41 1997/06/24 22:20:54 shotes Exp $
  21.  
  22. require "/usr/OnRamp/lib/OnRamp.pm";
  23. require "/usr/OnRamp/lib/java.pm";
  24.  
  25. $myname = "Tasks.connect-start.cgi";
  26. $temp = "task.tmp";
  27. $data = "task.dummy";
  28. $action = "Tasks.connect-start.cgi?loop";
  29.  
  30. $it = "<td align=right>";
  31. $ni = "</td>";
  32. $bo = "<td><font size=5><i>";
  33. $nb = "</i></font></td>";
  34.  
  35. @find_vals = ('provider','nameserver','domain');
  36.  
  37. &get_fields;
  38. &get_js;
  39.  
  40. # clear temporary file for initial call
  41. if (!$ARGV[0]) {
  42.     open(OUT,"> $temp");
  43.     close(OUT);
  44.  
  45.     open(IN,"/usr/bsd/hostname | ");
  46.     $host = <IN>; chomp($host);
  47.     if ($host) { ($host, $dum1, $dum2, $dum3, @dum4)
  48.                     = gethostbyname($host); }
  49.     $host =~ /^\w+\.([\w\.]+)$/;
  50.     $vals{'domain'} = $1;
  51. } elsif ($ARGV[0] eq 'loop') { %vals = %fld;  }
  52. else { &readValues; }
  53.  
  54. if ($ARGV[0] eq loop) {
  55.     &errorCheck;
  56.     &writeFile;
  57.  
  58.     $go = "/tasks/connect-second.cgi?st";
  59.     # printf("Location: %s%c%c",$go,10,10);
  60.     print "Content-type: text/html\n\n";
  61.     print "<HTML><HEAD>";
  62.     print "<META HTTP-EQUIV=\"refresh\" CONTENT=\"0; URL=$go\">";
  63.     print "</HEAD><BODY></BODY></HTML>";
  64.     exit 0;
  65. }
  66.  
  67. &generic;
  68.  
  69. sub readValues {
  70.     open(IN,"< $temp");
  71.     while(<IN>) {
  72.         @items = split(/=/);
  73.         foreach $arg (@find_vals) {
  74.             if ($arg eq $items[0]) {
  75.                 if ($items[1] ne "\n") {
  76.                     $vals{$arg} = $items[1];
  77.                     chop $vals{$arg};
  78.                 }
  79.             }
  80.         }
  81.     }
  82.     close(IN);
  83. }
  84.  
  85. sub errorCheck {
  86.     &error("The domain name is required.") if !$fld{'domain'};
  87.     &error("Provider IP address is required.") if !$fld{'provider'};
  88.     &error("Nameserver IP address is required.") if !$fld{'nameserver'};
  89.     &error("The domain name is invalid.") if &check_hostname($fld{'domain'});
  90.     &error("Provider IP address is invalid.") if &check_ipaddr($fld{'provider'});
  91.     &error("Nameserver IP address is invalid.") if &check_ipaddr($fld{'nameserver'});
  92. }
  93.  
  94. sub error {
  95.     $error = $_[0];
  96.     &generic;
  97.     exit 0;
  98. }
  99.  
  100. sub writeFile {
  101.     undef %terms;
  102.     open(IN,"< $temp");
  103.     while(<IN>) {
  104.         @items = split(/=/);
  105.         chop $items[1];
  106.         $terms{$items[0]} = $items[1];
  107.     }
  108.     close(IN);
  109.     foreach $arg (@find_vals) {
  110.         $terms{$arg} = $fld{$arg};
  111.     }
  112.     open(OUT,"> $temp");
  113.     foreach $arg (keys(%terms)) {
  114.         print OUT "$arg=$terms{$arg}\n";
  115.     }
  116.     close(OUT);
  117. }
  118.  
  119. sub get_js {
  120.  
  121. $js =
  122. "$js_error_box
  123. $js_ip
  124. $js_hostname
  125. function Next() {
  126.      form = document.page1;
  127.     if (!testHostname(form.domain, form.domain.value, \"domain name\", 0)) return;
  128.     if (!testIP(form.provider,\"provider\")) return;
  129.     if (!testIP(form.nameserver,\"nameserver\")) return;
  130.     setTimeout('form.submit()',0);
  131.     return;
  132. }
  133. function testIP(Ctrl,what) {
  134.     if (Ctrl.value == \"\") { errorBox (Ctrl, \"The \" + what + \" IP address is required.\"); return (false); }
  135.     if (! testIPaddress(Ctrl.value,false)) {
  136.         errorBox(Ctrl, \"The \" + what + \" IP address is invalid.\");
  137.         return (false);
  138.     }
  139.     return (true);
  140. }";
  141.  
  142. }
  143.  
  144. sub generic {
  145.     print "Content-type: text/html\n\n";
  146.     print "<html><head><title>Connect to the Internet</title>\n";
  147.     print "<script language=\"JavaScript\">\n<!--\n";
  148.  
  149.     print $js;
  150.  
  151. print "//-->\n";
  152. print "</script></head>\n\n";
  153.     
  154.     print "<body bgcolor=\'c7ded4\' background=/tasks/connect-task.bg.gif>\n";
  155.     if ($error) {
  156.         print "<font size=4 color=ff0000><b>Error: </b>$error<br></font>";
  157.     }
  158.     print "<i>$message</i>";
  159.  
  160.     print "<table width=100%>",
  161.           "<tr><th align=left><h1>Connect to the Internet</h1></th>\n",
  162.           "<th align=right><a href=\"/newsplash.shtml\">",
  163.           "<img height=55 width=57 border=0 src=/tasks/home.gif></a>\n",
  164.           "  <a href=\"Tasks.shtml\">",
  165.           "<img height=55 width=57 border=0 src=/tasks/back.gif></a>",
  166.           "</tr></table>\n";
  167.  
  168.     printf("\n<form name=\"page1\" action=\"%s\" method=post>\n", $action);
  169.     
  170.     print "<center><table width=620>\n";
  171.  
  172.     print "<tr><td colspan=2 align=left>
  173.     To connect your organization to the Internet, you must provide
  174.     information about your site and about the hosts and equipment
  175.     that will be used for Internet connections. Much of this information 
  176.     was supplied by your Internet service provider (ISP) when you subscribed 
  177.     to their service. Be sure that this information is available when you
  178.     complete the setup form that follows.<br><br>
  179.  
  180.     <b>Note:</b> Optional subsystem <i>eoe.sw.ppp</i> is required
  181.     to connect to the Internet via ppp.<br><br></td></tr>\n\n";
  182.  
  183.     print "<tr>$bo Domain name for your organization: $nb \n$it", 
  184.           &text("domain",$vals{'domain'},15), 
  185.           "$ni </tr>\n";
  186.     print "    <tr><td colspan=2>
  187.     In Internet parlance, a domain is a collection of hosts that are
  188.     managed as one entity. The domain name of your organization is the
  189.     name by which it will be known on the Internet. Enter your organization's
  190.     domain name in this field (supplied by your ISP).
  191.     <br><br></td></tr><tr><td> </td></tr>\n\n";
  192.  
  193.     print "<tr>$bo IP address of your ISP host: $nb \n$it", 
  194.           &text("provider",$vals{'provider'},15), 
  195.           "$ni </tr>\n";
  196.     print "    <tr><td colspan=2>
  197.     The Internet Gateway connects to a host at your ISP site to gain access
  198.     to other locations on the Internet. The IP address of the ISP host is needed
  199.     to establish this connection. Enter the ISP host address of in this field 
  200.     (supplied by your ISP). Your entry will look like this example: 191.65.43.8.
  201.     <br><br></td></tr><tr><td> </td></tr>\n\n";
  202.  
  203.     print "<tr>$bo IP address of the remote name server: $nb \n$it", 
  204.           &text("nameserver",$vals{'nameserver'},15), 
  205.           "$ni </tr>\n";
  206.     print "    <tr><td colspan=2>
  207.     The Internet Gateway translates hostnames to IP addresses for hosts in
  208.     your domain. But for hosts outside your domain, it forwards translation
  209.     requests to a remote name server. Enter the IP address of the remote
  210.     name server in this field (issued by your ISP). Your entry will look 
  211.     like this example: 191.64.43.8.  </td></tr><tr><td> </td></tr>\n";
  212.     print "</table></center>\n";
  213.  
  214.     print '<MAP NAME="js_map">',
  215.     '    <AREA SHAPE="rect" COORDS="0,0,59,52" HREF="javascript:Next()"
  216.     onMouseOver="window.status=\'\';return true">',
  217.     '</MAP>';
  218.     print "\n";
  219.     print '<IMG SRC="/tasks/rightarrow.gif" BORDER=0 USEMAP="#js_map" align="right">';
  220.  
  221.     print "\n</form></body></html>";
  222. }
  223.