Advertisement
Guest User

ecureuil-php-csv-vcf-1

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