$color = imagecolorallocate($image, 255, 122, 56); imagefilledellipse($image, $x, $y, $size, $size, $color); } function drawCircles($image) { $max = 12; $min = 2; $gap = $max - $min; $total = getTotalElements(); $result = getCoords(); foreach ($result as $row) { drawCircle($image, $row['x'], $row['y'], $min + $gap * ($row['total'] / $total)); } } function getTotalElements() { $result = Db::getInstance()->executeS('SELECT COUNT(`id_address`) as total FROM `' . _DB_PREFIX_ . 'address` WHERE deleted = 0 AND id_customer IS NOT NULL AND id_customer != 0'); return isset($result[0]) ? $result[0]['total'] : 0; } function getCoords() { return Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('SELECT `x`, `y`, COUNT(`id_address`) AS total FROM `' . _DB_PREFIX_ . 'address` a LEFT JOIN `' . _DB_PREFIX_ . 'location_coords` lc ON lc.`id_country`=a.`id_country` WHERE deleted = 0 AND id_customer IS NOT NULL AND id_customer != 0 GROUP BY a.`id_country` ORDER BY `total` DESC'); } $image = loadBaseImage($img_path); drawCircles($image); drawImage($image);
//create the image $img = imagecreatetruecolor(getConfig("CAPTCHA_WIDTH"), getConfig("CAPTCHA_HEIGHT")); $clr1 = explode(",", getConfig("CAPTCHA_BG_COLOR")); $clr2 = explode(",", getConfig("CAPTCHA_FONT_COLOR")); $clr3 = explode(",", getConfig("CAPTCHA_OTHERS_COLOR")); //set white background color,black text color,grey graphics $bg_color = imagecolorallocate($img, $clr1[0], $clr1[1], $clr1[2]); $text_color = imagecolorallocate($img, $clr2[0], $clr2[1], $clr2[2]); $graphics_color = imagecolorallocate($img, $clr3[0], $clr3[1], $clr3[2]); //image fill the background imagefilledrectangle($img, 0, 0, getConfig("CAPTCHA_WIDTH"), getConfig("CAPTCHA_HEIGHT"), $bg_color); //draw pass phrase imagettftext($img, getConfig("CAPTCHA_FONTSIZE"), getConfig("CAPTCHA_ANGLE"), getConfig("CAPTCHA_OFFSET"), getConfig("CAPTCHA_HEIGHT") - 6, $text_color, $font, $phrase); drawDots($img, $graphics_color); drawLines($img, $graphics_color); drawCircles($img, $graphics_color); // prevent client side caching header("Expires: Wed, 1 Jan 1997 00:00:00 GMT"); header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); header("Cache-Control: no-store, no-cache, must-revalidate"); header("Cache-Control: post-check=0, pre-check=0", false); header("Content-Transfer-Encoding: binary"); header("Pragma: no-cache"); header("Content-type:image/png"); imagepng($img); imagedestroy($img); //clean up memory ob_flush(); exit; function drawDots($img, $graphics_color) {