From 7b83d6c28c85208a583909be9bb4073ada8c8851 Mon Sep 17 00:00:00 2001 From: tofulm Date: Fri, 20 Dec 2019 19:21:51 +0100 Subject: [PATCH] ajout d'un inclure qui liste les blockchaines et indique si erreur, ajout pour les webmestre une page content/test.html --- blocklog_fonctions.php | 48 +++++++++- blocklog_options.php | 4 + content/test.html | 2 + inclure/inc-tableau_blockchaines.html | 26 ++++++ inclure/tableau_blockchaines.html | 127 ++++++++++++++++++++++++++ 5 files changed, 204 insertions(+), 3 deletions(-) create mode 100644 content/test.html create mode 100644 inclure/inc-tableau_blockchaines.html create mode 100644 inclure/tableau_blockchaines.html diff --git a/blocklog_fonctions.php b/blocklog_fonctions.php index 0a66bde..5a48b21 100755 --- a/blocklog_fonctions.php +++ b/blocklog_fonctions.php @@ -47,12 +47,54 @@ function blocklog_verifier_blockchaine($id_objet, $objet){ $blockchaine = sql_getfetsel('blockchaine', 'spip_blocklogs', $where, 'id_blocklog DESC', 1); - if (! defined("_BLOCKLOG_ALGO")) { - define("_BLOCKLOG_ALGO", 'sha256'); - } $blockchaine .= "|" . $r['chaine']; $blockchaine = hash(_BLOCKLOG_ALGO, $blockchaine); return $blockchaine === $r['blockchaine']; } } + +function blocklog_verifier_blockchaines($objet, $date_debut = '', $date_fin = ''){ + + if (empty($objet)) { + return []; + } + + if (empty($date_debut)) { + $date_debut = date_create() -> modify('-1 year')->format('Y-m-d H:i:s'); + } else { + $date_debut = date_create($date_debut)->format('Y-m-d H:i:s'); + } + if (empty($date_fin)) { + $date_fin = date_create()->format('Y-m-d H:i:s'); + } else { + $date_fin = date_create($date_fin)->format('Y-m-d 23:59:59'); + } + + $from = 'spip_blocklogs'; + $where = array( + 'objet='.sql_quote($objet), + 'maj>='.sql_quote($date_debut), + 'maj<='.sql_quote($date_fin), + ); + + $res = sql_allfetsel('*', $from, $where); + $retour = []; + if (count($res)) { + $blockchaine = ""; + foreach ($res as $r) { + $blockchaine .= "|" . $r['chaine']; + $blockchaine = hash(_BLOCKLOG_ALGO, $blockchaine); + if ($blockchaine === $r['blockchaine']){ + $r['v'] = 'ok'; + $retour[] = $r; + } else { + $r['v'] = 'error'; + $retour[] = $r; + break; + } + } + } + + return $retour; +} diff --git a/blocklog_options.php b/blocklog_options.php index 4602707..6ccddae 100755 --- a/blocklog_options.php +++ b/blocklog_options.php @@ -12,3 +12,7 @@ if (!defined('_ECRIRE_INC_VERSION')) { return; } + +if (! defined("_BLOCKLOG_ALGO")) { + define("_BLOCKLOG_ALGO", 'sha256'); +} diff --git a/content/test.html b/content/test.html new file mode 100644 index 0000000..ad87f24 --- /dev/null +++ b/content/test.html @@ -0,0 +1,2 @@ +[(#SESSION{webmestre}|sinon_interdire_acces)] + diff --git a/inclure/inc-tableau_blockchaines.html b/inclure/inc-tableau_blockchaines.html new file mode 100644 index 0000000..39ba455 --- /dev/null +++ b/inclure/inc-tableau_blockchaines.html @@ -0,0 +1,26 @@ +#CACHE{0} + +[(#ENV{objet}|blocklog_verifier_blockchaines{#ENV{date_debut}, #ENV{date_fin}}|set{mesLogs})] + + + + + + + + + + + + + + + + + + + + + + +
idnuméroBlockchaineDateValidité
[(#VALEUR{id_blocklog})][(#VALEUR{num})][(#VALEUR{blockchaine})][(#VALEUR{maj}|affdate{d/M/Y})][(#VALEUR{v})]
diff --git a/inclure/tableau_blockchaines.html b/inclure/tableau_blockchaines.html new file mode 100644 index 0000000..2dcf9c5 --- /dev/null +++ b/inclure/tableau_blockchaines.html @@ -0,0 +1,127 @@ +#CACHE{0} +

Tableau des Blockchaine

+ + + +
+
+
+
+ + +
+ +
+
+
+ + +
+
+
+
+ + +
+
+
+ +
+ +
+ +
+ + + +
+ +