PageRenderTime 48ms CodeModel.GetById 22ms RepoModel.GetById 0ms app.codeStats 1ms

/imapMailChecker/3_webnode_de.php

https://github.com/dimon36/projekt_1
PHP | 63 lines | 37 code | 13 blank | 13 comment | 2 complexity | 12be8c54804b1d9ecdbdb03fb933ee15 MD5 | raw file
  1. <?
  2. $db = new edb($db_data);
  3. $curl_start = new Curl;
  4. /* try to connect */
  5. $inbox = imap_open($IMAPhostname,$IMAPusername,$IMAPpassword) or die('Cannot connect to Imap: ' . imap_last_error());
  6. /* grab emails */
  7. $emails = imap_search($inbox,'ALL');
  8. /* if emails are returned, cycle through each... */
  9. if($emails) {
  10. /* begin output var */
  11. $output = '';
  12. /* put the newest emails on top */
  13. rsort($emails);
  14. /* for every email... */
  15. foreach($emails as $email_number) {
  16. /* get information specific to this email */
  17. $overview = imap_fetch_overview($inbox,$email_number,0);
  18. $message = imap_fetchbody($inbox,$email_number,1);
  19. if (preg_match("/Qml0dGUgYmVzdMOkdGlnZSBkZWluZSBCZWVwd29ybGQ/i", $overview[0]->subject)) {
  20. //echo $overview[0]->subject;
  21. $Message[] = $message;
  22. }
  23. $i++;
  24. If ($i > 3) continue;
  25. }
  26. }
  27. /* close the connection */
  28. //TODO test
  29. //$email_received = file_get_contents("email.txt", "r");
  30. echo $email_received = str_get_html($Message[0]);
  31. //echo $email_received;
  32. //RegExp email and to the $ok goes a confirmation link
  33. preg_match_all("!http:\/\/www.beepworld.de\/verify\/?'?([^ \"'>]+)\"?'?.*?!is",$email_received,$ok);
  34. //Goes to the link from email and click confirm
  35. $url_to_confirm = $ok[0][0];
  36. $curl_confirm = new Curl;
  37. $response = $curl_confirm->get($url_to_confirm);
  38. $response->body;
  39. $confirm_page = $response->body;
  40. $confirm_page = str_get_html($confirm_page);
  41. $to_reg['name'] = @$confirm_page->find("#box_login_name", 0) -> value;
  42. $to_reg['email'] = $to_reg['name'].$to_reg['domain_email'];
  43. $to_reg['url'] = "http://".$to_reg['name'].".beepworld.de/";
  44. if ($to_reg['name'] != '')
  45. $db->s("INSERT INTO `saved_accounts_beepworld_de` (`id`, `email`, `name`, `pass`, `url`) VALUES (NULL, '".$to_reg['email']."', '".$to_reg['name']."', '".$to_reg['pass']."', '".$to_reg['url']."');");