Plankton has asked for the wisdom of the Perl Monks concerning the following question:

Friends,

While at work I am not able to access certain web sites because they are considered fun. So I thought I would set up a CGI on my system at home that I could bounce my request to these blocked sites off of. The problem I am having is that I don't know how I should deal with <FORM>'s action attributes.

Here's what I have so far ...
#!/usr/local/bin/perl -w use strict; + + use WWW::Mechanize; use CGI; my $cgi = new CGI; my $mech = WWW::Mechanize->new(); my $scriptName = $ENV{'SCRIPT_NAME'} || $0; my ( $requestURI, $QS ) = split /\?/, $ENV{'REQUEST_URI'} || $0; my $url = $cgi->param('url') || 'http://localhost/'; $mech->get( $url ); my $content = $mech->content; $content =~ s/<HTML>//ig; $content =~ s/<\/HTML>//ig; $content =~ s/<BODY>//ig; $content =~ s/<\/BODY>//ig; my @lines = split /\n/, $content; print $cgi->header (); print "<base href=$url>\n"; print $cgi->start_html( "WAY $scriptName" ); for my $line (@lines) { if ( $line =~ /a href/i ) { if ( $line =~ /<a href=(['"])http/i ) { $line =~ s/<a href=(['"])/<a href=$1http:\/\/l +ocalhost\/cgi-bin\/way.pl?url=/ig; } else { $line =~ s/<a href=(['"])/<a href=$1http:\/\/l +ocalhost\/cgi-bin\/way.pl?url=$url/ig; } } print $line; } print "<!-- \n"; while ( my ($key, $val) = each %ENV) { print "$key = $val\n"; } print "-->\n"; print $cgi->end_html;
I want to be able to logon via this URL ...
http://localhost/cgi-bin/way.pl?url=http://www.itsyourturn.com/iyt.dll +?status?p=1
... and of course be able to play some chess once i logon.

Thanks!

Plankton: 1% Evil, 99% Hot Gas.

Replies are listed 'Best First'.
Re: Site Blocker Work Around CGI help
by tachyon (Chancellor) on Jul 01, 2004 at 05:40 UTC
Re: Site Blocker Work Around CGI help
by bart (Canon) on Jul 01, 2004 at 07:18 UTC
    I want to be able to logon via this URL ...
    http://localhost/cgi-bin/way.pl?url=http://www.itsyourturn.com/iyt.dll +?status?p=1
    Eh? It won't work on localhost. Your "proxy" must reside on a server outside of the firewall. And of course, the domain your proxy is on may not be blocked, itself.
      Or just ssh into a *nix box and use lynx ... that's what I do :/
        You don't even have to use lynx, ssh can pipe X-windows through the encrypted channel and display it on your local monitor! Go ahead and use Netscape or play Bolo. . .

        Ahem, this is all in theory, as I have never done anything like it, no no, not me. I'm not condoning this at all. :^)

        - - arden.