home *** CD-ROM | disk | FTP | other *** search
- ////////////////////////////////////////////////////////////////////////////////////////////
- //
- // PRODUCT: Norton Internet Security/Symantec Desktop Firewall
- //
- // NAME: ruleCreation.js (Javascript file for ruleCreation.HTM)
- //
- // Copyright (c) 2001 by Symantec Corporation. All rights reserved.
- //
- ////////////////////////////////////////////////////////////////////////////////////////////
-
- var CurrPage = "Action";
- var g_appName = "";
- var g_xml = null; // Holds the rule while being modified
-
- returnValue = null;
-
- function Page_OnLoad()
- {
- // Set the title...
- window.title = UserManager.ProductName;
-
- //
- // Special onload section
- //
- IPList_OnLoad();
- PortList_OnLoad();
-
- //
- // Register special handlers
- //
- IPAdd.onclick = IPAdd_OnClick;
- IPRemove.onclick = IPRemove_OnClick;
- PortsAdd.onclick = PortsAdd_OnClick;
- PortsRemove.onclick = PortsRemove_OnClick;
- IPAdapters.onclick = IPAdapters_OnClick;
- }
-
- function ruleTellMeMore()
- {
- TellMeMore("RuleEdit" + CurrPage);
- }
-
- function SetActionText()
- {
- DirectinSetText();
- IPSetText();
- PortSetText();
- LoggingSetText();
- }
-
- function HideAll()
- {
- UIAction.style.display = "none";
- UIDirection.style.display = "none";
- UIIP.style.display = "none";
- UIPorts.style.display = "none";
- UILogging.style.display = "none";
- UITitle.style.display = "none";
- UIFinish.style.display = "none";
- }
-
- function SetPage(Name, Page)
- {
- var Page = null;
- CurrPage = Name;
- HideAll();
-
- //
- // Find the correct page to display
- //
- switch(CurrPage)
- {
- case "Action":
- Page = UIAction;
- break;
- case "Direction":
- Page = UIDirection;
- break;
- case "IP":
- Page = UIIP;
- break;
- case "Ports":
- Page = UIPorts;
- break;
- case "Logging":
- Page = UILogging;
- break;
- case "Title":
- Page = UITitle;
- break;
- case "Finished":
- Page = UIFinish;
- }
-
- if (false)
- {
- //
- // Use this code if you want a fade transition.
- //
- Page.children[0].style.visibility="hidden";
- Page.style.display = "";
- Page.children[0].style.filter="blendTrans(duration=0.20)";
- Page.children[0].filters.blendTrans.apply();
- Page.children[0].style.visibility="visible";
- Page.children[0].filters.blendTrans.play();
- }
- else
- {
- //
- // "Normal" transition with no effects.
- //
- Page.style.display = "";
- }
-
- }
-
- function saveRule()
- {
- //
- // Prepare a working xml doc.
- //
- var xml = new ActiveXObject("Microsoft.XMLDOM");
- xml.documentElement = g_xml.cloneNode(true);
- var xmlTLN = xml.selectSingleNode("Rule");
-
- setXMLNode(xmlTLN, "InUse", "enabled");
- UIActionStore(xmlTLN);
- UIDirectionStore(xmlTLN);
- UIIPStore(xmlTLN);
-
- UIAdapterStore(xmlTLN);
- UIPortsStore(xmlTLN);
-
- setXMLNode(xmlTLN, "Logging", "");
- UILoggingStore(xmlTLN);
- UITitleStore(xmlTLN);
-
- return xml;
- }
-
-
- function init(xml, szRuleType, appName)
- {
- g_appName = appName;
- g_xml = xml;
-
- UIActionLoad(xml);
- UIDirectionLoad(xml);
- UIIPLoad(xml);
- UIAdapterLoad(xml);
- UIPortsLoad(xml);
- UILoggingLoad(xml);
- UITitleLoad(xml);
-
- // don't allow ICMP protocol on application rules
- if (szRuleType == "Application")
- {
- nonappitems.style.visibility="hidden";
- }
-
- SetActionText();
- }
-
- function validateAll()
- {
-
- if (!ActionValidate())
- {
- return("Action");
- }
- if (!DirectionValidate())
- {
- return("Direction");
- }
- if (!IPValidate())
- {
- return("IP");
- }
- if (!ProtocolAndPortValidate())
- {
- return("Ports");
- }
- if (!TitleValidate())
- {
- return("Title");
- }
-
- return null;
- }
-
-
- ////////////////////////////////////////////////////////////////////////////////////
- // Select Rule Action page
- //
-
- function UIActionStore(xml)
- {
- for(nElem = 0; nElem < 3; nElem++)
- {
- if (Action[nElem].checked)
- {
- setXMLNode(xml, "Action", Action[nElem].value.toLowerCase());
- break;
- }
- }
- }
-
- function UIActionLoad(xml)
- {
- nElem = 0;
-
- switch (getElem(xml, "Action").toLowerCase())
- {
- case "permit":
- nElem = 0;
- break;
- case "block":
- nElem = 1;
- break;
- case "monitor":
- nElem = 2;
- break;
- }
-
- Action[nElem].checked = true;
- }
-
-
- function RuleActionHandler()
- {
- SetActionText();
- }
-
- function ActionValidate()
- {
- return true;
- }
-
- ////////////////////////////////////////////////////////////////////////////////////
- // Determine traffic direction page
- //
- function UIDirectionStore(xml)
- {
- setXMLNode(xml, "Direction", getDirection());
- }
-
- function UIDirectionLoad(xml)
- {
- nElem = 0;
-
- switch (getElem(xml, "Direction").toLowerCase())
- {
- case "out":
- nElem = 0;
- break;
- case "in":
- nElem = 1;
- break;
- case "in-out":
- nElem = 2;
- break;
- }
-
- Direction[nElem].checked = true;
- }
-
- function getDirection()
- {
- for(nElem = 0; nElem < 3; nElem++)
- if (Direction[nElem].checked)
- return Direction[nElem].value.toLowerCase();
- }
-
- function DirectinSetText()
- {
- DirPermitRule.style.display = "none";
- DirBlockRule.style.display = "none";
- DirMonitorRule.style.display = "none";
-
- if (Action[0].checked)
- DirPermitRule.style.display = "";
-
- if (Action[1].checked)
- DirBlockRule.style.display = "";
-
- if (Action[2].checked)
- DirMonitorRule.style.display = "";
- }
-
- function DirectionValidate()
- {
- return true;
- }
-
- ////////////////////////////////////////////////////////////////////////////////////
- // Remote Sites/Zones to Block page
- //
-
- var xmlIPList = new ActiveXObject("Microsoft.XMLDOM");
- var xmlAdapterList = new ActiveXObject("Microsoft.XMLDOM");
-
- xmlIPList.loadXML("<RemoteAddresses/>");
- xmlAdapterList.loadXML("<LocalAddresses/>");
-
- var currentActionState = null;
-
- function IPList_OnClick()
- {
- // Enable the modify/delete buttons
- EnableButton(IPRemove,true);
- }
-
- function IPCtlsEnabled(enable)
- {
-
- EnableButton(IPAdd,enable);
-
- //
- // Only allow this button to be disabled. Be sure to remove
- // selection too.
- //
- if (!enable)
- {
- EnableButton(IPRemove,enable);
- IPList.SetCurSel(-1);
- }
-
- //
- // Enable radio buttons appropriately.
- //
- Addresses[0].checked = !enable;
- Addresses[1].checked = enable;
- }
-
- function UIIPStore(xml)
- {
- var node = xml.selectSingleNode("RemoteAddresses");
- if (null != node)
- node.parentNode.removeChild(node);
- //
- // If the user didn't narrow this down, get out now. The firewall
- // will default to all when no IP addresses are specified.
- //
- if (Addresses[0].checked)
- return;
-
- //
- // Save data.
- //
- var nodes = xmlIPList.selectNodes("(Address|NamedAddress|AddressRange|MaskedAddress|ZoneName)");
- if (nodes.length > 0)
- {
- var node = getDoc(xml).createElement("RemoteAddresses");
- for (var nElem = 0; nodes.length > nElem; nElem++)
- node.appendChild(nodes[nElem].cloneNode(true));
- xml.appendChild(node);
- }
- }
-
- function UIAdapterStore(xml)
- {
- node = xml.selectSingleNode("LocalAddresses");
- if (null != node)
- node.parentNode.removeChild(node);
- //
- // Save data.
- //
- var nodes = xmlAdapterList.selectNodes("(Address|NamedAddress|AddressRange|MaskedAddress|ZoneName)");
- if (nodes.length > 0)
- {
- var node = getDoc(xml).createElement("LocalAddresses");
- for (var nElem = 0; nodes.length > nElem; nElem++)
- node.appendChild(nodes[nElem].cloneNode(true));
- xml.appendChild(node);
- }
- }
-
- function UIIPLoad(xml)
- {
- IPList_OnLoad();
-
- //
- // Check to see if any addresses were specified.
- //
- var temp = xml.selectSingleNode("RemoteAddresses");
-
- if (null == temp)
- {
- temp = xml.ownerDocument.createElement("RemoteAddresses");
- xml.appendChild(temp);
- }
-
- xmlIPList = temp;
- refreshIPList();
- }
-
- function UIAdapterLoad(xml)
- {
- //
- // Check to see if any addresses were specified.
- //
- var temp = xml.selectSingleNode("LocalAddresses");
-
- if (null == temp)
- {
- temp = xml.ownerDocument.createElement("LocalAddresses");
- xml.appendChild(temp);
- }
-
- xmlAdapterList = temp;
- }
-
- function refreshIPList()
- {
- //
- // Reset the list control
- //
- IPList.DeleteAllRows();
- IPList.SetColumnCount(2);
-
- var addressNodeList = xmlIPList.selectNodes("(Address|NamedAddress|AddressRange|MaskedAddress|ZoneName)");
- var ChildCount = 0;
- var bEnableList = false;
-
- for(ChildCount = 0; ChildCount < addressNodeList.length; ChildCount++)
- {
- var addressChildNode = addressNodeList.item(ChildCount);
-
- if(stricmp(addressChildNode.nodeName, "MaskedAddress") == 0)
- {
- bEnableList = true;
- var chunks = addressChildNode.nodeTypedValue.split(":");
- var text = StrID("IP") + ": " + chunks[0] + "<BR>" + StrID("Mask") + ": " + chunks[1];
-
- pRow = IPList.InsertRow(-1);
- IPList.SetCellTextPtr(pRow, 0, StrID("NetworkAddress"));
- IPList.SetCellTextPtr(pRow, 1, text);
- }
- else if(stricmp(addressChildNode.nodeName, "AddressRange") == 0)
- {
- bEnableList = true;
- var chunks = addressChildNode.nodeTypedValue.split(":");
- var text = StrID("From") + ": " + chunks[0] + "<BR>" + StrID("To") + ": " + chunks[1];
-
- pRow = IPList.InsertRow(-1);
- IPList.SetCellTextPtr(pRow, 0, StrID("AddressRange"));
- IPList.SetCellTextPtr(pRow, 1, text);
- }
- else if(stricmp(addressChildNode.nodeName, "NamedAddress") == 0)
- {
- bEnableList = true;
- var text = StrID("Name") + ": " + addressChildNode.nodeTypedValue;
-
- pRow = IPList.InsertRow(-1);
- IPList.SetCellTextPtr(pRow, 0, StrID("SingleAddress"));
- IPList.SetCellTextPtr(pRow, 1, text);
- }
- else if(stricmp(addressChildNode.nodeName, "Address") == 0)
- {
- bEnableList = true;
- var text = StrID("IP") + ": " + addressChildNode.nodeTypedValue;
-
- pRow = IPList.InsertRow(-1);
- IPList.SetCellTextPtr(pRow, 0, StrID("SingleAddress"));
- IPList.SetCellTextPtr(pRow, 1, text);
- }
- }
-
- IPCtlsEnabled(bEnableList);
- }
-
- function IPAdd_OnClick()
- {
- var xmlOut = webWnd.showModalDialog('res://fwui.dll/IP-Popup.htm', 450, 330, currentActionState);
- if (null != xmlOut)
- {
- var nodes = xmlOut.selectNodes("/*/*");
- for (var nElem = 0; nodes.length > nElem; nElem++)
- {
- var appendTo = xmlIPList.selectSingleNode(".");
- if (null == xmlIPList.ownerDocument)
- appendTo = xmlIPList.selectSingleNode("*");
- appendTo.appendChild(nodes[nElem].cloneNode(true));
-
- }
- refreshIPList();
- IPRemove.disabled = true;
- }
- }
-
- function IPRemove_OnClick()
- {
- var nSel = IPList.GetCurSel();
- var nodes = xmlIPList.selectNodes("(Address|NamedAddress|AddressRange|MaskedAddress)");
- if (nodes.length <= nSel)
- {
- IPList.SetCurSel(-1);
- return;
- }
- var nodeRemove = nodes[nSel];
- nodeRemove.parentNode.removeChild(nodeRemove);
- refreshIPList();
-
- if (IPList.GetRowCount() <= nSel)
- nSel = IPList.GetRowCount()-1;
- IPList.SetCurSel(nSel);
- }
-
- function IPList_OnLoad()
- {
- IPList.SetTableClass("ListBoxClass");
- IPList.OnClick = IPList_OnClick;
- }
-
- function IPSetText()
- {
- IPPermitRule.style.display = "none";
- IPBlockRule.style.display = "none";
- IPMonitorRule.style.display = "none";
-
- if (Action[0].checked)
- {
- IPPermitRule.style.display = "";
- currentActionState = "permit";
- }
-
- if (Action[1].checked)
- {
- IPBlockRule.style.display = "";
- currentActionState = "block";
- }
-
- if (Action[2].checked)
- {
- IPMonitorRule.style.display = "";
- currentActionState = "monitor";
- }
- }
-
- function IPValidate()
- {
- if (Addresses[1].checked && IPList.GetRowCount() == 0)
- {
- webWind.MsgBox2(StrID("IPListError"), UserManager.AppTitle);
- return false;
- }
-
-
- return true;
- }
-
-
- ////////////////////////////////////////////////////////////////////////////////////
- // Ports to Block page
- //
-
- var currentProtocol = 2;
-
- var xmlLocalPorts = null;
- var xmlRemotePorts = null;
-
- function PortCtlsEnabled(enable)
- {
- var sVal = "";
- if (!enable)
- sVal = "yes";
- // PortsWebBrowsing.disabled = sVal;
- // PortsEmail.disabled = sVal;
- EnableButton(PortsAdd,enable);
-
- //
- // Only allow this button to be disabled. Be sure to remove
- // selection too.
- //
- if (!enable)
- {
- EnableButton(PortsRemove,enable);
- PortList.SetCurSel(-1);
- }
-
- PortsSel[0].checked = !enable;
- PortsSel[1].checked = enable;
- }
-
- function portList_OnClick()
- {
- //
- // Enable the Remove button.
- //
- EnableButton(PortsRemove,true);
- }
-
- function UIPortsStore(xml)
- {
- var node = null;
- var nodes = null;
- //
- // Store protocol
- //
- node = xml.selectSingleNode("Protocol");
- if (null != node)
- node.parentNode.removeChild(node);
- node = xml.selectSingleNode("LocalPorts");
- if (null != node)
- node.parentNode.removeChild(node);
- node = xml.selectSingleNode("RemotePorts");
- if (null != node)
- node.parentNode.removeChild(node);
-
- node = getDoc(xml).createElement("Protocol");
- node.text = SelProtocol[currentProtocol].value.toLowerCase();
- xml.appendChild(node);
-
- //
- // If the user specify any ports, get out now. The firewall
- // will default to all ports when no ports are specified.
- //
- if (PortsSel[0].checked)
- return;
-
- nodes = xmlLocalPorts.selectNodes("(Port|PortRange)");
- if (nodes.length > 0)
- {
- var portsNode = getDoc(xml).createElement("LocalPorts");
- for (var nElem = 0; nodes.length > nElem; nElem++)
- portsNode.appendChild(nodes[nElem].cloneNode(true));
- xml.appendChild(portsNode);
- }
-
-
- nodes = xmlRemotePorts.selectNodes("(Port|PortRange)");
- if (nodes.length > 0)
- {
- var portsNode = getDoc(xml).createElement("RemotePorts");
- for (var nElem = 0; nodes.length > nElem; nElem++)
- portsNode.appendChild(nodes[nElem].cloneNode(true));
- xml.appendChild(portsNode);
- }
- }
-
- function UIPortsLoad(xml)
- {
- PortList_OnLoad();
- //
- // Enable correct protocol
- //
- switch (getElem(xml, "Protocol").toUpperCase())
- {
- case "TCP":
- currentProtocol = 0;
- break;
- case "UDP":
- currentProtocol = 1;
- break;
- case "TCP-UDP":
- currentProtocol = 2;
- break;
- case "ICMP":
- currentProtocol = 3;
- break;
- }
- SelProtocol[currentProtocol].checked = true;
-
-
- var localports = xml.selectSingleNode("LocalPorts");
- if (localports != null)
- {
-
- xmlLocalPorts = localports.cloneNode(true);
- }
- else
- {
- xmlLocalPorts = xml.ownerDocument.createElement("LocalPorts");
- }
-
- var remoteports = xml.selectSingleNode("RemotePorts");
- if (remoteports != null)
- {
- xmlRemotePorts = remoteports.cloneNode(true);
- }
- else
- {
- xmlRemotePorts = xml.ownerDocument.createElement("RemotePorts");
- }
- refreshPortList();
- }
-
- function refreshPortList()
- {
- PortList.DeleteAllRows();
- PortList.SetColumnCount(1);
-
- var bEnableList = false;
- //
- // Now add each port to our list.
- //
- var oPortList = xmlLocalPorts.selectNodes("(Port|PortRange)");
-
- for(var nElem = 0; oPortList.length > nElem; nElem++)
- {
- bEnableList = true;
- pRow = PortList.InsertRow(-1);
- if(currentProtocol == 3)
- PortList.SetCellTextPtr(pRow, 0, getPortStr(oPortList[nElem], (currentProtocol == 3)));
- else
- PortList.SetCellTextPtr(pRow, 0, StrID("local_port") + " " + getPortStr(oPortList[nElem], (currentProtocol == 3)));
- }
- //
- // Now add each port to our list.
- //
- oPortList = xmlRemotePorts.selectNodes("(Port|PortRange)");
-
- for(var nElem = 0; oPortList.length > nElem; nElem++)
- {
- bEnableList = true;
- pRow = PortList.InsertRow(-1);
- if(currentProtocol == 3)
- PortList.SetCellTextPtr(pRow, 0, getPortStr(oPortList[nElem], (currentProtocol == 3)));
- else
- PortList.SetCellTextPtr(pRow, 0, StrID("remote_port") + " " + getPortStr(oPortList[nElem], (currentProtocol == 3)));
- }
-
- PortCtlsEnabled(bEnableList);
- }
-
- function PortsAdd_OnClick()
- {
- var popup = "res://fwui.dll/Ports-Popup.htm";
- if (currentProtocol == 3)
- popup = "res://fwui.dll/ICMP-Popup.htm";
-
- var xmlOut = webWnd.showModalDialog(popup, 450, 425, Direction[1].checked?"local":"remote");
-
- if(xmlOut != null)
- {
- var nodes = xmlOut.selectNodes("/*/*");
- if (xmlOut.documentElement.nodeName == "LocalPorts") {
- for (var nElem = 0; nodes.length > nElem; nElem++)
- addPort_limited(xmlLocalPorts, nodes[nElem].nodeTypedValue);
- }
- else if (xmlOut.documentElement.nodeName == "RemotePorts")
- {
- for (var nElem = 0; nodes.length > nElem; nElem++)
- addPort_limited(xmlRemotePorts, nodes[nElem].nodeTypedValue);
- }
-
- refreshPortList();
- }
- }
-
- function PortsRemove_OnClick()
- {
- var nDivide = 0;
- var nSel = PortList.GetCurSel();
- var nodes = xmlLocalPorts.selectNodes("(Port|PortRange)");
- if (nSel >= nodes.length)
- {
- nDivide = nodes.length;
- nodes = xmlRemotePorts.selectNodes("(Port|PortRange)");
- if (nSel - nDivide >= nodes.length)
- {
- PortList.SetCurSel(-1);
- return;
- }
- }
- var nodeRemove = nodes[nSel - nDivide];
- nodeRemove.parentNode.removeChild(nodeRemove);
- refreshPortList();
-
- if (PortList.GetRowCount() <= nSel)
- nSel = PortList.GetRowCount()-1;
- PortList.SetCurSel(nSel);
- }
-
- function PortList_OnLoad()
- {
- PortList.SetTableClass("ListBoxClass");
- PortList.OnClick = portList_OnClick;
-
- //
- // Reset the list control
- //
- PortList.DeleteAllRows();
- PortList.SetColumnCount(1);
- }
-
- // if the user switches to/from ICMP - he can't take his ports with him
- function Protocol_Onclick(newProtocol)
- {
-
-
- if ( ((currentProtocol == 3) && (newProtocol != 3))
- || ((currentProtocol != 3) && (newProtocol == 3)))
- {
- if (PortList.GetRowCount() == 0)
- {
- currentProtocol = newProtocol;
- } else {
- if (webWnd.MsgBox(StrID("ChangeToICMP"), StrID("RuleSumNoRulesTitle"), 1) == 1)
- {
- nodes = xmlLocalPorts.selectNodes("(Port|PortRange)");
- for (var nSel=0; nSel < nodes.length; nSel++)
- {
- var nodeRemove = nodes[nSel];
- nodeRemove.parentNode.removeChild(nodeRemove);
- }
- nodes = xmlRemotePorts.selectNodes("(Port|PortRange)");
- for (var nSel=0; nSel < nodes.length; nSel++)
- {
- var nodeRemove = nodes[nSel];
- nodeRemove.parentNode.removeChild(nodeRemove);
- }
-
- PortList.SetCurSel(-1);
- refreshPortList();
- currentProtocol = newProtocol;
- } else {
- SelProtocol[currentProtocol].checked = true;
- }
- }
- }
- else
- {
- currentProtocol = newProtocol;
- }
- }
-
- function PortSetText()
- {
- PortProtPermitRule.style.display = "none";
- PortProtBlockRule.style.display = "none";
- PortProtMonitorRule.style.display = "none";
- PortPermitRulePort.style.display = "none";
- PortBlockRulePort.style.display = "none";
- PortMonitorRulePort.style.display = "none";
-
- if (Action[0].checked)
- {
- PortProtPermitRule.style.display = "";
- PortPermitRulePort.style.display = "";
- }
-
- if (Action[1].checked)
- {
- PortProtBlockRule.style.display = "";
- PortBlockRulePort.style.display = "";
- }
-
- if (Action[2].checked)
- {
- PortProtMonitorRule.style.display = "";
- PortMonitorRulePort.style.display = "";
- }
- }
-
- function ProtocolAndPortValidate()
- {
-
- if (PortsSel[1].checked && PortList.GetRowCount() == 0)
- {
- webWind.MsgBox2(StrID("PortListError"), UserManager.AppTitle);
- return false;
- }
-
- return true;
- }
-
- ////////////////////////////////////////////////////////////////////////////////////
- // Logging page
- //
- function UILoggingLoad(xml)
- {
-
- var val = getElem(xml,"Logging").toLowerCase();
-
- //
- // Default.
- //
- var reDialog = new RegExp("dialog", "i");
- var reAlertTracker = new RegExp("AlertTracker", "i");
- var reLogging = new RegExp("logging", "i");
- var reDashboard = new RegExp("dashboard,dialog", "i");
-
- if (-1 != val.search(reAlertTracker))
- ATracker.checked = true;
- if (-1 != val.search(reLogging))
- Logging.checked = true;
- if ((-1 != val.search(reDialog)) && (-1 != val.search(reDashboard)))
- SecAlert.checked = true;
- }
-
- function UILoggingStore(xml)
- {
- var loggingValue = "";
-
- if (SecAlert.checked)
- {
- if (loggingValue != "")
- loggingValue += ",";
-
- loggingValue += SecAlert.value.toLowerCase();
- }
-
-
- if (ATracker.checked)
- {
- if (loggingValue != "")
- loggingValue += ",";
-
- loggingValue += ATracker.value.toLowerCase();
- }
-
-
- if (Logging.checked)
- {
- if (loggingValue != "")
- loggingValue += ",";
-
- loggingValue += Logging.value.toLowerCase();
- }
-
- if(loggingValue != "")
- setXMLNode(xml, "Logging", loggingValue);
- }
-
- function LoggingSetText()
- {
- if (Action[2].checked // If the user chose to monitor ...
- && !Logging.checked // ... and no forms of monitoring are already selected ...
- && !ATracker.checked
- && !SecAlert.checked)
- Logging.checked = true; // ... ensure that at least one form of monitoring is selected
- }
-
- ////////////////////////////////////////////////////////////////////////////////////
- // Enter title and category page
- //
- var xmlCategories = null;
- var g_catref = 0;
-
- function initCatList()
- {
- var xmlFW = regORxml.FirewallData;
- xmlCategories = xmlFW.selectNodes("/FirewallData/Categories/Category");
-
- for (var nElem = 0; nElem < xmlCategories.length; nElem++)
- {
- var oOption = document.createElement("OPTION");
- var name = xmlCategories.item(nElem).selectSingleNode("CategoryName");
- var val = xmlCategories.item(nElem).selectSingleNode("CategoryValue");
- oOption.text = name.nodeTypedValue;
- oOption.value = val.nodeTypedValue;
-
- //
- // Don't display non-user categories (> 255)
- //
- if (oOption.value < 256)
- catlist.add(oOption);
- }
- }
-
- function UITitleLoad(xml)
- {
- var txt = getElem(xml,"Description");
- g_catref = getElem(xml, "CategoryReference");
-
- if (txt == "")
- titletext.value = StrID("firewall_rule");
- else
- titletext.value = txt;
-
- //
- // Ensure categories only displayed for NISFE.
- // Don't display non-user categories (> 255)
- //
- if ("PT_FE" != UserManager.ProductType || g_catref >= 255)
- return;
-
- catUI.style.display = "";
-
- initCatList();
-
- //
- // Now set selected item in category list
- //
- var nItem = 0;
- for (nItem = 0; nItem < catlist.length; nItem++)
- {
- if (catlist.item(nItem).value == g_catref)
- break;
- }
- if (nItem < catlist.length)
- {
- catlist.selectedIndex = nItem;
- }
- else
- {
- // Failed to find the category... choose "General"
- catlist.selectedIndex = 0;
- }
- }
-
- function UITitleStore(xml)
- {
- setXMLNode(xml, "Description", titletext.value);
-
- if("PT_FE" == UserManager.ProductType && g_catref < 256)
- setXMLNode(xml, "CategoryReference", catlist.item(catlist.selectedIndex).value);
- else
- setXMLNode(xml, "CategoryReference", g_catref);
- }
-
- function TitleValidate()
- {
- return true;
- }
- ////////////////////////////////////////////////////////////////////////////////////
- // All done page
- //
- function displayRuleData()
- {
- //
- // Prepare a working xml doc.
- //
- var xml = new ActiveXObject("Microsoft.XMLDOM");
- xml.documentElement = xml.createElement("Rule");
- var xmlTLN = xml.selectSingleNode("Rule");
-
- setXMLNode(xmlTLN, "InUse", "enabled");
- UIActionStore(xmlTLN);
- UIDirectionStore(xmlTLN);
- UIIPStore(xmlTLN);
- UIAdapterStore(xmlTLN);
- UIPortsStore(xmlTLN);
- UILoggingStore(xmlTLN);
- UITitleStore(xmlTLN);
-
- switch (getElem(xmlTLN,"Action").toUpperCase())
- {
- case "BLOCK":
- finMonitor.style.display = "none";
- finPermit.style.display = "none";
- finBlock.style.display = "";
- break;
- case "MONITOR":
- finBlock.style.display = "none";
- finPermit.style.display = "none";
- finMonitor.style.display = "";
- break;
- case "PERMIT":
- default:
- finBlock.style.display = "none";
- finMonitor.style.display = "none";
- finPermit.style.display = "";
- break;
- }
-
- finAppName.innerText = g_appName;
-
- var rule = "<p class=nisText style='margin-top: 3; margin-bottom: 0; margin-left:0'>Description: " + getElem(xmlTLN,"Description") +
- "</p><p class=nisText style='margin-top: 3; margin-bottom: 0; margin-left:0'>Action: ";
- rule += ruleString(xmlTLN, "</p><p class=nisText style='margin-top: 3; margin-bottom: 0; margin-left:0'>");
- rule += "</p>";
- ruleSummary.innerHTML = rule;
- }
-
- function IPAdapters_OnClick()
- {
- UIActionStore(xmlAdapterList.parentNode);
- var xml = webWnd.showModalDialog('res://fwui.dll/Adapters-popup.htm', 450, 330, xmlAdapterList);
- if (xml != null)
- xmlAdapterList = xml;
- }
-