Convert HTML table to CSV

Just a quick one – I needed a script to convert a table to a csv, so this is what I came up with. See the annotations for notes: //html table is in variable $report $report = str_replace(array(“\n”, “\r”), “”, $report); //remove existing line breaks $report = str_replace(‘”‘, ‘\”‘, $report); //escape existing quote marks $csv_lines […]

Linode Xen to KVM upgrade breaks quotas

On a Linode Virtualmin CentOS 6 the upgrade from Xen to KVM breaks quotas with the following error: repquota: Cannot stat() mounted device /dev/root: No such file or directory The issue is that the symbolic link /dev/root is linking to /dev/xvda which has been replaced by /dev/sda so the symlink just needs to be replaced: […]

Fix nss-softokn rpm/yum issue in CentOS 6

The recent update to nss-softokn breaks rpm/yum updates in CentOS 6. To restore functionality run these commands: For 64-bit: # wget http://mirror.centos.org/centos/6/updates/x86_64/Packages/nss-softokn-freebl-3.14.3-19.el6_6.x86_64.rpm # rpm2cpio nss-softokn-freebl-3.14.3-19.el6_6.x86_64.rpm | cpio -idmv # cd lib64 # cp libfreeblpriv3.* /lib64 # yum update For 32-bit: # wget http://mirror.centos.org/centos/6/updates/i386/Packages/nss-softokn-freebl-3.14.3-19.el6_6.i686.rpm # rpm2cpio nss-softokn-freebl-3.14.3-19.el6_6.i686.rpm | cpio -idmv # cd lib # cp libfreeblpriv3.* […]

WordPress Distributed Botnet Attack Blocker

After the recent global distributed botnet attack on WordPress installations that took down servers and broke into admin accounts, I thought I’d write a plugin to prevent it happening again. Distributed botnet attacks can come from multiple IP addresses and locations at the same time, so conventional IP-based lockouts are not effective (e.g. those found […]

Cover your Paypal fees

I just thought I’d share a formula I worked out a few years ago when a client asked me to make sure his Paypal website payments were covering the Paypal fees – so that he got the full amount he was asking for. In the UK, Paypal standard fees are 3.4% plus 20p. So if […]

Postfix automated backup/secondary email server with Virtualmin

There are various guides online for setting up Postfix as a backup (hold and forward) mail server which knows which accounts are valid on the primary (to prevent backscatter spam, so it only accepts emails for actual accounts that exist on the primary mail server). All of them are slightly different and none of them […]

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 3 files from that package: […]