codice:
try
{
$conn = new PDO(DB_DSN,DB_USER,DB_PASSWORD);
}
catch (PDOException $e)
{
echo "Fallimento per l'handle " . $e->getMessage() . "\n";
exit;
}
try
{
$statement = $conn->prepare("INSERT INTO qualcosa
(id,tipo,estensione,path,nome,sizevera,data,ora,size,datafile,orafile,idwan,hash,idlink,chiave)
VALUES
(:id,:tipo,:estensione,:path,:nome,:sizevera,now(),now(),:size,:datafile,:orafile,:idwan,:hash,:idlink,conv(left(sha1(uuid()),13),16,10))");
}
catch (PDOException $e)
{
exit;
}
$tipo='BOOOOH';
$estensione=strtoupper(pathinfo($targetFile, PATHINFO_EXTENSION));
$path=$targetFile;
$path=pathinfo($targetFile, PATHINFO_DIRNAME);
$path=str_replace('/','\\',$path);
$path=$path.'\\';
$nome=pathinfo($targetFile, PATHINFO_BASENAME);
$sizevera=filesize($targetFile);
$size=$sizevera / 1000;
@$datafile=date('Y-m-d',filectime($targetFile));
@$orafile=date('H:i:s',filectime($targetFile));
$hash=strtoupper(sha1_file($targetFile));
$idlink=sprintf('BOOOH_%03d_%d', $idwan,$id);
$statement->bindParam(':id', $id);
$statement->bindParam(':tipo', $tipo);
$statement->bindParam(':estensione', $estensione);
$statement->bindParam(':path', $path);
$statement->bindParam(':nome', $nome);
$statement->bindParam(':sizevera', $sizevera);
$statement->bindParam(':size', $size);
$statement->bindParam(':datafile', $datafile);
$statement->bindParam(':orafile', $orafile);
$statement->bindParam(':idwan', $idwan);
$statement->bindParam(':hash', $hash);
$statement->bindParam(':idlink', $idlink);
try
{
$statement->execute();
}
catch (PDOException $e)
{
exit;
}