PageRenderTime 46ms CodeModel.GetById 24ms RepoModel.GetById 0ms app.codeStats 0ms

/site/importer/mygmail.php

https://bitbucket.org/kaerast/ppl
PHP | 116 lines | 96 code | 5 blank | 15 comment | 0 complexity | b3e2340a4ed742322cac3a43b7cccfb0 MD5 | raw file
Possible License(s): GPL-2.0, AGPL-1.0
  1. <?
  2. /////////////////////////////////////////////////////////////////////////////////////////
  3. // //
  4. // //
  5. // //
  6. // GMAIL CONTACT IMPORTING SCRIPT //
  7. // COPYRIGHT RESERVED //
  8. // //
  9. // You may not distribute this software without prior permission //
  10. // //
  11. // //
  12. // WWW.GETMYCONTACTS.COM //
  13. // //
  14. /////////////////////////////////////////////////////////////////////////////////////////
  15. $service = 'gmail';
  16. include_once ('includes/config.php');
  17. include_once ('includes/tbs_class.php');
  18. include ('includes/service.php');
  19. //--------------------------------------------end of service------------------------------------------------\\
  20. //WRITING OUTPUT TO CSV FILE
  21. $myFile = $username;
  22. $fh = fopen($myFile,'w') or die("can't open file");
  23. fwrite($fh,$result);
  24. fclose($fh);
  25. // CHECKING IF LOGIN WAS SUCCESSFUL - by search of the @ sign in the csv
  26. preg_match_all("/@/",$result,$array_at);
  27. //print_r($array_at); //DEBUG - Show array
  28. $at_sign = $array_at[0];
  29. if (empty($at_sign)) {
  30. $show = 1;
  31. $error_message = "No contacts found - check your login details and try again";
  32. }
  33. else {
  34. //*********************** | START OF HTML | ***********************************\\
  35. //OPEING CSV FILE FOR PROCESSING
  36. $fp = fopen($username,"r");
  37. while (!feof($fp)) {
  38. $data = fgetcsv($fp,4100,",");//this uses the fgetcsv function to store the quote info in the array $data
  39. //print_r($data);
  40. $dataname = $data[0];
  41. $dataname = preg_replace("/[^a-z0-9A-Z_-\s@\.]/","",$dataname);
  42. if (empty($dataname)) {
  43. $dataname = "None";
  44. }
  45. $email = $data[1];
  46. if (empty($email)) {//Skip table if email is blank
  47. }
  48. else {
  49. $email = $data[1];
  50. if ($dataname == "None") {
  51. $dataname = $email;
  52. }
  53. if ($dataname != "Name") {// skiping table to remove first line of csv file
  54. //remove none characters
  55. $email1 = preg_replace("/[^a-z0-9A-Z_-\s@\.]/","",$email);
  56. $dataname1 = preg_replace("/[^a-z0-9A-Z_-\s@\.]/","",$dataname);
  57. $result = array('contacts_email' => $email1,'contacts_name' => $dataname1);
  58. $display_array[] = $result;
  59. }
  60. }
  61. }
  62. $poweredby_bottom = $footer;//powered by
  63. $show_result = 1;//show results table
  64. unlink($username);//deleting csv file
  65. @unlink($mycookie);
  66. }
  67. $table = 1;//show table in main template (email or cvs upload)
  68. $service = 'mygmail';
  69. @unlink($username);//deleting csv file
  70. @unlink($mycookie);
  71. include_once ('index.php');
  72. ?>