if (!check_format_date($value, "days")) { echo "error"; } break; case 'time': if (!check_format_time("{$value}")) { echo "error"; } break; case 'same_time': $value = explode('_', $value); if (count($value) != 2) { echo "error"; break; } if (!check_times($value[0], $value[1])) { echo "error"; } break; case 'cyclic_time': if (!check_format_time("{$value}")) { echo "error"; } // Check if cyclic time is under 5minutes only if this limit is not deselected $main_error = ""; if (strcmp(get_configuration("REMOVE_5_MINUTE_LIMIT", $main_error), "False") == 0) { $tmp = str_replace(":", "", $value); if ($tmp < 500) { echo "2"; return 0; }
// si c'est le cas un seul événement couvre la journée: $optimize = true; unset($prog); $prog[] = array("start_time" => "{$cyclic_start}", "end_time" => "{$end_time_cyclic}", "value_program" => "{$value_program}", "selected_plug" => "{$selected_plug}", "type" => "{$type}", "number" => $program_index); } else { //Dans le cas d'un programme qui reboucle, on vérifie si les cycles ne se chevauchent pas, // si c'est le cas deux événements couvrent la journée: $optimize = true; unset($prog); $prog[] = array("start_time" => "{$cyclic_start}", "end_time" => "23:59:59", "value_program" => "{$value_program}", "selected_plug" => "{$selected_plug}", "type" => "{$type}", "number" => $program_index); $prog[] = array("start_time" => "00:00:00", "end_time" => "{$end_time_cyclic}", "value_program" => "{$value_program}", "selected_plug" => "{$selected_plug}", "type" => "{$type}", "number" => $program_index); } } if (!$optimize) { //Dans le cas ou les cycles ne rebouclent pas entre eux, on va les calculer et les insérer: $chtime = check_times($cyclic_start, $final_cyclic_end); if ($chtime == 2) { //Calcul de la plage de durée des actions, si la durée reboucle, la plage de durée = 86400 (1 jour en seconde) - (temps de départ - temps de fin) car cyclic_start > final_cyclic_end dans un rebouclage $elapsed_time = 86400 - (mktime(substr($cyclic_start, 0, 2), substr($cyclic_start, 3, 2), substr($cyclic_start, 6, 2)) - mktime(substr($final_cyclic_end, 0, 2), substr($final_cyclic_end, 3, 2), substr($final_cyclic_end, 6, 2))); if (date('His', $chk_stop) > date('H:i:s', $chk_start)) { $chk_while = $chk_stop - $chk_start; } else { $chk_while = mktime(23, 59, 59, 1, 1, 1970) - $chk_start + ($chk_stop - 86400); } } else { $elapsed_time = mktime(substr($final_cyclic_end, 0, 2), substr($final_cyclic_end, 3, 2), substr($final_cyclic_end, 6, 2)) - mktime(substr($cyclic_start, 0, 2), substr($cyclic_start, 3, 2), substr($cyclic_start, 6, 2)); $chk_while = $chk_stop - $chk_start; } $reboucle = false; while ($chk_while < $elapsed_time) { //On ne veut pas enregistrer le premier événement qui a déja été enregistré plus haut - utilisation de la variable chk_first: