vadvs (vadvs) wrote in changelog,
vadvs
vadvs
changelog

[ljcom] r8132: LJSUP-5445: add LJ::Request as proxy lay...

Committer: vsukhanov
LJSUP-5445: add LJ::Request as proxy layer between LJ.com's code and Apache v1/v2.
U   trunk/cgi-bin/LJ/Hooks/ControlStrip.pm
U   trunk/cgi-bin/LJ/Hooks/Homepage.pm
U   trunk/cgi-bin/LJ/Hooks/S2Styles.pm
U   trunk/cgi-bin/LJ/Hooks/SUP.pm
U   trunk/cgi-bin/LJ/Hooks/Userinfo.pm
U   trunk/cgi-bin/LJ/SUP/RPC/Command/comments_tree.pm
U   trunk/cgi-bin/LJ/SUP.pm
U   trunk/cgi-bin/bml/scheme/dystopia.look
U   trunk/cgi-bin/bml/scheme/lanzelot.look
U   trunk/cgi-bin/ljcom.pl
U   trunk/cgi-bin/phonepost.pl
U   trunk/htdocs/admin/accounts/paidsummary.bml
U   trunk/htdocs/admin/accounts/vgiftsummary.bml
U   trunk/htdocs/admin/feedback/deletion.bml
U   trunk/htdocs/friends/find.bml
U   trunk/htdocs/misc/elsewhere_info.bml
U   trunk/htdocs/misc/m365_ack.bml
U   trunk/htdocs/news/2004-01-qa.bml
U   trunk/htdocs/pay/modify.bml
U   trunk/htdocs/pay/paymeth/webmoney.bml
U   trunk/htdocs/sup/rpc_interface.bml
U   trunk/ssldocs/manage/account/cc.bml
U   trunk/ssldocs/misc/m365_mo.bml
U   trunk/ssldocs/pay/cc.bml
U   trunk/ssldocs/pay/ccpay.bml
Modified: trunk/cgi-bin/LJ/Hooks/ControlStrip.pm
===================================================================
--- trunk/cgi-bin/LJ/Hooks/ControlStrip.pm	2010-01-25 08:12:46 UTC (rev 8131)
+++ trunk/cgi-bin/LJ/Hooks/ControlStrip.pm	2010-01-25 08:26:27 UTC (rev 8132)
@@ -2,6 +2,7 @@
 
 use strict;
 use Class::Autouse qw(LJ::CProd::ControlStrip);
+use LJ::Request;
 
 # logic to make sure control strip props are in order and
 # do business logic to turn on control strip.
@@ -84,11 +85,10 @@
     } elsif ($opts->{'user'}) {
         $u = LJ::load_user($opts->{'user'});
     } else {
-        my $r = Apache->request;
-        $u = LJ::load_userid($r->notes("journalid"));
+        $u = LJ::load_userid(LJ::Request->notes("journalid"));
     }
 
-    my %GET = Apache->request->args;
+    my %GET = LJ::Request->args;
 
     # logic here:
     # if the journal has it set to show, show it
@@ -116,15 +116,14 @@
     } elsif ($opts->{'user'}) {
         $u = LJ::load_user($opts->{'user'});
     } else {
-        my $r = Apache->request;
-        $u = LJ::load_userid($r->notes("journalid"));
+        $u = LJ::load_userid(LJ::Request->notes("journalid"));
     }
 
     LJ::need_res('stc/controlstrip.css');
 
     my $color;
 
