File "read02.php"

Full Path: /home/analogde/www/DCIM/Auto/CHESS_2022/read02.php
File size: 4.99 KB
MIME-type: text/x-php
Charset: utf-8

<?php

	header( 'content-type: text/html; charset=utf-8' );
	
	error_reporting(0);
	date_default_timezone_set('Europe/Paris');
	
	
	$path = "backup";
	
	$results = array();
	$cpt = 0;

	
	chdir($path);
	array_multisort(array_map('filemtime', ($files = glob("*.*"))), SORT_DESC, $files);
	foreach($files as $filename)
	{
		//echo "<li>".substr($filename, 0, -4)."</li>";
		//echo "<li>" .$filename    ."</li>";
		
		if(is_file($filename))
		{
			$results[$cpt][0] = $filename;
			$results[$cpt][1]= filesize($filename);
			$results[$cpt][2]= filemtime($filename);
			$results[$cpt][3]= date("F d Y H:i:s.", filemtime($filename));
			$cpt = $cpt + 1;
		}
	}
	
	
	//$files = array_diff(scandir($path), array('.', '..'));
	
	//$results = array();
	//$cpt = 0;
	
	//foreach($files as $file) 
	//{
	//	if (!in_array($file,array(".",".."))) 
	//	{ 
	//		$results[$cpt][0] = $file;
	//		$results[$cpt][1]= filesize('backup/'.$file);
	//		$results[$cpt][2]= filemtime('backup/'.$file);
	//		$results[$cpt][3]= date("F d Y H:i:s.", filemtime('backup/'.$file));
	//		$cpt = $cpt + 1;
	//	}
	//}
	
	//echo "<pre>";
	//print_r($results);
	//echo "</pre>";
	
	//$tab = listing_fichier_repertoire('backup'); 
	
	//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);

	//for($i=0; $i < count($tab); $i++)
	//{
	//	$element = $tab_reverse[$i];
	//	$position = array_search($element, $tab_ts);
		//echo '<br><br>';
	//	$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 '<a href="' .$_SERVER['HTTP_REFERER'] .'">retour ...</a> ; 
	
	echo '<a href="admin.php">Retour...</a>';
	
	
	
	
	echo '<br><br>';
	
	echo "<table border=1 cellpadding=5 cellspacing=0>";
	echo "	<tr>
			<th>Id</th>
			<th>Fichier backup</th>
			<th>Date</th>
			<th>Taille en octets</th>
			<th>Voir</th>
			<th>Editer</th>
			<th>Importer</th>
			</tr>";
			
	//for($i=0; $i < count($tab_affiche); $i++)
	for($i=0; $i < $cpt; $i++)
		
	{
			$j = $i + 1;
			echo "<tr>
				  <td>" .$j ."</td>";	
			//echo '<td>';
			//echo '<a href="restauration.php?fichier=" .$tab_affiche[$i][0].</a>' .$tab_affiche[$i][0] .'</td>';
			echo '<td>'; 
				  //<a href="restauration.php?fichier='.$tab_affiche[$i][0].'" title = "Restauration">';
			//echo  $tab_affiche[$i][0];
			echo $results[$i][0];
			
			//echo '</a>
			echo	'</td>';
			
			$b = '<input type="button" value="Voir">';
			
			
			echo "<td align = 'center'>" .$results[$i][3] ."</td>";
			
			
			echo "<td align = 'center'>" .$results[$i][1] ."</td>";
			
			
			$blabla = $tab_affiche[$i][0];
			$blabla = $results[$i][0];

			
			
			echo "<td align = 'center'>"; 
			echo "<button type=\"button\" title=\"Visualiser\" id=\"button_voir\" onclick=\"window.location.href='https://analog-design.net/CHESS_2022/visualise.php?filename=$blabla'\"> Voir </>";
			echo "</td>";
		
			
			echo "<td align = 'center'>"; 
			echo "<button type=\"button\" title=\"Editer\" id=\"button_editer\" onclick=\"window.location.href='https://analog-design.net/CHESS_2022/editer.php?filename=$blabla'\"> Modifier </>";
			echo "</td>";
			
			
			echo "<td align = 'center'>"; 
			echo "<button type=\"button\" title=\"Importer\" id=\"button_importer\" onclick=\"window.location.href='https://analog-design.net/CHESS_2022/importer.php?filename=$blabla'\"> Importer </>";
			echo "</td>";
			
			echo '</td>
			      </tr>';
	}
	echo "</table>";
	
	
	?>
	
	<!--
	 <button onclick="window.location.href = 'https://waytolearnx.com';"> Cliquez ici </button>
    -->
	
<?php	 
	
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 "<pre>";
			//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;
}

?>