X-Git-Url: http://git.purplebirdman.com/public.git/blobdiff_plain/d6bdcd5ebdddfccaf412b260966d791247c52580..6d340888f9a823aed2a04174e4a6a454446186ae:/public diff --git a/public b/public index 8c6f828..2dd2481 100755 --- a/public +++ b/public @@ -5,18 +5,21 @@ use warnings; 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; } @@ -33,7 +36,8 @@ sub addFiles { 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; @@ -41,7 +45,7 @@ sub addFiles { 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) {