📄 upip.pas
字号:
end; }
end;
except
Label1.Caption:='FTP更新IP完成.但Http访问出错.';
end;
end;
function Replace(Str: String;Find:string;ToStr:String): string;
var
Text,A,B: String;
i,k: Integer;
begin
Text:=Str;
for k:=1 to Length(Str) do
begin
i:=pos(Find,Text);
if i>0 then
begin
Delete(Text,i,Length(Find));
A:=copy(Text,1,i-1);
B:= copy(Text,i,Length(Text));
Text:=A+ToStr+B;
end else break;
end;
Result := Text;
end;
procedure TUpIpDate.FtpButton1Click(Sender: TObject);
begin
if FTPAdder.Text='' then
begin
Label1.Caption :='请输入FTP服务器地址!';
Exit;
end;
if FTPUser.Text='' then
begin
Label1.Caption :='请输入FTP用户名!';
Exit;
end;
if FTPPass1.Text<>FTPPass2.Text then
begin
Label1.Caption :='两次密码输入不一样!';
FTPPass1.Text:='';
FTPPass2.Text:='';
Exit;
end;
Get_UserFile;
end;
function TUpIpDate.Update(Body,UpdateS:String):Boolean;
var
i:integer;
begin
Result:=False;
i:=pos(UpdateS,Body); //Update:='修改成功'
if i>=1 then Result:=True;
end;
procedure XWDns;
var
username,pass,Temp:string;
tmphttp:string;
ProxyStr: TProxyServerInf;
begin
try
username:=UpIpDate.Xwuser.Text;
pass:= UpIpDate.Xwpass.Text;
if GetDefaultProxyServer(ProxyStr) then {本地设置了代理服务器}
begin
if ProxyStr.httpName<>'' then
begin
UpIpDate.IdHTTP2.ProxyParams.ProxyServer:=ProxyStr.httpName;
UpIpDate.IdHTTP2.ProxyParams.ProxyPort:=ProxyStr.httpport;
end;
end else
begin
UpIpDate.IdHTTP2.ProxyParams.ProxyServer:='';
UpIpDate.IdHTTP2.ProxyParams.ProxyPort:=0;
end;
tmphttp:='http://www.3322.org/dyndns/update?system=dyndns&hostname='+UpIpDate.XwEdit.Text+'&myip='+UpIpDate.XWComboBox.Text+'&wildcard=OFF&mx=&backmx=NO';
UpIpDate.IdHTTP2.Request.Username :=username;
UpIpDate.IdHTTP2.Request.Password :=pass;
Temp:=UpIpDate.IdHTTP2.Get(tmphttp);
try
UpIpDate.IdHTTP2.Disconnect;
except
end;
if UpIpDate.Update(Temp,'good') then begin
UpIpDate.Label1.Caption :='更新IP成功!请等待服务器上线!';
{ if HgzVip.isSound then
begin
try
sndplaysound('',snd_async);
sndplaysound(Pchar(HgzVip.UpIPok),snd_async);
except
end;
end; }
end
else begin
if pos('badauth',Temp)>0 then begin
UpIpDate.Label1.Caption :='更新IP失败!用户名或密码不正确!';
UpIpDate.XWButton.Enabled:=True;
Exit;
end;
UpIpDate.Label1.Caption :='更新IP失败!请检查输入信息是否正确!'+Temp;
end;
Except
UpIpDate.Label1.Caption :='更新IP错误!请检查网络!';
end;
UpIpDate.XWButton.Enabled:=True;
end;
type
TXWDnsThread = class(TThread)
public
procedure Execute; override;
end;
procedure TXWDnsThread.Execute;
begin
XWDns;
Terminate;
end;
procedure TUpIpDate.XWButtonClick(Sender: TObject);
begin
if XwEdit.Text='' then
begin
Label1.Caption:='对不起!好像您没有填写域名噢!请您填上吧!';
Exit;
end;
if Xwuser.Text='' then
begin
Label1.Caption:='对不起!请填写用户名!';
Exit;
end;
if Xwpass.Text='' then
begin
Label1.Caption:='对不起!请填写密码!';
Exit;
end;
XWButton.Enabled:=False;
Label1.Caption:='开始更新IP地址到域名...';
TXWDnsThread.Create(false);
end;
procedure TUpIpDate.Label11Click(Sender: TObject);
begin
ShellExecute(0, 'Open','http://www.3322.org/',nil, nil, SW_Show);
end;
procedure TUpIpDate.NMFTP1Success(Trans_Type: TCmdType);
begin
//Label1.Caption :='成功.';
if Trans_Type=cmdUpload then
begin
AfterGetFile(nil);
NMFTP1.Disconnect;
end;
end;
procedure TUpIpDate.NMFTP1Connect(Sender: TObject);
begin
Label1.Caption :='连接FTP成功.';
end;
procedure TUpIpDate.NMFTP1ConnectionFailed(Sender: TObject);
begin
Label1.Caption :='连接FTP失败.';
end;
procedure TUpIpDate.NMFTP1Error(Sender: TComponent; Errno: Word;
Errmsg: String);
begin
Label1.Caption :='Error..';
end;
procedure TUpIpDate.NMFTP1Status(Sender: TComponent; Status: String);
begin
Label1.Caption :=Status;
end;
procedure TUpIpDate.FormShow(Sender: TObject);
begin
SetWindowLong(XWButton.Handle, GWL_STYLE, WS_CHILD or WS_VISIBLE or BS_FLAT);
SetWindowLong(FtpButton1.Handle, GWL_STYLE, WS_CHILD or WS_VISIBLE or BS_FLAT);
end;
procedure TUpIpDate.FormCreate(Sender: TObject);
begin
GetLocalIPtoHttp;
end;
procedure TUpIpDate.Label10Click(Sender: TObject);
begin
Shellexecute(handle, nil, pchar('http://www.comexe.cn/usr_lgin.php?page='), nil, nil, sw_shownormal);
end;
procedure TUpIpDate.Label12Click(Sender: TObject);
begin
Shellexecute(handle, nil, pchar('http://www.vicp.net'), nil, nil, sw_shownormal);
end;
procedure TUpIpDate.CheckRadioBox1Click(Sender: TObject);
begin
try
if CheckRadioBox1.Checked then
begin
Main.myinifile.writestring('DNS','AutoSave','1');
Main.myinifile.writestring('DNS','Dns',XwEdit.text);
Main.myinifile.writestring('DNS','User',Xwuser.text);
Main.myinifile.writestring('DNS','Password',Xwpass.text);
end else begin
Main.myinifile.writestring('DNS','AutoSave','0');
Main.myinifile.writestring('DNS','User','');
Main.myinifile.writestring('DNS','Password','');
end;
except
end;
end;
procedure TUpIpDate.RadioBox1Click(Sender: TObject);
begin
try
if RadioBox1.Checked then
begin
Main.myinifile.writestring('FTP', 'AutoSave', '1');
Main.myinifile.writestring('FTP', 'FTPServer', FTPAdder.text);
Main.myinifile.writestring('FTP', 'FTPport', FTPPort.text);
Main.myinifile.writestring('FTP', 'FTPUser', FTPUser.Text);
Main.myinifile.writestring('FTP', 'Password', FTPPass1.Text);
Main.myinifile.writestring('FTP', 'IpFile', IpFileEdit.Text);
end else begin
Main.myinifile.writestring('FTP', 'AutoSave', '0');
Main.myinifile.writestring('FTP', 'FTPServer', '');
Main.myinifile.writestring('FTP', 'FTPport', '21');
Main.myinifile.writestring('FTP', 'FTPUser', '');
Main.myinifile.writestring('FTP', 'Password', '');
Main.myinifile.writestring('FTP', 'IpFile', 'ip.txt');
end;
except
end;
end;
procedure TUpIpDate.FormClose(Sender: TObject; var Action: TCloseAction);
begin
try
if RadioBox1.Checked then
begin
Main.myinifile.writestring('FTP','AutoSave','1');
Main.myinifile.writestring('FTP','FTPServer',FTPAdder.text);
Main.myinifile.writestring('FTP','FTPport',FTPPort.text);
Main.myinifile.writestring('FTP','FTPUser',FTPUser.Text);
Main.myinifile.writestring('FTP','Password',FTPPass1.Text);
Main.myinifile.writestring('FTP','IpFile',IpFileEdit.Text);
Main.myinifile.writestring('FTP','Http',httpEdit.Text);
end else begin
Main.myinifile.writestring('FTP','AutoSave','0');
Main.myinifile.writestring('FTP','FTPServer','');
Main.myinifile.writestring('FTP','FTPport','21');
Main.myinifile.writestring('FTP','FTPUser','');
Main.myinifile.writestring('FTP','Password','');
Main.myinifile.writestring('FTP','IpFile','ip.txt');
Main.myinifile.writestring('FTP','Http','');
end;
except
end;
try
if CheckRadioBox1.Checked then
begin
Main.myinifile.writestring('DNS','AutoSave','1');
Main.myinifile.writestring('DNS','Dns',XwEdit.text);
Main.myinifile.writestring('DNS','User',Xwuser.text);
Main.myinifile.writestring('DNS','Password',Xwpass.text);
end else begin
Main.myinifile.writestring('DNS','AutoSave','0');
Main.myinifile.writestring('DNS','User','');
Main.myinifile.writestring('DNS','Password','');
end;
except
end;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -