choix_sondage"> if ((isset($_GET['choix_sondage']) && $_GET['choix_sondage'] == 'date') || (isset($_POST["choix_sondage"]) && $_POST["choix_sondage"] == 'creation_sondage_date')) { $choix_sondage = "creation_sondage_date"; $_SESSION['form']->choix_sondage = $choix_sondage; } else { $choix_sondage = "creation_sondage_autre"; $_SESSION['form']->choix_sondage = $choix_sondage; } // We clean the data $poursuivre = filter_input(INPUT_POST, 'poursuivre', FILTER_VALIDATE_REGEXP, ['options' => ['regexp' => '/^(creation_sondage_date|creation_sondage_autre)$/']]); $title = filter_input(INPUT_POST, 'title', FILTER_SANITIZE_STRING); $name = filter_input(INPUT_POST, 'name', FILTER_VALIDATE_REGEXP, ['options' => ['regexp' => NAME_REGEX]]); $mail = filter_input(INPUT_POST, 'mail', FILTER_VALIDATE_EMAIL); $description = filter_input(INPUT_POST, 'description', FILTER_SANITIZE_STRING); $editable = filter_input(INPUT_POST, 'editable', FILTER_VALIDATE_REGEXP, ['options' => ['regexp' => BOOLEAN_REGEX]]); $receiveNewVotes = filter_input(INPUT_POST, 'receiveNewVotes', FILTER_VALIDATE_REGEXP, ['options' => ['regexp' => BOOLEAN_REGEX]]); $receiveNewComments = filter_input(INPUT_POST, 'receiveNewComments', FILTER_VALIDATE_REGEXP, ['options' => ['regexp' => BOOLEAN_REGEX]]); // On initialise également les autres variables $error_on_mail = false; $error_on_title = false; $error_on_name = false; $error_on_description = false; #tests if (!empty($_POST['poursuivre'])) { $_SESSION['form']->title = $title; $_SESSION['form']->admin_name = $name; $_SESSION['form']->admin_mail = $mail; $_SESSION['form']->description = $description; $_SESSION['form']->editable = ($editable !== null) ? true : false; $_SESSION['form']->receiveNewVotes = ($receiveNewVotes !== null) ? true : false; $_SESSION['form']->receiveNewComments = ($receiveNewComments !== null) ? true : false; if ($config['use_smtp']==true) { if (empty($mail)) { $error_on_mail = true; } } if ($title !== $_POST['title']) { $error_on_title = true; } if ($name !== $_POST['name']) { $error_on_name = true; } if ($description !== $_POST['description']) { $error_on_description = true; } // Si pas d'erreur dans l'adresse alors on change de page vers date ou autre if ($config['use_smtp'] == true) { $email_OK = $mail && !$error_on_mail; } else { $email_OK = true; } if ($title && $name && $email_OK && ! $error_on_title && ! $error_on_description && ! $error_on_name) { if ( $poursuivre == 'creation_sondage_date' ) { header('Location:choix_date.php'); exit(); } if ( $poursuivre == 'creation_sondage_autre' ) { header('Location:choix_autre.php'); exit(); } } else { // Title Erreur ! Utils::print_header( _('Error!').' - '._('Poll creation (1 on 3)') ); } } else { // Title OK (formulaire pas encore rempli) Utils::print_header( _('Poll creation (1 on 3)') ); } bandeau_titre( _('Poll creation (1 on 3)') ); /* * Préparation des messages d'erreur */ $errors = array ( 'title' => array ( 'msg' => '', 'aria' => '', 'class' => '' ), 'description' => array ( 'msg' => '', 'aria' => '', 'class' => '' ), 'name' => array ( 'msg' => '', 'aria' => '', 'class' => '' ), 'email' => array ( 'msg' => '', 'aria' => '', 'class' => '' ) ); if (!empty($_POST['poursuivre'])) { if (empty($_POST['title'])) { $errors['title']['aria'] = 'aria-describeby="poll_title_error" '; $errors['title']['class'] = ' has-error'; $errors['title']['msg'] = '

' . _('Enter a title') . '

'; } elseif ($error_on_title) { $errors['title']['aria'] = 'aria-describeby="poll_title_error" '; $errors['title']['class'] = ' has-error'; $errors['title']['msg'] = '

' . _('Something is wrong with the format') . '

'; } if ($error_on_description) { $errors['description']['aria'] = 'aria-describeby="poll_comment_error" '; $errors['description']['class'] = ' has-error'; $errors['description']['msg'] = '

' . _('Something is wrong with the format') . '

'; } if (empty($_POST['name'])) { $errors['name']['aria'] = 'aria-describeby="poll_name_error" '; $errors['name']['class'] = ' has-error'; $errors['name']['msg'] = '

' . _('Enter a name') . '

'; } elseif ($error_on_name) { $errors['name']['aria'] = 'aria-describeby="poll_name_error" '; $errors['name']['class'] = ' has-error'; $errors['name']['msg'] = '

' . _('Something is wrong with the format') . '

'; } if (empty($_POST['mail'])) { $errors['email']['aria'] = 'aria-describeby="poll_name_error" '; $errors['email']['class'] = ' has-error'; $errors['email']['msg'] = '

' . _('Enter an email address') . '

'; } elseif ($error_on_mail) { $errors['email']['aria'] = 'aria-describeby="poll_email_error" '; $errors['email']['class'] = ' has-error'; $errors['email']['msg'] = '

' . _('The address is not correct! You should enter a valid email address (like r.stallman@outlock.com) in order to receive the link to your poll.') . '

'; } } /* * Préparation en fonction des paramètres de session */ // REMOTE_USER ? /** * @return string */ if (USE_REMOTE_USER && isset($_SERVER['REMOTE_USER'])) { $input_name = ''.$_SESSION['form']->admin_name; $input_email = ''.$_SESSION['form']->admin_mail; } else { $input_name = ''; $input_email = ''; } // Checkbox checked ? if ($_SESSION['form']->editable) { $editable = 'checked'; } if ($_SESSION['form']->receiveNewVotes) { $receiveNewVotes = 'checked'; } if ($_SESSION['form']->receiveNewComments) { $receiveNewComments = 'checked'; } // Display form echo ' '; echo ' '; bandeau_pied();