Welcome to the GoFuckYourself.com - Adult Webmaster Forum forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Post New Thread Reply

Register GFY Rules Calendar
Go Back   GoFuckYourself.com - Adult Webmaster Forum > >
Discuss what's fucking going on, and which programs are best and worst. One-time "program" announcements from "established" webmasters are allowed.

 
Thread Tools
Old 05-23-2012, 01:07 AM   #1
X_X_ROB_X_X
( ◣_◢ )
 
Industry Role:
Join Date: Jun 2007
Location: USA
Posts: 509
Are you any good with PHP?

I'm using a Geo Targeting script that was shared here a while ago. I've had some changes made to it to rotate the Tier1 URLs and split my AU, CA, UK, US traffic up between 2 separate affiliate links.

What I would like to do is also split up my Tier2 (foreign ) traffic the same way so I can send it to a couple different programs too. I've been messing with it for a while now but can't seem to get it to work.

Would any PHP coders mind having a look at it and showing me the best way to accomplish this?
Thanks in advance ;)

PHP Code:
<?php
    
    $geo 
unserialize(file_get_contents('http://www.geoplugin.net/php.gp?ip='.$_SERVER['REMOTE_ADDR']));
    
$countryCode $geo['geoplugin_countryCode'];

    
$a=array('AD''AE''AF''AG''AI''AL''AM''AN''AO''AQ''AR''AS''AT''AW''AX''AZ''BA''BB''BD''BE''BF''BG''BH''BI''BJ''BM''BN''BO''BR''BS''BT''BV''BW''BY''BZ''CC''CD''CF''CG''CH''CI''CK''CL''CM''CN''CO''CR''CS''CU''CV''CX''CY''CZ''DE''DJ''DK''DM''DO''DZ''EC''EE''EG''EH''ER''ES''ET''FI''FJ''FK''FM''FO''FR''FX''GA''GB''GD''GE''GF''GH''GI''GL''GM''GN''GP''GQ''GR''GS''GT''GU''GW''GY''HK''HM''HN''HR''HT''HU''ID''IE''IL''IN''IO''IQ''IR''IS''IT''JM''JO''JP''KE''KG''KH''KI''KM''KN''KP''KR''KW''KY''KZ''LA''LB''LC''LI''LK''LR''LS''LT''LU''LV''LY''MA''MC''MD''MG''MH''MK''ML''MM''MN''MO''MP''MQ''MR''MS''MT''MU''MV''MW''MX''MY''MZ''NA''NC''NE''NF''NG''NI''NL''NO''NP''NR''NU''NZ''OM''PA''PE''PF''PG''PH''PK''PL''PM''PN''PS''PT''PW''PY''QA''RE''RO''RU''RW''SA''SB''SC''SD''SE''SG''SH''SI''SJ''SK''SL''SM''SN''SO''SR''ST''SU''SV''SY''SZ''TC''TD''TF''TG''TH''TJ''TK''TL''TM''TN''TO''TP''TR''TT''TV''TW''TZ''UA''UG''UY''UZ''VA''VC''VE''VN''VU''WF''WS''YE''YT''YU''ZA''ZM''ZR''ZW'); 

    if (
in_array($countryCode$a)) {
        
header ('Location: http://www.Tier2-Affiliate-Link-1.com');
    } 
    else {
        
$destination_list = array(
            
'http://www.Tier1-Affiliate-Link-1.com',
            
'http://www.Tier1-Affiliate-Link-2.com'
        
);

        
$key rand(0count($destination_list) - 1);
        
        
header ('Location: '$destination_list[$key] .'');
        exit();
    }
?>
X_X_ROB_X_X is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 05-23-2012, 02:31 AM   #2
zerovic
Confirmed User
 
zerovic's Avatar
 
