dolibarr 21.0.0-beta
check_signature.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2017 Laurent Destailleur <eldy@users.sourceforge.net>
3 * Copyright (C) 2017 ATM Consulting <contact@atm-consulting.fr>
4 * Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
5 * Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <https://www.gnu.org/licenses/>.
19 */
20
28// This script is called with a POST method.
29// Directory to scan (full path) is inside POST['dir'].
30
31if (!defined('NOTOKENRENEWAL')) {
32 define('NOTOKENRENEWAL', 1); // Disables token renewal
33}
34if (!defined('NOREQUIREMENU')) {
35 define('NOREQUIREMENU', '1');
36}
37if (!defined('NOREQUIREHTML')) {
38 define('NOREQUIREHTML', '1');
39}
40
41
42// Load Dolibarr environment
43require '../../main.inc.php';
44require_once DOL_DOCUMENT_ROOT.'/core/lib/geturl.lib.php';
45require_once DOL_DOCUMENT_ROOT.'/blockedlog/class/blockedlog.class.php';
46require_once DOL_DOCUMENT_ROOT.'/blockedlog/class/authority.class.php';
47
56if (!getDolGlobalString('BLOCKEDLOG_AUTHORITY_URL')) {
57 exit('BLOCKEDLOG_AUTHORITY_URL not set');
58}
59
60
61/*
62 * View
63 */
64
66
67$auth = new BlockedLogAuthority($db);
68$auth->syncSignatureWithAuthority();
69
70$block_static = new BlockedLog($db);
71
72$blocks = $block_static->getLog('just_certified', 0, 0, 'rowid', 'ASC');
73
74$auth->signature = $block_static->getSignature();
75
76if (is_array($blocks)) {
77 foreach ($blocks as &$b) {
78 $auth->blockchain .= $b->signature;
79 }
80}
81
82$hash = $auth->getBlockchainHash();
83
84// Call external authority
85$url = getDolGlobalString('BLOCKEDLOG_AUTHORITY_URL') . '/blockedlog/ajax/authority.php?s='.urlencode($auth->signature).'&h='.urlencode($hash);
86
87$resarray = getURLContent($url, 'GET', '', 1, array(), array(), 2);
88$res = $resarray['content'];
89
90//echo $url;
91echo dol_escape_htmltag($res);
Class to manage certif authority.
Class to manage Blocked Log.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...
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).
if(!defined( 'NOREQUIREMENU')) if(!empty(GETPOST('seteventmessages', 'alpha'))) if(!function_exists("llxHeader")) top_httphead($contenttype='text/html', $forcenocache=0)
Show HTTP header.