📄 unit_main.pas
字号:
end;
end;
procedure TFrmMain.Timer_SendTimer(Sender: TObject);
var
SendMsg:PTMsg;
begin
Timer_Send.Enabled:=False;
if (MsgSend_List.Count>0)then
begin
try
New(SendMsg);
SendMsg:=PTMsg(MsgSend_List[0]);
MsgSend_List.Delete(0);
SendSocket(sendmsg.Socket,sendmsg.Str);
finally
end;
end;
Timer_Send.Enabled:=True;
end;
procedure TFrmMain.Bt_LevelClick(Sender: TObject);
var
Selected:integer;
CharidxPath:String;
begin
if Button3.Enabled then
begin
ShowMessage('请先连接数据库!');
exit;
end;
CharidxPath:=Edit_indexPath.Text+'Mir3CharIdx';
Label_Warining.Caption:='';
if (Sender as TButton).Name='Bt_Level' then Selected:=0;
if (Sender as TButton).Name='Bt_Gold' then Selected:=1;
if (Sender as TButton).Name='Bt_Guild' then Selected:=2;
Build_Mir3idx(selected);
case Selected of
0:
ShellExecute(Handle,'open',Pchar(CharidxPath+'\index_level.htm'),nil,nil,SW_NORMAL);
1:
ShellExecute(Handle,'open',Pchar(CharidxPath+'\index_Gold.htm'),nil,nil,SW_NORMAL);
2:
ShellExecute(Handle,'open',Pchar(CharidxPath+'\index_Guild.htm'),nil,nil,SW_NORMAL);
end;
end;
procedure TFrmMain.Button2Click(Sender: TObject);
begin
Edit_indexPath.Text:=FindDir(Handle);
end;
procedure TFrmMain.Button4Click(Sender: TObject);
begin
Frm_charIndex.ShowModal;
end;
procedure TFrmMain.Button7Click(Sender: TObject);
begin
Edit_GuildPath.Text:=FindDir(Handle);
if not FileExists(Edit_GuildPath.Text+'Guildlist.txt') then
begin
ShowMessage('无法找到行会数据,请检查!');
Edit_GuildPath.Text:='';
Edit_GuildPath.SetFocus;
end;
end;
procedure TFrmMain.Build_Mir3idx(Selected:integer);
var
Html_Body:TStrings;
i,j,k:integer;
Title,T1,T2,T3,T4,T5:String;
Sql_Str:String;
IniFile:TiniFile;
Ids:TStrings;
CharidxPath:string;
GuildList:Tlist;
Guild:PGuild;
Zero:String;
Guild_SBK,Guild_Str,Guild_Name,Guild_Char1,Guild_Char2,Guild_Count:string;
begin
Zero:='0000000';
Label_Warining.Caption:='';
if Selected=2 then
begin
if not FileExists(Edit_GuildPath.Text+'Guildlist.txt') then
begin
Label_Warining.Caption:='行会数据不存在!';
exit;
end;
end;
if Not DirectoryExists(Edit_indexPath.Text) then
begin
Label_Warining.Caption:='请指定正确的WEB服务目录!';
Exit;
end;
Ids:=TStringList.Create;
inifile:=TIniFile.Create(ExtractFilePath(Application.ExeName)+'RegSvr.ini');
for i:=1 to IniFile.ReadInteger('NoIndexID','IDCount',0) do
begin
Ids.Add(IniFile.ReadString('NoIndexID','Id'+IntToStr(i),''));
end;
IniFile.Free;
Html_Body:=TStringList.Create;
case Selected of
0:
begin
Title:='英雄榜';
T1:='序号';
T2:='角色名';
T3:='性别';
T4:='职业';
T5:='等级';
end ;
1:
begin
Title:='财富榜';
T1:='序号';
T2:='角色名';
T3:='性别';
T4:='职业';
T5:='金钱';
end ;
2:
begin
Title:='行会榜';
T1:='序号';
T2:='行会名';
T3:='掌门';
T4:='副掌门';
T5:='人数';
end ;
end;
Html_Body.Clear;
Html_Body.Add('<html><head><meta http-equiv="Content-Type" content="text/html; charset=gb2312">');
Html_Body.Add('<title>'+Title+'</title>');
Html_Body.Add('<style type="text/css"><!--.style6 { color: #FF0000; font-weight: bold; font-size: 12px;}.style8 {font-size: 12px; font-weight: bold;}.style9 {color: #72341F}.style11 {color: #000000}.style12 {font-size: 12px}--></style></head>');
Html_Body.Add('<body><table border="0" cellpadding="0" cellspacing="0">');
Html_Body.Add('<tr> <td bgcolor="#FFF1CC"><table width="255" border="1" cellpadding="1" cellspacing="1" bordercolor="#CC3300"><tr class="style12">');
Html_Body.Add('<td nowrap><Center>'+T1+'</Center></td>');
Html_Body.Add('<td nowrap><Center>'+T2+'</Center></td>');
Html_Body.Add('<td nowrap><Center>'+T3+'</Center></td>');
Html_Body.Add('<td nowrap><Center>'+T4+'</Center></td>');
Html_Body.Add('<td nowrap><Center>'+T5+'</Center></td></tr>');
case Selected of
0:
begin
with ADOQuery_Game do
begin
Close;
Sql.Clear;
Sql_Str:='Select Top '+Edit_Level.Text+' Fld_Character,Fld_Sex,Fld_job,Fld_Level from Tbl_Character';
if ids.Count>0 then
begin
Sql_Str:=Sql_Str+' where Fld_Userid not in (';
for j:=0 to Ids.Count-1 do
begin
Sql_Str:=Sql_Str+''''+Ids[j]+''',';
end;
Sql_Str[Length(Sql_Str)]:=')';
end;
Sql_Str:=Sql_Str+' order by Fld_Level Desc';
Sql.Add(Sql_Str);
Open;
First;
for j:=1 to Recordset.RecordCount do
begin
Html_Body.Add('<tr><tr class="style12">');
Html_Body.Add('<td nowrap align="right">'+IntToStr(j)+'</td>');
Html_Body.Add('<td nowrap>'+FieldByName('Fld_Character').AsString+'</td>');
if FieldByName('Fld_Sex').AsInteger=0 then Html_Body.Add('<td nowrap><Center>男</Center></td>') else Html_Body.Add('<td nowrap><center>女</center></td>');
case FieldByName('Fld_Job').AsInteger of
0:Html_Body.Add('<td nowrap><center>战士</center></td>');
1:Html_Body.Add('<td nowrap><center>法师<center></td>');
2:Html_Body.Add('<td nowrap><center>道士<center></td>');
end;
Html_Body.Add('<td nowrap align="right">'+IntToStr(FieldByName('Fld_Level').AsInteger)+'</td></tr>');
if j=StrToInt(Edit_Level.Text) then break;
Next;
end;
end;
end;
1:
begin
with ADOQuery_Game do
begin
Close;
Sql.Clear;
Sql_Str:='Select Top '+Edit_Level.Text+' Fld_Character,Fld_Sex,Fld_job,Fld_Gold from Tbl_Character';
if ids.Count>0 then
begin
Sql_Str:=Sql_Str+' where Fld_Userid not in (';
for j:=0 to Ids.Count-1 do
begin
Sql_Str:=Sql_Str+''''+Ids[j]+''',';
end;
Sql_Str[Length(Sql_Str)]:=')';
end;
Sql_Str:=Sql_Str+' order by Fld_Gold Desc';
Sql.Add(Sql_Str);
Open;
first;
for j:=1 to Recordset.RecordCount do
begin
Html_Body.Add('<tr class="style12">');
Html_Body.Add('<td nowrap align="right">'+IntToStr(j)+'</td>');
Html_Body.Add('<td nowrap>'+FieldByName('Fld_Character').AsString+'</td>');
if FieldByName('Fld_Sex').AsInteger=0 then Html_Body.Add('<td nowrap><center>男</center></td>') else Html_Body.Add('<td nowrap><center>女</center></td>');
case FieldByName('Fld_Job').AsInteger of
0:Html_Body.Add('<td nowrap><center>战士</center></td>');
1:Html_Body.Add('<td nowrap><center>法师</center></td>');
2:Html_Body.Add('<td nowrap><center>道士</center></td>');
end;
Html_Body.Add('<td nowrap align="right">'+IntToStr(FieldByName('Fld_Gold').AsInteger)+'</td></tr>');
if j=StrToInt(Edit_Level.Text) then break;
Next;
end;
end;
end;
2:
begin
with ADOQuery_Hero do
begin
Close;
Sql.Clear;
Sql.Add('Select CastleOwner from castledefine');
Open;
Guild_SBK:=Fields[0].AsString;
end;
GuildList:=TList.Create;
List_Guild.Items.Clear;
if Idx_Guild(GuildList,Edit_GuildPath.Text) then
begin
if GuildList.Count>0 then
begin
for j:=0 to GuildList.Count-1 do
begin
List_Guild.Items.Add(Copy(Zero,1,7-length(IntToStr(Pguild(GuildList[j]).count)))+IntToStr(Pguild(GuildList[j]).count)+';'+Pguild(GuildList[j]).name+';'+Pguild(GuildList[j]).char1+';'+Pguild(GuildList[j]).char2);
end;
k:=1;
for j:=List_Guild.Items.Count-1 downto 0 do
begin
Guild_Str:=List_Guild.Items[j];
Guild_Count:=IntToStr(StrToInt(Copy(Guild_Str,1,pos(';',Guild_Str)-1)));
Delete(Guild_Str,1,pos(';',Guild_Str));
Guild_Name:=Trim(Copy(Guild_Str,1,pos(';',Guild_Str)-1));
Delete(Guild_Str,1,pos(';',Guild_Str));
Guild_Char1:=Trim(Copy(Guild_Str,1,pos(';',Guild_Str)-1));
Delete(Guild_Str,1,pos(';',Guild_Str));
Guild_Char2:=Trim(Guild_Str);
if Guild_Name=Trim(Guild_SBK) then
begin
Html_Body.Add('<tr class="style12">');
Html_Body.Add('<td nowrap align="right" bgcolor="#FF66CC">'+IntToStr(k)+'</td>');
Html_Body.Add('<td nowrap bgcolor="#FF66CC">'+Guild_Name+'(沙巴克)</td>');
Html_Body.Add('<td nowrap bgcolor="#FF66CC">'+Guild_Char1+'</td>');
Html_Body.Add('<td nowrap bgcolor="#FF66CC">'+Guild_Char2+'</td>');
Html_Body.Add('<td nowrap bgcolor="#FF66CC" align="right">'+Guild_Count+'</td></tr>');
end
else
begin
Html_Body.Add('<tr class="style12">');
Html_Body.Add('<td nowrap align="right">'+IntToStr(k)+'</td>');
Html_Body.Add('<td nowrap>'+Guild_Name+'</td>');
Html_Body.Add('<td nowrap>'+Guild_Char1+'</td>');
Html_Body.Add('<td nowrap>'+Guild_Char2+'</td>');
Html_Body.Add('<td nowrap align="right">'+Guild_Count+'</td></tr>');
end;
if k=StrToInt(Edit_Guilds.Text) then break;
k:=k+1;
end;
end;
end;
GuildList.Free;
end;
end;
Html_Body.Add('</body></html>');
CharidxPath:=Edit_indexPath.Text+'Mir3CharIdx';
if not DirectoryExists(CharidxPath) then MkDir(CharidxPath);
case Selected of
0:
Html_Body.SaveToFile(CharidxPath+'\index_level.htm');
1:
Html_Body.SaveToFile(CharidxPath+'\index_Gold.htm');
2:
Html_Body.SaveToFile(CharidxPath+'\index_Guild.htm');
end;
Html_Body.Free;
Ids.Free;
end;
procedure TFrmMain.Button3Click(Sender: TObject);
var
SqlData,Sqluser,Sqlpass:String;
begin
Try
SqlData:=Trim(Edit_Accountdata.Text);
Sqluser:=Trim(Edit_Accountuser.Text);
Sqlpass:=Trim(Edit_Accountpass.Text);
DataConnectStr:='Provider=MSDASQL.1;Password='+Sqlpass+';Persist Security Info=True;User ID='+Sqluser+';Data Source='+SqlData;
ADOConnection1.ConnectionString:=DataConnectStr;
SqlData:=Trim(Edit_GameData.Text);
Sqluser:=Trim(Edit_GameUser.Text);
Sqlpass:=Trim(Edit_GamePass.Text);
DataConnectStr:='Provider=MSDASQL.1;Password='+Sqlpass+';Persist Security Info=True;User ID='+Sqluser+';Data Source='+SqlData;
ADOConnection2.ConnectionString:=DataConnectStr;
SqlData:=Trim(Edit_HeroData.Text);
Sqluser:=Trim(Edit_HeroUser.Text);
Sqlpass:=Trim(Edit_HeroPass.Text);
DataConnectStr:='Provider=MSDASQL.1;Password='+Sqlpass+';Persist Security Info=True;User ID='+Sqluser+';Data Source='+SqlData;
ADOConnection3.ConnectionString:=DataConnectStr;
try
ADOConnection1.connected:=True;
ADOConnection2.connected:=True;
ADOConnection3.connected:=True;
with ADOQuery2 do
begin
Close;
Sql.Clear;
Sql.Add('backup log '+Trim(Edit_Accountdata.Text)+' with NO_LOG');
Sql.Add('backup log '+Trim(Edit_Accountdata.Text)+' with TRUNCATE_ONLY');
Sql.Add('DBCC SHRINKDATABASE('+Trim(Edit_Accountdata.Text)+')');
ExecSQL;
Close;
Sql.Clear;
Sql.Add('backup log '+Trim(Edit_GameData.Text)+' with NO_LOG');
Sql.Add('backup log '+Trim(Edit_GameData.Text)+' with TRUNCATE_ONLY');
Sql.Add('DBCC SHRINKDATABASE('+Trim(Edit_GameData.Text)+')');
ExecSQL;
Close;
Sql.Clear;
Sql.Add('backup log '+Trim(Edit_HeroData.Text)+' with NO_LOG');
Sql.Add('backup log '+Trim(Edit_HeroData.Text)+' with TRUNCATE_ONLY');
Sql.Add('DBCC SHRINKDATABASE('+Trim(Edit_HeroData.Text)+')');
ExecSQL;
Close;
Sql.Clear;
Sql:=Memo_Backup.Lines;
ExecSQL
end;
with ADOQuery1 do
begin
Close;
Sql.Clear;
Sql:=Memo_DElProc.Lines;
ExecSQL;
Close;
Sql.Clear;
Sql:=Memo_AddUser.Lines;
ExecSQL;
Close;
Sql.Clear;
Sql:=Memo_FindQuiz.Lines;
ExecSQL;
Close;
Sql.Clear;
Sql:=Memo_FindPass.Lines;
ExecSQL;
Close;
Sql.Clear;
Sql:=Memo_EditPass.Lines;
ExecSQL;
end;
with ADOQuery_Game do
begin
Close;
Sql.Clear;
Sql:=Memo_DelProcGame.Lines;
ExecSQL;
Close;
Sql.Clear;
Sql:=Memo_FindChar.Lines;
ExecSQL;
Close;
Sql.Clear;
Sql:=Memo_EditChar.Lines;
ExecSQL;
Close;
Sql.Clear;
Sql:=Memo_FindStorage.Lines;
ExecSQL;
end;
Button3.Enabled:=False;
Button1.Enabled:=True;
except
ShowMessage('无法连接数据库,请检查!');
ADOConnection1.Connected:=False;
ADOConnection2.Connected:=False;
ADOConnection3.Connected:=False;
exit;
end;
except end;
end;
procedure TFrmMain.Timer_BuildIdxTimer(Sender: TObject);
begin
Timer_BuildIdx.Enabled:=False;
if Check_LevelIndex.Checked then Build_Mir3idx(0);
if Check_GoldIndex.Checked then Build_Mir3idx(1);
if Check_Guildindex.Checked then Build_Mir3idx(2);
Timer_BuildIdx.Enabled:=True;
end;
procedure TFrmMain.FormShow(Sender: TObject);
begin
FrmMain.Width:=385;
BitBtn1.Glyph:=Image2.Picture.Bitmap;
BitBtn1.tag:=0;
end;
procedure TFrmMain.BitBtn1Click(Sender: TObject);
begin
if BitBtn1.Tag= 0 then
begin
FrmMain.Width:=682;
FrmMain.Left:=50;
BitBtn1.Glyph:=Image1.Picture.Bitmap;
BitBtn1.Tag:=1;
end
else
begin
FrmMain.Width:=385;
FrmMain.Left:=250;
BitBtn1.Glyph:=Image2.Picture.Bitmap;
BitBtn1.Tag:=0;
end;
end;
procedure TFrmMain.N1Click(Sender: TObject);
begin
FrmMain.Visible:=True;
end;
procedure TFrmMain.N2Click(Sender: TObject);
begin
ADOConnection1.Connected:=False;
ADOConnection2.Connected:=False;
ADOConnection3.Connected:=False;
SSocket.Active:=False;
Application.Terminate;
end;
procedure TFrmMain.WMSysCommand(var Message: TWMSysCommand);
begin
Inherited;//调用先前的处理函数
if (Message.CmdType and $FFF0 = SC_MINIMIZE) then FrmMain.Visible:=False;
end;
procedure TFrmMain.Button5Click(Sender: TObject);
begin
Frm_Eywg.ShowModal;
end;
procedure TFrmMain.SysTray1IconDblClick(Sender: TObject);
begin
FrmMain.Visible:=True;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -