pingresult.php 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. <?php
  2. /* Copyright (C) 2019-2022 Laurent Destailleur <eldy@users.sourceforge.net>
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation; either version 3 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  16. */
  17. /**
  18. * \file htdocs/core/ajax/pingresult.php
  19. * \brief Page called after a ping was done in js to the official dolibarr ping service.
  20. * This ajax URL is called with parameter 'firstpingok' or 'firstpingko' depending on the result of the ping.
  21. */
  22. if (!defined('NOTOKENRENEWAL')) {
  23. define('NOTOKENRENEWAL', '1'); // Disables token renewal
  24. }
  25. if (!defined('NOREQUIREMENU')) {
  26. define('NOREQUIREMENU', '1');
  27. }
  28. if (!defined('NOREQUIREHTML')) {
  29. define('NOREQUIREHTML', '1');
  30. }
  31. if (!defined('NOREQUIREAJAX')) {
  32. define('NOREQUIREAJAX', '1');
  33. }
  34. if (!defined('NOREQUIRESOC')) {
  35. define('NOREQUIRESOC', '1');
  36. }
  37. if (!defined('NOREQUIRETRAN')) {
  38. define('NOREQUIRETRAN', '1');
  39. }
  40. require '../../main.inc.php';
  41. require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
  42. $action = GETPOST('action', 'aZ09');
  43. $hash_unique_id = GETPOST('hash_unique_id', 'alpha');
  44. $hash_algo = GETPOST('hash_algo', 'alpha');
  45. // Security check
  46. // None.
  47. $now = dol_now();
  48. /*
  49. * View
  50. */
  51. top_httphead();
  52. print '<!-- Ajax page called with url '.dol_escape_htmltag($_SERVER["PHP_SELF"]).'?'.dol_escape_htmltag($_SERVER["QUERY_STRING"]).' -->'."\n";
  53. // If ok
  54. if ($action == 'firstpingok') {
  55. // Note: pings are per installed instances / entity.
  56. // Once this constants are set, no more ping will be tried (except if we add parameter &forceping=1 on URL). So we can say this are 'first' ping.
  57. dolibarr_set_const($db, 'MAIN_FIRST_PING_OK_DATE', dol_print_date($now, 'dayhourlog', 'gmt'), 'chaine', 0, '', $conf->entity);
  58. dolibarr_set_const($db, 'MAIN_FIRST_PING_OK_ID', $hash_unique_id, 'chaine', 0, '', $conf->entity);
  59. print 'First ping OK saved for entity '.$conf->entity;
  60. } elseif ($action == 'firstpingko') {
  61. // If ko
  62. // Note: pings are by installation, done on entity 1.
  63. dolibarr_set_const($db, 'MAIN_LAST_PING_KO_DATE', dol_print_date($now, 'dayhourlog', 'gmt'), 'chaine', 0, '', $conf->entity); // erase last value
  64. print 'First ping KO saved for entity '.$conf->entity;
  65. } else {
  66. print 'Error action='.$action.' not supported';
  67. }