ssafronova (ssafronova) wrote in changelog,
ssafronova
ssafronova
changelog

[livejournal] r17664: LJSUP-7280: Statistic for Yandex

Committer: ssafronova
LJSUP-7280: Statistic for Yandex
U   trunk/cgi-bin/ljfeed.pl
Modified: trunk/cgi-bin/ljfeed.pl
===================================================================
--- trunk/cgi-bin/ljfeed.pl	2010-11-10 10:51:06 UTC (rev 17663)
+++ trunk/cgi-bin/ljfeed.pl	2010-11-10 12:32:16 UTC (rev 17664)
@@ -27,6 +27,28 @@
     my $feedtype = $1;
     my $viewfunc = $feedtypes{$feedtype};
 
+    # /ya/rss -> special rss for yandex
+    if ($feedtype eq 'ya') {
+        $opts->{pathextra} =~ s!^/(\w+)!!; # cut off '/rss' part
+        $feedtype = $1;
+        $viewfunc = $feedtypes{$feedtype} if $feedtype eq 'rss';
+        $opts->{include_statistics} = 1;
+
+        my $allowed = 0;
+        my $remote_ip = LJ::get_remote_ip();
+        foreach my $block (@LJ::YANDEX_RSS_IP_BLOCKS) {
+            my $net = Net::Netmask->new($block);
+            next unless $net->match($remote_ip);
+            $allowed = 1;
+            last;
+        }
+
+        unless ($allowed) {
+            $opts->{'handler_return'} = 403;
+            return undef;
+        }
+    }
+
     unless ($viewfunc) {
         $opts->{'handler_return'} = 404;
         return undef;

Tags: livejournal, pl, ssafronova
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