Settings_SmtpServerAccessControl.pas
上传用户:dh8233980
上传日期:2014-10-16
资源大小:1015k
文件大小:8k
源码类别:
Email服务器
开发平台:
Delphi
- unit Settings_SmtpServerAccessControl;
- (******************************************************************************)
- (* *)
- (* Hermes Smtp Server Settings Access Banning Dialog Box *)
- (* Part of Hermes SMTP/POP3 Server. *)
- (* Copyright(C) 2000 by Alexander J. Fanti, All Rights Reserver Worldwide. *)
- (* *)
- (* Created February 13, 2000 by Alexander J. Fanti. See License.txt *)
- (* *)
- (* Used by: Settings_SmtpServer *)
- (* Uses: DataU1 *)
- (* *)
- (* Description: This Modal dialog window allows the user to change Smtp *)
- (* server access settings. *)
- (* *)
- (* Revisions: 2/13/2000 AJF Commented *)
- (* *)
- (******************************************************************************)
- interface
- uses
- Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
- Menus, StdCtrls, Spin, Buttons;
- type
- TfrmSettings_SmtpServerAccessControl = class(TForm)
- cbxBannedDomains: TCheckBox;
- lstBannedDomains: TListBox;
- cbxBannedMailboxes: TCheckBox;
- lstBannedMailboxes: TListBox;
- cbxRejectToCount: TCheckBox;
- speRejectToCount: TSpinEdit;
- popupBannedDomains: TPopupMenu;
- pu_BannedDomains_Add: TMenuItem;
- pu_BannedDomains_Delete: TMenuItem;
- popupBannedMailboxes: TPopupMenu;
- pu_BannedMailboxes_Add: TMenuItem;
- pu_BannedMailboxes_Delete: TMenuItem;
- popupBannedAddresses: TPopupMenu;
- pu_BannedAddresses_Add: TMenuItem;
- pu_BannedAddresses_Delete: TMenuItem;
- btnOK: TBitBtn;
- btnCancel: TBitBtn;
- cbxBannedAddresses: TCheckBox;
- lstBannedAddresses: TListBox;
- Label8: TLabel;
- Label1: TLabel;
- procedure btnOKClick(Sender: TObject);
- procedure FormShow(Sender: TObject);
- procedure popupBannedDomainsPopup(Sender: TObject);
- procedure popupBannedMailboxesPopup(Sender: TObject);
- procedure popupBannedAddressesPopup(Sender: TObject);
- procedure pu_BannedDomains_AddClick(Sender: TObject);
- procedure pu_BannedDomains_DeleteClick(Sender: TObject);
- procedure pu_BannedMailboxes_AddClick(Sender: TObject);
- procedure pu_BannedMailboxes_DeleteClick(Sender: TObject);
- procedure pu_BannedAddresses_AddClick(Sender: TObject);
- procedure pu_BannedAddresses_DeleteClick(Sender: TObject);
- private
- { Private declarations }
- public
- { Public declarations }
- end;
- var
- frmSettings_SmtpServerAccessControl: TfrmSettings_SmtpServerAccessControl;
- implementation
- {$R *.DFM}
- uses DataU1;
- procedure TfrmSettings_SmtpServerAccessControl.FormShow(Sender: TObject);
- var
- x : longint;
- begin
- // Populate dialog with data
- lstBannedDomains.Clear;
- for x := 0 to INI.Smtp_Access_BannedDomains.Count -1 do
- lstBannedDomains.Items.Add(INI.Smtp_Access_BannedDomains[x]);
- lstBannedMailboxes.Clear;
- for x := 0 to INI.Smtp_Access_BannedMailboxes.Count -1 do
- lstBannedMailboxes.Items.Add(INI.Smtp_Access_BannedMailboxes[x]);
- lstBannedAddresses.Clear;
- for x := 0 to INI.Smtp_Access_BannedAddresses.Count -1 do
- lstBannedAddresses.Items.Add(INI.Smtp_Access_BannedAddresses[x]);
- cbxBannedDomains.Checked := INI.Smtp_Access_BanDomains;
- cbxBannedMailboxes.Checked := INI.Smtp_Access_BanMailboxes;
- cbxBannedAddresses.Checked := INI.Smtp_Access_BanAddresses;
- cbxRejectToCount.Checked := INI.Smtp_Access_OnlyForUnderXUsers;
- speRejectToCount.Value := INI.Smtp_Access_OnlyForUsersCount;
- end;
- procedure TfrmSettings_SmtpServerAccessControl.btnOKClick(Sender: TObject);
- begin
- // Save Access Control
- INI.SetSmtp_Access_BannedDomains(lstBannedDomains.Items);
- INI.SetSmtp_Access_BannedMailboxes(lstBannedMailboxes.Items);
- INI.SetSmtp_Access_BannedAddresses(lstBannedAddresses.Items);
- INI.Smtp_Access_BanDomains := cbxBannedDomains.Checked;
- INI.Smtp_Access_BanMailboxes := cbxBannedMailboxes.Checked;
- INI.Smtp_Access_BanAddresses := cbxBannedAddresses.Checked;
- INI.Smtp_Access_OnlyForUnderXUsers := cbxRejectToCount.Checked;
- INI.Smtp_Access_OnlyForUsersCount := speRejectToCount.Value;
- end;
- procedure TfrmSettings_SmtpServerAccessControl.popupBannedDomainsPopup(Sender: TObject);
- begin
- // Enable Domain list popum menu items
- pu_BannedDomains_Delete.Enabled := lstBannedDomains.SelCount > 0;
- end;
- procedure TfrmSettings_SmtpServerAccessControl.pu_BannedDomains_AddClick(Sender: TObject);
- var
- NewDomain : String;
- x : Longint;
- Found : Boolean;
- begin
- // Add a new domain to the Domains list
- NewDomain := Trim(InputBox('Add Banned Domain', 'Domain', ''));
- if NewDomain <> '' then begin
- Found := False;
- for x := 0 to lstBannedDomains.Items.Count -1 do
- if LowerCase(NewDomain) = LowerCase(lstBannedDomains.Items[x]) then
- Found := True;
- if not Found then lstBannedDomains.Items.Add(NewDomain);
- end;
- end;
- procedure TfrmSettings_SmtpServerAccessControl.pu_BannedDomains_DeleteClick(Sender: TObject);
- var
- x : Longint;
- begin
- // remove domains from the domain list
- for x := lstBannedDomains.Items.Count -1 downto 0 do
- if lstBannedDomains.Selected[x] then lstBannedDomains.Items.Delete(x);
- end;
- procedure TfrmSettings_SmtpServerAccessControl.popupBannedMailboxesPopup(
- Sender: TObject);
- begin
- // Enable Domain list popum menu items
- pu_BannedMailboxes_Delete.Enabled := lstBannedMailboxes.SelCount > 0;
- end;
- procedure TfrmSettings_SmtpServerAccessControl.pu_BannedMailboxes_AddClick(Sender: TObject);
- var
- NewMailbox : String;
- x : Longint;
- Found : Boolean;
- begin
- // Add a new mailbox to the mailboxes list
- NewMailbox := Trim(InputBox('Add Banned Mailbox', 'Mailbox', ''));
- if NewMailbox <> '' then begin
- Found := False;
- for x := 0 to lstBannedMailboxes.Items.Count -1 do
- if LowerCase(NewMailbox) = LowerCase(lstBannedMailboxes.Items[x]) then
- Found := True;
- if not Found then lstBannedMailboxes.Items.Add(NewMailbox);
- end;
- end;
- procedure TfrmSettings_SmtpServerAccessControl.pu_BannedMailboxes_DeleteClick(
- Sender: TObject);
- var
- x : Longint;
- begin
- // remove mailboxes from the mailbox list
- for x := lstBannedMailboxes.Items.Count -1 downto 0 do
- if lstBannedMailboxes.Selected[x] then lstBannedMailboxes.Items.Delete(x);
- end;
- procedure TfrmSettings_SmtpServerAccessControl.popupBannedAddressesPopup(
- Sender: TObject);
- begin
- // Enable Domain list popum menu items
- pu_BannedAddresses_Delete.Enabled := lstBannedAddresses.SelCount > 0;
- end;
- procedure TfrmSettings_SmtpServerAccessControl.pu_BannedAddresses_AddClick(
- Sender: TObject);
- var
- NewAddress : String;
- x : Longint;
- Found : Boolean;
- begin
- // Add a new domain to the Domains list
- NewAddress := Trim(InputBox('Add Banned Address', 'Address', ''));
- if NewAddress <> '' then begin
- Found := False;
- for x := 0 to lstBannedAddresses.Items.Count -1 do
- if LowerCase(NewAddress) = LowerCase(lstBannedAddresses.Items[x]) then
- Found := True;
- if not Found then lstBannedAddresses.Items.Add(NewAddress);
- end;
- end;
- procedure TfrmSettings_SmtpServerAccessControl.pu_BannedAddresses_DeleteClick(
- Sender: TObject);
- var
- x : Longint;
- begin
- // remove domains from the domain list
- for x := lstBannedAddresses.Items.Count -1 downto 0 do
- if lstBannedAddresses.Selected[x] then lstBannedAddresses.Items.Delete(x);
- end;
- end.