Use last commit date instead of unix mtime #6
| @ -1,5 +1,13 @@ | ||||
| <?php | ||||
|   $last_rev = exec('git log -1 --pretty=format:"%H" '.$this_file); | ||||
|   $mtime = exec('LANG="fr_FR.UTF-8" git log -1 --pretty="format:%cr" '.$this_file); | ||||
|   $mtime = exec('LANG="fr_FR.UTF-8" git log -1 --pretty="format:%ct" '.$this_file); | ||||
|   $fmt = datefmt_create( | ||||
|     'fr-FR', | ||||
|     IntlDateFormatter::FULL, | ||||
|     IntlDateFormatter::FULL, | ||||
|     'Europe/Paris', | ||||
|     IntlDateFormatter::GREGORIAN, | ||||
|     'd MMMM Y à HH:mm:ss O' | ||||
|   ); | ||||
| ?>
 | ||||
| <p style="text-align:right;">Dernière mise à jour <a href="https://git.gnous.fr/gnous/main_website/commit/<?php echo $last_rev;?>" target="_blank"><?php echo $mtime; ?></a></p>
 | ||||
| <p style="text-align:right;">Mis à jour le <a href="https://git.gnous.fr/gnous/main_website/commit/<?php echo $last_rev;?>" target="_blank"><?php echo datefmt_format($fmt, $mtime); ?></a></p>
 | ||||
|  | ||||
| @ -1,13 +1,10 @@ | ||||
| <?php | ||||
|   $this_file = basename($_SERVER["SCRIPT_FILENAME"]); //contient le nom de ce fichier (lui-même)
 | ||||
|   setlocale (LC_TIME, 'fr_FR.utf8','fra'); | ||||
| 
 | ||||
|   /* | ||||
|   Petit script pour afficher la dernière date de modification (toute page confondue) sur la page d'accueil (index.php) | ||||
|   */ | ||||
|   date_default_timezone_set('Europe/Paris'); | ||||
|   $mtime_this_file = exec('git log -1 --pretty="format:%ct" '.$this_file); //récupération de la date de modification de ce fichier
 | ||||
|   $mtime_max = $mtime_this_file;  //elle est instituée comme un maximum
 | ||||
|   $mtime_max = exec('git log -1 --pretty="format:%ct" '.$this_file); //récupération de la date de modification de ce fichier et institution comme maximum
 | ||||
|   $last_rev = exec('git log -1 --pretty=format:"%H" '.$this_file); //récupération du hash du commit associé
 | ||||
| 
 | ||||
|   foreach (glob("*.php") as $filename) {  //récupération de la liste de tous les fichiers .php du répertoire courant (les pages en somme)
 | ||||
| @ -17,7 +14,15 @@ | ||||
|       $last_rev = exec('git log -1 --pretty=format:"%H" '.$filename); //récupération du hash du commit associé
 | ||||
|     } | ||||
|   } | ||||
|   $mtime_max = date("d M Y H:i:s", $mtime_max);	//formatage de la date retenue
 | ||||
|   $fmt = datefmt_create( | ||||
|     'fr-FR', | ||||
|     IntlDateFormatter::FULL, | ||||
|     IntlDateFormatter::FULL, | ||||
|     'Europe/Paris', | ||||
|     IntlDateFormatter::GREGORIAN, | ||||
|     'd MMMM Y à HH:mm:ss O' | ||||
|   ); | ||||
| 
 | ||||
| ?>
 | ||||
| 
 | ||||
| <!DOCTYPE HTML> | ||||
| @ -31,7 +36,7 @@ | ||||
| 		<?php include 'includes/titre.php'; ?>
 | ||||
| 		<br> | ||||
| 		<?php include 'includes/menu.php'; ?>
 | ||||
|         <p style="text-align:right;">Dernière mise à jour du site le <?php echo strftime("%d %B %Y à %H:%M:%S UTC%z", strtotime($mtime_max)); ?><br>git revision: <a href="https://git.gnous.fr/gnous/main_website/commit/<?php echo $last_rev;?>" target="_blank"><?php echo substr($last_rev, 0, 7);?></a></p>
 | ||||
|         <p style="text-align:right;">Dernière mise à jour du site le <?php echo datefmt_format($fmt, $mtime_max); ?><br>git revision: <a href="https://git.gnous.fr/gnous/main_website/commit/<?php echo $last_rev;?>" target="_blank"><?php echo substr($last_rev, 0, 7);?></a></p>
 | ||||
| 
 | ||||
| 		<div style="width:40%;"> | ||||
| 		<p style="text-align: right;"> | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user