Guest User

Untitled

a guest
Apr 8th, 2018
547
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.91 KB | None | 0 0
  1. <meta http-equiv="Content-Type" content="text/html; charset=windows-1251" />
  2.  
  3. <?php
  4.  
  5. $user = "ZABOEBATEJLb@mail.ru";
  6. $pass = "killer";
  7. $server = "pop.mail.ru";
  8.  
  9. function from_detector ($text) {
  10. $pattern_from = "/(?<=From:\s).*/";
  11. preg_match($pattern_from, $text, $from);
  12. return $from[0];
  13. }
  14.  
  15. function subject_detector($text) {
  16. $pattern_subject = "/(?<=Subject:\s).*/";
  17. preg_match($pattern_subject, $text, $subject);
  18. return $subject[0];
  19. }
  20.  
  21. function decode_mime($text) {
  22.     $string = $text;
  23.     preg_match_all("#\=\?(.*)\?B\?#",$string,$val);
  24.     $encoding = strtoupper($val[1][0]);
  25.     if(($pos = strpos($string,"=?")) === false) return $string;
  26.     while(!($pos === false)) {
  27.         $newresult .= substr($string,0,$pos);
  28.         $string = substr($string,$pos+2,strlen($string));
  29.         $intpos = strpos($string,"?");
  30.         $charset = substr($string,0,$intpos);
  31.         $enctype = strtolower(substr($string,$intpos+1,1));
  32.         $string = substr($string,$intpos+3,strlen($string));
  33.         $endpos = strpos($string,"?=");
  34.         $mystring = substr($string,0,$endpos);
  35.         $string = substr($string,$endpos+2,strlen($string));
  36.        
  37.             if($enctype == "q") {
  38.                 $mystring = quoted_printable_decode(ereg_replace("_"," ",$mystring));
  39.                 }
  40.                
  41.             else if ($enctype == "b") {
  42.             $mystring = base64_decode($mystring);
  43.             }
  44.            
  45.         $newresult .= $mystring;
  46.         $pos = strpos($string,"=?");
  47.     }
  48.     $result = $newresult.$string;
  49.     if(preg_replace("/koi8/i", $result)) $result = convert_cyr_string($result, "k", "w");
  50.     else if(!preg_replace("/windows-1251/i", $result)) $result = iconv($encoding,"WINDOWS-1251",$result);
  51.     return $result;
  52. }
  53.  
  54. function read_socket($socket){
  55. $data="";
  56. while (!feof($socket)) {
  57.     $buffer = fgets($socket, 512);
  58.     if ($buffer == false) {
  59.     break;
  60.     }
  61.     $data .= "$buffer\r\n";
  62. }
  63. return $data;
  64. }
  65.  
  66. $socket = fsockopen("pop.mail.ru", 110, $errno, $errstr, 30);
  67. stream_set_timeout($socket, 2);
  68. if (!$socket) {
  69.     die($errstr. "($errno)<br />\n");
  70. }
  71.  
  72. $res = fgets($socket, 512);
  73. if (substr(trim($res), 0, 3) != "+OK") {
  74.     die($res);
  75. }
  76.  
  77. fputs($socket, "USER $user\r\n");
  78. $res = fgets($socket, 512);
  79. if (substr(trim($res), 0, 3) != "+OK") {
  80.     die($res);
  81. }
  82.  
  83. fputs($socket, "PASS $pass\r\n");
  84. $res = fgets($socket, 512);
  85. if (substr(trim($res), 0, 3) != "+OK") {
  86.     die($res);
  87. }
  88.  
  89. echo "Проверка почты...<br>\r";
  90.  
  91. fputs($socket, "STAT\r\n");
  92. $mails = fgets($socket, 15);
  93. if (substr(trim($mails), 0, 3) != "+OK") {
  94.     die($list);
  95. }
  96. else $mails = intval(substr_replace($mails, "", 0, 4));
  97. echo "Писем в ящике ".$user.": ".$mails."<br><br>\r";
  98.  
  99. for ($i = 1; $i <= $mails; $i++) {
  100. fputs($socket, "TOP $i 3\r\n");
  101. $mail = fgets($socket, 15);
  102. if (substr(trim($mail), 0, 3) != "+OK") {
  103.     die($mail);
  104.     }
  105.     else $mail = read_socket($socket);
  106.     $subject = decode_mime(subject_detector($mail));
  107.     $from = decode_mime(from_detector($mail));
  108. echo "Письмо ".$i.": ".$subject." от ".$from."<hr>";
  109. }
  110. fclose($socket);
  111.  
  112. die();
  113. ?>
Add Comment
Please, Sign In to add comment