Welcome to the GoFuckYourself.com - Adult Webmaster Forum forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Post New Thread Reply

Register GFY Rules Calendar Mark Forums Read
Go Back   GoFuckYourself.com - Adult Webmaster Forum > >
Discuss what's fucking going on, and which programs are best and worst. One-time "program" announcements from "established" webmasters are allowed.

 
Thread Tools
Old 11-09-2011, 08:40 AM   #1
Bladewire
StraightBro
 
Bladewire's Avatar
 
Industry Role:
Join Date: Aug 2003
Location: Monarch Beach, CA USA
Posts: 56,229
Can you configure Apache to do this?

Make Apache play .mp4 files as usual but

make Apache download .MP4 files to the users computer.

Is this possible? If so, how?

Thanks for your help
__________________


Skype: CallTomNow

Bladewire is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 11-09-2011, 08:57 AM   #2
darksoul
Confirmed User
 
darksoul's Avatar
 
Join Date: Apr 2002
Location: /root/
Posts: 4,997
The only way I can think of is setting a different mime type for MP4 files.
__________________
1337 5y54|)m1n: 157717888
BM-2cUBw4B2fgiYAfjkE7JvWaJMiUXD96n9tN
Cambooth
darksoul is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 11-09-2011, 09:08 AM   #3
Bladewire
StraightBro
 
Bladewire's Avatar
 
Industry Role:
Join Date: Aug 2003
Location: Monarch Beach, CA USA
Posts: 56,229
Quote:
Originally Posted by darksoul View Post
The only way I can think of is setting a different mime type for MP4 files.
Ok so changing the mime type for .MP4 , but keeping .mp4 as it is, could force downloads of .MP4 ?

What I'm trying to do is have a solution where I have one copy of each video file. Where .mp4 plays in my video player for member and when they click the download link, it will link to a .MP4 copy that downloads automatically.
__________________


Skype: CallTomNow

Bladewire is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 11-09-2011, 10:01 AM   #4
Bladewire
StraightBro
 
Bladewire's Avatar
 
Industry Role:
Join Date: Aug 2003
Location: Monarch Beach, CA USA
Posts: 56,229
bump
__________________


Skype: CallTomNow

Bladewire is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 11-09-2011, 10:33 AM   #5
SmokeyTheBear
►SouthOfHeaven
 
SmokeyTheBear's Avatar
 
Join Date: Jun 2004
Location: PlanetEarth MyBoardRank: GerbilMaster My-Penis-Size: extralarge MyWeapon: Computer
Posts: 28,609
you could use htaccess like this in the folder with the videos

Code:
RewriteEngine on
 RewriteRule ^(.*)\.MP4 mp4.php?x=$1 [nc]
this makes all requests for capital letter version "example.MP4" go to a file called mp4.php

Code:
<?php
$x = $_GET['x'];
$file = "$x.mp4";

if (file_exists($file)) {
    header('Content-Description: File Transfer');
    header('Content-Type: application/octet-stream');
    header('Content-Disposition: attachment; filename='.basename($file));
    header('Content-Transfer-Encoding: binary');
    header('Expires: 0');
    header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
    header('Pragma: public');
    header('Content-Length: ' . filesize($file));
    ob_clean();
    flush();
    readfile($file);
    exit;
} else {
echo "bad request";
}
?>
__________________
hatisblack at yahoo.com
SmokeyTheBear is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 11-09-2011, 11:58 AM   #6
Bladewire
StraightBro
 
Bladewire's Avatar
 
Industry Role:
Join Date: Aug 2003
Location: Monarch Beach, CA USA
Posts: 56,229
Quote:
Originally Posted by SmokeyTheBear View Post
you could use htaccess like this in the folder with the videos

Code:
RewriteEngine on
 RewriteRule ^(.*)\.MP4 mp4.php?x=$1 [nc]
this makes all requests for capital letter version "example.MP4" go to a file called mp4.php

Code:
<?php
$x = $_GET['x'];
$file = "$x.mp4";

