home *** CD-ROM | disk | FTP | other *** search
- #!/usr/bin/perl5
- #
- # Tasks.connect-start.cgi
- #
- # Copyright 1988-1996 Silicon Graphics, Inc.
- # All rights reserved.
- #
- # This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, Inc.;
- # the contents of this file may not be disclosed to third parties, copied or
- # duplicated in any form, in whole or in part, without the prior written
- # permission of Silicon Graphics, Inc.
- #
- # RESTRICTED RIGHTS LEGEND:
- # Use, duplication or disclosure by the Government is subject to restrictions
- # as set forth in subdivision (c)(1)(ii) of the Rights in Technical Data
- # and Computer Software clause at DFARS 252.227-7013, and/or in similar or
- # successor clauses in the FAR, DOD or NASA FAR Supplement. Unpublished -
- # rights reserved under the Copyright Laws of the United States.
- #
- # $Id: Tasks.connect-start.cgi,v 1.41 1997/06/24 22:20:54 shotes Exp $
-
- require "/usr/OnRamp/lib/OnRamp.pm";
- require "/usr/OnRamp/lib/java.pm";
-
- $myname = "Tasks.connect-start.cgi";
- $temp = "task.tmp";
- $data = "task.dummy";
- $action = "Tasks.connect-start.cgi?loop";
-
- $it = "<td align=right>";
- $ni = "</td>";
- $bo = "<td><font size=5><i>";
- $nb = "</i></font></td>";
-
- @find_vals = ('provider','nameserver','domain');
-
- &get_fields;
- &get_js;
-
- # clear temporary file for initial call
- if (!$ARGV[0]) {
- open(OUT,"> $temp");
- close(OUT);
-
- open(IN,"/usr/bsd/hostname | ");
- $host = <IN>; chomp($host);
- if ($host) { ($host, $dum1, $dum2, $dum3, @dum4)
- = gethostbyname($host); }
- $host =~ /^\w+\.([\w\.]+)$/;
- $vals{'domain'} = $1;
- } elsif ($ARGV[0] eq 'loop') { %vals = %fld; }
- else { &readValues; }
-
- if ($ARGV[0] eq loop) {
- &errorCheck;
- &writeFile;
-
- $go = "/tasks/connect-second.cgi?st";
- # printf("Location: %s%c%c",$go,10,10);
- print "Content-type: text/html\n\n";
- print "<HTML><HEAD>";
- print "<META HTTP-EQUIV=\"refresh\" CONTENT=\"0; URL=$go\">";
- print "</HEAD><BODY></BODY></HTML>";
- exit 0;
- }
-
- &generic;
-
- sub readValues {
- open(IN,"< $temp");
- while(<IN>) {
- @items = split(/=/);
- foreach $arg (@find_vals) {
- if ($arg eq $items[0]) {
- if ($items[1] ne "\n") {
- $vals{$arg} = $items[1];
- chop $vals{$arg};
- }
- }
- }
- }
- close(IN);
- }
-
- sub errorCheck {
- &error("The domain name is required.") if !$fld{'domain'};
- &error("Provider IP address is required.") if !$fld{'provider'};
- &error("Nameserver IP address is required.") if !$fld{'nameserver'};
- &error("The domain name is invalid.") if &check_hostname($fld{'domain'});
- &error("Provider IP address is invalid.") if &check_ipaddr($fld{'provider'});
- &error("Nameserver IP address is invalid.") if &check_ipaddr($fld{'nameserver'});
- }
-
- sub error {
- $error = $_[0];
- &generic;
- exit 0;
- }
-
- sub writeFile {
- undef %terms;
- open(IN,"< $temp");
- while(<IN>) {
- @items = split(/=/);
- chop $items[1];
- $terms{$items[0]} = $items[1];
- }
- close(IN);
- foreach $arg (@find_vals) {
- $terms{$arg} = $fld{$arg};
- }
- open(OUT,"> $temp");
- foreach $arg (keys(%terms)) {
- print OUT "$arg=$terms{$arg}\n";
- }
- close(OUT);
- }
-
- sub get_js {
-
- $js =
- "$js_error_box
- $js_ip
- $js_hostname
- function Next() {
- form = document.page1;
- if (!testHostname(form.domain, form.domain.value, \"domain name\", 0)) return;
- if (!testIP(form.provider,\"provider\")) return;
- if (!testIP(form.nameserver,\"nameserver\")) return;
- setTimeout('form.submit()',0);
- return;
- }
- function testIP(Ctrl,what) {
- if (Ctrl.value == \"\") { errorBox (Ctrl, \"The \" + what + \" IP address is required.\"); return (false); }
- if (! testIPaddress(Ctrl.value,false)) {
- errorBox(Ctrl, \"The \" + what + \" IP address is invalid.\");
- return (false);
- }
- return (true);
- }";
-
- }
-
- sub generic {
- print "Content-type: text/html\n\n";
- print "<html><head><title>Connect to the Internet</title>\n";
- print "<script language=\"JavaScript\">\n<!--\n";
-
- print $js;
-
- print "//-->\n";
- print "</script></head>\n\n";
-
- print "<body bgcolor=\'c7ded4\' background=/tasks/connect-task.bg.gif>\n";
- if ($error) {
- print "<font size=4 color=ff0000><b>Error: </b>$error<br></font>";
- }
- print "<i>$message</i>";
-
- print "<table width=100%>",
- "<tr><th align=left><h1>Connect to the Internet</h1></th>\n",
- "<th align=right><a href=\"/newsplash.shtml\">",
- "<img height=55 width=57 border=0 src=/tasks/home.gif></a>\n",
- " <a href=\"Tasks.shtml\">",
- "<img height=55 width=57 border=0 src=/tasks/back.gif></a>",
- "</tr></table>\n";
-
- printf("\n<form name=\"page1\" action=\"%s\" method=post>\n", $action);
-
- print "<center><table width=620>\n";
-
- print "<tr><td colspan=2 align=left>
- To connect your organization to the Internet, you must provide
- information about your site and about the hosts and equipment
- that will be used for Internet connections. Much of this information
- was supplied by your Internet service provider (ISP) when you subscribed
- to their service. Be sure that this information is available when you
- complete the setup form that follows.<br><br>
-
- <b>Note:</b> Optional subsystem <i>eoe.sw.ppp</i> is required
- to connect to the Internet via ppp.<br><br></td></tr>\n\n";
-
- print "<tr>$bo Domain name for your organization: $nb \n$it",
- &text("domain",$vals{'domain'},15),
- "$ni </tr>\n";
- print " <tr><td colspan=2>
- In Internet parlance, a domain is a collection of hosts that are
- managed as one entity. The domain name of your organization is the
- name by which it will be known on the Internet. Enter your organization's
- domain name in this field (supplied by your ISP).
- <br><br></td></tr><tr><td> </td></tr>\n\n";
-
- print "<tr>$bo IP address of your ISP host: $nb \n$it",
- &text("provider",$vals{'provider'},15),
- "$ni </tr>\n";
- print " <tr><td colspan=2>
- The Internet Gateway connects to a host at your ISP site to gain access
- to other locations on the Internet. The IP address of the ISP host is needed
- to establish this connection. Enter the ISP host address of in this field
- (supplied by your ISP). Your entry will look like this example: 191.65.43.8.
- <br><br></td></tr><tr><td> </td></tr>\n\n";
-
- print "<tr>$bo IP address of the remote name server: $nb \n$it",
- &text("nameserver",$vals{'nameserver'},15),
- "$ni </tr>\n";
- print " <tr><td colspan=2>
- The Internet Gateway translates hostnames to IP addresses for hosts in
- your domain. But for hosts outside your domain, it forwards translation
- requests to a remote name server. Enter the IP address of the remote
- name server in this field (issued by your ISP). Your entry will look
- like this example: 191.64.43.8. </td></tr><tr><td> </td></tr>\n";
- print "</table></center>\n";
-
- print '<MAP NAME="js_map">',
- ' <AREA SHAPE="rect" COORDS="0,0,59,52" HREF="javascript:Next()"
- onMouseOver="window.status=\'\';return true">',
- '</MAP>';
- print "\n";
- print '<IMG SRC="/tasks/rightarrow.gif" BORDER=0 USEMAP="#js_map" align="right">';
-
- print "\n</form></body></html>";
- }
-