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
|
<?
$body="";
$post = array();
$site="www.monsite.ch";
$sitewww="www.$site";
$recipient= $_POST["recipient"];
$email=$_POST["email"];
$subject=$_POST["subject"];
$required=$_POST["required"];
$redirect=$_POST["redirect"];
$var1= $_POST["TITRE"];
$ip=$_SERVER["REMOTE_ADDR"];
$nav=$_SERVER["HTTP_USER_AGENT"];
$host=$_SERVER['HTTP_HOST'];
foreach ($_POST as $nomvar => $valvar) {
$post[$nomvar] = $valvar;
$body.="$nomvar: $valvar\n";
}
$body.="\n\nposte par: $ip, $nav, $host\n";
$body.="Autorise depuis=>: $site/$sitewww, to=>: $recipient, from=>: $email, requis=>: $required, redirection=>: $redirect\n";
$found=0;
if (($site==$host) or ($sitewww==$host)) $found=1;
if (!$found){
print "sendmail.php - appel depuis un site illegal - $site<br>";
print "Modifier la variable \$ref dans le programme sendmail.php<br>";
print "Mettez le nom de votre site.<br>Voici la config actuel de \$ref dans sendmail.php: ";
print "$site,$sitewww<br>\n";
exit;
}
if (strlen($email)>30) { print "error ln email"; exit; }
if (strlen($subject)>128) { print "error ln subject"; exit; }
if (strlen($body)>2048) { print "error ln body"; exit; }
if ($email) {
$email = trim($email);
if (!eregi("^[_\.0-9a-z-]+@([0-9a-z][0-9a-z-]+\.)+[a-z]{2,3}$", $email)) {
print "adresse <b>email $email</b> est invalide";
exit;
}
}
if ($required) {
$missing_field_list="";
$required = split(",",$required);
for ($i=0;$i<count($required);$i++) {
$string = trim($required[$i]);
if(!$post["$string"]) {
$missing_field_list .= "<b>$required[$i]</b><br>\n";
}
}
}
if ($missing_field_list) {
print "Le(s) champ(s):<br>\n$missing_field_list est/sont obligatoire(s)";
exit;
}
mail("$recipient","$subject","$body","from:$email");
if (!$redirect) {
print "<pre>$body</pre>"; exit;
} else header("location: $redirect");
?> |
Partager