Advertisement
Guest User

ecureuil-php-csv-vcf-2

a guest
Jan 11th, 2020
154
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 23.43 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.     $delimiter = $_POST['_delimiter'];
  96.    
  97.     if($_FILES)
  98.     {
  99.  
  100.         if(checkExtension($allowedExts)) // MMM
  101.         {
  102.             if(($_FILES["file"]["size"] < $maximumFileSizeInBytes))
  103.             {
  104.                 if ($_FILES["file"]["error"] > 0)
  105.                 {
  106.                     echo "Return Code: " . $_FILES["file"]["error"] . "<br>";
  107.                 }
  108.                 else
  109.                 if ($delimiter == "")
  110.                 {
  111.                     echo "field selector not selected";
  112.                 }
  113.                 else
  114.                 {
  115.                     echo '<div id="uploadDetails">';
  116.                     echo "Name: ".$_FILES["file"]["name"]."<br>";
  117.                     echo "Type: " . $_FILES["file"]["type"] . "<br>";
  118.                     echo "Size: " . ($_FILES["file"]["size"] / 1024) . " kB<br>";
  119.                     echo "Temp file: ".$_FILES["file"]["tmp_name"] . "<br>";
  120. //                  echo "field selector:  ".$_POST['_delimiter']."   ZZZ<br>";
  121.                     echo "field selector:  '".$delimiter."'  <br>";
  122.                     convert($_FILES["file"]["tmp_name"],$delimiter);
  123.                     echo '</div>';
  124.                 }
  125.             }
  126.             else
  127.             {
  128.                 echo "File exceeds filezie limit of ".$maximumFileSizeInBytes."kByte.";
  129.             }
  130.         }
  131.         else
  132.         {
  133.             echo "File was not a allowed filetypes: ".$allowedExts_string;
  134.         }
  135.     }
  136. }
  137. else
  138. {
  139.  
  140.     echo '
  141.  
  142.             <form method="post" enctype="multipart/form-data">
  143.                 <label for="file">Please select your File.csv then hit convert:</label>
  144.                 <input type="file" name="file" id="file" style="width: 100%;">
  145.                 <br />
  146.                 field selector :
  147.                 <select name="_delimiter" >
  148.                     <option value=""></option>
  149.                     <option value=",">Comma</option>
  150.                     <option value=";">Semicolon</option>
  151.                     <option value=" ">Tab</option>
  152.                 </select><br />
  153.                 <input type="submit" name="convert" value="convert" style="width: 100%;">
  154.             </form>
  155.             <p>the following fields in the *.csv will be converted:</p>
  156.             <div style="overflow:auto;white-space:nowrap;width:100%;" class="codecolorer-container bash default">
  157.                 <pre>
  158. First Name
  159. Last Name
  160. Display Name
  161. Nicknam
  162. E-mail Address
  163. E-mail 2 Address
  164. E-mail 3 Address
  165. Home Phone
  166. Business Phone
  167. Home Fax
  168. Business Fax
  169. Pager
  170. Mobile Phone
  171. Home Street
  172. Home Address 2
  173. Home City
  174. Home State
  175. Home Postal Code
  176. Home Country
  177. Business Address
  178. Business Address 2
  179. Business City
  180. Business State
  181. Business Postal Code
  182. Business Country
  183. Country Code
  184. Related name
  185. Job Title
  186. Department
  187. Organization
  188. Notes
  189. Birthday
  190. Anniversary
  191. Gender
  192. Web Page
  193. Web Page 2
  194. Categories
  195.             </pre>
  196.             </div>
  197.         </div>
  198.     ';
  199. }
  200.  
  201. // <script type="text/javascript">
  202. //function set_form_fields(elem)
  203. //{
  204. //  var delimiter =   elem.options[elem.selectedIndex].value;  
  205. // elem.form._delimiter;
  206. //}
  207. //</script>
  208.  
  209. // MMM verifie que le fichier envoye a l'une des extensions de $allowedExts
  210. function checkExtension(array $allowedExts)
  211. {
  212.     $upload_filename = $_FILES["file"]["name"];
  213.     $upload_filename_array = explode(".", $upload_filename);
  214.     $extension = strtolower(end($upload_filename_array));
  215.  
  216.     $key = array_search($extension, $allowedExts);
  217.     return $key !== false;
  218. }
  219.  
  220.  
  221. function convert($filename_csv, $delimiter1)
  222. {
  223.     // $filename_csv = "export2016.06.24.csv";
  224.    
  225.     $lines_csv = file($filename_csv);
  226.    
  227.     $filename_extension = explode('.',$filename_csv);
  228.    
  229.     $filename_vcf = "./upload/".$_FILES["file"]["name"].".vcf";
  230.    
  231.     $file_vcf = fopen($filename_vcf, 'w') or die("can't open file");
  232.    
  233.     echo '<pre>generating vCard-Version: VERSION:2.1</pre>';
  234.    
  235.     // display name;phone0;phone1;phone2;phone3;phone4;phone5;phone6;phone7;phone8;phone9;phone10;phone11;phone12;phone13;phone14;phone15;phone16;phone17;phone18;phone19;
  236.     // 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;
  237.     // pobox0;street0;city0;region0;postcode0;country0;type0;pobox1;
  238.     // 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;
  239.    
  240.     // ==== fields to match ====
  241.     // display name
  242.     // street0 city0 region0 postcode0
  243.     // phone0 phone1 phone2 phone3
  244.     // email0
  245.     // organistion0
  246.  
  247.     // 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
  248.    
  249.     // get all possible fields in android-vcf
  250.     $length = count($lines_csv);
  251.     for($i = 0;$i < $length;$i++)
  252.     {
  253.         if($i == 0)
  254.         {
  255.             $keys_csv = $lines_csv[$i];
  256.             $keys_csv = explode($delimiter1,$keys_csv);
  257. //          $keys_csv = explode($_POST['_delimiter'],$keys_csv);
  258. //          $keys_csv = explode(";",$keys_csv);
  259.         }
  260.         else
  261.         {
  262.             fwrite($file_vcf, "BEGIN:VCARD\n"); // what Version does this file have
  263.             fwrite($file_vcf, "VERSION:2.1\n"); // what Version does this file have
  264.    
  265.             $values_csv = $lines_csv[$i];
  266.             $values_csv = explode($delimiter1,$values_csv);
  267. //          $values_csv = explode($_POST['_delimiter'],$values_csv);
  268. //          $values_csv = explode(";",$values_csv);
  269.    
  270.             $position1 = findPos("First Name", $keys_csv);
  271.             $position2 = findPos("Last Name", $keys_csv);
  272.             $position = $values_csv[$position1] . ";" . $values_csv[$position2]. ";;" ;
  273.             if ( ( $position ) !== ";;;")
  274.             {
  275.                 fwrite($file_vcf, "N:".$position."\n"); // N:Gump;Forrest;;Mr.
  276.             }          
  277.  
  278.             $position3 = findPos("Display Name", $keys_csv);
  279.             $position = $values_csv[$position3];
  280.             if ( !empty( $position ) )
  281.             {
  282.                 fwrite($file_vcf, "FN:".$position."\n"); // FN:Forrest Gump
  283.             }          
  284.            
  285.             $position3 = findPos("E-mail Address", $keys_csv);
  286.             $position = $values_csv[$position3];
  287.             if ( !empty( $position ) )
  288.             {
  289.                 fwrite($file_vcf, "EMAIL;TYPE=home:".$position."\n");
  290.             }
  291.  
  292.             $position3 = findPos("E-mail 2 Address", $keys_csv);
  293.             $position = $values_csv[$position3];
  294.             if ( !empty( $position ) )
  295.             {
  296.                 fwrite($file_vcf, "EMAIL;TYPE=work:".$position."\n");
  297.             }
  298.  
  299.             $position3 = findPos("E-mail 3 Address", $keys_csv);
  300.             $position = $values_csv[$position3];
  301.             if ( !empty( $position ) )
  302.             {
  303.                 fwrite($file_vcf, "EMAIL;TYPE=OTHER:".$position."\n");
  304.             }
  305.    
  306.             // ORG:Bubba Gump Shrimp Co.
  307.             // TITLE:Shrimp Man
  308.             // PHOTO;GIF:http://www.example.com/dir_photos/my_photo.gif
  309.            
  310.             // if phone1 differs from phone0
  311.             $position = findPos("Home Phone", $keys_csv);
  312.             $phone0 = $values_csv[$position];
  313.             if ( !empty( $phone0 ) )
  314.             {
  315.                 fwrite($file_vcf, "TEL;TYPE=home:".$phone0."\n"); // phone0
  316.             }          
  317.  
  318.             $position = findPos("Business Phone", $keys_csv);
  319.             $phone1 = $values_csv[$position];
  320.             if ( !empty( $phone1 ) )
  321.             {
  322.                 fwrite($file_vcf, "TEL;TYPE=work:".$phone1."\n"); // phone1
  323.             }
  324.  
  325.             $position = findPos("Home Fax", $keys_csv);
  326.             $phone2 = $values_csv[$position];
  327.             if ( !empty( $phone2 ) )
  328.             {
  329.                 fwrite($file_vcf, 'TEL;TYPE="fax,home":'.$phone2."\n"); // phone2
  330.             }
  331.             $position = findPos("Business Fax", $keys_csv);
  332.             $phone3 = $values_csv[$position];
  333.             if ( !empty( $phone3 ) )
  334.             {
  335.                 fwrite($file_vcf, 'TEL;TYPE="fax,work":'.$phone3."\n"); // phone2
  336.             }
  337.  
  338.             $position = findPos("Mobile Phone", $keys_csv);
  339.             $phone4 = $values_csv[$position];
  340.             if ( !empty( $phone4 ) )
  341.             {
  342.                 fwrite($file_vcf, "TEL;TYPE=cell:".$phone4."\n"); // phone3
  343.             }
  344.  
  345.             // ADR;HOME;PREF:;;100 Waters Edge;Baytown;LA;30314;United States of America
  346.             $street0 = $values_csv[findPos("Home Street", $keys_csv)];
  347.             $street1 = $values_csv[findPos("Home Address 2", $keys_csv)];
  348.             $city0 = $values_csv[findPos("Home City", $keys_csv)];
  349.             $region0 = $values_csv[findPos("Home State", $keys_csv)];
  350.             $postcode0 = $values_csv[findPos("Home Postal Code", $keys_csv)];
  351.             $country0 = $values_csv[findPos("Home Country", $keys_csv)];
  352.            
  353.             if ( ( !empty( $street0 ) ) || ( !empty( $street1 ) ) || ( !empty( $city0 ) ) || ( !empty( $region0 ) ) || ( !empty( $postcode0 ) ) || ( !empty( $country0 ) ) )
  354.             {          
  355.                 fwrite($file_vcf, "ADR;TYPE=home:".$street0.";".$street1.";".$city0.";".$region0.";".$postcode0.";".$country0."\n");
  356.             }
  357.    
  358.             // ADR;WORK;PREF:;;100 Waters Edge;Baytown;LA;30314;United States of America
  359.             $street0 = $values_csv[findPos("Business Address", $keys_csv)];
  360.             $street1 = $values_csv[findPos("Business Address 2", $keys_csv)];
  361.             $city0 = $values_csv[findPos("Business City", $keys_csv)];
  362.             $region0 = $values_csv[findPos("Business State", $keys_csv)];
  363.             $postcode0 = $values_csv[findPos("Business Postal Code", $keys_csv)];
  364.             $country0 = $values_csv[findPos("Business Country", $keys_csv)];
  365.  
  366.             if ( ( !empty( $street0 ) ) || ( !empty( $street1 ) ) || ( !empty( $city0 ) ) || ( !empty( $region0 ) ) || ( !empty( $postcode0 ) ) || ( !empty( $country0 ) ) )
  367.             {              
  368.                 fwrite($file_vcf, "ADR;TYPE=work:".$street0.";".$street1.";".$city0.";".$region0.";".$postcode0.";".$country0."\n");
  369.             }
  370.  
  371.             // LABEL;WORK;PREF;ENCODING=QUOTED-PRINTABLE;CHARSET=UTF-8:100 Waters Edge=0D==0 ABaytown\, LA 30314=0D=0AUnited States of America
  372.             // ADR;HOME:;;42 Plantation St.;Baytown;LA;30314;United States of America
  373.             // LABEL;HOME;ENCODING=QUOTED-PRINTABLE;CHARSET=UTF-8:42 Plantation St.=0D=0A=
  374.             // Baytown, LA 30314=0D=0AUnited States of America
  375.  
  376.             // Web page
  377.             $position = findPos("Web Page", $keys_csv);
  378.             if ( !empty( $values_csv[$position] ) )
  379.             {
  380.                 fwrite($file_vcf, "URL;VALUE=URI:".$values_csv[$position]."\n"); // email0 // EMAIL:
  381.             }
  382.  
  383.             // Web page
  384.             $position = findPos("Web Page 2", $keys_csv);
  385.             if ( !empty( $values_csv[$position] ) )
  386.             {
  387.                 fwrite($file_vcf, "URL;VALUE=URI:".$values_csv[$position]."\n"); // email1 // EMAIL:
  388.             }
  389.            
  390.             // NOTE
  391.             $position = findPos("Notes", $keys_csv);
  392.             if ( !empty( $values_csv[$position] ) )
  393.             {
  394.                 fwrite($file_vcf, "NOTE:".$values_csv[$position]."\n");
  395.             }
  396.  
  397.             // Birthday
  398.             $position = findPos("Birthday", $keys_csv);
  399.             if ( !empty( $values_csv[$position] ) )
  400.             {
  401.                 fwrite($file_vcf, "BDAY:".$values_csv[$position]."\n");
  402.             }
  403.  
  404.             // Categories
  405.             $position = findPos("Categories", $keys_csv);
  406.             if ( !empty( $values_csv[$position] ) )
  407.             {
  408.                 fwrite($file_vcf, "CATEGORIES :".$values_csv[$position]."\n"); // email0 // EMAIL:
  409.             }
  410.  
  411.             fwrite($file_vcf, "END:VCARD"."\n"); // END:VCARD
  412.         }
  413.     }
  414.    
  415.     fclose($file_vcf);
  416.  
  417.     // move_uploaded_file($_FILES["file"]["tmp_name"],"upload/".$_FILES["file"]["name"]);
  418.  
  419.     echo "<pre> ".$length." entries transformed</pre>";
  420.    
  421.     echo '<span style="color: green; font-weight: bold;">Please DOWNLOAD RESULT: <a href="'.$filename_vcf.'">'.$filename_vcf.'</a></span>'; // $_FILES["file"]["name"]
  422.  
  423.     echo '<h1><a href="index.php">Do it again</a></h1>';
  424.     // header("Content-type: text/plain");
  425.     // header('Content-Disposition: attachment; filename="'.$filename_vcf.'"');
  426.  
  427.     /*
  428.     echo '<h1>The result will selfdestruct in 60 seconds</h1>';
  429.     sleep(60);
  430.    
  431.     if(!unlink($filename_vcf))
  432.     {
  433.         echo ("Error deleting ".$filename_vcf);
  434.     }
  435.     else
  436.     {
  437.         echo ("Deleted ".$filename_vcf);
  438.     }
  439.     */
  440. }
  441.  
  442. /* determine position of a value in an number-indexed array */
  443. function findPos($value,$array)
  444. {
  445.     $result = null;
  446.     $length = count($array);
  447.     for($i=0;$i<$length;$i++)
  448.     {
  449.         if($array[$i] == $value)
  450.         {
  451.             $result = $i;
  452.             break;
  453.         }
  454.     }
  455.    
  456.     return $result;
  457. }
  458.  
  459. echo '
  460.         </div>
  461.         <div class="boxShadows" id="headline">';
  462.        
  463. // if ($_POST['_delimiter'] == ';')
  464. if ($delimiter == ';')
  465. {
  466.     echo '
  467.         <p>EXAMPLE INPUT with ";" : this goes in:</p>
  468.             <div style="overflow:auto;white-space:nowrap;width:100%;" class="codecolorer-container bash default">
  469.                 <pre>
  470. 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
  471. 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
  472. 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
  473. Aprenom3;Anom3;Aprenom3 Anom3;;;;;;;;;;+33 6 12 34 56 78;;;;;;;;;;;;;;;;;;;;;;;;test
  474. Aprenom5;Anom5;Aprenom5 Anom5;;;;;;+33 9 87 65 43 21;;;;;;;;;;;;;;;;;;;;;;;;;;;;test
  475. Aprenom4;Anom4;Aprenom4 Anom4;;;;;+33 1 23 45 67 89;+33 9 12 34 56 78;;;;+33 6 87 65 43 21;;;;;;;;;;;;;;;;;;;;;;;;test
  476. Aprenom7;Anom7;Aprenom7 Anom7;;;;;+33 1 23 45 67 89;;;;;;;;;;;;;;;;;;;;;;;;;;;;;test
  477. ;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
  478. ;;Aprenom6 Anom6;;;;;+33 1 23 45 67 89;;;;;;;;;;;;;;;;;;;;;;;;;;;;;test
  479.                 </pre>
  480.             </div>';
  481. }
  482. else  
  483. //  if ($_POST['_delimiter'] == '   ')
  484.     if ($delimiter == ' ')
  485.     {
  486.     echo '
  487.         <p>EXAMPLE INPUT with " " : this goes in:</p>
  488.             <div style="overflow:auto;white-space:nowrap;width:100%;" class="codecolorer-container bash default">      
  489. 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
  490. 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
  491. 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
  492. Aprenom3    Anom3   Aprenom3 Anom3                                      +33 6 12 34 56 78                                                                                               test
  493. Aprenom5    Anom5   Aprenom5 Anom5                      +33 9 87 65 43 21                                                                                                               test
  494. Aprenom4    Anom4   Aprenom4 Anom4                  +33 1 23 45 67 89   +33 9 12 34 56 78               +33 6 87 65 43 21                                                                                               test
  495. Aprenom7    Anom7   Aprenom7 Anom7                  +33 1 23 45 67 89                                                                                                                   test
  496.     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
  497.         Aprenom6 Anom6                  +33 1 23 45 67 89                                                                                                                   test
  498.                 </pre>
  499.             </div>';
  500.     }
  501.     else
  502.     {
  503.     echo '
  504.         <p>EXAMPLE INPUT with "," : this goes in:</p>
  505.             <div style="overflow:auto;white-space:nowrap;width:100%;" class="codecolorer-container bash default">
  506.                 <pre>
  507. 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
  508. 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
  509. 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
  510. Aprenom3,Anom3,Aprenom3 Anom3,,,,,,,,,,+33 6 12 34 56 78,,,,,,,,,,,,,,,,,,,,,,,,test
  511. Aprenom5,Anom5,Aprenom5 Anom5,,,,,,+33 9 87 65 43 21,,,,,,,,,,,,,,,,,,,,,,,,,,,,test
  512. Aprenom4,Anom4,Aprenom4 Anom4,,,,,+33 1 23 45 67 89,+33 9 12 34 56 78,,,,+33 6 87 65 43 21,,,,,,,,,,,,,,,,,,,,,,,,test
  513. Aprenom7,Anom7,Aprenom7 Anom7,,,,,+33 1 23 45 67 89,,,,,,,,,,,,,,,,,,,,,,,,,,,,,test
  514. ,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
  515. ,,Aprenom6 Anom6,,,,,+33 1 23 45 67 89,,,,,,,,,,,,,,,,,,,,,,,,,,,,,test
  516.                 </pre>
  517.             </div>';
  518.     }
  519.  
  520. echo '
  521.         </div>
  522.         <div class="boxShadows" id="headline">
  523.         <p>this comes out: (this is what android contact book understands)</p>
  524.             <div style="overflow:auto;white-space:nowrap;width:100%;" class="codecolorer-container bash default">
  525.                 <pre>
  526. BEGIN:VCARD
  527. VERSION:2.1
  528. N:Aprenom1 Anom1;;;
  529. FN:Aprenom1 Anom1
  530. EMAIL;TYPE=home:[email protected]
  531. EMAIL;TYPE=work:[email protected]
  532. TEL;TYPE=home:+33 1 23 45 67 89
  533. TEL;TYPE=work:+33 2 87 65 43 21
  534. TEL;TYPE="fax,home":+33 9 12 34 56 78
  535. TEL;TYPE="fax,work":+33 9 87 65 43 21
  536. TEL;TYPE=cell:+33 6 12 34 56 78
  537. ADR;TYPE=home:rue1;rue2;meylan;rhone alpes;38240;france
  538. ADR;TYPE=work:rue1T;rue2T;Grenoble;isere;38000;france
  539. NOTE:notes
  540. BDAY:1604-12-08 00:00:00
  541. END:VCARD
  542. BEGIN:VCARD
  543. VERSION:2.1
  544. N:Aprenom2;Anom2;;
  545. FN:Aprenom2 Anom2
  546. EMAIL;TYPE=home:[email protected]
  547. EMAIL;TYPE=work:[email protected]
  548. TEL;TYPE=home:+33 1 23 45 67 89
  549. TEL;TYPE=work:+33 9 12 34 76 78
  550. TEL;TYPE=cell:+33 6 56 78 12 34
  551. ADR;TYPE=home:rue D;rue D étendue;ville D;paca D;12345;france
  552. ADR;TYPE=work:rue T;rue T étendue;ville T;paca T;23456;france
  553. URL;VALUE=URI:www.xxx.com
  554. NOTE:note lig 1 note lig 2 note lig 3
  555. BDAY:2020-01-05 00:00:00
  556. END:VCARD
  557. BEGIN:VCARD
  558. VERSION:2.1
  559. N:Aprenom3;Anom3;;
  560. FN:Aprenom3 Anom3
  561. TEL;TYPE=cell:+33 6 12 34 56 78
  562. END:VCARD
  563. BEGIN:VCARD
  564. VERSION:2.1
  565. N:Aprenom5;Anom5;;
  566. FN:Aprenom5 Anom5
  567. TEL;TYPE=work:+33 9 87 65 43 21
  568. END:VCARD
  569. BEGIN:VCARD
  570. VERSION:2.1
  571. N:Aprenom4;Anom4;;
  572. FN:Aprenom4 Anom4
  573. TEL;TYPE=home:+33 1 23 45 67 89
  574. TEL;TYPE=work:+33 9 12 34 56 78
  575. TEL;TYPE=cell:+33 6 87 65 43 21
  576. END:VCARD
  577. BEGIN:VCARD
  578. VERSION:2.1
  579. N:Aprenom7;Anom7;;
  580. FN:Aprenom7 Anom7
  581. TEL;TYPE=home:+33 1 23 45 67 89
  582. END:VCARD
  583. BEGIN:VCARD
  584. VERSION:2.1
  585. N:;Aprenom Anom;;
  586. FN:Aprenom Anom
  587. EMAIL;TYPE=home:[email protected]
  588. EMAIL;TYPE=work:[email protected]
  589. EMAIL;TYPE=OTHER:[email protected]
  590. TEL;TYPE=home:+33 9 12 34 56 78
  591. TEL;TYPE=work:+33 9 87 65 43 21
  592. TEL;TYPE="fax,home":+33 8 12 34 56 78
  593. TEL;TYPE="fax,work":+33 8 87 65 43 21
  594. TEL;TYPE=cell:+33 6 12 56 34 78
  595. ADR;TYPE=home:rueD;;VILLED;;01234;
  596. ADR;TYPE=work:rueT;;VilleT;;34567;
  597. NOTE:notes en tout genre AAAAAA aaaaaa
  598. BDAY:2019-12-18 00:00:00
  599. END:VCARD
  600. BEGIN:VCARD
  601. VERSION:2.1
  602. FN:Aprenom6 Anom6
  603. TEL;TYPE=home:+33 1 23 45 67 89
  604. END:VCARD
  605.                 </pre>
  606.             </div>
  607.         </div>
  608.     </body>
  609. </html>
  610. ';
  611. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement