Андрей (andy) wrote in changelog,
Андрей
andy
changelog

[fotobilder] r1405: LJSUP-5576 (make fotobilder work on cent...

Committer: ailyin
LJSUP-5576 (make fotobilder work on centos/apache2)

U   trunk/lib/Apache/FotoBilder/WebUpload.pm
U   trunk/lib/Apache/FotoBilder.pm
U   trunk/lib/startup.pl
Modified: trunk/lib/Apache/FotoBilder/WebUpload.pm
===================================================================
--- trunk/lib/Apache/FotoBilder/WebUpload.pm	2010-03-03 05:56:36 UTC (rev 1404)
+++ trunk/lib/Apache/FotoBilder/WebUpload.pm	2010-03-03 11:24:35 UTC (rev 1405)
@@ -5,7 +5,6 @@
 
 use strict;
 use Digest::MD5 ();
-use Apache::Request;
 
 sub handler
 {
@@ -123,7 +122,7 @@
                     mkdir $spool_dir, 0755;
                     unless (-e $spool_dir) {
                         LJ::Request->log_error("Could not create spool directory (wrong permissions?): $spool_dir");
-                        die "Failed to find/create spool directory";
+                        die "Failed to find/create spool directory: $spool_dir";
                     }
                 }
 
@@ -235,7 +234,6 @@
 
             return 1;
         };
-
         # parse multipart-mime submission, one chunk at a time,
         # calling our hooks as we go to put uploads in temporary
         # MogileFS filehandles

Modified: trunk/lib/Apache/FotoBilder.pm
===================================================================
--- trunk/lib/Apache/FotoBilder.pm	2010-03-03 05:56:36 UTC (rev 1404)
+++ trunk/lib/Apache/FotoBilder.pm	2010-03-03 11:24:35 UTC (rev 1405)
@@ -108,7 +108,6 @@
     LJ::Request->pnotes(BMLEnvOverride => $bml_env_or);
 
     $FB::IMGPREFIX = $FB::IMGPREFIX_BAK;
-
     # let foo.com still work, but LJ::Request::REDIRECT to www.foo.com
     if ($FB::DOMAIN_WEB && LJ::Request->method eq "GET" &&
         $host eq $FB::DOMAIN && $FB::DOMAIN_WEB ne $FB::DOMAIN) {
@@ -256,6 +255,26 @@
         }
     }
 
+    # emulate DirectoryIndex directive
+    if (not defined LJ::Request->filename   # it seems that under Apache v2 'filename' method maps to files only
+                                            # and for directories it returns undef.
+    ){
+        # maps uri to dir
+        my $uri = LJ::Request->uri;
+        return LJ::Request::NOT_FOUND if $uri =~ /\.\./; # forbids ANY .. in uri
+        
+        if ($uri and -d "$ENV{FBHOME}/htdocs/" . $uri){
+            $uri .= "/" unless $uri =~ /\/$/; # make sure it ends with /
+            my $new_uri  = $uri . "index.bml";
+            my $bml_file = "$ENV{FBHOME}/htdocs/" . $uri . "index.bml";
+            LJ::Request->uri($new_uri);
+            LJ::Request->handler("perl-script");
+            LJ::Request->push_handlers(PerlHandler => \&Apache::BML::handler);
+            LJ::Request->filename($bml_file);
+            return LJ::Request::OK;
+        }
+    }
+
     return LJ::Request::DECLINED;
 }
 
@@ -352,6 +371,9 @@
 use strict;
 use vars qw($AUTOLOAD);
 
+# pretend we can do everything; AUTOLOAD will handle that
+sub can { 1 }
+
 sub AUTOLOAD {
     my $method = $AUTOLOAD;
     $method =~ s/^.*:://;

Modified: trunk/lib/startup.pl
===================================================================
--- trunk/lib/startup.pl	2010-03-03 05:56:36 UTC (rev 1404)
+++ trunk/lib/startup.pl	2010-03-03 11:24:35 UTC (rev 1405)
@@ -2,9 +2,10 @@
 #
 
 use strict;
+use lib "$ENV{'LJHOME'}/cgi-bin";
 use lib "$ENV{'FBHOME'}/lib";
 use lib "$ENV{'FBHOME'}/src/s2";
-use Apache;
+use LJ::Request;
 use Apache::FotoBilder;
 use Image::Magick;
 use S2::Compiler;
@@ -14,12 +15,11 @@
 require "$ENV{'FBHOME'}/lib/lang.pl";
 
 # setup httpd.conf things for the user:
-Apache->httpd_conf("DocumentRoot $FB::HOME/htdocs");
-Apache->httpd_conf("ServerAdmin $FB::ADMIN_EMAIL")
+LJ::Request->add_httpd_conf("DocumentRoot $FB::HOME/htdocs");
+LJ::Request->add_httpd_conf("ServerAdmin $FB::ADMIN_EMAIL")
     if $FB::ADMIN_EMAIL;
 
-Apache->httpd_conf(qq{
-AddDefaultCharset utf-8
+LJ::Request->add_httpd_conf(qq{
 PerlInitHandler +Apache::FotoBilder
 DirectoryIndex index.html index.bml
 
@@ -29,6 +29,6 @@
   PerlHandler +Apache::BML
 </FilesMatch>
 
-});
+}) if 0;
 
 1;

Tags: andy, fotobilder, pl, pm
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