summaryrefslogtreecommitdiff
path: root/httemplate/misc/custom_link_proxy.cgi
diff options
context:
space:
mode:
Diffstat (limited to 'httemplate/misc/custom_link_proxy.cgi')
-rw-r--r--httemplate/misc/custom_link_proxy.cgi32
1 files changed, 32 insertions, 0 deletions
diff --git a/httemplate/misc/custom_link_proxy.cgi b/httemplate/misc/custom_link_proxy.cgi
new file mode 100644
index 000000000..f3c6e376e
--- /dev/null
+++ b/httemplate/misc/custom_link_proxy.cgi
@@ -0,0 +1,32 @@
+% if( $response->is_success ) {
+<% $response->decoded_content %>
+% }
+% else {
+<% $response->error_as_HTML %>
+% }
+<%init>
+
+my( $custnum ) = $cgi->param('custnum');
+my $cust_main = qsearchs('cust_main', { custnum => $custnum } )
+ or die "custnum '$custnum' not found"; # just check for existence
+
+my $conf = new FS::Conf;
+my $url = $conf->config('cust_main-custom_link');
+
+my $agentnum = $cust_main->agentnum;
+my $curuser = $FS::CurrentUser::CurrentUser;
+my $usernum = $curuser->usernum;
+# like eval(qq("$url")) but with fewer things that can go wrong
+# and if $custnum isn't mentioned, assume it goes at the end
+$url =~ s/\$custnum/$custnum/ or $url .= $custnum;
+$url =~ s/\$agentnum/$agentnum/;
+$url =~ s/\$usernum/$usernum/;
+
+#warn $url;
+
+die "access denied"
+ unless $curuser->access_right('View customer');
+
+my $ua = new LWP::UserAgent;
+my $response = $ua->get($url);
+</%init>