49 lines
1.5 KiB
PHP
49 lines
1.5 KiB
PHP
<?php
|
|
$_SERVER['HTTP_HOST'] = 'www.bebeboutik.com';
|
|
$_SERVER['REMOTE_ADDR'] = '127.0.0.1';
|
|
$_SERVER['SERVER_PORT'] = 80;
|
|
|
|
include dirname(__FILE__).'/www/config/config.inc.php';
|
|
|
|
$filesToImport = scandir(dirname(__FILE__).'/www/adm/import');
|
|
uasort($filesToImport, '_usortFiles');
|
|
$fileTokeep = array();
|
|
foreach ($filesToImport AS $k => &$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;
|
|
} |