2020-11-29 11:25:34 +01:00
|
|
|
<?php
|
2024-02-12 20:46:07 +01:00
|
|
|
|
2020-11-29 11:25:34 +01:00
|
|
|
/* fixe un timer */
|
|
|
|
|
2024-02-12 20:46:07 +01:00
|
|
|
function settimer($TimerName, $String)
|
2020-11-29 11:25:34 +01:00
|
|
|
{
|
2024-02-12 20:46:07 +01:00
|
|
|
$FileTimerName = "modules/timers/$TimerName.csv";
|
2020-11-29 11:25:34 +01:00
|
|
|
|
2024-03-30 21:59:38 +01:00
|
|
|
$Date = date_format(date_create(), "YmdHis");
|
2020-11-29 11:25:34 +01:00
|
|
|
|
2024-02-12 20:46:07 +01:00
|
|
|
$fp = fopen("$FileTimerName", "w+");
|
|
|
|
$Ligne = sprintf("\"".$Date."\",\"".$String."\"\n");
|
|
|
|
fwrite($fp, $Ligne);
|
|
|
|
fclose($fp);
|
|
|
|
// echo "fichier créé<br>";
|
2020-11-29 11:25:34 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* renvoie $string si le temps n'est pas écoulé, ou FALSE sinon */
|
|
|
|
|
2024-02-12 20:46:07 +01:00
|
|
|
function timer($TimerName, $TimerNb)
|
2020-11-29 11:25:34 +01:00
|
|
|
{
|
|
|
|
|
2024-02-12 20:46:07 +01:00
|
|
|
$FileTimerN = "modules/timers/$TimerName.csv";
|
2020-11-29 11:25:34 +01:00
|
|
|
|
2024-03-30 21:59:38 +01:00
|
|
|
$Date = date_format(date_create(), "YmdHis");
|
2020-11-29 11:25:34 +01:00
|
|
|
|
2024-02-12 20:46:07 +01:00
|
|
|
if (!file_exists("$FileTimerN")) {
|
|
|
|
$timer = false;
|
|
|
|
} else {
|
|
|
|
// lecture de la date stockée dans le fichier
|
|
|
|
$fp = fopen("$FileTimerN", "r");
|
|
|
|
$data = fgetcsv($fp, 1000, ",");
|
|
|
|
fclose($fp);
|
2020-11-29 11:25:34 +01:00
|
|
|
|
2024-02-12 20:46:07 +01:00
|
|
|
$FileDate = $data[0];
|
2024-03-30 21:59:38 +01:00
|
|
|
$Date = date_format(date_create(), "YmdHis");
|
2020-11-29 11:25:34 +01:00
|
|
|
|
2024-02-12 20:46:07 +01:00
|
|
|
$String = $data[1];
|
2020-11-29 11:25:34 +01:00
|
|
|
|
2024-02-12 20:46:07 +01:00
|
|
|
if ($Date >= ($FileDate + $TimerNb)) {
|
|
|
|
// echo "date dépassée:".$Date." >= ".($FileDate+$TimerNb)."<br>";
|
|
|
|
$timer = false;
|
|
|
|
} else {
|
|
|
|
$timer = $String;
|
2020-11-29 11:25:34 +01:00
|
|
|
}
|
2024-02-12 20:46:07 +01:00
|
|
|
}
|
2020-11-29 11:25:34 +01:00
|
|
|
|
2024-02-12 20:46:07 +01:00
|
|
|
return $timer;
|
2020-11-29 11:25:34 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* renvoie l'heure française (format HH:MM) */
|
|
|
|
|
|
|
|
function iheure()
|
|
|
|
{
|
2024-02-12 20:46:07 +01:00
|
|
|
if ($HTTP_GET_VARS["IFRANCE"] == "1") {
|
|
|
|
$iheure = $I_HEURE_UK;
|
|
|
|
} else {
|
|
|
|
$iheure = date("H:i");
|
|
|
|
}
|
|
|
|
return $iheure;
|
2020-11-29 11:25:34 +01:00
|
|
|
}
|