#!/usr/bin/perl use CGI::Carp qw(fatalsToBrowser); use strict; use CGI::Simple; #use CGI_Lite; require 'config.pl'; main(); sub main { my ($urlGet) = ($ENV{'QUERY_STRING'} or $ENV{'PATH_INFO'}); my $strCamp = ""; # If IIS, remove the script name if($ENV{'PerlXS'} eq 'PerlIS') { $urlGet =~ s/^$ENV{SCRIPT_NAME}// if(!$ENV{'QUERY_STRING'}); } # Split the querystring into "campaign" and "go" my ($strCamp, $go) = split(/&/, $urlGet, 2); # The camp code is the first token in the input string $strCamp = $1 if($strCamp =~ m/^[\/\?]?(.+)/); # Remove any fake trailing ".html" or ".htm" $strCamp =~ s/\.html?$//; # Remove invalid characters $strCamp =~ s/[^a-zA-Z0-9_.]//gs; # Limit the length of the campaign code $strCamp = substr($strCamp, 0, 20); # If campaign is empty, set it to default if ($strCamp eq "") { $strCamp = $::strCampCodeDefault; } # Get value for "go" my $objCGI = CGI::Simple->new($go); $go = $objCGI->param("go"); # my $objCGI = CGI_Lite->new(); # my $rhCGI = $objCGI->parse_form_data(); # $go = $rhCGI->{"go"}; # Log click putLog($strCamp); # Construct Travis URL my $strUrl = "$::travisSrvUrl?name=$::strCasinoName"; $strUrl .= "&camp=$strCamp" if($strCamp); $strUrl .= "&go=$go" if($go); # Redirect print "Location: $strUrl\n\n"; exit(0); } sub putLog { my ($strCampClick) = @_; local *OUTLOG; # my $s; open(OUTLOG, ">>$::fileCampLog") or return(0); flock(OUTLOG, 2); print OUTLOG gmtime() . "\t" . $strCampClick . "\t" . $ENV{HTTP_REFERER} . "\n"; close(OUTLOG); return(1); }