pdf file within a psp file - Posted (1352 Views)
New Member
cadfhs
Posts: 77
77
Hi
Is there anyone out there who can solve this for me? I would like to put pdf files inside files with a psp extension. The reason is that I want to restrict access to the pdf's to members of the society but don't want them to have to enter a password for every pdf. My server don't support .htpasswd so I can not use that, but have code for a password that uses php script. cheers
Neil<
 Sort direction, for dates DESC means newest first  
 Page size 
Posted
Support Moderator
Shaggy
Posts: 6780
6780
psp?
Quickest & easiest way to do what you want is to stream the files through an ASP file that checks whether or not the visitor is logged in before serving the file.
<
Search is your friend “I was having a mildly paranoid day, mostly due to the
fact that the mad priest lady from over the river had
taken to nailing weasels to my front door again.”
Posted
New Member
cadfhs
Posts: 77
77
Shaggy, cheers for this, but I am at a lost how to do it.

Currently the links to these pdf's are on a web page which has a password on it, but I am not 100% happy that this is secure.<
Posted
Support Moderator
Shaggy
Posts: 6780
6780
This would be the basics of it, making the assumption that you're using the Snitz variables. You'll need to create a database connection in this file (you can't include inc_header.asp or any other files that use response.write but you will need to include inc_func_common.asp for the chkstring function) and you'd need to drop the filename of each PDF into a table in that database (FILES, below).
Code:
dim objStream,intPdf,strPdf
if MemberId>0 then
intPdf=request.querystring("pdf")
if len(intPdf)>0 and isnumeric(intPdf) then
intPdf=clng(intPdf)
set objRs=objConn.execute("SELECT FILENAME FROM FILES WHERE FILE_ID="&intPdf)
if not objRs.eof then
strPdf=chkstring(objRs("FILENAME"),"urlpath")
server.scripttimeout=300
set objStream=server.createObject("ADODB.Stream")
objStream.open
objStream.type=1
objStream.loadfromfile server.mappath("/pdfs/"&strPdf)
response.addheader "content-disposition","attachment;filename="&strPdf
response.charset="UTF-8"
response.contenttype="application/x-pdf"
response.binarywrite objStream.read
objStream.close:set objStream=nothing
end if
objRs.close:set objRs=nothing
end if
end if
<
Search is your friend “I was having a mildly paranoid day, mostly due to the
fact that the mad priest lady from over the river had
taken to nailing weasels to my front door again.”
Posted
New Member
cadfhs
Posts: 77
77
Thanks Shaggy
I will have a think about this and see what I can do. Cheers
Neil<
 
You Must enter a message