12)) { unset($dateTimeOriginal); } if (isset($dateTimeOriginal) && is_array($dateTimeOriginal) && ($dateTimeOriginal['d'] < 01 || $dateTimeOriginal['d'] >31)) { unset($dateTimeOriginal); } if (isset($dateTimeOriginal) && is_array($dateTimeOriginal) && ($dateTimeOriginal['y'] < 1900 || $dateTimeOriginal['d'] >2021)) { unset($dateTimeOriginal); } } // Récupération de la date de modification if ($traitement_ok && !isset($dateTimeOriginal)) { $dateTimeOriginal_explode = explode(":", date("Y:m:d", filemtime($entry))); if (isset($dateTimeOriginal_explode)) { $dateTimeOriginal['y'] = $dateTimeOriginal_explode[0]; $dateTimeOriginal['m'] = $dateTimeOriginal_explode[1]; $dateTimeOriginal['d'] = $dateTimeOriginal_explode[2]; } } // Création des dossiers et déplacement du fichier if ($traitement_ok && isset($dateTimeOriginal) && is_array($dateTimeOriginal)) { $rep_dest = $dateTimeOriginal['y'] ."/". $dateTimeOriginal['m'] ."/". $dateTimeOriginal['d']; if (!file_exists($rep_dest)) { if (!mkdir($rep_dest, 0777, true)) { die('Echec lors de la création des répertoires...'); } } $file_dest = $rep_dest."/".$entry; if (!file_exists($file_dest)) { rename($entry, $file_dest); $message .= " => ".$file_dest."\n"; } else { $md5_file_src = md5_file($entry); $md5_file_dst = md5_file($file_dest); if ($md5_file_src == $md5_file_dst) { $message .= " [ERREUR] ".$file_dest." existe déjà ! Destruction car même empreinte $md5_file_src / $md5_file_dst\n"; unlink($entry); } else { $message .= " [ERREUR] ".$file_dest." existe déjà !\n"; } } fwrite($file_log_out, $message); echo $message; } } } closedir($handle); fclose($file_log_out); }