Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 10/18/2020 in all areas

  1. v0.3.2 released. This version reverts to the hook methods used in v0.2.3 and earlier of this module now that the core circular reference issue was fixed in PW v3.0.166. To upgrade to v0.3.2 you must be running PW v3.0.166 or newer, which is currently only available on the dev branch.
    4 points
  2. Well, I just tested out this on PW 3.0.167, and it works as expected: $user_roles = user()->roles; $user_roles_count = count($user_roles); // make sure the current user has more than just default "guest" role if (($user_roles_count > 1) && !input()->post->ts) { $u_name = user()->name; $u_id = user()->id; $here = page()->url; $ts = time(); $form = <<<EOF <h1>Hello $u_name . Would you like to change your password?</h1> <form method="post" action="$here"> <label for="new_pass">New password: <input type="password" id="new_pass" name="new_pass" autocomplete="false"> </label> <label for="new_pass2">Confirm new password: <input type="password" id="new_pass2" name="new_pass2" autocomplete="false"> </label> <input type="hidden" id="uid" name="uid" autocomplete="false" value="$u_id"> <input type="hidden" id="uname" name="uname" autocomplete="false" value="$u_name"> <input type="hidden" id="ts" name="ts" autocomplete="false" value="$ts"> <button type="submit">Change your password</button> </form> EOF; echo $form; } if (input()->post->ts && input()->post->new_pass && input()->post->new_pass2 && input()->post->uid) { $out = ''; $errCount = 0; $form_uid = input()->post->uid; $form_uname = input()->post->uname; $curr_uid = user()->id; $curr_uname = user()->name; $form_new_pass = input()->post->new_pass; $form_new_pass2 = input()->post->new_pass2; $form_ts = (int)input()->post->ts; $max_time = 30 * 60; // 30 minutes // If the POST arrives a half hour later, something is probably fishy if ($form_ts < (time() - $max_time)) { $errCount++; $out = "It seems that it took you longer than 30 minutes to change your password - your request has been blocked due to security concerns. Please try again."; } // user has maybe manipulated the hidden form input fields if (($curr_uid != $form_uid) || ($curr_uname != $form_uname)) { $errCount++; $out = "Your request has been blocked due to security concerns. Please try again."; } // for added security, I would highly suggest to take this note seriously @ https://cheatsheet.processwire.com/user/user-properties/user-pass/ // "you will need to add your own complexity checks for passwords to ensure they meet a minimum length and character requirement." // I'm not sure if there is an API sanitizer method available for this purpose // below is just a basic check to ensure both pw-field values are identical if (($form_new_pass !== $form_new_pass2)) { $errCount++; $out = "Your new passwords do not match. Please try again."; } // If we've got that far, we're ready to update the user's PW if ($errCount < 1) { $user_page = users()->get($curr_uid); $user_page->of(false); $user_page->pass = $form_new_pass; $user_page->save(); $out = "Success! Your account has been updated with the new password you've chosen."; } echo $out; } If syntax like user()->roles doesn't work in your installation, you can either enable it in site/config.php ($config->useFunctionsAPI = true;) or re-write it with $user / $page / $input notation.
    2 points
  3. This week a second new module for processing Stripe payments has been added to FormBuilder. Unlike our other Stripe Inputfield for FormBuilder, this new one uses Stripe Checkout and supports 3D Secure (SCA) payments. We’ll take a closer look at it in this blog post, plus we’ve got a live demo of it here too— https://processwire.com/blog/posts/stripe-payment-processor-form-builder/
    1 point
  4. Relatively recently released: https://github.com/LINCnil/GDPR-Developer-Guide (GDPR guide for developers, v1.0)
    1 point
  5. Just a quick heads-up that Wireframe 0.17.0 went live a few hours ago. Versions 0.15.0 .. 0.17.0 mostly included behind-the-scenes improvements and refactoring for existing features, so didn't think these were particularly interesting. Full changelog can be found from CHANGELOG, as usual. Probably the one and only feature that might come in handy during development is the shortcut method for defining view template and view at the same time (to use a view from a specific template instead of current one), added in 0.16.0: <?php // find blog posts and render them using the "list_item" view of the "article" template: ?> <ul> <?php foreach ($pages->find('template=blog-post') as $post): ?> <?= $post->setView('article/list_item')->render() ?> <?php endforeach; ?> </ul> On a loosely related note I've removed the "WIP" label from the topic of this thread, and am considering submitting the module to the modules directory. I think it's long overdue, really ?
    1 point
  6. Thanks for another great module @bernhard Wanted to share my experiences changing from Pages2PDF to RockPdf. Wasn't quite as straightforward as I'd hoped. Such is life, but I got there. Pages2Pdf uses mPDFv5+ while RockPdf uses mPDFv7+ and I needed some of the newer features. Things Iearned along the way: 1. If you need to use @page, you lose everything in the template $pdf->set('header', '...'); settings. This has nothing to do with RockPdf but a 'feature' of mPDF 2. It's much easier to add custom fonts to RockPdf than Pages2PDF 3. You can display images in a circle using background-image but they don't print so that's not helpful, LOL This is NOT a full tutorial but hopefully will give you some pointers on how I got RockPdf working for a fairly specific PDF design. RockPdf template settings: <?php $pdf = $modules->get('RockPdf'); $pdf->settings([ 'fontdata' => (new \Mpdf\Config\FontVariables())->getDefaults()['fontdata'] + [ "montserrat" => [ 'R' => "montserrat-regular.ttf", 'B' => "montserrat-bold.ttf", ], "montserratlight" =>[ 'R' => "montserrat-light.ttf" ], "montserratthin" => [ 'R' => "montserrat-thin.ttf" ] ], 'defaultheaderline' => 0, 'font_size' => 9, 'mode' => 'utf-8', 'font' => 'montserrat', 'page_format' => 'A4', ]); $css = wireRenderFile($config->paths->templates . 'RockPdf/styles-v3.css'); $pdf->write("<style>" . $css . "</style>"); $body = wireRenderFile($config->paths->templates . 'RockPdf/profile_pdf_cv-v3.php'); $pdf->write($body); $pdfFile = $sanitizer->pageName($profile->title) . "-" . $profile->id . ".pdf"; $pdf->show($pdfFile); die(); // Remove old Pages2PDF settings // $mpdf->markupMain = $config->paths->templates . 'RockPdf/profile_pdf_cv-v3.php'; // $mpdf->markupHeader = $config->paths->templates . 'RockPdf/_header-v3.php'; // $mpdf->markupFooter = $config->paths->templates . 'pages2pdf/_footer-v2.php'; // $mpdf->cssFile = $config->paths->templates . 'RockPdf/styles-v3.css'; // $mpdf->pageOrientation = 'P'; // $mpdf->pageFormat = 'A4'; // $mpdf->topMargin = 9.5; // $mpdf->rightMargin = 0; // $mpdf->bottomMargin = 9; // $mpdf->leftMargin = 0; // $mpdf->headerMargin = 0; // $mpdf->footerMargin = 0; // $mpdf->fontSize = 9; // $mpdf->mode = 's'; // $mpdf->font = 'montserrat'; Header code: <div style=" background-color: #007ee5; height: 10mm; margin: 0; top: 0; left: 0; right: 0; width: 100%; "> </div> Page layout code: <?php // header is the same on all pages but need more spacing on all pages except the first $header = wireRenderFile($config->paths->templates . 'RockPdf/_header-v3.php'); ?> <htmlpageheader name="myHeaderFirst" style="display:none"> <?=$header?> </htmlpageheader> <htmlpageheader name="myHeader" style="display:none"> <?=$header?> </htmlpageheader> <sethtmlpageheader name="myHeaderFirst" value="on" show-this-page="1" /> <sethtmlpageheader name="myHeader" value="on" /> <div class="user-dets"> CSS: /* Additional fonts added to: site/assets/RockPdf/fonts */ @page { margin: 15mm 0 0 0; /* <any of the usual CSS values for margins> */ /*(% of page-box width for LR, of height for TB) */ margin-header: 0; /* <any of the usual CSS values for margins> */ margin-footer: 9mm; /* <any of the usual CSS values for margins> */ marks: none;/*crop | cross | none*/ header: html_myHeader; } @page :first { margin: 9.5mm 0 0 0; /* <any of the usual CSS values for margins> */ /*(% of page-box width for LR, of height for TB) */ margin-header: 0; /* <any of the usual CSS values for margins> */ margin-footer: 9mm; /* <any of the usual CSS values for margins> */ marks: none;/*crop | cross | none*/ header: html_myHeaderFirst; } Hope this is useful. Cheers psy
    1 point
×
×
  • Create New...