Fix: Add protection against bad parameter of labels in member module

This commit is contained in:
Laurent Destailleur 2009-03-13 15:17:34 +00:00
parent 6a806ecf35
commit f3d463e672
3 changed files with 24 additions and 32 deletions

View File

@ -1,7 +1,7 @@
<?php <?php
/* Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org> /* Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2003 Jean-Louis Bergamo <jlb@j1b.org> * Copyright (C) 2003 Jean-Louis Bergamo <jlb@j1b.org>
* Copyright (C) 2004-2008 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2004-2009 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2004 Sebastien Di Cintio <sdicintio@ressource-toi.org> * Copyright (C) 2004 Sebastien Di Cintio <sdicintio@ressource-toi.org>
* Copyright (C) 2004 Benoit Mortier <benoit.mortier@opensides.be> * Copyright (C) 2004 Benoit Mortier <benoit.mortier@opensides.be>
* *
@ -159,7 +159,7 @@ if ($conf->global->MAIN_FEATURES_LEVEL >= 1)
{ {
$lien=img_tick().' '; $lien=img_tick().' ';
$lien.='<a href="adherent.php?action=unset&value=0&name=ADHERENT_USE_MAILMAN">'.$langs->trans("Disable").'</a>'; $lien.='<a href="adherent.php?action=unset&value=0&name=ADHERENT_USE_MAILMAN">'.$langs->trans("Disable").'</a>';
// Edition des varibales globales rattache au theme Mailman // Edition des varibales globales rattache au theme Mailman
$constantes=array('ADHERENT_MAILMAN_LISTS', $constantes=array('ADHERENT_MAILMAN_LISTS',
'ADHERENT_MAILMAN_LISTS_COTISANT', 'ADHERENT_MAILMAN_LISTS_COTISANT',
'ADHERENT_MAILMAN_ADMINPW', 'ADHERENT_MAILMAN_ADMINPW',
@ -189,7 +189,7 @@ if ($conf->global->MAIN_FEATURES_LEVEL >= 1)
{ {
$lien=img_tick().' '; $lien=img_tick().' ';
$lien.='<a href="adherent.php?action=unset&value=0&name=ADHERENT_USE_SPIP">'.$langs->trans("Disable").'</a>'; $lien.='<a href="adherent.php?action=unset&value=0&name=ADHERENT_USE_SPIP">'.$langs->trans("Disable").'</a>';
// Edition des varibales globales rattache au theme Mailman // Edition des varibales globales rattache au theme Mailman
$constantes=array('ADHERENT_USE_SPIP_AUTO', $constantes=array('ADHERENT_USE_SPIP_AUTO',
'ADHERENT_SPIP_SERVEUR', 'ADHERENT_SPIP_SERVEUR',
'ADHERENT_SPIP_DB', 'ADHERENT_SPIP_DB',
@ -209,7 +209,7 @@ if ($conf->global->MAIN_FEATURES_LEVEL >= 1)
} }
/* /*
* Edition des varibales globales non rattache a un theme specifique * Edition des varibales globales non rattache a un theme specifique
*/ */
$constantes=array( $constantes=array(
'ADHERENT_MAIL_VALID_SUBJECT', 'ADHERENT_MAIL_VALID_SUBJECT',
@ -231,7 +231,7 @@ print '%DOL_MAIN_URL_ROOT%, %ID%, %PRENOM%, %NOM%, %LOGIN%, %PASSWORD%,';
print '%SOCIETE%, %ADRESSE%, %CP%, %VILLE%, %PAYS%, %EMAIL%, %NAISS%, %PHOTO%, %TYPE%,'; print '%SOCIETE%, %ADRESSE%, %CP%, %VILLE%, %PAYS%, %EMAIL%, %NAISS%, %PHOTO%, %TYPE%,';
//print '%INFOS%'; Deprecated //print '%INFOS%'; Deprecated
print '<br>'; print '<br>';
form_constantes($constantes); form_constantes($constantes);
@ -268,24 +268,24 @@ function form_constantes($tableau)
print '<input type="hidden" name="rowid" value="'.$rowid.'">'; print '<input type="hidden" name="rowid" value="'.$rowid.'">';
print '<input type="hidden" name="constname" value="'.$obj->name.'">'; print '<input type="hidden" name="constname" value="'.$obj->name.'">';
print '<input type="hidden" name="constnote" value="'.nl2br($obj->note).'">'; print '<input type="hidden" name="constnote" value="'.nl2br($obj->note).'">';
print "<tr $bc[$var]>"; print "<tr $bc[$var]>";
// Affiche nom constante // Affiche nom constante
print '<td>'; print '<td>';
print $langs->trans("Desc".$obj->name) != ("Desc".$obj->name) ? $langs->trans("Desc".$obj->name) : $obj->note; print $langs->trans("Desc".$obj->name) != ("Desc".$obj->name) ? $langs->trans("Desc".$obj->name) : $obj->note;
print "</td>\n"; print "</td>\n";
if ($obj->name == 'ADHERENT_ETIQUETTE_TYPE') if ($obj->name == 'ADHERENT_ETIQUETTE_TYPE')
{ {
print '<td>'; print '<td>';
// List of possible labels. Values must exists in // List of possible labels. Values must exists in
// file htdocs/adherents/PDF_Card.class.php // file htdocs/adherents/PDF_Card.class.php
require_once(DOL_DOCUMENT_ROOT.'/includes/modules/member/PDF_card.class.php'); require_once(DOL_DOCUMENT_ROOT.'/includes/modules/member/PDF_card.class.php');
$pdfcard=new PDF_card('5160',1,1,'mm'); $pdfcardstatic=new PDF_card('5160',1,1,'mm');
$arrayoflabels=array_keys($pdfcard->_Avery_Labels); $arrayoflabels=array_keys($pdfcardstatic->_Avery_Labels);
$form->select_array('constvalue',$arrayoflabels,$obj->value); $form->select_array('constvalue',$arrayoflabels,$obj->value,1,0,1);
print '</td><td>'; print '</td><td>';
$form->select_array('consttype',array('yesno','texte','chaine'),1); $form->select_array('consttype',array('yesno','texte','chaine'),1);
} }
@ -314,16 +314,16 @@ function form_constantes($tableau)
} }
print '</td>'; print '</td>';
} }
print '<td align="center">'; print '<td align="center">';
print '<input type="submit" class="button" value="'.$langs->trans("Update").'" name="Button"> &nbsp;'; print '<input type="submit" class="button" value="'.$langs->trans("Update").'" name="Button"> &nbsp;';
// print '<a href="adherent.php?name='.$const.'&action=unset">'.img_delete().'</a>'; // print '<a href="adherent.php?name='.$const.'&action=unset">'.img_delete().'</a>';
print "</td></tr>\n"; print "</td></tr>\n";
print '</form>'; print '</form>';
$i++; $i++;
} }
} }
print '</table>'; print '</table>';
} }

