Reviewed-on: #5 Reviewed-by: Juan Ferrer <juan@verdnatura.es>
This commit is contained in:
commit
2cc0242b50
|
@ -0,0 +1,10 @@
|
||||||
|
FROM httpd:2.4.61
|
||||||
|
|
||||||
|
RUN apt-get update \
|
||||||
|
&& apt-get install -y libcgi-pm-perl \
|
||||||
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
|
COPY rwmap.pl /usr/local/bin/
|
||||||
|
RUN chmod +x /usr/local/bin/rwmap.pl
|
||||||
|
|
||||||
|
RUN echo "IncludeOptional conf.d/*.conf" >> conf/httpd.conf
|
|
@ -0,0 +1,26 @@
|
||||||
|
#!/usr/bin/perl
|
||||||
|
use strict;
|
||||||
|
use warnings;
|
||||||
|
use Digest::SHA qw(sha1_hex);
|
||||||
|
# Desactiva el buffering de salida para que Apache pueda obtener la respuesta inmediatamente
|
||||||
|
$| = 1;
|
||||||
|
|
||||||
|
while (<STDIN>) {
|
||||||
|
chomp;
|
||||||
|
my $input = $_;
|
||||||
|
$input =~ /^\/image\/(.*)\/([a-z0-9-_]+)\.(png)$/;
|
||||||
|
my $collection = $1;
|
||||||
|
my $name = $2;
|
||||||
|
my $extension = $3;
|
||||||
|
|
||||||
|
my $sha1 = sha1_hex($name);
|
||||||
|
my $first = substr($sha1, 0, 2);
|
||||||
|
my $last = substr($sha1, 1, 2);
|
||||||
|
my $newPath = "images/$collection/$first/$last/$name.$extension";
|
||||||
|
|
||||||
|
if (-e "/usr/local/apache2/htdocs/$newPath") {
|
||||||
|
print "/$newPath\n";
|
||||||
|
} else {
|
||||||
|
print "/$input\n";
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue