Re: Problème pour insérer une commande bash dans un script p…

Pàgina inicial

Reply to this message
Autor: Dominique Fournier
Data:  
A: guilde
Assumpte: Re: Problème pour insérer une commande bash dans un script php
Bonjour Anne

str_replace ('"', "", $vcf)
ne suffirait pas ?

Dom

Le 27/12/2019 à 20:16, anne.guilde@??? a écrit :
> bonjour,
>
> Quand je récupère un fichier vcf à partir de nextcloud j'ai un problème
> avec les "
>
> TEL;TYPE="HOME,VOICE":12345678
>
> Le numéro n'est pas récupéré à cause des "
>
> La solution trouvée grâce à Marc
>
> cat fichier.vcf | tr -d '"' > new_fichier.vcf
>
> J'aimerais inclure cette commande dans le php
>
> https://github.com/thomascube/vcfconvert
>
> les fichiers :
>
> -rw-rw-r-- 1 admin shared 26008 26 févr.  2019 Contact_Vcard_Parse.php
> -rw-rw-r-- 1 admin shared  5617 27 déc.  02:49 index.php
> -rw-rw-r-- 1 admin shared  7300 27 déc.  02:47 page.html
> -rw-rw-r-- 1 admin shared  2129 26 févr.  2019 README.md
> drwxrwsr-x 2 admin shared  4096 11 déc.  23:08 tmp
> -rw-rw-r-- 1 admin shared  1259 26 févr.  2019 utils.php
> -rw-rw-r-- 1 admin shared 35687 27 déc.  01:04 vcard_convert.php
> -rw-rw-r-- 1 admin shared  5487 26 févr.  2019 vcf2csv_logo.jpg
> -rw-rw-r-- 1 admin shared  3675 26 févr.  2019 vcfconvert.sh
>
>
> # ./vcfconvert.sh help
> Usage: convert [-hilmpv] [-d delimiter] [-b identifier] [-o output_file]
> -f format file
>   -f Target format (ldif,ldap,csv,gmail,libdlusb)
>   -b LDAP identifier added to dn:
>   -l Generate just a list of DN objects (only works with -b)
>   -o Output file (write to stdout by default)
>   -d CSV col delimiter
>   -h Include header line in CSV output
>   -i Convert CSV output to ISO-8859-1 encoding
>   -m Only convert cards with an e-mail address
>   -p Only convert cards with phone numbers
>   -v Verbose output
>
> Pas essayé : en ligne de commande.
>
> J'ai mis les php sur mon serveur.
>
> J'ai modifié index.php et page.html pour inclure les 2 modifications que
> j'ai fait.
>
> index.php
> ...
>         $conv = new vcard_convert(array(
>                 'mailonly' => !empty($_POST['_mailonly']),
>                 'phoneonly' => !empty($_POST['_phoneonly']),
>                 'accesscode' => preg_replace('/[^1-9]/', '',
> $_POST['_accesscode']),
>                 'mobilephone' => !empty($_POST['_mobilephone']),  <=
> ajouté
>                 'nextcloudvcf' => !empty($_POST['_nextcloudvcf']), <=
> ajouté
>         ));
> ...
>
> mobilephone C'est pour savoir si le fichier vient du smartphone ou de
> nextcloud
> Je m'en sers pour la catégorie des vcard.
>
> nextcloudvcf c'est pour modifier les " des vcard quand le vcf vient de
> nextcloud.
> Je pense que cela fait double emploi. Je vais certainement l'enlever.
>
> page.html
> ...
> <td class="cell label">Groupe Mobile  phone:</td>
> <td class="cell">
>   <input type="checkbox" name="_mobilephone" id="checkmobilephone"
> value="1"><label for="checkmobilephone">&nbsp;vCards with mobile phone
> (group)</label>
> </td>
>
> </tr><tr>
>
> <td class="cell label">Nexctcloud VCF:</td>
> <td class="cell">
>   <input type="checkbox" name="_nextcloudvcf" id="checknextcloudvcf"
> value="1"><label for="checknextcloudvcf">&nbsp;vCards with nextcloud
> vcf</label>
> </td>
>
> </tr><tr>
> ...
>
> C'est la page html qui s'affiche à l'écran.
>
>
> vcard_convert.php
> ...
> function normalize()
>
> - avant
>             $vcard->categories = join(',',
> (array)$card['CATEGORIES'][0]['value'][0]);
>
> - après
>                         if ($this->mobilephone)
>                         {
>                                 $vcard->categories = join(',',
> (array)$card['X-GROUP-MEMBERSHIP'][0]['value'][0]);
>                         } else
>                         {
>                                 $vcard->categories = join(',',
> (array)$card['CATEGORIES'][0]['value'][0]);
>                         }
> ...
>
> J'ai ajouté le test pour savoir si le fichier vient du smartphone ou non
>
> La catégorie avec le vcard qui vient de nextcloud c'est : CATEGORIES
> exemple : CATEGORIES:Family
> La catégorie avec le vcard qui vient du smartphone c'est :
> X-GROUP-MEMBERSHIP
> exemple : X-GROUP-MEMBERSHIP:Family
>
> Pour cela c'est ok. Cela fonctionne, j'ai trouvé ce qu'il faut modifier.
> Je pense avoir modifié correctement.
>
> -------------------
>
> Quand le vcf vient de Nextcloud, pour l'instant je fais cette commande
> cat fichier.vcf | tr -d '"' > new_fichier.vcf
> C'est pour enlever les " de, par exemple, TEL;TYPE="HOME,VOICE":12345678
> qui vient du vcf de nextcloud.
> (Merci à Marc)
>
> J'aimerais bien inclure cela dans le programme vcfconvert
>
> C'est dans le pgm vcard_convert.php
> ...
> function normalize()
>
>                         // extract phones
>                         if (is_array($card['TEL']))
>                                 $this->parse_tel($card['TEL'], $vcard);
> ...
>         /**
>          * Helper method to parse an phone number node
>          *
>          * @access private
>          */
>         function parse_tel(&$node, &$vcard)
> ...
>
> C'est peut-être dans un autre pgm php que je pourrais inclure la modif.
>
> Si quelqu'un a du courage pour jeter avec un ou 2 yeux ...
>
> Merci
> Anne
>