Advertisement
Guest User

ecureuil-php-csv-vcf

a guest
Jan 11th, 2020
210
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 22.75 KB | None | 0 0
  1. <?php
  2. error_reporting(E_ALL & ~E_NOTICE); // report all errors except notices
  3. echo '
  4.     <!DOCTYPE html>
  5.     <html lang="en">
  6.     <head>
  7.     <meta charset="utf-8">
  8.     <meta http-equiv="X-UA-Compatible" content="IE=edge">
  9.     <meta name="viewport" content="width=device-width, initial-scale=1">
  10.     <meta name="description" content="convert csv2vcf" />
  11.     <meta name="keywords" content="csv2vcf" />
  12.     <title>convert csv2vcf</title>
  13.     <!-- external styles -->
  14.     <link href="css/style.css" type="text/css" rel="stylesheet"/>
  15.     </head>
  16.         <body>     
  17.             <div class="boxShadows" id="headline">
  18.                 <h1>csv2vcf: convert *.csv to *.vcf</h1>
  19. ';
  20. /* === examples for different vCard Versions according to Wikpedia ===
  21. vCard 2.1
  22.  
  23. BEGIN:VCARD
  24. VERSION:2.1
  25. N:Gump;Forrest;;Mr.
  26. FN:Forrest Gump
  27. ORG:Bubba Gump Shrimp Co.
  28. TITLE:Shrimp Man
  29. PHOTO;GIF:http://www.example.com/dir_photos/my_photo.gif
  30. TEL;WORK;VOICE:(111) 555-1212
  31. TEL;HOME;VOICE:(404) 555-1212
  32. ADR;WORK;PREF:;;100 Waters Edge;Baytown;LA;30314;United States of America
  33. LABEL;WORK;PREF;ENCODING=QUOTED-PRINTABLE;CHARSET=UTF-8:100 Waters Edge=0D=
  34.  =0ABaytown\, LA 30314=0D=0AUnited States of America
  35. ADR;HOME:;;42 Plantation St.;Baytown;LA;30314;United States of America
  36. LABEL;HOME;ENCODING=QUOTED-PRINTABLE;CHARSET=UTF-8:42 Plantation St.=0D=0A=
  37.  Baytown, LA 30314=0D=0AUnited States of America
  38. REV:20080424T195243Z
  39. END:VCARD
  40.  
  41. vCard 3.0
  42.  
  43. BEGIN:VCARD
  44. VERSION:3.0
  45. N:Gump;Forrest;;Mr.
  46. FN:Forrest Gump
  47. ORG:Bubba Gump Shrimp Co.
  48. TITLE:Shrimp Man
  49. PHOTO;VALUE=URI;TYPE=GIF:http://www.example.com/dir_photos/my_photo.gif
  50. TEL;TYPE=WORK,VOICE:(111) 555-1212
  51. TEL;TYPE=HOME,VOICE:(404) 555-1212
  52. ADR;TYPE=WORK,PREF:;;100 Waters Edge;Baytown;LA;30314;United States of Amer
  53.  ica
  54. LABEL;TYPE=WORK,PREF:100 Waters Edge\nBaytown\, LA 30314\nUnited States of
  55.  America
  56. ADR;TYPE=HOME:;;42 Plantation St.;Baytown;LA;30314;United States of America
  57. LABEL;TYPE=HOME:42 Plantation St.\nBaytown\, LA 30314\nUnited States of Ame
  58.  rica
  59. REV:2008-04-24T19:52:43Z
  60. END:VCARD
  61.  
  62. vCard 4.0
  63.  
  64. BEGIN:VCARD
  65. VERSION:4.0
  66. N:Forrest;Gump;;Mr.;
  67. FN:Forrest Gump
  68. ORG:Bubba Gump Shrimp Co.
  69. TITLE:Shrimp Man
  70. PHOTO;MEDIATYPE=image/gif:http://www.example.com/dir_photos/my_photo.gif
  71. TEL;TYPE=work,voice;VALUE=uri:tel:+1-111-555-1212
  72. TEL;TYPE=home,voice;VALUE=uri:tel:+1-404-555-1212
  73. ADR;TYPE=work;LABEL="100 Waters Edge\nBaytown, LA 30314\nUnited States of A
  74.  merica";PREF=1:;;100 Waters Edge;Baytown;LA;30314;United States of America
  75. ADR;TYPE=home;LABEL="42 Plantation St.\nBaytown, LA 30314\nUnited States of
  76.  America":;;42 Plantation St.;Baytown;LA;30314;United States of America
  77. REV:20080424T195243Z
  78. END:VCARD
  79.  
  80. <p>You can put as separator: ',' ';' or tab </p>
  81.  */
  82.  
  83. if(isset($_REQUEST["convert"])) // detect upload of file
  84. {
  85.     $allowedExts = array('csv','txt'); // MMM
  86.     $maximumFileSizeInKBytes = 4096;
  87.  
  88.     $allowedExts_string = "";
  89.     for($i=0;$i<count($allowedExts);$i++) {
  90.         $allowedExts_string .= "*.".$allowedExts[$i].", ";
  91.     }
  92.    
  93.     $maximumFileSizeInBytes = $maximumFileSizeInKBytes * 1024;
  94. //  $delimiter = $_POST['_delimiter'] == 'tab' ? "\t" : $_POST['_delimiter'];
  95.    
  96.     if($_FILES)
  97.     {
  98.  
  99.         if(checkExtension($allowedExts)) // MMM
  100.         {
  101.             if(($_FILES["file"]["size"] < $maximumFileSizeInBytes))
  102.             {
  103.                 if ($_FILES["file"]["error"] > 0)
  104.                 {
  105.                     echo "Return Code: " . $_FILES["file"]["error"] . "<br>";
  106.                 }
  107.                 else
  108.                 {
  109.                     echo '<div id="uploadDetails">';
  110.                     echo "Name: ".$_FILES["file"]["name"]."<br>";
  111.                     echo "Type: " . $_FILES["file"]["type"] . "<br>";
  112.                     echo "Size: " . ($_FILES["file"]["size"] / 1024) . " kB<br>";
  113.                     echo "Temp file: ".$_FILES["file"]["tmp_name"] . "<br>";
  114.                     echo "field selector:".$delimiter."ZZZ<br>";
  115.                     convert($_FILES["file"]["tmp_name"]);
  116.                     echo '</div>';
  117.                 }
  118.             }
  119.             else
  120.             {
  121.                 echo "File exceeds filezie limit of ".$maximumFileSizeInBytes."kByte.";
  122.             }
  123.         }
  124.         else
  125.         {
  126.             echo "File was not a allowed filetypes: ".$allowedExts_string;
  127.         }
  128.     }
  129. }
  130. else
  131. {
  132.  
  133.     echo '
  134.  
  135.             <form method="post" enctype="multipart/form-data">
  136.                 <label for="file">Please select your File.csv then hit convert:</label>
  137.                 <input type="file" name="file" id="file" style="width: 100%;">
  138.                 <br />
  139.                 field selector :
  140.                 <select name="$delimiter" onchange="set_form_fields(this)">
  141.                     <option value=",">Comma</option>
  142.                     <option value=";">Semicolon</option>
  143.                     <option value="\t">Tab</option>
  144.                 </select><br />
  145.                 <input type="submit" name="convert" value="convert" style="width: 100%;">
  146.             </form>
  147.             <p>the following fields in the *.csv will be converted:</p>
  148.             <div style="overflow:auto;white-space:nowrap;width:100%;" class="codecolorer-container bash default">
  149.                 <pre>
  150. First Name
  151. Last Name
  152. Display Name
  153. Nicknam
  154. E-mail Address
  155. E-mail 2 Address
  156. E-mail 3 Address
  157. Home Phone
  158. Business Phone
  159. Home Fax
  160. Business Fax
  161. Pager
  162. Mobile Phone
  163. Home Street
  164. Home Address 2
  165. Home City
  166. Home State
  167. Home Postal Code
  168. Home Country
  169. Business Address
  170. Business Address 2
  171. Business City
  172. Business State
  173. Business Postal Code
  174. Business Country
  175. Country Code
  176. Related name
  177. Job Title
  178. Department
  179. Organization
  180. Notes
  181. Birthday
  182. Anniversary
  183. Gender
  184. Web Page
  185. Web Page 2
  186. Categories
  187.             </pre>
  188.             </div>
  189.         </div>
  190.     ';
  191. }
  192.  
  193. // MMM verifie que le fichier envoye a l'une des extensions de $allowedExts
  194. function checkExtension(array $allowedExts)
  195. {
  196.     $upload_filename = $_FILES["file"]["name"];
  197.     $upload_filename_array = explode(".", $upload_filename);
  198.     $extension = strtolower(end($upload_filename_array));
  199.  
  200.     $key = array_search($extension, $allowedExts);
  201.     return $key !== false;
  202. }
  203.  
  204.  
  205. function convert($filename_csv)
  206. {
  207.     // $filename_csv = "export2016.06.24.csv";
  208.    
  209.     $lines_csv = file($filename_csv);
  210.    
  211.     $filename_extension = explode('.',$filename_csv);
  212.    
  213.     $filename_vcf = "./upload/".$_FILES["file"]["name"].".vcf";
  214.    
  215.     $file_vcf = fopen($filename_vcf, 'w') or die("can't open file");
  216.    
  217.     echo '<pre>generating vCard-Version: VERSION:2.1</pre>';
  218.    
  219.     // display name;phone0;phone1;phone2;phone3;phone4;phone5;phone6;phone7;phone8;phone9;phone10;phone11;phone12;phone13;phone14;phone15;phone16;phone17;phone18;phone19;
  220.     // email0;email_type0;email_label0;email1;email_type1;email_label1;email2;email_type2;email_label2;email3;email_type3;email_label3;email4;email_type4;email_label4;email5;email_type5;email_label5;email6;email_type6;email_label6;email7;email_type7;email_label7;email8;email_type8;email_label8;email9;email_type9;email_label9;email10;email_type10;email_label10;email11;email_type11;email_label11;email12;email_type12;email_label12;email13;email_type13;email_label13;
  221.     // pobox0;street0;city0;region0;postcode0;country0;type0;pobox1;
  222.     // street1;city1;region1;postcode1;country1;type1;pobox2;street2;city2;region2;postcode2;country2;type2;pobox3;street3;city3;region3;postcode3;country3;type3;pobox4;street4;city4;region4;postcode4;country4;type4;pobox5;street5;city5;region5;postcode5;country5;type5;pobox6;street6;city6;region6;postcode6;country6;type6;pobox7;street7;city7;region7;postcode7;country7;type7;pobox8;street8;city8;region8;postcode8;country8;type8;pobox9;street9;city9;region9;postcode9;country9;type9;pobox10;street10;city10;region10;postcode10;country10;type10;pobox11;street11;city11;region11;postcode11;country11;type11;pobox12;street12;city12;region12;postcode12;country12;type12;pobox13;street13;city13;region13;postcode13;country13;type13;organistion0;title0;organistion1;title1;organistion2;title2;organistion3;title3;
  223.    
  224.     // ==== fields to match ====
  225.     // display name
  226.     // street0 city0 region0 postcode0
  227.     // phone0 phone1 phone2 phone3
  228.     // email0
  229.     // organistion0
  230.  
  231.     // 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
  232.    
  233.     // get all possible fields in android-vcf
  234.     $length = count($lines_csv);
  235.     for($i = 0;$i < $length;$i++)
  236.     {
  237.         if($i == 0)
  238.         {
  239.             $keys_csv = $lines_csv[$i];
  240.             $keys_csv = explode(";",$keys_csv);
  241.         }
  242.         else
  243.         {
  244.             fwrite($file_vcf, "BEGIN:VCARD\n"); // what Version does this file have
  245.             fwrite($file_vcf, "VERSION:2.1\n"); // what Version does this file have
  246.    
  247.             $values_csv = $lines_csv[$i];
  248.             $values_csv = explode(";",$values_csv);
  249.    
  250.             $position1 = findPos("First Name", $keys_csv);
  251.             $position2 = findPos("Last Name", $keys_csv);
  252.             $position = $values_csv[$position1] . ";" . $values_csv[$position2]. ";;" ;
  253.             if ( ( $position ) !== ";;;")
  254.             {
  255.                 fwrite($file_vcf, "N:".$position."\n"); // N:Gump;Forrest;;Mr.
  256.             }          
  257.  
  258.             $position3 = findPos("Display Name", $keys_csv);
  259.             $position = $values_csv[$position3];
  260.             if ( !empty( $position ) )
  261.             {
  262.                 fwrite($file_vcf, "FN:".$position."\n"); // FN:Forrest Gump
  263.             }          
  264.            
  265.             $position3 = findPos("E-mail Address", $keys_csv);
  266.             $position = $values_csv[$position3];
  267.             if ( !empty( $position ) )
  268.             {
  269.                 fwrite($file_vcf, "EMAIL;TYPE=home:".$position."\n");
  270.             }
  271.  
  272.             $position3 = findPos("E-mail 2 Address", $keys_csv);
  273.             $position = $values_csv[$position3];
  274.             if ( !empty( $position ) )
  275.             {
  276.                 fwrite($file_vcf, "EMAIL;TYPE=work:".$position."\n");
  277.             }
  278.  
  279.             $position3 = findPos("E-mail 3 Address", $keys_csv);
  280.             $position = $values_csv[$position3];
  281.             if ( !empty( $position ) )
  282.             {
  283.                 fwrite($file_vcf, "EMAIL;TYPE=OTHER:".$position."\n");
  284.             }
  285.    
  286.             // ORG:Bubba Gump Shrimp Co.
  287.             // TITLE:Shrimp Man
  288.             // PHOTO;GIF:http://www.example.com/dir_photos/my_photo.gif
  289.            
  290.             // if phone1 differs from phone0
  291.             $position = findPos("Home Phone", $keys_csv);
  292.             $phone0 = $values_csv[$position];
  293.             if ( !empty( $phone0 ) )
  294.             {
  295.                 fwrite($file_vcf, "TEL;TYPE=home:".$phone0."\n"); // phone0
  296.             }          
  297.  
  298.             $position = findPos("Business Phone", $keys_csv);
  299.             $phone1 = $values_csv[$position];
  300.             if ( !empty( $phone1 ) )
  301.             {
  302.                 fwrite($file_vcf, "TEL;TYPE=work:".$phone1."\n"); // phone1
  303.             }
  304.  
  305.             $position = findPos("Home Fax", $keys_csv);
  306.             $phone2 = $values_csv[$position];
  307.             if ( !empty( $phone2 ) )
  308.             {
  309.                 fwrite($file_vcf, 'TEL;TYPE="fax,home":'.$phone2."\n"); // phone2
  310.             }
  311.             $position = findPos("Business Fax", $keys_csv);
  312.             $phone3 = $values_csv[$position];
  313.             if ( !empty( $phone3 ) )
  314.             {
  315.                 fwrite($file_vcf, 'TEL;TYPE="fax,work":'.$phone3."\n"); // phone2
  316.             }
  317.  
  318.             $position = findPos("Mobile Phone", $keys_csv);
  319.             $phone4 = $values_csv[$position];
  320.             if ( !empty( $phone4 ) )
  321.             {
  322.                 fwrite($file_vcf, "TEL;TYPE=cell:".$phone4."\n"); // phone3
  323.             }
  324.  
  325.             // ADR;HOME;PREF:;;100 Waters Edge;Baytown;LA;30314;United States of America
  326.             $street0 = $values_csv[findPos("Home Street", $keys_csv)];
  327.             $street1 = $values_csv[findPos("Home Address 2", $keys_csv)];
  328.             $city0 = $values_csv[findPos("Home City", $keys_csv)];
  329.             $region0 = $values_csv[findPos("Home State", $keys_csv)];
  330.             $postcode0 = $values_csv[findPos("Home Postal Code", $keys_csv)];
  331.             $country0 = $values_csv[findPos("Home Country", $keys_csv)];
  332.            
  333.             if ( ( !empty( $street0 ) ) || ( !empty( $street1 ) ) || ( !empty( $city0 ) ) || ( !empty( $region0 ) ) || ( !empty( $postcode0 ) ) || ( !empty( $country0 ) ) )
  334.             {          
  335.                 fwrite($file_vcf, "ADR;TYPE=home:".$street0.";".$street1.";".$city0.";".$region0.";".$postcode0.";".$country0."\n");
  336.             }
  337.    
  338.             // ADR;WORK;PREF:;;100 Waters Edge;Baytown;LA;30314;United States of America
  339.             $street0 = $values_csv[findPos("Business Address", $keys_csv)];
  340.             $street1 = $values_csv[findPos("Business Address 2", $keys_csv)];
  341.             $city0 = $values_csv[findPos("Business City", $keys_csv)];
  342.             $region0 = $values_csv[findPos("Business State", $keys_csv)];
  343.             $postcode0 = $values_csv[findPos("Business Postal Code", $keys_csv)];
  344.             $country0 = $values_csv[findPos("Business Country", $keys_csv)];
  345.  
  346.             if ( ( !empty( $street0 ) ) || ( !empty( $street1 ) ) || ( !empty( $city0 ) ) || ( !empty( $region0 ) ) || ( !empty( $postcode0 ) ) || ( !empty( $country0 ) ) )
  347.             {              
  348.                 fwrite($file_vcf, "ADR;TYPE=work:".$street0.";".$street1.";".$city0.";".$region0.";".$postcode0.";".$country0."\n");
  349.             }
  350.  
  351.             // LABEL;WORK;PREF;ENCODING=QUOTED-PRINTABLE;CHARSET=UTF-8:100 Waters Edge=0D==0 ABaytown\, LA 30314=0D=0AUnited States of America
  352.             // ADR;HOME:;;42 Plantation St.;Baytown;LA;30314;United States of America
  353.             // LABEL;HOME;ENCODING=QUOTED-PRINTABLE;CHARSET=UTF-8:42 Plantation St.=0D=0A=
  354.             // Baytown, LA 30314=0D=0AUnited States of America
  355.  
  356.             // Web page
  357.             $position = findPos("Web Page", $keys_csv);
  358.             if ( !empty( $values_csv[$position] ) )
  359.             {
  360.                 fwrite($file_vcf, "URL;VALUE=URI:".$values_csv[$position]."\n"); // email0 // EMAIL:
  361.             }
  362.  
  363.             // Web page
  364.             $position = findPos("Web Page 2", $keys_csv);
  365.             if ( !empty( $values_csv[$position] ) )
  366.             {
  367.                 fwrite($file_vcf, "URL;VALUE=URI:".$values_csv[$position]."\n"); // email1 // EMAIL:
  368.             }
  369.            
  370.             // NOTE
  371.             $position = findPos("Notes", $keys_csv);
  372.             if ( !empty( $values_csv[$position] ) )
  373.             {
  374.                 fwrite($file_vcf, "NOTE:".$values_csv[$position]."\n");
  375.             }
  376.  
  377.             // Birthday
  378.             $position = findPos("Birthday", $keys_csv);
  379.             if ( !empty( $values_csv[$position] ) )
  380.             {
  381.                 fwrite($file_vcf, "BDAY:".$values_csv[$position]."\n");
  382.             }
  383.  
  384.             // Categories
  385.             $position = findPos("Categories", $keys_csv);
  386.             if ( !empty( $values_csv[$position] ) )
  387.             {
  388.                 fwrite($file_vcf, "CATEGORIES :".$values_csv[$position]."\n"); // email0 // EMAIL:
  389.             }
  390.  
  391.             fwrite($file_vcf, "END:VCARD"."\n"); // END:VCARD
  392.         }
  393.     }
  394.    
  395.     fclose($file_vcf);
  396.  
  397.     // move_uploaded_file($_FILES["file"]["tmp_name"],"upload/".$_FILES["file"]["name"]);
  398.  
  399.     echo "<pre> ".$length." entries transformed</pre>";
  400.    
  401.     echo '<span style="color: green; font-weight: bold;">Please DOWNLOAD RESULT: <a href="'.$filename_vcf.'">'.$filename_vcf.'</a></span>'; // $_FILES["file"]["name"]
  402.  
  403.     echo '<h1><a href="index.php">Do it again</a></h1>';
  404.     // header("Content-type: text/plain");
  405.     // header('Content-Disposition: attachment; filename="'.$filename_vcf.'"');
  406.  
  407.     /*
  408.     echo '<h1>The result will selfdestruct in 60 seconds</h1>';
  409.     sleep(60);
  410.    
  411.     if(!unlink($filename_vcf))
  412.     {
  413.         echo ("Error deleting ".$filename_vcf);
  414.     }
  415.     else
  416.     {
  417.         echo ("Deleted ".$filename_vcf);
  418.     }
  419.     */
  420. }
  421.  
  422. /* determine position of a value in an number-indexed array */
  423. function findPos($value,$array)
  424. {
  425.     $result = null;
  426.     $length = count($array);
  427.     for($i=0;$i<$length;$i++)
  428.     {
  429.         if($array[$i] == $value)
  430.         {
  431.             $result = $i;
  432.             break;
  433.         }
  434.     }
  435.    
  436.     return $result;
  437. }
  438.  
  439. echo '
  440.         </div>
  441.         <div class="boxShadows" id="headline">';
  442.        
  443. if ($_POST['_delimiter'] == ';')
  444. {
  445.     echo '
  446.         <p>EXAMPLE INPUT with ";" : this goes in:</p>
  447.             <div style="overflow:auto;white-space:nowrap;width:100%;" class="codecolorer-container bash default">
  448.                 <pre>
  449. 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
  450. 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
  451. 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
  452. Aprenom3;Anom3;Aprenom3 Anom3;;;;;;;;;;+33 6 12 34 56 78;;;;;;;;;;;;;;;;;;;;;;;;test
  453. Aprenom5;Anom5;Aprenom5 Anom5;;;;;;+33 9 87 65 43 21;;;;;;;;;;;;;;;;;;;;;;;;;;;;test
  454. Aprenom4;Anom4;Aprenom4 Anom4;;;;;+33 1 23 45 67 89;+33 9 12 34 56 78;;;;+33 6 87 65 43 21;;;;;;;;;;;;;;;;;;;;;;;;test
  455. Aprenom7;Anom7;Aprenom7 Anom7;;;;;+33 1 23 45 67 89;;;;;;;;;;;;;;;;;;;;;;;;;;;;;test
  456. ;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
  457. ;;Aprenom6 Anom6;;;;;+33 1 23 45 67 89;;;;;;;;;;;;;;;;;;;;;;;;;;;;;test
  458.                 </pre>
  459.             </div>';
  460. }
  461. else  
  462.     if ($_POST['_delimiter'] == '\t')
  463.     {
  464.     echo '
  465.         <p>EXAMPLE INPUT with " " : this goes in:</p>
  466.             <div style="overflow:auto;white-space:nowrap;width:100%;" class="codecolorer-container bash default">      
  467. 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
  468. 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
  469. 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
  470. Aprenom3    Anom3   Aprenom3 Anom3                                      +33 6 12 34 56 78                                                                                               test
  471. Aprenom5    Anom5   Aprenom5 Anom5                      +33 9 87 65 43 21                                                                                                               test
  472. Aprenom4    Anom4   Aprenom4 Anom4                  +33 1 23 45 67 89   +33 9 12 34 56 78               +33 6 87 65 43 21                                                                                               test
  473. Aprenom7    Anom7   Aprenom7 Anom7                  +33 1 23 45 67 89                                                                                                                   test
  474.     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
  475.         Aprenom6 Anom6                  +33 1 23 45 67 89                                                                                                                   test
  476.                 </pre>
  477.             </div>';
  478.     }
  479.     else
  480.     {
  481.     echo '
  482.         <p>EXAMPLE INPUT with "," : this goes in:</p>
  483.             <div style="overflow:auto;white-space:nowrap;width:100%;" class="codecolorer-container bash default">
  484.                 <pre>
  485. 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
  486. 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
  487. 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
  488. Aprenom3,Anom3,Aprenom3 Anom3,,,,,,,,,,+33 6 12 34 56 78,,,,,,,,,,,,,,,,,,,,,,,,test
  489. Aprenom5,Anom5,Aprenom5 Anom5,,,,,,+33 9 87 65 43 21,,,,,,,,,,,,,,,,,,,,,,,,,,,,test
  490. Aprenom4,Anom4,Aprenom4 Anom4,,,,,+33 1 23 45 67 89,+33 9 12 34 56 78,,,,+33 6 87 65 43 21,,,,,,,,,,,,,,,,,,,,,,,,test
  491. Aprenom7,Anom7,Aprenom7 Anom7,,,,,+33 1 23 45 67 89,,,,,,,,,,,,,,,,,,,,,,,,,,,,,test
  492. ,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
  493. ,,Aprenom6 Anom6,,,,,+33 1 23 45 67 89,,,,,,,,,,,,,,,,,,,,,,,,,,,,,test
  494.                 </pre>
  495.             </div>';
  496.     }
  497.  
  498. echo '
  499.         </div>
  500.         <div class="boxShadows" id="headline">
  501.         <p>this comes out: (this is what android contact book understands)</p>
  502.             <div style="overflow:auto;white-space:nowrap;width:100%;" class="codecolorer-container bash default">
  503.                 <pre>
  504. BEGIN:VCARD
  505. VERSION:2.1
  506. N:Aprenom1 Anom1;;;
  507. FN:Aprenom1 Anom1
  508. EMAIL;TYPE=home:[email protected]
  509. EMAIL;TYPE=work:[email protected]
  510. TEL;TYPE=home:+33 1 23 45 67 89
  511. TEL;TYPE=work:+33 2 87 65 43 21
  512. TEL;TYPE="fax,home":+33 9 12 34 56 78
  513. TEL;TYPE="fax,work":+33 9 87 65 43 21
  514. TEL;TYPE=cell:+33 6 12 34 56 78
  515. ADR;TYPE=home:rue1;rue2;meylan;rhone alpes;38240;france
  516. ADR;TYPE=work:rue1T;rue2T;Grenoble;isere;38000;france
  517. NOTE:notes
  518. BDAY:1604-12-08 00:00:00
  519. END:VCARD
  520. BEGIN:VCARD
  521. VERSION:2.1
  522. N:Aprenom2;Anom2;;
  523. FN:Aprenom2 Anom2
  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 9 12 34 76 78
  528. TEL;TYPE=cell:+33 6 56 78 12 34
  529. ADR;TYPE=home:rue D;rue D étendue;ville D;paca D;12345;france
  530. ADR;TYPE=work:rue T;rue T étendue;ville T;paca T;23456;france
  531. URL;VALUE=URI:www.xxx.com
  532. NOTE:note lig 1 note lig 2 note lig 3
  533. BDAY:2020-01-05 00:00:00
  534. END:VCARD
  535. BEGIN:VCARD
  536. VERSION:2.1
  537. N:Aprenom3;Anom3;;
  538. FN:Aprenom3 Anom3
  539. TEL;TYPE=cell:+33 6 12 34 56 78
  540. END:VCARD
  541. BEGIN:VCARD
  542. VERSION:2.1
  543. N:Aprenom5;Anom5;;
  544. FN:Aprenom5 Anom5
  545. TEL;TYPE=work:+33 9 87 65 43 21
  546. END:VCARD
  547. BEGIN:VCARD
  548. VERSION:2.1
  549. N:Aprenom4;Anom4;;
  550. FN:Aprenom4 Anom4
  551. TEL;TYPE=home:+33 1 23 45 67 89
  552. TEL;TYPE=work:+33 9 12 34 56 78
  553. TEL;TYPE=cell:+33 6 87 65 43 21
  554. END:VCARD
  555. BEGIN:VCARD
  556. VERSION:2.1
  557. N:Aprenom7;Anom7;;
  558. FN:Aprenom7 Anom7
  559. TEL;TYPE=home:+33 1 23 45 67 89
  560. END:VCARD
  561. BEGIN:VCARD
  562. VERSION:2.1
  563. N:;Aprenom Anom;;
  564. FN:Aprenom Anom
  565. EMAIL;TYPE=home:[email protected]
  566. EMAIL;TYPE=work:[email protected]
  567. EMAIL;TYPE=OTHER:[email protected]
  568. TEL;TYPE=home:+33 9 12 34 56 78
  569. TEL;TYPE=work:+33 9 87 65 43 21
  570. TEL;TYPE="fax,home":+33 8 12 34 56 78
  571. TEL;TYPE="fax,work":+33 8 87 65 43 21
  572. TEL;TYPE=cell:+33 6 12 56 34 78
  573. ADR;TYPE=home:rueD;;VILLED;;01234;
  574. ADR;TYPE=work:rueT;;VilleT;;34567;
  575. NOTE:notes en tout genre AAAAAA aaaaaa
  576. BDAY:2019-12-18 00:00:00
  577. END:VCARD
  578. BEGIN:VCARD
  579. VERSION:2.1
  580. FN:Aprenom6 Anom6
  581. TEL;TYPE=home:+33 1 23 45 67 89
  582. END:VCARD
  583.                 </pre>
  584.             </div>
  585.         </div>
  586.     </body>
  587. </html>
  588. ';
  589. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement