on revoit la page de verifacation
This commit is contained in:
parent
2fcf94bc55
commit
fd9b509f28
3 changed files with 132 additions and 93 deletions
|
@ -13,7 +13,7 @@ if (!defined('_ECRIRE_INC_VERSION')) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
function trouver_blocklog($id_objet, $objet, $id = false){
|
function trouver_blocklog($id_objet, $objet, $all = false){
|
||||||
static $r;
|
static $r;
|
||||||
|
|
||||||
if ($r == null) {
|
if ($r == null) {
|
||||||
|
@ -24,17 +24,23 @@ function trouver_blocklog($id_objet, $objet, $id = false){
|
||||||
'id_objet='.intval($id_objet),
|
'id_objet='.intval($id_objet),
|
||||||
'objet='.sql_quote($objet),
|
'objet='.sql_quote($objet),
|
||||||
);
|
);
|
||||||
$r = sql_fetsel('id_blocklog, blockchaine, chaine', $from, $where);
|
$r = sql_fetsel('id_blocklog, blockchaine, chaine, requete', $from, $where);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($id) {
|
if ($all) {
|
||||||
return $r;
|
return $r;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $r['blockchaine'];
|
return $r['blockchaine'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function blockchaine_sur_pdf(){
|
||||||
|
if (!defined('_BLOCKLOG_CACHER_PDF') or _BLOCKLOG_CACHER_PDF !== true){
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
function afficher_blocklog($texte, $id_dossier, $objet){
|
function afficher_blocklog($texte, $id_dossier, $objet){
|
||||||
$objet = trim($objet);
|
$objet = trim($objet);
|
||||||
|
|
||||||
|
@ -58,68 +64,43 @@ function afficher_blocklog($texte, $id_dossier, $objet){
|
||||||
return $texte;
|
return $texte;
|
||||||
}
|
}
|
||||||
|
|
||||||
function blocklog_verifier_blockchaine($id_objet, $objet){
|
function blocklog_verifier_blockchaine($num, $objet){
|
||||||
if (intval($id_objet) and $objet) {
|
if (intval($num) and $objet) {
|
||||||
$r = trouver_blocklog($id_objet, $objet, true);
|
$where = array(
|
||||||
|
'num='.intval($num),
|
||||||
|
'objet='.sql_quote($objet),
|
||||||
|
);
|
||||||
|
$r = sql_fetsel('id_blocklog, blockchaine, chaine, requete', 'spip_blocklogs', $where);
|
||||||
|
|
||||||
$where = array(
|
$where = array(
|
||||||
'objet='.sql_quote($objet),
|
'objet='.sql_quote($objet),
|
||||||
'id_blocklog<'.intval($r['id_blocklog'])
|
'id_blocklog<'.intval($r['id_blocklog'])
|
||||||
);
|
);
|
||||||
|
|
||||||
$blockchaine = sql_getfetsel('blockchaine', 'spip_blocklogs', $where, 'id_blocklog DESC', 1);
|
$blockchaine_prec = sql_getfetsel('blockchaine', 'spip_blocklogs', $where, 'id_blocklog DESC', 1);
|
||||||
|
|
||||||
|
|
||||||
$blockchaine .= "|" . $r['chaine'];
|
$blockchaine = $blockchaine_prec . $r['chaine'];
|
||||||
$blockchaine = hash(_BLOCKLOG_ALGO, $blockchaine);
|
$blockchaine = hash(_BLOCKLOG_ALGO, $blockchaine);
|
||||||
|
|
||||||
return $blockchaine === $r['blockchaine'];
|
return $blockchaine === $r['blockchaine'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function blocklog_verifier_blockchaines($objet, $date_debut = '', $date_fin = ''){
|
function blocklog_verifier_chaine($num, $objet){
|
||||||
|
|
||||||
if (empty($objet)) {
|
if (intval($num) and $objet) {
|
||||||
return [];
|
$where = array(
|
||||||
|
'num='.intval($num),
|
||||||
|
'objet='.sql_quote($objet),
|
||||||
|
);
|
||||||
|
$r = sql_fetsel('id_blocklog, blockchaine, chaine, requete', 'spip_blocklogs', $where);
|
||||||
|
|
||||||
|
$chaine_bdd = $r['chaine'];
|
||||||
|
$chaine_dynamique = blocklog_creer_chaine($r['requete']);
|
||||||
|
|
||||||
|
return $chaine_bdd === $chaine_dynamique;
|
||||||
}
|
}
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function blocklog_creer_chaine($requete = ""){
|
function blocklog_creer_chaine($requete = ""){
|
||||||
|
@ -142,7 +123,6 @@ function blocklog_creer_chaine($requete = ""){
|
||||||
spip_log($chaine, 'blocklog');
|
spip_log($chaine, 'blocklog');
|
||||||
}
|
}
|
||||||
|
|
||||||
$chaine .= "|";
|
|
||||||
$chaine = hash(_BLOCKLOG_ALGO, $chaine);
|
$chaine = hash(_BLOCKLOG_ALGO, $chaine);
|
||||||
|
|
||||||
return $chaine;
|
return $chaine;
|
||||||
|
@ -154,8 +134,54 @@ function blocklog_creer_blockchaine($chaine, $objet){
|
||||||
);
|
);
|
||||||
$blockchaine = sql_getfetsel('blockchaine', 'spip_blocklogs', $where,'', 'id_blocklog DESC', '1');
|
$blockchaine = sql_getfetsel('blockchaine', 'spip_blocklogs', $where,'', 'id_blocklog DESC', '1');
|
||||||
|
|
||||||
$blockchaine .= "|" . $chaine;
|
$blockchaine .= $chaine;
|
||||||
$blockchaine = hash(_BLOCKLOG_ALGO, $blockchaine);
|
$blockchaine = hash(_BLOCKLOG_ALGO, $blockchaine);
|
||||||
|
|
||||||
return $blockchaine;
|
return $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;
|
||||||
|
//}
|
||||||
|
|
|
@ -1,26 +1,47 @@
|
||||||
#CACHE{0}
|
#CACHE{0}
|
||||||
|
|
||||||
[(#ENV{objet}|blocklog_verifier_blockchaines{#ENV{date_debut}, #ENV{date_fin}}|set{mesLogs})]
|
<div class="test">
|
||||||
|
|
||||||
<table>
|
<BOUCLE_blockchaine(BLOCKLOGS){num}{objet}>
|
||||||
<thead>
|
<div class="blocklog_bdd">
|
||||||
<tr>
|
[(#ENV{num}|blocklog_verifier_chaine{#ENV{objet}}|oui)
|
||||||
<th class="id">id</th>
|
<div class="blocklog_verte">
|
||||||
<th class="numero">numéro</th>
|
Ce dossier n'a pas été modifié dans la base de donnée depuis sa création
|
||||||
<th class="blockchaine">Blockchaine</th>
|
</div>
|
||||||
<th class="date">Date</th>
|
]
|
||||||
<th class="validite">Validité</th>
|
|
||||||
</tr>
|
[(#ENV{num}|blocklog_verifier_chaine{#ENV{objet}}|non)
|
||||||
</thead>
|
<div class="blocklog_rouge">
|
||||||
<tbody>
|
Ce dossier a été modifié dans la base de donnée depuis sa création
|
||||||
<BOUCLE_blocklog(DATA){source tableau, #GET{mesLogs}}>
|
</div>
|
||||||
<tr class="[valideLigne_(#VALEUR{v})]">
|
]
|
||||||
<td>[(#VALEUR{id_blocklog})]</td>
|
|
||||||
<td>[(#VALEUR{num})]</td>
|
<br>
|
||||||
<td>[(#VALEUR{blockchaine})]</td>
|
<div class="chaine_bdd">La blochaine de ce dossier en base de donnée est :
|
||||||
<td>[(#VALEUR{maj}|affdate{d/M/Y})]</td>
|
<strong>#BLOCKCHAINE</strong>
|
||||||
<td class="[valideTd_(#VALEUR{v})]">[(#VALEUR{v})]</td>
|
[<br> (#REM|blockchaine_sur_pdf|oui)
|
||||||
</tr>
|
Ce numéro doit correspondre à celui en inscrit en bas du pdf ]
|
||||||
</BOUCLE_blocklog>
|
</div>
|
||||||
</tbody>
|
|
||||||
</table>
|
[(#ENV{num}|blocklog_verifier_blockchaine{#ENV{objet}}|oui)
|
||||||
|
<div class="blocklog_verte">
|
||||||
|
Il n'y a pas d'altération de la blochaine jusqu'à ce dossier
|
||||||
|
</div>
|
||||||
|
]
|
||||||
|
[(#ENV{num}|blocklog_verifier_blockchaine{#ENV{objet}}|non)
|
||||||
|
<div class="blocklog_rouge">
|
||||||
|
La blockchaine a été altérée
|
||||||
|
</div>
|
||||||
|
]
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</BOUCLE_blockchaine>
|
||||||
|
[(#ENV{num}|et{#ENV{objet}}|oui)
|
||||||
|
<div class="orange">Ce dossier n'a pas de signature dans la base de donnée</div>
|
||||||
|
]
|
||||||
|
<//B_blockchaine>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<br>
|
||||||
|
</div>
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#CACHE{0}
|
#CACHE{0}
|
||||||
<h1>Tableau des Blockchaines</h1>
|
<h1>Vérification des dossiers</h1>
|
||||||
|
|
||||||
<style type="text/css" media="screen">
|
<style type="text/css" media="screen">
|
||||||
#blocklogs .selecteurs {
|
#blocklogs .selecteurs {
|
||||||
|
@ -56,10 +56,10 @@
|
||||||
#blocklogs th.validite{
|
#blocklogs th.validite{
|
||||||
width: 60px;
|
width: 60px;
|
||||||
}
|
}
|
||||||
.valideTd_ok {
|
.blocklog_verte {
|
||||||
background-color: #6CE712;
|
background-color: #6CE712;
|
||||||
}
|
}
|
||||||
.valideLigne_error {
|
.blocklog_rouge {
|
||||||
background-color: #E25656;
|
background-color: #E25656;
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
}
|
}
|
||||||
|
@ -81,20 +81,14 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="date_debut">
|
<div class="date_debut">
|
||||||
<div>
|
<div>
|
||||||
<label for="date_debut">Date de debut</label>
|
<label for="num">Numéro</label>
|
||||||
<input type="date" value="#ENV{date_debut}" name="date_debut" id="date_debut"/>
|
<input type="number" name="num" id="num"/>
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="date_fin">
|
|
||||||
<div>
|
|
||||||
<label for="date_fin">Date de fin</label>
|
|
||||||
<input type="date" value="#ENV{date_fin}" name="date_fin" id="date_fin"/>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="charger">
|
<div class="charger">
|
||||||
<button id="charger" type="button">Charger</button>
|
<button id="charger" type="button">Vérifier</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<hr>
|
<hr>
|
||||||
|
@ -108,15 +102,13 @@
|
||||||
jQuery(function() {
|
jQuery(function() {
|
||||||
$('#blocklogs').on('click','#charger', function(e){
|
$('#blocklogs').on('click','#charger', function(e){
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
var objet = $('#objet').val();
|
var objet = $('#objet').val();
|
||||||
var date_debut = $('#date_debut').val();
|
var num = $('#num').val();
|
||||||
var date_fin = $('#date_fin').val();
|
if (objet && num) {
|
||||||
if (objet && date_debut && date_fin) {
|
|
||||||
ajaxReload('blockchaines', {
|
ajaxReload('blockchaines', {
|
||||||
args:{
|
args:{
|
||||||
objet:objet,
|
objet:objet,
|
||||||
date_debut: date_debut,
|
num:num
|
||||||
date_fin: date_fin
|
|
||||||
},
|
},
|
||||||
callback: function(){}
|
callback: function(){}
|
||||||
});
|
});
|
||||||
|
|
Loading…
Add table
Reference in a new issue