PHP Developers Network

A community of PHP developers offering assistance, advice, discussion, and friendship.
 
Loading
It is currently Sun Mar 26, 2017 7:49 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 Contributor

Joined: Fri Sep 05, 2008 3:34 pm
Posts: 462
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.'  
'
;  
 
 

_________________
Hardcore Games Legendary is the Only Way to Play!
Vegan Advocate 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, Joomla and Drupal are some alternatives


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

Joined: Wed Aug 25, 2004 7:54 pm
Posts: 13385
Location: New York, NY, US
Vegan wrote:
PHP switch seems like the obvious choice

If you have something as structured as country codes, I would recommend using convention over code (like a switch statements). You can load the ad manager by either having database keys or file/folder names that use the country codes. That makes the system extensible by simply adding records or files/folders, rather than updating the code each time.

_________________
(#10850)


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

Joined: Wed Oct 15, 2008 2:35 am
Posts: 6379
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 Contributor

Joined: Fri Sep 05, 2008 3:34 pm
Posts: 462
Location: Victoria, BC
requinix wrote:
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.


That looks like an easier way to get it done, another issue, how to deal with cultural issues, try to offer products that appeal to the local market

My vegan site is one that I am considering some new ideas, I noticed PHP has fairly good support for DBF files, which can be leveraged possible more easily than other contains I can think of

_________________
Hardcore Games Legendary is the Only Way to Play!
Vegan Advocate 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, Joomla and Drupal are some alternatives


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

Joined: Wed Aug 25, 2004 7:54 pm
Posts: 13385
Location: New York, NY, US
Vegan wrote:
That looks like an easier way to get it done, another issue, how to deal with cultural issues, try to offer products that appeal to the local market
This kind of using convention to select based on a data point can load the appropriate code, but can also select the correct data. So you can access alternate data files as well.

Vegan wrote:
My vegan site is one that I am considering some new ideas, I noticed PHP has fairly good support for DBF files, which can be leveraged possible more easily than other contains I can think of
Hopefully you are only using DBF files for read-only data, unless your site is has low traffic. I would recommend using a regular database server like MySQL. If you are most comfortable using Excel or Access, you might want to create a work flow to export your data to CSV, upload it to the server, and import using LOAD DATA INFILE for database updates. That would allow you to work in the programs you are comfortable with, but have the site use a real database server with record locking.

_________________
(#10850)


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

Joined: Fri Sep 05, 2008 3:34 pm
Posts: 462
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

_________________
Hardcore Games Legendary is the Only Way to Play!
Vegan Advocate 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, Joomla and Drupal are some alternatives


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

Joined: Wed Aug 25, 2004 7:54 pm
Posts: 13385
Location: New York, NY, US
Vegan wrote:
Databases in the cloud are expensive, so I am looking to see what PHP can be leveraged to do
You have hosting that does not include a database? Can't you get hosting these days for under $5 a month?

Also, SQLite might be a good option to look into.

_________________
(#10850)


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

Joined: Fri Sep 05, 2008 3:34 pm
Posts: 462
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.

_________________
Hardcore Games Legendary is the Only Way to Play!
Vegan Advocate 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, Joomla and Drupal are some alternatives


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

Joined: Tue Nov 09, 2010 3:39 pm
Posts: 6192
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.

_________________
Supported PHP versions No longer supported versions


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

Joined: Fri Sep 05, 2008 3:34 pm
Posts: 462
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

_________________
Hardcore Games Legendary is the Only Way to Play!
Vegan Advocate 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, Joomla and Drupal are some alternatives


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: Bing [Bot] and 3 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