Apache-AxKit-Plugin-Upload
view release on metacpan or search on metacpan
lib/Apache/AxKit/Plugin/Upload.pm view on Meta::CPAN
sub is_running {
my ($r,$upload_id) = @_;
return 0 if ($running eq $upload_id);
my $destdir = $r->dir_config('AxUploadStatusDir') || return 0;
$destdir = $r->document_root.'/'.$destdir if substr($destdir,0,1) ne '/';
my $format = lc($r->dir_config('AxUploadFormat')) || 'html';
$file = $destdir."/".$upload_id.".".$format;
local (*FH);
sysopen(FH,$file.".lck",O_RDWR) || return undef;
my $unlocked = flock(FH,LOCK_EX|LOCK_NB);
close(FH);
return !$unlocked;
}
sub upload_handler_html {
my ($upload, $buf, $len, $hook_data) = @_;
my ($sizedone, $lasttime) = @$hook_data;
my $now = time();
$sizedone += $len;
$$hook_data[0] = $sizedone;
lib/Apache/AxKit/Plugin/Upload.pm view on Meta::CPAN
$destdir = $r->document_root.'/'.$destdir if substr($destdir,0,1) ne '/';
my $destloc = $r->dir_config('AxUploadStatusLocation') || return OK;
my $format = lc($r->dir_config('AxUploadFormat')) || 'html';
$custom = $r->dir_config('AxUploadCustom');
$file = "$destdir/$upload_id.$format";
$location = "$destloc/$upload_id.$format";
return OK unless $upload_id;
return OK unless $r->method eq 'POST';
$lock = new IO::Handle;
sysopen($lock,$file.".lck",O_RDWR|O_CREAT) || return OK;
my $unlocked = flock($lock,LOCK_EX|LOCK_NB);
return OK if !$unlocked;
$running = $upload_id;
# from Apache::RequestNotes
my $maxsize = $r->dir_config('MaxPostSize') || 1024;
my $uploads = $r->dir_config('DisableUploads') =~ m/Off/i ? 0 : 1;
$nf = new Number::Format(split(/ /,$r->dir_config('AxUploadNumberFormat')));
$sizetotal = $r->header_in('Content-Length');
$start = time();
( run in 0.491 second using v1.01-cache-2.11-cpan-49f99fa48dc )