Newsgroup: it.comp.www.php
Titolo: Help ! Guestbook in php

Salve a tutti sono Stefano spero che possiate aiutarmi per un piccolo
problema.
Ho un guestbook in php e vorrei che ogni volta che un utente firma il mio
guestbook arrivi una notifica al mio indirizzo email con il testo che ha
scritto l'utente sul guestbook
Attualmente la notifica arriva solo se cliccano sulla voce private
naturalmente scrivono un msg in privato ed arriva regolarmente la notifica
nella mia email con l'ip, client browser, l'ora ecc. ecc..
Quale stringa devo aggiungere ?
Vorrei che lo stesso msg che mandano in privato mi arriva la notifica anche
quando firmano il guestbook naturalmente con le varie info che logga
(ip,client browser,ora ecc.. ecc..) le stesse caratteristiche di un msg che
mandano in private.
Vi riporto qui di seguito tutto lo script con la speranza che qualcuno di
voi sia cosi' cortese da aiutarmi
Chiedendo scusa a tutti voi se sono scortese nel pubblicare l'intero script.
<?php
session_start();
$gb_name = "guestbook di prova"; // Guestbook name
$gb_data = "data.txt"; // File (path not URL) where data stored, chmod 666
$gb_psswd = "123456"; // Admin password
$gb_mail = "
mio_indir...@account.it
"; // Your email, only neaded if
private messages are enabled
include("languages/italian.inc.php");
// Features: true = enabled, false = disabled
$gb_flthtml = true; // Html code filter (recomended: true)
$gb_url2lnk = true; // Convert url:s to links in message
$gb_smiley = true; // Smileys
$gb_fltbdwrd = true; // Badword filter
$gb_privmsg = true; // Privated messages
$gb_fltspam = true; // Spam filter
$gb_msgpg = 5; // Messages per page
$gb_lngwrd = 35; // Max word length
$gb_lngmsg = 250; // Max message length
function flt_tags ($text, $html){
if ($html) {
$text = strip_tags($text);
$text = htmlspecialchars($text);}
$text = ereg_replace("\|", "", $text);
$text = ereg_replace("\r", "", $text);
$text = ereg_replace("\n", "<br> ", $text);
$text = stripslashes($text);
$text = trim($text);
return $text;
}
function flt_bdwrd ($text, $badwords){
foreach ($badwords as $badword){
$text = str_replace ($badword, "***", $text);}
return $text;
}
function flt_smiley ($text){
$text = ereg_replace(" :)", " <img src=\"images/sm01.gif\" width=\"15\"
height=\"15\" alt=\":)\" border=\"0\">", $text);
$text = ereg_replace(" :D", " <img src=\"images/sm02.gif\" width=\"15\"
height=\"15\" alt=\":D\" border=\"0\">", $text);
$text = ereg_replace(" 8)", " <img src=\"images/sm03.gif\" width=\"15\"
height=\"15\" alt=\"8)\" border=\"0\">", $text);
$text = ereg_replace(" ;)", " <img src=\"images/sm04.gif\" width=\"15\"
height=\"15\" alt=\";)\" border=\"0\">", $text);
$text = ereg_replace(" :P", " <img src=\"images/sm05.gif\" width=\"15\"
height=\"15\" alt=\":P\" border=\"0\">", $text);
$text = ereg_replace(" :o", " <img src=\"images/sm06.gif\" width=\"15\"
height=\"15\" alt=\":o\" border=\"0\">", $text);
$text = ereg_replace(" :\(", " <img src=\"images/sm07.gif\" width=\"15\"
height=\"15\" alt=\":(\" border=\"0\">", $text);
return $text;
}
function test_lngwrd ($text, $lng){
$test = explode(" ", $text);
foreach ($test as $word){
if (strlen($word) > $lng){$tmp = true;}}
if ($tmp){return $tmp;}
}
function test_lngmsg ($text, $lng){
if (strlen($text) > $lng){$tmp = true;}
if ($tmp){return $tmp;}
}
function test_email($email){
if
(eregi("^([a-z]|[0-9]|\.|-|_)+@([a-z]|[0-9]|\.|-|_)+\.([a-z]|[0-9]){2,3}$",
$email, $arr_vars) &&
!eregi("(@.*@)|(\.\.)|(@\.)|(\.@)|(^\.)", $email, $arr_vars)){
return true;}
else {return false;}
}
############################################################
# Main code
if($action == "msgnew"){
if ($spam && $gb_fltspam){$msg_txt = $lgerr[4]; $msg_cap = $lgerr[0];
$id="message";} else {
if($name & $message){
$name = flt_tags ($name,1);
$email = flt_tags ($email,1);
$page = flt_tags ($page,1);
$message = flt_tags ($message,$gb_flthtml);
$index = date("YmdHis",time());
$day = date("d.m.Y",time());
$time = date("H:i",time());
if (test_lngwrd($message,$gb_lngwrd)){$msg_txt = $lgerr[1]; $msg_cap =
$lgerr[0]; $id="message";}
elseif (test_lngmsg($message,$gb_lngmsg)){$msg_txt = $lgerr[2]; $msg_cap =
$lgerr[0]; $id="message";}
elseif ($private) {
$mail_msg =
"---------------------------------------------------------------\n".
"The folowning information was submitted on\n".
"$day $time\n".
"---------------------------------------------------------------\n".
"Name: $name\n".
"Email: $email\n".
"URL: $page\n".
"Message: $message.\n".
"---------------------------------------------------------------\n".
"Remote host: $REMOTE_HOST \n".
"Remote address: $REMOTE_ADDR \n".
"User Agent: $HTTP_USER_AGENT \n".
"---------------------------------------------------------------\n";
mail($gb_mail, "Private guestbook message", $mail_msg, "From: $name
<$email>");
$msg_txt = $lgpri[1]; $msg_cap = $lgpri[0]; $id="message";
session_register("spam");
$spam = true;
}
else {
$data = fopen($gb_data, "a");
fwrite($data,
"$index|$day|$time|$REMOTE_ADDR|$HTTP_USER_AGENT|$name|$email|$page|$message
|||\r\n");
fclose($data);
session_register("spam");
$spam = true;
}
}
else{$msg_txt = $lgerr[3]; $msg_cap = $lgerr[0]; $id = "message";}
}
}
if($action == "logon"){
if ($password == $gb_psswd){
session_register("psswd");
$psswd = $password;
}
else {$msg_txt = $lgerr[5]; $msg_cap = $lgerr[0]; $id="message";}
}
if($msgdelete || $msgdelete == "0" ){
if ($psswd == $gb_psswd){
$data = file($gb_data);
rsort ($data);
unset($data[$msgdelete]);
$fp = fopen($gb_data,"w");
foreach ($data as $row){fputs($fp, $row);}
fclose($fp);
}
else{$msg_txt = $lgerr[6]; $msg_cap = $lgerr[0]; $id="message";}
}
if($msgedit || $msgedit == "0" ){
if ($psswd == $gb_psswd){
$id = "edit";
}
else{$msg_txt = $lgerr[7]; $msg_cap = $lgerr[0]; $id="message";}
}
if($msgreplace){
if ($psswd == $gb_psswd){
$data = file($gb_data);
rsort ($data);
$message = flt_tags ($message,$gb_flthtml);
$comment = flt_tags ($comment,0);
$data[$num] =
"$index|$day|$time|$ip|$browser|$name|$email|$page|$message|$comment|0\r\n";
$fp = fopen($gb_data,"w");
foreach ($data as $row){fputs($fp, $row);}
fclose($fp);
}
else{$msg_txt = $lgerr[6]; $msg_cap = $lgerr[0]; $id="message";}
}
############################################################
# HTML code
?>
<html>
<head>
<title><?php print("$gb_name $lgtxt[0]");?></title>
<?php print("$metatag");?>
<style type="text/css">
<!--
a { text-decoration: none}
.fontnorm { font-family: Verdana, Arial, Helvetica, sans-serif; font-size:
12px}
.fontmini { font-family: Verdana, Arial, Helvetica, sans-serif; font-size:
10px}
-->
</style>
<SCRIPT language="JavaScript" type="text/javascript">
<!--
function setsmiley(which){
document.newmessage.message.value = document.newmessage.message.value +
which;
}
//-->
</SCRIPT>
</head>
<body bgcolor="#FFFFFF" text="#000000" link="#333333" vlink="#333333"
alink="#333333">
<table width="500" border="0" cellspacing="0" cellpadding="2"
align="center">
<tr><td bgcolor="#333333">
<table width="100%" border="0" cellspacing="1" cellpadding="1"
bgcolor="#FFFFFF">
<tr><td bgcolor="#EEEEEE">
<span class="fontnorm">&nbsp;<b><?php print("$gb_name");?></b></span><br>
<span class="fontmini">&nbsp;<?php print("$gb_name $lgtxt[0]");?></span>
</td></tr><tr><td bgcolor="#DDDDDD" class="fontmini">&nbsp;&raquo;
<a href="<?php print("$PHP_SELF");?>"><?php print("$lgtxt[1]");?></a> |
<a href="<?php print("$PHP_SELF?id=new");?>"><?php print("$lgtxt[2]");?></a>
|
<a href="<?php print("$PHP_SELF?id=admin");?>"><?php
print("$lgtxt[3]");?></a>
</td></tr></table>
</td></tr>
</table>
<table width="500" border="0" cellspacing="1" cellpadding="0"
align="center">
<tr><td class="fontmini"><?php
$data = file($gb_data);
$maxmsg = count($data);
print ("$lgtxt[6]: $maxmsg");
?></td><td align="right" class="fontmini">
<?php
rsort ($data);
If(!$pg){$pg=0;}
If($pg==0){print("<font color=\"#DDDDDD\">&laquo; $lgtxt[4]</font>");}
else{$tmp = $pg -1; print("<a href=\"$PHP_SELF?pg=$tmp\">&laquo;
$lgtxt[4]</a>");}
$tmp = $pg * $gb_msgpg + $gb_msgpg; print(" | ");
if ($maxmsg > $tmp){$tmp = $pg + 1; print ("<a
href=\"$PHP_SELF?pg=$tmp\">$lgtxt[5] &raquo;</a>");}
else {print("<font color=\"#DDDDDD\">$lgtxt[5] &raquo;</font>");}
?>
</td></tr>
</table>
<table width="500" border="0" cellspacing="0" cellpadding="2"
align="center">
<tr><td bgcolor="#333333">
<?php
############################################################
# Error message
if ($id=="message"){?>
<table width="100%" border="0" cellspacing="1" cellpadding="1"
bgcolor="#FFFFFF">
<tr><td bgcolor="#DDDDDD" colspan="2" align="center"
class="fontnorm"><b><?php print($msg_cap);?></b></td></tr>
<tr><td bgcolor="#EEEEEE" colspan="2" align="center"
class="fontnorm"><p><br><?php print($msg_txt);?><br><br></p></td></tr>
</table>
<?php }
############################################################
# Admin logon
elseif ($id=="admin"){?>
<table width="100%" border="0" cellspacing="1" cellpadding="1"
bgcolor="#FFFFFF">
<tr><td bgcolor="#DDDDDD" colspan="2" align="center"
class="fontnorm"><b><?php print($lgtxt[20]);?></b></td></tr>
<tr><td bgcolor="#EEEEEE" colspan="2" align="center"
class="fontnorm"><p><?php print($lgtxt[21]);?><br>
<form method="post" action="<?php print $PHP_SELF ?>">
<input type="text" name="password">
<input name="action" type="hidden" value="logon">
<input type="submit" name="Submit" value="<?php print($lgtxt[22]);?>">
</form>
<br></p></td></tr>
</table>
<?php }
############################################################
# Edit entry
elseif ($id=="edit"){
$data = file($gb_data);
rsort ($data);
$info = explode("|",$data[$msgedit]);
?>
<table width="100%" border="0" cellspacing="1" cellpadding="1"
bgcolor="#FFFFFF">
<form method="post" action="<?php print $PHP_SELF ?>">
<tr><td bgcolor="#DDDDDD" colspan="2" align="center"
class="fontnorm"><b><?php print("$lgtxt[29]");?></b></td></tr>
<tr><td bgcolor="#EEEEEE" width="130" align="right" class="fontnorm"><?php
print("$lgtxt[25]");?> :</td>
<td bgcolor="#EEEEEE" width="363"><input type="text" name="day" size="40"
value="<?php print("$info[1]"); ?>"></td></tr>
<tr><td bgcolor="#EEEEEE" width="130" align="right" class="fontnorm"><?php
print("$lgtxt[26]");?> :</td>
<td bgcolor="#EEEEEE" width="363"><input type="text" name="time" size="40"
value="<?php print("$info[2]"); ?>"></td></tr>
<tr><td bgcolor="#EEEEEE" width="130" align="right" class="fontnorm"><?php
print("$lgtxt[27]");?> :</td>
<td bgcolor="#EEEEEE" width="363"><input type="text" name="ip" size="40"
value="<?php print("$info[3]"); ?>"></td></tr>
<tr><td bgcolor="#EEEEEE" width="130" align="right" class="fontnorm"><?php
print("$lgtxt[28]");?> :</td>
<td bgcolor="#EEEEEE" width="363"><input type="text" name="browser"
size="40" value="<?php print("$info[4]"); ?>"></td></tr>
<tr><td bgcolor="#EEEEEE" width="130" align="right" class="fontnorm"><?php
print("$lgtxt[8]");?> :</td>
<td bgcolor="#EEEEEE" width="363"><input type="text" name="name" size="40"
value="<?php print("$info[5]"); ?>"></td></tr>
<tr><td bgcolor="#EEEEEE" width="130" align="right" class="fontnorm"><?php
print("$lgtxt[9]");?> :</td>
<td bgcolor="#EEEEEE" width="363"><input type="text" name="email" size="40"
value="<?php print("$info[6]"); ?>"></td></tr>
<tr><td bgcolor="#EEEEEE" width="130" align="right" class="fontnorm"><?php
print("$lgtxt[10]");?> :</td>
<td bgcolor="#EEEEEE" width="363"><input type="text" name="page" size="40"
value="<?php print("$info[7]"); ?>"></td></tr>
<tr><td bgcolor="#EEEEEE" width="130" align="right" class="fontnorm"><?php
print("$lgtxt[11]");?> :</td>
<td bgcolor="#EEEEEE" width="363"><textarea name="message" cols="40"
rows="5"><?php print("$info[8]"); ?></textarea></td></tr>
<tr><td bgcolor="#EEEEEE" width="130" align="right" class="fontnorm"><?php
print("$lgtxt[30]");?> :</td>
<td bgcolor="#EEEEEE" width="363"><textarea name="comment" cols="40"
rows="5"><?php print("$info[9]"); ?></textarea></td></tr>
<tr><td bgcolor="#EEEEEE" width="130"><input type="hidden" name="index"
value="<?php print("$info[0]"); ?>">
<input type="hidden" name="num" value="<?php print("$msgedit"); ?>"></td>
<td bgcolor="#EEEEEE" width="363"><input type="submit" name="msgreplace"
value="<?php print("$lgtxt[14]");?>"></td></tr>
</form>
</table>
<?php }
############################################################
# Add entry
elseif ($id=="new"){?>
<table width="100%" border="0" cellspacing="1" cellpadding="1"
bgcolor="#FFFFFF">
<form name="newmessage" method="post" action="<?php print $PHP_SELF ?>">
<tr><td bgcolor="#DDDDDD" colspan="2" align="center"
class="fontnorm"><b><?php print("$lgtxt[7]");?></b></td></tr>
<tr><td bgcolor="#EEEEEE" width="130" align="right" class="fontnorm"><?php
print("$lgtxt[8]");?> :</td>
<td bgcolor="#EEEEEE" width="363"><input type="text" name="name"
maxlength="30" size="40"></td></tr>
<tr><td bgcolor="#EEEEEE" width="130" align="right" class="fontnorm"><?php
print("$lgtxt[9]");?> :</td>
<td bgcolor="#EEEEEE" width="363"><input type="text" name="email"
maxlength="40" size="40"></td></tr>
<tr><td bgcolor="#EEEEEE" width="130" align="right" class="fontnorm"><?php
print("$lgtxt[10]");?> :</td>
<td bgcolor="#EEEEEE" width="363"><input type="text" name="page"
maxlength="40" value="http://" size="40"></td></tr>
<tr><td bgcolor="#EEEEEE" width="130" align="right" class="fontnorm"><?php
print("$lgtxt[11]");?> :</td>
<td bgcolor="#EEEEEE" width="363" class="fontnorm"><textarea name="message"
cols="40" rows="5"></textarea>
<?php if ($gb_privmsg){?><br><input type="checkbox" name="private"
value="true"> <?php print("$lgtxt[12]");?><?php }?></td></tr>
<?php if ($gb_smiley){?>
<tr><td bgcolor="#EEEEEE" width="130">&nbsp;</td>
<td bgcolor="#EEEEEE" width="363">
<A HREF="javascript:setsmiley(' :)')" ONFOCUS="filter:blur()"><img
src="images/sm01.gif" width="15" height="15" alt=":)" border="0"></a>
<A HREF="javascript:setsmiley(' :D')" ONFOCUS="filter:blur()"><img
src="images/sm02.gif" width="15" height="15" alt=":D" border="0"></a>
<A HREF="javascript:setsmiley(' 8)')" ONFOCUS="filter:blur()"><img
src="images/sm03.gif" width="15" height="15" alt="8)" border="0"></a>
<A HREF="javascript:setsmiley(' ;)')" ONFOCUS="filter:blur()"><img
src="images/sm04.gif" width="15" height="15" alt=";)" border="0"></a>
<A HREF="javascript:setsmiley(' :P')" ONFOCUS="filter:blur()"><img
src="images/sm05.gif" width="15" height="15" alt=":P" border="0"></a>
<A HREF="javascript:setsmiley(' :o')" ONFOCUS="filter:blur()"><img
src="images/sm06.gif" width="15" height="15" alt=":o" border="0"></a>
<A HREF="javascript:setsmiley(' :(')" ONFOCUS="filter:blur()"><img
src="images/sm07.gif" width="15" height="15" alt=":(" border="0"></a>
</td></tr>
<?php }?>
<tr><td bgcolor="#EEEEEE" width="130">&nbsp;</td>
<td bgcolor="#EEEEEE" width="363">
<input name="action" type="hidden" value="msgnew">
<input type="reset" name="reset" value="<?php print("$lgtxt[13]");?>">
<input type="submit" name="Submit" value="<?php print("$lgtxt[14]");?>">
</td></tr>
</form>
</table>
<?php }
############################################################
# Show gbook
else {?>
<table width="100%" border="0" cellspacing="1" cellpadding="1"
bgcolor="#FFFFFF">
<tr><td bgcolor="#DDDDDD" width="130" align="center"
class="fontnorm"><b><?php print("$lgtxt[8]");?>:</b></td>
<td bgcolor="#DDDDDD" width="363" align="center" class="fontnorm"><b><?php
print("$lgtxt[11]");?>:</b></td></tr>
<?php
$frstmsg = $pg * $gb_msgpg;
$lastmsg = $pg * $gb_msgpg + $gb_msgpg;
if ($lastmsg > $maxmsg){$lastmsg=$maxmsg;}
for ($u=$frstmsg; $u<$lastmsg; $u++)
{
$entry = explode("|",$data[$u]);
if ($gb_flthtml) {$entry[8] = strip_tags($entry[8]);}
if ($gb_fltbdwrd) {$entry[8] = flt_bdwrd($entry[8],$lgbdwrd);}
if ($gb_url2lnk) {$entry[8] =
ereg_replace("[[:alpha:]]+://[^<>[:space:]]+[[:alnum:]/]", "<a href=\"\\0\"
target=\"_blank\">\\0</a>", $entry[8]);}
if ($gb_smiley){$entry[8] = flt_smiley ($entry[8]);}
?>
<tr>
<td bgcolor="#EEEEEE" width="130" align="center" class="fontnorm">
<?php print("$entry[5]");?><p>
<img src="images/g_ip.gif" width="16" height="16" alt="<?php if ($psswd ==
$gb_psswd){print("IP: $entry[3]");} else {print("IP: $lgtxt[15]");} ?>">
<img src="images/g_br.gif" width="16" height="16" alt="<?php print("OS:
$entry[4]"); ?>">
<?php if ($entry[6]){?><a href="mailto:<?php print("$entry[6]"); ?>"><img
src="images/g_em.gif" width="16" height="16" alt="<?php print("$entry[6]");
?>" border="0"></a><?php }
else {?><img src="images/g_em.gif" width="16" height="16" alt="<?php
print("$lgtxt[17]"); ?>" border="0"><?php }
if ($entry[7] and $entry[7] != "http://"){?><a href="<?php
print("$entry[7]"); ?>" target="_blank"><img src="images/g_hm.gif"
width="16" height="16" alt="<?php print("$entry[7]"); ?>"
border="0"></a><?php }
else {?><img src="images/g_hm.gif" width="16" height="16" alt="<?php
print("$lgtxt[18]"); ?>" border="0"><?php }
?>
</p>
</td>
<td bgcolor="#EEEEEE" width="363">
<span class="fontmini"><?php print("$lgtxt[16] $entry[1] $entry[2]"); if
($psswd == $gb_psswd){?>
[ <a href="<?php print("$PHP_SELF?msgdelete=$u"); ?>"><?php
print("$lgtxt[23]"); ?></a> | <a href="<?php print("$PHP_SELF?msgedit=$u");
?>"><?php print("$lgtxt[24]"); ?></a> ]
<?php }?>
</span>
<hr noshade size="1">
<span class="fontnorm"><?php print("$entry[8]"); if($entry[9]){
print("<p><i>- $entry[9]</i></p>");}?></span>
</td>
</tr>
<?php }?>
</table>
<?php }
############################################################
?>
</td></tr>
</table>
<table width="500" border="0" cellspacing="0" cellpadding="0"
align="center">
<tr>
<td class="fontmini" width="50%">Powered by <a
href="
http://www.account-mio.com
">guestbook di prova</a></td>
<td class="fontmini" width="50%" align="right">
<?php If ($gb_flthtml) print($lgtxt[51]); else print($lgtxt[50]); ?>
</td>
</tr>
</table>
</body>
</html>

la prossima volta  metti : "Lungo"  nel titolo cosi eviti di essere scannato
da qualcuno meno di buon umore di me oggi (as esempio, io il 90% dei giorni)
.....
;-)
Ciao
Federico

 ha scritto nel messaggio
news:ENffc.2541$Qc.9...@twister1.libero.it...


dai,che ho messo anche la faccina simpaticaaaaaa
;-)
perdonato x stavolta !!
:-D
Ciao
Federico

Grazie di cuore so che siete tutti simpatici non avevo dubbi perdonatemi è
la prima volta che frequento questo news

 perdonatemi h la prima volta che frequento questo news
Sei un newbie? Leggi questo 
http://url.repository.biz/go/3C
-- 
I am what I am, I do what I can
L'uomo, conscio di sbagliare, persevera.