Guest User

ecureuil-php-csv-vcf-finalise

a guest
Jan 18th, 2020
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 23.01 KB | None | 0 0
  1. <?php
  2.  
  3. /*
  4.  Programme récupéré de https://sourceforge.net/projects/csv2vcf-php/
  5.  test possible ici https://dwaves.org/2016/06/30/csv2vcf-online-converter/
  6.  
  7. J'ai changé beaucoup de choses par rapport au départ.
  8. Le fichier csv provient d'un programme trouvé ici
  9. https://github.com/thomascube/vcfconvert
  10. Ce programme transforme les vcf en csv.
  11.  
  12. J'ai donc changé le nom des champs pour l'adapter au csv que j'avais.
  13. Le client envoie un fichier CSV pour le transformer en fichier VCF (vcard)
  14. Il faut connaitre le séparateur du fichier csv.
  15. Comme séparateur possible ',' ';' ou tab  (<p>You can put as separator: ',' ';' or tab </p> )
  16. Vous pouvez récupérer le fichier vcf produit mais dès que le vous revenez au début pour en transformer un autre, le fichier est détruit
  17.  
  18. La permière ligne du fichier csv doit contenir
  19. First Name;Last Name;Display Name;Nickname;E-mail Address;E-mail 2 Address;E-mail 3 Address;Home Phone;Business Phone;Home Fax;Business Fax;Pager;Mobile Phone;Home Street;Home Address 2;Home City;Home State;Home Postal Code;Home Country;Business Address;Business Address 2;Business City;Business State;Business Postal Code;Business Country;Country Code;Related name;Job Title;Department;Organization;Notes;Birthday;Anniversary;Gender;Web Page;Web Page 2;Categories
  20.  
  21. Le programme se base sur cela pour traiter les données du fichier csv
  22.  
  23. Merci à tous ceux qui m'ont aidé pour finaliser le php
  24. surtout Edgar, Marc et Jérôme de la guilde de Grenoble
  25.  
  26. La Guilde des utilisateurs d’informatique libre du Dauphiné (GUILDE) est une association loi 1901 ayant pour objectif de promouvoir les logiciels libres, et particulièrement le système GNU/Linux, auprès des particuliers et des professionnels et de rassembler les utilisateurs de la région du Dauphiné.
  27.  
  28. */
  29.  
  30. /* === examples for different vCard Versions according to Wikpedia ===
  31. vCard 2.1
  32.  
  33. BEGIN:VCARD
  34. VERSION:2.1
  35. N:Gump;Forrest;;Mr.
  36. FN:Forrest Gump
  37. ORG:Bubba Gump Shrimp Co.
  38. TITLE:Shrimp Man
  39. PHOTO;GIF:http://www.example.com/dir_photos/my_photo.gif
  40. TEL;WORK;VOICE:(111) 555-1212
  41. TEL;HOME;VOICE:(404) 555-1212
  42. ADR;WORK;PREF:;;100 Waters Edge;Baytown;LA;30314;United States of America
  43. LABEL;WORK;PREF;ENCODING=QUOTED-PRINTABLE;CHARSET=UTF-8:100 Waters Edge=0D=
  44.  =0ABaytown\, LA 30314=0D=0AUnited States of America
  45. ADR;HOME:;;42 Plantation St.;Baytown;LA;30314;United States of America
  46. LABEL;HOME;ENCODING=QUOTED-PRINTABLE;CHARSET=UTF-8:42 Plantation St.=0D=0A=
  47.  Baytown, LA 30314=0D=0AUnited States of America
  48. REV:20080424T195243Z
  49. END:VCARD
  50.  
  51. vCard 3.0
  52.  
  53. BEGIN:VCARD
  54. VERSION:3.0
  55. N:Gump;Forrest;;Mr.
  56. FN:Forrest Gump
  57. ORG:Bubba Gump Shrimp Co.
  58. TITLE:Shrimp Man
  59. PHOTO;VALUE=URI;TYPE=GIF:http://www.example.com/dir_photos/my_photo.gif
  60. TEL;TYPE=WORK,VOICE:(111) 555-1212
  61. TEL;TYPE=HOME,VOICE:(404) 555-1212
  62. ADR;TYPE=WORK,PREF:;;100 Waters Edge;Baytown;LA;30314;United States of Amer
  63.  ica
  64. LABEL;TYPE=WORK,PREF:100 Waters Edge\nBaytown\, LA 30314\nUnited States of
  65.  America
  66. ADR;TYPE=HOME:;;42 Plantation St.;Baytown;LA;30314;United States of America
  67. LABEL;TYPE=HOME:42 Plantation St.\nBaytown\, LA 30314\nUnited States of Ame
  68.  rica
  69. REV:2008-04-24T19:52:43Z
  70. END:VCARD
  71.  
  72. vCard 4.0
  73.  
  74. BEGIN:VCARD
  75. VERSION:4.0
  76. N:Forrest;Gump;;Mr.;
  77. FN:Forrest Gump
  78. ORG:Bubba Gump Shrimp Co.
  79. TITLE:Shrimp Man
  80. PHOTO;MEDIATYPE=image/gif:http://www.example.com/dir_photos/my_photo.gif
  81. TEL;TYPE=work,voice;VALUE=uri:tel:+1-111-555-1212
  82. TEL;TYPE=home,voice;VALUE=uri:tel:+1-404-555-1212
  83. ADR;TYPE=work;LABEL="100 Waters Edge\nBaytown, LA 30314\nUnited States of A
  84.  merica";PREF=1:;;100 Waters Edge;Baytown;LA;30314;United States of America
  85. ADR;TYPE=home;LABEL="42 Plantation St.\nBaytown, LA 30314\nUnited States of
  86.  America":;;42 Plantation St.;Baytown;LA;30314;United States of America
  87. REV:20080424T195243Z
  88. END:VCARD
  89.  */
  90.  
  91. error_reporting(E_ALL & ~E_NOTICE); // report all errors except notices
  92.  
  93. // fonction pour l'affichage de la page avec header
  94. function print_html_header()
  95. {
  96. echo '<!DOCTYPE html>
  97.     <html lang="en">
  98.     <head>
  99.     <meta charset="utf-8">
  100.     <meta http-equiv="X-UA-Compatible" content="IE=edge">
  101.     <meta name="viewport" content="width=device-width, initial-scale=1">
  102.     <meta name="description" content="convert csv2vcf" />
  103.     <meta name="keywords" content="csv2vcf" />
  104.     <title>convert csv2vcf</title>
  105.     <!-- external styles -->
  106.     <link href="css/style.css" type="text/css" rel="stylesheet"/>
  107.     </head>
  108.         <body>     
  109.             <div class="boxShadows" id="headline">
  110.                 <h1>csv2vcf: convert *.csv to *.vcf</h1>';
  111. }
  112.  
  113. $comma = ',';
  114. $semicolon = ';';
  115. // $tab = ' ';
  116. $tab = 'tab';
  117.  
  118. if(isset($_REQUEST["convert"])) // detect upload of file
  119. {
  120.     $allowedExts = array('csv','txt'); // MMM
  121.     $maximumFileSizeInKBytes = 4096;
  122.  
  123.     $allowedExts_string = "";
  124.     for($i=0;$i<count($allowedExts);$i++) {
  125.         $allowedExts_string .= "*.".$allowedExts[$i].", ";
  126.     }
  127.    
  128.     $maximumFileSizeInBytes = $maximumFileSizeInKBytes * 1024;
  129.     $delimiter = $_POST['_delimiter'] == 'tab' ? "\t" : $_POST['_delimiter'];
  130. //  $delimiter = $_POST['_delimiter'];
  131.    
  132.     if($_FILES)
  133.     {
  134.  
  135.         if(checkExtension($allowedExts)) // MMM
  136.         {
  137.             if(($_FILES["file"]["size"] < $maximumFileSizeInBytes))
  138.             {
  139.                 if ($_FILES["file"]["error"] > 0)
  140.                 {
  141.                     print_html_header();
  142.                     echo "Name: ".$_FILES["file"]["name"]."<br>";
  143.                     echo "field selector:  '".$delimiter."'<br>";
  144.                     echo "Size: ".($_FILES["file"]["size"] / 1024)." kB<br>";
  145.                     echo "Return Code: ".$_FILES["file"]["error"]."<br>";
  146.                 }
  147.                 else
  148.                 if ($delimiter == "")
  149.                 {
  150.                     print_html_header();
  151.                     echo "Name: ".$_FILES["file"]["name"]."<br>";
  152.                     echo "field selector:  '".$delimiter."'<br>";
  153.                     echo "Size: ".($_FILES["file"]["size"] / 1024)." kB<br>";
  154.                     echo "field selector not selected";
  155.                 }
  156.                 else
  157.                 {
  158.                     $filename_vcf = $_FILES["file"]["name"].".vcf";
  159.                     header('Content-Type: text/vcard');
  160.                     header(sprintf('Content-Disposition: attachment; filename="%s"', $filename_vcf));
  161.                     convert1($_FILES["file"]["tmp_name"],$delimiter);
  162.                     exit;
  163.                 }
  164.             }
  165.             else
  166.             {
  167.                 print_html_header();
  168.                 echo "Name: ".$_FILES["file"]["name"]."<br>";
  169.                 echo "field selector:  '".$delimiter."'<br>";
  170.                 echo "Size: ".($_FILES["file"]["size"] / 1024)." kB<br>";
  171.                 echo "File exceeds filezie limit of ".$maximumFileSizeInBytes."kByte.";
  172.             }
  173.         }
  174.         else
  175.         {
  176.             print_html_header();
  177.             echo "Name: ".$_FILES["file"]["name"]."<br>";
  178.             echo "field selector:  '".$delimiter."'<br>";
  179.             echo "Size: ".($_FILES["file"]["size"] / 1024)." kB<br>";
  180.             echo "File was not a allowed filetypes: ".$allowedExts_string."<br>";
  181.         }
  182.     }
  183. }
  184. else
  185. {
  186.     print_html_header();
  187.     echo '<form method="post" enctype="multipart/form-data">
  188.                 <label for="file">Please select your File.csv then hit convert:</label>
  189.                 <input type="file" name="file" id="file" style="width: 100%;">
  190.                 <br />
  191.                 field selector :
  192.  
  193.                 <select name="_delimiter" >
  194.                     <option value=""></option>
  195.                     <option value="'.$comma.'">Comma</option>
  196.                     <option value="'.$semicolon.'">Semicolon</option>
  197.                     <option value="'.$tab.'">Tab</option>
  198.                 </select><br />
  199.  
  200.                 <input type="submit" name="convert" value="convert" style="width: 100%;">
  201.             </form>
  202.             <p>the following fields in the *.csv will be converted:</p>
  203.             <div style="overflow:auto;white-space:nowrap;width:100%;" class="codecolorer-container bash default">
  204.                 <pre>
  205. First Name
  206. Last Name
  207. Display Name
  208. Nicknam
  209. E-mail Address
  210. E-mail 2 Address
  211. E-mail 3 Address
  212. Home Phone
  213. Business Phone
  214. Home Fax
  215. Business Fax
  216. Pager
  217. Mobile Phone
  218. Home Street
  219. Home Address 2
  220. Home City
  221. Home State
  222. Home Postal Code
  223. Home Country
  224. Business Address
  225. Business Address 2
  226. Business City
  227. Business State
  228. Business Postal Code
  229. Business Country
  230. Country Code
  231. Related name
  232. Job Title
  233. Department
  234. Organization
  235. Notes
  236. Birthday
  237. Anniversary
  238. Gender
  239. Web Page
  240. Web Page 2
  241. Categories
  242.             </pre>
  243.             </div>
  244.         </div>';
  245. }
  246.  
  247. // MMM verifie que le fichier envoye a l'une des extensions de $allowedExts
  248. function checkExtension(array $allowedExts)
  249. {
  250.     $upload_filename = $_FILES["file"]["name"];
  251.     $upload_filename_array = explode(".", $upload_filename);
  252.     $extension = strtolower(end($upload_filename_array));
  253.  
  254.     $key = array_search($extension, $allowedExts);
  255.     return $key !== false;
  256. }
  257.  
  258. // Conversion du fichier csv en vcf
  259. // J'ai changé la plupart des noms pour l'adapter au pgm qui fait vcf => csv qui vient de thomascube/vcfconvert
  260.  
  261. // First Name;Last Name;Display Name;Nickname;E-mail Address;E-mail 2 Address;E-mail 3 Address;Home Phone;Business Phone;Home Fax;Business Fax;Pager;Mobile Phone;Home Street;Home Address 2;Home City;Home State;Home Postal Code;Home Country;Business Address;Business Address 2;Business City;Business State;Business Postal Code;Business Country;Country Code;Related name;Job Title;Department;Organization;Notes;Birthday;Anniversary;Gender;Web Page;Web Page 2;Categories
  262.  
  263. // Si il n'y a pas de données dans les champs ci-dessus, rien n'est écrit dans le fichier de destination sauf
  264. // BEGIN:VCARD - VERSION:2.1 -  END:VCARD
  265. // Donc si mauvais séparateur de champs donné votre fichier de sortie n'aura que des lignes avec
  266. // BEGIN:VCARD - VERSION:2.1 -  END:VCARD
  267.  
  268. function convert1($filename_csv, $delimiter1)
  269. {
  270.     // $filename_csv = "export2016.06.24.csv";
  271.    
  272.     $lines_csv = file($filename_csv);
  273.  
  274.     $length = count($lines_csv);
  275.     for($i = 0;$i < $length;$i++)
  276.     {
  277.         if($i == 0)
  278.         {
  279.             $keys_csv = $lines_csv[$i];
  280.             $keys_csv = explode($delimiter1,$keys_csv);
  281.         }
  282.         else
  283.         {
  284.             print "BEGIN:VCARD\n"; // what Version does this file have
  285.             print "VERSION:2.1\n"; // what Version does this file have
  286.    
  287.             $values_csv = $lines_csv[$i];
  288.             $values_csv = explode($delimiter1,$values_csv);
  289.    
  290.             $position1 = findPos("First Name", $keys_csv);
  291.             $position2 = findPos("Last Name", $keys_csv);
  292.             $position = $values_csv[$position1] . ";" . $values_csv[$position2]. ";;" ;
  293.             if ( ( $position ) !== ";;;")
  294.             {
  295.                 print "N:".$position."\n"; // N:Gump;Forrest;;Mr.
  296.             }          
  297.  
  298.             $position3 = findPos("Display Name", $keys_csv);
  299.             $position = $values_csv[$position3];
  300.             if ( !empty( $position ) )
  301.             {
  302.                 print "FN:".$position."\n"; // FN:Forrest Gump
  303.             }          
  304.            
  305.             $position3 = findPos("E-mail Address", $keys_csv);
  306.             $position = $values_csv[$position3];
  307.             if ( !empty( $position ) )
  308.             {
  309.                 print "EMAIL;TYPE=home:".$position."\n";
  310.             }
  311.  
  312.             $position3 = findPos("E-mail 2 Address", $keys_csv);
  313.             $position = $values_csv[$position3];
  314.             if ( !empty( $position ) )
  315.             {
  316.                 print "EMAIL;TYPE=work:".$position."\n";
  317.             }
  318.  
  319.             $position3 = findPos("E-mail 3 Address", $keys_csv);
  320.             $position = $values_csv[$position3];
  321.             if ( !empty( $position ) )
  322.             {
  323.                 print "EMAIL;TYPE=OTHER:".$position."\n";
  324.             }
  325.    
  326.             // ORG:Bubba Gump Shrimp Co.
  327.             // TITLE:Shrimp Man
  328.             // PHOTO;GIF:http://www.example.com/dir_photos/my_photo.gif
  329.            
  330.             $position = findPos("Home Phone", $keys_csv);
  331.             $phone0 = $values_csv[$position];
  332.             if ( !empty( $phone0 ) )
  333.             {
  334.                 print "TEL;TYPE=home:".$phone0."\n"; // phone0
  335.             }          
  336.  
  337.             $position = findPos("Business Phone", $keys_csv);
  338.             $phone1 = $values_csv[$position];
  339.             if ( !empty( $phone1 ) )
  340.             {
  341.                 print "TEL;TYPE=work:".$phone1."\n"; // phone1
  342.             }
  343.  
  344.             $position = findPos("Mobile Phone", $keys_csv);
  345.             $phone4 = $values_csv[$position];
  346.             if ( !empty( $phone4 ) )
  347.             {
  348.                 print "TEL;TYPE=cell:".$phone4."\n"; // phone3
  349.             }
  350.  
  351.             $position = findPos("Home Fax", $keys_csv);
  352.             $phone2 = $values_csv[$position];
  353.             if ( !empty( $phone2 ) )
  354.             {
  355.                 print 'TEL;TYPE="fax,home":'.$phone2."\n"; // phone2
  356.             }
  357.             $position = findPos("Business Fax", $keys_csv);
  358.             $phone3 = $values_csv[$position];
  359.             if ( !empty( $phone3 ) )
  360.             {
  361.                 print 'TEL;TYPE="fax,work":'.$phone3."\n"; // phone2
  362.             }
  363.  
  364.             // ADR;HOME;PREF:;;100 Waters Edge;Baytown;LA;30314;United States of America
  365.             $street0 = $values_csv[findPos("Home Street", $keys_csv)];
  366.             $street1 = $values_csv[findPos("Home Address 2", $keys_csv)];
  367.             $city0 = $values_csv[findPos("Home City", $keys_csv)];
  368.             $region0 = $values_csv[findPos("Home State", $keys_csv)];
  369.             $postcode0 = $values_csv[findPos("Home Postal Code", $keys_csv)];
  370.             $country0 = $values_csv[findPos("Home Country", $keys_csv)];
  371.            
  372.             if ( ( !empty( $street0 ) ) || ( !empty( $street1 ) ) || ( !empty( $city0 ) ) || ( !empty( $region0 ) ) || ( !empty( $postcode0 ) ) || ( !empty( $country0 ) ) )
  373.             {          
  374.                 print "ADR;TYPE=home:".$street0.";".$street1.";".$city0.";".$region0.";".$postcode0.";".$country0."\n";
  375.             }
  376.    
  377.             // ADR;WORK;PREF:;;100 Waters Edge;Baytown;LA;30314;United States of America
  378.             $street0 = $values_csv[findPos("Business Address", $keys_csv)];
  379.             $street1 = $values_csv[findPos("Business Address 2", $keys_csv)];
  380.             $city0 = $values_csv[findPos("Business City", $keys_csv)];
  381.             $region0 = $values_csv[findPos("Business State", $keys_csv)];
  382.             $postcode0 = $values_csv[findPos("Business Postal Code", $keys_csv)];
  383.             $country0 = $values_csv[findPos("Business Country", $keys_csv)];
  384.  
  385.             if ( ( !empty( $street0 ) ) || ( !empty( $street1 ) ) || ( !empty( $city0 ) ) || ( !empty( $region0 ) ) || ( !empty( $postcode0 ) ) || ( !empty( $country0 ) ) )
  386.             {              
  387.                 print "ADR;TYPE=work:".$street0.";".$street1.";".$city0.";".$region0.";".$postcode0.";".$country0."\n";
  388.             }
  389.  
  390.             // LABEL;WORK;PREF;ENCODING=QUOTED-PRINTABLE;CHARSET=UTF-8:100 Waters Edge=0D==0 ABaytown\, LA 30314=0D=0AUnited States of America
  391.             // ADR;HOME:;;42 Plantation St.;Baytown;LA;30314;United States of America
  392.             // LABEL;HOME;ENCODING=QUOTED-PRINTABLE;CHARSET=UTF-8:42 Plantation St.=0D=0A=
  393.             // Baytown, LA 30314=0D=0AUnited States of America
  394.  
  395.             // Web page
  396.             $position = findPos("Web Page", $keys_csv);
  397.             if ( !empty( $values_csv[$position] ) )
  398.             {
  399.                 print "URL;VALUE=URI:".$values_csv[$position]."\n"; // email0 // EMAIL:
  400.             }
  401.  
  402.             // Web page
  403.             $position = findPos("Web Page 2", $keys_csv);
  404.             if ( !empty( $values_csv[$position] ) )
  405.             {
  406.                 print "URL;VALUE=URI:".$values_csv[$position]."\n"; // email1 // EMAIL:
  407.             }
  408.            
  409.             // NOTE
  410.             $position = findPos("Notes", $keys_csv);
  411.             if ( !empty( $values_csv[$position] ) )
  412.             {
  413.                 print "NOTE:".$values_csv[$position]."\n";
  414.             }
  415.  
  416.             // Birthday
  417.             $position = findPos("Birthday", $keys_csv);
  418.             if ( !empty( $values_csv[$position] ) )
  419.             {
  420.                 print "BDAY:".$values_csv[$position]."\n";
  421.             }
  422.  
  423.             // Categories
  424.             $position = findPos("Categories", $keys_csv);
  425.             if ( !empty( $values_csv[$position] ) )
  426.             {
  427.                 print "CATEGORIES :".$values_csv[$position]."\n"; // email0 // EMAIL:
  428.             }
  429.  
  430.             print "END:VCARD"."\n"; // END:VCARD
  431.         }
  432.     }
  433. }
  434.  
  435. /* determine position of a value in an number-indexed array */
  436. function findPos($value,$array)
  437. {
  438.     $result = null;
  439.     $length = count($array);
  440.     for($i=0;$i<$length;$i++)
  441.     {
  442.         if($array[$i] == $value)
  443.         {
  444.             $result = $i;
  445.             break;
  446.         }
  447.     }
  448.    
  449.     return $result;
  450. }
  451.  
  452.  
  453. echo '
  454.         </div>
  455.         <div class="boxShadows" id="headline">';
  456.        
  457. // if ($_POST['_delimiter'] == ';')
  458. if ($delimiter == ';')
  459. {
  460.     echo '
  461.         <p>EXAMPLE INPUT with ";" : this goes in:</p>
  462.             <div style="overflow:auto;white-space:nowrap;width:100%;" class="codecolorer-container bash default">
  463.                 <pre>
  464. First Name;Last Name;Display Name;Nickname;E-mail Address;E-mail 2 Address;E-mail 3 Address;Home Phone;Business Phone;Home Fax;Business Fax;Pager;Mobile Phone;Home Street;Home Address 2;Home City;Home State;Home Postal Code;Home Country;Business Address;Business Address 2;Business City;Business State;Business Postal Code;Business Country;Country Code;Related name;Job Title;Department;Organization;Notes;Birthday;Anniversary;Gender;Web Page;Web Page 2;Categories
  465. Aprenom1 Anom1;;Aprenom1 Anom1;;[email protected];[email protected];;+33 1 23 45 67 89;+33 2 87 65 43 21;+33 9 12 34 56 78;+33 9 87 65 43 21;;+33 6 12 34 56 78;rue1;rue2;meylan;rhone alpes;38240;france;rue1T;rue2T;Grenoble;isere;38000;france;;;;;;notes;1604-12-08 00:00:00;;;;;test
  466. Aprenom2;Anom2;Aprenom2 Anom2;;[email protected];[email protected];;+33 1 23 45 67 89;+33 9 12 34 76 78;;;;+33 6 56 78 12 34;rue D;rue D étendue;ville D;paca D;12345;france;rue T;rue T étendue;ville T;paca T;23456;france;;;;;;note lig 1 note lig 2 note lig 3;2020-01-05 00:00:00;;;www.xxx.com;;test
  467. Aprenom3;Anom3;Aprenom3 Anom3;;;;;;;;;;+33 6 12 34 56 78;;;;;;;;;;;;;;;;;;;;;;;;test
  468. Aprenom5;Anom5;Aprenom5 Anom5;;;;;;+33 9 87 65 43 21;;;;;;;;;;;;;;;;;;;;;;;;;;;;test
  469. Aprenom4;Anom4;Aprenom4 Anom4;;;;;+33 1 23 45 67 89;+33 9 12 34 56 78;;;;+33 6 87 65 43 21;;;;;;;;;;;;;;;;;;;;;;;;test
  470. Aprenom7;Anom7;Aprenom7 Anom7;;;;;+33 1 23 45 67 89;;;;;;;;;;;;;;;;;;;;;;;;;;;;;test
  471. ;Aprenom Anom;Aprenom Anom;;[email protected];[email protected];[email protected];+33 9 12 34 56 78;+33 9 87 65 43 21;+33 8 12 34 56 78;+33 8 87 65 43 21;;+33 6 12 56 34 78;rueD;;VILLED;;01234;;rueT;;VilleT;;34567;;;;;;;notes en tout genre AAAAAA aaaaaa;2019-12-18 00:00:00;;;;;test
  472. ;;Aprenom6 Anom6;;;;;+33 1 23 45 67 89;;;;;;;;;;;;;;;;;;;;;;;;;;;;;test
  473.                 </pre>
  474.             </div>';
  475. }
  476. else  
  477. //  if ($_POST['_delimiter'] == '   ')
  478.     if ($delimiter == ' ')
  479.     {
  480.     echo '
  481.         <p>EXAMPLE INPUT with " " : this goes in:</p>
  482.             <div style="overflow:auto;white-space:nowrap;width:100%;" class="codecolorer-container bash default">      
  483. First Name  Last Name   Display Name    Nickname    E-mail Address  E-mail 2 Address    E-mail 3 Address    Home Phone  Business Phone  Home Fax    Business Fax    Pager   Mobile Phone    Home Street Home Address 2  Home City   Home State  Home Postal Code    Home Country    Business Address    Business Address 2  Business City   Business State  Business Postal Code    Business Country    Country Code    Related name    Job Title   Department  Organization    Notes   Birthday    Anniversary Gender  Web Page    Web Page 2  Categories
  484. Aprenom1 Anom1      Aprenom1 Anom1      [email protected]  [email protected]       +33 1 23 45 67 89   +33 2 87 65 43 21   +33 9 12 34 56 78   +33 9 87 65 43 21       +33 6 12 34 56 78   rue1    rue2    meylan  rhone alpes 38240   france  rue1T   rue2T   Grenoble    isere   38000   france                      notes   1604-12-08 00:00:00                 test
  485. Aprenom2    Anom2   Aprenom2 Anom2      [email protected]  [email protected]     +33 1 23 45 67 89   +33 9 12 34 76 78               +33 6 56 78 12 34   rue D   rue D étendue  ville D paca D  12345   france  rue T   rue T étendue  ville T paca T  23456   france                      note lig 1 note lig 2 note lig 3    2020-01-05 00:00:00         www.xxx.com     test
  486. Aprenom3    Anom3   Aprenom3 Anom3                                      +33 6 12 34 56 78                                                                                               test
  487. Aprenom5    Anom5   Aprenom5 Anom5                      +33 9 87 65 43 21                                                                                                               test
  488. Aprenom4    Anom4   Aprenom4 Anom4                  +33 1 23 45 67 89   +33 9 12 34 56 78               +33 6 87 65 43 21                                                                                               test
  489. Aprenom7    Anom7   Aprenom7 Anom7                  +33 1 23 45 67 89                                                                                                                   test
  490.     Aprenom Anom    Aprenom Anom        [email protected]  [email protected]  [email protected]  +33 9 12 34 56 78   +33 9 87 65 43 21   +33 8 12 34 56 78   +33 8 87 65 43 21       +33 6 12 56 34 78   rueD        VILLED      01234       rueT        VilleT      34567                           notes en tout genre AAAAAA aaaaaa   2019-12-18 00:00:00                 test
  491.         Aprenom6 Anom6                  +33 1 23 45 67 89                                                                                                                   test
  492.                 </pre>
  493.             </div>';
  494.     }
  495.     else
  496.     {
  497.     echo '
  498.         <p>EXAMPLE INPUT with "," : this goes in:</p>
  499.             <div style="overflow:auto;white-space:nowrap;width:100%;" class="codecolorer-container bash default">
  500.                 <pre>
  501. First Name,Last Name,Display Name,Nickname,E-mail Address,E-mail 2 Address,E-mail 3 Address,Home Phone,Business Phone,Home Fax,Business Fax,Pager,Mobile Phone,Home Street,Home Address 2,Home City,Home State,Home Postal Code,Home Country,Business Address,Business Address 2,Business City,Business State,Business Postal Code,Business Country,Country Code,Related name,Job Title,Department,Organization,Notes,Birthday,Anniversary,Gender,Web Page,Web Page 2,Categories
  502. Aprenom1 Anom1,,Aprenom1 Anom1,,[email protected],[email protected],,+33 1 23 45 67 89,+33 2 87 65 43 21,+33 9 12 34 56 78,+33 9 87 65 43 21,,+33 6 12 34 56 78,rue1,rue2,meylan,rhone alpes,38240,france,rue1T,rue2T,Grenoble,isere,38000,france,,,,,,notes,1604-12-08 00:00:00,,,,,test
  503. Aprenom2,Anom2,Aprenom2 Anom2,,[email protected],[email protected],,+33 1 23 45 67 89,+33 9 12 34 76 78,,,,+33 6 56 78 12 34,rue D,rue D étendue,ville D,paca D,12345,france,rue T,rue T étendue,ville T,paca T,23456,france,,,,,,note lig 1 note lig 2 note lig 3,2020-01-05 00:00:00,,,www.xxx.com,,test
  504. Aprenom3,Anom3,Aprenom3 Anom3,,,,,,,,,,+33 6 12 34 56 78,,,,,,,,,,,,,,,,,,,,,,,,test
  505. Aprenom5,Anom5,Aprenom5 Anom5,,,,,,+33 9 87 65 43 21,,,,,,,,,,,,,,,,,,,,,,,,,,,,test
  506. Aprenom4,Anom4,Aprenom4 Anom4,,,,,+33 1 23 45 67 89,+33 9 12 34 56 78,,,,+33 6 87 65 43 21,,,,,,,,,,,,,,,,,,,,,,,,test
  507. Aprenom7,Anom7,Aprenom7 Anom7,,,,,+33 1 23 45 67 89,,,,,,,,,,,,,,,,,,,,,,,,,,,,,test
  508. ,Aprenom Anom,Aprenom Anom,,[email protected],[email protected],[email protected],+33 9 12 34 56 78,+33 9 87 65 43 21,+33 8 12 34 56 78,+33 8 87 65 43 21,,+33 6 12 56 34 78,rueD,,VILLED,,01234,,rueT,,VilleT,,34567,,,,,,,notes en tout genre AAAAAA aaaaaa,2019-12-18 00:00:00,,,,,test
  509. ,,Aprenom6 Anom6,,,,,+33 1 23 45 67 89,,,,,,,,,,,,,,,,,,,,,,,,,,,,,test
  510.                 </pre>
  511.             </div>';
  512.     }
  513.  
  514. echo '
  515.         </div>
  516.         <div class="boxShadows" id="headline">
  517.         <p>this comes out: (This comes from the nextcloud address book)</p>
  518.             <div style="overflow:auto;white-space:nowrap;width:100%;" class="codecolorer-container bash default">
  519.                 <pre>
  520. BEGIN:VCARD
  521. VERSION:2.1
  522. N:Aprenom1 Anom1;;;
  523. FN:Aprenom1 Anom1
  524. EMAIL;TYPE=home:[email protected]
  525. EMAIL;TYPE=work:[email protected]
  526. TEL;TYPE=home:+33 1 23 45 67 89
  527. TEL;TYPE=work:+33 2 87 65 43 21
  528. TEL;TYPE="fax,home":+33 9 12 34 56 78
  529. TEL;TYPE="fax,work":+33 9 87 65 43 21
  530. TEL;TYPE=cell:+33 6 12 34 56 78
  531. ADR;TYPE=home:rue1;rue2;meylan;rhone alpes;38240;france
  532. ADR;TYPE=work:rue1T;rue2T;Grenoble;isere;38000;france
  533. NOTE:notes
  534. BDAY:1604-12-08 00:00:00
  535. END:VCARD
  536. BEGIN:VCARD
  537. VERSION:2.1
  538. N:Aprenom2;Anom2;;
  539. FN:Aprenom2 Anom2
  540. EMAIL;TYPE=home:[email protected]
  541. EMAIL;TYPE=work:[email protected]
  542. TEL;TYPE=home:+33 1 23 45 67 89
  543. TEL;TYPE=work:+33 9 12 34 76 78
  544. TEL;TYPE=cell:+33 6 56 78 12 34
  545. ADR;TYPE=home:rue D;rue D étendue;ville D;paca D;12345;france
  546. ADR;TYPE=work:rue T;rue T étendue;ville T;paca T;23456;france
  547. URL;VALUE=URI:www.xxx.com
  548. NOTE:note lig 1 note lig 2 note lig 3
  549. BDAY:2020-01-05 00:00:00
  550. END:VCARD
  551. BEGIN:VCARD
  552. VERSION:2.1
  553. N:Aprenom3;Anom3;;
  554. FN:Aprenom3 Anom3
  555. TEL;TYPE=cell:+33 6 12 34 56 78
  556. END:VCARD
  557. BEGIN:VCARD
  558. VERSION:2.1
  559. N:Aprenom5;Anom5;;
  560. FN:Aprenom5 Anom5
  561. TEL;TYPE=work:+33 9 87 65 43 21
  562. END:VCARD
  563. BEGIN:VCARD
  564. VERSION:2.1
  565. N:Aprenom4;Anom4;;
  566. FN:Aprenom4 Anom4
  567. TEL;TYPE=home:+33 1 23 45 67 89
  568. TEL;TYPE=work:+33 9 12 34 56 78
  569. TEL;TYPE=cell:+33 6 87 65 43 21
  570. END:VCARD
  571. BEGIN:VCARD
  572. VERSION:2.1
  573. N:Aprenom7;Anom7;;
  574. FN:Aprenom7 Anom7
  575. TEL;TYPE=home:+33 1 23 45 67 89
  576. END:VCARD
  577. BEGIN:VCARD
  578. VERSION:2.1
  579. N:;Aprenom Anom;;
  580. FN:Aprenom Anom
  581. EMAIL;TYPE=home:[email protected]
  582. EMAIL;TYPE=work:[email protected]
  583. EMAIL;TYPE=OTHER:[email protected]
  584. TEL;TYPE=home:+33 9 12 34 56 78
  585. TEL;TYPE=work:+33 9 87 65 43 21
  586. TEL;TYPE="fax,home":+33 8 12 34 56 78
  587. TEL;TYPE="fax,work":+33 8 87 65 43 21
  588. TEL;TYPE=cell:+33 6 12 56 34 78
  589. ADR;TYPE=home:rueD;;VILLED;;01234;
  590. ADR;TYPE=work:rueT;;VilleT;;34567;
  591. NOTE:notes en tout genre AAAAAA aaaaaa
  592. BDAY:2019-12-18 00:00:00
  593. END:VCARD
  594. BEGIN:VCARD
  595. VERSION:2.1
  596. FN:Aprenom6 Anom6
  597. TEL;TYPE=home:+33 1 23 45 67 89
  598. END:VCARD
  599.                 </pre>
  600.             </div>
  601.         </div>
  602.     </body>
  603. </html>
  604. ';
  605. ?>
Add Comment
Please, Sign In to add comment