Skip to content

Instantly share code, notes, and snippets.

View gbot's full-sized avatar

GB gbot

View GitHub Profile
@gbot
gbot / dns_check.sh
Last active October 10, 2022 04:15
Use 'nslookup' to query one or more domains, using a pre-defined list of nameservers
#!/bin/bash
# what's this all about then?
description="Use 'nslookup' to query one or more domains, using a pre-defined list of nameservers"
# set nameservers as associative array
declare -A nameservers
nameservers['AdGuard DNS']='94.140.14.14'
nameservers['Alternate DNS']='76.76.19.19'
nameservers['CloudFlare']='1.1.1.1'
@gbot
gbot / jail.local
Last active October 6, 2021 23:15
Fail2Ban filter, jail and action (Slack message) for WordPress login failures on Spinup WP servers
[wordpress]
enabled = true
filter = wordpress
action = iptables-multiport[name="wordpress", port="http,https"]
slack-notify[name="wordpress"]
logpath = /sites/*/logs/access.log
/var/log/nginx/access.log
maxretry = 5
@gbot
gbot / wp_multisite_cron.sh
Last active September 1, 2021 00:02
Call wp-cron.php on WP Multisite installations
#!/bin/bash
# Call wp-cron.php on WP Multisite installations
# Requires WP-CLI
# Looks for WP_PATH in {user_home}/wp-cli.yml, otherwise must pass in as $1
# Set up cron job with crontab -e
# Use MAILTO to send output to email or write to a log file 'bash ~/wp_multisite_cron.sh >> crontab.log'
# MAILTO=admin@email.nz
# */1 * * * * bash ~/wp_multisite_cron.sh [WP_PATH]
@gbot
gbot / hash_password.php
Created October 16, 2018 22:16
Hash a string with PHP's password_hash() function.
<?php
// Hash a password
// by Gavin Botica
// requires PHP 5.5+
define("RQD_PHP_VER", "5.5");
// check php version
if (version_compare(PHP_VERSION, RQD_PHP_VER) == -1 ) {
echo "<p><b>ERROR:</b> PHP <i>" . RQD_PHP_VER . "</i> required. Version <i>" . PHP_VERSION . "</i> installed.</p>";
@gbot
gbot / wp_offload_media_db_migrate.json
Last active March 20, 2023 20:24
Migrate a WordPress database so that existing media items are served from Amazon S3 or CloudFront. Requires the WP Offload S3 Lite plugin.
{
"use_https": "",
"purge_amazonS3_info": ""
}
@gbot
gbot / wp-xmlrpc-jail.local
Last active July 26, 2023 17:07
Fail2Ban WordPress XMLRPC Jail and Filter. Notes: log path is set for Plesk v12.x. Change this to appropriate path for your set up. Only works if WordPress is installed in webroot, edit the Filter failregex if installed in sub-directory.
[wp-xmlrpc]
enabled = true
filter = wp-xmlrpc
action = iptables-multiport[name=wp-xmlrpc, port="http,https"]
logpath = /var/www/vhosts/system/*/logs/*access*log
/var/log/httpd/*access_log
bantime = 86400
maxretry = 0
@gbot
gbot / woocommerce-login-logout-redirects.php
Last active November 16, 2021 10:11
WP: Redirect to home page for WooCommerce login and logout. #ST3
/*----------------------------------------------------------------------------*/
// redirects for login / logout
/*----------------------------------------------------------------------------*/
add_filter('woocommerce_login_redirect', 'login_redirect');
function login_redirect($redirect_to) {
return home_url();
}
@gbot
gbot / wp-login-jail.local
Last active October 10, 2015 21:00
Fail2Ban WordPress login failure Jail and Filter. Notes:The log path uses 'access*_log' to monitor http and https logins. This will only work if WordPress is installed the webroot. Tweaking the failregex would be required to work with installs in sub-directories.
[wp-login]
enabled = true
filter = wp-login
action = iptables-multiport[name=wp-login, port="http,https"]
sendmail[dest="name@domain.com", sendername="Fail2Ban", sender="fail2ban", name="wp-login"]
logpath = /var/www/vhosts/system/*/logs/access*_log
maxretry = 5
findtime = 60
bantime = 1200