dolibarr 21.0.0-beta
authority.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 Frédéric France <frederic.france@free.fr>
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
40require '../../master.inc.php';
41
42require_once DOL_DOCUMENT_ROOT.'/blockedlog/class/blockedlog.class.php';
43require_once DOL_DOCUMENT_ROOT.'/blockedlog/class/authority.class.php';
52$user = new User($db);
53$user->fetch(1); //TODO conf user authority
54
55
56/*
57 * View
58 */
59
61
62$auth = new BlockedLogAuthority($db);
63
64$signature = GETPOST('s');
65$newblock = GETPOST('b');
66$hash = GETPOST('h');
67
68if ($auth->fetch(0, $signature) <= 0) {
69 $auth->signature = $signature;
70 $auth->create($user);
71}
72
73
74if (!empty($hash)) {
75 echo $auth->checkBlockchain($hash) ? 'hashisok' : 'hashisjunk';
76} elseif (!empty($newblock)) {
77 if ($auth->checkBlock($newblock)) {
78 $auth->addBlock($newblock);
79 $auth->update($user);
80
81 echo 'blockadded';
82 } else {
83 echo 'blockalreadyadded';
84 }
85} else {
86 echo 'idontunderstandwhatihavetodo';
87}
Class to manage certif authority.
Class to manage Dolibarr users.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
if(!defined( 'NOREQUIREMENU')) if(!empty(GETPOST('seteventmessages', 'alpha'))) if(!function_exists("llxHeader")) top_httphead($contenttype='text/html', $forcenocache=0)
Show HTTP header.