One Hat Cyber Team
Your IP :
216.73.216.1
Server IP :
27.254.111.200
Server :
Linux wh-sh59.csloxinfo.com 3.10.0-693.5.2.el7.x86_64 #1 SMP Fri Oct 20 20:32:50 UTC 2017 x86_64
Server Software :
Apache
PHP Version :
5.5.38
Buat File
|
Buat Folder
Eksekusi
Dir :
~
/
var
/
www
/
vhosts
/
oakwine.co.th
/
httpdocs
/
View File Name :
mimemail.inc.php
<?php /* +-------------------------------------------------------------------+ | M I M E M A I L (v2.3) | | | | Copyright Gerd Tentler www.gerd-tentler.de/tools | | Created: Nov. 2, 2004 Last modified: Sep. 27, 2015 | +-------------------------------------------------------------------+ | This program may be used and hosted free of charge by anyone for | | personal purpose as long as this copyright notice remains intact. | | | | Obtain permission before selling the code for this program or | | hosting this software on a commercial website or redistributing | | this software over the Internet or in any other medium. In all | | cases copyright must remain intact. | +-------------------------------------------------------------------+ ========================================================================================================== This script can send MIME mails with attachments. It uses the PHP mail() function. EXAMPLE: include('mimemail.inc.php'); $mail = new MIMEMAIL("HTML"); $mail->senderName = "sender name"; $mail->senderMail = "sender@email"; $mail->bcc = "bcc@email"; $mail->subject = "This is the subject line"; $mail->body = "Hello! This is a message for you."; // OR: $mail->body = "path/to/file"; $mail->attachments[] = "path/to/file1"; $mail->attachments[] = "path/to/file2"; ... $mail->create(); $recipients ='recipient1@email,recipient2@email,recipient3@email'; if(!$mail->send($recipients)) echo $mail->error; ========================================================================================================== */ error_reporting(E_WARNING); class MIMEMAIL { //-------------------------------------------------------------------------------------------------------- // Configuration //-------------------------------------------------------------------------------------------------------- var $type = 'Text'; // default e-mail type ("HTML" or "Text") var $senderName = ''; // default sender name var $senderMail = ''; // default sender e-mail address var $cc = ''; // default cc (e-mail address) var $bcc = ''; // default bcc (e-mail address) var $replyTo = ''; // default reply-to (e-mail address) var $subject = ''; // default subject line var $priority = 'normal'; // default priority ("high", "normal", "low") var $documentRoot = ''; // document root (path to images, stylesheets, etc.) var $saveDir = ''; // save e-mail to this directory instead of sending it => just for testing :) var $charSet = 'ISO-8859-1'; // character set (ISO) var $useQueue = false; // use mail queue (true = yes, false = no) => does not work with PHP // versions < 4.0.5, or with versions >= 4.2.3 in Safe Mode, or with // MTAs other than sendmail! //-------------------------------------------------------------------------------------------------------- // Don't change from here unless you know what you're doing //-------------------------------------------------------------------------------------------------------- var $inline = array(); var $attachments = array(); var $cnt = 0; var $body, $header, $footer, $error, $subjectLine, $bodyText; var $uid1, $uid2, $uid3; var $created = false; var $eol = "\n"; var $exclude = array('htm', 'php', 'pl', 'prl', 'cgi', 'py', 'asp'); var $mimeTypes = array('dwg' => 'application/acad', 'asd' => 'application/astound', 'tsp' => 'application/dsptype', 'dxf' => 'application/dxf', 'spl' => 'application/futuresplash', 'gz' => 'application/gzip', 'ptlk' => 'application/listenup', 'hqx' => 'application/mac-binhex40', 'mbd' => 'application/mbedlet', 'xls' => 'application/msexcel', 'xla' => 'application/msexcel', 'hlp' => 'application/mshelp', 'chm' => 'application/mshelp', 'ppt' => 'application/mspowerpoint', 'ppz' => 'application/mspowerpoint', 'pps' => 'application/mspowerpoint', 'pot' => 'application/mspowerpoint', 'doc' => 'application/msword', 'dot' => 'application/msword', 'bin' => 'application/octet-stream', 'oda' => 'application/oda', 'pdf' => 'application/pdf', 'ai' => 'application/postscript', 'eps' => 'application/postscript', 'ps' => 'application/postscript', 'rtc' => 'application/rtc', 'smp' => 'application/studiom', 'tbk' => 'application/toolbook', 'vmd' => 'application/vocaltec-media-desc', 'vmf' => 'application/vocaltec-media-file', 'xhtml' => 'application/xhtml+xml', 'bcpio' => 'application/x-bcpio', 'z' => 'application/x-compress', 'cpio' => 'application/x-cpio', 'csh' => 'application/x-csh', 'dcr' => 'application/x-director', 'dir' => 'application/x-director', 'dxr' => 'application/x-director', 'dvi' => 'application/x-dvi', 'evy' => 'application/x-envoy', 'gtar' => 'application/x-gtar', 'hdf' => 'application/x-hdf', 'php' => 'application/x-httpd-php', 'phtml' => 'application/x-httpd-php', 'latex' => 'application/x-latex', 'mif' => 'application/x-mif', 'nc' => 'application/x-netcdf', 'cdf' => 'application/x-netcdf', 'nsc' => 'application/x-nschat', 'sh' => 'application/x-sh', 'shar' => 'application/x-shar', 'swf' => 'application/x-shockwave-flash', 'cab' => 'application/x-shockwave-flash', 'spr' => 'application/x-sprite', 'sprite' => 'application/x-sprite', 'sit' => 'application/x-stuffit', 'sca' => 'application/x-supercard', 'sv4cpio' => 'application/x-sv4cpio', 'sv4crc' => 'application/x-sv4crc', 'tar' => 'application/x-tar', 'tcl' => 'application/x-tcl', 'tex' => 'application/x-tex', 'texinfo' => 'application/x-texinfo', 'texi' => 'application/x-texinfo', 't' => 'application/x-troff', 'tr' => 'application/x-troff', 'roff' => 'application/x-troff', 'troff' => 'application/x-troff', 'ustar' => 'application/x-ustar', 'src' => 'application/x-wais-source', 'zip' => 'application/zip', 'au' => 'audio/basic', 'snd' => 'audio/basic', 'es' => 'audio/echospeech', 'tsi' => 'audio/tsplayer', 'vox' => 'audio/voxware', 'aif' => 'audio/x-aiff', 'aiff' => 'audio/x-aiff', 'aifc' => 'audio/x-aiff', 'dus' => 'audio/x-dspeeh', 'cht' => 'audio/x-dspeeh', 'mid' => 'audio/x-midi', 'midi' => 'audio/x-midi', 'mp2' => 'audio/x-mpeg', 'ram' => 'audio/x-pn-realaudio', 'ra' => 'audio/x-pn-realaudio', 'rpm' => 'audio/x-pn-realaudio-plugin', 'stream' => 'audio/x-qt-stream', 'wav' => 'audio/x-wav', 'dwf' => 'drawing/x-dwf', 'cod' => 'image/cis-cod', 'ras' => 'image/cmu-raster', 'fif' => 'image/fif', 'gif' => 'image/gif', 'ief' => 'image/ief', 'jpeg' => 'image/jpeg', 'jpg' => 'image/jpeg', 'jpe' => 'image/jpeg', 'tiff' => 'image/tiff', 'tif' => 'image/tiff', 'mcf' => 'image/vasa', 'wbmp' => 'image/vnd.wap.wbmp', 'fh4' => 'image/x-freehand', 'fh5' => 'image/x-freehand', 'fhc' => 'image/x-freehand', 'pnm' => 'image/x-portable-anymap', 'pbm' => 'image/x-portable-bitmap', 'pgm' => 'image/x-portable-graymap', 'ppm' => 'image/x-portable-pixmap', 'rgb' => 'image/x-rgb', 'xwd' => 'image/x-windowdump', 'xbm' => 'image/x-xbitmap', 'xpm' => 'image/x-xpixmap', 'csv' => 'text/comma-separated-values', 'css' => 'text/css', 'htm' => 'text/html', 'html' => 'text/html', 'shtml' => 'text/html', 'js' => 'text/javascript', 'txt' => 'text/plain', 'rtx' => 'text/richtext', 'rtf' => 'text/rtf', 'tsv' => 'text/tab-separated-values', 'wml' => 'text/vnd.wap.wml', 'wmlc' => 'application/vnd.wap.wmlc', 'wmls' => 'text/vnd.wap.wmlscript', 'wmlsc' => 'application/vnd.wap.wmlscriptc', 'xml' => 'text/xml', 'etx' => 'text/x-setext', 'sgm' => 'text/x-sgml', 'sgml' => 'text/x-sgml', 'talk' => 'text/x-speech', 'spc' => 'text/x-speech', 'mpeg' => 'video/mpeg', 'mpg' => 'video/mpeg', 'mpe' => 'video/mpeg', 'qt' => 'video/quicktime', 'mov' => 'video/quicktime', 'viv' => 'video/vnd.vivo', 'vivo' => 'video/vnd.vivo', 'avi' => 'video/x-msvideo', 'movie' => 'video/x-sgi-movie', 'vts' => 'workbook/formulaone', 'vtts' => 'workbook/formulaone', '3dmf' => 'x-world/x-3dmf', '3dm' => 'x-world/x-3dmf', 'qd3d' => 'x-world/x-3dmf', 'qd3' => 'x-world/x-3dmf', 'wrl' => 'x-world/x-vrml'); //-------------------------------------------------------------------------------------------------------- // Functions //-------------------------------------------------------------------------------------------------------- function __construct($type = '') { if($type) $this->type = $type; if(strtoupper(substr(php_uname('s'), 0, 3)) == 'WIN') { $this->eol = "\r\n"; } } function get_img_type($data) { $abc = substr($data, 0, 20); if(stristr($abc, 'GIF')) $ftype = 'gif'; else if(stristr($abc, 'JFIF') || stristr($abc, 'Exif')) $ftype = 'jpeg'; else if(stristr($abc, 'PNG')) $ftype = 'png'; else if(stristr($abc, 'FWS') || stristr($abc, 'CWS')) $ftype = 'swf'; else $ftype = ''; return $ftype; } function get_inl_data($html, $m, $css) { global $HTTP_HOST; if(!$HTTP_HOST) $HTTP_HOST = $_SERVER['HTTP_HOST']; $host = 'http://' . preg_replace('%/$%', '', $HTTP_HOST); for($i = 0; $i < count($m[0]); $i++) { $data = $ext = $fname = ''; if(!preg_match('/^(http|ftp|mailto|javascript)/i', $m[2][$i])) { $inlName = $m[2][$i]; $ext = substr($inlName, strrpos($inlName, '.') + 1); $incl = true; for($j = 0; $j < count($this->exclude) && $incl; $j++) { if(stristr($ext, $this->exclude[$j])) $incl = false; } if($incl) { if($this->documentRoot) { $doc_root = $this->documentRoot; while(preg_match('%^\.\./%', $inlName)) { $inlName = substr($inlName, 3); $doc_root = preg_replace('%/[^/]+$%', '', $doc_root); } $fname = "$doc_root/$inlName"; } else $fname = $inlName; if($fp = @fopen($fname, 'rb')) { $data = fread($fp, filesize($fname)); fclose($fp); } } } if($data) { if(!$ext) $ftype = $this->get_img_type($data); else $ftype = $ext; if($css) $html = str_replace($m[0][$i], ' ' . $m[1][$i] . '(cid:' . $inlName . ')', $html); else $html = str_replace($m[0][$i], ' ' . $m[1][$i] . '="cid:' . $inlName . '"', $html); if(!$this->inline[$ftype][$inlName]) { $this->inline[$ftype][$inlName] = chunk_split(base64_encode($data)); } } else if(!preg_match('/^(http|ftp|mailto|javascript)/i', $m[2][$i])) { if($css) $html = str_replace($m[0][$i], ' ' . $m[1][$i] . "($host/$inlName)", $html); else $html = str_replace($m[0][$i], ' ' . $m[1][$i] . "=\"$host/$inlName\"", $html); } } return $html; } function check_body() { $this->body = preg_replace('/ (onMouseOver|onMouseOut|onClick)=".+?"/i', '', $this->body); if(preg_match_all('/ (src|background|href)="?([^" >]+)"?/i', $this->body, $m)) $this->body = $this->get_inl_data($this->body, $m, false); if(preg_match_all('/ (url)\("?([^"\)]+)"?\)/i', $this->body, $m)) $this->body = $this->get_inl_data($this->body, $m, true); $this->body = preg_replace("/<(table|tr|div)([^>]*)>\r?\n?/i", '<\\1\\2>' . $this->eol, $this->body); $this->body = preg_replace("/<\/(table|tr|td|style|script|div|p)>\r?\n?/i", '</\\1>' . $this->eol, $this->body); } function make_boundaries() { $this->uid1 = 'Next_' . strtoupper(md5(uniqid('MIMEmail') . 1)); $this->uid2 = 'Next_' . strtoupper(md5(uniqid('MIMEmail') . 2)); $this->uid3 = 'Next_' . strtoupper(md5(uniqid('MIMEmail') . 3)); } function build_header() { $this->header = 'Return-Path: ' . $this->senderMail . $this->eol . 'From: ' . $this->senderName . ' <' . $this->senderMail . '>' . $this->eol . 'X-Sender: ' . $this->senderMail . $this->eol . 'X-Mailer: MIMEmail (PHP)' . $this->eol . 'MIME-Version: 1.0' . $this->eol; if($this->replyTo) $this->header .= 'Reply-To: ' . $this->replyTo . $this->eol; if($this->cc) $this->header .= 'Cc: ' . $this->cc . $this->eol; if($this->bcc) $this->header .= 'Bcc: ' . $this->bcc . $this->eol; if($this->saveDir) $this->header .= 'Subject: ' . $this->subject . $this->eol; switch(strtolower($this->priority)) { case 'high': $priority = 1; $ms_priority = 'high'; break; case 'low': $priority = 5; $ms_priority = 'low'; break; default: $priority = 3; $ms_priority = 'normal'; break; } $this->header .= 'X-Priority: ' . $priority . $this->eol . 'X-MSMail-Priority: ' . $ms_priority . $this->eol; if(count($this->attachments)) { $this->header .= 'Content-Type: multipart/mixed; boundary="' . $this->uid1 . '"' . $this->eol . $this->eol . 'This is a multi-part message in MIME format.' . $this->eol . $this->eol . '--' . $this->uid1 . $this->eol; } if($this->type == 'HTML') { $this->header .= 'Content-Type: multipart/alternative; boundary="' . $this->uid3 . '"' . $this->eol . $this->eol . '--' . $this->uid3 . $this->eol; $this->header .= 'Content-Type: text/plain; ' . 'charset="' . $this->charSet . '"' . $this->eol . 'Content-Transfer-Encoding: 8bit' . $this->eol . $this->eol . preg_replace("/(\s*\r?\n\s*){2}/", '\\1\\1', @strip_tags($this->body)) . $this->eol . $this->eol . '--' . $this->uid3 . $this->eol; if(count($this->inline)) { $this->header .= 'Content-Type: multipart/related; boundary="' . $this->uid2 . '"' . $this->eol . $this->eol . '--' . $this->uid2 . $this->eol; } } $this->header .= 'Content-Type: text/' . (($this->type == 'HTML') ? 'html' : 'plain') . '; ' . 'charset="' . $this->charSet . '"' . $this->eol . 'Content-Transfer-Encoding: 8bit' . $this->eol; } function build_footer() { $atts = $ftypes = array(); $this->footer = ''; foreach($this->attachments as $att) { if($att && $att != 'none') { if($fp = @fopen($att, 'rb')) { $filename = basename(str_replace('\\', '/', $att)); $file = fread($fp, filesize($att)); fclose($fp); $ext = substr($filename, strrpos($filename, '.') + 1); $ftypes[$filename] = $this->mimeTypes[$ext] ? $this->mimeTypes[$ext] : $this->mimeTypes['bin']; $atts[$filename] = chunk_split(base64_encode($file)); } } } if(count($this->inline)) { while(list($ftype, $arr) = each($this->inline)) { if(count($arr)) while(list($inlName, $data) = each($arr)) { $inlType = $this->mimeTypes[$ftype] ? $this->mimeTypes[$ftype] : $this->mimeTypes['bin']; $this->footer .= '--' . $this->uid2 . $this->eol . 'Content-Type: ' . $inlType . '; name="' . $inlName . '"' . $this->eol . 'Content-ID: <' . $inlName . '>' . $this->eol . 'Content-Disposition: inline; filename="' . $inlName . '"' . $this->eol . 'Content-Transfer-Encoding: base64' . $this->eol . $this->eol . $data . $this->eol . $this->eol; } } $this->footer .= '--' . $this->uid2 . '--' . $this->eol . $this->eol; } if($this->type == 'HTML') $this->footer .= '--' . $this->uid3 . '--' . ($atts ? $this->eol . $this->eol : ''); if(count($atts)) { while(list($filename, $file) = each($atts)) { $this->footer .= '--' . $this->uid1 . $this->eol . 'Content-Type: ' . $ftypes[$filename] . '; name="' . $filename . '"' . $this->eol . 'Content-Disposition: attachment; filename="' . $filename . '"' . $this->eol . 'Content-Transfer-Encoding: base64' . $this->eol . $this->eol . $file . $this->eol . $this->eol; } $this->footer .= '--' . $this->uid1 . '--'; } } function send($recipients) { $ok = false; if($this->created) { $this->build_header(); $message = $this->body . $this->eol . $this->eol . $this->footer; if(is_array($recipients)) { $rec = implode(', ', $recipients); $recipients = $rec; } if($this->saveDir) { $file = $this->saveDir . '/mail_' . ($this->cnt + 1) . '.eml'; if($fp = @fopen($file, 'w')) { $mimemail = 'To: ' . $recipients . $this->eol . $this->header . $this->eol . $message; if(!fwrite($fp, $mimemail, strlen($mimemail))) { $this->error = 'Could not write to "' . $file . '"' . $this->eol; } fclose($fp); $ok = true; } else $this->error = 'Could not open "' . $file . '"' . $this->eol; } else { $php_ver = phpversion(); if(function_exists('ini_get')) $safe_mode = ini_get('safe_mode'); else $safe_mode = get_cfg_var('safe_mode'); if($php_ver < '4.0.5' || ($php_ver >= '4.2.3' && $safe_mode)) { $ok = @mail($recipients, $this->subject, $message, $this->header); } else { $options = ($this->useQueue ? '-odq ' : '') . '-i -f ' . $this->senderMail; $ok = @mail($recipients, $this->subject, $message, $this->header, $options); } if(!$ok) { $this->error = 'Error while sending e-mail'; if(!strstr($recipients, ',')) $this->error .= ' to "' . $recipients . '"' . $this->eol; else $this->error .= $this->eol; } } $this->cnt++; $this->subject = $this->subjectLine; $this->body = $this->bodyText; } else $this->error = 'MIME mail not created yet' . $this->eol; return $ok; } function create() { $this->inline = array(); if(strlen($this->body) < 100) { $file = str_replace('\\', '/', $this->body); if($fp = @fopen($file, 'r')) { $this->body = fread($fp, filesize($file)); fclose($fp); $this->documentRoot = dirname($file); } } if($this->type == 'HTML') $this->check_body(); $this->make_boundaries(); $this->build_footer(); $this->subjectLine = $this->subject; $this->bodyText = $this->body; $this->created = true; } } ?>