if (file_exists($file)) {
    header('Content-Description: File Transfer');
    header('Content-Type: application/octet-stream');
    header('Content-Disposition: attachment; filename='.basename($file));
    header('Content-Transfer-Encoding: binary');
    header('Expires: 0');
    header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
    header('Pragma: public');
    header('Content-Length: ' . filesize($file));
    ob_clean();
    flush();
    readfile($file);
    exit;
} else {
echo "bad request";
}
?>

This is great THANK YOU!


Before reading your post I came across a recomendation to add this to my .htaccess

AddType application/octet-stream .mp4
<FilesMatch "\.(docx?|txt|mp4?)$">
Header add Content-Disposition "attachment"
</FilesMatch>

So far what this does is allows my jwplayer to play .mp4 files, but when a link with an .mp4 file is clicked, the user is prompted to download the file. So I don't need two copies of the video file.

Do you see any drawback to this? I'm not big on programming and have no idea if this doesn't work for everyone.
__________________


Skype: CallTomNow

Bladewire is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 11-09-2011, 01:20 PM   #7
fris
Too lazy to set a custom title
 
fris's Avatar
 
Industry Role:
Join Date: Aug 2002
Posts: 55,319
dont you want to be able to embed mp4?
__________________
Since 1999: 69 Adult Industry awards for Best Hosting Company and professional excellence.


WP Stuff
fris is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 11-09-2011, 02:05 PM   #8
SmokeyTheBear
►SouthOfHeaven
 
SmokeyTheBear's Avatar
 
Join Date: Jun 2004
Location: PlanetEarth MyBoardRank: GerbilMaster My-Penis-Size: extralarge MyWeapon: Computer
Posts: 28,609
Quote:
Originally Posted by Squirtit View Post
This is great THANK YOU!


Before reading your post I came across a recomendation to add this to my .htaccess

AddType application/octet-stream .mp4
<FilesMatch "\.(docx?|txt|mp4?)$">
Header add Content-Disposition "attachment"
</FilesMatch>

So far what this does is allows my jwplayer to play .mp4 files, but when a link with an .mp4 file is clicked, the user is prompted to download the file. So I don't need two copies of the video file.

Do you see any drawback to this? I'm not big on programming and have no idea if this doesn't work for everyone.
my method is the same you just reference "file.MP4" for download and "file.mp4" for jwplayer , it pulls the same video you dont need 2 videos

but really you just need the htaccess you posted because the player will stream it either way
__________________
hatisblack at yahoo.com
SmokeyTheBear is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 11-09-2011, 03:24 PM   #9
Bladewire
StraightBro
 
Bladewire's Avatar
 
Industry Role:
Join Date: Aug 2003
Location: Monarch Beach, CA USA
Posts: 56,229
Quote:
Originally Posted by fris View Post
dont you want to be able to embed mp4?
Yes I definately need to embed.

This works for me on Chrome and Internet Explorer. Click here to see an example.

Does this embed and download the same file for you guys too?

If not, what browser and OS are you using?

I really appreciate the help


.
__________________


Skype: CallTomNow

Bladewire is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 11-09-2011, 03:31 PM   #10
Tempest
Too lazy to set a custom title
 
Industry Role:
Join Date: May 2004
Location: West Coast, Canada.
Posts: 10,217
Works for me in Opera.... but you might have issues with cellphones (androids) playing the video as I think they need to see the proper mime type. That's one of the reasons trying to "fake it" in apache etc isn't done and ppl have to right click to download or run the download thru a separate script.
Tempest is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 11-09-2011, 03:54 PM   #11
raymor
Confirmed User
 
Join Date: Oct 2002
Posts: 3,745
Quote:
Originally Posted by SmokeyTheBear View Post
you could use htaccess like this in the folder with the videos

Code:
RewriteEngine on
 RewriteRule ^(.*)\.MP4 mp4.php?x=$1 [nc]
this makes all requests for capital letter version "example.MP4" go to a file called mp4.php

