diff --git a/htdocs/blockedlog/admin/fingerprints.php b/htdocs/blockedlog/admin/fingerprints.php index bdd569d31bc..29cd2a3f73b 100644 --- a/htdocs/blockedlog/admin/fingerprints.php +++ b/htdocs/blockedlog/admin/fingerprints.php @@ -24,6 +24,7 @@ require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/blockedlog/lib/blockedlog.lib.php'; require_once DOL_DOCUMENT_ROOT.'/blockedlog/class/blockedlog.class.php'; +require_once DOL_DOCUMENT_ROOT.'/blockedlog/class/authority.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; $langs->load("admin"); @@ -34,6 +35,21 @@ if (! $user->admin) accessforbidden(); $action = GETPOST('action','alpha'); +if($action === 'downloadblockchain') { + + $auth = new BlockedLogAuthority($db); + + $bc = $auth->getLocalBlockChain(); + + header('Content-Type: application/octet-stream'); + header("Content-Transfer-Encoding: Binary"); + header("Content-disposition: attachment; filename=\"" .$auth->signature. ".certif\""); + + echo $bc; + + exit; +} + /* * View @@ -58,7 +74,7 @@ print $langs->trans("FingerprintsDesc")."
\n"; print '
'; -echo '
'.$langs->trans('ShowAllFingerPrintsMightBeTooLong').'
'; +echo '
'.$langs->trans('ShowAllFingerPrintsMightBeTooLong').' '.$langs->trans('DownloadBlockChain').'
'; print ''; diff --git a/htdocs/blockedlog/class/authority.class.php b/htdocs/blockedlog/class/authority.class.php index 8d241694b70..b422fb130d7 100644 --- a/htdocs/blockedlog/class/authority.class.php +++ b/htdocs/blockedlog/class/authority.class.php @@ -18,7 +18,7 @@ /** * Class to manage certif authority */ -class BlockedLogAuthority +class BlockedLogAuthority { /** @@ -56,6 +56,29 @@ class BlockedLogAuthority } + /** + * Get the blockchain + * + * @return string blockchain + */ + public function getLocalBlockChain() { + + $block_static = new BlockedLog($this->db); + + $this->signature = $block_static->getSignature(); + + $blocks = $block_static->getLog('all', 0, 0, 1) ; + + $this->blockchain = ''; + + foreach($blocks as &$b) { + $this->blockchain.=$b->signature; + + } + + return $this->blockchain; + } + /** * Get hash of the block chain to check * diff --git a/htdocs/blockedlog/class/blockedlog.class.php b/htdocs/blockedlog/class/blockedlog.class.php index 26283d6b08a..1f93eb3cc26 100644 --- a/htdocs/blockedlog/class/blockedlog.class.php +++ b/htdocs/blockedlog/class/blockedlog.class.php @@ -19,7 +19,7 @@ * Class to manage Blocked Log */ -class BlockedLog +class BlockedLog { /** diff --git a/htdocs/install/mysql/migration/5.0.0-6.0.0.sql b/htdocs/install/mysql/migration/5.0.0-6.0.0.sql index f4757e2475f..0f9ef8ee3ca 100644 --- a/htdocs/install/mysql/migration/5.0.0-6.0.0.sql +++ b/htdocs/install/mysql/migration/5.0.0-6.0.0.sql @@ -409,7 +409,7 @@ CREATE TABLE llx_blockedlog date_object datetime, object_data text, fk_user integer, - entity integer, + entity integer DEFAULT 1, certified integer ) ENGINE=innodb; diff --git a/htdocs/install/mysql/tables/llx_blockedlog.sql b/htdocs/install/mysql/tables/llx_blockedlog.sql index 769eb34e092..afc0f0d4375 100644 --- a/htdocs/install/mysql/tables/llx_blockedlog.sql +++ b/htdocs/install/mysql/tables/llx_blockedlog.sql @@ -13,7 +13,7 @@ CREATE TABLE llx_blockedlog date_object datetime, object_data text, fk_user integer, - entity integer, + entity integer DEFAULT 1, certified integer ) ENGINE=innodb;