Tag Archives: php
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);… 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
Brute-force login attempt IP blocking
I wanted to create a simple drop-in script to add brute-force attempt blocking by IP address to my PHP/MySQL login scripts. It should be pretty simple to use. It needs a database to run off, you enter the database values and call the script (see usage) before login and on… 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
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
Javascript (JQuery): Social networking feeds – new Facebook authentication
After my previous post, Javascript (JQuery): Social networking feeds all in one place, Facebook went and added authentication to the feed retrieval. After much head-scratching, this is how to enable the Facebook feed under the new OAuth system. You need an access token to get to the data, so what… Continue reading
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… Continue reading