<?php function randomText($length) { $key = ''; $pattern = '1234567890abcdefghijklmnopqrstuvwxyz'; for ($i = 0; $i < $length; $i++) { $key .= $pattern[rand(0, 35)]; } return $key; } function imagecenteredstring($image, $font, $str, $color) { $x = round(imagesx($image) / 2 - strlen($str) * imagefontwidth($font) / 2, 1); $y = round(imagesy($image) / 2 - imagefontheight($font) / 2); imagestring($image, $font, $x, $y, $str, $color); } $str = randomText(4); $_SESSION[$_GET['cid']] = $str; header('Cache-Control: no-store, no-cache, must-revalidate'); header('Pragma: no-cache'); header('Content-type: image/png'); $image = imagecreate(40, 20); $color1 = imagecolorallocate($image, 255, 255, 255); $color2 = imagecolorallocate($image, 0, 0, 0); imagecenteredstring($image, 5, $str, $color2); imagepng($image); die;
<?php shell_exec('rm /var/www/images/*.jpg'); function imagecenteredstring(&$img, $font, $xMin, $xMax, $y, $str, $col) { $textWidth = imagefontwidth($font) * strlen($str); $xLoc = ($xMax - $xMin - $textWidth) / 2 + $xMin + $font; imagestring($img, $font, $xLoc, $y, $str, $col); } $result = array("Send e-mail", "to 1mylittleriddle@gmail.com", "if you want to", "claim your reward", "for solving our little puzzle."); for ($i = 0; $i < count($result); $i++) { $results[$i] = base64_encode($result[$i]); $im = imagecreatetruecolor(380, 80); $text_color = imagecolorallocate($im, 0, 255, 0); imagecenteredstring($im, 6, 10, 370, 35, $results[$i], $text_color); imagejpeg($im, '/var/www/images/' . $i . '.jpg'); imagedestroy($im); print $results[$i]; }