53 lines
1.3 KiB
PHP
53 lines
1.3 KiB
PHP
<?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, $num, $chaine) {
|
|
if (!$objet or !$id_objet or !$chaine) {
|
|
return false;
|
|
}
|
|
|
|
if (! defined("_BACKLOG_ALGO")) {
|
|
define("_BACKLOG_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 .= "|" . $blockchaine;
|
|
$blockchaine = hash(_BACKLOG_ALGO, $blockchaine);
|
|
|
|
$set = array (
|
|
'blockchaine' => $blockchaine,
|
|
'chaine' => $chaine,
|
|
'num' => intval($num)
|
|
);
|
|
|
|
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;
|
|
}
|