&$filename) { //exclude . .. .svn and index.php and all hidden files if (preg_match('/^\..*|index.php/Ui', $filename)) { unset($filesToImport[$k]); } // ANTADIS - evite d'importer plusieurs fois le même fichier if (substr($filename, 0, 3) == 'old') { unset($filesToImport[$k]); } if (isset($filesToImport[$k])) { $date = strrev(substr(strrev($filesToImport[$k]), 0, 14)); $years = substr($date, 0, 4); $month = substr($date, 4, 2); $day = substr($date, 6, 2); $now = new DateTime("now"); $date2 = new DateTime($years.'-'.$month.'-'.$day); $interval = $date2->diff($now); if ((int)$interval->format('%a')<7) { $fileTokeep[] = $filesToImport[$k]; unset($filesToImport[$k]); } } } foreach ($filesToImport AS $k => &$filename) { rename(dirname(__FILE__).'/www/adm/import/'.$filename, dirname(__FILE__).'/www/adm/import/old_'.$filename); } function _usortFiles($a, $b) { $a = strrev(substr(strrev($a), 0, 14)); $b = strrev(substr(strrev($b), 0, 14)); if ($a == $b) return 0; return ($a < $b) ? 1 : -1; }