vadvs (vadvs) wrote in changelog,
vadvs
vadvs
changelog

[livejournal] r19160: LJSUP-8888: Display country and city wit...

Committer: vsukhanov
LJSUP-8888: Display country and city with IP adresses in comment
U   trunk/cgi-bin/LJ/Talk.pm
U   trunk/htdocs/talkread.bml.text
Modified: trunk/cgi-bin/LJ/Talk.pm
===================================================================
--- trunk/cgi-bin/LJ/Talk.pm	2011-05-27 09:10:03 UTC (rev 19159)
+++ trunk/cgi-bin/LJ/Talk.pm	2011-05-27 09:20:50 UTC (rev 19160)
@@ -15,6 +15,7 @@
 use LJ::Talk::Author;
 use LJ::TimeUtil;
 use LJ::Pay::Wallet;
+use LJ::GeoLocation;
 
 use constant PACK_FORMAT => "NNNNC"; ## $talkid, $parenttalkid, $poster, $time, $state 
 
@@ -2610,7 +2611,17 @@
                 if ($post->{'props'}->{'poster_ip'} &&
                     $remote && ($remote->{'user'} eq $up->{'user'} || $remote->can_manage($u) || $viewall))
                 {
-                    $text .= BML::ml('.fromip', { 'ip' => $post->{'props'}->{'poster_ip'} });
+                    ## resolve IP to a location
+                    my $ip   = $post->{'props'}->{'poster_ip'};
+                    my $info = LJ::GeoLocation->get_city_info_by_ip($ip);
+
+                    if ($info and my $country = $info->{country_name} and my $city = $info->{city_name}){
+                        ## Display location of an IP.
+                        $text .= LJ::Lang::ml('.fromip.extended', { ip => $ip, country => $country, city => $city });
+                    } else {
+                        ## IP location is unknown 
+                        $text .= LJ::Lang::ml('.fromip', { ip => $ip });
+                    }
                 }
 
                 if ($post->{'state'} ne 'B') {

Modified: trunk/htdocs/talkread.bml.text
===================================================================
--- trunk/htdocs/talkread.bml.text	2011-05-27 09:10:03 UTC (rev 19159)
+++ trunk/htdocs/talkread.bml.text	2011-05-27 09:20:50 UTC (rev 19160)
@@ -15,6 +15,7 @@
 .edittime=Edited at [[edittime]]
 
 .fromip=(from [[ip]])
+.fromip.extended=([[country]], [[city]] / [[ip]])
 
 .multi.no.action|staleness=1
 .multi.no.action=You have not selected one of the actions

Tags: livejournal, pm, text, vadvs
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