break up the download into two steps:
1) login & authenticate. Use the same scheme that you use for the rest of your site
and if the user has the correct permissions
2) instead of print()ing html text to the screen, just output the binary file instead,
this way you can keep the files to download outside of your web directory, and have php open then only when some other script has authenticated the user
does that make sense?