home *** CD-ROM | disk | FTP | other *** search
/ Online Praxis 1998 March / Image.iso / CD-ROM / NETSCAPE / CCK / INSTBLDR.Z / asw.jar / globals2.js < prev    next >
Encoding:
Text File  |  1998-02-27  |  29.2 KB  |  800 lines

  1. <!--  to hide script contents from old browsers
  2.  
  3.  
  4.  
  5. compromisePrincipals();
  6.  
  7.  
  8.  
  9. function configureNewAccount()
  10. {
  11.     netscape.security.PrivilegeManager.enablePrivilege("AccountSetup");
  12.  
  13.     var theFile = getAcctSetupFilename(self);
  14.     var intlFlag = GetNameValuePair(theFile,"Mode Selection","IntlMode");
  15.     intlFlag = intlFlag.toLowerCase();
  16.  
  17.  
  18.     var theScript = findVariable("LOGIN_SCRIPT");
  19.  
  20.  
  21.     // determine outside line access string
  22.     
  23.     var outsideLineAccessStr = "";
  24.     if (document.vars.prefixData.value != "")    {
  25.         outsideLineAccessStr = document.vars.prefixData.value;
  26.         x = outsideLineAccessStr.indexOf(",");
  27.         if (x<0)    outsideLineAccessStr = outsideLineAccessStr + ",";
  28.         }
  29.  
  30.     var dialAsLongDistance = findVariable("DIAL_AS_LONG_DISTANCE");
  31.     if (dialAsLongDistance != null && dialAsLongDistance!="")    {
  32.         var dialAsLongDistanceFlag = (dialAsLongDistance=="NO") ? "FALSE":"TRUE";
  33.         var dialAreaCode = findVariable("DIAL_AREA_CODE");
  34.         var dialAreaCodeFlag = "FALSE";
  35.         if (dialAreaCode != null && dialAreaCode != "")    {
  36.             dialAreaCodeFlag = (dialAreaCode == "NO") ? "FALSE":"TRUE";
  37.             }
  38.         }
  39.     else if (intlFlag == "yes")    {
  40.         var dialAsLongDistanceFlag = "FALSE";
  41.         var dialAreaCodeFlag = "FALSE";
  42.         }
  43.     else    {
  44.         var dialAsLongDistanceFlag = "TRUE";
  45.         var dialAreaCodeFlag = "TRUE";
  46.  
  47.         var ispAreaCode="";
  48.         var ispPhoneNum = findVariable("PHONE_NUM");
  49.         if (ispPhoneNum != null && ispPhoneNum!="")    {
  50.             var x=ispPhoneNum.indexOf("(");
  51.             if (x>=0)    {
  52.                 var y=ispPhoneNum.indexOf(")",x+1);
  53.                 ispAreaCode=ispPhoneNum.substring(x+1,y);
  54.                 }
  55.             }
  56.         if (ispAreaCode == document.vars.modemAreaCode.value)    {
  57.             dialAsLongDistanceFlag="FALSE";
  58.             dialAreaCodeFlag = "FALSE";
  59.             }
  60.         }
  61.  
  62.  
  63.     // determine new profile name (used for Account in dialer & profile name)
  64.  
  65.     var    newProfileName = findVariable("LOGIN");
  66.     if (newProfileName=="")    {
  67.         newProfileName = document.vars.first.value;
  68.         if (document.vars.last.value != "")    {
  69.             newProfileName = newProfileName + " " + document.vars.last.value;
  70.             }
  71.         }
  72.     if (newProfileName!="")    newProfileName = newProfileName + "'s";
  73.     if (findVariable("SITE_NAME") != "")    {
  74.         newProfileName = newProfileName + " " + findVariable("SITE_NAME");
  75.         }
  76.     newProfileName = newProfileName + " Account";
  77.     if (newProfileName.length > 240)    newProfileName=newProfileName.substring(0,240);
  78.  
  79.  
  80.     // platform check
  81.  
  82.     var thePlatform = new String(navigator.userAgent);
  83.     var x=thePlatform.indexOf("(")+1;
  84.     var y=thePlatform.indexOf(";",x+1);
  85.     thePlatform=thePlatform.substring(x,y);
  86.  
  87.     if (thePlatform == "Win16")    {
  88.         if (newProfileName.length > 40)    newProfileName=newProfileName.substring(0,40);
  89.         }
  90.  
  91.     
  92.     // On Win32 platforms, check if newProfileName contains any invalid characters, such as '/'
  93.     // On Mac, disallow invalid characters such as ':'
  94.     
  95.     if ((thePlatform == "WinNT") || (thePlatform == "Win95")) {
  96.         var x=0;
  97.         x = newProfileName.indexOf('/');
  98.         while ((x >= 0) && (newProfileName.length != 0)) {
  99.             newProfileName = newProfileName.substring(x+1, newProfileName.length);            
  100.             x = newProfileName.indexOf('/');
  101.             }
  102.         x = newProfileName.indexOf('\\');
  103.         while ((x >= 0) && (newProfileName.length != 0)) {
  104.             newProfileName = newProfileName.substring(x+1, newProfileName.length);            
  105.             x = newProfileName.indexOf('\\');
  106.             }
  107.         x = newProfileName.indexOf(':');
  108.         while ((x >= 0) && (newProfileName.length != 0)) {
  109.             newProfileName = newProfileName.substring(x+1, newProfileName.length);            
  110.             x = newProfileName.indexOf(':');
  111.             }
  112.         x = newProfileName.indexOf('\"');
  113.         while ((x >= 0) && (newProfileName.length != 0)) {
  114.             newProfileName = newProfileName.substring(x+1, newProfileName.length);            
  115.             x = newProfileName.indexOf('\"');
  116.             }
  117.         x = newProfileName.indexOf('?');
  118.         while ((x >= 0) && (newProfileName.length != 0)) {
  119.             newProfileName = newProfileName.substring(x+1, newProfileName.length);            
  120.             x = newProfileName.indexOf('?');
  121.             }
  122.         x = newProfileName.indexOf('<');
  123.         while ((x >= 0) && (newProfileName.length != 0)) {
  124.             newProfileName = newProfileName.substring(x+1, newProfileName.length);            
  125.             x = newProfileName.indexOf('<');
  126.             }
  127.         x = newProfileName.indexOf('>');
  128.         while ((x >= 0) && (newProfileName.length != 0)) {
  129.             newProfileName = newProfileName.substring(x+1, newProfileName.length);            
  130.             x = newProfileName.indexOf('>');
  131.             }
  132.         x = newProfileName.indexOf('|');
  133.         while ((x >= 0) && (newProfileName.length != 0)) {
  134.             newProfileName = newProfileName.substring(x+1, newProfileName.length);            
  135.             x = newProfileName.indexOf('|');
  136.             }
  137.         x = newProfileName.indexOf('&');
  138.         while ((x >= 0) && (newProfileName.length != 0)) {
  139.             newProfileName = newProfileName.substring(0, x) + newProfileName.substring(x+1, newProfileName.length);
  140.             x = newProfileName.indexOf('&');
  141.             }
  142.         }
  143.     else if (thePlatform == "Macintosh")    {
  144.         var x=0;
  145.         x = newProfileName.indexOf(':');
  146.         while ((x >= 0) && (newProfileName.length != 0)) {
  147.             newProfileName = newProfileName.substring(x+1, newProfileName.length);            
  148.             x = newProfileName.indexOf(':');
  149.             }
  150.         }
  151.     else if (thePlatform == "Win16") {
  152.         var x=0;
  153.         x = newProfileName.indexOf('(');
  154.         while ((x >= 0) && (newProfileName.length != 0)) {
  155.             newProfileName = newProfileName.substring(0, x) + newProfileName.substring(x+1, newProfileName.length);
  156.             x = newProfileName.indexOf('(');
  157.             }
  158.         x = newProfileName.indexOf(')');
  159.         while ((x >= 0) && (newProfileName.length != 0)) {
  160.             newProfileName = newProfileName.substring(0, x) + newProfileName.substring(x+1, newProfileName.length);
  161.             x = newProfileName.indexOf(')');
  162.             }
  163.         }
  164.  
  165.  
  166.     // configure dialer for new account 
  167.  
  168.     dialerData = document.setupPlugin.newStringArray(24);        // increment this # as new dialer strings are added
  169.     dialerData[0]  = "FileName=" + findVariable("SITE_FILE");
  170.     dialerData[1]  = "AccountName=" + newProfileName;
  171.     dialerData[2]  = "ISPPhoneNum=" + findVariable("PHONE_NUM");
  172.     dialerData[3]  = "LoginName=" + findVariable("LOGIN");
  173.     dialerData[4]  = "Password=" + findVariable("PASSWORD");
  174.     dialerData[5]  = "DNSAddress=" + findVariable("DNS_ADDR");
  175.     dialerData[6]  = "DNSAddress2=" + findVariable("DNS_ADDR_2");
  176.     dialerData[7]  = "DomainName=" + findVariable("DOMAIN_NAME");
  177.     dialerData[8]  = "IntlMode=" + ((intlFlag=="yes") ? "TRUE":"FALSE");
  178.     dialerData[9]  = "DialOnDemand=TRUE";
  179.     dialerData[10] = "ModemName=" + document.vars.modem.value;
  180.     dialerData[11] = "ModemType=" + document.setupPlugin.GetModemType(document.vars.modem.value);
  181.     dialerData[12] = "DialType=" + document.vars.dialMethod.value;
  182.     dialerData[13] = "OutsideLineAccess=" + outsideLineAccessStr;
  183.     dialerData[14] = "DisableCallWaiting=" + ((parent.parent.globals.document.vars.cwData.value != "") ? "TRUE":"FALSE");
  184.     dialerData[15] = "DisableCallWaitingCode=" + parent.parent.globals.document.vars.cwData.value;
  185.     dialerData[16] = "DialAsLongDistance=" + dialAsLongDistanceFlag;
  186.     dialerData[17] = "DialAreaCode=" + dialAreaCodeFlag;
  187.     dialerData[18] = "ScriptEnabled=" + ((theScript==null || theScript=="") ? "FALSE":"TRUE");
  188.     dialerData[19] = "Script=" + theScript;
  189.     dialerData[20] = "AutoSend=" + findVariable("AUTO_SEND");
  190.     dialerData[21] = "Location=Home";
  191.     dialerData[22] = "DisconnectTime=" + GetNameValuePair(theFile,"Mode Selection","Dialer_Disconnect_After");
  192.     dialerData[23] = "Path=New";
  193.  
  194.  
  195.     // write out dialer data to Java Console
  196.  
  197.     debug("\nNew Account for ISP: " + findVariable("SITE_NAME"));
  198.     var numElements = dialerData.length;
  199.     for (var x=0; x<numElements; x++)    {
  200.         debug("        " + x + ": " + dialerData[x]);
  201.         }
  202.  
  203.     parent.parent.globals.document.setupPlugin.DialerConfig(dialerData,false);
  204.  
  205.  
  206.     // configure desktop (Windows)
  207.  
  208.     parent.parent.globals.document.setupPlugin.DesktopConfig(newProfileName, null, theFile);
  209.  
  210.  
  211.     // set up Navigator preferences
  212.  
  213.     var userName = document.vars.first.value;
  214.     if (document.vars.last.value != "")    {
  215.         userName = userName + " " + document.vars.last.value;
  216.         }
  217.  
  218.     navigator.preference("network.hosts.smtp_server",        findVariable("SMTP_HOST"));
  219.     navigator.preference("network.hosts.nntp_server",        findVariable("NNTP_HOST"));
  220.  
  221.     var mailID=""
  222.     var mailAccount = findVariable("IMAP_HOST");
  223.     if (mailAccount == "")    {
  224.         mailAccount = findVariable("POP_SERVER");
  225.         }
  226.     var mailServer="";
  227.  
  228.     x = mailAccount.indexOf("@");
  229.     if (x>=0)    {
  230.         mailID=mailAccount.substring(0,x);
  231.         mailServer=mailAccount.substring(x+1,mailAccount.length);
  232.         }
  233.     else    {
  234.         mailID=mailAccount;
  235.         mailServer=findVariable("DOMAIN_NAME");
  236.         if (mailServer != "")    {
  237.             mailAccount = mailID + "@" + mailServer;
  238.             }
  239.         }
  240.  
  241.     navigator.preference("network.hosts.pop_server",    mailServer);
  242.     if (findVariable("IMAP_HOST") != "")    {
  243.         navigator.preference("mail.server_type",            1);
  244.         navigator.preference("mail.imap.server_sub_directory",findVariable("IMAP_SERVERPATH"));
  245.         }
  246.     else    {
  247.         navigator.preference("mail.server_type",            0);
  248.         }
  249.  
  250.     navigator.preference("mail.pop_name",                    mailID);
  251.     navigator.preference("mail.identity.organization",        document.vars.company.value);
  252.     navigator.preference("mail.identity.reply_to",            findVariable("EMAIL_ADDR"));
  253.     navigator.preference("mail.identity.username",            userName);
  254.     navigator.preference("mail.identity.useremail",            mailAccount);
  255.  
  256.     navigator.preference("mail.remember_password",    false);
  257.     navigator.preference("mail.pop_password",        "");
  258.     var theMailPassword=findVariable("POP_PASSWORD");
  259.     if (theMailPassword != null && theMailPassword != "")    {
  260.         theMailPassword = parent.parent.globals.document.setupPlugin.EncryptString(theMailPassword);
  261.         if (theMailPassword != null && theMailPassword != "")    {
  262.             navigator.preference("mail.remember_password",    true);
  263.             navigator.preference("mail.pop_password",        theMailPassword);
  264.             }
  265.         }
  266.  
  267.     navigator.preference("editor.author",                    userName);
  268.     navigator.preference("editor.publish_username",            mailID);
  269.     var pushURL = findVariable("PUBLISH_PUSH_URL");
  270.     navigator.preference("editor.publish_location",            pushURL);
  271.     navigator.preference("editor.publish_browse_location",    findVariable("PUBLISH_VIEW_URL"));
  272.  
  273.     navigator.preference("editor.publish_password",            "");
  274.     navigator.preference("editor.publish_save_password",    false);
  275.     if (pushURL != null && pushURL != "")    {
  276.         var thePublishPassword=findVariable("PASSWORD");
  277.         if (thePublishPassword != "")    {
  278.             thePublishPassword = parent.parent.globals.document.setupPlugin.EncryptString(thePublishPassword);
  279.             if (thePublishPassword != null && thePublishPassword != "")    {
  280.                 navigator.preference("editor.publish_save_password",    true);
  281.                 navigator.preference("editor.publish_password",            thePublishPassword);
  282.                 }
  283.             }
  284.         }
  285.  
  286.     if (findVariable("HOME_URL") != "")    {
  287.         navigator.preference("browser.startup.page",        1);                            // 0 blank, 1 homepage, 2 last visited
  288.         navigator.preference("browser.startup.homepage",    findVariable("HOME_URL"));
  289.         }
  290.  
  291.  
  292.     // look for LDAP data
  293.  
  294.     var ldapNum = navigator.preference("ldap_1.number_of_directories");
  295.     if (ldapNum == null || ldapNum == "")    {
  296.         // if # of directories isn't defined, count any existing LDAP entries
  297.         ldapNum=1;
  298.         while(true)    {
  299.             var ldapEntry = navigator.preference("ldap_1.directory" + ldapNum + ".filename");
  300.             if (ldapEntry == null || ldapEntry == "")    break;
  301.             ldapNum = ldapNum + 1;
  302.             }
  303.         }
  304.     ldapNum = 1 + ldapNum;
  305.  
  306.     var ldapEntriesAddedFlag=false;
  307.     var ldapIndex=1;
  308.     while(true)    {
  309.         var ldapURL = findVariable("LDAP_HOST_" + ldapIndex);
  310.         if (ldapURL == null || ldapURL == "")    break;
  311.         
  312.         var secureLDAP = false;
  313.         var    searchBase = "";
  314.         var portNum = 389;
  315.  
  316.         if (ldapURL.indexOf("ldaps://")==0)    {                    // LDAP over SSL
  317.             secureLDAP = true;
  318.             portNum = 636;
  319.             ldapURL = ldapURL.substring(8,ldapURL.length);
  320.             }
  321.         else if (ldapURL.indexOf("ldap://")==0)    {
  322.             ldapURL = ldapURL.substring(7,ldapURL.length);
  323.             }
  324.         var x = ldapURL.indexOf("/");                            // find any search base
  325.         if (x>0)    {
  326.             searchBase = ldapURL.substring(x+1,ldapURL.length);
  327.             ldapURL = ldapURL.substring(0,x);
  328.             }
  329.         x = ldapURL.indexOf(":");                                // find any port number
  330.         if (x>0)    {
  331.             portNumString = ldapURL.substring(x+1,ldapURL.length);
  332.             ldapURL = ldapURL.substring(0,x);
  333.             if (portNumString != "")    {
  334.                 portNum = parseInt(portNumString);
  335.                 }
  336.             }
  337.  
  338.         var ldapDesc = findVariable("LDAP_DESC_" + ldapIndex);
  339.         if (ldapDesc == "")    {
  340.             ldapDesc = ldapURL;
  341.             }
  342.  
  343.         ldapEntriesAddedFlag = true;
  344.         navigator.preference("ldap_1.directory" + ldapNum + ".filename", "");
  345.         navigator.preference("ldap_1.directory" + ldapNum + ".description", ldapDesc);
  346.         navigator.preference("ldap_1.directory" + ldapNum + ".serverName", ldapURL);
  347.         navigator.preference("ldap_1.directory" + ldapNum + ".port", portNum);
  348.         navigator.preference("ldap_1.directory" + ldapNum + ".isSecure", secureLDAP);
  349.         navigator.preference("ldap_1.directory" + ldapNum + ".searchBase", searchBase);
  350.         navigator.preference("ldap_1.directory" + ldapNum + ".searchString", "");
  351.         navigator.preference("ldap_1.directory" + ldapNum + ".dirType", 0);
  352.         navigator.preference("ldap_1.directory" + ldapNum + ".isOffline", false);
  353.         navigator.preference("ldap_1.directory" + ldapNum + ".savePassword", false);
  354.  
  355.         if (document.vars.debugMode.value.toLowerCase() == "yes")    {
  356.             debug("\tLDAP #" + ldapNum + " Desc: " + ldapDesc);
  357.             debug("\tLDAP #" + ldapNum + " serverName: " + ldapURL);
  358.             debug("\tLDAP #" + ldapNum + " port: " + portNum);
  359.             debug("\tLDAP #" + ldapNum + " isSecure: " + secureLDAP);
  360.             debug("\tLDAP #" + ldapNum + " searchBase: " + searchBase);
  361.             }
  362.         
  363.         ldapNum = ldapNum + 1;
  364.         ldapIndex = ldapIndex + 1;
  365.         }
  366.  
  367.     if (ldapEntriesAddedFlag == true)    {
  368.         navigator.preference("ldap_1.number_of_directories", ldapNum);
  369.         }
  370.  
  371.  
  372.     // on Mac, prevent Internet Config from overriding new settings
  373.  
  374.     navigator.preference("browser.mac.use_internet_config", false);
  375.  
  376.  
  377.     var profileDir = document.setupPlugin.GetCurrentProfileDirectory();
  378.     if (profileDir != null && profileDir != "")    {
  379.  
  380.         // write MUC Configuration file
  381.  
  382.         var thePlatform = new String(navigator.userAgent);
  383.         var x=thePlatform.indexOf("(")+1;
  384.         var y=thePlatform.indexOf(";",x+1);
  385.         thePlatform=thePlatform.substring(x,y);
  386.     
  387.         var configFile="";
  388.         if (thePlatform == "Macintosh")    {                // Macintosh support
  389.             configFile = profileDir + "Configuration";
  390.             }
  391.         else    {                                        // Windows support
  392.             configFile = profileDir + "CONFIG.INI";
  393.             }
  394.         
  395.         document.setupPlugin.SetNameValuePair(configFile,"Account", "Account", newProfileName);            // findVariable("SITE_NAME")
  396.         document.setupPlugin.SetNameValuePair(configFile,"Modem", "Modem", document.vars.modem.value);
  397.         document.setupPlugin.SetNameValuePair(configFile,"Location", "Location", "Home");
  398.  
  399.  
  400.         // write out Reggie bookmark file (if one was sent)
  401.         
  402.         var currentBookmarkFilename="";
  403.         var CRLF="";
  404.         if (thePlatform == "Macintosh")    {                // Macintosh support
  405.             currentBookmarkFilename = profileDir + "Bookmarks.html";
  406.             CRLF = "\r";
  407.             }
  408.         else    {                                        // Windows support
  409.             currentBookmarkFilename = profileDir + "BOOKMARK.HTM";
  410.             CRLF = "\r\n";
  411.             }
  412.  
  413.  
  414.         // Mac only: on clean install, core Communicator doesn't copy over Bookmarks.html file from Defaults folder
  415.         // so grab a copy from our Config folder
  416.  
  417.         if (thePlatform == "Macintosh")    {
  418.             var theActiveProfileName = document.setupPlugin.GetCurrentProfileName();
  419.             if (theActiveProfileName != null)    {
  420.                 theActiveProfileName = theActiveProfileName.toUpperCase();
  421.                 if (theActiveProfileName == '911' || theActiveProfileName == 'USER1')    {
  422.                     var theDefaultBookmarkFilename = parent.parent.globals.getConfigFolder(self) + "Bookmarks.html";
  423.                     var theBookmarkData = parent.parent.globals.document.setupPlugin.GetNameValuePair(theDefaultBookmarkFilename,null,null);
  424.                     if (theBookmarkData == null || theBookmarkData == "")    {
  425.                         theDefaultBookmarkFilename = parent.parent.globals.getConfigFolder(self) + "bookmark.htm";
  426.                         theBookmarkData = parent.parent.globals.document.setupPlugin.GetNameValuePair(theDefaultBookmarkFilename,null,null);
  427.                         }
  428.                     if (theBookmarkData != null && theBookmarkData != "")    {
  429.                         parent.parent.globals.document.setupPlugin.SaveTextToFile(currentBookmarkFilename,theBookmarkData,false);
  430.                         }
  431.                     }
  432.                 }
  433.             }
  434.  
  435.  
  436.         var bookmarkData = "" + document.setupPlugin.GetNameValuePair(currentBookmarkFilename,null,null);
  437.         if (bookmarkData != "")    {
  438.             if (bookmarkData.indexOf("<!DOCTYPE NETSCAPE-Bookmark-file-1>") ==0)    {                    // check for valid bookmark file header
  439.  
  440.                 // build new bookmark title
  441.  
  442.                 var titleStr = "Bookmarks";
  443.                 var name = "";
  444.                 if (parent.parent.globals.document.vars.first.value != "" && parent.parent.globals.document.vars.last.value != "")    {
  445.                     name = parent.parent.globals.document.vars.first.value + " " + parent.parent.globals.document.vars.last.value;
  446.                     }
  447.                 else    {
  448.                     name = findVariable("LOGIN");
  449.                     }
  450.                 if (name != "")    titleStr = titleStr + " for " + name;
  451.  
  452.                 // change TITLE section
  453.  
  454.                 var startTitleindex=bookmarkData.indexOf("<TITLE>");
  455.                 var endTitleindex=bookmarkData.indexOf("</TITLE>");
  456.                 if (startTitleindex>0 && endTitleindex>0)    {
  457.                     startTitleindex = startTitleindex + "<TITLE>".length;
  458.                     var bookmarkDataLen = bookmarkData.length;
  459.                     bookmarkData = bookmarkData.substring(0,startTitleindex) + titleStr + bookmarkData.substring(endTitleindex,bookmarkDataLen);
  460.                     }
  461.  
  462.                 // change H1 section
  463.  
  464.                 var startTitleindex=bookmarkData.indexOf("<H1>");
  465.                 var endTitleindex=bookmarkData.indexOf("</H1>");
  466.                 if (startTitleindex>0 && endTitleindex>0)    {
  467.                     startTitleindex = startTitleindex + "<H1>".length;
  468.                     var bookmarkDataLen = bookmarkData.length;
  469.                     bookmarkData = bookmarkData.substring(0,startTitleindex) + titleStr + bookmarkData.substring(endTitleindex,bookmarkDataLen);
  470.                     }
  471.                 }
  472.             }
  473.  
  474.         var regBookmarkData = document.vars.regBookmark.value;
  475.         if (regBookmarkData != null && regBookmarkData != "")    {
  476.             if (regBookmarkData.indexOf("<!DOCTYPE NETSCAPE-Bookmark-file-1>") == 0 )    {                // check for valid bookmark file header
  477.                 var cleanFlag = false;
  478.                 var activeProfileName = document.setupPlugin.GetCurrentProfileName();
  479.                 if (activeProfileName != null)    {
  480.                     activeProfileName = activeProfileName.toUpperCase();
  481.                     if (activeProfileName == '911' || activeProfileName == 'USER1')    {
  482.                         cleanFlag=true;
  483.                         }
  484.                     }
  485.  
  486.                 if (cleanFlag == true)    {                                                                // if magic profile, write out entire new bookmark file
  487.                     bookmarkData = regBookmarkData;
  488.                     }
  489.                 else    {                                                                                // else append onto end of bookmark file
  490.                     var headerStr = "<DL><p>" + CRLF;
  491.                     var startDLindex=regBookmarkData.indexOf(headerStr);
  492.                     if (startDLindex>0)    {
  493.                         startDLindex = startDLindex + headerStr.length;
  494.                         }
  495.                     var lastDLindex = regBookmarkData.lastIndexOf("</DL>");
  496.                     if (startDLindex>0 && startDLindex>0)    {                                            // remove bookmark header/footer data
  497.                         var newBookmarkData = regBookmarkData.substring(startDLindex,lastDLindex);
  498.                         if (newBookmarkData != "")    {
  499.                             if (bookmarkData.indexOf(newBookmarkData) <0)    {
  500.                                 var startDLindex=bookmarkData.indexOf(headerStr);
  501.                                 if (startDLindex>0)    {
  502.                                     startDLindex = startDLindex + headerStr.length;
  503.                                     }
  504.                                 var lastDLindex = bookmarkData.lastIndexOf("</DL>");
  505.                                 if (startDLindex>0 && startDLindex>0)    {                                // merge into current bookmark file
  506.                                     var bookmarkDataLen = bookmarkData.length;
  507.                                     // append new bookmark data to bookmark file
  508.                                     bookmarkData = bookmarkData.substring(0,lastDLindex) + newBookmarkData + bookmarkData.substring(lastDLindex,bookmarkDataLen);
  509.                                     }
  510.                                 }
  511.                             }
  512.                         }
  513.                     }
  514.                 }
  515.             else    {                                                                                    // if invalid bookmark header, discard
  516.                 regBookmarkData = "";
  517.                 }
  518.             }
  519.  
  520.         if (thePlatform == "Win16")    {
  521.             if (bookmarkData.length >= 16000)    {
  522.                 bookmarkData = "";
  523.                 }
  524.             }
  525.  
  526.         if (bookmarkData != "")    {
  527.             document.setupPlugin.SaveTextToFile(currentBookmarkFilename,bookmarkData,false);
  528.             }
  529.  
  530.  
  531.         // append ISP bookmark (if Reggie sends it down) to profile's bookmark file
  532.  
  533.         var ISPurl = findVariable("ISP_URL");
  534.         if (ISPurl != null && ISPurl != "")    {
  535.             bookmarkData = "" + document.setupPlugin.GetNameValuePair(currentBookmarkFilename, null, null);
  536.             if (bookmarkData != null && bookmarkData != "")    {
  537.                 var lastDLindex = bookmarkData.lastIndexOf("</DL>");
  538.                 if (lastDLindex >= 0)    {
  539.                     var newData = bookmarkData.substring(0,lastDLindex);
  540.                     newData = newData + "\t<DT><A HREF=\"" + ISPurl + "\">" + findVariable("SITE_NAME") + "</A>" + CRLF;
  541.                     newData = newData + bookmarkData.substring(lastDLindex,bookmarkData.length);
  542.  
  543.                     if (thePlatform == "Win16")    {
  544.                         if (newData.length >= 16000)    {
  545.                             newData = "";
  546.                             }
  547.                         }
  548.                     if (newData != "")    {
  549.                         document.setupPlugin.SaveTextToFile(currentBookmarkFilename,newData,false);
  550.                         }
  551.                     }
  552.                 }
  553.             }
  554.  
  555.         }
  556.  
  557.  
  558.     // rename profile
  559.     
  560.     if (thePlatform == "Macintosh") {
  561.         if (newProfileName.length > 31)    newProfileName=newProfileName.substring(0,31);
  562.         }
  563.  
  564.     document.setupPlugin.SetCurrentProfileName(newProfileName);
  565.     debug("\nSetting profile name: " + newProfileName);
  566.  
  567.     
  568.     // set the default path to now be the existing path
  569.     
  570.     document.vars.path.value = "Existing Path";
  571. }
  572.  
  573.  
  574.  
  575. function saveAccountInfo(promptFlag)
  576. {
  577.     netscape.security.PrivilegeManager.enablePrivilege("AccountSetup");
  578.  
  579.     var thePlatform = new String(navigator.userAgent);
  580.     var x=thePlatform.indexOf("(")+1;
  581.     var y=thePlatform.indexOf(";",x+1);
  582.     thePlatform=thePlatform.substring(x,y);
  583.  
  584.     var CRLF;
  585.     if (thePlatform == "Macintosh")    {
  586.         CRLF = "\r";
  587.         }
  588.     else    {
  589.         CRLF = "\r\n";
  590.         }
  591.  
  592.     // Determine the current date
  593.  
  594.     var theFile = parent.parent.globals.getAcctSetupFilename(self);
  595.     var savePasswordFlag = parent.parent.globals.GetNameValuePair(theFile,"New Acct Mode","SavePasswords");
  596.  
  597.     var now = new Date();
  598.     theDate = now.getMonth()+1 + "/" + now.getDate() + "/" + (now.getYear()+1900);
  599.     theDate += "  ";
  600.     var theHour = now.getHours();
  601.     var theString = " AM";
  602.     if (theHour >=12)    {
  603.         theHour = theHour-12;
  604.         theString = " PM";
  605.         }
  606.     var theMinute = now.getMinutes();
  607.     if (theMinute < 10)    {
  608.         theMinute="0" + theMinute;
  609.         }
  610.     theDate += theHour + ":" + theMinute + theString;
  611.  
  612.     // Mangle the POP/IMAP server
  613.  
  614.     var mailProtocol = "IMAP";
  615.     var popIMAPServer = findVariable("IMAP_HOST");
  616.     if (popIMAPServer == "")    {
  617.         mailProtocol = "POP";
  618.         popIMAPServer = findVariable("POP_SERVER");
  619.         }
  620.     var atLocation = popIMAPServer.indexOf("@");
  621.     if (atLocation>=0)    {
  622.         popIMAPServer = popIMAPServer.substring(atLocation+1);
  623.         }
  624.  
  625.     // Create the output string to save
  626.  
  627.     var output = "Your Account Information                  " + theDate + CRLF;
  628.        output += "______________________________________________________________" + CRLF + CRLF;
  629.        output += "Name:                                     " + parent.parent.globals.document.vars.first.value + " " + parent.parent.globals.document.vars.last.value + CRLF;
  630.        output += "Provider:                                 " + findVariable("SITE_NAME") + CRLF + CRLF;
  631.  
  632.        output += "Dialup access number:                     " + findVariable("PHONE_NUM") + CRLF + CRLF;
  633.  
  634.        output += "Login name:                               " + findVariable("LOGIN") + CRLF;
  635.  
  636.     if (savePasswordFlag == "yes")    {
  637.        output += "Login password:                           " + findVariable("PASSWORD") + CRLF + CRLF;
  638.         }
  639.  
  640.        output += "Email address:                            " + findVariable("EMAIL_ADDR") + CRLF;
  641.  
  642.     if (savePasswordFlag == "yes")    {
  643.        output += "Email password:                           " + findVariable("POP_PASSWORD") + CRLF + CRLF;
  644.         }
  645.  
  646.        output += "SMTP server:                              " + findVariable("SMTP_HOST") + CRLF;
  647.        
  648.     if (mailProtocol == "IMAP")    {
  649.        output += "IMAP server:                              " + popIMAPServer + CRLF;
  650.        
  651.        var imapDir = findVariable("IMAP_SERVERPATH");
  652.        if (imapDir != "")    {
  653.        output += "IMAP server mailbox path:                 " + imapDir + CRLF;
  654.             }
  655.         }
  656.     else    {
  657.        output += "POP server:                               " + popIMAPServer + CRLF;
  658.         }
  659.        output += "News (NNTP) server:                       " + findVariable("NNTP_HOST") + CRLF + CRLF;
  660.  
  661.        output += "Domain name:                              " + findVariable("DOMAIN_NAME") + CRLF;
  662.        output += "Primary DNS server:                       " + findVariable("DNS_ADDR") + CRLF;
  663.        output += "Secondary DNS server:                     " + findVariable("DNS_ADDR_2") + CRLF + CRLF;
  664.  
  665.        var viewURL = findVariable("PUBLISH_VIEW_URL");
  666.        if (viewURL != "")    {
  667.        output += "Publishing View URL:                      " + viewURL + CRLF;
  668.             }
  669.        var pushURL = findVariable("PUBLISH_PUSH_URL");
  670.        if (pushURL != "")    {
  671.        output += "Publishing Push URL:                      " + pushURL + CRLF;
  672.             }
  673.  
  674.        output += CRLF;
  675.  
  676.        output += "Modem:                                    " + parent.parent.globals.document.vars.modem.value + CRLF + CRLF;
  677.  
  678.        output += "Other information:" + CRLF + CRLF;
  679.        output += "Provider's technical support number:      " + findVariable("ISP_SUPPORT") + CRLF;
  680.  
  681.  
  682.     // determine new profile name (used for Account in dialer & profile name, save info default filename)
  683.  
  684.     var    newProfileName = findVariable("LOGIN");
  685.     if (newProfileName=="")    {
  686.         newProfileName = document.vars.first.value;
  687.         if (document.vars.last.value != "")    {
  688.             newProfileName = newProfileName + " " + document.vars.last.value;
  689.             }
  690.         }
  691.     if (newProfileName!="")    newProfileName = newProfileName + "'s";
  692.     if (findVariable("SITE_NAME") != "")    {
  693.         newProfileName = newProfileName + " " + findVariable("SITE_NAME");
  694.         }
  695.     newProfileName = newProfileName + " Account Info";
  696.  
  697.     if (thePlatform == "Macintosh") {
  698.         if (newProfileName.length > 31)    newProfileName=newProfileName.substring(0,31);
  699.         }
  700.  
  701.     
  702.     // On WIN32 platforms, check if newProfileName contains any invalid characters, such as '/'
  703.     // On Mac, disallow invalid characters such as ':'
  704.  
  705.     if ((thePlatform == "WinNT") || (thePlatform == "Win95")) {
  706.         var x=0;
  707.         x = newProfileName.indexOf('/');
  708.         while ((x >= 0) && (newProfileName.length != 0)) {
  709.             newProfileName = newProfileName.substring(x+1, newProfileName.length);            
  710.             x = newProfileName.indexOf('/');
  711.             }
  712.         x = newProfileName.indexOf('\\');
  713.         while ((x >= 0) && (newProfileName.length != 0)) {
  714.             newProfileName = newProfileName.substring(x+1, newProfileName.length);            
  715.             x = newProfileName.indexOf('\\');
  716.             }
  717.         x = newProfileName.indexOf(':');
  718.         while ((x >= 0) && (newProfileName.length != 0)) {
  719.             newProfileName = newProfileName.substring(x+1, newProfileName.length);            
  720.             x = newProfileName.indexOf(':');
  721.             }
  722.         x = newProfileName.indexOf('\"');
  723.         while ((x >= 0) && (newProfileName.length != 0)) {
  724.             newProfileName = newProfileName.substring(x+1, newProfileName.length);            
  725.             x = newProfileName.indexOf('\"');
  726.             }
  727.         x = newProfileName.indexOf('?');
  728.         while ((x >= 0) && (newProfileName.length != 0)) {
  729.             newProfileName = newProfileName.substring(x+1, newProfileName.length);            
  730.             x = newProfileName.indexOf('?');
  731.             }
  732.         x = newProfileName.indexOf('<');
  733.         while ((x >= 0) && (newProfileName.length != 0)) {
  734.             newProfileName = newProfileName.substring(x+1, newProfileName.length);            
  735.             x = newProfileName.indexOf('<');
  736.             }
  737.         x = newProfileName.indexOf('>');
  738.         while ((x >= 0) && (newProfileName.length != 0)) {
  739.             newProfileName = newProfileName.substring(x+1, newProfileName.length);            
  740.             x = newProfileName.indexOf('>');
  741.             }
  742.         x = newProfileName.indexOf('|');
  743.         while ((x >= 0) && (newProfileName.length != 0)) {
  744.             newProfileName = newProfileName.substring(x+1, newProfileName.length);            
  745.             x = newProfileName.indexOf('|');
  746.             }
  747.         }
  748.     else if (thePlatform == "Macintosh")    {
  749.         var x=0;
  750.         x = newProfileName.indexOf(':');
  751.         while ((x >= 0) && (newProfileName.length != 0)) {
  752.             newProfileName = newProfileName.substring(x+1, newProfileName.length);            
  753.             x = newProfileName.indexOf(':');
  754.             }
  755.         }
  756.     else if (thePlatform == "Win16") {
  757.         var x=0;
  758.         x = newProfileName.indexOf('(');
  759.         while ((x >= 0) && (newProfileName.length != 0)) {
  760.             newProfileName = newProfileName.substring(0, x-1) + newProfileName.substring(x+1, newProfileName.length);
  761.             x = newProfileName.indexOf('(');
  762.             }
  763.         x = newProfileName.indexOf(')');
  764.         while ((x >= 0) && (newProfileName.length != 0)) {
  765.             newProfileName = newProfileName.substring(0, x-1) + newProfileName.substring(x+1, newProfileName.length);
  766.             x = newProfileName.indexOf(')');
  767.             }
  768.         }
  769.  
  770.  
  771.     // create the default filename to save output to
  772. /*
  773.     var defaultFilename = findVariable("SITE_FILE");
  774.     if (defaultFilename != "")    defaultFilename=defaultFilename + " ";
  775.     defaultFilename = defaultFilename + "Account Info";
  776. */
  777.  
  778.     var savedFlag=false;
  779.     if (promptFlag==false)    {
  780.         var profileDir = document.setupPlugin.GetCurrentProfileDirectory();
  781.         if (profileDir != null && profileDir != "")    {
  782.             if (thePlatform == "Macintosh")    {
  783.                 newProfileName = profileDir + "Account Info";
  784.                 }
  785.             else    {
  786.                 newProfileName = profileDir + "ACCTINFO.TXT";
  787.                 }
  788.             savedFlag = parent.parent.globals.document.setupPlugin.SaveTextToFile(newProfileName,output,false);        // defaultFilename
  789.             }
  790.         }
  791.     else    {
  792.         savedFlag = parent.parent.globals.document.setupPlugin.SaveTextToFile(newProfileName,output,true);        // defaultFilename
  793.         }
  794.     return(savedFlag);
  795. }
  796.  
  797.  
  798.  
  799. // end hiding contents from old browsers  -->
  800.