📄 unit2.pas
字号:
end;
procedure TForm2.IdTCPServer1Connect(AThread: TIdPeerThread);
var
RdSize:integer;
RDStrList:TStringList;
RDStrStream:TStringStream;
SwapOK:Boolean;
begin
Try
RDStrStream:=TStringStream.Create('');
except
AThread.Connection.Disconnect;
AThread.Terminate;
exit;
end;
try
RdSize:=AThread.Connection.ReadInteger;
AThread.Connection.ReadStream(RDStrStream,RdSize);
except
RDStrStream.Free;
AThread.Connection.Disconnect;
AThread.Terminate;
exit;
end;
StrInfoSwap('wqkemail8088',RDStrStream,SwapOK);
if Not SwapOK then
begin
RDStrStream.Free;
AThread.Connection.Disconnect;
AThread.Terminate;
exit;
end;
try
RDStrList:=TStringList.Create;
except
RDStrStream.Free;
AThread.Connection.Disconnect;
AThread.Terminate;
exit;
end;
RDStrList.Text:=RDStrStream.DataString;
if authenticateUser(RDStrlist[1],RDStrList[2],AThread) then
begin
try
AThread.Connection.WriteInteger(1);
except
RDStrList.Free;
RDStrStream.Free;
AThread.Connection.Disconnect;
AThread.Terminate;
end;
end else
begin
try
AThread.Connection.WriteInteger(0);
AThread.Connection.Disconnect;
AThread.Terminate;
except
AThread.Connection.Disconnect;
AThread.Terminate;
RDStrStream.Free;
RDStrList.Free;
end;
end;
//-------------------------------------------------
RDStrStream.Free;
RDStrList.Free;
end;
procedure TForm2.BitBtn13Click(Sender: TObject);
begin
//设置系统用户
CheckBox1.Checked:=False;
//设置授权用户
CheckBox7.Checked:=False;
CheckBox8.Checked:=False;
CheckBox9.Checked:=False;
CheckBox12.Checked:=False;
CheckBox11.Checked:=True;
CheckBox2.Checked:=False;
CheckBox3.Checked:=False;
CheckBox13.Checked:=False;
CheckBox17.Checked:=False;
CheckBox18.Checked:=False;
//更新内部记录
setDefaultUserInfo;
BitBtn13.Enabled:=False;
end;
procedure TForm2.CheckBox4Click(Sender: TObject);
begin
BitBtn13.Enabled:=True;
BitBtn12.Enabled:=True;
end;
procedure TForm2.BitBtn12Click(Sender: TObject);
begin
SetSysUserInfo; //更新到内部记录
BitBtn12.Enabled:=False;
end;
procedure TForm2.IdTCPServer1Disconnect(AThread: TIdPeerThread);
var
i:integer;
begin
LetSingle.Acquire;
self.Canvas.Lock;
for i:=ListView1.Items.Count-1 Downto 0 do
begin
if ListView1.Items[i].Caption=IntToStr(AThread.ThreadID) then
begin
ListView1.Items[i].StateIndex:=0;
if AThread.Connection.Tag=0 then
begin
ListView1.Items[i].StateIndex:=1;
if ListView1.Items[i].SubItems[1]='超级用户' then
ListView1.Items[i].StateIndex:=2;
if ListView1.Items[i].SubItems[1]='授权用户' then
ListView1.Items[i].StateIndex:=10;
end;
if AThread.Connection.Tag=1 then
ListView1.Items[i].StateIndex:=0;
if AThread.Connection.Tag=10 then
ListView1.Items[i].StateIndex:=6;
if AThread.Connection.Tag=1888888888 then
ListView1.Items[i].StateIndex:=12;
SetSysLog(ListView3,ListView1.Items[i]);
ListView1.Items.Delete(i);
end;
end;
self.Canvas.Unlock;
LetSingle.Leave;
end;
procedure TForm2.FormDestroy(Sender: TObject);
begin
LetSingle.Free;
LetSingle2.Free;
LockTheOpUI.Free;
UserList.Free;
ShareDirUserList.Free;
RefuseIpList.Free;
end;
procedure TForm2.IdTCPServer1Execute(AThread: TIdPeerThread);
var
RecCMD:string;
begin
//侦听命令--------再进行分类处理
try
RecCMD:=AThread.Connection.ReadLn(EOL);
except
AThread.Connection.Disconnect;
AThread.Terminate;
exit;
end;
//接收到命令-----------根据用户类型进行分类处理
if AThread.Connection.Tag=SysSuper.UserTag then//转入系统用户的处理
begin
SuperUserProc(AThread,RecCMD);
end;
if AThread.Connection.Tag=SysAuthorizer.UserTag then//转入授权用户的处理
begin
AThread.Terminate;
end;
if AThread.Connection.Tag=SysGuest.UserTag then//转入访客用户的处理
begin
AThread.Terminate;
end;
if AThread.Connection.Tag=0 then//转入其他用户的处理
begin
AThread.Terminate;
end;
end;
procedure TForm2.SpeedButton19Click(Sender: TObject);
begin
IdTCPServer1.Active:=Not IdTCPServer1.Active;
if IdTCPServer1.Active=True then
begin
SpeedButton19.Caption:='已启动服务';
end;
if IdTCPServer1.Active=False then
begin
SpeedButton19.Caption:='已停止服务';
IdTCPServer1.DefaultPort:=StrToInt(MaskEdit4.Text);
end;
end;
procedure TForm2.ListView1Change(Sender: TObject; Item: TListItem;
Change: TItemChange);
begin
Label4.Caption:='当前有:'+IntToStr(listView1.Items.Count-1)+'个用户在线';
if listView1.Items.Count>1 then NotifyIcon1.Animated:=true else
NotifyIcon1.Animated:=False;
NotifyIcon1.Hint:='当前共有'+IntToStr(listView1.Items.Count-1)+'个连接登录';
end;
procedure TForm2.ListView3Change(Sender: TObject; Item: TListItem;
Change: TItemChange);
begin
ListView3.Hint:='当前共有:'+IntToStr(listView3.Items.Count-1)+'条历史登录记录';
if ListView3.Items.Count>StrToInt(Edit3.Text) then
ListView3.Items.Delete(ListView3.Items.Count-1);
end;
procedure TForm2.ListView5Change(Sender: TObject; Item: TListItem;
Change: TItemChange);
begin
ListView5.Hint:='当前共有:'+IntToStr(listView5.Items.Count-1)+'条操作记录';
if ListView5.Items.Count>StrToInt(Edit4.Text) then
ListView5.Items.Delete(ListView5.Items.Count-1);
end;
procedure TForm2.SpeedButton1Click(Sender: TObject);
var
TheDir :string;
TheItem :TListItem;
i :integer;
TmpStrList:TStringList;
begin
TheDir := 'C:\';
if SelectDirectory('选择授权目录','Desktop',TheDir) then
begin
SelDirFm.MaskEdit1.Text:=TheDir;
SelDirFm.ShowModal;
TheItem:=ListView4.Items.Add;
TheItem.Caption:=TheDir;
if SelDirFm.CheckBox1.Checked then
TheItem.SubItems.Add('只 读') else TheItem.SubItems.Add('读/写');
TheItem.SubItems.Add(SelDirFm.MaskEdit2.Text);
try
TmpStrList:=TStringList.Create;
except
Beep;
Self.Caption:='系统内存不够啦!';
exit;
end;
For i:=0 to ListView4.Items.Count-1 do
begin
TmpStrList.Add(ListView4.Items[i].Caption);
TmpStrList.Add(ListView4.Items[i].SubItems[0]);
TmpStrList.Add(ListView4.Items[i].SubItems[1])
end;
TmpStrList.SaveToFile(ShareDirSaveName);
end;
end;
procedure TForm2.SpeedButton6Click(Sender: TObject);
var
TmpStrList:TStringList;
i :integer;
begin
if ListView4.Selected=nil then exit;
try
TmpStrList:=TStringList.Create;
except
Beep;
Self.Caption:='系统内存不够啦!';
exit;
end;
For i:=ShareDirUserList.Count-1 Downto 0 do
begin
if ShareDirUserList.Names[i]=ListView4.Selected.Caption then
ShareDirUserList.Delete(i);
end;
ShareDirUserList.SaveToFile(ShareDirUserSName);
ListView4.Selected.Delete;
For i:=0 to ListView4.Items.Count-1 do
begin
TmpStrList.Add(ListView4.Items[i].Caption);
TmpStrList.Add(ListView4.Items[i].SubItems[0]);
TmpStrList.Add(ListView4.Items[i].SubItems[1])
end;
TmpStrList.SaveToFile(ShareDirSaveName);
end;
procedure TForm2.SpeedButton5Click(Sender: TObject);
var
TheListItem:TListItem;
i :integer ;
begin
RefuseSvFrm.ShowModal;
if RefuseSvFrm.MaskEdit2.Text<>'' then
begin
TheListItem:=ListView2.Items.Add;
TheListItem.StateIndex:=10;
TheListItem.Caption:=RefuseSvFrm.MaskEdit2.Text;
TheListItem.SubItems.Add(RefuseSvFrm.MaskEdit3.Text);
TheListItem.SubItems.Add(RefuseSvFrm.MaskEdit4.Text);
TheListItem.SubItems.Add(RefuseSvFrm.MaskEdit1.Text);
end;
RefuseIpList.Clear;
For i:=0 to ListView2.Items.Count-1 do
begin
RefuseIPList.Add(ListView2.Items[i].Caption);
RefuseIPList.Add( ListView2.Items[i].SubItems[0]);
RefuseIPList.Add( ListView2.Items[i].SubItems[1]);
RefuseIPList.Add( ListView2.Items[i].SubItems[2]);
end;
RefuseIpList.SaveToFile(RefuseIPListFName);
end;
procedure TForm2.SpeedButton9Click(Sender: TObject);
var
i:integer;
begin
if ListView2.Selected=nil then exit;
ListView2.DeleteSelected;
RefuseIpList.Clear;
For i:=0 to ListView2.Items.Count-1 do
begin
RefuseIPList.Add(ListView2.Items[i].Caption);
RefuseIPList.Add( ListView2.Items[i].SubItems[0]);
RefuseIPList.Add( ListView2.Items[i].SubItems[1]);
RefuseIPList.Add( ListView2.Items[i].SubItems[2]);
end;
RefuseIpList.SaveToFile(RefuseIPListFName);
end;
procedure TForm2.BitBtn11Click(Sender: TObject);
begin
Close;
end;
procedure TForm2.SpeedButton3Click(Sender: TObject);
begin
ListView5.Items.Clear;
end;
procedure TForm2.SpeedButton18Click(Sender: TObject);
var
TheSaveFL:TStringList;
i:integer;
begin
if SaveDialog1.Execute then
begin
TheSaveFL:=TStringList.Create;
for i:=0 to ListView5.Items.Count-1 do
begin
TheSaveFL.Add('IP地址:'+ListView5.Items[i].Caption+
'登录角色:'+ListView5.Items[i].SubItems[0]+
'操作类型:'+ListView5.Items[i].SubItems[1]+
'操作对象:'+ListView5.Items[i].SubItems[2]+
'操作时间:'+ListView5.Items[i].SubItems[3]);
end;
TheSaveFL.SaveToFile(SaveDialog1.FileName);
TheSaveFL.Free;
end;
end;
procedure TForm2.SpeedButton10Click(Sender: TObject);
begin
ListView3.Items.Clear;
end;
procedure TForm2.SpeedButton12Click(Sender: TObject);
var
TheSaveFL:TStringList;
i:integer;
begin
if SaveDialog1.Execute then
begin
TheSaveFL:=TStringList.Create;
for i:=0 to ListView3.Items.Count-1 do
begin
TheSaveFL.Add('线程ID:'+ListView3.Items[i].Caption+
'IP地址:'+ListView3.Items[i].SubItems[0]+
'登录角色:'+ListView3.Items[i].SubItems[1]+
'验证:'+ListView3.Items[i].SubItems[2]+
'登录时间:'+ListView3.Items[i].SubItems[3]+
'离开时间:'+ListView3.Items[i].SubItems[4]);
end;
TheSaveFL.SaveToFile(SaveDialog1.FileName);
TheSaveFL.Free;
end;
end;
procedure TForm2.SpeedButton22Click(Sender: TObject);
var
TheLI:TListItem;
begin
TheLI:=ListView7.Items.Add;
TheLI.Caption:=MaskEdit9.Text;
TheLI.SubItems.Add(MaskEdit10.Text);
TheLI.SubItems.Add(MaskEdit8.Text);
TheLI.StateIndex:=11;
end;
procedure TForm2.SpeedButton23Click(Sender: TObject);
begin
if ListView7.Selected=nil then exit;
ListView7.Selected.Delete;
end;
procedure TForm2.SpeedButton17Click(Sender: TObject);
var
TheLI:TListItem;
begin
TheLI:=ListView6.Items.Add;
TheLI.Caption:=MaskEdit5.Text;
TheLI.SubItems.Add(MaskEdit6.Text);
TheLI.SubItems.Add(MaskEdit7.Text);
TheLI.StateIndex:=10;
end;
procedure TForm2.SpeedButton21Click(Sender: TObject);
begin
if ListView6.Selected=nil then exit;
ListView6.Selected.Delete;
end;
procedure TForm2.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
begin
NotifyIcon1.Active:=True;
self.Hide;
ShowWindow(Application.Handle, SW_HIDE);
if BitBtn15.tag<>100 then CanClose:=False;
end;
procedure TForm2.BitBtn15Click(Sender: TObject);
begin
BitBtn15.Tag:=100;
close;
end;
procedure TForm2.N2Click(Sender: TObject);
begin
BitBtn15.Tag:=100;
close;
end;
procedure TForm2.N1Click(Sender: TObject);
begin
Form2.Show;
end;
procedure TForm2.FormDeactivate(Sender: TObject);
begin
NotifyIcon1.Active:=True;
self.Hide;
ShowWindow(Application.Handle, SW_HIDE);
end;
procedure TForm2.NotifyIcon1DblClick(Sender: TObject);
begin
Self.Show;
end;
procedure TForm2.ListView1Insert(Sender: TObject; Item: TListItem);
begin
if listView1.Items.Count>1 then NotifyIcon1.Animated:=true else
NotifyIcon1.Animated:=False;
NotifyIcon1.Hint:='当前共有'+IntToStr(listView1.Items.Count-1)+'个连接登录';
end;
procedure TForm2.ListView1Deletion(Sender: TObject; Item: TListItem);
begin
if listView1.Items.Count-1>1 then NotifyIcon1.Animated:=true else
NotifyIcon1.Animated:=False;
NotifyIcon1.Hint:='当前共有'+IntToStr(listView1.Items.Count-2)+'个连接登录';
end;
procedure TForm2.TabSet1Click(Sender: TObject);
begin
if TabSet1.TabIndex=0 then
Panel2.Align:=alClient else
begin
Panel2.Align:=alNone;
Panel2.Height:=0;
end;
if TabSet1.TabIndex=1 then
Panel16.Align:=alClient else
begin
Panel16.Align:=alNone;
Panel16.Height:=0;
end;
if TabSet1.TabIndex=2 then
Panel25.Align:=alClient else
begin
Panel25.Align:=alNone;
Panel25.Height:=0;
end;
end;
procedure TForm2.FormShow(Sender: TObject);
begin
TabSet1Click(self);
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -