Skip to content

Instantly share code, notes, and snippets.

View stefanpejcic's full-sized avatar
:octocat:
Live long and may the source be with you

Stefan Pejcic stefanpejcic

:octocat:
Live long and may the source be with you
View GitHub Profile
@stefanpejcic
stefanpejcic / varnish.php
Created July 10, 2025 16:03
WordPress Must-use plugin for HTTPS behind Varnish Proxy
<?php
/**
* Plugin Name: HTTPS for wp-admin
* Description: Forces SSL for wp-admin via X-Forwarded-Proto.
*
* https://wpxss.com/wp-config-php/how-to-set-up-wordpress-behind-a-secure-reverse-proxy-using-nginx/
*/
add_action('muplugins_loaded', function () {
if ( isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] === 'https' ) {
# prepration
git clone https://github.com/cathugger/mkp224o.git
apt install gcc libc6-dev libsodium-dev make autoconf
cd mkp224o
./autogen.sh
./configure
make
# generation
#!/bin/bash
log_dir="/var/lib/docker/containers"
echo "Container Name | Log Size"
echo "--------------------------"
for log_file in "$log_dir"/*/*-json.log; do
container_id=$(basename "$(dirname "$log_file")")
@stefanpejcic
stefanpejcic / demo_mode_openpanel.sh
Created April 25, 2025 18:28
Properly enable demo mode for OpenPanel
# enable demo
opencli config update demo_mode on
# disaable dev
opencli config update dev_mode off
# purge all redis cache so dev_mode value is instantly active and any sensitive data removed
docker exec -it openpanel_redis redis-cli FLUSHALL
@stefanpejcic
stefanpejcic / msmtp
Created April 14, 2025 13:16
openpanel /etc/msmtp specific email address
account openpanel
host 1IP_HERE
port 465
from [email protected]
user [email protected]
password XXXXXXXXXXXXXXXXXXXX
auth login
tls off
tls_starttls off
tls_trust_file /etc/ssl/certs/ca-certificates.crt
@stefanpejcic
stefanpejcic / msmtprc
Created April 14, 2025 13:15
/etc/msmtprc for openpanel user
# /etc/msmtprc
defaults
auth off
tls off
logfile /var/log/msmtp.log
account default
host IP_HERE
port 25
from USERNAME@HOSTNAME
#!/bin/bash
function _setup_mailname() {
_log 'debug' "Setting up mailname and creating '/etc/mailname'"
echo "${DOMAINNAME}" >/etc/mailname
}
function _setup_docker_permit() {
_log 'debug' 'Setting up PERMIT_DOCKER option'
<?php
if (!defined('WHMCS')) {
die('You cannot access this file directly.');
}
add_hook('TicketOpen', 1, function ($vars) {
// Your Discord webhook URL
$discordWebhookUrl = "PUT_HERE";
@stefanpejcic
stefanpejcic / blueprints.sh
Created February 15, 2025 05:43
Install WP plugins and themes sets
#!/bin/bash
BLUEPRINTS_DIR="/var/www/blueprints"
# Function to count valid lines (ignores empty lines and comments)
count_valid_lines() {
[[ -f "$1" ]] && grep -Evc '^\s*$|^\s*#' "$1" || echo "0"
}
# Function to validate each line (must be a slug, path, or URL)
@stefanpejcic
stefanpejcic / backup.sh
Created February 12, 2025 19:16
WP backup commands
# backup database only for WP site
0 0 1,15 * * backup_dir="/var/www/backups/demo.openpanel.org/2025-02-12_19-01-00" && mkdir -p "$backup_dir" && wp db export "$backup_dir/database.sql" --path="/var/www/html/demo.openpanel.org/" --allow-root
# backup files only for WP site
0 0 1,15 * * backup_dir="/var/www/backups/stefan.openpanel.org/$(date +"%Y-%m-%d_%H-%M-%S")" && mkdir -p "$backup_dir" && cd "/var/www/html/stefan.openpanel.org/" && zip -r files.zip . && mv files.zip $backup_dir/
# backup both files and database for WP site
0 0 1,15 * * backup_dir="/var/www/backups/stefan.openpanel.org/$(date +"%Y-%m-%d_%H-%M-%S")" && mkdir -p "$backup_dir" && wp db export "$backup_dir/database.sql" --path="/var/www/html/stefan.openpanel.org/" --allow-root && cd "/var/www/html/stefan.openpanel.org/" && zip -r "$backup_dir/files.zip" . && mv files.zip $backup_dir/