Skip to content

Instantly share code, notes, and snippets.

View richard-wolsch's full-sized avatar

Richard Wolsch richard-wolsch

View GitHub Profile
@richard-wolsch
richard-wolsch / cucumber_tags.md
Created March 22, 2024 13:32
Use Cucumber tags in context files

If you want to check out the @tags within a .feature file inside your Cucumber test context, then your context class should just use the following trait:

CucumberTagsTrait

<?php

namespace App\Tests\Context\Tags;

use Behat\Behat\Hook\Scope\BeforeScenarioScope;

S/MIME Encryption and Signature with PHPMailer

Note: Encryption and Signing is a matter of security. Make sure to review this code! It may contain security flaws.

This extension of PHPMailer allows to send S/MIME encrypted and singed emails. The SecurePhpMailer class may be found below.

In your code you will have to call:

$mailer = new SecurePhpMailer();
@richard-wolsch
richard-wolsch / convert-fpdf-form.php
Last active December 19, 2022 11:05
Preprocess a PDF form to fill it with FPDF: This will give unique names to all fields, flip checkbox options (yes needs to be before no) and makes all fields readonly.
<?php
echo "\e[32mConvert the form in a PDF to be used by FPDF. This will rename all form fields.\e[39m\n";
$filename = readline("PDF Path: ");
$content = file_get_contents($filename);
// ==== TASK 1 ====
// Find all text input fields and give them unique names.
// Solves: PDF forms are sometimes organized in groups where a form field has children (“/Kids”). Children of different
// groups could have the same field names. FPDF can't handle that.