--- /tmp/dsg/dolibarr/htdocs/opensurvey/wizard/github_choix_autre.php +++ /tmp/dsg/dolibarr/htdocs/opensurvey/wizard/client_choix_autre.php @@ -36,17 +36,14 @@ * Action */ -$arrayofchoices = GETPOST('choix', 'array'); -$arrayoftypecolumn = GETPOST('typecolonne', 'array'); - // Set session vars if (isset($_SESSION["nbrecases"])) { for ($i = 0; $i < $_SESSION["nbrecases"]; $i++) { - if (isset($arrayofchoices[$i])) { - $_SESSION["choix".$i] = $arrayofchoices[$i]; + if (isset($_POST["choix"][$i])) { + $_SESSION["choix$i"] = $_POST["choix"][$i]; } - if (isset($arrayoftypecolumn[$i])) { - $_SESSION["typecolonne".$i] = $arrayoftypecolumn[$i]; + if (isset($_POST["typecolonne"][$i])) { + $_SESSION["typecolonne$i"] = $_POST["typecolonne"][$i]; } } } else { //nombre de cases par défaut @@ -59,16 +56,16 @@ } // Create survey into database -if (GETPOSTISSET("confirmecreation")) +if (isset($_POST["confirmecreation"])) { //recuperation des données de champs textes $toutchoix = ''; for ($i = 0; $i < $_SESSION["nbrecases"] + 1; $i++) { - if (!empty($arrayofchoices[$i])) + if (!empty($_POST["choix"][$i])) { $toutchoix .= ','; - $toutchoix .= str_replace(array(",", "@"), " ", $arrayofchoices[$i]).(empty($arrayoftypecolumn[$i]) ? '' : '@'.$arrayoftypecolumn[$i]); + $toutchoix .= str_replace(array(",", "@"), " ", $_POST["choix"][$i]).(empty($_POST["typecolonne"][$i]) ? '' : '@'.$_POST["typecolonne"][$i]); } } @@ -79,7 +76,7 @@ $testremplissage = ''; for ($i = 0; $i < $_SESSION["nbrecases"]; $i++) { - if (isset($arrayofchoices[$i])) + if (isset($_POST["choix"][$i])) { $testremplissage = "ok"; } @@ -97,6 +94,9 @@ } } + + + /* * View */ @@ -107,7 +107,7 @@ $arrayofcss = array('/opensurvey/css/style.css'); llxHeader('', $langs->trans("OpenSurvey"), "", '', 0, 0, $arrayofjs, $arrayofcss); -if (empty($_SESSION['title'])) +if (empty($_SESSION['titre'])) { dol_print_error('', $langs->trans('ErrorOpenSurveyFillFirstSection')); llxFooter(); --- /tmp/dsg/dolibarr/htdocs/opensurvey/wizard/github_choix_date.php +++ /tmp/dsg/dolibarr/htdocs/opensurvey/wizard/client_choix_date.php @@ -46,7 +46,6 @@ if (issetAndNoEmpty('totalchoixjour', $_SESSION) === true && issetAndNoEmpty('nbrecaseshoraires', $_SESSION) === true) { $nbofchoice = count($_SESSION["totalchoixjour"]); - $errheure = array(); for ($i = 0; $i < $nbofchoice; $i++) { @@ -55,18 +54,16 @@ { $_SESSION["horaires$i"][$j] = $_POST["horaires$i"][$j]; - $tmphorairesi = GETPOST('horaires'.$i, 'array'); - - if (!is_array($tmphorairesi) || empty($tmphorairesi[$j])) { + $case = $j + 1; + + if (isset($_POST['horaires'.$i]) === false || isset($_POST['horaires'.$i][$j]) === false) { $errheure[$i][$j] = true; $erreur = true; continue; } - // A range like 8:00-11:00 - $creneaux = array(); - $heures = array(); - if (preg_match("/(\d{1,2}:\d{2})-(\d{1,2}:\d{2})/", $tmphorairesi[$j], $creneaux)) { + //si c'est un creneau type 8:00-11:00 + if (preg_match("/(\d{1,2}:\d{2})-(\d{1,2}:\d{2})/", $_POST["horaires$i"][$j], $creneaux)) { //on recupere les deux parties du preg_match qu'on redécoupe autour des ":" $debutcreneau = explode(":", $creneaux[1]); $fincreneau = explode(":", $creneaux[2]); @@ -79,7 +76,7 @@ $errheure[$i][$j] = true; $erreur = true; } - } elseif (preg_match(";^(\d{1,2}h\d{0,2})-(\d{1,2}h\d{0,2})$;i", $tmphorairesi[$j], $creneaux)) { //si c'est un creneau type 8h00-11h00 + } elseif (preg_match(";^(\d{1,2}h\d{0,2})-(\d{1,2}h\d{0,2})$;i", $_POST["horaires$i"][$j], $creneaux)) { //si c'est un creneau type 8h00-11h00 //on recupere les deux parties du preg_match qu'on redécoupe autour des "H" $debutcreneau = preg_split("/h/i", $creneaux[1]); $fincreneau = preg_split("/h/i", $creneaux[2]); @@ -92,7 +89,7 @@ $errheure[$i][$j] = true; $erreur = true; } - } elseif (preg_match(";^(\d{1,2}):(\d{2})$;", $tmphorairesi[$j], $heures)) { //si c'est une heure simple type 8:00 + } elseif (preg_match(";^(\d{1,2}):(\d{2})$;", $_POST["horaires$i"][$j], $heures)) { //si c'est une heure simple type 8:00 //si valeures correctes, on entre les données dans la variables de session if ($heures[1] < 24 && $heures[2] < 60) { $_SESSION["horaires$i"][$j] = $heures[0]; @@ -100,7 +97,7 @@ $errheure[$i][$j] = true; $erreur = true; } - } elseif (preg_match(";^(\d{1,2})h(\d{0,2})$;i", $tmphorairesi[$j], $heures)) { //si c'est une heure encore plus simple type 8h + } elseif (preg_match(";^(\d{1,2})h(\d{0,2})$;i", $_POST["horaires$i"][$j], $heures)) { //si c'est une heure encore plus simple type 8h //si valeures correctes, on entre les données dans la variables de session if ($heures[1] < 24 && $heures[2] < 60) { $_SESSION["horaires$i"][$j] = $heures[0]; @@ -108,7 +105,7 @@ $errheure[$i][$j] = true; $erreur = true; } - } elseif (preg_match(";^(\d{1,2})-(\d{1,2})$;", $tmphorairesi[$j], $heures)) { //si c'est un creneau simple type 8-11 + } elseif (preg_match(";^(\d{1,2})-(\d{1,2})$;", $_POST["horaires$i"][$j], $heures)) { //si c'est un creneau simple type 8-11 //si valeures correctes, on entre les données dans la variables de session if ($heures[1] < $heures[2] && $heures[1] < 24 && $heures[2] < 24) { $_SESSION["horaires$i"][$j] = $heures[0]; @@ -116,7 +113,7 @@ $errheure[$i][$j] = true; $erreur = true; } - } elseif (preg_match(";^(\d{1,2})h-(\d{1,2})h$;", $tmphorairesi[$j], $heures)) { //si c'est un creneau H type 8h-11h + } elseif (preg_match(";^(\d{1,2})h-(\d{1,2})h$;", $_POST["horaires$i"][$j], $heures)) { //si c'est un creneau H type 8h-11h //si valeures correctes, on entre les données dans la variables de session if ($heures[1] < $heures[2] && $heures[1] < 24 && $heures[2] < 24) { $_SESSION["horaires$i"][$j] = $heures[0]; @@ -124,7 +121,7 @@ $errheure[$i][$j] = true; $erreur = true; } - } elseif ($tmphorairesi[$j] == "") { //Si la case est vide + } elseif ($_POST["horaires$i"][$j] == "") { //Si la case est vide unset($_SESSION["horaires$i"][$j]); } else { //pour tout autre format, message d'erreur $errheure[$i][$j] = true; @@ -163,8 +160,7 @@ } //If just one day and no other time options, error message - $tmphoraires0 = GETPOST('horaires0', 'array'); - if (count($_SESSION["totalchoixjour"]) == "1" && $tmphoraires0[0] == "" && $tmphoraires0[1] == "" && $tmphoraires0[2] == "" && $tmphoraires0[3] == "" && $tmphoraires0[4] == "") { + if (count($_SESSION["totalchoixjour"]) == "1" && $_POST["horaires0"][0] == "" && $_POST["horaires0"][1] == "" && $_POST["horaires0"][2] == "" && $_POST["horaires0"][3] == "" && $_POST["horaires0"][4] == "") { setEventMessages($langs->trans("MoreChoices"), null, 'errors'); $erreur = true; } @@ -199,7 +195,7 @@ * View */ -if (!isset($_SESSION['description']) && !isset($_SESSION['mail'])) +if (!isset($_SESSION['commentaires']) && !isset($_SESSION['mail'])) { dol_print_error('', $langs->trans('ErrorOpenSurveyFillFirstSection')); exit; @@ -213,7 +209,8 @@ if (!isset($_SESSION["nbrecaseshoraires"])) { $_SESSION["nbrecaseshoraires"] = 5; -} elseif (GETPOST('ajoutcases') && $_SESSION["nbrecaseshoraires"] == 5) +} +elseif (GETPOST('ajoutcases') && $_SESSION["nbrecaseshoraires"] == 5) { $_SESSION["nbrecaseshoraires"] = 10; } @@ -322,7 +319,9 @@ if (is_integer($_SESSION["mois"]) && $_SESSION["mois"] > 0 && $_SESSION["mois"] < 13) { $motmois = dol_print_date(mktime(0, 0, 0, $_SESSION["mois"], 10), '%B'); -} else { +} +else +{ $motmois = dol_print_date(dol_now(), '%B'); } @@ -351,7 +350,7 @@ print ''."\n"; print ''."\n"; -print '
'."\n"; +print '
'."\n"; print ''."\n"; // The div class=center has no effect on table, so we must keep the align=center for table print ''."\n"; @@ -486,7 +485,7 @@ if (($numerojour >= $jourAJ && $_SESSION["mois"] == $moisAJ && $_SESSION["annee"] == $anneeAJ) || ($_SESSION["mois"] > $moisAJ && $_SESSION["annee"] == $anneeAJ) || $_SESSION["annee"] > $anneeAJ) { print ''."\n"; } else { - // grey button + // grey button print ''."\n"; } } --- /tmp/dsg/dolibarr/htdocs/opensurvey/wizard/github_create_survey.php +++ /tmp/dsg/dolibarr/htdocs/opensurvey/wizard/client_create_survey.php @@ -35,14 +35,16 @@ $langs->load("opensurvey"); -$title = GETPOST('title'); -$description = GETPOST('description', 'restricthtml'); -$mailsonde = GETPOST('mailsonde'); -$creation_sondage_date = GETPOST('creation_sondage_date'); -$creation_sondage_autre = GETPOST('creation_sondage_autre'); - -// We init some session variable to avoir warning -$session_var = array('title', 'description', 'mailsonde'); +// On teste toutes les variables pour supprimer l'ensemble des warnings PHP +// On transforme en entites html les données afin éviter les failles XSS +$post_var = array('titre', 'commentaires', 'mailsonde', 'creation_sondage_date', 'creation_sondage_autre'); +foreach ($post_var as $var) +{ + $$var = GETPOST($var); +} + +// On initialise egalement la session car sinon bonjour les warning :-) +$session_var = array('titre', 'commentaires', 'mailsonde'); foreach ($session_var as $var) { if (isset($_SESSION[$var])) $_SESSION[$var] = null; @@ -53,10 +55,10 @@ $cochemail = ''; // Jump to correct page -if (!empty($creation_sondage_date) || !empty($creation_sondage_autre)) -{ - $_SESSION["title"] = $title; - $_SESSION["description"] = $description; +if (GETPOST("creation_sondage_date") || GETPOST("creation_sondage_autre")) +{ + $_SESSION["titre"] = $titre; + $_SESSION["commentaires"] = $commentaires; if (GETPOST('mailsonde') == 'on') { $_SESSION["mailsonde"] = true; @@ -86,7 +88,9 @@ { $testdate = true; $_SESSION['champdatefin'] = dol_print_date($champdatefin, 'dayrfc'); - } else { + } + else + { $testdate = true; $_SESSION['champdatefin'] = dol_print_date($champdatefin, 'dayrfc'); //$testdate = false; @@ -99,7 +103,7 @@ setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv("ExpireDate")), null, 'errors'); } - if ($title && $testdate) + if ($titre && $testdate) { if (!empty($creation_sondage_date)) { @@ -134,20 +138,20 @@ print ''."\n"; print ''; -print dol_get_fiche_head(); +dol_fiche_head(); // Affichage des différents champs textes a remplir print '
'.$numerojour.'
'."\n"; -print ''."\n"; -if (!$_SESSION["title"] && (GETPOST('creation_sondage_date') || GETPOST('creation_sondage_autre'))) +print ''."\n"; +if (!$_SESSION["titre"] && (GETPOST('creation_sondage_date') || GETPOST('creation_sondage_autre'))) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("PollTitle")), null, 'errors'); } print ''."\n"; print ''."\n"; print ''."\n"; @@ -159,11 +163,11 @@ print ''."\n"; print '
'.$langs->trans("PollTitle").'
'.$langs->trans("PollTitle").'
'.$langs->trans("Description").''; -$doleditor = new DolEditor('description', $_SESSION["description"], '', 120, 'dolibarr_notes', 'In', 1, 1, 1, ROWS_7, '90%'); +$doleditor = new DolEditor('commentaires', $_SESSION["commentaires"], '', 120, 'dolibarr_notes', 'In', 1, 1, 1, ROWS_7, '90%'); $doleditor->Create(0, ''); print '
'."\n"; -print dol_get_fiche_end(); +dol_fiche_end(); //focus javascript sur le premier champ print ''."\n"; print '
'."\n"; @@ -175,11 +179,11 @@ print ' '.$langs->trans("ToReceiveEMailForEachVote").'
'."\n"; if ($_SESSION['allow_comments']) $allow_comments = 'checked'; -if (GETPOSTISSET('allow_comments')) $allow_comments = GETPOST('allow_comments') ? 'checked' : ''; +if (isset($_POST['allow_comments'])) $allow_comments = GETPOST('allow_comments') ? 'checked' : ''; print ' '.$langs->trans('CanComment').'
'."\n"; if ($_SESSION['allow_spy']) $allow_spy = 'checked'; -if (GETPOSTISSET('allow_spy')) $allow_spy = GETPOST('allow_spy') ? 'checked' : ''; +if (isset($_POST['allow_spy'])) $allow_spy = GETPOST('allow_spy') ? 'checked' : ''; print ' '.$langs->trans('CanSeeOthersVote').'
'."\n"; if (GETPOST('choix_sondage')) @@ -188,7 +192,9 @@ else print ''; print ''; print '
trans("TypeDate") : $langs->trans("TypeClassic")).')">'; -} else { +} +else +{ // Show image to selecte between date survey or other survey print '
'."\n"; print ' '."\n";
'.$langs->trans("CreateSurveyDate").'