BigCommerce - Hosted Ecommerce Software by Interspire

Interspire Forum

 
Go Back   Interspire Forum > Interspire Shopping Cart Community Forum > Customization and Integration > Code Modification and Development Questions

Reply
 
Thread Tools Display Modes
  #1  
Old 10-31-2014, 08:59 PM
Arin + Arin is offline
Interspire Customer
 
Join Date: Aug 2009
Posts: 11
Default Prevent store from loading based on IP address?

I want to completely prevent the online store from loading if the person accessing the store has an IP address other than one found in the USA.

I thought it would be as easy as editing the index.php file to something like this below. It actually works if they don't have a US IP address, but if they do I get “Fatal error: Cannot redeclare <function>” errors. I'm guessing it's loading functions a couple times in the index.php file based on how interspire works. Any ideas?

Code:
	include_once('GeoIP/geoipcity.inc');
	include_once('GeoIP/geoipregionvars.php');
	$gi = geoip_open('GeoIP/GeoIPCity.dat',GEOIP_STANDARD);
	$ip = $_SERVER['REMOTE_ADDR'];		
	$ipRecord = geoip_record_by_addr($gi,$ip);	
	if($ipRecord->country_code!='US'){
		geoip_close($gi);
		print '<p>The online store is for customers in the USA only. Please contact one of our <a href="http://www.example.com/">Local Importers</a> for pricing and purchasing in your country.';
	}else{
		include(dirname(__FILE__)."/init.php");
	
		// Visitor tracking Javascript
		if(isset($_REQUEST['action'])) {
			if($_REQUEST['action'] == "tracking_script") {
				$visitor = GetClass('ISC_VISITOR');
				$visitor->OutputTrackingJavascript();
			}
			else if($_REQUEST['action'] == "track_visitor") {
				$visitor = GetClass('ISC_VISITOR');
				$visitor->TrackVisitor();
			}
		}
	
		/**
		 * Index.php does something special - it passes off all requests
		 * to a worker function which decide on the page that should be
		 * shown.
		 */
		RewriteIncomingRequest();
		
	}

Last edited by Arin; 10-31-2014 at 09:05 PM..
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump