?
Solved

Authenticate an .exe file

Posted on 2004-04-22
2
Medium Priority
?
224 Views
Last Modified: 2008-07-03
Hello,

Using PHP/MySQL I have a login form.  When a user successfuly logs in a session is established and they are redirected to a downloads page. This downloads page checks to ensure the session is established.  If it is, then the user can view the possible downloads.  One of the downloads is a .exe file.  Well, how can I ensure that the .exe link is authenticated as well?  For example, what is the user types in the address bar www.website.com/downloads/program.exe without logging in.  Well, in theory they have bypassed the authentication process and are able to get to the .exe.

Thanks in advance.
0
Comment
Question by:rudyflyer
2 Comments
 
LVL 6

Accepted Solution

by:
CosminB earned 500 total points
ID: 10896628
you can put your files outside your webserver's directory and download them width a download script
smth. like this
======= download list ==========
<a href="download.php?file=file1.exe">
<a href="download.php?file=file2.exe">
<a href="download.php?file=file3.exe">

======= download script ========
<?php
header('Content-type: ...'); //you can find the apropiate headers on http://www.php.net/header

if ($_GET['file'] == 'file1.exe')
   readfile('/path/to/your/downloads/file1.exe')

?>
0
 
LVL 10

Expert Comment

by:eeBlueShadow
ID: 10899111
Like CosminB says, what you essentially do is to sit the file somewhere on your server and collect it through PHP. This also has the advantage that you use the PHP file to update a counter for example, of how many times each file was downloaded

One extension to this is that you don't actually have to move the exe files. Create a file called .htaccess in the same folder as the .exes (or add the following lines to the file if it already exists)

<Files *.exe>
    Order deny,allow
    Deny from all
</Files>

This will make it impossible for people to get directly to the program files (assumes the server is Apache)
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
There are times when I have encountered the need to decompress a response from a PHP request. This is how it's done, but you must have control of the request and you can set the Accept-Encoding header.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
Suggested Courses
Course of the Month16 days, 9 hours left to enroll

864 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question