File "files.php"

Full Path: /home/analogde/www/Bookmarks/CHESS_ON/files.php
File size: 1.24 KB
MIME-type: text/x-php
Charset: utf-8

<?php

	// Returns array of files
	
	$directory = '/homez.65/analogde/www/CHESS_2022/backup';
	
	$files1 = scandir($directory);
  
	// Count number of files and store them to variable
	$num_files = count($files1) - 2;
 
	echo $num_files . " files";
	
	//chdir($directory);
	
	
	echo "qas";
	echo "<br><br><br>";
	
	echo "Time ... " .time();
	
	//if( $num_files == 2)
	//{
		
		$days = 2;	
		
		if ($handle = opendir($directory)) 
		{
			while (false !== ($file = readdir($handle))) 
			{
				$pos = strpos( $file, '.' );
				if ($file != "." && $file != ".." && is_numeric($pos)  )
				{
					$filelastmodified = filemtime($directory ."/" .$file);
					
					//if(is_file($filelastmodified)) 
					//{
						echo " === " .$filelastmodified ." " .$file;
						echo "<br><br><br>";
						
						if((time() - $filelastmodified) > $days*24*3600)
						{
							if(is_file($path . $file))
							{
							//	unlink($path . $file);
								echo  "efface " .$filelastmodified;
								echo "<br><br><br>";
							}
							
						}
						else
						{
								echo  "trop resent " .$filelastmodified;
								echo "<br><br><br>";
						}		
					//}	
					
				}	
			}
	
			closedir($handle);
		}
		
	//}
	

?>