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
thing:

  http://devil.m3047.inwa.net/blogs/bots-are-my-friends.html

Or if you prefer:

  http://devil.m3047.inwa.net/politics/salzenberg-for-president.html


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?


ObPerl:

Appended. How cool is that?!

--

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

--

#!/usr/bin/perl -w
#
=pod

=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

0.1

=item System

BotMotel

=item Creation Date

25-Feb-2002

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

=back

=head2 CGI Parameters

None.

=back

=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/*/.

=cut

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' );
    $r->send_http_header();

    # Write it out.

    $r->print( $text );

    $| = 0;

} # &effective_main

effective_main();

1;




More information about the spug-list mailing list