PageRenderTime 55ms CodeModel.GetById 21ms RepoModel.GetById 0ms app.codeStats 0ms

/site/importer/myaol.php

https://bitbucket.org/kaerast/ppl
PHP | 449 lines | 243 code | 152 blank | 54 comment | 1 complexity | d767b64fee2e1c5a268c77d49e5e4a04 MD5 | raw file
Possible License(s): GPL-2.0, AGPL-1.0
  1. <?
  2. /////////////////////////////////////////////////////////////////////////////////////////
  3. // //
  4. // //
  5. // //
  6. // AOL CONTACT IMPORTING SCRIPT //
  7. // COPYRIGHT RESERVED //
  8. // //
  9. // You may not distribute this software without prior permission //
  10. // //
  11. // //
  12. // //
  13. // //
  14. /////////////////////////////////////////////////////////////////////////////////////////
  15. //******************************** START OF SCRIPT - SETTING VARIABLE ****************************\\
  16. include_once ('includes/config.php');
  17. include_once ('includes/tbs_class.php');
  18. $display_array = array();
  19. list($username,$domain) = split('@',$username);
  20. $refering_site ='http://classic.webmail.aol.com'; //setting the site for refer
  21. $browser_agent = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)"; //setting browser type
  22. $mycookie = $username.'.cookie';
  23. $fh = fopen($mycookie,'w');
  24. fclose($fh);
  25. $path_to_cookie = realpath("$mycookie");
  26. $setcookie = fopen($path_to_cookie,'wb');//this opens the file and resets it to zero length
  27. fclose($setcookie);
  28. //******************************** OPENING LOGIN PAGE ***************************\\
  29. $login_page = 'https://my.screenname.aol.com/_cqr/login/login.psp?mcState=initialized&seamless=novl&siteId=vatlasaol-static&siteState=OrigUrl%3dhttp%253a%252f%252fclassic.webmail.aol.com%252f_cqr%252fvllogin.adp&authLev=2';
  30. $ch = curl_init();
  31. curl_setopt($ch, CURLOPT_URL, $login_page);
  32. curl_setopt($ch, CURLOPT_USERAGENT, $browser_agent);
  33. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  34. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
  35. curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
  36. curl_setopt($ch, CURLOPT_COOKIEFILE, $path_to_cookie);
  37. curl_setopt($ch, CURLOPT_COOKIEJAR, $path_to_cookie);
  38. $page_result = curl_exec ($ch);
  39. curl_close ($ch);
  40. // DEBUG -- this will show you the whole page as you would in a broswer
  41. $cookie_data1 = ".aol.com FALSE / FALSE 0 s_sq %5B%5BB%5D%5D \n";
  42. $fp2 = fopen($path_to_cookie, "a"); // "a" is to append
  43. fwrite($fp2, $cookie_data1);
  44. fclose($fp2);
  45. $cookie_data2 = ".aol.com FALSE / FALSE 0 s_cc true";
  46. $fp3 = fopen($path_to_cookie, "a"); // "a" is to append
  47. fwrite($fp3, $cookie_data2);
  48. fclose($fp3);
  49. //echo "<textarea rows=30 cols=120>".$page_result."</textarea>"; //DEBUG -- this will pages html in nice box
  50. // (1) get usrd fieled
  51. preg_match_all("/name=\"usrd\" value=\"(.*?)\"/", $page_result, $usrd);
  52. //print_r($usrd); // DEBUG -- this will print the whole array to allow you to select the one you want e.g [1][0]
  53. $usrd_found = $usrd[1][0]; // stores the hidden text in a ariable to use later in POST
  54. //echo $usrd_found; // DEBUG -- To show if you have selcted the correct array
  55. // ******************* submitting login info as aquired above ***************************
  56. $postal_data ='sitedomain=vatlasaol-static&siteId=vatlasaol-static&lang=en&locale=us&authLev=2&siteState=OrigUrl%253Dhttp%25253a%25252f%25252fclassic.webmail.aol.com%25252f_cqr%25252fvllogin.adp&isSiteStateEncoded=true&mcState=initialized&usrd='.$usrd_found.'&loginId='.$username.'&password='.$password.'&rememberMe=off&x=33&y=10';
  57. $login_page2 = 'https://my.screenname.aol.com/_cqr/login/login.psp';
  58. $referer2 = 'https://my.screenname.aol.com/_cqr/login/login.psp?mcState=initialized&seamless=novl&siteId=vatlasaol-static&siteState=OrigUrl%3dhttp%253a%252f%252fclassic.webmail.aol.com%252f_cqr%252fvllogin.adp&authLev=2';
  59. //echo $postal_data; //DEBUG -- checking $postada1 above
  60. $ch = curl_init();
  61. curl_setopt($ch, CURLOPT_URL,$login_page2);
  62. curl_setopt($ch, CURLOPT_USERAGENT, $browser_agent);
  63. curl_setopt($ch, CURLOPT_POST, 1);
  64. curl_setopt($ch, CURLOPT_POSTFIELDS,$postal_data);
  65. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  66. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
  67. curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
  68. curl_setopt($ch, CURLOPT_REFERER, $referer2);
  69. curl_setopt($ch, CURLOPT_COOKIEFILE, $path_to_cookie);
  70. curl_setopt($ch, CURLOPT_COOKIEJAR, $path_to_cookie);
  71. curl_setopt($ch,CURLOPT_FOLLOWLOCATION, 0);
  72. $result3 = curl_exec ($ch);
  73. curl_close ($ch);
  74. //echo $result3;
  75. //echo "<textarea rows=30 cols=120>".$result3."</textarea>"; //DEBUG -- this will pages html in nice box
  76. //preg_match_all("/'loginForm', 'false', '(.*?)'/", $result3, $redirected);
  77. //$myaol = $redirected[1][0];
  78. // ********** START OF COOKIE CHECKS *********************************
  79. $cookiechecker1 = 'http://my.screenname.aol.com/_cqr/login/login.psp?mcState=copyCookies&siteId=vatlasaol-static&authLev=2&siteState=OrigUrl%3Dhttp%253a%252f%252fclassic.webmail.aol.com%252f_cqr%252fvllogin.adp&lang=en&locale=us';
  80. $ch = curl_init();
  81. curl_setopt($ch, CURLOPT_URL,$cookiechecker1);
  82. curl_setopt($ch, CURLOPT_USERAGENT, $browser_agent);
  83. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  84. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
  85. curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
  86. curl_setopt($ch, CURLOPT_REFERER, $login_page2);
  87. curl_setopt($ch, CURLOPT_COOKIEFILE, $path_to_cookie);
  88. curl_setopt($ch, CURLOPT_COOKIEJAR, $path_to_cookie);
  89. $result5 = curl_exec ($ch);
  90. curl_close ($ch);
  91. //echo $result5;
  92. preg_match_all("/MC_CMP_SX=(.*?)\" TYPE/", $result5, $cookieurl1);
  93. preg_match_all("/MC_CMP_S=(.*?)\" TYPE/", $result5, $cookieurl2);
  94. $redirect_CMP_SX = $cookieurl1[1][0];
  95. $redirect_CMP_S = $cookieurl2[1][0];
  96. //echo "<textarea rows=30 cols=120>".$result5."</textarea>"; //DEBUG -- this will pages html in nice box
  97. //echo $redirect_CMP_SX;
  98. //echo "<p></p>";
  99. //echo $redirect_CMP_S;
  100. //************* COOKIE STEP 2 ********************
  101. $cookiechecker2 = 'http://sns.cqr.classic.webmail.aol.com/_cqr/xdomain/final.psp?siteId=vatlasaol-static&MC_CMP_SX='.$redirect_CMP_SX;
  102. $referer3 = 'http://my.screenname.aol.com/_cqr/login/login.psp?mcState=copyCookies&siteId=vatlasaol-static&authLev=2&siteState=OrigUrl%3Dhttp%253a%252f%252fclassic.webmail.aol.com%252f_cqr%252fvllogin.adp&lang=en&locale=us';
  103. $ch = curl_init();
  104. curl_setopt($ch, CURLOPT_URL,$cookiechecker2);
  105. curl_setopt($ch, CURLOPT_USERAGENT, $browser_agent);
  106. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  107. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
  108. curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
  109. curl_setopt($ch, CURLOPT_REFERER, $referer3);
  110. curl_setopt($ch, CURLOPT_COOKIEFILE, $path_to_cookie);
  111. curl_setopt($ch, CURLOPT_COOKIEJAR, $path_to_cookie);
  112. $result6 = curl_exec ($ch);
  113. curl_close ($ch);
  114. //echo $result5;
  115. //preg_match_all("/MC_CMP_SX=(.*?)\" TYPE/", $result5, $cookieurl1);
  116. //$redirect_CMP_S = $cookieurl2[1][0];
  117. //echo "<textarea rows=30 cols=120>".$result6."</textarea>"; //DEBUG -- this will pages html in nice box
  118. //************* COOKIE STEP 3 ******************************************************************************
  119. $cookiechecker3 = 'http://sns.cqr.classic.webmail.aol.com/_cqr/xdomain/final.psp?siteId=vatlasaol-static&MC_CMP_S='.$redirect_CMP_S;
  120. $referer4 = 'http://my.screenname.aol.com/_cqr/login/login.psp?mcState=copyCookies&siteId=vatlasaol-static&authLev=2&siteState=OrigUrl%3Dhttp%253a%252f%252fclassic.webmail.aol.com%252f_cqr%252fvllogin.adp&lang=en&locale=us';
  121. $ch = curl_init();
  122. curl_setopt($ch, CURLOPT_URL,$cookiechecker3);
  123. curl_setopt($ch, CURLOPT_USERAGENT, $browser_agent);
  124. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  125. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
  126. curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
  127. curl_setopt($ch, CURLOPT_REFERER, $referer4);
  128. curl_setopt($ch, CURLOPT_COOKIEFILE, $path_to_cookie);
  129. curl_setopt($ch, CURLOPT_COOKIEJAR, $path_to_cookie);
  130. $result7 = curl_exec ($ch);
  131. curl_close ($ch);
  132. //echo $result7;
  133. //echo "<textarea rows=30 cols=120>".$result7."</textarea>"; //DEBUG -- this will pages html in nice box
  134. // ******************* LOGGING INTO AOL CLASSIC ***************************
  135. $login_page3 = 'http://classic.webmail.aol.com/_cqr/login';
  136. $postal_data2 ='siteId=vatlasaol-static&sitedomain=vatlasaol-static&authLev=2&lang=en&locale=us&siteState=OrigUrl%3Dhttp%253a%252f%252fclassic.webmail.aol.com%252f_cqr%252fvllogin.adp';
  137. $referer2 = 'http://my.screenname.aol.com/_cqr/login/login.psp?mcState=copyCookies&siteId=vatlasaol-static&authLev=2&siteState=OrigUrl%3Dhttp%253a%252f%252fclassic.webmail.aol.com%252f_cqr%252fvllogin.adp&lang=en&locale=us';
  138. $ch = curl_init();
  139. curl_setopt($ch, CURLOPT_URL,$login_page3);
  140. curl_setopt($ch, CURLOPT_USERAGENT, $browser_agent);
  141. curl_setopt($ch, CURLOPT_POST, 1);
  142. curl_setopt($ch, CURLOPT_POSTFIELDS,$postal_data2);
  143. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  144. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
  145. curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
  146. curl_setopt($ch, CURLOPT_REFERER, $referer2);
  147. curl_setopt($ch, CURLOPT_COOKIEFILE, $path_to_cookie);
  148. curl_setopt($ch, CURLOPT_COOKIEJAR, $path_to_cookie);
  149. $result8 = curl_exec ($ch);
  150. curl_close ($ch);
  151. //echo $result8;
  152. //echo "<textarea rows=30 cols=120>".$result8."</textarea>"; //DEBUG -- this will pages html in nice box
  153. //***************************** OPENING INBOX PART 1***********************************
  154. $inboxurl = 'http://classic.webmail.aol.com/_cqr/vllogin.adp';
  155. $referer3 = 'http://my.screenname.aol.com/_cqr/login/login.psp?mcState=copyCookies&siteId=vatlasaol-static&authLev=2&siteState=OrigUrl%3Dhttp%253a%252f%252fclassic.webmail.aol.com%252f_cqr%252fvllogin.adp&lang=en&locale=us';
  156. $ch = curl_init();
  157. curl_setopt($ch, CURLOPT_URL,$inboxurl);
  158. curl_setopt($ch, CURLOPT_USERAGENT, $browser_agent);
  159. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  160. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
  161. curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
  162. curl_setopt($ch, CURLOPT_REFERER, $referer3);
  163. curl_setopt($ch, CURLOPT_COOKIEFILE, $path_to_cookie);
  164. curl_setopt($ch, CURLOPT_COOKIEJAR, $path_to_cookie);
  165. $result9 = curl_exec ($ch);
  166. curl_close ($ch);
  167. //echo $result9;
  168. //echo "<textarea rows=30 cols=120>".$result9."</textarea>"; //DEBUG -- this will pages html in nice box
  169. //***************************** OPENING INBOX PART 2 ***********************************
  170. $inboxurl2 = 'http://classic.webmail.aol.com/msglist.adp';
  171. $referer4 = 'http://my.screenname.aol.com/_cqr/login/login.psp?mcState=copyCookies&siteId=vatlasaol-static&authLev=2&siteState=OrigUrl%3Dhttp%253a%252f%252fclassic.webmail.aol.com%252f_cqr%252fvllogin.adp&lang=en&locale=us';
  172. $ch = curl_init();
  173. curl_setopt($ch, CURLOPT_URL,$inboxurl2);
  174. curl_setopt($ch, CURLOPT_USERAGENT, $browser_agent);
  175. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  176. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
  177. curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
  178. curl_setopt($ch, CURLOPT_REFERER, $referer4);
  179. curl_setopt($ch, CURLOPT_COOKIEFILE, $path_to_cookie);
  180. curl_setopt($ch, CURLOPT_COOKIEJAR, $path_to_cookie);
  181. $result10 = curl_exec ($ch);
  182. curl_close ($ch);
  183. //echo $result10;
  184. //echo "<textarea rows=30 cols=120>".$result10."</textarea>"; //DEBUG -- this will pages html in nice box
  185. //***************************** OPENING ADDRESS BOOK 1 ***********************************
  186. $addressbook1 = 'http://classic.webmail.aol.com/rab.adp?launch=main';
  187. $ch = curl_init();
  188. curl_setopt($ch, CURLOPT_URL,$addressbook1);
  189. curl_setopt($ch, CURLOPT_USERAGENT, $browser_agent);
  190. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  191. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
  192. curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
  193. curl_setopt($ch, CURLOPT_REFERER, $inboxurl2);
  194. curl_setopt($ch, CURLOPT_COOKIEFILE, $path_to_cookie);
  195. curl_setopt($ch, CURLOPT_COOKIEJAR, $path_to_cookie);
  196. $result11 = curl_exec ($ch);
  197. curl_close ($ch);
  198. //echo "<textarea rows=30 cols=120>".$result11."</textarea>"; //DEBUG -- this will pages html in nice box
  199. preg_match_all("/main.adp\?(.*?)\"/", $result11, $addresses);
  200. $addressredirect = $addresses[1][0];
  201. //echo $addressredirect;
  202. // ******************* FINAL POST TO GET INTO ADDRESS BOOK ***************************
  203. $postal_final = $addressredirect;
  204. $posted = "";
  205. $login_final = 'http://ab.classic.webmail.aol.com/main.adp?'.$postal_final;
  206. $ch = curl_init();
  207. curl_setopt($ch, CURLOPT_URL,$login_final);
  208. curl_setopt($ch, CURLOPT_USERAGENT, $browser_agent);
  209. curl_setopt($ch, CURLOPT_POST, 1);
  210. curl_setopt($ch, CURLOPT_POSTFIELDS,$posted);
  211. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  212. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
  213. curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
  214. curl_setopt($ch, CURLOPT_REFERER, $addressbook1);
  215. curl_setopt($ch, CURLOPT_COOKIEFILE, $path_to_cookie);
  216. curl_setopt($ch, CURLOPT_COOKIEJAR, $path_to_cookie);
  217. $result22 = curl_exec ($ch);
  218. curl_close ($ch);
  219. //echo $result22;
  220. //echo "<textarea rows=30 cols=120>".$result22."</textarea>"; //DEBUG -- this will pages html in nice box
  221. //echo $login_final;
  222. //***************************** OPENING ADDRESS PRINT ALL ***********************************
  223. $addressbook2 = 'http://ab.classic.webmail.aol.com/print_all_information.adp?langid=0&ContactKey=100,99,98,97,96,95,94,93,92,91,90,89,88,87,86,85,84,83,82,81,80,79,78,77,76,75,74,73,72,71,70,69,68,67,66,65,64,63,62,61,60,59,58,57,56,55,54,53,52,51,50,49,48,47,46,45,44,43,42,41,40,39,38,37,36,35,34,33,32,31,30,29,28,27,26,25,24,23,22,21,20,19,18,17,16,15,14,13,12,11,10,9,8,7,6,5,4,3,2,1,&mheader=0';
  224. //put as many numbers in link abov to pull as many contacts as possible
  225. $ch = curl_init();
  226. curl_setopt($ch, CURLOPT_URL,$addressbook2);
  227. curl_setopt($ch, CURLOPT_USERAGENT, $browser_agent);
  228. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  229. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
  230. curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
  231. curl_setopt($ch, CURLOPT_REFERER, $login_final);
  232. curl_setopt($ch, CURLOPT_COOKIEFILE, $path_to_cookie);
  233. curl_setopt($ch, CURLOPT_COOKIEJAR, $path_to_cookie);
  234. $result23 = curl_exec ($ch);
  235. curl_close ($ch);
  236. //echo $result23;
  237. // ******************** this array pulls out the names and email using regular eaxpressions ******************************
  238. //FULL NAME AND EMAIL IN ONE ARRAY SEARCH
  239. preg_match_all("/size=2 color=\"#000000\"><b>(.*?)<\/b>.*E-mail: (.*?)<br>/", $result23, $array_fulldetails);
  240. //print_r($array_fulldetails); //DEBUG -- this will print the whole array
  241. $details = $array_fulldetails;
  242. // [checking if array empty]
  243. IF (empty($details)){
  244. $show = 1;
  245. $error_message = "No contacts found - check your login details and try again";
  246. }ELSE{
  247. $i = 0;
  248. while (isset($details[1][$i])):
  249. // [RESULTS - START OF CONTACTS LIST]
  250. $email = $matches[2][$i];
  251. $dataname = $matches[1][$i];
  252. $result = array('contacts_email' => $email,'contacts_name' => $dataname);
  253. $display_array[] = $result;
  254. $i++;
  255. endwhile;
  256. $poweredby_bottom = $footer;//powered by
  257. $show_result = 1;//show results table
  258. @unlink($mycookie);
  259. }
  260. $table = 1;//show table in main template (email or cvs upload)
  261. $service = 'myaol';
  262. @unlink($username);//deleting csv file
  263. @unlink($mycookie);
  264. include_once ('index.php');
  265. ?>