<?
// Max entries per page
$maxperpage = "20";
// Allow HTML in guestbook submissions? (0 = No, 1 = Yes)
$allowhtml = "0";
/* --------------- DO NOT EDIT BELOW THIS LINE -------------- */
/* --------------- PRE-CONFIGURED LAYOUTS ----------------- */
$addform = "<FORM ACTION=\"$PHP_SELF?addsubmit=true\" METHOD=\"POST\">\n";
$addform .= "<table border=\"0\" cols=\"2\" width=\"500\">\n";
$addform .= "<tr>\n";
$addform .= "<td width=\"100\">Nome:</td>\n";
$addform .= "<td width=\"400\"><input type=\"text\" name=\"name\"></td>\n";
$addform .= "</tr><tr>\n";
$addform .= "<td width=\"100\">E-Mail:</td>\n";
$addform .= "<td width=\"400\"><input type=\"text\" name=\"email\"></td>\n";
$addform .= "</tr><tr>\n";
$addform .= "<td width=\"100\">Messaggio:</td>\n";
$addform .= "<td width=\"400\"><TEXTAREA name=\"message\" cols=\"50\" rows=\"15\"></TEXTAREA></td>\n";
$addform .= "</tr><tr>\n";
$addform .= "<td width=\"100\"></td>\n";
$addform .= "<td width=\"400\"><input type=\"submit\" value=\"Inserisci\">\n";
$addform .= "</tr></table>\n";
$addform .= "</FORM>\n";
include ("entries.inc");
include ("entrycounter.inc");
IF (!isset($add) and !isset($addsubmit))
{
echo ("<A HREF=\"$PHP_SELF?add=true\">Inserisci un messaggio</a>");
$maxperpage = $maxperpage + 0;
IF (!isset($start))
{
$start = $lastentry;
}
$end = $start - $maxperpage;
$count = $start;
while ($count <= $start and $count > $end and $count > 0)
{
$entryid = "entry" . $count;
echo ("<table border=0 cols=2 width=500>");
IF (isset($$entryid))
{
while (list ($variable, $value) = each($$entryid))
{
IF ($allowhtml == 0)
{
$value = Strip_tags($value);
}
IF ($variable == "E-Mail")
{
echo ("<tr>\n<td width=100>\n
$variable:\n</td>\n<td width=400>\n<A HREF=\"mailto:$value\">$value</a>\n</td>\n</tr>\n");
}
ELSE IF ($variable == "Messaggio")
{
$value = str_replace("\\\"", "\"", $value);
echo ("<tr>\n<td width=100>\n
$variable:\n</td>\n<td width=400>\n$value\n</td>\n</tr>\n");
}
ELSE
{
echo ("<tr>\n<td width=100>\n
$variable:\n</td>\n<td width=400>\n$value\n</td>\n</tr>\n");
}
}
echo ("</table><hr width=100% noshade>");
}
ELSE
{
$end = $end - 1;
}
$count = $count - 1;
}
$entryid = "entry" . $count;
IF ($start != $lastentry)
{
$start = $start + $maxperpage;
echo (" <A HREF=\"$PHP_SELF?start=$start\"><<< Indietro</a>");
echo (" ");
}
IF (isset($$entryid))
{
echo (" ");
echo (" <A HREF=\"$PHP_SELF?start=$count\">Avanti >>></a>");
}
echo ("
<A HREF=\"$PHP_SELF?add=true\">Inserisci un messaggio</a> ");
}
ELSE IF (isset($add))
{
echo ("$addform");
}
ELSE IF (isset($addsubmit))
{
$required = Array (
'Nome' => $name,
'E-Mail' => $email,
'Messaggio' => $message);
while (list($caption, $variable) = each($required))
{
$errorcount = 0;
IF ($variable == "")
{
++$errorcount;
echo ("Il campo obbligatorio
'$caption' è stato lasciato bianco.
");
}
}
IF ($errorcount == 0)
{
$filename = "entrycounter.inc";
$increment = $lastentry + 1;
$incrementoutput = "<? $" . "lastentry = " . $increment . "; ?>";
$write = fopen($filename, "w");
fwrite ($write, $incrementoutput);
fclose($write);
$entryid = "entry" . $increment;
$datetime = date ("l F jS @ g:iA T");
$addentry = "<? $" . $entryid .
" = Array ( " .
"'Nome' => '$name', " .
"'E-Mail' => '$email', " .
"'Postato il' => '$datetime', " .
"'Messaggio' => '$message'); ?>";
$filename2 = "entries.inc";
$write2 = fopen($filename2, "a");
fwrite ($write2, $addentry . "\r\n\r\n");
fclose($write2);
echo ("
Grazie per aver inserito il messaggio.
<A HREF=\"$PHP_SELF\">Clicca qui</a> per vedere tutti i messaggi.");
}
ELSE
{
echo ("
<font color=\"red\">
Devi riempire i campi mancanti</font>");
}
}
?>