Verification de la taille du fichier récupéré
This commit is contained in:
parent
dc85785668
commit
43e141629d
@ -79,10 +79,15 @@ $date = time() - (24 * 3600 * $nbdays);
|
|||||||
$file = "daily_report_".strftime("%Y%m%d", $date).".zip";
|
$file = "daily_report_".strftime("%Y%m%d", $date).".zip";
|
||||||
|
|
||||||
$remote_file = 'cdr/'.$file;
|
$remote_file = 'cdr/'.$file;
|
||||||
|
|
||||||
|
$remote_size = ftp_size($conn_id, $remote_file);
|
||||||
|
if ($verbose)
|
||||||
|
echo "Récupération de ".$remote_size." Ko\n";
|
||||||
|
|
||||||
$local_file = DOL_DATA_ROOT.'/telephonie/CDR/temp/'.$file;
|
$local_file = DOL_DATA_ROOT.'/telephonie/CDR/temp/'.$file;
|
||||||
$handle = fopen($local_file, 'w');
|
$handle = fopen($local_file, 'w');
|
||||||
|
|
||||||
if (ftp_fget($conn_id, $handle, $remote_file, FTP_ASCII, 0))
|
if (ftp_fget($conn_id, $handle, $remote_file, FTP_BINARY, 0))
|
||||||
{
|
{
|
||||||
if ($verbose)
|
if ($verbose)
|
||||||
echo "Le chargement a réussi dans ".$local_file."\n";
|
echo "Le chargement a réussi dans ".$local_file."\n";
|
||||||
@ -95,46 +100,57 @@ else
|
|||||||
// Fermeture du flux FTP
|
// Fermeture du flux FTP
|
||||||
ftp_close($conn_id);
|
ftp_close($conn_id);
|
||||||
|
|
||||||
// Dezippage du fichier
|
$local_size = filesize($local_file);
|
||||||
|
|
||||||
$zip = zip_open($local_file);
|
if (file_exists($local_file) && $local_size === $remote_size && $local_size > 0)
|
||||||
|
{
|
||||||
if ($zip) {
|
// Dezippage du fichier
|
||||||
|
$zip = zip_open($local_file);
|
||||||
while ($zip_entry = zip_read($zip))
|
|
||||||
{
|
if ($zip) {
|
||||||
if ($verbose)
|
|
||||||
{
|
while ($zip_entry = zip_read($zip))
|
||||||
echo "Nom du fichier : " . zip_entry_name($zip_entry) . "\n";
|
{
|
||||||
echo "Taille réelle : " . zip_entry_filesize($zip_entry) . "\n";
|
if ($verbose)
|
||||||
echo "Taille compressée : " . zip_entry_compressedsize($zip_entry) . "\n";
|
{
|
||||||
echo "Méthode : " . zip_entry_compressionmethod($zip_entry) . "\n";
|
echo "Nom du fichier : " . zip_entry_name($zip_entry) . "\n";
|
||||||
}
|
echo "Taille réelle : " . zip_entry_filesize($zip_entry) . "\n";
|
||||||
|
echo "Taille compressée : " . zip_entry_compressedsize($zip_entry) . "\n";
|
||||||
if (zip_entry_open($zip, $zip_entry, "r"))
|
echo "Méthode : " . zip_entry_compressionmethod($zip_entry) . "\n";
|
||||||
{
|
}
|
||||||
if ($verbose)
|
|
||||||
echo "Decompression dans ".DOL_DATA_ROOT.'/telephonie/CDR/atraiter/'.zip_entry_name($zip_entry)."\n";
|
if (zip_entry_open($zip, $zip_entry, "r"))
|
||||||
|
{
|
||||||
$fp = fopen(DOL_DATA_ROOT.'/telephonie/CDR/atraiter/'.zip_entry_name($zip_entry),"w");
|
if ($verbose)
|
||||||
|
echo "Decompression dans ".DOL_DATA_ROOT.'/telephonie/CDR/atraiter/'.zip_entry_name($zip_entry)."\n";
|
||||||
if ($fp)
|
|
||||||
{
|
$fp = fopen(DOL_DATA_ROOT.'/telephonie/CDR/atraiter/'.zip_entry_name($zip_entry),"w");
|
||||||
$buf = zip_entry_read($zip_entry, zip_entry_filesize($zip_entry));
|
|
||||||
|
if ($fp)
|
||||||
if (fwrite($fp, $buf) === FALSE)
|
{
|
||||||
{
|
$buf = zip_entry_read($zip_entry, zip_entry_filesize($zip_entry));
|
||||||
echo "Erreur d'ecriture\n";
|
|
||||||
}
|
if (fwrite($fp, $buf) === FALSE)
|
||||||
fclose($fp);
|
{
|
||||||
}
|
echo "Erreur d'ecriture\n";
|
||||||
zip_entry_close($zip_entry);
|
}
|
||||||
}
|
fclose($fp);
|
||||||
}
|
}
|
||||||
zip_close($zip);
|
zip_entry_close($zip_entry);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
zip_close($zip);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Archivage du fichier
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
print "Erreur de récupération du fichier ".$local_file."\n";
|
||||||
|
print "Remote size ".$remote_size."\n";
|
||||||
|
print "Local size ".$local_size."\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
// Archivage du fichier
|
|
||||||
|
|
||||||
if (!file_exists(DOL_DATA_ROOT.'/telephonie/CDR/archive/'))
|
if (!file_exists(DOL_DATA_ROOT.'/telephonie/CDR/archive/'))
|
||||||
{
|
{
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user