/** * 랜던한 문자열을 길이만큼 반환 * @param int $length * @param string $chars * @return string */ function getRandStr($length = 32, $chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890') { $chars_length = (strlen($chars) - 1); $string = $chars{rand(0, $chars_length)}; for ($i = 1; $i < $length; $i = strlen($string)) { $r = $chars{rand(0, $chars_length)}; if ($r != $string{$i - 1}) $string .= $r; } return $string; } /** * 캡차처리(getRandStr 필요함, func.other.php) * @param string $text * @param int $font_size * @param int $width * @param int $height * @param int $xpos * @param int $ypos */ function captcha($font_size, $width, $height, $xpos, $ypos) { $text = getRandStr(6, $chars = 'abcdefghijkmnpqrstuvwxyz23456789'); $_SESSION['sess_captcha'] = $text; header ("Content-type: image/png"); $im = imagecreate($width, $height); $white = imagecolorallocate ($im, 240, 240, 240); $grey = imagecolorallocate ($im, 110, 110, 110); imagettftext($im, $font_size, 0, $xpos, $ypos, $grey, CFG_LIB_PATH.'/fonts/unispace.ttf', $text); imagepng($im); imagedestroy($im); }