} elseif (strlen($subtext)) { imagettftext($image, 11, 0, $imageMarginLeft, 43, $color, $font, $subtext); } return $image; } private function displayImage($arrText) { header('Content-Type: image/png'); //show empty pixel if version is recent if ($arrText[0] == 0) { echo base64_decode('iVBORw0KGgoAAAANSUhEUgAAAAEAAAABAQMAAAAl21bKAAAAA1BMVEUAAACnej3aAAAAAXRSTlMAQObYZgAAAApJREFUCNdjYAAAAAIAAeIhvDMAAAAASUVORK5CYII='); exit; } //Check for cached images $strCacheName = md5($arrText[0] . '_' . $arrText[4] . '_' . $arrText[5] . '_' . $arrText[6]); $strCacheFolder = 'cache/images/'; if (file_exists($strCacheFolder . $strCacheName . '.png') && filemtime($strCacheFolder . $strCacheName . '.png') + 3600 > time()) { echo file_get_contents($strCacheFolder . $strCacheName . '.png'); exit; } else { $image = $this->createImageWithText($arrText[1], $arrText[2], $arrText[3], $arrText[0]); imagepng($image, $strCacheFolder . $strCacheName . '.png', 0); imagedestroy($image); echo file_get_contents($strCacheFolder . $strCacheName . '.png'); exit; } } } $versionCheck = new VersionCheck(); $versionCheck->handler();