dolibarr  16.0.5
pingresult.php
Go to the documentation of this file.
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 
24 if (!defined('NOTOKENRENEWAL')) {
25  define('NOTOKENRENEWAL', '1'); // Disables token renewal
26 }
27 if (!defined('NOREQUIREMENU')) {
28  define('NOREQUIREMENU', '1');
29 }
30 if (!defined('NOREQUIREHTML')) {
31  define('NOREQUIREHTML', '1');
32 }
33 if (!defined('NOREQUIREAJAX')) {
34  define('NOREQUIREAJAX', '1');
35 }
36 if (!defined('NOREQUIRESOC')) {
37  define('NOREQUIRESOC', '1');
38 }
39 if (!defined('NOREQUIRETRAN')) {
40  define('NOREQUIRETRAN', '1');
41 }
42 
43 require '../../main.inc.php';
44 require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
45 
46 $action = GETPOST('action', 'aZ09');
47 $hash_unique_id = GETPOST('hash_unique_id', 'alpha');
48 $hash_algo = GETPOST('hash_algo', 'alpha');
49 
50 
51 // Security check
52 // None.
53 
54 $now = dol_now();
55 
56 
57 /*
58  * View
59  */
60 
61 top_httphead();
62 
63 print '<!-- Ajax page called with url '.dol_escape_htmltag($_SERVER["PHP_SELF"]).'?'.dol_escape_htmltag($_SERVER["QUERY_STRING"]).' -->'."\n";
64 
65 // If ok
66 if ($action == 'firstpingok') {
67  // Note: pings are per installed instances / entity.
68  // 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.
69  dolibarr_set_const($db, 'MAIN_FIRST_PING_OK_DATE', dol_print_date($now, 'dayhourlog', 'gmt'), 'chaine', 0, '', $conf->entity);
70  dolibarr_set_const($db, 'MAIN_FIRST_PING_OK_ID', $hash_unique_id, 'chaine', 0, '', $conf->entity);
71 
72  print 'First ping OK saved for entity '.$conf->entity;
73 } elseif ($action == 'firstpingko') {
74  // If ko
75  // Note: pings are by installation, done on entity 1.
76  dolibarr_set_const($db, 'MAIN_LAST_PING_KO_DATE', dol_print_date($now, 'dayhourlog', 'gmt'), 'chaine', 0, '', $conf->entity); // erase last value
77  print 'First ping KO saved for entity '.$conf->entity;
78 } else {
79  print 'Error action='.$action.' not supported';
80 }
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
GETPOST
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
Definition: functions.lib.php:484
top_httphead
if(!defined('NOREQUIREMENU')) if(!function_exists("llxHeader")) top_httphead($contenttype='text/html', $forcenocache=0)
Show HTTP header.
Definition: main.inc.php:1407
dol_print_date
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
Definition: functions.lib.php:2514
dolibarr_set_const
dolibarr_set_const($db, $name, $value, $type='chaine', $visible=0, $note='', $entity=1)
Insert a parameter (key,value) into database (delete old key then insert it again).
Definition: admin.lib.php:627
dol_now
dol_now($mode='auto')
Return date for now.
Definition: functions.lib.php:2845