#!/usr/bin/perl # replacement for click.cgi .. use strict; use lib "/global/lib/PerlPackages"; use Properties; my $prop = new Properties("hhdb.properties"); $main::dbfile = $prop->{'dbfile'}; use warnings; require "/global/lib/traceLog.pl"; require "hh-add-service_id.pl"; # URL encode/decode: ripped... sub URL_Encode { my($text) = $_[0]; $text =~ tr/ /+/; $text =~ s/[^A-Za-z0-9\+\*\.\@\_\-]/ uc sprintf("%%%02x",ord($&))/egx; return $text; } sub URL_Decode { my($text) = $_[0]; $text =~ tr/+/ /; $text =~ s/%([A-F0-9]{2})/pack("C", hex($1))/egi; return $text; } # http://www.hpic.com:3000/click.cgi?file=4freegr@lbus3 # http://www.hpic.com:3000/click.cgi?file=4freegr%40lbus3 # example target: # http://www.xxxescortsxxx.com/cgi-bin/click_s?site_mask=1234567890 my $query_str = $ENV{'QUERY_STRING'}; my ($script,$fragment); my %params; my @arg; # parse the arguments... if($query_str) { my $arglist; ($arglist,$fragment) = split(/\#/, $query_str); @arg = split(/&/,$arglist); my $x; foreach $x (@arg) { my ($n,$v) = split("=",$x); $params{$n}=$v; } } traceLog('DEBUG',__FILE__,__LINE__,%params); # grab the 'file=' parameter (which is the 'e_name') and map to service_id.. if( !$params{'file'} ) { print "Content-Type: text/plain\n\n"; print "error: no file\n"; exit; } my %rowhash = hh_query( URL_Decode( $params{'file'} ) ); traceLog('DEBUG',__FILE__,__LINE__,%rowhash); # add the service_id my $service_id= $rowhash{'service_id'}; my $domain = $rowhash{'url'}; $domain =~ s/www\.//; #print "Content-Type: text/plain\n\n"; # redirect to the right place.. if( $rowhash{'pkg_grp'} eq 'fetish' ) { if( $rowhash{'prod_cat'} eq 'S' ) { $script = "click_sf"; } else { $script = "click_gf"; } } else { if( $rowhash{'prod_cat'} eq 'S' ) { $script = "click_s"; } else { $script = "click_g"; } } # example target: # http://www.xxxescortsxxx.com/cgi-bin/click_s?site_mask=1234567890 my $addlang=""; if( $params{'lang'} ) { $addlang= "&lang=" . $params{'lang'}; } my $referer = URL_Encode( $ENV{'HTTP_REFERER'} ? $ENV{'HTTP_REFERER'} : "" ); #$referer =~ s/([^a-zA-Z0-9\.\-\_])/sprintf "%%%02X",ord($1)/eg; #print "Location: http://signup.$domain/clicks/buffer_nj?site_mask=$service_id&referer=$referer\n\n"; print "Location: http://www.$domain/cgi-bin/$script?site_mask=$service_id$addlang&referer=$referer\n\n";