Form Help

TOPIC:

Job offer: Attachement sent as single zip file secured with a default password. 3 weeks 14 hours ago #242703

  • Topic Author
  • trins123
  • Offline
  • Fresh Breezer
  • Fresh Breezer
  • Posts: 12
  • Thanks: 0
Hi,

We are using quick mode form and form is sending emails on select list value and files are then deleted from the server. No user data is stored on the server.

We need to have form uploaded files sent as single encrypted zip attachement secured with a default password.

I see in php 7.2 this can be done with ZipArchive::setEncryptionName but I dont know how to do it.

Is this possible and how much would that custom work cost?

Is 100€ enough for this job?

We are using Joomla 3.9 and Brezzing forms pro 1.9, php 7.2

Best regards,

Rok

Please Log in or Create an account to join the conversation.

Job offer: Attachement sent as single zip file secured with a default password. 3 weeks 13 hours ago #242705

  • TheMuffinMan's Avatar
  • TheMuffinMan
  • Offline
  • Developer
  • Developer
  • Posts: 9069
  • Karma: 167
  • Thanks: 737
Hi,

is it always the same file? If yes you could simply encrypt it using your zip program and use the attach file option in the email field's advanced tab (full server path to the file).

If not OR you are sending your emails with an end submit piece, there might be a little code addition that you can use. I think we should be able to provide that if you post your existing pieces code.

Regards,
Markus

Please Log in or Create an account to join the conversation.

Job offer: Attachement sent as single zip file secured with a default password. 2 weeks 6 days ago #242733

  • Topic Author
  • trins123
  • Offline
  • Fresh Breezer
  • Fresh Breezer
  • Posts: 12
  • Thanks: 0
Hi Marcus, thank you for your reply.

Users are uploading their sensitive health documents (multiple files) to different doctors department emails and this is what our end submit is:

$this->execPieceByName('ff_InitLib');

//Deletes the uploaded files
$files = glob('media/breezingforms/uploads/*'); // get all file names
foreach($files as $file){ // iterate files
if(is_file($file))
unlink($file); // delete file
}

// here you define the groups
$zdravnik1 = array('xxx@xxx.com', 'xxxy@xxxy.com' );
$zdravnik2 = array('yyy@yyy.com', 'zzz@zzz.com' );

// replace NAME-OF-SELECTION with the name of the select-list (not title)
$selected_group = ff_getSubmit("Oddelek2"); // assuming possible values: zdravnik1, zdravnik2

$mailing_group = array();

// here the selected group will be assigned (assuming group1 and group2 as possible values from the select-list
switch( $selected_group ){
case 'zdravnik1': $mailing_group = $zdravnik1; break;
case 'zdravnik2': $mailing_group = $zdravnik2; break;
}

// ok mailing group is determined, now let's send them a copy of the submission

$fromname = 'xxx'; // Change to your sender's name
$subject = 'yyy'; // Change to your preferred Email subject
$recipient = 'zzz'; // Change to your admin Email address, will be sent to the email given in addition to the group defined above

$body = '';

foreach ($this->maildata as $data) {
$body .= $data[_FF_DATA_TITLE].": ".$data[_FF_DATA_VALUE].nl() . "\r\n";
}

$this->sendMail($from, $fromname, $mailing_group, $subject, $body); // This line actually emails the form.

Please advise how to proceed with this task.

The doctor should get single zip file that they can open with a default password.

I can grant access to backend if needed.

Best regards,

Rok

Please Log in or Create an account to join the conversation.

Job offer: Attachement sent as single zip file secured with a default password. 2 weeks 6 days ago #242734

  • TheMuffinMan's Avatar
  • TheMuffinMan
  • Offline
  • Developer
  • Developer
  • Posts: 9069
  • Karma: 167
  • Thanks: 737
Hi,

so if the file is always the same, you can do it like this in the end, when it sends the email:
// assuming the file resides in the media folder. can be changed of course.
$attachment = JPATH_SITE . '/media/encrypted.zip';

$this->sendMail($from, $fromname, $mailing_group, $subject, $body, $attachment);

If it is not supposed to be the same files but the uploaded ones, then please let me know. I can see at the top of your code you are deleting these files, so I am not sure at this point.

Regards,
Markus

Please Log in or Create an account to join the conversation.

Job offer: Attachement sent as single zip file secured with a default password. 2 weeks 4 days ago #242853

  • Topic Author
  • trins123
  • Offline
  • Fresh Breezer
  • Fresh Breezer
  • Posts: 12
  • Thanks: 0
Hi Marcus,

