'; $img = find_in_path('img/icone_blockchaine.png'); if ($img) { $img = ''; $img .= " "; } if (!defined('_BLOCKLOG_CACHER_PDF') or (defined('_BLOCKLOG_CACHER_PDF') and _BLOCKLOG_CACHER_PDF !== true)){ if (intval($id_dossier) and $objet) { $blockchaine .= $img; $blockchaine .= trouver_blocklog($id_dossier, $objet, true)[$type]; $blockchaine .= ''; } } if (empty($texte)) { return $blockchaine; } $texte = str_replace('@@blockchaine@@', $blockchaine, $texte); $texte = str_replace('@@blocklog@@', $blockchaine, $texte); return $texte; } function blocklog_verifier_blockchaine($num, $objet){ if (intval($num) and $objet) { $where = array( 'num='.intval($num), 'objet='.sql_quote($objet), ); $r = sql_fetsel('id_blocklog, blockchaine, chaine, requete', 'spip_blocklogs', $where); $where = array( 'objet='.sql_quote($objet), 'id_blocklog<'.intval($r['id_blocklog']) ); $blockchaine_prec = sql_getfetsel('blockchaine', 'spip_blocklogs', $where, 'id_blocklog DESC', 1); $blockchaine = $blockchaine_prec . $r['chaine']; $blockchaine = hash(_BLOCKLOG_ALGO, $blockchaine); return $blockchaine === $r['blockchaine']; } } function blocklog_verifier_chaine($num, $objet){ if (intval($num) and $objet) { $where = array( 'num='.intval($num), 'objet='.sql_quote($objet), ); $r = sql_fetsel('id_blocklog, blockchaine, chaine, requete', 'spip_blocklogs', $where); $chaine_bdd = $r['chaine']; $chaine_dynamique = blocklog_creer_chaine($r['requete']); return $chaine_bdd === $chaine_dynamique; } } function blocklog_creer_chaine($requete = ""){ if ( strlen($requete) < 5 ) { return ''; } $get_infos = charger_fonction('get_infos', 'plugins'); $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)) { $c = []; foreach ($chaine as $i => $v) { $c[] = $v; } $chaine = implode('|', $c); } } else { $chaine = sql_fetch_all($r); if (is_array($chaine)) { $chaine = serialize($chaine); } } $chaine = hash(_BLOCKLOG_ALGO, $chaine); return $chaine; } function blocklog_creer_blockchaine($chaine, $objet){ $where = array( 'objet='.sql_quote($objet) ); $blockchaine = sql_getfetsel('blockchaine', 'spip_blocklogs', $where,'', 'id_blocklog DESC', '1'); $blockchaine .= $chaine; $blockchaine = hash(_BLOCKLOG_ALGO, $blockchaine); return $blockchaine; } //function blocklog_verifier_blockchaines($objet, $date_debut = '', $date_fin = ''){ //if (empty($objet)) { //return []; //} //if (empty($date_debut)) { //$date_debut = date_create() -> modify('-1 year')->format('Y-m-d H:i:s'); //} else { //$date_debut = date_create($date_debut)->format('Y-m-d H:i:s'); //} //if (empty($date_fin)) { //$date_fin = date_create()->format('Y-m-d H:i:s'); //} else { //$date_fin = date_create($date_fin)->format('Y-m-d 23:59:59'); //} //$from = 'spip_blocklogs'; //$where = array( //'objet='.sql_quote($objet), //'maj>='.sql_quote($date_debut), //'maj<='.sql_quote($date_fin), //); //$res = sql_allfetsel('*', $from, $where); //$retour = []; //if (count($res)) { //$blockchaine = ""; //foreach ($res as $r) { //$blockchaine .= $r['chaine']; //$blockchaine = hash(_BLOCKLOG_ALGO, $blockchaine); //if ($blockchaine === $r['blockchaine']){ //$r['v'] = 'ok'; //$retour[] = $r; //} else { //$r['v'] = 'error'; //$retour[] = $r; //break; //} //} //} //return $retour; //}