visitor_country_ip_redirect - Version 0.0.4

Version Notes

0.0.4 - new features: logging, landing URL, redirect once etc.
0.0.3 - Initial release.

Download this release

Release Info

Developer Liudas Stanevicius
Extension visitor_country_ip_redirect
Version 0.0.4
Comparing to
See all releases


Code changes from version 0.0.3 to 0.0.4

app/code/local/Creation/Afipredirect/Adminhtml/Model/System/Config/Source/Countrylookupproviders.php CHANGED
@@ -1,38 +1,38 @@
1
- <?php
2
- /**
3
- * @category Creation
4
- * @package Creation_Afipredirect
5
- * @author Liudas Stanevicius <liudas@creation.lt>
6
- * @copyright Elsoft, UAB (www.creation.lt) <info@creation.lt>
7
- */
8
-
9
- class Creation_Afipredirect_Adminhtml_Model_System_Config_Source_Countrylookupproviders extends Mage_Core_Model_Config_Data
10
- {
11
-
12
- /**
13
- * Options getter
14
- *
15
- * @return array
16
- */
17
- public function toOptionArray()
18
- {
19
- return array(
20
- array('value' => 'geoplugin', 'label'=>Mage::helper('adminhtml')->__('geoplugin.net')),
21
- array('value' => 'hostip', 'label'=>Mage::helper('adminhtml')->__('hostip.info')),
22
- array('value' => 'iptolatlng', 'label'=>Mage::helper('adminhtml')->__('iptolatlng.com')),
23
- );
24
- }
25
-
26
- public function save()
27
- {
28
- $service_provider = $this->getValue();
29
-
30
- if($service_provider != Mage::getStoreConfig( 'afipredirect/settings/country_lookup_service' ))
31
- {
32
- Mage::getSingleton('core/session')->addNotice ('You have changed the Country lookup service provider. Have in mind, that different providers could return different results.');
33
- }
34
-
35
- return parent::save();
36
- }
37
-
38
  }
1
+ <?php
2
+ /**
3
+ * @category Creation
4
+ * @package Creation_Afipredirect
5
+ * @author Liudas Stanevicius <liudas@creation.lt>
6
+ * @copyright Elsoft, UAB (www.creation.lt) <info@creation.lt>
7
+ */
8
+
9
+ class Creation_Afipredirect_Adminhtml_Model_System_Config_Source_Countrylookupproviders extends Mage_Core_Model_Config_Data
10
+ {
11
+
12
+ /**
13
+ * Options getter
14
+ *
15
+ * @return array
16
+ */
17
+ public function toOptionArray()
18
+ {
19
+ return array(
20
+ array('value' => 'geoplugin', 'label'=>Mage::helper('adminhtml')->__('geoplugin.net')),
21
+ array('value' => 'hostip', 'label'=>Mage::helper('adminhtml')->__('hostip.info')),
22
+ array('value' => 'iptolatlng', 'label'=>Mage::helper('adminhtml')->__('iptolatlng.com')),
23
+ );
24
+ }
25
+
26
+ public function save()
27
+ {
28
+ $service_provider = $this->getValue();
29
+
30
+ if($service_provider != Mage::getStoreConfig( 'afipredirect/settings/country_lookup_service' ))
31
+ {
32
+ Mage::getSingleton('core/session')->addNotice ('You have changed the Country lookup service provider. Have in mind, that different providers could return different results.');
33
+ }
34
+
35
+ return parent::save();
36
+ }
37
+
38
  }
app/code/local/Creation/Afipredirect/Block/Ipredirect.php CHANGED
@@ -1,63 +1,67 @@
1
- <?php
2
- /**
3
- * @category Creation
4
- * @package Creation_Afipredirect
5
- * @author Liudas Stanevicius <liudas@creation.lt>
6
- * @copyright Elsoft, UAB (www.creation.lt) <info@creation.lt>
7
- */
8
-
9
- class Creation_Afipredirect_Block_Ipredirect extends Mage_Core_Block_Template
10
- {
11
- protected function _construct()
12
- {
13
- parent::_construct();
14
- $this->_perform_redirect();
15
- }
16
-
17
- public function _perform_redirect()
18
- {
19
- $helper = $this->helper('afipredirect');
20
-
21
- if($helper->isEnabled() && $helper->isRedirectEnabled() && !$helper->isTestMode())
22
- {
23
- if($helper->userNeedsToBeRedirected())
24
- {
25
- $this->doTheRedirect();
26
- }
27
-
28
- }
29
- }
30
-
31
- private function doTheRedirect()
32
- {
33
- $helper = $this->helper('afipredirect');
34
- $destination_url = $helper->getDestinationWebsite();
35
-
36
-
37
- if($helper->isJsRedirect())
38
- {
39
- echo '<script>window.location.href="'.$destination_url.'";</script>';
40
- } else {
41
- Mage::app()->getFrontController()->getResponse()->setRedirect($destination_url);
42
- }
43
- }
44
-
45
-
46
-
47
-
48
- public function canShowTestPanel()
49
- {
50
- $helper = $this->helper('afipredirect');
51
- if($helper->isEnabled() && $helper->isTestMode())
52
- {
53
- return true;
54
- } else {
55
- return false;
56
- }
57
- }
58
-
59
-
60
-
61
-
62
-
 
 
 
 
63
  }
1
+ <?php
2
+ /**
3
+ * @category Creation
4
+ * @package Creation_Afipredirect
5
+ * @author Liudas Stanevicius <liudas@creation.lt>
6
+ * @copyright Elsoft, UAB (www.creation.lt) <info@creation.lt>
7
+ */
8
+
9
+ class Creation_Afipredirect_Block_Ipredirect extends Mage_Core_Block_Template
10
+ {
11
+ protected function _construct()
12
+ {
13
+ parent::_construct();
14
+ $this->_perform_redirect();
15
+ }
16
+
17
+ public function _perform_redirect()
18
+ {
19
+ $helper = $this->helper('afipredirect');
20
+
21
+ if($helper->isEnabled() && $helper->isRedirectEnabled() && !$helper->isTestMode())
22
+ {
23
+ if($helper->userNeedsToBeRedirected())
24
+ {
25
+ $this->doTheRedirect();
26
+ }
27
+
28
+ }
29
+ }
30
+
31
+ private function doTheRedirect()
32
+ {
33
+ $helper = $this->helper('afipredirect');
34
+ $destination_url = $helper->getDestinationWebsite();
35
+
36
+ if($helper->isLogRedirects())
37
+ {
38
+ Mage::log($helper->getVisitorsIp().' ('.$helper->getVisitorsIpCountrySession().') redirected from '.Mage::helper('core/url')->getCurrentUrl().' to '.$helper->getDestinationWebsite(),null,'afipredirect.log');
39
+ }
40
+
41
+ if($helper->isJsRedirect())
42
+ {
43
+ echo '<script>window.location.href="'.$destination_url.'";</script>';
44
+ } else {
45
+ Mage::app()->getFrontController()->getResponse()->setRedirect($destination_url);
46
+ }
47
+ }
48
+
49
+
50
+
51
+
52
+ public function canShowTestPanel()
53
+ {
54
+ $helper = $this->helper('afipredirect');
55
+ if($helper->isEnabled() && $helper->isTestMode())
56
+ {
57
+ return true;
58
+ } else {
59
+ return false;
60
+ }
61
+ }
62
+
63
+
64
+
65
+
66
+
67
  }
app/code/local/Creation/Afipredirect/Helper/Data.php CHANGED
@@ -1,316 +1,387 @@
1
- <?php
2
-
3
- /**
4
- * @category Creation
5
- * @package Creation_Afipredirect
6
- * @author Liudas Stanevicius <liudas@creation.lt>
7
- * @copyright Elsoft, UAB (www.creation.lt) <info@creation.lt>
8
- */
9
-
10
- class Creation_Afipredirect_Helper_Data extends Mage_Core_Helper_Abstract
11
- {
12
-
13
- const XML_PATH_ENABLED = 'afipredirect/settings/enable';
14
- const XML_PATH_SETTINGS_JSREDIRECT = 'afipredirect/settings/jsredirect';
15
- const XML_PATH_SETTINGS_IS_TEST_MODE = 'afipredirect/settings/is_test_mode';
16
- const XML_PATH_SETTINGS_TEST_MODE_IP = 'afipredirect/settings/test_mode_ip';
17
- const XML_PATH_SETTINGS_LOOKUP_SERVICE = 'afipredirect/settings/country_lookup_service';
18
- const XML_PATH_SETTINGS_EXCLUDE_IPS = 'afipredirect/settings/exlude_ips';
19
- const XML_PATH_SETTINGS_EXCLUDE_SEARCH_ENGINES = 'afipredirect/settings/exlude_search_engines';
20
- const XML_PATH_REDIRECT_SOURCE_COUNTRY = 'afipredirect/redirect/source_country';
21
- const XML_PATH_REDIRECT_DESTINATION_WEBSITE = 'afipredirect/redirect/destination_website';
22
- const XML_PATH_REDIRECT_ENABLED = 'afipredirect/redirect/redirect_enabled';
23
-
24
-
25
-
26
- public function isEnabled()
27
- {
28
- return Mage::getStoreConfig( self::XML_PATH_ENABLED );
29
- }
30
-
31
- public function isRedirectEnabled()
32
- {
33
- return Mage::getStoreConfig( self::XML_PATH_REDIRECT_ENABLED );
34
- }
35
-
36
- public function isTestMode()
37
- {
38
- return Mage::getStoreConfig( self::XML_PATH_SETTINGS_IS_TEST_MODE );
39
- }
40
-
41
- public function getExcludedIps()
42
- {
43
- return Mage::getStoreConfig( self::XML_PATH_SETTINGS_EXCLUDE_IPS );
44
- }
45
- public function getTestModeIp()
46
- {
47
- return Mage::getStoreConfig( self::XML_PATH_SETTINGS_TEST_MODE_IP );
48
- }
49
-
50
- public function getCountryLookupService()
51
- {
52
- return Mage::getStoreConfig( self::XML_PATH_SETTINGS_LOOKUP_SERVICE );
53
- }
54
-
55
- public function getSourceCountry()
56
- {
57
- return Mage::getStoreConfig( self::XML_PATH_REDIRECT_SOURCE_COUNTRY );
58
- }
59
-
60
- public function getDestinationWebsite()
61
- {
62
- return Mage::getStoreConfig( self::XML_PATH_REDIRECT_DESTINATION_WEBSITE );
63
- }
64
- public function isJsRedirect()
65
- {
66
- return Mage::getStoreConfig( self::XML_PATH_SETTINGS_JSREDIRECT );
67
- }
68
- public function getExcludedSearchEngineBots()
69
- {
70
- return Mage::getStoreConfig( self::XML_PATH_SETTINGS_EXCLUDE_SEARCH_ENGINES );
71
- }
72
-
73
-
74
- public function getVisitorsIp()
75
- {
76
- return Mage::helper('core/http')->getRemoteAddr();
77
- }
78
-
79
-
80
-
81
- public function getIpToTest()
82
- {
83
- $test_ip = $this->getTestModeIp();
84
- if(filter_var($test_ip, FILTER_VALIDATE_IP))
85
- {
86
- return $test_ip;
87
- } else {
88
- return $this->getVisitorsIp();
89
- }
90
- }
91
-
92
- public function getVisitorsIpCountrySession()
93
- {
94
- $session = Mage::getSingleton("core/session", array("name"=>"frontend"));
95
- return $session->getData($this->getCountryLookupService()."_visitor_ip_country");
96
- }
97
-
98
-
99
- public function setVisitorsIpCountrySession($country_code)
100
- {
101
- $session = Mage::getSingleton("core/session", array("name"=>"frontend"));
102
- $session->setData($this->getCountryLookupService()."_visitor_ip_country", $country_code);
103
-
104
- }
105
-
106
-
107
- public function isSearchEngineBot()
108
- {
109
- $bots = array(
110
- 'Googlebot', 'Baiduspider', 'ia_archiver',
111
- 'R6_FeedFetcher', 'NetcraftSurveyAgent', 'Sogou web spider',
112
- 'bingbot', 'Yahoo! Slurp', 'facebookexternalhit', 'PrintfulBot',
113
- 'msnbot', 'Twitterbot', 'UnwindFetchor',
114
- 'urlresolver', 'Butterfly', 'TweetmemeBot' );
115
-
116
- foreach($bots as $b){
117
-
118
- if( stripos( Mage::helper('core/http')->getHttpUserAgent(), $b ) !== false ) return true;
119
-
120
- }
121
- return false;
122
- }
123
-
124
-
125
- public function excludeThisVisitorFromRedirect($ip_address = false)
126
- {
127
- if($ip_address == false)
128
- {
129
- $ip_address = $this->getVisitorsIp();
130
- }
131
-
132
- $excluded_ips = $this->getExcludedIps();
133
-
134
- if($excluded_ips != '')
135
- {
136
- $excluded_ips = explode(',',$excluded_ips);
137
-
138
- $excluded_ips_clean = array();
139
- foreach($excluded_ips as $ip)
140
- {
141
- $excluded_ips_clean[] = trim($ip);
142
- }
143
-
144
- if((count($excluded_ips_clean) > 0) && in_array($ip_address,$excluded_ips_clean))
145
- {
146
- return true;
147
- }
148
- }
149
- return false;
150
- }
151
-
152
-
153
- public function userNeedsToBeRedirected()
154
- {
155
- $visitors_ip = $this->getVisitorsIp();
156
- // is this visitor in the IP exlude list?
157
- if($this->excludeThisVisitorFromRedirect($visitors_ip))
158
- {
159
- return false;
160
- }
161
-
162
- // check if this is not a search engine bot
163
- if($this->getExcludedSearchEngineBots() && $this->isSearchEngineBot())
164
- {
165
- return false;
166
- }
167
-
168
- // has the visitor been here before?
169
- $country_code = $this->getVisitorsIpCountrySession();
170
-
171
- // if not, lookup country code and store in the session
172
- if($country_code == NULL)
173
- {
174
- $country_code = $this->getCountryCodeByIp($visitors_ip);
175
- $this->setVisitorsIpCountrySession($country_code);
176
- }
177
-
178
- // get config values
179
- $source_countries = $this->getSourceCountry();
180
- $source_countries = explode(',',$source_countries);
181
-
182
- // match?
183
- if(in_array($country_code,$source_countries))
184
- {
185
- return true;
186
- } else {
187
- return false;
188
- }
189
- }
190
-
191
- public function getRedirectResultByIp($ip_address = false)
192
- {
193
- if($ip_address == false)
194
- {
195
- $ip_address = $this->getVisitorsIp();
196
- }
197
-
198
- $country_code = $this->getCountryCodeByIp($ip_address);
199
- $source_countries = $this->getSourceCountry();
200
-
201
- $source_countries = explode(',',$source_countries);
202
-
203
- if(in_array($country_code,$source_countries))
204
- {
205
- return true;
206
- } else {
207
- return false;
208
- }
209
- }
210
-
211
- public function getIpTestResults($ip_address)
212
- {
213
- $country_code = $this->getCountryCodeByIp($ip_address);
214
- if($country_code != false)
215
- {
216
- $country_name = Mage::app()->getLocale()->getCountryTranslation($country_code);
217
- if($country_name != false)
218
- {
219
- return $country_name.' ('.$country_code.')';
220
- } else {
221
- return 'Unknown ('.$country_code.')';
222
- }
223
- } else {
224
- return 'Unknown';
225
- }
226
- }
227
-
228
-
229
- public function getCountryCodeByIp($ip_address = false)
230
- {
231
- if($ip_address == false)
232
- {
233
- $ip_address = $this->getVisitorsIp();
234
- }
235
-
236
- $lookup_service = $this->getCountryLookupService();
237
-
238
- switch ($lookup_service) {
239
- case 'geoplugin':
240
- return $this->geoplugin_visitor_country($ip_address);
241
- break;
242
- case 'hostip':
243
- return $this->hostip_visitor_country($ip_address);
244
- break;
245
- case 'iptolatlng':
246
- return $this->iptolatlng_visitor_country($ip_address);
247
- break;
248
- default:
249
- return $this->iptolatlng_visitor_country($ip_address);
250
- }
251
-
252
- }
253
-
254
-
255
-
256
- private function geoplugin_visitor_country($ip_address = false)
257
- {
258
-
259
- if($ip_address == false)
260
- {
261
- $ip_address = $this->getVisitorsIp();
262
- }
263
-
264
- $result = false;
265
-
266
- $ip_data = @json_decode(file_get_contents("http://www.geoplugin.net/json.gp?ip=".$ip));
267
- if($ip_data && $ip_data->geoplugin_countryCode != null)
268
- {
269
- $result = $ip_data->geoplugin_countryCode;
270
- }
271
- return $result;
272
- }
273
-
274
- private function hostip_visitor_country($ip_address = false)
275
- {
276
-
277
- if($ip_address == false)
278
- {
279
- $ip_address = $this->getVisitorsIp();
280
- }
281
-
282
- $result = false;
283
-
284
- $ip_data = @file_get_contents("http://api.hostip.info/country.php?ip=".$ip_address);
285
-
286
- if($ip_data && $ip_data != null)
287
- {
288
- $result = $ip_data;
289
- }
290
-
291
- return $result;
292
- }
293
-
294
- private function iptolatlng_visitor_country($ip_address = false)
295
- {
296
- if($ip_address == false)
297
- {
298
- $ip_address = $this->getVisitorsIp();
299
- }
300
-
301
- $result = false;
302
-
303
- $ip_data = @json_decode(file_get_contents("http://www.iptolatlng.com?ip=".$ip_address."&type=json"));
304
-
305
- if($ip_data && $ip_data->country != null)
306
- {
307
- $result = $ip_data->country;
308
- }
309
-
310
- return $result;
311
- }
312
-
313
-
314
-
315
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
316
  ?>
1
+ <?php
2
+
3
+ /**
4
+ * @category Creation
5
+ * @package Creation_Afipredirect
6
+ * @author Liudas Stanevicius <liudas@creation.lt>
7
+ * @copyright Elsoft, UAB (www.creation.lt) <info@creation.lt>
8
+ */
9
+
10
+ class Creation_Afipredirect_Helper_Data extends Mage_Core_Helper_Abstract
11
+ {
12
+
13
+ const XML_PATH_ENABLED = 'afipredirect/settings/enable';
14
+ const XML_PATH_SETTINGS_JSREDIRECT = 'afipredirect/settings/jsredirect';
15
+ const XML_PATH_SETTINGS_IS_TEST_MODE = 'afipredirect/settings/is_test_mode';
16
+ const XML_PATH_SETTINGS_TEST_MODE_IP = 'afipredirect/settings/test_mode_ip';
17
+ const XML_PATH_SETTINGS_LOOKUP_SERVICE = 'afipredirect/settings/country_lookup_service';
18
+ const XML_PATH_SETTINGS_EXCLUDE_IPS = 'afipredirect/settings/exlude_ips';
19
+ const XML_PATH_SETTINGS_EXCLUDE_SEARCH_ENGINES = 'afipredirect/settings/exlude_search_engines';
20
+ const XML_PATH_LOG_REDIRECTS_ENABLED = 'afipredirect/settings/log_redirects';
21
+ const XML_PATH_REDIRECT_SOURCE_COUNTRY = 'afipredirect/redirect/source_country';
22
+ const XML_PATH_REDIRECT_DESTINATION_WEBSITE = 'afipredirect/redirect/destination_website';
23
+ const XML_PATH_REDIRECT_ENABLED = 'afipredirect/redirect/redirect_enabled';
24
+ const XML_PATH_REDIRECT_ONCE_ENABLED = 'afipredirect/redirect/redirect_once';
25
+ const XML_PATH_REDIRECT_LAND_URL = 'afipredirect/redirect/redirect_land_url';
26
+
27
+
28
+
29
+
30
+ public function isEnabled()
31
+ {
32
+ return Mage::getStoreConfig( self::XML_PATH_ENABLED );
33
+ }
34
+ public function isRedirectOnce()
35
+ {
36
+ return Mage::getStoreConfig( self::XML_PATH_REDIRECT_ONCE_ENABLED );
37
+ }
38
+
39
+ public function isRedirectLandUrl()
40
+ {
41
+ return Mage::getStoreConfig( self::XML_PATH_REDIRECT_LAND_URL );
42
+ }
43
+
44
+ public function isLogRedirects()
45
+ {
46
+ return Mage::getStoreConfig( self::XML_PATH_LOG_REDIRECTS_ENABLED );
47
+ }
48
+
49
+ public function isRedirectEnabled()
50
+ {
51
+ return Mage::getStoreConfig( self::XML_PATH_REDIRECT_ENABLED );
52
+ }
53
+
54
+ public function isTestMode()
55
+ {
56
+ return Mage::getStoreConfig( self::XML_PATH_SETTINGS_IS_TEST_MODE );
57
+ }
58
+
59
+ public function getExcludedIps()
60
+ {
61
+ return Mage::getStoreConfig( self::XML_PATH_SETTINGS_EXCLUDE_IPS );
62
+ }
63
+ public function getTestModeIp()
64
+ {
65
+ return Mage::getStoreConfig( self::XML_PATH_SETTINGS_TEST_MODE_IP );
66
+ }
67
+
68
+ public function getCountryLookupService()
69
+ {
70
+ return Mage::getStoreConfig( self::XML_PATH_SETTINGS_LOOKUP_SERVICE );
71
+ }
72
+
73
+ public function getSourceCountry()
74
+ {
75
+ return Mage::getStoreConfig( self::XML_PATH_REDIRECT_SOURCE_COUNTRY );
76
+ }
77
+
78
+ public function getDestinationWebsite()
79
+ {
80
+ return Mage::getStoreConfig( self::XML_PATH_REDIRECT_DESTINATION_WEBSITE );
81
+ }
82
+ public function isJsRedirect()
83
+ {
84
+ return Mage::getStoreConfig( self::XML_PATH_SETTINGS_JSREDIRECT );
85
+ }
86
+ public function getExcludedSearchEngineBots()
87
+ {
88
+ return Mage::getStoreConfig( self::XML_PATH_SETTINGS_EXCLUDE_SEARCH_ENGINES );
89
+ }
90
+
91
+
92
+ public function getVisitorsIp()
93
+ {
94
+ return Mage::helper('core/http')->getRemoteAddr();
95
+ }
96
+
97
+
98
+
99
+ public function getIpToTest()
100
+ {
101
+ $test_ip = $this->getTestModeIp();
102
+ if(filter_var($test_ip, FILTER_VALIDATE_IP))
103
+ {
104
+ return $test_ip;
105
+ } else {
106
+ return $this->getVisitorsIp();
107
+ }
108
+ }
109
+
110
+ public function getVisitorsIpCountrySession()
111
+ {
112
+ $session = Mage::getSingleton("core/session", array("name"=>"frontend"));
113
+ return $session->getData($this->getCountryLookupService()."_visitor_ip_country");
114
+ }
115
+
116
+
117
+ public function setVisitorsIpCountrySession($country_code)
118
+ {
119
+ $session = Mage::getSingleton("core/session", array("name"=>"frontend"));
120
+ $session->setData($this->getCountryLookupService()."_visitor_ip_country", $country_code);
121
+
122
+ }
123
+
124
+
125
+ public function isSearchEngineBot()
126
+ {
127
+ $bots = array(
128
+ 'Googlebot', 'Baiduspider', 'ia_archiver',
129
+ 'R6_FeedFetcher', 'NetcraftSurveyAgent', 'Sogou web spider',
130
+ 'bingbot', 'Yahoo! Slurp', 'facebookexternalhit', 'PrintfulBot',
131
+ 'msnbot', 'Twitterbot', 'UnwindFetchor',
132
+ 'urlresolver', 'Butterfly', 'TweetmemeBot' );
133
+
134
+ foreach($bots as $b){
135
+
136
+ if( stripos( Mage::helper('core/http')->getHttpUserAgent(), $b ) !== false ) return true;
137
+
138
+ }
139
+ return false;
140
+ }
141
+
142
+
143
+ public function excludeThisVisitorFromRedirect($ip_address = false)
144
+ {
145
+ if($ip_address == false)
146
+ {
147
+ $ip_address = $this->getVisitorsIp();
148
+ }
149
+
150
+ $excluded_ips = $this->getExcludedIps();
151
+
152
+ if($excluded_ips != '')
153
+ {
154
+ $excluded_ips = explode(',',$excluded_ips);
155
+
156
+ $excluded_ips_clean = array();
157
+ foreach($excluded_ips as $ip)
158
+ {
159
+ $excluded_ips_clean[] = trim($ip);
160
+ }
161
+
162
+ if((count($excluded_ips_clean) > 0) && in_array($ip_address,$excluded_ips_clean))
163
+ {
164
+ return true;
165
+ }
166
+ }
167
+ return false;
168
+ }
169
+
170
+
171
+ public function userNeedsToBeRedirected()
172
+ {
173
+ $visitors_ip = $this->getVisitorsIp();
174
+ // is this visitor in the IP exlude list?
175
+ if($this->excludeThisVisitorFromRedirect($visitors_ip))
176
+ {
177
+ return false;
178
+ }
179
+
180
+ // check if this is not a search engine bot
181
+ if($this->getExcludedSearchEngineBots() && $this->isSearchEngineBot())
182
+ {
183
+ return false;
184
+ }
185
+
186
+ // do we redirect based on the landing url
187
+ if(!$this->landAndCurrentUrlMatch())
188
+ {
189
+ return false;
190
+ }
191
+
192
+ // has the visitor been here before?
193
+ $country_code = $this->getVisitorsIpCountrySession();
194
+
195
+ // if not, lookup country code and store in the session
196
+ if($country_code == NULL)
197
+ {
198
+ $country_code = $this->getCountryCodeByIp($visitors_ip);
199
+ $this->setVisitorsIpCountrySession($country_code);
200
+ } elseif($this->isRedirectOnce())
201
+ {
202
+ // the user has been redirected, maybe thats enough?
203
+ return false;
204
+ }
205
+
206
+
207
+ // get config values
208
+ $source_countries = $this->getSourceCountry();
209
+ $source_countries = explode(',',$source_countries);
210
+
211
+ // match?
212
+ if(in_array($country_code,$source_countries))
213
+ {
214
+ return true;
215
+ } else {
216
+ return false;
217
+ }
218
+ }
219
+
220
+ public function landAndCurrentUrlMatch()
221
+ {
222
+ $landing_url = rtrim($this->isRedirectLandUrl(),'/');
223
+ if($landing_url == '')
224
+ {
225
+ // no landign URL is defined - continue conditions check;
226
+ return true;
227
+ }
228
+ $current_url = rtrim(Mage::helper('core/url')->getCurrentUrl(),'/');
229
+
230
+ $parse = parse_url($landing_url);
231
+ if(!isset($parse['path']))
232
+ {
233
+ $parse['path'] = '';
234
+ }
235
+ $landing_url_clean = preg_replace('#^www\.(.+\.)#i', '$1', $parse['host']) . $parse['path'];
236
+
237
+ $parse = parse_url($current_url);
238
+ if(!isset($parse['path']))
239
+ {
240
+ $parse['path'] = '';
241
+ }
242
+ $current_url_clean = preg_replace('#^www\.(.+\.)#i', '$1', $parse['host']) . $parse['path'];
243
+
244
+ if($landing_url_clean == $current_url_clean)
245
+ {
246
+ return true;
247
+ } else {
248
+ return false;
249
+ }
250
+
251
+
252
+ }
253
+
254
+ public function getRedirectResultByIp($ip_address = false)
255
+ {
256
+ if($ip_address == false)
257
+ {
258
+ $ip_address = $this->getVisitorsIp();
259
+ }
260
+
261
+ $country_code = $this->getCountryCodeByIp($ip_address);
262
+ $source_countries = $this->getSourceCountry();
263
+
264
+ $source_countries = explode(',',$source_countries);
265
+
266
+ if(in_array($country_code,$source_countries))
267
+ {
268
+ return true;
269
+ } else {
270
+ return false;
271
+ }
272
+ }
273
+
274
+ public function getIpTestResults($ip_address)
275
+ {
276
+ $country_code = $this->getCountryCodeByIp($ip_address);
277
+ if($country_code != false)
278
+ {
279
+ $country_name = Mage::app()->getLocale()->getCountryTranslation($country_code);
280
+ if($country_name != false)
281
+ {
282
+ return $country_name.' ('.$country_code.')';
283
+ } else {
284
+ return 'Unknown ('.$country_code.')';
285
+ }
286
+ } else {
287
+ return 'Unknown';
288
+ }
289
+ }
290
+
291
+
292
+ public function getCountryCodeByIp($ip_address = false)
293
+ {
294
+ if($ip_address == false)
295
+ {
296
+ $ip_address = $this->getVisitorsIp();
297
+ }
298
+
299
+ $lookup_service = $this->getCountryLookupService();
300
+
301
+ $start = microtime(true);
302
+ switch ($lookup_service) {
303
+ case 'geoplugin':
304
+ $result = $this->geoplugin_visitor_country($ip_address);
305
+ break;
306
+ case 'hostip':
307
+ $result = $this->hostip_visitor_country($ip_address);
308
+ break;
309
+ case 'iptolatlng':
310
+ $result = $this->iptolatlng_visitor_country($ip_address);
311
+ break;
312
+ default:
313
+ $result = $this->iptolatlng_visitor_country($ip_address);
314
+ }
315
+ $end = microtime(true);
316
+ $duration = (string) $end - $start;
317
+ if($this->isLogRedirects())
318
+ {
319
+ Mage::log($lookup_service.' returned country code '.$result.' on IP address '.$this->getVisitorsIp().' in '.$duration.' seconds' ,null,'afipredirect.log');
320
+ }
321
+ return $result;
322
+
323
+ }
324
+
325
+
326
+
327
+ private function geoplugin_visitor_country($ip_address = false)
328
+ {
329
+
330
+ if($ip_address == false)
331
+ {
332
+ $ip_address = $this->getVisitorsIp();
333
+ }
334
+
335
+ $result = false;
336
+
337
+ $ip_data = @json_decode(file_get_contents("http://www.geoplugin.net/json.gp?ip=".$ip));
338
+ if($ip_data && $ip_data->geoplugin_countryCode != null)
339
+ {
340
+ $result = $ip_data->geoplugin_countryCode;
341
+ }
342
+ return $result;
343
+ }
344
+
345
+ private function hostip_visitor_country($ip_address = false)
346
+ {
347
+
348
+ if($ip_address == false)
349
+ {
350
+ $ip_address = $this->getVisitorsIp();
351
+ }
352
+
353
+ $result = false;
354
+
355
+ $ip_data = @file_get_contents("http://api.hostip.info/country.php?ip=".$ip_address);
356
+
357
+ if($ip_data && $ip_data != null)
358
+ {
359
+ $result = $ip_data;
360
+ }
361
+
362
+ return $result;
363
+ }
364
+
365
+ private function iptolatlng_visitor_country($ip_address = false)
366
+ {
367
+ if($ip_address == false)
368
+ {
369
+ $ip_address = $this->getVisitorsIp();
370
+ }
371
+
372
+ $result = false;
373
+
374
+ $ip_data = @json_decode(file_get_contents("http://www.iptolatlng.com?ip=".$ip_address."&type=json"));
375
+
376
+ if($ip_data && $ip_data->country != null)
377
+ {
378
+ $result = $ip_data->country;
379
+ }
380
+
381
+ return $result;
382
+ }
383
+
384
+
385
+
386
+ }
387
  ?>
app/code/local/Creation/Afipredirect/etc/adminhtml.xml CHANGED
@@ -1,22 +1,22 @@
1
- <?xml version="1.0"?>
2
- <config>
3
- <acl>
4
- <resources>
5
- <admin>
6
- <children>
7
- <system>
8
- <children>
9
- <config>
10
- <children>
11
- <afipredirect>
12
- <title>AfIpRedirect configuration</title>
13
- </afipredirect>
14
- </children>
15
- </config>
16
- </children>
17
- </system>
18
- </children>
19
- </admin>
20
- </resources>
21
- </acl>
22
  </config>
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <acl>
4
+ <resources>
5
+ <admin>
6
+ <children>
7
+ <system>
8
+ <children>
9
+ <config>
10
+ <children>
11
+ <afipredirect>
12
+ <title>AfIpRedirect configuration</title>
13
+ </afipredirect>
14
+ </children>
15
+ </config>
16
+ </children>
17
+ </system>
18
+ </children>
19
+ </admin>
20
+ </resources>
21
+ </acl>
22
  </config>
app/code/local/Creation/Afipredirect/etc/config.xml CHANGED
@@ -5,6 +5,8 @@
5
  <settings>
6
  <enable>0</enable>
7
  <is_test_mode>0</is_test_mode>
 
 
8
  <jsredirect>0</jsredirect>
9
  <exlude_search_engines>1</exlude_search_engines>
10
  <country_lookup_service>iptolatlng</country_lookup_service>
@@ -14,7 +16,7 @@
14
 
15
  <modules>
16
  <Creation_Afipredirect>
17
- <version>0.0.3</version>
18
  </Creation_Afipredirect>
19
  </modules>
20
  <global>
5
  <settings>
6
  <enable>0</enable>
7
  <is_test_mode>0</is_test_mode>
8
+ <redirect_once>0</redirect_once>
9
+ <log_redirects>0</log_redirects>
10
  <jsredirect>0</jsredirect>
11
  <exlude_search_engines>1</exlude_search_engines>
12
  <country_lookup_service>iptolatlng</country_lookup_service>
16
 
17
  <modules>
18
  <Creation_Afipredirect>
19
+ <version>0.0.4</version>
20
  </Creation_Afipredirect>
21
  </modules>
22
  <global>
app/code/local/Creation/Afipredirect/etc/system.xml CHANGED
@@ -1,160 +1,195 @@
1
- <?xml version="1.0"?>
2
- <config>
3
- <tabs>
4
- <creation translate="label" module="afipredirect">
5
- <label>Creation Extensions</label>
6
- <sort_order>300</sort_order>
7
- </creation>
8
- </tabs>
9
- <sections>
10
- <afipredirect translate="label" module="afipredirect">
11
- <label>Visitor Country IP Redirect</label>
12
- <tab>creation</tab>
13
- <frontend_type>text</frontend_type>
14
- <sort_order>600</sort_order>
15
- <show_in_default>1</show_in_default>
16
- <show_in_website>1</show_in_website>
17
- <show_in_store>1</show_in_store>
18
-
19
- <groups>
20
- <settings>
21
- <label>Settings</label>
22
- <sort_order>1</sort_order>
23
- <show_in_default>1</show_in_default>
24
- <show_in_website>1</show_in_website>
25
- <show_in_store>1</show_in_store>
26
- <comment><![CDATA[The aim of this extension is to redirect your store visitors to an anoteher URL based on their country.]]></comment>
27
- <fields>
28
- <enable>
29
- <label>Extension Enabled</label>
30
- <comment>
31
- <![CDATA[Enable or Disable this extension.]]>
32
- </comment>
33
- <frontend_type>select</frontend_type>
34
- <source_model>adminhtml/system_config_source_yesno</source_model>
35
- <sort_order>1</sort_order>
36
- <show_in_default>1</show_in_default>
37
- <show_in_website>1</show_in_website>
38
- <show_in_store>1</show_in_store>
39
- </enable>
40
- <country_lookup_service translate="label comment">
41
- <label>Country lookup service</label>
42
- <comment>
43
- <![CDATA[To find out which country the visitor is from, we use remote lookup services.]]>
44
- </comment>
45
- <frontend_type>select</frontend_type>
46
- <source_model>afipredirect_adminhtml/system_config_source_countrylookupproviders</source_model>
47
- <backend_model>afipredirect_adminhtml/system_config_source_countrylookupproviders</backend_model>
48
- <sort_order>30</sort_order>
49
- <show_in_default>1</show_in_default>
50
- <show_in_website>1</show_in_website>
51
- <show_in_store>1</show_in_store>
52
- </country_lookup_service>
53
- <jsredirect>
54
- <label>Use Javascript redirect?</label>
55
- <comment>
56
- <![CDATA[Matched users will be redirected with Javascript. If above option is set to NO - then there will he a PHP redirect.]]>
57
- </comment>
58
- <frontend_type>select</frontend_type>
59
- <source_model>adminhtml/system_config_source_yesno</source_model>
60
- <sort_order>60</sort_order>
61
- <show_in_default>1</show_in_default>
62
- <show_in_website>1</show_in_website>
63
- <show_in_store>1</show_in_store>
64
- </jsredirect>
65
- <exlude_ips translate="label comment">
66
- <label>Exclude IP addresses</label>
67
- <comment>
68
- <![CDATA[Comma separated IP addresses. Visitors, with these IP addresses will be exluded from redirect. Most likely you would want to put your IP here.]]>
69
- </comment>
70
- <frontend_type>text</frontend_type>
71
- <sort_order>61</sort_order>
72
- <show_in_default>1</show_in_default>
73
- <show_in_website>1</show_in_website>
74
- <show_in_store>1</show_in_store>
75
- </exlude_ips>
76
- <exlude_search_engines translate="label comment">
77
- <label>Exclude search engines</label>
78
- <comment>
79
- <![CDATA[Exclude search engine bots like Googlebot, Baiduspider, ia_archiver, R6_FeedFetcher, NetcraftSurveyAgent, Sogou web spider, bingbot, Yahoo! Slurp, facebookexternalhit, PrintfulBot, msnbot, Twitterbot, UnwindFetchor, urlresolver, Butterfly, TweetmemeBot from redirect.]]>
80
- </comment>
81
- <frontend_type>select</frontend_type>
82
- <source_model>adminhtml/system_config_source_yesno</source_model>
83
- <sort_order>62</sort_order>
84
- <show_in_default>1</show_in_default>
85
- <show_in_website>1</show_in_website>
86
- <show_in_store>1</show_in_store>
87
- </exlude_search_engines>
88
- <is_test_mode translate="label comment">
89
- <label>Test mode</label>
90
- <comment>
91
- <![CDATA[If extension is enabled and test mode activated, in front end you will be able to see where the visitor will be redirected to. This is not recommended on a production environment.]]>
92
- </comment>
93
- <frontend_type>select</frontend_type>
94
- <source_model>adminhtml/system_config_source_yesno</source_model>
95
- <sort_order>20</sort_order>
96
- <show_in_default>1</show_in_default>
97
- <show_in_website>1</show_in_website>
98
- <show_in_store>1</show_in_store>
99
- </is_test_mode>
100
- <test_mode_ip translate="label comment">
101
- <label>Test IP address</label>
102
- <comment>Enter a test visitor IP address.</comment>
103
- <frontend_type>text</frontend_type>
104
- <sort_order>21</sort_order>
105
- <show_in_default>1</show_in_default>
106
- <show_in_website>1</show_in_website>
107
- <show_in_store>1</show_in_store>
108
- <depends>
109
- <is_test_mode>1</is_test_mode>
110
- </depends>
111
- </test_mode_ip>
112
- </fields>
113
- </settings>
114
- <redirect>
115
- <label>Redirect</label>
116
- <sort_order>2</sort_order>
117
- <show_in_default>1</show_in_default>
118
- <show_in_website>1</show_in_website>
119
- <show_in_store>1</show_in_store>
120
- <fields>
121
- <redirect_enabled>
122
- <label>Redirect enabled</label>
123
- <frontend_type>select</frontend_type>
124
- <source_model>adminhtml/system_config_source_yesno</source_model>
125
- <sort_order>10</sort_order>
126
- <show_in_default>1</show_in_default>
127
- <show_in_website>1</show_in_website>
128
- <show_in_store>1</show_in_store>
129
- </redirect_enabled>
130
-
131
- <source_country>
132
- <label>Visitor country</label>
133
- <comment>
134
- <![CDATA[If a user is from any of these countries...]]>
135
- </comment>
136
- <frontend_type>multiselect</frontend_type>
137
- <source_model>adminhtml/system_config_source_country</source_model>
138
- <sort_order>40</sort_order>
139
- <show_in_default>1</show_in_default>
140
- <show_in_website>1</show_in_website>
141
- <show_in_store>1</show_in_store>
142
- </source_country>
143
- <destination_website>
144
- <label>Redirect to URL</label>
145
- <comment>
146
- <![CDATA[..redirect him to this URL (example http://www.google.com).]]>
147
- </comment>
148
- <frontend_type>text</frontend_type>
149
- <sort_order>50</sort_order>
150
- <show_in_default>1</show_in_default>
151
- <show_in_website>1</show_in_website>
152
- <show_in_store>1</show_in_store>
153
- </destination_website>
154
-
155
- </fields>
156
- </redirect>
157
- </groups>
158
- </afipredirect>
159
- </sections>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
160
  </config>
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <tabs>
4
+ <creation translate="label" module="afipredirect">
5
+ <label>Creation Extensions</label>
6
+ <sort_order>300</sort_order>
7
+ </creation>
8
+ </tabs>
9
+ <sections>
10
+ <afipredirect translate="label" module="afipredirect">
11
+ <label>Visitor Country IP Redirect</label>
12
+ <tab>creation</tab>
13
+ <frontend_type>text</frontend_type>
14
+ <sort_order>600</sort_order>
15
+ <show_in_default>1</show_in_default>
16
+ <show_in_website>1</show_in_website>
17
+ <show_in_store>1</show_in_store>
18
+
19
+ <groups>
20
+ <settings>
21
+ <label>Settings</label>
22
+ <sort_order>1</sort_order>
23
+ <show_in_default>1</show_in_default>
24
+ <show_in_website>1</show_in_website>
25
+ <show_in_store>1</show_in_store>
26
+ <comment><![CDATA[The aim of this extension is to redirect your store visitors to an anoteher URL based on their country.]]></comment>
27
+ <fields>
28
+ <enable>
29
+ <label>Extension Enabled</label>
30
+ <comment>
31
+ <![CDATA[Enable or Disable this extension.]]>
32
+ </comment>
33
+ <frontend_type>select</frontend_type>
34
+ <source_model>adminhtml/system_config_source_yesno</source_model>
35
+ <sort_order>1</sort_order>
36
+ <show_in_default>1</show_in_default>
37
+ <show_in_website>1</show_in_website>
38
+ <show_in_store>1</show_in_store>
39
+ </enable>
40
+ <log_redirects>
41
+ <label>Log redirects?</label>
42
+ <frontend_type>select</frontend_type>
43
+ <source_model>adminhtml/system_config_source_yesno</source_model>
44
+ <sort_order>1</sort_order>
45
+ <show_in_default>1</show_in_default>
46
+ <show_in_website>1</show_in_website>
47
+ <show_in_store>1</show_in_store>
48
+ <comment>
49
+ <![CDATA[See afipredirect.log in you logs directory to see which users have been redirected.]]>
50
+ </comment>
51
+ </log_redirects>
52
+ <country_lookup_service translate="label comment">
53
+ <label>Country lookup service</label>
54
+ <comment>
55
+ <![CDATA[To find out which country the visitor is from, we use remote lookup services.]]>
56
+ </comment>
57
+ <frontend_type>select</frontend_type>
58
+ <source_model>afipredirect_adminhtml/system_config_source_countrylookupproviders</source_model>
59
+ <backend_model>afipredirect_adminhtml/system_config_source_countrylookupproviders</backend_model>
60
+ <sort_order>30</sort_order>
61
+ <show_in_default>1</show_in_default>
62
+ <show_in_website>1</show_in_website>
63
+ <show_in_store>1</show_in_store>
64
+ </country_lookup_service>
65
+ <jsredirect>
66
+ <label>Use Javascript redirect?</label>
67
+ <comment>
68
+ <![CDATA[Matched users will be redirected with Javascript. If above option is set to NO - then there will he a PHP redirect.]]>
69
+ </comment>
70
+ <frontend_type>select</frontend_type>
71
+ <source_model>adminhtml/system_config_source_yesno</source_model>
72
+ <sort_order>60</sort_order>
73
+ <show_in_default>1</show_in_default>
74
+ <show_in_website>1</show_in_website>
75
+ <show_in_store>1</show_in_store>
76
+ </jsredirect>
77
+ <exlude_ips translate="label comment">
78
+ <label>Exclude IP addresses</label>
79
+ <comment>
80
+ <![CDATA[Comma separated IP addresses. Visitors, with these IP addresses will be exluded from redirect. Most likely you would want to put your IP here.]]>
81
+ </comment>
82
+ <frontend_type>text</frontend_type>
83
+ <sort_order>61</sort_order>
84
+ <show_in_default>1</show_in_default>
85
+ <show_in_website>1</show_in_website>
86
+ <show_in_store>1</show_in_store>
87
+ </exlude_ips>
88
+ <exlude_search_engines translate="label comment">
89
+ <label>Exclude search engines</label>
90
+ <comment>
91
+ <![CDATA[Exclude search engine bots like Googlebot, Baiduspider, ia_archiver, R6_FeedFetcher, NetcraftSurveyAgent, Sogou web spider, bingbot, Yahoo! Slurp, facebookexternalhit, PrintfulBot, msnbot, Twitterbot, UnwindFetchor, urlresolver, Butterfly, TweetmemeBot from redirect.]]>
92
+ </comment>
93
+ <frontend_type>select</frontend_type>
94
+ <source_model>adminhtml/system_config_source_yesno</source_model>
95
+ <sort_order>62</sort_order>
96
+ <show_in_default>1</show_in_default>
97
+ <show_in_website>1</show_in_website>
98
+ <show_in_store>1</show_in_store>
99
+ </exlude_search_engines>
100
+ <is_test_mode translate="label comment">
101
+ <label>Test mode</label>
102
+ <comment>
103
+ <![CDATA[If extension is enabled and test mode activated, in front end you will be able to see where the visitor will be redirected to. This is not recommended on a production environment.]]>
104
+ </comment>
105
+ <frontend_type>select</frontend_type>
106
+ <source_model>adminhtml/system_config_source_yesno</source_model>
107
+ <sort_order>20</sort_order>
108
+ <show_in_default>1</show_in_default>
109
+ <show_in_website>1</show_in_website>
110
+ <show_in_store>1</show_in_store>
111
+ </is_test_mode>
112
+ <test_mode_ip translate="label comment">
113
+ <label>Test IP address</label>
114
+ <comment>Enter a test visitor IP address.</comment>
115
+ <frontend_type>text</frontend_type>
116
+ <sort_order>21</sort_order>
117
+ <show_in_default>1</show_in_default>
118
+ <show_in_website>1</show_in_website>
119
+ <show_in_store>1</show_in_store>
120
+ <depends>
121
+ <is_test_mode>1</is_test_mode>
122
+ </depends>
123
+ </test_mode_ip>
124
+ </fields>
125
+ </settings>
126
+ <redirect>
127
+ <label>Redirect</label>
128
+ <sort_order>2</sort_order>
129
+ <show_in_default>1</show_in_default>
130
+ <show_in_website>1</show_in_website>
131
+ <show_in_store>1</show_in_store>
132
+ <fields>
133
+ <redirect_enabled>
134
+ <label>Redirect enabled</label>
135
+ <frontend_type>select</frontend_type>
136
+ <source_model>adminhtml/system_config_source_yesno</source_model>
137
+ <sort_order>10</sort_order>
138
+ <show_in_default>1</show_in_default>
139
+ <show_in_website>1</show_in_website>
140
+ <show_in_store>1</show_in_store>
141
+ </redirect_enabled>
142
+ <redirect_once>
143
+ <label>Redirect only once?</label>
144
+ <frontend_type>select</frontend_type>
145
+ <source_model>adminhtml/system_config_source_yesno</source_model>
146
+ <sort_order>11</sort_order>
147
+ <show_in_default>1</show_in_default>
148
+ <show_in_website>1</show_in_website>
149
+ <show_in_store>1</show_in_store>
150
+ <comment>
151
+ <![CDATA[If set to YES, visitor who comes for the first time are redirected. Next time they come, no redirect is performed. If set to NO, users are redirect all the time. You might want to set this value to YES, if you want the visitors to be redirected to specific store language (f.e. www.domain.com/nl), and allow them to chose other language and return to home page etc.]]>
152
+ </comment>
153
+ </redirect_once>
154
+
155
+ <source_country>
156
+ <label>Visitor country</label>
157
+ <comment>
158
+ <![CDATA[If a user is from any of these countries...]]>
159
+ </comment>
160
+ <frontend_type>multiselect</frontend_type>
161
+ <source_model>adminhtml/system_config_source_country</source_model>
162
+ <sort_order>40</sort_order>
163
+ <show_in_default>1</show_in_default>
164
+ <show_in_website>1</show_in_website>
165
+ <show_in_store>1</show_in_store>
166
+ </source_country>
167
+ <redirect_land_url>
168
+ <label>Land URL</label>
169
+ <comment>
170
+ <![CDATA[..and he landed on this URL (example http://www.domain.com/category-page, if left blank, redirect will be performed on all website urls)...]]>
171
+ </comment>
172
+ <frontend_type>text</frontend_type>
173
+ <sort_order>45</sort_order>
174
+ <show_in_default>1</show_in_default>
175
+ <show_in_website>1</show_in_website>
176
+ <show_in_store>1</show_in_store>
177
+ </redirect_land_url>
178
+ <destination_website>
179
+ <label>Redirect to URL</label>
180
+ <comment>
181
+ <![CDATA[..redirect him to this URL (example http://www.google.com).]]>
182
+ </comment>
183
+ <frontend_type>text</frontend_type>
184
+ <sort_order>50</sort_order>
185
+ <show_in_default>1</show_in_default>
186
+ <show_in_website>1</show_in_website>
187
+ <show_in_store>1</show_in_store>
188
+ </destination_website>
189
+
190
+ </fields>
191
+ </redirect>
192
+ </groups>
193
+ </afipredirect>
194
+ </sections>
195
  </config>
package.xml CHANGED
@@ -1,7 +1,7 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>visitor_country_ip_redirect</name>
4
- <version>0.0.3</version>
5
  <stability>stable</stability>
6
  <license uri="http://opensource.org/licenses/osl-3.0.php">Open Software License (OSL 3.0)</license>
7
  <channel>community</channel>
@@ -22,11 +22,12 @@ Extension has some configuration options:&#xD;
22
  * etc.&#xD;
23
  &#xD;
24
  Extension is tested on versions 1.7+, but it could work with older versions as well.</description>
25
- <notes>Initial release.</notes>
 
26
  <authors><author><name>Liudas Stanevicius</name><user>liudass</user><email>liudas@creation.lt</email></author></authors>
27
- <date>2014-02-11</date>
28
- <time>17:21:53</time>
29
- <contents><target name="magelocal"><dir name="Creation"><dir name="Afipredirect"><dir name="Adminhtml"><dir name="Model"><dir name="System"><dir name="Config"><dir name="Source"><file name="Countrylookupproviders.php" hash="fce050c58e2ead60c11ffed8523b5b6d"/></dir></dir></dir></dir></dir><dir name="Block"><file name="Ipredirect.php" hash="f5fe243b7d1f79e4f19d4d2062d6ff4c"/></dir><dir name="Helper"><file name="Data.php" hash="0e5d96af04b074a76492897e8136b084"/></dir><dir name="etc"><file name="adminhtml.xml" hash="15bcd845fe1ed7a4c692632aea3392ca"/><file name="config.xml" hash="04f5cf9ab99f31e5b36c4af0a5727692"/><file name="system.xml" hash="ba0102b13ed115dfea9a2a0084505777"/></dir></dir></dir></target><target name="magedesign"><dir name="frontend"><dir name="default"><dir name="default"><dir name="template"><dir name="afipredirect"><file name="ipredirect.phtml" hash="09604fcc521fd5346800829ea4dca3fb"/></dir></dir><dir name="layout"><file name="afipredirect.xml" hash="4f48f9deb8bffcdefaee4b1b07e6a842"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Creation_Afipredirect.xml" hash="3c92fb37c92042cf2c759f0180596b3d"/></dir></target></contents>
30
  <compatible/>
31
  <dependencies><required><php><min>5.2.0</min><max>5.9.0</max></php></required></dependencies>
32
  </package>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>visitor_country_ip_redirect</name>
4
+ <version>0.0.4</version>
5
  <stability>stable</stability>
6
  <license uri="http://opensource.org/licenses/osl-3.0.php">Open Software License (OSL 3.0)</license>
7
  <channel>community</channel>
22
  * etc.&#xD;
23
  &#xD;
24
  Extension is tested on versions 1.7+, but it could work with older versions as well.</description>
25
+ <notes>0.0.4 - new features: logging, landing URL, redirect once etc.&#xD;
26
+ 0.0.3 - Initial release.</notes>
27
  <authors><author><name>Liudas Stanevicius</name><user>liudass</user><email>liudas@creation.lt</email></author></authors>
28
+ <date>2014-04-12</date>
29
+ <time>16:35:45</time>
30
+ <contents><target name="magelocal"><dir name="Creation"><dir name="Afipredirect"><dir name="Adminhtml"><dir name="Model"><dir name="System"><dir name="Config"><dir name="Source"><file name="Countrylookupproviders.php" hash="d05bc8e6a90c652875784202d2f7f00c"/></dir></dir></dir></dir></dir><dir name="Block"><file name="Ipredirect.php" hash="32c1325cea2b1393fda3ce5f9cab7f9d"/></dir><dir name="Helper"><file name="Data.php" hash="2566f12c3e0e9949b181fc59af0d466c"/></dir><dir name="etc"><file name="adminhtml.xml" hash="2d31a75f87743daa996f76d81f0924ac"/><file name="config.xml" hash="1c84913a7e759cfe57e322b9c138520a"/><file name="system.xml" hash="0bc19633521495503eddd2315f507ecf"/></dir></dir></dir></target><target name="magedesign"><dir name="frontend"><dir name="default"><dir name="default"><dir name="template"><dir name="afipredirect"><file name="ipredirect.phtml" hash="09604fcc521fd5346800829ea4dca3fb"/></dir></dir><dir name="layout"><file name="afipredirect.xml" hash="4f48f9deb8bffcdefaee4b1b07e6a842"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Creation_Afipredirect.xml" hash="3c92fb37c92042cf2c759f0180596b3d"/></dir></target></contents>
31
  <compatible/>
32
  <dependencies><required><php><min>5.2.0</min><max>5.9.0</max></php></required></dependencies>
33
  </package>