FLANKING
[To determine] whether two friendly[, non-helpless] characters flank an opponent in the middle, trace [the shortest possible] imaginary line between the two friendly characters’ centers. If the line passes through opposite borders of the opponent’s space (including corners of those borders), then the opponent is flanked. [Note that if the opponent is unaware of either of the two friendly characters, or if either of the friendly characters is unaware of the other or the opponent, the opponent is not flanked.*] [If you want to explicitly limit it to melee only, then you need to also add something like: You are not considered flanking when making any ranged attack.]
When [flanking and] making a melee attack, you get a +2 flanking bonus if your opponent is threatened by a character or creature friendly to you on the opponent’s opposite border or opposite corner.
Exception: If a flanker takes up more than 1 square, it gets the flanking bonus if any square it occupies counts for flanking.
Only a creature or character that threatens the defender can help an attacker get a flanking bonus. [^Stricken as redundant]
Creatures with a reach of 0 feet can’t flank an opponent.