visitor_country_ip_redirect - Version 0.0.5

Version Notes

0.0.5 - addded 4 more redirect rules
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.5
Comparing to
See all releases


Code changes from version 0.0.4 to 0.0.5

app/code/local/Creation/Afipredirect/Block/Ipredirect.php CHANGED
@@ -18,24 +18,69 @@ class Creation_Afipredirect_Block_Ipredirect extends Mage_Core_Block_Template
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())
18
  {
19
  $helper = $this->helper('afipredirect');
20
 
21
+ if($helper->isEnabled() && !$helper->isTestMode())
22
+ {
23
+
24
+ $i=1;
25
+ while($i<=5) {
26
+ if($helper->isRedirectEnabled($i))
27
+ {
28
+ if($helper->userNeedsToBeRedirected($i))
29
+ {
30
+ $this->doTheRedirect($i);
31
+ }
32
+ }
33
+ $i++;
34
+ }
35
+
36
+ /*if($helper->isRedirectEnabled($number = 1))
37
+ {
38
+ $this->doTheRedirect();
39
+ }
40
+ if($helper->isRedirectEnabled($number = 2))
41
+ {
42
+ $this->doTheRedirect();
43
+ }
44
+ if($helper->isRedirectEnabled($number = 3))
45
+ {
46
+ $this->doTheRedirect();
47
+ }
48
+ if($helper->isRedirectEnabled($number = 4))
49
+ {
50
+ $this->doTheRedirect();
51
+ }
52
+ if($helper->isRedirectEnabled($number = 5))
53
+ {
54
+ $this->doTheRedirect();
55
+ }*/
56
+
57
+
58
+
59
+ /*if($helper->userNeedsToBeRedirected())
60
+ {
61
+ $this->doTheRedirect();
62
+ }*/
63
+
64
+ }
65
+
66
+ /*if($helper->isEnabled() && $helper->isRedirectEnabled() && !$helper->isTestMode())
67
  {
68
  if($helper->userNeedsToBeRedirected())
69
  {
70
  $this->doTheRedirect();
71
  }
72
 
73
+ }*/
74
  }
75
 
76
+ private function doTheRedirect($number)
77
  {
78
  $helper = $this->helper('afipredirect');
79
+ $destination_url = $helper->getDestinationWebsite($number);
80
 
81
  if($helper->isLogRedirects())
82
  {
83
+ Mage::log('Redirect #'.$number.' '.$helper->getVisitorsIp().' ('.$helper->getVisitorsIpCountrySession().') redirected from '.Mage::helper('core/url')->getCurrentUrl().' to '.$helper->getDestinationWebsite(),null,'afipredirect.log');
84
  }
85
 
86
  if($helper->isJsRedirect())
app/code/local/Creation/Afipredirect/Helper/Data.php CHANGED
@@ -18,27 +18,43 @@ class Creation_Afipredirect_Helper_Data extends Mage_Core_Helper_Abstract
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()
@@ -46,9 +62,10 @@ class Creation_Afipredirect_Helper_Data extends Mage_Core_Helper_Abstract
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()
@@ -70,14 +87,18 @@ class Creation_Afipredirect_Helper_Data extends Mage_Core_Helper_Abstract
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
  {
@@ -168,7 +189,7 @@ class Creation_Afipredirect_Helper_Data extends Mage_Core_Helper_Abstract
168
  }
169
 
170
 
171
- public function userNeedsToBeRedirected()
172
  {
173
  $visitors_ip = $this->getVisitorsIp();
174
  // is this visitor in the IP exlude list?
@@ -184,7 +205,7 @@ class Creation_Afipredirect_Helper_Data extends Mage_Core_Helper_Abstract
184
  }
185
 
186
  // do we redirect based on the landing url
187
- if(!$this->landAndCurrentUrlMatch())
188
  {
189
  return false;
190
  }
@@ -197,7 +218,7 @@ class Creation_Afipredirect_Helper_Data extends Mage_Core_Helper_Abstract
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;
@@ -205,7 +226,7 @@ class Creation_Afipredirect_Helper_Data extends Mage_Core_Helper_Abstract
205
 
206
 
207
  // get config values
208
- $source_countries = $this->getSourceCountry();
209
  $source_countries = explode(',',$source_countries);
210
 
211
  // match?
@@ -217,9 +238,9 @@ class Creation_Afipredirect_Helper_Data extends Mage_Core_Helper_Abstract
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;
@@ -251,7 +272,7 @@ class Creation_Afipredirect_Helper_Data extends Mage_Core_Helper_Abstract
251
 
252
  }
