title) || empty($_SESSION['form']->admin_name) || (($config['use_smtp']) ? empty($_SESSION['form']->admin_mail) : false)) { Utils::print_header(__("Error!")); bandeau_titre(__("Error!")); echo '

' . __('You haven\'t filled the first section of the poll creation.') . ' !

' . __('Back to the homepage of') . ' ' . NOMAPPLICATION . '

' . "\n"; bandeau_pied(); } else { $min_time = time() + 86400; $max_time = time() + (86400 * $config['default_poll_duration']); // 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}$#']]); $min_time = time() + (24 * 60 * 60); $max_time = time() + (86400 * $config['default_poll_duration']); 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_time) { $_SESSION['form']->end_date = $min_time; } elseif ($max_time < $time) { $_SESSION['form']->end_date = $max_time; } else { $_SESSION['form']->end_date = $time; } } } if (empty($_SESSION['form']->end_date)) { // By default, expiration date is 6 months after last day $_SESSION['form']->end_date = $max_time; } // format du sondage AUTRE $_SESSION['form']->format = 'A'; // Insert poll in database $ids = $pollService->createPoll($_SESSION['form']); $poll_id = $ids[0]; $admin_poll_id = $ids[1]; // Send confirmation by mail if enabled if ($config['use_smtp'] === true) { $message = __("This is the message you have to send to the people you want to poll. \nNow, you have to send this message to everyone you want to poll."); $message .= "\n\n"; $message .= stripslashes(html_entity_decode($_SESSION['form']->admin_name, ENT_QUOTES, "UTF-8")) . ' ' . __('hast just created a poll called') . ' : "' . stripslashes(htmlspecialchars_decode($_SESSION['form']->title, ENT_QUOTES)) . "\".\n"; $message .= __('Thanks for filling the poll at the link above') . " :\n\n%s\n\n" . __('Thanks for your confidence.') . "\n" . NOMAPPLICATION; $message_admin = __("This message should NOT be sent to the polled people. It is private for the poll's creator.\n\nYou can now modify it at the link above"); $message_admin .= " :\n\n" . "%s \n\n" . __('Thanks for your confidence.') . "\n" . NOMAPPLICATION; $message = sprintf($message, Utils::getUrlSondage($poll_id)); $message_admin = sprintf($message_admin, Utils::getUrlSondage($admin_poll_id, true)); if ($mailService->isValidEmail($_SESSION['form']->admin_mail)) { $mailService->send($_SESSION['form']->admin_mail, '[' . NOMAPPLICATION . '][' . __('Author\'s message') . '] ' . __('Poll') . ' : ' . stripslashes(htmlspecialchars_decode($_SESSION['form']->title, ENT_QUOTES)), $message_admin); $mailService->send($_SESSION['form']->admin_mail, '[' . NOMAPPLICATION . '][' . __('For sending to the polled users') . '] ' . __('Poll') . ' : ' . stripslashes(htmlspecialchars_decode($_SESSION['form']->title, ENT_QUOTES)), $message); } } // Clean Form data in $_SESSION unset($_SESSION['form']); // Delete old polls $purgeService->purgeOldPolls(); // Redirect to poll administration header('Location:' . Utils::getUrlSondage($admin_poll_id, true)); exit; } // Step 3/4 : Confirm poll creation and choose a removal date else if (isset($_POST['fin_sondage_autre'])) { Utils::print_header(__('Step 3', 'Removal date and confirmation (3 on 3)')); bandeau_titre(__('Step 3', 'Removal date and confirmation (3 on 3)')); // Store choices in $_SESSION if (isset($_POST['choices'])) { $_SESSION['form']->clearChoices(); foreach ($_POST['choices'] as $c) { if (!empty($c)) { $c = strip_tags($c); $choice = new Choice($c); $_SESSION['form']->addChoice($choice); } } } // Expiration date is initialised with config parameter. Value will be modified in step 4 if user has defined an other date $_SESSION['form']->end_date = time() + (86400 * $config['default_poll_duration']); //60 sec * 60 min * 24 hours * config // Summary $summary = '
    '; foreach ($_SESSION['form']->getChoices() as $choice) { preg_match_all('/\[!\[(.*?)\]\((.*?)\)\]\((.*?)\)/', $choice->getName(), $md_a_img); // Markdown [![alt](src)](href) preg_match_all('/!\[(.*?)\]\((.*?)\)/', $choice->getName(), $md_img); // Markdown ![alt](src) preg_match_all('/\[(.*?)\]\((.*?)\)/', $choice->getName(), $md_a); // Markdown [text](href) if (isset($md_a_img[2][0]) && $md_a_img[2][0] != '' && isset($md_a_img[3][0]) && $md_a_img[3][0] != '') { // [![alt](src)](href) $li_subject_text = (isset($md_a_img[1][0]) && $md_a_img[1][0] != '') ? stripslashes($md_a_img[1][0]) : __('Generic', 'Choice') . ' ' . ($i + 1); $li_subject_html = '' . $li_subject_text . ''; } elseif (isset($md_img[2][0]) && $md_img[2][0] != '') { // ![alt](src) $li_subject_text = (isset($md_img[1][0]) && $md_img[1][0] != '') ? stripslashes($md_img[1][0]) : __('Generic', 'Choice') . ' ' . ($i + 1); $li_subject_html = '' . $li_subject_text . ''; } elseif (isset($md_a[2][0]) && $md_a[2][0] != '') { // [text](href) $li_subject_text = (isset($md_a[1][0]) && $md_a[1][0] != '') ? stripslashes($md_a[1][0]) : __('Generic', 'Choice') . ' ' . ($i + 1); $li_subject_html = '' . $li_subject_text . ''; } else { // text only $li_subject_text = stripslashes($choice->getName()); $li_subject_html = $li_subject_text; } $summary .= '
  1. ' . $li_subject_html . '
  2. ' . "\n"; } $summary .= '
'; $end_date_str = utf8_encode(strftime('%d/%m/%Y', $max_time)); //textual date echo '

' . __('Step 3', 'List of your choices') . '

' . $summary . '

' . __('Step 3', 'Your poll will be automatically removed after') . ' ' . $config['default_poll_duration'] . ' ' . __('Generic', 'days') . '.
' . __('Step 3', 'You can set a closer removal date for it.') . '

' . __('Date', 'dd/mm/yyyy') . '

' . __('Step 3', 'Once you have confirmed the creation of your poll, you will be automatically redirected on the administration page of your poll.') . '

'; if ($config['use_smtp'] == true) { echo '

' . __('Step 3', 'Then, you will receive quickly two emails: one contening the link of your poll for sending it to the voters, the other contening the link to the administration page of your poll.') . '

'; } echo '

' . "\n"; bandeau_pied(); // Step 2/4 : Select choices of the poll } else { Utils::print_header(__('Step 2 classic', 'Poll subjects (2 on 3)')); bandeau_titre(__('Step 2 classic', 'Poll subjects (2 on 3)')); echo '
'; echo '

' . __('Step 2 classic', 'To make a generic poll you need to propose at least two choices between differents subjects.') . '

' . __('Step 2 classic', 'You can add or remove additional choices with the buttons') . ' ' . __('Generic', 'Remove') . ' ' . __('Generic', 'Add') . '

'; if ($config['user_can_add_img_or_link']) { echo '

' . __('Step 2 classic', 'It\'s possible to propose links or images by using') . ' ' . __('Step 2 classic', 'the Markdown syntax') . '.

'; } echo '
' . "\n"; // Fields choices : 5 by default $choices = $_SESSION['form']->getChoices(); $nb_choices = max(count($choices), 5); for ($i = 0; $i < $nb_choices; $i++) { $choice = isset($choices[$i]) ? $choices[$i] : new Choice(); echo '
'; if ($config['user_can_add_img_or_link']) { echo ' '; } echo '
' . "\n"; } echo '
' . __('Generic', 'Back') . '
' . "\n"; bandeau_pied(); } }