The idea is that:

1.) Users upload their files like a.jpg, b.pdf, c.docx via form
2.) This files are put in a single password protected files.zip and send to recipient
3.) Doctor recieve files.zip as attachment and open it with some default password
4.) Files a.jpg, b.pdf, c.docx and files.zip are then automatically deleted from the server

I tried above code, but I dont see any changes. Attachment are still sent as a.jpg, and b.pdf

So I guess files need to be the uploaded ones?

Is there any code available to create a .zip password protected file to send this files as attachement?

Files should be deleted after sent as zip, so I am not sure how should our end submit piece look like.

Regards,

Rok

Please Log in or Create an account to join the conversation.

Job offer: Attachement sent as single zip file secured with a default password. 2 weeks 4 days ago #242855

  • TheMuffinMan's Avatar
  • TheMuffinMan
  • Offline
  • Developer
  • Developer
  • Posts: 9069
  • Karma: 167
  • Thanks: 737
Hi,

I attached you an example form. Please try it out by downloading, unzipping and installing it in BF => Configuration => Package Installer.

This form contains file uploads and a couple of other fields.

Upon submission, the files will be zipped with a password and sent to a specified email address.

The code is located in form => advanced => more options => submit pieces => end submit.

Your PHP version must be 7.2 or higher for this to work and the "ZipArchive" class may not been blocked by your hosting company or administrator.

For reference the full end submit code:
$this->execPieceByName('ff_InitLib');

if(class_exists('ZipArchive') && version_compare(PHP_VERSION, '7.2.0', '>=') ) {

    $recipient = 'your@email.com'; // admin recipient email
    $subject = 'New Record';

    $from = ff_getSubmit('email');
    $fromname = ff_getSubmit('name');

    // actual field values
    $attachments = ff_getSubmit('files', FF_ARRAY); // FF_ARRAY for multiple file uploads
    $attachment = ff_getSubmit('onemorefile'); // without FF_ARRAY for single uploads

    $attachments = array_merge($attachments, array($attachment)); // we are merging 2 uploads for demonstration. With a single file, this won't be necessary

    $body = '';

    foreach ($this->maildata as $data) {

        // filtering the uploads
        if( $data[_FF_DATA_NAME] != 'files' && $data[_FF_DATA_NAME] != 'onemorefile' )
        {

            $body .= $data[_FF_DATA_TITLE].": ".$data[_FF_DATA_VALUE].nl() . "\r\n";
        }
    }

    // zipping it all
    if(count($attachments) != 0) {

        $zip_file = JPATH_SITE . '/media/breezingforms/password_protected_' . $this->record_id . '.zip';

        $zip = new ZipArchive();

        if ($zip->open($zip_file, ZipArchive::CREATE) === true) {

            foreach ($attachments As $file) {

                $zip->addFromString(basename($file), file_get_contents($file));
                $zip->setEncryptionName(basename($file), ZipArchive::EM_AES_256, ff_getSubmit('password'));

            }

            $zip->close();

            // deleting the uploaded files
            foreach ($attachments As $file) {

                unlink($file);
            }

            $this->sendMail($from, $fromname, $recipient, $subject, $body, $zip_file);

            // finally deleting the encrypted file
            unlink($zip_file);
        }
    }

}else{

    echo 'Requirements for Zipping not fullfilled.';
    exit;
}

File Attachment:

File Name: encryptzip.zip
File Size:10 KB


Regards,
Markus
Attachments:

Please Log in or Create an account to join the conversation.

Moderators: ForumSupport
Time to create page: 0.049 seconds

July Sale!

Discounts for all of our extensions + support. Ending July 31st!

Get Your Subscription Here

Quick Links

Downloads

BreezingForms

ContentBuilder

BreezingCommerce

Templates

Documentation

BreezingForms

ContentBuilder

BreezingCommerce

Apprendre BreezingForms (French Community)

Apprendre et maîtriser BreezingForms par des tutoriels et exemples, le tout en français

breezingforms.eddy-vh.com

Questions et réponses sur les forums de l'AFUJ

AFUJ

Special Offer

Summer Sale! All subscriptions at a special price!

Includes prio support, all of our current and future Joomla!® extensions and Joomla!® templates for the duration of your membership.

Get it from here

3rd Party Discount - 25% Off

We help you to keep your costs under control. If you are a new member and purchased a form building tool from a different form vendor, then you'll get a 25% discount on our subscription plans.

How to receive the discount:

Send us a quick email to sales@crosstec.org with a proof of purchase (for example a paypal receipt), await payment instructions and enjoy your membership!