fix entity default value and add link to download blockchain

This commit is contained in:
Alexis Algoud 2017-06-11 00:03:01 +02:00
parent 3cae54c296
commit 11d2a5538b
5 changed files with 44 additions and 5 deletions

View File

@ -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%">';

View File

@ -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
*

View File

@ -19,7 +19,7 @@
* Class to manage Blocked Log
*/
class BlockedLog
class BlockedLog
{
/**

View File

@ -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;

View File

@ -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;