etre capable de recalculer la chaine. on passe en fonction la creation d'une chaine et d'une blochaine
64 lines
1.7 KiB
PHP
Executable file
64 lines
1.7 KiB
PHP
Executable file
<?php
|
|
if (!defined('_ECRIRE_INC_VERSION')){
|
|
return;
|
|
}
|
|
|
|
|
|
/**
|
|
* creation de la blockchaine
|
|
*
|
|
* @param string $objet
|
|
* @param int $id_objet
|
|
* @param string | array $chaine : ensemble des valeurs utilisées pour creer la chaine
|
|
* @return array [id_blocklog, chaine, blockchaine]
|
|
*/
|
|
function inc_blocklog_dist($objet, $id_objet = 0, $num = 0, $requete = '') {
|
|
if (!$objet or !$id_objet or !$requete) {
|
|
return false;
|
|
}
|
|
include_spip('blocklog_fonctions');
|
|
|
|
|
|
if (defined('_DEBUG_BLOCKLOG')) {
|
|
spip_log('objet = '.$objet, 'blocklog');
|
|
spip_log('id_objet = '.$id_objet, 'blocklog');
|
|
spip_log('num = '.$num, 'blocklog');
|
|
spip_log('----------------', 'blocklog');
|
|
}
|
|
|
|
if (! defined("_BLOCKLOG_ALGO")) {
|
|
define("_BLOCKLOG_ALGO", 'sha256');
|
|
}
|
|
|
|
$chaine = blocklog_creer_chaine($requete);
|
|
$blockchaine = blocklog_creer_blockchaine($chaine, $objet);
|
|
|
|
$set = array (
|
|
'objet' => $objet,
|
|
'id_objet' => intval($id_objet),
|
|
'blockchaine' => $blockchaine,
|
|
'chaine' => $chaine,
|
|
'num' => intval($num),
|
|
'requete' => $requete
|
|
);
|
|
|
|
if (defined('_DEBUG_BLOCKLOG')) {
|
|
spip_log($set, 'blocklog');
|
|
spip_log('================', 'blocklog');
|
|
}
|
|
|
|
// test la presence en bdd du couple objet / id_objet, si c'est le cas,
|
|
// c'est pas bon signe
|
|
$id_blocklog = sql_getfetsel('id_blocklog', 'spip_blocklogs', [
|
|
'id_objet='.intval($id_objet),
|
|
'objet='.sql_quote($objet)
|
|
]);
|
|
if (intval($id_blocklog)) {
|
|
spip_log("Modification log $id_blocklog","blocklog_modif");
|
|
spip_log("la blockchaine pour $objet / $id_objet ne pas pas etre inserer en bdd", 'blocklog'._LOG_ERREUR);
|
|
} else {
|
|
$id_blocklog = sql_insertq('spip_blocklogs', $set);
|
|
}
|
|
|
|
return $id_blocklog;
|
|
}
|