| | Help, I don't get it.. I don't understand the tutorail.. For what helps this tutorail? |
|
|
JpOlDeRmAn, surely you don't understand this tutorial bacause you don't have this problem, but maybe this long explanation can help you to undesrtand:
Bandwidth robbery, bandwidth theft or "hotlinking" is direct linking to a web site's files (images, video, etc.). An example would be using an <img> tag to display a JPEG image you found on someone else's web page so it will appear on your own site, weblog, etc. Bandwidth refers to the amount of data transferred from a web site to a user's computer. When you view a web page, you are using that site's bandwidth to display the files. Since web hosts charge based on the amount of data transferred, bandwidth is an issue. If a site is over its monthly bandwidth, it's billed for the extra data or taken offline. A simple analogy for bandwidth theft: Imagine a random stranger plugging into your electrical outlets, using your electricity without your consent, and you paying for it. This script use GD Library, so it's very usefull: QUOTE <?php // *** Configuration start // Web server root path $web_root = "/Users/daniel/Sites/"; // Cache directory. Need write permissions $path_cache = "/Users/daniel/Sites/cache/"; // Default photo. $default_photo = "/default.jpeg"; // Tag $tag = "http://ruido-blanco.net/blog/"; // *** Configuration end /* * Transforms a palette image into a truecolor image. Leaves truecolor images * untouched. */ function imagepalettetotruecolor(&$img) { if (!imageistruecolor($img)) { // GIF format is not truecolor $w = imagesx($img); $h = imagesy($img); $img1 = imagecreatetruecolor($w, $h); // Create a new truecolor image imagecopy($img1, $img, 0, 0, 0, 0, $w, $h); // Copy old image over $img = $img1; // Change the image handler } } /* * Process an image. The parameter is the path to the image. The result image is * saved over the old image. */ function process_image($photo) { global $tag; // Create an iamge handler from any known format $im = imagecreatefromstring(file_get_contents($photo)); imagepalettetotruecolor($im); $white = imagecolorallocate($im, 255, 255, 255); $black = imagecolorallocate($im, 0, 0, 0); // Add the tag using font #2 // Add a background rectangle. $tag_width = imagefontwidth(2) * strlen($tag) + 1; $tag_height = imagefontheight(2) + 2; imagefilledrectangle($im, 0, 0, $tag_width, , $black); imagestring($im, 2, 1, 1, $tag, $white); // Save the image in jpeg. imagejpeg($im, $photo); imagedestroy($im); } // Get the image to "tag" if ($_GET['photo'] != "") { // URL parameter for testing $photo_url = $_GET['photo']; } else if ($_SERVER['REQUEST_URI'] != "") { // Request URL for production $photo_url = $_SERVER['REQUEST_URI']; } else { // or a default image $photo_url = $default_photo; } // The path to the real image $photo_path = $web_root . $photo_url; // The path to the cached image. The md5 avoids name clashes. $photo_cache = $path_cache . md5($photo_url); if (is_file($photo_path)) { // We test if there is really an image if (!is_file($photo_cache)) { // If the image is not yet cached // Copy over the cache copy($photo_path, $photo_cache) or die('Error copying the image'); // Process the cached image process_image($photo_cache); } if (is_file($photo_cache)) { // If we have the image in the cache // Send the image mime type and length header("Content-Type: image/jpeg"); header("Content-Length: " . filesize($photo_cache)); readfile($photo_cache); } else { die('Image not in the cache'); } } else { die('Image not found ' . $photo_url); } ?> To finish the work and complete the code you have to write in your .htaccess in the hosting root the next lines: QUOTE RewriteEngine on RewriteCond %{HTTP_REFERER} !^$ RewriteCond %{HTTP_REFERER} !^http://eldominio.com(/)?.*$ [NC] RewriteRule .*.(gif|jpg|jpeg|bmp|png)$ /image.php [NC] You can download this file directly from here. Here you can see an example of the script running. The original work of this script is here, in spanish.
Itīs not just a nice tutorial, itīs vital. I find hotlinking completely necessary.
I am a truly believer of freedom of information in internet and I donīt mind people pick my images (or texts) and publish them everywhere, but at least take some time to save it and set it up in your own server... itīs such bad education, to steal contents and also bandwidth, having something completely for free just by stealing it. I have the hotlink protection activated in Cpanel... a really helpful feature.
Thanks that is a nice tutorial. I'm just starting to learn aobut .htaccess and it is quite interested. This looks like it use mod_rewrite which is very cool. Ive used this in my upcoming forum which uses a modification to rewrite the urls to search engine optimize them. Ive also seen that .htaccess is very powerful because you can change a whole lot of file types to another by entering one line of code in your .htaccess file which can be very useful across some large sites. Anyway this was a great tutorial and i might use it on a imgehost if i get round to doing one
Somebody robbed my bandwidth before. I lost all of it and got suspended. I'll use this when i get more hosting. Thanks.
Thanks for this nice tutorial
I'm currently thinking of doing something like this, because I get much traffic from hotlinked pictures. There are no disadvantages, or?
Not a bad tutorial. When I get the time, I'd be interested to replace a standard "no hot linking" image with a custom made image from Photoshop. Some "no hotlinking" images have been funny from time to time.
These tips are very useful, I wish i had them earlier I will recommend these tips to my friends since they seem to complain alot about losing bandwith...
Recent Queries:-
Keywords : avoid, bandwidth, robbery, avoid, bandwidth, robbery
Using Strings To Avoid Repitition (1) One of the useful features of PHP is strings. You can use them to print a long text item that you Looking for avoid, bandwidth, robbery, avoid, bandwidth, robbery
|
|
![]() How To Avoid The Bandwidth Robbery - How to avoid the bandwidth robbery |
| ADD REPLY / Got an Opinion! | a humble request :-) | RAPID SEARCH! | Free Hosting | [X] |
|
Express your Opinions, Thoughts or Contribute your information that might help someone here. Ask your Doubts & Queries to get answers.. "Together, We enlight each other!" |
Register FREE for AD-FREE forum, Create your own topics, Ask Questions, track topics, setup subscriptions & notifications and Get a Free Website w/ Email and FTP. | 500MB Space *No Ads*, CPanel, FTP, PHP, MySQL, EMails - 100% FREE |
|