Web Dev Blog


Exploring web development and related foobar.

Populate Select2 from Another Select2

Update the data in a select2 widget when another select2 widget changes.


Many to Many Select2 Widget in Yii2

Select multiple related records and add new related records using Select2.


Advanced Multi-Model Forms with HASMANY Relations in Yii2

Manage multiple child models in a form, supporting validation for each model.


Advanced Multi-Model Forms in Yii2

Manage multiple models in a form, supporting validation for each model.


DDos Protection with Cloudflare and Fail2Ban

Use CloudFlare API to automatically block attacking IP addresses from visiting your server.


Goodbye Drupal7, Hello Jekyll

MrPHP.com.au has been unlatched from the shackles of, Drupal7, to a much nicer responsive theme using the new Twitter Bootstrap 3.

We’re now powered by GitHub Pages. That’s right, no PHP on MrPHP.com.au.


PHP Store Locator

Just getting some code out of my wiki. The Google Maps API part won’t work, but there is some nice distance functions and the overall concept is fine. Just needs an update on the Google Maps API.


Change Drupal7 Comments - Submitted by Guest (not verified)

By default, if an anonymous user comments on some content in your drupal site, your comments box will show something like Submitted by Guest (not verified). The user may have left a username, so we would like to use that instead.


fuser taking 100% cpu on Ubuntu 11.10

Server was running up super high load thanks to php5’s cron task.


Goodbye Drupal6, Hello Drupal7

That's right! MrPHP.com.au has officially upgraded from that 2000's feeling theme, powered by Drupal6, to a much nicer web 2.0 feeling theme powered by Drupal7 and Twitter Bootstrap.


Cache Function for PHP

This is a fantastic function that will allow you to cache your data. By default it will cache using memcache, however if you do not have memcache installed or a connection cannot be achieved it will fall back to file based cache.

The single function supports cache read, cache write, cache clear key and cache clear all. The cached data can be given an expirey time so that your data does not become stale.

Usage is very simple and the performance results of caching using memcache are fantastic.


Prevent Cron Task Overlap in CakePHP

If you have a task that runs every 5 minutes, and it takes more than 5 minutes to run then the next task will start causing even more server load. This effect may stack up and eventually cause your server to come to a grinding halt. For this reason it is very important that your scheduled tasks do not overlap.

Override Apache Settings Per Site in cPanel

I have a domain where I keep all my pictures and I would like to be able to use multiple domains to access those images.

“Well that’s easy”, I hear you saying. “Just use parked or addon Domains”.

Yes that’s a fantastic solution… Unless you need to have an SSL certificate on the site. The problem is that you can only install 1 SSL certificate per site, and the SSL certificate must match only one domain name.


Clear All Cache in Drupal

Quick code snippet, just drop this into clearcache.php and then load it in your browser.


MySQL Ordering the Group By

A problem that I have faced with SQL many times is pre-ordering the GROUP BY clause.

When you GROUP BY, MySQL will return a set of records which I call representing records. These records represent the group that is selected.

For example select id from test group by class will return one representing record per unique value of the class field. The problem with this is that you have no control over which record will represent the group.


How to Enable Register Globals in PHP 5

If you understand the potential security risks but you still need to run PHP with register_globals ON there are a couple of ways to do it.

If you have access to the servers php.ini then its fairly easy, however if you don’t have access to that file or if you are not willing to make this change server wide then there are other ways to go about it.


Multiple Primary Keys in CakePHP

If you have ever tried to deal with multiple primary keys in cakePHP then you have probably hit a brick wall at some stage. Although you still need to add a single id field, this example will allow you to save your data without needing to know the id.

Install Memcache onto cPanel running CentOS

Every time I install Memcache on cPanel I get a little bit stuck, so I wrote this quick guide in the hopes of helping myself next time and also helping other people who want the advantages of super fast caching.


Pretty Bash Prompt

Add this to your ~/.bash_profile to get a pretty prompt.


Monitor Multiple MySQL Servers using PHP

This is a quick 1 page application to monitor your replicated MySQL servers.

Use it as you will. Enjoy!