Control add_comment
P0WER
Joined: 2002-10-11
Posts: 2 |
Posted: Fri, 2002-10-11 05:44 |
hi I modify the code to be able to control new the comment which is recorded on the page add_comment.php Be careful !! you must have mail() fonction actived on php configuration /* existing code */ <? if (strcmp($gallery->album->fields["public_comments"], "yes")) { if (!strcmp($submit, "Save")) { $texte = stripslashes($comment_text); /*mail for post control of comment in gallery*/ $date = date("d/m/Y"); $contenu=$sujet."rn"; Summary of seized information: Name : $commenter_name Enregistrement effectué le $date à $temps[hours]h$temps[minutes]m mail("commentaire-gallery@domaine.com", $sujet, $contenu, $headers); /* end modification */ $comment_text = removeTags($comment_text); ..... continuation of the page ... If you want bloked some IP, on the first line of code you can write : if ( $REMOTE_ADDR == "193.252.194.83" ) { echo " sorry, it's impossible" ; die; } Have a good day David <!-- BBCode Start --><A HREF="http://null" TARGET="_blank">null</A><!-- BBCode End --><!-- BBCode Start --><A HREF="http://www.annecyrandoroller.fr.fm" TARGET="_blank">null</A><!-- BBCode End --> |
|
Posts: 2
I had a few probs as it was written
I modified the code as such below (with english translation)
<!-- BBCode Start --><TABLE BORDER=0 ALIGN=CENTER WIDTH=85%><TR><TD><font class="pn-sub">Code:</font><HR></TD></TR><TR><TD><FONT class="pn-sub"><PRE>
<?
// Hack prevention.
if (!empty($HTTP_GET_VARS["GALLERY_BASEDIR"]) ||
!empty($HTTP_POST_VARS["GALLERY_BASEDIR"]) ||
!empty($HTTP_COOKIE_VARS["GALLERY_BASEDIR"])) {
print "Security violation
";
exit;
}
?>
<? require($GALLERY_BASEDIR . "init.php"); ?>
<?
// Hack check
if (strcmp($gallery->album->fields["public_comments"], "yes")) {
exit;
}
$error_text = "";
if (!strcmp($submit, "Save")) {
if ($commenter_name && $comment_text) {
$text = stripslashes($comment_text);
$text_url = urlencode($text);
/*mail for post control of comment in gallery*/
$email_admin="you@yourdomain.com";
$email_postmaster="you@yourdomain.com";
$headers="Return-Path: ".$email_postmaster."
";
$headers.="From: ".$email_admin."
";
$subject="Comment added by ".$commenter_name." to the gallery";
$date = date("d/m/Y");
$time = time("B / D d / j-m-Y / H:i:s");
$temps = getdate($time);
$dns = gethostbyaddr($REMOTE_ADDR);
$contents="
Summary of comment information:
Name : $commenter_name
IpNumber : $IPNumber
Comment : $text
Photo :
http://www.YOURDOMAIN.com/gallery/search.php?searchstring=$text_url
Recording carried out $date at $temps[hours]h$temps[minutes]m
by $REMOTE_ADDR
$dns with $HTTP_USER_AGENT ";
mail("you@yourdomain.com", $subject, $contents, $headers);
$comment_text = removeTags($comment_text);
$commenter_name = removeTags($commenter_name);
$gallery->album->addComment($index, stripslashes($comment_text), $IPNumber, $commenter_name);
$gallery->album->save();
dismissAndReload();
return;
} else {
$error_text = "Name and Comment are both required to save a new comment!";
}
}
?>
</TD></TR></TABLE><!-- BBCode End -->
Posts: 2
Hello,
Sorry for my english, but i'm french
thank for the modification in the script, but I think the probleme can be fonction of magic_quote on your server.
Now, 2 news challenge :smile:
How find the photo without use the page shearch.php ? or how deleted a comment by a link on the mail ? :smile
good night
Posts: 23
$photolocation=$gallery->album->getPhotoPath($index, $full)
as suggested by Beckett, will give you url of the photo as it sits in the albums directory. But that's no good, because you see only the picture file, and not the rest of the gallery appended stuff like comments, fwd/back, etc. I'm trying to figure out a way to strip the url and then add it to a hardcoded url (ie gallery/+filename instead of albums/filename), but I think there's an easier way to do it. Have to search through more of the files in teh classes directory.
Posts: 3474
Okay. I think :wink: I see what you're getting at.
Wouldn't you be able to generate the link... thus: (? :roll: )
We'd have somewhere near the top:
$id = $gallery->album->getPhotoId($index);
$myURL = makeAlbumUrl($albumName, $id);
Then in the text of the e-mail we'd have:
" ........ Photo : $myURL ....... "
Can someone try that out to see if I'm barking up the right tree?
As for a link from the e-mail to automatically delete? Hmm... not securely. You have to be logged in to be able to delete a comment... And you can't log in via the URL. You could do it insecurely by not authenticating... but then anyone could erase the comment if they knew the right URL. Hmm. Lemme think on that a bit.
-Beckett (
)
Posts: 23
This didn't work out of the box, and I couldn't find the function code for makeAlbumUrl. But I looked through some other files and decided to preface the $albumName argument with gallery->session-> so I get this, it seemed reasonable:
$id = $gallery->album->getPhotoId($index);
$myURL = makeAlbumUrl($gallery->session->albumName, $id);
...and surprisingly it worked! Thanks Beckett!
Posts: 70
I am getting the following error
Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at /home/mydamnpa/public_html/pics/add_comment.php:41) in /home/mydamnpa/public_html/pics/session.php on line 51
Enter your comment for this picture in the text box below.
After adding:
<?
// Hack prevention.
if (!empty($HTTP_GET_VARS["GALLERY_BASEDIR"]) ||
!empty($HTTP_POST_VARS["GALLERY_BASEDIR"]) ||
!empty($HTTP_COOKIE_VARS["GALLERY_BASEDIR"])) {
print "Security violation
";
exit;
}
?>
<? require($GALLERY_BASEDIR . "init.php"); ?>
<?
// Hack check
if (strcmp($gallery->album->fields["public_comments"], "yes")) {
exit;
}
$error_text = "";
if (!strcmp($submit, "Save")) {
if ($commenter_name && $comment_text) {
$text = stripslashes($comment_text);
$text_url = urlencode($text);
/*mail for post control of comment in gallery*/
$email_admin="admin@mydamnpage.com";
$email_postmaster="admin@mydamnpage.com";
$headers="Return-Path: ".$email_postmaster."
";
$headers.="From: ".$email_admin."
";
$subject="Comment added by ".$commenter_name." to the gallery";
$date = date("d/m/Y");
$time = time("B / D d / j-m-Y / H:i:s");
$temps = getdate($time);
$dns = gethostbyaddr($REMOTE_ADDR);
$contents="
Summary of comment information:
Name : $commenter_name
IpNumber : $IPNumber
Comment : $text
Photo :
http://www.mydamnpage.com/pics/search.php?searchstring=$text_url
Recording carried out $date at $temps[hours]h$temps[minutes]m
by $REMOTE_ADDR
$dns with $HTTP_USER_AGENT ";
mail("admin@mydamnpage.com", $subject, $contents, $headers);
$comment_text = removeTags($comment_text);
$commenter_name = removeTags($commenter_name);
$gallery->album->addComment($index, stripslashes($comment_text), $IPNumber, $commenter_name);
$gallery->album->save();
dismissAndReload();
return;
} else {
$error_text = "Name and Comment are both required to save a new comment!";
}
}
?>
Anyone have any ideas?
Posts: 70
Nevermind i fixed it