SPUG: bot motel Re: Chip Salzenberg Defense Fund

Fred Morris m3047 at inwa.net
Fri Aug 5 16:08:18 PDT 2005

I've been just kind of laying off this thread (Ken, you're doing a good
job) but maybe it is worth mentioning this page I put up about this whole


Or if you prefer:


Always good for a laugh. But what's funny is the people who look at me
funny for doing something like this: for not trusting in robots.txt! Which
is, sadly, most of the so-called "community". So I will shamelessly say: if
you're out there and you want stuff which is simple and works, and you want
to pay for results rather than lip gloss... you can find me, you know how
to Google, don't you?


Appended. How cool is that?!


Fred Morris
fredm3047 at inwa.net (I-ACK)


#!/usr/bin/perl -w

=head1 bot-motel.cgi

'Bots check in, but they never check out! This is a 404/403 replacement handler
which serves random randomized pages from cache and masks the error so that it
looks like a successful hit.

=head2 Copyright

=over 4

=item Author

Fred Morris

=item Version


=item System


=item Creation Date


=item Modification History

=item Copyright

Copyright (c) 2003 by Fred Morris, 6739 3rd NW Seattle WA USA 98117
e-mail: m3047 at inwa.net telephone 206.297.6344

Licensed under the same terms as Perl itself.


=head2 CGI Parameters



=head2 Templates

Substitution templates are not used.

The script operates in no-parsed-headers (NPH) mode so that
it can always return a success code.

It serves as content a random page from /opt/bot-motel/cache/*/.


use strict;

require Apache;

# Get something to return to the (ab)user.
sub get_file() {

    my $fnm = sprintf "%d/%d.html",
        rand( 10 ), rand( 100 );

    warn "BotMo: $fnm";

    local $/;   # Slurp.

    open F, "</opt/bot-motel/cache/$fnm"
                or warn "BotMo open failed: $!", return undef;

    defined(my $text = <F>)
                or warn "BotMo read failed: $!", return undef;

    close F     or warn "BotMo close failed: $!", return undef;

    return $text;

} # &get_file

# Effectively the main procedure, gives us something to gracefully bail out
# of.
sub effective_main() {

    $| = 1;

    my $r = Apache->request;

    my $text; my $status;

    if ($text = get_file()) {
        $status = 200;
    else {
        $status = 500;
        $text = "<html><head><title>Internal Server Error</title></head>\n"
              . " <body>Internal Server Error</body></html>\n";

    $r->status( $status );
    $r->content_type( 'text/html' );

    # Write it out.

    $r->print( $text );

    $| = 0;

} # &effective_main



More information about the spug-list mailing list