home *** CD-ROM | disk | FTP | other *** search
- #!/usr/bin/perl5
- #
- # connect-modem.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: connect-modem.cgi,v 1.34 1997/04/17 23:43:40 shotes Exp $
-
- require "/usr/OnRamp/lib/OnRamp.pm";
-
- if (!$ARGV[0]) { printf("Location: %s%c%c","/tasks/Tasks.connect-start.cgi",10,10); }
-
- $myname = "connect-modem.cgi";
- $temp = "task.tmp";
- $action= "connect-modem.cgi?loop";
-
- $it = "<td align=right><font size=4>";
- $ni = "</font></td>";
- $bo = "<td><font size=5><i>";
- $nb = "</i></font></td>";
-
- @find_vals = ('port','modem_type','speed','phone', 'lname','lpassword');
-
- &get_fields;
-
- if ($ARGV[0] eq 'loop') { %vals = %fld; }
- else { &readValues; }
-
- if ($ARGV[0] eq loop) {
- &errorCheck;
- &writeFile;
-
- $go = "/tasks/connect-end.cgi?m";
- #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("Phone number required.") if !$fld{'phone'};
- &error("Invalid phone number.") if &check_phone($fld{'phone'});
- &error("Login name required.") if !$fld{'lname'};
- &error("Invalid login name.") if &check_login($fld{'lname'});
- &error("Password required.") if !$fld{'lpassword'};
- &error("Invalid password.") if &check_login($fld{'lpassword'});
- }
-
- sub error {
- $error = $_[0];
- &generic;
- exit 0;
- }
-
- sub writeFile {
- $fld{'modem_type'} =~ s/%2B/+/;
- $fld{'modem_type'} =~ s/%26/&/;
- $fld{'phone'} =~ s/\(//g;
- $fld{'phone'} =~ s/\)//g;
- $fld{'phone'} =~ s/\-//g;
- $fld{'phone'} =~ s/\,//g;
- $fld{'phone'} =~ s/ //g;
-
- 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 generic {
- print "Content-type: text/html\n\n";
- print "<html><head><title>Modem Configuration</title>\n";
- print "<script language=\"JavaScript\">\n<!--\n";
-
- # JavaScript
- print "function Next() {
- form = document.modem;
- if (!testPhone(form)) return;
- if (!testWord(form.lname,\"login name\")) return;
- if (!testWord(form.lpassword,\"login password\")) return;
- setTimeout('form.submit()',0);
- return;
- }\n";
- print "function Previous() {
- setTimeout('window.location=\"connect-second.cgi?m\"',0);
- return;
- }\n";
- print "function testPhone(form) {
- Ctrl = form.phone;
- if (Ctrl.value == \"\") { errorBox (Ctrl, \"The phone number is required.\"); return (false); }
- error = testPhoneChars(Ctrl.value);
- if (error == 1) { errorBox (Ctrl, \"The phone number cannot contain spaces.\"); return (false); }
- if (error == 2) { errorBox (Ctrl, \"The phone number cannot contain \\nletters or punctuation.\"); return (false); }
- return (true);
- }\n";
- print "function testWord(Ctrl,what) {
- if (Ctrl.value == \"\") { errorBox (Ctrl, \"The \" + what + \" is required.\"); return (false); }
- error = testLoginChars(Ctrl.value);
- if (error == 1) { errorBox (Ctrl, \"The \" + what + \" cannot be more \\nthan 8 characters long.\"); return (false); }
- if (error == 2) { errorBox (Ctrl, \"The \" + what + \" cannot contain the \" + illegal + \" character.\"); return (false); }
- if (error == 3) { errorBox (Ctrl, \"The \" + what + \" cannot contain spaces.\"); return (false); }
- return (true);
- }\n";
- print "function testPhoneChars(word) {
- for(i = 0; i < word.length; i++) {
- c = word.charAt(i);
- if (c == ' ') return 1;
- if (c != \'(\' && c != \')\' && c != \'-\' && c != \',\') {
- num = parseInt(c);
- if(isNaN(num)) return 2;
- }
- } return 0;
- }\n";
- print "function testLoginChars(word) {
- if (word.length > 8) return 1;
- loginChars = \"_-\.{}()*!~<>?|[]'&^\$\@\#`\\\";:\\\\/+=,%\";
- for(j = 0; j < loginChars.length; j++) {
- c = loginChars.charAt(j);
- if (word.indexOf(c, 0) != -1) { illegal = c; return 2; }
- }
- for (c = 0; c < word.length; c++) { if (word.charAt(c) == ' ') return 3; }
- return 0;
- }\n";
- print "function errorBox (Ctrl, ErrorMessage) {
- alert (ErrorMessage); Ctrl.focus(); return;
- }\n";
-
- 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>Modem Configuration</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/Tasks.shtml\">",
- "<img height=55 width=57 border=0 src=/tasks/back.gif></a>",
- "</tr></table>\n";
-
- printf("\n<form name=\"modem\" action=\"%s\" method=post>\n", $action);
-
- print "<center><table width=620>";
-
- print "<tr>$bo Port where your modem is attached: $nb \n$it\n",
- &select("port",$vals{'port'},"Port 1","Port 2"),
- "$ni </tr>\n";
- print " <tr><td colspan=2>
- The Internet Gateway contains two serial ports where you can attach a
- modem; they are designated as Port 1 and Port 2. In most cases, Port 1
- is reserved for connecting a display console to the server (described
- in the <CITE>WebFORCE Internet Gateway Installation Guide</CITE>).
- However, you can configure either port for the modem connection to your
- Internet service provider if the port is unused. See <EM>IRIX Admin:
- Peripheral Devices</EM> for instructions on installing your modem.
- </td></tr><tr><td> </td></tr>\n\n";
-
- if (!$vals{'modem_type'}) { $vals{'modem_type'} = 'Hayes smartmodem'; }
- print "<tr>$bo Model of your modem: $nb $it\n",
- &select("modem_type",$vals{'modem_type'},
- 'Rixon',
- 'Rixon penril',
- 'Rixon ventel',
- 'Rixon vadic',
- 'Hayes smartmodem',
- 'Hayes 2400',
- 'Hayes accura',
- 'Telebit TB+',
- 'Telebit T2000',
- 'Telebit T2500',
- 'Telebit T1600',
- 'Telebit QBlazer',
- 'Digicom 9624LE+',
- 'Digicom Scout+',
- 'ZyXEL U-1496',
- 'Intel 14.4EX',
- 'Dallas Fax 14.4E',
- 'USR Sportster 14.4',
- 'USR Courier',
- 'AT&T Paradyne',
- 'Multitech ZDX'),
- "$ni </tr>\n";
- print " <tr><td colspan=2>
- A modem converts the digital communication that a computer issues to an
- analog tone sequence that can be sent over a telephone line to your
- Internet service provider. Most popular modem models are compatible
- with the Internet Gateway. Select the name of your modem model from
- the options menu.
- </td></tr><tr><td> </td></tr>\n\n";
-
- if (!$vals{'speed'}) { $vals{'speed'} = '28800'; }
- print "<tr>$bo Baud rate setting for your modem: $nb $it\n",
- &select("speed",$vals{'speed'},
- '1200',
- '2400',
- '9600',
- '14400',
- '19200',
- '28800',
- '38400'),
- "$ni </tr>\n";
- print " <tr><td colspan=2>
- The baud rate is the speed at which information is transferred between
- the Internet Gateway and your Internet service provider. This is
- usually specified on the modem.
- </td></tr><tr><td> </td></tr>\n\n";
-
- print "</table></center>\n";
- print "<center><table width=620>";
-
- print "<tr>$bo Phone number for your ISP: $nb $it\n",
- &text("phone",$vals{'phone'},15),
- "$ni </tr>\n";
- print " <tr><td colspan=2>
- To connect to the Internet, the Internet Gateway places a call over
- the modem line to a host at the service provider's site. This phone
- number is required to reach the host, just as a phone number is
- required for a standard voice call. (Your Internet service provider
- issues this phone number.) Do not include any punctuation symbols
- or spaces with the number.
- </td></tr><tr><td> </td></tr>\n\n";
-
- print "<tr>$bo Login name for your account on \nthe ISP host: $nb $it",
- &text("lname",$vals{'lname'},15),
- "$ni </tr>\n";
- print " <tr><td colspan=2>
- The Internet Gateway automatically places a login name in calls to the
- service provider's host. The service provider host uses the name to
- associate the call with an authorized subscriber account. (Your Internet
- service provider issues the login name for your modem account.)
- </td></tr><tr><td> </td></tr>\n\n";
-
- print "<tr>$bo Login password for your account on \nthe ISP host: $nb $it",
- &text("lpassword",$vals{'lpassword'},15),
- "$ni </tr>";
- print " <tr><td colspan=2>
- This is the password on the account into the Internet service provider
- system. This should have been given to you by your Internet service
- provider.
- </td></tr><tr><td> </td></tr>\n";
- print "</table></center>\n";
-
- print '<MAP NAME="js_map1">',
- ' <AREA SHAPE="rect" COORDS="0,0,59,52" HREF="javascript:Previous()"
- onMouseOver="window.status=\'\';return true">',
- '</MAP>';
- print "\n";
- print '<MAP NAME="js_map2">',
- ' <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_map2" align="right">';
- print "\n";
- print '<IMG SRC="/tasks/leftarrow.gif" BORDER=0 USEMAP="#js_map1" align="right">';
-
- print "\n</form></body></html>";
- }
-
-