61 lines
1.2 KiB
PHP
61 lines
1.2 KiB
PHP
<?php
|
|
require_once __DIR__ . '/../application/bin.bootstrap.php';
|
|
|
|
error_reporting(E_ALL & ~E_NOTICE);
|
|
|
|
$typesFichier = array('csv', 'fichiers', 'clients', 'kbis');
|
|
|
|
// --- Options
|
|
$displayUsage = false;
|
|
try {
|
|
$opts = new Zend_Console_Getopt(array(
|
|
'help|?' => 'Displays usage information.',
|
|
'all' => 'Execute toutes les actions (cron).',
|
|
'type=w' => 'Supprime uniquement les fichiers indiqués.',
|
|
));
|
|
$opts->parse();
|
|
$optionsNb = count($opts->getOptions());
|
|
} catch (Zend_Console_Getopt_Exception $e) {
|
|
$displayUsage = true;
|
|
}
|
|
|
|
// --- Aide / Options
|
|
if ($optionsNb == 0 || isset($opts->help)) {
|
|
$displayUsage = true;
|
|
}
|
|
|
|
// --- Usage
|
|
if ($displayUsage) {
|
|
echo $opts->getUsageMessage();
|
|
?>
|
|
|
|
Types de fichier disponibles : <?php echo join(', ', $typesFichier)?>
|
|
|
|
<?php
|
|
exit;
|
|
}
|
|
|
|
if ($opts->all || $opts->type)
|
|
{
|
|
foreach ($typesFichier as $dir)
|
|
{
|
|
if ($opts->all || $opts->type==$dir ){
|
|
removeFileInDir(LOG_PATH.'/'.$dir);
|
|
}
|
|
}
|
|
}
|
|
|
|
function removeFileInDir($dir)
|
|
{
|
|
if (is_dir($dir)) {
|
|
if ($dh = opendir($dir)) {
|
|
while (($file = readdir($dh)) !== false) {
|
|
unlink($dir . $file);
|
|
}
|
|
closedir($dh);
|
|
}
|
|
}
|
|
}
|
|
|
|
|