diff --git a/htdocs/core/modules/import/import_csv.modules.php b/htdocs/core/modules/import/import_csv.modules.php index 1b6f255a4f0..4ddc5dfcdea 100644 --- a/htdocs/core/modules/import/import_csv.modules.php +++ b/htdocs/core/modules/import/import_csv.modules.php @@ -267,6 +267,9 @@ class ImportCsv extends ModeleImports $arrayres=fgetcsv($this->handle,100000,$this->separator,$this->enclosure,$this->escape); } + // End of file + if ($arrayres === false) return false; + //var_dump($this->handle); //var_dump($arrayres);exit; $newarrayres=array(); diff --git a/htdocs/core/modules/modAdherent.class.php b/htdocs/core/modules/modAdherent.class.php index 44304f870f9..adefcea2d42 100644 --- a/htdocs/core/modules/modAdherent.class.php +++ b/htdocs/core/modules/modAdherent.class.php @@ -207,7 +207,7 @@ class modAdherent extends DolibarrModules $this->import_entities_array[$r]=array(); // We define here only fields that use another icon that the one defined into import_icon $this->import_tables_array[$r]=array('a'=>MAIN_DB_PREFIX.'adherent','extra'=>MAIN_DB_PREFIX.'adherent_extrafields'); $this->import_tables_creator_array[$r]=array('a'=>'fk_user_author'); // Fields to store import user id - $this->import_fields_array[$r]=array('a.civilite'=>"UserTitle",'a.nom'=>"Lastname*",'a.firstname'=>"Firstname",'a.login'=>"Login*","a.pass"=>"Password","a.fk_adherent_type"=>"MemberType*",'a.morphy'=>'Nature*','a.societe'=>'Company','a.address'=>"Address",'a.zip'=>"Zip",'a.town'=>"Town",'a.country'=>"Country",'a.phone'=>"PhonePro",'a.phone_perso'=>"PhonePerso",'a.phone_mobile'=>"PhoneMobile",'a.email'=>"Email",'a.birth'=>"Birthday",'a.statut'=>"Status*",'a.photo'=>"Photo",'a.note'=>"Note",'a.datec'=>'DateCreation','a.datefin'=>'DateEndSubscription'); + $this->import_fields_array[$r]=array('a.civilite'=>"UserTitle",'a.lastname'=>"Lastname*",'a.firstname'=>"Firstname",'a.login'=>"Login*","a.pass"=>"Password","a.fk_adherent_type"=>"MemberType*",'a.morphy'=>'Nature*','a.societe'=>'Company','a.address'=>"Address",'a.zip'=>"Zip",'a.town'=>"Town",'a.country'=>"Country",'a.phone'=>"PhonePro",'a.phone_perso'=>"PhonePerso",'a.phone_mobile'=>"PhoneMobile",'a.email'=>"Email",'a.birth'=>"Birthday",'a.statut'=>"Status*",'a.photo'=>"Photo",'a.note'=>"Note",'a.datec'=>'DateCreation','a.datefin'=>'DateEndSubscription'); // Add extra fields $sql="SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'member'"; $resql=$this->db->query($sql); @@ -223,7 +223,7 @@ class modAdherent extends DolibarrModules // End add extra fields $this->import_fieldshidden_array[$r]=array('extra.fk_object'=>'lastrowid-'.MAIN_DB_PREFIX.'adherent'); // aliastable.field => ('user->id' or 'lastrowid-'.tableparent) $this->import_regex_array[$r]=array('a.civilite'=>'code@'.MAIN_DB_PREFIX.'c_civilite','a.fk_adherent_type'=>'rowid@'.MAIN_DB_PREFIX.'adherent_type','a.morphy'=>'(phy|mor)','a.statut'=>'^[0|1]','a.datec'=>'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$','a.datefin'=>'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$'); - $this->import_examplevalues_array[$r]=array('a.civilite'=>"MR",'a.nom'=>'Smith','a.firstname'=>'John','a.login'=>'jsmith','a.pass'=>'passofjsmith','a.fk_adherent_type'=>'1','a.morphy'=>'"mor" or "phy"','a.societe'=>'JS company','a.address'=>'21 jump street','a.zip'=>'55000','a.town'=>'New York','a.country'=>'1','a.email'=>'jsmith@example.com','a.birth'=>'1972-10-10','a.statut'=>"0 or 1",'a.note'=>"This is a comment on member",'a.datec'=>dol_print_date($now,'%Y-%m-%d'),'a.datefin'=>dol_print_date(dol_time_plus_duree($now, 1, 'y'),'%Y-%m-%d')); + $this->import_examplevalues_array[$r]=array('a.civilite'=>"MR",'a.lastname'=>'Smith','a.firstname'=>'John','a.login'=>'jsmith','a.pass'=>'passofjsmith','a.fk_adherent_type'=>'1','a.morphy'=>'"mor" or "phy"','a.societe'=>'JS company','a.address'=>'21 jump street','a.zip'=>'55000','a.town'=>'New York','a.country'=>'1','a.email'=>'jsmith@example.com','a.birth'=>'1972-10-10','a.statut'=>"0 or 1",'a.note'=>"This is a comment on member",'a.datec'=>dol_print_date($now,'%Y-%m-%d'),'a.datefin'=>dol_print_date(dol_time_plus_duree($now, 1, 'y'),'%Y-%m-%d')); } diff --git a/htdocs/imports/import.php b/htdocs/imports/import.php index 734ba94534c..e7d599f8d68 100644 --- a/htdocs/imports/import.php +++ b/htdocs/imports/import.php @@ -1307,13 +1307,19 @@ if ($step == 5 && $datatoimport) $result=$obj->import_open_file($pathfile,$langs); if ($result > 0) { - $sourcelinenb=0; + $sourcelinenb=0; $endoffile=0; // Loop on each input file record - while ($sourcelinenb < $nboflines) + while ($sourcelinenb < $nboflines && ! $endoffile) { $sourcelinenb++; // Read line and stor it into $arrayrecord $arrayrecord=$obj->import_read_record(); + if ($arrayrecord === false) + { + $arrayofwarnings[$sourcelinenb][0]=array('lib'=>'File has '.$nboflines.' lines. However we reach end of file after record '.$sourcelinenb.'. This may occurs when some records are split onto several lines.','type'=>'EOF_RECORD_ON_SEVERAL_LINES'); + $endoffile++; + continue; + } if ($excludefirstline && $sourcelinenb == 1) continue; // @@ -1615,11 +1621,17 @@ if ($step == 6 && $datatoimport) $result=$obj->import_open_file($pathfile,$langs); if ($result > 0) { - $sourcelinenb=0; - while ($sourcelinenb < $nboflines) + $sourcelinenb=0; $endoffile=0; + while ($sourcelinenb < $nboflines && ! $endoffile) { $sourcelinenb++; $arrayrecord=$obj->import_read_record(); + if ($arrayrecord === false) + { + $arrayofwarnings[$sourcelinenb][0]=array('lib'=>'File has '.$nboflines.' lines. However we reach end of file after record '.$sourcelinenb.'. This may occurs when some records are split onto several lines.','type'=>'EOF_RECORD_ON_SEVERAL_LINES'); + $endoffile++; + continue; + } if ($excludefirstline && $sourcelinenb == 1) continue; $result=$obj->import_insert($arrayrecord,$array_match_file_to_database,$objimport,count($fieldssource),$importid); diff --git a/htdocs/langs/en_US/errors.lang b/htdocs/langs/en_US/errors.lang index a9de1c511a8..3677392d64c 100644 --- a/htdocs/langs/en_US/errors.lang +++ b/htdocs/langs/en_US/errors.lang @@ -77,7 +77,7 @@ ErrorContactEMail=A technical error occured. Please, contact administrator to fo ErrorWrongValueForField=Wrong value for field number %s (value '%s' does not match regex rule %s) ErrorFieldValueNotIn=Wrong value for field number %s (value '%s' is not a value available into field %s of table %s) ErrorFieldRefNotIn=Wrong value for field number %s (value '%s' is not a %s existing ref) -ErrorsOnXLines=Errors on %s source lines +ErrorsOnXLines=Errors on %s source record(s) ErrorFileIsInfectedWithAVirus=The antivirus program was not able to validate the file (file might be infected by a virus) ErrorSpecialCharNotAllowedForField=Special characters are not allowed for field "%s" ErrorDatabaseParameterWrong=Database setup parameter '%s' has a value not compatible to use Dolibarr (must have value '%s'). @@ -131,7 +131,7 @@ WarningBuildScriptNotRunned=Script %s was not yet ran to build graphics, WarningBookmarkAlreadyExists=A bookmark with this title or this target (URL) already exists. WarningPassIsEmpty=Warning, database password is empty. This is a security hole. You should add a password to your database and change your conf.php file to reflect this. WarningConfFileMustBeReadOnly=Warning, your config file (htdocs/conf/conf.php) can be overwritten by the web server. This is a serious security hole. Modify permissions on file to be in read only mode for operating system user used by Web server. If you use Windows and FAT format for your disk, you must know that this file system does not allow to add permissions on file, so can't be completely safe. -WarningsOnXLines=Warnings on %s source lines +WarningsOnXLines=Warnings on %s source record(s) WarningNoDocumentModelActivated=No model, for document generation, has been activated. A model will be choosed by default until you check your module setup. WarningLockFileDoesNotExists=Warning, once setup is finished, you must disable install/migrate tools by adding a file install.lock into directory %s. Missing this file is a security hole. WarningUntilDirRemoved=All security warnings (visible by admin users only) will remain active as long as the vulnerability is present (or that constant MAIN_REMOVE_INSTALL_WARNING is added in Setup->Other setup). diff --git a/htdocs/langs/fr_FR/errors.lang b/htdocs/langs/fr_FR/errors.lang index 08c14dc5c35..2c06d31126b 100644 --- a/htdocs/langs/fr_FR/errors.lang +++ b/htdocs/langs/fr_FR/errors.lang @@ -78,7 +78,7 @@ ErrorContactEMail=Une erreur technique est apparue. Merci de contacter l'adminis ErrorWrongValueForField=Mauvaise valeur pour le champ numéro %s (la valeur '%s' ne respecte pas la règle %s) ErrorFieldValueNotIn=Mauvaise valeur pour le champ numéro %s (la valeur '%s' n'est pas une valeure présente dans le champ %s de la table %s) ErrorFieldRefNotIn=Mauvaise valeur pour le champ numéro %s (la valeur '%s' n'est pas une référence existante comme %s) -ErrorsOnXLines=Erreurs sur %s lignes sources +ErrorsOnXLines=Erreurs sur %s enregistrement(s) source ErrorFileIsInfectedWithAVirus=L'antivirus n'a pas pu valider ce fichier (il est probablement infecté par un virus) ! ErrorSpecialCharNotAllowedForField=Les caractères spéciaux ne sont pas admis pour le champ "%s" ErrorDatabaseParameterWrong=Le paramètre de configuration de la base de donnée '%s' a une valeur non compatible pour une utilisation de Dolibarr (doit avoir la valeur '%s'). @@ -132,7 +132,7 @@ WarningBuildScriptNotRunned=Le script %s n'a pas encore été lancé pour WarningBookmarkAlreadyExists=Un marque-page avec ce titre ou cette destination (URL) existe déjà. WarningPassIsEmpty=Attention, le mot de passe de la base de données Dolibarr est vide. Cela représente une faille de sécurité. Il est recommandé d'ajouter manuellement un mot de passe à la base et de modifier le fichier conf.php pour refléter ce changement. WarningConfFileMustBeReadOnly=Attention, votre fichier de configuration (htdocs/conf/conf.php) est accessible en écriture au serveur Web. Ceci représente une faille sérieuse de sécurité. Modifiez les permissions pour qu'il soit en lecture seule pour le compte sous lequel tourne le serveur Web et non lisible pour les autres.
Si vous êtes sous Windows sur un disque dur utilisant un formatage FAT, sachez que ce système de fichier ne permet pas de protéger des fichiers et n'offre donc aucune solution pour réduire les risques de manipulation de ce fichier. -WarningsOnXLines=Alertes sur %s lignes sources +WarningsOnXLines=Alertes sur %s enregistrement(s) source WarningNoDocumentModelActivated=Aucun modèle, pour la génération de document, n'a été activé. Un modèle sera pris par défaut en attendant la correction de configuration du module. WarningLockFileDoesNotExists=Attention, une fois l'installation terminée, les outils d'installation/migration doivent être désactivés en ajoutant un fichier install.lock dans le répertoire %s. L'absence de ce fichier représente une faille de sécurité. WarningUntilDirRemoved=Les alertes de sécurité sont visibles par les administrateurs uniquement et resteront actives tant que la vulnérabilité sera avérée (ou que la constante MAIN_REMOVE_INSTALL_WARNING aura été définie dans Configuration->Divers)