E-Mail Notification To Members On Comments - Page 2 E-Mail Notification To Members On Comments - Page 2
 

News:

cpg1.5.48 Security release - upgrade mandatory!
The Coppermine development team is releasing a security update for Coppermine in order to counter a recently discovered vulnerability. It is important that all users who run version cpg1.5.46 or older update to this latest version as soon as possible.
[more]

Main Menu

E-Mail Notification To Members On Comments

Started by peakoverload, June 18, 2004, 11:56:49 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

nanothree


Nibbler

Ah, is this a comment on an anonymously uploaded pic ?

nanothree

#22
it seems to have stopped now, but that would be a problem, would it be possible to stop that error from happening if that was the case?

BTW i have made it possible to turn this feature on and off from the config page

if ($CONFIG['email_user_comment_notification']) {

if (defined('UDB_INTEGRATION')){
$result = db_query("SELECT owner_id  FROM {$CONFIG['TABLE_PICTURES']} WHERE pid=".$pid);
list($uid) = mysql_fetch_row($result);
$picture_owner_data = udb_get_user_infos($uid);
} else {
// send an email to the owner of the picture
$result = db_query("SELECT user_name,user_email FROM {$CONFIG['TABLE_PICTURES']} AS p, {$CONFIG['TABLE_USERS']} AS u WHERE u.user_id=p.owner_id and p.pid=".$pid);
$picture_owner_data = mysql_fetch_array($result);
}
$subject = "New GJPix Comment by ".USER_NAME;
$mail_body  = "Hi ".$picture_owner_data['user_name']."!\n\n".USER_NAME." just wrote a comment on one of your photos, click the link below to read and reply to it.\n";
$mail_body .= "http://gallery.greatestjournal.com/displayimage.php?pos=-".$pid;
cpg_mail($picture_owner_data['user_email'], $subject, $mail_body, 'text/plain', "GJPix", 'dontreply@yourdomain.com');

}


then you need to add a new row to the config table, you can use this sql query:

INSERT INTO `cpg11d_config` ( `name` , `value` )
VALUES (
'email_user_comment_notification', 1
)


change cpg11d to what your table prefix is

and finally find, in lang/englsih.php
  array('Notify admin of comments by email', 'email_comment_notification', 1), //cpg1.3.0

and after it add
array('Allow users to recieve email when comments are posted', 'email_user_comment_notification', 1),

from this it should be very easy to add a check for user approval, but i am yet to implement this

protox

#23
I've tryed this mod .. but I don't receive any mail ... and I don't understand why this doesn't work because the code seems to be working ...

Here is the code :

** EDIT :: ok; it's working .. I'm a poor stupid lame .. sorry :-X ;D **
Latest shot from " Les disséqueurs de société " :

