User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the PHP section within the Web Development category of DaniWeb, a massive community of 402,708 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,446 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our PHP advertiser: Lunarpages PHP Web Hosting
Views: 882 | Replies: 6
Reply
Join Date: Jul 2006
Posts: 6
Reputation: dcarrillo18 is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
dcarrillo18 dcarrillo18 is offline Offline
Newbie Poster

Help Show secured file

  #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;
}
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Sep 2006
Location: NYC
Posts: 133
Reputation: sn4rf3r is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 2
sn4rf3r's Avatar
sn4rf3r sn4rf3r is offline Offline
Junior Poster

Re: Show secured file

  #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  
Join Date: Jul 2006
Posts: 6
Reputation: dcarrillo18 is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
dcarrillo18 dcarrillo18 is offline Offline
Newbie Poster

Help Re: Show secured file

  #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  
Join Date: Oct 2006
Location: London
Posts: 42
Reputation: UrbanSky is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 4
UrbanSky UrbanSky is offline Offline
Light Poster

Re: Show secured file

  #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  
Join Date: Mar 2007
Posts: 1
Reputation: mapolina is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
mapolina mapolina is offline Offline
Newbie Poster

Re: Show secured file

  #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  
Join Date: Jul 2006
Posts: 6
Reputation: dcarrillo18 is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
dcarrillo18 dcarrillo18 is offline Offline
Newbie Poster

Re: Show secured file

  #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  
Join Date: Feb 2005
Posts: 354
Reputation: DanceInstructor is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 12
DanceInstructor's Avatar
DanceInstructor DanceInstructor is offline Offline
Posting Whiz

Re: Show secured file

  #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  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb PHP Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the PHP Forum

All times are GMT -4. The time now is 6:24 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC