99 lines
2.1 KiB
PHP
Executable File
99 lines
2.1 KiB
PHP
Executable File
<?php
|
|
require_once 'Functions.php';
|
|
require_once 'Societeusercentral.php';
|
|
|
|
class Cronnettoyerfihierstemp
|
|
{
|
|
private $societeusercentral;
|
|
|
|
public function __construct()
|
|
{
|
|
// $this->societeusercentral = new Societeusercentral();
|
|
}
|
|
|
|
function suppression($dossier_traite , $age_requis)
|
|
{
|
|
$repertoire = opendir($dossier_traite);
|
|
|
|
while(false !== ($fichier = readdir($repertoire)))
|
|
{
|
|
$chemin = $dossier_traite."/".$fichier;
|
|
|
|
|
|
$infos = pathinfo($chemin);
|
|
|
|
$age_fichier = time() - filemtime($chemin);
|
|
|
|
if($fichier!="." AND $fichier!=".." AND !is_dir($chemin) AND $age_fichier > $age_requis)
|
|
{
|
|
unlink($chemin);
|
|
}
|
|
}
|
|
|
|
closedir($repertoire); // On ferme !
|
|
}
|
|
|
|
function suppressionimport($dossier_traite , $age_requis)
|
|
{
|
|
$repertoire = opendir($dossier_traite);
|
|
|
|
while(false !== ($fichier = readdir($repertoire)))
|
|
{
|
|
$chemin = $dossier_traite."/".$fichier;
|
|
|
|
|
|
$infos = pathinfo($chemin);
|
|
// $extension = $infos['extension'];
|
|
|
|
$age_fichier = time() - filemtime($chemin);
|
|
|
|
if($fichier!="." AND $fichier!=".." AND !is_dir($fichier) AND $age_fichier > $age_requis)
|
|
{
|
|
unlink($chemin);
|
|
}
|
|
}
|
|
|
|
closedir($repertoire); // On ferme !
|
|
}
|
|
|
|
}
|
|
|
|
$nettoyerfihierstemp = new Cronnettoyerfihierstemp();
|
|
$societeusercentral = (new Societeusercentral())->getSocieteuserSaas();
|
|
|
|
/* KANE => maj 14/02/2026
|
|
$nettoyerfihierstemp->suppression( "../Temp" , "3600" );
|
|
$nettoyerfihierstemp->suppression( "../Temp/import" , "432000" );
|
|
*/
|
|
|
|
$tempProduction = $societeusercentral['tempProduction'];
|
|
$tempPrestation = $societeusercentral['tempPrestation'];
|
|
$tempGarant = $societeusercentral['tempGarant'];
|
|
$tempAssure = $societeusercentral['tempAssure'];
|
|
$tempRh = $societeusercentral['tempRh'];
|
|
|
|
/*
|
|
tempProduction,
|
|
tempPrestation,
|
|
tempGarant,
|
|
tempAssure,
|
|
tempRh
|
|
*/
|
|
|
|
var_dump(
|
|
array(
|
|
"tempProduction" => $tempProduction,
|
|
"tempPrestation" =>$tempPrestation,
|
|
"tempGarant" => $tempGarant,
|
|
"tempAssure" => $tempAssure,
|
|
"tempRh" => $tempRh
|
|
)
|
|
);
|
|
exit();
|
|
|
|
// Production
|
|
$nettoyerfihierstemp->suppression($tempProduction."/Temp" , "3600" );
|
|
$nettoyerfihierstemp->suppression($tempProduction."/Temp/import" , "432000" );
|
|
|
|
?>
|