Skip to content

Instantly share code, notes, and snippets.

View Digiover's full-sized avatar
💭
☕️

Jan Reilink Digiover

💭
☕️
View GitHub Profile
@Digiover
Digiover / clear-opcode-caches.php
Last active January 27, 2024 14:05
WordPress: Clear PHP opcode caches before updates are applied, ease the updating process (https://www.saotn.org/wordpress-plugin-flush-php-opcache/)
<?php
/**
* Plugin Name: Clear PHP opcode caches
* Plugin URI: https://www.saotn.org/wordpress-plugin-flush-php-opcache/
* Donate URI: https://www.paypal.me/jreilink
* Description: Purges various PHP opcode and user caches. Currently it tries to clear / purge / flush PHP OPcache and WinCache caches from your web server's memory. This should ease WordPress updates and plugin activation / deactivation.
* Network: True
* Version: 1.2
* Author: Jan Reilink
* Author URI: https://www.saotn.org
@Digiover
Digiover / web.config
Created January 16, 2018 10:47
ASP.NET set httpOnly and RequireSSL cookies
<httpCookies httpOnlyCookies="true" requireSSL="true" />
<!-- With domain: <httpCookies domain="www.saotn.org" httpOnlyCookies="true" requireSSL="true" /> -->
@Digiover
Digiover / web.config
Created January 16, 2018 10:45
Encrypt ASP.NET ViewState
<machineKey
validationKey="AutoGenerate,IsolateApps"
decryptionKey="AutoGenerate,IsolateApps"
validation="AES" decryption="Auto"
/>
@Digiover
Digiover / make-readonly.php
Last active November 23, 2016 17:26
Make WordPress writable before, and read-only after, WordPress updates with this MU-Plugin
<?php
/**
* Plugin Name: Make Read Only &amp; Clear Read Only WordPress
* Plugin URI: https://www.saotn.org
* Description: Makes all WordPress files read-only after updates, and writable just before updates. This should ease WordPress updates when it's read-only on the file system. Please donate <a rel="nofollow" target="_blank" href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&amp;hosted_button_id=J24FGGU96YSUY" title="donate to Sysadmins of the North in Dollars">$2.50 USD</a> (or <a rel="nofollow" target="_blank" href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&amp;hosted_button_id=QLX4RPPL3L8LY" title="donate to Sysadmins of the North in Euros">&euro; 2,50 Euro</a>) through PayPal to support me in my research time and hosting costs.
* Network: True
* Version: 1.0
* Author: Jan Reilink
* Author URI: https://www.saotn.org
* License: GPLv2
@Digiover
Digiover / cache_enabler_disk.class.php.patch
Created October 25, 2016 09:42
Diff for cache_enabler_disk.class.php to add wp_is_mobile() support to KeyCDN's Cache Enabler plugin
--- cache_enabler_disk.class.php.org 2016-09-26 07:24:22.000000000 +0200
+++ cache_enabler_disk.class.php 2016-10-24 16:33:54.145108306 +0200
@@ -24,7 +24,9 @@
*/
const FILE_HTML = 'index.html';
+ const FILE_HTML_MOBILE = 'index-mobile.html';
const FILE_GZIP = 'index.html.gz';
+ const FILE_GZIP_MOBILE = 'index-mobile.html.gz';
const FILE_WEBP_HTML = 'index-webp.html';
@Digiover
Digiover / add-hsts-to-wordpress.php
Last active January 15, 2022 07:15
Add HSTS to WordPress using a send_headers action
<?php
/*
* https://www.saotn.org/enable-http-strict-transport-security-hsts-on-iis/
* follow me on Twitter: @Jan_Reilink
*/
add_action( 'send_headers', 'saotn_add_hsts_header' );
function saotn_add_hsts_header() {
header( 'Strict-Transport-Security: max-age=31536000; includeSubDomains; preload' );
}
@Digiover
Digiover / disable_php_script_execution.php
Last active January 15, 2022 07:16
Function to disable PHP script execution for WordPress wp-content/uploads folder
<?php
/**
* Disable PHP script execution for WordPress wp-content/uploads folder.
* - based off the WordPress permalinks rewrite code
*
* - https://www.saotn.org/secure-wordpress-uploads-folder-disable-php-execution/
* - follow me on twitter: @Jan_Reilink
*
* don't allow this file to be loaded directly
*/
@Digiover
Digiover / prefetch-prerender-posts.php
Last active January 15, 2022 07:16
Prefetch and prerender WordPress posts with a function hook add_action
<?php
function saotn_post_prerender_prefetch() {
/* follow me on Twitter: @Jan_Reilink */
$next_post = get_next_post();
$prev_post = get_previous_post();
if ( !empty( $next_post ) ) {
echo '<link rel="prefetch" href="'.get_permalink( $next_post->ID ).'" />
<link rel="prerender" href="'.get_permalink( $next_post->ID ).'" />';
}
if ( !empty( $prev_post ) ) {
@Digiover
Digiover / AdSense-in-WordPress.php
Last active January 15, 2022 07:17
Create Google AdSense shortcode for in WordPress
<?php
/*
* enqueue adsbygoogle.js in the footer &
* create a WordPress shortcode with your Google AdSense code
* follow me on Twitter: @Jan_Reilink
*/
function saotn_loadAdsByGoogleJs() {
wp_register_script( 'google-adsense', '//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js', '', '', true );
wp_enqueue_script( 'google-adsense' );
@Digiover
Digiover / Blacklistcheck.ps1
Last active January 15, 2022 07:17
Blacklistcheck.ps1 - checks an IP address in various blacklists (DNSBL, RBL), in PowerShell
# blacklistcheck.ps1 - PowerShell script to check
# an IP address blacklist status
#
# Follow me on Twitter: @Jan_Reilink
#
# Steps:
# 1. IPv4 IP address input from the command-line:
# .\blacklistcheck.ps1 1.2.3.4
# 2. reverse the IP address: 1.2.3.4 becomes 4.3.2.1
# 3. append the blacklist zone, e.g .cbl.abuseat.org.