You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

520 lines
14 KiB
Plaintext

unit sform;
interface
uses
Windows, Classes, Forms, Graphics, SysUtils, StdCtrls, CallExec, MMSystem, plugin, IniFiles,
IdHTTP, IdMultipartFormData, Buttons, Dialogs, Menus, Spin, ExtCtrls, Controls;
{$I NoRTTI.inc}
type
{$IFNDEF RX_D4}
TSysCharSet = set of AnsiChar;
{$ENDIF}
TCharSet = TSysCharSet;
type
TSetForm = class(TForm)
YouAreAdded: TCheckBox;
Label1: TLabel;
TurnedOn: TCheckBox;
ListBox1: TListBox;
pop: TPopupMenu;
N1: TMenuItem;
N2: TMenuItem;
UseProxy: TCheckBox;
Label2: TLabel;
AvoidBan: TCheckBox;
Label4: TLabel;
ReadTMT: TSpinEdit;
opend: TOpenDialog;
ikey: TEdit;
CheckService: TRadioGroup;
loadProxy: TButton;
loadProxyRnQ: TBitBtn;
OKBtn: TButton;
procedure ListBox1MouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
procedure N1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure N2Click(Sender: TObject);
procedure ListBox1KeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure UseProxyClick(Sender: TObject);
procedure AvoidBanClick(Sender: TObject);
procedure ReadTMTChange(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure OKBtnClick(Sender: TObject);
procedure loadProxyRnQClick(Sender: TObject);
procedure loadProxyClick(Sender: TObject);
procedure CheckServiceClick(Sender: TObject);
private
procedure SetProxyParams;
procedure SaveProxy;
procedure SaveSets;
{ Private declarations }
public
procedure ExecAntiBan;
procedure StartTimer;
function ExtractWord(N: Integer; const S: string; const WordDelims: TCharSet): string;
{ Public declarations }
end;
var
SetForm: TSetForm;
glst: TStringList;
MegaTimer: Cardinal;
ba: Integer;
hico1, hico2, hico3, hico4, hico5: TIcon;
num: string;
delims: TCharSet = ['|'];
delimq: TCharSet = [':'];
gotcha, status, gdt: string;
mpf: TIdMultiPartFormDataStream;
GlobalProxy: Integer;
StartProxy: Integer;
ReadTMTnotice, ifPOST: boolean;
wintext: string;
IdH: TIdHTTP;
const
stname = '\InvisCheck.ini';
proxname = '\InvisCheckProxies.ini';
namepl = 'InvisChecker 0.6';
VersionText = namepl + ' <20> Mikanoshi 2009-2014';
implementation
{$R *.dfm}
procedure TSetForm.SaveProxy;
var ini: TIniFile;
begin
ini := TIniFile.Create(string(RQ_GetUserPath + proxname));
ini.WriteString('Main', 'UseProxy', BoolToStr(UseProxy.Checked));
ini.WriteString('Main', 'AvoidBan', BoolToStr(AvoidBan.Checked));
ini.WriteString('Main', 'ReadTMT', IntToStr(ReadTMT.value));
ini.WriteString('Main', 'Proxies', StringReplace(ListBox1.Items.Text, #13#10, '|', [rfReplaceAll, rfIgnoreCase]));
ini.Free;
end;
procedure TSetForm.SaveSets;
begin
if glst.count > 0 then
glst[0] := BoolToStr(YouAreAdded.Checked)
else
glst.Add(BoolToStr(YouAreAdded.Checked));
if glst.count > 1 then
glst[1] := BoolToStr(TurnedOn.Checked)
else
glst.Add(BoolToStr(TurnedOn.Checked));
if glst.count > 0 then
glst[0] := glst[0] + '|' + ikey.Text + '|' + IntToStr(CheckService.ItemIndex);
if TurnedOn.Checked = false then
begin
if MegaTimer <> 0 then
TimeKillEvent(MegaTimer);
RQ_ChangeChatButton(ba, hico3.Handle, namepl)
end
else
begin
if MegaTimer <> 0 then
TimeKillEvent(MegaTimer);
StartTimer;
end;
glst.SaveToFile(string(RQ_GetUserPath + stname));
end;
function ByteToStatus(statusbyte: byte): string;
begin
case statusbyte of
PS_ONLINE:
result := '<27> <20><>';
PS_OCCUPIED:
result := '<27><>';
PS_DND:
result := '<27><> <20><>';
PS_NA:
result := '<27><>';
PS_AWAY:
result := '<27><>';
PS_F4C:
result := '<27><>';
PS_OFFLINE:
result := '<27><>';
PS_UNKNOWN:
result := '<27><>';
PS_EVIL:
result := '<27><>';
PS_DEPRESSION:
result := '<27><>';
end;
end;
function WordPosition(const N: Integer; const S: string; const WordDelims: TCharSet): Integer;
var
count, I: Integer;
begin
count := 0;
I := 1;
result := 0;
while (I <= Length(S)) and (count <> N) do
begin
{ skip over delimiters }
while (I <= Length(S)) and (CharInSet(S[I], WordDelims)) do
Inc(I);
{ if we're not beyond end of S, we're at the start of a word }
if I <= Length(S) then
Inc(count);
{ if not finished, find the end of the current word }
if count <> N then
while (I <= Length(S)) and not(CharInSet(S[I], WordDelims)) do
Inc(I)
else
result := I;
end;
end;
function TSetForm.ExtractWord(N: Integer; const S: string; const WordDelims: TCharSet): string;
var
I: Integer;
Len: Integer;
begin
Len := 0;
I := WordPosition(N, S, WordDelims);
if I <> 0 then
{ find the end of the current word }
while (I <= Length(S)) and not(CharInSet(S[I], WordDelims)) do
begin
{ add the I'th character to result }
Inc(Len);
SetLength(result, Len);
result[Len] := S[I];
Inc(I);
end;
SetLength(result, Len);
end;
procedure TSetForm.SetProxyParams;
begin
if ListBox1.Items.count > 0 then
begin
IdH.ProxyParams.ProxyServer := ExtractWord(1, ListBox1.Items[0], delimq);
IdH.ProxyParams.ProxyPort := StrToInt(ExtractWord(2, ListBox1.Items[0], delimq));
end;
if (ListBox1.Items.count = 0) or (UseProxy.Checked = false) then
begin
IdH.ProxyParams.ProxyServer := '';
IdH.ProxyParams.ProxyPort := 0;
end;
end;
procedure TSetForm.CheckServiceClick(Sender: TObject);
begin
if CheckService.ItemIndex = 0 then
begin
YouAreAdded.Show;
ikey.Show;
end
else
begin
YouAreAdded.Hide;
ikey.Hide;
end
end;
procedure TSetForm.ExecAntiBan;
begin
if SetForm.ListBox1.Items.count >= 2 then
begin
if GlobalProxy < SetForm.ListBox1.Items.count - 1 then
Inc(GlobalProxy)
else
GlobalProxy := 0;
RQ_ChangeChatButton(ba, hico3.Handle, AnsiString(wintext));
IdH.ProxyParams.ProxyServer := ExtractWord(1, ListBox1.Items[GlobalProxy], delimq);
IdH.ProxyParams.ProxyPort := StrToInt(ExtractWord(2, ListBox1.Items[GlobalProxy], delimq));
end;
end;
procedure FNTimeCallBack(uTimerID, uMessage: UINT; dwUser, dw1, dw2: DWORD); stdcall;
var I, X: Integer;
fnd: string;
uin: Integer;
begin
if SetForm.TurnedOn.Checked = false then
exit;
uin := RQ_GetChatUIN;
fnd := '';
if ifPOST = true then
begin
if ReadTMTnotice = true then
begin
if SetForm.UseProxy.Checked = false then
wintext := '<27><> <20><> <20><> ' + IntToStr(uin) + '. <20><> <20><>: ' + IntToStr(SetForm.ReadTMT.value)
else
wintext := '<27><> <20><> <20><> ' + IntToStr(uin) + '. <20><>: ' + IntToStr(GlobalProxy + 1) + ' / ' +
IntToStr(SetForm.ListBox1.Items.count) + ', <20><> <20><>: ' + IntToStr(SetForm.ReadTMT.value)
end
else
begin
if SetForm.UseProxy.Checked = false then
wintext := '<27><> <20><> <20><> ' + IntToStr(uin)
else
wintext := '<27><> <20><> <20><> ' + IntToStr(uin) + '. <20><>: ' + IntToStr(GlobalProxy + 1) + ' / ' +
IntToStr(SetForm.ListBox1.Items.count);
end;
RQ_ChangeChatButton(ba, hico4.Handle, AnsiString(wintext));
exit;
end;
if uin <> 0 then
begin
if glst.count >= 3 then
for I := 2 to glst.count - 1 do
if pos(IntToStr(uin), glst[I]) > 0 then
begin
fnd := glst[I];
break;
end;
num := SetForm.ExtractWord(1, fnd, delims);
status := SetForm.ExtractWord(2, fnd, delims);
gdt := SetForm.ExtractWord(3, fnd, delims);
if not(num = '') and not(num = '0') then
begin
if (pos('<27><>', status) > 0) and (RQ_GetContactInfo(StrToInt(num)).status = PS_OFFLINE) then
RQ_ChangeChatButton(ba, hico5.Handle, AnsiString(num + ': ' + status + ' [' + gdt + ']'))
else if (pos('<27><>', status) > 0) and (RQ_GetContactInfo(StrToInt(num)).status = PS_OFFLINE) or
(RQ_GetContactInfo(StrToInt(num)).Invisible = true) then
RQ_ChangeChatButton(ba, hico1.Handle, AnsiString(num + ': ' + status + ' [' + gdt + ']'))
else if (pos('<27><>', status) > 0) and (RQ_GetContactInfo(uin).status <> PS_OFFLINE) and
(RQ_GetContactInfo(uin).Invisible = false) and (RQ_GetContactInfo(uin).status <> PS_UNKNOWN) then
begin
if glst.count >= 3 then
for X := 2 to glst.count - 1 do
if pos(IntToStr(uin), glst[X]) > 0 then
begin
glst[X] := IntToStr(uin) + '|' + ByteToStatus(RQ_GetContactInfo(uin).status) + '|' + gdt;
glst.SaveToFile(string(RQ_GetUserPath + stname));
end;
RQ_ChangeChatButton(ba, hico2.Handle, AnsiString(num + ': ' + status + ' [' + gdt + ']'));
end
else
RQ_ChangeChatButton(ba, hico2.Handle, AnsiString(num + ': ' + status + ' [' + gdt + ']'))
end
else
RQ_ChangeChatButton(ba, hico2.Handle, namepl);
end;
end;
procedure TSetForm.StartTimer;
begin
MegaTimer := TimeSetEvent(500, 10000, @FNTimeCallBack, 100, TIME_PERIODIC);
end;
procedure TSetForm.ListBox1MouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
if Button = mbRight then
pop.Popup(mouse.CursorPos.X, mouse.CursorPos.Y);
end;
procedure TSetForm.N1Click(Sender: TObject);
var NewProx: string;
begin
NewProx := InputBox('<27><> <20><> <20> <20><> <20><>', '<27><> 255.255.255.255:PORT', '0.0.0.0:0');
if (NewProx <> '') and (NewProx <> '0.0.0.0:0') then
begin
ListBox1.Items.Add(NewProx);
SetProxyParams;
SaveProxy;
GlobalProxy := 0;
end;
end;
procedure TSetForm.FormCreate(Sender: TObject);
var ini: TIniFile; txt: string;
begin
ifPOST := false;
GlobalProxy := 0;
Label1.Caption := VersionText;
if fileexists(string(RQ_GetUserPath + proxname)) then
begin
ini := TIniFile.Create(string(RQ_GetUserPath + proxname));
UseProxy.Checked := StrToBool(ini.ReadString('Main', 'UseProxy', '0'));
AvoidBan.Checked := StrToBool(ini.ReadString('Main', 'AvoidBan', '0'));
AvoidBan.Enabled := UseProxy.Checked;
ReadTMT.value := StrToInt(ini.ReadString('Main', 'ReadTMT', '30000'));
ListBox1.Items.Clear;
txt := ini.ReadString('Main', 'Proxies', '');
if Length(txt) > 0 then
ListBox1.Items.Text := StringReplace(txt, '|', #13#10, [rfReplaceAll, rfIgnoreCase]);
ini.Free;
SetProxyParams;
end
else
begin
// SaveSets;
SetProxyParams;
SaveProxy;
end;
end;
procedure TSetForm.N2Click(Sender: TObject);
begin
if ListBox1.ItemIndex >= 0 then
begin
ListBox1.Tag := ListBox1.ItemIndex;
ListBox1.DeleteSelected;
if ListBox1.Items.count > 0 then
if ListBox1.Tag < ListBox1.Items.count - 1 then
ListBox1.ItemIndex := ListBox1.Tag
else
ListBox1.ItemIndex := ListBox1.Items.count - 1;
SetProxyParams;
SaveProxy;
GlobalProxy := 1;
end;
end;
procedure TSetForm.ListBox1KeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
begin
if Key = VK_DELETE then
N2.Click
end;
procedure TSetForm.FormClose(Sender: TObject; var Action: TCloseAction);
begin
SaveSets;
SetProxyParams;
SaveProxy;
end;
procedure TSetForm.UseProxyClick(Sender: TObject);
begin
SetProxyParams;
if UseProxy.Checked = true then
AvoidBan.Enabled := true
else
AvoidBan.Enabled := false;
end;
procedure TSetForm.AvoidBanClick(Sender: TObject);
begin
if AvoidBan.Checked = false then
GlobalProxy := 0;
end;
procedure TSetForm.ReadTMTChange(Sender: TObject);
begin
IdH.ReadTimeout := ReadTMT.value;
end;
procedure TSetForm.FormShow(Sender: TObject);
begin
if glst.count > 0 then
begin
if pos('|', glst[0]) = 0 then
glst[0] := glst[0] + '|';
if SetForm.ExtractWord(1, glst[0], delims) <> '' then
SetForm.YouAreAdded.Checked := StrToBool(SetForm.ExtractWord(1, glst[0], delims));
if SetForm.ExtractWord(2, glst[0], delims) <> '' then
SetForm.ikey.Text := SetForm.ExtractWord(2, glst[0], delims);
if SetForm.ExtractWord(3, glst[0], delims) <> '' then
SetForm.CheckService.ItemIndex := StrToInt(SetForm.ExtractWord(3, glst[0], delims));
end;
if glst.count > 1 then
TurnedOn.Checked := StrToBool(glst[1]);
if CheckService.ItemIndex = 0 then
begin
YouAreAdded.Show;
ikey.Show;
end
else
begin
YouAreAdded.Hide;
ikey.Hide;
end
end;
procedure TSetForm.OKBtnClick(Sender: TObject);
begin
SetForm.close
end;
procedure TSetForm.loadProxyRnQClick(Sender: TObject);
var ls: TStringList;
I: Integer;
tmp: string;
// auth: boolean;
begin
exit;
tmp := '';
// auth := false;
ls := TStringList.Create;
ls.LoadFromFile(string(RQ_GetUserPath + '\rnq.ini'));
for I := 0 to ls.count - 1 do
begin
if pos('proxy-host=', ls[I]) > 0 then
tmp := copy(ls[I], pos('proxy-host=', ls[I]) + 11, Length(ls[I]));
if pos('proxy-port=', ls[I]) > 0 then
tmp := tmp + ':' + copy(ls[I], pos('proxy-port=', ls[I]) + 11, Length(ls[I]));
{
if pos('proxy-user=', ls[i]) > 0 then tmpA := ':' + copy(ls[i], pos('proxy-user=', ls[i])+11, length(ls[i]));
if pos('proxy-pass=', ls[i]) > 0 then tmpA := tmpA + ':' + copy(ls[i], pos('proxy-pass=', ls[i])+11, length(ls[i]));
if pos('proxy-auth=Yes', ls[i]) > 0 then auth := true;
}
end;
if tmp <> '' then
{ if auth = true then
ListBox1.items.Add(tmp + tmpA)
else }
ListBox1.Items.Add(tmp);
SetProxyParams;
SaveProxy;
ls.Free
end;
procedure TSetForm.loadProxyClick(Sender: TObject);
var I: Integer; l: TStringList;
begin
if opend.Execute then
begin
l := TStringList.Create;
l.LoadFromFile(opend.FileName);
for I := 0 to l.count - 1 do
if l[I] <> '' then
ListBox1.Items.Add(l[I]);
l.Free;
end;
end;
end.