Install PHP 7.4 on CentOS 8

This is surprisingly simple if you don’t want to mess around with multiple versions and just switch to 7.4. Run as root: # dnf -y module reset php# dnf -y module install php:7.4 Then in my installation a few pecl modules needed to be reinstalled (zip needs the extra step below): # pecl uninstall imagick […]

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 […]

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: […]

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, 0750); recursiveCopy($src.’/’.$file, $dest.’/’.$file); } //else […]

CentOS: Install PHP 5.2 with t1lib support

The first step is to vanilla install PHP 5.2 (to handle any dependency issues) and then recompile it with the t1lib option. So enable the testing repo of CentOS 5. Change to root user first, then create the repo: su – vi /etc/yum.repos.d/CentOS-Testing.repo Enter insert mode (hit i) and paste the following into the new […]