Compare commits
12 commits
Author | SHA1 | Date | |
---|---|---|---|
2dcf098153 | |||
|
2441f22fc3 | ||
2caf2f808e | |||
f191e4ce8e | |||
02e8f50bed | |||
|
4521675196 | ||
0186c57aa6 | |||
a0349698f0 | |||
9fac6e1c66 | |||
25544d1588 | |||
b6710055e7 | |||
0ae0147a1c |
5 changed files with 66 additions and 270 deletions
21
README.md
21
README.md
|
@ -3,14 +3,9 @@
|
||||||
## Utilisation
|
## Utilisation
|
||||||
> Génération du blocklog
|
> Génération du blocklog
|
||||||
```php
|
```php
|
||||||
|
$requete = sql_allfetsel($s, $f, $w,'','','','','', false);
|
||||||
$blocklog = charger_fonction('blocklog', 'inc');
|
$blocklog = charger_fonction('blocklog', 'inc');
|
||||||
// $chaine : string ou array
|
$blocklog($objet, $id_objet, $numero_facture, $requete);
|
||||||
$blocklog("monObjet", $id_objet, $num_dossier, $chaine);
|
|
||||||
```
|
|
||||||
|
|
||||||
## Page html de generation d'un bloclog
|
|
||||||
```
|
|
||||||
?page=sha256sum
|
|
||||||
```
|
```
|
||||||
|
|
||||||
## options :
|
## options :
|
||||||
|
@ -21,4 +16,16 @@ define("_BLOCKLOG_ALGO", 'sha256');
|
||||||
//activer les log : blocklog.log
|
//activer les log : blocklog.log
|
||||||
define("_DEBUG_BLOCKLOG", true);
|
define("_DEBUG_BLOCKLOG", true);
|
||||||
|
|
||||||
|
// garder le calcul de la chaine simple, requete avec sql_fetch et non sql_fetch_all
|
||||||
|
// utiliser sur lcdp
|
||||||
|
// l'autre solution est de rester en version 1 du plugin
|
||||||
|
define("_BLOCKLOG_CHAINE_SIMPLE", true);
|
||||||
|
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Page html de generation d'un bloclog
|
||||||
|
```
|
||||||
|
?page=sha256sum
|
||||||
|
```
|
||||||
|
|
||||||
|
|
|
@ -15,33 +15,28 @@ if (!defined('_ECRIRE_INC_VERSION')) {
|
||||||
|
|
||||||
function trouver_blocklog($id_objet, $objet, $all = false){
|
function trouver_blocklog($id_objet, $objet, $all = false){
|
||||||
static $r;
|
static $r;
|
||||||
|
if (is_null($r)) {
|
||||||
if ($r == null) {
|
$where = [
|
||||||
$from = array(
|
|
||||||
'spip_blocklogs',
|
|
||||||
);
|
|
||||||
$where = array(
|
|
||||||
'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, requete', $from, $where);
|
$r = sql_fetsel('id_blocklog, blockchaine, chaine, requete', 'spip_blocklogs', $where);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($all) {
|
if ($all) {
|
||||||
return $r;
|
return $r;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $r['blockchaine'];
|
return $r['blockchaine'] ?? '';
|
||||||
}
|
}
|
||||||
|
|
||||||
function blockchaine_sur_pdf(){
|
function blockchaine_sur_pdf(){
|
||||||
if (!defined('_BLOCKLOG_CACHER_PDF') or _BLOCKLOG_CACHER_PDF !== true){
|
if (!defined('_BLOCKLOG_CACHER_PDF') or (defined('_BLOCKLOG_CACHER_PDF') and _BLOCKLOG_CACHER_PDF !== true)){
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
function afficher_blocklog($texte, $id_dossier, $objet, $type = 'chaine'){
|
function afficher_blocklog($texte = '', $id_objet = 0, $objet = '', $type = 'chaine'){
|
||||||
$objet = trim($objet);
|
$objet = trim($objet);
|
||||||
|
|
||||||
$blockchaine = '<span class="affichage_blockchaine">';
|
$blockchaine = '<span class="affichage_blockchaine">';
|
||||||
|
@ -51,12 +46,16 @@ function afficher_blocklog($texte, $id_dossier, $objet, $type = 'chaine'){
|
||||||
$img .= " ";
|
$img .= " ";
|
||||||
}
|
}
|
||||||
if (!defined('_BLOCKLOG_CACHER_PDF') or _BLOCKLOG_CACHER_PDF !== true){
|
if (!defined('_BLOCKLOG_CACHER_PDF') or _BLOCKLOG_CACHER_PDF !== true){
|
||||||
if (intval($id_dossier) and $objet) {
|
if (intval($id_objet) and $objet) {
|
||||||
|
$recup_bl = trouver_blocklog($id_objet, $objet, true);
|
||||||
$blockchaine .= $img;
|
$blockchaine .= $img;
|
||||||
$blockchaine .= trouver_blocklog($id_dossier, $objet, true)[$type];
|
$blockchaine .= $recup_bl[$type] ?? '';
|
||||||
$blockchaine .= '</span>';
|
$blockchaine .= '</span>';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (empty($texte)) {
|
||||||
|
return $blockchaine;
|
||||||
|
}
|
||||||
|
|
||||||
$texte = str_replace('@@blockchaine@@', $blockchaine, $texte);
|
$texte = str_replace('@@blockchaine@@', $blockchaine, $texte);
|
||||||
$texte = str_replace('@@blocklog@@', $blockchaine, $texte);
|
$texte = str_replace('@@blocklog@@', $blockchaine, $texte);
|
||||||
|
@ -72,23 +71,23 @@ function blocklog_verifier_blockchaine($num, $objet){
|
||||||
);
|
);
|
||||||
$r = sql_fetsel('id_blocklog, blockchaine, chaine, requete', 'spip_blocklogs', $where);
|
$r = sql_fetsel('id_blocklog, blockchaine, chaine, requete', 'spip_blocklogs', $where);
|
||||||
|
|
||||||
|
if (is_array($r)) {
|
||||||
$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_prec = sql_getfetsel('blockchaine', 'spip_blocklogs', $where, 'id_blocklog DESC', 1);
|
$blockchaine_prec = sql_getfetsel('blockchaine', 'spip_blocklogs', $where, 'id_blocklog DESC', 1) ?? '';
|
||||||
|
|
||||||
|
|
||||||
$blockchaine = $blockchaine_prec . $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'];
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
function blocklog_verifier_chaine($num, $objet){
|
function blocklog_verifier_chaine($num, $objet){
|
||||||
|
|
||||||
if (intval($num) and $objet) {
|
if (intval($num) and $objet) {
|
||||||
$where = array(
|
$where = array(
|
||||||
'num='.intval($num),
|
'num='.intval($num),
|
||||||
|
@ -96,11 +95,14 @@ function blocklog_verifier_chaine($num, $objet){
|
||||||
);
|
);
|
||||||
$r = sql_fetsel('id_blocklog, blockchaine, chaine, requete', 'spip_blocklogs', $where);
|
$r = sql_fetsel('id_blocklog, blockchaine, chaine, requete', 'spip_blocklogs', $where);
|
||||||
|
|
||||||
|
if (isset($r['chaine']) and isset($r['requete'])) {
|
||||||
$chaine_bdd = $r['chaine'];
|
$chaine_bdd = $r['chaine'];
|
||||||
$chaine_dynamique = blocklog_creer_chaine($r['requete']);
|
$chaine_dynamique = blocklog_creer_chaine($r['requete']);
|
||||||
|
|
||||||
return $chaine_bdd === $chaine_dynamique;
|
return $chaine_bdd === $chaine_dynamique;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
function blocklog_creer_chaine($requete = ""){
|
function blocklog_creer_chaine($requete = ""){
|
||||||
|
@ -108,9 +110,13 @@ function blocklog_creer_chaine($requete = ""){
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
$r = sql_query($requete);
|
$get_infos = charger_fonction('get_infos', 'plugins');
|
||||||
$chaine = sql_fetch($r);
|
$version = $get_infos('blocklog');
|
||||||
|
|
||||||
|
$r = sql_query($requete);
|
||||||
|
|
||||||
|
if (intval($version) < 2 or defined('_BLOCKLOG_CHAINE_SIMPLE')) {
|
||||||
|
$chaine = sql_fetch($r);
|
||||||
if (is_array($chaine)) {
|
if (is_array($chaine)) {
|
||||||
$c = [];
|
$c = [];
|
||||||
foreach ($chaine as $i => $v) {
|
foreach ($chaine as $i => $v) {
|
||||||
|
@ -118,6 +124,12 @@ function blocklog_creer_chaine($requete = ""){
|
||||||
}
|
}
|
||||||
$chaine = implode('|', $c);
|
$chaine = implode('|', $c);
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
$chaine = sql_fetch_all($r);
|
||||||
|
if (is_array($chaine)) {
|
||||||
|
$chaine = serialize($chaine);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$chaine = hash(_BLOCKLOG_ALGO, $chaine);
|
$chaine = hash(_BLOCKLOG_ALGO, $chaine);
|
||||||
|
|
||||||
|
@ -125,10 +137,10 @@ function blocklog_creer_chaine($requete = ""){
|
||||||
}
|
}
|
||||||
|
|
||||||
function blocklog_creer_blockchaine($chaine, $objet){
|
function blocklog_creer_blockchaine($chaine, $objet){
|
||||||
$where = array(
|
$where = [
|
||||||
'objet='.sql_quote($objet)
|
'objet='.sql_quote($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);
|
||||||
|
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -1,9 +1,9 @@
|
||||||
<paquet
|
<paquet
|
||||||
prefix="blocklog"
|
prefix="blocklog"
|
||||||
categorie="outil"
|
categorie="outil"
|
||||||
version="1.1.5"
|
version="2.0.2"
|
||||||
etat="dev"
|
etat="dev"
|
||||||
compatibilite="[3.2.0;3.3.*]"
|
compatibilite="[3.2.0;4.*.*]"
|
||||||
logo="prive/themes/spip/images/blocklog-64.png"
|
logo="prive/themes/spip/images/blocklog-64.png"
|
||||||
documentation=""
|
documentation=""
|
||||||
schema="1.0.7"
|
schema="1.0.7"
|
||||||
|
|
|
@ -115,7 +115,6 @@
|
||||||
let c3 = document.querySelector('#c3').value;
|
let c3 = document.querySelector('#c3').value;
|
||||||
let chaine = c1 + c2 +c3;
|
let chaine = c1 + c2 +c3;
|
||||||
chaine = sha256(chaine);
|
chaine = sha256(chaine);
|
||||||
console.log(chaine);
|
|
||||||
document.querySelector('#sha').value = chaine;
|
document.querySelector('#sha').value = chaine;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue