Re: Downloads for subsrcibers only

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Depends where you store the file, if you store the file in the database,
then it's much easier to do it.
Your idea (as it is right now) won't work, because anyone will be able to
copy and paste the link to your PDF document and download it (thus easily
overriding the logic you have in the page).
I've attached a class, called the FileManager class, which handles saving
and displaying data (virtually all types) from the database. It's extremely
easy to use. The usage is demonstrated in download.php (also attached). You
have to add some logic in order to restrict access to your files.

--
itoctopus - http://www.itoctopus.com
"Mário Gamito" <gamito@xxxxxxxxx> wrote in message
news:460F732B.801@xxxxxxxxxxxx
> Hi,
>
> I made this site in PHP that has a page with some PDFs to download.
> My costumer wants that only subscribed people are allowed to download
> the PDFs.
>
> I've already made the subscrbe and login mechanism.
>
> Now, my question for you is about letting only subscribers download the
> PDFs.
> What is the best approach ?
> Register a session when they login and then in the PDFs page apply a
>
> if email is registered
>   you can download the PDFs
> else
>   you can't
>
> Something like this ?
> Or is it there a better way ?
>
> Any help would be appreciated.
>
> Warm Regards
> --
> :wq! Mário Gamito


begin 666 download.php
M/#]P:' -"@ES97-S:6]N7V-A8VAE7VQI;6ET97(H)VYO;F4G*3L-"@ER97%U
M:7)E*")I;F-L=61E<R]C;VYF:6<N<&AP(BD[#0H)+R]-:7-C96QL86YE;W5S
M.CIS86YI=&EZ92@D7T=%5"D[#0H))&9I;&5?:60@/2!H=&UL96YT:71I97,H
M)%]'151;)V9I;&5?:60G72P@14Y47U%53U1%4RD[#0H)1FEL94UA;F%G97(Z
8.F=E="@D9FEL95]I9"P@)&1B*3L-"C\^
`
end

begin 666 FileManager.class.php
M/#]P:' -"@DO*@T*"0E 8VQA<W,@1FEL94UA;F%G97(-"@D)0&1E<V-R:7!T
M:6]N(%1H:7,@8VQA<W,@:&%N9&QE<R!I;G1E<F%C=&EO;B!W:71H($9I;&5S
M#0H)"4!C;W!Y<FEG:'0@:71O8W1O<'5S(#(P,#<@+2!4:&4@1V5N;V,@3&EB
M<F%R>0T*"2HO#0H)8VQA<W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%D97(H(D-O;G1E;G0M='EP93H@(BXD<F5S=6QT6S!=6R=F:6QE
M7W1Y<&4G72XB.R!F:6QE;F%M93TB+B1R97-U;'1;,%U;)V9I;&5?;F%M92==
M*3L-"@D)"65L<V4-"@D)"0EH96%D97(H(D-O;G1E;G0M1&ES<&]S:71I;VXZ
M(&%T=&%C:&UE;G0[(&9I;&5N86UE/2(N)')E<W5L=%LP75LG9FEL95]N86UE
M)UTI.PT*"0D)96-H;R@D<F5S=6QT6S!=6R=F:6QE7V)I;F%R>2==*3L-"@D)
M?0T*"0D-"@D)+RH-"@D)"2I 9G5N8W1I;VX@9&5L971E#0H)"0DJ0&1E<V,@
M5&AI<R!F=6YC=&EO;B!D96QE=&4@82!F:6QE(&9R;VT@=&AE(&1A=&%B87-E
M#0H)"0DJ0'!A<F%M(&EN=&5G97(@)&9I;&5?:60@5&AE(&ED(&]F('1H92!F
M:6QE('1O(&)E(&1E;&5T960-"@D)"2I <&%R86T@;V)J96-T("1D8B!4:&4@
M9&%T86)A<V4@:&%N9&QE#0H)"0DJ0'-T871I8PT*"0DJ+PT*"0ES=&%T:6,@
M9G5N8W1I;VX@9&5L971E*"1F:6QE7VED+" D9&(I>PT*"0D))'-Q;" ]("=$
M14Q%5$4@1E)/32!F:6QE(%=(15)%(&9I;&5?:60]7"<D9FEL95]I9%PG)SL-
M"@D)"21R97-U;'0]("1D8BT^<75E<GDH)'-Q;"D[#0H)"7T-"@D)#0H)?0T*
"/SX`
`
end

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux