';
echo '
';
}
?>
1024)
{
$size = round($size / 1024 , 2);
$retour = $size ." Koctets";
if($size > 1024)
{
$size = round($size / 1024 , 2);
$retour = $size ." Moctets";
}
}
else
{
$retour = $size ." octets";
}
return $retour;
}
function listing_fichier_repertoire($repertoire)
{
$results = array();
$handler = opendir($repertoire);
$cpt = 0;
$ts_actuel = strtotime(date("d-m-Y H:i:s"));
//sauvegarde_edition-13-09-2015-10_06_57.txt
while ($file = readdir($handler))
{
if($file != "." && $file != ".." )
{
$file_name = explode(".",$file);
$date_pieces = explode("-",$file_name[0]);
$jour = $date_pieces[1];
$mois = $date_pieces[2];
$annee = $date_pieces[3];
$heure_tab = explode("_",$date_pieces[4]);
//echo "
";
//print_r($date_pieces);
$timestamp = mktime ($heure_tab[0], $heure_tab[1], $heure_tab[2], $mois, $jour, $annee);
$ts_difference = $ts_actuel - $timestamp;
$ts_7jours = 7 * 24 * 3600;
if($ts_difference >= $ts_7jours)
{
//echo $file ." ---- " .$format ." " .$ts ." trop ancien" ;
//chdir("sauvegarde_echec");
//unlink($file);
$coco = 5;
}
$results[$cpt][0] = $file;
$results[$cpt][1]= $timestamp;
$results[$cpt][2]= filesize($file);
$cpt = $cpt + 1;
}
}
chdir("backup");
closedir($handler);
return $results;
}
function sauvegarde_DB()
{
//$fichier = '/homez.65/analogde/www/Massage/Backup/manuel_db-backup-'.$infos.'.sql';
//system("mysqldump --host=analogdepat.mysql.db --user=analogdepat --password=Un92pac007 --default-character-set=utf8 analogdepat configuration client gestion reservation2015 > $fichier");
$jour = date('d-m-Y');
$heure = date("H_i_s");
$infos = $jour.'-'.$heure;
$filename = "sauvegarde_manuelle-" .$infos .".txt"; // "test.csv";
DB_to_file($filename);
echo "Backup Done";
echo '
';
echo '
';
}
/////////////////////////////
$chemin = getcwd();
echo '
';
$tab = listing_fichier_repertoire('backup');
//echo '';
//print_r($tab);
//chdir($chemin);
for($i=0; $i < count($tab); $i++)
{
$tab_fichier = $tab[$i][0];
$tab_ts[] = $tab[$i][1];
}
$tab_sort = $tab_ts;
sort($tab_sort);
$tab_reverse = array_reverse($tab_sort);
//echo '';
//print_r($tab_sort);
for($i=0; $i < count($tab); $i++)
{
$element = $tab_reverse[$i];
$position = array_search($element, $tab_ts);
//echo '
';
$file = $tab[$position][0];
//echo $position ." " .$tab[$position][0] ." " .filesize($file);
$tab_affiche[$i][0] = $tab[$position][0];
$tab_affiche[$i][1] = filesize($file);
}
echo 'retour ...
';
echo '';
$taille = dirsize('.');
$nb_fichiers = count($tab_affiche);
echo "$nb_fichiers fichier(s) pour un espace occupé de : " .$taille ;
echo '| Id | Fichier backup | Taille en octets | |
|---|---|---|---|
| " .$j ." | "; //echo ''; //echo '' .$tab_affiche[$i][0] .' | '; echo ''; echo $tab_affiche[$i][0]; echo ' | '; echo "" .$tab_affiche[$i][1] ." | "; echo '