Skip to content
Snippets Groups Projects
Commit 11d2a553 authored by Alexis Algoud's avatar Alexis Algoud
Browse files

fix entity default value and add link to download blockchain

parent 3cae54c2
No related branches found
No related tags found
No related merge requests found
......@@ -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")."<br>\n";
print '<br>';
echo '<div align="right"><a href="?all=1">'.$langs->trans('ShowAllFingerPrintsMightBeTooLong').'</a></div>';
echo '<div align="right"><a href="?all=1">'.$langs->trans('ShowAllFingerPrintsMightBeTooLong').'</a> <a href="?action=downloadblockchain">'.$langs->trans('DownloadBlockChain').'</a></div>';
print '<table class="noborder" width="100%">';
......
......@@ -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
*
......
......@@ -19,7 +19,7 @@
* Class to manage Blocked Log
*/
class BlockedLog
class BlockedLog
{
/**
......
......@@ -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;
......
......@@ -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;
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment