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 MB_OK = 0x00000000;
- var MB_OKCANCEL = 0x00000001;
- var MB_ABORTRETRYIGNORE = 0x00000002;
- var MB_YESNOCANCEL = 0x00000003;
- var MB_YESNO = 0x00000004;
- var MB_RETRYCANCEL = 0x00000005;
-
- var MB_ICONHAND = 0x00000010;
- var MB_ICONQUESTION = 0x00000020;
- var MB_ICONEXCLAMATION = 0x00000030;
- var MB_ICONASTERISK = 0x00000040;
-
- var MB_USERICON = 0x00000080;
- var MB_ICONWARNING = MB_ICONEXCLAMATION;
- var MB_ICONERROR = MB_ICONHAND;
-
- var MB_ICONINFORMATION = MB_ICONASTERISK;
- var MB_ICONSTOP = MB_ICONHAND;
-
- var IDOK = 1;
- var IDCANCEL = 2;
- var IDABORT = 3;
- var IDRETRY = 4;
- var IDIGNORE = 5;
- var IDYES = 6;
- var IDNO = 7;
-
- var CurrPage = "Action";
- var g_appName = "";
- var g_bIgnoreLocations = false;
-
- returnValue = null;
-
- function Page_OnLoad()
- {
- // Set the title...
- window.title = UserManager.ProductName;
-
- var bLAIsOn = RLevel.LocationAwarenessEnabled;
- if(bLAIsOn)
- {
- LocationAwarenessIsOffText.innerText = " ";
- }
-
- //
- // 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(bOnAdd)
- {
- DirectinSetText();
- IPSetText();
- PortSetText();
-
- if(bOnAdd == true)
- {
- 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";
- UIType.style.display = "none";
- UILocations.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 "Locations":
- Page = UILocations;
- UILocation_UpdateNextButtonState();
- break;
- case "Type":
- Page = UIType;
- 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()
- {
- UIActionStore(g_rule);
- UIDirectionStore(g_rule);
- UIIPStore(g_rule);
-
- UIAdapterStore(g_rule);
- UIPortsStore(g_rule);
-
- UILoggingStore(g_rule);
- UITitleStore(g_rule);
- UITypeStore(g_rule);
-
- // Set rule InUse to true;
- g_rule.InUse = true;
-
- // &!SWM - Remove this
- //g_rule.RemoteIPs = g_ipList;
- //g_rule.LocalIPs = g_AdapterList;
- //g_rule.LocalPorts = g_LocalPorts;
- //g_rule.RemotePorts = g_RemotePorts;
-
- if (!g_bIgnoreLocations)
- {
- var arrayLocations = Location_GetListBoxSelectedItems(locationList);
- for(var i = 0; i < arrayLocations.length; i++)
- {
- g_rule.AddToLocation(arrayLocations[i]);
- g_rule.AddInUseLocation(arrayLocations[i]);
- }
- }
-
- return g_rule;
- }
-
-
- function init(rule, szRuleType, appName, bIgnoreLocations)
- {
- g_appName = appName;
- g_rule = rule;
- g_ipList = g_rule.RemoteIPs;
- if (null == bIgnoreLocations)
- bIgnoreLocations = false;
- g_bIgnoreLocations = bIgnoreLocations;
-
- UIActionLoad(g_rule);
- UIDirectionLoad(g_rule);
- UIIPLoad(g_rule);
- UIAdapterLoad(g_rule);
- UIPortsLoad(g_rule);
- UILoggingLoad(g_rule);
- UITitleLoad(g_rule);
- UITypeLoad(g_rule);
- UILocationsLoad();
-
- // don't allow ICMP protocol on application rules
- if ("" != rule.ApplicationDescription)
- {
- nonappitems.style.display ="none";
- }
-
- SetActionText(false);
- }
-
- 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(rule)
- {
- if(Action[0].checked)
- rule.Action = 2;
- else if(Action[1].checked)
- rule.Action = 1;
- else if(Action[2].checked)
- rule.Action = 4;
- }
-
- function UIActionLoad(rule)
- {
- nElem = 0;
-
- switch(rule.Action)
- {
- case 2: // Permit
- nElem = 0;
- break;
- case 1: // Block
- nElem = 1;
- break;
- case 4: // Monitor
- nElem = 2;
- break;
- }
-
- Action[nElem].checked = true;
- }
-
-
- function RuleActionHandler()
- {
- SetActionText(true);
- }
-
- function ActionValidate()
- {
- return true;
- }
-
- ////////////////////////////////////////////////////////////////////////////////////
- // Determine traffic direction page
- //
- function UIDirectionStore(rule)
- {
- if(Direction[0].checked)
- rule.Direction = 1;
- else if(Direction[1].checked)
- rule.Direction = 2;
- else if(Direction[2].checked)
- rule.Direction = 3;
- }
-
- function UIDirectionLoad(rule)
- {
- nElem = 0;
-
- switch(rule.Direction)
- {
- case 1: // Out
- nElem = 0;
- break;
- case 2: // In
- nElem = 1;
- break;
- case 3: // In-Out
- nElem = 2;
- break;
- }
-
- Direction[nElem].checked = true;
- }
-
-
- 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 g_ipList = null;
- var g_AdapterList = null;
-
- 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(rule)
- {
- //
- // If the user didn't narrow this down, delete everthing
- // in the list
- //
- if(Addresses[0].checked)
- {
- if(g_ipList != null)
- g_ipList.DeleteAll();
- else
- g_ipList = new ActiveXObject("ccFWSettg.IPList");
- }
-
- //
- // Save data.
- //
- // &!SWM - Remove This rule.RemoteIPs = g_ipList;
- }
-
- function UIAdapterStore(rule)
- {
- //
- // Save data.
- //
- // &!SWM - Remove This rule.LocalIPs = g_AdapterList;
- }
-
- function UIIPLoad(rule)
- {
- IPList_OnLoad();
-
- //
- // Check to see if any addresses were specified.
- //
- refreshIPList();
- }
-
- function UIAdapterLoad(rule)
- {
- g_AdapterList = rule.LocalIPs;
- refreshAdapters();
- }
-
- function refreshIPList()
- {
- //
- // Reset the list control
- //
- IPList.DeleteAllRows();
- IPList.SetColumnCount(2);
-
- var bEnableList = false;
-
- var curIP = g_ipList.GetFirst();
-
- while(null != curIP)
- {
- // If the ip item is a Network...
- if(curIP.Type == 3)
- {
- var text = StrID("IP") + ": " + curIP.NetworkIP + "<BR>" + StrID("Mask") + ": " + curIP.NetworkMask;
-
- pRow = IPList.InsertRow(-1);
- IPList.SetCellTextPtr(pRow, 0, StrID("NetworkAddress"));
- IPList.SetCellTextPtr(pRow, 1, text);
- }
- // If the IP item is a range...
- else if(curIP.Type == 2)
- {
- var text = StrID("From") + ": " + curIP.RangeStart + "<BR>" + StrID("To") + ": " + curIP.RangeEnd;
-
- pRow = IPList.InsertRow(-1);
- IPList.SetCellTextPtr(pRow, 0, StrID("AddressRange"));
- IPList.SetCellTextPtr(pRow, 1, text);
- }
- // If the IP item is a named item...
- else if(curIP.Type == 1)
- {
- var text = StrID("Name") + ": " + curIP.NamedIP;
-
- pRow = IPList.InsertRow(-1);
- IPList.SetCellTextPtr(pRow, 0, StrID("SingleAddress"));
- IPList.SetCellTextPtr(pRow, 1, text);
- }
- // If the IP item is an address...
- else if(curIP.Type == 0)
- {
- var text = StrID("IP") + ": " + curIP.RawIP;
-
- pRow = IPList.InsertRow(-1);
- IPList.SetCellTextPtr(pRow, 0, StrID("SingleAddress"));
- IPList.SetCellTextPtr(pRow, 1, text);
- }
-
- curIP = g_ipList.GetNext();
- }
-
- if(g_ipList.ItemCount > 0)
- bEnableList = true;
-
- IPCtlsEnabled(bEnableList);
- }
-
- function IPAdd_OnClick()
- {
- var Params = new Array;
-
- Params[0] = currentActionState;
- Params[1] = null;
- Params[2] = g_ipList;
-
- webWnd.SetIcon2("res://NisRes.dll/105");
- var newIPList = webWnd.showModalDialog('res://fwui.dll/IP-Popup.htm', 450, 350, Params);
-
- if(null != newIPList)
- {
- var curIP = newIPList.GetFirst();
-
- while(null != curIP)
- {
- if(null == g_ipList.IsIPInList(curIP))
- {
- g_ipList.LastError = 0;
- g_ipList.AppendItem(curIP);
- if(HandleListError(g_ipList.LastError, 1008, 135))
- break;
- }
-
- curIP = newIPList.GetNext();
- }
- }
-
- refreshIPList();
- IPRemove.disabled = true;
- }
-
- function IPRemove_OnClick()
- {
- var nSel = IPList.GetCurSel();
- var rule = g_ipList.GetItem(nSel);
-
- if(null != rule)
- g_ipList.DeleteItem(rule);
-
- 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 && g_ipList.ItemCount == 0)
- {
- webWnd.MsgBox(StrID("IPListError"), UserManager.AppTitle, MB_OK | MB_ICONEXCLAMATION);
- return false;
- }
-
-
- return true;
- }
-
-
- ////////////////////////////////////////////////////////////////////////////////////
- // Ports to Block page
- //
-
- var currentProtocol = 2;
- var g_LocalPorts = null;
- var g_RemotePorts = 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;
-
- // If the user clicked on PortsSel[1] (specific ports), no longer force
- // all ports in the rule.
- if (enable) g_rule.AllPorts = false;
- }
-
- function portList_OnClick()
- {
- //
- // Enable the Remove button.
- //
- EnableButton(PortsRemove,true);
- }
-
- function UIPortsStore(rule)
- {
- var node = null;
- var nodes = null;
-
- //
- // Store protocol
- //
- if(SelProtocol[0].checked)
- rule.Protocol = 6; // TCP
- else if(SelProtocol[1].checked)
- rule.Protocol = 17; // UDP;
- else if(SelProtocol[2].checked)
- rule.Protocol = 0; // TCP-UDP
- if(SelProtocol[3].checked)
- rule.Protocol = 1; // ICMP
-
- //
- // If the user specify any ports, delete the lists
- //
- if (PortsSel[0].checked)
- {
- if(g_LocalPorts != null)
- g_LocalPorts.DeleteAll();
- else
- g_LocalPorts = new ActiveXObject("ccFWSettg.PortList");
-
- if(g_RemotePorts != null)
- g_RemotePorts.DeleteAll();
- else
- g_RemotePorts = new ActiveXObject("ccFWSettg.PortList");
- }
-
- // &!SWM - Remove This rule.LocalPorts = g_LocalPorts;
- // &!SWM - Remove This rule.RemotePorts = g_RemotePorts;
- }
-
- function UIPortsLoad(rule)
- {
- PortList_OnLoad();
- //
- // Enable correct protocol
- //
- switch(rule.Protocol)
- {
- case 6: // TCP
- currentProtocol = 0;
- break;
- case 17: // UDP
- currentProtocol = 1;
- break;
- case 0: // TCP-UDP
- currentProtocol = 2;
- break;
- case 1: // ICMP
- currentProtocol = 3;
- break;
- }
- SelProtocol[currentProtocol].checked = true;
-
-
- g_LocalPorts = rule.LocalPorts;
-
- g_RemotePorts = rule.RemotePorts;
-
- refreshPortList();
- }
-
- function refreshPortList()
- {
- PortList.DeleteAllRows();
- PortList.SetColumnCount(1);
-
- var bEnableList = false;
- //
- // Now add each port to our list.
- //
- var lPort = g_LocalPorts.GetFirst();
-
- while(null != lPort)
- {
- bEnableList = true;
- pRow = PortList.InsertRow(-1);
-
- if(currentProtocol == 3)
- PortList.SetCellTextPtr(pRow, 0, getPortStr(lPort, (currentProtocol == 3)));
- else
- PortList.SetCellTextPtr(pRow, 0, StrID("local_port") + " " + getPortStr(lPort, (currentProtocol == 3)));
-
- lPort = g_LocalPorts.GetNext();
- }
-
- //
- // Now add each port to our list.
- //
- var rPort = g_RemotePorts.GetFirst()
-
- while(null != rPort)
- {
- bEnableList = true;
- pRow = PortList.InsertRow(-1);
- if(currentProtocol == 3)
- PortList.SetCellTextPtr(pRow, 0, getPortStr(rPort, (currentProtocol == 3)));
- else
- PortList.SetCellTextPtr(pRow, 0, StrID("remote_port") + " " + getPortStr(rPort, (currentProtocol == 3)));
-
- rPort = g_RemotePorts.GetNext();
- }
-
- //
- // Rules may ask that all ports be selected even if some individual ports are listed.
- // This can happen when a listening alert comes up. We want to list the port being listened
- // on, but want to recommend all ports be allowed.
- //
- if (bEnableList && typeof(g_rule) != "undefined")
- {
- if (g_rule.AllPorts) bEnableList = false;
- }
-
- PortCtlsEnabled(bEnableList);
- }
-
- function PortsAdd_OnClick()
- {
- var Params = new Array;
-
- Params[0] = Direction[1].checked?"local":"remote";
- Params[1] = g_LocalPorts;
- Params[2] = g_RemotePorts;
-
- var popup = "res://fwui.dll/Ports-Popup.htm";
- if (currentProtocol == 3)
- popup = "res://fwui.dll/ICMP-Popup.htm";
-
- webWnd.SetIcon2("res://NisRes.dll/105");
- var outParams = webWnd.showModalDialog(popup, 450, 425, Params);
-
- if (outParams == null)
- return;
-
- if(null != outParams[0])
- {
- var lPort = outParams[0].GetFirst();
-
- while(null != lPort)
- {
- if(null == g_LocalPorts.IsPortInList(lPort))
- {
- g_LocalPorts.LastError = 0;
- g_LocalPorts.AppendItem(lPort);
- if(HandleListError(g_LocalPorts.LastError, 1008, 134))
- break;
- }
- lPort = outParams[0].GetNext();
- }
- }
-
- if(null != outParams[1])
- {
- var rPort = outParams[1].GetFirst();
-
- while(null != rPort)
- {
- if(null == g_RemotePorts.IsPortInList(rPort))
- {
- g_RemotePorts.LastError = 0;
- g_RemotePorts.AppendItem(rPort);
- if(HandleListError(g_RemotePorts.LastError, 1008, 135))
- break;
- }
- rPort = outParams[1].GetNext();
- }
- }
-
- refreshPortList();
-
- //
- // Disable the Remove button.
- //
- EnableButton(PortsRemove,false);
- }
-
- function PortsRemove_OnClick()
- {
- var nDivide = 0;
- var nSel = PortList.GetCurSel();
-
- if(nSel < g_LocalPorts.ItemCount)
- {
- var lPort = g_LocalPorts.GetItem(nSel);
-
- g_LocalPorts.DeleteItem(lPort);
- }
- else
- {
- var rPort = g_RemotePorts.GetItem(nSel - g_LocalPorts.ItemCount);
-
- g_RemotePorts.DeleteItem(rPort);
- }
-
- 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((newProtocol != currentProtocol) &&
- ((newProtocol == 3) || (currentProtocol == 3)))
- {
- g_LocalPorts.DeleteAll();
- g_RemotePorts.DeleteAll();
- }
-
- currentProtocol = newProtocol;
-
- refreshPortList();
- }
-
- 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)
- {
- webWnd.MsgBox(StrID("PortListError"), UserManager.AppTitle, MB_OK | MB_ICONEXCLAMATION);
- return false;
- }
-
- return true;
- }
-
- ////////////////////////////////////////////////////////////////////////////////////
- // Logging page
- //
- function UILoggingLoad(rule)
- {
- if(1 & rule.Logging)
- Logging.checked = true;
- if(18 & rule.Logging)
- SecAlert.checked = true;
-
- if(rule.LogThreshold>1)
- {
- NumTimesText.value = rule.LogThreshold;
- }
- else
- {
- NumTimesText.value = 1;
- }
-
- Logging_OnClick();
- }
-
- function UILoggingStore(rule)
- {
- var loggingValue = "";
-
- rule.Logging = 0;
-
- if (SecAlert.checked)
- {
- rule.Logging |= 18;
- }
-
- if (Logging.checked)
- {
- rule.Logging |= 1;
-
- var NumberOfTimes = NumTimesText.value;
-
- if(NumberOfTimes > 1)
- {
- rule.LogThreshold = NumberOfTimes;
- }
- else
- {
- rule.LogThreshold = 1;
- }
- }
-
- }
-
- function LoggingSetText()
- {
- if (Action[2].checked // If the user chose to monitor ...
- && !Logging.checked // ... and no forms of monitoring are already selected ...
- && !SecAlert.checked)
- Logging.checked = true; // ... ensure that at least one form of monitoring is selected
- }
-
-
- function Logging_OnClick()
- {
- IDS_RuleCreation5.disabled = !Logging.checked;
- }
-
- ////////////////////////////////////////////////////////////////////////////////////
- // Enter title and category page
- //
- var g_CategoryList = null;
- var g_catref = 0;
-
- function initCatList()
- {
- g_CategoryList = new ActiveXObject("ccFWSettg.CategoryList");
-
- for (var nElem = 0; nElem < g_CategoryList.ItemCount; nElem++)
- {
- var oOption = document.createElement("OPTION");
- oOption.text = g_CategoryList.GetItem(nElem).Name;
- oOption.value = g_CategoryList.GetItem(nElem).Value;
-
- //
- // Don't display non-user categories (> 255)
- //
- if (oOption.value < 256)
- catlist.add(oOption);
- }
- }
-
- function UITitleLoad(rule)
- {
- var txt = rule.Description;
- g_catref = rule.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((!RLevel.AreAccountsInstalled) || (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(rule)
- {
- rule.Description = titletext.value;
-
- if(RLevel.AreAccountsInstalled && g_catref < 256)
- rule.CategoryReference = g_CategoryList.GetItem(catlist.selectedIndex).Value;
- else
- rule.CategoryReference = g_catref;
- }
-
- function UITypeLoad(rule)
- {
- ruleType[rule.Priority].checked = true;
- }
-
- function UITypeStore(rule)
- {
- if(usingClientRules())
- {
- if(ruleType[0].checked)
- rule.Priority = 0;
- else if(ruleType[1].checked)
- rule.Priority = 1;
- }
- else
- rule.Priority = 0;
- }
-
- function TitleValidate()
- {
- titletext.value = trim(titletext.value);
-
- if(titletext.value == "")
- {
- webWnd.MsgBox(StrID("RuleNoDescription"), UserManager.AppTitle, MB_OK | MB_ICONEXCLAMATION);
- return false;
- }
-
- return true;
- }
-
- ///////////////////////////////////////////////////////////////////////
- // Select location page
- //
-
- function UILocationsLoad()
- {
- // Setup the list control
- locationList.OnClick = locationList_OnClick;
- locationList.OnDblClick = locationList_OnDblClick;
- locationList.OnSpace = locationList_OnSpace;
-
- // populate list
- RuleCreation_Body.style.cursor = "wait";
-
- var bCheckDefault = !RLevel.LocationAwarenessEnabled;
- var bCheckActive = RLevel.LocationAwarenessEnabled;
- Location_PopulateListBox(locationList,bCheckDefault,bCheckActive);
-
- RuleCreation_Body.style.cursor = "";
- }
-
- function UILocation_UpdateNextButtonState()
- {
- var arrayLocations = Location_GetListBoxSelectedItems(locationList);
-
- // too bad we have intimate knowledge of the containing (parent) window, but oh well
- if(arrayLocations.length)
- {
- window.parent.NextB.disabled = false;
- }
- else
- {
- window.parent.NextB.disabled = true;
- }
- }
-
- function locationList_OnSpace()
- {
- var nCurSel = locationList.GetCurSel();
- var bEnable = false;
-
- if(nCurSel < 0)
- {
- return;
- }
-
- // Swap the state of the check box for this item
- var CheckBox = locationList.GetCellPtr(nCurSel, 0).children[0];
- CheckBox.checked = !CheckBox.checked;
-
- UILocation_UpdateNextButtonState();
- }
-
- function locationList_OnClick()
- {
- UILocation_UpdateNextButtonState();
- }
-
- function locationList_OnDblClick()
- {
- var nCurSel = locationList.GetCurSel();
- var bEnable = false;
-
- if(nCurSel < 0)
- {
- return;
- }
-
- // Swap the state of the check box for this item
- var CheckBox = locationList.GetCellPtr(nCurSel, 0).children[0];
- CheckBox.checked = !CheckBox.checked;
-
- UILocation_UpdateNextButtonState();
- }
-
- function UILocation_SelectAll()
- {
- Location_SelectAllListBoxItems(locationList, true);
- UILocation_UpdateNextButtonState();
- }
-
- function UILocation_DeselectAll()
- {
- Location_SelectAllListBoxItems(locationList, false);
- UILocation_UpdateNextButtonState();
- }
-
-
- ////////////////////////////////////////////////////////////////////////////////////
- // All done page
- //
- function displayRuleData()
- {
- UIActionStore(g_rule);
- UIDirectionStore(g_rule);
- UIIPStore(g_rule);
- UIAdapterStore(g_rule);
- UIPortsStore(g_rule);
- UILoggingStore(g_rule);
- UITitleStore(g_rule);
- UITypeStore(g_rule);
-
- switch(g_rule.Action)
- {
- case 1: // Block
- finMonitor.style.display = "none";
- finPermit.style.display = "none";
- finBlock.style.display = "";
- break;
- case 4: // Monitor
- finBlock.style.display = "none";
- finPermit.style.display = "none";
- finMonitor.style.display = "";
- break;
- case 2: // Permit
- default:
- finBlock.style.display = "none";
- finMonitor.style.display = "none";
- finPermit.style.display = "";
- break;
- }
-
- // Don't show the warning if the new rule is for monitoring only
- // But show the warning if the rule is for any ip address or any local
- // or remote port
-
- if(g_rule.Action !=4 && // Monitor
- g_ipList.ItemCount ==0 &&
- g_LocalPorts.ItemCount ==0 &&
- g_RemotePorts.ItemCount ==0 &&
- g_rule.ApplicationDescription == "")
- {
- finWarning.style.display = "";
- }
-
- finAppName.innerText = g_appName;
-
- var arrayLocations = Location_GetListBoxSelectedItems(locationList);
-
- var ruleTxt = "<p class=nisText style='margin-top: 3; margin-bottom: 0; margin-left:0'>Description: " + g_rule.Description +
- "</p><p class=nisText style='margin-top: 3; margin-bottom: 0; margin-left:0'>Action: ";
- ruleTxt += ruleString(g_rule, arrayLocations, "</p><p class=nisText style='margin-top: 3; margin-bottom: 0; margin-left:0'>");
- ruleTxt += "</p>";
-
- if( usingClientRules() && (UserManager.CurrentUserType == "UT_SUPERVISOR") )
- {
- ruleTxt += "<p class=nisText style='margin-top: 3; margin-bottom: 0; margin-left:0'>Type: ";
-
- if(0 == g_rule.Priority)
- ruleTxt += StrID("Admin_Type");
- else
- ruleTxt += StrID("User_Type");
-
- ruleTxt += "</p>";
- }
-
- ruleSummary.innerHTML = ruleTxt;
- }
-
- function IPAdapters_OnClick()
- {
- UIActionStore(g_rule);
-
- var Params = new Array;
-
- var newList = new ActiveXObject("ccFWSettg.IPList");
- newList.CopyFrom(g_AdapterList);
-
- Params[0] = currentActionState;
- Params[1] = newList;
-
- var retList = null;
-
- webWnd.SetIcon2("res://NisRes.dll/105");
- retList = webWnd.showModalDialog('res://fwui.dll/Adapters-popup.htm', 450, 330, Params);
-
- if(null != retList)
- g_AdapterList.CopyFrom(retList);
- refreshAdapters();
- }
-
- function refreshAdapters()
- {
- if (g_AdapterList.ItemCount == 0)
- IPAdaptersSpecified.style.display = "none";
- else
- IPAdaptersSpecified.style.display = "";
- }
-