ASP4
view release on metacpan or search on metacpan
inc/Module/Install.pm view on Meta::CPAN
# If the script that is loading Module::Install is from the future,
# then make will detect this and cause it to re-run over and over
# again. This is bad. Rather than taking action to touch it (which
# is unreliable on some platforms and requires write permissions)
# for now we should catch this and refuse to run.
if ( -f $0 and (stat($0))[9] > time ) { die <<"END_DIE" }
Your installer $0 has a modification time in the future.
This is known to create infinite loops in make.
Please correct this, then run $0 again.
END_DIE
lib/ASP4/ConfigLoader.pm view on Meta::CPAN
our $Configs = { };
#==============================================================================
sub load
{
my ($s) = @_;
my $path = ASP4::ConfigFinder->config_path;
my $file_time = (stat($path))[7];
if( exists($Configs->{$path}) && ( $file_time <= $Configs->{$path}->{timestamp} ) )
{
return $Configs->{$path}->{data};
}# end if()
open my $ifh, '<', $path
or die "Cannot open '$path' for reading: $!";
local $/;
my $doc = decode_json( scalar(<$ifh>) );
close($ifh);
lib/ASP4/FileUpload.pm view on Meta::CPAN
foreach(qw( ContentType FileHandle FileName ))
{
confess "Required param '$_' was not provided"
unless $args{$_};
}# end foreach()
$args{UploadedFileName} = $args{FileName};
($args{FileName}) = $args{FileName} =~ m{[/\\]?([^/\\]+)$};
($args{FileExtension}) = $args{FileName} =~ m/([^\.]+)$/;
$args{FileSize} = (stat($args{FileHandle}))[7];
return bless \%args, $class;
}# end new()
# Public readonly properties:
sub ContentType { shift->{ContentType} }
sub FileName { shift->{FileName} }
sub UploadedFileName { shift->{UploadedFileName} }
sub FileExtension { shift->{FileExtension} }
lib/ASP4/FileUpload.pm view on Meta::CPAN
if( my $file = $Request->FileUpload('fieldname') ) {
# Save the file:
$file->SaveAs('/var/media/uploads/budget.csv');
# Some info about it:
warn $file->UploadedFileName; # C:\Users\billg\budget.csv
warn $file->FileName; # budget.csv
warn $file->FileExtension; # csv
warn $file->FileSize; # 273478 (Calculated via (stat(FH))[7] )
warn $file->ContentType; # text/csv
warn $file->FileContents; # (The contents of the file)
my $ifh = $file->FileHandle; # A normal, plain old filehandle
}
}
=head1 DESCRIPTION
This class provides a simple interface to uploaded files in ASP4.
lib/ASP4/HandlerResolver.pm view on Meta::CPAN
if( $uri =~ m/^\/handlers\// )
{
(my $handler = $uri) =~ s/^\/handlers\///;
$handler =~ s/[^a-z0-9_]/::/gi;
(my $path = "$handler.pm") =~ s/::/\//g;
my $filepath = $s->context->config->web->handler_root . "/$path";
(my $inc_entry = "$handler.pm") =~ s/::/\//g;
return unless -f $filepath;
if( stat($filepath)->mtime > ($FileTimes{ "$ENV{DOCUMENT_ROOT}:$filepath" } || 0) )
{
$FileTimes{ "$ENV{DOCUMENT_ROOT}:$filepath" } = stat($filepath)->mtime;
$s->_forget_package(
$inc_entry, $handler
);
delete( $HandlerCache{"$ENV{DOCUMENT_ROOT}:$uri"} );
}# end if()
}
else
{
my $info = ASP4::PageLoader->discover( script_name => $uri );
return if $info->{is_static};
return unless -f $info->{saved_to};
$FileTimes{ "$ENV{DOCUMENT_ROOT}:$info->{filename}" } ||= 0;
if( stat($info->{filename})->mtime > $FileTimes{ "$ENV{DOCUMENT_ROOT}:$info->{filename}" } )
{
$FileTimes{ "$ENV{DOCUMENT_ROOT}:$info->{filename}" } = stat($info->{filename})->mtime;
$s->_forget_package(
$info->{compiled_as}, $info->{package}
);
delete( $HandlerCache{"$ENV{DOCUMENT_ROOT}:$uri"} );
}# end if()
}# end if()
}# end check_reload()
sub _forget_package
lib/ASP4/PageLoader.pm view on Meta::CPAN
sub load
{
my ($class, %args) = @_;
my $info = $class->discover( script_name => $args{script_name} );
my $key = ($ENV{DOCUMENT_ROOT}||"") . ":$info->{filename}";
if( $class->needs_recompile( $info->{saved_to}, $info->{filename} ) )
{
my $page = ASP4::PageParser->new( script_name => $info->{script_name} )->parse();
$FileTimes{ $key } = stat($info->{filename})->mtime;
return $page;
}# end if()
my $config = ASP4::ConfigLoader->load();
# Deal with changes all the way up the master/child chain:
ASP4::HandlerResolver->_forget_package( $info->{compiled_as}, $info->{package} );
$config->load_class( $info->{package} );
$FileTimes{ $key } ||= stat($info->{filename})->mtime;
return $info->{package}->new();
}# end load()
sub needs_recompile
{
my ($class, $compiled_as, $filename) = @_;
return 1 unless $compiled_as && -f $compiled_as;
my $key = ($ENV{DOCUMENT_ROOT}||"") . ":$filename";
return stat($filename)->mtime > ( $FileTimes{ $key } || stat($compiled_as)->mtime );
}# end needs_recompile()
1;# return true:
lib/ASP4/StaticHandler.pm view on Meta::CPAN
unless( $file && -f $file )
{
$Response->Status( 404 );
$Response->End;
return 404;
}# end unless()
open my $ifh, '<', $file
or die "Cannot open '$file' for reading: $!";
local $/;
$Response->SetHeader('content-length' => (stat($file))[7] );
my ($ext) = $file =~ m{\.([^\.]+)$};
my %types = (
swf => 'application/x-shockwave-flash',
xml => 'text/xml',
jpg => 'image/jpeg',
jpeg => 'image/jpeg',
png => 'image/png',
bmp => 'image/bmp',
gif => 'image/gif',
sbin/asp4-deploy view on Meta::CPAN
else
{
`tar -zxvf "$src" && ln -s "$id" latest`;
my @to_update = ( );
my @files = qw( asp4-config.json httpd.conf );
foreach( grep { $_ !~ m{latest/common$} } <latest/*> )
{
my ($folder) = $_ =~ m{latest/([^/]+)};
foreach my $file ( @files )
{
if( (stat("latest/$folder/conf/$file.template"))[7] )
{
`cp latest/$folder/conf/$file.template latest/$folder/conf/$file`;
push @to_update, "latest/$folder/conf/$file";
}# end if()
}# end foreach()
}# end foreach()
warn "\n\n***You must update the following configuration files:***\n";
warn join( "\n", map {"\t* $_"} @to_update), "\n\n";
}# end if()
( run in 0.590 second using v1.01-cache-2.11-cpan-49f99fa48dc )