X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~yarrgweb/git?p=ypp-sc-tools.web-live.git;a=blobdiff_plain;f=yarrg%2FCommods.pm;h=0f7ebd63a253919301b58c90855c42284c5295f7;hp=62c1f5e6e94dd21d468d19923d5ea3e4840a7dbd;hb=e1104ec9b3f093f6c496cd9763b06b0792b679ff;hpb=a0dfb8222afa87d6fabaa8234da89e2a1b57ea5a diff --git a/yarrg/Commods.pm b/yarrg/Commods.pm index 62c1f5e..0f7ebd6 100644 --- a/yarrg/Commods.pm +++ b/yarrg/Commods.pm @@ -41,7 +41,8 @@ BEGIN { &pipethrough_prep &pipethrough_run &pipethrough_run_along &pipethrough_run_finish &pipethrough_run_gzip - &cgipostform &yarrgpostform); + &cgipostform &yarrgpostform &cgi_get_caller + &set_ctype_utf8); %EXPORT_TAGS = ( ); @EXPORT_OK = qw(); @@ -220,6 +221,9 @@ sub get_our_version ($$) { chomp($version); $aref->{"${prefix}version"}= $version; return $aref; + # clientname "ypp-sc-tools" + # clientversion 2.1-g2e06a26 [from git-describe --tags HEAD] + # clientfixes "lastpage" [space separated list] } sub pipethrough_prep () { @@ -340,4 +344,21 @@ sub check_tsv_line ($$) { return @v; } +sub cgi_get_caller () { + my $caller= $ENV{'REMOTE_ADDR'}; + $caller= 'LOCAL' unless defined $caller; + + my $fwdf= $ENV{'HTTP_X_FORWARDED_FOR'}; + if (defined $fwdf) { + $fwdf =~ s/\s//g; + $fwdf =~ s/[^0-9.,]/?/g; + $caller= "$fwdf"; + } + return $caller; +} + +sub set_ctype_utf8 () { + setlocale(LC_CTYPE, "en.UTF-8"); +} + 1;