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. |
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.