https://www.mediawiki.org/wiki/Special:Code/MediaWiki/102196

Revision: 102196
Author:   kaldari
Date:     2011-11-06 20:59:07 +0000 (Sun, 06 Nov 2011)
Log Message:
-----------
adding support for geoIP lookup to DonationInterface

Modified Paths:
--------------
    trunk/extensions/DonationInterface/gateway_common/DonationData.php

Modified: trunk/extensions/DonationInterface/gateway_common/DonationData.php
===================================================================
--- trunk/extensions/DonationInterface/gateway_common/DonationData.php  
2011-11-06 20:51:20 UTC (rev 102195)
+++ trunk/extensions/DonationInterface/gateway_common/DonationData.php  
2011-11-06 20:59:07 UTC (rev 102196)
@@ -280,6 +280,7 @@
                        $this->setGateway();
                        $this->setNormalizedOptOuts();
                        $this->setLanguage();
+                       $this->setCountry();
                        $this->handleContributionTrackingID();
                        $this->setCurrencyCode();
                        array_walk( $this->normalized, array( $this, 
'sanitizeInput' ) );
@@ -288,6 +289,25 @@
        
        /**
         * normalizeAndSanitize helper function
+        * Setting the country correctly.
+        */
+       function setCountry() {
+               global $wgRequest;
+               if ( !$this->isSomething('country') ){
+                       // If no country was passed, try to do GeoIP lookup
+                       // Requires php5-geoip package
+                       if ( function_exists( 'geoip_country_code_by_name' ) ) {
+                               $ip = wfGetIP();
+                               if ( IP::isValid( $ip ) ) {
+                                       $country = geoip_country_code_by_name( 
$ip );
+                                       $this->setVal('country', $country);
+                               }
+                       }
+               }
+       }
+       
+       /**
+        * normalizeAndSanitize helper function
         * Setting the currency code correctly. 
         */
        function setCurrencyCode() {


_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Reply via email to