Commenti:
Codice PHP:
<?php
$folder = "../../admin/commenti/";
# Attenzione
if (isset($_GET['mode']) && $_GET['mode']=='view'){$folder = "";}
include ($folder."config.php");
$ora = date("H:i");
setlocale (LC_TIME, "it_IT");
$giorno = strftime ("%d %B %G");
$stile = $s;
$file = $folder."commenti/".$f.".txt";
if (isset($_POST['nome'])){
$nome = $_POST['nome'];
$email = $_POST['email'];
$web = $_POST['web'];
$msg = stripslashes($_POST['messaggio']);
$msg = htmlspecialchars ($msg, ENT_QUOTES);
$messaggio = str_replace("\n", "<br>", $msg);
}
# CAPTCHA
session_start();
function audit() {
$digit = $_SESSION['digit'];
$userdigit = $_POST['userdigit'];
if (($digit == $userdigit) && ($digit > 1)) {
return true;
} else {
return false;
}
}
if($nome!=null){
if (!audit()){echo "<script> alert('Il codice inserito non corretto');</script>";}
else {
$open = fopen ($file, "a+");
fwrite ($open,$nome."|".$email."|".$web."|".$messaggio."|".time()."|\n");
fclose ($file);
}
}
# VISUALIZZA MESSAGGI
echo '<div align="left" style="position:relative; background-color:'.$bgf.'; font:'.$fcar.'; font-weight:bold; font-color:'.$fcol.'; margin:1px auto; width:'.$ltab.'; padding:15px;">
<p align="center">Commenti';
fopen ($file, "a+");
$msgg = file($file);
$vv = count($msgg)-$v;
if (isset($_GET['mode']) && $_GET['mode']=='view'){
$f = $_GET['f'];
$stile = $_GET['s'];
$vv = 0;
}
if (count($msgg)-$v<0){$vv=0;}
for ($i=count($msgg)-1; $i>=$vv; $i--){
$p=explode("|",$msgg[$i]);
$nome=$p['0'];
$web = $p['2'];
if ($p['1'] != null && $vemail==1){$email = " - ".$p['1'];} else {$email = "";}
if ($p['2'] != null){$t = " - ";} else {$t="";}
$messaggio=$p['3'];
if(strlen($p[4])==10) {
setlocale (LC_TIME, "it_IT");
$ora = date("H:i",$p[4]);
$giorno = strftime ("%d %B %G",$p[4]);
$data = $giorno.' - '.$ora;
}
echo '<div style="margin-top:10px; border:1px solid #3c3c3c;">
<div style="padding:3px; color: '.$cn[$stile].'; border: '.$bn[$stile].'; background-color:'.$bgn[$stile].';"> '.$nome.'<span style=" font: '.$card[$stile].'; color: '.$cd[$stile].';">'.$email.$t.'<a target="_blank" style="color:'.$clink.'" href="http://'.$web.'">'.$web.'</a>
<span style="position:absolute; right:20px;">'.$data.'</span></span></div>';
echo '<div style="padding:3px; margin-top:1px; padding:5px; color: '.$cm[$stile].'; background-color:'.$bgm[$stile].';">'.$messaggio.'</div>
</div>';
}
$cc=count($msgg);
echo '<p> </p><span style="float:left">'.$cc.' commenti</span>';
if (count($msgg)>$v && $_GET['mode']!='view'){
echo "<p align='right'><a href=\"Javascript:void(0)\" onclick=\"javascript:window.open('".$folder."commenti.php?f=".$f."&s=".$s."&mode=view','','resizable=yes,scrollbars=yes,width=600,height=700')\">[Visualizza tutti i messaggi]</a></p>";}
echo '<p> </p>';
# FORM
if ($_GET['mode']!='view'){
echo '
<script type="text/javascript" src="'.$folder.'check.js">
</script>
<form method="POST" name="comments" onSubmit="return check(this)" action="">
<p>Nome *
<p><input name="nome" size="30" maxlength="20">
<p>Email '; if($vemail==1){echo '(pubblica)';} else echo '(non pubblica)';
echo '<p><input name="email" size="30" ></p>
<p>Sito web - (senza http://)
<p><input na me="web" size="30" >
<p>Messaggio *
<p><textarea rows="9" cols="90" name="messaggio"></textarea></p>';
echo '<img src="'.$folder.'captcha.php" style="position:relative; top:10px; border:1px solid black;" alt="Captcha"> <input maxlength="5" size="5" name="userdigit" type="text"> <input type="submit" value="Commenta">
</form>';}
echo "</div>";
?>
View:
Codice HTML:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<title>WorldTech - Portali</title>
<style type="text/css">
a {
color: #000000;
}
a:visited {
color: #000000;
}
a:hover {
color: #FFFFFF;
}
.style18 {
font-family: Arial, Helvetica, sans-serif;
font-size: small;
}
.style28 {
font-family: Arial, Helvetica, sans-serif;
font-size: small;
border-top-style: none;
border-top-width: medium;
}
.style29 {
border-left-width: 0px;
border-right-width: 0px;
}
.style60 {
font-family: Arial, Helvetica, sans-serif;
font-size: medium;
border-top-style: none;
border-top-width: medium;
}
.style62 {
background-image: url('../../Immagini/up.gif');
}
.style63 {
text-align: center;
}
.style64 {
text-align: center;
background-image: url('../../Immagini/base_up.jpg');
}
</style>
</head>
<body style="background-image: url('../../Immagini/sfondo.gif'); background-attachment: fixed;">
<table style="width: 100%">
<tr>
<td><?
include("../../header1.php");
?>
</td>
</tr>
<tr>
<td class="style60">
<table style="width: 100%" class="style62">
<tr>
<td class="style63"><a href="../../index.php">
<img id="img32" alt="WorldTech.it" height="20" src="../../Immagini/button31.gif" style="border: 0" width="100" /><!-- MSComment="ibutton" fp-style="fp-btn: Simple Text 4; fp-font: Arial, Helvetica, sans-serif; fp-font-style: Bold; fp-font-size: 11; fp-font-color-normal: #FFFFFF; fp-img-hover: 0; fp-img-press: 0; fp-preload: 0; fp-transparent: 1" fp-title="WorldTech.it" --></a></td>
<td class="style63"><a href="../index.php">
<img id="img27" alt="Portali" height="20" src="../../Immagini/button32.gif" style="border: 0" width="100" /><!-- MSComment="ibutton" fp-style="fp-btn: Simple Text 4; fp-font: Arial, Helvetica, sans-serif; fp-font-style: Bold; fp-font-size: 11; fp-font-color-normal: #FFFFFF; fp-img-hover: 0; fp-img-press: 0; fp-preload: 0; fp-transparent: 1" fp-title="Portali" --></a></td>
<td class="style63"><a href="../../programmi/index.php">
<img id="img28" alt="Programmi" height="20" src="../../Immagini/button33.gif" style="border: 0" width="100" /><!-- MSComment="ibutton" fp-style="fp-btn: Simple Text 4; fp-font: Arial, Helvetica, sans-serif; fp-font-style: Bold; fp-font-size: 11; fp-font-color-normal: #FFFFFF; fp-img-hover: 0; fp-img-press: 0; fp-preload: 0; fp-transparent: 1" fp-title="Programmi" --></a></td>
<td class="style63"><a href="../../speciale/index.php">
<img id="img29" alt="Primo Piano" height="20" src="../../Immagini/button34.gif" style="border: 0" width="100" /><!-- MSComment="ibutton" fp-style="fp-btn: Simple Text 4; fp-font: Arial, Helvetica, sans-serif; fp-font-style: Bold; fp-font-size: 11; fp-font-color-normal: #FFFFFF; fp-img-hover: 0; fp-img-press: 0; fp-preload: 0; fp-transparent: 1" fp-title="Primo Piano" --></a></td>
<td class="style63"><a href="../../forum/forum.php">
<img id="img30" alt="Forum" height="20" src="../../Immagini/button35.gif" style="border: 0" width="100" /><!-- MSComment="ibutton" fp-style="fp-btn: Simple Text 4; fp-font: Arial, Helvetica, sans-serif; fp-font-style: Bold; fp-font-size: 11; fp-font-color-normal: #FFFFFF; fp-img-hover: 0; fp-img-press: 0; fp-preload: 0; fp-transparent: 1" fp-title="Forum" --></a></td>
<td class="style63">
<img id="img31" alt="Cerca" height="20" src="../../Immagini/button36.gif" style="border: 0" width="100" /><!-- MSComment="ibutton" fp-style="fp-btn: Simple Text 4; fp-font: Arial, Helvetica, sans-serif; fp-font-style: Bold; fp-font-size: 11; fp-font-color-normal: #FFFFFF; fp-img-hover: 0; fp-img-press: 0; fp-preload: 0; fp-transparent: 1" fp-title="Cerca" --></td>
</tr>
</table>
</td>
</tr>
<tr>
<td class="style64">
<br />
<img alt="" height="50" src="../../Immagini/portali.gif" width="400" /><br />
<br />
</td>
</tr>
</table>
<table align="center" style="width: 100%; height: 100%" class="style29">
<tr>
<td class="style28" colspan="2"> </td>
</tr>
<tr>
<td class="style28"><? include("top_foot.inc.php");
include("config.inc.php");
top();
$db = mysql_connect($db_host, $db_user, $db_password);
$id=$_GET['id'];
if ($db == FALSE)
die ("Errore nella connessione. Verificare i parametri nel file config.inc.php");
mysql_select_db($db_name, $db)
or die ("Errore nella selezione del database. Verificare i parametri nel file config.inc.php");
$query = "SELECT titolo, testo, data, autore, mail, categoria FROM $sezione WHERE id='$id'";
$result = mysql_query($query, $db);
$row = mysql_fetch_array($result);
$data = date("j/n/y", $row[data]);
echo "<b>$row[titolo]</b><br><br>";
echo "$row[testo]<br><br>";
$categorie = array("", "OS", "Software", "iPod-iPhone", "Prodotti", "News");
if ($row[mail] != "")
echo "$data, <a href=mailto:$row[mail]>$row[autore]</a><br>";
else
echo "$data, $row[autore]<br>";
echo "<br><a href=\"index.php\">Torna alla pagina iniziale</a><br>";
echo "<br>".$categorie[$row['categoria']]."<br>";
mysql_close($db);
foot();
?> </td>
<td class="style28" style="width: 20%"> </td>
</tr>
<tr>
<td class="style18" colspan="2"> </td>
</tr>
<tr>
<td class="style18" colspan="2"><?php
$f="$row[titolo]";
$s="2";
include "../../admin/commenti/commenti.php";
?>
</td>
</tr>
<tr>
<td style="height: 50px" class="style18" colspan="2"> </td>
</tr>
<tr>
<td colspan="2"><?
include("../../footer.php");
?>
</td>
</tr>
</table>
</body>
</html>
Top_foot.inc:
Codice PHP:
<? function top() { ?>
<html>
<head>
<meta>
</head>
<body>
<? }
function foot() { ?>
</body>
</html>
<? } ?>
Config.inc:
Codice PHP:
<?
// parametri del database
$db_host = "****";
$db_user = "****";
$db_name = "****";
$db_password = "****";
//password per inserimento articoli
$password = "****";
//nome sezione
$sezione = "****"
?>
Grazie per l'aiuto che mi state dando