If you're using cPanel, you might want to have a look at their Hotlink Protection feature. This feature allows you to forbid direct access to image files (or any file types you specify). Users can still access the images through your Web pages, but they won't be able to simply slurp up your photos.

I suggest that you have a look at your log files, though. The repeated accessing of your images by only a few users (or rather, only a few IP numbers) suggests an automated process, not people. In that case, you can use cPanel's IP Deny feature, which allows you to block individual IP's, or sets of them. You might also check whether these rude accesses are by a bot, but it really doesn't matter - whoever or whatever it is, it's hogging your bandwidth.

Once you've got a recent access log for your Website, you can write a script to find who's making the most accesses.

#!/usr/bin/perl -w use strict; use warnings; # Get the IP number from each line... while (<$INFILE>) { chomp; my $inline=$_; /(\d+.\d+.\d+.\d+)\s(.*)/; print $LOG "$1\n"; # . . . } # . . . # Create list of accesses, most frequent first. while(<$LOG>) { chomp; my $line=$_; $seen{$line}++; } # . . . foreach my $seenval ( sort {$seen{$b} <=> $seen{$a} } keys %seen) +{ next unless $seenval; print $FREQ "$seenval\t$seen{$seenval}\n"; }

This will help you see who's visiting most frequently. That's not quite the same as finding who's hogging the most bandwidth, but it should be a good start.

In order to get bandwidth itself, you'd need to do something like first identifying the size of the file downloaded, and then changing: $seen{$line}++; to $seen{$line}+=$size; (untested)


In reply to Re^5: mod_perl blocking greedy clients by spiritway
in thread mod_perl blocking greedy clients by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.