2022-06-06 21:30:34 +00:00
|
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
Class Captcha{
|
|
|
|
|
|
2023-01-10 16:29:32 +00:00
|
|
|
|
public $imgDir = 'images'; // директория где хранятся изображения
|
2022-06-06 21:30:34 +00:00
|
|
|
|
|
2023-01-10 16:29:32 +00:00
|
|
|
|
public $length = '5'; // количество цифр в капче
|
2022-06-06 21:30:34 +00:00
|
|
|
|
|
|
|
|
|
public function __construct(){
|
|
|
|
|
|
|
|
|
|
$this->keystring=array();
|
|
|
|
|
|
|
|
|
|
for($i=0;$i < $this->length;$i++){
|
|
|
|
|
$this->keystring[] .= mt_rand(0,9);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public function draw(){
|
|
|
|
|
$img = '';
|
|
|
|
|
foreach($this->keystring as $keystring){
|
|
|
|
|
$img .= '<img src="'.$this->imgDir.DIRECTORY_SEPARATOR.$keystring.'.gif" border="0">';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return $img;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public function getKeyString(){
|
|
|
|
|
return implode($this->keystring);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
?>
|