<%args>
$id=>undef
$reqkey=>undef
</%args>
<%init>
return undef unless $id;
my $dbh = $m->comp("/_shared/procs/utils/dbi_connect.m", database=>'guianet');

my $alfa1 = chr(97 + int(rand(26)));
my $alfa2 = chr(97 + int(rand(26)));
my $num = sprintf("%0.2d",int(rand(999999)));
my $filename = $alfa1 . $alfa2 . $num;

my ($count) = $dbh->selectrow_array("select count(*) from tdownloads where filename='$filename'");
$filename = $m->comp("newfilename.m", id=>$id, reqkey=>$reqkey) if ($count);

$dbh->do("update tdownloads set filename='$filename',lastrequest=NOW() where id=$id");

return undef if $dbh->err;
return $filename;
</%init>

	
