#!/usr/bin/perl # replacement for click-nj.cgi .. # this is like click.cgi but no buffer page 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"; # http://www.hpic.com:3000/click.cgi?file=4freegr@lbus3 my $query_str = $ENV{'QUERY_STRING'}; my ($script,$fragment); my %params; my @arg; # 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; } # 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); if( !$params{'file'} ) { print "Content-Type: text/plain\n\n"; print "error: no file\n"; exit; } # grab the 'file=' parameter (which is the 'e_name') and map to service_id.. 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\.//; # redirect to the right place #print "Content-Type: text/plain\n\n"; #print "Location: http://nm.$domain/$service_id\n\n"; 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/cgi-bin/clicks/buffer_nj?site_mask=$service_id$addlang&referer=$referer\n\n"; #http://signup.sitename.com/clicks/buffer_nj?site_mask=9999999993&referer=www.yahoo.com