wisest owl (wisest_owl) wrote in changelog,
wisest owl
wisest_owl
changelog

[ljcom] r11709: LJSUP-11838: Adjust redirect from livejo...

Committer: wisest-owl
LJSUP-11838: Adjust redirect from livejournal.com to livejournal.my like for lj.sg

U   trunk/cgi-bin/LJ/Widget/HomepageEN.pm
Modified: trunk/cgi-bin/LJ/Widget/HomepageEN.pm
===================================================================
--- trunk/cgi-bin/LJ/Widget/HomepageEN.pm	2012-04-16 11:42:53 UTC (rev 11708)
+++ trunk/cgi-bin/LJ/Widget/HomepageEN.pm	2012-04-16 11:48:49 UTC (rev 11709)
@@ -38,13 +38,43 @@
 
     ## Country blocks
     $result{country} = LJ::GeoLocation->get_country_info_by_ip;
-    if ((!$remote && $result{country} eq 'SG') || ( $remote && ($result{country} eq 'SG' || $remote->prop('country') eq 'SG')) && !$remote->prop('disable_sg_redirect')) {
-        if ($GET->{sgredirect} eq 'off') {
+    my @countries = (
+        {
+            country     => qr/^SG$/,
+            get_param   => "sgredirect",
+            domain      => "sg",
+        },
+        {
+            country     => qr/^MY$/,
+            get_param   => "myredirect",
+            domain      => "my",
+        },
+    );
+    if (
+        ## Anonymous with @countries-IP
+        ( !$remote && grep { $result{country} =~ $_->{'country'} } @countries )
+        ||
+        (
+            ## Logged-in user with @countries-IP or with set prop
+            $remote &&
+                (
+                    (grep { $result{country} =~ $_->{'country'} } @countries)
+                    ||
+                    (grep { $remote->prop('country') =~ $_->{'country'} } @countries)
+                )
+        )
+        &&
+        ## User does not disable redirects
+        ! $remote->prop ( 'disable_sg_redirect' )
+    ) 
+    {
+        my ($user_country) = grep { ($result{country} =~ $_->{'country'}) || ($remote && $remote->prop('country') =~ $_->{'country'}) } @countries;
+        if ($GET->{'sgredirect'} eq 'off') {
             LJ::Request->set_cookie('non-sg-redirect' => '1', 'expires' => time + 15552000);
             $remote->set_prop('disable_sg_redirect', 1) if $remote;
         }
         unless (LJ::Request->cookie('non-sg-redirect')) { 
-            LJ::Request->redirect('http://www.livejournal.sg/?sgr=1'); 
+            LJ::Request->redirect('http://www.livejournal.'.$user_country->{'domain'}.'/?'.$user_country->{'domain'}.'r=1'); 
         }
     }
     $result{uk_block} =

Tags: ljcom, pm, wisest-owl
Subscribe
  • Post a new comment

    Error

    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

  • 0 comments