1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244
| <?php
include_once ('/mnt/104/sdb/7/d/ub33/photo/inc/config.php');
include_once ('/mnt/104/sdb/7/d/ub33/photo/inc/fonctions.php');
include_once ('/mnt/104/sdb/7/d/ub33/photo/admin/hpage.php');
if (!empty($_GET))
{myExtract($_GET, $GLOBALS);}
else if (!empty($HTTP_GET_VARS))
{myExtract($HTTP_GET_VARS, $GLOBALS);}
if (!empty($_POST))
{myExtract($_POST, $GLOBALS);}
else if (!empty($HTTP_POST_VARS))
{myExtract($HTTP_POST_VARS, $GLOBALS);}
$racine_mailing="/mnt/104/sdb/7/d/ub33";
$mailing_fichier="/photo/admin/mailing/mailing_list.txt";
$mailing_text="/photo/admin/mailing/mailing_message.txt";
$num_ligne = 0 ;
if ($option == "arreter") {
if ($_GET['fichier']) {
unlink($_GET['fichier']);
unlink($racine_mailing.$mailing_text);
echo "<div style='font-size: 18px; text-align: center; padding-top:25%;'>Suppression du fichier: ".$_GET['fichier']." demandé<br />";
echo "Le mailing est annulé<br />";
if (file_exists($racine_mailing.$mailing_fichier)) { echo "Une erreur est survenue: Le fichier ".$_GET['fichier']." existe toujours !!"; } else { echo "Le fichier ".$_GET['fichier']." a bien été supprimé"; }
}
} else {
if (file_exists($racine_mailing.$mailing_fichier)) { $affichage="no"; echo "<meta http-equiv='Refresh' content='$delais_mail; url=admin_message.php' />"; }
if (!$_POST['Submit'] && $affichage!="no") {
?>
<link rel="stylesheet" type="text/css" href="img/ajout.css"/>
<link rel="stylesheet" type="text/css" id="styles"/>
<link href="style.css" rel="stylesheet" type="text/css">
<style type="text/css" media="all">
@import url("img/style.css");
</style>
<body>
<div id="content">
<form method="post" name="mailing" id="mailing">
<input type="hidden" name="date" value="<?php echo date("Y-m-d H:i:s") ?>" />
<table>
<tr>
<td class='noir' style="width: 100%; text-align: left; font-size: 18px;">Envoyer un mailing </td></tr>
<tr><td colspan='5' style="text-align: center;">
<table>
<tr><td style="white-space: nowrap; vertical-align: top;">Contenu du mail :</td></tr>
<tr>
<td><textarea cols="62" rows="12" name="texte"></textarea></td>
<td>
<table style="text-align: left;">
<tr><td><input type="radio" name="choix" value="Membres" />Liste Membre
<br /><input type="radio" name="choix" value="Spamlist" />Pub-list</td></tr>
<tr><td><select name="choix_fichier">
<?php
$dir="/mnt/104/sdb/7/d/ub33/photo/admin/mailing/liste";
if ($handle = opendir($dir)) {
while (false !== ($file = readdir($handle))) {
if ($file != "." && $file != "..") { echo "<option value='".$file."'>".$file."</option> "; }
}
closedir($handle);
}
?>
</select></td></tr>
</table>
</td>
</tr>
<tr><td style="text-align: center; padding-top: 25px;"><input type="submit" onclick="javascript:window.location='admin_message.php';" name="Submit" value="Envoyer le mail" />
<input type="hidden" name="MM_insert" value="add" /></td>
</tr>
</table></td>
<td style="width: 15%;"> </td>
</tr>
</table>
</form>
</div>
<center>
</body>
</html>
<?php
}
if (file_exists($racine_mailing.$mailing_fichier)) {
$mailing_en_cours = 1;
echo "<br /><br /><br />";
envoi_mailing($racine_mailing ,$mailing_fichier, $mailing_text);
exit;
} else {
if ($_POST['Submit']) {
if (!$_POST['choix']) {
echo "<div style='font-size: 18px; padding-top: 25%; text-align: center;'>Tu dois selectionner une liste de diffusion<div><br /><a class='ferm_button' href='javascript:history.back()'><span style='margin-left: 5%;'>[ Page précédente ]</span></a><br /><br />"; exit;
} else if ($_POST['texte'] == "") {
echo "<div style='font-size: 18px; padding-top: 25%; text-align: center;'>Tu n'as pas saisi de message !!<div><br /><a class='ferm_button' href='javascript:history.back()'><span style='margin-left: 5%;'>[ Page précédente ]</span></a><br /><br />"; exit;
} else {
echo "<meta http-equiv='Refresh' content='$delais_mail; url=admin_message.php' />";
$objet_mail = str_replace(array(";","\n","\r")," ",$_POST['texte']);
$list_mailing = "MESSAGE: ".$objet_mail."\n";
$post_message = $_POST['texte'];
$post_message = stripslashes($post_message);
$texte_message ="<html><head></head><body>";
$texte_message .= $post_message."</body>";
if ($_POST['choix'] == "Membres") {
$requete = "SELECT `idx`, `pseudo`, `email`, `sexe` FROM trombino_trombino";
$act_requete = mysql_query($requete) or die(mysql_error());
$mass_mail = mysql_fetch_assoc($act_requete);
do {
$list_mailing .= $mass_mail['email'].":".$mass_mail['pseudo']."\n";
} while ($mass_mail = mysql_fetch_assoc($act_requete));
}
if ($_POST['choix'] == "Spamlist") {
$racine="/mnt/104/sdb/7/d/ub33/photo/admin/mailing/liste/";
$content .= file_get_contents($racine.$_POST['choix_fichier']);
$list_mailing .= str_replace(";", "\n", $content);
}
if (!$inF = fopen($racine_mailing.$mailing_text,"w")) {
echo "Echec de l'ouverture du fichier: ".$racine_mailing.$mailing_text."<br />";
exit;
} else {
fputs($inF,$texte_message);
fclose($inF);
}
if (!$inF = fopen($racine_mailing.$mailing_fichier,"w")) {
echo "Echec de l'ouverture du fichier: ".$racine_mailing.$mailing_fichier."<br />";
exit;
} else {
fputs($inF,$list_mailing);
fclose($inF);
$contents = file_get_contents($racine_mailing.$mailing_fichier);
$taille_init = filesize($racine_mailing.$mailing_fichier);
if (!$inF = fopen($racine_mailing.$mailing_fichier,"w")) {
echo "Echec de l'ouverture du fichier: ".$racine_mailing.$mailing_fichier."<br />";
exit;
} else {
$list_mailing = "Taille initial du fichier : " .$taille_init."\n";
$list_mailing .= $contents;
fputs($inF,$list_mailing);
fclose($inF);
}
envoi_mailing($racine_mailing, $mailing_fichier, $mailing_text);
unset($conf_post);
}
}
}
}
}
function envoi_mailing($racine_mailing, $mailing_fichier, $mailing_text) {
include ('/mnt/104/sdb/7/d/ub33/photo/inc/config.php');
$taille=filesize($racine_mailing.$mailing_fichier);
$tab = file($racine_mailing.$mailing_fichier);
if (!$fp = fopen($racine_mailing.$mailing_text,"r+")) {
echo "Echec de l'ouverture du fichier lors de la fonction lecture : ".$mailing_text."<br />";
exit;
} else {
$handle = fopen($racine_mailing.$mailing_text,"r+");
$message .= fread($handle, filesize($racine_mailing.$mailing_text));
fclose($handle);
}
if (count($tab) == '2') {
echo "<div style='font-size:16px; text-align: center;'>Le mailing a bien été envoyé. <br /> Suppression du fichier temporaire en cours</div>";
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
@mail("pervy14@hotmail.com", "TCHAT-FUSION: Fin de mailing.",
"Bonjour,
-- Le mailing a bien été a: ".$nb_mail_env." adresses <br /> -- Avec ce message : <br />
".$message."",$headers);
unlink($racine_mailing.$mailing_fichier);
unlink($racine_mailing.$mailing_text);
exit;
}
else {
echo "le message est : " .$message. ".";
echo "<div style='font-size:16px; text-align: center; padding-top:25%;'>Un mailing est en cours d'execution.<br /><br />";
echo "<input type=\"submit\" name=\"Annuler\" Onclick=\"javascript: window.location='admin_message.php?option=arreter&fichier=$racine_mailing$mailing_fichier';\" value=\"Stopper cet envoi\" />";
if (!$fp = fopen($racine_mailing.$mailing_fichier,"r+")) {
echo "Echec de l'ouverture du fichier lors de la fonction lecture : ".$racine_mailing.$mailing_fichier."<br />";
exit;
} else {
$fp = fopen($racine_mailing.$mailing_fichier,"r+");
$num_ligne=1;
$nb_pack=$nb_mail + 2;
while (!feof($fp)) {
$buffer = trim(fgets($fp, 4096));
if ($num_ligne == 1) { $liste = explode(":", $buffer); $prop_avancement = 100 - round(($taille/$liste['1'])*100); $liste_modif.=$buffer."\n"; echo "<br /><br /><br /><div style='font-size:20px'>Etat d'avancement : <b>" .$prop_avancement."% </b>.</div>";}
else if ($num_ligne == 2) { $liste_modif.=$buffer."\n"; }
else if ($num_ligne > 2 && $num_ligne <= $nb_pack && $buffer != "") {
$liste = explode(":", $buffer);
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
@mail("".$liste['0']."", "TCHAT-FUSION: Actualités.", $message,$headers);
}
else if ($num_ligne > $nb_pack) { $liste_modif.=$buffer."\n"; }
$num_ligne++;
}
fclose ($fp);
echo "</div>";
//Réecriture du fichier modifié.
if (!$fp = fopen($racine_mailing.$mailing_fichier,"w+")) {
echo "Echec de l'ouverture du fichier lors de la fonction ecriture: ".$racine_mailing.$mailing_fichier."<br />";
exit;
} else {
fwrite($fp,$liste_modif);
fclose($fp);
exit;
}
}
}
}
?> |
Partager