253
 
254
- public function getRedirectResultByIp($ip_address = false)
255
  {
256
  if($ip_address == false)
257
  {
@@ -259,13 +280,20 @@ class Creation_Afipredirect_Helper_Data extends Mage_Core_Helper_Abstract
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
  }
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
+
22
+ const XML_PATH_REDIRECT_SOURCE_COUNTRY = 'afipredirect/redirect{{number}}/source_country';
23
+ const XML_PATH_REDIRECT_DESTINATION_WEBSITE = 'afipredirect/redirect{{number}}/destination_website';
24
+ const XML_PATH_REDIRECT_ENABLED = 'afipredirect/redirect{{number}}/redirect_enabled';
25
+ const XML_PATH_REDIRECT_ONCE_ENABLED = 'afipredirect/redirect{{number}}/redirect_once';
26
+ const XML_PATH_REDIRECT_LAND_URL = 'afipredirect/redirect{{number}}/redirect_land_url';
27
+
28
+ const NUMBER_CONST = '{{number}}';
29
 
30
 
31
 
32
+ public function getRedirectSettings($path, $number)
33
+ {
34
+ if(($number == false) || ($number == 1))
35
+ {
36
+ // since 1st redirect does not have numbering in the path..
37
+ $number = '';
38
+ }
39
+
40
+ $result = str_replace(self::NUMBER_CONST,$number,$path);
41
+ return $result;
42
+ }
43
 
44
  public function isEnabled()
45
  {
46
+ return Mage::getStoreConfig( self::XML_PATH_ENABLED );
47
  }
48
+ public function isRedirectOnce($redirect_no = false)
49
  {
50
+ $path = $this->getRedirectSettings(self::XML_PATH_REDIRECT_ONCE_ENABLED,$redirect_no);
51
+ return Mage::getStoreConfig( $path );
52
  }
53
 
54
+ public function isRedirectLandUrl($redirect_no = false)
55
  {
56
+ $path = $this->getRedirectSettings(self::XML_PATH_REDIRECT_LAND_URL,$redirect_no);
57
+ return Mage::getStoreConfig( $path );
58
  }
59
 
60
  public function isLogRedirects()
62
  return Mage::getStoreConfig( self::XML_PATH_LOG_REDIRECTS_ENABLED );
63
  }
64
 
65
+ public function isRedirectEnabled($redirect_no = false)
66
  {
67
+ $path = $this->getRedirectSettings(self::XML_PATH_REDIRECT_ENABLED,$redirect_no);
68
+ return Mage::getStoreConfig( $path );
69
  }
70
 
71
  public function isTestMode()
87
  return Mage::getStoreConfig( self::XML_PATH_SETTINGS_LOOKUP_SERVICE );
88
  }
89
 
90
+ public function getSourceCountry($redirect_no = false)
91
  {
92
+ $path = $this->getRedirectSettings(self::XML_PATH_REDIRECT_SOURCE_COUNTRY,$redirect_no);
93
+ return Mage::getStoreConfig( $path );
94
+ //return Mage::getStoreConfig( self::XML_PATH_REDIRECT_SOURCE_COUNTRY );
95
  }
96
 
97
+ public function getDestinationWebsite($redirect_no = false)
98
  {
99
+ $path = $this->getRedirectSettings(self::XML_PATH_REDIRECT_DESTINATION_WEBSITE,$redirect_no);
100
+ return Mage::getStoreConfig( $path );
101
+ //return Mage::getStoreConfig( self::XML_PATH_REDIRECT_DESTINATION_WEBSITE );
102
  }
103
  public function isJsRedirect()
104
  {
189
  }
190
 
191
 
192
+ public function userNeedsToBeRedirected($number)
193
  {
194
  $visitors_ip = $this->getVisitorsIp();
195
  // is this visitor in the IP exlude list?
205
  }
