dolibarr  17.0.4
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  *
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 $res = require '../../master.inc.php';
40 
41 require_once DOL_DOCUMENT_ROOT.'/blockedlog/class/blockedlog.class.php';
42 require_once DOL_DOCUMENT_ROOT.'/blockedlog/class/authority.class.php';
43 
44 $user = new User($db);
45 $user->fetch(1); //TODO conf user authority
46 
47 
48 /*
49  * View
50  */
51 
52 top_httphead();
53 
54 $auth = new BlockedLogAuthority($db);
55 
56 $signature = GETPOST('s');
57 $newblock = GETPOST('b');
58 $hash = GETPOST('h');
59 
60 if ($auth->fetch(0, $signature) <= 0) {
61  $auth->signature = $signature;
62  $auth->create($user);
63 }
64 
65 
66 if (!empty($hash)) {
67  echo $auth->checkBlockchain($hash) ? 'hashisok' : 'hashisjunk';
68 } elseif (!empty($newblock)) {
69  if ($auth->checkBlock($newblock)) {
70  $auth->addBlock($newblock);
71  $auth->update($user);
72 
73  echo 'blockadded';
74  } else {
75  echo 'blockalreadyadded';
76  }
77 } else {
78  echo 'idontunderstandwhatihavetodo';
79 }
Class to manage certif authority.
Class to manage Dolibarr users.
Definition: user.class.php:47
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(!function_exists("llxHeader")) top_httphead($contenttype='text/html', $forcenocache=0)
Show HTTP header.
Definition: main.inc.php:1440