Code:
<?php
$x = $_GET['x'];
$file = "$x.mp4";

if (file_exists($file)) {
    header('Content-Description: File Transfer');
    header('Content-Type: application/octet-stream');
    header('Content-Disposition: attachment; filename='.basename($file));
    header('Content-Transfer-Encoding: binary');
    header('Expires: 0');
    header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
    header('Pragma: public');
    header('Content-Length: ' . filesize($file));
    ob_clean();
    flush();
    readfile($file);
    exit;
} else {
echo "bad request";
}
?>
Do NOT do that in PHP. Similar code in PHP almost always has three major bugs.
Instead set the headers in the .htaccess.
__________________
For historical display only. This information is not current:
support&#64;bettercgi.com ICQ 7208627
Strongbox - The next generation in site security
Throttlebox - The next generation in bandwidth control
Clonebox - Backup and disaster recovery on steroids
raymor is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 11-09-2011, 03:59 PM   #12
raymor
Confirmed User
 
Join Date: Oct 2002
Posts: 3,745
Quote:
Originally Posted by SmokeyTheBear View Post
you could use htaccess like this in the folder with the videos

Code:
RewriteEngine on
 RewriteRule ^(.*)\.MP4 mp4.php?x=$1 [nc]
this makes all requests for capital letter version "example.MP4" go to a file called mp4.php

Code:
<?php
$x = $_GET['x'];
$file = "$x.mp4";

if (file_exists($file)) {
    header('Content-Description: File Transfer');
    header('Content-Type: application/octet-stream');
    header('Content-Disposition: attachment; filename='.basename($file));
    header('Content-Transfer-Encoding: binary');
    header('Expires: 0');
    header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
    header('Pragma: public');
    header('Content-Length: ' . filesize($file));
    ob_clean();
    flush();
    readfile($file);
    exit;
} else {
echo "bad request";
}
?>
Do NOT read and print videos in PHP. Similar code in PHP almost always has three major bugs.
Instead set the headers in the .htaccess.
Smokey did manage to halfway avoid one bug, so his implementation has only 2 1/2 major issues. That's definitely better than most people do.

Still remaining is the big which for about a year caused one popular CMS to crash servers fairly regularly and this code too will crash your server when it gets busy. It also has a glaring security hole.

Last edited by raymor; 11-09-2011 at 04:02 PM..
raymor is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 11-09-2011, 04:18 PM   #13
Bladewire
StraightBro
 
Bladewire's Avatar
 
Industry Role:
Join Date: Aug 2003
Location: Monarch Beach, CA USA
Posts: 56,229
Quote:
Originally Posted by raymor View Post
Do NOT read and print videos in PHP. Similar code in PHP almost always has three major bugs.
Instead set the headers in the .htaccess.
Smokey did manage to halfway avoid one bug, so his implementation has only 2 1/2 major issues. That's definitely better than most people do.

Still remaining is the big which for about a year caused one popular CMS to crash servers fairly regularly and this code too will crash your server when it gets busy. It also has a glaring security hole.
WOW ouch! Thanks for the tip Ray I appreciate that.

Quote:
AddType application/octet-stream .mp4

<FilesMatch "\.(docx?|txt|mp4?)$">
Header add Content-Disposition "attachment"
</FilesMatch>
The above code seems to do the trick in browsers with the longtail video player.

However on my IPad no video shows, only the "download" graphic appears, and when clicked on, it plays the video.

On my Android phone no video shows, only the "download" graphic appears, and when click on, it downloads the video to the phone without viewing.

So maybe if I adjust the longtail player setting to be html5 compatible it could fix this problem?

Thanks for your input I really appreciate it
__________________


Skype: CallTomNow

Bladewire is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 11-09-2011, 09:52 PM   #14
raymor
Confirmed User
 
Join Date: Oct 2002
Posts: 3,745
Quote:
Originally Posted by Squirtit View Post
WOW ouch! Thanks for the tip Ray I appreciate that.



The above code seems to do the trick in browsers with the longtail video player.

However on my IPad no video shows, only the "download" graphic appears, and when clicked on, it plays the video.

On my Android phone no video shows, only the "download" graphic appears, and when click on, it downloads the video to the phone without viewing.

So maybe if I adjust the longtail player s etting to be html5 compatible it could fix this problem?

Thanks for your input I really appreciate it
What you can do is use rewrite to call the same file as both mp4 and MP4. So long as you're using rewrite anyway, you can also use it to set the content type. Further, you could add a Content-Disposition header. I'm driving at moment so I can't go through tbe exact code, but that can point you in the right direction.
__________________
For historical display only. This information is not current:
support&#64;bettercgi.com ICQ 7208627
Strongbox - The next generation in site security
Throttlebox - The next generation in bandwidth control
Clonebox - Backup and disaster recovery on steroids
raymor is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 11-09-2011, 09:57 PM   #15
raymor
Confirmed User
 
Join Date: Oct 2002
Posts: 3,745
By the way, what any of this does is SUGGEST to the browser that a file could be saved in the one case or played in the other case. There is absolutely no forcing going on. You can't MAKE them save the file to the hard drive. As far as you know, they may be on a diskless system that doesn't even HAVE a hard drive. You're merely suggesting an appropriate way the file could be handled.
__________________
For historical display only. This information is not current:
support&#64;bettercgi.com ICQ 7208627
Strongbox - The next generation in site security
Throttlebox - The next generation in bandwidth control
Clonebox - Backup and disaster recovery on steroids
raymor is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 11-09-2011, 10:16 PM   #16
SmokeyTheBear
►SouthOfHeaven
 
SmokeyTheBear's Avatar
 
Join Date: Jun 2004
Location: PlanetEarth MyBoardRank: GerbilMaster My-Penis-Size: extralarge MyWeapon: Computer
Posts: 28,609
Quote:
Originally Posted by raymor View Post
By the way, what any of this does is SUGGEST to the browser that a file could be saved in the one case or played in the other case. There is absolutely no forcing going on. You can't MAKE them save the file to the hard drive. As far as you know, they may be on a diskless system that doesn't even HAVE a hard drive. You're merely suggesting an appropriate way the file could be handled.
actually my method includes nazi skinhead enforcers who will actually visit your house and force you to download it.. if you don't have a hard drive they drive you to the store to buy one.
__________________
hatisblack at yahoo.com
SmokeyTheBear is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 11-09-2011, 10:21 PM   #17
raymor
Confirmed User
 
Join Date: Oct 2002
Posts: 3,745
Quote:
Originally Posted by SmokeyTheBear View Post
actually my method includes nazi skinhead enforcers who will actually visit your house and force you to download it.. if you don't have a hard drive they drive you to the store to buy one.
Does the automatic forfeit for triggering Godwin's law apply to jokes?
__________________
For historical display only. This information is not current:
support&#64;bettercgi.com ICQ 7208627
Strongbox - The next generation in site security
Throttlebox - The next generation in bandwidth control
Clonebox - Backup and disaster recovery on steroids
raymor is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 11-09-2011, 10:44 PM   #18
SmokeyTheBear
►SouthOfHeaven
 
SmokeyTheBear's Avatar
 
Join Date: Jun 2004
Location: PlanetEarth MyBoardRank: GerbilMaster My-Penis-Size: extralarge MyWeapon: Computer
Posts: 28,609
Quote:
Originally Posted by raymor View Post
Does the automatic forfeit for triggering Godwin's law apply to jokes?
the south park "grace period" has expired on using nazi's in jokes, it is ok now..
__________________
hatisblack at yahoo.com
SmokeyTheBear is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Post New Thread Reply
Go Back   GoFuckYourself.com - Adult Webmaster Forum > >

Bookmarks
Thread Tools



Advertising inquiries - marketing at gfy dot com

Contact Admin - Advertise - GFY Rules - Top

©2000-, AI Media Network Inc



Powered by vBulletin
Copyright © 2000- Jelsoft Enterprises Limited.