34 public $signature =
'';
40 public $blockchain =
'';
68 $this->signature = $block_static->getSignature();
70 $blocks = $block_static->getLog(
'all', 0, 0,
'rowid',
'ASC');
72 $this->blockchain =
'';
74 if (is_array($blocks)) {
75 foreach ($blocks as &$b) {
76 $this->blockchain .= $b->signature;
80 return $this->blockchain;
91 return md5($this->signature.$this->blockchain);
115 $this->blockchain .= $block;
127 if (strlen($block) != 64) {
131 $blocks = str_split($this->blockchain, 64);
133 if (!in_array($block, $blocks)) {
148 public function fetch($id, $signature =
'')
153 dol_syslog(get_class($this).
"::fetch id=".((
int) $id), LOG_DEBUG);
155 if (empty($id) && empty($signature)) {
156 $this->error =
'BadParameter';
160 $langs->load(
"blockedlog");
162 $sql =
"SELECT b.rowid, b.signature, b.blockchain, b.tms";
163 $sql .=
" FROM ".MAIN_DB_PREFIX.
"blockedlog_authority as b";
166 $sql .=
" WHERE b.rowid = ".((int) $id);
167 } elseif ($signature) {
168 $sql .=
" WHERE b.signature = '".$this->db->escape($signature).
"'";
174 $obj = $this->
db->fetch_object(
$resql);
176 $this->
id = $obj->rowid;
177 $this->
ref = $obj->rowid;
179 $this->signature = $obj->signature;
180 $this->blockchain = $obj->blockchain;
182 $this->tms = $this->
db->jdate($obj->tms);
186 $this->error = $langs->trans(
"RecordNotFound");
190 $this->error = $this->
db->error();
204 global $conf, $langs, $hookmanager;
206 $langs->load(
'blockedlog');
210 dol_syslog(get_class($this).
'::create', LOG_DEBUG);
214 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"blockedlog_authority (";
215 $sql .=
" signature,";
216 $sql .=
" blockchain";
217 $sql .=
") VALUES (";
218 $sql .=
"'".$this->db->escape($this->signature).
"',";
219 $sql .=
"'".$this->db->escape($this->blockchain).
"'";
222 $res = $this->
db->query($sql);
224 $id = $this->
db->last_insert_id(MAIN_DB_PREFIX.
"blockedlog_authority");
233 $this->
db->rollback();
237 $this->error = $this->
db->error();
238 $this->
db->rollback();
252 global $conf, $langs, $hookmanager;
254 $langs->load(
'blockedlog');
258 dol_syslog(get_class($this).
'::create', LOG_DEBUG);
262 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"blockedlog_authority SET ";
263 $sql .=
" blockchain='".$this->db->escape($this->blockchain).
"'";
264 $sql .=
" WHERE rowid=".((int) $this->
id);
266 $res = $this->
db->query($sql);
272 $this->error = $this->
db->error();
273 $this->
db->rollback();
285 global $conf, $langs;
289 if (empty($conf->global->BLOCKEDLOG_AUTHORITY_URL) || empty($conf->global->BLOCKEDLOG_USE_REMOTE_AUTHORITY)) {
290 $this->error = $langs->trans(
'NoAuthorityURLDefined');
294 require_once DOL_DOCUMENT_ROOT.
'/blockedlog/class/blockedlog.class.php';
298 $blocks = $block_static->getLog(
'not_certified', 0, 0,
'rowid',
'ASC');
300 $signature = $block_static->getSignature();
302 if (is_array($blocks)) {
303 foreach ($blocks as &$block) {
304 $url = $conf->global->BLOCKEDLOG_AUTHORITY_URL.
'/blockedlog/ajax/authority.php?s='.$signature.
'&b='.$block->signature;
307 echo $block->signature.
' '.$url.
' '.$res[
'content'].
'<br>';
308 if ($res[
'content'] ===
'blockalreadyadded' || $res[
'content'] ===
'blockadded') {
309 $block->setCertified();
311 $this->error = $langs->trans(
'ImpossibleToContactAuthority ', $url);
Class to manage certif authority.
fetch($id, $signature='')
Get object from database.
checkBlock($block)
hash already exist into chain ?
create($user)
Create authority in database.
__construct($db)
Constructor.
getLocalBlockChain()
Get the blockchain.
syncSignatureWithAuthority()
For cron to sync to authority.
update($user)
Create authority in database.
checkBlockchain($hash)
Get hash of the block chain to check.
addBlock($block)
Add a new block to the chain.
getBlockchainHash()
Get hash of the block chain to check.
Class to manage Blocked Log.
if(isModEnabled('facture') &&!empty($user->rights->facture->lire)) if((isModEnabled('fournisseur') &&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->hasRight("fournisseur", "facture", "lire"))||(isModEnabled('supplier_invoice') && $user->hasRight("supplier_invoice", "lire"))) if(isModEnabled('don') &&!empty($user->rights->don->lire)) if(isModEnabled('tax') &&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture') &&isModEnabled('commande') && $user->hasRight("commande", "lire") &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $resql
Social contributions to pay.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
getURLContent($url, $postorget='GET', $param='', $followlocation=1, $addheaders=array(), $allowedschemes=array('http', 'https'), $localurl=0, $ssl_verifypeer=-1)
Function to get a content from an URL (use proxy if proxy defined).
$conf db
API class for accounts.