JMBsoft TGPx modified for php 5.x