ajout sur la page sha256sum d'une verification id_objet objet
This commit is contained in:
parent
05c63e9155
commit
8902d8ce92
2 changed files with 106 additions and 23 deletions
|
@ -13,17 +13,42 @@ if (!defined('_ECRIRE_INC_VERSION')) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
function trouver_blocklog($id_objet, $objet){
|
function trouver_blocklog($id_objet, $objet, $id = false){
|
||||||
$from = array(
|
static $r;
|
||||||
'spip_blocklogs as B',
|
|
||||||
'spip_blocklogs_liens as L'
|
|
||||||
);
|
|
||||||
$where = array(
|
|
||||||
'L.id_objet='.intval($id_objet),
|
|
||||||
'L.objet='.sql_quote($objet),
|
|
||||||
'L.id_blocklog=B.id_blocklog'
|
|
||||||
);
|
|
||||||
$blockchaine = sql_getfetsel('blockchaine', $from, $where, '', 'B.id_blocklog DESC', 1);
|
|
||||||
|
|
||||||
return $blockchaine;
|
if ($r == null) {
|
||||||
|
$from = array(
|
||||||
|
'spip_blocklogs as B',
|
||||||
|
'spip_blocklogs_liens as L'
|
||||||
|
);
|
||||||
|
$where = array(
|
||||||
|
'L.id_objet='.intval($id_objet),
|
||||||
|
'L.objet='.sql_quote($objet),
|
||||||
|
'L.id_blocklog=B.id_blocklog'
|
||||||
|
);
|
||||||
|
$r = sql_fetsel('B.id_blocklog, B.blockchaine, B.chaine', $from, $where, '', 'B.id_blocklog DESC', 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($id) {
|
||||||
|
return $r;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $r['blockchaine'];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function blocklog_verifier_blockchaine($id_objet, $objet){
|
||||||
|
if (intval($id_objet) and $objet) {
|
||||||
|
$r = trouver_blocklog($id_objet, $objet, true);
|
||||||
|
$id_blocklog_pre = intval($r['id_blocklog']) - 1;
|
||||||
|
$blockchaine = sql_getfetsel('blockchaine', 'spip_blocklogs', 'id_blocklog='.intval($id_blocklog_pre));
|
||||||
|
|
||||||
|
if (! defined("_BLOCKLOG_ALGO")) {
|
||||||
|
define("_BLOCKLOG_ALGO", 'sha256');
|
||||||
|
}
|
||||||
|
$blockchaine .= "|" . $r['chaine'];
|
||||||
|
$blockchaine = hash(_BLOCKLOG_ALGO, $blockchaine);
|
||||||
|
|
||||||
|
return $blockchaine === $r['blockchaine'];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
File diff suppressed because one or more lines are too long
Loading…
Add table
Reference in a new issue