PageRenderTime 41ms CodeModel.GetById 20ms app.highlight 3ms RepoModel.GetById 17ms app.codeStats 0ms

/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
 4$curl_start = new Curl;
 5
 6
 7/* try to connect */
 8$inbox = imap_open($IMAPhostname,$IMAPusername,$IMAPpassword) or die('Cannot connect to Imap: ' . imap_last_error());
 9
10/* grab emails */
11$emails = imap_search($inbox,'ALL');
12
13/* if emails are returned, cycle through each... */
14if($emails) {
15	
16	/* begin output var */
17	$output = '';
18	
19	/* put the newest emails on top */
20	rsort($emails);
21	
22	/* for every email... */
23	foreach($emails as $email_number) {
24		
25		/* get information specific to this email */
26		$overview = imap_fetch_overview($inbox,$email_number,0);
27		$message = imap_fetchbody($inbox,$email_number,1);
28		if (preg_match("/Qml0dGUgYmVzdMOkdGlnZSBkZWluZSBCZWVwd29ybGQ/i", $overview[0]->subject)) {
29		    //echo $overview[0]->subject;
30		    $Message[] = $message;
31		}
32		
33		$i++;
34		If ($i > 3) continue;
35	}
36} 
37/* close the connection */
38
39
40
41//TODO test
42//$email_received = file_get_contents("email.txt", "r");
43echo $email_received = str_get_html($Message[0]);
44//echo $email_received;
45//RegExp email and to the $ok goes a confirmation link
46preg_match_all("!http:\/\/www.beepworld.de\/verify\/?'?([^ \"'>]+)\"?'?.*?!is",$email_received,$ok); 
47
48
49//Goes to the link from email and click confirm
50$url_to_confirm = $ok[0][0];
51$curl_confirm = new Curl;
52
53$response = $curl_confirm->get($url_to_confirm);
54$response->body;
55$confirm_page = $response->body;
56$confirm_page = str_get_html($confirm_page);
57$to_reg['name'] = @$confirm_page->find("#box_login_name", 0) -> value;
58$to_reg['email'] = $to_reg['name'].$to_reg['domain_email'];
59$to_reg['url'] = "http://".$to_reg['name'].".beepworld.de/";
60if ($to_reg['name'] != '')
61	$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']."');");
62
63