Advanced search  

News:

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

Pages: [1]   Go Down

Author Topic: Contact from option - copy to self  (Read 4976 times)

0 Members and 1 Guest are viewing this topic.

twoclones

  • Coppermine newbie
  • Offline Offline
  • Posts: 15
Contact from option - copy to self
« on: January 26, 2014, 06:05:09 am »

On the Contact Form, how can I have an option for "send yourself a copy" ?  There doesn't appear to be an option for this in the Config.
Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15386
Re: Contact from option - copy to self
« Reply #1 on: January 27, 2014, 12:02:51 pm »

Such an option doesn't exist, as such a feature currently doesn't exist. However, this could be added as a mod. I've currently no time to create this mod immediately. Please reply to this thread, so I can highlight it in my inbox and will create the mod later.

IMHO that feature should go to core.
Logged

twoclones

  • Coppermine newbie
  • Offline Offline
  • Posts: 15
Re: Contact from option - copy to self
« Reply #2 on: January 27, 2014, 07:30:23 pm »

Thank you.  It would be great to have this option :)
Logged

gmc

  • Dev Team member
  • Coppermine addict
  • ****
  • Country: us
  • Offline Offline
  • Gender: Male
  • Posts: 723
    • GMC Design Photo Gallery
Re: Contact from option - copy to self
« Reply #3 on: January 27, 2014, 08:25:37 pm »

I think that is a great idea too...

Αndré,
Attached is a zipped patch file based on SVN 8660 that implements this feature for your review...
As there is a change (one line addition) to language file - I assumed you would want a hidden config option in 1.5.x... and build into 1.6.

Summary:
Insert a record into cpg_config with name 'contact_form_cc_sender_field' and value '1' to enable support
If this option is set... AND (either a registered user OR guest and displaying email field to guest)
 - then an option will be displayed on contact.php to allow user to select 'Send me a copy of contact email'...
   (otherwise we have no way to get an email to cc to...)
On submit, if a valid email is provided (registered user may not have email... guest email may be optional), and new config option is set
 - a CC will be added to the email using the sender email provided (in form or from registered user data).

Updated:
contact.php:  form additions and processing data on submit
include/mailer.inc.php: updated function cpg_mail to receive and process $cc_sender using the AddCC function of the cpg_PHPMailer class.
lang/english.php: add text for label on form for new field

Logged
Thanks!
Greg
My Coppermine Gallery
Need a web hosting account? See my gallery for an offer for CPG Forum users.
Send me money

gmc

  • Dev Team member
  • Coppermine addict
  • ****
  • Country: us
  • Offline Offline
  • Gender: Male
  • Posts: 723
    • GMC Design Photo Gallery
Re: Contact from option - copy to self
« Reply #4 on: January 27, 2014, 09:13:56 pm »

For those not familiar with or using SVN, the following changes were proposed:
Based on 1.5.26+...

In contact.php:
Find:
Code: [Select]
     $email_address = $superCage->post->getEscaped('sender_email');
INSERT after:
Code: [Select]
     $cc_sender = ($superCage->post->keyExists('cc_sender')) ? $superCage->post->getInt('cc_sender') : FALSE;           //*GMC added support to CC sender

