Y
yemeng
Unregistered / Unconfirmed
GUEST, unregistred user!
其实,代理服务器的原理是很简单的,我给武汉一家大网吧写过一个计费程序,
具体使用WEBSHOES控件,修改部分代码,让端口设为80,将客户访问的URL地址由程序以流的形式返回给服务器,由服务器以流的形式返回给浏览器。部分代码如下:
HttpCli1 := THttpCli.Create(nil);
MyStream := TMemoryStream.Create;
HttpCli1.RcvdStream := MyStream;
try
HttpCli1.URL := RequestInfo.Document;
temp := Thread.Connection.RemotAddress;
HttpCli1.Get;
Query_temp := TQuery.Create(nil);
Query_temp.DatabaseName := 'jf';
Query_Temp.SQL.Clear;
Query_temp.SQL.Add('select * from xtsjk where IP='+''''+temp+'''');
Query_temp.Open;
if ((Query_temp.FieldByName('Start').AsString = 'T' ) and(Query_temp.FieldByName('restTime').AsInteger>0) and (copy(Query_temp.FieldByName('username').AsString,1,1)='S')) then
begin
if (RequestInfo.Command)='GET' then
begin
with Thread.Connection do
begin
Memo1.Lines.Clear;
Memo1.Lines.Add(RequestInfo.Document);
Memo1.Lines.Add(RemotAddress);
WriteStream(MyStream,true);
end;
end
else
end;
finally
具体使用WEBSHOES控件,修改部分代码,让端口设为80,将客户访问的URL地址由程序以流的形式返回给服务器,由服务器以流的形式返回给浏览器。部分代码如下:
HttpCli1 := THttpCli.Create(nil);
MyStream := TMemoryStream.Create;
HttpCli1.RcvdStream := MyStream;
try
HttpCli1.URL := RequestInfo.Document;
temp := Thread.Connection.RemotAddress;
HttpCli1.Get;
Query_temp := TQuery.Create(nil);
Query_temp.DatabaseName := 'jf';
Query_Temp.SQL.Clear;
Query_temp.SQL.Add('select * from xtsjk where IP='+''''+temp+'''');
Query_temp.Open;
if ((Query_temp.FieldByName('Start').AsString = 'T' ) and(Query_temp.FieldByName('restTime').AsInteger>0) and (copy(Query_temp.FieldByName('username').AsString,1,1)='S')) then
begin
if (RequestInfo.Command)='GET' then
begin
with Thread.Connection do
begin
Memo1.Lines.Clear;
Memo1.Lines.Add(RequestInfo.Document);
Memo1.Lines.Add(RemotAddress);
WriteStream(MyStream,true);
end;
end
else
end;
finally