This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
cgi_script_to_print_visitor_ip [2011/08/11 19:43] k2patel created |
cgi_script_to_print_visitor_ip [2011/10/10 17:45] k2patel |
||
---|---|---|---|
Line 1: | Line 1: | ||
<code cgi | index.cgi> | <code cgi | index.cgi> | ||
- | #!/usr/bin/perl -wT | + | #!/usr/bin/perl -wT |
- | # Ketan Patel | + | use CGI qw(:standard); |
- | + | print "Content-type: text/html\n\n"; | |
- | use strict; | + | #print "<pre>\n"; |
- | use CGI; | + | if ($ENV{HTTP_X_FORWARDED_FOR}){ |
- | my $q=CGI->new(); | + | print $ENV{HTTP_X_FORWARDED_FOR}; |
- | print $q->header().$q->remote_addr()."\n"; | + | } |
+ | else | ||
+ | { | ||
+ | print $ENV{REMOTE_ADDR}; | ||
+ | } | ||
+ | print "\n"; | ||
+ | </code> | ||
+ | |||
+ | Try it here !! | ||
+ | |||
+ | <code bash> | ||
+ | curl ip.k2patel.in | ||
</code> | </code> |