Got any code I can put in place ro make this possible? This would be similar to a phpBB mod I have where I get notified by email when a new post is created so I can admin my forums effectively.
I would just hate for someone to post a bunch of nasty, vulgar comments and me not notice it for months. )
Thanks!!
|
|||

Re:Send email to Admin when comment is posted?
Thanks! Works Great!
Merry Christmas!
Chris
Re:Send email to Admin when comment is posted?
OK, now I understand
mail($comment_email,'New comment for photoalbum ' . $title,'photo ' . $_REQUEST['comment_showimage'] . chr(10) . chr(10) . 'comment ' . substr(trim(stripslashes($_REQUEST['newcomment'])),0,250) . chr(10) . chr(10) . 'Link http//' . $_SERVER['HTTP_HOST'] . $HTTP_SERVER_VARS['SCRIPT_NAME'] . '?showimage=' . rawurlencode($_REQUEST['showimage']) . '&screenwidth=' . $_REQUEST['screenwidth'],'From ' . $comment_email . "\r\n" . 'Reply-To ' . $comment_email . "\r\n" . 'X-Mailer PHP/' . phpversion());Re:Send email to Admin when comment is posted?
Yeah, ok... But I thought about another thing
I want, that for every new comment I would receive an email with a link to the picture with the new comment, so I can see to which picture the comment is related
(like "http//www.domain.com/albumname/index.php?showimage=DSCN0001.JPG&screenwidth=1024")
The only thing, that I'm still needing is the value for the "albumname" ("$albumname isn't the right value, unfortunatly sick ...). The rest I've already solved, and it's looking like this
. $home_page . >>>albumname<<< . '/index.php?showimage=' . $_REQUEST['comment_showimage'] . '&screenwidth=' . $_REQUEST['screenwidth'] .Chris
Re:Send email to Admin when comment is posted?
it should be something like this
mail($shop_email,'New comment!','Comment for photoalbum ' . $title . chr(10) . ' photo ' . $_REQUEST['comment_showimage'] . chr(10) . trim(stripslashes($_REQUEST['newcomment'])),'From ' . $shop_email . "\r\n" . 'Reply-To ' . $shop_email . "\r\n" . 'X-Mailer PHP/' . phpversion());
Re:Send email to Admin when comment is posted?
Great idea!
But it would be nice, if you would also get a link to the affected picture.
I've tried to solve this, but I don't know, which variables I have to use for the "albumname", the "showimage" and the "screenwidth" part.
mail($shop_email,'New comment!','Picture ' . $home_page . chr(47) . $albumname . chr(47) . $albumname . chr(47) . 'index' . chr(46) . 'php' . chr(63) . 'showimage' . chr(61) . $showimage . chr(38) . 'screenwidth' . chr(61) . $screenwidth . chr(10) . chr(10) . 'Written by ' . $username . chr(10) . chr(10) . trim(stripslashes($_REQUEST['newcomment'])) . chr(10) . chr(10) ,'From ' . $shop_email . "\r\n" . 'Reply-To ' . $shop_email . "\r\n" . 'X-Mailer PHP/' . phpversion());Re:Send email to Admin when comment is posted?
Sorry, I read so literally into your "add the following code twice" that I failed to realize/see that it was 2 seperate areas in that section. Up and running perfectly now, thanks!
Re:Send email to Admin when comment is posted?
It should be something like this
if (is_dir('textfiles')) {If it doesn't work your email settings in PHP might be wrong...if ($fp=fopen('textfiles/'.substr($_REQUEST['comment_showimage'],0,strrpos($_REQUEST['comment_showimage'],'.')).'.txt','ab')) {
fwrite($fp,'[ '.date("d/M/Y Hi"«»).' - '.$_SERVER['REMOTE_ADDR'].' - ' . $username . ' ]' . "\n"«»);
fwrite($fp,trim(stripslashes($_REQUEST['newcomment'])) . "\n". "\n"«»);
fclose($fp);
mail($shop_email,'New comment!','Comment for photoalbum ' . $title . chr(10) . chr(10) . trim(stripslashes($_REQUEST['newcomment'])),'From ' . $shop_email . "\r\n" . 'Reply-To ' . $shop_email . "\r\n" . 'X-Mailer PHP/' . phpversion());
}
} else {
if ($fp=fopen(substr($_REQUEST['comment_showimage'],0,strrpos($_REQUEST['comment_showimage'],'.')).'.txt','ab')) {
fwrite($fp,'[ '.date("d/M/Y Hi"«»).' - '.$_SERVER['REMOTE_ADDR'].' - ' . $username . ' ]' . "\n"«»);
fwrite($fp,trim(stripslashes($_REQUEST['newcomment'])) . "\n". "\n"«»);
fclose($fp);
mail($shop_email,'New comment!','Comment for photoalbum ' . $title . chr(10) . chr(10) . trim(stripslashes($_REQUEST['newcomment'])),'From ' . $shop_email . "\r\n" . 'Reply-To ' . $shop_email . "\r\n" . 'X-Mailer PHP/' . phpversion());
}
}
Re:Send email to Admin when comment is posted?
Thanks, although I tried it and couldnt get it to work. Make sure I followed you right.
fwrite($fp,trim(stripslashes($_REQUEST['newcomment'])) . "\n". "\n"«»);
fclose($fp);
mail($shop_email,'New comment!!','Comment for photoalbum ' . $title . ' photo ' . $_REQUEST['comment_showimage'] . chr(10) . chr(10) . trim(stripslashes($_REQUEST['newcomment'])),'From ' . $shop_email . "\r\n" . 'Reply-To ' . $shop_email . "\r\n" . 'X-Mailer PHP/' . phpversion());
mail($shop_email,'New comment!!','Comment for photoalbum ' . $title . ' photo ' . $_REQUEST['comment_showimage'] . chr(10) . chr(10) . trim(stripslashes($_REQUEST['newcomment'])),'From ' . $shop_email . "\r\n" . 'Reply-To ' . $shop_email . "\r\n" . 'X-Mailer PHP/' . phpversion());
}
}
}
}
}
Re:Send email to Admin when comment is posted?
Thats a good idea!
Find the section called '// Save visitor comment with photo' and add the following code twice after the lines 'fclose($fp);'
mail($shop_email,'New comment!!','Comment for photoalbum ' . $title . ' photo ' . $_REQUEST['comment_showimage'] . chr(10) . chr(10) . trim(stripslashes($_REQUEST['newcomment'])),'From ' . $shop_email . "\r\n" . 'Reply-To ' . $shop_email . "\r\n" . 'X-Mailer PHP/' . phpversion());It will send the email to the same email address as for the shop system.