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 / connect-modem.cgi.z / connect-modem.cgi
Encoding:
Text File  |  1997-07-30  |  10.7 KB  |  310 lines

  1. #!/usr/bin/perl5
  2. #
  3. # connect-modem.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: connect-modem.cgi,v 1.34 1997/04/17 23:43:40 shotes Exp $
  21.  
  22. require "/usr/OnRamp/lib/OnRamp.pm";
  23.  
  24. if (!$ARGV[0]) { printf("Location: %s%c%c","/tasks/Tasks.connect-start.cgi",10,10); } 
  25.  
  26. $myname = "connect-modem.cgi";
  27. $temp = "task.tmp";
  28. $action= "connect-modem.cgi?loop";
  29.  
  30. $it = "<td align=right><font size=4>";
  31. $ni = "</font></td>";
  32. $bo = "<td><font size=5><i>";
  33. $nb = "</i></font></td>";
  34.  
  35. @find_vals = ('port','modem_type','speed','phone', 'lname','lpassword');
  36.  
  37. &get_fields;
  38.  
  39. if ($ARGV[0] eq 'loop') { %vals = %fld; }
  40. else { &readValues; }
  41.  
  42. if ($ARGV[0] eq loop) {
  43.     &errorCheck;
  44.     &writeFile;
  45.  
  46.     $go = "/tasks/connect-end.cgi?m";
  47.     #printf("Location: %s%c%c",$go,10,10); 
  48.     print "Content-type: text/html\n\n";
  49.     print "<HTML><HEAD>";
  50.     print "<META HTTP-EQUIV=\"refresh\" CONTENT=\"0; URL=$go\">";
  51.     print "</HEAD><BODY></BODY></HTML>";
  52.     exit 0;
  53. }
  54.  
  55. &generic;
  56.  
  57. sub readValues {
  58.     open(IN,"< $temp");
  59.     while(<IN>) {
  60.         @items = split(/=/);
  61.         foreach $arg (@find_vals) {
  62.             if ($arg eq $items[0]) { 
  63.                 if ($items[1] ne "\n") {
  64.                     $vals{$arg} = $items[1];
  65.                     chop $vals{$arg};
  66.                 }
  67.             }
  68.         }
  69.     }
  70.     close(IN);
  71. }
  72.  
  73. sub errorCheck {
  74.     &error("Phone number required.") if !$fld{'phone'};
  75.     &error("Invalid phone number.") if &check_phone($fld{'phone'});
  76.     &error("Login name required.") if !$fld{'lname'};
  77.     &error("Invalid login name.") if &check_login($fld{'lname'});
  78.     &error("Password required.") if !$fld{'lpassword'};
  79.     &error("Invalid password.") if &check_login($fld{'lpassword'});
  80. }
  81.  
  82. sub error {
  83.     $error = $_[0];
  84.     &generic;
  85.     exit 0;
  86. }
  87.     
  88. sub writeFile {
  89.     $fld{'modem_type'} =~ s/%2B/+/;
  90.     $fld{'modem_type'} =~ s/%26/&/;
  91.     $fld{'phone'} =~ s/\(//g;
  92.     $fld{'phone'} =~ s/\)//g;
  93.     $fld{'phone'} =~ s/\-//g;
  94.     $fld{'phone'} =~ s/\,//g;
  95.     $fld{'phone'} =~ s/ //g;
  96.  
  97.     undef %terms;
  98.     open(IN,"< $temp");
  99.     while(<IN>) {
  100.         @items = split(/=/);
  101.         chop $items[1];
  102.         $terms{$items[0]} = $items[1];
  103.     }
  104.     close(IN);
  105.     foreach $arg (@find_vals) {
  106.         $terms{$arg} = $fld{$arg};
  107.     }
  108.     open(OUT,"> $temp");
  109.     foreach $arg (keys(%terms)) {
  110.         print OUT "$arg=$terms{$arg}\n";
  111.     }
  112.     close(OUT);
  113. }
  114.  
  115. sub generic {
  116.     print "Content-type: text/html\n\n";
  117.     print "<html><head><title>Modem Configuration</title>\n";
  118.     print "<script language=\"JavaScript\">\n<!--\n";
  119.  
  120.     # JavaScript
  121. print "function Next()  {
  122.     form = document.modem;
  123.     if (!testPhone(form)) return;
  124.     if (!testWord(form.lname,\"login name\")) return;
  125.     if (!testWord(form.lpassword,\"login password\")) return;
  126.     setTimeout('form.submit()',0);
  127.     return;
  128. }\n";
  129. print "function Previous()  {
  130.     setTimeout('window.location=\"connect-second.cgi?m\"',0);
  131.     return;
  132. }\n";
  133. print "function testPhone(form) { 
  134.     Ctrl = form.phone;
  135.     if (Ctrl.value == \"\") { errorBox (Ctrl, \"The phone number is required.\"); return (false); } 
  136.     error = testPhoneChars(Ctrl.value);
  137.     if (error == 1) { errorBox (Ctrl, \"The phone number cannot contain spaces.\"); return (false); } 
  138.     if (error == 2) { errorBox (Ctrl, \"The phone number cannot contain \\nletters or punctuation.\"); return (false); } 
  139.     return (true);
  140. }\n";
  141. print "function testWord(Ctrl,what) { 
  142.     if (Ctrl.value == \"\") { errorBox (Ctrl, \"The \" + what + \" is required.\"); return (false); } 
  143.     error = testLoginChars(Ctrl.value);
  144.     if (error == 1) { errorBox (Ctrl, \"The \" + what + \" cannot be more \\nthan 8 characters long.\"); return (false); } 
  145.     if (error == 2) { errorBox (Ctrl, \"The \" + what + \" cannot contain the \" + illegal + \" character.\"); return (false); } 
  146.     if (error == 3) { errorBox (Ctrl, \"The \" + what + \" cannot contain spaces.\"); return (false); } 
  147.     return (true);
  148. }\n";
  149. print "function testPhoneChars(word) {
  150.     for(i = 0; i < word.length; i++) {
  151.         c = word.charAt(i);
  152.         if (c == ' ') return 1;
  153.         if (c != \'(\' && c != \')\' && c != \'-\' && c != \',\') {
  154.             num = parseInt(c);
  155.             if(isNaN(num)) return 2;
  156.         }
  157.     } return 0;
  158. }\n";
  159. print "function testLoginChars(word) {
  160.     if (word.length > 8) return 1;
  161.     loginChars = \"_-\.{}()*!~<>?|[]'&^\$\@\#`\\\";:\\\\/+=,%\";
  162.     for(j = 0; j < loginChars.length; j++) {
  163.         c = loginChars.charAt(j); 
  164.         if (word.indexOf(c, 0) != -1) { illegal = c; return 2; }
  165.     }
  166.     for (c = 0; c < word.length; c++) { if (word.charAt(c) == ' ') return 3; }
  167.     return 0;
  168. }\n";
  169. print "function errorBox (Ctrl, ErrorMessage) {
  170.     alert (ErrorMessage);  Ctrl.focus();  return;
  171. }\n";
  172.  
  173. print "//-->\n";
  174. print "</script></head>\n\n";
  175.  
  176.     print "<body bgcolor=\'c7ded4\' background=/tasks/connect-task.bg.gif>\n";
  177.  
  178.     if ($error) {
  179.         print "<font size=4 color=ff0000><b>Error: </b>$error<br></font>";
  180.     }
  181.     print "<i>$message</i>";
  182.  
  183.     print "<table width=100%>",
  184.           "<tr><th align=left><h1>Modem Configuration</h1></th>\n",
  185.           "<th align=right><a href=\"/newsplash.shtml\">",
  186.           "<img height=55 width=57 border=0 src=/tasks/home.gif></a>\n",
  187.           "  <a href=\"/tasks/Tasks.shtml\">",
  188.           "<img height=55 width=57 border=0 src=/tasks/back.gif></a>",
  189.           "</tr></table>\n";
  190.  
  191.     printf("\n<form name=\"modem\" action=\"%s\" method=post>\n", $action);
  192.     
  193.     print "<center><table width=620>";
  194.  
  195.     print "<tr>$bo Port where your modem is attached: $nb \n$it\n", 
  196.           &select("port",$vals{'port'},"Port 1","Port 2"), 
  197.           "$ni </tr>\n";
  198.     print "    <tr><td colspan=2>
  199.     The Internet Gateway contains two serial ports where you can attach a 
  200.     modem; they are designated as Port 1 and Port 2. In most cases, Port 1 
  201.     is reserved for connecting a display console to the server (described 
  202.     in the <CITE>WebFORCE Internet Gateway Installation Guide</CITE>). 
  203.     However, you can configure either port for the modem connection to your
  204.     Internet service provider if the port is unused. See <EM>IRIX Admin: 
  205.     Peripheral Devices</EM> for instructions on installing your modem.
  206.     </td></tr><tr><td> </td></tr>\n\n";
  207.  
  208.     if (!$vals{'modem_type'}) { $vals{'modem_type'} = 'Hayes smartmodem'; }
  209.     print "<tr>$bo Model of your modem: $nb $it\n", 
  210.           &select("modem_type",$vals{'modem_type'},
  211.           'Rixon',
  212.           'Rixon penril',
  213.           'Rixon ventel',
  214.           'Rixon vadic',
  215.           'Hayes smartmodem',
  216.           'Hayes 2400',
  217.           'Hayes accura',
  218.           'Telebit TB+',
  219.           'Telebit T2000',
  220.           'Telebit T2500',
  221.           'Telebit T1600',
  222.           'Telebit QBlazer',
  223.           'Digicom 9624LE+',
  224.           'Digicom Scout+',
  225.           'ZyXEL U-1496',
  226.           'Intel 14.4EX',
  227.           'Dallas Fax 14.4E',
  228.           'USR Sportster 14.4',
  229.           'USR Courier',
  230.           'AT&T Paradyne',
  231.           'Multitech ZDX'), 
  232.           "$ni </tr>\n";
  233.     print "    <tr><td colspan=2>
  234.     A modem converts the digital communication that a computer issues to an
  235.     analog tone sequence that can be sent over a telephone line to your 
  236.     Internet service provider. Most popular modem models are compatible 
  237.     with the Internet Gateway. Select the name of your modem model from 
  238.     the options menu.
  239.     </td></tr><tr><td> </td></tr>\n\n";
  240.  
  241.     if (!$vals{'speed'}) { $vals{'speed'} = '28800'; }
  242.     print "<tr>$bo Baud rate setting for your modem: $nb $it\n", 
  243.           &select("speed",$vals{'speed'},
  244.           '1200',
  245.           '2400',
  246.           '9600',
  247.           '14400',
  248.           '19200',
  249.           '28800',
  250.           '38400'), 
  251.           "$ni </tr>\n";
  252.     print "    <tr><td colspan=2>
  253.     The baud rate is the speed at which information is transferred between 
  254.     the Internet Gateway and your Internet service provider.  This is 
  255.     usually specified on the modem.
  256.     </td></tr><tr><td> </td></tr>\n\n";
  257.  
  258.     print "</table></center>\n";
  259.     print "<center><table width=620>";
  260.  
  261.     print "<tr>$bo Phone number for your ISP: $nb $it\n", 
  262.           &text("phone",$vals{'phone'},15), 
  263.           "$ni </tr>\n";
  264.     print "    <tr><td colspan=2>
  265.     To connect to the Internet, the Internet Gateway places a call over
  266.     the modem line to a host at the service provider's site. This phone 
  267.     number is required to reach the host, just as a phone number is 
  268.     required for a standard voice call. (Your Internet service provider 
  269.     issues this phone number.) Do not include any punctuation symbols 
  270.     or spaces with the number.
  271.     </td></tr><tr><td> </td></tr>\n\n";
  272.  
  273.     print "<tr>$bo Login name for your account on \nthe ISP host: $nb $it", 
  274.           &text("lname",$vals{'lname'},15), 
  275.           "$ni </tr>\n";
  276.     print "    <tr><td colspan=2>
  277.     The Internet Gateway automatically places a login name in calls to the 
  278.     service provider's host. The service provider host uses the name to 
  279.     associate the call with an authorized subscriber account. (Your Internet 
  280.     service provider issues the login name for your modem account.)
  281.     </td></tr><tr><td> </td></tr>\n\n";
  282.  
  283.     print "<tr>$bo Login password for your account on \nthe ISP host: $nb $it", 
  284.           &text("lpassword",$vals{'lpassword'},15), 
  285.           "$ni </tr>";
  286.     print "    <tr><td colspan=2>
  287.     This is the password on the account into the Internet service provider
  288.     system.  This should have been given to you by your Internet service
  289.     provider.
  290.     </td></tr><tr><td> </td></tr>\n";
  291.     print "</table></center>\n";
  292.  
  293.     print '<MAP NAME="js_map1">',
  294.     '    <AREA SHAPE="rect" COORDS="0,0,59,52" HREF="javascript:Previous()"
  295.     onMouseOver="window.status=\'\';return true">',
  296.     '</MAP>';
  297.     print "\n";
  298.     print '<MAP NAME="js_map2">',
  299.     '    <AREA SHAPE="rect" COORDS="0,0,59,52" HREF="javascript:Next()"
  300.     onMouseOver="window.status=\'\';return true">',
  301.     '</MAP>';
  302.     print "\n";
  303.     print '<IMG SRC="/tasks/rightarrow.gif" BORDER=0 USEMAP="#js_map2" align="right">';
  304.     print "\n";
  305.     print '<IMG SRC="/tasks/leftarrow.gif" BORDER=0 USEMAP="#js_map1" align="right">';
  306.  
  307.     print "\n</form></body></html>";
  308. }
  309.  
  310.