Files
ms1inscription-v5/auto_chronotrack_sync.php

45 lines
1.3 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
/**
* MSIN-4328 — Cron sync auto ChronoTrack (différentiel).
*
* Cron recommandé (toutes les minutes) :
* /usr/bin/curl -s https://VOTRE-DOMAINE/auto_chronotrack_sync.php > /dev/null 2>&1
*
* La fréquence réelle denvoi par événement est celle choisie dans ladmin
* (1 / 5 / 15 / 30 / 60 min) + date/heure de fin.
*/
ini_set('display_errors', 0);
ini_set('log_errors', 1);
ini_set('error_log', __DIR__ . '/log/php_log.txt');
@set_time_limit(300);
$strLockPath = rtrim(sys_get_temp_dir(), '/\\') . DIRECTORY_SEPARATOR . 'ms1_chronotrack_auto_sync.lock';
$fpLock = @fopen($strLockPath, 'c');
if ($fpLock === false || !flock($fpLock, LOCK_EX | LOCK_NB)) {
// Un passage précédent tourne encore — on saute ce tick.
if (is_resource($fpLock)) {
fclose($fpLock);
}
header('Content-Type: text/plain; charset=utf-8');
echo 'busy';
exit;
}
session_start();
require_once __DIR__ . '/php/inc_fonctions.php';
require_once __DIR__ . '/php/chronotrack_api/inc_bootstrap.php';
$arrResult = fxChronotrackApiSyncRunAutoCron();
$strLine = 'auto_chronotrack_sync [' . date('Y-m-d H:i:s') . '] '
. ($arrResult['message'] ?? 'done');
error_log($strLine);
header('Content-Type: text/plain; charset=utf-8');
echo $strLine . "\n";
flock($fpLock, LOCK_UN);
fclose($fpLock);