-    my %GET = Apache->request->args;
+    my %GET = LJ::Request->args;
     my $stylemine = $GET{'style'} eq 'mine' && $remote && $u->id != $remote->id;
 
     if ($u->prop('show_control_strip') && !$stylemine) {

Modified: trunk/cgi-bin/LJ/Hooks/Homepage.pm
===================================================================
--- trunk/cgi-bin/LJ/Hooks/Homepage.pm	2010-01-25 08:12:46 UTC (rev 8131)
+++ trunk/cgi-bin/LJ/Hooks/Homepage.pm	2010-01-25 08:26:27 UTC (rev 8132)
@@ -6,9 +6,8 @@
 
     ## special hack: to allow members of lj_core view
     ## reskined pages
-    my $r = eval {Apache->request};
-    if ($r) {
-        my %args = $r->args;
+    if (LJ::Request->is_inited) {
+        my %args = LJ::Request->args;
         if ($args{xbox_reskining}) {
             if ($LJ::IS_DEV_SERVER) {
                 return 1;
@@ -50,9 +49,8 @@
     my $params = shift;
     
     ## allow to disable reskining in query string args
-    my $r = eval {Apache->request};
-    if ($r) {
-        my %args = $r->args;
+    if (LJ::Request->is_inited) {
+        my %args = LJ::Request->args;
         return 0 if $args{no_ny_2010};
         return 1 if $args{ny_2010};
     }
@@ -71,13 +69,12 @@
     my $params = shift;
     
     ## allow to enable reskining in query string args
-    my $r = eval {Apache->request};
-    if ($r) {
-        my %args = $r->args;
+    if (LJ::Request->is_inited) {
+        my %args = LJ::Request->args;
         return 1 if $args{nokia_2010};
         
         # Show this skin only on /index.bml
-        return 0 unless $r->uri =~ m!^/(?:index\.bml)?$!; 
+        return 0 unless LJ::Request->uri =~ m!^/(?:index\.bml)?$!; 
     } else {
         # no real request => no reskining
         return 0;

Modified: trunk/cgi-bin/LJ/Hooks/S2Styles.pm
===================================================================
--- trunk/cgi-bin/LJ/Hooks/S2Styles.pm	2010-01-25 08:12:46 UTC (rev 8131)
+++ trunk/cgi-bin/LJ/Hooks/S2Styles.pm	2010-01-25 08:26:27 UTC (rev 8132)
@@ -5,7 +5,7 @@
 
 LJ::register_hook('s2_head_content_extra', sub {
     my ($str_ref, $u, $r) = @_;
-    $$str_ref .= expresslane_html_comment($u, $r);
+    $$str_ref .= expresslane_html_comment($u);
 });
 
 LJ::register_hook('s2_can_use_layer', sub {

Modified: trunk/cgi-bin/LJ/Hooks/SUP.pm
===================================================================
--- trunk/cgi-bin/LJ/Hooks/SUP.pm	2010-01-25 08:12:46 UTC (rev 8131)
+++ trunk/cgi-bin/LJ/Hooks/SUP.pm	2010-01-25 08:26:27 UTC (rev 8132)
@@ -6,6 +6,7 @@
 use Storable qw/freeze thaw/;
 use LJ::S2Theme;
 use LJ::HomepageItems;
+use LJ::Request;
 
 my $udp_log;
 
@@ -31,7 +32,7 @@
                 $params->{state} = $comment->state;
             };
 
-            my $rec = eval { LJ::AccessLogRecord->new( Apache->request ) } || {};
+            my $rec = eval { LJ::AccessLogRecord->new() } || {};
 
             # Convert LJ::AccessLogRecord object into hash for output
             my @rec_array = map { $_ . '="' . $udp_log->escape($rec->{$_}) . '"' } $rec->keys();
@@ -62,7 +63,7 @@
         if ($poll_log) {
 
             # Convert LJ::AccessLogRecord object into hash for output
-            my $rec = eval { LJ::AccessLogRecord->new( Apache->request ) } || {};
+            my $rec = eval { LJ::AccessLogRecord->new() } || {};
             my @rec_array = map { $_ . '="' . $poll_log->escape($rec->{$_}) . '"' } $rec->keys();
 
             # Don't log password field
@@ -113,8 +114,8 @@
 LJ::register_hook('set_alternate_statimg', sub {
     return 0; # disable this hook for now
 
-    my $r = eval { Apache->request } or return 0;
-    my $ip = $r->connection->remote_ip;
+    return 0 unless LJ::Request->is_inited;
+    my $ip = LJ::Request->connection->remote_ip;
     my $ipclass = LJ::LJcom::ip_class($ip);
     return unless $ipclass;
 
@@ -348,11 +349,10 @@
     
     # This P3P header should be set to enable login when login page is in <iframe> tag on the other site
     eval{
-        my $r = Apache->request;
         my $header_name = 'P3P';
         my $header_body = 'CP="NON DSP COR CUR ADM DEV PSA PSD OUR UNR BUS UNI COM NAV INT DEM STA"';
-        $r->header_out($header_name, $header_body);
-        $r->err_header_out($header_name, $header_body);
+        LJ::Request->header_out($header_name, $header_body);
+        LJ::Request->err_header_out($header_name, $header_body);
     };
 });
                                    
@@ -385,7 +385,7 @@
     ## Redirect user to that page next time.
     ## If there is a flag in URL (?force=1), then do not redirect and remember the page
 
-    my $called_from = Apache->request->uri;
+    my $called_from = LJ::Request->uri;
     my $prop_name = 'last_chosen_mobile_page';
     my $preferred_mobile_page = $remote->prop($prop_name);
     if (!$preferred_mobile_page) {
@@ -601,7 +601,7 @@
 ##
 LJ::register_hook('show_thread_expander', sub {
     return 0 if $LJ::DISABLED{thread_expander};
-    my $u = LJ::load_userid(Apache->request->notes("journalid"));
+    my $u = LJ::load_userid(LJ::Request->notes("journalid"));
     return 1 if $u && $u->get_cap('thread_expander');
     my $remote = LJ::get_remote();
     return 1 if $remote && $remote->get_cap('thread_expander');
@@ -754,7 +754,7 @@
     ## to URL of embedded iframe
     return unless $journalu && $drugoi_campaign_journals{ $journalu->{userid} };
   
-    my %getargs = eval { Apache->request->args };
+    my %getargs = eval { LJ::Request->args };
     $params->{pID}   = $getargs{'photoId'};
     $params->{uNAME} = $remote->{user} if $remote;
 });

Modified: trunk/cgi-bin/LJ/Hooks/Userinfo.pm
===================================================================
--- trunk/cgi-bin/LJ/Hooks/Userinfo.pm	2010-01-25 08:12:46 UTC (rev 8131)
+++ trunk/cgi-bin/LJ/Hooks/Userinfo.pm	2010-01-25 08:26:27 UTC (rev 8132)
@@ -1,4 +1,4 @@
-	package LJ::LJcom;
+package LJ::LJcom;
 use strict;
 
 LJ::register_hook("userinfo_rows", sub {

Modified: trunk/cgi-bin/LJ/SUP/RPC/Command/comments_tree.pm
===================================================================
--- trunk/cgi-bin/LJ/SUP/RPC/Command/comments_tree.pm	2010-01-25 08:12:46 UTC (rev 8131)
+++ trunk/cgi-bin/LJ/SUP/RPC/Command/comments_tree.pm	2010-01-25 08:26:27 UTC (rev 8132)
@@ -49,7 +49,7 @@
     my $opts   = {
                     ljentry => LJ::Entry->new($journal, ditemid => $ditemid),
                     getargs => { page => $page, thread => $thread, view => $view },
-                    r       => Apache->request,
+                    r       => LJ::Request->r,
                     };
 
 

Modified: trunk/cgi-bin/LJ/SUP.pm
===================================================================
--- trunk/cgi-bin/LJ/SUP.pm	2010-01-25 08:12:46 UTC (rev 8131)
+++ trunk/cgi-bin/LJ/SUP.pm	2010-01-25 08:26:27 UTC (rev 8132)
@@ -110,8 +110,7 @@
 
     # debug/testing options
     my %flags;
-    my $r = eval { Apache->request };
-    if ($LJ::IS_DEV_SERVER && $r && $r->args && $r->args =~ /supads=([\w:]+)/) {
+    if ($LJ::IS_DEV_SERVER && LJ::Request->is_inited && LJ::Request->args && LJ::Request->args =~ /supads=([\w:]+)/) {
         %flags = map { $_ => 1 } split(/:/, $1);
         $ip_class = "russia" if $flags{ip_russia};
     }
@@ -168,7 +167,7 @@
 
     $params{i1}     = $u->id if $u;
     $params{i2}     = $remote->id if $remote;
-    $params{cp}     = eval { Apache->notes("codepath") } || "";
+    $params{cp}     = eval { LJ::Request->notes("codepath") } || "";
     $params{vid}    = $LJ::SUP_REQUEST_ID;
     $params{srv}    = 1;
 

Modified: trunk/cgi-bin/bml/scheme/dystopia.look
===================================================================
--- trunk/cgi-bin/bml/scheme/dystopia.look	2010-01-25 08:12:46 UTC (rev 8131)
+++ trunk/cgi-bin/bml/scheme/dystopia.look	2010-01-25 08:26:27 UTC (rev 8132)
@@ -131,7 +131,7 @@
 <?_code
 {
     my $remote = LJ::get_remote(); # will be requested later and returned from cache
-    return LJ::LJcom::expresslane_html_comment($remote, $_[0]->{r});
+    return LJ::LJcom::expresslane_html_comment($remote);
 }
 _code?>
 <head>
@@ -140,7 +140,7 @@
 <link rel="contents" title="Site Map" href="<?siteroot?>/site/" />
 <link rel="help" title="Technical Support" href="<?siteroot?>/support/" />
 <title><?_code {
-    my $elhash = $_[2];
+    my $elhash = $_[1];
     return $elhash->{'WINDOWTITLE'} || $elhash->{'TITLE'};
 } _code?></title>
 <?_code LJ::res_includes() _code?>

Modified: trunk/cgi-bin/bml/scheme/lanzelot.look
===================================================================
--- trunk/cgi-bin/bml/scheme/lanzelot.look	2010-01-25 08:12:46 UTC (rev 8131)
+++ trunk/cgi-bin/bml/scheme/lanzelot.look	2010-01-25 08:26:27 UTC (rev 8132)
@@ -43,7 +43,7 @@
 <head>
     <meta http-equiv="X-UA-Compatible" content="IE=7"/>
     <meta http-equiv="content-type" content="text/html; charset=utf-8">
-    <title><?_code { my $elhash = $_[2]; return $elhash->{'WINDOWTITLE'} || $elhash->{'TITLE'}; } _code?></title>
+    <title><?_code { my $elhash = $_[1]; return $elhash->{'WINDOWTITLE'} || $elhash->{'TITLE'}; } _code?></title>
 
 <?_code
         LJ::need_res('js/core.js');

Modified: trunk/cgi-bin/ljcom.pl
===================================================================
--- trunk/cgi-bin/ljcom.pl	2010-01-25 08:12:46 UTC (rev 8131)
+++ trunk/cgi-bin/ljcom.pl	2010-01-25 08:26:27 UTC (rev 8132)
@@ -27,6 +27,8 @@
                       LJ::GeoLocation
                       );
 
+use LJ::Request;
+
 LJ::clear_hooks();
 
 @LJ::USER_TABLES_LOCAL = ("phonepostentry", "phoneposttrans", "vgifts",
@@ -213,10 +215,10 @@
 }
 
 sub expresslane_html_comment {
-    my ($u, $r) = @_;
-    return '' unless $r && $u && LJ::get_cap($u, 'paid');
+    my $u = shift;
+    return '' unless LJ::Request->is_inited && $u && LJ::get_cap($u, 'paid');
 
-    my ($free_ct, $free_age) = ($r->header_in('X-Queue-Count')+0, $r->header_in('X-Queue-Age')+0);
+    my ($free_ct, $free_age) = (LJ::Request->header_in('X-Queue-Count')+0, LJ::Request->header_in('X-Queue-Age')+0);
     return "<!-- LiveJournal ExpressLane: You received this page before $free_ct free users" .
            ($free_age > 0 ? ", saving approximately $free_age seconds" : '') . "! -->\n";
 }
@@ -568,10 +570,9 @@
 }
 
 LJ::register_hook("ssl_check", sub {
-    my $r = $_[0]{r};
     return
-        $r->header_in("X-LJ-SSL") ||
-        ($LJ::IS_DEV_SERVER && $r->header_in("Host") eq $LJ::SSLDOMAIN);
+        LJ::Request->header_in("X-LJ-SSL") ||
+        ($LJ::IS_DEV_SERVER && LJ::Request->header_in("Host") eq $LJ::SSLDOMAIN);
 });
 
 # when cancelling an account be sure to revoke promos
@@ -638,9 +639,8 @@
     if ($pathextra =~ m#^/(\d+)\.(mp3|ogg|wav)$#) {
         my $dppid = $1;
         return sub {
-            my $r = shift;
             my $u = LJ::load_user($user);
-            return LJ::PhonePost::apache_content($r, $u, $dppid);
+            return LJ::PhonePost::apache_content($u, $dppid);
         };
     }
     return undef;
@@ -652,11 +652,10 @@
     if ($pathextra =~ m#^/(\d+)\.(mp3|ogg|wav)$#) {
         my ($dppid, $ext) = ($1, $2);
         return sub {
-            my $r = shift;
             my $u = LJ::load_user($user);
             my $dataurl = $u->journal_base . "/data/phonepost/$dppid.$ext";
-            $r->header_out(Location => $dataurl);
-            return Apache::Constants::REDIRECT();
+            LJ::Request->header_out(Location => $dataurl);
+            return LJ::Request::REDIRECT();
         };
     }
     return undef;
@@ -1050,7 +1049,7 @@
             'posterid' => $up->{'userid'},
             'journalid' => $uo->{'userid'},
             'remote_ip' => LJ::get_remote_ip(),
-            'remote_ua' => LJ::is_web_context() ? Apache->request->header_in('User-Agent') : undef,
+            'remote_ua' => LJ::is_web_context() ? LJ::Request->instance->header_in('User-Agent') : undef,
             'remote_uniq' => LJ::UniqCookie->current_uniq,
         }) if ($rand <= $LJ::POST_SAMPLE && !$LJ::DISABLED{'tp_antispam_test'});
     }
@@ -1116,9 +1115,8 @@
 });
 
 LJ::register_hook("forbid_request", sub {
-    my $r = shift;
-    my $ua = $r->header_in("User-Agent");
-    my $ip = $r->connection->remote_ip;
+    my $ua = LJ::Request->header_in("User-Agent");
+    my $ip = LJ::Request->connection->remote_ip;
     # @BAN_UA can be either scalar substrings of user-agents, or
     # an arrayref of [ $substr, $ip ] which makes the substring
     # match conditional on it matching that IP
@@ -1373,7 +1371,7 @@
 
     my $uniq = '';
     eval {
-        $uniq = Apache->request->notes('uniq');
+        $uniq = LJ::Request->instance->notes('uniq');
     };
     my $ip = LJ::get_remote_ip();
 
@@ -1503,7 +1501,6 @@
     my $opts = shift;
 
     my $interface = delete $opts->{'int'};
-    my $r = delete $opts->{'r'};
     my $bml_handler = delete $opts->{'bml_handler'};
 
     if ($interface eq 'm365_mo') {
@@ -1776,9 +1773,8 @@
     my $ret;
 
     return unless LJ::is_web_context();
-    my $r = Apache->request;
     # Friends pages has a different message for first post
-    if ($r->notes('view') eq "friends") {
+    if (LJ::Request->notes('view') eq "friends") {
         $ret .= BML::ml('ljcom.lj-replace.first_post.friends', {
                     'addfriend'    => "src='$LJ::IMGPREFIX/btn_addfriend.gif'",
                     'userhead'     => "src='$LJ::IMGPREFIX/userinfo.gif'",

Modified: trunk/cgi-bin/phonepost.pl
===================================================================
--- trunk/cgi-bin/phonepost.pl	2010-01-25 08:12:46 UTC (rev 8131)
+++ trunk/cgi-bin/phonepost.pl	2010-01-25 08:26:27 UTC (rev 8132)
@@ -64,7 +64,7 @@
 }
 
 sub apache_content {
-    my ($r, $u, $dppid) = @_;
+    my ($u, $dppid) = @_;
     my $bid = int($dppid/256);
     my $ppe = get_phonepost_entry($u, $bid);
     return 404 unless $ppe && $ppe->{jitemid} && $ppe->{anum} == $dppid % 256;
@@ -78,7 +78,7 @@
         # from Akamai/Speedera/etc and the IP won't match
         my $remote = LJ::get_remote({ ignore_ip => 1 });
 
-        my %GET = $r->args;
+        my %GET = LJ::Request->args;
 
         my $viewall = 0;
         my $viewsome = 0;
@@ -96,19 +96,19 @@
     }
 
     # future:  if length is NULL, then it's an external reference and we redirect
-    $r->header_out("Cache-Control", "must-revalidate, private");
-    $r->header_out("Content-Length", $ppe->{length});
-    $r->content_type( $datatypes->{ $ppe->{filetype} }->{mime} );
+    LJ::Request->header_out("Cache-Control", "must-revalidate, private");
+    LJ::Request->header_out("Content-Length", $ppe->{length});
+    LJ::Request->content_type( $datatypes->{ $ppe->{filetype} }->{mime} );
 
     # handle IMS requests
     my $last_mod = LJ::time_to_http($ppe->{posttime});
-    if (my $ims = $r->header_in("If-Modified-Since")) {
+    if (my $ims = LJ::Request->header_in("If-Modified-Since")) {
         return 304 if $ims eq $last_mod;
     }
 
-    $r->header_out("Last-Modified", $last_mod);
-    if ($r->header_only) {
-        $r->send_http_header();
+    LJ::Request->header_out("Last-Modified", $last_mod);
+    if (LJ::Request->header_only) {
+        LJ::Request->send_http_header();
         return 200;
     }
 
@@ -116,41 +116,41 @@
     if ($ppe->{location} eq 'mogile') {
         # Mogile
         if ( !$LJ::REPROXY_DISABLE{phoneposts} &&
-             $r->header_in('X-Proxy-Capabilities') &&
-             $r->header_in('X-Proxy-Capabilities') =~ /\breproxy-file\b/i )
+             LJ::Request->header_in('X-Proxy-Capabilities') &&
+             LJ::Request->header_in('X-Proxy-Capabilities') =~ /\breproxy-file\b/i )
         {
             my @paths = LJ::mogclient()->get_paths( "pp:$u->{userid}:$bid", 1 );
 
             # reproxy url
             if ($paths[0] =~ m/^http:/) {
-                $r->header_out('X-REPROXY-URL', join(' ', @paths));
+                LJ::Request->header_out('X-REPROXY-URL', join(' ', @paths));
             }
             # reproxy file
             else {
-                $r->header_out('X-REPROXY-FILE', $paths[0]);
+                LJ::Request->header_out('X-REPROXY-FILE', $paths[0]);
             }
-            $r->send_http_header();
+            LJ::Request->send_http_header();
         }
         else {
             $buffer = LJ::mogclient()->get_file_data("pp:$u->{userid}:$bid");
-            $r->send_http_header();
+            LJ::Request->send_http_header();
             return 500 unless $buffer && ref $buffer;
-            $r->print($$buffer);
+            LJ::Request->print($$buffer);
         }
 
     }
     else {
         # BlobServer
-        $r->send_http_header();
+        LJ::Request->send_http_header();
         my $ret = LJ::Blob::get_stream($u, 'phonepost',
                                        $datatypes->{ $ppe->{filetype} }->{ext}, $bid, sub {
             $buffer .= $_[0];
             if (length($buffer) > 50_000) {
-                $r->print($buffer);
+                LJ::Request->print($buffer);
                 undef $buffer;
             }
         });
-        $r->print($buffer) if length($buffer);
+        LJ::Request->print($buffer) if length($buffer);
         return 500 unless $ret;
     }
 

Modified: trunk/htdocs/admin/accounts/paidsummary.bml
===================================================================
--- trunk/htdocs/admin/accounts/paidsummary.bml	2010-01-25 08:12:46 UTC (rev 8131)
+++ trunk/htdocs/admin/accounts/paidsummary.bml	2010-01-25 08:26:27 UTC (rev 8132)
@@ -5,10 +5,6 @@
 
     my $PAGE_SIZE = 50;
 
-    # sometimes need an Apache::Request object
-    my $req = shift;
-    my $r = $req->{'r'};
-
     my $remote = LJ::get_remote();
     return "You must first <a href=\"/login.bml?ret=1\">log in</a>."
         unless $remote;
@@ -60,7 +56,7 @@
 
     # Handle CSV output (which outputs different content than HTMl output)
     if ($view_mode eq 'csv') {
-        handle_csv($r, \%stats, $year, $month, $day);
+        handle_csv(\%stats, $year, $month, $day);
         return;
     }
 
@@ -513,7 +509,7 @@
     }   # subroutine
 
     sub handle_csv {
-        my ($r, $stats_ref, $year, $month, $day) = @_;
+        my ($stats_ref, $year, $month, $day) = @_;
 
         # CSV columns.  FIXME: add more
         my $ret .= join
@@ -597,10 +593,10 @@
             sprintf("paidsummary-%4d-%02d.csv", $year, $month) :
             sprintf("paidsummary-%4d-%02d-%02d.csv", $year, $month, $day);
 
-        $r->content_type("application/x-csv");
-        $r->header_out("Content-disposition" => "attachment; filename=\"$filename\"");
-        $r->send_http_header;
-        $r->print($ret);
+        LJ::Request->content_type("application/x-csv");
+        LJ::Request->header_out("Content-disposition" => "attachment; filename=\"$filename\"");
+        LJ::Request->send_http_header();
+        LJ::Request->print($ret);
 
         return;
     }

Modified: trunk/htdocs/admin/accounts/vgiftsummary.bml
===================================================================
--- trunk/htdocs/admin/accounts/vgiftsummary.bml	2010-01-25 08:12:46 UTC (rev 8131)
+++ trunk/htdocs/admin/accounts/vgiftsummary.bml	2010-01-25 08:26:27 UTC (rev 8132)
@@ -5,10 +5,6 @@
 
     my $PAGE_SIZE = 50;
 
-    # sometimes need an Apache::Request object
-    my $req = shift;
-    my $r = $req->{'r'};
-
     my $remote = LJ::get_remote();
     return "You must first <a href=\"/login.bml?ret=1\">log in</a>."
         unless $remote;
@@ -235,10 +231,10 @@
                 sprintf("paidsummary-%4d-%02d.csv", $year, $month) :
                 sprintf("paidsummary-%4d-%02d-%02d.csv", $year, $month, $day);
 
-            $r->content_type("application/x-csv");
-            $r->header_out("Content-disposition" => "attachment; filename=\"$filename\"");
-            $r->send_http_header;
-            $r->print($output);
+            LJ::Request->content_type("application/x-csv");
+            LJ::Request->header_out("Content-disposition" => "attachment; filename=\"$filename\"");
+            LJ::Request->send_http_header();
+            LJ::Request->print($output);
 
             return;
         }

Modified: trunk/htdocs/admin/feedback/deletion.bml
===================================================================
--- trunk/htdocs/admin/feedback/deletion.bml	2010-01-25 08:12:46 UTC (rev 8131)
+++ trunk/htdocs/admin/feedback/deletion.bml	2010-01-25 08:26:27 UTC (rev 8132)
@@ -89,11 +89,10 @@
 
             my $filename = sprintf("deletion_feedback_%4d-%02d-%02d_through_%4d-%02d-%02d.csv", $year_start, $month_start, $day_start, $year_end, $month_end, $day_end);
 
-            my $r = Apache->request;
-            $r->content_type("application/x-csv");
-            $r->header_out("Content-disposition" => "attachment; filename=\"$filename\"");
-            $r->send_http_header;
-            $r->print($csv_text);
+            LJ::Request->content_type("application/x-csv");
+            LJ::Request->header_out("Content-disposition" => "attachment; filename=\"$filename\"");
+            LJ::Request->send_http_header();
+            LJ::Request->print($csv_text);
 
             return;
         }

Modified: trunk/htdocs/friends/find.bml
===================================================================
--- trunk/htdocs/friends/find.bml	2010-01-25 08:12:46 UTC (rev 8131)
+++ trunk/htdocs/friends/find.bml	2010-01-25 08:26:27 UTC (rev 8132)
@@ -28,7 +28,7 @@
 
     my $remote = LJ::get_remote();
 
-    $_[2]->{WINDOWTITLE} = $ML{'.title1'};
+    $_[1]->{WINDOWTITLE} = $ML{'.title1'};
 
     return "<?needlogin?>"
         unless $remote;
@@ -134,7 +134,7 @@
     # skip invite page if we have no emails for it
     $step = 4 if $step == 3 and scalar @{$result->{for_invite}} == 0;
 
-    $_[2]->{WINDOWTITLE} = $ML{'.title' . $step};
+    $_[1]->{WINDOWTITLE} = $ML{'.title' . $step};
 
     $ret .= LJ::Widget::FindFriendsProgressMeter->render( step => $step ) if $step <= 3;
     $ret .= '<h1>' . $ML{'.head_finish'} . '</h1>' if $step == 4;
@@ -166,7 +166,7 @@
             $ret .= '<div class="warningbar" style="background: url(' . $LJ::IMGPREFIX . '/message-warning.gif) repeat-x #FFFFDD;">';
             $ret .= $ML{'.already'};
             $ret .= '</div>';
-            $_[2]->{WINDOWTITLE} = $ML{'.title_all'};
+            $_[1]->{WINDOWTITLE} = $ML{'.title_all'};
         }
 
         if ($from_post{'added'}) {

Modified: trunk/htdocs/misc/elsewhere_info.bml
===================================================================
--- trunk/htdocs/misc/elsewhere_info.bml	2010-01-25 08:12:46 UTC (rev 8131)
+++ trunk/htdocs/misc/elsewhere_info.bml	2010-01-25 08:26:27 UTC (rev 8132)
@@ -6,11 +6,8 @@
     # We'll handle it from here
     BML::finish_suppress_all();
 
-    my $req = shift;
-    my $r = $req->{r};
+    Apache::LiveJournal::Interface::ElsewhereInfo->handle('UNUSED');
 
-    Apache::LiveJournal::Interface::ElsewhereInfo->handle($r);
-
     return;
 }
 _code?>

Modified: trunk/htdocs/misc/m365_ack.bml
===================================================================
--- trunk/htdocs/misc/m365_ack.bml	2010-01-25 08:12:46 UTC (rev 8131)
+++ trunk/htdocs/misc/m365_ack.bml	2010-01-25 08:26:27 UTC (rev 8132)
@@ -3,17 +3,14 @@
     use strict;
     use vars qw(%GET %POST);
 
-    my $req = shift;
-    my $r = $req->{r};
-
     # BML calls $r->content which can only be called once
     # so we'll add a 'content' pnotes field for \%POST
-    $r->pnotes('content' => \%GET);
+    LJ::Request->pnotes('content' => \%GET);
 
     my $gw = LJ::sms_gateway()
         or die "unable to retrieve gateway object";
 
-    my $dsms_ack = $gw->recv_ack_http($r);
+    my $dsms_ack = $gw->recv_ack_http('UNUSED');
 
     # create an LJ::SMS::MessageAck from this DSMS::MessageAck
     my $lj_ack = LJ::SMS::MessageAck->new_from_dsms($dsms_ack);

Modified: trunk/htdocs/news/2004-01-qa.bml
===================================================================
--- trunk/htdocs/news/2004-01-qa.bml	2010-01-25 08:12:46 UTC (rev 8131)
+++ trunk/htdocs/news/2004-01-qa.bml	2010-01-25 08:26:27 UTC (rev 8132)
@@ -4,7 +4,7 @@
 {Fp}
 <?_code
 {
-    my ($scratch, $args) = ($_[1], $_[2]);
+    my ($scratch, $args) = ($_[0], $_[1]);
     my $ljuser = $args->{LJUSER};
     my $count = ++$scratch->{"count"};
     my $lastnum = $scratch->{"perma_$ljuser"};

Modified: trunk/htdocs/pay/modify.bml
===================================================================
--- trunk/htdocs/pay/modify.bml	2010-01-25 08:12:46 UTC (rev 8131)
+++ trunk/htdocs/pay/modify.bml	2010-01-25 08:26:27 UTC (rev 8132)
@@ -10,9 +10,6 @@
     return BML::redirect("./")
         unless LJ::did_post();
 
-    my $req = shift;
-    my $r = $req->{'r'};
-
     my $now = time();
 
     ($title, $body) = ("", "");
@@ -214,7 +211,7 @@
         $cartobj->payvar_add("browser", $ua) if $ua;
 
         # log uniq
-        my $uniq = $r->notes('uniq');
+        my $uniq = LJ::Request->notes('uniq');
         $cartobj->payvar_add("uniq",  LJ::mysql_time() . " - $uniq") if $uniq;
 
         if ($paymeth eq "sup_sms" && LJ::Pay::can_use_sup_sms($remote)) {

Modified: trunk/htdocs/pay/paymeth/webmoney.bml
===================================================================
--- trunk/htdocs/pay/paymeth/webmoney.bml	2010-01-25 08:12:46 UTC (rev 8131)
+++ trunk/htdocs/pay/paymeth/webmoney.bml	2010-01-25 08:26:27 UTC (rev 8132)
@@ -9,9 +9,6 @@
     # Continue shopping if they hit that button
     return BML::redirect("/shop/") if $POST{'action:continue'};
 
-    my $req = shift;
-    my $r = $req->{'r'};
-
     my $now = time();
 
     ($title, $body) = ("", "");

Modified: trunk/htdocs/sup/rpc_interface.bml
===================================================================
--- trunk/htdocs/sup/rpc_interface.bml	2010-01-25 08:12:46 UTC (rev 8131)
+++ trunk/htdocs/sup/rpc_interface.bml	2010-01-25 08:26:27 UTC (rev 8132)
@@ -10,8 +10,10 @@
     use XML::Simple;
     use JSON qw//;
 
-    my $r = eval { Apache->request };
-    my $response_format = $r ? $r->headers_in->get("X-Response-Format") : 'xml';
+    # Old code:
+    # my $r = eval { Apache->request };
+    # my $response_format = $r ? $r->headers_in->get("X-Response-Format") : 'xml';
+    my $response_format = LJ::Request->headers_in->get("X-Response-Format");
 
     #
     # PARAMS:
@@ -27,8 +29,7 @@
     my $ip_class  = LJ::LJcom::ip_class();
     my $remote_ip = LJ::get_remote_ip();
 
-    $r->notes('codepath' => "interface.sup_rpc.index:" . $params->{action})
-        if $r;
+    LJ::Request->notes('codepath' => "interface.sup_rpc.index:" . $params->{action});
     
     my $trusted_commands = 
         $LJ::IS_DEV_SERVER 

Modified: trunk/ssldocs/manage/account/cc.bml
===================================================================
--- trunk/ssldocs/manage/account/cc.bml	2010-01-25 08:12:46 UTC (rev 8131)
+++ trunk/ssldocs/manage/account/cc.bml	2010-01-25 08:26:27 UTC (rev 8132)
@@ -80,9 +80,7 @@
     my ($ret, $err);
 
     # Sysban checks
-    my $req = shift;
-    my $r = $req->{r};
-    my $uniq = $r->notes('uniq');
+    my $uniq = LJ::Request->notes('uniq');
 
     if (LJ::sysban_check('pay_email', $u->email_raw)) {
         LJ::sysban_note($u->{'userid'},

Modified: trunk/ssldocs/misc/m365_mo.bml
===================================================================
--- trunk/ssldocs/misc/m365_mo.bml	2010-01-25 08:12:46 UTC (rev 8131)
+++ trunk/ssldocs/misc/m365_mo.bml	2010-01-25 08:26:27 UTC (rev 8132)
@@ -3,17 +3,14 @@
     use strict;
     use vars qw(%POST);
 
-    my $req = shift;
-    my $r = $req->{r};
-
     # BML calls $r->content which can only be called once
     # so we'll add a 'content' pnotes field for \%POST
-    $r->pnotes('content' => \%POST);
+    LJ::Request->pnotes('content' => \%POST);
 
     my $gw = LJ::sms_gateway()
         or die "unable to retrieve gateway object";
 
-    my $resp = $gw->recv_msg_http($r);
+    my $resp = $gw->recv_msg_http('UNUSED');
 
     # was it a properly formed and read request?
     if ($resp->is_success) {

Modified: trunk/ssldocs/pay/cc.bml
===================================================================
--- trunk/ssldocs/pay/cc.bml	2010-01-25 08:12:46 UTC (rev 8131)
+++ trunk/ssldocs/pay/cc.bml	2010-01-25 08:26:27 UTC (rev 8132)
@@ -8,9 +8,7 @@
     # Auto redirect to status if disabled
     return BML::redirect("http://status.livejournal.org/") if $LJ::DISABLED{'recbill_shop'};
 
-    my $req = shift;
-    my $r = $req->{r};
-    my $uniq = $r->notes('uniq');
+    my $uniq = LJ::Request->notes('uniq');
     my $remote = LJ::get_remote();
     my $remote_ip = LJ::get_remote_ip();
 

Modified: trunk/ssldocs/pay/ccpay.bml
===================================================================
--- trunk/ssldocs/pay/ccpay.bml	2010-01-25 08:12:46 UTC (rev 8131)
+++ trunk/ssldocs/pay/ccpay.bml	2010-01-25 08:26:27 UTC (rev 8132)
@@ -8,9 +8,7 @@
     use LWP;
     use LWP::UserAgent;
 
-    my $req = shift;
-    my $r = $req->{r};
-    my $uniq = $r->notes('uniq');
+    my $uniq = LJ::Request->notes('uniq');
 
     my $dbh = LJ::get_db_writer();
     my $cart = $POST{'cart'};

Tags: bml, ljcom, look, pl, pm, 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