70 lines
1.7 KiB
PHP
Executable file
70 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, $chaine = '') {
|
|
if (!$objet or !$id_objet or !$chaine) {
|
|
return false;
|
|
}
|
|
|
|
if (defined('_DEBUG_BLOCKLOG')) {
|
|
spip_log('objet = '.$objet, 'blocklog');
|
|
spip_log('id_objet = '.$id_objet, 'blocklog');
|
|
spip_log('num = '.$num, 'blocklog');
|
|
spip_log($chaine, 'blocklog');
|
|
spip_log('----------------', 'blocklog');
|
|
}
|
|
|
|
if (! defined("_BLOCKLOG_ALGO")) {
|
|
define("_BLOCKLOG_ALGO", 'sha256');
|
|
}
|
|
|
|
if (is_array($chaine)) {
|
|
$chaine = implode('|', $chaine);
|
|
}
|
|
|
|
$date = date_create();
|
|
$chaine .= "|". date_timestamp_get($date);
|
|
$chaine = hash(_BACKLOG_ALGO, $chaine);
|
|
|
|
|
|
$blockchaine = sql_getfetsel('blockchaine', 'spip_blocklogs',1,'', 'id_blocklog DESC', '1');
|
|
|
|
$blockchaine .= "|" . $chaine;
|
|
$blockchaine = hash(_BACKLOG_ALGO, $blockchaine);
|
|
|
|
|
|
$set = array (
|
|
'blockchaine' => $blockchaine,
|
|
'chaine' => $chaine,
|
|
'num' => intval($num)
|
|
);
|
|
|
|
if (defined('_DEBUG_BLOCKLOG')) {
|
|
spip_log($set, 'blocklog');
|
|
spip_log('================', 'blocklog');
|
|
}
|
|
|
|
include_spip('action/editer_objet');
|
|
$id_blocklog = objet_inserer("blocklog");
|
|
objet_modifier("blocklog", $id_blocklog, $set);
|
|
$set['id_blocklog'] = $id_blocklog;
|
|
|
|
|
|
include_spip('action/editer_liens');
|
|
$objets_source = array("blocklog"=>$id_blocklog);
|
|
$objets_lies = array($objet => $id_objet);
|
|
objet_associer($objets_source, $objets_lies);
|
|
|
|
return $set;
|
|
}
|