Welcome to the LimeSurvey Community Forum

Ask the community, share ideas, and connect with other LimeSurvey users!

Create PDF with token and QR code

More
2 years 4 months ago #242646 by evaluation2023
That looks pretty good - I got it work to create individual qr codes with token and save it temporary on the server and put 5 codes per page (with a "for"-function). Unfortunately "NewDirectRequest" does not work - I open a bug report...

400: Falsche Anfrage Der CSRF-Token konnte nicht verifiziert werden.

PHP Version 8.0.28
Version 5.6.4+230206

Please Log in to join the conversation.

More
2 years 4 months ago #242653 by evaluation2023
And could you post the code of your solution? Would be very helpful ;-)

PHP Version 8.0.28
Version 5.6.4+230206

Please Log in to join the conversation.

More
2 years 4 months ago #242654 by DenisChenu

That looks pretty good - I got it work to create individual qr codes with token and save it temporary on the server and put 5 codes per page (with a "for"-function). Unfortunately "NewDirectRequest" does not work - I open a bug report...

400: Falsche Anfrage Der CSRF-Token konnte nicht verifiziert werden.
 
No : it's not an issue
See www.limesurvey.org/manual/NewUnsecureRequest
 

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member. - Professional support - Plugins, theme and development .
I don't answer to private message.

Please Log in to join the conversation.

More
2 years 4 months ago #242672 by evaluation2023
Many thanks for your help, Dennis and Joffm! - unfortunately I tried to use "NewUnsecureRequest" - so in the function which shows the <form>- with an number-input and a send button i added the url which sends then to /plugins/unsecure ... but the viewed page then is blank with no code :-(

So in my class now I have two functions, one is the "index-Function" which shows the <form> with <input number> and <button> and the other is the "create"-function which gets the <input number> and the survey id and then successfull generates the PDF with QR-Codes.... but just, when I access the url manually ...

My question: How can I get it work to call the create-function from the index-function without getting the CSRF-Errors ... I tried to understand your examples, but didn't get it to work...

Maybe I could get a look at Joffm's solution ;-)

PHP Version 8.0.28
Version 5.6.4+230206

Please Log in to join the conversation.

More
2 years 4 months ago #242679 by DenisChenu
I don't really understand the purpose of using NewDirectRequest , but if it work with NewDirectRequest : it work with NewUnsecureRequest : it's exactly the same fuinctoion except unsecure are ,not CRSF protected

BUT : since it's a plugin for admin : why not pluginhelper

www.limesurvey.org/manual/Add_new_menu_and_view_by_a_plugin

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member. - Professional support - Plugins, theme and development .
I don't answer to private message.

Please Log in to join the conversation.

More
2 years 4 months ago #242680 by evaluation2023
I tried for 4 hours to solve the problem. Now I just renamed the previous function to "public function NewUnsecureRequest" on a trial basis thanks to your hint and it works. Great.
Is it also "secure" to use this function or is the system then vulnerable?

PHP Version 8.0.28
Version 5.6.4+230206

Please Log in to join the conversation.

More
2 years 4 months ago #242681 by evaluation2023
One stupid question more (sorry...)

I want to add a "valid from" and "valid until" - Date Picker in the form of my plugin (using /admin/pluginhelper)

In my form I added the code: 
Code:
$dateFrom = Yii::app()->getController()->widget('ext.DateTimePickerWidget.DateTimePicker', [
                                'name' => 'validfrom',
                                'value' => $validfrom ?? '',
                                'pluginOptions' => [
                                    'format' => "DD.MM.YYYY HH:mm",
                                    'allowInputToggle' => true,
                                    'showClear' => true,
                                    'locale' => 'de'
                                ]
                            ]);

Then I get a 500-message:
"500: Interner Serverfehler Object of class DateTimePicker could not be converted to string"

Any ideas?

 

PHP Version 8.0.28
Version 5.6.4+230206

Please Log in to join the conversation.

More
2 years 4 months ago #242877 by evaluation2023
Update: Got it work now... 
When I click on the button, PDF is created with individuale QR-Codes and sent to browser for download

Many thanks for the help!

PHP Version 8.0.28
Version 5.6.4+230206

Please Log in to join the conversation.

Moderators: tpartnerholch

Lime-years ahead

Online-surveys for every purse and purpose