use File::Spec;
use File::Path qw/ make_path /;
-my $root_dir = '/mnt/Shared/Personal/My art';
-my $link_dir = '/var/www/html/public';
-my $http_uri = 'http://136.63.171.222/public';
+my $root_dir = $ENV{PUBLIC_ROOT_DIR}
+ or die "Need PUBLIC_ROOT_DIR\n";
+my $link_dir = $ENV{PUBLIC_LINK_DIR}
+ or die "Need PUBLIC_LINK_DIR\n";
+my $http_uri = $ENV{PUBLIC_HTTP_URI}
+ or die "Need PUBLIC_HTTP_URI\n";
sub nonce {
my $n = shift;
- $n = 10 unless $n;
+ $n = 10 unless $n > 0;
my @chars = ( 'a' .. 'z', 'A' .. 'Z', '0' .. '9' );
my @path = ();
- push @path, $chars[ rand @chars ] for 1 .. 10;
+ push @path, $chars[ rand @chars ] for 1 .. $n;
return join '', @path;
}
my $name = shift
or die "Need filename!\n";
- opendir DIR, $root_dir;
+ opendir DIR, $root_dir
+ or die $!;
my @files = grep /$name/i, readdir(DIR);
closedir DIR;
die "No match: $name\n" unless @files;
# create nonce dir and add symbolic links
- my $nonce = nonce();
+ my $nonce = nonce(20);
my $nonce_dir = makeNonceDir($nonce);
for my $file (@files) {