Show secured file

Reply

Join Date: Jul 2006
Posts: 6
Reputation: dcarrillo18 is an unknown quantity at this point 
Solved Threads: 0
dcarrillo18 dcarrillo18 is offline Offline
Newbie Poster

Show secured file

 
0
  #1
Mar 20th, 2007
I have a folder called _secure in which I have a .htaccess file that denies all access to the _secure folder. Within the _secure folder I also have a swf file. I'm using PHP to retrieve the secured swf file and show it if the user is logged in. For some reason my code bellow doen't seem to work. I would appreciate any help.

$filename = $_GET['filename'];
$dir = '_secure/';

if ( user_logged_in() ) {
download_file( $filename, $dir );
} else {
header("HTTP/1.1 404 Not Found"); // dead end
}

function download_file( $fname, $path) {
$fpath = $path.$fname; // absolute path to file
$fsize = filesize( $fpath ); // size of file

header('Content-Type: application/x-shockwave-flash');
$content = file_get_contents($fpath);
echo $content;
}
Reply With Quote Quick reply to this message  
Join Date: Sep 2006
Posts: 133
Reputation: sn4rf3r is an unknown quantity at this point 
Solved Threads: 2
sn4rf3r's Avatar
sn4rf3r sn4rf3r is offline Offline
Junior Poster

Re: Show secured file

 
0
  #2
Mar 23rd, 2007
any erros outputted?
If you are dnying all access to the "secure" are there any entries in the apache error logs?

I would wrap the file_get_contents() call in an if statement, this way you can see where the program fails. maybe try echoing the path fname, fpath variables out, see what they are set to.
Also add these to the top of your file
[PHP]
error_reporting(E_ALL);
display_errors(1);
[/PHP]
Reply With Quote Quick reply to this message  
Join Date: Jul 2006
Posts: 6
Reputation: dcarrillo18 is an unknown quantity at this point 
Solved Threads: 0
dcarrillo18 dcarrillo18 is offline Offline
Newbie Poster

Re: Show secured file

 
0
  #3
Mar 26th, 2007
I got it to work. But since it is a swf 5mb file it takes a while to get it. How can I fix this?

Originally Posted by sn4rf3r View Post
any erros outputted?
If you are dnying all access to the "secure" are there any entries in the apache error logs?

I would wrap the file_get_contents() call in an if statement, this way you can see where the program fails. maybe try echoing the path fname, fpath variables out, see what they are set to.
Also add these to the top of your file
[php]
error_reporting(E_ALL);
display_errors(1);
[/php]
Reply With Quote Quick reply to this message  
Join Date: Oct 2006
Posts: 42
Reputation: UrbanSky is an unknown quantity at this point 
Solved Threads: 4
UrbanSky UrbanSky is offline Offline
Light Poster

Re: Show secured file

 
0
  #4
Mar 26th, 2007
To be slightly unhelpful but honest, get a faster server or optimise your web server. There is not much else you can do. Apart from streaming the flash flie to the user so that it starts playing before the whole file has finished downloading it.
Reply With Quote Quick reply to this message  
Join Date: Mar 2007
Posts: 1
Reputation: mapolina is an unknown quantity at this point 
Solved Threads: 0
mapolina mapolina is offline Offline
Newbie Poster

Re: Show secured file

 
0
  #5
Mar 26th, 2007
You can try to increase the maximum execution time via set_time_limit() function or via php.ini if it is disabled (it is 30 seconds by default).
Sergey Egorov
Customer Service Dept.
SourceGuardian PHP Encoder
Reply With Quote Quick reply to this message  
Join Date: Jul 2006
Posts: 6
Reputation: dcarrillo18 is an unknown quantity at this point 
Solved Threads: 0
dcarrillo18 dcarrillo18 is offline Offline
Newbie Poster

Re: Show secured file

 
0
  #6
Mar 26th, 2007
Yes, that's what I thought streaming the file would be the best option for me. I gotta work on that then. If you can help on that I would really appreciate.
Reply With Quote Quick reply to this message  
Join Date: Feb 2005
Posts: 355
Reputation: DanceInstructor is an unknown quantity at this point 
Solved Threads: 14
DanceInstructor's Avatar
DanceInstructor DanceInstructor is offline Offline
Posting Whiz

Re: Show secured file

 
0
  #7
Mar 26th, 2007
You need to learn about making a flash preloader. It won't really speed up the loading time, but will give your visitor an indication that something is happening and the progress.
Clear Mind Hosting and Web Design

If I've helped you please consider adding to my reputation.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the PHP Forum


Views: 1270 | Replies: 6
Thread Tools Search this Thread



Tag cloud for PHP
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC