sub get_fname($self, $ua) {
my $dbh = $self->{server}->{modules}->{$self->{db}};
my $filename = $ua->{postparams}->{'fname'} || '';
$filename = $self->clean_fname($filename);
my %data = (
fname => $filename,
status => 'OK',
statustext => 'OK',
description => '',
);
# Check for existing filename
my $selsth = $dbh->prepare_cached("SELECT *
FROM " . $self->{tablename} . "
WHERE filename = ?
LIMIT 1")
or croak($dbh->errstr);
$selsth->execute($filename) or croak($dbh->errstr);
my $existcount = 0;
while((my $line = $selsth->fetchrow_hashref)) {
$existcount++;
$data{description} = $line->{description};
}
if($existcount) {
$data{status} = 'WARNING';
$data{statustext} = "File exists, will overwrite!
This may lead to caching problems for the next few hours!";
}
my $jsondata = encode_json \%data;
return (status => 200,
type => "text/plain",
data => $jsondata);
}