dealing with hosts files etc

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
Vegan
Forum Regular
Posts: 574
Joined: Fri Sep 05, 2008 3:34 pm
Location: Victoria, BC
Contact:

dealing with hosts files etc

Post by Vegan »

I have now developed some strong countermeasures to ad block users, this is a growing problem that is best described as pervasive

I used a google custom job to show the use of ad blockers, it was not pretty

one angle that comes to mind is the growing use of HOSTS files to block domains etc

so I was wondering if there is any easy way to identify if the URL is not working with PHP which can then echo the result

I was also pondering using hard coded IP addresses as well
Hardcore Games™ Legendary is the Only Way to Play™
My site is powered by LAMP
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: dealing with hosts files etc

Post by requinix »

PHP can't do anything about this - the problem is entirely client-side.

With a hosts file entry, pretty much any request to a blacklisted domain will fail. You can have Javascript check for that. Or check if a referenced variable in an ad script was defined. But your options are limited as you can't use Javascript to hit up another domain unless they've specifically allowed it.
User avatar
Vegan
Forum Regular
Posts: 574
Joined: Fri Sep 05, 2008 3:34 pm
Location: Victoria, BC
Contact:

Re: dealing with hosts files etc

Post by Vegan »

can PHP find the IP address of a given URL so I can use that to assemble ads by hard coded IP address to circumvent the HOSTS
Hardcore Games™ Legendary is the Only Way to Play™
My site is powered by LAMP
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: dealing with hosts files etc

Post by requinix »

That wouldn't help: an IP address corresponds to a server, not to a website, and nowadays most servers provide more than one site at a time. When the browser requests //ads.example.com/ad.js it will send two pieces of information to the server: the path (/ad.js) and the hostname (ads.example.com). The server needs the right hostname to know the right site to use. If the hostname is just an IP address then the server doesn't know which of the number of sites it has configured that the request should go to.

For example, http://www.devnetwork.net and forums.devnetwork.net go to the same server, 68.168.223.237, and if you go there then the server won't know what to do and will give you a generic error message. (Another possibility is that it would just pick the "first" site it has configured, but that would be a poorly configured web server.)
User avatar
Vegan
Forum Regular
Posts: 574
Joined: Fri Sep 05, 2008 3:34 pm
Location: Victoria, BC
Contact:

Re: dealing with hosts files etc

Post by Vegan »

i suspect Amazon has a dedicated server for their ad host
Hardcore Games™ Legendary is the Only Way to Play™
My site is powered by LAMP
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: dealing with hosts files etc

Post by requinix »

Which domain name? It's pretty easy to check.
User avatar
Vegan
Forum Regular
Posts: 574
Joined: Fri Sep 05, 2008 3:34 pm
Location: Victoria, BC
Contact:

Re: dealing with hosts files etc

Post by Vegan »

ws-na.amazon-adsystem.com
Hardcore Games™ Legendary is the Only Way to Play™
My site is powered by LAMP
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: dealing with hosts files etc

Post by requinix »

So I can't confirm whether the server hosts multiple sites, but I can try finding some random URL online and seeing if that works with an IP address.

And it isn't.

Code: Select all

http://ws-na.amazon-adsystem.com/widgets/q?ServiceVersion=20070822&Operation=GetAdHtml&ID=OneJS&OneJS=1&source=ss&ref=ss_til&ad_type=product_link&tracking_id=woodandshop-20&marketplace=amazon&region=US&placement=B001ONHUAA&asins=B001ONHUAA&show_border=true&link_opens_in_new_window=true&MarketPlace=US

Code: Select all

http://176.32.100.230/widgets/q?ServiceVersion=20070822&Operation=GetAdHtml&ID=OneJS&OneJS=1&source=ss&ref=ss_til&ad_type=product_link&tracking_id=woodandshop-20&marketplace=amazon&region=US&placement=B001ONHUAA&asins=B001ONHUAA&show_border=true&link_opens_in_new_window=true&MarketPlace=US
Try the same with one of your URLs to see if the IP address works.
User avatar
Vegan
Forum Regular
Posts: 574
Joined: Fri Sep 05, 2008 3:34 pm
Location: Victoria, BC
Contact:

Re: dealing with hosts files etc

Post by Vegan »

It looks like the IP address does not work as desired

so much for that idea

any other suggestions to get around blocking with HOSTS
Hardcore Games™ Legendary is the Only Way to Play™
My site is powered by LAMP
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: dealing with hosts files etc

Post by requinix »

Not really. You can still do the Javascript detection and present a message about allowing ads on your site.
User avatar
Vegan
Forum Regular
Posts: 574
Joined: Fri Sep 05, 2008 3:34 pm
Location: Victoria, BC
Contact:

Re: dealing with hosts files etc

Post by Vegan »

Unfortunately it does seem that all I can do is use JS, other ideas have come up short

I am using this idea now, send miscreants to Chilling effects where DCMA is taken more seriously

Code: Select all

if(window.isAdsDisplayed === undefined ) {
  // AdBlock is enabled. Show message or track custom data here
  		busted = document.cookie; // check for an existing cookie
  		if (busted) {
  			href = "https://www.chillingeffects.org/";
  		else {
  			document.cookie("adblock=true");
  			alert("An ad blocker has been detected. Please remove the program to use this site. This is an ad supported small business.\n Ad blocking destroys web content which needs a revenue source to survive.\n Adblockers and click fraud have cause so much economic damage that many sites have been forced to close.\n Your webmaster needs to eat too, let alone the cost of web hosting etc. \n\n This site cannot afford to to use a higher service level when traffic is heavy.");
  		}
}
Recently 275,000 requests on a single day makes me wonder what is wrong? That happened on October 26, 2015
Hardcore Games™ Legendary is the Only Way to Play™
My site is powered by LAMP
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: dealing with hosts files etc

Post by requinix »

Yeah... That's definitely the best way to make sure I remove your site from my search results and never go back to it again.
User avatar
Vegan
Forum Regular
Posts: 574
Joined: Fri Sep 05, 2008 3:34 pm
Location: Victoria, BC
Contact:

Re: dealing with hosts files etc

Post by Vegan »

requinix wrote:Yeah... That's definitely the best way to make sure I remove your site from my search results and never go back to it again.
I have seen a sharp increase in page views, looks like this is working properly with the desired effect

Page views are now up more than 2x and I am tracking the use of adblock against my ads to see how its working
Hardcore Games™ Legendary is the Only Way to Play™
My site is powered by LAMP
Post Reply