(https://coppermine-gallery.com/forum/proxy.php?request=http%3A%2F%2Fx-poz.org%2Fcpmfetch%2Fcfimageget.php%3Fcmd%3Dlast&hash=6c9ccde658006a5ed432bbbd56630302b3cb9b7d)

Chrigi

hi there

i've made this for my gallery (brigded for phpBB) but it doesn't work. i means, i've changed the code, and it works fine to add an comment, but i recieve no mail.
is there anything wrong in the DB query, if yes, can anybody make for me such an query for the phpBB?

greetz and thx
chrigi


Chrigi

hi Nibbler,

thank tou you for the answer,  i've tried it, but nothing works.
this is a piece of the code, starting at "//comment"
    // Comment

    case 'comment':
        if (!(USER_CAN_POST_COMMENTS)) cpg_die(ERROR, $lang_errors['perm_denied'], __FILE__, __LINE__);

        check_comment($HTTP_POST_VARS['msg_body']);
                check_comment($HTTP_POST_VARS['msg_author']);
        $msg_author = addslashes(trim($HTTP_POST_VARS['msg_author']));
        $msg_body = addslashes(trim($HTTP_POST_VARS['msg_body']));
        $pid = (int)$HTTP_POST_VARS['pid'];

        if ($msg_author == '' || $msg_body == '') cpg_die(ERROR, $lang_db_input_php['empty_name_or_com'], __FILE__, __LINE__);

        $result = db_query("SELECT comments FROM {$CONFIG['TABLE_PICTURES']}, {$CONFIG['TABLE_ALBUMS']} WHERE {$CONFIG['TABLE_PICTURES']}.aid = {$CONFIG['TABLE_ALBUMS']}.aid AND pid='$pid'");
        if (!mysql_num_rows($result)) cpg_die(ERROR, $lang_errors['non_exist_ap'], __FILE__, __LINE__);
        $album_data = mysql_fetch_array($result);
        mysql_free_result($result);

        if ($album_data['comments'] != 'YES') cpg_die(ERROR, $lang_errors['perm_denied'], __FILE__, __LINE__);

        if (!$CONFIG['disable_comment_flood_protect']){
          $result = db_query("SELECT author_md5_id, author_id FROM {$CONFIG['TABLE_COMMENTS']} WHERE pid = '$pid' ORDER BY msg_id DESC LIMIT 1");
          if (mysql_num_rows($result)) {
              $last_com_data = mysql_fetch_array($result);
              if ((USER_ID && $last_com_data['author_id'] == USER_ID) || (!USER_ID && $last_com_data['author_md5_id'] == $USER['ID'])) {
                  cpg_die(ERROR, $lang_db_input_php['no_flood'], __FILE__, __LINE__);
              }
          }
        }

        if (!USER_ID) { // Anonymous users, we need to use META refresh to save the cookie
            $insert = db_query("INSERT INTO {$CONFIG['TABLE_COMMENTS']} (pid, msg_author, msg_body, msg_date, author_md5_id, author_id, msg_raw_ip, msg_hdr_ip) VALUES ('$pid', '$msg_author', '$msg_body', NOW(), '{$USER['ID']}', '0', '$raw_ip', '$hdr_ip')");
            $USER['name'] = $HTTP_POST_VARS['msg_author'];
            $redirect = "displayimage.php?pos=" . (- $pid);
           if ($CONFIG['email_comment_notification']) {
            $mail_body = $msg_body . "\n\r ".$lang_db_input_php['email_comment_body'] . " " . $CONFIG['ecards_more_pic_target'] . $redirect;
cpg_mail($CONFIG['gallery_admin_email'], $lang_db_input_php['email_comment_subject'], $mail_body);

if (defined('UDB_INTEGRATION')){
$result = db_query("SELECT owner_id  FROM {$CONFIG['TABLE_PICTURES']} WHERE pid=".$pid);
list($uid) = mysql_fetch_row($result);
$picture_owner_data = udb_get_user_infos($uid);
} else {
// send an email to the owner of the picture
$result = db_query("SELECT user_name,user_email FROM {$CONFIG['TABLE_PICTURES']} AS p, {$CONFIG['TABLE_USERS']} AS u WHERE u.user_id=p.owner_id and p.pid=".$pid);
$picture_owner_data = mysql_fetch_array($result);
}
$subject = "New GJPix Comment by ".USER_NAME;
$mail_body  = "Hi ".$picture_owner_data['user_name']."!\n\n".USER_NAME." just wrote a comment on one of your photos, click the link below to read and reply to it.\n";
$mail_body .= "http://gallery.greatestjournal.com/displayimage.php?pos=-".$pid;
cpg_mail($picture_owner_data['user_email'], $subject, $mail_body, 'text/plain', "GJPix", 'webmaster@snaplife.ch');


            }

            pageheader($lang_db_input_php['com_added'], "<META http-equiv=\"refresh\" content=\"1;url=$redirect\">");
            msg_box($lang_db_input_php['info'], $lang_db_input_php['com_added'], $lang_continue, $redirect);
            pagefooter();
            ob_end_flush();
            exit;
        } else { // Registered users, we can use Location to redirect
            $insert = db_query("INSERT INTO {$CONFIG['TABLE_COMMENTS']} (pid, msg_author, msg_body, msg_date, author_md5_id, author_id, msg_raw_ip, msg_hdr_ip) VALUES ('$pid', '" . addslashes(USER_NAME) . "', '$msg_body', NOW(), '', '" . USER_ID . "', '$raw_ip', '$hdr_ip')");
            $redirect = "displayimage.php?pos=" . (- $pid);
            if ($CONFIG['email_comment_notification']) {

                $mail_body = $msg_body . "\n\r ".$lang_db_input_php['email_comment_body'] . " " . $CONFIG['ecards_more_pic_target'] . $redirect;
                cpg_mail($CONFIG['gallery_admin_email'], $lang_db_input_php['email_comment_subject'], $mail_body);
            }
         $header_location = (@preg_match('/Microsoft|WebSTAR|Xitami/', getenv('SERVER_SOFTWARE'))) ? 'Refresh: 0; URL=' : 'Location: ';
            header($header_location . $redirect);
            pageheader($lang_db_input_php['com_added'], "<META http-equiv=\"refresh\" content=\"1;url=$redirect\">");
            msg_box($lang_db_input_php['info'], $lang_db_input_php['com_added'], $lang_continue, $redirect);
            pagefooter();
            ob_end_flush();
            exit;
        }
        break;


Can you please tell me, where I make the fault?

greetz n thx
chrigi

Nibbler

Wrong place, put it after the other

if ($CONFIG['email_comment_notification']) {

Chrigi

ough

I felt a bit sheepish about it.
but now it works, thanks a lot  :D ;D

greetz
chrigi

Rallemann

Quote from: nanothree on April 10, 2005, 03:47:04 PM
then you need to add a new row to the config table, you can use this sql query:

INSERT INTO `cpg11d_config` ( `name` , `value` )
VALUES (
'email_user_comment_notification', 1
)


change cpg11d to what your table prefix is


Which file do I have to edit?
I can't find a similar code in config.php
In which line the text has to been added?

thanks for support =)

Nibbler

You need to run the query on your database using phpmyadmin or similar.

blobnl

Hi i followed the instruction but i do not recieve any email.. (as admin i will receive the comment emails)
Here is my code can anyone tell me if this is ok ?
   // Comment

   case 'comment':
       if (!(USER_CAN_POST_COMMENTS)) cpg_die(ERROR, $lang_errors['perm_denied'], __FILE__, __LINE__);

       check_comment($HTTP_POST_VARS['msg_body']);
       $msg_author = addslashes(trim($HTTP_POST_VARS['msg_author']));
       $msg_body = addslashes(trim($HTTP_POST_VARS['msg_body']));
       $pid = (int)$HTTP_POST_VARS['pid'];

       if ($msg_author == '' || $msg_body == '') cpg_die(ERROR, $lang_db_input_php['empty_name_or_com'], __FILE__, __LINE__);

       $result = db_query("SELECT comments FROM {$CONFIG['TABLE_PICTURES']}, {$CONFIG['TABLE_ALBUMS']} WHERE {$CONFIG['TABLE_PICTURES']}.aid = {$CONFIG['TABLE_ALBUMS']}.aid AND pid='$pid'");
       


       //MATEJ DOPESNU
       if ($pid == 0) {
       } else {
          if (!mysql_num_rows($result)) cpg_die(ERROR, $lang_errors['non_exist_ap'], __FILE__, __LINE__);
       }
       //-------------
       $album_data = mysql_fetch_array($result);
       mysql_free_result($result);
       
//MATEJ DOPESNU
       if ($pid == 0) {
       } else {
          if ($album_data['comments'] != 'YES') cpg_die(ERROR, $lang_errors['perm_denied'], __FILE__, __LINE__);
       }        
       //-------------
       

       if (!$CONFIG['disable_comment_flood_protect']){
         $result = db_query("SELECT author_md5_id, author_id FROM {$CONFIG['TABLE_COMMENTS']} WHERE pid = '$pid' ORDER BY msg_id DESC LIMIT 1");
         if (mysql_num_rows($result)) {
             $last_com_data = mysql_fetch_array($result);
             if ((USER_ID && $last_com_data['author_id'] == USER_ID) || (!USER_ID && $last_com_data['author_md5_id'] == $USER['ID'])) {
                 cpg_die(ERROR, $lang_db_input_php['no_flood'], __FILE__, __LINE__);
             }
         }
       }

       if (!USER_ID) { // Anonymous users, we need to use META refresh to save the cookie
           $insert = db_query("INSERT INTO {$CONFIG['TABLE_COMMENTS']} (pid, msg_author, msg_body, msg_date, author_md5_id, author_id, msg_raw_ip, msg_hdr_ip) VALUES ('$pid', '$msg_author', '$msg_body', NOW(), '{$USER['ID']}', '0', '$raw_ip', '$hdr_ip')");
           $USER['name'] = $HTTP_POST_VARS['msg_author'];
           //MATEJ DOPESNU
           if ($pid == 0) {
         $redirect = "index.php";
           } else {
             $redirect = "displayimage.php?pos=" . (- $pid);        
           }
           //-------------
           if ($CONFIG['email_comment_notification']) {
               $mail_body = $msg_body . "\n\r ".$lang_db_input_php['email_comment_body']." http://" . $_SERVER["SERVER_NAME"] . "/" . $redirect;
               cpg_mail($CONFIG['gallery_admin_email'], $lang_db_input_php['email_comment_subject'], $mail_body);
           }
           pageheader($lang_db_input_php['com_added'], "<META http-equiv=\"refresh\" content=\"1;url=$redirect\">");
           msg_box($lang_db_input_php['info'], $lang_db_input_php['com_added'], $lang_continue, $redirect);
           pagefooter();
           ob_end_flush();
           exit;
       } else { // Registered users, we can use Location to redirect
           $insert = db_query("INSERT INTO {$CONFIG['TABLE_COMMENTS']} (pid, msg_author, msg_body, msg_date, author_md5_id, author_id, msg_raw_ip, msg_hdr_ip) VALUES ('$pid', '" . addslashes(USER_NAME) . "', '$msg_body', NOW(), '', '" . USER_ID . "', '$raw_ip', '$hdr_ip')");
           //MATEJ DOPESNU
           if ($pid == 0) {
         $redirect = "index.php";
           } else {
             $redirect = "displayimage.php?pos=" . (- $pid);        
           }
           //-------------
           if ($CONFIG['email_comment_notification']) {
               $mail_body = $msg_body . "\n\r ".$lang_db_input_php['email_comment_body']." http://" . $_SERVER["SERVER_NAME"] . "/" . $redirect;
               cpg_mail($CONFIG['gallery_admin_email'], $lang_db_input_php['email_comment_subject'], $mail_body);
           }
           $header_location = (@preg_match('/Microsoft|WebSTAR|Xitami/', getenv('SERVER_SOFTWARE'))) ? 'Refresh: 0; URL=' : 'Location: ';
           header($header_location . $redirect);
           pageheader($lang_db_input_php['com_added'], "<META http-equiv=\"refresh\" content=\"1;url=$redirect\">");
           msg_box($lang_db_input_php['info'], $lang_db_input_php['com_added'], $lang_continue, $redirect);
           pagefooter();
           ob_end_flush();
           exit;
       }
if ($CONFIG['email_user_comment_notification']) {

if (defined('UDB_INTEGRATION')){
$result = db_query("SELECT owner_id  FROM {$CONFIG['TABLE_PICTURES']} WHERE pid=".$pid);
list($uid) = mysql_fetch_row($result);
$picture_owner_data = udb_get_user_infos($uid);
} else {
// send an email to the owner of the picture
$result = db_query("SELECT user_name,user_email FROM {$CONFIG['TABLE_PICTURES']} AS p, {$CONFIG['TABLE_USERS']} AS u WHERE u.user_id=p.owner_id and p.pid=".$pid);
$picture_owner_data = mysql_fetch_array($result);
}
$subject = "New GJPix Comment by ".USER_NAME;
$mail_body  = "Hi ".$picture_owner_data['user_name']."!\n\n".USER_NAME." just wrote a comment on one of your photos, click the link below to read and reply to it.\n";
$mail_body .= "http://gallery.greatestjournal.com/displayimage.php?pos=-".$pid;
cpg_mail($picture_owner_data['user_email'], $subject, $mail_body, 'text/plain', "GJPix", 'dontreply@yourdomain.com');

}
       break;

   // Update album
(https://coppermine-gallery.com/forum/proxy.php?request=http%3A%2F%2F82.156.219.246%2Ffotoforum%2Fpic.jpg&hash=b1875bd30c51c96623f1876fccaa05f24adacb24)

chupa2k

I have a question , Will this work with IPB 1.3 bridge ??? this is just what i need .

AWJunkies

Edited to work with 1.4.3 stand alone as well as E-mail link becomes clickable now. THIS IS FOR NON BRIDGED VERSIONS the UDB blah balh wasnt working because 1.4.3 doesn't have the function called opon to grab photo infos. If someone wants it for bridged version as well I will find the new function for the same thing if needed.

db_input.php
FIND:
if ($CONFIG['email_comment_notification'] && !USER_IS_ADMIN ) {
ADD BEFORE:

if ($CONFIG['email_user_comment_notification']) {

// send an email to the owner of the picture
$result = cpg_db_query("SELECT user_name,user_email FROM {$CONFIG['TABLE_PICTURES']} AS p, {$CONFIG['TABLE_USERS']} AS u WHERE u.user_id=p.owner_id and p.pid=".$pid);
$picture_owner_data = mysql_fetch_array($result);
$subject = "New GJPix Comment by ".USER_NAME;
$mail_body  = "Hi ".$picture_owner_data['user_name']."!\n\n".USER_NAME." just wrote a comment on one of your photos, click the link below to read and reply to it.\n";
$mail_body .= "http://gallery.greatestjournal.com/displayimage.php?pos=-".$pid;
cpg_mail($picture_owner_data['user_email'], $subject, make_clickable($mail_body), 'text/plain', "GJPix", 'dontreply@yourdomain.com');
}

DONT FORGET TO CHANGE $mail_body url to yours as well as $subject and as well cpg_mail info.


then you need to add a new row to the config table, you can use this sql query:

INSERT INTO `cpg143_config` ( `name` , `value` )
VALUES (
'email_user_comment_notification', 1
)


and finally find, in lang/englsih.php
  array('Notify admin of comments by email', 'email_comment_

and after it add
array('Allow users to recieve email when comments are posted', 'email_user_comment_notification', 1),

fcarentz

A search would have revealed a working version of this script that i did back in December.

http://forum.coppermine-gallery.net/index.php?topic=25675.0

Go there and follow the instructions it will support a bridge and your users can set the option to be mailed or not. And it will only mail them once until they view the comments so they don't get spammed with Comment emails.

Hope this helps you.

angeldevil

hi to you,
i tried your code but didn't work for me. i have coppermine version 1.4.4
is there any edit that i might write on your script?
help me, please!
a

cosmoweb

For coppermine 1.4.18, that's all right?  ::)

Joachim Müller

Should work for all versions of the cpg1.4.x series.