Find **ALL OCCURRENCES** of :  (there will be 4... only 3 are needed, but changing all 4 doesn't hurt... (the first case is caught by form processing)
Code: [Select]
             $sender_email = $CONFIG['gallery_admin_email'];INSERT after EACH:
Code: [Select]
             $cc_sender = FALSE;                                                 //*GMC no valid sender email - turn off CC if set

Find:
Code: [Select]
         if (!cpg_mail($CONFIG['gallery_admin_email'], $subject, $html_message, 'text/html', $sender_name, $sender_email, $message)) {
REPLACE with:
Code: [Select]
+        if (!cpg_mail($CONFIG['gallery_admin_email'], $subject, $html_message, 'text/html', $sender_name, $sender_email, $message, $cc_sender)) {  //*GMC added cc_sender as parm

Find:
Code: [Select]
        <td class="tableb">
            <span id="email_wrapper" class="{$highlightFieldCSS}">
                <input type="text" class="textinput" name="sender_email" size="30" maxlength="200" value="{$email_address}" style="width:100%" />
            </span>
        </td>
        <td class="tableb">
            <span id="email_remark" style="display:{$email_remark_visibility}">{$lang_contact_php['email_field_mandatory']}</span>
        </td>
    </tr>
EOT;
}
INSERT after:
Code: [Select]
//*GMC added cc field based on ('hidden' for 1.5) config option 'contact_form_cc_sender_field' - and if we have an emailid (USER_ID or $CONFIG['contact_form_guest_email_field']
if ((USER_ID || $CONFIG['contact_form_guest_email_field'] != 0) && $CONFIG['contact_form_cc_sender_field']) {

    print <<< EOT
    <tr>
        <td class="tableb" align="right">
            {$lang_contact_php['cc_me']}
        </td>
        <td class="tableb">
            <span id="cc_wrapper">
                <input type="checkbox" class="checkbox" name="cc_sender" value="1" />
            </span>
        </td>
        <td class="tableb">
        </td>
    </tr>
EOT;
}
//*GMC end modifications for cc field
 

In include/mailer.inc.php:
Find:
Code: [Select]
function cpg_mail($to, $subject, $msg_body = '', $type = 'text/plain', $sender_name = '', $sender_email = '', $msg_body_plaintext = '')
 {
     global $CONFIG, $lang_charset, $HTML_SUBST;
REPLACE with:
Code: [Select]
function cpg_mail($to, $subject, $msg_body = '', $type = 'text/plain', $sender_name = '', $sender_email = '', $msg_body_plaintext = '', $cc_sender = FALSE)
 {
     global $CONFIG, $lang_charset, $HTML_SUBST;
    //*GMC Added $cc_sender as optional parm - FALSE by default - if TRUE, add sender_email as CC recipient.
    //*GMC - used in contact.php if chosen by user and valid sender email provided.

In include/mailer.inc.php:
Find:
Code: [Select]
    foreach ($to as $email) {
        $mail->AddAddress($email);
    }
INSERT after:
Code: [Select]

    if ($cc_sender) {                                                           //*GMC add CC to sender if requested
        $mail->AddCC($sender_email);;
    }                                                                                //*GMC - end additions

In lang/english.php: (or language file of your choice with appropriate translations...)
Find:
Code: [Select]
$lang_contact_php['your_email'] = 'Your email address'; // cpg1.5
INSERT after:
Code: [Select]
$lang_contact_php['cc_me'] = 'Send me a copy of contact email'; // cpg1.5 //*GMC added support to cc sender

Via phpMyAdmin or equivalent (substituting cpg table prefix for cpg_):
Code: [Select]
INSERT INTO `cpg_config` (`name`, `value`) VALUES ('contact_form_cc_sender_field', '1');
deleting the above name/value - or setting value to 0 disables the support.

and now you see why I used a patch file that makes the updates for me... :)
Logged
Thanks!
Greg
My Coppermine Gallery
Need a web hosting account? See my gallery for an offer for CPG Forum users.
Send me money

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15386
Re: Contact from option - copy to self
« Reply #5 on: January 28, 2014, 09:51:32 am »

I'll review your patch soon. Adding it as hidden feature to cpg1.5.x and new config option to cpg1.6.x was exactly what I had in mind ;)
Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15386
Re: Contact from option - copy to self
« Reply #6 on: January 30, 2014, 12:25:10 pm »

I re-considered about that feature while I came across
Code: [Select]
$CONFIG['contact_form_guest_email_field']
If we display that option for guests, spammers could easily use the contact form to send spam via a Coppermine gallery. Even if we enable it just for registered users, we cannot say without fail if the email address entered during the registration really belongs to the user, as the admin has the choice if he wants his users to validate the email address during registration. I introduced a database column "user_email_valid" in cpg1.5.10, which is the only way to determine without fail if an email address is valid, and it won't work in bridged galleries. This results in a situation that the option isn't displayed for all users for sure or at all.

For that reason I don't want to add this feature to the core code.

Of course it could be implemented as plugin. We could use captcha_contact_print to display the option and probably another existing hook like page_start to send the email (instead of using the Cc option, just send a separate email). If not, we need to add a new plugin hook. To make this clear, I've no interest in creating such a plugin, but am ready to help to find/create the plugin needed hook(s).
Logged

gmc

  • Dev Team member
  • Coppermine addict
  • ****
  • Country: us
  • Offline Offline
  • Gender: Male
  • Posts: 723
    • GMC Design Photo Gallery
Re: Re: Contact from option - copy to self
« Reply #7 on: January 30, 2014, 01:35:01 pm »

If we display that option for guests, spammers could easily use the contact form to send spam via a Coppermine gallery. Even if we enable it just for registered users, we cannot say without fail if the email address entered during the registration really belongs to the user, as the admin has the choice if he wants his users to validate the email address during registration. I introduced a database column "user_email_valid" in cpg1.5.10, which is the only way to determine without fail if an email address is valid, and it won't work in bridged galleries. This results in a situation that the option isn't displayed for all users for sure or at all.
Leave it to spammers to ruin a perfectly good idea... sigh... You are right of course - any valid email entered by a guest would be used - and most certainly result in spam... I know I've had many registrations from spammers - I happen to force validation so they never get activated (but I didn't check that in the sample provided)... (I've now either turned off registrations or added a master password so they have to ask me first (or auto register members in the background..) Got tired of cleaning out the garbage...)

Quote
Of course it could be implemented as plugin. We could use captcha_contact_print to display the option and probably another existing hook like page_start to send the email (instead of using the Cc option, just send a separate email). If not, we need to add a new plugin hook. To make this clear, I've no interest in creating such a plugin, but am ready to help to find/create the plugin needed hook(s).
If going down the plugin route - two hooks in cpg_mail already: cpg_mail_to_email and cpg_mail_sender_email.
cpg_mail_to_email filters the 'to' array - would be simple to add a recipient here.. at least for a registered verified email (for unbridged...) It will get added to the email To field upon return.
cpg_mail_sender_email filters the sender email... but the mail object hasn't been instantiated yet.

I like the idea from twoclones... but now I'm not seeing a safe way to implement.
Logged
Thanks!
Greg
My Coppermine Gallery
Need a web hosting account? See my gallery for an offer for CPG Forum users.
Send me money
Pages: [1]   Go Up
 

Page created in 0.016 seconds with 20 queries.