206
 
207
  // do we redirect based on the landing url
208
+ if(!$this->landAndCurrentUrlMatch($number))
209
  {
210
  return false;
211
  }
218
  {
219
  $country_code = $this->getCountryCodeByIp($visitors_ip);
220
  $this->setVisitorsIpCountrySession($country_code);
221
+ } elseif($this->isRedirectOnce($number))
222
  {
223
  // the user has been redirected, maybe thats enough?
224
  return false;
226
 
227
 
228
  // get config values
229
+ $source_countries = $this->getSourceCountry($number);
230
  $source_countries = explode(',',$source_countries);
231
 
232
  // match?
238
  }
239
  }
240
 
241
+ public function landAndCurrentUrlMatch($number = false)
242
  {
243
+ $landing_url = rtrim($this->isRedirectLandUrl($number),'/');
244
  if($landing_url == '')
245
  {
246
  // no landign URL is defined - continue conditions check;
272
 
273
  }
274
 
275
+ public function getRedirectResultByIp($ip_address = false, $number = false)
276
  {
277
  if($ip_address == false)
278
  {
280
  }
281
 
282
  $country_code = $this->getCountryCodeByIp($ip_address);
283
+ $source_countries = $this->getSourceCountry($number);
284
 
285
  $source_countries = explode(',',$source_countries);
286
 
287
+
288
  if(in_array($country_code,$source_countries))
289
  {
290
+ // do we redirect based on the landing url
291
+ if(!$this->landAndCurrentUrlMatch($number))
292
+ {
293
+ return false;
294
+ } else {
295
+ return true;
296
+ }
297
  } else {
298
  return false;
299
  }
app/code/local/Creation/Afipredirect/etc/config.xml CHANGED
@@ -16,7 +16,7 @@
16
 
17
  <modules>
18
  <Creation_Afipredirect>
19
- <version>0.0.4</version>
20
  </Creation_Afipredirect>
21
  </modules>
22
  <global>
16
 
17
  <modules>
18
  <Creation_Afipredirect>
19
+ <version>0.0.5</version>
20
  </Creation_Afipredirect>
21
  </modules>
22
  <global>
app/code/local/Creation/Afipredirect/etc/system.xml CHANGED
@@ -23,7 +23,7 @@
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>
@@ -124,7 +124,7 @@
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>
@@ -188,7 +188,223 @@
188
  </destination_website>
189
 
190
  </fields>
191
- </redirect>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
192
  </groups>
193
  </afipredirect>
194
  </sections>
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[<p>The aim of this extension is to redirect your store visitors to an anoteher URL based on their country.</p><div style="padding: 5px 10px; color: red; background-color: #FFF9E9; border: 1px dashed red;"><strong>If rules are set up not right - you might end up in infinite redirect loop.</strong></div>]]></comment>
27
  <fields>
28
  <enable>
29
  <label>Extension Enabled</label>
124
  </fields>
125
  </settings>
126
  <redirect>
127
+ <label>Redirect #1</label>
128
  <sort_order>2</sort_order>
129
  <show_in_default>1</show_in_default>
130
  <show_in_website>1</show_in_website>
188
  </destination_website>
189
 
190
  </fields>
191
+ </redirect>
192
+ <redirect2>
193
+ <label>Redirect #2</label>
194
+ <sort_order>20</sort_order>
195
+ <show_in_default>1</show_in_default>
196
+ <show_in_website>1</show_in_website>
197
+ <show_in_store>1</show_in_store>
198
+ <fields>
199
+ <redirect_enabled>
200
+ <label>Redirect enabled</label>
201
+ <frontend_type>select</frontend_type>
202
+ <source_model>adminhtml/system_config_source_yesno</source_model>
203
+ <sort_order>10</sort_order>
204
+ <show_in_default>1</show_in_default>
205
+ <show_in_website>1</show_in_website>
206
+ <show_in_store>1</show_in_store>
207
+ </redirect_enabled>
208
+ <redirect_once>
209
+ <label>Redirect only once?</label>
210
+ <frontend_type>select</frontend_type>
211
+ <source_model>adminhtml/system_config_source_yesno</source_model>
212
+ <sort_order>11</sort_order>
213
+ <show_in_default>1</show_in_default>
214
+ <show_in_website>1</show_in_website>
215
+ <show_in_store>1</show_in_store>
216
+ </redirect_once>
217
+
218
+ <source_country>
219
+ <label>Visitor country</label>
220
+ <frontend_type>multiselect</frontend_type>
221
+ <source_model>adminhtml/system_config_source_country</source_model>
222
+ <sort_order>40</sort_order>
223
+ <show_in_default>1</show_in_default>
224
+ <show_in_website>1</show_in_website>
225
+ <show_in_store>1</show_in_store>
226
+ </source_country>
227
+ <redirect_land_url>
228
+ <label>Land URL</label>
229
+ <frontend_type>text</frontend_type>
230
+ <sort_order>45</sort_order>
231
+ <show_in_default>1</show_in_default>
232
+ <show_in_website>1</show_in_website>
233
+ <show_in_store>1</show_in_store>
234
+ </redirect_land_url>
235
+ <destination_website>
236
+ <label>Redirect to URL</label>
237
+ <frontend_type>text</frontend_type>
238
+ <sort_order>50</sort_order>
239
+ <show_in_default>1</show_in_default>
240
+ <show_in_website>1</show_in_website>
241
+ <show_in_store>1</show_in_store>
242
+ </destination_website>
243
+
244
+ </fields>
245
+ </redirect2>
246
+ <redirect3>
247
+ <label>Redirect #3</label>
248
+ <sort_order>30</sort_order>
249
+ <show_in_default>1</show_in_default>
250
+ <show_in_website>1</show_in_website>
251
+ <show_in_store>1</show_in_store>
252
+ <fields>
253
+ <redirect_enabled>
254
+ <label>Redirect enabled</label>
255
+ <frontend_type>select</frontend_type>
256
+ <source_model>adminhtml/system_config_source_yesno</source_model>
257
+ <sort_order>10</sort_order>
258
+ <show_in_default>1</show_in_default>
259
+ <show_in_website>1</show_in_website>
260
+ <show_in_store>1</show_in_store>
261
+ </redirect_enabled>
262
+ <redirect_once>
263
+ <label>Redirect only once?</label>
264
+ <frontend_type>select</frontend_type>
265
+ <source_model>adminhtml/system_config_source_yesno</source_model>
266
+ <sort_order>11</sort_order>
267
+ <show_in_default>1</show_in_default>
268
+ <show_in_website>1</show_in_website>
269
+ <show_in_store>1</show_in_store>
270
+ </redirect_once>
271
+
272
+ <source_country>
273
+ <label>Visitor country</label>
274
+ <frontend_type>multiselect</frontend_type>
275
+ <source_model>adminhtml/system_config_source_country</source_model>
276
+ <sort_order>40</sort_order>
277
+ <show_in_default>1</show_in_default>
278
+ <show_in_website>1</show_in_website>
279
+ <show_in_store>1</show_in_store>
280
+ </source_country>
281
+ <redirect_land_url>
282
+ <label>Land URL</label>
283
+ <frontend_type>text</frontend_type>
284
+ <sort_order>45</sort_order>
285
+ <show_in_default>1</show_in_default>
286
+ <show_in_website>1</show_in_website>
287
+ <show_in_store>1</show_in_store>
288
+ </redirect_land_url>
289
+ <destination_website>
290
+ <label>Redirect to URL</label>
291
+ <frontend_type>text</frontend_type>
292
+ <sort_order>50</sort_order>
293
+ <show_in_default>1</show_in_default>
294
+ <show_in_website>1</show_in_website>
295
+ <show_in_store>1</show_in_store>
296
+ </destination_website>
297
+
298
+ </fields>
299
+ </redirect3>
300
+ <redirect4>
301
+ <label>Redirect #4</label>
302
+ <sort_order>40</sort_order>
303
+ <show_in_default>1</show_in_default>
304
+ <show_in_website>1</show_in_website>
305
+ <show_in_store>1</show_in_store>
306
+ <fields>
307
+ <redirect_enabled>
308
+ <label>Redirect enabled</label>
309
+ <frontend_type>select</frontend_type>
310
+ <source_model>adminhtml/system_config_source_yesno</source_model>
311
+ <sort_order>10</sort_order>
312
+ <show_in_default>1</show_in_default>
313
+ <show_in_website>1</show_in_website>
314
+ <show_in_store>1</show_in_store>
315
+ </redirect_enabled>
316
+ <redirect_once>
317
+ <label>Redirect only once?</label>
318
+ <frontend_type>select</frontend_type>
319
+ <source_model>adminhtml/system_config_source_yesno</source_model>
320
+ <sort_order>11</sort_order>
321
+ <show_in_default>1</show_in_default>
322
+ <show_in_website>1</show_in_website>
323
+ <show_in_store>1</show_in_store>
324
+ </redirect_once>
325
+
326
+ <source_country>
327
+ <label>Visitor country</label>
328
+ <frontend_type>multiselect</frontend_type>
329
+ <source_model>adminhtml/system_config_source_country</source_model>
330
+ <sort_order>40</sort_order>
331
+ <show_in_default>1</show_in_default>
332
+ <show_in_website>1</show_in_website>
333
+ <show_in_store>1</show_in_store>
334
+ </source_country>
335
+ <redirect_land_url>
336
+ <label>Land URL</label>
337
+ <frontend_type>text</frontend_type>
338
+ <sort_order>45</sort_order>
339
+ <show_in_default>1</show_in_default>
340
+ <show_in_website>1</show_in_website>
341
+ <show_in_store>1</show_in_store>
342
+ </redirect_land_url>
343
+ <destination_website>
344
+ <label>Redirect to URL</label>
345
+ <frontend_type>text</frontend_type>
346
+ <sort_order>50</sort_order>
347
+ <show_in_default>1</show_in_default>
348
+ <show_in_website>1</show_in_website>
349
+ <show_in_store>1</show_in_store>
350
+ </destination_website>
351
+
352
+ </fields>
353
+ </redirect4>
354
+ <redirect5>
355
+ <label>Redirect #5</label>
356
+ <sort_order>50</sort_order>
357
+ <show_in_default>1</show_in_default>
358
+ <show_in_website>1</show_in_website>
359
+ <show_in_store>1</show_in_store>
360
+ <fields>
361
+ <redirect_enabled>
362
+ <label>Redirect enabled</label>
363
+ <frontend_type>select</frontend_type>
364
+ <source_model>adminhtml/system_config_source_yesno</source_model>
365
+ <sort_order>10</sort_order>
366
+ <show_in_default>1</show_in_default>
367
+ <show_in_website>1</show_in_website>
368
+ <show_in_store>1</show_in_store>
369
+ </redirect_enabled>
370
+ <redirect_once>
371
+ <label>Redirect only once?</label>
372
+ <frontend_type>select</frontend_type>
373
+ <source_model>adminhtml/system_config_source_yesno</source_model>
374
+ <sort_order>11</sort_order>
375
+ <show_in_default>1</show_in_default>
376
+ <show_in_website>1</show_in_website>
377
+ <show_in_store>1</show_in_store>
378
+ </redirect_once>
379
+
380
+ <source_country>
381
+ <label>Visitor country</label>
382
+ <frontend_type>multiselect</frontend_type>
383
+ <source_model>adminhtml/system_config_source_country</source_model>
384
+ <sort_order>40</sort_order>
385
+ <show_in_default>1</show_in_default>
386
+ <show_in_website>1</show_in_website>
387
+ <show_in_store>1</show_in_store>
388
+ </source_country>
389
+ <redirect_land_url>
390
+ <label>Land URL</label>
391
+ <frontend_type>text</frontend_type>
392
+ <sort_order>45</sort_order>
393
+ <show_in_default>1</show_in_default>
394
+ <show_in_website>1</show_in_website>
395
+ <show_in_store>1</show_in_store>
396
+ </redirect_land_url>
397
+ <destination_website>
398
+ <label>Redirect to URL</label>
399
+ <frontend_type>text</frontend_type>
400
+ <sort_order>50</sort_order>
401
+ <show_in_default>1</show_in_default>
402
+ <show_in_website>1</show_in_website>
403
+ <show_in_store>1</show_in_store>
404
+ </destination_website>
405
+
406
+ </fields>
407
+ </redirect5>
408
  </groups>
409
  </afipredirect>
410
  </sections>
app/design/frontend/default/default/template/afipredirect/ipredirect.phtml CHANGED
@@ -27,14 +27,28 @@
27
  <strong><?php echo __('no'); ?></strong>
28
  <?php endif; ?>
29
  <br />
30
- <?php echo __('Would user be redirected to %s?', $helper->getDestinationWebsite()); ?>: <strong><?php if($helper->getRedirectResultByIp($helper->getIpToTest())): ?><?php echo __('yes'); ?><?php else: ?><?php echo __('no'); ?><?php endif; ?></strong>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
31
  </div>
32
 
33
 
34
  <style type="text/css">
35
  div.afipredirect_testmode {
36
  font-family: Arial;
37
- font-size: 12px;
38
  text-align: left;
39
  margin: 0px auto;
40
  padding: 10px;
27
  <strong><?php echo __('no'); ?></strong>
28
  <?php endif; ?>
29
  <br />
30
+ <hr />
31
+ <?php for ($i = 1; $i <= 5; $i++): ?>
32
+ <?php if($helper->isRedirectEnabled($i)): ?>
33
+ <div><strong>Redirect #<?php echo $i; ?></strong></div>
34
+ <?php echo __('Redirected to %s?', $helper->getDestinationWebsite($i)); ?>:
35
+ <strong>
36
+ <?php if($helper->getRedirectResultByIp($helper->getIpToTest(),$i)): ?>
37
+ <?php echo __('yes'); ?>
38
+ <?php else: ?>
39
+ <?php echo __('no'); ?>
40
+ <?php endif; ?>
41
+ </strong>
42
+ <?php endif; ?>
43
+ <?php endfor; ?>
44
+
45
  </div>
46
 
47
 
48
  <style type="text/css">
49
  div.afipredirect_testmode {
50
  font-family: Arial;
51
+ font-size: 11px;
52
  text-align: left;
53
  margin: 0px auto;
54
  padding: 10px;
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.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>
@@ -17,17 +17,19 @@ Visitor's country code is obtained from visitor's IP address by getting data fro
17
  Extension has some configuration options:&#xD;
18
  * test mode;&#xD;
19
  * redirect type (PHP/JavaScript);&#xD;
 
20
  * exclude specific IP addresses from redirect;&#xD;
21
  * exclude search engine bots from redirect;&#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>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>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>visitor_country_ip_redirect</name>
4
+ <version>0.0.5</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>
17
  Extension has some configuration options:&#xD;
18
  * test mode;&#xD;
19
  * redirect type (PHP/JavaScript);&#xD;
20
+ * multiple redirect rules;&#xD;
21
  * exclude specific IP addresses from redirect;&#xD;
22
  * exclude search engine bots from redirect;&#xD;
23
  * etc.&#xD;
24
  &#xD;
25
  Extension is tested on versions 1.7+, but it could work with older versions as well.</description>
26
+ <notes>0.0.5 - addded 4 more redirect rules&#xD;
27
+ 0.0.4 - new features: logging, landing URL, redirect once etc.&#xD;
28
  0.0.3 - Initial release.</notes>
29
  <authors><author><name>Liudas Stanevicius</name><user>liudass</user><email>liudas@creation.lt</email></author></authors>
30
+ <date>2014-09-25</date>
31
+ <time>18:25:48</time>
32
+ <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="8ed0a59cfdd3b6380be57b33a834a26e"/></dir><dir name="Helper"><file name="Data.php" hash="bc0724de1ce00b813ecf64638041d47b"/></dir><dir name="etc"><file name="adminhtml.xml" hash="2d31a75f87743daa996f76d81f0924ac"/><file name="config.xml" hash="bd84b2c6b702e0f5b65cd48c54a98cfe"/><file name="system.xml" hash="7905df675f9a1311b8de264253d946d6"/></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="84de622a8ef1f5ac81d6a9f78b914845"/></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>
33
  <compatible/>
34
  <dependencies><required><php><min>5.2.0</min><max>5.9.0</max></php></required></dependencies>
35
  </package>