forked from halo-battle/game
Version 1.12
This commit is contained in:
parent
2a066a7498
commit
de31cd3e9a
1373 changed files with 156282 additions and 45238 deletions
143
htdocs/integrite.php
Normal file
143
htdocs/integrite.php
Normal file
|
|
@ -0,0 +1,143 @@
|
|||
<html>
|
||||
<head>
|
||||
<title>.: Halo-Battle :: Vérification de l'intégrité des fichiers :.</title>
|
||||
</head>
|
||||
<body>
|
||||
<h2>Vérification de l'intégrité des fichiers</h2>
|
||||
<?php
|
||||
define ('FILE_SAV', "../onyx2/cache/checksum.php");
|
||||
define ('dir_start', "../");
|
||||
|
||||
print 'Chargement du fichier de comparaison ...';
|
||||
if (is_file('checkSum.php'))
|
||||
{
|
||||
print ' Touvé ...';
|
||||
$SUM = sha1(file_get_contents('checkSum.php'));
|
||||
print ' Données chargées avec succès<br /><br />';
|
||||
}
|
||||
|
||||
print 'Vérification du fichier de validation ...';
|
||||
if (sha1(sha1_file(__FILE__)) != $SUM)
|
||||
die(' INVALIDE !<br />Arrêt du processus de validation !');
|
||||
else
|
||||
print ' Valide<br /><br />';
|
||||
|
||||
print 'Recherche du fichier de sauvegarde ...';
|
||||
if (is_file(FILE_SAV) && !isset($_GET['erase']))
|
||||
{
|
||||
function parcourDir($dir, $sums)
|
||||
{
|
||||
if (isset($_GET['v']))
|
||||
print "<br />Parcours du dossier à la recherche de nouveaux fichiers : ".$dir;
|
||||
|
||||
$new = 0;
|
||||
$pointeur = opendir($dir);
|
||||
while ($fichier = readdir($pointeur))
|
||||
{
|
||||
if($fichier == '.' || $fichier == '..' || $fichier == '.svn' || ereg("~", $fichier))
|
||||
continue;
|
||||
|
||||
if(is_dir($dir.$fichier) && is_readable($dir.$fichier))
|
||||
$new += parcourDir($dir.$fichier.'/', $sums);
|
||||
|
||||
elseif(is_file($dir.$fichier))
|
||||
{
|
||||
if (!isset($sums[$dir.$fichier]))
|
||||
{
|
||||
$new++;
|
||||
print "<tr style=\"background: #00FFFF;\"><td>".$dir.$fichier."</td><td style=\"text-align: center;\">Nouveau fichier !</td></tr>";
|
||||
}
|
||||
}
|
||||
}
|
||||
closedir($pointeur);
|
||||
|
||||
return $new;
|
||||
}
|
||||
|
||||
print ' Trouvé<br /><br />';
|
||||
|
||||
if (isset($_GET["check"]))
|
||||
{
|
||||
print 'Contrôle de la somme de la dernière validation ...';
|
||||
if (sha1(sha1_file(FILE_SAV).'<^>'.sha1_file(__FILE__).sha1_file('checkSum.php')) == $_GET["check"])
|
||||
print ' <span style="color: #00FF00;">Authentique</span><br /><br />';
|
||||
else
|
||||
die (' Invalide !<br />Arrêt du processus de vérification !');
|
||||
}
|
||||
else
|
||||
print '<span style="color: #FF0000; font-weigth: bold;">Les résultats présentés ci-dessus ne peuvent pas être authentifiés sans la somme d\'un précédent contrôle, rien ne dit que les fichiers de validation n\'ont pas été modifiés !</span><br /><br />';
|
||||
|
||||
$start = unserialize(file_get_contents(FILE_SAV));
|
||||
|
||||
print ' Vérification des fichiers ...';
|
||||
print '<table border="1" style=""><tr><th>Nom du fichier</th><th>Détails</th></tr>';
|
||||
$alerte = 0;
|
||||
foreach($start as $key => $sum)
|
||||
{
|
||||
if (!is_file($key))
|
||||
{
|
||||
$alerte++;
|
||||
if (!isset($_GET['a']))
|
||||
print "<tr style=\"background: #FFCC00;\"><td>".$key."</td><td style=\"text-align: center;\">Fichier supprimé !</td></tr>";
|
||||
}
|
||||
elseif (sha1_file($key) != $sum)
|
||||
{
|
||||
$alerte++;
|
||||
print "<tr style=\"background: #FF0000;\"><td>".$key."</td><td style=\"text-align: center;\">Alerte de différence de somme !</td></tr>";
|
||||
}
|
||||
elseif (isset($_GET['v']))
|
||||
print "<tr style=\"background: #00FF00;\"><td>".$key."</td><td style=\"text-align: center;\">Ok</td></tr>";
|
||||
}
|
||||
$newFiles = parcourDir(dir_start, $start);
|
||||
print '</table>';
|
||||
|
||||
print '<br />Fin de la vérification : '.$alerte.' alerte(s) sur '.count($start).' fichier(s). '.$newFiles.' nouveau(x) fichier(s).';
|
||||
|
||||
print '<br /><br />Contôle de la prochaine validation : '.sha1(sha1_file(FILE_SAV).'<^>'.sha1_file(__FILE__).sha1_file('checkSum.php'));
|
||||
}
|
||||
else
|
||||
{
|
||||
if (isset($_GET['erase']) && $_GET['erase'] == $SUM)
|
||||
print ' Trouvé<br />Détection d\'une demande d\'effacement<br /><br />';
|
||||
elseif (!is_file(FILE_SAV))
|
||||
//print ' Introuvable<br /><br />';
|
||||
die (' Introuvable<br /><br />Arrêt de la vérification.');
|
||||
else
|
||||
die(' ?<br /><br />Impossible de déterminer l\'origine de la requête !<br />Arrêt de la vérification.');
|
||||
|
||||
function extractDir($dir)
|
||||
{
|
||||
$sums = array();
|
||||
|
||||
if (isset($_GET['v']))
|
||||
print "<br />Génération des sommes de fichiers pour le dossier : ".$dir;
|
||||
|
||||
$pointeur = opendir($dir);
|
||||
while ($fichier = readdir($pointeur))
|
||||
{
|
||||
if($fichier == '.' || $fichier == '..' || $fichier == '.svn' || ereg("~", $fichier))
|
||||
continue;
|
||||
|
||||
if(is_dir($dir.$fichier) && is_readable($dir.$fichier))
|
||||
$sums = array_merge($sums, extractDir($dir.$fichier.'/'));
|
||||
|
||||
elseif(is_file($dir.$fichier))
|
||||
$sums[$dir.$fichier] = sha1_file($dir.$fichier);
|
||||
}
|
||||
closedir($pointeur);
|
||||
|
||||
return $sums;
|
||||
}
|
||||
|
||||
print 'Génération du tableau ...';
|
||||
$sums = array();
|
||||
|
||||
$sums = extractDir(dir_start);
|
||||
|
||||
print "Écriture du fichier.<br />";
|
||||
file_put_contents(FILE_SAV, serialize($sums));
|
||||
print "Fin de l'opération.<br />";
|
||||
}
|
||||
?>
|
||||
</body>
|
||||
</html>
|
||||
Loading…
Add table
Add a link
Reference in a new issue