Oui je poste le contenu du fichier "contact_fonction.php", merci !
Mon site n'est pas encore en ligne, mais ca ne saurait tardé...
<?php
$EMAIL_MAX = 2500;
$SMS_MAX = 120;
function cleanUp($str_to_clean, $newlines, $spaces){
$bad_chars = array('\r', '\t', ';');
if(!$newlines){array_push($bad_chars, '\n');}
if(!$spaces){array_push($bad_chars, ' ');}
$str_to_clean_a = str_replace($bad_chars, '', $str_to_clean);
$str_to_clean_b = strip_tags($str_to_clean_a);
return $str_to_clean_b;
}
function checkEmail($email) {
if(!eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $email)) {return false;}
return true;
}
function checkURL($url) {
if(!eregi("^http:\/\/", $url)) {return false;}
return true;
}
if(isset($_POST["submitForm"])){
$_name = cleanUp($_POST["sender_name"], false, true);
$_email = cleanUp($_POST["sender_email"], false, false);
$_subject = cleanUp($_POST["sender_subject"], false, true);
$_message = cleanUp($_POST["sender_message"], true, true);
$_body = "Contact form\n\n";
if($_name){
$_body .= "NAME: $_name\n\n";
}
if($_email){
$_body .= "EMAIL: $_email\n\n";
}
if($_url){
$_body .= "URL: $_url\n\n";
}
if($_phone){
$_body .= "PHONE: $_phone\n\n";
}
if($_message){
if(strlen($_message) > $EMAIL_MAX){$_message= substr($_message, 0, $EMAIL_MAX);}else{$_message = $_message;}
if(strlen($_message) > $SMS_MAX){$_message2 = substr($_message, 0, $SMS_MAX);}else{$_message2 = $_message;}
}
$_to = array();
$_to[] = "xxxxxxxx@xxxx.xxxx";
if(!$_subject){$_subject = "Contact form";}
if(!$_name){$_name = "CONTACT FORM";}
if(!$_email){$_email = $_name;}
//set the headers
$_header = "From: $_name < $_email >" . "\r\n" .
"Reply-To: ".$_email."\r\n" .
"";
//we can send up to 2 emails (EMAIL and/or SMS)
if(count($_to) > 2){ $_to = array_slice($_to,0,2);}
for($i=0;$i<count($_to);$i++){
//get the correct message, based on where it is delivering to
if(strstr($_to[$i],"xxxxx;fr")){$_text = $_body.$_message2;}else{$_text = $_body.$_message;}
//send the email(s)
mail($_to[$i], $_subject, $_text, $_header);
}
echo "<script type=\"text/javascript\">window.onload = function(){showThanks(thanks_message);}</script>";
}
?>
Modifié par Glasgow (25 Oct 2010 - 17:45)