Ancora problemi con la bacheca
Salve a tutti, ho ancora dei problemi con la mia bacheca.
Intanto posto il codice:
azione.php (il motore):
Codice PHP:
<?php
$filename="bacheca.html";
if ($_POST['nasc'] == 'y') {
$nome=trim($_POST['nick']);
$nome=htmlentities($nome, ENT_QUOTES);
$testo2=trim($_POST['testo']);
$testo2=htmlentities($testo2, ENT_QUOTES);
$email=trim($_POST['email']);
$opzione=$_POST['opzione'];
if ($nome="" OR $email="" OR $sito="" OR $testo2="" OR $opzione="") {
echo "Devi riempire tutti i campi!";
}
else {
if($opzione == "si") {
$sito = trim($_POST['sito']);
}
else {
$sito="no";
}
if ($sito=="no") {
$testo="$nome,<a href=\"mailto:$email\">e-mail</a> ha scritto:<br>$testo2<br>";
}
else {
$testo="$nome,<a href=\"mailto:$email\">e-mail</a>,<a href=\"$sito\">sito web</a> ha scritto:<br>$testo2<br>";
}
function bbcode($testo) {
$cerca_codice= array(
'/\[b\](.*?)\[\/b\]/is',
'/\[i\](.*?)\[\/i\]/is',
'/\[u\](.*?)\[\/u\]/is',
'/\[url\](.*?)\[\/url\]/is',
'/\[img\](.*?)\[\/img\]/is',
'/\[url\=(.*?)\](.*?)\[\/url\]/is'
);
$sostituisci_codice = array(
'<strong>$1</strong>',
'<em>$1</em>',
'<u>$1</u>',
'<a href=$1 target=blank>$1</a>',
'<img src=\'$1\' />',
'<a href=$1 target=blank>$2</a>',
);
$testo= preg_replace ($cerca_codice, $sostituisci_codice, $testo);
return $testo;
}
$testo=bbcode($testo);
/***emoticons & codice ***/
$url=array("<img src=\"http://hackerforum.devil.it/images/smiles/sc_biggrin.gif\">","<img src=\"http://hackerforum.devil.it/images/smiles/sc_sad.gif\">","<img src=\"http://hackerforum.devil.it/images/smiles/sc_redface.gif\">","<img src=\"http://hackerforum.devil.it/images/smiles/sc_wink.gif\">","<div class=\"codice\">","</div>","\n</div>\n</body>\n</html>");
$testo=str_replace(':D',$url[0], $testo);
$testo=str_replace(':(',$url[1], $testo);
$testo=str_replace(':oops:',$url[2], $testo);
$testo=str_replace(';)',$url[3], $testo);
$testo=str_replace('[code]',$url[4], $testo);
$testo=str_replace('[/code]',$url[5], $testo);
$fp=fopen($filename, 'a+');
$fr=fread($fp, filesize($filename));
str_replace('</div>','',$fr);
str_replace('</body>','',$fr);
str_replace('</html>','',$fr);
fwrite($fp, $testo.$url[6]);
fclose($fp);
echo "<script type=\"text/javascript\">\n";
echo "location.href='bacheca.html';\n";
echo "</script>";
}
}
else {
?>
<html>
<head>
<title>Scrivi</title>
<style>
.container {
width: 80%;
margin: 0 auto auto;
}
.col {
float: left;
width: 50%;
}
.img {
cursor: pointer;
}
</style>
</head>
<body><div class="container"><div class="col">
<form name="form" action="azione.php" method="post">
<input type="hidden" value="y" name="nasc">
Nickname: <input type="text" name="nick"><br>
E-mail: <input type="text" name="email" id="email"><br>
Sito web: si <input type="radio" name="opzione" value="si" onclick="document.getElementById ('indirizzo_box').style.display = 'block'" /> no <input type="radio" name="opzione" value="no" onclick="document.getElementById ('indirizzo_box').style.display = 'none'" /><div id="indirizzo_box" style="display: none;"><input type="text" name="sito"></div><br>
Inserisci il commento:<br> <textarea cols="20" name="testo" rows="10"></textarea><br>
<input type="submit" value="invia" > <input type="reset" value="cancella">
</form></div>
<div class="col"> </div><div class="col">
Regole:<ul>
<li>HTML <b>non permesso</b></li>
<li>BBCODE <b>permesso</b></li>
<li>EMOTICON <b>permesse</b></li><br>
<img src="http://hackerforum.devil.it/images/smiles/sc_biggrin.gif" onclick="form.testo.value=form.testo.value+':D'" class="img"> <img src="http://hackerforum.devil.it/images/smiles/sc_sad.gif" onclick="form.testo.value=form.testo.value+':('" class="img"> <img src="http://hackerforum.devil.it/images/smiles/sc_redface.gif" onclick="form.testo.value=form.testo.value+':oops:'" class="img"> <img src="http://hackerforum.devil.it/images/smiles/sc_wink.gif"onclick="form.testo.value=form.testo.value+';)'" class="img"><br>
I tag bbcode permessi sono:<br>
[b][/b],[i][/i],[u][/u],[code][/code],[ur][/url],[url=][/url],[img][/img]
</ul>
</div>
</div>
</body>
</html>
<?php
}
?>
bacheca.html:
Codice HTML:
<html>
<head>
<title>Bacheca</title>
<style>
.codice {
font-family: Courier, 'Courier New', sans-serif;
font-size: 11px;
color: #FF9900;
background-color: #FAFAFA;
border: #D1D7DC;
border-style: solid;
border-left-width: 1px;
border-top-width: 1px;
border-right-width: 1px;
border-bottom-width: 1px
}
#contenitore {
background-color:#EFEFEF;
width: 500px;
}
</style>
</head>
<body>
<a href="azione.php">Aggiungi un commento</a><br>
Ecco la bacheca:<br><div id="contenitore">
</div>
</body>
</html>
I problemi sono questi:
1) se scrivo ciao mi viene scritto ciao ciao
ciao
2) in azione.php mi da errore :
Codice:
Parse error: syntax error, unexpected ';' in /membri/gabryhacker/azione.php on line 60
Come posso risolvere?
EDIT:
Il secondo problema è risolto: manca una parentesi al fread.