include_once 'bandeaux.php';
}
// Step 1/4 : error if $_SESSION from info_sondage are not valid
if (empty($_SESSION['form']->title) || empty($_SESSION['form']->admin_name) || ($config['use_smtp'] ? empty($_SESSION['form']->admin_mail) : false)) {
    Utils::print_header(__('Error', 'Error!'));
    bandeau_titre(__('Error', 'Error!'));
    echo '
    <div class="alert alert-danger">
        <h3>' . __('Error', 'You haven\'t filled the first section of the poll creation.') . ' !</h3>
        <p>' . __('Generic', 'Back to the homepage of') . ' <a href="' . Utils::get_server_name() . '"> ' . NOMAPPLICATION . '</a></p>
    </div>' . "\n";
    bandeau_pied();
} else {
    // Min/Max archive date
    $min_expiry_time = $pollService->minExpiryDate();
    $max_expiry_time = $pollService->maxExpiryDate();
    // The poll format is AUTRE (other)
    if ($_SESSION['form']->format !== 'A') {
        $_SESSION['form']->format = 'A';
        $_SESSION['form']->clearChoices();
    }
    // Step 4 : Data prepare before insert in DB
    if (isset($_POST['confirmecreation'])) {
        // Define expiration date
        $enddate = filter_input(INPUT_POST, 'enddate', FILTER_VALIDATE_REGEXP, ['options' => ['regexp' => '#^[0-9]{2}/[0-9]{2}/[0-9]{4}$#']]);
        if (!empty($enddate)) {
            $registredate = explode('/', $enddate);
            if (is_array($registredate) && count($registredate) == 3) {
                $time = mktime(0, 0, 0, $registredate[1], $registredate[0], $registredate[2]);
                if ($time < $min_expiry_time) {
                    $_SESSION['form']->end_date = $min_expiry_time;