PERL
24
nph opt out
Guest on 10th July 2022 07:59:17 PM
#!/usr/bin/perl
use Time::Local;
$domain = ".realmedia.com";
$optoutname = "RMOPTOUT";
$future_time = "Friday, 31-Dec-2032 23:59:59";
$expire_time = "Tuesday, 2-Apr-2022 00:00:00";
%itsNodeHash = 0;
sub Decode
{
my ($words) = @_;
while ($words =~ /(\%[0-9A-F][0-9A-F])/)
{
my ($decode) = &DecodeToken ($1);
$words =~ s/$1/$decode/g;
}
$words =~ s/\+/ /g;
}
sub GetDataField
{
my ($name) = @_;
my ($values) = $itsNodeHash{$name};
}
#
# Main
#
#create the headers
my ($input);
my ($node);
if (! ($input = $ENV{"QUERY_STRING"}))
{
$input = <STDIN>;
}
foreach $node (split ('&', $input))
{
my ($name, $value) = split ('=', $node);
my ($decodedName) = &Decode ($name);
my ($decodedValue) = &Decode ($value);
my ($values) = $itsNodeHash{$decodedName};
push (@$values, $decodedValue);
$itsNodeHash{$decodedName} = $values;
}
#get the Domain
$domainKey = "Domain";
chomp ($tmpDomain = &GetDataField ($domainKey));
if (length($tmpDomain) > 0) { $domain = $tmpDomain; }
# Get the action
$actionKey = "Action";
chomp ($actionVal = &GetDataField ($actionKey));
print "HTTP/1.1 302 Moved Temporarily\n";
#this is the first request, so remove them all, set the opt-out, and redirect
foreach $cookie (split ('; ', $ENV{'HTTP_COOKIE'}))
{
my ($cook) = (split ('=', $cookie))[0];
print "Set-Cookie: $cook=0; path=/; domain= $domain; expires=$expire_time\n";
}
print "Set-Cookie: RMOPTOUT=3; path=/; domain= $domain; expires=$future_time\n";
#set the compact privacy policy
print "P3P: policyref=\"http://www.247realmedia.com/w3c/p3p.xml\",CP=\"NOI DSP COR NID CUR OUR NOR\"\n";
$setflag = 1;
print "Location: nph-opt_out.cgi?Action=check&Domain=$domain\n\r";
}
else {
#this is the second request. If there is no opt out cookie, or if there are other cookies in the domain, redirect to failure, otherwise redirect to success.
$fail = 0;
foreach $cookie (split ('; ', $ENV{'HTTP_COOKIE'}))
{
my ($cookieName) = (split ('=', $cookie))[0];
my ($cookieVal) = (split ('=', $cookie))[1];
if ($cookieName ne $optoutname) { $fail = 1;}
}
if ($fail > 0) { print "Location: http://www.networkadvertising.org/optout/opt_failure.gif\n\r"; }
else {print "Location: http://www.networkadvertising.org/optout/opt_success.gif\n\r"; }
}