restezconnectes / send-pdf-for-contact-form-7

Send the PDF for Contact Form 7 plugin will allow you to recover the data yourself via your form to insert them into a PDF built and prepared by you.
https://restezconnectes.fr/tutoriel-wordpress-lextension-send-pdf-for-contact-form-7/
GNU General Public License v3.0
15 stars 17 forks source link

Temp Directory Not Writable #8

Closed TryndaEAdair closed 4 years ago

TryndaEAdair commented 4 years ago

There is no way to easily modify the path for the temp directory mpdf uses. This can cause issues in test and production servers where the host has locked down write access to all but the uploads folders for security purposes.

A temporary solution is to update the mpdf instances in the send to pdf classes/views (send-pdf.php & send-pdf-admin.php) and include the temp url directory argument, but this can be overwritten by an update from the WordPress repository.

A long term solution would be to include a settings area where the temp argument can be set as an option in the wp_options table or default directory to one in the uploads folder which is always has writable permissions.

temporary solution / wp_option Example: ` // Change this to option saved in DB $custom_tmp_path = '/wp-content/uploads/send-to-pdf-contact-form-7/tmp';

// Add tempDir argument with option variable to all mpdf constructors. $mpdf = new \Mpdf\Mpdf(['tempDir' => $custom_tmp_path, 'mode' => 'utf-8', 'format' => $formatPdf, 'margin_header' => 10, 'margin_top' => 40,]); `

restezconnectes commented 4 years ago

Hi!

Can you see the last version. I adding the TMP folder.

Thanks

TryndaEAdair commented 4 years ago

Hi :D

Thank you for looking into this issue. I tried installing the update and on setting save I get a 502 Bag Gateway Error. Looking at the code in send-pdf-7.php class, it looks like the mpdf object still needs the argument (see screenshot from my code modification) [image: image.png]

You'd just need to change the variable to use the option created, something like: $custom_tmp_path = get_option('wpcf7pdf_path_temp'');

Hope this helps, love the plugin to far, very handy!

On Wed, Jul 8, 2020 at 8:20 AM Restez Connectés notifications@github.com wrote:

Hi!

Can you see the last version. I adding the TMP folder.

Thanks

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/Florent73/send-pdf-for-contact-form-7/issues/8#issuecomment-655514893, or unsubscribe https://github.com/notifications/unsubscribe-auth/AA2ANWJIAYELCS2FW7YXTZLR2RXA7ANCNFSM4OMLZLPA .

-- Thank you,

Trynda E. Adair Author | Developer | YouTuber www.authortryndaadair.ca http://www.authortryndaadair.ca/

restezconnectes commented 4 years ago

Hi!

I think I fix the bug..

Thanks to check it!