Add custom fonts to WordPress TinyMCE editor with @font-face

The list of fonts in the WordPress visual editor is quite short. There are plugins available to increase it, but I wanted to add my own custom font to the select dropdown. There’s no plugin hook for this, so it needs a little lateral thinking. Firstly, generate your webfont @font-face in… Continue reading

Process email bounces with PHP

This is a quick script to process email bounces, for example from a mailing list so that users can be flagged up or unsubscribed when they have too many failures. The actual bounce identification will be done by Chris Fortune’s Bounce Handler, which you can download from: http://anti-spam-man.com/php_bouncehandler/ We require… Continue reading

Monitor server cpu resources with email notification

I thought I’d write a quick script to keep an eye on which processes/users are using too many cpu cycles on my CentOS server. This checks the usage over the previous 5 minutes and emails a detailed list of cpu-hungry processes if it’s over the defined limit. Run it from cron to… Continue reading

Dovecot brute-force blocking with fail2ban

If you are getting any brute force attacks to your dovecot imap/pop3 server, install fail2ban to block the offenders. This works on CentOs 5.7. For other distributions, see the relevant websites. Firstly, install fail2ban. You should have the rpmforge repo from my previous post. Enable it first to install fail2ban:… Continue reading

IP Failover

IP Failover (proof of concept) Essentially the idea is that if your primary web server goes down, your backup server automatically takes over (failover). When your primary server is back online, it takes over again (failback). It sounds simple, but it can be very complicated and expensive to eliminate all… Continue reading

RAID error email reporting with the 3ware 9550SXU-8L and tw_cli

This is a follow up to my previous post dmraid error reporting by email, this time for a hardware raid controller, this one is the 3ware/AMCC 9550SXU-8L. The concept is exactly the same, the only thing different is the script that checks the raid array status. We will be using… Continue reading

PHP Recursive File Copy Function

I couldn’t find a function online that copies folders recursively in PHP and actually works, so I wrote my own: function recursiveCopy($src, $dest) { if (is_dir($src)) $dir = opendir($src); while ($file = readdir($dir)) { if ($file != ‘.’ && $file != ‘..’) { if (!is_dir($src.’/’.$file)) copy($src.’/’.$file, $dest.’/’.$file); else { @mkdir($dest.’/’.$file,… Continue reading