###################### # Copyright © 2000 Portal Scripts. # All Rights Reserved. # # The original developer of this software module and his/her company, the subsequent # editors and their companies, have no liability for use of this # software module or modifications thereof in an implementation. # # Permission to use, copy, and modify this software and its documentation on # the server of the customer is hereby granted, provided that the above copyright # notice, this paragraph and the following two paragraphs appear in all # copies. # # This software program and documentation are copyrighted by Portal Scripts. # The software program and documentation are supplied "as is", without any # accompanying services. Portal Scripts does not # warrant that the operation of the program will be # uninterrupted or error-free. # # IN NO EVENT SHALL PORTAL SCRIPTS BE LIABLE TO ANY PARTY FOR # DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING # LOST PROFITS, ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION. # ###################### use strict; use vars qw(@url_refs); sub get_content { my ($url) = @_; use LWP::UserAgent; use HTML::LinkExtor; use URI::URL; my $ua = new LWP::UserAgent; $ua->agent('Mozilla/3.0 (compatible)'); @url_refs = (); my $p = HTML::LinkExtor->new(\&callback); my $res = $ua->request(HTTP::Request->new(GET => $url)); my $base = $res->base; my $html = $res->content; $p->parse($html); @url_refs = map { [$_->[0], $_->[1], url($_->[1], $base)->abs] } @url_refs; for my $ref (@url_refs){ my $attr = $ref->[0]; my $val = $ref->[1]; my $full_val = $ref->[2]; $html =~ s#$attr\s*=\s*"?$val"?#$attr="$full_val"#igs; } undef @url_refs; return $html; } sub adv_get_content { my ($url, $start, $end) = @_; use LWP::UserAgent; use HTML::LinkExtor; use URI::URL; my $ua = new LWP::UserAgent; $ua->agent('Mozilla/3.0 (compatible)'); @url_refs = (); my $p = HTML::LinkExtor->new(\&callback); my $res = $ua->request(HTTP::Request->new(GET => $url)); my $base = $res->base; my $html = $res->content; $p->parse($html); @url_refs = map { [$_->[0], $_->[1], url($_->[1], $base)->abs] } @url_refs; if($html =~ m#($start.*$end)#s){ $html = $1; } for my $ref (@url_refs){ my $attr = $ref->[0]; my $val = $ref->[1]; my $full_val = $ref->[2]; $html =~ s#$attr\s*=\s*"?$val"?#$attr="$full_val"#igs; } undef @url_refs; return $html; } sub callback { my($tag, %attr) = @_; while (my ($key,$value) = each %attr) { next if $key eq 'usemap'; push(@url_refs, [$key, $value]); } } sub execute_cgi { my ($cgi) = @_; use Cwd; my $cur_dir = cwd; my $cgi_dir = $cgi; $cgi_dir =~ s#[^/]*$##; chdir($cgi_dir); my $temp = `perl $cgi`; $temp =~ s#Content-type: text/html##i; chdir($cur_dir); return $temp; } sub transfer_content { my ($file) = @_; undef $/; open(FILE, $file); flock(FILE, 2); my $content = ; flock(FILE, 8); close($file); $/ = "\n"; return $content; } 1;