Add to Google

How To Avoid The Bandwidth Robbery - How to avoid the bandwidth robbery

Pages: 1, 2, 3
free web hosting
Open Discussion > CONTRIBUTE > Tutorials

How To Avoid The Bandwidth Robbery - How to avoid the bandwidth robbery

JpOlDeRmAn
Help, I don't get it..
I don't understand the tutorail..
For what helps this tutorail?

Reply

aka-2
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.

Reply

aka-2
Other way to take advantage of this theft is to make publicity of your site. Whem someone links directly to one of the photos of your site, the script create a box around the photo with the name of your site, or with anything you want.

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.

 

 

 


Reply

Sprnknwn
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.

Reply

Gem
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 biggrin.gif

Reply

DarkFox
Somebody robbed my bandwidth before. I lost all of it and got suspended. I'll use this when i get more hosting. Thanks.

Reply

SolarX
Thanks for this nice tutorial smile.gif
I'm currently thinking of doing something like this, because I get much traffic from hotlinked pictures. There are no disadvantages, or?






Reply

arnz
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.

Reply

Spiritreaver
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...

Reply

AnGeL KiSS
thanks for sharing; whenever I'm low in bandwidth I'll be sure to try this tut biggrin.gif

Reply



Got an Opinion! Express your Views! (no registration):-
Add your Reply/ Opinion/ Views/ Comments/ Suggestion/ Questions/ Queries etc.
Posts with decent grammar & English will be accepted and please refrain from profanities.
For asking a Question, We recommend you to sign-up (for free) so that you can track the topic easily.

Nature of your Post*: Opinion/ Reply/ Comments
Question/Query
Feedback to us.
       
Name   Email
Title/Question*

(Maximum characters: 10,000)
You have characters left.

Pages: 1, 2, 3






*SIMILAR VIDEOS*
Searching Video's for avoid, bandwidth, robbery, avoid, bandwidth, robbery

*MORE FROM TRAP17.COM*
advertisement



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