adayinthelife
Programmer
Hi,
I am having a problem getting my code to execute what is needed. It is sort of complex, but I think I have most of it down. Though, when I test it, it does not seem to work as I want it to.
Let me explain a bit, to give a little more info here:
I have a search engine, and as a Pay Per Click Search Engine owner, I think it is an invaluable tool to be able to block domain names that have abused, or incentivize traffic, etc...
Anyway, I have gotten the programming part done that allows me to put in the domain name and store it in a text file for later reading. That, I do not think is the problem.
But, what I want to happen, is to later check that data file against the referrering URL to my site. I use the $ENV{HTTP_REFERER} environmental variable to compare it to the domain I have set to be blocked like this:
################
##################
Sorry for the rather lengthy description, but shouldn't this work, if domain is matched to the $ENV{HTTP_REFERER} ?
I am not sure what else can be done in order to be able to get it to work properly. Would appreciate any feedback, ideas, etc - or alternate solutions to getting domains blocked, so that, only the domain name cannot access this part of the site, whereas, still, if there were 100 other sites on that same IP address of the domain in question, they would not have a problem accessing the site if they too were not also blocked.
Thanks to anyone who took the time to read this
Mike
I am having a problem getting my code to execute what is needed. It is sort of complex, but I think I have most of it down. Though, when I test it, it does not seem to work as I want it to.
Let me explain a bit, to give a little more info here:
I have a search engine, and as a Pay Per Click Search Engine owner, I think it is an invaluable tool to be able to block domain names that have abused, or incentivize traffic, etc...
Anyway, I have gotten the programming part done that allows me to put in the domain name and store it in a text file for later reading. That, I do not think is the problem.
But, what I want to happen, is to later check that data file against the referrering URL to my site. I use the $ENV{HTTP_REFERER} environmental variable to compare it to the domain I have set to be blocked like this:
################
Code:
[COLOR=maroon]# keyword has been clicked to initiate search to return
# results for that keyword clicked...
# this is the beginning of that process to be carried out
# where I set up the argument...[/color]
[b]sub dosearch {
my ($begin, $howmany, $thing, $paidname, $freename) = @_;[/b]
[COLOR=maroon]# below line is not related to the problem of the
# domains being banned, but is before where argument for
# domain matching is made, just so as to not confuse
# anymore so than I may have already :-)
[/color]
[b]require 'include/affapproval.cgi'; &checkaff($username);
if ($username ne '') { &idcheck; }[/b]
[COLOR=maroon] # here is where I set up to match domain.
[/color]
[b]if (($ENV{HTTP_REFERER}) ne '') { &domcheck; }[/b]
[COLOR=maroon]
# then goes through several routines for to search
# for keywords to bring back results, but if the above
# arguments were returned as being flagged, it is
# supposed to deny completing the search and returning
# results. So, getting to the next part...
[/color]
[b]sub domcheck {[/b]
[COLOR=maroon]
# $domfile contain the domains to check against[/color]
[b]$domfile = "$dir$data_dir/domfile.txt";[/b]
[COLOR=maroon] # referring to the environmental variable (HTTP_REFERER)
# as the $domain below.[/color]
[b]$domain = $ENV{HTTP_REFERER};[/b]
[COLOR=maroon]# stripping extra components from referring url...[/color]
[b]@url = split(/\/\//, $domain);
@url2 = split(/\//, $url[1]);[/b]
[COLOR=maroon]# arrive at final value to match against my data file[/color]
[b]$dom = $url2[0];[/b]
[COLOR=maroon]# put debug code in here to make sure it was stripping
# HTTP_REFERER properly and it does match the exact
# domain I had meant to match - ex: [URL unfurl="true"]www.domain.com[/URL]
# stripped out of
# [URL unfurl="true"]http://www.example.com/pages/search.php?ref=green[/URL] or
# whatever it may be - but strips to just [URL unfurl="true"]www.domain.com[/URL]
# and I confirmed it through my debug output[/color]
[b]if ($settings{'debug'}) { print DEBUG "\$dom - $dom\n"; }[/b]
[COLOR=maroon]# now checking file against domain name[/color]
[b]open(FILE,"$domfile");
flock(FILE,LOCK_SH|LOCK_NB);
flock(FILE,LOCK_SH);
while (<FILE>) {[/b]
[COLOR=maroon]# is supposed to redirect traffic if domain matches[/color]
[b]if ($_ =~ /^$dom$/) {
print "Content-type: text/html\n\n";
print qq~<html><head><meta http-equiv="Refresh" content="10; URL=http://yahoo.com/"><title>Domain Not Accepted</title></head><body><p>.explanation as to why they are going to be redirected</p></body></html>~;
exit;
}
}
close(FILE);
}[/b]
Sorry for the rather lengthy description, but shouldn't this work, if domain is matched to the $ENV{HTTP_REFERER} ?
I am not sure what else can be done in order to be able to get it to work properly. Would appreciate any feedback, ideas, etc - or alternate solutions to getting domains blocked, so that, only the domain name cannot access this part of the site, whereas, still, if there were 100 other sites on that same IP address of the domain in question, they would not have a problem accessing the site if they too were not also blocked.
Thanks to anyone who took the time to read this
Mike