Snitz Forums 2000
Snitz Forums 2000
Home | Profile | Register | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Community Forums
 Community Discussions (All other subjects)
 pdf file within a psp file
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

cadfhs
New Member

United Kingdom
77 Posts

Posted - 24 May 2008 :  11:07:25  Show Profile  Visit cadfhs's Homepage  Reply with Quote
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<

Shaggy
Support Moderator

Ireland
6780 Posts

Posted - 26 May 2008 :  04:41:05  Show Profile  Reply with Quote
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.”
Go to Top of Page

cadfhs
New Member

United Kingdom
77 Posts

Posted - 26 May 2008 :  05:21:44  Show Profile  Visit cadfhs's Homepage  Reply with Quote
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.<
Go to Top of Page

Shaggy
Support Moderator

Ireland
6780 Posts

Posted - 26 May 2008 :  05:33:39  Show Profile  Reply with Quote
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).
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.”
Go to Top of Page

cadfhs
New Member

United Kingdom
77 Posts

Posted - 26 May 2008 :  11:04:41  Show Profile  Visit cadfhs's Homepage  Reply with Quote
Thanks Shaggy
I will have a think about this and see what I can do.
Cheers
Neil<
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
Snitz Forums 2000 © 2000-2021 Snitz™ Communications Go To Top Of Page
This page was generated in 0.1 seconds. Powered By: Snitz Forums 2000 Version 3.4.07