Industry Role:
Join Date: Apr 2010
Posts: 1,093
there you go, i have removed those ' things from the second header part..
so, instead of header ('Location: '. $destination_list[$key] .');
we just use header ('Location: ' . $destination_list[$key]);

PHP Code:

<?php
    
    $geo 
unserialize(file_get_contents('http://www.geoplugin.net/php.gp?ip='.$_SERVER['REMOTE_ADDR']));
    
$countryCode $geo['geoplugin_countryCode'];

    
$a=array('AD''AE''AF''AG''AI''AL''AM''AN''AO''AQ''AR''AS''AT''AW''AX''AZ''BA''BB''BD''BE''BF''BG''BH''BI''BJ''BM''BN''BO''BR''BS''BT''BV''BW''BY''BZ''CC''CD''CF''CG''CH''CI''CK''CL''CM''CN''CO''CR''CS''CU''CV''CX''CY''CZ''DE''DJ''DK''DM''DO''DZ''EC''EE''EG''EH''ER''ES''ET''FI''FJ''FK''FM''FO''FR''FX''GA''GB''GD''GE''GF''GH''GI''GL''GM''GN''GP''GQ''GR''GS''GT''GU''GW''GY''HK''HM''HN''HR''HT''HU''ID''IE''IL''IN''IO''IQ''IR''IS''IT''JM''JO''JP''KE''KG''KH''KI''KM''KN''KP''KR''KW''KY''KZ''LA''LB''LC''LI''LK''LR''LS''LT''LU''LV''LY''MA''MC''MD''MG''MH''MK''ML''MM''MN''MO''MP''MQ''MR''MS''MT''MU''MV''MW''MX''MY''MZ''NA''NC''NE''NF''NG''NI''NL''NO''NP''NR''NU''NZ''OM''PA''PE''PF''PG''PH''PK''PL''PM''PN''PS''PT''PW''PY''QA''RE''RO''RU''RW''SA''SB''SC''SD''SE''SG''SH''SI''SJ''SK''SL''SM''SN''SO''SR''ST''SU''SV''SY''SZ''TC''TD''TF''TG''TH''TJ''TK''TL''TM''TN''TO''TP''TR''TT''TV''TW''TZ''UA''UG''UY''UZ''VA''VC''VE''VN''VU''WF''WS''YE''YT''YU''ZA''ZM''ZR''ZW''RS'); 

    if (
in_array($countryCode$a)) {
        
header ('Location: http://www.Tier2-Affiliate-Link-1.com');
        echo 
"country found!";
    } 
    else {
        
$destination_list = array(
            
'http://www.Tier1-Affiliate-Link-1.com',
            
'http://www.Tier1-Affiliate-Link-2.com'
        
);

        
$key rand(0count($destination_list) - 1);        
        
header ('Location: ' $destination_list[$key]);
    }
?>

regards
__________________
php, html, jquery, javascript, wordpress - contact me at contact at zerovic.com
zerovic is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 05-23-2012, 02:47 AM   #3
X_X_ROB_X_X
( ◣_◢ )
 
Industry Role:
Join Date: Jun 2007
Location: USA
Posts: 509
After looking it over I'm not sure if this is doing what I need.

I'm basically wanting to have 2 URLs for Tier2 traffic too, then have it alternate the URLs for each visitor.

I'd like to give 50% of my foreign traffic to one link and the other 50% to another (just like the lower part of the code does)

PHP Code:
else {
        
$destination_list = array(
            
'http://www.Tier1-Affiliate-Link-1.com',
            
'http://www.Tier1-Affiliate-Link-2.com'
        
);

        
$key rand(0count($destination_list) - 1);
        
        
header ('Location: '$destination_list[$key] .''); 
X_X_ROB_X_X is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 05-23-2012, 04:27 AM   #4
zerovic
Confirmed User
 
zerovic's Avatar
 
Industry Role:
Join Date: Apr 2010
Posts: 1,093
oh well, the code actually works, however it gets a RANDOM number, not 50-50%...

PHP Code:
<?php
    
    $geo 
unserialize(file_get_contents('http://www.geoplugin.net/php.gp?ip='.$_SERVER['REMOTE_ADDR']));
    
$countryCode $geo['geoplugin_countryCode'];

    
$a=array('AD''AE''AF''AG''AI''AL''AM''AN''AO''AQ''AR''AS''AT''AW''AX''AZ''BA''BB''BD''BE''BF''BG''BH''BI''BJ''BM''BN''BO''BR''BS''BT''BV''BW''BY''BZ''CC''CD''CF''CG''CH''CI''CK''CL''CM''CN''CO''CR''CS''CU''CV''CX''CY''CZ''DE''DJ''DK''DM''DO''DZ''EC''EE''EG''EH''ER''ES''ET''FI''FJ''FK''FM''FO''FR''FX''GA''GB''GD''GE''GF''GH''GI''GL''GM''GN''GP''GQ''GR''GS''GT''GU''GW''GY''HK''HM''HN''HR''HT''HU''ID''IE''IL''IN''IO''IQ''IR''IS''IT''JM''JO''JP''KE''KG''KH''KI''KM''KN''KP''KR''KW''KY''KZ''LA''LB''LC''LI''LK''LR''LS''LT''LU''LV''LY''MA''MC''MD''MG''MH''MK''ML''MM''MN''MO''MP''MQ''MR''MS''MT''MU''MV''MW''MX''MY''MZ''NA''NC''NE''NF''NG''NI''NL''NO''NP''NR''NU''NZ''OM''PA''PE''PF''PG''PH''PK''PL''PM''PN''PS''PT''PW''PY''QA''RE''RO''RU''RW''SA''SB''SC''SD''SE''SG''SH''SI''SJ''SK''SL''SM''SN''SO''SR''ST''SU''SV''SY''SZ''TC''TD''TF''TG''TH''TJ''TK''TL''TM''TN''TO''TP''TR''TT''TV''TW''TZ''UA''UG''UY''UZ''VA''VC''VE''VN''VU''WF''WS''YE''YT''YU''ZA''ZM''ZR''ZW'); 

    if (
in_array($countryCode$a)) {
        
//header ('Location: http://www.google.com');
    
echo "your country: " $countryCode "<br />";
    echo 
"country found in the array!";
    } 
    else {
        
$destination_list = array(
            
'http://www.yahoo.com',
            
'http://www.bing.com'
        
);

        
$key rand(0count($destination_list) - 1);        
        
//header ('Location: ' . $destination_list[$key]);
    
echo "your country: " $countryCode "<br />";
    echo 
"country not found in the array! redirecting to " $destination_list[$key];
    }

?>
you'll get the idea ;)
__________________
php, html, jquery, javascript, wordpress - contact me at contact at zerovic.com
zerovic is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 05-23-2012, 06:50 AM   #5
HomerSimpson
Too lazy to set a custom title
 
HomerSimpson's Avatar
 
Industry Role:
Join Date: Sep 2005
Location: Springfield
Posts: 13,826
better get maxmind geoIP...
it will perform better than pulling the country from other site...
__________________
Make a bank with Chaturbate - the best selling webcam program
Ads that can't be block with AdBlockers !!! /// Best paying popup program (Bitcoin payouts) !!!

PHP, MySql, Smarty, CodeIgniter, Laravel, WordPress, NATS... fixing stuff, server migrations & optimizations... My ICQ: 27429884 | Email:
HomerSimpson is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 05-23-2012, 06:53 AM   #6
notjoe
Confirmed User
 
Industry Role:
Join Date: May 2002
Location: Toronto, Canada
Posts: 5,599
Quote:
Originally Posted by HomerSimpson View Post
better get maxmind geoIP...
it will perform better than pulling the country from other site...
Or at the very least use some sort of caching technology so you're not doing a remote lookup against every single ip address.

What he has might work for a few hits but once you get serious traffic it'll fail.
notjoe is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 05-23-2012, 07:50 AM   #7
X_X_ROB_X_X
( ◣_◢ )
 
Industry Role:
Join Date: Jun 2007
Location: USA
Posts: 509
Quote:
Originally Posted by notjoe View Post
Or at the very least use some sort of caching technology so you're not doing a remote lookup against every single ip address.

What he has might work for a few hits but once you get serious traffic it'll fail.
I've actually been pushing about 30k hits daily through this script the way it is and it seems to be doing fine. The foreign is being redirected to one site I use and the "good" traffic is going to 2 other programs I use.

I'm sure there are much better ways to do it but I didn't really see any reason to change it thus far (other than to try and split the foreign traffic up that is).
X_X_ROB_X_X is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Post New Thread Reply
Go Back   GoFuckYourself.com - Adult Webmaster Forum > >

Bookmarks



Advertising inquiries - marketing at gfy dot com

Contact Admin - Advertise - GFY Rules - Top

©2000-, AI Media Network Inc



Powered by vBulletin
Copyright © 2000- Jelsoft Enterprises Limited.