dolibarr 21.0.0-alpha
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 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <https://www.gnu.org/licenses/>.
18 */
19
27// This script is called with a POST method.
28// Directory to scan (full path) is inside POST['dir'].
29
30if (!defined('NOTOKENRENEWAL')) {
31 define('NOTOKENRENEWAL', 1); // Disables token renewal
32}
33if (!defined('NOREQUIREMENU')) {
34 define('NOREQUIREMENU', '1');
35}
36if (!defined('NOREQUIREHTML')) {
37 define('NOREQUIREHTML', '1');
38}
39
40
41// Load Dolibarr environment
42require '../../main.inc.php';
43require_once DOL_DOCUMENT_ROOT.'/core/lib/geturl.lib.php';
44require_once DOL_DOCUMENT_ROOT.'/blockedlog/class/blockedlog.class.php';
45require_once DOL_DOCUMENT_ROOT.'/blockedlog/class/authority.class.php';
46
47
48if (!getDolGlobalString('BLOCKEDLOG_AUTHORITY_URL')) {
49 exit('BLOCKEDLOG_AUTHORITY_URL not set');
50}
51
52
53/*
54 * View
55 */
56
58
59$auth = new BlockedLogAuthority($db);
60$auth->syncSignatureWithAuthority();
61
62$block_static = new BlockedLog($db);
63
64$blocks = $block_static->getLog('just_certified', 0, 0, 'rowid', 'ASC');
65
66$auth->signature = $block_static->getSignature();
67
68if (is_array($blocks)) {
69 foreach ($blocks as &$b) {
70 $auth->blockchain .= $b->signature;
71 }
72}
73
74$hash = $auth->getBlockchainHash();
75
76// Call external authority
77$url = getDolGlobalString('BLOCKEDLOG_AUTHORITY_URL') . '/blockedlog/ajax/authority.php?s='.urlencode($auth->signature).'&h='.urlencode($hash);
78
79$resarray = getURLContent($url, 'GET', '', 1, array(), array(), 2);
80$res = $resarray['content'];
81
82//echo $url;
83echo 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.