codice del file prova_form_mail.php : (come puoi vedere sono inclusi 2 file per il BBcode):
Codice PHP:
<?php
include("bbcode.php");
include("bbcode2.php");
if (count($_POST))//invio email solo se $_POST è diverso da zero o è settato
{
//CONTROLLO HACKERS
foreach(array('email') as $key) {$_POST[$key] = strip_tags($_POST[$key]);}
if(!is_secure($_POST)) {
$subject = "Hack Attempt via Contact Form!";
$body = " - Indirizzo IP: ".getenv("REMOTE_ADDR")."
- Agent: ".getenv("HTTP_USER_AGENT")."";
//QUI INSERISCI LA TUA EMAIL
$emailto = "eurosalute@altervista.org";
$headers = "From: $emailto";
//AVVERTI TE STESSO DELL'ATTACCO:
@mail($emailto, $subject, $body, $headers);
die("<br><br><font color=\"red\"><b>Asta la vista Hacker!</b></font><br><br>");
}
//end CONTROLLO HACKERS
$validate_email = true;
$filter_email = "/^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/";
$contenuto_textarea = bbcode($_POST[note]);
$contenuto_textarea = strip_tags($contenuto_textarea,"<strong><em><u><img><a><marquee><object><param><embed><div>");
if (!preg_match($filter_email, $_POST[email])) {
echo ("<font color=\"red\"><b>Indirizzo email non valido!</b></font><br>");
$validate_email = false;
}
if (empty($contenuto_textarea)) {
echo ("<font color=\"red\"><b>Non hai scritto alcun messaggio!</b></font><br>");
$validate_email = false;
}
if ($validate_email)
{
//L'INDIRIZZO DEL DESTINATARIO DELLA MAIL
$to = "eurosalute@altervista.org";//, ***@***.it";
//IL SOGGETTO DELLA MAIL
$subject = "Messaggio da $_POST[email]";
//CORPO DEL MESSAGGIO
//metti come commento il seguente $body:
//$body .= "\nMessaggio:\n__________\n" . @filter_var($_POST['note'], FILTER_SANITIZE_STRING);
//metti questo come $body:
$body = nl2br("\nMessaggio:\n__________\n".stripslashes($contenuto_textarea)."\n\nFrom: ".stripslashes($_POST[email])."\n__________\nFine Messaggio.");
//INTESTAZIONI SUPPLEMENTARI
$headers = "MIME-Version: 1.0\r\n" ;
$headers .= "Content-Type: text/html; charset=iso-8859-1\r\n";
$headers .= "Content-Transfer-Encoding: 7bit\r\n";
$headers .= "From: $_POST[email]\r\n";
//INVIO
if(@mail($to, $subject, $body, $headers)) { // SE L'INOLTRO È ANDATO A BUON FINE...
echo "E-mail inviata con successo!<br><br>";
//stampo il messaggio inviato:
echo "<font color=\"\">$body</font><br><br>";
} else {// ALTRIMENTI...
echo "Si sono verificati dei problemi nell'invio della mail, riprova pù tardi.<br><br>";
//echo "<meta http-equiv=\"refresh\" content=\"5;url=/private/mediabssp.html\" />";
}
}//end if $validate_email
}//end if (count($_POST)
//# NON CAMBIARE NIENTE QUI SOTTO:
function is_secure($ar) {
$reg = "/(Content-Type|Bcc|MIME-Version|Content-Transfer-Encoding)/i";
if(!is_array($ar)) {return preg_match($reg,$ar);}
$incoming = array_values_recursive($ar);
foreach($incoming as $k=>$v) if(preg_match($reg,$v)) return false;
return true;
}
function array_values_recursive($array) {
$arrayValues = array();
foreach ($array as $key=>$value) {
if (is_scalar($value) || is_resource($value)) {
$arrayValues[] = $value;
$arrayValues[] = $key;
}
elseif (is_array($value)) {
$arrayValues[] = $key;
$arrayValues = array_merge($arrayValues, array_values_recursive($value));
}
}
return $arrayValues;
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Prova Form email</title>
<meta name="description" content="">
<meta name="keywords" content="">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<meta http-equiv="Pragma" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="Cache-Control" content="no-cache">
<meta name="rating" content="General">
<meta http-equiv="Content-Language" content="it">
<meta name="copyright" content="Copyright 2010, eurosalute.altervista.org">
<meta name="resource-type" content="document">
<meta name="Submission" CONTENT="http://eurosalute.altervista.org">
<meta name="Author" CONTENT="Webmaster">
<meta name="Subject" CONTENT="">
<meta name="ROBOTS" content="ALL">
<meta name="revisit-after" content="10 days">
<link href="http://classifieds.yourclickspaid.com/style/style.css" rel="stylesheet" type="text/css" />
<script language="javascript" src="../js/windowstatus0.js"></script>
</head>
<body topmargin="0" leftmargin="0">
<div class="special">
<br>
<form action="prova_form_mail.php" method="POST" name="provaform">
<table border="0">
<tr>
<td valign="top"><font size="2" color="">*Tuo Indirizzo email:</font></td>
<td>
<input size="40" name="email" maxlength="45">
</td>
<tr>
<td valign="top"><font size="2" color="">*Messaggio da inviare:</font></td>
<td>
<?php textarea("note", "", "provaform");?>
<!--<textarea rows="10" name="note" cols="40"></textarea>-->
</td>
</tr>
<tr>
<td colspan="2" valign="bottom" align="center" height="30">
<!-- qui ho aggiunto name="send" per if ($_POST['send'])-->
<input type="submit" value="Invia" name="send">
<input type="reset" value="Cancella"></td>
</tr>
</table>
</form>
</div>
</body>
</html>
codice file bbcode.php:
Codice PHP:
<?php
//CODE BY MATTEOIAMMA – WWW.MATTEOIAMMARRONE.COM
//MODIFICATO E FATTO FUNZIONARE DA eurosalute@altervista.org http://eurosalute.altervista.org
function bbcode($var){
$bbcodevar = array(
"/\[b\](.*?)\[\/b\]/is" => '<strong>$1</strong>',
"/\[i\](.*?)\[\/i\]/is" => '<em>$1</em>',
"/\[u\](.*?)\[\/u\]/is" => '<u>$1</u>',
"/\[img\](.*?)\[\/img\]/is" => '<img src="$1" />',
"/\[url\](.*?)\[\/url\]/is" => '<a href="$1" target="_blank">$1</a>',
"/\[url\=(.*?)\](.*?)\[\/url\]/is" => '<a href="$1" target="_blank">$2</a>',
"/\[quote\](.*?)\[\/quote\]/is" => '<div class="forum_quote">$1</div>',
"/\[youtube\](.*?)\[\/youtube\]/is" => '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0"><param name="movie" value="$1" /><param name="quality" value="best" /><param name="play" value="true" /><embed pluginspage="http://www.macromedia.com/go/getflashplayer" src="$1" type="application/x-shockwave-flash" quality="best" play="true"></embed></object>',
"/\[code\](.*?)\[\/code\]/is" => '<div class="forum_code">$1</div>',
"/\[marquee\](.*?)\[\/marquee\]/is" => '<marquee>$1</marquee>'
);
$count = 0;
$var = preg_replace (array_keys($bbcodevar), array_values($bbcodevar), $var, -1, $count);
if (!$var) echo "<br>Errore BBcode<br>";
//$var = preg_replace (array_keys($bbcodevar), array_values($bbcodevar), $var);
//end SISTEMA BBCODE
//SISTEMA SMILE
$sel_smile = opendir("smiles");
while($smile=readdir($sel_smile))
{
$smile_value = str_replace(".gif", "", $smile);
$var_nw = str_replace($smile_value, "<img src='http://eurosalute.altervista.org/tool/smiles/$smile'/>", $var);
}
if (!$var_nw) echo "<br>Errore Smile(BBcode)<br>";
//end SYSTEMA SMILE
return $var_nw;
//return $var;
}
?>
codice file bbcode2.php:
Codice PHP:
<?php
//MODIFICATO E FATTO FUNZIONARE DA eurosalute@altervista.org http://eurosalute.altervista.org
function textarea($name, $value, $form){
?>
BBcode :
<a Onclick="document.<?php echo $form; ?>.<?php echo $name; ?>.value+='[b][/b]'" class="box" style="cursor: ;">Grassetto</a>
<a Onclick="document.<?php echo $form; ?>.<?php echo $name; ?>.value+='[u][/u]'" class="box">Sottolineato</a>
<a Onclick="document.<?php echo $form; ?>.<?php echo $name; ?>.value+='[i][/i]'" class="box">Corsivo</a>
<a Onclick="document.<?php echo $form; ?>.<?php echo $name; ?>.value+='[img][/img]'" class="box"><b>IMMAGINE</b></a>
<a Onclick="document.<?php echo $form; ?>.<?php echo $name; ?>.value+='[url=quiurl]quitesto[/url]'" class="box"><b>URL</b></a>
<a Onclick="document.<?php echo $form; ?>.<?php echo $name; ?>.value+='[youtube][/youtube]'" class="box">YouTube Video</a>
<a onclick="document.<?php echo $form; ?>.<?php echo $name; ?>.value+='[code][/code]'" class="box">CODE</a>
<a onclick="document.<?php echo $form; ?>.<?php echo $name; ?>.value+='[quote][/quote]'" class="box">QUOTE</a>
<a onclick="document.<?php echo $form; ?>.<?php echo $name; ?>.value+='[marquee][/marquee]'" class="box">MARQUEE</a>
<p></p>
<?php
echo "<textarea name='$name' rows='10' cols='50' id='$name'>$value</textarea>";
?>
<p></p>
BBcode Smiles :
<?php
$smile_op = opendir("smiles");
while($smile=readdir($smile_op)){
if (substr_count($smile,".gif")){
?>
<a onclick="document.<?php echo $form; ?>.<?php echo $name; ?>.value+='[img]http://eurosalute.altervista.org/tool/smiles/<?php echo $smile;?>[/img]'">
<img src="smiles/<?php echo $smile;?>"/></a>
<?php
}//end substr_count
}// end while
?>
<p></p>
<?php
}
?>
Segui i commenti nei file.....