Hi, I was just wondering if anyone knows of a simple tutorial for displaying YPN ads to usa visitors and adsense ads to international visitors? Is there a script a guy could get?
Here is a simple way to do it. Is fairly accurate. <?PHP $ip = $_SERVER[REMOTE_ADDR]; $ip = gethostbyaddr($ip); $ip = substr($ip,(strlen($ip)-3),strlen($ip)); if ($ip == "com") { echo("in america"); } else { echo("you are a forign dueche"); } ?> Code (markup):
are you serious or just messin with me, that code looks like it would be something that would block ALL traffic or something
That will tell you if someone is domestic to the US or foriegn. The implamentation is up to you. Good luck...
ok thats cool , but could you display what this code is actually doing and how it is determining if the person is from the usa or not? $ip = $_SERVER[REMOTE_ADDR]; $ip = gethostbyaddr($ip); $ip = substr($ip,(strlen($ip)-3),strlen($ip)); if ($ip == "com") { Code (markup):
My ISP and host that I have used for almost 10 years does not offer PHP or MySql support. Any other ways to show non usa visitors Adsense ads instead of YPN ? javascript ?
<?PHP $ip = $_SERVER[REMOTE_ADDR]; $ip = gethostbyaddr($ip); $ip = substr($ip,(strlen($ip)-3),strlen($ip)); if ($ip == "com") { echo("YOUR YPN CODE HERE"); } else { echo("YOUR ADSENSE CODE HERE"); } ?> Code (markup): Just put that where your ads would be
Hey, have a look here: http://www.maxmind.com/app/geoip_country They offer a free (GPL) ip2country database and also some scripting help. I'm using it and works great!! You just have to put your ads in a switch-case depending on the country code (which is easily obtained - have a look at their files! Details on their php module here: http://www.maxmind.com/app/php ) Hope this helps
Has anybody got this working? I have no idea what the code means. What does "com" do? And how do i test the accuracy of this? Do i tell my foreign friends to help me check the ads? Or do i go proxy site to do it? ANybody knows of any proxy site where they offer foreign ip or something?
I currently have my geotargetting set up through PHPAdsNew, but it's a little too much for my needs. If anyone has a simpler geotargetting script (one that connects to an IP database and not a simple host filter) please post here if you're comfortable doing so or email me at tomfadial@gmail.com
<? include("geoip.inc"); $gi = geoip_open("GeoIP.dat",GEOIP_STANDARD); $visitor_country_code=geoip_country_code_by_addr($gi, $_SERVER['REMOTE_ADDR']); $visitor_country_name=geoip_country_name_by_addr($gi, $_SERVER['REMOTE_ADDR']); ?> PHP: In order for this to work, you need to get these files: - GeoIP.dat from http://www.maxmind.com/app/geoip_country - geoip.inc from http://www.maxmind.com/download/geoip/api/php/ You can use $visitor_country_code and $visitor_country_name to target your ads country specific. I'll be working on a script for this, 'cause phpadsnew is way too complex for just doing that. I hope this time you took the time to read the post, it's all written above as well.
Ufff... After you've done all of the above you can use - let's say - $visitor_country_code this way: <? switch ($visitor_country_code) { case "AU": { switch ($vrand=rand(1,2)) { case 1: { //1st banner for Australian visitors ?> HTML CODE FOR ADSENSE OR WHATEVER <? } break; case 2: { //2nd banner for Australian visitors } break; } break; case "RO": { //banner for Romanian visitors } break; default: { // any country not mentioned } } ?> Code (markup): When you put the banner codes, don't forget to close php "?>" and open it "<?" after the HTML code I hope that is clear. The above script is not copy/pasted (not verified) so I hope all syntaxes are ok . If you have troubles, post the error here
ok so this would be the exact code to display YPN ads to all usa visitors and adsense ads to all people in other countries? thats how I would like to have it set up if possible