Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

SOAP::Lite - Finding callers IP

by Biker (Priest)
on Jan 23, 2003 at 13:53 UTC ( [id://229307]=perlquestion: print w/replies, xml ) Need Help??

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

I'm playing around with SOAP::Lite as a CGI script.

My little CGI test script works fine, but I'm looking for a way to find out the IP address of the caller of the script. (I believe the IP address technically can be spoofed, but this is to be executed in a fairly trusted environment.)

It would be useful when logging unexpected input parameter contents to the CGI script and also (potentially) for statistics purposes.

I haven't found any hints in the docs I've read so far.

Any hints?


Everything went worng, just as foreseen.

Replies are listed 'Best First'.
Re: SOAP::Lite - Finding callers IP
by valdez (Monsignor) on Jan 23, 2003 at 14:03 UTC

    If you are using Apache, look into the %ENV variable; there you will find REMOTE_ADDR and other useful informations.

    Ciao, Valerio

      print_env.pl :
      print "Content-type: text/html\n\n"; print "<HTML> <HEAD><TITLE>Env</TITLE></HEAD> <BODY><TABLE>\n"; while (my ($k, $v) = each %ENV) { print "<TR><TD>$k</TD><TD> = $v</TD></TR>\n"; } print "</TABLE></BODY></HTML>";

      --
      Jaap Karssenberg || Pardus (Larus)? <pardus@cpan.org>
      >>>> Zoidberg: So many memories, so many strange fluids gushing out of patients' bodies.... <<<<

      I do use Apache, but I must keep my CGI script compatible between Apache and IIS V5. (Company policies.)

      And yes, I can find REMOTE_ADDR => in both environments.

      Great. Thanks a lot.


      Everything went worng, just as foreseen.

Re: SOAP::Lite - Finding callers IP
by foxops (Monk) on Jan 23, 2003 at 14:36 UTC
    How 'bout some inspiration.
    Please forgive all the forward slashing, I've got a hacked-up version of Perl <shrug>
    #!c:/Perl/bin/Perl.exe ## ## printenv -- demo CGI program which just prints its environment ## print "Content-type: text/plain\n\n"; print "\<HTML\>\n"; print "\<HEAD\>\n"; print " \<TITLE\>Testies, Testies, 1-2-3\<\/TITLE\>\n"; print "\<\/HEAD\>\n"; print "\<BODY BGCOLOR\=\"\#c0c0c0\" TEXT\=\"\#000000\" LINK\=\"\#ff000 +0\" VLINK\=\"\#0F0000\"\>\n"; foreach $var (sort(keys(%ENV))) { $val = $ENV{$var}; $val =~ s|\n|\\n|g; $val =~ s|"|\\"|g; print "${var}=\"${val}\"\n"; } print "\<\/BODY\>\<\/HTML\>\n";

    Update:foxops shakes fist at Pardus
      Ugghh! Printing HTML like that, while good at getting stuff done farily quickly, is not recommended for those who wish to learn and grow. How about this instead:
      use strict; use warnings; use CGI qw(:standard); print header, start_html( -title => 'Testing 1-2-3', -bgcolor => '#c0c0c0', ), ul(li[map qq|$_ => "$ENV{$_}"|,keys %ENV]), end_html, ;
      Or this:
      use strict; use warnings; use CGI qw(header); use HTML::Template; my $tmpl = HTML::Template->new(filehandle => \*DATA); $tmpl->param(env => [ map {{ key => $_, val => $ENV{$_}, }} keys %ENV ]); print header, $tmpl->output; __DATA__ <html> <head> <title>Testing 1-2-3</title> </head> <body bgcolor="#c0c0c0"> <ul> <tmpl_loop env> <li><tmpl_var key> = "<tmpl_var name="val" escape="HTML">" </tmpl_loop> </ul> </body> </html>
      And ... if you still insist on printing out HTML like you did, then at least check out the q and qq operators:
      # look ma, no slashes! print qq|${var} = "${val}"\n|; print q|<body bgcolor="#c0c0c0">\n|;

      jeffa

      L-LL-L--L-LL-L--L-LL-L--
      -R--R-RR-R--R-RR-R--R-RR
      B--B--B--B--B--B--B--B--
      H---H---H---H---H---H---
      (the triplet paradiddle with high-hat)
      

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://229307]
Approved by newrisedesigns
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others sharing their wisdom with the Monastery: (2)
As of 2024-11-10 01:39 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    chatterbot is...






    Results (36 votes). Check out past polls.