diff options
Diffstat (limited to 'bin/install_fullcalendar.php')
| -rw-r--r-- | bin/install_fullcalendar.php | 42 |
1 files changed, 40 insertions, 2 deletions
diff --git a/bin/install_fullcalendar.php b/bin/install_fullcalendar.php index aafce77..1a2839e 100644 --- a/bin/install_fullcalendar.php +++ b/bin/install_fullcalendar.php | |||
| @@ -1,5 +1,6 @@ | |||
| 1 | <?php | 1 | <?php |
| 2 | // bin/install_fullcalendar.php | 2 | // bin/install_fullcalendar.php |
| 3 | |||
| 3 | function installFullCalendar(): void | 4 | function installFullCalendar(): void |
| 4 | { | 5 | { |
| 5 | $path = 'public/js/fullcalendar'; | 6 | $path = 'public/js/fullcalendar'; |
| @@ -18,7 +19,9 @@ function installFullCalendar(): void | |||
| 18 | if(!is_dir($path)){ | 19 | if(!is_dir($path)){ |
| 19 | mkdir($path, 0755, true); | 20 | mkdir($path, 0755, true); |
| 20 | } | 21 | } |
| 21 | 22 | ||
| 23 | $old_version = getVersion($path . '/' . $key); // peut être null | ||
| 24 | |||
| 22 | $file = @fopen($path . '/' . $key, 'w+'); // @masque l'erreur pour la traiter soi-même | 25 | $file = @fopen($path . '/' . $key, 'w+'); // @masque l'erreur pour la traiter soi-même |
| 23 | if(!$file){ // erreur écriture fichier | 26 | if(!$file){ // erreur écriture fichier |
| 24 | echo "Erreur : Impossible d'ouvrir le fichier $path pour l'écriture.\n"; | 27 | echo "Erreur : Impossible d'ouvrir le fichier $path pour l'écriture.\n"; |
| @@ -36,6 +39,41 @@ function installFullCalendar(): void | |||
| 36 | 39 | ||
| 37 | fclose($file); | 40 | fclose($file); |
| 38 | curl_close($curl); | 41 | curl_close($curl); |
| 39 | } | 42 | |
| 43 | $new_version = getVersion($path . '/' . $key); | ||
| 44 | |||
| 45 | if(!$old_version){ | ||
| 46 | echo $key . " installé " . $new_version . "\n"; | ||
| 47 | } | ||
| 48 | elseif($old_version === $new_version){ | ||
| 49 | echo $key . " réinstallé " . $new_version . "\n"; | ||
| 50 | } | ||
| 51 | else{ | ||
| 52 | echo $key . " mis à jour de " . $old_version . " vers " . $new_version . "\n"; | ||
| 53 | } | ||
| 54 | } | ||
| 40 | } | 55 | } |
| 56 | |||
| 57 | function getVersion(string $path): ?string | ||
| 58 | { | ||
| 59 | if(!is_file($path)){ | ||
| 60 | return null; | ||
| 61 | } | ||
| 62 | |||
| 63 | $file = fopen($path, 'r'); | ||
| 64 | if(!$file){ | ||
| 65 | return null; | ||
| 66 | } | ||
| 67 | |||
| 68 | for($i = 0; $i < 5 && ($line = fgets($file)) !== false; $i++){ | ||
| 69 | if(preg_match('/FullCalendar .*? (v[0-9.]+)/', $line, $matches)){ | ||
| 70 | fclose($file); | ||
| 71 | return $matches[1]; | ||
| 72 | } | ||
| 73 | } | ||
| 74 | |||
| 75 | fclose($file); | ||
| 76 | return null; | ||
| 77 | } | ||
| 78 | |||
| 41 | installFullCalendar(); | 79 | installFullCalendar(); |
