<?php include 'vcode.class.php'; $vcode = new Vcode(80, 30, 4); $_SESSION['code'] = $vcode->getcode(); $vcode->outimg();
{ if (imagetypes() & IMG_GIF) { header("Content-type: image/gif"); imagegif($this->img); } elseif (function_exists("imagejpeg")) { header("Content-type: image/jpeg"); imagegif($this->img); } elseif (imagetypes() & IMG_PNG) { header("Content-type: image/png"); imagegif($this->img); } else { die("No image support in this PHP server"); } } private function createcode() { $codes = "ABCDEFGHIGKLMNOPQRSTUVWXYZ"; $code = ""; for ($i = 0; $i < $this->num; $i++) { $code .= $codes[rand(0, strlen($codes) - 1)]; } return $code; } function __destruct() { imagedestroy($this->img); } } $vcode = new Vcode(80, 30, 4); setcookie("captcha", str_rot13($vcode->getcode()), time() + 60 * 2); $vcode->outimg();