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