PHP Developers Network

A community of PHP developers offering assistance, advice, discussion, and friendship.
 
Loading
It is currently Sat Aug 24, 2019 1:55 pm

All times are UTC - 5 hours




Post new topic Reply to topic  [ 10 posts ] 
Author Message
PostPosted: Tue Dec 01, 2015 6:05 pm 
Offline
Forum Regular

Joined: Fri Sep 05, 2008 3:34 pm
Posts: 540
Location: Victoria, BC
my site gets a lot of international traffic and right now I have US and UK ads available

so I was wondering, PHP switch seems like the obvious choice, then I can load the ad manager that is suitable for the visitor's local needs etc

I was considering new ideas but I am not sure about the best approach for a globalized site

Syntax: [ Download ] [ Hide ]
/*Get ip address*/  
 
$ip=$_SERVER['REMOTE_ADDR'];  
 
/* Now get ip details  with geoplugin.net      */  
 
$geopluginURL='http://www.geoplugin.net/php.gp?ip='.$ip;  
$unarr= file_get_contents($geopluginURL);     // Get File Contents  
$AddArr = unserialize($unarr);    // Get PHP values from file contents  
 
/* print_r($AddArr); */  // Print all the values  
 
$city = $AddArr['geoplugin_city'];  // City Name  
 
 
$country = $AddArr['geoplugin_countryName']; // Country Name  
 
$country_code = $AddArr['geoplugin_countryCode']; // Country Code  
 
$currency_code = $AddArr['geoplugin_currencyCode']; // Country Name  
 
$latitude = $AddArr['geoplugin_latitude']; // Latitude  
 
$longitude = $AddArr['geoplugin_longitude']; // Latitude  
 
 
echo '<strong>IP Address</strong>:- '.$ip.'  
'
;  
echo '<strong>City</strong>:- '.$city.'  
'
;  
echo '<strong>Country</strong>:- '.$country.'  
'
;  
echo '<strong>Country Code</strong>:- '.$country_code.'  
'
;  
echo '<strong>Currency Code</strong>:- '.$currency_code.'  
'
;  
echo '<strong>Latitude </strong>:- '.$latitude.'  
'
;  
echo '<strong>Longitude </strong>:- '.$longitude.'  
'
;  
 
 

_________________
Legendary is the Only Way to Play!
16 lbs grain to make only 1 lb meat, water for 6 months of showers and 34.1 lbs carbon dioxide
My sites are made with WordPress, which is a content management system which now accounts for more than 60% of all websites


Top
 Profile  
 
PostPosted: Tue Dec 01, 2015 6:32 pm 
Offline
Site Administrator
User avatar

Joined: Wed Aug 25, 2004 7:54 pm
Posts: 13592
Location: New York, NY, US

_________________
(#10850)


Top
 Profile  
 
PostPosted: Tue Dec 01, 2015 8:08 pm 
Offline
Spammer :|
User avatar

Joined: Wed Oct 15, 2008 2:35 am
Posts: 6617
Location: WA, USA
Basically the code goes like
Syntax: [ Download ] [ Hide ]
$file = "/path/to/ads/{$country}/index.php";
if (!is_file($file)) {
        $file = "/path/to/ads/default/index.php";
}
include $file;

Using more PHP code gives you flexibility, or you use straight ad HTML or whatever for simplicity. Point is, you pick a filename, and if that thing doesn't exist then you use a default instead. Want to add stuff for a new country? Drop the files right in.


Top
 Profile  
 
PostPosted: Thu Dec 03, 2015 4:07 pm 
Offline
Forum Regular

Joined: Fri Sep 05, 2008 3:34 pm
Posts: 540
Location: Victoria, BC

_________________
Legendary is the Only Way to Play!
16 lbs grain to make only 1 lb meat, water for 6 months of showers and 34.1 lbs carbon dioxide
My sites are made with WordPress, which is a content management system which now accounts for more than 60% of all websites


Top
 Profile  
 
PostPosted: Thu Dec 03, 2015 5:21 pm 
Offline
Site Administrator
User avatar

Joined: Wed Aug 25, 2004 7:54 pm
Posts: 13592
Location: New York, NY, US

_________________
(#10850)


Top
 Profile  
 
PostPosted: Thu Dec 03, 2015 5:39 pm 
Offline
Forum Regular

Joined: Fri Sep 05, 2008 3:34 pm
Posts: 540
Location: Victoria, BC
very little to no writes to the DBF file, 99.9% would be all read access

any writes would be a simple add to the table, however I see PHP does support PACK so at least I do not have to open FoxPro or other classic development tools

I was considering using a simple DBF to store recipes in, seems like an easy way to store them

Databases in the cloud are expensive, so I am looking to see what PHP can be leveraged to do

some databases I have are in Access format, so I have to figured out how to best leverage what I have

_________________
Legendary is the Only Way to Play!
16 lbs grain to make only 1 lb meat, water for 6 months of showers and 34.1 lbs carbon dioxide
My sites are made with WordPress, which is a content management system which now accounts for more than 60% of all websites


Top
 Profile  
 
PostPosted: Thu Dec 03, 2015 7:47 pm 
Offline
Site Administrator
User avatar

Joined: Wed Aug 25, 2004 7:54 pm
Posts: 13592
Location: New York, NY, US

_________________
(#10850)


Top
 Profile  
 
PostPosted: Fri Dec 04, 2015 6:16 am 
Offline
Forum Regular

Joined: Fri Sep 05, 2008 3:34 pm
Posts: 540
Location: Victoria, BC
I am considering mostly what I can do directly with PHP and JavaScript so that the site can be moved around easily. So any resource needs to be in the document root or a subfolder.

_________________
Legendary is the Only Way to Play!
16 lbs grain to make only 1 lb meat, water for 6 months of showers and 34.1 lbs carbon dioxide
My sites are made with WordPress, which is a content management system which now accounts for more than 60% of all websites


Top
 Profile  
 
PostPosted: Fri Dec 04, 2015 7:40 am 
Offline
Moderator
User avatar

Joined: Tue Nov 09, 2010 3:39 pm
Posts: 6425
Location: Montreal, Canada
MySQL is fairly ubiquitous so shouldn't pose a problem. An SQLite database would be stored as a file right in your project's directory structure, so should also be very portable. Just something to consider.

_________________


Top
 Profile  
 
PostPosted: Fri Dec 04, 2015 1:54 pm 
Offline
Forum Regular

Joined: Fri Sep 05, 2008 3:34 pm
Posts: 540
Location: Victoria, BC
dBase tables are OK for my needs, a lot of the functionality needed is already intrinsic with PHP and I suspect it will remain useful as the old database is still a solid workhorse

Once I figure out some nutritional databases I have I was thinking of how best to leverage them which gets back to the recipes database, so clearly I need to consider a lot of options

_________________
Legendary is the Only Way to Play!
16 lbs grain to make only 1 lb meat, water for 6 months of showers and 34.1 lbs carbon dioxide
My sites are made with WordPress, which is a content management system which now accounts for more than 60% of all websites


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 10 posts ] 

All times are UTC - 5 hours


Who is online

Users browsing this forum: Google [Bot] and 9 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB® Forum Software © phpBB Group