ajout d'un inclure qui liste les blockchaines et indique si erreur, ajout pour les webmestre une page content/test.html
This commit is contained in:
parent
7051f24ae9
commit
7b83d6c28c
5 changed files with 204 additions and 3 deletions
|
@ -47,12 +47,54 @@ function blocklog_verifier_blockchaine($id_objet, $objet){
|
||||||
$blockchaine = sql_getfetsel('blockchaine', 'spip_blocklogs', $where, 'id_blocklog DESC', 1);
|
$blockchaine = sql_getfetsel('blockchaine', 'spip_blocklogs', $where, 'id_blocklog DESC', 1);
|
||||||
|
|
||||||
|
|
||||||
if (! defined("_BLOCKLOG_ALGO")) {
|
|
||||||
define("_BLOCKLOG_ALGO", 'sha256');
|
|
||||||
}
|
|
||||||
$blockchaine .= "|" . $r['chaine'];
|
$blockchaine .= "|" . $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 = ''){
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
|
@ -12,3 +12,7 @@
|
||||||
if (!defined('_ECRIRE_INC_VERSION')) {
|
if (!defined('_ECRIRE_INC_VERSION')) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (! defined("_BLOCKLOG_ALGO")) {
|
||||||
|
define("_BLOCKLOG_ALGO", 'sha256');
|
||||||
|
}
|
||||||
|
|
2
content/test.html
Normal file
2
content/test.html
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
[(#SESSION{webmestre}|sinon_interdire_acces)]
|
||||||
|
<INCLURE{fond=inclure/tableau_blockchaines,env}>
|
26
inclure/inc-tableau_blockchaines.html
Normal file
26
inclure/inc-tableau_blockchaines.html
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
#CACHE{0}
|
||||||
|
|
||||||
|
[(#ENV{objet}|blocklog_verifier_blockchaines{#ENV{date_debut}, #ENV{date_fin}}|set{mesLogs})]
|
||||||
|
|
||||||
|
<table>
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th class="id">id</th>
|
||||||
|
<th class="numero">numéro</th>
|
||||||
|
<th class="blockchaine">Blockchaine</th>
|
||||||
|
<th class="date">Date</th>
|
||||||
|
<th class="validite">Validité</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<BOUCLE_blocklog(DATA){source tableau, #GET{mesLogs}}>
|
||||||
|
<tr class="[valideLigne_(#VALEUR{v})]">
|
||||||
|
<td>[(#VALEUR{id_blocklog})]</td>
|
||||||
|
<td>[(#VALEUR{num})]</td>
|
||||||
|
<td>[(#VALEUR{blockchaine})]</td>
|
||||||
|
<td>[(#VALEUR{maj}|affdate{d/M/Y})]</td>
|
||||||
|
<td class="[valideTd_(#VALEUR{v})]">[(#VALEUR{v})]</td>
|
||||||
|
</tr>
|
||||||
|
</BOUCLE_blocklog>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
127
inclure/tableau_blockchaines.html
Normal file
127
inclure/tableau_blockchaines.html
Normal file
|
@ -0,0 +1,127 @@
|
||||||
|
#CACHE{0}
|
||||||
|
<h1>Tableau des Blockchaine</h1>
|
||||||
|
|
||||||
|
<style type="text/css" media="screen">
|
||||||
|
#blocklogs .selecteurs {
|
||||||
|
width: 800px;
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-around;
|
||||||
|
}
|
||||||
|
|
||||||
|
#blocklogs .selecteurs label{
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
#blocklogs .selecteurs #objet{
|
||||||
|
width: 150px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#blocklogs .charger{
|
||||||
|
width: 800px;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
#blocklogs .selecteurs > div{
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
#blocklogs table{
|
||||||
|
width: 100%;
|
||||||
|
max-width: 100%;
|
||||||
|
table-layout: fixed;
|
||||||
|
border-collapse: collapse;
|
||||||
|
vertical-align: top;
|
||||||
|
margin-bottom: 2rem;
|
||||||
|
display: table;
|
||||||
|
border: 1px solid rgb(172, 179, 194);
|
||||||
|
background: transparent;
|
||||||
|
}
|
||||||
|
#blocklogs th, #blocklogs td{
|
||||||
|
padding: 0.3rem 0.6rem;
|
||||||
|
min-width: 2rem;
|
||||||
|
vertical-align: top;
|
||||||
|
border: 1px rgb(172, 179, 194) dotted;
|
||||||
|
text-align: left;
|
||||||
|
cursor: default;
|
||||||
|
}
|
||||||
|
#blocklogs th.id{
|
||||||
|
width: 30px;
|
||||||
|
}
|
||||||
|
#blocklogs th.numero{
|
||||||
|
width: 50px;
|
||||||
|
}
|
||||||
|
#blocklogs th.date{
|
||||||
|
width: 90px;
|
||||||
|
}
|
||||||
|
#blocklogs th.validite{
|
||||||
|
width: 60px;
|
||||||
|
}
|
||||||
|
.valideTd_ok {
|
||||||
|
background-color: #6CE712;
|
||||||
|
}
|
||||||
|
.valideLigne_error {
|
||||||
|
background-color: #E25656;
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
||||||
|
<div id="blocklogs">
|
||||||
|
<div class="selecteurs">
|
||||||
|
<div class="objet">
|
||||||
|
<div>
|
||||||
|
<label for="objet">Objet </label>
|
||||||
|
<select name="objet" id="objet">
|
||||||
|
<option></option>
|
||||||
|
<BOUCLE_objet(BLOCKLOGS){fusion objet}>
|
||||||
|
<option value="#OBJET">#OBJET</option>
|
||||||
|
</BOUCLE_objet>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<div class="date_debut">
|
||||||
|
<div>
|
||||||
|
<label for="date_debut">Date de debut</label>
|
||||||
|
<input type="date" value="#ENV{date_debut}" name="date_debut" id="date_debut"/>
|
||||||
|
</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 class="charger">
|
||||||
|
<button id="charger" type="button">Charger</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<hr>
|
||||||
|
|
||||||
|
<INCLURE{fond=inclure/inc-tableau_blockchaines,env,ajax=blockchaines}>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<script type="text/javascript">
|
||||||
|
|
||||||
|
jQuery(function() {
|
||||||
|
$('#blocklogs').on('click','#charger', function(e){
|
||||||
|
e.preventDefault();
|
||||||
|
var objet = $('#objet').val();
|
||||||
|
var date_debut = $('#date_debut').val();
|
||||||
|
var date_fin = $('#date_fin').val();
|
||||||
|
if (objet && date_debut && date_fin) {
|
||||||
|
ajaxReload('blockchaines', {
|
||||||
|
args:{
|
||||||
|
objet:objet,
|
||||||
|
date_debut: date_debut,
|
||||||
|
date_fin: date_fin
|
||||||
|
},
|
||||||
|
callback: function(){}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
})
|
||||||
|
});
|
||||||
|
|
||||||
|
</script>
|
Loading…
Add table
Reference in a new issue