Thread: geo4zen add-on

Results 1 to 10 of 14

Hybrid View

  1. #1
    Join Date
    Jul 2006
    Location
    SF Bay Area
    Posts
    867
    Plugin Contributions
    1

    Default geo4zen add-on

    This adds a simple way to detect the country of your customer.

    By default, the module sets a session variable you can use in your own programming.

    for example:

    if($_SESSION['customers_geo_iso'] == "CA") {some nice PHP code here...;}

    It also sets $_SESSION['customers_geo_country'] with the text name of the country.

    To make it a small bit useful out of the box, it includes a mechanism to either deny or allow access to the site on a country by country basis, and to specify an action for blocked countries. The default is to send a header re-direct to google, but you can be creative here and customize this action.

    The default here is to deny access to IP's originating in the countries listed at the beginning if the ipcheck.php file. Edit these (line 4) as you wish.

    To change the default action to Allow Only, edit line 50 of ipcheck .php and add the negation char to the in_array statement.

    ie:
    if (!in_array($iso2, $ban_array)){
    // what to do with banned countries. Default = send them to google...
    header('Location: http://www.google.com/');
    exit;
    }

    This will now allow access only to those countries defined at the top of the script.

    Some other creative uses...

    Here is where you must be creative. One example is if you own stores in different geographical areas, you can route customers to the proper store. For instance, you can easily route European customers to your .co.uk shop, and North American customers to your .com shop.

    Another idea may be to set the store mode (normal vs showcase) based on customers location.

    This is not 100% fool-proof as you can proxy around it if you are determined, but it has proven quite handy in some sites I do.

    If you have any questions or find bad bugs, please post them to this thread.
    Maybe post your nice code built using this.

    There are some more details in the packages readme file.

    Please be careful and test well before using this in a live shop.

    Kiddo

  2. #2
    Join Date
    Jun 2008
    Posts
    54
    Plugin Contributions
    2

    Default Re: geo4zen add-on

    Hey, Kiddo. What lovely code! It would have been beautiful if it worked for me, but it somehow doesn't. All I am looking for is to redirect users from a specific country to a different site. To test it, I added US to the list of the "banned" countries, but it does not redirect me. I followed all your instructions, and currently the CSV is in the root.

    My server is a WIMP - Windows IIS, MySQL, PHP. Does that matter?

    Here is the edited portion of my ipcheck.php:

    Code:
    <?php
    // Add the two letter iso country codes you want to ban to the line below.
    // NG=Nigeria KR=Korea TH=Thailand CN=China...
    $ban_array = array("US");
    Last edited by dimmyr; 4 Feb 2009 at 04:54 AM.

  3. #3
    Join Date
    Jun 2008
    Posts
    54
    Plugin Contributions
    2

    Default Re: geo4zen add-on

    Quick update - I just placed the ipcheck.php file in the root of my WIMP server and browsed straight to it, with a blank browser as a result. When I did the same thing on a linux machine, it redirected just fine. Soooo, what is the difference between IIS and Apache that your script doesn't work in IIS?

  4. #4
    Join Date
    Jul 2006
    Location
    SF Bay Area
    Posts
    867
    Plugin Contributions
    1

    Default Re: geo4zen add-on

    I will be at my dev machine in an hour or so and try to help you.

  5. #5
    Join Date
    Jun 2008
    Posts
    54
    Plugin Contributions
    2

    Default Re: geo4zen add-on

    You rock, Kiddo.

    Here is some more snooping that I've done. So I tried to debug the HTTP traffic, and found that on the Linux box the stream lists the Location variable from your script and redirects using 302:

    Code:
    HTTP/1.1 302 Moved Temporarily
    Date: Wed, 04 Feb 2009 04:27:11 GMT
    Server: Apache/2.2.11 (Unix) mod_ssl/2.2.11 OpenSSL/0.9.8i DAV/2 mod_auth_passthrough/2.1 mod_bwlimited/1.4 FrontPage/5.0.2.2635
    X-Powered-By: PHP/5.2.8
    Location: http://www.google.com/
    Content-Length: 0
    Keep-Alive: timeout=15, max=100
    Connection: Keep-Alive
    Content-Type: text/html
    But on the IIS box, that "Location:" is missing in the stream:

    Code:
    HTTP/1.1 200 OK
    Content-Type: text/html
    Server: Microsoft-IIS/6.0
    X-Powered-By: ASP.NET
    MicrosoftOfficeWebServer: 5.0_Pub
    X-Powered-By: PHP/5.2.6
    Date: Wed, 04 Feb 2009 04:27:22 GMT
    Connection: close

  6. #6
    Join Date
    Jun 2008
    Posts
    54
    Plugin Contributions
    2

    Default Re: geo4zen add-on

    Ok, more info. I am not a PHP programmer by far. I just cut and paste. So I created a small PHP file with the following code on the root of the IIS site:

    Code:
    <?php
    header('HTTP/1.1 301 Moved Permanently');
    header('Location: http://www.google.com/');
    ?>
    And it worked. Which means that the whole IF statement is not working or the script is not parsing the IP CSV site...

 

 

Similar Threads

  1. Looking for an Add-On that allows admin to add fields to a product
    By tcarden in forum All Other Contributions/Addons
    Replies: 2
    Last Post: 24 Jun 2014, 08:38 PM
  2. v139h Geo4Zen & Multisite
    By gazag in forum All Other Contributions/Addons
    Replies: 1
    Last Post: 18 Feb 2012, 04:24 AM
  3. how can i add add to cart with image on front page
    By chrisnasah in forum Templates, Stylesheets, Page Layout
    Replies: 0
    Last Post: 24 Oct 2010, 04:39 PM
  4. Remove add to cart & add box from product listing!!!
    By hcd888 in forum Templates, Stylesheets, Page Layout
    Replies: 3
    Last Post: 28 May 2008, 12:27 PM
  5. Is it possible to add an images section to store without price/add to cart?
    By jdjohnson99 in forum Templates, Stylesheets, Page Layout
    Replies: 3
    Last Post: 12 Sep 2007, 04:37 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg