Recently, I am finding a good solution to protect the uploaded media files against non authorized downloading. I am especially concerned about downloading media file direct access through browser and hotlink prevention. The uploaded media files (mp3 files) stored in 'media' directory under document root in my server.


Observations:

To prevent hotlink prevention and downloading media files direct access through browser can be controlled using .htaccess file under the 'media' directory. That is,

(a) The user cannot download the media files directly from the browser like http://www.domain.com/media/mj_heal_the_world.mp3

(b) The prevention of bandwidth theft or "hotlink" (direct linking to a web site's files)

-> . htaccess
<FilesMatch "\.(mp3|MP3)$">
order deny,allow
deny from all
</FilesMatch>
The above code worked well for prevention of hotlink and restriction of downloading media file directly from the browser. But the following functionalities were not working due to the above code implementation.

(a) The embed player does not play mp3 files

(b) The flash player does not play mp3 files.

(c) The authenticated users not able to download the mp3 files

Please note that my website have both embed player and flash player for playing mp3 files. Since the both player source code pointed to the actual mp3 files location and due to above .htaccess code the player failed to play the appropriate mp3 files.

How to avoid conflict (as explained above) and make sure the player functions and keep up the .htaccess? - Here I have given a solution for embed player.

Initially, the embed code looks like below:

-> embed.php
<?php
<embed src=
"http://www.domain.com/media/mj_heal_the_world.mp3">
?>
The above embed player does not work due to above explained .htaccess code implementation. Now this HTML code should be changed in to little bit and pointed to a intermediate PHP script that would get the filename as a parameter and then read the file content immediately. This solution is another way of serving content to the user.

Finally the embed.php code should be:

-> embed.php

<?php
<embed src="http://www.domain.com/play.php?filename=mj_heal_the_world.mp3">
?>

-> play.php

<?php
# get file name
$fileName = $_GET['filename']
# assemble file path
$file = '/var/www/domain.com/public_html/media/'.$fileName;
$fileSize=filesize($file);

header("Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0");
header("Pragma: no-cache");
header("Content-Type: audio/mpeg");
header("Content-Disposition: attachment; filename=\"" . $fileName . "\"");
header("Content-Length: " . $fileSize);
readfile ($file);
?>
Now the embed player would be working without any trouble. Similarly, you can able make sure the required tweaks for flash player and downloading media files to the authenticated users.

Mostly I don't have enough time to read when I see/browse any nice & interesting news, technical tips & review, blog etc during office hours due to busy schedule. At that time, I thought about any tool that converting web page in to PDF and save locally. Later it would be helpful for me to read saved web page with more attention in offline mode.

Why can’t save web page as HTML? Why PDF conversion Firefox add-ons?

Of course, we have the option called "Save page as" from the web browser menu and save the pages in to HTML format. But it would be always not comfortable and annoying to read web pages in offline mode. Since the saved page source rely on the external site references especially when you talking about the loading images and advertisements in the browser. As a result, when you open saved page, the loading of page would be very slow, getting lot of broken images/ads banners and content presentation getting affected.

The converting web page in to PDF option is very smart and easy to view web page as it is and then save, share, print or archive them. Control PDF files in Firefox. Stop crashes and get the upper hand on Web-based PDF files by automating and controlling how your Firefox or Flock browsers deal with them.

How to convert web pages in to PDF?

The converting web page in to PDF is very easy. There are two Firefox add-ons available. Just check it out the below URLs and install it.



PDF Download

After installing PDF download Firefox add-ons & restart Firefox browser, open your favorite URL on your browser and do mouse right click button in any section of the page, then you would be getting properties window and have the menu called “Save Page As PDF...”. Using this menu, you can easily convert your favorite web page in to PDF format. Also you can control over the various great options/preferences available for this add-ons. Look at the below screen shots.





PDFIT

After installing PDFIT Firefox add-ons & restart Firefox browser, open your favorite URL on your browser and do mouse right click button in any section of the page, then you would be getting properties window and have the menu called “Pdf It!”. Using this menu, you can easily convert your favorite web page in to PDF or image file. Also you can control over the various great options/preferences available for this add-ons.



PDF Download Features

(a) Convert web page in to PDF. The conversion may take couple of minutes.
(b) Convert your PDF in to HTML format.
(c) The PDF output settings can be configurable.
(d) Either you can save the page as PDF or email to specified email address.



PDFIT Features

(a) Convert web page in to PDF or Image file. Additionally you can save either partial visible area or whole page.
(b) There are many image generation preferences that you can control it.
(c) When you save the PDF, you can able to control (such as the page size & split PDF pages settings) how the PDF should be stored locally.





Observations:

The both add-ons are mainly focusing on converting web page in to PDF format. However I wanted to show there is one main difference that I have observed. That is, during the conversion of PDF format - "PDF download" convert the web page as it is. But "PDFIT" conversion looks like, converting web page in to image and then finally PDF format. As a result, if any source links (href) in the web page would be disabled and can't be seen any href link in the "PDFIT" add-ons.

The below screen shot that involving PDF conversion using "pdf download" add-ons and you can able to see source href links.



The below screen shot that involving PDF conversion using "pdfif" add-ons and you can't able to see any source href links.



I personally think that "PDF download" is absolutely the best add-ons for converting web page in to PDF format. I have been using this add-ons since the PDF conversion process works as it as in the web page and easy as well.