stuppid_bot

Untitled

May 3rd, 2013
164
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.73 KB | None | 0 0
  1. <?php
  2.  
  3. error_reporting(E_ALL);
  4. session_start();
  5.  
  6. if ( isset($_POST['captcha']) && strtolower( trim($_POST['captcha']) ) == $_SESSION['captcha'] && ( $message = isset($_POST['message']) ? trim($_POST['message']) : '' || isset($_FILES['attachment']) ) ) {
  7.     $to = '[email protected]';
  8.     $headers  = "Mime-Version: 1.0\r\n";    
  9.     $headers .= ( $email = isset($_POST['email']) ? $_POST['email'] : '' && filter_var($email, FILTER_VALIDATE_EMAIL) )
  10.         ? "From: " . ( ($name = isset($_POST['name']) ? trim($_POST['name']) : '') ? "=?UTF-8?B?" . base64_encode($name) . "?= " : "" ) . "<$email>\r\n"
  11.         : "From: noreply@" . $_SERVER['HTTP_HOST'] . "\r\n";
  12.     $boundary = md5( time() );
  13.     $headers .= "Content-Type: multipart/mixed; boundary=\"$boundary\"";
  14.     $body  = "--$boundary\r\n";
  15.     $body .= "Content-Type: text/plain; charset=UTF-8\r\n";
  16.     $body .= "Content-Transfer-Encoding: binary\r\n\r\n";  
  17.     $body .= $message;
  18.  
  19.     if (isset($_FILES['attachment'])) {
  20.         for ($i = 0, $c = count($_FILES['attachment']['name']); $i < $c; ++$i) {
  21.             $body .= "\r\n--$boundary\r\n";
  22.             $body .= "Content-Type: " . $_FILES['attachment']['type'][$i] . "; name=\"=?UTF-8?B?" . base64_encode($_FILES['attachment']['name'][$i]) . "?=\"\r\n";
  23.             $body .= "Content-Disposition: attachment\r\n";
  24.             $body .= "Content-Transfer-Encoding: base64\r\n\r\n";      
  25.             $body .= base64_encode( file_get_contents($_FILES['attachment']['tmp_name'][$i]) );      
  26.         }      
  27.     }
  28.  
  29.     $body .= "\r\n--$boundary--";
  30.  
  31.     if ( @mail($to, '=?UTF-8?B?' . base64_encode('Отправлено через обратную связь') . '?=', $body, $headers) ) {
  32.         echo('OK');
  33.     }
  34. }
  35.  
  36. ?>
Advertisement
Add Comment
Please, Sign In to add comment