From 7cee54901f48ae3f5c1ce711990ab0d210876fe9 Mon Sep 17 00:00:00 2001 From: Bob Le Bricodeur Date: Fri, 14 Nov 2014 22:34:40 +0100 Subject: [PATCH 01/10] Adaptation setlocale en fonction de l'environnement (Windows) --- app/inc/i18n.php | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/app/inc/i18n.php b/app/inc/i18n.php index 0986b29..647fd05 100644 --- a/app/inc/i18n.php +++ b/app/inc/i18n.php @@ -36,7 +36,15 @@ if (isset($_POST['lang']) && is_string($_POST['lang']) && in_array($_POST['lang' } -$locale = $mlocale . '.utf8'; +$locale = $mlocale . '.utf8';//unix format +if (strtoupper(substr(PHP_OS,0,3))=='WIN'){ //windows locale format, see http://msdn.microsoft.com/en-us/library/39cwe7zf%28v=vs.90%29.aspx + switch ($mlocale){ + case 'fr_FR' : $locale = "fra";break; + case 'en_GB' : $locale = "english";break; + case 'de_DE' : $locale = "deu";break; + case 'es_ES' : $locale = "esp";break; + } +} putenv('LANGUAGE='); setlocale(LC_ALL, $locale); setlocale(LC_TIME, $locale); @@ -48,7 +56,7 @@ bind_textdomain_codeset($domain, 'UTF-8'); textdomain($domain); /* temp, for compatibility :*/ -$a = explode('_', $locale); +$a = explode('_', $mlocale); $_SESSION['langue'] = strtoupper($a[0]); /* */ From 0239dd07351434f2f177671a63a42883d14597c4 Mon Sep 17 00:00:00 2001 From: Bob Le Bricodeur Date: Fri, 14 Nov 2014 23:56:47 +0100 Subject: [PATCH 02/10] Add environment variable to be able to switch between languages using Windows --- app/inc/i18n.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/app/inc/i18n.php b/app/inc/i18n.php index 647fd05..31c6f2d 100644 --- a/app/inc/i18n.php +++ b/app/inc/i18n.php @@ -37,15 +37,17 @@ if (isset($_POST['lang']) && is_string($_POST['lang']) && in_array($_POST['lang' } $locale = $mlocale . '.utf8';//unix format -if (strtoupper(substr(PHP_OS,0,3))=='WIN'){ //windows locale format, see http://msdn.microsoft.com/en-us/library/39cwe7zf%28v=vs.90%29.aspx +if (strtoupper(substr(PHP_OS,0,3))=='WIN'){ + putenv("LC_ALL=$mlocale"); //Windows env. needed to switch between languages switch ($mlocale){ - case 'fr_FR' : $locale = "fra";break; - case 'en_GB' : $locale = "english";break; + case 'fr_FR' : $locale = "fra";break; //$locale in windows locale format, needed to use php function that handle text : strftime() + case 'en_GB' : $locale = "english";break; //see http://msdn.microsoft.com/en-us/library/39cwe7zf%28v=vs.90%29.aspx case 'de_DE' : $locale = "deu";break; case 'es_ES' : $locale = "esp";break; } } -putenv('LANGUAGE='); + +putenv('LANGUAGE=');//sert à quoi? setlocale(LC_ALL, $locale); setlocale(LC_TIME, $locale); setlocale(LC_MESSAGES, $locale); From 5d981cb717777c547abfe86aa6301cb745a75433 Mon Sep 17 00:00:00 2001 From: Bob Le Bricodeur Date: Sat, 15 Nov 2014 00:50:27 +0100 Subject: [PATCH 03/10] UTF8 encode on Removal date for French chars on Months --- choix_autre.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/choix_autre.php b/choix_autre.php index 978ba66..fd69bd5 100644 --- a/choix_autre.php +++ b/choix_autre.php @@ -94,7 +94,7 @@ if (Utils::issetAndNoEmpty('titre', $_SESSION) === false || Utils::issetAndNoEmp // Expiration date is initialised with config parameter. Value will be modified in step 4 if user has defined an other date $_SESSION["champdatefin"]= time()+ (86400 * $config['default_poll_duration']); //60 sec * 60 min * 24 hours * config - $removal_date= strftime($date_format['txt_full'], ($_SESSION["champdatefin"]));//textual date + $removal_date= utf8_encode(strftime($date_format['txt_full'], ($_SESSION["champdatefin"])));//textual date // Summary $summary = '
    '; From af54981cf62b773dc7fdcdd3d6cdd991cd8d774b Mon Sep 17 00:00:00 2001 From: Bob Le Bricodeur Date: Sat, 15 Nov 2014 00:59:33 +0100 Subject: [PATCH 04/10] correction warning pour acces $config[use_smtp] depuis adminstuds.php --- adminstuds.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/adminstuds.php b/adminstuds.php index 0ea9a4c..7369316 100644 --- a/adminstuds.php +++ b/adminstuds.php @@ -79,11 +79,13 @@ $dsondage=$sondage->FetchObject(false); // Send email (only once during the session) to alert admin of the change he made. ==> two modifications (comment, title, description, ...) on differents polls in the same session will generate only one mail. $email_admin = $dsondage->mail_admin; $poll_title = $dsondage->titre; +$smtp_allowed = $config['use_smtp']; function send_mail_admin() { global $email_admin; global $poll_title; global $numsondageadmin; - if($config['use_smtp']==true){ + global $smtp_allowed; + if($smtp_allowed==true){ if(!isset($_SESSION["mail_admin_sent"])) { Utils::sendEmail( $email_admin, _("[ADMINISTRATOR] New settings for your poll") . ' ' . stripslashes( $poll_title ), From 52f421072615614725d82f4acd7632282d0db50f Mon Sep 17 00:00:00 2001 From: Bob Le Bricodeur Date: Sat, 15 Nov 2014 01:27:38 +0100 Subject: [PATCH 05/10] reuse condition from choix_autre.php for Step 1 validation --- choix_date.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/choix_date.php b/choix_date.php index 0531b4e..0280ab1 100644 --- a/choix_date.php +++ b/choix_date.php @@ -29,7 +29,7 @@ if (is_readable('bandeaux_local.php')) { } // Step 1/3 : error if $_SESSION from info_sondage are not valid -if (!Utils::issetAndNoEmpty('nom', $_SESSION) && !Utils::issetAndNoEmpty('adresse', $_SESSION) && !Utils::issetAndNoEmpty('commentaires', $_SESSION) && !Utils::issetAndNoEmpty('mail', $_SESSION)) { +if (Utils::issetAndNoEmpty('titre', $_SESSION) === false || Utils::issetAndNoEmpty('nom', $_SESSION) === false || (($config['use_smtp']) ? Utils::issetAndNoEmpty('adresse', $_SESSION) === false : false)) { Utils::print_header ( _("Error!") ); bandeau_titre(_("Error!")); From 67b72e5b067852c1be5aeea27bc063f3a957a664 Mon Sep 17 00:00:00 2001 From: Bob Le Bricodeur Date: Sat, 15 Nov 2014 01:38:23 +0100 Subject: [PATCH 06/10] remove warning "unknown index horaire0" one first access to choix_date.php --- choix_date.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/choix_date.php b/choix_date.php index 0280ab1..21d6064 100644 --- a/choix_date.php +++ b/choix_date.php @@ -213,8 +213,8 @@ if (Utils::issetAndNoEmpty('titre', $_SESSION) === false || Utils::issetAndNoEmp '."\n"; // Fields hours : 3 by default - for ($j=0;$j From 8910c69495c5777fbbd7b239940264b03021a5d9 Mon Sep 17 00:00:00 2001 From: Bob Le Bricodeur Date: Sat, 15 Nov 2014 01:40:59 +0100 Subject: [PATCH 07/10] UTF8_encode(removal date) for date poll --- choix_date.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/choix_date.php b/choix_date.php index 21d6064..b9f6314 100644 --- a/choix_date.php +++ b/choix_date.php @@ -124,7 +124,7 @@ if (Utils::issetAndNoEmpty('titre', $_SESSION) === false || Utils::issetAndNoEmp $temp_array = array_unique($_SESSION["totalchoixjour"]); sort($temp_array); - $removal_date=strftime($date_format['txt_full'], end($temp_array)+ (86400 * $config['default_poll_duration'])); + $removal_date=utf8_encode(strftime($date_format['txt_full'], end($temp_array)+ (86400 * $config['default_poll_duration']))); // Sumary $summary = '
      '; From bae0054b77af27e7cf9134e2f75804fc21536685 Mon Sep 17 00:00:00 2001 From: Bob Le Bricodeur Date: Sat, 15 Nov 2014 02:21:12 +0100 Subject: [PATCH 08/10] several warning displayed : "A non well formed numeric value encountered in adminstuds.php" remove all displayed warning by splitting day and hour in $current variable --- adminstuds.php | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/adminstuds.php b/adminstuds.php index 7369316..1af9393 100644 --- a/adminstuds.php +++ b/adminstuds.php @@ -838,45 +838,43 @@ if (substr($dsondage->format, 0, 1)=="D") { for ($i = 0; $i < count($toutsujet); $i++) { // Current date - $current = $toutsujet[$i]; - + $current = $toutsujet[$i];//format date@hour. ex : 2020292820@10:00 + $horoCur = explode("@",$current); //horoCur[0] = date, horoCur[1] = hour + if (isset($toutsujet[$i+1])){ + $next = $toutsujet[$i+1]; + $horoNext = explode("@",$next); + } $border[$i] = false; - $radio_title[$i] = strftime($date_format['txt_short'],$current); + $radio_title[$i] = strftime($date_format['txt_short'],$horoCur[0]); // Months $td_headers[$i] = 'M'.($i+1-$colspan_month); - if (isset($toutsujet[$i+1]) && strftime("%B", $current) == strftime("%B", $toutsujet[$i+1]) && strftime("%Y", $current) == strftime("%Y", $toutsujet[$i+1])){ + if (isset($toutsujet[$i+1]) && strftime("%B", $horoCur[0]) == strftime("%B", $horoNext[0]) && strftime("%Y", $horoCur[0]) == strftime("%Y", $horoNext[0])){ $colspan_month++; } else { $border[$i] = true; - $tr_months .= ''.strftime("%B",$current).' '.strftime("%Y", $current).''; + $tr_months .= ''.strftime("%B",$horoCur[0]).' '.strftime("%Y", $horoCur[0]).''; $colspan_month=1; } // Days $td_headers[$i] .= ' D'.($i+1-$colspan_day); - if (isset($toutsujet[$i+1]) && strftime($date_format['txt_day'],$current)==strftime($date_format['txt_day'],$toutsujet[$i+1]) && strftime("%B",$current)==strftime("%B",$toutsujet[$i+1])){ + if (isset($toutsujet[$i+1]) && strftime($date_format['txt_day'],$horoCur[0])==strftime($date_format['txt_day'],$horoNext[0]) && strftime("%B",$horoCur[0])==strftime("%B",$horoNext[0])){ $colspan_day++; } else { $rbd = ($border[$i]) ? ' rbd' : ''; - $tr_days .= ''.strftime($date_format['txt_day'],$current).''; + $tr_days .= ''.strftime($date_format['txt_day'],$horoCur[0]).''; $colspan_day=1; } // Hours $rbd = ($border[$i]) ? ' rbd' : ''; - if (strpos($current,'@') !== false) { - $hour = substr($current, strpos($current, '@')-count($current)+2); - - if ($hour != "") { - $tr_hours .= ''.$hour.''; - $radio_title[$i] .= ' - '.$hour; + if ($horoCur[1] !== "") { + $tr_hours .= ''.$horoCur[1].''; + $radio_title[$i] .= ' - '.$horoCur[1]; $td_headers[$i] .= ' H'.$i; - } else { - $tr_hours .= ''; - } } else { $tr_hours .= ''; } From c1c337142cf25821d37aa1bc7ff0273285da08ae Mon Sep 17 00:00:00 2001 From: Bob Le Bricodeur Date: Sat, 15 Nov 2014 02:41:20 +0100 Subject: [PATCH 09/10] several warning displayed : A non well formed numeric value encountered in "studs.php" remove all displayed warning by splitting day and hour in $current variable --- studs.php | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/studs.php b/studs.php index 0d3ee93..82c6853 100644 --- a/studs.php +++ b/studs.php @@ -333,44 +333,43 @@ if ($dsondage->format=="D"||$dsondage->format=="D+"||$dsondage->format=="D-") { // Current date $current = $toutsujet[$i]; + $horoCur = explode("@",$current); //horoCur[0] = date, horoCur[1] = hour + if (isset($toutsujet[$i+1])){ + $next = $toutsujet[$i+1]; + $horoNext = explode("@",$next); + } $border[$i] = false; - $radio_title[$i] = strftime($date_format['txt_short'],$current); + $radio_title[$i] = strftime($date_format['txt_short'],$horoCur[0]); // Months $td_headers[$i] = 'M'.($i+1-$colspan_month); - if (isset($toutsujet[$i+1]) && strftime("%B", $current) == strftime("%B", $toutsujet[$i+1]) && strftime("%Y", $current) == strftime("%Y", $toutsujet[$i+1])){ + if (isset($toutsujet[$i+1]) && strftime("%B", $horoCur[0]) == strftime("%B", $horoNext[0]) && strftime("%Y", $horoCur[0]) == strftime("%Y", $horoNext[0])){ $colspan_month++; } else { $border[$i] = true; - $tr_months .= ''.strftime("%B",$current).' '.strftime("%Y", $current).''; + $tr_months .= ''.strftime("%B",$horoCur[0]).' '.strftime("%Y", $horoCur[0]).''; $colspan_month=1; } // Days $td_headers[$i] .= ' D'.($i+1-$colspan_day); - if (isset($toutsujet[$i+1]) && strftime($date_format['txt_day'],$current)==strftime($date_format['txt_day'],$toutsujet[$i+1])&&strftime("%B",$current)==strftime("%B",$toutsujet[$i+1])){ + if (isset($toutsujet[$i+1]) && strftime($date_format['txt_day'],$horoCur[0])==strftime($date_format['txt_day'],$horoNext[0])&&strftime("%B",$horoCur[0])==strftime("%B",$horoNext[0])){ $colspan_day++; } else { $rbd = ($border[$i]) ? ' rbd' : ''; - $tr_days .= ''.strftime($date_format['txt_day'],$current).''; + $tr_days .= ''.strftime($date_format['txt_day'],$horoCur[0]).''; $colspan_day=1; } // Hours $rbd = ($border[$i]) ? ' rbd' : ''; - if (strpos($current,'@') !== false) { - $hour = substr($current, strpos($current, '@')-count($current)+2); - - if ($hour != "") { - $tr_hours .= ''.$hour.''; - $radio_title[$i] .= ' - '.$hour; + if ($horoCur[1] !== "") { + $tr_hours .= ''.$horoCur[1].''; + $radio_title[$i] .= ' - '.$horoCur[1]; $td_headers[$i] .= ' H'.$i; - } else { - $tr_hours .= ''; - } } else { $tr_hours .= ''; } From 293d813b628e72ae3ffa7e3a2a0bdc82a4db75aa Mon Sep 17 00:00:00 2001 From: Bob Le Bricodeur Date: Sat, 15 Nov 2014 02:47:30 +0100 Subject: [PATCH 10/10] warning correction : Warning: max(): Array must contain at least one element in "studs.php" on line 615 --- studs.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/studs.php b/studs.php index 82c6853..9918083 100644 --- a/studs.php +++ b/studs.php @@ -472,7 +472,7 @@ echo' $user_mod = false; //affichage des resultats actuels -$somme = array(); +$somme[] = 0; $compteur = 0; while ($data = $user_studs->FetchNextObject(false)) {