J
johnsun
Unregistered / Unconfirmed
GUEST, unregistred user!
我做了一个下载管理程序,用delphi写的isapi,主要根据登录者的权限实现文件的下载,问题是:
1、大部分机器可以对word文档下载后自动在IE里打开,但有小部分机器下载word文档后虽然也
象打开的样子,但是页面左上角只显示一个“S”型的图标,并无文档正文,但是如果页面回退
后再前进就可以在页面里看到word文档,但是winword出错
2、如果没有数据库操作,不进行权限校验,这些机器能够正常打开word文档
3、源程序如下:
procedure TWebModule1.WebModule1WebActionItem1Action(Sender: TObject;
Request: TWebRequest; Response: TWebResponse; var Handled: Boolean);
var s,sfz,bz1,zfbh1:string;
lx1,jb1:byte;
bbzz:boolean;
begin
bbzz:=false;
s:=request.queryfields.values['s'];
sfz:=request.queryfields.values['sfz'];
sfz:=getgh(sfz,request.remoteaddr);
if sfz<>'' then
begin
with getquery do
begin
sql.clear;
sql.add('select lx,jb,bz,zfbh from xxb where bh=:bh');
parambyname('bh').asstring:=copy(s,1,16);
open;
if RecordCount<>0 then
begin
lx1:=fieldbyname('lx').asinteger;
jb1:=fieldbyname('jb').asinteger;
bz1:=fieldbyname('bz').asstring;
zfbh1:=fieldbyname('zfbh').asstring;
close;
sql.clear;
sql.add('select * from yhb where gh=:gh');
parambyname('gh').asstring:=sfz;
open;
case lx1 of
1:if (fieldbyname('rszl').asinteger mod 100)>=jb1 then bbzz:=true;
2:if (fieldbyname('nbkh').asinteger mod 100)>=jb1 then bbzz:=true;
3:if (fieldbyname('bbcx').asinteger mod 100)>=jb1 then bbzz:=true;
4:if (fieldbyname('xxcx').asinteger mod 100)>=jb1 then bbzz:=true;
5:if (fieldbyname('zlgx').asinteger mod 100)>=jb1 then bbzz:=true;
6:if (fieldbyname('khzl').asinteger mod 100)>=jb1 then bbzz:=true;
7:if (fieldbyname('byxt').asinteger mod 100)>=jb1 then bbzz:=true;
9:if (fieldbyname('lczz').asinteger mod 100)>=jb1 then bbzz:=true;
10:if (fieldbyname('tmp1').asinteger mod 100)>=jb1 then bbzz:=true;
20:if (fieldbyname('tmp2').asinteger mod 100)>=jb1 then bbzz:=true;
21:if (fieldbyname('tmp3').asinteger mod 100)>=jb1 then bbzz:=true;
11:if pos(sfz,bz1)>0 then
begin
bbzz:=true;
if zfbh1<>'' then s:=zfbh1+copy(s,17,255);
end;
end;
end
else
bbzz:=false;
close;
free;
end;
if FileExists('gd:/nbgl/'+s) and bbzz then
sendfile(response,'d:/nbgl/'+s)
else begin
Response.ContentType := 'text/html';
response.content:='&Icirc;&Auml;&frac14;&thorn;&sup2;&raquo;&acute;&aelig;&Ocirc;&Uacute;&pound;&iexcl;';
end;
end
else begin
Response.ContentType := 'text/html';
response.content:='&Icirc;&Auml;&frac14;&thorn;&sup2;&raquo;&acute;&aelig;&Ocirc;&Uacute;&pound;&iexcl;';
end;
//handled:=true;
end;
procedure TWebModule1.sendfile(iResponse: TwebResponse; iFilename:string);
var FileStream:TFileStream;
begin
filestream := TFileStream.Create(ifilename, fmOpenRead and fmShareDenyWrite);
try
Response.ContentStream := filestream; {Response will free the stream}
Response.ContentType := 'application/file';
Response.SetCustomHeader('Content-Disposition','filename='+copy(ifilename,25,255));
except
filestream.free();
Response.ContentType := 'text/html';
response.content:='&Iuml;&Acirc;&Ocirc;&Oslash;&acute;í&Icirc;ó&pound;&not;&Ccedil;&euml;&Oacute;&euml;&Iuml;&micro;&Iacute;&sup3;&sup1;&Uuml;&Agrave;í&Ocirc;±&Aacute;&ordf;&Iuml;&micro;&pound;&iexcl;';
end;
end;
请各位大侠不吝赐教。
1、大部分机器可以对word文档下载后自动在IE里打开,但有小部分机器下载word文档后虽然也
象打开的样子,但是页面左上角只显示一个“S”型的图标,并无文档正文,但是如果页面回退
后再前进就可以在页面里看到word文档,但是winword出错
2、如果没有数据库操作,不进行权限校验,这些机器能够正常打开word文档
3、源程序如下:
procedure TWebModule1.WebModule1WebActionItem1Action(Sender: TObject;
Request: TWebRequest; Response: TWebResponse; var Handled: Boolean);
var s,sfz,bz1,zfbh1:string;
lx1,jb1:byte;
bbzz:boolean;
begin
bbzz:=false;
s:=request.queryfields.values['s'];
sfz:=request.queryfields.values['sfz'];
sfz:=getgh(sfz,request.remoteaddr);
if sfz<>'' then
begin
with getquery do
begin
sql.clear;
sql.add('select lx,jb,bz,zfbh from xxb where bh=:bh');
parambyname('bh').asstring:=copy(s,1,16);
open;
if RecordCount<>0 then
begin
lx1:=fieldbyname('lx').asinteger;
jb1:=fieldbyname('jb').asinteger;
bz1:=fieldbyname('bz').asstring;
zfbh1:=fieldbyname('zfbh').asstring;
close;
sql.clear;
sql.add('select * from yhb where gh=:gh');
parambyname('gh').asstring:=sfz;
open;
case lx1 of
1:if (fieldbyname('rszl').asinteger mod 100)>=jb1 then bbzz:=true;
2:if (fieldbyname('nbkh').asinteger mod 100)>=jb1 then bbzz:=true;
3:if (fieldbyname('bbcx').asinteger mod 100)>=jb1 then bbzz:=true;
4:if (fieldbyname('xxcx').asinteger mod 100)>=jb1 then bbzz:=true;
5:if (fieldbyname('zlgx').asinteger mod 100)>=jb1 then bbzz:=true;
6:if (fieldbyname('khzl').asinteger mod 100)>=jb1 then bbzz:=true;
7:if (fieldbyname('byxt').asinteger mod 100)>=jb1 then bbzz:=true;
9:if (fieldbyname('lczz').asinteger mod 100)>=jb1 then bbzz:=true;
10:if (fieldbyname('tmp1').asinteger mod 100)>=jb1 then bbzz:=true;
20:if (fieldbyname('tmp2').asinteger mod 100)>=jb1 then bbzz:=true;
21:if (fieldbyname('tmp3').asinteger mod 100)>=jb1 then bbzz:=true;
11:if pos(sfz,bz1)>0 then
begin
bbzz:=true;
if zfbh1<>'' then s:=zfbh1+copy(s,17,255);
end;
end;
end
else
bbzz:=false;
close;
free;
end;
if FileExists('gd:/nbgl/'+s) and bbzz then
sendfile(response,'d:/nbgl/'+s)
else begin
Response.ContentType := 'text/html';
response.content:='&Icirc;&Auml;&frac14;&thorn;&sup2;&raquo;&acute;&aelig;&Ocirc;&Uacute;&pound;&iexcl;';
end;
end
else begin
Response.ContentType := 'text/html';
response.content:='&Icirc;&Auml;&frac14;&thorn;&sup2;&raquo;&acute;&aelig;&Ocirc;&Uacute;&pound;&iexcl;';
end;
//handled:=true;
end;
procedure TWebModule1.sendfile(iResponse: TwebResponse; iFilename:string);
var FileStream:TFileStream;
begin
filestream := TFileStream.Create(ifilename, fmOpenRead and fmShareDenyWrite);
try
Response.ContentStream := filestream; {Response will free the stream}
Response.ContentType := 'application/file';
Response.SetCustomHeader('Content-Disposition','filename='+copy(ifilename,25,255));
except
filestream.free();
Response.ContentType := 'text/html';
response.content:='&Iuml;&Acirc;&Ocirc;&Oslash;&acute;í&Icirc;ó&pound;&not;&Ccedil;&euml;&Oacute;&euml;&Iuml;&micro;&Iacute;&sup3;&sup1;&Uuml;&Agrave;í&Ocirc;±&Aacute;&ordf;&Iuml;&micro;&pound;&iexcl;';
end;
end;
请各位大侠不吝赐教。