-
Notifications
You must be signed in to change notification settings - Fork 0
/
carte_manquante.php
148 lines (71 loc) · 2.92 KB
/
carte_manquante.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.2/jquery.min.js"></script>
<script src="cartes.js"></script>
<div id="manque">Cartes manquantes :<br></div>
<div id="entrop">Cartes en trop : <br></div>
<div id="suitemanquante">Erreur de suite : <br></div>
<?php
$ListeImages = array();
function AfficherImageDossier($dir_nom) {
global $ListeImages;
$dir = opendir($dir_nom) or die('Erreur de listage : le répertoire n\'existe pas'); // on ouvre le contenu du dossier courant
$fichier= array(); // on déclare le tableau contenant le nom des fichiers
$dossier= array(); // on déclare le tableau contenant le nom des dossiers
while($element = readdir($dir)) {
if($element != '.' && $element != '..') {
if (!is_dir($dir_nom.'/'.$element)) {$fichier[] = $element;}
else {$dossier[] = $element;}
}
}
closedir($dir);
if(!empty($dossier)) {
foreach($dossier as $lien){
AfficherImageDossier($dir_nom.'/'.$lien);
}
}
if(!empty($fichier)){
foreach($fichier as $lien) {
$ListeImages[] = substr($lien,0,-4);
}
}
}
AfficherImageDossier('image/cartes');
$ListeImages = json_encode($ListeImages);
?>
<script>
$(document).ready(function() {
Object.keys(ListeCarte).forEach(function(Nom) {
UrlExists(Nom);
ListeCarte[Nom].suiteG.forEach(function(NomCarteG) {
if (!ListeCarte.hasOwnProperty(NomCarteG)) {
console.log(Nom);
console.log(ListeCarte[Nom].suiteG);
$('#suitemanquante').append('Erreur SuiteG pour '+Nom+' : Cherche à atteindre : '+NomCarteG+'<br>');
}
});
ListeCarte[Nom].suiteD.forEach(function(NomCarteD) {
if (!ListeCarte.hasOwnProperty(NomCarteD)) {
console.log(Nom);
console.log(ListeCarte[Nom].suiteD);
$('#suitemanquante').append('Erreur SuiteD pour '+Nom+' : Cherche à atteindre : '+NomCarteD+'<br>');
}
});
});
var ListeImage = JSON.parse('<?php echo $ListeImages; ?>');
ListeImage.forEach(function(elm) {
if (!ListeCarte.hasOwnProperty(elm)) {
$('#entrop').append(elm+'<br>');
}
})
});
function UrlExists(Nom)
{
var http = new XMLHttpRequest();
http.open('HEAD', 'image/cartes/'+ Nom + '.png', true);
http.onload = function () {
if (http.status==404){
$('#manque').append(Nom+'<br>');
}
}
http.send();
}
</script>