View File

@ -2409,7 +2409,7 @@ class Form
* \param id Preselected key * \param id Preselected key
* \param show_empty 1 si il faut ajouter une valeur vide dans la liste, 0 sinon * \param show_empty 1 si il faut ajouter une valeur vide dans la liste, 0 sinon
* \param key_in_label 1 pour afficher la key dans la valeur "[key] value" * \param key_in_label 1 pour afficher la key dans la valeur "[key] value"
* \param value_as_key 1 pour utiliser la valeur comme clé * \param value_as_key 1 to use value as key
* \param optionType Type de l'option: 1 pour des fonctions javascript * \param optionType Type de l'option: 1 pour des fonctions javascript
* \param option Valeur de l'option en fonction du type choisi * \param option Valeur de l'option en fonction du type choisi
* \param translate Traduire la valeur * \param translate Traduire la valeur

View File

@ -179,18 +179,6 @@ class PDF_card extends FPDF {
'width'=>99.1, 'width'=>99.1,
'height'=>38.1, 'height'=>38.1,
'font-size'=>10), 'font-size'=>10),
'FREELUG'=>array('name'=>'FREELUG',
'paper-size'=>'A4',
'metric'=>'mm',
'marginLeft'=>0,
'marginTop'=>0,
'NX'=>2,
'NY'=>8,
'SpaceX'=>0,
'SpaceY'=>0,
'width'=>105,
'height'=>38,
'font-size'=>10),
'CARD'=>array('name'=>'CARD', 'CARD'=>array('name'=>'CARD',
'paper-size'=>'A4', 'paper-size'=>'A4',
'metric'=>'mm', 'metric'=>'mm',
@ -225,9 +213,13 @@ class PDF_card extends FPDF {
// Si c'est un format personnel alors on maj les valeurs // Si c'est un format personnel alors on maj les valeurs
$Tformat = $format; $Tformat = $format;
} else { } else {
// Si c'est un format avery on stocke le nom de ce format selon la norme Avery. // If it's an Avery format, we get array that describe it from key and we store it in Tformat.
// Permettra d'aller récupérer les valeurs dans le tableau _Avery_Labels
$Tformat = $this->_Avery_Labels[$format]; $Tformat = $this->_Avery_Labels[$format];
if (empty($Tformat))
{
dol_print_error('','Format value "'.$format.'" is not supported.');
exit;
}
} }
parent::FPDF('P', $unit, $Tformat['paper-size']); parent::FPDF('P', $unit, $Tformat['paper-size']);