\r\n\r\nURL
\r\nThe starting URL for the proxy.\r\n
\r\n\r\nFollow redirects?
\r\nSometimes the URL to a page, is actually a redirection to another page. Do you wish to follow those redirections when they occur?\r\n
\r\n\r\nRewrite urls?
\r\nSwitch this to No if you want to deeplink an external page.\r\n
\r\n\r\nTimeout
\r\nThe amount of time (in seconds) that WebGUI should wait for a connection before giving up on an external page.\r\n
\r\n\r\nRemove style?
\r\nDo you wish to remove the stylesheet from the proxied content in favor of the stylesheet from your site?\r\n
\r\n\r\nFilter Content
\r\nChoose the level of HTML filtering you wish to apply to the proxied content.\r\n
\r\n\r\nSearch for
\r\nA search string used as starting point. Use this when you want to display only a part of the proxied content. Content before this point is not displayed\r\n
\r\n\r\nStop at
\r\nA search string used as ending point. Content after this point is not displayed.\r\n
\r\nNote: The Search for and Stop at strings are included in the content. You can change this by editing the template for HttpProxy.\r\n
\r\n\r\nAllow proxying of other domains?
\r\nIf you proxy a site like Yahoo! that links to other domains, do you wish to allow the user to follow the links to those other domains, or should the proxy stop them as they try to leave the original site you specified?\r\n
\r\n' where internationalId = 11 and namespace = 'HttpProxy' and languageId = 1;
diff --git a/lib/WebGUI/Wobject/HttpProxy.pm b/lib/WebGUI/Wobject/HttpProxy.pm
index f760eb5de..00679f7af 100644
--- a/lib/WebGUI/Wobject/HttpProxy.pm
+++ b/lib/WebGUI/Wobject/HttpProxy.pm
@@ -60,8 +60,15 @@ sub new {
},
followRedirect=>{
defaultValue=>0
- }
- }
+ },
+ searchFor=>{
+ defaultValue=>''
+ },
+ stopAt=>{
+ defaultValue=>''
+ },
+ },
+ -useTemplate=>1
);
bless $self, $class;
}
@@ -114,6 +121,16 @@ sub www_edit {
-label=>WebGUI::International::get(4,$_[0]->get("namespace")),
-value=>[$_[0]->getValue("timeout")]
);
+ $layout->text(
+ -name=>"searchFor",
+ -label=>WebGUI::International::get(13,$_[0]->get("namespace")),
+ -value=>$_[0]->getValue("searchFor")
+ );
+ $layout->text(
+ -name=>"stopAt",
+ -label=>WebGUI::International::get(14,$_[0]->get("namespace")),
+ -value=>$_[0]->getValue("stopAt")
+ );
return $_[0]->SUPER::www_edit(
-properties=>$properties->printRowsOnly,
-layout=>$layout->printRowsOnly,
@@ -126,11 +143,7 @@ sub www_edit {
#-------------------------------------------------------------------
sub www_view {
- my (%formdata, @formUpload, $redirect, $response, $header,
- $userAgent, $proxiedUrl, $request, $content, $ttl);
-
- my $output = $_[0]->displayTitle;
- $output .= $_[0]->description;
+ my (%var, %formdata, @formUpload, $redirect, $response, $header, $userAgent, $proxiedUrl, $request, $ttl);
my $node = WebGUI::Node->new("temp",$_[0]->get("namespace")."_cookies");
$node->create;
@@ -149,13 +162,13 @@ sub www_view {
$redirect=0;
- return $output unless ($proxiedUrl ne "");
+ ssTemplate($_[0]->get("templateId"),{}) unless ($proxiedUrl ne "");
my $cachedContent = WebGUI::Cache->new($proxiedUrl,"URL");
my $cachedHeader = WebGUI::Cache->new($proxiedUrl,"HEADER");
- $header = $cachedHeader->get;
- $content = $cachedContent->get;
- unless ($content && $session{env}{REQUEST_METHOD}=~/GET/i) {
+ $var{header} = $cachedHeader->get;
+ $var{content} = $cachedContent->get;
+ unless ($var{content} && $session{env}{REQUEST_METHOD}=~/GET/i) {
$redirect=0;
until($redirect == 5) { # We follow max 5 redirects to prevent bouncing/flapping
$userAgent = new LWP::UserAgent;
@@ -236,26 +249,38 @@ sub www_view {
}
if($response->is_success) {
- $content = $response->content;
- $header = $response->content_type;
+ $var{content} = $response->content;
+ $var{header} = $response->content_type;
if($response->content_type eq "text/html" ||
- ($response->content_type eq "" && $content=~/new($proxiedUrl, $content, $_[0]->get("wobjectId"),$_[0]->get("rewriteUrls"));
- $content = $p->filter; # Rewrite content. (let forms/links return to us).
+ ($response->content_type eq "" && $var{content}=~/getValue("searchFor");
+ $var{"stop.at"} = $_[0]->getValue("stopAt");
+ if ($var{"search.for"}) {
+ $var{content} =~ /^(.*?)\Q$var{"search.for"}\E(.*)$/gis;
+ $var{"content.leading"} = $1 || $var{content};
+ $var{content} = $2;
+ }
+ if ($var{"stop.at"}) {
+ $var{content} =~ /(.*?)\Q$var{"stop.at"}\E(.*)$/gis;
+ $var{content} = $1 || $var{content};
+ $var{"content.trailing"} = $2;
+ }
+ my $p = WebGUI::Wobject::HttpProxy::Parse->new($proxiedUrl, $var{content}, $_[0]->get("wobjectId"),$_[0]->get("rewriteUrls"));
+ $var{content} = $p->filter; # Rewrite content. (let forms/links return to us).
$p->DESTROY;
- if ($content =~ /HttpProxy: Can't display frames
+ if ($var{content} =~ /HttpProxy: Can't display frames
Try fetching it directly here.";
} else {
- $content =~ s/\ GET status line: ".$response->status_line."";
}
if ($session{user}{userId} == 1) {
@@ -264,15 +289,15 @@ sub www_view {
$ttl = $session{page}{cacheTimeout};
}
- $cachedContent->set($content,$ttl);
- $cachedHeader->set($header,$ttl);
+ $cachedContent->set($var{content},$ttl);
+ $cachedHeader->set($var{header},$ttl);
}
- if($header ne "text/html") {
- $session{header}{mimetype} = $header;
- return $content;
+ if($var{header} ne "text/html") {
+ $session{header}{mimetype} = $var{header};
+ return $var{content};
} else {
- return $output.$content;
+ return $_[0]->processTemplate($_[0]->get("templateId"),\%var);
}
}
1;