Looks like a modified version of this, http://hawkee.com/snippet/7416/


Replace $chan1 and $chan2 with $chan