check_signature.php 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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. /**
  19. * \file htdocs/blockedlog/ajax/check_signature.php
  20. * \ingroup blockedlog
  21. * \brief This page is not used yet.
  22. */
  23. // This script is called with a POST method.
  24. // Directory to scan (full path) is inside POST['dir'].
  25. if (!defined('NOTOKENRENEWAL')) {
  26. define('NOTOKENRENEWAL', 1); // Disables token renewal
  27. }
  28. if (!defined('NOREQUIREMENU')) {
  29. define('NOREQUIREMENU', '1');
  30. }
  31. if (!defined('NOREQUIREHTML')) {
  32. define('NOREQUIREHTML', '1');
  33. }
  34. // Load Dolibarr environment
  35. require '../../main.inc.php';
  36. require_once DOL_DOCUMENT_ROOT.'/core/lib/geturl.lib.php';
  37. require_once DOL_DOCUMENT_ROOT.'/blockedlog/class/blockedlog.class.php';
  38. require_once DOL_DOCUMENT_ROOT.'/blockedlog/class/authority.class.php';
  39. if (!getDolGlobalString('BLOCKEDLOG_AUTHORITY_URL')) {
  40. exit('BLOCKEDLOG_AUTHORITY_URL not set');
  41. }
  42. /*
  43. * View
  44. */
  45. top_httphead();
  46. $auth = new BlockedLogAuthority($db);
  47. $auth->syncSignatureWithAuthority();
  48. $block_static = new BlockedLog($db);
  49. $blocks = $block_static->getLog('just_certified', 0, 0, 'rowid', 'ASC');
  50. $auth->signature = $block_static->getSignature();
  51. if (is_array($bocks)) {
  52. foreach ($blocks as &$b) {
  53. $auth->blockchain .= $b->signature;
  54. }
  55. }
  56. $hash = $auth->getBlockchainHash();
  57. // Call external authority
  58. $url = getDolGlobalString('BLOCKEDLOG_AUTHORITY_URL') . '/blockedlog/ajax/authority.php?s='.urlencode($auth->signature).'&h='.urlencode($hash);
  59. $resarray = getURLContent($url, 'GET', '', 1, array(), array(), 2);
  60. $res = $resarray['content'];
  61. //echo $url;
  62. echo dol_escape_htmltag($res);