Skip to content

Instantly share code, notes, and snippets.

{
"landingPage": "/pdf.php",
"steps": [
{
"step": "writeFile",
"path": "/wordpress/pdf.php",
"data": "<?php $pdf = '%PDF-1.1\n\n '; $pdf .= '1 0 obj\n '; $pdf .= '<<\n '; $pdf .= '/Type /Catalog\n '; $pdf .= '/Outlines 2 0 R\n '; $pdf .= '/Pages 3 0 R\n '; $pdf .= '>>\n '; $pdf .= 'endobj\n\n '; $pdf .= '2 0 obj\n '; $pdf .= '<<\n '; $pdf .= '/Type /Outlines\n '; $pdf .= '/Count 0\n '; $pdf .= '>>\n '; $pdf .= 'endobj\n\n '; $pdf .= '3 0 obj\n '; $pdf .= '<<\n '; $pdf .= '/Type /Pages\n '; $pdf .= '/Kids [4 0 R]\n '; $pdf .= '/Count 1\n '; $pdf .= '>>\n '; $pdf .= 'endobj\n\n '; $pdf .= '4 0 obj\n '; $pdf .= '<<\n '; $pdf .= '/Type /Page\n '; $pdf .= '/Parent 3 0 R\n '; $pdf .= '/MediaBox [0 0 595.28 841.89]\n '; $pdf .= '/Contents 5 0 R\n '; $pdf .= '/Resources << /Font << /F1 6 0 R >> >>\n '; $pdf .= '>>\n '; $pdf .= 'endobj\n\n '; $pdf .= '5 0 obj\n '; $pdf .= '<< /Length 44 >>\n '; $pdf .= 'stream\n '; $pdf .= 'BT\n '; $pdf .= '70 50 TD\n ';
{
"landingPage": "/",
"steps": [
{
"step": "writeFile",
"path": "/wordpress/wp-content/mu-plugins/error.php",
"data": "<?php error_log('This is broken');"
}
]
}
@bgrgicak
bgrgicak / permalink-blueprint.json
Last active March 8, 2024 07:24
Set permalink structure
@bgrgicak
bgrgicak / all-features-blueprint.json
Last active March 8, 2024 07:28
Start Playground with PHP extensions and networking
{
"landingPage": "/wp-admin/plugin-install.php",
"phpExtensionBundles": [
"kitchen-sink"
],
"features": {
"networking": true
},
"steps": [
{
@bgrgicak
bgrgicak / debug-log.php
Created November 18, 2022 13:10
PHP pretty print objects and arrays in a log file
function debug( $message, $label = '', $log_file = 'debug.log' ) {
if ( is_bool( $message ) ) {
$message = $message ? 'true' : 'false';
} else if ( is_array( $message ) || is_object( $message ) ) {
$message = json_encode(
$message,
JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES
);
}
openssl aes-256-cbc -a -salt -pbkdf2 -in .env -out .env.enc
openssl aes-256-cbc -d -a -pbkdf2 -in .env.enc -out .env
@bgrgicak
bgrgicak / import-runner.sh
Created July 13, 2021 10:38
WC Admin analytics import runner. Used to run https://gist.github.com/bgrgicak/de6c675c832276ae852cb3330f448e62 and restert it if ti fails.
#!/bin/bash
TOTAL=${1:-5}
echo "Import runner started"
while :
do
ACTIVE=$(ps -aux | grep import-wc-admin-orders.sh | grep -c -v grep)
echo "Active importers: $ACTIVE/$TOTAL"
@bgrgicak
bgrgicak / import-wc-admin-orders.sh
Last active July 13, 2021 10:44
Import WooCommerce Admin orders using the Action scheduler CLI
#!/bin/bash
cd /var/www/
wp action-scheduler run --batch-size=10 --hooks=wc-admin_queue_batches_orders,wc-admin_import_batch_orders 2>&1 | awk -v commandid=$1 '{ "date +%Y-%m-%d\\ %T.%3N" | getline timestamp; print timestamp, commandid, $0; fflush(); }' >> ~/cli.log