Skip to content

Instantly share code, notes, and snippets.

View chrisdavidmiles's full-sized avatar
💙

Chris David Miles chrisdavidmiles

💙
View GitHub Profile
@chrisdavidmiles
chrisdavidmiles / xmlrpc.php
Created March 19, 2016 23:23
Instead of disabling or deleting xmlrpc.php in WordPress, replace it with this file, which would serve one of several sarcastic error messages at random.
<?php $possible_messages = [
'Nope',
'Go away',
'Nice try',
'XML-RPC requests on this server have been disabled cuz of people like you. This is why we can\'t have nice things.',
'We don\'t serve your kind here',
'<img src="//i.imgur.com/oeLBdQJ.png">',
'<img src="//i.imgur.com/ZZW6M6P.gif"><hr>Did you really think an xmlrpc.php attack would work on this site?',
'<img src="//i.imgur.com/OkQFngF.png"><hr>Get off my site! (And stop trying to access people\'s xmlrpc.php files.)',
@chrisdavidmiles
chrisdavidmiles / wp-connection-test.php
Last active May 29, 2016 16:23
This is a database connectivity script for WordPress. It's designed to help troubleshoot the dreaded "Error Establishing Database Connection" error. To use this tool, create a file in the same folder as wp-config.php, place this code in it, and access the file in a browser.
<?php
/**
* This is a database connectivity script for WordPress.
* It's designed to help troubleshot the dreaded "Error Establishing Database Connection" error.
*
* How does it work? It uses regular expressions to match the database settings in the wp-config.php
* and then tests those settings. If there is an error thrown, the script interprets the error and
* prints actionable information that can be used to fix the site, if at all possible. If the database
* connection works, the script will run a REPAIR on all tables in the database, and print the results.
@chrisdavidmiles
chrisdavidmiles / .htaccess
Created May 23, 2017 19:25
Secure MIME Types .htaccess
# BEGIN Secure MIME-types
<FilesMatch "\.[Jj][Pp][Ee]?[Gg]$">
ForceType image/jpeg
</FilesMatch>
<FilesMatch "\.[Pp][Nn][Gg]$">
ForceType image/png
</FilesMatch>
<FilesMatch "\.[Gg][Ii][Ff]$">
ForceType image/gif
</FilesMatch>
@chrisdavidmiles
chrisdavidmiles / keybase.md
Created June 5, 2017 03:38
Keybase Identity

Keybase proof

I hereby claim:

  • I am chrisdavidmiles on github.
  • I am chrisdavidmiles (https://keybase.io/chrisdavidmiles) on keybase.
  • I have a public key whose fingerprint is 0471 E258 8E1A DBDA 9034 1EFD A686 AD2C 7AB0 7D97

To claim this, I am signing this object:

@chrisdavidmiles
chrisdavidmiles / rollingtext.pl
Created June 6, 2017 22:10
Rolling Text in Perl
#!/usr/bin/perl
use 5.010;
use Time::HiRes qw (sleep);
sub rand_letter() {
@letters=(A..Z,a..z," ",".",",");
return $letters[rand @letters];
}
my $final_form = "Hello world";
@chrisdavidmiles
chrisdavidmiles / .htaccess
Last active July 6, 2017 07:16
Prevent POST requests to wp-login.php
<Files "wp-login.php">
ErrorDocument 403 default
RewriteCond %{REQUEST_METHOD} POST
RewriteRule .* - [F,L]
</Files>
@chrisdavidmiles
chrisdavidmiles / functions.php
Created June 13, 2017 20:49
Remove WordPress version number from both header and RSS feeds.
function chrisdavidmiles_remove_version() {return '';}
add_filter('the_generator', 'chrisdavidmiles_remove_version');
@chrisdavidmiles
chrisdavidmiles / .htaccess
Created June 13, 2017 21:01
301 redirect http:// to https:// for specified domain
RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteCond %{HTTP_HOST} ^(www.)?example\.com$
RewriteRule ^(.*)$ "https\:\/\/example\.com\/$1" [R=301,L]
@chrisdavidmiles
chrisdavidmiles / functions.php
Created June 14, 2017 01:38
Disable WordPress password reset notification email
add_filter( 'send_email_change_email', '__return_false' );
@chrisdavidmiles
chrisdavidmiles / functions.php
Created June 14, 2017 21:22
Disable WordPress password authentication. User/Pass combination will always return false, even if correct password is used. Use only if alternate login methods are in place.
remove_filter('authenticate', 'wp_authenticate_username_password', 20, 3);